blob: 229f8d6937c8cbab19e33892ace9953bae3e8afa [file] [log] [blame]
Harald Welte28d943e2017-11-25 15:00:50 +01001module BSC_Tests {
2
Harald Welte21b46bd2017-12-17 19:46:32 +01003/* Integration Tests for OsmoBSC
Harald Weltea0630032018-03-20 21:09:55 +01004 * (C) 2017-2018 by Harald Welte <laforge@gnumonks.org>
Harald Welte21b46bd2017-12-17 19:46:32 +01005 * All rights reserved.
6 *
7 * Released under the terms of GNU General Public License, Version 2 or
8 * (at your option) any later version.
9 *
Harald Welte34b5a952019-05-27 11:54:11 +020010 * SPDX-License-Identifier: GPL-2.0-or-later
11 *
Harald Welte21b46bd2017-12-17 19:46:32 +010012 * This test suite tests OsmoBSC while emulating both multiple BTS + MS as
13 * well as the MSC. See README for more details.
14 *
15 * There are test cases that run in so-called 'handler mode' and test cases
16 * that run directly on top of the BSSAP and RSL CodecPorts. The "handler mode"
17 * tests abstract the multiplexing/demultiplexing of multiple SCCP connections
18 * and/or RSL channels and are hence suitable for higher-level test cases, while
19 * the "raw" tests directly on top of the CodecPorts are more suitable for lower-
20 * level testing.
21 */
22
Neels Hofmeyr9f3e6ac2021-04-08 23:09:24 +020023friend module BSC_Tests_VAMOS;
24
Neels Hofmeyr4f118412020-06-04 15:25:10 +020025import from Misc_Helpers all;
Harald Welte4003d112017-12-09 22:35:39 +010026import from General_Types all;
Harald Welte28d943e2017-11-25 15:00:50 +010027import from Osmocom_Types all;
Harald Welteae026692017-12-09 01:03:01 +010028import from GSM_Types all;
Harald Welte28d943e2017-11-25 15:00:50 +010029import from IPL4asp_Types all;
30
Harald Welte6f521d82017-12-11 19:52:02 +010031import from BSSAP_Types all;
Harald Welte6811d102019-04-14 22:23:14 +020032import from RAN_Adapter all;
Harald Welte47cd0e32020-08-21 12:39:11 +020033import from BSSAP_LE_Adapter all;
34import from BSSAP_LE_CodecPort all;
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +020035import from BSSAP_LE_Types all;
36import from BSSLAP_Types all;
Harald Welteae026692017-12-09 01:03:01 +010037import from BSSAP_CodecPort all;
38import from BSSMAP_Templates all;
Harald Welte28d943e2017-11-25 15:00:50 +010039import from IPA_Emulation all;
Stefan Sperling830dc9d2018-02-12 21:08:28 +010040import from IPA_CodecPort all;
Harald Welteae026692017-12-09 01:03:01 +010041import from IPA_Types all;
Stefan Sperling0796a822018-10-05 13:01:39 +020042import from IPA_Testing all;
Harald Welteae026692017-12-09 01:03:01 +010043import from RSL_Types all;
Harald Welte624f9632017-12-16 19:26:04 +010044import from RSL_Emulation all;
Daniel Willmann191e0d92018-01-17 12:44:35 +010045import from MGCP_Emulation all;
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +010046import from MGCP_Templates all;
47import from MGCP_Types all;
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +020048import from MGCP_CodecPort all;
Harald Welte28d943e2017-11-25 15:00:50 +010049
Harald Welte96c94412017-12-09 03:12:45 +010050import from Osmocom_CTRL_Functions all;
Harald Weltea5d2ab22017-12-09 14:21:42 +010051import from Osmocom_CTRL_Types all;
Harald Welteffe55fc2018-01-17 22:39:54 +010052import from Osmocom_CTRL_Adapter all;
Harald Welte96c94412017-12-09 03:12:45 +010053
Daniel Willmannebdecc02020-08-12 15:30:17 +020054import from StatsD_Types all;
55import from StatsD_CodecPort all;
56import from StatsD_CodecPort_CtrlFunct all;
57import from StatsD_Checker all;
58
Harald Weltebc03c762018-02-12 18:09:38 +010059import from Osmocom_VTY_Functions all;
60import from TELNETasp_PortType all;
61
Harald Welte6f521d82017-12-11 19:52:02 +010062import from MobileL3_CommonIE_Types all;
Harald Weltee3bd6582018-01-31 22:51:25 +010063import from MobileL3_Types all;
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +010064import from MobileL3_RRM_Types all;
Harald Welte6f521d82017-12-11 19:52:02 +010065import from L3_Templates all;
66import from GSM_RR_Types all;
67
Stefan Sperlingc307e682018-06-14 15:15:46 +020068import from SCCP_Templates all;
Neels Hofmeyr4ff93282018-03-12 04:25:35 +010069import from BSSMAP_Templates all;
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +020070import from BSSMAP_LE_Templates all;
Neels Hofmeyr4ff93282018-03-12 04:25:35 +010071
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +010072import from SCCPasp_Types all;
73
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +020074import from GSM_SystemInformation all;
75import from GSM_RestOctets all;
Neels Hofmeyrad132f22020-07-08 02:20:16 +020076import from TCCConversion_Functions all;
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +020077
Neels Hofmeyrbf720202021-10-02 12:58:24 +020078type record of integer integer_list;
79
Harald Welte5d1a2202017-12-13 19:51:29 +010080const integer NUM_BTS := 3;
Neels Hofmeyr5ce3ae42021-08-29 15:32:00 +020081const integer NUM_BTS_CFG := 4; /* we have 4 BTS in the osmo-bsc.cfg (for inter-BSC HO tests) but use only 3 */
Neels Hofmeyrf246a922020-05-13 02:27:10 +020082const integer NUM_MSC := 3;
Harald Welteae026692017-12-09 01:03:01 +010083const float T3101_MAX := 12.0;
Harald Welte28d943e2017-11-25 15:00:50 +010084
Harald Welte799c97b2017-12-14 17:50:30 +010085/* make sure to sync this with the osmo-bts.cfg you're using */
Philipp Maiercb6cc482018-03-26 13:08:00 +020086const integer NUM_TCHH_PER_BTS := 2;
87const integer NUM_TCHF_PER_BTS := 4;
Neels Hofmeyr74083c22020-07-29 00:43:01 +020088const integer NUM_SDCCH_PER_BTS := 3;
Harald Welte799c97b2017-12-14 17:50:30 +010089
Neels Hofmeyrbf720202021-10-02 12:58:24 +020090/* Default Training Sequence Code expected for bts[i]:
91 * BTS 0 has BSIC 10 (and no explicit timeslot training_sequence_code config), so expecting TSC = (BSIC & 7) = 2.
92 * BTS 1 has BSIC 11, TSC = (BSIC & 7) = 3.
93 * BTS 2 has BSIC 12, TSC = (BSIC & 7) = 4.
94 * BTS 2 has BSIC 12, TSC = (BSIC & 7) = 4.
95 */
96const integer_list BTS_TSC := {
97 2,
98 3,
99 4,
100 4
101}
Harald Welte4003d112017-12-09 22:35:39 +0100102
Harald Welte21b46bd2017-12-17 19:46:32 +0100103/* per-BTS state which we keep */
Harald Welte96c94412017-12-09 03:12:45 +0100104type record BTS_State {
Harald Welte21b46bd2017-12-17 19:46:32 +0100105 /* component reference to the IPA_Client component used for RSL */
Harald Weltea5d2ab22017-12-09 14:21:42 +0100106 IPA_Client rsl
Harald Welte96c94412017-12-09 03:12:45 +0100107}
108
Neels Hofmeyr22c3f792020-06-17 02:49:28 +0200109/* Default list of counters for an 'msc' entity. */
110const CounterNameVals counternames_msc_mscpool := {
111 { "mscpool:subscr:new", 0 },
112 { "mscpool:subscr:known", 0 },
113 { "mscpool:subscr:reattach", 0 },
114 { "mscpool:subscr:attach_lost", 0 },
115 { "mscpool:subscr:paged", 0 }
116};
117
Neels Hofmeyrbf037052020-10-28 22:52:02 +0000118/* List of global mscpool counters, not related to a specific 'msc' entity. */
119const CounterNameVals counternames_bsc_mscpool := {
120 { "mscpool:subscr:no_msc", 0 }
121};
122
Neels Hofmeyr12941bd2020-08-29 03:21:26 +0000123/* Default list of counters for 'bsc' and 'bts' entities. */
124const CounterNameVals counternames_bsc_bts_handover := {
125 { "assignment:attempted", 0 },
126 { "assignment:completed", 0 },
127 { "assignment:stopped", 0 },
128 { "assignment:no_channel", 0 },
129 { "assignment:timeout", 0 },
130 { "assignment:failed", 0 },
131 { "assignment:error", 0 },
132
133 { "handover:attempted", 0 },
134 { "handover:completed", 0 },
135 { "handover:stopped", 0 },
136 { "handover:no_channel", 0 },
137 { "handover:timeout", 0 },
138 { "handover:failed", 0 },
139 { "handover:error", 0 },
140
141 { "intra_cell_ho:attempted", 0 },
142 { "intra_cell_ho:completed", 0 },
143 { "intra_cell_ho:stopped", 0 },
144 { "intra_cell_ho:no_channel", 0 },
145 { "intra_cell_ho:timeout", 0 },
146 { "intra_cell_ho:failed", 0 },
147 { "intra_cell_ho:error", 0 },
148
149 { "intra_bsc_ho:attempted", 0 },
150 { "intra_bsc_ho:completed", 0 },
151 { "intra_bsc_ho:stopped", 0 },
152 { "intra_bsc_ho:no_channel", 0 },
153 { "intra_bsc_ho:timeout", 0 },
154 { "intra_bsc_ho:failed", 0 },
155 { "intra_bsc_ho:error", 0 },
156
157 { "interbsc_ho_out:attempted", 0 },
158 { "interbsc_ho_out:completed", 0 },
159 { "interbsc_ho_out:stopped", 0 },
160 { "interbsc_ho_out:timeout", 0 },
161 { "interbsc_ho_out:failed", 0 },
162 { "interbsc_ho_out:error", 0 },
163
164 { "interbsc_ho_in:attempted", 0 },
165 { "interbsc_ho_in:completed", 0 },
166 { "interbsc_ho_in:stopped", 0 },
167 { "interbsc_ho_in:no_channel", 0 },
168 { "interbsc_ho_in:timeout", 0 },
169 { "interbsc_ho_in:failed", 0 },
170 { "interbsc_ho_in:error", 0 }
171};
172
Neels Hofmeyrac432fa2021-11-02 16:45:56 +0100173const CounterNameVals counternames_bts_handover := {
174 { "incoming_intra_bsc_ho:attempted", 0 },
175 { "incoming_intra_bsc_ho:completed", 0 },
176 { "incoming_intra_bsc_ho:stopped", 0 },
177 { "incoming_intra_bsc_ho:no_channel", 0 },
178 { "incoming_intra_bsc_ho:timeout", 0 },
179 { "incoming_intra_bsc_ho:failed", 0 },
180 { "incoming_intra_bsc_ho:error", 0 }
181};
182
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +0200183/* Set of all System Information received during one RSL port's startup.
184 * Note that some System Information may be sent on RSL, but lacking actual SI data, to indicate that the BTS should not
185 * broadcast that SI type. That will be reflected as 'omit' here.
186 */
187type record SystemInformationConfig {
188 SystemInformationType1 si1 optional,
189 SystemInformationType2 si2 optional,
190 SystemInformationType2bis si2bis optional,
191 SystemInformationType2ter si2ter optional,
Neels Hofmeyrad132f22020-07-08 02:20:16 +0200192 SI2quaterRestOctetsList si2quater optional,
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +0200193 SystemInformationType3 si3 optional,
194 SystemInformationType4 si4 optional,
Pau Espin Pedrol28652d82021-02-09 20:20:17 +0100195 SystemInformationType13 si13 optional,
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +0200196 SystemInformationType5 si5 optional,
197 SystemInformationType5bis si5bis optional,
198 SystemInformationType5ter si5ter optional,
199 SystemInformationType6 si6 optional
200};
201
202const SystemInformationConfig SystemInformationConfig_omit := {
203 si1 := omit,
204 si2 := omit,
205 si2bis := omit,
206 si2ter := omit,
207 si2quater := omit,
208 si3 := omit,
209 si4 := omit,
210 si13 := omit,
211 si5 := omit,
212 si5bis := omit,
213 si5ter := omit,
214 si6 := omit
215};
216
217/* tr_EUTRAN_CellDesc with defaults used in BSC_Tests.ttcn */
218template EUTRAN_CellDesc tr_EUTRAN_CellDesc_default(template (present) uint16_t e_arfcn := ?,
219 template uint3_t meas_bw := 3)
220:= tr_EUTRAN_CellDesc(e_arfcn := e_arfcn,
221 meas_bw_presence := '1'B,
222 meas_bw := meas_bw);
223
224/* tr_EUTRAN_NeighbourCells with defaults used in BSC_Tests.ttcn */
Harald Welte65e419a2020-08-21 12:38:33 +0200225template EUTRAN_NeighbourCells tr_EUTRAN_NeighbourCells_default(template (present) EUTRAN_CellDescs cell_desc_list := { tr_EUTRAN_CellDesc_default },
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +0200226 template uint3_t prio := 3,
227 template (present) uint5_t thresh_high := 20,
228 template uint5_t thresh_low := 10,
229 template uint5_t qrxlevmin := 22)
230:= tr_EUTRAN_NeighbourCells(
231 cell_desc_list := cell_desc_list,
232 prio_presence := '1'B,
233 prio := prio,
234 thresh_high := thresh_high,
235 thresh_low_presence := '1'B,
236 thresh_low := thresh_low,
237 qrxlevmin_presence := '1'B,
238 qrxlevmin := qrxlevmin);
239
240template SystemInformationConfig SystemInformationConfig_default := {
241 si1 := {
242 cell_chan_desc := '8FB38000000000000000000000000000'O,
243 rach_control := {
244 max_retrans := RACH_MAX_RETRANS_7,
245 tx_integer := '1001'B,
246 cell_barr_access := false,
247 re_not_allowed := true,
248 acc := '0000010000000000'B
249 },
250 rest_octets := ?
251 },
252 si2 := {
253 bcch_freq_list := '00000000000000000000000000000000'O,
254 ncc_permitted := '11111111'B,
255 rach_control := {
256 max_retrans := RACH_MAX_RETRANS_7,
257 tx_integer := '1001'B,
258 cell_barr_access := false,
259 re_not_allowed := true,
260 acc := '0000010000000000'B
261 }
262 },
263 si2bis := omit,
264 si2ter := {
265 extd_bcch_freq_list := '8E320000000000000000000000000800'O,
266 rest_octets := ?
267 },
268 si2quater := {
269 tr_SI2quaterRestOctets_EUTRAN( repeated_neigh_cells := { tr_EUTRAN_NeighbourCells_default } )
270 },
271 si3 := {
272 cell_id := 0,
273 lai := {
274 mcc_mnc := '001F01'H,
275 lac := 1
276 },
277 ctrl_chan_desc := {
278 msc_r99 := true,
279 att := true,
280 bs_ag_blks_res := 1,
281 ccch_conf := CCHAN_DESC_1CCCH_COMBINED,
282 si22ind := false,
283 cbq3 := CBQ3_IU_MODE_NOT_SUPPORTED,
284 spare := '00'B,
285 bs_pa_mfrms := 3,
286 t3212 := 30
287 },
288 cell_options := {
289 dn_ind := false,
290 pwrc := false,
291 dtx := MS_SHALL_USE_UL_DTX,
292 radio_link_tout_div4 := 7
293 },
294 cell_sel_par := {
295 cell_resel_hyst_2dB := 2,
296 ms_txpwr_max_cch := 7,
297 acs := '0'B,
298 neci := true,
299 rxlev_access_min := 0
300 },
301 rach_control := {
302 max_retrans := RACH_MAX_RETRANS_7,
303 tx_integer := '1001'B,
304 cell_barr_access := false,
305 re_not_allowed := true,
306 acc := '0000010000000000'B
307 },
308 rest_octets := {
309 sel_params := {
310 presence := '0'B,
311 params := omit
312 },
313 pwr_offset := {
314 presence := '0'B,
315 offset := omit
316 },
317 si_2ter_ind := '1'B,
318 early_cm_ind := '0'B,
319 sched_where := {
320 presence := '0'B,
321 where := omit
322 },
323 gprs_ind := {
324 presence := '1'B,
325 ind := {
326 ra_colour := 0,
327 si13_pos := '0'B
328 }
329 },
330 umts_early_cm_ind := '1'B,
331 si2_quater_ind := {
332 presence := '1'B,
333 ind := '0'B
334 },
335 iu_mode_ind := omit,
336 si21_ind := {
337 presence := '0'B,
338 pos := omit
339 }
340 }
341 },
342 si4 := {
343 lai := {
344 mcc_mnc := '001F01'H,
345 lac := 1
346 },
347 cell_sel_par := {
348 cell_resel_hyst_2dB := 2,
349 ms_txpwr_max_cch := 7,
350 acs := '0'B,
351 neci := true,
352 rxlev_access_min := 0
353 },
354 rach_control := {
355 max_retrans := RACH_MAX_RETRANS_7,
356 tx_integer := '1001'B,
357 cell_barr_access := false,
358 re_not_allowed := true,
359 acc := '0000010000000000'B
360 },
Neels Hofmeyr74083c22020-07-29 00:43:01 +0200361 cbch_chan_desc := {
362 iei := '64'O,
363 v := {
364 chan_nr := {
365 u := {
366 sdcch4 := {
367 tag := '001'B,
368 sub_chan := 2
369 }
370 },
371 tn := 0
372 },
373 tsc := 2,
374 h := false,
375 arfcn := 871,
376 maio_hsn := omit
377 }
378 },
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +0200379 cbch_mobile_alloc := omit,
380 rest_octets := {
381 sel_params := {
382 presence := '0'B,
383 params := omit
384 },
385 pwr_offset := {
386 presence := '0'B,
387 offset := omit
388 },
389 gprs_ind := {
390 presence := '1'B,
391 ind := {
392 ra_colour := 0,
393 si13_pos := '0'B
394 }
395 },
396 s_presence := '0'B,
397 s := omit
398 }
399 },
Pau Espin Pedrol28652d82021-02-09 20:20:17 +0100400 si13 := {
401 rest_octets := {
402 presence := '1'B,
403 bcch_change_mark := ?,
404 si_change_field := '0000'B,
405 presence2 := '0'B,
406 si13_change_mark := omit,
407 gprs_ma := omit,
408 zero := '0'B, /* PBCCH not present in cell */
409 rac := 0,
410 spgc_ccch_sup := '0'B,
411 priority_access_thr := '110'B,
412 network_control_order := '00'B,
413 gprs_cell_opts := {
414 nmo := '01'B,
415 t3168 := '011'B,
416 t3192 := '010'B,
417 drx_timer_max := '011'B,
418 access_burst_type := '0'B,
419 control_ack_type := '1'B,
420 bs_cv_max := 15,
421 pan_presence := '1'B,
422 pan_dec := 1,
423 pan_inc := 1,
424 pan_max := '111'B,
425 ext_info_presence := ?,
426 ext_info_length := *,
427 ext_info := *
428 },
429 gprs_pwr_ctrl_params := {
430 alpha := 0,
431 t_avg_w := '10000'B,
432 t_avg_t := '10000'B,
433 pc_meas_chan := '0'B,
434 n_avg_i := '1000'B
435 }
436 }
437 },
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +0200438 si5 := {
439 bcch_freq_list := '10000000000000000000000000000000'O
440 },
441 si5bis := omit,
442 si5ter := {
443 extd_bcch_freq_list := '9E050020000000000000000000000000'O
444 },
445 si6 := {
446 cell_id := 0,
447 lai := {
448 mcc_mnc := '001F01'H,
449 lac := 1
450 },
451 cell_options := {
452 dtx_ext := '1'B,
453 pwrc := false,
454 dtx := '01'B,
455 radio_link_timeout := '0111'B
456 },
457 ncc_permitted := '11111111'B,
458 rest_octets := ?
459 }
460 };
461
462
463/* List of all the System Information received on all RSL ports */
464type record of SystemInformationConfig SystemInformationConfig_list;
465
466function f_sysinfo_dec_raw(inout SystemInformationConfig si, RSL_Message rsl)
467{
468 var RSL_IE_Body sysinfo_type_ie;
469 var RSL_IE_SysinfoType si_type;
470 var octetstring data;
471
472 if (f_rsl_find_ie(rsl, RSL_IE_SYSINFO_TYPE, sysinfo_type_ie) == false) {
473 setverdict(fail, "Cannot find RSL_IE_SYSINFO_TYPE");
474 mtc.stop;
475 }
476 si_type := sysinfo_type_ie.sysinfo_type;
477
478 if (rsl.msg_type == RSL_MT_BCCH_INFO) {
479 var RSL_IE_Body bcch_ie;
480 if (f_rsl_find_ie(rsl, RSL_IE_FULL_BCCH_INFO, bcch_ie)) {
481 data := bcch_ie.other.payload;
482 }
483 } else if (rsl.msg_type == RSL_MT_SACCH_FILL) {
484 var RSL_IE_Body l3_ie;
485 if (f_rsl_find_ie(rsl, RSL_IE_L3_INFO, l3_ie)) {
486 data := l3_ie.l3_info.payload;
487 }
488 } else {
489 setverdict(fail, "Don't understand this System Information message");
490 mtc.stop;
491 }
492
493 var boolean handled := false;
494
495 if (rsl.msg_type == RSL_MT_BCCH_INFO) {
496 handled := true;
497
498 if (si_type == RSL_SYSTEM_INFO_1) {
499 if (not isbound(data)) {
500 si.si1 := omit;
501 } else {
502 si.si1 := dec_SystemInformation(data).payload.si1;
503 }
504 } else if (si_type == RSL_SYSTEM_INFO_2) {
505 if (not isbound(data)) {
506 si.si2 := omit;
507 } else {
508 si.si2 := dec_SystemInformation(data).payload.si2;
509 }
510 } else if (si_type == RSL_SYSTEM_INFO_2bis) {
511 if (not isbound(data)) {
512 si.si2bis := omit;
513 } else {
514 si.si2bis := dec_SystemInformation(data).payload.si2bis;
515 }
516 } else if (si_type == RSL_SYSTEM_INFO_2ter) {
517 if (not isbound(data)) {
518 si.si2ter := omit;
519 } else {
520 si.si2ter := dec_SystemInformation(data).payload.si2ter;
521 }
522 } else if (si_type == RSL_SYSTEM_INFO_2quater) {
523 if (not isbound(data)) {
524 si.si2quater := {};
525 } else {
526 var SystemInformationType2quater decoded := dec_SystemInformation(data).payload.si2quater;
527 /* this is a *record* of SI2quaterRestOctets! (multiplexed) */
528 si.si2quater[decoded.rest_octets.si2quater_index] := decoded.rest_octets;
529 }
530 } else if (si_type == RSL_SYSTEM_INFO_3) {
531 if (not isbound(data)) {
532 si.si3 := omit;
533 } else {
534 si.si3 := dec_SystemInformation(data).payload.si3;
535 }
536 } else if (si_type == RSL_SYSTEM_INFO_4) {
537 if (not isbound(data)) {
538 si.si4 := omit;
539 } else {
540 si.si4 := dec_SystemInformation(data).payload.si4;
541 }
542 } else if (si_type == RSL_SYSTEM_INFO_13) {
543 if (not isbound(data)) {
544 si.si13 := omit;
545 } else {
Pau Espin Pedrol28652d82021-02-09 20:20:17 +0100546 si.si13 := dec_SystemInformation(data).payload.si13;
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +0200547 }
548 } else {
549 handled := false;
550 }
551 } else if (rsl.msg_type == RSL_MT_SACCH_FILL) {
552 handled := true;
553
554 if (si_type == RSL_SYSTEM_INFO_5) {
555 if (not isbound(data)) {
556 si.si5 := omit;
557 } else {
558 si.si5 := dec_SystemInformation(data).payload.si5;
559 }
560 } else if (si_type == RSL_SYSTEM_INFO_5bis) {
561 if (not isbound(data)) {
562 si.si5bis := omit;
563 } else {
564 si.si5bis := dec_SystemInformation(data).payload.si5bis;
565 }
566 } else if (si_type == RSL_SYSTEM_INFO_5ter) {
567 if (not isbound(data)) {
568 si.si5ter := omit;
569 } else {
570 si.si5ter := dec_SystemInformation(data).payload.si5ter;
571 }
572 } else if (si_type == RSL_SYSTEM_INFO_6) {
573 if (not isbound(data)) {
574 si.si6 := omit;
575 } else {
576 si.si6 := dec_SystemInformation(data).payload.si6;
577 }
578 } else {
579 handled := false;
580 }
581 }
582
583 if (not handled) {
584 setverdict(fail, "Unexpected SI type in ", rsl.msg_type, " message: ", si_type);
585 }
586}
587
Harald Weltea4ca4462018-02-09 00:17:14 +0100588type component test_CT extends CTRL_Adapter_CT {
Harald Welte21b46bd2017-12-17 19:46:32 +0100589 /* Array of per-BTS state */
Harald Welte96c94412017-12-09 03:12:45 +0100590 var BTS_State bts[NUM_BTS];
Harald Welte89ab1912018-02-23 18:56:29 +0100591 /* RSL common Channel Port (for RSL_Emulation) */
592 port RSL_CCHAN_PT RSL_CCHAN[NUM_BTS];
Harald Welte21b46bd2017-12-17 19:46:32 +0100593 /* array of per-BTS RSL test ports */
Harald Welteae026692017-12-09 01:03:01 +0100594 port IPA_RSL_PT IPA_RSL[NUM_BTS];
Stefan Sperling830dc9d2018-02-12 21:08:28 +0100595 port IPA_CODEC_PT IPA; /* Required for compilation of TC_rsl_unknown_unit_id() */
Pau Espin Pedrol5a2d7432019-06-07 19:43:45 +0200596 /* CTRL muxed over IPA in SCCPlite conn BSC<->MSC (or BSC-NAT) */
597 port IPA_CTRL_PT SCCPLITE_IPA_CTRL;
Harald Weltea5d2ab22017-12-09 14:21:42 +0100598
Daniel Willmann191e0d92018-01-17 12:44:35 +0100599 var MGCP_Emulation_CT vc_MGCP;
Harald Weltebc03c762018-02-12 18:09:38 +0100600 port TELNETasp_PT BSCVTY;
Daniel Willmann191e0d92018-01-17 12:44:35 +0100601
Daniel Willmannebdecc02020-08-12 15:30:17 +0200602 /* StatsD */
603 var StatsD_Checker_CT vc_STATSD;
604
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200605 var RAN_Adapter g_bssap[NUM_MSC];
Harald Welte47cd0e32020-08-21 12:39:11 +0200606 var BSSAP_LE_Adapter g_bssap_le;
Harald Weltea4ca4462018-02-09 00:17:14 +0100607 /* for old legacy-tests only */
608 port BSSAP_CODEC_PT BSSAP;
Harald Welte47cd0e32020-08-21 12:39:11 +0200609 port BSSAP_LE_CODEC_PT BSSAP_LE;
Harald Weltea4ca4462018-02-09 00:17:14 +0100610
Harald Welte21b46bd2017-12-17 19:46:32 +0100611 /* are we initialized yet */
Harald Welte28d943e2017-11-25 15:00:50 +0100612 var boolean g_initialized := false;
Harald Welte21b46bd2017-12-17 19:46:32 +0100613
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200614 /* Osmux is enabled through VTY */
615 var boolean g_osmux_enabled := false;
616
Pau Espin Pedrolc675b612020-01-09 19:55:40 +0100617 /*Configure T(tias) over VTY, seconds */
618 var integer g_bsc_sccp_timer_ias := 7 * 60;
619 /*Configure T(tiar) over VTY, seconds */
620 var integer g_bsc_sccp_timer_iar := 15 * 60;
621
Neels Hofmeyr4fbad7f2020-06-16 00:30:47 +0200622 /* global test case guard timer (actual timeout value is set in f_init()) */
Harald Welteae026692017-12-09 01:03:01 +0100623 timer T_guard := 30.0;
624
Neels Hofmeyr22c3f792020-06-17 02:49:28 +0200625 var CounterNameValsList g_ctr_msc;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +0000626 var CounterNameValsList g_ctr_bsc;
627 var CounterNameValsList g_ctr_bts;
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +0200628
629 /* System Information bytes as received during RSL startup, for each RSL[idx]. */
630 var SystemInformationConfig_list g_system_information := {};
Harald Welte28d943e2017-11-25 15:00:50 +0100631}
632
Pau Espin Pedrol0953bf82021-07-09 13:20:19 +0200633type record of charstring phys_chan_configs;
Harald Welte28d943e2017-11-25 15:00:50 +0100634modulepar {
Harald Welte21b46bd2017-12-17 19:46:32 +0100635 /* IP address at which the BSC can be reached */
Harald Welte696ddb62017-12-08 14:01:43 +0100636 charstring mp_bsc_ip := "127.0.0.1";
Stefan Sperling830dc9d2018-02-12 21:08:28 +0100637 /* port number to which to establish the IPA OML connections */
638 integer mp_bsc_oml_port := 3002;
Harald Welte21b46bd2017-12-17 19:46:32 +0100639 /* port number to which to establish the IPA RSL connections */
Harald Welte696ddb62017-12-08 14:01:43 +0100640 integer mp_bsc_rsl_port := 3003;
Harald Welte21b46bd2017-12-17 19:46:32 +0100641 /* port number to which to establish the IPA CTRL connection */
Harald Welte96c94412017-12-09 03:12:45 +0100642 integer mp_bsc_ctrl_port := 4249;
Daniel Willmannebdecc02020-08-12 15:30:17 +0200643 /* port number to which to listen for STATSD metrics */
644 integer mp_bsc_statsd_port := 8125;
Daniel Willmann191e0d92018-01-17 12:44:35 +0100645 /* IP address at which the test binds */
646 charstring mp_test_ip := "127.0.0.1";
Harald Weltea4ca4462018-02-09 00:17:14 +0100647
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200648 RAN_Configurations mp_bssap_cfg := {
649 {
650 transport := BSSAP_TRANSPORT_AoIP,
651 sccp_service_type := "mtp3_itu",
652 sctp_addr := { 23905, "127.0.0.1", 2905, "127.0.0.1" },
653 own_pc := 185, /* 0.23.1 first MSC emulation */
654 own_ssn := 254,
655 peer_pc := 187, /* 0.23.3 osmo-bsc */
656 peer_ssn := 254,
657 sio := '83'O,
Harald Weltecb0cc432020-06-21 19:42:31 +0200658 rctx := 1
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200659 },
660 {
661 transport := BSSAP_TRANSPORT_AoIP,
662 sccp_service_type := "mtp3_itu",
663 sctp_addr := { 23906, "127.0.0.1", 2905, "127.0.0.1" },
664 own_pc := 2, /* 0.0.2 second MSC emulation */
665 own_ssn := 254,
666 peer_pc := 187, /* 0.23.3 osmo-bsc */
667 peer_ssn := 254,
668 sio := '83'O,
669 rctx := 2
670 },
671 {
672 transport := BSSAP_TRANSPORT_AoIP,
673 sccp_service_type := "mtp3_itu",
674 sctp_addr := { 23907, "127.0.0.1", 2905, "127.0.0.1" },
675 own_pc := 3, /* 0.0.3 third MSC emulation */
676 own_ssn := 254,
677 peer_pc := 187, /* 0.23.3 osmo-bsc */
678 peer_ssn := 254,
679 sio := '83'O,
680 rctx := 3
681 }
Harald Weltea4ca4462018-02-09 00:17:14 +0100682 };
Pau Espin Pedrol58cf6822019-05-28 18:11:33 +0200683
Pau Espin Pedrol0953bf82021-07-09 13:20:19 +0200684 /* Must match per BTS config in osmo-bsc.cfg */
685 phys_chan_configs phys_chan_config := {
686 "CCCH+SDCCH4+CBCH",
687 "TCH/F",
688 "TCH/F",
689 "TCH/F",
690 "TCH/F",
Vadim Yanitskiy343c9eb2021-07-16 18:36:01 +0600691 "TCH/H",
Pau Espin Pedrol0953bf82021-07-09 13:20:19 +0200692 "PDCH",
693 "PDCH"
694 };
695
Harald Welte47cd0e32020-08-21 12:39:11 +0200696 BSSAP_LE_Configuration mp_bssap_le_cfg := {
697 sccp_service_type := "mtp3_itu",
698 sctp_addr := { 23908, "127.0.0.1", 2905, "127.0.0.1" },
Neels Hofmeyrac086c12020-09-18 23:46:42 +0200699 own_pc := 190, /* 0.23.6 SMLC emulation */
Harald Welte47cd0e32020-08-21 12:39:11 +0200700 own_ssn := 252, /* SMLC side SSN */
701 peer_pc := 187, /* 0.23.3 osmo-bsc */
702 peer_ssn := 250, /* BSC side SSN */
703 sio := '83'O,
704 rctx := 6
705 };
Neels Hofmeyrcfe44062020-10-15 02:28:08 +0200706 boolean mp_enable_lcs_tests := true;
Harald Welte47cd0e32020-08-21 12:39:11 +0200707
Pau Espin Pedrole076b3f2021-07-20 16:45:57 +0200708 /* Whether to enable dyn TS SDCCH8 tests. Can be dropped completely and enable
709 unconditionally once new version of osmo-bsc is released (current
710 version: 1.7.0) */
711 boolean mp_enable_dyn_sdcch8_test := true;
Pau Espin Pedrol8f30ccd2019-11-01 17:30:57 +0100712 /* Value set in osmo-bsc.cfg "ms max power" */
713 uint8_t mp_exp_ms_power_level := 7;
Harald Weltea4ca4462018-02-09 00:17:14 +0100714}
715
Neels Hofmeyr9f3e6ac2021-04-08 23:09:24 +0200716friend function f_gen_test_hdlr_pars(integer bssap_idx := 0) return TestHdlrParams {
Philipp Maier48604732018-10-09 15:00:37 +0200717
718 var TestHdlrParams pars := valueof(t_def_TestHdlrPars);
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200719 if (mp_bssap_cfg[bssap_idx].transport == BSSAP_TRANSPORT_AoIP) {
Philipp Maier48604732018-10-09 15:00:37 +0200720 pars.aoip := true;
721 } else {
722 pars.aoip := false;
723 }
Pau Espin Pedrol8f30ccd2019-11-01 17:30:57 +0100724 pars.exp_ms_power_level := mp_exp_ms_power_level;
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200725 pars.mscpool.bssap_idx := bssap_idx;
Neels Hofmeyrbf720202021-10-02 12:58:24 +0200726 pars.expect_tsc := BTS_TSC[0];
Neels Hofmeyrb5b7a6e2021-06-04 19:03:45 +0200727
Philipp Maier48604732018-10-09 15:00:37 +0200728 return pars;
729}
730
Neels Hofmeyr22c3f792020-06-17 02:49:28 +0200731/* Convenience functions for rate counters using g_ctr_msc. */
732
733private function f_ctrs_msc_init(integer mscs_count := NUM_MSC, CounterNameVals counternames := counternames_msc_mscpool) runs on test_CT {
734 g_ctr_msc := f_counter_name_vals_get_n(IPA_CTRL, "msc", mscs_count, counternames);
735 log("initial msc rate counters: ", g_ctr_msc);
736}
737
738private function f_ctrs_msc_add(integer msc_nr, charstring countername, integer val := 1) runs on test_CT {
Neels Hofmeyr9656e922020-06-30 01:27:01 +0200739 f_counter_name_vals_list_add(g_ctr_msc, msc_nr, countername, val);
Neels Hofmeyr22c3f792020-06-17 02:49:28 +0200740}
741
742/* f_ctrs_msc_init();
743 * f_do_thing(on_msc := 0);
744 * f_do_thing(on_msc := 0);
745 * f_do_other(on_msc := 1);
746 * f_ctrs_msc_add(0, "thing", 2);
747 * f_ctrs_msc_add(1, "other");
748 * f_ctrs_msc_verify();
749 */
750private function f_ctrs_msc_verify() runs on test_CT {
751 log("verifying msc rate counters: ", g_ctr_msc);
752 f_counter_name_vals_expect_n(IPA_CTRL, "msc", g_ctr_msc);
753}
754
755/* convenience: f_ctrs_msc_add() and f_ctrs_msc_verify() in one call.
756 * f_ctrs_msc_init();
757 * f_do_thing(on_msc := 0);
758 * f_do_thing(on_msc := 0);
759 * f_do_thing(on_msc := 0);
760 * f_ctrs_msc_expect(0, "thing", 3);
761 */
762private function f_ctrs_msc_expect(integer msc_nr, charstring countername, integer val := 1) runs on test_CT {
763 f_ctrs_msc_add(msc_nr, countername, val);
764 f_ctrs_msc_verify();
765}
766
Neels Hofmeyr12941bd2020-08-29 03:21:26 +0000767/* Convenience functions for rate counters using g_ctr_bts, always also including g_ctr_bsc. */
768
Neels Hofmeyrb7581872021-11-07 14:02:49 +0100769private 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 +0000770 g_ctr_bts := f_counter_name_vals_get_n(IPA_CTRL, "bts", bts_count, counternames);
Neels Hofmeyrb7581872021-11-07 14:02:49 +0100771}
772
773function f_ctrs_bsc_and_bts_init(integer bts_count := NUM_BTS, CounterNameVals counternames := counternames_bsc_bts_handover) runs on test_CT {
774 f_ctrs_bts_init(bts_count, counternames);
Neels Hofmeyr12941bd2020-08-29 03:21:26 +0000775 log("initial bts rate counters: ", g_ctr_bts);
776 f_ctrs_bsc_init(counternames);
777}
778
Neels Hofmeyrac432fa2021-11-02 16:45:56 +0100779private function f_ctrs_bsc_and_bts_handover_init(integer bts_count := NUM_BTS) runs on test_CT {
780 var CounterNameVals bts_names := counternames_bsc_bts_handover & counternames_bts_handover;
781 g_ctr_bts := f_counter_name_vals_get_n(IPA_CTRL, "bts", bts_count, bts_names);
782 log("initial bts rate counters: ", g_ctr_bts);
783 f_ctrs_bsc_init(counternames_bsc_bts_handover);
784}
785
786private function f_ctrs_bts_add(integer bts_nr, charstring countername, integer val := 1) runs on test_CT {
Neels Hofmeyr12941bd2020-08-29 03:21:26 +0000787 f_counter_name_vals_list_add(g_ctr_bts, bts_nr, countername, val);
Neels Hofmeyrac432fa2021-11-02 16:45:56 +0100788}
789
790private function f_ctrs_bsc_and_bts_add(integer bts_nr, charstring countername, integer val := 1) runs on test_CT {
791 f_ctrs_bts_add(bts_nr, countername, val);
Neels Hofmeyr12941bd2020-08-29 03:21:26 +0000792 f_ctrs_bsc_add(countername, val);
793}
794
Neels Hofmeyrb7581872021-11-07 14:02:49 +0100795function f_ctrs_bts_verify() runs on test_CT {
796 f_counter_name_vals_expect_n(IPA_CTRL, "bts", g_ctr_bts);
797}
798
Neels Hofmeyr12941bd2020-08-29 03:21:26 +0000799/* f_ctrs_bsc_and_bts_init();
800 * f_do_thing(on_bts := 0);
801 * f_do_thing(on_bts := 0);
802 * f_do_other(on_bts := 1);
803 * f_ctrs_bsc_and_bts_add(0, "thing", 2);
804 * f_ctrs_bsc_and_bts_add(1, "other");
805 * f_ctrs_bsc_and_bts_verify();
806 */
807private function f_ctrs_bsc_and_bts_verify() runs on test_CT {
Neels Hofmeyrb7581872021-11-07 14:02:49 +0100808 f_ctrs_bts_verify();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +0000809 f_ctrs_bsc_verify();
810}
811
812/* convenience: f_ctrs_bsc_and_bts_add() and f_ctrs_bsc_and_bts_verify() in one call.
813 * f_ctrs_bsc_and_bts_init();
814 * f_do_thing(on_bts := 0);
815 * f_do_thing(on_bts := 0);
816 * f_do_thing(on_bts := 0);
817 * f_ctrs_bsc_and_bts_expect(0, "thing", 3);
818 */
819private function f_ctrs_bsc_and_bts_expect(integer bts_nr, charstring countername, integer val := 1) runs on test_CT {
820 f_ctrs_bsc_and_bts_add(bts_nr, countername, val);
821 f_ctrs_bsc_and_bts_verify();
822}
823
824
825/* Convenience functions for rate counters using g_ctr_bsc. */
826
827private function f_ctrs_bsc_init(CounterNameVals counternames := counternames_bsc_bts_handover) runs on test_CT {
828 g_ctr_bsc := f_counter_name_vals_get_n(IPA_CTRL, "bsc", 1, counternames);
829 log("initial bsc rate counters: ", g_ctr_bsc);
830}
831
832private function f_ctrs_bsc_add(charstring countername, integer val := 1) runs on test_CT {
833 f_counter_name_vals_list_add(g_ctr_bsc, 0, countername, val);
834}
835
836/* f_ctrs_bsc_init();
837 * f_do_thing();
838 * f_do_thing();
839 * f_do_other();
840 * f_ctrs_bsc_add("thing", 2);
841 * f_ctrs_bsc_add("other");
842 * f_ctrs_bsc_verify();
843 */
844private function f_ctrs_bsc_verify() runs on test_CT {
845 f_counter_name_vals_expect_n(IPA_CTRL, "bsc", g_ctr_bsc);
846}
847
848/* convenience: f_ctrs_bsc_add() and f_ctrs_bsc_verify() in one call.
849 * f_ctrs_bsc_init();
850 * f_do_thing();
851 * f_ctrs_bsc_expect("thing", 1);
852 */
853private function f_ctrs_bsc_expect(charstring countername, integer val := 1) runs on test_CT {
854 f_ctrs_bsc_add(countername, val);
855 f_ctrs_bsc_verify();
856}
857
Neels Hofmeyr22c3f792020-06-17 02:49:28 +0200858
Neels Hofmeyr9f3e6ac2021-04-08 23:09:24 +0200859friend function f_shutdown_helper() runs on test_CT {
Daniel Willmann637ef6c2018-07-25 10:49:09 +0200860 all component.stop;
Philipp Maier282ca4b2018-02-27 17:17:00 +0100861 setverdict(pass);
Daniel Willmannafce8662018-07-06 23:11:32 +0200862 mtc.stop;
Philipp Maier282ca4b2018-02-27 17:17:00 +0100863}
864
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200865private function f_legacy_bssap_reset(integer bssap_idx := 0) runs on test_CT {
Harald Weltea4ca4462018-02-09 00:17:14 +0100866 var BSSAP_N_UNITDATA_ind ud_ind;
Pau Espin Pedrol24c05992020-09-01 12:54:12 +0200867 var boolean reset_received := false;
Harald Weltea4ca4462018-02-09 00:17:14 +0100868 timer T := 5.0;
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200869 BSSAP.send(ts_BSSAP_UNITDATA_req(g_bssap[bssap_idx].sccp_addr_peer, g_bssap[bssap_idx].sccp_addr_own,
870 ts_BSSMAP_Reset(0, g_osmux_enabled)));
Harald Weltea4ca4462018-02-09 00:17:14 +0100871 T.start;
872 alt {
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200873 [] BSSAP.receive(tr_BSSAP_UNITDATA_ind(g_bssap[bssap_idx].sccp_addr_own, g_bssap[bssap_idx].sccp_addr_peer,
874 tr_BSSMAP_ResetAck(g_osmux_enabled))) {
Neels Hofmeyr4f5d7be2020-10-16 16:28:16 +0200875 log("BSSMAP: Received RESET-ACK in response to RESET, we're ready to go!");
Harald Weltea4ca4462018-02-09 00:17:14 +0100876 }
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200877 [] BSSAP.receive(tr_BSSAP_UNITDATA_ind(?, ?, tr_BSSMAP_Reset(g_osmux_enabled))) -> value ud_ind {
Neels Hofmeyr4f5d7be2020-10-16 16:28:16 +0200878 log("BSSMAP: Respoding to inbound RESET with RESET-ACK");
Harald Weltea4ca4462018-02-09 00:17:14 +0100879 BSSAP.send(ts_BSSAP_UNITDATA_req(ud_ind.callingAddress, ud_ind.calledAddress,
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200880 ts_BSSMAP_ResetAck(g_osmux_enabled)));
Pau Espin Pedrol24c05992020-09-01 12:54:12 +0200881 reset_received := true;
Harald Weltea4ca4462018-02-09 00:17:14 +0100882 repeat;
883 }
884 [] BSSAP.receive { repeat; }
Pau Espin Pedrol24c05992020-09-01 12:54:12 +0200885 [] T.timeout {
Neels Hofmeyr4f5d7be2020-10-16 16:28:16 +0200886 log("BSSMAP: Timeout waiting for RESET-ACK after sending RESET");
Pau Espin Pedrol24c05992020-09-01 12:54:12 +0200887 /* If we received a RESET after ours was sent, it
888 may be a race condition where the other peer beacame
889 available after we sent it, but we are in a desired
890 state anyway, so go forward. */
891 if (not reset_received) {
892 setverdict(fail);
893 }
894 }
Harald Weltea4ca4462018-02-09 00:17:14 +0100895 }
Harald Welte28d943e2017-11-25 15:00:50 +0100896}
897
Harald Welteae026692017-12-09 01:03:01 +0100898type record IPA_Client {
Harald Welte21b46bd2017-12-17 19:46:32 +0100899 /* IPA Emulation component reference */
Harald Welteae026692017-12-09 01:03:01 +0100900 IPA_Emulation_CT vc_IPA,
Harald Welte21b46bd2017-12-17 19:46:32 +0100901 /* Unit-ID and other CCM parameters to use for IPA client emulation */
Harald Welteae026692017-12-09 01:03:01 +0100902 IPA_CCM_Parameters ccm_pars,
Harald Welte21b46bd2017-12-17 19:46:32 +0100903 /* String identifier for this IPA Client */
Harald Welte624f9632017-12-16 19:26:04 +0100904 charstring id,
Harald Welte21b46bd2017-12-17 19:46:32 +0100905 /* Associated RSL Emulation Component (if any). Only used in "Handler mode" */
Harald Welte624f9632017-12-16 19:26:04 +0100906 RSL_Emulation_CT vc_RSL optional
Harald Welte28d943e2017-11-25 15:00:50 +0100907}
908
Harald Welte21b46bd2017-12-17 19:46:32 +0100909/*! Start the IPA/RSL related bits for one IPA_Client.
910 * \param clnt IPA_Client for which to establish
911 * \param bsc_host IP address / hostname of the BSC
912 * \param bsc_port TCP port number of the BSC
913 * \param i number identifying this BTS
914 * \param handler_mode Start an RSL_Emulation_CT component (true) or not (false) */
Harald Welte624f9632017-12-16 19:26:04 +0100915function f_ipa_rsl_start(inout IPA_Client clnt, charstring bsc_host, PortNumber bsc_port, integer i,
916 boolean handler_mode := false)
Harald Welte28d943e2017-11-25 15:00:50 +0100917runs on test_CT {
Harald Welteae026692017-12-09 01:03:01 +0100918 timer T := 10.0;
919
Harald Welte96c94412017-12-09 03:12:45 +0100920 clnt.id := "IPA" & int2str(i) & "-RSL";
Harald Welteae026692017-12-09 01:03:01 +0100921 clnt.vc_IPA := IPA_Emulation_CT.create(clnt.id & "-IPA");
922 clnt.ccm_pars := c_IPA_default_ccm_pars;
923 clnt.ccm_pars.name := "Osmocom TTCN-3 BTS Simulator";
924 clnt.ccm_pars.unit_id := int2str(1234+i) & "/0/0";
Harald Welte624f9632017-12-16 19:26:04 +0100925 if (handler_mode) {
926 clnt.vc_RSL := RSL_Emulation_CT.create(clnt.id & "-RSL");
Harald Welte89ab1912018-02-23 18:56:29 +0100927 connect(clnt.vc_RSL:CCHAN_PT, self:RSL_CCHAN[i]);
Harald Welte624f9632017-12-16 19:26:04 +0100928 }
Harald Welteae026692017-12-09 01:03:01 +0100929
930 map(clnt.vc_IPA:IPA_PORT, system:IPA_CODEC_PT);
Harald Welte624f9632017-12-16 19:26:04 +0100931 if (handler_mode) {
932 connect(clnt.vc_IPA:IPA_RSL_PORT, clnt.vc_RSL:IPA_PT);
933 } else {
934 connect(clnt.vc_IPA:IPA_RSL_PORT, self:IPA_RSL[i]);
935 }
Harald Welteae026692017-12-09 01:03:01 +0100936
Harald Welte5d1a2202017-12-13 19:51:29 +0100937 clnt.vc_IPA.start(IPA_Emulation.main_client(bsc_host, bsc_port, "", 10000+i, clnt.ccm_pars));
Harald Welte624f9632017-12-16 19:26:04 +0100938 if (handler_mode) {
939 clnt.vc_RSL.start(RSL_Emulation.main());
940 return;
941 }
Harald Welteae026692017-12-09 01:03:01 +0100942
943 /* wait for IPA RSL link to connect and send ID ACK */
944 T.start;
945 alt {
Vadim Yanitskiya2afacc2020-05-18 21:16:19 +0700946 [] IPA_RSL[i].receive(tr_ASP_IPA_EV(ASP_IPA_EVENT_ID_ACK)) {
Harald Welteae026692017-12-09 01:03:01 +0100947 T.stop;
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +0700948 IPA_RSL[i].send(ts_ASP_RSL_UD(ts_RSL_PAGING_LOAD_IND(23)));
Harald Welteae026692017-12-09 01:03:01 +0100949 }
Harald Welte60e823a2017-12-10 14:10:59 +0100950 [] IPA_RSL[i].receive(ASP_IPA_Event:?) { repeat }
Harald Welteae026692017-12-09 01:03:01 +0100951 [] IPA_RSL[i].receive { repeat }
952 [] T.timeout {
Harald Welte96c94412017-12-09 03:12:45 +0100953 setverdict(fail, "Timeout RSL waiting for ASP_IPA_EVENT_ID_ACK");
Daniel Willmannafce8662018-07-06 23:11:32 +0200954 mtc.stop;
Harald Welteae026692017-12-09 01:03:01 +0100955 }
956 }
957}
958
Harald Welte12055472018-03-17 20:10:08 +0100959function f_ipa_rsl_stop(inout IPA_Client clnt) runs on test_CT {
960 if (not isbound(clnt) or not isbound(clnt.vc_IPA)) {
961 return;
962 }
963 clnt.vc_IPA.stop;
964 if (isbound(clnt.vc_RSL)) {
965 clnt.vc_RSL.stop;
966 }
967}
968
Harald Welte21b46bd2017-12-17 19:46:32 +0100969/* Wait for the OML connection to be brought up by the external osmo-bts-omldummy */
Harald Weltea5d2ab22017-12-09 14:21:42 +0100970function f_wait_oml(integer bts_nr, charstring status, float secs_max) runs on test_CT {
971 timer T := secs_max;
972 T.start;
973 while (true) {
974 if (f_ctrl_get_bts(IPA_CTRL, bts_nr, "oml-connection-state") == status) {
975 T.stop;
Harald Weltebd868bd2017-12-10 18:28:40 +0100976 /* the 'degraded' state exists from OML connection time, and we have to wait
977 * until all MO's are initialized */
978 T.start(1.0);
979 T.timeout;
Harald Weltea5d2ab22017-12-09 14:21:42 +0100980 return;
981 }
Harald Weltef0d6ac62017-12-17 17:02:21 +0100982 f_sleep(0.1);
Harald Weltea5d2ab22017-12-09 14:21:42 +0100983 if (not T.running) {
Max99253902018-11-16 17:57:39 +0100984 setverdict(fail, "Timeout waiting for BTS" & int2str(bts_nr) & " oml-connection-state ", status);
Daniel Willmannafce8662018-07-06 23:11:32 +0200985 mtc.stop;
Harald Weltea5d2ab22017-12-09 14:21:42 +0100986 }
987 }
988}
989
Harald Welte21b46bd2017-12-17 19:46:32 +0100990/* global altstep for global guard timer; also takes care of responding RESET witH RESET-ACK */
Harald Welteae026692017-12-09 01:03:01 +0100991altstep as_Tguard() runs on test_CT {
Harald Welte60e823a2017-12-10 14:10:59 +0100992 var BSSAP_N_UNITDATA_ind ud_ind;
Neels Hofmeyrcc3f76a2018-03-12 01:43:25 +0100993 [] T_guard.timeout {
994 setverdict(fail, "Timeout of T_guard");
Daniel Willmannafce8662018-07-06 23:11:32 +0200995 mtc.stop;
Neels Hofmeyrcc3f76a2018-03-12 01:43:25 +0100996 }
Harald Welte60e823a2017-12-10 14:10:59 +0100997 /* always respond with RESET ACK to RESET */
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200998 [] BSSAP.receive(tr_BSSAP_UNITDATA_ind(?, ?, tr_BSSMAP_Reset(g_osmux_enabled))) -> value ud_ind {
Harald Welte60e823a2017-12-10 14:10:59 +0100999 BSSAP.send(ts_BSSAP_UNITDATA_req(ud_ind.callingAddress, ud_ind.calledAddress,
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02001000 ts_BSSMAP_ResetAck(g_osmux_enabled)));
Harald Welte69c1c262017-12-13 21:02:08 +01001001 repeat;
Harald Welte60e823a2017-12-10 14:10:59 +01001002 }
Harald Welte28d943e2017-11-25 15:00:50 +01001003}
1004
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01001005altstep no_bssmap_reset() runs on test_CT {
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02001006 [] BSSAP.receive(tr_BSSAP_UNITDATA_ind(?, ?, tr_BSSMAP_Reset(g_osmux_enabled))) {
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01001007 setverdict(fail, "unexpected BSSMAP Reset");
Daniel Willmannafce8662018-07-06 23:11:32 +02001008 mtc.stop;
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01001009 }
1010}
1011
Daniel Willmann191e0d92018-01-17 12:44:35 +01001012function f_init_mgcp(charstring id) runs on test_CT {
1013 id := id & "-MGCP";
1014
1015 var MGCPOps ops := {
1016 create_cb := refers(MGCP_Emulation.ExpectedCreateCallback),
1017 unitdata_cb := refers(MGCP_Emulation.DummyUnitdataCallback)
1018 };
1019 var MGCP_conn_parameters mgcp_pars := {
1020 callagent_ip := mp_bsc_ip,
Harald Welte9e4273e2018-01-29 22:01:22 +01001021 callagent_udp_port := -1,
Daniel Willmann191e0d92018-01-17 12:44:35 +01001022 mgw_ip := mp_test_ip,
Pau Espin Pedrol1a026a52019-06-18 17:21:52 +02001023 mgw_udp_port := 2427,
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +02001024 /* Enable it for SCCPlite, since we have 2 MGCP sockets towards MGW (UDP one +
1025 the on with MGCP over IPA forwarded from MSC one) */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001026 multi_conn_mode := (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_SCCPlite_SERVER)
Daniel Willmann191e0d92018-01-17 12:44:35 +01001027 };
1028
1029 vc_MGCP := MGCP_Emulation_CT.create(id);
1030 vc_MGCP.start(MGCP_Emulation.main(ops, mgcp_pars, id));
1031}
1032
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02001033/* Enable or disable (current default) Osmux. When enabling, BSSMAP Reset
1034 * contains extra IE (OsmuxSupport) and osmo-bsc will handle AssignReq with
1035 * OsmuxCID IE.
1036 */
1037private function f_vty_allow_osmux(boolean allow) runs on test_CT {
1038 f_vty_enter_cfg_msc(BSCVTY, 0);
1039 if (allow) {
1040 f_vty_transceive(BSCVTY, "osmux on");
1041 } else {
1042 f_vty_transceive(BSCVTY, "osmux off");
1043 }
1044 f_vty_transceive(BSCVTY, "exit");
1045 f_vty_transceive(BSCVTY, "exit");
1046 g_osmux_enabled := allow;
1047}
1048
Max2253c0b2018-11-06 19:28:05 +01001049function f_init_vty(charstring id := "foo") runs on test_CT {
Harald Welte94e0c342018-04-07 11:33:23 +02001050 if (BSCVTY.checkstate("Mapped")) {
1051 /* skip initialization if already executed once */
1052 return;
1053 }
Harald Weltebc03c762018-02-12 18:09:38 +01001054 map(self:BSCVTY, system:BSCVTY);
1055 f_vty_set_prompts(BSCVTY);
1056 f_vty_transceive(BSCVTY, "enable");
Pau Espin Pedrolc675b612020-01-09 19:55:40 +01001057 f_cs7_inst_0_cfg(BSCVTY, {"sccp-timer ias " & int2str(g_bsc_sccp_timer_ias),
1058 "sccp-timer iar " & int2str(g_bsc_sccp_timer_iar)});
Harald Weltebc03c762018-02-12 18:09:38 +01001059}
1060
Neels Hofmeyr9f3e6ac2021-04-08 23:09:24 +02001061friend function f_logp(TELNETasp_PT pt, charstring log_msg)
Neels Hofmeyr4f118412020-06-04 15:25:10 +02001062{
1063 // log on TTCN3 log output
1064 log(log_msg);
1065 // log in stderr log
Neels Hofmeyr767548a2020-08-09 20:26:07 +00001066 f_vty_transceive(pt, "logp lglobal notice TTCN3 f_logp(): " & log_msg);
Neels Hofmeyr4f118412020-06-04 15:25:10 +02001067}
1068
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +02001069private function f_sysinfo_seen(integer rsl_idx, RSL_Message rsl) runs on test_CT
1070{
1071 if (rsl_idx >= lengthof(g_system_information)) {
1072 g_system_information[rsl_idx] := SystemInformationConfig_omit
1073 }
1074 f_sysinfo_dec_raw(g_system_information[rsl_idx], rsl);
1075}
1076
1077altstep as_catch_RSL_sysinfo(integer rsl_idx) runs on test_CT {
1078 var ASP_RSL_Unitdata rx_rsl_ud;
1079
1080 /* For handler_mode := false, receiving the RSL bootstrap messages directly on IPA_RSL */
1081 [] IPA_RSL[rsl_idx].receive(tr_ASP_RSL_UD(tr_RSL_NO_BCCH_INFO)) -> value rx_rsl_ud {
1082 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
1083 repeat;
1084 }
1085 [] IPA_RSL[rsl_idx].receive(tr_ASP_RSL_UD(tr_RSL_BCCH_INFO)) -> value rx_rsl_ud {
1086 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
1087 repeat;
1088 }
1089 [] IPA_RSL[rsl_idx].receive(tr_ASP_RSL_UD(tr_RSL_NO_SACCH_FILL)) -> value rx_rsl_ud {
1090 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
1091 repeat;
1092 }
1093 [] IPA_RSL[rsl_idx].receive(tr_ASP_RSL_UD(tr_RSL_SACCH_FILL)) -> value rx_rsl_ud {
1094 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
1095 repeat;
1096 }
1097
1098 /* For handler_mode := true, receiving the RSL bootstrap messages via RSL_Emulation */
1099 [] RSL_CCHAN[rsl_idx].receive(tr_ASP_RSL_UD(tr_RSL_NO_BCCH_INFO)) -> value rx_rsl_ud {
1100 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
1101 repeat;
1102 }
1103 [] RSL_CCHAN[rsl_idx].receive(tr_ASP_RSL_UD(tr_RSL_BCCH_INFO)) -> value rx_rsl_ud {
1104 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
1105 repeat;
1106 }
1107 [] RSL_CCHAN[rsl_idx].receive(tr_ASP_RSL_UD(tr_RSL_NO_SACCH_FILL)) -> value rx_rsl_ud {
1108 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
1109 repeat;
1110 }
1111 [] RSL_CCHAN[rsl_idx].receive(tr_ASP_RSL_UD(tr_RSL_SACCH_FILL)) -> value rx_rsl_ud {
1112 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
1113 repeat;
1114 }
1115}
1116
Neels Hofmeyra460f1f2020-08-09 20:17:03 +00001117/* TODO: use BooleanList from COMMON/src/General_Types.ttcn */
1118private type record of boolean my_BooleanList;
1119
1120private function f_vty_msc_allow_attach(TELNETasp_PT pt, my_BooleanList allow_attach_list)
1121{
Neels Hofmeyr8f576712020-08-12 22:49:53 +00001122 var charstring config := f_vty_transceive_ret(pt, "show running-config");
1123
Neels Hofmeyra460f1f2020-08-09 20:17:03 +00001124 for (var integer msc_nr := 0; msc_nr < sizeof(allow_attach_list); msc_nr := msc_nr+1) {
Neels Hofmeyr8f576712020-08-12 22:49:53 +00001125 if (f_strstr(config, "\nmsc " & int2str(msc_nr) & "\n") < 0) {
1126 /* There is no 'msc N' for this msc_nr in the running config, so don't create an empty msc by
1127 * stepping into that config node. */
1128 log("msc ", msc_nr, " is not configured, skipping");
1129 continue;
1130 }
Neels Hofmeyra460f1f2020-08-09 20:17:03 +00001131 f_vty_enter_cfg_msc(pt, msc_nr);
1132 if (allow_attach_list[msc_nr]) {
1133 /* strict := false: ignore if osmo-bsc does not support this config option (latest build) */
1134 f_vty_transceive(pt, "allow-attach", strict := false);
1135 } else {
1136 f_vty_transceive(pt, "no allow-attach", strict := false);
1137 }
1138 f_vty_transceive(pt, "exit");
1139 f_vty_transceive(pt, "exit");
1140 }
1141}
1142
Harald Welte21b46bd2017-12-17 19:46:32 +01001143/* global initialization function
1144 * \param nr_bts Number of BTSs we should start/bring up
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001145 * \param handler_mode Start an RSL_Emulation_CT component (true) or not (false).
1146 * \param nr_msc Number of virtual MSCs to bring up to connect to osmo-bsc.
1147 */
1148function f_init(integer nr_bts := NUM_BTS, boolean handler_mode := false, boolean allow_osmux := false,
Neels Hofmeyr4fbad7f2020-06-16 00:30:47 +02001149 integer nr_msc := 1, float guard_timeout := 30.0) runs on test_CT {
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001150 var integer bssap_idx;
Harald Welte28d943e2017-11-25 15:00:50 +01001151
Harald Welteae026692017-12-09 01:03:01 +01001152 if (g_initialized) {
1153 return;
Harald Welte28d943e2017-11-25 15:00:50 +01001154 }
Harald Welteae026692017-12-09 01:03:01 +01001155 g_initialized := true;
1156
Neels Hofmeyr4fbad7f2020-06-16 00:30:47 +02001157 T_guard.start(guard_timeout);
Daniel Willmanne68f9272018-11-27 15:15:28 +01001158 activate(as_Tguard());
1159
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02001160 f_init_vty("VirtMSC");
Pau Espin Pedrol23510fb2021-07-20 17:00:38 +02001161 f_vty_allow_osmux(allow_osmux);
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02001162
Neels Hofmeyra460f1f2020-08-09 20:17:03 +00001163 var my_BooleanList allow_attach := { false, false, false };
Daniel Willmannebdecc02020-08-12 15:30:17 +02001164 f_init_statsd("VirtMSC", vc_STATSD, mp_test_ip, mp_bsc_statsd_port);
1165
Neels Hofmeyr9db8e0e2021-08-23 20:45:58 +02001166 /* Make sure each MSC's internal state is "DISCONNECTED" at first */
1167 for (bssap_idx := 0; bssap_idx < NUM_MSC; bssap_idx := bssap_idx+1) {
1168 f_vty_transceive(BSCVTY, "msc " & int2str(bssap_idx) & " bssmap reset", strict := false);
1169 }
1170
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001171 for (bssap_idx := 0; bssap_idx < nr_msc; bssap_idx := bssap_idx+1) {
Neels Hofmeyra460f1f2020-08-09 20:17:03 +00001172 allow_attach[bssap_idx] := true;
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001173 /* Call a function of our 'parent component' RAN_Adapter_CT to start the
1174 * MSC-side BSSAP emulation */
1175 if (handler_mode) {
1176 var RanOps ranops := MSC_RanOps;
1177 ranops.use_osmux := g_osmux_enabled;
1178 f_ran_adapter_init(g_bssap[bssap_idx], mp_bssap_cfg[bssap_idx], "VirtMSC", ranops);
1179 connect(self:SCCPLITE_IPA_CTRL, g_bssap[bssap_idx].vc_RAN:CTRL_CLIENT);
1180 f_ran_adapter_start(g_bssap[bssap_idx]);
1181 } else {
1182 f_ran_adapter_init(g_bssap[bssap_idx], mp_bssap_cfg[bssap_idx], "VirtMSC", omit);
1183 connect(self:BSSAP, g_bssap[bssap_idx].vc_SCCP:SCCP_SP_PORT);
1184 f_ran_adapter_start(g_bssap[bssap_idx]);
1185 f_legacy_bssap_reset();
1186 }
Harald Welte67089ee2018-01-17 22:19:03 +01001187 }
Harald Welted5833a82018-05-27 16:52:56 +02001188
Neels Hofmeyrcfe44062020-10-15 02:28:08 +02001189 if (mp_enable_lcs_tests) {
1190 if (handler_mode) {
1191 f_bssap_le_adapter_init(g_bssap_le, mp_bssap_le_cfg, "VirtSMLC", SMLC_BssapLeOps);
1192 } else {
1193 f_bssap_le_adapter_init(g_bssap_le, mp_bssap_le_cfg, "VirtSMLC", omit);
1194 connect(self:BSSAP_LE, g_bssap_le.vc_SCCP:SCCP_SP_PORT);
1195 }
1196 f_bssap_le_adapter_start(g_bssap_le);
Harald Welte47cd0e32020-08-21 12:39:11 +02001197 }
Harald Welte47cd0e32020-08-21 12:39:11 +02001198
Neels Hofmeyra460f1f2020-08-09 20:17:03 +00001199 /* start the test with exactly all enabled MSCs allowed to attach */
1200 f_vty_msc_allow_attach(BSCVTY, allow_attach);
1201
Pau Espin Pedrol9a5b8ff2021-01-04 19:01:31 +01001202 f_ipa_ctrl_start_client(mp_bsc_ip, mp_bsc_ctrl_port);
Harald Welte28d943e2017-11-25 15:00:50 +01001203
Daniel Willmann191e0d92018-01-17 12:44:35 +01001204 f_init_mgcp("VirtMSC");
1205
Neels Hofmeyr0b7365b2020-07-04 00:52:34 +02001206 for (var integer i := 0; i < nr_bts; i := i+1) {
1207 f_init_bts(i, handler_mode);
Harald Welte696ddb62017-12-08 14:01:43 +01001208 }
Neels Hofmeyr0b7365b2020-07-04 00:52:34 +02001209}
Harald Welte696ddb62017-12-08 14:01:43 +01001210
Neels Hofmeyr0b7365b2020-07-04 00:52:34 +02001211function f_init_bts(integer bts_idx := 0, boolean handler_mode := false)
1212runs on test_CT {
1213 /* wait until osmo-bts-omldummy has respawned */
1214 f_wait_oml(bts_idx, "degraded", 5.0);
1215
1216 /* start RSL connection */
1217 f_ipa_rsl_start(bts[bts_idx].rsl, mp_bsc_ip, mp_bsc_rsl_port, bts_idx, handler_mode);
1218 /* wait until BSC tells us "connected" */
1219 f_wait_oml(bts_idx, "connected", 5.0);
Harald Welte28d943e2017-11-25 15:00:50 +01001220}
1221
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +02001222function f_init_bts_and_check_sysinfo(integer bts_idx := 0, boolean handler_mode := false,
1223 template SystemInformationConfig expect_si)
1224runs on test_CT {
1225 var default sysinfo := activate(as_catch_RSL_sysinfo(bts_idx));
1226
1227 f_init_bts(bts_idx, handler_mode);
1228
1229 /* Give some time to (hopefully/most likely) collect all system informations from RSL startup.
1230 * We could stop as soon as all expected SI are received, but then we might miss SI that we don't expect and
1231 * that might be sent afterwards. So rather give a generous timeout and be quite sure to catch all SI.
1232 */
1233 f_sleep(5.0);
1234 log("RSL ", bts_idx, " SYSTEM INFORMATION: ", g_system_information[bts_idx]);
1235
1236 deactivate(sysinfo);
1237
1238 if (match(g_system_information[bts_idx], expect_si)) {
1239 setverdict(pass);
1240 } else {
1241 log("RSL ", bts_idx, ": EXPECTED SI: ", expect_si);
1242 log("RSL ", bts_idx, ": GOT SI: ", g_system_information[bts_idx]);
1243 setverdict(fail, "received SI does not match expectations");
1244 return;
1245 }
1246}
1247
Maxd4e56962018-10-31 19:08:25 +01001248/* expect to receive a RSL message matching a specified template on a given BTS / stream */
Harald Welte65e419a2020-08-21 12:38:33 +02001249function 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 +01001250runs on test_CT return RSL_Message {
1251 var ASP_RSL_Unitdata rx_rsl_ud;
1252 timer T := t_secs;
1253
1254 T.start;
1255 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001256 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(t_rx, sid)) -> value rx_rsl_ud {
Harald Welteae026692017-12-09 01:03:01 +01001257 T.stop;
1258 }
1259 [] IPA_RSL[bts_nr].receive { repeat; }
Harald Welteb2917702017-12-10 15:48:52 +01001260 [] T.timeout {
1261 setverdict(fail, "Timeout expecting ", t_rx);
Daniel Willmannafce8662018-07-06 23:11:32 +02001262 mtc.stop;
Harald Welteb2917702017-12-10 15:48:52 +01001263 }
Harald Welteae026692017-12-09 01:03:01 +01001264 }
1265 return rx_rsl_ud.rsl;
1266}
1267
Harald Welte21b46bd2017-12-17 19:46:32 +01001268/* helper function to transmit RSL on a given BTS/stream */
Harald Welte65e419a2020-08-21 12:38:33 +02001269function 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 +01001270runs on test_CT {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001271 IPA_RSL[bts_nr].send(ts_ASP_RSL_UD(t_tx, sid));
Harald Welteae026692017-12-09 01:03:01 +01001272}
1273
1274
Harald Welte4003d112017-12-09 22:35:39 +01001275/* verify we get a CHAN_ACT after CHAN RQD */
Harald Welteae026692017-12-09 01:03:01 +01001276testcase TC_chan_act_noreply() runs on test_CT {
1277 var BSSAP_N_UNITDATA_ind ud_ind;
Harald Welte930d0a72018-03-22 22:08:40 +01001278 var RSL_Message rsl_unused;
Harald Welte28d943e2017-11-25 15:00:50 +01001279
Harald Welte89d42e82017-12-17 16:42:41 +01001280 f_init(1);
Harald Welte28d943e2017-11-25 15:00:50 +01001281
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001282 IPA_RSL[0].send(ts_ASP_RSL_UD(ts_RSL_CHAN_RQD('23'O, 23)));
Harald Welte930d0a72018-03-22 22:08:40 +01001283 rsl_unused := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001284 f_shutdown_helper();
Harald Welte28d943e2017-11-25 15:00:50 +01001285}
1286
Harald Welte4003d112017-12-09 22:35:39 +01001287/* verify if the "chreq:total" counter increments as expected */
1288testcase TC_chan_act_counter() runs on test_CT {
1289 var BSSAP_N_UNITDATA_ind ud_ind;
1290 var integer chreq_total;
Harald Welte930d0a72018-03-22 22:08:40 +01001291 var RSL_Message rsl_unused;
Harald Welte4003d112017-12-09 22:35:39 +01001292
Harald Welte89d42e82017-12-17 16:42:41 +01001293 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +01001294
1295 chreq_total := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total");
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001296 IPA_RSL[0].send(ts_ASP_RSL_UD(ts_RSL_CHAN_RQD('23'O, 23)));
Harald Welte930d0a72018-03-22 22:08:40 +01001297 rsl_unused := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
Harald Welte4003d112017-12-09 22:35:39 +01001298 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total", chreq_total+1);
1299
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001300 f_shutdown_helper();
Harald Welte4003d112017-12-09 22:35:39 +01001301}
1302
Harald Welteae026692017-12-09 01:03:01 +01001303/* CHAN RQD -> CHAN ACT -> CHAN ACT ACK -> RF CHAN REL */
Philipp Maier9c60a622020-07-09 15:08:46 +02001304private function f_TC_chan_act_ack_noest(OCT1 ra := '23'O) runs on test_CT {
Harald Welteae026692017-12-09 01:03:01 +01001305 var RSL_Message rx_rsl;
1306
Harald Welteae026692017-12-09 01:03:01 +01001307 /* Send CHAN RQD and wait for allocation; acknowledge it */
Philipp Maier9c60a622020-07-09 15:08:46 +02001308 var RslChannelNr chan_nr := f_chreq_act_ack(ra);
Harald Welteae026692017-12-09 01:03:01 +01001309
1310 /* expect BSC to disable the channel again if there's no RLL EST IND */
1311 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), T3101_MAX);
1312
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001313 f_shutdown_helper();
Harald Welteae026692017-12-09 01:03:01 +01001314}
1315
Philipp Maier9c60a622020-07-09 15:08:46 +02001316/* Normal variant */
1317testcase TC_chan_act_ack_noest() runs on test_CT {
Philipp Maieraf58db22020-08-12 17:24:40 +02001318 f_init(1);
Philipp Maier9c60a622020-07-09 15:08:46 +02001319 f_TC_chan_act_ack_noest();
1320}
1321
1322/* Emergency call variant */
1323testcase TC_chan_act_ack_noest_emerg() runs on test_CT {
1324 /* See also: 3GPP TS 04.08, Table 9.9, ra=101xxxxx */
Philipp Maieraf58db22020-08-12 17:24:40 +02001325 f_init(1);
1326 f_vty_allow_emerg_bts(true, 0);
Philipp Maier9c60a622020-07-09 15:08:46 +02001327 f_TC_chan_act_ack_noest(ra := 'A5'O);
1328}
1329
Philipp Maier606f07d2020-08-12 17:21:58 +02001330/* Emergency call variant, but emergency calls are not allowed */
1331testcase TC_chan_rqd_emerg_deny() runs on test_CT {
1332 /* See also: 3GPP TS 04.08, Table 9.9, ra=101xxxxx */
1333
1334 var RSL_Message rx_rsl;
1335 var GsmRrMessage rr;
1336
1337 f_init(1);
1338 f_vty_allow_emerg_bts(false, 0);
1339
1340 IPA_RSL[0].clear;
1341 f_ipa_tx(0, ts_RSL_CHAN_RQD('A5'O, 23));
1342
1343 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeC(RSL_MT_IMMEDIATE_ASSIGN_CMD));
1344 rr := dec_GsmRrMessage(rx_rsl.ies[1].body.full_imm_ass_info.payload);
1345 if (rr.header.message_type == IMMEDIATE_ASSIGNMENT_REJECT) {
1346 setverdict(pass);
1347 } else {
1348 setverdict(fail, "immediate assignment not rejected");
1349 }
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01001350
1351 f_shutdown_helper();
Philipp Maier606f07d2020-08-12 17:21:58 +02001352}
1353
Harald Welteae026692017-12-09 01:03:01 +01001354/* Test behavior if MSC never answers to CR */
1355testcase TC_chan_act_ack_est_ind_noreply() runs on test_CT {
Harald Weltef77aef62018-01-28 15:35:42 +01001356 var RslLinkId main_dcch := valueof(ts_RslLinkID_DCCH(0));
1357 var IpaStreamId sid := IPAC_PROTO_RSL_TRX0;
Harald Welteae026692017-12-09 01:03:01 +01001358 var RSL_Message rx_rsl;
Harald Weltef77aef62018-01-28 15:35:42 +01001359 var ASP_RSL_Unitdata rx_rsl_ud;
Harald Welteae026692017-12-09 01:03:01 +01001360
Harald Welte89d42e82017-12-17 16:42:41 +01001361 f_init(1);
Harald Welteae026692017-12-09 01:03:01 +01001362
1363 /* Send CHAN RQD and wait for allocation; acknowledge it */
Harald Welted6939652017-12-13 21:02:46 +01001364 var RslChannelNr chan_nr := f_chreq_act_ack();
Harald Welteae026692017-12-09 01:03:01 +01001365
1366 var octetstring l3 := '00010203040506'O
1367 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
1368
1369 BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3)));
1370
1371 /* expect BSC to disable the channel again if there's no response from MSC */
Harald Weltef77aef62018-01-28 15:35:42 +01001372 /* MS waits 20s (T3210) at LU; 10s (T3230) at CM SERV REQ and 5s (T3220) AT detach */
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001373 f_expect_chan_rel(0, chan_nr, expect_rll_rel_req := false);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001374 f_shutdown_helper();
Harald Welteae026692017-12-09 01:03:01 +01001375}
1376
1377/* Test behavior if MSC answers with CREF to CR */
1378testcase TC_chan_act_ack_est_ind_refused() runs on test_CT {
1379 var BSSAP_N_CONNECT_ind rx_c_ind;
1380 var RSL_Message rx_rsl;
1381
Harald Welte89d42e82017-12-17 16:42:41 +01001382 f_init(1);
Harald Welteae026692017-12-09 01:03:01 +01001383
1384 /* Send CHAN RQD and wait for allocation; acknowledge it */
Harald Welted6939652017-12-13 21:02:46 +01001385 var RslChannelNr chan_nr := f_chreq_act_ack();
Harald Welteae026692017-12-09 01:03:01 +01001386
1387 var octetstring l3 := '00010203040506'O
1388 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
1389
1390 BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) -> value rx_c_ind;
1391 BSSAP.send(ts_BSSAP_DISC_req(rx_c_ind.connectionId, 0));
1392
1393 /* expect BSC to disable the channel */
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001394 f_expect_chan_rel(0, chan_nr, expect_rll_rel_req := false);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001395 f_shutdown_helper();
Harald Welteae026692017-12-09 01:03:01 +01001396}
1397
Harald Welte618ef642017-12-14 14:58:20 +01001398/* CHAN RQD -> CHAN ACT -> CHAN ACT NACK -> RF CHAN REL */
1399testcase TC_chan_act_nack() runs on test_CT {
1400 var RSL_Message rx_rsl;
1401 var integer chact_nack;
1402
Harald Welte89d42e82017-12-17 16:42:41 +01001403 f_init(1);
Harald Welte618ef642017-12-14 14:58:20 +01001404
1405 chact_nack := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chan_act:nack");
1406
1407 f_ipa_tx(0, ts_RSL_CHAN_RQD('33'O, 33));
1408 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
1409 var RslChannelNr chan_nr := rx_rsl.ies[0].body.chan_nr;
1410
1411 f_ipa_tx(0, ts_RSL_CHAN_ACT_NACK(chan_nr, RSL_ERR_EQUIPMENT_FAIL));
1412
1413 /* wait for some time to hope the NACK arrives before the CTRL GET below */
1414 f_sleep(0.5);
1415
1416 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chan_act:nack", chact_nack+1);
1417
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001418 f_shutdown_helper();
Harald Welte618ef642017-12-14 14:58:20 +01001419}
1420
Harald Welte799c97b2017-12-14 17:50:30 +01001421/* Test for channel exhaustion due to RACH overload */
1422testcase TC_chan_exhaustion() runs on test_CT {
1423 var ASP_RSL_Unitdata rsl_ud;
1424 var integer i;
1425 var integer chreq_total, chreq_nochan;
1426
Harald Welte89d42e82017-12-17 16:42:41 +01001427 f_init(1);
Harald Welte799c97b2017-12-14 17:50:30 +01001428
1429 chreq_total := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total");
1430 chreq_nochan := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:no_channel");
1431
Neels Hofmeyr85fa37f2021-10-06 13:50:38 +02001432 /* GSM 44.018 Table 9.1.8.2:
Pau Espin Pedrolfe200d72018-12-10 12:41:04 +01001433 * RA = '33'O -> Establishment cause = 0011xxxx (MS dual rate capable and asks for "TCH/H or TCH/F").
1434 * With current setup, expect 4xSDCCH + 4xTCH/F + 1xTCH/H to succeed */
Philipp Maiercb6cc482018-03-26 13:08:00 +02001435 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 +01001436 var RslChannelNr chan_nr := f_chreq_act_ack('33'O, i);
Harald Welte799c97b2017-12-14 17:50:30 +01001437 }
1438
1439 IPA_RSL[0].clear;
1440
Harald Weltedd8cbf32018-01-28 12:07:52 +01001441 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total",
Philipp Maiercb6cc482018-03-26 13:08:00 +02001442 chreq_total + NUM_TCHF_PER_BTS + NUM_TCHH_PER_BTS + NUM_SDCCH_PER_BTS);
Harald Welte799c97b2017-12-14 17:50:30 +01001443
1444 /* now expect additional channel activations to fail */
1445 f_ipa_tx(0, ts_RSL_CHAN_RQD('42'O, 42));
1446
1447 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001448 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV))) {
Harald Welte799c97b2017-12-14 17:50:30 +01001449 setverdict(fail, "Received CHAN ACT ACK without resources?!?");
1450 }
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001451 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_IMM_ASSIGN(?))) -> value rsl_ud {
Harald Welte799c97b2017-12-14 17:50:30 +01001452 var GsmRrMessage rr;
1453 /* match on IMM ASS REJ */
1454 rr := dec_GsmRrMessage(rsl_ud.rsl.ies[1].body.full_imm_ass_info.payload);
1455 if (rr.header.message_type == IMMEDIATE_ASSIGNMENT_REJECT) {
1456 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total",
Philipp Maiercb6cc482018-03-26 13:08:00 +02001457 chreq_total + NUM_TCHF_PER_BTS + NUM_TCHH_PER_BTS + NUM_SDCCH_PER_BTS+1);
Harald Welte799c97b2017-12-14 17:50:30 +01001458 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:no_channel",
1459 chreq_nochan+1);
1460 setverdict(pass);
1461 } else {
1462 repeat;
1463 }
1464 }
1465 [] IPA_RSL[0].receive { repeat; }
1466 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001467 f_shutdown_helper();
Harald Welte799c97b2017-12-14 17:50:30 +01001468}
1469
Vadim Yanitskiy1ff1fdf2018-11-27 01:32:57 +07001470/* Test channel deactivation due to silence from MS */
1471testcase TC_chan_deact_silence() runs on test_CT {
1472 var RslChannelNr chan_nr;
1473
1474 f_init(1);
1475
1476 /* Request for a dedicated channel */
1477 chan_nr := f_chreq_act_ack('23'O);
1478
1479 /* Wait some time until the channel is released */
1480 f_sleep(2.0);
1481
1482 /* Expect CHANnel RELease */
1483 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001484 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL))) {
Vadim Yanitskiy1ff1fdf2018-11-27 01:32:57 +07001485 log("Received CHANnel RELease");
1486 setverdict(pass);
1487 }
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001488 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_IMM_ASSIGN(?))) {
Vadim Yanitskiy1ff1fdf2018-11-27 01:32:57 +07001489 /* See OS#3709, OsmoBSC should not send Immediate
1490 * Assignment Reject since a dedicated channel was
1491 * already allocated, and Immediate Assignment was
1492 * already sent. */
1493 setverdict(fail, "Unexpected Immediate Assignment!");
1494 }
1495 [] IPA_RSL[0].receive {
1496 setverdict(fail, "Unexpected RSL message!");
1497 }
1498 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001499 f_shutdown_helper();
Vadim Yanitskiy1ff1fdf2018-11-27 01:32:57 +07001500}
1501
Harald Weltecfe2c962017-12-15 12:09:32 +01001502/***********************************************************************
1503 * Assignment Testing
1504 ***********************************************************************/
1505
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02001506/* Verify that the BSC refuses any BSSAP connection from the MSC (They are all BSC->MSC direction,
1507 * except for the inter-BSC handover, MT side) */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001508testcase TC_outbound_connect(integer bssap_idx := 0) runs on test_CT {
Harald Welte89d42e82017-12-17 16:42:41 +01001509 f_init(1);
Harald Weltecfe2c962017-12-15 12:09:32 +01001510
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001511 BSSAP.send(ts_BSSAP_CONNECT_req(g_bssap[bssap_idx].sccp_addr_peer, g_bssap[bssap_idx].sccp_addr_own,
1512 2342, ts_BSSMAP_AssignmentReq));
Harald Weltecfe2c962017-12-15 12:09:32 +01001513 BSSAP.receive(tr_BSSAP_DISC_ind(2342, ?, ?));
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001514 f_shutdown_helper();
Harald Weltecfe2c962017-12-15 12:09:32 +01001515}
1516
Harald Welte16a4adf2017-12-14 18:54:01 +01001517/* Test behavior if MSC answers with CREF to CR */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001518testcase TC_assignment_cic_only(integer bssap_idx := 0) runs on test_CT {
Harald Welte16a4adf2017-12-14 18:54:01 +01001519 var BSSAP_N_CONNECT_ind rx_c_ind;
1520 var RSL_Message rx_rsl;
1521 var DchanTuple dt;
1522
Harald Welte89d42e82017-12-17 16:42:41 +01001523 f_init(1);
Harald Welte16a4adf2017-12-14 18:54:01 +01001524
1525 dt := f_est_dchan('23'O, 23, '00000000'O);
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001526 if (mp_bssap_cfg[bssap_idx].transport == BSSAP_TRANSPORT_AoIP) {
Harald Welte17b27da2018-05-25 20:33:53 +02001527 /* send assignment without AoIP IEs */
1528 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_AssignmentReq(ts_BSSMAP_IE_CIC(0, 1))));
1529 } else {
1530 /* Send assignmetn without CIC in IPA case */
1531 var BSSMAP_IE_AoIP_TransportLayerAddress tla :=
1532 valueof(ts_BSSMAP_IE_AoIP_TLA4('01020304'O, 2342));
1533 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_AssignmentReq(omit, tla)));
1534 }
Harald Welte16a4adf2017-12-14 18:54:01 +01001535 alt {
1536 [] BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_AssignmentComplete)) {
1537 setverdict(fail, "AoIP BSC cannot accept ASSIGNMENT without AoIP Transport IE");
1538 }
Harald Welte235ebf12017-12-15 14:18:16 +01001539 /* TODO: Actually expect GSM0808_CAUSE_REQ_A_IF_TYPE_NOT_SUPP */
Harald Welte16a4adf2017-12-14 18:54:01 +01001540 [] BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_AssignmentFail)) {
1541 setverdict(pass);
1542 }
1543 [] BSSAP.receive { repeat; }
1544 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001545 f_shutdown_helper();
Harald Welte16a4adf2017-12-14 18:54:01 +01001546}
1547
Harald Welteed848512018-05-24 22:27:58 +02001548/* generate an assignment request for either AoIP or SCCPlite */
Pau Espin Pedrol07866632020-09-03 19:10:55 +02001549function 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 +02001550 var PDU_BSSAP ass_cmd;
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02001551 var BSSMAP_IE_Osmo_OsmuxCID osmux_cid := valueof(ts_OsmuxCID(0));
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001552 if (mp_bssap_cfg[bssap_idx].transport == BSSAP_TRANSPORT_AoIP) {
Harald Welteed848512018-05-24 22:27:58 +02001553 var BSSMAP_IE_AoIP_TransportLayerAddress tla :=
Pau Espin Pedrol07866632020-09-03 19:10:55 +02001554 valueof(f_ts_BSSMAP_IE_AoIP_TLA(aoip_tla, 2342));
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02001555 if (osmux_enabled) {
1556 ass_cmd := valueof(ts_BSSMAP_AssignmentReq(omit, tla, osmux_cid));
1557 } else {
1558 ass_cmd := valueof(ts_BSSMAP_AssignmentReq(omit, tla));
1559 }
Harald Welteed848512018-05-24 22:27:58 +02001560 } else {
1561 var BSSMAP_IE_CircuitIdentityCode cic := valueof(ts_BSSMAP_IE_CIC(0,1));
Pau Espin Pedrol096d73d2019-06-06 12:49:17 +02001562 ass_cmd := valueof(ts_BSSMAP_AssignmentReq(cic, omit));
Harald Welteed848512018-05-24 22:27:58 +02001563 }
1564 return ass_cmd;
1565}
1566
Pau Espin Pedrolc08d5522021-04-16 15:40:38 +02001567function f_gen_handover_req(integer bssap_idx := 0, charstring aoip_tla := "1.2.3.4",
Neels Hofmeyr8ebf19c2021-06-21 05:24:01 +02001568 template (omit) BSSMAP_oldToNewBSSIEs oldToNewBSSIEs := omit,
1569 template (omit) TestHdlrEncrParams enc := omit) return PDU_BSSAP {
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01001570 var PDU_BSSAP ho_req;
Neels Hofmeyr8ebf19c2021-06-21 05:24:01 +02001571
1572 var BSSMAP_IE_EncryptionInformation encryptionInformation :=
1573 valueof(ts_BSSMAP_IE_EncrInfo('0000000000000000'O,'01'O));
1574 var template BSSMAP_IE_ChosenEncryptionAlgorithm chosenEncryptionAlgorithm := omit;
1575 var template BSSMAP_IE_KC128 kc128 := omit;
1576 if (ispresent(enc)) {
1577 var TestHdlrEncrParams v_enc := valueof(enc);
1578 encryptionInformation := valueof(ts_BSSMAP_IE_EncrInfo(v_enc.enc_key, v_enc.enc_alg));
1579 chosenEncryptionAlgorithm := valueof(
1580 ts_BSSMAP_IE_ChosenEncryptionAlgorithm(int2oct(enum2int(
Oliver Smith598e1ed2021-07-09 10:28:40 +02001581 f_cipher_mode_bssmap_to_rsl(v_enc.enc_alg)), 1)));
Neels Hofmeyr8ebf19c2021-06-21 05:24:01 +02001582 if (ispresent(v_enc.enc_kc128)) {
1583 kc128 := ts_BSSMAP_IE_Kc128(v_enc.enc_kc128);
1584 }
1585 }
1586
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001587 if (mp_bssap_cfg[bssap_idx].transport == BSSAP_TRANSPORT_AoIP) {
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01001588 var BSSMAP_IE_AoIP_TransportLayerAddress tla :=
Pau Espin Pedrol07866632020-09-03 19:10:55 +02001589 valueof(f_ts_BSSMAP_IE_AoIP_TLA(aoip_tla, 2342));
Neels Hofmeyr8ebf19c2021-06-21 05:24:01 +02001590 ho_req := valueof(ts_BSSMAP_HandoverRequest(omit, tla, oldToNewBSSIEs := oldToNewBSSIEs,
1591 encryptionInformation := encryptionInformation,
1592 chosenEncryptionAlgorithm := chosenEncryptionAlgorithm,
1593 kC128 := kc128));
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01001594 } else {
1595 var BSSMAP_IE_CircuitIdentityCode cic := valueof(ts_BSSMAP_IE_CIC(0,1));
Neels Hofmeyr8ebf19c2021-06-21 05:24:01 +02001596 ho_req := valueof(ts_BSSMAP_HandoverRequest(cic, omit, oldToNewBSSIEs := oldToNewBSSIEs,
1597 encryptionInformation := encryptionInformation,
1598 chosenEncryptionAlgorithm := chosenEncryptionAlgorithm,
1599 kC128 := kc128));
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01001600 }
1601 return ho_req;
1602}
1603
Harald Welteed848512018-05-24 22:27:58 +02001604/* generate an assignment complete template for either AoIP or SCCPlite */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001605function f_gen_exp_compl(boolean expect_osmux := false, integer bssap_idx := 0) return template PDU_BSSAP {
Harald Welteed848512018-05-24 22:27:58 +02001606 var template PDU_BSSAP exp_compl;
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02001607 var BSSMAP_IE_Osmo_OsmuxCID osmux_cid := valueof(ts_OsmuxCID(0));
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001608 if (mp_bssap_cfg[bssap_idx].transport == BSSAP_TRANSPORT_AoIP) {
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02001609 if (expect_osmux) {
1610 exp_compl := tr_BSSMAP_AssignmentComplete(omit, ?, osmux_cid);
1611 } else {
1612 exp_compl := tr_BSSMAP_AssignmentComplete(omit, ?, omit);
1613 }
Harald Welteed848512018-05-24 22:27:58 +02001614 } else {
1615 /* CIC is optional "*" as the MSC allocated it */
Pau Espin Pedrol096d73d2019-06-06 12:49:17 +02001616 exp_compl := tr_BSSMAP_AssignmentComplete(*, omit);
Harald Welteed848512018-05-24 22:27:58 +02001617 }
1618 return exp_compl;
1619}
1620
Harald Welte235ebf12017-12-15 14:18:16 +01001621/* Run everything required up to sending a caller-specified assignment command and expect response */
1622function f_assignment_exp(PDU_BSSAP ass_cmd, template PDU_BSSAP exp, charstring fail_text)
1623runs on test_CT {
1624 var BSSAP_N_CONNECT_ind rx_c_ind;
1625 var RSL_Message rx_rsl;
1626 var DchanTuple dt;
1627
Harald Welte89d42e82017-12-17 16:42:41 +01001628 f_init(1);
Harald Welte235ebf12017-12-15 14:18:16 +01001629
1630 dt := f_est_dchan('23'O, 23, '00000000'O);
1631 /* send assignment without AoIP IEs */
1632 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ass_cmd));
1633 alt {
1634 [] BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_AssignmentComplete)) {
1635 if (ischosen(exp.pdu.bssmap.assignmentComplete)) {
1636 setverdict(pass);
1637 } else {
1638 setverdict(fail, fail_text);
1639 }
1640 }
1641 [] BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_AssignmentFail)) {
1642 if (ischosen(exp.pdu.bssmap.assignmentFailure)) {
1643 setverdict(pass);
1644 } else {
1645 setverdict(fail, fail_text);
1646 }
1647 }
1648 [] BSSAP.receive { repeat; }
1649 }
1650}
1651testcase TC_assignment_csd() runs on test_CT {
1652 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
Harald Welteed848512018-05-24 22:27:58 +02001653 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte235ebf12017-12-15 14:18:16 +01001654 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeCSD);
1655 //exp_fail.pdu.bssmap.assignmentFailure.cause.causeValue := int2bit(enum2int(GSM0808_CAUSE_REQ_CODEC_TYPE_OR_CONFIG_UNAVAIL), 7);
1656 f_assignment_exp(ass_cmd, exp_fail, "BSC accepted Assignment for CSD");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001657 f_shutdown_helper();
Harald Welte235ebf12017-12-15 14:18:16 +01001658}
1659
1660testcase TC_assignment_ctm() runs on test_CT {
1661 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
Harald Welteed848512018-05-24 22:27:58 +02001662 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte235ebf12017-12-15 14:18:16 +01001663 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeCTM);
1664 //exp_fail.pdu.bssmap.assignmentFailure.cause.causeValue := int2bit(enum2int(GSM0808_CAUSE_REQ_CODEC_TYPE_OR_CONFIG_UNAVAIL), 7);
1665 f_assignment_exp(ass_cmd, exp_fail, "BSC accepted Assignment for Speech+CTM");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001666 f_shutdown_helper();
Harald Welte235ebf12017-12-15 14:18:16 +01001667}
1668
Harald Welte4003d112017-12-09 22:35:39 +01001669type record DchanTuple {
1670 integer sccp_conn_id,
1671 RslChannelNr rsl_chan_nr
Harald Weltea5d2ab22017-12-09 14:21:42 +01001672}
1673
Neels Hofmeyrbd94fe72021-10-26 22:04:53 +02001674type record of DchanTuple DchanTuples;
1675
Harald Welted6939652017-12-13 21:02:46 +01001676/* Send CHAN RQD and wait for allocation; acknowledge it */
1677private function f_chreq_act_ack(OCT1 ra := '23'O, GsmFrameNumber fn := 23)
1678runs on test_CT return RslChannelNr {
1679 var RSL_Message rx_rsl;
1680 f_ipa_tx(0, ts_RSL_CHAN_RQD(ra, fn));
1681 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
1682 var RslChannelNr chan_nr := rx_rsl.ies[0].body.chan_nr;
1683 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, fn+10));
Daniel Willmannf4ac4ce2018-08-02 14:06:30 +02001684 rx_rsl := f_exp_ipa_rx(0, tr_RSL_IMM_ASSIGN(0));
Harald Welted6939652017-12-13 21:02:46 +01001685 return chan_nr;
1686}
1687
Harald Welte4003d112017-12-09 22:35:39 +01001688/* helper function to establish a dedicated channel via BTS and MSC */
1689function f_est_dchan(OCT1 ra, GsmFrameNumber fn, octetstring l3)
1690runs on test_CT return DchanTuple {
1691 var BSSAP_N_CONNECT_ind rx_c_ind;
Harald Welte4003d112017-12-09 22:35:39 +01001692 var DchanTuple dt;
Harald Weltea5d2ab22017-12-09 14:21:42 +01001693
Harald Welte4003d112017-12-09 22:35:39 +01001694 /* Send CHAN RQD and wait for allocation; acknowledge it */
Harald Welted6939652017-12-13 21:02:46 +01001695 dt.rsl_chan_nr := f_chreq_act_ack(ra, fn);
Harald Welte4003d112017-12-09 22:35:39 +01001696
1697 f_ipa_tx(0, ts_RSL_EST_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
1698
1699 BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) -> value rx_c_ind;
1700 dt.sccp_conn_id := rx_c_ind.connectionId;
1701 BSSAP.send(ts_BSSAP_CONNECT_res(dt.sccp_conn_id));
1702
1703 return dt;
Harald Weltea5d2ab22017-12-09 14:21:42 +01001704}
1705
Neels Hofmeyre1a7c4d2021-10-23 23:13:01 +02001706/* Like f_est_dchan(), but for the first lchan of a dynamic timeslot: first ACK the deactivation of PDCH. */
1707function f_est_dchan_dyn(OCT1 ra, GsmFrameNumber fn, octetstring l3)
1708runs on test_CT return DchanTuple {
1709 var BSSAP_N_CONNECT_ind rx_c_ind;
1710 var DchanTuple dt;
1711
1712 /* Send CHAN RQD */
1713 var RSL_Message rx_rsl;
1714 f_ipa_tx(0, ts_RSL_CHAN_RQD(ra, fn));
1715
1716 /* The dyn TS first deactivates PDCH */
1717 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), T3101_MAX);
1718 dt.rsl_chan_nr := rx_rsl.ies[0].body.chan_nr;
1719 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(dt.rsl_chan_nr));
1720
1721 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
1722 dt.rsl_chan_nr := rx_rsl.ies[0].body.chan_nr;
1723
1724 /* Now activates the signalling channel */
1725 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(dt.rsl_chan_nr, fn+10));
1726 rx_rsl := f_exp_ipa_rx(0, tr_RSL_IMM_ASSIGN(0));
1727
1728 f_ipa_tx(0, ts_RSL_EST_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
1729
1730 BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) -> value rx_c_ind;
1731 dt.sccp_conn_id := rx_c_ind.connectionId;
1732 BSSAP.send(ts_BSSAP_CONNECT_res(dt.sccp_conn_id));
1733
1734 return dt;
1735}
1736
Harald Welte641fcbe2018-06-14 10:58:35 +02001737/* expect RF CAN REL from BTS, acknowledge it and clear the MSC side */
1738private function f_exp_chan_rel_and_clear(DchanTuple dt, integer bts_nr := 0) runs on test_CT {
1739 var RSL_Message rx_rsl;
1740 /* expect BSC to disable the channel */
1741 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), T3101_MAX);
1742 /* respond with CHAN REL ACK */
1743 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(dt.rsl_chan_nr));
1744
1745 /* expect Clear Complete from BSC */
1746 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete));
1747
1748 /* MSC disconnects as instructed. */
1749 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
1750}
1751
Harald Welte4003d112017-12-09 22:35:39 +01001752/* Test behavior of channel release after unilateral RLL REL IND (DISC from MS) */
1753testcase TC_chan_rel_rll_rel_ind() runs on test_CT {
Neels Hofmeyr27f64362018-03-12 01:44:00 +01001754 var BSSAP_N_DATA_ind rx_di;
Harald Welte4003d112017-12-09 22:35:39 +01001755 var DchanTuple dt;
Harald Welte96c94412017-12-09 03:12:45 +01001756
Harald Welte89d42e82017-12-17 16:42:41 +01001757 f_init(1);
Harald Welte96c94412017-12-09 03:12:45 +01001758
Harald Welte4003d112017-12-09 22:35:39 +01001759 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1760
1761 /* simulate RLL REL IND */
1762 f_ipa_tx(0, ts_RSL_REL_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0))));
1763
Neels Hofmeyr27f64362018-03-12 01:44:00 +01001764 /* expect Clear Request on MSC side */
1765 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearRequest)) -> value rx_di;
1766
1767 /* Instruct BSC to clear channel */
1768 var BssmapCause cause := bit2int(rx_di.userData.pdu.bssmap.clearRequest.cause.causeValue);
1769 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
1770
Harald Welte4003d112017-12-09 22:35:39 +01001771 /* expect BSC to disable the channel */
Harald Welte641fcbe2018-06-14 10:58:35 +02001772 f_exp_chan_rel_and_clear(dt, 0);
Neels Hofmeyr27f64362018-03-12 01:44:00 +01001773
1774 /* wait for SCCP emulation to do its job */
1775 f_sleep(1.0);
Harald Welte4003d112017-12-09 22:35:39 +01001776
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001777 f_shutdown_helper();
Harald Welte4003d112017-12-09 22:35:39 +01001778}
1779
1780/* Test behavior of channel release after CONN FAIL IND from BTS */
1781testcase TC_chan_rel_conn_fail() runs on test_CT {
1782 var BSSAP_N_DATA_ind rx_di;
Harald Welte4003d112017-12-09 22:35:39 +01001783 var DchanTuple dt;
1784
Harald Welte89d42e82017-12-17 16:42:41 +01001785 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +01001786
1787 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1788
1789 /* simulate CONN FAIL IND */
Harald Weltea8ed9062017-12-14 09:46:01 +01001790 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 +01001791 /* TODO: different cause values? */
1792
Harald Welte4003d112017-12-09 22:35:39 +01001793 /* expect Clear Request from BSC */
1794 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearRequest)) -> value rx_di;
1795
1796 /* Instruct BSC to clear channel */
1797 var BssmapCause cause := bit2int(rx_di.userData.pdu.bssmap.clearRequest.cause.causeValue);
1798 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
1799
Harald Welte6ff76ea2018-01-28 13:08:01 +01001800 /* expect BSC to disable the channel */
Harald Welte641fcbe2018-06-14 10:58:35 +02001801 f_exp_chan_rel_and_clear(dt, 0);
Harald Welte4003d112017-12-09 22:35:39 +01001802
1803 /* wait for SCCP emulation to do its job */
1804 f_sleep(1.0);
1805
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001806 f_shutdown_helper();
Harald Welte4003d112017-12-09 22:35:39 +01001807}
1808
Harald Welte99f3ca02018-06-14 13:40:29 +02001809/* Test behavior of early CONN FAIL IND from BTS (before EST IND!) */
1810/* See also https://www.osmocom.org/issues/3182 */
1811testcase TC_early_conn_fail() runs on test_CT {
1812 var RSL_Message rx_rsl;
1813 var DchanTuple dt;
1814
1815 f_init(1);
1816
1817 /* BTS->BSC: Send CHAN RQD and wait for allocation; acknowledge it */
Harald Weltec46ea3c2020-10-10 18:46:12 +02001818 dt.rsl_chan_nr := f_chreq_act_ack(f_rnd_ra_cs(), 23);
Harald Welte99f3ca02018-06-14 13:40:29 +02001819
1820 /* BTS->BSC: simulate CONN FAIL IND */
1821 f_ipa_tx(0, ts_RSL_CONN_FAIL_IND(dt.rsl_chan_nr, RSL_ERR_RADIO_LINK_FAIL));
1822
1823 /* BTS->BSC: Expect RF channel release from BSC on Abis */
1824 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), 10.0);
1825
1826 /* BTS<-BSC: respond with CHAN REL ACK */
1827 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(dt.rsl_chan_nr));
1828
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001829 f_shutdown_helper();
Harald Welte99f3ca02018-06-14 13:40:29 +02001830}
1831
1832/* Test behavior of late CONN FAIL IND from BTS (ater REL IND!) */
1833/* See also https://www.osmocom.org/issues/3182 */
1834testcase TC_late_conn_fail() runs on test_CT {
1835 var RSL_Message rx_rsl;
1836 var DchanTuple dt;
1837
1838 f_init(1);
1839
1840 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1841
1842 /* BSC<-MSC: Instruct BSC to clear connection */
1843 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(0)));
1844
1845 /* BTS->BSC: expect BSC to deactivate SACCH */
1846 rx_rsl := f_exp_ipa_rx(0, tr_RSL_DEACT_SACCH(dt.rsl_chan_nr));
1847
1848 /* BTS->BSC: simulate a late CONN FAIL IND from BTS */
1849 f_ipa_tx(0, ts_RSL_CONN_FAIL_IND(dt.rsl_chan_nr, RSL_ERR_RADIO_LINK_FAIL));
1850
1851 /* BTS<-BSC: Expect RF channel release from BSC on Abis */
1852 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), 10.0);
1853 /* BTS->BSC: respond with CHAN REL ACK */
1854 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(dt.rsl_chan_nr));
1855
1856 /* BSC->MSC: expect Clear Complete from BSC */
1857 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete));
1858
1859 /* BSC<-MSC: MSC disconnects as requested. */
1860 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
1861
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001862 f_shutdown_helper();
Harald Welte99f3ca02018-06-14 13:40:29 +02001863}
1864
Oliver Smithaf03bef2021-08-24 15:34:51 +02001865private function f_TC_stats_conn_fail(charstring id) runs on MSC_ConnHdlr {
1866 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
1867 var PDU_BSSAP ass_cmd := f_gen_ass_req();
1868
1869 f_statsd_reset();
1870
1871 /* Establish SDCCH */
1872 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeCSD);
1873 f_establish_fully(ass_cmd, exp_fail);
1874
1875 /* Expect stats to be 0 */
1876 var StatsDExpects expect := {
1877 {name := "TTCN3.bts.0.chan.rf_fail", mtype := "c", min := 0, max := 0},
1878 {name := "TTCN3.bts.0.chan.rf_fail_sdcch", mtype := "c", min := 0, max := 0}
1879 };
1880 f_statsd_expect(expect);
1881
1882 /* Simulate CONN FAIL IND on SDCCH */
1883 RSL.send(ts_ASP_RSL_UD(
1884 ts_RSL_CONN_FAIL_IND(g_chan_nr, RSL_ERR_RADIO_LINK_FAIL),
1885 IPAC_PROTO_RSL_TRX0));
1886
Neels Hofmeyr58be48a2021-09-07 18:39:21 +02001887 f_sleep(1.0);
1888
Oliver Smithaf03bef2021-08-24 15:34:51 +02001889 /* Expect stats to be 1 */
1890 expect := {
1891 {name := "TTCN3.bts.0.chan.rf_fail", mtype := "c", min := 1, max := 1},
1892 {name := "TTCN3.bts.0.chan.rf_fail_sdcch", mtype := "c", min := 1, max := 1}
1893 };
1894 f_statsd_expect(expect);
1895}
1896testcase TC_stats_conn_fail() runs on test_CT {
1897 var TestHdlrParams pars := f_gen_test_hdlr_pars();
1898 var MSC_ConnHdlr vc_conn;
1899
1900 f_init(1, true);
1901 f_sleep(1.0);
1902
1903 vc_conn := f_start_handler(refers(f_TC_stats_conn_fail), pars);
1904 vc_conn.done;
1905
1906 f_shutdown_helper();
1907}
1908
Neels Hofmeyrf44ccd12018-11-05 19:15:23 +01001909function f_expect_chan_rel(integer bts_nr, RslChannelNr rsl_chan_nr,
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001910 boolean expect_deact_sacch := true,
1911 boolean expect_rr_chan_rel := true,
1912 boolean expect_rll_rel_req := true,
Harald Welte99787102019-02-04 10:41:36 +01001913 boolean handle_rll_rel := true,
Pau Espin Pedrol36bd4fa2021-04-15 13:00:24 +02001914 template CellSelIndValue expect_cells := omit,
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02001915 template RR_Cause expect_rr_cause := ?
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001916 ) runs on test_CT {
Harald Welte91d54a52018-01-28 15:35:07 +01001917
1918 var RslLinkId main_dcch := valueof(ts_RslLinkID_DCCH(0));
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001919 var boolean got_deact_sacch := false;
1920 var boolean got_rr_chan_rel := false;
1921 var boolean got_rll_rel_req := false;
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02001922 var ASP_RSL_Unitdata ud;
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02001923 var RSL_IE_Body l3_ie;
1924 var PDU_ML3_NW_MS l3;
1925 var RR_Cause got_cause;
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001926 log("f_expect_chan_rel() expecting: expect_deact_sacch=", expect_deact_sacch, " expect_rr_chan_rel=", expect_rr_chan_rel,
1927 " expect_rll_rel_req=", expect_rll_rel_req);
Harald Welte91d54a52018-01-28 15:35:07 +01001928 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001929 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(tr_RSL_DEACT_SACCH(rsl_chan_nr))) {
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001930 got_deact_sacch := true;
Harald Welte91d54a52018-01-28 15:35:07 +01001931 repeat;
1932 }
Pau Espin Pedrol841b90d2021-04-15 16:42:52 +02001933 [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 +01001934 got_rr_chan_rel := true;
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02001935
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02001936 if (f_rsl_find_ie(ud.rsl, RSL_IE_L3_INFO, l3_ie) == false) {
1937 setverdict(fail, "cannot find L3");
1938 mtc.stop;
1939 }
1940 l3 := dec_PDU_ML3_NW_MS(l3_ie.l3_info.payload);
1941
Pau Espin Pedrol36bd4fa2021-04-15 13:00:24 +02001942 if (not istemplatekind(expect_cells, "omit")) {
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02001943 var CellSelIndValue cells := dec_CellSelIndValue(
1944 l3.msgs.rrm.channelRelease.cellSelectionIndicator.cellSelectionIndicatorValue);
1945
Pau Espin Pedrol36bd4fa2021-04-15 13:00:24 +02001946 log("GOT RR CHANNEL RELEASE WITH CELLS: ", cells);
1947 if (match(cells, expect_cells)) {
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02001948 setverdict(pass);
1949 } else {
Pau Espin Pedrol36bd4fa2021-04-15 13:00:24 +02001950 log("EXPECTED CELLS: ", expect_cells);
1951 setverdict(fail, "Received cells list on RR Channel Release does not match expectations");
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02001952 }
1953 }
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02001954
1955 if (not istemplatekind(expect_rr_cause, "omit")) {
1956 int2enum(oct2int(l3.msgs.rrm.channelRelease.rRCause.valuePart), got_cause);
1957 log("GOT CAUSE CODE: ", l3.msgs.rrm.channelRelease.rRCause.valuePart, " = ", got_cause);
1958 if (match(got_cause, expect_rr_cause)) {
1959 setverdict(pass);
1960 } else {
1961 log("EXPECTED CAUSE CODE: ", expect_rr_cause);
1962 setverdict(fail, "Received RR Channel Release Cause code does not match expectations");
1963 }
1964 }
Harald Welte99787102019-02-04 10:41:36 +01001965 repeat;
1966 }
Pau Espin Pedrol841b90d2021-04-15 16:42:52 +02001967 [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 +01001968 got_rr_chan_rel := true;
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02001969
1970 if (not istemplatekind(expect_rr_cause, "omit")) {
1971 if (f_rsl_find_ie(ud.rsl, RSL_IE_L3_INFO, l3_ie) == false) {
1972 setverdict(fail, "cannot find L3");
1973 mtc.stop;
1974 }
1975 l3 := dec_PDU_ML3_NW_MS(l3_ie.l3_info.payload);
1976
1977 int2enum(oct2int(l3.msgs.rrm.channelRelease.rRCause.valuePart), got_cause);
1978 log("GOT CAUSE CODE: ", l3.msgs.rrm.channelRelease.rRCause.valuePart, " = ", got_cause);
1979 if (match(got_cause, expect_rr_cause)) {
1980 setverdict(pass);
1981 } else {
1982 log("EXPECTED CAUSE CODE: ", expect_rr_cause);
1983 setverdict(fail, "Received RR Channel Release Cause code does not match expectations");
1984 }
1985 }
Neels Hofmeyr211169d2018-11-07 00:37:29 +01001986 repeat;
1987 }
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001988 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(tr_RSL_REL_REQ(rsl_chan_nr, ?))) {
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001989 got_rll_rel_req := true;
Harald Welte91d54a52018-01-28 15:35:07 +01001990 /* FIXME: Why are we getting this for LinkID SACCH? */
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001991 if (handle_rll_rel) {
1992 f_ipa_tx(0, ts_RSL_REL_CONF(rsl_chan_nr, main_dcch));
1993 }
Harald Welte91d54a52018-01-28 15:35:07 +01001994 repeat;
1995 }
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001996 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL))) {
Harald Welte91d54a52018-01-28 15:35:07 +01001997 /* respond with CHAN REL ACK */
1998 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(rsl_chan_nr));
1999 }
2000 /* ignore any user data */
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07002001 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(tr_RSL_MsgTypeR(?))) {
Harald Welte91d54a52018-01-28 15:35:07 +01002002 repeat;
2003 }
2004 }
Neels Hofmeyra5302c82018-11-04 23:09:58 +01002005
2006 log("f_expect_chan_rel() summary: got_deact_sacch=", got_deact_sacch, " got_rr_chan_rel=", got_rr_chan_rel,
2007 " got_rll_rel_req=", got_rll_rel_req);
2008
2009 if (expect_deact_sacch != got_deact_sacch) {
2010 setverdict(fail, "f_expect_chan_rel(): expect_deact_sacch=", expect_deact_sacch, " got_deact_sacch=", got_deact_sacch);
2011 }
2012 if (expect_rr_chan_rel != got_rr_chan_rel) {
2013 setverdict(fail, "f_expect_chan_rel(): expect_rr_chan_rel=", expect_rr_chan_rel, " got_rr_chan_rel=", got_rr_chan_rel);
2014 }
2015 if (expect_rll_rel_req != got_rll_rel_req) {
2016 setverdict(fail, "f_expect_chan_rel(): expect_rll_rel_req=", expect_rll_rel_req, " got_rll_rel_req=", got_rll_rel_req);
2017 }
Harald Welte91d54a52018-01-28 15:35:07 +01002018}
2019
Harald Welte4003d112017-12-09 22:35:39 +01002020/* Test behavior of channel release after hard Clear Command from MSC */
2021testcase TC_chan_rel_hard_clear() runs on test_CT {
2022 var BSSAP_N_DATA_ind rx_di;
Harald Welte4003d112017-12-09 22:35:39 +01002023 var DchanTuple dt;
Harald Welte4003d112017-12-09 22:35:39 +01002024
Harald Welte89d42e82017-12-17 16:42:41 +01002025 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +01002026
2027 dt := f_est_dchan('23'O, 23, '00010203040506'O);
2028
2029 /* Instruct BSC to clear channel */
2030 var BssmapCause cause := 0;
2031 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
2032
2033 /* expect Clear Complete from BSC on A */
2034 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete)) {
2035 /* release the SCCP connection */
2036 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
2037 }
2038
Neels Hofmeyra5302c82018-11-04 23:09:58 +01002039 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002040 f_shutdown_helper();
Harald Welte4003d112017-12-09 22:35:39 +01002041}
2042
Pau Espin Pedrol841b90d2021-04-15 16:42:52 +02002043function f_TC_chan_rel_last_eutran_plmn_hard_clear(boolean tx_csfb_ind) runs on test_CT {
2044 var BSSAP_N_DATA_ind rx_di;
2045 var DchanTuple dt;
2046
2047 f_init(1);
2048
2049 dt := f_est_dchan('23'O, 23, '00010203040506'O);
2050 /* Send CommonID with some random PLMN (BSC doesn't take it into account
2051 /* yet when generating the EUTRAN neigh list in RR CHannel Release) */
2052 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_CommonId('001019876543210'H, '323454'O)));
2053
2054 /* Instruct BSC to clear channel */
2055 var BssmapCause cause := 0;
2056 if (tx_csfb_ind) {
2057 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommandCSFB(cause)));
2058 } else {
2059 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
2060 }
2061
2062 /* expect Clear Complete from BSC on A */
2063 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete)) {
2064 /* release the SCCP connection */
2065 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
2066 }
2067
2068 /* 1 neighbor is added by default in osmo-bts.cfg and
2069 SystemInformationConfig_default, use that: */
2070 var template CellSelIndValue exp_cells := f_tr_rr_chan_rel_earfcns(1);
2071
2072 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false, expect_cells := exp_cells);
2073 f_shutdown_helper();
2074}
2075
2076/* Test behavior of RR Channel rRelease after Clear Command without CSFB indicator
2077 from MSC, previously receiving any CommonID containing the "Last Used E-UTRAN
2078 PLMN Id". According to spec (3GPP TS 48.008 sec 3.1.30) that's the bit requesting
2079 EUTRAN neighbor list sent later on by BSC in RR Channel, so receiving CSFB
2080 Indicator or not shouldn't matter at all. */
2081testcase TC_chan_rel_last_eutran_plmn_hard_clear_no_csfb() runs on test_CT {
2082 f_TC_chan_rel_last_eutran_plmn_hard_clear(false);
2083}
2084
2085/* Test behavior of RR Channel rRelease after Clear Command with CSFB indicator from
2086 MSC, previously receiving any CommonID containing the "Last Used E-UTRAN PLMN
2087 Id". According to spec (3GPP TS 48.008 sec 3.1.30) that's the bit requesting
2088 EUTRAN neighbor list sent later on by BSC in RR Channel. */
2089testcase TC_chan_rel_last_eutran_plmn_hard_clear_csfb() runs on test_CT {
2090 f_TC_chan_rel_last_eutran_plmn_hard_clear(true);
2091}
2092
2093/* Test behavior of RR Channel Release after Clear Command with CSFB indicator from
2094 MSC, without receiving any CommonID containing the "Last Used E-UTRAN PLMN
2095 Id". According to spec (TS 48.008 version 16.0.0 Release 16 "3.2.1.21") the
2096 CSFB Indicator should not be used anymore, and hence, there should be no
2097 EUTRAN neighbor list sent by BSC in RR Channel release since no CommonId with
2098 Last Used E-UTRAN PLMN Id" IE was sent for this conn. */
Harald Welte99787102019-02-04 10:41:36 +01002099testcase TC_chan_rel_hard_clear_csfb() runs on test_CT {
2100 var BSSAP_N_DATA_ind rx_di;
2101 var DchanTuple dt;
2102
2103 f_init(1);
2104
2105 dt := f_est_dchan('23'O, 23, '00010203040506'O);
2106
2107 /* Instruct BSC to clear channel */
2108 var BssmapCause cause := 0;
2109 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommandCSFB(cause)));
2110
2111 /* expect Clear Complete from BSC on A */
2112 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete)) {
2113 /* release the SCCP connection */
2114 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
2115 }
2116
Pau Espin Pedrol841b90d2021-04-15 16:42:52 +02002117 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002118 f_shutdown_helper();
Harald Welte99787102019-02-04 10:41:36 +01002119}
2120
Harald Welted8c36cd2017-12-09 23:05:31 +01002121/* Test behavior of channel release after hard RLSD from MSC */
2122testcase TC_chan_rel_hard_rlsd() runs on test_CT {
Harald Welted8c36cd2017-12-09 23:05:31 +01002123 var DchanTuple dt;
Harald Welted8c36cd2017-12-09 23:05:31 +01002124
Harald Welte89d42e82017-12-17 16:42:41 +01002125 f_init(1);
Harald Welted8c36cd2017-12-09 23:05:31 +01002126
2127 dt := f_est_dchan('23'O, 23, '00010203040506'O);
2128
2129 /* release the SCCP connection */
2130 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
2131
Neels Hofmeyra5302c82018-11-04 23:09:58 +01002132 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002133 f_shutdown_helper();
Harald Welted8c36cd2017-12-09 23:05:31 +01002134}
2135
Harald Welte550daf92018-06-11 19:22:13 +02002136/* Test behavior of channel release after hard RLSD from MSC and MS is not responding to RLL REL REQ */
2137testcase TC_chan_rel_hard_rlsd_ms_dead() runs on test_CT {
2138 var DchanTuple dt;
2139
2140 f_init(1);
2141
2142 dt := f_est_dchan('23'O, 23, '00010203040506'O);
2143
2144 /* release the SCCP connection */
2145 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
2146
Neels Hofmeyra5302c82018-11-04 23:09:58 +01002147 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002148 f_shutdown_helper();
Harald Welte550daf92018-06-11 19:22:13 +02002149}
2150
Harald Welte85804d42017-12-10 14:11:58 +01002151/* Test behavior of channel release after BSSMAP RESET from MSC */
2152testcase TC_chan_rel_a_reset() runs on test_CT {
Harald Welte85804d42017-12-10 14:11:58 +01002153 var DchanTuple dt;
Harald Welte85804d42017-12-10 14:11:58 +01002154
Harald Welte89d42e82017-12-17 16:42:41 +01002155 f_init(1);
Harald Welte85804d42017-12-10 14:11:58 +01002156
2157 dt := f_est_dchan('23'O, 23, '00010203040506'O);
2158
2159 /* Clear the queue, it might still contain stuff like IMMEDIATE ASSIGN */
2160 IPA_RSL[0].clear;
2161
2162 /* perform BSSAP RESET, expect RESET ACK and DISC.ind on connection */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02002163 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 +01002164 interleave {
Neels Hofmeyrf246a922020-05-13 02:27:10 +02002165 [] 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 +01002166 [] BSSAP.receive(tr_BSSAP_DISC_ind(dt.sccp_conn_id, ?, ?)) { }
2167 }
2168
Neels Hofmeyra5302c82018-11-04 23:09:58 +01002169 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002170 f_shutdown_helper();
Harald Welte85804d42017-12-10 14:11:58 +01002171}
2172
Pau Espin Pedrolc675b612020-01-09 19:55:40 +01002173/* Verify T(iar) triggers and releases the channel */
2174testcase TC_chan_rel_sccp_tiar_timeout() runs on test_CT {
2175 var DchanTuple dt;
2176
2177 /* Set T(iar) in BSC low enough that it will trigger before other side
2178 has time to keep alive with a T(ias). Keep recommended ratio of
2179 T(iar) >= T(ias)*2 */
2180 g_bsc_sccp_timer_ias := 2;
2181 g_bsc_sccp_timer_iar := 5;
2182
2183 f_init(1);
2184
2185 dt := f_est_dchan('23'O, 23, '00010203040506'O);
2186 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002187 f_shutdown_helper();
Pau Espin Pedrolc675b612020-01-09 19:55:40 +01002188}
2189
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02002190private function f_tc_chan_rel_rr_cause(myBSSMAP_Cause clear_cmd_cause, template RR_Cause expect_rr_cause)
2191runs on test_CT
2192{
2193 var DchanTuple dt;
2194
2195 dt := f_est_dchan('23'O, 23, '00010203040506'O);
2196 var BssmapCause cause := 0;
2197 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(enum2int(clear_cmd_cause))));
2198 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete)) {
2199 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
2200 }
2201
2202 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 +02002203}
2204
2205/* Test that Clear Command cause codes affect the RR Channel Release cause code */
2206testcase TC_chan_rel_rr_cause() runs on test_CT {
2207 f_init(1);
2208
2209 f_tc_chan_rel_rr_cause(GSM0808_CAUSE_CALL_CONTROL, GSM48_RR_CAUSE_NORMAL);
2210 f_tc_chan_rel_rr_cause(GSM0808_CAUSE_HANDOVER_SUCCESSFUL, GSM48_RR_CAUSE_NORMAL);
2211 f_tc_chan_rel_rr_cause(GSM0808_CAUSE_PREEMPTION, GSM48_RR_CAUSE_PREMPTIVE_REL);
2212 f_tc_chan_rel_rr_cause(GSM0808_CAUSE_RADIO_INTERFACE_MESSAGE_FAILURE, GSM48_RR_CAUSE_PROT_ERROR_UNSPC);
2213 f_tc_chan_rel_rr_cause(GSM0808_CAUSE_RADIO_INTERFACE_FAILURE, GSM48_RR_CAUSE_ABNORMAL_UNSPEC);
2214 f_tc_chan_rel_rr_cause(GSM0808_CAUSE_EQUIPMENT_FAILURE, GSM48_RR_CAUSE_ABNORMAL_UNSPEC);
Vadim Yanitskiye18aebb2021-01-03 13:10:43 +01002215
2216 f_shutdown_helper();
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02002217}
2218
Harald Welte5cd20ed2017-12-13 21:03:20 +01002219/* Test behavior if RSL EST IND for non-active channel */
2220testcase TC_rll_est_ind_inact_lchan() runs on test_CT {
2221 timer T := 2.0;
2222
Harald Welte89d42e82017-12-17 16:42:41 +01002223 f_init(1);
Harald Welte5cd20ed2017-12-13 21:03:20 +01002224
2225 var octetstring l3 := '00010203040506'O;
2226 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(6));
2227 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
2228
2229 T.start;
2230 alt {
2231 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) {
2232 setverdict(fail, "MSC received COMPL L3 for non-active lchan");
2233 }
2234 [] BSSAP.receive {}
2235 [] IPA_RSL[0].receive {}
2236 [] T.timeout {}
2237 }
2238
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002239 f_shutdown_helper();
Harald Welte5cd20ed2017-12-13 21:03:20 +01002240}
2241
2242/* Test behavior if RSL EST IND for invalid SAPI */
2243testcase TC_rll_est_ind_inval_sapi1() runs on test_CT {
2244 var RslChannelNr chan_nr;
2245
Harald Welte89d42e82017-12-17 16:42:41 +01002246 f_init(1);
Harald Welte5cd20ed2017-12-13 21:03:20 +01002247
2248 chan_nr := f_chreq_act_ack()
2249
2250 var octetstring l3 := '00010203040506'O;
2251 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(1)), l3));
2252
2253 timer T := 2.0;
2254 T.start;
2255 alt {
2256 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) {
2257 setverdict(fail, "MSC received COMPL L3 for invalid SAPI 1");
2258 }
2259 [] BSSAP.receive { repeat; }
2260 [] IPA_RSL[0].receive { repeat; }
2261 [] T.timeout {}
2262 }
2263
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002264 f_shutdown_helper();
Harald Welte5cd20ed2017-12-13 21:03:20 +01002265}
2266
2267/* Test behavior if RSL EST IND for invalid SAPI */
2268testcase TC_rll_est_ind_inval_sapi3() runs on test_CT {
2269 timer T := 2.0;
2270
Harald Welte89d42e82017-12-17 16:42:41 +01002271 f_init(1);
Harald Welte5cd20ed2017-12-13 21:03:20 +01002272
2273 var RslChannelNr chan_nr := f_chreq_act_ack();
2274
2275 var octetstring l3 := '00010203040506'O;
2276 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(3)), l3));
2277
2278 T.start;
2279 alt {
2280 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) {
2281 setverdict(fail, "MSC received COMPL L3 for invalid SAPI 3");
2282 }
2283 [] BSSAP.receive { repeat; }
2284 [] IPA_RSL[0].receive { repeat; }
2285 [] T.timeout {}
2286 }
2287
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002288 f_shutdown_helper();
Harald Welte5cd20ed2017-12-13 21:03:20 +01002289}
2290
2291/* Test behavior if RSL EST IND for invalid SACCH */
2292testcase TC_rll_est_ind_inval_sacch() runs on test_CT {
2293 timer T := 2.0;
2294
Harald Welte89d42e82017-12-17 16:42:41 +01002295 f_init(1);
Harald Welte5cd20ed2017-12-13 21:03:20 +01002296
2297 var RslChannelNr chan_nr := f_chreq_act_ack();
2298
2299 var octetstring l3 := '00010203040506'O;
2300 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_SACCH(0)), l3));
2301
2302 T.start;
2303 alt {
2304 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) {
2305 setverdict(fail, "MSC received COMPL L3 for invalid Link SACCH");
2306 }
2307 [] BSSAP.receive { repeat; }
2308 [] IPA_RSL[0].receive { repeat; }
2309 [] T.timeout {}
2310 }
2311
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002312 f_shutdown_helper();
Harald Welte5cd20ed2017-12-13 21:03:20 +01002313}
2314
Vadim Yanitskiy61f784a2020-10-01 21:12:19 +07002315/* Verify DLCI / RSL Link ID conversion for MO/MT messages on SAPI0/SAPI3 */
2316private function f_TC_tch_dlci_link_id_sapi(charstring id) runs on MSC_ConnHdlr {
2317 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
2318 var PDU_BSSAP ass_cmd := f_gen_ass_req();
2319
2320 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
2321 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
2322
2323 f_establish_fully(ass_cmd, exp_compl);
2324
2325 /* SAPI0 has already been established by f_establish_fully(), establish SAPI3 */
2326 RSL.send(ts_RSL_EST_IND(g_chan_nr, ts_RslLinkID_SACCH(3), '0904'O));
2327 /* Expect BSSAP/DTAP on SAPI3 (DLCI IE) */
2328 BSSAP.receive(PDU_BSSAP:{
2329 discriminator := '1'B,
2330 spare := '0000000'B,
2331 dlci := 'C3'O,
2332 lengthIndicator := ?,
2333 pdu := { dtap := '0904'O }
2334 });
2335
2336 /* Send messages on DCCH/SAPI0 and ACCH/SAPI3 */
2337 for (var integer i := 0; i < 32; i := i + 1) {
2338 var octetstring l3 := '09'O & f_rnd_octstring(14);
2339 var template (value) RslLinkId link_id;
2340 var template (value) OCT1 dlci;
2341
2342 if (i mod 2 == 0) {
2343 /* SAPI0 on FACCH or SDCCH */
2344 link_id := ts_RslLinkID_DCCH(0);
2345 dlci := '80'O;
2346 } else {
2347 /* SAPI3 on SACCH */
2348 link_id := ts_RslLinkID_SACCH(3);
2349 dlci := 'C3'O;
2350 }
2351
2352 /* Send MO message: RSL -> BSSAP */
Neels Hofmeyr0aa719b2020-10-12 18:43:09 +00002353 f_mo_l3_transceive(RSL, link_id, dlci, l3);
Vadim Yanitskiy61f784a2020-10-01 21:12:19 +07002354 /* Send MT message: BSSAP -> RSL */
Neels Hofmeyr0aa719b2020-10-12 18:43:09 +00002355 f_mt_l3_transceive(RSL, link_id, dlci, l3);
Vadim Yanitskiy61f784a2020-10-01 21:12:19 +07002356 }
2357}
2358testcase TC_tch_dlci_link_id_sapi() runs on test_CT {
2359 var TestHdlrParams pars := f_gen_test_hdlr_pars();
2360 var MSC_ConnHdlr vc_conn;
2361
2362 f_init(1, true);
2363 f_sleep(1.0);
2364
2365 vc_conn := f_start_handler(refers(f_TC_tch_dlci_link_id_sapi), pars);
2366 vc_conn.done;
2367
2368 f_shutdown_helper();
2369}
2370
Vadim Yanitskiy6ef5dfa2020-08-28 18:04:41 +07002371private function f_exp_sapi_n_reject(template (present) GsmSapi sapi := ?,
2372 template myBSSMAP_Cause cause := ?,
2373 float T_val := 2.0)
2374runs on test_CT {
2375 var BSSAP_N_DATA_ind rx_di;
2376 timer T;
2377
2378 var template BSSMAP_IE_Cause tr_cause := tr_BSSMAP_IE_Cause(cause);
2379 var template PDU_BSSAP tr_pdu := tr_BSSMAP_SAPInReject(sapi);
2380
2381 T.start(T_val);
2382 alt {
2383 [] BSSAP.receive(tr_BSSAP_DATA_ind(?, tr_pdu)) -> value rx_di {
2384 var BSSMAP_IE_Cause rx_cause := rx_di.userData.pdu.bssmap.sAPInReject.cause;
2385 if (not match(rx_cause, tr_cause)) {
2386 setverdict(fail, "Rx unexpected Cause IE: ",
2387 rx_cause, " vs expected ", tr_cause);
2388 }
2389 setverdict(pass);
2390 }
2391 [] BSSAP.receive(BSSAP_N_DATA_ind:?) -> value rx_di {
2392 setverdict(fail, "Rx unexpected BSSAP PDU: ", rx_di);
2393 }
2394 [] T.timeout {
2395 setverdict(fail, "Timeout waiting for BSSMAP SAPI N Reject");
2396 }
2397 }
2398}
2399
2400/* Check if we get SAPI N Reject on receipt of unexpected RLL RELease INDication */
2401testcase TC_rll_rel_ind_sapi_n_reject() runs on test_CT {
2402 var octetstring rnd_data := f_rnd_octstring(16);
2403 var RSL_Message rx_rsl;
2404 var DchanTuple dt;
2405
2406 f_init(1);
2407
2408 /* MS establishes a SAPI=0 link on DCCH */
2409 dt := f_est_dchan(f_rnd_ra_cs(), 23, rnd_data);
2410
2411 /* MSC sends some data on (not yet established) SAPI=3 link */
2412 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSAP_DTAP(rnd_data, '03'O)));
2413 /* BSC attempts to establish a SAPI=3 link on DCCH */
2414 rx_rsl := f_exp_ipa_rx(0, tr_RSL_EST_REQ(dt.rsl_chan_nr, tr_RslLinkID_DCCH(3)));
2415
2416 /* MS sends unexpected RELease INDication on SAPI=3 */
2417 f_ipa_tx(0, ts_RSL_REL_IND(dt.rsl_chan_nr, ts_RslLinkID_DCCH(3)));
2418 /* We expect to receive BSSMAP SAPI N Reject message from the BSC */
2419 f_exp_sapi_n_reject(3, GSM0808_CAUSE_MS_NOT_EQUIPPED);
2420
2421 /* Clean up the connection */
2422 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
2423 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
2424
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002425 f_shutdown_helper();
Vadim Yanitskiy6ef5dfa2020-08-28 18:04:41 +07002426}
2427
2428/* Check if we get SAPI N Reject on receipt of unexpected RLL ERROR INDication */
2429testcase TC_rll_err_ind_sapi_n_reject() runs on test_CT {
2430 var octetstring rnd_data := f_rnd_octstring(16);
2431 var RSL_Message rx_rsl;
2432 var DchanTuple dt;
2433
2434 f_init(1);
2435
2436 /* MS establishes a SAPI=0 link on DCCH */
2437 dt := f_est_dchan(f_rnd_ra_cs(), 23, rnd_data);
2438
2439 /* MSC sends some data on (not yet established) SAPI=3 link */
2440 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSAP_DTAP(rnd_data, '03'O)));
2441 /* BSC attempts to establish a SAPI=3 link on DCCH */
2442 rx_rsl := f_exp_ipa_rx(0, tr_RSL_EST_REQ(dt.rsl_chan_nr, tr_RslLinkID_DCCH(3)));
2443
2444 /* BTS sends unexpected ERROR INDication on SAPI=3 */
2445 f_ipa_tx(0, ts_RSL_ERROR_IND(dt.rsl_chan_nr, ts_RslLinkID_DCCH(3), ''O));
2446 /* We expect to receive BSSMAP SAPI N Reject message from the BSC */
2447 f_exp_sapi_n_reject(3, GSM0808_CAUSE_BSS_NOT_EQUIPPED);
2448
2449 /* Clean up the connection */
2450 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
2451 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
2452
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002453 f_shutdown_helper();
Vadim Yanitskiy6ef5dfa2020-08-28 18:04:41 +07002454}
2455
2456/* Check if we get SAPI N Reject due to a SAPI=3 link establishment timeout */
2457testcase TC_rll_timeout_sapi_n_reject() runs on test_CT {
2458 var octetstring rnd_data := f_rnd_octstring(16);
2459 var RSL_Message rx_rsl;
2460 var DchanTuple dt;
2461
2462 f_init(1);
2463
2464 /* MS establishes a SAPI=0 link on DCCH */
2465 dt := f_est_dchan(f_rnd_ra_cs(), 23, rnd_data);
2466
2467 /* MSC sends some data on (not yet established) SAPI=3 link */
2468 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSAP_DTAP(rnd_data, '03'O)));
2469 /* BSC attempts to establish a SAPI=3 link on DCCH */
2470 rx_rsl := f_exp_ipa_rx(0, tr_RSL_EST_REQ(dt.rsl_chan_nr, tr_RslLinkID_DCCH(3)));
2471
2472 /* MS does not respond, so the link establishment timeout triggers SAPI N Reject */
2473 f_exp_sapi_n_reject(3, GSM0808_CAUSE_BSS_NOT_EQUIPPED, T_val := 8.0);
2474
2475 /* Clean up the connection */
2476 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
2477 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
2478
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002479 f_shutdown_helper();
Vadim Yanitskiy6ef5dfa2020-08-28 18:04:41 +07002480}
2481
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +02002482testcase TC_si_default() runs on test_CT {
2483 f_init(0);
2484 f_init_bts_and_check_sysinfo(0, expect_si := SystemInformationConfig_default);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002485 f_shutdown_helper();
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +02002486}
Harald Welte4003d112017-12-09 22:35:39 +01002487
Neels Hofmeyr56f24782020-07-09 00:50:49 +02002488/* We're testing SI2quater with lists of EARFCNs. Instead of just incrementing EARFCNs, also pick some from the edges of
2489 * the entire value range. This function provides the same EARFCN numbers for the same earfcn_index */
2490private function f_test_si2quater_earfcn_by_idx(integer earfcn_index) return uint16_t
2491{
2492 select (earfcn_index) {
2493 case (0) {
2494 /* E-ARFCN 111 is already added in the osmo-bsc.cfg */
2495 return 111;
2496 }
2497 case (1) {
2498 return 1;
2499 }
2500 case (2) {
2501 return 0;
2502 }
2503 case (3) {
2504 return 65535;
2505 }
2506 case else {
2507 return 23 * (earfcn_index - 3);
2508 }
2509 }
2510}
2511
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02002512function f_test_si2quater(integer total_earfcns, template SystemInformationConfig expect_si,
2513 template CellSelIndValue expect_cells := omit) runs on test_CT {
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002514
2515 f_init(0);
2516
2517 /* E-ARFCN 111 is already added in the osmo-bsc.cfg, so only add more arfcns if total_earfcns > 1 */
2518 for (var integer i := 1; i < total_earfcns; i := i + 1) {
Neels Hofmeyr56f24782020-07-09 00:50:49 +02002519 f_bts_0_cfg(BSCVTY, {"si2quater neighbor-list add earfcn " & int2str(f_test_si2quater_earfcn_by_idx(i))
2520 & " thresh-hi 20 thresh-lo 10 prio 3 qrxlv 22 meas 3"});
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002521 }
2522
2523 f_init_bts_and_check_sysinfo(0, expect_si := expect_si);
2524
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02002525 if (not istemplatekind(expect_cells, "omit")) {
2526 /* Also check that RR Channel Release contains these EARFCNs.
2527 * (copied code from TC_chan_rel_hard_clear_csfb) */
2528 var BSSAP_N_DATA_ind rx_di;
2529 var DchanTuple dt;
2530
2531 dt := f_est_dchan('23'O, 23, '00010203040506'O);
Pau Espin Pedrold0046312021-04-19 16:35:58 +02002532 /* Send CommonID with some random PLMN (BSC doesn't take it into account
2533 * yet when generating the EUTRAN neigh list in RR CHannel Release) */
2534 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_CommonId('001019876543210'H, '323454'O)));
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02002535
2536 /* Instruct BSC to clear channel */
2537 var BssmapCause cause := 0;
2538 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommandCSFB(cause)));
2539
2540 /* expect Clear Complete from BSC on A */
2541 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete)) {
2542 /* release the SCCP connection */
2543 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
2544 }
2545
Pau Espin Pedrol841b90d2021-04-15 16:42:52 +02002546 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 +02002547 }
2548
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002549 for (var integer i := 1; i < total_earfcns; i := i + 1) {
Neels Hofmeyr56f24782020-07-09 00:50:49 +02002550 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 +02002551 }
2552}
2553
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002554private function f_tr_si2quater_earfcns(integer count) return template SI2quaterRestOctetsList
2555{
2556 var template SI2quaterRestOctetsList si2quater := {};
2557 var integer si2quater_count := (count + 2) / 3;
2558
2559 for (var integer i := 0; i < count; i := i + 1) {
Neels Hofmeyr56f24782020-07-09 00:50:49 +02002560 var integer earfcn := f_test_si2quater_earfcn_by_idx(i);
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002561 var integer index := i / 3;
2562 var integer earfcn_index := i mod 3;
2563 if (index >= lengthof(si2quater)) {
2564 si2quater[index] := tr_SI2quaterRestOctets_EUTRAN(index := index, count := si2quater_count - 1);
2565 }
2566 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);
2567 }
2568
2569 return si2quater;
2570}
2571
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02002572private function f_tr_rr_chan_rel_earfcns(integer count) return template CellSelIndValue
2573{
2574 var template CellSelIndValue_EUTRAN_Descrs cells := {};
2575
Alexander Couzensf74b5cb2020-09-10 22:28:40 +02002576 /* the lte neighbors must match the config & vty to pass this test */
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02002577 for (var integer i := 0; i < count; i := i + 1) {
2578 var integer earfcn := f_test_si2quater_earfcn_by_idx(i);
Alexander Couzensf74b5cb2020-09-10 22:28:40 +02002579 cells[i] := tr_CellSelIndValue_EUTRAN_Descr(earfcn, '1'B, 3);
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02002580 }
2581
2582 return tr_CellSelIndValue_EUTRAN(cells);
2583}
2584
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002585private function f_tc_si2quater_n_earfcns(integer n) runs on test_CT
2586{
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002587 var template SystemInformationConfig sic := SystemInformationConfig_default;
Pau Espin Pedrol8ab62e42020-12-18 16:19:11 +01002588 sic.si2quater := f_tr_si2quater_earfcns(n);
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02002589 var template CellSelIndValue cells := f_tr_rr_chan_rel_earfcns(n);
2590 f_test_si2quater(n, sic, cells);
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002591}
2592
2593testcase TC_si2quater_2_earfcns() runs on test_CT {
2594 f_tc_si2quater_n_earfcns(2);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002595 f_shutdown_helper();
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002596}
2597
2598testcase TC_si2quater_3_earfcns() runs on test_CT {
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002599 f_tc_si2quater_n_earfcns(3);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002600 f_shutdown_helper();
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002601}
2602
2603testcase TC_si2quater_4_earfcns() runs on test_CT {
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002604 f_tc_si2quater_n_earfcns(4);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002605 f_shutdown_helper();
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002606}
2607
2608testcase TC_si2quater_5_earfcns() runs on test_CT {
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002609 f_tc_si2quater_n_earfcns(5);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002610 f_shutdown_helper();
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002611}
2612
2613testcase TC_si2quater_6_earfcns() runs on test_CT {
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002614 f_tc_si2quater_n_earfcns(6);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002615 f_shutdown_helper();
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002616}
2617
2618testcase TC_si2quater_12_earfcns() runs on test_CT {
2619 f_tc_si2quater_n_earfcns(12);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002620 f_shutdown_helper();
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002621}
2622
2623testcase TC_si2quater_23_earfcns() runs on test_CT {
2624 f_tc_si2quater_n_earfcns(23);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002625 f_shutdown_helper();
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002626}
2627
2628testcase TC_si2quater_32_earfcns() runs on test_CT {
2629 f_tc_si2quater_n_earfcns(32);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002630 f_shutdown_helper();
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002631}
2632
2633testcase TC_si2quater_33_earfcns() runs on test_CT {
2634 f_tc_si2quater_n_earfcns(33);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002635 f_shutdown_helper();
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002636}
2637
2638testcase TC_si2quater_42_earfcns() runs on test_CT {
2639 f_tc_si2quater_n_earfcns(42);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002640 f_shutdown_helper();
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002641}
2642
2643testcase TC_si2quater_48_earfcns() runs on test_CT {
2644 f_tc_si2quater_n_earfcns(48);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002645 f_shutdown_helper();
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002646}
2647
2648/* verify the VTY error response when adding too many EARFCNs, and showing that osmo-bsc still sends 16 SI2quater with
2649 * 48 EARFCNs. */
2650testcase TC_si2quater_49_earfcns() runs on test_CT {
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002651 var template SystemInformationConfig sic := SystemInformationConfig_default;
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002652 sic.si2quater := f_tr_si2quater_earfcns(48); /* 48, not 49! */
2653 f_init(0);
2654
2655 for (var integer i := 1; i < 48; i := i + 1) {
Neels Hofmeyr56f24782020-07-09 00:50:49 +02002656 f_bts_0_cfg(BSCVTY, {"si2quater neighbor-list add earfcn " & int2str(f_test_si2quater_earfcn_by_idx(i))
2657 & " thresh-hi 20 thresh-lo 10 prio 3 qrxlv 22 meas 3"});
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002658 }
2659
2660 /* The 49th EARFCN no longer fits, expect VTY error */
2661 f_vty_enter_cfg_bts(BSCVTY, 0);
2662 var charstring vty_error;
2663 vty_error := f_vty_transceive_ret(BSCVTY,
2664 "si2quater neighbor-list add earfcn 70 thresh-hi 20 thresh-lo 10 prio 3 qrxlv 22 meas 3")
2665 f_vty_transceive(BSCVTY, "end");
2666
2667 if (f_strstr(vty_error, "Unable to add ARFCN 70") >= 0) {
2668 log("Got expected VTY error: ", vty_error);
2669 setverdict(pass);
2670 } else {
2671 setverdict(fail, "Expected the 49th EUTRAN ARFCN to be rejected by vty config, got: ", vty_error);
2672 }
2673
2674 f_init_bts_and_check_sysinfo(0, expect_si := sic);
2675
2676 for (var integer i := 1; i < 48; i := i + 1) {
Neels Hofmeyr56f24782020-07-09 00:50:49 +02002677 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 +02002678 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002679 f_shutdown_helper();
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002680}
2681
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02002682private function f_acc09_count_allowed(AccessControlClass acc) return uint8_t
2683{
2684 var uint8_t count := 0;
2685 for (var integer i := 5; i < 16; i := i + 1) {
2686 if (acc[i] == '0'B) { /* the list marks barred, we count allowed */
2687 count := count + 1;
2688 }
2689 }
2690 return count;
2691}
2692
Pau Espin Pedrolc6136cd2020-07-24 13:20:02 +02002693private function f_recv_next_si1(integer rsl_idx := 0) runs on test_CT return SystemInformationType1
2694{
2695 var ASP_RSL_Unitdata rx_rsl_ud;
2696 var SystemInformationType1 last_si1;
2697
2698 timer T := 30.0;
2699 T.start;
2700 alt {
2701 [] IPA_RSL[rsl_idx].receive(tr_ASP_RSL_UD((tr_RSL_NO_BCCH_INFO,
2702 tr_RSL_BCCH_INFO,
2703 tr_RSL_NO_SACCH_FILL,
2704 tr_RSL_SACCH_FILL))
2705 ) -> value rx_rsl_ud {
2706 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
2707 if (g_system_information[rsl_idx].si1 == omit) {
2708 repeat;
2709 }
2710 last_si1 := g_system_information[rsl_idx].si1;
2711 g_system_information[rsl_idx].si1 := omit;
2712 T.stop;
2713 }
Vadim Yanitskiy79ebd5e2021-01-04 00:12:55 +01002714 [] IPA_RSL[rsl_idx].receive { repeat; }
Pau Espin Pedrolc6136cd2020-07-24 13:20:02 +02002715 [] T.timeout { setverdict(fail, "Timeout receiving next SI1"); }
2716 }
2717 return last_si1;
2718}
2719
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02002720/* verify ACC rotate feature */
2721testcase TC_si_acc_rotate() runs on test_CT {
2722 var template SystemInformationConfig sic := SystemInformationConfig_default;
Pau Espin Pedrolc6136cd2020-07-24 13:20:02 +02002723 var SystemInformationType1 last_si1;
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02002724 var AccessControlClass acc;
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02002725 var uint8_t count;
2726 var integer times_allowed[10] := { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
2727
2728 f_init(0, guard_timeout := 60.0);
2729
2730 f_bts_0_cfg(BSCVTY, {"rach access-control-class 5 barred",
2731 "access-control-class-rotate 3",
2732 "access-control-class-rotate-quantum 1"});
2733
2734 /* Init and get first sysinfo */
2735 f_init_bts_and_check_sysinfo(0, expect_si := ?);
2736
Pau Espin Pedrolc6136cd2020-07-24 13:20:02 +02002737 for (var integer i:= 0; i < 20; i := i + 1) {
2738 last_si1 := f_recv_next_si1(0);
2739 acc := last_si1.rach_control.acc;
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02002740 count := f_acc09_count_allowed(acc);
2741 log("RSL: GOT SI1 ACC len=", count, ": ", acc);
2742
2743 if (count != 3) {
2744 log("RSL: EXPECTED SI ACC len=3");
2745 setverdict(fail, "received SI does not match expectations");
2746 break;
2747 }
2748
2749 for (var integer j := 0; j < 10; j := j + 1) {
2750 if (acc[16 - 1 - j] == '0'B) { /* the list marks barred, we count allowed */
2751 times_allowed[j] := times_allowed[j] + 1;
2752 }
2753 }
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02002754 }
2755
2756 for (var integer j := 0; j < 10; j := j + 1) {
2757 log("ACC", j, " allowed ", times_allowed[j], " times" );
2758 if (j != 5 and times_allowed[j] < 3) {
2759 setverdict(fail, "ACC", j, " ERROR: allowed ", times_allowed[j], " < 1 times");
2760 } else if (j == 5 and times_allowed[j] > 0) {
2761 setverdict(fail, "ACC", j, " ERROR: allowed ", times_allowed[j], " > 0 times");
2762 }
2763 }
2764
2765 f_bts_0_cfg(BSCVTY, {"access-control-class-rotate 10",
2766 "rach access-control-class 5 allowed"});
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002767 f_shutdown_helper();
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02002768}
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002769
Pau Espin Pedrolc6136cd2020-07-24 13:20:02 +02002770/* verify ACC startup ramp+rotate feature */
2771testcase TC_si_acc_ramp_rotate() runs on test_CT {
2772 var template SystemInformationConfig sic := SystemInformationConfig_default;
2773 var SystemInformationType1 last_si1;
2774 var AccessControlClass acc;
2775 var ASP_RSL_Unitdata rx_rsl_ud;
2776 var uint8_t count;
2777 var uint8_t prev_count;
2778 var integer times_allowed[10] := { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
2779
2780 f_init(0, guard_timeout := 80.0);
2781
2782 f_bts_0_cfg(BSCVTY, {"rach access-control-class 4 barred",
2783 "access-control-class-rotate 0",
2784 "access-control-class-rotate-quantum 1",
2785 "access-control-class-ramping",
2786 "access-control-class-ramping-step-interval 5",
2787 "access-control-class-ramping-step-size 5"});
2788
2789 /* Init and get first sysinfo */
2790 f_init_bts_and_check_sysinfo(0, expect_si := ?);
2791 last_si1 := g_system_information[0].si1;
2792 acc := last_si1.rach_control.acc;
2793 count := f_acc09_count_allowed(acc);
2794 /* Adm subset size was set to 0 above, so wait until all ACC are barred */
2795 while (count > 0) {
2796 last_si1 := f_recv_next_si1(0);
2797 acc := last_si1.rach_control.acc;
2798 count := f_acc09_count_allowed(acc);
2799 log("RSL: wait len()=0: GOT SI1 ACC len=", count, ": ", acc);
2800 }
2801
2802 /* Increase adm subset size, we should see ramping start up */
2803 f_bts_0_cfg(BSCVTY, {"access-control-class-rotate 10"});
2804 prev_count := 0;
2805 while (true) {
2806 last_si1 := f_recv_next_si1(0);
2807 acc := last_si1.rach_control.acc;
2808 count := f_acc09_count_allowed(acc);
2809 log("RSL: GOT SI1 ACC len=", count, ": ", acc);
2810
2811 if (prev_count > count) {
2812 setverdict(fail, "ACC allowed count dropped while expecting grow: ", prev_count, " -> ", count);
2813 break;
2814 }
2815
2816 if (count == 9) {
2817 break; /* Maximum reached (10 - 1 perm barred), done here */
2818 }
2819
2820 prev_count := count;
2821 }
2822
2823 setverdict(pass);
2824
2825 f_bts_0_cfg(BSCVTY, {"access-control-class-rotate 10",
2826 "rach access-control-class 4 allowed",
2827 "no access-control-class-ramping"});
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002828 f_shutdown_helper();
Pau Espin Pedrolc6136cd2020-07-24 13:20:02 +02002829}
2830
Harald Welte4003d112017-12-09 22:35:39 +01002831testcase TC_ctrl_msc_connection_status() runs on test_CT {
2832 var charstring ctrl_resp;
2833
Harald Welte89d42e82017-12-17 16:42:41 +01002834 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +01002835
2836 /* See https://osmocom.org/issues/2729 */
2837 f_ctrl_get_exp(IPA_CTRL, "msc_connection_status", "connected");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002838 f_shutdown_helper();
Harald Welte4003d112017-12-09 22:35:39 +01002839}
2840
Stefan Sperlingb041b3d2018-01-03 17:14:55 +01002841testcase TC_ctrl_msc0_connection_status() runs on test_CT {
2842 var charstring ctrl_resp;
2843
2844 f_init(1);
Stefan Sperlingb041b3d2018-01-03 17:14:55 +01002845
2846 f_ctrl_get_exp(IPA_CTRL, "msc.0.connection_status", "connected");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002847 f_shutdown_helper();
Stefan Sperlingb041b3d2018-01-03 17:14:55 +01002848}
2849
Neels Hofmeyr0bc470d2021-08-21 13:37:13 +02002850/* Verify correct stats on the number of configured and connected MSCs */
2851private function f_tc_stat_num_msc_connected_msc_connhdlr(integer expect_num_msc_connected) runs on MSC_ConnHdlr {
2852 g_pars := f_gen_test_hdlr_pars();
2853 var StatsDExpects expect := {
2854 { name := "TTCN3.bsc.0.num_msc.connected", mtype := "g", min := expect_num_msc_connected, max := expect_num_msc_connected },
2855 { name := "TTCN3.bsc.0.num_msc.total", mtype := "g", min := NUM_MSC, max := NUM_MSC }
2856 };
2857 f_statsd_expect(expect);
2858}
2859
2860private function f_tc_stat_num_msc_connected_test_ct(void_fn tc_fn, integer nr_msc) runs on test_CT
2861{
2862 var MSC_ConnHdlr vc_conn;
2863
2864 f_init(nr_bts := 1, handler_mode := true, nr_msc := nr_msc);
2865 f_sleep(1.0);
2866 vc_conn := f_start_handler(tc_fn);
2867 vc_conn.done;
2868
2869 /* Also verify stat exposed on CTRL interface */
2870 f_ctrl_get_exp(IPA_CTRL, "stat_item.last.bsc.0.num_msc:connected", int2str(nr_msc));
2871 f_ctrl_get_exp(IPA_CTRL, "stat_item.last.bsc.0.num_msc:total", int2str(NUM_MSC));
2872
2873 f_shutdown_helper();
2874}
2875
2876/* Verify that when 1 MSC is active, that num_msc:connected reports 1. */
2877private function f_tc_stat_num_msc_connected_1(charstring id) runs on MSC_ConnHdlr {
2878 f_tc_stat_num_msc_connected_msc_connhdlr(1);
2879}
2880testcase TC_stat_num_msc_connected_1() runs on test_CT {
2881 f_tc_stat_num_msc_connected_test_ct(refers(f_tc_stat_num_msc_connected_1), 1);
2882}
2883
2884/* Verify that when 2 MSCs are active, that num_msc:connected reports 2. */
2885private function f_tc_stat_num_msc_connected_2(charstring id) runs on MSC_ConnHdlr {
2886 f_tc_stat_num_msc_connected_msc_connhdlr(2);
2887}
2888testcase TC_stat_num_msc_connected_2() runs on test_CT {
2889 f_tc_stat_num_msc_connected_test_ct(refers(f_tc_stat_num_msc_connected_2), 2);
2890}
2891
2892/* Verify that when 3 MSCs are active, that num_msc:connected reports 3. */
2893private function f_tc_stat_num_msc_connected_3(charstring id) runs on MSC_ConnHdlr {
2894 f_tc_stat_num_msc_connected_msc_connhdlr(3);
2895}
2896testcase TC_stat_num_msc_connected_3() runs on test_CT {
2897 f_tc_stat_num_msc_connected_test_ct(refers(f_tc_stat_num_msc_connected_3), 3);
2898}
2899
Neels Hofmeyr5ce3ae42021-08-29 15:32:00 +02002900/* Verify correct stats on the number of configured and connected MSCs */
2901private function f_tc_stat_num_bts_connected_msc_connhdlr(integer expect_num_bts_connected) runs on MSC_ConnHdlr {
2902 g_pars := f_gen_test_hdlr_pars();
2903 var StatsDExpects expect := {
2904 { name := "TTCN3.bsc.0.num_bts.oml_connected", mtype := "g", min := expect_num_bts_connected, max := NUM_BTS_CFG },
2905 { name := "TTCN3.bsc.0.num_bts.all_trx_rsl_connected", mtype := "g", min := expect_num_bts_connected, max := expect_num_bts_connected },
2906 { name := "TTCN3.bsc.0.num_bts.total", mtype := "g", min := NUM_BTS_CFG, max := NUM_BTS_CFG },
2907 { name := "TTCN3.bsc.0.num_trx.rsl_connected", mtype := "g", min := expect_num_bts_connected, max := expect_num_bts_connected },
2908 { name := "TTCN3.bsc.0.num_trx.total", mtype := "g", min := NUM_BTS_CFG, max := NUM_BTS_CFG }
2909 };
2910 f_statsd_expect(expect);
2911}
2912
2913private function f_tc_stat_num_bts_connected_test_ct(void_fn tc_fn, integer nr_bts) runs on test_CT {
2914 var MSC_ConnHdlr vc_conn;
2915
2916 f_init(nr_bts := nr_bts, handler_mode := true, nr_msc := 1);
2917 f_sleep(1.0);
2918 vc_conn := f_start_handler(tc_fn);
2919 vc_conn.done;
2920
2921 /* Also verify stat exposed on CTRL interface */
2922 f_ctrl_get_exp(IPA_CTRL, "stat_item.last.bsc.0.num_bts:all_trx_rsl_connected", int2str(nr_bts));
2923 f_ctrl_get_exp(IPA_CTRL, "stat_item.last.bsc.0.num_bts:total", int2str(NUM_BTS_CFG));
2924 f_ctrl_get_exp(IPA_CTRL, "stat_item.last.bsc.0.num_trx:rsl_connected", int2str(nr_bts));
2925 f_ctrl_get_exp(IPA_CTRL, "stat_item.last.bsc.0.num_trx:total", int2str(NUM_BTS_CFG));
2926
Neels Hofmeyra41ae302021-09-06 22:06:02 +02002927 /* Verify rf_states exposed on CTRL interface */
2928 var charstring expect_net_rf_states := "";
2929 for (var integer i := 0; i < NUM_BTS_CFG; i := i + 1) {
2930 var charstring expect_bts_rf_states := int2str(i) & ",0,";
2931 if (i < NUM_BTS) {
2932 /* In these tests, OML for the first NUM_BTS are always connected via osmo-bts-omldummy */
2933 expect_bts_rf_states := expect_bts_rf_states & "operational,unlocked,";
2934 } else {
2935 /* For remaining i < NUM_BTS_CFG, OML is not connected, i.e. inoperational */
2936 expect_bts_rf_states := expect_bts_rf_states & "inoperational,locked,";
2937 }
2938 /* The RF policy is still global in osmo-bsc, i.e. always "on" */
2939 expect_bts_rf_states := expect_bts_rf_states & "on,";
2940 if (i < nr_bts) {
2941 /* For BTS where RSL is connected, the RSL state will be "up" */
2942 expect_bts_rf_states := expect_bts_rf_states & "rsl-up;";
2943 } else {
2944 expect_bts_rf_states := expect_bts_rf_states & "rsl-down;";
2945 }
2946
2947 f_ctrl_get_exp(IPA_CTRL, "bts." & int2str(i) & ".rf_states", expect_bts_rf_states);
2948 expect_net_rf_states := expect_net_rf_states & expect_bts_rf_states;
2949 }
2950 f_ctrl_get_exp(IPA_CTRL, "rf_states", expect_net_rf_states);
2951
Neels Hofmeyr5ce3ae42021-08-29 15:32:00 +02002952 f_shutdown_helper();
2953}
2954
2955/* Verify that when 1 BTS is connected, that num_{bts,trx}:*_connected reports 1. */
2956private function f_tc_stat_num_bts_connected_1(charstring id) runs on MSC_ConnHdlr {
2957 f_tc_stat_num_bts_connected_msc_connhdlr(1);
2958}
2959testcase TC_stat_num_bts_connected_1() runs on test_CT {
2960 f_tc_stat_num_bts_connected_test_ct(refers(f_tc_stat_num_bts_connected_1), 1);
2961}
2962
2963/* Verify that when 2 BTS is connected, that num_{bts,trx}:*_connected reports 2. */
2964private function f_tc_stat_num_bts_connected_2(charstring id) runs on MSC_ConnHdlr {
2965 f_tc_stat_num_bts_connected_msc_connhdlr(2);
2966}
2967testcase TC_stat_num_bts_connected_2() runs on test_CT {
2968 f_tc_stat_num_bts_connected_test_ct(refers(f_tc_stat_num_bts_connected_2), 2);
2969}
2970
2971/* Verify that when 3 BTS is connected, that num_{bts,trx}:*_connected reports 3. */
2972private function f_tc_stat_num_bts_connected_3(charstring id) runs on MSC_ConnHdlr {
2973 f_tc_stat_num_bts_connected_msc_connhdlr(3);
2974}
2975testcase TC_stat_num_bts_connected_3() runs on test_CT {
2976 f_tc_stat_num_bts_connected_test_ct(refers(f_tc_stat_num_bts_connected_3), 3);
2977}
2978
Harald Welte4003d112017-12-09 22:35:39 +01002979testcase TC_ctrl() runs on test_CT {
2980 var charstring ctrl_resp;
2981
Harald Welte89d42e82017-12-17 16:42:41 +01002982 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +01002983
2984 /* all below values must match the osmo-bsc.cfg config file used */
2985
Harald Welte6a129692018-03-17 17:30:14 +01002986 f_ctrl_get_exp(IPA_CTRL, "mcc", "001");
2987 f_ctrl_get_exp(IPA_CTRL, "mnc", "01");
Oliver Smith75aa0202019-08-19 14:17:50 +02002988 f_ctrl_get_exp(IPA_CTRL, "number-of-bts", "4");
Harald Welte4003d112017-12-09 22:35:39 +01002989
2990 var integer bts_nr := 0;
2991 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "location-area-code", "1");
2992 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "cell-identity", "0");
2993 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "oml-connection-state", "connected");
2994 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "gprs-mode", "gprs");
2995 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "rf_state", "operational,unlocked,on");
2996 f_ctrl_get_exp_trx(IPA_CTRL, bts_nr, 0, "arfcn", "871");
2997 f_ctrl_get_exp_trx(IPA_CTRL, bts_nr, 0, "max-power-reduction", "20");
2998
2999 var integer uptime := str2int(f_ctrl_get_bts(IPA_CTRL, bts_nr, "oml-uptime"));
3000 f_sleep(2.0);
3001 if (str2int(f_ctrl_get_bts(IPA_CTRL, bts_nr, "oml-uptime")) < uptime+1) {
3002 setverdict(fail, "oml-uptime not incrementing as expected");
3003 }
3004 /* TODO: Disconnect RSL, imply that OML is disconnected and check for uptime zero? */
3005
3006 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bsc", 0, "paging:attempted", 0);
3007
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003008 f_shutdown_helper();
Harald Welte96c94412017-12-09 03:12:45 +01003009}
3010
Pau Espin Pedrol5a2d7432019-06-07 19:43:45 +02003011/* Verify that Upon receival of SET "location", BSC forwards a TRAP
3012 "location-state" over the SCCPlite IPA conn */
3013testcase TC_ctrl_location() runs on test_CT {
3014 var MSC_ConnHdlr vc_conn;
3015 var integer bts_nr := 0;
3016
3017 f_init(1, true);
3018 f_sleep(1.0);
3019
3020 f_ctrl_set_bts(IPA_CTRL, bts_nr, "location", "1234567,fix3d,0.340000,0.560000,0.780000");
3021 f_ctrl_exp_trap(SCCPLITE_IPA_CTRL, "bts." & int2str(bts_nr) & ".location-state",
3022 "1234567,fix3d,0.340000,0.560000,0.780000,operational,unlocked,on,001,01");
3023
3024 f_ctrl_set(SCCPLITE_IPA_CTRL, "rf_locked", "1");
3025 f_sleep(2.0);
3026
3027 f_ctrl_set_bts(IPA_CTRL, bts_nr, "location", "1234888,fix3d,0.350000,0.570000,0.790000");
3028 f_ctrl_exp_trap(SCCPLITE_IPA_CTRL, "bts." & int2str(bts_nr) & ".location-state",
3029 "1234888,fix3d,0.350000,0.570000,0.790000,operational,locked,off,001,01");
3030
3031 /* should match the one from config */
3032 f_ctrl_set(SCCPLITE_IPA_CTRL, "rf_locked", "0");
3033
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003034 f_shutdown_helper();
Pau Espin Pedrol5a2d7432019-06-07 19:43:45 +02003035}
3036
Harald Welte6f521d82017-12-11 19:52:02 +01003037
3038/***********************************************************************
3039 * Paging Testing
3040 ***********************************************************************/
3041
3042type record Cell_Identity {
3043 GsmMcc mcc,
3044 GsmMnc mnc,
3045 GsmLac lac,
3046 GsmCellId ci
3047};
Harald Welte24135bd2018-03-17 19:27:53 +01003048private const Cell_Identity cid := { '001'H, '01'H, 1, 0 };
Stefan Sperling049a86e2018-03-20 15:51:00 +01003049private const Cell_Identity unknown_cid := { '678'H, 'f90'H, 1, 0 };
Harald Welte6f521d82017-12-11 19:52:02 +01003050
Harald Welte5d1a2202017-12-13 19:51:29 +01003051type set of integer BtsIdList;
3052
3053private function f_bts_in_list(integer bts_id, BtsIdList bts_ids) return boolean {
3054 for (var integer j := 0; j < sizeof(bts_ids); j := j + 1) {
3055 if (bts_id == bts_ids[j]) {
3056 return true;
3057 }
3058 }
3059 return false;
3060}
Harald Welte6f521d82017-12-11 19:52:02 +01003061
3062/* core paging test helper function; used by most paging test cases */
3063private function f_pageing_helper(hexstring imsi,
3064 template BSSMAP_FIELD_CellIdentificationList cid_list,
Harald Welte5d1a2202017-12-13 19:51:29 +01003065 BtsIdList bts_ids := { 0 },
Harald Welte6f521d82017-12-11 19:52:02 +01003066 template RSL_ChanNeeded rsl_chneed := omit,
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07003067 template (omit) OCT4 tmsi := omit) runs on test_CT
Harald Welte6f521d82017-12-11 19:52:02 +01003068{
3069 var template BSSMAP_IE_ChannelNeeded bssmap_chneed;
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07003070 var template MobileIdentityV mi;
Harald Welte6f521d82017-12-11 19:52:02 +01003071 var RSL_Message rx_rsl;
3072 var integer paging_group := hex2int(imsi[lengthof(imsi)-1]);
Harald Welte5d1a2202017-12-13 19:51:29 +01003073 var integer i;
Harald Welte6f521d82017-12-11 19:52:02 +01003074
3075 f_init();
Harald Welte6f521d82017-12-11 19:52:02 +01003076
3077 /* Clear the queue, it might still contain stuff like BCCH FILLING */
Harald Weltec3068592018-03-17 19:55:31 +01003078 for (i := 0; i < NUM_BTS; i := i + 1) {
3079 IPA_RSL[i].clear;
Harald Welte5d1a2202017-12-13 19:51:29 +01003080 }
Harald Welte6f521d82017-12-11 19:52:02 +01003081
3082 if (isvalue(rsl_chneed)) {
3083 /* The values of 08.08 3.2.2.36 and 08.58 9.3.40 are luckily identical */
3084 bssmap_chneed := ts_BSSMAP_IE_ChanNeeded(int2bit(enum2int(valueof(rsl_chneed)),2));
3085 } else {
3086 bssmap_chneed := omit;
3087 }
3088
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003089 BSSAP.send(ts_BSSAP_UNITDATA_req(g_bssap[0].sccp_addr_peer, g_bssap[0].sccp_addr_own,
3090 ts_BSSMAP_Paging(imsi, cid_list, tmsi, bssmap_chneed)));
Harald Welte6f521d82017-12-11 19:52:02 +01003091
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07003092 if (not istemplatekind(tmsi, "omit")) {
3093 mi := t_MI_TMSI(tmsi);
Harald Welte6f521d82017-12-11 19:52:02 +01003094 } else {
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07003095 mi := tr_MI_IMSI(imsi);
Harald Welte6f521d82017-12-11 19:52:02 +01003096 }
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07003097
Harald Welte5d1a2202017-12-13 19:51:29 +01003098 for (i := 0; i < sizeof(bts_ids); i := i + 1) {
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07003099 rx_rsl := f_exp_ipa_rx(bts_ids[i], tr_RSL_PAGING_CMD(mi));
Harald Welte5d1a2202017-12-13 19:51:29 +01003100 /* check channel type, paging group */
3101 if (rx_rsl.ies[1].body.paging_group != paging_group) {
3102 setverdict(fail, "Paging for wrong paging group");
3103 }
3104 if (ispresent(rsl_chneed) and
3105 rx_rsl.ies[3].body.chan_needed.chan_needed != valueof(rsl_chneed)) {
3106 setverdict(fail, "RSL Channel Needed != BSSMAP Channel Needed");
3107 }
Harald Welte6f521d82017-12-11 19:52:02 +01003108 }
Harald Welte2fccd982018-01-31 15:48:19 +01003109 f_sleep(2.0);
Harald Welte5d1a2202017-12-13 19:51:29 +01003110 /* do a quick check on all not-included BTSs if they received paging */
3111 for (i := 0; i < NUM_BTS; i := i + 1) {
3112 timer T := 0.1;
3113 if (f_bts_in_list(i, bts_ids)) {
3114 continue;
3115 }
3116 T.start;
3117 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07003118 [] IPA_RSL[i].receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD(mi))) {
Harald Welte5d1a2202017-12-13 19:51:29 +01003119 setverdict(fail, "Paging on BTS ", i, " which is not part of ", bts_ids);
3120 }
3121 [] IPA_RSL[i].receive { repeat; }
3122 [] T.timeout { }
3123 }
Harald Welte6f521d82017-12-11 19:52:02 +01003124 }
3125
3126 setverdict(pass);
3127}
3128
Harald Welte5d1a2202017-12-13 19:51:29 +01003129const BtsIdList c_BtsId_all := { 0, 1, 2 };
Harald Welte751d3eb2018-01-31 15:51:06 +01003130const BtsIdList c_BtsId_none := { };
Harald Welte5d1a2202017-12-13 19:51:29 +01003131const BtsIdList c_BtsId_LAC1 := { 0, 1 };
3132const BtsIdList c_BtsId_LAC2 := { 2 };
3133
Harald Welte6f521d82017-12-11 19:52:02 +01003134/* PAGING by IMSI + TMSI */
3135testcase TC_paging_imsi_nochan() runs on test_CT {
3136 var BSSMAP_FIELD_CellIdentificationList cid_list;
3137 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Philipp Maier8c04b0a2018-02-23 13:48:48 +01003138 f_pageing_helper('001010100000001'H, cid_list, c_BtsId_all, omit, omit);
Philipp Maier282ca4b2018-02-27 17:17:00 +01003139 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01003140}
3141
3142/* PAGING by IMSI + TMSI */
3143testcase TC_paging_tmsi_nochan() runs on test_CT {
3144 var BSSMAP_FIELD_CellIdentificationList cid_list;
3145 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01003146 f_pageing_helper('001010100000001'H, cid_list, c_BtsId_all, omit, 'A1B2C301'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01003147 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01003148}
3149
3150/* Paging with different "channel needed' values */
3151testcase TC_paging_tmsi_any() runs on test_CT {
3152 var BSSMAP_FIELD_CellIdentificationList cid_list;
3153 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01003154 f_pageing_helper('001010100000002'H, cid_list, c_BtsId_all, RSL_CHANNEED_ANY, 'A1B2C302'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01003155 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01003156}
3157testcase TC_paging_tmsi_sdcch() runs on test_CT {
3158 var BSSMAP_FIELD_CellIdentificationList cid_list;
3159 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01003160 f_pageing_helper('001010100000003'H, cid_list, c_BtsId_all, RSL_CHANNEED_SDCCH, 'A1B2C303'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01003161 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01003162}
3163testcase TC_paging_tmsi_tch_f() runs on test_CT {
3164 var BSSMAP_FIELD_CellIdentificationList cid_list;
3165 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01003166 f_pageing_helper('001010000000004'H, cid_list, c_BtsId_all, RSL_CHANNEED_TCH_F, 'A1B2C304'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01003167 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01003168}
3169testcase TC_paging_tmsi_tch_hf() runs on test_CT {
3170 var BSSMAP_FIELD_CellIdentificationList cid_list;
3171 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01003172 f_pageing_helper('001010000000005'H, cid_list, c_BtsId_all, RSL_CHANNEED_TCH_ForH, 'A1B2C305'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01003173 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01003174}
3175
3176/* Paging by CGI */
3177testcase TC_paging_imsi_nochan_cgi() runs on test_CT {
3178 var template BSSMAP_FIELD_CellIdentificationList cid_list;
3179 cid_list := { cIl_CGI := { ts_BSSMAP_CI_CGI(cid.mcc, cid.mnc, cid.lac, cid.ci) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01003180 f_pageing_helper('001010000000006'H, cid_list, { 0 });
Philipp Maier282ca4b2018-02-27 17:17:00 +01003181 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01003182}
3183
3184/* Paging by LAC+CI */
3185testcase TC_paging_imsi_nochan_lac_ci() runs on test_CT {
3186 var template BSSMAP_FIELD_CellIdentificationList cid_list;
3187 cid_list := { cIl_LAC_CI := { ts_BSSMAP_CI_LAC_CI(cid.lac, cid.ci) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01003188 f_pageing_helper('001010000000007'H, cid_list, { 0 });
Philipp Maier282ca4b2018-02-27 17:17:00 +01003189 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01003190}
3191
3192/* Paging by CI */
3193testcase TC_paging_imsi_nochan_ci() runs on test_CT {
3194 var template BSSMAP_FIELD_CellIdentificationList cid_list;
3195 cid_list := { cIl_CI := { ts_BSSMAP_CI_CI(cid.ci) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01003196 f_pageing_helper('001010000000008'H, cid_list, { 0 });
Philipp Maier282ca4b2018-02-27 17:17:00 +01003197 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01003198}
3199
3200/* Paging by LAI */
3201testcase TC_paging_imsi_nochan_lai() runs on test_CT {
3202 var template BSSMAP_FIELD_CellIdentificationList cid_list;
3203 cid_list := { cIl_LAI := { ts_BSSMAP_CI_LAI(cid.mcc, cid.mnc, cid.lac) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01003204 f_pageing_helper('001010000000009'H, cid_list, c_BtsId_LAC1);
Philipp Maier282ca4b2018-02-27 17:17:00 +01003205 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01003206}
3207
3208/* Paging by LAC */
3209testcase TC_paging_imsi_nochan_lac() runs on test_CT {
3210 var template BSSMAP_FIELD_CellIdentificationList cid_list;
3211 cid_list := { cIl_LAC := { ts_BSSMAP_CI_LAC(cid.lac) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01003212 f_pageing_helper('001010000000010'H, cid_list, c_BtsId_LAC1);
Philipp Maier282ca4b2018-02-27 17:17:00 +01003213 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01003214}
3215
3216/* Paging by "all in BSS" */
3217testcase TC_paging_imsi_nochan_all() runs on test_CT {
3218 var template BSSMAP_FIELD_CellIdentificationList cid_list;
3219 cid_list := { cIl_allInBSS := ''O };
Harald Welte5d1a2202017-12-13 19:51:29 +01003220 f_pageing_helper('001010000000011'H, cid_list, c_BtsId_all);
Philipp Maier282ca4b2018-02-27 17:17:00 +01003221 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01003222}
3223
Stefan Sperling7b5e1782018-03-20 19:32:43 +01003224/* Paging by PLMN+LAC+RNC; We do not implement this; Verify nothing is paged */
Harald Welte751d3eb2018-01-31 15:51:06 +01003225testcase TC_paging_imsi_nochan_plmn_lac_rnc() runs on test_CT {
3226 var template BSSMAP_FIELD_CellIdentificationList cid_list;
3227 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 +01003228 f_pageing_helper('001010000000012'H, cid_list, c_BtsId_none);
Philipp Maier282ca4b2018-02-27 17:17:00 +01003229 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01003230}
Harald Welte6f521d82017-12-11 19:52:02 +01003231
Stefan Sperling7b5e1782018-03-20 19:32:43 +01003232/* Paging by RNC; We do not implement this; Verify nothing is paged */
Harald Welte751d3eb2018-01-31 15:51:06 +01003233testcase TC_paging_imsi_nochan_rnc() runs on test_CT {
3234 var template BSSMAP_FIELD_CellIdentificationList cid_list;
3235 cid_list := { cIl_RNC := { int2oct(13, 2) } };
Stefan Sperling7b5e1782018-03-20 19:32:43 +01003236 f_pageing_helper('001010000000013'H, cid_list, c_BtsId_none);
Philipp Maier282ca4b2018-02-27 17:17:00 +01003237 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01003238}
3239
Stefan Sperling7b5e1782018-03-20 19:32:43 +01003240/* Paging by LAC+RNC; We do not implement; Verify nothing is paged */
Harald Welte751d3eb2018-01-31 15:51:06 +01003241testcase TC_paging_imsi_nochan_lac_rnc() runs on test_CT {
3242 var template BSSMAP_FIELD_CellIdentificationList cid_list;
3243 cid_list := { cIl_LAC_RNC := { ts_BSSMAP_CI_LAC_RNC(cid.lac, 14) } };
Stefan Sperling7b5e1782018-03-20 19:32:43 +01003244 f_pageing_helper('001010000000014'H, cid_list, c_BtsId_none);
Philipp Maier282ca4b2018-02-27 17:17:00 +01003245 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01003246}
3247
Harald Welte6f521d82017-12-11 19:52:02 +01003248/* Paging on multiple cells (multiple entries in list): Verify all of them page */
Harald Welte751d3eb2018-01-31 15:51:06 +01003249testcase TC_paging_imsi_nochan_lacs() runs on test_CT {
3250 var template BSSMAP_FIELD_CellIdentificationList cid_list;
3251 cid_list := { cIl_LAC := { ts_BSSMAP_CI_LAC(1), ts_BSSMAP_CI_LAC(2) } };
3252 f_pageing_helper('001010000000015'H, cid_list, c_BtsId_all);
Philipp Maier282ca4b2018-02-27 17:17:00 +01003253 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01003254}
3255
3256/* Paging on empty list: Verify none of them page */
3257testcase TC_paging_imsi_nochan_lacs_empty() runs on test_CT {
3258 var template BSSMAP_FIELD_CellIdentificationList cid_list;
3259 cid_list := { cIl_LAC := { } };
3260 f_pageing_helper('001010000000016'H, cid_list, c_BtsId_none);
Philipp Maier282ca4b2018-02-27 17:17:00 +01003261 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01003262}
3263
Stefan Sperling049a86e2018-03-20 15:51:00 +01003264/* Paging by CGI with unknown MCC/MNC: Verify nothing is paged. */
3265testcase TC_paging_imsi_nochan_cgi_unknown_cid() runs on test_CT {
3266 var template BSSMAP_FIELD_CellIdentificationList cid_list;
3267 cid_list := { cIl_CGI := { ts_BSSMAP_CI_CGI(unknown_cid.mcc, unknown_cid.mnc, unknown_cid.lac, unknown_cid.ci) } };
3268 f_pageing_helper('001010000000006'H, cid_list, c_BtsId_none);
3269 f_shutdown_helper();
3270}
3271
Harald Welte6f521d82017-12-11 19:52:02 +01003272/* Verify paging retransmission interval + count */
3273/* Verify paging stops after channel establishment */
Harald Welte6f521d82017-12-11 19:52:02 +01003274/* Test behavior under paging overload */
Harald Welteae026692017-12-09 01:03:01 +01003275
Harald Weltee65d40e2017-12-13 00:09:06 +01003276/* Verify PCH load */
3277testcase TC_paging_imsi_load() runs on test_CT {
3278 var BSSMAP_FIELD_CellIdentificationList cid_list;
3279 timer T := 4.0;
Harald Welte2caa1062018-03-17 18:19:05 +01003280 timer T_retrans := 1.0;
Harald Weltee65d40e2017-12-13 00:09:06 +01003281 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01003282 f_pageing_helper('001010123456789'H, cid_list, c_BtsId_all);
Harald Weltee65d40e2017-12-13 00:09:06 +01003283
3284 /* tell BSC there is no paging space anymore */
3285 f_ipa_tx(0, ts_RSL_PAGING_LOAD_IND(0));
Harald Welte3b57ab52018-03-17 18:01:10 +01003286 f_sleep(0.2);
3287 IPA_RSL[0].clear;
Harald Weltee65d40e2017-12-13 00:09:06 +01003288
3289 /* Wait for 4 seconds if any more PAGING CMD are received on RSL. Normally,
3290 * there would be 8 retransmissions during 4 seconds */
3291 T.start;
Harald Welte2caa1062018-03-17 18:19:05 +01003292 T_retrans.start;
Harald Weltee65d40e2017-12-13 00:09:06 +01003293 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07003294 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD(?))) {
Harald Weltee65d40e2017-12-13 00:09:06 +01003295 setverdict(fail, "Received PAGING after LOAD_IND(0)");
Daniel Willmannafce8662018-07-06 23:11:32 +02003296 mtc.stop;
Harald Weltee65d40e2017-12-13 00:09:06 +01003297 }
Harald Welte2caa1062018-03-17 18:19:05 +01003298 [] T_retrans.timeout {
3299 /* re-trnsmit the zero-space LOAD IND to avoid BSC 'auto credit' */
3300 f_ipa_tx(0, ts_RSL_PAGING_LOAD_IND(0));
3301 T_retrans.start;
3302 repeat;
3303 }
Harald Weltee65d40e2017-12-13 00:09:06 +01003304 [] T.timeout {
3305 setverdict(pass);
3306 }
3307 }
Philipp Maier282ca4b2018-02-27 17:17:00 +01003308
3309 f_shutdown_helper();
Harald Weltee65d40e2017-12-13 00:09:06 +01003310}
3311
Harald Welte235ebf12017-12-15 14:18:16 +01003312/* Verify Paging Counter */
Harald Welte1ff69992017-12-14 12:31:17 +01003313testcase TC_paging_counter() runs on test_CT {
3314 var BSSMAP_FIELD_CellIdentificationList cid_list;
3315 timer T := 4.0;
3316 var integer i;
3317 var integer paging_attempted_bsc;
3318 var integer paging_attempted_bts[NUM_BTS];
3319 var integer paging_expired_bts[NUM_BTS];
3320 cid_list := valueof(ts_BSSMAP_CIL_noCell);
3321
3322 f_init();
3323
3324 /* read counters before paging */
3325 paging_attempted_bsc := f_ctrl_get_ratectr_abs(IPA_CTRL, "bsc", 0, "paging:attempted");
3326 for (i := 0; i < NUM_BTS; i := i+1) {
3327 paging_attempted_bts[i] := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", i, "paging:attempted");
3328 paging_expired_bts[i] := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", i, "paging:expired");
3329 }
3330
3331 f_pageing_helper('001230000000001'H, cid_list, c_BtsId_all);
3332
3333 /* expect the attempted pages on BSC and each BTSs to have incremented by one */
3334 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bsc", 0, "paging:attempted", paging_attempted_bsc+1);
3335 for (i := 0; i < NUM_BTS; i := i+1) {
3336 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", i, "paging:attempted",
3337 paging_attempted_bts[i]+1);
3338 }
3339
3340 /* assume that 12s later the paging on all BTSs have expired and hence incremented by 1 */
3341 f_sleep(12.0);
3342 for (i := 0; i < NUM_BTS; i := i+1) {
3343 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", i, "paging:expired",
3344 paging_expired_bts[i]+1);
3345 }
Harald Welte1ff69992017-12-14 12:31:17 +01003346
Philipp Maier282ca4b2018-02-27 17:17:00 +01003347 f_shutdown_helper();
Harald Welte1ff69992017-12-14 12:31:17 +01003348}
3349
3350
Harald Welte10985002017-12-12 09:29:15 +01003351/* Verify paging stops after A-RESET */
3352testcase TC_paging_imsi_a_reset() runs on test_CT {
3353 var BSSMAP_FIELD_CellIdentificationList cid_list;
3354 timer T := 3.0;
3355 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01003356 f_pageing_helper('001010123456789'H, cid_list, c_BtsId_all);
Harald Welte10985002017-12-12 09:29:15 +01003357
3358 /* Perform a BSSMAP Reset and wait for ACK */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003359 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 +01003360 alt {
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003361 [] 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 +01003362 [] BSSAP.receive { repeat; }
3363 }
3364
Daniel Willmanncbef3982018-07-30 09:22:40 +02003365 /* Wait to avoid a possible race condition if a paging message is
3366 * received right before the reset ACK. */
3367 f_sleep(0.2);
3368
Harald Welte10985002017-12-12 09:29:15 +01003369 /* Clear the queue, it might still contain stuff like BCCH FILLING */
Philipp Maier1e6b4422018-02-23 14:02:13 +01003370 for (var integer i := 0; i < sizeof(IPA_RSL); i := i+1) {
3371 IPA_RSL[i].clear;
3372 }
Harald Welte10985002017-12-12 09:29:15 +01003373
3374 /* Wait for 3 seconds if any more PAGING CMD are received on RSL */
3375 T.start;
3376 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07003377 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD(?))) {
Harald Welte10985002017-12-12 09:29:15 +01003378 setverdict(fail, "Received PAGING after A-RESET");
Daniel Willmannafce8662018-07-06 23:11:32 +02003379 mtc.stop;
Harald Welte10985002017-12-12 09:29:15 +01003380 }
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07003381 [] IPA_RSL[1].receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD(?))) {
Harald Welte5d1a2202017-12-13 19:51:29 +01003382 setverdict(fail, "Received PAGING after A-RESET");
Daniel Willmannafce8662018-07-06 23:11:32 +02003383 mtc.stop;
Harald Welte5d1a2202017-12-13 19:51:29 +01003384 }
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07003385 [] IPA_RSL[2].receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD(?))) {
Harald Welte5d1a2202017-12-13 19:51:29 +01003386 setverdict(fail, "Received PAGING after A-RESET");
Daniel Willmannafce8662018-07-06 23:11:32 +02003387 mtc.stop;
Harald Welte5d1a2202017-12-13 19:51:29 +01003388 }
Harald Welte10985002017-12-12 09:29:15 +01003389 [] T.timeout {
3390 setverdict(pass);
3391 }
3392 }
Philipp Maier282ca4b2018-02-27 17:17:00 +01003393
3394 f_shutdown_helper();
Harald Welte10985002017-12-12 09:29:15 +01003395}
Harald Welteae026692017-12-09 01:03:01 +01003396
Philipp Maierf45824a2019-08-14 14:44:10 +02003397/* Verify how we handle unsolicited Paging Response. In case of an unsolicit
3398 * paging response we can not know which MSC is in charge, so we will blindly
3399 * pick the first configured MSC. This behavior is required in order to make
3400 * MT-CSFB calls working because in those cases the BSC can not know that the
3401 * MSC has already paged the subscriver via SGs. So any MT-CSFB call will look
3402 * like an unsolicited Paging Response to the MSC.
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01003403 */
3404testcase TC_paging_resp_unsol() runs on test_CT {
3405
3406 f_init(1);
Philipp Maierf45824a2019-08-14 14:44:10 +02003407 timer T := 5.0;
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01003408
3409 var BSSAP_N_CONNECT_ind rx_c_ind;
3410 var DchanTuple dt;
3411 var PDU_ML3_MS_NW l3 := valueof(ts_PAG_RESP(valueof(ts_MI_IMSI_LV('001010008880018'H))));
Philipp Maierf45824a2019-08-14 14:44:10 +02003412 var octetstring rr_pag_resp := enc_PDU_ML3_MS_NW(l3);
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01003413
3414 /* Send CHAN RQD and wait for allocation; acknowledge it */
3415 dt.rsl_chan_nr := f_chreq_act_ack();
3416
3417 /* Send unsolicited Paging response (no matching Paging CMD stored in BSC) */
3418 f_ipa_tx(0, ts_RSL_EST_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0)), enc_PDU_ML3_MS_NW(l3)));
3419
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01003420
Philipp Maierf45824a2019-08-14 14:44:10 +02003421 /* Expevct a CR with a matching Paging response on the A-Interface */
3422 T.start;
3423 alt {
3424 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(rr_pag_resp))) {
3425 setverdict(pass);
3426 }
3427 [] BSSAP.receive {
3428 setverdict(fail, "Received unexpected message on A-Interface!");
3429 }
3430 [] T.timeout {
3431 setverdict(fail, "Received nothing on A-Interface!");
3432 }
3433 }
3434
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003435 f_shutdown_helper();
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01003436}
3437
Harald Welte4e9b9cc2017-12-14 18:31:02 +01003438/* Test RSL link drop causes counter increment */
3439testcase TC_rsl_drop_counter() runs on test_CT {
3440 var integer rsl_fail;
3441
Harald Welte89d42e82017-12-17 16:42:41 +01003442 f_init(1);
Harald Welte4e9b9cc2017-12-14 18:31:02 +01003443
3444 rsl_fail := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "rsl_fail");
3445
3446 bts[0].rsl.vc_IPA.stop;
3447
3448 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "rsl_fail", rsl_fail+1);
3449
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003450 f_shutdown_helper();
Harald Welte4e9b9cc2017-12-14 18:31:02 +01003451}
3452
3453/* TODO: Test OML link drop causes counter increment */
3454
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003455/* The body of TC_rsl_unknown_unit_id() and TC_oml_unknown_unit_id() tests. */
3456function f_ipa_unknown_unit_id(integer mp_bsc_ipa_port) runs on test_CT return boolean {
3457 timer T := 10.0;
3458
3459 bts[0].rsl.id := "IPA-0-RSL";
3460 bts[0].rsl.vc_IPA := IPA_Emulation_CT.create(bts[0].rsl.id & "-IPA");
3461 bts[0].rsl.ccm_pars := c_IPA_default_ccm_pars;
3462 bts[0].rsl.ccm_pars.name := "Osmocom TTCN-3 BTS Simulator";
Oliver Smith92c2bdb2019-08-20 15:11:24 +02003463 bts[0].rsl.ccm_pars.unit_id := "99/0/0"; /* value which is unknown at BTS */
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003464
Pau Espin Pedrol9a5b8ff2021-01-04 19:01:31 +01003465 f_ipa_ctrl_start_client(mp_bsc_ip, mp_bsc_ctrl_port);
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003466
3467 f_init_mgcp("VirtMSC");
3468
3469 /* start RSL/OML connection (XXX re-uses RSL port/protocol definitions for OML) */
3470 map(bts[0].rsl.vc_IPA:IPA_PORT, system:IPA);
3471 connect(bts[0].rsl.vc_IPA:IPA_RSL_PORT, self:IPA_RSL[0]);
3472 bts[0].rsl.vc_IPA.start(IPA_Emulation.main_client(mp_bsc_ip, mp_bsc_ipa_port, "", 10000, bts[0].rsl.ccm_pars));
3473
3474 /* wait for IPA OML link to connect and then disconnect */
3475 T.start;
3476 alt {
Vadim Yanitskiya2afacc2020-05-18 21:16:19 +07003477 [] IPA_RSL[0].receive(tr_ASP_IPA_EV(ASP_IPA_EVENT_DOWN)) {
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003478 T.stop;
3479 return true;
3480 }
3481 [] IPA_RSL[0].receive { repeat }
3482 [] T.timeout {
Daniel Willmannafce8662018-07-06 23:11:32 +02003483 return false;
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003484 }
3485 }
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003486 return false;
3487}
3488
3489/* BSC should close an RSL connection from a BTS with unknown unit ID (OS#2714). */
3490testcase TC_rsl_unknown_unit_id() runs on test_CT {
3491 if (f_ipa_unknown_unit_id(mp_bsc_rsl_port)) {
3492 setverdict(pass);
3493 } else {
3494 setverdict(fail, "Timeout RSL waiting for connection to close");
3495 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003496 f_shutdown_helper();
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003497}
3498
3499
3500/* BSC should close an RSL connection from a BTS with unknown unit ID (OS#2714). */
3501testcase TC_oml_unknown_unit_id() runs on test_CT {
3502 if (f_ipa_unknown_unit_id(mp_bsc_oml_port)) {
3503 setverdict(pass);
3504 } else {
3505 setverdict(fail, "Timeout OML waiting for connection to close");
3506 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003507 f_shutdown_helper();
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003508}
3509
3510
Harald Weltec1a2fff2017-12-17 11:06:19 +01003511/***********************************************************************
Harald Welte6811d102019-04-14 22:23:14 +02003512 * "New world" test cases using RSL_Emulation + RAN_Emulation
Harald Weltec1a2fff2017-12-17 11:06:19 +01003513 ***********************************************************************/
3514
Harald Welte6811d102019-04-14 22:23:14 +02003515import from RAN_Emulation all;
Harald Welte47cd0e32020-08-21 12:39:11 +02003516import from BSSAP_LE_Emulation all;
Harald Weltec1a2fff2017-12-17 11:06:19 +01003517import from RSL_Emulation all;
3518import from MSC_ConnectionHandler all;
3519
3520type function void_fn(charstring id) runs on MSC_ConnHdlr;
3521
Harald Welte336820c2018-05-31 20:34:52 +02003522/* helper function to create and connect a MSC_ConnHdlr component */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003523private function f_connect_handler(inout MSC_ConnHdlr vc_conn, integer bssap_idx := 0) runs on test_CT {
3524 connect(vc_conn:RAN, g_bssap[bssap_idx].vc_RAN:PROC);
Daniel Willmann191e0d92018-01-17 12:44:35 +01003525 connect(vc_conn:MGCP_PROC, vc_MGCP:MGCP_PROC);
Harald Weltec1a2fff2017-12-17 11:06:19 +01003526 connect(vc_conn:RSL, bts[0].rsl.vc_RSL:CLIENT_PT);
Harald Weltef70df652018-01-29 22:00:23 +01003527 connect(vc_conn:RSL_PROC, bts[0].rsl.vc_RSL:RSL_PROC);
Philipp Maier88f4ae82018-03-01 14:00:58 +01003528 if (isvalue(bts[1])) {
Philipp Maier956a92f2018-02-16 10:58:07 +01003529 connect(vc_conn:RSL1, bts[1].rsl.vc_RSL:CLIENT_PT);
3530 connect(vc_conn:RSL1_PROC, bts[1].rsl.vc_RSL:RSL_PROC);
3531 }
Neels Hofmeyr91401012019-07-11 00:42:35 +02003532 if (isvalue(bts[2])) {
3533 connect(vc_conn:RSL2, bts[2].rsl.vc_RSL:CLIENT_PT);
3534 connect(vc_conn:RSL2_PROC, bts[2].rsl.vc_RSL:RSL_PROC);
3535 }
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003536 connect(vc_conn:BSSAP, g_bssap[bssap_idx].vc_RAN:CLIENT);
Neels Hofmeyrcfe44062020-10-15 02:28:08 +02003537 if (mp_enable_lcs_tests) {
3538 connect(vc_conn:BSSAP_LE, g_bssap_le.vc_BSSAP_LE:CLIENT);
3539 connect(vc_conn:BSSAP_LE_PROC, g_bssap_le.vc_BSSAP_LE:PROC);
3540 }
Daniel Willmann191e0d92018-01-17 12:44:35 +01003541 connect(vc_conn:MGCP, vc_MGCP:MGCP_CLIENT);
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +02003542 connect(vc_conn:MGCP_MULTI, vc_MGCP:MGCP_CLIENT_MULTI);
Daniel Willmannebdecc02020-08-12 15:30:17 +02003543 connect(vc_conn:STATSD_PROC, vc_STATSD:STATSD_PROC);
Harald Welte336820c2018-05-31 20:34:52 +02003544}
3545
Neels Hofmeyrda436782021-07-20 22:09:06 +02003546function f_start_handler_create(template (omit) TestHdlrParams pars := omit)
Harald Welte336820c2018-05-31 20:34:52 +02003547runs on test_CT return MSC_ConnHdlr {
3548 var charstring id := testcasename();
3549 var MSC_ConnHdlr vc_conn;
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003550 var integer bssap_idx := 0;
3551 if (isvalue(pars)) {
3552 bssap_idx := valueof(pars).mscpool.bssap_idx;
3553 }
Harald Welte336820c2018-05-31 20:34:52 +02003554 vc_conn := MSC_ConnHdlr.create(id);
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003555 f_connect_handler(vc_conn, bssap_idx);
Neels Hofmeyrda436782021-07-20 22:09:06 +02003556 return vc_conn;
3557}
3558
3559function f_start_handler_run(MSC_ConnHdlr vc_conn, void_fn fn, template (omit) TestHdlrParams pars := omit)
3560runs on test_CT return MSC_ConnHdlr {
3561 var charstring id := testcasename();
Neels Hofmeyr1708d1b2020-10-10 16:56:48 +02003562 /* Emit a marker to appear in the SUT's own logging output */
Neels Hofmeyrda436782021-07-20 22:09:06 +02003563 f_logp(BSCVTY, id & "() start");
Harald Weltea0630032018-03-20 21:09:55 +01003564 vc_conn.start(f_handler_init(fn, id, pars));
Harald Weltec1a2fff2017-12-17 11:06:19 +01003565 return vc_conn;
3566}
3567
Neels Hofmeyrda436782021-07-20 22:09:06 +02003568function f_start_handler(void_fn fn, template (omit) TestHdlrParams pars := omit)
3569runs on test_CT return MSC_ConnHdlr {
3570 return f_start_handler_run(f_start_handler_create(pars), fn, pars);
3571}
3572
Harald Weltea0630032018-03-20 21:09:55 +01003573/* first function inside ConnHdlr component; sets g_pars + starts function */
3574private function f_handler_init(void_fn fn, charstring id, template (omit) TestHdlrParams pars := omit)
3575runs on MSC_ConnHdlr {
3576 if (isvalue(pars)) {
3577 g_pars := valueof(pars);
3578 }
3579 fn.apply(id);
3580}
3581
Oliver Smith26a3db72021-07-09 13:51:29 +02003582private function f_vty_encryption_a5(charstring options) runs on test_CT {
3583 f_vty_transceive(BSCVTY, "configure terminal");
3584 f_vty_transceive(BSCVTY, "network");
3585 f_vty_transceive(BSCVTY, "encryption a5 " & options);
3586 f_vty_transceive(BSCVTY, "exit");
3587 f_vty_transceive(BSCVTY, "exit");
3588}
3589
3590private function f_vty_encryption_a5_reset() runs on test_CT {
3591 /* keep in sync with docker-playground.git ttcn3-bsc-test/osmo-bsc.cfg */
3592 f_vty_encryption_a5("0 1 3");
3593}
3594
Harald Welte3c86ea02018-05-10 22:28:05 +02003595/* Establish signalling channel (non-assignment case) followed by cipher mode */
3596private function f_tc_ciph_mode_a5(charstring id) runs on MSC_ConnHdlr {
Harald Welteed848512018-05-24 22:27:58 +02003597 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3598 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte3c86ea02018-05-10 22:28:05 +02003599 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeSIGNAL);
Philipp Maier23000732018-05-18 11:25:37 +02003600 ass_cmd.pdu.bssmap.assignmentRequest.circuitIdentityCode := omit;
3601 ass_cmd.pdu.bssmap.assignmentRequest.aoIPTransportLayer := omit;
3602 exp_compl.pdu.bssmap.assignmentComplete.circuitIdentityCode := omit;
3603 exp_compl.pdu.bssmap.assignmentComplete.aoIPTransportLayer := omit;
Harald Welte3c86ea02018-05-10 22:28:05 +02003604
Philipp Maier23000732018-05-18 11:25:37 +02003605 f_establish_fully(ass_cmd, exp_compl);
Harald Welte3c86ea02018-05-10 22:28:05 +02003606}
3607testcase TC_ciph_mode_a5_0() runs on test_CT {
3608 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02003609 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte3c86ea02018-05-10 22:28:05 +02003610 pars.encr := valueof(t_EncrParams('01'O, f_rnd_octstring(8)));
3611
3612 f_init(1, true);
3613 f_sleep(1.0);
3614 vc_conn := f_start_handler(refers(f_tc_ciph_mode_a5), pars);
3615 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003616 f_shutdown_helper();
Harald Welte3c86ea02018-05-10 22:28:05 +02003617}
3618testcase TC_ciph_mode_a5_1() runs on test_CT {
3619 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02003620 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte3c86ea02018-05-10 22:28:05 +02003621 pars.encr := valueof(t_EncrParams('02'O, f_rnd_octstring(8)));
3622
3623 f_init(1, true);
3624 f_sleep(1.0);
3625 vc_conn := f_start_handler(refers(f_tc_ciph_mode_a5), pars);
3626 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003627 f_shutdown_helper();
Harald Welte3c86ea02018-05-10 22:28:05 +02003628}
Oliver Smith50b98122021-07-09 15:00:28 +02003629/* OS#4975: verify that A5/2 is preferred over A5/0 */
3630testcase TC_ciph_mode_a5_2_0() runs on test_CT {
3631 var MSC_ConnHdlr vc_conn;
3632 var TestHdlrParams pars := f_gen_test_hdlr_pars();
3633
3634 pars.encr := valueof(t_EncrParams('05'O, f_rnd_octstring(8))); /* A5/0 and A5/2 (0x01|0x04)*/
3635 pars.encr_exp_enc_alg := '04'O; /* A5/2 */
3636
3637 f_init(1, true);
3638 f_vty_encryption_a5("0 1 2 3");
3639 f_sleep(1.0);
3640 vc_conn := f_start_handler(refers(f_tc_ciph_mode_a5), pars);
3641 vc_conn.done;
3642 f_vty_encryption_a5_reset();
3643 f_shutdown_helper();
3644}
Oliver Smith1dff88d2021-07-09 08:45:51 +02003645/* OS#4975: verify that A5/1 is preferred over A5/2 */
3646testcase TC_ciph_mode_a5_2_1() runs on test_CT {
3647 var MSC_ConnHdlr vc_conn;
3648 var TestHdlrParams pars := f_gen_test_hdlr_pars();
3649
3650 pars.encr := valueof(t_EncrParams('06'O, f_rnd_octstring(8))); /* A5/1 and A5/2 (0x02|0x04)*/
3651 pars.encr_exp_enc_alg := '02'O; /* A5/1 */
3652
3653 f_init(1, true);
3654 f_vty_encryption_a5("1 2");
3655 f_sleep(1.0);
3656 vc_conn := f_start_handler(refers(f_tc_ciph_mode_a5), pars);
3657 vc_conn.done;
3658 f_vty_encryption_a5_reset();
3659 f_shutdown_helper();
3660}
Harald Welte3c86ea02018-05-10 22:28:05 +02003661testcase TC_ciph_mode_a5_3() runs on test_CT {
3662 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02003663 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte3c86ea02018-05-10 22:28:05 +02003664 pars.encr := valueof(t_EncrParams('08'O, f_rnd_octstring(8)));
3665
3666 f_init(1, true);
3667 f_sleep(1.0);
3668 vc_conn := f_start_handler(refers(f_tc_ciph_mode_a5), pars);
3669 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003670 f_shutdown_helper();
Harald Welte3c86ea02018-05-10 22:28:05 +02003671}
Neels Hofmeyr81ad27f2021-06-11 00:09:40 +02003672/* Establish a Signalling channel with A5/4 encryption. */
3673testcase TC_ciph_mode_a5_4() runs on test_CT {
3674 var MSC_ConnHdlr vc_conn;
3675 var TestHdlrParams pars := f_gen_test_hdlr_pars();
3676 pars.encr := valueof(t_EncrParams('10'O, f_rnd_octstring(8), f_rnd_octstring(16)));
Harald Welte3c86ea02018-05-10 22:28:05 +02003677
Neels Hofmeyr81ad27f2021-06-11 00:09:40 +02003678 f_init(1, true);
Oliver Smith26a3db72021-07-09 13:51:29 +02003679 f_vty_encryption_a5("0 1 3 4");
Neels Hofmeyr81ad27f2021-06-11 00:09:40 +02003680 f_sleep(1.0);
3681 vc_conn := f_start_handler(refers(f_tc_ciph_mode_a5), pars);
3682 vc_conn.done;
Oliver Smith26a3db72021-07-09 13:51:29 +02003683 f_vty_encryption_a5_reset();
Neels Hofmeyr81ad27f2021-06-11 00:09:40 +02003684 f_shutdown_helper();
3685}
Pau Espin Pedrol07866632020-09-03 19:10:55 +02003686/* establish initial channel, enable ciphering followed by assignment to ciphered channel */
3687private function f_tc_assignment_aoip_tla_v6(charstring id) runs on MSC_ConnHdlr {
3688 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3689 var PDU_BSSAP ass_cmd := f_gen_ass_req(aoip_tla := "::3");
3690 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3691 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
3692
3693 f_establish_fully(ass_cmd, exp_compl);
3694}
3695testcase TC_assignment_aoip_tla_v6() runs on test_CT {
3696 var MSC_ConnHdlr vc_conn;
3697 var TestHdlrParams pars := f_gen_test_hdlr_pars();
3698
3699 f_init(1, true);
3700 f_sleep(1.0);
3701 vc_conn := f_start_handler(refers(f_tc_assignment_aoip_tla_v6), pars);
3702 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003703 f_shutdown_helper();
Pau Espin Pedrol07866632020-09-03 19:10:55 +02003704}
3705
Harald Welte3c86ea02018-05-10 22:28:05 +02003706
3707/* establish initial channel, enable ciphering followed by assignment to ciphered channel */
Harald Welte651fcdc2018-05-10 20:23:16 +02003708private function f_tc_assignment_fr_a5(charstring id) runs on MSC_ConnHdlr {
Harald Welteed848512018-05-24 22:27:58 +02003709 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3710 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Weltec1a2fff2017-12-17 11:06:19 +01003711
Harald Welte552620d2017-12-16 23:21:36 +01003712 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3713 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
Harald Welte73cd2712017-12-17 00:44:52 +01003714
Harald Weltea0630032018-03-20 21:09:55 +01003715 f_establish_fully(ass_cmd, exp_compl);
Harald Welte552620d2017-12-16 23:21:36 +01003716}
Harald Welte552620d2017-12-16 23:21:36 +01003717testcase TC_assignment_fr_a5_0() runs on test_CT {
3718 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02003719 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte651fcdc2018-05-10 20:23:16 +02003720 pars.encr := valueof(t_EncrParams('01'O, f_rnd_octstring(8)));
Harald Welte552620d2017-12-16 23:21:36 +01003721
Harald Welte89d42e82017-12-17 16:42:41 +01003722 f_init(1, true);
Harald Welte552620d2017-12-16 23:21:36 +01003723 f_sleep(1.0);
Harald Welte651fcdc2018-05-10 20:23:16 +02003724 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5), pars);
Harald Welte552620d2017-12-16 23:21:36 +01003725 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003726 f_shutdown_helper();
Harald Welte552620d2017-12-16 23:21:36 +01003727}
Harald Welte552620d2017-12-16 23:21:36 +01003728testcase TC_assignment_fr_a5_1() runs on test_CT {
Harald Weltec1a2fff2017-12-17 11:06:19 +01003729 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02003730 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte651fcdc2018-05-10 20:23:16 +02003731 pars.encr := valueof(t_EncrParams('02'O, f_rnd_octstring(8)));
Harald Weltec1a2fff2017-12-17 11:06:19 +01003732
Harald Welte89d42e82017-12-17 16:42:41 +01003733 f_init(1, true);
Harald Weltec1a2fff2017-12-17 11:06:19 +01003734 f_sleep(1.0);
Harald Welte651fcdc2018-05-10 20:23:16 +02003735 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5), pars);
3736 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003737 f_shutdown_helper();
Harald Welte651fcdc2018-05-10 20:23:16 +02003738}
3739testcase TC_assignment_fr_a5_3() runs on test_CT {
3740 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02003741 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte651fcdc2018-05-10 20:23:16 +02003742 pars.encr := valueof(t_EncrParams('08'O, f_rnd_octstring(8)));
Harald Weltec1a2fff2017-12-17 11:06:19 +01003743
Harald Welte651fcdc2018-05-10 20:23:16 +02003744 f_init(1, true);
3745 f_sleep(1.0);
3746 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5), pars);
Harald Weltec1a2fff2017-12-17 11:06:19 +01003747 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003748 f_shutdown_helper();
Harald Weltec1a2fff2017-12-17 11:06:19 +01003749}
Neels Hofmeyr0d8ec532021-06-11 00:09:48 +02003750/* Establish a Signalling channel and re-assign to TCH/F with A5/4 encryption. */
3751testcase TC_assignment_fr_a5_4() runs on test_CT {
3752 var MSC_ConnHdlr vc_conn;
3753 var TestHdlrParams pars := f_gen_test_hdlr_pars();
3754 pars.encr := valueof(t_EncrParams('10'O, f_rnd_octstring(8), f_rnd_octstring(16)));
3755
3756 f_init(1, true);
Oliver Smith7eabd312021-07-12 14:18:56 +02003757 f_vty_encryption_a5("0 1 3 4");
Neels Hofmeyr0d8ec532021-06-11 00:09:48 +02003758 f_sleep(1.0);
3759 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5), pars);
3760 vc_conn.done;
Oliver Smith7eabd312021-07-12 14:18:56 +02003761 f_vty_encryption_a5_reset();
Neels Hofmeyr0d8ec532021-06-11 00:09:48 +02003762 f_shutdown_helper();
3763}
Harald Weltec1a2fff2017-12-17 11:06:19 +01003764
Neels Hofmeyr0faeb7a2021-06-10 23:59:35 +02003765/* Allow only A5/4, but omit the Kc128 IE from MSC's msg. Expect Cipher Mode Reject. */
3766testcase TC_assignment_fr_a5_4_fail() runs on test_CT {
3767 var TestHdlrParams pars := f_gen_test_hdlr_pars();
3768 var MSC_ConnHdlr vc_conn;
3769
3770 f_init(1, true);
3771 f_sleep(1.0);
3772
3773 pars.encr := valueof(t_EncrParams('10'O, f_rnd_octstring(8))); // A5/4 support, but Kc128 missing!
3774 vc_conn := f_start_handler(refers(f_TC_assignment_a5_not_sup), pars);
3775 vc_conn.done;
3776 f_shutdown_helper();
3777}
3778
Harald Welte552620d2017-12-16 23:21:36 +01003779/* Expect ASSIGNMENT FAIL if mandatory IE is missing */
3780private function f_tc_assignment_fr_a5_1_codec_missing(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02003781 g_pars := f_gen_test_hdlr_pars();
Harald Welte552620d2017-12-16 23:21:36 +01003782 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
Harald Welteed848512018-05-24 22:27:58 +02003783 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte552620d2017-12-16 23:21:36 +01003784
3785 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02003786 /* Omit: ass_cmd.pdu.bssmap.assignmentRequest.codecList */
3787
Harald Weltea0630032018-03-20 21:09:55 +01003788 f_establish_fully(ass_cmd, exp_fail);
Harald Welte552620d2017-12-16 23:21:36 +01003789}
Harald Welte552620d2017-12-16 23:21:36 +01003790testcase TC_assignment_fr_a5_1_codec_missing() runs on test_CT {
3791 var MSC_ConnHdlr vc_conn;
3792
Harald Welte89d42e82017-12-17 16:42:41 +01003793 f_init(1, true);
Harald Welte552620d2017-12-16 23:21:36 +01003794 f_sleep(1.0);
3795
Harald Welte8863fa12018-05-10 20:15:27 +02003796 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5_1_codec_missing));
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}
3800
Neels Hofmeyr04d6e6a2021-06-11 00:10:02 +02003801private function f_TC_assignment_a5_not_sup(charstring id) runs on MSC_ConnHdlr {
3802 var template PDU_BSSAP exp_ass_cpl := f_gen_exp_compl();
3803 var PDU_BSSAP exp_ass_req := f_gen_ass_req();
Harald Welte552620d2017-12-16 23:21:36 +01003804
Neels Hofmeyr04d6e6a2021-06-11 00:10:02 +02003805 exp_ass_req.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3806 exp_ass_req.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
3807
3808 /* this is like the beginning of f_establish_fully(), but only up to ciphering reject */
3809
3810 var BSSMAP_FIELD_CodecType codecType;
3811 timer T := 10.0;
3812
3813 codecType := exp_ass_req.pdu.bssmap.assignmentRequest.codecList.codecElements[0].codecType;
3814 f_MscConnHdlr_init(g_pars.media_nr, host_bts, host_mgw_mgcp, codecType);
3815
3816 f_create_chan_and_exp();
3817 /* we should now have a COMPL_L3 at the MSC */
3818
3819 var template PDU_BSSAP exp_l3_compl;
3820 exp_l3_compl := tr_BSSMAP_ComplL3()
3821 if (g_pars.aoip == false) {
3822 exp_l3_compl.pdu.bssmap.completeLayer3Information.codecList := omit;
3823 } else {
3824 exp_l3_compl.pdu.bssmap.completeLayer3Information.codecList := ?;
3825 }
3826 T.start;
3827 alt {
3828 [] BSSAP.receive(exp_l3_compl);
3829 [] BSSAP.receive(tr_BSSMAP_ComplL3) {
3830 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Received non-matching COMPLETE LAYER 3 INFORMATION");
3831 }
3832 [] T.timeout {
3833 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for COMPLETE LAYER 3 INFORMATION");
3834 }
3835 }
3836
3837 /* Start ciphering, expect Cipher Mode Reject */
Neels Hofmeyr6c388f22021-06-11 02:36:56 +02003838 f_cipher_mode(g_pars.encr, exp_fail := true);
Harald Welte552620d2017-12-16 23:21:36 +01003839}
Neels Hofmeyr04d6e6a2021-06-11 00:10:02 +02003840testcase TC_assignment_fr_a5_not_sup() runs on test_CT {
3841 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte552620d2017-12-16 23:21:36 +01003842 var MSC_ConnHdlr vc_conn;
3843
Harald Welte89d42e82017-12-17 16:42:41 +01003844 f_init(1, true);
Harald Welte552620d2017-12-16 23:21:36 +01003845 f_sleep(1.0);
3846
Neels Hofmeyr0588cad2021-06-11 01:38:18 +02003847 pars.encr := valueof(t_EncrParams('20'O, f_rnd_octstring(8), f_rnd_octstring(16)));
Neels Hofmeyr04d6e6a2021-06-11 00:10:02 +02003848 vc_conn := f_start_handler(refers(f_TC_assignment_a5_not_sup), pars);
Harald Welte552620d2017-12-16 23:21:36 +01003849 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003850 f_shutdown_helper();
Harald Welte552620d2017-12-16 23:21:36 +01003851}
3852
3853
Harald Welte4532e0a2017-12-23 02:05:44 +01003854private function f_tc_assignment_sign(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02003855 g_pars := f_gen_test_hdlr_pars();
Harald Welte4532e0a2017-12-23 02:05:44 +01003856 var template PDU_BSSAP exp_compl := tr_BSSMAP_AssignmentComplete(omit, omit);
Philipp Maier48604732018-10-09 15:00:37 +02003857 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte4532e0a2017-12-23 02:05:44 +01003858 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeSIGNAL);
Daniel Willmannebdecc02020-08-12 15:30:17 +02003859
3860 f_statsd_reset();
Harald Weltea0630032018-03-20 21:09:55 +01003861 f_establish_fully(ass_cmd, exp_compl);
Daniel Willmannebdecc02020-08-12 15:30:17 +02003862
3863 var StatsDExpects expect := {
Daniel Willmannc5398f72020-09-21 10:41:35 +02003864 { name := "TTCN3.bts.0.chreq.total", mtype := "c", min := 1, max := 1},
3865 { name := "TTCN3.bts.0.chreq.successful", mtype := "c", min := 1, max := 1},
Daniel Willmannebdecc02020-08-12 15:30:17 +02003866 { name := "TTCN3.bsc.0.assignment.attempted", mtype := "c", min := 1, max := 1},
3867 { name := "TTCN3.bsc.0.assignment.completed", mtype := "c", min := 1, max := 1}
3868 };
3869 f_statsd_expect(expect);
Harald Welte4532e0a2017-12-23 02:05:44 +01003870}
3871
3872testcase TC_assignment_sign() runs on test_CT {
3873 var MSC_ConnHdlr vc_conn;
3874
3875 f_init(1, true);
3876 f_sleep(1.0);
3877
Harald Welte8863fa12018-05-10 20:15:27 +02003878 vc_conn := f_start_handler(refers(f_tc_assignment_sign));
Harald Welte4532e0a2017-12-23 02:05:44 +01003879 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003880 f_shutdown_helper();
Harald Welte4532e0a2017-12-23 02:05:44 +01003881}
3882
Harald Welte60aa5762018-03-21 19:33:13 +01003883/***********************************************************************
3884 * Codec (list) testing
3885 ***********************************************************************/
3886
3887/* check if the given rsl_mode is compatible with the a_elem */
3888private function f_match_codec(BSSMAP_FIELD_CodecElement a_elem, RSL_IE_ChannelMode rsl_mode)
3889return boolean {
3890 select (a_elem.codecType) {
3891 case (GSM_FR) {
3892 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM1))) {
3893 return true;
3894 }
3895 }
3896 case (GSM_HR) {
3897 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_H, RSL_CMOD_SP_GSM1))) {
3898 return true;
3899 }
3900 }
3901 case (GSM_EFR) {
3902 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM2))) {
3903 return true;
3904 }
3905 }
3906 case (FR_AMR) {
3907 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM3))) {
3908 return true;
3909 }
3910 }
3911 case (HR_AMR) {
3912 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_H, RSL_CMOD_SP_GSM3))) {
3913 return true;
3914 }
3915 }
3916 case else { }
3917 }
3918 return false;
3919}
3920
3921/* check if the given rsl_mode is compatible with the a_list */
3922private function f_match_codecs(BSSMAP_IE_SpeechCodecList a_list, RSL_IE_ChannelMode rsl_mode)
3923return boolean {
3924 for (var integer i := 0; i < sizeof(a_list); i := i+1) {
3925 if (f_match_codec(a_list.codecElements[i], rsl_mode)) {
3926 return true;
3927 }
3928 }
3929 return false;
3930}
3931
3932/* determine BSSMAP_IE_ChannelType from *first* element of BSSMAP_FIELD_CodecElement */
Philipp Maier61f6b572018-07-06 14:03:38 +02003933function f_BSSMAP_chtype_from_codec(BSSMAP_FIELD_CodecElement a_elem)
Harald Welte60aa5762018-03-21 19:33:13 +01003934return BSSMAP_IE_ChannelType {
3935 /* FIXME: actually look at all elements of BSSMAP_IE_SpeechCodecList */
3936 var BSSMAP_IE_ChannelType ret := valueof(ts_BSSMAP_IE_ChannelType);
3937 select (a_elem.codecType) {
3938 case (GSM_FR) {
3939 ret.channelRateAndType := ChRate_TCHF;
3940 ret.speechId_DataIndicator := Spdi_TCHF_FR;
3941 }
3942 case (GSM_HR) {
3943 ret.channelRateAndType := ChRate_TCHH;
3944 ret.speechId_DataIndicator := Spdi_TCHH_HR;
3945 }
3946 case (GSM_EFR) {
3947 ret.channelRateAndType := ChRate_TCHF;
3948 ret.speechId_DataIndicator := Spdi_TCHF_EFR;
3949 }
3950 case (FR_AMR) {
3951 ret.channelRateAndType := ChRate_TCHF;
3952 ret.speechId_DataIndicator := Spdi_TCHF_AMR;
3953 }
3954 case (HR_AMR) {
3955 ret.channelRateAndType := ChRate_TCHH;
3956 ret.speechId_DataIndicator := Spdi_TCHH_AMR;
3957 }
3958 case else {
3959 setverdict(fail, "Unsupported codec ", a_elem);
Daniel Willmannafce8662018-07-06 23:11:32 +02003960 mtc.stop;
Harald Welte60aa5762018-03-21 19:33:13 +01003961 }
3962 }
3963 return ret;
3964}
3965
Harald Weltea63b9102018-03-22 20:36:16 +01003966private function f_rsl_chmod_tmpl_from_codec(BSSMAP_FIELD_CodecElement a_elem)
3967return template RSL_IE_Body {
3968 var template RSL_IE_Body mode_ie := {
3969 chan_mode := {
3970 len := ?,
3971 reserved := ?,
3972 dtx_d := ?,
3973 dtx_u := ?,
3974 spd_ind := RSL_SPDI_SPEECH,
3975 ch_rate_type := -,
3976 coding_alg_rate := -
3977 }
3978 }
3979
3980 select (a_elem.codecType) {
3981 case (GSM_FR) {
3982 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_F;
3983 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM1;
3984 }
3985 case (GSM_HR) {
3986 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_H;
3987 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM1;
3988 }
3989 case (GSM_EFR) {
3990 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_F;
3991 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM2;
3992 }
3993 case (FR_AMR) {
3994 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_F;
3995 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM3;
3996 }
3997 case (HR_AMR) {
3998 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_H;
3999 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM3;
4000 }
4001 }
4002 return mode_ie;
4003}
4004
Harald Welte60aa5762018-03-21 19:33:13 +01004005type record CodecListTest {
4006 BSSMAP_IE_SpeechCodecList codec_list,
4007 charstring id
4008}
4009type record of CodecListTest CodecListTests
4010
4011private function f_TC_assignment_codec(charstring id) runs on MSC_ConnHdlr {
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02004012 var PDU_BSSAP ass_cmd := f_gen_ass_req(g_pars.use_osmux);
4013 var template PDU_BSSAP exp_compl := f_gen_exp_compl(g_pars.use_osmux);
Harald Welte60aa5762018-03-21 19:33:13 +01004014
4015 /* puzzle together the ASSIGNMENT REQ for given codec[s] */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02004016 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
Harald Welte79f3f542018-05-25 20:02:37 +02004017 ass_cmd.pdu.bssmap.assignmentRequest.codecList := g_pars.ass_codec_list;
4018 exp_compl.pdu.bssmap.assignmentComplete.speechCodec.codecElements[0] :=
4019 g_pars.ass_codec_list.codecElements[0];
Philipp Maierd0e64b02019-03-13 14:15:23 +01004020 if (isvalue(g_pars.expect_mr_s0_s7)) {
4021 exp_compl.pdu.bssmap.assignmentComplete.speechCodec.codecElements[0].s0_7 :=
4022 g_pars.expect_mr_s0_s7;
4023 }
Harald Welte79f3f542018-05-25 20:02:37 +02004024 }
Harald Welte60aa5762018-03-21 19:33:13 +01004025 ass_cmd.pdu.bssmap.assignmentRequest.channelType :=
4026 f_BSSMAP_chtype_from_codec(g_pars.ass_codec_list.codecElements[0]);
Harald Welte60aa5762018-03-21 19:33:13 +01004027 log("expecting ASS COMPL like this: ", exp_compl);
4028
4029 f_establish_fully(ass_cmd, exp_compl);
Harald Weltea63b9102018-03-22 20:36:16 +01004030
Neels Hofmeyr559d5d02021-04-16 16:50:49 +02004031 if (not g_pars.expect_channel_mode_modify) {
4032 /* Verify that the RSL-side activation actually matches our expectations */
4033 var RSL_Message rsl := f_rslem_get_last_act(RSL_PROC, 0, g_chan_nr);
Harald Weltea63b9102018-03-22 20:36:16 +01004034
Neels Hofmeyr559d5d02021-04-16 16:50:49 +02004035 var RSL_IE_Body mode_ie;
4036 if (f_rsl_find_ie(rsl, RSL_IE_CHAN_MODE, mode_ie) == false) {
4037 setverdict(fail, "Couldn't find CHAN_MODE IE");
Daniel Willmannafce8662018-07-06 23:11:32 +02004038 mtc.stop;
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02004039 }
Neels Hofmeyr559d5d02021-04-16 16:50:49 +02004040 var template RSL_IE_Body t_mode_ie := f_rsl_chmod_tmpl_from_codec(g_pars.ass_codec_list.codecElements[0]);
4041 if (not match(mode_ie, t_mode_ie)) {
4042 log("mode_ie ", mode_ie, " != t_mode_ie ", t_mode_ie);
4043 setverdict(fail, "RSL Channel Mode IE doesn't match expectation");
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02004044 }
Neels Hofmeyr559d5d02021-04-16 16:50:49 +02004045
4046 var RSL_IE_Body mr_conf;
4047 if (g_pars.expect_mr_conf_ie != omit) {
4048 if (f_rsl_find_ie(rsl, RSL_IE_MR_CONFIG, mr_conf) == false) {
4049 setverdict(fail, "Missing MR CONFIG IE in RSL Chan Activ");
4050 mtc.stop;
4051 }
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02004052 log("found RSL MR CONFIG IE: ", mr_conf);
Neels Hofmeyr559d5d02021-04-16 16:50:49 +02004053
4054 if (not match(mr_conf, g_pars.expect_mr_conf_ie)) {
4055 setverdict(fail, "RSL MR CONFIG IE does not match expectation. Expected: ",
4056 g_pars.expect_mr_conf_ie);
4057 }
4058 } else {
4059 if (f_rsl_find_ie(rsl, RSL_IE_MR_CONFIG, mr_conf) == true) {
4060 log("found RSL MR CONFIG IE: ", mr_conf);
4061 setverdict(fail, "Found MR CONFIG IE in RSL Chan Activ, expecting omit");
4062 mtc.stop;
4063 }
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02004064 }
4065 }
Harald Welte60aa5762018-03-21 19:33:13 +01004066}
4067
Philipp Maierd0e64b02019-03-13 14:15:23 +01004068private function f_TC_assignment_codec_fail(charstring id) runs on MSC_ConnHdlr {
4069
4070 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4071 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
4072
4073 /* puzzle together the ASSIGNMENT REQ for given codec[s] */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02004074 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
Philipp Maierd0e64b02019-03-13 14:15:23 +01004075 ass_cmd.pdu.bssmap.assignmentRequest.codecList := g_pars.ass_codec_list;
4076 }
4077 ass_cmd.pdu.bssmap.assignmentRequest.channelType :=
4078 f_BSSMAP_chtype_from_codec(g_pars.ass_codec_list.codecElements[0]);
4079 log("expecting ASS FAIL like this: ", exp_fail);
4080
4081 f_establish_fully(ass_cmd, exp_fail);
4082}
4083
Harald Welte60aa5762018-03-21 19:33:13 +01004084testcase TC_assignment_codec_fr() runs on test_CT {
Philipp Maier48604732018-10-09 15:00:37 +02004085 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte60aa5762018-03-21 19:33:13 +01004086 var MSC_ConnHdlr vc_conn;
4087
4088 f_init(1, true);
4089 f_sleep(1.0);
4090
4091 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
Harald Welte8863fa12018-05-10 20:15:27 +02004092 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01004093 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004094 f_shutdown_helper();
Harald Welte60aa5762018-03-21 19:33:13 +01004095}
4096
4097testcase TC_assignment_codec_hr() runs on test_CT {
Philipp Maier48604732018-10-09 15:00:37 +02004098 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte60aa5762018-03-21 19:33:13 +01004099 var MSC_ConnHdlr vc_conn;
4100
4101 f_init(1, true);
4102 f_sleep(1.0);
4103
4104 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR}));
Harald Welte8863fa12018-05-10 20:15:27 +02004105 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01004106 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004107 f_shutdown_helper();
Harald Welte60aa5762018-03-21 19:33:13 +01004108}
4109
4110testcase TC_assignment_codec_efr() runs on test_CT {
Philipp Maier48604732018-10-09 15:00:37 +02004111 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte60aa5762018-03-21 19:33:13 +01004112 var MSC_ConnHdlr vc_conn;
4113
4114 f_init(1, true);
4115 f_sleep(1.0);
4116
4117 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecEFR}));
Harald Welte8863fa12018-05-10 20:15:27 +02004118 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01004119 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004120 f_shutdown_helper();
Harald Welte60aa5762018-03-21 19:33:13 +01004121}
4122
Philipp Maierd0e64b02019-03-13 14:15:23 +01004123/* Allow 5,90k only (current default config) */
4124private function f_allow_amr_rate_5_90k() runs on test_CT {
Neels Hofmeyr2a5670b2020-11-25 23:39:57 +00004125 f_vty_cfg_msc(BSCVTY, 0, {
4126 "amr-config 12_2k forbidden",
4127 "amr-config 10_2k forbidden",
4128 "amr-config 7_95k forbidden",
4129 "amr-config 7_40k forbidden",
4130 "amr-config 6_70k forbidden",
4131 "amr-config 5_90k allowed",
4132 "amr-config 5_15k forbidden",
4133 "amr-config 4_75k forbidden"
4134 });
Philipp Maierd0e64b02019-03-13 14:15:23 +01004135}
4136
4137/* Allow 4,75k, 5,90k, 4,70k and 12,2k, which are the most common rates
4138 * ("Config-NB-Code = 1") */
4139private function f_allow_amr_rate_4_75k_5_90k_7_40k_12_20k() runs on test_CT {
Neels Hofmeyr2a5670b2020-11-25 23:39:57 +00004140 f_vty_cfg_msc(BSCVTY, 0, {
4141 "amr-config 12_2k allowed",
4142 "amr-config 10_2k forbidden",
4143 "amr-config 7_95k forbidden",
4144 "amr-config 7_40k allowed",
4145 "amr-config 6_70k forbidden",
4146 "amr-config 5_90k allowed",
4147 "amr-config 5_15k forbidden",
4148 "amr-config 4_75k allowed"
4149 });
Philipp Maierd0e64b02019-03-13 14:15:23 +01004150}
4151
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00004152private function f_vty_amr_start_mode_set(boolean fr, charstring startmode) runs on test_CT {
4153 var charstring tch;
4154 if (fr) {
4155 tch := "tch-f";
4156 } else {
4157 tch := "tch-h";
4158 }
4159 f_vty_cfg_bts(BSCVTY, 0, { "amr " & tch & " start-mode " & startmode });
4160}
4161
4162/* Set the AMR start-mode for this TCH back to the default configuration. */
4163private function f_vty_amr_start_mode_restore(boolean fr) runs on test_CT {
4164 f_vty_amr_start_mode_set(fr, "auto");
4165}
4166
Harald Welte60aa5762018-03-21 19:33:13 +01004167testcase TC_assignment_codec_amr_f() runs on test_CT {
Philipp Maier48604732018-10-09 15:00:37 +02004168 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte60aa5762018-03-21 19:33:13 +01004169 var MSC_ConnHdlr vc_conn;
Philipp Maier7695a0d2018-09-27 17:52:14 +02004170
4171 /* Note: This setups the codec configuration. The parameter payload in
4172 * mr_conf must be consistant with the parameter codecElements in pars
4173 * and also must match the amr-config in osmo-bsc.cfg! */
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02004174 var RSL_IE_Body mr_conf := {
4175 other := {
4176 len := 2,
4177 payload := '2804'O
4178 }
4179 };
Harald Welte60aa5762018-03-21 19:33:13 +01004180
Philipp Maier7695a0d2018-09-27 17:52:14 +02004181 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_F}));
Philipp Maier806f8f12019-03-12 12:13:41 +01004182 pars.ass_codec_list.codecElements[0].s0_7 := '00000100'B; /* 5,90k */
Philipp Maier7695a0d2018-09-27 17:52:14 +02004183 pars.ass_codec_list.codecElements[0].s8_15 := '01010111'B;
4184 pars.expect_mr_conf_ie := mr_conf;
4185
Harald Welte60aa5762018-03-21 19:33:13 +01004186 f_init(1, true);
4187 f_sleep(1.0);
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00004188 f_vty_amr_start_mode_set(true, "1");
Harald Welte60aa5762018-03-21 19:33:13 +01004189
Harald Welte8863fa12018-05-10 20:15:27 +02004190 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01004191 vc_conn.done;
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00004192
4193 f_vty_amr_start_mode_restore(true);
Vadim Yanitskiy292e5962021-01-03 14:18:47 +01004194 f_shutdown_helper();
Harald Welte60aa5762018-03-21 19:33:13 +01004195}
4196
4197testcase TC_assignment_codec_amr_h() runs on test_CT {
Philipp Maier48604732018-10-09 15:00:37 +02004198 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte60aa5762018-03-21 19:33:13 +01004199 var MSC_ConnHdlr vc_conn;
Philipp Maier7695a0d2018-09-27 17:52:14 +02004200
4201 /* See note above */
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02004202 var RSL_IE_Body mr_conf := {
4203 other := {
4204 len := 2,
4205 payload := '2804'O
4206 }
4207 };
Harald Welte60aa5762018-03-21 19:33:13 +01004208
Philipp Maier7695a0d2018-09-27 17:52:14 +02004209 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_H}));
Philipp Maier806f8f12019-03-12 12:13:41 +01004210 pars.ass_codec_list.codecElements[0].s0_7 := '00000100'B; /* 5,90k */
Philipp Maier7695a0d2018-09-27 17:52:14 +02004211 pars.ass_codec_list.codecElements[0].s8_15 := '00000111'B;
4212 pars.expect_mr_conf_ie := mr_conf;
4213
Harald Welte60aa5762018-03-21 19:33:13 +01004214 f_init(1, true);
4215 f_sleep(1.0);
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00004216 f_vty_amr_start_mode_set(false, "1");
Harald Welte60aa5762018-03-21 19:33:13 +01004217
Harald Welte8863fa12018-05-10 20:15:27 +02004218 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01004219 vc_conn.done;
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00004220
4221 f_vty_amr_start_mode_restore(false);
Vadim Yanitskiy292e5962021-01-03 14:18:47 +01004222 f_shutdown_helper();
Harald Welte60aa5762018-03-21 19:33:13 +01004223}
4224
Neels Hofmeyr559d5d02021-04-16 16:50:49 +02004225/* Establish signalling on a TCH/F lchan, and then switch to speech mode without a new Assignment. */
4226testcase TC_assignment_codec_fr_by_mode_modify() runs on test_CT {
4227 var TestHdlrParams pars := f_gen_test_hdlr_pars();
4228 var MSC_ConnHdlr vc_conn;
4229
4230 f_init(1, true);
4231 f_sleep(1.0);
4232
4233 /* By disabling all SDCCH, the MS should be given a TCH/F for signalling. Then activating an FR codec should
4234 * merely do a Channel Mode Modify, and not assign to a new lchan. f_establish_fully() already accounts for
4235 * expecting a Channel Mode Modify if the channel type is compatible. */
4236 f_disable_all_sdcch();
4237 f_disable_all_tch_h();
4238
4239 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
4240 pars.expect_channel_mode_modify := true;
4241 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
4242 vc_conn.done;
4243
4244 f_enable_all_sdcch();
4245 f_enable_all_tch();
4246 f_shutdown_helper();
4247}
4248
Neels Hofmeyr454d7922020-11-26 02:24:57 +00004249/* 'amr start-mode auto' should not keep the (unused) 'smod' bits from previous configuration */
4250testcase TC_assignment_codec_amr_startmode_cruft() runs on test_CT {
4251 var TestHdlrParams pars := f_gen_test_hdlr_pars();
4252 var MSC_ConnHdlr vc_conn;
4253
4254 var RSL_IE_Body mr_conf := {
4255 other := {
4256 len := 2,
4257 payload := '2004'O /* <- expect ICMI=0, smod=00 */
4258 }
4259 };
4260
4261 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_F}));
4262 pars.ass_codec_list.codecElements[0].s0_7 := '00000100'B; /* 5,90k */
4263 pars.ass_codec_list.codecElements[0].s8_15 := '01010111'B;
4264 pars.expect_mr_conf_ie := mr_conf;
4265
4266 f_init(1, true);
4267 f_sleep(1.0);
4268
4269 /* First set nonzero start mode bits */
4270 f_vty_amr_start_mode_set(true, "4");
4271 /* Now set to auto, and expect the startmode bits to be zero in the message, i.e. ensure that osmo-bsc does not
4272 * let the startmode bits stick around and has deterministic MultiRate config for 'start-mode auto'; that is
4273 * ensured by above '2004'O, where 'x0xx'O indicates ICMI = 0, spare = 0, smod = 00. */
4274 f_vty_amr_start_mode_set(true, "auto");
4275
4276 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
4277 vc_conn.done;
Neels Hofmeyr454d7922020-11-26 02:24:57 +00004278
4279 /* Clear the startmode bits to not affect subsequent tests, in case the bits should indeed stick around. */
4280 f_vty_amr_start_mode_set(true, "1");
4281 f_vty_amr_start_mode_restore(true);
Vadim Yanitskiy292e5962021-01-03 14:18:47 +01004282 f_shutdown_helper();
Neels Hofmeyr454d7922020-11-26 02:24:57 +00004283}
4284
Neels Hofmeyr21863562020-11-26 00:34:33 +00004285function f_TC_assignment_codec_amr(boolean fr, octetstring mrconf, bitstring s8_s0, bitstring exp_s8_s0,
4286 charstring start_mode := "1")
Philipp Maierd0e64b02019-03-13 14:15:23 +01004287runs on test_CT {
4288
4289 var TestHdlrParams pars := f_gen_test_hdlr_pars();
4290 var MSC_ConnHdlr vc_conn;
4291
4292 /* See note above */
4293 var RSL_IE_Body mr_conf := {
4294 other := {
4295 len := lengthof(mrconf),
4296 payload := mrconf
4297 }
4298 };
4299
4300 if (fr) {
4301 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_F}));
4302 } else {
4303 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_H}));
4304 }
4305 pars.ass_codec_list.codecElements[0].s0_7 := s8_s0;
4306 pars.ass_codec_list.codecElements[0].s8_15 := '00000111'B;
4307 pars.expect_mr_conf_ie := mr_conf;
4308 pars.expect_mr_s0_s7 := exp_s8_s0;
4309
4310 f_init(1, true);
4311 f_allow_amr_rate_4_75k_5_90k_7_40k_12_20k();
Neels Hofmeyr21863562020-11-26 00:34:33 +00004312 f_vty_amr_start_mode_set(fr, start_mode);
Philipp Maierd0e64b02019-03-13 14:15:23 +01004313 f_sleep(1.0);
4314
4315 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
4316 vc_conn.done;
4317 f_allow_amr_rate_5_90k();
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00004318 f_vty_amr_start_mode_restore(fr);
Philipp Maierd0e64b02019-03-13 14:15:23 +01004319}
4320
4321function f_TC_assignment_codec_amr_fail(boolean fr, bitstring s8_s0)
4322runs on test_CT {
4323
4324 var TestHdlrParams pars := f_gen_test_hdlr_pars();
4325 var MSC_ConnHdlr vc_conn;
4326
4327 if (fr) {
4328 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_F}));
4329 } else {
4330 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_H}));
4331 }
4332 pars.ass_codec_list.codecElements[0].s0_7 := s8_s0;
4333 pars.ass_codec_list.codecElements[0].s8_15 := '00000111'B;
4334
4335 f_init(1, true);
4336 f_allow_amr_rate_4_75k_5_90k_7_40k_12_20k();
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00004337 f_vty_amr_start_mode_set(fr, "1");
Philipp Maierd0e64b02019-03-13 14:15:23 +01004338 f_sleep(1.0);
4339
4340 vc_conn := f_start_handler(refers(f_TC_assignment_codec_fail), pars);
4341 vc_conn.done;
4342 f_allow_amr_rate_5_90k();
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00004343 f_vty_amr_start_mode_restore(fr);
Philipp Maierd0e64b02019-03-13 14:15:23 +01004344}
4345
4346
4347/* Set S1, we expect an AMR multirate configuration IE with all four rates
4348 * set. */
4349testcase TC_assignment_codec_amr_f_S1() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02004350 f_TC_assignment_codec_amr(true, '289520882208'O, '00000010'B, '00000010'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004351 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01004352}
4353
4354/* Set S1, we expect an AMR multirate configuration IE with the lower three
4355 * rates set. */
4356testcase TC_assignment_codec_amr_h_S1() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02004357 f_TC_assignment_codec_amr(false, '2815208820'O, '00000010'B, '00000010'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004358 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01004359}
4360
4361/* Set S1 and two other rates, we expect an AMR MULTIRATE CONFIGURATION IE with
4362 * all four rates (and only S1 set in the ASSIGNMENT COMPLETE) */
4363testcase TC_assignment_codec_amr_f_S124() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02004364 f_TC_assignment_codec_amr(true, '289520882208'O, '00010110'B, '00000010'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004365 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01004366}
4367
4368/* Set S1 and two other rates, we expect an AMR MULTIRATE CONFIGURATION IE with
4369 * all four rates (and only S1 set in the ASSIGNMENT COMPLETE) */
4370testcase TC_assignment_codec_amr_h_S124() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02004371 f_TC_assignment_codec_amr(false, '2815208820'O, '00010110'B, '00000010'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004372 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01004373}
4374
4375/* The following block of tests selects more and more rates until all four
4376 * possible rates are in the active set (full rate) */
4377testcase TC_assignment_codec_amr_f_S0() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02004378 f_TC_assignment_codec_amr(true, '2801'O, '00000001'B, '00000001'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004379 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01004380}
4381
4382testcase TC_assignment_codec_amr_f_S02() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02004383 f_TC_assignment_codec_amr(true, '28052080'O, '00000101'B, '00000101'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004384 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01004385}
4386
4387testcase TC_assignment_codec_amr_f_S024() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02004388 f_TC_assignment_codec_amr(true, '2815208820'O, '00010101'B, '00010101'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004389 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01004390}
4391
4392testcase TC_assignment_codec_amr_f_S0247() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02004393 f_TC_assignment_codec_amr(true, '289520882208'O, '10010101'B, '10010101'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004394 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01004395}
4396
4397/* The following block of tests selects more and more rates until all three
4398 * possible rates are in the active set (half rate) */
4399testcase TC_assignment_codec_amr_h_S0() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02004400 f_TC_assignment_codec_amr(false, '2801'O, '00000001'B, '00000001'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004401 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01004402}
4403
4404testcase TC_assignment_codec_amr_h_S02() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02004405 f_TC_assignment_codec_amr(false, '28052080'O, '00000101'B, '00000101'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004406 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01004407}
4408
4409testcase TC_assignment_codec_amr_h_S024() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02004410 f_TC_assignment_codec_amr(false, '2815208820'O, '00010101'B, '00010101'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004411 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01004412}
4413
4414/* The following block tests what happens when the MSC does offer rate
4415 * configurations that are not supported by the BSC. Normally such situations
4416 * should not happen because the MSC gets informed by the BSC in advance via
4417 * the L3 COMPLETE message which rates are applicable. The MSC should not try
4418 * to offer rates that are not applicable anyway. */
4419
4420testcase TC_assignment_codec_amr_h_S0247() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02004421 /* Try to include 12,2k in into the active set even though the channel
4422 * is half rate only. The BSC is expected to remove the 12,0k */
4423 f_TC_assignment_codec_amr(false, '2815208820'O, '10010101'B, '00010101'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004424 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01004425}
4426
4427testcase TC_assignment_codec_amr_f_S01234567() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02004428 /* See what happens when all rates are selected at once. Since then
4429 * Also S1 is selected, this setting will be prefered and we should
4430 * get 12.2k, 7,40k, 5,90k, and 4,75k in the active set. */
4431 f_TC_assignment_codec_amr(true, '289520882208'O, '11111111'B, '00000010'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004432 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01004433}
4434
4435testcase TC_assignment_codec_amr_f_S0234567() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02004436 /* Same as above, but with S1 missing, the MSC is then expected to
4437 * select the currently supported rates, which are also 12.2k, 7,40k,
4438 * 5,90k, and 4,75k, into the active set. */
4439 f_TC_assignment_codec_amr(true, '289520882208'O, '11111101'B, '10010101'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004440 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01004441}
4442
4443testcase TC_assignment_codec_amr_f_zero() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02004444 /* Try to select no rates at all */
4445 f_TC_assignment_codec_amr_fail(true, '00000000'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004446 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01004447}
4448
4449testcase TC_assignment_codec_amr_f_unsupp() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02004450 /* Try to select only unsupported rates */
4451 f_TC_assignment_codec_amr_fail(true, '01101000'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004452 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01004453}
4454
4455testcase TC_assignment_codec_amr_h_S7() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02004456 /* Try to select 12,2k for half rate */
4457 f_TC_assignment_codec_amr_fail(false, '10000000'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004458 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01004459}
4460
Neels Hofmeyr21863562020-11-26 00:34:33 +00004461testcase TC_assignment_codec_amr_f_start_mode_auto() runs on test_CT {
4462 f_TC_assignment_codec_amr(true, '209520882208'O, '11111111'B, '00000010'B,
4463 start_mode := "auto");
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01004464 f_shutdown_helper();
Neels Hofmeyr21863562020-11-26 00:34:33 +00004465}
4466
4467testcase TC_assignment_codec_amr_h_start_mode_auto() runs on test_CT {
4468 f_TC_assignment_codec_amr(false, '2015208820'O, '10010101'B, '00010101'B,
4469 start_mode := "auto");
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01004470 f_shutdown_helper();
Neels Hofmeyr21863562020-11-26 00:34:33 +00004471}
4472
Neels Hofmeyr3eb94562020-11-26 02:40:26 +00004473testcase TC_assignment_codec_amr_f_start_mode_4() runs on test_CT {
Vadim Yanitskiy7815f482021-01-03 17:07:37 +01004474 /* "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 +00004475 f_TC_assignment_codec_amr(true, '2b9520882208'O, '11111111'B, '00000010'B,
4476 start_mode := "4");
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01004477 f_shutdown_helper();
Neels Hofmeyr3eb94562020-11-26 02:40:26 +00004478}
4479
4480testcase TC_assignment_codec_amr_h_start_mode_4() runs on test_CT {
Vadim Yanitskiy7815f482021-01-03 17:07:37 +01004481 /* "amr tch-h modes 0 2 4" => total 3 modes and start mode 4 => '10'B on the wire */
4482 f_TC_assignment_codec_amr(false, '2a15208820'O, '10010101'B, '00010101'B,
Neels Hofmeyr3eb94562020-11-26 02:40:26 +00004483 start_mode := "4");
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01004484 f_shutdown_helper();
Neels Hofmeyr3eb94562020-11-26 02:40:26 +00004485}
4486
Philipp Maierac09bfc2019-01-08 13:41:39 +01004487private function f_disable_all_tch_f() runs on test_CT {
Philipp Maierc704a882019-01-29 15:58:52 +01004488 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 1 sub-slot 0 borken");
4489 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 2 sub-slot 0 borken");
4490 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 3 sub-slot 0 borken");
4491 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 4 sub-slot 0 borken");
Philipp Maierac09bfc2019-01-08 13:41:39 +01004492}
4493
4494private function f_disable_all_tch_h() runs on test_CT {
Philipp Maierc704a882019-01-29 15:58:52 +01004495 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 5 sub-slot 0 borken");
4496 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 5 sub-slot 1 borken");
Philipp Maierac09bfc2019-01-08 13:41:39 +01004497}
4498
4499private function f_enable_all_tch() runs on test_CT {
Philipp Maierc704a882019-01-29 15:58:52 +01004500 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 1 sub-slot 0 unused");
4501 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 2 sub-slot 0 unused");
4502 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 3 sub-slot 0 unused");
4503 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 4 sub-slot 0 unused");
4504 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 5 sub-slot 0 unused");
4505 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 5 sub-slot 1 unused");
Philipp Maierac09bfc2019-01-08 13:41:39 +01004506}
4507
Neels Hofmeyr559d5d02021-04-16 16:50:49 +02004508private function f_disable_all_sdcch() runs on test_CT {
4509 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 0 sub-slot 0 borken");
4510 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 0 sub-slot 1 borken");
4511 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 0 sub-slot 2 borken");
4512 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 0 sub-slot 3 borken");
4513}
4514
4515private function f_enable_all_sdcch() runs on test_CT {
4516 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 0 sub-slot 0 unused");
4517 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 0 sub-slot 1 unused");
4518 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 0 sub-slot 2 unused");
4519 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 0 sub-slot 3 unused");
4520}
4521
Philipp Maierac09bfc2019-01-08 13:41:39 +01004522/* Allow HR only */
4523private function f_TC_assignment_codec_xr_exhausted_req_hr(charstring id) runs on MSC_ConnHdlr {
4524 g_pars := f_gen_test_hdlr_pars();
4525 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4526 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4527 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4528 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '09'O;
4529 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '05'O;
4530 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR}));
4531 f_establish_fully(ass_cmd, exp_compl);
4532}
4533
4534/* Allow FR only */
4535private function f_TC_assignment_codec_xr_exhausted_req_fr(charstring id) runs on MSC_ConnHdlr {
4536 g_pars := f_gen_test_hdlr_pars();
4537 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4538 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4539 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4540 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '08'O;
4541 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '01'O;
4542 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
4543 f_establish_fully(ass_cmd, exp_compl);
4544}
4545
4546/* Allow HR only (expect assignment failure) */
4547private function f_TC_assignment_codec_xr_exhausted_req_hr_fail(charstring id) runs on MSC_ConnHdlr {
4548 g_pars := f_gen_test_hdlr_pars();
4549 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4550 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
4551 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4552 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '09'O;
4553 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '05'O;
4554 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR}));
4555 f_establish_fully(ass_cmd, exp_fail);
4556}
4557
4558/* Allow FR only (expect assignment failure) */
4559private function f_TC_assignment_codec_xr_exhausted_req_fr_fail(charstring id) runs on MSC_ConnHdlr {
4560 g_pars := f_gen_test_hdlr_pars();
4561 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4562 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
4563 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4564 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '08'O;
4565 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '01'O;
4566 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
4567 f_establish_fully(ass_cmd, exp_fail);
4568}
4569
4570/* Allow FR and HR, but prefer FR */
4571private function f_TC_assignment_codec_fr_exhausted_req_fr_hr(charstring id) runs on MSC_ConnHdlr {
4572 g_pars := f_gen_test_hdlr_pars();
4573 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4574 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4575 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4576 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0A'O; /* Prefer FR */
4577 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8105'O;
4578 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR, ts_CodecHR}));
4579 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000101'B; /* Expect HR */
4580 f_establish_fully(ass_cmd, exp_compl);
4581}
4582
4583/* Allow FR and HR, but prefer HR */
4584private function f_TC_assignment_codec_fr_exhausted_req_hr_fr(charstring id) runs on MSC_ConnHdlr {
4585 g_pars := f_gen_test_hdlr_pars();
4586 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4587 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4588 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4589 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0B'O; /* Prefer HR */
4590 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8501'O;
4591 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR, ts_CodecFR}));
4592 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000101'B; /* Expect HR */
4593 f_establish_fully(ass_cmd, exp_compl);
4594}
4595
4596/* Allow FR and HR, but prefer FR */
4597private function f_TC_assignment_codec_hr_exhausted_req_fr_hr(charstring id) runs on MSC_ConnHdlr {
4598 g_pars := f_gen_test_hdlr_pars();
4599 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4600 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4601 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4602 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0A'O; /* Prefer FR */
4603 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8105'O;
4604 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR, ts_CodecHR}));
4605 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000001'B; /* Expect FR */
4606 f_establish_fully(ass_cmd, exp_compl);
4607}
4608
4609/* Allow FR and HR, but prefer HR */
4610private function f_TC_assignment_codec_hr_exhausted_req_hr_fr(charstring id) runs on MSC_ConnHdlr {
4611 g_pars := f_gen_test_hdlr_pars();
4612 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4613 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4614 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4615 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0B'O; /* Prefer HR */
4616 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8501'O;
4617 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR, ts_CodecFR}));
4618 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000001'B; /* Expect FR */
4619 f_establish_fully(ass_cmd, exp_compl);
4620}
4621
4622/* Request a HR channel while all FR channels are exhausted, this is expected
4623 * to work without conflicts */
4624testcase TC_assignment_codec_fr_exhausted_req_hr() runs on test_CT {
4625 var MSC_ConnHdlr vc_conn;
4626 f_init(1, true);
4627 f_sleep(1.0);
4628 f_enable_all_tch();
4629 f_disable_all_tch_f();
4630 vc_conn := f_start_handler(refers(f_TC_assignment_codec_xr_exhausted_req_hr));
4631 vc_conn.done;
4632 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004633 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004634}
4635
4636/* Request a FR channel while all FR channels are exhausted, this is expected
4637 * to fail. */
4638testcase TC_assignment_codec_fr_exhausted_req_fr() runs on test_CT {
4639 var MSC_ConnHdlr vc_conn;
4640 f_init(1, true);
4641 f_sleep(1.0);
4642 f_enable_all_tch();
4643 f_disable_all_tch_f();
4644 vc_conn := f_start_handler(refers(f_TC_assignment_codec_xr_exhausted_req_fr_fail));
4645 vc_conn.done;
4646 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004647 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004648}
4649
4650/* Request a FR (prefered) or alternatively a HR channel while all FR channels
4651 * are exhausted, this is expected to be resolved by selecting a HR channel. */
4652testcase TC_assignment_codec_fr_exhausted_req_fr_hr() runs on test_CT {
4653 var MSC_ConnHdlr vc_conn;
4654 f_init(1, true);
4655 f_sleep(1.0);
4656 f_enable_all_tch();
4657 f_disable_all_tch_f();
4658 vc_conn := f_start_handler(refers(f_TC_assignment_codec_fr_exhausted_req_fr_hr));
4659 vc_conn.done;
4660 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004661 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004662}
4663
4664/* Request a HR (prefered) or alternatively a FR channel while all FR channels
4665 * are exhausted, this is expected to work without conflicts. */
4666testcase TC_assignment_codec_fr_exhausted_req_hr_fr() runs on test_CT {
4667 var MSC_ConnHdlr vc_conn;
4668 f_init(1, true);
4669 f_sleep(1.0);
4670 f_enable_all_tch();
4671 f_disable_all_tch_f();
4672 vc_conn := f_start_handler(refers(f_TC_assignment_codec_fr_exhausted_req_hr_fr));
4673 vc_conn.done;
4674 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004675 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004676}
4677
4678/* Request a FR channel while all HR channels are exhausted, this is expected
4679 * to work without conflicts */
4680testcase TC_assignment_codec_hr_exhausted_req_fr() runs on test_CT {
4681 var MSC_ConnHdlr vc_conn;
4682 f_init(1, true);
4683 f_sleep(1.0);
4684 f_enable_all_tch();
4685 f_disable_all_tch_h();
4686 vc_conn := f_start_handler(refers(f_TC_assignment_codec_xr_exhausted_req_fr));
4687 vc_conn.done;
4688 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004689 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004690}
4691
4692/* Request a HR channel while all HR channels are exhausted, this is expected
4693 * to fail. */
4694testcase TC_assignment_codec_hr_exhausted_req_hr() runs on test_CT {
4695 var MSC_ConnHdlr vc_conn;
4696 f_init(1, true);
4697 f_sleep(1.0);
4698 f_enable_all_tch();
4699 f_disable_all_tch_h();
4700 vc_conn := f_start_handler(refers(f_TC_assignment_codec_xr_exhausted_req_hr_fail));
4701 vc_conn.done;
4702 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004703 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004704}
4705
4706/* Request a HR (prefered) or alternatively a FR channel while all HR channels
4707 * are exhausted, this is expected to be resolved by selecting a FR channel. */
4708testcase TC_assignment_codec_hr_exhausted_req_hr_fr() runs on test_CT {
4709 var MSC_ConnHdlr vc_conn;
4710 f_init(1, true);
4711 f_sleep(1.0);
4712 f_enable_all_tch();
4713 f_disable_all_tch_h();
4714 vc_conn := f_start_handler(refers(f_TC_assignment_codec_hr_exhausted_req_hr_fr));
4715 vc_conn.done;
4716 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004717 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004718}
4719
4720/* Request a FR (prefered) or alternatively a HR channel while all HR channels
4721 * are exhausted, this is expected to work without conflicts. */
4722testcase TC_assignment_codec_hr_exhausted_req_fr_hr() runs on test_CT {
4723 var MSC_ConnHdlr vc_conn;
4724 f_init(1, true);
4725 f_sleep(1.0);
4726 f_enable_all_tch();
4727 f_disable_all_tch_h();
4728 vc_conn := f_start_handler(refers(f_TC_assignment_codec_hr_exhausted_req_fr_hr));
4729 vc_conn.done;
4730 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004731 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004732}
4733
4734/* Allow FR and HR, but prefer HR */
4735private function f_TC_assignment_codec_req_hr_fr(charstring id) runs on MSC_ConnHdlr {
4736 g_pars := f_gen_test_hdlr_pars();
4737 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4738 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4739 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4740 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0B'O; /* Prefer HR */
4741 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8501'O;
4742 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR, ts_CodecFR}));
4743 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000101'B; /* Expect HR */
4744 f_establish_fully(ass_cmd, exp_compl);
4745}
4746
4747/* Allow FR and HR, but prefer FR */
4748private function f_TC_assignment_codec_req_fr_hr(charstring id) runs on MSC_ConnHdlr {
4749 g_pars := f_gen_test_hdlr_pars();
4750 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4751 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4752 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4753 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0A'O; /* Prefer FR */
4754 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8105'O;
4755 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR, ts_CodecHR}));
4756 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000001'B; /* Expect FR */
4757 f_establish_fully(ass_cmd, exp_compl);
4758}
4759
4760/* Request a HR (prefered) or alternatively a FR channel, it is expected that
4761 * HR, which is the prefered type, is selected. */
4762testcase TC_assignment_codec_req_hr_fr() runs on test_CT {
4763 var MSC_ConnHdlr vc_conn;
4764 f_init(1, true);
4765 f_sleep(1.0);
4766 f_enable_all_tch();
4767 vc_conn := f_start_handler(refers(f_TC_assignment_codec_req_hr_fr));
4768 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004769 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004770}
4771
4772/* Request a FR (prefered) or alternatively a HR channel, it is expected that
4773 * FR, which is the prefered type, is selected. */
4774testcase TC_assignment_codec_req_fr_hr() runs on test_CT {
4775 var MSC_ConnHdlr vc_conn;
4776 f_init(1, true);
4777 f_sleep(1.0);
4778 f_enable_all_tch();
4779 vc_conn := f_start_handler(refers(f_TC_assignment_codec_req_fr_hr));
4780 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004781 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004782}
4783
Pau Espin Pedrol14475352021-07-22 15:48:16 +02004784/* request a signalling channel with all SDCCH exhausted, it is expected that a TCH will be selected */
4785private function f_TC_assignment_sdcch_exhausted_req_signalling(charstring id) runs on MSC_ConnHdlr {
4786 g_pars := f_gen_test_hdlr_pars();
4787 g_pars.ra := '02'O; /* RA containing reason=LU */
4788
4789 var MobileIdentityLV mi := valueof(ts_MI_IMSI_LV(g_pars.imsi));
4790 var PDU_ML3_MS_NW l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, mi));
4791 var octetstring l3_enc := enc_PDU_ML3_MS_NW(l3_info);
4792 var template uint3_t tsc := ?;
4793
4794 f_MscConnHdlr_init(g_pars.media_nr, host_bts, host_mgw_mgcp, FR_AMR);
4795 f_create_bssmap_exp(l3_enc);
4796 /* call helper function for CHAN_RQD -> IMM ASS ->EST_IND */
4797 RSL_Emulation.f_chan_est(g_pars.ra, l3_enc, g_pars.link_id, g_pars.fn, tsc);
4798
4799 /* we should now have a COMPL_L3 at the MSC */
4800 timer T := 10.0;
4801 T.start;
4802 alt {
4803 [] BSSAP.receive(tr_BSSMAP_ComplL3);
4804 [] T.timeout {
4805 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for COMPLETE LAYER 3 INFORMATION");
4806 }
4807 }
4808}
4809testcase TC_assignment_sdcch_exhausted_req_signalling() runs on test_CT {
4810 var MSC_ConnHdlr vc_conn;
4811 f_init(1, true);
4812 f_sleep(1.0);
4813 f_disable_all_sdcch();
4814 vc_conn := f_start_handler(refers(f_TC_assignment_sdcch_exhausted_req_signalling));
4815 vc_conn.done;
4816 f_enable_all_sdcch();
4817 f_shutdown_helper();
4818}
4819
4820/* Request a signalling channel with all SDCCH exhausted, it is
4821 expected that no TCH will be selected for signalling and assigment will fail
4822 because it's dictated by VTY config */
4823testcase TC_assignment_sdcch_exhausted_req_signalling_tch_forbidden() runs on test_CT {
4824 var RSL_Message rsl_unused, rsl_msg;
4825 var GsmRrMessage rr;
4826 f_init(1, false);
4827 f_sleep(1.0);
4828 f_vty_allow_tch_for_signalling(false, 0);
4829 f_disable_all_sdcch();
4830
4831 /* RA containing reason=LU */
4832 f_ipa_tx(0, ts_RSL_CHAN_RQD('02'O, 2342));
4833 rsl_msg := f_exp_ipa_rx(0, tr_RSL_IMM_ASSIGN(0));
4834 rr := dec_GsmRrMessage(rsl_msg.ies[1].body.full_imm_ass_info.payload);
4835 if (rr.header.message_type != IMMEDIATE_ASSIGNMENT_REJECT) {
4836 setverdict(fail, "Expected reject");
4837 }
4838
4839 f_vty_allow_tch_for_signalling(true, 0);
4840 f_enable_all_sdcch();
4841 f_shutdown_helper();
4842}
4843
4844/* Request a voice channel with all SDCCH exhausted, it is
4845 * expected that TCH channel will be allocated since the VTY option is only
4846 * aimed at signalling requests */
4847private function f_TC_assignment_sdcch_exhausted_req_voice_tch_forbidden(charstring id) runs on MSC_ConnHdlr {
4848 g_pars := f_gen_test_hdlr_pars();
4849 g_pars.ra := '43'O; /* RA containing reason=originating speech call*/
4850
4851 var MobileIdentityLV mi := valueof(ts_MI_IMSI_LV(g_pars.imsi));
4852 var PDU_ML3_MS_NW l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, mi));
4853 var octetstring l3_enc := enc_PDU_ML3_MS_NW(l3_info);
4854 var template uint3_t tsc := ?;
4855
4856 f_MscConnHdlr_init(g_pars.media_nr, host_bts, host_mgw_mgcp, FR_AMR);
4857 f_create_bssmap_exp(l3_enc);
4858 /* call helper function for CHAN_RQD -> IMM ASS ->EST_IND */
4859 RSL_Emulation.f_chan_est(g_pars.ra, l3_enc, g_pars.link_id, g_pars.fn, tsc);
4860
4861 /* we should now have a COMPL_L3 at the MSC */
4862 timer T := 10.0;
4863 T.start;
4864 alt {
4865 [] BSSAP.receive(tr_BSSMAP_ComplL3);
4866 [] T.timeout {
4867 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for COMPLETE LAYER 3 INFORMATION");
4868 }
4869 }
4870}
4871testcase TC_assignment_sdcch_exhausted_req_voice_tch_forbidden() runs on test_CT {
4872 var MSC_ConnHdlr vc_conn;
4873 f_init(1, true);
4874 f_sleep(1.0);
4875 f_vty_allow_tch_for_signalling(false, 0);
4876 f_disable_all_sdcch();
4877
4878 vc_conn := f_start_handler(refers(f_TC_assignment_sdcch_exhausted_req_voice_tch_forbidden));
4879 vc_conn.done;
4880
4881 f_vty_allow_tch_for_signalling(true, 0);
4882 f_enable_all_sdcch();
4883 f_shutdown_helper();
4884}
4885
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02004886testcase TC_assignment_osmux() runs on test_CT {
4887 var TestHdlrParams pars := f_gen_test_hdlr_pars();
4888 var MSC_ConnHdlr vc_conn;
4889
4890 /* See note above */
4891 var RSL_IE_Body mr_conf := {
4892 other := {
4893 len := 2,
4894 payload := '2804'O
4895 }
4896 };
4897
4898 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_H}));
4899 pars.ass_codec_list.codecElements[0].s0_7 := '00000100'B; /* 5,90k */
4900 pars.ass_codec_list.codecElements[0].s8_15 := '00000111'B;
4901 pars.expect_mr_conf_ie := mr_conf;
4902 pars.use_osmux := true;
4903
4904 f_init(1, true, true);
4905 f_sleep(1.0);
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00004906 f_vty_amr_start_mode_set(false, "1");
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02004907
4908 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
4909 vc_conn.done;
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00004910
4911 f_vty_amr_start_mode_restore(false);
Vadim Yanitskiy292e5962021-01-03 14:18:47 +01004912 f_shutdown_helper();
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02004913}
4914
Neels Hofmeyr92b12b72018-09-18 14:30:23 +02004915/* test the procedure of the MSC requesting a Classmark Update:
4916 * a) BSSMAP Classmark Request should result in RR CLASSMARK ENQUIRY,
4917 * b) L3 RR CLASSMARK CHANGE should result in BSSMAP CLASSMARK UPDATE */
Harald Welte898113b2018-01-31 18:32:21 +01004918private function f_tc_classmark(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02004919 g_pars := f_gen_test_hdlr_pars();
4920
Harald Weltea0630032018-03-20 21:09:55 +01004921 f_create_chan_and_exp();
Harald Welte898113b2018-01-31 18:32:21 +01004922 /* we should now have a COMPL_L3 at the MSC */
4923 BSSAP.receive(tr_BSSMAP_ComplL3);
4924
Neels Hofmeyr92b12b72018-09-18 14:30:23 +02004925 BSSAP.send(ts_BSSMAP_ClassmarkRequest);
4926 RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_CM_ENQUIRY));
4927
Harald Welte898113b2018-01-31 18:32:21 +01004928 f_rsl_send_l3(ts_RRM_CM_CHG(valueof(ts_CM2)));
4929 BSSAP.receive(tr_BSSMAP_ClassmarkUpd(?, omit));
4930 setverdict(pass);
4931}
4932testcase TC_classmark() runs on test_CT {
4933 var MSC_ConnHdlr vc_conn;
4934 f_init(1, true);
4935 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02004936 vc_conn := f_start_handler(refers(f_tc_classmark));
Harald Welte898113b2018-01-31 18:32:21 +01004937 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004938 f_shutdown_helper();
Harald Welte898113b2018-01-31 18:32:21 +01004939}
4940
Harald Welteeddf0e92020-06-21 19:42:15 +02004941/* Send a CommonID from the simulated MSC and verify that the information is used to
4942 * fill BSC-internal data structures (specifically, bsc_subscr associated with subscr_conn) */
4943private function f_tc_common_id(charstring id) runs on MSC_ConnHdlr {
4944 g_pars := f_gen_test_hdlr_pars();
4945 f_MscConnHdlr_init_vty();
4946
4947 f_create_chan_and_exp();
4948 /* we should now have a COMPL_L3 at the MSC */
4949 BSSAP.receive(tr_BSSMAP_ComplL3);
4950
4951 /* Send CommonID */
4952 BSSAP.send(ts_BSSMAP_CommonId(g_pars.imsi));
4953
4954 /* Use VTY to verify that the IMSI of the subscr_conn is set */
4955 var charstring regex := "*(IMSI: " & hex2str(g_pars.imsi) & ")*";
4956 f_vty_transceive_match_regexp_retry(BSCVTY, "show conns", regex, 0, 4, 1.0);
4957
4958 setverdict(pass);
4959}
4960testcase TC_common_id() runs on test_CT {
4961 var MSC_ConnHdlr vc_conn;
4962 f_init(1, true);
4963 f_sleep(1.0);
4964 vc_conn := f_start_handler(refers(f_tc_common_id));
4965 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004966 f_shutdown_helper();
Harald Welteeddf0e92020-06-21 19:42:15 +02004967}
4968
Harald Weltee3bd6582018-01-31 22:51:25 +01004969private function f_est_single_l3(template PDU_ML3_MS_NW l3) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02004970 g_pars := f_gen_test_hdlr_pars();
Harald Weltea0630032018-03-20 21:09:55 +01004971 f_create_chan_and_exp();
Harald Welte898113b2018-01-31 18:32:21 +01004972 /* we should now have a COMPL_L3 at the MSC */
4973 BSSAP.receive(tr_BSSMAP_ComplL3);
4974
Harald Weltee3bd6582018-01-31 22:51:25 +01004975 /* send the single message we want to send */
4976 f_rsl_send_l3(l3);
4977}
4978
4979private function f_bssap_expect_nothing(float sec := 5.00) runs on MSC_ConnHdlr {
4980 timer T := sec;
4981 var PDU_BSSAP bssap;
Harald Welte898113b2018-01-31 18:32:21 +01004982 T.start;
4983 alt {
Harald Weltee3bd6582018-01-31 22:51:25 +01004984 [] BSSAP.receive(PDU_BSSAP:?) -> value bssap {
4985 setverdict(fail, "Unexpected BSSMAP ", bssap);
Daniel Willmannafce8662018-07-06 23:11:32 +02004986 mtc.stop;
Harald Welte898113b2018-01-31 18:32:21 +01004987 }
4988 [] T.timeout {
4989 setverdict(pass);
4990 }
4991 }
4992}
4993
Harald Weltee3bd6582018-01-31 22:51:25 +01004994/* unsolicited ASSIGNMENT FAIL (without ASSIGN) from MS shouldn't bring BSC down */
4995private function f_tc_unsol_ass_fail(charstring id) runs on MSC_ConnHdlr {
4996 f_est_single_l3(ts_RRM_AssignmentFailure('00'O));
4997 f_bssap_expect_nothing();
4998}
Harald Welte898113b2018-01-31 18:32:21 +01004999testcase TC_unsol_ass_fail() runs on test_CT {
5000 var MSC_ConnHdlr vc_conn;
5001 f_init(1, true);
5002 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02005003 vc_conn := f_start_handler(refers(f_tc_unsol_ass_fail));
Harald Welte898113b2018-01-31 18:32:21 +01005004 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005005 f_shutdown_helper();
Harald Welte898113b2018-01-31 18:32:21 +01005006}
Harald Welte552620d2017-12-16 23:21:36 +01005007
Harald Welteea99a002018-01-31 20:46:43 +01005008
5009/* unsolicited ASSIGNMENT COMPLETE (without ASSIGN) from MS shouldn't bring BSC down */
5010private function f_tc_unsol_ass_compl(charstring id) runs on MSC_ConnHdlr {
Harald Weltee3bd6582018-01-31 22:51:25 +01005011 f_est_single_l3(ts_RRM_AssignmentComplete('00'O));
5012 f_bssap_expect_nothing();
Harald Welteea99a002018-01-31 20:46:43 +01005013}
5014testcase TC_unsol_ass_compl() runs on test_CT {
5015 var MSC_ConnHdlr vc_conn;
5016 f_init(1, true);
5017 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02005018 vc_conn := f_start_handler(refers(f_tc_unsol_ass_compl));
Harald Welteea99a002018-01-31 20:46:43 +01005019 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005020 f_shutdown_helper();
Harald Welteea99a002018-01-31 20:46:43 +01005021}
5022
5023
Harald Weltefbf9b5e2018-01-31 20:41:23 +01005024/* unsolicited HANDOVER FAIL (without ASSIGN) from MS shouldn't bring BSC down */
5025private function f_tc_unsol_ho_fail(charstring id) runs on MSC_ConnHdlr {
Harald Weltee3bd6582018-01-31 22:51:25 +01005026 f_est_single_l3(ts_RRM_HandoverFailure('00'O));
5027 f_bssap_expect_nothing();
Harald Weltefbf9b5e2018-01-31 20:41:23 +01005028}
Harald Weltefbf9b5e2018-01-31 20:41:23 +01005029testcase TC_unsol_ho_fail() runs on test_CT {
5030 var MSC_ConnHdlr vc_conn;
5031 f_init(1, true);
5032 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02005033 vc_conn := f_start_handler(refers(f_tc_unsol_ho_fail));
Harald Weltefbf9b5e2018-01-31 20:41:23 +01005034 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005035 f_shutdown_helper();
Harald Weltefbf9b5e2018-01-31 20:41:23 +01005036}
5037
5038
Harald Weltee3bd6582018-01-31 22:51:25 +01005039/* short message from MS should be ignored */
5040private function f_tc_err_82_short_msg(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02005041 g_pars := f_gen_test_hdlr_pars();
Harald Weltea0630032018-03-20 21:09:55 +01005042 f_create_chan_and_exp();
Harald Weltee3bd6582018-01-31 22:51:25 +01005043 /* we should now have a COMPL_L3 at the MSC */
5044 BSSAP.receive(tr_BSSMAP_ComplL3);
5045
5046 /* send short message */
5047 RSL.send(ts_RSL_DATA_IND(g_chan_nr, valueof(ts_RslLinkID_DCCH(0)), ''O));
5048 f_bssap_expect_nothing();
5049}
5050testcase TC_err_82_short_msg() runs on test_CT {
5051 var MSC_ConnHdlr vc_conn;
5052 f_init(1, true);
5053 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02005054 vc_conn := f_start_handler(refers(f_tc_err_82_short_msg));
Harald Weltee3bd6582018-01-31 22:51:25 +01005055 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005056 f_shutdown_helper();
Harald Weltee3bd6582018-01-31 22:51:25 +01005057}
5058
5059
Harald Weltee9e02e42018-01-31 23:36:25 +01005060/* 24.008 8.4 Unknown message must trigger RR STATUS */
5061private function f_tc_err_84_unknown_msg(charstring id) runs on MSC_ConnHdlr {
5062 f_est_single_l3(ts_RRM_UL_REL('00'O));
5063 timer T := 3.0
5064 alt {
5065 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_STATUS)) {
5066 setverdict(pass);
5067 }
5068 [] BSSAP.receive { setverdict(fail, "unexpected BSSAP"); }
Harald Welte458fd372018-03-21 11:26:23 +01005069 [] T.timeout { setverdict(fail, "Timeout waiting for RR STATUS"); }
Harald Weltee9e02e42018-01-31 23:36:25 +01005070 }
5071}
5072testcase TC_err_84_unknown_msg() runs on test_CT {
5073 var MSC_ConnHdlr vc_conn;
5074 f_init(1, true);
5075 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02005076 vc_conn := f_start_handler(refers(f_tc_err_84_unknown_msg));
Harald Weltee9e02e42018-01-31 23:36:25 +01005077 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005078 f_shutdown_helper();
Harald Weltee9e02e42018-01-31 23:36:25 +01005079}
5080
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005081/***********************************************************************
5082 * Handover
5083 ***********************************************************************/
5084
Harald Welte94e0c342018-04-07 11:33:23 +02005085/* execute a "bts <0-255> trx <0-255> timeslot <0-7> " command on given Dchan */
5086private function f_vty_ts_action(charstring suffix, integer bts_nr, integer trx_nr, integer ts_nr)
5087runs on test_CT {
5088 var charstring cmd := "bts "&int2str(bts_nr)&" trx "&int2str(trx_nr)&
5089 " timeslot "&int2str(ts_nr)&" ";
5090 f_vty_transceive(BSCVTY, cmd & suffix);
5091}
5092
Harald Welte261af4b2018-02-12 21:20:39 +01005093/* 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 +07005094private function f_vty_ss_action(TELNETasp_PT pt, charstring suffix,
5095 uint8_t bts_nr, uint8_t trx_nr,
5096 in RslChannelNr chan_nr)
5097{
Harald Welte261af4b2018-02-12 21:20:39 +01005098 /* FIXME: resolve those from component-global state */
5099 var integer ts_nr := chan_nr.tn;
5100 var integer ss_nr;
5101 if (ischosen(chan_nr.u.ch0)) {
5102 ss_nr := 0;
5103 } else if (ischosen(chan_nr.u.lm)) {
5104 ss_nr := chan_nr.u.lm.sub_chan;
5105 } else if (ischosen(chan_nr.u.sdcch4)) {
5106 ss_nr := chan_nr.u.sdcch4.sub_chan;
5107 } else if (ischosen(chan_nr.u.sdcch8)) {
5108 ss_nr := chan_nr.u.sdcch8.sub_chan;
5109 } else {
5110 setverdict(fail, "Invalid ChanNr ", chan_nr);
Daniel Willmannafce8662018-07-06 23:11:32 +02005111 mtc.stop;
Harald Welte261af4b2018-02-12 21:20:39 +01005112 }
5113
5114 var charstring cmd := "bts "&int2str(bts_nr)&" trx "&int2str(trx_nr)&
5115 " timeslot "&int2str(ts_nr)&" sub-slot "&int2str(ss_nr)&" ";
Vadim Yanitskiy00070722020-09-02 17:27:57 +07005116 f_vty_transceive(pt, cmd & suffix);
Harald Welte261af4b2018-02-12 21:20:39 +01005117}
5118
Neels Hofmeyr91401012019-07-11 00:42:35 +02005119/* Even though the VTY command to trigger handover takes a new BTS number as argument, behind the scenes osmo-bsc always
5120 * translates that to a target ARFCN+BSIC first. See bsc_vty.c trigger_ho_or_as(), which puts the selected BTS' neighbor
5121 * ident key (ARFCN + BSIC) in the struct passed on to handover_request(). handover_start() then resolves that to a
5122 * viable actual neighbor cell. So from the internal osmo-bsc perspective, we always request handover to an ARFCN + BSIC
5123 * pair, not really to a specific BTS number. */
Vadim Yanitskiy00070722020-09-02 17:27:57 +07005124private function f_vty_handover(TELNETasp_PT pt, uint8_t bts_nr, uint8_t trx_nr,
5125 in RslChannelNr chan_nr, uint8_t new_bts_nr)
5126{
5127 f_vty_ss_action(pt, "handover " & int2str(new_bts_nr), bts_nr, trx_nr, chan_nr);
Harald Welte261af4b2018-02-12 21:20:39 +01005128}
5129
5130/* intra-BSC hand-over between BTS0 and BTS1 */
5131private function f_tc_ho_int(charstring id) runs on MSC_ConnHdlr {
Harald Welteed848512018-05-24 22:27:58 +02005132 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
5133 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte261af4b2018-02-12 21:20:39 +01005134
5135 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
5136 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
5137
Harald Weltea0630032018-03-20 21:09:55 +01005138 f_establish_fully(ass_cmd, exp_compl);
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005139 f_bts_0_cfg(BSCVTY, {"neighbor bts 1"});
Harald Welte261af4b2018-02-12 21:20:39 +01005140
5141 var HandoverState hs := {
5142 rr_ho_cmpl_seen := false,
5143 handover_done := false,
Neels Hofmeyrc741fcb2021-10-02 14:52:28 +02005144 old_chan_nr := -,
5145 expect_target_tsc := BTS_TSC[1]
Harald Welte261af4b2018-02-12 21:20:39 +01005146 };
Neels Hofmeyrc2cf4542021-10-02 12:26:38 +02005147 /* issue hand-over command on VTY, from BTS 0 to BTS 1 */
Vadim Yanitskiy00070722020-09-02 17:27:57 +07005148 f_vty_handover(BSCVTY, 0, 0, g_chan_nr, 1);
Harald Welte261af4b2018-02-12 21:20:39 +01005149 /* temporarily suspend DChan processing on BTS1 to avoid race with RSLEM_register */
5150 f_rslem_suspend(RSL1_PROC);
Philipp Maier3e2af5d2018-07-11 17:01:05 +02005151
5152 /* From the MGW perspective, a handover is is characterized by
5153 * performing one MDCX operation with the MGW. So we expect to see
5154 * one more MDCX during handover. */
5155 g_media.mgcp_conn[0].mdcx_seen_exp := g_media.mgcp_conn[0].crcx_seen_exp + 1;
5156
Harald Welte261af4b2018-02-12 21:20:39 +01005157 alt {
5158 [] as_handover(hs);
Harald Welte261af4b2018-02-12 21:20:39 +01005159 }
Philipp Maier3e2af5d2018-07-11 17:01:05 +02005160
Philipp Maier4dae0652018-11-12 12:03:26 +01005161 /* Since this is an internal handover we expect the BSC to inform the
5162 * MSC about the event */
5163 BSSAP.receive(tr_BSSMAP_HandoverPerformed);
5164
Philipp Maier3e2af5d2018-07-11 17:01:05 +02005165 /* Check the amount of MGCP transactions is still consistant with the
5166 * test expectation */
5167 f_check_mgcp_expectations()
Neels Hofmeyraf88d9d2021-06-21 02:14:27 +02005168
Neels Hofmeyrc2cf4542021-10-02 12:26:38 +02005169 var RSL_Message chan_act := f_rslem_get_last_act(RSL1_PROC, 0, g_chan_nr);
5170
Neels Hofmeyraf88d9d2021-06-21 02:14:27 +02005171 /* Ensure the Channel Activation for the new channel contained the right encryption params. as_handover() set
5172 * 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 +02005173 f_verify_encr_info(chan_act);
5174
5175 f_chan_act_verify_tsc(chan_act, BTS_TSC[1]);
Neels Hofmeyraf88d9d2021-06-21 02:14:27 +02005176
Neels Hofmeyr861a4c12018-11-07 01:23:17 +01005177 f_sleep(0.5);
Harald Welte261af4b2018-02-12 21:20:39 +01005178}
5179
5180testcase TC_ho_int() runs on test_CT {
Neels Hofmeyr5f7a9df2021-06-21 01:30:43 +02005181 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte261af4b2018-02-12 21:20:39 +01005182 var MSC_ConnHdlr vc_conn;
5183 f_init(2, true);
5184 f_sleep(1.0);
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005185
Neels Hofmeyrc2cf4542021-10-02 12:26:38 +02005186 pars.expect_tsc := BTS_TSC[0];
5187
Neels Hofmeyrac432fa2021-11-02 16:45:56 +01005188 f_ctrs_bsc_and_bts_handover_init();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005189
Neels Hofmeyr5f7a9df2021-06-21 01:30:43 +02005190 vc_conn := f_start_handler(refers(f_tc_ho_int), pars);
Harald Welte261af4b2018-02-12 21:20:39 +01005191 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005192
5193 /* from f_establish_fully() */
5194 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5195 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5196 /* from handover */
5197 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5198 f_ctrs_bsc_and_bts_add(0, "handover:completed");
5199 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
5200 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:completed");
Neels Hofmeyrac432fa2021-11-02 16:45:56 +01005201 f_ctrs_bts_add(1, "incoming_intra_bsc_ho:attempted");
5202 f_ctrs_bts_add(1, "incoming_intra_bsc_ho:completed");
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005203 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005204 f_shutdown_helper();
Harald Welte261af4b2018-02-12 21:20:39 +01005205}
Harald Weltee9e02e42018-01-31 23:36:25 +01005206
Oliver Smith7eabd312021-07-12 14:18:56 +02005207function 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 +02005208 var MSC_ConnHdlr vc_conn;
5209 var TestHdlrParams pars := f_gen_test_hdlr_pars();
5210 pars.encr := valueof(t_EncrParams(encr_alg, f_rnd_octstring(8), f_rnd_octstring(16)));
5211
5212 f_init(2, true);
Oliver Smith7eabd312021-07-12 14:18:56 +02005213 f_vty_encryption_a5(enc_a5);
Neels Hofmeyraf88d9d2021-06-21 02:14:27 +02005214 f_sleep(1.0);
5215
Neels Hofmeyrac432fa2021-11-02 16:45:56 +01005216 f_ctrs_bsc_and_bts_handover_init();
Neels Hofmeyraf88d9d2021-06-21 02:14:27 +02005217
5218 vc_conn := f_start_handler(refers(f_tc_ho_int), pars);
5219 vc_conn.done;
5220
5221 /* from f_establish_fully() */
5222 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5223 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5224 /* from handover */
5225 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5226 f_ctrs_bsc_and_bts_add(0, "handover:completed");
5227 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
5228 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:completed");
Neels Hofmeyrac432fa2021-11-02 16:45:56 +01005229 f_ctrs_bts_add(1, "incoming_intra_bsc_ho:attempted");
5230 f_ctrs_bts_add(1, "incoming_intra_bsc_ho:completed");
Neels Hofmeyraf88d9d2021-06-21 02:14:27 +02005231 f_ctrs_bsc_and_bts_verify();
Oliver Smith7eabd312021-07-12 14:18:56 +02005232 f_vty_encryption_a5_reset();
Neels Hofmeyraf88d9d2021-06-21 02:14:27 +02005233 f_shutdown_helper();
5234}
5235
5236testcase TC_ho_int_a5_0() runs on test_CT {
5237 f_tc_ho_int_a5('01'O);
5238}
5239
5240testcase TC_ho_int_a5_1() runs on test_CT {
5241 f_tc_ho_int_a5('02'O);
5242}
5243
5244testcase TC_ho_int_a5_3() runs on test_CT {
5245 f_tc_ho_int_a5('08'O);
5246}
5247
5248testcase TC_ho_int_a5_4() runs on test_CT {
Oliver Smith7eabd312021-07-12 14:18:56 +02005249 f_tc_ho_int_a5('10'O, "0 1 3 4");
Neels Hofmeyraf88d9d2021-06-21 02:14:27 +02005250}
5251
Neels Hofmeyr5f144212020-11-03 15:41:58 +00005252/* intra-BSC hand-over with CONNection FAILure and cause Radio Link Failure: check RR release cause */
5253private function f_tc_ho_int_radio_link_failure(charstring id) runs on MSC_ConnHdlr {
5254 g_pars := f_gen_test_hdlr_pars();
5255 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
5256 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Neels Hofmeyr5f144212020-11-03 15:41:58 +00005257
5258 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
5259 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
5260
5261 f_establish_fully(ass_cmd, exp_compl);
5262 f_bts_0_cfg(BSCVTY, {"neighbor bts 1"});
5263
5264 var HandoverState hs := {
5265 rr_ho_cmpl_seen := false,
5266 handover_done := false,
Neels Hofmeyrc741fcb2021-10-02 14:52:28 +02005267 old_chan_nr := -,
5268 expect_target_tsc := BTS_TSC[1]
Neels Hofmeyr5f144212020-11-03 15:41:58 +00005269 };
5270 /* issue hand-over command on VTY */
5271 f_vty_handover(BSCVTY, 0, 0, g_chan_nr, 1);
5272 /* temporarily suspend DChan processing on BTS1 to avoid race with RSLEM_register */
5273 f_rslem_suspend(RSL1_PROC);
5274
5275 /* From the MGW perspective, a handover is is characterized by
5276 * performing one MDCX operation with the MGW. So we expect to see
5277 * one more MDCX during handover. */
5278 g_media.mgcp_conn[0].mdcx_seen_exp := g_media.mgcp_conn[0].crcx_seen_exp + 1;
5279
5280 var RSL_Message rsl;
5281 var PDU_ML3_NW_MS l3;
5282 var RslChannelNr new_chan_nr;
5283 var GsmArfcn arfcn;
5284 RSL.receive(tr_RSL_DATA_REQ(g_chan_nr)) -> value rsl {
5285 l3 := dec_PDU_ML3_NW_MS(rsl.ies[2].body.l3_info.payload);
5286 if (not ischosen(l3.msgs.rrm.handoverCommand)) {
5287 setverdict(fail, "Expected handoverCommand");
5288 mtc.stop;
5289 }
5290 }
5291 f_ChDesc2RslChanNr(l3.msgs.rrm.handoverCommand.channelDescription2,
5292 new_chan_nr, arfcn);
5293
5294 f_rslem_register(0, new_chan_nr, RSL1_PROC);
5295
5296 /* resume processing of RSL DChan messages, which was temporarily suspended
5297 * before performing a hand-over */
5298 f_rslem_resume(RSL1_PROC);
5299 RSL1.receive(tr_RSL_IPA_CRCX(new_chan_nr));
5300
5301 f_sleep(1.0);
5302
5303 /* Handover fails because no HANDO DET appears on the new lchan,
5304 * and the old lchan reports a Radio Link Failure. */
5305 RSL.send(ts_RSL_CONN_FAIL_IND(g_chan_nr, RSL_ERR_RADIO_LINK_FAIL));
5306
5307 var PDU_BSSAP rx_clear_request;
5308 BSSAP.receive(tr_BSSMAP_ClearRequest) -> value rx_clear_request;
5309 var BssmapCause cause := bit2int(rx_clear_request.pdu.bssmap.clearRequest.cause.causeValue);
5310 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
5311
5312 var RR_Cause rr_cause := GSM48_RR_CAUSE_ABNORMAL_UNSPEC;
5313
5314 var MgcpCommand mgcp;
5315 interleave {
5316 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_RELEASE(int2oct(enum2int(rr_cause), 1)))) {}
5317 [] RSL.receive(tr_RSL_DEACT_SACCH(g_chan_nr)) {}
Neels Hofmeyr3c5127e2021-07-22 19:18:40 +02005318 [] RSL.receive(tr_RSL_RF_CHAN_REL(g_chan_nr)) {
Neels Hofmeyr5f144212020-11-03 15:41:58 +00005319 RSL.send(ts_RSL_RF_CHAN_REL_ACK(g_chan_nr));
Neels Hofmeyre680b012021-07-22 19:19:09 +02005320 f_rslem_unregister(0, g_chan_nr);
Neels Hofmeyr5f144212020-11-03 15:41:58 +00005321 }
5322 [] RSL1.receive(tr_RSL_DEACT_SACCH(new_chan_nr)) {}
Neels Hofmeyr3c5127e2021-07-22 19:18:40 +02005323 [] RSL1.receive(tr_RSL_RF_CHAN_REL(new_chan_nr)) {
Neels Hofmeyr5f144212020-11-03 15:41:58 +00005324 RSL1.send(ts_RSL_RF_CHAN_REL_ACK(new_chan_nr));
Neels Hofmeyre680b012021-07-22 19:19:09 +02005325 f_rslem_unregister(0, g_chan_nr, PT := RSL1_PROC);
Neels Hofmeyr5f144212020-11-03 15:41:58 +00005326 }
5327 [] BSSAP.receive(tr_BSSMAP_ClearComplete) {}
5328 }
5329
5330 f_sleep(0.5);
5331 setverdict(pass);
5332}
5333testcase TC_ho_int_radio_link_failure() runs on test_CT {
5334 var MSC_ConnHdlr vc_conn;
5335 f_init(2, true);
5336 f_sleep(1.0);
5337
Neels Hofmeyrac432fa2021-11-02 16:45:56 +01005338 f_ctrs_bsc_and_bts_handover_init();
Neels Hofmeyr5f144212020-11-03 15:41:58 +00005339
5340 vc_conn := f_start_handler(refers(f_tc_ho_int_radio_link_failure));
5341 vc_conn.done;
5342
5343 /* from f_establish_fully() */
5344 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5345 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5346 /* from handover */
5347 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5348 f_ctrs_bsc_and_bts_add(0, "handover:stopped");
5349 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
5350 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:stopped");
Neels Hofmeyrac432fa2021-11-02 16:45:56 +01005351 f_ctrs_bts_add(1, "incoming_intra_bsc_ho:attempted");
5352 f_ctrs_bts_add(1, "incoming_intra_bsc_ho:stopped");
Neels Hofmeyr5f144212020-11-03 15:41:58 +00005353 f_ctrs_bsc_and_bts_verify();
5354 f_shutdown_helper();
5355}
5356
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02005357/* Expecting MGCP to DLCX the endpoint's two connections: towards BTS and towards MSC */
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02005358private function f_expect_dlcx_conns() runs on MSC_ConnHdlr {
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02005359 var MgcpCommand mgcp;
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +02005360 var template MgcpResponse mgcp_resp;
5361 var MGCP_RecvFrom mrf;
5362 var template MgcpMessage msg_resp;
5363 var template MgcpMessage msg_dlcx := {
5364 command := tr_DLCX()
5365 }
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02005366
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +02005367 if (g_pars.aoip) {
5368 MGCP.receive(tr_DLCX()) -> value mgcp {
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02005369 log("Got first DLCX: ", mgcp);
5370 MGCP.send(ts_DLCX_ACK2(mgcp.line.trans_id));
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +02005371 };
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02005372
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02005373 MGCP.receive(tr_DLCX()) -> value mgcp {
5374 log("Got second DLCX: ", mgcp);
5375 MGCP.send(ts_DLCX_ACK2(mgcp.line.trans_id));
5376 };
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +02005377 } else {
5378 /* For SCCPLite, BSC doesn't handle the MSC-side */
5379 MGCP_MULTI.receive(tr_MGCP_RecvFrom_any(msg_dlcx)) -> value mrf {
5380 log("Got first DLCX: ", mrf.msg.command);
5381 msg_resp := {
5382 response := ts_DLCX_ACK2(mrf.msg.command.line.trans_id)
5383 }
5384 MGCP_MULTI.send(t_MGCP_SendToMrf(mrf, msg_resp));
5385 };
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02005386 }
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02005387}
5388
Pau Espin Pedrol35801c32021-04-19 13:03:20 +02005389private 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 +01005390
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005391 f_bts_0_cfg(BSCVTY, {"neighbor lac 99 arfcn 123 bsic any"});
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005392 f_vty_transceive(BSCVTY, "handover any to arfcn 123 bsic any");
5393
Pau Espin Pedrol35801c32021-04-19 13:03:20 +02005394 BSSAP.receive(tr_BSSMAP_HandoverRequired(exp_oldToNewBSSIEs));
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005395
5396 f_sleep(0.5);
5397 /* The MSC negotiates Handover Request and Handover Request Ack with
5398 * the other BSS and comes back with a BSSMAP Handover Command
5399 * containing an RR Handover Command coming from the target BSS... */
5400
5401 var PDU_ML3_NW_MS rr_ho_cmd := valueof(ts_RR_HandoverCommand);
5402 log("Remote cell's RR Handover Command passed through as L3 Info: ", rr_ho_cmd);
5403 var octetstring rr_ho_cmd_enc := enc_PDU_ML3_NW_MS(rr_ho_cmd);
5404 log("Remote cell's RR Handover Command passed through as L3 Info, encoded: ", rr_ho_cmd_enc);
5405 BSSAP.send(ts_BSSMAP_HandoverCommand(rr_ho_cmd_enc));
5406
5407 /* expect the Handover Command to go out on RR */
5408 var RSL_Message rsl_ho_cmd
5409 RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, ?)) -> value rsl_ho_cmd;
5410 log("RSL Data Req went out to first BTS: ", rsl_ho_cmd);
5411 var RSL_IE_Body rsl_ho_cmd_l3;
5412 if (not f_rsl_find_ie(rsl_ho_cmd, RSL_IE_L3_INFO, rsl_ho_cmd_l3)) {
5413 log("RSL message contains no L3 Info IE, expected RR Handover Command");
5414 setverdict(fail);
5415 } else {
5416 log("Found L3 Info: ", rsl_ho_cmd_l3);
5417 if (rsl_ho_cmd_l3.l3_info.payload != rr_ho_cmd_enc) {
5418 log("FAIL: the BSC sent out a different L3 Info, not matching the RR Handover Command the other BSS forwarded.");
5419 setverdict(fail);
5420 } else {
5421 log("Success: the BSC sent out the same RR Handover Command the other BSS forwarded.");
5422 setverdict(pass);
5423 }
5424 }
5425
5426 /* When the other BSS has reported a completed handover, this side is
5427 * torn down. */
5428
5429 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_HANDOVER_SUCCESSFUL;
5430 var BssmapCause cause := enum2int(cause_val);
5431 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
5432
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02005433 f_expect_dlcx_conns();
Pau Espin Pedrol06199952021-06-15 11:30:00 +02005434
5435 interleave {
5436 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_RELEASE));
5437 [] RSL.receive(tr_RSL_DEACT_SACCH(g_chan_nr));
5438 [] RSL.receive(tr_RSL_RF_CHAN_REL(g_chan_nr));
Neels Hofmeyr8fcd8772021-07-22 16:12:57 +02005439 [] BSSAP.receive(tr_BSSMAP_ClearComplete);
Pau Espin Pedrol06199952021-06-15 11:30:00 +02005440 }
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005441 setverdict(pass);
Pau Espin Pedrol35801c32021-04-19 13:03:20 +02005442}
5443
5444private function f_tc_ho_out_of_this_bsc(charstring id) runs on MSC_ConnHdlr {
5445 g_pars := f_gen_test_hdlr_pars();
5446 var PDU_BSSAP ass_req := f_gen_ass_req();
5447 ass_req.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
5448 ass_req.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
5449 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
5450 f_establish_fully(ass_req, exp_compl);
5451
5452 f_ho_out_of_this_bsc();
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005453}
5454testcase TC_ho_out_of_this_bsc() runs on test_CT {
5455 var MSC_ConnHdlr vc_conn;
5456
5457 f_init(1, true);
5458 f_sleep(1.0);
5459
Neels Hofmeyrac432fa2021-11-02 16:45:56 +01005460 f_ctrs_bsc_and_bts_handover_init();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005461
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005462 vc_conn := f_start_handler(refers(f_tc_ho_out_of_this_bsc));
5463 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005464
5465 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5466 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5467 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5468 f_ctrs_bsc_and_bts_add(0, "handover:completed");
5469 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
5470 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:completed");
5471 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005472 f_shutdown_helper();
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005473}
5474
Neels Hofmeyr0aa719b2020-10-12 18:43:09 +00005475private function f_mo_l3_transceive(RSL_DCHAN_PT rsl := RSL,
5476 template (value) RslLinkId link_id := ts_RslLinkID_DCCH(0),
Vadim Yanitskiy2ef6a2f2020-10-08 23:17:32 +07005477 template (present) OCT1 dlci := ?,
Vadim Yanitskiyb93aa432020-10-01 14:23:11 +07005478 octetstring l3 := '0123456789'O)
5479runs on MSC_ConnHdlr {
Neels Hofmeyr43654812020-09-25 01:35:35 +02005480 /* The old lchan and conn should still be active. See that arbitrary L3
5481 * is still going through. */
Neels Hofmeyr0aa719b2020-10-12 18:43:09 +00005482 rsl.send(ts_RSL_DATA_IND(g_chan_nr, link_id, l3));
Neels Hofmeyr43654812020-09-25 01:35:35 +02005483 var template PDU_BSSAP exp_data := {
5484 discriminator := '1'B,
5485 spare := '0000000'B,
Vadim Yanitskiyb93aa432020-10-01 14:23:11 +07005486 dlci := dlci,
5487 lengthIndicator := lengthof(l3),
Neels Hofmeyr43654812020-09-25 01:35:35 +02005488 pdu := {
5489 dtap := l3
5490 }
5491 };
5492 BSSAP.receive(exp_data);
5493 setverdict(pass);
5494}
5495
Neels Hofmeyr0aa719b2020-10-12 18:43:09 +00005496private function f_mt_l3_transceive(RSL_DCHAN_PT rsl := RSL,
5497 template (present) RslLinkId link_id := tr_RslLinkID_DCCH(0),
Vadim Yanitskiy0033a3b2020-10-01 22:21:16 +07005498 template (value) OCT1 dlci := '00'O,
5499 octetstring l3 := '0123456789'O)
5500runs on MSC_ConnHdlr {
5501 BSSAP.send(PDU_BSSAP:{
5502 discriminator := '1'B,
5503 spare := '0000000'B,
5504 dlci := dlci,
5505 lengthIndicator := lengthof(l3),
5506 pdu := {
5507 dtap := l3
5508 }
5509 });
Neels Hofmeyr0aa719b2020-10-12 18:43:09 +00005510 rsl.receive(tr_RSL_DATA_REQ(g_chan_nr, link_id, l3));
Vadim Yanitskiy0033a3b2020-10-01 22:21:16 +07005511 setverdict(pass);
5512}
5513
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005514/* BSC asks for inter-BSC HO, but the MSC decides that it won't happen and
5515 * simply never sends a BSSMAP Handover Command. */
5516private function f_tc_ho_out_fail_no_msc_response(charstring id) runs on MSC_ConnHdlr {
Daniel Willmann3b59eb52018-10-29 15:40:55 +01005517 g_pars := f_gen_test_hdlr_pars();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005518
5519 var PDU_BSSAP ass_req := f_gen_ass_req();
5520 ass_req.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
5521 ass_req.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
5522 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
5523 f_establish_fully(ass_req, exp_compl);
5524
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005525 f_bts_0_cfg(BSCVTY, {"neighbor lac 99 arfcn 123 bsic any"});
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005526 f_vty_transceive(BSCVTY, "handover any to arfcn 123 bsic any");
5527
5528 BSSAP.receive(tr_BSSMAP_HandoverRequired);
5529
5530 /* osmo-bsc should time out 10 seconds after the handover started.
5531 * Let's give it a bit extra. */
5532 f_sleep(15.0);
5533
Vadim Yanitskiy74ae5eb2020-10-01 22:13:29 +07005534 f_mo_l3_transceive();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005535 f_sleep(1.0);
5536}
5537testcase TC_ho_out_fail_no_msc_response() runs on test_CT {
5538 var MSC_ConnHdlr vc_conn;
5539
5540 f_init(1, true);
5541 f_sleep(1.0);
5542
Neels Hofmeyrac432fa2021-11-02 16:45:56 +01005543 f_ctrs_bsc_and_bts_handover_init();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005544
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005545 vc_conn := f_start_handler(refers(f_tc_ho_out_fail_no_msc_response));
5546 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005547
5548 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5549 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5550 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5551 f_ctrs_bsc_and_bts_add(0, "handover:timeout");
5552 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
5553 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:timeout");
5554 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005555 f_shutdown_helper();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005556}
5557
5558/* BSC asks for inter-BSC HO, receives BSSMAP Handover Command, but MS reports
5559 * RR Handover Failure. */
5560private function f_tc_ho_out_fail_rr_ho_failure(charstring id) runs on MSC_ConnHdlr {
Daniel Willmann3b59eb52018-10-29 15:40:55 +01005561 g_pars := f_gen_test_hdlr_pars();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005562
5563 var PDU_BSSAP ass_req := f_gen_ass_req();
5564 ass_req.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
5565 ass_req.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
5566 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
5567 f_establish_fully(ass_req, exp_compl);
5568
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005569 f_bts_0_cfg(BSCVTY, {"neighbor lac 99 arfcn 123 bsic any"});
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005570 f_vty_transceive(BSCVTY, "handover any to arfcn 123 bsic any");
5571
5572 BSSAP.receive(tr_BSSMAP_HandoverRequired);
5573
5574 f_sleep(0.5);
5575 /* The MSC negotiates Handover Request and Handover Request Ack with
5576 * the other BSS and comes back with a BSSMAP Handover Command
5577 * containing an RR Handover Command coming from the target BSS... */
5578
5579 var PDU_ML3_NW_MS rr_ho_cmd := valueof(ts_RR_HandoverCommand);
5580 log("Remote cell's RR Handover Command passed through as L3 Info: ", rr_ho_cmd);
5581 var octetstring rr_ho_cmd_enc := enc_PDU_ML3_NW_MS(rr_ho_cmd);
5582 log("Remote cell's RR Handover Command passed through as L3 Info, encoded: ", rr_ho_cmd_enc);
5583 BSSAP.send(ts_BSSMAP_HandoverCommand(rr_ho_cmd_enc));
5584
5585 /* expect the Handover Command to go out on RR */
5586 var RSL_Message rsl_ho_cmd
5587 RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, ?)) -> value rsl_ho_cmd;
5588 log("RSL Data Req went out to first BTS: ", rsl_ho_cmd);
5589 var RSL_IE_Body rsl_ho_cmd_l3;
5590 if (not f_rsl_find_ie(rsl_ho_cmd, RSL_IE_L3_INFO, rsl_ho_cmd_l3)) {
5591 log("RSL message contains no L3 Info IE, expected RR Handover Command");
5592 setverdict(fail);
5593 } else {
5594 log("Found L3 Info: ", rsl_ho_cmd_l3);
5595 if (rsl_ho_cmd_l3.l3_info.payload != rr_ho_cmd_enc) {
5596 log("FAIL: the BSC sent out a different L3 Info, not matching the RR Handover Command the other BSS forwarded.");
5597 setverdict(fail);
5598 } else {
5599 log("Success: the BSC sent out the same RR Handover Command the other BSS forwarded.");
5600 setverdict(pass);
5601 }
5602 }
5603
5604 f_sleep(0.2);
5605 f_rsl_send_l3(ts_RRM_HandoverFailure('00'O));
5606
5607 /* Should tell the MSC about the failure */
5608 BSSAP.receive(tr_BSSMAP_HandoverFailure);
5609
5610 f_sleep(1.0);
5611
Vadim Yanitskiy74ae5eb2020-10-01 22:13:29 +07005612 f_mo_l3_transceive();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005613 f_sleep(1.0);
5614
5615 setverdict(pass);
5616 f_sleep(1.0);
5617}
5618testcase TC_ho_out_fail_rr_ho_failure() runs on test_CT {
5619 var MSC_ConnHdlr vc_conn;
5620
5621 f_init(1, true);
5622 f_sleep(1.0);
5623
Neels Hofmeyrac432fa2021-11-02 16:45:56 +01005624 f_ctrs_bsc_and_bts_handover_init();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005625
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005626 vc_conn := f_start_handler(refers(f_tc_ho_out_fail_rr_ho_failure));
5627 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005628
5629 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5630 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5631 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5632 f_ctrs_bsc_and_bts_add(0, "handover:failed");
5633 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
5634 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:failed");
5635 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005636 f_shutdown_helper();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005637}
5638
Neels Hofmeyr10f2bfa2019-07-09 19:33:29 +02005639/* BSC asks for inter-BSC-out HO, receives BSSMAP Handover Command, but then no reply is received about HO outcome
5640 * (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 +02005641 * and the lchan is released. */
5642private function f_tc_ho_out_fail_no_result_after_ho_cmd(charstring id) runs on MSC_ConnHdlr {
Daniel Willmann3b59eb52018-10-29 15:40:55 +01005643 g_pars := f_gen_test_hdlr_pars();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005644
5645 var PDU_BSSAP ass_req := f_gen_ass_req();
5646 ass_req.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
5647 ass_req.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
5648 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
5649 f_establish_fully(ass_req, exp_compl);
5650
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005651 f_bts_0_cfg(BSCVTY, {"neighbor lac 99 arfcn 123 bsic any"});
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005652 f_vty_transceive(BSCVTY, "handover any to arfcn 123 bsic any");
5653
5654 BSSAP.receive(tr_BSSMAP_HandoverRequired);
5655
5656 f_sleep(0.5);
5657 /* The MSC negotiates Handover Request and Handover Request Ack with
5658 * the other BSS and comes back with a BSSMAP Handover Command
5659 * containing an RR Handover Command coming from the target BSS... */
5660
5661 var PDU_ML3_NW_MS rr_ho_cmd := valueof(ts_RR_HandoverCommand);
5662 log("Remote cell's RR Handover Command passed through as L3 Info: ", rr_ho_cmd);
5663 var octetstring rr_ho_cmd_enc := enc_PDU_ML3_NW_MS(rr_ho_cmd);
5664 log("Remote cell's RR Handover Command passed through as L3 Info, encoded: ", rr_ho_cmd_enc);
5665 BSSAP.send(ts_BSSMAP_HandoverCommand(rr_ho_cmd_enc));
5666
5667 /* expect the Handover Command to go out on RR */
5668 var RSL_Message rsl_ho_cmd
5669 RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, ?)) -> value rsl_ho_cmd;
5670 log("RSL Data Req went out to first BTS: ", rsl_ho_cmd);
5671 var RSL_IE_Body rsl_ho_cmd_l3;
5672 if (not f_rsl_find_ie(rsl_ho_cmd, RSL_IE_L3_INFO, rsl_ho_cmd_l3)) {
5673 log("RSL message contains no L3 Info IE, expected RR Handover Command");
5674 setverdict(fail);
5675 } else {
5676 log("Found L3 Info: ", rsl_ho_cmd_l3);
5677 if (rsl_ho_cmd_l3.l3_info.payload != rr_ho_cmd_enc) {
5678 log("FAIL: the BSC sent out a different L3 Info, not matching the RR Handover Command the other BSS forwarded.");
5679 setverdict(fail);
5680 } else {
5681 log("Success: the BSC sent out the same RR Handover Command the other BSS forwarded.");
5682 setverdict(pass);
5683 }
5684 }
5685
Neels Hofmeyr10f2bfa2019-07-09 19:33:29 +02005686 /* We get neither success nor failure report from the remote BSS. Eventually T8 times out and we run into 3GPP
5687 * TS 48.008 3.1.5.3.3 "Abnormal Conditions": Clear Request should go to the MSC, and RR should be released
5688 * after Clear Command */
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005689
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02005690 var PDU_BSSAP rx_clear_request;
Neels Hofmeyre1797aa2019-07-09 19:34:04 +02005691 BSSAP.receive(tr_BSSMAP_ClearRequest) -> value rx_clear_request;
5692 log("Got BSSMAP Clear Request");
5693 /* Instruct BSC to clear channel */
5694 var BssmapCause cause := bit2int(rx_clear_request.pdu.bssmap.clearRequest.cause.causeValue);
5695 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
5696
5697 var MgcpCommand mgcp;
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005698 interleave {
Neels Hofmeyr861a4c12018-11-07 01:23:17 +01005699 [] RSL.receive(tr_RSL_DEACT_SACCH(g_chan_nr)) {
5700 log("Got Deact SACCH");
5701 }
Harald Welte924b6ea2019-02-04 01:05:34 +01005702 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_RELEASE)) {
Neels Hofmeyr211169d2018-11-07 00:37:29 +01005703 log("Got RR Release");
5704 }
Neels Hofmeyr3c5127e2021-07-22 19:18:40 +02005705 [] RSL.receive(tr_RSL_RF_CHAN_REL(g_chan_nr)) {
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005706 log("Got RF Chan Rel");
5707 RSL.send(ts_RSL_RF_CHAN_REL_ACK(g_chan_nr));
Neels Hofmeyre680b012021-07-22 19:19:09 +02005708 f_rslem_unregister(0, g_chan_nr);
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005709 }
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005710 }
5711
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02005712 f_expect_dlcx_conns();
Neels Hofmeyr8fcd8772021-07-22 16:12:57 +02005713 BSSAP.receive(tr_BSSMAP_ClearComplete);
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02005714
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005715 setverdict(pass);
5716 f_sleep(1.0);
5717}
Neels Hofmeyrd8a602c2019-07-09 19:46:01 +02005718testcase TC_ho_out_fail_no_result_after_ho_cmd() runs on test_CT {
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005719 var MSC_ConnHdlr vc_conn;
5720
5721 f_init(1, true);
5722 f_sleep(1.0);
5723
Neels Hofmeyrac432fa2021-11-02 16:45:56 +01005724 f_ctrs_bsc_and_bts_handover_init();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005725
Neels Hofmeyrd8a602c2019-07-09 19:46:01 +02005726 vc_conn := f_start_handler(refers(f_tc_ho_out_fail_no_result_after_ho_cmd));
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005727 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005728
5729 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5730 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5731 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5732 f_ctrs_bsc_and_bts_add(0, "handover:timeout");
5733 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
5734 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:timeout");
5735 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005736 f_shutdown_helper();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005737}
5738
Pau Espin Pedrol35801c32021-04-19 13:03:20 +02005739private 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 +01005740 /* Hack: the proper way would be to wait for the BSSMAP Handover Request ACK and extract the
5741 * actual assigned chan_nr from its L3 (RR Handover Command) message. But osmo-bsc starts acting
5742 * on the lchan even before we get a chance to evaluate the BSSMAP Handover Request ACK. So we
5743 * need to assume that osmo-bsc will activate TS 1 and already set up this lchan's RSL emulation
5744 * before we get started. */
5745 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
5746 f_rslem_register(0, new_chan_nr);
5747 g_chan_nr := new_chan_nr;
Neels Hofmeyr34174bd2021-10-02 14:52:57 +02005748 var uint3_t expect_target_tsc := BTS_TSC[0];
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005749 f_sleep(1.0);
5750
5751 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
5752 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
5753 activate(as_Media());
5754
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005755 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Pau Espin Pedrolc08d5522021-04-16 15:40:38 +02005756 f_gen_handover_req(aoip_tla := g_pars.host_aoip_tla,
Neels Hofmeyr8ebf19c2021-06-21 05:24:01 +02005757 oldToNewBSSIEs := oldToNewBSSIEs,
5758 enc := g_pars.encr)));
Harald Welte6811d102019-04-14 22:23:14 +02005759 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005760
5761 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
5762
5763 var PDU_BSSAP rx_bssap;
5764 var octetstring ho_command_str;
5765
5766 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
Pau Espin Pedrol76ba5412019-06-10 11:00:33 +02005767
Neels Hofmeyr34174bd2021-10-02 14:52:57 +02005768 /* we're sure that the channel activation is done now, verify the parameters in it */
5769 var RSL_Message chan_act := f_rslem_get_last_act(RSL_PROC, 0, g_chan_nr);
5770 f_verify_encr_info(chan_act);
5771 f_chan_act_verify_tsc(chan_act, expect_target_tsc);
Neels Hofmeyr8ebf19c2021-06-21 05:24:01 +02005772
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005773 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
5774 log("Received L3 Info in HO Request Ack: ", ho_command_str);
5775 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
5776 log("L3 Info in HO Request Ack is ", ho_command);
5777
5778 var GsmArfcn arfcn;
5779 var RslChannelNr actual_new_chan_nr;
5780 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
5781 actual_new_chan_nr, arfcn);
5782
5783 if (actual_new_chan_nr != new_chan_nr) {
5784 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
5785 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
5786 setverdict(fail);
5787 return;
5788 }
5789 log("Handover Command chan_nr is", actual_new_chan_nr);
5790
Neels Hofmeyr34174bd2021-10-02 14:52:57 +02005791 var uint3_t got_tsc := rr_chan_desc_tsc(ho_command.msgs.rrm.handoverCommand.channelDescription2);
5792 if (not match(got_tsc, expect_target_tsc)) {
5793 setverdict(fail, "RR Handover Command: unexpected TSC in Channel Description: expected ",
5794 expect_target_tsc, " got ", got_tsc);
5795 mtc.stop;
5796 } else {
5797 log("handoverCommand: verified TSC = ", got_tsc);
5798 }
5799
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005800 /* Now the MSC forwards the RR Handover Command to the other BSC, which
5801 * tells the MS to handover to the new lchan. Here comes the new MS on
5802 * the new lchan with a Handover RACH: */
5803
5804 /* send handover detect */
5805
5806 RSL.send(ts_RSL_HANDO_DET(new_chan_nr));
5807
5808 BSSAP.receive(tr_BSSMAP_HandoverDetect);
5809
5810 /* send handover complete over the new channel */
5811
5812 var PDU_ML3_MS_NW l3_tx := valueof(ts_RRM_HandoverComplete('00'O));
5813 RSL.send(ts_RSL_EST_IND(new_chan_nr, valueof(ts_RslLinkID_DCCH(0)),
5814 enc_PDU_ML3_MS_NW(l3_tx)));
5815
5816 BSSAP.receive(tr_BSSMAP_HandoverComplete);
Pau Espin Pedrol35801c32021-04-19 13:03:20 +02005817 setverdict(pass);
5818}
Pau Espin Pedrolc08d5522021-04-16 15:40:38 +02005819
Pau Espin Pedrol35801c32021-04-19 13:03:20 +02005820private function f_tc_ho_into_this_bsc(charstring id) runs on MSC_ConnHdlr {
Pau Espin Pedrol9ae36d52021-06-15 17:29:43 +02005821 var template PDU_ML3_NW_MS exp_rr_rel_tmpl;
Pau Espin Pedrol35801c32021-04-19 13:03:20 +02005822 var template (omit) BSSMAP_oldToNewBSSIEs oldToNewBSSIEs := omit;
5823 if (not istemplatekind(g_pars.last_used_eutran_plmn, "omit")) {
5824 oldToNewBSSIEs := f_ts_BSSMAP_oldToNewBSSIEs(ts_BSSMAP_LastUsedEUTRANPLMNId(g_pars.last_used_eutran_plmn));
Pau Espin Pedrol9ae36d52021-06-15 17:29:43 +02005825 }
5826 if (g_pars.exp_fast_return) {
Pau Espin Pedrol35801c32021-04-19 13:03:20 +02005827 exp_rr_rel_tmpl := tr_RRM_RR_RELEASE_CellSelectInd;
Pau Espin Pedrol9ae36d52021-06-15 17:29:43 +02005828 } else {
5829 exp_rr_rel_tmpl := tr_RRM_RR_RELEASE;
Pau Espin Pedrol35801c32021-04-19 13:03:20 +02005830 }
5831 f_ho_into_this_bsc(id, oldToNewBSSIEs);
Neels Hofmeyr85bcd272021-07-22 19:14:48 +02005832 f_perform_clear(exp_rr_rel_tmpl := exp_rr_rel_tmpl);
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005833 setverdict(pass);
5834}
Pau Espin Pedrol07866632020-09-03 19:10:55 +02005835function f_tc_ho_into_this_bsc_main(TestHdlrParams pars) runs on test_CT {
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005836 var MSC_ConnHdlr vc_conn;
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005837
5838 f_init(1, true);
5839 f_sleep(1.0);
5840
Neels Hofmeyrac432fa2021-11-02 16:45:56 +01005841 f_ctrs_bsc_and_bts_handover_init();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005842
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005843 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
5844 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005845
5846 vc_conn := f_start_handler(refers(f_tc_ho_into_this_bsc), pars);
5847 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005848
5849 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5850 f_ctrs_bsc_and_bts_add(0, "handover:completed");
5851 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:attempted");
5852 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:completed");
5853 f_ctrs_bsc_and_bts_verify();
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005854}
5855
Pau Espin Pedrol07866632020-09-03 19:10:55 +02005856testcase TC_ho_into_this_bsc() runs on test_CT {
5857 var TestHdlrParams pars := f_gen_test_hdlr_pars();
5858 f_tc_ho_into_this_bsc_main(pars);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005859 f_shutdown_helper();
Pau Espin Pedrol07866632020-09-03 19:10:55 +02005860}
5861
Neels Hofmeyr8ebf19c2021-06-21 05:24:01 +02005862function f_tc_ho_into_this_bsc_a5(OCT1 encr_alg) runs on test_CT {
5863 var TestHdlrParams pars := f_gen_test_hdlr_pars();
5864 pars.encr := valueof(t_EncrParams(encr_alg, f_rnd_octstring(8), f_rnd_octstring(16)));
5865 f_tc_ho_into_this_bsc_main(pars);
5866 f_shutdown_helper();
5867}
5868
5869testcase TC_ho_into_this_bsc_a5_0() runs on test_CT {
5870 f_tc_ho_into_this_bsc_a5('01'O);
5871}
5872
5873testcase TC_ho_into_this_bsc_a5_1() runs on test_CT {
5874 f_tc_ho_into_this_bsc_a5('02'O);
5875}
5876
5877testcase TC_ho_into_this_bsc_a5_3() runs on test_CT {
5878 f_tc_ho_into_this_bsc_a5('08'O);
5879}
5880
5881testcase TC_ho_into_this_bsc_a5_4() runs on test_CT {
5882 f_tc_ho_into_this_bsc_a5('10'O);
5883}
5884
Pau Espin Pedrol07866632020-09-03 19:10:55 +02005885testcase TC_ho_into_this_bsc_tla_v6() runs on test_CT {
5886 var TestHdlrParams pars := f_gen_test_hdlr_pars();
5887 pars.host_aoip_tla := "::6";
5888 f_tc_ho_into_this_bsc_main(pars);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005889 f_shutdown_helper();
Pau Espin Pedrol07866632020-09-03 19:10:55 +02005890}
5891
Pau Espin Pedrolc08d5522021-04-16 15:40:38 +02005892/* Similar to TC_ho_into_this_bsc, but when in SRVCC, HO Req contains "Old BSS
Pau Espin Pedrol35801c32021-04-19 13:03:20 +02005893 to New BSS Information" IE with "Last Used E-UTRAN PLMN Id", which, when the
Pau Espin Pedrolc08d5522021-04-16 15:40:38 +02005894 channel is later released (RR CHannel Release), should trigger inclusion of
5895 IE "Cell Selection Indicator after Release of all TCH and SDCCH" with E-UTRAN
5896 neighbors. */
5897testcase TC_srvcc_eutran_to_geran() runs on test_CT {
5898 var TestHdlrParams pars := f_gen_test_hdlr_pars();
5899 pars.last_used_eutran_plmn := '323454'O;
Pau Espin Pedrol9ae36d52021-06-15 17:29:43 +02005900 pars.exp_fast_return := true;
Pau Espin Pedrolc08d5522021-04-16 15:40:38 +02005901 f_tc_ho_into_this_bsc_main(pars);
Pau Espin Pedrol211a7142021-06-15 16:43:03 +02005902
5903 f_ctrs_bsc_and_bts_add(0, "srvcc:attempted");
5904 f_ctrs_bsc_and_bts_add(0, "srvcc:completed");
5905 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrolc08d5522021-04-16 15:40:38 +02005906 f_shutdown_helper();
5907}
5908
Pau Espin Pedrol9ae36d52021-06-15 17:29:43 +02005909/* Same as TC_srvcc_eutran_to_geran, but test explicitly forbiding fast return
5910 on the BTS. As a result, RR Release shouldn't contain the EUTRAN neighbor
5911 list when the channel is released. */
5912testcase TC_srvcc_eutran_to_geran_forbid_fast_return() runs on test_CT {
5913 f_init_vty();
5914 f_vty_allow_srvcc_fast_return(true, 0)
5915
5916 var TestHdlrParams pars := f_gen_test_hdlr_pars();
5917 pars.last_used_eutran_plmn := '323454'O;
5918 pars.exp_fast_return := false;
5919 f_tc_ho_into_this_bsc_main(pars);
5920 f_vty_allow_srvcc_fast_return(false, 0);
5921 f_shutdown_helper();
5922}
5923
Pau Espin Pedrol35801c32021-04-19 13:03:20 +02005924private function f_tc_srvcc_eutran_to_geran_ho_out(charstring id) runs on MSC_ConnHdlr {
5925 var template (omit) BSSMAP_oldToNewBSSIEs oldToNewBSSIEs;
5926 oldToNewBSSIEs := f_ts_BSSMAP_oldToNewBSSIEs(ts_BSSMAP_LastUsedEUTRANPLMNId(g_pars.last_used_eutran_plmn));
5927 f_ho_into_this_bsc(id, oldToNewBSSIEs);
5928 f_ho_out_of_this_bsc(oldToNewBSSIEs);
5929 setverdict(pass);
5930}
Pau Espin Pedrol9ae36d52021-06-15 17:29:43 +02005931
5932private function f_tc_srvcc_eutran_to_geran_ho_out_main(boolean disable_fast_return)
5933 runs on test_CT {
Pau Espin Pedrol35801c32021-04-19 13:03:20 +02005934 var MSC_ConnHdlr vc_conn;
5935 var TestHdlrParams pars := f_gen_test_hdlr_pars();
5936
5937 f_init(1, true);
Pau Espin Pedrol9ae36d52021-06-15 17:29:43 +02005938 if (disable_fast_return) {
5939 f_vty_allow_srvcc_fast_return(true, 0);
5940 }
Pau Espin Pedrol35801c32021-04-19 13:03:20 +02005941 f_sleep(1.0);
5942
Neels Hofmeyrac432fa2021-11-02 16:45:56 +01005943 f_ctrs_bsc_and_bts_handover_init();
Pau Espin Pedrol35801c32021-04-19 13:03:20 +02005944
5945 pars.last_used_eutran_plmn := '323454'O;
5946 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
5947 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
5948
5949 vc_conn := f_start_handler(refers(f_tc_srvcc_eutran_to_geran_ho_out), pars);
5950 vc_conn.done;
5951
5952 f_ctrs_bsc_and_bts_add(0, "handover:attempted", 2);
5953 f_ctrs_bsc_and_bts_add(0, "handover:completed", 2);
5954 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:attempted", 1);
5955 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:completed", 1);
5956 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted", 1);
5957 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:completed", 1);
Pau Espin Pedrol211a7142021-06-15 16:43:03 +02005958
5959 f_ctrs_bsc_and_bts_add(0, "srvcc:attempted", 1);
5960 f_ctrs_bsc_and_bts_add(0, "srvcc:completed", 1);
Pau Espin Pedrol35801c32021-04-19 13:03:20 +02005961 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol9ae36d52021-06-15 17:29:43 +02005962
5963 if (disable_fast_return) {
5964 f_vty_allow_srvcc_fast_return(false, 0);
5965 }
Pau Espin Pedrol35801c32021-04-19 13:03:20 +02005966 f_shutdown_helper();
5967}
5968
Pau Espin Pedrol9ae36d52021-06-15 17:29:43 +02005969/* First, HO into BSC from EUTRAN (SRVCC): HO Request contains "Old BSS to New
5970 BSS Information" IE with "Last Used E-UTRAN PLMN Id".
5971 Second, HO to another BSC: HO Required contains "Old BSS to New BSS Information"
5972 IE with "Last Used E-UTRAN PLMN Id" from first step. */
5973testcase TC_srvcc_eutran_to_geran_ho_out() runs on test_CT {
5974 f_tc_srvcc_eutran_to_geran_ho_out_main(false);
5975}
5976/* Validate subsequent intra-GSM-HO works the same (with OldBSSToNewBSSInfo IE)
5977 * independently of fast-reture allowed/forbidden in local BTS */
5978testcase TC_srvcc_eutran_to_geran_ho_out_forbid_fast_return() runs on test_CT {
5979 f_tc_srvcc_eutran_to_geran_ho_out_main(true);
5980}
5981
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005982private function f_tc_ho_in_fail_msc_clears(charstring id) runs on MSC_ConnHdlr {
5983 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
5984 f_rslem_register(0, new_chan_nr);
5985 g_chan_nr := new_chan_nr;
5986 f_sleep(1.0);
5987
5988 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
5989 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
5990 activate(as_Media());
5991
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005992 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005993 f_gen_handover_req()));
Harald Welte6811d102019-04-14 22:23:14 +02005994 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005995
5996 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
5997
5998 var PDU_BSSAP rx_bssap;
5999 var octetstring ho_command_str;
6000
6001 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
6002
6003 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
6004 log("Received L3 Info in HO Request Ack: ", ho_command_str);
6005 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
6006 log("L3 Info in HO Request Ack is ", ho_command);
6007
6008 var GsmArfcn arfcn;
6009 var RslChannelNr actual_new_chan_nr;
6010 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
6011 actual_new_chan_nr, arfcn);
6012
6013 if (actual_new_chan_nr != new_chan_nr) {
6014 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
6015 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
6016 setverdict(fail);
6017 return;
6018 }
6019 log("Handover Command chan_nr is", actual_new_chan_nr);
6020
Neels Hofmeyr61ca08d2019-05-06 23:52:22 +02006021 /* For deterministic test results, give some time for the MGW endpoint to be configured */
6022 f_sleep(1.0);
6023
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01006024 /* Now the MSC forwards the RR Handover Command to the other BSC, which
6025 * tells the MS to handover to the new lchan. In this case, the MS
6026 * reports a Handover Failure to the old BSS, which forwards a BSSMAP
6027 * Handover Failure to the MSC. The procedure according to 3GPP TS
6028 * 48.008 3.1.5.3.2 "Handover Failure" is then that the MSC sends a
6029 * BSSMAP Clear Command: */
6030
6031 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_RADIO_INTERFACE_FAILURE_REVERSION;
6032 var BssmapCause cause := enum2int(cause_val);
6033 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
6034
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02006035 f_expect_dlcx_conns();
Neels Hofmeyr8fcd8772021-07-22 16:12:57 +02006036 BSSAP.receive(tr_BSSMAP_ClearComplete);
6037
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01006038 setverdict(pass);
6039 f_sleep(1.0);
6040
6041 setverdict(pass);
6042}
6043testcase TC_ho_in_fail_msc_clears() runs on test_CT {
6044 var MSC_ConnHdlr vc_conn;
6045 var TestHdlrParams pars := f_gen_test_hdlr_pars();
6046
6047 f_init(1, true);
6048 f_sleep(1.0);
6049
Neels Hofmeyrac432fa2021-11-02 16:45:56 +01006050 f_ctrs_bsc_and_bts_handover_init();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006051
Neels Hofmeyr90f80962020-06-12 16:16:55 +02006052 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
6053 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01006054
6055 vc_conn := f_start_handler(refers(f_tc_ho_in_fail_msc_clears), pars);
6056 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006057
6058 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
6059 f_ctrs_bsc_and_bts_add(0, "handover:stopped");
6060 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:attempted");
6061 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:stopped");
6062 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006063 f_shutdown_helper();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01006064}
6065
6066private function f_tc_ho_in_fail_msc_clears_after_ho_detect(charstring id) runs on MSC_ConnHdlr {
6067 /* Hack: the proper way would be to wait for the BSSMAP Handover Request ACK and extract the
6068 * actual assigned chan_nr from its L3 (RR Handover Command) message. But osmo-bsc starts acting
6069 * on the lchan even before we get a chance to evaluate the BSSMAP Handover Request ACK. So we
6070 * need to assume that osmo-bsc will activate TS 1 and already set up this lchan's RSL emulation
6071 * before we get started. */
6072 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
6073 f_rslem_register(0, new_chan_nr);
6074 g_chan_nr := new_chan_nr;
6075 f_sleep(1.0);
6076
6077 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
6078 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
6079 activate(as_Media());
6080
Neels Hofmeyr90f80962020-06-12 16:16:55 +02006081 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01006082 f_gen_handover_req()));
Harald Welte6811d102019-04-14 22:23:14 +02006083 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01006084
6085 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
6086
6087 var PDU_BSSAP rx_bssap;
6088 var octetstring ho_command_str;
6089
6090 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
6091
6092 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
6093 log("Received L3 Info in HO Request Ack: ", ho_command_str);
6094 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
6095 log("L3 Info in HO Request Ack is ", ho_command);
6096
6097 var GsmArfcn arfcn;
6098 var RslChannelNr actual_new_chan_nr;
6099 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
6100 actual_new_chan_nr, arfcn);
6101
6102 if (actual_new_chan_nr != new_chan_nr) {
6103 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
6104 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
6105 setverdict(fail);
6106 return;
6107 }
6108 log("Handover Command chan_nr is", actual_new_chan_nr);
6109
6110 /* Now the MSC forwards the RR Handover Command to the other BSC, which
6111 * tells the MS to handover to the new lchan. Here comes the new MS on
6112 * the new lchan with a Handover RACH: */
6113
6114 /* send handover detect */
6115
6116 RSL.send(ts_RSL_HANDO_DET(new_chan_nr));
6117
6118 BSSAP.receive(tr_BSSMAP_HandoverDetect);
6119
6120 /* The MSC chooses to clear the connection now, maybe we got the
6121 * Handover RACH on the new cell but the MS still signaled Handover
6122 * Failure to the old BSS? */
6123
6124 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_RADIO_INTERFACE_FAILURE_REVERSION;
6125 var BssmapCause cause := enum2int(cause_val);
6126 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
6127
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02006128 f_expect_dlcx_conns();
Neels Hofmeyr8fcd8772021-07-22 16:12:57 +02006129 BSSAP.receive(tr_BSSMAP_ClearComplete);
6130
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01006131 f_sleep(1.0);
6132}
6133testcase TC_ho_in_fail_msc_clears_after_ho_detect() runs on test_CT {
6134 var MSC_ConnHdlr vc_conn;
6135 var TestHdlrParams pars := f_gen_test_hdlr_pars();
6136
6137 f_init(1, true);
6138 f_sleep(1.0);
6139
Neels Hofmeyrac432fa2021-11-02 16:45:56 +01006140 f_ctrs_bsc_and_bts_handover_init();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006141
Neels Hofmeyr90f80962020-06-12 16:16:55 +02006142 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
6143 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01006144
6145 vc_conn := f_start_handler(refers(f_tc_ho_in_fail_msc_clears_after_ho_detect), pars);
6146 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006147
6148 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
6149 f_ctrs_bsc_and_bts_add(0, "handover:stopped");
6150 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:attempted");
6151 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:stopped");
6152 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006153 f_shutdown_helper();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01006154}
6155
6156/* The new BSS's lchan times out before the MSC decides that handover failed. */
6157private function f_tc_ho_in_fail_no_detect(charstring id) runs on MSC_ConnHdlr {
6158 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
6159 f_rslem_register(0, new_chan_nr);
6160 g_chan_nr := new_chan_nr;
6161 f_sleep(1.0);
6162
6163 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
6164 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
6165 activate(as_Media());
6166
Neels Hofmeyr90f80962020-06-12 16:16:55 +02006167 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01006168 f_gen_handover_req()));
Harald Welte6811d102019-04-14 22:23:14 +02006169 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01006170
6171 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
6172
6173 var PDU_BSSAP rx_bssap;
6174 var octetstring ho_command_str;
6175
6176 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
6177
6178 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
6179 log("Received L3 Info in HO Request Ack: ", ho_command_str);
6180 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
6181 log("L3 Info in HO Request Ack is ", ho_command);
6182
6183 var GsmArfcn arfcn;
6184 var RslChannelNr actual_new_chan_nr;
6185 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
6186 actual_new_chan_nr, arfcn);
6187
6188 if (actual_new_chan_nr != new_chan_nr) {
6189 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
6190 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
6191 setverdict(fail);
6192 return;
6193 }
6194 log("Handover Command chan_nr is", actual_new_chan_nr);
6195
6196 /* Now the MSC forwards the RR Handover Command to the other BSC, which
6197 * tells the MS to handover to the new lchan. But the MS never shows up
6198 * on the new lchan. */
6199
6200 BSSAP.receive(tr_BSSMAP_HandoverFailure);
6201
6202 /* Did osmo-bsc also send a Clear Request? */
6203 timer T := 0.5;
6204 T.start;
6205 alt {
6206 [] BSSAP.receive(tr_BSSMAP_ClearRequest);
6207 [] T.timeout { }
6208 }
6209
6210 /* MSC plays along with a Clear Command (no matter whether osmo-bsc
6211 * asked for it, this is a Handover Failure after all). */
6212
6213 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_RADIO_INTERFACE_FAILURE_REVERSION;
6214 var BssmapCause cause := enum2int(cause_val);
6215 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
6216
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02006217 f_expect_dlcx_conns();
Neels Hofmeyr8fcd8772021-07-22 16:12:57 +02006218 BSSAP.receive(tr_BSSMAP_ClearComplete);
6219
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01006220 f_sleep(1.0);
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01006221}
6222testcase TC_ho_in_fail_no_detect() runs on test_CT {
6223 var MSC_ConnHdlr vc_conn;
6224 var TestHdlrParams pars := f_gen_test_hdlr_pars();
6225
6226 f_init(1, true);
6227 f_sleep(1.0);
6228
Neels Hofmeyrac432fa2021-11-02 16:45:56 +01006229 f_ctrs_bsc_and_bts_handover_init();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006230
Neels Hofmeyr90f80962020-06-12 16:16:55 +02006231 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
6232 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01006233
6234 vc_conn := f_start_handler(refers(f_tc_ho_in_fail_no_detect), pars);
6235 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006236
6237 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
6238 f_ctrs_bsc_and_bts_add(0, "handover:error");
6239 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:attempted");
6240 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:error");
6241 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006242 f_shutdown_helper();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01006243}
6244
6245/* Same as f_tc_ho_in_fail_no_detect, but MSC fails to send a Clear Command */
6246private function f_tc_ho_in_fail_no_detect2(charstring id) runs on MSC_ConnHdlr {
6247 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
6248 f_rslem_register(0, new_chan_nr);
6249 g_chan_nr := new_chan_nr;
6250 f_sleep(1.0);
6251
6252 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
6253 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
6254 activate(as_Media());
6255
Neels Hofmeyr90f80962020-06-12 16:16:55 +02006256 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01006257 f_gen_handover_req()));
Harald Welte6811d102019-04-14 22:23:14 +02006258 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01006259
6260 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
6261
6262 var PDU_BSSAP rx_bssap;
6263 var octetstring ho_command_str;
6264
6265 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
6266
6267 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
6268 log("Received L3 Info in HO Request Ack: ", ho_command_str);
6269 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
6270 log("L3 Info in HO Request Ack is ", ho_command);
6271
6272 var GsmArfcn arfcn;
6273 var RslChannelNr actual_new_chan_nr;
6274 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
6275 actual_new_chan_nr, arfcn);
6276
6277 if (actual_new_chan_nr != new_chan_nr) {
6278 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
6279 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
6280 setverdict(fail);
6281 return;
6282 }
6283 log("Handover Command chan_nr is", actual_new_chan_nr);
6284
6285 /* Now the MSC forwards the RR Handover Command to the other BSC, which
6286 * tells the MS to handover to the new lchan. But the MS never shows up
6287 * on the new lchan. */
6288
6289 BSSAP.receive(tr_BSSMAP_HandoverFailure);
6290
6291 /* MSC plays dumb and sends no Clear Command */
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01006292 var PDU_BSSAP rx_clear_request;
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02006293
6294 BSSAP.receive(tr_BSSMAP_ClearRequest) -> value rx_clear_request {
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01006295 var BssmapCause cause := bit2int(rx_clear_request.pdu.bssmap.clearRequest.cause.causeValue);
6296 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
6297 };
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02006298 f_expect_dlcx_conns();
Neels Hofmeyr8fcd8772021-07-22 16:12:57 +02006299 BSSAP.receive(tr_BSSMAP_ClearComplete);
6300
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01006301 f_sleep(1.0);
6302}
6303testcase TC_ho_in_fail_no_detect2() runs on test_CT {
6304 var MSC_ConnHdlr vc_conn;
6305 var TestHdlrParams pars := f_gen_test_hdlr_pars();
6306
6307 f_init(1, true);
6308 f_sleep(1.0);
6309
Neels Hofmeyrac432fa2021-11-02 16:45:56 +01006310 f_ctrs_bsc_and_bts_handover_init();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006311
Neels Hofmeyr90f80962020-06-12 16:16:55 +02006312 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
6313 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01006314
6315 vc_conn := f_start_handler(refers(f_tc_ho_in_fail_no_detect2), pars);
6316 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006317
6318 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
6319 f_ctrs_bsc_and_bts_add(0, "handover:error");
6320 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:attempted");
6321 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:error");
6322 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006323 f_shutdown_helper();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01006324}
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01006325
Neels Hofmeyr91401012019-07-11 00:42:35 +02006326type record of charstring Commands;
6327
Neels Hofmeyr666f0432020-07-04 00:53:07 +02006328private function f_bts_0_cfg(TELNETasp_PT pt, Commands cmds := {})
Neels Hofmeyr91401012019-07-11 00:42:35 +02006329{
Neels Hofmeyr666f0432020-07-04 00:53:07 +02006330 f_vty_enter_cfg_bts(pt, 0);
Neels Hofmeyr91401012019-07-11 00:42:35 +02006331 for (var integer i := 0; i < sizeof(cmds); i := i+1) {
Neels Hofmeyr666f0432020-07-04 00:53:07 +02006332 f_vty_transceive(pt, cmds[i]);
Neels Hofmeyr91401012019-07-11 00:42:35 +02006333 }
Neels Hofmeyr666f0432020-07-04 00:53:07 +02006334 f_vty_transceive(pt, "end");
Neels Hofmeyr91401012019-07-11 00:42:35 +02006335}
6336
Pau Espin Pedrolc675b612020-01-09 19:55:40 +01006337private function f_cs7_inst_0_cfg(TELNETasp_PT pt, Commands cmds := {})
6338{
6339 f_vty_enter_cfg_cs7_inst(pt, 0);
6340 for (var integer i := 0; i < sizeof(cmds); i := i+1) {
6341 f_vty_transceive(pt, cmds[i]);
6342 }
6343 f_vty_transceive(pt, "end");
6344}
6345
Neels Hofmeyr91401012019-07-11 00:42:35 +02006346private function f_probe_for_handover(charstring log_label,
6347 charstring log_descr,
6348 charstring handover_vty_cmd,
6349 boolean expect_handover,
Neels Hofmeyr6a955cc2021-10-02 14:53:48 +02006350 boolean is_inter_bsc_handover := false,
6351 template uint3_t expect_target_tsc := ?)
Neels Hofmeyr91401012019-07-11 00:42:35 +02006352runs on MSC_ConnHdlr
6353{
Neels Hofmeyrb3fc8982020-05-11 00:16:42 +02006354 /* We're going to thwart any and all handover attempts, just be ready to handle (and ignore) handover target
6355 * lchans to be established on bts 1 or bts 2. */
6356 f_rslem_suspend(RSL1_PROC);
6357 f_rslem_suspend(RSL2_PROC);
6358
Neels Hofmeyr91401012019-07-11 00:42:35 +02006359 var RSL_Message rsl;
6360
6361 var charstring log_msg := " (expecting handover)"
6362 if (not expect_handover) {
6363 log_msg := " (expecting NO handover)";
6364 }
6365 log("f_probe_for_handover starting: " & log_label & ": " & log_descr & log_msg);
6366 f_vty_transceive(BSCVTY, handover_vty_cmd);
6367
Neels Hofmeyr91401012019-07-11 00:42:35 +02006368 timer T := 2.0;
6369 T.start;
6370
6371 alt {
6372 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr)) -> value rsl {
6373 var PDU_ML3_NW_MS l3 := dec_PDU_ML3_NW_MS(rsl.ies[2].body.l3_info.payload);
6374 log("Rx L3 from net: ", l3);
6375 if (ischosen(l3.msgs.rrm.handoverCommand)) {
6376 var RslChannelNr new_chan_nr;
6377 var GsmArfcn arfcn;
6378 f_ChDesc2RslChanNr(l3.msgs.rrm.handoverCommand.channelDescription2,
6379 new_chan_nr, arfcn);
6380 log("Handover to new chan ", new_chan_nr, " on ARFCN ", arfcn);
6381 log(l3.msgs.rrm.handoverCommand);
6382
Neels Hofmeyr6a955cc2021-10-02 14:53:48 +02006383 /* Verify correct TSC in handoverCommand */
6384 var uint3_t got_tsc := rr_chan_desc_tsc(l3.msgs.rrm.handoverCommand.channelDescription2);
6385 if (not match(got_tsc, expect_target_tsc)) {
6386 setverdict(fail, "RR Handover Command: unexpected TSC in Channel Description: expected ",
6387 expect_target_tsc, " got ", got_tsc);
6388 mtc.stop;
6389 } else {
6390 log("handoverCommand: verified TSC = ", got_tsc, " (matches ",
6391 expect_target_tsc, ")");
6392 }
6393
Neels Hofmeyr91401012019-07-11 00:42:35 +02006394 /* Need to register for new lchan on new BTS -- it's either bts 1 or bts 2. It doesn't really
6395 * matter on which BTS it really is, we're not going to follow through an entire handover
6396 * anyway. */
6397 f_rslem_register(0, new_chan_nr, RSL1_PROC);
6398 f_rslem_resume(RSL1_PROC);
6399 f_rslem_register(0, new_chan_nr, RSL2_PROC);
6400 f_rslem_resume(RSL2_PROC);
6401
6402 if (expect_handover and not is_inter_bsc_handover) {
6403 setverdict(pass);
6404 log("f_probe_for_handover(" & log_label & "): Got RSL Handover Command as expected.");
6405 } else {
6406 setverdict(fail, "f_probe_for_handover(" & log_label & "): Expected none, but got RSL Handover Command. "
6407 & log_label & ": " & log_descr);
6408 }
6409
6410 log("f_probe_for_handover(" & log_label & "): Ending the test: Handover Failure stops the procedure.");
6411 /* osmo-bsc has triggered Handover. That's all we need to know for this test, reply with
6412 * Handover Failure. */
6413 f_rsl_send_l3(ts_RRM_HandoverFailure('00'O));
6414
6415 /* target BTS is told to release lchan again; don't care which BTS nor what messages. */
6416 f_sleep(0.5);
6417 RSL1.clear;
6418 RSL2.clear;
6419 log("f_probe_for_handover(" & log_label & "): done (got RSL Handover Command)");
6420 break;
6421 } else {
6422 repeat;
6423 }
6424 }
6425 [] BSSAP.receive(tr_BSSMAP_HandoverRequired) {
6426 if (expect_handover and is_inter_bsc_handover) {
6427 setverdict(pass);
6428 log("f_probe_for_handover(" & log_label & "): Got BSSMAP Handover Required as expected.");
6429 } else {
6430 setverdict(fail, "f_probe_for_handover(" & log_label & "): Expected none, but got BSSMAP Handover Required. "
6431 & log_label & ": " & log_descr);
6432 }
6433
6434 log("f_probe_for_handover(" & log_label & "): done (got BSSMAP Handover Required)");
6435
6436 /* Note: f_tc_ho_neighbor_config_start() sets T7, the timeout for BSSMAP Handover Required, to
6437 * 1 second. There is no legal way to quickly abort a handover after a BSSMAP Handover Required,
6438 * setting a short timeout and waiting is the only way. */
6439 log("f_probe_for_handover(" & log_label & "): waiting for inter-BSC HO to time out...");
6440 f_sleep(1.5);
6441 log("f_probe_for_handover(" & log_label & "): ...done");
6442
6443 break;
6444 }
6445 [] T.timeout {
6446 if (expect_handover) {
6447 setverdict(fail, "f_probe_for_handover(" & log_label & "): Expected Handover, but got none. "
6448 & log_label & ": " & log_descr);
6449 } else {
6450 setverdict(pass);
6451 log("f_probe_for_handover(" & log_label & "): Got no Handover, as expected.");
6452 }
6453 log("f_probe_for_handover(" & log_label & "): done (got no Handover)");
6454 break;
6455 }
6456 }
6457
6458 f_rslem_resume(RSL1_PROC);
6459 f_rslem_resume(RSL2_PROC);
6460 f_sleep(3.0);
6461 RSL.clear;
6462
6463 log("f_probe_for_handover(" & log_label & "): done clearing");
6464}
6465
6466/* Test the effect of various neighbor configuration scenarios:
6467 *
6468 * To avoid complexity, block off any actual handover operation, and always remain on the lchan at bts 0.
6469 * Reconfigure the neighbors for bts 0, trigger a Handover, and probe whether osmo-bsc does or doesn't start HO.
6470 */
6471private function f_tc_ho_neighbor_config_start() runs on MSC_ConnHdlr {
6472 g_pars := f_gen_test_hdlr_pars();
6473 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
6474 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Neels Hofmeyr91401012019-07-11 00:42:35 +02006475
6476 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
6477 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
6478
6479 /* Establish lchan at bts 0 */
6480 f_establish_fully(ass_cmd, exp_compl);
6481
6482 /* Shorten the inter-BSC Handover timeout, to not wait so long for inter-BSC Handovers */
6483 f_vty_enter_cfg_network(BSCVTY);
6484 f_vty_transceive(BSCVTY, "timer T7 1");
6485 f_vty_transceive(BSCVTY, "end");
6486}
6487
6488private function f_tc_ho_neighbor_config_1(charstring id) runs on MSC_ConnHdlr {
6489 f_tc_ho_neighbor_config_start();
6490
6491 /*
6492 * bts 0 ARFCN 871 BSIC 10
6493 * bts 1 ARFCN 871 BSIC 11
6494 * bts 2 ARFCN 871 BSIC 12
6495 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
6496 */
6497
6498 log("f_tc_ho_neighbor_config: 1. No 'neighbor' config");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02006499 f_bts_0_cfg(BSCVTY, {"no neighbors"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02006500 f_probe_for_handover("1.a", "HO to bts 1 works, implicitly listed as neighbor (legacy behavior when none are configured)",
6501 "handover any to arfcn 871 bsic 11",
Neels Hofmeyr6a955cc2021-10-02 14:53:48 +02006502 true, expect_target_tsc := BTS_TSC[1]);
Neels Hofmeyr91401012019-07-11 00:42:35 +02006503
6504 f_probe_for_handover("1.b", "HO to unknown cell does not start",
6505 "handover any to arfcn 13 bsic 39",
6506 false);
6507
6508 f_probe_for_handover("1.c", "HO to 871-12 is ambiguous = error",
6509 "handover any to arfcn 871 bsic 12",
6510 false);
6511
6512 f_probe_for_handover("1.d", "HO to 871-11 still works (verify that this test properly cleans up)",
6513 "handover any to arfcn 871 bsic 11",
Neels Hofmeyr6a955cc2021-10-02 14:53:48 +02006514 true, expect_target_tsc := BTS_TSC[1]);
Neels Hofmeyr91401012019-07-11 00:42:35 +02006515}
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006516testcase TC_ho_neighbor_config_1() runs on test_CT {
6517 var MSC_ConnHdlr vc_conn;
6518 f_init(3, true, guard_timeout := 60.0);
6519 f_sleep(1.0);
Neels Hofmeyrac432fa2021-11-02 16:45:56 +01006520 f_ctrs_bsc_and_bts_handover_init();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006521 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_1));
6522 vc_conn.done;
6523
6524 /* f_tc_ho_neighbor_config_start() */
6525 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
6526 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
6527
6528 /* 1.a */
6529 /* "failed" means a handover was triggered and started (which is all this test aims for) and the test ended the
6530 * handover quickly by sending a Handover Failure message. */
6531 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
6532 f_ctrs_bsc_and_bts_add(0, "handover:failed");
6533 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
6534 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:failed");
Neels Hofmeyrac432fa2021-11-02 16:45:56 +01006535 f_ctrs_bts_add(1, "incoming_intra_bsc_ho:attempted");
6536 f_ctrs_bts_add(1, "incoming_intra_bsc_ho:failed");
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006537
6538 /* 1.b */
6539 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
6540 f_ctrs_bsc_and_bts_add(0, "handover:error");
6541
6542 /* 1.c */
6543 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
6544 f_ctrs_bsc_and_bts_add(0, "handover:error");
6545
6546 /* 1.d */
6547 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
6548 f_ctrs_bsc_and_bts_add(0, "handover:failed");
6549 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
6550 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:failed");
Neels Hofmeyrac432fa2021-11-02 16:45:56 +01006551 f_ctrs_bts_add(1, "incoming_intra_bsc_ho:attempted");
6552 f_ctrs_bts_add(1, "incoming_intra_bsc_ho:failed");
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006553
6554 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006555 f_shutdown_helper();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006556}
6557
Neels Hofmeyr91401012019-07-11 00:42:35 +02006558private function f_tc_ho_neighbor_config_2(charstring id) runs on MSC_ConnHdlr {
6559 f_tc_ho_neighbor_config_start();
6560
6561 /*
6562 * bts 0 ARFCN 871 BSIC 10
6563 * bts 1 ARFCN 871 BSIC 11
6564 * bts 2 ARFCN 871 BSIC 12
6565 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
6566 */
6567
6568 log("f_tc_ho_neighbor_config: 2. explicit local neighbor: 'neighbor bts 1'");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02006569 f_bts_0_cfg(BSCVTY, {"neighbor bts 1"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02006570 f_sleep(0.5);
6571
6572 f_probe_for_handover("2.a", "HO to bts 1 works, explicitly listed as neighbor",
6573 "handover any to arfcn 871 bsic 11",
Neels Hofmeyr6a955cc2021-10-02 14:53:48 +02006574 true, expect_target_tsc := BTS_TSC[1]);
Neels Hofmeyr91401012019-07-11 00:42:35 +02006575
6576 f_probe_for_handover("2.b", "HO to bts 2 doesn't work, not listed as neighbor",
6577 "handover any to arfcn 871 bsic 12",
6578 false);
6579}
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006580testcase TC_ho_neighbor_config_2() runs on test_CT {
6581 var MSC_ConnHdlr vc_conn;
6582 f_init(3, true, guard_timeout := 50.0);
6583 f_sleep(1.0);
Neels Hofmeyrac432fa2021-11-02 16:45:56 +01006584 f_ctrs_bsc_and_bts_handover_init();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006585 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_2));
6586 vc_conn.done;
6587
6588 /* f_tc_ho_neighbor_config_start() */
6589 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
6590 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
6591
6592 /* 2.a */
6593 /* "failed" means a handover was triggered and started (which is all this test aims for) and the test ended the
6594 * handover quickly by sending a Handover Failure message. */
6595 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
6596 f_ctrs_bsc_and_bts_add(0, "handover:failed");
6597 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
6598 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:failed");
Neels Hofmeyrac432fa2021-11-02 16:45:56 +01006599 f_ctrs_bts_add(1, "incoming_intra_bsc_ho:attempted");
6600 f_ctrs_bts_add(1, "incoming_intra_bsc_ho:failed");
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006601
6602 /* 2.b */
6603 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
6604 f_ctrs_bsc_and_bts_add(0, "handover:error");
6605
6606 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006607 f_shutdown_helper();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006608}
6609
Neels Hofmeyr91401012019-07-11 00:42:35 +02006610private function f_tc_ho_neighbor_config_3(charstring id) runs on MSC_ConnHdlr {
6611 f_tc_ho_neighbor_config_start();
6612
6613 /*
6614 * bts 0 ARFCN 871 BSIC 10
6615 * bts 1 ARFCN 871 BSIC 11
6616 * bts 2 ARFCN 871 BSIC 12
6617 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
6618 */
6619
6620 log("f_tc_ho_neighbor_config: 3. explicit local neighbor: 'neighbor bts 2'");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02006621 f_bts_0_cfg(BSCVTY, {"no neighbors", "neighbor bts 2"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02006622 f_sleep(0.5);
6623
6624 f_probe_for_handover("3.a", "HO to bts 1 doesn't work, not listed as neighbor",
6625 "handover any to arfcn 871 bsic 11",
6626 false);
6627 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",
6628 "handover any to arfcn 871 bsic 12",
Neels Hofmeyr6a955cc2021-10-02 14:53:48 +02006629 true, expect_target_tsc := BTS_TSC[2]);
Neels Hofmeyr91401012019-07-11 00:42:35 +02006630}
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006631testcase TC_ho_neighbor_config_3() runs on test_CT {
6632 var MSC_ConnHdlr vc_conn;
6633 f_init(3, true, guard_timeout := 50.0);
6634 f_sleep(1.0);
Neels Hofmeyrac432fa2021-11-02 16:45:56 +01006635 f_ctrs_bsc_and_bts_handover_init();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006636 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_3));
6637 vc_conn.done;
6638
6639 /* f_tc_ho_neighbor_config_start() */
6640 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
6641 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
6642
6643 /* 3.a */
6644 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
6645 f_ctrs_bsc_and_bts_add(0, "handover:error");
6646
6647 /* 3.b */
6648 /* "failed" means a handover was triggered and started (which is all this test aims for) and the test ended the
6649 * handover quickly by sending a Handover Failure message. */
6650 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
6651 f_ctrs_bsc_and_bts_add(0, "handover:failed");
6652 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
6653 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:failed");
Neels Hofmeyrac432fa2021-11-02 16:45:56 +01006654 f_ctrs_bts_add(2, "incoming_intra_bsc_ho:attempted");
6655 f_ctrs_bts_add(2, "incoming_intra_bsc_ho:failed");
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006656
6657 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006658 f_shutdown_helper();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006659}
6660
Neels Hofmeyr91401012019-07-11 00:42:35 +02006661private function f_tc_ho_neighbor_config_4(charstring id) runs on MSC_ConnHdlr {
6662 f_tc_ho_neighbor_config_start();
6663
6664 /*
6665 * bts 0 ARFCN 871 BSIC 10
6666 * bts 1 ARFCN 871 BSIC 11
6667 * bts 2 ARFCN 871 BSIC 12
6668 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
6669 */
6670
6671 log("f_tc_ho_neighbor_config: 4. explicit remote neighbor: 'neighbor lac 99 arfcn 123 bsic 45'");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02006672 f_bts_0_cfg(BSCVTY, {"no neighbors", "neighbor lac 99 arfcn 123 bsic 45"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02006673 f_sleep(0.5);
6674
6675 f_probe_for_handover("4.a", "HO to bts 1 doesn't work, not listed as neighbor",
6676 "handover any to arfcn 871 bsic 11",
6677 false);
6678 f_probe_for_handover("4.b", "HO to bts 2 doesn't work, not listed as neighbor",
6679 "handover any to arfcn 871 bsic 12",
6680 false);
6681 f_probe_for_handover("4.c", "HO to 123-45 triggers inter-BSC HO",
6682 "handover any to arfcn 123 bsic 45",
6683 true, true);
6684}
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006685testcase TC_ho_neighbor_config_4() runs on test_CT {
6686 var MSC_ConnHdlr vc_conn;
6687 f_init(3, true, guard_timeout := 50.0);
6688 f_sleep(1.0);
Neels Hofmeyrac432fa2021-11-02 16:45:56 +01006689 f_ctrs_bsc_and_bts_handover_init();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006690 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_4));
6691 vc_conn.done;
6692
6693 /* f_tc_ho_neighbor_config_start() */
6694 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
6695 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
6696
6697 /* 4.a */
6698 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
6699 f_ctrs_bsc_and_bts_add(0, "handover:error");
6700
6701 /* 4.b */
6702 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
6703 f_ctrs_bsc_and_bts_add(0, "handover:error");
6704
6705 /* 4.c */
6706 /* "timeout" means a handover was triggered and started (which is all this test aims for) and the test ended the
6707 * handover quickly by timing out after the Handover Required message */
6708 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
6709 f_ctrs_bsc_and_bts_add(0, "handover:timeout");
6710 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
6711 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:timeout");
6712
6713 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006714 f_shutdown_helper();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006715}
6716
Neels Hofmeyr91401012019-07-11 00:42:35 +02006717private function f_tc_ho_neighbor_config_5(charstring id) runs on MSC_ConnHdlr {
6718 f_tc_ho_neighbor_config_start();
6719
6720 /*
6721 * bts 0 ARFCN 871 BSIC 10
6722 * bts 1 ARFCN 871 BSIC 11
6723 * bts 2 ARFCN 871 BSIC 12
6724 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
6725 */
6726
6727 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 +02006728 f_bts_0_cfg(BSCVTY, {"no neighbors", "neighbor lac 99 arfcn 871 bsic 12"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02006729 f_sleep(0.5);
6730
6731 f_probe_for_handover("5.a", "HO to 871-12 triggers inter-BSC HO (ignoring local cells with same ARFCN+BSIC)",
6732 "handover any to arfcn 871 bsic 12",
6733 true, true);
6734}
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006735testcase TC_ho_neighbor_config_5() runs on test_CT {
6736 var MSC_ConnHdlr vc_conn;
6737 f_init(3, true);
6738 f_sleep(1.0);
Neels Hofmeyrac432fa2021-11-02 16:45:56 +01006739 f_ctrs_bsc_and_bts_handover_init();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006740 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_5));
6741 vc_conn.done;
6742
6743 /* f_tc_ho_neighbor_config_start() */
6744 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
6745 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
6746
6747 /* 5 */
6748 /* "timeout" means a handover was triggered and started (which is all this test aims for) and the test ended the
6749 * handover quickly by timing out after the Handover Required message */
6750 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
6751 f_ctrs_bsc_and_bts_add(0, "handover:timeout");
6752 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
6753 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:timeout");
6754
6755 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006756 f_shutdown_helper();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006757}
6758
Neels Hofmeyr91401012019-07-11 00:42:35 +02006759private function f_tc_ho_neighbor_config_6(charstring id) runs on MSC_ConnHdlr {
6760 f_tc_ho_neighbor_config_start();
6761
6762 /*
6763 * bts 0 ARFCN 871 BSIC 10
6764 * bts 1 ARFCN 871 BSIC 11
6765 * bts 2 ARFCN 871 BSIC 12
6766 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
6767 */
6768
6769 log("f_tc_ho_neighbor_config: 6. config error: explicit local and remote neighbors with ambiguous ARFCN+BSIC:"
6770 & " 'neighbor bts 2; neighbor lac 99 arfcn 871 bsic 12'");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02006771 f_bts_0_cfg(BSCVTY, {"no neighbors", "neighbor bts 2", "neighbor lac 99 arfcn 871 bsic 12"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02006772 f_sleep(0.5);
6773
6774 f_probe_for_handover("6.a", "HO to 871-12 is ambiguous = error",
6775 "handover any to arfcn 871 bsic 12",
6776 false);
6777}
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006778testcase TC_ho_neighbor_config_6() runs on test_CT {
6779 var MSC_ConnHdlr vc_conn;
6780 f_init(3, true);
6781 f_sleep(1.0);
Neels Hofmeyrac432fa2021-11-02 16:45:56 +01006782 f_ctrs_bsc_and_bts_handover_init();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006783 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_6));
6784 vc_conn.done;
6785
6786 /* f_tc_ho_neighbor_config_start() */
6787 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
6788 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
6789
6790 /* 6.a */
6791 /* "timeout" means a handover was triggered and started (which is all this test aims for) and the test ended the
6792 * handover quickly by timing out after the Handover Required message */
6793 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
6794 f_ctrs_bsc_and_bts_add(0, "handover:error");
6795
6796 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006797 f_shutdown_helper();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006798}
6799
Neels Hofmeyr91401012019-07-11 00:42:35 +02006800private function f_tc_ho_neighbor_config_7(charstring id) runs on MSC_ConnHdlr {
6801 f_tc_ho_neighbor_config_start();
6802
6803 /*
6804 * bts 0 ARFCN 871 BSIC 10
6805 * bts 1 ARFCN 871 BSIC 11
6806 * bts 2 ARFCN 871 BSIC 12
6807 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
6808 */
6809
6810 log("f_tc_ho_neighbor_config: 7. explicit local and remote neighbors:"
6811 & " 'neighbor bts 2; neighbor lac 99 arfcn 123 bsic 45'");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02006812 f_bts_0_cfg(BSCVTY, {"no neighbors", "neighbor bts 2", "neighbor lac 99 arfcn 123 bsic 45"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02006813 f_sleep(0.5);
6814
6815 f_probe_for_handover("7.a", "HO to 871-12 does HO to bts 2",
6816 "handover any to arfcn 871 bsic 12",
Neels Hofmeyr6a955cc2021-10-02 14:53:48 +02006817 true, expect_target_tsc := BTS_TSC[2]);
Neels Hofmeyr91401012019-07-11 00:42:35 +02006818 f_probe_for_handover("7.b", "HO to 123-45 triggers inter-BSC HO",
6819 "handover any to arfcn 123 bsic 45",
6820 true, true);
6821}
Neels Hofmeyr91401012019-07-11 00:42:35 +02006822testcase TC_ho_neighbor_config_7() runs on test_CT {
6823 var MSC_ConnHdlr vc_conn;
Neels Hofmeyrf2b88032020-06-16 00:35:04 +02006824 f_init(3, true, guard_timeout := 50.0);
Neels Hofmeyr91401012019-07-11 00:42:35 +02006825 f_sleep(1.0);
Neels Hofmeyrac432fa2021-11-02 16:45:56 +01006826 f_ctrs_bsc_and_bts_handover_init();
Neels Hofmeyr91401012019-07-11 00:42:35 +02006827 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_7));
6828 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006829
6830 /* f_tc_ho_neighbor_config_start() */
6831 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
6832 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
6833
6834 /* 7.a */
6835 /* "failed" means a handover was triggered and started (which is all this test aims for) and the test ended the
6836 * handover quickly by sending a Handover Failure message. */
6837 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
6838 f_ctrs_bsc_and_bts_add(0, "handover:failed");
6839 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
6840 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:failed");
Neels Hofmeyrac432fa2021-11-02 16:45:56 +01006841 f_ctrs_bts_add(2, "incoming_intra_bsc_ho:attempted");
6842 f_ctrs_bts_add(2, "incoming_intra_bsc_ho:failed");
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006843
6844 /* 7.b */
6845 /* "timeout" means a handover was triggered and started (which is all this test aims for) and the test ended the
6846 * handover quickly by timing out after the Handover Required message */
6847 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
6848 f_ctrs_bsc_and_bts_add(0, "handover:timeout");
6849 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
6850 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:timeout");
6851
6852 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006853 f_shutdown_helper();
Neels Hofmeyr91401012019-07-11 00:42:35 +02006854}
6855
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01006856/* OS#3041: Open and close N connections in a normal fashion, and expect no
6857 * BSSMAP Reset just because of that. */
6858testcase TC_bssap_rlsd_does_not_cause_bssmap_reset() runs on test_CT {
6859 var default d;
6860 var integer i;
6861 var DchanTuple dt;
6862
6863 f_init();
6864
6865 /* Wait for initial BSSMAP Reset to pass */
6866 f_sleep(4.0);
6867
6868 d := activate(no_bssmap_reset());
6869
6870 /* Setup up a number of connections and RLSD them again from the MSC
6871 * side. In the buggy behavior, the fourth one triggers BSSMAP Reset.
6872 * Let's do it some more times for good measure. */
Harald Weltec3260d92018-06-11 17:48:16 +02006873 for (i := 0; i < 4; i := i+1) {
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01006874 /* Since we're doing a lot of runs, give each one a fresh
6875 * T_guard from the top. */
6876 T_guard.start;
6877
6878 /* Setup a BSSAP connection and clear it right away. This is
6879 * the MSC telling the BSC about a planned release, it's not an
6880 * erratic loss of a connection. */
Harald Weltea1897182018-06-11 13:53:09 +02006881 dt := f_est_dchan(int2oct(i,1), 23+i, '00010203040506'O);
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01006882
6883 /* MSC disconnects (RLSD). */
6884 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
6885 }
6886
6887 /* In the buggy behavior, a timeout of 2 seconds happens between above
6888 * trigger (logs "SIGTRAN connection down, reconnecting...") and the
6889 * actual BSSMAP Reset. Wait a bit longer just to make sure. */
6890 f_sleep(4.0);
6891
6892 deactivate(d);
6893 f_shutdown_helper();
6894}
Harald Welte552620d2017-12-16 23:21:36 +01006895
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01006896/* OS#3041: Open and close N connections in a normal fashion, and expect no
6897 * BSSMAP Reset just because of that. Invoke the release by a BSSMAP Clear from
6898 * the MSC. */
6899testcase TC_bssmap_clear_does_not_cause_bssmap_reset() runs on test_CT {
6900 var default d;
6901 var integer i;
6902 var DchanTuple dt;
6903 var BSSAP_N_DATA_ind rx_di;
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01006904 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_CALL_CONTROL;
6905 var BssmapCause cause := enum2int(cause_val);
6906
6907 f_init();
6908
6909 /* Wait for initial BSSMAP Reset to pass */
6910 f_sleep(4.0);
6911
6912 d := activate(no_bssmap_reset());
6913
6914 /* Setup up a number of connections and RLSD them again from the MSC
6915 * side. In the buggy behavior, the fourth one triggers BSSMAP Reset.
6916 * Let's do it some more times for good measure. */
6917 for (i := 0; i < 8; i := i+1) {
6918 /* Since we're doing a lot of runs, give each one a fresh
6919 * T_guard from the top. */
6920 T_guard.start;
6921
6922 /* Setup a BSSAP connection and clear it right away. This is
6923 * the MSC telling the BSC about a planned release, it's not an
6924 * erratic loss of a connection. */
Harald Weltea1897182018-06-11 13:53:09 +02006925 dt := f_est_dchan(int2oct(i,1), 23+i, '00010203040506'O);
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01006926
6927 /* Instruct BSC to clear channel */
6928 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
6929
6930 /* expect BSC to disable the channel */
Harald Welte641fcbe2018-06-14 10:58:35 +02006931 f_exp_chan_rel_and_clear(dt, 0);
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01006932 }
6933
6934 /* In the buggy behavior, a timeout of 2 seconds happens between above
6935 * trigger (logs "SIGTRAN connection down, reconnecting...") and the
6936 * actual BSSMAP Reset. Wait a bit longer just to make sure. */
6937 f_sleep(4.0);
6938
6939 deactivate(d);
6940 f_shutdown_helper();
6941}
6942
Neels Hofmeyrfd445c32018-03-09 15:39:31 +01006943/* OS#3041: Open and close N connections in a normal fashion, and expect no
6944 * BSSMAP Reset just because of that. Close connections from the MS side with a
6945 * Release Ind on RSL. */
6946testcase TC_ms_rel_ind_does_not_cause_bssmap_reset() runs on test_CT {
6947 var default d;
6948 var integer i;
6949 var DchanTuple dt;
6950 var BSSAP_N_DATA_ind rx_di;
Neels Hofmeyrfd445c32018-03-09 15:39:31 +01006951 var integer j;
6952
6953 f_init();
6954
6955 /* Wait for initial BSSMAP Reset to pass */
6956 f_sleep(4.0);
6957
6958 d := activate(no_bssmap_reset());
6959
6960 /* Setup up a number of connections and RLSD them again from the MSC
6961 * side. In the buggy behavior, the fourth one triggers BSSMAP Reset.
6962 * Let's do it some more times for good measure. */
6963 for (i := 0; i < 8; i := i+1) {
6964 /* Since we're doing a lot of runs, give each one a fresh
6965 * T_guard from the top. */
6966 T_guard.start;
6967
6968 /* Setup a BSSAP connection and clear it right away. This is
6969 * the MSC telling the BSC about a planned release, it's not an
6970 * erratic loss of a connection. */
6971 dt := f_est_dchan('23'O, 23, '00010203040506'O);
6972
6973 /* simulate RLL REL IND */
6974 f_ipa_tx(0, ts_RSL_REL_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0))));
6975
6976 /* expect Clear Request on MSC side */
6977 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearRequest)) -> value rx_di;
6978
6979 /* Instruct BSC to clear channel */
6980 var BssmapCause cause := bit2int(rx_di.userData.pdu.bssmap.clearRequest.cause.causeValue);
6981 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
6982
6983 /* expect BSC to disable the channel */
Harald Welte641fcbe2018-06-14 10:58:35 +02006984 f_exp_chan_rel_and_clear(dt, 0);
Neels Hofmeyrfd445c32018-03-09 15:39:31 +01006985 }
6986
6987 /* In the buggy behavior, a timeout of 2 seconds happens between above
6988 * trigger (logs "SIGTRAN connection down, reconnecting...") and the
6989 * actual BSSMAP Reset. Wait a bit longer just to make sure. */
6990 f_sleep(4.0);
6991
6992 deactivate(d);
6993 f_shutdown_helper();
6994}
6995
Harald Welte94e0c342018-04-07 11:33:23 +02006996/***********************************************************************
6997 * IPA style dynamic PDCH
6998 ***********************************************************************/
6999
7000private function f_dyn_ipa_pdch_act(integer bts_nr, integer trx_nr, integer ts_nr,
7001 template (omit) RSL_Cause nack := omit)
7002runs on test_CT {
7003 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(ts_nr));
7004 var RSL_Message rsl_unused;
7005 /* ask BSC via VTY to activate a given IPA style chan as PDCH */
7006 f_vty_ts_action("pdch activate", bts_nr, trx_nr, ts_nr);
7007 /* expect the BSC to issue the related RSL command */
7008 rsl_unused := f_exp_ipa_rx(0, tr_RSL_IPA_PDCH_ACT(chan_nr));
7009 if (istemplatekind(nack, "omit")) {
7010 /* respond with a related acknowledgement */
7011 f_ipa_tx(0, ts_RSL_IPA_PDCH_ACT_ACK(chan_nr, ts_RSL_IE_FrameNumber(2342)));
7012 } else {
7013 f_ipa_tx(0, ts_RSL_IPA_PDCH_ACT_NACK(chan_nr, valueof(nack)));
7014 }
7015}
7016
7017private function f_dyn_ipa_pdch_deact(integer bts_nr, integer trx_nr, integer ts_nr,
7018 template (omit) RSL_Cause nack := omit)
7019runs on test_CT {
7020 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(ts_nr));
7021 var RSL_Message rsl_unused;
7022 /* ask BSC via VTY to activate a given IPA style chan as PDCH */
7023 f_vty_ts_action("pdch deactivate", bts_nr, trx_nr, ts_nr);
7024 /* expect the BSC to issue the related RSL command */
7025 rsl_unused := f_exp_ipa_rx(0, tr_RSL_IPA_PDCH_DEACT(chan_nr));
7026 if (istemplatekind(nack, "omit")) {
7027 /* respond with a related acknowledgement */
7028 f_ipa_tx(0, ts_RSL_IPA_PDCH_DEACT_ACK(chan_nr));
7029 } else {
7030 f_ipa_tx(0, ts_RSL_IPA_PDCH_DEACT_NACK(chan_nr, valueof(nack)));
7031 }
7032}
7033
7034private function f_ts_dyn_mode_get(integer bts_nr, integer trx_nr, integer ts_nr)
7035runs on test_CT return charstring {
7036 var charstring cmd, resp;
7037 cmd := "show timeslot "&int2str(bts_nr)&" "&int2str(trx_nr)&" "&int2str(ts_nr);
Stefan Sperlingcff13562018-11-13 15:24:06 +01007038 return f_vty_transceive_match_regexp_retry(BSCVTY, cmd, "*\((*)\)*", 0, 4, 1.0);
Harald Welte94e0c342018-04-07 11:33:23 +02007039}
7040
7041private function f_ts_dyn_mode_assert(integer bts_nr, integer trx_nr, integer ts_nr,
7042 template charstring exp)
7043runs on test_CT {
7044 var charstring mode := f_ts_dyn_mode_get(bts_nr, trx_nr, ts_nr);
7045 if (not match(mode, exp)) {
7046 setverdict(fail, "Unexpected TS Mode: ", mode);
Daniel Willmannafce8662018-07-06 23:11:32 +02007047 mtc.stop;
Harald Welte94e0c342018-04-07 11:33:23 +02007048 }
7049}
7050
7051private function f_ts_set_chcomb(integer bts_nr, integer trx_nr, integer ts_nr, charstring chcomb)
7052runs on test_CT {
7053 f_vty_enter_cfg_ts(BSCVTY, bts_nr, trx_nr, ts_nr);
7054 f_vty_transceive(BSCVTY, "phys_chan_config " & chcomb);
7055 f_vty_transceive(BSCVTY, "end");
7056}
7057
Pau Espin Pedrol0953bf82021-07-09 13:20:19 +02007058
7059private function f_ts_reset_chcomb(integer bts_nr) runs on test_CT {
7060 var integer i;
7061 for (i := 0; i < 8; i := i + 1) {
7062 f_ts_set_chcomb(bts_nr, 0, i, phys_chan_config[i]);
7063 }
7064}
7065
Harald Welte94e0c342018-04-07 11:33:23 +02007066private const charstring TCHF_MODE := "TCH/F mode";
7067private const charstring TCHH_MODE := "TCH/H mode";
7068private const charstring PDCH_MODE := "PDCH mode";
7069private const charstring NONE_MODE := "NONE mode";
Pau Espin Pedrol5b381082021-06-28 17:14:03 +02007070private const charstring SDCCH8_MODE := "SDCCH8 mode";
Harald Welte94e0c342018-04-07 11:33:23 +02007071
7072/* Test IPA PDCH activation / deactivation triggered by VTY */
7073testcase TC_dyn_pdch_ipa_act_deact() runs on test_CT {
7074 var RSL_Message rsl_unused;
7075
7076 /* change Timeslot 6 before f_init() starts RSL */
7077 f_init_vty();
7078 f_ts_set_chcomb(0, 0, 6, "TCH/F_PDCH");
7079 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
7080
7081 f_init(1, false);
7082 f_sleep(1.0);
7083
7084 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(6));
7085
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02007086 log("TCH/F_PDCH pchan starts out in TCH/F mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02007087 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
7088 /* The BSC will activate the dynamic PDCH by default, so confirm that */
7089 rsl_unused := f_exp_ipa_rx(0, tr_RSL_IPA_PDCH_ACT(chan_nr));
7090 f_ipa_tx(0, ts_RSL_IPA_PDCH_ACT_ACK(chan_nr, ts_RSL_IE_FrameNumber(2342)));
7091 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02007092 log("TCH/F_PDCH pchan, PDCH ACT was ACKed, so now in PDCH mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02007093 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, PDCH_MODE);
7094
7095 /* De-activate it via VTY */
7096 f_dyn_ipa_pdch_deact(0, 0, chan_nr.tn);
7097 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02007098 log("TCH/F_PDCH pchan, PDCH DEACT via VTY, so now back in TCH/F mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02007099 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
7100
7101 /* re-activate it via VTY */
7102 f_dyn_ipa_pdch_act(0, 0, chan_nr.tn);
7103 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02007104 log("TCH/F_PDCH pchan, PDCH ACT via VTY, so now in PDCH mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02007105 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, PDCH_MODE);
7106
7107 /* and finally de-activate it again */
7108 f_dyn_ipa_pdch_deact(0, 0, chan_nr.tn);
7109 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02007110 log("TCH/F_PDCH pchan, PDCH DEACT via VTY, so now back in TCH/F mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02007111 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
7112
Neels Hofmeyr887e8f12018-06-27 01:01:55 +02007113 /* clean up config */
7114 f_ts_set_chcomb(0, 0, 6, "PDCH");
7115
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007116 f_shutdown_helper();
Harald Welte94e0c342018-04-07 11:33:23 +02007117}
7118
7119/* Test IPA PDCH activation NACK */
7120testcase TC_dyn_pdch_ipa_act_nack() runs on test_CT {
7121 var RSL_Message rsl_unused;
7122
7123 /* change Timeslot 6 before f_init() starts RSL */
7124 f_init_vty();
7125 f_ts_set_chcomb(0, 0, 6, "TCH/F_PDCH");
7126 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
7127
7128 f_init(1, false);
7129 f_sleep(1.0);
7130
7131 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(6));
7132
7133 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
7134 /* The BSC will activate the dynamic PDCH by default, so confirm that */
7135 rsl_unused := f_exp_ipa_rx(0, tr_RSL_IPA_PDCH_ACT(chan_nr));
7136 f_ipa_tx(0, ts_RSL_IPA_PDCH_ACT_ACK(chan_nr, ts_RSL_IE_FrameNumber(2342)));
7137 f_sleep(1.0);
7138 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, PDCH_MODE);
7139
7140 /* De-activate it via VTY */
7141 f_dyn_ipa_pdch_deact(0, 0, chan_nr.tn);
7142 f_sleep(1.0);
7143 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
7144
7145 /* re-activate it via VTY, but fail that; check BSC still assumes TCH/F mode */
7146 f_dyn_ipa_pdch_act(0, 0, chan_nr.tn, RSL_ERR_EQUIPMENT_FAIL);
7147 f_sleep(1.0);
7148 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
7149
Neels Hofmeyr887e8f12018-06-27 01:01:55 +02007150 /* clean up config */
7151 f_ts_set_chcomb(0, 0, 6, "PDCH");
7152
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007153 f_shutdown_helper();
Harald Welte94e0c342018-04-07 11:33:23 +02007154}
7155
7156
7157/***********************************************************************
7158 * Osmocom style dynamic PDCH
7159 ***********************************************************************/
7160
7161private function f_dyn_osmo_pdch_act(integer bts_nr, integer trx_nr, integer ts_nr,
7162 template (omit) RSL_Cause nack := omit)
7163runs on test_CT {
7164 var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(ts_nr));
7165 var RSL_Message rsl_unused;
Pau Espin Pedrol64adf372021-06-28 16:25:47 +02007166 /* ask BSC via VTY to activate a given OSMO style chan as PDCH */
Harald Welte94e0c342018-04-07 11:33:23 +02007167 /* FIXME: no VTY command to activate Osmocom PDCH !! */
7168 /* expect the BSC to issue the related RSL command */
7169 rsl_unused := f_exp_ipa_rx(0, tr_RSL_CHAN_ACT(chan_nr, ?));
7170 if (istemplatekind(nack, "omit")) {
7171 /* respond with a related acknowledgement */
7172 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, 2342));
7173 } else {
7174 f_ipa_tx(0, ts_RSL_CHAN_ACT_NACK(chan_nr, valueof(nack)));
7175 }
7176}
7177
7178private function f_dyn_osmo_pdch_deact(integer bts_nr, integer trx_nr, integer ts_nr,
7179 template (omit) RSL_Cause nack := omit)
7180runs on test_CT {
7181 var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(ts_nr));
7182 var RSL_Message rsl_unused;
Pau Espin Pedrol64adf372021-06-28 16:25:47 +02007183 /* ask BSC via VTY to activate a given OSMO style chan as PDCH */
Harald Welte94e0c342018-04-07 11:33:23 +02007184 /* FIXME: no VTY command to activate Osmocom PDCH !! */
7185 /* expect the BSC to issue the related RSL command */
7186 rsl_unused := f_exp_ipa_rx(0, tr_RSL_RF_CHAN_REL(chan_nr));
7187 if (istemplatekind(nack, "omit")) {
7188 /* respond with a related acknowledgement */
7189 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(chan_nr));
7190 } else {
7191 //f_ipa_tx(0, ts_RSL_RF_CHAN_REL_NACK(chan_nr, valueof(nack)));
7192 }
7193}
7194
7195/* Test Osmocom dyn PDCH activation / deactivation triggered by VTY */
7196testcase TC_dyn_pdch_osmo_act_deact() runs on test_CT {
7197 var RSL_Message rsl_unused;
7198
7199 /* change Timeslot 6 before f_init() starts RSL */
7200 f_init_vty();
7201 f_ts_set_chcomb(0, 0, 6, "TCH/F_TCH/H_PDCH");
7202 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
7203
7204 f_init(1, false);
7205 f_sleep(1.0);
7206
7207 var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(6));
7208
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02007209 log("TCH/F_TCH/H_PDCH pchan starts out in disabled mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02007210 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, NONE_MODE);
7211 /* The BSC will activate the dynamic PDCH by default, so confirm that */
7212 rsl_unused := f_exp_ipa_rx(0, tr_RSL_CHAN_ACT_PDCH(chan_nr, ?));
7213
7214 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, 2342));
7215 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02007216 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 +02007217 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, PDCH_MODE);
7218
Neels Hofmeyr887e8f12018-06-27 01:01:55 +02007219 /* clean up config */
7220 f_ts_set_chcomb(0, 0, 6, "PDCH");
7221
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007222 f_shutdown_helper();
Harald Welte94e0c342018-04-07 11:33:23 +02007223}
7224
7225/* Test Osmocom dyn PDCH activation NACK behavior */
7226testcase TC_dyn_pdch_osmo_act_nack() runs on test_CT {
7227 var RSL_Message rsl_unused;
7228
7229 /* change Timeslot 6 before f_init() starts RSL */
7230 f_init_vty();
7231 f_ts_set_chcomb(0, 0, 6, "TCH/F_TCH/H_PDCH");
7232 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
7233
7234 f_init(1, false);
7235 f_sleep(1.0);
7236
7237 var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(6));
7238
7239 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, NONE_MODE);
7240 /* The BSC will activate the dynamic PDCH by default, so confirm that */
7241 rsl_unused := f_exp_ipa_rx(0, tr_RSL_CHAN_ACT_PDCH(chan_nr, ?));
7242
7243 /* NACK this activation and expect the "show timeslot" mode still to be NONE */
7244 f_ipa_tx(0, ts_RSL_CHAN_ACT_NACK(chan_nr, RSL_ERR_EQUIPMENT_FAIL));
7245 f_sleep(1.0);
7246 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, NONE_MODE);
7247
Neels Hofmeyr887e8f12018-06-27 01:01:55 +02007248 /* clean up config */
7249 f_ts_set_chcomb(0, 0, 6, "PDCH");
7250
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007251 f_shutdown_helper();
Harald Welte94e0c342018-04-07 11:33:23 +02007252}
7253
Pau Espin Pedrol5b381082021-06-28 17:14:03 +02007254/* Test Osmocom dyn TS SDCCH8 activation / deactivation */
7255testcase TC_dyn_ts_sdcch8_act_deact() runs on test_CT {
7256 var RSL_Message rsl_unused, rsl_msg;
7257 var DchanTuple dt;
7258 var BSSAP_N_CONNECT_ind rx_c_ind;
7259
7260 /* change Timeslot 6 before f_init() starts RSL */
7261 f_init_vty();
7262 f_ts_set_chcomb(0, 0, 6, "TCH/F_TCH/H_SDCCH8_PDCH");
7263 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
7264
7265 f_init(1, false);
7266 f_sleep(1.0);
7267
7268 var RslChannelNr pdch_chan_nr := valueof(t_RslChanNr_PDCH(6));
7269
7270 log("TCH/F_TCH/H_SDCCH8_PDCH pchan starts out in disabled mode:");
7271 f_ts_dyn_mode_assert(0, 0, pdch_chan_nr.tn, NONE_MODE);
7272 /* The BSC will activate the dynamic PDCH by default, so confirm that */
7273 rsl_unused := f_exp_ipa_rx(0, tr_RSL_CHAN_ACT_PDCH(pdch_chan_nr, ?));
7274
7275 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(pdch_chan_nr, 2342));
7276 f_sleep(1.0);
7277 log("TCH/F_TCH/H_SDCCH8_PDC requested to PDCH ACT on startup, which was ACKed, so now in PDCH:");
7278 f_ts_dyn_mode_assert(0, 0, pdch_chan_nr.tn, PDCH_MODE);
7279
7280 /* Fill TS0 SDCCH channels (NOTE: only 3 SDCCH/4 channels are available
7281 * on CCCH+SDCCH4+CBCH) */
7282 var integer i;
Pau Espin Pedrolce4d5bb2021-10-25 13:31:25 +02007283 for (i := 0; i < NUM_SDCCH_PER_BTS; i := i + 1) {
Pau Espin Pedrol5b381082021-06-28 17:14:03 +02007284 dt := f_est_dchan('23'O, i, '00010203040506'O);
7285 }
7286
7287 /* Now the dyn ts is selected. First PDCH is released, then sdcch chan is activated */
7288 f_ipa_tx(0, ts_RSL_CHAN_RQD(int2oct(oct2int('23'O) + i, 1), 2342));
7289 rsl_unused := f_exp_ipa_rx(0, tr_RSL_RF_CHAN_REL(pdch_chan_nr));
7290 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(pdch_chan_nr));
7291
7292 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
7293 dt.rsl_chan_nr := rsl_msg.ies[0].body.chan_nr;
7294
7295 f_ts_dyn_mode_assert(0, 0, dt.rsl_chan_nr.tn, SDCCH8_MODE);
7296 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(dt.rsl_chan_nr, 2342));
7297 rsl_msg := f_exp_ipa_rx(0, tr_RSL_IMM_ASSIGN(0));
7298 f_ts_dyn_mode_assert(0, 0, dt.rsl_chan_nr.tn, SDCCH8_MODE);
7299
7300 f_ipa_tx(0, ts_RSL_EST_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0)), '1234'O));
7301 BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3('1234'O))) -> value rx_c_ind;
7302 dt.sccp_conn_id := rx_c_ind.connectionId;
7303 BSSAP.send(ts_BSSAP_CONNECT_res(dt.sccp_conn_id));
7304
7305 /* Instruct BSC to clear channel */
7306 var BssmapCause cause := 0;
7307 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
7308 f_exp_chan_rel_and_clear(dt, 0);
7309
7310 /* The BSC will switch the TS back to PDCH once the only lchan using it is released: */
7311 rsl_unused := f_exp_ipa_rx(0, tr_RSL_CHAN_ACT_PDCH(pdch_chan_nr, ?));
7312 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(pdch_chan_nr, 2342));
7313 f_sleep(1.0);
7314 f_ts_dyn_mode_assert(0, 0, pdch_chan_nr.tn, PDCH_MODE);
7315
7316 /* clean up config */
7317 f_ts_set_chcomb(0, 0, 6, "PDCH");
7318
7319 f_shutdown_helper();
7320}
7321
Neels Hofmeyre1a7c4d2021-10-23 23:13:01 +02007322/* Validate all 8 subslots of a dynamics TS configured as SDCCH8 are used */
7323testcase TC_dyn_ts_sdcch8_all_subslots_used() runs on test_CT {
7324 var ASP_RSL_Unitdata rsl_ud;
7325 var integer i;
7326 var integer chreq_total, chreq_nochan;
7327
7328 f_init_vty();
7329 for (i := 1; i < 8; i := i + 1) {
7330 if (i == 2) {
7331 f_ts_set_chcomb(0, 0, i, "TCH/F_TCH/H_SDCCH8_PDCH");
7332 } else {
7333 f_ts_set_chcomb(0, 0, i, "PDCH");
7334 }
7335 }
7336 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
7337
7338 f_init(1);
7339
7340 /* The dyn TS want to activate PDCH mode, ACK that. */
7341 var RslChannelNr chan_nr;
7342 chan_nr := valueof(t_RslChanNr_PDCH(2));
7343 f_exp_ipa_rx(0, tr_RSL_CHAN_ACT_PDCH(chan_nr, ?));
7344 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, 2342));
7345
7346 f_sleep(1.0);
7347
7348 /* Exhaust all dedicated SDCCH lchans.
7349 /* GSM 44.018 Table 9.1.8.2:
7350 * RA = '13'O -> Establishment cause = 0001xxxx (MS dual rate capable and asks for "SDCCH").
7351 */
7352 for (i := 0; i < NUM_SDCCH_PER_BTS; i := i+1) {
7353 f_est_dchan('13'O, NUM_SDCCH_PER_BTS + i, '00010203040506'O);
7354 }
7355
7356 /* Only the dyn TS is still available. Its first lchan gets converted to SDCCH8 */
7357 f_est_dchan_dyn('33'O, NUM_SDCCH_PER_BTS + i, '00010203040506'O);
7358 /* Also occupy the seven other SDCCH of the dyn TS */
7359 for (i := 0; i < 7; i := i+1) {
7360 f_est_dchan('33'O, NUM_SDCCH_PER_BTS + i, '00010203040506'O);
7361 }
7362
7363 /* clean up config */
7364 f_ts_reset_chcomb(0);
7365
7366 f_shutdown_helper();
7367}
7368
Pau Espin Pedrol0953bf82021-07-09 13:20:19 +02007369/* Test Osmocom dyn TS SDCCH8 activation / deactivation: If activating dyn TS as
7370 SDCCH8 would end up in having no free TCH, then BSC should decide to activate
7371 it as TCH directly instead. SYS#5309. */
7372testcase TC_dyn_ts_sdcch8_tch_call_act_deact() runs on test_CT {
7373 var RSL_Message rsl_unused, rsl_msg;
7374 var DchanTuple dt;
7375 var BSSAP_N_CONNECT_ind rx_c_ind;
7376 var integer i;
7377
7378 /* change Timeslot 6 before f_init() starts RSL */
7379 f_init_vty();
7380 for (i := 1; i < 8; i := i + 1) {
7381 if (i == 6) {
7382 f_ts_set_chcomb(0, 0, i, "TCH/F_TCH/H_SDCCH8_PDCH");
7383 } else {
7384 f_ts_set_chcomb(0, 0, i, "PDCH");
7385 }
7386 }
7387 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
7388
7389 f_init(1, false);
7390 f_sleep(1.0);
7391
7392 var RslChannelNr pdch_chan_nr := valueof(t_RslChanNr_PDCH(6));
7393
7394 log("TCH/F_TCH/H_SDCCH8_PDCH pchan starts out in disabled mode:");
7395 f_ts_dyn_mode_assert(0, 0, pdch_chan_nr.tn, NONE_MODE);
7396 /* The BSC will activate the dynamic PDCH by default, so confirm that */
7397 rsl_unused := f_exp_ipa_rx(0, tr_RSL_CHAN_ACT_PDCH(pdch_chan_nr, ?));
7398
7399 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(pdch_chan_nr, 2342));
7400 f_sleep(1.0);
7401 log("TCH/F_TCH/H_SDCCH8_PDC requested to PDCH ACT on startup, which was ACKed, so now in PDCH:");
7402 f_ts_dyn_mode_assert(0, 0, pdch_chan_nr.tn, PDCH_MODE);
7403
7404 /* Fill TS0 SDCCH channels (NOTE: only 3 SDCCH/4 channels are available
7405 * on CCCH+SDCCH4+CBCH) */
Pau Espin Pedrol2ebbe7c2021-07-23 16:17:09 +02007406 var OCT1 ra := '43'O; /* RA containing reason=originating speech call*/
Pau Espin Pedrolce4d5bb2021-10-25 13:31:25 +02007407 for (i := 0; i < NUM_SDCCH_PER_BTS; i := i + 1) {
Pau Espin Pedrol2ebbe7c2021-07-23 16:17:09 +02007408 dt := f_est_dchan(ra, i, '00010203040506'O);
Pau Espin Pedrol0953bf82021-07-09 13:20:19 +02007409 }
7410
7411 /* Now the dyn ts is selected. First PDCH is released, then TCH chan is activated */
Pau Espin Pedrol2ebbe7c2021-07-23 16:17:09 +02007412 f_ipa_tx(0, ts_RSL_CHAN_RQD(int2oct(oct2int(ra) + i, 1), 2342));
Pau Espin Pedrol0953bf82021-07-09 13:20:19 +02007413 rsl_unused := f_exp_ipa_rx(0, tr_RSL_RF_CHAN_REL(pdch_chan_nr));
7414 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(pdch_chan_nr));
7415
7416 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
7417 dt.rsl_chan_nr := rsl_msg.ies[0].body.chan_nr;
7418
7419 f_ts_dyn_mode_assert(0, 0, dt.rsl_chan_nr.tn, TCHH_MODE);
7420 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(dt.rsl_chan_nr, 2342));
7421 rsl_msg := f_exp_ipa_rx(0, tr_RSL_IMM_ASSIGN(0));
7422 f_ts_dyn_mode_assert(0, 0, dt.rsl_chan_nr.tn, TCHH_MODE);
7423
7424 f_ipa_tx(0, ts_RSL_EST_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0)), '1234'O));
7425 BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3('1234'O))) -> value rx_c_ind;
7426 dt.sccp_conn_id := rx_c_ind.connectionId;
7427 BSSAP.send(ts_BSSAP_CONNECT_res(dt.sccp_conn_id));
7428
7429 /* Instruct BSC to clear channel */
7430 var BssmapCause cause := 0;
7431 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
7432 f_exp_chan_rel_and_clear(dt, 0);
7433
7434 /* The BSC will switch the TS back to PDCH once the only lchan using it is released: */
7435 rsl_unused := f_exp_ipa_rx(0, tr_RSL_CHAN_ACT_PDCH(pdch_chan_nr, ?));
7436 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(pdch_chan_nr, 2342));
7437 f_sleep(1.0);
7438 f_ts_dyn_mode_assert(0, 0, pdch_chan_nr.tn, PDCH_MODE);
7439
7440 /* clean up config */
7441 f_ts_reset_chcomb(0);
7442 /* TODO: clean up other channels? */
7443
7444 f_shutdown_helper();
7445}
7446
Pau Espin Pedrolcdf26142021-06-28 17:14:03 +02007447/* Test Osmocom dyn TS SDCCH8 activation / deactivation when SDCCH fails at BTS */
7448testcase TC_dyn_ts_sdcch8_act_nack() runs on test_CT {
7449 var RSL_Message rsl_unused, rsl_msg;
7450 var DchanTuple dt;
7451 var BSSAP_N_CONNECT_ind rx_c_ind;
7452 var GsmRrMessage rr;
7453
7454 /* change Timeslot 6 before f_init() starts RSL */
7455 f_init_vty();
7456 f_ts_set_chcomb(0, 0, 6, "TCH/F_TCH/H_SDCCH8_PDCH");
7457 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
7458
7459 f_init(1, false);
7460 f_sleep(1.0);
7461
7462 var RslChannelNr pdch_chan_nr := valueof(t_RslChanNr_PDCH(6));
7463
7464 log("TCH/F_TCH/H_SDCCH8_PDCH pchan starts out in disabled mode:");
7465 f_ts_dyn_mode_assert(0, 0, pdch_chan_nr.tn, NONE_MODE);
7466 /* The BSC will activate the dynamic PDCH by default, so confirm that */
7467 rsl_unused := f_exp_ipa_rx(0, tr_RSL_CHAN_ACT_PDCH(pdch_chan_nr, ?));
7468
7469 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(pdch_chan_nr, 2342));
7470 f_sleep(1.0);
7471 log("TCH/F_TCH/H_SDCCH8_PDC requested to PDCH ACT on startup, which was ACKed, so now in PDCH:");
7472 f_ts_dyn_mode_assert(0, 0, pdch_chan_nr.tn, PDCH_MODE);
7473
7474 /* Fill TS0 SDCCH channels (NOTE: only 3 SDCCH/4 channels are available
7475 * on CCCH+SDCCH4+CBCH) */
7476 var integer i;
Pau Espin Pedrolce4d5bb2021-10-25 13:31:25 +02007477 for (i := 0; i < NUM_SDCCH_PER_BTS; i := i + 1) {
Pau Espin Pedrolcdf26142021-06-28 17:14:03 +02007478 dt := f_est_dchan('23'O, i, '00010203040506'O);
7479 }
7480
7481 /* Now the dyn ts is selected. First PDCH is released, then sdcch chan is activated */
7482 f_ipa_tx(0, ts_RSL_CHAN_RQD(int2oct(oct2int('23'O) + i, 1), 2342));
7483 rsl_unused := f_exp_ipa_rx(0, tr_RSL_RF_CHAN_REL(pdch_chan_nr));
7484 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(pdch_chan_nr));
7485
7486 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
7487 dt.rsl_chan_nr := rsl_msg.ies[0].body.chan_nr;
7488
7489 f_ts_dyn_mode_assert(0, 0, dt.rsl_chan_nr.tn, SDCCH8_MODE);
7490 f_ipa_tx(0, ts_RSL_CHAN_ACT_NACK(dt.rsl_chan_nr, RSL_ERR_EQUIPMENT_FAIL));
7491 rsl_msg := f_exp_ipa_rx(0, tr_RSL_IMM_ASSIGN(0));
7492 rr := dec_GsmRrMessage(rsl_msg.ies[1].body.full_imm_ass_info.payload);
7493 if (rr.header.message_type != IMMEDIATE_ASSIGNMENT_REJECT) {
7494 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Expected reject");
7495 }
7496
7497 /* FIXME? Currently the TS stays in state BORKEN: */
7498
7499 /* The BSC will switch the TS back to PDCH once the only lchan using it is released: */
7500 /* rsl_unused := f_exp_ipa_rx(0, tr_RSL_CHAN_ACT_PDCH(pdch_chan_nr, ?));
7501 * f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(pdch_chan_nr, 2342));
7502 * f_sleep(1.0);
7503 * f_ts_dyn_mode_assert(0, 0, pdch_chan_nr.tn, PDCH_MODE)
7504 */
7505
7506 /* clean up config */
7507 f_ts_set_chcomb(0, 0, 6, "PDCH");
7508
7509 f_shutdown_helper();
7510}
7511
Stefan Sperling0796a822018-10-05 13:01:39 +02007512testcase TC_chopped_ipa_ping() runs on test_CT {
Stefan Sperling554123f2018-10-09 14:12:30 +02007513 const Integers bsc_ipa_ports := {mp_bsc_rsl_port, mp_bsc_oml_port, mp_bsc_ctrl_port};
Stefan Sperling0796a822018-10-05 13:01:39 +02007514 for (var integer i := 0; i < lengthof(bsc_ipa_ports); i := i + 1) {
7515 IPA_Testing.f_run_TC_chopped_ipa_ping(mp_bsc_ip, bsc_ipa_ports[i], CONNECT_TO_SERVER);
7516 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007517 f_shutdown_helper();
Stefan Sperling0796a822018-10-05 13:01:39 +02007518}
7519
Stefan Sperlingaa1e60f2018-10-15 16:34:07 +02007520testcase TC_chopped_ipa_payload() runs on test_CT {
7521 const Integers bsc_ipa_ports := {mp_bsc_rsl_port, mp_bsc_oml_port
7522 /* TODO: mp_bsc_ctrl_port does not work yet */};
7523 for (var integer i := 0; i < lengthof(bsc_ipa_ports); i := i + 1) {
7524 IPA_Testing.f_run_TC_chopped_ipa_payload(mp_bsc_ip, bsc_ipa_ports[i], CONNECT_TO_SERVER);
7525 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007526 f_shutdown_helper();
Stefan Sperlingaa1e60f2018-10-15 16:34:07 +02007527}
7528
Pau Espin Pedrol8f773632019-11-05 11:46:53 +01007529/* Verify the BSC sends the MS Power Parameters IE during CHAN ACT to make sure
7530 the BTS does autonomous MS power control loop */
7531testcase TC_assignment_verify_ms_power_params_ie() runs on test_CT {
7532 var MSC_ConnHdlr vc_conn;
7533 var TestHdlrParams pars := f_gen_test_hdlr_pars();
7534 //pars.encr := valueof(t_EncrParams('01'O, f_rnd_octstring(8)));
7535 pars.exp_ms_power_params := true;
7536
7537 f_init(1, true);
7538 f_sleep(1.0);
7539 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5), pars);
7540 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007541 f_shutdown_helper();
Pau Espin Pedrol8f773632019-11-05 11:46:53 +01007542}
Stefan Sperlingaa1e60f2018-10-15 16:34:07 +02007543
Vadim Yanitskiy4b233042021-06-30 00:58:43 +02007544/* Verify activation and deactivation of the BCCH carrier power reduction mode */
7545testcase TC_c0_power_red_mode() runs on test_CT {
7546 f_init(1);
7547
7548 for (var integer red := 6; red >= 0; red := red - 2) {
7549 /* Configure BCCH carrier power reduction mode via the VTY */
7550 f_vty_transceive(BSCVTY, "bts 0 c0-power-reduction " & int2str(red));
7551
7552 /* Expect Osmocom specific BS Power Control message on the RSL */
7553 var template RSL_Message tr_rsl_pdu := tr_RSL_BS_PWR_CTRL(
7554 chan_nr := t_RslChanNr_BCCH(0),
7555 bs_power := tr_RSL_IE_BS_Power(red / 2));
7556 tr_rsl_pdu.msg_disc := tr_RSL_MsgDisc(RSL_MDISC_CCHAN, false);
7557 var RSL_Message unused := f_exp_ipa_rx(0, tr_rsl_pdu);
7558
7559 /* Additionally verify the applied value over the CTRL interface */
7560 var CtrlValue cred := f_ctrl_get_bts(IPA_CTRL, 0, "c0-power-reduction");
7561 if (cred != int2str(red)) {
7562 setverdict(fail, "Unexpected BCCH carrier power reduction value ",
7563 cred, " (expected ", red, ")");
7564 }
7565 }
7566
7567 f_shutdown_helper();
7568}
7569
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007570/***********************************************************************
7571 * MSC Pooling
7572 ***********************************************************************/
7573
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007574template MobileIdentityLV ts_MI_TMSI_NRI_LV(integer nri_v, integer nri_bitlen := 10) :=
Harald Weltebf397612021-01-14 20:39:46 +01007575 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 +02007576
Neels Hofmeyr85bcd272021-07-22 19:14:48 +02007577private 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 +02007578runs on MSC_ConnHdlr {
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02007579 interleave {
Neels Hofmeyr85bcd272021-07-22 19:14:48 +02007580 [] rsl_pt.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch exp_rr_rel_tmpl)) {
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02007581 f_logp(BSCVTY, "Got RSL RR Release");
7582 }
Neels Hofmeyr85bcd272021-07-22 19:14:48 +02007583 [] rsl_pt.receive(tr_RSL_DEACT_SACCH(g_chan_nr)) {
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02007584 f_logp(BSCVTY, "Got RSL Deact SACCH");
7585 }
Neels Hofmeyr3c5127e2021-07-22 19:18:40 +02007586 [] rsl_pt.receive(tr_RSL_RF_CHAN_REL(g_chan_nr)) {
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02007587 f_logp(BSCVTY, "Got RSL RF Chan Rel, sending Rel Ack");
Neels Hofmeyr85bcd272021-07-22 19:14:48 +02007588 rsl_pt.send(ts_RSL_RF_CHAN_REL_ACK(g_chan_nr));
7589 f_rslem_unregister(0, g_chan_nr, PT := rsl_proc_pt);
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02007590 break;
7591 }
7592 }
7593}
7594
Neels Hofmeyr85bcd272021-07-22 19:14:48 +02007595friend function f_perform_clear(RSL_DCHAN_PT rsl_pt := RSL, RSLEM_PROC_PT rsl_proc_pt := RSL_PROC,
7596 template PDU_ML3_NW_MS exp_rr_rel_tmpl := tr_RRM_RR_RELEASE)
Pau Espin Pedrolc08d5522021-04-16 15:40:38 +02007597runs on MSC_ConnHdlr {
Neels Hofmeyr767548a2020-08-09 20:26:07 +00007598 f_logp(BSCVTY, "MSC instructs BSC to clear channel");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007599 BSSAP.send(ts_BSSMAP_ClearCommand(0));
7600 interleave {
Neels Hofmeyr85bcd272021-07-22 19:14:48 +02007601 [] rsl_pt.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch exp_rr_rel_tmpl)) {
Neels Hofmeyr767548a2020-08-09 20:26:07 +00007602 f_logp(BSCVTY, "Got RSL RR Release");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007603 }
Neels Hofmeyr85bcd272021-07-22 19:14:48 +02007604 [] rsl_pt.receive(tr_RSL_DEACT_SACCH(g_chan_nr)) {
Neels Hofmeyr767548a2020-08-09 20:26:07 +00007605 f_logp(BSCVTY, "Got RSL Deact SACCH");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007606 }
7607 [] BSSAP.receive(tr_BSSMAP_ClearComplete) {
Neels Hofmeyr767548a2020-08-09 20:26:07 +00007608 f_logp(BSCVTY, "Got BSSMAP Clear Complete");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007609 /* Also drop the SCCP connection */
7610 BSSAP.send(RAN_Conn_Prim:MSC_CONN_PRIM_DISC_REQ);
7611 }
Neels Hofmeyr3c5127e2021-07-22 19:18:40 +02007612 [] rsl_pt.receive(tr_RSL_RF_CHAN_REL(g_chan_nr)) {
Neels Hofmeyr767548a2020-08-09 20:26:07 +00007613 f_logp(BSCVTY, "Got RSL RF Chan Rel, sending Rel Ack");
Neels Hofmeyr85bcd272021-07-22 19:14:48 +02007614 rsl_pt.send(ts_RSL_RF_CHAN_REL_ACK(g_chan_nr));
7615 f_rslem_unregister(0, g_chan_nr, PT := rsl_proc_pt);
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007616 }
7617 }
7618}
7619
Neels Hofmeyr85bcd272021-07-22 19:14:48 +02007620private function f_perform_compl_l3(RSL_DCHAN_PT rsl_pt, RSLEM_PROC_PT rsl_proc_pt,
7621 template PDU_ML3_MS_NW l3_info, boolean do_clear := true, boolean expect_bssmap_l3 := true)
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007622runs on MSC_ConnHdlr {
7623 timer T := 10.0;
7624 var octetstring l3_enc := enc_PDU_ML3_MS_NW(valueof(l3_info));
7625
Neels Hofmeyr767548a2020-08-09 20:26:07 +00007626 f_logp(BSCVTY, "establish channel, send Complete Layer 3 Info");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007627 f_create_bssmap_exp(l3_enc);
7628
Neels Hofmeyr85bcd272021-07-22 19:14:48 +02007629 /* RSL_Emulation.f_chan_est() on rsl_pt:
7630 * This is basically code dup with s/RSL/rsl_pt from:
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007631 * RSL_Emulation.f_chan_est(g_pars.ra, l3_enc, g_pars.link_id, g_pars.fn);
7632 */
7633 var RSL_Message rx_rsl;
7634 var GsmRrMessage rr;
7635
7636 /* request a channel to be established */
Neels Hofmeyr85bcd272021-07-22 19:14:48 +02007637 rsl_pt.send(ts_RSLDC_ChanRqd(g_pars.ra, g_pars.fn));
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007638 /* expect immediate assignment.
Neels Hofmeyr85bcd272021-07-22 19:14:48 +02007639 * Code dup with s/RSL/rsl_pt from:
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007640 * rx_rsl := f_rx_or_fail(tr_RSL_IMM_ASSIGN);
7641 */
7642 timer Tt := 10.0;
7643
7644 /* request a channel to be established */
7645 Tt.start;
7646 alt {
Neels Hofmeyr85bcd272021-07-22 19:14:48 +02007647 [] rsl_pt.receive(tr_RSL_IMM_ASSIGN) -> value rx_rsl {
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007648 Tt.stop;
7649 }
Neels Hofmeyr85bcd272021-07-22 19:14:48 +02007650 [] rsl_pt.receive {
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007651 setverdict(fail, "Unexpected RSL message on DCHAN");
7652 mtc.stop;
7653 }
7654 [] Tt.timeout {
7655 setverdict(fail, "Timeout waiting for RSL on DCHAN");
7656 mtc.stop;
7657 }
7658 }
7659 rr := dec_GsmRrMessage(rx_rsl.ies[1].body.full_imm_ass_info.payload);
7660 g_chan_nr := rr.payload.imm_ass.chan_desc.chan_nr;
Neels Hofmeyr85bcd272021-07-22 19:14:48 +02007661 rsl_pt.send(ts_RSL_EST_IND(g_chan_nr, valueof(g_pars.link_id), l3_enc));
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007662
7663
Neels Hofmeyr66e15092020-10-12 18:44:41 +00007664 if (expect_bssmap_l3) {
7665 f_logp(BSCVTY, "expect BSSAP Complete Layer 3 Info at MSC");
7666 var template PDU_BSSAP exp_l3_compl;
7667 exp_l3_compl := tr_BSSMAP_ComplL3()
7668 if (g_pars.aoip == false) {
7669 exp_l3_compl.pdu.bssmap.completeLayer3Information.codecList := omit;
7670 } else {
7671 exp_l3_compl.pdu.bssmap.completeLayer3Information.codecList := ?;
7672 }
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007673
Neels Hofmeyr66e15092020-10-12 18:44:41 +00007674 var PDU_BSSAP bssap;
7675 T.start;
7676 alt {
7677 [] BSSAP.receive(exp_l3_compl) -> value bssap {
7678 f_logp(BSCVTY, "received expected Complete Layer 3 Info at MSC");
7679 log("rx exp_l3_compl = ", bssap);
7680 }
7681 [] BSSAP.receive(tr_BSSMAP_ComplL3) {
7682 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Received non-matching COMPLETE LAYER 3 INFORMATION");
7683 }
7684 [] T.timeout {
7685 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for COMPLETE LAYER 3 INFORMATION");
7686 }
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007687 }
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007688
Neels Hofmeyr66e15092020-10-12 18:44:41 +00007689 /* start ciphering, if requested */
7690 if (ispresent(g_pars.encr)) {
7691 f_logp(BSCVTY, "start ciphering");
Neels Hofmeyr85bcd272021-07-22 19:14:48 +02007692 f_cipher_mode(g_pars.encr, rsl_pt := rsl_pt, rsl_proc_pt := rsl_proc_pt);
Neels Hofmeyr66e15092020-10-12 18:44:41 +00007693 }
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007694 }
7695
7696 if (do_clear) {
Neels Hofmeyr85bcd272021-07-22 19:14:48 +02007697 f_perform_clear(rsl_pt, rsl_proc_pt);
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007698 }
7699 setverdict(pass);
7700 f_sleep(1.0);
7701}
7702
7703private function f_tc_mscpool_compl_l3(charstring id) runs on MSC_ConnHdlr {
7704 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
7705 if (g_pars.mscpool.rsl_idx == 0) {
Neels Hofmeyr85bcd272021-07-22 19:14:48 +02007706 f_perform_compl_l3(RSL, RSL_PROC, g_pars.mscpool.l3_info);
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007707 } else if (g_pars.mscpool.rsl_idx == 1) {
Neels Hofmeyr85bcd272021-07-22 19:14:48 +02007708 f_perform_compl_l3(RSL1, RSL1_PROC, g_pars.mscpool.l3_info);
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007709 } else if (g_pars.mscpool.rsl_idx == 2) {
Neels Hofmeyr85bcd272021-07-22 19:14:48 +02007710 f_perform_compl_l3(RSL2, RSL2_PROC, g_pars.mscpool.l3_info);
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007711 }
7712}
7713
7714/* Various Complete Layer 3 by IMSI all end up with the first MSC, because the other MSCs are not connected. */
7715private function f_tc_mscpool_L3Compl_on_1_msc(charstring id) runs on MSC_ConnHdlr {
7716 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
Neels Hofmeyr85bcd272021-07-22 19:14:48 +02007717 f_perform_compl_l3(RSL, RSL_PROC, ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_IMSI_LV('001010000000001'H)), '00F110'O) );
7718 f_perform_compl_l3(RSL, RSL_PROC, ts_CM_SERV_REQ(CM_TYPE_MO_SMS, valueof(ts_MI_IMSI_LV('001010000000002'H))) );
7719 f_perform_compl_l3(RSL, RSL_PROC, ts_PAG_RESP(valueof(ts_MI_IMSI_LV('001010000000003'H))) );
7720 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 +02007721}
7722testcase TC_mscpool_L3Compl_on_1_msc() runs on test_CT {
7723
7724 f_init(1, true);
7725 f_sleep(1.0);
7726 var MSC_ConnHdlr vc_conn;
7727 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007728
7729 f_ctrs_msc_init();
7730
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007731 vc_conn := f_start_handler(refers(f_tc_mscpool_L3Compl_on_1_msc), pars);
7732 vc_conn.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007733
7734 f_ctrs_msc_expect(0, "mscpool:subscr:new", 4);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007735 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007736}
7737
7738/* Three Layer 3 Complete by IMSI are round-robin'ed across two connected MSCs */
7739/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
7740 * just as well using only RSL. */
7741testcase TC_mscpool_L3Complete_by_imsi_round_robin() runs on test_CT {
7742
7743 f_init(nr_bts := 3, handler_mode := true, nr_msc := 2);
7744 f_sleep(1.0);
7745
7746 /* Control which MSC gets chosen next by the round-robin, otherwise
7747 * would be randomly affected by which other tests ran before this. */
7748 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
7749
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007750 f_ctrs_msc_init();
7751
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007752 var MSC_ConnHdlr vc_conn1;
7753 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
7754 pars1.mscpool.rsl_idx := 0;
7755 pars1.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_IMSI_LV('001010000000001'H)), '00F110'O));
7756 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
7757 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007758 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007759
7760 var MSC_ConnHdlr vc_conn2;
7761 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 1);
7762 pars2.mscpool.rsl_idx := 1;
7763 pars2.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, valueof(ts_MI_IMSI_LV('001010000000002'H))));
7764 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
7765 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007766 f_ctrs_msc_expect(1, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007767
7768 /* Test round-robin wrap to the first MSC */
7769 var MSC_ConnHdlr vc_conn3;
7770 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 0);
7771 pars3.mscpool.rsl_idx := 2;
7772 pars3.mscpool.l3_info := valueof(ts_PAG_RESP(valueof(ts_MI_IMSI_LV('001010000000003'H))));
7773 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
7774 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007775 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007776 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007777}
7778
7779/* Three LU by TMSI are round-robin'ed across two connected MSCs, because they contain the NULL-NRI 0
7780 * (configured in osmo-bsc.cfg). */
7781/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
7782 * just as well using only RSL. */
7783testcase TC_mscpool_LU_by_tmsi_null_nri_0_round_robin() runs on test_CT {
7784
7785 f_init(nr_bts := 3, handler_mode := true, nr_msc := 2);
7786 f_sleep(1.0);
7787
7788 /* Control which MSC gets chosen next by the round-robin, otherwise
7789 * would be randomly affected by which other tests ran before this. */
7790 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
7791
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007792 f_ctrs_msc_init();
7793
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007794 var MSC_ConnHdlr vc_conn1;
7795 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
7796 pars1.mscpool.rsl_idx := 0;
7797 pars1.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(0)), '00F110'O));
7798 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
7799 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007800 f_ctrs_msc_expect(0, "mscpool:subscr:reattach");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007801
7802 var MSC_ConnHdlr vc_conn2;
7803 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 1);
7804 pars2.mscpool.rsl_idx := 1;
7805 pars2.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(0)), '00F110'O));
7806 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
7807 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007808 f_ctrs_msc_expect(1, "mscpool:subscr:reattach");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007809
7810 /* Test round-robin wrap to the first MSC */
7811 var MSC_ConnHdlr vc_conn3;
7812 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 0);
7813 pars3.mscpool.rsl_idx := 2;
7814 pars3.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(0)), '00F110'O));
7815 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
7816 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007817 f_ctrs_msc_expect(0, "mscpool:subscr:reattach");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007818 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007819}
7820
7821/* Three LU by TMSI are round-robin'ed across two connected MSCs, because they contain the NULL-NRI 1
7822 * (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
7823 * NULL-NRI setting is stronger than that. */
7824/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
7825 * just as well using only RSL. */
7826testcase TC_mscpool_LU_by_tmsi_null_nri_1_round_robin() runs on test_CT {
7827
7828 f_init(nr_bts := 3, handler_mode := true, nr_msc := 2);
7829 f_sleep(1.0);
7830
7831 /* Control which MSC gets chosen next by the round-robin, otherwise
7832 * would be randomly affected by which other tests ran before this. */
7833 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
7834
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007835 f_ctrs_msc_init();
7836
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007837 var MSC_ConnHdlr vc_conn1;
7838 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
7839 pars1.mscpool.rsl_idx := 0;
7840 pars1.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(1)), '00F110'O));
7841 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
7842 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007843 f_ctrs_msc_expect(0, "mscpool:subscr:reattach");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007844
7845 var MSC_ConnHdlr vc_conn2;
7846 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 1);
7847 pars2.mscpool.rsl_idx := 1;
7848 pars2.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(1)), '00F110'O));
7849 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
7850 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007851 f_ctrs_msc_expect(1, "mscpool:subscr:reattach");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007852
7853 /* Test round-robin wrap to the first MSC */
7854 var MSC_ConnHdlr vc_conn3;
7855 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 0);
7856 pars3.mscpool.rsl_idx := 2;
7857 pars3.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(1)), '00F110'O));
7858 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
7859 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007860 f_ctrs_msc_expect(0, "mscpool:subscr:reattach");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007861 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007862}
7863
7864/* Three Layer 3 Complete by TMSI are round-robin'ed across two connected MSCs, because they contain an NRI not
7865 * assigned to any MSC (configured in osmo-bsc.cfg). */
7866/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
7867 * just as well using only RSL. */
7868testcase TC_mscpool_L3Complete_by_tmsi_unassigned_nri_round_robin() runs on test_CT {
7869
7870 f_init(nr_bts := 3, handler_mode := true, nr_msc := 2);
7871 f_sleep(1.0);
7872
7873 /* Control which MSC gets chosen next by the round-robin, otherwise
7874 * would be randomly affected by which other tests ran before this. */
7875 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
7876
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007877 f_ctrs_msc_init();
7878
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007879 var MSC_ConnHdlr vc_conn1;
7880 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
7881 pars1.mscpool.rsl_idx := 0;
7882 /* An NRI that is not assigned to any MSC */
7883 pars1.mscpool.l3_info := valueof(ts_ML3_MO_MM_IMSI_DET_Ind(valueof(ts_MI_TMSI_NRI_LV(1023))));
7884 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
7885 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007886 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007887
7888 var MSC_ConnHdlr vc_conn2;
7889 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 1);
7890 pars2.mscpool.rsl_idx := 1;
7891 /* An NRI that is not assigned to any MSC */
7892 pars2.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(768)), '00F110'O));
7893 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
7894 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007895 f_ctrs_msc_expect(1, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007896
7897 /* Test round-robin wrap to the first MSC */
7898 var MSC_ConnHdlr vc_conn3;
7899 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 0);
7900 pars3.mscpool.rsl_idx := 2;
7901 /* An NRI that is not assigned to any MSC */
7902 pars3.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_SS_ACT, valueof(ts_MI_TMSI_NRI_LV(819))));
7903 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
7904 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007905 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007906 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007907}
7908
7909/* Three Layer 3 Complete by TMSI are round-robin'ed across two connected MSCs, because they contain an NRI
7910 * assigned to an MSC that is currently not connected (configured in osmo-bsc.cfg). */
7911/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
7912 * just as well using only RSL. */
7913testcase TC_mscpool_L3Complete_by_tmsi_valid_nri_msc_not_connected_round_robin() runs on test_CT {
7914
7915 f_init(nr_bts := 3, handler_mode := true, nr_msc := 2);
7916 f_sleep(1.0);
7917
7918 /* Control which MSC gets chosen next by the round-robin, otherwise
7919 * would be randomly affected by which other tests ran before this. */
7920 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
7921
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007922 f_ctrs_msc_init();
7923
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007924 var MSC_ConnHdlr vc_conn1;
7925 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
7926 pars1.mscpool.rsl_idx := 0;
7927 /* An NRI that is assigned to an unconnected MSC */
7928 pars1.mscpool.l3_info := valueof(ts_PAG_RESP(valueof(ts_MI_TMSI_NRI_LV(512))));
7929 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
7930 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007931 f_ctrs_msc_add(2, "mscpool:subscr:attach_lost");
7932 f_ctrs_msc_add(0, "mscpool:subscr:new");
7933 f_ctrs_msc_verify();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007934
7935 var MSC_ConnHdlr vc_conn2;
7936 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 1);
7937 pars2.mscpool.rsl_idx := 1;
7938 /* An NRI that is assigned to an unconnected MSC */
7939 pars2.mscpool.l3_info := valueof(ts_ML3_MO_MM_IMSI_DET_Ind(valueof(ts_MI_TMSI_NRI_LV(767))));
7940 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
7941 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007942 f_ctrs_msc_add(2, "mscpool:subscr:attach_lost");
7943 f_ctrs_msc_add(1, "mscpool:subscr:new");
7944 f_ctrs_msc_verify();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007945
7946 /* Test round-robin wrap to the first MSC */
7947 var MSC_ConnHdlr vc_conn3;
7948 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 0);
7949 pars3.mscpool.rsl_idx := 2;
7950 /* An NRI that is assigned to an unconnected MSC */
7951 pars3.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(750)), '00F110'O));
7952 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
7953 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007954 f_ctrs_msc_add(2, "mscpool:subscr:attach_lost");
7955 f_ctrs_msc_add(0, "mscpool:subscr:new");
7956 f_ctrs_msc_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007957 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007958}
7959
7960/* Three Layer 3 Complete by TMSI with valid NRI for the second MSC are all directed to the second MSC (configured in
7961 * osmo-bsc.cfg). */
7962/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
7963 * just as well using only RSL. */
7964testcase TC_mscpool_L3Complete_by_tmsi_valid_nri_1() runs on test_CT {
7965
7966 f_init(nr_bts := 3, handler_mode := true, nr_msc := 2);
7967 f_sleep(1.0);
7968
7969 /* All TMSIs in this test point at the second MSC, set the round robin to point at the first MSC to make sure
7970 * this is not using round-robin. */
7971 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
7972
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007973 f_ctrs_msc_init();
7974
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007975 var MSC_ConnHdlr vc_conn1;
7976 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 1);
7977 pars1.mscpool.rsl_idx := 0;
7978 /* An NRI of the second MSC's range (256-511) */
7979 pars1.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_SMS, valueof(ts_MI_TMSI_NRI_LV(256))));
7980 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
7981 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007982 f_ctrs_msc_expect(1, "mscpool:subscr:known");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007983
7984 var MSC_ConnHdlr vc_conn2;
7985 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 1);
7986 pars2.mscpool.rsl_idx := 1;
7987 /* An NRI of the second MSC's range (256-511) */
7988 pars2.mscpool.l3_info := valueof(ts_PAG_RESP(valueof(ts_MI_TMSI_NRI_LV(260))));
7989 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
7990 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007991 f_ctrs_msc_expect(1, "mscpool:subscr:known");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007992
7993 var MSC_ConnHdlr vc_conn3;
7994 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 1);
7995 pars3.mscpool.rsl_idx := 2;
7996 /* An NRI of the second MSC's range (256-511) */
7997 pars3.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(511)), '00F110'O));
7998 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
7999 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02008000 f_ctrs_msc_expect(1, "mscpool:subscr:known");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02008001 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02008002}
8003
8004/* Layer 3 Complete by TMSI with valid NRI for the third MSC are directed to the third MSC (configured in osmo-bsc.cfg),
8005 * while a round-robin remains unaffected by that. */
8006/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
8007 * just as well using only RSL. */
8008testcase TC_mscpool_L3Complete_by_tmsi_valid_nri_2() runs on test_CT {
8009
8010 f_init(nr_bts := 3, handler_mode := true, nr_msc := 3);
8011 f_sleep(1.0);
8012
8013 /* All TMSIs in this test point at the third MSC, set the round robin to point at the second MSC to make sure
8014 * this is not using round-robin. */
8015 f_vty_transceive(BSCVTY, "mscpool roundrobin next 1");
8016
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02008017 f_ctrs_msc_init();
8018
Neels Hofmeyr4f118412020-06-04 15:25:10 +02008019 var MSC_ConnHdlr vc_conn1;
8020 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 2);
8021 pars1.mscpool.rsl_idx := 0;
8022 /* An NRI of the third MSC's range (512-767) */
8023 pars1.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_SMS, valueof(ts_MI_TMSI_NRI_LV(512))));
8024 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
8025 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02008026 f_ctrs_msc_expect(2, "mscpool:subscr:known");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02008027
8028 var MSC_ConnHdlr vc_conn2;
8029 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 2);
8030 pars2.mscpool.rsl_idx := 1;
8031 /* An NRI of the third MSC's range (512-767) */
8032 pars2.mscpool.l3_info := valueof(ts_PAG_RESP(valueof(ts_MI_TMSI_NRI_LV(678))));
8033 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
8034 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02008035 f_ctrs_msc_expect(2, "mscpool:subscr:known");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02008036
8037 /* The above forwardings to third MSC have not affected the round robin, which still points at the second MSC */
8038 var MSC_ConnHdlr vc_conn3;
8039 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 1);
8040 pars3.mscpool.rsl_idx := 2;
8041 pars3.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_IMSI_LV('001010000000013'H)), '00F110'O));
8042 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
8043 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02008044 f_ctrs_msc_expect(1, "mscpool:subscr:new");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02008045 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02008046}
8047
8048/* LU with a TMSI but indicating a different PLMN in its previous LAI: ignore the NRI. */
8049/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
8050 * just as well using only RSL. */
8051testcase TC_mscpool_LU_by_tmsi_from_other_PLMN() runs on test_CT {
8052
8053 f_init(nr_bts := 3, handler_mode := true, nr_msc := 3);
8054 f_sleep(1.0);
8055
8056 /* The TMSIs in this test points at the second MSC, but since it is from a different PLMN, round-robin is used
8057 * instead, and hits msc 0. */
8058 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
8059
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02008060 f_ctrs_msc_init();
8061
Neels Hofmeyr4f118412020-06-04 15:25:10 +02008062 /* An NRI of the second MSC's range (256-511), but a PLMN that doesn't match with osmo-bsc.cfg */
8063 var MSC_ConnHdlr vc_conn1;
8064 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
8065 pars1.mscpool.rsl_idx := 0;
8066 pars1.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(260)), '99F999'O));
8067 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
8068 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02008069 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02008070
8071 /* An NRI of the third MSC's range (512-767) and a matching PLMN gets directed by NRI. */
8072 var MSC_ConnHdlr vc_conn2;
8073 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 2);
8074 pars2.mscpool.rsl_idx := 1;
8075 pars2.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(555)), '00F110'O));
8076 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
8077 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02008078 f_ctrs_msc_expect(2, "mscpool:subscr:known");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02008079 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02008080}
8081
8082/* Make sure that whichever MSC paged a subscriber will also get the Paging Response. Page by IMSI, which would be
8083 * round-robined to another MSC, to make sure the Paging->Response relation is stronger than the NRI->MSC mapping. */
8084private function f_tc_mscpool_paging_imsi(charstring id) runs on MSC_ConnHdlr {
8085 var template BSSMAP_FIELD_CellIdentificationList cid_list := { cIl_CI := { ts_BSSMAP_CI_CI(0) } };
8086 //cid_list := { cIl_allInBSS := ''O };
8087 var RSL_ChanNeeded rsl_chneed := RSL_CHANNEED_SDCCH;
8088 var template BSSMAP_IE_ChannelNeeded bssmap_chneed := ts_BSSMAP_IE_ChanNeeded(int2bit(enum2int(valueof(rsl_chneed)),2));
8089 var BSSAP_N_UNITDATA_req paging;
8090 var hexstring imsi := '001010000000123'H;
8091
8092 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
8093
Neels Hofmeyr90f80962020-06-12 16:16:55 +02008094 paging := valueof(ts_BSSAP_UNITDATA_req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyr4f118412020-06-04 15:25:10 +02008095 valueof(ts_BSSMAP_Paging(imsi, cid_list, omit, bssmap_chneed))));
8096 BSSAP.send(paging);
8097
8098 /* Register any RSL conn so that the Paging Command gets received here. With the current RSL_Emulation's main()
8099 * handling of '[bts_role] IPA_PT.receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD()))' it doesn't matter at all which
8100 * channel number is picked here. */
8101 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(0, RSL_CHAN_NR_INVALID));
8102 f_rslem_register(0, new_chan_nr);
8103 RSL.receive(tr_RSL_PAGING_CMD(tr_MI_IMSI(imsi)));
8104 f_rslem_unregister(0, new_chan_nr);
8105
8106 /* Despite the round robin pointing at the second MSC ('roundrobin next 1'), the earlier Paging for the same IMSI
8107 * causes this Paging Response to go to the first MSC (bssap_idx := 0). */
Neels Hofmeyr85bcd272021-07-22 19:14:48 +02008108 f_perform_compl_l3(RSL, RSL_PROC, ts_PAG_RESP(valueof(ts_MI_IMSI_LV(imsi))) );
Neels Hofmeyr4f118412020-06-04 15:25:10 +02008109 f_sleep(1.0);
8110}
8111testcase TC_mscpool_paging_and_response_imsi() runs on test_CT {
8112 f_init(nr_bts := 1, handler_mode := true, nr_msc := 3);
8113 f_sleep(1.0);
8114
8115 /* Testing a Paging on the first MSC to get a Paging Response back to the first MSC. Set round robin to the
8116 * second MSC to make sure we're getting the Paging logic, not a coincidental round robin match. */
8117 f_vty_transceive(BSCVTY, "mscpool roundrobin next 1");
8118
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02008119 f_ctrs_msc_init();
8120
Neels Hofmeyr4f118412020-06-04 15:25:10 +02008121 var MSC_ConnHdlr vc_conn1;
8122 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
8123 pars1.mscpool.rsl_idx := 0;
Neels Hofmeyr90f80962020-06-12 16:16:55 +02008124 pars1.sccp_addr_bsc := g_bssap[pars1.mscpool.bssap_idx].sccp_addr_peer;
8125 pars1.sccp_addr_msc := g_bssap[pars1.mscpool.bssap_idx].sccp_addr_own;
Neels Hofmeyr4f118412020-06-04 15:25:10 +02008126 vc_conn1 := f_start_handler(refers(f_tc_mscpool_paging_imsi), pars1);
8127 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02008128 f_ctrs_msc_expect(0, "mscpool:subscr:paged");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02008129 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02008130}
8131
8132/* Make sure that whichever MSC paged a subscriber will also get the Paging Response. Page by TMSI with an NRI value
8133 * that matches a different MSC, to make sure the Paging->Response relation is stronger than the NRI->MSC mapping. */
8134private function f_tc_mscpool_paging_tmsi(charstring id) runs on MSC_ConnHdlr {
8135 var template BSSMAP_FIELD_CellIdentificationList cid_list := { cIl_CI := { ts_BSSMAP_CI_CI(0) } };
8136 //cid_list := { cIl_allInBSS := ''O };
8137 var RSL_ChanNeeded rsl_chneed := RSL_CHANNEED_SDCCH;
8138 var template BSSMAP_IE_ChannelNeeded bssmap_chneed := ts_BSSMAP_IE_ChanNeeded(int2bit(enum2int(valueof(rsl_chneed)),2));
8139 var integer nri_v := 300; /* <-- second MSC's NRI */
Harald Weltebf397612021-01-14 20:39:46 +01008140 var octetstring tmsi := f_gen_tmsi(suffix := 0, nri_v := nri_v);
Neels Hofmeyr4f118412020-06-04 15:25:10 +02008141 var BSSAP_N_UNITDATA_req paging;
8142
8143 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
8144
Neels Hofmeyr90f80962020-06-12 16:16:55 +02008145 paging := valueof(ts_BSSAP_UNITDATA_req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyr4f118412020-06-04 15:25:10 +02008146 valueof(ts_BSSMAP_Paging('001010000000011'H, cid_list, tmsi, bssmap_chneed))));
8147 BSSAP.send(paging);
8148
8149 /* Register any RSL conn so that the Paging Command gets received here. With the current RSL_Emulation's main()
8150 * handling of '[bts_role] IPA_PT.receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD()))' it doesn't matter at all which
8151 * channel number is picked here. */
8152 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(0, RSL_CHAN_NR_INVALID));
8153 f_rslem_register(0, new_chan_nr);
8154 RSL.receive(tr_RSL_PAGING_CMD(t_MI_TMSI(tmsi)));
8155 f_rslem_unregister(0, new_chan_nr);
8156
8157 /* Despite the NRI matching the second MSC (NRI from 'msc 1' in osmo-bsc.cfg) and round robin pointing at the
8158 * third MSC ('roundrobin next 2'), the earlier Paging for the same TMSI causes this Paging Response to go to
8159 * the first MSC (bssap_idx := 0). */
Neels Hofmeyr85bcd272021-07-22 19:14:48 +02008160 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 +02008161 f_sleep(1.0);
8162}
8163testcase TC_mscpool_paging_and_response_tmsi() runs on test_CT {
8164 f_init(nr_bts := 1, handler_mode := true, nr_msc := 3);
8165 f_sleep(1.0);
8166
8167 /* Testing a Paging on the first MSC to get a Paging Response back to the first MSC. Set round robin to the
8168 * third MSC to make sure we're getting the Paging logic, not a coincidental round robin match. */
8169 f_vty_transceive(BSCVTY, "mscpool roundrobin next 2");
8170
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02008171 f_ctrs_msc_init();
8172
Neels Hofmeyr4f118412020-06-04 15:25:10 +02008173 var MSC_ConnHdlr vc_conn1;
8174 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
8175 pars1.mscpool.rsl_idx := 0;
Neels Hofmeyr90f80962020-06-12 16:16:55 +02008176 pars1.sccp_addr_bsc := g_bssap[pars1.mscpool.bssap_idx].sccp_addr_peer;
8177 pars1.sccp_addr_msc := g_bssap[pars1.mscpool.bssap_idx].sccp_addr_own;
Neels Hofmeyr4f118412020-06-04 15:25:10 +02008178 vc_conn1 := f_start_handler(refers(f_tc_mscpool_paging_tmsi), pars1);
8179 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02008180 f_ctrs_msc_expect(0, "mscpool:subscr:paged");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02008181 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02008182}
8183
8184/* For round-robin, skip an MSC that has 'no allow-attach' set. */
8185/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
8186 * just as well using only RSL. */
8187testcase TC_mscpool_no_allow_attach_round_robin() runs on test_CT {
8188
8189 f_init(nr_bts := 3, handler_mode := true, nr_msc := 3);
8190 f_sleep(1.0);
Neels Hofmeyra460f1f2020-08-09 20:17:03 +00008191 /* Mark the second MSC as offloading, round-robin should skip this MSC now. */
8192 f_vty_msc_allow_attach(BSCVTY, {true, false, true});
Neels Hofmeyr4f118412020-06-04 15:25:10 +02008193
8194 /* Control which MSC gets chosen next by the round-robin, otherwise
8195 * would be randomly affected by which other tests ran before this. */
8196 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
8197
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02008198 f_ctrs_msc_init();
8199
Neels Hofmeyr4f118412020-06-04 15:25:10 +02008200 var MSC_ConnHdlr vc_conn1;
8201 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
8202 pars1.mscpool.rsl_idx := 0;
8203 pars1.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_IMSI_LV('001010000000001'H)), '00F110'O));
8204 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
8205 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02008206 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02008207
8208 var MSC_ConnHdlr vc_conn2;
8209 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 2);
8210 pars2.mscpool.rsl_idx := 1;
8211 pars2.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, valueof(ts_MI_IMSI_LV('001010000000002'H))));
8212 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
8213 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02008214 f_ctrs_msc_expect(2, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02008215
8216 var MSC_ConnHdlr vc_conn3;
8217 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 0);
8218 pars3.mscpool.rsl_idx := 2;
8219 pars3.mscpool.l3_info := valueof(ts_PAG_RESP(valueof(ts_MI_IMSI_LV('001010000000003'H))));
8220 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
8221 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02008222 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02008223 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02008224}
8225
8226/* An MSC that has 'no allow-attach' set should still serve subscribers that are already attached according to their
8227 * TMSI NRI. */
8228testcase TC_mscpool_no_allow_attach_valid_nri() runs on test_CT {
8229
8230 f_init(nr_bts := 3, handler_mode := true, nr_msc := 3);
8231 f_sleep(1.0);
8232
Neels Hofmeyra460f1f2020-08-09 20:17:03 +00008233 /* Mark the second MSC as offloading, round-robin should skip this MSC now. */
8234 f_vty_msc_allow_attach(BSCVTY, {true, false, true});
8235
Neels Hofmeyr4f118412020-06-04 15:25:10 +02008236 /* Control which MSC gets chosen next by the round-robin, otherwise
8237 * would be randomly affected by which other tests ran before this. */
8238 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
8239
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02008240 f_ctrs_msc_init();
8241
Neels Hofmeyr4f118412020-06-04 15:25:10 +02008242 /* Round robin points at msc 0, but the valid NRI directs to msc 1, even though msc 1 has 'no allow-attach'. */
8243 var MSC_ConnHdlr vc_conn1;
8244 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 1);
8245 pars1.mscpool.rsl_idx := 0;
8246 /* An NRI of the second MSC's range (256-511) */
8247 pars1.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, valueof(ts_MI_TMSI_NRI_LV(260))));
8248 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
8249 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02008250 f_ctrs_msc_expect(1, "mscpool:subscr:known");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02008251
8252 var MSC_ConnHdlr vc_conn2;
8253 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 0);
8254 pars2.mscpool.rsl_idx := 1;
8255 pars2.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, valueof(ts_MI_IMSI_LV('001010000000002'H))));
8256 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
8257 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02008258 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02008259
8260 var MSC_ConnHdlr vc_conn3;
8261 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 2);
8262 pars3.mscpool.rsl_idx := 2;
8263 pars3.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, valueof(ts_MI_IMSI_LV('001010000000003'H))));
8264 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
8265 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02008266 f_ctrs_msc_expect(2, "mscpool:subscr:new");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02008267 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02008268}
8269
Philipp Maier783681c2020-07-16 16:47:06 +02008270/* Allow/Deny emergency calls globally via VTY */
8271private function f_vty_allow_emerg_msc(boolean allow) runs on test_CT {
8272 f_vty_enter_cfg_msc(BSCVTY, 0);
8273 if (allow) {
8274 f_vty_transceive(BSCVTY, "allow-emergency allow");
8275 } else {
8276 f_vty_transceive(BSCVTY, "allow-emergency deny");
8277 }
8278 f_vty_transceive(BSCVTY, "exit");
8279 f_vty_transceive(BSCVTY, "exit");
8280}
8281
8282/* Allow/Deny emergency calls per BTS via VTY */
8283private function f_vty_allow_emerg_bts(boolean allow, integer bts_nr) runs on test_CT {
8284 f_vty_enter_cfg_bts(BSCVTY, bts_nr);
8285 if (allow) {
8286 f_vty_transceive(BSCVTY, "rach emergency call allowed 1");
8287 } else {
8288 f_vty_transceive(BSCVTY, "rach emergency call allowed 0");
8289 }
8290 f_vty_transceive(BSCVTY, "exit");
8291 f_vty_transceive(BSCVTY, "exit");
Neels Hofmeyrb6ed80c2020-10-12 22:52:39 +00008292 f_vty_transceive(BSCVTY, "exit");
Philipp Maier783681c2020-07-16 16:47:06 +02008293}
8294
Pau Espin Pedrol9ae36d52021-06-15 17:29:43 +02008295/* Allow/Forbid Fast Return after SRVCC on a given BTS via VTY */
8296private function f_vty_allow_srvcc_fast_return(boolean allow, integer bts_nr) runs on test_CT {
8297 f_vty_enter_cfg_bts(BSCVTY, bts_nr);
8298 if (allow) {
8299 f_vty_transceive(BSCVTY, "srvcc fast-return allow");
8300 } else {
8301 f_vty_transceive(BSCVTY, "srvcc fast-return forbid");
8302 }
8303 f_vty_transceive(BSCVTY, "exit");
8304 f_vty_transceive(BSCVTY, "exit");
8305 f_vty_transceive(BSCVTY, "exit");
8306}
8307
Pau Espin Pedrol14475352021-07-22 15:48:16 +02008308/* Allow/Forbid TCH for signalling if SDCCH exhausted on a given BTS via VTY */
8309private function f_vty_allow_tch_for_signalling(boolean allow, integer bts_nr) runs on test_CT {
8310 f_vty_enter_cfg_bts(BSCVTY, bts_nr);
8311 if (allow) {
8312 f_vty_transceive(BSCVTY, "channel allocator allow-tch-for-signalling 1");
8313 } else {
8314 f_vty_transceive(BSCVTY, "channel allocator allow-tch-for-signalling 0");
8315 }
8316 f_vty_transceive(BSCVTY, "exit");
8317 f_vty_transceive(BSCVTY, "exit");
8318 f_vty_transceive(BSCVTY, "exit");
8319}
8320
Philipp Maier783681c2020-07-16 16:47:06 +02008321/* Begin assignmet procedure and send an EMERGENCY SETUP (RR) */
8322private function f_assignment_emerg_setup() runs on MSC_ConnHdlr {
8323 var PDU_ML3_MS_NW emerg_setup;
8324 var octetstring emerg_setup_enc;
8325 var RSL_Message emerg_setup_data_ind;
8326
8327 f_establish_fully(omit, omit);
8328
8329 emerg_setup := valueof(ts_ML3_MO_CC_EMERG_SETUP(1, valueof(ts_Bcap_voice)));
8330 emerg_setup_enc := enc_PDU_ML3_MS_NW(emerg_setup);
8331 emerg_setup_data_ind := valueof(ts_RSL_DATA_IND(g_chan_nr, valueof(ts_RslLinkID_DCCH(0)), emerg_setup_enc));
8332
8333 RSL.send(emerg_setup_data_ind);
8334}
8335
8336/* Test if the EMERGENCY SETUP gets passed on to the MSC via A when EMERGENCY
8337 * CALLS are permitted by the BSC config. */
8338private function f_TC_assignment_emerg_setup_allow(charstring id) runs on MSC_ConnHdlr {
8339 var PDU_BSSAP emerg_setup_data_ind_bssap;
8340 var PDU_ML3_MS_NW emerg_setup;
8341 timer T := 3.0;
8342
8343 f_assignment_emerg_setup()
8344
8345 T.start;
8346 alt {
8347 [] BSSAP.receive(tr_BSSAP_DTAP) -> value emerg_setup_data_ind_bssap {
8348 emerg_setup := dec_PDU_ML3_MS_NW(emerg_setup_data_ind_bssap.pdu.dtap);
8349 if (not isbound(emerg_setup.msgs.cc.emergencySetup)) {
8350 setverdict(fail, "no emergency setup");
8351 }
8352 }
8353 [] BSSAP.receive {
8354 setverdict(fail, "unexpected BSSAP message!");
8355 }
8356 [] T.timeout {
8357 setverdict(fail, "timout waiting for EMERGENCY SETUP!");
8358 }
8359 }
8360
8361 setverdict(pass);
8362}
8363
8364/* Test if the EMERGENCY SETUP gets blocked by the BSC if EMERGENCY CALLS are
8365 * forbidden by the BSC config. */
8366private function f_TC_assignment_emerg_setup_deny(charstring id) runs on MSC_ConnHdlr {
8367 var PDU_BSSAP emerg_setup_data_ind_bssap;
8368 timer T := 3.0;
8369
8370 f_assignment_emerg_setup()
8371
8372 T.start;
8373 alt {
8374 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_RELEASE)) {
8375 setverdict(pass);
8376 }
8377 [] RSL.receive {
8378 setverdict(fail, "unexpected RSL message!");
8379 }
8380 [] T.timeout {
8381 setverdict(fail, "timout waiting for RR CHANNEL RELEASE!");
8382 }
8383 }
8384}
8385
8386/* EMERGENCY CALL situation #1, allowed globally and by BTS */
8387testcase TC_assignment_emerg_setup_allow() runs on test_CT {
8388 var TestHdlrParams pars := f_gen_test_hdlr_pars();
8389 var MSC_ConnHdlr vc_conn;
8390
8391 f_init(1, true);
8392 f_sleep(1.0);
8393
8394 f_vty_allow_emerg_msc(true);
8395 f_vty_allow_emerg_bts(true, 0);
8396 vc_conn := f_start_handler(refers(f_TC_assignment_emerg_setup_allow), pars);
8397 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02008398 f_shutdown_helper();
Philipp Maier783681c2020-07-16 16:47:06 +02008399}
8400
8401/* EMERGENCY CALL situation #2, forbidden globally but allowed by BTS */
8402testcase TC_assignment_emerg_setup_deny_msc() runs on test_CT {
8403 var TestHdlrParams pars := f_gen_test_hdlr_pars();
8404 var MSC_ConnHdlr vc_conn;
8405
8406 f_init(1, true);
8407 f_sleep(1.0);
8408
8409 f_vty_allow_emerg_msc(false);
8410 f_vty_allow_emerg_bts(true, 0);
8411 vc_conn := f_start_handler(refers(f_TC_assignment_emerg_setup_deny), pars);
8412 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02008413 f_shutdown_helper();
Philipp Maier783681c2020-07-16 16:47:06 +02008414}
8415
8416/* EMERGENCY CALL situation #3, allowed globally but forbidden by BTS */
8417testcase TC_assignment_emerg_setup_deny_bts() runs on test_CT {
8418 var TestHdlrParams pars := f_gen_test_hdlr_pars();
8419 var MSC_ConnHdlr vc_conn;
8420
8421 /* Note: This simulates a spec violation by the MS, correct MS
8422 * implementations would not try to establish an emergency call because
8423 * the system information tells in advance that emergency calls are
8424 * not forbidden */
8425
8426 f_init(1, true);
8427 f_sleep(1.0);
8428
8429 f_vty_allow_emerg_msc(true);
8430 f_vty_allow_emerg_bts(false, 0);
8431 vc_conn := f_start_handler(refers(f_TC_assignment_emerg_setup_deny), pars);
8432 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02008433 f_shutdown_helper();
Philipp Maier783681c2020-07-16 16:47:06 +02008434}
8435
Philipp Maier82812002020-08-13 18:48:27 +02008436/* Test what happens when an emergency call arrives while all TCH channels are
8437 * busy, the BSC is expected to terminate one call in favor of the incoming
8438 * emergency call */
8439testcase TC_emerg_premption() runs on test_CT {
8440 var ASP_RSL_Unitdata rsl_ud;
8441 var integer i;
8442 var integer chreq_total, chreq_nochan;
8443 var RSL_Message rx_rsl;
8444 var RslChannelNr chan_nr;
8445
8446 f_init(1);
8447 f_sleep(1.0);
8448
8449 f_vty_allow_emerg_msc(true);
8450 f_vty_allow_emerg_bts(true, 0);
8451
8452 /* Fill up all channels on the BTS */
8453 chreq_total := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total");
8454 chreq_nochan := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:no_channel");
8455 for (i := 0; i < NUM_TCHF_PER_BTS + NUM_TCHH_PER_BTS + NUM_SDCCH_PER_BTS; i := i+1) {
8456 chan_nr := f_chreq_act_ack('33'O, i);
8457 }
8458 IPA_RSL[0].clear;
8459 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total",
8460 chreq_total + NUM_TCHF_PER_BTS + NUM_TCHH_PER_BTS + NUM_SDCCH_PER_BTS);
8461
8462 /* Send Channel request for emegergency call */
8463 f_ipa_tx(0, ts_RSL_CHAN_RQD('A5'O, 23));
8464
8465 /* Expect the BSC to release one (the first) TCH/F on the BTS */
8466 chan_nr := valueof(t_RslChanNr_Bm(1));
8467 f_expect_chan_rel(0, chan_nr, expect_rr_chan_rel := false, expect_rll_rel_req := false);
8468
8469 /* Expect the BSC to send activate/assign the a channel for the emergency call */
8470 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
8471 chan_nr := rx_rsl.ies[0].body.chan_nr;
8472 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, 33));
8473 rx_rsl := f_exp_ipa_rx(0, tr_RSL_IMM_ASSIGN(0));
Philipp Maier104f4c02020-09-11 18:12:18 +02008474
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02008475 f_shutdown_helper();
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008476}
8477
8478/* Hopping parameters per a timeslot */
Vadim Yanitskiybc6654a2020-09-13 01:27:40 +07008479private type record length(0..64) of GsmArfcn ArfcnList;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008480private type record FHParamsTs {
8481 boolean enabled,
8482 uint6_t hsn,
8483 uint6_t maio,
8484 ArfcnList ma
8485};
8486
8487/* Hopping parameters per a transceiver */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07008488private type record FHParamsTrx {
Philipp Maier798d8952021-10-19 14:43:19 +02008489 GsmBandArfcn arfcn,
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07008490 FHParamsTs ts[8]
8491};
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008492
8493/* Randomly generate the hopping parameters for the given timeslot numbers */
8494private function f_TC_fh_params_gen(template integer tr_tn := (1, 3, 5))
8495runs on test_CT return FHParamsTrx {
8496 var FHParamsTrx fhp;
8497
Philipp Maier798d8952021-10-19 14:43:19 +02008498 /* Generate a random ARFCN in the range of 0 - 3. This ARFCN will
8499 * fall in the GSM900 band. */
8500 fhp.arfcn.arfcn := f_rnd_int(3);
8501 fhp.arfcn.pcs := false;
Vadim Yanitskiye7c8c6e2020-09-13 14:33:03 +07008502
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008503 for (var integer tn := 0; tn < 8; tn := tn + 1) {
8504 if (not match(tn, tr_tn)) {
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07008505 fhp.ts[tn].enabled := false;
8506 fhp.ts[tn].ma := { };
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008507 continue;
8508 }
8509
8510 /* Random HSN / MAIO values: 0..63 */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07008511 fhp.ts[tn].hsn := f_rnd_int(64);
8512 fhp.ts[tn].maio := f_rnd_int(64);
8513 fhp.ts[tn].ma := { };
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008514
8515 /* Random Mobile Allocation (hopping channels) */
8516 var integer ma_len := 2 + f_rnd_int(9); /* 2..10 channels */
8517 var integer step := 3 + f_rnd_int(4); /* 3..6 stepping */
8518 for (var integer i := 1; i <= ma_len; i := i + 1) {
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07008519 fhp.ts[tn].ma := fhp.ts[tn].ma & { i * step };
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008520 }
8521
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07008522 fhp.ts[tn].enabled := true;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008523 }
8524
8525 log("f_TC_fh_params_gen(): ", fhp);
8526 return fhp;
8527}
8528
8529/* Make sure that the given Channel Description IE matches the hopping configuration */
8530private function f_TC_fh_params_match_chan_desc(in FHParamsTrx fhp, in ChannelDescription cd)
8531{
8532 var template (present) ChannelDescription tr_cd;
8533 var template (present) MaioHsn tr_maio_hsn;
8534 var uint3_t tn := cd.chan_nr.tn;
8535
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07008536 if (fhp.ts[tn].enabled) {
8537 tr_maio_hsn := tr_HsnMaio(fhp.ts[tn].hsn, fhp.ts[tn].maio);
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008538 tr_cd := tr_ChanDescH1(cd.chan_nr, tr_maio_hsn);
8539 } else {
Philipp Maier798d8952021-10-19 14:43:19 +02008540 tr_cd := tr_ChanDescH0(cd.chan_nr, fhp.arfcn.arfcn);
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008541 }
8542
8543 if (not match(cd, tr_cd)) {
8544 setverdict(fail, "Channel Description IE does not match: ",
8545 cd, " vs expected ", tr_cd);
8546 }
8547}
8548
8549/* Make sure that the given Mobile Allocation IE matches the hopping configuration */
8550private function f_TC_fh_params_match_ma(in FHParamsTrx fhp, uint3_t tn,
8551 in MobileAllocationLV ma)
8552{
8553 var template MobileAllocationLV tr_ma := f_TC_fh_params_gen_tr_ma(fhp, tn, ma);
8554
8555 if (not match(ma, tr_ma)) {
8556 setverdict(fail, "Mobile Allocation IE does not match (tn := ",
8557 tn, "): ", ma, " vs expected: ", tr_ma);
8558 } else {
8559 setverdict(pass);
8560 }
8561}
8562
8563private function f_TC_fh_params_gen_tr_ma(in FHParamsTrx fhp, uint3_t tn,
8564 in MobileAllocationLV ma)
8565return template MobileAllocationLV {
8566 /* Mobile Allocation IE is expected to be empty if hopping is not enabled */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07008567 if (not fhp.ts[tn].enabled) {
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008568 return { len := 0, ma := ''B };
8569 }
8570
8571 var bitstring full_mask := f_pad_bit(''B, 1024, '0'B);
8572 var bitstring slot_mask := f_pad_bit(''B, 1024, '0'B);
8573 var bitstring ma_mask := ''B;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008574
8575 /* Compose the full bit-mask (all channels, up to 1024 entries) */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07008576 for (var integer i := 0; i < lengthof(fhp.ts); i := i + 1) {
8577 for (var integer j := 0; j < lengthof(fhp.ts[i].ma); j := j + 1) {
8578 if (full_mask[fhp.ts[i].ma[j]] == '1'B)
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008579 { continue; }
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07008580 full_mask[fhp.ts[i].ma[j]] := '1'B;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008581 }
8582 }
8583
Vadim Yanitskiye7c8c6e2020-09-13 14:33:03 +07008584 /* Take ARFCN of the TRX itself into account */
Philipp Maier798d8952021-10-19 14:43:19 +02008585 full_mask[fhp.arfcn.arfcn] := '1'B;
Vadim Yanitskiye7c8c6e2020-09-13 14:33:03 +07008586
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008587 /* Compose a bit-mask for the given timeslot number */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07008588 for (var integer i := 0; i < lengthof(fhp.ts[tn].ma); i := i + 1) {
8589 slot_mask[fhp.ts[tn].ma[i]] := '1'B;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008590 }
8591
8592 /* Finally, compose the Mobile Allocation bit-mask */
Vadim Yanitskiy3e997362020-09-05 21:08:34 +07008593 for (var integer i := 1; i < lengthof(full_mask); i := i + 1) {
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008594 if (full_mask[i] != '1'B)
8595 { continue; }
8596
8597 /* FIXME: ma_mask := ma_mask & slot_mask[i]; // triggers a bug in TITAN */
8598 if (slot_mask[i] == '1'B) {
8599 ma_mask := ma_mask & '1'B;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008600 } else {
8601 ma_mask := ma_mask & '0'B;
8602 }
8603 }
8604
Vadim Yanitskiy3e997362020-09-05 21:08:34 +07008605 /* ARFCN 0 (if present) goes to the last position of the bit-mask */
8606 if (full_mask[0] == '1'B) {
8607 /* FIXME: ma_mask := ma_mask & slot_mask[0]; // triggers a bug in TITAN */
8608 if (slot_mask[0] == '1'B) {
8609 ma_mask := ma_mask & '1'B;
8610 } else {
8611 ma_mask := ma_mask & '0'B;
8612 }
8613 }
8614
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008615 /* Ensure that ma_mask is octet-aligned */
Vadim Yanitskiy2aa02522020-09-06 14:05:23 +07008616 var integer ma_mask_len := (lengthof(ma_mask) + 8 - 1) / 8;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008617 ma_mask := f_pad_bit(ma_mask, ma_mask_len * 8, '0'B);
8618
8619 return { len := ma_mask_len, ma := ma_mask };
8620}
8621
Philipp Maier798d8952021-10-19 14:43:19 +02008622/* Configure the appropriate band for a given arfcn, exc */
8623private function f_TC_set_band_by_arfcn(integer bts_nr, GsmBandArfcn arfcn) runs on test_CT
8624{
8625 var charstring band;
8626 var GsmBandArfcn arfcn_ := valueof(ts_GsmBandArfcn(arfcn.arfcn, arfcn.pcs, false));
8627
8628 select (arfcn_) {
8629 case (tr_GsmBandArfcn((259..293), false, ?)) { band := "GSM450"; }
8630 case (tr_GsmBandArfcn((306..340), false, ?)) { band := "GSM480"; }
8631 case (tr_GsmBandArfcn((438..511), false, ?)) { band := "GSM750"; }
8632 case (tr_GsmBandArfcn((128..251), false, ?)) { band := "GSM850"; }
8633 case (tr_GsmBandArfcn((0..124), false, ?)) { band := "GSM900"; }
8634 case (tr_GsmBandArfcn((955..1023), false, ?)) { band := "GSM900"; }
8635 case (tr_GsmBandArfcn((512..885), false, ?)) { band := "DCS1800"; }
8636 case (tr_GsmBandArfcn((512..810), true, ?)) { band := "PCS1900"; }
8637 case else { return; }
8638 }
8639
8640 f_vty_enter_cfg_bts(BSCVTY, bts_nr);
8641 f_vty_transceive(BSCVTY, "band " & band);
8642 f_vty_transceive(BSCVTY, "end");
8643}
8644
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008645/* Configure the hopping parameters in accordance with the given record */
8646private function f_TC_fh_params_set(in FHParamsTrx fhp,
8647 uint8_t bts_nr := 0,
8648 uint8_t trx_nr := 0)
8649runs on test_CT {
Philipp Maier798d8952021-10-19 14:43:19 +02008650
8651 f_TC_set_band_by_arfcn(bts_nr, fhp.arfcn);
8652
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008653 /* Enter the configuration node for the given BTS/TRX numbers */
8654 f_vty_enter_cfg_trx(BSCVTY, bts_nr, trx_nr);
8655
Philipp Maier798d8952021-10-19 14:43:19 +02008656 f_vty_transceive(BSCVTY, "arfcn " & int2str(fhp.arfcn.arfcn));
Vadim Yanitskiye7c8c6e2020-09-13 14:33:03 +07008657
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07008658 for (var integer tn := 0; tn < lengthof(fhp.ts); tn := tn + 1) {
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008659 f_vty_transceive(BSCVTY, "timeslot " & int2str(tn));
8660
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07008661 if (not fhp.ts[tn].enabled) {
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008662 f_vty_transceive(BSCVTY, "hopping enabled 0");
8663 f_vty_transceive(BSCVTY, "exit"); /* go back */
8664 continue;
8665 }
8666
8667 /* Configure HSN / MAIO values */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07008668 f_vty_transceive(BSCVTY, "hopping sequence-number " & int2str(fhp.ts[tn].hsn));
8669 f_vty_transceive(BSCVTY, "hopping maio " & int2str(fhp.ts[tn].maio));
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008670
8671 /* Configure the Mobile Allocation (hopping channels) */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07008672 for (var integer i := 0; i < lengthof(fhp.ts[tn].ma); i := i + 1) {
8673 f_vty_transceive(BSCVTY, "hopping arfcn add " & int2str(fhp.ts[tn].ma[i]));
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008674 }
8675
8676 f_vty_transceive(BSCVTY, "hopping enabled 1");
8677 f_vty_transceive(BSCVTY, "exit"); /* go back */
8678 }
8679
8680 f_vty_transceive(BSCVTY, "end");
8681}
8682
8683/* Disable frequency hopping on all timeslots */
8684private function f_TC_fh_params_unset(in FHParamsTrx fhp,
8685 uint8_t bts_nr := 0,
Vadim Yanitskiye7c8c6e2020-09-13 14:33:03 +07008686 uint8_t trx_nr := 0,
Philipp Maier798d8952021-10-19 14:43:19 +02008687 GsmBandArfcn arfcn := {pcs := false, arfcn := 871})
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008688runs on test_CT {
Philipp Maier798d8952021-10-19 14:43:19 +02008689
8690 f_TC_set_band_by_arfcn(bts_nr, arfcn);
8691
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008692 /* Enter the configuration node for the given BTS/TRX numbers */
8693 f_vty_enter_cfg_trx(BSCVTY, bts_nr, trx_nr);
8694
Philipp Maier798d8952021-10-19 14:43:19 +02008695 f_vty_transceive(BSCVTY, "arfcn " & int2str(arfcn.arfcn));
Vadim Yanitskiye7c8c6e2020-09-13 14:33:03 +07008696
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07008697 for (var integer tn := 0; tn < lengthof(fhp.ts); tn := tn + 1) {
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008698 f_vty_transceive(BSCVTY, "timeslot " & int2str(tn));
8699
8700 /* Delete all ARFCNs from the Mobile Allocation (if any) */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07008701 for (var integer i := 0; i < lengthof(fhp.ts[tn].ma); i := i + 1) {
8702 f_vty_transceive(BSCVTY, "hopping arfcn del " & int2str(fhp.ts[tn].ma[i]));
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008703 }
8704
8705 f_vty_transceive(BSCVTY, "hopping enabled 0");
8706 f_vty_transceive(BSCVTY, "exit"); /* go back */
8707 }
8708
8709 f_vty_transceive(BSCVTY, "end");
8710 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
8711}
8712
8713/* Verify presence and correctness of the hopping parameters (HSN, MAIO)
8714 * in the Channel Identification IE of the RSL CHANnel ACTIVation message. */
8715testcase TC_fh_params_chan_activ() runs on test_CT {
8716 var FHParamsTrx fhp := f_TC_fh_params_gen();
8717 var RSL_Message rsl_msg;
8718 var RSL_IE_Body ie;
8719
8720 f_init_vty();
8721
8722 f_TC_fh_params_set(fhp); /* Enable frequency hopping */
8723 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
8724
8725 f_init(1);
8726
8727 /* CS domain: 3 (SDCCH/4+CBCH) + 4 (TCH/F) + 2 (TCH/H) channels available */
8728 for (var integer i := 0; i < 9; i := i + 1) {
8729 f_ipa_tx(0, ts_RSL_CHAN_RQD(f_rnd_ra_cs(), 23));
8730 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
8731
8732 /* Make sure that Channel Identification IE is present */
8733 if (not f_rsl_find_ie(rsl_msg, RSL_IE_CHAN_IDENT, ie)) {
8734 setverdict(fail, "RSL Channel Identification IE is absent");
8735 continue;
8736 }
8737
8738 /* Make sure that hopping parameters (HSN/MAIO) match */
8739 f_TC_fh_params_match_chan_desc(fhp, ie.chan_ident.ch_desc.v);
8740
8741 /* "Mobile Allocation shall be included but empty" - let's check this */
8742 if (ie.chan_ident.ma.v.len != 0) {
8743 setverdict(fail, "Mobile Allocation IE is not empty: ",
8744 ie.chan_ident.ma, ", despite it shall be");
8745 continue;
8746 }
8747 }
8748
8749 /* Disable frequency hopping */
8750 f_TC_fh_params_unset(fhp);
8751
Vadim Yanitskiy21726312020-09-04 01:45:36 +07008752 f_shutdown_helper();
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008753}
8754
8755/* Verify the hopping parameters (HSN, MAIO, MA) in (RR) Immediate Assignment */
8756testcase TC_fh_params_imm_ass() runs on test_CT {
8757 var FHParamsTrx fhp := f_TC_fh_params_gen();
8758 var RSL_Message rsl_msg;
8759 var RSL_IE_Body ie;
8760
8761 f_init_vty();
8762
8763 f_TC_fh_params_set(fhp); /* Enable frequency hopping */
8764 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
8765
8766 f_init(1);
8767
8768 /* CS domain: 3 (SDCCH/4+CBCH) + 4 (TCH/F) + 2 (TCH/H) channels available */
8769 for (var integer i := 0; i < 9; i := i + 1) {
8770 f_ipa_tx(0, ts_RSL_CHAN_RQD(f_rnd_ra_cs(), 23));
8771 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
8772
8773 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(rsl_msg.ies[0].body.chan_nr, 33));
8774 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeC(RSL_MT_IMMEDIATE_ASSIGN_CMD));
8775
8776 /* Make sure that Full Immediate Assign Info IE is present */
8777 if (not f_rsl_find_ie(rsl_msg, RSL_IE_FULL_IMM_ASS_INFO, ie)) {
8778 setverdict(fail, "RSL Full Immediate Assign Info IE is absent");
8779 continue;
8780 }
8781
8782 /* Decode the actual Immediate Assignment message */
8783 var GsmRrMessage rr_msg := dec_GsmRrMessage(ie.full_imm_ass_info.payload);
8784 if (not match(rr_msg.header, t_RrHeader(IMMEDIATE_ASSIGNMENT, ?))) {
8785 setverdict(fail, "Failed to match Immediate Assignment: ", rr_msg);
8786 continue;
8787 }
8788
8789 /* Make sure that hopping parameters (HSN/MAIO) match */
8790 f_TC_fh_params_match_chan_desc(fhp, rr_msg.payload.imm_ass.chan_desc);
8791
8792 /* Make sure that the Mobile Allocation IE matches */
8793 f_TC_fh_params_match_ma(fhp, rr_msg.payload.imm_ass.chan_desc.chan_nr.tn,
8794 rr_msg.payload.imm_ass.mobile_allocation);
8795 }
8796
8797 /* Disable frequency hopping */
8798 f_TC_fh_params_unset(fhp);
Philipp Maier82812002020-08-13 18:48:27 +02008799
Vadim Yanitskiy21726312020-09-04 01:45:36 +07008800 f_shutdown_helper();
Philipp Maier82812002020-08-13 18:48:27 +02008801}
8802
Vadim Yanitskiyaeb54a22020-09-01 06:25:25 +07008803/* Verify the hopping parameters (HSN, MAIO, MA) in (RR) Assignment Command */
8804testcase TC_fh_params_assignment_cmd() runs on test_CT {
8805 var FHParamsTrx fhp := f_TC_fh_params_gen();
8806 var RSL_Message rsl_msg;
8807 var RSL_IE_Body ie;
8808
8809 f_init_vty();
8810
8811 f_TC_fh_params_set(fhp); /* Enable frequency hopping */
8812 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
8813
8814 f_init(1);
8815
8816 /* HACK: work around "Couldn't find Expect for CRCX" */
8817 vc_MGCP.stop;
8818
8819 var template PDU_BSSAP ass_cmd := f_gen_ass_req();
8820 ass_cmd.pdu.bssmap.assignmentRequest.codecList := ts_BSSMAP_IE_CodecList({ts_CodecFR});
8821
8822 /* CS domain (TCH): 4 (TCH/F) + 2 (TCH/H) channels available
8823 * NOTE: only 3 SDCCH/4 channels are available on CCCH+SDCCH4+CBCH */
8824 for (var integer i := 0; i < 3; i := i + 1) {
8825 /* Establish a dedicated channel, so we can trigger (late) TCH assignment */
8826 var DchanTuple dt := f_est_dchan(f_rnd_ra_cs(), 23, f_rnd_octstring(16));
8827
8828 /* Send a BSSMAP Assignment Command, expect CHANnel ACTIVation */
8829 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ass_cmd));
8830 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
8831
8832 /* ACKnowledge CHANnel ACTIVation, expect RSL DATA REQuest */
8833 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(rsl_msg.ies[0].body.chan_nr, 33));
8834 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeR(RSL_MT_DATA_REQ));
8835
8836 /* Make sure that L3 Information IE is present */
8837 if (not f_rsl_find_ie(rsl_msg, RSL_IE_L3_INFO, ie)) {
8838 setverdict(fail, "RSL L3 Information IE is absent");
8839 continue;
8840 }
8841
8842 /* Decode the L3 message and make sure it is (RR) Assignment Command */
8843 var GsmRrL3Message l3_msg := dec_GsmRrL3Message(ie.l3_info.payload);
8844 if (not match(l3_msg.header, t_RrL3Header(ASSIGNMENT_COMMAND))) {
8845 setverdict(fail, "Failed to match Assignment Command: ", l3_msg);
8846 continue;
8847 }
8848
8849 /* Make sure that hopping parameters (HSN/MAIO) match */
8850 var ChannelDescription chan_desc := l3_msg.payload.ass_cmd.chan_desc;
8851 f_TC_fh_params_match_chan_desc(fhp, chan_desc);
8852
8853 /* Make sure that Cell Channel Description IE is present if FH is enabled */
8854 if (chan_desc.h and not ispresent(l3_msg.payload.ass_cmd.cell_chan_desc)) {
Vadim Yanitskiy38d069d2020-09-02 17:18:57 +07008855 setverdict(fail, "FH enabled, but Cell Channel Description IE is absent");
Vadim Yanitskiyaeb54a22020-09-01 06:25:25 +07008856 continue;
8857 }
8858
8859 /* Make sure that the Mobile Allocation IE matches (if present) */
8860 var boolean ma_present := ispresent(l3_msg.payload.ass_cmd.mobile_allocation);
8861 if (chan_desc.h and ma_present) {
8862 f_TC_fh_params_match_ma(fhp, chan_desc.chan_nr.tn,
8863 l3_msg.payload.ass_cmd.mobile_allocation.v);
8864 } else if (chan_desc.h and not ma_present) {
8865 setverdict(fail, "FH enabled, but Mobile Allocation IE is absent");
8866 continue;
8867 } else if (not chan_desc.h and ma_present) {
8868 setverdict(fail, "FH disabled, but Mobile Allocation IE is present");
8869 continue;
8870 }
8871 }
8872
8873 /* Give the IUT some time to release all channels */
8874 f_sleep(3.0);
8875
8876 /* Disable frequency hopping */
8877 f_TC_fh_params_unset(fhp);
8878
Vadim Yanitskiy21726312020-09-04 01:45:36 +07008879 f_shutdown_helper();
Vadim Yanitskiyaeb54a22020-09-01 06:25:25 +07008880}
8881
Vadim Yanitskiy8f5430d2020-09-02 18:51:38 +07008882/* Verify the hopping parameters (HSN, MAIO, MA) in (RR) Handover Command */
8883private function f_TC_fh_params_handover_cmd(in FHParamsTrx fhp)
8884runs on test_CT {
8885 var RSL_Message rsl_msg;
8886 var RSL_IE_Body ie;
8887 var DchanTuple dt;
8888
8889 /* Establish a dedicated channel, so we can trigger handover */
8890 dt := f_est_dchan(f_rnd_ra_cs(), 23, f_rnd_octstring(16));
8891
8892 /* Trigger handover from BTS0 to BTS1 */
8893 f_bts_0_cfg(BSCVTY, { "neighbor bts 1" });
8894 f_vty_handover(BSCVTY, 0, 0, dt.rsl_chan_nr, 1);
8895
8896 /* Expect RSL CHANnel ACTIVation on BTS1/TRX0/TS1 */
8897 rsl_msg := f_exp_ipa_rx(1, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
8898
8899 /* ACKnowledge channel activation and expect (RR) Handover Command */
8900 f_ipa_tx(1, ts_RSL_CHAN_ACT_ACK(rsl_msg.ies[0].body.chan_nr, 33));
8901 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeR(RSL_MT_DATA_REQ));
8902
8903 /* Make sure that L3 Information IE is present */
8904 if (not f_rsl_find_ie(rsl_msg, RSL_IE_L3_INFO, ie)) {
8905 setverdict(fail, "RSL L3 Information IE is absent");
8906 return;
8907 }
8908
8909 /* Decode the L3 message and make sure it is (RR) Handover Command */
8910 var GsmRrL3Message l3_msg := dec_GsmRrL3Message(ie.l3_info.payload);
8911 if (not match(l3_msg.header, t_RrL3Header(HANDOVER_COMMAND))) {
8912 setverdict(fail, "Failed to match Handover Command: ", l3_msg);
8913 return;
8914 }
8915
8916 /* Make sure that we've got SDCCH/8 on TS1 (expected to be hopping) */
8917 var ChannelDescription chan_desc := l3_msg.payload.ho_cmd.chan_desc;
8918 if (not match(chan_desc.chan_nr, t_RslChanNr_SDCCH8(1, ?))) {
8919 setverdict(fail, "Unexpected channel number: ", chan_desc.chan_nr);
8920 return;
8921 }
8922
8923 /* Make sure that hopping parameters (HSN/MAIO) match */
8924 f_TC_fh_params_match_chan_desc(fhp, chan_desc);
8925
8926 /* Make sure that Cell Channel Description IE is present */
8927 if (not ispresent(l3_msg.payload.ho_cmd.cell_chan_desc)) {
8928 setverdict(fail, "FH enabled, but Cell Channel Description IE is absent");
8929 return;
8930 }
8931
8932 /* Make sure that the Mobile Allocation (after time) IE is present and matches */
8933 var boolean ma_present := ispresent(l3_msg.payload.ho_cmd.mobile_allocation);
8934 if (ma_present) {
8935 f_TC_fh_params_match_ma(fhp, chan_desc.chan_nr.tn,
8936 l3_msg.payload.ho_cmd.mobile_allocation.v);
8937 } else {
8938 setverdict(fail, "FH enabled, but Mobile Allocation IE is absent");
8939 return;
8940 }
8941}
8942testcase TC_fh_params_handover_cmd() runs on test_CT {
8943 var FHParamsTrx fhp := f_TC_fh_params_gen();
8944
8945 f_init_vty();
8946
8947 /* (Re)configure TS0 as BCCH and TS1 as SDCCH8 on BTS1/TRX0 */
8948 f_vty_enter_cfg_trx(BSCVTY, bts := 1, trx := 0);
8949
8950 f_vty_transceive(BSCVTY, "timeslot 0");
8951 f_vty_transceive(BSCVTY, "phys_chan_config ccch");
8952 f_vty_transceive(BSCVTY, "exit"); /* go back */
8953
8954 f_vty_transceive(BSCVTY, "timeslot 1");
8955 f_vty_transceive(BSCVTY, "phys_chan_config sdcch8");
8956 f_vty_transceive(BSCVTY, "end"); /* we're done */
8957
8958 f_TC_fh_params_set(fhp, 1); /* Enable frequency hopping on BTS1 */
8959 f_vty_transceive(BSCVTY, "drop bts connection 1 oml");
8960
8961 f_init(2);
8962
8963 f_TC_fh_params_handover_cmd(fhp);
8964
8965 /* Disable frequency hopping on BTS1 */
8966 f_TC_fh_params_unset(fhp, 1);
8967
8968 /* (Re)configure TS0 as CCCH+SDCCH4+CBCH and TS1 as TCH/F */
8969 f_vty_enter_cfg_trx(BSCVTY, bts := 1, trx := 0);
8970
8971 f_vty_transceive(BSCVTY, "timeslot 0");
8972 f_vty_transceive(BSCVTY, "phys_chan_config ccch+sdcch4+cbch");
8973 f_vty_transceive(BSCVTY, "exit"); /* go back */
8974
8975 f_vty_transceive(BSCVTY, "timeslot 1");
8976 f_vty_transceive(BSCVTY, "phys_chan_config tch/f");
8977 f_vty_transceive(BSCVTY, "end"); /* we're done */
8978
8979 f_shutdown_helper();
8980}
8981
Vadim Yanitskiyca974032020-09-01 07:20:39 +07008982/* Verify the hopping parameters in System Information Type 4 */
8983testcase TC_fh_params_si4_cbch() runs on test_CT {
8984 var FHParamsTrx fhp := f_TC_fh_params_gen(tr_tn := 1);
8985 var ASP_RSL_Unitdata rx_rsl_ud;
8986 timer T := 5.0;
8987
8988 f_init_vty();
8989
8990 /* (Re)configure TS0 as BCCH and TS1 as SDCCH8+CBCH */
8991 f_vty_enter_cfg_trx(BSCVTY, trx := 0);
8992
8993 f_vty_transceive(BSCVTY, "timeslot 0");
8994 f_vty_transceive(BSCVTY, "phys_chan_config ccch");
8995 f_vty_transceive(BSCVTY, "exit"); /* go back */
8996
8997 f_vty_transceive(BSCVTY, "timeslot 1");
8998 f_vty_transceive(BSCVTY, "phys_chan_config sdcch8+cbch");
8999 f_vty_transceive(BSCVTY, "end"); /* we're done */
9000
9001 f_TC_fh_params_set(fhp); /* Enable frequency hopping */
9002 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
9003
9004 f_init(1);
9005
9006 T.start;
9007 alt {
9008 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_BCCH_INFO(RSL_SYSTEM_INFO_4))) -> value rx_rsl_ud {
9009 var RSL_IE_Body ie := rx_rsl_ud.rsl.ies[2].body; /* FULL BCCH Information IE */
9010 var SystemInformation si := dec_SystemInformation(ie.other.payload);
9011
9012 /* Make sure that what we decoded is System Information Type 4 */
9013 if (si.header.message_type != SYSTEM_INFORMATION_TYPE_4) {
9014 setverdict(fail, "RSL FULL BCCH Information IE contains: ", si);
9015 repeat;
9016 }
9017
9018 /* Make sure that CBCH Channel Description IE is present */
9019 if (not ispresent(si.payload.si4.cbch_chan_desc)) {
9020 setverdict(fail, "CBCH Channel Description IE is absent");
9021 break;
9022 }
9023
9024 /* Finally, check the hopping parameters (HSN, MAIO) */
9025 var ChannelDescription chan_desc := si.payload.si4.cbch_chan_desc.v;
9026 f_TC_fh_params_match_chan_desc(fhp, chan_desc);
9027
9028 /* 3GPP TS 44.018, section 9.1.36.2 "CBCH Mobile Allocation":
9029 * The CBCH Mobile Allocation IE *shall* be present if FH is enabled. */
9030 if (chan_desc.h and not ispresent(si.payload.si4.cbch_mobile_alloc)) {
9031 setverdict(fail, "FH enabled, but Mobile Allocation IE is absent");
9032 break;
9033 } else if (chan_desc.h and ispresent(si.payload.si4.cbch_mobile_alloc)) {
9034 f_TC_fh_params_match_ma(fhp, chan_desc.chan_nr.tn,
9035 si.payload.si4.cbch_mobile_alloc.v);
9036 }
9037 }
9038 [] IPA_RSL[0].receive { repeat; }
9039 [] T.timeout {
9040 setverdict(fail, "Timeout waiting for RSL BCCH INFOrmation (SI4)");
9041 }
9042 }
9043
9044 /* Disable frequency hopping */
9045 f_TC_fh_params_unset(fhp);
9046
Vadim Yanitskiy8bc46012020-09-06 12:38:01 +07009047 /* (Re)configure TS0 as CCCH+SDCCH4+CBCH and TS1 as TCH/F */
Vadim Yanitskiyca974032020-09-01 07:20:39 +07009048 f_vty_enter_cfg_trx(BSCVTY, trx := 0);
9049
9050 f_vty_transceive(BSCVTY, "timeslot 0");
Vadim Yanitskiy8bc46012020-09-06 12:38:01 +07009051 f_vty_transceive(BSCVTY, "phys_chan_config ccch+sdcch4+cbch");
Vadim Yanitskiyca974032020-09-01 07:20:39 +07009052 f_vty_transceive(BSCVTY, "exit"); /* go back */
9053
9054 f_vty_transceive(BSCVTY, "timeslot 1");
9055 f_vty_transceive(BSCVTY, "phys_chan_config tch/f");
9056 f_vty_transceive(BSCVTY, "end"); /* we're done */
9057
Vadim Yanitskiy21726312020-09-04 01:45:36 +07009058 f_shutdown_helper();
Vadim Yanitskiyca974032020-09-01 07:20:39 +07009059}
9060
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02009061template (value) PDU_BSSAP_LE ts_BSSMAP_LE_BSSLAP(template (value) BSSLAP_PDU bsslap)
9062 := ts_BSSMAP_LE_ConnInfo(BSSMAP_LE_PROT_BSSLAP, data := enc_BSSLAP_PDU(valueof(bsslap)));
9063
9064private function f_match_bsslap(PDU_BSSAP_LE got_bsslap_msg,
9065 template (present) BSSLAP_PDU expect_bsslap)
9066{
9067 var BSSLAP_PDU bsslap := dec_BSSLAP_PDU(got_bsslap_msg.pdu.bssmap.co_info.bsslap_apdu.data);
9068 if (not match(bsslap, expect_bsslap)) {
9069 log("EXPECTING BSSLAP: ", expect_bsslap);
9070 log("GOT BSSLAP: ", bsslap);
9071 setverdict(fail, "BSSLAP is not as expected");
9072 mtc.stop;
9073 }
9074 setverdict(pass);
9075}
9076
9077/* GAD: this is an Ellipsoid point with uncertainty circle, encoded as in 3GPP TS 23.032 §7.3.2. */
9078const octetstring gad_ell_point_unc_circle := '10b0646d0d5f6627'O;
9079
9080private function f_expect_bsslap(template (present) BSSLAP_PDU expect_rx_bsslap) runs on MSC_ConnHdlr {
9081 var PDU_BSSAP_LE rx_bsslap;
9082 BSSAP_LE.receive(tr_BSSMAP_LE_ConnInfo(BSSMAP_LE_PROT_BSSLAP, ?)) -> value(rx_bsslap);
9083 f_match_bsslap(rx_bsslap, expect_rx_bsslap);
9084}
9085
9086/* With an active lchan, start BSSMAP Perform Location Request on A interface, starting BSSMAP-LE Perform Location
9087 * Request on Lb interface. Either with or without the SMLC doing a BSSLAP TA Request. */
9088private function f_lcs_loc_req_for_active_ms(boolean do_ta_request := false) runs on MSC_ConnHdlr {
9089 f_sleep(1.0);
9090
9091 f_establish_fully(omit, omit);
9092 f_bssap_le_register_imsi(g_pars.imsi, omit);
9093
9094 BSSAP.send(valueof(ts_BSSMAP_Perform_Location_Request(ts_BSSMAP_Imsi(g_pars.imsi),
9095 ts_CellId_CGI('262'H, '42'H, 23, 42))));
9096
9097 var PDU_BSSAP_LE plr;
9098 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocReq(BSSMAP_LE_LOC_INFO_CURRENT_GEOGRAPHIC_LOC, ?, ?)) -> value(plr);
9099
9100 if (not do_ta_request) {
9101 /* verify TA Layer 3 in APDU. First the APDU type (BSSLAP), then the BSSLAP data contents. */
9102 var template BSSMAP_LE_IE_APDU expect_apdu := tr_BSSMAP_LE_APDU(BSSMAP_LE_PROT_BSSLAP, ?);
9103 if (not match(plr.pdu.bssmap.perf_loc_req.bsslap_apdu, expect_apdu)) {
9104 log("EXPECTING BSSMAP-LE APDU IE ", expect_apdu);
9105 log("GOT BSSMAP-LE APDU IE ", plr.pdu.bssmap.perf_loc_req.bsslap_apdu);
9106 setverdict(fail, "BSSMAP-LE APDU IE is not as expected");
9107 mtc.stop;
9108 }
9109 var template BSSLAP_PDU expect_ta_layer3 := tr_BSSLAP_TA_Layer3(tr_BSSLAP_IE_TA(0));
9110 var BSSLAP_PDU bsslap := dec_BSSLAP_PDU(plr.pdu.bssmap.perf_loc_req.bsslap_apdu.data);
9111 if (not match(bsslap, expect_ta_layer3)) {
9112 log("EXPECTING BSSLAP TA Layer 3: ", expect_ta_layer3);
9113 log("GOT BSSLAP: ", bsslap);
9114 setverdict(fail, "BSSLAP is not as expected");
9115 mtc.stop;
9116 }
9117 /* OsmoBSC directly sent the TA as BSSLAP APDU in the BSSMAP-LE Perform Location Request to the SMLC. The SMLC
9118 * has no need to request the TA from the BSC and directly responds. */
9119 } else {
9120 /* SMLC wants to ask the TA from the BSC explicitly in a BSSLAP TA Request message */
9121 BSSAP_LE.send(ts_BSSMAP_LE_BSSLAP(ts_BSSLAP_TA_Req));
9122 f_expect_bsslap(tr_BSSLAP_TA_Resp(?, ?));
9123 }
9124
9125 /* SMLC got the TA from the BSC, now responds with geo information data. */
9126 BSSAP_LE.send(ts_BSSMAP_LE_PerfLocResp(gad_ell_point_unc_circle, omit));
9127 BSSAP_LE.receive(BSSAP_LE_Conn_Prim:CONN_PRIM_DISC_IND);
9128 BSSAP.receive(tr_BSSMAP_Perform_Location_Response(tr_BSSMAP_IE_LocationEstimate(gad_ell_point_unc_circle)));
9129
9130 /* The LCS was using an active A-interface conn. It should still remain active after this. */
9131 f_mo_l3_transceive();
9132
Neels Hofmeyr85bcd272021-07-22 19:14:48 +02009133 f_perform_clear();
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02009134
9135 f_sleep(2.0);
9136 setverdict(pass);
9137}
9138
9139/* With an active lchan, start BSSMAP Perform Location Request on A interface, starting BSSMAP-LE Perform Location
9140 * Request on Lb interface. Without the SMLC doing a BSSLAP TA Request. */
9141private function f_tc_lcs_loc_req_for_active_ms(charstring id) runs on MSC_ConnHdlr {
9142 f_lcs_loc_req_for_active_ms(false);
9143}
9144testcase TC_lcs_loc_req_for_active_ms() runs on test_CT {
9145 var MSC_ConnHdlr vc_conn;
9146 var TestHdlrParams pars := f_gen_test_hdlr_pars();
9147
9148 f_init(1, true);
9149 f_sleep(1.0);
9150 vc_conn := f_start_handler(refers(f_tc_lcs_loc_req_for_active_ms), pars);
9151 vc_conn.done;
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01009152 f_shutdown_helper();
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02009153}
9154
9155/* With an active lchan, start BSSMAP Perform Location Request on A interface, starting BSSMAP-LE Perform Location
9156 * Request on Lb interface. With the SMLC doing a BSSLAP TA Request. */
9157private function f_tc_lcs_loc_req_for_active_ms_ta_req(charstring id) runs on MSC_ConnHdlr {
9158 f_lcs_loc_req_for_active_ms(true);
9159}
9160testcase TC_lcs_loc_req_for_active_ms_ta_req() runs on test_CT {
9161 var MSC_ConnHdlr vc_conn;
9162 var TestHdlrParams pars := f_gen_test_hdlr_pars();
9163
9164 f_init(1, true);
9165 f_sleep(1.0);
9166 vc_conn := f_start_handler(refers(f_tc_lcs_loc_req_for_active_ms_ta_req), pars);
9167 vc_conn.done;
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01009168 f_shutdown_helper();
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02009169}
9170
9171/* Clear the A-interface conn only, without doing anything on Abis. Useful for LCS, for cases where there is only an A
9172 * conn without an active lchan. */
9173private function f_clear_A_conn() runs on MSC_ConnHdlr
9174{
9175 var BssmapCause cause := 0;
9176 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
9177 BSSAP.receive(tr_BSSMAP_ClearComplete);
9178 BSSAP.send(RAN_Conn_Prim:MSC_CONN_PRIM_DISC_REQ);
9179
9180 timer no_more_bssap := 5.0;
9181 no_more_bssap.start;
9182 alt {
9183 [] no_more_bssap.timeout { break; }
9184 [] BSSAP.receive(tr_BSSAP_BSSMAP) {
9185 setverdict(fail, "Expected no more BSSAP after Clear Complete");
9186 mtc.stop;
9187 }
9188 }
9189 setverdict(pass);
9190}
9191
9192/* Verify that the A-interface connection is still working, and then clear it, without doing anything on Abis. Useful
9193 * for LCS, for cases where there is only an A conn without an active lchan. */
9194private function f_verify_active_A_conn_and_clear() runs on MSC_ConnHdlr
9195{
9196 f_logp(BSCVTY, "f_verify_active_A_conn_and_clear: test A link, then clear");
9197
9198 /* When an lchan is active, we can send some L3 data from the BTS side and verify that it shows up on the other
9199 * side towards the MSC. When there is no lchan, this is not possible. To probe whether the A-interface
9200 * connection is still up, we need something that echos back on the A-interface. Another LCS request! */
9201 BSSAP.send(valueof(ts_BSSMAP_Perform_Location_Request(ts_BSSMAP_Imsi(g_pars.imsi),
9202 ts_CellId_CGI('262'H, '42'H, 23, 42))));
9203 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocReq(BSSMAP_LE_LOC_INFO_CURRENT_GEOGRAPHIC_LOC, ?, ?));
9204
9205 /* Right, the Perform Location Request showed up on Lb, now we can clear the A conn. */
9206 f_clear_A_conn();
9207 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocAbort(BSSMAP_LE_LCS_CAUSE_REQUEST_ABORTED));
9208 BSSAP_LE.receive(BSSAP_LE_Conn_Prim:CONN_PRIM_DISC_IND);
9209}
9210
9211/* With *no* active lchan, start BSSMAP Perform Location Request on A interface, starting BSSMAP-LE Perform Location
9212 * Request on Lb interface. BSC will Page for the subscriber as soon as we (virtual SMLC) request the TA via BSSLAP.
9213 */
9214private function f_tc_lcs_loc_req_for_idle_ms(charstring id) runs on MSC_ConnHdlr {
9215 f_sleep(1.0);
9216
9217 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
9218 f_bssap_le_register_imsi(g_pars.imsi, omit);
9219
9220 /* Register to receive the Paging Command */
9221 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
9222 g_chan_nr := new_chan_nr;
9223 f_rslem_register(0, g_chan_nr);
9224
9225 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
9226 valueof(ts_BSSMAP_Perform_Location_Request(ts_BSSMAP_Imsi(g_pars.imsi),
9227 ts_CellId_CGI('001'H, '01'H, 1, 0)))));
9228 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
9229
9230 var PDU_BSSAP_LE plr;
9231 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocReq(BSSMAP_LE_LOC_INFO_CURRENT_GEOGRAPHIC_LOC, ?, ?)) -> value(plr);
9232
9233 /* SMLC wants to ask the TA from the BSC explicitly in a BSSLAP TA Request message */
9234 BSSAP_LE.send(ts_BSSMAP_LE_BSSLAP(ts_BSSLAP_TA_Req));
9235
9236 /* OsmoBSC needs to Page */
9237 RSL.receive(tr_RSL_PAGING_CMD(tr_MI_IMSI(g_pars.imsi)));
9238 f_logp(BSCVTY, "got Paging Command");
9239
9240 /* MS requests channel. Since the Paging was for LCS, the Paging Response does not trigger a Complete Layer 3 to
9241 * the MSC, and releases the lchan directly. */
Neels Hofmeyr85bcd272021-07-22 19:14:48 +02009242 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);
9243 f_expect_lchan_rel(RSL, RSL_PROC);
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02009244
9245 /* From the Paging Response, the TA is now known to the BSC, and it responds to the SMLC. */
9246
9247 f_expect_bsslap(tr_BSSLAP_TA_Resp(?, ?));
9248
9249 /* SMLC got the TA from the BSC, now responds with geo information data. */
9250 BSSAP_LE.send(ts_BSSMAP_LE_PerfLocResp(gad_ell_point_unc_circle, omit));
9251 BSSAP_LE.receive(BSSAP_LE_Conn_Prim:CONN_PRIM_DISC_IND);
9252
9253 BSSAP.receive(tr_BSSMAP_Perform_Location_Response(tr_BSSMAP_IE_LocationEstimate(gad_ell_point_unc_circle)));
9254
9255 /* The lchan is gone, the A-interface conn was created for the LCS only.
9256 * Still it is clearly the MSC's job to decide whether to tear down the conn or not. */
9257 f_verify_active_A_conn_and_clear();
9258
9259 f_sleep(2.0);
9260 setverdict(pass);
9261}
9262testcase TC_lcs_loc_req_for_idle_ms() runs on test_CT {
9263 var MSC_ConnHdlr vc_conn;
9264 var TestHdlrParams pars := f_gen_test_hdlr_pars();
9265
9266 f_init(1, true);
9267 f_sleep(1.0);
9268
9269 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
9270 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
9271
9272 vc_conn := f_start_handler(refers(f_tc_lcs_loc_req_for_idle_ms), pars);
9273 vc_conn.done;
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01009274 f_shutdown_helper();
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02009275}
9276
9277/* With no active lchan, start BSSMAP Perform Location Request on A interface, but omit IMSI; expect failure response.
9278 */
9279private function f_tc_lcs_loc_req_no_subscriber(charstring id) runs on MSC_ConnHdlr {
9280 f_sleep(1.0);
9281
9282 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
9283 f_bssap_le_register_imsi(g_pars.imsi, omit);
9284
9285 /* provoke an abort by omitting both IMSI and IMEI */
9286 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
9287 valueof(ts_BSSMAP_Perform_Location_Request(omit,
9288 ts_CellId_CGI('262'H, '42'H, 23, 42)))));
9289 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
9290
9291 /* BSC tells MSC about failure */
9292 BSSAP.receive(tr_BSSMAP_Perform_Location_Response(
9293 locationEstimate := omit, positioningData := omit,
9294 lCS_Cause := tr_BSSMAP_LcsCause(BSSMAP_LCS_CAUSE_DATA_MISSING_IN_REQ)));
9295
9296 /* There is no lchan. Still the MSC's job to decide whether to tear down the conn or not. */
9297 f_verify_active_A_conn_and_clear();
9298
9299 f_sleep(2.0);
9300 setverdict(pass);
9301}
9302testcase TC_lcs_loc_req_no_subscriber() runs on test_CT {
9303 var MSC_ConnHdlr vc_conn;
9304 var TestHdlrParams pars := f_gen_test_hdlr_pars();
9305
9306 f_init(1, true);
9307 f_sleep(1.0);
9308
9309 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
9310 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
9311
9312 vc_conn := f_start_handler(refers(f_tc_lcs_loc_req_no_subscriber), pars);
9313 vc_conn.done;
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01009314 f_shutdown_helper();
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02009315}
9316
9317/* With an active lchan, start a Perform Location Request on the A-interface, but virtual SMLC does not answer with
9318 * BSSMAP-LE Perform Location Response (before or after sending a BSSLAP TA Request) */
9319private function f_lcs_loc_req_for_active_ms_le_timeout(boolean do_ta) runs on MSC_ConnHdlr {
9320 f_sleep(1.0);
9321
9322 f_establish_fully(omit, omit);
9323 f_bssap_le_register_imsi(g_pars.imsi, omit);
9324
9325 BSSAP.send(valueof(ts_BSSMAP_Perform_Location_Request(ts_BSSMAP_Imsi(g_pars.imsi),
9326 ts_CellId_CGI('262'H, '42'H, 23, 42))));
9327
9328 var PDU_BSSAP_LE plr;
9329 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocReq(BSSMAP_LE_LOC_INFO_CURRENT_GEOGRAPHIC_LOC, ?, ?)) -> value(plr);
9330
9331 if (do_ta) {
9332 /* SMLC wants to ask the TA from the BSC explicitly in a BSSLAP TA Request message */
9333 BSSAP_LE.send(ts_BSSMAP_LE_BSSLAP(ts_BSSLAP_TA_Req));
9334 f_expect_bsslap(tr_BSSLAP_TA_Resp(?, ?));
9335 }
9336
9337 /* SMLC fails to respond, BSC runs into timeout */
9338 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocAbort(BSSMAP_LE_LCS_CAUSE_SYSTEM_FAILURE));
9339 BSSAP_LE.receive(BSSAP_LE_Conn_Prim:CONN_PRIM_DISC_IND);
9340
9341 BSSAP.receive(tr_BSSMAP_Perform_Location_Response(
9342 locationEstimate := omit, positioningData := omit,
9343 lCS_Cause := tr_BSSMAP_LcsCause(BSSMAP_LCS_CAUSE_SYSTEM_FAILURE)));
9344
9345 /* There is no lchan. Still the MSC's job to decide whether to tear down the conn or not. */
9346 f_verify_active_A_conn_and_clear();
9347
9348 f_sleep(2.0);
9349 setverdict(pass);
9350}
9351
9352/* With an active lchan, start a Perform Location Request on the A-interface, but virtual SMLC does not answer with
9353 * BSSMAP-LE Perform Location Response, without sending a BSSLAP TA Request. */
9354private function f_tc_lcs_loc_req_for_active_ms_le_timeout(charstring id) runs on MSC_ConnHdlr {
9355 f_lcs_loc_req_for_active_ms_le_timeout(false);
9356}
9357
9358testcase TC_lcs_loc_req_for_active_ms_le_timeout() runs on test_CT {
9359 var MSC_ConnHdlr vc_conn;
9360 var TestHdlrParams pars := f_gen_test_hdlr_pars();
9361
9362 f_init(1, true);
9363 f_sleep(1.0);
9364 vc_conn := f_start_handler(refers(f_tc_lcs_loc_req_for_active_ms_le_timeout), pars);
9365 vc_conn.done;
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01009366 f_shutdown_helper();
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02009367}
9368
9369/* With an active lchan, start a Perform Location Request on the A-interface, but virtual SMLC does not answer with
9370 * BSSMAP-LE Perform Location Response, after sending a BSSLAP TA Request. */
9371private function f_tc_lcs_loc_req_for_active_ms_le_timeout2(charstring id) runs on MSC_ConnHdlr {
9372 f_lcs_loc_req_for_active_ms_le_timeout(true);
9373}
9374
9375testcase TC_lcs_loc_req_for_active_ms_le_timeout2() runs on test_CT {
9376 var MSC_ConnHdlr vc_conn;
9377 var TestHdlrParams pars := f_gen_test_hdlr_pars();
9378
9379 f_init(1, true);
9380 f_sleep(1.0);
9381 vc_conn := f_start_handler(refers(f_tc_lcs_loc_req_for_active_ms_le_timeout2), pars);
9382 vc_conn.done;
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01009383 f_shutdown_helper();
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02009384}
9385
9386/* With *no* active lchan, start a Perform Location Request, expecting that the MS will be Paged. */
9387private function f_tc_lcs_loc_req_for_idle_ms_no_pag_resp(charstring id) runs on MSC_ConnHdlr {
9388 f_sleep(1.0);
9389
9390 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
9391 f_bssap_le_register_imsi(g_pars.imsi, omit);
9392
9393 /* Register to receive the Paging Command */
9394 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
9395 g_chan_nr := new_chan_nr;
9396 f_rslem_register(0, g_chan_nr);
9397
9398 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
9399 valueof(ts_BSSMAP_Perform_Location_Request(ts_BSSMAP_Imsi(g_pars.imsi),
9400 ts_CellId_CGI('001'H, '01'H, 1, 0)))));
9401 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
9402
9403 var PDU_BSSAP_LE plr;
9404 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocReq(BSSMAP_LE_LOC_INFO_CURRENT_GEOGRAPHIC_LOC, ?, ?)) -> value(plr);
9405
9406 /* SMLC wants to ask the TA from the BSC explicitly in a BSSLAP TA Request message */
9407 BSSAP_LE.send(ts_BSSMAP_LE_BSSLAP(ts_BSSLAP_TA_Req));
9408
9409 /* OsmoBSC needs to Page */
9410 var PDU_BSSAP_LE rx_bsslap;
9411 alt {
9412 [] RSL.receive(tr_RSL_PAGING_CMD(tr_MI_IMSI(g_pars.imsi))) {
9413 f_logp(BSCVTY, "got Paging Command");
9414 repeat;
9415 }
9416 [] BSSAP_LE.receive(tr_BSSMAP_LE_ConnInfo(BSSMAP_LE_PROT_BSSLAP, ?)) -> value(rx_bsslap) {
9417 /* MS does not respond to Paging, TA Req runs into timeout. */
9418 f_match_bsslap(rx_bsslap, tr_BSSLAP_Abort(?));
9419 }
9420 }
9421
9422 /* SMLC responds with failure */
9423 BSSAP_LE.send(ts_BSSMAP_LE_PerfLocResp(omit, BSSMAP_LE_LCS_CAUSE_REQUEST_ABORTED));
9424 BSSAP_LE.receive(BSSAP_LE_Conn_Prim:CONN_PRIM_DISC_IND);
9425
9426 /* BSC tells MSC about failure */
9427 BSSAP.receive(tr_BSSMAP_Perform_Location_Response(
9428 locationEstimate := omit, positioningData := omit,
9429 lCS_Cause := tr_BSSMAP_LcsCause(BSSMAP_LCS_CAUSE_REQUEST_ABORTED)));
9430
9431 /* There is no lchan. Still the MSC's job to decide whether to tear down the conn or not. */
9432 f_verify_active_A_conn_and_clear();
9433
9434 f_sleep(2.0);
9435 setverdict(pass);
9436}
9437testcase TC_lcs_loc_req_for_idle_ms_no_pag_resp() runs on test_CT {
9438 var MSC_ConnHdlr vc_conn;
9439 var TestHdlrParams pars := f_gen_test_hdlr_pars();
9440
9441 f_init(1, true);
9442 f_sleep(1.0);
9443
9444 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
9445 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
9446
9447 vc_conn := f_start_handler(refers(f_tc_lcs_loc_req_for_idle_ms_no_pag_resp), pars);
9448 vc_conn.done;
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01009449 f_shutdown_helper();
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02009450}
9451
9452/* During an ongoing Location Request, the MS sends a CM Service Request. Expect the same A-conn to be re-used / taken
9453 * over. */
9454private function f_tc_cm_service_during_lcs_loc_req(charstring id) runs on MSC_ConnHdlr {
9455 f_sleep(1.0);
9456
9457 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
9458 f_bssap_le_register_imsi(g_pars.imsi, omit);
9459
9460 /* Register to receive the Paging Command */
9461 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
9462 g_chan_nr := new_chan_nr;
9463 f_rslem_register(0, g_chan_nr);
9464
9465 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
9466 valueof(ts_BSSMAP_Perform_Location_Request(ts_BSSMAP_Imsi(g_pars.imsi),
9467 ts_CellId_CGI('001'H, '01'H, 1, 0)))));
9468 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
9469
9470 var PDU_BSSAP_LE plr;
9471 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocReq(BSSMAP_LE_LOC_INFO_CURRENT_GEOGRAPHIC_LOC, ?, ?)) -> value(plr);
9472
9473 /* As the A-interface conn was established for LCS, the MS coincidentally decides to issue a CM Service Request
9474 * and establish Layer 3. It should use the existing A-interface conn. */
Neels Hofmeyr85bcd272021-07-22 19:14:48 +02009475 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 +02009476 do_clear := false, expect_bssmap_l3 := true);
9477
9478 /* SMLC wants to ask the TA from the BSC explicitly in a BSSLAP TA Request message */
9479 BSSAP_LE.send(ts_BSSMAP_LE_BSSLAP(ts_BSSLAP_TA_Req));
9480
9481 /* OsmoBSC already has an lchan, no need to Page, just returns the TA */
9482 f_expect_bsslap(tr_BSSLAP_TA_Resp(?, ?));
9483
9484 /* SMLC got the TA from the BSC, now responds with geo information data. */
9485 BSSAP_LE.send(ts_BSSMAP_LE_PerfLocResp(gad_ell_point_unc_circle, omit));
9486 BSSAP_LE.receive(BSSAP_LE_Conn_Prim:CONN_PRIM_DISC_IND);
9487 BSSAP.receive(tr_BSSMAP_Perform_Location_Response(tr_BSSMAP_IE_LocationEstimate(gad_ell_point_unc_circle)));
9488
9489 /* The lchan should still exist, it was from a CM Service Request. */
9490 f_mo_l3_transceive();
9491
Neels Hofmeyr85bcd272021-07-22 19:14:48 +02009492 f_perform_clear();
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02009493
9494 f_sleep(2.0);
9495 setverdict(pass);
9496}
9497testcase TC_cm_service_during_lcs_loc_req() runs on test_CT {
9498 var MSC_ConnHdlr vc_conn;
9499 var TestHdlrParams pars := f_gen_test_hdlr_pars();
9500
9501 f_init(1, true);
9502 f_sleep(1.0);
9503
9504 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
9505 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
9506
9507 vc_conn := f_start_handler(refers(f_tc_cm_service_during_lcs_loc_req), 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/* During an ongoing Perform Location Request, do a Handover, an expect a BSSLAP Reset message from the BSC to indicate
9513 * the new lchan after handover. */
9514private function f_tc_ho_during_lcs_loc_req(charstring id) runs on MSC_ConnHdlr {
9515 f_sleep(1.0);
9516
9517 f_establish_fully(omit, omit);
9518 f_bssap_le_register_imsi(g_pars.imsi, omit);
9519
9520 BSSAP.send(valueof(ts_BSSMAP_Perform_Location_Request(ts_BSSMAP_Imsi(g_pars.imsi),
9521 ts_CellId_CGI('262'H, '42'H, 23, 42))));
9522
9523 var PDU_BSSAP_LE plr;
9524 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocReq(BSSMAP_LE_LOC_INFO_CURRENT_GEOGRAPHIC_LOC, ?, ?)) -> value(plr);
9525
9526 /* SMLC ponders the Location Request, in the meantime the BSC decides to handover */
9527 f_bts_0_cfg(BSCVTY, {"neighbor bts 1"});
9528
9529 var HandoverState hs := {
9530 rr_ho_cmpl_seen := false,
9531 handover_done := false,
Neels Hofmeyrc741fcb2021-10-02 14:52:28 +02009532 old_chan_nr := -,
9533 expect_target_tsc := BTS_TSC[1]
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02009534 };
9535 /* issue hand-over command on VTY */
9536 f_vty_handover(BSCVTY, 0, 0, g_chan_nr, 1);
9537 /* temporarily suspend DChan processing on BTS1 to avoid race with RSLEM_register */
9538 f_rslem_suspend(RSL1_PROC);
9539
9540 /* From the MGW perspective, a handover is is characterized by
9541 * performing one MDCX operation with the MGW. So we expect to see
9542 * one more MDCX during handover. */
9543 g_media.mgcp_conn[0].mdcx_seen_exp := g_media.mgcp_conn[0].crcx_seen_exp + 1;
9544
9545 alt {
9546 [] as_handover(hs);
9547 }
9548
9549 var PDU_BSSAP_LE rx_bsslap;
9550
9551 interleave {
9552 /* Expect the BSC to inform the MSC about the handover */
9553 [] BSSAP.receive(tr_BSSMAP_HandoverPerformed);
9554
9555 /* Expect the BSC to inform the SMLC about the handover */
9556 [] BSSAP_LE.receive(tr_BSSMAP_LE_ConnInfo(BSSMAP_LE_PROT_BSSLAP, ?)) -> value(rx_bsslap) {
9557 f_match_bsslap(rx_bsslap, tr_BSSLAP_Reset(BSSLAP_CAUSE_INTRA_BSS_HO));
9558 }
9559 }
9560
9561 /* SMLC now responds with geo information data. */
9562 BSSAP_LE.send(ts_BSSMAP_LE_PerfLocResp(gad_ell_point_unc_circle, omit));
9563 BSSAP_LE.receive(BSSAP_LE_Conn_Prim:CONN_PRIM_DISC_IND);
9564 BSSAP.receive(tr_BSSMAP_Perform_Location_Response(tr_BSSMAP_IE_LocationEstimate(gad_ell_point_unc_circle)));
9565
9566 /* lchan still active */
9567 f_mo_l3_transceive(RSL1);
9568
9569 /* MSC decides it is done now. */
Neels Hofmeyr85bcd272021-07-22 19:14:48 +02009570 f_perform_clear(RSL1, RSL1_PROC);
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02009571
9572 f_sleep(2.0);
9573 setverdict(pass);
9574}
9575testcase TC_ho_during_lcs_loc_req() runs on test_CT {
9576 var MSC_ConnHdlr vc_conn;
9577 var TestHdlrParams pars := f_gen_test_hdlr_pars();
9578
9579 f_init(2, true);
9580 f_sleep(1.0);
9581 vc_conn := f_start_handler(refers(f_tc_ho_during_lcs_loc_req), pars);
9582 vc_conn.done;
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01009583 f_shutdown_helper();
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02009584}
9585
Neels Hofmeyrbf037052020-10-28 22:52:02 +00009586/* Attempt Complete Layer 3 without any MSC available (OS#4832) */
9587private function f_tc_no_msc(charstring id) runs on MSC_ConnHdlr {
9588 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
9589
9590 /* Also disable attach for the single connected MSC */
9591 f_vty_msc_allow_attach(BSCVTY, { false });
9592
9593 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) ));
9594 f_chan_est(g_pars.ra, l3_enc, g_pars.link_id, g_pars.fn);
9595
9596 /* No MSC is found, expecting a proper release on RSL */
9597 interleave {
9598 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_RELEASE)) {
9599 f_logp(BSCVTY, "Got RSL RR Release");
9600 }
9601 [] RSL.receive(tr_RSL_DEACT_SACCH(g_chan_nr)) {
9602 f_logp(BSCVTY, "Got RSL Deact SACCH");
9603 }
Neels Hofmeyr3c5127e2021-07-22 19:18:40 +02009604 [] RSL.receive(tr_RSL_RF_CHAN_REL(g_chan_nr)) {
Neels Hofmeyrbf037052020-10-28 22:52:02 +00009605 f_logp(BSCVTY, "Got RSL RF Chan Rel, sending Rel Ack");
9606 RSL.send(ts_RSL_RF_CHAN_REL_ACK(g_chan_nr));
Neels Hofmeyre680b012021-07-22 19:19:09 +02009607 f_rslem_unregister(0, g_chan_nr);
Neels Hofmeyrbf037052020-10-28 22:52:02 +00009608 }
9609 }
9610 setverdict(pass);
9611}
9612testcase TC_no_msc() runs on test_CT {
9613
9614 f_init(1, true);
9615 f_sleep(1.0);
9616 var MSC_ConnHdlr vc_conn;
9617 var TestHdlrParams pars := f_gen_test_hdlr_pars();
9618
9619 f_ctrs_bsc_init(counternames_bsc_mscpool);
9620
9621 vc_conn := f_start_handler(refers(f_tc_no_msc), pars);
9622 vc_conn.done;
9623
9624 f_ctrs_bsc_add("mscpool:subscr:no_msc");
9625 f_ctrs_bsc_verify();
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01009626 f_shutdown_helper();
Neels Hofmeyrbf037052020-10-28 22:52:02 +00009627}
9628
Harald Welte0ea2d5e2018-04-07 21:40:29 +02009629/* Dyn PDCH todo:
9630 * activate OSMO as TCH/F
9631 * activate OSMO as TCH/H
9632 * does the BSC-located PCU socket get the updated INFO?
9633 * what if no PCU is connected at the time?
9634 * is the info correct on delayed PCU (re)connect?
9635 */
Harald Welte94e0c342018-04-07 11:33:23 +02009636
Neels Hofmeyr87857ec2021-04-25 16:17:47 +00009637private function f_TC_refuse_mode_modif_to_vamos(charstring id) runs on MSC_ConnHdlr {
9638 var PDU_BSSAP ass_cmd := f_gen_ass_req(g_pars.use_osmux);
9639 var template PDU_BSSAP exp_compl := f_gen_exp_compl(g_pars.use_osmux);
9640
9641 /* puzzle together the ASSIGNMENT REQ for given codec[s] */
9642 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
9643 ass_cmd.pdu.bssmap.assignmentRequest.codecList := g_pars.ass_codec_list;
9644 exp_compl.pdu.bssmap.assignmentComplete.speechCodec.codecElements[0] :=
9645 g_pars.ass_codec_list.codecElements[0];
9646 if (isvalue(g_pars.expect_mr_s0_s7)) {
9647 exp_compl.pdu.bssmap.assignmentComplete.speechCodec.codecElements[0].s0_7 :=
9648 g_pars.expect_mr_s0_s7;
9649 }
9650 }
9651 ass_cmd.pdu.bssmap.assignmentRequest.channelType :=
9652 f_BSSMAP_chtype_from_codec(g_pars.ass_codec_list.codecElements[0]);
9653 log("expecting ASS COMPL like this: ", exp_compl);
9654
9655 f_establish_fully(ass_cmd, exp_compl);
9656
Neels Hofmeyr8746b0d2021-06-01 17:25:39 +02009657 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 +00009658
9659 var RSL_Message rsl;
9660
9661 timer T := 5.0;
9662 T.start;
9663 alt {
9664 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr)) -> value rsl {
9665 var PDU_ML3_NW_MS l3 := dec_PDU_ML3_NW_MS(rsl.ies[2].body.l3_info.payload);
9666 log("Rx L3 from net: ", l3);
9667 if (ischosen(l3.msgs.rrm.channelModeModify)) {
9668 setverdict(fail, "Mode Modify to VAMOS succeeded even though BTS does not support VAMOS");
9669 mtc.stop;
9670 }
9671 }
9672 [] RSL.receive(tr_RSL_MODE_MODIFY_REQ(g_chan_nr, ?)) -> value rsl {
9673 setverdict(fail, "Mode Modify to VAMOS succeeded even though BTS does not support VAMOS");
9674 mtc.stop;
9675 }
9676 [] T.timeout {
9677 /* The BTS does not exhibit BTS_FEAT_VAMOS, so no VAMOS related Mode Modify should happen. */
9678 setverdict(pass);
9679 }
9680 }
9681 T.stop;
9682}
9683
9684/* The BSC does *not* indicate BTS_FEAT_VAMOS; make sure that a channel Mode Modify to VAMOS mode is refused by
9685 * osmo-bsc. */
9686testcase TC_refuse_mode_modif_to_vamos() runs on test_CT {
9687 var TestHdlrParams pars := f_gen_test_hdlr_pars();
9688 var MSC_ConnHdlr vc_conn;
9689
9690 f_init(1, true);
9691 f_sleep(1.0);
9692
9693 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
9694 vc_conn := f_start_handler(refers(f_TC_refuse_mode_modif_to_vamos), pars);
9695 vc_conn.done;
9696 f_shutdown_helper();
9697}
9698
9699/* The BSC does *not* indicate BTS_FEAT_VAMOS; make sure that a channel activation to VAMOS mode is refused by osmo-bsc.
9700 */
9701testcase TC_refuse_chan_act_to_vamos() runs on test_CT {
9702 f_init_vty();
9703
9704 f_init(1, false);
9705 f_sleep(1.0);
9706
9707 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 1 sub-slot 0 activate-vamos fr");
9708
9709 var ASP_RSL_Unitdata rx_rsl_ud;
9710 timer T := 5.0;
9711
9712 T.start;
9713 alt {
9714 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(?, IPAC_PROTO_RSL_TRX0)) -> value rx_rsl_ud {
9715 if (rx_rsl_ud.rsl.msg_type == RSL_MT_CHAN_ACTIV) {
9716 T.stop;
9717 setverdict(fail, "CHANnel ACTivate in VAMOS mode succeeded even though BTS does not support VAMOS");
9718 mtc.stop;
9719 }
9720 repeat;
9721 }
9722 [] T.timeout {
9723 /* The BTS does not exhibit BTS_FEAT_VAMOS, so no VAMOS related CHANnel ACTivate should happen. */
9724 setverdict(pass);
9725 }
9726 }
9727}
9728
Neels Hofmeyrd2d9f332021-04-28 22:23:36 +00009729private function f_TC_reassignment_codec(charstring id) runs on MSC_ConnHdlr {
9730 /* First fully set up a speech lchan */
9731 f_TC_assignment_codec(id);
9732
9733 /* Trigger re-assignment to another lchan */
9734 var AssignmentState assignment_st := valueof(ts_AssignmentStateInit);
9735
9736 /* Re-Assignment should tell the MGW endpoint the new lchan's RTP address and port, so expecting to see exactly
9737 * one MDCX on MGCP. */
9738 g_media.mgcp_conn[0].mdcx_seen_exp := g_media.mgcp_conn[0].mdcx_seen_exp + 1;
9739
9740 /* The new lchan will see all-new IPAC_CRCX and IPAC_MDCX messages telling the BTS the same RTP address and port
9741 * as the old lchan used. */
9742 g_media.bts.ipa_crcx_seen := false;
9743 g_media.bts.ipa_mdcx_seen := false;
9744
9745 /* Send different BTS side RTP port number for the new lchan */
9746 g_media.bts.bts.port_nr := 4223;
9747
9748 f_rslem_register(0, valueof(ts_RslChanNr_Bm(2))); /* <-- FIXME: can we somehow infer the timeslot that will be used? */
9749
9750 /* Trigger re-assignment. */
9751 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot " & int2str(g_chan_nr.tn) & " sub-slot 0 assignment");
9752
9753 timer T := 5.0;
9754 T.start;
9755 alt {
9756 [] as_assignment(assignment_st);
9757 [] as_Media();
9758 [] T.timeout {
9759 break;
9760 }
9761 }
9762
9763 if (not assignment_st.assignment_done) {
9764 setverdict(fail, "Assignment did not complete");
9765 mtc.stop;
9766 }
9767
9768 f_check_mgcp_expectations()
9769 setverdict(pass);
9770
9771 f_sleep(2.0);
9772 log("show lchan summary: ", f_vty_transceive_ret(BSCVTY, "show lchan summary"));
9773
9774 /* Instruct BSC to clear channel */
9775 var BssmapCause cause := 0;
9776 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
9777 interleave {
Neels Hofmeyrd2d9f332021-04-28 22:23:36 +00009778 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_RELEASE)) {}
9779 [] RSL.receive(tr_RSL_DEACT_SACCH(g_chan_nr)) {}
Neels Hofmeyr3c5127e2021-07-22 19:18:40 +02009780 [] RSL.receive(tr_RSL_RF_CHAN_REL(g_chan_nr)) {
Neels Hofmeyrd2d9f332021-04-28 22:23:36 +00009781 RSL.send(ts_RSL_RF_CHAN_REL_ACK(g_chan_nr));
Neels Hofmeyre680b012021-07-22 19:19:09 +02009782 f_rslem_unregister(0, g_chan_nr);
Neels Hofmeyrd2d9f332021-04-28 22:23:36 +00009783 }
9784 [] BSSAP.receive(tr_BSSMAP_ClearComplete) {
9785 BSSAP.send(RAN_Conn_Prim:MSC_CONN_PRIM_DISC_REQ);
9786 }
9787 }
Neels Hofmeyr40a45d12021-09-23 22:57:12 +02009788 f_expect_dlcx_conns();
Neels Hofmeyrd2d9f332021-04-28 22:23:36 +00009789
9790 f_sleep(0.5);
9791}
9792
9793testcase TC_reassignment_fr() runs on test_CT {
9794 var TestHdlrParams pars := f_gen_test_hdlr_pars();
9795 var MSC_ConnHdlr vc_conn;
9796
9797 f_init(1, true);
9798 f_sleep(1.0);
9799
Neels Hofmeyrac432fa2021-11-02 16:45:56 +01009800 f_ctrs_bsc_and_bts_handover_init();
Neels Hofmeyrd2d9f332021-04-28 22:23:36 +00009801
9802 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
9803 vc_conn := f_start_handler(refers(f_TC_reassignment_codec), pars);
9804 vc_conn.done;
9805
9806 /* from f_establish_fully() */
9807 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
9808 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
9809 /* from re-assignment */
9810 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
9811 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
9812 f_ctrs_bsc_and_bts_verify();
9813 f_shutdown_helper();
9814}
9815
Neels Hofmeyrfeda88e2021-07-19 13:51:29 +02009816const charstring REEST_LOST_CONNECTION := "REEST_LOST_CONNECTION";
9817const charstring REEST_CLEAR := "REEST_CLEAR";
9818const charstring REEST_CLEAR_DONE := "REEST_CLEAR_DONE";
9819
9820/* CM Re-Establishment, 3GPP TS 24.008 4.5.1.6.
9821 * The MS <-> BTS loses radio connection, MS shows up on second BTS and asks for CM Re-Establishment.
9822 * BSC should establish a separate A conn for the same MS, the original A conn is then cleared by
9823 * the MSC as the CM Re-Establishment is handled.
9824 *
9825 * MS bts0 bts1 bsc msc test-component
9826 * |<----->|<----------------->|<-0-->| _1 Establish channel on bts 0
9827 * | | _1 wait a bit, to settle down
9828 * |<-x x--| | _1 "lose connection"
9829 * | | REEST_LOST_CONNECTION
9830 * |----------------->|------->|--1-->| _2 new A-conn: Chan Rqd, Imm Ass, Compl L3 with CM Re-Establishment Req
9831 * | | REEST_CLEAR
9832 * | |<-0---| _1 Clear Command on first A-conn
9833 * | |--0-->| _1 Clear Complete
9834 * | |<----------------->| | _1 Release first channel
9835 * | | REEST_CLEAR_DONE
9836 * |<-----------------|<-------|<-1---| _2 Chan Activ, Assignment Command
9837 * |<-----------------|<-------|<-1---| _2 Clear Command, Release
9838 *
9839 */
9840private function f_tc_cm_reestablishment_1(charstring id) runs on MSC_ConnHdlr {
9841 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
9842 var PDU_BSSAP ass_cmd := f_gen_ass_req();
9843
9844 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
9845 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
9846
9847 f_establish_fully(ass_cmd, exp_compl);
9848
9849 /* The original channel loses connection, MS attemts CM Re-Establishment on another cell, see
9850 * f_tc_cm_reestablishment_2(). This established channel stays active until MSC sends a Clear Command. The time
9851 * when exactly that happens is determined by f_tc_cm_reestablishment_2(). */
9852 f_sleep(2.0);
9853 COORD.send(REEST_LOST_CONNECTION);
9854
9855 alt {
9856 [] COORD.receive(REEST_CLEAR);
9857 [] RSL.receive(tr_RSL_DEACT_SACCH(g_chan_nr)) {
9858 setverdict(fail, "Unexpected channel release");
9859 mtc.stop;
9860 }
9861 [] RSL.receive(tr_RSL_RF_CHAN_REL(g_chan_nr)) {
9862 setverdict(fail, "Unexpected channel release");
9863 mtc.stop;
9864 }
9865 }
9866 f_perform_clear()
9867 f_expect_dlcx_conns();
Neels Hofmeyr969abd02021-09-23 22:24:08 +02009868 f_create_mgcp_delete_ep(g_media.mgcp_ep);
Neels Hofmeyrfeda88e2021-07-19 13:51:29 +02009869 COORD.send(REEST_CLEAR_DONE);
9870}
9871
9872private function f_tc_cm_reestablishment_2(charstring id) runs on MSC_ConnHdlr {
9873 f_MscConnHdlr_init(g_pars.media_nr, host_bts, host_mgw_mgcp, FR_AMR);
9874
9875 /* The MS lost the connection on the first channel, now establishes another one */
9876 COORD.receive(REEST_LOST_CONNECTION);
9877
9878 var MobileIdentityLV mi := valueof(ts_MI_IMSI_LV(g_pars.imsi));
9879 var PDU_ML3_MS_NW l3_info := valueof(ts_CM_REESTABL_REQ(mi));
9880 var octetstring l3_enc := enc_PDU_ML3_MS_NW(l3_info);
9881
9882 f_create_bssmap_exp(l3_enc);
Neels Hofmeyrc7b1f6d2021-07-20 23:21:36 +02009883 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 +02009884 BSSAP.receive(tr_BSSMAP_ComplL3(l3_enc));
9885
9886 /* MSC got the CM Re-Establishment request and first off clears the previous conn. */
9887 COORD.send(REEST_CLEAR);
9888 COORD.receive(REEST_CLEAR_DONE);
9889
9890 f_sleep(2.0);
9891
9892 /* Answer the CM Re-Establishment with an Assignment Command. */
9893 var template PDU_BSSAP expect_assignment_compl := f_gen_exp_compl();
9894 var PDU_BSSAP ass_cmd := f_gen_ass_req();
9895 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
9896 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
9897
9898 var AssignmentState st := valueof(ts_AssignmentStateInit);
9899 st.voice_call := true;
9900 st.is_assignment := true;
9901
9902 var ExpectCriteria mgcpcrit := {
9903 connid := omit,
9904 endpoint := omit,
9905 transid := omit
9906 };
9907 f_create_mgcp_expect(mgcpcrit);
9908
Neels Hofmeyrc7b1f6d2021-07-20 23:21:36 +02009909 f_rslem_dchan_queue_enable(RSL1_PROC);
Neels Hofmeyrfeda88e2021-07-19 13:51:29 +02009910
9911 BSSAP.send(ass_cmd);
9912
9913 var PDU_BSSAP bssap;
9914
9915 alt {
Neels Hofmeyrc7b1f6d2021-07-20 23:21:36 +02009916 [] as_assignment(st, rsl_pt := RSL1, rsl_proc_pt := RSL1_PROC);
9917 [] as_Media_ipacc(RSL1, RSL2);
9918 [] as_Media_mgw();
Neels Hofmeyrfeda88e2021-07-19 13:51:29 +02009919 [st.assignment_done] BSSAP.receive(expect_assignment_compl) {
9920 break;
9921 }
9922 }
9923
9924 f_sleep(3.0);
9925
9926 f_logp(BSCVTY, "f_tc_cm_reestablishment_2 clearing");
Neels Hofmeyrc7b1f6d2021-07-20 23:21:36 +02009927 f_perform_clear(RSL1, RSL1_PROC);
Neels Hofmeyrfeda88e2021-07-19 13:51:29 +02009928 f_expect_dlcx_conns();
9929}
9930
9931testcase TC_cm_reestablishment() runs on test_CT {
9932 var TestHdlrParams pars1 := f_gen_test_hdlr_pars();
9933 var MSC_ConnHdlr vc_conn1;
9934
9935 var TestHdlrParams pars2 := f_gen_test_hdlr_pars();
9936 var MSC_ConnHdlr vc_conn2;
9937 pars2.imsi := pars1.imsi;
9938 pars2.media_nr := 2;
Neels Hofmeyrbf720202021-10-02 12:58:24 +02009939 pars2.expect_tsc := BTS_TSC[1];
Neels Hofmeyrfeda88e2021-07-19 13:51:29 +02009940
9941 f_init(2, true, guard_timeout := 40.0);
9942 f_sleep(1.0);
9943
9944 vc_conn1 := f_start_handler_create(pars1);
9945 vc_conn2 := f_start_handler_create(pars2);
9946 connect(vc_conn1:COORD, vc_conn2:COORD);
9947 f_start_handler_run(vc_conn1, refers(f_tc_cm_reestablishment_1), pars1);
9948 f_start_handler_run(vc_conn2, refers(f_tc_cm_reestablishment_2), pars2);
9949 vc_conn1.done;
9950 vc_conn2.done;
9951
9952 f_shutdown_helper();
9953}
Neels Hofmeyr87857ec2021-04-25 16:17:47 +00009954
Neels Hofmeyrb07b2952021-08-07 04:23:14 +02009955function f_exp_ipa_rx_nonfatal(integer bts_nr, template (present) RSL_Message t_rx, float t_secs := 2.0,
9956 IpaStreamId sid := IPAC_PROTO_RSL_TRX0, boolean ignore_other_rx := true)
9957runs on test_CT return template (omit) RSL_Message {
9958 var ASP_RSL_Unitdata rx_rsl_ud;
9959 timer T := t_secs;
9960
9961 T.start;
9962 alt {
9963 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(t_rx, sid)) -> value rx_rsl_ud {
9964 T.stop;
9965 }
9966 [ignore_other_rx] IPA_RSL[bts_nr].receive { repeat; }
9967 [not ignore_other_rx] IPA_RSL[bts_nr].receive {
9968 log("f_exp_ipa_rx_nonfatal(): Got different message than ", t_rx);
9969 T.stop;
9970 return omit;
9971 }
9972 [] T.timeout {
9973 return omit;
9974 }
9975 }
9976 return rx_rsl_ud.rsl;
9977}
9978
9979private function f_vty_set_imm_ass(TELNETasp_PT pt, BtsNr bts_nr := 0, charstring imm_ass_setting := "post-chan-ack") {
9980 f_vty_enter_cfg_bts(pt, bts_nr);
9981 f_vty_transceive(pt, "immediate-assignment " & imm_ass_setting);
9982 f_vty_transceive(pt, "exit");
9983 f_vty_transceive(pt, "exit");
9984 f_vty_transceive(pt, "exit");
9985}
9986
9987private function f_verify_imm_ass(RSL_Message imm_ass, template uint8_t ra := ?, template GsmFrameNumber fn := ?,
Neels Hofmeyr07603cf2021-09-07 19:05:52 +02009988 template RslChannelNr chan_nr := ?,
9989 template (present) uint12_t arfcn := ?,
9990 template (present) uint3_t tsc := ?)
Neels Hofmeyrb07b2952021-08-07 04:23:14 +02009991{
9992 var RSL_IE_Body full_imm_ass_info;
9993 if (not f_rsl_find_ie(imm_ass, RSL_IE_FULL_IMM_ASS_INFO, full_imm_ass_info)) {
9994 setverdict(fail, "RSL Full Immediate Assign Info IE is absent");
9995 mtc.stop;
9996 }
9997
9998 var GsmRrMessage rr_imm_ass := dec_GsmRrMessage(full_imm_ass_info.full_imm_ass_info.payload);
9999 var template GsmRrMessage expect_imm_ass := tr_IMM_ASS(ra := ra,
10000 fn := fn,
Neels Hofmeyr07603cf2021-09-07 19:05:52 +020010001 ch_desc := tr_ChanDescH0(chan_nr, arfcn, tsc),
Neels Hofmeyrb07b2952021-08-07 04:23:14 +020010002 page_mode := ?);
10003 if (not match(rr_imm_ass, expect_imm_ass)) {
10004 log("Error: expected ", expect_imm_ass, " got ", rr_imm_ass);
10005 setverdict(fail, "Failed to match Immediate Assignment");
10006 mtc.stop;
10007 }
10008}
10009
10010testcase TC_imm_ass_post_chan_ack() runs on test_CT {
10011 var RSL_Message chan_act;
10012 var RSL_Message imm_ass;
10013
10014 f_init(1, false);
10015 f_sleep(1.0);
10016
10017 /* (should be the default anyway, just to make things clear) */
10018 f_vty_set_imm_ass(BSCVTY, 0, "post-chan-ack");
10019
10020 /* RA containing reason=LU */
10021 var GsmFrameNumber fn := 2342;
10022 var uint8_t ra := 2;
10023 f_ipa_tx(0, ts_RSL_CHAN_RQD(int2oct(ra, 1), fn));
10024
10025 chan_act := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
10026
10027 /* First send the Chan Act ACK */
10028 var RslChannelNr chan_nr := chan_act.ies[0].body.chan_nr;
Neels Hofmeyr07603cf2021-09-07 19:05:52 +020010029 var RSL_IE_Body chan_ident_ie;
10030 if (not f_rsl_find_ie(chan_act, RSL_IE_CHAN_IDENT, chan_ident_ie)) {
10031 setverdict(fail, "RSL Channel Identification IE is absent");
10032 mtc.stop;
10033 }
10034
Neels Hofmeyrb07b2952021-08-07 04:23:14 +020010035 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, fn + 10));
10036
10037 /* Then expect the Immediate Assignment, after we ACKed the chan act */
10038 imm_ass := f_exp_ipa_rx(0, tr_RSL_IMM_ASSIGN(0));
10039
Neels Hofmeyr07603cf2021-09-07 19:05:52 +020010040 f_verify_imm_ass(imm_ass, ra, fn, chan_nr, chan_ident_ie.chan_ident.ch_desc.v.arfcn,
10041 chan_ident_ie.chan_ident.ch_desc.v.tsc);
Neels Hofmeyrb07b2952021-08-07 04:23:14 +020010042
10043 /* Check that the lchan is working */
10044 var octetstring l3 := '00010203040506'O;
10045 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
10046
10047 var BSSAP_N_CONNECT_ind rx_c_ind;
10048 BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) -> value rx_c_ind;
10049 BSSAP.send(ts_BSSAP_CONNECT_res(rx_c_ind.connectionId));
10050
10051 f_sleep(1.0);
10052 f_shutdown_helper();
10053}
10054
10055testcase TC_imm_ass_pre_chan_ack() runs on test_CT {
10056 var RSL_Message chan_act;
10057 var RSL_Message imm_ass;
10058
10059 f_init(1, false);
10060 f_sleep(1.0);
10061
10062 f_vty_set_imm_ass(BSCVTY, 0, "pre-chan-ack");
10063
10064 /* RA containing reason=LU */
10065 var GsmFrameNumber fn := 2342;
10066 var uint8_t ra := 2;
10067 f_ipa_tx(0, ts_RSL_CHAN_RQD(int2oct(ra, 1), fn));
10068
10069 /* (set bts 0 cfg back to default) */
10070 f_vty_set_imm_ass(BSCVTY);
10071
10072 chan_act := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
10073 var RslChannelNr chan_nr := chan_act.ies[0].body.chan_nr;
Neels Hofmeyr07603cf2021-09-07 19:05:52 +020010074 var RSL_IE_Body chan_ident_ie;
10075 if (not f_rsl_find_ie(chan_act, RSL_IE_CHAN_IDENT, chan_ident_ie)) {
10076 setverdict(fail, "RSL Channel Identification IE is absent");
10077 mtc.stop;
10078 }
Neels Hofmeyrb07b2952021-08-07 04:23:14 +020010079
10080 /* *FIRST* expect the Immediate Assignment, before we ACK the chan act */
10081 imm_ass := f_exp_ipa_rx(0, tr_RSL_IMM_ASSIGN(0));
Neels Hofmeyr07603cf2021-09-07 19:05:52 +020010082 f_verify_imm_ass(imm_ass, ra, fn, chan_nr, chan_ident_ie.chan_ident.ch_desc.v.arfcn,
10083 chan_ident_ie.chan_ident.ch_desc.v.tsc);
Neels Hofmeyrb07b2952021-08-07 04:23:14 +020010084
10085 /* Only now send the Chan Act ACK */
10086 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, fn+10));
10087
10088 /* Check that the lchan is working */
10089 var octetstring l3 := '00010203040506'O;
10090 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
10091
10092 var BSSAP_N_CONNECT_ind rx_c_ind;
10093 BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) -> value rx_c_ind;
10094 BSSAP.send(ts_BSSAP_CONNECT_res(rx_c_ind.connectionId));
10095
10096 f_sleep(1.0);
10097 f_shutdown_helper();
10098}
10099
Neels Hofmeyr23158742021-09-07 19:08:07 +020010100testcase TC_imm_ass_pre_ts_ack() runs on test_CT {
10101 var RSL_Message chan_act;
10102 var RSL_Message imm_ass;
10103
10104 f_init(1, false);
10105 f_sleep(1.0);
10106
10107 f_vty_set_imm_ass(BSCVTY, 0, "pre-ts-ack");
10108
10109 /* RA containing reason=LU */
10110 var GsmFrameNumber fn := 2342;
10111 var uint8_t ra := 2;
10112 f_ipa_tx(0, ts_RSL_CHAN_RQD(int2oct(ra, 1), fn));
10113
10114 /* (set bts 0 cfg back to default) */
10115 f_vty_set_imm_ass(BSCVTY);
10116
10117 chan_act := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
10118 var RslChannelNr chan_nr := chan_act.ies[0].body.chan_nr;
10119 var RSL_IE_Body chan_ident_ie;
10120 if (not f_rsl_find_ie(chan_act, RSL_IE_CHAN_IDENT, chan_ident_ie)) {
10121 setverdict(fail, "RSL Channel Identification IE is absent");
10122 mtc.stop;
10123 }
10124
10125 /* *FIRST* expect the Immediate Assignment, before we ACK the chan act */
10126 imm_ass := f_exp_ipa_rx(0, tr_RSL_IMM_ASSIGN(0));
10127 f_verify_imm_ass(imm_ass, ra, fn, chan_nr, chan_ident_ie.chan_ident.ch_desc.v.arfcn,
10128 chan_ident_ie.chan_ident.ch_desc.v.tsc);
10129
10130 /* Only now send the Chan Act ACK */
10131 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, fn+10));
10132
10133 /* Check that the lchan is working */
10134 var octetstring l3 := '00010203040506'O;
10135 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
10136
10137 var BSSAP_N_CONNECT_ind rx_c_ind;
10138 BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) -> value rx_c_ind;
10139 BSSAP.send(ts_BSSAP_CONNECT_res(rx_c_ind.connectionId));
10140
10141 f_sleep(1.0);
10142 f_shutdown_helper();
10143}
10144
Neels Hofmeyr7a6d0602021-08-07 04:23:50 +020010145testcase TC_imm_ass_pre_chan_ack_dyn_ts() runs on test_CT {
10146 /* change Timeslot 6 before f_init() starts RSL */
10147 f_init_vty();
10148 f_ts_set_chcomb(0, 0, 6, "TCH/F_TCH/H_PDCH");
10149 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
10150
10151 f_init(1, false);
10152 f_sleep(1.0);
10153
10154 var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(6));
10155 /* The BSC will activate the dynamic PDCH by default, so confirm that */
10156 f_exp_ipa_rx(0, tr_RSL_CHAN_ACT_PDCH(chan_nr, ?));
10157 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, 2323));
10158
10159 /* clean up timeslot 6 config, will only take effect when the OML drops the next time */
10160 f_ts_set_chcomb(0, 0, 6, "PDCH");
10161
10162 /* block all static timeslots so that the dyn TS will be used */
10163 f_disable_all_tch_f();
10164 f_disable_all_tch_h();
10165 f_disable_all_sdcch();
10166
10167 var RSL_Message chan_act;
10168 var RSL_Message imm_ass;
10169
10170 f_init(1, false);
10171 f_sleep(1.0);
10172
10173 f_vty_set_imm_ass(BSCVTY, 0, "pre-chan-ack");
10174
10175 /* RA containing reason=LU */
10176 var GsmFrameNumber fn := 2342;
10177 var uint8_t ra := 2;
10178 f_ipa_tx(0, ts_RSL_CHAN_RQD(int2oct(ra, 1), fn));
10179
10180 /* (set bts 0 cfg back to default) */
10181 f_vty_set_imm_ass(BSCVTY);
10182
10183 /* Expect the dyn TS to deactivate PDCH first */
10184 f_exp_ipa_rx(0, tr_RSL_RF_CHAN_REL(chan_nr));
10185 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(chan_nr));
10186
10187 /* Now activation as SDCCH8 */
10188 chan_nr := valueof(t_RslChanNr_SDCCH8(tn := 6, sub_slot := 0));
10189
10190 chan_act := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
Neels Hofmeyr07603cf2021-09-07 19:05:52 +020010191 var RSL_IE_Body chan_ident_ie;
10192 if (not f_rsl_find_ie(chan_act, RSL_IE_CHAN_IDENT, chan_ident_ie)) {
10193 setverdict(fail, "RSL Channel Identification IE is absent");
10194 mtc.stop;
10195 }
Neels Hofmeyr7a6d0602021-08-07 04:23:50 +020010196
10197 /* *FIRST* expect the Immediate Assignment, before we ACK the chan act */
10198 imm_ass := f_exp_ipa_rx(0, tr_RSL_IMM_ASSIGN(0));
Neels Hofmeyr07603cf2021-09-07 19:05:52 +020010199 f_verify_imm_ass(imm_ass, ra, fn, chan_nr, chan_ident_ie.chan_ident.ch_desc.v.arfcn,
10200 chan_ident_ie.chan_ident.ch_desc.v.tsc);
Neels Hofmeyr7a6d0602021-08-07 04:23:50 +020010201
10202 /* Only now send the Chan Act ACK */
10203 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, fn+10));
10204
10205 /* Check that the lchan is working */
10206 var octetstring l3 := '00010203040506'O;
10207 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
10208
10209 var BSSAP_N_CONNECT_ind rx_c_ind;
10210 BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) -> value rx_c_ind;
10211 BSSAP.send(ts_BSSAP_CONNECT_res(rx_c_ind.connectionId));
10212
10213 f_sleep(1.0);
10214 f_shutdown_helper();
10215}
10216
Neels Hofmeyrc8b95c12021-08-07 04:24:02 +020010217testcase TC_imm_ass_pre_ts_ack_dyn_ts() runs on test_CT {
10218 /* change Timeslot 6 before f_init() starts RSL */
10219 f_init_vty();
10220 f_ts_set_chcomb(0, 0, 6, "TCH/F_TCH/H_PDCH");
10221 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
10222
10223 f_init(1, false);
10224 f_sleep(1.0);
10225
10226 var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(6));
10227 /* The BSC will activate the dynamic PDCH by default, so confirm that */
10228 f_exp_ipa_rx(0, tr_RSL_CHAN_ACT_PDCH(chan_nr, ?));
10229 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, 2323));
10230
10231 /* clean up timeslot 6 config, will only take effect when the OML drops the next time */
10232 f_ts_set_chcomb(0, 0, 6, "PDCH");
10233
10234 /* block all static timeslots so that the dyn TS will be used */
10235 f_disable_all_tch_f();
10236 f_disable_all_tch_h();
10237 f_disable_all_sdcch();
10238
10239 var RSL_Message chan_act;
10240 var RSL_Message imm_ass;
10241
10242 f_init(1, false);
10243 f_sleep(1.0);
10244
10245 f_vty_set_imm_ass(BSCVTY, 0, "pre-ts-ack");
10246
10247 /* RA containing reason=LU */
10248 var GsmFrameNumber fn := 2342;
10249 var uint8_t ra := 2;
10250 f_ipa_tx(0, ts_RSL_CHAN_RQD(int2oct(ra, 1), fn));
10251
10252 /* (set bts 0 cfg back to default) */
10253 f_vty_set_imm_ass(BSCVTY);
10254
10255 /* Expect the dyn TS to deactivate PDCH first */
10256 f_exp_ipa_rx(0, tr_RSL_RF_CHAN_REL(chan_nr));
10257
10258 /* And already the Immediate Assignment even before the PDCH Deact ACK */
10259 imm_ass := f_exp_ipa_rx(0, tr_RSL_IMM_ASSIGN(0));
10260
10261 /* continue the Osmo style PDCH Deact (usual chan rel) */
10262 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(chan_nr));
10263
10264 /* Now activation as SDCCH8 */
10265 chan_nr := valueof(t_RslChanNr_SDCCH8(tn := 6, sub_slot := 0));
10266
10267 chan_act := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
Neels Hofmeyr07603cf2021-09-07 19:05:52 +020010268 var RSL_IE_Body chan_ident_ie;
10269 if (not f_rsl_find_ie(chan_act, RSL_IE_CHAN_IDENT, chan_ident_ie)) {
10270 setverdict(fail, "RSL Channel Identification IE is absent");
10271 mtc.stop;
10272 }
Neels Hofmeyrc8b95c12021-08-07 04:24:02 +020010273 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, fn+10));
10274
Neels Hofmeyr07603cf2021-09-07 19:05:52 +020010275 f_verify_imm_ass(imm_ass, ra, fn, chan_nr, chan_ident_ie.chan_ident.ch_desc.v.arfcn,
10276 chan_ident_ie.chan_ident.ch_desc.v.tsc);
Neels Hofmeyrc8b95c12021-08-07 04:24:02 +020010277
10278 /* Check that the lchan is working */
10279 var octetstring l3 := '00010203040506'O;
10280 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
10281
10282 var BSSAP_N_CONNECT_ind rx_c_ind;
10283 BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) -> value rx_c_ind;
10284 BSSAP.send(ts_BSSAP_CONNECT_res(rx_c_ind.connectionId));
10285
10286 f_sleep(1.0);
10287 f_shutdown_helper();
10288}
10289
Neels Hofmeyr5d7d13f2021-09-07 14:44:36 +020010290/* GET and SET the bts.N.trx.M.rf_locked CTRL variable */
10291testcase TC_ctrl_trx_rf_locked() runs on test_CT {
10292 var MSC_ConnHdlr vc_conn;
10293
10294 f_init(nr_bts := 2, handler_mode := true, nr_msc := 1);
10295 f_sleep(1.0);
10296
10297 /* BTS 0, 1, 2 are OML unlocked, only BTS 0, 1 are actually connected to RSL. */
10298 f_ctrl_get_exp(IPA_CTRL, "rf_states",
10299 "0,0,operational,unlocked,on,rsl-up;" &
10300 "1,0,operational,unlocked,on,rsl-up;" &
10301 "2,0,operational,unlocked,on,rsl-down;" &
10302 "3,0,inoperational,locked,on,rsl-down;");
10303
10304 f_logp(BSCVTY, "TC_ctrl_trx_rf_locked: lock BTS 1 TRX 0");
10305 f_ctrl_set(IPA_CTRL, "bts.1.trx.0.rf_locked", "1");
10306 /* give it a moment to settle the FSM status */
10307 f_sleep(1.0);
10308
10309 /* Now BTS 1 TRX 0 should reflect "locked". Note the RF policy stays "on", because this is still handled
10310 * globally in osmo-bsc. Probably after sending "rf_locked 1" for a TRX, that TRX should reflect an RF policy
10311 * of "off"? But that's for a future patch if at all. */
10312 f_ctrl_get_exp(IPA_CTRL, "rf_states",
10313 "0,0,operational,unlocked,on,rsl-up;" &
10314 "1,0,operational,locked,on,rsl-up;" &
10315 "2,0,operational,unlocked,on,rsl-down;" &
10316 "3,0,inoperational,locked,on,rsl-down;");
10317
10318 f_logp(BSCVTY, "TC_ctrl_trx_rf_locked: lock the already locked TRX, nothing should change");
10319 f_ctrl_set(IPA_CTRL, "bts.1.trx.0.rf_locked", "1");
10320 f_sleep(1.0);
10321 f_ctrl_get_exp(IPA_CTRL, "rf_states",
10322 "0,0,operational,unlocked,on,rsl-up;" &
10323 "1,0,operational,locked,on,rsl-up;" &
10324 "2,0,operational,unlocked,on,rsl-down;" &
10325 "3,0,inoperational,locked,on,rsl-down;");
10326
10327 f_logp(BSCVTY, "TC_ctrl_trx_rf_locked: unlock BTS 1 TRX 0");
10328 f_ctrl_set(IPA_CTRL, "bts.1.trx.0.rf_locked", "0");
10329 f_sleep(1.0);
10330 f_ctrl_get_exp(IPA_CTRL, "rf_states",
10331 "0,0,operational,unlocked,on,rsl-up;" &
10332 "1,0,operational,unlocked,on,rsl-up;" &
10333 "2,0,operational,unlocked,on,rsl-down;" &
10334 "3,0,inoperational,locked,on,rsl-down;");
10335
10336 f_logp(BSCVTY, "TC_ctrl_trx_rf_locked: unlock an already unlocked TRX, nothing should change");
10337 f_ctrl_set(IPA_CTRL, "bts.0.trx.0.rf_locked", "0");
10338 f_sleep(1.0);
10339 f_ctrl_get_exp(IPA_CTRL, "rf_states",
10340 "0,0,operational,unlocked,on,rsl-up;" &
10341 "1,0,operational,unlocked,on,rsl-up;" &
10342 "2,0,operational,unlocked,on,rsl-down;" &
10343 "3,0,inoperational,locked,on,rsl-down;");
10344
10345 f_logp(BSCVTY, "TC_ctrl_trx_rf_locked: unlock an inoperational TRX");
10346 f_ctrl_set(IPA_CTRL, "bts.3.trx.0.rf_locked", "0");
10347 f_sleep(1.0);
10348 f_ctrl_get_exp(IPA_CTRL, "rf_states",
10349 "0,0,operational,unlocked,on,rsl-up;" &
10350 "1,0,operational,unlocked,on,rsl-up;" &
10351 "2,0,operational,unlocked,on,rsl-down;" &
10352 "3,0,inoperational,locked,on,rsl-down;");
10353
10354 f_shutdown_helper();
10355}
10356
Neels Hofmeyrb7581872021-11-07 14:02:49 +010010357const CounterNameVals counternames_cm_serv_rej := {
10358 { "cm_serv_rej", 0 },
10359 { "cm_serv_rej:imsi_unknown_in_hlr", 0 },
10360 { "cm_serv_rej:illegal_ms", 0 },
10361 { "cm_serv_rej:imsi_unknown_in_vlr", 0 },
10362 { "cm_serv_rej:imei_not_accepted", 0 },
10363 { "cm_serv_rej:illegal_me", 0 },
10364 { "cm_serv_rej:plmn_not_allowed", 0 },
10365 { "cm_serv_rej:loc_not_allowed", 0 },
10366 { "cm_serv_rej:roaming_not_allowed", 0 },
10367 { "cm_serv_rej:network_failure", 0 },
10368 { "cm_serv_rej:synch_failure", 0 },
10369 { "cm_serv_rej:congestion", 0 },
10370 { "cm_serv_rej:srv_opt_not_supported", 0 },
10371 { "cm_serv_rej:rqd_srv_opt_not_supported", 0 },
10372 { "cm_serv_rej:srv_opt_tmp_out_of_order", 0 },
10373 { "cm_serv_rej:call_can_not_be_identified", 0 },
10374 { "cm_serv_rej:incorrect_message", 0 },
10375 { "cm_serv_rej:invalid_mandantory_inf", 0 },
10376 { "cm_serv_rej:msg_type_not_implemented", 0 },
10377 { "cm_serv_rej:msg_type_not_compatible", 0 },
10378 { "cm_serv_rej:inf_eleme_not_implemented", 0 },
10379 { "cm_serv_rej:condtional_ie_error", 0 },
10380 { "cm_serv_rej:msg_not_compatible", 0 },
10381 { "cm_serv_rej:protocol_error", 0 },
10382 { "cm_serv_rej:retry_in_new_cell", 0 }
10383};
10384
10385private function f_TC_cm_serv_rej(charstring id) runs on MSC_ConnHdlr
10386{
10387 f_create_chan_and_exp();
10388 BSSAP.send(ts_PDU_DTAP_MT(ts_CM_SERV_REJ('02'O), '00'O));
Neels Hofmeyr87a65612021-11-16 15:56:45 +010010389 f_sleep(1.0);
Neels Hofmeyrb7581872021-11-07 14:02:49 +010010390}
10391testcase TC_cm_serv_rej() runs on test_CT {
10392 var TestHdlrParams pars := f_gen_test_hdlr_pars();
10393 var MSC_ConnHdlr vc_conn;
10394
10395 f_init(1, true);
10396 f_sleep(1.0);
10397
10398 f_ctrs_bts_init(1, counternames_cm_serv_rej);
10399
10400 vc_conn := f_start_handler(refers(f_TC_cm_serv_rej), pars);
10401 vc_conn.done;
10402
10403 f_ctrs_bts_add(0, "cm_serv_rej", 1);
10404 f_ctrs_bts_add(0, "cm_serv_rej:imsi_unknown_in_hlr", 1);
10405 f_ctrs_bts_verify();
10406
Neels Hofmeyr87a65612021-11-16 15:56:45 +010010407 f_sleep(1.0);
Neels Hofmeyrb7581872021-11-07 14:02:49 +010010408 f_shutdown_helper();
10409}
10410
Neels Hofmeyr92cfa1c2021-09-28 18:29:44 +020010411/* Reproduce a segfault happening when the SDCCH (primary) lchan is lost in-between a TCH Channel Activ and its Channel
10412 * Activ Ack (SYS#5627). */
10413private function f_TC_lost_sdcch_during_assignment(charstring id) runs on MSC_ConnHdlr {
10414 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Vadim Yanitskiyf0310e32021-10-26 00:30:59 +030010415
10416 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
10417 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
Neels Hofmeyr92cfa1c2021-09-28 18:29:44 +020010418
10419 var BSSMAP_FIELD_CodecType codecType;
10420 codecType := valueof(ass_cmd.pdu.bssmap.assignmentRequest.codecList.codecElements[0].codecType);
10421
10422 f_MscConnHdlr_init(g_pars.media_nr, host_bts, host_mgw_mgcp, codecType);
10423
10424 /* First establish a signalling lchan */
10425 f_create_chan_and_exp();
10426 f_rslem_dchan_queue_enable();
10427
10428 /* we should now have a COMPL_L3 at the MSC */
10429 var template PDU_BSSAP exp_l3_compl;
10430 exp_l3_compl := tr_BSSMAP_ComplL3()
10431 if (g_pars.aoip == false) {
10432 exp_l3_compl.pdu.bssmap.completeLayer3Information.codecList := omit;
10433 } else {
10434 exp_l3_compl.pdu.bssmap.completeLayer3Information.codecList := ?;
10435 }
10436 timer T := 10.0;
10437 T.start;
10438 alt {
10439 [] BSSAP.receive(exp_l3_compl);
10440 [] BSSAP.receive(tr_BSSMAP_ComplL3) {
10441 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Received non-matching COMPLETE LAYER 3 INFORMATION");
10442 }
10443 [] T.timeout {
10444 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for COMPLETE LAYER 3 INFORMATION");
10445 }
10446 }
10447
10448 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
10449 activate(as_Media_mgw());
10450
10451 var RslChannelNr chan_nr := { u := { ch0 := RSL_CHAN_NR_Bm_ACCH }, tn := 1 };
10452 f_rslem_register(0, chan_nr);
10453
10454 f_rslem_set_auto_chan_act_ack(RSL_PROC, false);
10455 BSSAP.send(ass_cmd);
10456
10457
10458 /* Wait for the Channel Activ for the TCH channel */
10459 var ASP_RSL_Unitdata rx_rsl_ud;
10460 RSL.receive(tr_ASP_RSL_UD(tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV), sid := ?)) -> value rx_rsl_ud;
10461
10462 /* make the original SDCCH disappear */
10463 RSL.send(ts_RSL_REL_IND(g_chan_nr, valueof(ts_RslLinkID_DCCH(0))));
10464
10465 /* and ACK the TCH channel activation. This caused a segfault up to OsmoBSC 1.7.0 (SYS#5627) */
10466 RSL.send(ts_ASP_RSL_UD(ts_RSL_CHAN_ACT_ACK(chan_nr, 23), rx_rsl_ud.streamId));
10467
10468 interleave {
10469 [] BSSAP.receive(tr_BSSMAP_AssignmentFail);
10470 [] BSSAP.receive(tr_BSSMAP_ClearRequest);
10471 }
10472
10473 BSSAP.send(ts_BSSMAP_ClearCommand(0));
10474 BSSAP.receive(tr_BSSMAP_ClearComplete);
10475 BSSAP.send(RAN_Conn_Prim:MSC_CONN_PRIM_DISC_REQ);
10476
10477 var MgcpCommand mgcp;
10478 MGCP.receive(tr_DLCX()) -> value mgcp {
10479 MGCP.send(ts_DLCX_ACK2(mgcp.line.trans_id));
10480 };
10481
10482 f_sleep(0.5);
10483}
10484testcase TC_lost_sdcch_during_assignment() runs on test_CT {
10485 var TestHdlrParams pars := f_gen_test_hdlr_pars();
10486 var MSC_ConnHdlr vc_conn;
10487
10488 f_init(1, true);
10489 f_sleep(1.0);
10490
Neels Hofmeyr92cfa1c2021-09-28 18:29:44 +020010491 vc_conn := f_start_handler(refers(f_TC_lost_sdcch_during_assignment), pars);
10492 vc_conn.done;
10493
10494 f_shutdown_helper();
10495}
10496
Neels Hofmeyrbd94fe72021-10-26 22:04:53 +020010497const CounterNameVals counternames_bsc_bts_all_available_allocated := {
10498 { "all_allocated:sdcch", 0 },
10499 { "all_allocated:static_sdcch", 0 },
10500 { "all_allocated:tch", 0 },
10501 { "all_allocated:static_tch", 0 }
10502}
10503
10504private function f_all_allocated_expect_counter_change(charstring_list expect_changed) runs on test_CT
10505{
10506 /* Make sure counters settle first */
10507 f_sleep(1.0);
10508
10509 /* Take a baseline of counters */
10510 f_ctrs_bsc_and_bts_init(1, counternames_bsc_bts_all_available_allocated);
10511
10512 /* Elapse some time so that we see changes in counters, hopefully where expected */
10513 f_sleep(2.0);
10514
10515 /* Get new counters */
10516 var charstring_list all_changed := {};
10517 all_changed := all_changed & f_counter_name_vals_get_changed_n(IPA_CTRL, "bsc", g_ctr_bsc);
10518 all_changed := all_changed & f_counter_name_vals_get_changed_n(IPA_CTRL, "bts", g_ctr_bts);
10519
10520 /* Compare with expectations */
10521 var charstring_list all_expect_changed := {};
10522 for (var integer i := 0; i < lengthof(expect_changed); i := i + 1) {
10523 all_expect_changed := all_expect_changed & { "bsc.0." & expect_changed[i], "bts.0." & expect_changed[i] };
10524 }
10525 f_counter_name_vals_expect_changed_list(all_changed, all_expect_changed);
10526}
10527
10528testcase TC_ratectr_all_available_allocated() runs on test_CT {
10529 var ASP_RSL_Unitdata rsl_ud;
10530 var integer i;
10531 var integer chreq_total, chreq_nochan;
10532
10533 f_init(1);
10534 f_sleep(1.0);
10535
10536 /* Exhaust all dedicated SDCCH lchans.
10537 /* GSM 44.018 Table 9.1.8.2:
10538 * RA = '13'O -> Establishment cause = 0001xxxx (MS dual rate capable and asks for "SDCCH").
10539 */
10540 for (i := 0; i < NUM_SDCCH_PER_BTS; i := i+1) {
10541 f_est_dchan('13'O, NUM_SDCCH_PER_BTS + i, '00010203040506'O);
10542 }
10543
10544 /* Since only bts 0 is connected, expecting all_allocated to become true for both bts 0 and the "global" bsc
10545 * level.
10546 * All SDCCH are now occupied. */
10547 f_all_allocated_expect_counter_change({"all_allocated:sdcch", "all_allocated:static_sdcch"});
10548
10549 /* Also fill up all remaining (TCH) channels */
10550 for (i := 0; i < NUM_TCHF_PER_BTS + NUM_TCHH_PER_BTS; i := i+1) {
10551 f_est_dchan('33'O, NUM_SDCCH_PER_BTS + i, '00010203040506'O);
10552 }
10553
10554 /* All TCH are now also occupied */
10555 f_all_allocated_expect_counter_change({"all_allocated:sdcch", "all_allocated:static_sdcch",
10556 "all_allocated:tch", "all_allocated:static_tch"});
10557
10558 f_shutdown_helper();
10559}
10560
10561testcase TC_ratectr_all_available_allocated_dyn() runs on test_CT {
10562 var ASP_RSL_Unitdata rsl_ud;
10563 var integer i;
10564 var integer chreq_total, chreq_nochan;
10565
10566 f_init_vty();
10567 f_ts_set_chcomb(0, 0, 2, "TCH/F_TCH/H_PDCH");
10568 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
10569 /* Now we have 3 TCH/F, 1 OSMO_DYN, 1 TCH/H */
10570
10571 f_init(1, guard_timeout := 60.0);
10572 f_sleep(1.0);
10573
10574 /* The dyn TS wants to activate PDCH mode, ACK that. */
10575 var RslChannelNr chan_nr;
10576 chan_nr := valueof(t_RslChanNr_PDCH(2));
10577 f_exp_ipa_rx(0, tr_RSL_CHAN_ACT_PDCH(chan_nr, ?));
10578 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, 2342));
10579
10580 /* Exhaust all dedicated SDCCH lchans.
10581 /* GSM 44.018 Table 9.1.8.2:
10582 * RA = '13'O -> Establishment cause = 0001xxxx (MS dual rate capable and asks for "SDCCH").
10583 */
10584 for (i := 0; i < NUM_SDCCH_PER_BTS; i := i+1) {
10585 f_est_dchan('13'O, NUM_SDCCH_PER_BTS + i, '00010203040506'O);
10586 }
10587
10588 /* The static SDCCH should now be occupied, while still 3x8 dynamic SDCCH potentially remain. So only
10589 * all_allocated:static_sdcch is counted, all_allocated:sdcch remains zero. */
10590 f_all_allocated_expect_counter_change({"all_allocated:static_sdcch"});
10591
10592 /* Request more SDCCH, hence convert the first dyn TS to SDCCH8.
10593 * Will release them later, so remember all the DchanTuples. */
10594 var DchanTuples dyn_sddch := {};
10595 dyn_sddch := dyn_sddch & { f_est_dchan_dyn('33'O, NUM_SDCCH_PER_BTS + i, '00010203040506'O) };
10596
10597 /* Also occupy the seven other SDCCH of the dyn TS */
10598 for (i := 0; i < 7; i := i+1) {
10599 dyn_sddch := dyn_sddch & { f_est_dchan('33'O, NUM_SDCCH_PER_BTS + i, '00010203040506'O) };
10600 }
10601
10602 /* Now all dynamic SDCCH are also occupied, so for the first time all_allocated:sdcch will trigger... */
10603 f_all_allocated_expect_counter_change({"all_allocated:sdcch", "all_allocated:static_sdcch"});
10604
10605 /* occupy the remaining TCH, three TCH/F and two TCH/H lchans */
10606 for (i := 0; i < 5; i := i+1) {
10607 f_est_dchan('33'O, NUM_SDCCH_PER_BTS + i, '00010203040506'O);
10608 }
10609
10610 /* All TCH lchans are now also occupied, both static and dynamic */
10611 f_all_allocated_expect_counter_change({"all_allocated:sdcch", "all_allocated:static_sdcch",
10612 "all_allocated:tch", "all_allocated:static_tch"});
10613
10614 /* Starting to release the dyn TS: as soon as the first SDCCH gets released, all_allocated:sdcch stops
10615 * incrementing. */
10616 var BssmapCause cause := 0;
10617 var DchanTuple dt := dyn_sddch[0];
10618 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
10619 f_exp_chan_rel_and_clear(dt, 0);
10620
10621 /* one dyn TS SDCCH is free again, so only the static_sdcch should increment. For tch, both static and dynamic
10622 * count as occupied, so those still both increment. */
10623 f_all_allocated_expect_counter_change({"all_allocated:static_sdcch",
10624 "all_allocated:tch", "all_allocated:static_tch"});
10625
10626 /* Release the remaining SDCCH of the dyn TS, so it becomes available as TCH again */
10627 for (i := 1; i < lengthof(dyn_sddch); i := i+1) {
10628 dt := dyn_sddch[i];
10629 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
10630 f_exp_chan_rel_and_clear(dt, 0);
10631 }
10632
10633 /* All SDCCH on the dyn TS are released, the dyn TS wants to activate PDCH again */
10634 chan_nr := valueof(t_RslChanNr_PDCH(2));
10635 f_exp_ipa_rx(0, tr_RSL_CHAN_ACT_PDCH(chan_nr, ?));
10636 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, 2342));
10637
10638 /* Now all channels are occupied except the dyn TS, so expecting only the static counters to increment */
10639 f_all_allocated_expect_counter_change({"all_allocated:static_sdcch", "all_allocated:static_tch"});
10640
10641 /* clean up config */
10642 f_ts_reset_chcomb(0);
10643
10644 f_shutdown_helper();
10645}
10646
Harald Welte28d943e2017-11-25 15:00:50 +010010647control {
Harald Welte898113b2018-01-31 18:32:21 +010010648 /* CTRL interface testing */
Harald Welte4003d112017-12-09 22:35:39 +010010649 execute( TC_ctrl_msc_connection_status() );
Stefan Sperlingb041b3d2018-01-03 17:14:55 +010010650 execute( TC_ctrl_msc0_connection_status() );
Neels Hofmeyrf65ce872021-09-23 18:40:10 +020010651 /* In SCCPlite tests, only one MSC is configured. These tests assume that three MSCs are configured, so only run
10652 * these in the AoIP test suite. */
10653 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
10654 execute( TC_stat_num_msc_connected_1() );
10655 execute( TC_stat_num_msc_connected_2() );
10656 execute( TC_stat_num_msc_connected_3() );
10657 }
Neels Hofmeyr5ce3ae42021-08-29 15:32:00 +020010658 execute( TC_stat_num_bts_connected_1() );
10659 execute( TC_stat_num_bts_connected_2() );
10660 execute( TC_stat_num_bts_connected_3() );
Harald Welte96c94412017-12-09 03:12:45 +010010661 execute( TC_ctrl() );
Neels Hofmeyrf246a922020-05-13 02:27:10 +020010662 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_SCCPlite_SERVER) {
Pau Espin Pedrol5a2d7432019-06-07 19:43:45 +020010663 execute( TC_ctrl_location() );
10664 }
Harald Welte898113b2018-01-31 18:32:21 +010010665
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +020010666 execute( TC_si_default() );
Neels Hofmeyr66aeba42020-07-06 02:21:21 +020010667 execute( TC_si2quater_2_earfcns() );
10668 execute( TC_si2quater_3_earfcns() );
10669 execute( TC_si2quater_4_earfcns() );
10670 execute( TC_si2quater_5_earfcns() );
10671 execute( TC_si2quater_6_earfcns() );
Neels Hofmeyrad132f22020-07-08 02:20:16 +020010672 execute( TC_si2quater_12_earfcns() );
10673 execute( TC_si2quater_23_earfcns() );
10674 execute( TC_si2quater_32_earfcns() );
10675 execute( TC_si2quater_33_earfcns() );
10676 execute( TC_si2quater_42_earfcns() );
10677 execute( TC_si2quater_48_earfcns() );
10678 execute( TC_si2quater_49_earfcns() );
Pau Espin Pedrol85a84432020-07-20 18:45:03 +020010679 execute( TC_si_acc_rotate() );
Alexander Couzens4ad3a352020-09-10 22:29:12 +020010680 execute( TC_si_acc_ramp_rotate() );
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +020010681
Harald Welte898113b2018-01-31 18:32:21 +010010682 /* RSL DCHAN Channel ACtivation / Deactivation */
Harald Welteae026692017-12-09 01:03:01 +010010683 execute( TC_chan_act_noreply() );
Harald Welte4003d112017-12-09 22:35:39 +010010684 execute( TC_chan_act_counter() );
Harald Welteae026692017-12-09 01:03:01 +010010685 execute( TC_chan_act_ack_noest() );
Philipp Maier9c60a622020-07-09 15:08:46 +020010686 execute( TC_chan_act_ack_noest_emerg() );
Philipp Maier606f07d2020-08-12 17:21:58 +020010687 execute( TC_chan_rqd_emerg_deny() );
Harald Welteae026692017-12-09 01:03:01 +010010688 execute( TC_chan_act_ack_est_ind_noreply() );
10689 execute( TC_chan_act_ack_est_ind_refused() );
Harald Welte618ef642017-12-14 14:58:20 +010010690 execute( TC_chan_act_nack() );
Harald Welte799c97b2017-12-14 17:50:30 +010010691 execute( TC_chan_exhaustion() );
Vadim Yanitskiy1ff1fdf2018-11-27 01:32:57 +070010692 execute( TC_chan_deact_silence() );
Harald Welte4003d112017-12-09 22:35:39 +010010693 execute( TC_chan_rel_rll_rel_ind() );
10694 execute( TC_chan_rel_conn_fail() );
10695 execute( TC_chan_rel_hard_clear() );
Pau Espin Pedrol841b90d2021-04-15 16:42:52 +020010696 execute( TC_chan_rel_last_eutran_plmn_hard_clear_no_csfb() );
10697 execute( TC_chan_rel_last_eutran_plmn_hard_clear_csfb() );
Harald Welte99787102019-02-04 10:41:36 +010010698 execute( TC_chan_rel_hard_clear_csfb() );
Harald Welted8c36cd2017-12-09 23:05:31 +010010699 execute( TC_chan_rel_hard_rlsd() );
Harald Welte550daf92018-06-11 19:22:13 +020010700 execute( TC_chan_rel_hard_rlsd_ms_dead() );
Harald Welte85804d42017-12-10 14:11:58 +010010701 execute( TC_chan_rel_a_reset() );
Pau Espin Pedrolc675b612020-01-09 19:55:40 +010010702 execute( TC_chan_rel_sccp_tiar_timeout() );
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +020010703 execute( TC_chan_rel_rr_cause() );
Harald Welte6f521d82017-12-11 19:52:02 +010010704
Harald Weltecfe2c962017-12-15 12:09:32 +010010705 execute( TC_outbound_connect() );
Harald Welte898113b2018-01-31 18:32:21 +010010706
10707 /* Assignment related */
Harald Welte16a4adf2017-12-14 18:54:01 +010010708 execute( TC_assignment_cic_only() );
Harald Welte235ebf12017-12-15 14:18:16 +010010709 execute( TC_assignment_csd() );
10710 execute( TC_assignment_ctm() );
10711 execute( TC_assignment_sign() );
Pau Espin Pedrol07866632020-09-03 19:10:55 +020010712 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
10713 execute( TC_assignment_aoip_tla_v6() );
10714 }
Harald Welte235ebf12017-12-15 14:18:16 +010010715 execute( TC_assignment_fr_a5_0() );
10716 execute( TC_assignment_fr_a5_1() );
Neels Hofmeyrf246a922020-05-13 02:27:10 +020010717 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
Harald Welte8f67d1d2018-05-25 20:38:42 +020010718 execute( TC_assignment_fr_a5_1_codec_missing() );
10719 }
Harald Welte235ebf12017-12-15 14:18:16 +010010720 execute( TC_assignment_fr_a5_3() );
Neels Hofmeyr0d8ec532021-06-11 00:09:48 +020010721 execute( TC_assignment_fr_a5_4() );
Neels Hofmeyr0faeb7a2021-06-10 23:59:35 +020010722 execute( TC_assignment_fr_a5_4_fail() );
Neels Hofmeyr04d6e6a2021-06-11 00:10:02 +020010723 execute( TC_assignment_fr_a5_not_sup() );
Harald Welte3c86ea02018-05-10 22:28:05 +020010724 execute( TC_ciph_mode_a5_0() );
10725 execute( TC_ciph_mode_a5_1() );
Oliver Smith50b98122021-07-09 15:00:28 +020010726 execute( TC_ciph_mode_a5_2_0() );
Oliver Smith1dff88d2021-07-09 08:45:51 +020010727 execute( TC_ciph_mode_a5_2_1() );
Harald Welte3c86ea02018-05-10 22:28:05 +020010728 execute( TC_ciph_mode_a5_3() );
Neels Hofmeyr81ad27f2021-06-11 00:09:40 +020010729 execute( TC_ciph_mode_a5_4() );
Harald Welte16a4adf2017-12-14 18:54:01 +010010730
Harald Welte60aa5762018-03-21 19:33:13 +010010731 execute( TC_assignment_codec_fr() );
Neels Hofmeyr559d5d02021-04-16 16:50:49 +020010732 execute( TC_assignment_codec_fr_by_mode_modify() );
Harald Welte60aa5762018-03-21 19:33:13 +010010733 execute( TC_assignment_codec_hr() );
10734 execute( TC_assignment_codec_efr() );
10735 execute( TC_assignment_codec_amr_f() );
10736 execute( TC_assignment_codec_amr_h() );
Philipp Maier8a581d22019-03-26 18:32:48 +010010737
Neels Hofmeyrf246a922020-05-13 02:27:10 +020010738 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
Philipp Maier8a581d22019-03-26 18:32:48 +010010739 execute( TC_assignment_codec_amr_f_S1() );
10740 execute( TC_assignment_codec_amr_h_S1() );
10741 execute( TC_assignment_codec_amr_f_S124() );
10742 execute( TC_assignment_codec_amr_h_S124() );
10743 execute( TC_assignment_codec_amr_f_S0() );
10744 execute( TC_assignment_codec_amr_f_S02() );
10745 execute( TC_assignment_codec_amr_f_S024() );
10746 execute( TC_assignment_codec_amr_f_S0247() );
10747 execute( TC_assignment_codec_amr_h_S0() );
10748 execute( TC_assignment_codec_amr_h_S02() );
10749 execute( TC_assignment_codec_amr_h_S024() );
10750 execute( TC_assignment_codec_amr_h_S0247() );
10751 execute( TC_assignment_codec_amr_f_S01234567() );
10752 execute( TC_assignment_codec_amr_f_S0234567() );
10753 execute( TC_assignment_codec_amr_f_zero() );
10754 execute( TC_assignment_codec_amr_f_unsupp() );
10755 execute( TC_assignment_codec_amr_h_S7() );
Neels Hofmeyr21863562020-11-26 00:34:33 +000010756 execute( TC_assignment_codec_amr_f_start_mode_auto() );
10757 execute( TC_assignment_codec_amr_h_start_mode_auto() );
Neels Hofmeyr3eb94562020-11-26 02:40:26 +000010758 execute( TC_assignment_codec_amr_f_start_mode_4() );
10759 execute( TC_assignment_codec_amr_h_start_mode_4() );
Neels Hofmeyr454d7922020-11-26 02:24:57 +000010760 execute( TC_assignment_codec_amr_startmode_cruft() );
Philipp Maier8a581d22019-03-26 18:32:48 +010010761 }
Harald Welte60aa5762018-03-21 19:33:13 +010010762
Philipp Maierac09bfc2019-01-08 13:41:39 +010010763 execute( TC_assignment_codec_fr_exhausted_req_hr() );
10764 execute( TC_assignment_codec_fr_exhausted_req_fr() );
10765 execute( TC_assignment_codec_fr_exhausted_req_fr_hr() );
10766 execute( TC_assignment_codec_fr_exhausted_req_hr_fr() );
10767 execute( TC_assignment_codec_hr_exhausted_req_fr() );
10768 execute( TC_assignment_codec_hr_exhausted_req_hr() );
10769 execute( TC_assignment_codec_hr_exhausted_req_hr_fr() );
10770 execute( TC_assignment_codec_hr_exhausted_req_fr_hr() );
10771 execute( TC_assignment_codec_req_hr_fr() );
10772 execute( TC_assignment_codec_req_fr_hr() );
Pau Espin Pedrol14475352021-07-22 15:48:16 +020010773 execute( TC_assignment_sdcch_exhausted_req_signalling() );
10774 execute( TC_assignment_sdcch_exhausted_req_signalling_tch_forbidden() );
10775 execute( TC_assignment_sdcch_exhausted_req_voice_tch_forbidden() );
Philipp Maierac09bfc2019-01-08 13:41:39 +010010776
Pau Espin Pedrol23510fb2021-07-20 17:00:38 +020010777 execute( TC_assignment_osmux() );
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +020010778
Harald Welte898113b2018-01-31 18:32:21 +010010779 /* RLL Establish Indication on inactive DCHAN / SAPI */
Harald Welte5cd20ed2017-12-13 21:03:20 +010010780 execute( TC_rll_est_ind_inact_lchan() );
10781 execute( TC_rll_est_ind_inval_sapi1() );
10782 execute( TC_rll_est_ind_inval_sapi3() );
10783 execute( TC_rll_est_ind_inval_sacch() );
10784
Vadim Yanitskiy61f784a2020-10-01 21:12:19 +070010785 /* DLCI / RSL Link ID conversion for MO/MT messages on SAPI0/SAPI3 */
10786 execute( TC_tch_dlci_link_id_sapi() );
10787
Vadim Yanitskiy6ef5dfa2020-08-28 18:04:41 +070010788 /* SAPI N Reject triggered by RLL establishment failures */
10789 execute( TC_rll_rel_ind_sapi_n_reject() );
10790 execute( TC_rll_err_ind_sapi_n_reject() );
10791 execute( TC_rll_timeout_sapi_n_reject() );
10792
Harald Welte898113b2018-01-31 18:32:21 +010010793 /* Paging related tests */
Harald Welte6f521d82017-12-11 19:52:02 +010010794 execute( TC_paging_imsi_nochan() );
10795 execute( TC_paging_tmsi_nochan() );
10796 execute( TC_paging_tmsi_any() );
10797 execute( TC_paging_tmsi_sdcch() );
10798 execute( TC_paging_tmsi_tch_f() );
10799 execute( TC_paging_tmsi_tch_hf() );
10800 execute( TC_paging_imsi_nochan_cgi() );
10801 execute( TC_paging_imsi_nochan_lac_ci() );
10802 execute( TC_paging_imsi_nochan_ci() );
10803 execute( TC_paging_imsi_nochan_lai() );
10804 execute( TC_paging_imsi_nochan_lac() );
10805 execute( TC_paging_imsi_nochan_all() );
Harald Welte751d3eb2018-01-31 15:51:06 +010010806 execute( TC_paging_imsi_nochan_plmn_lac_rnc() );
10807 execute( TC_paging_imsi_nochan_rnc() );
10808 execute( TC_paging_imsi_nochan_lac_rnc() );
10809 execute( TC_paging_imsi_nochan_lacs() );
10810 execute( TC_paging_imsi_nochan_lacs_empty() );
Stefan Sperling049a86e2018-03-20 15:51:00 +010010811 execute( TC_paging_imsi_nochan_cgi_unknown_cid() );
Harald Welte10985002017-12-12 09:29:15 +010010812 execute( TC_paging_imsi_a_reset() );
Harald Weltee65d40e2017-12-13 00:09:06 +010010813 execute( TC_paging_imsi_load() );
Philipp Maier779a7922018-02-16 11:00:37 +010010814 execute( TC_paging_counter() );
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +010010815 execute( TC_paging_resp_unsol() );
Harald Welte4e9b9cc2017-12-14 18:31:02 +010010816
10817 execute( TC_rsl_drop_counter() );
Stefan Sperling830dc9d2018-02-12 21:08:28 +010010818 execute( TC_rsl_unknown_unit_id() );
10819
10820 execute( TC_oml_unknown_unit_id() );
Harald Welte898113b2018-01-31 18:32:21 +010010821
10822 execute( TC_classmark() );
Harald Welteeddf0e92020-06-21 19:42:15 +020010823 execute( TC_common_id() );
Harald Welte898113b2018-01-31 18:32:21 +010010824 execute( TC_unsol_ass_fail() );
Harald Welteea99a002018-01-31 20:46:43 +010010825 execute( TC_unsol_ass_compl() );
Harald Weltefbf9b5e2018-01-31 20:41:23 +010010826 execute( TC_unsol_ho_fail() );
Harald Weltee3bd6582018-01-31 22:51:25 +010010827 execute( TC_err_82_short_msg() );
Harald Weltee9e02e42018-01-31 23:36:25 +010010828 execute( TC_err_84_unknown_msg() );
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +010010829
Harald Welte261af4b2018-02-12 21:20:39 +010010830 execute( TC_ho_int() );
Neels Hofmeyraf88d9d2021-06-21 02:14:27 +020010831 execute( TC_ho_int_a5_0() );
10832 execute( TC_ho_int_a5_1() );
10833 execute( TC_ho_int_a5_3() );
10834 execute( TC_ho_int_a5_4() );
Neels Hofmeyr5f144212020-11-03 15:41:58 +000010835 execute( TC_ho_int_radio_link_failure() );
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +010010836
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +010010837 execute( TC_ho_out_of_this_bsc() );
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +020010838 execute( TC_ho_out_fail_no_msc_response() );
10839 execute( TC_ho_out_fail_rr_ho_failure() );
Neels Hofmeyrd8a602c2019-07-09 19:46:01 +020010840 execute( TC_ho_out_fail_no_result_after_ho_cmd() );
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +010010841
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +010010842 execute( TC_ho_into_this_bsc() );
Neels Hofmeyr8ebf19c2021-06-21 05:24:01 +020010843 execute( TC_ho_into_this_bsc_a5_0() );
10844 execute( TC_ho_into_this_bsc_a5_1() );
10845 execute( TC_ho_into_this_bsc_a5_3() );
10846 execute( TC_ho_into_this_bsc_a5_4() );
Pau Espin Pedrol07866632020-09-03 19:10:55 +020010847 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
10848 execute( TC_ho_into_this_bsc_tla_v6() );
10849 }
Pau Espin Pedrolc08d5522021-04-16 15:40:38 +020010850 execute( TC_srvcc_eutran_to_geran() );
Pau Espin Pedrol35801c32021-04-19 13:03:20 +020010851 execute( TC_srvcc_eutran_to_geran_ho_out() );
Pau Espin Pedrol9ae36d52021-06-15 17:29:43 +020010852 execute( TC_srvcc_eutran_to_geran_forbid_fast_return() );
10853 execute( TC_srvcc_eutran_to_geran_ho_out_forbid_fast_return() );
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +010010854 execute( TC_ho_in_fail_msc_clears() );
10855 execute( TC_ho_in_fail_msc_clears_after_ho_detect() );
10856 execute( TC_ho_in_fail_no_detect() );
10857 execute( TC_ho_in_fail_no_detect2() );
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +010010858
Neels Hofmeyr91401012019-07-11 00:42:35 +020010859 execute( TC_ho_neighbor_config_1() );
10860 execute( TC_ho_neighbor_config_2() );
10861 execute( TC_ho_neighbor_config_3() );
10862 execute( TC_ho_neighbor_config_4() );
10863 execute( TC_ho_neighbor_config_5() );
10864 execute( TC_ho_neighbor_config_6() );
10865 execute( TC_ho_neighbor_config_7() );
10866
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +010010867 execute( TC_bssap_rlsd_does_not_cause_bssmap_reset() );
Neels Hofmeyr4ff93282018-03-12 04:25:35 +010010868 execute( TC_bssmap_clear_does_not_cause_bssmap_reset() );
Neels Hofmeyrfd445c32018-03-09 15:39:31 +010010869 execute( TC_ms_rel_ind_does_not_cause_bssmap_reset() );
Harald Welte94e0c342018-04-07 11:33:23 +020010870
10871 execute( TC_dyn_pdch_ipa_act_deact() );
10872 execute( TC_dyn_pdch_ipa_act_nack() );
10873 execute( TC_dyn_pdch_osmo_act_deact() );
10874 execute( TC_dyn_pdch_osmo_act_nack() );
Pau Espin Pedrole076b3f2021-07-20 16:45:57 +020010875 if (mp_enable_dyn_sdcch8_test) {
10876 execute( TC_dyn_ts_sdcch8_act_deact() );
Neels Hofmeyre1a7c4d2021-10-23 23:13:01 +020010877 execute( TC_dyn_ts_sdcch8_all_subslots_used() );
Vadim Yanitskiy07e4b632021-10-12 14:04:45 +030010878 execute( TC_dyn_ts_sdcch8_tch_call_act_deact() );
Pau Espin Pedrole076b3f2021-07-20 16:45:57 +020010879 execute( TC_dyn_ts_sdcch8_act_nack() );
10880 }
Harald Welte99f3ca02018-06-14 13:40:29 +020010881
Stefan Sperling0796a822018-10-05 13:01:39 +020010882 execute( TC_chopped_ipa_ping() );
Stefan Sperlingaa1e60f2018-10-15 16:34:07 +020010883 execute( TC_chopped_ipa_payload() );
Stefan Sperling0796a822018-10-05 13:01:39 +020010884
Pau Espin Pedrol8f773632019-11-05 11:46:53 +010010885 /* Power control related */
10886 execute( TC_assignment_verify_ms_power_params_ie() );
Vadim Yanitskiy4b233042021-06-30 00:58:43 +020010887 execute( TC_c0_power_red_mode() );
Neels Hofmeyr4f118412020-06-04 15:25:10 +020010888
10889 /* MSC pooling */
10890 /* FIXME: in SCCPlite, indicating how many MSCs should be connected does currently not work. Since
10891 * RESET->RESET-ACK is unconditionally negotiated for all configured MSCs, they always all appear as connected
10892 * to osmo-bsc. The MSC pooling tests however require disconnecting selected MSCs, and hence don't work out as
10893 * intended on SCCPlite. So for now, run these only for SCCP/M3UA. */
10894 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
10895 execute( TC_mscpool_L3Compl_on_1_msc() );
10896 execute( TC_mscpool_L3Complete_by_imsi_round_robin() );
10897 execute( TC_mscpool_LU_by_tmsi_null_nri_0_round_robin() );
10898 execute( TC_mscpool_LU_by_tmsi_null_nri_1_round_robin() );
10899 execute( TC_mscpool_L3Complete_by_tmsi_unassigned_nri_round_robin() );
10900 execute( TC_mscpool_L3Complete_by_tmsi_valid_nri_msc_not_connected_round_robin() );
10901 execute( TC_mscpool_L3Complete_by_tmsi_valid_nri_1() );
10902 execute( TC_mscpool_L3Complete_by_tmsi_valid_nri_2() );
10903 execute( TC_mscpool_LU_by_tmsi_from_other_PLMN() );
10904 execute( TC_mscpool_paging_and_response_imsi() );
10905 execute( TC_mscpool_paging_and_response_tmsi() );
10906 execute( TC_mscpool_no_allow_attach_round_robin() );
10907 execute( TC_mscpool_no_allow_attach_valid_nri() );
10908 }
10909
Harald Welte99f3ca02018-06-14 13:40:29 +020010910 execute( TC_early_conn_fail() );
10911 execute( TC_late_conn_fail() );
Oliver Smithaf03bef2021-08-24 15:34:51 +020010912 execute( TC_stats_conn_fail() );
Harald Welte99f3ca02018-06-14 13:40:29 +020010913
Philipp Maier783681c2020-07-16 16:47:06 +020010914 /* Emergency call handling (deny / allow) */
10915 execute( TC_assignment_emerg_setup_allow() );
10916 execute( TC_assignment_emerg_setup_deny_msc() );
10917 execute( TC_assignment_emerg_setup_deny_bts() );
Philipp Maier82812002020-08-13 18:48:27 +020010918 execute( TC_emerg_premption() );
10919
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +070010920 /* Frequency hopping parameters handling */
10921 execute( TC_fh_params_chan_activ() );
10922 execute( TC_fh_params_imm_ass() );
Vadim Yanitskiyaeb54a22020-09-01 06:25:25 +070010923 execute( TC_fh_params_assignment_cmd() );
Vadim Yanitskiy8f5430d2020-09-02 18:51:38 +070010924 execute( TC_fh_params_handover_cmd() );
Vadim Yanitskiyca974032020-09-01 07:20:39 +070010925 execute( TC_fh_params_si4_cbch() );
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +020010926
10927 if (mp_enable_lcs_tests) {
10928 execute( TC_lcs_loc_req_for_active_ms() );
10929 execute( TC_lcs_loc_req_for_active_ms_ta_req() );
10930 execute( TC_lcs_loc_req_for_idle_ms() );
10931 execute( TC_lcs_loc_req_no_subscriber() );
10932 execute( TC_lcs_loc_req_for_active_ms_le_timeout() );
10933 execute( TC_lcs_loc_req_for_active_ms_le_timeout2() );
10934 execute( TC_lcs_loc_req_for_idle_ms_no_pag_resp() );
10935 execute( TC_cm_service_during_lcs_loc_req() );
10936 execute( TC_ho_during_lcs_loc_req() );
10937 }
Neels Hofmeyrbf037052020-10-28 22:52:02 +000010938
10939 execute( TC_no_msc() );
Neels Hofmeyr87857ec2021-04-25 16:17:47 +000010940
10941 execute( TC_refuse_chan_act_to_vamos() );
10942 execute( TC_refuse_mode_modif_to_vamos() );
Neels Hofmeyrd2d9f332021-04-28 22:23:36 +000010943
10944 execute( TC_reassignment_fr() );
Neels Hofmeyrfeda88e2021-07-19 13:51:29 +020010945
10946 execute( TC_cm_reestablishment() );
Neels Hofmeyrb07b2952021-08-07 04:23:14 +020010947
10948 execute( TC_imm_ass_post_chan_ack() );
10949 execute( TC_imm_ass_pre_chan_ack() );
Neels Hofmeyr23158742021-09-07 19:08:07 +020010950 execute( TC_imm_ass_pre_ts_ack() );
Neels Hofmeyr7a6d0602021-08-07 04:23:50 +020010951 execute( TC_imm_ass_pre_chan_ack_dyn_ts() );
Neels Hofmeyrc8b95c12021-08-07 04:24:02 +020010952 execute( TC_imm_ass_pre_ts_ack_dyn_ts() );
Neels Hofmeyr5d7d13f2021-09-07 14:44:36 +020010953
10954 execute( TC_ctrl_trx_rf_locked() );
Neels Hofmeyr92cfa1c2021-09-28 18:29:44 +020010955
Neels Hofmeyrbd94fe72021-10-26 22:04:53 +020010956 execute( TC_ratectr_all_available_allocated() );
10957 execute( TC_ratectr_all_available_allocated_dyn() );
10958
Neels Hofmeyrb7581872021-11-07 14:02:49 +010010959 execute( TC_cm_serv_rej() );
10960
Neels Hofmeyr92cfa1c2021-09-28 18:29:44 +020010961 execute( TC_lost_sdcch_during_assignment() );
Harald Welte28d943e2017-11-25 15:00:50 +010010962}
10963
10964}