blob: 077daba3c1c59a64b7eca90d4379b08342c8e299 [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
Harald Welte5d1a2202017-12-13 19:51:29 +010078const integer NUM_BTS := 3;
Neels Hofmeyrf246a922020-05-13 02:27:10 +020079const integer NUM_MSC := 3;
Harald Welteae026692017-12-09 01:03:01 +010080const float T3101_MAX := 12.0;
Harald Welte28d943e2017-11-25 15:00:50 +010081
Harald Welte799c97b2017-12-14 17:50:30 +010082/* make sure to sync this with the osmo-bts.cfg you're using */
Philipp Maiercb6cc482018-03-26 13:08:00 +020083const integer NUM_TCHH_PER_BTS := 2;
84const integer NUM_TCHF_PER_BTS := 4;
Neels Hofmeyr74083c22020-07-29 00:43:01 +020085const integer NUM_SDCCH_PER_BTS := 3;
Harald Welte799c97b2017-12-14 17:50:30 +010086
Harald Welte4003d112017-12-09 22:35:39 +010087
Harald Welte21b46bd2017-12-17 19:46:32 +010088/* per-BTS state which we keep */
Harald Welte96c94412017-12-09 03:12:45 +010089type record BTS_State {
Harald Welte21b46bd2017-12-17 19:46:32 +010090 /* component reference to the IPA_Client component used for RSL */
Harald Weltea5d2ab22017-12-09 14:21:42 +010091 IPA_Client rsl
Harald Welte96c94412017-12-09 03:12:45 +010092}
93
Neels Hofmeyr22c3f792020-06-17 02:49:28 +020094/* Default list of counters for an 'msc' entity. */
95const CounterNameVals counternames_msc_mscpool := {
96 { "mscpool:subscr:new", 0 },
97 { "mscpool:subscr:known", 0 },
98 { "mscpool:subscr:reattach", 0 },
99 { "mscpool:subscr:attach_lost", 0 },
100 { "mscpool:subscr:paged", 0 }
101};
102
Neels Hofmeyrbf037052020-10-28 22:52:02 +0000103/* List of global mscpool counters, not related to a specific 'msc' entity. */
104const CounterNameVals counternames_bsc_mscpool := {
105 { "mscpool:subscr:no_msc", 0 }
106};
107
Neels Hofmeyr12941bd2020-08-29 03:21:26 +0000108/* Default list of counters for 'bsc' and 'bts' entities. */
109const CounterNameVals counternames_bsc_bts_handover := {
110 { "assignment:attempted", 0 },
111 { "assignment:completed", 0 },
112 { "assignment:stopped", 0 },
113 { "assignment:no_channel", 0 },
114 { "assignment:timeout", 0 },
115 { "assignment:failed", 0 },
116 { "assignment:error", 0 },
117
118 { "handover:attempted", 0 },
119 { "handover:completed", 0 },
120 { "handover:stopped", 0 },
121 { "handover:no_channel", 0 },
122 { "handover:timeout", 0 },
123 { "handover:failed", 0 },
124 { "handover:error", 0 },
125
126 { "intra_cell_ho:attempted", 0 },
127 { "intra_cell_ho:completed", 0 },
128 { "intra_cell_ho:stopped", 0 },
129 { "intra_cell_ho:no_channel", 0 },
130 { "intra_cell_ho:timeout", 0 },
131 { "intra_cell_ho:failed", 0 },
132 { "intra_cell_ho:error", 0 },
133
134 { "intra_bsc_ho:attempted", 0 },
135 { "intra_bsc_ho:completed", 0 },
136 { "intra_bsc_ho:stopped", 0 },
137 { "intra_bsc_ho:no_channel", 0 },
138 { "intra_bsc_ho:timeout", 0 },
139 { "intra_bsc_ho:failed", 0 },
140 { "intra_bsc_ho:error", 0 },
141
142 { "interbsc_ho_out:attempted", 0 },
143 { "interbsc_ho_out:completed", 0 },
144 { "interbsc_ho_out:stopped", 0 },
145 { "interbsc_ho_out:timeout", 0 },
146 { "interbsc_ho_out:failed", 0 },
147 { "interbsc_ho_out:error", 0 },
148
149 { "interbsc_ho_in:attempted", 0 },
150 { "interbsc_ho_in:completed", 0 },
151 { "interbsc_ho_in:stopped", 0 },
152 { "interbsc_ho_in:no_channel", 0 },
153 { "interbsc_ho_in:timeout", 0 },
154 { "interbsc_ho_in:failed", 0 },
155 { "interbsc_ho_in:error", 0 }
156};
157
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +0200158/* Set of all System Information received during one RSL port's startup.
159 * Note that some System Information may be sent on RSL, but lacking actual SI data, to indicate that the BTS should not
160 * broadcast that SI type. That will be reflected as 'omit' here.
161 */
162type record SystemInformationConfig {
163 SystemInformationType1 si1 optional,
164 SystemInformationType2 si2 optional,
165 SystemInformationType2bis si2bis optional,
166 SystemInformationType2ter si2ter optional,
Neels Hofmeyrad132f22020-07-08 02:20:16 +0200167 SI2quaterRestOctetsList si2quater optional,
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +0200168 SystemInformationType3 si3 optional,
169 SystemInformationType4 si4 optional,
Pau Espin Pedrol28652d82021-02-09 20:20:17 +0100170 SystemInformationType13 si13 optional,
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +0200171 SystemInformationType5 si5 optional,
172 SystemInformationType5bis si5bis optional,
173 SystemInformationType5ter si5ter optional,
174 SystemInformationType6 si6 optional
175};
176
177const SystemInformationConfig SystemInformationConfig_omit := {
178 si1 := omit,
179 si2 := omit,
180 si2bis := omit,
181 si2ter := omit,
182 si2quater := omit,
183 si3 := omit,
184 si4 := omit,
185 si13 := omit,
186 si5 := omit,
187 si5bis := omit,
188 si5ter := omit,
189 si6 := omit
190};
191
192/* tr_EUTRAN_CellDesc with defaults used in BSC_Tests.ttcn */
193template EUTRAN_CellDesc tr_EUTRAN_CellDesc_default(template (present) uint16_t e_arfcn := ?,
194 template uint3_t meas_bw := 3)
195:= tr_EUTRAN_CellDesc(e_arfcn := e_arfcn,
196 meas_bw_presence := '1'B,
197 meas_bw := meas_bw);
198
199/* tr_EUTRAN_NeighbourCells with defaults used in BSC_Tests.ttcn */
Harald Welte65e419a2020-08-21 12:38:33 +0200200template EUTRAN_NeighbourCells tr_EUTRAN_NeighbourCells_default(template (present) EUTRAN_CellDescs cell_desc_list := { tr_EUTRAN_CellDesc_default },
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +0200201 template uint3_t prio := 3,
202 template (present) uint5_t thresh_high := 20,
203 template uint5_t thresh_low := 10,
204 template uint5_t qrxlevmin := 22)
205:= tr_EUTRAN_NeighbourCells(
206 cell_desc_list := cell_desc_list,
207 prio_presence := '1'B,
208 prio := prio,
209 thresh_high := thresh_high,
210 thresh_low_presence := '1'B,
211 thresh_low := thresh_low,
212 qrxlevmin_presence := '1'B,
213 qrxlevmin := qrxlevmin);
214
215template SystemInformationConfig SystemInformationConfig_default := {
216 si1 := {
217 cell_chan_desc := '8FB38000000000000000000000000000'O,
218 rach_control := {
219 max_retrans := RACH_MAX_RETRANS_7,
220 tx_integer := '1001'B,
221 cell_barr_access := false,
222 re_not_allowed := true,
223 acc := '0000010000000000'B
224 },
225 rest_octets := ?
226 },
227 si2 := {
228 bcch_freq_list := '00000000000000000000000000000000'O,
229 ncc_permitted := '11111111'B,
230 rach_control := {
231 max_retrans := RACH_MAX_RETRANS_7,
232 tx_integer := '1001'B,
233 cell_barr_access := false,
234 re_not_allowed := true,
235 acc := '0000010000000000'B
236 }
237 },
238 si2bis := omit,
239 si2ter := {
240 extd_bcch_freq_list := '8E320000000000000000000000000800'O,
241 rest_octets := ?
242 },
243 si2quater := {
244 tr_SI2quaterRestOctets_EUTRAN( repeated_neigh_cells := { tr_EUTRAN_NeighbourCells_default } )
245 },
246 si3 := {
247 cell_id := 0,
248 lai := {
249 mcc_mnc := '001F01'H,
250 lac := 1
251 },
252 ctrl_chan_desc := {
253 msc_r99 := true,
254 att := true,
255 bs_ag_blks_res := 1,
256 ccch_conf := CCHAN_DESC_1CCCH_COMBINED,
257 si22ind := false,
258 cbq3 := CBQ3_IU_MODE_NOT_SUPPORTED,
259 spare := '00'B,
260 bs_pa_mfrms := 3,
261 t3212 := 30
262 },
263 cell_options := {
264 dn_ind := false,
265 pwrc := false,
266 dtx := MS_SHALL_USE_UL_DTX,
267 radio_link_tout_div4 := 7
268 },
269 cell_sel_par := {
270 cell_resel_hyst_2dB := 2,
271 ms_txpwr_max_cch := 7,
272 acs := '0'B,
273 neci := true,
274 rxlev_access_min := 0
275 },
276 rach_control := {
277 max_retrans := RACH_MAX_RETRANS_7,
278 tx_integer := '1001'B,
279 cell_barr_access := false,
280 re_not_allowed := true,
281 acc := '0000010000000000'B
282 },
283 rest_octets := {
284 sel_params := {
285 presence := '0'B,
286 params := omit
287 },
288 pwr_offset := {
289 presence := '0'B,
290 offset := omit
291 },
292 si_2ter_ind := '1'B,
293 early_cm_ind := '0'B,
294 sched_where := {
295 presence := '0'B,
296 where := omit
297 },
298 gprs_ind := {
299 presence := '1'B,
300 ind := {
301 ra_colour := 0,
302 si13_pos := '0'B
303 }
304 },
305 umts_early_cm_ind := '1'B,
306 si2_quater_ind := {
307 presence := '1'B,
308 ind := '0'B
309 },
310 iu_mode_ind := omit,
311 si21_ind := {
312 presence := '0'B,
313 pos := omit
314 }
315 }
316 },
317 si4 := {
318 lai := {
319 mcc_mnc := '001F01'H,
320 lac := 1
321 },
322 cell_sel_par := {
323 cell_resel_hyst_2dB := 2,
324 ms_txpwr_max_cch := 7,
325 acs := '0'B,
326 neci := true,
327 rxlev_access_min := 0
328 },
329 rach_control := {
330 max_retrans := RACH_MAX_RETRANS_7,
331 tx_integer := '1001'B,
332 cell_barr_access := false,
333 re_not_allowed := true,
334 acc := '0000010000000000'B
335 },
Neels Hofmeyr74083c22020-07-29 00:43:01 +0200336 cbch_chan_desc := {
337 iei := '64'O,
338 v := {
339 chan_nr := {
340 u := {
341 sdcch4 := {
342 tag := '001'B,
343 sub_chan := 2
344 }
345 },
346 tn := 0
347 },
348 tsc := 2,
349 h := false,
350 arfcn := 871,
351 maio_hsn := omit
352 }
353 },
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +0200354 cbch_mobile_alloc := omit,
355 rest_octets := {
356 sel_params := {
357 presence := '0'B,
358 params := omit
359 },
360 pwr_offset := {
361 presence := '0'B,
362 offset := omit
363 },
364 gprs_ind := {
365 presence := '1'B,
366 ind := {
367 ra_colour := 0,
368 si13_pos := '0'B
369 }
370 },
371 s_presence := '0'B,
372 s := omit
373 }
374 },
Pau Espin Pedrol28652d82021-02-09 20:20:17 +0100375 si13 := {
376 rest_octets := {
377 presence := '1'B,
378 bcch_change_mark := ?,
379 si_change_field := '0000'B,
380 presence2 := '0'B,
381 si13_change_mark := omit,
382 gprs_ma := omit,
383 zero := '0'B, /* PBCCH not present in cell */
384 rac := 0,
385 spgc_ccch_sup := '0'B,
386 priority_access_thr := '110'B,
387 network_control_order := '00'B,
388 gprs_cell_opts := {
389 nmo := '01'B,
390 t3168 := '011'B,
391 t3192 := '010'B,
392 drx_timer_max := '011'B,
393 access_burst_type := '0'B,
394 control_ack_type := '1'B,
395 bs_cv_max := 15,
396 pan_presence := '1'B,
397 pan_dec := 1,
398 pan_inc := 1,
399 pan_max := '111'B,
400 ext_info_presence := ?,
401 ext_info_length := *,
402 ext_info := *
403 },
404 gprs_pwr_ctrl_params := {
405 alpha := 0,
406 t_avg_w := '10000'B,
407 t_avg_t := '10000'B,
408 pc_meas_chan := '0'B,
409 n_avg_i := '1000'B
410 }
411 }
412 },
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +0200413 si5 := {
414 bcch_freq_list := '10000000000000000000000000000000'O
415 },
416 si5bis := omit,
417 si5ter := {
418 extd_bcch_freq_list := '9E050020000000000000000000000000'O
419 },
420 si6 := {
421 cell_id := 0,
422 lai := {
423 mcc_mnc := '001F01'H,
424 lac := 1
425 },
426 cell_options := {
427 dtx_ext := '1'B,
428 pwrc := false,
429 dtx := '01'B,
430 radio_link_timeout := '0111'B
431 },
432 ncc_permitted := '11111111'B,
433 rest_octets := ?
434 }
435 };
436
437
438/* List of all the System Information received on all RSL ports */
439type record of SystemInformationConfig SystemInformationConfig_list;
440
441function f_sysinfo_dec_raw(inout SystemInformationConfig si, RSL_Message rsl)
442{
443 var RSL_IE_Body sysinfo_type_ie;
444 var RSL_IE_SysinfoType si_type;
445 var octetstring data;
446
447 if (f_rsl_find_ie(rsl, RSL_IE_SYSINFO_TYPE, sysinfo_type_ie) == false) {
448 setverdict(fail, "Cannot find RSL_IE_SYSINFO_TYPE");
449 mtc.stop;
450 }
451 si_type := sysinfo_type_ie.sysinfo_type;
452
453 if (rsl.msg_type == RSL_MT_BCCH_INFO) {
454 var RSL_IE_Body bcch_ie;
455 if (f_rsl_find_ie(rsl, RSL_IE_FULL_BCCH_INFO, bcch_ie)) {
456 data := bcch_ie.other.payload;
457 }
458 } else if (rsl.msg_type == RSL_MT_SACCH_FILL) {
459 var RSL_IE_Body l3_ie;
460 if (f_rsl_find_ie(rsl, RSL_IE_L3_INFO, l3_ie)) {
461 data := l3_ie.l3_info.payload;
462 }
463 } else {
464 setverdict(fail, "Don't understand this System Information message");
465 mtc.stop;
466 }
467
468 var boolean handled := false;
469
470 if (rsl.msg_type == RSL_MT_BCCH_INFO) {
471 handled := true;
472
473 if (si_type == RSL_SYSTEM_INFO_1) {
474 if (not isbound(data)) {
475 si.si1 := omit;
476 } else {
477 si.si1 := dec_SystemInformation(data).payload.si1;
478 }
479 } else if (si_type == RSL_SYSTEM_INFO_2) {
480 if (not isbound(data)) {
481 si.si2 := omit;
482 } else {
483 si.si2 := dec_SystemInformation(data).payload.si2;
484 }
485 } else if (si_type == RSL_SYSTEM_INFO_2bis) {
486 if (not isbound(data)) {
487 si.si2bis := omit;
488 } else {
489 si.si2bis := dec_SystemInformation(data).payload.si2bis;
490 }
491 } else if (si_type == RSL_SYSTEM_INFO_2ter) {
492 if (not isbound(data)) {
493 si.si2ter := omit;
494 } else {
495 si.si2ter := dec_SystemInformation(data).payload.si2ter;
496 }
497 } else if (si_type == RSL_SYSTEM_INFO_2quater) {
498 if (not isbound(data)) {
499 si.si2quater := {};
500 } else {
501 var SystemInformationType2quater decoded := dec_SystemInformation(data).payload.si2quater;
502 /* this is a *record* of SI2quaterRestOctets! (multiplexed) */
503 si.si2quater[decoded.rest_octets.si2quater_index] := decoded.rest_octets;
504 }
505 } else if (si_type == RSL_SYSTEM_INFO_3) {
506 if (not isbound(data)) {
507 si.si3 := omit;
508 } else {
509 si.si3 := dec_SystemInformation(data).payload.si3;
510 }
511 } else if (si_type == RSL_SYSTEM_INFO_4) {
512 if (not isbound(data)) {
513 si.si4 := omit;
514 } else {
515 si.si4 := dec_SystemInformation(data).payload.si4;
516 }
517 } else if (si_type == RSL_SYSTEM_INFO_13) {
518 if (not isbound(data)) {
519 si.si13 := omit;
520 } else {
Pau Espin Pedrol28652d82021-02-09 20:20:17 +0100521 si.si13 := dec_SystemInformation(data).payload.si13;
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +0200522 }
523 } else {
524 handled := false;
525 }
526 } else if (rsl.msg_type == RSL_MT_SACCH_FILL) {
527 handled := true;
528
529 if (si_type == RSL_SYSTEM_INFO_5) {
530 if (not isbound(data)) {
531 si.si5 := omit;
532 } else {
533 si.si5 := dec_SystemInformation(data).payload.si5;
534 }
535 } else if (si_type == RSL_SYSTEM_INFO_5bis) {
536 if (not isbound(data)) {
537 si.si5bis := omit;
538 } else {
539 si.si5bis := dec_SystemInformation(data).payload.si5bis;
540 }
541 } else if (si_type == RSL_SYSTEM_INFO_5ter) {
542 if (not isbound(data)) {
543 si.si5ter := omit;
544 } else {
545 si.si5ter := dec_SystemInformation(data).payload.si5ter;
546 }
547 } else if (si_type == RSL_SYSTEM_INFO_6) {
548 if (not isbound(data)) {
549 si.si6 := omit;
550 } else {
551 si.si6 := dec_SystemInformation(data).payload.si6;
552 }
553 } else {
554 handled := false;
555 }
556 }
557
558 if (not handled) {
559 setverdict(fail, "Unexpected SI type in ", rsl.msg_type, " message: ", si_type);
560 }
561}
562
Harald Weltea4ca4462018-02-09 00:17:14 +0100563type component test_CT extends CTRL_Adapter_CT {
Harald Welte21b46bd2017-12-17 19:46:32 +0100564 /* Array of per-BTS state */
Harald Welte96c94412017-12-09 03:12:45 +0100565 var BTS_State bts[NUM_BTS];
Harald Welte89ab1912018-02-23 18:56:29 +0100566 /* RSL common Channel Port (for RSL_Emulation) */
567 port RSL_CCHAN_PT RSL_CCHAN[NUM_BTS];
Harald Welte21b46bd2017-12-17 19:46:32 +0100568 /* array of per-BTS RSL test ports */
Harald Welteae026692017-12-09 01:03:01 +0100569 port IPA_RSL_PT IPA_RSL[NUM_BTS];
Stefan Sperling830dc9d2018-02-12 21:08:28 +0100570 port IPA_CODEC_PT IPA; /* Required for compilation of TC_rsl_unknown_unit_id() */
Pau Espin Pedrol5a2d7432019-06-07 19:43:45 +0200571 /* CTRL muxed over IPA in SCCPlite conn BSC<->MSC (or BSC-NAT) */
572 port IPA_CTRL_PT SCCPLITE_IPA_CTRL;
Harald Weltea5d2ab22017-12-09 14:21:42 +0100573
Daniel Willmann191e0d92018-01-17 12:44:35 +0100574 var MGCP_Emulation_CT vc_MGCP;
Harald Weltebc03c762018-02-12 18:09:38 +0100575 port TELNETasp_PT BSCVTY;
Daniel Willmann191e0d92018-01-17 12:44:35 +0100576
Daniel Willmannebdecc02020-08-12 15:30:17 +0200577 /* StatsD */
578 var StatsD_Checker_CT vc_STATSD;
579
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200580 var RAN_Adapter g_bssap[NUM_MSC];
Harald Welte47cd0e32020-08-21 12:39:11 +0200581 var BSSAP_LE_Adapter g_bssap_le;
Harald Weltea4ca4462018-02-09 00:17:14 +0100582 /* for old legacy-tests only */
583 port BSSAP_CODEC_PT BSSAP;
Harald Welte47cd0e32020-08-21 12:39:11 +0200584 port BSSAP_LE_CODEC_PT BSSAP_LE;
Harald Weltea4ca4462018-02-09 00:17:14 +0100585
Harald Welte21b46bd2017-12-17 19:46:32 +0100586 /* are we initialized yet */
Harald Welte28d943e2017-11-25 15:00:50 +0100587 var boolean g_initialized := false;
Harald Welte21b46bd2017-12-17 19:46:32 +0100588
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200589 /* Osmux is enabled through VTY */
590 var boolean g_osmux_enabled := false;
591
Pau Espin Pedrolc675b612020-01-09 19:55:40 +0100592 /*Configure T(tias) over VTY, seconds */
593 var integer g_bsc_sccp_timer_ias := 7 * 60;
594 /*Configure T(tiar) over VTY, seconds */
595 var integer g_bsc_sccp_timer_iar := 15 * 60;
596
Neels Hofmeyr4fbad7f2020-06-16 00:30:47 +0200597 /* global test case guard timer (actual timeout value is set in f_init()) */
Harald Welteae026692017-12-09 01:03:01 +0100598 timer T_guard := 30.0;
599
Neels Hofmeyr22c3f792020-06-17 02:49:28 +0200600 var CounterNameValsList g_ctr_msc;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +0000601 var CounterNameValsList g_ctr_bsc;
602 var CounterNameValsList g_ctr_bts;
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +0200603
604 /* System Information bytes as received during RSL startup, for each RSL[idx]. */
605 var SystemInformationConfig_list g_system_information := {};
Harald Welte28d943e2017-11-25 15:00:50 +0100606}
607
Pau Espin Pedrol0953bf82021-07-09 13:20:19 +0200608type record of charstring phys_chan_configs;
Harald Welte28d943e2017-11-25 15:00:50 +0100609modulepar {
Harald Welte21b46bd2017-12-17 19:46:32 +0100610 /* IP address at which the BSC can be reached */
Harald Welte696ddb62017-12-08 14:01:43 +0100611 charstring mp_bsc_ip := "127.0.0.1";
Stefan Sperling830dc9d2018-02-12 21:08:28 +0100612 /* port number to which to establish the IPA OML connections */
613 integer mp_bsc_oml_port := 3002;
Harald Welte21b46bd2017-12-17 19:46:32 +0100614 /* port number to which to establish the IPA RSL connections */
Harald Welte696ddb62017-12-08 14:01:43 +0100615 integer mp_bsc_rsl_port := 3003;
Harald Welte21b46bd2017-12-17 19:46:32 +0100616 /* port number to which to establish the IPA CTRL connection */
Harald Welte96c94412017-12-09 03:12:45 +0100617 integer mp_bsc_ctrl_port := 4249;
Daniel Willmannebdecc02020-08-12 15:30:17 +0200618 /* port number to which to listen for STATSD metrics */
619 integer mp_bsc_statsd_port := 8125;
Daniel Willmann191e0d92018-01-17 12:44:35 +0100620 /* IP address at which the test binds */
621 charstring mp_test_ip := "127.0.0.1";
Harald Weltea4ca4462018-02-09 00:17:14 +0100622
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200623 RAN_Configurations mp_bssap_cfg := {
624 {
625 transport := BSSAP_TRANSPORT_AoIP,
626 sccp_service_type := "mtp3_itu",
627 sctp_addr := { 23905, "127.0.0.1", 2905, "127.0.0.1" },
628 own_pc := 185, /* 0.23.1 first MSC emulation */
629 own_ssn := 254,
630 peer_pc := 187, /* 0.23.3 osmo-bsc */
631 peer_ssn := 254,
632 sio := '83'O,
Harald Weltecb0cc432020-06-21 19:42:31 +0200633 rctx := 1
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200634 },
635 {
636 transport := BSSAP_TRANSPORT_AoIP,
637 sccp_service_type := "mtp3_itu",
638 sctp_addr := { 23906, "127.0.0.1", 2905, "127.0.0.1" },
639 own_pc := 2, /* 0.0.2 second MSC emulation */
640 own_ssn := 254,
641 peer_pc := 187, /* 0.23.3 osmo-bsc */
642 peer_ssn := 254,
643 sio := '83'O,
644 rctx := 2
645 },
646 {
647 transport := BSSAP_TRANSPORT_AoIP,
648 sccp_service_type := "mtp3_itu",
649 sctp_addr := { 23907, "127.0.0.1", 2905, "127.0.0.1" },
650 own_pc := 3, /* 0.0.3 third MSC emulation */
651 own_ssn := 254,
652 peer_pc := 187, /* 0.23.3 osmo-bsc */
653 peer_ssn := 254,
654 sio := '83'O,
655 rctx := 3
656 }
Harald Weltea4ca4462018-02-09 00:17:14 +0100657 };
Pau Espin Pedrol58cf6822019-05-28 18:11:33 +0200658
Pau Espin Pedrol0953bf82021-07-09 13:20:19 +0200659 /* Must match per BTS config in osmo-bsc.cfg */
660 phys_chan_configs phys_chan_config := {
661 "CCCH+SDCCH4+CBCH",
662 "TCH/F",
663 "TCH/F",
664 "TCH/F",
665 "TCH/F",
Vadim Yanitskiy343c9eb2021-07-16 18:36:01 +0600666 "TCH/H",
Pau Espin Pedrol0953bf82021-07-09 13:20:19 +0200667 "PDCH",
668 "PDCH"
669 };
670
Harald Welte47cd0e32020-08-21 12:39:11 +0200671 BSSAP_LE_Configuration mp_bssap_le_cfg := {
672 sccp_service_type := "mtp3_itu",
673 sctp_addr := { 23908, "127.0.0.1", 2905, "127.0.0.1" },
Neels Hofmeyrac086c12020-09-18 23:46:42 +0200674 own_pc := 190, /* 0.23.6 SMLC emulation */
Harald Welte47cd0e32020-08-21 12:39:11 +0200675 own_ssn := 252, /* SMLC side SSN */
676 peer_pc := 187, /* 0.23.3 osmo-bsc */
677 peer_ssn := 250, /* BSC side SSN */
678 sio := '83'O,
679 rctx := 6
680 };
Neels Hofmeyrcfe44062020-10-15 02:28:08 +0200681 boolean mp_enable_lcs_tests := true;
Harald Welte47cd0e32020-08-21 12:39:11 +0200682
Pau Espin Pedrole076b3f2021-07-20 16:45:57 +0200683 /* Whether to enable dyn TS SDCCH8 tests. Can be dropped completely and enable
684 unconditionally once new version of osmo-bsc is released (current
685 version: 1.7.0) */
686 boolean mp_enable_dyn_sdcch8_test := true;
Pau Espin Pedrol8f30ccd2019-11-01 17:30:57 +0100687 /* Value set in osmo-bsc.cfg "ms max power" */
688 uint8_t mp_exp_ms_power_level := 7;
Harald Weltea4ca4462018-02-09 00:17:14 +0100689}
690
Neels Hofmeyr9f3e6ac2021-04-08 23:09:24 +0200691friend function f_gen_test_hdlr_pars(integer bssap_idx := 0) return TestHdlrParams {
Philipp Maier48604732018-10-09 15:00:37 +0200692
693 var TestHdlrParams pars := valueof(t_def_TestHdlrPars);
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200694 if (mp_bssap_cfg[bssap_idx].transport == BSSAP_TRANSPORT_AoIP) {
Philipp Maier48604732018-10-09 15:00:37 +0200695 pars.aoip := true;
696 } else {
697 pars.aoip := false;
698 }
Pau Espin Pedrol8f30ccd2019-11-01 17:30:57 +0100699 pars.exp_ms_power_level := mp_exp_ms_power_level;
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200700 pars.mscpool.bssap_idx := bssap_idx;
Philipp Maier48604732018-10-09 15:00:37 +0200701
Neels Hofmeyrb5b7a6e2021-06-04 19:03:45 +0200702 /* BTS 0 has BSIC 10 (and no explicit timeslot training_sequence_code config), so expecting TSC = (BSIC & 7) = 2 */
703 pars.expect_tsc := 2;
704
Philipp Maier48604732018-10-09 15:00:37 +0200705 return pars;
706}
707
Neels Hofmeyr22c3f792020-06-17 02:49:28 +0200708/* Convenience functions for rate counters using g_ctr_msc. */
709
710private function f_ctrs_msc_init(integer mscs_count := NUM_MSC, CounterNameVals counternames := counternames_msc_mscpool) runs on test_CT {
711 g_ctr_msc := f_counter_name_vals_get_n(IPA_CTRL, "msc", mscs_count, counternames);
712 log("initial msc rate counters: ", g_ctr_msc);
713}
714
715private function f_ctrs_msc_add(integer msc_nr, charstring countername, integer val := 1) runs on test_CT {
Neels Hofmeyr9656e922020-06-30 01:27:01 +0200716 f_counter_name_vals_list_add(g_ctr_msc, msc_nr, countername, val);
Neels Hofmeyr22c3f792020-06-17 02:49:28 +0200717}
718
719/* f_ctrs_msc_init();
720 * f_do_thing(on_msc := 0);
721 * f_do_thing(on_msc := 0);
722 * f_do_other(on_msc := 1);
723 * f_ctrs_msc_add(0, "thing", 2);
724 * f_ctrs_msc_add(1, "other");
725 * f_ctrs_msc_verify();
726 */
727private function f_ctrs_msc_verify() runs on test_CT {
728 log("verifying msc rate counters: ", g_ctr_msc);
729 f_counter_name_vals_expect_n(IPA_CTRL, "msc", g_ctr_msc);
730}
731
732/* convenience: f_ctrs_msc_add() and f_ctrs_msc_verify() in one call.
733 * f_ctrs_msc_init();
734 * f_do_thing(on_msc := 0);
735 * f_do_thing(on_msc := 0);
736 * f_do_thing(on_msc := 0);
737 * f_ctrs_msc_expect(0, "thing", 3);
738 */
739private function f_ctrs_msc_expect(integer msc_nr, charstring countername, integer val := 1) runs on test_CT {
740 f_ctrs_msc_add(msc_nr, countername, val);
741 f_ctrs_msc_verify();
742}
743
Neels Hofmeyr12941bd2020-08-29 03:21:26 +0000744/* Convenience functions for rate counters using g_ctr_bts, always also including g_ctr_bsc. */
745
746private function f_ctrs_bsc_and_bts_init(integer bts_count := NUM_BTS, CounterNameVals counternames := counternames_bsc_bts_handover) runs on test_CT {
747 g_ctr_bts := f_counter_name_vals_get_n(IPA_CTRL, "bts", bts_count, counternames);
748 log("initial bts rate counters: ", g_ctr_bts);
749 f_ctrs_bsc_init(counternames);
750}
751
752private function f_ctrs_bsc_and_bts_add(integer bts_nr, charstring countername, integer val := 1) runs on test_CT {
753 f_counter_name_vals_list_add(g_ctr_bts, bts_nr, countername, val);
754 f_ctrs_bsc_add(countername, val);
755}
756
757/* f_ctrs_bsc_and_bts_init();
758 * f_do_thing(on_bts := 0);
759 * f_do_thing(on_bts := 0);
760 * f_do_other(on_bts := 1);
761 * f_ctrs_bsc_and_bts_add(0, "thing", 2);
762 * f_ctrs_bsc_and_bts_add(1, "other");
763 * f_ctrs_bsc_and_bts_verify();
764 */
765private function f_ctrs_bsc_and_bts_verify() runs on test_CT {
766 f_counter_name_vals_expect_n(IPA_CTRL, "bts", g_ctr_bts);
767 f_ctrs_bsc_verify();
768}
769
770/* convenience: f_ctrs_bsc_and_bts_add() and f_ctrs_bsc_and_bts_verify() in one call.
771 * f_ctrs_bsc_and_bts_init();
772 * f_do_thing(on_bts := 0);
773 * f_do_thing(on_bts := 0);
774 * f_do_thing(on_bts := 0);
775 * f_ctrs_bsc_and_bts_expect(0, "thing", 3);
776 */
777private function f_ctrs_bsc_and_bts_expect(integer bts_nr, charstring countername, integer val := 1) runs on test_CT {
778 f_ctrs_bsc_and_bts_add(bts_nr, countername, val);
779 f_ctrs_bsc_and_bts_verify();
780}
781
782
783/* Convenience functions for rate counters using g_ctr_bsc. */
784
785private function f_ctrs_bsc_init(CounterNameVals counternames := counternames_bsc_bts_handover) runs on test_CT {
786 g_ctr_bsc := f_counter_name_vals_get_n(IPA_CTRL, "bsc", 1, counternames);
787 log("initial bsc rate counters: ", g_ctr_bsc);
788}
789
790private function f_ctrs_bsc_add(charstring countername, integer val := 1) runs on test_CT {
791 f_counter_name_vals_list_add(g_ctr_bsc, 0, countername, val);
792}
793
794/* f_ctrs_bsc_init();
795 * f_do_thing();
796 * f_do_thing();
797 * f_do_other();
798 * f_ctrs_bsc_add("thing", 2);
799 * f_ctrs_bsc_add("other");
800 * f_ctrs_bsc_verify();
801 */
802private function f_ctrs_bsc_verify() runs on test_CT {
803 f_counter_name_vals_expect_n(IPA_CTRL, "bsc", g_ctr_bsc);
804}
805
806/* convenience: f_ctrs_bsc_add() and f_ctrs_bsc_verify() in one call.
807 * f_ctrs_bsc_init();
808 * f_do_thing();
809 * f_ctrs_bsc_expect("thing", 1);
810 */
811private function f_ctrs_bsc_expect(charstring countername, integer val := 1) runs on test_CT {
812 f_ctrs_bsc_add(countername, val);
813 f_ctrs_bsc_verify();
814}
815
Neels Hofmeyr22c3f792020-06-17 02:49:28 +0200816
Neels Hofmeyr9f3e6ac2021-04-08 23:09:24 +0200817friend function f_shutdown_helper() runs on test_CT {
Daniel Willmann637ef6c2018-07-25 10:49:09 +0200818 all component.stop;
Philipp Maier282ca4b2018-02-27 17:17:00 +0100819 setverdict(pass);
Daniel Willmannafce8662018-07-06 23:11:32 +0200820 mtc.stop;
Philipp Maier282ca4b2018-02-27 17:17:00 +0100821}
822
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200823private function f_legacy_bssap_reset(integer bssap_idx := 0) runs on test_CT {
Harald Weltea4ca4462018-02-09 00:17:14 +0100824 var BSSAP_N_UNITDATA_ind ud_ind;
Pau Espin Pedrol24c05992020-09-01 12:54:12 +0200825 var boolean reset_received := false;
Harald Weltea4ca4462018-02-09 00:17:14 +0100826 timer T := 5.0;
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200827 BSSAP.send(ts_BSSAP_UNITDATA_req(g_bssap[bssap_idx].sccp_addr_peer, g_bssap[bssap_idx].sccp_addr_own,
828 ts_BSSMAP_Reset(0, g_osmux_enabled)));
Harald Weltea4ca4462018-02-09 00:17:14 +0100829 T.start;
830 alt {
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200831 [] BSSAP.receive(tr_BSSAP_UNITDATA_ind(g_bssap[bssap_idx].sccp_addr_own, g_bssap[bssap_idx].sccp_addr_peer,
832 tr_BSSMAP_ResetAck(g_osmux_enabled))) {
Neels Hofmeyr4f5d7be2020-10-16 16:28:16 +0200833 log("BSSMAP: Received RESET-ACK in response to RESET, we're ready to go!");
Harald Weltea4ca4462018-02-09 00:17:14 +0100834 }
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200835 [] BSSAP.receive(tr_BSSAP_UNITDATA_ind(?, ?, tr_BSSMAP_Reset(g_osmux_enabled))) -> value ud_ind {
Neels Hofmeyr4f5d7be2020-10-16 16:28:16 +0200836 log("BSSMAP: Respoding to inbound RESET with RESET-ACK");
Harald Weltea4ca4462018-02-09 00:17:14 +0100837 BSSAP.send(ts_BSSAP_UNITDATA_req(ud_ind.callingAddress, ud_ind.calledAddress,
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200838 ts_BSSMAP_ResetAck(g_osmux_enabled)));
Pau Espin Pedrol24c05992020-09-01 12:54:12 +0200839 reset_received := true;
Harald Weltea4ca4462018-02-09 00:17:14 +0100840 repeat;
841 }
842 [] BSSAP.receive { repeat; }
Pau Espin Pedrol24c05992020-09-01 12:54:12 +0200843 [] T.timeout {
Neels Hofmeyr4f5d7be2020-10-16 16:28:16 +0200844 log("BSSMAP: Timeout waiting for RESET-ACK after sending RESET");
Pau Espin Pedrol24c05992020-09-01 12:54:12 +0200845 /* If we received a RESET after ours was sent, it
846 may be a race condition where the other peer beacame
847 available after we sent it, but we are in a desired
848 state anyway, so go forward. */
849 if (not reset_received) {
850 setverdict(fail);
851 }
852 }
Harald Weltea4ca4462018-02-09 00:17:14 +0100853 }
Harald Welte28d943e2017-11-25 15:00:50 +0100854}
855
Harald Welteae026692017-12-09 01:03:01 +0100856type record IPA_Client {
Harald Welte21b46bd2017-12-17 19:46:32 +0100857 /* IPA Emulation component reference */
Harald Welteae026692017-12-09 01:03:01 +0100858 IPA_Emulation_CT vc_IPA,
Harald Welte21b46bd2017-12-17 19:46:32 +0100859 /* Unit-ID and other CCM parameters to use for IPA client emulation */
Harald Welteae026692017-12-09 01:03:01 +0100860 IPA_CCM_Parameters ccm_pars,
Harald Welte21b46bd2017-12-17 19:46:32 +0100861 /* String identifier for this IPA Client */
Harald Welte624f9632017-12-16 19:26:04 +0100862 charstring id,
Harald Welte21b46bd2017-12-17 19:46:32 +0100863 /* Associated RSL Emulation Component (if any). Only used in "Handler mode" */
Harald Welte624f9632017-12-16 19:26:04 +0100864 RSL_Emulation_CT vc_RSL optional
Harald Welte28d943e2017-11-25 15:00:50 +0100865}
866
Harald Welte21b46bd2017-12-17 19:46:32 +0100867/*! Start the IPA/RSL related bits for one IPA_Client.
868 * \param clnt IPA_Client for which to establish
869 * \param bsc_host IP address / hostname of the BSC
870 * \param bsc_port TCP port number of the BSC
871 * \param i number identifying this BTS
872 * \param handler_mode Start an RSL_Emulation_CT component (true) or not (false) */
Harald Welte624f9632017-12-16 19:26:04 +0100873function f_ipa_rsl_start(inout IPA_Client clnt, charstring bsc_host, PortNumber bsc_port, integer i,
874 boolean handler_mode := false)
Harald Welte28d943e2017-11-25 15:00:50 +0100875runs on test_CT {
Harald Welteae026692017-12-09 01:03:01 +0100876 timer T := 10.0;
877
Harald Welte96c94412017-12-09 03:12:45 +0100878 clnt.id := "IPA" & int2str(i) & "-RSL";
Harald Welteae026692017-12-09 01:03:01 +0100879 clnt.vc_IPA := IPA_Emulation_CT.create(clnt.id & "-IPA");
880 clnt.ccm_pars := c_IPA_default_ccm_pars;
881 clnt.ccm_pars.name := "Osmocom TTCN-3 BTS Simulator";
882 clnt.ccm_pars.unit_id := int2str(1234+i) & "/0/0";
Harald Welte624f9632017-12-16 19:26:04 +0100883 if (handler_mode) {
884 clnt.vc_RSL := RSL_Emulation_CT.create(clnt.id & "-RSL");
Harald Welte89ab1912018-02-23 18:56:29 +0100885 connect(clnt.vc_RSL:CCHAN_PT, self:RSL_CCHAN[i]);
Harald Welte624f9632017-12-16 19:26:04 +0100886 }
Harald Welteae026692017-12-09 01:03:01 +0100887
888 map(clnt.vc_IPA:IPA_PORT, system:IPA_CODEC_PT);
Harald Welte624f9632017-12-16 19:26:04 +0100889 if (handler_mode) {
890 connect(clnt.vc_IPA:IPA_RSL_PORT, clnt.vc_RSL:IPA_PT);
891 } else {
892 connect(clnt.vc_IPA:IPA_RSL_PORT, self:IPA_RSL[i]);
893 }
Harald Welteae026692017-12-09 01:03:01 +0100894
Harald Welte5d1a2202017-12-13 19:51:29 +0100895 clnt.vc_IPA.start(IPA_Emulation.main_client(bsc_host, bsc_port, "", 10000+i, clnt.ccm_pars));
Harald Welte624f9632017-12-16 19:26:04 +0100896 if (handler_mode) {
897 clnt.vc_RSL.start(RSL_Emulation.main());
898 return;
899 }
Harald Welteae026692017-12-09 01:03:01 +0100900
901 /* wait for IPA RSL link to connect and send ID ACK */
902 T.start;
903 alt {
Vadim Yanitskiya2afacc2020-05-18 21:16:19 +0700904 [] IPA_RSL[i].receive(tr_ASP_IPA_EV(ASP_IPA_EVENT_ID_ACK)) {
Harald Welteae026692017-12-09 01:03:01 +0100905 T.stop;
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +0700906 IPA_RSL[i].send(ts_ASP_RSL_UD(ts_RSL_PAGING_LOAD_IND(23)));
Harald Welteae026692017-12-09 01:03:01 +0100907 }
Harald Welte60e823a2017-12-10 14:10:59 +0100908 [] IPA_RSL[i].receive(ASP_IPA_Event:?) { repeat }
Harald Welteae026692017-12-09 01:03:01 +0100909 [] IPA_RSL[i].receive { repeat }
910 [] T.timeout {
Harald Welte96c94412017-12-09 03:12:45 +0100911 setverdict(fail, "Timeout RSL waiting for ASP_IPA_EVENT_ID_ACK");
Daniel Willmannafce8662018-07-06 23:11:32 +0200912 mtc.stop;
Harald Welteae026692017-12-09 01:03:01 +0100913 }
914 }
915}
916
Harald Welte12055472018-03-17 20:10:08 +0100917function f_ipa_rsl_stop(inout IPA_Client clnt) runs on test_CT {
918 if (not isbound(clnt) or not isbound(clnt.vc_IPA)) {
919 return;
920 }
921 clnt.vc_IPA.stop;
922 if (isbound(clnt.vc_RSL)) {
923 clnt.vc_RSL.stop;
924 }
925}
926
Harald Welte21b46bd2017-12-17 19:46:32 +0100927/* Wait for the OML connection to be brought up by the external osmo-bts-omldummy */
Harald Weltea5d2ab22017-12-09 14:21:42 +0100928function f_wait_oml(integer bts_nr, charstring status, float secs_max) runs on test_CT {
929 timer T := secs_max;
930 T.start;
931 while (true) {
932 if (f_ctrl_get_bts(IPA_CTRL, bts_nr, "oml-connection-state") == status) {
933 T.stop;
Harald Weltebd868bd2017-12-10 18:28:40 +0100934 /* the 'degraded' state exists from OML connection time, and we have to wait
935 * until all MO's are initialized */
936 T.start(1.0);
937 T.timeout;
Harald Weltea5d2ab22017-12-09 14:21:42 +0100938 return;
939 }
Harald Weltef0d6ac62017-12-17 17:02:21 +0100940 f_sleep(0.1);
Harald Weltea5d2ab22017-12-09 14:21:42 +0100941 if (not T.running) {
Max99253902018-11-16 17:57:39 +0100942 setverdict(fail, "Timeout waiting for BTS" & int2str(bts_nr) & " oml-connection-state ", status);
Daniel Willmannafce8662018-07-06 23:11:32 +0200943 mtc.stop;
Harald Weltea5d2ab22017-12-09 14:21:42 +0100944 }
945 }
946}
947
Harald Welte21b46bd2017-12-17 19:46:32 +0100948/* global altstep for global guard timer; also takes care of responding RESET witH RESET-ACK */
Harald Welteae026692017-12-09 01:03:01 +0100949altstep as_Tguard() runs on test_CT {
Harald Welte60e823a2017-12-10 14:10:59 +0100950 var BSSAP_N_UNITDATA_ind ud_ind;
Neels Hofmeyrcc3f76a2018-03-12 01:43:25 +0100951 [] T_guard.timeout {
952 setverdict(fail, "Timeout of T_guard");
Daniel Willmannafce8662018-07-06 23:11:32 +0200953 mtc.stop;
Neels Hofmeyrcc3f76a2018-03-12 01:43:25 +0100954 }
Harald Welte60e823a2017-12-10 14:10:59 +0100955 /* always respond with RESET ACK to RESET */
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200956 [] BSSAP.receive(tr_BSSAP_UNITDATA_ind(?, ?, tr_BSSMAP_Reset(g_osmux_enabled))) -> value ud_ind {
Harald Welte60e823a2017-12-10 14:10:59 +0100957 BSSAP.send(ts_BSSAP_UNITDATA_req(ud_ind.callingAddress, ud_ind.calledAddress,
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200958 ts_BSSMAP_ResetAck(g_osmux_enabled)));
Harald Welte69c1c262017-12-13 21:02:08 +0100959 repeat;
Harald Welte60e823a2017-12-10 14:10:59 +0100960 }
Harald Welte28d943e2017-11-25 15:00:50 +0100961}
962
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +0100963altstep no_bssmap_reset() runs on test_CT {
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200964 [] BSSAP.receive(tr_BSSAP_UNITDATA_ind(?, ?, tr_BSSMAP_Reset(g_osmux_enabled))) {
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +0100965 setverdict(fail, "unexpected BSSMAP Reset");
Daniel Willmannafce8662018-07-06 23:11:32 +0200966 mtc.stop;
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +0100967 }
968}
969
Daniel Willmann191e0d92018-01-17 12:44:35 +0100970function f_init_mgcp(charstring id) runs on test_CT {
971 id := id & "-MGCP";
972
973 var MGCPOps ops := {
974 create_cb := refers(MGCP_Emulation.ExpectedCreateCallback),
975 unitdata_cb := refers(MGCP_Emulation.DummyUnitdataCallback)
976 };
977 var MGCP_conn_parameters mgcp_pars := {
978 callagent_ip := mp_bsc_ip,
Harald Welte9e4273e2018-01-29 22:01:22 +0100979 callagent_udp_port := -1,
Daniel Willmann191e0d92018-01-17 12:44:35 +0100980 mgw_ip := mp_test_ip,
Pau Espin Pedrol1a026a52019-06-18 17:21:52 +0200981 mgw_udp_port := 2427,
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +0200982 /* Enable it for SCCPlite, since we have 2 MGCP sockets towards MGW (UDP one +
983 the on with MGCP over IPA forwarded from MSC one) */
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200984 multi_conn_mode := (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_SCCPlite_SERVER)
Daniel Willmann191e0d92018-01-17 12:44:35 +0100985 };
986
987 vc_MGCP := MGCP_Emulation_CT.create(id);
988 vc_MGCP.start(MGCP_Emulation.main(ops, mgcp_pars, id));
989}
990
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200991/* Enable or disable (current default) Osmux. When enabling, BSSMAP Reset
992 * contains extra IE (OsmuxSupport) and osmo-bsc will handle AssignReq with
993 * OsmuxCID IE.
994 */
995private function f_vty_allow_osmux(boolean allow) runs on test_CT {
996 f_vty_enter_cfg_msc(BSCVTY, 0);
997 if (allow) {
998 f_vty_transceive(BSCVTY, "osmux on");
999 } else {
1000 f_vty_transceive(BSCVTY, "osmux off");
1001 }
1002 f_vty_transceive(BSCVTY, "exit");
1003 f_vty_transceive(BSCVTY, "exit");
1004 g_osmux_enabled := allow;
1005}
1006
Max2253c0b2018-11-06 19:28:05 +01001007function f_init_vty(charstring id := "foo") runs on test_CT {
Harald Welte94e0c342018-04-07 11:33:23 +02001008 if (BSCVTY.checkstate("Mapped")) {
1009 /* skip initialization if already executed once */
1010 return;
1011 }
Harald Weltebc03c762018-02-12 18:09:38 +01001012 map(self:BSCVTY, system:BSCVTY);
1013 f_vty_set_prompts(BSCVTY);
1014 f_vty_transceive(BSCVTY, "enable");
Pau Espin Pedrolc675b612020-01-09 19:55:40 +01001015 f_cs7_inst_0_cfg(BSCVTY, {"sccp-timer ias " & int2str(g_bsc_sccp_timer_ias),
1016 "sccp-timer iar " & int2str(g_bsc_sccp_timer_iar)});
Harald Weltebc03c762018-02-12 18:09:38 +01001017}
1018
Neels Hofmeyr9f3e6ac2021-04-08 23:09:24 +02001019friend function f_logp(TELNETasp_PT pt, charstring log_msg)
Neels Hofmeyr4f118412020-06-04 15:25:10 +02001020{
1021 // log on TTCN3 log output
1022 log(log_msg);
1023 // log in stderr log
Neels Hofmeyr767548a2020-08-09 20:26:07 +00001024 f_vty_transceive(pt, "logp lglobal notice TTCN3 f_logp(): " & log_msg);
Neels Hofmeyr4f118412020-06-04 15:25:10 +02001025}
1026
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +02001027private function f_sysinfo_seen(integer rsl_idx, RSL_Message rsl) runs on test_CT
1028{
1029 if (rsl_idx >= lengthof(g_system_information)) {
1030 g_system_information[rsl_idx] := SystemInformationConfig_omit
1031 }
1032 f_sysinfo_dec_raw(g_system_information[rsl_idx], rsl);
1033}
1034
1035altstep as_catch_RSL_sysinfo(integer rsl_idx) runs on test_CT {
1036 var ASP_RSL_Unitdata rx_rsl_ud;
1037
1038 /* For handler_mode := false, receiving the RSL bootstrap messages directly on IPA_RSL */
1039 [] IPA_RSL[rsl_idx].receive(tr_ASP_RSL_UD(tr_RSL_NO_BCCH_INFO)) -> value rx_rsl_ud {
1040 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
1041 repeat;
1042 }
1043 [] IPA_RSL[rsl_idx].receive(tr_ASP_RSL_UD(tr_RSL_BCCH_INFO)) -> value rx_rsl_ud {
1044 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
1045 repeat;
1046 }
1047 [] IPA_RSL[rsl_idx].receive(tr_ASP_RSL_UD(tr_RSL_NO_SACCH_FILL)) -> value rx_rsl_ud {
1048 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
1049 repeat;
1050 }
1051 [] IPA_RSL[rsl_idx].receive(tr_ASP_RSL_UD(tr_RSL_SACCH_FILL)) -> value rx_rsl_ud {
1052 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
1053 repeat;
1054 }
1055
1056 /* For handler_mode := true, receiving the RSL bootstrap messages via RSL_Emulation */
1057 [] RSL_CCHAN[rsl_idx].receive(tr_ASP_RSL_UD(tr_RSL_NO_BCCH_INFO)) -> value rx_rsl_ud {
1058 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
1059 repeat;
1060 }
1061 [] RSL_CCHAN[rsl_idx].receive(tr_ASP_RSL_UD(tr_RSL_BCCH_INFO)) -> value rx_rsl_ud {
1062 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
1063 repeat;
1064 }
1065 [] RSL_CCHAN[rsl_idx].receive(tr_ASP_RSL_UD(tr_RSL_NO_SACCH_FILL)) -> value rx_rsl_ud {
1066 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
1067 repeat;
1068 }
1069 [] RSL_CCHAN[rsl_idx].receive(tr_ASP_RSL_UD(tr_RSL_SACCH_FILL)) -> value rx_rsl_ud {
1070 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
1071 repeat;
1072 }
1073}
1074
Neels Hofmeyra460f1f2020-08-09 20:17:03 +00001075/* TODO: use BooleanList from COMMON/src/General_Types.ttcn */
1076private type record of boolean my_BooleanList;
1077
1078private function f_vty_msc_allow_attach(TELNETasp_PT pt, my_BooleanList allow_attach_list)
1079{
Neels Hofmeyr8f576712020-08-12 22:49:53 +00001080 var charstring config := f_vty_transceive_ret(pt, "show running-config");
1081
Neels Hofmeyra460f1f2020-08-09 20:17:03 +00001082 for (var integer msc_nr := 0; msc_nr < sizeof(allow_attach_list); msc_nr := msc_nr+1) {
Neels Hofmeyr8f576712020-08-12 22:49:53 +00001083 if (f_strstr(config, "\nmsc " & int2str(msc_nr) & "\n") < 0) {
1084 /* There is no 'msc N' for this msc_nr in the running config, so don't create an empty msc by
1085 * stepping into that config node. */
1086 log("msc ", msc_nr, " is not configured, skipping");
1087 continue;
1088 }
Neels Hofmeyra460f1f2020-08-09 20:17:03 +00001089 f_vty_enter_cfg_msc(pt, msc_nr);
1090 if (allow_attach_list[msc_nr]) {
1091 /* strict := false: ignore if osmo-bsc does not support this config option (latest build) */
1092 f_vty_transceive(pt, "allow-attach", strict := false);
1093 } else {
1094 f_vty_transceive(pt, "no allow-attach", strict := false);
1095 }
1096 f_vty_transceive(pt, "exit");
1097 f_vty_transceive(pt, "exit");
1098 }
1099}
1100
Harald Welte21b46bd2017-12-17 19:46:32 +01001101/* global initialization function
1102 * \param nr_bts Number of BTSs we should start/bring up
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001103 * \param handler_mode Start an RSL_Emulation_CT component (true) or not (false).
1104 * \param nr_msc Number of virtual MSCs to bring up to connect to osmo-bsc.
1105 */
1106function f_init(integer nr_bts := NUM_BTS, boolean handler_mode := false, boolean allow_osmux := false,
Neels Hofmeyr4fbad7f2020-06-16 00:30:47 +02001107 integer nr_msc := 1, float guard_timeout := 30.0) runs on test_CT {
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001108 var integer bssap_idx;
Harald Welte28d943e2017-11-25 15:00:50 +01001109
Harald Welteae026692017-12-09 01:03:01 +01001110 if (g_initialized) {
1111 return;
Harald Welte28d943e2017-11-25 15:00:50 +01001112 }
Harald Welteae026692017-12-09 01:03:01 +01001113 g_initialized := true;
1114
Neels Hofmeyr4fbad7f2020-06-16 00:30:47 +02001115 T_guard.start(guard_timeout);
Daniel Willmanne68f9272018-11-27 15:15:28 +01001116 activate(as_Tguard());
1117
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02001118 f_init_vty("VirtMSC");
Pau Espin Pedrol23510fb2021-07-20 17:00:38 +02001119 f_vty_allow_osmux(allow_osmux);
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02001120
Neels Hofmeyra460f1f2020-08-09 20:17:03 +00001121 var my_BooleanList allow_attach := { false, false, false };
Daniel Willmannebdecc02020-08-12 15:30:17 +02001122 f_init_statsd("VirtMSC", vc_STATSD, mp_test_ip, mp_bsc_statsd_port);
1123
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001124 for (bssap_idx := 0; bssap_idx < nr_msc; bssap_idx := bssap_idx+1) {
Neels Hofmeyra460f1f2020-08-09 20:17:03 +00001125 allow_attach[bssap_idx] := true;
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001126 /* Call a function of our 'parent component' RAN_Adapter_CT to start the
1127 * MSC-side BSSAP emulation */
1128 if (handler_mode) {
1129 var RanOps ranops := MSC_RanOps;
1130 ranops.use_osmux := g_osmux_enabled;
1131 f_ran_adapter_init(g_bssap[bssap_idx], mp_bssap_cfg[bssap_idx], "VirtMSC", ranops);
1132 connect(self:SCCPLITE_IPA_CTRL, g_bssap[bssap_idx].vc_RAN:CTRL_CLIENT);
1133 f_ran_adapter_start(g_bssap[bssap_idx]);
1134 } else {
1135 f_ran_adapter_init(g_bssap[bssap_idx], mp_bssap_cfg[bssap_idx], "VirtMSC", omit);
1136 connect(self:BSSAP, g_bssap[bssap_idx].vc_SCCP:SCCP_SP_PORT);
1137 f_ran_adapter_start(g_bssap[bssap_idx]);
1138 f_legacy_bssap_reset();
1139 }
Harald Welte67089ee2018-01-17 22:19:03 +01001140 }
Harald Welted5833a82018-05-27 16:52:56 +02001141
Neels Hofmeyrcfe44062020-10-15 02:28:08 +02001142 if (mp_enable_lcs_tests) {
1143 if (handler_mode) {
1144 f_bssap_le_adapter_init(g_bssap_le, mp_bssap_le_cfg, "VirtSMLC", SMLC_BssapLeOps);
1145 } else {
1146 f_bssap_le_adapter_init(g_bssap_le, mp_bssap_le_cfg, "VirtSMLC", omit);
1147 connect(self:BSSAP_LE, g_bssap_le.vc_SCCP:SCCP_SP_PORT);
1148 }
1149 f_bssap_le_adapter_start(g_bssap_le);
Harald Welte47cd0e32020-08-21 12:39:11 +02001150 }
Harald Welte47cd0e32020-08-21 12:39:11 +02001151
Neels Hofmeyra460f1f2020-08-09 20:17:03 +00001152 /* start the test with exactly all enabled MSCs allowed to attach */
1153 f_vty_msc_allow_attach(BSCVTY, allow_attach);
1154
Pau Espin Pedrol9a5b8ff2021-01-04 19:01:31 +01001155 f_ipa_ctrl_start_client(mp_bsc_ip, mp_bsc_ctrl_port);
Harald Welte28d943e2017-11-25 15:00:50 +01001156
Daniel Willmann191e0d92018-01-17 12:44:35 +01001157 f_init_mgcp("VirtMSC");
1158
Neels Hofmeyr0b7365b2020-07-04 00:52:34 +02001159 for (var integer i := 0; i < nr_bts; i := i+1) {
1160 f_init_bts(i, handler_mode);
Harald Welte696ddb62017-12-08 14:01:43 +01001161 }
Neels Hofmeyr0b7365b2020-07-04 00:52:34 +02001162}
Harald Welte696ddb62017-12-08 14:01:43 +01001163
Neels Hofmeyr0b7365b2020-07-04 00:52:34 +02001164function f_init_bts(integer bts_idx := 0, boolean handler_mode := false)
1165runs on test_CT {
1166 /* wait until osmo-bts-omldummy has respawned */
1167 f_wait_oml(bts_idx, "degraded", 5.0);
1168
1169 /* start RSL connection */
1170 f_ipa_rsl_start(bts[bts_idx].rsl, mp_bsc_ip, mp_bsc_rsl_port, bts_idx, handler_mode);
1171 /* wait until BSC tells us "connected" */
1172 f_wait_oml(bts_idx, "connected", 5.0);
Harald Welte28d943e2017-11-25 15:00:50 +01001173}
1174
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +02001175function f_init_bts_and_check_sysinfo(integer bts_idx := 0, boolean handler_mode := false,
1176 template SystemInformationConfig expect_si)
1177runs on test_CT {
1178 var default sysinfo := activate(as_catch_RSL_sysinfo(bts_idx));
1179
1180 f_init_bts(bts_idx, handler_mode);
1181
1182 /* Give some time to (hopefully/most likely) collect all system informations from RSL startup.
1183 * We could stop as soon as all expected SI are received, but then we might miss SI that we don't expect and
1184 * that might be sent afterwards. So rather give a generous timeout and be quite sure to catch all SI.
1185 */
1186 f_sleep(5.0);
1187 log("RSL ", bts_idx, " SYSTEM INFORMATION: ", g_system_information[bts_idx]);
1188
1189 deactivate(sysinfo);
1190
1191 if (match(g_system_information[bts_idx], expect_si)) {
1192 setverdict(pass);
1193 } else {
1194 log("RSL ", bts_idx, ": EXPECTED SI: ", expect_si);
1195 log("RSL ", bts_idx, ": GOT SI: ", g_system_information[bts_idx]);
1196 setverdict(fail, "received SI does not match expectations");
1197 return;
1198 }
1199}
1200
Maxd4e56962018-10-31 19:08:25 +01001201/* expect to receive a RSL message matching a specified template on a given BTS / stream */
Harald Welte65e419a2020-08-21 12:38:33 +02001202function 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 +01001203runs on test_CT return RSL_Message {
1204 var ASP_RSL_Unitdata rx_rsl_ud;
1205 timer T := t_secs;
1206
1207 T.start;
1208 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001209 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(t_rx, sid)) -> value rx_rsl_ud {
Harald Welteae026692017-12-09 01:03:01 +01001210 T.stop;
1211 }
1212 [] IPA_RSL[bts_nr].receive { repeat; }
Harald Welteb2917702017-12-10 15:48:52 +01001213 [] T.timeout {
1214 setverdict(fail, "Timeout expecting ", t_rx);
Daniel Willmannafce8662018-07-06 23:11:32 +02001215 mtc.stop;
Harald Welteb2917702017-12-10 15:48:52 +01001216 }
Harald Welteae026692017-12-09 01:03:01 +01001217 }
1218 return rx_rsl_ud.rsl;
1219}
1220
Harald Welte21b46bd2017-12-17 19:46:32 +01001221/* helper function to transmit RSL on a given BTS/stream */
Harald Welte65e419a2020-08-21 12:38:33 +02001222function 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 +01001223runs on test_CT {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001224 IPA_RSL[bts_nr].send(ts_ASP_RSL_UD(t_tx, sid));
Harald Welteae026692017-12-09 01:03:01 +01001225}
1226
1227
Harald Welte4003d112017-12-09 22:35:39 +01001228/* verify we get a CHAN_ACT after CHAN RQD */
Harald Welteae026692017-12-09 01:03:01 +01001229testcase TC_chan_act_noreply() runs on test_CT {
1230 var BSSAP_N_UNITDATA_ind ud_ind;
Harald Welte930d0a72018-03-22 22:08:40 +01001231 var RSL_Message rsl_unused;
Harald Welte28d943e2017-11-25 15:00:50 +01001232
Harald Welte89d42e82017-12-17 16:42:41 +01001233 f_init(1);
Harald Welte28d943e2017-11-25 15:00:50 +01001234
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001235 IPA_RSL[0].send(ts_ASP_RSL_UD(ts_RSL_CHAN_RQD('23'O, 23)));
Harald Welte930d0a72018-03-22 22:08:40 +01001236 rsl_unused := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001237 f_shutdown_helper();
Harald Welte28d943e2017-11-25 15:00:50 +01001238}
1239
Harald Welte4003d112017-12-09 22:35:39 +01001240/* verify if the "chreq:total" counter increments as expected */
1241testcase TC_chan_act_counter() runs on test_CT {
1242 var BSSAP_N_UNITDATA_ind ud_ind;
1243 var integer chreq_total;
Harald Welte930d0a72018-03-22 22:08:40 +01001244 var RSL_Message rsl_unused;
Harald Welte4003d112017-12-09 22:35:39 +01001245
Harald Welte89d42e82017-12-17 16:42:41 +01001246 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +01001247
1248 chreq_total := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total");
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001249 IPA_RSL[0].send(ts_ASP_RSL_UD(ts_RSL_CHAN_RQD('23'O, 23)));
Harald Welte930d0a72018-03-22 22:08:40 +01001250 rsl_unused := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
Harald Welte4003d112017-12-09 22:35:39 +01001251 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total", chreq_total+1);
1252
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001253 f_shutdown_helper();
Harald Welte4003d112017-12-09 22:35:39 +01001254}
1255
Harald Welteae026692017-12-09 01:03:01 +01001256/* CHAN RQD -> CHAN ACT -> CHAN ACT ACK -> RF CHAN REL */
Philipp Maier9c60a622020-07-09 15:08:46 +02001257private function f_TC_chan_act_ack_noest(OCT1 ra := '23'O) runs on test_CT {
Harald Welteae026692017-12-09 01:03:01 +01001258 var RSL_Message rx_rsl;
1259
Harald Welteae026692017-12-09 01:03:01 +01001260 /* Send CHAN RQD and wait for allocation; acknowledge it */
Philipp Maier9c60a622020-07-09 15:08:46 +02001261 var RslChannelNr chan_nr := f_chreq_act_ack(ra);
Harald Welteae026692017-12-09 01:03:01 +01001262
1263 /* expect BSC to disable the channel again if there's no RLL EST IND */
1264 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), T3101_MAX);
1265
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001266 f_shutdown_helper();
Harald Welteae026692017-12-09 01:03:01 +01001267}
1268
Philipp Maier9c60a622020-07-09 15:08:46 +02001269/* Normal variant */
1270testcase TC_chan_act_ack_noest() runs on test_CT {
Philipp Maieraf58db22020-08-12 17:24:40 +02001271 f_init(1);
Philipp Maier9c60a622020-07-09 15:08:46 +02001272 f_TC_chan_act_ack_noest();
1273}
1274
1275/* Emergency call variant */
1276testcase TC_chan_act_ack_noest_emerg() runs on test_CT {
1277 /* See also: 3GPP TS 04.08, Table 9.9, ra=101xxxxx */
Philipp Maieraf58db22020-08-12 17:24:40 +02001278 f_init(1);
1279 f_vty_allow_emerg_bts(true, 0);
Philipp Maier9c60a622020-07-09 15:08:46 +02001280 f_TC_chan_act_ack_noest(ra := 'A5'O);
1281}
1282
Philipp Maier606f07d2020-08-12 17:21:58 +02001283/* Emergency call variant, but emergency calls are not allowed */
1284testcase TC_chan_rqd_emerg_deny() runs on test_CT {
1285 /* See also: 3GPP TS 04.08, Table 9.9, ra=101xxxxx */
1286
1287 var RSL_Message rx_rsl;
1288 var GsmRrMessage rr;
1289
1290 f_init(1);
1291 f_vty_allow_emerg_bts(false, 0);
1292
1293 IPA_RSL[0].clear;
1294 f_ipa_tx(0, ts_RSL_CHAN_RQD('A5'O, 23));
1295
1296 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeC(RSL_MT_IMMEDIATE_ASSIGN_CMD));
1297 rr := dec_GsmRrMessage(rx_rsl.ies[1].body.full_imm_ass_info.payload);
1298 if (rr.header.message_type == IMMEDIATE_ASSIGNMENT_REJECT) {
1299 setverdict(pass);
1300 } else {
1301 setverdict(fail, "immediate assignment not rejected");
1302 }
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01001303
1304 f_shutdown_helper();
Philipp Maier606f07d2020-08-12 17:21:58 +02001305}
1306
Harald Welteae026692017-12-09 01:03:01 +01001307/* Test behavior if MSC never answers to CR */
1308testcase TC_chan_act_ack_est_ind_noreply() runs on test_CT {
Harald Weltef77aef62018-01-28 15:35:42 +01001309 var RslLinkId main_dcch := valueof(ts_RslLinkID_DCCH(0));
1310 var IpaStreamId sid := IPAC_PROTO_RSL_TRX0;
Harald Welteae026692017-12-09 01:03:01 +01001311 var RSL_Message rx_rsl;
Harald Weltef77aef62018-01-28 15:35:42 +01001312 var ASP_RSL_Unitdata rx_rsl_ud;
Harald Welteae026692017-12-09 01:03:01 +01001313
Harald Welte89d42e82017-12-17 16:42:41 +01001314 f_init(1);
Harald Welteae026692017-12-09 01:03:01 +01001315
1316 /* Send CHAN RQD and wait for allocation; acknowledge it */
Harald Welted6939652017-12-13 21:02:46 +01001317 var RslChannelNr chan_nr := f_chreq_act_ack();
Harald Welteae026692017-12-09 01:03:01 +01001318
1319 var octetstring l3 := '00010203040506'O
1320 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
1321
1322 BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3)));
1323
1324 /* expect BSC to disable the channel again if there's no response from MSC */
Harald Weltef77aef62018-01-28 15:35:42 +01001325 /* MS waits 20s (T3210) at LU; 10s (T3230) at CM SERV REQ and 5s (T3220) AT detach */
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001326 f_expect_chan_rel(0, chan_nr, expect_rll_rel_req := false);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001327 f_shutdown_helper();
Harald Welteae026692017-12-09 01:03:01 +01001328}
1329
1330/* Test behavior if MSC answers with CREF to CR */
1331testcase TC_chan_act_ack_est_ind_refused() runs on test_CT {
1332 var BSSAP_N_CONNECT_ind rx_c_ind;
1333 var RSL_Message rx_rsl;
1334
Harald Welte89d42e82017-12-17 16:42:41 +01001335 f_init(1);
Harald Welteae026692017-12-09 01:03:01 +01001336
1337 /* Send CHAN RQD and wait for allocation; acknowledge it */
Harald Welted6939652017-12-13 21:02:46 +01001338 var RslChannelNr chan_nr := f_chreq_act_ack();
Harald Welteae026692017-12-09 01:03:01 +01001339
1340 var octetstring l3 := '00010203040506'O
1341 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
1342
1343 BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) -> value rx_c_ind;
1344 BSSAP.send(ts_BSSAP_DISC_req(rx_c_ind.connectionId, 0));
1345
1346 /* expect BSC to disable the channel */
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001347 f_expect_chan_rel(0, chan_nr, expect_rll_rel_req := false);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001348 f_shutdown_helper();
Harald Welteae026692017-12-09 01:03:01 +01001349}
1350
Harald Welte618ef642017-12-14 14:58:20 +01001351/* CHAN RQD -> CHAN ACT -> CHAN ACT NACK -> RF CHAN REL */
1352testcase TC_chan_act_nack() runs on test_CT {
1353 var RSL_Message rx_rsl;
1354 var integer chact_nack;
1355
Harald Welte89d42e82017-12-17 16:42:41 +01001356 f_init(1);
Harald Welte618ef642017-12-14 14:58:20 +01001357
1358 chact_nack := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chan_act:nack");
1359
1360 f_ipa_tx(0, ts_RSL_CHAN_RQD('33'O, 33));
1361 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
1362 var RslChannelNr chan_nr := rx_rsl.ies[0].body.chan_nr;
1363
1364 f_ipa_tx(0, ts_RSL_CHAN_ACT_NACK(chan_nr, RSL_ERR_EQUIPMENT_FAIL));
1365
1366 /* wait for some time to hope the NACK arrives before the CTRL GET below */
1367 f_sleep(0.5);
1368
1369 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chan_act:nack", chact_nack+1);
1370
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001371 f_shutdown_helper();
Harald Welte618ef642017-12-14 14:58:20 +01001372}
1373
Harald Welte799c97b2017-12-14 17:50:30 +01001374/* Test for channel exhaustion due to RACH overload */
1375testcase TC_chan_exhaustion() runs on test_CT {
1376 var ASP_RSL_Unitdata rsl_ud;
1377 var integer i;
1378 var integer chreq_total, chreq_nochan;
1379
Harald Welte89d42e82017-12-17 16:42:41 +01001380 f_init(1);
Harald Welte799c97b2017-12-14 17:50:30 +01001381
1382 chreq_total := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total");
1383 chreq_nochan := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:no_channel");
1384
Pau Espin Pedrolfe200d72018-12-10 12:41:04 +01001385 /* GSM 04.08 Table 9.9a:
1386 * RA = '33'O -> Establishment cause = 0011xxxx (MS dual rate capable and asks for "TCH/H or TCH/F").
1387 * With current setup, expect 4xSDCCH + 4xTCH/F + 1xTCH/H to succeed */
Philipp Maiercb6cc482018-03-26 13:08:00 +02001388 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 +01001389 var RslChannelNr chan_nr := f_chreq_act_ack('33'O, i);
Harald Welte799c97b2017-12-14 17:50:30 +01001390 }
1391
1392 IPA_RSL[0].clear;
1393
Harald Weltedd8cbf32018-01-28 12:07:52 +01001394 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total",
Philipp Maiercb6cc482018-03-26 13:08:00 +02001395 chreq_total + NUM_TCHF_PER_BTS + NUM_TCHH_PER_BTS + NUM_SDCCH_PER_BTS);
Harald Welte799c97b2017-12-14 17:50:30 +01001396
1397 /* now expect additional channel activations to fail */
1398 f_ipa_tx(0, ts_RSL_CHAN_RQD('42'O, 42));
1399
1400 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001401 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV))) {
Harald Welte799c97b2017-12-14 17:50:30 +01001402 setverdict(fail, "Received CHAN ACT ACK without resources?!?");
1403 }
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001404 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_IMM_ASSIGN(?))) -> value rsl_ud {
Harald Welte799c97b2017-12-14 17:50:30 +01001405 var GsmRrMessage rr;
1406 /* match on IMM ASS REJ */
1407 rr := dec_GsmRrMessage(rsl_ud.rsl.ies[1].body.full_imm_ass_info.payload);
1408 if (rr.header.message_type == IMMEDIATE_ASSIGNMENT_REJECT) {
1409 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total",
Philipp Maiercb6cc482018-03-26 13:08:00 +02001410 chreq_total + NUM_TCHF_PER_BTS + NUM_TCHH_PER_BTS + NUM_SDCCH_PER_BTS+1);
Harald Welte799c97b2017-12-14 17:50:30 +01001411 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:no_channel",
1412 chreq_nochan+1);
1413 setverdict(pass);
1414 } else {
1415 repeat;
1416 }
1417 }
1418 [] IPA_RSL[0].receive { repeat; }
1419 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001420 f_shutdown_helper();
Harald Welte799c97b2017-12-14 17:50:30 +01001421}
1422
Vadim Yanitskiy1ff1fdf2018-11-27 01:32:57 +07001423/* Test channel deactivation due to silence from MS */
1424testcase TC_chan_deact_silence() runs on test_CT {
1425 var RslChannelNr chan_nr;
1426
1427 f_init(1);
1428
1429 /* Request for a dedicated channel */
1430 chan_nr := f_chreq_act_ack('23'O);
1431
1432 /* Wait some time until the channel is released */
1433 f_sleep(2.0);
1434
1435 /* Expect CHANnel RELease */
1436 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001437 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL))) {
Vadim Yanitskiy1ff1fdf2018-11-27 01:32:57 +07001438 log("Received CHANnel RELease");
1439 setverdict(pass);
1440 }
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001441 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_IMM_ASSIGN(?))) {
Vadim Yanitskiy1ff1fdf2018-11-27 01:32:57 +07001442 /* See OS#3709, OsmoBSC should not send Immediate
1443 * Assignment Reject since a dedicated channel was
1444 * already allocated, and Immediate Assignment was
1445 * already sent. */
1446 setverdict(fail, "Unexpected Immediate Assignment!");
1447 }
1448 [] IPA_RSL[0].receive {
1449 setverdict(fail, "Unexpected RSL message!");
1450 }
1451 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001452 f_shutdown_helper();
Vadim Yanitskiy1ff1fdf2018-11-27 01:32:57 +07001453}
1454
Harald Weltecfe2c962017-12-15 12:09:32 +01001455/***********************************************************************
1456 * Assignment Testing
1457 ***********************************************************************/
1458
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02001459/* Verify that the BSC refuses any BSSAP connection from the MSC (They are all BSC->MSC direction,
1460 * except for the inter-BSC handover, MT side) */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001461testcase TC_outbound_connect(integer bssap_idx := 0) runs on test_CT {
Harald Welte89d42e82017-12-17 16:42:41 +01001462 f_init(1);
Harald Weltecfe2c962017-12-15 12:09:32 +01001463
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001464 BSSAP.send(ts_BSSAP_CONNECT_req(g_bssap[bssap_idx].sccp_addr_peer, g_bssap[bssap_idx].sccp_addr_own,
1465 2342, ts_BSSMAP_AssignmentReq));
Harald Weltecfe2c962017-12-15 12:09:32 +01001466 BSSAP.receive(tr_BSSAP_DISC_ind(2342, ?, ?));
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001467 f_shutdown_helper();
Harald Weltecfe2c962017-12-15 12:09:32 +01001468}
1469
Harald Welte16a4adf2017-12-14 18:54:01 +01001470/* Test behavior if MSC answers with CREF to CR */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001471testcase TC_assignment_cic_only(integer bssap_idx := 0) runs on test_CT {
Harald Welte16a4adf2017-12-14 18:54:01 +01001472 var BSSAP_N_CONNECT_ind rx_c_ind;
1473 var RSL_Message rx_rsl;
1474 var DchanTuple dt;
1475
Harald Welte89d42e82017-12-17 16:42:41 +01001476 f_init(1);
Harald Welte16a4adf2017-12-14 18:54:01 +01001477
1478 dt := f_est_dchan('23'O, 23, '00000000'O);
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001479 if (mp_bssap_cfg[bssap_idx].transport == BSSAP_TRANSPORT_AoIP) {
Harald Welte17b27da2018-05-25 20:33:53 +02001480 /* send assignment without AoIP IEs */
1481 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_AssignmentReq(ts_BSSMAP_IE_CIC(0, 1))));
1482 } else {
1483 /* Send assignmetn without CIC in IPA case */
1484 var BSSMAP_IE_AoIP_TransportLayerAddress tla :=
1485 valueof(ts_BSSMAP_IE_AoIP_TLA4('01020304'O, 2342));
1486 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_AssignmentReq(omit, tla)));
1487 }
Harald Welte16a4adf2017-12-14 18:54:01 +01001488 alt {
1489 [] BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_AssignmentComplete)) {
1490 setverdict(fail, "AoIP BSC cannot accept ASSIGNMENT without AoIP Transport IE");
1491 }
Harald Welte235ebf12017-12-15 14:18:16 +01001492 /* TODO: Actually expect GSM0808_CAUSE_REQ_A_IF_TYPE_NOT_SUPP */
Harald Welte16a4adf2017-12-14 18:54:01 +01001493 [] BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_AssignmentFail)) {
1494 setverdict(pass);
1495 }
1496 [] BSSAP.receive { repeat; }
1497 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001498 f_shutdown_helper();
Harald Welte16a4adf2017-12-14 18:54:01 +01001499}
1500
Harald Welteed848512018-05-24 22:27:58 +02001501/* generate an assignment request for either AoIP or SCCPlite */
Pau Espin Pedrol07866632020-09-03 19:10:55 +02001502function 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 +02001503 var PDU_BSSAP ass_cmd;
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02001504 var BSSMAP_IE_Osmo_OsmuxCID osmux_cid := valueof(ts_OsmuxCID(0));
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001505 if (mp_bssap_cfg[bssap_idx].transport == BSSAP_TRANSPORT_AoIP) {
Harald Welteed848512018-05-24 22:27:58 +02001506 var BSSMAP_IE_AoIP_TransportLayerAddress tla :=
Pau Espin Pedrol07866632020-09-03 19:10:55 +02001507 valueof(f_ts_BSSMAP_IE_AoIP_TLA(aoip_tla, 2342));
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02001508 if (osmux_enabled) {
1509 ass_cmd := valueof(ts_BSSMAP_AssignmentReq(omit, tla, osmux_cid));
1510 } else {
1511 ass_cmd := valueof(ts_BSSMAP_AssignmentReq(omit, tla));
1512 }
Harald Welteed848512018-05-24 22:27:58 +02001513 } else {
1514 var BSSMAP_IE_CircuitIdentityCode cic := valueof(ts_BSSMAP_IE_CIC(0,1));
Pau Espin Pedrol096d73d2019-06-06 12:49:17 +02001515 ass_cmd := valueof(ts_BSSMAP_AssignmentReq(cic, omit));
Harald Welteed848512018-05-24 22:27:58 +02001516 }
1517 return ass_cmd;
1518}
1519
Pau Espin Pedrolc08d5522021-04-16 15:40:38 +02001520function f_gen_handover_req(integer bssap_idx := 0, charstring aoip_tla := "1.2.3.4",
Neels Hofmeyr8ebf19c2021-06-21 05:24:01 +02001521 template (omit) BSSMAP_oldToNewBSSIEs oldToNewBSSIEs := omit,
1522 template (omit) TestHdlrEncrParams enc := omit) return PDU_BSSAP {
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01001523 var PDU_BSSAP ho_req;
Neels Hofmeyr8ebf19c2021-06-21 05:24:01 +02001524
1525 var BSSMAP_IE_EncryptionInformation encryptionInformation :=
1526 valueof(ts_BSSMAP_IE_EncrInfo('0000000000000000'O,'01'O));
1527 var template BSSMAP_IE_ChosenEncryptionAlgorithm chosenEncryptionAlgorithm := omit;
1528 var template BSSMAP_IE_KC128 kc128 := omit;
1529 if (ispresent(enc)) {
1530 var TestHdlrEncrParams v_enc := valueof(enc);
1531 encryptionInformation := valueof(ts_BSSMAP_IE_EncrInfo(v_enc.enc_key, v_enc.enc_alg));
1532 chosenEncryptionAlgorithm := valueof(
1533 ts_BSSMAP_IE_ChosenEncryptionAlgorithm(int2oct(enum2int(
Oliver Smith598e1ed2021-07-09 10:28:40 +02001534 f_cipher_mode_bssmap_to_rsl(v_enc.enc_alg)), 1)));
Neels Hofmeyr8ebf19c2021-06-21 05:24:01 +02001535 if (ispresent(v_enc.enc_kc128)) {
1536 kc128 := ts_BSSMAP_IE_Kc128(v_enc.enc_kc128);
1537 }
1538 }
1539
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001540 if (mp_bssap_cfg[bssap_idx].transport == BSSAP_TRANSPORT_AoIP) {
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01001541 var BSSMAP_IE_AoIP_TransportLayerAddress tla :=
Pau Espin Pedrol07866632020-09-03 19:10:55 +02001542 valueof(f_ts_BSSMAP_IE_AoIP_TLA(aoip_tla, 2342));
Neels Hofmeyr8ebf19c2021-06-21 05:24:01 +02001543 ho_req := valueof(ts_BSSMAP_HandoverRequest(omit, tla, oldToNewBSSIEs := oldToNewBSSIEs,
1544 encryptionInformation := encryptionInformation,
1545 chosenEncryptionAlgorithm := chosenEncryptionAlgorithm,
1546 kC128 := kc128));
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01001547 } else {
1548 var BSSMAP_IE_CircuitIdentityCode cic := valueof(ts_BSSMAP_IE_CIC(0,1));
Neels Hofmeyr8ebf19c2021-06-21 05:24:01 +02001549 ho_req := valueof(ts_BSSMAP_HandoverRequest(cic, omit, oldToNewBSSIEs := oldToNewBSSIEs,
1550 encryptionInformation := encryptionInformation,
1551 chosenEncryptionAlgorithm := chosenEncryptionAlgorithm,
1552 kC128 := kc128));
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01001553 }
1554 return ho_req;
1555}
1556
Harald Welteed848512018-05-24 22:27:58 +02001557/* generate an assignment complete template for either AoIP or SCCPlite */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001558function f_gen_exp_compl(boolean expect_osmux := false, integer bssap_idx := 0) return template PDU_BSSAP {
Harald Welteed848512018-05-24 22:27:58 +02001559 var template PDU_BSSAP exp_compl;
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02001560 var BSSMAP_IE_Osmo_OsmuxCID osmux_cid := valueof(ts_OsmuxCID(0));
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001561 if (mp_bssap_cfg[bssap_idx].transport == BSSAP_TRANSPORT_AoIP) {
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02001562 if (expect_osmux) {
1563 exp_compl := tr_BSSMAP_AssignmentComplete(omit, ?, osmux_cid);
1564 } else {
1565 exp_compl := tr_BSSMAP_AssignmentComplete(omit, ?, omit);
1566 }
Harald Welteed848512018-05-24 22:27:58 +02001567 } else {
1568 /* CIC is optional "*" as the MSC allocated it */
Pau Espin Pedrol096d73d2019-06-06 12:49:17 +02001569 exp_compl := tr_BSSMAP_AssignmentComplete(*, omit);
Harald Welteed848512018-05-24 22:27:58 +02001570 }
1571 return exp_compl;
1572}
1573
Harald Welte235ebf12017-12-15 14:18:16 +01001574/* Run everything required up to sending a caller-specified assignment command and expect response */
1575function f_assignment_exp(PDU_BSSAP ass_cmd, template PDU_BSSAP exp, charstring fail_text)
1576runs on test_CT {
1577 var BSSAP_N_CONNECT_ind rx_c_ind;
1578 var RSL_Message rx_rsl;
1579 var DchanTuple dt;
1580
Harald Welte89d42e82017-12-17 16:42:41 +01001581 f_init(1);
Harald Welte235ebf12017-12-15 14:18:16 +01001582
1583 dt := f_est_dchan('23'O, 23, '00000000'O);
1584 /* send assignment without AoIP IEs */
1585 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ass_cmd));
1586 alt {
1587 [] BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_AssignmentComplete)) {
1588 if (ischosen(exp.pdu.bssmap.assignmentComplete)) {
1589 setverdict(pass);
1590 } else {
1591 setverdict(fail, fail_text);
1592 }
1593 }
1594 [] BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_AssignmentFail)) {
1595 if (ischosen(exp.pdu.bssmap.assignmentFailure)) {
1596 setverdict(pass);
1597 } else {
1598 setverdict(fail, fail_text);
1599 }
1600 }
1601 [] BSSAP.receive { repeat; }
1602 }
1603}
1604testcase TC_assignment_csd() runs on test_CT {
1605 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
Harald Welteed848512018-05-24 22:27:58 +02001606 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte235ebf12017-12-15 14:18:16 +01001607 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeCSD);
1608 //exp_fail.pdu.bssmap.assignmentFailure.cause.causeValue := int2bit(enum2int(GSM0808_CAUSE_REQ_CODEC_TYPE_OR_CONFIG_UNAVAIL), 7);
1609 f_assignment_exp(ass_cmd, exp_fail, "BSC accepted Assignment for CSD");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001610 f_shutdown_helper();
Harald Welte235ebf12017-12-15 14:18:16 +01001611}
1612
1613testcase TC_assignment_ctm() runs on test_CT {
1614 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
Harald Welteed848512018-05-24 22:27:58 +02001615 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte235ebf12017-12-15 14:18:16 +01001616 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeCTM);
1617 //exp_fail.pdu.bssmap.assignmentFailure.cause.causeValue := int2bit(enum2int(GSM0808_CAUSE_REQ_CODEC_TYPE_OR_CONFIG_UNAVAIL), 7);
1618 f_assignment_exp(ass_cmd, exp_fail, "BSC accepted Assignment for Speech+CTM");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001619 f_shutdown_helper();
Harald Welte235ebf12017-12-15 14:18:16 +01001620}
1621
Harald Welte4003d112017-12-09 22:35:39 +01001622type record DchanTuple {
1623 integer sccp_conn_id,
1624 RslChannelNr rsl_chan_nr
Harald Weltea5d2ab22017-12-09 14:21:42 +01001625}
1626
Harald Welted6939652017-12-13 21:02:46 +01001627/* Send CHAN RQD and wait for allocation; acknowledge it */
1628private function f_chreq_act_ack(OCT1 ra := '23'O, GsmFrameNumber fn := 23)
1629runs on test_CT return RslChannelNr {
1630 var RSL_Message rx_rsl;
1631 f_ipa_tx(0, ts_RSL_CHAN_RQD(ra, fn));
1632 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
1633 var RslChannelNr chan_nr := rx_rsl.ies[0].body.chan_nr;
1634 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, fn+10));
Daniel Willmannf4ac4ce2018-08-02 14:06:30 +02001635 rx_rsl := f_exp_ipa_rx(0, tr_RSL_IMM_ASSIGN(0));
Harald Welted6939652017-12-13 21:02:46 +01001636 return chan_nr;
1637}
1638
Harald Welte4003d112017-12-09 22:35:39 +01001639/* helper function to establish a dedicated channel via BTS and MSC */
1640function f_est_dchan(OCT1 ra, GsmFrameNumber fn, octetstring l3)
1641runs on test_CT return DchanTuple {
1642 var BSSAP_N_CONNECT_ind rx_c_ind;
Harald Welte4003d112017-12-09 22:35:39 +01001643 var DchanTuple dt;
Harald Weltea5d2ab22017-12-09 14:21:42 +01001644
Harald Welte4003d112017-12-09 22:35:39 +01001645 /* Send CHAN RQD and wait for allocation; acknowledge it */
Harald Welted6939652017-12-13 21:02:46 +01001646 dt.rsl_chan_nr := f_chreq_act_ack(ra, fn);
Harald Welte4003d112017-12-09 22:35:39 +01001647
1648 f_ipa_tx(0, ts_RSL_EST_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
1649
1650 BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) -> value rx_c_ind;
1651 dt.sccp_conn_id := rx_c_ind.connectionId;
1652 BSSAP.send(ts_BSSAP_CONNECT_res(dt.sccp_conn_id));
1653
1654 return dt;
Harald Weltea5d2ab22017-12-09 14:21:42 +01001655}
1656
Harald Welte641fcbe2018-06-14 10:58:35 +02001657/* expect RF CAN REL from BTS, acknowledge it and clear the MSC side */
1658private function f_exp_chan_rel_and_clear(DchanTuple dt, integer bts_nr := 0) runs on test_CT {
1659 var RSL_Message rx_rsl;
1660 /* expect BSC to disable the channel */
1661 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), T3101_MAX);
1662 /* respond with CHAN REL ACK */
1663 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(dt.rsl_chan_nr));
1664
1665 /* expect Clear Complete from BSC */
1666 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete));
1667
1668 /* MSC disconnects as instructed. */
1669 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
1670}
1671
Harald Welte4003d112017-12-09 22:35:39 +01001672/* Test behavior of channel release after unilateral RLL REL IND (DISC from MS) */
1673testcase TC_chan_rel_rll_rel_ind() runs on test_CT {
Neels Hofmeyr27f64362018-03-12 01:44:00 +01001674 var BSSAP_N_DATA_ind rx_di;
Harald Welte4003d112017-12-09 22:35:39 +01001675 var DchanTuple dt;
Harald Welte96c94412017-12-09 03:12:45 +01001676
Harald Welte89d42e82017-12-17 16:42:41 +01001677 f_init(1);
Harald Welte96c94412017-12-09 03:12:45 +01001678
Harald Welte4003d112017-12-09 22:35:39 +01001679 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1680
1681 /* simulate RLL REL IND */
1682 f_ipa_tx(0, ts_RSL_REL_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0))));
1683
Neels Hofmeyr27f64362018-03-12 01:44:00 +01001684 /* expect Clear Request on MSC side */
1685 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearRequest)) -> value rx_di;
1686
1687 /* Instruct BSC to clear channel */
1688 var BssmapCause cause := bit2int(rx_di.userData.pdu.bssmap.clearRequest.cause.causeValue);
1689 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
1690
Harald Welte4003d112017-12-09 22:35:39 +01001691 /* expect BSC to disable the channel */
Harald Welte641fcbe2018-06-14 10:58:35 +02001692 f_exp_chan_rel_and_clear(dt, 0);
Neels Hofmeyr27f64362018-03-12 01:44:00 +01001693
1694 /* wait for SCCP emulation to do its job */
1695 f_sleep(1.0);
Harald Welte4003d112017-12-09 22:35:39 +01001696
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001697 f_shutdown_helper();
Harald Welte4003d112017-12-09 22:35:39 +01001698}
1699
1700/* Test behavior of channel release after CONN FAIL IND from BTS */
1701testcase TC_chan_rel_conn_fail() runs on test_CT {
1702 var BSSAP_N_DATA_ind rx_di;
Harald Welte4003d112017-12-09 22:35:39 +01001703 var DchanTuple dt;
1704
Harald Welte89d42e82017-12-17 16:42:41 +01001705 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +01001706
1707 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1708
1709 /* simulate CONN FAIL IND */
Harald Weltea8ed9062017-12-14 09:46:01 +01001710 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 +01001711 /* TODO: different cause values? */
1712
Harald Welte4003d112017-12-09 22:35:39 +01001713 /* expect Clear Request from BSC */
1714 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearRequest)) -> value rx_di;
1715
1716 /* Instruct BSC to clear channel */
1717 var BssmapCause cause := bit2int(rx_di.userData.pdu.bssmap.clearRequest.cause.causeValue);
1718 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
1719
Harald Welte6ff76ea2018-01-28 13:08:01 +01001720 /* expect BSC to disable the channel */
Harald Welte641fcbe2018-06-14 10:58:35 +02001721 f_exp_chan_rel_and_clear(dt, 0);
Harald Welte4003d112017-12-09 22:35:39 +01001722
1723 /* wait for SCCP emulation to do its job */
1724 f_sleep(1.0);
1725
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001726 f_shutdown_helper();
Harald Welte4003d112017-12-09 22:35:39 +01001727}
1728
Harald Welte99f3ca02018-06-14 13:40:29 +02001729/* Test behavior of early CONN FAIL IND from BTS (before EST IND!) */
1730/* See also https://www.osmocom.org/issues/3182 */
1731testcase TC_early_conn_fail() runs on test_CT {
1732 var RSL_Message rx_rsl;
1733 var DchanTuple dt;
1734
1735 f_init(1);
1736
1737 /* BTS->BSC: Send CHAN RQD and wait for allocation; acknowledge it */
Harald Weltec46ea3c2020-10-10 18:46:12 +02001738 dt.rsl_chan_nr := f_chreq_act_ack(f_rnd_ra_cs(), 23);
Harald Welte99f3ca02018-06-14 13:40:29 +02001739
1740 /* BTS->BSC: simulate CONN FAIL IND */
1741 f_ipa_tx(0, ts_RSL_CONN_FAIL_IND(dt.rsl_chan_nr, RSL_ERR_RADIO_LINK_FAIL));
1742
1743 /* BTS->BSC: Expect RF channel release from BSC on Abis */
1744 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), 10.0);
1745
1746 /* BTS<-BSC: respond with CHAN REL ACK */
1747 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(dt.rsl_chan_nr));
1748
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001749 f_shutdown_helper();
Harald Welte99f3ca02018-06-14 13:40:29 +02001750}
1751
1752/* Test behavior of late CONN FAIL IND from BTS (ater REL IND!) */
1753/* See also https://www.osmocom.org/issues/3182 */
1754testcase TC_late_conn_fail() runs on test_CT {
1755 var RSL_Message rx_rsl;
1756 var DchanTuple dt;
1757
1758 f_init(1);
1759
1760 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1761
1762 /* BSC<-MSC: Instruct BSC to clear connection */
1763 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(0)));
1764
1765 /* BTS->BSC: expect BSC to deactivate SACCH */
1766 rx_rsl := f_exp_ipa_rx(0, tr_RSL_DEACT_SACCH(dt.rsl_chan_nr));
1767
1768 /* BTS->BSC: simulate a late CONN FAIL IND from BTS */
1769 f_ipa_tx(0, ts_RSL_CONN_FAIL_IND(dt.rsl_chan_nr, RSL_ERR_RADIO_LINK_FAIL));
1770
1771 /* BTS<-BSC: Expect RF channel release from BSC on Abis */
1772 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), 10.0);
1773 /* BTS->BSC: respond with CHAN REL ACK */
1774 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(dt.rsl_chan_nr));
1775
1776 /* BSC->MSC: expect Clear Complete from BSC */
1777 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete));
1778
1779 /* BSC<-MSC: MSC disconnects as requested. */
1780 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
1781
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001782 f_shutdown_helper();
Harald Welte99f3ca02018-06-14 13:40:29 +02001783}
1784
Oliver Smithaf03bef2021-08-24 15:34:51 +02001785private function f_TC_stats_conn_fail(charstring id) runs on MSC_ConnHdlr {
1786 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
1787 var PDU_BSSAP ass_cmd := f_gen_ass_req();
1788
1789 f_statsd_reset();
1790
1791 /* Establish SDCCH */
1792 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeCSD);
1793 f_establish_fully(ass_cmd, exp_fail);
1794
1795 /* Expect stats to be 0 */
1796 var StatsDExpects expect := {
1797 {name := "TTCN3.bts.0.chan.rf_fail", mtype := "c", min := 0, max := 0},
1798 {name := "TTCN3.bts.0.chan.rf_fail_sdcch", mtype := "c", min := 0, max := 0}
1799 };
1800 f_statsd_expect(expect);
1801
1802 /* Simulate CONN FAIL IND on SDCCH */
1803 RSL.send(ts_ASP_RSL_UD(
1804 ts_RSL_CONN_FAIL_IND(g_chan_nr, RSL_ERR_RADIO_LINK_FAIL),
1805 IPAC_PROTO_RSL_TRX0));
1806
Neels Hofmeyr58be48a2021-09-07 18:39:21 +02001807 f_sleep(1.0);
1808
Oliver Smithaf03bef2021-08-24 15:34:51 +02001809 /* Expect stats to be 1 */
1810 expect := {
1811 {name := "TTCN3.bts.0.chan.rf_fail", mtype := "c", min := 1, max := 1},
1812 {name := "TTCN3.bts.0.chan.rf_fail_sdcch", mtype := "c", min := 1, max := 1}
1813 };
1814 f_statsd_expect(expect);
1815}
1816testcase TC_stats_conn_fail() runs on test_CT {
1817 var TestHdlrParams pars := f_gen_test_hdlr_pars();
1818 var MSC_ConnHdlr vc_conn;
1819
1820 f_init(1, true);
1821 f_sleep(1.0);
1822
1823 vc_conn := f_start_handler(refers(f_TC_stats_conn_fail), pars);
1824 vc_conn.done;
1825
1826 f_shutdown_helper();
1827}
1828
Neels Hofmeyrf44ccd12018-11-05 19:15:23 +01001829function f_expect_chan_rel(integer bts_nr, RslChannelNr rsl_chan_nr,
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001830 boolean expect_deact_sacch := true,
1831 boolean expect_rr_chan_rel := true,
1832 boolean expect_rll_rel_req := true,
Harald Welte99787102019-02-04 10:41:36 +01001833 boolean handle_rll_rel := true,
Pau Espin Pedrol36bd4fa2021-04-15 13:00:24 +02001834 template CellSelIndValue expect_cells := omit,
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02001835 template RR_Cause expect_rr_cause := ?
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001836 ) runs on test_CT {
Harald Welte91d54a52018-01-28 15:35:07 +01001837
1838 var RslLinkId main_dcch := valueof(ts_RslLinkID_DCCH(0));
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001839 var boolean got_deact_sacch := false;
1840 var boolean got_rr_chan_rel := false;
1841 var boolean got_rll_rel_req := false;
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02001842 var ASP_RSL_Unitdata ud;
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02001843 var RSL_IE_Body l3_ie;
1844 var PDU_ML3_NW_MS l3;
1845 var RR_Cause got_cause;
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001846 log("f_expect_chan_rel() expecting: expect_deact_sacch=", expect_deact_sacch, " expect_rr_chan_rel=", expect_rr_chan_rel,
1847 " expect_rll_rel_req=", expect_rll_rel_req);
Harald Welte91d54a52018-01-28 15:35:07 +01001848 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001849 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(tr_RSL_DEACT_SACCH(rsl_chan_nr))) {
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001850 got_deact_sacch := true;
Harald Welte91d54a52018-01-28 15:35:07 +01001851 repeat;
1852 }
Pau Espin Pedrol841b90d2021-04-15 16:42:52 +02001853 [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 +01001854 got_rr_chan_rel := true;
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02001855
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02001856 if (f_rsl_find_ie(ud.rsl, RSL_IE_L3_INFO, l3_ie) == false) {
1857 setverdict(fail, "cannot find L3");
1858 mtc.stop;
1859 }
1860 l3 := dec_PDU_ML3_NW_MS(l3_ie.l3_info.payload);
1861
Pau Espin Pedrol36bd4fa2021-04-15 13:00:24 +02001862 if (not istemplatekind(expect_cells, "omit")) {
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02001863 var CellSelIndValue cells := dec_CellSelIndValue(
1864 l3.msgs.rrm.channelRelease.cellSelectionIndicator.cellSelectionIndicatorValue);
1865
Pau Espin Pedrol36bd4fa2021-04-15 13:00:24 +02001866 log("GOT RR CHANNEL RELEASE WITH CELLS: ", cells);
1867 if (match(cells, expect_cells)) {
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02001868 setverdict(pass);
1869 } else {
Pau Espin Pedrol36bd4fa2021-04-15 13:00:24 +02001870 log("EXPECTED CELLS: ", expect_cells);
1871 setverdict(fail, "Received cells list on RR Channel Release does not match expectations");
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02001872 }
1873 }
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02001874
1875 if (not istemplatekind(expect_rr_cause, "omit")) {
1876 int2enum(oct2int(l3.msgs.rrm.channelRelease.rRCause.valuePart), got_cause);
1877 log("GOT CAUSE CODE: ", l3.msgs.rrm.channelRelease.rRCause.valuePart, " = ", got_cause);
1878 if (match(got_cause, expect_rr_cause)) {
1879 setverdict(pass);
1880 } else {
1881 log("EXPECTED CAUSE CODE: ", expect_rr_cause);
1882 setverdict(fail, "Received RR Channel Release Cause code does not match expectations");
1883 }
1884 }
Harald Welte99787102019-02-04 10:41:36 +01001885 repeat;
1886 }
Pau Espin Pedrol841b90d2021-04-15 16:42:52 +02001887 [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 +01001888 got_rr_chan_rel := true;
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02001889
1890 if (not istemplatekind(expect_rr_cause, "omit")) {
1891 if (f_rsl_find_ie(ud.rsl, RSL_IE_L3_INFO, l3_ie) == false) {
1892 setverdict(fail, "cannot find L3");
1893 mtc.stop;
1894 }
1895 l3 := dec_PDU_ML3_NW_MS(l3_ie.l3_info.payload);
1896
1897 int2enum(oct2int(l3.msgs.rrm.channelRelease.rRCause.valuePart), got_cause);
1898 log("GOT CAUSE CODE: ", l3.msgs.rrm.channelRelease.rRCause.valuePart, " = ", got_cause);
1899 if (match(got_cause, expect_rr_cause)) {
1900 setverdict(pass);
1901 } else {
1902 log("EXPECTED CAUSE CODE: ", expect_rr_cause);
1903 setverdict(fail, "Received RR Channel Release Cause code does not match expectations");
1904 }
1905 }
Neels Hofmeyr211169d2018-11-07 00:37:29 +01001906 repeat;
1907 }
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001908 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(tr_RSL_REL_REQ(rsl_chan_nr, ?))) {
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001909 got_rll_rel_req := true;
Harald Welte91d54a52018-01-28 15:35:07 +01001910 /* FIXME: Why are we getting this for LinkID SACCH? */
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001911 if (handle_rll_rel) {
1912 f_ipa_tx(0, ts_RSL_REL_CONF(rsl_chan_nr, main_dcch));
1913 }
Harald Welte91d54a52018-01-28 15:35:07 +01001914 repeat;
1915 }
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001916 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL))) {
Harald Welte91d54a52018-01-28 15:35:07 +01001917 /* respond with CHAN REL ACK */
1918 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(rsl_chan_nr));
1919 }
1920 /* ignore any user data */
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001921 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(tr_RSL_MsgTypeR(?))) {
Harald Welte91d54a52018-01-28 15:35:07 +01001922 repeat;
1923 }
1924 }
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001925
1926 log("f_expect_chan_rel() summary: got_deact_sacch=", got_deact_sacch, " got_rr_chan_rel=", got_rr_chan_rel,
1927 " got_rll_rel_req=", got_rll_rel_req);
1928
1929 if (expect_deact_sacch != got_deact_sacch) {
1930 setverdict(fail, "f_expect_chan_rel(): expect_deact_sacch=", expect_deact_sacch, " got_deact_sacch=", got_deact_sacch);
1931 }
1932 if (expect_rr_chan_rel != got_rr_chan_rel) {
1933 setverdict(fail, "f_expect_chan_rel(): expect_rr_chan_rel=", expect_rr_chan_rel, " got_rr_chan_rel=", got_rr_chan_rel);
1934 }
1935 if (expect_rll_rel_req != got_rll_rel_req) {
1936 setverdict(fail, "f_expect_chan_rel(): expect_rll_rel_req=", expect_rll_rel_req, " got_rll_rel_req=", got_rll_rel_req);
1937 }
Harald Welte91d54a52018-01-28 15:35:07 +01001938}
1939
Harald Welte4003d112017-12-09 22:35:39 +01001940/* Test behavior of channel release after hard Clear Command from MSC */
1941testcase TC_chan_rel_hard_clear() runs on test_CT {
1942 var BSSAP_N_DATA_ind rx_di;
Harald Welte4003d112017-12-09 22:35:39 +01001943 var DchanTuple dt;
Harald Welte4003d112017-12-09 22:35:39 +01001944
Harald Welte89d42e82017-12-17 16:42:41 +01001945 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +01001946
1947 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1948
1949 /* Instruct BSC to clear channel */
1950 var BssmapCause cause := 0;
1951 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
1952
1953 /* expect Clear Complete from BSC on A */
1954 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete)) {
1955 /* release the SCCP connection */
1956 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
1957 }
1958
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001959 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001960 f_shutdown_helper();
Harald Welte4003d112017-12-09 22:35:39 +01001961}
1962
Pau Espin Pedrol841b90d2021-04-15 16:42:52 +02001963function f_TC_chan_rel_last_eutran_plmn_hard_clear(boolean tx_csfb_ind) runs on test_CT {
1964 var BSSAP_N_DATA_ind rx_di;
1965 var DchanTuple dt;
1966
1967 f_init(1);
1968
1969 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1970 /* Send CommonID with some random PLMN (BSC doesn't take it into account
1971 /* yet when generating the EUTRAN neigh list in RR CHannel Release) */
1972 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_CommonId('001019876543210'H, '323454'O)));
1973
1974 /* Instruct BSC to clear channel */
1975 var BssmapCause cause := 0;
1976 if (tx_csfb_ind) {
1977 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommandCSFB(cause)));
1978 } else {
1979 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
1980 }
1981
1982 /* expect Clear Complete from BSC on A */
1983 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete)) {
1984 /* release the SCCP connection */
1985 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
1986 }
1987
1988 /* 1 neighbor is added by default in osmo-bts.cfg and
1989 SystemInformationConfig_default, use that: */
1990 var template CellSelIndValue exp_cells := f_tr_rr_chan_rel_earfcns(1);
1991
1992 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false, expect_cells := exp_cells);
1993 f_shutdown_helper();
1994}
1995
1996/* Test behavior of RR Channel rRelease after Clear Command without CSFB indicator
1997 from MSC, previously receiving any CommonID containing the "Last Used E-UTRAN
1998 PLMN Id". According to spec (3GPP TS 48.008 sec 3.1.30) that's the bit requesting
1999 EUTRAN neighbor list sent later on by BSC in RR Channel, so receiving CSFB
2000 Indicator or not shouldn't matter at all. */
2001testcase TC_chan_rel_last_eutran_plmn_hard_clear_no_csfb() runs on test_CT {
2002 f_TC_chan_rel_last_eutran_plmn_hard_clear(false);
2003}
2004
2005/* Test behavior of RR Channel rRelease after Clear Command with CSFB indicator from
2006 MSC, previously receiving any CommonID containing the "Last Used E-UTRAN PLMN
2007 Id". According to spec (3GPP TS 48.008 sec 3.1.30) that's the bit requesting
2008 EUTRAN neighbor list sent later on by BSC in RR Channel. */
2009testcase TC_chan_rel_last_eutran_plmn_hard_clear_csfb() runs on test_CT {
2010 f_TC_chan_rel_last_eutran_plmn_hard_clear(true);
2011}
2012
2013/* Test behavior of RR Channel Release after Clear Command with CSFB indicator from
2014 MSC, without receiving any CommonID containing the "Last Used E-UTRAN PLMN
2015 Id". According to spec (TS 48.008 version 16.0.0 Release 16 "3.2.1.21") the
2016 CSFB Indicator should not be used anymore, and hence, there should be no
2017 EUTRAN neighbor list sent by BSC in RR Channel release since no CommonId with
2018 Last Used E-UTRAN PLMN Id" IE was sent for this conn. */
Harald Welte99787102019-02-04 10:41:36 +01002019testcase TC_chan_rel_hard_clear_csfb() runs on test_CT {
2020 var BSSAP_N_DATA_ind rx_di;
2021 var DchanTuple dt;
2022
2023 f_init(1);
2024
2025 dt := f_est_dchan('23'O, 23, '00010203040506'O);
2026
2027 /* Instruct BSC to clear channel */
2028 var BssmapCause cause := 0;
2029 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommandCSFB(cause)));
2030
2031 /* expect Clear Complete from BSC on A */
2032 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete)) {
2033 /* release the SCCP connection */
2034 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
2035 }
2036
Pau Espin Pedrol841b90d2021-04-15 16:42:52 +02002037 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002038 f_shutdown_helper();
Harald Welte99787102019-02-04 10:41:36 +01002039}
2040
Harald Welted8c36cd2017-12-09 23:05:31 +01002041/* Test behavior of channel release after hard RLSD from MSC */
2042testcase TC_chan_rel_hard_rlsd() runs on test_CT {
Harald Welted8c36cd2017-12-09 23:05:31 +01002043 var DchanTuple dt;
Harald Welted8c36cd2017-12-09 23:05:31 +01002044
Harald Welte89d42e82017-12-17 16:42:41 +01002045 f_init(1);
Harald Welted8c36cd2017-12-09 23:05:31 +01002046
2047 dt := f_est_dchan('23'O, 23, '00010203040506'O);
2048
2049 /* release the SCCP connection */
2050 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
2051
Neels Hofmeyra5302c82018-11-04 23:09:58 +01002052 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002053 f_shutdown_helper();
Harald Welted8c36cd2017-12-09 23:05:31 +01002054}
2055
Harald Welte550daf92018-06-11 19:22:13 +02002056/* Test behavior of channel release after hard RLSD from MSC and MS is not responding to RLL REL REQ */
2057testcase TC_chan_rel_hard_rlsd_ms_dead() runs on test_CT {
2058 var DchanTuple dt;
2059
2060 f_init(1);
2061
2062 dt := f_est_dchan('23'O, 23, '00010203040506'O);
2063
2064 /* release the SCCP connection */
2065 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
2066
Neels Hofmeyra5302c82018-11-04 23:09:58 +01002067 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002068 f_shutdown_helper();
Harald Welte550daf92018-06-11 19:22:13 +02002069}
2070
Harald Welte85804d42017-12-10 14:11:58 +01002071/* Test behavior of channel release after BSSMAP RESET from MSC */
2072testcase TC_chan_rel_a_reset() runs on test_CT {
Harald Welte85804d42017-12-10 14:11:58 +01002073 var DchanTuple dt;
Harald Welte85804d42017-12-10 14:11:58 +01002074
Harald Welte89d42e82017-12-17 16:42:41 +01002075 f_init(1);
Harald Welte85804d42017-12-10 14:11:58 +01002076
2077 dt := f_est_dchan('23'O, 23, '00010203040506'O);
2078
2079 /* Clear the queue, it might still contain stuff like IMMEDIATE ASSIGN */
2080 IPA_RSL[0].clear;
2081
2082 /* perform BSSAP RESET, expect RESET ACK and DISC.ind on connection */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02002083 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 +01002084 interleave {
Neels Hofmeyrf246a922020-05-13 02:27:10 +02002085 [] 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 +01002086 [] BSSAP.receive(tr_BSSAP_DISC_ind(dt.sccp_conn_id, ?, ?)) { }
2087 }
2088
Neels Hofmeyra5302c82018-11-04 23:09:58 +01002089 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002090 f_shutdown_helper();
Harald Welte85804d42017-12-10 14:11:58 +01002091}
2092
Pau Espin Pedrolc675b612020-01-09 19:55:40 +01002093/* Verify T(iar) triggers and releases the channel */
2094testcase TC_chan_rel_sccp_tiar_timeout() runs on test_CT {
2095 var DchanTuple dt;
2096
2097 /* Set T(iar) in BSC low enough that it will trigger before other side
2098 has time to keep alive with a T(ias). Keep recommended ratio of
2099 T(iar) >= T(ias)*2 */
2100 g_bsc_sccp_timer_ias := 2;
2101 g_bsc_sccp_timer_iar := 5;
2102
2103 f_init(1);
2104
2105 dt := f_est_dchan('23'O, 23, '00010203040506'O);
2106 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002107 f_shutdown_helper();
Pau Espin Pedrolc675b612020-01-09 19:55:40 +01002108}
2109
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02002110private function f_tc_chan_rel_rr_cause(myBSSMAP_Cause clear_cmd_cause, template RR_Cause expect_rr_cause)
2111runs on test_CT
2112{
2113 var DchanTuple dt;
2114
2115 dt := f_est_dchan('23'O, 23, '00010203040506'O);
2116 var BssmapCause cause := 0;
2117 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(enum2int(clear_cmd_cause))));
2118 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete)) {
2119 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
2120 }
2121
2122 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 +02002123}
2124
2125/* Test that Clear Command cause codes affect the RR Channel Release cause code */
2126testcase TC_chan_rel_rr_cause() runs on test_CT {
2127 f_init(1);
2128
2129 f_tc_chan_rel_rr_cause(GSM0808_CAUSE_CALL_CONTROL, GSM48_RR_CAUSE_NORMAL);
2130 f_tc_chan_rel_rr_cause(GSM0808_CAUSE_HANDOVER_SUCCESSFUL, GSM48_RR_CAUSE_NORMAL);
2131 f_tc_chan_rel_rr_cause(GSM0808_CAUSE_PREEMPTION, GSM48_RR_CAUSE_PREMPTIVE_REL);
2132 f_tc_chan_rel_rr_cause(GSM0808_CAUSE_RADIO_INTERFACE_MESSAGE_FAILURE, GSM48_RR_CAUSE_PROT_ERROR_UNSPC);
2133 f_tc_chan_rel_rr_cause(GSM0808_CAUSE_RADIO_INTERFACE_FAILURE, GSM48_RR_CAUSE_ABNORMAL_UNSPEC);
2134 f_tc_chan_rel_rr_cause(GSM0808_CAUSE_EQUIPMENT_FAILURE, GSM48_RR_CAUSE_ABNORMAL_UNSPEC);
Vadim Yanitskiye18aebb2021-01-03 13:10:43 +01002135
2136 f_shutdown_helper();
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02002137}
2138
Harald Welte5cd20ed2017-12-13 21:03:20 +01002139/* Test behavior if RSL EST IND for non-active channel */
2140testcase TC_rll_est_ind_inact_lchan() runs on test_CT {
2141 timer T := 2.0;
2142
Harald Welte89d42e82017-12-17 16:42:41 +01002143 f_init(1);
Harald Welte5cd20ed2017-12-13 21:03:20 +01002144
2145 var octetstring l3 := '00010203040506'O;
2146 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(6));
2147 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
2148
2149 T.start;
2150 alt {
2151 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) {
2152 setverdict(fail, "MSC received COMPL L3 for non-active lchan");
2153 }
2154 [] BSSAP.receive {}
2155 [] IPA_RSL[0].receive {}
2156 [] T.timeout {}
2157 }
2158
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002159 f_shutdown_helper();
Harald Welte5cd20ed2017-12-13 21:03:20 +01002160}
2161
2162/* Test behavior if RSL EST IND for invalid SAPI */
2163testcase TC_rll_est_ind_inval_sapi1() runs on test_CT {
2164 var RslChannelNr chan_nr;
2165
Harald Welte89d42e82017-12-17 16:42:41 +01002166 f_init(1);
Harald Welte5cd20ed2017-12-13 21:03:20 +01002167
2168 chan_nr := f_chreq_act_ack()
2169
2170 var octetstring l3 := '00010203040506'O;
2171 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(1)), l3));
2172
2173 timer T := 2.0;
2174 T.start;
2175 alt {
2176 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) {
2177 setverdict(fail, "MSC received COMPL L3 for invalid SAPI 1");
2178 }
2179 [] BSSAP.receive { repeat; }
2180 [] IPA_RSL[0].receive { repeat; }
2181 [] T.timeout {}
2182 }
2183
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002184 f_shutdown_helper();
Harald Welte5cd20ed2017-12-13 21:03:20 +01002185}
2186
2187/* Test behavior if RSL EST IND for invalid SAPI */
2188testcase TC_rll_est_ind_inval_sapi3() runs on test_CT {
2189 timer T := 2.0;
2190
Harald Welte89d42e82017-12-17 16:42:41 +01002191 f_init(1);
Harald Welte5cd20ed2017-12-13 21:03:20 +01002192
2193 var RslChannelNr chan_nr := f_chreq_act_ack();
2194
2195 var octetstring l3 := '00010203040506'O;
2196 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(3)), l3));
2197
2198 T.start;
2199 alt {
2200 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) {
2201 setverdict(fail, "MSC received COMPL L3 for invalid SAPI 3");
2202 }
2203 [] BSSAP.receive { repeat; }
2204 [] IPA_RSL[0].receive { repeat; }
2205 [] T.timeout {}
2206 }
2207
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002208 f_shutdown_helper();
Harald Welte5cd20ed2017-12-13 21:03:20 +01002209}
2210
2211/* Test behavior if RSL EST IND for invalid SACCH */
2212testcase TC_rll_est_ind_inval_sacch() runs on test_CT {
2213 timer T := 2.0;
2214
Harald Welte89d42e82017-12-17 16:42:41 +01002215 f_init(1);
Harald Welte5cd20ed2017-12-13 21:03:20 +01002216
2217 var RslChannelNr chan_nr := f_chreq_act_ack();
2218
2219 var octetstring l3 := '00010203040506'O;
2220 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_SACCH(0)), l3));
2221
2222 T.start;
2223 alt {
2224 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) {
2225 setverdict(fail, "MSC received COMPL L3 for invalid Link SACCH");
2226 }
2227 [] BSSAP.receive { repeat; }
2228 [] IPA_RSL[0].receive { repeat; }
2229 [] T.timeout {}
2230 }
2231
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002232 f_shutdown_helper();
Harald Welte5cd20ed2017-12-13 21:03:20 +01002233}
2234
Vadim Yanitskiy61f784a2020-10-01 21:12:19 +07002235/* Verify DLCI / RSL Link ID conversion for MO/MT messages on SAPI0/SAPI3 */
2236private function f_TC_tch_dlci_link_id_sapi(charstring id) runs on MSC_ConnHdlr {
2237 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
2238 var PDU_BSSAP ass_cmd := f_gen_ass_req();
2239
2240 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
2241 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
2242
2243 f_establish_fully(ass_cmd, exp_compl);
2244
2245 /* SAPI0 has already been established by f_establish_fully(), establish SAPI3 */
2246 RSL.send(ts_RSL_EST_IND(g_chan_nr, ts_RslLinkID_SACCH(3), '0904'O));
2247 /* Expect BSSAP/DTAP on SAPI3 (DLCI IE) */
2248 BSSAP.receive(PDU_BSSAP:{
2249 discriminator := '1'B,
2250 spare := '0000000'B,
2251 dlci := 'C3'O,
2252 lengthIndicator := ?,
2253 pdu := { dtap := '0904'O }
2254 });
2255
2256 /* Send messages on DCCH/SAPI0 and ACCH/SAPI3 */
2257 for (var integer i := 0; i < 32; i := i + 1) {
2258 var octetstring l3 := '09'O & f_rnd_octstring(14);
2259 var template (value) RslLinkId link_id;
2260 var template (value) OCT1 dlci;
2261
2262 if (i mod 2 == 0) {
2263 /* SAPI0 on FACCH or SDCCH */
2264 link_id := ts_RslLinkID_DCCH(0);
2265 dlci := '80'O;
2266 } else {
2267 /* SAPI3 on SACCH */
2268 link_id := ts_RslLinkID_SACCH(3);
2269 dlci := 'C3'O;
2270 }
2271
2272 /* Send MO message: RSL -> BSSAP */
Neels Hofmeyr0aa719b2020-10-12 18:43:09 +00002273 f_mo_l3_transceive(RSL, link_id, dlci, l3);
Vadim Yanitskiy61f784a2020-10-01 21:12:19 +07002274 /* Send MT message: BSSAP -> RSL */
Neels Hofmeyr0aa719b2020-10-12 18:43:09 +00002275 f_mt_l3_transceive(RSL, link_id, dlci, l3);
Vadim Yanitskiy61f784a2020-10-01 21:12:19 +07002276 }
2277}
2278testcase TC_tch_dlci_link_id_sapi() runs on test_CT {
2279 var TestHdlrParams pars := f_gen_test_hdlr_pars();
2280 var MSC_ConnHdlr vc_conn;
2281
2282 f_init(1, true);
2283 f_sleep(1.0);
2284
2285 vc_conn := f_start_handler(refers(f_TC_tch_dlci_link_id_sapi), pars);
2286 vc_conn.done;
2287
2288 f_shutdown_helper();
2289}
2290
Vadim Yanitskiy6ef5dfa2020-08-28 18:04:41 +07002291private function f_exp_sapi_n_reject(template (present) GsmSapi sapi := ?,
2292 template myBSSMAP_Cause cause := ?,
2293 float T_val := 2.0)
2294runs on test_CT {
2295 var BSSAP_N_DATA_ind rx_di;
2296 timer T;
2297
2298 var template BSSMAP_IE_Cause tr_cause := tr_BSSMAP_IE_Cause(cause);
2299 var template PDU_BSSAP tr_pdu := tr_BSSMAP_SAPInReject(sapi);
2300
2301 T.start(T_val);
2302 alt {
2303 [] BSSAP.receive(tr_BSSAP_DATA_ind(?, tr_pdu)) -> value rx_di {
2304 var BSSMAP_IE_Cause rx_cause := rx_di.userData.pdu.bssmap.sAPInReject.cause;
2305 if (not match(rx_cause, tr_cause)) {
2306 setverdict(fail, "Rx unexpected Cause IE: ",
2307 rx_cause, " vs expected ", tr_cause);
2308 }
2309 setverdict(pass);
2310 }
2311 [] BSSAP.receive(BSSAP_N_DATA_ind:?) -> value rx_di {
2312 setverdict(fail, "Rx unexpected BSSAP PDU: ", rx_di);
2313 }
2314 [] T.timeout {
2315 setverdict(fail, "Timeout waiting for BSSMAP SAPI N Reject");
2316 }
2317 }
2318}
2319
2320/* Check if we get SAPI N Reject on receipt of unexpected RLL RELease INDication */
2321testcase TC_rll_rel_ind_sapi_n_reject() runs on test_CT {
2322 var octetstring rnd_data := f_rnd_octstring(16);
2323 var RSL_Message rx_rsl;
2324 var DchanTuple dt;
2325
2326 f_init(1);
2327
2328 /* MS establishes a SAPI=0 link on DCCH */
2329 dt := f_est_dchan(f_rnd_ra_cs(), 23, rnd_data);
2330
2331 /* MSC sends some data on (not yet established) SAPI=3 link */
2332 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSAP_DTAP(rnd_data, '03'O)));
2333 /* BSC attempts to establish a SAPI=3 link on DCCH */
2334 rx_rsl := f_exp_ipa_rx(0, tr_RSL_EST_REQ(dt.rsl_chan_nr, tr_RslLinkID_DCCH(3)));
2335
2336 /* MS sends unexpected RELease INDication on SAPI=3 */
2337 f_ipa_tx(0, ts_RSL_REL_IND(dt.rsl_chan_nr, ts_RslLinkID_DCCH(3)));
2338 /* We expect to receive BSSMAP SAPI N Reject message from the BSC */
2339 f_exp_sapi_n_reject(3, GSM0808_CAUSE_MS_NOT_EQUIPPED);
2340
2341 /* Clean up the connection */
2342 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
2343 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
2344
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002345 f_shutdown_helper();
Vadim Yanitskiy6ef5dfa2020-08-28 18:04:41 +07002346}
2347
2348/* Check if we get SAPI N Reject on receipt of unexpected RLL ERROR INDication */
2349testcase TC_rll_err_ind_sapi_n_reject() runs on test_CT {
2350 var octetstring rnd_data := f_rnd_octstring(16);
2351 var RSL_Message rx_rsl;
2352 var DchanTuple dt;
2353
2354 f_init(1);
2355
2356 /* MS establishes a SAPI=0 link on DCCH */
2357 dt := f_est_dchan(f_rnd_ra_cs(), 23, rnd_data);
2358
2359 /* MSC sends some data on (not yet established) SAPI=3 link */
2360 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSAP_DTAP(rnd_data, '03'O)));
2361 /* BSC attempts to establish a SAPI=3 link on DCCH */
2362 rx_rsl := f_exp_ipa_rx(0, tr_RSL_EST_REQ(dt.rsl_chan_nr, tr_RslLinkID_DCCH(3)));
2363
2364 /* BTS sends unexpected ERROR INDication on SAPI=3 */
2365 f_ipa_tx(0, ts_RSL_ERROR_IND(dt.rsl_chan_nr, ts_RslLinkID_DCCH(3), ''O));
2366 /* We expect to receive BSSMAP SAPI N Reject message from the BSC */
2367 f_exp_sapi_n_reject(3, GSM0808_CAUSE_BSS_NOT_EQUIPPED);
2368
2369 /* Clean up the connection */
2370 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
2371 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
2372
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002373 f_shutdown_helper();
Vadim Yanitskiy6ef5dfa2020-08-28 18:04:41 +07002374}
2375
2376/* Check if we get SAPI N Reject due to a SAPI=3 link establishment timeout */
2377testcase TC_rll_timeout_sapi_n_reject() runs on test_CT {
2378 var octetstring rnd_data := f_rnd_octstring(16);
2379 var RSL_Message rx_rsl;
2380 var DchanTuple dt;
2381
2382 f_init(1);
2383
2384 /* MS establishes a SAPI=0 link on DCCH */
2385 dt := f_est_dchan(f_rnd_ra_cs(), 23, rnd_data);
2386
2387 /* MSC sends some data on (not yet established) SAPI=3 link */
2388 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSAP_DTAP(rnd_data, '03'O)));
2389 /* BSC attempts to establish a SAPI=3 link on DCCH */
2390 rx_rsl := f_exp_ipa_rx(0, tr_RSL_EST_REQ(dt.rsl_chan_nr, tr_RslLinkID_DCCH(3)));
2391
2392 /* MS does not respond, so the link establishment timeout triggers SAPI N Reject */
2393 f_exp_sapi_n_reject(3, GSM0808_CAUSE_BSS_NOT_EQUIPPED, T_val := 8.0);
2394
2395 /* Clean up the connection */
2396 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
2397 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
2398
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002399 f_shutdown_helper();
Vadim Yanitskiy6ef5dfa2020-08-28 18:04:41 +07002400}
2401
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +02002402testcase TC_si_default() runs on test_CT {
2403 f_init(0);
2404 f_init_bts_and_check_sysinfo(0, expect_si := SystemInformationConfig_default);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002405 f_shutdown_helper();
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +02002406}
Harald Welte4003d112017-12-09 22:35:39 +01002407
Neels Hofmeyr56f24782020-07-09 00:50:49 +02002408/* We're testing SI2quater with lists of EARFCNs. Instead of just incrementing EARFCNs, also pick some from the edges of
2409 * the entire value range. This function provides the same EARFCN numbers for the same earfcn_index */
2410private function f_test_si2quater_earfcn_by_idx(integer earfcn_index) return uint16_t
2411{
2412 select (earfcn_index) {
2413 case (0) {
2414 /* E-ARFCN 111 is already added in the osmo-bsc.cfg */
2415 return 111;
2416 }
2417 case (1) {
2418 return 1;
2419 }
2420 case (2) {
2421 return 0;
2422 }
2423 case (3) {
2424 return 65535;
2425 }
2426 case else {
2427 return 23 * (earfcn_index - 3);
2428 }
2429 }
2430}
2431
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02002432function f_test_si2quater(integer total_earfcns, template SystemInformationConfig expect_si,
2433 template CellSelIndValue expect_cells := omit) runs on test_CT {
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002434
2435 f_init(0);
2436
2437 /* E-ARFCN 111 is already added in the osmo-bsc.cfg, so only add more arfcns if total_earfcns > 1 */
2438 for (var integer i := 1; i < total_earfcns; i := i + 1) {
Neels Hofmeyr56f24782020-07-09 00:50:49 +02002439 f_bts_0_cfg(BSCVTY, {"si2quater neighbor-list add earfcn " & int2str(f_test_si2quater_earfcn_by_idx(i))
2440 & " thresh-hi 20 thresh-lo 10 prio 3 qrxlv 22 meas 3"});
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002441 }
2442
2443 f_init_bts_and_check_sysinfo(0, expect_si := expect_si);
2444
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02002445 if (not istemplatekind(expect_cells, "omit")) {
2446 /* Also check that RR Channel Release contains these EARFCNs.
2447 * (copied code from TC_chan_rel_hard_clear_csfb) */
2448 var BSSAP_N_DATA_ind rx_di;
2449 var DchanTuple dt;
2450
2451 dt := f_est_dchan('23'O, 23, '00010203040506'O);
Pau Espin Pedrold0046312021-04-19 16:35:58 +02002452 /* Send CommonID with some random PLMN (BSC doesn't take it into account
2453 * yet when generating the EUTRAN neigh list in RR CHannel Release) */
2454 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_CommonId('001019876543210'H, '323454'O)));
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02002455
2456 /* Instruct BSC to clear channel */
2457 var BssmapCause cause := 0;
2458 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommandCSFB(cause)));
2459
2460 /* expect Clear Complete from BSC on A */
2461 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete)) {
2462 /* release the SCCP connection */
2463 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
2464 }
2465
Pau Espin Pedrol841b90d2021-04-15 16:42:52 +02002466 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 +02002467 }
2468
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002469 for (var integer i := 1; i < total_earfcns; i := i + 1) {
Neels Hofmeyr56f24782020-07-09 00:50:49 +02002470 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 +02002471 }
2472}
2473
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002474private function f_tr_si2quater_earfcns(integer count) return template SI2quaterRestOctetsList
2475{
2476 var template SI2quaterRestOctetsList si2quater := {};
2477 var integer si2quater_count := (count + 2) / 3;
2478
2479 for (var integer i := 0; i < count; i := i + 1) {
Neels Hofmeyr56f24782020-07-09 00:50:49 +02002480 var integer earfcn := f_test_si2quater_earfcn_by_idx(i);
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002481 var integer index := i / 3;
2482 var integer earfcn_index := i mod 3;
2483 if (index >= lengthof(si2quater)) {
2484 si2quater[index] := tr_SI2quaterRestOctets_EUTRAN(index := index, count := si2quater_count - 1);
2485 }
2486 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);
2487 }
2488
2489 return si2quater;
2490}
2491
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02002492private function f_tr_rr_chan_rel_earfcns(integer count) return template CellSelIndValue
2493{
2494 var template CellSelIndValue_EUTRAN_Descrs cells := {};
2495
Alexander Couzensf74b5cb2020-09-10 22:28:40 +02002496 /* the lte neighbors must match the config & vty to pass this test */
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02002497 for (var integer i := 0; i < count; i := i + 1) {
2498 var integer earfcn := f_test_si2quater_earfcn_by_idx(i);
Alexander Couzensf74b5cb2020-09-10 22:28:40 +02002499 cells[i] := tr_CellSelIndValue_EUTRAN_Descr(earfcn, '1'B, 3);
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02002500 }
2501
2502 return tr_CellSelIndValue_EUTRAN(cells);
2503}
2504
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002505private function f_tc_si2quater_n_earfcns(integer n) runs on test_CT
2506{
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002507 var template SystemInformationConfig sic := SystemInformationConfig_default;
Pau Espin Pedrol8ab62e42020-12-18 16:19:11 +01002508 sic.si2quater := f_tr_si2quater_earfcns(n);
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02002509 var template CellSelIndValue cells := f_tr_rr_chan_rel_earfcns(n);
2510 f_test_si2quater(n, sic, cells);
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002511}
2512
2513testcase TC_si2quater_2_earfcns() runs on test_CT {
2514 f_tc_si2quater_n_earfcns(2);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002515 f_shutdown_helper();
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002516}
2517
2518testcase TC_si2quater_3_earfcns() runs on test_CT {
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002519 f_tc_si2quater_n_earfcns(3);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002520 f_shutdown_helper();
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002521}
2522
2523testcase TC_si2quater_4_earfcns() runs on test_CT {
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002524 f_tc_si2quater_n_earfcns(4);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002525 f_shutdown_helper();
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002526}
2527
2528testcase TC_si2quater_5_earfcns() runs on test_CT {
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002529 f_tc_si2quater_n_earfcns(5);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002530 f_shutdown_helper();
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002531}
2532
2533testcase TC_si2quater_6_earfcns() runs on test_CT {
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002534 f_tc_si2quater_n_earfcns(6);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002535 f_shutdown_helper();
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002536}
2537
2538testcase TC_si2quater_12_earfcns() runs on test_CT {
2539 f_tc_si2quater_n_earfcns(12);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002540 f_shutdown_helper();
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002541}
2542
2543testcase TC_si2quater_23_earfcns() runs on test_CT {
2544 f_tc_si2quater_n_earfcns(23);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002545 f_shutdown_helper();
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002546}
2547
2548testcase TC_si2quater_32_earfcns() runs on test_CT {
2549 f_tc_si2quater_n_earfcns(32);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002550 f_shutdown_helper();
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002551}
2552
2553testcase TC_si2quater_33_earfcns() runs on test_CT {
2554 f_tc_si2quater_n_earfcns(33);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002555 f_shutdown_helper();
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002556}
2557
2558testcase TC_si2quater_42_earfcns() runs on test_CT {
2559 f_tc_si2quater_n_earfcns(42);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002560 f_shutdown_helper();
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002561}
2562
2563testcase TC_si2quater_48_earfcns() runs on test_CT {
2564 f_tc_si2quater_n_earfcns(48);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002565 f_shutdown_helper();
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002566}
2567
2568/* verify the VTY error response when adding too many EARFCNs, and showing that osmo-bsc still sends 16 SI2quater with
2569 * 48 EARFCNs. */
2570testcase TC_si2quater_49_earfcns() runs on test_CT {
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002571 var template SystemInformationConfig sic := SystemInformationConfig_default;
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002572 sic.si2quater := f_tr_si2quater_earfcns(48); /* 48, not 49! */
2573 f_init(0);
2574
2575 for (var integer i := 1; i < 48; i := i + 1) {
Neels Hofmeyr56f24782020-07-09 00:50:49 +02002576 f_bts_0_cfg(BSCVTY, {"si2quater neighbor-list add earfcn " & int2str(f_test_si2quater_earfcn_by_idx(i))
2577 & " thresh-hi 20 thresh-lo 10 prio 3 qrxlv 22 meas 3"});
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002578 }
2579
2580 /* The 49th EARFCN no longer fits, expect VTY error */
2581 f_vty_enter_cfg_bts(BSCVTY, 0);
2582 var charstring vty_error;
2583 vty_error := f_vty_transceive_ret(BSCVTY,
2584 "si2quater neighbor-list add earfcn 70 thresh-hi 20 thresh-lo 10 prio 3 qrxlv 22 meas 3")
2585 f_vty_transceive(BSCVTY, "end");
2586
2587 if (f_strstr(vty_error, "Unable to add ARFCN 70") >= 0) {
2588 log("Got expected VTY error: ", vty_error);
2589 setverdict(pass);
2590 } else {
2591 setverdict(fail, "Expected the 49th EUTRAN ARFCN to be rejected by vty config, got: ", vty_error);
2592 }
2593
2594 f_init_bts_and_check_sysinfo(0, expect_si := sic);
2595
2596 for (var integer i := 1; i < 48; i := i + 1) {
Neels Hofmeyr56f24782020-07-09 00:50:49 +02002597 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 +02002598 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002599 f_shutdown_helper();
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002600}
2601
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02002602private function f_acc09_count_allowed(AccessControlClass acc) return uint8_t
2603{
2604 var uint8_t count := 0;
2605 for (var integer i := 5; i < 16; i := i + 1) {
2606 if (acc[i] == '0'B) { /* the list marks barred, we count allowed */
2607 count := count + 1;
2608 }
2609 }
2610 return count;
2611}
2612
Pau Espin Pedrolc6136cd2020-07-24 13:20:02 +02002613private function f_recv_next_si1(integer rsl_idx := 0) runs on test_CT return SystemInformationType1
2614{
2615 var ASP_RSL_Unitdata rx_rsl_ud;
2616 var SystemInformationType1 last_si1;
2617
2618 timer T := 30.0;
2619 T.start;
2620 alt {
2621 [] IPA_RSL[rsl_idx].receive(tr_ASP_RSL_UD((tr_RSL_NO_BCCH_INFO,
2622 tr_RSL_BCCH_INFO,
2623 tr_RSL_NO_SACCH_FILL,
2624 tr_RSL_SACCH_FILL))
2625 ) -> value rx_rsl_ud {
2626 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
2627 if (g_system_information[rsl_idx].si1 == omit) {
2628 repeat;
2629 }
2630 last_si1 := g_system_information[rsl_idx].si1;
2631 g_system_information[rsl_idx].si1 := omit;
2632 T.stop;
2633 }
Vadim Yanitskiy79ebd5e2021-01-04 00:12:55 +01002634 [] IPA_RSL[rsl_idx].receive { repeat; }
Pau Espin Pedrolc6136cd2020-07-24 13:20:02 +02002635 [] T.timeout { setverdict(fail, "Timeout receiving next SI1"); }
2636 }
2637 return last_si1;
2638}
2639
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02002640/* verify ACC rotate feature */
2641testcase TC_si_acc_rotate() runs on test_CT {
2642 var template SystemInformationConfig sic := SystemInformationConfig_default;
Pau Espin Pedrolc6136cd2020-07-24 13:20:02 +02002643 var SystemInformationType1 last_si1;
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02002644 var AccessControlClass acc;
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02002645 var uint8_t count;
2646 var integer times_allowed[10] := { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
2647
2648 f_init(0, guard_timeout := 60.0);
2649
2650 f_bts_0_cfg(BSCVTY, {"rach access-control-class 5 barred",
2651 "access-control-class-rotate 3",
2652 "access-control-class-rotate-quantum 1"});
2653
2654 /* Init and get first sysinfo */
2655 f_init_bts_and_check_sysinfo(0, expect_si := ?);
2656
Pau Espin Pedrolc6136cd2020-07-24 13:20:02 +02002657 for (var integer i:= 0; i < 20; i := i + 1) {
2658 last_si1 := f_recv_next_si1(0);
2659 acc := last_si1.rach_control.acc;
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02002660 count := f_acc09_count_allowed(acc);
2661 log("RSL: GOT SI1 ACC len=", count, ": ", acc);
2662
2663 if (count != 3) {
2664 log("RSL: EXPECTED SI ACC len=3");
2665 setverdict(fail, "received SI does not match expectations");
2666 break;
2667 }
2668
2669 for (var integer j := 0; j < 10; j := j + 1) {
2670 if (acc[16 - 1 - j] == '0'B) { /* the list marks barred, we count allowed */
2671 times_allowed[j] := times_allowed[j] + 1;
2672 }
2673 }
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02002674 }
2675
2676 for (var integer j := 0; j < 10; j := j + 1) {
2677 log("ACC", j, " allowed ", times_allowed[j], " times" );
2678 if (j != 5 and times_allowed[j] < 3) {
2679 setverdict(fail, "ACC", j, " ERROR: allowed ", times_allowed[j], " < 1 times");
2680 } else if (j == 5 and times_allowed[j] > 0) {
2681 setverdict(fail, "ACC", j, " ERROR: allowed ", times_allowed[j], " > 0 times");
2682 }
2683 }
2684
2685 f_bts_0_cfg(BSCVTY, {"access-control-class-rotate 10",
2686 "rach access-control-class 5 allowed"});
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002687 f_shutdown_helper();
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02002688}
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002689
Pau Espin Pedrolc6136cd2020-07-24 13:20:02 +02002690/* verify ACC startup ramp+rotate feature */
2691testcase TC_si_acc_ramp_rotate() runs on test_CT {
2692 var template SystemInformationConfig sic := SystemInformationConfig_default;
2693 var SystemInformationType1 last_si1;
2694 var AccessControlClass acc;
2695 var ASP_RSL_Unitdata rx_rsl_ud;
2696 var uint8_t count;
2697 var uint8_t prev_count;
2698 var integer times_allowed[10] := { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
2699
2700 f_init(0, guard_timeout := 80.0);
2701
2702 f_bts_0_cfg(BSCVTY, {"rach access-control-class 4 barred",
2703 "access-control-class-rotate 0",
2704 "access-control-class-rotate-quantum 1",
2705 "access-control-class-ramping",
2706 "access-control-class-ramping-step-interval 5",
2707 "access-control-class-ramping-step-size 5"});
2708
2709 /* Init and get first sysinfo */
2710 f_init_bts_and_check_sysinfo(0, expect_si := ?);
2711 last_si1 := g_system_information[0].si1;
2712 acc := last_si1.rach_control.acc;
2713 count := f_acc09_count_allowed(acc);
2714 /* Adm subset size was set to 0 above, so wait until all ACC are barred */
2715 while (count > 0) {
2716 last_si1 := f_recv_next_si1(0);
2717 acc := last_si1.rach_control.acc;
2718 count := f_acc09_count_allowed(acc);
2719 log("RSL: wait len()=0: GOT SI1 ACC len=", count, ": ", acc);
2720 }
2721
2722 /* Increase adm subset size, we should see ramping start up */
2723 f_bts_0_cfg(BSCVTY, {"access-control-class-rotate 10"});
2724 prev_count := 0;
2725 while (true) {
2726 last_si1 := f_recv_next_si1(0);
2727 acc := last_si1.rach_control.acc;
2728 count := f_acc09_count_allowed(acc);
2729 log("RSL: GOT SI1 ACC len=", count, ": ", acc);
2730
2731 if (prev_count > count) {
2732 setverdict(fail, "ACC allowed count dropped while expecting grow: ", prev_count, " -> ", count);
2733 break;
2734 }
2735
2736 if (count == 9) {
2737 break; /* Maximum reached (10 - 1 perm barred), done here */
2738 }
2739
2740 prev_count := count;
2741 }
2742
2743 setverdict(pass);
2744
2745 f_bts_0_cfg(BSCVTY, {"access-control-class-rotate 10",
2746 "rach access-control-class 4 allowed",
2747 "no access-control-class-ramping"});
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002748 f_shutdown_helper();
Pau Espin Pedrolc6136cd2020-07-24 13:20:02 +02002749}
2750
Harald Welte4003d112017-12-09 22:35:39 +01002751testcase TC_ctrl_msc_connection_status() runs on test_CT {
2752 var charstring ctrl_resp;
2753
Harald Welte89d42e82017-12-17 16:42:41 +01002754 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +01002755
2756 /* See https://osmocom.org/issues/2729 */
2757 f_ctrl_get_exp(IPA_CTRL, "msc_connection_status", "connected");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002758 f_shutdown_helper();
Harald Welte4003d112017-12-09 22:35:39 +01002759}
2760
Stefan Sperlingb041b3d2018-01-03 17:14:55 +01002761testcase TC_ctrl_msc0_connection_status() runs on test_CT {
2762 var charstring ctrl_resp;
2763
2764 f_init(1);
Stefan Sperlingb041b3d2018-01-03 17:14:55 +01002765
2766 f_ctrl_get_exp(IPA_CTRL, "msc.0.connection_status", "connected");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002767 f_shutdown_helper();
Stefan Sperlingb041b3d2018-01-03 17:14:55 +01002768}
2769
Harald Welte4003d112017-12-09 22:35:39 +01002770testcase TC_ctrl() runs on test_CT {
2771 var charstring ctrl_resp;
2772
Harald Welte89d42e82017-12-17 16:42:41 +01002773 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +01002774
2775 /* all below values must match the osmo-bsc.cfg config file used */
2776
Harald Welte6a129692018-03-17 17:30:14 +01002777 f_ctrl_get_exp(IPA_CTRL, "mcc", "001");
2778 f_ctrl_get_exp(IPA_CTRL, "mnc", "01");
Oliver Smith75aa0202019-08-19 14:17:50 +02002779 f_ctrl_get_exp(IPA_CTRL, "number-of-bts", "4");
Harald Welte4003d112017-12-09 22:35:39 +01002780
2781 var integer bts_nr := 0;
2782 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "location-area-code", "1");
2783 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "cell-identity", "0");
2784 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "oml-connection-state", "connected");
2785 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "gprs-mode", "gprs");
2786 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "rf_state", "operational,unlocked,on");
2787 f_ctrl_get_exp_trx(IPA_CTRL, bts_nr, 0, "arfcn", "871");
2788 f_ctrl_get_exp_trx(IPA_CTRL, bts_nr, 0, "max-power-reduction", "20");
2789
2790 var integer uptime := str2int(f_ctrl_get_bts(IPA_CTRL, bts_nr, "oml-uptime"));
2791 f_sleep(2.0);
2792 if (str2int(f_ctrl_get_bts(IPA_CTRL, bts_nr, "oml-uptime")) < uptime+1) {
2793 setverdict(fail, "oml-uptime not incrementing as expected");
2794 }
2795 /* TODO: Disconnect RSL, imply that OML is disconnected and check for uptime zero? */
2796
2797 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bsc", 0, "paging:attempted", 0);
2798
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002799 f_shutdown_helper();
Harald Welte96c94412017-12-09 03:12:45 +01002800}
2801
Pau Espin Pedrol5a2d7432019-06-07 19:43:45 +02002802/* Verify that Upon receival of SET "location", BSC forwards a TRAP
2803 "location-state" over the SCCPlite IPA conn */
2804testcase TC_ctrl_location() runs on test_CT {
2805 var MSC_ConnHdlr vc_conn;
2806 var integer bts_nr := 0;
2807
2808 f_init(1, true);
2809 f_sleep(1.0);
2810
2811 f_ctrl_set_bts(IPA_CTRL, bts_nr, "location", "1234567,fix3d,0.340000,0.560000,0.780000");
2812 f_ctrl_exp_trap(SCCPLITE_IPA_CTRL, "bts." & int2str(bts_nr) & ".location-state",
2813 "1234567,fix3d,0.340000,0.560000,0.780000,operational,unlocked,on,001,01");
2814
2815 f_ctrl_set(SCCPLITE_IPA_CTRL, "rf_locked", "1");
2816 f_sleep(2.0);
2817
2818 f_ctrl_set_bts(IPA_CTRL, bts_nr, "location", "1234888,fix3d,0.350000,0.570000,0.790000");
2819 f_ctrl_exp_trap(SCCPLITE_IPA_CTRL, "bts." & int2str(bts_nr) & ".location-state",
2820 "1234888,fix3d,0.350000,0.570000,0.790000,operational,locked,off,001,01");
2821
2822 /* should match the one from config */
2823 f_ctrl_set(SCCPLITE_IPA_CTRL, "rf_locked", "0");
2824
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002825 f_shutdown_helper();
Pau Espin Pedrol5a2d7432019-06-07 19:43:45 +02002826}
2827
Harald Welte6f521d82017-12-11 19:52:02 +01002828
2829/***********************************************************************
2830 * Paging Testing
2831 ***********************************************************************/
2832
2833type record Cell_Identity {
2834 GsmMcc mcc,
2835 GsmMnc mnc,
2836 GsmLac lac,
2837 GsmCellId ci
2838};
Harald Welte24135bd2018-03-17 19:27:53 +01002839private const Cell_Identity cid := { '001'H, '01'H, 1, 0 };
Stefan Sperling049a86e2018-03-20 15:51:00 +01002840private const Cell_Identity unknown_cid := { '678'H, 'f90'H, 1, 0 };
Harald Welte6f521d82017-12-11 19:52:02 +01002841
Harald Welte5d1a2202017-12-13 19:51:29 +01002842type set of integer BtsIdList;
2843
2844private function f_bts_in_list(integer bts_id, BtsIdList bts_ids) return boolean {
2845 for (var integer j := 0; j < sizeof(bts_ids); j := j + 1) {
2846 if (bts_id == bts_ids[j]) {
2847 return true;
2848 }
2849 }
2850 return false;
2851}
Harald Welte6f521d82017-12-11 19:52:02 +01002852
2853/* core paging test helper function; used by most paging test cases */
2854private function f_pageing_helper(hexstring imsi,
2855 template BSSMAP_FIELD_CellIdentificationList cid_list,
Harald Welte5d1a2202017-12-13 19:51:29 +01002856 BtsIdList bts_ids := { 0 },
Harald Welte6f521d82017-12-11 19:52:02 +01002857 template RSL_ChanNeeded rsl_chneed := omit,
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07002858 template (omit) OCT4 tmsi := omit) runs on test_CT
Harald Welte6f521d82017-12-11 19:52:02 +01002859{
2860 var template BSSMAP_IE_ChannelNeeded bssmap_chneed;
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07002861 var template MobileIdentityV mi;
Harald Welte6f521d82017-12-11 19:52:02 +01002862 var RSL_Message rx_rsl;
2863 var integer paging_group := hex2int(imsi[lengthof(imsi)-1]);
Harald Welte5d1a2202017-12-13 19:51:29 +01002864 var integer i;
Harald Welte6f521d82017-12-11 19:52:02 +01002865
2866 f_init();
Harald Welte6f521d82017-12-11 19:52:02 +01002867
2868 /* Clear the queue, it might still contain stuff like BCCH FILLING */
Harald Weltec3068592018-03-17 19:55:31 +01002869 for (i := 0; i < NUM_BTS; i := i + 1) {
2870 IPA_RSL[i].clear;
Harald Welte5d1a2202017-12-13 19:51:29 +01002871 }
Harald Welte6f521d82017-12-11 19:52:02 +01002872
2873 if (isvalue(rsl_chneed)) {
2874 /* The values of 08.08 3.2.2.36 and 08.58 9.3.40 are luckily identical */
2875 bssmap_chneed := ts_BSSMAP_IE_ChanNeeded(int2bit(enum2int(valueof(rsl_chneed)),2));
2876 } else {
2877 bssmap_chneed := omit;
2878 }
2879
Neels Hofmeyrf246a922020-05-13 02:27:10 +02002880 BSSAP.send(ts_BSSAP_UNITDATA_req(g_bssap[0].sccp_addr_peer, g_bssap[0].sccp_addr_own,
2881 ts_BSSMAP_Paging(imsi, cid_list, tmsi, bssmap_chneed)));
Harald Welte6f521d82017-12-11 19:52:02 +01002882
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07002883 if (not istemplatekind(tmsi, "omit")) {
2884 mi := t_MI_TMSI(tmsi);
Harald Welte6f521d82017-12-11 19:52:02 +01002885 } else {
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07002886 mi := tr_MI_IMSI(imsi);
Harald Welte6f521d82017-12-11 19:52:02 +01002887 }
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07002888
Harald Welte5d1a2202017-12-13 19:51:29 +01002889 for (i := 0; i < sizeof(bts_ids); i := i + 1) {
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07002890 rx_rsl := f_exp_ipa_rx(bts_ids[i], tr_RSL_PAGING_CMD(mi));
Harald Welte5d1a2202017-12-13 19:51:29 +01002891 /* check channel type, paging group */
2892 if (rx_rsl.ies[1].body.paging_group != paging_group) {
2893 setverdict(fail, "Paging for wrong paging group");
2894 }
2895 if (ispresent(rsl_chneed) and
2896 rx_rsl.ies[3].body.chan_needed.chan_needed != valueof(rsl_chneed)) {
2897 setverdict(fail, "RSL Channel Needed != BSSMAP Channel Needed");
2898 }
Harald Welte6f521d82017-12-11 19:52:02 +01002899 }
Harald Welte2fccd982018-01-31 15:48:19 +01002900 f_sleep(2.0);
Harald Welte5d1a2202017-12-13 19:51:29 +01002901 /* do a quick check on all not-included BTSs if they received paging */
2902 for (i := 0; i < NUM_BTS; i := i + 1) {
2903 timer T := 0.1;
2904 if (f_bts_in_list(i, bts_ids)) {
2905 continue;
2906 }
2907 T.start;
2908 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07002909 [] IPA_RSL[i].receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD(mi))) {
Harald Welte5d1a2202017-12-13 19:51:29 +01002910 setverdict(fail, "Paging on BTS ", i, " which is not part of ", bts_ids);
2911 }
2912 [] IPA_RSL[i].receive { repeat; }
2913 [] T.timeout { }
2914 }
Harald Welte6f521d82017-12-11 19:52:02 +01002915 }
2916
2917 setverdict(pass);
2918}
2919
Harald Welte5d1a2202017-12-13 19:51:29 +01002920const BtsIdList c_BtsId_all := { 0, 1, 2 };
Harald Welte751d3eb2018-01-31 15:51:06 +01002921const BtsIdList c_BtsId_none := { };
Harald Welte5d1a2202017-12-13 19:51:29 +01002922const BtsIdList c_BtsId_LAC1 := { 0, 1 };
2923const BtsIdList c_BtsId_LAC2 := { 2 };
2924
Harald Welte6f521d82017-12-11 19:52:02 +01002925/* PAGING by IMSI + TMSI */
2926testcase TC_paging_imsi_nochan() runs on test_CT {
2927 var BSSMAP_FIELD_CellIdentificationList cid_list;
2928 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Philipp Maier8c04b0a2018-02-23 13:48:48 +01002929 f_pageing_helper('001010100000001'H, cid_list, c_BtsId_all, omit, omit);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002930 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002931}
2932
2933/* PAGING by IMSI + TMSI */
2934testcase TC_paging_tmsi_nochan() runs on test_CT {
2935 var BSSMAP_FIELD_CellIdentificationList cid_list;
2936 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01002937 f_pageing_helper('001010100000001'H, cid_list, c_BtsId_all, omit, 'A1B2C301'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002938 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002939}
2940
2941/* Paging with different "channel needed' values */
2942testcase TC_paging_tmsi_any() runs on test_CT {
2943 var BSSMAP_FIELD_CellIdentificationList cid_list;
2944 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01002945 f_pageing_helper('001010100000002'H, cid_list, c_BtsId_all, RSL_CHANNEED_ANY, 'A1B2C302'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002946 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002947}
2948testcase TC_paging_tmsi_sdcch() runs on test_CT {
2949 var BSSMAP_FIELD_CellIdentificationList cid_list;
2950 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01002951 f_pageing_helper('001010100000003'H, cid_list, c_BtsId_all, RSL_CHANNEED_SDCCH, 'A1B2C303'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002952 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002953}
2954testcase TC_paging_tmsi_tch_f() runs on test_CT {
2955 var BSSMAP_FIELD_CellIdentificationList cid_list;
2956 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01002957 f_pageing_helper('001010000000004'H, cid_list, c_BtsId_all, RSL_CHANNEED_TCH_F, 'A1B2C304'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002958 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002959}
2960testcase TC_paging_tmsi_tch_hf() runs on test_CT {
2961 var BSSMAP_FIELD_CellIdentificationList cid_list;
2962 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01002963 f_pageing_helper('001010000000005'H, cid_list, c_BtsId_all, RSL_CHANNEED_TCH_ForH, 'A1B2C305'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002964 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002965}
2966
2967/* Paging by CGI */
2968testcase TC_paging_imsi_nochan_cgi() runs on test_CT {
2969 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2970 cid_list := { cIl_CGI := { ts_BSSMAP_CI_CGI(cid.mcc, cid.mnc, cid.lac, cid.ci) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01002971 f_pageing_helper('001010000000006'H, cid_list, { 0 });
Philipp Maier282ca4b2018-02-27 17:17:00 +01002972 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002973}
2974
2975/* Paging by LAC+CI */
2976testcase TC_paging_imsi_nochan_lac_ci() runs on test_CT {
2977 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2978 cid_list := { cIl_LAC_CI := { ts_BSSMAP_CI_LAC_CI(cid.lac, cid.ci) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01002979 f_pageing_helper('001010000000007'H, cid_list, { 0 });
Philipp Maier282ca4b2018-02-27 17:17:00 +01002980 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002981}
2982
2983/* Paging by CI */
2984testcase TC_paging_imsi_nochan_ci() runs on test_CT {
2985 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2986 cid_list := { cIl_CI := { ts_BSSMAP_CI_CI(cid.ci) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01002987 f_pageing_helper('001010000000008'H, cid_list, { 0 });
Philipp Maier282ca4b2018-02-27 17:17:00 +01002988 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002989}
2990
2991/* Paging by LAI */
2992testcase TC_paging_imsi_nochan_lai() runs on test_CT {
2993 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2994 cid_list := { cIl_LAI := { ts_BSSMAP_CI_LAI(cid.mcc, cid.mnc, cid.lac) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01002995 f_pageing_helper('001010000000009'H, cid_list, c_BtsId_LAC1);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002996 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002997}
2998
2999/* Paging by LAC */
3000testcase TC_paging_imsi_nochan_lac() runs on test_CT {
3001 var template BSSMAP_FIELD_CellIdentificationList cid_list;
3002 cid_list := { cIl_LAC := { ts_BSSMAP_CI_LAC(cid.lac) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01003003 f_pageing_helper('001010000000010'H, cid_list, c_BtsId_LAC1);
Philipp Maier282ca4b2018-02-27 17:17:00 +01003004 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01003005}
3006
3007/* Paging by "all in BSS" */
3008testcase TC_paging_imsi_nochan_all() runs on test_CT {
3009 var template BSSMAP_FIELD_CellIdentificationList cid_list;
3010 cid_list := { cIl_allInBSS := ''O };
Harald Welte5d1a2202017-12-13 19:51:29 +01003011 f_pageing_helper('001010000000011'H, cid_list, c_BtsId_all);
Philipp Maier282ca4b2018-02-27 17:17:00 +01003012 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01003013}
3014
Stefan Sperling7b5e1782018-03-20 19:32:43 +01003015/* Paging by PLMN+LAC+RNC; We do not implement this; Verify nothing is paged */
Harald Welte751d3eb2018-01-31 15:51:06 +01003016testcase TC_paging_imsi_nochan_plmn_lac_rnc() runs on test_CT {
3017 var template BSSMAP_FIELD_CellIdentificationList cid_list;
3018 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 +01003019 f_pageing_helper('001010000000012'H, cid_list, c_BtsId_none);
Philipp Maier282ca4b2018-02-27 17:17:00 +01003020 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01003021}
Harald Welte6f521d82017-12-11 19:52:02 +01003022
Stefan Sperling7b5e1782018-03-20 19:32:43 +01003023/* Paging by RNC; We do not implement this; Verify nothing is paged */
Harald Welte751d3eb2018-01-31 15:51:06 +01003024testcase TC_paging_imsi_nochan_rnc() runs on test_CT {
3025 var template BSSMAP_FIELD_CellIdentificationList cid_list;
3026 cid_list := { cIl_RNC := { int2oct(13, 2) } };
Stefan Sperling7b5e1782018-03-20 19:32:43 +01003027 f_pageing_helper('001010000000013'H, cid_list, c_BtsId_none);
Philipp Maier282ca4b2018-02-27 17:17:00 +01003028 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01003029}
3030
Stefan Sperling7b5e1782018-03-20 19:32:43 +01003031/* Paging by LAC+RNC; We do not implement; Verify nothing is paged */
Harald Welte751d3eb2018-01-31 15:51:06 +01003032testcase TC_paging_imsi_nochan_lac_rnc() runs on test_CT {
3033 var template BSSMAP_FIELD_CellIdentificationList cid_list;
3034 cid_list := { cIl_LAC_RNC := { ts_BSSMAP_CI_LAC_RNC(cid.lac, 14) } };
Stefan Sperling7b5e1782018-03-20 19:32:43 +01003035 f_pageing_helper('001010000000014'H, cid_list, c_BtsId_none);
Philipp Maier282ca4b2018-02-27 17:17:00 +01003036 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01003037}
3038
Harald Welte6f521d82017-12-11 19:52:02 +01003039/* Paging on multiple cells (multiple entries in list): Verify all of them page */
Harald Welte751d3eb2018-01-31 15:51:06 +01003040testcase TC_paging_imsi_nochan_lacs() runs on test_CT {
3041 var template BSSMAP_FIELD_CellIdentificationList cid_list;
3042 cid_list := { cIl_LAC := { ts_BSSMAP_CI_LAC(1), ts_BSSMAP_CI_LAC(2) } };
3043 f_pageing_helper('001010000000015'H, cid_list, c_BtsId_all);
Philipp Maier282ca4b2018-02-27 17:17:00 +01003044 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01003045}
3046
3047/* Paging on empty list: Verify none of them page */
3048testcase TC_paging_imsi_nochan_lacs_empty() runs on test_CT {
3049 var template BSSMAP_FIELD_CellIdentificationList cid_list;
3050 cid_list := { cIl_LAC := { } };
3051 f_pageing_helper('001010000000016'H, cid_list, c_BtsId_none);
Philipp Maier282ca4b2018-02-27 17:17:00 +01003052 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01003053}
3054
Stefan Sperling049a86e2018-03-20 15:51:00 +01003055/* Paging by CGI with unknown MCC/MNC: Verify nothing is paged. */
3056testcase TC_paging_imsi_nochan_cgi_unknown_cid() runs on test_CT {
3057 var template BSSMAP_FIELD_CellIdentificationList cid_list;
3058 cid_list := { cIl_CGI := { ts_BSSMAP_CI_CGI(unknown_cid.mcc, unknown_cid.mnc, unknown_cid.lac, unknown_cid.ci) } };
3059 f_pageing_helper('001010000000006'H, cid_list, c_BtsId_none);
3060 f_shutdown_helper();
3061}
3062
Harald Welte6f521d82017-12-11 19:52:02 +01003063/* Verify paging retransmission interval + count */
3064/* Verify paging stops after channel establishment */
Harald Welte6f521d82017-12-11 19:52:02 +01003065/* Test behavior under paging overload */
Harald Welteae026692017-12-09 01:03:01 +01003066
Harald Weltee65d40e2017-12-13 00:09:06 +01003067/* Verify PCH load */
3068testcase TC_paging_imsi_load() runs on test_CT {
3069 var BSSMAP_FIELD_CellIdentificationList cid_list;
3070 timer T := 4.0;
Harald Welte2caa1062018-03-17 18:19:05 +01003071 timer T_retrans := 1.0;
Harald Weltee65d40e2017-12-13 00:09:06 +01003072 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01003073 f_pageing_helper('001010123456789'H, cid_list, c_BtsId_all);
Harald Weltee65d40e2017-12-13 00:09:06 +01003074
3075 /* tell BSC there is no paging space anymore */
3076 f_ipa_tx(0, ts_RSL_PAGING_LOAD_IND(0));
Harald Welte3b57ab52018-03-17 18:01:10 +01003077 f_sleep(0.2);
3078 IPA_RSL[0].clear;
Harald Weltee65d40e2017-12-13 00:09:06 +01003079
3080 /* Wait for 4 seconds if any more PAGING CMD are received on RSL. Normally,
3081 * there would be 8 retransmissions during 4 seconds */
3082 T.start;
Harald Welte2caa1062018-03-17 18:19:05 +01003083 T_retrans.start;
Harald Weltee65d40e2017-12-13 00:09:06 +01003084 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07003085 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD(?))) {
Harald Weltee65d40e2017-12-13 00:09:06 +01003086 setverdict(fail, "Received PAGING after LOAD_IND(0)");
Daniel Willmannafce8662018-07-06 23:11:32 +02003087 mtc.stop;
Harald Weltee65d40e2017-12-13 00:09:06 +01003088 }
Harald Welte2caa1062018-03-17 18:19:05 +01003089 [] T_retrans.timeout {
3090 /* re-trnsmit the zero-space LOAD IND to avoid BSC 'auto credit' */
3091 f_ipa_tx(0, ts_RSL_PAGING_LOAD_IND(0));
3092 T_retrans.start;
3093 repeat;
3094 }
Harald Weltee65d40e2017-12-13 00:09:06 +01003095 [] T.timeout {
3096 setverdict(pass);
3097 }
3098 }
Philipp Maier282ca4b2018-02-27 17:17:00 +01003099
3100 f_shutdown_helper();
Harald Weltee65d40e2017-12-13 00:09:06 +01003101}
3102
Harald Welte235ebf12017-12-15 14:18:16 +01003103/* Verify Paging Counter */
Harald Welte1ff69992017-12-14 12:31:17 +01003104testcase TC_paging_counter() runs on test_CT {
3105 var BSSMAP_FIELD_CellIdentificationList cid_list;
3106 timer T := 4.0;
3107 var integer i;
3108 var integer paging_attempted_bsc;
3109 var integer paging_attempted_bts[NUM_BTS];
3110 var integer paging_expired_bts[NUM_BTS];
3111 cid_list := valueof(ts_BSSMAP_CIL_noCell);
3112
3113 f_init();
3114
3115 /* read counters before paging */
3116 paging_attempted_bsc := f_ctrl_get_ratectr_abs(IPA_CTRL, "bsc", 0, "paging:attempted");
3117 for (i := 0; i < NUM_BTS; i := i+1) {
3118 paging_attempted_bts[i] := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", i, "paging:attempted");
3119 paging_expired_bts[i] := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", i, "paging:expired");
3120 }
3121
3122 f_pageing_helper('001230000000001'H, cid_list, c_BtsId_all);
3123
3124 /* expect the attempted pages on BSC and each BTSs to have incremented by one */
3125 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bsc", 0, "paging:attempted", paging_attempted_bsc+1);
3126 for (i := 0; i < NUM_BTS; i := i+1) {
3127 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", i, "paging:attempted",
3128 paging_attempted_bts[i]+1);
3129 }
3130
3131 /* assume that 12s later the paging on all BTSs have expired and hence incremented by 1 */
3132 f_sleep(12.0);
3133 for (i := 0; i < NUM_BTS; i := i+1) {
3134 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", i, "paging:expired",
3135 paging_expired_bts[i]+1);
3136 }
Harald Welte1ff69992017-12-14 12:31:17 +01003137
Philipp Maier282ca4b2018-02-27 17:17:00 +01003138 f_shutdown_helper();
Harald Welte1ff69992017-12-14 12:31:17 +01003139}
3140
3141
Harald Welte10985002017-12-12 09:29:15 +01003142/* Verify paging stops after A-RESET */
3143testcase TC_paging_imsi_a_reset() runs on test_CT {
3144 var BSSMAP_FIELD_CellIdentificationList cid_list;
3145 timer T := 3.0;
3146 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01003147 f_pageing_helper('001010123456789'H, cid_list, c_BtsId_all);
Harald Welte10985002017-12-12 09:29:15 +01003148
3149 /* Perform a BSSMAP Reset and wait for ACK */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003150 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 +01003151 alt {
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003152 [] 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 +01003153 [] BSSAP.receive { repeat; }
3154 }
3155
Daniel Willmanncbef3982018-07-30 09:22:40 +02003156 /* Wait to avoid a possible race condition if a paging message is
3157 * received right before the reset ACK. */
3158 f_sleep(0.2);
3159
Harald Welte10985002017-12-12 09:29:15 +01003160 /* Clear the queue, it might still contain stuff like BCCH FILLING */
Philipp Maier1e6b4422018-02-23 14:02:13 +01003161 for (var integer i := 0; i < sizeof(IPA_RSL); i := i+1) {
3162 IPA_RSL[i].clear;
3163 }
Harald Welte10985002017-12-12 09:29:15 +01003164
3165 /* Wait for 3 seconds if any more PAGING CMD are received on RSL */
3166 T.start;
3167 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07003168 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD(?))) {
Harald Welte10985002017-12-12 09:29:15 +01003169 setverdict(fail, "Received PAGING after A-RESET");
Daniel Willmannafce8662018-07-06 23:11:32 +02003170 mtc.stop;
Harald Welte10985002017-12-12 09:29:15 +01003171 }
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07003172 [] IPA_RSL[1].receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD(?))) {
Harald Welte5d1a2202017-12-13 19:51:29 +01003173 setverdict(fail, "Received PAGING after A-RESET");
Daniel Willmannafce8662018-07-06 23:11:32 +02003174 mtc.stop;
Harald Welte5d1a2202017-12-13 19:51:29 +01003175 }
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07003176 [] IPA_RSL[2].receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD(?))) {
Harald Welte5d1a2202017-12-13 19:51:29 +01003177 setverdict(fail, "Received PAGING after A-RESET");
Daniel Willmannafce8662018-07-06 23:11:32 +02003178 mtc.stop;
Harald Welte5d1a2202017-12-13 19:51:29 +01003179 }
Harald Welte10985002017-12-12 09:29:15 +01003180 [] T.timeout {
3181 setverdict(pass);
3182 }
3183 }
Philipp Maier282ca4b2018-02-27 17:17:00 +01003184
3185 f_shutdown_helper();
Harald Welte10985002017-12-12 09:29:15 +01003186}
Harald Welteae026692017-12-09 01:03:01 +01003187
Philipp Maierf45824a2019-08-14 14:44:10 +02003188/* Verify how we handle unsolicited Paging Response. In case of an unsolicit
3189 * paging response we can not know which MSC is in charge, so we will blindly
3190 * pick the first configured MSC. This behavior is required in order to make
3191 * MT-CSFB calls working because in those cases the BSC can not know that the
3192 * MSC has already paged the subscriver via SGs. So any MT-CSFB call will look
3193 * like an unsolicited Paging Response to the MSC.
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01003194 */
3195testcase TC_paging_resp_unsol() runs on test_CT {
3196
3197 f_init(1);
Philipp Maierf45824a2019-08-14 14:44:10 +02003198 timer T := 5.0;
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01003199
3200 var BSSAP_N_CONNECT_ind rx_c_ind;
3201 var DchanTuple dt;
3202 var PDU_ML3_MS_NW l3 := valueof(ts_PAG_RESP(valueof(ts_MI_IMSI_LV('001010008880018'H))));
Philipp Maierf45824a2019-08-14 14:44:10 +02003203 var octetstring rr_pag_resp := enc_PDU_ML3_MS_NW(l3);
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01003204
3205 /* Send CHAN RQD and wait for allocation; acknowledge it */
3206 dt.rsl_chan_nr := f_chreq_act_ack();
3207
3208 /* Send unsolicited Paging response (no matching Paging CMD stored in BSC) */
3209 f_ipa_tx(0, ts_RSL_EST_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0)), enc_PDU_ML3_MS_NW(l3)));
3210
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01003211
Philipp Maierf45824a2019-08-14 14:44:10 +02003212 /* Expevct a CR with a matching Paging response on the A-Interface */
3213 T.start;
3214 alt {
3215 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(rr_pag_resp))) {
3216 setverdict(pass);
3217 }
3218 [] BSSAP.receive {
3219 setverdict(fail, "Received unexpected message on A-Interface!");
3220 }
3221 [] T.timeout {
3222 setverdict(fail, "Received nothing on A-Interface!");
3223 }
3224 }
3225
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003226 f_shutdown_helper();
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01003227}
3228
Harald Welte4e9b9cc2017-12-14 18:31:02 +01003229/* Test RSL link drop causes counter increment */
3230testcase TC_rsl_drop_counter() runs on test_CT {
3231 var integer rsl_fail;
3232
Harald Welte89d42e82017-12-17 16:42:41 +01003233 f_init(1);
Harald Welte4e9b9cc2017-12-14 18:31:02 +01003234
3235 rsl_fail := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "rsl_fail");
3236
3237 bts[0].rsl.vc_IPA.stop;
3238
3239 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "rsl_fail", rsl_fail+1);
3240
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003241 f_shutdown_helper();
Harald Welte4e9b9cc2017-12-14 18:31:02 +01003242}
3243
3244/* TODO: Test OML link drop causes counter increment */
3245
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003246/* The body of TC_rsl_unknown_unit_id() and TC_oml_unknown_unit_id() tests. */
3247function f_ipa_unknown_unit_id(integer mp_bsc_ipa_port) runs on test_CT return boolean {
3248 timer T := 10.0;
3249
3250 bts[0].rsl.id := "IPA-0-RSL";
3251 bts[0].rsl.vc_IPA := IPA_Emulation_CT.create(bts[0].rsl.id & "-IPA");
3252 bts[0].rsl.ccm_pars := c_IPA_default_ccm_pars;
3253 bts[0].rsl.ccm_pars.name := "Osmocom TTCN-3 BTS Simulator";
Oliver Smith92c2bdb2019-08-20 15:11:24 +02003254 bts[0].rsl.ccm_pars.unit_id := "99/0/0"; /* value which is unknown at BTS */
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003255
Pau Espin Pedrol9a5b8ff2021-01-04 19:01:31 +01003256 f_ipa_ctrl_start_client(mp_bsc_ip, mp_bsc_ctrl_port);
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003257
3258 f_init_mgcp("VirtMSC");
3259
3260 /* start RSL/OML connection (XXX re-uses RSL port/protocol definitions for OML) */
3261 map(bts[0].rsl.vc_IPA:IPA_PORT, system:IPA);
3262 connect(bts[0].rsl.vc_IPA:IPA_RSL_PORT, self:IPA_RSL[0]);
3263 bts[0].rsl.vc_IPA.start(IPA_Emulation.main_client(mp_bsc_ip, mp_bsc_ipa_port, "", 10000, bts[0].rsl.ccm_pars));
3264
3265 /* wait for IPA OML link to connect and then disconnect */
3266 T.start;
3267 alt {
Vadim Yanitskiya2afacc2020-05-18 21:16:19 +07003268 [] IPA_RSL[0].receive(tr_ASP_IPA_EV(ASP_IPA_EVENT_DOWN)) {
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003269 T.stop;
3270 return true;
3271 }
3272 [] IPA_RSL[0].receive { repeat }
3273 [] T.timeout {
Daniel Willmannafce8662018-07-06 23:11:32 +02003274 return false;
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003275 }
3276 }
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003277 return false;
3278}
3279
3280/* BSC should close an RSL connection from a BTS with unknown unit ID (OS#2714). */
3281testcase TC_rsl_unknown_unit_id() runs on test_CT {
3282 if (f_ipa_unknown_unit_id(mp_bsc_rsl_port)) {
3283 setverdict(pass);
3284 } else {
3285 setverdict(fail, "Timeout RSL waiting for connection to close");
3286 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003287 f_shutdown_helper();
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003288}
3289
3290
3291/* BSC should close an RSL connection from a BTS with unknown unit ID (OS#2714). */
3292testcase TC_oml_unknown_unit_id() runs on test_CT {
3293 if (f_ipa_unknown_unit_id(mp_bsc_oml_port)) {
3294 setverdict(pass);
3295 } else {
3296 setverdict(fail, "Timeout OML waiting for connection to close");
3297 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003298 f_shutdown_helper();
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003299}
3300
3301
Harald Weltec1a2fff2017-12-17 11:06:19 +01003302/***********************************************************************
Harald Welte6811d102019-04-14 22:23:14 +02003303 * "New world" test cases using RSL_Emulation + RAN_Emulation
Harald Weltec1a2fff2017-12-17 11:06:19 +01003304 ***********************************************************************/
3305
Harald Welte6811d102019-04-14 22:23:14 +02003306import from RAN_Emulation all;
Harald Welte47cd0e32020-08-21 12:39:11 +02003307import from BSSAP_LE_Emulation all;
Harald Weltec1a2fff2017-12-17 11:06:19 +01003308import from RSL_Emulation all;
3309import from MSC_ConnectionHandler all;
3310
3311type function void_fn(charstring id) runs on MSC_ConnHdlr;
3312
Harald Welte336820c2018-05-31 20:34:52 +02003313/* helper function to create and connect a MSC_ConnHdlr component */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003314private function f_connect_handler(inout MSC_ConnHdlr vc_conn, integer bssap_idx := 0) runs on test_CT {
3315 connect(vc_conn:RAN, g_bssap[bssap_idx].vc_RAN:PROC);
Daniel Willmann191e0d92018-01-17 12:44:35 +01003316 connect(vc_conn:MGCP_PROC, vc_MGCP:MGCP_PROC);
Harald Weltec1a2fff2017-12-17 11:06:19 +01003317 connect(vc_conn:RSL, bts[0].rsl.vc_RSL:CLIENT_PT);
Harald Weltef70df652018-01-29 22:00:23 +01003318 connect(vc_conn:RSL_PROC, bts[0].rsl.vc_RSL:RSL_PROC);
Philipp Maier88f4ae82018-03-01 14:00:58 +01003319 if (isvalue(bts[1])) {
Philipp Maier956a92f2018-02-16 10:58:07 +01003320 connect(vc_conn:RSL1, bts[1].rsl.vc_RSL:CLIENT_PT);
3321 connect(vc_conn:RSL1_PROC, bts[1].rsl.vc_RSL:RSL_PROC);
3322 }
Neels Hofmeyr91401012019-07-11 00:42:35 +02003323 if (isvalue(bts[2])) {
3324 connect(vc_conn:RSL2, bts[2].rsl.vc_RSL:CLIENT_PT);
3325 connect(vc_conn:RSL2_PROC, bts[2].rsl.vc_RSL:RSL_PROC);
3326 }
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003327 connect(vc_conn:BSSAP, g_bssap[bssap_idx].vc_RAN:CLIENT);
Neels Hofmeyrcfe44062020-10-15 02:28:08 +02003328 if (mp_enable_lcs_tests) {
3329 connect(vc_conn:BSSAP_LE, g_bssap_le.vc_BSSAP_LE:CLIENT);
3330 connect(vc_conn:BSSAP_LE_PROC, g_bssap_le.vc_BSSAP_LE:PROC);
3331 }
Daniel Willmann191e0d92018-01-17 12:44:35 +01003332 connect(vc_conn:MGCP, vc_MGCP:MGCP_CLIENT);
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +02003333 connect(vc_conn:MGCP_MULTI, vc_MGCP:MGCP_CLIENT_MULTI);
Daniel Willmannebdecc02020-08-12 15:30:17 +02003334 connect(vc_conn:STATSD_PROC, vc_STATSD:STATSD_PROC);
Harald Welte336820c2018-05-31 20:34:52 +02003335}
3336
Neels Hofmeyrda436782021-07-20 22:09:06 +02003337function f_start_handler_create(template (omit) TestHdlrParams pars := omit)
Harald Welte336820c2018-05-31 20:34:52 +02003338runs on test_CT return MSC_ConnHdlr {
3339 var charstring id := testcasename();
3340 var MSC_ConnHdlr vc_conn;
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003341 var integer bssap_idx := 0;
3342 if (isvalue(pars)) {
3343 bssap_idx := valueof(pars).mscpool.bssap_idx;
3344 }
Harald Welte336820c2018-05-31 20:34:52 +02003345 vc_conn := MSC_ConnHdlr.create(id);
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003346 f_connect_handler(vc_conn, bssap_idx);
Neels Hofmeyrda436782021-07-20 22:09:06 +02003347 return vc_conn;
3348}
3349
3350function f_start_handler_run(MSC_ConnHdlr vc_conn, void_fn fn, template (omit) TestHdlrParams pars := omit)
3351runs on test_CT return MSC_ConnHdlr {
3352 var charstring id := testcasename();
Neels Hofmeyr1708d1b2020-10-10 16:56:48 +02003353 /* Emit a marker to appear in the SUT's own logging output */
Neels Hofmeyrda436782021-07-20 22:09:06 +02003354 f_logp(BSCVTY, id & "() start");
Harald Weltea0630032018-03-20 21:09:55 +01003355 vc_conn.start(f_handler_init(fn, id, pars));
Harald Weltec1a2fff2017-12-17 11:06:19 +01003356 return vc_conn;
3357}
3358
Neels Hofmeyrda436782021-07-20 22:09:06 +02003359function f_start_handler(void_fn fn, template (omit) TestHdlrParams pars := omit)
3360runs on test_CT return MSC_ConnHdlr {
3361 return f_start_handler_run(f_start_handler_create(pars), fn, pars);
3362}
3363
Harald Weltea0630032018-03-20 21:09:55 +01003364/* first function inside ConnHdlr component; sets g_pars + starts function */
3365private function f_handler_init(void_fn fn, charstring id, template (omit) TestHdlrParams pars := omit)
3366runs on MSC_ConnHdlr {
3367 if (isvalue(pars)) {
3368 g_pars := valueof(pars);
3369 }
3370 fn.apply(id);
3371}
3372
Oliver Smith26a3db72021-07-09 13:51:29 +02003373private function f_vty_encryption_a5(charstring options) runs on test_CT {
3374 f_vty_transceive(BSCVTY, "configure terminal");
3375 f_vty_transceive(BSCVTY, "network");
3376 f_vty_transceive(BSCVTY, "encryption a5 " & options);
3377 f_vty_transceive(BSCVTY, "exit");
3378 f_vty_transceive(BSCVTY, "exit");
3379}
3380
3381private function f_vty_encryption_a5_reset() runs on test_CT {
3382 /* keep in sync with docker-playground.git ttcn3-bsc-test/osmo-bsc.cfg */
3383 f_vty_encryption_a5("0 1 3");
3384}
3385
Harald Welte3c86ea02018-05-10 22:28:05 +02003386/* Establish signalling channel (non-assignment case) followed by cipher mode */
3387private function f_tc_ciph_mode_a5(charstring id) runs on MSC_ConnHdlr {
Harald Welteed848512018-05-24 22:27:58 +02003388 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3389 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte3c86ea02018-05-10 22:28:05 +02003390 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeSIGNAL);
Philipp Maier23000732018-05-18 11:25:37 +02003391 ass_cmd.pdu.bssmap.assignmentRequest.circuitIdentityCode := omit;
3392 ass_cmd.pdu.bssmap.assignmentRequest.aoIPTransportLayer := omit;
3393 exp_compl.pdu.bssmap.assignmentComplete.circuitIdentityCode := omit;
3394 exp_compl.pdu.bssmap.assignmentComplete.aoIPTransportLayer := omit;
Harald Welte3c86ea02018-05-10 22:28:05 +02003395
Philipp Maier23000732018-05-18 11:25:37 +02003396 f_establish_fully(ass_cmd, exp_compl);
Harald Welte3c86ea02018-05-10 22:28:05 +02003397}
3398testcase TC_ciph_mode_a5_0() runs on test_CT {
3399 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02003400 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte3c86ea02018-05-10 22:28:05 +02003401 pars.encr := valueof(t_EncrParams('01'O, f_rnd_octstring(8)));
3402
3403 f_init(1, true);
3404 f_sleep(1.0);
3405 vc_conn := f_start_handler(refers(f_tc_ciph_mode_a5), pars);
3406 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003407 f_shutdown_helper();
Harald Welte3c86ea02018-05-10 22:28:05 +02003408}
3409testcase TC_ciph_mode_a5_1() runs on test_CT {
3410 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02003411 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte3c86ea02018-05-10 22:28:05 +02003412 pars.encr := valueof(t_EncrParams('02'O, f_rnd_octstring(8)));
3413
3414 f_init(1, true);
3415 f_sleep(1.0);
3416 vc_conn := f_start_handler(refers(f_tc_ciph_mode_a5), pars);
3417 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003418 f_shutdown_helper();
Harald Welte3c86ea02018-05-10 22:28:05 +02003419}
Oliver Smith50b98122021-07-09 15:00:28 +02003420/* OS#4975: verify that A5/2 is preferred over A5/0 */
3421testcase TC_ciph_mode_a5_2_0() runs on test_CT {
3422 var MSC_ConnHdlr vc_conn;
3423 var TestHdlrParams pars := f_gen_test_hdlr_pars();
3424
3425 pars.encr := valueof(t_EncrParams('05'O, f_rnd_octstring(8))); /* A5/0 and A5/2 (0x01|0x04)*/
3426 pars.encr_exp_enc_alg := '04'O; /* A5/2 */
3427
3428 f_init(1, true);
3429 f_vty_encryption_a5("0 1 2 3");
3430 f_sleep(1.0);
3431 vc_conn := f_start_handler(refers(f_tc_ciph_mode_a5), pars);
3432 vc_conn.done;
3433 f_vty_encryption_a5_reset();
3434 f_shutdown_helper();
3435}
Oliver Smith1dff88d2021-07-09 08:45:51 +02003436/* OS#4975: verify that A5/1 is preferred over A5/2 */
3437testcase TC_ciph_mode_a5_2_1() runs on test_CT {
3438 var MSC_ConnHdlr vc_conn;
3439 var TestHdlrParams pars := f_gen_test_hdlr_pars();
3440
3441 pars.encr := valueof(t_EncrParams('06'O, f_rnd_octstring(8))); /* A5/1 and A5/2 (0x02|0x04)*/
3442 pars.encr_exp_enc_alg := '02'O; /* A5/1 */
3443
3444 f_init(1, true);
3445 f_vty_encryption_a5("1 2");
3446 f_sleep(1.0);
3447 vc_conn := f_start_handler(refers(f_tc_ciph_mode_a5), pars);
3448 vc_conn.done;
3449 f_vty_encryption_a5_reset();
3450 f_shutdown_helper();
3451}
Harald Welte3c86ea02018-05-10 22:28:05 +02003452testcase TC_ciph_mode_a5_3() runs on test_CT {
3453 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02003454 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte3c86ea02018-05-10 22:28:05 +02003455 pars.encr := valueof(t_EncrParams('08'O, f_rnd_octstring(8)));
3456
3457 f_init(1, true);
3458 f_sleep(1.0);
3459 vc_conn := f_start_handler(refers(f_tc_ciph_mode_a5), pars);
3460 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003461 f_shutdown_helper();
Harald Welte3c86ea02018-05-10 22:28:05 +02003462}
Neels Hofmeyr81ad27f2021-06-11 00:09:40 +02003463/* Establish a Signalling channel with A5/4 encryption. */
3464testcase TC_ciph_mode_a5_4() runs on test_CT {
3465 var MSC_ConnHdlr vc_conn;
3466 var TestHdlrParams pars := f_gen_test_hdlr_pars();
3467 pars.encr := valueof(t_EncrParams('10'O, f_rnd_octstring(8), f_rnd_octstring(16)));
Harald Welte3c86ea02018-05-10 22:28:05 +02003468
Neels Hofmeyr81ad27f2021-06-11 00:09:40 +02003469 f_init(1, true);
Oliver Smith26a3db72021-07-09 13:51:29 +02003470 f_vty_encryption_a5("0 1 3 4");
Neels Hofmeyr81ad27f2021-06-11 00:09:40 +02003471 f_sleep(1.0);
3472 vc_conn := f_start_handler(refers(f_tc_ciph_mode_a5), pars);
3473 vc_conn.done;
Oliver Smith26a3db72021-07-09 13:51:29 +02003474 f_vty_encryption_a5_reset();
Neels Hofmeyr81ad27f2021-06-11 00:09:40 +02003475 f_shutdown_helper();
3476}
Pau Espin Pedrol07866632020-09-03 19:10:55 +02003477/* establish initial channel, enable ciphering followed by assignment to ciphered channel */
3478private function f_tc_assignment_aoip_tla_v6(charstring id) runs on MSC_ConnHdlr {
3479 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3480 var PDU_BSSAP ass_cmd := f_gen_ass_req(aoip_tla := "::3");
3481 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3482 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
3483
3484 f_establish_fully(ass_cmd, exp_compl);
3485}
3486testcase TC_assignment_aoip_tla_v6() runs on test_CT {
3487 var MSC_ConnHdlr vc_conn;
3488 var TestHdlrParams pars := f_gen_test_hdlr_pars();
3489
3490 f_init(1, true);
3491 f_sleep(1.0);
3492 vc_conn := f_start_handler(refers(f_tc_assignment_aoip_tla_v6), pars);
3493 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003494 f_shutdown_helper();
Pau Espin Pedrol07866632020-09-03 19:10:55 +02003495}
3496
Harald Welte3c86ea02018-05-10 22:28:05 +02003497
3498/* establish initial channel, enable ciphering followed by assignment to ciphered channel */
Harald Welte651fcdc2018-05-10 20:23:16 +02003499private function f_tc_assignment_fr_a5(charstring id) runs on MSC_ConnHdlr {
Harald Welteed848512018-05-24 22:27:58 +02003500 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3501 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Weltec1a2fff2017-12-17 11:06:19 +01003502
Harald Welte552620d2017-12-16 23:21:36 +01003503 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3504 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
Harald Welte73cd2712017-12-17 00:44:52 +01003505
Harald Weltea0630032018-03-20 21:09:55 +01003506 f_establish_fully(ass_cmd, exp_compl);
Harald Welte552620d2017-12-16 23:21:36 +01003507}
Harald Welte552620d2017-12-16 23:21:36 +01003508testcase TC_assignment_fr_a5_0() runs on test_CT {
3509 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02003510 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte651fcdc2018-05-10 20:23:16 +02003511 pars.encr := valueof(t_EncrParams('01'O, f_rnd_octstring(8)));
Harald Welte552620d2017-12-16 23:21:36 +01003512
Harald Welte89d42e82017-12-17 16:42:41 +01003513 f_init(1, true);
Harald Welte552620d2017-12-16 23:21:36 +01003514 f_sleep(1.0);
Harald Welte651fcdc2018-05-10 20:23:16 +02003515 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5), pars);
Harald Welte552620d2017-12-16 23:21:36 +01003516 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003517 f_shutdown_helper();
Harald Welte552620d2017-12-16 23:21:36 +01003518}
Harald Welte552620d2017-12-16 23:21:36 +01003519testcase TC_assignment_fr_a5_1() runs on test_CT {
Harald Weltec1a2fff2017-12-17 11:06:19 +01003520 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02003521 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte651fcdc2018-05-10 20:23:16 +02003522 pars.encr := valueof(t_EncrParams('02'O, f_rnd_octstring(8)));
Harald Weltec1a2fff2017-12-17 11:06:19 +01003523
Harald Welte89d42e82017-12-17 16:42:41 +01003524 f_init(1, true);
Harald Weltec1a2fff2017-12-17 11:06:19 +01003525 f_sleep(1.0);
Harald Welte651fcdc2018-05-10 20:23:16 +02003526 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5), pars);
3527 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003528 f_shutdown_helper();
Harald Welte651fcdc2018-05-10 20:23:16 +02003529}
3530testcase TC_assignment_fr_a5_3() runs on test_CT {
3531 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02003532 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte651fcdc2018-05-10 20:23:16 +02003533 pars.encr := valueof(t_EncrParams('08'O, f_rnd_octstring(8)));
Harald Weltec1a2fff2017-12-17 11:06:19 +01003534
Harald Welte651fcdc2018-05-10 20:23:16 +02003535 f_init(1, true);
3536 f_sleep(1.0);
3537 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5), pars);
Harald Weltec1a2fff2017-12-17 11:06:19 +01003538 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003539 f_shutdown_helper();
Harald Weltec1a2fff2017-12-17 11:06:19 +01003540}
Neels Hofmeyr0d8ec532021-06-11 00:09:48 +02003541/* Establish a Signalling channel and re-assign to TCH/F with A5/4 encryption. */
3542testcase TC_assignment_fr_a5_4() runs on test_CT {
3543 var MSC_ConnHdlr vc_conn;
3544 var TestHdlrParams pars := f_gen_test_hdlr_pars();
3545 pars.encr := valueof(t_EncrParams('10'O, f_rnd_octstring(8), f_rnd_octstring(16)));
3546
3547 f_init(1, true);
Oliver Smith7eabd312021-07-12 14:18:56 +02003548 f_vty_encryption_a5("0 1 3 4");
Neels Hofmeyr0d8ec532021-06-11 00:09:48 +02003549 f_sleep(1.0);
3550 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5), pars);
3551 vc_conn.done;
Oliver Smith7eabd312021-07-12 14:18:56 +02003552 f_vty_encryption_a5_reset();
Neels Hofmeyr0d8ec532021-06-11 00:09:48 +02003553 f_shutdown_helper();
3554}
Harald Weltec1a2fff2017-12-17 11:06:19 +01003555
Neels Hofmeyr0faeb7a2021-06-10 23:59:35 +02003556/* Allow only A5/4, but omit the Kc128 IE from MSC's msg. Expect Cipher Mode Reject. */
3557testcase TC_assignment_fr_a5_4_fail() runs on test_CT {
3558 var TestHdlrParams pars := f_gen_test_hdlr_pars();
3559 var MSC_ConnHdlr vc_conn;
3560
3561 f_init(1, true);
3562 f_sleep(1.0);
3563
3564 pars.encr := valueof(t_EncrParams('10'O, f_rnd_octstring(8))); // A5/4 support, but Kc128 missing!
3565 vc_conn := f_start_handler(refers(f_TC_assignment_a5_not_sup), pars);
3566 vc_conn.done;
3567 f_shutdown_helper();
3568}
3569
Harald Welte552620d2017-12-16 23:21:36 +01003570/* Expect ASSIGNMENT FAIL if mandatory IE is missing */
3571private function f_tc_assignment_fr_a5_1_codec_missing(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02003572 g_pars := f_gen_test_hdlr_pars();
Harald Welte552620d2017-12-16 23:21:36 +01003573 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
Harald Welteed848512018-05-24 22:27:58 +02003574 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte552620d2017-12-16 23:21:36 +01003575
3576 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02003577 /* Omit: ass_cmd.pdu.bssmap.assignmentRequest.codecList */
3578
Harald Weltea0630032018-03-20 21:09:55 +01003579 f_establish_fully(ass_cmd, exp_fail);
Harald Welte552620d2017-12-16 23:21:36 +01003580}
Harald Welte552620d2017-12-16 23:21:36 +01003581testcase TC_assignment_fr_a5_1_codec_missing() runs on test_CT {
3582 var MSC_ConnHdlr vc_conn;
3583
Harald Welte89d42e82017-12-17 16:42:41 +01003584 f_init(1, true);
Harald Welte552620d2017-12-16 23:21:36 +01003585 f_sleep(1.0);
3586
Harald Welte8863fa12018-05-10 20:15:27 +02003587 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5_1_codec_missing));
Harald Welte552620d2017-12-16 23:21:36 +01003588 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003589 f_shutdown_helper();
Harald Welte552620d2017-12-16 23:21:36 +01003590}
3591
Neels Hofmeyr04d6e6a2021-06-11 00:10:02 +02003592private function f_TC_assignment_a5_not_sup(charstring id) runs on MSC_ConnHdlr {
3593 var template PDU_BSSAP exp_ass_cpl := f_gen_exp_compl();
3594 var PDU_BSSAP exp_ass_req := f_gen_ass_req();
Harald Welte552620d2017-12-16 23:21:36 +01003595
Neels Hofmeyr04d6e6a2021-06-11 00:10:02 +02003596 exp_ass_req.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3597 exp_ass_req.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
3598
3599 /* this is like the beginning of f_establish_fully(), but only up to ciphering reject */
3600
3601 var BSSMAP_FIELD_CodecType codecType;
3602 timer T := 10.0;
3603
3604 codecType := exp_ass_req.pdu.bssmap.assignmentRequest.codecList.codecElements[0].codecType;
3605 f_MscConnHdlr_init(g_pars.media_nr, host_bts, host_mgw_mgcp, codecType);
3606
3607 f_create_chan_and_exp();
3608 /* we should now have a COMPL_L3 at the MSC */
3609
3610 var template PDU_BSSAP exp_l3_compl;
3611 exp_l3_compl := tr_BSSMAP_ComplL3()
3612 if (g_pars.aoip == false) {
3613 exp_l3_compl.pdu.bssmap.completeLayer3Information.codecList := omit;
3614 } else {
3615 exp_l3_compl.pdu.bssmap.completeLayer3Information.codecList := ?;
3616 }
3617 T.start;
3618 alt {
3619 [] BSSAP.receive(exp_l3_compl);
3620 [] BSSAP.receive(tr_BSSMAP_ComplL3) {
3621 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Received non-matching COMPLETE LAYER 3 INFORMATION");
3622 }
3623 [] T.timeout {
3624 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for COMPLETE LAYER 3 INFORMATION");
3625 }
3626 }
3627
3628 /* Start ciphering, expect Cipher Mode Reject */
Neels Hofmeyr6c388f22021-06-11 02:36:56 +02003629 f_cipher_mode(g_pars.encr, exp_fail := true);
Harald Welte552620d2017-12-16 23:21:36 +01003630}
Neels Hofmeyr04d6e6a2021-06-11 00:10:02 +02003631testcase TC_assignment_fr_a5_not_sup() runs on test_CT {
3632 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte552620d2017-12-16 23:21:36 +01003633 var MSC_ConnHdlr vc_conn;
3634
Harald Welte89d42e82017-12-17 16:42:41 +01003635 f_init(1, true);
Harald Welte552620d2017-12-16 23:21:36 +01003636 f_sleep(1.0);
3637
Neels Hofmeyr0588cad2021-06-11 01:38:18 +02003638 pars.encr := valueof(t_EncrParams('20'O, f_rnd_octstring(8), f_rnd_octstring(16)));
Neels Hofmeyr04d6e6a2021-06-11 00:10:02 +02003639 vc_conn := f_start_handler(refers(f_TC_assignment_a5_not_sup), pars);
Harald Welte552620d2017-12-16 23:21:36 +01003640 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003641 f_shutdown_helper();
Harald Welte552620d2017-12-16 23:21:36 +01003642}
3643
3644
Harald Welte4532e0a2017-12-23 02:05:44 +01003645private function f_tc_assignment_sign(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02003646 g_pars := f_gen_test_hdlr_pars();
Harald Welte4532e0a2017-12-23 02:05:44 +01003647 var template PDU_BSSAP exp_compl := tr_BSSMAP_AssignmentComplete(omit, omit);
Philipp Maier48604732018-10-09 15:00:37 +02003648 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte4532e0a2017-12-23 02:05:44 +01003649 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeSIGNAL);
Daniel Willmannebdecc02020-08-12 15:30:17 +02003650
3651 f_statsd_reset();
Harald Weltea0630032018-03-20 21:09:55 +01003652 f_establish_fully(ass_cmd, exp_compl);
Daniel Willmannebdecc02020-08-12 15:30:17 +02003653
3654 var StatsDExpects expect := {
Daniel Willmannc5398f72020-09-21 10:41:35 +02003655 { name := "TTCN3.bts.0.chreq.total", mtype := "c", min := 1, max := 1},
3656 { name := "TTCN3.bts.0.chreq.successful", mtype := "c", min := 1, max := 1},
Daniel Willmannebdecc02020-08-12 15:30:17 +02003657 { name := "TTCN3.bsc.0.assignment.attempted", mtype := "c", min := 1, max := 1},
3658 { name := "TTCN3.bsc.0.assignment.completed", mtype := "c", min := 1, max := 1}
3659 };
3660 f_statsd_expect(expect);
Harald Welte4532e0a2017-12-23 02:05:44 +01003661}
3662
3663testcase TC_assignment_sign() runs on test_CT {
3664 var MSC_ConnHdlr vc_conn;
3665
3666 f_init(1, true);
3667 f_sleep(1.0);
3668
Harald Welte8863fa12018-05-10 20:15:27 +02003669 vc_conn := f_start_handler(refers(f_tc_assignment_sign));
Harald Welte4532e0a2017-12-23 02:05:44 +01003670 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003671 f_shutdown_helper();
Harald Welte4532e0a2017-12-23 02:05:44 +01003672}
3673
Harald Welte60aa5762018-03-21 19:33:13 +01003674/***********************************************************************
3675 * Codec (list) testing
3676 ***********************************************************************/
3677
3678/* check if the given rsl_mode is compatible with the a_elem */
3679private function f_match_codec(BSSMAP_FIELD_CodecElement a_elem, RSL_IE_ChannelMode rsl_mode)
3680return boolean {
3681 select (a_elem.codecType) {
3682 case (GSM_FR) {
3683 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM1))) {
3684 return true;
3685 }
3686 }
3687 case (GSM_HR) {
3688 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_H, RSL_CMOD_SP_GSM1))) {
3689 return true;
3690 }
3691 }
3692 case (GSM_EFR) {
3693 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM2))) {
3694 return true;
3695 }
3696 }
3697 case (FR_AMR) {
3698 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM3))) {
3699 return true;
3700 }
3701 }
3702 case (HR_AMR) {
3703 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_H, RSL_CMOD_SP_GSM3))) {
3704 return true;
3705 }
3706 }
3707 case else { }
3708 }
3709 return false;
3710}
3711
3712/* check if the given rsl_mode is compatible with the a_list */
3713private function f_match_codecs(BSSMAP_IE_SpeechCodecList a_list, RSL_IE_ChannelMode rsl_mode)
3714return boolean {
3715 for (var integer i := 0; i < sizeof(a_list); i := i+1) {
3716 if (f_match_codec(a_list.codecElements[i], rsl_mode)) {
3717 return true;
3718 }
3719 }
3720 return false;
3721}
3722
3723/* determine BSSMAP_IE_ChannelType from *first* element of BSSMAP_FIELD_CodecElement */
Philipp Maier61f6b572018-07-06 14:03:38 +02003724function f_BSSMAP_chtype_from_codec(BSSMAP_FIELD_CodecElement a_elem)
Harald Welte60aa5762018-03-21 19:33:13 +01003725return BSSMAP_IE_ChannelType {
3726 /* FIXME: actually look at all elements of BSSMAP_IE_SpeechCodecList */
3727 var BSSMAP_IE_ChannelType ret := valueof(ts_BSSMAP_IE_ChannelType);
3728 select (a_elem.codecType) {
3729 case (GSM_FR) {
3730 ret.channelRateAndType := ChRate_TCHF;
3731 ret.speechId_DataIndicator := Spdi_TCHF_FR;
3732 }
3733 case (GSM_HR) {
3734 ret.channelRateAndType := ChRate_TCHH;
3735 ret.speechId_DataIndicator := Spdi_TCHH_HR;
3736 }
3737 case (GSM_EFR) {
3738 ret.channelRateAndType := ChRate_TCHF;
3739 ret.speechId_DataIndicator := Spdi_TCHF_EFR;
3740 }
3741 case (FR_AMR) {
3742 ret.channelRateAndType := ChRate_TCHF;
3743 ret.speechId_DataIndicator := Spdi_TCHF_AMR;
3744 }
3745 case (HR_AMR) {
3746 ret.channelRateAndType := ChRate_TCHH;
3747 ret.speechId_DataIndicator := Spdi_TCHH_AMR;
3748 }
3749 case else {
3750 setverdict(fail, "Unsupported codec ", a_elem);
Daniel Willmannafce8662018-07-06 23:11:32 +02003751 mtc.stop;
Harald Welte60aa5762018-03-21 19:33:13 +01003752 }
3753 }
3754 return ret;
3755}
3756
Harald Weltea63b9102018-03-22 20:36:16 +01003757private function f_rsl_chmod_tmpl_from_codec(BSSMAP_FIELD_CodecElement a_elem)
3758return template RSL_IE_Body {
3759 var template RSL_IE_Body mode_ie := {
3760 chan_mode := {
3761 len := ?,
3762 reserved := ?,
3763 dtx_d := ?,
3764 dtx_u := ?,
3765 spd_ind := RSL_SPDI_SPEECH,
3766 ch_rate_type := -,
3767 coding_alg_rate := -
3768 }
3769 }
3770
3771 select (a_elem.codecType) {
3772 case (GSM_FR) {
3773 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_F;
3774 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM1;
3775 }
3776 case (GSM_HR) {
3777 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_H;
3778 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM1;
3779 }
3780 case (GSM_EFR) {
3781 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_F;
3782 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM2;
3783 }
3784 case (FR_AMR) {
3785 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_F;
3786 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM3;
3787 }
3788 case (HR_AMR) {
3789 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_H;
3790 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM3;
3791 }
3792 }
3793 return mode_ie;
3794}
3795
Harald Welte60aa5762018-03-21 19:33:13 +01003796type record CodecListTest {
3797 BSSMAP_IE_SpeechCodecList codec_list,
3798 charstring id
3799}
3800type record of CodecListTest CodecListTests
3801
3802private function f_TC_assignment_codec(charstring id) runs on MSC_ConnHdlr {
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02003803 var PDU_BSSAP ass_cmd := f_gen_ass_req(g_pars.use_osmux);
3804 var template PDU_BSSAP exp_compl := f_gen_exp_compl(g_pars.use_osmux);
Harald Welte60aa5762018-03-21 19:33:13 +01003805
3806 /* puzzle together the ASSIGNMENT REQ for given codec[s] */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003807 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
Harald Welte79f3f542018-05-25 20:02:37 +02003808 ass_cmd.pdu.bssmap.assignmentRequest.codecList := g_pars.ass_codec_list;
3809 exp_compl.pdu.bssmap.assignmentComplete.speechCodec.codecElements[0] :=
3810 g_pars.ass_codec_list.codecElements[0];
Philipp Maierd0e64b02019-03-13 14:15:23 +01003811 if (isvalue(g_pars.expect_mr_s0_s7)) {
3812 exp_compl.pdu.bssmap.assignmentComplete.speechCodec.codecElements[0].s0_7 :=
3813 g_pars.expect_mr_s0_s7;
3814 }
Harald Welte79f3f542018-05-25 20:02:37 +02003815 }
Harald Welte60aa5762018-03-21 19:33:13 +01003816 ass_cmd.pdu.bssmap.assignmentRequest.channelType :=
3817 f_BSSMAP_chtype_from_codec(g_pars.ass_codec_list.codecElements[0]);
Harald Welte60aa5762018-03-21 19:33:13 +01003818 log("expecting ASS COMPL like this: ", exp_compl);
3819
3820 f_establish_fully(ass_cmd, exp_compl);
Harald Weltea63b9102018-03-22 20:36:16 +01003821
Neels Hofmeyr559d5d02021-04-16 16:50:49 +02003822 if (not g_pars.expect_channel_mode_modify) {
3823 /* Verify that the RSL-side activation actually matches our expectations */
3824 var RSL_Message rsl := f_rslem_get_last_act(RSL_PROC, 0, g_chan_nr);
Harald Weltea63b9102018-03-22 20:36:16 +01003825
Neels Hofmeyr559d5d02021-04-16 16:50:49 +02003826 var RSL_IE_Body mode_ie;
3827 if (f_rsl_find_ie(rsl, RSL_IE_CHAN_MODE, mode_ie) == false) {
3828 setverdict(fail, "Couldn't find CHAN_MODE IE");
Daniel Willmannafce8662018-07-06 23:11:32 +02003829 mtc.stop;
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02003830 }
Neels Hofmeyr559d5d02021-04-16 16:50:49 +02003831 var template RSL_IE_Body t_mode_ie := f_rsl_chmod_tmpl_from_codec(g_pars.ass_codec_list.codecElements[0]);
3832 if (not match(mode_ie, t_mode_ie)) {
3833 log("mode_ie ", mode_ie, " != t_mode_ie ", t_mode_ie);
3834 setverdict(fail, "RSL Channel Mode IE doesn't match expectation");
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02003835 }
Neels Hofmeyr559d5d02021-04-16 16:50:49 +02003836
3837 var RSL_IE_Body mr_conf;
3838 if (g_pars.expect_mr_conf_ie != omit) {
3839 if (f_rsl_find_ie(rsl, RSL_IE_MR_CONFIG, mr_conf) == false) {
3840 setverdict(fail, "Missing MR CONFIG IE in RSL Chan Activ");
3841 mtc.stop;
3842 }
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02003843 log("found RSL MR CONFIG IE: ", mr_conf);
Neels Hofmeyr559d5d02021-04-16 16:50:49 +02003844
3845 if (not match(mr_conf, g_pars.expect_mr_conf_ie)) {
3846 setverdict(fail, "RSL MR CONFIG IE does not match expectation. Expected: ",
3847 g_pars.expect_mr_conf_ie);
3848 }
3849 } else {
3850 if (f_rsl_find_ie(rsl, RSL_IE_MR_CONFIG, mr_conf) == true) {
3851 log("found RSL MR CONFIG IE: ", mr_conf);
3852 setverdict(fail, "Found MR CONFIG IE in RSL Chan Activ, expecting omit");
3853 mtc.stop;
3854 }
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02003855 }
3856 }
Harald Welte60aa5762018-03-21 19:33:13 +01003857}
3858
Philipp Maierd0e64b02019-03-13 14:15:23 +01003859private function f_TC_assignment_codec_fail(charstring id) runs on MSC_ConnHdlr {
3860
3861 var PDU_BSSAP ass_cmd := f_gen_ass_req();
3862 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
3863
3864 /* puzzle together the ASSIGNMENT REQ for given codec[s] */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003865 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
Philipp Maierd0e64b02019-03-13 14:15:23 +01003866 ass_cmd.pdu.bssmap.assignmentRequest.codecList := g_pars.ass_codec_list;
3867 }
3868 ass_cmd.pdu.bssmap.assignmentRequest.channelType :=
3869 f_BSSMAP_chtype_from_codec(g_pars.ass_codec_list.codecElements[0]);
3870 log("expecting ASS FAIL like this: ", exp_fail);
3871
3872 f_establish_fully(ass_cmd, exp_fail);
3873}
3874
Harald Welte60aa5762018-03-21 19:33:13 +01003875testcase TC_assignment_codec_fr() runs on test_CT {
Philipp Maier48604732018-10-09 15:00:37 +02003876 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte60aa5762018-03-21 19:33:13 +01003877 var MSC_ConnHdlr vc_conn;
3878
3879 f_init(1, true);
3880 f_sleep(1.0);
3881
3882 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
Harald Welte8863fa12018-05-10 20:15:27 +02003883 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01003884 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003885 f_shutdown_helper();
Harald Welte60aa5762018-03-21 19:33:13 +01003886}
3887
3888testcase TC_assignment_codec_hr() runs on test_CT {
Philipp Maier48604732018-10-09 15:00:37 +02003889 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte60aa5762018-03-21 19:33:13 +01003890 var MSC_ConnHdlr vc_conn;
3891
3892 f_init(1, true);
3893 f_sleep(1.0);
3894
3895 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR}));
Harald Welte8863fa12018-05-10 20:15:27 +02003896 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01003897 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003898 f_shutdown_helper();
Harald Welte60aa5762018-03-21 19:33:13 +01003899}
3900
3901testcase TC_assignment_codec_efr() runs on test_CT {
Philipp Maier48604732018-10-09 15:00:37 +02003902 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte60aa5762018-03-21 19:33:13 +01003903 var MSC_ConnHdlr vc_conn;
3904
3905 f_init(1, true);
3906 f_sleep(1.0);
3907
3908 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecEFR}));
Harald Welte8863fa12018-05-10 20:15:27 +02003909 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01003910 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003911 f_shutdown_helper();
Harald Welte60aa5762018-03-21 19:33:13 +01003912}
3913
Philipp Maierd0e64b02019-03-13 14:15:23 +01003914/* Allow 5,90k only (current default config) */
3915private function f_allow_amr_rate_5_90k() runs on test_CT {
Neels Hofmeyr2a5670b2020-11-25 23:39:57 +00003916 f_vty_cfg_msc(BSCVTY, 0, {
3917 "amr-config 12_2k forbidden",
3918 "amr-config 10_2k forbidden",
3919 "amr-config 7_95k forbidden",
3920 "amr-config 7_40k forbidden",
3921 "amr-config 6_70k forbidden",
3922 "amr-config 5_90k allowed",
3923 "amr-config 5_15k forbidden",
3924 "amr-config 4_75k forbidden"
3925 });
Philipp Maierd0e64b02019-03-13 14:15:23 +01003926}
3927
3928/* Allow 4,75k, 5,90k, 4,70k and 12,2k, which are the most common rates
3929 * ("Config-NB-Code = 1") */
3930private function f_allow_amr_rate_4_75k_5_90k_7_40k_12_20k() runs on test_CT {
Neels Hofmeyr2a5670b2020-11-25 23:39:57 +00003931 f_vty_cfg_msc(BSCVTY, 0, {
3932 "amr-config 12_2k allowed",
3933 "amr-config 10_2k forbidden",
3934 "amr-config 7_95k forbidden",
3935 "amr-config 7_40k allowed",
3936 "amr-config 6_70k forbidden",
3937 "amr-config 5_90k allowed",
3938 "amr-config 5_15k forbidden",
3939 "amr-config 4_75k allowed"
3940 });
Philipp Maierd0e64b02019-03-13 14:15:23 +01003941}
3942
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00003943private function f_vty_amr_start_mode_set(boolean fr, charstring startmode) runs on test_CT {
3944 var charstring tch;
3945 if (fr) {
3946 tch := "tch-f";
3947 } else {
3948 tch := "tch-h";
3949 }
3950 f_vty_cfg_bts(BSCVTY, 0, { "amr " & tch & " start-mode " & startmode });
3951}
3952
3953/* Set the AMR start-mode for this TCH back to the default configuration. */
3954private function f_vty_amr_start_mode_restore(boolean fr) runs on test_CT {
3955 f_vty_amr_start_mode_set(fr, "auto");
3956}
3957
Harald Welte60aa5762018-03-21 19:33:13 +01003958testcase TC_assignment_codec_amr_f() runs on test_CT {
Philipp Maier48604732018-10-09 15:00:37 +02003959 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte60aa5762018-03-21 19:33:13 +01003960 var MSC_ConnHdlr vc_conn;
Philipp Maier7695a0d2018-09-27 17:52:14 +02003961
3962 /* Note: This setups the codec configuration. The parameter payload in
3963 * mr_conf must be consistant with the parameter codecElements in pars
3964 * and also must match the amr-config in osmo-bsc.cfg! */
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02003965 var RSL_IE_Body mr_conf := {
3966 other := {
3967 len := 2,
3968 payload := '2804'O
3969 }
3970 };
Harald Welte60aa5762018-03-21 19:33:13 +01003971
Philipp Maier7695a0d2018-09-27 17:52:14 +02003972 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_F}));
Philipp Maier806f8f12019-03-12 12:13:41 +01003973 pars.ass_codec_list.codecElements[0].s0_7 := '00000100'B; /* 5,90k */
Philipp Maier7695a0d2018-09-27 17:52:14 +02003974 pars.ass_codec_list.codecElements[0].s8_15 := '01010111'B;
3975 pars.expect_mr_conf_ie := mr_conf;
3976
Harald Welte60aa5762018-03-21 19:33:13 +01003977 f_init(1, true);
3978 f_sleep(1.0);
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00003979 f_vty_amr_start_mode_set(true, "1");
Harald Welte60aa5762018-03-21 19:33:13 +01003980
Harald Welte8863fa12018-05-10 20:15:27 +02003981 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01003982 vc_conn.done;
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00003983
3984 f_vty_amr_start_mode_restore(true);
Vadim Yanitskiy292e5962021-01-03 14:18:47 +01003985 f_shutdown_helper();
Harald Welte60aa5762018-03-21 19:33:13 +01003986}
3987
3988testcase TC_assignment_codec_amr_h() runs on test_CT {
Philipp Maier48604732018-10-09 15:00:37 +02003989 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte60aa5762018-03-21 19:33:13 +01003990 var MSC_ConnHdlr vc_conn;
Philipp Maier7695a0d2018-09-27 17:52:14 +02003991
3992 /* See note above */
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02003993 var RSL_IE_Body mr_conf := {
3994 other := {
3995 len := 2,
3996 payload := '2804'O
3997 }
3998 };
Harald Welte60aa5762018-03-21 19:33:13 +01003999
Philipp Maier7695a0d2018-09-27 17:52:14 +02004000 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_H}));
Philipp Maier806f8f12019-03-12 12:13:41 +01004001 pars.ass_codec_list.codecElements[0].s0_7 := '00000100'B; /* 5,90k */
Philipp Maier7695a0d2018-09-27 17:52:14 +02004002 pars.ass_codec_list.codecElements[0].s8_15 := '00000111'B;
4003 pars.expect_mr_conf_ie := mr_conf;
4004
Harald Welte60aa5762018-03-21 19:33:13 +01004005 f_init(1, true);
4006 f_sleep(1.0);
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00004007 f_vty_amr_start_mode_set(false, "1");
Harald Welte60aa5762018-03-21 19:33:13 +01004008
Harald Welte8863fa12018-05-10 20:15:27 +02004009 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01004010 vc_conn.done;
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00004011
4012 f_vty_amr_start_mode_restore(false);
Vadim Yanitskiy292e5962021-01-03 14:18:47 +01004013 f_shutdown_helper();
Harald Welte60aa5762018-03-21 19:33:13 +01004014}
4015
Neels Hofmeyr559d5d02021-04-16 16:50:49 +02004016/* Establish signalling on a TCH/F lchan, and then switch to speech mode without a new Assignment. */
4017testcase TC_assignment_codec_fr_by_mode_modify() runs on test_CT {
4018 var TestHdlrParams pars := f_gen_test_hdlr_pars();
4019 var MSC_ConnHdlr vc_conn;
4020
4021 f_init(1, true);
4022 f_sleep(1.0);
4023
4024 /* By disabling all SDCCH, the MS should be given a TCH/F for signalling. Then activating an FR codec should
4025 * merely do a Channel Mode Modify, and not assign to a new lchan. f_establish_fully() already accounts for
4026 * expecting a Channel Mode Modify if the channel type is compatible. */
4027 f_disable_all_sdcch();
4028 f_disable_all_tch_h();
4029
4030 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
4031 pars.expect_channel_mode_modify := true;
4032 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
4033 vc_conn.done;
4034
4035 f_enable_all_sdcch();
4036 f_enable_all_tch();
4037 f_shutdown_helper();
4038}
4039
Neels Hofmeyr454d7922020-11-26 02:24:57 +00004040/* 'amr start-mode auto' should not keep the (unused) 'smod' bits from previous configuration */
4041testcase TC_assignment_codec_amr_startmode_cruft() runs on test_CT {
4042 var TestHdlrParams pars := f_gen_test_hdlr_pars();
4043 var MSC_ConnHdlr vc_conn;
4044
4045 var RSL_IE_Body mr_conf := {
4046 other := {
4047 len := 2,
4048 payload := '2004'O /* <- expect ICMI=0, smod=00 */
4049 }
4050 };
4051
4052 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_F}));
4053 pars.ass_codec_list.codecElements[0].s0_7 := '00000100'B; /* 5,90k */
4054 pars.ass_codec_list.codecElements[0].s8_15 := '01010111'B;
4055 pars.expect_mr_conf_ie := mr_conf;
4056
4057 f_init(1, true);
4058 f_sleep(1.0);
4059
4060 /* First set nonzero start mode bits */
4061 f_vty_amr_start_mode_set(true, "4");
4062 /* Now set to auto, and expect the startmode bits to be zero in the message, i.e. ensure that osmo-bsc does not
4063 * let the startmode bits stick around and has deterministic MultiRate config for 'start-mode auto'; that is
4064 * ensured by above '2004'O, where 'x0xx'O indicates ICMI = 0, spare = 0, smod = 00. */
4065 f_vty_amr_start_mode_set(true, "auto");
4066
4067 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
4068 vc_conn.done;
Neels Hofmeyr454d7922020-11-26 02:24:57 +00004069
4070 /* Clear the startmode bits to not affect subsequent tests, in case the bits should indeed stick around. */
4071 f_vty_amr_start_mode_set(true, "1");
4072 f_vty_amr_start_mode_restore(true);
Vadim Yanitskiy292e5962021-01-03 14:18:47 +01004073 f_shutdown_helper();
Neels Hofmeyr454d7922020-11-26 02:24:57 +00004074}
4075
Neels Hofmeyr21863562020-11-26 00:34:33 +00004076function f_TC_assignment_codec_amr(boolean fr, octetstring mrconf, bitstring s8_s0, bitstring exp_s8_s0,
4077 charstring start_mode := "1")
Philipp Maierd0e64b02019-03-13 14:15:23 +01004078runs on test_CT {
4079
4080 var TestHdlrParams pars := f_gen_test_hdlr_pars();
4081 var MSC_ConnHdlr vc_conn;
4082
4083 /* See note above */
4084 var RSL_IE_Body mr_conf := {
4085 other := {
4086 len := lengthof(mrconf),
4087 payload := mrconf
4088 }
4089 };
4090
4091 if (fr) {
4092 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_F}));
4093 } else {
4094 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_H}));
4095 }
4096 pars.ass_codec_list.codecElements[0].s0_7 := s8_s0;
4097 pars.ass_codec_list.codecElements[0].s8_15 := '00000111'B;
4098 pars.expect_mr_conf_ie := mr_conf;
4099 pars.expect_mr_s0_s7 := exp_s8_s0;
4100
4101 f_init(1, true);
4102 f_allow_amr_rate_4_75k_5_90k_7_40k_12_20k();
Neels Hofmeyr21863562020-11-26 00:34:33 +00004103 f_vty_amr_start_mode_set(fr, start_mode);
Philipp Maierd0e64b02019-03-13 14:15:23 +01004104 f_sleep(1.0);
4105
4106 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
4107 vc_conn.done;
4108 f_allow_amr_rate_5_90k();
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00004109 f_vty_amr_start_mode_restore(fr);
Philipp Maierd0e64b02019-03-13 14:15:23 +01004110}
4111
4112function f_TC_assignment_codec_amr_fail(boolean fr, bitstring s8_s0)
4113runs on test_CT {
4114
4115 var TestHdlrParams pars := f_gen_test_hdlr_pars();
4116 var MSC_ConnHdlr vc_conn;
4117
4118 if (fr) {
4119 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_F}));
4120 } else {
4121 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_H}));
4122 }
4123 pars.ass_codec_list.codecElements[0].s0_7 := s8_s0;
4124 pars.ass_codec_list.codecElements[0].s8_15 := '00000111'B;
4125
4126 f_init(1, true);
4127 f_allow_amr_rate_4_75k_5_90k_7_40k_12_20k();
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00004128 f_vty_amr_start_mode_set(fr, "1");
Philipp Maierd0e64b02019-03-13 14:15:23 +01004129 f_sleep(1.0);
4130
4131 vc_conn := f_start_handler(refers(f_TC_assignment_codec_fail), pars);
4132 vc_conn.done;
4133 f_allow_amr_rate_5_90k();
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00004134 f_vty_amr_start_mode_restore(fr);
Philipp Maierd0e64b02019-03-13 14:15:23 +01004135}
4136
4137
4138/* Set S1, we expect an AMR multirate configuration IE with all four rates
4139 * set. */
4140testcase TC_assignment_codec_amr_f_S1() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02004141 f_TC_assignment_codec_amr(true, '289520882208'O, '00000010'B, '00000010'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004142 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01004143}
4144
4145/* Set S1, we expect an AMR multirate configuration IE with the lower three
4146 * rates set. */
4147testcase TC_assignment_codec_amr_h_S1() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02004148 f_TC_assignment_codec_amr(false, '2815208820'O, '00000010'B, '00000010'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004149 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01004150}
4151
4152/* Set S1 and two other rates, we expect an AMR MULTIRATE CONFIGURATION IE with
4153 * all four rates (and only S1 set in the ASSIGNMENT COMPLETE) */
4154testcase TC_assignment_codec_amr_f_S124() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02004155 f_TC_assignment_codec_amr(true, '289520882208'O, '00010110'B, '00000010'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004156 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01004157}
4158
4159/* Set S1 and two other rates, we expect an AMR MULTIRATE CONFIGURATION IE with
4160 * all four rates (and only S1 set in the ASSIGNMENT COMPLETE) */
4161testcase TC_assignment_codec_amr_h_S124() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02004162 f_TC_assignment_codec_amr(false, '2815208820'O, '00010110'B, '00000010'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004163 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01004164}
4165
4166/* The following block of tests selects more and more rates until all four
4167 * possible rates are in the active set (full rate) */
4168testcase TC_assignment_codec_amr_f_S0() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02004169 f_TC_assignment_codec_amr(true, '2801'O, '00000001'B, '00000001'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004170 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01004171}
4172
4173testcase TC_assignment_codec_amr_f_S02() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02004174 f_TC_assignment_codec_amr(true, '28052080'O, '00000101'B, '00000101'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004175 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01004176}
4177
4178testcase TC_assignment_codec_amr_f_S024() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02004179 f_TC_assignment_codec_amr(true, '2815208820'O, '00010101'B, '00010101'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004180 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01004181}
4182
4183testcase TC_assignment_codec_amr_f_S0247() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02004184 f_TC_assignment_codec_amr(true, '289520882208'O, '10010101'B, '10010101'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004185 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01004186}
4187
4188/* The following block of tests selects more and more rates until all three
4189 * possible rates are in the active set (half rate) */
4190testcase TC_assignment_codec_amr_h_S0() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02004191 f_TC_assignment_codec_amr(false, '2801'O, '00000001'B, '00000001'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004192 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01004193}
4194
4195testcase TC_assignment_codec_amr_h_S02() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02004196 f_TC_assignment_codec_amr(false, '28052080'O, '00000101'B, '00000101'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004197 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01004198}
4199
4200testcase TC_assignment_codec_amr_h_S024() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02004201 f_TC_assignment_codec_amr(false, '2815208820'O, '00010101'B, '00010101'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004202 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01004203}
4204
4205/* The following block tests what happens when the MSC does offer rate
4206 * configurations that are not supported by the BSC. Normally such situations
4207 * should not happen because the MSC gets informed by the BSC in advance via
4208 * the L3 COMPLETE message which rates are applicable. The MSC should not try
4209 * to offer rates that are not applicable anyway. */
4210
4211testcase TC_assignment_codec_amr_h_S0247() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02004212 /* Try to include 12,2k in into the active set even though the channel
4213 * is half rate only. The BSC is expected to remove the 12,0k */
4214 f_TC_assignment_codec_amr(false, '2815208820'O, '10010101'B, '00010101'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004215 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01004216}
4217
4218testcase TC_assignment_codec_amr_f_S01234567() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02004219 /* See what happens when all rates are selected at once. Since then
4220 * Also S1 is selected, this setting will be prefered and we should
4221 * get 12.2k, 7,40k, 5,90k, and 4,75k in the active set. */
4222 f_TC_assignment_codec_amr(true, '289520882208'O, '11111111'B, '00000010'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004223 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01004224}
4225
4226testcase TC_assignment_codec_amr_f_S0234567() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02004227 /* Same as above, but with S1 missing, the MSC is then expected to
4228 * select the currently supported rates, which are also 12.2k, 7,40k,
4229 * 5,90k, and 4,75k, into the active set. */
4230 f_TC_assignment_codec_amr(true, '289520882208'O, '11111101'B, '10010101'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004231 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01004232}
4233
4234testcase TC_assignment_codec_amr_f_zero() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02004235 /* Try to select no rates at all */
4236 f_TC_assignment_codec_amr_fail(true, '00000000'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004237 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01004238}
4239
4240testcase TC_assignment_codec_amr_f_unsupp() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02004241 /* Try to select only unsupported rates */
4242 f_TC_assignment_codec_amr_fail(true, '01101000'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004243 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01004244}
4245
4246testcase TC_assignment_codec_amr_h_S7() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02004247 /* Try to select 12,2k for half rate */
4248 f_TC_assignment_codec_amr_fail(false, '10000000'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004249 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01004250}
4251
Neels Hofmeyr21863562020-11-26 00:34:33 +00004252testcase TC_assignment_codec_amr_f_start_mode_auto() runs on test_CT {
4253 f_TC_assignment_codec_amr(true, '209520882208'O, '11111111'B, '00000010'B,
4254 start_mode := "auto");
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01004255 f_shutdown_helper();
Neels Hofmeyr21863562020-11-26 00:34:33 +00004256}
4257
4258testcase TC_assignment_codec_amr_h_start_mode_auto() runs on test_CT {
4259 f_TC_assignment_codec_amr(false, '2015208820'O, '10010101'B, '00010101'B,
4260 start_mode := "auto");
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01004261 f_shutdown_helper();
Neels Hofmeyr21863562020-11-26 00:34:33 +00004262}
4263
Neels Hofmeyr3eb94562020-11-26 02:40:26 +00004264testcase TC_assignment_codec_amr_f_start_mode_4() runs on test_CT {
Vadim Yanitskiy7815f482021-01-03 17:07:37 +01004265 /* "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 +00004266 f_TC_assignment_codec_amr(true, '2b9520882208'O, '11111111'B, '00000010'B,
4267 start_mode := "4");
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01004268 f_shutdown_helper();
Neels Hofmeyr3eb94562020-11-26 02:40:26 +00004269}
4270
4271testcase TC_assignment_codec_amr_h_start_mode_4() runs on test_CT {
Vadim Yanitskiy7815f482021-01-03 17:07:37 +01004272 /* "amr tch-h modes 0 2 4" => total 3 modes and start mode 4 => '10'B on the wire */
4273 f_TC_assignment_codec_amr(false, '2a15208820'O, '10010101'B, '00010101'B,
Neels Hofmeyr3eb94562020-11-26 02:40:26 +00004274 start_mode := "4");
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01004275 f_shutdown_helper();
Neels Hofmeyr3eb94562020-11-26 02:40:26 +00004276}
4277
Philipp Maierac09bfc2019-01-08 13:41:39 +01004278private function f_disable_all_tch_f() runs on test_CT {
Philipp Maierc704a882019-01-29 15:58:52 +01004279 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 1 sub-slot 0 borken");
4280 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 2 sub-slot 0 borken");
4281 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 3 sub-slot 0 borken");
4282 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 4 sub-slot 0 borken");
Philipp Maierac09bfc2019-01-08 13:41:39 +01004283}
4284
4285private function f_disable_all_tch_h() runs on test_CT {
Philipp Maierc704a882019-01-29 15:58:52 +01004286 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 5 sub-slot 0 borken");
4287 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 5 sub-slot 1 borken");
Philipp Maierac09bfc2019-01-08 13:41:39 +01004288}
4289
4290private function f_enable_all_tch() runs on test_CT {
Philipp Maierc704a882019-01-29 15:58:52 +01004291 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 1 sub-slot 0 unused");
4292 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 2 sub-slot 0 unused");
4293 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 3 sub-slot 0 unused");
4294 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 4 sub-slot 0 unused");
4295 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 5 sub-slot 0 unused");
4296 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 5 sub-slot 1 unused");
Philipp Maierac09bfc2019-01-08 13:41:39 +01004297}
4298
Neels Hofmeyr559d5d02021-04-16 16:50:49 +02004299private function f_disable_all_sdcch() runs on test_CT {
4300 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 0 sub-slot 0 borken");
4301 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 0 sub-slot 1 borken");
4302 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 0 sub-slot 2 borken");
4303 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 0 sub-slot 3 borken");
4304}
4305
4306private function f_enable_all_sdcch() runs on test_CT {
4307 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 0 sub-slot 0 unused");
4308 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 0 sub-slot 1 unused");
4309 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 0 sub-slot 2 unused");
4310 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 0 sub-slot 3 unused");
4311}
4312
Philipp Maierac09bfc2019-01-08 13:41:39 +01004313/* Allow HR only */
4314private function f_TC_assignment_codec_xr_exhausted_req_hr(charstring id) runs on MSC_ConnHdlr {
4315 g_pars := f_gen_test_hdlr_pars();
4316 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4317 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4318 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4319 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '09'O;
4320 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '05'O;
4321 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR}));
4322 f_establish_fully(ass_cmd, exp_compl);
4323}
4324
4325/* Allow FR only */
4326private function f_TC_assignment_codec_xr_exhausted_req_fr(charstring id) runs on MSC_ConnHdlr {
4327 g_pars := f_gen_test_hdlr_pars();
4328 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4329 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4330 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4331 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '08'O;
4332 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '01'O;
4333 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
4334 f_establish_fully(ass_cmd, exp_compl);
4335}
4336
4337/* Allow HR only (expect assignment failure) */
4338private function f_TC_assignment_codec_xr_exhausted_req_hr_fail(charstring id) runs on MSC_ConnHdlr {
4339 g_pars := f_gen_test_hdlr_pars();
4340 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4341 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
4342 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4343 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '09'O;
4344 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '05'O;
4345 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR}));
4346 f_establish_fully(ass_cmd, exp_fail);
4347}
4348
4349/* Allow FR only (expect assignment failure) */
4350private function f_TC_assignment_codec_xr_exhausted_req_fr_fail(charstring id) runs on MSC_ConnHdlr {
4351 g_pars := f_gen_test_hdlr_pars();
4352 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4353 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
4354 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4355 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '08'O;
4356 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '01'O;
4357 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
4358 f_establish_fully(ass_cmd, exp_fail);
4359}
4360
4361/* Allow FR and HR, but prefer FR */
4362private function f_TC_assignment_codec_fr_exhausted_req_fr_hr(charstring id) runs on MSC_ConnHdlr {
4363 g_pars := f_gen_test_hdlr_pars();
4364 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4365 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4366 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4367 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0A'O; /* Prefer FR */
4368 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8105'O;
4369 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR, ts_CodecHR}));
4370 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000101'B; /* Expect HR */
4371 f_establish_fully(ass_cmd, exp_compl);
4372}
4373
4374/* Allow FR and HR, but prefer HR */
4375private function f_TC_assignment_codec_fr_exhausted_req_hr_fr(charstring id) runs on MSC_ConnHdlr {
4376 g_pars := f_gen_test_hdlr_pars();
4377 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4378 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4379 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4380 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0B'O; /* Prefer HR */
4381 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8501'O;
4382 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR, ts_CodecFR}));
4383 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000101'B; /* Expect HR */
4384 f_establish_fully(ass_cmd, exp_compl);
4385}
4386
4387/* Allow FR and HR, but prefer FR */
4388private function f_TC_assignment_codec_hr_exhausted_req_fr_hr(charstring id) runs on MSC_ConnHdlr {
4389 g_pars := f_gen_test_hdlr_pars();
4390 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4391 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4392 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4393 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0A'O; /* Prefer FR */
4394 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8105'O;
4395 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR, ts_CodecHR}));
4396 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000001'B; /* Expect FR */
4397 f_establish_fully(ass_cmd, exp_compl);
4398}
4399
4400/* Allow FR and HR, but prefer HR */
4401private function f_TC_assignment_codec_hr_exhausted_req_hr_fr(charstring id) runs on MSC_ConnHdlr {
4402 g_pars := f_gen_test_hdlr_pars();
4403 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4404 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4405 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4406 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0B'O; /* Prefer HR */
4407 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8501'O;
4408 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR, ts_CodecFR}));
4409 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000001'B; /* Expect FR */
4410 f_establish_fully(ass_cmd, exp_compl);
4411}
4412
4413/* Request a HR channel while all FR channels are exhausted, this is expected
4414 * to work without conflicts */
4415testcase TC_assignment_codec_fr_exhausted_req_hr() runs on test_CT {
4416 var MSC_ConnHdlr vc_conn;
4417 f_init(1, true);
4418 f_sleep(1.0);
4419 f_enable_all_tch();
4420 f_disable_all_tch_f();
4421 vc_conn := f_start_handler(refers(f_TC_assignment_codec_xr_exhausted_req_hr));
4422 vc_conn.done;
4423 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004424 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004425}
4426
4427/* Request a FR channel while all FR channels are exhausted, this is expected
4428 * to fail. */
4429testcase TC_assignment_codec_fr_exhausted_req_fr() runs on test_CT {
4430 var MSC_ConnHdlr vc_conn;
4431 f_init(1, true);
4432 f_sleep(1.0);
4433 f_enable_all_tch();
4434 f_disable_all_tch_f();
4435 vc_conn := f_start_handler(refers(f_TC_assignment_codec_xr_exhausted_req_fr_fail));
4436 vc_conn.done;
4437 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004438 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004439}
4440
4441/* Request a FR (prefered) or alternatively a HR channel while all FR channels
4442 * are exhausted, this is expected to be resolved by selecting a HR channel. */
4443testcase TC_assignment_codec_fr_exhausted_req_fr_hr() runs on test_CT {
4444 var MSC_ConnHdlr vc_conn;
4445 f_init(1, true);
4446 f_sleep(1.0);
4447 f_enable_all_tch();
4448 f_disable_all_tch_f();
4449 vc_conn := f_start_handler(refers(f_TC_assignment_codec_fr_exhausted_req_fr_hr));
4450 vc_conn.done;
4451 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004452 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004453}
4454
4455/* Request a HR (prefered) or alternatively a FR channel while all FR channels
4456 * are exhausted, this is expected to work without conflicts. */
4457testcase TC_assignment_codec_fr_exhausted_req_hr_fr() runs on test_CT {
4458 var MSC_ConnHdlr vc_conn;
4459 f_init(1, true);
4460 f_sleep(1.0);
4461 f_enable_all_tch();
4462 f_disable_all_tch_f();
4463 vc_conn := f_start_handler(refers(f_TC_assignment_codec_fr_exhausted_req_hr_fr));
4464 vc_conn.done;
4465 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004466 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004467}
4468
4469/* Request a FR channel while all HR channels are exhausted, this is expected
4470 * to work without conflicts */
4471testcase TC_assignment_codec_hr_exhausted_req_fr() runs on test_CT {
4472 var MSC_ConnHdlr vc_conn;
4473 f_init(1, true);
4474 f_sleep(1.0);
4475 f_enable_all_tch();
4476 f_disable_all_tch_h();
4477 vc_conn := f_start_handler(refers(f_TC_assignment_codec_xr_exhausted_req_fr));
4478 vc_conn.done;
4479 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004480 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004481}
4482
4483/* Request a HR channel while all HR channels are exhausted, this is expected
4484 * to fail. */
4485testcase TC_assignment_codec_hr_exhausted_req_hr() runs on test_CT {
4486 var MSC_ConnHdlr vc_conn;
4487 f_init(1, true);
4488 f_sleep(1.0);
4489 f_enable_all_tch();
4490 f_disable_all_tch_h();
4491 vc_conn := f_start_handler(refers(f_TC_assignment_codec_xr_exhausted_req_hr_fail));
4492 vc_conn.done;
4493 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004494 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004495}
4496
4497/* Request a HR (prefered) or alternatively a FR channel while all HR channels
4498 * are exhausted, this is expected to be resolved by selecting a FR channel. */
4499testcase TC_assignment_codec_hr_exhausted_req_hr_fr() runs on test_CT {
4500 var MSC_ConnHdlr vc_conn;
4501 f_init(1, true);
4502 f_sleep(1.0);
4503 f_enable_all_tch();
4504 f_disable_all_tch_h();
4505 vc_conn := f_start_handler(refers(f_TC_assignment_codec_hr_exhausted_req_hr_fr));
4506 vc_conn.done;
4507 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004508 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004509}
4510
4511/* Request a FR (prefered) or alternatively a HR channel while all HR channels
4512 * are exhausted, this is expected to work without conflicts. */
4513testcase TC_assignment_codec_hr_exhausted_req_fr_hr() runs on test_CT {
4514 var MSC_ConnHdlr vc_conn;
4515 f_init(1, true);
4516 f_sleep(1.0);
4517 f_enable_all_tch();
4518 f_disable_all_tch_h();
4519 vc_conn := f_start_handler(refers(f_TC_assignment_codec_hr_exhausted_req_fr_hr));
4520 vc_conn.done;
4521 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004522 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004523}
4524
4525/* Allow FR and HR, but prefer HR */
4526private function f_TC_assignment_codec_req_hr_fr(charstring id) runs on MSC_ConnHdlr {
4527 g_pars := f_gen_test_hdlr_pars();
4528 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4529 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4530 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4531 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0B'O; /* Prefer HR */
4532 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8501'O;
4533 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR, ts_CodecFR}));
4534 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000101'B; /* Expect HR */
4535 f_establish_fully(ass_cmd, exp_compl);
4536}
4537
4538/* Allow FR and HR, but prefer FR */
4539private function f_TC_assignment_codec_req_fr_hr(charstring id) runs on MSC_ConnHdlr {
4540 g_pars := f_gen_test_hdlr_pars();
4541 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4542 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4543 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4544 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0A'O; /* Prefer FR */
4545 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8105'O;
4546 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR, ts_CodecHR}));
4547 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000001'B; /* Expect FR */
4548 f_establish_fully(ass_cmd, exp_compl);
4549}
4550
4551/* Request a HR (prefered) or alternatively a FR channel, it is expected that
4552 * HR, which is the prefered type, is selected. */
4553testcase TC_assignment_codec_req_hr_fr() runs on test_CT {
4554 var MSC_ConnHdlr vc_conn;
4555 f_init(1, true);
4556 f_sleep(1.0);
4557 f_enable_all_tch();
4558 vc_conn := f_start_handler(refers(f_TC_assignment_codec_req_hr_fr));
4559 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004560 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004561}
4562
4563/* Request a FR (prefered) or alternatively a HR channel, it is expected that
4564 * FR, which is the prefered type, is selected. */
4565testcase TC_assignment_codec_req_fr_hr() runs on test_CT {
4566 var MSC_ConnHdlr vc_conn;
4567 f_init(1, true);
4568 f_sleep(1.0);
4569 f_enable_all_tch();
4570 vc_conn := f_start_handler(refers(f_TC_assignment_codec_req_fr_hr));
4571 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004572 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004573}
4574
Pau Espin Pedrol14475352021-07-22 15:48:16 +02004575/* request a signalling channel with all SDCCH exhausted, it is expected that a TCH will be selected */
4576private function f_TC_assignment_sdcch_exhausted_req_signalling(charstring id) runs on MSC_ConnHdlr {
4577 g_pars := f_gen_test_hdlr_pars();
4578 g_pars.ra := '02'O; /* RA containing reason=LU */
4579
4580 var MobileIdentityLV mi := valueof(ts_MI_IMSI_LV(g_pars.imsi));
4581 var PDU_ML3_MS_NW l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, mi));
4582 var octetstring l3_enc := enc_PDU_ML3_MS_NW(l3_info);
4583 var template uint3_t tsc := ?;
4584
4585 f_MscConnHdlr_init(g_pars.media_nr, host_bts, host_mgw_mgcp, FR_AMR);
4586 f_create_bssmap_exp(l3_enc);
4587 /* call helper function for CHAN_RQD -> IMM ASS ->EST_IND */
4588 RSL_Emulation.f_chan_est(g_pars.ra, l3_enc, g_pars.link_id, g_pars.fn, tsc);
4589
4590 /* we should now have a COMPL_L3 at the MSC */
4591 timer T := 10.0;
4592 T.start;
4593 alt {
4594 [] BSSAP.receive(tr_BSSMAP_ComplL3);
4595 [] T.timeout {
4596 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for COMPLETE LAYER 3 INFORMATION");
4597 }
4598 }
4599}
4600testcase TC_assignment_sdcch_exhausted_req_signalling() runs on test_CT {
4601 var MSC_ConnHdlr vc_conn;
4602 f_init(1, true);
4603 f_sleep(1.0);
4604 f_disable_all_sdcch();
4605 vc_conn := f_start_handler(refers(f_TC_assignment_sdcch_exhausted_req_signalling));
4606 vc_conn.done;
4607 f_enable_all_sdcch();
4608 f_shutdown_helper();
4609}
4610
4611/* Request a signalling channel with all SDCCH exhausted, it is
4612 expected that no TCH will be selected for signalling and assigment will fail
4613 because it's dictated by VTY config */
4614testcase TC_assignment_sdcch_exhausted_req_signalling_tch_forbidden() runs on test_CT {
4615 var RSL_Message rsl_unused, rsl_msg;
4616 var GsmRrMessage rr;
4617 f_init(1, false);
4618 f_sleep(1.0);
4619 f_vty_allow_tch_for_signalling(false, 0);
4620 f_disable_all_sdcch();
4621
4622 /* RA containing reason=LU */
4623 f_ipa_tx(0, ts_RSL_CHAN_RQD('02'O, 2342));
4624 rsl_msg := f_exp_ipa_rx(0, tr_RSL_IMM_ASSIGN(0));
4625 rr := dec_GsmRrMessage(rsl_msg.ies[1].body.full_imm_ass_info.payload);
4626 if (rr.header.message_type != IMMEDIATE_ASSIGNMENT_REJECT) {
4627 setverdict(fail, "Expected reject");
4628 }
4629
4630 f_vty_allow_tch_for_signalling(true, 0);
4631 f_enable_all_sdcch();
4632 f_shutdown_helper();
4633}
4634
4635/* Request a voice channel with all SDCCH exhausted, it is
4636 * expected that TCH channel will be allocated since the VTY option is only
4637 * aimed at signalling requests */
4638private function f_TC_assignment_sdcch_exhausted_req_voice_tch_forbidden(charstring id) runs on MSC_ConnHdlr {
4639 g_pars := f_gen_test_hdlr_pars();
4640 g_pars.ra := '43'O; /* RA containing reason=originating speech call*/
4641
4642 var MobileIdentityLV mi := valueof(ts_MI_IMSI_LV(g_pars.imsi));
4643 var PDU_ML3_MS_NW l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, mi));
4644 var octetstring l3_enc := enc_PDU_ML3_MS_NW(l3_info);
4645 var template uint3_t tsc := ?;
4646
4647 f_MscConnHdlr_init(g_pars.media_nr, host_bts, host_mgw_mgcp, FR_AMR);
4648 f_create_bssmap_exp(l3_enc);
4649 /* call helper function for CHAN_RQD -> IMM ASS ->EST_IND */
4650 RSL_Emulation.f_chan_est(g_pars.ra, l3_enc, g_pars.link_id, g_pars.fn, tsc);
4651
4652 /* we should now have a COMPL_L3 at the MSC */
4653 timer T := 10.0;
4654 T.start;
4655 alt {
4656 [] BSSAP.receive(tr_BSSMAP_ComplL3);
4657 [] T.timeout {
4658 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for COMPLETE LAYER 3 INFORMATION");
4659 }
4660 }
4661}
4662testcase TC_assignment_sdcch_exhausted_req_voice_tch_forbidden() runs on test_CT {
4663 var MSC_ConnHdlr vc_conn;
4664 f_init(1, true);
4665 f_sleep(1.0);
4666 f_vty_allow_tch_for_signalling(false, 0);
4667 f_disable_all_sdcch();
4668
4669 vc_conn := f_start_handler(refers(f_TC_assignment_sdcch_exhausted_req_voice_tch_forbidden));
4670 vc_conn.done;
4671
4672 f_vty_allow_tch_for_signalling(true, 0);
4673 f_enable_all_sdcch();
4674 f_shutdown_helper();
4675}
4676
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02004677testcase TC_assignment_osmux() runs on test_CT {
4678 var TestHdlrParams pars := f_gen_test_hdlr_pars();
4679 var MSC_ConnHdlr vc_conn;
4680
4681 /* See note above */
4682 var RSL_IE_Body mr_conf := {
4683 other := {
4684 len := 2,
4685 payload := '2804'O
4686 }
4687 };
4688
4689 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_H}));
4690 pars.ass_codec_list.codecElements[0].s0_7 := '00000100'B; /* 5,90k */
4691 pars.ass_codec_list.codecElements[0].s8_15 := '00000111'B;
4692 pars.expect_mr_conf_ie := mr_conf;
4693 pars.use_osmux := true;
4694
4695 f_init(1, true, true);
4696 f_sleep(1.0);
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00004697 f_vty_amr_start_mode_set(false, "1");
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02004698
4699 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
4700 vc_conn.done;
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00004701
4702 f_vty_amr_start_mode_restore(false);
Vadim Yanitskiy292e5962021-01-03 14:18:47 +01004703 f_shutdown_helper();
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02004704}
4705
Neels Hofmeyr92b12b72018-09-18 14:30:23 +02004706/* test the procedure of the MSC requesting a Classmark Update:
4707 * a) BSSMAP Classmark Request should result in RR CLASSMARK ENQUIRY,
4708 * b) L3 RR CLASSMARK CHANGE should result in BSSMAP CLASSMARK UPDATE */
Harald Welte898113b2018-01-31 18:32:21 +01004709private function f_tc_classmark(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02004710 g_pars := f_gen_test_hdlr_pars();
4711
Harald Weltea0630032018-03-20 21:09:55 +01004712 f_create_chan_and_exp();
Harald Welte898113b2018-01-31 18:32:21 +01004713 /* we should now have a COMPL_L3 at the MSC */
4714 BSSAP.receive(tr_BSSMAP_ComplL3);
4715
Neels Hofmeyr92b12b72018-09-18 14:30:23 +02004716 BSSAP.send(ts_BSSMAP_ClassmarkRequest);
4717 RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_CM_ENQUIRY));
4718
Harald Welte898113b2018-01-31 18:32:21 +01004719 f_rsl_send_l3(ts_RRM_CM_CHG(valueof(ts_CM2)));
4720 BSSAP.receive(tr_BSSMAP_ClassmarkUpd(?, omit));
4721 setverdict(pass);
4722}
4723testcase TC_classmark() runs on test_CT {
4724 var MSC_ConnHdlr vc_conn;
4725 f_init(1, true);
4726 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02004727 vc_conn := f_start_handler(refers(f_tc_classmark));
Harald Welte898113b2018-01-31 18:32:21 +01004728 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004729 f_shutdown_helper();
Harald Welte898113b2018-01-31 18:32:21 +01004730}
4731
Harald Welteeddf0e92020-06-21 19:42:15 +02004732/* Send a CommonID from the simulated MSC and verify that the information is used to
4733 * fill BSC-internal data structures (specifically, bsc_subscr associated with subscr_conn) */
4734private function f_tc_common_id(charstring id) runs on MSC_ConnHdlr {
4735 g_pars := f_gen_test_hdlr_pars();
4736 f_MscConnHdlr_init_vty();
4737
4738 f_create_chan_and_exp();
4739 /* we should now have a COMPL_L3 at the MSC */
4740 BSSAP.receive(tr_BSSMAP_ComplL3);
4741
4742 /* Send CommonID */
4743 BSSAP.send(ts_BSSMAP_CommonId(g_pars.imsi));
4744
4745 /* Use VTY to verify that the IMSI of the subscr_conn is set */
4746 var charstring regex := "*(IMSI: " & hex2str(g_pars.imsi) & ")*";
4747 f_vty_transceive_match_regexp_retry(BSCVTY, "show conns", regex, 0, 4, 1.0);
4748
4749 setverdict(pass);
4750}
4751testcase TC_common_id() runs on test_CT {
4752 var MSC_ConnHdlr vc_conn;
4753 f_init(1, true);
4754 f_sleep(1.0);
4755 vc_conn := f_start_handler(refers(f_tc_common_id));
4756 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004757 f_shutdown_helper();
Harald Welteeddf0e92020-06-21 19:42:15 +02004758}
4759
Harald Weltee3bd6582018-01-31 22:51:25 +01004760private function f_est_single_l3(template PDU_ML3_MS_NW l3) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02004761 g_pars := f_gen_test_hdlr_pars();
Harald Weltea0630032018-03-20 21:09:55 +01004762 f_create_chan_and_exp();
Harald Welte898113b2018-01-31 18:32:21 +01004763 /* we should now have a COMPL_L3 at the MSC */
4764 BSSAP.receive(tr_BSSMAP_ComplL3);
4765
Harald Weltee3bd6582018-01-31 22:51:25 +01004766 /* send the single message we want to send */
4767 f_rsl_send_l3(l3);
4768}
4769
4770private function f_bssap_expect_nothing(float sec := 5.00) runs on MSC_ConnHdlr {
4771 timer T := sec;
4772 var PDU_BSSAP bssap;
Harald Welte898113b2018-01-31 18:32:21 +01004773 T.start;
4774 alt {
Harald Weltee3bd6582018-01-31 22:51:25 +01004775 [] BSSAP.receive(PDU_BSSAP:?) -> value bssap {
4776 setverdict(fail, "Unexpected BSSMAP ", bssap);
Daniel Willmannafce8662018-07-06 23:11:32 +02004777 mtc.stop;
Harald Welte898113b2018-01-31 18:32:21 +01004778 }
4779 [] T.timeout {
4780 setverdict(pass);
4781 }
4782 }
4783}
4784
Harald Weltee3bd6582018-01-31 22:51:25 +01004785/* unsolicited ASSIGNMENT FAIL (without ASSIGN) from MS shouldn't bring BSC down */
4786private function f_tc_unsol_ass_fail(charstring id) runs on MSC_ConnHdlr {
4787 f_est_single_l3(ts_RRM_AssignmentFailure('00'O));
4788 f_bssap_expect_nothing();
4789}
Harald Welte898113b2018-01-31 18:32:21 +01004790testcase TC_unsol_ass_fail() runs on test_CT {
4791 var MSC_ConnHdlr vc_conn;
4792 f_init(1, true);
4793 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02004794 vc_conn := f_start_handler(refers(f_tc_unsol_ass_fail));
Harald Welte898113b2018-01-31 18:32:21 +01004795 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004796 f_shutdown_helper();
Harald Welte898113b2018-01-31 18:32:21 +01004797}
Harald Welte552620d2017-12-16 23:21:36 +01004798
Harald Welteea99a002018-01-31 20:46:43 +01004799
4800/* unsolicited ASSIGNMENT COMPLETE (without ASSIGN) from MS shouldn't bring BSC down */
4801private function f_tc_unsol_ass_compl(charstring id) runs on MSC_ConnHdlr {
Harald Weltee3bd6582018-01-31 22:51:25 +01004802 f_est_single_l3(ts_RRM_AssignmentComplete('00'O));
4803 f_bssap_expect_nothing();
Harald Welteea99a002018-01-31 20:46:43 +01004804}
4805testcase TC_unsol_ass_compl() runs on test_CT {
4806 var MSC_ConnHdlr vc_conn;
4807 f_init(1, true);
4808 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02004809 vc_conn := f_start_handler(refers(f_tc_unsol_ass_compl));
Harald Welteea99a002018-01-31 20:46:43 +01004810 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004811 f_shutdown_helper();
Harald Welteea99a002018-01-31 20:46:43 +01004812}
4813
4814
Harald Weltefbf9b5e2018-01-31 20:41:23 +01004815/* unsolicited HANDOVER FAIL (without ASSIGN) from MS shouldn't bring BSC down */
4816private function f_tc_unsol_ho_fail(charstring id) runs on MSC_ConnHdlr {
Harald Weltee3bd6582018-01-31 22:51:25 +01004817 f_est_single_l3(ts_RRM_HandoverFailure('00'O));
4818 f_bssap_expect_nothing();
Harald Weltefbf9b5e2018-01-31 20:41:23 +01004819}
Harald Weltefbf9b5e2018-01-31 20:41:23 +01004820testcase TC_unsol_ho_fail() runs on test_CT {
4821 var MSC_ConnHdlr vc_conn;
4822 f_init(1, true);
4823 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02004824 vc_conn := f_start_handler(refers(f_tc_unsol_ho_fail));
Harald Weltefbf9b5e2018-01-31 20:41:23 +01004825 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004826 f_shutdown_helper();
Harald Weltefbf9b5e2018-01-31 20:41:23 +01004827}
4828
4829
Harald Weltee3bd6582018-01-31 22:51:25 +01004830/* short message from MS should be ignored */
4831private function f_tc_err_82_short_msg(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02004832 g_pars := f_gen_test_hdlr_pars();
Harald Weltea0630032018-03-20 21:09:55 +01004833 f_create_chan_and_exp();
Harald Weltee3bd6582018-01-31 22:51:25 +01004834 /* we should now have a COMPL_L3 at the MSC */
4835 BSSAP.receive(tr_BSSMAP_ComplL3);
4836
4837 /* send short message */
4838 RSL.send(ts_RSL_DATA_IND(g_chan_nr, valueof(ts_RslLinkID_DCCH(0)), ''O));
4839 f_bssap_expect_nothing();
4840}
4841testcase TC_err_82_short_msg() runs on test_CT {
4842 var MSC_ConnHdlr vc_conn;
4843 f_init(1, true);
4844 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02004845 vc_conn := f_start_handler(refers(f_tc_err_82_short_msg));
Harald Weltee3bd6582018-01-31 22:51:25 +01004846 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004847 f_shutdown_helper();
Harald Weltee3bd6582018-01-31 22:51:25 +01004848}
4849
4850
Harald Weltee9e02e42018-01-31 23:36:25 +01004851/* 24.008 8.4 Unknown message must trigger RR STATUS */
4852private function f_tc_err_84_unknown_msg(charstring id) runs on MSC_ConnHdlr {
4853 f_est_single_l3(ts_RRM_UL_REL('00'O));
4854 timer T := 3.0
4855 alt {
4856 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_STATUS)) {
4857 setverdict(pass);
4858 }
4859 [] BSSAP.receive { setverdict(fail, "unexpected BSSAP"); }
Harald Welte458fd372018-03-21 11:26:23 +01004860 [] T.timeout { setverdict(fail, "Timeout waiting for RR STATUS"); }
Harald Weltee9e02e42018-01-31 23:36:25 +01004861 }
4862}
4863testcase TC_err_84_unknown_msg() runs on test_CT {
4864 var MSC_ConnHdlr vc_conn;
4865 f_init(1, true);
4866 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02004867 vc_conn := f_start_handler(refers(f_tc_err_84_unknown_msg));
Harald Weltee9e02e42018-01-31 23:36:25 +01004868 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004869 f_shutdown_helper();
Harald Weltee9e02e42018-01-31 23:36:25 +01004870}
4871
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004872/***********************************************************************
4873 * Handover
4874 ***********************************************************************/
4875
Harald Welte94e0c342018-04-07 11:33:23 +02004876/* execute a "bts <0-255> trx <0-255> timeslot <0-7> " command on given Dchan */
4877private function f_vty_ts_action(charstring suffix, integer bts_nr, integer trx_nr, integer ts_nr)
4878runs on test_CT {
4879 var charstring cmd := "bts "&int2str(bts_nr)&" trx "&int2str(trx_nr)&
4880 " timeslot "&int2str(ts_nr)&" ";
4881 f_vty_transceive(BSCVTY, cmd & suffix);
4882}
4883
Harald Welte261af4b2018-02-12 21:20:39 +01004884/* 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 +07004885private function f_vty_ss_action(TELNETasp_PT pt, charstring suffix,
4886 uint8_t bts_nr, uint8_t trx_nr,
4887 in RslChannelNr chan_nr)
4888{
Harald Welte261af4b2018-02-12 21:20:39 +01004889 /* FIXME: resolve those from component-global state */
4890 var integer ts_nr := chan_nr.tn;
4891 var integer ss_nr;
4892 if (ischosen(chan_nr.u.ch0)) {
4893 ss_nr := 0;
4894 } else if (ischosen(chan_nr.u.lm)) {
4895 ss_nr := chan_nr.u.lm.sub_chan;
4896 } else if (ischosen(chan_nr.u.sdcch4)) {
4897 ss_nr := chan_nr.u.sdcch4.sub_chan;
4898 } else if (ischosen(chan_nr.u.sdcch8)) {
4899 ss_nr := chan_nr.u.sdcch8.sub_chan;
4900 } else {
4901 setverdict(fail, "Invalid ChanNr ", chan_nr);
Daniel Willmannafce8662018-07-06 23:11:32 +02004902 mtc.stop;
Harald Welte261af4b2018-02-12 21:20:39 +01004903 }
4904
4905 var charstring cmd := "bts "&int2str(bts_nr)&" trx "&int2str(trx_nr)&
4906 " timeslot "&int2str(ts_nr)&" sub-slot "&int2str(ss_nr)&" ";
Vadim Yanitskiy00070722020-09-02 17:27:57 +07004907 f_vty_transceive(pt, cmd & suffix);
Harald Welte261af4b2018-02-12 21:20:39 +01004908}
4909
Neels Hofmeyr91401012019-07-11 00:42:35 +02004910/* Even though the VTY command to trigger handover takes a new BTS number as argument, behind the scenes osmo-bsc always
4911 * translates that to a target ARFCN+BSIC first. See bsc_vty.c trigger_ho_or_as(), which puts the selected BTS' neighbor
4912 * ident key (ARFCN + BSIC) in the struct passed on to handover_request(). handover_start() then resolves that to a
4913 * viable actual neighbor cell. So from the internal osmo-bsc perspective, we always request handover to an ARFCN + BSIC
4914 * pair, not really to a specific BTS number. */
Vadim Yanitskiy00070722020-09-02 17:27:57 +07004915private function f_vty_handover(TELNETasp_PT pt, uint8_t bts_nr, uint8_t trx_nr,
4916 in RslChannelNr chan_nr, uint8_t new_bts_nr)
4917{
4918 f_vty_ss_action(pt, "handover " & int2str(new_bts_nr), bts_nr, trx_nr, chan_nr);
Harald Welte261af4b2018-02-12 21:20:39 +01004919}
4920
4921/* intra-BSC hand-over between BTS0 and BTS1 */
4922private function f_tc_ho_int(charstring id) runs on MSC_ConnHdlr {
Harald Welteed848512018-05-24 22:27:58 +02004923 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4924 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte261af4b2018-02-12 21:20:39 +01004925
4926 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4927 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
4928
Harald Weltea0630032018-03-20 21:09:55 +01004929 f_establish_fully(ass_cmd, exp_compl);
Neels Hofmeyr666f0432020-07-04 00:53:07 +02004930 f_bts_0_cfg(BSCVTY, {"neighbor bts 1"});
Harald Welte261af4b2018-02-12 21:20:39 +01004931
4932 var HandoverState hs := {
4933 rr_ho_cmpl_seen := false,
4934 handover_done := false,
4935 old_chan_nr := -
4936 };
4937 /* issue hand-over command on VTY */
Vadim Yanitskiy00070722020-09-02 17:27:57 +07004938 f_vty_handover(BSCVTY, 0, 0, g_chan_nr, 1);
Harald Welte261af4b2018-02-12 21:20:39 +01004939 /* temporarily suspend DChan processing on BTS1 to avoid race with RSLEM_register */
4940 f_rslem_suspend(RSL1_PROC);
Philipp Maier3e2af5d2018-07-11 17:01:05 +02004941
4942 /* From the MGW perspective, a handover is is characterized by
4943 * performing one MDCX operation with the MGW. So we expect to see
4944 * one more MDCX during handover. */
4945 g_media.mgcp_conn[0].mdcx_seen_exp := g_media.mgcp_conn[0].crcx_seen_exp + 1;
4946
Harald Welte261af4b2018-02-12 21:20:39 +01004947 alt {
4948 [] as_handover(hs);
Harald Welte261af4b2018-02-12 21:20:39 +01004949 }
Philipp Maier3e2af5d2018-07-11 17:01:05 +02004950
Philipp Maier4dae0652018-11-12 12:03:26 +01004951 /* Since this is an internal handover we expect the BSC to inform the
4952 * MSC about the event */
4953 BSSAP.receive(tr_BSSMAP_HandoverPerformed);
4954
Philipp Maier3e2af5d2018-07-11 17:01:05 +02004955 /* Check the amount of MGCP transactions is still consistant with the
4956 * test expectation */
4957 f_check_mgcp_expectations()
Neels Hofmeyraf88d9d2021-06-21 02:14:27 +02004958
4959 /* Ensure the Channel Activation for the new channel contained the right encryption params. as_handover() set
4960 * g_chan_nr to the new lchan that was handed over to. It lives in bts 1, so look it up at RSL1_PROC. */
4961 f_verify_encr_info(f_rslem_get_last_act(RSL1_PROC, 0, g_chan_nr));
4962
Neels Hofmeyr861a4c12018-11-07 01:23:17 +01004963 f_sleep(0.5);
Harald Welte261af4b2018-02-12 21:20:39 +01004964}
4965
4966testcase TC_ho_int() runs on test_CT {
Neels Hofmeyr5f7a9df2021-06-21 01:30:43 +02004967 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte261af4b2018-02-12 21:20:39 +01004968 var MSC_ConnHdlr vc_conn;
4969 f_init(2, true);
4970 f_sleep(1.0);
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004971
4972 f_ctrs_bsc_and_bts_init();
4973
Neels Hofmeyr5f7a9df2021-06-21 01:30:43 +02004974 vc_conn := f_start_handler(refers(f_tc_ho_int), pars);
Harald Welte261af4b2018-02-12 21:20:39 +01004975 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004976
4977 /* from f_establish_fully() */
4978 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
4979 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
4980 /* from handover */
4981 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
4982 f_ctrs_bsc_and_bts_add(0, "handover:completed");
4983 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
4984 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:completed");
4985 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004986 f_shutdown_helper();
Harald Welte261af4b2018-02-12 21:20:39 +01004987}
Harald Weltee9e02e42018-01-31 23:36:25 +01004988
Oliver Smith7eabd312021-07-12 14:18:56 +02004989function 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 +02004990 var MSC_ConnHdlr vc_conn;
4991 var TestHdlrParams pars := f_gen_test_hdlr_pars();
4992 pars.encr := valueof(t_EncrParams(encr_alg, f_rnd_octstring(8), f_rnd_octstring(16)));
4993
4994 f_init(2, true);
Oliver Smith7eabd312021-07-12 14:18:56 +02004995 f_vty_encryption_a5(enc_a5);
Neels Hofmeyraf88d9d2021-06-21 02:14:27 +02004996 f_sleep(1.0);
4997
4998 f_ctrs_bsc_and_bts_init();
4999
5000 vc_conn := f_start_handler(refers(f_tc_ho_int), pars);
5001 vc_conn.done;
5002
5003 /* from f_establish_fully() */
5004 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5005 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5006 /* from handover */
5007 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5008 f_ctrs_bsc_and_bts_add(0, "handover:completed");
5009 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
5010 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:completed");
5011 f_ctrs_bsc_and_bts_verify();
Oliver Smith7eabd312021-07-12 14:18:56 +02005012 f_vty_encryption_a5_reset();
Neels Hofmeyraf88d9d2021-06-21 02:14:27 +02005013 f_shutdown_helper();
5014}
5015
5016testcase TC_ho_int_a5_0() runs on test_CT {
5017 f_tc_ho_int_a5('01'O);
5018}
5019
5020testcase TC_ho_int_a5_1() runs on test_CT {
5021 f_tc_ho_int_a5('02'O);
5022}
5023
5024testcase TC_ho_int_a5_3() runs on test_CT {
5025 f_tc_ho_int_a5('08'O);
5026}
5027
5028testcase TC_ho_int_a5_4() runs on test_CT {
Oliver Smith7eabd312021-07-12 14:18:56 +02005029 f_tc_ho_int_a5('10'O, "0 1 3 4");
Neels Hofmeyraf88d9d2021-06-21 02:14:27 +02005030}
5031
Neels Hofmeyr5f144212020-11-03 15:41:58 +00005032/* intra-BSC hand-over with CONNection FAILure and cause Radio Link Failure: check RR release cause */
5033private function f_tc_ho_int_radio_link_failure(charstring id) runs on MSC_ConnHdlr {
5034 g_pars := f_gen_test_hdlr_pars();
5035 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
5036 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Neels Hofmeyr5f144212020-11-03 15:41:58 +00005037
5038 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
5039 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
5040
5041 f_establish_fully(ass_cmd, exp_compl);
5042 f_bts_0_cfg(BSCVTY, {"neighbor bts 1"});
5043
5044 var HandoverState hs := {
5045 rr_ho_cmpl_seen := false,
5046 handover_done := false,
5047 old_chan_nr := -
5048 };
5049 /* issue hand-over command on VTY */
5050 f_vty_handover(BSCVTY, 0, 0, g_chan_nr, 1);
5051 /* temporarily suspend DChan processing on BTS1 to avoid race with RSLEM_register */
5052 f_rslem_suspend(RSL1_PROC);
5053
5054 /* From the MGW perspective, a handover is is characterized by
5055 * performing one MDCX operation with the MGW. So we expect to see
5056 * one more MDCX during handover. */
5057 g_media.mgcp_conn[0].mdcx_seen_exp := g_media.mgcp_conn[0].crcx_seen_exp + 1;
5058
5059 var RSL_Message rsl;
5060 var PDU_ML3_NW_MS l3;
5061 var RslChannelNr new_chan_nr;
5062 var GsmArfcn arfcn;
5063 RSL.receive(tr_RSL_DATA_REQ(g_chan_nr)) -> value rsl {
5064 l3 := dec_PDU_ML3_NW_MS(rsl.ies[2].body.l3_info.payload);
5065 if (not ischosen(l3.msgs.rrm.handoverCommand)) {
5066 setverdict(fail, "Expected handoverCommand");
5067 mtc.stop;
5068 }
5069 }
5070 f_ChDesc2RslChanNr(l3.msgs.rrm.handoverCommand.channelDescription2,
5071 new_chan_nr, arfcn);
5072
5073 f_rslem_register(0, new_chan_nr, RSL1_PROC);
5074
5075 /* resume processing of RSL DChan messages, which was temporarily suspended
5076 * before performing a hand-over */
5077 f_rslem_resume(RSL1_PROC);
5078 RSL1.receive(tr_RSL_IPA_CRCX(new_chan_nr));
5079
5080 f_sleep(1.0);
5081
5082 /* Handover fails because no HANDO DET appears on the new lchan,
5083 * and the old lchan reports a Radio Link Failure. */
5084 RSL.send(ts_RSL_CONN_FAIL_IND(g_chan_nr, RSL_ERR_RADIO_LINK_FAIL));
5085
5086 var PDU_BSSAP rx_clear_request;
5087 BSSAP.receive(tr_BSSMAP_ClearRequest) -> value rx_clear_request;
5088 var BssmapCause cause := bit2int(rx_clear_request.pdu.bssmap.clearRequest.cause.causeValue);
5089 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
5090
5091 var RR_Cause rr_cause := GSM48_RR_CAUSE_ABNORMAL_UNSPEC;
5092
5093 var MgcpCommand mgcp;
5094 interleave {
5095 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_RELEASE(int2oct(enum2int(rr_cause), 1)))) {}
5096 [] RSL.receive(tr_RSL_DEACT_SACCH(g_chan_nr)) {}
Neels Hofmeyr3c5127e2021-07-22 19:18:40 +02005097 [] RSL.receive(tr_RSL_RF_CHAN_REL(g_chan_nr)) {
Neels Hofmeyr5f144212020-11-03 15:41:58 +00005098 RSL.send(ts_RSL_RF_CHAN_REL_ACK(g_chan_nr));
Neels Hofmeyre680b012021-07-22 19:19:09 +02005099 f_rslem_unregister(0, g_chan_nr);
Neels Hofmeyr5f144212020-11-03 15:41:58 +00005100 }
5101 [] RSL1.receive(tr_RSL_DEACT_SACCH(new_chan_nr)) {}
Neels Hofmeyr3c5127e2021-07-22 19:18:40 +02005102 [] RSL1.receive(tr_RSL_RF_CHAN_REL(new_chan_nr)) {
Neels Hofmeyr5f144212020-11-03 15:41:58 +00005103 RSL1.send(ts_RSL_RF_CHAN_REL_ACK(new_chan_nr));
Neels Hofmeyre680b012021-07-22 19:19:09 +02005104 f_rslem_unregister(0, g_chan_nr, PT := RSL1_PROC);
Neels Hofmeyr5f144212020-11-03 15:41:58 +00005105 }
5106 [] BSSAP.receive(tr_BSSMAP_ClearComplete) {}
5107 }
5108
5109 f_sleep(0.5);
5110 setverdict(pass);
5111}
5112testcase TC_ho_int_radio_link_failure() runs on test_CT {
5113 var MSC_ConnHdlr vc_conn;
5114 f_init(2, true);
5115 f_sleep(1.0);
5116
5117 f_ctrs_bsc_and_bts_init();
5118
5119 vc_conn := f_start_handler(refers(f_tc_ho_int_radio_link_failure));
5120 vc_conn.done;
5121
5122 /* from f_establish_fully() */
5123 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5124 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5125 /* from handover */
5126 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5127 f_ctrs_bsc_and_bts_add(0, "handover:stopped");
5128 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
5129 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:stopped");
5130 f_ctrs_bsc_and_bts_verify();
5131 f_shutdown_helper();
5132}
5133
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02005134/* Expecting MGCP to DLCX the endpoint's two connections: towards BTS and towards MSC */
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02005135private function f_expect_dlcx_conns() runs on MSC_ConnHdlr {
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02005136 var MgcpCommand mgcp;
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +02005137 var template MgcpResponse mgcp_resp;
5138 var MGCP_RecvFrom mrf;
5139 var template MgcpMessage msg_resp;
5140 var template MgcpMessage msg_dlcx := {
5141 command := tr_DLCX()
5142 }
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02005143
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +02005144 if (g_pars.aoip) {
5145 MGCP.receive(tr_DLCX()) -> value mgcp {
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02005146 log("Got first DLCX: ", mgcp);
5147 MGCP.send(ts_DLCX_ACK2(mgcp.line.trans_id));
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +02005148 };
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02005149
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02005150 MGCP.receive(tr_DLCX()) -> value mgcp {
5151 log("Got second DLCX: ", mgcp);
5152 MGCP.send(ts_DLCX_ACK2(mgcp.line.trans_id));
5153 };
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +02005154 } else {
5155 /* For SCCPLite, BSC doesn't handle the MSC-side */
5156 MGCP_MULTI.receive(tr_MGCP_RecvFrom_any(msg_dlcx)) -> value mrf {
5157 log("Got first DLCX: ", mrf.msg.command);
5158 msg_resp := {
5159 response := ts_DLCX_ACK2(mrf.msg.command.line.trans_id)
5160 }
5161 MGCP_MULTI.send(t_MGCP_SendToMrf(mrf, msg_resp));
5162 };
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02005163 }
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02005164}
5165
Pau Espin Pedrol35801c32021-04-19 13:03:20 +02005166private 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 +01005167
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005168 f_bts_0_cfg(BSCVTY, {"neighbor lac 99 arfcn 123 bsic any"});
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005169 f_vty_transceive(BSCVTY, "handover any to arfcn 123 bsic any");
5170
Pau Espin Pedrol35801c32021-04-19 13:03:20 +02005171 BSSAP.receive(tr_BSSMAP_HandoverRequired(exp_oldToNewBSSIEs));
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005172
5173 f_sleep(0.5);
5174 /* The MSC negotiates Handover Request and Handover Request Ack with
5175 * the other BSS and comes back with a BSSMAP Handover Command
5176 * containing an RR Handover Command coming from the target BSS... */
5177
5178 var PDU_ML3_NW_MS rr_ho_cmd := valueof(ts_RR_HandoverCommand);
5179 log("Remote cell's RR Handover Command passed through as L3 Info: ", rr_ho_cmd);
5180 var octetstring rr_ho_cmd_enc := enc_PDU_ML3_NW_MS(rr_ho_cmd);
5181 log("Remote cell's RR Handover Command passed through as L3 Info, encoded: ", rr_ho_cmd_enc);
5182 BSSAP.send(ts_BSSMAP_HandoverCommand(rr_ho_cmd_enc));
5183
5184 /* expect the Handover Command to go out on RR */
5185 var RSL_Message rsl_ho_cmd
5186 RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, ?)) -> value rsl_ho_cmd;
5187 log("RSL Data Req went out to first BTS: ", rsl_ho_cmd);
5188 var RSL_IE_Body rsl_ho_cmd_l3;
5189 if (not f_rsl_find_ie(rsl_ho_cmd, RSL_IE_L3_INFO, rsl_ho_cmd_l3)) {
5190 log("RSL message contains no L3 Info IE, expected RR Handover Command");
5191 setverdict(fail);
5192 } else {
5193 log("Found L3 Info: ", rsl_ho_cmd_l3);
5194 if (rsl_ho_cmd_l3.l3_info.payload != rr_ho_cmd_enc) {
5195 log("FAIL: the BSC sent out a different L3 Info, not matching the RR Handover Command the other BSS forwarded.");
5196 setverdict(fail);
5197 } else {
5198 log("Success: the BSC sent out the same RR Handover Command the other BSS forwarded.");
5199 setverdict(pass);
5200 }
5201 }
5202
5203 /* When the other BSS has reported a completed handover, this side is
5204 * torn down. */
5205
5206 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_HANDOVER_SUCCESSFUL;
5207 var BssmapCause cause := enum2int(cause_val);
5208 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
5209
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02005210 f_expect_dlcx_conns();
Pau Espin Pedrol06199952021-06-15 11:30:00 +02005211
5212 interleave {
5213 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_RELEASE));
5214 [] RSL.receive(tr_RSL_DEACT_SACCH(g_chan_nr));
5215 [] RSL.receive(tr_RSL_RF_CHAN_REL(g_chan_nr));
Neels Hofmeyr8fcd8772021-07-22 16:12:57 +02005216 [] BSSAP.receive(tr_BSSMAP_ClearComplete);
Pau Espin Pedrol06199952021-06-15 11:30:00 +02005217 }
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005218 setverdict(pass);
Pau Espin Pedrol35801c32021-04-19 13:03:20 +02005219}
5220
5221private function f_tc_ho_out_of_this_bsc(charstring id) runs on MSC_ConnHdlr {
5222 g_pars := f_gen_test_hdlr_pars();
5223 var PDU_BSSAP ass_req := f_gen_ass_req();
5224 ass_req.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
5225 ass_req.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
5226 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
5227 f_establish_fully(ass_req, exp_compl);
5228
5229 f_ho_out_of_this_bsc();
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005230}
5231testcase TC_ho_out_of_this_bsc() runs on test_CT {
5232 var MSC_ConnHdlr vc_conn;
5233
5234 f_init(1, true);
5235 f_sleep(1.0);
5236
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005237 f_ctrs_bsc_and_bts_init();
5238
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005239 vc_conn := f_start_handler(refers(f_tc_ho_out_of_this_bsc));
5240 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005241
5242 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5243 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5244 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5245 f_ctrs_bsc_and_bts_add(0, "handover:completed");
5246 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
5247 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:completed");
5248 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005249 f_shutdown_helper();
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005250}
5251
Neels Hofmeyr0aa719b2020-10-12 18:43:09 +00005252private function f_mo_l3_transceive(RSL_DCHAN_PT rsl := RSL,
5253 template (value) RslLinkId link_id := ts_RslLinkID_DCCH(0),
Vadim Yanitskiy2ef6a2f2020-10-08 23:17:32 +07005254 template (present) OCT1 dlci := ?,
Vadim Yanitskiyb93aa432020-10-01 14:23:11 +07005255 octetstring l3 := '0123456789'O)
5256runs on MSC_ConnHdlr {
Neels Hofmeyr43654812020-09-25 01:35:35 +02005257 /* The old lchan and conn should still be active. See that arbitrary L3
5258 * is still going through. */
Neels Hofmeyr0aa719b2020-10-12 18:43:09 +00005259 rsl.send(ts_RSL_DATA_IND(g_chan_nr, link_id, l3));
Neels Hofmeyr43654812020-09-25 01:35:35 +02005260 var template PDU_BSSAP exp_data := {
5261 discriminator := '1'B,
5262 spare := '0000000'B,
Vadim Yanitskiyb93aa432020-10-01 14:23:11 +07005263 dlci := dlci,
5264 lengthIndicator := lengthof(l3),
Neels Hofmeyr43654812020-09-25 01:35:35 +02005265 pdu := {
5266 dtap := l3
5267 }
5268 };
5269 BSSAP.receive(exp_data);
5270 setverdict(pass);
5271}
5272
Neels Hofmeyr0aa719b2020-10-12 18:43:09 +00005273private function f_mt_l3_transceive(RSL_DCHAN_PT rsl := RSL,
5274 template (present) RslLinkId link_id := tr_RslLinkID_DCCH(0),
Vadim Yanitskiy0033a3b2020-10-01 22:21:16 +07005275 template (value) OCT1 dlci := '00'O,
5276 octetstring l3 := '0123456789'O)
5277runs on MSC_ConnHdlr {
5278 BSSAP.send(PDU_BSSAP:{
5279 discriminator := '1'B,
5280 spare := '0000000'B,
5281 dlci := dlci,
5282 lengthIndicator := lengthof(l3),
5283 pdu := {
5284 dtap := l3
5285 }
5286 });
Neels Hofmeyr0aa719b2020-10-12 18:43:09 +00005287 rsl.receive(tr_RSL_DATA_REQ(g_chan_nr, link_id, l3));
Vadim Yanitskiy0033a3b2020-10-01 22:21:16 +07005288 setverdict(pass);
5289}
5290
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005291/* BSC asks for inter-BSC HO, but the MSC decides that it won't happen and
5292 * simply never sends a BSSMAP Handover Command. */
5293private function f_tc_ho_out_fail_no_msc_response(charstring id) runs on MSC_ConnHdlr {
Daniel Willmann3b59eb52018-10-29 15:40:55 +01005294 g_pars := f_gen_test_hdlr_pars();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005295
5296 var PDU_BSSAP ass_req := f_gen_ass_req();
5297 ass_req.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
5298 ass_req.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
5299 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
5300 f_establish_fully(ass_req, exp_compl);
5301
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005302 f_bts_0_cfg(BSCVTY, {"neighbor lac 99 arfcn 123 bsic any"});
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005303 f_vty_transceive(BSCVTY, "handover any to arfcn 123 bsic any");
5304
5305 BSSAP.receive(tr_BSSMAP_HandoverRequired);
5306
5307 /* osmo-bsc should time out 10 seconds after the handover started.
5308 * Let's give it a bit extra. */
5309 f_sleep(15.0);
5310
Vadim Yanitskiy74ae5eb2020-10-01 22:13:29 +07005311 f_mo_l3_transceive();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005312 f_sleep(1.0);
5313}
5314testcase TC_ho_out_fail_no_msc_response() runs on test_CT {
5315 var MSC_ConnHdlr vc_conn;
5316
5317 f_init(1, true);
5318 f_sleep(1.0);
5319
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005320 f_ctrs_bsc_and_bts_init();
5321
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005322 vc_conn := f_start_handler(refers(f_tc_ho_out_fail_no_msc_response));
5323 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005324
5325 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5326 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5327 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5328 f_ctrs_bsc_and_bts_add(0, "handover:timeout");
5329 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
5330 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:timeout");
5331 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005332 f_shutdown_helper();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005333}
5334
5335/* BSC asks for inter-BSC HO, receives BSSMAP Handover Command, but MS reports
5336 * RR Handover Failure. */
5337private function f_tc_ho_out_fail_rr_ho_failure(charstring id) runs on MSC_ConnHdlr {
Daniel Willmann3b59eb52018-10-29 15:40:55 +01005338 g_pars := f_gen_test_hdlr_pars();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005339
5340 var PDU_BSSAP ass_req := f_gen_ass_req();
5341 ass_req.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
5342 ass_req.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
5343 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
5344 f_establish_fully(ass_req, exp_compl);
5345
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005346 f_bts_0_cfg(BSCVTY, {"neighbor lac 99 arfcn 123 bsic any"});
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005347 f_vty_transceive(BSCVTY, "handover any to arfcn 123 bsic any");
5348
5349 BSSAP.receive(tr_BSSMAP_HandoverRequired);
5350
5351 f_sleep(0.5);
5352 /* The MSC negotiates Handover Request and Handover Request Ack with
5353 * the other BSS and comes back with a BSSMAP Handover Command
5354 * containing an RR Handover Command coming from the target BSS... */
5355
5356 var PDU_ML3_NW_MS rr_ho_cmd := valueof(ts_RR_HandoverCommand);
5357 log("Remote cell's RR Handover Command passed through as L3 Info: ", rr_ho_cmd);
5358 var octetstring rr_ho_cmd_enc := enc_PDU_ML3_NW_MS(rr_ho_cmd);
5359 log("Remote cell's RR Handover Command passed through as L3 Info, encoded: ", rr_ho_cmd_enc);
5360 BSSAP.send(ts_BSSMAP_HandoverCommand(rr_ho_cmd_enc));
5361
5362 /* expect the Handover Command to go out on RR */
5363 var RSL_Message rsl_ho_cmd
5364 RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, ?)) -> value rsl_ho_cmd;
5365 log("RSL Data Req went out to first BTS: ", rsl_ho_cmd);
5366 var RSL_IE_Body rsl_ho_cmd_l3;
5367 if (not f_rsl_find_ie(rsl_ho_cmd, RSL_IE_L3_INFO, rsl_ho_cmd_l3)) {
5368 log("RSL message contains no L3 Info IE, expected RR Handover Command");
5369 setverdict(fail);
5370 } else {
5371 log("Found L3 Info: ", rsl_ho_cmd_l3);
5372 if (rsl_ho_cmd_l3.l3_info.payload != rr_ho_cmd_enc) {
5373 log("FAIL: the BSC sent out a different L3 Info, not matching the RR Handover Command the other BSS forwarded.");
5374 setverdict(fail);
5375 } else {
5376 log("Success: the BSC sent out the same RR Handover Command the other BSS forwarded.");
5377 setverdict(pass);
5378 }
5379 }
5380
5381 f_sleep(0.2);
5382 f_rsl_send_l3(ts_RRM_HandoverFailure('00'O));
5383
5384 /* Should tell the MSC about the failure */
5385 BSSAP.receive(tr_BSSMAP_HandoverFailure);
5386
5387 f_sleep(1.0);
5388
Vadim Yanitskiy74ae5eb2020-10-01 22:13:29 +07005389 f_mo_l3_transceive();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005390 f_sleep(1.0);
5391
5392 setverdict(pass);
5393 f_sleep(1.0);
5394}
5395testcase TC_ho_out_fail_rr_ho_failure() runs on test_CT {
5396 var MSC_ConnHdlr vc_conn;
5397
5398 f_init(1, true);
5399 f_sleep(1.0);
5400
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005401 f_ctrs_bsc_and_bts_init();
5402
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005403 vc_conn := f_start_handler(refers(f_tc_ho_out_fail_rr_ho_failure));
5404 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005405
5406 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5407 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5408 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5409 f_ctrs_bsc_and_bts_add(0, "handover:failed");
5410 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
5411 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:failed");
5412 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005413 f_shutdown_helper();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005414}
5415
Neels Hofmeyr10f2bfa2019-07-09 19:33:29 +02005416/* BSC asks for inter-BSC-out HO, receives BSSMAP Handover Command, but then no reply is received about HO outcome
5417 * (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 +02005418 * and the lchan is released. */
5419private function f_tc_ho_out_fail_no_result_after_ho_cmd(charstring id) runs on MSC_ConnHdlr {
Daniel Willmann3b59eb52018-10-29 15:40:55 +01005420 g_pars := f_gen_test_hdlr_pars();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005421
5422 var PDU_BSSAP ass_req := f_gen_ass_req();
5423 ass_req.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
5424 ass_req.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
5425 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
5426 f_establish_fully(ass_req, exp_compl);
5427
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005428 f_bts_0_cfg(BSCVTY, {"neighbor lac 99 arfcn 123 bsic any"});
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005429 f_vty_transceive(BSCVTY, "handover any to arfcn 123 bsic any");
5430
5431 BSSAP.receive(tr_BSSMAP_HandoverRequired);
5432
5433 f_sleep(0.5);
5434 /* The MSC negotiates Handover Request and Handover Request Ack with
5435 * the other BSS and comes back with a BSSMAP Handover Command
5436 * containing an RR Handover Command coming from the target BSS... */
5437
5438 var PDU_ML3_NW_MS rr_ho_cmd := valueof(ts_RR_HandoverCommand);
5439 log("Remote cell's RR Handover Command passed through as L3 Info: ", rr_ho_cmd);
5440 var octetstring rr_ho_cmd_enc := enc_PDU_ML3_NW_MS(rr_ho_cmd);
5441 log("Remote cell's RR Handover Command passed through as L3 Info, encoded: ", rr_ho_cmd_enc);
5442 BSSAP.send(ts_BSSMAP_HandoverCommand(rr_ho_cmd_enc));
5443
5444 /* expect the Handover Command to go out on RR */
5445 var RSL_Message rsl_ho_cmd
5446 RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, ?)) -> value rsl_ho_cmd;
5447 log("RSL Data Req went out to first BTS: ", rsl_ho_cmd);
5448 var RSL_IE_Body rsl_ho_cmd_l3;
5449 if (not f_rsl_find_ie(rsl_ho_cmd, RSL_IE_L3_INFO, rsl_ho_cmd_l3)) {
5450 log("RSL message contains no L3 Info IE, expected RR Handover Command");
5451 setverdict(fail);
5452 } else {
5453 log("Found L3 Info: ", rsl_ho_cmd_l3);
5454 if (rsl_ho_cmd_l3.l3_info.payload != rr_ho_cmd_enc) {
5455 log("FAIL: the BSC sent out a different L3 Info, not matching the RR Handover Command the other BSS forwarded.");
5456 setverdict(fail);
5457 } else {
5458 log("Success: the BSC sent out the same RR Handover Command the other BSS forwarded.");
5459 setverdict(pass);
5460 }
5461 }
5462
Neels Hofmeyr10f2bfa2019-07-09 19:33:29 +02005463 /* We get neither success nor failure report from the remote BSS. Eventually T8 times out and we run into 3GPP
5464 * TS 48.008 3.1.5.3.3 "Abnormal Conditions": Clear Request should go to the MSC, and RR should be released
5465 * after Clear Command */
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005466
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02005467 var PDU_BSSAP rx_clear_request;
Neels Hofmeyre1797aa2019-07-09 19:34:04 +02005468 BSSAP.receive(tr_BSSMAP_ClearRequest) -> value rx_clear_request;
5469 log("Got BSSMAP Clear Request");
5470 /* Instruct BSC to clear channel */
5471 var BssmapCause cause := bit2int(rx_clear_request.pdu.bssmap.clearRequest.cause.causeValue);
5472 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
5473
5474 var MgcpCommand mgcp;
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005475 interleave {
Neels Hofmeyr861a4c12018-11-07 01:23:17 +01005476 [] RSL.receive(tr_RSL_DEACT_SACCH(g_chan_nr)) {
5477 log("Got Deact SACCH");
5478 }
Harald Welte924b6ea2019-02-04 01:05:34 +01005479 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_RELEASE)) {
Neels Hofmeyr211169d2018-11-07 00:37:29 +01005480 log("Got RR Release");
5481 }
Neels Hofmeyr3c5127e2021-07-22 19:18:40 +02005482 [] RSL.receive(tr_RSL_RF_CHAN_REL(g_chan_nr)) {
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005483 log("Got RF Chan Rel");
5484 RSL.send(ts_RSL_RF_CHAN_REL_ACK(g_chan_nr));
Neels Hofmeyre680b012021-07-22 19:19:09 +02005485 f_rslem_unregister(0, g_chan_nr);
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005486 }
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005487 }
5488
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02005489 f_expect_dlcx_conns();
Neels Hofmeyr8fcd8772021-07-22 16:12:57 +02005490 BSSAP.receive(tr_BSSMAP_ClearComplete);
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02005491
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005492 setverdict(pass);
5493 f_sleep(1.0);
5494}
Neels Hofmeyrd8a602c2019-07-09 19:46:01 +02005495testcase TC_ho_out_fail_no_result_after_ho_cmd() runs on test_CT {
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005496 var MSC_ConnHdlr vc_conn;
5497
5498 f_init(1, true);
5499 f_sleep(1.0);
5500
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005501 f_ctrs_bsc_and_bts_init();
5502
Neels Hofmeyrd8a602c2019-07-09 19:46:01 +02005503 vc_conn := f_start_handler(refers(f_tc_ho_out_fail_no_result_after_ho_cmd));
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005504 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005505
5506 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5507 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5508 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5509 f_ctrs_bsc_and_bts_add(0, "handover:timeout");
5510 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
5511 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:timeout");
5512 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005513 f_shutdown_helper();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005514}
5515
Pau Espin Pedrol35801c32021-04-19 13:03:20 +02005516private 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 +01005517 /* Hack: the proper way would be to wait for the BSSMAP Handover Request ACK and extract the
5518 * actual assigned chan_nr from its L3 (RR Handover Command) message. But osmo-bsc starts acting
5519 * on the lchan even before we get a chance to evaluate the BSSMAP Handover Request ACK. So we
5520 * need to assume that osmo-bsc will activate TS 1 and already set up this lchan's RSL emulation
5521 * before we get started. */
5522 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
5523 f_rslem_register(0, new_chan_nr);
5524 g_chan_nr := new_chan_nr;
5525 f_sleep(1.0);
5526
5527 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
5528 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
5529 activate(as_Media());
5530
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005531 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Pau Espin Pedrolc08d5522021-04-16 15:40:38 +02005532 f_gen_handover_req(aoip_tla := g_pars.host_aoip_tla,
Neels Hofmeyr8ebf19c2021-06-21 05:24:01 +02005533 oldToNewBSSIEs := oldToNewBSSIEs,
5534 enc := g_pars.encr)));
Harald Welte6811d102019-04-14 22:23:14 +02005535 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005536
5537 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
5538
5539 var PDU_BSSAP rx_bssap;
5540 var octetstring ho_command_str;
5541
5542 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
Pau Espin Pedrol76ba5412019-06-10 11:00:33 +02005543
Neels Hofmeyr8ebf19c2021-06-21 05:24:01 +02005544 /* we're sure that the channel activation is done now, verify the encryption parameters in it */
5545 f_verify_encr_info(f_rslem_get_last_act(RSL_PROC, 0, g_chan_nr));
5546
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005547 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
5548 log("Received L3 Info in HO Request Ack: ", ho_command_str);
5549 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
5550 log("L3 Info in HO Request Ack is ", ho_command);
5551
5552 var GsmArfcn arfcn;
5553 var RslChannelNr actual_new_chan_nr;
5554 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
5555 actual_new_chan_nr, arfcn);
5556
5557 if (actual_new_chan_nr != new_chan_nr) {
5558 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
5559 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
5560 setverdict(fail);
5561 return;
5562 }
5563 log("Handover Command chan_nr is", actual_new_chan_nr);
5564
5565 /* Now the MSC forwards the RR Handover Command to the other BSC, which
5566 * tells the MS to handover to the new lchan. Here comes the new MS on
5567 * the new lchan with a Handover RACH: */
5568
5569 /* send handover detect */
5570
5571 RSL.send(ts_RSL_HANDO_DET(new_chan_nr));
5572
5573 BSSAP.receive(tr_BSSMAP_HandoverDetect);
5574
5575 /* send handover complete over the new channel */
5576
5577 var PDU_ML3_MS_NW l3_tx := valueof(ts_RRM_HandoverComplete('00'O));
5578 RSL.send(ts_RSL_EST_IND(new_chan_nr, valueof(ts_RslLinkID_DCCH(0)),
5579 enc_PDU_ML3_MS_NW(l3_tx)));
5580
5581 BSSAP.receive(tr_BSSMAP_HandoverComplete);
Pau Espin Pedrol35801c32021-04-19 13:03:20 +02005582 setverdict(pass);
5583}
Pau Espin Pedrolc08d5522021-04-16 15:40:38 +02005584
Pau Espin Pedrol35801c32021-04-19 13:03:20 +02005585private function f_tc_ho_into_this_bsc(charstring id) runs on MSC_ConnHdlr {
Pau Espin Pedrol9ae36d52021-06-15 17:29:43 +02005586 var template PDU_ML3_NW_MS exp_rr_rel_tmpl;
Pau Espin Pedrol35801c32021-04-19 13:03:20 +02005587 var template (omit) BSSMAP_oldToNewBSSIEs oldToNewBSSIEs := omit;
5588 if (not istemplatekind(g_pars.last_used_eutran_plmn, "omit")) {
5589 oldToNewBSSIEs := f_ts_BSSMAP_oldToNewBSSIEs(ts_BSSMAP_LastUsedEUTRANPLMNId(g_pars.last_used_eutran_plmn));
Pau Espin Pedrol9ae36d52021-06-15 17:29:43 +02005590 }
5591 if (g_pars.exp_fast_return) {
Pau Espin Pedrol35801c32021-04-19 13:03:20 +02005592 exp_rr_rel_tmpl := tr_RRM_RR_RELEASE_CellSelectInd;
Pau Espin Pedrol9ae36d52021-06-15 17:29:43 +02005593 } else {
5594 exp_rr_rel_tmpl := tr_RRM_RR_RELEASE;
Pau Espin Pedrol35801c32021-04-19 13:03:20 +02005595 }
5596 f_ho_into_this_bsc(id, oldToNewBSSIEs);
Neels Hofmeyr85bcd272021-07-22 19:14:48 +02005597 f_perform_clear(exp_rr_rel_tmpl := exp_rr_rel_tmpl);
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005598 setverdict(pass);
5599}
Pau Espin Pedrol07866632020-09-03 19:10:55 +02005600function f_tc_ho_into_this_bsc_main(TestHdlrParams pars) runs on test_CT {
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005601 var MSC_ConnHdlr vc_conn;
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005602
5603 f_init(1, true);
5604 f_sleep(1.0);
5605
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005606 f_ctrs_bsc_and_bts_init();
5607
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005608 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
5609 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005610
5611 vc_conn := f_start_handler(refers(f_tc_ho_into_this_bsc), pars);
5612 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005613
5614 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5615 f_ctrs_bsc_and_bts_add(0, "handover:completed");
5616 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:attempted");
5617 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:completed");
5618 f_ctrs_bsc_and_bts_verify();
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005619}
5620
Pau Espin Pedrol07866632020-09-03 19:10:55 +02005621testcase TC_ho_into_this_bsc() runs on test_CT {
5622 var TestHdlrParams pars := f_gen_test_hdlr_pars();
5623 f_tc_ho_into_this_bsc_main(pars);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005624 f_shutdown_helper();
Pau Espin Pedrol07866632020-09-03 19:10:55 +02005625}
5626
Neels Hofmeyr8ebf19c2021-06-21 05:24:01 +02005627function f_tc_ho_into_this_bsc_a5(OCT1 encr_alg) runs on test_CT {
5628 var TestHdlrParams pars := f_gen_test_hdlr_pars();
5629 pars.encr := valueof(t_EncrParams(encr_alg, f_rnd_octstring(8), f_rnd_octstring(16)));
5630 f_tc_ho_into_this_bsc_main(pars);
5631 f_shutdown_helper();
5632}
5633
5634testcase TC_ho_into_this_bsc_a5_0() runs on test_CT {
5635 f_tc_ho_into_this_bsc_a5('01'O);
5636}
5637
5638testcase TC_ho_into_this_bsc_a5_1() runs on test_CT {
5639 f_tc_ho_into_this_bsc_a5('02'O);
5640}
5641
5642testcase TC_ho_into_this_bsc_a5_3() runs on test_CT {
5643 f_tc_ho_into_this_bsc_a5('08'O);
5644}
5645
5646testcase TC_ho_into_this_bsc_a5_4() runs on test_CT {
5647 f_tc_ho_into_this_bsc_a5('10'O);
5648}
5649
Pau Espin Pedrol07866632020-09-03 19:10:55 +02005650testcase TC_ho_into_this_bsc_tla_v6() runs on test_CT {
5651 var TestHdlrParams pars := f_gen_test_hdlr_pars();
5652 pars.host_aoip_tla := "::6";
5653 f_tc_ho_into_this_bsc_main(pars);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005654 f_shutdown_helper();
Pau Espin Pedrol07866632020-09-03 19:10:55 +02005655}
5656
Pau Espin Pedrolc08d5522021-04-16 15:40:38 +02005657/* Similar to TC_ho_into_this_bsc, but when in SRVCC, HO Req contains "Old BSS
Pau Espin Pedrol35801c32021-04-19 13:03:20 +02005658 to New BSS Information" IE with "Last Used E-UTRAN PLMN Id", which, when the
Pau Espin Pedrolc08d5522021-04-16 15:40:38 +02005659 channel is later released (RR CHannel Release), should trigger inclusion of
5660 IE "Cell Selection Indicator after Release of all TCH and SDCCH" with E-UTRAN
5661 neighbors. */
5662testcase TC_srvcc_eutran_to_geran() runs on test_CT {
5663 var TestHdlrParams pars := f_gen_test_hdlr_pars();
5664 pars.last_used_eutran_plmn := '323454'O;
Pau Espin Pedrol9ae36d52021-06-15 17:29:43 +02005665 pars.exp_fast_return := true;
Pau Espin Pedrolc08d5522021-04-16 15:40:38 +02005666 f_tc_ho_into_this_bsc_main(pars);
Pau Espin Pedrol211a7142021-06-15 16:43:03 +02005667
5668 f_ctrs_bsc_and_bts_add(0, "srvcc:attempted");
5669 f_ctrs_bsc_and_bts_add(0, "srvcc:completed");
5670 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrolc08d5522021-04-16 15:40:38 +02005671 f_shutdown_helper();
5672}
5673
Pau Espin Pedrol9ae36d52021-06-15 17:29:43 +02005674/* Same as TC_srvcc_eutran_to_geran, but test explicitly forbiding fast return
5675 on the BTS. As a result, RR Release shouldn't contain the EUTRAN neighbor
5676 list when the channel is released. */
5677testcase TC_srvcc_eutran_to_geran_forbid_fast_return() runs on test_CT {
5678 f_init_vty();
5679 f_vty_allow_srvcc_fast_return(true, 0)
5680
5681 var TestHdlrParams pars := f_gen_test_hdlr_pars();
5682 pars.last_used_eutran_plmn := '323454'O;
5683 pars.exp_fast_return := false;
5684 f_tc_ho_into_this_bsc_main(pars);
5685 f_vty_allow_srvcc_fast_return(false, 0);
5686 f_shutdown_helper();
5687}
5688
Pau Espin Pedrol35801c32021-04-19 13:03:20 +02005689private function f_tc_srvcc_eutran_to_geran_ho_out(charstring id) runs on MSC_ConnHdlr {
5690 var template (omit) BSSMAP_oldToNewBSSIEs oldToNewBSSIEs;
5691 oldToNewBSSIEs := f_ts_BSSMAP_oldToNewBSSIEs(ts_BSSMAP_LastUsedEUTRANPLMNId(g_pars.last_used_eutran_plmn));
5692 f_ho_into_this_bsc(id, oldToNewBSSIEs);
5693 f_ho_out_of_this_bsc(oldToNewBSSIEs);
5694 setverdict(pass);
5695}
Pau Espin Pedrol9ae36d52021-06-15 17:29:43 +02005696
5697private function f_tc_srvcc_eutran_to_geran_ho_out_main(boolean disable_fast_return)
5698 runs on test_CT {
Pau Espin Pedrol35801c32021-04-19 13:03:20 +02005699 var MSC_ConnHdlr vc_conn;
5700 var TestHdlrParams pars := f_gen_test_hdlr_pars();
5701
5702 f_init(1, true);
Pau Espin Pedrol9ae36d52021-06-15 17:29:43 +02005703 if (disable_fast_return) {
5704 f_vty_allow_srvcc_fast_return(true, 0);
5705 }
Pau Espin Pedrol35801c32021-04-19 13:03:20 +02005706 f_sleep(1.0);
5707
5708 f_ctrs_bsc_and_bts_init();
5709
5710 pars.last_used_eutran_plmn := '323454'O;
5711 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
5712 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
5713
5714 vc_conn := f_start_handler(refers(f_tc_srvcc_eutran_to_geran_ho_out), pars);
5715 vc_conn.done;
5716
5717 f_ctrs_bsc_and_bts_add(0, "handover:attempted", 2);
5718 f_ctrs_bsc_and_bts_add(0, "handover:completed", 2);
5719 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:attempted", 1);
5720 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:completed", 1);
5721 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted", 1);
5722 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:completed", 1);
Pau Espin Pedrol211a7142021-06-15 16:43:03 +02005723
5724 f_ctrs_bsc_and_bts_add(0, "srvcc:attempted", 1);
5725 f_ctrs_bsc_and_bts_add(0, "srvcc:completed", 1);
Pau Espin Pedrol35801c32021-04-19 13:03:20 +02005726 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol9ae36d52021-06-15 17:29:43 +02005727
5728 if (disable_fast_return) {
5729 f_vty_allow_srvcc_fast_return(false, 0);
5730 }
Pau Espin Pedrol35801c32021-04-19 13:03:20 +02005731 f_shutdown_helper();
5732}
5733
Pau Espin Pedrol9ae36d52021-06-15 17:29:43 +02005734/* First, HO into BSC from EUTRAN (SRVCC): HO Request contains "Old BSS to New
5735 BSS Information" IE with "Last Used E-UTRAN PLMN Id".
5736 Second, HO to another BSC: HO Required contains "Old BSS to New BSS Information"
5737 IE with "Last Used E-UTRAN PLMN Id" from first step. */
5738testcase TC_srvcc_eutran_to_geran_ho_out() runs on test_CT {
5739 f_tc_srvcc_eutran_to_geran_ho_out_main(false);
5740}
5741/* Validate subsequent intra-GSM-HO works the same (with OldBSSToNewBSSInfo IE)
5742 * independently of fast-reture allowed/forbidden in local BTS */
5743testcase TC_srvcc_eutran_to_geran_ho_out_forbid_fast_return() runs on test_CT {
5744 f_tc_srvcc_eutran_to_geran_ho_out_main(true);
5745}
5746
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005747private function f_tc_ho_in_fail_msc_clears(charstring id) runs on MSC_ConnHdlr {
5748 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
5749 f_rslem_register(0, new_chan_nr);
5750 g_chan_nr := new_chan_nr;
5751 f_sleep(1.0);
5752
5753 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
5754 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
5755 activate(as_Media());
5756
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005757 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005758 f_gen_handover_req()));
Harald Welte6811d102019-04-14 22:23:14 +02005759 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +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;
5767
5768 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
5769 log("Received L3 Info in HO Request Ack: ", ho_command_str);
5770 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
5771 log("L3 Info in HO Request Ack is ", ho_command);
5772
5773 var GsmArfcn arfcn;
5774 var RslChannelNr actual_new_chan_nr;
5775 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
5776 actual_new_chan_nr, arfcn);
5777
5778 if (actual_new_chan_nr != new_chan_nr) {
5779 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
5780 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
5781 setverdict(fail);
5782 return;
5783 }
5784 log("Handover Command chan_nr is", actual_new_chan_nr);
5785
Neels Hofmeyr61ca08d2019-05-06 23:52:22 +02005786 /* For deterministic test results, give some time for the MGW endpoint to be configured */
5787 f_sleep(1.0);
5788
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005789 /* Now the MSC forwards the RR Handover Command to the other BSC, which
5790 * tells the MS to handover to the new lchan. In this case, the MS
5791 * reports a Handover Failure to the old BSS, which forwards a BSSMAP
5792 * Handover Failure to the MSC. The procedure according to 3GPP TS
5793 * 48.008 3.1.5.3.2 "Handover Failure" is then that the MSC sends a
5794 * BSSMAP Clear Command: */
5795
5796 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_RADIO_INTERFACE_FAILURE_REVERSION;
5797 var BssmapCause cause := enum2int(cause_val);
5798 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
5799
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02005800 f_expect_dlcx_conns();
Neels Hofmeyr8fcd8772021-07-22 16:12:57 +02005801 BSSAP.receive(tr_BSSMAP_ClearComplete);
5802
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005803 setverdict(pass);
5804 f_sleep(1.0);
5805
5806 setverdict(pass);
5807}
5808testcase TC_ho_in_fail_msc_clears() runs on test_CT {
5809 var MSC_ConnHdlr vc_conn;
5810 var TestHdlrParams pars := f_gen_test_hdlr_pars();
5811
5812 f_init(1, true);
5813 f_sleep(1.0);
5814
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005815 f_ctrs_bsc_and_bts_init();
5816
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005817 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
5818 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005819
5820 vc_conn := f_start_handler(refers(f_tc_ho_in_fail_msc_clears), pars);
5821 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005822
5823 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5824 f_ctrs_bsc_and_bts_add(0, "handover:stopped");
5825 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:attempted");
5826 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:stopped");
5827 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005828 f_shutdown_helper();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005829}
5830
5831private function f_tc_ho_in_fail_msc_clears_after_ho_detect(charstring id) runs on MSC_ConnHdlr {
5832 /* Hack: the proper way would be to wait for the BSSMAP Handover Request ACK and extract the
5833 * actual assigned chan_nr from its L3 (RR Handover Command) message. But osmo-bsc starts acting
5834 * on the lchan even before we get a chance to evaluate the BSSMAP Handover Request ACK. So we
5835 * need to assume that osmo-bsc will activate TS 1 and already set up this lchan's RSL emulation
5836 * before we get started. */
5837 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
5838 f_rslem_register(0, new_chan_nr);
5839 g_chan_nr := new_chan_nr;
5840 f_sleep(1.0);
5841
5842 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
5843 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
5844 activate(as_Media());
5845
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005846 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005847 f_gen_handover_req()));
Harald Welte6811d102019-04-14 22:23:14 +02005848 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005849
5850 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
5851
5852 var PDU_BSSAP rx_bssap;
5853 var octetstring ho_command_str;
5854
5855 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
5856
5857 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
5858 log("Received L3 Info in HO Request Ack: ", ho_command_str);
5859 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
5860 log("L3 Info in HO Request Ack is ", ho_command);
5861
5862 var GsmArfcn arfcn;
5863 var RslChannelNr actual_new_chan_nr;
5864 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
5865 actual_new_chan_nr, arfcn);
5866
5867 if (actual_new_chan_nr != new_chan_nr) {
5868 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
5869 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
5870 setverdict(fail);
5871 return;
5872 }
5873 log("Handover Command chan_nr is", actual_new_chan_nr);
5874
5875 /* Now the MSC forwards the RR Handover Command to the other BSC, which
5876 * tells the MS to handover to the new lchan. Here comes the new MS on
5877 * the new lchan with a Handover RACH: */
5878
5879 /* send handover detect */
5880
5881 RSL.send(ts_RSL_HANDO_DET(new_chan_nr));
5882
5883 BSSAP.receive(tr_BSSMAP_HandoverDetect);
5884
5885 /* The MSC chooses to clear the connection now, maybe we got the
5886 * Handover RACH on the new cell but the MS still signaled Handover
5887 * Failure to the old BSS? */
5888
5889 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_RADIO_INTERFACE_FAILURE_REVERSION;
5890 var BssmapCause cause := enum2int(cause_val);
5891 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
5892
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02005893 f_expect_dlcx_conns();
Neels Hofmeyr8fcd8772021-07-22 16:12:57 +02005894 BSSAP.receive(tr_BSSMAP_ClearComplete);
5895
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005896 f_sleep(1.0);
5897}
5898testcase TC_ho_in_fail_msc_clears_after_ho_detect() runs on test_CT {
5899 var MSC_ConnHdlr vc_conn;
5900 var TestHdlrParams pars := f_gen_test_hdlr_pars();
5901
5902 f_init(1, true);
5903 f_sleep(1.0);
5904
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005905 f_ctrs_bsc_and_bts_init();
5906
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005907 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
5908 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005909
5910 vc_conn := f_start_handler(refers(f_tc_ho_in_fail_msc_clears_after_ho_detect), pars);
5911 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005912
5913 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5914 f_ctrs_bsc_and_bts_add(0, "handover:stopped");
5915 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:attempted");
5916 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:stopped");
5917 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005918 f_shutdown_helper();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005919}
5920
5921/* The new BSS's lchan times out before the MSC decides that handover failed. */
5922private function f_tc_ho_in_fail_no_detect(charstring id) runs on MSC_ConnHdlr {
5923 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
5924 f_rslem_register(0, new_chan_nr);
5925 g_chan_nr := new_chan_nr;
5926 f_sleep(1.0);
5927
5928 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
5929 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
5930 activate(as_Media());
5931
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005932 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005933 f_gen_handover_req()));
Harald Welte6811d102019-04-14 22:23:14 +02005934 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005935
5936 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
5937
5938 var PDU_BSSAP rx_bssap;
5939 var octetstring ho_command_str;
5940
5941 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
5942
5943 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
5944 log("Received L3 Info in HO Request Ack: ", ho_command_str);
5945 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
5946 log("L3 Info in HO Request Ack is ", ho_command);
5947
5948 var GsmArfcn arfcn;
5949 var RslChannelNr actual_new_chan_nr;
5950 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
5951 actual_new_chan_nr, arfcn);
5952
5953 if (actual_new_chan_nr != new_chan_nr) {
5954 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
5955 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
5956 setverdict(fail);
5957 return;
5958 }
5959 log("Handover Command chan_nr is", actual_new_chan_nr);
5960
5961 /* Now the MSC forwards the RR Handover Command to the other BSC, which
5962 * tells the MS to handover to the new lchan. But the MS never shows up
5963 * on the new lchan. */
5964
5965 BSSAP.receive(tr_BSSMAP_HandoverFailure);
5966
5967 /* Did osmo-bsc also send a Clear Request? */
5968 timer T := 0.5;
5969 T.start;
5970 alt {
5971 [] BSSAP.receive(tr_BSSMAP_ClearRequest);
5972 [] T.timeout { }
5973 }
5974
5975 /* MSC plays along with a Clear Command (no matter whether osmo-bsc
5976 * asked for it, this is a Handover Failure after all). */
5977
5978 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_RADIO_INTERFACE_FAILURE_REVERSION;
5979 var BssmapCause cause := enum2int(cause_val);
5980 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
5981
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02005982 f_expect_dlcx_conns();
Neels Hofmeyr8fcd8772021-07-22 16:12:57 +02005983 BSSAP.receive(tr_BSSMAP_ClearComplete);
5984
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005985 f_sleep(1.0);
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005986}
5987testcase TC_ho_in_fail_no_detect() runs on test_CT {
5988 var MSC_ConnHdlr vc_conn;
5989 var TestHdlrParams pars := f_gen_test_hdlr_pars();
5990
5991 f_init(1, true);
5992 f_sleep(1.0);
5993
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005994 f_ctrs_bsc_and_bts_init();
5995
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005996 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
5997 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005998
5999 vc_conn := f_start_handler(refers(f_tc_ho_in_fail_no_detect), pars);
6000 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006001
6002 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
6003 f_ctrs_bsc_and_bts_add(0, "handover:error");
6004 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:attempted");
6005 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:error");
6006 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006007 f_shutdown_helper();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01006008}
6009
6010/* Same as f_tc_ho_in_fail_no_detect, but MSC fails to send a Clear Command */
6011private function f_tc_ho_in_fail_no_detect2(charstring id) runs on MSC_ConnHdlr {
6012 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
6013 f_rslem_register(0, new_chan_nr);
6014 g_chan_nr := new_chan_nr;
6015 f_sleep(1.0);
6016
6017 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
6018 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
6019 activate(as_Media());
6020
Neels Hofmeyr90f80962020-06-12 16:16:55 +02006021 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01006022 f_gen_handover_req()));
Harald Welte6811d102019-04-14 22:23:14 +02006023 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01006024
6025 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
6026
6027 var PDU_BSSAP rx_bssap;
6028 var octetstring ho_command_str;
6029
6030 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
6031
6032 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
6033 log("Received L3 Info in HO Request Ack: ", ho_command_str);
6034 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
6035 log("L3 Info in HO Request Ack is ", ho_command);
6036
6037 var GsmArfcn arfcn;
6038 var RslChannelNr actual_new_chan_nr;
6039 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
6040 actual_new_chan_nr, arfcn);
6041
6042 if (actual_new_chan_nr != new_chan_nr) {
6043 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
6044 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
6045 setverdict(fail);
6046 return;
6047 }
6048 log("Handover Command chan_nr is", actual_new_chan_nr);
6049
6050 /* Now the MSC forwards the RR Handover Command to the other BSC, which
6051 * tells the MS to handover to the new lchan. But the MS never shows up
6052 * on the new lchan. */
6053
6054 BSSAP.receive(tr_BSSMAP_HandoverFailure);
6055
6056 /* MSC plays dumb and sends no Clear Command */
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01006057 var PDU_BSSAP rx_clear_request;
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02006058
6059 BSSAP.receive(tr_BSSMAP_ClearRequest) -> value rx_clear_request {
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01006060 var BssmapCause cause := bit2int(rx_clear_request.pdu.bssmap.clearRequest.cause.causeValue);
6061 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
6062 };
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02006063 f_expect_dlcx_conns();
Neels Hofmeyr8fcd8772021-07-22 16:12:57 +02006064 BSSAP.receive(tr_BSSMAP_ClearComplete);
6065
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01006066 f_sleep(1.0);
6067}
6068testcase TC_ho_in_fail_no_detect2() runs on test_CT {
6069 var MSC_ConnHdlr vc_conn;
6070 var TestHdlrParams pars := f_gen_test_hdlr_pars();
6071
6072 f_init(1, true);
6073 f_sleep(1.0);
6074
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006075 f_ctrs_bsc_and_bts_init();
6076
Neels Hofmeyr90f80962020-06-12 16:16:55 +02006077 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
6078 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01006079
6080 vc_conn := f_start_handler(refers(f_tc_ho_in_fail_no_detect2), pars);
6081 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006082
6083 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
6084 f_ctrs_bsc_and_bts_add(0, "handover:error");
6085 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:attempted");
6086 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:error");
6087 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006088 f_shutdown_helper();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01006089}
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01006090
Neels Hofmeyr91401012019-07-11 00:42:35 +02006091type record of charstring Commands;
6092
Neels Hofmeyr666f0432020-07-04 00:53:07 +02006093private function f_bts_0_cfg(TELNETasp_PT pt, Commands cmds := {})
Neels Hofmeyr91401012019-07-11 00:42:35 +02006094{
Neels Hofmeyr666f0432020-07-04 00:53:07 +02006095 f_vty_enter_cfg_bts(pt, 0);
Neels Hofmeyr91401012019-07-11 00:42:35 +02006096 for (var integer i := 0; i < sizeof(cmds); i := i+1) {
Neels Hofmeyr666f0432020-07-04 00:53:07 +02006097 f_vty_transceive(pt, cmds[i]);
Neels Hofmeyr91401012019-07-11 00:42:35 +02006098 }
Neels Hofmeyr666f0432020-07-04 00:53:07 +02006099 f_vty_transceive(pt, "end");
Neels Hofmeyr91401012019-07-11 00:42:35 +02006100}
6101
Pau Espin Pedrolc675b612020-01-09 19:55:40 +01006102private function f_cs7_inst_0_cfg(TELNETasp_PT pt, Commands cmds := {})
6103{
6104 f_vty_enter_cfg_cs7_inst(pt, 0);
6105 for (var integer i := 0; i < sizeof(cmds); i := i+1) {
6106 f_vty_transceive(pt, cmds[i]);
6107 }
6108 f_vty_transceive(pt, "end");
6109}
6110
Neels Hofmeyr91401012019-07-11 00:42:35 +02006111private function f_probe_for_handover(charstring log_label,
6112 charstring log_descr,
6113 charstring handover_vty_cmd,
6114 boolean expect_handover,
6115 boolean is_inter_bsc_handover := false)
6116runs on MSC_ConnHdlr
6117{
Neels Hofmeyrb3fc8982020-05-11 00:16:42 +02006118 /* We're going to thwart any and all handover attempts, just be ready to handle (and ignore) handover target
6119 * lchans to be established on bts 1 or bts 2. */
6120 f_rslem_suspend(RSL1_PROC);
6121 f_rslem_suspend(RSL2_PROC);
6122
Neels Hofmeyr91401012019-07-11 00:42:35 +02006123 var RSL_Message rsl;
6124
6125 var charstring log_msg := " (expecting handover)"
6126 if (not expect_handover) {
6127 log_msg := " (expecting NO handover)";
6128 }
6129 log("f_probe_for_handover starting: " & log_label & ": " & log_descr & log_msg);
6130 f_vty_transceive(BSCVTY, handover_vty_cmd);
6131
Neels Hofmeyr91401012019-07-11 00:42:35 +02006132 timer T := 2.0;
6133 T.start;
6134
6135 alt {
6136 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr)) -> value rsl {
6137 var PDU_ML3_NW_MS l3 := dec_PDU_ML3_NW_MS(rsl.ies[2].body.l3_info.payload);
6138 log("Rx L3 from net: ", l3);
6139 if (ischosen(l3.msgs.rrm.handoverCommand)) {
6140 var RslChannelNr new_chan_nr;
6141 var GsmArfcn arfcn;
6142 f_ChDesc2RslChanNr(l3.msgs.rrm.handoverCommand.channelDescription2,
6143 new_chan_nr, arfcn);
6144 log("Handover to new chan ", new_chan_nr, " on ARFCN ", arfcn);
6145 log(l3.msgs.rrm.handoverCommand);
6146
6147 /* Need to register for new lchan on new BTS -- it's either bts 1 or bts 2. It doesn't really
6148 * matter on which BTS it really is, we're not going to follow through an entire handover
6149 * anyway. */
6150 f_rslem_register(0, new_chan_nr, RSL1_PROC);
6151 f_rslem_resume(RSL1_PROC);
6152 f_rslem_register(0, new_chan_nr, RSL2_PROC);
6153 f_rslem_resume(RSL2_PROC);
6154
6155 if (expect_handover and not is_inter_bsc_handover) {
6156 setverdict(pass);
6157 log("f_probe_for_handover(" & log_label & "): Got RSL Handover Command as expected.");
6158 } else {
6159 setverdict(fail, "f_probe_for_handover(" & log_label & "): Expected none, but got RSL Handover Command. "
6160 & log_label & ": " & log_descr);
6161 }
6162
6163 log("f_probe_for_handover(" & log_label & "): Ending the test: Handover Failure stops the procedure.");
6164 /* osmo-bsc has triggered Handover. That's all we need to know for this test, reply with
6165 * Handover Failure. */
6166 f_rsl_send_l3(ts_RRM_HandoverFailure('00'O));
6167
6168 /* target BTS is told to release lchan again; don't care which BTS nor what messages. */
6169 f_sleep(0.5);
6170 RSL1.clear;
6171 RSL2.clear;
6172 log("f_probe_for_handover(" & log_label & "): done (got RSL Handover Command)");
6173 break;
6174 } else {
6175 repeat;
6176 }
6177 }
6178 [] BSSAP.receive(tr_BSSMAP_HandoverRequired) {
6179 if (expect_handover and is_inter_bsc_handover) {
6180 setverdict(pass);
6181 log("f_probe_for_handover(" & log_label & "): Got BSSMAP Handover Required as expected.");
6182 } else {
6183 setverdict(fail, "f_probe_for_handover(" & log_label & "): Expected none, but got BSSMAP Handover Required. "
6184 & log_label & ": " & log_descr);
6185 }
6186
6187 log("f_probe_for_handover(" & log_label & "): done (got BSSMAP Handover Required)");
6188
6189 /* Note: f_tc_ho_neighbor_config_start() sets T7, the timeout for BSSMAP Handover Required, to
6190 * 1 second. There is no legal way to quickly abort a handover after a BSSMAP Handover Required,
6191 * setting a short timeout and waiting is the only way. */
6192 log("f_probe_for_handover(" & log_label & "): waiting for inter-BSC HO to time out...");
6193 f_sleep(1.5);
6194 log("f_probe_for_handover(" & log_label & "): ...done");
6195
6196 break;
6197 }
6198 [] T.timeout {
6199 if (expect_handover) {
6200 setverdict(fail, "f_probe_for_handover(" & log_label & "): Expected Handover, but got none. "
6201 & log_label & ": " & log_descr);
6202 } else {
6203 setverdict(pass);
6204 log("f_probe_for_handover(" & log_label & "): Got no Handover, as expected.");
6205 }
6206 log("f_probe_for_handover(" & log_label & "): done (got no Handover)");
6207 break;
6208 }
6209 }
6210
6211 f_rslem_resume(RSL1_PROC);
6212 f_rslem_resume(RSL2_PROC);
6213 f_sleep(3.0);
6214 RSL.clear;
6215
6216 log("f_probe_for_handover(" & log_label & "): done clearing");
6217}
6218
6219/* Test the effect of various neighbor configuration scenarios:
6220 *
6221 * To avoid complexity, block off any actual handover operation, and always remain on the lchan at bts 0.
6222 * Reconfigure the neighbors for bts 0, trigger a Handover, and probe whether osmo-bsc does or doesn't start HO.
6223 */
6224private function f_tc_ho_neighbor_config_start() runs on MSC_ConnHdlr {
6225 g_pars := f_gen_test_hdlr_pars();
6226 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
6227 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Neels Hofmeyr91401012019-07-11 00:42:35 +02006228
6229 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
6230 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
6231
6232 /* Establish lchan at bts 0 */
6233 f_establish_fully(ass_cmd, exp_compl);
6234
6235 /* Shorten the inter-BSC Handover timeout, to not wait so long for inter-BSC Handovers */
6236 f_vty_enter_cfg_network(BSCVTY);
6237 f_vty_transceive(BSCVTY, "timer T7 1");
6238 f_vty_transceive(BSCVTY, "end");
6239}
6240
6241private function f_tc_ho_neighbor_config_1(charstring id) runs on MSC_ConnHdlr {
6242 f_tc_ho_neighbor_config_start();
6243
6244 /*
6245 * bts 0 ARFCN 871 BSIC 10
6246 * bts 1 ARFCN 871 BSIC 11
6247 * bts 2 ARFCN 871 BSIC 12
6248 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
6249 */
6250
6251 log("f_tc_ho_neighbor_config: 1. No 'neighbor' config");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02006252 f_bts_0_cfg(BSCVTY, {"no neighbors"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02006253 f_probe_for_handover("1.a", "HO to bts 1 works, implicitly listed as neighbor (legacy behavior when none are configured)",
6254 "handover any to arfcn 871 bsic 11",
6255 true);
6256
6257 f_probe_for_handover("1.b", "HO to unknown cell does not start",
6258 "handover any to arfcn 13 bsic 39",
6259 false);
6260
6261 f_probe_for_handover("1.c", "HO to 871-12 is ambiguous = error",
6262 "handover any to arfcn 871 bsic 12",
6263 false);
6264
6265 f_probe_for_handover("1.d", "HO to 871-11 still works (verify that this test properly cleans up)",
6266 "handover any to arfcn 871 bsic 11",
6267 true);
6268}
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006269testcase TC_ho_neighbor_config_1() runs on test_CT {
6270 var MSC_ConnHdlr vc_conn;
6271 f_init(3, true, guard_timeout := 60.0);
6272 f_sleep(1.0);
6273 f_ctrs_bsc_and_bts_init();
6274 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_1));
6275 vc_conn.done;
6276
6277 /* f_tc_ho_neighbor_config_start() */
6278 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
6279 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
6280
6281 /* 1.a */
6282 /* "failed" means a handover was triggered and started (which is all this test aims for) and the test ended the
6283 * handover quickly by sending a Handover Failure message. */
6284 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
6285 f_ctrs_bsc_and_bts_add(0, "handover:failed");
6286 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
6287 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:failed");
6288
6289 /* 1.b */
6290 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
6291 f_ctrs_bsc_and_bts_add(0, "handover:error");
6292
6293 /* 1.c */
6294 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
6295 f_ctrs_bsc_and_bts_add(0, "handover:error");
6296
6297 /* 1.d */
6298 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
6299 f_ctrs_bsc_and_bts_add(0, "handover:failed");
6300 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
6301 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:failed");
6302
6303 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006304 f_shutdown_helper();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006305}
6306
Neels Hofmeyr91401012019-07-11 00:42:35 +02006307private function f_tc_ho_neighbor_config_2(charstring id) runs on MSC_ConnHdlr {
6308 f_tc_ho_neighbor_config_start();
6309
6310 /*
6311 * bts 0 ARFCN 871 BSIC 10
6312 * bts 1 ARFCN 871 BSIC 11
6313 * bts 2 ARFCN 871 BSIC 12
6314 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
6315 */
6316
6317 log("f_tc_ho_neighbor_config: 2. explicit local neighbor: 'neighbor bts 1'");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02006318 f_bts_0_cfg(BSCVTY, {"neighbor bts 1"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02006319 f_sleep(0.5);
6320
6321 f_probe_for_handover("2.a", "HO to bts 1 works, explicitly listed as neighbor",
6322 "handover any to arfcn 871 bsic 11",
6323 true);
6324
6325 f_probe_for_handover("2.b", "HO to bts 2 doesn't work, not listed as neighbor",
6326 "handover any to arfcn 871 bsic 12",
6327 false);
6328}
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006329testcase TC_ho_neighbor_config_2() runs on test_CT {
6330 var MSC_ConnHdlr vc_conn;
6331 f_init(3, true, guard_timeout := 50.0);
6332 f_sleep(1.0);
6333 f_ctrs_bsc_and_bts_init();
6334 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_2));
6335 vc_conn.done;
6336
6337 /* f_tc_ho_neighbor_config_start() */
6338 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
6339 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
6340
6341 /* 2.a */
6342 /* "failed" means a handover was triggered and started (which is all this test aims for) and the test ended the
6343 * handover quickly by sending a Handover Failure message. */
6344 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
6345 f_ctrs_bsc_and_bts_add(0, "handover:failed");
6346 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
6347 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:failed");
6348
6349 /* 2.b */
6350 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
6351 f_ctrs_bsc_and_bts_add(0, "handover:error");
6352
6353 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006354 f_shutdown_helper();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006355}
6356
Neels Hofmeyr91401012019-07-11 00:42:35 +02006357private function f_tc_ho_neighbor_config_3(charstring id) runs on MSC_ConnHdlr {
6358 f_tc_ho_neighbor_config_start();
6359
6360 /*
6361 * bts 0 ARFCN 871 BSIC 10
6362 * bts 1 ARFCN 871 BSIC 11
6363 * bts 2 ARFCN 871 BSIC 12
6364 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
6365 */
6366
6367 log("f_tc_ho_neighbor_config: 3. explicit local neighbor: 'neighbor bts 2'");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02006368 f_bts_0_cfg(BSCVTY, {"no neighbors", "neighbor bts 2"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02006369 f_sleep(0.5);
6370
6371 f_probe_for_handover("3.a", "HO to bts 1 doesn't work, not listed as neighbor",
6372 "handover any to arfcn 871 bsic 11",
6373 false);
6374 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",
6375 "handover any to arfcn 871 bsic 12",
6376 true);
6377}
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006378testcase TC_ho_neighbor_config_3() runs on test_CT {
6379 var MSC_ConnHdlr vc_conn;
6380 f_init(3, true, guard_timeout := 50.0);
6381 f_sleep(1.0);
6382 f_ctrs_bsc_and_bts_init();
6383 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_3));
6384 vc_conn.done;
6385
6386 /* f_tc_ho_neighbor_config_start() */
6387 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
6388 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
6389
6390 /* 3.a */
6391 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
6392 f_ctrs_bsc_and_bts_add(0, "handover:error");
6393
6394 /* 3.b */
6395 /* "failed" means a handover was triggered and started (which is all this test aims for) and the test ended the
6396 * handover quickly by sending a Handover Failure message. */
6397 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
6398 f_ctrs_bsc_and_bts_add(0, "handover:failed");
6399 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
6400 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:failed");
6401
6402 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006403 f_shutdown_helper();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006404}
6405
Neels Hofmeyr91401012019-07-11 00:42:35 +02006406private function f_tc_ho_neighbor_config_4(charstring id) runs on MSC_ConnHdlr {
6407 f_tc_ho_neighbor_config_start();
6408
6409 /*
6410 * bts 0 ARFCN 871 BSIC 10
6411 * bts 1 ARFCN 871 BSIC 11
6412 * bts 2 ARFCN 871 BSIC 12
6413 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
6414 */
6415
6416 log("f_tc_ho_neighbor_config: 4. explicit remote neighbor: 'neighbor lac 99 arfcn 123 bsic 45'");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02006417 f_bts_0_cfg(BSCVTY, {"no neighbors", "neighbor lac 99 arfcn 123 bsic 45"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02006418 f_sleep(0.5);
6419
6420 f_probe_for_handover("4.a", "HO to bts 1 doesn't work, not listed as neighbor",
6421 "handover any to arfcn 871 bsic 11",
6422 false);
6423 f_probe_for_handover("4.b", "HO to bts 2 doesn't work, not listed as neighbor",
6424 "handover any to arfcn 871 bsic 12",
6425 false);
6426 f_probe_for_handover("4.c", "HO to 123-45 triggers inter-BSC HO",
6427 "handover any to arfcn 123 bsic 45",
6428 true, true);
6429}
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006430testcase TC_ho_neighbor_config_4() runs on test_CT {
6431 var MSC_ConnHdlr vc_conn;
6432 f_init(3, true, guard_timeout := 50.0);
6433 f_sleep(1.0);
6434 f_ctrs_bsc_and_bts_init();
6435 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_4));
6436 vc_conn.done;
6437
6438 /* f_tc_ho_neighbor_config_start() */
6439 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
6440 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
6441
6442 /* 4.a */
6443 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
6444 f_ctrs_bsc_and_bts_add(0, "handover:error");
6445
6446 /* 4.b */
6447 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
6448 f_ctrs_bsc_and_bts_add(0, "handover:error");
6449
6450 /* 4.c */
6451 /* "timeout" means a handover was triggered and started (which is all this test aims for) and the test ended the
6452 * handover quickly by timing out after the Handover Required message */
6453 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
6454 f_ctrs_bsc_and_bts_add(0, "handover:timeout");
6455 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
6456 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:timeout");
6457
6458 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006459 f_shutdown_helper();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006460}
6461
Neels Hofmeyr91401012019-07-11 00:42:35 +02006462private function f_tc_ho_neighbor_config_5(charstring id) runs on MSC_ConnHdlr {
6463 f_tc_ho_neighbor_config_start();
6464
6465 /*
6466 * bts 0 ARFCN 871 BSIC 10
6467 * bts 1 ARFCN 871 BSIC 11
6468 * bts 2 ARFCN 871 BSIC 12
6469 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
6470 */
6471
6472 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 +02006473 f_bts_0_cfg(BSCVTY, {"no neighbors", "neighbor lac 99 arfcn 871 bsic 12"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02006474 f_sleep(0.5);
6475
6476 f_probe_for_handover("5.a", "HO to 871-12 triggers inter-BSC HO (ignoring local cells with same ARFCN+BSIC)",
6477 "handover any to arfcn 871 bsic 12",
6478 true, true);
6479}
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006480testcase TC_ho_neighbor_config_5() runs on test_CT {
6481 var MSC_ConnHdlr vc_conn;
6482 f_init(3, true);
6483 f_sleep(1.0);
6484 f_ctrs_bsc_and_bts_init();
6485 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_5));
6486 vc_conn.done;
6487
6488 /* f_tc_ho_neighbor_config_start() */
6489 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
6490 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
6491
6492 /* 5 */
6493 /* "timeout" means a handover was triggered and started (which is all this test aims for) and the test ended the
6494 * handover quickly by timing out after the Handover Required message */
6495 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
6496 f_ctrs_bsc_and_bts_add(0, "handover:timeout");
6497 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
6498 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:timeout");
6499
6500 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006501 f_shutdown_helper();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006502}
6503
Neels Hofmeyr91401012019-07-11 00:42:35 +02006504private function f_tc_ho_neighbor_config_6(charstring id) runs on MSC_ConnHdlr {
6505 f_tc_ho_neighbor_config_start();
6506
6507 /*
6508 * bts 0 ARFCN 871 BSIC 10
6509 * bts 1 ARFCN 871 BSIC 11
6510 * bts 2 ARFCN 871 BSIC 12
6511 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
6512 */
6513
6514 log("f_tc_ho_neighbor_config: 6. config error: explicit local and remote neighbors with ambiguous ARFCN+BSIC:"
6515 & " 'neighbor bts 2; neighbor lac 99 arfcn 871 bsic 12'");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02006516 f_bts_0_cfg(BSCVTY, {"no neighbors", "neighbor bts 2", "neighbor lac 99 arfcn 871 bsic 12"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02006517 f_sleep(0.5);
6518
6519 f_probe_for_handover("6.a", "HO to 871-12 is ambiguous = error",
6520 "handover any to arfcn 871 bsic 12",
6521 false);
6522}
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006523testcase TC_ho_neighbor_config_6() runs on test_CT {
6524 var MSC_ConnHdlr vc_conn;
6525 f_init(3, true);
6526 f_sleep(1.0);
6527 f_ctrs_bsc_and_bts_init();
6528 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_6));
6529 vc_conn.done;
6530
6531 /* f_tc_ho_neighbor_config_start() */
6532 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
6533 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
6534
6535 /* 6.a */
6536 /* "timeout" means a handover was triggered and started (which is all this test aims for) and the test ended the
6537 * handover quickly by timing out after the Handover Required message */
6538 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
6539 f_ctrs_bsc_and_bts_add(0, "handover:error");
6540
6541 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006542 f_shutdown_helper();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006543}
6544
Neels Hofmeyr91401012019-07-11 00:42:35 +02006545private function f_tc_ho_neighbor_config_7(charstring id) runs on MSC_ConnHdlr {
6546 f_tc_ho_neighbor_config_start();
6547
6548 /*
6549 * bts 0 ARFCN 871 BSIC 10
6550 * bts 1 ARFCN 871 BSIC 11
6551 * bts 2 ARFCN 871 BSIC 12
6552 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
6553 */
6554
6555 log("f_tc_ho_neighbor_config: 7. explicit local and remote neighbors:"
6556 & " 'neighbor bts 2; neighbor lac 99 arfcn 123 bsic 45'");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02006557 f_bts_0_cfg(BSCVTY, {"no neighbors", "neighbor bts 2", "neighbor lac 99 arfcn 123 bsic 45"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02006558 f_sleep(0.5);
6559
6560 f_probe_for_handover("7.a", "HO to 871-12 does HO to bts 2",
6561 "handover any to arfcn 871 bsic 12",
6562 true);
6563 f_probe_for_handover("7.b", "HO to 123-45 triggers inter-BSC HO",
6564 "handover any to arfcn 123 bsic 45",
6565 true, true);
6566}
Neels Hofmeyr91401012019-07-11 00:42:35 +02006567testcase TC_ho_neighbor_config_7() runs on test_CT {
6568 var MSC_ConnHdlr vc_conn;
Neels Hofmeyrf2b88032020-06-16 00:35:04 +02006569 f_init(3, true, guard_timeout := 50.0);
Neels Hofmeyr91401012019-07-11 00:42:35 +02006570 f_sleep(1.0);
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006571 f_ctrs_bsc_and_bts_init();
Neels Hofmeyr91401012019-07-11 00:42:35 +02006572 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_7));
6573 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006574
6575 /* f_tc_ho_neighbor_config_start() */
6576 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
6577 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
6578
6579 /* 7.a */
6580 /* "failed" means a handover was triggered and started (which is all this test aims for) and the test ended the
6581 * handover quickly by sending a Handover Failure message. */
6582 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
6583 f_ctrs_bsc_and_bts_add(0, "handover:failed");
6584 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
6585 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:failed");
6586
6587 /* 7.b */
6588 /* "timeout" means a handover was triggered and started (which is all this test aims for) and the test ended the
6589 * handover quickly by timing out after the Handover Required message */
6590 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
6591 f_ctrs_bsc_and_bts_add(0, "handover:timeout");
6592 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
6593 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:timeout");
6594
6595 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006596 f_shutdown_helper();
Neels Hofmeyr91401012019-07-11 00:42:35 +02006597}
6598
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01006599/* OS#3041: Open and close N connections in a normal fashion, and expect no
6600 * BSSMAP Reset just because of that. */
6601testcase TC_bssap_rlsd_does_not_cause_bssmap_reset() runs on test_CT {
6602 var default d;
6603 var integer i;
6604 var DchanTuple dt;
6605
6606 f_init();
6607
6608 /* Wait for initial BSSMAP Reset to pass */
6609 f_sleep(4.0);
6610
6611 d := activate(no_bssmap_reset());
6612
6613 /* Setup up a number of connections and RLSD them again from the MSC
6614 * side. In the buggy behavior, the fourth one triggers BSSMAP Reset.
6615 * Let's do it some more times for good measure. */
Harald Weltec3260d92018-06-11 17:48:16 +02006616 for (i := 0; i < 4; i := i+1) {
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01006617 /* Since we're doing a lot of runs, give each one a fresh
6618 * T_guard from the top. */
6619 T_guard.start;
6620
6621 /* Setup a BSSAP connection and clear it right away. This is
6622 * the MSC telling the BSC about a planned release, it's not an
6623 * erratic loss of a connection. */
Harald Weltea1897182018-06-11 13:53:09 +02006624 dt := f_est_dchan(int2oct(i,1), 23+i, '00010203040506'O);
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01006625
6626 /* MSC disconnects (RLSD). */
6627 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
6628 }
6629
6630 /* In the buggy behavior, a timeout of 2 seconds happens between above
6631 * trigger (logs "SIGTRAN connection down, reconnecting...") and the
6632 * actual BSSMAP Reset. Wait a bit longer just to make sure. */
6633 f_sleep(4.0);
6634
6635 deactivate(d);
6636 f_shutdown_helper();
6637}
Harald Welte552620d2017-12-16 23:21:36 +01006638
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01006639/* OS#3041: Open and close N connections in a normal fashion, and expect no
6640 * BSSMAP Reset just because of that. Invoke the release by a BSSMAP Clear from
6641 * the MSC. */
6642testcase TC_bssmap_clear_does_not_cause_bssmap_reset() runs on test_CT {
6643 var default d;
6644 var integer i;
6645 var DchanTuple dt;
6646 var BSSAP_N_DATA_ind rx_di;
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01006647 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_CALL_CONTROL;
6648 var BssmapCause cause := enum2int(cause_val);
6649
6650 f_init();
6651
6652 /* Wait for initial BSSMAP Reset to pass */
6653 f_sleep(4.0);
6654
6655 d := activate(no_bssmap_reset());
6656
6657 /* Setup up a number of connections and RLSD them again from the MSC
6658 * side. In the buggy behavior, the fourth one triggers BSSMAP Reset.
6659 * Let's do it some more times for good measure. */
6660 for (i := 0; i < 8; i := i+1) {
6661 /* Since we're doing a lot of runs, give each one a fresh
6662 * T_guard from the top. */
6663 T_guard.start;
6664
6665 /* Setup a BSSAP connection and clear it right away. This is
6666 * the MSC telling the BSC about a planned release, it's not an
6667 * erratic loss of a connection. */
Harald Weltea1897182018-06-11 13:53:09 +02006668 dt := f_est_dchan(int2oct(i,1), 23+i, '00010203040506'O);
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01006669
6670 /* Instruct BSC to clear channel */
6671 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
6672
6673 /* expect BSC to disable the channel */
Harald Welte641fcbe2018-06-14 10:58:35 +02006674 f_exp_chan_rel_and_clear(dt, 0);
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01006675 }
6676
6677 /* In the buggy behavior, a timeout of 2 seconds happens between above
6678 * trigger (logs "SIGTRAN connection down, reconnecting...") and the
6679 * actual BSSMAP Reset. Wait a bit longer just to make sure. */
6680 f_sleep(4.0);
6681
6682 deactivate(d);
6683 f_shutdown_helper();
6684}
6685
Neels Hofmeyrfd445c32018-03-09 15:39:31 +01006686/* OS#3041: Open and close N connections in a normal fashion, and expect no
6687 * BSSMAP Reset just because of that. Close connections from the MS side with a
6688 * Release Ind on RSL. */
6689testcase TC_ms_rel_ind_does_not_cause_bssmap_reset() runs on test_CT {
6690 var default d;
6691 var integer i;
6692 var DchanTuple dt;
6693 var BSSAP_N_DATA_ind rx_di;
Neels Hofmeyrfd445c32018-03-09 15:39:31 +01006694 var integer j;
6695
6696 f_init();
6697
6698 /* Wait for initial BSSMAP Reset to pass */
6699 f_sleep(4.0);
6700
6701 d := activate(no_bssmap_reset());
6702
6703 /* Setup up a number of connections and RLSD them again from the MSC
6704 * side. In the buggy behavior, the fourth one triggers BSSMAP Reset.
6705 * Let's do it some more times for good measure. */
6706 for (i := 0; i < 8; i := i+1) {
6707 /* Since we're doing a lot of runs, give each one a fresh
6708 * T_guard from the top. */
6709 T_guard.start;
6710
6711 /* Setup a BSSAP connection and clear it right away. This is
6712 * the MSC telling the BSC about a planned release, it's not an
6713 * erratic loss of a connection. */
6714 dt := f_est_dchan('23'O, 23, '00010203040506'O);
6715
6716 /* simulate RLL REL IND */
6717 f_ipa_tx(0, ts_RSL_REL_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0))));
6718
6719 /* expect Clear Request on MSC side */
6720 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearRequest)) -> value rx_di;
6721
6722 /* Instruct BSC to clear channel */
6723 var BssmapCause cause := bit2int(rx_di.userData.pdu.bssmap.clearRequest.cause.causeValue);
6724 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
6725
6726 /* expect BSC to disable the channel */
Harald Welte641fcbe2018-06-14 10:58:35 +02006727 f_exp_chan_rel_and_clear(dt, 0);
Neels Hofmeyrfd445c32018-03-09 15:39:31 +01006728 }
6729
6730 /* In the buggy behavior, a timeout of 2 seconds happens between above
6731 * trigger (logs "SIGTRAN connection down, reconnecting...") and the
6732 * actual BSSMAP Reset. Wait a bit longer just to make sure. */
6733 f_sleep(4.0);
6734
6735 deactivate(d);
6736 f_shutdown_helper();
6737}
6738
Harald Welte94e0c342018-04-07 11:33:23 +02006739/***********************************************************************
6740 * IPA style dynamic PDCH
6741 ***********************************************************************/
6742
6743private function f_dyn_ipa_pdch_act(integer bts_nr, integer trx_nr, integer ts_nr,
6744 template (omit) RSL_Cause nack := omit)
6745runs on test_CT {
6746 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(ts_nr));
6747 var RSL_Message rsl_unused;
6748 /* ask BSC via VTY to activate a given IPA style chan as PDCH */
6749 f_vty_ts_action("pdch activate", bts_nr, trx_nr, ts_nr);
6750 /* expect the BSC to issue the related RSL command */
6751 rsl_unused := f_exp_ipa_rx(0, tr_RSL_IPA_PDCH_ACT(chan_nr));
6752 if (istemplatekind(nack, "omit")) {
6753 /* respond with a related acknowledgement */
6754 f_ipa_tx(0, ts_RSL_IPA_PDCH_ACT_ACK(chan_nr, ts_RSL_IE_FrameNumber(2342)));
6755 } else {
6756 f_ipa_tx(0, ts_RSL_IPA_PDCH_ACT_NACK(chan_nr, valueof(nack)));
6757 }
6758}
6759
6760private function f_dyn_ipa_pdch_deact(integer bts_nr, integer trx_nr, integer ts_nr,
6761 template (omit) RSL_Cause nack := omit)
6762runs on test_CT {
6763 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(ts_nr));
6764 var RSL_Message rsl_unused;
6765 /* ask BSC via VTY to activate a given IPA style chan as PDCH */
6766 f_vty_ts_action("pdch deactivate", bts_nr, trx_nr, ts_nr);
6767 /* expect the BSC to issue the related RSL command */
6768 rsl_unused := f_exp_ipa_rx(0, tr_RSL_IPA_PDCH_DEACT(chan_nr));
6769 if (istemplatekind(nack, "omit")) {
6770 /* respond with a related acknowledgement */
6771 f_ipa_tx(0, ts_RSL_IPA_PDCH_DEACT_ACK(chan_nr));
6772 } else {
6773 f_ipa_tx(0, ts_RSL_IPA_PDCH_DEACT_NACK(chan_nr, valueof(nack)));
6774 }
6775}
6776
6777private function f_ts_dyn_mode_get(integer bts_nr, integer trx_nr, integer ts_nr)
6778runs on test_CT return charstring {
6779 var charstring cmd, resp;
6780 cmd := "show timeslot "&int2str(bts_nr)&" "&int2str(trx_nr)&" "&int2str(ts_nr);
Stefan Sperlingcff13562018-11-13 15:24:06 +01006781 return f_vty_transceive_match_regexp_retry(BSCVTY, cmd, "*\((*)\)*", 0, 4, 1.0);
Harald Welte94e0c342018-04-07 11:33:23 +02006782}
6783
6784private function f_ts_dyn_mode_assert(integer bts_nr, integer trx_nr, integer ts_nr,
6785 template charstring exp)
6786runs on test_CT {
6787 var charstring mode := f_ts_dyn_mode_get(bts_nr, trx_nr, ts_nr);
6788 if (not match(mode, exp)) {
6789 setverdict(fail, "Unexpected TS Mode: ", mode);
Daniel Willmannafce8662018-07-06 23:11:32 +02006790 mtc.stop;
Harald Welte94e0c342018-04-07 11:33:23 +02006791 }
6792}
6793
6794private function f_ts_set_chcomb(integer bts_nr, integer trx_nr, integer ts_nr, charstring chcomb)
6795runs on test_CT {
6796 f_vty_enter_cfg_ts(BSCVTY, bts_nr, trx_nr, ts_nr);
6797 f_vty_transceive(BSCVTY, "phys_chan_config " & chcomb);
6798 f_vty_transceive(BSCVTY, "end");
6799}
6800
Pau Espin Pedrol0953bf82021-07-09 13:20:19 +02006801
6802private function f_ts_reset_chcomb(integer bts_nr) runs on test_CT {
6803 var integer i;
6804 for (i := 0; i < 8; i := i + 1) {
6805 f_ts_set_chcomb(bts_nr, 0, i, phys_chan_config[i]);
6806 }
6807}
6808
Harald Welte94e0c342018-04-07 11:33:23 +02006809private const charstring TCHF_MODE := "TCH/F mode";
6810private const charstring TCHH_MODE := "TCH/H mode";
6811private const charstring PDCH_MODE := "PDCH mode";
6812private const charstring NONE_MODE := "NONE mode";
Pau Espin Pedrol5b381082021-06-28 17:14:03 +02006813private const charstring SDCCH8_MODE := "SDCCH8 mode";
Harald Welte94e0c342018-04-07 11:33:23 +02006814
6815/* Test IPA PDCH activation / deactivation triggered by VTY */
6816testcase TC_dyn_pdch_ipa_act_deact() runs on test_CT {
6817 var RSL_Message rsl_unused;
6818
6819 /* change Timeslot 6 before f_init() starts RSL */
6820 f_init_vty();
6821 f_ts_set_chcomb(0, 0, 6, "TCH/F_PDCH");
6822 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
6823
6824 f_init(1, false);
6825 f_sleep(1.0);
6826
6827 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(6));
6828
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02006829 log("TCH/F_PDCH pchan starts out in TCH/F mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02006830 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
6831 /* The BSC will activate the dynamic PDCH by default, so confirm that */
6832 rsl_unused := f_exp_ipa_rx(0, tr_RSL_IPA_PDCH_ACT(chan_nr));
6833 f_ipa_tx(0, ts_RSL_IPA_PDCH_ACT_ACK(chan_nr, ts_RSL_IE_FrameNumber(2342)));
6834 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02006835 log("TCH/F_PDCH pchan, PDCH ACT was ACKed, so now in PDCH mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02006836 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, PDCH_MODE);
6837
6838 /* De-activate it via VTY */
6839 f_dyn_ipa_pdch_deact(0, 0, chan_nr.tn);
6840 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02006841 log("TCH/F_PDCH pchan, PDCH DEACT via VTY, so now back in TCH/F mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02006842 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
6843
6844 /* re-activate it via VTY */
6845 f_dyn_ipa_pdch_act(0, 0, chan_nr.tn);
6846 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02006847 log("TCH/F_PDCH pchan, PDCH ACT via VTY, so now in PDCH mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02006848 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, PDCH_MODE);
6849
6850 /* and finally de-activate it again */
6851 f_dyn_ipa_pdch_deact(0, 0, chan_nr.tn);
6852 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02006853 log("TCH/F_PDCH pchan, PDCH DEACT via VTY, so now back in TCH/F mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02006854 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
6855
Neels Hofmeyr887e8f12018-06-27 01:01:55 +02006856 /* clean up config */
6857 f_ts_set_chcomb(0, 0, 6, "PDCH");
6858
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006859 f_shutdown_helper();
Harald Welte94e0c342018-04-07 11:33:23 +02006860}
6861
6862/* Test IPA PDCH activation NACK */
6863testcase TC_dyn_pdch_ipa_act_nack() runs on test_CT {
6864 var RSL_Message rsl_unused;
6865
6866 /* change Timeslot 6 before f_init() starts RSL */
6867 f_init_vty();
6868 f_ts_set_chcomb(0, 0, 6, "TCH/F_PDCH");
6869 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
6870
6871 f_init(1, false);
6872 f_sleep(1.0);
6873
6874 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(6));
6875
6876 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
6877 /* The BSC will activate the dynamic PDCH by default, so confirm that */
6878 rsl_unused := f_exp_ipa_rx(0, tr_RSL_IPA_PDCH_ACT(chan_nr));
6879 f_ipa_tx(0, ts_RSL_IPA_PDCH_ACT_ACK(chan_nr, ts_RSL_IE_FrameNumber(2342)));
6880 f_sleep(1.0);
6881 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, PDCH_MODE);
6882
6883 /* De-activate it via VTY */
6884 f_dyn_ipa_pdch_deact(0, 0, chan_nr.tn);
6885 f_sleep(1.0);
6886 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
6887
6888 /* re-activate it via VTY, but fail that; check BSC still assumes TCH/F mode */
6889 f_dyn_ipa_pdch_act(0, 0, chan_nr.tn, RSL_ERR_EQUIPMENT_FAIL);
6890 f_sleep(1.0);
6891 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
6892
Neels Hofmeyr887e8f12018-06-27 01:01:55 +02006893 /* clean up config */
6894 f_ts_set_chcomb(0, 0, 6, "PDCH");
6895
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006896 f_shutdown_helper();
Harald Welte94e0c342018-04-07 11:33:23 +02006897}
6898
6899
6900/***********************************************************************
6901 * Osmocom style dynamic PDCH
6902 ***********************************************************************/
6903
6904private function f_dyn_osmo_pdch_act(integer bts_nr, integer trx_nr, integer ts_nr,
6905 template (omit) RSL_Cause nack := omit)
6906runs on test_CT {
6907 var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(ts_nr));
6908 var RSL_Message rsl_unused;
Pau Espin Pedrol64adf372021-06-28 16:25:47 +02006909 /* ask BSC via VTY to activate a given OSMO style chan as PDCH */
Harald Welte94e0c342018-04-07 11:33:23 +02006910 /* FIXME: no VTY command to activate Osmocom PDCH !! */
6911 /* expect the BSC to issue the related RSL command */
6912 rsl_unused := f_exp_ipa_rx(0, tr_RSL_CHAN_ACT(chan_nr, ?));
6913 if (istemplatekind(nack, "omit")) {
6914 /* respond with a related acknowledgement */
6915 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, 2342));
6916 } else {
6917 f_ipa_tx(0, ts_RSL_CHAN_ACT_NACK(chan_nr, valueof(nack)));
6918 }
6919}
6920
6921private function f_dyn_osmo_pdch_deact(integer bts_nr, integer trx_nr, integer ts_nr,
6922 template (omit) RSL_Cause nack := omit)
6923runs on test_CT {
6924 var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(ts_nr));
6925 var RSL_Message rsl_unused;
Pau Espin Pedrol64adf372021-06-28 16:25:47 +02006926 /* ask BSC via VTY to activate a given OSMO style chan as PDCH */
Harald Welte94e0c342018-04-07 11:33:23 +02006927 /* FIXME: no VTY command to activate Osmocom PDCH !! */
6928 /* expect the BSC to issue the related RSL command */
6929 rsl_unused := f_exp_ipa_rx(0, tr_RSL_RF_CHAN_REL(chan_nr));
6930 if (istemplatekind(nack, "omit")) {
6931 /* respond with a related acknowledgement */
6932 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(chan_nr));
6933 } else {
6934 //f_ipa_tx(0, ts_RSL_RF_CHAN_REL_NACK(chan_nr, valueof(nack)));
6935 }
6936}
6937
6938/* Test Osmocom dyn PDCH activation / deactivation triggered by VTY */
6939testcase TC_dyn_pdch_osmo_act_deact() runs on test_CT {
6940 var RSL_Message rsl_unused;
6941
6942 /* change Timeslot 6 before f_init() starts RSL */
6943 f_init_vty();
6944 f_ts_set_chcomb(0, 0, 6, "TCH/F_TCH/H_PDCH");
6945 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
6946
6947 f_init(1, false);
6948 f_sleep(1.0);
6949
6950 var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(6));
6951
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02006952 log("TCH/F_TCH/H_PDCH pchan starts out in disabled mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02006953 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, NONE_MODE);
6954 /* The BSC will activate the dynamic PDCH by default, so confirm that */
6955 rsl_unused := f_exp_ipa_rx(0, tr_RSL_CHAN_ACT_PDCH(chan_nr, ?));
6956
6957 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, 2342));
6958 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02006959 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 +02006960 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, PDCH_MODE);
6961
Neels Hofmeyr887e8f12018-06-27 01:01:55 +02006962 /* clean up config */
6963 f_ts_set_chcomb(0, 0, 6, "PDCH");
6964
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006965 f_shutdown_helper();
Harald Welte94e0c342018-04-07 11:33:23 +02006966}
6967
6968/* Test Osmocom dyn PDCH activation NACK behavior */
6969testcase TC_dyn_pdch_osmo_act_nack() runs on test_CT {
6970 var RSL_Message rsl_unused;
6971
6972 /* change Timeslot 6 before f_init() starts RSL */
6973 f_init_vty();
6974 f_ts_set_chcomb(0, 0, 6, "TCH/F_TCH/H_PDCH");
6975 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
6976
6977 f_init(1, false);
6978 f_sleep(1.0);
6979
6980 var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(6));
6981
6982 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, NONE_MODE);
6983 /* The BSC will activate the dynamic PDCH by default, so confirm that */
6984 rsl_unused := f_exp_ipa_rx(0, tr_RSL_CHAN_ACT_PDCH(chan_nr, ?));
6985
6986 /* NACK this activation and expect the "show timeslot" mode still to be NONE */
6987 f_ipa_tx(0, ts_RSL_CHAN_ACT_NACK(chan_nr, RSL_ERR_EQUIPMENT_FAIL));
6988 f_sleep(1.0);
6989 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, NONE_MODE);
6990
Neels Hofmeyr887e8f12018-06-27 01:01:55 +02006991 /* clean up config */
6992 f_ts_set_chcomb(0, 0, 6, "PDCH");
6993
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006994 f_shutdown_helper();
Harald Welte94e0c342018-04-07 11:33:23 +02006995}
6996
Pau Espin Pedrol5b381082021-06-28 17:14:03 +02006997/* Test Osmocom dyn TS SDCCH8 activation / deactivation */
6998testcase TC_dyn_ts_sdcch8_act_deact() runs on test_CT {
6999 var RSL_Message rsl_unused, rsl_msg;
7000 var DchanTuple dt;
7001 var BSSAP_N_CONNECT_ind rx_c_ind;
7002
7003 /* change Timeslot 6 before f_init() starts RSL */
7004 f_init_vty();
7005 f_ts_set_chcomb(0, 0, 6, "TCH/F_TCH/H_SDCCH8_PDCH");
7006 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
7007
7008 f_init(1, false);
7009 f_sleep(1.0);
7010
7011 var RslChannelNr pdch_chan_nr := valueof(t_RslChanNr_PDCH(6));
7012
7013 log("TCH/F_TCH/H_SDCCH8_PDCH pchan starts out in disabled mode:");
7014 f_ts_dyn_mode_assert(0, 0, pdch_chan_nr.tn, NONE_MODE);
7015 /* The BSC will activate the dynamic PDCH by default, so confirm that */
7016 rsl_unused := f_exp_ipa_rx(0, tr_RSL_CHAN_ACT_PDCH(pdch_chan_nr, ?));
7017
7018 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(pdch_chan_nr, 2342));
7019 f_sleep(1.0);
7020 log("TCH/F_TCH/H_SDCCH8_PDC requested to PDCH ACT on startup, which was ACKed, so now in PDCH:");
7021 f_ts_dyn_mode_assert(0, 0, pdch_chan_nr.tn, PDCH_MODE);
7022
7023 /* Fill TS0 SDCCH channels (NOTE: only 3 SDCCH/4 channels are available
7024 * on CCCH+SDCCH4+CBCH) */
7025 var integer i;
7026 for (i := 0; i < 3; i := i + 1) {
7027 dt := f_est_dchan('23'O, i, '00010203040506'O);
7028 }
7029
7030 /* Now the dyn ts is selected. First PDCH is released, then sdcch chan is activated */
7031 f_ipa_tx(0, ts_RSL_CHAN_RQD(int2oct(oct2int('23'O) + i, 1), 2342));
7032 rsl_unused := f_exp_ipa_rx(0, tr_RSL_RF_CHAN_REL(pdch_chan_nr));
7033 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(pdch_chan_nr));
7034
7035 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
7036 dt.rsl_chan_nr := rsl_msg.ies[0].body.chan_nr;
7037
7038 f_ts_dyn_mode_assert(0, 0, dt.rsl_chan_nr.tn, SDCCH8_MODE);
7039 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(dt.rsl_chan_nr, 2342));
7040 rsl_msg := f_exp_ipa_rx(0, tr_RSL_IMM_ASSIGN(0));
7041 f_ts_dyn_mode_assert(0, 0, dt.rsl_chan_nr.tn, SDCCH8_MODE);
7042
7043 f_ipa_tx(0, ts_RSL_EST_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0)), '1234'O));
7044 BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3('1234'O))) -> value rx_c_ind;
7045 dt.sccp_conn_id := rx_c_ind.connectionId;
7046 BSSAP.send(ts_BSSAP_CONNECT_res(dt.sccp_conn_id));
7047
7048 /* Instruct BSC to clear channel */
7049 var BssmapCause cause := 0;
7050 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
7051 f_exp_chan_rel_and_clear(dt, 0);
7052
7053 /* The BSC will switch the TS back to PDCH once the only lchan using it is released: */
7054 rsl_unused := f_exp_ipa_rx(0, tr_RSL_CHAN_ACT_PDCH(pdch_chan_nr, ?));
7055 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(pdch_chan_nr, 2342));
7056 f_sleep(1.0);
7057 f_ts_dyn_mode_assert(0, 0, pdch_chan_nr.tn, PDCH_MODE);
7058
7059 /* clean up config */
7060 f_ts_set_chcomb(0, 0, 6, "PDCH");
7061
7062 f_shutdown_helper();
7063}
7064
Pau Espin Pedrol0953bf82021-07-09 13:20:19 +02007065/* Test Osmocom dyn TS SDCCH8 activation / deactivation: If activating dyn TS as
7066 SDCCH8 would end up in having no free TCH, then BSC should decide to activate
7067 it as TCH directly instead. SYS#5309. */
7068testcase TC_dyn_ts_sdcch8_tch_call_act_deact() runs on test_CT {
7069 var RSL_Message rsl_unused, rsl_msg;
7070 var DchanTuple dt;
7071 var BSSAP_N_CONNECT_ind rx_c_ind;
7072 var integer i;
7073
7074 /* change Timeslot 6 before f_init() starts RSL */
7075 f_init_vty();
7076 for (i := 1; i < 8; i := i + 1) {
7077 if (i == 6) {
7078 f_ts_set_chcomb(0, 0, i, "TCH/F_TCH/H_SDCCH8_PDCH");
7079 } else {
7080 f_ts_set_chcomb(0, 0, i, "PDCH");
7081 }
7082 }
7083 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
7084
7085 f_init(1, false);
7086 f_sleep(1.0);
7087
7088 var RslChannelNr pdch_chan_nr := valueof(t_RslChanNr_PDCH(6));
7089
7090 log("TCH/F_TCH/H_SDCCH8_PDCH pchan starts out in disabled mode:");
7091 f_ts_dyn_mode_assert(0, 0, pdch_chan_nr.tn, NONE_MODE);
7092 /* The BSC will activate the dynamic PDCH by default, so confirm that */
7093 rsl_unused := f_exp_ipa_rx(0, tr_RSL_CHAN_ACT_PDCH(pdch_chan_nr, ?));
7094
7095 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(pdch_chan_nr, 2342));
7096 f_sleep(1.0);
7097 log("TCH/F_TCH/H_SDCCH8_PDC requested to PDCH ACT on startup, which was ACKed, so now in PDCH:");
7098 f_ts_dyn_mode_assert(0, 0, pdch_chan_nr.tn, PDCH_MODE);
7099
7100 /* Fill TS0 SDCCH channels (NOTE: only 3 SDCCH/4 channels are available
7101 * on CCCH+SDCCH4+CBCH) */
Pau Espin Pedrol2ebbe7c2021-07-23 16:17:09 +02007102 var OCT1 ra := '43'O; /* RA containing reason=originating speech call*/
Pau Espin Pedrol0953bf82021-07-09 13:20:19 +02007103 for (i := 0; i < 3; i := i + 1) {
Pau Espin Pedrol2ebbe7c2021-07-23 16:17:09 +02007104 dt := f_est_dchan(ra, i, '00010203040506'O);
Pau Espin Pedrol0953bf82021-07-09 13:20:19 +02007105 }
7106
7107 /* Now the dyn ts is selected. First PDCH is released, then TCH chan is activated */
Pau Espin Pedrol2ebbe7c2021-07-23 16:17:09 +02007108 f_ipa_tx(0, ts_RSL_CHAN_RQD(int2oct(oct2int(ra) + i, 1), 2342));
Pau Espin Pedrol0953bf82021-07-09 13:20:19 +02007109 rsl_unused := f_exp_ipa_rx(0, tr_RSL_RF_CHAN_REL(pdch_chan_nr));
7110 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(pdch_chan_nr));
7111
7112 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
7113 dt.rsl_chan_nr := rsl_msg.ies[0].body.chan_nr;
7114
7115 f_ts_dyn_mode_assert(0, 0, dt.rsl_chan_nr.tn, TCHH_MODE);
7116 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(dt.rsl_chan_nr, 2342));
7117 rsl_msg := f_exp_ipa_rx(0, tr_RSL_IMM_ASSIGN(0));
7118 f_ts_dyn_mode_assert(0, 0, dt.rsl_chan_nr.tn, TCHH_MODE);
7119
7120 f_ipa_tx(0, ts_RSL_EST_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0)), '1234'O));
7121 BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3('1234'O))) -> value rx_c_ind;
7122 dt.sccp_conn_id := rx_c_ind.connectionId;
7123 BSSAP.send(ts_BSSAP_CONNECT_res(dt.sccp_conn_id));
7124
7125 /* Instruct BSC to clear channel */
7126 var BssmapCause cause := 0;
7127 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
7128 f_exp_chan_rel_and_clear(dt, 0);
7129
7130 /* The BSC will switch the TS back to PDCH once the only lchan using it is released: */
7131 rsl_unused := f_exp_ipa_rx(0, tr_RSL_CHAN_ACT_PDCH(pdch_chan_nr, ?));
7132 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(pdch_chan_nr, 2342));
7133 f_sleep(1.0);
7134 f_ts_dyn_mode_assert(0, 0, pdch_chan_nr.tn, PDCH_MODE);
7135
7136 /* clean up config */
7137 f_ts_reset_chcomb(0);
7138 /* TODO: clean up other channels? */
7139
7140 f_shutdown_helper();
7141}
7142
Pau Espin Pedrolcdf26142021-06-28 17:14:03 +02007143/* Test Osmocom dyn TS SDCCH8 activation / deactivation when SDCCH fails at BTS */
7144testcase TC_dyn_ts_sdcch8_act_nack() runs on test_CT {
7145 var RSL_Message rsl_unused, rsl_msg;
7146 var DchanTuple dt;
7147 var BSSAP_N_CONNECT_ind rx_c_ind;
7148 var GsmRrMessage rr;
7149
7150 /* change Timeslot 6 before f_init() starts RSL */
7151 f_init_vty();
7152 f_ts_set_chcomb(0, 0, 6, "TCH/F_TCH/H_SDCCH8_PDCH");
7153 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
7154
7155 f_init(1, false);
7156 f_sleep(1.0);
7157
7158 var RslChannelNr pdch_chan_nr := valueof(t_RslChanNr_PDCH(6));
7159
7160 log("TCH/F_TCH/H_SDCCH8_PDCH pchan starts out in disabled mode:");
7161 f_ts_dyn_mode_assert(0, 0, pdch_chan_nr.tn, NONE_MODE);
7162 /* The BSC will activate the dynamic PDCH by default, so confirm that */
7163 rsl_unused := f_exp_ipa_rx(0, tr_RSL_CHAN_ACT_PDCH(pdch_chan_nr, ?));
7164
7165 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(pdch_chan_nr, 2342));
7166 f_sleep(1.0);
7167 log("TCH/F_TCH/H_SDCCH8_PDC requested to PDCH ACT on startup, which was ACKed, so now in PDCH:");
7168 f_ts_dyn_mode_assert(0, 0, pdch_chan_nr.tn, PDCH_MODE);
7169
7170 /* Fill TS0 SDCCH channels (NOTE: only 3 SDCCH/4 channels are available
7171 * on CCCH+SDCCH4+CBCH) */
7172 var integer i;
7173 for (i := 0; i < 3; i := i + 1) {
7174 dt := f_est_dchan('23'O, i, '00010203040506'O);
7175 }
7176
7177 /* Now the dyn ts is selected. First PDCH is released, then sdcch chan is activated */
7178 f_ipa_tx(0, ts_RSL_CHAN_RQD(int2oct(oct2int('23'O) + i, 1), 2342));
7179 rsl_unused := f_exp_ipa_rx(0, tr_RSL_RF_CHAN_REL(pdch_chan_nr));
7180 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(pdch_chan_nr));
7181
7182 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
7183 dt.rsl_chan_nr := rsl_msg.ies[0].body.chan_nr;
7184
7185 f_ts_dyn_mode_assert(0, 0, dt.rsl_chan_nr.tn, SDCCH8_MODE);
7186 f_ipa_tx(0, ts_RSL_CHAN_ACT_NACK(dt.rsl_chan_nr, RSL_ERR_EQUIPMENT_FAIL));
7187 rsl_msg := f_exp_ipa_rx(0, tr_RSL_IMM_ASSIGN(0));
7188 rr := dec_GsmRrMessage(rsl_msg.ies[1].body.full_imm_ass_info.payload);
7189 if (rr.header.message_type != IMMEDIATE_ASSIGNMENT_REJECT) {
7190 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Expected reject");
7191 }
7192
7193 /* FIXME? Currently the TS stays in state BORKEN: */
7194
7195 /* The BSC will switch the TS back to PDCH once the only lchan using it is released: */
7196 /* rsl_unused := f_exp_ipa_rx(0, tr_RSL_CHAN_ACT_PDCH(pdch_chan_nr, ?));
7197 * f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(pdch_chan_nr, 2342));
7198 * f_sleep(1.0);
7199 * f_ts_dyn_mode_assert(0, 0, pdch_chan_nr.tn, PDCH_MODE)
7200 */
7201
7202 /* clean up config */
7203 f_ts_set_chcomb(0, 0, 6, "PDCH");
7204
7205 f_shutdown_helper();
7206}
7207
Stefan Sperling0796a822018-10-05 13:01:39 +02007208testcase TC_chopped_ipa_ping() runs on test_CT {
Stefan Sperling554123f2018-10-09 14:12:30 +02007209 const Integers bsc_ipa_ports := {mp_bsc_rsl_port, mp_bsc_oml_port, mp_bsc_ctrl_port};
Stefan Sperling0796a822018-10-05 13:01:39 +02007210 for (var integer i := 0; i < lengthof(bsc_ipa_ports); i := i + 1) {
7211 IPA_Testing.f_run_TC_chopped_ipa_ping(mp_bsc_ip, bsc_ipa_ports[i], CONNECT_TO_SERVER);
7212 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007213 f_shutdown_helper();
Stefan Sperling0796a822018-10-05 13:01:39 +02007214}
7215
Stefan Sperlingaa1e60f2018-10-15 16:34:07 +02007216testcase TC_chopped_ipa_payload() runs on test_CT {
7217 const Integers bsc_ipa_ports := {mp_bsc_rsl_port, mp_bsc_oml_port
7218 /* TODO: mp_bsc_ctrl_port does not work yet */};
7219 for (var integer i := 0; i < lengthof(bsc_ipa_ports); i := i + 1) {
7220 IPA_Testing.f_run_TC_chopped_ipa_payload(mp_bsc_ip, bsc_ipa_ports[i], CONNECT_TO_SERVER);
7221 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007222 f_shutdown_helper();
Stefan Sperlingaa1e60f2018-10-15 16:34:07 +02007223}
7224
Pau Espin Pedrol8f773632019-11-05 11:46:53 +01007225/* Verify the BSC sends the MS Power Parameters IE during CHAN ACT to make sure
7226 the BTS does autonomous MS power control loop */
7227testcase TC_assignment_verify_ms_power_params_ie() runs on test_CT {
7228 var MSC_ConnHdlr vc_conn;
7229 var TestHdlrParams pars := f_gen_test_hdlr_pars();
7230 //pars.encr := valueof(t_EncrParams('01'O, f_rnd_octstring(8)));
7231 pars.exp_ms_power_params := true;
7232
7233 f_init(1, true);
7234 f_sleep(1.0);
7235 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5), pars);
7236 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007237 f_shutdown_helper();
Pau Espin Pedrol8f773632019-11-05 11:46:53 +01007238}
Stefan Sperlingaa1e60f2018-10-15 16:34:07 +02007239
Vadim Yanitskiy4b233042021-06-30 00:58:43 +02007240/* Verify activation and deactivation of the BCCH carrier power reduction mode */
7241testcase TC_c0_power_red_mode() runs on test_CT {
7242 f_init(1);
7243
7244 for (var integer red := 6; red >= 0; red := red - 2) {
7245 /* Configure BCCH carrier power reduction mode via the VTY */
7246 f_vty_transceive(BSCVTY, "bts 0 c0-power-reduction " & int2str(red));
7247
7248 /* Expect Osmocom specific BS Power Control message on the RSL */
7249 var template RSL_Message tr_rsl_pdu := tr_RSL_BS_PWR_CTRL(
7250 chan_nr := t_RslChanNr_BCCH(0),
7251 bs_power := tr_RSL_IE_BS_Power(red / 2));
7252 tr_rsl_pdu.msg_disc := tr_RSL_MsgDisc(RSL_MDISC_CCHAN, false);
7253 var RSL_Message unused := f_exp_ipa_rx(0, tr_rsl_pdu);
7254
7255 /* Additionally verify the applied value over the CTRL interface */
7256 var CtrlValue cred := f_ctrl_get_bts(IPA_CTRL, 0, "c0-power-reduction");
7257 if (cred != int2str(red)) {
7258 setverdict(fail, "Unexpected BCCH carrier power reduction value ",
7259 cred, " (expected ", red, ")");
7260 }
7261 }
7262
7263 f_shutdown_helper();
7264}
7265
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007266/***********************************************************************
7267 * MSC Pooling
7268 ***********************************************************************/
7269
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007270template MobileIdentityLV ts_MI_TMSI_NRI_LV(integer nri_v, integer nri_bitlen := 10) :=
Harald Weltebf397612021-01-14 20:39:46 +01007271 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 +02007272
Neels Hofmeyr85bcd272021-07-22 19:14:48 +02007273private 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 +02007274runs on MSC_ConnHdlr {
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02007275 interleave {
Neels Hofmeyr85bcd272021-07-22 19:14:48 +02007276 [] rsl_pt.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch exp_rr_rel_tmpl)) {
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02007277 f_logp(BSCVTY, "Got RSL RR Release");
7278 }
Neels Hofmeyr85bcd272021-07-22 19:14:48 +02007279 [] rsl_pt.receive(tr_RSL_DEACT_SACCH(g_chan_nr)) {
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02007280 f_logp(BSCVTY, "Got RSL Deact SACCH");
7281 }
Neels Hofmeyr3c5127e2021-07-22 19:18:40 +02007282 [] rsl_pt.receive(tr_RSL_RF_CHAN_REL(g_chan_nr)) {
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02007283 f_logp(BSCVTY, "Got RSL RF Chan Rel, sending Rel Ack");
Neels Hofmeyr85bcd272021-07-22 19:14:48 +02007284 rsl_pt.send(ts_RSL_RF_CHAN_REL_ACK(g_chan_nr));
7285 f_rslem_unregister(0, g_chan_nr, PT := rsl_proc_pt);
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02007286 break;
7287 }
7288 }
7289}
7290
Neels Hofmeyr85bcd272021-07-22 19:14:48 +02007291friend function f_perform_clear(RSL_DCHAN_PT rsl_pt := RSL, RSLEM_PROC_PT rsl_proc_pt := RSL_PROC,
7292 template PDU_ML3_NW_MS exp_rr_rel_tmpl := tr_RRM_RR_RELEASE)
Pau Espin Pedrolc08d5522021-04-16 15:40:38 +02007293runs on MSC_ConnHdlr {
Neels Hofmeyr767548a2020-08-09 20:26:07 +00007294 f_logp(BSCVTY, "MSC instructs BSC to clear channel");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007295 BSSAP.send(ts_BSSMAP_ClearCommand(0));
7296 interleave {
Neels Hofmeyr85bcd272021-07-22 19:14:48 +02007297 [] rsl_pt.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch exp_rr_rel_tmpl)) {
Neels Hofmeyr767548a2020-08-09 20:26:07 +00007298 f_logp(BSCVTY, "Got RSL RR Release");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007299 }
Neels Hofmeyr85bcd272021-07-22 19:14:48 +02007300 [] rsl_pt.receive(tr_RSL_DEACT_SACCH(g_chan_nr)) {
Neels Hofmeyr767548a2020-08-09 20:26:07 +00007301 f_logp(BSCVTY, "Got RSL Deact SACCH");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007302 }
7303 [] BSSAP.receive(tr_BSSMAP_ClearComplete) {
Neels Hofmeyr767548a2020-08-09 20:26:07 +00007304 f_logp(BSCVTY, "Got BSSMAP Clear Complete");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007305 /* Also drop the SCCP connection */
7306 BSSAP.send(RAN_Conn_Prim:MSC_CONN_PRIM_DISC_REQ);
7307 }
Neels Hofmeyr3c5127e2021-07-22 19:18:40 +02007308 [] rsl_pt.receive(tr_RSL_RF_CHAN_REL(g_chan_nr)) {
Neels Hofmeyr767548a2020-08-09 20:26:07 +00007309 f_logp(BSCVTY, "Got RSL RF Chan Rel, sending Rel Ack");
Neels Hofmeyr85bcd272021-07-22 19:14:48 +02007310 rsl_pt.send(ts_RSL_RF_CHAN_REL_ACK(g_chan_nr));
7311 f_rslem_unregister(0, g_chan_nr, PT := rsl_proc_pt);
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007312 }
7313 }
7314}
7315
Neels Hofmeyr85bcd272021-07-22 19:14:48 +02007316private function f_perform_compl_l3(RSL_DCHAN_PT rsl_pt, RSLEM_PROC_PT rsl_proc_pt,
7317 template PDU_ML3_MS_NW l3_info, boolean do_clear := true, boolean expect_bssmap_l3 := true)
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007318runs on MSC_ConnHdlr {
7319 timer T := 10.0;
7320 var octetstring l3_enc := enc_PDU_ML3_MS_NW(valueof(l3_info));
7321
Neels Hofmeyr767548a2020-08-09 20:26:07 +00007322 f_logp(BSCVTY, "establish channel, send Complete Layer 3 Info");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007323 f_create_bssmap_exp(l3_enc);
7324
Neels Hofmeyr85bcd272021-07-22 19:14:48 +02007325 /* RSL_Emulation.f_chan_est() on rsl_pt:
7326 * This is basically code dup with s/RSL/rsl_pt from:
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007327 * RSL_Emulation.f_chan_est(g_pars.ra, l3_enc, g_pars.link_id, g_pars.fn);
7328 */
7329 var RSL_Message rx_rsl;
7330 var GsmRrMessage rr;
7331
7332 /* request a channel to be established */
Neels Hofmeyr85bcd272021-07-22 19:14:48 +02007333 rsl_pt.send(ts_RSLDC_ChanRqd(g_pars.ra, g_pars.fn));
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007334 /* expect immediate assignment.
Neels Hofmeyr85bcd272021-07-22 19:14:48 +02007335 * Code dup with s/RSL/rsl_pt from:
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007336 * rx_rsl := f_rx_or_fail(tr_RSL_IMM_ASSIGN);
7337 */
7338 timer Tt := 10.0;
7339
7340 /* request a channel to be established */
7341 Tt.start;
7342 alt {
Neels Hofmeyr85bcd272021-07-22 19:14:48 +02007343 [] rsl_pt.receive(tr_RSL_IMM_ASSIGN) -> value rx_rsl {
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007344 Tt.stop;
7345 }
Neels Hofmeyr85bcd272021-07-22 19:14:48 +02007346 [] rsl_pt.receive {
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007347 setverdict(fail, "Unexpected RSL message on DCHAN");
7348 mtc.stop;
7349 }
7350 [] Tt.timeout {
7351 setverdict(fail, "Timeout waiting for RSL on DCHAN");
7352 mtc.stop;
7353 }
7354 }
7355 rr := dec_GsmRrMessage(rx_rsl.ies[1].body.full_imm_ass_info.payload);
7356 g_chan_nr := rr.payload.imm_ass.chan_desc.chan_nr;
Neels Hofmeyr85bcd272021-07-22 19:14:48 +02007357 rsl_pt.send(ts_RSL_EST_IND(g_chan_nr, valueof(g_pars.link_id), l3_enc));
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007358
7359
Neels Hofmeyr66e15092020-10-12 18:44:41 +00007360 if (expect_bssmap_l3) {
7361 f_logp(BSCVTY, "expect BSSAP Complete Layer 3 Info at MSC");
7362 var template PDU_BSSAP exp_l3_compl;
7363 exp_l3_compl := tr_BSSMAP_ComplL3()
7364 if (g_pars.aoip == false) {
7365 exp_l3_compl.pdu.bssmap.completeLayer3Information.codecList := omit;
7366 } else {
7367 exp_l3_compl.pdu.bssmap.completeLayer3Information.codecList := ?;
7368 }
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007369
Neels Hofmeyr66e15092020-10-12 18:44:41 +00007370 var PDU_BSSAP bssap;
7371 T.start;
7372 alt {
7373 [] BSSAP.receive(exp_l3_compl) -> value bssap {
7374 f_logp(BSCVTY, "received expected Complete Layer 3 Info at MSC");
7375 log("rx exp_l3_compl = ", bssap);
7376 }
7377 [] BSSAP.receive(tr_BSSMAP_ComplL3) {
7378 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Received non-matching COMPLETE LAYER 3 INFORMATION");
7379 }
7380 [] T.timeout {
7381 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for COMPLETE LAYER 3 INFORMATION");
7382 }
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007383 }
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007384
Neels Hofmeyr66e15092020-10-12 18:44:41 +00007385 /* start ciphering, if requested */
7386 if (ispresent(g_pars.encr)) {
7387 f_logp(BSCVTY, "start ciphering");
Neels Hofmeyr85bcd272021-07-22 19:14:48 +02007388 f_cipher_mode(g_pars.encr, rsl_pt := rsl_pt, rsl_proc_pt := rsl_proc_pt);
Neels Hofmeyr66e15092020-10-12 18:44:41 +00007389 }
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007390 }
7391
7392 if (do_clear) {
Neels Hofmeyr85bcd272021-07-22 19:14:48 +02007393 f_perform_clear(rsl_pt, rsl_proc_pt);
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007394 }
7395 setverdict(pass);
7396 f_sleep(1.0);
7397}
7398
7399private function f_tc_mscpool_compl_l3(charstring id) runs on MSC_ConnHdlr {
7400 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
7401 if (g_pars.mscpool.rsl_idx == 0) {
Neels Hofmeyr85bcd272021-07-22 19:14:48 +02007402 f_perform_compl_l3(RSL, RSL_PROC, g_pars.mscpool.l3_info);
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007403 } else if (g_pars.mscpool.rsl_idx == 1) {
Neels Hofmeyr85bcd272021-07-22 19:14:48 +02007404 f_perform_compl_l3(RSL1, RSL1_PROC, g_pars.mscpool.l3_info);
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007405 } else if (g_pars.mscpool.rsl_idx == 2) {
Neels Hofmeyr85bcd272021-07-22 19:14:48 +02007406 f_perform_compl_l3(RSL2, RSL2_PROC, g_pars.mscpool.l3_info);
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007407 }
7408}
7409
7410/* Various Complete Layer 3 by IMSI all end up with the first MSC, because the other MSCs are not connected. */
7411private function f_tc_mscpool_L3Compl_on_1_msc(charstring id) runs on MSC_ConnHdlr {
7412 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
Neels Hofmeyr85bcd272021-07-22 19:14:48 +02007413 f_perform_compl_l3(RSL, RSL_PROC, ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_IMSI_LV('001010000000001'H)), '00F110'O) );
7414 f_perform_compl_l3(RSL, RSL_PROC, ts_CM_SERV_REQ(CM_TYPE_MO_SMS, valueof(ts_MI_IMSI_LV('001010000000002'H))) );
7415 f_perform_compl_l3(RSL, RSL_PROC, ts_PAG_RESP(valueof(ts_MI_IMSI_LV('001010000000003'H))) );
7416 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 +02007417}
7418testcase TC_mscpool_L3Compl_on_1_msc() runs on test_CT {
7419
7420 f_init(1, true);
7421 f_sleep(1.0);
7422 var MSC_ConnHdlr vc_conn;
7423 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007424
7425 f_ctrs_msc_init();
7426
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007427 vc_conn := f_start_handler(refers(f_tc_mscpool_L3Compl_on_1_msc), pars);
7428 vc_conn.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007429
7430 f_ctrs_msc_expect(0, "mscpool:subscr:new", 4);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007431 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007432}
7433
7434/* Three Layer 3 Complete by IMSI are round-robin'ed across two connected MSCs */
7435/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
7436 * just as well using only RSL. */
7437testcase TC_mscpool_L3Complete_by_imsi_round_robin() runs on test_CT {
7438
7439 f_init(nr_bts := 3, handler_mode := true, nr_msc := 2);
7440 f_sleep(1.0);
7441
7442 /* Control which MSC gets chosen next by the round-robin, otherwise
7443 * would be randomly affected by which other tests ran before this. */
7444 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
7445
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007446 f_ctrs_msc_init();
7447
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007448 var MSC_ConnHdlr vc_conn1;
7449 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
7450 pars1.mscpool.rsl_idx := 0;
7451 pars1.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_IMSI_LV('001010000000001'H)), '00F110'O));
7452 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
7453 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007454 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007455
7456 var MSC_ConnHdlr vc_conn2;
7457 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 1);
7458 pars2.mscpool.rsl_idx := 1;
7459 pars2.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, valueof(ts_MI_IMSI_LV('001010000000002'H))));
7460 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
7461 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007462 f_ctrs_msc_expect(1, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007463
7464 /* Test round-robin wrap to the first MSC */
7465 var MSC_ConnHdlr vc_conn3;
7466 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 0);
7467 pars3.mscpool.rsl_idx := 2;
7468 pars3.mscpool.l3_info := valueof(ts_PAG_RESP(valueof(ts_MI_IMSI_LV('001010000000003'H))));
7469 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
7470 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007471 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007472 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007473}
7474
7475/* Three LU by TMSI are round-robin'ed across two connected MSCs, because they contain the NULL-NRI 0
7476 * (configured in osmo-bsc.cfg). */
7477/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
7478 * just as well using only RSL. */
7479testcase TC_mscpool_LU_by_tmsi_null_nri_0_round_robin() runs on test_CT {
7480
7481 f_init(nr_bts := 3, handler_mode := true, nr_msc := 2);
7482 f_sleep(1.0);
7483
7484 /* Control which MSC gets chosen next by the round-robin, otherwise
7485 * would be randomly affected by which other tests ran before this. */
7486 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
7487
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007488 f_ctrs_msc_init();
7489
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007490 var MSC_ConnHdlr vc_conn1;
7491 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
7492 pars1.mscpool.rsl_idx := 0;
7493 pars1.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(0)), '00F110'O));
7494 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
7495 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007496 f_ctrs_msc_expect(0, "mscpool:subscr:reattach");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007497
7498 var MSC_ConnHdlr vc_conn2;
7499 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 1);
7500 pars2.mscpool.rsl_idx := 1;
7501 pars2.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(0)), '00F110'O));
7502 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
7503 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007504 f_ctrs_msc_expect(1, "mscpool:subscr:reattach");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007505
7506 /* Test round-robin wrap to the first MSC */
7507 var MSC_ConnHdlr vc_conn3;
7508 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 0);
7509 pars3.mscpool.rsl_idx := 2;
7510 pars3.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(0)), '00F110'O));
7511 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
7512 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007513 f_ctrs_msc_expect(0, "mscpool:subscr:reattach");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007514 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007515}
7516
7517/* Three LU by TMSI are round-robin'ed across two connected MSCs, because they contain the NULL-NRI 1
7518 * (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
7519 * NULL-NRI setting is stronger than that. */
7520/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
7521 * just as well using only RSL. */
7522testcase TC_mscpool_LU_by_tmsi_null_nri_1_round_robin() runs on test_CT {
7523
7524 f_init(nr_bts := 3, handler_mode := true, nr_msc := 2);
7525 f_sleep(1.0);
7526
7527 /* Control which MSC gets chosen next by the round-robin, otherwise
7528 * would be randomly affected by which other tests ran before this. */
7529 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
7530
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007531 f_ctrs_msc_init();
7532
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007533 var MSC_ConnHdlr vc_conn1;
7534 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
7535 pars1.mscpool.rsl_idx := 0;
7536 pars1.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(1)), '00F110'O));
7537 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
7538 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007539 f_ctrs_msc_expect(0, "mscpool:subscr:reattach");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007540
7541 var MSC_ConnHdlr vc_conn2;
7542 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 1);
7543 pars2.mscpool.rsl_idx := 1;
7544 pars2.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(1)), '00F110'O));
7545 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
7546 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007547 f_ctrs_msc_expect(1, "mscpool:subscr:reattach");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007548
7549 /* Test round-robin wrap to the first MSC */
7550 var MSC_ConnHdlr vc_conn3;
7551 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 0);
7552 pars3.mscpool.rsl_idx := 2;
7553 pars3.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(1)), '00F110'O));
7554 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
7555 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007556 f_ctrs_msc_expect(0, "mscpool:subscr:reattach");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007557 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007558}
7559
7560/* Three Layer 3 Complete by TMSI are round-robin'ed across two connected MSCs, because they contain an NRI not
7561 * assigned to any MSC (configured in osmo-bsc.cfg). */
7562/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
7563 * just as well using only RSL. */
7564testcase TC_mscpool_L3Complete_by_tmsi_unassigned_nri_round_robin() runs on test_CT {
7565
7566 f_init(nr_bts := 3, handler_mode := true, nr_msc := 2);
7567 f_sleep(1.0);
7568
7569 /* Control which MSC gets chosen next by the round-robin, otherwise
7570 * would be randomly affected by which other tests ran before this. */
7571 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
7572
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007573 f_ctrs_msc_init();
7574
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007575 var MSC_ConnHdlr vc_conn1;
7576 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
7577 pars1.mscpool.rsl_idx := 0;
7578 /* An NRI that is not assigned to any MSC */
7579 pars1.mscpool.l3_info := valueof(ts_ML3_MO_MM_IMSI_DET_Ind(valueof(ts_MI_TMSI_NRI_LV(1023))));
7580 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
7581 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007582 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007583
7584 var MSC_ConnHdlr vc_conn2;
7585 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 1);
7586 pars2.mscpool.rsl_idx := 1;
7587 /* An NRI that is not assigned to any MSC */
7588 pars2.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(768)), '00F110'O));
7589 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
7590 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007591 f_ctrs_msc_expect(1, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007592
7593 /* Test round-robin wrap to the first MSC */
7594 var MSC_ConnHdlr vc_conn3;
7595 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 0);
7596 pars3.mscpool.rsl_idx := 2;
7597 /* An NRI that is not assigned to any MSC */
7598 pars3.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_SS_ACT, valueof(ts_MI_TMSI_NRI_LV(819))));
7599 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
7600 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007601 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007602 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007603}
7604
7605/* Three Layer 3 Complete by TMSI are round-robin'ed across two connected MSCs, because they contain an NRI
7606 * assigned to an MSC that is currently not connected (configured in osmo-bsc.cfg). */
7607/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
7608 * just as well using only RSL. */
7609testcase TC_mscpool_L3Complete_by_tmsi_valid_nri_msc_not_connected_round_robin() runs on test_CT {
7610
7611 f_init(nr_bts := 3, handler_mode := true, nr_msc := 2);
7612 f_sleep(1.0);
7613
7614 /* Control which MSC gets chosen next by the round-robin, otherwise
7615 * would be randomly affected by which other tests ran before this. */
7616 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
7617
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007618 f_ctrs_msc_init();
7619
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007620 var MSC_ConnHdlr vc_conn1;
7621 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
7622 pars1.mscpool.rsl_idx := 0;
7623 /* An NRI that is assigned to an unconnected MSC */
7624 pars1.mscpool.l3_info := valueof(ts_PAG_RESP(valueof(ts_MI_TMSI_NRI_LV(512))));
7625 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
7626 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007627 f_ctrs_msc_add(2, "mscpool:subscr:attach_lost");
7628 f_ctrs_msc_add(0, "mscpool:subscr:new");
7629 f_ctrs_msc_verify();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007630
7631 var MSC_ConnHdlr vc_conn2;
7632 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 1);
7633 pars2.mscpool.rsl_idx := 1;
7634 /* An NRI that is assigned to an unconnected MSC */
7635 pars2.mscpool.l3_info := valueof(ts_ML3_MO_MM_IMSI_DET_Ind(valueof(ts_MI_TMSI_NRI_LV(767))));
7636 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
7637 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007638 f_ctrs_msc_add(2, "mscpool:subscr:attach_lost");
7639 f_ctrs_msc_add(1, "mscpool:subscr:new");
7640 f_ctrs_msc_verify();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007641
7642 /* Test round-robin wrap to the first MSC */
7643 var MSC_ConnHdlr vc_conn3;
7644 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 0);
7645 pars3.mscpool.rsl_idx := 2;
7646 /* An NRI that is assigned to an unconnected MSC */
7647 pars3.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(750)), '00F110'O));
7648 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
7649 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007650 f_ctrs_msc_add(2, "mscpool:subscr:attach_lost");
7651 f_ctrs_msc_add(0, "mscpool:subscr:new");
7652 f_ctrs_msc_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007653 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007654}
7655
7656/* Three Layer 3 Complete by TMSI with valid NRI for the second MSC are all directed to the second MSC (configured in
7657 * osmo-bsc.cfg). */
7658/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
7659 * just as well using only RSL. */
7660testcase TC_mscpool_L3Complete_by_tmsi_valid_nri_1() runs on test_CT {
7661
7662 f_init(nr_bts := 3, handler_mode := true, nr_msc := 2);
7663 f_sleep(1.0);
7664
7665 /* All TMSIs in this test point at the second MSC, set the round robin to point at the first MSC to make sure
7666 * this is not using round-robin. */
7667 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
7668
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007669 f_ctrs_msc_init();
7670
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007671 var MSC_ConnHdlr vc_conn1;
7672 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 1);
7673 pars1.mscpool.rsl_idx := 0;
7674 /* An NRI of the second MSC's range (256-511) */
7675 pars1.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_SMS, valueof(ts_MI_TMSI_NRI_LV(256))));
7676 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
7677 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007678 f_ctrs_msc_expect(1, "mscpool:subscr:known");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007679
7680 var MSC_ConnHdlr vc_conn2;
7681 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 1);
7682 pars2.mscpool.rsl_idx := 1;
7683 /* An NRI of the second MSC's range (256-511) */
7684 pars2.mscpool.l3_info := valueof(ts_PAG_RESP(valueof(ts_MI_TMSI_NRI_LV(260))));
7685 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
7686 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007687 f_ctrs_msc_expect(1, "mscpool:subscr:known");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007688
7689 var MSC_ConnHdlr vc_conn3;
7690 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 1);
7691 pars3.mscpool.rsl_idx := 2;
7692 /* An NRI of the second MSC's range (256-511) */
7693 pars3.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(511)), '00F110'O));
7694 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
7695 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007696 f_ctrs_msc_expect(1, "mscpool:subscr:known");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007697 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007698}
7699
7700/* Layer 3 Complete by TMSI with valid NRI for the third MSC are directed to the third MSC (configured in osmo-bsc.cfg),
7701 * while a round-robin remains unaffected by that. */
7702/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
7703 * just as well using only RSL. */
7704testcase TC_mscpool_L3Complete_by_tmsi_valid_nri_2() runs on test_CT {
7705
7706 f_init(nr_bts := 3, handler_mode := true, nr_msc := 3);
7707 f_sleep(1.0);
7708
7709 /* All TMSIs in this test point at the third MSC, set the round robin to point at the second MSC to make sure
7710 * this is not using round-robin. */
7711 f_vty_transceive(BSCVTY, "mscpool roundrobin next 1");
7712
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007713 f_ctrs_msc_init();
7714
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007715 var MSC_ConnHdlr vc_conn1;
7716 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 2);
7717 pars1.mscpool.rsl_idx := 0;
7718 /* An NRI of the third MSC's range (512-767) */
7719 pars1.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_SMS, valueof(ts_MI_TMSI_NRI_LV(512))));
7720 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
7721 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007722 f_ctrs_msc_expect(2, "mscpool:subscr:known");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007723
7724 var MSC_ConnHdlr vc_conn2;
7725 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 2);
7726 pars2.mscpool.rsl_idx := 1;
7727 /* An NRI of the third MSC's range (512-767) */
7728 pars2.mscpool.l3_info := valueof(ts_PAG_RESP(valueof(ts_MI_TMSI_NRI_LV(678))));
7729 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
7730 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007731 f_ctrs_msc_expect(2, "mscpool:subscr:known");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007732
7733 /* The above forwardings to third MSC have not affected the round robin, which still points at the second MSC */
7734 var MSC_ConnHdlr vc_conn3;
7735 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 1);
7736 pars3.mscpool.rsl_idx := 2;
7737 pars3.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_IMSI_LV('001010000000013'H)), '00F110'O));
7738 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
7739 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007740 f_ctrs_msc_expect(1, "mscpool:subscr:new");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007741 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007742}
7743
7744/* LU with a TMSI but indicating a different PLMN in its previous LAI: ignore the NRI. */
7745/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
7746 * just as well using only RSL. */
7747testcase TC_mscpool_LU_by_tmsi_from_other_PLMN() runs on test_CT {
7748
7749 f_init(nr_bts := 3, handler_mode := true, nr_msc := 3);
7750 f_sleep(1.0);
7751
7752 /* The TMSIs in this test points at the second MSC, but since it is from a different PLMN, round-robin is used
7753 * instead, and hits msc 0. */
7754 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
7755
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007756 f_ctrs_msc_init();
7757
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007758 /* An NRI of the second MSC's range (256-511), but a PLMN that doesn't match with osmo-bsc.cfg */
7759 var MSC_ConnHdlr vc_conn1;
7760 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
7761 pars1.mscpool.rsl_idx := 0;
7762 pars1.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(260)), '99F999'O));
7763 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
7764 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007765 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007766
7767 /* An NRI of the third MSC's range (512-767) and a matching PLMN gets directed by NRI. */
7768 var MSC_ConnHdlr vc_conn2;
7769 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 2);
7770 pars2.mscpool.rsl_idx := 1;
7771 pars2.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(555)), '00F110'O));
7772 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
7773 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007774 f_ctrs_msc_expect(2, "mscpool:subscr:known");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007775 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007776}
7777
7778/* Make sure that whichever MSC paged a subscriber will also get the Paging Response. Page by IMSI, which would be
7779 * round-robined to another MSC, to make sure the Paging->Response relation is stronger than the NRI->MSC mapping. */
7780private function f_tc_mscpool_paging_imsi(charstring id) runs on MSC_ConnHdlr {
7781 var template BSSMAP_FIELD_CellIdentificationList cid_list := { cIl_CI := { ts_BSSMAP_CI_CI(0) } };
7782 //cid_list := { cIl_allInBSS := ''O };
7783 var RSL_ChanNeeded rsl_chneed := RSL_CHANNEED_SDCCH;
7784 var template BSSMAP_IE_ChannelNeeded bssmap_chneed := ts_BSSMAP_IE_ChanNeeded(int2bit(enum2int(valueof(rsl_chneed)),2));
7785 var BSSAP_N_UNITDATA_req paging;
7786 var hexstring imsi := '001010000000123'H;
7787
7788 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
7789
Neels Hofmeyr90f80962020-06-12 16:16:55 +02007790 paging := valueof(ts_BSSAP_UNITDATA_req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007791 valueof(ts_BSSMAP_Paging(imsi, cid_list, omit, bssmap_chneed))));
7792 BSSAP.send(paging);
7793
7794 /* Register any RSL conn so that the Paging Command gets received here. With the current RSL_Emulation's main()
7795 * handling of '[bts_role] IPA_PT.receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD()))' it doesn't matter at all which
7796 * channel number is picked here. */
7797 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(0, RSL_CHAN_NR_INVALID));
7798 f_rslem_register(0, new_chan_nr);
7799 RSL.receive(tr_RSL_PAGING_CMD(tr_MI_IMSI(imsi)));
7800 f_rslem_unregister(0, new_chan_nr);
7801
7802 /* Despite the round robin pointing at the second MSC ('roundrobin next 1'), the earlier Paging for the same IMSI
7803 * causes this Paging Response to go to the first MSC (bssap_idx := 0). */
Neels Hofmeyr85bcd272021-07-22 19:14:48 +02007804 f_perform_compl_l3(RSL, RSL_PROC, ts_PAG_RESP(valueof(ts_MI_IMSI_LV(imsi))) );
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007805 f_sleep(1.0);
7806}
7807testcase TC_mscpool_paging_and_response_imsi() runs on test_CT {
7808 f_init(nr_bts := 1, handler_mode := true, nr_msc := 3);
7809 f_sleep(1.0);
7810
7811 /* Testing a Paging on the first MSC to get a Paging Response back to the first MSC. Set round robin to the
7812 * second MSC to make sure we're getting the Paging logic, not a coincidental round robin match. */
7813 f_vty_transceive(BSCVTY, "mscpool roundrobin next 1");
7814
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007815 f_ctrs_msc_init();
7816
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007817 var MSC_ConnHdlr vc_conn1;
7818 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
7819 pars1.mscpool.rsl_idx := 0;
Neels Hofmeyr90f80962020-06-12 16:16:55 +02007820 pars1.sccp_addr_bsc := g_bssap[pars1.mscpool.bssap_idx].sccp_addr_peer;
7821 pars1.sccp_addr_msc := g_bssap[pars1.mscpool.bssap_idx].sccp_addr_own;
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007822 vc_conn1 := f_start_handler(refers(f_tc_mscpool_paging_imsi), pars1);
7823 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007824 f_ctrs_msc_expect(0, "mscpool:subscr:paged");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007825 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007826}
7827
7828/* Make sure that whichever MSC paged a subscriber will also get the Paging Response. Page by TMSI with an NRI value
7829 * that matches a different MSC, to make sure the Paging->Response relation is stronger than the NRI->MSC mapping. */
7830private function f_tc_mscpool_paging_tmsi(charstring id) runs on MSC_ConnHdlr {
7831 var template BSSMAP_FIELD_CellIdentificationList cid_list := { cIl_CI := { ts_BSSMAP_CI_CI(0) } };
7832 //cid_list := { cIl_allInBSS := ''O };
7833 var RSL_ChanNeeded rsl_chneed := RSL_CHANNEED_SDCCH;
7834 var template BSSMAP_IE_ChannelNeeded bssmap_chneed := ts_BSSMAP_IE_ChanNeeded(int2bit(enum2int(valueof(rsl_chneed)),2));
7835 var integer nri_v := 300; /* <-- second MSC's NRI */
Harald Weltebf397612021-01-14 20:39:46 +01007836 var octetstring tmsi := f_gen_tmsi(suffix := 0, nri_v := nri_v);
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007837 var BSSAP_N_UNITDATA_req paging;
7838
7839 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
7840
Neels Hofmeyr90f80962020-06-12 16:16:55 +02007841 paging := valueof(ts_BSSAP_UNITDATA_req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007842 valueof(ts_BSSMAP_Paging('001010000000011'H, cid_list, tmsi, bssmap_chneed))));
7843 BSSAP.send(paging);
7844
7845 /* Register any RSL conn so that the Paging Command gets received here. With the current RSL_Emulation's main()
7846 * handling of '[bts_role] IPA_PT.receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD()))' it doesn't matter at all which
7847 * channel number is picked here. */
7848 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(0, RSL_CHAN_NR_INVALID));
7849 f_rslem_register(0, new_chan_nr);
7850 RSL.receive(tr_RSL_PAGING_CMD(t_MI_TMSI(tmsi)));
7851 f_rslem_unregister(0, new_chan_nr);
7852
7853 /* Despite the NRI matching the second MSC (NRI from 'msc 1' in osmo-bsc.cfg) and round robin pointing at the
7854 * third MSC ('roundrobin next 2'), the earlier Paging for the same TMSI causes this Paging Response to go to
7855 * the first MSC (bssap_idx := 0). */
Neels Hofmeyr85bcd272021-07-22 19:14:48 +02007856 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 +02007857 f_sleep(1.0);
7858}
7859testcase TC_mscpool_paging_and_response_tmsi() runs on test_CT {
7860 f_init(nr_bts := 1, handler_mode := true, nr_msc := 3);
7861 f_sleep(1.0);
7862
7863 /* Testing a Paging on the first MSC to get a Paging Response back to the first MSC. Set round robin to the
7864 * third MSC to make sure we're getting the Paging logic, not a coincidental round robin match. */
7865 f_vty_transceive(BSCVTY, "mscpool roundrobin next 2");
7866
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007867 f_ctrs_msc_init();
7868
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007869 var MSC_ConnHdlr vc_conn1;
7870 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
7871 pars1.mscpool.rsl_idx := 0;
Neels Hofmeyr90f80962020-06-12 16:16:55 +02007872 pars1.sccp_addr_bsc := g_bssap[pars1.mscpool.bssap_idx].sccp_addr_peer;
7873 pars1.sccp_addr_msc := g_bssap[pars1.mscpool.bssap_idx].sccp_addr_own;
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007874 vc_conn1 := f_start_handler(refers(f_tc_mscpool_paging_tmsi), pars1);
7875 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007876 f_ctrs_msc_expect(0, "mscpool:subscr:paged");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007877 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007878}
7879
7880/* For round-robin, skip an MSC that has 'no allow-attach' set. */
7881/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
7882 * just as well using only RSL. */
7883testcase TC_mscpool_no_allow_attach_round_robin() runs on test_CT {
7884
7885 f_init(nr_bts := 3, handler_mode := true, nr_msc := 3);
7886 f_sleep(1.0);
Neels Hofmeyra460f1f2020-08-09 20:17:03 +00007887 /* Mark the second MSC as offloading, round-robin should skip this MSC now. */
7888 f_vty_msc_allow_attach(BSCVTY, {true, false, true});
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007889
7890 /* Control which MSC gets chosen next by the round-robin, otherwise
7891 * would be randomly affected by which other tests ran before this. */
7892 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
7893
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007894 f_ctrs_msc_init();
7895
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007896 var MSC_ConnHdlr vc_conn1;
7897 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
7898 pars1.mscpool.rsl_idx := 0;
7899 pars1.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_IMSI_LV('001010000000001'H)), '00F110'O));
7900 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
7901 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007902 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007903
7904 var MSC_ConnHdlr vc_conn2;
7905 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 2);
7906 pars2.mscpool.rsl_idx := 1;
7907 pars2.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, valueof(ts_MI_IMSI_LV('001010000000002'H))));
7908 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
7909 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007910 f_ctrs_msc_expect(2, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007911
7912 var MSC_ConnHdlr vc_conn3;
7913 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 0);
7914 pars3.mscpool.rsl_idx := 2;
7915 pars3.mscpool.l3_info := valueof(ts_PAG_RESP(valueof(ts_MI_IMSI_LV('001010000000003'H))));
7916 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
7917 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007918 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007919 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007920}
7921
7922/* An MSC that has 'no allow-attach' set should still serve subscribers that are already attached according to their
7923 * TMSI NRI. */
7924testcase TC_mscpool_no_allow_attach_valid_nri() runs on test_CT {
7925
7926 f_init(nr_bts := 3, handler_mode := true, nr_msc := 3);
7927 f_sleep(1.0);
7928
Neels Hofmeyra460f1f2020-08-09 20:17:03 +00007929 /* Mark the second MSC as offloading, round-robin should skip this MSC now. */
7930 f_vty_msc_allow_attach(BSCVTY, {true, false, true});
7931
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007932 /* Control which MSC gets chosen next by the round-robin, otherwise
7933 * would be randomly affected by which other tests ran before this. */
7934 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
7935
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007936 f_ctrs_msc_init();
7937
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007938 /* Round robin points at msc 0, but the valid NRI directs to msc 1, even though msc 1 has 'no allow-attach'. */
7939 var MSC_ConnHdlr vc_conn1;
7940 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 1);
7941 pars1.mscpool.rsl_idx := 0;
7942 /* An NRI of the second MSC's range (256-511) */
7943 pars1.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, valueof(ts_MI_TMSI_NRI_LV(260))));
7944 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
7945 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007946 f_ctrs_msc_expect(1, "mscpool:subscr:known");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007947
7948 var MSC_ConnHdlr vc_conn2;
7949 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 0);
7950 pars2.mscpool.rsl_idx := 1;
7951 pars2.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, valueof(ts_MI_IMSI_LV('001010000000002'H))));
7952 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
7953 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007954 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007955
7956 var MSC_ConnHdlr vc_conn3;
7957 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 2);
7958 pars3.mscpool.rsl_idx := 2;
7959 pars3.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, valueof(ts_MI_IMSI_LV('001010000000003'H))));
7960 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
7961 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007962 f_ctrs_msc_expect(2, "mscpool:subscr:new");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007963 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007964}
7965
Philipp Maier783681c2020-07-16 16:47:06 +02007966/* Allow/Deny emergency calls globally via VTY */
7967private function f_vty_allow_emerg_msc(boolean allow) runs on test_CT {
7968 f_vty_enter_cfg_msc(BSCVTY, 0);
7969 if (allow) {
7970 f_vty_transceive(BSCVTY, "allow-emergency allow");
7971 } else {
7972 f_vty_transceive(BSCVTY, "allow-emergency deny");
7973 }
7974 f_vty_transceive(BSCVTY, "exit");
7975 f_vty_transceive(BSCVTY, "exit");
7976}
7977
7978/* Allow/Deny emergency calls per BTS via VTY */
7979private function f_vty_allow_emerg_bts(boolean allow, integer bts_nr) runs on test_CT {
7980 f_vty_enter_cfg_bts(BSCVTY, bts_nr);
7981 if (allow) {
7982 f_vty_transceive(BSCVTY, "rach emergency call allowed 1");
7983 } else {
7984 f_vty_transceive(BSCVTY, "rach emergency call allowed 0");
7985 }
7986 f_vty_transceive(BSCVTY, "exit");
7987 f_vty_transceive(BSCVTY, "exit");
Neels Hofmeyrb6ed80c2020-10-12 22:52:39 +00007988 f_vty_transceive(BSCVTY, "exit");
Philipp Maier783681c2020-07-16 16:47:06 +02007989}
7990
Pau Espin Pedrol9ae36d52021-06-15 17:29:43 +02007991/* Allow/Forbid Fast Return after SRVCC on a given BTS via VTY */
7992private function f_vty_allow_srvcc_fast_return(boolean allow, integer bts_nr) runs on test_CT {
7993 f_vty_enter_cfg_bts(BSCVTY, bts_nr);
7994 if (allow) {
7995 f_vty_transceive(BSCVTY, "srvcc fast-return allow");
7996 } else {
7997 f_vty_transceive(BSCVTY, "srvcc fast-return forbid");
7998 }
7999 f_vty_transceive(BSCVTY, "exit");
8000 f_vty_transceive(BSCVTY, "exit");
8001 f_vty_transceive(BSCVTY, "exit");
8002}
8003
Pau Espin Pedrol14475352021-07-22 15:48:16 +02008004/* Allow/Forbid TCH for signalling if SDCCH exhausted on a given BTS via VTY */
8005private function f_vty_allow_tch_for_signalling(boolean allow, integer bts_nr) runs on test_CT {
8006 f_vty_enter_cfg_bts(BSCVTY, bts_nr);
8007 if (allow) {
8008 f_vty_transceive(BSCVTY, "channel allocator allow-tch-for-signalling 1");
8009 } else {
8010 f_vty_transceive(BSCVTY, "channel allocator allow-tch-for-signalling 0");
8011 }
8012 f_vty_transceive(BSCVTY, "exit");
8013 f_vty_transceive(BSCVTY, "exit");
8014 f_vty_transceive(BSCVTY, "exit");
8015}
8016
Philipp Maier783681c2020-07-16 16:47:06 +02008017/* Begin assignmet procedure and send an EMERGENCY SETUP (RR) */
8018private function f_assignment_emerg_setup() runs on MSC_ConnHdlr {
8019 var PDU_ML3_MS_NW emerg_setup;
8020 var octetstring emerg_setup_enc;
8021 var RSL_Message emerg_setup_data_ind;
8022
8023 f_establish_fully(omit, omit);
8024
8025 emerg_setup := valueof(ts_ML3_MO_CC_EMERG_SETUP(1, valueof(ts_Bcap_voice)));
8026 emerg_setup_enc := enc_PDU_ML3_MS_NW(emerg_setup);
8027 emerg_setup_data_ind := valueof(ts_RSL_DATA_IND(g_chan_nr, valueof(ts_RslLinkID_DCCH(0)), emerg_setup_enc));
8028
8029 RSL.send(emerg_setup_data_ind);
8030}
8031
8032/* Test if the EMERGENCY SETUP gets passed on to the MSC via A when EMERGENCY
8033 * CALLS are permitted by the BSC config. */
8034private function f_TC_assignment_emerg_setup_allow(charstring id) runs on MSC_ConnHdlr {
8035 var PDU_BSSAP emerg_setup_data_ind_bssap;
8036 var PDU_ML3_MS_NW emerg_setup;
8037 timer T := 3.0;
8038
8039 f_assignment_emerg_setup()
8040
8041 T.start;
8042 alt {
8043 [] BSSAP.receive(tr_BSSAP_DTAP) -> value emerg_setup_data_ind_bssap {
8044 emerg_setup := dec_PDU_ML3_MS_NW(emerg_setup_data_ind_bssap.pdu.dtap);
8045 if (not isbound(emerg_setup.msgs.cc.emergencySetup)) {
8046 setverdict(fail, "no emergency setup");
8047 }
8048 }
8049 [] BSSAP.receive {
8050 setverdict(fail, "unexpected BSSAP message!");
8051 }
8052 [] T.timeout {
8053 setverdict(fail, "timout waiting for EMERGENCY SETUP!");
8054 }
8055 }
8056
8057 setverdict(pass);
8058}
8059
8060/* Test if the EMERGENCY SETUP gets blocked by the BSC if EMERGENCY CALLS are
8061 * forbidden by the BSC config. */
8062private function f_TC_assignment_emerg_setup_deny(charstring id) runs on MSC_ConnHdlr {
8063 var PDU_BSSAP emerg_setup_data_ind_bssap;
8064 timer T := 3.0;
8065
8066 f_assignment_emerg_setup()
8067
8068 T.start;
8069 alt {
8070 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_RELEASE)) {
8071 setverdict(pass);
8072 }
8073 [] RSL.receive {
8074 setverdict(fail, "unexpected RSL message!");
8075 }
8076 [] T.timeout {
8077 setverdict(fail, "timout waiting for RR CHANNEL RELEASE!");
8078 }
8079 }
8080}
8081
8082/* EMERGENCY CALL situation #1, allowed globally and by BTS */
8083testcase TC_assignment_emerg_setup_allow() runs on test_CT {
8084 var TestHdlrParams pars := f_gen_test_hdlr_pars();
8085 var MSC_ConnHdlr vc_conn;
8086
8087 f_init(1, true);
8088 f_sleep(1.0);
8089
8090 f_vty_allow_emerg_msc(true);
8091 f_vty_allow_emerg_bts(true, 0);
8092 vc_conn := f_start_handler(refers(f_TC_assignment_emerg_setup_allow), pars);
8093 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02008094 f_shutdown_helper();
Philipp Maier783681c2020-07-16 16:47:06 +02008095}
8096
8097/* EMERGENCY CALL situation #2, forbidden globally but allowed by BTS */
8098testcase TC_assignment_emerg_setup_deny_msc() runs on test_CT {
8099 var TestHdlrParams pars := f_gen_test_hdlr_pars();
8100 var MSC_ConnHdlr vc_conn;
8101
8102 f_init(1, true);
8103 f_sleep(1.0);
8104
8105 f_vty_allow_emerg_msc(false);
8106 f_vty_allow_emerg_bts(true, 0);
8107 vc_conn := f_start_handler(refers(f_TC_assignment_emerg_setup_deny), pars);
8108 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02008109 f_shutdown_helper();
Philipp Maier783681c2020-07-16 16:47:06 +02008110}
8111
8112/* EMERGENCY CALL situation #3, allowed globally but forbidden by BTS */
8113testcase TC_assignment_emerg_setup_deny_bts() runs on test_CT {
8114 var TestHdlrParams pars := f_gen_test_hdlr_pars();
8115 var MSC_ConnHdlr vc_conn;
8116
8117 /* Note: This simulates a spec violation by the MS, correct MS
8118 * implementations would not try to establish an emergency call because
8119 * the system information tells in advance that emergency calls are
8120 * not forbidden */
8121
8122 f_init(1, true);
8123 f_sleep(1.0);
8124
8125 f_vty_allow_emerg_msc(true);
8126 f_vty_allow_emerg_bts(false, 0);
8127 vc_conn := f_start_handler(refers(f_TC_assignment_emerg_setup_deny), pars);
8128 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02008129 f_shutdown_helper();
Philipp Maier783681c2020-07-16 16:47:06 +02008130}
8131
Philipp Maier82812002020-08-13 18:48:27 +02008132/* Test what happens when an emergency call arrives while all TCH channels are
8133 * busy, the BSC is expected to terminate one call in favor of the incoming
8134 * emergency call */
8135testcase TC_emerg_premption() runs on test_CT {
8136 var ASP_RSL_Unitdata rsl_ud;
8137 var integer i;
8138 var integer chreq_total, chreq_nochan;
8139 var RSL_Message rx_rsl;
8140 var RslChannelNr chan_nr;
8141
8142 f_init(1);
8143 f_sleep(1.0);
8144
8145 f_vty_allow_emerg_msc(true);
8146 f_vty_allow_emerg_bts(true, 0);
8147
8148 /* Fill up all channels on the BTS */
8149 chreq_total := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total");
8150 chreq_nochan := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:no_channel");
8151 for (i := 0; i < NUM_TCHF_PER_BTS + NUM_TCHH_PER_BTS + NUM_SDCCH_PER_BTS; i := i+1) {
8152 chan_nr := f_chreq_act_ack('33'O, i);
8153 }
8154 IPA_RSL[0].clear;
8155 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total",
8156 chreq_total + NUM_TCHF_PER_BTS + NUM_TCHH_PER_BTS + NUM_SDCCH_PER_BTS);
8157
8158 /* Send Channel request for emegergency call */
8159 f_ipa_tx(0, ts_RSL_CHAN_RQD('A5'O, 23));
8160
8161 /* Expect the BSC to release one (the first) TCH/F on the BTS */
8162 chan_nr := valueof(t_RslChanNr_Bm(1));
8163 f_expect_chan_rel(0, chan_nr, expect_rr_chan_rel := false, expect_rll_rel_req := false);
8164
8165 /* Expect the BSC to send activate/assign the a channel for the emergency call */
8166 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
8167 chan_nr := rx_rsl.ies[0].body.chan_nr;
8168 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, 33));
8169 rx_rsl := f_exp_ipa_rx(0, tr_RSL_IMM_ASSIGN(0));
Philipp Maier104f4c02020-09-11 18:12:18 +02008170
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02008171 f_shutdown_helper();
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008172}
8173
8174/* Hopping parameters per a timeslot */
Vadim Yanitskiybc6654a2020-09-13 01:27:40 +07008175private type record length(0..64) of GsmArfcn ArfcnList;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008176private type record FHParamsTs {
8177 boolean enabled,
8178 uint6_t hsn,
8179 uint6_t maio,
8180 ArfcnList ma
8181};
8182
8183/* Hopping parameters per a transceiver */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07008184private type record FHParamsTrx {
8185 GsmArfcn arfcn,
8186 FHParamsTs ts[8]
8187};
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008188
8189/* Randomly generate the hopping parameters for the given timeslot numbers */
8190private function f_TC_fh_params_gen(template integer tr_tn := (1, 3, 5))
8191runs on test_CT return FHParamsTrx {
8192 var FHParamsTrx fhp;
8193
Vadim Yanitskiy3e997362020-09-05 21:08:34 +07008194 /* Generate a random ARFCN, including ARFCN 0 */
8195 fhp.arfcn := f_rnd_int(3);
Vadim Yanitskiye7c8c6e2020-09-13 14:33:03 +07008196
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008197 for (var integer tn := 0; tn < 8; tn := tn + 1) {
8198 if (not match(tn, tr_tn)) {
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07008199 fhp.ts[tn].enabled := false;
8200 fhp.ts[tn].ma := { };
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008201 continue;
8202 }
8203
8204 /* Random HSN / MAIO values: 0..63 */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07008205 fhp.ts[tn].hsn := f_rnd_int(64);
8206 fhp.ts[tn].maio := f_rnd_int(64);
8207 fhp.ts[tn].ma := { };
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008208
8209 /* Random Mobile Allocation (hopping channels) */
8210 var integer ma_len := 2 + f_rnd_int(9); /* 2..10 channels */
8211 var integer step := 3 + f_rnd_int(4); /* 3..6 stepping */
8212 for (var integer i := 1; i <= ma_len; i := i + 1) {
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07008213 fhp.ts[tn].ma := fhp.ts[tn].ma & { i * step };
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008214 }
8215
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07008216 fhp.ts[tn].enabled := true;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008217 }
8218
8219 log("f_TC_fh_params_gen(): ", fhp);
8220 return fhp;
8221}
8222
8223/* Make sure that the given Channel Description IE matches the hopping configuration */
8224private function f_TC_fh_params_match_chan_desc(in FHParamsTrx fhp, in ChannelDescription cd)
8225{
8226 var template (present) ChannelDescription tr_cd;
8227 var template (present) MaioHsn tr_maio_hsn;
8228 var uint3_t tn := cd.chan_nr.tn;
8229
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07008230 if (fhp.ts[tn].enabled) {
8231 tr_maio_hsn := tr_HsnMaio(fhp.ts[tn].hsn, fhp.ts[tn].maio);
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008232 tr_cd := tr_ChanDescH1(cd.chan_nr, tr_maio_hsn);
8233 } else {
Vadim Yanitskiye7c8c6e2020-09-13 14:33:03 +07008234 tr_cd := tr_ChanDescH0(cd.chan_nr, fhp.arfcn);
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008235 }
8236
8237 if (not match(cd, tr_cd)) {
8238 setverdict(fail, "Channel Description IE does not match: ",
8239 cd, " vs expected ", tr_cd);
8240 }
8241}
8242
8243/* Make sure that the given Mobile Allocation IE matches the hopping configuration */
8244private function f_TC_fh_params_match_ma(in FHParamsTrx fhp, uint3_t tn,
8245 in MobileAllocationLV ma)
8246{
8247 var template MobileAllocationLV tr_ma := f_TC_fh_params_gen_tr_ma(fhp, tn, ma);
8248
8249 if (not match(ma, tr_ma)) {
8250 setverdict(fail, "Mobile Allocation IE does not match (tn := ",
8251 tn, "): ", ma, " vs expected: ", tr_ma);
8252 } else {
8253 setverdict(pass);
8254 }
8255}
8256
8257private function f_TC_fh_params_gen_tr_ma(in FHParamsTrx fhp, uint3_t tn,
8258 in MobileAllocationLV ma)
8259return template MobileAllocationLV {
8260 /* Mobile Allocation IE is expected to be empty if hopping is not enabled */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07008261 if (not fhp.ts[tn].enabled) {
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008262 return { len := 0, ma := ''B };
8263 }
8264
8265 var bitstring full_mask := f_pad_bit(''B, 1024, '0'B);
8266 var bitstring slot_mask := f_pad_bit(''B, 1024, '0'B);
8267 var bitstring ma_mask := ''B;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008268
8269 /* Compose the full bit-mask (all channels, up to 1024 entries) */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07008270 for (var integer i := 0; i < lengthof(fhp.ts); i := i + 1) {
8271 for (var integer j := 0; j < lengthof(fhp.ts[i].ma); j := j + 1) {
8272 if (full_mask[fhp.ts[i].ma[j]] == '1'B)
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008273 { continue; }
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07008274 full_mask[fhp.ts[i].ma[j]] := '1'B;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008275 }
8276 }
8277
Vadim Yanitskiye7c8c6e2020-09-13 14:33:03 +07008278 /* Take ARFCN of the TRX itself into account */
8279 full_mask[fhp.arfcn] := '1'B;
8280
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008281 /* Compose a bit-mask for the given timeslot number */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07008282 for (var integer i := 0; i < lengthof(fhp.ts[tn].ma); i := i + 1) {
8283 slot_mask[fhp.ts[tn].ma[i]] := '1'B;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008284 }
8285
8286 /* Finally, compose the Mobile Allocation bit-mask */
Vadim Yanitskiy3e997362020-09-05 21:08:34 +07008287 for (var integer i := 1; i < lengthof(full_mask); i := i + 1) {
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008288 if (full_mask[i] != '1'B)
8289 { continue; }
8290
8291 /* FIXME: ma_mask := ma_mask & slot_mask[i]; // triggers a bug in TITAN */
8292 if (slot_mask[i] == '1'B) {
8293 ma_mask := ma_mask & '1'B;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008294 } else {
8295 ma_mask := ma_mask & '0'B;
8296 }
8297 }
8298
Vadim Yanitskiy3e997362020-09-05 21:08:34 +07008299 /* ARFCN 0 (if present) goes to the last position of the bit-mask */
8300 if (full_mask[0] == '1'B) {
8301 /* FIXME: ma_mask := ma_mask & slot_mask[0]; // triggers a bug in TITAN */
8302 if (slot_mask[0] == '1'B) {
8303 ma_mask := ma_mask & '1'B;
8304 } else {
8305 ma_mask := ma_mask & '0'B;
8306 }
8307 }
8308
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008309 /* Ensure that ma_mask is octet-aligned */
Vadim Yanitskiy2aa02522020-09-06 14:05:23 +07008310 var integer ma_mask_len := (lengthof(ma_mask) + 8 - 1) / 8;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008311 ma_mask := f_pad_bit(ma_mask, ma_mask_len * 8, '0'B);
8312
8313 return { len := ma_mask_len, ma := ma_mask };
8314}
8315
8316/* Configure the hopping parameters in accordance with the given record */
8317private function f_TC_fh_params_set(in FHParamsTrx fhp,
8318 uint8_t bts_nr := 0,
8319 uint8_t trx_nr := 0)
8320runs on test_CT {
8321 /* Enter the configuration node for the given BTS/TRX numbers */
8322 f_vty_enter_cfg_trx(BSCVTY, bts_nr, trx_nr);
8323
Vadim Yanitskiye7c8c6e2020-09-13 14:33:03 +07008324 f_vty_transceive(BSCVTY, "arfcn " & int2str(fhp.arfcn));
8325
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07008326 for (var integer tn := 0; tn < lengthof(fhp.ts); tn := tn + 1) {
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008327 f_vty_transceive(BSCVTY, "timeslot " & int2str(tn));
8328
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07008329 if (not fhp.ts[tn].enabled) {
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008330 f_vty_transceive(BSCVTY, "hopping enabled 0");
8331 f_vty_transceive(BSCVTY, "exit"); /* go back */
8332 continue;
8333 }
8334
8335 /* Configure HSN / MAIO values */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07008336 f_vty_transceive(BSCVTY, "hopping sequence-number " & int2str(fhp.ts[tn].hsn));
8337 f_vty_transceive(BSCVTY, "hopping maio " & int2str(fhp.ts[tn].maio));
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008338
8339 /* Configure the Mobile Allocation (hopping channels) */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07008340 for (var integer i := 0; i < lengthof(fhp.ts[tn].ma); i := i + 1) {
8341 f_vty_transceive(BSCVTY, "hopping arfcn add " & int2str(fhp.ts[tn].ma[i]));
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008342 }
8343
8344 f_vty_transceive(BSCVTY, "hopping enabled 1");
8345 f_vty_transceive(BSCVTY, "exit"); /* go back */
8346 }
8347
8348 f_vty_transceive(BSCVTY, "end");
8349}
8350
8351/* Disable frequency hopping on all timeslots */
8352private function f_TC_fh_params_unset(in FHParamsTrx fhp,
8353 uint8_t bts_nr := 0,
Vadim Yanitskiye7c8c6e2020-09-13 14:33:03 +07008354 uint8_t trx_nr := 0,
8355 GsmArfcn arfcn := 871)
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008356runs on test_CT {
8357 /* Enter the configuration node for the given BTS/TRX numbers */
8358 f_vty_enter_cfg_trx(BSCVTY, bts_nr, trx_nr);
8359
Vadim Yanitskiye7c8c6e2020-09-13 14:33:03 +07008360 f_vty_transceive(BSCVTY, "arfcn " & int2str(arfcn));
8361
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07008362 for (var integer tn := 0; tn < lengthof(fhp.ts); tn := tn + 1) {
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008363 f_vty_transceive(BSCVTY, "timeslot " & int2str(tn));
8364
8365 /* Delete all ARFCNs from the Mobile Allocation (if any) */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07008366 for (var integer i := 0; i < lengthof(fhp.ts[tn].ma); i := i + 1) {
8367 f_vty_transceive(BSCVTY, "hopping arfcn del " & int2str(fhp.ts[tn].ma[i]));
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008368 }
8369
8370 f_vty_transceive(BSCVTY, "hopping enabled 0");
8371 f_vty_transceive(BSCVTY, "exit"); /* go back */
8372 }
8373
8374 f_vty_transceive(BSCVTY, "end");
8375 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
8376}
8377
8378/* Verify presence and correctness of the hopping parameters (HSN, MAIO)
8379 * in the Channel Identification IE of the RSL CHANnel ACTIVation message. */
8380testcase TC_fh_params_chan_activ() runs on test_CT {
8381 var FHParamsTrx fhp := f_TC_fh_params_gen();
8382 var RSL_Message rsl_msg;
8383 var RSL_IE_Body ie;
8384
8385 f_init_vty();
8386
8387 f_TC_fh_params_set(fhp); /* Enable frequency hopping */
8388 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
8389
8390 f_init(1);
8391
8392 /* CS domain: 3 (SDCCH/4+CBCH) + 4 (TCH/F) + 2 (TCH/H) channels available */
8393 for (var integer i := 0; i < 9; i := i + 1) {
8394 f_ipa_tx(0, ts_RSL_CHAN_RQD(f_rnd_ra_cs(), 23));
8395 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
8396
8397 /* Make sure that Channel Identification IE is present */
8398 if (not f_rsl_find_ie(rsl_msg, RSL_IE_CHAN_IDENT, ie)) {
8399 setverdict(fail, "RSL Channel Identification IE is absent");
8400 continue;
8401 }
8402
8403 /* Make sure that hopping parameters (HSN/MAIO) match */
8404 f_TC_fh_params_match_chan_desc(fhp, ie.chan_ident.ch_desc.v);
8405
8406 /* "Mobile Allocation shall be included but empty" - let's check this */
8407 if (ie.chan_ident.ma.v.len != 0) {
8408 setverdict(fail, "Mobile Allocation IE is not empty: ",
8409 ie.chan_ident.ma, ", despite it shall be");
8410 continue;
8411 }
8412 }
8413
8414 /* Disable frequency hopping */
8415 f_TC_fh_params_unset(fhp);
8416
Vadim Yanitskiy21726312020-09-04 01:45:36 +07008417 f_shutdown_helper();
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008418}
8419
8420/* Verify the hopping parameters (HSN, MAIO, MA) in (RR) Immediate Assignment */
8421testcase TC_fh_params_imm_ass() runs on test_CT {
8422 var FHParamsTrx fhp := f_TC_fh_params_gen();
8423 var RSL_Message rsl_msg;
8424 var RSL_IE_Body ie;
8425
8426 f_init_vty();
8427
8428 f_TC_fh_params_set(fhp); /* Enable frequency hopping */
8429 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
8430
8431 f_init(1);
8432
8433 /* CS domain: 3 (SDCCH/4+CBCH) + 4 (TCH/F) + 2 (TCH/H) channels available */
8434 for (var integer i := 0; i < 9; i := i + 1) {
8435 f_ipa_tx(0, ts_RSL_CHAN_RQD(f_rnd_ra_cs(), 23));
8436 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
8437
8438 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(rsl_msg.ies[0].body.chan_nr, 33));
8439 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeC(RSL_MT_IMMEDIATE_ASSIGN_CMD));
8440
8441 /* Make sure that Full Immediate Assign Info IE is present */
8442 if (not f_rsl_find_ie(rsl_msg, RSL_IE_FULL_IMM_ASS_INFO, ie)) {
8443 setverdict(fail, "RSL Full Immediate Assign Info IE is absent");
8444 continue;
8445 }
8446
8447 /* Decode the actual Immediate Assignment message */
8448 var GsmRrMessage rr_msg := dec_GsmRrMessage(ie.full_imm_ass_info.payload);
8449 if (not match(rr_msg.header, t_RrHeader(IMMEDIATE_ASSIGNMENT, ?))) {
8450 setverdict(fail, "Failed to match Immediate Assignment: ", rr_msg);
8451 continue;
8452 }
8453
8454 /* Make sure that hopping parameters (HSN/MAIO) match */
8455 f_TC_fh_params_match_chan_desc(fhp, rr_msg.payload.imm_ass.chan_desc);
8456
8457 /* Make sure that the Mobile Allocation IE matches */
8458 f_TC_fh_params_match_ma(fhp, rr_msg.payload.imm_ass.chan_desc.chan_nr.tn,
8459 rr_msg.payload.imm_ass.mobile_allocation);
8460 }
8461
8462 /* Disable frequency hopping */
8463 f_TC_fh_params_unset(fhp);
Philipp Maier82812002020-08-13 18:48:27 +02008464
Vadim Yanitskiy21726312020-09-04 01:45:36 +07008465 f_shutdown_helper();
Philipp Maier82812002020-08-13 18:48:27 +02008466}
8467
Vadim Yanitskiyaeb54a22020-09-01 06:25:25 +07008468/* Verify the hopping parameters (HSN, MAIO, MA) in (RR) Assignment Command */
8469testcase TC_fh_params_assignment_cmd() runs on test_CT {
8470 var FHParamsTrx fhp := f_TC_fh_params_gen();
8471 var RSL_Message rsl_msg;
8472 var RSL_IE_Body ie;
8473
8474 f_init_vty();
8475
8476 f_TC_fh_params_set(fhp); /* Enable frequency hopping */
8477 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
8478
8479 f_init(1);
8480
8481 /* HACK: work around "Couldn't find Expect for CRCX" */
8482 vc_MGCP.stop;
8483
8484 var template PDU_BSSAP ass_cmd := f_gen_ass_req();
8485 ass_cmd.pdu.bssmap.assignmentRequest.codecList := ts_BSSMAP_IE_CodecList({ts_CodecFR});
8486
8487 /* CS domain (TCH): 4 (TCH/F) + 2 (TCH/H) channels available
8488 * NOTE: only 3 SDCCH/4 channels are available on CCCH+SDCCH4+CBCH */
8489 for (var integer i := 0; i < 3; i := i + 1) {
8490 /* Establish a dedicated channel, so we can trigger (late) TCH assignment */
8491 var DchanTuple dt := f_est_dchan(f_rnd_ra_cs(), 23, f_rnd_octstring(16));
8492
8493 /* Send a BSSMAP Assignment Command, expect CHANnel ACTIVation */
8494 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ass_cmd));
8495 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
8496
8497 /* ACKnowledge CHANnel ACTIVation, expect RSL DATA REQuest */
8498 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(rsl_msg.ies[0].body.chan_nr, 33));
8499 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeR(RSL_MT_DATA_REQ));
8500
8501 /* Make sure that L3 Information IE is present */
8502 if (not f_rsl_find_ie(rsl_msg, RSL_IE_L3_INFO, ie)) {
8503 setverdict(fail, "RSL L3 Information IE is absent");
8504 continue;
8505 }
8506
8507 /* Decode the L3 message and make sure it is (RR) Assignment Command */
8508 var GsmRrL3Message l3_msg := dec_GsmRrL3Message(ie.l3_info.payload);
8509 if (not match(l3_msg.header, t_RrL3Header(ASSIGNMENT_COMMAND))) {
8510 setverdict(fail, "Failed to match Assignment Command: ", l3_msg);
8511 continue;
8512 }
8513
8514 /* Make sure that hopping parameters (HSN/MAIO) match */
8515 var ChannelDescription chan_desc := l3_msg.payload.ass_cmd.chan_desc;
8516 f_TC_fh_params_match_chan_desc(fhp, chan_desc);
8517
8518 /* Make sure that Cell Channel Description IE is present if FH is enabled */
8519 if (chan_desc.h and not ispresent(l3_msg.payload.ass_cmd.cell_chan_desc)) {
Vadim Yanitskiy38d069d2020-09-02 17:18:57 +07008520 setverdict(fail, "FH enabled, but Cell Channel Description IE is absent");
Vadim Yanitskiyaeb54a22020-09-01 06:25:25 +07008521 continue;
8522 }
8523
8524 /* Make sure that the Mobile Allocation IE matches (if present) */
8525 var boolean ma_present := ispresent(l3_msg.payload.ass_cmd.mobile_allocation);
8526 if (chan_desc.h and ma_present) {
8527 f_TC_fh_params_match_ma(fhp, chan_desc.chan_nr.tn,
8528 l3_msg.payload.ass_cmd.mobile_allocation.v);
8529 } else if (chan_desc.h and not ma_present) {
8530 setverdict(fail, "FH enabled, but Mobile Allocation IE is absent");
8531 continue;
8532 } else if (not chan_desc.h and ma_present) {
8533 setverdict(fail, "FH disabled, but Mobile Allocation IE is present");
8534 continue;
8535 }
8536 }
8537
8538 /* Give the IUT some time to release all channels */
8539 f_sleep(3.0);
8540
8541 /* Disable frequency hopping */
8542 f_TC_fh_params_unset(fhp);
8543
Vadim Yanitskiy21726312020-09-04 01:45:36 +07008544 f_shutdown_helper();
Vadim Yanitskiyaeb54a22020-09-01 06:25:25 +07008545}
8546
Vadim Yanitskiy8f5430d2020-09-02 18:51:38 +07008547/* Verify the hopping parameters (HSN, MAIO, MA) in (RR) Handover Command */
8548private function f_TC_fh_params_handover_cmd(in FHParamsTrx fhp)
8549runs on test_CT {
8550 var RSL_Message rsl_msg;
8551 var RSL_IE_Body ie;
8552 var DchanTuple dt;
8553
8554 /* Establish a dedicated channel, so we can trigger handover */
8555 dt := f_est_dchan(f_rnd_ra_cs(), 23, f_rnd_octstring(16));
8556
8557 /* Trigger handover from BTS0 to BTS1 */
8558 f_bts_0_cfg(BSCVTY, { "neighbor bts 1" });
8559 f_vty_handover(BSCVTY, 0, 0, dt.rsl_chan_nr, 1);
8560
8561 /* Expect RSL CHANnel ACTIVation on BTS1/TRX0/TS1 */
8562 rsl_msg := f_exp_ipa_rx(1, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
8563
8564 /* ACKnowledge channel activation and expect (RR) Handover Command */
8565 f_ipa_tx(1, ts_RSL_CHAN_ACT_ACK(rsl_msg.ies[0].body.chan_nr, 33));
8566 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeR(RSL_MT_DATA_REQ));
8567
8568 /* Make sure that L3 Information IE is present */
8569 if (not f_rsl_find_ie(rsl_msg, RSL_IE_L3_INFO, ie)) {
8570 setverdict(fail, "RSL L3 Information IE is absent");
8571 return;
8572 }
8573
8574 /* Decode the L3 message and make sure it is (RR) Handover Command */
8575 var GsmRrL3Message l3_msg := dec_GsmRrL3Message(ie.l3_info.payload);
8576 if (not match(l3_msg.header, t_RrL3Header(HANDOVER_COMMAND))) {
8577 setverdict(fail, "Failed to match Handover Command: ", l3_msg);
8578 return;
8579 }
8580
8581 /* Make sure that we've got SDCCH/8 on TS1 (expected to be hopping) */
8582 var ChannelDescription chan_desc := l3_msg.payload.ho_cmd.chan_desc;
8583 if (not match(chan_desc.chan_nr, t_RslChanNr_SDCCH8(1, ?))) {
8584 setverdict(fail, "Unexpected channel number: ", chan_desc.chan_nr);
8585 return;
8586 }
8587
8588 /* Make sure that hopping parameters (HSN/MAIO) match */
8589 f_TC_fh_params_match_chan_desc(fhp, chan_desc);
8590
8591 /* Make sure that Cell Channel Description IE is present */
8592 if (not ispresent(l3_msg.payload.ho_cmd.cell_chan_desc)) {
8593 setverdict(fail, "FH enabled, but Cell Channel Description IE is absent");
8594 return;
8595 }
8596
8597 /* Make sure that the Mobile Allocation (after time) IE is present and matches */
8598 var boolean ma_present := ispresent(l3_msg.payload.ho_cmd.mobile_allocation);
8599 if (ma_present) {
8600 f_TC_fh_params_match_ma(fhp, chan_desc.chan_nr.tn,
8601 l3_msg.payload.ho_cmd.mobile_allocation.v);
8602 } else {
8603 setverdict(fail, "FH enabled, but Mobile Allocation IE is absent");
8604 return;
8605 }
8606}
8607testcase TC_fh_params_handover_cmd() runs on test_CT {
8608 var FHParamsTrx fhp := f_TC_fh_params_gen();
8609
8610 f_init_vty();
8611
8612 /* (Re)configure TS0 as BCCH and TS1 as SDCCH8 on BTS1/TRX0 */
8613 f_vty_enter_cfg_trx(BSCVTY, bts := 1, trx := 0);
8614
8615 f_vty_transceive(BSCVTY, "timeslot 0");
8616 f_vty_transceive(BSCVTY, "phys_chan_config ccch");
8617 f_vty_transceive(BSCVTY, "exit"); /* go back */
8618
8619 f_vty_transceive(BSCVTY, "timeslot 1");
8620 f_vty_transceive(BSCVTY, "phys_chan_config sdcch8");
8621 f_vty_transceive(BSCVTY, "end"); /* we're done */
8622
8623 f_TC_fh_params_set(fhp, 1); /* Enable frequency hopping on BTS1 */
8624 f_vty_transceive(BSCVTY, "drop bts connection 1 oml");
8625
8626 f_init(2);
8627
8628 f_TC_fh_params_handover_cmd(fhp);
8629
8630 /* Disable frequency hopping on BTS1 */
8631 f_TC_fh_params_unset(fhp, 1);
8632
8633 /* (Re)configure TS0 as CCCH+SDCCH4+CBCH and TS1 as TCH/F */
8634 f_vty_enter_cfg_trx(BSCVTY, bts := 1, trx := 0);
8635
8636 f_vty_transceive(BSCVTY, "timeslot 0");
8637 f_vty_transceive(BSCVTY, "phys_chan_config ccch+sdcch4+cbch");
8638 f_vty_transceive(BSCVTY, "exit"); /* go back */
8639
8640 f_vty_transceive(BSCVTY, "timeslot 1");
8641 f_vty_transceive(BSCVTY, "phys_chan_config tch/f");
8642 f_vty_transceive(BSCVTY, "end"); /* we're done */
8643
8644 f_shutdown_helper();
8645}
8646
Vadim Yanitskiyca974032020-09-01 07:20:39 +07008647/* Verify the hopping parameters in System Information Type 4 */
8648testcase TC_fh_params_si4_cbch() runs on test_CT {
8649 var FHParamsTrx fhp := f_TC_fh_params_gen(tr_tn := 1);
8650 var ASP_RSL_Unitdata rx_rsl_ud;
8651 timer T := 5.0;
8652
8653 f_init_vty();
8654
8655 /* (Re)configure TS0 as BCCH and TS1 as SDCCH8+CBCH */
8656 f_vty_enter_cfg_trx(BSCVTY, trx := 0);
8657
8658 f_vty_transceive(BSCVTY, "timeslot 0");
8659 f_vty_transceive(BSCVTY, "phys_chan_config ccch");
8660 f_vty_transceive(BSCVTY, "exit"); /* go back */
8661
8662 f_vty_transceive(BSCVTY, "timeslot 1");
8663 f_vty_transceive(BSCVTY, "phys_chan_config sdcch8+cbch");
8664 f_vty_transceive(BSCVTY, "end"); /* we're done */
8665
8666 f_TC_fh_params_set(fhp); /* Enable frequency hopping */
8667 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
8668
8669 f_init(1);
8670
8671 T.start;
8672 alt {
8673 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_BCCH_INFO(RSL_SYSTEM_INFO_4))) -> value rx_rsl_ud {
8674 var RSL_IE_Body ie := rx_rsl_ud.rsl.ies[2].body; /* FULL BCCH Information IE */
8675 var SystemInformation si := dec_SystemInformation(ie.other.payload);
8676
8677 /* Make sure that what we decoded is System Information Type 4 */
8678 if (si.header.message_type != SYSTEM_INFORMATION_TYPE_4) {
8679 setverdict(fail, "RSL FULL BCCH Information IE contains: ", si);
8680 repeat;
8681 }
8682
8683 /* Make sure that CBCH Channel Description IE is present */
8684 if (not ispresent(si.payload.si4.cbch_chan_desc)) {
8685 setverdict(fail, "CBCH Channel Description IE is absent");
8686 break;
8687 }
8688
8689 /* Finally, check the hopping parameters (HSN, MAIO) */
8690 var ChannelDescription chan_desc := si.payload.si4.cbch_chan_desc.v;
8691 f_TC_fh_params_match_chan_desc(fhp, chan_desc);
8692
8693 /* 3GPP TS 44.018, section 9.1.36.2 "CBCH Mobile Allocation":
8694 * The CBCH Mobile Allocation IE *shall* be present if FH is enabled. */
8695 if (chan_desc.h and not ispresent(si.payload.si4.cbch_mobile_alloc)) {
8696 setverdict(fail, "FH enabled, but Mobile Allocation IE is absent");
8697 break;
8698 } else if (chan_desc.h and ispresent(si.payload.si4.cbch_mobile_alloc)) {
8699 f_TC_fh_params_match_ma(fhp, chan_desc.chan_nr.tn,
8700 si.payload.si4.cbch_mobile_alloc.v);
8701 }
8702 }
8703 [] IPA_RSL[0].receive { repeat; }
8704 [] T.timeout {
8705 setverdict(fail, "Timeout waiting for RSL BCCH INFOrmation (SI4)");
8706 }
8707 }
8708
8709 /* Disable frequency hopping */
8710 f_TC_fh_params_unset(fhp);
8711
Vadim Yanitskiy8bc46012020-09-06 12:38:01 +07008712 /* (Re)configure TS0 as CCCH+SDCCH4+CBCH and TS1 as TCH/F */
Vadim Yanitskiyca974032020-09-01 07:20:39 +07008713 f_vty_enter_cfg_trx(BSCVTY, trx := 0);
8714
8715 f_vty_transceive(BSCVTY, "timeslot 0");
Vadim Yanitskiy8bc46012020-09-06 12:38:01 +07008716 f_vty_transceive(BSCVTY, "phys_chan_config ccch+sdcch4+cbch");
Vadim Yanitskiyca974032020-09-01 07:20:39 +07008717 f_vty_transceive(BSCVTY, "exit"); /* go back */
8718
8719 f_vty_transceive(BSCVTY, "timeslot 1");
8720 f_vty_transceive(BSCVTY, "phys_chan_config tch/f");
8721 f_vty_transceive(BSCVTY, "end"); /* we're done */
8722
Vadim Yanitskiy21726312020-09-04 01:45:36 +07008723 f_shutdown_helper();
Vadim Yanitskiyca974032020-09-01 07:20:39 +07008724}
8725
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02008726template (value) PDU_BSSAP_LE ts_BSSMAP_LE_BSSLAP(template (value) BSSLAP_PDU bsslap)
8727 := ts_BSSMAP_LE_ConnInfo(BSSMAP_LE_PROT_BSSLAP, data := enc_BSSLAP_PDU(valueof(bsslap)));
8728
8729private function f_match_bsslap(PDU_BSSAP_LE got_bsslap_msg,
8730 template (present) BSSLAP_PDU expect_bsslap)
8731{
8732 var BSSLAP_PDU bsslap := dec_BSSLAP_PDU(got_bsslap_msg.pdu.bssmap.co_info.bsslap_apdu.data);
8733 if (not match(bsslap, expect_bsslap)) {
8734 log("EXPECTING BSSLAP: ", expect_bsslap);
8735 log("GOT BSSLAP: ", bsslap);
8736 setverdict(fail, "BSSLAP is not as expected");
8737 mtc.stop;
8738 }
8739 setverdict(pass);
8740}
8741
8742/* GAD: this is an Ellipsoid point with uncertainty circle, encoded as in 3GPP TS 23.032 §7.3.2. */
8743const octetstring gad_ell_point_unc_circle := '10b0646d0d5f6627'O;
8744
8745private function f_expect_bsslap(template (present) BSSLAP_PDU expect_rx_bsslap) runs on MSC_ConnHdlr {
8746 var PDU_BSSAP_LE rx_bsslap;
8747 BSSAP_LE.receive(tr_BSSMAP_LE_ConnInfo(BSSMAP_LE_PROT_BSSLAP, ?)) -> value(rx_bsslap);
8748 f_match_bsslap(rx_bsslap, expect_rx_bsslap);
8749}
8750
8751/* With an active lchan, start BSSMAP Perform Location Request on A interface, starting BSSMAP-LE Perform Location
8752 * Request on Lb interface. Either with or without the SMLC doing a BSSLAP TA Request. */
8753private function f_lcs_loc_req_for_active_ms(boolean do_ta_request := false) runs on MSC_ConnHdlr {
8754 f_sleep(1.0);
8755
8756 f_establish_fully(omit, omit);
8757 f_bssap_le_register_imsi(g_pars.imsi, omit);
8758
8759 BSSAP.send(valueof(ts_BSSMAP_Perform_Location_Request(ts_BSSMAP_Imsi(g_pars.imsi),
8760 ts_CellId_CGI('262'H, '42'H, 23, 42))));
8761
8762 var PDU_BSSAP_LE plr;
8763 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocReq(BSSMAP_LE_LOC_INFO_CURRENT_GEOGRAPHIC_LOC, ?, ?)) -> value(plr);
8764
8765 if (not do_ta_request) {
8766 /* verify TA Layer 3 in APDU. First the APDU type (BSSLAP), then the BSSLAP data contents. */
8767 var template BSSMAP_LE_IE_APDU expect_apdu := tr_BSSMAP_LE_APDU(BSSMAP_LE_PROT_BSSLAP, ?);
8768 if (not match(plr.pdu.bssmap.perf_loc_req.bsslap_apdu, expect_apdu)) {
8769 log("EXPECTING BSSMAP-LE APDU IE ", expect_apdu);
8770 log("GOT BSSMAP-LE APDU IE ", plr.pdu.bssmap.perf_loc_req.bsslap_apdu);
8771 setverdict(fail, "BSSMAP-LE APDU IE is not as expected");
8772 mtc.stop;
8773 }
8774 var template BSSLAP_PDU expect_ta_layer3 := tr_BSSLAP_TA_Layer3(tr_BSSLAP_IE_TA(0));
8775 var BSSLAP_PDU bsslap := dec_BSSLAP_PDU(plr.pdu.bssmap.perf_loc_req.bsslap_apdu.data);
8776 if (not match(bsslap, expect_ta_layer3)) {
8777 log("EXPECTING BSSLAP TA Layer 3: ", expect_ta_layer3);
8778 log("GOT BSSLAP: ", bsslap);
8779 setverdict(fail, "BSSLAP is not as expected");
8780 mtc.stop;
8781 }
8782 /* OsmoBSC directly sent the TA as BSSLAP APDU in the BSSMAP-LE Perform Location Request to the SMLC. The SMLC
8783 * has no need to request the TA from the BSC and directly responds. */
8784 } else {
8785 /* SMLC wants to ask the TA from the BSC explicitly in a BSSLAP TA Request message */
8786 BSSAP_LE.send(ts_BSSMAP_LE_BSSLAP(ts_BSSLAP_TA_Req));
8787 f_expect_bsslap(tr_BSSLAP_TA_Resp(?, ?));
8788 }
8789
8790 /* SMLC got the TA from the BSC, now responds with geo information data. */
8791 BSSAP_LE.send(ts_BSSMAP_LE_PerfLocResp(gad_ell_point_unc_circle, omit));
8792 BSSAP_LE.receive(BSSAP_LE_Conn_Prim:CONN_PRIM_DISC_IND);
8793 BSSAP.receive(tr_BSSMAP_Perform_Location_Response(tr_BSSMAP_IE_LocationEstimate(gad_ell_point_unc_circle)));
8794
8795 /* The LCS was using an active A-interface conn. It should still remain active after this. */
8796 f_mo_l3_transceive();
8797
Neels Hofmeyr85bcd272021-07-22 19:14:48 +02008798 f_perform_clear();
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02008799
8800 f_sleep(2.0);
8801 setverdict(pass);
8802}
8803
8804/* With an active lchan, start BSSMAP Perform Location Request on A interface, starting BSSMAP-LE Perform Location
8805 * Request on Lb interface. Without the SMLC doing a BSSLAP TA Request. */
8806private function f_tc_lcs_loc_req_for_active_ms(charstring id) runs on MSC_ConnHdlr {
8807 f_lcs_loc_req_for_active_ms(false);
8808}
8809testcase TC_lcs_loc_req_for_active_ms() runs on test_CT {
8810 var MSC_ConnHdlr vc_conn;
8811 var TestHdlrParams pars := f_gen_test_hdlr_pars();
8812
8813 f_init(1, true);
8814 f_sleep(1.0);
8815 vc_conn := f_start_handler(refers(f_tc_lcs_loc_req_for_active_ms), pars);
8816 vc_conn.done;
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01008817 f_shutdown_helper();
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02008818}
8819
8820/* With an active lchan, start BSSMAP Perform Location Request on A interface, starting BSSMAP-LE Perform Location
8821 * Request on Lb interface. With the SMLC doing a BSSLAP TA Request. */
8822private function f_tc_lcs_loc_req_for_active_ms_ta_req(charstring id) runs on MSC_ConnHdlr {
8823 f_lcs_loc_req_for_active_ms(true);
8824}
8825testcase TC_lcs_loc_req_for_active_ms_ta_req() runs on test_CT {
8826 var MSC_ConnHdlr vc_conn;
8827 var TestHdlrParams pars := f_gen_test_hdlr_pars();
8828
8829 f_init(1, true);
8830 f_sleep(1.0);
8831 vc_conn := f_start_handler(refers(f_tc_lcs_loc_req_for_active_ms_ta_req), pars);
8832 vc_conn.done;
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01008833 f_shutdown_helper();
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02008834}
8835
8836/* Clear the A-interface conn only, without doing anything on Abis. Useful for LCS, for cases where there is only an A
8837 * conn without an active lchan. */
8838private function f_clear_A_conn() runs on MSC_ConnHdlr
8839{
8840 var BssmapCause cause := 0;
8841 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
8842 BSSAP.receive(tr_BSSMAP_ClearComplete);
8843 BSSAP.send(RAN_Conn_Prim:MSC_CONN_PRIM_DISC_REQ);
8844
8845 timer no_more_bssap := 5.0;
8846 no_more_bssap.start;
8847 alt {
8848 [] no_more_bssap.timeout { break; }
8849 [] BSSAP.receive(tr_BSSAP_BSSMAP) {
8850 setverdict(fail, "Expected no more BSSAP after Clear Complete");
8851 mtc.stop;
8852 }
8853 }
8854 setverdict(pass);
8855}
8856
8857/* Verify that the A-interface connection is still working, and then clear it, without doing anything on Abis. Useful
8858 * for LCS, for cases where there is only an A conn without an active lchan. */
8859private function f_verify_active_A_conn_and_clear() runs on MSC_ConnHdlr
8860{
8861 f_logp(BSCVTY, "f_verify_active_A_conn_and_clear: test A link, then clear");
8862
8863 /* When an lchan is active, we can send some L3 data from the BTS side and verify that it shows up on the other
8864 * side towards the MSC. When there is no lchan, this is not possible. To probe whether the A-interface
8865 * connection is still up, we need something that echos back on the A-interface. Another LCS request! */
8866 BSSAP.send(valueof(ts_BSSMAP_Perform_Location_Request(ts_BSSMAP_Imsi(g_pars.imsi),
8867 ts_CellId_CGI('262'H, '42'H, 23, 42))));
8868 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocReq(BSSMAP_LE_LOC_INFO_CURRENT_GEOGRAPHIC_LOC, ?, ?));
8869
8870 /* Right, the Perform Location Request showed up on Lb, now we can clear the A conn. */
8871 f_clear_A_conn();
8872 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocAbort(BSSMAP_LE_LCS_CAUSE_REQUEST_ABORTED));
8873 BSSAP_LE.receive(BSSAP_LE_Conn_Prim:CONN_PRIM_DISC_IND);
8874}
8875
8876/* With *no* active lchan, start BSSMAP Perform Location Request on A interface, starting BSSMAP-LE Perform Location
8877 * Request on Lb interface. BSC will Page for the subscriber as soon as we (virtual SMLC) request the TA via BSSLAP.
8878 */
8879private function f_tc_lcs_loc_req_for_idle_ms(charstring id) runs on MSC_ConnHdlr {
8880 f_sleep(1.0);
8881
8882 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
8883 f_bssap_le_register_imsi(g_pars.imsi, omit);
8884
8885 /* Register to receive the Paging Command */
8886 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
8887 g_chan_nr := new_chan_nr;
8888 f_rslem_register(0, g_chan_nr);
8889
8890 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
8891 valueof(ts_BSSMAP_Perform_Location_Request(ts_BSSMAP_Imsi(g_pars.imsi),
8892 ts_CellId_CGI('001'H, '01'H, 1, 0)))));
8893 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
8894
8895 var PDU_BSSAP_LE plr;
8896 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocReq(BSSMAP_LE_LOC_INFO_CURRENT_GEOGRAPHIC_LOC, ?, ?)) -> value(plr);
8897
8898 /* SMLC wants to ask the TA from the BSC explicitly in a BSSLAP TA Request message */
8899 BSSAP_LE.send(ts_BSSMAP_LE_BSSLAP(ts_BSSLAP_TA_Req));
8900
8901 /* OsmoBSC needs to Page */
8902 RSL.receive(tr_RSL_PAGING_CMD(tr_MI_IMSI(g_pars.imsi)));
8903 f_logp(BSCVTY, "got Paging Command");
8904
8905 /* MS requests channel. Since the Paging was for LCS, the Paging Response does not trigger a Complete Layer 3 to
8906 * the MSC, and releases the lchan directly. */
Neels Hofmeyr85bcd272021-07-22 19:14:48 +02008907 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);
8908 f_expect_lchan_rel(RSL, RSL_PROC);
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02008909
8910 /* From the Paging Response, the TA is now known to the BSC, and it responds to the SMLC. */
8911
8912 f_expect_bsslap(tr_BSSLAP_TA_Resp(?, ?));
8913
8914 /* SMLC got the TA from the BSC, now responds with geo information data. */
8915 BSSAP_LE.send(ts_BSSMAP_LE_PerfLocResp(gad_ell_point_unc_circle, omit));
8916 BSSAP_LE.receive(BSSAP_LE_Conn_Prim:CONN_PRIM_DISC_IND);
8917
8918 BSSAP.receive(tr_BSSMAP_Perform_Location_Response(tr_BSSMAP_IE_LocationEstimate(gad_ell_point_unc_circle)));
8919
8920 /* The lchan is gone, the A-interface conn was created for the LCS only.
8921 * Still it is clearly the MSC's job to decide whether to tear down the conn or not. */
8922 f_verify_active_A_conn_and_clear();
8923
8924 f_sleep(2.0);
8925 setverdict(pass);
8926}
8927testcase TC_lcs_loc_req_for_idle_ms() runs on test_CT {
8928 var MSC_ConnHdlr vc_conn;
8929 var TestHdlrParams pars := f_gen_test_hdlr_pars();
8930
8931 f_init(1, true);
8932 f_sleep(1.0);
8933
8934 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
8935 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
8936
8937 vc_conn := f_start_handler(refers(f_tc_lcs_loc_req_for_idle_ms), pars);
8938 vc_conn.done;
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01008939 f_shutdown_helper();
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02008940}
8941
8942/* With no active lchan, start BSSMAP Perform Location Request on A interface, but omit IMSI; expect failure response.
8943 */
8944private function f_tc_lcs_loc_req_no_subscriber(charstring id) runs on MSC_ConnHdlr {
8945 f_sleep(1.0);
8946
8947 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
8948 f_bssap_le_register_imsi(g_pars.imsi, omit);
8949
8950 /* provoke an abort by omitting both IMSI and IMEI */
8951 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
8952 valueof(ts_BSSMAP_Perform_Location_Request(omit,
8953 ts_CellId_CGI('262'H, '42'H, 23, 42)))));
8954 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
8955
8956 /* BSC tells MSC about failure */
8957 BSSAP.receive(tr_BSSMAP_Perform_Location_Response(
8958 locationEstimate := omit, positioningData := omit,
8959 lCS_Cause := tr_BSSMAP_LcsCause(BSSMAP_LCS_CAUSE_DATA_MISSING_IN_REQ)));
8960
8961 /* There is no lchan. Still the MSC's job to decide whether to tear down the conn or not. */
8962 f_verify_active_A_conn_and_clear();
8963
8964 f_sleep(2.0);
8965 setverdict(pass);
8966}
8967testcase TC_lcs_loc_req_no_subscriber() runs on test_CT {
8968 var MSC_ConnHdlr vc_conn;
8969 var TestHdlrParams pars := f_gen_test_hdlr_pars();
8970
8971 f_init(1, true);
8972 f_sleep(1.0);
8973
8974 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
8975 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
8976
8977 vc_conn := f_start_handler(refers(f_tc_lcs_loc_req_no_subscriber), pars);
8978 vc_conn.done;
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01008979 f_shutdown_helper();
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02008980}
8981
8982/* With an active lchan, start a Perform Location Request on the A-interface, but virtual SMLC does not answer with
8983 * BSSMAP-LE Perform Location Response (before or after sending a BSSLAP TA Request) */
8984private function f_lcs_loc_req_for_active_ms_le_timeout(boolean do_ta) runs on MSC_ConnHdlr {
8985 f_sleep(1.0);
8986
8987 f_establish_fully(omit, omit);
8988 f_bssap_le_register_imsi(g_pars.imsi, omit);
8989
8990 BSSAP.send(valueof(ts_BSSMAP_Perform_Location_Request(ts_BSSMAP_Imsi(g_pars.imsi),
8991 ts_CellId_CGI('262'H, '42'H, 23, 42))));
8992
8993 var PDU_BSSAP_LE plr;
8994 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocReq(BSSMAP_LE_LOC_INFO_CURRENT_GEOGRAPHIC_LOC, ?, ?)) -> value(plr);
8995
8996 if (do_ta) {
8997 /* SMLC wants to ask the TA from the BSC explicitly in a BSSLAP TA Request message */
8998 BSSAP_LE.send(ts_BSSMAP_LE_BSSLAP(ts_BSSLAP_TA_Req));
8999 f_expect_bsslap(tr_BSSLAP_TA_Resp(?, ?));
9000 }
9001
9002 /* SMLC fails to respond, BSC runs into timeout */
9003 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocAbort(BSSMAP_LE_LCS_CAUSE_SYSTEM_FAILURE));
9004 BSSAP_LE.receive(BSSAP_LE_Conn_Prim:CONN_PRIM_DISC_IND);
9005
9006 BSSAP.receive(tr_BSSMAP_Perform_Location_Response(
9007 locationEstimate := omit, positioningData := omit,
9008 lCS_Cause := tr_BSSMAP_LcsCause(BSSMAP_LCS_CAUSE_SYSTEM_FAILURE)));
9009
9010 /* There is no lchan. Still the MSC's job to decide whether to tear down the conn or not. */
9011 f_verify_active_A_conn_and_clear();
9012
9013 f_sleep(2.0);
9014 setverdict(pass);
9015}
9016
9017/* With an active lchan, start a Perform Location Request on the A-interface, but virtual SMLC does not answer with
9018 * BSSMAP-LE Perform Location Response, without sending a BSSLAP TA Request. */
9019private function f_tc_lcs_loc_req_for_active_ms_le_timeout(charstring id) runs on MSC_ConnHdlr {
9020 f_lcs_loc_req_for_active_ms_le_timeout(false);
9021}
9022
9023testcase TC_lcs_loc_req_for_active_ms_le_timeout() runs on test_CT {
9024 var MSC_ConnHdlr vc_conn;
9025 var TestHdlrParams pars := f_gen_test_hdlr_pars();
9026
9027 f_init(1, true);
9028 f_sleep(1.0);
9029 vc_conn := f_start_handler(refers(f_tc_lcs_loc_req_for_active_ms_le_timeout), pars);
9030 vc_conn.done;
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01009031 f_shutdown_helper();
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02009032}
9033
9034/* With an active lchan, start a Perform Location Request on the A-interface, but virtual SMLC does not answer with
9035 * BSSMAP-LE Perform Location Response, after sending a BSSLAP TA Request. */
9036private function f_tc_lcs_loc_req_for_active_ms_le_timeout2(charstring id) runs on MSC_ConnHdlr {
9037 f_lcs_loc_req_for_active_ms_le_timeout(true);
9038}
9039
9040testcase TC_lcs_loc_req_for_active_ms_le_timeout2() runs on test_CT {
9041 var MSC_ConnHdlr vc_conn;
9042 var TestHdlrParams pars := f_gen_test_hdlr_pars();
9043
9044 f_init(1, true);
9045 f_sleep(1.0);
9046 vc_conn := f_start_handler(refers(f_tc_lcs_loc_req_for_active_ms_le_timeout2), pars);
9047 vc_conn.done;
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01009048 f_shutdown_helper();
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02009049}
9050
9051/* With *no* active lchan, start a Perform Location Request, expecting that the MS will be Paged. */
9052private function f_tc_lcs_loc_req_for_idle_ms_no_pag_resp(charstring id) runs on MSC_ConnHdlr {
9053 f_sleep(1.0);
9054
9055 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
9056 f_bssap_le_register_imsi(g_pars.imsi, omit);
9057
9058 /* Register to receive the Paging Command */
9059 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
9060 g_chan_nr := new_chan_nr;
9061 f_rslem_register(0, g_chan_nr);
9062
9063 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
9064 valueof(ts_BSSMAP_Perform_Location_Request(ts_BSSMAP_Imsi(g_pars.imsi),
9065 ts_CellId_CGI('001'H, '01'H, 1, 0)))));
9066 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
9067
9068 var PDU_BSSAP_LE plr;
9069 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocReq(BSSMAP_LE_LOC_INFO_CURRENT_GEOGRAPHIC_LOC, ?, ?)) -> value(plr);
9070
9071 /* SMLC wants to ask the TA from the BSC explicitly in a BSSLAP TA Request message */
9072 BSSAP_LE.send(ts_BSSMAP_LE_BSSLAP(ts_BSSLAP_TA_Req));
9073
9074 /* OsmoBSC needs to Page */
9075 var PDU_BSSAP_LE rx_bsslap;
9076 alt {
9077 [] RSL.receive(tr_RSL_PAGING_CMD(tr_MI_IMSI(g_pars.imsi))) {
9078 f_logp(BSCVTY, "got Paging Command");
9079 repeat;
9080 }
9081 [] BSSAP_LE.receive(tr_BSSMAP_LE_ConnInfo(BSSMAP_LE_PROT_BSSLAP, ?)) -> value(rx_bsslap) {
9082 /* MS does not respond to Paging, TA Req runs into timeout. */
9083 f_match_bsslap(rx_bsslap, tr_BSSLAP_Abort(?));
9084 }
9085 }
9086
9087 /* SMLC responds with failure */
9088 BSSAP_LE.send(ts_BSSMAP_LE_PerfLocResp(omit, BSSMAP_LE_LCS_CAUSE_REQUEST_ABORTED));
9089 BSSAP_LE.receive(BSSAP_LE_Conn_Prim:CONN_PRIM_DISC_IND);
9090
9091 /* BSC tells MSC about failure */
9092 BSSAP.receive(tr_BSSMAP_Perform_Location_Response(
9093 locationEstimate := omit, positioningData := omit,
9094 lCS_Cause := tr_BSSMAP_LcsCause(BSSMAP_LCS_CAUSE_REQUEST_ABORTED)));
9095
9096 /* There is no lchan. Still the MSC's job to decide whether to tear down the conn or not. */
9097 f_verify_active_A_conn_and_clear();
9098
9099 f_sleep(2.0);
9100 setverdict(pass);
9101}
9102testcase TC_lcs_loc_req_for_idle_ms_no_pag_resp() runs on test_CT {
9103 var MSC_ConnHdlr vc_conn;
9104 var TestHdlrParams pars := f_gen_test_hdlr_pars();
9105
9106 f_init(1, true);
9107 f_sleep(1.0);
9108
9109 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
9110 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
9111
9112 vc_conn := f_start_handler(refers(f_tc_lcs_loc_req_for_idle_ms_no_pag_resp), pars);
9113 vc_conn.done;
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01009114 f_shutdown_helper();
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02009115}
9116
9117/* During an ongoing Location Request, the MS sends a CM Service Request. Expect the same A-conn to be re-used / taken
9118 * over. */
9119private function f_tc_cm_service_during_lcs_loc_req(charstring id) runs on MSC_ConnHdlr {
9120 f_sleep(1.0);
9121
9122 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
9123 f_bssap_le_register_imsi(g_pars.imsi, omit);
9124
9125 /* Register to receive the Paging Command */
9126 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
9127 g_chan_nr := new_chan_nr;
9128 f_rslem_register(0, g_chan_nr);
9129
9130 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
9131 valueof(ts_BSSMAP_Perform_Location_Request(ts_BSSMAP_Imsi(g_pars.imsi),
9132 ts_CellId_CGI('001'H, '01'H, 1, 0)))));
9133 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
9134
9135 var PDU_BSSAP_LE plr;
9136 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocReq(BSSMAP_LE_LOC_INFO_CURRENT_GEOGRAPHIC_LOC, ?, ?)) -> value(plr);
9137
9138 /* As the A-interface conn was established for LCS, the MS coincidentally decides to issue a CM Service Request
9139 * and establish Layer 3. It should use the existing A-interface conn. */
Neels Hofmeyr85bcd272021-07-22 19:14:48 +02009140 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 +02009141 do_clear := false, expect_bssmap_l3 := true);
9142
9143 /* SMLC wants to ask the TA from the BSC explicitly in a BSSLAP TA Request message */
9144 BSSAP_LE.send(ts_BSSMAP_LE_BSSLAP(ts_BSSLAP_TA_Req));
9145
9146 /* OsmoBSC already has an lchan, no need to Page, just returns the TA */
9147 f_expect_bsslap(tr_BSSLAP_TA_Resp(?, ?));
9148
9149 /* SMLC got the TA from the BSC, now responds with geo information data. */
9150 BSSAP_LE.send(ts_BSSMAP_LE_PerfLocResp(gad_ell_point_unc_circle, omit));
9151 BSSAP_LE.receive(BSSAP_LE_Conn_Prim:CONN_PRIM_DISC_IND);
9152 BSSAP.receive(tr_BSSMAP_Perform_Location_Response(tr_BSSMAP_IE_LocationEstimate(gad_ell_point_unc_circle)));
9153
9154 /* The lchan should still exist, it was from a CM Service Request. */
9155 f_mo_l3_transceive();
9156
Neels Hofmeyr85bcd272021-07-22 19:14:48 +02009157 f_perform_clear();
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02009158
9159 f_sleep(2.0);
9160 setverdict(pass);
9161}
9162testcase TC_cm_service_during_lcs_loc_req() runs on test_CT {
9163 var MSC_ConnHdlr vc_conn;
9164 var TestHdlrParams pars := f_gen_test_hdlr_pars();
9165
9166 f_init(1, true);
9167 f_sleep(1.0);
9168
9169 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
9170 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
9171
9172 vc_conn := f_start_handler(refers(f_tc_cm_service_during_lcs_loc_req), pars);
9173 vc_conn.done;
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01009174 f_shutdown_helper();
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02009175}
9176
9177/* During an ongoing Perform Location Request, do a Handover, an expect a BSSLAP Reset message from the BSC to indicate
9178 * the new lchan after handover. */
9179private function f_tc_ho_during_lcs_loc_req(charstring id) runs on MSC_ConnHdlr {
9180 f_sleep(1.0);
9181
9182 f_establish_fully(omit, omit);
9183 f_bssap_le_register_imsi(g_pars.imsi, omit);
9184
9185 BSSAP.send(valueof(ts_BSSMAP_Perform_Location_Request(ts_BSSMAP_Imsi(g_pars.imsi),
9186 ts_CellId_CGI('262'H, '42'H, 23, 42))));
9187
9188 var PDU_BSSAP_LE plr;
9189 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocReq(BSSMAP_LE_LOC_INFO_CURRENT_GEOGRAPHIC_LOC, ?, ?)) -> value(plr);
9190
9191 /* SMLC ponders the Location Request, in the meantime the BSC decides to handover */
9192 f_bts_0_cfg(BSCVTY, {"neighbor bts 1"});
9193
9194 var HandoverState hs := {
9195 rr_ho_cmpl_seen := false,
9196 handover_done := false,
9197 old_chan_nr := -
9198 };
9199 /* issue hand-over command on VTY */
9200 f_vty_handover(BSCVTY, 0, 0, g_chan_nr, 1);
9201 /* temporarily suspend DChan processing on BTS1 to avoid race with RSLEM_register */
9202 f_rslem_suspend(RSL1_PROC);
9203
9204 /* From the MGW perspective, a handover is is characterized by
9205 * performing one MDCX operation with the MGW. So we expect to see
9206 * one more MDCX during handover. */
9207 g_media.mgcp_conn[0].mdcx_seen_exp := g_media.mgcp_conn[0].crcx_seen_exp + 1;
9208
9209 alt {
9210 [] as_handover(hs);
9211 }
9212
9213 var PDU_BSSAP_LE rx_bsslap;
9214
9215 interleave {
9216 /* Expect the BSC to inform the MSC about the handover */
9217 [] BSSAP.receive(tr_BSSMAP_HandoverPerformed);
9218
9219 /* Expect the BSC to inform the SMLC about the handover */
9220 [] BSSAP_LE.receive(tr_BSSMAP_LE_ConnInfo(BSSMAP_LE_PROT_BSSLAP, ?)) -> value(rx_bsslap) {
9221 f_match_bsslap(rx_bsslap, tr_BSSLAP_Reset(BSSLAP_CAUSE_INTRA_BSS_HO));
9222 }
9223 }
9224
9225 /* SMLC now responds with geo information data. */
9226 BSSAP_LE.send(ts_BSSMAP_LE_PerfLocResp(gad_ell_point_unc_circle, omit));
9227 BSSAP_LE.receive(BSSAP_LE_Conn_Prim:CONN_PRIM_DISC_IND);
9228 BSSAP.receive(tr_BSSMAP_Perform_Location_Response(tr_BSSMAP_IE_LocationEstimate(gad_ell_point_unc_circle)));
9229
9230 /* lchan still active */
9231 f_mo_l3_transceive(RSL1);
9232
9233 /* MSC decides it is done now. */
Neels Hofmeyr85bcd272021-07-22 19:14:48 +02009234 f_perform_clear(RSL1, RSL1_PROC);
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02009235
9236 f_sleep(2.0);
9237 setverdict(pass);
9238}
9239testcase TC_ho_during_lcs_loc_req() runs on test_CT {
9240 var MSC_ConnHdlr vc_conn;
9241 var TestHdlrParams pars := f_gen_test_hdlr_pars();
9242
9243 f_init(2, true);
9244 f_sleep(1.0);
9245 vc_conn := f_start_handler(refers(f_tc_ho_during_lcs_loc_req), pars);
9246 vc_conn.done;
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01009247 f_shutdown_helper();
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02009248}
9249
Neels Hofmeyrbf037052020-10-28 22:52:02 +00009250/* Attempt Complete Layer 3 without any MSC available (OS#4832) */
9251private function f_tc_no_msc(charstring id) runs on MSC_ConnHdlr {
9252 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
9253
9254 /* Also disable attach for the single connected MSC */
9255 f_vty_msc_allow_attach(BSCVTY, { false });
9256
9257 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) ));
9258 f_chan_est(g_pars.ra, l3_enc, g_pars.link_id, g_pars.fn);
9259
9260 /* No MSC is found, expecting a proper release on RSL */
9261 interleave {
9262 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_RELEASE)) {
9263 f_logp(BSCVTY, "Got RSL RR Release");
9264 }
9265 [] RSL.receive(tr_RSL_DEACT_SACCH(g_chan_nr)) {
9266 f_logp(BSCVTY, "Got RSL Deact SACCH");
9267 }
Neels Hofmeyr3c5127e2021-07-22 19:18:40 +02009268 [] RSL.receive(tr_RSL_RF_CHAN_REL(g_chan_nr)) {
Neels Hofmeyrbf037052020-10-28 22:52:02 +00009269 f_logp(BSCVTY, "Got RSL RF Chan Rel, sending Rel Ack");
9270 RSL.send(ts_RSL_RF_CHAN_REL_ACK(g_chan_nr));
Neels Hofmeyre680b012021-07-22 19:19:09 +02009271 f_rslem_unregister(0, g_chan_nr);
Neels Hofmeyrbf037052020-10-28 22:52:02 +00009272 }
9273 }
9274 setverdict(pass);
9275}
9276testcase TC_no_msc() runs on test_CT {
9277
9278 f_init(1, true);
9279 f_sleep(1.0);
9280 var MSC_ConnHdlr vc_conn;
9281 var TestHdlrParams pars := f_gen_test_hdlr_pars();
9282
9283 f_ctrs_bsc_init(counternames_bsc_mscpool);
9284
9285 vc_conn := f_start_handler(refers(f_tc_no_msc), pars);
9286 vc_conn.done;
9287
9288 f_ctrs_bsc_add("mscpool:subscr:no_msc");
9289 f_ctrs_bsc_verify();
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01009290 f_shutdown_helper();
Neels Hofmeyrbf037052020-10-28 22:52:02 +00009291}
9292
Harald Welte0ea2d5e2018-04-07 21:40:29 +02009293/* Dyn PDCH todo:
9294 * activate OSMO as TCH/F
9295 * activate OSMO as TCH/H
9296 * does the BSC-located PCU socket get the updated INFO?
9297 * what if no PCU is connected at the time?
9298 * is the info correct on delayed PCU (re)connect?
9299 */
Harald Welte94e0c342018-04-07 11:33:23 +02009300
Neels Hofmeyr87857ec2021-04-25 16:17:47 +00009301private function f_TC_refuse_mode_modif_to_vamos(charstring id) runs on MSC_ConnHdlr {
9302 var PDU_BSSAP ass_cmd := f_gen_ass_req(g_pars.use_osmux);
9303 var template PDU_BSSAP exp_compl := f_gen_exp_compl(g_pars.use_osmux);
9304
9305 /* puzzle together the ASSIGNMENT REQ for given codec[s] */
9306 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
9307 ass_cmd.pdu.bssmap.assignmentRequest.codecList := g_pars.ass_codec_list;
9308 exp_compl.pdu.bssmap.assignmentComplete.speechCodec.codecElements[0] :=
9309 g_pars.ass_codec_list.codecElements[0];
9310 if (isvalue(g_pars.expect_mr_s0_s7)) {
9311 exp_compl.pdu.bssmap.assignmentComplete.speechCodec.codecElements[0].s0_7 :=
9312 g_pars.expect_mr_s0_s7;
9313 }
9314 }
9315 ass_cmd.pdu.bssmap.assignmentRequest.channelType :=
9316 f_BSSMAP_chtype_from_codec(g_pars.ass_codec_list.codecElements[0]);
9317 log("expecting ASS COMPL like this: ", exp_compl);
9318
9319 f_establish_fully(ass_cmd, exp_compl);
9320
Neels Hofmeyr8746b0d2021-06-01 17:25:39 +02009321 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 +00009322
9323 var RSL_Message rsl;
9324
9325 timer T := 5.0;
9326 T.start;
9327 alt {
9328 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr)) -> value rsl {
9329 var PDU_ML3_NW_MS l3 := dec_PDU_ML3_NW_MS(rsl.ies[2].body.l3_info.payload);
9330 log("Rx L3 from net: ", l3);
9331 if (ischosen(l3.msgs.rrm.channelModeModify)) {
9332 setverdict(fail, "Mode Modify to VAMOS succeeded even though BTS does not support VAMOS");
9333 mtc.stop;
9334 }
9335 }
9336 [] RSL.receive(tr_RSL_MODE_MODIFY_REQ(g_chan_nr, ?)) -> value rsl {
9337 setverdict(fail, "Mode Modify to VAMOS succeeded even though BTS does not support VAMOS");
9338 mtc.stop;
9339 }
9340 [] T.timeout {
9341 /* The BTS does not exhibit BTS_FEAT_VAMOS, so no VAMOS related Mode Modify should happen. */
9342 setverdict(pass);
9343 }
9344 }
9345 T.stop;
9346}
9347
9348/* The BSC does *not* indicate BTS_FEAT_VAMOS; make sure that a channel Mode Modify to VAMOS mode is refused by
9349 * osmo-bsc. */
9350testcase TC_refuse_mode_modif_to_vamos() runs on test_CT {
9351 var TestHdlrParams pars := f_gen_test_hdlr_pars();
9352 var MSC_ConnHdlr vc_conn;
9353
9354 f_init(1, true);
9355 f_sleep(1.0);
9356
9357 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
9358 vc_conn := f_start_handler(refers(f_TC_refuse_mode_modif_to_vamos), pars);
9359 vc_conn.done;
9360 f_shutdown_helper();
9361}
9362
9363/* The BSC does *not* indicate BTS_FEAT_VAMOS; make sure that a channel activation to VAMOS mode is refused by osmo-bsc.
9364 */
9365testcase TC_refuse_chan_act_to_vamos() runs on test_CT {
9366 f_init_vty();
9367
9368 f_init(1, false);
9369 f_sleep(1.0);
9370
9371 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 1 sub-slot 0 activate-vamos fr");
9372
9373 var ASP_RSL_Unitdata rx_rsl_ud;
9374 timer T := 5.0;
9375
9376 T.start;
9377 alt {
9378 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(?, IPAC_PROTO_RSL_TRX0)) -> value rx_rsl_ud {
9379 if (rx_rsl_ud.rsl.msg_type == RSL_MT_CHAN_ACTIV) {
9380 T.stop;
9381 setverdict(fail, "CHANnel ACTivate in VAMOS mode succeeded even though BTS does not support VAMOS");
9382 mtc.stop;
9383 }
9384 repeat;
9385 }
9386 [] T.timeout {
9387 /* The BTS does not exhibit BTS_FEAT_VAMOS, so no VAMOS related CHANnel ACTivate should happen. */
9388 setverdict(pass);
9389 }
9390 }
9391}
9392
Neels Hofmeyrd2d9f332021-04-28 22:23:36 +00009393private function f_TC_reassignment_codec(charstring id) runs on MSC_ConnHdlr {
9394 /* First fully set up a speech lchan */
9395 f_TC_assignment_codec(id);
9396
9397 /* Trigger re-assignment to another lchan */
9398 var AssignmentState assignment_st := valueof(ts_AssignmentStateInit);
9399
9400 /* Re-Assignment should tell the MGW endpoint the new lchan's RTP address and port, so expecting to see exactly
9401 * one MDCX on MGCP. */
9402 g_media.mgcp_conn[0].mdcx_seen_exp := g_media.mgcp_conn[0].mdcx_seen_exp + 1;
9403
9404 /* The new lchan will see all-new IPAC_CRCX and IPAC_MDCX messages telling the BTS the same RTP address and port
9405 * as the old lchan used. */
9406 g_media.bts.ipa_crcx_seen := false;
9407 g_media.bts.ipa_mdcx_seen := false;
9408
9409 /* Send different BTS side RTP port number for the new lchan */
9410 g_media.bts.bts.port_nr := 4223;
9411
9412 f_rslem_register(0, valueof(ts_RslChanNr_Bm(2))); /* <-- FIXME: can we somehow infer the timeslot that will be used? */
9413
9414 /* Trigger re-assignment. */
9415 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot " & int2str(g_chan_nr.tn) & " sub-slot 0 assignment");
9416
9417 timer T := 5.0;
9418 T.start;
9419 alt {
9420 [] as_assignment(assignment_st);
9421 [] as_Media();
9422 [] T.timeout {
9423 break;
9424 }
9425 }
9426
9427 if (not assignment_st.assignment_done) {
9428 setverdict(fail, "Assignment did not complete");
9429 mtc.stop;
9430 }
9431
9432 f_check_mgcp_expectations()
9433 setverdict(pass);
9434
9435 f_sleep(2.0);
9436 log("show lchan summary: ", f_vty_transceive_ret(BSCVTY, "show lchan summary"));
9437
9438 /* Instruct BSC to clear channel */
9439 var BssmapCause cause := 0;
9440 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
9441 interleave {
9442 [] MGCP.receive(tr_DLCX) {}
9443 [] MGCP.receive(tr_DLCX) {}
9444 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_RELEASE)) {}
9445 [] RSL.receive(tr_RSL_DEACT_SACCH(g_chan_nr)) {}
Neels Hofmeyr3c5127e2021-07-22 19:18:40 +02009446 [] RSL.receive(tr_RSL_RF_CHAN_REL(g_chan_nr)) {
Neels Hofmeyrd2d9f332021-04-28 22:23:36 +00009447 RSL.send(ts_RSL_RF_CHAN_REL_ACK(g_chan_nr));
Neels Hofmeyre680b012021-07-22 19:19:09 +02009448 f_rslem_unregister(0, g_chan_nr);
Neels Hofmeyrd2d9f332021-04-28 22:23:36 +00009449 }
9450 [] BSSAP.receive(tr_BSSMAP_ClearComplete) {
9451 BSSAP.send(RAN_Conn_Prim:MSC_CONN_PRIM_DISC_REQ);
9452 }
9453 }
9454
9455 f_sleep(0.5);
9456}
9457
9458testcase TC_reassignment_fr() runs on test_CT {
9459 var TestHdlrParams pars := f_gen_test_hdlr_pars();
9460 var MSC_ConnHdlr vc_conn;
9461
9462 f_init(1, true);
9463 f_sleep(1.0);
9464
9465 f_ctrs_bsc_and_bts_init();
9466
9467 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
9468 vc_conn := f_start_handler(refers(f_TC_reassignment_codec), pars);
9469 vc_conn.done;
9470
9471 /* from f_establish_fully() */
9472 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
9473 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
9474 /* from re-assignment */
9475 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
9476 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
9477 f_ctrs_bsc_and_bts_verify();
9478 f_shutdown_helper();
9479}
9480
Neels Hofmeyrfeda88e2021-07-19 13:51:29 +02009481const charstring REEST_LOST_CONNECTION := "REEST_LOST_CONNECTION";
9482const charstring REEST_CLEAR := "REEST_CLEAR";
9483const charstring REEST_CLEAR_DONE := "REEST_CLEAR_DONE";
9484
9485/* CM Re-Establishment, 3GPP TS 24.008 4.5.1.6.
9486 * The MS <-> BTS loses radio connection, MS shows up on second BTS and asks for CM Re-Establishment.
9487 * BSC should establish a separate A conn for the same MS, the original A conn is then cleared by
9488 * the MSC as the CM Re-Establishment is handled.
9489 *
9490 * MS bts0 bts1 bsc msc test-component
9491 * |<----->|<----------------->|<-0-->| _1 Establish channel on bts 0
9492 * | | _1 wait a bit, to settle down
9493 * |<-x x--| | _1 "lose connection"
9494 * | | REEST_LOST_CONNECTION
9495 * |----------------->|------->|--1-->| _2 new A-conn: Chan Rqd, Imm Ass, Compl L3 with CM Re-Establishment Req
9496 * | | REEST_CLEAR
9497 * | |<-0---| _1 Clear Command on first A-conn
9498 * | |--0-->| _1 Clear Complete
9499 * | |<----------------->| | _1 Release first channel
9500 * | | REEST_CLEAR_DONE
9501 * |<-----------------|<-------|<-1---| _2 Chan Activ, Assignment Command
9502 * |<-----------------|<-------|<-1---| _2 Clear Command, Release
9503 *
9504 */
9505private function f_tc_cm_reestablishment_1(charstring id) runs on MSC_ConnHdlr {
9506 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
9507 var PDU_BSSAP ass_cmd := f_gen_ass_req();
9508
9509 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
9510 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
9511
9512 f_establish_fully(ass_cmd, exp_compl);
9513
9514 /* The original channel loses connection, MS attemts CM Re-Establishment on another cell, see
9515 * f_tc_cm_reestablishment_2(). This established channel stays active until MSC sends a Clear Command. The time
9516 * when exactly that happens is determined by f_tc_cm_reestablishment_2(). */
9517 f_sleep(2.0);
9518 COORD.send(REEST_LOST_CONNECTION);
9519
9520 alt {
9521 [] COORD.receive(REEST_CLEAR);
9522 [] RSL.receive(tr_RSL_DEACT_SACCH(g_chan_nr)) {
9523 setverdict(fail, "Unexpected channel release");
9524 mtc.stop;
9525 }
9526 [] RSL.receive(tr_RSL_RF_CHAN_REL(g_chan_nr)) {
9527 setverdict(fail, "Unexpected channel release");
9528 mtc.stop;
9529 }
9530 }
9531 f_perform_clear()
9532 f_expect_dlcx_conns();
9533 COORD.send(REEST_CLEAR_DONE);
9534}
9535
9536private function f_tc_cm_reestablishment_2(charstring id) runs on MSC_ConnHdlr {
9537 f_MscConnHdlr_init(g_pars.media_nr, host_bts, host_mgw_mgcp, FR_AMR);
9538
9539 /* The MS lost the connection on the first channel, now establishes another one */
9540 COORD.receive(REEST_LOST_CONNECTION);
9541
9542 var MobileIdentityLV mi := valueof(ts_MI_IMSI_LV(g_pars.imsi));
9543 var PDU_ML3_MS_NW l3_info := valueof(ts_CM_REESTABL_REQ(mi));
9544 var octetstring l3_enc := enc_PDU_ML3_MS_NW(l3_info);
9545
9546 f_create_bssmap_exp(l3_enc);
Neels Hofmeyrc7b1f6d2021-07-20 23:21:36 +02009547 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 +02009548 BSSAP.receive(tr_BSSMAP_ComplL3(l3_enc));
9549
9550 /* MSC got the CM Re-Establishment request and first off clears the previous conn. */
9551 COORD.send(REEST_CLEAR);
9552 COORD.receive(REEST_CLEAR_DONE);
9553
9554 f_sleep(2.0);
9555
9556 /* Answer the CM Re-Establishment with an Assignment Command. */
9557 var template PDU_BSSAP expect_assignment_compl := f_gen_exp_compl();
9558 var PDU_BSSAP ass_cmd := f_gen_ass_req();
9559 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
9560 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
9561
9562 var AssignmentState st := valueof(ts_AssignmentStateInit);
9563 st.voice_call := true;
9564 st.is_assignment := true;
9565
9566 var ExpectCriteria mgcpcrit := {
9567 connid := omit,
9568 endpoint := omit,
9569 transid := omit
9570 };
9571 f_create_mgcp_expect(mgcpcrit);
9572
Neels Hofmeyrc7b1f6d2021-07-20 23:21:36 +02009573 f_rslem_dchan_queue_enable(RSL1_PROC);
Neels Hofmeyrfeda88e2021-07-19 13:51:29 +02009574
9575 BSSAP.send(ass_cmd);
9576
9577 var PDU_BSSAP bssap;
9578
9579 alt {
Neels Hofmeyrc7b1f6d2021-07-20 23:21:36 +02009580 [] as_assignment(st, rsl_pt := RSL1, rsl_proc_pt := RSL1_PROC);
9581 [] as_Media_ipacc(RSL1, RSL2);
9582 [] as_Media_mgw();
Neels Hofmeyrfeda88e2021-07-19 13:51:29 +02009583 [st.assignment_done] BSSAP.receive(expect_assignment_compl) {
9584 break;
9585 }
9586 }
9587
9588 f_sleep(3.0);
9589
9590 f_logp(BSCVTY, "f_tc_cm_reestablishment_2 clearing");
Neels Hofmeyrc7b1f6d2021-07-20 23:21:36 +02009591 f_perform_clear(RSL1, RSL1_PROC);
Neels Hofmeyrfeda88e2021-07-19 13:51:29 +02009592 f_expect_dlcx_conns();
9593}
9594
9595testcase TC_cm_reestablishment() runs on test_CT {
9596 var TestHdlrParams pars1 := f_gen_test_hdlr_pars();
9597 var MSC_ConnHdlr vc_conn1;
9598
9599 var TestHdlrParams pars2 := f_gen_test_hdlr_pars();
9600 var MSC_ConnHdlr vc_conn2;
9601 pars2.imsi := pars1.imsi;
9602 pars2.media_nr := 2;
Neels Hofmeyrc7b1f6d2021-07-20 23:21:36 +02009603 /* f_tc_cm_reestablishment_2 uses 'bts 1'.
9604 * BTS 1 has BSIC 11 (and no explicit timeslot training_sequence_code config), so expecting TSC = (BSIC & 7) = 3 */
9605 pars2.expect_tsc := 3;
Neels Hofmeyrfeda88e2021-07-19 13:51:29 +02009606
9607 f_init(2, true, guard_timeout := 40.0);
9608 f_sleep(1.0);
9609
9610 vc_conn1 := f_start_handler_create(pars1);
9611 vc_conn2 := f_start_handler_create(pars2);
9612 connect(vc_conn1:COORD, vc_conn2:COORD);
9613 f_start_handler_run(vc_conn1, refers(f_tc_cm_reestablishment_1), pars1);
9614 f_start_handler_run(vc_conn2, refers(f_tc_cm_reestablishment_2), pars2);
9615 vc_conn1.done;
9616 vc_conn2.done;
9617
9618 f_shutdown_helper();
9619}
Neels Hofmeyr87857ec2021-04-25 16:17:47 +00009620
Neels Hofmeyrb07b2952021-08-07 04:23:14 +02009621function f_exp_ipa_rx_nonfatal(integer bts_nr, template (present) RSL_Message t_rx, float t_secs := 2.0,
9622 IpaStreamId sid := IPAC_PROTO_RSL_TRX0, boolean ignore_other_rx := true)
9623runs on test_CT return template (omit) RSL_Message {
9624 var ASP_RSL_Unitdata rx_rsl_ud;
9625 timer T := t_secs;
9626
9627 T.start;
9628 alt {
9629 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(t_rx, sid)) -> value rx_rsl_ud {
9630 T.stop;
9631 }
9632 [ignore_other_rx] IPA_RSL[bts_nr].receive { repeat; }
9633 [not ignore_other_rx] IPA_RSL[bts_nr].receive {
9634 log("f_exp_ipa_rx_nonfatal(): Got different message than ", t_rx);
9635 T.stop;
9636 return omit;
9637 }
9638 [] T.timeout {
9639 return omit;
9640 }
9641 }
9642 return rx_rsl_ud.rsl;
9643}
9644
9645private function f_vty_set_imm_ass(TELNETasp_PT pt, BtsNr bts_nr := 0, charstring imm_ass_setting := "post-chan-ack") {
9646 f_vty_enter_cfg_bts(pt, bts_nr);
9647 f_vty_transceive(pt, "immediate-assignment " & imm_ass_setting);
9648 f_vty_transceive(pt, "exit");
9649 f_vty_transceive(pt, "exit");
9650 f_vty_transceive(pt, "exit");
9651}
9652
9653private function f_verify_imm_ass(RSL_Message imm_ass, template uint8_t ra := ?, template GsmFrameNumber fn := ?,
Neels Hofmeyr07603cf2021-09-07 19:05:52 +02009654 template RslChannelNr chan_nr := ?,
9655 template (present) uint12_t arfcn := ?,
9656 template (present) uint3_t tsc := ?)
Neels Hofmeyrb07b2952021-08-07 04:23:14 +02009657{
9658 var RSL_IE_Body full_imm_ass_info;
9659 if (not f_rsl_find_ie(imm_ass, RSL_IE_FULL_IMM_ASS_INFO, full_imm_ass_info)) {
9660 setverdict(fail, "RSL Full Immediate Assign Info IE is absent");
9661 mtc.stop;
9662 }
9663
9664 var GsmRrMessage rr_imm_ass := dec_GsmRrMessage(full_imm_ass_info.full_imm_ass_info.payload);
9665 var template GsmRrMessage expect_imm_ass := tr_IMM_ASS(ra := ra,
9666 fn := fn,
Neels Hofmeyr07603cf2021-09-07 19:05:52 +02009667 ch_desc := tr_ChanDescH0(chan_nr, arfcn, tsc),
Neels Hofmeyrb07b2952021-08-07 04:23:14 +02009668 page_mode := ?);
9669 if (not match(rr_imm_ass, expect_imm_ass)) {
9670 log("Error: expected ", expect_imm_ass, " got ", rr_imm_ass);
9671 setverdict(fail, "Failed to match Immediate Assignment");
9672 mtc.stop;
9673 }
9674}
9675
9676testcase TC_imm_ass_post_chan_ack() runs on test_CT {
9677 var RSL_Message chan_act;
9678 var RSL_Message imm_ass;
9679
9680 f_init(1, false);
9681 f_sleep(1.0);
9682
9683 /* (should be the default anyway, just to make things clear) */
9684 f_vty_set_imm_ass(BSCVTY, 0, "post-chan-ack");
9685
9686 /* RA containing reason=LU */
9687 var GsmFrameNumber fn := 2342;
9688 var uint8_t ra := 2;
9689 f_ipa_tx(0, ts_RSL_CHAN_RQD(int2oct(ra, 1), fn));
9690
9691 chan_act := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
9692
9693 /* First send the Chan Act ACK */
9694 var RslChannelNr chan_nr := chan_act.ies[0].body.chan_nr;
Neels Hofmeyr07603cf2021-09-07 19:05:52 +02009695 var RSL_IE_Body chan_ident_ie;
9696 if (not f_rsl_find_ie(chan_act, RSL_IE_CHAN_IDENT, chan_ident_ie)) {
9697 setverdict(fail, "RSL Channel Identification IE is absent");
9698 mtc.stop;
9699 }
9700
Neels Hofmeyrb07b2952021-08-07 04:23:14 +02009701 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, fn + 10));
9702
9703 /* Then expect the Immediate Assignment, after we ACKed the chan act */
9704 imm_ass := f_exp_ipa_rx(0, tr_RSL_IMM_ASSIGN(0));
9705
Neels Hofmeyr07603cf2021-09-07 19:05:52 +02009706 f_verify_imm_ass(imm_ass, ra, fn, chan_nr, chan_ident_ie.chan_ident.ch_desc.v.arfcn,
9707 chan_ident_ie.chan_ident.ch_desc.v.tsc);
Neels Hofmeyrb07b2952021-08-07 04:23:14 +02009708
9709 /* Check that the lchan is working */
9710 var octetstring l3 := '00010203040506'O;
9711 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
9712
9713 var BSSAP_N_CONNECT_ind rx_c_ind;
9714 BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) -> value rx_c_ind;
9715 BSSAP.send(ts_BSSAP_CONNECT_res(rx_c_ind.connectionId));
9716
9717 f_sleep(1.0);
9718 f_shutdown_helper();
9719}
9720
9721testcase TC_imm_ass_pre_chan_ack() runs on test_CT {
9722 var RSL_Message chan_act;
9723 var RSL_Message imm_ass;
9724
9725 f_init(1, false);
9726 f_sleep(1.0);
9727
9728 f_vty_set_imm_ass(BSCVTY, 0, "pre-chan-ack");
9729
9730 /* RA containing reason=LU */
9731 var GsmFrameNumber fn := 2342;
9732 var uint8_t ra := 2;
9733 f_ipa_tx(0, ts_RSL_CHAN_RQD(int2oct(ra, 1), fn));
9734
9735 /* (set bts 0 cfg back to default) */
9736 f_vty_set_imm_ass(BSCVTY);
9737
9738 chan_act := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
9739 var RslChannelNr chan_nr := chan_act.ies[0].body.chan_nr;
Neels Hofmeyr07603cf2021-09-07 19:05:52 +02009740 var RSL_IE_Body chan_ident_ie;
9741 if (not f_rsl_find_ie(chan_act, RSL_IE_CHAN_IDENT, chan_ident_ie)) {
9742 setverdict(fail, "RSL Channel Identification IE is absent");
9743 mtc.stop;
9744 }
Neels Hofmeyrb07b2952021-08-07 04:23:14 +02009745
9746 /* *FIRST* expect the Immediate Assignment, before we ACK the chan act */
9747 imm_ass := f_exp_ipa_rx(0, tr_RSL_IMM_ASSIGN(0));
Neels Hofmeyr07603cf2021-09-07 19:05:52 +02009748 f_verify_imm_ass(imm_ass, ra, fn, chan_nr, chan_ident_ie.chan_ident.ch_desc.v.arfcn,
9749 chan_ident_ie.chan_ident.ch_desc.v.tsc);
Neels Hofmeyrb07b2952021-08-07 04:23:14 +02009750
9751 /* Only now send the Chan Act ACK */
9752 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, fn+10));
9753
9754 /* Check that the lchan is working */
9755 var octetstring l3 := '00010203040506'O;
9756 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
9757
9758 var BSSAP_N_CONNECT_ind rx_c_ind;
9759 BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) -> value rx_c_ind;
9760 BSSAP.send(ts_BSSAP_CONNECT_res(rx_c_ind.connectionId));
9761
9762 f_sleep(1.0);
9763 f_shutdown_helper();
9764}
9765
Neels Hofmeyr23158742021-09-07 19:08:07 +02009766testcase TC_imm_ass_pre_ts_ack() runs on test_CT {
9767 var RSL_Message chan_act;
9768 var RSL_Message imm_ass;
9769
9770 f_init(1, false);
9771 f_sleep(1.0);
9772
9773 f_vty_set_imm_ass(BSCVTY, 0, "pre-ts-ack");
9774
9775 /* RA containing reason=LU */
9776 var GsmFrameNumber fn := 2342;
9777 var uint8_t ra := 2;
9778 f_ipa_tx(0, ts_RSL_CHAN_RQD(int2oct(ra, 1), fn));
9779
9780 /* (set bts 0 cfg back to default) */
9781 f_vty_set_imm_ass(BSCVTY);
9782
9783 chan_act := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
9784 var RslChannelNr chan_nr := chan_act.ies[0].body.chan_nr;
9785 var RSL_IE_Body chan_ident_ie;
9786 if (not f_rsl_find_ie(chan_act, RSL_IE_CHAN_IDENT, chan_ident_ie)) {
9787 setverdict(fail, "RSL Channel Identification IE is absent");
9788 mtc.stop;
9789 }
9790
9791 /* *FIRST* expect the Immediate Assignment, before we ACK the chan act */
9792 imm_ass := f_exp_ipa_rx(0, tr_RSL_IMM_ASSIGN(0));
9793 f_verify_imm_ass(imm_ass, ra, fn, chan_nr, chan_ident_ie.chan_ident.ch_desc.v.arfcn,
9794 chan_ident_ie.chan_ident.ch_desc.v.tsc);
9795
9796 /* Only now send the Chan Act ACK */
9797 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, fn+10));
9798
9799 /* Check that the lchan is working */
9800 var octetstring l3 := '00010203040506'O;
9801 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
9802
9803 var BSSAP_N_CONNECT_ind rx_c_ind;
9804 BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) -> value rx_c_ind;
9805 BSSAP.send(ts_BSSAP_CONNECT_res(rx_c_ind.connectionId));
9806
9807 f_sleep(1.0);
9808 f_shutdown_helper();
9809}
9810
Neels Hofmeyr7a6d0602021-08-07 04:23:50 +02009811testcase TC_imm_ass_pre_chan_ack_dyn_ts() runs on test_CT {
9812 /* change Timeslot 6 before f_init() starts RSL */
9813 f_init_vty();
9814 f_ts_set_chcomb(0, 0, 6, "TCH/F_TCH/H_PDCH");
9815 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
9816
9817 f_init(1, false);
9818 f_sleep(1.0);
9819
9820 var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(6));
9821 /* The BSC will activate the dynamic PDCH by default, so confirm that */
9822 f_exp_ipa_rx(0, tr_RSL_CHAN_ACT_PDCH(chan_nr, ?));
9823 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, 2323));
9824
9825 /* clean up timeslot 6 config, will only take effect when the OML drops the next time */
9826 f_ts_set_chcomb(0, 0, 6, "PDCH");
9827
9828 /* block all static timeslots so that the dyn TS will be used */
9829 f_disable_all_tch_f();
9830 f_disable_all_tch_h();
9831 f_disable_all_sdcch();
9832
9833 var RSL_Message chan_act;
9834 var RSL_Message imm_ass;
9835
9836 f_init(1, false);
9837 f_sleep(1.0);
9838
9839 f_vty_set_imm_ass(BSCVTY, 0, "pre-chan-ack");
9840
9841 /* RA containing reason=LU */
9842 var GsmFrameNumber fn := 2342;
9843 var uint8_t ra := 2;
9844 f_ipa_tx(0, ts_RSL_CHAN_RQD(int2oct(ra, 1), fn));
9845
9846 /* (set bts 0 cfg back to default) */
9847 f_vty_set_imm_ass(BSCVTY);
9848
9849 /* Expect the dyn TS to deactivate PDCH first */
9850 f_exp_ipa_rx(0, tr_RSL_RF_CHAN_REL(chan_nr));
9851 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(chan_nr));
9852
9853 /* Now activation as SDCCH8 */
9854 chan_nr := valueof(t_RslChanNr_SDCCH8(tn := 6, sub_slot := 0));
9855
9856 chan_act := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
Neels Hofmeyr07603cf2021-09-07 19:05:52 +02009857 var RSL_IE_Body chan_ident_ie;
9858 if (not f_rsl_find_ie(chan_act, RSL_IE_CHAN_IDENT, chan_ident_ie)) {
9859 setverdict(fail, "RSL Channel Identification IE is absent");
9860 mtc.stop;
9861 }
Neels Hofmeyr7a6d0602021-08-07 04:23:50 +02009862
9863 /* *FIRST* expect the Immediate Assignment, before we ACK the chan act */
9864 imm_ass := f_exp_ipa_rx(0, tr_RSL_IMM_ASSIGN(0));
Neels Hofmeyr07603cf2021-09-07 19:05:52 +02009865 f_verify_imm_ass(imm_ass, ra, fn, chan_nr, chan_ident_ie.chan_ident.ch_desc.v.arfcn,
9866 chan_ident_ie.chan_ident.ch_desc.v.tsc);
Neels Hofmeyr7a6d0602021-08-07 04:23:50 +02009867
9868 /* Only now send the Chan Act ACK */
9869 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, fn+10));
9870
9871 /* Check that the lchan is working */
9872 var octetstring l3 := '00010203040506'O;
9873 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
9874
9875 var BSSAP_N_CONNECT_ind rx_c_ind;
9876 BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) -> value rx_c_ind;
9877 BSSAP.send(ts_BSSAP_CONNECT_res(rx_c_ind.connectionId));
9878
9879 f_sleep(1.0);
9880 f_shutdown_helper();
9881}
9882
Neels Hofmeyrc8b95c12021-08-07 04:24:02 +02009883testcase TC_imm_ass_pre_ts_ack_dyn_ts() runs on test_CT {
9884 /* change Timeslot 6 before f_init() starts RSL */
9885 f_init_vty();
9886 f_ts_set_chcomb(0, 0, 6, "TCH/F_TCH/H_PDCH");
9887 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
9888
9889 f_init(1, false);
9890 f_sleep(1.0);
9891
9892 var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(6));
9893 /* The BSC will activate the dynamic PDCH by default, so confirm that */
9894 f_exp_ipa_rx(0, tr_RSL_CHAN_ACT_PDCH(chan_nr, ?));
9895 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, 2323));
9896
9897 /* clean up timeslot 6 config, will only take effect when the OML drops the next time */
9898 f_ts_set_chcomb(0, 0, 6, "PDCH");
9899
9900 /* block all static timeslots so that the dyn TS will be used */
9901 f_disable_all_tch_f();
9902 f_disable_all_tch_h();
9903 f_disable_all_sdcch();
9904
9905 var RSL_Message chan_act;
9906 var RSL_Message imm_ass;
9907
9908 f_init(1, false);
9909 f_sleep(1.0);
9910
9911 f_vty_set_imm_ass(BSCVTY, 0, "pre-ts-ack");
9912
9913 /* RA containing reason=LU */
9914 var GsmFrameNumber fn := 2342;
9915 var uint8_t ra := 2;
9916 f_ipa_tx(0, ts_RSL_CHAN_RQD(int2oct(ra, 1), fn));
9917
9918 /* (set bts 0 cfg back to default) */
9919 f_vty_set_imm_ass(BSCVTY);
9920
9921 /* Expect the dyn TS to deactivate PDCH first */
9922 f_exp_ipa_rx(0, tr_RSL_RF_CHAN_REL(chan_nr));
9923
9924 /* And already the Immediate Assignment even before the PDCH Deact ACK */
9925 imm_ass := f_exp_ipa_rx(0, tr_RSL_IMM_ASSIGN(0));
9926
9927 /* continue the Osmo style PDCH Deact (usual chan rel) */
9928 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(chan_nr));
9929
9930 /* Now activation as SDCCH8 */
9931 chan_nr := valueof(t_RslChanNr_SDCCH8(tn := 6, sub_slot := 0));
9932
9933 chan_act := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
Neels Hofmeyr07603cf2021-09-07 19:05:52 +02009934 var RSL_IE_Body chan_ident_ie;
9935 if (not f_rsl_find_ie(chan_act, RSL_IE_CHAN_IDENT, chan_ident_ie)) {
9936 setverdict(fail, "RSL Channel Identification IE is absent");
9937 mtc.stop;
9938 }
Neels Hofmeyrc8b95c12021-08-07 04:24:02 +02009939 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, fn+10));
9940
Neels Hofmeyr07603cf2021-09-07 19:05:52 +02009941 f_verify_imm_ass(imm_ass, ra, fn, chan_nr, chan_ident_ie.chan_ident.ch_desc.v.arfcn,
9942 chan_ident_ie.chan_ident.ch_desc.v.tsc);
Neels Hofmeyrc8b95c12021-08-07 04:24:02 +02009943
9944 /* Check that the lchan is working */
9945 var octetstring l3 := '00010203040506'O;
9946 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
9947
9948 var BSSAP_N_CONNECT_ind rx_c_ind;
9949 BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) -> value rx_c_ind;
9950 BSSAP.send(ts_BSSAP_CONNECT_res(rx_c_ind.connectionId));
9951
9952 f_sleep(1.0);
9953 f_shutdown_helper();
9954}
9955
Harald Welte28d943e2017-11-25 15:00:50 +01009956control {
Harald Welte898113b2018-01-31 18:32:21 +01009957 /* CTRL interface testing */
Harald Welte4003d112017-12-09 22:35:39 +01009958 execute( TC_ctrl_msc_connection_status() );
Stefan Sperlingb041b3d2018-01-03 17:14:55 +01009959 execute( TC_ctrl_msc0_connection_status() );
Harald Welte96c94412017-12-09 03:12:45 +01009960 execute( TC_ctrl() );
Neels Hofmeyrf246a922020-05-13 02:27:10 +02009961 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_SCCPlite_SERVER) {
Pau Espin Pedrol5a2d7432019-06-07 19:43:45 +02009962 execute( TC_ctrl_location() );
9963 }
Harald Welte898113b2018-01-31 18:32:21 +01009964
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +02009965 execute( TC_si_default() );
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02009966 execute( TC_si2quater_2_earfcns() );
9967 execute( TC_si2quater_3_earfcns() );
9968 execute( TC_si2quater_4_earfcns() );
9969 execute( TC_si2quater_5_earfcns() );
9970 execute( TC_si2quater_6_earfcns() );
Neels Hofmeyrad132f22020-07-08 02:20:16 +02009971 execute( TC_si2quater_12_earfcns() );
9972 execute( TC_si2quater_23_earfcns() );
9973 execute( TC_si2quater_32_earfcns() );
9974 execute( TC_si2quater_33_earfcns() );
9975 execute( TC_si2quater_42_earfcns() );
9976 execute( TC_si2quater_48_earfcns() );
9977 execute( TC_si2quater_49_earfcns() );
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02009978 execute( TC_si_acc_rotate() );
Alexander Couzens4ad3a352020-09-10 22:29:12 +02009979 execute( TC_si_acc_ramp_rotate() );
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +02009980
Harald Welte898113b2018-01-31 18:32:21 +01009981 /* RSL DCHAN Channel ACtivation / Deactivation */
Harald Welteae026692017-12-09 01:03:01 +01009982 execute( TC_chan_act_noreply() );
Harald Welte4003d112017-12-09 22:35:39 +01009983 execute( TC_chan_act_counter() );
Harald Welteae026692017-12-09 01:03:01 +01009984 execute( TC_chan_act_ack_noest() );
Philipp Maier9c60a622020-07-09 15:08:46 +02009985 execute( TC_chan_act_ack_noest_emerg() );
Philipp Maier606f07d2020-08-12 17:21:58 +02009986 execute( TC_chan_rqd_emerg_deny() );
Harald Welteae026692017-12-09 01:03:01 +01009987 execute( TC_chan_act_ack_est_ind_noreply() );
9988 execute( TC_chan_act_ack_est_ind_refused() );
Harald Welte618ef642017-12-14 14:58:20 +01009989 execute( TC_chan_act_nack() );
Harald Welte799c97b2017-12-14 17:50:30 +01009990 execute( TC_chan_exhaustion() );
Vadim Yanitskiy1ff1fdf2018-11-27 01:32:57 +07009991 execute( TC_chan_deact_silence() );
Harald Welte4003d112017-12-09 22:35:39 +01009992 execute( TC_chan_rel_rll_rel_ind() );
9993 execute( TC_chan_rel_conn_fail() );
9994 execute( TC_chan_rel_hard_clear() );
Pau Espin Pedrol841b90d2021-04-15 16:42:52 +02009995 execute( TC_chan_rel_last_eutran_plmn_hard_clear_no_csfb() );
9996 execute( TC_chan_rel_last_eutran_plmn_hard_clear_csfb() );
Harald Welte99787102019-02-04 10:41:36 +01009997 execute( TC_chan_rel_hard_clear_csfb() );
Harald Welted8c36cd2017-12-09 23:05:31 +01009998 execute( TC_chan_rel_hard_rlsd() );
Harald Welte550daf92018-06-11 19:22:13 +02009999 execute( TC_chan_rel_hard_rlsd_ms_dead() );
Harald Welte85804d42017-12-10 14:11:58 +010010000 execute( TC_chan_rel_a_reset() );
Pau Espin Pedrolc675b612020-01-09 19:55:40 +010010001 execute( TC_chan_rel_sccp_tiar_timeout() );
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +020010002 execute( TC_chan_rel_rr_cause() );
Harald Welte6f521d82017-12-11 19:52:02 +010010003
Harald Weltecfe2c962017-12-15 12:09:32 +010010004 execute( TC_outbound_connect() );
Harald Welte898113b2018-01-31 18:32:21 +010010005
10006 /* Assignment related */
Harald Welte16a4adf2017-12-14 18:54:01 +010010007 execute( TC_assignment_cic_only() );
Harald Welte235ebf12017-12-15 14:18:16 +010010008 execute( TC_assignment_csd() );
10009 execute( TC_assignment_ctm() );
10010 execute( TC_assignment_sign() );
Pau Espin Pedrol07866632020-09-03 19:10:55 +020010011 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
10012 execute( TC_assignment_aoip_tla_v6() );
10013 }
Harald Welte235ebf12017-12-15 14:18:16 +010010014 execute( TC_assignment_fr_a5_0() );
10015 execute( TC_assignment_fr_a5_1() );
Neels Hofmeyrf246a922020-05-13 02:27:10 +020010016 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
Harald Welte8f67d1d2018-05-25 20:38:42 +020010017 execute( TC_assignment_fr_a5_1_codec_missing() );
10018 }
Harald Welte235ebf12017-12-15 14:18:16 +010010019 execute( TC_assignment_fr_a5_3() );
Neels Hofmeyr0d8ec532021-06-11 00:09:48 +020010020 execute( TC_assignment_fr_a5_4() );
Neels Hofmeyr0faeb7a2021-06-10 23:59:35 +020010021 execute( TC_assignment_fr_a5_4_fail() );
Neels Hofmeyr04d6e6a2021-06-11 00:10:02 +020010022 execute( TC_assignment_fr_a5_not_sup() );
Harald Welte3c86ea02018-05-10 22:28:05 +020010023 execute( TC_ciph_mode_a5_0() );
10024 execute( TC_ciph_mode_a5_1() );
Oliver Smith50b98122021-07-09 15:00:28 +020010025 execute( TC_ciph_mode_a5_2_0() );
Oliver Smith1dff88d2021-07-09 08:45:51 +020010026 execute( TC_ciph_mode_a5_2_1() );
Harald Welte3c86ea02018-05-10 22:28:05 +020010027 execute( TC_ciph_mode_a5_3() );
Neels Hofmeyr81ad27f2021-06-11 00:09:40 +020010028 execute( TC_ciph_mode_a5_4() );
Harald Welte16a4adf2017-12-14 18:54:01 +010010029
Harald Welte60aa5762018-03-21 19:33:13 +010010030 execute( TC_assignment_codec_fr() );
Neels Hofmeyr559d5d02021-04-16 16:50:49 +020010031 execute( TC_assignment_codec_fr_by_mode_modify() );
Harald Welte60aa5762018-03-21 19:33:13 +010010032 execute( TC_assignment_codec_hr() );
10033 execute( TC_assignment_codec_efr() );
10034 execute( TC_assignment_codec_amr_f() );
10035 execute( TC_assignment_codec_amr_h() );
Philipp Maier8a581d22019-03-26 18:32:48 +010010036
Neels Hofmeyrf246a922020-05-13 02:27:10 +020010037 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
Philipp Maier8a581d22019-03-26 18:32:48 +010010038 execute( TC_assignment_codec_amr_f_S1() );
10039 execute( TC_assignment_codec_amr_h_S1() );
10040 execute( TC_assignment_codec_amr_f_S124() );
10041 execute( TC_assignment_codec_amr_h_S124() );
10042 execute( TC_assignment_codec_amr_f_S0() );
10043 execute( TC_assignment_codec_amr_f_S02() );
10044 execute( TC_assignment_codec_amr_f_S024() );
10045 execute( TC_assignment_codec_amr_f_S0247() );
10046 execute( TC_assignment_codec_amr_h_S0() );
10047 execute( TC_assignment_codec_amr_h_S02() );
10048 execute( TC_assignment_codec_amr_h_S024() );
10049 execute( TC_assignment_codec_amr_h_S0247() );
10050 execute( TC_assignment_codec_amr_f_S01234567() );
10051 execute( TC_assignment_codec_amr_f_S0234567() );
10052 execute( TC_assignment_codec_amr_f_zero() );
10053 execute( TC_assignment_codec_amr_f_unsupp() );
10054 execute( TC_assignment_codec_amr_h_S7() );
Neels Hofmeyr21863562020-11-26 00:34:33 +000010055 execute( TC_assignment_codec_amr_f_start_mode_auto() );
10056 execute( TC_assignment_codec_amr_h_start_mode_auto() );
Neels Hofmeyr3eb94562020-11-26 02:40:26 +000010057 execute( TC_assignment_codec_amr_f_start_mode_4() );
10058 execute( TC_assignment_codec_amr_h_start_mode_4() );
Neels Hofmeyr454d7922020-11-26 02:24:57 +000010059 execute( TC_assignment_codec_amr_startmode_cruft() );
Philipp Maier8a581d22019-03-26 18:32:48 +010010060 }
Harald Welte60aa5762018-03-21 19:33:13 +010010061
Philipp Maierac09bfc2019-01-08 13:41:39 +010010062 execute( TC_assignment_codec_fr_exhausted_req_hr() );
10063 execute( TC_assignment_codec_fr_exhausted_req_fr() );
10064 execute( TC_assignment_codec_fr_exhausted_req_fr_hr() );
10065 execute( TC_assignment_codec_fr_exhausted_req_hr_fr() );
10066 execute( TC_assignment_codec_hr_exhausted_req_fr() );
10067 execute( TC_assignment_codec_hr_exhausted_req_hr() );
10068 execute( TC_assignment_codec_hr_exhausted_req_hr_fr() );
10069 execute( TC_assignment_codec_hr_exhausted_req_fr_hr() );
10070 execute( TC_assignment_codec_req_hr_fr() );
10071 execute( TC_assignment_codec_req_fr_hr() );
Pau Espin Pedrol14475352021-07-22 15:48:16 +020010072 execute( TC_assignment_sdcch_exhausted_req_signalling() );
10073 execute( TC_assignment_sdcch_exhausted_req_signalling_tch_forbidden() );
10074 execute( TC_assignment_sdcch_exhausted_req_voice_tch_forbidden() );
Philipp Maierac09bfc2019-01-08 13:41:39 +010010075
Pau Espin Pedrol23510fb2021-07-20 17:00:38 +020010076 execute( TC_assignment_osmux() );
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +020010077
Harald Welte898113b2018-01-31 18:32:21 +010010078 /* RLL Establish Indication on inactive DCHAN / SAPI */
Harald Welte5cd20ed2017-12-13 21:03:20 +010010079 execute( TC_rll_est_ind_inact_lchan() );
10080 execute( TC_rll_est_ind_inval_sapi1() );
10081 execute( TC_rll_est_ind_inval_sapi3() );
10082 execute( TC_rll_est_ind_inval_sacch() );
10083
Vadim Yanitskiy61f784a2020-10-01 21:12:19 +070010084 /* DLCI / RSL Link ID conversion for MO/MT messages on SAPI0/SAPI3 */
10085 execute( TC_tch_dlci_link_id_sapi() );
10086
Vadim Yanitskiy6ef5dfa2020-08-28 18:04:41 +070010087 /* SAPI N Reject triggered by RLL establishment failures */
10088 execute( TC_rll_rel_ind_sapi_n_reject() );
10089 execute( TC_rll_err_ind_sapi_n_reject() );
10090 execute( TC_rll_timeout_sapi_n_reject() );
10091
Harald Welte898113b2018-01-31 18:32:21 +010010092 /* Paging related tests */
Harald Welte6f521d82017-12-11 19:52:02 +010010093 execute( TC_paging_imsi_nochan() );
10094 execute( TC_paging_tmsi_nochan() );
10095 execute( TC_paging_tmsi_any() );
10096 execute( TC_paging_tmsi_sdcch() );
10097 execute( TC_paging_tmsi_tch_f() );
10098 execute( TC_paging_tmsi_tch_hf() );
10099 execute( TC_paging_imsi_nochan_cgi() );
10100 execute( TC_paging_imsi_nochan_lac_ci() );
10101 execute( TC_paging_imsi_nochan_ci() );
10102 execute( TC_paging_imsi_nochan_lai() );
10103 execute( TC_paging_imsi_nochan_lac() );
10104 execute( TC_paging_imsi_nochan_all() );
Harald Welte751d3eb2018-01-31 15:51:06 +010010105 execute( TC_paging_imsi_nochan_plmn_lac_rnc() );
10106 execute( TC_paging_imsi_nochan_rnc() );
10107 execute( TC_paging_imsi_nochan_lac_rnc() );
10108 execute( TC_paging_imsi_nochan_lacs() );
10109 execute( TC_paging_imsi_nochan_lacs_empty() );
Stefan Sperling049a86e2018-03-20 15:51:00 +010010110 execute( TC_paging_imsi_nochan_cgi_unknown_cid() );
Harald Welte10985002017-12-12 09:29:15 +010010111 execute( TC_paging_imsi_a_reset() );
Harald Weltee65d40e2017-12-13 00:09:06 +010010112 execute( TC_paging_imsi_load() );
Philipp Maier779a7922018-02-16 11:00:37 +010010113 execute( TC_paging_counter() );
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +010010114 execute( TC_paging_resp_unsol() );
Harald Welte4e9b9cc2017-12-14 18:31:02 +010010115
10116 execute( TC_rsl_drop_counter() );
Stefan Sperling830dc9d2018-02-12 21:08:28 +010010117 execute( TC_rsl_unknown_unit_id() );
10118
10119 execute( TC_oml_unknown_unit_id() );
Harald Welte898113b2018-01-31 18:32:21 +010010120
10121 execute( TC_classmark() );
Harald Welteeddf0e92020-06-21 19:42:15 +020010122 execute( TC_common_id() );
Harald Welte898113b2018-01-31 18:32:21 +010010123 execute( TC_unsol_ass_fail() );
Harald Welteea99a002018-01-31 20:46:43 +010010124 execute( TC_unsol_ass_compl() );
Harald Weltefbf9b5e2018-01-31 20:41:23 +010010125 execute( TC_unsol_ho_fail() );
Harald Weltee3bd6582018-01-31 22:51:25 +010010126 execute( TC_err_82_short_msg() );
Harald Weltee9e02e42018-01-31 23:36:25 +010010127 execute( TC_err_84_unknown_msg() );
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +010010128
Harald Welte261af4b2018-02-12 21:20:39 +010010129 execute( TC_ho_int() );
Neels Hofmeyraf88d9d2021-06-21 02:14:27 +020010130 execute( TC_ho_int_a5_0() );
10131 execute( TC_ho_int_a5_1() );
10132 execute( TC_ho_int_a5_3() );
10133 execute( TC_ho_int_a5_4() );
Neels Hofmeyr5f144212020-11-03 15:41:58 +000010134 execute( TC_ho_int_radio_link_failure() );
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +010010135
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +010010136 execute( TC_ho_out_of_this_bsc() );
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +020010137 execute( TC_ho_out_fail_no_msc_response() );
10138 execute( TC_ho_out_fail_rr_ho_failure() );
Neels Hofmeyrd8a602c2019-07-09 19:46:01 +020010139 execute( TC_ho_out_fail_no_result_after_ho_cmd() );
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +010010140
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +010010141 execute( TC_ho_into_this_bsc() );
Neels Hofmeyr8ebf19c2021-06-21 05:24:01 +020010142 execute( TC_ho_into_this_bsc_a5_0() );
10143 execute( TC_ho_into_this_bsc_a5_1() );
10144 execute( TC_ho_into_this_bsc_a5_3() );
10145 execute( TC_ho_into_this_bsc_a5_4() );
Pau Espin Pedrol07866632020-09-03 19:10:55 +020010146 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
10147 execute( TC_ho_into_this_bsc_tla_v6() );
10148 }
Pau Espin Pedrolc08d5522021-04-16 15:40:38 +020010149 execute( TC_srvcc_eutran_to_geran() );
Pau Espin Pedrol35801c32021-04-19 13:03:20 +020010150 execute( TC_srvcc_eutran_to_geran_ho_out() );
Pau Espin Pedrol9ae36d52021-06-15 17:29:43 +020010151 execute( TC_srvcc_eutran_to_geran_forbid_fast_return() );
10152 execute( TC_srvcc_eutran_to_geran_ho_out_forbid_fast_return() );
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +010010153 execute( TC_ho_in_fail_msc_clears() );
10154 execute( TC_ho_in_fail_msc_clears_after_ho_detect() );
10155 execute( TC_ho_in_fail_no_detect() );
10156 execute( TC_ho_in_fail_no_detect2() );
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +010010157
Neels Hofmeyr91401012019-07-11 00:42:35 +020010158 execute( TC_ho_neighbor_config_1() );
10159 execute( TC_ho_neighbor_config_2() );
10160 execute( TC_ho_neighbor_config_3() );
10161 execute( TC_ho_neighbor_config_4() );
10162 execute( TC_ho_neighbor_config_5() );
10163 execute( TC_ho_neighbor_config_6() );
10164 execute( TC_ho_neighbor_config_7() );
10165
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +010010166 execute( TC_bssap_rlsd_does_not_cause_bssmap_reset() );
Neels Hofmeyr4ff93282018-03-12 04:25:35 +010010167 execute( TC_bssmap_clear_does_not_cause_bssmap_reset() );
Neels Hofmeyrfd445c32018-03-09 15:39:31 +010010168 execute( TC_ms_rel_ind_does_not_cause_bssmap_reset() );
Harald Welte94e0c342018-04-07 11:33:23 +020010169
10170 execute( TC_dyn_pdch_ipa_act_deact() );
10171 execute( TC_dyn_pdch_ipa_act_nack() );
10172 execute( TC_dyn_pdch_osmo_act_deact() );
10173 execute( TC_dyn_pdch_osmo_act_nack() );
Pau Espin Pedrole076b3f2021-07-20 16:45:57 +020010174 if (mp_enable_dyn_sdcch8_test) {
10175 execute( TC_dyn_ts_sdcch8_act_deact() );
10176 execute (TC_dyn_ts_sdcch8_tch_call_act_deact() );
10177 execute( TC_dyn_ts_sdcch8_act_nack() );
10178 }
Harald Welte99f3ca02018-06-14 13:40:29 +020010179
Stefan Sperling0796a822018-10-05 13:01:39 +020010180 execute( TC_chopped_ipa_ping() );
Stefan Sperlingaa1e60f2018-10-15 16:34:07 +020010181 execute( TC_chopped_ipa_payload() );
Stefan Sperling0796a822018-10-05 13:01:39 +020010182
Pau Espin Pedrol8f773632019-11-05 11:46:53 +010010183 /* Power control related */
10184 execute( TC_assignment_verify_ms_power_params_ie() );
Vadim Yanitskiy4b233042021-06-30 00:58:43 +020010185 execute( TC_c0_power_red_mode() );
Neels Hofmeyr4f118412020-06-04 15:25:10 +020010186
10187 /* MSC pooling */
10188 /* FIXME: in SCCPlite, indicating how many MSCs should be connected does currently not work. Since
10189 * RESET->RESET-ACK is unconditionally negotiated for all configured MSCs, they always all appear as connected
10190 * to osmo-bsc. The MSC pooling tests however require disconnecting selected MSCs, and hence don't work out as
10191 * intended on SCCPlite. So for now, run these only for SCCP/M3UA. */
10192 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
10193 execute( TC_mscpool_L3Compl_on_1_msc() );
10194 execute( TC_mscpool_L3Complete_by_imsi_round_robin() );
10195 execute( TC_mscpool_LU_by_tmsi_null_nri_0_round_robin() );
10196 execute( TC_mscpool_LU_by_tmsi_null_nri_1_round_robin() );
10197 execute( TC_mscpool_L3Complete_by_tmsi_unassigned_nri_round_robin() );
10198 execute( TC_mscpool_L3Complete_by_tmsi_valid_nri_msc_not_connected_round_robin() );
10199 execute( TC_mscpool_L3Complete_by_tmsi_valid_nri_1() );
10200 execute( TC_mscpool_L3Complete_by_tmsi_valid_nri_2() );
10201 execute( TC_mscpool_LU_by_tmsi_from_other_PLMN() );
10202 execute( TC_mscpool_paging_and_response_imsi() );
10203 execute( TC_mscpool_paging_and_response_tmsi() );
10204 execute( TC_mscpool_no_allow_attach_round_robin() );
10205 execute( TC_mscpool_no_allow_attach_valid_nri() );
10206 }
10207
Harald Welte99f3ca02018-06-14 13:40:29 +020010208 execute( TC_early_conn_fail() );
10209 execute( TC_late_conn_fail() );
Oliver Smithaf03bef2021-08-24 15:34:51 +020010210 execute( TC_stats_conn_fail() );
Harald Welte99f3ca02018-06-14 13:40:29 +020010211
Philipp Maier783681c2020-07-16 16:47:06 +020010212 /* Emergency call handling (deny / allow) */
10213 execute( TC_assignment_emerg_setup_allow() );
10214 execute( TC_assignment_emerg_setup_deny_msc() );
10215 execute( TC_assignment_emerg_setup_deny_bts() );
Philipp Maier82812002020-08-13 18:48:27 +020010216 execute( TC_emerg_premption() );
10217
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +070010218 /* Frequency hopping parameters handling */
10219 execute( TC_fh_params_chan_activ() );
10220 execute( TC_fh_params_imm_ass() );
Vadim Yanitskiyaeb54a22020-09-01 06:25:25 +070010221 execute( TC_fh_params_assignment_cmd() );
Vadim Yanitskiy8f5430d2020-09-02 18:51:38 +070010222 execute( TC_fh_params_handover_cmd() );
Vadim Yanitskiyca974032020-09-01 07:20:39 +070010223 execute( TC_fh_params_si4_cbch() );
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +020010224
10225 if (mp_enable_lcs_tests) {
10226 execute( TC_lcs_loc_req_for_active_ms() );
10227 execute( TC_lcs_loc_req_for_active_ms_ta_req() );
10228 execute( TC_lcs_loc_req_for_idle_ms() );
10229 execute( TC_lcs_loc_req_no_subscriber() );
10230 execute( TC_lcs_loc_req_for_active_ms_le_timeout() );
10231 execute( TC_lcs_loc_req_for_active_ms_le_timeout2() );
10232 execute( TC_lcs_loc_req_for_idle_ms_no_pag_resp() );
10233 execute( TC_cm_service_during_lcs_loc_req() );
10234 execute( TC_ho_during_lcs_loc_req() );
10235 }
Neels Hofmeyrbf037052020-10-28 22:52:02 +000010236
10237 execute( TC_no_msc() );
Neels Hofmeyr87857ec2021-04-25 16:17:47 +000010238
10239 execute( TC_refuse_chan_act_to_vamos() );
10240 execute( TC_refuse_mode_modif_to_vamos() );
Neels Hofmeyrd2d9f332021-04-28 22:23:36 +000010241
10242 execute( TC_reassignment_fr() );
Neels Hofmeyrfeda88e2021-07-19 13:51:29 +020010243
10244 execute( TC_cm_reestablishment() );
Neels Hofmeyrb07b2952021-08-07 04:23:14 +020010245
10246 execute( TC_imm_ass_post_chan_ack() );
10247 execute( TC_imm_ass_pre_chan_ack() );
Neels Hofmeyr23158742021-09-07 19:08:07 +020010248 execute( TC_imm_ass_pre_ts_ack() );
Neels Hofmeyr7a6d0602021-08-07 04:23:50 +020010249 execute( TC_imm_ass_pre_chan_ack_dyn_ts() );
Neels Hofmeyrc8b95c12021-08-07 04:24:02 +020010250 execute( TC_imm_ass_pre_ts_ack_dyn_ts() );
Harald Welte28d943e2017-11-25 15:00:50 +010010251}
10252
10253}