blob: 2a8965926e125de2b5266d03e4605eabd00ee88d [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
608modulepar {
Harald Welte21b46bd2017-12-17 19:46:32 +0100609 /* IP address at which the BSC can be reached */
Harald Welte696ddb62017-12-08 14:01:43 +0100610 charstring mp_bsc_ip := "127.0.0.1";
Stefan Sperling830dc9d2018-02-12 21:08:28 +0100611 /* port number to which to establish the IPA OML connections */
612 integer mp_bsc_oml_port := 3002;
Harald Welte21b46bd2017-12-17 19:46:32 +0100613 /* port number to which to establish the IPA RSL connections */
Harald Welte696ddb62017-12-08 14:01:43 +0100614 integer mp_bsc_rsl_port := 3003;
Harald Welte21b46bd2017-12-17 19:46:32 +0100615 /* port number to which to establish the IPA CTRL connection */
Harald Welte96c94412017-12-09 03:12:45 +0100616 integer mp_bsc_ctrl_port := 4249;
Daniel Willmannebdecc02020-08-12 15:30:17 +0200617 /* port number to which to listen for STATSD metrics */
618 integer mp_bsc_statsd_port := 8125;
Daniel Willmann191e0d92018-01-17 12:44:35 +0100619 /* IP address at which the test binds */
620 charstring mp_test_ip := "127.0.0.1";
Harald Weltea4ca4462018-02-09 00:17:14 +0100621
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200622 RAN_Configurations mp_bssap_cfg := {
623 {
624 transport := BSSAP_TRANSPORT_AoIP,
625 sccp_service_type := "mtp3_itu",
626 sctp_addr := { 23905, "127.0.0.1", 2905, "127.0.0.1" },
627 own_pc := 185, /* 0.23.1 first MSC emulation */
628 own_ssn := 254,
629 peer_pc := 187, /* 0.23.3 osmo-bsc */
630 peer_ssn := 254,
631 sio := '83'O,
Harald Weltecb0cc432020-06-21 19:42:31 +0200632 rctx := 1
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200633 },
634 {
635 transport := BSSAP_TRANSPORT_AoIP,
636 sccp_service_type := "mtp3_itu",
637 sctp_addr := { 23906, "127.0.0.1", 2905, "127.0.0.1" },
638 own_pc := 2, /* 0.0.2 second MSC emulation */
639 own_ssn := 254,
640 peer_pc := 187, /* 0.23.3 osmo-bsc */
641 peer_ssn := 254,
642 sio := '83'O,
643 rctx := 2
644 },
645 {
646 transport := BSSAP_TRANSPORT_AoIP,
647 sccp_service_type := "mtp3_itu",
648 sctp_addr := { 23907, "127.0.0.1", 2905, "127.0.0.1" },
649 own_pc := 3, /* 0.0.3 third MSC emulation */
650 own_ssn := 254,
651 peer_pc := 187, /* 0.23.3 osmo-bsc */
652 peer_ssn := 254,
653 sio := '83'O,
654 rctx := 3
655 }
Harald Weltea4ca4462018-02-09 00:17:14 +0100656 };
Pau Espin Pedrol58cf6822019-05-28 18:11:33 +0200657
Harald Welte47cd0e32020-08-21 12:39:11 +0200658 BSSAP_LE_Configuration mp_bssap_le_cfg := {
659 sccp_service_type := "mtp3_itu",
660 sctp_addr := { 23908, "127.0.0.1", 2905, "127.0.0.1" },
Neels Hofmeyrac086c12020-09-18 23:46:42 +0200661 own_pc := 190, /* 0.23.6 SMLC emulation */
Harald Welte47cd0e32020-08-21 12:39:11 +0200662 own_ssn := 252, /* SMLC side SSN */
663 peer_pc := 187, /* 0.23.3 osmo-bsc */
664 peer_ssn := 250, /* BSC side SSN */
665 sio := '83'O,
666 rctx := 6
667 };
Neels Hofmeyrcfe44062020-10-15 02:28:08 +0200668 boolean mp_enable_lcs_tests := true;
Harald Welte47cd0e32020-08-21 12:39:11 +0200669
Pau Espin Pedrol58cf6822019-05-28 18:11:33 +0200670 /* Whether to enable osmux tests. Can be dropped completely and enable
671 unconditionally once new version of osmo-bsc is released (current
672 version: 1.4.1) */
673 boolean mp_enable_osmux_test := true;
Pau Espin Pedrol8f30ccd2019-11-01 17:30:57 +0100674 /* Value set in osmo-bsc.cfg "ms max power" */
675 uint8_t mp_exp_ms_power_level := 7;
Harald Weltea4ca4462018-02-09 00:17:14 +0100676}
677
Neels Hofmeyr9f3e6ac2021-04-08 23:09:24 +0200678friend function f_gen_test_hdlr_pars(integer bssap_idx := 0) return TestHdlrParams {
Philipp Maier48604732018-10-09 15:00:37 +0200679
680 var TestHdlrParams pars := valueof(t_def_TestHdlrPars);
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200681 if (mp_bssap_cfg[bssap_idx].transport == BSSAP_TRANSPORT_AoIP) {
Philipp Maier48604732018-10-09 15:00:37 +0200682 pars.aoip := true;
683 } else {
684 pars.aoip := false;
685 }
Pau Espin Pedrol8f30ccd2019-11-01 17:30:57 +0100686 pars.exp_ms_power_level := mp_exp_ms_power_level;
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200687 pars.mscpool.bssap_idx := bssap_idx;
Philipp Maier48604732018-10-09 15:00:37 +0200688
Neels Hofmeyrb5b7a6e2021-06-04 19:03:45 +0200689 /* BTS 0 has BSIC 10 (and no explicit timeslot training_sequence_code config), so expecting TSC = (BSIC & 7) = 2 */
690 pars.expect_tsc := 2;
691
Philipp Maier48604732018-10-09 15:00:37 +0200692 return pars;
693}
694
Neels Hofmeyr22c3f792020-06-17 02:49:28 +0200695/* Convenience functions for rate counters using g_ctr_msc. */
696
697private function f_ctrs_msc_init(integer mscs_count := NUM_MSC, CounterNameVals counternames := counternames_msc_mscpool) runs on test_CT {
698 g_ctr_msc := f_counter_name_vals_get_n(IPA_CTRL, "msc", mscs_count, counternames);
699 log("initial msc rate counters: ", g_ctr_msc);
700}
701
702private function f_ctrs_msc_add(integer msc_nr, charstring countername, integer val := 1) runs on test_CT {
Neels Hofmeyr9656e922020-06-30 01:27:01 +0200703 f_counter_name_vals_list_add(g_ctr_msc, msc_nr, countername, val);
Neels Hofmeyr22c3f792020-06-17 02:49:28 +0200704}
705
706/* f_ctrs_msc_init();
707 * f_do_thing(on_msc := 0);
708 * f_do_thing(on_msc := 0);
709 * f_do_other(on_msc := 1);
710 * f_ctrs_msc_add(0, "thing", 2);
711 * f_ctrs_msc_add(1, "other");
712 * f_ctrs_msc_verify();
713 */
714private function f_ctrs_msc_verify() runs on test_CT {
715 log("verifying msc rate counters: ", g_ctr_msc);
716 f_counter_name_vals_expect_n(IPA_CTRL, "msc", g_ctr_msc);
717}
718
719/* convenience: f_ctrs_msc_add() and f_ctrs_msc_verify() in one call.
720 * f_ctrs_msc_init();
721 * f_do_thing(on_msc := 0);
722 * f_do_thing(on_msc := 0);
723 * f_do_thing(on_msc := 0);
724 * f_ctrs_msc_expect(0, "thing", 3);
725 */
726private function f_ctrs_msc_expect(integer msc_nr, charstring countername, integer val := 1) runs on test_CT {
727 f_ctrs_msc_add(msc_nr, countername, val);
728 f_ctrs_msc_verify();
729}
730
Neels Hofmeyr12941bd2020-08-29 03:21:26 +0000731/* Convenience functions for rate counters using g_ctr_bts, always also including g_ctr_bsc. */
732
733private function f_ctrs_bsc_and_bts_init(integer bts_count := NUM_BTS, CounterNameVals counternames := counternames_bsc_bts_handover) runs on test_CT {
734 g_ctr_bts := f_counter_name_vals_get_n(IPA_CTRL, "bts", bts_count, counternames);
735 log("initial bts rate counters: ", g_ctr_bts);
736 f_ctrs_bsc_init(counternames);
737}
738
739private function f_ctrs_bsc_and_bts_add(integer bts_nr, charstring countername, integer val := 1) runs on test_CT {
740 f_counter_name_vals_list_add(g_ctr_bts, bts_nr, countername, val);
741 f_ctrs_bsc_add(countername, val);
742}
743
744/* f_ctrs_bsc_and_bts_init();
745 * f_do_thing(on_bts := 0);
746 * f_do_thing(on_bts := 0);
747 * f_do_other(on_bts := 1);
748 * f_ctrs_bsc_and_bts_add(0, "thing", 2);
749 * f_ctrs_bsc_and_bts_add(1, "other");
750 * f_ctrs_bsc_and_bts_verify();
751 */
752private function f_ctrs_bsc_and_bts_verify() runs on test_CT {
753 f_counter_name_vals_expect_n(IPA_CTRL, "bts", g_ctr_bts);
754 f_ctrs_bsc_verify();
755}
756
757/* convenience: f_ctrs_bsc_and_bts_add() and f_ctrs_bsc_and_bts_verify() in one call.
758 * f_ctrs_bsc_and_bts_init();
759 * f_do_thing(on_bts := 0);
760 * f_do_thing(on_bts := 0);
761 * f_do_thing(on_bts := 0);
762 * f_ctrs_bsc_and_bts_expect(0, "thing", 3);
763 */
764private function f_ctrs_bsc_and_bts_expect(integer bts_nr, charstring countername, integer val := 1) runs on test_CT {
765 f_ctrs_bsc_and_bts_add(bts_nr, countername, val);
766 f_ctrs_bsc_and_bts_verify();
767}
768
769
770/* Convenience functions for rate counters using g_ctr_bsc. */
771
772private function f_ctrs_bsc_init(CounterNameVals counternames := counternames_bsc_bts_handover) runs on test_CT {
773 g_ctr_bsc := f_counter_name_vals_get_n(IPA_CTRL, "bsc", 1, counternames);
774 log("initial bsc rate counters: ", g_ctr_bsc);
775}
776
777private function f_ctrs_bsc_add(charstring countername, integer val := 1) runs on test_CT {
778 f_counter_name_vals_list_add(g_ctr_bsc, 0, countername, val);
779}
780
781/* f_ctrs_bsc_init();
782 * f_do_thing();
783 * f_do_thing();
784 * f_do_other();
785 * f_ctrs_bsc_add("thing", 2);
786 * f_ctrs_bsc_add("other");
787 * f_ctrs_bsc_verify();
788 */
789private function f_ctrs_bsc_verify() runs on test_CT {
790 f_counter_name_vals_expect_n(IPA_CTRL, "bsc", g_ctr_bsc);
791}
792
793/* convenience: f_ctrs_bsc_add() and f_ctrs_bsc_verify() in one call.
794 * f_ctrs_bsc_init();
795 * f_do_thing();
796 * f_ctrs_bsc_expect("thing", 1);
797 */
798private function f_ctrs_bsc_expect(charstring countername, integer val := 1) runs on test_CT {
799 f_ctrs_bsc_add(countername, val);
800 f_ctrs_bsc_verify();
801}
802
Neels Hofmeyr22c3f792020-06-17 02:49:28 +0200803
Neels Hofmeyr9f3e6ac2021-04-08 23:09:24 +0200804friend function f_shutdown_helper() runs on test_CT {
Daniel Willmann637ef6c2018-07-25 10:49:09 +0200805 all component.stop;
Philipp Maier282ca4b2018-02-27 17:17:00 +0100806 setverdict(pass);
Daniel Willmannafce8662018-07-06 23:11:32 +0200807 mtc.stop;
Philipp Maier282ca4b2018-02-27 17:17:00 +0100808}
809
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200810private function f_legacy_bssap_reset(integer bssap_idx := 0) runs on test_CT {
Harald Weltea4ca4462018-02-09 00:17:14 +0100811 var BSSAP_N_UNITDATA_ind ud_ind;
Pau Espin Pedrol24c05992020-09-01 12:54:12 +0200812 var boolean reset_received := false;
Harald Weltea4ca4462018-02-09 00:17:14 +0100813 timer T := 5.0;
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200814 BSSAP.send(ts_BSSAP_UNITDATA_req(g_bssap[bssap_idx].sccp_addr_peer, g_bssap[bssap_idx].sccp_addr_own,
815 ts_BSSMAP_Reset(0, g_osmux_enabled)));
Harald Weltea4ca4462018-02-09 00:17:14 +0100816 T.start;
817 alt {
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200818 [] BSSAP.receive(tr_BSSAP_UNITDATA_ind(g_bssap[bssap_idx].sccp_addr_own, g_bssap[bssap_idx].sccp_addr_peer,
819 tr_BSSMAP_ResetAck(g_osmux_enabled))) {
Neels Hofmeyr4f5d7be2020-10-16 16:28:16 +0200820 log("BSSMAP: Received RESET-ACK in response to RESET, we're ready to go!");
Harald Weltea4ca4462018-02-09 00:17:14 +0100821 }
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200822 [] BSSAP.receive(tr_BSSAP_UNITDATA_ind(?, ?, tr_BSSMAP_Reset(g_osmux_enabled))) -> value ud_ind {
Neels Hofmeyr4f5d7be2020-10-16 16:28:16 +0200823 log("BSSMAP: Respoding to inbound RESET with RESET-ACK");
Harald Weltea4ca4462018-02-09 00:17:14 +0100824 BSSAP.send(ts_BSSAP_UNITDATA_req(ud_ind.callingAddress, ud_ind.calledAddress,
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200825 ts_BSSMAP_ResetAck(g_osmux_enabled)));
Pau Espin Pedrol24c05992020-09-01 12:54:12 +0200826 reset_received := true;
Harald Weltea4ca4462018-02-09 00:17:14 +0100827 repeat;
828 }
829 [] BSSAP.receive { repeat; }
Pau Espin Pedrol24c05992020-09-01 12:54:12 +0200830 [] T.timeout {
Neels Hofmeyr4f5d7be2020-10-16 16:28:16 +0200831 log("BSSMAP: Timeout waiting for RESET-ACK after sending RESET");
Pau Espin Pedrol24c05992020-09-01 12:54:12 +0200832 /* If we received a RESET after ours was sent, it
833 may be a race condition where the other peer beacame
834 available after we sent it, but we are in a desired
835 state anyway, so go forward. */
836 if (not reset_received) {
837 setverdict(fail);
838 }
839 }
Harald Weltea4ca4462018-02-09 00:17:14 +0100840 }
Harald Welte28d943e2017-11-25 15:00:50 +0100841}
842
Harald Welteae026692017-12-09 01:03:01 +0100843type record IPA_Client {
Harald Welte21b46bd2017-12-17 19:46:32 +0100844 /* IPA Emulation component reference */
Harald Welteae026692017-12-09 01:03:01 +0100845 IPA_Emulation_CT vc_IPA,
Harald Welte21b46bd2017-12-17 19:46:32 +0100846 /* Unit-ID and other CCM parameters to use for IPA client emulation */
Harald Welteae026692017-12-09 01:03:01 +0100847 IPA_CCM_Parameters ccm_pars,
Harald Welte21b46bd2017-12-17 19:46:32 +0100848 /* String identifier for this IPA Client */
Harald Welte624f9632017-12-16 19:26:04 +0100849 charstring id,
Harald Welte21b46bd2017-12-17 19:46:32 +0100850 /* Associated RSL Emulation Component (if any). Only used in "Handler mode" */
Harald Welte624f9632017-12-16 19:26:04 +0100851 RSL_Emulation_CT vc_RSL optional
Harald Welte28d943e2017-11-25 15:00:50 +0100852}
853
Harald Welte21b46bd2017-12-17 19:46:32 +0100854/*! Start the IPA/RSL related bits for one IPA_Client.
855 * \param clnt IPA_Client for which to establish
856 * \param bsc_host IP address / hostname of the BSC
857 * \param bsc_port TCP port number of the BSC
858 * \param i number identifying this BTS
859 * \param handler_mode Start an RSL_Emulation_CT component (true) or not (false) */
Harald Welte624f9632017-12-16 19:26:04 +0100860function f_ipa_rsl_start(inout IPA_Client clnt, charstring bsc_host, PortNumber bsc_port, integer i,
861 boolean handler_mode := false)
Harald Welte28d943e2017-11-25 15:00:50 +0100862runs on test_CT {
Harald Welteae026692017-12-09 01:03:01 +0100863 timer T := 10.0;
864
Harald Welte96c94412017-12-09 03:12:45 +0100865 clnt.id := "IPA" & int2str(i) & "-RSL";
Harald Welteae026692017-12-09 01:03:01 +0100866 clnt.vc_IPA := IPA_Emulation_CT.create(clnt.id & "-IPA");
867 clnt.ccm_pars := c_IPA_default_ccm_pars;
868 clnt.ccm_pars.name := "Osmocom TTCN-3 BTS Simulator";
869 clnt.ccm_pars.unit_id := int2str(1234+i) & "/0/0";
Harald Welte624f9632017-12-16 19:26:04 +0100870 if (handler_mode) {
871 clnt.vc_RSL := RSL_Emulation_CT.create(clnt.id & "-RSL");
Harald Welte89ab1912018-02-23 18:56:29 +0100872 connect(clnt.vc_RSL:CCHAN_PT, self:RSL_CCHAN[i]);
Harald Welte624f9632017-12-16 19:26:04 +0100873 }
Harald Welteae026692017-12-09 01:03:01 +0100874
875 map(clnt.vc_IPA:IPA_PORT, system:IPA_CODEC_PT);
Harald Welte624f9632017-12-16 19:26:04 +0100876 if (handler_mode) {
877 connect(clnt.vc_IPA:IPA_RSL_PORT, clnt.vc_RSL:IPA_PT);
878 } else {
879 connect(clnt.vc_IPA:IPA_RSL_PORT, self:IPA_RSL[i]);
880 }
Harald Welteae026692017-12-09 01:03:01 +0100881
Harald Welte5d1a2202017-12-13 19:51:29 +0100882 clnt.vc_IPA.start(IPA_Emulation.main_client(bsc_host, bsc_port, "", 10000+i, clnt.ccm_pars));
Harald Welte624f9632017-12-16 19:26:04 +0100883 if (handler_mode) {
884 clnt.vc_RSL.start(RSL_Emulation.main());
885 return;
886 }
Harald Welteae026692017-12-09 01:03:01 +0100887
888 /* wait for IPA RSL link to connect and send ID ACK */
889 T.start;
890 alt {
Vadim Yanitskiya2afacc2020-05-18 21:16:19 +0700891 [] IPA_RSL[i].receive(tr_ASP_IPA_EV(ASP_IPA_EVENT_ID_ACK)) {
Harald Welteae026692017-12-09 01:03:01 +0100892 T.stop;
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +0700893 IPA_RSL[i].send(ts_ASP_RSL_UD(ts_RSL_PAGING_LOAD_IND(23)));
Harald Welteae026692017-12-09 01:03:01 +0100894 }
Harald Welte60e823a2017-12-10 14:10:59 +0100895 [] IPA_RSL[i].receive(ASP_IPA_Event:?) { repeat }
Harald Welteae026692017-12-09 01:03:01 +0100896 [] IPA_RSL[i].receive { repeat }
897 [] T.timeout {
Harald Welte96c94412017-12-09 03:12:45 +0100898 setverdict(fail, "Timeout RSL waiting for ASP_IPA_EVENT_ID_ACK");
Daniel Willmannafce8662018-07-06 23:11:32 +0200899 mtc.stop;
Harald Welteae026692017-12-09 01:03:01 +0100900 }
901 }
902}
903
Harald Welte12055472018-03-17 20:10:08 +0100904function f_ipa_rsl_stop(inout IPA_Client clnt) runs on test_CT {
905 if (not isbound(clnt) or not isbound(clnt.vc_IPA)) {
906 return;
907 }
908 clnt.vc_IPA.stop;
909 if (isbound(clnt.vc_RSL)) {
910 clnt.vc_RSL.stop;
911 }
912}
913
Harald Welte21b46bd2017-12-17 19:46:32 +0100914/* Wait for the OML connection to be brought up by the external osmo-bts-omldummy */
Harald Weltea5d2ab22017-12-09 14:21:42 +0100915function f_wait_oml(integer bts_nr, charstring status, float secs_max) runs on test_CT {
916 timer T := secs_max;
917 T.start;
918 while (true) {
919 if (f_ctrl_get_bts(IPA_CTRL, bts_nr, "oml-connection-state") == status) {
920 T.stop;
Harald Weltebd868bd2017-12-10 18:28:40 +0100921 /* the 'degraded' state exists from OML connection time, and we have to wait
922 * until all MO's are initialized */
923 T.start(1.0);
924 T.timeout;
Harald Weltea5d2ab22017-12-09 14:21:42 +0100925 return;
926 }
Harald Weltef0d6ac62017-12-17 17:02:21 +0100927 f_sleep(0.1);
Harald Weltea5d2ab22017-12-09 14:21:42 +0100928 if (not T.running) {
Max99253902018-11-16 17:57:39 +0100929 setverdict(fail, "Timeout waiting for BTS" & int2str(bts_nr) & " oml-connection-state ", status);
Daniel Willmannafce8662018-07-06 23:11:32 +0200930 mtc.stop;
Harald Weltea5d2ab22017-12-09 14:21:42 +0100931 }
932 }
933}
934
Harald Welte21b46bd2017-12-17 19:46:32 +0100935/* global altstep for global guard timer; also takes care of responding RESET witH RESET-ACK */
Harald Welteae026692017-12-09 01:03:01 +0100936altstep as_Tguard() runs on test_CT {
Harald Welte60e823a2017-12-10 14:10:59 +0100937 var BSSAP_N_UNITDATA_ind ud_ind;
Neels Hofmeyrcc3f76a2018-03-12 01:43:25 +0100938 [] T_guard.timeout {
939 setverdict(fail, "Timeout of T_guard");
Daniel Willmannafce8662018-07-06 23:11:32 +0200940 mtc.stop;
Neels Hofmeyrcc3f76a2018-03-12 01:43:25 +0100941 }
Harald Welte60e823a2017-12-10 14:10:59 +0100942 /* always respond with RESET ACK to RESET */
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200943 [] BSSAP.receive(tr_BSSAP_UNITDATA_ind(?, ?, tr_BSSMAP_Reset(g_osmux_enabled))) -> value ud_ind {
Harald Welte60e823a2017-12-10 14:10:59 +0100944 BSSAP.send(ts_BSSAP_UNITDATA_req(ud_ind.callingAddress, ud_ind.calledAddress,
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200945 ts_BSSMAP_ResetAck(g_osmux_enabled)));
Harald Welte69c1c262017-12-13 21:02:08 +0100946 repeat;
Harald Welte60e823a2017-12-10 14:10:59 +0100947 }
Harald Welte28d943e2017-11-25 15:00:50 +0100948}
949
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +0100950altstep no_bssmap_reset() runs on test_CT {
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200951 [] BSSAP.receive(tr_BSSAP_UNITDATA_ind(?, ?, tr_BSSMAP_Reset(g_osmux_enabled))) {
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +0100952 setverdict(fail, "unexpected BSSMAP Reset");
Daniel Willmannafce8662018-07-06 23:11:32 +0200953 mtc.stop;
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +0100954 }
955}
956
Daniel Willmann191e0d92018-01-17 12:44:35 +0100957function f_init_mgcp(charstring id) runs on test_CT {
958 id := id & "-MGCP";
959
960 var MGCPOps ops := {
961 create_cb := refers(MGCP_Emulation.ExpectedCreateCallback),
962 unitdata_cb := refers(MGCP_Emulation.DummyUnitdataCallback)
963 };
964 var MGCP_conn_parameters mgcp_pars := {
965 callagent_ip := mp_bsc_ip,
Harald Welte9e4273e2018-01-29 22:01:22 +0100966 callagent_udp_port := -1,
Daniel Willmann191e0d92018-01-17 12:44:35 +0100967 mgw_ip := mp_test_ip,
Pau Espin Pedrol1a026a52019-06-18 17:21:52 +0200968 mgw_udp_port := 2427,
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +0200969 /* Enable it for SCCPlite, since we have 2 MGCP sockets towards MGW (UDP one +
970 the on with MGCP over IPA forwarded from MSC one) */
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200971 multi_conn_mode := (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_SCCPlite_SERVER)
Daniel Willmann191e0d92018-01-17 12:44:35 +0100972 };
973
974 vc_MGCP := MGCP_Emulation_CT.create(id);
975 vc_MGCP.start(MGCP_Emulation.main(ops, mgcp_pars, id));
976}
977
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200978/* Enable or disable (current default) Osmux. When enabling, BSSMAP Reset
979 * contains extra IE (OsmuxSupport) and osmo-bsc will handle AssignReq with
980 * OsmuxCID IE.
981 */
982private function f_vty_allow_osmux(boolean allow) runs on test_CT {
983 f_vty_enter_cfg_msc(BSCVTY, 0);
984 if (allow) {
985 f_vty_transceive(BSCVTY, "osmux on");
986 } else {
987 f_vty_transceive(BSCVTY, "osmux off");
988 }
989 f_vty_transceive(BSCVTY, "exit");
990 f_vty_transceive(BSCVTY, "exit");
991 g_osmux_enabled := allow;
992}
993
Max2253c0b2018-11-06 19:28:05 +0100994function f_init_vty(charstring id := "foo") runs on test_CT {
Harald Welte94e0c342018-04-07 11:33:23 +0200995 if (BSCVTY.checkstate("Mapped")) {
996 /* skip initialization if already executed once */
997 return;
998 }
Harald Weltebc03c762018-02-12 18:09:38 +0100999 map(self:BSCVTY, system:BSCVTY);
1000 f_vty_set_prompts(BSCVTY);
1001 f_vty_transceive(BSCVTY, "enable");
Pau Espin Pedrolc675b612020-01-09 19:55:40 +01001002 f_cs7_inst_0_cfg(BSCVTY, {"sccp-timer ias " & int2str(g_bsc_sccp_timer_ias),
1003 "sccp-timer iar " & int2str(g_bsc_sccp_timer_iar)});
Harald Weltebc03c762018-02-12 18:09:38 +01001004}
1005
Neels Hofmeyr9f3e6ac2021-04-08 23:09:24 +02001006friend function f_logp(TELNETasp_PT pt, charstring log_msg)
Neels Hofmeyr4f118412020-06-04 15:25:10 +02001007{
1008 // log on TTCN3 log output
1009 log(log_msg);
1010 // log in stderr log
Neels Hofmeyr767548a2020-08-09 20:26:07 +00001011 f_vty_transceive(pt, "logp lglobal notice TTCN3 f_logp(): " & log_msg);
Neels Hofmeyr4f118412020-06-04 15:25:10 +02001012}
1013
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +02001014private function f_sysinfo_seen(integer rsl_idx, RSL_Message rsl) runs on test_CT
1015{
1016 if (rsl_idx >= lengthof(g_system_information)) {
1017 g_system_information[rsl_idx] := SystemInformationConfig_omit
1018 }
1019 f_sysinfo_dec_raw(g_system_information[rsl_idx], rsl);
1020}
1021
1022altstep as_catch_RSL_sysinfo(integer rsl_idx) runs on test_CT {
1023 var ASP_RSL_Unitdata rx_rsl_ud;
1024
1025 /* For handler_mode := false, receiving the RSL bootstrap messages directly on IPA_RSL */
1026 [] IPA_RSL[rsl_idx].receive(tr_ASP_RSL_UD(tr_RSL_NO_BCCH_INFO)) -> value rx_rsl_ud {
1027 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
1028 repeat;
1029 }
1030 [] IPA_RSL[rsl_idx].receive(tr_ASP_RSL_UD(tr_RSL_BCCH_INFO)) -> value rx_rsl_ud {
1031 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
1032 repeat;
1033 }
1034 [] IPA_RSL[rsl_idx].receive(tr_ASP_RSL_UD(tr_RSL_NO_SACCH_FILL)) -> value rx_rsl_ud {
1035 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
1036 repeat;
1037 }
1038 [] IPA_RSL[rsl_idx].receive(tr_ASP_RSL_UD(tr_RSL_SACCH_FILL)) -> value rx_rsl_ud {
1039 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
1040 repeat;
1041 }
1042
1043 /* For handler_mode := true, receiving the RSL bootstrap messages via RSL_Emulation */
1044 [] RSL_CCHAN[rsl_idx].receive(tr_ASP_RSL_UD(tr_RSL_NO_BCCH_INFO)) -> value rx_rsl_ud {
1045 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
1046 repeat;
1047 }
1048 [] RSL_CCHAN[rsl_idx].receive(tr_ASP_RSL_UD(tr_RSL_BCCH_INFO)) -> value rx_rsl_ud {
1049 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
1050 repeat;
1051 }
1052 [] RSL_CCHAN[rsl_idx].receive(tr_ASP_RSL_UD(tr_RSL_NO_SACCH_FILL)) -> value rx_rsl_ud {
1053 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
1054 repeat;
1055 }
1056 [] RSL_CCHAN[rsl_idx].receive(tr_ASP_RSL_UD(tr_RSL_SACCH_FILL)) -> value rx_rsl_ud {
1057 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
1058 repeat;
1059 }
1060}
1061
Neels Hofmeyra460f1f2020-08-09 20:17:03 +00001062/* TODO: use BooleanList from COMMON/src/General_Types.ttcn */
1063private type record of boolean my_BooleanList;
1064
1065private function f_vty_msc_allow_attach(TELNETasp_PT pt, my_BooleanList allow_attach_list)
1066{
Neels Hofmeyr8f576712020-08-12 22:49:53 +00001067 var charstring config := f_vty_transceive_ret(pt, "show running-config");
1068
Neels Hofmeyra460f1f2020-08-09 20:17:03 +00001069 for (var integer msc_nr := 0; msc_nr < sizeof(allow_attach_list); msc_nr := msc_nr+1) {
Neels Hofmeyr8f576712020-08-12 22:49:53 +00001070 if (f_strstr(config, "\nmsc " & int2str(msc_nr) & "\n") < 0) {
1071 /* There is no 'msc N' for this msc_nr in the running config, so don't create an empty msc by
1072 * stepping into that config node. */
1073 log("msc ", msc_nr, " is not configured, skipping");
1074 continue;
1075 }
Neels Hofmeyra460f1f2020-08-09 20:17:03 +00001076 f_vty_enter_cfg_msc(pt, msc_nr);
1077 if (allow_attach_list[msc_nr]) {
1078 /* strict := false: ignore if osmo-bsc does not support this config option (latest build) */
1079 f_vty_transceive(pt, "allow-attach", strict := false);
1080 } else {
1081 f_vty_transceive(pt, "no allow-attach", strict := false);
1082 }
1083 f_vty_transceive(pt, "exit");
1084 f_vty_transceive(pt, "exit");
1085 }
1086}
1087
Harald Welte21b46bd2017-12-17 19:46:32 +01001088/* global initialization function
1089 * \param nr_bts Number of BTSs we should start/bring up
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001090 * \param handler_mode Start an RSL_Emulation_CT component (true) or not (false).
1091 * \param nr_msc Number of virtual MSCs to bring up to connect to osmo-bsc.
1092 */
1093function f_init(integer nr_bts := NUM_BTS, boolean handler_mode := false, boolean allow_osmux := false,
Neels Hofmeyr4fbad7f2020-06-16 00:30:47 +02001094 integer nr_msc := 1, float guard_timeout := 30.0) runs on test_CT {
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001095 var integer bssap_idx;
Harald Welte28d943e2017-11-25 15:00:50 +01001096
Harald Welteae026692017-12-09 01:03:01 +01001097 if (g_initialized) {
1098 return;
Harald Welte28d943e2017-11-25 15:00:50 +01001099 }
Harald Welteae026692017-12-09 01:03:01 +01001100 g_initialized := true;
1101
Neels Hofmeyr4fbad7f2020-06-16 00:30:47 +02001102 T_guard.start(guard_timeout);
Daniel Willmanne68f9272018-11-27 15:15:28 +01001103 activate(as_Tguard());
1104
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02001105 f_init_vty("VirtMSC");
Pau Espin Pedrol58cf6822019-05-28 18:11:33 +02001106 if (mp_enable_osmux_test) {
1107 f_vty_allow_osmux(allow_osmux);
1108 }
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02001109
Neels Hofmeyra460f1f2020-08-09 20:17:03 +00001110 var my_BooleanList allow_attach := { false, false, false };
Daniel Willmannebdecc02020-08-12 15:30:17 +02001111 f_init_statsd("VirtMSC", vc_STATSD, mp_test_ip, mp_bsc_statsd_port);
1112
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001113 for (bssap_idx := 0; bssap_idx < nr_msc; bssap_idx := bssap_idx+1) {
Neels Hofmeyra460f1f2020-08-09 20:17:03 +00001114 allow_attach[bssap_idx] := true;
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001115 /* Call a function of our 'parent component' RAN_Adapter_CT to start the
1116 * MSC-side BSSAP emulation */
1117 if (handler_mode) {
1118 var RanOps ranops := MSC_RanOps;
1119 ranops.use_osmux := g_osmux_enabled;
1120 f_ran_adapter_init(g_bssap[bssap_idx], mp_bssap_cfg[bssap_idx], "VirtMSC", ranops);
1121 connect(self:SCCPLITE_IPA_CTRL, g_bssap[bssap_idx].vc_RAN:CTRL_CLIENT);
1122 f_ran_adapter_start(g_bssap[bssap_idx]);
1123 } else {
1124 f_ran_adapter_init(g_bssap[bssap_idx], mp_bssap_cfg[bssap_idx], "VirtMSC", omit);
1125 connect(self:BSSAP, g_bssap[bssap_idx].vc_SCCP:SCCP_SP_PORT);
1126 f_ran_adapter_start(g_bssap[bssap_idx]);
1127 f_legacy_bssap_reset();
1128 }
Harald Welte67089ee2018-01-17 22:19:03 +01001129 }
Harald Welted5833a82018-05-27 16:52:56 +02001130
Neels Hofmeyrcfe44062020-10-15 02:28:08 +02001131 if (mp_enable_lcs_tests) {
1132 if (handler_mode) {
1133 f_bssap_le_adapter_init(g_bssap_le, mp_bssap_le_cfg, "VirtSMLC", SMLC_BssapLeOps);
1134 } else {
1135 f_bssap_le_adapter_init(g_bssap_le, mp_bssap_le_cfg, "VirtSMLC", omit);
1136 connect(self:BSSAP_LE, g_bssap_le.vc_SCCP:SCCP_SP_PORT);
1137 }
1138 f_bssap_le_adapter_start(g_bssap_le);
Harald Welte47cd0e32020-08-21 12:39:11 +02001139 }
Harald Welte47cd0e32020-08-21 12:39:11 +02001140
Neels Hofmeyra460f1f2020-08-09 20:17:03 +00001141 /* start the test with exactly all enabled MSCs allowed to attach */
1142 f_vty_msc_allow_attach(BSCVTY, allow_attach);
1143
Pau Espin Pedrol9a5b8ff2021-01-04 19:01:31 +01001144 f_ipa_ctrl_start_client(mp_bsc_ip, mp_bsc_ctrl_port);
Harald Welte28d943e2017-11-25 15:00:50 +01001145
Daniel Willmann191e0d92018-01-17 12:44:35 +01001146 f_init_mgcp("VirtMSC");
1147
Neels Hofmeyr0b7365b2020-07-04 00:52:34 +02001148 for (var integer i := 0; i < nr_bts; i := i+1) {
1149 f_init_bts(i, handler_mode);
Harald Welte696ddb62017-12-08 14:01:43 +01001150 }
Neels Hofmeyr0b7365b2020-07-04 00:52:34 +02001151}
Harald Welte696ddb62017-12-08 14:01:43 +01001152
Neels Hofmeyr0b7365b2020-07-04 00:52:34 +02001153function f_init_bts(integer bts_idx := 0, boolean handler_mode := false)
1154runs on test_CT {
1155 /* wait until osmo-bts-omldummy has respawned */
1156 f_wait_oml(bts_idx, "degraded", 5.0);
1157
1158 /* start RSL connection */
1159 f_ipa_rsl_start(bts[bts_idx].rsl, mp_bsc_ip, mp_bsc_rsl_port, bts_idx, handler_mode);
1160 /* wait until BSC tells us "connected" */
1161 f_wait_oml(bts_idx, "connected", 5.0);
Harald Welte28d943e2017-11-25 15:00:50 +01001162}
1163
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +02001164function f_init_bts_and_check_sysinfo(integer bts_idx := 0, boolean handler_mode := false,
1165 template SystemInformationConfig expect_si)
1166runs on test_CT {
1167 var default sysinfo := activate(as_catch_RSL_sysinfo(bts_idx));
1168
1169 f_init_bts(bts_idx, handler_mode);
1170
1171 /* Give some time to (hopefully/most likely) collect all system informations from RSL startup.
1172 * We could stop as soon as all expected SI are received, but then we might miss SI that we don't expect and
1173 * that might be sent afterwards. So rather give a generous timeout and be quite sure to catch all SI.
1174 */
1175 f_sleep(5.0);
1176 log("RSL ", bts_idx, " SYSTEM INFORMATION: ", g_system_information[bts_idx]);
1177
1178 deactivate(sysinfo);
1179
1180 if (match(g_system_information[bts_idx], expect_si)) {
1181 setverdict(pass);
1182 } else {
1183 log("RSL ", bts_idx, ": EXPECTED SI: ", expect_si);
1184 log("RSL ", bts_idx, ": GOT SI: ", g_system_information[bts_idx]);
1185 setverdict(fail, "received SI does not match expectations");
1186 return;
1187 }
1188}
1189
Maxd4e56962018-10-31 19:08:25 +01001190/* expect to receive a RSL message matching a specified template on a given BTS / stream */
Harald Welte65e419a2020-08-21 12:38:33 +02001191function 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 +01001192runs on test_CT return RSL_Message {
1193 var ASP_RSL_Unitdata rx_rsl_ud;
1194 timer T := t_secs;
1195
1196 T.start;
1197 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001198 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(t_rx, sid)) -> value rx_rsl_ud {
Harald Welteae026692017-12-09 01:03:01 +01001199 T.stop;
1200 }
1201 [] IPA_RSL[bts_nr].receive { repeat; }
Harald Welteb2917702017-12-10 15:48:52 +01001202 [] T.timeout {
1203 setverdict(fail, "Timeout expecting ", t_rx);
Daniel Willmannafce8662018-07-06 23:11:32 +02001204 mtc.stop;
Harald Welteb2917702017-12-10 15:48:52 +01001205 }
Harald Welteae026692017-12-09 01:03:01 +01001206 }
1207 return rx_rsl_ud.rsl;
1208}
1209
Harald Welte21b46bd2017-12-17 19:46:32 +01001210/* helper function to transmit RSL on a given BTS/stream */
Harald Welte65e419a2020-08-21 12:38:33 +02001211function 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 +01001212runs on test_CT {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001213 IPA_RSL[bts_nr].send(ts_ASP_RSL_UD(t_tx, sid));
Harald Welteae026692017-12-09 01:03:01 +01001214}
1215
1216
Harald Welte4003d112017-12-09 22:35:39 +01001217/* verify we get a CHAN_ACT after CHAN RQD */
Harald Welteae026692017-12-09 01:03:01 +01001218testcase TC_chan_act_noreply() runs on test_CT {
1219 var BSSAP_N_UNITDATA_ind ud_ind;
Harald Welte930d0a72018-03-22 22:08:40 +01001220 var RSL_Message rsl_unused;
Harald Welte28d943e2017-11-25 15:00:50 +01001221
Harald Welte89d42e82017-12-17 16:42:41 +01001222 f_init(1);
Harald Welte28d943e2017-11-25 15:00:50 +01001223
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001224 IPA_RSL[0].send(ts_ASP_RSL_UD(ts_RSL_CHAN_RQD('23'O, 23)));
Harald Welte930d0a72018-03-22 22:08:40 +01001225 rsl_unused := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001226 f_shutdown_helper();
Harald Welte28d943e2017-11-25 15:00:50 +01001227}
1228
Harald Welte4003d112017-12-09 22:35:39 +01001229/* verify if the "chreq:total" counter increments as expected */
1230testcase TC_chan_act_counter() runs on test_CT {
1231 var BSSAP_N_UNITDATA_ind ud_ind;
1232 var integer chreq_total;
Harald Welte930d0a72018-03-22 22:08:40 +01001233 var RSL_Message rsl_unused;
Harald Welte4003d112017-12-09 22:35:39 +01001234
Harald Welte89d42e82017-12-17 16:42:41 +01001235 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +01001236
1237 chreq_total := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total");
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001238 IPA_RSL[0].send(ts_ASP_RSL_UD(ts_RSL_CHAN_RQD('23'O, 23)));
Harald Welte930d0a72018-03-22 22:08:40 +01001239 rsl_unused := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
Harald Welte4003d112017-12-09 22:35:39 +01001240 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total", chreq_total+1);
1241
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001242 f_shutdown_helper();
Harald Welte4003d112017-12-09 22:35:39 +01001243}
1244
Harald Welteae026692017-12-09 01:03:01 +01001245/* CHAN RQD -> CHAN ACT -> CHAN ACT ACK -> RF CHAN REL */
Philipp Maier9c60a622020-07-09 15:08:46 +02001246private function f_TC_chan_act_ack_noest(OCT1 ra := '23'O) runs on test_CT {
Harald Welteae026692017-12-09 01:03:01 +01001247 var RSL_Message rx_rsl;
1248
Harald Welteae026692017-12-09 01:03:01 +01001249 /* Send CHAN RQD and wait for allocation; acknowledge it */
Philipp Maier9c60a622020-07-09 15:08:46 +02001250 var RslChannelNr chan_nr := f_chreq_act_ack(ra);
Harald Welteae026692017-12-09 01:03:01 +01001251
1252 /* expect BSC to disable the channel again if there's no RLL EST IND */
1253 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), T3101_MAX);
1254
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001255 f_shutdown_helper();
Harald Welteae026692017-12-09 01:03:01 +01001256}
1257
Philipp Maier9c60a622020-07-09 15:08:46 +02001258/* Normal variant */
1259testcase TC_chan_act_ack_noest() runs on test_CT {
Philipp Maieraf58db22020-08-12 17:24:40 +02001260 f_init(1);
Philipp Maier9c60a622020-07-09 15:08:46 +02001261 f_TC_chan_act_ack_noest();
1262}
1263
1264/* Emergency call variant */
1265testcase TC_chan_act_ack_noest_emerg() runs on test_CT {
1266 /* See also: 3GPP TS 04.08, Table 9.9, ra=101xxxxx */
Philipp Maieraf58db22020-08-12 17:24:40 +02001267 f_init(1);
1268 f_vty_allow_emerg_bts(true, 0);
Philipp Maier9c60a622020-07-09 15:08:46 +02001269 f_TC_chan_act_ack_noest(ra := 'A5'O);
1270}
1271
Philipp Maier606f07d2020-08-12 17:21:58 +02001272/* Emergency call variant, but emergency calls are not allowed */
1273testcase TC_chan_rqd_emerg_deny() runs on test_CT {
1274 /* See also: 3GPP TS 04.08, Table 9.9, ra=101xxxxx */
1275
1276 var RSL_Message rx_rsl;
1277 var GsmRrMessage rr;
1278
1279 f_init(1);
1280 f_vty_allow_emerg_bts(false, 0);
1281
1282 IPA_RSL[0].clear;
1283 f_ipa_tx(0, ts_RSL_CHAN_RQD('A5'O, 23));
1284
1285 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeC(RSL_MT_IMMEDIATE_ASSIGN_CMD));
1286 rr := dec_GsmRrMessage(rx_rsl.ies[1].body.full_imm_ass_info.payload);
1287 if (rr.header.message_type == IMMEDIATE_ASSIGNMENT_REJECT) {
1288 setverdict(pass);
1289 } else {
1290 setverdict(fail, "immediate assignment not rejected");
1291 }
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01001292
1293 f_shutdown_helper();
Philipp Maier606f07d2020-08-12 17:21:58 +02001294}
1295
Harald Welteae026692017-12-09 01:03:01 +01001296/* Test behavior if MSC never answers to CR */
1297testcase TC_chan_act_ack_est_ind_noreply() runs on test_CT {
Harald Weltef77aef62018-01-28 15:35:42 +01001298 var RslLinkId main_dcch := valueof(ts_RslLinkID_DCCH(0));
1299 var IpaStreamId sid := IPAC_PROTO_RSL_TRX0;
Harald Welteae026692017-12-09 01:03:01 +01001300 var RSL_Message rx_rsl;
Harald Weltef77aef62018-01-28 15:35:42 +01001301 var ASP_RSL_Unitdata rx_rsl_ud;
Harald Welteae026692017-12-09 01:03:01 +01001302
Harald Welte89d42e82017-12-17 16:42:41 +01001303 f_init(1);
Harald Welteae026692017-12-09 01:03:01 +01001304
1305 /* Send CHAN RQD and wait for allocation; acknowledge it */
Harald Welted6939652017-12-13 21:02:46 +01001306 var RslChannelNr chan_nr := f_chreq_act_ack();
Harald Welteae026692017-12-09 01:03:01 +01001307
1308 var octetstring l3 := '00010203040506'O
1309 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
1310
1311 BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3)));
1312
1313 /* expect BSC to disable the channel again if there's no response from MSC */
Harald Weltef77aef62018-01-28 15:35:42 +01001314 /* MS waits 20s (T3210) at LU; 10s (T3230) at CM SERV REQ and 5s (T3220) AT detach */
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001315 f_expect_chan_rel(0, chan_nr, expect_rll_rel_req := false);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001316 f_shutdown_helper();
Harald Welteae026692017-12-09 01:03:01 +01001317}
1318
1319/* Test behavior if MSC answers with CREF to CR */
1320testcase TC_chan_act_ack_est_ind_refused() runs on test_CT {
1321 var BSSAP_N_CONNECT_ind rx_c_ind;
1322 var RSL_Message rx_rsl;
1323
Harald Welte89d42e82017-12-17 16:42:41 +01001324 f_init(1);
Harald Welteae026692017-12-09 01:03:01 +01001325
1326 /* Send CHAN RQD and wait for allocation; acknowledge it */
Harald Welted6939652017-12-13 21:02:46 +01001327 var RslChannelNr chan_nr := f_chreq_act_ack();
Harald Welteae026692017-12-09 01:03:01 +01001328
1329 var octetstring l3 := '00010203040506'O
1330 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
1331
1332 BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) -> value rx_c_ind;
1333 BSSAP.send(ts_BSSAP_DISC_req(rx_c_ind.connectionId, 0));
1334
1335 /* expect BSC to disable the channel */
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001336 f_expect_chan_rel(0, chan_nr, expect_rll_rel_req := false);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001337 f_shutdown_helper();
Harald Welteae026692017-12-09 01:03:01 +01001338}
1339
Harald Welte618ef642017-12-14 14:58:20 +01001340/* CHAN RQD -> CHAN ACT -> CHAN ACT NACK -> RF CHAN REL */
1341testcase TC_chan_act_nack() runs on test_CT {
1342 var RSL_Message rx_rsl;
1343 var integer chact_nack;
1344
Harald Welte89d42e82017-12-17 16:42:41 +01001345 f_init(1);
Harald Welte618ef642017-12-14 14:58:20 +01001346
1347 chact_nack := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chan_act:nack");
1348
1349 f_ipa_tx(0, ts_RSL_CHAN_RQD('33'O, 33));
1350 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
1351 var RslChannelNr chan_nr := rx_rsl.ies[0].body.chan_nr;
1352
1353 f_ipa_tx(0, ts_RSL_CHAN_ACT_NACK(chan_nr, RSL_ERR_EQUIPMENT_FAIL));
1354
1355 /* wait for some time to hope the NACK arrives before the CTRL GET below */
1356 f_sleep(0.5);
1357
1358 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chan_act:nack", chact_nack+1);
1359
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001360 f_shutdown_helper();
Harald Welte618ef642017-12-14 14:58:20 +01001361}
1362
Harald Welte799c97b2017-12-14 17:50:30 +01001363/* Test for channel exhaustion due to RACH overload */
1364testcase TC_chan_exhaustion() runs on test_CT {
1365 var ASP_RSL_Unitdata rsl_ud;
1366 var integer i;
1367 var integer chreq_total, chreq_nochan;
1368
Harald Welte89d42e82017-12-17 16:42:41 +01001369 f_init(1);
Harald Welte799c97b2017-12-14 17:50:30 +01001370
1371 chreq_total := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total");
1372 chreq_nochan := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:no_channel");
1373
Pau Espin Pedrolfe200d72018-12-10 12:41:04 +01001374 /* GSM 04.08 Table 9.9a:
1375 * RA = '33'O -> Establishment cause = 0011xxxx (MS dual rate capable and asks for "TCH/H or TCH/F").
1376 * With current setup, expect 4xSDCCH + 4xTCH/F + 1xTCH/H to succeed */
Philipp Maiercb6cc482018-03-26 13:08:00 +02001377 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 +01001378 var RslChannelNr chan_nr := f_chreq_act_ack('33'O, i);
Harald Welte799c97b2017-12-14 17:50:30 +01001379 }
1380
1381 IPA_RSL[0].clear;
1382
Harald Weltedd8cbf32018-01-28 12:07:52 +01001383 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total",
Philipp Maiercb6cc482018-03-26 13:08:00 +02001384 chreq_total + NUM_TCHF_PER_BTS + NUM_TCHH_PER_BTS + NUM_SDCCH_PER_BTS);
Harald Welte799c97b2017-12-14 17:50:30 +01001385
1386 /* now expect additional channel activations to fail */
1387 f_ipa_tx(0, ts_RSL_CHAN_RQD('42'O, 42));
1388
1389 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001390 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV))) {
Harald Welte799c97b2017-12-14 17:50:30 +01001391 setverdict(fail, "Received CHAN ACT ACK without resources?!?");
1392 }
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001393 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_IMM_ASSIGN(?))) -> value rsl_ud {
Harald Welte799c97b2017-12-14 17:50:30 +01001394 var GsmRrMessage rr;
1395 /* match on IMM ASS REJ */
1396 rr := dec_GsmRrMessage(rsl_ud.rsl.ies[1].body.full_imm_ass_info.payload);
1397 if (rr.header.message_type == IMMEDIATE_ASSIGNMENT_REJECT) {
1398 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total",
Philipp Maiercb6cc482018-03-26 13:08:00 +02001399 chreq_total + NUM_TCHF_PER_BTS + NUM_TCHH_PER_BTS + NUM_SDCCH_PER_BTS+1);
Harald Welte799c97b2017-12-14 17:50:30 +01001400 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:no_channel",
1401 chreq_nochan+1);
1402 setverdict(pass);
1403 } else {
1404 repeat;
1405 }
1406 }
1407 [] IPA_RSL[0].receive { repeat; }
1408 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001409 f_shutdown_helper();
Harald Welte799c97b2017-12-14 17:50:30 +01001410}
1411
Vadim Yanitskiy1ff1fdf2018-11-27 01:32:57 +07001412/* Test channel deactivation due to silence from MS */
1413testcase TC_chan_deact_silence() runs on test_CT {
1414 var RslChannelNr chan_nr;
1415
1416 f_init(1);
1417
1418 /* Request for a dedicated channel */
1419 chan_nr := f_chreq_act_ack('23'O);
1420
1421 /* Wait some time until the channel is released */
1422 f_sleep(2.0);
1423
1424 /* Expect CHANnel RELease */
1425 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001426 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL))) {
Vadim Yanitskiy1ff1fdf2018-11-27 01:32:57 +07001427 log("Received CHANnel RELease");
1428 setverdict(pass);
1429 }
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001430 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_IMM_ASSIGN(?))) {
Vadim Yanitskiy1ff1fdf2018-11-27 01:32:57 +07001431 /* See OS#3709, OsmoBSC should not send Immediate
1432 * Assignment Reject since a dedicated channel was
1433 * already allocated, and Immediate Assignment was
1434 * already sent. */
1435 setverdict(fail, "Unexpected Immediate Assignment!");
1436 }
1437 [] IPA_RSL[0].receive {
1438 setverdict(fail, "Unexpected RSL message!");
1439 }
1440 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001441 f_shutdown_helper();
Vadim Yanitskiy1ff1fdf2018-11-27 01:32:57 +07001442}
1443
Harald Weltecfe2c962017-12-15 12:09:32 +01001444/***********************************************************************
1445 * Assignment Testing
1446 ***********************************************************************/
1447
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02001448/* Verify that the BSC refuses any BSSAP connection from the MSC (They are all BSC->MSC direction,
1449 * except for the inter-BSC handover, MT side) */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001450testcase TC_outbound_connect(integer bssap_idx := 0) runs on test_CT {
Harald Welte89d42e82017-12-17 16:42:41 +01001451 f_init(1);
Harald Weltecfe2c962017-12-15 12:09:32 +01001452
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001453 BSSAP.send(ts_BSSAP_CONNECT_req(g_bssap[bssap_idx].sccp_addr_peer, g_bssap[bssap_idx].sccp_addr_own,
1454 2342, ts_BSSMAP_AssignmentReq));
Harald Weltecfe2c962017-12-15 12:09:32 +01001455 BSSAP.receive(tr_BSSAP_DISC_ind(2342, ?, ?));
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001456 f_shutdown_helper();
Harald Weltecfe2c962017-12-15 12:09:32 +01001457}
1458
Harald Welte16a4adf2017-12-14 18:54:01 +01001459/* Test behavior if MSC answers with CREF to CR */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001460testcase TC_assignment_cic_only(integer bssap_idx := 0) runs on test_CT {
Harald Welte16a4adf2017-12-14 18:54:01 +01001461 var BSSAP_N_CONNECT_ind rx_c_ind;
1462 var RSL_Message rx_rsl;
1463 var DchanTuple dt;
1464
Harald Welte89d42e82017-12-17 16:42:41 +01001465 f_init(1);
Harald Welte16a4adf2017-12-14 18:54:01 +01001466
1467 dt := f_est_dchan('23'O, 23, '00000000'O);
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001468 if (mp_bssap_cfg[bssap_idx].transport == BSSAP_TRANSPORT_AoIP) {
Harald Welte17b27da2018-05-25 20:33:53 +02001469 /* send assignment without AoIP IEs */
1470 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_AssignmentReq(ts_BSSMAP_IE_CIC(0, 1))));
1471 } else {
1472 /* Send assignmetn without CIC in IPA case */
1473 var BSSMAP_IE_AoIP_TransportLayerAddress tla :=
1474 valueof(ts_BSSMAP_IE_AoIP_TLA4('01020304'O, 2342));
1475 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_AssignmentReq(omit, tla)));
1476 }
Harald Welte16a4adf2017-12-14 18:54:01 +01001477 alt {
1478 [] BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_AssignmentComplete)) {
1479 setverdict(fail, "AoIP BSC cannot accept ASSIGNMENT without AoIP Transport IE");
1480 }
Harald Welte235ebf12017-12-15 14:18:16 +01001481 /* TODO: Actually expect GSM0808_CAUSE_REQ_A_IF_TYPE_NOT_SUPP */
Harald Welte16a4adf2017-12-14 18:54:01 +01001482 [] BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_AssignmentFail)) {
1483 setverdict(pass);
1484 }
1485 [] BSSAP.receive { repeat; }
1486 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001487 f_shutdown_helper();
Harald Welte16a4adf2017-12-14 18:54:01 +01001488}
1489
Harald Welteed848512018-05-24 22:27:58 +02001490/* generate an assignment request for either AoIP or SCCPlite */
Pau Espin Pedrol07866632020-09-03 19:10:55 +02001491function 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 +02001492 var PDU_BSSAP ass_cmd;
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02001493 var BSSMAP_IE_Osmo_OsmuxCID osmux_cid := valueof(ts_OsmuxCID(0));
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001494 if (mp_bssap_cfg[bssap_idx].transport == BSSAP_TRANSPORT_AoIP) {
Harald Welteed848512018-05-24 22:27:58 +02001495 var BSSMAP_IE_AoIP_TransportLayerAddress tla :=
Pau Espin Pedrol07866632020-09-03 19:10:55 +02001496 valueof(f_ts_BSSMAP_IE_AoIP_TLA(aoip_tla, 2342));
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02001497 if (osmux_enabled) {
1498 ass_cmd := valueof(ts_BSSMAP_AssignmentReq(omit, tla, osmux_cid));
1499 } else {
1500 ass_cmd := valueof(ts_BSSMAP_AssignmentReq(omit, tla));
1501 }
Harald Welteed848512018-05-24 22:27:58 +02001502 } else {
1503 var BSSMAP_IE_CircuitIdentityCode cic := valueof(ts_BSSMAP_IE_CIC(0,1));
Pau Espin Pedrol096d73d2019-06-06 12:49:17 +02001504 ass_cmd := valueof(ts_BSSMAP_AssignmentReq(cic, omit));
Harald Welteed848512018-05-24 22:27:58 +02001505 }
1506 return ass_cmd;
1507}
1508
Pau Espin Pedrolc08d5522021-04-16 15:40:38 +02001509function f_gen_handover_req(integer bssap_idx := 0, charstring aoip_tla := "1.2.3.4",
Neels Hofmeyr8ebf19c2021-06-21 05:24:01 +02001510 template (omit) BSSMAP_oldToNewBSSIEs oldToNewBSSIEs := omit,
1511 template (omit) TestHdlrEncrParams enc := omit) return PDU_BSSAP {
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01001512 var PDU_BSSAP ho_req;
Neels Hofmeyr8ebf19c2021-06-21 05:24:01 +02001513
1514 var BSSMAP_IE_EncryptionInformation encryptionInformation :=
1515 valueof(ts_BSSMAP_IE_EncrInfo('0000000000000000'O,'01'O));
1516 var template BSSMAP_IE_ChosenEncryptionAlgorithm chosenEncryptionAlgorithm := omit;
1517 var template BSSMAP_IE_KC128 kc128 := omit;
1518 if (ispresent(enc)) {
1519 var TestHdlrEncrParams v_enc := valueof(enc);
1520 encryptionInformation := valueof(ts_BSSMAP_IE_EncrInfo(v_enc.enc_key, v_enc.enc_alg));
1521 chosenEncryptionAlgorithm := valueof(
1522 ts_BSSMAP_IE_ChosenEncryptionAlgorithm(int2oct(enum2int(
Oliver Smith598e1ed2021-07-09 10:28:40 +02001523 f_cipher_mode_bssmap_to_rsl(v_enc.enc_alg)), 1)));
Neels Hofmeyr8ebf19c2021-06-21 05:24:01 +02001524 if (ispresent(v_enc.enc_kc128)) {
1525 kc128 := ts_BSSMAP_IE_Kc128(v_enc.enc_kc128);
1526 }
1527 }
1528
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001529 if (mp_bssap_cfg[bssap_idx].transport == BSSAP_TRANSPORT_AoIP) {
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01001530 var BSSMAP_IE_AoIP_TransportLayerAddress tla :=
Pau Espin Pedrol07866632020-09-03 19:10:55 +02001531 valueof(f_ts_BSSMAP_IE_AoIP_TLA(aoip_tla, 2342));
Neels Hofmeyr8ebf19c2021-06-21 05:24:01 +02001532 ho_req := valueof(ts_BSSMAP_HandoverRequest(omit, tla, oldToNewBSSIEs := oldToNewBSSIEs,
1533 encryptionInformation := encryptionInformation,
1534 chosenEncryptionAlgorithm := chosenEncryptionAlgorithm,
1535 kC128 := kc128));
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01001536 } else {
1537 var BSSMAP_IE_CircuitIdentityCode cic := valueof(ts_BSSMAP_IE_CIC(0,1));
Neels Hofmeyr8ebf19c2021-06-21 05:24:01 +02001538 ho_req := valueof(ts_BSSMAP_HandoverRequest(cic, omit, oldToNewBSSIEs := oldToNewBSSIEs,
1539 encryptionInformation := encryptionInformation,
1540 chosenEncryptionAlgorithm := chosenEncryptionAlgorithm,
1541 kC128 := kc128));
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01001542 }
1543 return ho_req;
1544}
1545
Harald Welteed848512018-05-24 22:27:58 +02001546/* generate an assignment complete template for either AoIP or SCCPlite */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001547function f_gen_exp_compl(boolean expect_osmux := false, integer bssap_idx := 0) return template PDU_BSSAP {
Harald Welteed848512018-05-24 22:27:58 +02001548 var template PDU_BSSAP exp_compl;
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02001549 var BSSMAP_IE_Osmo_OsmuxCID osmux_cid := valueof(ts_OsmuxCID(0));
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001550 if (mp_bssap_cfg[bssap_idx].transport == BSSAP_TRANSPORT_AoIP) {
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02001551 if (expect_osmux) {
1552 exp_compl := tr_BSSMAP_AssignmentComplete(omit, ?, osmux_cid);
1553 } else {
1554 exp_compl := tr_BSSMAP_AssignmentComplete(omit, ?, omit);
1555 }
Harald Welteed848512018-05-24 22:27:58 +02001556 } else {
1557 /* CIC is optional "*" as the MSC allocated it */
Pau Espin Pedrol096d73d2019-06-06 12:49:17 +02001558 exp_compl := tr_BSSMAP_AssignmentComplete(*, omit);
Harald Welteed848512018-05-24 22:27:58 +02001559 }
1560 return exp_compl;
1561}
1562
Harald Welte235ebf12017-12-15 14:18:16 +01001563/* Run everything required up to sending a caller-specified assignment command and expect response */
1564function f_assignment_exp(PDU_BSSAP ass_cmd, template PDU_BSSAP exp, charstring fail_text)
1565runs on test_CT {
1566 var BSSAP_N_CONNECT_ind rx_c_ind;
1567 var RSL_Message rx_rsl;
1568 var DchanTuple dt;
1569
Harald Welte89d42e82017-12-17 16:42:41 +01001570 f_init(1);
Harald Welte235ebf12017-12-15 14:18:16 +01001571
1572 dt := f_est_dchan('23'O, 23, '00000000'O);
1573 /* send assignment without AoIP IEs */
1574 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ass_cmd));
1575 alt {
1576 [] BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_AssignmentComplete)) {
1577 if (ischosen(exp.pdu.bssmap.assignmentComplete)) {
1578 setverdict(pass);
1579 } else {
1580 setverdict(fail, fail_text);
1581 }
1582 }
1583 [] BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_AssignmentFail)) {
1584 if (ischosen(exp.pdu.bssmap.assignmentFailure)) {
1585 setverdict(pass);
1586 } else {
1587 setverdict(fail, fail_text);
1588 }
1589 }
1590 [] BSSAP.receive { repeat; }
1591 }
1592}
1593testcase TC_assignment_csd() runs on test_CT {
1594 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
Harald Welteed848512018-05-24 22:27:58 +02001595 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte235ebf12017-12-15 14:18:16 +01001596 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeCSD);
1597 //exp_fail.pdu.bssmap.assignmentFailure.cause.causeValue := int2bit(enum2int(GSM0808_CAUSE_REQ_CODEC_TYPE_OR_CONFIG_UNAVAIL), 7);
1598 f_assignment_exp(ass_cmd, exp_fail, "BSC accepted Assignment for CSD");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001599 f_shutdown_helper();
Harald Welte235ebf12017-12-15 14:18:16 +01001600}
1601
1602testcase TC_assignment_ctm() runs on test_CT {
1603 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
Harald Welteed848512018-05-24 22:27:58 +02001604 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte235ebf12017-12-15 14:18:16 +01001605 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeCTM);
1606 //exp_fail.pdu.bssmap.assignmentFailure.cause.causeValue := int2bit(enum2int(GSM0808_CAUSE_REQ_CODEC_TYPE_OR_CONFIG_UNAVAIL), 7);
1607 f_assignment_exp(ass_cmd, exp_fail, "BSC accepted Assignment for Speech+CTM");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001608 f_shutdown_helper();
Harald Welte235ebf12017-12-15 14:18:16 +01001609}
1610
Harald Welte4003d112017-12-09 22:35:39 +01001611type record DchanTuple {
1612 integer sccp_conn_id,
1613 RslChannelNr rsl_chan_nr
Harald Weltea5d2ab22017-12-09 14:21:42 +01001614}
1615
Harald Welted6939652017-12-13 21:02:46 +01001616/* Send CHAN RQD and wait for allocation; acknowledge it */
1617private function f_chreq_act_ack(OCT1 ra := '23'O, GsmFrameNumber fn := 23)
1618runs on test_CT return RslChannelNr {
1619 var RSL_Message rx_rsl;
1620 f_ipa_tx(0, ts_RSL_CHAN_RQD(ra, fn));
1621 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
1622 var RslChannelNr chan_nr := rx_rsl.ies[0].body.chan_nr;
1623 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, fn+10));
Daniel Willmannf4ac4ce2018-08-02 14:06:30 +02001624 rx_rsl := f_exp_ipa_rx(0, tr_RSL_IMM_ASSIGN(0));
Harald Welted6939652017-12-13 21:02:46 +01001625 return chan_nr;
1626}
1627
Harald Welte4003d112017-12-09 22:35:39 +01001628/* helper function to establish a dedicated channel via BTS and MSC */
1629function f_est_dchan(OCT1 ra, GsmFrameNumber fn, octetstring l3)
1630runs on test_CT return DchanTuple {
1631 var BSSAP_N_CONNECT_ind rx_c_ind;
Harald Welte4003d112017-12-09 22:35:39 +01001632 var DchanTuple dt;
Harald Weltea5d2ab22017-12-09 14:21:42 +01001633
Harald Welte4003d112017-12-09 22:35:39 +01001634 /* Send CHAN RQD and wait for allocation; acknowledge it */
Harald Welted6939652017-12-13 21:02:46 +01001635 dt.rsl_chan_nr := f_chreq_act_ack(ra, fn);
Harald Welte4003d112017-12-09 22:35:39 +01001636
1637 f_ipa_tx(0, ts_RSL_EST_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
1638
1639 BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) -> value rx_c_ind;
1640 dt.sccp_conn_id := rx_c_ind.connectionId;
1641 BSSAP.send(ts_BSSAP_CONNECT_res(dt.sccp_conn_id));
1642
1643 return dt;
Harald Weltea5d2ab22017-12-09 14:21:42 +01001644}
1645
Harald Welte641fcbe2018-06-14 10:58:35 +02001646/* expect RF CAN REL from BTS, acknowledge it and clear the MSC side */
1647private function f_exp_chan_rel_and_clear(DchanTuple dt, integer bts_nr := 0) runs on test_CT {
1648 var RSL_Message rx_rsl;
1649 /* expect BSC to disable the channel */
1650 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), T3101_MAX);
1651 /* respond with CHAN REL ACK */
1652 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(dt.rsl_chan_nr));
1653
1654 /* expect Clear Complete from BSC */
1655 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete));
1656
1657 /* MSC disconnects as instructed. */
1658 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
1659}
1660
Harald Welte4003d112017-12-09 22:35:39 +01001661/* Test behavior of channel release after unilateral RLL REL IND (DISC from MS) */
1662testcase TC_chan_rel_rll_rel_ind() runs on test_CT {
Neels Hofmeyr27f64362018-03-12 01:44:00 +01001663 var BSSAP_N_DATA_ind rx_di;
Harald Welte4003d112017-12-09 22:35:39 +01001664 var DchanTuple dt;
Harald Welte96c94412017-12-09 03:12:45 +01001665
Harald Welte89d42e82017-12-17 16:42:41 +01001666 f_init(1);
Harald Welte96c94412017-12-09 03:12:45 +01001667
Harald Welte4003d112017-12-09 22:35:39 +01001668 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1669
1670 /* simulate RLL REL IND */
1671 f_ipa_tx(0, ts_RSL_REL_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0))));
1672
Neels Hofmeyr27f64362018-03-12 01:44:00 +01001673 /* expect Clear Request on MSC side */
1674 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearRequest)) -> value rx_di;
1675
1676 /* Instruct BSC to clear channel */
1677 var BssmapCause cause := bit2int(rx_di.userData.pdu.bssmap.clearRequest.cause.causeValue);
1678 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
1679
Harald Welte4003d112017-12-09 22:35:39 +01001680 /* expect BSC to disable the channel */
Harald Welte641fcbe2018-06-14 10:58:35 +02001681 f_exp_chan_rel_and_clear(dt, 0);
Neels Hofmeyr27f64362018-03-12 01:44:00 +01001682
1683 /* wait for SCCP emulation to do its job */
1684 f_sleep(1.0);
Harald Welte4003d112017-12-09 22:35:39 +01001685
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001686 f_shutdown_helper();
Harald Welte4003d112017-12-09 22:35:39 +01001687}
1688
1689/* Test behavior of channel release after CONN FAIL IND from BTS */
1690testcase TC_chan_rel_conn_fail() runs on test_CT {
1691 var BSSAP_N_DATA_ind rx_di;
Harald Welte4003d112017-12-09 22:35:39 +01001692 var DchanTuple dt;
1693
Harald Welte89d42e82017-12-17 16:42:41 +01001694 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +01001695
1696 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1697
1698 /* simulate CONN FAIL IND */
Harald Weltea8ed9062017-12-14 09:46:01 +01001699 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 +01001700 /* TODO: different cause values? */
1701
Harald Welte4003d112017-12-09 22:35:39 +01001702 /* expect Clear Request from BSC */
1703 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearRequest)) -> value rx_di;
1704
1705 /* Instruct BSC to clear channel */
1706 var BssmapCause cause := bit2int(rx_di.userData.pdu.bssmap.clearRequest.cause.causeValue);
1707 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
1708
Harald Welte6ff76ea2018-01-28 13:08:01 +01001709 /* expect BSC to disable the channel */
Harald Welte641fcbe2018-06-14 10:58:35 +02001710 f_exp_chan_rel_and_clear(dt, 0);
Harald Welte4003d112017-12-09 22:35:39 +01001711
1712 /* wait for SCCP emulation to do its job */
1713 f_sleep(1.0);
1714
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001715 f_shutdown_helper();
Harald Welte4003d112017-12-09 22:35:39 +01001716}
1717
Harald Welte99f3ca02018-06-14 13:40:29 +02001718/* Test behavior of early CONN FAIL IND from BTS (before EST IND!) */
1719/* See also https://www.osmocom.org/issues/3182 */
1720testcase TC_early_conn_fail() runs on test_CT {
1721 var RSL_Message rx_rsl;
1722 var DchanTuple dt;
1723
1724 f_init(1);
1725
1726 /* BTS->BSC: Send CHAN RQD and wait for allocation; acknowledge it */
Harald Weltec46ea3c2020-10-10 18:46:12 +02001727 dt.rsl_chan_nr := f_chreq_act_ack(f_rnd_ra_cs(), 23);
Harald Welte99f3ca02018-06-14 13:40:29 +02001728
1729 /* BTS->BSC: simulate CONN FAIL IND */
1730 f_ipa_tx(0, ts_RSL_CONN_FAIL_IND(dt.rsl_chan_nr, RSL_ERR_RADIO_LINK_FAIL));
1731
1732 /* BTS->BSC: Expect RF channel release from BSC on Abis */
1733 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), 10.0);
1734
1735 /* BTS<-BSC: respond with CHAN REL ACK */
1736 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(dt.rsl_chan_nr));
1737
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001738 f_shutdown_helper();
Harald Welte99f3ca02018-06-14 13:40:29 +02001739}
1740
1741/* Test behavior of late CONN FAIL IND from BTS (ater REL IND!) */
1742/* See also https://www.osmocom.org/issues/3182 */
1743testcase TC_late_conn_fail() runs on test_CT {
1744 var RSL_Message rx_rsl;
1745 var DchanTuple dt;
1746
1747 f_init(1);
1748
1749 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1750
1751 /* BSC<-MSC: Instruct BSC to clear connection */
1752 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(0)));
1753
1754 /* BTS->BSC: expect BSC to deactivate SACCH */
1755 rx_rsl := f_exp_ipa_rx(0, tr_RSL_DEACT_SACCH(dt.rsl_chan_nr));
1756
1757 /* BTS->BSC: simulate a late CONN FAIL IND from BTS */
1758 f_ipa_tx(0, ts_RSL_CONN_FAIL_IND(dt.rsl_chan_nr, RSL_ERR_RADIO_LINK_FAIL));
1759
1760 /* BTS<-BSC: Expect RF channel release from BSC on Abis */
1761 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), 10.0);
1762 /* BTS->BSC: respond with CHAN REL ACK */
1763 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(dt.rsl_chan_nr));
1764
1765 /* BSC->MSC: expect Clear Complete from BSC */
1766 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete));
1767
1768 /* BSC<-MSC: MSC disconnects as requested. */
1769 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
1770
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001771 f_shutdown_helper();
Harald Welte99f3ca02018-06-14 13:40:29 +02001772}
1773
Neels Hofmeyrf44ccd12018-11-05 19:15:23 +01001774function f_expect_chan_rel(integer bts_nr, RslChannelNr rsl_chan_nr,
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001775 boolean expect_deact_sacch := true,
1776 boolean expect_rr_chan_rel := true,
1777 boolean expect_rll_rel_req := true,
Harald Welte99787102019-02-04 10:41:36 +01001778 boolean handle_rll_rel := true,
Pau Espin Pedrol36bd4fa2021-04-15 13:00:24 +02001779 template CellSelIndValue expect_cells := omit,
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02001780 template RR_Cause expect_rr_cause := ?
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001781 ) runs on test_CT {
Harald Welte91d54a52018-01-28 15:35:07 +01001782
1783 var RslLinkId main_dcch := valueof(ts_RslLinkID_DCCH(0));
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001784 var boolean got_deact_sacch := false;
1785 var boolean got_rr_chan_rel := false;
1786 var boolean got_rll_rel_req := false;
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02001787 var ASP_RSL_Unitdata ud;
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02001788 var RSL_IE_Body l3_ie;
1789 var PDU_ML3_NW_MS l3;
1790 var RR_Cause got_cause;
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001791 log("f_expect_chan_rel() expecting: expect_deact_sacch=", expect_deact_sacch, " expect_rr_chan_rel=", expect_rr_chan_rel,
1792 " expect_rll_rel_req=", expect_rll_rel_req);
Harald Welte91d54a52018-01-28 15:35:07 +01001793 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001794 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(tr_RSL_DEACT_SACCH(rsl_chan_nr))) {
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001795 got_deact_sacch := true;
Harald Welte91d54a52018-01-28 15:35:07 +01001796 repeat;
1797 }
Pau Espin Pedrol841b90d2021-04-15 16:42:52 +02001798 [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 +01001799 got_rr_chan_rel := true;
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02001800
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02001801 if (f_rsl_find_ie(ud.rsl, RSL_IE_L3_INFO, l3_ie) == false) {
1802 setverdict(fail, "cannot find L3");
1803 mtc.stop;
1804 }
1805 l3 := dec_PDU_ML3_NW_MS(l3_ie.l3_info.payload);
1806
Pau Espin Pedrol36bd4fa2021-04-15 13:00:24 +02001807 if (not istemplatekind(expect_cells, "omit")) {
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02001808 var CellSelIndValue cells := dec_CellSelIndValue(
1809 l3.msgs.rrm.channelRelease.cellSelectionIndicator.cellSelectionIndicatorValue);
1810
Pau Espin Pedrol36bd4fa2021-04-15 13:00:24 +02001811 log("GOT RR CHANNEL RELEASE WITH CELLS: ", cells);
1812 if (match(cells, expect_cells)) {
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02001813 setverdict(pass);
1814 } else {
Pau Espin Pedrol36bd4fa2021-04-15 13:00:24 +02001815 log("EXPECTED CELLS: ", expect_cells);
1816 setverdict(fail, "Received cells list on RR Channel Release does not match expectations");
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02001817 }
1818 }
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02001819
1820 if (not istemplatekind(expect_rr_cause, "omit")) {
1821 int2enum(oct2int(l3.msgs.rrm.channelRelease.rRCause.valuePart), got_cause);
1822 log("GOT CAUSE CODE: ", l3.msgs.rrm.channelRelease.rRCause.valuePart, " = ", got_cause);
1823 if (match(got_cause, expect_rr_cause)) {
1824 setverdict(pass);
1825 } else {
1826 log("EXPECTED CAUSE CODE: ", expect_rr_cause);
1827 setverdict(fail, "Received RR Channel Release Cause code does not match expectations");
1828 }
1829 }
Harald Welte99787102019-02-04 10:41:36 +01001830 repeat;
1831 }
Pau Espin Pedrol841b90d2021-04-15 16:42:52 +02001832 [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 +01001833 got_rr_chan_rel := true;
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02001834
1835 if (not istemplatekind(expect_rr_cause, "omit")) {
1836 if (f_rsl_find_ie(ud.rsl, RSL_IE_L3_INFO, l3_ie) == false) {
1837 setverdict(fail, "cannot find L3");
1838 mtc.stop;
1839 }
1840 l3 := dec_PDU_ML3_NW_MS(l3_ie.l3_info.payload);
1841
1842 int2enum(oct2int(l3.msgs.rrm.channelRelease.rRCause.valuePart), got_cause);
1843 log("GOT CAUSE CODE: ", l3.msgs.rrm.channelRelease.rRCause.valuePart, " = ", got_cause);
1844 if (match(got_cause, expect_rr_cause)) {
1845 setverdict(pass);
1846 } else {
1847 log("EXPECTED CAUSE CODE: ", expect_rr_cause);
1848 setverdict(fail, "Received RR Channel Release Cause code does not match expectations");
1849 }
1850 }
Neels Hofmeyr211169d2018-11-07 00:37:29 +01001851 repeat;
1852 }
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001853 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(tr_RSL_REL_REQ(rsl_chan_nr, ?))) {
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001854 got_rll_rel_req := true;
Harald Welte91d54a52018-01-28 15:35:07 +01001855 /* FIXME: Why are we getting this for LinkID SACCH? */
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001856 if (handle_rll_rel) {
1857 f_ipa_tx(0, ts_RSL_REL_CONF(rsl_chan_nr, main_dcch));
1858 }
Harald Welte91d54a52018-01-28 15:35:07 +01001859 repeat;
1860 }
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001861 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL))) {
Harald Welte91d54a52018-01-28 15:35:07 +01001862 /* respond with CHAN REL ACK */
1863 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(rsl_chan_nr));
1864 }
1865 /* ignore any user data */
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001866 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(tr_RSL_MsgTypeR(?))) {
Harald Welte91d54a52018-01-28 15:35:07 +01001867 repeat;
1868 }
1869 }
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001870
1871 log("f_expect_chan_rel() summary: got_deact_sacch=", got_deact_sacch, " got_rr_chan_rel=", got_rr_chan_rel,
1872 " got_rll_rel_req=", got_rll_rel_req);
1873
1874 if (expect_deact_sacch != got_deact_sacch) {
1875 setverdict(fail, "f_expect_chan_rel(): expect_deact_sacch=", expect_deact_sacch, " got_deact_sacch=", got_deact_sacch);
1876 }
1877 if (expect_rr_chan_rel != got_rr_chan_rel) {
1878 setverdict(fail, "f_expect_chan_rel(): expect_rr_chan_rel=", expect_rr_chan_rel, " got_rr_chan_rel=", got_rr_chan_rel);
1879 }
1880 if (expect_rll_rel_req != got_rll_rel_req) {
1881 setverdict(fail, "f_expect_chan_rel(): expect_rll_rel_req=", expect_rll_rel_req, " got_rll_rel_req=", got_rll_rel_req);
1882 }
Harald Welte91d54a52018-01-28 15:35:07 +01001883}
1884
Harald Welte4003d112017-12-09 22:35:39 +01001885/* Test behavior of channel release after hard Clear Command from MSC */
1886testcase TC_chan_rel_hard_clear() runs on test_CT {
1887 var BSSAP_N_DATA_ind rx_di;
Harald Welte4003d112017-12-09 22:35:39 +01001888 var DchanTuple dt;
Harald Welte4003d112017-12-09 22:35:39 +01001889
Harald Welte89d42e82017-12-17 16:42:41 +01001890 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +01001891
1892 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1893
1894 /* Instruct BSC to clear channel */
1895 var BssmapCause cause := 0;
1896 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
1897
1898 /* expect Clear Complete from BSC on A */
1899 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete)) {
1900 /* release the SCCP connection */
1901 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
1902 }
1903
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001904 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001905 f_shutdown_helper();
Harald Welte4003d112017-12-09 22:35:39 +01001906}
1907
Pau Espin Pedrol841b90d2021-04-15 16:42:52 +02001908function f_TC_chan_rel_last_eutran_plmn_hard_clear(boolean tx_csfb_ind) runs on test_CT {
1909 var BSSAP_N_DATA_ind rx_di;
1910 var DchanTuple dt;
1911
1912 f_init(1);
1913
1914 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1915 /* Send CommonID with some random PLMN (BSC doesn't take it into account
1916 /* yet when generating the EUTRAN neigh list in RR CHannel Release) */
1917 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_CommonId('001019876543210'H, '323454'O)));
1918
1919 /* Instruct BSC to clear channel */
1920 var BssmapCause cause := 0;
1921 if (tx_csfb_ind) {
1922 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommandCSFB(cause)));
1923 } else {
1924 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
1925 }
1926
1927 /* expect Clear Complete from BSC on A */
1928 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete)) {
1929 /* release the SCCP connection */
1930 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
1931 }
1932
1933 /* 1 neighbor is added by default in osmo-bts.cfg and
1934 SystemInformationConfig_default, use that: */
1935 var template CellSelIndValue exp_cells := f_tr_rr_chan_rel_earfcns(1);
1936
1937 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false, expect_cells := exp_cells);
1938 f_shutdown_helper();
1939}
1940
1941/* Test behavior of RR Channel rRelease after Clear Command without CSFB indicator
1942 from MSC, previously receiving any CommonID containing the "Last Used E-UTRAN
1943 PLMN Id". According to spec (3GPP TS 48.008 sec 3.1.30) that's the bit requesting
1944 EUTRAN neighbor list sent later on by BSC in RR Channel, so receiving CSFB
1945 Indicator or not shouldn't matter at all. */
1946testcase TC_chan_rel_last_eutran_plmn_hard_clear_no_csfb() runs on test_CT {
1947 f_TC_chan_rel_last_eutran_plmn_hard_clear(false);
1948}
1949
1950/* Test behavior of RR Channel rRelease after Clear Command with CSFB indicator from
1951 MSC, previously receiving any CommonID containing the "Last Used E-UTRAN PLMN
1952 Id". According to spec (3GPP TS 48.008 sec 3.1.30) that's the bit requesting
1953 EUTRAN neighbor list sent later on by BSC in RR Channel. */
1954testcase TC_chan_rel_last_eutran_plmn_hard_clear_csfb() runs on test_CT {
1955 f_TC_chan_rel_last_eutran_plmn_hard_clear(true);
1956}
1957
1958/* Test behavior of RR Channel Release after Clear Command with CSFB indicator from
1959 MSC, without receiving any CommonID containing the "Last Used E-UTRAN PLMN
1960 Id". According to spec (TS 48.008 version 16.0.0 Release 16 "3.2.1.21") the
1961 CSFB Indicator should not be used anymore, and hence, there should be no
1962 EUTRAN neighbor list sent by BSC in RR Channel release since no CommonId with
1963 Last Used E-UTRAN PLMN Id" IE was sent for this conn. */
Harald Welte99787102019-02-04 10:41:36 +01001964testcase TC_chan_rel_hard_clear_csfb() runs on test_CT {
1965 var BSSAP_N_DATA_ind rx_di;
1966 var DchanTuple dt;
1967
1968 f_init(1);
1969
1970 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1971
1972 /* Instruct BSC to clear channel */
1973 var BssmapCause cause := 0;
1974 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommandCSFB(cause)));
1975
1976 /* expect Clear Complete from BSC on A */
1977 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete)) {
1978 /* release the SCCP connection */
1979 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
1980 }
1981
Pau Espin Pedrol841b90d2021-04-15 16:42:52 +02001982 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001983 f_shutdown_helper();
Harald Welte99787102019-02-04 10:41:36 +01001984}
1985
Harald Welted8c36cd2017-12-09 23:05:31 +01001986/* Test behavior of channel release after hard RLSD from MSC */
1987testcase TC_chan_rel_hard_rlsd() runs on test_CT {
Harald Welted8c36cd2017-12-09 23:05:31 +01001988 var DchanTuple dt;
Harald Welted8c36cd2017-12-09 23:05:31 +01001989
Harald Welte89d42e82017-12-17 16:42:41 +01001990 f_init(1);
Harald Welted8c36cd2017-12-09 23:05:31 +01001991
1992 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1993
1994 /* release the SCCP connection */
1995 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
1996
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001997 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001998 f_shutdown_helper();
Harald Welted8c36cd2017-12-09 23:05:31 +01001999}
2000
Harald Welte550daf92018-06-11 19:22:13 +02002001/* Test behavior of channel release after hard RLSD from MSC and MS is not responding to RLL REL REQ */
2002testcase TC_chan_rel_hard_rlsd_ms_dead() runs on test_CT {
2003 var DchanTuple dt;
2004
2005 f_init(1);
2006
2007 dt := f_est_dchan('23'O, 23, '00010203040506'O);
2008
2009 /* release the SCCP connection */
2010 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
2011
Neels Hofmeyra5302c82018-11-04 23:09:58 +01002012 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002013 f_shutdown_helper();
Harald Welte550daf92018-06-11 19:22:13 +02002014}
2015
Harald Welte85804d42017-12-10 14:11:58 +01002016/* Test behavior of channel release after BSSMAP RESET from MSC */
2017testcase TC_chan_rel_a_reset() runs on test_CT {
Harald Welte85804d42017-12-10 14:11:58 +01002018 var DchanTuple dt;
Harald Welte85804d42017-12-10 14:11:58 +01002019
Harald Welte89d42e82017-12-17 16:42:41 +01002020 f_init(1);
Harald Welte85804d42017-12-10 14:11:58 +01002021
2022 dt := f_est_dchan('23'O, 23, '00010203040506'O);
2023
2024 /* Clear the queue, it might still contain stuff like IMMEDIATE ASSIGN */
2025 IPA_RSL[0].clear;
2026
2027 /* perform BSSAP RESET, expect RESET ACK and DISC.ind on connection */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02002028 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 +01002029 interleave {
Neels Hofmeyrf246a922020-05-13 02:27:10 +02002030 [] 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 +01002031 [] BSSAP.receive(tr_BSSAP_DISC_ind(dt.sccp_conn_id, ?, ?)) { }
2032 }
2033
Neels Hofmeyra5302c82018-11-04 23:09:58 +01002034 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002035 f_shutdown_helper();
Harald Welte85804d42017-12-10 14:11:58 +01002036}
2037
Pau Espin Pedrolc675b612020-01-09 19:55:40 +01002038/* Verify T(iar) triggers and releases the channel */
2039testcase TC_chan_rel_sccp_tiar_timeout() runs on test_CT {
2040 var DchanTuple dt;
2041
2042 /* Set T(iar) in BSC low enough that it will trigger before other side
2043 has time to keep alive with a T(ias). Keep recommended ratio of
2044 T(iar) >= T(ias)*2 */
2045 g_bsc_sccp_timer_ias := 2;
2046 g_bsc_sccp_timer_iar := 5;
2047
2048 f_init(1);
2049
2050 dt := f_est_dchan('23'O, 23, '00010203040506'O);
2051 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002052 f_shutdown_helper();
Pau Espin Pedrolc675b612020-01-09 19:55:40 +01002053}
2054
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02002055private function f_tc_chan_rel_rr_cause(myBSSMAP_Cause clear_cmd_cause, template RR_Cause expect_rr_cause)
2056runs on test_CT
2057{
2058 var DchanTuple dt;
2059
2060 dt := f_est_dchan('23'O, 23, '00010203040506'O);
2061 var BssmapCause cause := 0;
2062 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(enum2int(clear_cmd_cause))));
2063 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete)) {
2064 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
2065 }
2066
2067 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 +02002068}
2069
2070/* Test that Clear Command cause codes affect the RR Channel Release cause code */
2071testcase TC_chan_rel_rr_cause() runs on test_CT {
2072 f_init(1);
2073
2074 f_tc_chan_rel_rr_cause(GSM0808_CAUSE_CALL_CONTROL, GSM48_RR_CAUSE_NORMAL);
2075 f_tc_chan_rel_rr_cause(GSM0808_CAUSE_HANDOVER_SUCCESSFUL, GSM48_RR_CAUSE_NORMAL);
2076 f_tc_chan_rel_rr_cause(GSM0808_CAUSE_PREEMPTION, GSM48_RR_CAUSE_PREMPTIVE_REL);
2077 f_tc_chan_rel_rr_cause(GSM0808_CAUSE_RADIO_INTERFACE_MESSAGE_FAILURE, GSM48_RR_CAUSE_PROT_ERROR_UNSPC);
2078 f_tc_chan_rel_rr_cause(GSM0808_CAUSE_RADIO_INTERFACE_FAILURE, GSM48_RR_CAUSE_ABNORMAL_UNSPEC);
2079 f_tc_chan_rel_rr_cause(GSM0808_CAUSE_EQUIPMENT_FAILURE, GSM48_RR_CAUSE_ABNORMAL_UNSPEC);
Vadim Yanitskiye18aebb2021-01-03 13:10:43 +01002080
2081 f_shutdown_helper();
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02002082}
2083
Harald Welte5cd20ed2017-12-13 21:03:20 +01002084/* Test behavior if RSL EST IND for non-active channel */
2085testcase TC_rll_est_ind_inact_lchan() runs on test_CT {
2086 timer T := 2.0;
2087
Harald Welte89d42e82017-12-17 16:42:41 +01002088 f_init(1);
Harald Welte5cd20ed2017-12-13 21:03:20 +01002089
2090 var octetstring l3 := '00010203040506'O;
2091 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(6));
2092 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
2093
2094 T.start;
2095 alt {
2096 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) {
2097 setverdict(fail, "MSC received COMPL L3 for non-active lchan");
2098 }
2099 [] BSSAP.receive {}
2100 [] IPA_RSL[0].receive {}
2101 [] T.timeout {}
2102 }
2103
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002104 f_shutdown_helper();
Harald Welte5cd20ed2017-12-13 21:03:20 +01002105}
2106
2107/* Test behavior if RSL EST IND for invalid SAPI */
2108testcase TC_rll_est_ind_inval_sapi1() runs on test_CT {
2109 var RslChannelNr chan_nr;
2110
Harald Welte89d42e82017-12-17 16:42:41 +01002111 f_init(1);
Harald Welte5cd20ed2017-12-13 21:03:20 +01002112
2113 chan_nr := f_chreq_act_ack()
2114
2115 var octetstring l3 := '00010203040506'O;
2116 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(1)), l3));
2117
2118 timer T := 2.0;
2119 T.start;
2120 alt {
2121 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) {
2122 setverdict(fail, "MSC received COMPL L3 for invalid SAPI 1");
2123 }
2124 [] BSSAP.receive { repeat; }
2125 [] IPA_RSL[0].receive { repeat; }
2126 [] T.timeout {}
2127 }
2128
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002129 f_shutdown_helper();
Harald Welte5cd20ed2017-12-13 21:03:20 +01002130}
2131
2132/* Test behavior if RSL EST IND for invalid SAPI */
2133testcase TC_rll_est_ind_inval_sapi3() runs on test_CT {
2134 timer T := 2.0;
2135
Harald Welte89d42e82017-12-17 16:42:41 +01002136 f_init(1);
Harald Welte5cd20ed2017-12-13 21:03:20 +01002137
2138 var RslChannelNr chan_nr := f_chreq_act_ack();
2139
2140 var octetstring l3 := '00010203040506'O;
2141 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(3)), l3));
2142
2143 T.start;
2144 alt {
2145 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) {
2146 setverdict(fail, "MSC received COMPL L3 for invalid SAPI 3");
2147 }
2148 [] BSSAP.receive { repeat; }
2149 [] IPA_RSL[0].receive { repeat; }
2150 [] T.timeout {}
2151 }
2152
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002153 f_shutdown_helper();
Harald Welte5cd20ed2017-12-13 21:03:20 +01002154}
2155
2156/* Test behavior if RSL EST IND for invalid SACCH */
2157testcase TC_rll_est_ind_inval_sacch() runs on test_CT {
2158 timer T := 2.0;
2159
Harald Welte89d42e82017-12-17 16:42:41 +01002160 f_init(1);
Harald Welte5cd20ed2017-12-13 21:03:20 +01002161
2162 var RslChannelNr chan_nr := f_chreq_act_ack();
2163
2164 var octetstring l3 := '00010203040506'O;
2165 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_SACCH(0)), l3));
2166
2167 T.start;
2168 alt {
2169 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) {
2170 setverdict(fail, "MSC received COMPL L3 for invalid Link SACCH");
2171 }
2172 [] BSSAP.receive { repeat; }
2173 [] IPA_RSL[0].receive { repeat; }
2174 [] T.timeout {}
2175 }
2176
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002177 f_shutdown_helper();
Harald Welte5cd20ed2017-12-13 21:03:20 +01002178}
2179
Vadim Yanitskiy61f784a2020-10-01 21:12:19 +07002180/* Verify DLCI / RSL Link ID conversion for MO/MT messages on SAPI0/SAPI3 */
2181private function f_TC_tch_dlci_link_id_sapi(charstring id) runs on MSC_ConnHdlr {
2182 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
2183 var PDU_BSSAP ass_cmd := f_gen_ass_req();
2184
2185 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
2186 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
2187
2188 f_establish_fully(ass_cmd, exp_compl);
2189
2190 /* SAPI0 has already been established by f_establish_fully(), establish SAPI3 */
2191 RSL.send(ts_RSL_EST_IND(g_chan_nr, ts_RslLinkID_SACCH(3), '0904'O));
2192 /* Expect BSSAP/DTAP on SAPI3 (DLCI IE) */
2193 BSSAP.receive(PDU_BSSAP:{
2194 discriminator := '1'B,
2195 spare := '0000000'B,
2196 dlci := 'C3'O,
2197 lengthIndicator := ?,
2198 pdu := { dtap := '0904'O }
2199 });
2200
2201 /* Send messages on DCCH/SAPI0 and ACCH/SAPI3 */
2202 for (var integer i := 0; i < 32; i := i + 1) {
2203 var octetstring l3 := '09'O & f_rnd_octstring(14);
2204 var template (value) RslLinkId link_id;
2205 var template (value) OCT1 dlci;
2206
2207 if (i mod 2 == 0) {
2208 /* SAPI0 on FACCH or SDCCH */
2209 link_id := ts_RslLinkID_DCCH(0);
2210 dlci := '80'O;
2211 } else {
2212 /* SAPI3 on SACCH */
2213 link_id := ts_RslLinkID_SACCH(3);
2214 dlci := 'C3'O;
2215 }
2216
2217 /* Send MO message: RSL -> BSSAP */
Neels Hofmeyr0aa719b2020-10-12 18:43:09 +00002218 f_mo_l3_transceive(RSL, link_id, dlci, l3);
Vadim Yanitskiy61f784a2020-10-01 21:12:19 +07002219 /* Send MT message: BSSAP -> RSL */
Neels Hofmeyr0aa719b2020-10-12 18:43:09 +00002220 f_mt_l3_transceive(RSL, link_id, dlci, l3);
Vadim Yanitskiy61f784a2020-10-01 21:12:19 +07002221 }
2222}
2223testcase TC_tch_dlci_link_id_sapi() runs on test_CT {
2224 var TestHdlrParams pars := f_gen_test_hdlr_pars();
2225 var MSC_ConnHdlr vc_conn;
2226
2227 f_init(1, true);
2228 f_sleep(1.0);
2229
2230 vc_conn := f_start_handler(refers(f_TC_tch_dlci_link_id_sapi), pars);
2231 vc_conn.done;
2232
2233 f_shutdown_helper();
2234}
2235
Vadim Yanitskiy6ef5dfa2020-08-28 18:04:41 +07002236private function f_exp_sapi_n_reject(template (present) GsmSapi sapi := ?,
2237 template myBSSMAP_Cause cause := ?,
2238 float T_val := 2.0)
2239runs on test_CT {
2240 var BSSAP_N_DATA_ind rx_di;
2241 timer T;
2242
2243 var template BSSMAP_IE_Cause tr_cause := tr_BSSMAP_IE_Cause(cause);
2244 var template PDU_BSSAP tr_pdu := tr_BSSMAP_SAPInReject(sapi);
2245
2246 T.start(T_val);
2247 alt {
2248 [] BSSAP.receive(tr_BSSAP_DATA_ind(?, tr_pdu)) -> value rx_di {
2249 var BSSMAP_IE_Cause rx_cause := rx_di.userData.pdu.bssmap.sAPInReject.cause;
2250 if (not match(rx_cause, tr_cause)) {
2251 setverdict(fail, "Rx unexpected Cause IE: ",
2252 rx_cause, " vs expected ", tr_cause);
2253 }
2254 setverdict(pass);
2255 }
2256 [] BSSAP.receive(BSSAP_N_DATA_ind:?) -> value rx_di {
2257 setverdict(fail, "Rx unexpected BSSAP PDU: ", rx_di);
2258 }
2259 [] T.timeout {
2260 setverdict(fail, "Timeout waiting for BSSMAP SAPI N Reject");
2261 }
2262 }
2263}
2264
2265/* Check if we get SAPI N Reject on receipt of unexpected RLL RELease INDication */
2266testcase TC_rll_rel_ind_sapi_n_reject() runs on test_CT {
2267 var octetstring rnd_data := f_rnd_octstring(16);
2268 var RSL_Message rx_rsl;
2269 var DchanTuple dt;
2270
2271 f_init(1);
2272
2273 /* MS establishes a SAPI=0 link on DCCH */
2274 dt := f_est_dchan(f_rnd_ra_cs(), 23, rnd_data);
2275
2276 /* MSC sends some data on (not yet established) SAPI=3 link */
2277 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSAP_DTAP(rnd_data, '03'O)));
2278 /* BSC attempts to establish a SAPI=3 link on DCCH */
2279 rx_rsl := f_exp_ipa_rx(0, tr_RSL_EST_REQ(dt.rsl_chan_nr, tr_RslLinkID_DCCH(3)));
2280
2281 /* MS sends unexpected RELease INDication on SAPI=3 */
2282 f_ipa_tx(0, ts_RSL_REL_IND(dt.rsl_chan_nr, ts_RslLinkID_DCCH(3)));
2283 /* We expect to receive BSSMAP SAPI N Reject message from the BSC */
2284 f_exp_sapi_n_reject(3, GSM0808_CAUSE_MS_NOT_EQUIPPED);
2285
2286 /* Clean up the connection */
2287 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
2288 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
2289
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002290 f_shutdown_helper();
Vadim Yanitskiy6ef5dfa2020-08-28 18:04:41 +07002291}
2292
2293/* Check if we get SAPI N Reject on receipt of unexpected RLL ERROR INDication */
2294testcase TC_rll_err_ind_sapi_n_reject() runs on test_CT {
2295 var octetstring rnd_data := f_rnd_octstring(16);
2296 var RSL_Message rx_rsl;
2297 var DchanTuple dt;
2298
2299 f_init(1);
2300
2301 /* MS establishes a SAPI=0 link on DCCH */
2302 dt := f_est_dchan(f_rnd_ra_cs(), 23, rnd_data);
2303
2304 /* MSC sends some data on (not yet established) SAPI=3 link */
2305 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSAP_DTAP(rnd_data, '03'O)));
2306 /* BSC attempts to establish a SAPI=3 link on DCCH */
2307 rx_rsl := f_exp_ipa_rx(0, tr_RSL_EST_REQ(dt.rsl_chan_nr, tr_RslLinkID_DCCH(3)));
2308
2309 /* BTS sends unexpected ERROR INDication on SAPI=3 */
2310 f_ipa_tx(0, ts_RSL_ERROR_IND(dt.rsl_chan_nr, ts_RslLinkID_DCCH(3), ''O));
2311 /* We expect to receive BSSMAP SAPI N Reject message from the BSC */
2312 f_exp_sapi_n_reject(3, GSM0808_CAUSE_BSS_NOT_EQUIPPED);
2313
2314 /* Clean up the connection */
2315 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
2316 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
2317
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002318 f_shutdown_helper();
Vadim Yanitskiy6ef5dfa2020-08-28 18:04:41 +07002319}
2320
2321/* Check if we get SAPI N Reject due to a SAPI=3 link establishment timeout */
2322testcase TC_rll_timeout_sapi_n_reject() runs on test_CT {
2323 var octetstring rnd_data := f_rnd_octstring(16);
2324 var RSL_Message rx_rsl;
2325 var DchanTuple dt;
2326
2327 f_init(1);
2328
2329 /* MS establishes a SAPI=0 link on DCCH */
2330 dt := f_est_dchan(f_rnd_ra_cs(), 23, rnd_data);
2331
2332 /* MSC sends some data on (not yet established) SAPI=3 link */
2333 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSAP_DTAP(rnd_data, '03'O)));
2334 /* BSC attempts to establish a SAPI=3 link on DCCH */
2335 rx_rsl := f_exp_ipa_rx(0, tr_RSL_EST_REQ(dt.rsl_chan_nr, tr_RslLinkID_DCCH(3)));
2336
2337 /* MS does not respond, so the link establishment timeout triggers SAPI N Reject */
2338 f_exp_sapi_n_reject(3, GSM0808_CAUSE_BSS_NOT_EQUIPPED, T_val := 8.0);
2339
2340 /* Clean up the connection */
2341 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
2342 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
2343
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002344 f_shutdown_helper();
Vadim Yanitskiy6ef5dfa2020-08-28 18:04:41 +07002345}
2346
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +02002347testcase TC_si_default() runs on test_CT {
2348 f_init(0);
2349 f_init_bts_and_check_sysinfo(0, expect_si := SystemInformationConfig_default);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002350 f_shutdown_helper();
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +02002351}
Harald Welte4003d112017-12-09 22:35:39 +01002352
Neels Hofmeyr56f24782020-07-09 00:50:49 +02002353/* We're testing SI2quater with lists of EARFCNs. Instead of just incrementing EARFCNs, also pick some from the edges of
2354 * the entire value range. This function provides the same EARFCN numbers for the same earfcn_index */
2355private function f_test_si2quater_earfcn_by_idx(integer earfcn_index) return uint16_t
2356{
2357 select (earfcn_index) {
2358 case (0) {
2359 /* E-ARFCN 111 is already added in the osmo-bsc.cfg */
2360 return 111;
2361 }
2362 case (1) {
2363 return 1;
2364 }
2365 case (2) {
2366 return 0;
2367 }
2368 case (3) {
2369 return 65535;
2370 }
2371 case else {
2372 return 23 * (earfcn_index - 3);
2373 }
2374 }
2375}
2376
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02002377function f_test_si2quater(integer total_earfcns, template SystemInformationConfig expect_si,
2378 template CellSelIndValue expect_cells := omit) runs on test_CT {
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002379
2380 f_init(0);
2381
2382 /* E-ARFCN 111 is already added in the osmo-bsc.cfg, so only add more arfcns if total_earfcns > 1 */
2383 for (var integer i := 1; i < total_earfcns; i := i + 1) {
Neels Hofmeyr56f24782020-07-09 00:50:49 +02002384 f_bts_0_cfg(BSCVTY, {"si2quater neighbor-list add earfcn " & int2str(f_test_si2quater_earfcn_by_idx(i))
2385 & " thresh-hi 20 thresh-lo 10 prio 3 qrxlv 22 meas 3"});
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002386 }
2387
2388 f_init_bts_and_check_sysinfo(0, expect_si := expect_si);
2389
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02002390 if (not istemplatekind(expect_cells, "omit")) {
2391 /* Also check that RR Channel Release contains these EARFCNs.
2392 * (copied code from TC_chan_rel_hard_clear_csfb) */
2393 var BSSAP_N_DATA_ind rx_di;
2394 var DchanTuple dt;
2395
2396 dt := f_est_dchan('23'O, 23, '00010203040506'O);
Pau Espin Pedrold0046312021-04-19 16:35:58 +02002397 /* Send CommonID with some random PLMN (BSC doesn't take it into account
2398 * yet when generating the EUTRAN neigh list in RR CHannel Release) */
2399 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_CommonId('001019876543210'H, '323454'O)));
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02002400
2401 /* Instruct BSC to clear channel */
2402 var BssmapCause cause := 0;
2403 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommandCSFB(cause)));
2404
2405 /* expect Clear Complete from BSC on A */
2406 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete)) {
2407 /* release the SCCP connection */
2408 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
2409 }
2410
Pau Espin Pedrol841b90d2021-04-15 16:42:52 +02002411 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 +02002412 }
2413
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002414 for (var integer i := 1; i < total_earfcns; i := i + 1) {
Neels Hofmeyr56f24782020-07-09 00:50:49 +02002415 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 +02002416 }
2417}
2418
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002419private function f_tr_si2quater_earfcns(integer count) return template SI2quaterRestOctetsList
2420{
2421 var template SI2quaterRestOctetsList si2quater := {};
2422 var integer si2quater_count := (count + 2) / 3;
2423
2424 for (var integer i := 0; i < count; i := i + 1) {
Neels Hofmeyr56f24782020-07-09 00:50:49 +02002425 var integer earfcn := f_test_si2quater_earfcn_by_idx(i);
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002426 var integer index := i / 3;
2427 var integer earfcn_index := i mod 3;
2428 if (index >= lengthof(si2quater)) {
2429 si2quater[index] := tr_SI2quaterRestOctets_EUTRAN(index := index, count := si2quater_count - 1);
2430 }
2431 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);
2432 }
2433
2434 return si2quater;
2435}
2436
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02002437private function f_tr_rr_chan_rel_earfcns(integer count) return template CellSelIndValue
2438{
2439 var template CellSelIndValue_EUTRAN_Descrs cells := {};
2440
Alexander Couzensf74b5cb2020-09-10 22:28:40 +02002441 /* the lte neighbors must match the config & vty to pass this test */
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02002442 for (var integer i := 0; i < count; i := i + 1) {
2443 var integer earfcn := f_test_si2quater_earfcn_by_idx(i);
Alexander Couzensf74b5cb2020-09-10 22:28:40 +02002444 cells[i] := tr_CellSelIndValue_EUTRAN_Descr(earfcn, '1'B, 3);
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02002445 }
2446
2447 return tr_CellSelIndValue_EUTRAN(cells);
2448}
2449
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002450private function f_tc_si2quater_n_earfcns(integer n) runs on test_CT
2451{
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002452 var template SystemInformationConfig sic := SystemInformationConfig_default;
Pau Espin Pedrol8ab62e42020-12-18 16:19:11 +01002453 sic.si2quater := f_tr_si2quater_earfcns(n);
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02002454 var template CellSelIndValue cells := f_tr_rr_chan_rel_earfcns(n);
2455 f_test_si2quater(n, sic, cells);
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002456}
2457
2458testcase TC_si2quater_2_earfcns() runs on test_CT {
2459 f_tc_si2quater_n_earfcns(2);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002460 f_shutdown_helper();
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002461}
2462
2463testcase TC_si2quater_3_earfcns() runs on test_CT {
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002464 f_tc_si2quater_n_earfcns(3);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002465 f_shutdown_helper();
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002466}
2467
2468testcase TC_si2quater_4_earfcns() runs on test_CT {
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002469 f_tc_si2quater_n_earfcns(4);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002470 f_shutdown_helper();
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002471}
2472
2473testcase TC_si2quater_5_earfcns() runs on test_CT {
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002474 f_tc_si2quater_n_earfcns(5);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002475 f_shutdown_helper();
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002476}
2477
2478testcase TC_si2quater_6_earfcns() runs on test_CT {
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002479 f_tc_si2quater_n_earfcns(6);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002480 f_shutdown_helper();
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002481}
2482
2483testcase TC_si2quater_12_earfcns() runs on test_CT {
2484 f_tc_si2quater_n_earfcns(12);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002485 f_shutdown_helper();
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002486}
2487
2488testcase TC_si2quater_23_earfcns() runs on test_CT {
2489 f_tc_si2quater_n_earfcns(23);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002490 f_shutdown_helper();
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002491}
2492
2493testcase TC_si2quater_32_earfcns() runs on test_CT {
2494 f_tc_si2quater_n_earfcns(32);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002495 f_shutdown_helper();
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002496}
2497
2498testcase TC_si2quater_33_earfcns() runs on test_CT {
2499 f_tc_si2quater_n_earfcns(33);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002500 f_shutdown_helper();
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002501}
2502
2503testcase TC_si2quater_42_earfcns() runs on test_CT {
2504 f_tc_si2quater_n_earfcns(42);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002505 f_shutdown_helper();
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002506}
2507
2508testcase TC_si2quater_48_earfcns() runs on test_CT {
2509 f_tc_si2quater_n_earfcns(48);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002510 f_shutdown_helper();
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002511}
2512
2513/* verify the VTY error response when adding too many EARFCNs, and showing that osmo-bsc still sends 16 SI2quater with
2514 * 48 EARFCNs. */
2515testcase TC_si2quater_49_earfcns() runs on test_CT {
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002516 var template SystemInformationConfig sic := SystemInformationConfig_default;
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002517 sic.si2quater := f_tr_si2quater_earfcns(48); /* 48, not 49! */
2518 f_init(0);
2519
2520 for (var integer i := 1; i < 48; i := i + 1) {
Neels Hofmeyr56f24782020-07-09 00:50:49 +02002521 f_bts_0_cfg(BSCVTY, {"si2quater neighbor-list add earfcn " & int2str(f_test_si2quater_earfcn_by_idx(i))
2522 & " thresh-hi 20 thresh-lo 10 prio 3 qrxlv 22 meas 3"});
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002523 }
2524
2525 /* The 49th EARFCN no longer fits, expect VTY error */
2526 f_vty_enter_cfg_bts(BSCVTY, 0);
2527 var charstring vty_error;
2528 vty_error := f_vty_transceive_ret(BSCVTY,
2529 "si2quater neighbor-list add earfcn 70 thresh-hi 20 thresh-lo 10 prio 3 qrxlv 22 meas 3")
2530 f_vty_transceive(BSCVTY, "end");
2531
2532 if (f_strstr(vty_error, "Unable to add ARFCN 70") >= 0) {
2533 log("Got expected VTY error: ", vty_error);
2534 setverdict(pass);
2535 } else {
2536 setverdict(fail, "Expected the 49th EUTRAN ARFCN to be rejected by vty config, got: ", vty_error);
2537 }
2538
2539 f_init_bts_and_check_sysinfo(0, expect_si := sic);
2540
2541 for (var integer i := 1; i < 48; i := i + 1) {
Neels Hofmeyr56f24782020-07-09 00:50:49 +02002542 f_bts_0_cfg(BSCVTY, {"si2quater neighbor-list del earfcn " & int2str(f_test_si2quater_earfcn_by_idx(i))});
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002543 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002544 f_shutdown_helper();
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002545}
2546
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02002547private function f_acc09_count_allowed(AccessControlClass acc) return uint8_t
2548{
2549 var uint8_t count := 0;
2550 for (var integer i := 5; i < 16; i := i + 1) {
2551 if (acc[i] == '0'B) { /* the list marks barred, we count allowed */
2552 count := count + 1;
2553 }
2554 }
2555 return count;
2556}
2557
Pau Espin Pedrolc6136cd2020-07-24 13:20:02 +02002558private function f_recv_next_si1(integer rsl_idx := 0) runs on test_CT return SystemInformationType1
2559{
2560 var ASP_RSL_Unitdata rx_rsl_ud;
2561 var SystemInformationType1 last_si1;
2562
2563 timer T := 30.0;
2564 T.start;
2565 alt {
2566 [] IPA_RSL[rsl_idx].receive(tr_ASP_RSL_UD((tr_RSL_NO_BCCH_INFO,
2567 tr_RSL_BCCH_INFO,
2568 tr_RSL_NO_SACCH_FILL,
2569 tr_RSL_SACCH_FILL))
2570 ) -> value rx_rsl_ud {
2571 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
2572 if (g_system_information[rsl_idx].si1 == omit) {
2573 repeat;
2574 }
2575 last_si1 := g_system_information[rsl_idx].si1;
2576 g_system_information[rsl_idx].si1 := omit;
2577 T.stop;
2578 }
Vadim Yanitskiy79ebd5e2021-01-04 00:12:55 +01002579 [] IPA_RSL[rsl_idx].receive { repeat; }
Pau Espin Pedrolc6136cd2020-07-24 13:20:02 +02002580 [] T.timeout { setverdict(fail, "Timeout receiving next SI1"); }
2581 }
2582 return last_si1;
2583}
2584
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02002585/* verify ACC rotate feature */
2586testcase TC_si_acc_rotate() runs on test_CT {
2587 var template SystemInformationConfig sic := SystemInformationConfig_default;
Pau Espin Pedrolc6136cd2020-07-24 13:20:02 +02002588 var SystemInformationType1 last_si1;
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02002589 var AccessControlClass acc;
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02002590 var uint8_t count;
2591 var integer times_allowed[10] := { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
2592
2593 f_init(0, guard_timeout := 60.0);
2594
2595 f_bts_0_cfg(BSCVTY, {"rach access-control-class 5 barred",
2596 "access-control-class-rotate 3",
2597 "access-control-class-rotate-quantum 1"});
2598
2599 /* Init and get first sysinfo */
2600 f_init_bts_and_check_sysinfo(0, expect_si := ?);
2601
Pau Espin Pedrolc6136cd2020-07-24 13:20:02 +02002602 for (var integer i:= 0; i < 20; i := i + 1) {
2603 last_si1 := f_recv_next_si1(0);
2604 acc := last_si1.rach_control.acc;
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02002605 count := f_acc09_count_allowed(acc);
2606 log("RSL: GOT SI1 ACC len=", count, ": ", acc);
2607
2608 if (count != 3) {
2609 log("RSL: EXPECTED SI ACC len=3");
2610 setverdict(fail, "received SI does not match expectations");
2611 break;
2612 }
2613
2614 for (var integer j := 0; j < 10; j := j + 1) {
2615 if (acc[16 - 1 - j] == '0'B) { /* the list marks barred, we count allowed */
2616 times_allowed[j] := times_allowed[j] + 1;
2617 }
2618 }
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02002619 }
2620
2621 for (var integer j := 0; j < 10; j := j + 1) {
2622 log("ACC", j, " allowed ", times_allowed[j], " times" );
2623 if (j != 5 and times_allowed[j] < 3) {
2624 setverdict(fail, "ACC", j, " ERROR: allowed ", times_allowed[j], " < 1 times");
2625 } else if (j == 5 and times_allowed[j] > 0) {
2626 setverdict(fail, "ACC", j, " ERROR: allowed ", times_allowed[j], " > 0 times");
2627 }
2628 }
2629
2630 f_bts_0_cfg(BSCVTY, {"access-control-class-rotate 10",
2631 "rach access-control-class 5 allowed"});
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002632 f_shutdown_helper();
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02002633}
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002634
Pau Espin Pedrolc6136cd2020-07-24 13:20:02 +02002635/* verify ACC startup ramp+rotate feature */
2636testcase TC_si_acc_ramp_rotate() runs on test_CT {
2637 var template SystemInformationConfig sic := SystemInformationConfig_default;
2638 var SystemInformationType1 last_si1;
2639 var AccessControlClass acc;
2640 var ASP_RSL_Unitdata rx_rsl_ud;
2641 var uint8_t count;
2642 var uint8_t prev_count;
2643 var integer times_allowed[10] := { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
2644
2645 f_init(0, guard_timeout := 80.0);
2646
2647 f_bts_0_cfg(BSCVTY, {"rach access-control-class 4 barred",
2648 "access-control-class-rotate 0",
2649 "access-control-class-rotate-quantum 1",
2650 "access-control-class-ramping",
2651 "access-control-class-ramping-step-interval 5",
2652 "access-control-class-ramping-step-size 5"});
2653
2654 /* Init and get first sysinfo */
2655 f_init_bts_and_check_sysinfo(0, expect_si := ?);
2656 last_si1 := g_system_information[0].si1;
2657 acc := last_si1.rach_control.acc;
2658 count := f_acc09_count_allowed(acc);
2659 /* Adm subset size was set to 0 above, so wait until all ACC are barred */
2660 while (count > 0) {
2661 last_si1 := f_recv_next_si1(0);
2662 acc := last_si1.rach_control.acc;
2663 count := f_acc09_count_allowed(acc);
2664 log("RSL: wait len()=0: GOT SI1 ACC len=", count, ": ", acc);
2665 }
2666
2667 /* Increase adm subset size, we should see ramping start up */
2668 f_bts_0_cfg(BSCVTY, {"access-control-class-rotate 10"});
2669 prev_count := 0;
2670 while (true) {
2671 last_si1 := f_recv_next_si1(0);
2672 acc := last_si1.rach_control.acc;
2673 count := f_acc09_count_allowed(acc);
2674 log("RSL: GOT SI1 ACC len=", count, ": ", acc);
2675
2676 if (prev_count > count) {
2677 setverdict(fail, "ACC allowed count dropped while expecting grow: ", prev_count, " -> ", count);
2678 break;
2679 }
2680
2681 if (count == 9) {
2682 break; /* Maximum reached (10 - 1 perm barred), done here */
2683 }
2684
2685 prev_count := count;
2686 }
2687
2688 setverdict(pass);
2689
2690 f_bts_0_cfg(BSCVTY, {"access-control-class-rotate 10",
2691 "rach access-control-class 4 allowed",
2692 "no access-control-class-ramping"});
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002693 f_shutdown_helper();
Pau Espin Pedrolc6136cd2020-07-24 13:20:02 +02002694}
2695
Harald Welte4003d112017-12-09 22:35:39 +01002696testcase TC_ctrl_msc_connection_status() runs on test_CT {
2697 var charstring ctrl_resp;
2698
Harald Welte89d42e82017-12-17 16:42:41 +01002699 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +01002700
2701 /* See https://osmocom.org/issues/2729 */
2702 f_ctrl_get_exp(IPA_CTRL, "msc_connection_status", "connected");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002703 f_shutdown_helper();
Harald Welte4003d112017-12-09 22:35:39 +01002704}
2705
Stefan Sperlingb041b3d2018-01-03 17:14:55 +01002706testcase TC_ctrl_msc0_connection_status() runs on test_CT {
2707 var charstring ctrl_resp;
2708
2709 f_init(1);
Stefan Sperlingb041b3d2018-01-03 17:14:55 +01002710
2711 f_ctrl_get_exp(IPA_CTRL, "msc.0.connection_status", "connected");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002712 f_shutdown_helper();
Stefan Sperlingb041b3d2018-01-03 17:14:55 +01002713}
2714
Harald Welte4003d112017-12-09 22:35:39 +01002715testcase TC_ctrl() runs on test_CT {
2716 var charstring ctrl_resp;
2717
Harald Welte89d42e82017-12-17 16:42:41 +01002718 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +01002719
2720 /* all below values must match the osmo-bsc.cfg config file used */
2721
Harald Welte6a129692018-03-17 17:30:14 +01002722 f_ctrl_get_exp(IPA_CTRL, "mcc", "001");
2723 f_ctrl_get_exp(IPA_CTRL, "mnc", "01");
Oliver Smith75aa0202019-08-19 14:17:50 +02002724 f_ctrl_get_exp(IPA_CTRL, "number-of-bts", "4");
Harald Welte4003d112017-12-09 22:35:39 +01002725
2726 var integer bts_nr := 0;
2727 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "location-area-code", "1");
2728 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "cell-identity", "0");
2729 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "oml-connection-state", "connected");
2730 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "gprs-mode", "gprs");
2731 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "rf_state", "operational,unlocked,on");
2732 f_ctrl_get_exp_trx(IPA_CTRL, bts_nr, 0, "arfcn", "871");
2733 f_ctrl_get_exp_trx(IPA_CTRL, bts_nr, 0, "max-power-reduction", "20");
2734
2735 var integer uptime := str2int(f_ctrl_get_bts(IPA_CTRL, bts_nr, "oml-uptime"));
2736 f_sleep(2.0);
2737 if (str2int(f_ctrl_get_bts(IPA_CTRL, bts_nr, "oml-uptime")) < uptime+1) {
2738 setverdict(fail, "oml-uptime not incrementing as expected");
2739 }
2740 /* TODO: Disconnect RSL, imply that OML is disconnected and check for uptime zero? */
2741
2742 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bsc", 0, "paging:attempted", 0);
2743
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002744 f_shutdown_helper();
Harald Welte96c94412017-12-09 03:12:45 +01002745}
2746
Pau Espin Pedrol5a2d7432019-06-07 19:43:45 +02002747/* Verify that Upon receival of SET "location", BSC forwards a TRAP
2748 "location-state" over the SCCPlite IPA conn */
2749testcase TC_ctrl_location() runs on test_CT {
2750 var MSC_ConnHdlr vc_conn;
2751 var integer bts_nr := 0;
2752
2753 f_init(1, true);
2754 f_sleep(1.0);
2755
2756 f_ctrl_set_bts(IPA_CTRL, bts_nr, "location", "1234567,fix3d,0.340000,0.560000,0.780000");
2757 f_ctrl_exp_trap(SCCPLITE_IPA_CTRL, "bts." & int2str(bts_nr) & ".location-state",
2758 "1234567,fix3d,0.340000,0.560000,0.780000,operational,unlocked,on,001,01");
2759
2760 f_ctrl_set(SCCPLITE_IPA_CTRL, "rf_locked", "1");
2761 f_sleep(2.0);
2762
2763 f_ctrl_set_bts(IPA_CTRL, bts_nr, "location", "1234888,fix3d,0.350000,0.570000,0.790000");
2764 f_ctrl_exp_trap(SCCPLITE_IPA_CTRL, "bts." & int2str(bts_nr) & ".location-state",
2765 "1234888,fix3d,0.350000,0.570000,0.790000,operational,locked,off,001,01");
2766
2767 /* should match the one from config */
2768 f_ctrl_set(SCCPLITE_IPA_CTRL, "rf_locked", "0");
2769
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002770 f_shutdown_helper();
Pau Espin Pedrol5a2d7432019-06-07 19:43:45 +02002771}
2772
Harald Welte6f521d82017-12-11 19:52:02 +01002773
2774/***********************************************************************
2775 * Paging Testing
2776 ***********************************************************************/
2777
2778type record Cell_Identity {
2779 GsmMcc mcc,
2780 GsmMnc mnc,
2781 GsmLac lac,
2782 GsmCellId ci
2783};
Harald Welte24135bd2018-03-17 19:27:53 +01002784private const Cell_Identity cid := { '001'H, '01'H, 1, 0 };
Stefan Sperling049a86e2018-03-20 15:51:00 +01002785private const Cell_Identity unknown_cid := { '678'H, 'f90'H, 1, 0 };
Harald Welte6f521d82017-12-11 19:52:02 +01002786
Harald Welte5d1a2202017-12-13 19:51:29 +01002787type set of integer BtsIdList;
2788
2789private function f_bts_in_list(integer bts_id, BtsIdList bts_ids) return boolean {
2790 for (var integer j := 0; j < sizeof(bts_ids); j := j + 1) {
2791 if (bts_id == bts_ids[j]) {
2792 return true;
2793 }
2794 }
2795 return false;
2796}
Harald Welte6f521d82017-12-11 19:52:02 +01002797
2798/* core paging test helper function; used by most paging test cases */
2799private function f_pageing_helper(hexstring imsi,
2800 template BSSMAP_FIELD_CellIdentificationList cid_list,
Harald Welte5d1a2202017-12-13 19:51:29 +01002801 BtsIdList bts_ids := { 0 },
Harald Welte6f521d82017-12-11 19:52:02 +01002802 template RSL_ChanNeeded rsl_chneed := omit,
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07002803 template (omit) OCT4 tmsi := omit) runs on test_CT
Harald Welte6f521d82017-12-11 19:52:02 +01002804{
2805 var template BSSMAP_IE_ChannelNeeded bssmap_chneed;
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07002806 var template MobileIdentityV mi;
Harald Welte6f521d82017-12-11 19:52:02 +01002807 var RSL_Message rx_rsl;
2808 var integer paging_group := hex2int(imsi[lengthof(imsi)-1]);
Harald Welte5d1a2202017-12-13 19:51:29 +01002809 var integer i;
Harald Welte6f521d82017-12-11 19:52:02 +01002810
2811 f_init();
Harald Welte6f521d82017-12-11 19:52:02 +01002812
2813 /* Clear the queue, it might still contain stuff like BCCH FILLING */
Harald Weltec3068592018-03-17 19:55:31 +01002814 for (i := 0; i < NUM_BTS; i := i + 1) {
2815 IPA_RSL[i].clear;
Harald Welte5d1a2202017-12-13 19:51:29 +01002816 }
Harald Welte6f521d82017-12-11 19:52:02 +01002817
2818 if (isvalue(rsl_chneed)) {
2819 /* The values of 08.08 3.2.2.36 and 08.58 9.3.40 are luckily identical */
2820 bssmap_chneed := ts_BSSMAP_IE_ChanNeeded(int2bit(enum2int(valueof(rsl_chneed)),2));
2821 } else {
2822 bssmap_chneed := omit;
2823 }
2824
Neels Hofmeyrf246a922020-05-13 02:27:10 +02002825 BSSAP.send(ts_BSSAP_UNITDATA_req(g_bssap[0].sccp_addr_peer, g_bssap[0].sccp_addr_own,
2826 ts_BSSMAP_Paging(imsi, cid_list, tmsi, bssmap_chneed)));
Harald Welte6f521d82017-12-11 19:52:02 +01002827
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07002828 if (not istemplatekind(tmsi, "omit")) {
2829 mi := t_MI_TMSI(tmsi);
Harald Welte6f521d82017-12-11 19:52:02 +01002830 } else {
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07002831 mi := tr_MI_IMSI(imsi);
Harald Welte6f521d82017-12-11 19:52:02 +01002832 }
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07002833
Harald Welte5d1a2202017-12-13 19:51:29 +01002834 for (i := 0; i < sizeof(bts_ids); i := i + 1) {
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07002835 rx_rsl := f_exp_ipa_rx(bts_ids[i], tr_RSL_PAGING_CMD(mi));
Harald Welte5d1a2202017-12-13 19:51:29 +01002836 /* check channel type, paging group */
2837 if (rx_rsl.ies[1].body.paging_group != paging_group) {
2838 setverdict(fail, "Paging for wrong paging group");
2839 }
2840 if (ispresent(rsl_chneed) and
2841 rx_rsl.ies[3].body.chan_needed.chan_needed != valueof(rsl_chneed)) {
2842 setverdict(fail, "RSL Channel Needed != BSSMAP Channel Needed");
2843 }
Harald Welte6f521d82017-12-11 19:52:02 +01002844 }
Harald Welte2fccd982018-01-31 15:48:19 +01002845 f_sleep(2.0);
Harald Welte5d1a2202017-12-13 19:51:29 +01002846 /* do a quick check on all not-included BTSs if they received paging */
2847 for (i := 0; i < NUM_BTS; i := i + 1) {
2848 timer T := 0.1;
2849 if (f_bts_in_list(i, bts_ids)) {
2850 continue;
2851 }
2852 T.start;
2853 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07002854 [] IPA_RSL[i].receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD(mi))) {
Harald Welte5d1a2202017-12-13 19:51:29 +01002855 setverdict(fail, "Paging on BTS ", i, " which is not part of ", bts_ids);
2856 }
2857 [] IPA_RSL[i].receive { repeat; }
2858 [] T.timeout { }
2859 }
Harald Welte6f521d82017-12-11 19:52:02 +01002860 }
2861
2862 setverdict(pass);
2863}
2864
Harald Welte5d1a2202017-12-13 19:51:29 +01002865const BtsIdList c_BtsId_all := { 0, 1, 2 };
Harald Welte751d3eb2018-01-31 15:51:06 +01002866const BtsIdList c_BtsId_none := { };
Harald Welte5d1a2202017-12-13 19:51:29 +01002867const BtsIdList c_BtsId_LAC1 := { 0, 1 };
2868const BtsIdList c_BtsId_LAC2 := { 2 };
2869
Harald Welte6f521d82017-12-11 19:52:02 +01002870/* PAGING by IMSI + TMSI */
2871testcase TC_paging_imsi_nochan() runs on test_CT {
2872 var BSSMAP_FIELD_CellIdentificationList cid_list;
2873 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Philipp Maier8c04b0a2018-02-23 13:48:48 +01002874 f_pageing_helper('001010100000001'H, cid_list, c_BtsId_all, omit, omit);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002875 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002876}
2877
2878/* PAGING by IMSI + TMSI */
2879testcase TC_paging_tmsi_nochan() runs on test_CT {
2880 var BSSMAP_FIELD_CellIdentificationList cid_list;
2881 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01002882 f_pageing_helper('001010100000001'H, cid_list, c_BtsId_all, omit, 'A1B2C301'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002883 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002884}
2885
2886/* Paging with different "channel needed' values */
2887testcase TC_paging_tmsi_any() runs on test_CT {
2888 var BSSMAP_FIELD_CellIdentificationList cid_list;
2889 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01002890 f_pageing_helper('001010100000002'H, cid_list, c_BtsId_all, RSL_CHANNEED_ANY, 'A1B2C302'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002891 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002892}
2893testcase TC_paging_tmsi_sdcch() runs on test_CT {
2894 var BSSMAP_FIELD_CellIdentificationList cid_list;
2895 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01002896 f_pageing_helper('001010100000003'H, cid_list, c_BtsId_all, RSL_CHANNEED_SDCCH, 'A1B2C303'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002897 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002898}
2899testcase TC_paging_tmsi_tch_f() runs on test_CT {
2900 var BSSMAP_FIELD_CellIdentificationList cid_list;
2901 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01002902 f_pageing_helper('001010000000004'H, cid_list, c_BtsId_all, RSL_CHANNEED_TCH_F, 'A1B2C304'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002903 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002904}
2905testcase TC_paging_tmsi_tch_hf() runs on test_CT {
2906 var BSSMAP_FIELD_CellIdentificationList cid_list;
2907 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01002908 f_pageing_helper('001010000000005'H, cid_list, c_BtsId_all, RSL_CHANNEED_TCH_ForH, 'A1B2C305'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002909 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002910}
2911
2912/* Paging by CGI */
2913testcase TC_paging_imsi_nochan_cgi() runs on test_CT {
2914 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2915 cid_list := { cIl_CGI := { ts_BSSMAP_CI_CGI(cid.mcc, cid.mnc, cid.lac, cid.ci) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01002916 f_pageing_helper('001010000000006'H, cid_list, { 0 });
Philipp Maier282ca4b2018-02-27 17:17:00 +01002917 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002918}
2919
2920/* Paging by LAC+CI */
2921testcase TC_paging_imsi_nochan_lac_ci() runs on test_CT {
2922 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2923 cid_list := { cIl_LAC_CI := { ts_BSSMAP_CI_LAC_CI(cid.lac, cid.ci) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01002924 f_pageing_helper('001010000000007'H, cid_list, { 0 });
Philipp Maier282ca4b2018-02-27 17:17:00 +01002925 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002926}
2927
2928/* Paging by CI */
2929testcase TC_paging_imsi_nochan_ci() runs on test_CT {
2930 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2931 cid_list := { cIl_CI := { ts_BSSMAP_CI_CI(cid.ci) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01002932 f_pageing_helper('001010000000008'H, cid_list, { 0 });
Philipp Maier282ca4b2018-02-27 17:17:00 +01002933 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002934}
2935
2936/* Paging by LAI */
2937testcase TC_paging_imsi_nochan_lai() runs on test_CT {
2938 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2939 cid_list := { cIl_LAI := { ts_BSSMAP_CI_LAI(cid.mcc, cid.mnc, cid.lac) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01002940 f_pageing_helper('001010000000009'H, cid_list, c_BtsId_LAC1);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002941 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002942}
2943
2944/* Paging by LAC */
2945testcase TC_paging_imsi_nochan_lac() runs on test_CT {
2946 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2947 cid_list := { cIl_LAC := { ts_BSSMAP_CI_LAC(cid.lac) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01002948 f_pageing_helper('001010000000010'H, cid_list, c_BtsId_LAC1);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002949 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002950}
2951
2952/* Paging by "all in BSS" */
2953testcase TC_paging_imsi_nochan_all() runs on test_CT {
2954 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2955 cid_list := { cIl_allInBSS := ''O };
Harald Welte5d1a2202017-12-13 19:51:29 +01002956 f_pageing_helper('001010000000011'H, cid_list, c_BtsId_all);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002957 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002958}
2959
Stefan Sperling7b5e1782018-03-20 19:32:43 +01002960/* Paging by PLMN+LAC+RNC; We do not implement this; Verify nothing is paged */
Harald Welte751d3eb2018-01-31 15:51:06 +01002961testcase TC_paging_imsi_nochan_plmn_lac_rnc() runs on test_CT {
2962 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2963 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 +01002964 f_pageing_helper('001010000000012'H, cid_list, c_BtsId_none);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002965 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01002966}
Harald Welte6f521d82017-12-11 19:52:02 +01002967
Stefan Sperling7b5e1782018-03-20 19:32:43 +01002968/* Paging by RNC; We do not implement this; Verify nothing is paged */
Harald Welte751d3eb2018-01-31 15:51:06 +01002969testcase TC_paging_imsi_nochan_rnc() runs on test_CT {
2970 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2971 cid_list := { cIl_RNC := { int2oct(13, 2) } };
Stefan Sperling7b5e1782018-03-20 19:32:43 +01002972 f_pageing_helper('001010000000013'H, cid_list, c_BtsId_none);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002973 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01002974}
2975
Stefan Sperling7b5e1782018-03-20 19:32:43 +01002976/* Paging by LAC+RNC; We do not implement; Verify nothing is paged */
Harald Welte751d3eb2018-01-31 15:51:06 +01002977testcase TC_paging_imsi_nochan_lac_rnc() runs on test_CT {
2978 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2979 cid_list := { cIl_LAC_RNC := { ts_BSSMAP_CI_LAC_RNC(cid.lac, 14) } };
Stefan Sperling7b5e1782018-03-20 19:32:43 +01002980 f_pageing_helper('001010000000014'H, cid_list, c_BtsId_none);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002981 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01002982}
2983
Harald Welte6f521d82017-12-11 19:52:02 +01002984/* Paging on multiple cells (multiple entries in list): Verify all of them page */
Harald Welte751d3eb2018-01-31 15:51:06 +01002985testcase TC_paging_imsi_nochan_lacs() runs on test_CT {
2986 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2987 cid_list := { cIl_LAC := { ts_BSSMAP_CI_LAC(1), ts_BSSMAP_CI_LAC(2) } };
2988 f_pageing_helper('001010000000015'H, cid_list, c_BtsId_all);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002989 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01002990}
2991
2992/* Paging on empty list: Verify none of them page */
2993testcase TC_paging_imsi_nochan_lacs_empty() runs on test_CT {
2994 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2995 cid_list := { cIl_LAC := { } };
2996 f_pageing_helper('001010000000016'H, cid_list, c_BtsId_none);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002997 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01002998}
2999
Stefan Sperling049a86e2018-03-20 15:51:00 +01003000/* Paging by CGI with unknown MCC/MNC: Verify nothing is paged. */
3001testcase TC_paging_imsi_nochan_cgi_unknown_cid() runs on test_CT {
3002 var template BSSMAP_FIELD_CellIdentificationList cid_list;
3003 cid_list := { cIl_CGI := { ts_BSSMAP_CI_CGI(unknown_cid.mcc, unknown_cid.mnc, unknown_cid.lac, unknown_cid.ci) } };
3004 f_pageing_helper('001010000000006'H, cid_list, c_BtsId_none);
3005 f_shutdown_helper();
3006}
3007
Harald Welte6f521d82017-12-11 19:52:02 +01003008/* Verify paging retransmission interval + count */
3009/* Verify paging stops after channel establishment */
Harald Welte6f521d82017-12-11 19:52:02 +01003010/* Test behavior under paging overload */
Harald Welteae026692017-12-09 01:03:01 +01003011
Harald Weltee65d40e2017-12-13 00:09:06 +01003012/* Verify PCH load */
3013testcase TC_paging_imsi_load() runs on test_CT {
3014 var BSSMAP_FIELD_CellIdentificationList cid_list;
3015 timer T := 4.0;
Harald Welte2caa1062018-03-17 18:19:05 +01003016 timer T_retrans := 1.0;
Harald Weltee65d40e2017-12-13 00:09:06 +01003017 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01003018 f_pageing_helper('001010123456789'H, cid_list, c_BtsId_all);
Harald Weltee65d40e2017-12-13 00:09:06 +01003019
3020 /* tell BSC there is no paging space anymore */
3021 f_ipa_tx(0, ts_RSL_PAGING_LOAD_IND(0));
Harald Welte3b57ab52018-03-17 18:01:10 +01003022 f_sleep(0.2);
3023 IPA_RSL[0].clear;
Harald Weltee65d40e2017-12-13 00:09:06 +01003024
3025 /* Wait for 4 seconds if any more PAGING CMD are received on RSL. Normally,
3026 * there would be 8 retransmissions during 4 seconds */
3027 T.start;
Harald Welte2caa1062018-03-17 18:19:05 +01003028 T_retrans.start;
Harald Weltee65d40e2017-12-13 00:09:06 +01003029 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07003030 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD(?))) {
Harald Weltee65d40e2017-12-13 00:09:06 +01003031 setverdict(fail, "Received PAGING after LOAD_IND(0)");
Daniel Willmannafce8662018-07-06 23:11:32 +02003032 mtc.stop;
Harald Weltee65d40e2017-12-13 00:09:06 +01003033 }
Harald Welte2caa1062018-03-17 18:19:05 +01003034 [] T_retrans.timeout {
3035 /* re-trnsmit the zero-space LOAD IND to avoid BSC 'auto credit' */
3036 f_ipa_tx(0, ts_RSL_PAGING_LOAD_IND(0));
3037 T_retrans.start;
3038 repeat;
3039 }
Harald Weltee65d40e2017-12-13 00:09:06 +01003040 [] T.timeout {
3041 setverdict(pass);
3042 }
3043 }
Philipp Maier282ca4b2018-02-27 17:17:00 +01003044
3045 f_shutdown_helper();
Harald Weltee65d40e2017-12-13 00:09:06 +01003046}
3047
Harald Welte235ebf12017-12-15 14:18:16 +01003048/* Verify Paging Counter */
Harald Welte1ff69992017-12-14 12:31:17 +01003049testcase TC_paging_counter() runs on test_CT {
3050 var BSSMAP_FIELD_CellIdentificationList cid_list;
3051 timer T := 4.0;
3052 var integer i;
3053 var integer paging_attempted_bsc;
3054 var integer paging_attempted_bts[NUM_BTS];
3055 var integer paging_expired_bts[NUM_BTS];
3056 cid_list := valueof(ts_BSSMAP_CIL_noCell);
3057
3058 f_init();
3059
3060 /* read counters before paging */
3061 paging_attempted_bsc := f_ctrl_get_ratectr_abs(IPA_CTRL, "bsc", 0, "paging:attempted");
3062 for (i := 0; i < NUM_BTS; i := i+1) {
3063 paging_attempted_bts[i] := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", i, "paging:attempted");
3064 paging_expired_bts[i] := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", i, "paging:expired");
3065 }
3066
3067 f_pageing_helper('001230000000001'H, cid_list, c_BtsId_all);
3068
3069 /* expect the attempted pages on BSC and each BTSs to have incremented by one */
3070 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bsc", 0, "paging:attempted", paging_attempted_bsc+1);
3071 for (i := 0; i < NUM_BTS; i := i+1) {
3072 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", i, "paging:attempted",
3073 paging_attempted_bts[i]+1);
3074 }
3075
3076 /* assume that 12s later the paging on all BTSs have expired and hence incremented by 1 */
3077 f_sleep(12.0);
3078 for (i := 0; i < NUM_BTS; i := i+1) {
3079 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", i, "paging:expired",
3080 paging_expired_bts[i]+1);
3081 }
Harald Welte1ff69992017-12-14 12:31:17 +01003082
Philipp Maier282ca4b2018-02-27 17:17:00 +01003083 f_shutdown_helper();
Harald Welte1ff69992017-12-14 12:31:17 +01003084}
3085
3086
Harald Welte10985002017-12-12 09:29:15 +01003087/* Verify paging stops after A-RESET */
3088testcase TC_paging_imsi_a_reset() runs on test_CT {
3089 var BSSMAP_FIELD_CellIdentificationList cid_list;
3090 timer T := 3.0;
3091 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01003092 f_pageing_helper('001010123456789'H, cid_list, c_BtsId_all);
Harald Welte10985002017-12-12 09:29:15 +01003093
3094 /* Perform a BSSMAP Reset and wait for ACK */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003095 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 +01003096 alt {
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003097 [] 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 +01003098 [] BSSAP.receive { repeat; }
3099 }
3100
Daniel Willmanncbef3982018-07-30 09:22:40 +02003101 /* Wait to avoid a possible race condition if a paging message is
3102 * received right before the reset ACK. */
3103 f_sleep(0.2);
3104
Harald Welte10985002017-12-12 09:29:15 +01003105 /* Clear the queue, it might still contain stuff like BCCH FILLING */
Philipp Maier1e6b4422018-02-23 14:02:13 +01003106 for (var integer i := 0; i < sizeof(IPA_RSL); i := i+1) {
3107 IPA_RSL[i].clear;
3108 }
Harald Welte10985002017-12-12 09:29:15 +01003109
3110 /* Wait for 3 seconds if any more PAGING CMD are received on RSL */
3111 T.start;
3112 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07003113 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD(?))) {
Harald Welte10985002017-12-12 09:29:15 +01003114 setverdict(fail, "Received PAGING after A-RESET");
Daniel Willmannafce8662018-07-06 23:11:32 +02003115 mtc.stop;
Harald Welte10985002017-12-12 09:29:15 +01003116 }
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07003117 [] IPA_RSL[1].receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD(?))) {
Harald Welte5d1a2202017-12-13 19:51:29 +01003118 setverdict(fail, "Received PAGING after A-RESET");
Daniel Willmannafce8662018-07-06 23:11:32 +02003119 mtc.stop;
Harald Welte5d1a2202017-12-13 19:51:29 +01003120 }
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07003121 [] IPA_RSL[2].receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD(?))) {
Harald Welte5d1a2202017-12-13 19:51:29 +01003122 setverdict(fail, "Received PAGING after A-RESET");
Daniel Willmannafce8662018-07-06 23:11:32 +02003123 mtc.stop;
Harald Welte5d1a2202017-12-13 19:51:29 +01003124 }
Harald Welte10985002017-12-12 09:29:15 +01003125 [] T.timeout {
3126 setverdict(pass);
3127 }
3128 }
Philipp Maier282ca4b2018-02-27 17:17:00 +01003129
3130 f_shutdown_helper();
Harald Welte10985002017-12-12 09:29:15 +01003131}
Harald Welteae026692017-12-09 01:03:01 +01003132
Philipp Maierf45824a2019-08-14 14:44:10 +02003133/* Verify how we handle unsolicited Paging Response. In case of an unsolicit
3134 * paging response we can not know which MSC is in charge, so we will blindly
3135 * pick the first configured MSC. This behavior is required in order to make
3136 * MT-CSFB calls working because in those cases the BSC can not know that the
3137 * MSC has already paged the subscriver via SGs. So any MT-CSFB call will look
3138 * like an unsolicited Paging Response to the MSC.
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01003139 */
3140testcase TC_paging_resp_unsol() runs on test_CT {
3141
3142 f_init(1);
Philipp Maierf45824a2019-08-14 14:44:10 +02003143 timer T := 5.0;
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01003144
3145 var BSSAP_N_CONNECT_ind rx_c_ind;
3146 var DchanTuple dt;
3147 var PDU_ML3_MS_NW l3 := valueof(ts_PAG_RESP(valueof(ts_MI_IMSI_LV('001010008880018'H))));
Philipp Maierf45824a2019-08-14 14:44:10 +02003148 var octetstring rr_pag_resp := enc_PDU_ML3_MS_NW(l3);
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01003149
3150 /* Send CHAN RQD and wait for allocation; acknowledge it */
3151 dt.rsl_chan_nr := f_chreq_act_ack();
3152
3153 /* Send unsolicited Paging response (no matching Paging CMD stored in BSC) */
3154 f_ipa_tx(0, ts_RSL_EST_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0)), enc_PDU_ML3_MS_NW(l3)));
3155
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01003156
Philipp Maierf45824a2019-08-14 14:44:10 +02003157 /* Expevct a CR with a matching Paging response on the A-Interface */
3158 T.start;
3159 alt {
3160 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(rr_pag_resp))) {
3161 setverdict(pass);
3162 }
3163 [] BSSAP.receive {
3164 setverdict(fail, "Received unexpected message on A-Interface!");
3165 }
3166 [] T.timeout {
3167 setverdict(fail, "Received nothing on A-Interface!");
3168 }
3169 }
3170
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003171 f_shutdown_helper();
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01003172}
3173
Harald Welte4e9b9cc2017-12-14 18:31:02 +01003174/* Test RSL link drop causes counter increment */
3175testcase TC_rsl_drop_counter() runs on test_CT {
3176 var integer rsl_fail;
3177
Harald Welte89d42e82017-12-17 16:42:41 +01003178 f_init(1);
Harald Welte4e9b9cc2017-12-14 18:31:02 +01003179
3180 rsl_fail := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "rsl_fail");
3181
3182 bts[0].rsl.vc_IPA.stop;
3183
3184 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "rsl_fail", rsl_fail+1);
3185
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003186 f_shutdown_helper();
Harald Welte4e9b9cc2017-12-14 18:31:02 +01003187}
3188
3189/* TODO: Test OML link drop causes counter increment */
3190
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003191/* The body of TC_rsl_unknown_unit_id() and TC_oml_unknown_unit_id() tests. */
3192function f_ipa_unknown_unit_id(integer mp_bsc_ipa_port) runs on test_CT return boolean {
3193 timer T := 10.0;
3194
3195 bts[0].rsl.id := "IPA-0-RSL";
3196 bts[0].rsl.vc_IPA := IPA_Emulation_CT.create(bts[0].rsl.id & "-IPA");
3197 bts[0].rsl.ccm_pars := c_IPA_default_ccm_pars;
3198 bts[0].rsl.ccm_pars.name := "Osmocom TTCN-3 BTS Simulator";
Oliver Smith92c2bdb2019-08-20 15:11:24 +02003199 bts[0].rsl.ccm_pars.unit_id := "99/0/0"; /* value which is unknown at BTS */
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003200
Pau Espin Pedrol9a5b8ff2021-01-04 19:01:31 +01003201 f_ipa_ctrl_start_client(mp_bsc_ip, mp_bsc_ctrl_port);
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003202
3203 f_init_mgcp("VirtMSC");
3204
3205 /* start RSL/OML connection (XXX re-uses RSL port/protocol definitions for OML) */
3206 map(bts[0].rsl.vc_IPA:IPA_PORT, system:IPA);
3207 connect(bts[0].rsl.vc_IPA:IPA_RSL_PORT, self:IPA_RSL[0]);
3208 bts[0].rsl.vc_IPA.start(IPA_Emulation.main_client(mp_bsc_ip, mp_bsc_ipa_port, "", 10000, bts[0].rsl.ccm_pars));
3209
3210 /* wait for IPA OML link to connect and then disconnect */
3211 T.start;
3212 alt {
Vadim Yanitskiya2afacc2020-05-18 21:16:19 +07003213 [] IPA_RSL[0].receive(tr_ASP_IPA_EV(ASP_IPA_EVENT_DOWN)) {
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003214 T.stop;
3215 return true;
3216 }
3217 [] IPA_RSL[0].receive { repeat }
3218 [] T.timeout {
Daniel Willmannafce8662018-07-06 23:11:32 +02003219 return false;
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003220 }
3221 }
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003222 return false;
3223}
3224
3225/* BSC should close an RSL connection from a BTS with unknown unit ID (OS#2714). */
3226testcase TC_rsl_unknown_unit_id() runs on test_CT {
3227 if (f_ipa_unknown_unit_id(mp_bsc_rsl_port)) {
3228 setverdict(pass);
3229 } else {
3230 setverdict(fail, "Timeout RSL waiting for connection to close");
3231 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003232 f_shutdown_helper();
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003233}
3234
3235
3236/* BSC should close an RSL connection from a BTS with unknown unit ID (OS#2714). */
3237testcase TC_oml_unknown_unit_id() runs on test_CT {
3238 if (f_ipa_unknown_unit_id(mp_bsc_oml_port)) {
3239 setverdict(pass);
3240 } else {
3241 setverdict(fail, "Timeout OML waiting for connection to close");
3242 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003243 f_shutdown_helper();
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003244}
3245
3246
Harald Weltec1a2fff2017-12-17 11:06:19 +01003247/***********************************************************************
Harald Welte6811d102019-04-14 22:23:14 +02003248 * "New world" test cases using RSL_Emulation + RAN_Emulation
Harald Weltec1a2fff2017-12-17 11:06:19 +01003249 ***********************************************************************/
3250
Harald Welte6811d102019-04-14 22:23:14 +02003251import from RAN_Emulation all;
Harald Welte47cd0e32020-08-21 12:39:11 +02003252import from BSSAP_LE_Emulation all;
Harald Weltec1a2fff2017-12-17 11:06:19 +01003253import from RSL_Emulation all;
3254import from MSC_ConnectionHandler all;
3255
3256type function void_fn(charstring id) runs on MSC_ConnHdlr;
3257
Harald Welte336820c2018-05-31 20:34:52 +02003258/* helper function to create and connect a MSC_ConnHdlr component */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003259private function f_connect_handler(inout MSC_ConnHdlr vc_conn, integer bssap_idx := 0) runs on test_CT {
3260 connect(vc_conn:RAN, g_bssap[bssap_idx].vc_RAN:PROC);
Daniel Willmann191e0d92018-01-17 12:44:35 +01003261 connect(vc_conn:MGCP_PROC, vc_MGCP:MGCP_PROC);
Harald Weltec1a2fff2017-12-17 11:06:19 +01003262 connect(vc_conn:RSL, bts[0].rsl.vc_RSL:CLIENT_PT);
Harald Weltef70df652018-01-29 22:00:23 +01003263 connect(vc_conn:RSL_PROC, bts[0].rsl.vc_RSL:RSL_PROC);
Philipp Maier88f4ae82018-03-01 14:00:58 +01003264 if (isvalue(bts[1])) {
Philipp Maier956a92f2018-02-16 10:58:07 +01003265 connect(vc_conn:RSL1, bts[1].rsl.vc_RSL:CLIENT_PT);
3266 connect(vc_conn:RSL1_PROC, bts[1].rsl.vc_RSL:RSL_PROC);
3267 }
Neels Hofmeyr91401012019-07-11 00:42:35 +02003268 if (isvalue(bts[2])) {
3269 connect(vc_conn:RSL2, bts[2].rsl.vc_RSL:CLIENT_PT);
3270 connect(vc_conn:RSL2_PROC, bts[2].rsl.vc_RSL:RSL_PROC);
3271 }
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003272 connect(vc_conn:BSSAP, g_bssap[bssap_idx].vc_RAN:CLIENT);
Neels Hofmeyrcfe44062020-10-15 02:28:08 +02003273 if (mp_enable_lcs_tests) {
3274 connect(vc_conn:BSSAP_LE, g_bssap_le.vc_BSSAP_LE:CLIENT);
3275 connect(vc_conn:BSSAP_LE_PROC, g_bssap_le.vc_BSSAP_LE:PROC);
3276 }
Daniel Willmann191e0d92018-01-17 12:44:35 +01003277 connect(vc_conn:MGCP, vc_MGCP:MGCP_CLIENT);
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +02003278 connect(vc_conn:MGCP_MULTI, vc_MGCP:MGCP_CLIENT_MULTI);
Daniel Willmannebdecc02020-08-12 15:30:17 +02003279 connect(vc_conn:STATSD_PROC, vc_STATSD:STATSD_PROC);
Harald Welte336820c2018-05-31 20:34:52 +02003280}
3281
3282function f_start_handler(void_fn fn, template (omit) TestHdlrParams pars := omit)
3283runs on test_CT return MSC_ConnHdlr {
3284 var charstring id := testcasename();
3285 var MSC_ConnHdlr vc_conn;
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003286 var integer bssap_idx := 0;
3287 if (isvalue(pars)) {
3288 bssap_idx := valueof(pars).mscpool.bssap_idx;
3289 }
Harald Welte336820c2018-05-31 20:34:52 +02003290 vc_conn := MSC_ConnHdlr.create(id);
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003291 f_connect_handler(vc_conn, bssap_idx);
Neels Hofmeyr1708d1b2020-10-10 16:56:48 +02003292 /* Emit a marker to appear in the SUT's own logging output */
3293 f_logp(BSCVTY, testcasename() & "() start");
Harald Weltea0630032018-03-20 21:09:55 +01003294 vc_conn.start(f_handler_init(fn, id, pars));
Harald Weltec1a2fff2017-12-17 11:06:19 +01003295 return vc_conn;
3296}
3297
Harald Weltea0630032018-03-20 21:09:55 +01003298/* first function inside ConnHdlr component; sets g_pars + starts function */
3299private function f_handler_init(void_fn fn, charstring id, template (omit) TestHdlrParams pars := omit)
3300runs on MSC_ConnHdlr {
3301 if (isvalue(pars)) {
3302 g_pars := valueof(pars);
3303 }
3304 fn.apply(id);
3305}
3306
Oliver Smith26a3db72021-07-09 13:51:29 +02003307private function f_vty_encryption_a5(charstring options) runs on test_CT {
3308 f_vty_transceive(BSCVTY, "configure terminal");
3309 f_vty_transceive(BSCVTY, "network");
3310 f_vty_transceive(BSCVTY, "encryption a5 " & options);
3311 f_vty_transceive(BSCVTY, "exit");
3312 f_vty_transceive(BSCVTY, "exit");
3313}
3314
3315private function f_vty_encryption_a5_reset() runs on test_CT {
3316 /* keep in sync with docker-playground.git ttcn3-bsc-test/osmo-bsc.cfg */
3317 f_vty_encryption_a5("0 1 3");
3318}
3319
Harald Welte3c86ea02018-05-10 22:28:05 +02003320/* Establish signalling channel (non-assignment case) followed by cipher mode */
3321private function f_tc_ciph_mode_a5(charstring id) runs on MSC_ConnHdlr {
Harald Welteed848512018-05-24 22:27:58 +02003322 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3323 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte3c86ea02018-05-10 22:28:05 +02003324 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeSIGNAL);
Philipp Maier23000732018-05-18 11:25:37 +02003325 ass_cmd.pdu.bssmap.assignmentRequest.circuitIdentityCode := omit;
3326 ass_cmd.pdu.bssmap.assignmentRequest.aoIPTransportLayer := omit;
3327 exp_compl.pdu.bssmap.assignmentComplete.circuitIdentityCode := omit;
3328 exp_compl.pdu.bssmap.assignmentComplete.aoIPTransportLayer := omit;
Harald Welte3c86ea02018-05-10 22:28:05 +02003329
Philipp Maier23000732018-05-18 11:25:37 +02003330 f_establish_fully(ass_cmd, exp_compl);
Harald Welte3c86ea02018-05-10 22:28:05 +02003331}
3332testcase TC_ciph_mode_a5_0() runs on test_CT {
3333 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02003334 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte3c86ea02018-05-10 22:28:05 +02003335 pars.encr := valueof(t_EncrParams('01'O, f_rnd_octstring(8)));
3336
3337 f_init(1, true);
3338 f_sleep(1.0);
3339 vc_conn := f_start_handler(refers(f_tc_ciph_mode_a5), pars);
3340 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003341 f_shutdown_helper();
Harald Welte3c86ea02018-05-10 22:28:05 +02003342}
3343testcase TC_ciph_mode_a5_1() runs on test_CT {
3344 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02003345 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte3c86ea02018-05-10 22:28:05 +02003346 pars.encr := valueof(t_EncrParams('02'O, f_rnd_octstring(8)));
3347
3348 f_init(1, true);
3349 f_sleep(1.0);
3350 vc_conn := f_start_handler(refers(f_tc_ciph_mode_a5), pars);
3351 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003352 f_shutdown_helper();
Harald Welte3c86ea02018-05-10 22:28:05 +02003353}
Oliver Smith50b98122021-07-09 15:00:28 +02003354/* OS#4975: verify that A5/2 is preferred over A5/0 */
3355testcase TC_ciph_mode_a5_2_0() runs on test_CT {
3356 var MSC_ConnHdlr vc_conn;
3357 var TestHdlrParams pars := f_gen_test_hdlr_pars();
3358
3359 pars.encr := valueof(t_EncrParams('05'O, f_rnd_octstring(8))); /* A5/0 and A5/2 (0x01|0x04)*/
3360 pars.encr_exp_enc_alg := '04'O; /* A5/2 */
3361
3362 f_init(1, true);
3363 f_vty_encryption_a5("0 1 2 3");
3364 f_sleep(1.0);
3365 vc_conn := f_start_handler(refers(f_tc_ciph_mode_a5), pars);
3366 vc_conn.done;
3367 f_vty_encryption_a5_reset();
3368 f_shutdown_helper();
3369}
Oliver Smith1dff88d2021-07-09 08:45:51 +02003370/* OS#4975: verify that A5/1 is preferred over A5/2 */
3371testcase TC_ciph_mode_a5_2_1() runs on test_CT {
3372 var MSC_ConnHdlr vc_conn;
3373 var TestHdlrParams pars := f_gen_test_hdlr_pars();
3374
3375 pars.encr := valueof(t_EncrParams('06'O, f_rnd_octstring(8))); /* A5/1 and A5/2 (0x02|0x04)*/
3376 pars.encr_exp_enc_alg := '02'O; /* A5/1 */
3377
3378 f_init(1, true);
3379 f_vty_encryption_a5("1 2");
3380 f_sleep(1.0);
3381 vc_conn := f_start_handler(refers(f_tc_ciph_mode_a5), pars);
3382 vc_conn.done;
3383 f_vty_encryption_a5_reset();
3384 f_shutdown_helper();
3385}
Harald Welte3c86ea02018-05-10 22:28:05 +02003386testcase TC_ciph_mode_a5_3() runs on test_CT {
3387 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02003388 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte3c86ea02018-05-10 22:28:05 +02003389 pars.encr := valueof(t_EncrParams('08'O, f_rnd_octstring(8)));
3390
3391 f_init(1, true);
3392 f_sleep(1.0);
3393 vc_conn := f_start_handler(refers(f_tc_ciph_mode_a5), pars);
3394 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003395 f_shutdown_helper();
Harald Welte3c86ea02018-05-10 22:28:05 +02003396}
Neels Hofmeyr81ad27f2021-06-11 00:09:40 +02003397/* Establish a Signalling channel with A5/4 encryption. */
3398testcase TC_ciph_mode_a5_4() runs on test_CT {
3399 var MSC_ConnHdlr vc_conn;
3400 var TestHdlrParams pars := f_gen_test_hdlr_pars();
3401 pars.encr := valueof(t_EncrParams('10'O, f_rnd_octstring(8), f_rnd_octstring(16)));
Harald Welte3c86ea02018-05-10 22:28:05 +02003402
Neels Hofmeyr81ad27f2021-06-11 00:09:40 +02003403 f_init(1, true);
Oliver Smith26a3db72021-07-09 13:51:29 +02003404 f_vty_encryption_a5("0 1 3 4");
Neels Hofmeyr81ad27f2021-06-11 00:09:40 +02003405 f_sleep(1.0);
3406 vc_conn := f_start_handler(refers(f_tc_ciph_mode_a5), pars);
3407 vc_conn.done;
Oliver Smith26a3db72021-07-09 13:51:29 +02003408 f_vty_encryption_a5_reset();
Neels Hofmeyr81ad27f2021-06-11 00:09:40 +02003409 f_shutdown_helper();
3410}
Pau Espin Pedrol07866632020-09-03 19:10:55 +02003411/* establish initial channel, enable ciphering followed by assignment to ciphered channel */
3412private function f_tc_assignment_aoip_tla_v6(charstring id) runs on MSC_ConnHdlr {
3413 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3414 var PDU_BSSAP ass_cmd := f_gen_ass_req(aoip_tla := "::3");
3415 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3416 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
3417
3418 f_establish_fully(ass_cmd, exp_compl);
3419}
3420testcase TC_assignment_aoip_tla_v6() runs on test_CT {
3421 var MSC_ConnHdlr vc_conn;
3422 var TestHdlrParams pars := f_gen_test_hdlr_pars();
3423
3424 f_init(1, true);
3425 f_sleep(1.0);
3426 vc_conn := f_start_handler(refers(f_tc_assignment_aoip_tla_v6), pars);
3427 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003428 f_shutdown_helper();
Pau Espin Pedrol07866632020-09-03 19:10:55 +02003429}
3430
Harald Welte3c86ea02018-05-10 22:28:05 +02003431
3432/* establish initial channel, enable ciphering followed by assignment to ciphered channel */
Harald Welte651fcdc2018-05-10 20:23:16 +02003433private function f_tc_assignment_fr_a5(charstring id) runs on MSC_ConnHdlr {
Harald Welteed848512018-05-24 22:27:58 +02003434 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3435 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Weltec1a2fff2017-12-17 11:06:19 +01003436
Harald Welte552620d2017-12-16 23:21:36 +01003437 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3438 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
Harald Welte73cd2712017-12-17 00:44:52 +01003439
Harald Weltea0630032018-03-20 21:09:55 +01003440 f_establish_fully(ass_cmd, exp_compl);
Harald Welte552620d2017-12-16 23:21:36 +01003441}
Harald Welte552620d2017-12-16 23:21:36 +01003442testcase TC_assignment_fr_a5_0() runs on test_CT {
3443 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02003444 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte651fcdc2018-05-10 20:23:16 +02003445 pars.encr := valueof(t_EncrParams('01'O, f_rnd_octstring(8)));
Harald Welte552620d2017-12-16 23:21:36 +01003446
Harald Welte89d42e82017-12-17 16:42:41 +01003447 f_init(1, true);
Harald Welte552620d2017-12-16 23:21:36 +01003448 f_sleep(1.0);
Harald Welte651fcdc2018-05-10 20:23:16 +02003449 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5), pars);
Harald Welte552620d2017-12-16 23:21:36 +01003450 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003451 f_shutdown_helper();
Harald Welte552620d2017-12-16 23:21:36 +01003452}
Harald Welte552620d2017-12-16 23:21:36 +01003453testcase TC_assignment_fr_a5_1() runs on test_CT {
Harald Weltec1a2fff2017-12-17 11:06:19 +01003454 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02003455 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte651fcdc2018-05-10 20:23:16 +02003456 pars.encr := valueof(t_EncrParams('02'O, f_rnd_octstring(8)));
Harald Weltec1a2fff2017-12-17 11:06:19 +01003457
Harald Welte89d42e82017-12-17 16:42:41 +01003458 f_init(1, true);
Harald Weltec1a2fff2017-12-17 11:06:19 +01003459 f_sleep(1.0);
Harald Welte651fcdc2018-05-10 20:23:16 +02003460 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5), pars);
3461 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003462 f_shutdown_helper();
Harald Welte651fcdc2018-05-10 20:23:16 +02003463}
3464testcase TC_assignment_fr_a5_3() runs on test_CT {
3465 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02003466 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte651fcdc2018-05-10 20:23:16 +02003467 pars.encr := valueof(t_EncrParams('08'O, f_rnd_octstring(8)));
Harald Weltec1a2fff2017-12-17 11:06:19 +01003468
Harald Welte651fcdc2018-05-10 20:23:16 +02003469 f_init(1, true);
3470 f_sleep(1.0);
3471 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5), pars);
Harald Weltec1a2fff2017-12-17 11:06:19 +01003472 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003473 f_shutdown_helper();
Harald Weltec1a2fff2017-12-17 11:06:19 +01003474}
Neels Hofmeyr0d8ec532021-06-11 00:09:48 +02003475/* Establish a Signalling channel and re-assign to TCH/F with A5/4 encryption. */
3476testcase TC_assignment_fr_a5_4() runs on test_CT {
3477 var MSC_ConnHdlr vc_conn;
3478 var TestHdlrParams pars := f_gen_test_hdlr_pars();
3479 pars.encr := valueof(t_EncrParams('10'O, f_rnd_octstring(8), f_rnd_octstring(16)));
3480
3481 f_init(1, true);
3482 f_sleep(1.0);
3483 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5), pars);
3484 vc_conn.done;
3485 f_shutdown_helper();
3486}
Harald Weltec1a2fff2017-12-17 11:06:19 +01003487
Neels Hofmeyr0faeb7a2021-06-10 23:59:35 +02003488/* Allow only A5/4, but omit the Kc128 IE from MSC's msg. Expect Cipher Mode Reject. */
3489testcase TC_assignment_fr_a5_4_fail() runs on test_CT {
3490 var TestHdlrParams pars := f_gen_test_hdlr_pars();
3491 var MSC_ConnHdlr vc_conn;
3492
3493 f_init(1, true);
3494 f_sleep(1.0);
3495
3496 pars.encr := valueof(t_EncrParams('10'O, f_rnd_octstring(8))); // A5/4 support, but Kc128 missing!
3497 vc_conn := f_start_handler(refers(f_TC_assignment_a5_not_sup), pars);
3498 vc_conn.done;
3499 f_shutdown_helper();
3500}
3501
Harald Welte552620d2017-12-16 23:21:36 +01003502/* Expect ASSIGNMENT FAIL if mandatory IE is missing */
3503private function f_tc_assignment_fr_a5_1_codec_missing(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02003504 g_pars := f_gen_test_hdlr_pars();
Harald Welte552620d2017-12-16 23:21:36 +01003505 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
Harald Welteed848512018-05-24 22:27:58 +02003506 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte552620d2017-12-16 23:21:36 +01003507
3508 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02003509 /* Omit: ass_cmd.pdu.bssmap.assignmentRequest.codecList */
3510
Harald Weltea0630032018-03-20 21:09:55 +01003511 f_establish_fully(ass_cmd, exp_fail);
Harald Welte552620d2017-12-16 23:21:36 +01003512}
Harald Welte552620d2017-12-16 23:21:36 +01003513testcase TC_assignment_fr_a5_1_codec_missing() runs on test_CT {
3514 var MSC_ConnHdlr vc_conn;
3515
Harald Welte89d42e82017-12-17 16:42:41 +01003516 f_init(1, true);
Harald Welte552620d2017-12-16 23:21:36 +01003517 f_sleep(1.0);
3518
Harald Welte8863fa12018-05-10 20:15:27 +02003519 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5_1_codec_missing));
Harald Welte552620d2017-12-16 23:21:36 +01003520 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003521 f_shutdown_helper();
Harald Welte552620d2017-12-16 23:21:36 +01003522}
3523
Neels Hofmeyr04d6e6a2021-06-11 00:10:02 +02003524private function f_TC_assignment_a5_not_sup(charstring id) runs on MSC_ConnHdlr {
3525 var template PDU_BSSAP exp_ass_cpl := f_gen_exp_compl();
3526 var PDU_BSSAP exp_ass_req := f_gen_ass_req();
Harald Welte552620d2017-12-16 23:21:36 +01003527
Neels Hofmeyr04d6e6a2021-06-11 00:10:02 +02003528 exp_ass_req.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3529 exp_ass_req.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
3530
3531 /* this is like the beginning of f_establish_fully(), but only up to ciphering reject */
3532
3533 var BSSMAP_FIELD_CodecType codecType;
3534 timer T := 10.0;
3535
3536 codecType := exp_ass_req.pdu.bssmap.assignmentRequest.codecList.codecElements[0].codecType;
3537 f_MscConnHdlr_init(g_pars.media_nr, host_bts, host_mgw_mgcp, codecType);
3538
3539 f_create_chan_and_exp();
3540 /* we should now have a COMPL_L3 at the MSC */
3541
3542 var template PDU_BSSAP exp_l3_compl;
3543 exp_l3_compl := tr_BSSMAP_ComplL3()
3544 if (g_pars.aoip == false) {
3545 exp_l3_compl.pdu.bssmap.completeLayer3Information.codecList := omit;
3546 } else {
3547 exp_l3_compl.pdu.bssmap.completeLayer3Information.codecList := ?;
3548 }
3549 T.start;
3550 alt {
3551 [] BSSAP.receive(exp_l3_compl);
3552 [] BSSAP.receive(tr_BSSMAP_ComplL3) {
3553 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Received non-matching COMPLETE LAYER 3 INFORMATION");
3554 }
3555 [] T.timeout {
3556 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for COMPLETE LAYER 3 INFORMATION");
3557 }
3558 }
3559
3560 /* Start ciphering, expect Cipher Mode Reject */
Neels Hofmeyr6c388f22021-06-11 02:36:56 +02003561 f_cipher_mode(g_pars.encr, exp_fail := true);
Harald Welte552620d2017-12-16 23:21:36 +01003562}
Neels Hofmeyr04d6e6a2021-06-11 00:10:02 +02003563testcase TC_assignment_fr_a5_not_sup() runs on test_CT {
3564 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte552620d2017-12-16 23:21:36 +01003565 var MSC_ConnHdlr vc_conn;
3566
Harald Welte89d42e82017-12-17 16:42:41 +01003567 f_init(1, true);
Harald Welte552620d2017-12-16 23:21:36 +01003568 f_sleep(1.0);
3569
Neels Hofmeyr0588cad2021-06-11 01:38:18 +02003570 pars.encr := valueof(t_EncrParams('20'O, f_rnd_octstring(8), f_rnd_octstring(16)));
Neels Hofmeyr04d6e6a2021-06-11 00:10:02 +02003571 vc_conn := f_start_handler(refers(f_TC_assignment_a5_not_sup), pars);
Harald Welte552620d2017-12-16 23:21:36 +01003572 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003573 f_shutdown_helper();
Harald Welte552620d2017-12-16 23:21:36 +01003574}
3575
3576
Harald Welte4532e0a2017-12-23 02:05:44 +01003577private function f_tc_assignment_sign(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02003578 g_pars := f_gen_test_hdlr_pars();
Harald Welte4532e0a2017-12-23 02:05:44 +01003579 var template PDU_BSSAP exp_compl := tr_BSSMAP_AssignmentComplete(omit, omit);
Philipp Maier48604732018-10-09 15:00:37 +02003580 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte4532e0a2017-12-23 02:05:44 +01003581 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeSIGNAL);
Daniel Willmannebdecc02020-08-12 15:30:17 +02003582
3583 f_statsd_reset();
Harald Weltea0630032018-03-20 21:09:55 +01003584 f_establish_fully(ass_cmd, exp_compl);
Daniel Willmannebdecc02020-08-12 15:30:17 +02003585
3586 var StatsDExpects expect := {
Daniel Willmannc5398f72020-09-21 10:41:35 +02003587 { name := "TTCN3.bts.0.chreq.total", mtype := "c", min := 1, max := 1},
3588 { name := "TTCN3.bts.0.chreq.successful", mtype := "c", min := 1, max := 1},
Daniel Willmannebdecc02020-08-12 15:30:17 +02003589 { name := "TTCN3.bsc.0.assignment.attempted", mtype := "c", min := 1, max := 1},
3590 { name := "TTCN3.bsc.0.assignment.completed", mtype := "c", min := 1, max := 1}
3591 };
3592 f_statsd_expect(expect);
Harald Welte4532e0a2017-12-23 02:05:44 +01003593}
3594
3595testcase TC_assignment_sign() runs on test_CT {
3596 var MSC_ConnHdlr vc_conn;
3597
3598 f_init(1, true);
3599 f_sleep(1.0);
3600
Harald Welte8863fa12018-05-10 20:15:27 +02003601 vc_conn := f_start_handler(refers(f_tc_assignment_sign));
Harald Welte4532e0a2017-12-23 02:05:44 +01003602 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003603 f_shutdown_helper();
Harald Welte4532e0a2017-12-23 02:05:44 +01003604}
3605
Harald Welte60aa5762018-03-21 19:33:13 +01003606/***********************************************************************
3607 * Codec (list) testing
3608 ***********************************************************************/
3609
3610/* check if the given rsl_mode is compatible with the a_elem */
3611private function f_match_codec(BSSMAP_FIELD_CodecElement a_elem, RSL_IE_ChannelMode rsl_mode)
3612return boolean {
3613 select (a_elem.codecType) {
3614 case (GSM_FR) {
3615 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM1))) {
3616 return true;
3617 }
3618 }
3619 case (GSM_HR) {
3620 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_H, RSL_CMOD_SP_GSM1))) {
3621 return true;
3622 }
3623 }
3624 case (GSM_EFR) {
3625 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM2))) {
3626 return true;
3627 }
3628 }
3629 case (FR_AMR) {
3630 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM3))) {
3631 return true;
3632 }
3633 }
3634 case (HR_AMR) {
3635 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_H, RSL_CMOD_SP_GSM3))) {
3636 return true;
3637 }
3638 }
3639 case else { }
3640 }
3641 return false;
3642}
3643
3644/* check if the given rsl_mode is compatible with the a_list */
3645private function f_match_codecs(BSSMAP_IE_SpeechCodecList a_list, RSL_IE_ChannelMode rsl_mode)
3646return boolean {
3647 for (var integer i := 0; i < sizeof(a_list); i := i+1) {
3648 if (f_match_codec(a_list.codecElements[i], rsl_mode)) {
3649 return true;
3650 }
3651 }
3652 return false;
3653}
3654
3655/* determine BSSMAP_IE_ChannelType from *first* element of BSSMAP_FIELD_CodecElement */
Philipp Maier61f6b572018-07-06 14:03:38 +02003656function f_BSSMAP_chtype_from_codec(BSSMAP_FIELD_CodecElement a_elem)
Harald Welte60aa5762018-03-21 19:33:13 +01003657return BSSMAP_IE_ChannelType {
3658 /* FIXME: actually look at all elements of BSSMAP_IE_SpeechCodecList */
3659 var BSSMAP_IE_ChannelType ret := valueof(ts_BSSMAP_IE_ChannelType);
3660 select (a_elem.codecType) {
3661 case (GSM_FR) {
3662 ret.channelRateAndType := ChRate_TCHF;
3663 ret.speechId_DataIndicator := Spdi_TCHF_FR;
3664 }
3665 case (GSM_HR) {
3666 ret.channelRateAndType := ChRate_TCHH;
3667 ret.speechId_DataIndicator := Spdi_TCHH_HR;
3668 }
3669 case (GSM_EFR) {
3670 ret.channelRateAndType := ChRate_TCHF;
3671 ret.speechId_DataIndicator := Spdi_TCHF_EFR;
3672 }
3673 case (FR_AMR) {
3674 ret.channelRateAndType := ChRate_TCHF;
3675 ret.speechId_DataIndicator := Spdi_TCHF_AMR;
3676 }
3677 case (HR_AMR) {
3678 ret.channelRateAndType := ChRate_TCHH;
3679 ret.speechId_DataIndicator := Spdi_TCHH_AMR;
3680 }
3681 case else {
3682 setverdict(fail, "Unsupported codec ", a_elem);
Daniel Willmannafce8662018-07-06 23:11:32 +02003683 mtc.stop;
Harald Welte60aa5762018-03-21 19:33:13 +01003684 }
3685 }
3686 return ret;
3687}
3688
Harald Weltea63b9102018-03-22 20:36:16 +01003689private function f_rsl_chmod_tmpl_from_codec(BSSMAP_FIELD_CodecElement a_elem)
3690return template RSL_IE_Body {
3691 var template RSL_IE_Body mode_ie := {
3692 chan_mode := {
3693 len := ?,
3694 reserved := ?,
3695 dtx_d := ?,
3696 dtx_u := ?,
3697 spd_ind := RSL_SPDI_SPEECH,
3698 ch_rate_type := -,
3699 coding_alg_rate := -
3700 }
3701 }
3702
3703 select (a_elem.codecType) {
3704 case (GSM_FR) {
3705 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_F;
3706 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM1;
3707 }
3708 case (GSM_HR) {
3709 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_H;
3710 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM1;
3711 }
3712 case (GSM_EFR) {
3713 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_F;
3714 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM2;
3715 }
3716 case (FR_AMR) {
3717 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_F;
3718 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM3;
3719 }
3720 case (HR_AMR) {
3721 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_H;
3722 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM3;
3723 }
3724 }
3725 return mode_ie;
3726}
3727
Harald Welte60aa5762018-03-21 19:33:13 +01003728type record CodecListTest {
3729 BSSMAP_IE_SpeechCodecList codec_list,
3730 charstring id
3731}
3732type record of CodecListTest CodecListTests
3733
3734private function f_TC_assignment_codec(charstring id) runs on MSC_ConnHdlr {
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02003735 var PDU_BSSAP ass_cmd := f_gen_ass_req(g_pars.use_osmux);
3736 var template PDU_BSSAP exp_compl := f_gen_exp_compl(g_pars.use_osmux);
Harald Welte60aa5762018-03-21 19:33:13 +01003737
3738 /* puzzle together the ASSIGNMENT REQ for given codec[s] */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003739 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
Harald Welte79f3f542018-05-25 20:02:37 +02003740 ass_cmd.pdu.bssmap.assignmentRequest.codecList := g_pars.ass_codec_list;
3741 exp_compl.pdu.bssmap.assignmentComplete.speechCodec.codecElements[0] :=
3742 g_pars.ass_codec_list.codecElements[0];
Philipp Maierd0e64b02019-03-13 14:15:23 +01003743 if (isvalue(g_pars.expect_mr_s0_s7)) {
3744 exp_compl.pdu.bssmap.assignmentComplete.speechCodec.codecElements[0].s0_7 :=
3745 g_pars.expect_mr_s0_s7;
3746 }
Harald Welte79f3f542018-05-25 20:02:37 +02003747 }
Harald Welte60aa5762018-03-21 19:33:13 +01003748 ass_cmd.pdu.bssmap.assignmentRequest.channelType :=
3749 f_BSSMAP_chtype_from_codec(g_pars.ass_codec_list.codecElements[0]);
Harald Welte60aa5762018-03-21 19:33:13 +01003750 log("expecting ASS COMPL like this: ", exp_compl);
3751
3752 f_establish_fully(ass_cmd, exp_compl);
Harald Weltea63b9102018-03-22 20:36:16 +01003753
Neels Hofmeyr559d5d02021-04-16 16:50:49 +02003754 if (not g_pars.expect_channel_mode_modify) {
3755 /* Verify that the RSL-side activation actually matches our expectations */
3756 var RSL_Message rsl := f_rslem_get_last_act(RSL_PROC, 0, g_chan_nr);
Harald Weltea63b9102018-03-22 20:36:16 +01003757
Neels Hofmeyr559d5d02021-04-16 16:50:49 +02003758 var RSL_IE_Body mode_ie;
3759 if (f_rsl_find_ie(rsl, RSL_IE_CHAN_MODE, mode_ie) == false) {
3760 setverdict(fail, "Couldn't find CHAN_MODE IE");
Daniel Willmannafce8662018-07-06 23:11:32 +02003761 mtc.stop;
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02003762 }
Neels Hofmeyr559d5d02021-04-16 16:50:49 +02003763 var template RSL_IE_Body t_mode_ie := f_rsl_chmod_tmpl_from_codec(g_pars.ass_codec_list.codecElements[0]);
3764 if (not match(mode_ie, t_mode_ie)) {
3765 log("mode_ie ", mode_ie, " != t_mode_ie ", t_mode_ie);
3766 setverdict(fail, "RSL Channel Mode IE doesn't match expectation");
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02003767 }
Neels Hofmeyr559d5d02021-04-16 16:50:49 +02003768
3769 var RSL_IE_Body mr_conf;
3770 if (g_pars.expect_mr_conf_ie != omit) {
3771 if (f_rsl_find_ie(rsl, RSL_IE_MR_CONFIG, mr_conf) == false) {
3772 setverdict(fail, "Missing MR CONFIG IE in RSL Chan Activ");
3773 mtc.stop;
3774 }
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02003775 log("found RSL MR CONFIG IE: ", mr_conf);
Neels Hofmeyr559d5d02021-04-16 16:50:49 +02003776
3777 if (not match(mr_conf, g_pars.expect_mr_conf_ie)) {
3778 setverdict(fail, "RSL MR CONFIG IE does not match expectation. Expected: ",
3779 g_pars.expect_mr_conf_ie);
3780 }
3781 } else {
3782 if (f_rsl_find_ie(rsl, RSL_IE_MR_CONFIG, mr_conf) == true) {
3783 log("found RSL MR CONFIG IE: ", mr_conf);
3784 setverdict(fail, "Found MR CONFIG IE in RSL Chan Activ, expecting omit");
3785 mtc.stop;
3786 }
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02003787 }
3788 }
Harald Welte60aa5762018-03-21 19:33:13 +01003789}
3790
Philipp Maierd0e64b02019-03-13 14:15:23 +01003791private function f_TC_assignment_codec_fail(charstring id) runs on MSC_ConnHdlr {
3792
3793 var PDU_BSSAP ass_cmd := f_gen_ass_req();
3794 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
3795
3796 /* puzzle together the ASSIGNMENT REQ for given codec[s] */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003797 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
Philipp Maierd0e64b02019-03-13 14:15:23 +01003798 ass_cmd.pdu.bssmap.assignmentRequest.codecList := g_pars.ass_codec_list;
3799 }
3800 ass_cmd.pdu.bssmap.assignmentRequest.channelType :=
3801 f_BSSMAP_chtype_from_codec(g_pars.ass_codec_list.codecElements[0]);
3802 log("expecting ASS FAIL like this: ", exp_fail);
3803
3804 f_establish_fully(ass_cmd, exp_fail);
3805}
3806
Harald Welte60aa5762018-03-21 19:33:13 +01003807testcase TC_assignment_codec_fr() runs on test_CT {
Philipp Maier48604732018-10-09 15:00:37 +02003808 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte60aa5762018-03-21 19:33:13 +01003809 var MSC_ConnHdlr vc_conn;
3810
3811 f_init(1, true);
3812 f_sleep(1.0);
3813
3814 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
Harald Welte8863fa12018-05-10 20:15:27 +02003815 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01003816 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003817 f_shutdown_helper();
Harald Welte60aa5762018-03-21 19:33:13 +01003818}
3819
3820testcase TC_assignment_codec_hr() runs on test_CT {
Philipp Maier48604732018-10-09 15:00:37 +02003821 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte60aa5762018-03-21 19:33:13 +01003822 var MSC_ConnHdlr vc_conn;
3823
3824 f_init(1, true);
3825 f_sleep(1.0);
3826
3827 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR}));
Harald Welte8863fa12018-05-10 20:15:27 +02003828 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01003829 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003830 f_shutdown_helper();
Harald Welte60aa5762018-03-21 19:33:13 +01003831}
3832
3833testcase TC_assignment_codec_efr() runs on test_CT {
Philipp Maier48604732018-10-09 15:00:37 +02003834 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte60aa5762018-03-21 19:33:13 +01003835 var MSC_ConnHdlr vc_conn;
3836
3837 f_init(1, true);
3838 f_sleep(1.0);
3839
3840 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecEFR}));
Harald Welte8863fa12018-05-10 20:15:27 +02003841 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01003842 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003843 f_shutdown_helper();
Harald Welte60aa5762018-03-21 19:33:13 +01003844}
3845
Philipp Maierd0e64b02019-03-13 14:15:23 +01003846/* Allow 5,90k only (current default config) */
3847private function f_allow_amr_rate_5_90k() runs on test_CT {
Neels Hofmeyr2a5670b2020-11-25 23:39:57 +00003848 f_vty_cfg_msc(BSCVTY, 0, {
3849 "amr-config 12_2k forbidden",
3850 "amr-config 10_2k forbidden",
3851 "amr-config 7_95k forbidden",
3852 "amr-config 7_40k forbidden",
3853 "amr-config 6_70k forbidden",
3854 "amr-config 5_90k allowed",
3855 "amr-config 5_15k forbidden",
3856 "amr-config 4_75k forbidden"
3857 });
Philipp Maierd0e64b02019-03-13 14:15:23 +01003858}
3859
3860/* Allow 4,75k, 5,90k, 4,70k and 12,2k, which are the most common rates
3861 * ("Config-NB-Code = 1") */
3862private function f_allow_amr_rate_4_75k_5_90k_7_40k_12_20k() runs on test_CT {
Neels Hofmeyr2a5670b2020-11-25 23:39:57 +00003863 f_vty_cfg_msc(BSCVTY, 0, {
3864 "amr-config 12_2k allowed",
3865 "amr-config 10_2k forbidden",
3866 "amr-config 7_95k forbidden",
3867 "amr-config 7_40k allowed",
3868 "amr-config 6_70k forbidden",
3869 "amr-config 5_90k allowed",
3870 "amr-config 5_15k forbidden",
3871 "amr-config 4_75k allowed"
3872 });
Philipp Maierd0e64b02019-03-13 14:15:23 +01003873}
3874
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00003875private function f_vty_amr_start_mode_set(boolean fr, charstring startmode) runs on test_CT {
3876 var charstring tch;
3877 if (fr) {
3878 tch := "tch-f";
3879 } else {
3880 tch := "tch-h";
3881 }
3882 f_vty_cfg_bts(BSCVTY, 0, { "amr " & tch & " start-mode " & startmode });
3883}
3884
3885/* Set the AMR start-mode for this TCH back to the default configuration. */
3886private function f_vty_amr_start_mode_restore(boolean fr) runs on test_CT {
3887 f_vty_amr_start_mode_set(fr, "auto");
3888}
3889
Harald Welte60aa5762018-03-21 19:33:13 +01003890testcase TC_assignment_codec_amr_f() runs on test_CT {
Philipp Maier48604732018-10-09 15:00:37 +02003891 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte60aa5762018-03-21 19:33:13 +01003892 var MSC_ConnHdlr vc_conn;
Philipp Maier7695a0d2018-09-27 17:52:14 +02003893
3894 /* Note: This setups the codec configuration. The parameter payload in
3895 * mr_conf must be consistant with the parameter codecElements in pars
3896 * and also must match the amr-config in osmo-bsc.cfg! */
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02003897 var RSL_IE_Body mr_conf := {
3898 other := {
3899 len := 2,
3900 payload := '2804'O
3901 }
3902 };
Harald Welte60aa5762018-03-21 19:33:13 +01003903
Philipp Maier7695a0d2018-09-27 17:52:14 +02003904 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_F}));
Philipp Maier806f8f12019-03-12 12:13:41 +01003905 pars.ass_codec_list.codecElements[0].s0_7 := '00000100'B; /* 5,90k */
Philipp Maier7695a0d2018-09-27 17:52:14 +02003906 pars.ass_codec_list.codecElements[0].s8_15 := '01010111'B;
3907 pars.expect_mr_conf_ie := mr_conf;
3908
Harald Welte60aa5762018-03-21 19:33:13 +01003909 f_init(1, true);
3910 f_sleep(1.0);
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00003911 f_vty_amr_start_mode_set(true, "1");
Harald Welte60aa5762018-03-21 19:33:13 +01003912
Harald Welte8863fa12018-05-10 20:15:27 +02003913 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01003914 vc_conn.done;
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00003915
3916 f_vty_amr_start_mode_restore(true);
Vadim Yanitskiy292e5962021-01-03 14:18:47 +01003917 f_shutdown_helper();
Harald Welte60aa5762018-03-21 19:33:13 +01003918}
3919
3920testcase TC_assignment_codec_amr_h() runs on test_CT {
Philipp Maier48604732018-10-09 15:00:37 +02003921 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte60aa5762018-03-21 19:33:13 +01003922 var MSC_ConnHdlr vc_conn;
Philipp Maier7695a0d2018-09-27 17:52:14 +02003923
3924 /* See note above */
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02003925 var RSL_IE_Body mr_conf := {
3926 other := {
3927 len := 2,
3928 payload := '2804'O
3929 }
3930 };
Harald Welte60aa5762018-03-21 19:33:13 +01003931
Philipp Maier7695a0d2018-09-27 17:52:14 +02003932 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_H}));
Philipp Maier806f8f12019-03-12 12:13:41 +01003933 pars.ass_codec_list.codecElements[0].s0_7 := '00000100'B; /* 5,90k */
Philipp Maier7695a0d2018-09-27 17:52:14 +02003934 pars.ass_codec_list.codecElements[0].s8_15 := '00000111'B;
3935 pars.expect_mr_conf_ie := mr_conf;
3936
Harald Welte60aa5762018-03-21 19:33:13 +01003937 f_init(1, true);
3938 f_sleep(1.0);
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00003939 f_vty_amr_start_mode_set(false, "1");
Harald Welte60aa5762018-03-21 19:33:13 +01003940
Harald Welte8863fa12018-05-10 20:15:27 +02003941 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01003942 vc_conn.done;
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00003943
3944 f_vty_amr_start_mode_restore(false);
Vadim Yanitskiy292e5962021-01-03 14:18:47 +01003945 f_shutdown_helper();
Harald Welte60aa5762018-03-21 19:33:13 +01003946}
3947
Neels Hofmeyr559d5d02021-04-16 16:50:49 +02003948/* Establish signalling on a TCH/F lchan, and then switch to speech mode without a new Assignment. */
3949testcase TC_assignment_codec_fr_by_mode_modify() runs on test_CT {
3950 var TestHdlrParams pars := f_gen_test_hdlr_pars();
3951 var MSC_ConnHdlr vc_conn;
3952
3953 f_init(1, true);
3954 f_sleep(1.0);
3955
3956 /* By disabling all SDCCH, the MS should be given a TCH/F for signalling. Then activating an FR codec should
3957 * merely do a Channel Mode Modify, and not assign to a new lchan. f_establish_fully() already accounts for
3958 * expecting a Channel Mode Modify if the channel type is compatible. */
3959 f_disable_all_sdcch();
3960 f_disable_all_tch_h();
3961
3962 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
3963 pars.expect_channel_mode_modify := true;
3964 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
3965 vc_conn.done;
3966
3967 f_enable_all_sdcch();
3968 f_enable_all_tch();
3969 f_shutdown_helper();
3970}
3971
Neels Hofmeyr454d7922020-11-26 02:24:57 +00003972/* 'amr start-mode auto' should not keep the (unused) 'smod' bits from previous configuration */
3973testcase TC_assignment_codec_amr_startmode_cruft() runs on test_CT {
3974 var TestHdlrParams pars := f_gen_test_hdlr_pars();
3975 var MSC_ConnHdlr vc_conn;
3976
3977 var RSL_IE_Body mr_conf := {
3978 other := {
3979 len := 2,
3980 payload := '2004'O /* <- expect ICMI=0, smod=00 */
3981 }
3982 };
3983
3984 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_F}));
3985 pars.ass_codec_list.codecElements[0].s0_7 := '00000100'B; /* 5,90k */
3986 pars.ass_codec_list.codecElements[0].s8_15 := '01010111'B;
3987 pars.expect_mr_conf_ie := mr_conf;
3988
3989 f_init(1, true);
3990 f_sleep(1.0);
3991
3992 /* First set nonzero start mode bits */
3993 f_vty_amr_start_mode_set(true, "4");
3994 /* Now set to auto, and expect the startmode bits to be zero in the message, i.e. ensure that osmo-bsc does not
3995 * let the startmode bits stick around and has deterministic MultiRate config for 'start-mode auto'; that is
3996 * ensured by above '2004'O, where 'x0xx'O indicates ICMI = 0, spare = 0, smod = 00. */
3997 f_vty_amr_start_mode_set(true, "auto");
3998
3999 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
4000 vc_conn.done;
Neels Hofmeyr454d7922020-11-26 02:24:57 +00004001
4002 /* Clear the startmode bits to not affect subsequent tests, in case the bits should indeed stick around. */
4003 f_vty_amr_start_mode_set(true, "1");
4004 f_vty_amr_start_mode_restore(true);
Vadim Yanitskiy292e5962021-01-03 14:18:47 +01004005 f_shutdown_helper();
Neels Hofmeyr454d7922020-11-26 02:24:57 +00004006}
4007
Neels Hofmeyr21863562020-11-26 00:34:33 +00004008function f_TC_assignment_codec_amr(boolean fr, octetstring mrconf, bitstring s8_s0, bitstring exp_s8_s0,
4009 charstring start_mode := "1")
Philipp Maierd0e64b02019-03-13 14:15:23 +01004010runs on test_CT {
4011
4012 var TestHdlrParams pars := f_gen_test_hdlr_pars();
4013 var MSC_ConnHdlr vc_conn;
4014
4015 /* See note above */
4016 var RSL_IE_Body mr_conf := {
4017 other := {
4018 len := lengthof(mrconf),
4019 payload := mrconf
4020 }
4021 };
4022
4023 if (fr) {
4024 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_F}));
4025 } else {
4026 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_H}));
4027 }
4028 pars.ass_codec_list.codecElements[0].s0_7 := s8_s0;
4029 pars.ass_codec_list.codecElements[0].s8_15 := '00000111'B;
4030 pars.expect_mr_conf_ie := mr_conf;
4031 pars.expect_mr_s0_s7 := exp_s8_s0;
4032
4033 f_init(1, true);
4034 f_allow_amr_rate_4_75k_5_90k_7_40k_12_20k();
Neels Hofmeyr21863562020-11-26 00:34:33 +00004035 f_vty_amr_start_mode_set(fr, start_mode);
Philipp Maierd0e64b02019-03-13 14:15:23 +01004036 f_sleep(1.0);
4037
4038 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
4039 vc_conn.done;
4040 f_allow_amr_rate_5_90k();
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00004041 f_vty_amr_start_mode_restore(fr);
Philipp Maierd0e64b02019-03-13 14:15:23 +01004042}
4043
4044function f_TC_assignment_codec_amr_fail(boolean fr, bitstring s8_s0)
4045runs on test_CT {
4046
4047 var TestHdlrParams pars := f_gen_test_hdlr_pars();
4048 var MSC_ConnHdlr vc_conn;
4049
4050 if (fr) {
4051 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_F}));
4052 } else {
4053 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_H}));
4054 }
4055 pars.ass_codec_list.codecElements[0].s0_7 := s8_s0;
4056 pars.ass_codec_list.codecElements[0].s8_15 := '00000111'B;
4057
4058 f_init(1, true);
4059 f_allow_amr_rate_4_75k_5_90k_7_40k_12_20k();
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00004060 f_vty_amr_start_mode_set(fr, "1");
Philipp Maierd0e64b02019-03-13 14:15:23 +01004061 f_sleep(1.0);
4062
4063 vc_conn := f_start_handler(refers(f_TC_assignment_codec_fail), pars);
4064 vc_conn.done;
4065 f_allow_amr_rate_5_90k();
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00004066 f_vty_amr_start_mode_restore(fr);
Philipp Maierd0e64b02019-03-13 14:15:23 +01004067}
4068
4069
4070/* Set S1, we expect an AMR multirate configuration IE with all four rates
4071 * set. */
4072testcase TC_assignment_codec_amr_f_S1() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02004073 f_TC_assignment_codec_amr(true, '289520882208'O, '00000010'B, '00000010'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004074 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01004075}
4076
4077/* Set S1, we expect an AMR multirate configuration IE with the lower three
4078 * rates set. */
4079testcase TC_assignment_codec_amr_h_S1() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02004080 f_TC_assignment_codec_amr(false, '2815208820'O, '00000010'B, '00000010'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004081 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01004082}
4083
4084/* Set S1 and two other rates, we expect an AMR MULTIRATE CONFIGURATION IE with
4085 * all four rates (and only S1 set in the ASSIGNMENT COMPLETE) */
4086testcase TC_assignment_codec_amr_f_S124() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02004087 f_TC_assignment_codec_amr(true, '289520882208'O, '00010110'B, '00000010'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004088 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01004089}
4090
4091/* Set S1 and two other rates, we expect an AMR MULTIRATE CONFIGURATION IE with
4092 * all four rates (and only S1 set in the ASSIGNMENT COMPLETE) */
4093testcase TC_assignment_codec_amr_h_S124() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02004094 f_TC_assignment_codec_amr(false, '2815208820'O, '00010110'B, '00000010'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004095 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01004096}
4097
4098/* The following block of tests selects more and more rates until all four
4099 * possible rates are in the active set (full rate) */
4100testcase TC_assignment_codec_amr_f_S0() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02004101 f_TC_assignment_codec_amr(true, '2801'O, '00000001'B, '00000001'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004102 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01004103}
4104
4105testcase TC_assignment_codec_amr_f_S02() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02004106 f_TC_assignment_codec_amr(true, '28052080'O, '00000101'B, '00000101'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004107 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01004108}
4109
4110testcase TC_assignment_codec_amr_f_S024() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02004111 f_TC_assignment_codec_amr(true, '2815208820'O, '00010101'B, '00010101'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004112 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01004113}
4114
4115testcase TC_assignment_codec_amr_f_S0247() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02004116 f_TC_assignment_codec_amr(true, '289520882208'O, '10010101'B, '10010101'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004117 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01004118}
4119
4120/* The following block of tests selects more and more rates until all three
4121 * possible rates are in the active set (half rate) */
4122testcase TC_assignment_codec_amr_h_S0() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02004123 f_TC_assignment_codec_amr(false, '2801'O, '00000001'B, '00000001'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004124 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01004125}
4126
4127testcase TC_assignment_codec_amr_h_S02() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02004128 f_TC_assignment_codec_amr(false, '28052080'O, '00000101'B, '00000101'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004129 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01004130}
4131
4132testcase TC_assignment_codec_amr_h_S024() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02004133 f_TC_assignment_codec_amr(false, '2815208820'O, '00010101'B, '00010101'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004134 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01004135}
4136
4137/* The following block tests what happens when the MSC does offer rate
4138 * configurations that are not supported by the BSC. Normally such situations
4139 * should not happen because the MSC gets informed by the BSC in advance via
4140 * the L3 COMPLETE message which rates are applicable. The MSC should not try
4141 * to offer rates that are not applicable anyway. */
4142
4143testcase TC_assignment_codec_amr_h_S0247() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02004144 /* Try to include 12,2k in into the active set even though the channel
4145 * is half rate only. The BSC is expected to remove the 12,0k */
4146 f_TC_assignment_codec_amr(false, '2815208820'O, '10010101'B, '00010101'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004147 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01004148}
4149
4150testcase TC_assignment_codec_amr_f_S01234567() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02004151 /* See what happens when all rates are selected at once. Since then
4152 * Also S1 is selected, this setting will be prefered and we should
4153 * get 12.2k, 7,40k, 5,90k, and 4,75k in the active set. */
4154 f_TC_assignment_codec_amr(true, '289520882208'O, '11111111'B, '00000010'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004155 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01004156}
4157
4158testcase TC_assignment_codec_amr_f_S0234567() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02004159 /* Same as above, but with S1 missing, the MSC is then expected to
4160 * select the currently supported rates, which are also 12.2k, 7,40k,
4161 * 5,90k, and 4,75k, into the active set. */
4162 f_TC_assignment_codec_amr(true, '289520882208'O, '11111101'B, '10010101'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004163 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01004164}
4165
4166testcase TC_assignment_codec_amr_f_zero() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02004167 /* Try to select no rates at all */
4168 f_TC_assignment_codec_amr_fail(true, '00000000'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004169 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01004170}
4171
4172testcase TC_assignment_codec_amr_f_unsupp() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02004173 /* Try to select only unsupported rates */
4174 f_TC_assignment_codec_amr_fail(true, '01101000'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_h_S7() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02004179 /* Try to select 12,2k for half rate */
4180 f_TC_assignment_codec_amr_fail(false, '10000000'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004181 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01004182}
4183
Neels Hofmeyr21863562020-11-26 00:34:33 +00004184testcase TC_assignment_codec_amr_f_start_mode_auto() runs on test_CT {
4185 f_TC_assignment_codec_amr(true, '209520882208'O, '11111111'B, '00000010'B,
4186 start_mode := "auto");
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01004187 f_shutdown_helper();
Neels Hofmeyr21863562020-11-26 00:34:33 +00004188}
4189
4190testcase TC_assignment_codec_amr_h_start_mode_auto() runs on test_CT {
4191 f_TC_assignment_codec_amr(false, '2015208820'O, '10010101'B, '00010101'B,
4192 start_mode := "auto");
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01004193 f_shutdown_helper();
Neels Hofmeyr21863562020-11-26 00:34:33 +00004194}
4195
Neels Hofmeyr3eb94562020-11-26 02:40:26 +00004196testcase TC_assignment_codec_amr_f_start_mode_4() runs on test_CT {
Vadim Yanitskiy7815f482021-01-03 17:07:37 +01004197 /* "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 +00004198 f_TC_assignment_codec_amr(true, '2b9520882208'O, '11111111'B, '00000010'B,
4199 start_mode := "4");
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01004200 f_shutdown_helper();
Neels Hofmeyr3eb94562020-11-26 02:40:26 +00004201}
4202
4203testcase TC_assignment_codec_amr_h_start_mode_4() runs on test_CT {
Vadim Yanitskiy7815f482021-01-03 17:07:37 +01004204 /* "amr tch-h modes 0 2 4" => total 3 modes and start mode 4 => '10'B on the wire */
4205 f_TC_assignment_codec_amr(false, '2a15208820'O, '10010101'B, '00010101'B,
Neels Hofmeyr3eb94562020-11-26 02:40:26 +00004206 start_mode := "4");
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01004207 f_shutdown_helper();
Neels Hofmeyr3eb94562020-11-26 02:40:26 +00004208}
4209
Philipp Maierac09bfc2019-01-08 13:41:39 +01004210private function f_disable_all_tch_f() runs on test_CT {
Philipp Maierc704a882019-01-29 15:58:52 +01004211 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 1 sub-slot 0 borken");
4212 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 2 sub-slot 0 borken");
4213 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 3 sub-slot 0 borken");
4214 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 4 sub-slot 0 borken");
Philipp Maierac09bfc2019-01-08 13:41:39 +01004215}
4216
4217private function f_disable_all_tch_h() runs on test_CT {
Philipp Maierc704a882019-01-29 15:58:52 +01004218 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 5 sub-slot 0 borken");
4219 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 5 sub-slot 1 borken");
Philipp Maierac09bfc2019-01-08 13:41:39 +01004220}
4221
4222private function f_enable_all_tch() runs on test_CT {
Philipp Maierc704a882019-01-29 15:58:52 +01004223 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 1 sub-slot 0 unused");
4224 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 2 sub-slot 0 unused");
4225 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 3 sub-slot 0 unused");
4226 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 4 sub-slot 0 unused");
4227 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 5 sub-slot 0 unused");
4228 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 5 sub-slot 1 unused");
Philipp Maierac09bfc2019-01-08 13:41:39 +01004229}
4230
Neels Hofmeyr559d5d02021-04-16 16:50:49 +02004231private function f_disable_all_sdcch() runs on test_CT {
4232 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 0 sub-slot 0 borken");
4233 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 0 sub-slot 1 borken");
4234 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 0 sub-slot 2 borken");
4235 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 0 sub-slot 3 borken");
4236}
4237
4238private function f_enable_all_sdcch() runs on test_CT {
4239 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 0 sub-slot 0 unused");
4240 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 0 sub-slot 1 unused");
4241 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 0 sub-slot 2 unused");
4242 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 0 sub-slot 3 unused");
4243}
4244
Philipp Maierac09bfc2019-01-08 13:41:39 +01004245/* Allow HR only */
4246private function f_TC_assignment_codec_xr_exhausted_req_hr(charstring id) runs on MSC_ConnHdlr {
4247 g_pars := f_gen_test_hdlr_pars();
4248 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4249 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4250 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4251 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '09'O;
4252 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '05'O;
4253 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR}));
4254 f_establish_fully(ass_cmd, exp_compl);
4255}
4256
4257/* Allow FR only */
4258private function f_TC_assignment_codec_xr_exhausted_req_fr(charstring id) runs on MSC_ConnHdlr {
4259 g_pars := f_gen_test_hdlr_pars();
4260 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4261 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4262 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4263 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '08'O;
4264 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '01'O;
4265 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
4266 f_establish_fully(ass_cmd, exp_compl);
4267}
4268
4269/* Allow HR only (expect assignment failure) */
4270private function f_TC_assignment_codec_xr_exhausted_req_hr_fail(charstring id) runs on MSC_ConnHdlr {
4271 g_pars := f_gen_test_hdlr_pars();
4272 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4273 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
4274 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4275 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '09'O;
4276 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '05'O;
4277 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR}));
4278 f_establish_fully(ass_cmd, exp_fail);
4279}
4280
4281/* Allow FR only (expect assignment failure) */
4282private function f_TC_assignment_codec_xr_exhausted_req_fr_fail(charstring id) runs on MSC_ConnHdlr {
4283 g_pars := f_gen_test_hdlr_pars();
4284 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4285 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
4286 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4287 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '08'O;
4288 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '01'O;
4289 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
4290 f_establish_fully(ass_cmd, exp_fail);
4291}
4292
4293/* Allow FR and HR, but prefer FR */
4294private function f_TC_assignment_codec_fr_exhausted_req_fr_hr(charstring id) runs on MSC_ConnHdlr {
4295 g_pars := f_gen_test_hdlr_pars();
4296 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4297 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4298 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4299 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0A'O; /* Prefer FR */
4300 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8105'O;
4301 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR, ts_CodecHR}));
4302 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000101'B; /* Expect HR */
4303 f_establish_fully(ass_cmd, exp_compl);
4304}
4305
4306/* Allow FR and HR, but prefer HR */
4307private function f_TC_assignment_codec_fr_exhausted_req_hr_fr(charstring id) runs on MSC_ConnHdlr {
4308 g_pars := f_gen_test_hdlr_pars();
4309 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4310 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4311 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4312 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0B'O; /* Prefer HR */
4313 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8501'O;
4314 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR, ts_CodecFR}));
4315 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000101'B; /* Expect HR */
4316 f_establish_fully(ass_cmd, exp_compl);
4317}
4318
4319/* Allow FR and HR, but prefer FR */
4320private function f_TC_assignment_codec_hr_exhausted_req_fr_hr(charstring id) runs on MSC_ConnHdlr {
4321 g_pars := f_gen_test_hdlr_pars();
4322 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4323 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4324 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4325 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0A'O; /* Prefer FR */
4326 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8105'O;
4327 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR, ts_CodecHR}));
4328 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000001'B; /* Expect FR */
4329 f_establish_fully(ass_cmd, exp_compl);
4330}
4331
4332/* Allow FR and HR, but prefer HR */
4333private function f_TC_assignment_codec_hr_exhausted_req_hr_fr(charstring id) runs on MSC_ConnHdlr {
4334 g_pars := f_gen_test_hdlr_pars();
4335 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4336 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4337 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4338 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0B'O; /* Prefer HR */
4339 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8501'O;
4340 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR, ts_CodecFR}));
4341 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000001'B; /* Expect FR */
4342 f_establish_fully(ass_cmd, exp_compl);
4343}
4344
4345/* Request a HR channel while all FR channels are exhausted, this is expected
4346 * to work without conflicts */
4347testcase TC_assignment_codec_fr_exhausted_req_hr() runs on test_CT {
4348 var MSC_ConnHdlr vc_conn;
4349 f_init(1, true);
4350 f_sleep(1.0);
4351 f_enable_all_tch();
4352 f_disable_all_tch_f();
4353 vc_conn := f_start_handler(refers(f_TC_assignment_codec_xr_exhausted_req_hr));
4354 vc_conn.done;
4355 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004356 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004357}
4358
4359/* Request a FR channel while all FR channels are exhausted, this is expected
4360 * to fail. */
4361testcase TC_assignment_codec_fr_exhausted_req_fr() runs on test_CT {
4362 var MSC_ConnHdlr vc_conn;
4363 f_init(1, true);
4364 f_sleep(1.0);
4365 f_enable_all_tch();
4366 f_disable_all_tch_f();
4367 vc_conn := f_start_handler(refers(f_TC_assignment_codec_xr_exhausted_req_fr_fail));
4368 vc_conn.done;
4369 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004370 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004371}
4372
4373/* Request a FR (prefered) or alternatively a HR channel while all FR channels
4374 * are exhausted, this is expected to be resolved by selecting a HR channel. */
4375testcase TC_assignment_codec_fr_exhausted_req_fr_hr() runs on test_CT {
4376 var MSC_ConnHdlr vc_conn;
4377 f_init(1, true);
4378 f_sleep(1.0);
4379 f_enable_all_tch();
4380 f_disable_all_tch_f();
4381 vc_conn := f_start_handler(refers(f_TC_assignment_codec_fr_exhausted_req_fr_hr));
4382 vc_conn.done;
4383 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004384 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004385}
4386
4387/* Request a HR (prefered) or alternatively a FR channel while all FR channels
4388 * are exhausted, this is expected to work without conflicts. */
4389testcase TC_assignment_codec_fr_exhausted_req_hr_fr() runs on test_CT {
4390 var MSC_ConnHdlr vc_conn;
4391 f_init(1, true);
4392 f_sleep(1.0);
4393 f_enable_all_tch();
4394 f_disable_all_tch_f();
4395 vc_conn := f_start_handler(refers(f_TC_assignment_codec_fr_exhausted_req_hr_fr));
4396 vc_conn.done;
4397 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004398 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004399}
4400
4401/* Request a FR channel while all HR channels are exhausted, this is expected
4402 * to work without conflicts */
4403testcase TC_assignment_codec_hr_exhausted_req_fr() runs on test_CT {
4404 var MSC_ConnHdlr vc_conn;
4405 f_init(1, true);
4406 f_sleep(1.0);
4407 f_enable_all_tch();
4408 f_disable_all_tch_h();
4409 vc_conn := f_start_handler(refers(f_TC_assignment_codec_xr_exhausted_req_fr));
4410 vc_conn.done;
4411 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004412 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004413}
4414
4415/* Request a HR channel while all HR channels are exhausted, this is expected
4416 * to fail. */
4417testcase TC_assignment_codec_hr_exhausted_req_hr() runs on test_CT {
4418 var MSC_ConnHdlr vc_conn;
4419 f_init(1, true);
4420 f_sleep(1.0);
4421 f_enable_all_tch();
4422 f_disable_all_tch_h();
4423 vc_conn := f_start_handler(refers(f_TC_assignment_codec_xr_exhausted_req_hr_fail));
4424 vc_conn.done;
4425 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004426 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004427}
4428
4429/* Request a HR (prefered) or alternatively a FR channel while all HR channels
4430 * are exhausted, this is expected to be resolved by selecting a FR channel. */
4431testcase TC_assignment_codec_hr_exhausted_req_hr_fr() runs on test_CT {
4432 var MSC_ConnHdlr vc_conn;
4433 f_init(1, true);
4434 f_sleep(1.0);
4435 f_enable_all_tch();
4436 f_disable_all_tch_h();
4437 vc_conn := f_start_handler(refers(f_TC_assignment_codec_hr_exhausted_req_hr_fr));
4438 vc_conn.done;
4439 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004440 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004441}
4442
4443/* Request a FR (prefered) or alternatively a HR channel while all HR channels
4444 * are exhausted, this is expected to work without conflicts. */
4445testcase TC_assignment_codec_hr_exhausted_req_fr_hr() runs on test_CT {
4446 var MSC_ConnHdlr vc_conn;
4447 f_init(1, true);
4448 f_sleep(1.0);
4449 f_enable_all_tch();
4450 f_disable_all_tch_h();
4451 vc_conn := f_start_handler(refers(f_TC_assignment_codec_hr_exhausted_req_fr_hr));
4452 vc_conn.done;
4453 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004454 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004455}
4456
4457/* Allow FR and HR, but prefer HR */
4458private function f_TC_assignment_codec_req_hr_fr(charstring id) runs on MSC_ConnHdlr {
4459 g_pars := f_gen_test_hdlr_pars();
4460 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4461 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4462 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4463 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0B'O; /* Prefer HR */
4464 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8501'O;
4465 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR, ts_CodecFR}));
4466 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000101'B; /* Expect HR */
4467 f_establish_fully(ass_cmd, exp_compl);
4468}
4469
4470/* Allow FR and HR, but prefer FR */
4471private function f_TC_assignment_codec_req_fr_hr(charstring id) runs on MSC_ConnHdlr {
4472 g_pars := f_gen_test_hdlr_pars();
4473 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4474 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4475 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4476 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0A'O; /* Prefer FR */
4477 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8105'O;
4478 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR, ts_CodecHR}));
4479 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000001'B; /* Expect FR */
4480 f_establish_fully(ass_cmd, exp_compl);
4481}
4482
4483/* Request a HR (prefered) or alternatively a FR channel, it is expected that
4484 * HR, which is the prefered type, is selected. */
4485testcase TC_assignment_codec_req_hr_fr() 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 vc_conn := f_start_handler(refers(f_TC_assignment_codec_req_hr_fr));
4491 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004492 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004493}
4494
4495/* Request a FR (prefered) or alternatively a HR channel, it is expected that
4496 * FR, which is the prefered type, is selected. */
4497testcase TC_assignment_codec_req_fr_hr() runs on test_CT {
4498 var MSC_ConnHdlr vc_conn;
4499 f_init(1, true);
4500 f_sleep(1.0);
4501 f_enable_all_tch();
4502 vc_conn := f_start_handler(refers(f_TC_assignment_codec_req_fr_hr));
4503 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004504 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004505}
4506
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02004507testcase TC_assignment_osmux() runs on test_CT {
4508 var TestHdlrParams pars := f_gen_test_hdlr_pars();
4509 var MSC_ConnHdlr vc_conn;
4510
4511 /* See note above */
4512 var RSL_IE_Body mr_conf := {
4513 other := {
4514 len := 2,
4515 payload := '2804'O
4516 }
4517 };
4518
4519 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_H}));
4520 pars.ass_codec_list.codecElements[0].s0_7 := '00000100'B; /* 5,90k */
4521 pars.ass_codec_list.codecElements[0].s8_15 := '00000111'B;
4522 pars.expect_mr_conf_ie := mr_conf;
4523 pars.use_osmux := true;
4524
4525 f_init(1, true, true);
4526 f_sleep(1.0);
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00004527 f_vty_amr_start_mode_set(false, "1");
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02004528
4529 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
4530 vc_conn.done;
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00004531
4532 f_vty_amr_start_mode_restore(false);
Vadim Yanitskiy292e5962021-01-03 14:18:47 +01004533 f_shutdown_helper();
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02004534}
4535
Neels Hofmeyr92b12b72018-09-18 14:30:23 +02004536/* test the procedure of the MSC requesting a Classmark Update:
4537 * a) BSSMAP Classmark Request should result in RR CLASSMARK ENQUIRY,
4538 * b) L3 RR CLASSMARK CHANGE should result in BSSMAP CLASSMARK UPDATE */
Harald Welte898113b2018-01-31 18:32:21 +01004539private function f_tc_classmark(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02004540 g_pars := f_gen_test_hdlr_pars();
4541
Harald Weltea0630032018-03-20 21:09:55 +01004542 f_create_chan_and_exp();
Harald Welte898113b2018-01-31 18:32:21 +01004543 /* we should now have a COMPL_L3 at the MSC */
4544 BSSAP.receive(tr_BSSMAP_ComplL3);
4545
Neels Hofmeyr92b12b72018-09-18 14:30:23 +02004546 BSSAP.send(ts_BSSMAP_ClassmarkRequest);
4547 RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_CM_ENQUIRY));
4548
Harald Welte898113b2018-01-31 18:32:21 +01004549 f_rsl_send_l3(ts_RRM_CM_CHG(valueof(ts_CM2)));
4550 BSSAP.receive(tr_BSSMAP_ClassmarkUpd(?, omit));
4551 setverdict(pass);
4552}
4553testcase TC_classmark() runs on test_CT {
4554 var MSC_ConnHdlr vc_conn;
4555 f_init(1, true);
4556 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02004557 vc_conn := f_start_handler(refers(f_tc_classmark));
Harald Welte898113b2018-01-31 18:32:21 +01004558 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004559 f_shutdown_helper();
Harald Welte898113b2018-01-31 18:32:21 +01004560}
4561
Harald Welteeddf0e92020-06-21 19:42:15 +02004562/* Send a CommonID from the simulated MSC and verify that the information is used to
4563 * fill BSC-internal data structures (specifically, bsc_subscr associated with subscr_conn) */
4564private function f_tc_common_id(charstring id) runs on MSC_ConnHdlr {
4565 g_pars := f_gen_test_hdlr_pars();
4566 f_MscConnHdlr_init_vty();
4567
4568 f_create_chan_and_exp();
4569 /* we should now have a COMPL_L3 at the MSC */
4570 BSSAP.receive(tr_BSSMAP_ComplL3);
4571
4572 /* Send CommonID */
4573 BSSAP.send(ts_BSSMAP_CommonId(g_pars.imsi));
4574
4575 /* Use VTY to verify that the IMSI of the subscr_conn is set */
4576 var charstring regex := "*(IMSI: " & hex2str(g_pars.imsi) & ")*";
4577 f_vty_transceive_match_regexp_retry(BSCVTY, "show conns", regex, 0, 4, 1.0);
4578
4579 setverdict(pass);
4580}
4581testcase TC_common_id() runs on test_CT {
4582 var MSC_ConnHdlr vc_conn;
4583 f_init(1, true);
4584 f_sleep(1.0);
4585 vc_conn := f_start_handler(refers(f_tc_common_id));
4586 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004587 f_shutdown_helper();
Harald Welteeddf0e92020-06-21 19:42:15 +02004588}
4589
Harald Weltee3bd6582018-01-31 22:51:25 +01004590private function f_est_single_l3(template PDU_ML3_MS_NW l3) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02004591 g_pars := f_gen_test_hdlr_pars();
Harald Weltea0630032018-03-20 21:09:55 +01004592 f_create_chan_and_exp();
Harald Welte898113b2018-01-31 18:32:21 +01004593 /* we should now have a COMPL_L3 at the MSC */
4594 BSSAP.receive(tr_BSSMAP_ComplL3);
4595
Harald Weltee3bd6582018-01-31 22:51:25 +01004596 /* send the single message we want to send */
4597 f_rsl_send_l3(l3);
4598}
4599
4600private function f_bssap_expect_nothing(float sec := 5.00) runs on MSC_ConnHdlr {
4601 timer T := sec;
4602 var PDU_BSSAP bssap;
Harald Welte898113b2018-01-31 18:32:21 +01004603 T.start;
4604 alt {
Harald Weltee3bd6582018-01-31 22:51:25 +01004605 [] BSSAP.receive(PDU_BSSAP:?) -> value bssap {
4606 setverdict(fail, "Unexpected BSSMAP ", bssap);
Daniel Willmannafce8662018-07-06 23:11:32 +02004607 mtc.stop;
Harald Welte898113b2018-01-31 18:32:21 +01004608 }
4609 [] T.timeout {
4610 setverdict(pass);
4611 }
4612 }
4613}
4614
Harald Weltee3bd6582018-01-31 22:51:25 +01004615/* unsolicited ASSIGNMENT FAIL (without ASSIGN) from MS shouldn't bring BSC down */
4616private function f_tc_unsol_ass_fail(charstring id) runs on MSC_ConnHdlr {
4617 f_est_single_l3(ts_RRM_AssignmentFailure('00'O));
4618 f_bssap_expect_nothing();
4619}
Harald Welte898113b2018-01-31 18:32:21 +01004620testcase TC_unsol_ass_fail() runs on test_CT {
4621 var MSC_ConnHdlr vc_conn;
4622 f_init(1, true);
4623 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02004624 vc_conn := f_start_handler(refers(f_tc_unsol_ass_fail));
Harald Welte898113b2018-01-31 18:32:21 +01004625 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004626 f_shutdown_helper();
Harald Welte898113b2018-01-31 18:32:21 +01004627}
Harald Welte552620d2017-12-16 23:21:36 +01004628
Harald Welteea99a002018-01-31 20:46:43 +01004629
4630/* unsolicited ASSIGNMENT COMPLETE (without ASSIGN) from MS shouldn't bring BSC down */
4631private function f_tc_unsol_ass_compl(charstring id) runs on MSC_ConnHdlr {
Harald Weltee3bd6582018-01-31 22:51:25 +01004632 f_est_single_l3(ts_RRM_AssignmentComplete('00'O));
4633 f_bssap_expect_nothing();
Harald Welteea99a002018-01-31 20:46:43 +01004634}
4635testcase TC_unsol_ass_compl() runs on test_CT {
4636 var MSC_ConnHdlr vc_conn;
4637 f_init(1, true);
4638 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02004639 vc_conn := f_start_handler(refers(f_tc_unsol_ass_compl));
Harald Welteea99a002018-01-31 20:46:43 +01004640 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004641 f_shutdown_helper();
Harald Welteea99a002018-01-31 20:46:43 +01004642}
4643
4644
Harald Weltefbf9b5e2018-01-31 20:41:23 +01004645/* unsolicited HANDOVER FAIL (without ASSIGN) from MS shouldn't bring BSC down */
4646private function f_tc_unsol_ho_fail(charstring id) runs on MSC_ConnHdlr {
Harald Weltee3bd6582018-01-31 22:51:25 +01004647 f_est_single_l3(ts_RRM_HandoverFailure('00'O));
4648 f_bssap_expect_nothing();
Harald Weltefbf9b5e2018-01-31 20:41:23 +01004649}
Harald Weltefbf9b5e2018-01-31 20:41:23 +01004650testcase TC_unsol_ho_fail() runs on test_CT {
4651 var MSC_ConnHdlr vc_conn;
4652 f_init(1, true);
4653 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02004654 vc_conn := f_start_handler(refers(f_tc_unsol_ho_fail));
Harald Weltefbf9b5e2018-01-31 20:41:23 +01004655 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004656 f_shutdown_helper();
Harald Weltefbf9b5e2018-01-31 20:41:23 +01004657}
4658
4659
Harald Weltee3bd6582018-01-31 22:51:25 +01004660/* short message from MS should be ignored */
4661private function f_tc_err_82_short_msg(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02004662 g_pars := f_gen_test_hdlr_pars();
Harald Weltea0630032018-03-20 21:09:55 +01004663 f_create_chan_and_exp();
Harald Weltee3bd6582018-01-31 22:51:25 +01004664 /* we should now have a COMPL_L3 at the MSC */
4665 BSSAP.receive(tr_BSSMAP_ComplL3);
4666
4667 /* send short message */
4668 RSL.send(ts_RSL_DATA_IND(g_chan_nr, valueof(ts_RslLinkID_DCCH(0)), ''O));
4669 f_bssap_expect_nothing();
4670}
4671testcase TC_err_82_short_msg() runs on test_CT {
4672 var MSC_ConnHdlr vc_conn;
4673 f_init(1, true);
4674 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02004675 vc_conn := f_start_handler(refers(f_tc_err_82_short_msg));
Harald Weltee3bd6582018-01-31 22:51:25 +01004676 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004677 f_shutdown_helper();
Harald Weltee3bd6582018-01-31 22:51:25 +01004678}
4679
4680
Harald Weltee9e02e42018-01-31 23:36:25 +01004681/* 24.008 8.4 Unknown message must trigger RR STATUS */
4682private function f_tc_err_84_unknown_msg(charstring id) runs on MSC_ConnHdlr {
4683 f_est_single_l3(ts_RRM_UL_REL('00'O));
4684 timer T := 3.0
4685 alt {
4686 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_STATUS)) {
4687 setverdict(pass);
4688 }
4689 [] BSSAP.receive { setverdict(fail, "unexpected BSSAP"); }
Harald Welte458fd372018-03-21 11:26:23 +01004690 [] T.timeout { setverdict(fail, "Timeout waiting for RR STATUS"); }
Harald Weltee9e02e42018-01-31 23:36:25 +01004691 }
4692}
4693testcase TC_err_84_unknown_msg() runs on test_CT {
4694 var MSC_ConnHdlr vc_conn;
4695 f_init(1, true);
4696 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02004697 vc_conn := f_start_handler(refers(f_tc_err_84_unknown_msg));
Harald Weltee9e02e42018-01-31 23:36:25 +01004698 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004699 f_shutdown_helper();
Harald Weltee9e02e42018-01-31 23:36:25 +01004700}
4701
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004702/***********************************************************************
4703 * Handover
4704 ***********************************************************************/
4705
Harald Welte94e0c342018-04-07 11:33:23 +02004706/* execute a "bts <0-255> trx <0-255> timeslot <0-7> " command on given Dchan */
4707private function f_vty_ts_action(charstring suffix, integer bts_nr, integer trx_nr, integer ts_nr)
4708runs on test_CT {
4709 var charstring cmd := "bts "&int2str(bts_nr)&" trx "&int2str(trx_nr)&
4710 " timeslot "&int2str(ts_nr)&" ";
4711 f_vty_transceive(BSCVTY, cmd & suffix);
4712}
4713
Harald Welte261af4b2018-02-12 21:20:39 +01004714/* 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 +07004715private function f_vty_ss_action(TELNETasp_PT pt, charstring suffix,
4716 uint8_t bts_nr, uint8_t trx_nr,
4717 in RslChannelNr chan_nr)
4718{
Harald Welte261af4b2018-02-12 21:20:39 +01004719 /* FIXME: resolve those from component-global state */
4720 var integer ts_nr := chan_nr.tn;
4721 var integer ss_nr;
4722 if (ischosen(chan_nr.u.ch0)) {
4723 ss_nr := 0;
4724 } else if (ischosen(chan_nr.u.lm)) {
4725 ss_nr := chan_nr.u.lm.sub_chan;
4726 } else if (ischosen(chan_nr.u.sdcch4)) {
4727 ss_nr := chan_nr.u.sdcch4.sub_chan;
4728 } else if (ischosen(chan_nr.u.sdcch8)) {
4729 ss_nr := chan_nr.u.sdcch8.sub_chan;
4730 } else {
4731 setverdict(fail, "Invalid ChanNr ", chan_nr);
Daniel Willmannafce8662018-07-06 23:11:32 +02004732 mtc.stop;
Harald Welte261af4b2018-02-12 21:20:39 +01004733 }
4734
4735 var charstring cmd := "bts "&int2str(bts_nr)&" trx "&int2str(trx_nr)&
4736 " timeslot "&int2str(ts_nr)&" sub-slot "&int2str(ss_nr)&" ";
Vadim Yanitskiy00070722020-09-02 17:27:57 +07004737 f_vty_transceive(pt, cmd & suffix);
Harald Welte261af4b2018-02-12 21:20:39 +01004738}
4739
Neels Hofmeyr91401012019-07-11 00:42:35 +02004740/* Even though the VTY command to trigger handover takes a new BTS number as argument, behind the scenes osmo-bsc always
4741 * translates that to a target ARFCN+BSIC first. See bsc_vty.c trigger_ho_or_as(), which puts the selected BTS' neighbor
4742 * ident key (ARFCN + BSIC) in the struct passed on to handover_request(). handover_start() then resolves that to a
4743 * viable actual neighbor cell. So from the internal osmo-bsc perspective, we always request handover to an ARFCN + BSIC
4744 * pair, not really to a specific BTS number. */
Vadim Yanitskiy00070722020-09-02 17:27:57 +07004745private function f_vty_handover(TELNETasp_PT pt, uint8_t bts_nr, uint8_t trx_nr,
4746 in RslChannelNr chan_nr, uint8_t new_bts_nr)
4747{
4748 f_vty_ss_action(pt, "handover " & int2str(new_bts_nr), bts_nr, trx_nr, chan_nr);
Harald Welte261af4b2018-02-12 21:20:39 +01004749}
4750
4751/* intra-BSC hand-over between BTS0 and BTS1 */
4752private function f_tc_ho_int(charstring id) runs on MSC_ConnHdlr {
Harald Welteed848512018-05-24 22:27:58 +02004753 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4754 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte261af4b2018-02-12 21:20:39 +01004755
4756 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4757 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
4758
Harald Weltea0630032018-03-20 21:09:55 +01004759 f_establish_fully(ass_cmd, exp_compl);
Neels Hofmeyr666f0432020-07-04 00:53:07 +02004760 f_bts_0_cfg(BSCVTY, {"neighbor bts 1"});
Harald Welte261af4b2018-02-12 21:20:39 +01004761
4762 var HandoverState hs := {
4763 rr_ho_cmpl_seen := false,
4764 handover_done := false,
4765 old_chan_nr := -
4766 };
4767 /* issue hand-over command on VTY */
Vadim Yanitskiy00070722020-09-02 17:27:57 +07004768 f_vty_handover(BSCVTY, 0, 0, g_chan_nr, 1);
Harald Welte261af4b2018-02-12 21:20:39 +01004769 /* temporarily suspend DChan processing on BTS1 to avoid race with RSLEM_register */
4770 f_rslem_suspend(RSL1_PROC);
Philipp Maier3e2af5d2018-07-11 17:01:05 +02004771
4772 /* From the MGW perspective, a handover is is characterized by
4773 * performing one MDCX operation with the MGW. So we expect to see
4774 * one more MDCX during handover. */
4775 g_media.mgcp_conn[0].mdcx_seen_exp := g_media.mgcp_conn[0].crcx_seen_exp + 1;
4776
Harald Welte261af4b2018-02-12 21:20:39 +01004777 alt {
4778 [] as_handover(hs);
Harald Welte261af4b2018-02-12 21:20:39 +01004779 }
Philipp Maier3e2af5d2018-07-11 17:01:05 +02004780
Philipp Maier4dae0652018-11-12 12:03:26 +01004781 /* Since this is an internal handover we expect the BSC to inform the
4782 * MSC about the event */
4783 BSSAP.receive(tr_BSSMAP_HandoverPerformed);
4784
Philipp Maier3e2af5d2018-07-11 17:01:05 +02004785 /* Check the amount of MGCP transactions is still consistant with the
4786 * test expectation */
4787 f_check_mgcp_expectations()
Neels Hofmeyraf88d9d2021-06-21 02:14:27 +02004788
4789 /* Ensure the Channel Activation for the new channel contained the right encryption params. as_handover() set
4790 * g_chan_nr to the new lchan that was handed over to. It lives in bts 1, so look it up at RSL1_PROC. */
4791 f_verify_encr_info(f_rslem_get_last_act(RSL1_PROC, 0, g_chan_nr));
4792
Neels Hofmeyr861a4c12018-11-07 01:23:17 +01004793 f_sleep(0.5);
Harald Welte261af4b2018-02-12 21:20:39 +01004794}
4795
4796testcase TC_ho_int() runs on test_CT {
Neels Hofmeyr5f7a9df2021-06-21 01:30:43 +02004797 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte261af4b2018-02-12 21:20:39 +01004798 var MSC_ConnHdlr vc_conn;
4799 f_init(2, true);
4800 f_sleep(1.0);
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004801
4802 f_ctrs_bsc_and_bts_init();
4803
Neels Hofmeyr5f7a9df2021-06-21 01:30:43 +02004804 vc_conn := f_start_handler(refers(f_tc_ho_int), pars);
Harald Welte261af4b2018-02-12 21:20:39 +01004805 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004806
4807 /* from f_establish_fully() */
4808 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
4809 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
4810 /* from handover */
4811 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
4812 f_ctrs_bsc_and_bts_add(0, "handover:completed");
4813 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
4814 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:completed");
4815 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004816 f_shutdown_helper();
Harald Welte261af4b2018-02-12 21:20:39 +01004817}
Harald Weltee9e02e42018-01-31 23:36:25 +01004818
Neels Hofmeyraf88d9d2021-06-21 02:14:27 +02004819function f_tc_ho_int_a5(OCT1 encr_alg) runs on test_CT {
4820 var MSC_ConnHdlr vc_conn;
4821 var TestHdlrParams pars := f_gen_test_hdlr_pars();
4822 pars.encr := valueof(t_EncrParams(encr_alg, f_rnd_octstring(8), f_rnd_octstring(16)));
4823
4824 f_init(2, true);
4825 f_sleep(1.0);
4826
4827 f_ctrs_bsc_and_bts_init();
4828
4829 vc_conn := f_start_handler(refers(f_tc_ho_int), pars);
4830 vc_conn.done;
4831
4832 /* from f_establish_fully() */
4833 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
4834 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
4835 /* from handover */
4836 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
4837 f_ctrs_bsc_and_bts_add(0, "handover:completed");
4838 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
4839 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:completed");
4840 f_ctrs_bsc_and_bts_verify();
4841 f_shutdown_helper();
4842}
4843
4844testcase TC_ho_int_a5_0() runs on test_CT {
4845 f_tc_ho_int_a5('01'O);
4846}
4847
4848testcase TC_ho_int_a5_1() runs on test_CT {
4849 f_tc_ho_int_a5('02'O);
4850}
4851
4852testcase TC_ho_int_a5_3() runs on test_CT {
4853 f_tc_ho_int_a5('08'O);
4854}
4855
4856testcase TC_ho_int_a5_4() runs on test_CT {
4857 f_tc_ho_int_a5('10'O);
4858}
4859
Neels Hofmeyr5f144212020-11-03 15:41:58 +00004860/* intra-BSC hand-over with CONNection FAILure and cause Radio Link Failure: check RR release cause */
4861private function f_tc_ho_int_radio_link_failure(charstring id) runs on MSC_ConnHdlr {
4862 g_pars := f_gen_test_hdlr_pars();
4863 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4864 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Neels Hofmeyr5f144212020-11-03 15:41:58 +00004865
4866 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4867 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
4868
4869 f_establish_fully(ass_cmd, exp_compl);
4870 f_bts_0_cfg(BSCVTY, {"neighbor bts 1"});
4871
4872 var HandoverState hs := {
4873 rr_ho_cmpl_seen := false,
4874 handover_done := false,
4875 old_chan_nr := -
4876 };
4877 /* issue hand-over command on VTY */
4878 f_vty_handover(BSCVTY, 0, 0, g_chan_nr, 1);
4879 /* temporarily suspend DChan processing on BTS1 to avoid race with RSLEM_register */
4880 f_rslem_suspend(RSL1_PROC);
4881
4882 /* From the MGW perspective, a handover is is characterized by
4883 * performing one MDCX operation with the MGW. So we expect to see
4884 * one more MDCX during handover. */
4885 g_media.mgcp_conn[0].mdcx_seen_exp := g_media.mgcp_conn[0].crcx_seen_exp + 1;
4886
4887 var RSL_Message rsl;
4888 var PDU_ML3_NW_MS l3;
4889 var RslChannelNr new_chan_nr;
4890 var GsmArfcn arfcn;
4891 RSL.receive(tr_RSL_DATA_REQ(g_chan_nr)) -> value rsl {
4892 l3 := dec_PDU_ML3_NW_MS(rsl.ies[2].body.l3_info.payload);
4893 if (not ischosen(l3.msgs.rrm.handoverCommand)) {
4894 setverdict(fail, "Expected handoverCommand");
4895 mtc.stop;
4896 }
4897 }
4898 f_ChDesc2RslChanNr(l3.msgs.rrm.handoverCommand.channelDescription2,
4899 new_chan_nr, arfcn);
4900
4901 f_rslem_register(0, new_chan_nr, RSL1_PROC);
4902
4903 /* resume processing of RSL DChan messages, which was temporarily suspended
4904 * before performing a hand-over */
4905 f_rslem_resume(RSL1_PROC);
4906 RSL1.receive(tr_RSL_IPA_CRCX(new_chan_nr));
4907
4908 f_sleep(1.0);
4909
4910 /* Handover fails because no HANDO DET appears on the new lchan,
4911 * and the old lchan reports a Radio Link Failure. */
4912 RSL.send(ts_RSL_CONN_FAIL_IND(g_chan_nr, RSL_ERR_RADIO_LINK_FAIL));
4913
4914 var PDU_BSSAP rx_clear_request;
4915 BSSAP.receive(tr_BSSMAP_ClearRequest) -> value rx_clear_request;
4916 var BssmapCause cause := bit2int(rx_clear_request.pdu.bssmap.clearRequest.cause.causeValue);
4917 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
4918
4919 var RR_Cause rr_cause := GSM48_RR_CAUSE_ABNORMAL_UNSPEC;
4920
4921 var MgcpCommand mgcp;
4922 interleave {
4923 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_RELEASE(int2oct(enum2int(rr_cause), 1)))) {}
4924 [] RSL.receive(tr_RSL_DEACT_SACCH(g_chan_nr)) {}
4925 [] RSL.receive(tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL)) {
4926 RSL.send(ts_RSL_RF_CHAN_REL_ACK(g_chan_nr));
4927 }
4928 [] RSL1.receive(tr_RSL_DEACT_SACCH(new_chan_nr)) {}
4929 [] RSL1.receive(tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL)) {
4930 RSL1.send(ts_RSL_RF_CHAN_REL_ACK(new_chan_nr));
4931 }
4932 [] BSSAP.receive(tr_BSSMAP_ClearComplete) {}
4933 }
4934
4935 f_sleep(0.5);
4936 setverdict(pass);
4937}
4938testcase TC_ho_int_radio_link_failure() runs on test_CT {
4939 var MSC_ConnHdlr vc_conn;
4940 f_init(2, true);
4941 f_sleep(1.0);
4942
4943 f_ctrs_bsc_and_bts_init();
4944
4945 vc_conn := f_start_handler(refers(f_tc_ho_int_radio_link_failure));
4946 vc_conn.done;
4947
4948 /* from f_establish_fully() */
4949 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
4950 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
4951 /* from handover */
4952 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
4953 f_ctrs_bsc_and_bts_add(0, "handover:stopped");
4954 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
4955 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:stopped");
4956 f_ctrs_bsc_and_bts_verify();
4957 f_shutdown_helper();
4958}
4959
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004960/* Expecting MGCP to DLCX the endpoint's two connections: towards BTS and towards MSC */
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02004961private function f_expect_dlcx_conns() runs on MSC_ConnHdlr {
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004962 var MgcpCommand mgcp;
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +02004963 var template MgcpResponse mgcp_resp;
4964 var MGCP_RecvFrom mrf;
4965 var template MgcpMessage msg_resp;
4966 var template MgcpMessage msg_dlcx := {
4967 command := tr_DLCX()
4968 }
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004969
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +02004970 if (g_pars.aoip) {
4971 MGCP.receive(tr_DLCX()) -> value mgcp {
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004972 log("Got first DLCX: ", mgcp);
4973 MGCP.send(ts_DLCX_ACK2(mgcp.line.trans_id));
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +02004974 };
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004975
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004976 MGCP.receive(tr_DLCX()) -> value mgcp {
4977 log("Got second DLCX: ", mgcp);
4978 MGCP.send(ts_DLCX_ACK2(mgcp.line.trans_id));
4979 };
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +02004980 } else {
4981 /* For SCCPLite, BSC doesn't handle the MSC-side */
4982 MGCP_MULTI.receive(tr_MGCP_RecvFrom_any(msg_dlcx)) -> value mrf {
4983 log("Got first DLCX: ", mrf.msg.command);
4984 msg_resp := {
4985 response := ts_DLCX_ACK2(mrf.msg.command.line.trans_id)
4986 }
4987 MGCP_MULTI.send(t_MGCP_SendToMrf(mrf, msg_resp));
4988 };
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004989 }
4990
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02004991 BSSAP.receive(tr_BSSMAP_ClearComplete);
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004992}
4993
Pau Espin Pedrol35801c32021-04-19 13:03:20 +02004994private 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 +01004995
Neels Hofmeyr666f0432020-07-04 00:53:07 +02004996 f_bts_0_cfg(BSCVTY, {"neighbor lac 99 arfcn 123 bsic any"});
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004997 f_vty_transceive(BSCVTY, "handover any to arfcn 123 bsic any");
4998
Pau Espin Pedrol35801c32021-04-19 13:03:20 +02004999 BSSAP.receive(tr_BSSMAP_HandoverRequired(exp_oldToNewBSSIEs));
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005000
5001 f_sleep(0.5);
5002 /* The MSC negotiates Handover Request and Handover Request Ack with
5003 * the other BSS and comes back with a BSSMAP Handover Command
5004 * containing an RR Handover Command coming from the target BSS... */
5005
5006 var PDU_ML3_NW_MS rr_ho_cmd := valueof(ts_RR_HandoverCommand);
5007 log("Remote cell's RR Handover Command passed through as L3 Info: ", rr_ho_cmd);
5008 var octetstring rr_ho_cmd_enc := enc_PDU_ML3_NW_MS(rr_ho_cmd);
5009 log("Remote cell's RR Handover Command passed through as L3 Info, encoded: ", rr_ho_cmd_enc);
5010 BSSAP.send(ts_BSSMAP_HandoverCommand(rr_ho_cmd_enc));
5011
5012 /* expect the Handover Command to go out on RR */
5013 var RSL_Message rsl_ho_cmd
5014 RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, ?)) -> value rsl_ho_cmd;
5015 log("RSL Data Req went out to first BTS: ", rsl_ho_cmd);
5016 var RSL_IE_Body rsl_ho_cmd_l3;
5017 if (not f_rsl_find_ie(rsl_ho_cmd, RSL_IE_L3_INFO, rsl_ho_cmd_l3)) {
5018 log("RSL message contains no L3 Info IE, expected RR Handover Command");
5019 setverdict(fail);
5020 } else {
5021 log("Found L3 Info: ", rsl_ho_cmd_l3);
5022 if (rsl_ho_cmd_l3.l3_info.payload != rr_ho_cmd_enc) {
5023 log("FAIL: the BSC sent out a different L3 Info, not matching the RR Handover Command the other BSS forwarded.");
5024 setverdict(fail);
5025 } else {
5026 log("Success: the BSC sent out the same RR Handover Command the other BSS forwarded.");
5027 setverdict(pass);
5028 }
5029 }
5030
5031 /* When the other BSS has reported a completed handover, this side is
5032 * torn down. */
5033
5034 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_HANDOVER_SUCCESSFUL;
5035 var BssmapCause cause := enum2int(cause_val);
5036 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
5037
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02005038 f_expect_dlcx_conns();
Pau Espin Pedrol06199952021-06-15 11:30:00 +02005039
5040 interleave {
5041 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_RELEASE));
5042 [] RSL.receive(tr_RSL_DEACT_SACCH(g_chan_nr));
5043 [] RSL.receive(tr_RSL_RF_CHAN_REL(g_chan_nr));
5044 }
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005045 setverdict(pass);
Pau Espin Pedrol35801c32021-04-19 13:03:20 +02005046}
5047
5048private function f_tc_ho_out_of_this_bsc(charstring id) runs on MSC_ConnHdlr {
5049 g_pars := f_gen_test_hdlr_pars();
5050 var PDU_BSSAP ass_req := f_gen_ass_req();
5051 ass_req.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
5052 ass_req.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
5053 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
5054 f_establish_fully(ass_req, exp_compl);
5055
5056 f_ho_out_of_this_bsc();
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005057}
5058testcase TC_ho_out_of_this_bsc() runs on test_CT {
5059 var MSC_ConnHdlr vc_conn;
5060
5061 f_init(1, true);
5062 f_sleep(1.0);
5063
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005064 f_ctrs_bsc_and_bts_init();
5065
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005066 vc_conn := f_start_handler(refers(f_tc_ho_out_of_this_bsc));
5067 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005068
5069 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5070 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5071 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5072 f_ctrs_bsc_and_bts_add(0, "handover:completed");
5073 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
5074 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:completed");
5075 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005076 f_shutdown_helper();
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005077}
5078
Neels Hofmeyr0aa719b2020-10-12 18:43:09 +00005079private function f_mo_l3_transceive(RSL_DCHAN_PT rsl := RSL,
5080 template (value) RslLinkId link_id := ts_RslLinkID_DCCH(0),
Vadim Yanitskiy2ef6a2f2020-10-08 23:17:32 +07005081 template (present) OCT1 dlci := ?,
Vadim Yanitskiyb93aa432020-10-01 14:23:11 +07005082 octetstring l3 := '0123456789'O)
5083runs on MSC_ConnHdlr {
Neels Hofmeyr43654812020-09-25 01:35:35 +02005084 /* The old lchan and conn should still be active. See that arbitrary L3
5085 * is still going through. */
Neels Hofmeyr0aa719b2020-10-12 18:43:09 +00005086 rsl.send(ts_RSL_DATA_IND(g_chan_nr, link_id, l3));
Neels Hofmeyr43654812020-09-25 01:35:35 +02005087 var template PDU_BSSAP exp_data := {
5088 discriminator := '1'B,
5089 spare := '0000000'B,
Vadim Yanitskiyb93aa432020-10-01 14:23:11 +07005090 dlci := dlci,
5091 lengthIndicator := lengthof(l3),
Neels Hofmeyr43654812020-09-25 01:35:35 +02005092 pdu := {
5093 dtap := l3
5094 }
5095 };
5096 BSSAP.receive(exp_data);
5097 setverdict(pass);
5098}
5099
Neels Hofmeyr0aa719b2020-10-12 18:43:09 +00005100private function f_mt_l3_transceive(RSL_DCHAN_PT rsl := RSL,
5101 template (present) RslLinkId link_id := tr_RslLinkID_DCCH(0),
Vadim Yanitskiy0033a3b2020-10-01 22:21:16 +07005102 template (value) OCT1 dlci := '00'O,
5103 octetstring l3 := '0123456789'O)
5104runs on MSC_ConnHdlr {
5105 BSSAP.send(PDU_BSSAP:{
5106 discriminator := '1'B,
5107 spare := '0000000'B,
5108 dlci := dlci,
5109 lengthIndicator := lengthof(l3),
5110 pdu := {
5111 dtap := l3
5112 }
5113 });
Neels Hofmeyr0aa719b2020-10-12 18:43:09 +00005114 rsl.receive(tr_RSL_DATA_REQ(g_chan_nr, link_id, l3));
Vadim Yanitskiy0033a3b2020-10-01 22:21:16 +07005115 setverdict(pass);
5116}
5117
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005118/* BSC asks for inter-BSC HO, but the MSC decides that it won't happen and
5119 * simply never sends a BSSMAP Handover Command. */
5120private function f_tc_ho_out_fail_no_msc_response(charstring id) runs on MSC_ConnHdlr {
Daniel Willmann3b59eb52018-10-29 15:40:55 +01005121 g_pars := f_gen_test_hdlr_pars();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005122
5123 var PDU_BSSAP ass_req := f_gen_ass_req();
5124 ass_req.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
5125 ass_req.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
5126 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
5127 f_establish_fully(ass_req, exp_compl);
5128
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005129 f_bts_0_cfg(BSCVTY, {"neighbor lac 99 arfcn 123 bsic any"});
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005130 f_vty_transceive(BSCVTY, "handover any to arfcn 123 bsic any");
5131
5132 BSSAP.receive(tr_BSSMAP_HandoverRequired);
5133
5134 /* osmo-bsc should time out 10 seconds after the handover started.
5135 * Let's give it a bit extra. */
5136 f_sleep(15.0);
5137
Vadim Yanitskiy74ae5eb2020-10-01 22:13:29 +07005138 f_mo_l3_transceive();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005139 f_sleep(1.0);
5140}
5141testcase TC_ho_out_fail_no_msc_response() runs on test_CT {
5142 var MSC_ConnHdlr vc_conn;
5143
5144 f_init(1, true);
5145 f_sleep(1.0);
5146
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005147 f_ctrs_bsc_and_bts_init();
5148
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005149 vc_conn := f_start_handler(refers(f_tc_ho_out_fail_no_msc_response));
5150 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005151
5152 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5153 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5154 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5155 f_ctrs_bsc_and_bts_add(0, "handover:timeout");
5156 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
5157 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:timeout");
5158 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005159 f_shutdown_helper();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005160}
5161
5162/* BSC asks for inter-BSC HO, receives BSSMAP Handover Command, but MS reports
5163 * RR Handover Failure. */
5164private function f_tc_ho_out_fail_rr_ho_failure(charstring id) runs on MSC_ConnHdlr {
Daniel Willmann3b59eb52018-10-29 15:40:55 +01005165 g_pars := f_gen_test_hdlr_pars();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005166
5167 var PDU_BSSAP ass_req := f_gen_ass_req();
5168 ass_req.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
5169 ass_req.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
5170 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
5171 f_establish_fully(ass_req, exp_compl);
5172
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005173 f_bts_0_cfg(BSCVTY, {"neighbor lac 99 arfcn 123 bsic any"});
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005174 f_vty_transceive(BSCVTY, "handover any to arfcn 123 bsic any");
5175
5176 BSSAP.receive(tr_BSSMAP_HandoverRequired);
5177
5178 f_sleep(0.5);
5179 /* The MSC negotiates Handover Request and Handover Request Ack with
5180 * the other BSS and comes back with a BSSMAP Handover Command
5181 * containing an RR Handover Command coming from the target BSS... */
5182
5183 var PDU_ML3_NW_MS rr_ho_cmd := valueof(ts_RR_HandoverCommand);
5184 log("Remote cell's RR Handover Command passed through as L3 Info: ", rr_ho_cmd);
5185 var octetstring rr_ho_cmd_enc := enc_PDU_ML3_NW_MS(rr_ho_cmd);
5186 log("Remote cell's RR Handover Command passed through as L3 Info, encoded: ", rr_ho_cmd_enc);
5187 BSSAP.send(ts_BSSMAP_HandoverCommand(rr_ho_cmd_enc));
5188
5189 /* expect the Handover Command to go out on RR */
5190 var RSL_Message rsl_ho_cmd
5191 RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, ?)) -> value rsl_ho_cmd;
5192 log("RSL Data Req went out to first BTS: ", rsl_ho_cmd);
5193 var RSL_IE_Body rsl_ho_cmd_l3;
5194 if (not f_rsl_find_ie(rsl_ho_cmd, RSL_IE_L3_INFO, rsl_ho_cmd_l3)) {
5195 log("RSL message contains no L3 Info IE, expected RR Handover Command");
5196 setverdict(fail);
5197 } else {
5198 log("Found L3 Info: ", rsl_ho_cmd_l3);
5199 if (rsl_ho_cmd_l3.l3_info.payload != rr_ho_cmd_enc) {
5200 log("FAIL: the BSC sent out a different L3 Info, not matching the RR Handover Command the other BSS forwarded.");
5201 setverdict(fail);
5202 } else {
5203 log("Success: the BSC sent out the same RR Handover Command the other BSS forwarded.");
5204 setverdict(pass);
5205 }
5206 }
5207
5208 f_sleep(0.2);
5209 f_rsl_send_l3(ts_RRM_HandoverFailure('00'O));
5210
5211 /* Should tell the MSC about the failure */
5212 BSSAP.receive(tr_BSSMAP_HandoverFailure);
5213
5214 f_sleep(1.0);
5215
Vadim Yanitskiy74ae5eb2020-10-01 22:13:29 +07005216 f_mo_l3_transceive();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005217 f_sleep(1.0);
5218
5219 setverdict(pass);
5220 f_sleep(1.0);
5221}
5222testcase TC_ho_out_fail_rr_ho_failure() runs on test_CT {
5223 var MSC_ConnHdlr vc_conn;
5224
5225 f_init(1, true);
5226 f_sleep(1.0);
5227
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005228 f_ctrs_bsc_and_bts_init();
5229
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005230 vc_conn := f_start_handler(refers(f_tc_ho_out_fail_rr_ho_failure));
5231 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005232
5233 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5234 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5235 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5236 f_ctrs_bsc_and_bts_add(0, "handover:failed");
5237 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
5238 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:failed");
5239 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005240 f_shutdown_helper();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005241}
5242
Neels Hofmeyr10f2bfa2019-07-09 19:33:29 +02005243/* BSC asks for inter-BSC-out HO, receives BSSMAP Handover Command, but then no reply is received about HO outcome
5244 * (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 +02005245 * and the lchan is released. */
5246private function f_tc_ho_out_fail_no_result_after_ho_cmd(charstring id) runs on MSC_ConnHdlr {
Daniel Willmann3b59eb52018-10-29 15:40:55 +01005247 g_pars := f_gen_test_hdlr_pars();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005248
5249 var PDU_BSSAP ass_req := f_gen_ass_req();
5250 ass_req.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
5251 ass_req.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
5252 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
5253 f_establish_fully(ass_req, exp_compl);
5254
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005255 f_bts_0_cfg(BSCVTY, {"neighbor lac 99 arfcn 123 bsic any"});
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005256 f_vty_transceive(BSCVTY, "handover any to arfcn 123 bsic any");
5257
5258 BSSAP.receive(tr_BSSMAP_HandoverRequired);
5259
5260 f_sleep(0.5);
5261 /* The MSC negotiates Handover Request and Handover Request Ack with
5262 * the other BSS and comes back with a BSSMAP Handover Command
5263 * containing an RR Handover Command coming from the target BSS... */
5264
5265 var PDU_ML3_NW_MS rr_ho_cmd := valueof(ts_RR_HandoverCommand);
5266 log("Remote cell's RR Handover Command passed through as L3 Info: ", rr_ho_cmd);
5267 var octetstring rr_ho_cmd_enc := enc_PDU_ML3_NW_MS(rr_ho_cmd);
5268 log("Remote cell's RR Handover Command passed through as L3 Info, encoded: ", rr_ho_cmd_enc);
5269 BSSAP.send(ts_BSSMAP_HandoverCommand(rr_ho_cmd_enc));
5270
5271 /* expect the Handover Command to go out on RR */
5272 var RSL_Message rsl_ho_cmd
5273 RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, ?)) -> value rsl_ho_cmd;
5274 log("RSL Data Req went out to first BTS: ", rsl_ho_cmd);
5275 var RSL_IE_Body rsl_ho_cmd_l3;
5276 if (not f_rsl_find_ie(rsl_ho_cmd, RSL_IE_L3_INFO, rsl_ho_cmd_l3)) {
5277 log("RSL message contains no L3 Info IE, expected RR Handover Command");
5278 setverdict(fail);
5279 } else {
5280 log("Found L3 Info: ", rsl_ho_cmd_l3);
5281 if (rsl_ho_cmd_l3.l3_info.payload != rr_ho_cmd_enc) {
5282 log("FAIL: the BSC sent out a different L3 Info, not matching the RR Handover Command the other BSS forwarded.");
5283 setverdict(fail);
5284 } else {
5285 log("Success: the BSC sent out the same RR Handover Command the other BSS forwarded.");
5286 setverdict(pass);
5287 }
5288 }
5289
Neels Hofmeyr10f2bfa2019-07-09 19:33:29 +02005290 /* We get neither success nor failure report from the remote BSS. Eventually T8 times out and we run into 3GPP
5291 * TS 48.008 3.1.5.3.3 "Abnormal Conditions": Clear Request should go to the MSC, and RR should be released
5292 * after Clear Command */
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005293
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02005294 var PDU_BSSAP rx_clear_request;
Neels Hofmeyre1797aa2019-07-09 19:34:04 +02005295 BSSAP.receive(tr_BSSMAP_ClearRequest) -> value rx_clear_request;
5296 log("Got BSSMAP Clear Request");
5297 /* Instruct BSC to clear channel */
5298 var BssmapCause cause := bit2int(rx_clear_request.pdu.bssmap.clearRequest.cause.causeValue);
5299 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
5300
5301 var MgcpCommand mgcp;
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005302 interleave {
Neels Hofmeyr861a4c12018-11-07 01:23:17 +01005303 [] RSL.receive(tr_RSL_DEACT_SACCH(g_chan_nr)) {
5304 log("Got Deact SACCH");
5305 }
Harald Welte924b6ea2019-02-04 01:05:34 +01005306 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_RELEASE)) {
Neels Hofmeyr211169d2018-11-07 00:37:29 +01005307 log("Got RR Release");
5308 }
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005309 [] RSL.receive(tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL)) {
5310 log("Got RF Chan Rel");
5311 RSL.send(ts_RSL_RF_CHAN_REL_ACK(g_chan_nr));
5312 }
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005313 }
5314
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02005315 f_expect_dlcx_conns();
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02005316
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005317 setverdict(pass);
5318 f_sleep(1.0);
5319}
Neels Hofmeyrd8a602c2019-07-09 19:46:01 +02005320testcase TC_ho_out_fail_no_result_after_ho_cmd() runs on test_CT {
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005321 var MSC_ConnHdlr vc_conn;
5322
5323 f_init(1, true);
5324 f_sleep(1.0);
5325
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005326 f_ctrs_bsc_and_bts_init();
5327
Neels Hofmeyrd8a602c2019-07-09 19:46:01 +02005328 vc_conn := f_start_handler(refers(f_tc_ho_out_fail_no_result_after_ho_cmd));
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005329 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005330
5331 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5332 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5333 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5334 f_ctrs_bsc_and_bts_add(0, "handover:timeout");
5335 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
5336 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:timeout");
5337 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005338 f_shutdown_helper();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005339}
5340
Pau Espin Pedrol35801c32021-04-19 13:03:20 +02005341private 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 +01005342 /* Hack: the proper way would be to wait for the BSSMAP Handover Request ACK and extract the
5343 * actual assigned chan_nr from its L3 (RR Handover Command) message. But osmo-bsc starts acting
5344 * on the lchan even before we get a chance to evaluate the BSSMAP Handover Request ACK. So we
5345 * need to assume that osmo-bsc will activate TS 1 and already set up this lchan's RSL emulation
5346 * before we get started. */
5347 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
5348 f_rslem_register(0, new_chan_nr);
5349 g_chan_nr := new_chan_nr;
5350 f_sleep(1.0);
5351
5352 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
5353 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
5354 activate(as_Media());
5355
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005356 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Pau Espin Pedrolc08d5522021-04-16 15:40:38 +02005357 f_gen_handover_req(aoip_tla := g_pars.host_aoip_tla,
Neels Hofmeyr8ebf19c2021-06-21 05:24:01 +02005358 oldToNewBSSIEs := oldToNewBSSIEs,
5359 enc := g_pars.encr)));
Harald Welte6811d102019-04-14 22:23:14 +02005360 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005361
5362 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
5363
5364 var PDU_BSSAP rx_bssap;
5365 var octetstring ho_command_str;
5366
5367 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
Pau Espin Pedrol76ba5412019-06-10 11:00:33 +02005368
Neels Hofmeyr8ebf19c2021-06-21 05:24:01 +02005369 /* we're sure that the channel activation is done now, verify the encryption parameters in it */
5370 f_verify_encr_info(f_rslem_get_last_act(RSL_PROC, 0, g_chan_nr));
5371
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005372 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
5373 log("Received L3 Info in HO Request Ack: ", ho_command_str);
5374 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
5375 log("L3 Info in HO Request Ack is ", ho_command);
5376
5377 var GsmArfcn arfcn;
5378 var RslChannelNr actual_new_chan_nr;
5379 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
5380 actual_new_chan_nr, arfcn);
5381
5382 if (actual_new_chan_nr != new_chan_nr) {
5383 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
5384 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
5385 setverdict(fail);
5386 return;
5387 }
5388 log("Handover Command chan_nr is", actual_new_chan_nr);
5389
5390 /* Now the MSC forwards the RR Handover Command to the other BSC, which
5391 * tells the MS to handover to the new lchan. Here comes the new MS on
5392 * the new lchan with a Handover RACH: */
5393
5394 /* send handover detect */
5395
5396 RSL.send(ts_RSL_HANDO_DET(new_chan_nr));
5397
5398 BSSAP.receive(tr_BSSMAP_HandoverDetect);
5399
5400 /* send handover complete over the new channel */
5401
5402 var PDU_ML3_MS_NW l3_tx := valueof(ts_RRM_HandoverComplete('00'O));
5403 RSL.send(ts_RSL_EST_IND(new_chan_nr, valueof(ts_RslLinkID_DCCH(0)),
5404 enc_PDU_ML3_MS_NW(l3_tx)));
5405
5406 BSSAP.receive(tr_BSSMAP_HandoverComplete);
Pau Espin Pedrol35801c32021-04-19 13:03:20 +02005407 setverdict(pass);
5408}
Pau Espin Pedrolc08d5522021-04-16 15:40:38 +02005409
Pau Espin Pedrol35801c32021-04-19 13:03:20 +02005410private function f_tc_ho_into_this_bsc(charstring id) runs on MSC_ConnHdlr {
Pau Espin Pedrol9ae36d52021-06-15 17:29:43 +02005411 var template PDU_ML3_NW_MS exp_rr_rel_tmpl;
Pau Espin Pedrol35801c32021-04-19 13:03:20 +02005412 var template (omit) BSSMAP_oldToNewBSSIEs oldToNewBSSIEs := omit;
5413 if (not istemplatekind(g_pars.last_used_eutran_plmn, "omit")) {
5414 oldToNewBSSIEs := f_ts_BSSMAP_oldToNewBSSIEs(ts_BSSMAP_LastUsedEUTRANPLMNId(g_pars.last_used_eutran_plmn));
Pau Espin Pedrol9ae36d52021-06-15 17:29:43 +02005415 }
5416 if (g_pars.exp_fast_return) {
Pau Espin Pedrol35801c32021-04-19 13:03:20 +02005417 exp_rr_rel_tmpl := tr_RRM_RR_RELEASE_CellSelectInd;
Pau Espin Pedrol9ae36d52021-06-15 17:29:43 +02005418 } else {
5419 exp_rr_rel_tmpl := tr_RRM_RR_RELEASE;
Pau Espin Pedrol35801c32021-04-19 13:03:20 +02005420 }
5421 f_ho_into_this_bsc(id, oldToNewBSSIEs);
Pau Espin Pedrolc08d5522021-04-16 15:40:38 +02005422 f_perform_clear(RSL, exp_rr_rel_tmpl);
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005423 setverdict(pass);
5424}
Pau Espin Pedrol07866632020-09-03 19:10:55 +02005425function f_tc_ho_into_this_bsc_main(TestHdlrParams pars) runs on test_CT {
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005426 var MSC_ConnHdlr vc_conn;
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005427
5428 f_init(1, true);
5429 f_sleep(1.0);
5430
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005431 f_ctrs_bsc_and_bts_init();
5432
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005433 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
5434 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005435
5436 vc_conn := f_start_handler(refers(f_tc_ho_into_this_bsc), pars);
5437 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005438
5439 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5440 f_ctrs_bsc_and_bts_add(0, "handover:completed");
5441 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:attempted");
5442 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:completed");
5443 f_ctrs_bsc_and_bts_verify();
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005444}
5445
Pau Espin Pedrol07866632020-09-03 19:10:55 +02005446testcase TC_ho_into_this_bsc() runs on test_CT {
5447 var TestHdlrParams pars := f_gen_test_hdlr_pars();
5448 f_tc_ho_into_this_bsc_main(pars);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005449 f_shutdown_helper();
Pau Espin Pedrol07866632020-09-03 19:10:55 +02005450}
5451
Neels Hofmeyr8ebf19c2021-06-21 05:24:01 +02005452function f_tc_ho_into_this_bsc_a5(OCT1 encr_alg) runs on test_CT {
5453 var TestHdlrParams pars := f_gen_test_hdlr_pars();
5454 pars.encr := valueof(t_EncrParams(encr_alg, f_rnd_octstring(8), f_rnd_octstring(16)));
5455 f_tc_ho_into_this_bsc_main(pars);
5456 f_shutdown_helper();
5457}
5458
5459testcase TC_ho_into_this_bsc_a5_0() runs on test_CT {
5460 f_tc_ho_into_this_bsc_a5('01'O);
5461}
5462
5463testcase TC_ho_into_this_bsc_a5_1() runs on test_CT {
5464 f_tc_ho_into_this_bsc_a5('02'O);
5465}
5466
5467testcase TC_ho_into_this_bsc_a5_3() runs on test_CT {
5468 f_tc_ho_into_this_bsc_a5('08'O);
5469}
5470
5471testcase TC_ho_into_this_bsc_a5_4() runs on test_CT {
5472 f_tc_ho_into_this_bsc_a5('10'O);
5473}
5474
Pau Espin Pedrol07866632020-09-03 19:10:55 +02005475testcase TC_ho_into_this_bsc_tla_v6() runs on test_CT {
5476 var TestHdlrParams pars := f_gen_test_hdlr_pars();
5477 pars.host_aoip_tla := "::6";
5478 f_tc_ho_into_this_bsc_main(pars);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005479 f_shutdown_helper();
Pau Espin Pedrol07866632020-09-03 19:10:55 +02005480}
5481
Pau Espin Pedrolc08d5522021-04-16 15:40:38 +02005482/* Similar to TC_ho_into_this_bsc, but when in SRVCC, HO Req contains "Old BSS
Pau Espin Pedrol35801c32021-04-19 13:03:20 +02005483 to New BSS Information" IE with "Last Used E-UTRAN PLMN Id", which, when the
Pau Espin Pedrolc08d5522021-04-16 15:40:38 +02005484 channel is later released (RR CHannel Release), should trigger inclusion of
5485 IE "Cell Selection Indicator after Release of all TCH and SDCCH" with E-UTRAN
5486 neighbors. */
5487testcase TC_srvcc_eutran_to_geran() runs on test_CT {
5488 var TestHdlrParams pars := f_gen_test_hdlr_pars();
5489 pars.last_used_eutran_plmn := '323454'O;
Pau Espin Pedrol9ae36d52021-06-15 17:29:43 +02005490 pars.exp_fast_return := true;
Pau Espin Pedrolc08d5522021-04-16 15:40:38 +02005491 f_tc_ho_into_this_bsc_main(pars);
Pau Espin Pedrol211a7142021-06-15 16:43:03 +02005492
5493 f_ctrs_bsc_and_bts_add(0, "srvcc:attempted");
5494 f_ctrs_bsc_and_bts_add(0, "srvcc:completed");
5495 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrolc08d5522021-04-16 15:40:38 +02005496 f_shutdown_helper();
5497}
5498
Pau Espin Pedrol9ae36d52021-06-15 17:29:43 +02005499/* Same as TC_srvcc_eutran_to_geran, but test explicitly forbiding fast return
5500 on the BTS. As a result, RR Release shouldn't contain the EUTRAN neighbor
5501 list when the channel is released. */
5502testcase TC_srvcc_eutran_to_geran_forbid_fast_return() runs on test_CT {
5503 f_init_vty();
5504 f_vty_allow_srvcc_fast_return(true, 0)
5505
5506 var TestHdlrParams pars := f_gen_test_hdlr_pars();
5507 pars.last_used_eutran_plmn := '323454'O;
5508 pars.exp_fast_return := false;
5509 f_tc_ho_into_this_bsc_main(pars);
5510 f_vty_allow_srvcc_fast_return(false, 0);
5511 f_shutdown_helper();
5512}
5513
Pau Espin Pedrol35801c32021-04-19 13:03:20 +02005514private function f_tc_srvcc_eutran_to_geran_ho_out(charstring id) runs on MSC_ConnHdlr {
5515 var template (omit) BSSMAP_oldToNewBSSIEs oldToNewBSSIEs;
5516 oldToNewBSSIEs := f_ts_BSSMAP_oldToNewBSSIEs(ts_BSSMAP_LastUsedEUTRANPLMNId(g_pars.last_used_eutran_plmn));
5517 f_ho_into_this_bsc(id, oldToNewBSSIEs);
5518 f_ho_out_of_this_bsc(oldToNewBSSIEs);
5519 setverdict(pass);
5520}
Pau Espin Pedrol9ae36d52021-06-15 17:29:43 +02005521
5522private function f_tc_srvcc_eutran_to_geran_ho_out_main(boolean disable_fast_return)
5523 runs on test_CT {
Pau Espin Pedrol35801c32021-04-19 13:03:20 +02005524 var MSC_ConnHdlr vc_conn;
5525 var TestHdlrParams pars := f_gen_test_hdlr_pars();
5526
5527 f_init(1, true);
Pau Espin Pedrol9ae36d52021-06-15 17:29:43 +02005528 if (disable_fast_return) {
5529 f_vty_allow_srvcc_fast_return(true, 0);
5530 }
Pau Espin Pedrol35801c32021-04-19 13:03:20 +02005531 f_sleep(1.0);
5532
5533 f_ctrs_bsc_and_bts_init();
5534
5535 pars.last_used_eutran_plmn := '323454'O;
5536 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
5537 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
5538
5539 vc_conn := f_start_handler(refers(f_tc_srvcc_eutran_to_geran_ho_out), pars);
5540 vc_conn.done;
5541
5542 f_ctrs_bsc_and_bts_add(0, "handover:attempted", 2);
5543 f_ctrs_bsc_and_bts_add(0, "handover:completed", 2);
5544 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:attempted", 1);
5545 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:completed", 1);
5546 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted", 1);
5547 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:completed", 1);
Pau Espin Pedrol211a7142021-06-15 16:43:03 +02005548
5549 f_ctrs_bsc_and_bts_add(0, "srvcc:attempted", 1);
5550 f_ctrs_bsc_and_bts_add(0, "srvcc:completed", 1);
Pau Espin Pedrol35801c32021-04-19 13:03:20 +02005551 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol9ae36d52021-06-15 17:29:43 +02005552
5553 if (disable_fast_return) {
5554 f_vty_allow_srvcc_fast_return(false, 0);
5555 }
Pau Espin Pedrol35801c32021-04-19 13:03:20 +02005556 f_shutdown_helper();
5557}
5558
Pau Espin Pedrol9ae36d52021-06-15 17:29:43 +02005559/* First, HO into BSC from EUTRAN (SRVCC): HO Request contains "Old BSS to New
5560 BSS Information" IE with "Last Used E-UTRAN PLMN Id".
5561 Second, HO to another BSC: HO Required contains "Old BSS to New BSS Information"
5562 IE with "Last Used E-UTRAN PLMN Id" from first step. */
5563testcase TC_srvcc_eutran_to_geran_ho_out() runs on test_CT {
5564 f_tc_srvcc_eutran_to_geran_ho_out_main(false);
5565}
5566/* Validate subsequent intra-GSM-HO works the same (with OldBSSToNewBSSInfo IE)
5567 * independently of fast-reture allowed/forbidden in local BTS */
5568testcase TC_srvcc_eutran_to_geran_ho_out_forbid_fast_return() runs on test_CT {
5569 f_tc_srvcc_eutran_to_geran_ho_out_main(true);
5570}
5571
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005572private function f_tc_ho_in_fail_msc_clears(charstring id) runs on MSC_ConnHdlr {
5573 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
5574 f_rslem_register(0, new_chan_nr);
5575 g_chan_nr := new_chan_nr;
5576 f_sleep(1.0);
5577
5578 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
5579 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
5580 activate(as_Media());
5581
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005582 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005583 f_gen_handover_req()));
Harald Welte6811d102019-04-14 22:23:14 +02005584 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005585
5586 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
5587
5588 var PDU_BSSAP rx_bssap;
5589 var octetstring ho_command_str;
5590
5591 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
5592
5593 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
5594 log("Received L3 Info in HO Request Ack: ", ho_command_str);
5595 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
5596 log("L3 Info in HO Request Ack is ", ho_command);
5597
5598 var GsmArfcn arfcn;
5599 var RslChannelNr actual_new_chan_nr;
5600 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
5601 actual_new_chan_nr, arfcn);
5602
5603 if (actual_new_chan_nr != new_chan_nr) {
5604 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
5605 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
5606 setverdict(fail);
5607 return;
5608 }
5609 log("Handover Command chan_nr is", actual_new_chan_nr);
5610
Neels Hofmeyr61ca08d2019-05-06 23:52:22 +02005611 /* For deterministic test results, give some time for the MGW endpoint to be configured */
5612 f_sleep(1.0);
5613
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005614 /* Now the MSC forwards the RR Handover Command to the other BSC, which
5615 * tells the MS to handover to the new lchan. In this case, the MS
5616 * reports a Handover Failure to the old BSS, which forwards a BSSMAP
5617 * Handover Failure to the MSC. The procedure according to 3GPP TS
5618 * 48.008 3.1.5.3.2 "Handover Failure" is then that the MSC sends a
5619 * BSSMAP Clear Command: */
5620
5621 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_RADIO_INTERFACE_FAILURE_REVERSION;
5622 var BssmapCause cause := enum2int(cause_val);
5623 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
5624
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02005625 f_expect_dlcx_conns();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005626 setverdict(pass);
5627 f_sleep(1.0);
5628
5629 setverdict(pass);
5630}
5631testcase TC_ho_in_fail_msc_clears() runs on test_CT {
5632 var MSC_ConnHdlr vc_conn;
5633 var TestHdlrParams pars := f_gen_test_hdlr_pars();
5634
5635 f_init(1, true);
5636 f_sleep(1.0);
5637
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005638 f_ctrs_bsc_and_bts_init();
5639
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005640 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
5641 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005642
5643 vc_conn := f_start_handler(refers(f_tc_ho_in_fail_msc_clears), pars);
5644 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005645
5646 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5647 f_ctrs_bsc_and_bts_add(0, "handover:stopped");
5648 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:attempted");
5649 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:stopped");
5650 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005651 f_shutdown_helper();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005652}
5653
5654private function f_tc_ho_in_fail_msc_clears_after_ho_detect(charstring id) runs on MSC_ConnHdlr {
5655 /* Hack: the proper way would be to wait for the BSSMAP Handover Request ACK and extract the
5656 * actual assigned chan_nr from its L3 (RR Handover Command) message. But osmo-bsc starts acting
5657 * on the lchan even before we get a chance to evaluate the BSSMAP Handover Request ACK. So we
5658 * need to assume that osmo-bsc will activate TS 1 and already set up this lchan's RSL emulation
5659 * before we get started. */
5660 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
5661 f_rslem_register(0, new_chan_nr);
5662 g_chan_nr := new_chan_nr;
5663 f_sleep(1.0);
5664
5665 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
5666 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
5667 activate(as_Media());
5668
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005669 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005670 f_gen_handover_req()));
Harald Welte6811d102019-04-14 22:23:14 +02005671 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005672
5673 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
5674
5675 var PDU_BSSAP rx_bssap;
5676 var octetstring ho_command_str;
5677
5678 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
5679
5680 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
5681 log("Received L3 Info in HO Request Ack: ", ho_command_str);
5682 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
5683 log("L3 Info in HO Request Ack is ", ho_command);
5684
5685 var GsmArfcn arfcn;
5686 var RslChannelNr actual_new_chan_nr;
5687 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
5688 actual_new_chan_nr, arfcn);
5689
5690 if (actual_new_chan_nr != new_chan_nr) {
5691 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
5692 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
5693 setverdict(fail);
5694 return;
5695 }
5696 log("Handover Command chan_nr is", actual_new_chan_nr);
5697
5698 /* Now the MSC forwards the RR Handover Command to the other BSC, which
5699 * tells the MS to handover to the new lchan. Here comes the new MS on
5700 * the new lchan with a Handover RACH: */
5701
5702 /* send handover detect */
5703
5704 RSL.send(ts_RSL_HANDO_DET(new_chan_nr));
5705
5706 BSSAP.receive(tr_BSSMAP_HandoverDetect);
5707
5708 /* The MSC chooses to clear the connection now, maybe we got the
5709 * Handover RACH on the new cell but the MS still signaled Handover
5710 * Failure to the old BSS? */
5711
5712 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_RADIO_INTERFACE_FAILURE_REVERSION;
5713 var BssmapCause cause := enum2int(cause_val);
5714 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
5715
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02005716 f_expect_dlcx_conns();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005717 f_sleep(1.0);
5718}
5719testcase TC_ho_in_fail_msc_clears_after_ho_detect() runs on test_CT {
5720 var MSC_ConnHdlr vc_conn;
5721 var TestHdlrParams pars := f_gen_test_hdlr_pars();
5722
5723 f_init(1, true);
5724 f_sleep(1.0);
5725
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005726 f_ctrs_bsc_and_bts_init();
5727
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005728 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
5729 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005730
5731 vc_conn := f_start_handler(refers(f_tc_ho_in_fail_msc_clears_after_ho_detect), pars);
5732 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005733
5734 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5735 f_ctrs_bsc_and_bts_add(0, "handover:stopped");
5736 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:attempted");
5737 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:stopped");
5738 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005739 f_shutdown_helper();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005740}
5741
5742/* The new BSS's lchan times out before the MSC decides that handover failed. */
5743private function f_tc_ho_in_fail_no_detect(charstring id) runs on MSC_ConnHdlr {
5744 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
5745 f_rslem_register(0, new_chan_nr);
5746 g_chan_nr := new_chan_nr;
5747 f_sleep(1.0);
5748
5749 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
5750 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
5751 activate(as_Media());
5752
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005753 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005754 f_gen_handover_req()));
Harald Welte6811d102019-04-14 22:23:14 +02005755 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005756
5757 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
5758
5759 var PDU_BSSAP rx_bssap;
5760 var octetstring ho_command_str;
5761
5762 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
5763
5764 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
5765 log("Received L3 Info in HO Request Ack: ", ho_command_str);
5766 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
5767 log("L3 Info in HO Request Ack is ", ho_command);
5768
5769 var GsmArfcn arfcn;
5770 var RslChannelNr actual_new_chan_nr;
5771 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
5772 actual_new_chan_nr, arfcn);
5773
5774 if (actual_new_chan_nr != new_chan_nr) {
5775 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
5776 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
5777 setverdict(fail);
5778 return;
5779 }
5780 log("Handover Command chan_nr is", actual_new_chan_nr);
5781
5782 /* Now the MSC forwards the RR Handover Command to the other BSC, which
5783 * tells the MS to handover to the new lchan. But the MS never shows up
5784 * on the new lchan. */
5785
5786 BSSAP.receive(tr_BSSMAP_HandoverFailure);
5787
5788 /* Did osmo-bsc also send a Clear Request? */
5789 timer T := 0.5;
5790 T.start;
5791 alt {
5792 [] BSSAP.receive(tr_BSSMAP_ClearRequest);
5793 [] T.timeout { }
5794 }
5795
5796 /* MSC plays along with a Clear Command (no matter whether osmo-bsc
5797 * asked for it, this is a Handover Failure after all). */
5798
5799 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_RADIO_INTERFACE_FAILURE_REVERSION;
5800 var BssmapCause cause := enum2int(cause_val);
5801 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
5802
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02005803 f_expect_dlcx_conns();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005804 f_sleep(1.0);
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005805}
5806testcase TC_ho_in_fail_no_detect() runs on test_CT {
5807 var MSC_ConnHdlr vc_conn;
5808 var TestHdlrParams pars := f_gen_test_hdlr_pars();
5809
5810 f_init(1, true);
5811 f_sleep(1.0);
5812
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005813 f_ctrs_bsc_and_bts_init();
5814
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005815 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
5816 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005817
5818 vc_conn := f_start_handler(refers(f_tc_ho_in_fail_no_detect), pars);
5819 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005820
5821 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5822 f_ctrs_bsc_and_bts_add(0, "handover:error");
5823 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:attempted");
5824 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:error");
5825 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005826 f_shutdown_helper();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005827}
5828
5829/* Same as f_tc_ho_in_fail_no_detect, but MSC fails to send a Clear Command */
5830private function f_tc_ho_in_fail_no_detect2(charstring id) runs on MSC_ConnHdlr {
5831 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
5832 f_rslem_register(0, new_chan_nr);
5833 g_chan_nr := new_chan_nr;
5834 f_sleep(1.0);
5835
5836 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
5837 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
5838 activate(as_Media());
5839
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005840 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005841 f_gen_handover_req()));
Harald Welte6811d102019-04-14 22:23:14 +02005842 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005843
5844 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
5845
5846 var PDU_BSSAP rx_bssap;
5847 var octetstring ho_command_str;
5848
5849 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
5850
5851 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
5852 log("Received L3 Info in HO Request Ack: ", ho_command_str);
5853 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
5854 log("L3 Info in HO Request Ack is ", ho_command);
5855
5856 var GsmArfcn arfcn;
5857 var RslChannelNr actual_new_chan_nr;
5858 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
5859 actual_new_chan_nr, arfcn);
5860
5861 if (actual_new_chan_nr != new_chan_nr) {
5862 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
5863 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
5864 setverdict(fail);
5865 return;
5866 }
5867 log("Handover Command chan_nr is", actual_new_chan_nr);
5868
5869 /* Now the MSC forwards the RR Handover Command to the other BSC, which
5870 * tells the MS to handover to the new lchan. But the MS never shows up
5871 * on the new lchan. */
5872
5873 BSSAP.receive(tr_BSSMAP_HandoverFailure);
5874
5875 /* MSC plays dumb and sends no Clear Command */
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005876 var PDU_BSSAP rx_clear_request;
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02005877
5878 BSSAP.receive(tr_BSSMAP_ClearRequest) -> value rx_clear_request {
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005879 var BssmapCause cause := bit2int(rx_clear_request.pdu.bssmap.clearRequest.cause.causeValue);
5880 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
5881 };
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02005882 f_expect_dlcx_conns();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005883 f_sleep(1.0);
5884}
5885testcase TC_ho_in_fail_no_detect2() runs on test_CT {
5886 var MSC_ConnHdlr vc_conn;
5887 var TestHdlrParams pars := f_gen_test_hdlr_pars();
5888
5889 f_init(1, true);
5890 f_sleep(1.0);
5891
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005892 f_ctrs_bsc_and_bts_init();
5893
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005894 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
5895 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005896
5897 vc_conn := f_start_handler(refers(f_tc_ho_in_fail_no_detect2), pars);
5898 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005899
5900 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5901 f_ctrs_bsc_and_bts_add(0, "handover:error");
5902 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:attempted");
5903 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:error");
5904 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005905 f_shutdown_helper();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005906}
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005907
Neels Hofmeyr91401012019-07-11 00:42:35 +02005908type record of charstring Commands;
5909
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005910private function f_bts_0_cfg(TELNETasp_PT pt, Commands cmds := {})
Neels Hofmeyr91401012019-07-11 00:42:35 +02005911{
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005912 f_vty_enter_cfg_bts(pt, 0);
Neels Hofmeyr91401012019-07-11 00:42:35 +02005913 for (var integer i := 0; i < sizeof(cmds); i := i+1) {
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005914 f_vty_transceive(pt, cmds[i]);
Neels Hofmeyr91401012019-07-11 00:42:35 +02005915 }
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005916 f_vty_transceive(pt, "end");
Neels Hofmeyr91401012019-07-11 00:42:35 +02005917}
5918
Pau Espin Pedrolc675b612020-01-09 19:55:40 +01005919private function f_cs7_inst_0_cfg(TELNETasp_PT pt, Commands cmds := {})
5920{
5921 f_vty_enter_cfg_cs7_inst(pt, 0);
5922 for (var integer i := 0; i < sizeof(cmds); i := i+1) {
5923 f_vty_transceive(pt, cmds[i]);
5924 }
5925 f_vty_transceive(pt, "end");
5926}
5927
Neels Hofmeyr91401012019-07-11 00:42:35 +02005928private function f_probe_for_handover(charstring log_label,
5929 charstring log_descr,
5930 charstring handover_vty_cmd,
5931 boolean expect_handover,
5932 boolean is_inter_bsc_handover := false)
5933runs on MSC_ConnHdlr
5934{
Neels Hofmeyrb3fc8982020-05-11 00:16:42 +02005935 /* We're going to thwart any and all handover attempts, just be ready to handle (and ignore) handover target
5936 * lchans to be established on bts 1 or bts 2. */
5937 f_rslem_suspend(RSL1_PROC);
5938 f_rslem_suspend(RSL2_PROC);
5939
Neels Hofmeyr91401012019-07-11 00:42:35 +02005940 var RSL_Message rsl;
5941
5942 var charstring log_msg := " (expecting handover)"
5943 if (not expect_handover) {
5944 log_msg := " (expecting NO handover)";
5945 }
5946 log("f_probe_for_handover starting: " & log_label & ": " & log_descr & log_msg);
5947 f_vty_transceive(BSCVTY, handover_vty_cmd);
5948
Neels Hofmeyr91401012019-07-11 00:42:35 +02005949 timer T := 2.0;
5950 T.start;
5951
5952 alt {
5953 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr)) -> value rsl {
5954 var PDU_ML3_NW_MS l3 := dec_PDU_ML3_NW_MS(rsl.ies[2].body.l3_info.payload);
5955 log("Rx L3 from net: ", l3);
5956 if (ischosen(l3.msgs.rrm.handoverCommand)) {
5957 var RslChannelNr new_chan_nr;
5958 var GsmArfcn arfcn;
5959 f_ChDesc2RslChanNr(l3.msgs.rrm.handoverCommand.channelDescription2,
5960 new_chan_nr, arfcn);
5961 log("Handover to new chan ", new_chan_nr, " on ARFCN ", arfcn);
5962 log(l3.msgs.rrm.handoverCommand);
5963
5964 /* Need to register for new lchan on new BTS -- it's either bts 1 or bts 2. It doesn't really
5965 * matter on which BTS it really is, we're not going to follow through an entire handover
5966 * anyway. */
5967 f_rslem_register(0, new_chan_nr, RSL1_PROC);
5968 f_rslem_resume(RSL1_PROC);
5969 f_rslem_register(0, new_chan_nr, RSL2_PROC);
5970 f_rslem_resume(RSL2_PROC);
5971
5972 if (expect_handover and not is_inter_bsc_handover) {
5973 setverdict(pass);
5974 log("f_probe_for_handover(" & log_label & "): Got RSL Handover Command as expected.");
5975 } else {
5976 setverdict(fail, "f_probe_for_handover(" & log_label & "): Expected none, but got RSL Handover Command. "
5977 & log_label & ": " & log_descr);
5978 }
5979
5980 log("f_probe_for_handover(" & log_label & "): Ending the test: Handover Failure stops the procedure.");
5981 /* osmo-bsc has triggered Handover. That's all we need to know for this test, reply with
5982 * Handover Failure. */
5983 f_rsl_send_l3(ts_RRM_HandoverFailure('00'O));
5984
5985 /* target BTS is told to release lchan again; don't care which BTS nor what messages. */
5986 f_sleep(0.5);
5987 RSL1.clear;
5988 RSL2.clear;
5989 log("f_probe_for_handover(" & log_label & "): done (got RSL Handover Command)");
5990 break;
5991 } else {
5992 repeat;
5993 }
5994 }
5995 [] BSSAP.receive(tr_BSSMAP_HandoverRequired) {
5996 if (expect_handover and is_inter_bsc_handover) {
5997 setverdict(pass);
5998 log("f_probe_for_handover(" & log_label & "): Got BSSMAP Handover Required as expected.");
5999 } else {
6000 setverdict(fail, "f_probe_for_handover(" & log_label & "): Expected none, but got BSSMAP Handover Required. "
6001 & log_label & ": " & log_descr);
6002 }
6003
6004 log("f_probe_for_handover(" & log_label & "): done (got BSSMAP Handover Required)");
6005
6006 /* Note: f_tc_ho_neighbor_config_start() sets T7, the timeout for BSSMAP Handover Required, to
6007 * 1 second. There is no legal way to quickly abort a handover after a BSSMAP Handover Required,
6008 * setting a short timeout and waiting is the only way. */
6009 log("f_probe_for_handover(" & log_label & "): waiting for inter-BSC HO to time out...");
6010 f_sleep(1.5);
6011 log("f_probe_for_handover(" & log_label & "): ...done");
6012
6013 break;
6014 }
6015 [] T.timeout {
6016 if (expect_handover) {
6017 setverdict(fail, "f_probe_for_handover(" & log_label & "): Expected Handover, but got none. "
6018 & log_label & ": " & log_descr);
6019 } else {
6020 setverdict(pass);
6021 log("f_probe_for_handover(" & log_label & "): Got no Handover, as expected.");
6022 }
6023 log("f_probe_for_handover(" & log_label & "): done (got no Handover)");
6024 break;
6025 }
6026 }
6027
6028 f_rslem_resume(RSL1_PROC);
6029 f_rslem_resume(RSL2_PROC);
6030 f_sleep(3.0);
6031 RSL.clear;
6032
6033 log("f_probe_for_handover(" & log_label & "): done clearing");
6034}
6035
6036/* Test the effect of various neighbor configuration scenarios:
6037 *
6038 * To avoid complexity, block off any actual handover operation, and always remain on the lchan at bts 0.
6039 * Reconfigure the neighbors for bts 0, trigger a Handover, and probe whether osmo-bsc does or doesn't start HO.
6040 */
6041private function f_tc_ho_neighbor_config_start() runs on MSC_ConnHdlr {
6042 g_pars := f_gen_test_hdlr_pars();
6043 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
6044 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Neels Hofmeyr91401012019-07-11 00:42:35 +02006045
6046 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
6047 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
6048
6049 /* Establish lchan at bts 0 */
6050 f_establish_fully(ass_cmd, exp_compl);
6051
6052 /* Shorten the inter-BSC Handover timeout, to not wait so long for inter-BSC Handovers */
6053 f_vty_enter_cfg_network(BSCVTY);
6054 f_vty_transceive(BSCVTY, "timer T7 1");
6055 f_vty_transceive(BSCVTY, "end");
6056}
6057
6058private function f_tc_ho_neighbor_config_1(charstring id) runs on MSC_ConnHdlr {
6059 f_tc_ho_neighbor_config_start();
6060
6061 /*
6062 * bts 0 ARFCN 871 BSIC 10
6063 * bts 1 ARFCN 871 BSIC 11
6064 * bts 2 ARFCN 871 BSIC 12
6065 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
6066 */
6067
6068 log("f_tc_ho_neighbor_config: 1. No 'neighbor' config");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02006069 f_bts_0_cfg(BSCVTY, {"no neighbors"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02006070 f_probe_for_handover("1.a", "HO to bts 1 works, implicitly listed as neighbor (legacy behavior when none are configured)",
6071 "handover any to arfcn 871 bsic 11",
6072 true);
6073
6074 f_probe_for_handover("1.b", "HO to unknown cell does not start",
6075 "handover any to arfcn 13 bsic 39",
6076 false);
6077
6078 f_probe_for_handover("1.c", "HO to 871-12 is ambiguous = error",
6079 "handover any to arfcn 871 bsic 12",
6080 false);
6081
6082 f_probe_for_handover("1.d", "HO to 871-11 still works (verify that this test properly cleans up)",
6083 "handover any to arfcn 871 bsic 11",
6084 true);
6085}
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006086testcase TC_ho_neighbor_config_1() runs on test_CT {
6087 var MSC_ConnHdlr vc_conn;
6088 f_init(3, true, guard_timeout := 60.0);
6089 f_sleep(1.0);
6090 f_ctrs_bsc_and_bts_init();
6091 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_1));
6092 vc_conn.done;
6093
6094 /* f_tc_ho_neighbor_config_start() */
6095 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
6096 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
6097
6098 /* 1.a */
6099 /* "failed" means a handover was triggered and started (which is all this test aims for) and the test ended the
6100 * handover quickly by sending a Handover Failure message. */
6101 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
6102 f_ctrs_bsc_and_bts_add(0, "handover:failed");
6103 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
6104 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:failed");
6105
6106 /* 1.b */
6107 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
6108 f_ctrs_bsc_and_bts_add(0, "handover:error");
6109
6110 /* 1.c */
6111 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
6112 f_ctrs_bsc_and_bts_add(0, "handover:error");
6113
6114 /* 1.d */
6115 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
6116 f_ctrs_bsc_and_bts_add(0, "handover:failed");
6117 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
6118 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:failed");
6119
6120 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006121 f_shutdown_helper();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006122}
6123
Neels Hofmeyr91401012019-07-11 00:42:35 +02006124private function f_tc_ho_neighbor_config_2(charstring id) runs on MSC_ConnHdlr {
6125 f_tc_ho_neighbor_config_start();
6126
6127 /*
6128 * bts 0 ARFCN 871 BSIC 10
6129 * bts 1 ARFCN 871 BSIC 11
6130 * bts 2 ARFCN 871 BSIC 12
6131 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
6132 */
6133
6134 log("f_tc_ho_neighbor_config: 2. explicit local neighbor: 'neighbor bts 1'");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02006135 f_bts_0_cfg(BSCVTY, {"neighbor bts 1"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02006136 f_sleep(0.5);
6137
6138 f_probe_for_handover("2.a", "HO to bts 1 works, explicitly listed as neighbor",
6139 "handover any to arfcn 871 bsic 11",
6140 true);
6141
6142 f_probe_for_handover("2.b", "HO to bts 2 doesn't work, not listed as neighbor",
6143 "handover any to arfcn 871 bsic 12",
6144 false);
6145}
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006146testcase TC_ho_neighbor_config_2() runs on test_CT {
6147 var MSC_ConnHdlr vc_conn;
6148 f_init(3, true, guard_timeout := 50.0);
6149 f_sleep(1.0);
6150 f_ctrs_bsc_and_bts_init();
6151 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_2));
6152 vc_conn.done;
6153
6154 /* f_tc_ho_neighbor_config_start() */
6155 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
6156 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
6157
6158 /* 2.a */
6159 /* "failed" means a handover was triggered and started (which is all this test aims for) and the test ended the
6160 * handover quickly by sending a Handover Failure message. */
6161 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
6162 f_ctrs_bsc_and_bts_add(0, "handover:failed");
6163 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
6164 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:failed");
6165
6166 /* 2.b */
6167 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
6168 f_ctrs_bsc_and_bts_add(0, "handover:error");
6169
6170 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006171 f_shutdown_helper();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006172}
6173
Neels Hofmeyr91401012019-07-11 00:42:35 +02006174private function f_tc_ho_neighbor_config_3(charstring id) runs on MSC_ConnHdlr {
6175 f_tc_ho_neighbor_config_start();
6176
6177 /*
6178 * bts 0 ARFCN 871 BSIC 10
6179 * bts 1 ARFCN 871 BSIC 11
6180 * bts 2 ARFCN 871 BSIC 12
6181 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
6182 */
6183
6184 log("f_tc_ho_neighbor_config: 3. explicit local neighbor: 'neighbor bts 2'");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02006185 f_bts_0_cfg(BSCVTY, {"no neighbors", "neighbor bts 2"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02006186 f_sleep(0.5);
6187
6188 f_probe_for_handover("3.a", "HO to bts 1 doesn't work, not listed as neighbor",
6189 "handover any to arfcn 871 bsic 11",
6190 false);
6191 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",
6192 "handover any to arfcn 871 bsic 12",
6193 true);
6194}
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006195testcase TC_ho_neighbor_config_3() runs on test_CT {
6196 var MSC_ConnHdlr vc_conn;
6197 f_init(3, true, guard_timeout := 50.0);
6198 f_sleep(1.0);
6199 f_ctrs_bsc_and_bts_init();
6200 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_3));
6201 vc_conn.done;
6202
6203 /* f_tc_ho_neighbor_config_start() */
6204 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
6205 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
6206
6207 /* 3.a */
6208 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
6209 f_ctrs_bsc_and_bts_add(0, "handover:error");
6210
6211 /* 3.b */
6212 /* "failed" means a handover was triggered and started (which is all this test aims for) and the test ended the
6213 * handover quickly by sending a Handover Failure message. */
6214 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
6215 f_ctrs_bsc_and_bts_add(0, "handover:failed");
6216 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
6217 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:failed");
6218
6219 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006220 f_shutdown_helper();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006221}
6222
Neels Hofmeyr91401012019-07-11 00:42:35 +02006223private function f_tc_ho_neighbor_config_4(charstring id) runs on MSC_ConnHdlr {
6224 f_tc_ho_neighbor_config_start();
6225
6226 /*
6227 * bts 0 ARFCN 871 BSIC 10
6228 * bts 1 ARFCN 871 BSIC 11
6229 * bts 2 ARFCN 871 BSIC 12
6230 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
6231 */
6232
6233 log("f_tc_ho_neighbor_config: 4. explicit remote neighbor: 'neighbor lac 99 arfcn 123 bsic 45'");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02006234 f_bts_0_cfg(BSCVTY, {"no neighbors", "neighbor lac 99 arfcn 123 bsic 45"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02006235 f_sleep(0.5);
6236
6237 f_probe_for_handover("4.a", "HO to bts 1 doesn't work, not listed as neighbor",
6238 "handover any to arfcn 871 bsic 11",
6239 false);
6240 f_probe_for_handover("4.b", "HO to bts 2 doesn't work, not listed as neighbor",
6241 "handover any to arfcn 871 bsic 12",
6242 false);
6243 f_probe_for_handover("4.c", "HO to 123-45 triggers inter-BSC HO",
6244 "handover any to arfcn 123 bsic 45",
6245 true, true);
6246}
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006247testcase TC_ho_neighbor_config_4() runs on test_CT {
6248 var MSC_ConnHdlr vc_conn;
6249 f_init(3, true, guard_timeout := 50.0);
6250 f_sleep(1.0);
6251 f_ctrs_bsc_and_bts_init();
6252 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_4));
6253 vc_conn.done;
6254
6255 /* f_tc_ho_neighbor_config_start() */
6256 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
6257 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
6258
6259 /* 4.a */
6260 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
6261 f_ctrs_bsc_and_bts_add(0, "handover:error");
6262
6263 /* 4.b */
6264 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
6265 f_ctrs_bsc_and_bts_add(0, "handover:error");
6266
6267 /* 4.c */
6268 /* "timeout" means a handover was triggered and started (which is all this test aims for) and the test ended the
6269 * handover quickly by timing out after the Handover Required message */
6270 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
6271 f_ctrs_bsc_and_bts_add(0, "handover:timeout");
6272 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
6273 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:timeout");
6274
6275 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006276 f_shutdown_helper();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006277}
6278
Neels Hofmeyr91401012019-07-11 00:42:35 +02006279private function f_tc_ho_neighbor_config_5(charstring id) runs on MSC_ConnHdlr {
6280 f_tc_ho_neighbor_config_start();
6281
6282 /*
6283 * bts 0 ARFCN 871 BSIC 10
6284 * bts 1 ARFCN 871 BSIC 11
6285 * bts 2 ARFCN 871 BSIC 12
6286 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
6287 */
6288
6289 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 +02006290 f_bts_0_cfg(BSCVTY, {"no neighbors", "neighbor lac 99 arfcn 871 bsic 12"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02006291 f_sleep(0.5);
6292
6293 f_probe_for_handover("5.a", "HO to 871-12 triggers inter-BSC HO (ignoring local cells with same ARFCN+BSIC)",
6294 "handover any to arfcn 871 bsic 12",
6295 true, true);
6296}
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006297testcase TC_ho_neighbor_config_5() runs on test_CT {
6298 var MSC_ConnHdlr vc_conn;
6299 f_init(3, true);
6300 f_sleep(1.0);
6301 f_ctrs_bsc_and_bts_init();
6302 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_5));
6303 vc_conn.done;
6304
6305 /* f_tc_ho_neighbor_config_start() */
6306 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
6307 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
6308
6309 /* 5 */
6310 /* "timeout" means a handover was triggered and started (which is all this test aims for) and the test ended the
6311 * handover quickly by timing out after the Handover Required message */
6312 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
6313 f_ctrs_bsc_and_bts_add(0, "handover:timeout");
6314 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
6315 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:timeout");
6316
6317 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006318 f_shutdown_helper();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006319}
6320
Neels Hofmeyr91401012019-07-11 00:42:35 +02006321private function f_tc_ho_neighbor_config_6(charstring id) runs on MSC_ConnHdlr {
6322 f_tc_ho_neighbor_config_start();
6323
6324 /*
6325 * bts 0 ARFCN 871 BSIC 10
6326 * bts 1 ARFCN 871 BSIC 11
6327 * bts 2 ARFCN 871 BSIC 12
6328 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
6329 */
6330
6331 log("f_tc_ho_neighbor_config: 6. config error: explicit local and remote neighbors with ambiguous ARFCN+BSIC:"
6332 & " 'neighbor bts 2; neighbor lac 99 arfcn 871 bsic 12'");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02006333 f_bts_0_cfg(BSCVTY, {"no neighbors", "neighbor bts 2", "neighbor lac 99 arfcn 871 bsic 12"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02006334 f_sleep(0.5);
6335
6336 f_probe_for_handover("6.a", "HO to 871-12 is ambiguous = error",
6337 "handover any to arfcn 871 bsic 12",
6338 false);
6339}
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006340testcase TC_ho_neighbor_config_6() runs on test_CT {
6341 var MSC_ConnHdlr vc_conn;
6342 f_init(3, true);
6343 f_sleep(1.0);
6344 f_ctrs_bsc_and_bts_init();
6345 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_6));
6346 vc_conn.done;
6347
6348 /* f_tc_ho_neighbor_config_start() */
6349 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
6350 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
6351
6352 /* 6.a */
6353 /* "timeout" means a handover was triggered and started (which is all this test aims for) and the test ended the
6354 * handover quickly by timing out after the Handover Required message */
6355 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
6356 f_ctrs_bsc_and_bts_add(0, "handover:error");
6357
6358 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006359 f_shutdown_helper();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006360}
6361
Neels Hofmeyr91401012019-07-11 00:42:35 +02006362private function f_tc_ho_neighbor_config_7(charstring id) runs on MSC_ConnHdlr {
6363 f_tc_ho_neighbor_config_start();
6364
6365 /*
6366 * bts 0 ARFCN 871 BSIC 10
6367 * bts 1 ARFCN 871 BSIC 11
6368 * bts 2 ARFCN 871 BSIC 12
6369 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
6370 */
6371
6372 log("f_tc_ho_neighbor_config: 7. explicit local and remote neighbors:"
6373 & " 'neighbor bts 2; neighbor lac 99 arfcn 123 bsic 45'");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02006374 f_bts_0_cfg(BSCVTY, {"no neighbors", "neighbor bts 2", "neighbor lac 99 arfcn 123 bsic 45"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02006375 f_sleep(0.5);
6376
6377 f_probe_for_handover("7.a", "HO to 871-12 does HO to bts 2",
6378 "handover any to arfcn 871 bsic 12",
6379 true);
6380 f_probe_for_handover("7.b", "HO to 123-45 triggers inter-BSC HO",
6381 "handover any to arfcn 123 bsic 45",
6382 true, true);
6383}
Neels Hofmeyr91401012019-07-11 00:42:35 +02006384testcase TC_ho_neighbor_config_7() runs on test_CT {
6385 var MSC_ConnHdlr vc_conn;
Neels Hofmeyrf2b88032020-06-16 00:35:04 +02006386 f_init(3, true, guard_timeout := 50.0);
Neels Hofmeyr91401012019-07-11 00:42:35 +02006387 f_sleep(1.0);
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006388 f_ctrs_bsc_and_bts_init();
Neels Hofmeyr91401012019-07-11 00:42:35 +02006389 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_7));
6390 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006391
6392 /* f_tc_ho_neighbor_config_start() */
6393 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
6394 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
6395
6396 /* 7.a */
6397 /* "failed" means a handover was triggered and started (which is all this test aims for) and the test ended the
6398 * handover quickly by sending a Handover Failure message. */
6399 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
6400 f_ctrs_bsc_and_bts_add(0, "handover:failed");
6401 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
6402 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:failed");
6403
6404 /* 7.b */
6405 /* "timeout" means a handover was triggered and started (which is all this test aims for) and the test ended the
6406 * handover quickly by timing out after the Handover Required message */
6407 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
6408 f_ctrs_bsc_and_bts_add(0, "handover:timeout");
6409 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
6410 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:timeout");
6411
6412 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006413 f_shutdown_helper();
Neels Hofmeyr91401012019-07-11 00:42:35 +02006414}
6415
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01006416/* OS#3041: Open and close N connections in a normal fashion, and expect no
6417 * BSSMAP Reset just because of that. */
6418testcase TC_bssap_rlsd_does_not_cause_bssmap_reset() runs on test_CT {
6419 var default d;
6420 var integer i;
6421 var DchanTuple dt;
6422
6423 f_init();
6424
6425 /* Wait for initial BSSMAP Reset to pass */
6426 f_sleep(4.0);
6427
6428 d := activate(no_bssmap_reset());
6429
6430 /* Setup up a number of connections and RLSD them again from the MSC
6431 * side. In the buggy behavior, the fourth one triggers BSSMAP Reset.
6432 * Let's do it some more times for good measure. */
Harald Weltec3260d92018-06-11 17:48:16 +02006433 for (i := 0; i < 4; i := i+1) {
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01006434 /* Since we're doing a lot of runs, give each one a fresh
6435 * T_guard from the top. */
6436 T_guard.start;
6437
6438 /* Setup a BSSAP connection and clear it right away. This is
6439 * the MSC telling the BSC about a planned release, it's not an
6440 * erratic loss of a connection. */
Harald Weltea1897182018-06-11 13:53:09 +02006441 dt := f_est_dchan(int2oct(i,1), 23+i, '00010203040506'O);
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01006442
6443 /* MSC disconnects (RLSD). */
6444 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
6445 }
6446
6447 /* In the buggy behavior, a timeout of 2 seconds happens between above
6448 * trigger (logs "SIGTRAN connection down, reconnecting...") and the
6449 * actual BSSMAP Reset. Wait a bit longer just to make sure. */
6450 f_sleep(4.0);
6451
6452 deactivate(d);
6453 f_shutdown_helper();
6454}
Harald Welte552620d2017-12-16 23:21:36 +01006455
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01006456/* OS#3041: Open and close N connections in a normal fashion, and expect no
6457 * BSSMAP Reset just because of that. Invoke the release by a BSSMAP Clear from
6458 * the MSC. */
6459testcase TC_bssmap_clear_does_not_cause_bssmap_reset() runs on test_CT {
6460 var default d;
6461 var integer i;
6462 var DchanTuple dt;
6463 var BSSAP_N_DATA_ind rx_di;
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01006464 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_CALL_CONTROL;
6465 var BssmapCause cause := enum2int(cause_val);
6466
6467 f_init();
6468
6469 /* Wait for initial BSSMAP Reset to pass */
6470 f_sleep(4.0);
6471
6472 d := activate(no_bssmap_reset());
6473
6474 /* Setup up a number of connections and RLSD them again from the MSC
6475 * side. In the buggy behavior, the fourth one triggers BSSMAP Reset.
6476 * Let's do it some more times for good measure. */
6477 for (i := 0; i < 8; i := i+1) {
6478 /* Since we're doing a lot of runs, give each one a fresh
6479 * T_guard from the top. */
6480 T_guard.start;
6481
6482 /* Setup a BSSAP connection and clear it right away. This is
6483 * the MSC telling the BSC about a planned release, it's not an
6484 * erratic loss of a connection. */
Harald Weltea1897182018-06-11 13:53:09 +02006485 dt := f_est_dchan(int2oct(i,1), 23+i, '00010203040506'O);
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01006486
6487 /* Instruct BSC to clear channel */
6488 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
6489
6490 /* expect BSC to disable the channel */
Harald Welte641fcbe2018-06-14 10:58:35 +02006491 f_exp_chan_rel_and_clear(dt, 0);
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01006492 }
6493
6494 /* In the buggy behavior, a timeout of 2 seconds happens between above
6495 * trigger (logs "SIGTRAN connection down, reconnecting...") and the
6496 * actual BSSMAP Reset. Wait a bit longer just to make sure. */
6497 f_sleep(4.0);
6498
6499 deactivate(d);
6500 f_shutdown_helper();
6501}
6502
Neels Hofmeyrfd445c32018-03-09 15:39:31 +01006503/* OS#3041: Open and close N connections in a normal fashion, and expect no
6504 * BSSMAP Reset just because of that. Close connections from the MS side with a
6505 * Release Ind on RSL. */
6506testcase TC_ms_rel_ind_does_not_cause_bssmap_reset() runs on test_CT {
6507 var default d;
6508 var integer i;
6509 var DchanTuple dt;
6510 var BSSAP_N_DATA_ind rx_di;
Neels Hofmeyrfd445c32018-03-09 15:39:31 +01006511 var integer j;
6512
6513 f_init();
6514
6515 /* Wait for initial BSSMAP Reset to pass */
6516 f_sleep(4.0);
6517
6518 d := activate(no_bssmap_reset());
6519
6520 /* Setup up a number of connections and RLSD them again from the MSC
6521 * side. In the buggy behavior, the fourth one triggers BSSMAP Reset.
6522 * Let's do it some more times for good measure. */
6523 for (i := 0; i < 8; i := i+1) {
6524 /* Since we're doing a lot of runs, give each one a fresh
6525 * T_guard from the top. */
6526 T_guard.start;
6527
6528 /* Setup a BSSAP connection and clear it right away. This is
6529 * the MSC telling the BSC about a planned release, it's not an
6530 * erratic loss of a connection. */
6531 dt := f_est_dchan('23'O, 23, '00010203040506'O);
6532
6533 /* simulate RLL REL IND */
6534 f_ipa_tx(0, ts_RSL_REL_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0))));
6535
6536 /* expect Clear Request on MSC side */
6537 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearRequest)) -> value rx_di;
6538
6539 /* Instruct BSC to clear channel */
6540 var BssmapCause cause := bit2int(rx_di.userData.pdu.bssmap.clearRequest.cause.causeValue);
6541 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
6542
6543 /* expect BSC to disable the channel */
Harald Welte641fcbe2018-06-14 10:58:35 +02006544 f_exp_chan_rel_and_clear(dt, 0);
Neels Hofmeyrfd445c32018-03-09 15:39:31 +01006545 }
6546
6547 /* In the buggy behavior, a timeout of 2 seconds happens between above
6548 * trigger (logs "SIGTRAN connection down, reconnecting...") and the
6549 * actual BSSMAP Reset. Wait a bit longer just to make sure. */
6550 f_sleep(4.0);
6551
6552 deactivate(d);
6553 f_shutdown_helper();
6554}
6555
Harald Welte94e0c342018-04-07 11:33:23 +02006556/***********************************************************************
6557 * IPA style dynamic PDCH
6558 ***********************************************************************/
6559
6560private function f_dyn_ipa_pdch_act(integer bts_nr, integer trx_nr, integer ts_nr,
6561 template (omit) RSL_Cause nack := omit)
6562runs on test_CT {
6563 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(ts_nr));
6564 var RSL_Message rsl_unused;
6565 /* ask BSC via VTY to activate a given IPA style chan as PDCH */
6566 f_vty_ts_action("pdch activate", bts_nr, trx_nr, ts_nr);
6567 /* expect the BSC to issue the related RSL command */
6568 rsl_unused := f_exp_ipa_rx(0, tr_RSL_IPA_PDCH_ACT(chan_nr));
6569 if (istemplatekind(nack, "omit")) {
6570 /* respond with a related acknowledgement */
6571 f_ipa_tx(0, ts_RSL_IPA_PDCH_ACT_ACK(chan_nr, ts_RSL_IE_FrameNumber(2342)));
6572 } else {
6573 f_ipa_tx(0, ts_RSL_IPA_PDCH_ACT_NACK(chan_nr, valueof(nack)));
6574 }
6575}
6576
6577private function f_dyn_ipa_pdch_deact(integer bts_nr, integer trx_nr, integer ts_nr,
6578 template (omit) RSL_Cause nack := omit)
6579runs on test_CT {
6580 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(ts_nr));
6581 var RSL_Message rsl_unused;
6582 /* ask BSC via VTY to activate a given IPA style chan as PDCH */
6583 f_vty_ts_action("pdch deactivate", bts_nr, trx_nr, ts_nr);
6584 /* expect the BSC to issue the related RSL command */
6585 rsl_unused := f_exp_ipa_rx(0, tr_RSL_IPA_PDCH_DEACT(chan_nr));
6586 if (istemplatekind(nack, "omit")) {
6587 /* respond with a related acknowledgement */
6588 f_ipa_tx(0, ts_RSL_IPA_PDCH_DEACT_ACK(chan_nr));
6589 } else {
6590 f_ipa_tx(0, ts_RSL_IPA_PDCH_DEACT_NACK(chan_nr, valueof(nack)));
6591 }
6592}
6593
6594private function f_ts_dyn_mode_get(integer bts_nr, integer trx_nr, integer ts_nr)
6595runs on test_CT return charstring {
6596 var charstring cmd, resp;
6597 cmd := "show timeslot "&int2str(bts_nr)&" "&int2str(trx_nr)&" "&int2str(ts_nr);
Stefan Sperlingcff13562018-11-13 15:24:06 +01006598 return f_vty_transceive_match_regexp_retry(BSCVTY, cmd, "*\((*)\)*", 0, 4, 1.0);
Harald Welte94e0c342018-04-07 11:33:23 +02006599}
6600
6601private function f_ts_dyn_mode_assert(integer bts_nr, integer trx_nr, integer ts_nr,
6602 template charstring exp)
6603runs on test_CT {
6604 var charstring mode := f_ts_dyn_mode_get(bts_nr, trx_nr, ts_nr);
6605 if (not match(mode, exp)) {
6606 setverdict(fail, "Unexpected TS Mode: ", mode);
Daniel Willmannafce8662018-07-06 23:11:32 +02006607 mtc.stop;
Harald Welte94e0c342018-04-07 11:33:23 +02006608 }
6609}
6610
6611private function f_ts_set_chcomb(integer bts_nr, integer trx_nr, integer ts_nr, charstring chcomb)
6612runs on test_CT {
6613 f_vty_enter_cfg_ts(BSCVTY, bts_nr, trx_nr, ts_nr);
6614 f_vty_transceive(BSCVTY, "phys_chan_config " & chcomb);
6615 f_vty_transceive(BSCVTY, "end");
6616}
6617
6618private const charstring TCHF_MODE := "TCH/F mode";
6619private const charstring TCHH_MODE := "TCH/H mode";
6620private const charstring PDCH_MODE := "PDCH mode";
6621private const charstring NONE_MODE := "NONE mode";
Pau Espin Pedrol5b381082021-06-28 17:14:03 +02006622private const charstring SDCCH8_MODE := "SDCCH8 mode";
Harald Welte94e0c342018-04-07 11:33:23 +02006623
6624/* Test IPA PDCH activation / deactivation triggered by VTY */
6625testcase TC_dyn_pdch_ipa_act_deact() runs on test_CT {
6626 var RSL_Message rsl_unused;
6627
6628 /* change Timeslot 6 before f_init() starts RSL */
6629 f_init_vty();
6630 f_ts_set_chcomb(0, 0, 6, "TCH/F_PDCH");
6631 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
6632
6633 f_init(1, false);
6634 f_sleep(1.0);
6635
6636 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(6));
6637
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02006638 log("TCH/F_PDCH pchan starts out in TCH/F mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02006639 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
6640 /* The BSC will activate the dynamic PDCH by default, so confirm that */
6641 rsl_unused := f_exp_ipa_rx(0, tr_RSL_IPA_PDCH_ACT(chan_nr));
6642 f_ipa_tx(0, ts_RSL_IPA_PDCH_ACT_ACK(chan_nr, ts_RSL_IE_FrameNumber(2342)));
6643 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02006644 log("TCH/F_PDCH pchan, PDCH ACT was ACKed, so now in PDCH mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02006645 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, PDCH_MODE);
6646
6647 /* De-activate it via VTY */
6648 f_dyn_ipa_pdch_deact(0, 0, chan_nr.tn);
6649 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02006650 log("TCH/F_PDCH pchan, PDCH DEACT via VTY, so now back in TCH/F mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02006651 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
6652
6653 /* re-activate it via VTY */
6654 f_dyn_ipa_pdch_act(0, 0, chan_nr.tn);
6655 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02006656 log("TCH/F_PDCH pchan, PDCH ACT via VTY, so now in PDCH mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02006657 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, PDCH_MODE);
6658
6659 /* and finally de-activate it again */
6660 f_dyn_ipa_pdch_deact(0, 0, chan_nr.tn);
6661 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02006662 log("TCH/F_PDCH pchan, PDCH DEACT via VTY, so now back in TCH/F mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02006663 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
6664
Neels Hofmeyr887e8f12018-06-27 01:01:55 +02006665 /* clean up config */
6666 f_ts_set_chcomb(0, 0, 6, "PDCH");
6667
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006668 f_shutdown_helper();
Harald Welte94e0c342018-04-07 11:33:23 +02006669}
6670
6671/* Test IPA PDCH activation NACK */
6672testcase TC_dyn_pdch_ipa_act_nack() runs on test_CT {
6673 var RSL_Message rsl_unused;
6674
6675 /* change Timeslot 6 before f_init() starts RSL */
6676 f_init_vty();
6677 f_ts_set_chcomb(0, 0, 6, "TCH/F_PDCH");
6678 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
6679
6680 f_init(1, false);
6681 f_sleep(1.0);
6682
6683 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(6));
6684
6685 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
6686 /* The BSC will activate the dynamic PDCH by default, so confirm that */
6687 rsl_unused := f_exp_ipa_rx(0, tr_RSL_IPA_PDCH_ACT(chan_nr));
6688 f_ipa_tx(0, ts_RSL_IPA_PDCH_ACT_ACK(chan_nr, ts_RSL_IE_FrameNumber(2342)));
6689 f_sleep(1.0);
6690 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, PDCH_MODE);
6691
6692 /* De-activate it via VTY */
6693 f_dyn_ipa_pdch_deact(0, 0, chan_nr.tn);
6694 f_sleep(1.0);
6695 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
6696
6697 /* re-activate it via VTY, but fail that; check BSC still assumes TCH/F mode */
6698 f_dyn_ipa_pdch_act(0, 0, chan_nr.tn, RSL_ERR_EQUIPMENT_FAIL);
6699 f_sleep(1.0);
6700 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
6701
Neels Hofmeyr887e8f12018-06-27 01:01:55 +02006702 /* clean up config */
6703 f_ts_set_chcomb(0, 0, 6, "PDCH");
6704
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006705 f_shutdown_helper();
Harald Welte94e0c342018-04-07 11:33:23 +02006706}
6707
6708
6709/***********************************************************************
6710 * Osmocom style dynamic PDCH
6711 ***********************************************************************/
6712
6713private function f_dyn_osmo_pdch_act(integer bts_nr, integer trx_nr, integer ts_nr,
6714 template (omit) RSL_Cause nack := omit)
6715runs on test_CT {
6716 var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(ts_nr));
6717 var RSL_Message rsl_unused;
Pau Espin Pedrol64adf372021-06-28 16:25:47 +02006718 /* ask BSC via VTY to activate a given OSMO style chan as PDCH */
Harald Welte94e0c342018-04-07 11:33:23 +02006719 /* FIXME: no VTY command to activate Osmocom PDCH !! */
6720 /* expect the BSC to issue the related RSL command */
6721 rsl_unused := f_exp_ipa_rx(0, tr_RSL_CHAN_ACT(chan_nr, ?));
6722 if (istemplatekind(nack, "omit")) {
6723 /* respond with a related acknowledgement */
6724 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, 2342));
6725 } else {
6726 f_ipa_tx(0, ts_RSL_CHAN_ACT_NACK(chan_nr, valueof(nack)));
6727 }
6728}
6729
6730private function f_dyn_osmo_pdch_deact(integer bts_nr, integer trx_nr, integer ts_nr,
6731 template (omit) RSL_Cause nack := omit)
6732runs on test_CT {
6733 var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(ts_nr));
6734 var RSL_Message rsl_unused;
Pau Espin Pedrol64adf372021-06-28 16:25:47 +02006735 /* ask BSC via VTY to activate a given OSMO style chan as PDCH */
Harald Welte94e0c342018-04-07 11:33:23 +02006736 /* FIXME: no VTY command to activate Osmocom PDCH !! */
6737 /* expect the BSC to issue the related RSL command */
6738 rsl_unused := f_exp_ipa_rx(0, tr_RSL_RF_CHAN_REL(chan_nr));
6739 if (istemplatekind(nack, "omit")) {
6740 /* respond with a related acknowledgement */
6741 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(chan_nr));
6742 } else {
6743 //f_ipa_tx(0, ts_RSL_RF_CHAN_REL_NACK(chan_nr, valueof(nack)));
6744 }
6745}
6746
6747/* Test Osmocom dyn PDCH activation / deactivation triggered by VTY */
6748testcase TC_dyn_pdch_osmo_act_deact() runs on test_CT {
6749 var RSL_Message rsl_unused;
6750
6751 /* change Timeslot 6 before f_init() starts RSL */
6752 f_init_vty();
6753 f_ts_set_chcomb(0, 0, 6, "TCH/F_TCH/H_PDCH");
6754 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
6755
6756 f_init(1, false);
6757 f_sleep(1.0);
6758
6759 var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(6));
6760
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02006761 log("TCH/F_TCH/H_PDCH pchan starts out in disabled mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02006762 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, NONE_MODE);
6763 /* The BSC will activate the dynamic PDCH by default, so confirm that */
6764 rsl_unused := f_exp_ipa_rx(0, tr_RSL_CHAN_ACT_PDCH(chan_nr, ?));
6765
6766 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, 2342));
6767 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02006768 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 +02006769 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, PDCH_MODE);
6770
Neels Hofmeyr887e8f12018-06-27 01:01:55 +02006771 /* clean up config */
6772 f_ts_set_chcomb(0, 0, 6, "PDCH");
6773
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006774 f_shutdown_helper();
Harald Welte94e0c342018-04-07 11:33:23 +02006775}
6776
6777/* Test Osmocom dyn PDCH activation NACK behavior */
6778testcase TC_dyn_pdch_osmo_act_nack() runs on test_CT {
6779 var RSL_Message rsl_unused;
6780
6781 /* change Timeslot 6 before f_init() starts RSL */
6782 f_init_vty();
6783 f_ts_set_chcomb(0, 0, 6, "TCH/F_TCH/H_PDCH");
6784 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
6785
6786 f_init(1, false);
6787 f_sleep(1.0);
6788
6789 var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(6));
6790
6791 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, NONE_MODE);
6792 /* The BSC will activate the dynamic PDCH by default, so confirm that */
6793 rsl_unused := f_exp_ipa_rx(0, tr_RSL_CHAN_ACT_PDCH(chan_nr, ?));
6794
6795 /* NACK this activation and expect the "show timeslot" mode still to be NONE */
6796 f_ipa_tx(0, ts_RSL_CHAN_ACT_NACK(chan_nr, RSL_ERR_EQUIPMENT_FAIL));
6797 f_sleep(1.0);
6798 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, NONE_MODE);
6799
Neels Hofmeyr887e8f12018-06-27 01:01:55 +02006800 /* clean up config */
6801 f_ts_set_chcomb(0, 0, 6, "PDCH");
6802
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006803 f_shutdown_helper();
Harald Welte94e0c342018-04-07 11:33:23 +02006804}
6805
Pau Espin Pedrol5b381082021-06-28 17:14:03 +02006806/* Test Osmocom dyn TS SDCCH8 activation / deactivation */
6807testcase TC_dyn_ts_sdcch8_act_deact() runs on test_CT {
6808 var RSL_Message rsl_unused, rsl_msg;
6809 var DchanTuple dt;
6810 var BSSAP_N_CONNECT_ind rx_c_ind;
6811
6812 /* change Timeslot 6 before f_init() starts RSL */
6813 f_init_vty();
6814 f_ts_set_chcomb(0, 0, 6, "TCH/F_TCH/H_SDCCH8_PDCH");
6815 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
6816
6817 f_init(1, false);
6818 f_sleep(1.0);
6819
6820 var RslChannelNr pdch_chan_nr := valueof(t_RslChanNr_PDCH(6));
6821
6822 log("TCH/F_TCH/H_SDCCH8_PDCH pchan starts out in disabled mode:");
6823 f_ts_dyn_mode_assert(0, 0, pdch_chan_nr.tn, NONE_MODE);
6824 /* The BSC will activate the dynamic PDCH by default, so confirm that */
6825 rsl_unused := f_exp_ipa_rx(0, tr_RSL_CHAN_ACT_PDCH(pdch_chan_nr, ?));
6826
6827 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(pdch_chan_nr, 2342));
6828 f_sleep(1.0);
6829 log("TCH/F_TCH/H_SDCCH8_PDC requested to PDCH ACT on startup, which was ACKed, so now in PDCH:");
6830 f_ts_dyn_mode_assert(0, 0, pdch_chan_nr.tn, PDCH_MODE);
6831
6832 /* Fill TS0 SDCCH channels (NOTE: only 3 SDCCH/4 channels are available
6833 * on CCCH+SDCCH4+CBCH) */
6834 var integer i;
6835 for (i := 0; i < 3; i := i + 1) {
6836 dt := f_est_dchan('23'O, i, '00010203040506'O);
6837 }
6838
6839 /* Now the dyn ts is selected. First PDCH is released, then sdcch chan is activated */
6840 f_ipa_tx(0, ts_RSL_CHAN_RQD(int2oct(oct2int('23'O) + i, 1), 2342));
6841 rsl_unused := f_exp_ipa_rx(0, tr_RSL_RF_CHAN_REL(pdch_chan_nr));
6842 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(pdch_chan_nr));
6843
6844 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
6845 dt.rsl_chan_nr := rsl_msg.ies[0].body.chan_nr;
6846
6847 f_ts_dyn_mode_assert(0, 0, dt.rsl_chan_nr.tn, SDCCH8_MODE);
6848 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(dt.rsl_chan_nr, 2342));
6849 rsl_msg := f_exp_ipa_rx(0, tr_RSL_IMM_ASSIGN(0));
6850 f_ts_dyn_mode_assert(0, 0, dt.rsl_chan_nr.tn, SDCCH8_MODE);
6851
6852 f_ipa_tx(0, ts_RSL_EST_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0)), '1234'O));
6853 BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3('1234'O))) -> value rx_c_ind;
6854 dt.sccp_conn_id := rx_c_ind.connectionId;
6855 BSSAP.send(ts_BSSAP_CONNECT_res(dt.sccp_conn_id));
6856
6857 /* Instruct BSC to clear channel */
6858 var BssmapCause cause := 0;
6859 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
6860 f_exp_chan_rel_and_clear(dt, 0);
6861
6862 /* The BSC will switch the TS back to PDCH once the only lchan using it is released: */
6863 rsl_unused := f_exp_ipa_rx(0, tr_RSL_CHAN_ACT_PDCH(pdch_chan_nr, ?));
6864 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(pdch_chan_nr, 2342));
6865 f_sleep(1.0);
6866 f_ts_dyn_mode_assert(0, 0, pdch_chan_nr.tn, PDCH_MODE);
6867
6868 /* clean up config */
6869 f_ts_set_chcomb(0, 0, 6, "PDCH");
6870
6871 f_shutdown_helper();
6872}
6873
Pau Espin Pedrolcdf26142021-06-28 17:14:03 +02006874/* Test Osmocom dyn TS SDCCH8 activation / deactivation when SDCCH fails at BTS */
6875testcase TC_dyn_ts_sdcch8_act_nack() runs on test_CT {
6876 var RSL_Message rsl_unused, rsl_msg;
6877 var DchanTuple dt;
6878 var BSSAP_N_CONNECT_ind rx_c_ind;
6879 var GsmRrMessage rr;
6880
6881 /* change Timeslot 6 before f_init() starts RSL */
6882 f_init_vty();
6883 f_ts_set_chcomb(0, 0, 6, "TCH/F_TCH/H_SDCCH8_PDCH");
6884 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
6885
6886 f_init(1, false);
6887 f_sleep(1.0);
6888
6889 var RslChannelNr pdch_chan_nr := valueof(t_RslChanNr_PDCH(6));
6890
6891 log("TCH/F_TCH/H_SDCCH8_PDCH pchan starts out in disabled mode:");
6892 f_ts_dyn_mode_assert(0, 0, pdch_chan_nr.tn, NONE_MODE);
6893 /* The BSC will activate the dynamic PDCH by default, so confirm that */
6894 rsl_unused := f_exp_ipa_rx(0, tr_RSL_CHAN_ACT_PDCH(pdch_chan_nr, ?));
6895
6896 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(pdch_chan_nr, 2342));
6897 f_sleep(1.0);
6898 log("TCH/F_TCH/H_SDCCH8_PDC requested to PDCH ACT on startup, which was ACKed, so now in PDCH:");
6899 f_ts_dyn_mode_assert(0, 0, pdch_chan_nr.tn, PDCH_MODE);
6900
6901 /* Fill TS0 SDCCH channels (NOTE: only 3 SDCCH/4 channels are available
6902 * on CCCH+SDCCH4+CBCH) */
6903 var integer i;
6904 for (i := 0; i < 3; i := i + 1) {
6905 dt := f_est_dchan('23'O, i, '00010203040506'O);
6906 }
6907
6908 /* Now the dyn ts is selected. First PDCH is released, then sdcch chan is activated */
6909 f_ipa_tx(0, ts_RSL_CHAN_RQD(int2oct(oct2int('23'O) + i, 1), 2342));
6910 rsl_unused := f_exp_ipa_rx(0, tr_RSL_RF_CHAN_REL(pdch_chan_nr));
6911 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(pdch_chan_nr));
6912
6913 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
6914 dt.rsl_chan_nr := rsl_msg.ies[0].body.chan_nr;
6915
6916 f_ts_dyn_mode_assert(0, 0, dt.rsl_chan_nr.tn, SDCCH8_MODE);
6917 f_ipa_tx(0, ts_RSL_CHAN_ACT_NACK(dt.rsl_chan_nr, RSL_ERR_EQUIPMENT_FAIL));
6918 rsl_msg := f_exp_ipa_rx(0, tr_RSL_IMM_ASSIGN(0));
6919 rr := dec_GsmRrMessage(rsl_msg.ies[1].body.full_imm_ass_info.payload);
6920 if (rr.header.message_type != IMMEDIATE_ASSIGNMENT_REJECT) {
6921 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Expected reject");
6922 }
6923
6924 /* FIXME? Currently the TS stays in state BORKEN: */
6925
6926 /* The BSC will switch the TS back to PDCH once the only lchan using it is released: */
6927 /* rsl_unused := f_exp_ipa_rx(0, tr_RSL_CHAN_ACT_PDCH(pdch_chan_nr, ?));
6928 * f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(pdch_chan_nr, 2342));
6929 * f_sleep(1.0);
6930 * f_ts_dyn_mode_assert(0, 0, pdch_chan_nr.tn, PDCH_MODE)
6931 */
6932
6933 /* clean up config */
6934 f_ts_set_chcomb(0, 0, 6, "PDCH");
6935
6936 f_shutdown_helper();
6937}
6938
Stefan Sperling0796a822018-10-05 13:01:39 +02006939testcase TC_chopped_ipa_ping() runs on test_CT {
Stefan Sperling554123f2018-10-09 14:12:30 +02006940 const Integers bsc_ipa_ports := {mp_bsc_rsl_port, mp_bsc_oml_port, mp_bsc_ctrl_port};
Stefan Sperling0796a822018-10-05 13:01:39 +02006941 for (var integer i := 0; i < lengthof(bsc_ipa_ports); i := i + 1) {
6942 IPA_Testing.f_run_TC_chopped_ipa_ping(mp_bsc_ip, bsc_ipa_ports[i], CONNECT_TO_SERVER);
6943 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006944 f_shutdown_helper();
Stefan Sperling0796a822018-10-05 13:01:39 +02006945}
6946
Stefan Sperlingaa1e60f2018-10-15 16:34:07 +02006947testcase TC_chopped_ipa_payload() runs on test_CT {
6948 const Integers bsc_ipa_ports := {mp_bsc_rsl_port, mp_bsc_oml_port
6949 /* TODO: mp_bsc_ctrl_port does not work yet */};
6950 for (var integer i := 0; i < lengthof(bsc_ipa_ports); i := i + 1) {
6951 IPA_Testing.f_run_TC_chopped_ipa_payload(mp_bsc_ip, bsc_ipa_ports[i], CONNECT_TO_SERVER);
6952 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006953 f_shutdown_helper();
Stefan Sperlingaa1e60f2018-10-15 16:34:07 +02006954}
6955
Pau Espin Pedrol8f773632019-11-05 11:46:53 +01006956/* Verify the BSC sends the MS Power Parameters IE during CHAN ACT to make sure
6957 the BTS does autonomous MS power control loop */
6958testcase TC_assignment_verify_ms_power_params_ie() runs on test_CT {
6959 var MSC_ConnHdlr vc_conn;
6960 var TestHdlrParams pars := f_gen_test_hdlr_pars();
6961 //pars.encr := valueof(t_EncrParams('01'O, f_rnd_octstring(8)));
6962 pars.exp_ms_power_params := true;
6963
6964 f_init(1, true);
6965 f_sleep(1.0);
6966 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5), pars);
6967 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006968 f_shutdown_helper();
Pau Espin Pedrol8f773632019-11-05 11:46:53 +01006969}
Stefan Sperlingaa1e60f2018-10-15 16:34:07 +02006970
Vadim Yanitskiy4b233042021-06-30 00:58:43 +02006971/* Verify activation and deactivation of the BCCH carrier power reduction mode */
6972testcase TC_c0_power_red_mode() runs on test_CT {
6973 f_init(1);
6974
6975 for (var integer red := 6; red >= 0; red := red - 2) {
6976 /* Configure BCCH carrier power reduction mode via the VTY */
6977 f_vty_transceive(BSCVTY, "bts 0 c0-power-reduction " & int2str(red));
6978
6979 /* Expect Osmocom specific BS Power Control message on the RSL */
6980 var template RSL_Message tr_rsl_pdu := tr_RSL_BS_PWR_CTRL(
6981 chan_nr := t_RslChanNr_BCCH(0),
6982 bs_power := tr_RSL_IE_BS_Power(red / 2));
6983 tr_rsl_pdu.msg_disc := tr_RSL_MsgDisc(RSL_MDISC_CCHAN, false);
6984 var RSL_Message unused := f_exp_ipa_rx(0, tr_rsl_pdu);
6985
6986 /* Additionally verify the applied value over the CTRL interface */
6987 var CtrlValue cred := f_ctrl_get_bts(IPA_CTRL, 0, "c0-power-reduction");
6988 if (cred != int2str(red)) {
6989 setverdict(fail, "Unexpected BCCH carrier power reduction value ",
6990 cred, " (expected ", red, ")");
6991 }
6992 }
6993
6994 f_shutdown_helper();
6995}
6996
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006997/***********************************************************************
6998 * MSC Pooling
6999 ***********************************************************************/
7000
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007001template MobileIdentityLV ts_MI_TMSI_NRI_LV(integer nri_v, integer nri_bitlen := 10) :=
Harald Weltebf397612021-01-14 20:39:46 +01007002 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 +02007003
Pau Espin Pedrolc08d5522021-04-16 15:40:38 +02007004private function f_expect_lchan_rel(RSL_DCHAN_PT rsl, template PDU_ML3_NW_MS exp_rr_rel_tmpl := tr_RRM_RR_RELEASE)
7005runs on MSC_ConnHdlr {
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02007006 interleave {
Pau Espin Pedrolc08d5522021-04-16 15:40:38 +02007007 [] rsl.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch exp_rr_rel_tmpl)) {
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02007008 f_logp(BSCVTY, "Got RSL RR Release");
7009 }
7010 [] rsl.receive(tr_RSL_DEACT_SACCH(g_chan_nr)) {
7011 f_logp(BSCVTY, "Got RSL Deact SACCH");
7012 }
7013 [] rsl.receive(tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL)) {
7014 f_logp(BSCVTY, "Got RSL RF Chan Rel, sending Rel Ack");
7015 rsl.send(ts_RSL_RF_CHAN_REL_ACK(g_chan_nr));
7016 break;
7017 }
7018 }
7019}
7020
Neels Hofmeyr9f3e6ac2021-04-08 23:09:24 +02007021friend function f_perform_clear(RSL_DCHAN_PT rsl, template PDU_ML3_NW_MS exp_rr_rel_tmpl := tr_RRM_RR_RELEASE)
Pau Espin Pedrolc08d5522021-04-16 15:40:38 +02007022runs on MSC_ConnHdlr {
Neels Hofmeyr767548a2020-08-09 20:26:07 +00007023 f_logp(BSCVTY, "MSC instructs BSC to clear channel");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007024 BSSAP.send(ts_BSSMAP_ClearCommand(0));
7025 interleave {
Pau Espin Pedrolc08d5522021-04-16 15:40:38 +02007026 [] rsl.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch exp_rr_rel_tmpl)) {
Neels Hofmeyr767548a2020-08-09 20:26:07 +00007027 f_logp(BSCVTY, "Got RSL RR Release");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007028 }
7029 [] rsl.receive(tr_RSL_DEACT_SACCH(g_chan_nr)) {
Neels Hofmeyr767548a2020-08-09 20:26:07 +00007030 f_logp(BSCVTY, "Got RSL Deact SACCH");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007031 }
7032 [] BSSAP.receive(tr_BSSMAP_ClearComplete) {
Neels Hofmeyr767548a2020-08-09 20:26:07 +00007033 f_logp(BSCVTY, "Got BSSMAP Clear Complete");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007034 /* Also drop the SCCP connection */
7035 BSSAP.send(RAN_Conn_Prim:MSC_CONN_PRIM_DISC_REQ);
7036 }
7037 [] rsl.receive(tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL)) {
Neels Hofmeyr767548a2020-08-09 20:26:07 +00007038 f_logp(BSCVTY, "Got RSL RF Chan Rel, sending Rel Ack");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007039 rsl.send(ts_RSL_RF_CHAN_REL_ACK(g_chan_nr));
7040 }
7041 }
7042}
7043
Neels Hofmeyr66e15092020-10-12 18:44:41 +00007044private function f_perform_compl_l3(RSL_DCHAN_PT rsl, template PDU_ML3_MS_NW l3_info, boolean do_clear := true, boolean expect_bssmap_l3 := true)
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007045runs on MSC_ConnHdlr {
7046 timer T := 10.0;
7047 var octetstring l3_enc := enc_PDU_ML3_MS_NW(valueof(l3_info));
7048
Neels Hofmeyr767548a2020-08-09 20:26:07 +00007049 f_logp(BSCVTY, "establish channel, send Complete Layer 3 Info");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007050 f_create_bssmap_exp(l3_enc);
7051
7052 /* RSL_Emulation.f_chan_est() on rsl:
7053 * This is basically code dup with s/RSL/rsl from:
7054 * RSL_Emulation.f_chan_est(g_pars.ra, l3_enc, g_pars.link_id, g_pars.fn);
7055 */
7056 var RSL_Message rx_rsl;
7057 var GsmRrMessage rr;
7058
7059 /* request a channel to be established */
7060 rsl.send(ts_RSLDC_ChanRqd(g_pars.ra, g_pars.fn));
7061 /* expect immediate assignment.
7062 * Code dup with s/RSL/rsl from:
7063 * rx_rsl := f_rx_or_fail(tr_RSL_IMM_ASSIGN);
7064 */
7065 timer Tt := 10.0;
7066
7067 /* request a channel to be established */
7068 Tt.start;
7069 alt {
7070 [] rsl.receive(tr_RSL_IMM_ASSIGN) -> value rx_rsl {
7071 Tt.stop;
7072 }
7073 [] rsl.receive {
7074 setverdict(fail, "Unexpected RSL message on DCHAN");
7075 mtc.stop;
7076 }
7077 [] Tt.timeout {
7078 setverdict(fail, "Timeout waiting for RSL on DCHAN");
7079 mtc.stop;
7080 }
7081 }
7082 rr := dec_GsmRrMessage(rx_rsl.ies[1].body.full_imm_ass_info.payload);
7083 g_chan_nr := rr.payload.imm_ass.chan_desc.chan_nr;
7084 rsl.send(ts_RSL_EST_IND(g_chan_nr, valueof(g_pars.link_id), l3_enc));
7085
7086
Neels Hofmeyr66e15092020-10-12 18:44:41 +00007087 if (expect_bssmap_l3) {
7088 f_logp(BSCVTY, "expect BSSAP Complete Layer 3 Info at MSC");
7089 var template PDU_BSSAP exp_l3_compl;
7090 exp_l3_compl := tr_BSSMAP_ComplL3()
7091 if (g_pars.aoip == false) {
7092 exp_l3_compl.pdu.bssmap.completeLayer3Information.codecList := omit;
7093 } else {
7094 exp_l3_compl.pdu.bssmap.completeLayer3Information.codecList := ?;
7095 }
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007096
Neels Hofmeyr66e15092020-10-12 18:44:41 +00007097 var PDU_BSSAP bssap;
7098 T.start;
7099 alt {
7100 [] BSSAP.receive(exp_l3_compl) -> value bssap {
7101 f_logp(BSCVTY, "received expected Complete Layer 3 Info at MSC");
7102 log("rx exp_l3_compl = ", bssap);
7103 }
7104 [] BSSAP.receive(tr_BSSMAP_ComplL3) {
7105 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Received non-matching COMPLETE LAYER 3 INFORMATION");
7106 }
7107 [] T.timeout {
7108 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for COMPLETE LAYER 3 INFORMATION");
7109 }
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007110 }
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007111
Neels Hofmeyr66e15092020-10-12 18:44:41 +00007112 /* start ciphering, if requested */
7113 if (ispresent(g_pars.encr)) {
7114 f_logp(BSCVTY, "start ciphering");
Neels Hofmeyr6c388f22021-06-11 02:36:56 +02007115 f_cipher_mode(g_pars.encr);
Neels Hofmeyr66e15092020-10-12 18:44:41 +00007116 }
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007117 }
7118
7119 if (do_clear) {
7120 f_perform_clear(rsl);
7121 }
7122 setverdict(pass);
7123 f_sleep(1.0);
7124}
7125
7126private function f_tc_mscpool_compl_l3(charstring id) runs on MSC_ConnHdlr {
7127 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
7128 if (g_pars.mscpool.rsl_idx == 0) {
7129 f_perform_compl_l3(RSL, g_pars.mscpool.l3_info);
7130 } else if (g_pars.mscpool.rsl_idx == 1) {
7131 f_perform_compl_l3(RSL1, g_pars.mscpool.l3_info);
7132 } else if (g_pars.mscpool.rsl_idx == 2) {
7133 f_perform_compl_l3(RSL2, g_pars.mscpool.l3_info);
7134 }
7135}
7136
7137/* Various Complete Layer 3 by IMSI all end up with the first MSC, because the other MSCs are not connected. */
7138private function f_tc_mscpool_L3Compl_on_1_msc(charstring id) runs on MSC_ConnHdlr {
7139 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
7140 f_perform_compl_l3(RSL, ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_IMSI_LV('001010000000001'H)), '00F110'O) );
7141 f_perform_compl_l3(RSL, ts_CM_SERV_REQ(CM_TYPE_MO_SMS, valueof(ts_MI_IMSI_LV('001010000000002'H))) );
7142 f_perform_compl_l3(RSL, ts_PAG_RESP(valueof(ts_MI_IMSI_LV('001010000000003'H))) );
7143 f_perform_compl_l3(RSL, ts_ML3_MO_MM_IMSI_DET_Ind(valueof(ts_MI_IMSI_LV('001010000000004'H))) );
7144}
7145testcase TC_mscpool_L3Compl_on_1_msc() runs on test_CT {
7146
7147 f_init(1, true);
7148 f_sleep(1.0);
7149 var MSC_ConnHdlr vc_conn;
7150 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007151
7152 f_ctrs_msc_init();
7153
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007154 vc_conn := f_start_handler(refers(f_tc_mscpool_L3Compl_on_1_msc), pars);
7155 vc_conn.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007156
7157 f_ctrs_msc_expect(0, "mscpool:subscr:new", 4);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007158 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007159}
7160
7161/* Three Layer 3 Complete by IMSI are round-robin'ed across two connected MSCs */
7162/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
7163 * just as well using only RSL. */
7164testcase TC_mscpool_L3Complete_by_imsi_round_robin() runs on test_CT {
7165
7166 f_init(nr_bts := 3, handler_mode := true, nr_msc := 2);
7167 f_sleep(1.0);
7168
7169 /* Control which MSC gets chosen next by the round-robin, otherwise
7170 * would be randomly affected by which other tests ran before this. */
7171 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
7172
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007173 f_ctrs_msc_init();
7174
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007175 var MSC_ConnHdlr vc_conn1;
7176 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
7177 pars1.mscpool.rsl_idx := 0;
7178 pars1.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_IMSI_LV('001010000000001'H)), '00F110'O));
7179 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
7180 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007181 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007182
7183 var MSC_ConnHdlr vc_conn2;
7184 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 1);
7185 pars2.mscpool.rsl_idx := 1;
7186 pars2.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, valueof(ts_MI_IMSI_LV('001010000000002'H))));
7187 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
7188 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007189 f_ctrs_msc_expect(1, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007190
7191 /* Test round-robin wrap to the first MSC */
7192 var MSC_ConnHdlr vc_conn3;
7193 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 0);
7194 pars3.mscpool.rsl_idx := 2;
7195 pars3.mscpool.l3_info := valueof(ts_PAG_RESP(valueof(ts_MI_IMSI_LV('001010000000003'H))));
7196 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
7197 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007198 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007199 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007200}
7201
7202/* Three LU by TMSI are round-robin'ed across two connected MSCs, because they contain the NULL-NRI 0
7203 * (configured in osmo-bsc.cfg). */
7204/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
7205 * just as well using only RSL. */
7206testcase TC_mscpool_LU_by_tmsi_null_nri_0_round_robin() runs on test_CT {
7207
7208 f_init(nr_bts := 3, handler_mode := true, nr_msc := 2);
7209 f_sleep(1.0);
7210
7211 /* Control which MSC gets chosen next by the round-robin, otherwise
7212 * would be randomly affected by which other tests ran before this. */
7213 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
7214
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007215 f_ctrs_msc_init();
7216
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007217 var MSC_ConnHdlr vc_conn1;
7218 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
7219 pars1.mscpool.rsl_idx := 0;
7220 pars1.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(0)), '00F110'O));
7221 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
7222 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007223 f_ctrs_msc_expect(0, "mscpool:subscr:reattach");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007224
7225 var MSC_ConnHdlr vc_conn2;
7226 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 1);
7227 pars2.mscpool.rsl_idx := 1;
7228 pars2.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(0)), '00F110'O));
7229 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
7230 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007231 f_ctrs_msc_expect(1, "mscpool:subscr:reattach");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007232
7233 /* Test round-robin wrap to the first MSC */
7234 var MSC_ConnHdlr vc_conn3;
7235 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 0);
7236 pars3.mscpool.rsl_idx := 2;
7237 pars3.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(0)), '00F110'O));
7238 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
7239 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007240 f_ctrs_msc_expect(0, "mscpool:subscr:reattach");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007241 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007242}
7243
7244/* Three LU by TMSI are round-robin'ed across two connected MSCs, because they contain the NULL-NRI 1
7245 * (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
7246 * NULL-NRI setting is stronger than that. */
7247/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
7248 * just as well using only RSL. */
7249testcase TC_mscpool_LU_by_tmsi_null_nri_1_round_robin() runs on test_CT {
7250
7251 f_init(nr_bts := 3, handler_mode := true, nr_msc := 2);
7252 f_sleep(1.0);
7253
7254 /* Control which MSC gets chosen next by the round-robin, otherwise
7255 * would be randomly affected by which other tests ran before this. */
7256 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
7257
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007258 f_ctrs_msc_init();
7259
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007260 var MSC_ConnHdlr vc_conn1;
7261 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
7262 pars1.mscpool.rsl_idx := 0;
7263 pars1.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(1)), '00F110'O));
7264 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
7265 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007266 f_ctrs_msc_expect(0, "mscpool:subscr:reattach");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007267
7268 var MSC_ConnHdlr vc_conn2;
7269 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 1);
7270 pars2.mscpool.rsl_idx := 1;
7271 pars2.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(1)), '00F110'O));
7272 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
7273 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007274 f_ctrs_msc_expect(1, "mscpool:subscr:reattach");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007275
7276 /* Test round-robin wrap to the first MSC */
7277 var MSC_ConnHdlr vc_conn3;
7278 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 0);
7279 pars3.mscpool.rsl_idx := 2;
7280 pars3.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(1)), '00F110'O));
7281 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
7282 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007283 f_ctrs_msc_expect(0, "mscpool:subscr:reattach");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007284 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007285}
7286
7287/* Three Layer 3 Complete by TMSI are round-robin'ed across two connected MSCs, because they contain an NRI not
7288 * assigned to any MSC (configured in osmo-bsc.cfg). */
7289/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
7290 * just as well using only RSL. */
7291testcase TC_mscpool_L3Complete_by_tmsi_unassigned_nri_round_robin() runs on test_CT {
7292
7293 f_init(nr_bts := 3, handler_mode := true, nr_msc := 2);
7294 f_sleep(1.0);
7295
7296 /* Control which MSC gets chosen next by the round-robin, otherwise
7297 * would be randomly affected by which other tests ran before this. */
7298 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
7299
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007300 f_ctrs_msc_init();
7301
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007302 var MSC_ConnHdlr vc_conn1;
7303 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
7304 pars1.mscpool.rsl_idx := 0;
7305 /* An NRI that is not assigned to any MSC */
7306 pars1.mscpool.l3_info := valueof(ts_ML3_MO_MM_IMSI_DET_Ind(valueof(ts_MI_TMSI_NRI_LV(1023))));
7307 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
7308 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007309 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007310
7311 var MSC_ConnHdlr vc_conn2;
7312 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 1);
7313 pars2.mscpool.rsl_idx := 1;
7314 /* An NRI that is not assigned to any MSC */
7315 pars2.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(768)), '00F110'O));
7316 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
7317 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007318 f_ctrs_msc_expect(1, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007319
7320 /* Test round-robin wrap to the first MSC */
7321 var MSC_ConnHdlr vc_conn3;
7322 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 0);
7323 pars3.mscpool.rsl_idx := 2;
7324 /* An NRI that is not assigned to any MSC */
7325 pars3.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_SS_ACT, valueof(ts_MI_TMSI_NRI_LV(819))));
7326 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
7327 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007328 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007329 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007330}
7331
7332/* Three Layer 3 Complete by TMSI are round-robin'ed across two connected MSCs, because they contain an NRI
7333 * assigned to an MSC that is currently not connected (configured in osmo-bsc.cfg). */
7334/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
7335 * just as well using only RSL. */
7336testcase TC_mscpool_L3Complete_by_tmsi_valid_nri_msc_not_connected_round_robin() runs on test_CT {
7337
7338 f_init(nr_bts := 3, handler_mode := true, nr_msc := 2);
7339 f_sleep(1.0);
7340
7341 /* Control which MSC gets chosen next by the round-robin, otherwise
7342 * would be randomly affected by which other tests ran before this. */
7343 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
7344
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007345 f_ctrs_msc_init();
7346
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007347 var MSC_ConnHdlr vc_conn1;
7348 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
7349 pars1.mscpool.rsl_idx := 0;
7350 /* An NRI that is assigned to an unconnected MSC */
7351 pars1.mscpool.l3_info := valueof(ts_PAG_RESP(valueof(ts_MI_TMSI_NRI_LV(512))));
7352 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
7353 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007354 f_ctrs_msc_add(2, "mscpool:subscr:attach_lost");
7355 f_ctrs_msc_add(0, "mscpool:subscr:new");
7356 f_ctrs_msc_verify();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007357
7358 var MSC_ConnHdlr vc_conn2;
7359 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 1);
7360 pars2.mscpool.rsl_idx := 1;
7361 /* An NRI that is assigned to an unconnected MSC */
7362 pars2.mscpool.l3_info := valueof(ts_ML3_MO_MM_IMSI_DET_Ind(valueof(ts_MI_TMSI_NRI_LV(767))));
7363 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
7364 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007365 f_ctrs_msc_add(2, "mscpool:subscr:attach_lost");
7366 f_ctrs_msc_add(1, "mscpool:subscr:new");
7367 f_ctrs_msc_verify();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007368
7369 /* Test round-robin wrap to the first MSC */
7370 var MSC_ConnHdlr vc_conn3;
7371 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 0);
7372 pars3.mscpool.rsl_idx := 2;
7373 /* An NRI that is assigned to an unconnected MSC */
7374 pars3.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(750)), '00F110'O));
7375 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
7376 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007377 f_ctrs_msc_add(2, "mscpool:subscr:attach_lost");
7378 f_ctrs_msc_add(0, "mscpool:subscr:new");
7379 f_ctrs_msc_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007380 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007381}
7382
7383/* Three Layer 3 Complete by TMSI with valid NRI for the second MSC are all directed to the second MSC (configured in
7384 * osmo-bsc.cfg). */
7385/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
7386 * just as well using only RSL. */
7387testcase TC_mscpool_L3Complete_by_tmsi_valid_nri_1() runs on test_CT {
7388
7389 f_init(nr_bts := 3, handler_mode := true, nr_msc := 2);
7390 f_sleep(1.0);
7391
7392 /* All TMSIs in this test point at the second MSC, set the round robin to point at the first MSC to make sure
7393 * this is not using round-robin. */
7394 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
7395
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007396 f_ctrs_msc_init();
7397
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007398 var MSC_ConnHdlr vc_conn1;
7399 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 1);
7400 pars1.mscpool.rsl_idx := 0;
7401 /* An NRI of the second MSC's range (256-511) */
7402 pars1.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_SMS, valueof(ts_MI_TMSI_NRI_LV(256))));
7403 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
7404 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007405 f_ctrs_msc_expect(1, "mscpool:subscr:known");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007406
7407 var MSC_ConnHdlr vc_conn2;
7408 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 1);
7409 pars2.mscpool.rsl_idx := 1;
7410 /* An NRI of the second MSC's range (256-511) */
7411 pars2.mscpool.l3_info := valueof(ts_PAG_RESP(valueof(ts_MI_TMSI_NRI_LV(260))));
7412 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
7413 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007414 f_ctrs_msc_expect(1, "mscpool:subscr:known");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007415
7416 var MSC_ConnHdlr vc_conn3;
7417 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 1);
7418 pars3.mscpool.rsl_idx := 2;
7419 /* An NRI of the second MSC's range (256-511) */
7420 pars3.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(511)), '00F110'O));
7421 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
7422 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007423 f_ctrs_msc_expect(1, "mscpool:subscr:known");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007424 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007425}
7426
7427/* Layer 3 Complete by TMSI with valid NRI for the third MSC are directed to the third MSC (configured in osmo-bsc.cfg),
7428 * while a round-robin remains unaffected by that. */
7429/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
7430 * just as well using only RSL. */
7431testcase TC_mscpool_L3Complete_by_tmsi_valid_nri_2() runs on test_CT {
7432
7433 f_init(nr_bts := 3, handler_mode := true, nr_msc := 3);
7434 f_sleep(1.0);
7435
7436 /* All TMSIs in this test point at the third MSC, set the round robin to point at the second MSC to make sure
7437 * this is not using round-robin. */
7438 f_vty_transceive(BSCVTY, "mscpool roundrobin next 1");
7439
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007440 f_ctrs_msc_init();
7441
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007442 var MSC_ConnHdlr vc_conn1;
7443 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 2);
7444 pars1.mscpool.rsl_idx := 0;
7445 /* An NRI of the third MSC's range (512-767) */
7446 pars1.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_SMS, valueof(ts_MI_TMSI_NRI_LV(512))));
7447 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
7448 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007449 f_ctrs_msc_expect(2, "mscpool:subscr:known");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007450
7451 var MSC_ConnHdlr vc_conn2;
7452 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 2);
7453 pars2.mscpool.rsl_idx := 1;
7454 /* An NRI of the third MSC's range (512-767) */
7455 pars2.mscpool.l3_info := valueof(ts_PAG_RESP(valueof(ts_MI_TMSI_NRI_LV(678))));
7456 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
7457 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007458 f_ctrs_msc_expect(2, "mscpool:subscr:known");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007459
7460 /* The above forwardings to third MSC have not affected the round robin, which still points at the second MSC */
7461 var MSC_ConnHdlr vc_conn3;
7462 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 1);
7463 pars3.mscpool.rsl_idx := 2;
7464 pars3.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_IMSI_LV('001010000000013'H)), '00F110'O));
7465 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
7466 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007467 f_ctrs_msc_expect(1, "mscpool:subscr:new");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007468 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007469}
7470
7471/* LU with a TMSI but indicating a different PLMN in its previous LAI: ignore the NRI. */
7472/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
7473 * just as well using only RSL. */
7474testcase TC_mscpool_LU_by_tmsi_from_other_PLMN() runs on test_CT {
7475
7476 f_init(nr_bts := 3, handler_mode := true, nr_msc := 3);
7477 f_sleep(1.0);
7478
7479 /* The TMSIs in this test points at the second MSC, but since it is from a different PLMN, round-robin is used
7480 * instead, and hits msc 0. */
7481 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
7482
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007483 f_ctrs_msc_init();
7484
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007485 /* An NRI of the second MSC's range (256-511), but a PLMN that doesn't match with osmo-bsc.cfg */
7486 var MSC_ConnHdlr vc_conn1;
7487 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
7488 pars1.mscpool.rsl_idx := 0;
7489 pars1.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(260)), '99F999'O));
7490 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
7491 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007492 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007493
7494 /* An NRI of the third MSC's range (512-767) and a matching PLMN gets directed by NRI. */
7495 var MSC_ConnHdlr vc_conn2;
7496 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 2);
7497 pars2.mscpool.rsl_idx := 1;
7498 pars2.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(555)), '00F110'O));
7499 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
7500 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007501 f_ctrs_msc_expect(2, "mscpool:subscr:known");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007502 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007503}
7504
7505/* Make sure that whichever MSC paged a subscriber will also get the Paging Response. Page by IMSI, which would be
7506 * round-robined to another MSC, to make sure the Paging->Response relation is stronger than the NRI->MSC mapping. */
7507private function f_tc_mscpool_paging_imsi(charstring id) runs on MSC_ConnHdlr {
7508 var template BSSMAP_FIELD_CellIdentificationList cid_list := { cIl_CI := { ts_BSSMAP_CI_CI(0) } };
7509 //cid_list := { cIl_allInBSS := ''O };
7510 var RSL_ChanNeeded rsl_chneed := RSL_CHANNEED_SDCCH;
7511 var template BSSMAP_IE_ChannelNeeded bssmap_chneed := ts_BSSMAP_IE_ChanNeeded(int2bit(enum2int(valueof(rsl_chneed)),2));
7512 var BSSAP_N_UNITDATA_req paging;
7513 var hexstring imsi := '001010000000123'H;
7514
7515 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
7516
Neels Hofmeyr90f80962020-06-12 16:16:55 +02007517 paging := valueof(ts_BSSAP_UNITDATA_req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007518 valueof(ts_BSSMAP_Paging(imsi, cid_list, omit, bssmap_chneed))));
7519 BSSAP.send(paging);
7520
7521 /* Register any RSL conn so that the Paging Command gets received here. With the current RSL_Emulation's main()
7522 * handling of '[bts_role] IPA_PT.receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD()))' it doesn't matter at all which
7523 * channel number is picked here. */
7524 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(0, RSL_CHAN_NR_INVALID));
7525 f_rslem_register(0, new_chan_nr);
7526 RSL.receive(tr_RSL_PAGING_CMD(tr_MI_IMSI(imsi)));
7527 f_rslem_unregister(0, new_chan_nr);
7528
7529 /* Despite the round robin pointing at the second MSC ('roundrobin next 1'), the earlier Paging for the same IMSI
7530 * causes this Paging Response to go to the first MSC (bssap_idx := 0). */
7531 f_perform_compl_l3(RSL, ts_PAG_RESP(valueof(ts_MI_IMSI_LV(imsi))) );
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007532 f_sleep(1.0);
7533}
7534testcase TC_mscpool_paging_and_response_imsi() runs on test_CT {
7535 f_init(nr_bts := 1, handler_mode := true, nr_msc := 3);
7536 f_sleep(1.0);
7537
7538 /* Testing a Paging on the first MSC to get a Paging Response back to the first MSC. Set round robin to the
7539 * second MSC to make sure we're getting the Paging logic, not a coincidental round robin match. */
7540 f_vty_transceive(BSCVTY, "mscpool roundrobin next 1");
7541
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007542 f_ctrs_msc_init();
7543
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007544 var MSC_ConnHdlr vc_conn1;
7545 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
7546 pars1.mscpool.rsl_idx := 0;
Neels Hofmeyr90f80962020-06-12 16:16:55 +02007547 pars1.sccp_addr_bsc := g_bssap[pars1.mscpool.bssap_idx].sccp_addr_peer;
7548 pars1.sccp_addr_msc := g_bssap[pars1.mscpool.bssap_idx].sccp_addr_own;
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007549 vc_conn1 := f_start_handler(refers(f_tc_mscpool_paging_imsi), pars1);
7550 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007551 f_ctrs_msc_expect(0, "mscpool:subscr:paged");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007552 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007553}
7554
7555/* Make sure that whichever MSC paged a subscriber will also get the Paging Response. Page by TMSI with an NRI value
7556 * that matches a different MSC, to make sure the Paging->Response relation is stronger than the NRI->MSC mapping. */
7557private function f_tc_mscpool_paging_tmsi(charstring id) runs on MSC_ConnHdlr {
7558 var template BSSMAP_FIELD_CellIdentificationList cid_list := { cIl_CI := { ts_BSSMAP_CI_CI(0) } };
7559 //cid_list := { cIl_allInBSS := ''O };
7560 var RSL_ChanNeeded rsl_chneed := RSL_CHANNEED_SDCCH;
7561 var template BSSMAP_IE_ChannelNeeded bssmap_chneed := ts_BSSMAP_IE_ChanNeeded(int2bit(enum2int(valueof(rsl_chneed)),2));
7562 var integer nri_v := 300; /* <-- second MSC's NRI */
Harald Weltebf397612021-01-14 20:39:46 +01007563 var octetstring tmsi := f_gen_tmsi(suffix := 0, nri_v := nri_v);
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007564 var BSSAP_N_UNITDATA_req paging;
7565
7566 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
7567
Neels Hofmeyr90f80962020-06-12 16:16:55 +02007568 paging := valueof(ts_BSSAP_UNITDATA_req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007569 valueof(ts_BSSMAP_Paging('001010000000011'H, cid_list, tmsi, bssmap_chneed))));
7570 BSSAP.send(paging);
7571
7572 /* Register any RSL conn so that the Paging Command gets received here. With the current RSL_Emulation's main()
7573 * handling of '[bts_role] IPA_PT.receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD()))' it doesn't matter at all which
7574 * channel number is picked here. */
7575 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(0, RSL_CHAN_NR_INVALID));
7576 f_rslem_register(0, new_chan_nr);
7577 RSL.receive(tr_RSL_PAGING_CMD(t_MI_TMSI(tmsi)));
7578 f_rslem_unregister(0, new_chan_nr);
7579
7580 /* Despite the NRI matching the second MSC (NRI from 'msc 1' in osmo-bsc.cfg) and round robin pointing at the
7581 * third MSC ('roundrobin next 2'), the earlier Paging for the same TMSI causes this Paging Response to go to
7582 * the first MSC (bssap_idx := 0). */
7583 f_perform_compl_l3(RSL, ts_PAG_RESP(valueof(ts_MI_TMSI_NRI_LV(nri_v))) );
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007584 f_sleep(1.0);
7585}
7586testcase TC_mscpool_paging_and_response_tmsi() runs on test_CT {
7587 f_init(nr_bts := 1, handler_mode := true, nr_msc := 3);
7588 f_sleep(1.0);
7589
7590 /* Testing a Paging on the first MSC to get a Paging Response back to the first MSC. Set round robin to the
7591 * third MSC to make sure we're getting the Paging logic, not a coincidental round robin match. */
7592 f_vty_transceive(BSCVTY, "mscpool roundrobin next 2");
7593
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007594 f_ctrs_msc_init();
7595
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007596 var MSC_ConnHdlr vc_conn1;
7597 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
7598 pars1.mscpool.rsl_idx := 0;
Neels Hofmeyr90f80962020-06-12 16:16:55 +02007599 pars1.sccp_addr_bsc := g_bssap[pars1.mscpool.bssap_idx].sccp_addr_peer;
7600 pars1.sccp_addr_msc := g_bssap[pars1.mscpool.bssap_idx].sccp_addr_own;
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007601 vc_conn1 := f_start_handler(refers(f_tc_mscpool_paging_tmsi), pars1);
7602 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007603 f_ctrs_msc_expect(0, "mscpool:subscr:paged");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007604 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007605}
7606
7607/* For round-robin, skip an MSC that has 'no allow-attach' set. */
7608/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
7609 * just as well using only RSL. */
7610testcase TC_mscpool_no_allow_attach_round_robin() runs on test_CT {
7611
7612 f_init(nr_bts := 3, handler_mode := true, nr_msc := 3);
7613 f_sleep(1.0);
Neels Hofmeyra460f1f2020-08-09 20:17:03 +00007614 /* Mark the second MSC as offloading, round-robin should skip this MSC now. */
7615 f_vty_msc_allow_attach(BSCVTY, {true, false, true});
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007616
7617 /* Control which MSC gets chosen next by the round-robin, otherwise
7618 * would be randomly affected by which other tests ran before this. */
7619 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
7620
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007621 f_ctrs_msc_init();
7622
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007623 var MSC_ConnHdlr vc_conn1;
7624 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
7625 pars1.mscpool.rsl_idx := 0;
7626 pars1.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_IMSI_LV('001010000000001'H)), '00F110'O));
7627 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
7628 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007629 f_ctrs_msc_expect(0, "mscpool:subscr:new");
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 := 2);
7633 pars2.mscpool.rsl_idx := 1;
7634 pars2.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, valueof(ts_MI_IMSI_LV('001010000000002'H))));
7635 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
7636 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007637 f_ctrs_msc_expect(2, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007638
7639 var MSC_ConnHdlr vc_conn3;
7640 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 0);
7641 pars3.mscpool.rsl_idx := 2;
7642 pars3.mscpool.l3_info := valueof(ts_PAG_RESP(valueof(ts_MI_IMSI_LV('001010000000003'H))));
7643 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
7644 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007645 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007646 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007647}
7648
7649/* An MSC that has 'no allow-attach' set should still serve subscribers that are already attached according to their
7650 * TMSI NRI. */
7651testcase TC_mscpool_no_allow_attach_valid_nri() runs on test_CT {
7652
7653 f_init(nr_bts := 3, handler_mode := true, nr_msc := 3);
7654 f_sleep(1.0);
7655
Neels Hofmeyra460f1f2020-08-09 20:17:03 +00007656 /* Mark the second MSC as offloading, round-robin should skip this MSC now. */
7657 f_vty_msc_allow_attach(BSCVTY, {true, false, true});
7658
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007659 /* Control which MSC gets chosen next by the round-robin, otherwise
7660 * would be randomly affected by which other tests ran before this. */
7661 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
7662
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007663 f_ctrs_msc_init();
7664
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007665 /* Round robin points at msc 0, but the valid NRI directs to msc 1, even though msc 1 has 'no allow-attach'. */
7666 var MSC_ConnHdlr vc_conn1;
7667 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 1);
7668 pars1.mscpool.rsl_idx := 0;
7669 /* An NRI of the second MSC's range (256-511) */
7670 pars1.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, valueof(ts_MI_TMSI_NRI_LV(260))));
7671 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
7672 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007673 f_ctrs_msc_expect(1, "mscpool:subscr:known");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007674
7675 var MSC_ConnHdlr vc_conn2;
7676 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 0);
7677 pars2.mscpool.rsl_idx := 1;
7678 pars2.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, valueof(ts_MI_IMSI_LV('001010000000002'H))));
7679 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
7680 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007681 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007682
7683 var MSC_ConnHdlr vc_conn3;
7684 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 2);
7685 pars3.mscpool.rsl_idx := 2;
7686 pars3.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, valueof(ts_MI_IMSI_LV('001010000000003'H))));
7687 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
7688 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007689 f_ctrs_msc_expect(2, "mscpool:subscr:new");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007690 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007691}
7692
Philipp Maier783681c2020-07-16 16:47:06 +02007693/* Allow/Deny emergency calls globally via VTY */
7694private function f_vty_allow_emerg_msc(boolean allow) runs on test_CT {
7695 f_vty_enter_cfg_msc(BSCVTY, 0);
7696 if (allow) {
7697 f_vty_transceive(BSCVTY, "allow-emergency allow");
7698 } else {
7699 f_vty_transceive(BSCVTY, "allow-emergency deny");
7700 }
7701 f_vty_transceive(BSCVTY, "exit");
7702 f_vty_transceive(BSCVTY, "exit");
7703}
7704
7705/* Allow/Deny emergency calls per BTS via VTY */
7706private function f_vty_allow_emerg_bts(boolean allow, integer bts_nr) runs on test_CT {
7707 f_vty_enter_cfg_bts(BSCVTY, bts_nr);
7708 if (allow) {
7709 f_vty_transceive(BSCVTY, "rach emergency call allowed 1");
7710 } else {
7711 f_vty_transceive(BSCVTY, "rach emergency call allowed 0");
7712 }
7713 f_vty_transceive(BSCVTY, "exit");
7714 f_vty_transceive(BSCVTY, "exit");
Neels Hofmeyrb6ed80c2020-10-12 22:52:39 +00007715 f_vty_transceive(BSCVTY, "exit");
Philipp Maier783681c2020-07-16 16:47:06 +02007716}
7717
Pau Espin Pedrol9ae36d52021-06-15 17:29:43 +02007718/* Allow/Forbid Fast Return after SRVCC on a given BTS via VTY */
7719private function f_vty_allow_srvcc_fast_return(boolean allow, integer bts_nr) runs on test_CT {
7720 f_vty_enter_cfg_bts(BSCVTY, bts_nr);
7721 if (allow) {
7722 f_vty_transceive(BSCVTY, "srvcc fast-return allow");
7723 } else {
7724 f_vty_transceive(BSCVTY, "srvcc fast-return forbid");
7725 }
7726 f_vty_transceive(BSCVTY, "exit");
7727 f_vty_transceive(BSCVTY, "exit");
7728 f_vty_transceive(BSCVTY, "exit");
7729}
7730
Philipp Maier783681c2020-07-16 16:47:06 +02007731/* Begin assignmet procedure and send an EMERGENCY SETUP (RR) */
7732private function f_assignment_emerg_setup() runs on MSC_ConnHdlr {
7733 var PDU_ML3_MS_NW emerg_setup;
7734 var octetstring emerg_setup_enc;
7735 var RSL_Message emerg_setup_data_ind;
7736
7737 f_establish_fully(omit, omit);
7738
7739 emerg_setup := valueof(ts_ML3_MO_CC_EMERG_SETUP(1, valueof(ts_Bcap_voice)));
7740 emerg_setup_enc := enc_PDU_ML3_MS_NW(emerg_setup);
7741 emerg_setup_data_ind := valueof(ts_RSL_DATA_IND(g_chan_nr, valueof(ts_RslLinkID_DCCH(0)), emerg_setup_enc));
7742
7743 RSL.send(emerg_setup_data_ind);
7744}
7745
7746/* Test if the EMERGENCY SETUP gets passed on to the MSC via A when EMERGENCY
7747 * CALLS are permitted by the BSC config. */
7748private function f_TC_assignment_emerg_setup_allow(charstring id) runs on MSC_ConnHdlr {
7749 var PDU_BSSAP emerg_setup_data_ind_bssap;
7750 var PDU_ML3_MS_NW emerg_setup;
7751 timer T := 3.0;
7752
7753 f_assignment_emerg_setup()
7754
7755 T.start;
7756 alt {
7757 [] BSSAP.receive(tr_BSSAP_DTAP) -> value emerg_setup_data_ind_bssap {
7758 emerg_setup := dec_PDU_ML3_MS_NW(emerg_setup_data_ind_bssap.pdu.dtap);
7759 if (not isbound(emerg_setup.msgs.cc.emergencySetup)) {
7760 setverdict(fail, "no emergency setup");
7761 }
7762 }
7763 [] BSSAP.receive {
7764 setverdict(fail, "unexpected BSSAP message!");
7765 }
7766 [] T.timeout {
7767 setverdict(fail, "timout waiting for EMERGENCY SETUP!");
7768 }
7769 }
7770
7771 setverdict(pass);
7772}
7773
7774/* Test if the EMERGENCY SETUP gets blocked by the BSC if EMERGENCY CALLS are
7775 * forbidden by the BSC config. */
7776private function f_TC_assignment_emerg_setup_deny(charstring id) runs on MSC_ConnHdlr {
7777 var PDU_BSSAP emerg_setup_data_ind_bssap;
7778 timer T := 3.0;
7779
7780 f_assignment_emerg_setup()
7781
7782 T.start;
7783 alt {
7784 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_RELEASE)) {
7785 setverdict(pass);
7786 }
7787 [] RSL.receive {
7788 setverdict(fail, "unexpected RSL message!");
7789 }
7790 [] T.timeout {
7791 setverdict(fail, "timout waiting for RR CHANNEL RELEASE!");
7792 }
7793 }
7794}
7795
7796/* EMERGENCY CALL situation #1, allowed globally and by BTS */
7797testcase TC_assignment_emerg_setup_allow() runs on test_CT {
7798 var TestHdlrParams pars := f_gen_test_hdlr_pars();
7799 var MSC_ConnHdlr vc_conn;
7800
7801 f_init(1, true);
7802 f_sleep(1.0);
7803
7804 f_vty_allow_emerg_msc(true);
7805 f_vty_allow_emerg_bts(true, 0);
7806 vc_conn := f_start_handler(refers(f_TC_assignment_emerg_setup_allow), pars);
7807 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007808 f_shutdown_helper();
Philipp Maier783681c2020-07-16 16:47:06 +02007809}
7810
7811/* EMERGENCY CALL situation #2, forbidden globally but allowed by BTS */
7812testcase TC_assignment_emerg_setup_deny_msc() runs on test_CT {
7813 var TestHdlrParams pars := f_gen_test_hdlr_pars();
7814 var MSC_ConnHdlr vc_conn;
7815
7816 f_init(1, true);
7817 f_sleep(1.0);
7818
7819 f_vty_allow_emerg_msc(false);
7820 f_vty_allow_emerg_bts(true, 0);
7821 vc_conn := f_start_handler(refers(f_TC_assignment_emerg_setup_deny), pars);
7822 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007823 f_shutdown_helper();
Philipp Maier783681c2020-07-16 16:47:06 +02007824}
7825
7826/* EMERGENCY CALL situation #3, allowed globally but forbidden by BTS */
7827testcase TC_assignment_emerg_setup_deny_bts() runs on test_CT {
7828 var TestHdlrParams pars := f_gen_test_hdlr_pars();
7829 var MSC_ConnHdlr vc_conn;
7830
7831 /* Note: This simulates a spec violation by the MS, correct MS
7832 * implementations would not try to establish an emergency call because
7833 * the system information tells in advance that emergency calls are
7834 * not forbidden */
7835
7836 f_init(1, true);
7837 f_sleep(1.0);
7838
7839 f_vty_allow_emerg_msc(true);
7840 f_vty_allow_emerg_bts(false, 0);
7841 vc_conn := f_start_handler(refers(f_TC_assignment_emerg_setup_deny), pars);
7842 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007843 f_shutdown_helper();
Philipp Maier783681c2020-07-16 16:47:06 +02007844}
7845
Philipp Maier82812002020-08-13 18:48:27 +02007846/* Test what happens when an emergency call arrives while all TCH channels are
7847 * busy, the BSC is expected to terminate one call in favor of the incoming
7848 * emergency call */
7849testcase TC_emerg_premption() runs on test_CT {
7850 var ASP_RSL_Unitdata rsl_ud;
7851 var integer i;
7852 var integer chreq_total, chreq_nochan;
7853 var RSL_Message rx_rsl;
7854 var RslChannelNr chan_nr;
7855
7856 f_init(1);
7857 f_sleep(1.0);
7858
7859 f_vty_allow_emerg_msc(true);
7860 f_vty_allow_emerg_bts(true, 0);
7861
7862 /* Fill up all channels on the BTS */
7863 chreq_total := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total");
7864 chreq_nochan := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:no_channel");
7865 for (i := 0; i < NUM_TCHF_PER_BTS + NUM_TCHH_PER_BTS + NUM_SDCCH_PER_BTS; i := i+1) {
7866 chan_nr := f_chreq_act_ack('33'O, i);
7867 }
7868 IPA_RSL[0].clear;
7869 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total",
7870 chreq_total + NUM_TCHF_PER_BTS + NUM_TCHH_PER_BTS + NUM_SDCCH_PER_BTS);
7871
7872 /* Send Channel request for emegergency call */
7873 f_ipa_tx(0, ts_RSL_CHAN_RQD('A5'O, 23));
7874
7875 /* Expect the BSC to release one (the first) TCH/F on the BTS */
7876 chan_nr := valueof(t_RslChanNr_Bm(1));
7877 f_expect_chan_rel(0, chan_nr, expect_rr_chan_rel := false, expect_rll_rel_req := false);
7878
7879 /* Expect the BSC to send activate/assign the a channel for the emergency call */
7880 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
7881 chan_nr := rx_rsl.ies[0].body.chan_nr;
7882 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, 33));
7883 rx_rsl := f_exp_ipa_rx(0, tr_RSL_IMM_ASSIGN(0));
Philipp Maier104f4c02020-09-11 18:12:18 +02007884
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007885 f_shutdown_helper();
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007886}
7887
7888/* Hopping parameters per a timeslot */
Vadim Yanitskiybc6654a2020-09-13 01:27:40 +07007889private type record length(0..64) of GsmArfcn ArfcnList;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007890private type record FHParamsTs {
7891 boolean enabled,
7892 uint6_t hsn,
7893 uint6_t maio,
7894 ArfcnList ma
7895};
7896
7897/* Hopping parameters per a transceiver */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007898private type record FHParamsTrx {
7899 GsmArfcn arfcn,
7900 FHParamsTs ts[8]
7901};
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007902
7903/* Randomly generate the hopping parameters for the given timeslot numbers */
7904private function f_TC_fh_params_gen(template integer tr_tn := (1, 3, 5))
7905runs on test_CT return FHParamsTrx {
7906 var FHParamsTrx fhp;
7907
Vadim Yanitskiy3e997362020-09-05 21:08:34 +07007908 /* Generate a random ARFCN, including ARFCN 0 */
7909 fhp.arfcn := f_rnd_int(3);
Vadim Yanitskiye7c8c6e2020-09-13 14:33:03 +07007910
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007911 for (var integer tn := 0; tn < 8; tn := tn + 1) {
7912 if (not match(tn, tr_tn)) {
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007913 fhp.ts[tn].enabled := false;
7914 fhp.ts[tn].ma := { };
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007915 continue;
7916 }
7917
7918 /* Random HSN / MAIO values: 0..63 */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007919 fhp.ts[tn].hsn := f_rnd_int(64);
7920 fhp.ts[tn].maio := f_rnd_int(64);
7921 fhp.ts[tn].ma := { };
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007922
7923 /* Random Mobile Allocation (hopping channels) */
7924 var integer ma_len := 2 + f_rnd_int(9); /* 2..10 channels */
7925 var integer step := 3 + f_rnd_int(4); /* 3..6 stepping */
7926 for (var integer i := 1; i <= ma_len; i := i + 1) {
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007927 fhp.ts[tn].ma := fhp.ts[tn].ma & { i * step };
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007928 }
7929
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007930 fhp.ts[tn].enabled := true;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007931 }
7932
7933 log("f_TC_fh_params_gen(): ", fhp);
7934 return fhp;
7935}
7936
7937/* Make sure that the given Channel Description IE matches the hopping configuration */
7938private function f_TC_fh_params_match_chan_desc(in FHParamsTrx fhp, in ChannelDescription cd)
7939{
7940 var template (present) ChannelDescription tr_cd;
7941 var template (present) MaioHsn tr_maio_hsn;
7942 var uint3_t tn := cd.chan_nr.tn;
7943
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007944 if (fhp.ts[tn].enabled) {
7945 tr_maio_hsn := tr_HsnMaio(fhp.ts[tn].hsn, fhp.ts[tn].maio);
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007946 tr_cd := tr_ChanDescH1(cd.chan_nr, tr_maio_hsn);
7947 } else {
Vadim Yanitskiye7c8c6e2020-09-13 14:33:03 +07007948 tr_cd := tr_ChanDescH0(cd.chan_nr, fhp.arfcn);
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007949 }
7950
7951 if (not match(cd, tr_cd)) {
7952 setverdict(fail, "Channel Description IE does not match: ",
7953 cd, " vs expected ", tr_cd);
7954 }
7955}
7956
7957/* Make sure that the given Mobile Allocation IE matches the hopping configuration */
7958private function f_TC_fh_params_match_ma(in FHParamsTrx fhp, uint3_t tn,
7959 in MobileAllocationLV ma)
7960{
7961 var template MobileAllocationLV tr_ma := f_TC_fh_params_gen_tr_ma(fhp, tn, ma);
7962
7963 if (not match(ma, tr_ma)) {
7964 setverdict(fail, "Mobile Allocation IE does not match (tn := ",
7965 tn, "): ", ma, " vs expected: ", tr_ma);
7966 } else {
7967 setverdict(pass);
7968 }
7969}
7970
7971private function f_TC_fh_params_gen_tr_ma(in FHParamsTrx fhp, uint3_t tn,
7972 in MobileAllocationLV ma)
7973return template MobileAllocationLV {
7974 /* Mobile Allocation IE is expected to be empty if hopping is not enabled */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007975 if (not fhp.ts[tn].enabled) {
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007976 return { len := 0, ma := ''B };
7977 }
7978
7979 var bitstring full_mask := f_pad_bit(''B, 1024, '0'B);
7980 var bitstring slot_mask := f_pad_bit(''B, 1024, '0'B);
7981 var bitstring ma_mask := ''B;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007982
7983 /* Compose the full bit-mask (all channels, up to 1024 entries) */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007984 for (var integer i := 0; i < lengthof(fhp.ts); i := i + 1) {
7985 for (var integer j := 0; j < lengthof(fhp.ts[i].ma); j := j + 1) {
7986 if (full_mask[fhp.ts[i].ma[j]] == '1'B)
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007987 { continue; }
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007988 full_mask[fhp.ts[i].ma[j]] := '1'B;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007989 }
7990 }
7991
Vadim Yanitskiye7c8c6e2020-09-13 14:33:03 +07007992 /* Take ARFCN of the TRX itself into account */
7993 full_mask[fhp.arfcn] := '1'B;
7994
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007995 /* Compose a bit-mask for the given timeslot number */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007996 for (var integer i := 0; i < lengthof(fhp.ts[tn].ma); i := i + 1) {
7997 slot_mask[fhp.ts[tn].ma[i]] := '1'B;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007998 }
7999
8000 /* Finally, compose the Mobile Allocation bit-mask */
Vadim Yanitskiy3e997362020-09-05 21:08:34 +07008001 for (var integer i := 1; i < lengthof(full_mask); i := i + 1) {
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008002 if (full_mask[i] != '1'B)
8003 { continue; }
8004
8005 /* FIXME: ma_mask := ma_mask & slot_mask[i]; // triggers a bug in TITAN */
8006 if (slot_mask[i] == '1'B) {
8007 ma_mask := ma_mask & '1'B;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008008 } else {
8009 ma_mask := ma_mask & '0'B;
8010 }
8011 }
8012
Vadim Yanitskiy3e997362020-09-05 21:08:34 +07008013 /* ARFCN 0 (if present) goes to the last position of the bit-mask */
8014 if (full_mask[0] == '1'B) {
8015 /* FIXME: ma_mask := ma_mask & slot_mask[0]; // triggers a bug in TITAN */
8016 if (slot_mask[0] == '1'B) {
8017 ma_mask := ma_mask & '1'B;
8018 } else {
8019 ma_mask := ma_mask & '0'B;
8020 }
8021 }
8022
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008023 /* Ensure that ma_mask is octet-aligned */
Vadim Yanitskiy2aa02522020-09-06 14:05:23 +07008024 var integer ma_mask_len := (lengthof(ma_mask) + 8 - 1) / 8;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008025 ma_mask := f_pad_bit(ma_mask, ma_mask_len * 8, '0'B);
8026
8027 return { len := ma_mask_len, ma := ma_mask };
8028}
8029
8030/* Configure the hopping parameters in accordance with the given record */
8031private function f_TC_fh_params_set(in FHParamsTrx fhp,
8032 uint8_t bts_nr := 0,
8033 uint8_t trx_nr := 0)
8034runs on test_CT {
8035 /* Enter the configuration node for the given BTS/TRX numbers */
8036 f_vty_enter_cfg_trx(BSCVTY, bts_nr, trx_nr);
8037
Vadim Yanitskiye7c8c6e2020-09-13 14:33:03 +07008038 f_vty_transceive(BSCVTY, "arfcn " & int2str(fhp.arfcn));
8039
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07008040 for (var integer tn := 0; tn < lengthof(fhp.ts); tn := tn + 1) {
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008041 f_vty_transceive(BSCVTY, "timeslot " & int2str(tn));
8042
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07008043 if (not fhp.ts[tn].enabled) {
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008044 f_vty_transceive(BSCVTY, "hopping enabled 0");
8045 f_vty_transceive(BSCVTY, "exit"); /* go back */
8046 continue;
8047 }
8048
8049 /* Configure HSN / MAIO values */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07008050 f_vty_transceive(BSCVTY, "hopping sequence-number " & int2str(fhp.ts[tn].hsn));
8051 f_vty_transceive(BSCVTY, "hopping maio " & int2str(fhp.ts[tn].maio));
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008052
8053 /* Configure the Mobile Allocation (hopping channels) */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07008054 for (var integer i := 0; i < lengthof(fhp.ts[tn].ma); i := i + 1) {
8055 f_vty_transceive(BSCVTY, "hopping arfcn add " & int2str(fhp.ts[tn].ma[i]));
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008056 }
8057
8058 f_vty_transceive(BSCVTY, "hopping enabled 1");
8059 f_vty_transceive(BSCVTY, "exit"); /* go back */
8060 }
8061
8062 f_vty_transceive(BSCVTY, "end");
8063}
8064
8065/* Disable frequency hopping on all timeslots */
8066private function f_TC_fh_params_unset(in FHParamsTrx fhp,
8067 uint8_t bts_nr := 0,
Vadim Yanitskiye7c8c6e2020-09-13 14:33:03 +07008068 uint8_t trx_nr := 0,
8069 GsmArfcn arfcn := 871)
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008070runs on test_CT {
8071 /* Enter the configuration node for the given BTS/TRX numbers */
8072 f_vty_enter_cfg_trx(BSCVTY, bts_nr, trx_nr);
8073
Vadim Yanitskiye7c8c6e2020-09-13 14:33:03 +07008074 f_vty_transceive(BSCVTY, "arfcn " & int2str(arfcn));
8075
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07008076 for (var integer tn := 0; tn < lengthof(fhp.ts); tn := tn + 1) {
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008077 f_vty_transceive(BSCVTY, "timeslot " & int2str(tn));
8078
8079 /* Delete all ARFCNs from the Mobile Allocation (if any) */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07008080 for (var integer i := 0; i < lengthof(fhp.ts[tn].ma); i := i + 1) {
8081 f_vty_transceive(BSCVTY, "hopping arfcn del " & int2str(fhp.ts[tn].ma[i]));
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008082 }
8083
8084 f_vty_transceive(BSCVTY, "hopping enabled 0");
8085 f_vty_transceive(BSCVTY, "exit"); /* go back */
8086 }
8087
8088 f_vty_transceive(BSCVTY, "end");
8089 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
8090}
8091
8092/* Verify presence and correctness of the hopping parameters (HSN, MAIO)
8093 * in the Channel Identification IE of the RSL CHANnel ACTIVation message. */
8094testcase TC_fh_params_chan_activ() runs on test_CT {
8095 var FHParamsTrx fhp := f_TC_fh_params_gen();
8096 var RSL_Message rsl_msg;
8097 var RSL_IE_Body ie;
8098
8099 f_init_vty();
8100
8101 f_TC_fh_params_set(fhp); /* Enable frequency hopping */
8102 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
8103
8104 f_init(1);
8105
8106 /* CS domain: 3 (SDCCH/4+CBCH) + 4 (TCH/F) + 2 (TCH/H) channels available */
8107 for (var integer i := 0; i < 9; i := i + 1) {
8108 f_ipa_tx(0, ts_RSL_CHAN_RQD(f_rnd_ra_cs(), 23));
8109 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
8110
8111 /* Make sure that Channel Identification IE is present */
8112 if (not f_rsl_find_ie(rsl_msg, RSL_IE_CHAN_IDENT, ie)) {
8113 setverdict(fail, "RSL Channel Identification IE is absent");
8114 continue;
8115 }
8116
8117 /* Make sure that hopping parameters (HSN/MAIO) match */
8118 f_TC_fh_params_match_chan_desc(fhp, ie.chan_ident.ch_desc.v);
8119
8120 /* "Mobile Allocation shall be included but empty" - let's check this */
8121 if (ie.chan_ident.ma.v.len != 0) {
8122 setverdict(fail, "Mobile Allocation IE is not empty: ",
8123 ie.chan_ident.ma, ", despite it shall be");
8124 continue;
8125 }
8126 }
8127
8128 /* Disable frequency hopping */
8129 f_TC_fh_params_unset(fhp);
8130
Vadim Yanitskiy21726312020-09-04 01:45:36 +07008131 f_shutdown_helper();
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008132}
8133
8134/* Verify the hopping parameters (HSN, MAIO, MA) in (RR) Immediate Assignment */
8135testcase TC_fh_params_imm_ass() runs on test_CT {
8136 var FHParamsTrx fhp := f_TC_fh_params_gen();
8137 var RSL_Message rsl_msg;
8138 var RSL_IE_Body ie;
8139
8140 f_init_vty();
8141
8142 f_TC_fh_params_set(fhp); /* Enable frequency hopping */
8143 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
8144
8145 f_init(1);
8146
8147 /* CS domain: 3 (SDCCH/4+CBCH) + 4 (TCH/F) + 2 (TCH/H) channels available */
8148 for (var integer i := 0; i < 9; i := i + 1) {
8149 f_ipa_tx(0, ts_RSL_CHAN_RQD(f_rnd_ra_cs(), 23));
8150 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
8151
8152 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(rsl_msg.ies[0].body.chan_nr, 33));
8153 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeC(RSL_MT_IMMEDIATE_ASSIGN_CMD));
8154
8155 /* Make sure that Full Immediate Assign Info IE is present */
8156 if (not f_rsl_find_ie(rsl_msg, RSL_IE_FULL_IMM_ASS_INFO, ie)) {
8157 setverdict(fail, "RSL Full Immediate Assign Info IE is absent");
8158 continue;
8159 }
8160
8161 /* Decode the actual Immediate Assignment message */
8162 var GsmRrMessage rr_msg := dec_GsmRrMessage(ie.full_imm_ass_info.payload);
8163 if (not match(rr_msg.header, t_RrHeader(IMMEDIATE_ASSIGNMENT, ?))) {
8164 setverdict(fail, "Failed to match Immediate Assignment: ", rr_msg);
8165 continue;
8166 }
8167
8168 /* Make sure that hopping parameters (HSN/MAIO) match */
8169 f_TC_fh_params_match_chan_desc(fhp, rr_msg.payload.imm_ass.chan_desc);
8170
8171 /* Make sure that the Mobile Allocation IE matches */
8172 f_TC_fh_params_match_ma(fhp, rr_msg.payload.imm_ass.chan_desc.chan_nr.tn,
8173 rr_msg.payload.imm_ass.mobile_allocation);
8174 }
8175
8176 /* Disable frequency hopping */
8177 f_TC_fh_params_unset(fhp);
Philipp Maier82812002020-08-13 18:48:27 +02008178
Vadim Yanitskiy21726312020-09-04 01:45:36 +07008179 f_shutdown_helper();
Philipp Maier82812002020-08-13 18:48:27 +02008180}
8181
Vadim Yanitskiyaeb54a22020-09-01 06:25:25 +07008182/* Verify the hopping parameters (HSN, MAIO, MA) in (RR) Assignment Command */
8183testcase TC_fh_params_assignment_cmd() runs on test_CT {
8184 var FHParamsTrx fhp := f_TC_fh_params_gen();
8185 var RSL_Message rsl_msg;
8186 var RSL_IE_Body ie;
8187
8188 f_init_vty();
8189
8190 f_TC_fh_params_set(fhp); /* Enable frequency hopping */
8191 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
8192
8193 f_init(1);
8194
8195 /* HACK: work around "Couldn't find Expect for CRCX" */
8196 vc_MGCP.stop;
8197
8198 var template PDU_BSSAP ass_cmd := f_gen_ass_req();
8199 ass_cmd.pdu.bssmap.assignmentRequest.codecList := ts_BSSMAP_IE_CodecList({ts_CodecFR});
8200
8201 /* CS domain (TCH): 4 (TCH/F) + 2 (TCH/H) channels available
8202 * NOTE: only 3 SDCCH/4 channels are available on CCCH+SDCCH4+CBCH */
8203 for (var integer i := 0; i < 3; i := i + 1) {
8204 /* Establish a dedicated channel, so we can trigger (late) TCH assignment */
8205 var DchanTuple dt := f_est_dchan(f_rnd_ra_cs(), 23, f_rnd_octstring(16));
8206
8207 /* Send a BSSMAP Assignment Command, expect CHANnel ACTIVation */
8208 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ass_cmd));
8209 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
8210
8211 /* ACKnowledge CHANnel ACTIVation, expect RSL DATA REQuest */
8212 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(rsl_msg.ies[0].body.chan_nr, 33));
8213 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeR(RSL_MT_DATA_REQ));
8214
8215 /* Make sure that L3 Information IE is present */
8216 if (not f_rsl_find_ie(rsl_msg, RSL_IE_L3_INFO, ie)) {
8217 setverdict(fail, "RSL L3 Information IE is absent");
8218 continue;
8219 }
8220
8221 /* Decode the L3 message and make sure it is (RR) Assignment Command */
8222 var GsmRrL3Message l3_msg := dec_GsmRrL3Message(ie.l3_info.payload);
8223 if (not match(l3_msg.header, t_RrL3Header(ASSIGNMENT_COMMAND))) {
8224 setverdict(fail, "Failed to match Assignment Command: ", l3_msg);
8225 continue;
8226 }
8227
8228 /* Make sure that hopping parameters (HSN/MAIO) match */
8229 var ChannelDescription chan_desc := l3_msg.payload.ass_cmd.chan_desc;
8230 f_TC_fh_params_match_chan_desc(fhp, chan_desc);
8231
8232 /* Make sure that Cell Channel Description IE is present if FH is enabled */
8233 if (chan_desc.h and not ispresent(l3_msg.payload.ass_cmd.cell_chan_desc)) {
Vadim Yanitskiy38d069d2020-09-02 17:18:57 +07008234 setverdict(fail, "FH enabled, but Cell Channel Description IE is absent");
Vadim Yanitskiyaeb54a22020-09-01 06:25:25 +07008235 continue;
8236 }
8237
8238 /* Make sure that the Mobile Allocation IE matches (if present) */
8239 var boolean ma_present := ispresent(l3_msg.payload.ass_cmd.mobile_allocation);
8240 if (chan_desc.h and ma_present) {
8241 f_TC_fh_params_match_ma(fhp, chan_desc.chan_nr.tn,
8242 l3_msg.payload.ass_cmd.mobile_allocation.v);
8243 } else if (chan_desc.h and not ma_present) {
8244 setverdict(fail, "FH enabled, but Mobile Allocation IE is absent");
8245 continue;
8246 } else if (not chan_desc.h and ma_present) {
8247 setverdict(fail, "FH disabled, but Mobile Allocation IE is present");
8248 continue;
8249 }
8250 }
8251
8252 /* Give the IUT some time to release all channels */
8253 f_sleep(3.0);
8254
8255 /* Disable frequency hopping */
8256 f_TC_fh_params_unset(fhp);
8257
Vadim Yanitskiy21726312020-09-04 01:45:36 +07008258 f_shutdown_helper();
Vadim Yanitskiyaeb54a22020-09-01 06:25:25 +07008259}
8260
Vadim Yanitskiy8f5430d2020-09-02 18:51:38 +07008261/* Verify the hopping parameters (HSN, MAIO, MA) in (RR) Handover Command */
8262private function f_TC_fh_params_handover_cmd(in FHParamsTrx fhp)
8263runs on test_CT {
8264 var RSL_Message rsl_msg;
8265 var RSL_IE_Body ie;
8266 var DchanTuple dt;
8267
8268 /* Establish a dedicated channel, so we can trigger handover */
8269 dt := f_est_dchan(f_rnd_ra_cs(), 23, f_rnd_octstring(16));
8270
8271 /* Trigger handover from BTS0 to BTS1 */
8272 f_bts_0_cfg(BSCVTY, { "neighbor bts 1" });
8273 f_vty_handover(BSCVTY, 0, 0, dt.rsl_chan_nr, 1);
8274
8275 /* Expect RSL CHANnel ACTIVation on BTS1/TRX0/TS1 */
8276 rsl_msg := f_exp_ipa_rx(1, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
8277
8278 /* ACKnowledge channel activation and expect (RR) Handover Command */
8279 f_ipa_tx(1, ts_RSL_CHAN_ACT_ACK(rsl_msg.ies[0].body.chan_nr, 33));
8280 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeR(RSL_MT_DATA_REQ));
8281
8282 /* Make sure that L3 Information IE is present */
8283 if (not f_rsl_find_ie(rsl_msg, RSL_IE_L3_INFO, ie)) {
8284 setverdict(fail, "RSL L3 Information IE is absent");
8285 return;
8286 }
8287
8288 /* Decode the L3 message and make sure it is (RR) Handover Command */
8289 var GsmRrL3Message l3_msg := dec_GsmRrL3Message(ie.l3_info.payload);
8290 if (not match(l3_msg.header, t_RrL3Header(HANDOVER_COMMAND))) {
8291 setverdict(fail, "Failed to match Handover Command: ", l3_msg);
8292 return;
8293 }
8294
8295 /* Make sure that we've got SDCCH/8 on TS1 (expected to be hopping) */
8296 var ChannelDescription chan_desc := l3_msg.payload.ho_cmd.chan_desc;
8297 if (not match(chan_desc.chan_nr, t_RslChanNr_SDCCH8(1, ?))) {
8298 setverdict(fail, "Unexpected channel number: ", chan_desc.chan_nr);
8299 return;
8300 }
8301
8302 /* Make sure that hopping parameters (HSN/MAIO) match */
8303 f_TC_fh_params_match_chan_desc(fhp, chan_desc);
8304
8305 /* Make sure that Cell Channel Description IE is present */
8306 if (not ispresent(l3_msg.payload.ho_cmd.cell_chan_desc)) {
8307 setverdict(fail, "FH enabled, but Cell Channel Description IE is absent");
8308 return;
8309 }
8310
8311 /* Make sure that the Mobile Allocation (after time) IE is present and matches */
8312 var boolean ma_present := ispresent(l3_msg.payload.ho_cmd.mobile_allocation);
8313 if (ma_present) {
8314 f_TC_fh_params_match_ma(fhp, chan_desc.chan_nr.tn,
8315 l3_msg.payload.ho_cmd.mobile_allocation.v);
8316 } else {
8317 setverdict(fail, "FH enabled, but Mobile Allocation IE is absent");
8318 return;
8319 }
8320}
8321testcase TC_fh_params_handover_cmd() runs on test_CT {
8322 var FHParamsTrx fhp := f_TC_fh_params_gen();
8323
8324 f_init_vty();
8325
8326 /* (Re)configure TS0 as BCCH and TS1 as SDCCH8 on BTS1/TRX0 */
8327 f_vty_enter_cfg_trx(BSCVTY, bts := 1, trx := 0);
8328
8329 f_vty_transceive(BSCVTY, "timeslot 0");
8330 f_vty_transceive(BSCVTY, "phys_chan_config ccch");
8331 f_vty_transceive(BSCVTY, "exit"); /* go back */
8332
8333 f_vty_transceive(BSCVTY, "timeslot 1");
8334 f_vty_transceive(BSCVTY, "phys_chan_config sdcch8");
8335 f_vty_transceive(BSCVTY, "end"); /* we're done */
8336
8337 f_TC_fh_params_set(fhp, 1); /* Enable frequency hopping on BTS1 */
8338 f_vty_transceive(BSCVTY, "drop bts connection 1 oml");
8339
8340 f_init(2);
8341
8342 f_TC_fh_params_handover_cmd(fhp);
8343
8344 /* Disable frequency hopping on BTS1 */
8345 f_TC_fh_params_unset(fhp, 1);
8346
8347 /* (Re)configure TS0 as CCCH+SDCCH4+CBCH and TS1 as TCH/F */
8348 f_vty_enter_cfg_trx(BSCVTY, bts := 1, trx := 0);
8349
8350 f_vty_transceive(BSCVTY, "timeslot 0");
8351 f_vty_transceive(BSCVTY, "phys_chan_config ccch+sdcch4+cbch");
8352 f_vty_transceive(BSCVTY, "exit"); /* go back */
8353
8354 f_vty_transceive(BSCVTY, "timeslot 1");
8355 f_vty_transceive(BSCVTY, "phys_chan_config tch/f");
8356 f_vty_transceive(BSCVTY, "end"); /* we're done */
8357
8358 f_shutdown_helper();
8359}
8360
Vadim Yanitskiyca974032020-09-01 07:20:39 +07008361/* Verify the hopping parameters in System Information Type 4 */
8362testcase TC_fh_params_si4_cbch() runs on test_CT {
8363 var FHParamsTrx fhp := f_TC_fh_params_gen(tr_tn := 1);
8364 var ASP_RSL_Unitdata rx_rsl_ud;
8365 timer T := 5.0;
8366
8367 f_init_vty();
8368
8369 /* (Re)configure TS0 as BCCH and TS1 as SDCCH8+CBCH */
8370 f_vty_enter_cfg_trx(BSCVTY, trx := 0);
8371
8372 f_vty_transceive(BSCVTY, "timeslot 0");
8373 f_vty_transceive(BSCVTY, "phys_chan_config ccch");
8374 f_vty_transceive(BSCVTY, "exit"); /* go back */
8375
8376 f_vty_transceive(BSCVTY, "timeslot 1");
8377 f_vty_transceive(BSCVTY, "phys_chan_config sdcch8+cbch");
8378 f_vty_transceive(BSCVTY, "end"); /* we're done */
8379
8380 f_TC_fh_params_set(fhp); /* Enable frequency hopping */
8381 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
8382
8383 f_init(1);
8384
8385 T.start;
8386 alt {
8387 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_BCCH_INFO(RSL_SYSTEM_INFO_4))) -> value rx_rsl_ud {
8388 var RSL_IE_Body ie := rx_rsl_ud.rsl.ies[2].body; /* FULL BCCH Information IE */
8389 var SystemInformation si := dec_SystemInformation(ie.other.payload);
8390
8391 /* Make sure that what we decoded is System Information Type 4 */
8392 if (si.header.message_type != SYSTEM_INFORMATION_TYPE_4) {
8393 setverdict(fail, "RSL FULL BCCH Information IE contains: ", si);
8394 repeat;
8395 }
8396
8397 /* Make sure that CBCH Channel Description IE is present */
8398 if (not ispresent(si.payload.si4.cbch_chan_desc)) {
8399 setverdict(fail, "CBCH Channel Description IE is absent");
8400 break;
8401 }
8402
8403 /* Finally, check the hopping parameters (HSN, MAIO) */
8404 var ChannelDescription chan_desc := si.payload.si4.cbch_chan_desc.v;
8405 f_TC_fh_params_match_chan_desc(fhp, chan_desc);
8406
8407 /* 3GPP TS 44.018, section 9.1.36.2 "CBCH Mobile Allocation":
8408 * The CBCH Mobile Allocation IE *shall* be present if FH is enabled. */
8409 if (chan_desc.h and not ispresent(si.payload.si4.cbch_mobile_alloc)) {
8410 setverdict(fail, "FH enabled, but Mobile Allocation IE is absent");
8411 break;
8412 } else if (chan_desc.h and ispresent(si.payload.si4.cbch_mobile_alloc)) {
8413 f_TC_fh_params_match_ma(fhp, chan_desc.chan_nr.tn,
8414 si.payload.si4.cbch_mobile_alloc.v);
8415 }
8416 }
8417 [] IPA_RSL[0].receive { repeat; }
8418 [] T.timeout {
8419 setverdict(fail, "Timeout waiting for RSL BCCH INFOrmation (SI4)");
8420 }
8421 }
8422
8423 /* Disable frequency hopping */
8424 f_TC_fh_params_unset(fhp);
8425
Vadim Yanitskiy8bc46012020-09-06 12:38:01 +07008426 /* (Re)configure TS0 as CCCH+SDCCH4+CBCH and TS1 as TCH/F */
Vadim Yanitskiyca974032020-09-01 07:20:39 +07008427 f_vty_enter_cfg_trx(BSCVTY, trx := 0);
8428
8429 f_vty_transceive(BSCVTY, "timeslot 0");
Vadim Yanitskiy8bc46012020-09-06 12:38:01 +07008430 f_vty_transceive(BSCVTY, "phys_chan_config ccch+sdcch4+cbch");
Vadim Yanitskiyca974032020-09-01 07:20:39 +07008431 f_vty_transceive(BSCVTY, "exit"); /* go back */
8432
8433 f_vty_transceive(BSCVTY, "timeslot 1");
8434 f_vty_transceive(BSCVTY, "phys_chan_config tch/f");
8435 f_vty_transceive(BSCVTY, "end"); /* we're done */
8436
Vadim Yanitskiy21726312020-09-04 01:45:36 +07008437 f_shutdown_helper();
Vadim Yanitskiyca974032020-09-01 07:20:39 +07008438}
8439
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02008440template (value) PDU_BSSAP_LE ts_BSSMAP_LE_BSSLAP(template (value) BSSLAP_PDU bsslap)
8441 := ts_BSSMAP_LE_ConnInfo(BSSMAP_LE_PROT_BSSLAP, data := enc_BSSLAP_PDU(valueof(bsslap)));
8442
8443private function f_match_bsslap(PDU_BSSAP_LE got_bsslap_msg,
8444 template (present) BSSLAP_PDU expect_bsslap)
8445{
8446 var BSSLAP_PDU bsslap := dec_BSSLAP_PDU(got_bsslap_msg.pdu.bssmap.co_info.bsslap_apdu.data);
8447 if (not match(bsslap, expect_bsslap)) {
8448 log("EXPECTING BSSLAP: ", expect_bsslap);
8449 log("GOT BSSLAP: ", bsslap);
8450 setverdict(fail, "BSSLAP is not as expected");
8451 mtc.stop;
8452 }
8453 setverdict(pass);
8454}
8455
8456/* GAD: this is an Ellipsoid point with uncertainty circle, encoded as in 3GPP TS 23.032 §7.3.2. */
8457const octetstring gad_ell_point_unc_circle := '10b0646d0d5f6627'O;
8458
8459private function f_expect_bsslap(template (present) BSSLAP_PDU expect_rx_bsslap) runs on MSC_ConnHdlr {
8460 var PDU_BSSAP_LE rx_bsslap;
8461 BSSAP_LE.receive(tr_BSSMAP_LE_ConnInfo(BSSMAP_LE_PROT_BSSLAP, ?)) -> value(rx_bsslap);
8462 f_match_bsslap(rx_bsslap, expect_rx_bsslap);
8463}
8464
8465/* With an active lchan, start BSSMAP Perform Location Request on A interface, starting BSSMAP-LE Perform Location
8466 * Request on Lb interface. Either with or without the SMLC doing a BSSLAP TA Request. */
8467private function f_lcs_loc_req_for_active_ms(boolean do_ta_request := false) runs on MSC_ConnHdlr {
8468 f_sleep(1.0);
8469
8470 f_establish_fully(omit, omit);
8471 f_bssap_le_register_imsi(g_pars.imsi, omit);
8472
8473 BSSAP.send(valueof(ts_BSSMAP_Perform_Location_Request(ts_BSSMAP_Imsi(g_pars.imsi),
8474 ts_CellId_CGI('262'H, '42'H, 23, 42))));
8475
8476 var PDU_BSSAP_LE plr;
8477 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocReq(BSSMAP_LE_LOC_INFO_CURRENT_GEOGRAPHIC_LOC, ?, ?)) -> value(plr);
8478
8479 if (not do_ta_request) {
8480 /* verify TA Layer 3 in APDU. First the APDU type (BSSLAP), then the BSSLAP data contents. */
8481 var template BSSMAP_LE_IE_APDU expect_apdu := tr_BSSMAP_LE_APDU(BSSMAP_LE_PROT_BSSLAP, ?);
8482 if (not match(plr.pdu.bssmap.perf_loc_req.bsslap_apdu, expect_apdu)) {
8483 log("EXPECTING BSSMAP-LE APDU IE ", expect_apdu);
8484 log("GOT BSSMAP-LE APDU IE ", plr.pdu.bssmap.perf_loc_req.bsslap_apdu);
8485 setverdict(fail, "BSSMAP-LE APDU IE is not as expected");
8486 mtc.stop;
8487 }
8488 var template BSSLAP_PDU expect_ta_layer3 := tr_BSSLAP_TA_Layer3(tr_BSSLAP_IE_TA(0));
8489 var BSSLAP_PDU bsslap := dec_BSSLAP_PDU(plr.pdu.bssmap.perf_loc_req.bsslap_apdu.data);
8490 if (not match(bsslap, expect_ta_layer3)) {
8491 log("EXPECTING BSSLAP TA Layer 3: ", expect_ta_layer3);
8492 log("GOT BSSLAP: ", bsslap);
8493 setverdict(fail, "BSSLAP is not as expected");
8494 mtc.stop;
8495 }
8496 /* OsmoBSC directly sent the TA as BSSLAP APDU in the BSSMAP-LE Perform Location Request to the SMLC. The SMLC
8497 * has no need to request the TA from the BSC and directly responds. */
8498 } else {
8499 /* SMLC wants to ask the TA from the BSC explicitly in a BSSLAP TA Request message */
8500 BSSAP_LE.send(ts_BSSMAP_LE_BSSLAP(ts_BSSLAP_TA_Req));
8501 f_expect_bsslap(tr_BSSLAP_TA_Resp(?, ?));
8502 }
8503
8504 /* SMLC got the TA from the BSC, now responds with geo information data. */
8505 BSSAP_LE.send(ts_BSSMAP_LE_PerfLocResp(gad_ell_point_unc_circle, omit));
8506 BSSAP_LE.receive(BSSAP_LE_Conn_Prim:CONN_PRIM_DISC_IND);
8507 BSSAP.receive(tr_BSSMAP_Perform_Location_Response(tr_BSSMAP_IE_LocationEstimate(gad_ell_point_unc_circle)));
8508
8509 /* The LCS was using an active A-interface conn. It should still remain active after this. */
8510 f_mo_l3_transceive();
8511
8512 f_perform_clear(RSL);
8513
8514 f_sleep(2.0);
8515 setverdict(pass);
8516}
8517
8518/* With an active lchan, start BSSMAP Perform Location Request on A interface, starting BSSMAP-LE Perform Location
8519 * Request on Lb interface. Without the SMLC doing a BSSLAP TA Request. */
8520private function f_tc_lcs_loc_req_for_active_ms(charstring id) runs on MSC_ConnHdlr {
8521 f_lcs_loc_req_for_active_ms(false);
8522}
8523testcase TC_lcs_loc_req_for_active_ms() runs on test_CT {
8524 var MSC_ConnHdlr vc_conn;
8525 var TestHdlrParams pars := f_gen_test_hdlr_pars();
8526
8527 f_init(1, true);
8528 f_sleep(1.0);
8529 vc_conn := f_start_handler(refers(f_tc_lcs_loc_req_for_active_ms), pars);
8530 vc_conn.done;
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01008531 f_shutdown_helper();
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02008532}
8533
8534/* With an active lchan, start BSSMAP Perform Location Request on A interface, starting BSSMAP-LE Perform Location
8535 * Request on Lb interface. With the SMLC doing a BSSLAP TA Request. */
8536private function f_tc_lcs_loc_req_for_active_ms_ta_req(charstring id) runs on MSC_ConnHdlr {
8537 f_lcs_loc_req_for_active_ms(true);
8538}
8539testcase TC_lcs_loc_req_for_active_ms_ta_req() runs on test_CT {
8540 var MSC_ConnHdlr vc_conn;
8541 var TestHdlrParams pars := f_gen_test_hdlr_pars();
8542
8543 f_init(1, true);
8544 f_sleep(1.0);
8545 vc_conn := f_start_handler(refers(f_tc_lcs_loc_req_for_active_ms_ta_req), pars);
8546 vc_conn.done;
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01008547 f_shutdown_helper();
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02008548}
8549
8550/* Clear the A-interface conn only, without doing anything on Abis. Useful for LCS, for cases where there is only an A
8551 * conn without an active lchan. */
8552private function f_clear_A_conn() runs on MSC_ConnHdlr
8553{
8554 var BssmapCause cause := 0;
8555 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
8556 BSSAP.receive(tr_BSSMAP_ClearComplete);
8557 BSSAP.send(RAN_Conn_Prim:MSC_CONN_PRIM_DISC_REQ);
8558
8559 timer no_more_bssap := 5.0;
8560 no_more_bssap.start;
8561 alt {
8562 [] no_more_bssap.timeout { break; }
8563 [] BSSAP.receive(tr_BSSAP_BSSMAP) {
8564 setverdict(fail, "Expected no more BSSAP after Clear Complete");
8565 mtc.stop;
8566 }
8567 }
8568 setverdict(pass);
8569}
8570
8571/* Verify that the A-interface connection is still working, and then clear it, without doing anything on Abis. Useful
8572 * for LCS, for cases where there is only an A conn without an active lchan. */
8573private function f_verify_active_A_conn_and_clear() runs on MSC_ConnHdlr
8574{
8575 f_logp(BSCVTY, "f_verify_active_A_conn_and_clear: test A link, then clear");
8576
8577 /* When an lchan is active, we can send some L3 data from the BTS side and verify that it shows up on the other
8578 * side towards the MSC. When there is no lchan, this is not possible. To probe whether the A-interface
8579 * connection is still up, we need something that echos back on the A-interface. Another LCS request! */
8580 BSSAP.send(valueof(ts_BSSMAP_Perform_Location_Request(ts_BSSMAP_Imsi(g_pars.imsi),
8581 ts_CellId_CGI('262'H, '42'H, 23, 42))));
8582 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocReq(BSSMAP_LE_LOC_INFO_CURRENT_GEOGRAPHIC_LOC, ?, ?));
8583
8584 /* Right, the Perform Location Request showed up on Lb, now we can clear the A conn. */
8585 f_clear_A_conn();
8586 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocAbort(BSSMAP_LE_LCS_CAUSE_REQUEST_ABORTED));
8587 BSSAP_LE.receive(BSSAP_LE_Conn_Prim:CONN_PRIM_DISC_IND);
8588}
8589
8590/* With *no* active lchan, start BSSMAP Perform Location Request on A interface, starting BSSMAP-LE Perform Location
8591 * Request on Lb interface. BSC will Page for the subscriber as soon as we (virtual SMLC) request the TA via BSSLAP.
8592 */
8593private function f_tc_lcs_loc_req_for_idle_ms(charstring id) runs on MSC_ConnHdlr {
8594 f_sleep(1.0);
8595
8596 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
8597 f_bssap_le_register_imsi(g_pars.imsi, omit);
8598
8599 /* Register to receive the Paging Command */
8600 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
8601 g_chan_nr := new_chan_nr;
8602 f_rslem_register(0, g_chan_nr);
8603
8604 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
8605 valueof(ts_BSSMAP_Perform_Location_Request(ts_BSSMAP_Imsi(g_pars.imsi),
8606 ts_CellId_CGI('001'H, '01'H, 1, 0)))));
8607 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
8608
8609 var PDU_BSSAP_LE plr;
8610 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocReq(BSSMAP_LE_LOC_INFO_CURRENT_GEOGRAPHIC_LOC, ?, ?)) -> value(plr);
8611
8612 /* SMLC wants to ask the TA from the BSC explicitly in a BSSLAP TA Request message */
8613 BSSAP_LE.send(ts_BSSMAP_LE_BSSLAP(ts_BSSLAP_TA_Req));
8614
8615 /* OsmoBSC needs to Page */
8616 RSL.receive(tr_RSL_PAGING_CMD(tr_MI_IMSI(g_pars.imsi)));
8617 f_logp(BSCVTY, "got Paging Command");
8618
8619 /* MS requests channel. Since the Paging was for LCS, the Paging Response does not trigger a Complete Layer 3 to
8620 * the MSC, and releases the lchan directly. */
8621 f_perform_compl_l3(RSL, ts_PAG_RESP(valueof(ts_MI_IMSI_LV(g_pars.imsi))), do_clear := false, expect_bssmap_l3 := false);
8622 f_expect_lchan_rel(RSL);
8623
8624 /* From the Paging Response, the TA is now known to the BSC, and it responds to the SMLC. */
8625
8626 f_expect_bsslap(tr_BSSLAP_TA_Resp(?, ?));
8627
8628 /* SMLC got the TA from the BSC, now responds with geo information data. */
8629 BSSAP_LE.send(ts_BSSMAP_LE_PerfLocResp(gad_ell_point_unc_circle, omit));
8630 BSSAP_LE.receive(BSSAP_LE_Conn_Prim:CONN_PRIM_DISC_IND);
8631
8632 BSSAP.receive(tr_BSSMAP_Perform_Location_Response(tr_BSSMAP_IE_LocationEstimate(gad_ell_point_unc_circle)));
8633
8634 /* The lchan is gone, the A-interface conn was created for the LCS only.
8635 * Still it is clearly the MSC's job to decide whether to tear down the conn or not. */
8636 f_verify_active_A_conn_and_clear();
8637
8638 f_sleep(2.0);
8639 setverdict(pass);
8640}
8641testcase TC_lcs_loc_req_for_idle_ms() runs on test_CT {
8642 var MSC_ConnHdlr vc_conn;
8643 var TestHdlrParams pars := f_gen_test_hdlr_pars();
8644
8645 f_init(1, true);
8646 f_sleep(1.0);
8647
8648 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
8649 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
8650
8651 vc_conn := f_start_handler(refers(f_tc_lcs_loc_req_for_idle_ms), pars);
8652 vc_conn.done;
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01008653 f_shutdown_helper();
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02008654}
8655
8656/* With no active lchan, start BSSMAP Perform Location Request on A interface, but omit IMSI; expect failure response.
8657 */
8658private function f_tc_lcs_loc_req_no_subscriber(charstring id) runs on MSC_ConnHdlr {
8659 f_sleep(1.0);
8660
8661 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
8662 f_bssap_le_register_imsi(g_pars.imsi, omit);
8663
8664 /* provoke an abort by omitting both IMSI and IMEI */
8665 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
8666 valueof(ts_BSSMAP_Perform_Location_Request(omit,
8667 ts_CellId_CGI('262'H, '42'H, 23, 42)))));
8668 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
8669
8670 /* BSC tells MSC about failure */
8671 BSSAP.receive(tr_BSSMAP_Perform_Location_Response(
8672 locationEstimate := omit, positioningData := omit,
8673 lCS_Cause := tr_BSSMAP_LcsCause(BSSMAP_LCS_CAUSE_DATA_MISSING_IN_REQ)));
8674
8675 /* There is no lchan. Still the MSC's job to decide whether to tear down the conn or not. */
8676 f_verify_active_A_conn_and_clear();
8677
8678 f_sleep(2.0);
8679 setverdict(pass);
8680}
8681testcase TC_lcs_loc_req_no_subscriber() runs on test_CT {
8682 var MSC_ConnHdlr vc_conn;
8683 var TestHdlrParams pars := f_gen_test_hdlr_pars();
8684
8685 f_init(1, true);
8686 f_sleep(1.0);
8687
8688 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
8689 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
8690
8691 vc_conn := f_start_handler(refers(f_tc_lcs_loc_req_no_subscriber), pars);
8692 vc_conn.done;
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01008693 f_shutdown_helper();
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02008694}
8695
8696/* With an active lchan, start a Perform Location Request on the A-interface, but virtual SMLC does not answer with
8697 * BSSMAP-LE Perform Location Response (before or after sending a BSSLAP TA Request) */
8698private function f_lcs_loc_req_for_active_ms_le_timeout(boolean do_ta) runs on MSC_ConnHdlr {
8699 f_sleep(1.0);
8700
8701 f_establish_fully(omit, omit);
8702 f_bssap_le_register_imsi(g_pars.imsi, omit);
8703
8704 BSSAP.send(valueof(ts_BSSMAP_Perform_Location_Request(ts_BSSMAP_Imsi(g_pars.imsi),
8705 ts_CellId_CGI('262'H, '42'H, 23, 42))));
8706
8707 var PDU_BSSAP_LE plr;
8708 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocReq(BSSMAP_LE_LOC_INFO_CURRENT_GEOGRAPHIC_LOC, ?, ?)) -> value(plr);
8709
8710 if (do_ta) {
8711 /* SMLC wants to ask the TA from the BSC explicitly in a BSSLAP TA Request message */
8712 BSSAP_LE.send(ts_BSSMAP_LE_BSSLAP(ts_BSSLAP_TA_Req));
8713 f_expect_bsslap(tr_BSSLAP_TA_Resp(?, ?));
8714 }
8715
8716 /* SMLC fails to respond, BSC runs into timeout */
8717 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocAbort(BSSMAP_LE_LCS_CAUSE_SYSTEM_FAILURE));
8718 BSSAP_LE.receive(BSSAP_LE_Conn_Prim:CONN_PRIM_DISC_IND);
8719
8720 BSSAP.receive(tr_BSSMAP_Perform_Location_Response(
8721 locationEstimate := omit, positioningData := omit,
8722 lCS_Cause := tr_BSSMAP_LcsCause(BSSMAP_LCS_CAUSE_SYSTEM_FAILURE)));
8723
8724 /* There is no lchan. Still the MSC's job to decide whether to tear down the conn or not. */
8725 f_verify_active_A_conn_and_clear();
8726
8727 f_sleep(2.0);
8728 setverdict(pass);
8729}
8730
8731/* With an active lchan, start a Perform Location Request on the A-interface, but virtual SMLC does not answer with
8732 * BSSMAP-LE Perform Location Response, without sending a BSSLAP TA Request. */
8733private function f_tc_lcs_loc_req_for_active_ms_le_timeout(charstring id) runs on MSC_ConnHdlr {
8734 f_lcs_loc_req_for_active_ms_le_timeout(false);
8735}
8736
8737testcase TC_lcs_loc_req_for_active_ms_le_timeout() runs on test_CT {
8738 var MSC_ConnHdlr vc_conn;
8739 var TestHdlrParams pars := f_gen_test_hdlr_pars();
8740
8741 f_init(1, true);
8742 f_sleep(1.0);
8743 vc_conn := f_start_handler(refers(f_tc_lcs_loc_req_for_active_ms_le_timeout), pars);
8744 vc_conn.done;
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01008745 f_shutdown_helper();
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02008746}
8747
8748/* With an active lchan, start a Perform Location Request on the A-interface, but virtual SMLC does not answer with
8749 * BSSMAP-LE Perform Location Response, after sending a BSSLAP TA Request. */
8750private function f_tc_lcs_loc_req_for_active_ms_le_timeout2(charstring id) runs on MSC_ConnHdlr {
8751 f_lcs_loc_req_for_active_ms_le_timeout(true);
8752}
8753
8754testcase TC_lcs_loc_req_for_active_ms_le_timeout2() runs on test_CT {
8755 var MSC_ConnHdlr vc_conn;
8756 var TestHdlrParams pars := f_gen_test_hdlr_pars();
8757
8758 f_init(1, true);
8759 f_sleep(1.0);
8760 vc_conn := f_start_handler(refers(f_tc_lcs_loc_req_for_active_ms_le_timeout2), pars);
8761 vc_conn.done;
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01008762 f_shutdown_helper();
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02008763}
8764
8765/* With *no* active lchan, start a Perform Location Request, expecting that the MS will be Paged. */
8766private function f_tc_lcs_loc_req_for_idle_ms_no_pag_resp(charstring id) runs on MSC_ConnHdlr {
8767 f_sleep(1.0);
8768
8769 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
8770 f_bssap_le_register_imsi(g_pars.imsi, omit);
8771
8772 /* Register to receive the Paging Command */
8773 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
8774 g_chan_nr := new_chan_nr;
8775 f_rslem_register(0, g_chan_nr);
8776
8777 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
8778 valueof(ts_BSSMAP_Perform_Location_Request(ts_BSSMAP_Imsi(g_pars.imsi),
8779 ts_CellId_CGI('001'H, '01'H, 1, 0)))));
8780 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
8781
8782 var PDU_BSSAP_LE plr;
8783 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocReq(BSSMAP_LE_LOC_INFO_CURRENT_GEOGRAPHIC_LOC, ?, ?)) -> value(plr);
8784
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
8788 /* OsmoBSC needs to Page */
8789 var PDU_BSSAP_LE rx_bsslap;
8790 alt {
8791 [] RSL.receive(tr_RSL_PAGING_CMD(tr_MI_IMSI(g_pars.imsi))) {
8792 f_logp(BSCVTY, "got Paging Command");
8793 repeat;
8794 }
8795 [] BSSAP_LE.receive(tr_BSSMAP_LE_ConnInfo(BSSMAP_LE_PROT_BSSLAP, ?)) -> value(rx_bsslap) {
8796 /* MS does not respond to Paging, TA Req runs into timeout. */
8797 f_match_bsslap(rx_bsslap, tr_BSSLAP_Abort(?));
8798 }
8799 }
8800
8801 /* SMLC responds with failure */
8802 BSSAP_LE.send(ts_BSSMAP_LE_PerfLocResp(omit, BSSMAP_LE_LCS_CAUSE_REQUEST_ABORTED));
8803 BSSAP_LE.receive(BSSAP_LE_Conn_Prim:CONN_PRIM_DISC_IND);
8804
8805 /* BSC tells MSC about failure */
8806 BSSAP.receive(tr_BSSMAP_Perform_Location_Response(
8807 locationEstimate := omit, positioningData := omit,
8808 lCS_Cause := tr_BSSMAP_LcsCause(BSSMAP_LCS_CAUSE_REQUEST_ABORTED)));
8809
8810 /* There is no lchan. Still the MSC's job to decide whether to tear down the conn or not. */
8811 f_verify_active_A_conn_and_clear();
8812
8813 f_sleep(2.0);
8814 setverdict(pass);
8815}
8816testcase TC_lcs_loc_req_for_idle_ms_no_pag_resp() runs on test_CT {
8817 var MSC_ConnHdlr vc_conn;
8818 var TestHdlrParams pars := f_gen_test_hdlr_pars();
8819
8820 f_init(1, true);
8821 f_sleep(1.0);
8822
8823 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
8824 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
8825
8826 vc_conn := f_start_handler(refers(f_tc_lcs_loc_req_for_idle_ms_no_pag_resp), pars);
8827 vc_conn.done;
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01008828 f_shutdown_helper();
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02008829}
8830
8831/* During an ongoing Location Request, the MS sends a CM Service Request. Expect the same A-conn to be re-used / taken
8832 * over. */
8833private function f_tc_cm_service_during_lcs_loc_req(charstring id) runs on MSC_ConnHdlr {
8834 f_sleep(1.0);
8835
8836 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
8837 f_bssap_le_register_imsi(g_pars.imsi, omit);
8838
8839 /* Register to receive the Paging Command */
8840 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
8841 g_chan_nr := new_chan_nr;
8842 f_rslem_register(0, g_chan_nr);
8843
8844 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
8845 valueof(ts_BSSMAP_Perform_Location_Request(ts_BSSMAP_Imsi(g_pars.imsi),
8846 ts_CellId_CGI('001'H, '01'H, 1, 0)))));
8847 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
8848
8849 var PDU_BSSAP_LE plr;
8850 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocReq(BSSMAP_LE_LOC_INFO_CURRENT_GEOGRAPHIC_LOC, ?, ?)) -> value(plr);
8851
8852 /* As the A-interface conn was established for LCS, the MS coincidentally decides to issue a CM Service Request
8853 * and establish Layer 3. It should use the existing A-interface conn. */
8854 f_perform_compl_l3(RSL, valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, valueof(ts_MI_IMSI_LV(g_pars.imsi)))),
8855 do_clear := false, expect_bssmap_l3 := true);
8856
8857 /* SMLC wants to ask the TA from the BSC explicitly in a BSSLAP TA Request message */
8858 BSSAP_LE.send(ts_BSSMAP_LE_BSSLAP(ts_BSSLAP_TA_Req));
8859
8860 /* OsmoBSC already has an lchan, no need to Page, just returns the TA */
8861 f_expect_bsslap(tr_BSSLAP_TA_Resp(?, ?));
8862
8863 /* SMLC got the TA from the BSC, now responds with geo information data. */
8864 BSSAP_LE.send(ts_BSSMAP_LE_PerfLocResp(gad_ell_point_unc_circle, omit));
8865 BSSAP_LE.receive(BSSAP_LE_Conn_Prim:CONN_PRIM_DISC_IND);
8866 BSSAP.receive(tr_BSSMAP_Perform_Location_Response(tr_BSSMAP_IE_LocationEstimate(gad_ell_point_unc_circle)));
8867
8868 /* The lchan should still exist, it was from a CM Service Request. */
8869 f_mo_l3_transceive();
8870
8871 f_perform_clear(RSL);
8872
8873 f_sleep(2.0);
8874 setverdict(pass);
8875}
8876testcase TC_cm_service_during_lcs_loc_req() runs on test_CT {
8877 var MSC_ConnHdlr vc_conn;
8878 var TestHdlrParams pars := f_gen_test_hdlr_pars();
8879
8880 f_init(1, true);
8881 f_sleep(1.0);
8882
8883 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
8884 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
8885
8886 vc_conn := f_start_handler(refers(f_tc_cm_service_during_lcs_loc_req), pars);
8887 vc_conn.done;
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01008888 f_shutdown_helper();
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02008889}
8890
8891/* During an ongoing Perform Location Request, do a Handover, an expect a BSSLAP Reset message from the BSC to indicate
8892 * the new lchan after handover. */
8893private function f_tc_ho_during_lcs_loc_req(charstring id) runs on MSC_ConnHdlr {
8894 f_sleep(1.0);
8895
8896 f_establish_fully(omit, omit);
8897 f_bssap_le_register_imsi(g_pars.imsi, omit);
8898
8899 BSSAP.send(valueof(ts_BSSMAP_Perform_Location_Request(ts_BSSMAP_Imsi(g_pars.imsi),
8900 ts_CellId_CGI('262'H, '42'H, 23, 42))));
8901
8902 var PDU_BSSAP_LE plr;
8903 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocReq(BSSMAP_LE_LOC_INFO_CURRENT_GEOGRAPHIC_LOC, ?, ?)) -> value(plr);
8904
8905 /* SMLC ponders the Location Request, in the meantime the BSC decides to handover */
8906 f_bts_0_cfg(BSCVTY, {"neighbor bts 1"});
8907
8908 var HandoverState hs := {
8909 rr_ho_cmpl_seen := false,
8910 handover_done := false,
8911 old_chan_nr := -
8912 };
8913 /* issue hand-over command on VTY */
8914 f_vty_handover(BSCVTY, 0, 0, g_chan_nr, 1);
8915 /* temporarily suspend DChan processing on BTS1 to avoid race with RSLEM_register */
8916 f_rslem_suspend(RSL1_PROC);
8917
8918 /* From the MGW perspective, a handover is is characterized by
8919 * performing one MDCX operation with the MGW. So we expect to see
8920 * one more MDCX during handover. */
8921 g_media.mgcp_conn[0].mdcx_seen_exp := g_media.mgcp_conn[0].crcx_seen_exp + 1;
8922
8923 alt {
8924 [] as_handover(hs);
8925 }
8926
8927 var PDU_BSSAP_LE rx_bsslap;
8928
8929 interleave {
8930 /* Expect the BSC to inform the MSC about the handover */
8931 [] BSSAP.receive(tr_BSSMAP_HandoverPerformed);
8932
8933 /* Expect the BSC to inform the SMLC about the handover */
8934 [] BSSAP_LE.receive(tr_BSSMAP_LE_ConnInfo(BSSMAP_LE_PROT_BSSLAP, ?)) -> value(rx_bsslap) {
8935 f_match_bsslap(rx_bsslap, tr_BSSLAP_Reset(BSSLAP_CAUSE_INTRA_BSS_HO));
8936 }
8937 }
8938
8939 /* SMLC now responds with geo information data. */
8940 BSSAP_LE.send(ts_BSSMAP_LE_PerfLocResp(gad_ell_point_unc_circle, omit));
8941 BSSAP_LE.receive(BSSAP_LE_Conn_Prim:CONN_PRIM_DISC_IND);
8942 BSSAP.receive(tr_BSSMAP_Perform_Location_Response(tr_BSSMAP_IE_LocationEstimate(gad_ell_point_unc_circle)));
8943
8944 /* lchan still active */
8945 f_mo_l3_transceive(RSL1);
8946
8947 /* MSC decides it is done now. */
8948 f_perform_clear(RSL1);
8949
8950 f_sleep(2.0);
8951 setverdict(pass);
8952}
8953testcase TC_ho_during_lcs_loc_req() runs on test_CT {
8954 var MSC_ConnHdlr vc_conn;
8955 var TestHdlrParams pars := f_gen_test_hdlr_pars();
8956
8957 f_init(2, true);
8958 f_sleep(1.0);
8959 vc_conn := f_start_handler(refers(f_tc_ho_during_lcs_loc_req), pars);
8960 vc_conn.done;
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01008961 f_shutdown_helper();
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02008962}
8963
Neels Hofmeyrbf037052020-10-28 22:52:02 +00008964/* Attempt Complete Layer 3 without any MSC available (OS#4832) */
8965private function f_tc_no_msc(charstring id) runs on MSC_ConnHdlr {
8966 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
8967
8968 /* Also disable attach for the single connected MSC */
8969 f_vty_msc_allow_attach(BSCVTY, { false });
8970
8971 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) ));
8972 f_chan_est(g_pars.ra, l3_enc, g_pars.link_id, g_pars.fn);
8973
8974 /* No MSC is found, expecting a proper release on RSL */
8975 interleave {
8976 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_RELEASE)) {
8977 f_logp(BSCVTY, "Got RSL RR Release");
8978 }
8979 [] RSL.receive(tr_RSL_DEACT_SACCH(g_chan_nr)) {
8980 f_logp(BSCVTY, "Got RSL Deact SACCH");
8981 }
8982 [] RSL.receive(tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL)) {
8983 f_logp(BSCVTY, "Got RSL RF Chan Rel, sending Rel Ack");
8984 RSL.send(ts_RSL_RF_CHAN_REL_ACK(g_chan_nr));
8985 }
8986 }
8987 setverdict(pass);
8988}
8989testcase TC_no_msc() runs on test_CT {
8990
8991 f_init(1, true);
8992 f_sleep(1.0);
8993 var MSC_ConnHdlr vc_conn;
8994 var TestHdlrParams pars := f_gen_test_hdlr_pars();
8995
8996 f_ctrs_bsc_init(counternames_bsc_mscpool);
8997
8998 vc_conn := f_start_handler(refers(f_tc_no_msc), pars);
8999 vc_conn.done;
9000
9001 f_ctrs_bsc_add("mscpool:subscr:no_msc");
9002 f_ctrs_bsc_verify();
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01009003 f_shutdown_helper();
Neels Hofmeyrbf037052020-10-28 22:52:02 +00009004}
9005
Harald Welte0ea2d5e2018-04-07 21:40:29 +02009006/* Dyn PDCH todo:
9007 * activate OSMO as TCH/F
9008 * activate OSMO as TCH/H
9009 * does the BSC-located PCU socket get the updated INFO?
9010 * what if no PCU is connected at the time?
9011 * is the info correct on delayed PCU (re)connect?
9012 */
Harald Welte94e0c342018-04-07 11:33:23 +02009013
Neels Hofmeyr87857ec2021-04-25 16:17:47 +00009014private function f_TC_refuse_mode_modif_to_vamos(charstring id) runs on MSC_ConnHdlr {
9015 var PDU_BSSAP ass_cmd := f_gen_ass_req(g_pars.use_osmux);
9016 var template PDU_BSSAP exp_compl := f_gen_exp_compl(g_pars.use_osmux);
9017
9018 /* puzzle together the ASSIGNMENT REQ for given codec[s] */
9019 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
9020 ass_cmd.pdu.bssmap.assignmentRequest.codecList := g_pars.ass_codec_list;
9021 exp_compl.pdu.bssmap.assignmentComplete.speechCodec.codecElements[0] :=
9022 g_pars.ass_codec_list.codecElements[0];
9023 if (isvalue(g_pars.expect_mr_s0_s7)) {
9024 exp_compl.pdu.bssmap.assignmentComplete.speechCodec.codecElements[0].s0_7 :=
9025 g_pars.expect_mr_s0_s7;
9026 }
9027 }
9028 ass_cmd.pdu.bssmap.assignmentRequest.channelType :=
9029 f_BSSMAP_chtype_from_codec(g_pars.ass_codec_list.codecElements[0]);
9030 log("expecting ASS COMPL like this: ", exp_compl);
9031
9032 f_establish_fully(ass_cmd, exp_compl);
9033
Neels Hofmeyr8746b0d2021-06-01 17:25:39 +02009034 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 +00009035
9036 var RSL_Message rsl;
9037
9038 timer T := 5.0;
9039 T.start;
9040 alt {
9041 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr)) -> value rsl {
9042 var PDU_ML3_NW_MS l3 := dec_PDU_ML3_NW_MS(rsl.ies[2].body.l3_info.payload);
9043 log("Rx L3 from net: ", l3);
9044 if (ischosen(l3.msgs.rrm.channelModeModify)) {
9045 setverdict(fail, "Mode Modify to VAMOS succeeded even though BTS does not support VAMOS");
9046 mtc.stop;
9047 }
9048 }
9049 [] RSL.receive(tr_RSL_MODE_MODIFY_REQ(g_chan_nr, ?)) -> value rsl {
9050 setverdict(fail, "Mode Modify to VAMOS succeeded even though BTS does not support VAMOS");
9051 mtc.stop;
9052 }
9053 [] T.timeout {
9054 /* The BTS does not exhibit BTS_FEAT_VAMOS, so no VAMOS related Mode Modify should happen. */
9055 setverdict(pass);
9056 }
9057 }
9058 T.stop;
9059}
9060
9061/* The BSC does *not* indicate BTS_FEAT_VAMOS; make sure that a channel Mode Modify to VAMOS mode is refused by
9062 * osmo-bsc. */
9063testcase TC_refuse_mode_modif_to_vamos() runs on test_CT {
9064 var TestHdlrParams pars := f_gen_test_hdlr_pars();
9065 var MSC_ConnHdlr vc_conn;
9066
9067 f_init(1, true);
9068 f_sleep(1.0);
9069
9070 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
9071 vc_conn := f_start_handler(refers(f_TC_refuse_mode_modif_to_vamos), pars);
9072 vc_conn.done;
9073 f_shutdown_helper();
9074}
9075
9076/* The BSC does *not* indicate BTS_FEAT_VAMOS; make sure that a channel activation to VAMOS mode is refused by osmo-bsc.
9077 */
9078testcase TC_refuse_chan_act_to_vamos() runs on test_CT {
9079 f_init_vty();
9080
9081 f_init(1, false);
9082 f_sleep(1.0);
9083
9084 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 1 sub-slot 0 activate-vamos fr");
9085
9086 var ASP_RSL_Unitdata rx_rsl_ud;
9087 timer T := 5.0;
9088
9089 T.start;
9090 alt {
9091 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(?, IPAC_PROTO_RSL_TRX0)) -> value rx_rsl_ud {
9092 if (rx_rsl_ud.rsl.msg_type == RSL_MT_CHAN_ACTIV) {
9093 T.stop;
9094 setverdict(fail, "CHANnel ACTivate in VAMOS mode succeeded even though BTS does not support VAMOS");
9095 mtc.stop;
9096 }
9097 repeat;
9098 }
9099 [] T.timeout {
9100 /* The BTS does not exhibit BTS_FEAT_VAMOS, so no VAMOS related CHANnel ACTivate should happen. */
9101 setverdict(pass);
9102 }
9103 }
9104}
9105
Neels Hofmeyrd2d9f332021-04-28 22:23:36 +00009106private function f_TC_reassignment_codec(charstring id) runs on MSC_ConnHdlr {
9107 /* First fully set up a speech lchan */
9108 f_TC_assignment_codec(id);
9109
9110 /* Trigger re-assignment to another lchan */
9111 var AssignmentState assignment_st := valueof(ts_AssignmentStateInit);
9112
9113 /* Re-Assignment should tell the MGW endpoint the new lchan's RTP address and port, so expecting to see exactly
9114 * one MDCX on MGCP. */
9115 g_media.mgcp_conn[0].mdcx_seen_exp := g_media.mgcp_conn[0].mdcx_seen_exp + 1;
9116
9117 /* The new lchan will see all-new IPAC_CRCX and IPAC_MDCX messages telling the BTS the same RTP address and port
9118 * as the old lchan used. */
9119 g_media.bts.ipa_crcx_seen := false;
9120 g_media.bts.ipa_mdcx_seen := false;
9121
9122 /* Send different BTS side RTP port number for the new lchan */
9123 g_media.bts.bts.port_nr := 4223;
9124
9125 f_rslem_register(0, valueof(ts_RslChanNr_Bm(2))); /* <-- FIXME: can we somehow infer the timeslot that will be used? */
9126
9127 /* Trigger re-assignment. */
9128 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot " & int2str(g_chan_nr.tn) & " sub-slot 0 assignment");
9129
9130 timer T := 5.0;
9131 T.start;
9132 alt {
9133 [] as_assignment(assignment_st);
9134 [] as_Media();
9135 [] T.timeout {
9136 break;
9137 }
9138 }
9139
9140 if (not assignment_st.assignment_done) {
9141 setverdict(fail, "Assignment did not complete");
9142 mtc.stop;
9143 }
9144
9145 f_check_mgcp_expectations()
9146 setverdict(pass);
9147
9148 f_sleep(2.0);
9149 log("show lchan summary: ", f_vty_transceive_ret(BSCVTY, "show lchan summary"));
9150
9151 /* Instruct BSC to clear channel */
9152 var BssmapCause cause := 0;
9153 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
9154 interleave {
9155 [] MGCP.receive(tr_DLCX) {}
9156 [] MGCP.receive(tr_DLCX) {}
9157 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_RELEASE)) {}
9158 [] RSL.receive(tr_RSL_DEACT_SACCH(g_chan_nr)) {}
9159 [] RSL.receive(tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL)) {
9160 RSL.send(ts_RSL_RF_CHAN_REL_ACK(g_chan_nr));
9161 }
9162 [] BSSAP.receive(tr_BSSMAP_ClearComplete) {
9163 BSSAP.send(RAN_Conn_Prim:MSC_CONN_PRIM_DISC_REQ);
9164 }
9165 }
9166
9167 f_sleep(0.5);
9168}
9169
9170testcase TC_reassignment_fr() runs on test_CT {
9171 var TestHdlrParams pars := f_gen_test_hdlr_pars();
9172 var MSC_ConnHdlr vc_conn;
9173
9174 f_init(1, true);
9175 f_sleep(1.0);
9176
9177 f_ctrs_bsc_and_bts_init();
9178
9179 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
9180 vc_conn := f_start_handler(refers(f_TC_reassignment_codec), pars);
9181 vc_conn.done;
9182
9183 /* from f_establish_fully() */
9184 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
9185 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
9186 /* from re-assignment */
9187 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
9188 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
9189 f_ctrs_bsc_and_bts_verify();
9190 f_shutdown_helper();
9191}
9192
Neels Hofmeyr87857ec2021-04-25 16:17:47 +00009193
Harald Welte28d943e2017-11-25 15:00:50 +01009194control {
Harald Welte898113b2018-01-31 18:32:21 +01009195 /* CTRL interface testing */
Harald Welte4003d112017-12-09 22:35:39 +01009196 execute( TC_ctrl_msc_connection_status() );
Stefan Sperlingb041b3d2018-01-03 17:14:55 +01009197 execute( TC_ctrl_msc0_connection_status() );
Harald Welte96c94412017-12-09 03:12:45 +01009198 execute( TC_ctrl() );
Neels Hofmeyrf246a922020-05-13 02:27:10 +02009199 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_SCCPlite_SERVER) {
Pau Espin Pedrol5a2d7432019-06-07 19:43:45 +02009200 execute( TC_ctrl_location() );
9201 }
Harald Welte898113b2018-01-31 18:32:21 +01009202
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +02009203 execute( TC_si_default() );
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02009204 execute( TC_si2quater_2_earfcns() );
9205 execute( TC_si2quater_3_earfcns() );
9206 execute( TC_si2quater_4_earfcns() );
9207 execute( TC_si2quater_5_earfcns() );
9208 execute( TC_si2quater_6_earfcns() );
Neels Hofmeyrad132f22020-07-08 02:20:16 +02009209 execute( TC_si2quater_12_earfcns() );
9210 execute( TC_si2quater_23_earfcns() );
9211 execute( TC_si2quater_32_earfcns() );
9212 execute( TC_si2quater_33_earfcns() );
9213 execute( TC_si2quater_42_earfcns() );
9214 execute( TC_si2quater_48_earfcns() );
9215 execute( TC_si2quater_49_earfcns() );
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02009216 execute( TC_si_acc_rotate() );
Alexander Couzens4ad3a352020-09-10 22:29:12 +02009217 execute( TC_si_acc_ramp_rotate() );
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +02009218
Harald Welte898113b2018-01-31 18:32:21 +01009219 /* RSL DCHAN Channel ACtivation / Deactivation */
Harald Welteae026692017-12-09 01:03:01 +01009220 execute( TC_chan_act_noreply() );
Harald Welte4003d112017-12-09 22:35:39 +01009221 execute( TC_chan_act_counter() );
Harald Welteae026692017-12-09 01:03:01 +01009222 execute( TC_chan_act_ack_noest() );
Philipp Maier9c60a622020-07-09 15:08:46 +02009223 execute( TC_chan_act_ack_noest_emerg() );
Philipp Maier606f07d2020-08-12 17:21:58 +02009224 execute( TC_chan_rqd_emerg_deny() );
Harald Welteae026692017-12-09 01:03:01 +01009225 execute( TC_chan_act_ack_est_ind_noreply() );
9226 execute( TC_chan_act_ack_est_ind_refused() );
Harald Welte618ef642017-12-14 14:58:20 +01009227 execute( TC_chan_act_nack() );
Harald Welte799c97b2017-12-14 17:50:30 +01009228 execute( TC_chan_exhaustion() );
Vadim Yanitskiy1ff1fdf2018-11-27 01:32:57 +07009229 execute( TC_chan_deact_silence() );
Harald Welte4003d112017-12-09 22:35:39 +01009230 execute( TC_chan_rel_rll_rel_ind() );
9231 execute( TC_chan_rel_conn_fail() );
9232 execute( TC_chan_rel_hard_clear() );
Pau Espin Pedrol841b90d2021-04-15 16:42:52 +02009233 execute( TC_chan_rel_last_eutran_plmn_hard_clear_no_csfb() );
9234 execute( TC_chan_rel_last_eutran_plmn_hard_clear_csfb() );
Harald Welte99787102019-02-04 10:41:36 +01009235 execute( TC_chan_rel_hard_clear_csfb() );
Harald Welted8c36cd2017-12-09 23:05:31 +01009236 execute( TC_chan_rel_hard_rlsd() );
Harald Welte550daf92018-06-11 19:22:13 +02009237 execute( TC_chan_rel_hard_rlsd_ms_dead() );
Harald Welte85804d42017-12-10 14:11:58 +01009238 execute( TC_chan_rel_a_reset() );
Pau Espin Pedrolc675b612020-01-09 19:55:40 +01009239 execute( TC_chan_rel_sccp_tiar_timeout() );
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02009240 execute( TC_chan_rel_rr_cause() );
Harald Welte6f521d82017-12-11 19:52:02 +01009241
Harald Weltecfe2c962017-12-15 12:09:32 +01009242 execute( TC_outbound_connect() );
Harald Welte898113b2018-01-31 18:32:21 +01009243
9244 /* Assignment related */
Harald Welte16a4adf2017-12-14 18:54:01 +01009245 execute( TC_assignment_cic_only() );
Harald Welte235ebf12017-12-15 14:18:16 +01009246 execute( TC_assignment_csd() );
9247 execute( TC_assignment_ctm() );
9248 execute( TC_assignment_sign() );
Pau Espin Pedrol07866632020-09-03 19:10:55 +02009249 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
9250 execute( TC_assignment_aoip_tla_v6() );
9251 }
Harald Welte235ebf12017-12-15 14:18:16 +01009252 execute( TC_assignment_fr_a5_0() );
9253 execute( TC_assignment_fr_a5_1() );
Neels Hofmeyrf246a922020-05-13 02:27:10 +02009254 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
Harald Welte8f67d1d2018-05-25 20:38:42 +02009255 execute( TC_assignment_fr_a5_1_codec_missing() );
9256 }
Harald Welte235ebf12017-12-15 14:18:16 +01009257 execute( TC_assignment_fr_a5_3() );
Neels Hofmeyr0d8ec532021-06-11 00:09:48 +02009258 execute( TC_assignment_fr_a5_4() );
Neels Hofmeyr0faeb7a2021-06-10 23:59:35 +02009259 execute( TC_assignment_fr_a5_4_fail() );
Neels Hofmeyr04d6e6a2021-06-11 00:10:02 +02009260 execute( TC_assignment_fr_a5_not_sup() );
Harald Welte3c86ea02018-05-10 22:28:05 +02009261 execute( TC_ciph_mode_a5_0() );
9262 execute( TC_ciph_mode_a5_1() );
Oliver Smith50b98122021-07-09 15:00:28 +02009263 execute( TC_ciph_mode_a5_2_0() );
Oliver Smith1dff88d2021-07-09 08:45:51 +02009264 execute( TC_ciph_mode_a5_2_1() );
Harald Welte3c86ea02018-05-10 22:28:05 +02009265 execute( TC_ciph_mode_a5_3() );
Neels Hofmeyr81ad27f2021-06-11 00:09:40 +02009266 execute( TC_ciph_mode_a5_4() );
Harald Welte16a4adf2017-12-14 18:54:01 +01009267
Harald Welte60aa5762018-03-21 19:33:13 +01009268 execute( TC_assignment_codec_fr() );
Neels Hofmeyr559d5d02021-04-16 16:50:49 +02009269 execute( TC_assignment_codec_fr_by_mode_modify() );
Harald Welte60aa5762018-03-21 19:33:13 +01009270 execute( TC_assignment_codec_hr() );
9271 execute( TC_assignment_codec_efr() );
9272 execute( TC_assignment_codec_amr_f() );
9273 execute( TC_assignment_codec_amr_h() );
Philipp Maier8a581d22019-03-26 18:32:48 +01009274
Neels Hofmeyrf246a922020-05-13 02:27:10 +02009275 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
Philipp Maier8a581d22019-03-26 18:32:48 +01009276 execute( TC_assignment_codec_amr_f_S1() );
9277 execute( TC_assignment_codec_amr_h_S1() );
9278 execute( TC_assignment_codec_amr_f_S124() );
9279 execute( TC_assignment_codec_amr_h_S124() );
9280 execute( TC_assignment_codec_amr_f_S0() );
9281 execute( TC_assignment_codec_amr_f_S02() );
9282 execute( TC_assignment_codec_amr_f_S024() );
9283 execute( TC_assignment_codec_amr_f_S0247() );
9284 execute( TC_assignment_codec_amr_h_S0() );
9285 execute( TC_assignment_codec_amr_h_S02() );
9286 execute( TC_assignment_codec_amr_h_S024() );
9287 execute( TC_assignment_codec_amr_h_S0247() );
9288 execute( TC_assignment_codec_amr_f_S01234567() );
9289 execute( TC_assignment_codec_amr_f_S0234567() );
9290 execute( TC_assignment_codec_amr_f_zero() );
9291 execute( TC_assignment_codec_amr_f_unsupp() );
9292 execute( TC_assignment_codec_amr_h_S7() );
Neels Hofmeyr21863562020-11-26 00:34:33 +00009293 execute( TC_assignment_codec_amr_f_start_mode_auto() );
9294 execute( TC_assignment_codec_amr_h_start_mode_auto() );
Neels Hofmeyr3eb94562020-11-26 02:40:26 +00009295 execute( TC_assignment_codec_amr_f_start_mode_4() );
9296 execute( TC_assignment_codec_amr_h_start_mode_4() );
Neels Hofmeyr454d7922020-11-26 02:24:57 +00009297 execute( TC_assignment_codec_amr_startmode_cruft() );
Philipp Maier8a581d22019-03-26 18:32:48 +01009298 }
Harald Welte60aa5762018-03-21 19:33:13 +01009299
Philipp Maierac09bfc2019-01-08 13:41:39 +01009300 execute( TC_assignment_codec_fr_exhausted_req_hr() );
9301 execute( TC_assignment_codec_fr_exhausted_req_fr() );
9302 execute( TC_assignment_codec_fr_exhausted_req_fr_hr() );
9303 execute( TC_assignment_codec_fr_exhausted_req_hr_fr() );
9304 execute( TC_assignment_codec_hr_exhausted_req_fr() );
9305 execute( TC_assignment_codec_hr_exhausted_req_hr() );
9306 execute( TC_assignment_codec_hr_exhausted_req_hr_fr() );
9307 execute( TC_assignment_codec_hr_exhausted_req_fr_hr() );
9308 execute( TC_assignment_codec_req_hr_fr() );
9309 execute( TC_assignment_codec_req_fr_hr() );
9310
Pau Espin Pedrol58cf6822019-05-28 18:11:33 +02009311 if (mp_enable_osmux_test) {
9312 execute( TC_assignment_osmux() );
9313 }
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02009314
Harald Welte898113b2018-01-31 18:32:21 +01009315 /* RLL Establish Indication on inactive DCHAN / SAPI */
Harald Welte5cd20ed2017-12-13 21:03:20 +01009316 execute( TC_rll_est_ind_inact_lchan() );
9317 execute( TC_rll_est_ind_inval_sapi1() );
9318 execute( TC_rll_est_ind_inval_sapi3() );
9319 execute( TC_rll_est_ind_inval_sacch() );
9320
Vadim Yanitskiy61f784a2020-10-01 21:12:19 +07009321 /* DLCI / RSL Link ID conversion for MO/MT messages on SAPI0/SAPI3 */
9322 execute( TC_tch_dlci_link_id_sapi() );
9323
Vadim Yanitskiy6ef5dfa2020-08-28 18:04:41 +07009324 /* SAPI N Reject triggered by RLL establishment failures */
9325 execute( TC_rll_rel_ind_sapi_n_reject() );
9326 execute( TC_rll_err_ind_sapi_n_reject() );
9327 execute( TC_rll_timeout_sapi_n_reject() );
9328
Harald Welte898113b2018-01-31 18:32:21 +01009329 /* Paging related tests */
Harald Welte6f521d82017-12-11 19:52:02 +01009330 execute( TC_paging_imsi_nochan() );
9331 execute( TC_paging_tmsi_nochan() );
9332 execute( TC_paging_tmsi_any() );
9333 execute( TC_paging_tmsi_sdcch() );
9334 execute( TC_paging_tmsi_tch_f() );
9335 execute( TC_paging_tmsi_tch_hf() );
9336 execute( TC_paging_imsi_nochan_cgi() );
9337 execute( TC_paging_imsi_nochan_lac_ci() );
9338 execute( TC_paging_imsi_nochan_ci() );
9339 execute( TC_paging_imsi_nochan_lai() );
9340 execute( TC_paging_imsi_nochan_lac() );
9341 execute( TC_paging_imsi_nochan_all() );
Harald Welte751d3eb2018-01-31 15:51:06 +01009342 execute( TC_paging_imsi_nochan_plmn_lac_rnc() );
9343 execute( TC_paging_imsi_nochan_rnc() );
9344 execute( TC_paging_imsi_nochan_lac_rnc() );
9345 execute( TC_paging_imsi_nochan_lacs() );
9346 execute( TC_paging_imsi_nochan_lacs_empty() );
Stefan Sperling049a86e2018-03-20 15:51:00 +01009347 execute( TC_paging_imsi_nochan_cgi_unknown_cid() );
Harald Welte10985002017-12-12 09:29:15 +01009348 execute( TC_paging_imsi_a_reset() );
Harald Weltee65d40e2017-12-13 00:09:06 +01009349 execute( TC_paging_imsi_load() );
Philipp Maier779a7922018-02-16 11:00:37 +01009350 execute( TC_paging_counter() );
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01009351 execute( TC_paging_resp_unsol() );
Harald Welte4e9b9cc2017-12-14 18:31:02 +01009352
9353 execute( TC_rsl_drop_counter() );
Stefan Sperling830dc9d2018-02-12 21:08:28 +01009354 execute( TC_rsl_unknown_unit_id() );
9355
9356 execute( TC_oml_unknown_unit_id() );
Harald Welte898113b2018-01-31 18:32:21 +01009357
9358 execute( TC_classmark() );
Harald Welteeddf0e92020-06-21 19:42:15 +02009359 execute( TC_common_id() );
Harald Welte898113b2018-01-31 18:32:21 +01009360 execute( TC_unsol_ass_fail() );
Harald Welteea99a002018-01-31 20:46:43 +01009361 execute( TC_unsol_ass_compl() );
Harald Weltefbf9b5e2018-01-31 20:41:23 +01009362 execute( TC_unsol_ho_fail() );
Harald Weltee3bd6582018-01-31 22:51:25 +01009363 execute( TC_err_82_short_msg() );
Harald Weltee9e02e42018-01-31 23:36:25 +01009364 execute( TC_err_84_unknown_msg() );
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01009365
Harald Welte261af4b2018-02-12 21:20:39 +01009366 execute( TC_ho_int() );
Neels Hofmeyraf88d9d2021-06-21 02:14:27 +02009367 execute( TC_ho_int_a5_0() );
9368 execute( TC_ho_int_a5_1() );
9369 execute( TC_ho_int_a5_3() );
9370 execute( TC_ho_int_a5_4() );
Neels Hofmeyr5f144212020-11-03 15:41:58 +00009371 execute( TC_ho_int_radio_link_failure() );
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01009372
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01009373 execute( TC_ho_out_of_this_bsc() );
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02009374 execute( TC_ho_out_fail_no_msc_response() );
9375 execute( TC_ho_out_fail_rr_ho_failure() );
Neels Hofmeyrd8a602c2019-07-09 19:46:01 +02009376 execute( TC_ho_out_fail_no_result_after_ho_cmd() );
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01009377
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01009378 execute( TC_ho_into_this_bsc() );
Neels Hofmeyr8ebf19c2021-06-21 05:24:01 +02009379 execute( TC_ho_into_this_bsc_a5_0() );
9380 execute( TC_ho_into_this_bsc_a5_1() );
9381 execute( TC_ho_into_this_bsc_a5_3() );
9382 execute( TC_ho_into_this_bsc_a5_4() );
Pau Espin Pedrol07866632020-09-03 19:10:55 +02009383 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
9384 execute( TC_ho_into_this_bsc_tla_v6() );
9385 }
Pau Espin Pedrolc08d5522021-04-16 15:40:38 +02009386 execute( TC_srvcc_eutran_to_geran() );
Pau Espin Pedrol35801c32021-04-19 13:03:20 +02009387 execute( TC_srvcc_eutran_to_geran_ho_out() );
Pau Espin Pedrol9ae36d52021-06-15 17:29:43 +02009388 execute( TC_srvcc_eutran_to_geran_forbid_fast_return() );
9389 execute( TC_srvcc_eutran_to_geran_ho_out_forbid_fast_return() );
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01009390 execute( TC_ho_in_fail_msc_clears() );
9391 execute( TC_ho_in_fail_msc_clears_after_ho_detect() );
9392 execute( TC_ho_in_fail_no_detect() );
9393 execute( TC_ho_in_fail_no_detect2() );
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01009394
Neels Hofmeyr91401012019-07-11 00:42:35 +02009395 execute( TC_ho_neighbor_config_1() );
9396 execute( TC_ho_neighbor_config_2() );
9397 execute( TC_ho_neighbor_config_3() );
9398 execute( TC_ho_neighbor_config_4() );
9399 execute( TC_ho_neighbor_config_5() );
9400 execute( TC_ho_neighbor_config_6() );
9401 execute( TC_ho_neighbor_config_7() );
9402
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01009403 execute( TC_bssap_rlsd_does_not_cause_bssmap_reset() );
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01009404 execute( TC_bssmap_clear_does_not_cause_bssmap_reset() );
Neels Hofmeyrfd445c32018-03-09 15:39:31 +01009405 execute( TC_ms_rel_ind_does_not_cause_bssmap_reset() );
Harald Welte94e0c342018-04-07 11:33:23 +02009406
9407 execute( TC_dyn_pdch_ipa_act_deact() );
9408 execute( TC_dyn_pdch_ipa_act_nack() );
9409 execute( TC_dyn_pdch_osmo_act_deact() );
9410 execute( TC_dyn_pdch_osmo_act_nack() );
Pau Espin Pedrol5b381082021-06-28 17:14:03 +02009411 execute( TC_dyn_ts_sdcch8_act_deact() );
Pau Espin Pedrolcdf26142021-06-28 17:14:03 +02009412 execute( TC_dyn_ts_sdcch8_act_nack() );
Harald Welte99f3ca02018-06-14 13:40:29 +02009413
Stefan Sperling0796a822018-10-05 13:01:39 +02009414 execute( TC_chopped_ipa_ping() );
Stefan Sperlingaa1e60f2018-10-15 16:34:07 +02009415 execute( TC_chopped_ipa_payload() );
Stefan Sperling0796a822018-10-05 13:01:39 +02009416
Pau Espin Pedrol8f773632019-11-05 11:46:53 +01009417 /* Power control related */
9418 execute( TC_assignment_verify_ms_power_params_ie() );
Vadim Yanitskiy4b233042021-06-30 00:58:43 +02009419 execute( TC_c0_power_red_mode() );
Neels Hofmeyr4f118412020-06-04 15:25:10 +02009420
9421 /* MSC pooling */
9422 /* FIXME: in SCCPlite, indicating how many MSCs should be connected does currently not work. Since
9423 * RESET->RESET-ACK is unconditionally negotiated for all configured MSCs, they always all appear as connected
9424 * to osmo-bsc. The MSC pooling tests however require disconnecting selected MSCs, and hence don't work out as
9425 * intended on SCCPlite. So for now, run these only for SCCP/M3UA. */
9426 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
9427 execute( TC_mscpool_L3Compl_on_1_msc() );
9428 execute( TC_mscpool_L3Complete_by_imsi_round_robin() );
9429 execute( TC_mscpool_LU_by_tmsi_null_nri_0_round_robin() );
9430 execute( TC_mscpool_LU_by_tmsi_null_nri_1_round_robin() );
9431 execute( TC_mscpool_L3Complete_by_tmsi_unassigned_nri_round_robin() );
9432 execute( TC_mscpool_L3Complete_by_tmsi_valid_nri_msc_not_connected_round_robin() );
9433 execute( TC_mscpool_L3Complete_by_tmsi_valid_nri_1() );
9434 execute( TC_mscpool_L3Complete_by_tmsi_valid_nri_2() );
9435 execute( TC_mscpool_LU_by_tmsi_from_other_PLMN() );
9436 execute( TC_mscpool_paging_and_response_imsi() );
9437 execute( TC_mscpool_paging_and_response_tmsi() );
9438 execute( TC_mscpool_no_allow_attach_round_robin() );
9439 execute( TC_mscpool_no_allow_attach_valid_nri() );
9440 }
9441
Harald Welte99f3ca02018-06-14 13:40:29 +02009442 /* at bottom as they might crash OsmoBSC before OS#3182 is fixed */
9443 execute( TC_early_conn_fail() );
9444 execute( TC_late_conn_fail() );
9445
Philipp Maier783681c2020-07-16 16:47:06 +02009446 /* Emergency call handling (deny / allow) */
9447 execute( TC_assignment_emerg_setup_allow() );
9448 execute( TC_assignment_emerg_setup_deny_msc() );
9449 execute( TC_assignment_emerg_setup_deny_bts() );
Philipp Maier82812002020-08-13 18:48:27 +02009450 execute( TC_emerg_premption() );
9451
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07009452 /* Frequency hopping parameters handling */
9453 execute( TC_fh_params_chan_activ() );
9454 execute( TC_fh_params_imm_ass() );
Vadim Yanitskiyaeb54a22020-09-01 06:25:25 +07009455 execute( TC_fh_params_assignment_cmd() );
Vadim Yanitskiy8f5430d2020-09-02 18:51:38 +07009456 execute( TC_fh_params_handover_cmd() );
Vadim Yanitskiyca974032020-09-01 07:20:39 +07009457 execute( TC_fh_params_si4_cbch() );
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02009458
9459 if (mp_enable_lcs_tests) {
9460 execute( TC_lcs_loc_req_for_active_ms() );
9461 execute( TC_lcs_loc_req_for_active_ms_ta_req() );
9462 execute( TC_lcs_loc_req_for_idle_ms() );
9463 execute( TC_lcs_loc_req_no_subscriber() );
9464 execute( TC_lcs_loc_req_for_active_ms_le_timeout() );
9465 execute( TC_lcs_loc_req_for_active_ms_le_timeout2() );
9466 execute( TC_lcs_loc_req_for_idle_ms_no_pag_resp() );
9467 execute( TC_cm_service_during_lcs_loc_req() );
9468 execute( TC_ho_during_lcs_loc_req() );
9469 }
Neels Hofmeyrbf037052020-10-28 22:52:02 +00009470
9471 execute( TC_no_msc() );
Neels Hofmeyr87857ec2021-04-25 16:17:47 +00009472
9473 execute( TC_refuse_chan_act_to_vamos() );
9474 execute( TC_refuse_mode_modif_to_vamos() );
Neels Hofmeyrd2d9f332021-04-28 22:23:36 +00009475
9476 execute( TC_reassignment_fr() );
Harald Welte28d943e2017-11-25 15:00:50 +01009477}
9478
9479}