blob: 340d766138a83430ff55b93e3eac3caec1a7bfbb [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",
1510 template (omit) BSSMAP_oldToNewBSSIEs oldToNewBSSIEs := omit) return PDU_BSSAP {
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01001511 var PDU_BSSAP ho_req;
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001512 if (mp_bssap_cfg[bssap_idx].transport == BSSAP_TRANSPORT_AoIP) {
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01001513 var BSSMAP_IE_AoIP_TransportLayerAddress tla :=
Pau Espin Pedrol07866632020-09-03 19:10:55 +02001514 valueof(f_ts_BSSMAP_IE_AoIP_TLA(aoip_tla, 2342));
Pau Espin Pedrolc08d5522021-04-16 15:40:38 +02001515 ho_req := valueof(ts_BSSMAP_HandoverRequest(omit, tla, oldToNewBSSIEs := oldToNewBSSIEs));
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01001516 } else {
1517 var BSSMAP_IE_CircuitIdentityCode cic := valueof(ts_BSSMAP_IE_CIC(0,1));
Pau Espin Pedrolc08d5522021-04-16 15:40:38 +02001518 ho_req := valueof(ts_BSSMAP_HandoverRequest(cic, omit, oldToNewBSSIEs := oldToNewBSSIEs));
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01001519 }
1520 return ho_req;
1521}
1522
Harald Welteed848512018-05-24 22:27:58 +02001523/* generate an assignment complete template for either AoIP or SCCPlite */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001524function f_gen_exp_compl(boolean expect_osmux := false, integer bssap_idx := 0) return template PDU_BSSAP {
Harald Welteed848512018-05-24 22:27:58 +02001525 var template PDU_BSSAP exp_compl;
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02001526 var BSSMAP_IE_Osmo_OsmuxCID osmux_cid := valueof(ts_OsmuxCID(0));
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001527 if (mp_bssap_cfg[bssap_idx].transport == BSSAP_TRANSPORT_AoIP) {
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02001528 if (expect_osmux) {
1529 exp_compl := tr_BSSMAP_AssignmentComplete(omit, ?, osmux_cid);
1530 } else {
1531 exp_compl := tr_BSSMAP_AssignmentComplete(omit, ?, omit);
1532 }
Harald Welteed848512018-05-24 22:27:58 +02001533 } else {
1534 /* CIC is optional "*" as the MSC allocated it */
Pau Espin Pedrol096d73d2019-06-06 12:49:17 +02001535 exp_compl := tr_BSSMAP_AssignmentComplete(*, omit);
Harald Welteed848512018-05-24 22:27:58 +02001536 }
1537 return exp_compl;
1538}
1539
Harald Welte235ebf12017-12-15 14:18:16 +01001540/* Run everything required up to sending a caller-specified assignment command and expect response */
1541function f_assignment_exp(PDU_BSSAP ass_cmd, template PDU_BSSAP exp, charstring fail_text)
1542runs on test_CT {
1543 var BSSAP_N_CONNECT_ind rx_c_ind;
1544 var RSL_Message rx_rsl;
1545 var DchanTuple dt;
1546
Harald Welte89d42e82017-12-17 16:42:41 +01001547 f_init(1);
Harald Welte235ebf12017-12-15 14:18:16 +01001548
1549 dt := f_est_dchan('23'O, 23, '00000000'O);
1550 /* send assignment without AoIP IEs */
1551 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ass_cmd));
1552 alt {
1553 [] BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_AssignmentComplete)) {
1554 if (ischosen(exp.pdu.bssmap.assignmentComplete)) {
1555 setverdict(pass);
1556 } else {
1557 setverdict(fail, fail_text);
1558 }
1559 }
1560 [] BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_AssignmentFail)) {
1561 if (ischosen(exp.pdu.bssmap.assignmentFailure)) {
1562 setverdict(pass);
1563 } else {
1564 setverdict(fail, fail_text);
1565 }
1566 }
1567 [] BSSAP.receive { repeat; }
1568 }
1569}
1570testcase TC_assignment_csd() runs on test_CT {
1571 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
Harald Welteed848512018-05-24 22:27:58 +02001572 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte235ebf12017-12-15 14:18:16 +01001573 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeCSD);
1574 //exp_fail.pdu.bssmap.assignmentFailure.cause.causeValue := int2bit(enum2int(GSM0808_CAUSE_REQ_CODEC_TYPE_OR_CONFIG_UNAVAIL), 7);
1575 f_assignment_exp(ass_cmd, exp_fail, "BSC accepted Assignment for CSD");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001576 f_shutdown_helper();
Harald Welte235ebf12017-12-15 14:18:16 +01001577}
1578
1579testcase TC_assignment_ctm() runs on test_CT {
1580 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
Harald Welteed848512018-05-24 22:27:58 +02001581 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte235ebf12017-12-15 14:18:16 +01001582 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeCTM);
1583 //exp_fail.pdu.bssmap.assignmentFailure.cause.causeValue := int2bit(enum2int(GSM0808_CAUSE_REQ_CODEC_TYPE_OR_CONFIG_UNAVAIL), 7);
1584 f_assignment_exp(ass_cmd, exp_fail, "BSC accepted Assignment for Speech+CTM");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001585 f_shutdown_helper();
Harald Welte235ebf12017-12-15 14:18:16 +01001586}
1587
Harald Welte4003d112017-12-09 22:35:39 +01001588type record DchanTuple {
1589 integer sccp_conn_id,
1590 RslChannelNr rsl_chan_nr
Harald Weltea5d2ab22017-12-09 14:21:42 +01001591}
1592
Harald Welted6939652017-12-13 21:02:46 +01001593/* Send CHAN RQD and wait for allocation; acknowledge it */
1594private function f_chreq_act_ack(OCT1 ra := '23'O, GsmFrameNumber fn := 23)
1595runs on test_CT return RslChannelNr {
1596 var RSL_Message rx_rsl;
1597 f_ipa_tx(0, ts_RSL_CHAN_RQD(ra, fn));
1598 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
1599 var RslChannelNr chan_nr := rx_rsl.ies[0].body.chan_nr;
1600 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, fn+10));
Daniel Willmannf4ac4ce2018-08-02 14:06:30 +02001601 rx_rsl := f_exp_ipa_rx(0, tr_RSL_IMM_ASSIGN(0));
Harald Welted6939652017-12-13 21:02:46 +01001602 return chan_nr;
1603}
1604
Harald Welte4003d112017-12-09 22:35:39 +01001605/* helper function to establish a dedicated channel via BTS and MSC */
1606function f_est_dchan(OCT1 ra, GsmFrameNumber fn, octetstring l3)
1607runs on test_CT return DchanTuple {
1608 var BSSAP_N_CONNECT_ind rx_c_ind;
Harald Welte4003d112017-12-09 22:35:39 +01001609 var DchanTuple dt;
Harald Weltea5d2ab22017-12-09 14:21:42 +01001610
Harald Welte4003d112017-12-09 22:35:39 +01001611 /* Send CHAN RQD and wait for allocation; acknowledge it */
Harald Welted6939652017-12-13 21:02:46 +01001612 dt.rsl_chan_nr := f_chreq_act_ack(ra, fn);
Harald Welte4003d112017-12-09 22:35:39 +01001613
1614 f_ipa_tx(0, ts_RSL_EST_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
1615
1616 BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) -> value rx_c_ind;
1617 dt.sccp_conn_id := rx_c_ind.connectionId;
1618 BSSAP.send(ts_BSSAP_CONNECT_res(dt.sccp_conn_id));
1619
1620 return dt;
Harald Weltea5d2ab22017-12-09 14:21:42 +01001621}
1622
Harald Welte641fcbe2018-06-14 10:58:35 +02001623/* expect RF CAN REL from BTS, acknowledge it and clear the MSC side */
1624private function f_exp_chan_rel_and_clear(DchanTuple dt, integer bts_nr := 0) runs on test_CT {
1625 var RSL_Message rx_rsl;
1626 /* expect BSC to disable the channel */
1627 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), T3101_MAX);
1628 /* respond with CHAN REL ACK */
1629 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(dt.rsl_chan_nr));
1630
1631 /* expect Clear Complete from BSC */
1632 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete));
1633
1634 /* MSC disconnects as instructed. */
1635 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
1636}
1637
Harald Welte4003d112017-12-09 22:35:39 +01001638/* Test behavior of channel release after unilateral RLL REL IND (DISC from MS) */
1639testcase TC_chan_rel_rll_rel_ind() runs on test_CT {
Neels Hofmeyr27f64362018-03-12 01:44:00 +01001640 var BSSAP_N_DATA_ind rx_di;
Harald Welte4003d112017-12-09 22:35:39 +01001641 var DchanTuple dt;
Harald Welte96c94412017-12-09 03:12:45 +01001642
Harald Welte89d42e82017-12-17 16:42:41 +01001643 f_init(1);
Harald Welte96c94412017-12-09 03:12:45 +01001644
Harald Welte4003d112017-12-09 22:35:39 +01001645 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1646
1647 /* simulate RLL REL IND */
1648 f_ipa_tx(0, ts_RSL_REL_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0))));
1649
Neels Hofmeyr27f64362018-03-12 01:44:00 +01001650 /* expect Clear Request on MSC side */
1651 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearRequest)) -> value rx_di;
1652
1653 /* Instruct BSC to clear channel */
1654 var BssmapCause cause := bit2int(rx_di.userData.pdu.bssmap.clearRequest.cause.causeValue);
1655 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
1656
Harald Welte4003d112017-12-09 22:35:39 +01001657 /* expect BSC to disable the channel */
Harald Welte641fcbe2018-06-14 10:58:35 +02001658 f_exp_chan_rel_and_clear(dt, 0);
Neels Hofmeyr27f64362018-03-12 01:44:00 +01001659
1660 /* wait for SCCP emulation to do its job */
1661 f_sleep(1.0);
Harald Welte4003d112017-12-09 22:35:39 +01001662
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001663 f_shutdown_helper();
Harald Welte4003d112017-12-09 22:35:39 +01001664}
1665
1666/* Test behavior of channel release after CONN FAIL IND from BTS */
1667testcase TC_chan_rel_conn_fail() runs on test_CT {
1668 var BSSAP_N_DATA_ind rx_di;
Harald Welte4003d112017-12-09 22:35:39 +01001669 var DchanTuple dt;
1670
Harald Welte89d42e82017-12-17 16:42:41 +01001671 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +01001672
1673 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1674
1675 /* simulate CONN FAIL IND */
Harald Weltea8ed9062017-12-14 09:46:01 +01001676 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 +01001677 /* TODO: different cause values? */
1678
Harald Welte4003d112017-12-09 22:35:39 +01001679 /* expect Clear Request from BSC */
1680 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearRequest)) -> value rx_di;
1681
1682 /* Instruct BSC to clear channel */
1683 var BssmapCause cause := bit2int(rx_di.userData.pdu.bssmap.clearRequest.cause.causeValue);
1684 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
1685
Harald Welte6ff76ea2018-01-28 13:08:01 +01001686 /* expect BSC to disable the channel */
Harald Welte641fcbe2018-06-14 10:58:35 +02001687 f_exp_chan_rel_and_clear(dt, 0);
Harald Welte4003d112017-12-09 22:35:39 +01001688
1689 /* wait for SCCP emulation to do its job */
1690 f_sleep(1.0);
1691
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001692 f_shutdown_helper();
Harald Welte4003d112017-12-09 22:35:39 +01001693}
1694
Harald Welte99f3ca02018-06-14 13:40:29 +02001695/* Test behavior of early CONN FAIL IND from BTS (before EST IND!) */
1696/* See also https://www.osmocom.org/issues/3182 */
1697testcase TC_early_conn_fail() runs on test_CT {
1698 var RSL_Message rx_rsl;
1699 var DchanTuple dt;
1700
1701 f_init(1);
1702
1703 /* BTS->BSC: Send CHAN RQD and wait for allocation; acknowledge it */
Harald Weltec46ea3c2020-10-10 18:46:12 +02001704 dt.rsl_chan_nr := f_chreq_act_ack(f_rnd_ra_cs(), 23);
Harald Welte99f3ca02018-06-14 13:40:29 +02001705
1706 /* BTS->BSC: simulate CONN FAIL IND */
1707 f_ipa_tx(0, ts_RSL_CONN_FAIL_IND(dt.rsl_chan_nr, RSL_ERR_RADIO_LINK_FAIL));
1708
1709 /* BTS->BSC: Expect RF channel release from BSC on Abis */
1710 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), 10.0);
1711
1712 /* BTS<-BSC: respond with CHAN REL ACK */
1713 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(dt.rsl_chan_nr));
1714
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001715 f_shutdown_helper();
Harald Welte99f3ca02018-06-14 13:40:29 +02001716}
1717
1718/* Test behavior of late CONN FAIL IND from BTS (ater REL IND!) */
1719/* See also https://www.osmocom.org/issues/3182 */
1720testcase TC_late_conn_fail() runs on test_CT {
1721 var RSL_Message rx_rsl;
1722 var DchanTuple dt;
1723
1724 f_init(1);
1725
1726 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1727
1728 /* BSC<-MSC: Instruct BSC to clear connection */
1729 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(0)));
1730
1731 /* BTS->BSC: expect BSC to deactivate SACCH */
1732 rx_rsl := f_exp_ipa_rx(0, tr_RSL_DEACT_SACCH(dt.rsl_chan_nr));
1733
1734 /* BTS->BSC: simulate a late CONN FAIL IND from BTS */
1735 f_ipa_tx(0, ts_RSL_CONN_FAIL_IND(dt.rsl_chan_nr, RSL_ERR_RADIO_LINK_FAIL));
1736
1737 /* BTS<-BSC: Expect RF channel release from BSC on Abis */
1738 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), 10.0);
1739 /* BTS->BSC: respond with CHAN REL ACK */
1740 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(dt.rsl_chan_nr));
1741
1742 /* BSC->MSC: expect Clear Complete from BSC */
1743 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete));
1744
1745 /* BSC<-MSC: MSC disconnects as requested. */
1746 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
1747
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001748 f_shutdown_helper();
Harald Welte99f3ca02018-06-14 13:40:29 +02001749}
1750
Neels Hofmeyrf44ccd12018-11-05 19:15:23 +01001751function f_expect_chan_rel(integer bts_nr, RslChannelNr rsl_chan_nr,
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001752 boolean expect_deact_sacch := true,
1753 boolean expect_rr_chan_rel := true,
1754 boolean expect_rll_rel_req := true,
Harald Welte99787102019-02-04 10:41:36 +01001755 boolean handle_rll_rel := true,
Pau Espin Pedrol36bd4fa2021-04-15 13:00:24 +02001756 template CellSelIndValue expect_cells := omit,
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02001757 template RR_Cause expect_rr_cause := ?
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001758 ) runs on test_CT {
Harald Welte91d54a52018-01-28 15:35:07 +01001759
1760 var RslLinkId main_dcch := valueof(ts_RslLinkID_DCCH(0));
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001761 var boolean got_deact_sacch := false;
1762 var boolean got_rr_chan_rel := false;
1763 var boolean got_rll_rel_req := false;
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02001764 var ASP_RSL_Unitdata ud;
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02001765 var RSL_IE_Body l3_ie;
1766 var PDU_ML3_NW_MS l3;
1767 var RR_Cause got_cause;
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001768 log("f_expect_chan_rel() expecting: expect_deact_sacch=", expect_deact_sacch, " expect_rr_chan_rel=", expect_rr_chan_rel,
1769 " expect_rll_rel_req=", expect_rll_rel_req);
Harald Welte91d54a52018-01-28 15:35:07 +01001770 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001771 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(tr_RSL_DEACT_SACCH(rsl_chan_nr))) {
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001772 got_deact_sacch := true;
Harald Welte91d54a52018-01-28 15:35:07 +01001773 repeat;
1774 }
Pau Espin Pedrol841b90d2021-04-15 16:42:52 +02001775 [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 +01001776 got_rr_chan_rel := true;
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02001777
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02001778 if (f_rsl_find_ie(ud.rsl, RSL_IE_L3_INFO, l3_ie) == false) {
1779 setverdict(fail, "cannot find L3");
1780 mtc.stop;
1781 }
1782 l3 := dec_PDU_ML3_NW_MS(l3_ie.l3_info.payload);
1783
Pau Espin Pedrol36bd4fa2021-04-15 13:00:24 +02001784 if (not istemplatekind(expect_cells, "omit")) {
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02001785 var CellSelIndValue cells := dec_CellSelIndValue(
1786 l3.msgs.rrm.channelRelease.cellSelectionIndicator.cellSelectionIndicatorValue);
1787
Pau Espin Pedrol36bd4fa2021-04-15 13:00:24 +02001788 log("GOT RR CHANNEL RELEASE WITH CELLS: ", cells);
1789 if (match(cells, expect_cells)) {
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02001790 setverdict(pass);
1791 } else {
Pau Espin Pedrol36bd4fa2021-04-15 13:00:24 +02001792 log("EXPECTED CELLS: ", expect_cells);
1793 setverdict(fail, "Received cells list on RR Channel Release does not match expectations");
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02001794 }
1795 }
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02001796
1797 if (not istemplatekind(expect_rr_cause, "omit")) {
1798 int2enum(oct2int(l3.msgs.rrm.channelRelease.rRCause.valuePart), got_cause);
1799 log("GOT CAUSE CODE: ", l3.msgs.rrm.channelRelease.rRCause.valuePart, " = ", got_cause);
1800 if (match(got_cause, expect_rr_cause)) {
1801 setverdict(pass);
1802 } else {
1803 log("EXPECTED CAUSE CODE: ", expect_rr_cause);
1804 setverdict(fail, "Received RR Channel Release Cause code does not match expectations");
1805 }
1806 }
Harald Welte99787102019-02-04 10:41:36 +01001807 repeat;
1808 }
Pau Espin Pedrol841b90d2021-04-15 16:42:52 +02001809 [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 +01001810 got_rr_chan_rel := true;
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02001811
1812 if (not istemplatekind(expect_rr_cause, "omit")) {
1813 if (f_rsl_find_ie(ud.rsl, RSL_IE_L3_INFO, l3_ie) == false) {
1814 setverdict(fail, "cannot find L3");
1815 mtc.stop;
1816 }
1817 l3 := dec_PDU_ML3_NW_MS(l3_ie.l3_info.payload);
1818
1819 int2enum(oct2int(l3.msgs.rrm.channelRelease.rRCause.valuePart), got_cause);
1820 log("GOT CAUSE CODE: ", l3.msgs.rrm.channelRelease.rRCause.valuePart, " = ", got_cause);
1821 if (match(got_cause, expect_rr_cause)) {
1822 setverdict(pass);
1823 } else {
1824 log("EXPECTED CAUSE CODE: ", expect_rr_cause);
1825 setverdict(fail, "Received RR Channel Release Cause code does not match expectations");
1826 }
1827 }
Neels Hofmeyr211169d2018-11-07 00:37:29 +01001828 repeat;
1829 }
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001830 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(tr_RSL_REL_REQ(rsl_chan_nr, ?))) {
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001831 got_rll_rel_req := true;
Harald Welte91d54a52018-01-28 15:35:07 +01001832 /* FIXME: Why are we getting this for LinkID SACCH? */
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001833 if (handle_rll_rel) {
1834 f_ipa_tx(0, ts_RSL_REL_CONF(rsl_chan_nr, main_dcch));
1835 }
Harald Welte91d54a52018-01-28 15:35:07 +01001836 repeat;
1837 }
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001838 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL))) {
Harald Welte91d54a52018-01-28 15:35:07 +01001839 /* respond with CHAN REL ACK */
1840 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(rsl_chan_nr));
1841 }
1842 /* ignore any user data */
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001843 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(tr_RSL_MsgTypeR(?))) {
Harald Welte91d54a52018-01-28 15:35:07 +01001844 repeat;
1845 }
1846 }
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001847
1848 log("f_expect_chan_rel() summary: got_deact_sacch=", got_deact_sacch, " got_rr_chan_rel=", got_rr_chan_rel,
1849 " got_rll_rel_req=", got_rll_rel_req);
1850
1851 if (expect_deact_sacch != got_deact_sacch) {
1852 setverdict(fail, "f_expect_chan_rel(): expect_deact_sacch=", expect_deact_sacch, " got_deact_sacch=", got_deact_sacch);
1853 }
1854 if (expect_rr_chan_rel != got_rr_chan_rel) {
1855 setverdict(fail, "f_expect_chan_rel(): expect_rr_chan_rel=", expect_rr_chan_rel, " got_rr_chan_rel=", got_rr_chan_rel);
1856 }
1857 if (expect_rll_rel_req != got_rll_rel_req) {
1858 setverdict(fail, "f_expect_chan_rel(): expect_rll_rel_req=", expect_rll_rel_req, " got_rll_rel_req=", got_rll_rel_req);
1859 }
Harald Welte91d54a52018-01-28 15:35:07 +01001860}
1861
Harald Welte4003d112017-12-09 22:35:39 +01001862/* Test behavior of channel release after hard Clear Command from MSC */
1863testcase TC_chan_rel_hard_clear() runs on test_CT {
1864 var BSSAP_N_DATA_ind rx_di;
Harald Welte4003d112017-12-09 22:35:39 +01001865 var DchanTuple dt;
Harald Welte4003d112017-12-09 22:35:39 +01001866
Harald Welte89d42e82017-12-17 16:42:41 +01001867 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +01001868
1869 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1870
1871 /* Instruct BSC to clear channel */
1872 var BssmapCause cause := 0;
1873 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
1874
1875 /* expect Clear Complete from BSC on A */
1876 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete)) {
1877 /* release the SCCP connection */
1878 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
1879 }
1880
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001881 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001882 f_shutdown_helper();
Harald Welte4003d112017-12-09 22:35:39 +01001883}
1884
Pau Espin Pedrol841b90d2021-04-15 16:42:52 +02001885function f_TC_chan_rel_last_eutran_plmn_hard_clear(boolean tx_csfb_ind) runs on test_CT {
1886 var BSSAP_N_DATA_ind rx_di;
1887 var DchanTuple dt;
1888
1889 f_init(1);
1890
1891 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1892 /* Send CommonID with some random PLMN (BSC doesn't take it into account
1893 /* yet when generating the EUTRAN neigh list in RR CHannel Release) */
1894 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_CommonId('001019876543210'H, '323454'O)));
1895
1896 /* Instruct BSC to clear channel */
1897 var BssmapCause cause := 0;
1898 if (tx_csfb_ind) {
1899 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommandCSFB(cause)));
1900 } else {
1901 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
1902 }
1903
1904 /* expect Clear Complete from BSC on A */
1905 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete)) {
1906 /* release the SCCP connection */
1907 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
1908 }
1909
1910 /* 1 neighbor is added by default in osmo-bts.cfg and
1911 SystemInformationConfig_default, use that: */
1912 var template CellSelIndValue exp_cells := f_tr_rr_chan_rel_earfcns(1);
1913
1914 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false, expect_cells := exp_cells);
1915 f_shutdown_helper();
1916}
1917
1918/* Test behavior of RR Channel rRelease after Clear Command without CSFB indicator
1919 from MSC, previously receiving any CommonID containing the "Last Used E-UTRAN
1920 PLMN Id". According to spec (3GPP TS 48.008 sec 3.1.30) that's the bit requesting
1921 EUTRAN neighbor list sent later on by BSC in RR Channel, so receiving CSFB
1922 Indicator or not shouldn't matter at all. */
1923testcase TC_chan_rel_last_eutran_plmn_hard_clear_no_csfb() runs on test_CT {
1924 f_TC_chan_rel_last_eutran_plmn_hard_clear(false);
1925}
1926
1927/* Test behavior of RR Channel rRelease after Clear Command with CSFB indicator from
1928 MSC, previously receiving any CommonID containing the "Last Used E-UTRAN PLMN
1929 Id". According to spec (3GPP TS 48.008 sec 3.1.30) that's the bit requesting
1930 EUTRAN neighbor list sent later on by BSC in RR Channel. */
1931testcase TC_chan_rel_last_eutran_plmn_hard_clear_csfb() runs on test_CT {
1932 f_TC_chan_rel_last_eutran_plmn_hard_clear(true);
1933}
1934
1935/* Test behavior of RR Channel Release after Clear Command with CSFB indicator from
1936 MSC, without receiving any CommonID containing the "Last Used E-UTRAN PLMN
1937 Id". According to spec (TS 48.008 version 16.0.0 Release 16 "3.2.1.21") the
1938 CSFB Indicator should not be used anymore, and hence, there should be no
1939 EUTRAN neighbor list sent by BSC in RR Channel release since no CommonId with
1940 Last Used E-UTRAN PLMN Id" IE was sent for this conn. */
Harald Welte99787102019-02-04 10:41:36 +01001941testcase TC_chan_rel_hard_clear_csfb() runs on test_CT {
1942 var BSSAP_N_DATA_ind rx_di;
1943 var DchanTuple dt;
1944
1945 f_init(1);
1946
1947 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1948
1949 /* Instruct BSC to clear channel */
1950 var BssmapCause cause := 0;
1951 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommandCSFB(cause)));
1952
1953 /* expect Clear Complete from BSC on A */
1954 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete)) {
1955 /* release the SCCP connection */
1956 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
1957 }
1958
Pau Espin Pedrol841b90d2021-04-15 16:42:52 +02001959 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001960 f_shutdown_helper();
Harald Welte99787102019-02-04 10:41:36 +01001961}
1962
Harald Welted8c36cd2017-12-09 23:05:31 +01001963/* Test behavior of channel release after hard RLSD from MSC */
1964testcase TC_chan_rel_hard_rlsd() runs on test_CT {
Harald Welted8c36cd2017-12-09 23:05:31 +01001965 var DchanTuple dt;
Harald Welted8c36cd2017-12-09 23:05:31 +01001966
Harald Welte89d42e82017-12-17 16:42:41 +01001967 f_init(1);
Harald Welted8c36cd2017-12-09 23:05:31 +01001968
1969 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1970
1971 /* release the SCCP connection */
1972 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
1973
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001974 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001975 f_shutdown_helper();
Harald Welted8c36cd2017-12-09 23:05:31 +01001976}
1977
Harald Welte550daf92018-06-11 19:22:13 +02001978/* Test behavior of channel release after hard RLSD from MSC and MS is not responding to RLL REL REQ */
1979testcase TC_chan_rel_hard_rlsd_ms_dead() runs on test_CT {
1980 var DchanTuple dt;
1981
1982 f_init(1);
1983
1984 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1985
1986 /* release the SCCP connection */
1987 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
1988
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001989 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001990 f_shutdown_helper();
Harald Welte550daf92018-06-11 19:22:13 +02001991}
1992
Harald Welte85804d42017-12-10 14:11:58 +01001993/* Test behavior of channel release after BSSMAP RESET from MSC */
1994testcase TC_chan_rel_a_reset() runs on test_CT {
Harald Welte85804d42017-12-10 14:11:58 +01001995 var DchanTuple dt;
Harald Welte85804d42017-12-10 14:11:58 +01001996
Harald Welte89d42e82017-12-17 16:42:41 +01001997 f_init(1);
Harald Welte85804d42017-12-10 14:11:58 +01001998
1999 dt := f_est_dchan('23'O, 23, '00010203040506'O);
2000
2001 /* Clear the queue, it might still contain stuff like IMMEDIATE ASSIGN */
2002 IPA_RSL[0].clear;
2003
2004 /* perform BSSAP RESET, expect RESET ACK and DISC.ind on connection */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02002005 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 +01002006 interleave {
Neels Hofmeyrf246a922020-05-13 02:27:10 +02002007 [] 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 +01002008 [] BSSAP.receive(tr_BSSAP_DISC_ind(dt.sccp_conn_id, ?, ?)) { }
2009 }
2010
Neels Hofmeyra5302c82018-11-04 23:09:58 +01002011 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002012 f_shutdown_helper();
Harald Welte85804d42017-12-10 14:11:58 +01002013}
2014
Pau Espin Pedrolc675b612020-01-09 19:55:40 +01002015/* Verify T(iar) triggers and releases the channel */
2016testcase TC_chan_rel_sccp_tiar_timeout() runs on test_CT {
2017 var DchanTuple dt;
2018
2019 /* Set T(iar) in BSC low enough that it will trigger before other side
2020 has time to keep alive with a T(ias). Keep recommended ratio of
2021 T(iar) >= T(ias)*2 */
2022 g_bsc_sccp_timer_ias := 2;
2023 g_bsc_sccp_timer_iar := 5;
2024
2025 f_init(1);
2026
2027 dt := f_est_dchan('23'O, 23, '00010203040506'O);
2028 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002029 f_shutdown_helper();
Pau Espin Pedrolc675b612020-01-09 19:55:40 +01002030}
2031
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02002032private function f_tc_chan_rel_rr_cause(myBSSMAP_Cause clear_cmd_cause, template RR_Cause expect_rr_cause)
2033runs on test_CT
2034{
2035 var DchanTuple dt;
2036
2037 dt := f_est_dchan('23'O, 23, '00010203040506'O);
2038 var BssmapCause cause := 0;
2039 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(enum2int(clear_cmd_cause))));
2040 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete)) {
2041 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
2042 }
2043
2044 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 +02002045}
2046
2047/* Test that Clear Command cause codes affect the RR Channel Release cause code */
2048testcase TC_chan_rel_rr_cause() runs on test_CT {
2049 f_init(1);
2050
2051 f_tc_chan_rel_rr_cause(GSM0808_CAUSE_CALL_CONTROL, GSM48_RR_CAUSE_NORMAL);
2052 f_tc_chan_rel_rr_cause(GSM0808_CAUSE_HANDOVER_SUCCESSFUL, GSM48_RR_CAUSE_NORMAL);
2053 f_tc_chan_rel_rr_cause(GSM0808_CAUSE_PREEMPTION, GSM48_RR_CAUSE_PREMPTIVE_REL);
2054 f_tc_chan_rel_rr_cause(GSM0808_CAUSE_RADIO_INTERFACE_MESSAGE_FAILURE, GSM48_RR_CAUSE_PROT_ERROR_UNSPC);
2055 f_tc_chan_rel_rr_cause(GSM0808_CAUSE_RADIO_INTERFACE_FAILURE, GSM48_RR_CAUSE_ABNORMAL_UNSPEC);
2056 f_tc_chan_rel_rr_cause(GSM0808_CAUSE_EQUIPMENT_FAILURE, GSM48_RR_CAUSE_ABNORMAL_UNSPEC);
Vadim Yanitskiye18aebb2021-01-03 13:10:43 +01002057
2058 f_shutdown_helper();
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02002059}
2060
Harald Welte5cd20ed2017-12-13 21:03:20 +01002061/* Test behavior if RSL EST IND for non-active channel */
2062testcase TC_rll_est_ind_inact_lchan() runs on test_CT {
2063 timer T := 2.0;
2064
Harald Welte89d42e82017-12-17 16:42:41 +01002065 f_init(1);
Harald Welte5cd20ed2017-12-13 21:03:20 +01002066
2067 var octetstring l3 := '00010203040506'O;
2068 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(6));
2069 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
2070
2071 T.start;
2072 alt {
2073 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) {
2074 setverdict(fail, "MSC received COMPL L3 for non-active lchan");
2075 }
2076 [] BSSAP.receive {}
2077 [] IPA_RSL[0].receive {}
2078 [] T.timeout {}
2079 }
2080
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002081 f_shutdown_helper();
Harald Welte5cd20ed2017-12-13 21:03:20 +01002082}
2083
2084/* Test behavior if RSL EST IND for invalid SAPI */
2085testcase TC_rll_est_ind_inval_sapi1() runs on test_CT {
2086 var RslChannelNr chan_nr;
2087
Harald Welte89d42e82017-12-17 16:42:41 +01002088 f_init(1);
Harald Welte5cd20ed2017-12-13 21:03:20 +01002089
2090 chan_nr := f_chreq_act_ack()
2091
2092 var octetstring l3 := '00010203040506'O;
2093 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(1)), l3));
2094
2095 timer T := 2.0;
2096 T.start;
2097 alt {
2098 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) {
2099 setverdict(fail, "MSC received COMPL L3 for invalid SAPI 1");
2100 }
2101 [] BSSAP.receive { repeat; }
2102 [] IPA_RSL[0].receive { repeat; }
2103 [] T.timeout {}
2104 }
2105
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002106 f_shutdown_helper();
Harald Welte5cd20ed2017-12-13 21:03:20 +01002107}
2108
2109/* Test behavior if RSL EST IND for invalid SAPI */
2110testcase TC_rll_est_ind_inval_sapi3() runs on test_CT {
2111 timer T := 2.0;
2112
Harald Welte89d42e82017-12-17 16:42:41 +01002113 f_init(1);
Harald Welte5cd20ed2017-12-13 21:03:20 +01002114
2115 var RslChannelNr chan_nr := f_chreq_act_ack();
2116
2117 var octetstring l3 := '00010203040506'O;
2118 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(3)), l3));
2119
2120 T.start;
2121 alt {
2122 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) {
2123 setverdict(fail, "MSC received COMPL L3 for invalid SAPI 3");
2124 }
2125 [] BSSAP.receive { repeat; }
2126 [] IPA_RSL[0].receive { repeat; }
2127 [] T.timeout {}
2128 }
2129
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002130 f_shutdown_helper();
Harald Welte5cd20ed2017-12-13 21:03:20 +01002131}
2132
2133/* Test behavior if RSL EST IND for invalid SACCH */
2134testcase TC_rll_est_ind_inval_sacch() runs on test_CT {
2135 timer T := 2.0;
2136
Harald Welte89d42e82017-12-17 16:42:41 +01002137 f_init(1);
Harald Welte5cd20ed2017-12-13 21:03:20 +01002138
2139 var RslChannelNr chan_nr := f_chreq_act_ack();
2140
2141 var octetstring l3 := '00010203040506'O;
2142 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_SACCH(0)), l3));
2143
2144 T.start;
2145 alt {
2146 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) {
2147 setverdict(fail, "MSC received COMPL L3 for invalid Link SACCH");
2148 }
2149 [] BSSAP.receive { repeat; }
2150 [] IPA_RSL[0].receive { repeat; }
2151 [] T.timeout {}
2152 }
2153
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002154 f_shutdown_helper();
Harald Welte5cd20ed2017-12-13 21:03:20 +01002155}
2156
Vadim Yanitskiy61f784a2020-10-01 21:12:19 +07002157/* Verify DLCI / RSL Link ID conversion for MO/MT messages on SAPI0/SAPI3 */
2158private function f_TC_tch_dlci_link_id_sapi(charstring id) runs on MSC_ConnHdlr {
2159 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
2160 var PDU_BSSAP ass_cmd := f_gen_ass_req();
2161
2162 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
2163 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
2164
2165 f_establish_fully(ass_cmd, exp_compl);
2166
2167 /* SAPI0 has already been established by f_establish_fully(), establish SAPI3 */
2168 RSL.send(ts_RSL_EST_IND(g_chan_nr, ts_RslLinkID_SACCH(3), '0904'O));
2169 /* Expect BSSAP/DTAP on SAPI3 (DLCI IE) */
2170 BSSAP.receive(PDU_BSSAP:{
2171 discriminator := '1'B,
2172 spare := '0000000'B,
2173 dlci := 'C3'O,
2174 lengthIndicator := ?,
2175 pdu := { dtap := '0904'O }
2176 });
2177
2178 /* Send messages on DCCH/SAPI0 and ACCH/SAPI3 */
2179 for (var integer i := 0; i < 32; i := i + 1) {
2180 var octetstring l3 := '09'O & f_rnd_octstring(14);
2181 var template (value) RslLinkId link_id;
2182 var template (value) OCT1 dlci;
2183
2184 if (i mod 2 == 0) {
2185 /* SAPI0 on FACCH or SDCCH */
2186 link_id := ts_RslLinkID_DCCH(0);
2187 dlci := '80'O;
2188 } else {
2189 /* SAPI3 on SACCH */
2190 link_id := ts_RslLinkID_SACCH(3);
2191 dlci := 'C3'O;
2192 }
2193
2194 /* Send MO message: RSL -> BSSAP */
Neels Hofmeyr0aa719b2020-10-12 18:43:09 +00002195 f_mo_l3_transceive(RSL, link_id, dlci, l3);
Vadim Yanitskiy61f784a2020-10-01 21:12:19 +07002196 /* Send MT message: BSSAP -> RSL */
Neels Hofmeyr0aa719b2020-10-12 18:43:09 +00002197 f_mt_l3_transceive(RSL, link_id, dlci, l3);
Vadim Yanitskiy61f784a2020-10-01 21:12:19 +07002198 }
2199}
2200testcase TC_tch_dlci_link_id_sapi() runs on test_CT {
2201 var TestHdlrParams pars := f_gen_test_hdlr_pars();
2202 var MSC_ConnHdlr vc_conn;
2203
2204 f_init(1, true);
2205 f_sleep(1.0);
2206
2207 vc_conn := f_start_handler(refers(f_TC_tch_dlci_link_id_sapi), pars);
2208 vc_conn.done;
2209
2210 f_shutdown_helper();
2211}
2212
Vadim Yanitskiy6ef5dfa2020-08-28 18:04:41 +07002213private function f_exp_sapi_n_reject(template (present) GsmSapi sapi := ?,
2214 template myBSSMAP_Cause cause := ?,
2215 float T_val := 2.0)
2216runs on test_CT {
2217 var BSSAP_N_DATA_ind rx_di;
2218 timer T;
2219
2220 var template BSSMAP_IE_Cause tr_cause := tr_BSSMAP_IE_Cause(cause);
2221 var template PDU_BSSAP tr_pdu := tr_BSSMAP_SAPInReject(sapi);
2222
2223 T.start(T_val);
2224 alt {
2225 [] BSSAP.receive(tr_BSSAP_DATA_ind(?, tr_pdu)) -> value rx_di {
2226 var BSSMAP_IE_Cause rx_cause := rx_di.userData.pdu.bssmap.sAPInReject.cause;
2227 if (not match(rx_cause, tr_cause)) {
2228 setverdict(fail, "Rx unexpected Cause IE: ",
2229 rx_cause, " vs expected ", tr_cause);
2230 }
2231 setverdict(pass);
2232 }
2233 [] BSSAP.receive(BSSAP_N_DATA_ind:?) -> value rx_di {
2234 setverdict(fail, "Rx unexpected BSSAP PDU: ", rx_di);
2235 }
2236 [] T.timeout {
2237 setverdict(fail, "Timeout waiting for BSSMAP SAPI N Reject");
2238 }
2239 }
2240}
2241
2242/* Check if we get SAPI N Reject on receipt of unexpected RLL RELease INDication */
2243testcase TC_rll_rel_ind_sapi_n_reject() runs on test_CT {
2244 var octetstring rnd_data := f_rnd_octstring(16);
2245 var RSL_Message rx_rsl;
2246 var DchanTuple dt;
2247
2248 f_init(1);
2249
2250 /* MS establishes a SAPI=0 link on DCCH */
2251 dt := f_est_dchan(f_rnd_ra_cs(), 23, rnd_data);
2252
2253 /* MSC sends some data on (not yet established) SAPI=3 link */
2254 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSAP_DTAP(rnd_data, '03'O)));
2255 /* BSC attempts to establish a SAPI=3 link on DCCH */
2256 rx_rsl := f_exp_ipa_rx(0, tr_RSL_EST_REQ(dt.rsl_chan_nr, tr_RslLinkID_DCCH(3)));
2257
2258 /* MS sends unexpected RELease INDication on SAPI=3 */
2259 f_ipa_tx(0, ts_RSL_REL_IND(dt.rsl_chan_nr, ts_RslLinkID_DCCH(3)));
2260 /* We expect to receive BSSMAP SAPI N Reject message from the BSC */
2261 f_exp_sapi_n_reject(3, GSM0808_CAUSE_MS_NOT_EQUIPPED);
2262
2263 /* Clean up the connection */
2264 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
2265 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
2266
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002267 f_shutdown_helper();
Vadim Yanitskiy6ef5dfa2020-08-28 18:04:41 +07002268}
2269
2270/* Check if we get SAPI N Reject on receipt of unexpected RLL ERROR INDication */
2271testcase TC_rll_err_ind_sapi_n_reject() runs on test_CT {
2272 var octetstring rnd_data := f_rnd_octstring(16);
2273 var RSL_Message rx_rsl;
2274 var DchanTuple dt;
2275
2276 f_init(1);
2277
2278 /* MS establishes a SAPI=0 link on DCCH */
2279 dt := f_est_dchan(f_rnd_ra_cs(), 23, rnd_data);
2280
2281 /* MSC sends some data on (not yet established) SAPI=3 link */
2282 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSAP_DTAP(rnd_data, '03'O)));
2283 /* BSC attempts to establish a SAPI=3 link on DCCH */
2284 rx_rsl := f_exp_ipa_rx(0, tr_RSL_EST_REQ(dt.rsl_chan_nr, tr_RslLinkID_DCCH(3)));
2285
2286 /* BTS sends unexpected ERROR INDication on SAPI=3 */
2287 f_ipa_tx(0, ts_RSL_ERROR_IND(dt.rsl_chan_nr, ts_RslLinkID_DCCH(3), ''O));
2288 /* We expect to receive BSSMAP SAPI N Reject message from the BSC */
2289 f_exp_sapi_n_reject(3, GSM0808_CAUSE_BSS_NOT_EQUIPPED);
2290
2291 /* Clean up the connection */
2292 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
2293 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
2294
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002295 f_shutdown_helper();
Vadim Yanitskiy6ef5dfa2020-08-28 18:04:41 +07002296}
2297
2298/* Check if we get SAPI N Reject due to a SAPI=3 link establishment timeout */
2299testcase TC_rll_timeout_sapi_n_reject() runs on test_CT {
2300 var octetstring rnd_data := f_rnd_octstring(16);
2301 var RSL_Message rx_rsl;
2302 var DchanTuple dt;
2303
2304 f_init(1);
2305
2306 /* MS establishes a SAPI=0 link on DCCH */
2307 dt := f_est_dchan(f_rnd_ra_cs(), 23, rnd_data);
2308
2309 /* MSC sends some data on (not yet established) SAPI=3 link */
2310 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSAP_DTAP(rnd_data, '03'O)));
2311 /* BSC attempts to establish a SAPI=3 link on DCCH */
2312 rx_rsl := f_exp_ipa_rx(0, tr_RSL_EST_REQ(dt.rsl_chan_nr, tr_RslLinkID_DCCH(3)));
2313
2314 /* MS does not respond, so the link establishment timeout triggers SAPI N Reject */
2315 f_exp_sapi_n_reject(3, GSM0808_CAUSE_BSS_NOT_EQUIPPED, T_val := 8.0);
2316
2317 /* Clean up the connection */
2318 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
2319 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
2320
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002321 f_shutdown_helper();
Vadim Yanitskiy6ef5dfa2020-08-28 18:04:41 +07002322}
2323
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +02002324testcase TC_si_default() runs on test_CT {
2325 f_init(0);
2326 f_init_bts_and_check_sysinfo(0, expect_si := SystemInformationConfig_default);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002327 f_shutdown_helper();
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +02002328}
Harald Welte4003d112017-12-09 22:35:39 +01002329
Neels Hofmeyr56f24782020-07-09 00:50:49 +02002330/* We're testing SI2quater with lists of EARFCNs. Instead of just incrementing EARFCNs, also pick some from the edges of
2331 * the entire value range. This function provides the same EARFCN numbers for the same earfcn_index */
2332private function f_test_si2quater_earfcn_by_idx(integer earfcn_index) return uint16_t
2333{
2334 select (earfcn_index) {
2335 case (0) {
2336 /* E-ARFCN 111 is already added in the osmo-bsc.cfg */
2337 return 111;
2338 }
2339 case (1) {
2340 return 1;
2341 }
2342 case (2) {
2343 return 0;
2344 }
2345 case (3) {
2346 return 65535;
2347 }
2348 case else {
2349 return 23 * (earfcn_index - 3);
2350 }
2351 }
2352}
2353
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02002354function f_test_si2quater(integer total_earfcns, template SystemInformationConfig expect_si,
2355 template CellSelIndValue expect_cells := omit) runs on test_CT {
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002356
2357 f_init(0);
2358
2359 /* E-ARFCN 111 is already added in the osmo-bsc.cfg, so only add more arfcns if total_earfcns > 1 */
2360 for (var integer i := 1; i < total_earfcns; i := i + 1) {
Neels Hofmeyr56f24782020-07-09 00:50:49 +02002361 f_bts_0_cfg(BSCVTY, {"si2quater neighbor-list add earfcn " & int2str(f_test_si2quater_earfcn_by_idx(i))
2362 & " thresh-hi 20 thresh-lo 10 prio 3 qrxlv 22 meas 3"});
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002363 }
2364
2365 f_init_bts_and_check_sysinfo(0, expect_si := expect_si);
2366
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02002367 if (not istemplatekind(expect_cells, "omit")) {
2368 /* Also check that RR Channel Release contains these EARFCNs.
2369 * (copied code from TC_chan_rel_hard_clear_csfb) */
2370 var BSSAP_N_DATA_ind rx_di;
2371 var DchanTuple dt;
2372
2373 dt := f_est_dchan('23'O, 23, '00010203040506'O);
Pau Espin Pedrold0046312021-04-19 16:35:58 +02002374 /* Send CommonID with some random PLMN (BSC doesn't take it into account
2375 * yet when generating the EUTRAN neigh list in RR CHannel Release) */
2376 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_CommonId('001019876543210'H, '323454'O)));
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02002377
2378 /* Instruct BSC to clear channel */
2379 var BssmapCause cause := 0;
2380 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommandCSFB(cause)));
2381
2382 /* expect Clear Complete from BSC on A */
2383 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete)) {
2384 /* release the SCCP connection */
2385 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
2386 }
2387
Pau Espin Pedrol841b90d2021-04-15 16:42:52 +02002388 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 +02002389 }
2390
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002391 for (var integer i := 1; i < total_earfcns; i := i + 1) {
Neels Hofmeyr56f24782020-07-09 00:50:49 +02002392 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 +02002393 }
2394}
2395
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002396private function f_tr_si2quater_earfcns(integer count) return template SI2quaterRestOctetsList
2397{
2398 var template SI2quaterRestOctetsList si2quater := {};
2399 var integer si2quater_count := (count + 2) / 3;
2400
2401 for (var integer i := 0; i < count; i := i + 1) {
Neels Hofmeyr56f24782020-07-09 00:50:49 +02002402 var integer earfcn := f_test_si2quater_earfcn_by_idx(i);
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002403 var integer index := i / 3;
2404 var integer earfcn_index := i mod 3;
2405 if (index >= lengthof(si2quater)) {
2406 si2quater[index] := tr_SI2quaterRestOctets_EUTRAN(index := index, count := si2quater_count - 1);
2407 }
2408 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);
2409 }
2410
2411 return si2quater;
2412}
2413
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02002414private function f_tr_rr_chan_rel_earfcns(integer count) return template CellSelIndValue
2415{
2416 var template CellSelIndValue_EUTRAN_Descrs cells := {};
2417
Alexander Couzensf74b5cb2020-09-10 22:28:40 +02002418 /* the lte neighbors must match the config & vty to pass this test */
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02002419 for (var integer i := 0; i < count; i := i + 1) {
2420 var integer earfcn := f_test_si2quater_earfcn_by_idx(i);
Alexander Couzensf74b5cb2020-09-10 22:28:40 +02002421 cells[i] := tr_CellSelIndValue_EUTRAN_Descr(earfcn, '1'B, 3);
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02002422 }
2423
2424 return tr_CellSelIndValue_EUTRAN(cells);
2425}
2426
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002427private function f_tc_si2quater_n_earfcns(integer n) runs on test_CT
2428{
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002429 var template SystemInformationConfig sic := SystemInformationConfig_default;
Pau Espin Pedrol8ab62e42020-12-18 16:19:11 +01002430 sic.si2quater := f_tr_si2quater_earfcns(n);
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02002431 var template CellSelIndValue cells := f_tr_rr_chan_rel_earfcns(n);
2432 f_test_si2quater(n, sic, cells);
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002433}
2434
2435testcase TC_si2quater_2_earfcns() runs on test_CT {
2436 f_tc_si2quater_n_earfcns(2);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002437 f_shutdown_helper();
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002438}
2439
2440testcase TC_si2quater_3_earfcns() runs on test_CT {
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002441 f_tc_si2quater_n_earfcns(3);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002442 f_shutdown_helper();
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002443}
2444
2445testcase TC_si2quater_4_earfcns() runs on test_CT {
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002446 f_tc_si2quater_n_earfcns(4);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002447 f_shutdown_helper();
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002448}
2449
2450testcase TC_si2quater_5_earfcns() runs on test_CT {
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002451 f_tc_si2quater_n_earfcns(5);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002452 f_shutdown_helper();
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002453}
2454
2455testcase TC_si2quater_6_earfcns() runs on test_CT {
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002456 f_tc_si2quater_n_earfcns(6);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002457 f_shutdown_helper();
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002458}
2459
2460testcase TC_si2quater_12_earfcns() runs on test_CT {
2461 f_tc_si2quater_n_earfcns(12);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002462 f_shutdown_helper();
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002463}
2464
2465testcase TC_si2quater_23_earfcns() runs on test_CT {
2466 f_tc_si2quater_n_earfcns(23);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002467 f_shutdown_helper();
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002468}
2469
2470testcase TC_si2quater_32_earfcns() runs on test_CT {
2471 f_tc_si2quater_n_earfcns(32);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002472 f_shutdown_helper();
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002473}
2474
2475testcase TC_si2quater_33_earfcns() runs on test_CT {
2476 f_tc_si2quater_n_earfcns(33);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002477 f_shutdown_helper();
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002478}
2479
2480testcase TC_si2quater_42_earfcns() runs on test_CT {
2481 f_tc_si2quater_n_earfcns(42);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002482 f_shutdown_helper();
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002483}
2484
2485testcase TC_si2quater_48_earfcns() runs on test_CT {
2486 f_tc_si2quater_n_earfcns(48);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002487 f_shutdown_helper();
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002488}
2489
2490/* verify the VTY error response when adding too many EARFCNs, and showing that osmo-bsc still sends 16 SI2quater with
2491 * 48 EARFCNs. */
2492testcase TC_si2quater_49_earfcns() runs on test_CT {
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002493 var template SystemInformationConfig sic := SystemInformationConfig_default;
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002494 sic.si2quater := f_tr_si2quater_earfcns(48); /* 48, not 49! */
2495 f_init(0);
2496
2497 for (var integer i := 1; i < 48; i := i + 1) {
Neels Hofmeyr56f24782020-07-09 00:50:49 +02002498 f_bts_0_cfg(BSCVTY, {"si2quater neighbor-list add earfcn " & int2str(f_test_si2quater_earfcn_by_idx(i))
2499 & " thresh-hi 20 thresh-lo 10 prio 3 qrxlv 22 meas 3"});
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002500 }
2501
2502 /* The 49th EARFCN no longer fits, expect VTY error */
2503 f_vty_enter_cfg_bts(BSCVTY, 0);
2504 var charstring vty_error;
2505 vty_error := f_vty_transceive_ret(BSCVTY,
2506 "si2quater neighbor-list add earfcn 70 thresh-hi 20 thresh-lo 10 prio 3 qrxlv 22 meas 3")
2507 f_vty_transceive(BSCVTY, "end");
2508
2509 if (f_strstr(vty_error, "Unable to add ARFCN 70") >= 0) {
2510 log("Got expected VTY error: ", vty_error);
2511 setverdict(pass);
2512 } else {
2513 setverdict(fail, "Expected the 49th EUTRAN ARFCN to be rejected by vty config, got: ", vty_error);
2514 }
2515
2516 f_init_bts_and_check_sysinfo(0, expect_si := sic);
2517
2518 for (var integer i := 1; i < 48; i := i + 1) {
Neels Hofmeyr56f24782020-07-09 00:50:49 +02002519 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 +02002520 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002521 f_shutdown_helper();
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002522}
2523
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02002524private function f_acc09_count_allowed(AccessControlClass acc) return uint8_t
2525{
2526 var uint8_t count := 0;
2527 for (var integer i := 5; i < 16; i := i + 1) {
2528 if (acc[i] == '0'B) { /* the list marks barred, we count allowed */
2529 count := count + 1;
2530 }
2531 }
2532 return count;
2533}
2534
Pau Espin Pedrolc6136cd2020-07-24 13:20:02 +02002535private function f_recv_next_si1(integer rsl_idx := 0) runs on test_CT return SystemInformationType1
2536{
2537 var ASP_RSL_Unitdata rx_rsl_ud;
2538 var SystemInformationType1 last_si1;
2539
2540 timer T := 30.0;
2541 T.start;
2542 alt {
2543 [] IPA_RSL[rsl_idx].receive(tr_ASP_RSL_UD((tr_RSL_NO_BCCH_INFO,
2544 tr_RSL_BCCH_INFO,
2545 tr_RSL_NO_SACCH_FILL,
2546 tr_RSL_SACCH_FILL))
2547 ) -> value rx_rsl_ud {
2548 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
2549 if (g_system_information[rsl_idx].si1 == omit) {
2550 repeat;
2551 }
2552 last_si1 := g_system_information[rsl_idx].si1;
2553 g_system_information[rsl_idx].si1 := omit;
2554 T.stop;
2555 }
Vadim Yanitskiy79ebd5e2021-01-04 00:12:55 +01002556 [] IPA_RSL[rsl_idx].receive { repeat; }
Pau Espin Pedrolc6136cd2020-07-24 13:20:02 +02002557 [] T.timeout { setverdict(fail, "Timeout receiving next SI1"); }
2558 }
2559 return last_si1;
2560}
2561
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02002562/* verify ACC rotate feature */
2563testcase TC_si_acc_rotate() runs on test_CT {
2564 var template SystemInformationConfig sic := SystemInformationConfig_default;
Pau Espin Pedrolc6136cd2020-07-24 13:20:02 +02002565 var SystemInformationType1 last_si1;
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02002566 var AccessControlClass acc;
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02002567 var uint8_t count;
2568 var integer times_allowed[10] := { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
2569
2570 f_init(0, guard_timeout := 60.0);
2571
2572 f_bts_0_cfg(BSCVTY, {"rach access-control-class 5 barred",
2573 "access-control-class-rotate 3",
2574 "access-control-class-rotate-quantum 1"});
2575
2576 /* Init and get first sysinfo */
2577 f_init_bts_and_check_sysinfo(0, expect_si := ?);
2578
Pau Espin Pedrolc6136cd2020-07-24 13:20:02 +02002579 for (var integer i:= 0; i < 20; i := i + 1) {
2580 last_si1 := f_recv_next_si1(0);
2581 acc := last_si1.rach_control.acc;
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02002582 count := f_acc09_count_allowed(acc);
2583 log("RSL: GOT SI1 ACC len=", count, ": ", acc);
2584
2585 if (count != 3) {
2586 log("RSL: EXPECTED SI ACC len=3");
2587 setverdict(fail, "received SI does not match expectations");
2588 break;
2589 }
2590
2591 for (var integer j := 0; j < 10; j := j + 1) {
2592 if (acc[16 - 1 - j] == '0'B) { /* the list marks barred, we count allowed */
2593 times_allowed[j] := times_allowed[j] + 1;
2594 }
2595 }
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02002596 }
2597
2598 for (var integer j := 0; j < 10; j := j + 1) {
2599 log("ACC", j, " allowed ", times_allowed[j], " times" );
2600 if (j != 5 and times_allowed[j] < 3) {
2601 setverdict(fail, "ACC", j, " ERROR: allowed ", times_allowed[j], " < 1 times");
2602 } else if (j == 5 and times_allowed[j] > 0) {
2603 setverdict(fail, "ACC", j, " ERROR: allowed ", times_allowed[j], " > 0 times");
2604 }
2605 }
2606
2607 f_bts_0_cfg(BSCVTY, {"access-control-class-rotate 10",
2608 "rach access-control-class 5 allowed"});
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002609 f_shutdown_helper();
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02002610}
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002611
Pau Espin Pedrolc6136cd2020-07-24 13:20:02 +02002612/* verify ACC startup ramp+rotate feature */
2613testcase TC_si_acc_ramp_rotate() runs on test_CT {
2614 var template SystemInformationConfig sic := SystemInformationConfig_default;
2615 var SystemInformationType1 last_si1;
2616 var AccessControlClass acc;
2617 var ASP_RSL_Unitdata rx_rsl_ud;
2618 var uint8_t count;
2619 var uint8_t prev_count;
2620 var integer times_allowed[10] := { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
2621
2622 f_init(0, guard_timeout := 80.0);
2623
2624 f_bts_0_cfg(BSCVTY, {"rach access-control-class 4 barred",
2625 "access-control-class-rotate 0",
2626 "access-control-class-rotate-quantum 1",
2627 "access-control-class-ramping",
2628 "access-control-class-ramping-step-interval 5",
2629 "access-control-class-ramping-step-size 5"});
2630
2631 /* Init and get first sysinfo */
2632 f_init_bts_and_check_sysinfo(0, expect_si := ?);
2633 last_si1 := g_system_information[0].si1;
2634 acc := last_si1.rach_control.acc;
2635 count := f_acc09_count_allowed(acc);
2636 /* Adm subset size was set to 0 above, so wait until all ACC are barred */
2637 while (count > 0) {
2638 last_si1 := f_recv_next_si1(0);
2639 acc := last_si1.rach_control.acc;
2640 count := f_acc09_count_allowed(acc);
2641 log("RSL: wait len()=0: GOT SI1 ACC len=", count, ": ", acc);
2642 }
2643
2644 /* Increase adm subset size, we should see ramping start up */
2645 f_bts_0_cfg(BSCVTY, {"access-control-class-rotate 10"});
2646 prev_count := 0;
2647 while (true) {
2648 last_si1 := f_recv_next_si1(0);
2649 acc := last_si1.rach_control.acc;
2650 count := f_acc09_count_allowed(acc);
2651 log("RSL: GOT SI1 ACC len=", count, ": ", acc);
2652
2653 if (prev_count > count) {
2654 setverdict(fail, "ACC allowed count dropped while expecting grow: ", prev_count, " -> ", count);
2655 break;
2656 }
2657
2658 if (count == 9) {
2659 break; /* Maximum reached (10 - 1 perm barred), done here */
2660 }
2661
2662 prev_count := count;
2663 }
2664
2665 setverdict(pass);
2666
2667 f_bts_0_cfg(BSCVTY, {"access-control-class-rotate 10",
2668 "rach access-control-class 4 allowed",
2669 "no access-control-class-ramping"});
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002670 f_shutdown_helper();
Pau Espin Pedrolc6136cd2020-07-24 13:20:02 +02002671}
2672
Harald Welte4003d112017-12-09 22:35:39 +01002673testcase TC_ctrl_msc_connection_status() runs on test_CT {
2674 var charstring ctrl_resp;
2675
Harald Welte89d42e82017-12-17 16:42:41 +01002676 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +01002677
2678 /* See https://osmocom.org/issues/2729 */
2679 f_ctrl_get_exp(IPA_CTRL, "msc_connection_status", "connected");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002680 f_shutdown_helper();
Harald Welte4003d112017-12-09 22:35:39 +01002681}
2682
Stefan Sperlingb041b3d2018-01-03 17:14:55 +01002683testcase TC_ctrl_msc0_connection_status() runs on test_CT {
2684 var charstring ctrl_resp;
2685
2686 f_init(1);
Stefan Sperlingb041b3d2018-01-03 17:14:55 +01002687
2688 f_ctrl_get_exp(IPA_CTRL, "msc.0.connection_status", "connected");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002689 f_shutdown_helper();
Stefan Sperlingb041b3d2018-01-03 17:14:55 +01002690}
2691
Harald Welte4003d112017-12-09 22:35:39 +01002692testcase TC_ctrl() runs on test_CT {
2693 var charstring ctrl_resp;
2694
Harald Welte89d42e82017-12-17 16:42:41 +01002695 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +01002696
2697 /* all below values must match the osmo-bsc.cfg config file used */
2698
Harald Welte6a129692018-03-17 17:30:14 +01002699 f_ctrl_get_exp(IPA_CTRL, "mcc", "001");
2700 f_ctrl_get_exp(IPA_CTRL, "mnc", "01");
Oliver Smith75aa0202019-08-19 14:17:50 +02002701 f_ctrl_get_exp(IPA_CTRL, "number-of-bts", "4");
Harald Welte4003d112017-12-09 22:35:39 +01002702
2703 var integer bts_nr := 0;
2704 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "location-area-code", "1");
2705 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "cell-identity", "0");
2706 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "oml-connection-state", "connected");
2707 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "gprs-mode", "gprs");
2708 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "rf_state", "operational,unlocked,on");
2709 f_ctrl_get_exp_trx(IPA_CTRL, bts_nr, 0, "arfcn", "871");
2710 f_ctrl_get_exp_trx(IPA_CTRL, bts_nr, 0, "max-power-reduction", "20");
2711
2712 var integer uptime := str2int(f_ctrl_get_bts(IPA_CTRL, bts_nr, "oml-uptime"));
2713 f_sleep(2.0);
2714 if (str2int(f_ctrl_get_bts(IPA_CTRL, bts_nr, "oml-uptime")) < uptime+1) {
2715 setverdict(fail, "oml-uptime not incrementing as expected");
2716 }
2717 /* TODO: Disconnect RSL, imply that OML is disconnected and check for uptime zero? */
2718
2719 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bsc", 0, "paging:attempted", 0);
2720
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002721 f_shutdown_helper();
Harald Welte96c94412017-12-09 03:12:45 +01002722}
2723
Pau Espin Pedrol5a2d7432019-06-07 19:43:45 +02002724/* Verify that Upon receival of SET "location", BSC forwards a TRAP
2725 "location-state" over the SCCPlite IPA conn */
2726testcase TC_ctrl_location() runs on test_CT {
2727 var MSC_ConnHdlr vc_conn;
2728 var integer bts_nr := 0;
2729
2730 f_init(1, true);
2731 f_sleep(1.0);
2732
2733 f_ctrl_set_bts(IPA_CTRL, bts_nr, "location", "1234567,fix3d,0.340000,0.560000,0.780000");
2734 f_ctrl_exp_trap(SCCPLITE_IPA_CTRL, "bts." & int2str(bts_nr) & ".location-state",
2735 "1234567,fix3d,0.340000,0.560000,0.780000,operational,unlocked,on,001,01");
2736
2737 f_ctrl_set(SCCPLITE_IPA_CTRL, "rf_locked", "1");
2738 f_sleep(2.0);
2739
2740 f_ctrl_set_bts(IPA_CTRL, bts_nr, "location", "1234888,fix3d,0.350000,0.570000,0.790000");
2741 f_ctrl_exp_trap(SCCPLITE_IPA_CTRL, "bts." & int2str(bts_nr) & ".location-state",
2742 "1234888,fix3d,0.350000,0.570000,0.790000,operational,locked,off,001,01");
2743
2744 /* should match the one from config */
2745 f_ctrl_set(SCCPLITE_IPA_CTRL, "rf_locked", "0");
2746
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002747 f_shutdown_helper();
Pau Espin Pedrol5a2d7432019-06-07 19:43:45 +02002748}
2749
Harald Welte6f521d82017-12-11 19:52:02 +01002750
2751/***********************************************************************
2752 * Paging Testing
2753 ***********************************************************************/
2754
2755type record Cell_Identity {
2756 GsmMcc mcc,
2757 GsmMnc mnc,
2758 GsmLac lac,
2759 GsmCellId ci
2760};
Harald Welte24135bd2018-03-17 19:27:53 +01002761private const Cell_Identity cid := { '001'H, '01'H, 1, 0 };
Stefan Sperling049a86e2018-03-20 15:51:00 +01002762private const Cell_Identity unknown_cid := { '678'H, 'f90'H, 1, 0 };
Harald Welte6f521d82017-12-11 19:52:02 +01002763
Harald Welte5d1a2202017-12-13 19:51:29 +01002764type set of integer BtsIdList;
2765
2766private function f_bts_in_list(integer bts_id, BtsIdList bts_ids) return boolean {
2767 for (var integer j := 0; j < sizeof(bts_ids); j := j + 1) {
2768 if (bts_id == bts_ids[j]) {
2769 return true;
2770 }
2771 }
2772 return false;
2773}
Harald Welte6f521d82017-12-11 19:52:02 +01002774
2775/* core paging test helper function; used by most paging test cases */
2776private function f_pageing_helper(hexstring imsi,
2777 template BSSMAP_FIELD_CellIdentificationList cid_list,
Harald Welte5d1a2202017-12-13 19:51:29 +01002778 BtsIdList bts_ids := { 0 },
Harald Welte6f521d82017-12-11 19:52:02 +01002779 template RSL_ChanNeeded rsl_chneed := omit,
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07002780 template (omit) OCT4 tmsi := omit) runs on test_CT
Harald Welte6f521d82017-12-11 19:52:02 +01002781{
2782 var template BSSMAP_IE_ChannelNeeded bssmap_chneed;
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07002783 var template MobileIdentityV mi;
Harald Welte6f521d82017-12-11 19:52:02 +01002784 var RSL_Message rx_rsl;
2785 var integer paging_group := hex2int(imsi[lengthof(imsi)-1]);
Harald Welte5d1a2202017-12-13 19:51:29 +01002786 var integer i;
Harald Welte6f521d82017-12-11 19:52:02 +01002787
2788 f_init();
Harald Welte6f521d82017-12-11 19:52:02 +01002789
2790 /* Clear the queue, it might still contain stuff like BCCH FILLING */
Harald Weltec3068592018-03-17 19:55:31 +01002791 for (i := 0; i < NUM_BTS; i := i + 1) {
2792 IPA_RSL[i].clear;
Harald Welte5d1a2202017-12-13 19:51:29 +01002793 }
Harald Welte6f521d82017-12-11 19:52:02 +01002794
2795 if (isvalue(rsl_chneed)) {
2796 /* The values of 08.08 3.2.2.36 and 08.58 9.3.40 are luckily identical */
2797 bssmap_chneed := ts_BSSMAP_IE_ChanNeeded(int2bit(enum2int(valueof(rsl_chneed)),2));
2798 } else {
2799 bssmap_chneed := omit;
2800 }
2801
Neels Hofmeyrf246a922020-05-13 02:27:10 +02002802 BSSAP.send(ts_BSSAP_UNITDATA_req(g_bssap[0].sccp_addr_peer, g_bssap[0].sccp_addr_own,
2803 ts_BSSMAP_Paging(imsi, cid_list, tmsi, bssmap_chneed)));
Harald Welte6f521d82017-12-11 19:52:02 +01002804
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07002805 if (not istemplatekind(tmsi, "omit")) {
2806 mi := t_MI_TMSI(tmsi);
Harald Welte6f521d82017-12-11 19:52:02 +01002807 } else {
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07002808 mi := tr_MI_IMSI(imsi);
Harald Welte6f521d82017-12-11 19:52:02 +01002809 }
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07002810
Harald Welte5d1a2202017-12-13 19:51:29 +01002811 for (i := 0; i < sizeof(bts_ids); i := i + 1) {
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07002812 rx_rsl := f_exp_ipa_rx(bts_ids[i], tr_RSL_PAGING_CMD(mi));
Harald Welte5d1a2202017-12-13 19:51:29 +01002813 /* check channel type, paging group */
2814 if (rx_rsl.ies[1].body.paging_group != paging_group) {
2815 setverdict(fail, "Paging for wrong paging group");
2816 }
2817 if (ispresent(rsl_chneed) and
2818 rx_rsl.ies[3].body.chan_needed.chan_needed != valueof(rsl_chneed)) {
2819 setverdict(fail, "RSL Channel Needed != BSSMAP Channel Needed");
2820 }
Harald Welte6f521d82017-12-11 19:52:02 +01002821 }
Harald Welte2fccd982018-01-31 15:48:19 +01002822 f_sleep(2.0);
Harald Welte5d1a2202017-12-13 19:51:29 +01002823 /* do a quick check on all not-included BTSs if they received paging */
2824 for (i := 0; i < NUM_BTS; i := i + 1) {
2825 timer T := 0.1;
2826 if (f_bts_in_list(i, bts_ids)) {
2827 continue;
2828 }
2829 T.start;
2830 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07002831 [] IPA_RSL[i].receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD(mi))) {
Harald Welte5d1a2202017-12-13 19:51:29 +01002832 setverdict(fail, "Paging on BTS ", i, " which is not part of ", bts_ids);
2833 }
2834 [] IPA_RSL[i].receive { repeat; }
2835 [] T.timeout { }
2836 }
Harald Welte6f521d82017-12-11 19:52:02 +01002837 }
2838
2839 setverdict(pass);
2840}
2841
Harald Welte5d1a2202017-12-13 19:51:29 +01002842const BtsIdList c_BtsId_all := { 0, 1, 2 };
Harald Welte751d3eb2018-01-31 15:51:06 +01002843const BtsIdList c_BtsId_none := { };
Harald Welte5d1a2202017-12-13 19:51:29 +01002844const BtsIdList c_BtsId_LAC1 := { 0, 1 };
2845const BtsIdList c_BtsId_LAC2 := { 2 };
2846
Harald Welte6f521d82017-12-11 19:52:02 +01002847/* PAGING by IMSI + TMSI */
2848testcase TC_paging_imsi_nochan() runs on test_CT {
2849 var BSSMAP_FIELD_CellIdentificationList cid_list;
2850 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Philipp Maier8c04b0a2018-02-23 13:48:48 +01002851 f_pageing_helper('001010100000001'H, cid_list, c_BtsId_all, omit, omit);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002852 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002853}
2854
2855/* PAGING by IMSI + TMSI */
2856testcase TC_paging_tmsi_nochan() runs on test_CT {
2857 var BSSMAP_FIELD_CellIdentificationList cid_list;
2858 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01002859 f_pageing_helper('001010100000001'H, cid_list, c_BtsId_all, omit, 'A1B2C301'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002860 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002861}
2862
2863/* Paging with different "channel needed' values */
2864testcase TC_paging_tmsi_any() runs on test_CT {
2865 var BSSMAP_FIELD_CellIdentificationList cid_list;
2866 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01002867 f_pageing_helper('001010100000002'H, cid_list, c_BtsId_all, RSL_CHANNEED_ANY, 'A1B2C302'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002868 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002869}
2870testcase TC_paging_tmsi_sdcch() runs on test_CT {
2871 var BSSMAP_FIELD_CellIdentificationList cid_list;
2872 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01002873 f_pageing_helper('001010100000003'H, cid_list, c_BtsId_all, RSL_CHANNEED_SDCCH, 'A1B2C303'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002874 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002875}
2876testcase TC_paging_tmsi_tch_f() runs on test_CT {
2877 var BSSMAP_FIELD_CellIdentificationList cid_list;
2878 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01002879 f_pageing_helper('001010000000004'H, cid_list, c_BtsId_all, RSL_CHANNEED_TCH_F, 'A1B2C304'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002880 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002881}
2882testcase TC_paging_tmsi_tch_hf() runs on test_CT {
2883 var BSSMAP_FIELD_CellIdentificationList cid_list;
2884 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01002885 f_pageing_helper('001010000000005'H, cid_list, c_BtsId_all, RSL_CHANNEED_TCH_ForH, 'A1B2C305'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002886 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002887}
2888
2889/* Paging by CGI */
2890testcase TC_paging_imsi_nochan_cgi() runs on test_CT {
2891 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2892 cid_list := { cIl_CGI := { ts_BSSMAP_CI_CGI(cid.mcc, cid.mnc, cid.lac, cid.ci) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01002893 f_pageing_helper('001010000000006'H, cid_list, { 0 });
Philipp Maier282ca4b2018-02-27 17:17:00 +01002894 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002895}
2896
2897/* Paging by LAC+CI */
2898testcase TC_paging_imsi_nochan_lac_ci() runs on test_CT {
2899 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2900 cid_list := { cIl_LAC_CI := { ts_BSSMAP_CI_LAC_CI(cid.lac, cid.ci) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01002901 f_pageing_helper('001010000000007'H, cid_list, { 0 });
Philipp Maier282ca4b2018-02-27 17:17:00 +01002902 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002903}
2904
2905/* Paging by CI */
2906testcase TC_paging_imsi_nochan_ci() runs on test_CT {
2907 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2908 cid_list := { cIl_CI := { ts_BSSMAP_CI_CI(cid.ci) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01002909 f_pageing_helper('001010000000008'H, cid_list, { 0 });
Philipp Maier282ca4b2018-02-27 17:17:00 +01002910 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002911}
2912
2913/* Paging by LAI */
2914testcase TC_paging_imsi_nochan_lai() runs on test_CT {
2915 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2916 cid_list := { cIl_LAI := { ts_BSSMAP_CI_LAI(cid.mcc, cid.mnc, cid.lac) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01002917 f_pageing_helper('001010000000009'H, cid_list, c_BtsId_LAC1);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002918 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002919}
2920
2921/* Paging by LAC */
2922testcase TC_paging_imsi_nochan_lac() runs on test_CT {
2923 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2924 cid_list := { cIl_LAC := { ts_BSSMAP_CI_LAC(cid.lac) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01002925 f_pageing_helper('001010000000010'H, cid_list, c_BtsId_LAC1);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002926 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002927}
2928
2929/* Paging by "all in BSS" */
2930testcase TC_paging_imsi_nochan_all() runs on test_CT {
2931 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2932 cid_list := { cIl_allInBSS := ''O };
Harald Welte5d1a2202017-12-13 19:51:29 +01002933 f_pageing_helper('001010000000011'H, cid_list, c_BtsId_all);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002934 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002935}
2936
Stefan Sperling7b5e1782018-03-20 19:32:43 +01002937/* Paging by PLMN+LAC+RNC; We do not implement this; Verify nothing is paged */
Harald Welte751d3eb2018-01-31 15:51:06 +01002938testcase TC_paging_imsi_nochan_plmn_lac_rnc() runs on test_CT {
2939 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2940 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 +01002941 f_pageing_helper('001010000000012'H, cid_list, c_BtsId_none);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002942 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01002943}
Harald Welte6f521d82017-12-11 19:52:02 +01002944
Stefan Sperling7b5e1782018-03-20 19:32:43 +01002945/* Paging by RNC; We do not implement this; Verify nothing is paged */
Harald Welte751d3eb2018-01-31 15:51:06 +01002946testcase TC_paging_imsi_nochan_rnc() runs on test_CT {
2947 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2948 cid_list := { cIl_RNC := { int2oct(13, 2) } };
Stefan Sperling7b5e1782018-03-20 19:32:43 +01002949 f_pageing_helper('001010000000013'H, cid_list, c_BtsId_none);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002950 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01002951}
2952
Stefan Sperling7b5e1782018-03-20 19:32:43 +01002953/* Paging by LAC+RNC; We do not implement; Verify nothing is paged */
Harald Welte751d3eb2018-01-31 15:51:06 +01002954testcase TC_paging_imsi_nochan_lac_rnc() runs on test_CT {
2955 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2956 cid_list := { cIl_LAC_RNC := { ts_BSSMAP_CI_LAC_RNC(cid.lac, 14) } };
Stefan Sperling7b5e1782018-03-20 19:32:43 +01002957 f_pageing_helper('001010000000014'H, cid_list, c_BtsId_none);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002958 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01002959}
2960
Harald Welte6f521d82017-12-11 19:52:02 +01002961/* Paging on multiple cells (multiple entries in list): Verify all of them page */
Harald Welte751d3eb2018-01-31 15:51:06 +01002962testcase TC_paging_imsi_nochan_lacs() runs on test_CT {
2963 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2964 cid_list := { cIl_LAC := { ts_BSSMAP_CI_LAC(1), ts_BSSMAP_CI_LAC(2) } };
2965 f_pageing_helper('001010000000015'H, cid_list, c_BtsId_all);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002966 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01002967}
2968
2969/* Paging on empty list: Verify none of them page */
2970testcase TC_paging_imsi_nochan_lacs_empty() runs on test_CT {
2971 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2972 cid_list := { cIl_LAC := { } };
2973 f_pageing_helper('001010000000016'H, cid_list, c_BtsId_none);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002974 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01002975}
2976
Stefan Sperling049a86e2018-03-20 15:51:00 +01002977/* Paging by CGI with unknown MCC/MNC: Verify nothing is paged. */
2978testcase TC_paging_imsi_nochan_cgi_unknown_cid() runs on test_CT {
2979 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2980 cid_list := { cIl_CGI := { ts_BSSMAP_CI_CGI(unknown_cid.mcc, unknown_cid.mnc, unknown_cid.lac, unknown_cid.ci) } };
2981 f_pageing_helper('001010000000006'H, cid_list, c_BtsId_none);
2982 f_shutdown_helper();
2983}
2984
Harald Welte6f521d82017-12-11 19:52:02 +01002985/* Verify paging retransmission interval + count */
2986/* Verify paging stops after channel establishment */
Harald Welte6f521d82017-12-11 19:52:02 +01002987/* Test behavior under paging overload */
Harald Welteae026692017-12-09 01:03:01 +01002988
Harald Weltee65d40e2017-12-13 00:09:06 +01002989/* Verify PCH load */
2990testcase TC_paging_imsi_load() runs on test_CT {
2991 var BSSMAP_FIELD_CellIdentificationList cid_list;
2992 timer T := 4.0;
Harald Welte2caa1062018-03-17 18:19:05 +01002993 timer T_retrans := 1.0;
Harald Weltee65d40e2017-12-13 00:09:06 +01002994 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01002995 f_pageing_helper('001010123456789'H, cid_list, c_BtsId_all);
Harald Weltee65d40e2017-12-13 00:09:06 +01002996
2997 /* tell BSC there is no paging space anymore */
2998 f_ipa_tx(0, ts_RSL_PAGING_LOAD_IND(0));
Harald Welte3b57ab52018-03-17 18:01:10 +01002999 f_sleep(0.2);
3000 IPA_RSL[0].clear;
Harald Weltee65d40e2017-12-13 00:09:06 +01003001
3002 /* Wait for 4 seconds if any more PAGING CMD are received on RSL. Normally,
3003 * there would be 8 retransmissions during 4 seconds */
3004 T.start;
Harald Welte2caa1062018-03-17 18:19:05 +01003005 T_retrans.start;
Harald Weltee65d40e2017-12-13 00:09:06 +01003006 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07003007 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD(?))) {
Harald Weltee65d40e2017-12-13 00:09:06 +01003008 setverdict(fail, "Received PAGING after LOAD_IND(0)");
Daniel Willmannafce8662018-07-06 23:11:32 +02003009 mtc.stop;
Harald Weltee65d40e2017-12-13 00:09:06 +01003010 }
Harald Welte2caa1062018-03-17 18:19:05 +01003011 [] T_retrans.timeout {
3012 /* re-trnsmit the zero-space LOAD IND to avoid BSC 'auto credit' */
3013 f_ipa_tx(0, ts_RSL_PAGING_LOAD_IND(0));
3014 T_retrans.start;
3015 repeat;
3016 }
Harald Weltee65d40e2017-12-13 00:09:06 +01003017 [] T.timeout {
3018 setverdict(pass);
3019 }
3020 }
Philipp Maier282ca4b2018-02-27 17:17:00 +01003021
3022 f_shutdown_helper();
Harald Weltee65d40e2017-12-13 00:09:06 +01003023}
3024
Harald Welte235ebf12017-12-15 14:18:16 +01003025/* Verify Paging Counter */
Harald Welte1ff69992017-12-14 12:31:17 +01003026testcase TC_paging_counter() runs on test_CT {
3027 var BSSMAP_FIELD_CellIdentificationList cid_list;
3028 timer T := 4.0;
3029 var integer i;
3030 var integer paging_attempted_bsc;
3031 var integer paging_attempted_bts[NUM_BTS];
3032 var integer paging_expired_bts[NUM_BTS];
3033 cid_list := valueof(ts_BSSMAP_CIL_noCell);
3034
3035 f_init();
3036
3037 /* read counters before paging */
3038 paging_attempted_bsc := f_ctrl_get_ratectr_abs(IPA_CTRL, "bsc", 0, "paging:attempted");
3039 for (i := 0; i < NUM_BTS; i := i+1) {
3040 paging_attempted_bts[i] := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", i, "paging:attempted");
3041 paging_expired_bts[i] := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", i, "paging:expired");
3042 }
3043
3044 f_pageing_helper('001230000000001'H, cid_list, c_BtsId_all);
3045
3046 /* expect the attempted pages on BSC and each BTSs to have incremented by one */
3047 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bsc", 0, "paging:attempted", paging_attempted_bsc+1);
3048 for (i := 0; i < NUM_BTS; i := i+1) {
3049 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", i, "paging:attempted",
3050 paging_attempted_bts[i]+1);
3051 }
3052
3053 /* assume that 12s later the paging on all BTSs have expired and hence incremented by 1 */
3054 f_sleep(12.0);
3055 for (i := 0; i < NUM_BTS; i := i+1) {
3056 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", i, "paging:expired",
3057 paging_expired_bts[i]+1);
3058 }
Harald Welte1ff69992017-12-14 12:31:17 +01003059
Philipp Maier282ca4b2018-02-27 17:17:00 +01003060 f_shutdown_helper();
Harald Welte1ff69992017-12-14 12:31:17 +01003061}
3062
3063
Harald Welte10985002017-12-12 09:29:15 +01003064/* Verify paging stops after A-RESET */
3065testcase TC_paging_imsi_a_reset() runs on test_CT {
3066 var BSSMAP_FIELD_CellIdentificationList cid_list;
3067 timer T := 3.0;
3068 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01003069 f_pageing_helper('001010123456789'H, cid_list, c_BtsId_all);
Harald Welte10985002017-12-12 09:29:15 +01003070
3071 /* Perform a BSSMAP Reset and wait for ACK */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003072 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 +01003073 alt {
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003074 [] 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 +01003075 [] BSSAP.receive { repeat; }
3076 }
3077
Daniel Willmanncbef3982018-07-30 09:22:40 +02003078 /* Wait to avoid a possible race condition if a paging message is
3079 * received right before the reset ACK. */
3080 f_sleep(0.2);
3081
Harald Welte10985002017-12-12 09:29:15 +01003082 /* Clear the queue, it might still contain stuff like BCCH FILLING */
Philipp Maier1e6b4422018-02-23 14:02:13 +01003083 for (var integer i := 0; i < sizeof(IPA_RSL); i := i+1) {
3084 IPA_RSL[i].clear;
3085 }
Harald Welte10985002017-12-12 09:29:15 +01003086
3087 /* Wait for 3 seconds if any more PAGING CMD are received on RSL */
3088 T.start;
3089 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07003090 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD(?))) {
Harald Welte10985002017-12-12 09:29:15 +01003091 setverdict(fail, "Received PAGING after A-RESET");
Daniel Willmannafce8662018-07-06 23:11:32 +02003092 mtc.stop;
Harald Welte10985002017-12-12 09:29:15 +01003093 }
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07003094 [] IPA_RSL[1].receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD(?))) {
Harald Welte5d1a2202017-12-13 19:51:29 +01003095 setverdict(fail, "Received PAGING after A-RESET");
Daniel Willmannafce8662018-07-06 23:11:32 +02003096 mtc.stop;
Harald Welte5d1a2202017-12-13 19:51:29 +01003097 }
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07003098 [] IPA_RSL[2].receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD(?))) {
Harald Welte5d1a2202017-12-13 19:51:29 +01003099 setverdict(fail, "Received PAGING after A-RESET");
Daniel Willmannafce8662018-07-06 23:11:32 +02003100 mtc.stop;
Harald Welte5d1a2202017-12-13 19:51:29 +01003101 }
Harald Welte10985002017-12-12 09:29:15 +01003102 [] T.timeout {
3103 setverdict(pass);
3104 }
3105 }
Philipp Maier282ca4b2018-02-27 17:17:00 +01003106
3107 f_shutdown_helper();
Harald Welte10985002017-12-12 09:29:15 +01003108}
Harald Welteae026692017-12-09 01:03:01 +01003109
Philipp Maierf45824a2019-08-14 14:44:10 +02003110/* Verify how we handle unsolicited Paging Response. In case of an unsolicit
3111 * paging response we can not know which MSC is in charge, so we will blindly
3112 * pick the first configured MSC. This behavior is required in order to make
3113 * MT-CSFB calls working because in those cases the BSC can not know that the
3114 * MSC has already paged the subscriver via SGs. So any MT-CSFB call will look
3115 * like an unsolicited Paging Response to the MSC.
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01003116 */
3117testcase TC_paging_resp_unsol() runs on test_CT {
3118
3119 f_init(1);
Philipp Maierf45824a2019-08-14 14:44:10 +02003120 timer T := 5.0;
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01003121
3122 var BSSAP_N_CONNECT_ind rx_c_ind;
3123 var DchanTuple dt;
3124 var PDU_ML3_MS_NW l3 := valueof(ts_PAG_RESP(valueof(ts_MI_IMSI_LV('001010008880018'H))));
Philipp Maierf45824a2019-08-14 14:44:10 +02003125 var octetstring rr_pag_resp := enc_PDU_ML3_MS_NW(l3);
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01003126
3127 /* Send CHAN RQD and wait for allocation; acknowledge it */
3128 dt.rsl_chan_nr := f_chreq_act_ack();
3129
3130 /* Send unsolicited Paging response (no matching Paging CMD stored in BSC) */
3131 f_ipa_tx(0, ts_RSL_EST_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0)), enc_PDU_ML3_MS_NW(l3)));
3132
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01003133
Philipp Maierf45824a2019-08-14 14:44:10 +02003134 /* Expevct a CR with a matching Paging response on the A-Interface */
3135 T.start;
3136 alt {
3137 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(rr_pag_resp))) {
3138 setverdict(pass);
3139 }
3140 [] BSSAP.receive {
3141 setverdict(fail, "Received unexpected message on A-Interface!");
3142 }
3143 [] T.timeout {
3144 setverdict(fail, "Received nothing on A-Interface!");
3145 }
3146 }
3147
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003148 f_shutdown_helper();
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01003149}
3150
Harald Welte4e9b9cc2017-12-14 18:31:02 +01003151/* Test RSL link drop causes counter increment */
3152testcase TC_rsl_drop_counter() runs on test_CT {
3153 var integer rsl_fail;
3154
Harald Welte89d42e82017-12-17 16:42:41 +01003155 f_init(1);
Harald Welte4e9b9cc2017-12-14 18:31:02 +01003156
3157 rsl_fail := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "rsl_fail");
3158
3159 bts[0].rsl.vc_IPA.stop;
3160
3161 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "rsl_fail", rsl_fail+1);
3162
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003163 f_shutdown_helper();
Harald Welte4e9b9cc2017-12-14 18:31:02 +01003164}
3165
3166/* TODO: Test OML link drop causes counter increment */
3167
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003168/* The body of TC_rsl_unknown_unit_id() and TC_oml_unknown_unit_id() tests. */
3169function f_ipa_unknown_unit_id(integer mp_bsc_ipa_port) runs on test_CT return boolean {
3170 timer T := 10.0;
3171
3172 bts[0].rsl.id := "IPA-0-RSL";
3173 bts[0].rsl.vc_IPA := IPA_Emulation_CT.create(bts[0].rsl.id & "-IPA");
3174 bts[0].rsl.ccm_pars := c_IPA_default_ccm_pars;
3175 bts[0].rsl.ccm_pars.name := "Osmocom TTCN-3 BTS Simulator";
Oliver Smith92c2bdb2019-08-20 15:11:24 +02003176 bts[0].rsl.ccm_pars.unit_id := "99/0/0"; /* value which is unknown at BTS */
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003177
Pau Espin Pedrol9a5b8ff2021-01-04 19:01:31 +01003178 f_ipa_ctrl_start_client(mp_bsc_ip, mp_bsc_ctrl_port);
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003179
3180 f_init_mgcp("VirtMSC");
3181
3182 /* start RSL/OML connection (XXX re-uses RSL port/protocol definitions for OML) */
3183 map(bts[0].rsl.vc_IPA:IPA_PORT, system:IPA);
3184 connect(bts[0].rsl.vc_IPA:IPA_RSL_PORT, self:IPA_RSL[0]);
3185 bts[0].rsl.vc_IPA.start(IPA_Emulation.main_client(mp_bsc_ip, mp_bsc_ipa_port, "", 10000, bts[0].rsl.ccm_pars));
3186
3187 /* wait for IPA OML link to connect and then disconnect */
3188 T.start;
3189 alt {
Vadim Yanitskiya2afacc2020-05-18 21:16:19 +07003190 [] IPA_RSL[0].receive(tr_ASP_IPA_EV(ASP_IPA_EVENT_DOWN)) {
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003191 T.stop;
3192 return true;
3193 }
3194 [] IPA_RSL[0].receive { repeat }
3195 [] T.timeout {
Daniel Willmannafce8662018-07-06 23:11:32 +02003196 return false;
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003197 }
3198 }
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003199 return false;
3200}
3201
3202/* BSC should close an RSL connection from a BTS with unknown unit ID (OS#2714). */
3203testcase TC_rsl_unknown_unit_id() runs on test_CT {
3204 if (f_ipa_unknown_unit_id(mp_bsc_rsl_port)) {
3205 setverdict(pass);
3206 } else {
3207 setverdict(fail, "Timeout RSL waiting for connection to close");
3208 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003209 f_shutdown_helper();
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003210}
3211
3212
3213/* BSC should close an RSL connection from a BTS with unknown unit ID (OS#2714). */
3214testcase TC_oml_unknown_unit_id() runs on test_CT {
3215 if (f_ipa_unknown_unit_id(mp_bsc_oml_port)) {
3216 setverdict(pass);
3217 } else {
3218 setverdict(fail, "Timeout OML waiting for connection to close");
3219 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003220 f_shutdown_helper();
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003221}
3222
3223
Harald Weltec1a2fff2017-12-17 11:06:19 +01003224/***********************************************************************
Harald Welte6811d102019-04-14 22:23:14 +02003225 * "New world" test cases using RSL_Emulation + RAN_Emulation
Harald Weltec1a2fff2017-12-17 11:06:19 +01003226 ***********************************************************************/
3227
Harald Welte6811d102019-04-14 22:23:14 +02003228import from RAN_Emulation all;
Harald Welte47cd0e32020-08-21 12:39:11 +02003229import from BSSAP_LE_Emulation all;
Harald Weltec1a2fff2017-12-17 11:06:19 +01003230import from RSL_Emulation all;
3231import from MSC_ConnectionHandler all;
3232
3233type function void_fn(charstring id) runs on MSC_ConnHdlr;
3234
Harald Welte336820c2018-05-31 20:34:52 +02003235/* helper function to create and connect a MSC_ConnHdlr component */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003236private function f_connect_handler(inout MSC_ConnHdlr vc_conn, integer bssap_idx := 0) runs on test_CT {
3237 connect(vc_conn:RAN, g_bssap[bssap_idx].vc_RAN:PROC);
Daniel Willmann191e0d92018-01-17 12:44:35 +01003238 connect(vc_conn:MGCP_PROC, vc_MGCP:MGCP_PROC);
Harald Weltec1a2fff2017-12-17 11:06:19 +01003239 connect(vc_conn:RSL, bts[0].rsl.vc_RSL:CLIENT_PT);
Harald Weltef70df652018-01-29 22:00:23 +01003240 connect(vc_conn:RSL_PROC, bts[0].rsl.vc_RSL:RSL_PROC);
Philipp Maier88f4ae82018-03-01 14:00:58 +01003241 if (isvalue(bts[1])) {
Philipp Maier956a92f2018-02-16 10:58:07 +01003242 connect(vc_conn:RSL1, bts[1].rsl.vc_RSL:CLIENT_PT);
3243 connect(vc_conn:RSL1_PROC, bts[1].rsl.vc_RSL:RSL_PROC);
3244 }
Neels Hofmeyr91401012019-07-11 00:42:35 +02003245 if (isvalue(bts[2])) {
3246 connect(vc_conn:RSL2, bts[2].rsl.vc_RSL:CLIENT_PT);
3247 connect(vc_conn:RSL2_PROC, bts[2].rsl.vc_RSL:RSL_PROC);
3248 }
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003249 connect(vc_conn:BSSAP, g_bssap[bssap_idx].vc_RAN:CLIENT);
Neels Hofmeyrcfe44062020-10-15 02:28:08 +02003250 if (mp_enable_lcs_tests) {
3251 connect(vc_conn:BSSAP_LE, g_bssap_le.vc_BSSAP_LE:CLIENT);
3252 connect(vc_conn:BSSAP_LE_PROC, g_bssap_le.vc_BSSAP_LE:PROC);
3253 }
Daniel Willmann191e0d92018-01-17 12:44:35 +01003254 connect(vc_conn:MGCP, vc_MGCP:MGCP_CLIENT);
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +02003255 connect(vc_conn:MGCP_MULTI, vc_MGCP:MGCP_CLIENT_MULTI);
Daniel Willmannebdecc02020-08-12 15:30:17 +02003256 connect(vc_conn:STATSD_PROC, vc_STATSD:STATSD_PROC);
Harald Welte336820c2018-05-31 20:34:52 +02003257}
3258
3259function f_start_handler(void_fn fn, template (omit) TestHdlrParams pars := omit)
3260runs on test_CT return MSC_ConnHdlr {
3261 var charstring id := testcasename();
3262 var MSC_ConnHdlr vc_conn;
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003263 var integer bssap_idx := 0;
3264 if (isvalue(pars)) {
3265 bssap_idx := valueof(pars).mscpool.bssap_idx;
3266 }
Harald Welte336820c2018-05-31 20:34:52 +02003267 vc_conn := MSC_ConnHdlr.create(id);
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003268 f_connect_handler(vc_conn, bssap_idx);
Neels Hofmeyr1708d1b2020-10-10 16:56:48 +02003269 /* Emit a marker to appear in the SUT's own logging output */
3270 f_logp(BSCVTY, testcasename() & "() start");
Harald Weltea0630032018-03-20 21:09:55 +01003271 vc_conn.start(f_handler_init(fn, id, pars));
Harald Weltec1a2fff2017-12-17 11:06:19 +01003272 return vc_conn;
3273}
3274
Harald Weltea0630032018-03-20 21:09:55 +01003275/* first function inside ConnHdlr component; sets g_pars + starts function */
3276private function f_handler_init(void_fn fn, charstring id, template (omit) TestHdlrParams pars := omit)
3277runs on MSC_ConnHdlr {
3278 if (isvalue(pars)) {
3279 g_pars := valueof(pars);
3280 }
3281 fn.apply(id);
3282}
3283
Harald Welte3c86ea02018-05-10 22:28:05 +02003284/* Establish signalling channel (non-assignment case) followed by cipher mode */
3285private function f_tc_ciph_mode_a5(charstring id) runs on MSC_ConnHdlr {
Harald Welteed848512018-05-24 22:27:58 +02003286 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3287 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte3c86ea02018-05-10 22:28:05 +02003288 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeSIGNAL);
Philipp Maier23000732018-05-18 11:25:37 +02003289 ass_cmd.pdu.bssmap.assignmentRequest.circuitIdentityCode := omit;
3290 ass_cmd.pdu.bssmap.assignmentRequest.aoIPTransportLayer := omit;
3291 exp_compl.pdu.bssmap.assignmentComplete.circuitIdentityCode := omit;
3292 exp_compl.pdu.bssmap.assignmentComplete.aoIPTransportLayer := omit;
Harald Welte3c86ea02018-05-10 22:28:05 +02003293
Philipp Maier23000732018-05-18 11:25:37 +02003294 f_establish_fully(ass_cmd, exp_compl);
Harald Welte3c86ea02018-05-10 22:28:05 +02003295}
3296testcase TC_ciph_mode_a5_0() runs on test_CT {
3297 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02003298 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte3c86ea02018-05-10 22:28:05 +02003299 pars.encr := valueof(t_EncrParams('01'O, f_rnd_octstring(8)));
3300
3301 f_init(1, true);
3302 f_sleep(1.0);
3303 vc_conn := f_start_handler(refers(f_tc_ciph_mode_a5), pars);
3304 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003305 f_shutdown_helper();
Harald Welte3c86ea02018-05-10 22:28:05 +02003306}
3307testcase TC_ciph_mode_a5_1() runs on test_CT {
3308 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02003309 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte3c86ea02018-05-10 22:28:05 +02003310 pars.encr := valueof(t_EncrParams('02'O, f_rnd_octstring(8)));
3311
3312 f_init(1, true);
3313 f_sleep(1.0);
3314 vc_conn := f_start_handler(refers(f_tc_ciph_mode_a5), pars);
3315 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003316 f_shutdown_helper();
Harald Welte3c86ea02018-05-10 22:28:05 +02003317}
3318testcase TC_ciph_mode_a5_3() runs on test_CT {
3319 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02003320 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte3c86ea02018-05-10 22:28:05 +02003321 pars.encr := valueof(t_EncrParams('08'O, f_rnd_octstring(8)));
3322
3323 f_init(1, true);
3324 f_sleep(1.0);
3325 vc_conn := f_start_handler(refers(f_tc_ciph_mode_a5), pars);
3326 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003327 f_shutdown_helper();
Harald Welte3c86ea02018-05-10 22:28:05 +02003328}
Neels Hofmeyr81ad27f2021-06-11 00:09:40 +02003329/* Establish a Signalling channel with A5/4 encryption. */
3330testcase TC_ciph_mode_a5_4() runs on test_CT {
3331 var MSC_ConnHdlr vc_conn;
3332 var TestHdlrParams pars := f_gen_test_hdlr_pars();
3333 pars.encr := valueof(t_EncrParams('10'O, f_rnd_octstring(8), f_rnd_octstring(16)));
Harald Welte3c86ea02018-05-10 22:28:05 +02003334
Neels Hofmeyr81ad27f2021-06-11 00:09:40 +02003335 f_init(1, true);
3336 f_sleep(1.0);
3337 vc_conn := f_start_handler(refers(f_tc_ciph_mode_a5), pars);
3338 vc_conn.done;
3339 f_shutdown_helper();
3340}
Pau Espin Pedrol07866632020-09-03 19:10:55 +02003341/* establish initial channel, enable ciphering followed by assignment to ciphered channel */
3342private function f_tc_assignment_aoip_tla_v6(charstring id) runs on MSC_ConnHdlr {
3343 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3344 var PDU_BSSAP ass_cmd := f_gen_ass_req(aoip_tla := "::3");
3345 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3346 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
3347
3348 f_establish_fully(ass_cmd, exp_compl);
3349}
3350testcase TC_assignment_aoip_tla_v6() runs on test_CT {
3351 var MSC_ConnHdlr vc_conn;
3352 var TestHdlrParams pars := f_gen_test_hdlr_pars();
3353
3354 f_init(1, true);
3355 f_sleep(1.0);
3356 vc_conn := f_start_handler(refers(f_tc_assignment_aoip_tla_v6), pars);
3357 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003358 f_shutdown_helper();
Pau Espin Pedrol07866632020-09-03 19:10:55 +02003359}
3360
Harald Welte3c86ea02018-05-10 22:28:05 +02003361
3362/* establish initial channel, enable ciphering followed by assignment to ciphered channel */
Harald Welte651fcdc2018-05-10 20:23:16 +02003363private function f_tc_assignment_fr_a5(charstring id) runs on MSC_ConnHdlr {
Harald Welteed848512018-05-24 22:27:58 +02003364 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3365 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Weltec1a2fff2017-12-17 11:06:19 +01003366
Harald Welte552620d2017-12-16 23:21:36 +01003367 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3368 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
Harald Welte73cd2712017-12-17 00:44:52 +01003369
Harald Weltea0630032018-03-20 21:09:55 +01003370 f_establish_fully(ass_cmd, exp_compl);
Harald Welte552620d2017-12-16 23:21:36 +01003371}
Harald Welte552620d2017-12-16 23:21:36 +01003372testcase TC_assignment_fr_a5_0() runs on test_CT {
3373 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02003374 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte651fcdc2018-05-10 20:23:16 +02003375 pars.encr := valueof(t_EncrParams('01'O, f_rnd_octstring(8)));
Harald Welte552620d2017-12-16 23:21:36 +01003376
Harald Welte89d42e82017-12-17 16:42:41 +01003377 f_init(1, true);
Harald Welte552620d2017-12-16 23:21:36 +01003378 f_sleep(1.0);
Harald Welte651fcdc2018-05-10 20:23:16 +02003379 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5), pars);
Harald Welte552620d2017-12-16 23:21:36 +01003380 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003381 f_shutdown_helper();
Harald Welte552620d2017-12-16 23:21:36 +01003382}
Harald Welte552620d2017-12-16 23:21:36 +01003383testcase TC_assignment_fr_a5_1() runs on test_CT {
Harald Weltec1a2fff2017-12-17 11:06:19 +01003384 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02003385 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte651fcdc2018-05-10 20:23:16 +02003386 pars.encr := valueof(t_EncrParams('02'O, f_rnd_octstring(8)));
Harald Weltec1a2fff2017-12-17 11:06:19 +01003387
Harald Welte89d42e82017-12-17 16:42:41 +01003388 f_init(1, true);
Harald Weltec1a2fff2017-12-17 11:06:19 +01003389 f_sleep(1.0);
Harald Welte651fcdc2018-05-10 20:23:16 +02003390 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5), pars);
3391 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003392 f_shutdown_helper();
Harald Welte651fcdc2018-05-10 20:23:16 +02003393}
3394testcase TC_assignment_fr_a5_3() runs on test_CT {
3395 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02003396 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte651fcdc2018-05-10 20:23:16 +02003397 pars.encr := valueof(t_EncrParams('08'O, f_rnd_octstring(8)));
Harald Weltec1a2fff2017-12-17 11:06:19 +01003398
Harald Welte651fcdc2018-05-10 20:23:16 +02003399 f_init(1, true);
3400 f_sleep(1.0);
3401 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5), pars);
Harald Weltec1a2fff2017-12-17 11:06:19 +01003402 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003403 f_shutdown_helper();
Harald Weltec1a2fff2017-12-17 11:06:19 +01003404}
Neels Hofmeyr0d8ec532021-06-11 00:09:48 +02003405/* Establish a Signalling channel and re-assign to TCH/F with A5/4 encryption. */
3406testcase TC_assignment_fr_a5_4() runs on test_CT {
3407 var MSC_ConnHdlr vc_conn;
3408 var TestHdlrParams pars := f_gen_test_hdlr_pars();
3409 pars.encr := valueof(t_EncrParams('10'O, f_rnd_octstring(8), f_rnd_octstring(16)));
3410
3411 f_init(1, true);
3412 f_sleep(1.0);
3413 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5), pars);
3414 vc_conn.done;
3415 f_shutdown_helper();
3416}
Harald Weltec1a2fff2017-12-17 11:06:19 +01003417
Neels Hofmeyr0faeb7a2021-06-10 23:59:35 +02003418/* Allow only A5/4, but omit the Kc128 IE from MSC's msg. Expect Cipher Mode Reject. */
3419testcase TC_assignment_fr_a5_4_fail() runs on test_CT {
3420 var TestHdlrParams pars := f_gen_test_hdlr_pars();
3421 var MSC_ConnHdlr vc_conn;
3422
3423 f_init(1, true);
3424 f_sleep(1.0);
3425
3426 pars.encr := valueof(t_EncrParams('10'O, f_rnd_octstring(8))); // A5/4 support, but Kc128 missing!
3427 vc_conn := f_start_handler(refers(f_TC_assignment_a5_not_sup), pars);
3428 vc_conn.done;
3429 f_shutdown_helper();
3430}
3431
Harald Welte552620d2017-12-16 23:21:36 +01003432/* Expect ASSIGNMENT FAIL if mandatory IE is missing */
3433private function f_tc_assignment_fr_a5_1_codec_missing(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02003434 g_pars := f_gen_test_hdlr_pars();
Harald Welte552620d2017-12-16 23:21:36 +01003435 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
Harald Welteed848512018-05-24 22:27:58 +02003436 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte552620d2017-12-16 23:21:36 +01003437 const OCT8 kc := '0001020304050607'O;
3438
3439 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02003440 /* Omit: ass_cmd.pdu.bssmap.assignmentRequest.codecList */
3441
Harald Weltea0630032018-03-20 21:09:55 +01003442 f_establish_fully(ass_cmd, exp_fail);
Harald Welte552620d2017-12-16 23:21:36 +01003443}
Harald Welte552620d2017-12-16 23:21:36 +01003444testcase TC_assignment_fr_a5_1_codec_missing() runs on test_CT {
3445 var MSC_ConnHdlr vc_conn;
3446
Harald Welte89d42e82017-12-17 16:42:41 +01003447 f_init(1, true);
Harald Welte552620d2017-12-16 23:21:36 +01003448 f_sleep(1.0);
3449
Harald Welte8863fa12018-05-10 20:15:27 +02003450 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5_1_codec_missing));
Harald Welte552620d2017-12-16 23:21:36 +01003451 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003452 f_shutdown_helper();
Harald Welte552620d2017-12-16 23:21:36 +01003453}
3454
Neels Hofmeyr04d6e6a2021-06-11 00:10:02 +02003455private function f_TC_assignment_a5_not_sup(charstring id) runs on MSC_ConnHdlr {
3456 var template PDU_BSSAP exp_ass_cpl := f_gen_exp_compl();
3457 var PDU_BSSAP exp_ass_req := f_gen_ass_req();
Harald Welte552620d2017-12-16 23:21:36 +01003458
Neels Hofmeyr04d6e6a2021-06-11 00:10:02 +02003459 exp_ass_req.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3460 exp_ass_req.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
3461
3462 /* this is like the beginning of f_establish_fully(), but only up to ciphering reject */
3463
3464 var BSSMAP_FIELD_CodecType codecType;
3465 timer T := 10.0;
3466
3467 codecType := exp_ass_req.pdu.bssmap.assignmentRequest.codecList.codecElements[0].codecType;
3468 f_MscConnHdlr_init(g_pars.media_nr, host_bts, host_mgw_mgcp, codecType);
3469
3470 f_create_chan_and_exp();
3471 /* we should now have a COMPL_L3 at the MSC */
3472
3473 var template PDU_BSSAP exp_l3_compl;
3474 exp_l3_compl := tr_BSSMAP_ComplL3()
3475 if (g_pars.aoip == false) {
3476 exp_l3_compl.pdu.bssmap.completeLayer3Information.codecList := omit;
3477 } else {
3478 exp_l3_compl.pdu.bssmap.completeLayer3Information.codecList := ?;
3479 }
3480 T.start;
3481 alt {
3482 [] BSSAP.receive(exp_l3_compl);
3483 [] BSSAP.receive(tr_BSSMAP_ComplL3) {
3484 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Received non-matching COMPLETE LAYER 3 INFORMATION");
3485 }
3486 [] T.timeout {
3487 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for COMPLETE LAYER 3 INFORMATION");
3488 }
3489 }
3490
3491 /* Start ciphering, expect Cipher Mode Reject */
Neels Hofmeyr6c388f22021-06-11 02:36:56 +02003492 f_cipher_mode(g_pars.encr, exp_fail := true);
Harald Welte552620d2017-12-16 23:21:36 +01003493}
Neels Hofmeyr04d6e6a2021-06-11 00:10:02 +02003494testcase TC_assignment_fr_a5_not_sup() runs on test_CT {
3495 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte552620d2017-12-16 23:21:36 +01003496 var MSC_ConnHdlr vc_conn;
3497
Harald Welte89d42e82017-12-17 16:42:41 +01003498 f_init(1, true);
Harald Welte552620d2017-12-16 23:21:36 +01003499 f_sleep(1.0);
3500
Neels Hofmeyr0588cad2021-06-11 01:38:18 +02003501 pars.encr := valueof(t_EncrParams('20'O, f_rnd_octstring(8), f_rnd_octstring(16)));
Neels Hofmeyr04d6e6a2021-06-11 00:10:02 +02003502 vc_conn := f_start_handler(refers(f_TC_assignment_a5_not_sup), pars);
Harald Welte552620d2017-12-16 23:21:36 +01003503 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003504 f_shutdown_helper();
Harald Welte552620d2017-12-16 23:21:36 +01003505}
3506
3507
Harald Welte4532e0a2017-12-23 02:05:44 +01003508private function f_tc_assignment_sign(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02003509 g_pars := f_gen_test_hdlr_pars();
Harald Welte4532e0a2017-12-23 02:05:44 +01003510 var template PDU_BSSAP exp_compl := tr_BSSMAP_AssignmentComplete(omit, omit);
Philipp Maier48604732018-10-09 15:00:37 +02003511 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte4532e0a2017-12-23 02:05:44 +01003512 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeSIGNAL);
Daniel Willmannebdecc02020-08-12 15:30:17 +02003513
3514 f_statsd_reset();
Harald Weltea0630032018-03-20 21:09:55 +01003515 f_establish_fully(ass_cmd, exp_compl);
Daniel Willmannebdecc02020-08-12 15:30:17 +02003516
3517 var StatsDExpects expect := {
Daniel Willmannc5398f72020-09-21 10:41:35 +02003518 { name := "TTCN3.bts.0.chreq.total", mtype := "c", min := 1, max := 1},
3519 { name := "TTCN3.bts.0.chreq.successful", mtype := "c", min := 1, max := 1},
Daniel Willmannebdecc02020-08-12 15:30:17 +02003520 { name := "TTCN3.bsc.0.assignment.attempted", mtype := "c", min := 1, max := 1},
3521 { name := "TTCN3.bsc.0.assignment.completed", mtype := "c", min := 1, max := 1}
3522 };
3523 f_statsd_expect(expect);
Harald Welte4532e0a2017-12-23 02:05:44 +01003524}
3525
3526testcase TC_assignment_sign() runs on test_CT {
3527 var MSC_ConnHdlr vc_conn;
3528
3529 f_init(1, true);
3530 f_sleep(1.0);
3531
Harald Welte8863fa12018-05-10 20:15:27 +02003532 vc_conn := f_start_handler(refers(f_tc_assignment_sign));
Harald Welte4532e0a2017-12-23 02:05:44 +01003533 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003534 f_shutdown_helper();
Harald Welte4532e0a2017-12-23 02:05:44 +01003535}
3536
Harald Welte60aa5762018-03-21 19:33:13 +01003537/***********************************************************************
3538 * Codec (list) testing
3539 ***********************************************************************/
3540
3541/* check if the given rsl_mode is compatible with the a_elem */
3542private function f_match_codec(BSSMAP_FIELD_CodecElement a_elem, RSL_IE_ChannelMode rsl_mode)
3543return boolean {
3544 select (a_elem.codecType) {
3545 case (GSM_FR) {
3546 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM1))) {
3547 return true;
3548 }
3549 }
3550 case (GSM_HR) {
3551 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_H, RSL_CMOD_SP_GSM1))) {
3552 return true;
3553 }
3554 }
3555 case (GSM_EFR) {
3556 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM2))) {
3557 return true;
3558 }
3559 }
3560 case (FR_AMR) {
3561 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM3))) {
3562 return true;
3563 }
3564 }
3565 case (HR_AMR) {
3566 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_H, RSL_CMOD_SP_GSM3))) {
3567 return true;
3568 }
3569 }
3570 case else { }
3571 }
3572 return false;
3573}
3574
3575/* check if the given rsl_mode is compatible with the a_list */
3576private function f_match_codecs(BSSMAP_IE_SpeechCodecList a_list, RSL_IE_ChannelMode rsl_mode)
3577return boolean {
3578 for (var integer i := 0; i < sizeof(a_list); i := i+1) {
3579 if (f_match_codec(a_list.codecElements[i], rsl_mode)) {
3580 return true;
3581 }
3582 }
3583 return false;
3584}
3585
3586/* determine BSSMAP_IE_ChannelType from *first* element of BSSMAP_FIELD_CodecElement */
Philipp Maier61f6b572018-07-06 14:03:38 +02003587function f_BSSMAP_chtype_from_codec(BSSMAP_FIELD_CodecElement a_elem)
Harald Welte60aa5762018-03-21 19:33:13 +01003588return BSSMAP_IE_ChannelType {
3589 /* FIXME: actually look at all elements of BSSMAP_IE_SpeechCodecList */
3590 var BSSMAP_IE_ChannelType ret := valueof(ts_BSSMAP_IE_ChannelType);
3591 select (a_elem.codecType) {
3592 case (GSM_FR) {
3593 ret.channelRateAndType := ChRate_TCHF;
3594 ret.speechId_DataIndicator := Spdi_TCHF_FR;
3595 }
3596 case (GSM_HR) {
3597 ret.channelRateAndType := ChRate_TCHH;
3598 ret.speechId_DataIndicator := Spdi_TCHH_HR;
3599 }
3600 case (GSM_EFR) {
3601 ret.channelRateAndType := ChRate_TCHF;
3602 ret.speechId_DataIndicator := Spdi_TCHF_EFR;
3603 }
3604 case (FR_AMR) {
3605 ret.channelRateAndType := ChRate_TCHF;
3606 ret.speechId_DataIndicator := Spdi_TCHF_AMR;
3607 }
3608 case (HR_AMR) {
3609 ret.channelRateAndType := ChRate_TCHH;
3610 ret.speechId_DataIndicator := Spdi_TCHH_AMR;
3611 }
3612 case else {
3613 setverdict(fail, "Unsupported codec ", a_elem);
Daniel Willmannafce8662018-07-06 23:11:32 +02003614 mtc.stop;
Harald Welte60aa5762018-03-21 19:33:13 +01003615 }
3616 }
3617 return ret;
3618}
3619
Harald Weltea63b9102018-03-22 20:36:16 +01003620private function f_rsl_chmod_tmpl_from_codec(BSSMAP_FIELD_CodecElement a_elem)
3621return template RSL_IE_Body {
3622 var template RSL_IE_Body mode_ie := {
3623 chan_mode := {
3624 len := ?,
3625 reserved := ?,
3626 dtx_d := ?,
3627 dtx_u := ?,
3628 spd_ind := RSL_SPDI_SPEECH,
3629 ch_rate_type := -,
3630 coding_alg_rate := -
3631 }
3632 }
3633
3634 select (a_elem.codecType) {
3635 case (GSM_FR) {
3636 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_F;
3637 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM1;
3638 }
3639 case (GSM_HR) {
3640 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_H;
3641 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM1;
3642 }
3643 case (GSM_EFR) {
3644 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_F;
3645 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM2;
3646 }
3647 case (FR_AMR) {
3648 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_F;
3649 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM3;
3650 }
3651 case (HR_AMR) {
3652 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_H;
3653 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM3;
3654 }
3655 }
3656 return mode_ie;
3657}
3658
Harald Welte60aa5762018-03-21 19:33:13 +01003659type record CodecListTest {
3660 BSSMAP_IE_SpeechCodecList codec_list,
3661 charstring id
3662}
3663type record of CodecListTest CodecListTests
3664
3665private function f_TC_assignment_codec(charstring id) runs on MSC_ConnHdlr {
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02003666 var PDU_BSSAP ass_cmd := f_gen_ass_req(g_pars.use_osmux);
3667 var template PDU_BSSAP exp_compl := f_gen_exp_compl(g_pars.use_osmux);
Harald Welte60aa5762018-03-21 19:33:13 +01003668
3669 /* puzzle together the ASSIGNMENT REQ for given codec[s] */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003670 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
Harald Welte79f3f542018-05-25 20:02:37 +02003671 ass_cmd.pdu.bssmap.assignmentRequest.codecList := g_pars.ass_codec_list;
3672 exp_compl.pdu.bssmap.assignmentComplete.speechCodec.codecElements[0] :=
3673 g_pars.ass_codec_list.codecElements[0];
Philipp Maierd0e64b02019-03-13 14:15:23 +01003674 if (isvalue(g_pars.expect_mr_s0_s7)) {
3675 exp_compl.pdu.bssmap.assignmentComplete.speechCodec.codecElements[0].s0_7 :=
3676 g_pars.expect_mr_s0_s7;
3677 }
Harald Welte79f3f542018-05-25 20:02:37 +02003678 }
Harald Welte60aa5762018-03-21 19:33:13 +01003679 ass_cmd.pdu.bssmap.assignmentRequest.channelType :=
3680 f_BSSMAP_chtype_from_codec(g_pars.ass_codec_list.codecElements[0]);
Harald Welte60aa5762018-03-21 19:33:13 +01003681 log("expecting ASS COMPL like this: ", exp_compl);
3682
3683 f_establish_fully(ass_cmd, exp_compl);
Harald Weltea63b9102018-03-22 20:36:16 +01003684
Neels Hofmeyr559d5d02021-04-16 16:50:49 +02003685 if (not g_pars.expect_channel_mode_modify) {
3686 /* Verify that the RSL-side activation actually matches our expectations */
3687 var RSL_Message rsl := f_rslem_get_last_act(RSL_PROC, 0, g_chan_nr);
Harald Weltea63b9102018-03-22 20:36:16 +01003688
Neels Hofmeyr559d5d02021-04-16 16:50:49 +02003689 var RSL_IE_Body mode_ie;
3690 if (f_rsl_find_ie(rsl, RSL_IE_CHAN_MODE, mode_ie) == false) {
3691 setverdict(fail, "Couldn't find CHAN_MODE IE");
Daniel Willmannafce8662018-07-06 23:11:32 +02003692 mtc.stop;
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02003693 }
Neels Hofmeyr559d5d02021-04-16 16:50:49 +02003694 var template RSL_IE_Body t_mode_ie := f_rsl_chmod_tmpl_from_codec(g_pars.ass_codec_list.codecElements[0]);
3695 if (not match(mode_ie, t_mode_ie)) {
3696 log("mode_ie ", mode_ie, " != t_mode_ie ", t_mode_ie);
3697 setverdict(fail, "RSL Channel Mode IE doesn't match expectation");
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02003698 }
Neels Hofmeyr559d5d02021-04-16 16:50:49 +02003699
3700 var RSL_IE_Body mr_conf;
3701 if (g_pars.expect_mr_conf_ie != omit) {
3702 if (f_rsl_find_ie(rsl, RSL_IE_MR_CONFIG, mr_conf) == false) {
3703 setverdict(fail, "Missing MR CONFIG IE in RSL Chan Activ");
3704 mtc.stop;
3705 }
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02003706 log("found RSL MR CONFIG IE: ", mr_conf);
Neels Hofmeyr559d5d02021-04-16 16:50:49 +02003707
3708 if (not match(mr_conf, g_pars.expect_mr_conf_ie)) {
3709 setverdict(fail, "RSL MR CONFIG IE does not match expectation. Expected: ",
3710 g_pars.expect_mr_conf_ie);
3711 }
3712 } else {
3713 if (f_rsl_find_ie(rsl, RSL_IE_MR_CONFIG, mr_conf) == true) {
3714 log("found RSL MR CONFIG IE: ", mr_conf);
3715 setverdict(fail, "Found MR CONFIG IE in RSL Chan Activ, expecting omit");
3716 mtc.stop;
3717 }
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02003718 }
3719 }
Harald Welte60aa5762018-03-21 19:33:13 +01003720}
3721
Philipp Maierd0e64b02019-03-13 14:15:23 +01003722private function f_TC_assignment_codec_fail(charstring id) runs on MSC_ConnHdlr {
3723
3724 var PDU_BSSAP ass_cmd := f_gen_ass_req();
3725 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
3726
3727 /* puzzle together the ASSIGNMENT REQ for given codec[s] */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003728 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
Philipp Maierd0e64b02019-03-13 14:15:23 +01003729 ass_cmd.pdu.bssmap.assignmentRequest.codecList := g_pars.ass_codec_list;
3730 }
3731 ass_cmd.pdu.bssmap.assignmentRequest.channelType :=
3732 f_BSSMAP_chtype_from_codec(g_pars.ass_codec_list.codecElements[0]);
3733 log("expecting ASS FAIL like this: ", exp_fail);
3734
3735 f_establish_fully(ass_cmd, exp_fail);
3736}
3737
Harald Welte60aa5762018-03-21 19:33:13 +01003738testcase TC_assignment_codec_fr() runs on test_CT {
Philipp Maier48604732018-10-09 15:00:37 +02003739 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte60aa5762018-03-21 19:33:13 +01003740 var MSC_ConnHdlr vc_conn;
3741
3742 f_init(1, true);
3743 f_sleep(1.0);
3744
3745 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
Harald Welte8863fa12018-05-10 20:15:27 +02003746 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01003747 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003748 f_shutdown_helper();
Harald Welte60aa5762018-03-21 19:33:13 +01003749}
3750
3751testcase TC_assignment_codec_hr() runs on test_CT {
Philipp Maier48604732018-10-09 15:00:37 +02003752 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte60aa5762018-03-21 19:33:13 +01003753 var MSC_ConnHdlr vc_conn;
3754
3755 f_init(1, true);
3756 f_sleep(1.0);
3757
3758 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR}));
Harald Welte8863fa12018-05-10 20:15:27 +02003759 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01003760 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003761 f_shutdown_helper();
Harald Welte60aa5762018-03-21 19:33:13 +01003762}
3763
3764testcase TC_assignment_codec_efr() runs on test_CT {
Philipp Maier48604732018-10-09 15:00:37 +02003765 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte60aa5762018-03-21 19:33:13 +01003766 var MSC_ConnHdlr vc_conn;
3767
3768 f_init(1, true);
3769 f_sleep(1.0);
3770
3771 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecEFR}));
Harald Welte8863fa12018-05-10 20:15:27 +02003772 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01003773 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003774 f_shutdown_helper();
Harald Welte60aa5762018-03-21 19:33:13 +01003775}
3776
Philipp Maierd0e64b02019-03-13 14:15:23 +01003777/* Allow 5,90k only (current default config) */
3778private function f_allow_amr_rate_5_90k() runs on test_CT {
Neels Hofmeyr2a5670b2020-11-25 23:39:57 +00003779 f_vty_cfg_msc(BSCVTY, 0, {
3780 "amr-config 12_2k forbidden",
3781 "amr-config 10_2k forbidden",
3782 "amr-config 7_95k forbidden",
3783 "amr-config 7_40k forbidden",
3784 "amr-config 6_70k forbidden",
3785 "amr-config 5_90k allowed",
3786 "amr-config 5_15k forbidden",
3787 "amr-config 4_75k forbidden"
3788 });
Philipp Maierd0e64b02019-03-13 14:15:23 +01003789}
3790
3791/* Allow 4,75k, 5,90k, 4,70k and 12,2k, which are the most common rates
3792 * ("Config-NB-Code = 1") */
3793private function f_allow_amr_rate_4_75k_5_90k_7_40k_12_20k() runs on test_CT {
Neels Hofmeyr2a5670b2020-11-25 23:39:57 +00003794 f_vty_cfg_msc(BSCVTY, 0, {
3795 "amr-config 12_2k allowed",
3796 "amr-config 10_2k forbidden",
3797 "amr-config 7_95k forbidden",
3798 "amr-config 7_40k allowed",
3799 "amr-config 6_70k forbidden",
3800 "amr-config 5_90k allowed",
3801 "amr-config 5_15k forbidden",
3802 "amr-config 4_75k allowed"
3803 });
Philipp Maierd0e64b02019-03-13 14:15:23 +01003804}
3805
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00003806private function f_vty_amr_start_mode_set(boolean fr, charstring startmode) runs on test_CT {
3807 var charstring tch;
3808 if (fr) {
3809 tch := "tch-f";
3810 } else {
3811 tch := "tch-h";
3812 }
3813 f_vty_cfg_bts(BSCVTY, 0, { "amr " & tch & " start-mode " & startmode });
3814}
3815
3816/* Set the AMR start-mode for this TCH back to the default configuration. */
3817private function f_vty_amr_start_mode_restore(boolean fr) runs on test_CT {
3818 f_vty_amr_start_mode_set(fr, "auto");
3819}
3820
Harald Welte60aa5762018-03-21 19:33:13 +01003821testcase TC_assignment_codec_amr_f() runs on test_CT {
Philipp Maier48604732018-10-09 15:00:37 +02003822 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte60aa5762018-03-21 19:33:13 +01003823 var MSC_ConnHdlr vc_conn;
Philipp Maier7695a0d2018-09-27 17:52:14 +02003824
3825 /* Note: This setups the codec configuration. The parameter payload in
3826 * mr_conf must be consistant with the parameter codecElements in pars
3827 * and also must match the amr-config in osmo-bsc.cfg! */
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02003828 var RSL_IE_Body mr_conf := {
3829 other := {
3830 len := 2,
3831 payload := '2804'O
3832 }
3833 };
Harald Welte60aa5762018-03-21 19:33:13 +01003834
Philipp Maier7695a0d2018-09-27 17:52:14 +02003835 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_F}));
Philipp Maier806f8f12019-03-12 12:13:41 +01003836 pars.ass_codec_list.codecElements[0].s0_7 := '00000100'B; /* 5,90k */
Philipp Maier7695a0d2018-09-27 17:52:14 +02003837 pars.ass_codec_list.codecElements[0].s8_15 := '01010111'B;
3838 pars.expect_mr_conf_ie := mr_conf;
3839
Harald Welte60aa5762018-03-21 19:33:13 +01003840 f_init(1, true);
3841 f_sleep(1.0);
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00003842 f_vty_amr_start_mode_set(true, "1");
Harald Welte60aa5762018-03-21 19:33:13 +01003843
Harald Welte8863fa12018-05-10 20:15:27 +02003844 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01003845 vc_conn.done;
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00003846
3847 f_vty_amr_start_mode_restore(true);
Vadim Yanitskiy292e5962021-01-03 14:18:47 +01003848 f_shutdown_helper();
Harald Welte60aa5762018-03-21 19:33:13 +01003849}
3850
3851testcase TC_assignment_codec_amr_h() runs on test_CT {
Philipp Maier48604732018-10-09 15:00:37 +02003852 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte60aa5762018-03-21 19:33:13 +01003853 var MSC_ConnHdlr vc_conn;
Philipp Maier7695a0d2018-09-27 17:52:14 +02003854
3855 /* See note above */
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02003856 var RSL_IE_Body mr_conf := {
3857 other := {
3858 len := 2,
3859 payload := '2804'O
3860 }
3861 };
Harald Welte60aa5762018-03-21 19:33:13 +01003862
Philipp Maier7695a0d2018-09-27 17:52:14 +02003863 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_H}));
Philipp Maier806f8f12019-03-12 12:13:41 +01003864 pars.ass_codec_list.codecElements[0].s0_7 := '00000100'B; /* 5,90k */
Philipp Maier7695a0d2018-09-27 17:52:14 +02003865 pars.ass_codec_list.codecElements[0].s8_15 := '00000111'B;
3866 pars.expect_mr_conf_ie := mr_conf;
3867
Harald Welte60aa5762018-03-21 19:33:13 +01003868 f_init(1, true);
3869 f_sleep(1.0);
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00003870 f_vty_amr_start_mode_set(false, "1");
Harald Welte60aa5762018-03-21 19:33:13 +01003871
Harald Welte8863fa12018-05-10 20:15:27 +02003872 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01003873 vc_conn.done;
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00003874
3875 f_vty_amr_start_mode_restore(false);
Vadim Yanitskiy292e5962021-01-03 14:18:47 +01003876 f_shutdown_helper();
Harald Welte60aa5762018-03-21 19:33:13 +01003877}
3878
Neels Hofmeyr559d5d02021-04-16 16:50:49 +02003879/* Establish signalling on a TCH/F lchan, and then switch to speech mode without a new Assignment. */
3880testcase TC_assignment_codec_fr_by_mode_modify() runs on test_CT {
3881 var TestHdlrParams pars := f_gen_test_hdlr_pars();
3882 var MSC_ConnHdlr vc_conn;
3883
3884 f_init(1, true);
3885 f_sleep(1.0);
3886
3887 /* By disabling all SDCCH, the MS should be given a TCH/F for signalling. Then activating an FR codec should
3888 * merely do a Channel Mode Modify, and not assign to a new lchan. f_establish_fully() already accounts for
3889 * expecting a Channel Mode Modify if the channel type is compatible. */
3890 f_disable_all_sdcch();
3891 f_disable_all_tch_h();
3892
3893 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
3894 pars.expect_channel_mode_modify := true;
3895 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
3896 vc_conn.done;
3897
3898 f_enable_all_sdcch();
3899 f_enable_all_tch();
3900 f_shutdown_helper();
3901}
3902
Neels Hofmeyr454d7922020-11-26 02:24:57 +00003903/* 'amr start-mode auto' should not keep the (unused) 'smod' bits from previous configuration */
3904testcase TC_assignment_codec_amr_startmode_cruft() runs on test_CT {
3905 var TestHdlrParams pars := f_gen_test_hdlr_pars();
3906 var MSC_ConnHdlr vc_conn;
3907
3908 var RSL_IE_Body mr_conf := {
3909 other := {
3910 len := 2,
3911 payload := '2004'O /* <- expect ICMI=0, smod=00 */
3912 }
3913 };
3914
3915 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_F}));
3916 pars.ass_codec_list.codecElements[0].s0_7 := '00000100'B; /* 5,90k */
3917 pars.ass_codec_list.codecElements[0].s8_15 := '01010111'B;
3918 pars.expect_mr_conf_ie := mr_conf;
3919
3920 f_init(1, true);
3921 f_sleep(1.0);
3922
3923 /* First set nonzero start mode bits */
3924 f_vty_amr_start_mode_set(true, "4");
3925 /* Now set to auto, and expect the startmode bits to be zero in the message, i.e. ensure that osmo-bsc does not
3926 * let the startmode bits stick around and has deterministic MultiRate config for 'start-mode auto'; that is
3927 * ensured by above '2004'O, where 'x0xx'O indicates ICMI = 0, spare = 0, smod = 00. */
3928 f_vty_amr_start_mode_set(true, "auto");
3929
3930 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
3931 vc_conn.done;
Neels Hofmeyr454d7922020-11-26 02:24:57 +00003932
3933 /* Clear the startmode bits to not affect subsequent tests, in case the bits should indeed stick around. */
3934 f_vty_amr_start_mode_set(true, "1");
3935 f_vty_amr_start_mode_restore(true);
Vadim Yanitskiy292e5962021-01-03 14:18:47 +01003936 f_shutdown_helper();
Neels Hofmeyr454d7922020-11-26 02:24:57 +00003937}
3938
Neels Hofmeyr21863562020-11-26 00:34:33 +00003939function f_TC_assignment_codec_amr(boolean fr, octetstring mrconf, bitstring s8_s0, bitstring exp_s8_s0,
3940 charstring start_mode := "1")
Philipp Maierd0e64b02019-03-13 14:15:23 +01003941runs on test_CT {
3942
3943 var TestHdlrParams pars := f_gen_test_hdlr_pars();
3944 var MSC_ConnHdlr vc_conn;
3945
3946 /* See note above */
3947 var RSL_IE_Body mr_conf := {
3948 other := {
3949 len := lengthof(mrconf),
3950 payload := mrconf
3951 }
3952 };
3953
3954 if (fr) {
3955 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_F}));
3956 } else {
3957 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_H}));
3958 }
3959 pars.ass_codec_list.codecElements[0].s0_7 := s8_s0;
3960 pars.ass_codec_list.codecElements[0].s8_15 := '00000111'B;
3961 pars.expect_mr_conf_ie := mr_conf;
3962 pars.expect_mr_s0_s7 := exp_s8_s0;
3963
3964 f_init(1, true);
3965 f_allow_amr_rate_4_75k_5_90k_7_40k_12_20k();
Neels Hofmeyr21863562020-11-26 00:34:33 +00003966 f_vty_amr_start_mode_set(fr, start_mode);
Philipp Maierd0e64b02019-03-13 14:15:23 +01003967 f_sleep(1.0);
3968
3969 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
3970 vc_conn.done;
3971 f_allow_amr_rate_5_90k();
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00003972 f_vty_amr_start_mode_restore(fr);
Philipp Maierd0e64b02019-03-13 14:15:23 +01003973}
3974
3975function f_TC_assignment_codec_amr_fail(boolean fr, bitstring s8_s0)
3976runs on test_CT {
3977
3978 var TestHdlrParams pars := f_gen_test_hdlr_pars();
3979 var MSC_ConnHdlr vc_conn;
3980
3981 if (fr) {
3982 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_F}));
3983 } else {
3984 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_H}));
3985 }
3986 pars.ass_codec_list.codecElements[0].s0_7 := s8_s0;
3987 pars.ass_codec_list.codecElements[0].s8_15 := '00000111'B;
3988
3989 f_init(1, true);
3990 f_allow_amr_rate_4_75k_5_90k_7_40k_12_20k();
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00003991 f_vty_amr_start_mode_set(fr, "1");
Philipp Maierd0e64b02019-03-13 14:15:23 +01003992 f_sleep(1.0);
3993
3994 vc_conn := f_start_handler(refers(f_TC_assignment_codec_fail), pars);
3995 vc_conn.done;
3996 f_allow_amr_rate_5_90k();
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00003997 f_vty_amr_start_mode_restore(fr);
Philipp Maierd0e64b02019-03-13 14:15:23 +01003998}
3999
4000
4001/* Set S1, we expect an AMR multirate configuration IE with all four rates
4002 * set. */
4003testcase TC_assignment_codec_amr_f_S1() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02004004 f_TC_assignment_codec_amr(true, '289520882208'O, '00000010'B, '00000010'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004005 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01004006}
4007
4008/* Set S1, we expect an AMR multirate configuration IE with the lower three
4009 * rates set. */
4010testcase TC_assignment_codec_amr_h_S1() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02004011 f_TC_assignment_codec_amr(false, '2815208820'O, '00000010'B, '00000010'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004012 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01004013}
4014
4015/* Set S1 and two other rates, we expect an AMR MULTIRATE CONFIGURATION IE with
4016 * all four rates (and only S1 set in the ASSIGNMENT COMPLETE) */
4017testcase TC_assignment_codec_amr_f_S124() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02004018 f_TC_assignment_codec_amr(true, '289520882208'O, '00010110'B, '00000010'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004019 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01004020}
4021
4022/* Set S1 and two other rates, we expect an AMR MULTIRATE CONFIGURATION IE with
4023 * all four rates (and only S1 set in the ASSIGNMENT COMPLETE) */
4024testcase TC_assignment_codec_amr_h_S124() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02004025 f_TC_assignment_codec_amr(false, '2815208820'O, '00010110'B, '00000010'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004026 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01004027}
4028
4029/* The following block of tests selects more and more rates until all four
4030 * possible rates are in the active set (full rate) */
4031testcase TC_assignment_codec_amr_f_S0() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02004032 f_TC_assignment_codec_amr(true, '2801'O, '00000001'B, '00000001'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004033 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01004034}
4035
4036testcase TC_assignment_codec_amr_f_S02() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02004037 f_TC_assignment_codec_amr(true, '28052080'O, '00000101'B, '00000101'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004038 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01004039}
4040
4041testcase TC_assignment_codec_amr_f_S024() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02004042 f_TC_assignment_codec_amr(true, '2815208820'O, '00010101'B, '00010101'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004043 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01004044}
4045
4046testcase TC_assignment_codec_amr_f_S0247() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02004047 f_TC_assignment_codec_amr(true, '289520882208'O, '10010101'B, '10010101'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004048 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01004049}
4050
4051/* The following block of tests selects more and more rates until all three
4052 * possible rates are in the active set (half rate) */
4053testcase TC_assignment_codec_amr_h_S0() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02004054 f_TC_assignment_codec_amr(false, '2801'O, '00000001'B, '00000001'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004055 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01004056}
4057
4058testcase TC_assignment_codec_amr_h_S02() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02004059 f_TC_assignment_codec_amr(false, '28052080'O, '00000101'B, '00000101'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004060 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01004061}
4062
4063testcase TC_assignment_codec_amr_h_S024() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02004064 f_TC_assignment_codec_amr(false, '2815208820'O, '00010101'B, '00010101'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004065 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01004066}
4067
4068/* The following block tests what happens when the MSC does offer rate
4069 * configurations that are not supported by the BSC. Normally such situations
4070 * should not happen because the MSC gets informed by the BSC in advance via
4071 * the L3 COMPLETE message which rates are applicable. The MSC should not try
4072 * to offer rates that are not applicable anyway. */
4073
4074testcase TC_assignment_codec_amr_h_S0247() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02004075 /* Try to include 12,2k in into the active set even though the channel
4076 * is half rate only. The BSC is expected to remove the 12,0k */
4077 f_TC_assignment_codec_amr(false, '2815208820'O, '10010101'B, '00010101'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004078 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01004079}
4080
4081testcase TC_assignment_codec_amr_f_S01234567() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02004082 /* See what happens when all rates are selected at once. Since then
4083 * Also S1 is selected, this setting will be prefered and we should
4084 * get 12.2k, 7,40k, 5,90k, and 4,75k in the active set. */
4085 f_TC_assignment_codec_amr(true, '289520882208'O, '11111111'B, '00000010'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004086 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01004087}
4088
4089testcase TC_assignment_codec_amr_f_S0234567() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02004090 /* Same as above, but with S1 missing, the MSC is then expected to
4091 * select the currently supported rates, which are also 12.2k, 7,40k,
4092 * 5,90k, and 4,75k, into the active set. */
4093 f_TC_assignment_codec_amr(true, '289520882208'O, '11111101'B, '10010101'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004094 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01004095}
4096
4097testcase TC_assignment_codec_amr_f_zero() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02004098 /* Try to select no rates at all */
4099 f_TC_assignment_codec_amr_fail(true, '00000000'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004100 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01004101}
4102
4103testcase TC_assignment_codec_amr_f_unsupp() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02004104 /* Try to select only unsupported rates */
4105 f_TC_assignment_codec_amr_fail(true, '01101000'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004106 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01004107}
4108
4109testcase TC_assignment_codec_amr_h_S7() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02004110 /* Try to select 12,2k for half rate */
4111 f_TC_assignment_codec_amr_fail(false, '10000000'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004112 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01004113}
4114
Neels Hofmeyr21863562020-11-26 00:34:33 +00004115testcase TC_assignment_codec_amr_f_start_mode_auto() runs on test_CT {
4116 f_TC_assignment_codec_amr(true, '209520882208'O, '11111111'B, '00000010'B,
4117 start_mode := "auto");
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01004118 f_shutdown_helper();
Neels Hofmeyr21863562020-11-26 00:34:33 +00004119}
4120
4121testcase TC_assignment_codec_amr_h_start_mode_auto() runs on test_CT {
4122 f_TC_assignment_codec_amr(false, '2015208820'O, '10010101'B, '00010101'B,
4123 start_mode := "auto");
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01004124 f_shutdown_helper();
Neels Hofmeyr21863562020-11-26 00:34:33 +00004125}
4126
Neels Hofmeyr3eb94562020-11-26 02:40:26 +00004127testcase TC_assignment_codec_amr_f_start_mode_4() runs on test_CT {
Vadim Yanitskiy7815f482021-01-03 17:07:37 +01004128 /* "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 +00004129 f_TC_assignment_codec_amr(true, '2b9520882208'O, '11111111'B, '00000010'B,
4130 start_mode := "4");
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01004131 f_shutdown_helper();
Neels Hofmeyr3eb94562020-11-26 02:40:26 +00004132}
4133
4134testcase TC_assignment_codec_amr_h_start_mode_4() runs on test_CT {
Vadim Yanitskiy7815f482021-01-03 17:07:37 +01004135 /* "amr tch-h modes 0 2 4" => total 3 modes and start mode 4 => '10'B on the wire */
4136 f_TC_assignment_codec_amr(false, '2a15208820'O, '10010101'B, '00010101'B,
Neels Hofmeyr3eb94562020-11-26 02:40:26 +00004137 start_mode := "4");
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01004138 f_shutdown_helper();
Neels Hofmeyr3eb94562020-11-26 02:40:26 +00004139}
4140
Philipp Maierac09bfc2019-01-08 13:41:39 +01004141private function f_disable_all_tch_f() runs on test_CT {
Philipp Maierc704a882019-01-29 15:58:52 +01004142 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 1 sub-slot 0 borken");
4143 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 2 sub-slot 0 borken");
4144 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 3 sub-slot 0 borken");
4145 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 4 sub-slot 0 borken");
Philipp Maierac09bfc2019-01-08 13:41:39 +01004146}
4147
4148private function f_disable_all_tch_h() runs on test_CT {
Philipp Maierc704a882019-01-29 15:58:52 +01004149 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 5 sub-slot 0 borken");
4150 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 5 sub-slot 1 borken");
Philipp Maierac09bfc2019-01-08 13:41:39 +01004151}
4152
4153private function f_enable_all_tch() runs on test_CT {
Philipp Maierc704a882019-01-29 15:58:52 +01004154 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 1 sub-slot 0 unused");
4155 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 2 sub-slot 0 unused");
4156 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 3 sub-slot 0 unused");
4157 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 4 sub-slot 0 unused");
4158 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 5 sub-slot 0 unused");
4159 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 5 sub-slot 1 unused");
Philipp Maierac09bfc2019-01-08 13:41:39 +01004160}
4161
Neels Hofmeyr559d5d02021-04-16 16:50:49 +02004162private function f_disable_all_sdcch() runs on test_CT {
4163 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 0 sub-slot 0 borken");
4164 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 0 sub-slot 1 borken");
4165 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 0 sub-slot 2 borken");
4166 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 0 sub-slot 3 borken");
4167}
4168
4169private function f_enable_all_sdcch() runs on test_CT {
4170 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 0 sub-slot 0 unused");
4171 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 0 sub-slot 1 unused");
4172 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 0 sub-slot 2 unused");
4173 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 0 sub-slot 3 unused");
4174}
4175
Philipp Maierac09bfc2019-01-08 13:41:39 +01004176/* Allow HR only */
4177private function f_TC_assignment_codec_xr_exhausted_req_hr(charstring id) runs on MSC_ConnHdlr {
4178 g_pars := f_gen_test_hdlr_pars();
4179 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4180 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4181 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4182 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '09'O;
4183 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '05'O;
4184 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR}));
4185 f_establish_fully(ass_cmd, exp_compl);
4186}
4187
4188/* Allow FR only */
4189private function f_TC_assignment_codec_xr_exhausted_req_fr(charstring id) runs on MSC_ConnHdlr {
4190 g_pars := f_gen_test_hdlr_pars();
4191 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4192 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4193 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4194 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '08'O;
4195 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '01'O;
4196 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
4197 f_establish_fully(ass_cmd, exp_compl);
4198}
4199
4200/* Allow HR only (expect assignment failure) */
4201private function f_TC_assignment_codec_xr_exhausted_req_hr_fail(charstring id) runs on MSC_ConnHdlr {
4202 g_pars := f_gen_test_hdlr_pars();
4203 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4204 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
4205 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4206 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '09'O;
4207 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '05'O;
4208 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR}));
4209 f_establish_fully(ass_cmd, exp_fail);
4210}
4211
4212/* Allow FR only (expect assignment failure) */
4213private function f_TC_assignment_codec_xr_exhausted_req_fr_fail(charstring id) runs on MSC_ConnHdlr {
4214 g_pars := f_gen_test_hdlr_pars();
4215 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4216 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
4217 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4218 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '08'O;
4219 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '01'O;
4220 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
4221 f_establish_fully(ass_cmd, exp_fail);
4222}
4223
4224/* Allow FR and HR, but prefer FR */
4225private function f_TC_assignment_codec_fr_exhausted_req_fr_hr(charstring id) runs on MSC_ConnHdlr {
4226 g_pars := f_gen_test_hdlr_pars();
4227 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4228 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4229 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4230 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0A'O; /* Prefer FR */
4231 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8105'O;
4232 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR, ts_CodecHR}));
4233 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000101'B; /* Expect HR */
4234 f_establish_fully(ass_cmd, exp_compl);
4235}
4236
4237/* Allow FR and HR, but prefer HR */
4238private function f_TC_assignment_codec_fr_exhausted_req_hr_fr(charstring id) runs on MSC_ConnHdlr {
4239 g_pars := f_gen_test_hdlr_pars();
4240 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4241 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4242 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4243 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0B'O; /* Prefer HR */
4244 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8501'O;
4245 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR, ts_CodecFR}));
4246 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000101'B; /* Expect HR */
4247 f_establish_fully(ass_cmd, exp_compl);
4248}
4249
4250/* Allow FR and HR, but prefer FR */
4251private function f_TC_assignment_codec_hr_exhausted_req_fr_hr(charstring id) runs on MSC_ConnHdlr {
4252 g_pars := f_gen_test_hdlr_pars();
4253 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4254 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4255 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4256 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0A'O; /* Prefer FR */
4257 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8105'O;
4258 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR, ts_CodecHR}));
4259 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000001'B; /* Expect FR */
4260 f_establish_fully(ass_cmd, exp_compl);
4261}
4262
4263/* Allow FR and HR, but prefer HR */
4264private function f_TC_assignment_codec_hr_exhausted_req_hr_fr(charstring id) runs on MSC_ConnHdlr {
4265 g_pars := f_gen_test_hdlr_pars();
4266 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4267 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4268 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4269 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0B'O; /* Prefer HR */
4270 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8501'O;
4271 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR, ts_CodecFR}));
4272 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000001'B; /* Expect FR */
4273 f_establish_fully(ass_cmd, exp_compl);
4274}
4275
4276/* Request a HR channel while all FR channels are exhausted, this is expected
4277 * to work without conflicts */
4278testcase TC_assignment_codec_fr_exhausted_req_hr() runs on test_CT {
4279 var MSC_ConnHdlr vc_conn;
4280 f_init(1, true);
4281 f_sleep(1.0);
4282 f_enable_all_tch();
4283 f_disable_all_tch_f();
4284 vc_conn := f_start_handler(refers(f_TC_assignment_codec_xr_exhausted_req_hr));
4285 vc_conn.done;
4286 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004287 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004288}
4289
4290/* Request a FR channel while all FR channels are exhausted, this is expected
4291 * to fail. */
4292testcase TC_assignment_codec_fr_exhausted_req_fr() runs on test_CT {
4293 var MSC_ConnHdlr vc_conn;
4294 f_init(1, true);
4295 f_sleep(1.0);
4296 f_enable_all_tch();
4297 f_disable_all_tch_f();
4298 vc_conn := f_start_handler(refers(f_TC_assignment_codec_xr_exhausted_req_fr_fail));
4299 vc_conn.done;
4300 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004301 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004302}
4303
4304/* Request a FR (prefered) or alternatively a HR channel while all FR channels
4305 * are exhausted, this is expected to be resolved by selecting a HR channel. */
4306testcase TC_assignment_codec_fr_exhausted_req_fr_hr() runs on test_CT {
4307 var MSC_ConnHdlr vc_conn;
4308 f_init(1, true);
4309 f_sleep(1.0);
4310 f_enable_all_tch();
4311 f_disable_all_tch_f();
4312 vc_conn := f_start_handler(refers(f_TC_assignment_codec_fr_exhausted_req_fr_hr));
4313 vc_conn.done;
4314 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004315 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004316}
4317
4318/* Request a HR (prefered) or alternatively a FR channel while all FR channels
4319 * are exhausted, this is expected to work without conflicts. */
4320testcase TC_assignment_codec_fr_exhausted_req_hr_fr() runs on test_CT {
4321 var MSC_ConnHdlr vc_conn;
4322 f_init(1, true);
4323 f_sleep(1.0);
4324 f_enable_all_tch();
4325 f_disable_all_tch_f();
4326 vc_conn := f_start_handler(refers(f_TC_assignment_codec_fr_exhausted_req_hr_fr));
4327 vc_conn.done;
4328 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004329 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004330}
4331
4332/* Request a FR channel while all HR channels are exhausted, this is expected
4333 * to work without conflicts */
4334testcase TC_assignment_codec_hr_exhausted_req_fr() runs on test_CT {
4335 var MSC_ConnHdlr vc_conn;
4336 f_init(1, true);
4337 f_sleep(1.0);
4338 f_enable_all_tch();
4339 f_disable_all_tch_h();
4340 vc_conn := f_start_handler(refers(f_TC_assignment_codec_xr_exhausted_req_fr));
4341 vc_conn.done;
4342 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004343 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004344}
4345
4346/* Request a HR channel while all HR channels are exhausted, this is expected
4347 * to fail. */
4348testcase TC_assignment_codec_hr_exhausted_req_hr() runs on test_CT {
4349 var MSC_ConnHdlr vc_conn;
4350 f_init(1, true);
4351 f_sleep(1.0);
4352 f_enable_all_tch();
4353 f_disable_all_tch_h();
4354 vc_conn := f_start_handler(refers(f_TC_assignment_codec_xr_exhausted_req_hr_fail));
4355 vc_conn.done;
4356 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004357 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004358}
4359
4360/* Request a HR (prefered) or alternatively a FR channel while all HR channels
4361 * are exhausted, this is expected to be resolved by selecting a FR channel. */
4362testcase TC_assignment_codec_hr_exhausted_req_hr_fr() runs on test_CT {
4363 var MSC_ConnHdlr vc_conn;
4364 f_init(1, true);
4365 f_sleep(1.0);
4366 f_enable_all_tch();
4367 f_disable_all_tch_h();
4368 vc_conn := f_start_handler(refers(f_TC_assignment_codec_hr_exhausted_req_hr_fr));
4369 vc_conn.done;
4370 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004371 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004372}
4373
4374/* Request a FR (prefered) or alternatively a HR channel while all HR channels
4375 * are exhausted, this is expected to work without conflicts. */
4376testcase TC_assignment_codec_hr_exhausted_req_fr_hr() runs on test_CT {
4377 var MSC_ConnHdlr vc_conn;
4378 f_init(1, true);
4379 f_sleep(1.0);
4380 f_enable_all_tch();
4381 f_disable_all_tch_h();
4382 vc_conn := f_start_handler(refers(f_TC_assignment_codec_hr_exhausted_req_fr_hr));
4383 vc_conn.done;
4384 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004385 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004386}
4387
4388/* Allow FR and HR, but prefer HR */
4389private function f_TC_assignment_codec_req_hr_fr(charstring id) runs on MSC_ConnHdlr {
4390 g_pars := f_gen_test_hdlr_pars();
4391 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4392 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4393 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4394 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0B'O; /* Prefer HR */
4395 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8501'O;
4396 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR, ts_CodecFR}));
4397 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000101'B; /* Expect HR */
4398 f_establish_fully(ass_cmd, exp_compl);
4399}
4400
4401/* Allow FR and HR, but prefer FR */
4402private function f_TC_assignment_codec_req_fr_hr(charstring id) runs on MSC_ConnHdlr {
4403 g_pars := f_gen_test_hdlr_pars();
4404 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4405 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4406 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4407 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0A'O; /* Prefer FR */
4408 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8105'O;
4409 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR, ts_CodecHR}));
4410 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000001'B; /* Expect FR */
4411 f_establish_fully(ass_cmd, exp_compl);
4412}
4413
4414/* Request a HR (prefered) or alternatively a FR channel, it is expected that
4415 * HR, which is the prefered type, is selected. */
4416testcase TC_assignment_codec_req_hr_fr() runs on test_CT {
4417 var MSC_ConnHdlr vc_conn;
4418 f_init(1, true);
4419 f_sleep(1.0);
4420 f_enable_all_tch();
4421 vc_conn := f_start_handler(refers(f_TC_assignment_codec_req_hr_fr));
4422 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004423 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004424}
4425
4426/* Request a FR (prefered) or alternatively a HR channel, it is expected that
4427 * FR, which is the prefered type, is selected. */
4428testcase TC_assignment_codec_req_fr_hr() runs on test_CT {
4429 var MSC_ConnHdlr vc_conn;
4430 f_init(1, true);
4431 f_sleep(1.0);
4432 f_enable_all_tch();
4433 vc_conn := f_start_handler(refers(f_TC_assignment_codec_req_fr_hr));
4434 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004435 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004436}
4437
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02004438testcase TC_assignment_osmux() runs on test_CT {
4439 var TestHdlrParams pars := f_gen_test_hdlr_pars();
4440 var MSC_ConnHdlr vc_conn;
4441
4442 /* See note above */
4443 var RSL_IE_Body mr_conf := {
4444 other := {
4445 len := 2,
4446 payload := '2804'O
4447 }
4448 };
4449
4450 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_H}));
4451 pars.ass_codec_list.codecElements[0].s0_7 := '00000100'B; /* 5,90k */
4452 pars.ass_codec_list.codecElements[0].s8_15 := '00000111'B;
4453 pars.expect_mr_conf_ie := mr_conf;
4454 pars.use_osmux := true;
4455
4456 f_init(1, true, true);
4457 f_sleep(1.0);
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00004458 f_vty_amr_start_mode_set(false, "1");
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02004459
4460 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
4461 vc_conn.done;
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00004462
4463 f_vty_amr_start_mode_restore(false);
Vadim Yanitskiy292e5962021-01-03 14:18:47 +01004464 f_shutdown_helper();
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02004465}
4466
Neels Hofmeyr92b12b72018-09-18 14:30:23 +02004467/* test the procedure of the MSC requesting a Classmark Update:
4468 * a) BSSMAP Classmark Request should result in RR CLASSMARK ENQUIRY,
4469 * b) L3 RR CLASSMARK CHANGE should result in BSSMAP CLASSMARK UPDATE */
Harald Welte898113b2018-01-31 18:32:21 +01004470private function f_tc_classmark(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02004471 g_pars := f_gen_test_hdlr_pars();
4472
Harald Weltea0630032018-03-20 21:09:55 +01004473 f_create_chan_and_exp();
Harald Welte898113b2018-01-31 18:32:21 +01004474 /* we should now have a COMPL_L3 at the MSC */
4475 BSSAP.receive(tr_BSSMAP_ComplL3);
4476
Neels Hofmeyr92b12b72018-09-18 14:30:23 +02004477 BSSAP.send(ts_BSSMAP_ClassmarkRequest);
4478 RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_CM_ENQUIRY));
4479
Harald Welte898113b2018-01-31 18:32:21 +01004480 f_rsl_send_l3(ts_RRM_CM_CHG(valueof(ts_CM2)));
4481 BSSAP.receive(tr_BSSMAP_ClassmarkUpd(?, omit));
4482 setverdict(pass);
4483}
4484testcase TC_classmark() runs on test_CT {
4485 var MSC_ConnHdlr vc_conn;
4486 f_init(1, true);
4487 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02004488 vc_conn := f_start_handler(refers(f_tc_classmark));
Harald Welte898113b2018-01-31 18:32:21 +01004489 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004490 f_shutdown_helper();
Harald Welte898113b2018-01-31 18:32:21 +01004491}
4492
Harald Welteeddf0e92020-06-21 19:42:15 +02004493/* Send a CommonID from the simulated MSC and verify that the information is used to
4494 * fill BSC-internal data structures (specifically, bsc_subscr associated with subscr_conn) */
4495private function f_tc_common_id(charstring id) runs on MSC_ConnHdlr {
4496 g_pars := f_gen_test_hdlr_pars();
4497 f_MscConnHdlr_init_vty();
4498
4499 f_create_chan_and_exp();
4500 /* we should now have a COMPL_L3 at the MSC */
4501 BSSAP.receive(tr_BSSMAP_ComplL3);
4502
4503 /* Send CommonID */
4504 BSSAP.send(ts_BSSMAP_CommonId(g_pars.imsi));
4505
4506 /* Use VTY to verify that the IMSI of the subscr_conn is set */
4507 var charstring regex := "*(IMSI: " & hex2str(g_pars.imsi) & ")*";
4508 f_vty_transceive_match_regexp_retry(BSCVTY, "show conns", regex, 0, 4, 1.0);
4509
4510 setverdict(pass);
4511}
4512testcase TC_common_id() runs on test_CT {
4513 var MSC_ConnHdlr vc_conn;
4514 f_init(1, true);
4515 f_sleep(1.0);
4516 vc_conn := f_start_handler(refers(f_tc_common_id));
4517 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004518 f_shutdown_helper();
Harald Welteeddf0e92020-06-21 19:42:15 +02004519}
4520
Harald Weltee3bd6582018-01-31 22:51:25 +01004521private function f_est_single_l3(template PDU_ML3_MS_NW l3) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02004522 g_pars := f_gen_test_hdlr_pars();
Harald Weltea0630032018-03-20 21:09:55 +01004523 f_create_chan_and_exp();
Harald Welte898113b2018-01-31 18:32:21 +01004524 /* we should now have a COMPL_L3 at the MSC */
4525 BSSAP.receive(tr_BSSMAP_ComplL3);
4526
Harald Weltee3bd6582018-01-31 22:51:25 +01004527 /* send the single message we want to send */
4528 f_rsl_send_l3(l3);
4529}
4530
4531private function f_bssap_expect_nothing(float sec := 5.00) runs on MSC_ConnHdlr {
4532 timer T := sec;
4533 var PDU_BSSAP bssap;
Harald Welte898113b2018-01-31 18:32:21 +01004534 T.start;
4535 alt {
Harald Weltee3bd6582018-01-31 22:51:25 +01004536 [] BSSAP.receive(PDU_BSSAP:?) -> value bssap {
4537 setverdict(fail, "Unexpected BSSMAP ", bssap);
Daniel Willmannafce8662018-07-06 23:11:32 +02004538 mtc.stop;
Harald Welte898113b2018-01-31 18:32:21 +01004539 }
4540 [] T.timeout {
4541 setverdict(pass);
4542 }
4543 }
4544}
4545
Harald Weltee3bd6582018-01-31 22:51:25 +01004546/* unsolicited ASSIGNMENT FAIL (without ASSIGN) from MS shouldn't bring BSC down */
4547private function f_tc_unsol_ass_fail(charstring id) runs on MSC_ConnHdlr {
4548 f_est_single_l3(ts_RRM_AssignmentFailure('00'O));
4549 f_bssap_expect_nothing();
4550}
Harald Welte898113b2018-01-31 18:32:21 +01004551testcase TC_unsol_ass_fail() runs on test_CT {
4552 var MSC_ConnHdlr vc_conn;
4553 f_init(1, true);
4554 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02004555 vc_conn := f_start_handler(refers(f_tc_unsol_ass_fail));
Harald Welte898113b2018-01-31 18:32:21 +01004556 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004557 f_shutdown_helper();
Harald Welte898113b2018-01-31 18:32:21 +01004558}
Harald Welte552620d2017-12-16 23:21:36 +01004559
Harald Welteea99a002018-01-31 20:46:43 +01004560
4561/* unsolicited ASSIGNMENT COMPLETE (without ASSIGN) from MS shouldn't bring BSC down */
4562private function f_tc_unsol_ass_compl(charstring id) runs on MSC_ConnHdlr {
Harald Weltee3bd6582018-01-31 22:51:25 +01004563 f_est_single_l3(ts_RRM_AssignmentComplete('00'O));
4564 f_bssap_expect_nothing();
Harald Welteea99a002018-01-31 20:46:43 +01004565}
4566testcase TC_unsol_ass_compl() runs on test_CT {
4567 var MSC_ConnHdlr vc_conn;
4568 f_init(1, true);
4569 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02004570 vc_conn := f_start_handler(refers(f_tc_unsol_ass_compl));
Harald Welteea99a002018-01-31 20:46:43 +01004571 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004572 f_shutdown_helper();
Harald Welteea99a002018-01-31 20:46:43 +01004573}
4574
4575
Harald Weltefbf9b5e2018-01-31 20:41:23 +01004576/* unsolicited HANDOVER FAIL (without ASSIGN) from MS shouldn't bring BSC down */
4577private function f_tc_unsol_ho_fail(charstring id) runs on MSC_ConnHdlr {
Harald Weltee3bd6582018-01-31 22:51:25 +01004578 f_est_single_l3(ts_RRM_HandoverFailure('00'O));
4579 f_bssap_expect_nothing();
Harald Weltefbf9b5e2018-01-31 20:41:23 +01004580}
Harald Weltefbf9b5e2018-01-31 20:41:23 +01004581testcase TC_unsol_ho_fail() runs on test_CT {
4582 var MSC_ConnHdlr vc_conn;
4583 f_init(1, true);
4584 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02004585 vc_conn := f_start_handler(refers(f_tc_unsol_ho_fail));
Harald Weltefbf9b5e2018-01-31 20:41:23 +01004586 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004587 f_shutdown_helper();
Harald Weltefbf9b5e2018-01-31 20:41:23 +01004588}
4589
4590
Harald Weltee3bd6582018-01-31 22:51:25 +01004591/* short message from MS should be ignored */
4592private function f_tc_err_82_short_msg(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02004593 g_pars := f_gen_test_hdlr_pars();
Harald Weltea0630032018-03-20 21:09:55 +01004594 f_create_chan_and_exp();
Harald Weltee3bd6582018-01-31 22:51:25 +01004595 /* we should now have a COMPL_L3 at the MSC */
4596 BSSAP.receive(tr_BSSMAP_ComplL3);
4597
4598 /* send short message */
4599 RSL.send(ts_RSL_DATA_IND(g_chan_nr, valueof(ts_RslLinkID_DCCH(0)), ''O));
4600 f_bssap_expect_nothing();
4601}
4602testcase TC_err_82_short_msg() runs on test_CT {
4603 var MSC_ConnHdlr vc_conn;
4604 f_init(1, true);
4605 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02004606 vc_conn := f_start_handler(refers(f_tc_err_82_short_msg));
Harald Weltee3bd6582018-01-31 22:51:25 +01004607 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004608 f_shutdown_helper();
Harald Weltee3bd6582018-01-31 22:51:25 +01004609}
4610
4611
Harald Weltee9e02e42018-01-31 23:36:25 +01004612/* 24.008 8.4 Unknown message must trigger RR STATUS */
4613private function f_tc_err_84_unknown_msg(charstring id) runs on MSC_ConnHdlr {
4614 f_est_single_l3(ts_RRM_UL_REL('00'O));
4615 timer T := 3.0
4616 alt {
4617 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_STATUS)) {
4618 setverdict(pass);
4619 }
4620 [] BSSAP.receive { setverdict(fail, "unexpected BSSAP"); }
Harald Welte458fd372018-03-21 11:26:23 +01004621 [] T.timeout { setverdict(fail, "Timeout waiting for RR STATUS"); }
Harald Weltee9e02e42018-01-31 23:36:25 +01004622 }
4623}
4624testcase TC_err_84_unknown_msg() runs on test_CT {
4625 var MSC_ConnHdlr vc_conn;
4626 f_init(1, true);
4627 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02004628 vc_conn := f_start_handler(refers(f_tc_err_84_unknown_msg));
Harald Weltee9e02e42018-01-31 23:36:25 +01004629 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004630 f_shutdown_helper();
Harald Weltee9e02e42018-01-31 23:36:25 +01004631}
4632
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004633/***********************************************************************
4634 * Handover
4635 ***********************************************************************/
4636
Harald Welte94e0c342018-04-07 11:33:23 +02004637/* execute a "bts <0-255> trx <0-255> timeslot <0-7> " command on given Dchan */
4638private function f_vty_ts_action(charstring suffix, integer bts_nr, integer trx_nr, integer ts_nr)
4639runs on test_CT {
4640 var charstring cmd := "bts "&int2str(bts_nr)&" trx "&int2str(trx_nr)&
4641 " timeslot "&int2str(ts_nr)&" ";
4642 f_vty_transceive(BSCVTY, cmd & suffix);
4643}
4644
Harald Welte261af4b2018-02-12 21:20:39 +01004645/* 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 +07004646private function f_vty_ss_action(TELNETasp_PT pt, charstring suffix,
4647 uint8_t bts_nr, uint8_t trx_nr,
4648 in RslChannelNr chan_nr)
4649{
Harald Welte261af4b2018-02-12 21:20:39 +01004650 /* FIXME: resolve those from component-global state */
4651 var integer ts_nr := chan_nr.tn;
4652 var integer ss_nr;
4653 if (ischosen(chan_nr.u.ch0)) {
4654 ss_nr := 0;
4655 } else if (ischosen(chan_nr.u.lm)) {
4656 ss_nr := chan_nr.u.lm.sub_chan;
4657 } else if (ischosen(chan_nr.u.sdcch4)) {
4658 ss_nr := chan_nr.u.sdcch4.sub_chan;
4659 } else if (ischosen(chan_nr.u.sdcch8)) {
4660 ss_nr := chan_nr.u.sdcch8.sub_chan;
4661 } else {
4662 setverdict(fail, "Invalid ChanNr ", chan_nr);
Daniel Willmannafce8662018-07-06 23:11:32 +02004663 mtc.stop;
Harald Welte261af4b2018-02-12 21:20:39 +01004664 }
4665
4666 var charstring cmd := "bts "&int2str(bts_nr)&" trx "&int2str(trx_nr)&
4667 " timeslot "&int2str(ts_nr)&" sub-slot "&int2str(ss_nr)&" ";
Vadim Yanitskiy00070722020-09-02 17:27:57 +07004668 f_vty_transceive(pt, cmd & suffix);
Harald Welte261af4b2018-02-12 21:20:39 +01004669}
4670
Neels Hofmeyr91401012019-07-11 00:42:35 +02004671/* Even though the VTY command to trigger handover takes a new BTS number as argument, behind the scenes osmo-bsc always
4672 * translates that to a target ARFCN+BSIC first. See bsc_vty.c trigger_ho_or_as(), which puts the selected BTS' neighbor
4673 * ident key (ARFCN + BSIC) in the struct passed on to handover_request(). handover_start() then resolves that to a
4674 * viable actual neighbor cell. So from the internal osmo-bsc perspective, we always request handover to an ARFCN + BSIC
4675 * pair, not really to a specific BTS number. */
Vadim Yanitskiy00070722020-09-02 17:27:57 +07004676private function f_vty_handover(TELNETasp_PT pt, uint8_t bts_nr, uint8_t trx_nr,
4677 in RslChannelNr chan_nr, uint8_t new_bts_nr)
4678{
4679 f_vty_ss_action(pt, "handover " & int2str(new_bts_nr), bts_nr, trx_nr, chan_nr);
Harald Welte261af4b2018-02-12 21:20:39 +01004680}
4681
4682/* intra-BSC hand-over between BTS0 and BTS1 */
4683private function f_tc_ho_int(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02004684 g_pars := f_gen_test_hdlr_pars();
Harald Welteed848512018-05-24 22:27:58 +02004685 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4686 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte261af4b2018-02-12 21:20:39 +01004687 const OCT8 kc := '0001020304050607'O;
4688
4689 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4690 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
4691
Harald Weltea0630032018-03-20 21:09:55 +01004692 f_establish_fully(ass_cmd, exp_compl);
Neels Hofmeyr666f0432020-07-04 00:53:07 +02004693 f_bts_0_cfg(BSCVTY, {"neighbor bts 1"});
Harald Welte261af4b2018-02-12 21:20:39 +01004694
4695 var HandoverState hs := {
4696 rr_ho_cmpl_seen := false,
4697 handover_done := false,
4698 old_chan_nr := -
4699 };
4700 /* issue hand-over command on VTY */
Vadim Yanitskiy00070722020-09-02 17:27:57 +07004701 f_vty_handover(BSCVTY, 0, 0, g_chan_nr, 1);
Harald Welte261af4b2018-02-12 21:20:39 +01004702 /* temporarily suspend DChan processing on BTS1 to avoid race with RSLEM_register */
4703 f_rslem_suspend(RSL1_PROC);
Philipp Maier3e2af5d2018-07-11 17:01:05 +02004704
4705 /* From the MGW perspective, a handover is is characterized by
4706 * performing one MDCX operation with the MGW. So we expect to see
4707 * one more MDCX during handover. */
4708 g_media.mgcp_conn[0].mdcx_seen_exp := g_media.mgcp_conn[0].crcx_seen_exp + 1;
4709
Harald Welte261af4b2018-02-12 21:20:39 +01004710 alt {
4711 [] as_handover(hs);
Harald Welte261af4b2018-02-12 21:20:39 +01004712 }
Philipp Maier3e2af5d2018-07-11 17:01:05 +02004713
Philipp Maier4dae0652018-11-12 12:03:26 +01004714 /* Since this is an internal handover we expect the BSC to inform the
4715 * MSC about the event */
4716 BSSAP.receive(tr_BSSMAP_HandoverPerformed);
4717
Philipp Maier3e2af5d2018-07-11 17:01:05 +02004718 /* Check the amount of MGCP transactions is still consistant with the
4719 * test expectation */
4720 f_check_mgcp_expectations()
Neels Hofmeyr861a4c12018-11-07 01:23:17 +01004721 f_sleep(0.5);
Harald Welte261af4b2018-02-12 21:20:39 +01004722}
4723
4724testcase TC_ho_int() runs on test_CT {
4725 var MSC_ConnHdlr vc_conn;
4726 f_init(2, true);
4727 f_sleep(1.0);
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004728
4729 f_ctrs_bsc_and_bts_init();
4730
Harald Welte8863fa12018-05-10 20:15:27 +02004731 vc_conn := f_start_handler(refers(f_tc_ho_int));
Harald Welte261af4b2018-02-12 21:20:39 +01004732 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004733
4734 /* from f_establish_fully() */
4735 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
4736 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
4737 /* from handover */
4738 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
4739 f_ctrs_bsc_and_bts_add(0, "handover:completed");
4740 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
4741 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:completed");
4742 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004743 f_shutdown_helper();
Harald Welte261af4b2018-02-12 21:20:39 +01004744}
Harald Weltee9e02e42018-01-31 23:36:25 +01004745
Neels Hofmeyr5f144212020-11-03 15:41:58 +00004746/* intra-BSC hand-over with CONNection FAILure and cause Radio Link Failure: check RR release cause */
4747private function f_tc_ho_int_radio_link_failure(charstring id) runs on MSC_ConnHdlr {
4748 g_pars := f_gen_test_hdlr_pars();
4749 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4750 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4751 const OCT8 kc := '0001020304050607'O;
4752
4753 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4754 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
4755
4756 f_establish_fully(ass_cmd, exp_compl);
4757 f_bts_0_cfg(BSCVTY, {"neighbor bts 1"});
4758
4759 var HandoverState hs := {
4760 rr_ho_cmpl_seen := false,
4761 handover_done := false,
4762 old_chan_nr := -
4763 };
4764 /* issue hand-over command on VTY */
4765 f_vty_handover(BSCVTY, 0, 0, g_chan_nr, 1);
4766 /* temporarily suspend DChan processing on BTS1 to avoid race with RSLEM_register */
4767 f_rslem_suspend(RSL1_PROC);
4768
4769 /* From the MGW perspective, a handover is is characterized by
4770 * performing one MDCX operation with the MGW. So we expect to see
4771 * one more MDCX during handover. */
4772 g_media.mgcp_conn[0].mdcx_seen_exp := g_media.mgcp_conn[0].crcx_seen_exp + 1;
4773
4774 var RSL_Message rsl;
4775 var PDU_ML3_NW_MS l3;
4776 var RslChannelNr new_chan_nr;
4777 var GsmArfcn arfcn;
4778 RSL.receive(tr_RSL_DATA_REQ(g_chan_nr)) -> value rsl {
4779 l3 := dec_PDU_ML3_NW_MS(rsl.ies[2].body.l3_info.payload);
4780 if (not ischosen(l3.msgs.rrm.handoverCommand)) {
4781 setverdict(fail, "Expected handoverCommand");
4782 mtc.stop;
4783 }
4784 }
4785 f_ChDesc2RslChanNr(l3.msgs.rrm.handoverCommand.channelDescription2,
4786 new_chan_nr, arfcn);
4787
4788 f_rslem_register(0, new_chan_nr, RSL1_PROC);
4789
4790 /* resume processing of RSL DChan messages, which was temporarily suspended
4791 * before performing a hand-over */
4792 f_rslem_resume(RSL1_PROC);
4793 RSL1.receive(tr_RSL_IPA_CRCX(new_chan_nr));
4794
4795 f_sleep(1.0);
4796
4797 /* Handover fails because no HANDO DET appears on the new lchan,
4798 * and the old lchan reports a Radio Link Failure. */
4799 RSL.send(ts_RSL_CONN_FAIL_IND(g_chan_nr, RSL_ERR_RADIO_LINK_FAIL));
4800
4801 var PDU_BSSAP rx_clear_request;
4802 BSSAP.receive(tr_BSSMAP_ClearRequest) -> value rx_clear_request;
4803 var BssmapCause cause := bit2int(rx_clear_request.pdu.bssmap.clearRequest.cause.causeValue);
4804 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
4805
4806 var RR_Cause rr_cause := GSM48_RR_CAUSE_ABNORMAL_UNSPEC;
4807
4808 var MgcpCommand mgcp;
4809 interleave {
4810 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_RELEASE(int2oct(enum2int(rr_cause), 1)))) {}
4811 [] RSL.receive(tr_RSL_DEACT_SACCH(g_chan_nr)) {}
4812 [] RSL.receive(tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL)) {
4813 RSL.send(ts_RSL_RF_CHAN_REL_ACK(g_chan_nr));
4814 }
4815 [] RSL1.receive(tr_RSL_DEACT_SACCH(new_chan_nr)) {}
4816 [] RSL1.receive(tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL)) {
4817 RSL1.send(ts_RSL_RF_CHAN_REL_ACK(new_chan_nr));
4818 }
4819 [] BSSAP.receive(tr_BSSMAP_ClearComplete) {}
4820 }
4821
4822 f_sleep(0.5);
4823 setverdict(pass);
4824}
4825testcase TC_ho_int_radio_link_failure() runs on test_CT {
4826 var MSC_ConnHdlr vc_conn;
4827 f_init(2, true);
4828 f_sleep(1.0);
4829
4830 f_ctrs_bsc_and_bts_init();
4831
4832 vc_conn := f_start_handler(refers(f_tc_ho_int_radio_link_failure));
4833 vc_conn.done;
4834
4835 /* from f_establish_fully() */
4836 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
4837 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
4838 /* from handover */
4839 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
4840 f_ctrs_bsc_and_bts_add(0, "handover:stopped");
4841 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
4842 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:stopped");
4843 f_ctrs_bsc_and_bts_verify();
4844 f_shutdown_helper();
4845}
4846
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004847/* Expecting MGCP to DLCX the endpoint's two connections: towards BTS and towards MSC */
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02004848private function f_expect_dlcx_conns() runs on MSC_ConnHdlr {
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004849 var MgcpCommand mgcp;
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +02004850 var template MgcpResponse mgcp_resp;
4851 var MGCP_RecvFrom mrf;
4852 var template MgcpMessage msg_resp;
4853 var template MgcpMessage msg_dlcx := {
4854 command := tr_DLCX()
4855 }
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004856
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +02004857 if (g_pars.aoip) {
4858 MGCP.receive(tr_DLCX()) -> value mgcp {
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004859 log("Got first DLCX: ", mgcp);
4860 MGCP.send(ts_DLCX_ACK2(mgcp.line.trans_id));
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +02004861 };
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004862
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004863 MGCP.receive(tr_DLCX()) -> value mgcp {
4864 log("Got second DLCX: ", mgcp);
4865 MGCP.send(ts_DLCX_ACK2(mgcp.line.trans_id));
4866 };
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +02004867 } else {
4868 /* For SCCPLite, BSC doesn't handle the MSC-side */
4869 MGCP_MULTI.receive(tr_MGCP_RecvFrom_any(msg_dlcx)) -> value mrf {
4870 log("Got first DLCX: ", mrf.msg.command);
4871 msg_resp := {
4872 response := ts_DLCX_ACK2(mrf.msg.command.line.trans_id)
4873 }
4874 MGCP_MULTI.send(t_MGCP_SendToMrf(mrf, msg_resp));
4875 };
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004876 }
4877
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02004878 BSSAP.receive(tr_BSSMAP_ClearComplete);
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004879}
4880
Pau Espin Pedrol35801c32021-04-19 13:03:20 +02004881private 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 +01004882
Neels Hofmeyr666f0432020-07-04 00:53:07 +02004883 f_bts_0_cfg(BSCVTY, {"neighbor lac 99 arfcn 123 bsic any"});
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004884 f_vty_transceive(BSCVTY, "handover any to arfcn 123 bsic any");
4885
Pau Espin Pedrol35801c32021-04-19 13:03:20 +02004886 BSSAP.receive(tr_BSSMAP_HandoverRequired(exp_oldToNewBSSIEs));
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004887
4888 f_sleep(0.5);
4889 /* The MSC negotiates Handover Request and Handover Request Ack with
4890 * the other BSS and comes back with a BSSMAP Handover Command
4891 * containing an RR Handover Command coming from the target BSS... */
4892
4893 var PDU_ML3_NW_MS rr_ho_cmd := valueof(ts_RR_HandoverCommand);
4894 log("Remote cell's RR Handover Command passed through as L3 Info: ", rr_ho_cmd);
4895 var octetstring rr_ho_cmd_enc := enc_PDU_ML3_NW_MS(rr_ho_cmd);
4896 log("Remote cell's RR Handover Command passed through as L3 Info, encoded: ", rr_ho_cmd_enc);
4897 BSSAP.send(ts_BSSMAP_HandoverCommand(rr_ho_cmd_enc));
4898
4899 /* expect the Handover Command to go out on RR */
4900 var RSL_Message rsl_ho_cmd
4901 RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, ?)) -> value rsl_ho_cmd;
4902 log("RSL Data Req went out to first BTS: ", rsl_ho_cmd);
4903 var RSL_IE_Body rsl_ho_cmd_l3;
4904 if (not f_rsl_find_ie(rsl_ho_cmd, RSL_IE_L3_INFO, rsl_ho_cmd_l3)) {
4905 log("RSL message contains no L3 Info IE, expected RR Handover Command");
4906 setverdict(fail);
4907 } else {
4908 log("Found L3 Info: ", rsl_ho_cmd_l3);
4909 if (rsl_ho_cmd_l3.l3_info.payload != rr_ho_cmd_enc) {
4910 log("FAIL: the BSC sent out a different L3 Info, not matching the RR Handover Command the other BSS forwarded.");
4911 setverdict(fail);
4912 } else {
4913 log("Success: the BSC sent out the same RR Handover Command the other BSS forwarded.");
4914 setverdict(pass);
4915 }
4916 }
4917
4918 /* When the other BSS has reported a completed handover, this side is
4919 * torn down. */
4920
4921 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_HANDOVER_SUCCESSFUL;
4922 var BssmapCause cause := enum2int(cause_val);
4923 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
4924
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02004925 f_expect_dlcx_conns();
Pau Espin Pedrol06199952021-06-15 11:30:00 +02004926
4927 interleave {
4928 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_RELEASE));
4929 [] RSL.receive(tr_RSL_DEACT_SACCH(g_chan_nr));
4930 [] RSL.receive(tr_RSL_RF_CHAN_REL(g_chan_nr));
4931 }
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004932 setverdict(pass);
Pau Espin Pedrol35801c32021-04-19 13:03:20 +02004933}
4934
4935private function f_tc_ho_out_of_this_bsc(charstring id) runs on MSC_ConnHdlr {
4936 g_pars := f_gen_test_hdlr_pars();
4937 var PDU_BSSAP ass_req := f_gen_ass_req();
4938 ass_req.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4939 ass_req.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
4940 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4941 f_establish_fully(ass_req, exp_compl);
4942
4943 f_ho_out_of_this_bsc();
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004944}
4945testcase TC_ho_out_of_this_bsc() runs on test_CT {
4946 var MSC_ConnHdlr vc_conn;
4947
4948 f_init(1, true);
4949 f_sleep(1.0);
4950
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004951 f_ctrs_bsc_and_bts_init();
4952
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004953 vc_conn := f_start_handler(refers(f_tc_ho_out_of_this_bsc));
4954 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004955
4956 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
4957 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
4958 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
4959 f_ctrs_bsc_and_bts_add(0, "handover:completed");
4960 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
4961 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:completed");
4962 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004963 f_shutdown_helper();
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004964}
4965
Neels Hofmeyr0aa719b2020-10-12 18:43:09 +00004966private function f_mo_l3_transceive(RSL_DCHAN_PT rsl := RSL,
4967 template (value) RslLinkId link_id := ts_RslLinkID_DCCH(0),
Vadim Yanitskiy2ef6a2f2020-10-08 23:17:32 +07004968 template (present) OCT1 dlci := ?,
Vadim Yanitskiyb93aa432020-10-01 14:23:11 +07004969 octetstring l3 := '0123456789'O)
4970runs on MSC_ConnHdlr {
Neels Hofmeyr43654812020-09-25 01:35:35 +02004971 /* The old lchan and conn should still be active. See that arbitrary L3
4972 * is still going through. */
Neels Hofmeyr0aa719b2020-10-12 18:43:09 +00004973 rsl.send(ts_RSL_DATA_IND(g_chan_nr, link_id, l3));
Neels Hofmeyr43654812020-09-25 01:35:35 +02004974 var template PDU_BSSAP exp_data := {
4975 discriminator := '1'B,
4976 spare := '0000000'B,
Vadim Yanitskiyb93aa432020-10-01 14:23:11 +07004977 dlci := dlci,
4978 lengthIndicator := lengthof(l3),
Neels Hofmeyr43654812020-09-25 01:35:35 +02004979 pdu := {
4980 dtap := l3
4981 }
4982 };
4983 BSSAP.receive(exp_data);
4984 setverdict(pass);
4985}
4986
Neels Hofmeyr0aa719b2020-10-12 18:43:09 +00004987private function f_mt_l3_transceive(RSL_DCHAN_PT rsl := RSL,
4988 template (present) RslLinkId link_id := tr_RslLinkID_DCCH(0),
Vadim Yanitskiy0033a3b2020-10-01 22:21:16 +07004989 template (value) OCT1 dlci := '00'O,
4990 octetstring l3 := '0123456789'O)
4991runs on MSC_ConnHdlr {
4992 BSSAP.send(PDU_BSSAP:{
4993 discriminator := '1'B,
4994 spare := '0000000'B,
4995 dlci := dlci,
4996 lengthIndicator := lengthof(l3),
4997 pdu := {
4998 dtap := l3
4999 }
5000 });
Neels Hofmeyr0aa719b2020-10-12 18:43:09 +00005001 rsl.receive(tr_RSL_DATA_REQ(g_chan_nr, link_id, l3));
Vadim Yanitskiy0033a3b2020-10-01 22:21:16 +07005002 setverdict(pass);
5003}
5004
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005005/* BSC asks for inter-BSC HO, but the MSC decides that it won't happen and
5006 * simply never sends a BSSMAP Handover Command. */
5007private function f_tc_ho_out_fail_no_msc_response(charstring id) runs on MSC_ConnHdlr {
Daniel Willmann3b59eb52018-10-29 15:40:55 +01005008 g_pars := f_gen_test_hdlr_pars();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005009
5010 var PDU_BSSAP ass_req := f_gen_ass_req();
5011 ass_req.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
5012 ass_req.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
5013 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
5014 f_establish_fully(ass_req, exp_compl);
5015
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005016 f_bts_0_cfg(BSCVTY, {"neighbor lac 99 arfcn 123 bsic any"});
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005017 f_vty_transceive(BSCVTY, "handover any to arfcn 123 bsic any");
5018
5019 BSSAP.receive(tr_BSSMAP_HandoverRequired);
5020
5021 /* osmo-bsc should time out 10 seconds after the handover started.
5022 * Let's give it a bit extra. */
5023 f_sleep(15.0);
5024
Vadim Yanitskiy74ae5eb2020-10-01 22:13:29 +07005025 f_mo_l3_transceive();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005026 f_sleep(1.0);
5027}
5028testcase TC_ho_out_fail_no_msc_response() runs on test_CT {
5029 var MSC_ConnHdlr vc_conn;
5030
5031 f_init(1, true);
5032 f_sleep(1.0);
5033
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005034 f_ctrs_bsc_and_bts_init();
5035
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005036 vc_conn := f_start_handler(refers(f_tc_ho_out_fail_no_msc_response));
5037 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005038
5039 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5040 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5041 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5042 f_ctrs_bsc_and_bts_add(0, "handover:timeout");
5043 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
5044 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:timeout");
5045 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005046 f_shutdown_helper();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005047}
5048
5049/* BSC asks for inter-BSC HO, receives BSSMAP Handover Command, but MS reports
5050 * RR Handover Failure. */
5051private function f_tc_ho_out_fail_rr_ho_failure(charstring id) runs on MSC_ConnHdlr {
Daniel Willmann3b59eb52018-10-29 15:40:55 +01005052 g_pars := f_gen_test_hdlr_pars();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005053
5054 var PDU_BSSAP ass_req := f_gen_ass_req();
5055 ass_req.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
5056 ass_req.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
5057 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
5058 f_establish_fully(ass_req, exp_compl);
5059
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005060 f_bts_0_cfg(BSCVTY, {"neighbor lac 99 arfcn 123 bsic any"});
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005061 f_vty_transceive(BSCVTY, "handover any to arfcn 123 bsic any");
5062
5063 BSSAP.receive(tr_BSSMAP_HandoverRequired);
5064
5065 f_sleep(0.5);
5066 /* The MSC negotiates Handover Request and Handover Request Ack with
5067 * the other BSS and comes back with a BSSMAP Handover Command
5068 * containing an RR Handover Command coming from the target BSS... */
5069
5070 var PDU_ML3_NW_MS rr_ho_cmd := valueof(ts_RR_HandoverCommand);
5071 log("Remote cell's RR Handover Command passed through as L3 Info: ", rr_ho_cmd);
5072 var octetstring rr_ho_cmd_enc := enc_PDU_ML3_NW_MS(rr_ho_cmd);
5073 log("Remote cell's RR Handover Command passed through as L3 Info, encoded: ", rr_ho_cmd_enc);
5074 BSSAP.send(ts_BSSMAP_HandoverCommand(rr_ho_cmd_enc));
5075
5076 /* expect the Handover Command to go out on RR */
5077 var RSL_Message rsl_ho_cmd
5078 RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, ?)) -> value rsl_ho_cmd;
5079 log("RSL Data Req went out to first BTS: ", rsl_ho_cmd);
5080 var RSL_IE_Body rsl_ho_cmd_l3;
5081 if (not f_rsl_find_ie(rsl_ho_cmd, RSL_IE_L3_INFO, rsl_ho_cmd_l3)) {
5082 log("RSL message contains no L3 Info IE, expected RR Handover Command");
5083 setverdict(fail);
5084 } else {
5085 log("Found L3 Info: ", rsl_ho_cmd_l3);
5086 if (rsl_ho_cmd_l3.l3_info.payload != rr_ho_cmd_enc) {
5087 log("FAIL: the BSC sent out a different L3 Info, not matching the RR Handover Command the other BSS forwarded.");
5088 setverdict(fail);
5089 } else {
5090 log("Success: the BSC sent out the same RR Handover Command the other BSS forwarded.");
5091 setverdict(pass);
5092 }
5093 }
5094
5095 f_sleep(0.2);
5096 f_rsl_send_l3(ts_RRM_HandoverFailure('00'O));
5097
5098 /* Should tell the MSC about the failure */
5099 BSSAP.receive(tr_BSSMAP_HandoverFailure);
5100
5101 f_sleep(1.0);
5102
Vadim Yanitskiy74ae5eb2020-10-01 22:13:29 +07005103 f_mo_l3_transceive();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005104 f_sleep(1.0);
5105
5106 setverdict(pass);
5107 f_sleep(1.0);
5108}
5109testcase TC_ho_out_fail_rr_ho_failure() runs on test_CT {
5110 var MSC_ConnHdlr vc_conn;
5111
5112 f_init(1, true);
5113 f_sleep(1.0);
5114
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005115 f_ctrs_bsc_and_bts_init();
5116
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005117 vc_conn := f_start_handler(refers(f_tc_ho_out_fail_rr_ho_failure));
5118 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005119
5120 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5121 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5122 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5123 f_ctrs_bsc_and_bts_add(0, "handover:failed");
5124 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
5125 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:failed");
5126 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005127 f_shutdown_helper();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005128}
5129
Neels Hofmeyr10f2bfa2019-07-09 19:33:29 +02005130/* BSC asks for inter-BSC-out HO, receives BSSMAP Handover Command, but then no reply is received about HO outcome
5131 * (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 +02005132 * and the lchan is released. */
5133private function f_tc_ho_out_fail_no_result_after_ho_cmd(charstring id) runs on MSC_ConnHdlr {
Daniel Willmann3b59eb52018-10-29 15:40:55 +01005134 g_pars := f_gen_test_hdlr_pars();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005135
5136 var PDU_BSSAP ass_req := f_gen_ass_req();
5137 ass_req.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
5138 ass_req.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
5139 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
5140 f_establish_fully(ass_req, exp_compl);
5141
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005142 f_bts_0_cfg(BSCVTY, {"neighbor lac 99 arfcn 123 bsic any"});
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005143 f_vty_transceive(BSCVTY, "handover any to arfcn 123 bsic any");
5144
5145 BSSAP.receive(tr_BSSMAP_HandoverRequired);
5146
5147 f_sleep(0.5);
5148 /* The MSC negotiates Handover Request and Handover Request Ack with
5149 * the other BSS and comes back with a BSSMAP Handover Command
5150 * containing an RR Handover Command coming from the target BSS... */
5151
5152 var PDU_ML3_NW_MS rr_ho_cmd := valueof(ts_RR_HandoverCommand);
5153 log("Remote cell's RR Handover Command passed through as L3 Info: ", rr_ho_cmd);
5154 var octetstring rr_ho_cmd_enc := enc_PDU_ML3_NW_MS(rr_ho_cmd);
5155 log("Remote cell's RR Handover Command passed through as L3 Info, encoded: ", rr_ho_cmd_enc);
5156 BSSAP.send(ts_BSSMAP_HandoverCommand(rr_ho_cmd_enc));
5157
5158 /* expect the Handover Command to go out on RR */
5159 var RSL_Message rsl_ho_cmd
5160 RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, ?)) -> value rsl_ho_cmd;
5161 log("RSL Data Req went out to first BTS: ", rsl_ho_cmd);
5162 var RSL_IE_Body rsl_ho_cmd_l3;
5163 if (not f_rsl_find_ie(rsl_ho_cmd, RSL_IE_L3_INFO, rsl_ho_cmd_l3)) {
5164 log("RSL message contains no L3 Info IE, expected RR Handover Command");
5165 setverdict(fail);
5166 } else {
5167 log("Found L3 Info: ", rsl_ho_cmd_l3);
5168 if (rsl_ho_cmd_l3.l3_info.payload != rr_ho_cmd_enc) {
5169 log("FAIL: the BSC sent out a different L3 Info, not matching the RR Handover Command the other BSS forwarded.");
5170 setverdict(fail);
5171 } else {
5172 log("Success: the BSC sent out the same RR Handover Command the other BSS forwarded.");
5173 setverdict(pass);
5174 }
5175 }
5176
Neels Hofmeyr10f2bfa2019-07-09 19:33:29 +02005177 /* We get neither success nor failure report from the remote BSS. Eventually T8 times out and we run into 3GPP
5178 * TS 48.008 3.1.5.3.3 "Abnormal Conditions": Clear Request should go to the MSC, and RR should be released
5179 * after Clear Command */
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005180
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02005181 var PDU_BSSAP rx_clear_request;
Neels Hofmeyre1797aa2019-07-09 19:34:04 +02005182 BSSAP.receive(tr_BSSMAP_ClearRequest) -> value rx_clear_request;
5183 log("Got BSSMAP Clear Request");
5184 /* Instruct BSC to clear channel */
5185 var BssmapCause cause := bit2int(rx_clear_request.pdu.bssmap.clearRequest.cause.causeValue);
5186 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
5187
5188 var MgcpCommand mgcp;
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005189 interleave {
Neels Hofmeyr861a4c12018-11-07 01:23:17 +01005190 [] RSL.receive(tr_RSL_DEACT_SACCH(g_chan_nr)) {
5191 log("Got Deact SACCH");
5192 }
Harald Welte924b6ea2019-02-04 01:05:34 +01005193 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_RELEASE)) {
Neels Hofmeyr211169d2018-11-07 00:37:29 +01005194 log("Got RR Release");
5195 }
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005196 [] RSL.receive(tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL)) {
5197 log("Got RF Chan Rel");
5198 RSL.send(ts_RSL_RF_CHAN_REL_ACK(g_chan_nr));
5199 }
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005200 }
5201
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02005202 f_expect_dlcx_conns();
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02005203
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005204 setverdict(pass);
5205 f_sleep(1.0);
5206}
Neels Hofmeyrd8a602c2019-07-09 19:46:01 +02005207testcase TC_ho_out_fail_no_result_after_ho_cmd() runs on test_CT {
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005208 var MSC_ConnHdlr vc_conn;
5209
5210 f_init(1, true);
5211 f_sleep(1.0);
5212
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005213 f_ctrs_bsc_and_bts_init();
5214
Neels Hofmeyrd8a602c2019-07-09 19:46:01 +02005215 vc_conn := f_start_handler(refers(f_tc_ho_out_fail_no_result_after_ho_cmd));
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005216 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005217
5218 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5219 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5220 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5221 f_ctrs_bsc_and_bts_add(0, "handover:timeout");
5222 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
5223 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:timeout");
5224 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005225 f_shutdown_helper();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005226}
5227
Pau Espin Pedrol35801c32021-04-19 13:03:20 +02005228private 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 +01005229 /* Hack: the proper way would be to wait for the BSSMAP Handover Request ACK and extract the
5230 * actual assigned chan_nr from its L3 (RR Handover Command) message. But osmo-bsc starts acting
5231 * on the lchan even before we get a chance to evaluate the BSSMAP Handover Request ACK. So we
5232 * need to assume that osmo-bsc will activate TS 1 and already set up this lchan's RSL emulation
5233 * before we get started. */
5234 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
5235 f_rslem_register(0, new_chan_nr);
5236 g_chan_nr := new_chan_nr;
5237 f_sleep(1.0);
5238
5239 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
5240 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
5241 activate(as_Media());
5242
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005243 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Pau Espin Pedrolc08d5522021-04-16 15:40:38 +02005244 f_gen_handover_req(aoip_tla := g_pars.host_aoip_tla,
5245 oldToNewBSSIEs := oldToNewBSSIEs)));
Harald Welte6811d102019-04-14 22:23:14 +02005246 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005247
5248 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
5249
5250 var PDU_BSSAP rx_bssap;
5251 var octetstring ho_command_str;
5252
5253 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
Pau Espin Pedrol76ba5412019-06-10 11:00:33 +02005254
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005255 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
5256 log("Received L3 Info in HO Request Ack: ", ho_command_str);
5257 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
5258 log("L3 Info in HO Request Ack is ", ho_command);
5259
5260 var GsmArfcn arfcn;
5261 var RslChannelNr actual_new_chan_nr;
5262 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
5263 actual_new_chan_nr, arfcn);
5264
5265 if (actual_new_chan_nr != new_chan_nr) {
5266 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
5267 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
5268 setverdict(fail);
5269 return;
5270 }
5271 log("Handover Command chan_nr is", actual_new_chan_nr);
5272
5273 /* Now the MSC forwards the RR Handover Command to the other BSC, which
5274 * tells the MS to handover to the new lchan. Here comes the new MS on
5275 * the new lchan with a Handover RACH: */
5276
5277 /* send handover detect */
5278
5279 RSL.send(ts_RSL_HANDO_DET(new_chan_nr));
5280
5281 BSSAP.receive(tr_BSSMAP_HandoverDetect);
5282
5283 /* send handover complete over the new channel */
5284
5285 var PDU_ML3_MS_NW l3_tx := valueof(ts_RRM_HandoverComplete('00'O));
5286 RSL.send(ts_RSL_EST_IND(new_chan_nr, valueof(ts_RslLinkID_DCCH(0)),
5287 enc_PDU_ML3_MS_NW(l3_tx)));
5288
5289 BSSAP.receive(tr_BSSMAP_HandoverComplete);
Pau Espin Pedrol35801c32021-04-19 13:03:20 +02005290 setverdict(pass);
5291}
Pau Espin Pedrolc08d5522021-04-16 15:40:38 +02005292
Pau Espin Pedrol35801c32021-04-19 13:03:20 +02005293private function f_tc_ho_into_this_bsc(charstring id) runs on MSC_ConnHdlr {
Pau Espin Pedrol9ae36d52021-06-15 17:29:43 +02005294 var template PDU_ML3_NW_MS exp_rr_rel_tmpl;
Pau Espin Pedrol35801c32021-04-19 13:03:20 +02005295 var template (omit) BSSMAP_oldToNewBSSIEs oldToNewBSSIEs := omit;
5296 if (not istemplatekind(g_pars.last_used_eutran_plmn, "omit")) {
5297 oldToNewBSSIEs := f_ts_BSSMAP_oldToNewBSSIEs(ts_BSSMAP_LastUsedEUTRANPLMNId(g_pars.last_used_eutran_plmn));
Pau Espin Pedrol9ae36d52021-06-15 17:29:43 +02005298 }
5299 if (g_pars.exp_fast_return) {
Pau Espin Pedrol35801c32021-04-19 13:03:20 +02005300 exp_rr_rel_tmpl := tr_RRM_RR_RELEASE_CellSelectInd;
Pau Espin Pedrol9ae36d52021-06-15 17:29:43 +02005301 } else {
5302 exp_rr_rel_tmpl := tr_RRM_RR_RELEASE;
Pau Espin Pedrol35801c32021-04-19 13:03:20 +02005303 }
5304 f_ho_into_this_bsc(id, oldToNewBSSIEs);
Pau Espin Pedrolc08d5522021-04-16 15:40:38 +02005305 f_perform_clear(RSL, exp_rr_rel_tmpl);
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005306 setverdict(pass);
5307}
Pau Espin Pedrol07866632020-09-03 19:10:55 +02005308function f_tc_ho_into_this_bsc_main(TestHdlrParams pars) runs on test_CT {
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005309 var MSC_ConnHdlr vc_conn;
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005310
5311 f_init(1, true);
5312 f_sleep(1.0);
5313
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005314 f_ctrs_bsc_and_bts_init();
5315
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005316 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
5317 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005318
5319 vc_conn := f_start_handler(refers(f_tc_ho_into_this_bsc), pars);
5320 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005321
5322 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5323 f_ctrs_bsc_and_bts_add(0, "handover:completed");
5324 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:attempted");
5325 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:completed");
5326 f_ctrs_bsc_and_bts_verify();
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005327}
5328
Pau Espin Pedrol07866632020-09-03 19:10:55 +02005329testcase TC_ho_into_this_bsc() runs on test_CT {
5330 var TestHdlrParams pars := f_gen_test_hdlr_pars();
5331 f_tc_ho_into_this_bsc_main(pars);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005332 f_shutdown_helper();
Pau Espin Pedrol07866632020-09-03 19:10:55 +02005333}
5334
5335testcase TC_ho_into_this_bsc_tla_v6() runs on test_CT {
5336 var TestHdlrParams pars := f_gen_test_hdlr_pars();
5337 pars.host_aoip_tla := "::6";
5338 f_tc_ho_into_this_bsc_main(pars);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005339 f_shutdown_helper();
Pau Espin Pedrol07866632020-09-03 19:10:55 +02005340}
5341
Pau Espin Pedrolc08d5522021-04-16 15:40:38 +02005342/* Similar to TC_ho_into_this_bsc, but when in SRVCC, HO Req contains "Old BSS
Pau Espin Pedrol35801c32021-04-19 13:03:20 +02005343 to New BSS Information" IE with "Last Used E-UTRAN PLMN Id", which, when the
Pau Espin Pedrolc08d5522021-04-16 15:40:38 +02005344 channel is later released (RR CHannel Release), should trigger inclusion of
5345 IE "Cell Selection Indicator after Release of all TCH and SDCCH" with E-UTRAN
5346 neighbors. */
5347testcase TC_srvcc_eutran_to_geran() runs on test_CT {
5348 var TestHdlrParams pars := f_gen_test_hdlr_pars();
5349 pars.last_used_eutran_plmn := '323454'O;
Pau Espin Pedrol9ae36d52021-06-15 17:29:43 +02005350 pars.exp_fast_return := true;
Pau Espin Pedrolc08d5522021-04-16 15:40:38 +02005351 f_tc_ho_into_this_bsc_main(pars);
Pau Espin Pedrol211a7142021-06-15 16:43:03 +02005352
5353 f_ctrs_bsc_and_bts_add(0, "srvcc:attempted");
5354 f_ctrs_bsc_and_bts_add(0, "srvcc:completed");
5355 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrolc08d5522021-04-16 15:40:38 +02005356 f_shutdown_helper();
5357}
5358
Pau Espin Pedrol9ae36d52021-06-15 17:29:43 +02005359/* Same as TC_srvcc_eutran_to_geran, but test explicitly forbiding fast return
5360 on the BTS. As a result, RR Release shouldn't contain the EUTRAN neighbor
5361 list when the channel is released. */
5362testcase TC_srvcc_eutran_to_geran_forbid_fast_return() runs on test_CT {
5363 f_init_vty();
5364 f_vty_allow_srvcc_fast_return(true, 0)
5365
5366 var TestHdlrParams pars := f_gen_test_hdlr_pars();
5367 pars.last_used_eutran_plmn := '323454'O;
5368 pars.exp_fast_return := false;
5369 f_tc_ho_into_this_bsc_main(pars);
5370 f_vty_allow_srvcc_fast_return(false, 0);
5371 f_shutdown_helper();
5372}
5373
Pau Espin Pedrol35801c32021-04-19 13:03:20 +02005374private function f_tc_srvcc_eutran_to_geran_ho_out(charstring id) runs on MSC_ConnHdlr {
5375 var template (omit) BSSMAP_oldToNewBSSIEs oldToNewBSSIEs;
5376 oldToNewBSSIEs := f_ts_BSSMAP_oldToNewBSSIEs(ts_BSSMAP_LastUsedEUTRANPLMNId(g_pars.last_used_eutran_plmn));
5377 f_ho_into_this_bsc(id, oldToNewBSSIEs);
5378 f_ho_out_of_this_bsc(oldToNewBSSIEs);
5379 setverdict(pass);
5380}
Pau Espin Pedrol9ae36d52021-06-15 17:29:43 +02005381
5382private function f_tc_srvcc_eutran_to_geran_ho_out_main(boolean disable_fast_return)
5383 runs on test_CT {
Pau Espin Pedrol35801c32021-04-19 13:03:20 +02005384 var MSC_ConnHdlr vc_conn;
5385 var TestHdlrParams pars := f_gen_test_hdlr_pars();
5386
5387 f_init(1, true);
Pau Espin Pedrol9ae36d52021-06-15 17:29:43 +02005388 if (disable_fast_return) {
5389 f_vty_allow_srvcc_fast_return(true, 0);
5390 }
Pau Espin Pedrol35801c32021-04-19 13:03:20 +02005391 f_sleep(1.0);
5392
5393 f_ctrs_bsc_and_bts_init();
5394
5395 pars.last_used_eutran_plmn := '323454'O;
5396 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
5397 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
5398
5399 vc_conn := f_start_handler(refers(f_tc_srvcc_eutran_to_geran_ho_out), pars);
5400 vc_conn.done;
5401
5402 f_ctrs_bsc_and_bts_add(0, "handover:attempted", 2);
5403 f_ctrs_bsc_and_bts_add(0, "handover:completed", 2);
5404 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:attempted", 1);
5405 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:completed", 1);
5406 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted", 1);
5407 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:completed", 1);
Pau Espin Pedrol211a7142021-06-15 16:43:03 +02005408
5409 f_ctrs_bsc_and_bts_add(0, "srvcc:attempted", 1);
5410 f_ctrs_bsc_and_bts_add(0, "srvcc:completed", 1);
Pau Espin Pedrol35801c32021-04-19 13:03:20 +02005411 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol9ae36d52021-06-15 17:29:43 +02005412
5413 if (disable_fast_return) {
5414 f_vty_allow_srvcc_fast_return(false, 0);
5415 }
Pau Espin Pedrol35801c32021-04-19 13:03:20 +02005416 f_shutdown_helper();
5417}
5418
Pau Espin Pedrol9ae36d52021-06-15 17:29:43 +02005419/* First, HO into BSC from EUTRAN (SRVCC): HO Request contains "Old BSS to New
5420 BSS Information" IE with "Last Used E-UTRAN PLMN Id".
5421 Second, HO to another BSC: HO Required contains "Old BSS to New BSS Information"
5422 IE with "Last Used E-UTRAN PLMN Id" from first step. */
5423testcase TC_srvcc_eutran_to_geran_ho_out() runs on test_CT {
5424 f_tc_srvcc_eutran_to_geran_ho_out_main(false);
5425}
5426/* Validate subsequent intra-GSM-HO works the same (with OldBSSToNewBSSInfo IE)
5427 * independently of fast-reture allowed/forbidden in local BTS */
5428testcase TC_srvcc_eutran_to_geran_ho_out_forbid_fast_return() runs on test_CT {
5429 f_tc_srvcc_eutran_to_geran_ho_out_main(true);
5430}
5431
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005432private function f_tc_ho_in_fail_msc_clears(charstring id) runs on MSC_ConnHdlr {
5433 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
5434 f_rslem_register(0, new_chan_nr);
5435 g_chan_nr := new_chan_nr;
5436 f_sleep(1.0);
5437
5438 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
5439 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
5440 activate(as_Media());
5441
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005442 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005443 f_gen_handover_req()));
Harald Welte6811d102019-04-14 22:23:14 +02005444 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005445
5446 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
5447
5448 var PDU_BSSAP rx_bssap;
5449 var octetstring ho_command_str;
5450
5451 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
5452
5453 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
5454 log("Received L3 Info in HO Request Ack: ", ho_command_str);
5455 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
5456 log("L3 Info in HO Request Ack is ", ho_command);
5457
5458 var GsmArfcn arfcn;
5459 var RslChannelNr actual_new_chan_nr;
5460 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
5461 actual_new_chan_nr, arfcn);
5462
5463 if (actual_new_chan_nr != new_chan_nr) {
5464 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
5465 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
5466 setverdict(fail);
5467 return;
5468 }
5469 log("Handover Command chan_nr is", actual_new_chan_nr);
5470
Neels Hofmeyr61ca08d2019-05-06 23:52:22 +02005471 /* For deterministic test results, give some time for the MGW endpoint to be configured */
5472 f_sleep(1.0);
5473
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005474 /* Now the MSC forwards the RR Handover Command to the other BSC, which
5475 * tells the MS to handover to the new lchan. In this case, the MS
5476 * reports a Handover Failure to the old BSS, which forwards a BSSMAP
5477 * Handover Failure to the MSC. The procedure according to 3GPP TS
5478 * 48.008 3.1.5.3.2 "Handover Failure" is then that the MSC sends a
5479 * BSSMAP Clear Command: */
5480
5481 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_RADIO_INTERFACE_FAILURE_REVERSION;
5482 var BssmapCause cause := enum2int(cause_val);
5483 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
5484
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02005485 f_expect_dlcx_conns();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005486 setverdict(pass);
5487 f_sleep(1.0);
5488
5489 setverdict(pass);
5490}
5491testcase TC_ho_in_fail_msc_clears() runs on test_CT {
5492 var MSC_ConnHdlr vc_conn;
5493 var TestHdlrParams pars := f_gen_test_hdlr_pars();
5494
5495 f_init(1, true);
5496 f_sleep(1.0);
5497
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005498 f_ctrs_bsc_and_bts_init();
5499
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005500 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
5501 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005502
5503 vc_conn := f_start_handler(refers(f_tc_ho_in_fail_msc_clears), pars);
5504 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005505
5506 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5507 f_ctrs_bsc_and_bts_add(0, "handover:stopped");
5508 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:attempted");
5509 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:stopped");
5510 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005511 f_shutdown_helper();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005512}
5513
5514private function f_tc_ho_in_fail_msc_clears_after_ho_detect(charstring id) runs on MSC_ConnHdlr {
5515 /* Hack: the proper way would be to wait for the BSSMAP Handover Request ACK and extract the
5516 * actual assigned chan_nr from its L3 (RR Handover Command) message. But osmo-bsc starts acting
5517 * on the lchan even before we get a chance to evaluate the BSSMAP Handover Request ACK. So we
5518 * need to assume that osmo-bsc will activate TS 1 and already set up this lchan's RSL emulation
5519 * before we get started. */
5520 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
5521 f_rslem_register(0, new_chan_nr);
5522 g_chan_nr := new_chan_nr;
5523 f_sleep(1.0);
5524
5525 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
5526 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
5527 activate(as_Media());
5528
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005529 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005530 f_gen_handover_req()));
Harald Welte6811d102019-04-14 22:23:14 +02005531 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005532
5533 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
5534
5535 var PDU_BSSAP rx_bssap;
5536 var octetstring ho_command_str;
5537
5538 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
5539
5540 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
5541 log("Received L3 Info in HO Request Ack: ", ho_command_str);
5542 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
5543 log("L3 Info in HO Request Ack is ", ho_command);
5544
5545 var GsmArfcn arfcn;
5546 var RslChannelNr actual_new_chan_nr;
5547 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
5548 actual_new_chan_nr, arfcn);
5549
5550 if (actual_new_chan_nr != new_chan_nr) {
5551 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
5552 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
5553 setverdict(fail);
5554 return;
5555 }
5556 log("Handover Command chan_nr is", actual_new_chan_nr);
5557
5558 /* Now the MSC forwards the RR Handover Command to the other BSC, which
5559 * tells the MS to handover to the new lchan. Here comes the new MS on
5560 * the new lchan with a Handover RACH: */
5561
5562 /* send handover detect */
5563
5564 RSL.send(ts_RSL_HANDO_DET(new_chan_nr));
5565
5566 BSSAP.receive(tr_BSSMAP_HandoverDetect);
5567
5568 /* The MSC chooses to clear the connection now, maybe we got the
5569 * Handover RACH on the new cell but the MS still signaled Handover
5570 * Failure to the old BSS? */
5571
5572 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_RADIO_INTERFACE_FAILURE_REVERSION;
5573 var BssmapCause cause := enum2int(cause_val);
5574 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
5575
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02005576 f_expect_dlcx_conns();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005577 f_sleep(1.0);
5578}
5579testcase TC_ho_in_fail_msc_clears_after_ho_detect() runs on test_CT {
5580 var MSC_ConnHdlr vc_conn;
5581 var TestHdlrParams pars := f_gen_test_hdlr_pars();
5582
5583 f_init(1, true);
5584 f_sleep(1.0);
5585
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005586 f_ctrs_bsc_and_bts_init();
5587
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005588 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
5589 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005590
5591 vc_conn := f_start_handler(refers(f_tc_ho_in_fail_msc_clears_after_ho_detect), pars);
5592 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005593
5594 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5595 f_ctrs_bsc_and_bts_add(0, "handover:stopped");
5596 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:attempted");
5597 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:stopped");
5598 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005599 f_shutdown_helper();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005600}
5601
5602/* The new BSS's lchan times out before the MSC decides that handover failed. */
5603private function f_tc_ho_in_fail_no_detect(charstring id) runs on MSC_ConnHdlr {
5604 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
5605 f_rslem_register(0, new_chan_nr);
5606 g_chan_nr := new_chan_nr;
5607 f_sleep(1.0);
5608
5609 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
5610 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
5611 activate(as_Media());
5612
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005613 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005614 f_gen_handover_req()));
Harald Welte6811d102019-04-14 22:23:14 +02005615 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005616
5617 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
5618
5619 var PDU_BSSAP rx_bssap;
5620 var octetstring ho_command_str;
5621
5622 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
5623
5624 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
5625 log("Received L3 Info in HO Request Ack: ", ho_command_str);
5626 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
5627 log("L3 Info in HO Request Ack is ", ho_command);
5628
5629 var GsmArfcn arfcn;
5630 var RslChannelNr actual_new_chan_nr;
5631 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
5632 actual_new_chan_nr, arfcn);
5633
5634 if (actual_new_chan_nr != new_chan_nr) {
5635 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
5636 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
5637 setverdict(fail);
5638 return;
5639 }
5640 log("Handover Command chan_nr is", actual_new_chan_nr);
5641
5642 /* Now the MSC forwards the RR Handover Command to the other BSC, which
5643 * tells the MS to handover to the new lchan. But the MS never shows up
5644 * on the new lchan. */
5645
5646 BSSAP.receive(tr_BSSMAP_HandoverFailure);
5647
5648 /* Did osmo-bsc also send a Clear Request? */
5649 timer T := 0.5;
5650 T.start;
5651 alt {
5652 [] BSSAP.receive(tr_BSSMAP_ClearRequest);
5653 [] T.timeout { }
5654 }
5655
5656 /* MSC plays along with a Clear Command (no matter whether osmo-bsc
5657 * asked for it, this is a Handover Failure after all). */
5658
5659 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_RADIO_INTERFACE_FAILURE_REVERSION;
5660 var BssmapCause cause := enum2int(cause_val);
5661 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
5662
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02005663 f_expect_dlcx_conns();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005664 f_sleep(1.0);
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005665}
5666testcase TC_ho_in_fail_no_detect() runs on test_CT {
5667 var MSC_ConnHdlr vc_conn;
5668 var TestHdlrParams pars := f_gen_test_hdlr_pars();
5669
5670 f_init(1, true);
5671 f_sleep(1.0);
5672
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005673 f_ctrs_bsc_and_bts_init();
5674
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005675 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
5676 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005677
5678 vc_conn := f_start_handler(refers(f_tc_ho_in_fail_no_detect), pars);
5679 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005680
5681 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5682 f_ctrs_bsc_and_bts_add(0, "handover:error");
5683 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:attempted");
5684 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:error");
5685 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005686 f_shutdown_helper();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005687}
5688
5689/* Same as f_tc_ho_in_fail_no_detect, but MSC fails to send a Clear Command */
5690private function f_tc_ho_in_fail_no_detect2(charstring id) runs on MSC_ConnHdlr {
5691 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
5692 f_rslem_register(0, new_chan_nr);
5693 g_chan_nr := new_chan_nr;
5694 f_sleep(1.0);
5695
5696 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
5697 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
5698 activate(as_Media());
5699
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005700 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005701 f_gen_handover_req()));
Harald Welte6811d102019-04-14 22:23:14 +02005702 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005703
5704 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
5705
5706 var PDU_BSSAP rx_bssap;
5707 var octetstring ho_command_str;
5708
5709 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
5710
5711 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
5712 log("Received L3 Info in HO Request Ack: ", ho_command_str);
5713 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
5714 log("L3 Info in HO Request Ack is ", ho_command);
5715
5716 var GsmArfcn arfcn;
5717 var RslChannelNr actual_new_chan_nr;
5718 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
5719 actual_new_chan_nr, arfcn);
5720
5721 if (actual_new_chan_nr != new_chan_nr) {
5722 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
5723 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
5724 setverdict(fail);
5725 return;
5726 }
5727 log("Handover Command chan_nr is", actual_new_chan_nr);
5728
5729 /* Now the MSC forwards the RR Handover Command to the other BSC, which
5730 * tells the MS to handover to the new lchan. But the MS never shows up
5731 * on the new lchan. */
5732
5733 BSSAP.receive(tr_BSSMAP_HandoverFailure);
5734
5735 /* MSC plays dumb and sends no Clear Command */
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005736 var PDU_BSSAP rx_clear_request;
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02005737
5738 BSSAP.receive(tr_BSSMAP_ClearRequest) -> value rx_clear_request {
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005739 var BssmapCause cause := bit2int(rx_clear_request.pdu.bssmap.clearRequest.cause.causeValue);
5740 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
5741 };
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02005742 f_expect_dlcx_conns();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005743 f_sleep(1.0);
5744}
5745testcase TC_ho_in_fail_no_detect2() runs on test_CT {
5746 var MSC_ConnHdlr vc_conn;
5747 var TestHdlrParams pars := f_gen_test_hdlr_pars();
5748
5749 f_init(1, true);
5750 f_sleep(1.0);
5751
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005752 f_ctrs_bsc_and_bts_init();
5753
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005754 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
5755 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005756
5757 vc_conn := f_start_handler(refers(f_tc_ho_in_fail_no_detect2), pars);
5758 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005759
5760 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5761 f_ctrs_bsc_and_bts_add(0, "handover:error");
5762 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:attempted");
5763 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:error");
5764 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005765 f_shutdown_helper();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005766}
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005767
Neels Hofmeyr91401012019-07-11 00:42:35 +02005768type record of charstring Commands;
5769
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005770private function f_bts_0_cfg(TELNETasp_PT pt, Commands cmds := {})
Neels Hofmeyr91401012019-07-11 00:42:35 +02005771{
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005772 f_vty_enter_cfg_bts(pt, 0);
Neels Hofmeyr91401012019-07-11 00:42:35 +02005773 for (var integer i := 0; i < sizeof(cmds); i := i+1) {
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005774 f_vty_transceive(pt, cmds[i]);
Neels Hofmeyr91401012019-07-11 00:42:35 +02005775 }
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005776 f_vty_transceive(pt, "end");
Neels Hofmeyr91401012019-07-11 00:42:35 +02005777}
5778
Pau Espin Pedrolc675b612020-01-09 19:55:40 +01005779private function f_cs7_inst_0_cfg(TELNETasp_PT pt, Commands cmds := {})
5780{
5781 f_vty_enter_cfg_cs7_inst(pt, 0);
5782 for (var integer i := 0; i < sizeof(cmds); i := i+1) {
5783 f_vty_transceive(pt, cmds[i]);
5784 }
5785 f_vty_transceive(pt, "end");
5786}
5787
Neels Hofmeyr91401012019-07-11 00:42:35 +02005788private function f_probe_for_handover(charstring log_label,
5789 charstring log_descr,
5790 charstring handover_vty_cmd,
5791 boolean expect_handover,
5792 boolean is_inter_bsc_handover := false)
5793runs on MSC_ConnHdlr
5794{
Neels Hofmeyrb3fc8982020-05-11 00:16:42 +02005795 /* We're going to thwart any and all handover attempts, just be ready to handle (and ignore) handover target
5796 * lchans to be established on bts 1 or bts 2. */
5797 f_rslem_suspend(RSL1_PROC);
5798 f_rslem_suspend(RSL2_PROC);
5799
Neels Hofmeyr91401012019-07-11 00:42:35 +02005800 var RSL_Message rsl;
5801
5802 var charstring log_msg := " (expecting handover)"
5803 if (not expect_handover) {
5804 log_msg := " (expecting NO handover)";
5805 }
5806 log("f_probe_for_handover starting: " & log_label & ": " & log_descr & log_msg);
5807 f_vty_transceive(BSCVTY, handover_vty_cmd);
5808
Neels Hofmeyr91401012019-07-11 00:42:35 +02005809 timer T := 2.0;
5810 T.start;
5811
5812 alt {
5813 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr)) -> value rsl {
5814 var PDU_ML3_NW_MS l3 := dec_PDU_ML3_NW_MS(rsl.ies[2].body.l3_info.payload);
5815 log("Rx L3 from net: ", l3);
5816 if (ischosen(l3.msgs.rrm.handoverCommand)) {
5817 var RslChannelNr new_chan_nr;
5818 var GsmArfcn arfcn;
5819 f_ChDesc2RslChanNr(l3.msgs.rrm.handoverCommand.channelDescription2,
5820 new_chan_nr, arfcn);
5821 log("Handover to new chan ", new_chan_nr, " on ARFCN ", arfcn);
5822 log(l3.msgs.rrm.handoverCommand);
5823
5824 /* Need to register for new lchan on new BTS -- it's either bts 1 or bts 2. It doesn't really
5825 * matter on which BTS it really is, we're not going to follow through an entire handover
5826 * anyway. */
5827 f_rslem_register(0, new_chan_nr, RSL1_PROC);
5828 f_rslem_resume(RSL1_PROC);
5829 f_rslem_register(0, new_chan_nr, RSL2_PROC);
5830 f_rslem_resume(RSL2_PROC);
5831
5832 if (expect_handover and not is_inter_bsc_handover) {
5833 setverdict(pass);
5834 log("f_probe_for_handover(" & log_label & "): Got RSL Handover Command as expected.");
5835 } else {
5836 setverdict(fail, "f_probe_for_handover(" & log_label & "): Expected none, but got RSL Handover Command. "
5837 & log_label & ": " & log_descr);
5838 }
5839
5840 log("f_probe_for_handover(" & log_label & "): Ending the test: Handover Failure stops the procedure.");
5841 /* osmo-bsc has triggered Handover. That's all we need to know for this test, reply with
5842 * Handover Failure. */
5843 f_rsl_send_l3(ts_RRM_HandoverFailure('00'O));
5844
5845 /* target BTS is told to release lchan again; don't care which BTS nor what messages. */
5846 f_sleep(0.5);
5847 RSL1.clear;
5848 RSL2.clear;
5849 log("f_probe_for_handover(" & log_label & "): done (got RSL Handover Command)");
5850 break;
5851 } else {
5852 repeat;
5853 }
5854 }
5855 [] BSSAP.receive(tr_BSSMAP_HandoverRequired) {
5856 if (expect_handover and is_inter_bsc_handover) {
5857 setverdict(pass);
5858 log("f_probe_for_handover(" & log_label & "): Got BSSMAP Handover Required as expected.");
5859 } else {
5860 setverdict(fail, "f_probe_for_handover(" & log_label & "): Expected none, but got BSSMAP Handover Required. "
5861 & log_label & ": " & log_descr);
5862 }
5863
5864 log("f_probe_for_handover(" & log_label & "): done (got BSSMAP Handover Required)");
5865
5866 /* Note: f_tc_ho_neighbor_config_start() sets T7, the timeout for BSSMAP Handover Required, to
5867 * 1 second. There is no legal way to quickly abort a handover after a BSSMAP Handover Required,
5868 * setting a short timeout and waiting is the only way. */
5869 log("f_probe_for_handover(" & log_label & "): waiting for inter-BSC HO to time out...");
5870 f_sleep(1.5);
5871 log("f_probe_for_handover(" & log_label & "): ...done");
5872
5873 break;
5874 }
5875 [] T.timeout {
5876 if (expect_handover) {
5877 setverdict(fail, "f_probe_for_handover(" & log_label & "): Expected Handover, but got none. "
5878 & log_label & ": " & log_descr);
5879 } else {
5880 setverdict(pass);
5881 log("f_probe_for_handover(" & log_label & "): Got no Handover, as expected.");
5882 }
5883 log("f_probe_for_handover(" & log_label & "): done (got no Handover)");
5884 break;
5885 }
5886 }
5887
5888 f_rslem_resume(RSL1_PROC);
5889 f_rslem_resume(RSL2_PROC);
5890 f_sleep(3.0);
5891 RSL.clear;
5892
5893 log("f_probe_for_handover(" & log_label & "): done clearing");
5894}
5895
5896/* Test the effect of various neighbor configuration scenarios:
5897 *
5898 * To avoid complexity, block off any actual handover operation, and always remain on the lchan at bts 0.
5899 * Reconfigure the neighbors for bts 0, trigger a Handover, and probe whether osmo-bsc does or doesn't start HO.
5900 */
5901private function f_tc_ho_neighbor_config_start() runs on MSC_ConnHdlr {
5902 g_pars := f_gen_test_hdlr_pars();
5903 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
5904 var PDU_BSSAP ass_cmd := f_gen_ass_req();
5905 const OCT8 kc := '0001020304050607'O;
5906
5907 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
5908 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
5909
5910 /* Establish lchan at bts 0 */
5911 f_establish_fully(ass_cmd, exp_compl);
5912
5913 /* Shorten the inter-BSC Handover timeout, to not wait so long for inter-BSC Handovers */
5914 f_vty_enter_cfg_network(BSCVTY);
5915 f_vty_transceive(BSCVTY, "timer T7 1");
5916 f_vty_transceive(BSCVTY, "end");
5917}
5918
5919private function f_tc_ho_neighbor_config_1(charstring id) runs on MSC_ConnHdlr {
5920 f_tc_ho_neighbor_config_start();
5921
5922 /*
5923 * bts 0 ARFCN 871 BSIC 10
5924 * bts 1 ARFCN 871 BSIC 11
5925 * bts 2 ARFCN 871 BSIC 12
5926 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
5927 */
5928
5929 log("f_tc_ho_neighbor_config: 1. No 'neighbor' config");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005930 f_bts_0_cfg(BSCVTY, {"no neighbors"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02005931 f_probe_for_handover("1.a", "HO to bts 1 works, implicitly listed as neighbor (legacy behavior when none are configured)",
5932 "handover any to arfcn 871 bsic 11",
5933 true);
5934
5935 f_probe_for_handover("1.b", "HO to unknown cell does not start",
5936 "handover any to arfcn 13 bsic 39",
5937 false);
5938
5939 f_probe_for_handover("1.c", "HO to 871-12 is ambiguous = error",
5940 "handover any to arfcn 871 bsic 12",
5941 false);
5942
5943 f_probe_for_handover("1.d", "HO to 871-11 still works (verify that this test properly cleans up)",
5944 "handover any to arfcn 871 bsic 11",
5945 true);
5946}
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005947testcase TC_ho_neighbor_config_1() runs on test_CT {
5948 var MSC_ConnHdlr vc_conn;
5949 f_init(3, true, guard_timeout := 60.0);
5950 f_sleep(1.0);
5951 f_ctrs_bsc_and_bts_init();
5952 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_1));
5953 vc_conn.done;
5954
5955 /* f_tc_ho_neighbor_config_start() */
5956 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5957 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5958
5959 /* 1.a */
5960 /* "failed" means a handover was triggered and started (which is all this test aims for) and the test ended the
5961 * handover quickly by sending a Handover Failure message. */
5962 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5963 f_ctrs_bsc_and_bts_add(0, "handover:failed");
5964 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
5965 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:failed");
5966
5967 /* 1.b */
5968 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5969 f_ctrs_bsc_and_bts_add(0, "handover:error");
5970
5971 /* 1.c */
5972 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5973 f_ctrs_bsc_and_bts_add(0, "handover:error");
5974
5975 /* 1.d */
5976 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5977 f_ctrs_bsc_and_bts_add(0, "handover:failed");
5978 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
5979 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:failed");
5980
5981 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005982 f_shutdown_helper();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005983}
5984
Neels Hofmeyr91401012019-07-11 00:42:35 +02005985private function f_tc_ho_neighbor_config_2(charstring id) runs on MSC_ConnHdlr {
5986 f_tc_ho_neighbor_config_start();
5987
5988 /*
5989 * bts 0 ARFCN 871 BSIC 10
5990 * bts 1 ARFCN 871 BSIC 11
5991 * bts 2 ARFCN 871 BSIC 12
5992 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
5993 */
5994
5995 log("f_tc_ho_neighbor_config: 2. explicit local neighbor: 'neighbor bts 1'");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005996 f_bts_0_cfg(BSCVTY, {"neighbor bts 1"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02005997 f_sleep(0.5);
5998
5999 f_probe_for_handover("2.a", "HO to bts 1 works, explicitly listed as neighbor",
6000 "handover any to arfcn 871 bsic 11",
6001 true);
6002
6003 f_probe_for_handover("2.b", "HO to bts 2 doesn't work, not listed as neighbor",
6004 "handover any to arfcn 871 bsic 12",
6005 false);
6006}
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006007testcase TC_ho_neighbor_config_2() runs on test_CT {
6008 var MSC_ConnHdlr vc_conn;
6009 f_init(3, true, guard_timeout := 50.0);
6010 f_sleep(1.0);
6011 f_ctrs_bsc_and_bts_init();
6012 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_2));
6013 vc_conn.done;
6014
6015 /* f_tc_ho_neighbor_config_start() */
6016 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
6017 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
6018
6019 /* 2.a */
6020 /* "failed" means a handover was triggered and started (which is all this test aims for) and the test ended the
6021 * handover quickly by sending a Handover Failure message. */
6022 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
6023 f_ctrs_bsc_and_bts_add(0, "handover:failed");
6024 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
6025 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:failed");
6026
6027 /* 2.b */
6028 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
6029 f_ctrs_bsc_and_bts_add(0, "handover:error");
6030
6031 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006032 f_shutdown_helper();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006033}
6034
Neels Hofmeyr91401012019-07-11 00:42:35 +02006035private function f_tc_ho_neighbor_config_3(charstring id) runs on MSC_ConnHdlr {
6036 f_tc_ho_neighbor_config_start();
6037
6038 /*
6039 * bts 0 ARFCN 871 BSIC 10
6040 * bts 1 ARFCN 871 BSIC 11
6041 * bts 2 ARFCN 871 BSIC 12
6042 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
6043 */
6044
6045 log("f_tc_ho_neighbor_config: 3. explicit local neighbor: 'neighbor bts 2'");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02006046 f_bts_0_cfg(BSCVTY, {"no neighbors", "neighbor bts 2"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02006047 f_sleep(0.5);
6048
6049 f_probe_for_handover("3.a", "HO to bts 1 doesn't work, not listed as neighbor",
6050 "handover any to arfcn 871 bsic 11",
6051 false);
6052 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",
6053 "handover any to arfcn 871 bsic 12",
6054 true);
6055}
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006056testcase TC_ho_neighbor_config_3() runs on test_CT {
6057 var MSC_ConnHdlr vc_conn;
6058 f_init(3, true, guard_timeout := 50.0);
6059 f_sleep(1.0);
6060 f_ctrs_bsc_and_bts_init();
6061 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_3));
6062 vc_conn.done;
6063
6064 /* f_tc_ho_neighbor_config_start() */
6065 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
6066 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
6067
6068 /* 3.a */
6069 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
6070 f_ctrs_bsc_and_bts_add(0, "handover:error");
6071
6072 /* 3.b */
6073 /* "failed" means a handover was triggered and started (which is all this test aims for) and the test ended the
6074 * handover quickly by sending a Handover Failure message. */
6075 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
6076 f_ctrs_bsc_and_bts_add(0, "handover:failed");
6077 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
6078 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:failed");
6079
6080 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006081 f_shutdown_helper();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006082}
6083
Neels Hofmeyr91401012019-07-11 00:42:35 +02006084private function f_tc_ho_neighbor_config_4(charstring id) runs on MSC_ConnHdlr {
6085 f_tc_ho_neighbor_config_start();
6086
6087 /*
6088 * bts 0 ARFCN 871 BSIC 10
6089 * bts 1 ARFCN 871 BSIC 11
6090 * bts 2 ARFCN 871 BSIC 12
6091 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
6092 */
6093
6094 log("f_tc_ho_neighbor_config: 4. explicit remote neighbor: 'neighbor lac 99 arfcn 123 bsic 45'");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02006095 f_bts_0_cfg(BSCVTY, {"no neighbors", "neighbor lac 99 arfcn 123 bsic 45"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02006096 f_sleep(0.5);
6097
6098 f_probe_for_handover("4.a", "HO to bts 1 doesn't work, not listed as neighbor",
6099 "handover any to arfcn 871 bsic 11",
6100 false);
6101 f_probe_for_handover("4.b", "HO to bts 2 doesn't work, not listed as neighbor",
6102 "handover any to arfcn 871 bsic 12",
6103 false);
6104 f_probe_for_handover("4.c", "HO to 123-45 triggers inter-BSC HO",
6105 "handover any to arfcn 123 bsic 45",
6106 true, true);
6107}
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006108testcase TC_ho_neighbor_config_4() runs on test_CT {
6109 var MSC_ConnHdlr vc_conn;
6110 f_init(3, true, guard_timeout := 50.0);
6111 f_sleep(1.0);
6112 f_ctrs_bsc_and_bts_init();
6113 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_4));
6114 vc_conn.done;
6115
6116 /* f_tc_ho_neighbor_config_start() */
6117 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
6118 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
6119
6120 /* 4.a */
6121 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
6122 f_ctrs_bsc_and_bts_add(0, "handover:error");
6123
6124 /* 4.b */
6125 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
6126 f_ctrs_bsc_and_bts_add(0, "handover:error");
6127
6128 /* 4.c */
6129 /* "timeout" means a handover was triggered and started (which is all this test aims for) and the test ended the
6130 * handover quickly by timing out after the Handover Required message */
6131 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
6132 f_ctrs_bsc_and_bts_add(0, "handover:timeout");
6133 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
6134 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:timeout");
6135
6136 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006137 f_shutdown_helper();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006138}
6139
Neels Hofmeyr91401012019-07-11 00:42:35 +02006140private function f_tc_ho_neighbor_config_5(charstring id) runs on MSC_ConnHdlr {
6141 f_tc_ho_neighbor_config_start();
6142
6143 /*
6144 * bts 0 ARFCN 871 BSIC 10
6145 * bts 1 ARFCN 871 BSIC 11
6146 * bts 2 ARFCN 871 BSIC 12
6147 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
6148 */
6149
6150 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 +02006151 f_bts_0_cfg(BSCVTY, {"no neighbors", "neighbor lac 99 arfcn 871 bsic 12"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02006152 f_sleep(0.5);
6153
6154 f_probe_for_handover("5.a", "HO to 871-12 triggers inter-BSC HO (ignoring local cells with same ARFCN+BSIC)",
6155 "handover any to arfcn 871 bsic 12",
6156 true, true);
6157}
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006158testcase TC_ho_neighbor_config_5() runs on test_CT {
6159 var MSC_ConnHdlr vc_conn;
6160 f_init(3, true);
6161 f_sleep(1.0);
6162 f_ctrs_bsc_and_bts_init();
6163 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_5));
6164 vc_conn.done;
6165
6166 /* f_tc_ho_neighbor_config_start() */
6167 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
6168 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
6169
6170 /* 5 */
6171 /* "timeout" means a handover was triggered and started (which is all this test aims for) and the test ended the
6172 * handover quickly by timing out after the Handover Required message */
6173 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
6174 f_ctrs_bsc_and_bts_add(0, "handover:timeout");
6175 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
6176 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:timeout");
6177
6178 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006179 f_shutdown_helper();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006180}
6181
Neels Hofmeyr91401012019-07-11 00:42:35 +02006182private function f_tc_ho_neighbor_config_6(charstring id) runs on MSC_ConnHdlr {
6183 f_tc_ho_neighbor_config_start();
6184
6185 /*
6186 * bts 0 ARFCN 871 BSIC 10
6187 * bts 1 ARFCN 871 BSIC 11
6188 * bts 2 ARFCN 871 BSIC 12
6189 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
6190 */
6191
6192 log("f_tc_ho_neighbor_config: 6. config error: explicit local and remote neighbors with ambiguous ARFCN+BSIC:"
6193 & " 'neighbor bts 2; neighbor lac 99 arfcn 871 bsic 12'");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02006194 f_bts_0_cfg(BSCVTY, {"no neighbors", "neighbor bts 2", "neighbor lac 99 arfcn 871 bsic 12"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02006195 f_sleep(0.5);
6196
6197 f_probe_for_handover("6.a", "HO to 871-12 is ambiguous = error",
6198 "handover any to arfcn 871 bsic 12",
6199 false);
6200}
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006201testcase TC_ho_neighbor_config_6() runs on test_CT {
6202 var MSC_ConnHdlr vc_conn;
6203 f_init(3, true);
6204 f_sleep(1.0);
6205 f_ctrs_bsc_and_bts_init();
6206 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_6));
6207 vc_conn.done;
6208
6209 /* f_tc_ho_neighbor_config_start() */
6210 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
6211 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
6212
6213 /* 6.a */
6214 /* "timeout" means a handover was triggered and started (which is all this test aims for) and the test ended the
6215 * handover quickly by timing out after the Handover Required message */
6216 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
6217 f_ctrs_bsc_and_bts_add(0, "handover:error");
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_7(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: 7. explicit local and remote neighbors:"
6234 & " 'neighbor bts 2; neighbor lac 99 arfcn 123 bsic 45'");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02006235 f_bts_0_cfg(BSCVTY, {"no neighbors", "neighbor bts 2", "neighbor lac 99 arfcn 123 bsic 45"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02006236 f_sleep(0.5);
6237
6238 f_probe_for_handover("7.a", "HO to 871-12 does HO to bts 2",
6239 "handover any to arfcn 871 bsic 12",
6240 true);
6241 f_probe_for_handover("7.b", "HO to 123-45 triggers inter-BSC HO",
6242 "handover any to arfcn 123 bsic 45",
6243 true, true);
6244}
Neels Hofmeyr91401012019-07-11 00:42:35 +02006245testcase TC_ho_neighbor_config_7() runs on test_CT {
6246 var MSC_ConnHdlr vc_conn;
Neels Hofmeyrf2b88032020-06-16 00:35:04 +02006247 f_init(3, true, guard_timeout := 50.0);
Neels Hofmeyr91401012019-07-11 00:42:35 +02006248 f_sleep(1.0);
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006249 f_ctrs_bsc_and_bts_init();
Neels Hofmeyr91401012019-07-11 00:42:35 +02006250 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_7));
6251 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006252
6253 /* f_tc_ho_neighbor_config_start() */
6254 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
6255 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
6256
6257 /* 7.a */
6258 /* "failed" means a handover was triggered and started (which is all this test aims for) and the test ended the
6259 * handover quickly by sending a Handover Failure message. */
6260 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
6261 f_ctrs_bsc_and_bts_add(0, "handover:failed");
6262 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
6263 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:failed");
6264
6265 /* 7.b */
6266 /* "timeout" means a handover was triggered and started (which is all this test aims for) and the test ended the
6267 * handover quickly by timing out after the Handover Required message */
6268 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
6269 f_ctrs_bsc_and_bts_add(0, "handover:timeout");
6270 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
6271 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:timeout");
6272
6273 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006274 f_shutdown_helper();
Neels Hofmeyr91401012019-07-11 00:42:35 +02006275}
6276
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01006277/* OS#3041: Open and close N connections in a normal fashion, and expect no
6278 * BSSMAP Reset just because of that. */
6279testcase TC_bssap_rlsd_does_not_cause_bssmap_reset() runs on test_CT {
6280 var default d;
6281 var integer i;
6282 var DchanTuple dt;
6283
6284 f_init();
6285
6286 /* Wait for initial BSSMAP Reset to pass */
6287 f_sleep(4.0);
6288
6289 d := activate(no_bssmap_reset());
6290
6291 /* Setup up a number of connections and RLSD them again from the MSC
6292 * side. In the buggy behavior, the fourth one triggers BSSMAP Reset.
6293 * Let's do it some more times for good measure. */
Harald Weltec3260d92018-06-11 17:48:16 +02006294 for (i := 0; i < 4; i := i+1) {
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01006295 /* Since we're doing a lot of runs, give each one a fresh
6296 * T_guard from the top. */
6297 T_guard.start;
6298
6299 /* Setup a BSSAP connection and clear it right away. This is
6300 * the MSC telling the BSC about a planned release, it's not an
6301 * erratic loss of a connection. */
Harald Weltea1897182018-06-11 13:53:09 +02006302 dt := f_est_dchan(int2oct(i,1), 23+i, '00010203040506'O);
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01006303
6304 /* MSC disconnects (RLSD). */
6305 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
6306 }
6307
6308 /* In the buggy behavior, a timeout of 2 seconds happens between above
6309 * trigger (logs "SIGTRAN connection down, reconnecting...") and the
6310 * actual BSSMAP Reset. Wait a bit longer just to make sure. */
6311 f_sleep(4.0);
6312
6313 deactivate(d);
6314 f_shutdown_helper();
6315}
Harald Welte552620d2017-12-16 23:21:36 +01006316
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01006317/* OS#3041: Open and close N connections in a normal fashion, and expect no
6318 * BSSMAP Reset just because of that. Invoke the release by a BSSMAP Clear from
6319 * the MSC. */
6320testcase TC_bssmap_clear_does_not_cause_bssmap_reset() runs on test_CT {
6321 var default d;
6322 var integer i;
6323 var DchanTuple dt;
6324 var BSSAP_N_DATA_ind rx_di;
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01006325 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_CALL_CONTROL;
6326 var BssmapCause cause := enum2int(cause_val);
6327
6328 f_init();
6329
6330 /* Wait for initial BSSMAP Reset to pass */
6331 f_sleep(4.0);
6332
6333 d := activate(no_bssmap_reset());
6334
6335 /* Setup up a number of connections and RLSD them again from the MSC
6336 * side. In the buggy behavior, the fourth one triggers BSSMAP Reset.
6337 * Let's do it some more times for good measure. */
6338 for (i := 0; i < 8; i := i+1) {
6339 /* Since we're doing a lot of runs, give each one a fresh
6340 * T_guard from the top. */
6341 T_guard.start;
6342
6343 /* Setup a BSSAP connection and clear it right away. This is
6344 * the MSC telling the BSC about a planned release, it's not an
6345 * erratic loss of a connection. */
Harald Weltea1897182018-06-11 13:53:09 +02006346 dt := f_est_dchan(int2oct(i,1), 23+i, '00010203040506'O);
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01006347
6348 /* Instruct BSC to clear channel */
6349 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
6350
6351 /* expect BSC to disable the channel */
Harald Welte641fcbe2018-06-14 10:58:35 +02006352 f_exp_chan_rel_and_clear(dt, 0);
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01006353 }
6354
6355 /* In the buggy behavior, a timeout of 2 seconds happens between above
6356 * trigger (logs "SIGTRAN connection down, reconnecting...") and the
6357 * actual BSSMAP Reset. Wait a bit longer just to make sure. */
6358 f_sleep(4.0);
6359
6360 deactivate(d);
6361 f_shutdown_helper();
6362}
6363
Neels Hofmeyrfd445c32018-03-09 15:39:31 +01006364/* OS#3041: Open and close N connections in a normal fashion, and expect no
6365 * BSSMAP Reset just because of that. Close connections from the MS side with a
6366 * Release Ind on RSL. */
6367testcase TC_ms_rel_ind_does_not_cause_bssmap_reset() runs on test_CT {
6368 var default d;
6369 var integer i;
6370 var DchanTuple dt;
6371 var BSSAP_N_DATA_ind rx_di;
Neels Hofmeyrfd445c32018-03-09 15:39:31 +01006372 var integer j;
6373
6374 f_init();
6375
6376 /* Wait for initial BSSMAP Reset to pass */
6377 f_sleep(4.0);
6378
6379 d := activate(no_bssmap_reset());
6380
6381 /* Setup up a number of connections and RLSD them again from the MSC
6382 * side. In the buggy behavior, the fourth one triggers BSSMAP Reset.
6383 * Let's do it some more times for good measure. */
6384 for (i := 0; i < 8; i := i+1) {
6385 /* Since we're doing a lot of runs, give each one a fresh
6386 * T_guard from the top. */
6387 T_guard.start;
6388
6389 /* Setup a BSSAP connection and clear it right away. This is
6390 * the MSC telling the BSC about a planned release, it's not an
6391 * erratic loss of a connection. */
6392 dt := f_est_dchan('23'O, 23, '00010203040506'O);
6393
6394 /* simulate RLL REL IND */
6395 f_ipa_tx(0, ts_RSL_REL_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0))));
6396
6397 /* expect Clear Request on MSC side */
6398 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearRequest)) -> value rx_di;
6399
6400 /* Instruct BSC to clear channel */
6401 var BssmapCause cause := bit2int(rx_di.userData.pdu.bssmap.clearRequest.cause.causeValue);
6402 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
6403
6404 /* expect BSC to disable the channel */
Harald Welte641fcbe2018-06-14 10:58:35 +02006405 f_exp_chan_rel_and_clear(dt, 0);
Neels Hofmeyrfd445c32018-03-09 15:39:31 +01006406 }
6407
6408 /* In the buggy behavior, a timeout of 2 seconds happens between above
6409 * trigger (logs "SIGTRAN connection down, reconnecting...") and the
6410 * actual BSSMAP Reset. Wait a bit longer just to make sure. */
6411 f_sleep(4.0);
6412
6413 deactivate(d);
6414 f_shutdown_helper();
6415}
6416
Harald Welte94e0c342018-04-07 11:33:23 +02006417/***********************************************************************
6418 * IPA style dynamic PDCH
6419 ***********************************************************************/
6420
6421private function f_dyn_ipa_pdch_act(integer bts_nr, integer trx_nr, integer ts_nr,
6422 template (omit) RSL_Cause nack := omit)
6423runs on test_CT {
6424 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(ts_nr));
6425 var RSL_Message rsl_unused;
6426 /* ask BSC via VTY to activate a given IPA style chan as PDCH */
6427 f_vty_ts_action("pdch activate", bts_nr, trx_nr, ts_nr);
6428 /* expect the BSC to issue the related RSL command */
6429 rsl_unused := f_exp_ipa_rx(0, tr_RSL_IPA_PDCH_ACT(chan_nr));
6430 if (istemplatekind(nack, "omit")) {
6431 /* respond with a related acknowledgement */
6432 f_ipa_tx(0, ts_RSL_IPA_PDCH_ACT_ACK(chan_nr, ts_RSL_IE_FrameNumber(2342)));
6433 } else {
6434 f_ipa_tx(0, ts_RSL_IPA_PDCH_ACT_NACK(chan_nr, valueof(nack)));
6435 }
6436}
6437
6438private function f_dyn_ipa_pdch_deact(integer bts_nr, integer trx_nr, integer ts_nr,
6439 template (omit) RSL_Cause nack := omit)
6440runs on test_CT {
6441 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(ts_nr));
6442 var RSL_Message rsl_unused;
6443 /* ask BSC via VTY to activate a given IPA style chan as PDCH */
6444 f_vty_ts_action("pdch deactivate", bts_nr, trx_nr, ts_nr);
6445 /* expect the BSC to issue the related RSL command */
6446 rsl_unused := f_exp_ipa_rx(0, tr_RSL_IPA_PDCH_DEACT(chan_nr));
6447 if (istemplatekind(nack, "omit")) {
6448 /* respond with a related acknowledgement */
6449 f_ipa_tx(0, ts_RSL_IPA_PDCH_DEACT_ACK(chan_nr));
6450 } else {
6451 f_ipa_tx(0, ts_RSL_IPA_PDCH_DEACT_NACK(chan_nr, valueof(nack)));
6452 }
6453}
6454
6455private function f_ts_dyn_mode_get(integer bts_nr, integer trx_nr, integer ts_nr)
6456runs on test_CT return charstring {
6457 var charstring cmd, resp;
6458 cmd := "show timeslot "&int2str(bts_nr)&" "&int2str(trx_nr)&" "&int2str(ts_nr);
Stefan Sperlingcff13562018-11-13 15:24:06 +01006459 return f_vty_transceive_match_regexp_retry(BSCVTY, cmd, "*\((*)\)*", 0, 4, 1.0);
Harald Welte94e0c342018-04-07 11:33:23 +02006460}
6461
6462private function f_ts_dyn_mode_assert(integer bts_nr, integer trx_nr, integer ts_nr,
6463 template charstring exp)
6464runs on test_CT {
6465 var charstring mode := f_ts_dyn_mode_get(bts_nr, trx_nr, ts_nr);
6466 if (not match(mode, exp)) {
6467 setverdict(fail, "Unexpected TS Mode: ", mode);
Daniel Willmannafce8662018-07-06 23:11:32 +02006468 mtc.stop;
Harald Welte94e0c342018-04-07 11:33:23 +02006469 }
6470}
6471
6472private function f_ts_set_chcomb(integer bts_nr, integer trx_nr, integer ts_nr, charstring chcomb)
6473runs on test_CT {
6474 f_vty_enter_cfg_ts(BSCVTY, bts_nr, trx_nr, ts_nr);
6475 f_vty_transceive(BSCVTY, "phys_chan_config " & chcomb);
6476 f_vty_transceive(BSCVTY, "end");
6477}
6478
6479private const charstring TCHF_MODE := "TCH/F mode";
6480private const charstring TCHH_MODE := "TCH/H mode";
6481private const charstring PDCH_MODE := "PDCH mode";
6482private const charstring NONE_MODE := "NONE mode";
6483
6484/* Test IPA PDCH activation / deactivation triggered by VTY */
6485testcase TC_dyn_pdch_ipa_act_deact() runs on test_CT {
6486 var RSL_Message rsl_unused;
6487
6488 /* change Timeslot 6 before f_init() starts RSL */
6489 f_init_vty();
6490 f_ts_set_chcomb(0, 0, 6, "TCH/F_PDCH");
6491 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
6492
6493 f_init(1, false);
6494 f_sleep(1.0);
6495
6496 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(6));
6497
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02006498 log("TCH/F_PDCH pchan starts out in TCH/F mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02006499 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
6500 /* The BSC will activate the dynamic PDCH by default, so confirm that */
6501 rsl_unused := f_exp_ipa_rx(0, tr_RSL_IPA_PDCH_ACT(chan_nr));
6502 f_ipa_tx(0, ts_RSL_IPA_PDCH_ACT_ACK(chan_nr, ts_RSL_IE_FrameNumber(2342)));
6503 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02006504 log("TCH/F_PDCH pchan, PDCH ACT was ACKed, so now in PDCH mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02006505 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, PDCH_MODE);
6506
6507 /* De-activate it via VTY */
6508 f_dyn_ipa_pdch_deact(0, 0, chan_nr.tn);
6509 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02006510 log("TCH/F_PDCH pchan, PDCH DEACT via VTY, so now back in TCH/F mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02006511 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
6512
6513 /* re-activate it via VTY */
6514 f_dyn_ipa_pdch_act(0, 0, chan_nr.tn);
6515 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02006516 log("TCH/F_PDCH pchan, PDCH ACT via VTY, so now in PDCH mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02006517 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, PDCH_MODE);
6518
6519 /* and finally de-activate it again */
6520 f_dyn_ipa_pdch_deact(0, 0, chan_nr.tn);
6521 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02006522 log("TCH/F_PDCH pchan, PDCH DEACT via VTY, so now back in TCH/F mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02006523 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
6524
Neels Hofmeyr887e8f12018-06-27 01:01:55 +02006525 /* clean up config */
6526 f_ts_set_chcomb(0, 0, 6, "PDCH");
6527
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006528 f_shutdown_helper();
Harald Welte94e0c342018-04-07 11:33:23 +02006529}
6530
6531/* Test IPA PDCH activation NACK */
6532testcase TC_dyn_pdch_ipa_act_nack() runs on test_CT {
6533 var RSL_Message rsl_unused;
6534
6535 /* change Timeslot 6 before f_init() starts RSL */
6536 f_init_vty();
6537 f_ts_set_chcomb(0, 0, 6, "TCH/F_PDCH");
6538 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
6539
6540 f_init(1, false);
6541 f_sleep(1.0);
6542
6543 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(6));
6544
6545 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
6546 /* The BSC will activate the dynamic PDCH by default, so confirm that */
6547 rsl_unused := f_exp_ipa_rx(0, tr_RSL_IPA_PDCH_ACT(chan_nr));
6548 f_ipa_tx(0, ts_RSL_IPA_PDCH_ACT_ACK(chan_nr, ts_RSL_IE_FrameNumber(2342)));
6549 f_sleep(1.0);
6550 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, PDCH_MODE);
6551
6552 /* De-activate it via VTY */
6553 f_dyn_ipa_pdch_deact(0, 0, chan_nr.tn);
6554 f_sleep(1.0);
6555 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
6556
6557 /* re-activate it via VTY, but fail that; check BSC still assumes TCH/F mode */
6558 f_dyn_ipa_pdch_act(0, 0, chan_nr.tn, RSL_ERR_EQUIPMENT_FAIL);
6559 f_sleep(1.0);
6560 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
6561
Neels Hofmeyr887e8f12018-06-27 01:01:55 +02006562 /* clean up config */
6563 f_ts_set_chcomb(0, 0, 6, "PDCH");
6564
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006565 f_shutdown_helper();
Harald Welte94e0c342018-04-07 11:33:23 +02006566}
6567
6568
6569/***********************************************************************
6570 * Osmocom style dynamic PDCH
6571 ***********************************************************************/
6572
6573private function f_dyn_osmo_pdch_act(integer bts_nr, integer trx_nr, integer ts_nr,
6574 template (omit) RSL_Cause nack := omit)
6575runs on test_CT {
6576 var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(ts_nr));
6577 var RSL_Message rsl_unused;
6578 /* ask BSC via VTY to activate a given IPA style chan as PDCH */
6579 /* FIXME: no VTY command to activate Osmocom PDCH !! */
6580 /* expect the BSC to issue the related RSL command */
6581 rsl_unused := f_exp_ipa_rx(0, tr_RSL_CHAN_ACT(chan_nr, ?));
6582 if (istemplatekind(nack, "omit")) {
6583 /* respond with a related acknowledgement */
6584 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, 2342));
6585 } else {
6586 f_ipa_tx(0, ts_RSL_CHAN_ACT_NACK(chan_nr, valueof(nack)));
6587 }
6588}
6589
6590private function f_dyn_osmo_pdch_deact(integer bts_nr, integer trx_nr, integer ts_nr,
6591 template (omit) RSL_Cause nack := omit)
6592runs on test_CT {
6593 var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(ts_nr));
6594 var RSL_Message rsl_unused;
6595 /* ask BSC via VTY to activate a given IPA style chan as PDCH */
6596 /* FIXME: no VTY command to activate Osmocom PDCH !! */
6597 /* expect the BSC to issue the related RSL command */
6598 rsl_unused := f_exp_ipa_rx(0, tr_RSL_RF_CHAN_REL(chan_nr));
6599 if (istemplatekind(nack, "omit")) {
6600 /* respond with a related acknowledgement */
6601 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(chan_nr));
6602 } else {
6603 //f_ipa_tx(0, ts_RSL_RF_CHAN_REL_NACK(chan_nr, valueof(nack)));
6604 }
6605}
6606
6607/* Test Osmocom dyn PDCH activation / deactivation triggered by VTY */
6608testcase TC_dyn_pdch_osmo_act_deact() runs on test_CT {
6609 var RSL_Message rsl_unused;
6610
6611 /* change Timeslot 6 before f_init() starts RSL */
6612 f_init_vty();
6613 f_ts_set_chcomb(0, 0, 6, "TCH/F_TCH/H_PDCH");
6614 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
6615
6616 f_init(1, false);
6617 f_sleep(1.0);
6618
6619 var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(6));
6620
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02006621 log("TCH/F_TCH/H_PDCH pchan starts out in disabled mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02006622 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, NONE_MODE);
6623 /* The BSC will activate the dynamic PDCH by default, so confirm that */
6624 rsl_unused := f_exp_ipa_rx(0, tr_RSL_CHAN_ACT_PDCH(chan_nr, ?));
6625
6626 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, 2342));
6627 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02006628 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 +02006629 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, PDCH_MODE);
6630
Neels Hofmeyr887e8f12018-06-27 01:01:55 +02006631 /* clean up config */
6632 f_ts_set_chcomb(0, 0, 6, "PDCH");
6633
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006634 f_shutdown_helper();
Harald Welte94e0c342018-04-07 11:33:23 +02006635}
6636
6637/* Test Osmocom dyn PDCH activation NACK behavior */
6638testcase TC_dyn_pdch_osmo_act_nack() runs on test_CT {
6639 var RSL_Message rsl_unused;
6640
6641 /* change Timeslot 6 before f_init() starts RSL */
6642 f_init_vty();
6643 f_ts_set_chcomb(0, 0, 6, "TCH/F_TCH/H_PDCH");
6644 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
6645
6646 f_init(1, false);
6647 f_sleep(1.0);
6648
6649 var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(6));
6650
6651 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, NONE_MODE);
6652 /* The BSC will activate the dynamic PDCH by default, so confirm that */
6653 rsl_unused := f_exp_ipa_rx(0, tr_RSL_CHAN_ACT_PDCH(chan_nr, ?));
6654
6655 /* NACK this activation and expect the "show timeslot" mode still to be NONE */
6656 f_ipa_tx(0, ts_RSL_CHAN_ACT_NACK(chan_nr, RSL_ERR_EQUIPMENT_FAIL));
6657 f_sleep(1.0);
6658 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, NONE_MODE);
6659
Neels Hofmeyr887e8f12018-06-27 01:01:55 +02006660 /* clean up config */
6661 f_ts_set_chcomb(0, 0, 6, "PDCH");
6662
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006663 f_shutdown_helper();
Harald Welte94e0c342018-04-07 11:33:23 +02006664}
6665
Stefan Sperling0796a822018-10-05 13:01:39 +02006666testcase TC_chopped_ipa_ping() runs on test_CT {
Stefan Sperling554123f2018-10-09 14:12:30 +02006667 const Integers bsc_ipa_ports := {mp_bsc_rsl_port, mp_bsc_oml_port, mp_bsc_ctrl_port};
Stefan Sperling0796a822018-10-05 13:01:39 +02006668 for (var integer i := 0; i < lengthof(bsc_ipa_ports); i := i + 1) {
6669 IPA_Testing.f_run_TC_chopped_ipa_ping(mp_bsc_ip, bsc_ipa_ports[i], CONNECT_TO_SERVER);
6670 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006671 f_shutdown_helper();
Stefan Sperling0796a822018-10-05 13:01:39 +02006672}
6673
Stefan Sperlingaa1e60f2018-10-15 16:34:07 +02006674testcase TC_chopped_ipa_payload() runs on test_CT {
6675 const Integers bsc_ipa_ports := {mp_bsc_rsl_port, mp_bsc_oml_port
6676 /* TODO: mp_bsc_ctrl_port does not work yet */};
6677 for (var integer i := 0; i < lengthof(bsc_ipa_ports); i := i + 1) {
6678 IPA_Testing.f_run_TC_chopped_ipa_payload(mp_bsc_ip, bsc_ipa_ports[i], CONNECT_TO_SERVER);
6679 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006680 f_shutdown_helper();
Stefan Sperlingaa1e60f2018-10-15 16:34:07 +02006681}
6682
Pau Espin Pedrol8f773632019-11-05 11:46:53 +01006683/* Verify the BSC sends the MS Power Parameters IE during CHAN ACT to make sure
6684 the BTS does autonomous MS power control loop */
6685testcase TC_assignment_verify_ms_power_params_ie() runs on test_CT {
6686 var MSC_ConnHdlr vc_conn;
6687 var TestHdlrParams pars := f_gen_test_hdlr_pars();
6688 //pars.encr := valueof(t_EncrParams('01'O, f_rnd_octstring(8)));
6689 pars.exp_ms_power_params := true;
6690
6691 f_init(1, true);
6692 f_sleep(1.0);
6693 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5), pars);
6694 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006695 f_shutdown_helper();
Pau Espin Pedrol8f773632019-11-05 11:46:53 +01006696}
Stefan Sperlingaa1e60f2018-10-15 16:34:07 +02006697
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006698/***********************************************************************
6699 * MSC Pooling
6700 ***********************************************************************/
6701
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006702template MobileIdentityLV ts_MI_TMSI_NRI_LV(integer nri_v, integer nri_bitlen := 10) :=
Harald Weltebf397612021-01-14 20:39:46 +01006703 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 +02006704
Pau Espin Pedrolc08d5522021-04-16 15:40:38 +02006705private function f_expect_lchan_rel(RSL_DCHAN_PT rsl, template PDU_ML3_NW_MS exp_rr_rel_tmpl := tr_RRM_RR_RELEASE)
6706runs on MSC_ConnHdlr {
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02006707 interleave {
Pau Espin Pedrolc08d5522021-04-16 15:40:38 +02006708 [] rsl.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch exp_rr_rel_tmpl)) {
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02006709 f_logp(BSCVTY, "Got RSL RR Release");
6710 }
6711 [] rsl.receive(tr_RSL_DEACT_SACCH(g_chan_nr)) {
6712 f_logp(BSCVTY, "Got RSL Deact SACCH");
6713 }
6714 [] rsl.receive(tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL)) {
6715 f_logp(BSCVTY, "Got RSL RF Chan Rel, sending Rel Ack");
6716 rsl.send(ts_RSL_RF_CHAN_REL_ACK(g_chan_nr));
6717 break;
6718 }
6719 }
6720}
6721
Neels Hofmeyr9f3e6ac2021-04-08 23:09:24 +02006722friend 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 +02006723runs on MSC_ConnHdlr {
Neels Hofmeyr767548a2020-08-09 20:26:07 +00006724 f_logp(BSCVTY, "MSC instructs BSC to clear channel");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006725 BSSAP.send(ts_BSSMAP_ClearCommand(0));
6726 interleave {
Pau Espin Pedrolc08d5522021-04-16 15:40:38 +02006727 [] rsl.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch exp_rr_rel_tmpl)) {
Neels Hofmeyr767548a2020-08-09 20:26:07 +00006728 f_logp(BSCVTY, "Got RSL RR Release");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006729 }
6730 [] rsl.receive(tr_RSL_DEACT_SACCH(g_chan_nr)) {
Neels Hofmeyr767548a2020-08-09 20:26:07 +00006731 f_logp(BSCVTY, "Got RSL Deact SACCH");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006732 }
6733 [] BSSAP.receive(tr_BSSMAP_ClearComplete) {
Neels Hofmeyr767548a2020-08-09 20:26:07 +00006734 f_logp(BSCVTY, "Got BSSMAP Clear Complete");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006735 /* Also drop the SCCP connection */
6736 BSSAP.send(RAN_Conn_Prim:MSC_CONN_PRIM_DISC_REQ);
6737 }
6738 [] rsl.receive(tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL)) {
Neels Hofmeyr767548a2020-08-09 20:26:07 +00006739 f_logp(BSCVTY, "Got RSL RF Chan Rel, sending Rel Ack");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006740 rsl.send(ts_RSL_RF_CHAN_REL_ACK(g_chan_nr));
6741 }
6742 }
6743}
6744
Neels Hofmeyr66e15092020-10-12 18:44:41 +00006745private 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 +02006746runs on MSC_ConnHdlr {
6747 timer T := 10.0;
6748 var octetstring l3_enc := enc_PDU_ML3_MS_NW(valueof(l3_info));
6749
Neels Hofmeyr767548a2020-08-09 20:26:07 +00006750 f_logp(BSCVTY, "establish channel, send Complete Layer 3 Info");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006751 f_create_bssmap_exp(l3_enc);
6752
6753 /* RSL_Emulation.f_chan_est() on rsl:
6754 * This is basically code dup with s/RSL/rsl from:
6755 * RSL_Emulation.f_chan_est(g_pars.ra, l3_enc, g_pars.link_id, g_pars.fn);
6756 */
6757 var RSL_Message rx_rsl;
6758 var GsmRrMessage rr;
6759
6760 /* request a channel to be established */
6761 rsl.send(ts_RSLDC_ChanRqd(g_pars.ra, g_pars.fn));
6762 /* expect immediate assignment.
6763 * Code dup with s/RSL/rsl from:
6764 * rx_rsl := f_rx_or_fail(tr_RSL_IMM_ASSIGN);
6765 */
6766 timer Tt := 10.0;
6767
6768 /* request a channel to be established */
6769 Tt.start;
6770 alt {
6771 [] rsl.receive(tr_RSL_IMM_ASSIGN) -> value rx_rsl {
6772 Tt.stop;
6773 }
6774 [] rsl.receive {
6775 setverdict(fail, "Unexpected RSL message on DCHAN");
6776 mtc.stop;
6777 }
6778 [] Tt.timeout {
6779 setverdict(fail, "Timeout waiting for RSL on DCHAN");
6780 mtc.stop;
6781 }
6782 }
6783 rr := dec_GsmRrMessage(rx_rsl.ies[1].body.full_imm_ass_info.payload);
6784 g_chan_nr := rr.payload.imm_ass.chan_desc.chan_nr;
6785 rsl.send(ts_RSL_EST_IND(g_chan_nr, valueof(g_pars.link_id), l3_enc));
6786
6787
Neels Hofmeyr66e15092020-10-12 18:44:41 +00006788 if (expect_bssmap_l3) {
6789 f_logp(BSCVTY, "expect BSSAP Complete Layer 3 Info at MSC");
6790 var template PDU_BSSAP exp_l3_compl;
6791 exp_l3_compl := tr_BSSMAP_ComplL3()
6792 if (g_pars.aoip == false) {
6793 exp_l3_compl.pdu.bssmap.completeLayer3Information.codecList := omit;
6794 } else {
6795 exp_l3_compl.pdu.bssmap.completeLayer3Information.codecList := ?;
6796 }
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006797
Neels Hofmeyr66e15092020-10-12 18:44:41 +00006798 var PDU_BSSAP bssap;
6799 T.start;
6800 alt {
6801 [] BSSAP.receive(exp_l3_compl) -> value bssap {
6802 f_logp(BSCVTY, "received expected Complete Layer 3 Info at MSC");
6803 log("rx exp_l3_compl = ", bssap);
6804 }
6805 [] BSSAP.receive(tr_BSSMAP_ComplL3) {
6806 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Received non-matching COMPLETE LAYER 3 INFORMATION");
6807 }
6808 [] T.timeout {
6809 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for COMPLETE LAYER 3 INFORMATION");
6810 }
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006811 }
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006812
Neels Hofmeyr66e15092020-10-12 18:44:41 +00006813 /* start ciphering, if requested */
6814 if (ispresent(g_pars.encr)) {
6815 f_logp(BSCVTY, "start ciphering");
Neels Hofmeyr6c388f22021-06-11 02:36:56 +02006816 f_cipher_mode(g_pars.encr);
Neels Hofmeyr66e15092020-10-12 18:44:41 +00006817 }
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006818 }
6819
6820 if (do_clear) {
6821 f_perform_clear(rsl);
6822 }
6823 setverdict(pass);
6824 f_sleep(1.0);
6825}
6826
6827private function f_tc_mscpool_compl_l3(charstring id) runs on MSC_ConnHdlr {
6828 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
6829 if (g_pars.mscpool.rsl_idx == 0) {
6830 f_perform_compl_l3(RSL, g_pars.mscpool.l3_info);
6831 } else if (g_pars.mscpool.rsl_idx == 1) {
6832 f_perform_compl_l3(RSL1, g_pars.mscpool.l3_info);
6833 } else if (g_pars.mscpool.rsl_idx == 2) {
6834 f_perform_compl_l3(RSL2, g_pars.mscpool.l3_info);
6835 }
6836}
6837
6838/* Various Complete Layer 3 by IMSI all end up with the first MSC, because the other MSCs are not connected. */
6839private function f_tc_mscpool_L3Compl_on_1_msc(charstring id) runs on MSC_ConnHdlr {
6840 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
6841 f_perform_compl_l3(RSL, ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_IMSI_LV('001010000000001'H)), '00F110'O) );
6842 f_perform_compl_l3(RSL, ts_CM_SERV_REQ(CM_TYPE_MO_SMS, valueof(ts_MI_IMSI_LV('001010000000002'H))) );
6843 f_perform_compl_l3(RSL, ts_PAG_RESP(valueof(ts_MI_IMSI_LV('001010000000003'H))) );
6844 f_perform_compl_l3(RSL, ts_ML3_MO_MM_IMSI_DET_Ind(valueof(ts_MI_IMSI_LV('001010000000004'H))) );
6845}
6846testcase TC_mscpool_L3Compl_on_1_msc() runs on test_CT {
6847
6848 f_init(1, true);
6849 f_sleep(1.0);
6850 var MSC_ConnHdlr vc_conn;
6851 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006852
6853 f_ctrs_msc_init();
6854
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006855 vc_conn := f_start_handler(refers(f_tc_mscpool_L3Compl_on_1_msc), pars);
6856 vc_conn.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006857
6858 f_ctrs_msc_expect(0, "mscpool:subscr:new", 4);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006859 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006860}
6861
6862/* Three Layer 3 Complete by IMSI are round-robin'ed across two connected MSCs */
6863/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
6864 * just as well using only RSL. */
6865testcase TC_mscpool_L3Complete_by_imsi_round_robin() runs on test_CT {
6866
6867 f_init(nr_bts := 3, handler_mode := true, nr_msc := 2);
6868 f_sleep(1.0);
6869
6870 /* Control which MSC gets chosen next by the round-robin, otherwise
6871 * would be randomly affected by which other tests ran before this. */
6872 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
6873
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006874 f_ctrs_msc_init();
6875
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006876 var MSC_ConnHdlr vc_conn1;
6877 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
6878 pars1.mscpool.rsl_idx := 0;
6879 pars1.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_IMSI_LV('001010000000001'H)), '00F110'O));
6880 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6881 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006882 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006883
6884 var MSC_ConnHdlr vc_conn2;
6885 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 1);
6886 pars2.mscpool.rsl_idx := 1;
6887 pars2.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, valueof(ts_MI_IMSI_LV('001010000000002'H))));
6888 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6889 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006890 f_ctrs_msc_expect(1, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006891
6892 /* Test round-robin wrap to the first MSC */
6893 var MSC_ConnHdlr vc_conn3;
6894 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 0);
6895 pars3.mscpool.rsl_idx := 2;
6896 pars3.mscpool.l3_info := valueof(ts_PAG_RESP(valueof(ts_MI_IMSI_LV('001010000000003'H))));
6897 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
6898 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006899 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006900 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006901}
6902
6903/* Three LU by TMSI are round-robin'ed across two connected MSCs, because they contain the NULL-NRI 0
6904 * (configured in osmo-bsc.cfg). */
6905/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
6906 * just as well using only RSL. */
6907testcase TC_mscpool_LU_by_tmsi_null_nri_0_round_robin() runs on test_CT {
6908
6909 f_init(nr_bts := 3, handler_mode := true, nr_msc := 2);
6910 f_sleep(1.0);
6911
6912 /* Control which MSC gets chosen next by the round-robin, otherwise
6913 * would be randomly affected by which other tests ran before this. */
6914 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
6915
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006916 f_ctrs_msc_init();
6917
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006918 var MSC_ConnHdlr vc_conn1;
6919 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
6920 pars1.mscpool.rsl_idx := 0;
6921 pars1.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(0)), '00F110'O));
6922 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6923 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006924 f_ctrs_msc_expect(0, "mscpool:subscr:reattach");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006925
6926 var MSC_ConnHdlr vc_conn2;
6927 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 1);
6928 pars2.mscpool.rsl_idx := 1;
6929 pars2.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(0)), '00F110'O));
6930 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6931 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006932 f_ctrs_msc_expect(1, "mscpool:subscr:reattach");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006933
6934 /* Test round-robin wrap to the first MSC */
6935 var MSC_ConnHdlr vc_conn3;
6936 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 0);
6937 pars3.mscpool.rsl_idx := 2;
6938 pars3.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(0)), '00F110'O));
6939 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
6940 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006941 f_ctrs_msc_expect(0, "mscpool:subscr:reattach");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006942 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006943}
6944
6945/* Three LU by TMSI are round-robin'ed across two connected MSCs, because they contain the NULL-NRI 1
6946 * (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
6947 * NULL-NRI setting is stronger than that. */
6948/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
6949 * just as well using only RSL. */
6950testcase TC_mscpool_LU_by_tmsi_null_nri_1_round_robin() runs on test_CT {
6951
6952 f_init(nr_bts := 3, handler_mode := true, nr_msc := 2);
6953 f_sleep(1.0);
6954
6955 /* Control which MSC gets chosen next by the round-robin, otherwise
6956 * would be randomly affected by which other tests ran before this. */
6957 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
6958
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006959 f_ctrs_msc_init();
6960
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006961 var MSC_ConnHdlr vc_conn1;
6962 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
6963 pars1.mscpool.rsl_idx := 0;
6964 pars1.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(1)), '00F110'O));
6965 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6966 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006967 f_ctrs_msc_expect(0, "mscpool:subscr:reattach");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006968
6969 var MSC_ConnHdlr vc_conn2;
6970 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 1);
6971 pars2.mscpool.rsl_idx := 1;
6972 pars2.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(1)), '00F110'O));
6973 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6974 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006975 f_ctrs_msc_expect(1, "mscpool:subscr:reattach");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006976
6977 /* Test round-robin wrap to the first MSC */
6978 var MSC_ConnHdlr vc_conn3;
6979 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 0);
6980 pars3.mscpool.rsl_idx := 2;
6981 pars3.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(1)), '00F110'O));
6982 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
6983 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006984 f_ctrs_msc_expect(0, "mscpool:subscr:reattach");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006985 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006986}
6987
6988/* Three Layer 3 Complete by TMSI are round-robin'ed across two connected MSCs, because they contain an NRI not
6989 * assigned to any MSC (configured in osmo-bsc.cfg). */
6990/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
6991 * just as well using only RSL. */
6992testcase TC_mscpool_L3Complete_by_tmsi_unassigned_nri_round_robin() runs on test_CT {
6993
6994 f_init(nr_bts := 3, handler_mode := true, nr_msc := 2);
6995 f_sleep(1.0);
6996
6997 /* Control which MSC gets chosen next by the round-robin, otherwise
6998 * would be randomly affected by which other tests ran before this. */
6999 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
7000
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007001 f_ctrs_msc_init();
7002
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007003 var MSC_ConnHdlr vc_conn1;
7004 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
7005 pars1.mscpool.rsl_idx := 0;
7006 /* An NRI that is not assigned to any MSC */
7007 pars1.mscpool.l3_info := valueof(ts_ML3_MO_MM_IMSI_DET_Ind(valueof(ts_MI_TMSI_NRI_LV(1023))));
7008 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
7009 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007010 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007011
7012 var MSC_ConnHdlr vc_conn2;
7013 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 1);
7014 pars2.mscpool.rsl_idx := 1;
7015 /* An NRI that is not assigned to any MSC */
7016 pars2.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(768)), '00F110'O));
7017 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
7018 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007019 f_ctrs_msc_expect(1, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007020
7021 /* Test round-robin wrap to the first MSC */
7022 var MSC_ConnHdlr vc_conn3;
7023 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 0);
7024 pars3.mscpool.rsl_idx := 2;
7025 /* An NRI that is not assigned to any MSC */
7026 pars3.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_SS_ACT, valueof(ts_MI_TMSI_NRI_LV(819))));
7027 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
7028 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007029 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007030 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007031}
7032
7033/* Three Layer 3 Complete by TMSI are round-robin'ed across two connected MSCs, because they contain an NRI
7034 * assigned to an MSC that is currently not connected (configured in osmo-bsc.cfg). */
7035/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
7036 * just as well using only RSL. */
7037testcase TC_mscpool_L3Complete_by_tmsi_valid_nri_msc_not_connected_round_robin() runs on test_CT {
7038
7039 f_init(nr_bts := 3, handler_mode := true, nr_msc := 2);
7040 f_sleep(1.0);
7041
7042 /* Control which MSC gets chosen next by the round-robin, otherwise
7043 * would be randomly affected by which other tests ran before this. */
7044 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
7045
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007046 f_ctrs_msc_init();
7047
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007048 var MSC_ConnHdlr vc_conn1;
7049 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
7050 pars1.mscpool.rsl_idx := 0;
7051 /* An NRI that is assigned to an unconnected MSC */
7052 pars1.mscpool.l3_info := valueof(ts_PAG_RESP(valueof(ts_MI_TMSI_NRI_LV(512))));
7053 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
7054 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007055 f_ctrs_msc_add(2, "mscpool:subscr:attach_lost");
7056 f_ctrs_msc_add(0, "mscpool:subscr:new");
7057 f_ctrs_msc_verify();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007058
7059 var MSC_ConnHdlr vc_conn2;
7060 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 1);
7061 pars2.mscpool.rsl_idx := 1;
7062 /* An NRI that is assigned to an unconnected MSC */
7063 pars2.mscpool.l3_info := valueof(ts_ML3_MO_MM_IMSI_DET_Ind(valueof(ts_MI_TMSI_NRI_LV(767))));
7064 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
7065 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007066 f_ctrs_msc_add(2, "mscpool:subscr:attach_lost");
7067 f_ctrs_msc_add(1, "mscpool:subscr:new");
7068 f_ctrs_msc_verify();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007069
7070 /* Test round-robin wrap to the first MSC */
7071 var MSC_ConnHdlr vc_conn3;
7072 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 0);
7073 pars3.mscpool.rsl_idx := 2;
7074 /* An NRI that is assigned to an unconnected MSC */
7075 pars3.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(750)), '00F110'O));
7076 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
7077 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007078 f_ctrs_msc_add(2, "mscpool:subscr:attach_lost");
7079 f_ctrs_msc_add(0, "mscpool:subscr:new");
7080 f_ctrs_msc_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007081 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007082}
7083
7084/* Three Layer 3 Complete by TMSI with valid NRI for the second MSC are all directed to the second MSC (configured in
7085 * osmo-bsc.cfg). */
7086/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
7087 * just as well using only RSL. */
7088testcase TC_mscpool_L3Complete_by_tmsi_valid_nri_1() runs on test_CT {
7089
7090 f_init(nr_bts := 3, handler_mode := true, nr_msc := 2);
7091 f_sleep(1.0);
7092
7093 /* All TMSIs in this test point at the second MSC, set the round robin to point at the first MSC to make sure
7094 * this is not using round-robin. */
7095 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
7096
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007097 f_ctrs_msc_init();
7098
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007099 var MSC_ConnHdlr vc_conn1;
7100 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 1);
7101 pars1.mscpool.rsl_idx := 0;
7102 /* An NRI of the second MSC's range (256-511) */
7103 pars1.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_SMS, valueof(ts_MI_TMSI_NRI_LV(256))));
7104 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
7105 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007106 f_ctrs_msc_expect(1, "mscpool:subscr:known");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007107
7108 var MSC_ConnHdlr vc_conn2;
7109 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 1);
7110 pars2.mscpool.rsl_idx := 1;
7111 /* An NRI of the second MSC's range (256-511) */
7112 pars2.mscpool.l3_info := valueof(ts_PAG_RESP(valueof(ts_MI_TMSI_NRI_LV(260))));
7113 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
7114 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007115 f_ctrs_msc_expect(1, "mscpool:subscr:known");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007116
7117 var MSC_ConnHdlr vc_conn3;
7118 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 1);
7119 pars3.mscpool.rsl_idx := 2;
7120 /* An NRI of the second MSC's range (256-511) */
7121 pars3.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(511)), '00F110'O));
7122 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
7123 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007124 f_ctrs_msc_expect(1, "mscpool:subscr:known");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007125 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007126}
7127
7128/* Layer 3 Complete by TMSI with valid NRI for the third MSC are directed to the third MSC (configured in osmo-bsc.cfg),
7129 * while a round-robin remains unaffected by that. */
7130/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
7131 * just as well using only RSL. */
7132testcase TC_mscpool_L3Complete_by_tmsi_valid_nri_2() runs on test_CT {
7133
7134 f_init(nr_bts := 3, handler_mode := true, nr_msc := 3);
7135 f_sleep(1.0);
7136
7137 /* All TMSIs in this test point at the third MSC, set the round robin to point at the second MSC to make sure
7138 * this is not using round-robin. */
7139 f_vty_transceive(BSCVTY, "mscpool roundrobin next 1");
7140
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007141 f_ctrs_msc_init();
7142
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007143 var MSC_ConnHdlr vc_conn1;
7144 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 2);
7145 pars1.mscpool.rsl_idx := 0;
7146 /* An NRI of the third MSC's range (512-767) */
7147 pars1.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_SMS, valueof(ts_MI_TMSI_NRI_LV(512))));
7148 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
7149 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007150 f_ctrs_msc_expect(2, "mscpool:subscr:known");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007151
7152 var MSC_ConnHdlr vc_conn2;
7153 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 2);
7154 pars2.mscpool.rsl_idx := 1;
7155 /* An NRI of the third MSC's range (512-767) */
7156 pars2.mscpool.l3_info := valueof(ts_PAG_RESP(valueof(ts_MI_TMSI_NRI_LV(678))));
7157 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
7158 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007159 f_ctrs_msc_expect(2, "mscpool:subscr:known");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007160
7161 /* The above forwardings to third MSC have not affected the round robin, which still points at the second MSC */
7162 var MSC_ConnHdlr vc_conn3;
7163 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 1);
7164 pars3.mscpool.rsl_idx := 2;
7165 pars3.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_IMSI_LV('001010000000013'H)), '00F110'O));
7166 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
7167 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007168 f_ctrs_msc_expect(1, "mscpool:subscr:new");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007169 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007170}
7171
7172/* LU with a TMSI but indicating a different PLMN in its previous LAI: ignore the NRI. */
7173/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
7174 * just as well using only RSL. */
7175testcase TC_mscpool_LU_by_tmsi_from_other_PLMN() runs on test_CT {
7176
7177 f_init(nr_bts := 3, handler_mode := true, nr_msc := 3);
7178 f_sleep(1.0);
7179
7180 /* The TMSIs in this test points at the second MSC, but since it is from a different PLMN, round-robin is used
7181 * instead, and hits msc 0. */
7182 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
7183
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007184 f_ctrs_msc_init();
7185
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007186 /* An NRI of the second MSC's range (256-511), but a PLMN that doesn't match with osmo-bsc.cfg */
7187 var MSC_ConnHdlr vc_conn1;
7188 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
7189 pars1.mscpool.rsl_idx := 0;
7190 pars1.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(260)), '99F999'O));
7191 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
7192 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007193 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007194
7195 /* An NRI of the third MSC's range (512-767) and a matching PLMN gets directed by NRI. */
7196 var MSC_ConnHdlr vc_conn2;
7197 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 2);
7198 pars2.mscpool.rsl_idx := 1;
7199 pars2.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(555)), '00F110'O));
7200 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
7201 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007202 f_ctrs_msc_expect(2, "mscpool:subscr:known");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007203 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007204}
7205
7206/* Make sure that whichever MSC paged a subscriber will also get the Paging Response. Page by IMSI, which would be
7207 * round-robined to another MSC, to make sure the Paging->Response relation is stronger than the NRI->MSC mapping. */
7208private function f_tc_mscpool_paging_imsi(charstring id) runs on MSC_ConnHdlr {
7209 var template BSSMAP_FIELD_CellIdentificationList cid_list := { cIl_CI := { ts_BSSMAP_CI_CI(0) } };
7210 //cid_list := { cIl_allInBSS := ''O };
7211 var RSL_ChanNeeded rsl_chneed := RSL_CHANNEED_SDCCH;
7212 var template BSSMAP_IE_ChannelNeeded bssmap_chneed := ts_BSSMAP_IE_ChanNeeded(int2bit(enum2int(valueof(rsl_chneed)),2));
7213 var BSSAP_N_UNITDATA_req paging;
7214 var hexstring imsi := '001010000000123'H;
7215
7216 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
7217
Neels Hofmeyr90f80962020-06-12 16:16:55 +02007218 paging := valueof(ts_BSSAP_UNITDATA_req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007219 valueof(ts_BSSMAP_Paging(imsi, cid_list, omit, bssmap_chneed))));
7220 BSSAP.send(paging);
7221
7222 /* Register any RSL conn so that the Paging Command gets received here. With the current RSL_Emulation's main()
7223 * handling of '[bts_role] IPA_PT.receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD()))' it doesn't matter at all which
7224 * channel number is picked here. */
7225 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(0, RSL_CHAN_NR_INVALID));
7226 f_rslem_register(0, new_chan_nr);
7227 RSL.receive(tr_RSL_PAGING_CMD(tr_MI_IMSI(imsi)));
7228 f_rslem_unregister(0, new_chan_nr);
7229
7230 /* Despite the round robin pointing at the second MSC ('roundrobin next 1'), the earlier Paging for the same IMSI
7231 * causes this Paging Response to go to the first MSC (bssap_idx := 0). */
7232 f_perform_compl_l3(RSL, ts_PAG_RESP(valueof(ts_MI_IMSI_LV(imsi))) );
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007233 f_sleep(1.0);
7234}
7235testcase TC_mscpool_paging_and_response_imsi() runs on test_CT {
7236 f_init(nr_bts := 1, handler_mode := true, nr_msc := 3);
7237 f_sleep(1.0);
7238
7239 /* Testing a Paging on the first MSC to get a Paging Response back to the first MSC. Set round robin to the
7240 * second MSC to make sure we're getting the Paging logic, not a coincidental round robin match. */
7241 f_vty_transceive(BSCVTY, "mscpool roundrobin next 1");
7242
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007243 f_ctrs_msc_init();
7244
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007245 var MSC_ConnHdlr vc_conn1;
7246 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
7247 pars1.mscpool.rsl_idx := 0;
Neels Hofmeyr90f80962020-06-12 16:16:55 +02007248 pars1.sccp_addr_bsc := g_bssap[pars1.mscpool.bssap_idx].sccp_addr_peer;
7249 pars1.sccp_addr_msc := g_bssap[pars1.mscpool.bssap_idx].sccp_addr_own;
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007250 vc_conn1 := f_start_handler(refers(f_tc_mscpool_paging_imsi), pars1);
7251 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007252 f_ctrs_msc_expect(0, "mscpool:subscr:paged");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007253 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007254}
7255
7256/* Make sure that whichever MSC paged a subscriber will also get the Paging Response. Page by TMSI with an NRI value
7257 * that matches a different MSC, to make sure the Paging->Response relation is stronger than the NRI->MSC mapping. */
7258private function f_tc_mscpool_paging_tmsi(charstring id) runs on MSC_ConnHdlr {
7259 var template BSSMAP_FIELD_CellIdentificationList cid_list := { cIl_CI := { ts_BSSMAP_CI_CI(0) } };
7260 //cid_list := { cIl_allInBSS := ''O };
7261 var RSL_ChanNeeded rsl_chneed := RSL_CHANNEED_SDCCH;
7262 var template BSSMAP_IE_ChannelNeeded bssmap_chneed := ts_BSSMAP_IE_ChanNeeded(int2bit(enum2int(valueof(rsl_chneed)),2));
7263 var integer nri_v := 300; /* <-- second MSC's NRI */
Harald Weltebf397612021-01-14 20:39:46 +01007264 var octetstring tmsi := f_gen_tmsi(suffix := 0, nri_v := nri_v);
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007265 var BSSAP_N_UNITDATA_req paging;
7266
7267 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
7268
Neels Hofmeyr90f80962020-06-12 16:16:55 +02007269 paging := valueof(ts_BSSAP_UNITDATA_req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007270 valueof(ts_BSSMAP_Paging('001010000000011'H, cid_list, tmsi, bssmap_chneed))));
7271 BSSAP.send(paging);
7272
7273 /* Register any RSL conn so that the Paging Command gets received here. With the current RSL_Emulation's main()
7274 * handling of '[bts_role] IPA_PT.receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD()))' it doesn't matter at all which
7275 * channel number is picked here. */
7276 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(0, RSL_CHAN_NR_INVALID));
7277 f_rslem_register(0, new_chan_nr);
7278 RSL.receive(tr_RSL_PAGING_CMD(t_MI_TMSI(tmsi)));
7279 f_rslem_unregister(0, new_chan_nr);
7280
7281 /* Despite the NRI matching the second MSC (NRI from 'msc 1' in osmo-bsc.cfg) and round robin pointing at the
7282 * third MSC ('roundrobin next 2'), the earlier Paging for the same TMSI causes this Paging Response to go to
7283 * the first MSC (bssap_idx := 0). */
7284 f_perform_compl_l3(RSL, ts_PAG_RESP(valueof(ts_MI_TMSI_NRI_LV(nri_v))) );
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007285 f_sleep(1.0);
7286}
7287testcase TC_mscpool_paging_and_response_tmsi() runs on test_CT {
7288 f_init(nr_bts := 1, handler_mode := true, nr_msc := 3);
7289 f_sleep(1.0);
7290
7291 /* Testing a Paging on the first MSC to get a Paging Response back to the first MSC. Set round robin to the
7292 * third MSC to make sure we're getting the Paging logic, not a coincidental round robin match. */
7293 f_vty_transceive(BSCVTY, "mscpool roundrobin next 2");
7294
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007295 f_ctrs_msc_init();
7296
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007297 var MSC_ConnHdlr vc_conn1;
7298 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
7299 pars1.mscpool.rsl_idx := 0;
Neels Hofmeyr90f80962020-06-12 16:16:55 +02007300 pars1.sccp_addr_bsc := g_bssap[pars1.mscpool.bssap_idx].sccp_addr_peer;
7301 pars1.sccp_addr_msc := g_bssap[pars1.mscpool.bssap_idx].sccp_addr_own;
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007302 vc_conn1 := f_start_handler(refers(f_tc_mscpool_paging_tmsi), pars1);
7303 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007304 f_ctrs_msc_expect(0, "mscpool:subscr:paged");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007305 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007306}
7307
7308/* For round-robin, skip an MSC that has 'no allow-attach' set. */
7309/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
7310 * just as well using only RSL. */
7311testcase TC_mscpool_no_allow_attach_round_robin() runs on test_CT {
7312
7313 f_init(nr_bts := 3, handler_mode := true, nr_msc := 3);
7314 f_sleep(1.0);
Neels Hofmeyra460f1f2020-08-09 20:17:03 +00007315 /* Mark the second MSC as offloading, round-robin should skip this MSC now. */
7316 f_vty_msc_allow_attach(BSCVTY, {true, false, true});
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007317
7318 /* Control which MSC gets chosen next by the round-robin, otherwise
7319 * would be randomly affected by which other tests ran before this. */
7320 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
7321
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007322 f_ctrs_msc_init();
7323
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007324 var MSC_ConnHdlr vc_conn1;
7325 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
7326 pars1.mscpool.rsl_idx := 0;
7327 pars1.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_IMSI_LV('001010000000001'H)), '00F110'O));
7328 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
7329 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007330 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007331
7332 var MSC_ConnHdlr vc_conn2;
7333 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 2);
7334 pars2.mscpool.rsl_idx := 1;
7335 pars2.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, valueof(ts_MI_IMSI_LV('001010000000002'H))));
7336 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
7337 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007338 f_ctrs_msc_expect(2, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007339
7340 var MSC_ConnHdlr vc_conn3;
7341 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 0);
7342 pars3.mscpool.rsl_idx := 2;
7343 pars3.mscpool.l3_info := valueof(ts_PAG_RESP(valueof(ts_MI_IMSI_LV('001010000000003'H))));
7344 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
7345 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007346 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007347 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007348}
7349
7350/* An MSC that has 'no allow-attach' set should still serve subscribers that are already attached according to their
7351 * TMSI NRI. */
7352testcase TC_mscpool_no_allow_attach_valid_nri() runs on test_CT {
7353
7354 f_init(nr_bts := 3, handler_mode := true, nr_msc := 3);
7355 f_sleep(1.0);
7356
Neels Hofmeyra460f1f2020-08-09 20:17:03 +00007357 /* Mark the second MSC as offloading, round-robin should skip this MSC now. */
7358 f_vty_msc_allow_attach(BSCVTY, {true, false, true});
7359
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007360 /* Control which MSC gets chosen next by the round-robin, otherwise
7361 * would be randomly affected by which other tests ran before this. */
7362 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
7363
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007364 f_ctrs_msc_init();
7365
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007366 /* Round robin points at msc 0, but the valid NRI directs to msc 1, even though msc 1 has 'no allow-attach'. */
7367 var MSC_ConnHdlr vc_conn1;
7368 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 1);
7369 pars1.mscpool.rsl_idx := 0;
7370 /* An NRI of the second MSC's range (256-511) */
7371 pars1.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, valueof(ts_MI_TMSI_NRI_LV(260))));
7372 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
7373 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007374 f_ctrs_msc_expect(1, "mscpool:subscr:known");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007375
7376 var MSC_ConnHdlr vc_conn2;
7377 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 0);
7378 pars2.mscpool.rsl_idx := 1;
7379 pars2.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, valueof(ts_MI_IMSI_LV('001010000000002'H))));
7380 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
7381 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007382 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007383
7384 var MSC_ConnHdlr vc_conn3;
7385 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 2);
7386 pars3.mscpool.rsl_idx := 2;
7387 pars3.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, valueof(ts_MI_IMSI_LV('001010000000003'H))));
7388 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
7389 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007390 f_ctrs_msc_expect(2, "mscpool:subscr:new");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007391 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007392}
7393
Philipp Maier783681c2020-07-16 16:47:06 +02007394/* Allow/Deny emergency calls globally via VTY */
7395private function f_vty_allow_emerg_msc(boolean allow) runs on test_CT {
7396 f_vty_enter_cfg_msc(BSCVTY, 0);
7397 if (allow) {
7398 f_vty_transceive(BSCVTY, "allow-emergency allow");
7399 } else {
7400 f_vty_transceive(BSCVTY, "allow-emergency deny");
7401 }
7402 f_vty_transceive(BSCVTY, "exit");
7403 f_vty_transceive(BSCVTY, "exit");
7404}
7405
7406/* Allow/Deny emergency calls per BTS via VTY */
7407private function f_vty_allow_emerg_bts(boolean allow, integer bts_nr) runs on test_CT {
7408 f_vty_enter_cfg_bts(BSCVTY, bts_nr);
7409 if (allow) {
7410 f_vty_transceive(BSCVTY, "rach emergency call allowed 1");
7411 } else {
7412 f_vty_transceive(BSCVTY, "rach emergency call allowed 0");
7413 }
7414 f_vty_transceive(BSCVTY, "exit");
7415 f_vty_transceive(BSCVTY, "exit");
Neels Hofmeyrb6ed80c2020-10-12 22:52:39 +00007416 f_vty_transceive(BSCVTY, "exit");
Philipp Maier783681c2020-07-16 16:47:06 +02007417}
7418
Pau Espin Pedrol9ae36d52021-06-15 17:29:43 +02007419/* Allow/Forbid Fast Return after SRVCC on a given BTS via VTY */
7420private function f_vty_allow_srvcc_fast_return(boolean allow, integer bts_nr) runs on test_CT {
7421 f_vty_enter_cfg_bts(BSCVTY, bts_nr);
7422 if (allow) {
7423 f_vty_transceive(BSCVTY, "srvcc fast-return allow");
7424 } else {
7425 f_vty_transceive(BSCVTY, "srvcc fast-return forbid");
7426 }
7427 f_vty_transceive(BSCVTY, "exit");
7428 f_vty_transceive(BSCVTY, "exit");
7429 f_vty_transceive(BSCVTY, "exit");
7430}
7431
Philipp Maier783681c2020-07-16 16:47:06 +02007432/* Begin assignmet procedure and send an EMERGENCY SETUP (RR) */
7433private function f_assignment_emerg_setup() runs on MSC_ConnHdlr {
7434 var PDU_ML3_MS_NW emerg_setup;
7435 var octetstring emerg_setup_enc;
7436 var RSL_Message emerg_setup_data_ind;
7437
7438 f_establish_fully(omit, omit);
7439
7440 emerg_setup := valueof(ts_ML3_MO_CC_EMERG_SETUP(1, valueof(ts_Bcap_voice)));
7441 emerg_setup_enc := enc_PDU_ML3_MS_NW(emerg_setup);
7442 emerg_setup_data_ind := valueof(ts_RSL_DATA_IND(g_chan_nr, valueof(ts_RslLinkID_DCCH(0)), emerg_setup_enc));
7443
7444 RSL.send(emerg_setup_data_ind);
7445}
7446
7447/* Test if the EMERGENCY SETUP gets passed on to the MSC via A when EMERGENCY
7448 * CALLS are permitted by the BSC config. */
7449private function f_TC_assignment_emerg_setup_allow(charstring id) runs on MSC_ConnHdlr {
7450 var PDU_BSSAP emerg_setup_data_ind_bssap;
7451 var PDU_ML3_MS_NW emerg_setup;
7452 timer T := 3.0;
7453
7454 f_assignment_emerg_setup()
7455
7456 T.start;
7457 alt {
7458 [] BSSAP.receive(tr_BSSAP_DTAP) -> value emerg_setup_data_ind_bssap {
7459 emerg_setup := dec_PDU_ML3_MS_NW(emerg_setup_data_ind_bssap.pdu.dtap);
7460 if (not isbound(emerg_setup.msgs.cc.emergencySetup)) {
7461 setverdict(fail, "no emergency setup");
7462 }
7463 }
7464 [] BSSAP.receive {
7465 setverdict(fail, "unexpected BSSAP message!");
7466 }
7467 [] T.timeout {
7468 setverdict(fail, "timout waiting for EMERGENCY SETUP!");
7469 }
7470 }
7471
7472 setverdict(pass);
7473}
7474
7475/* Test if the EMERGENCY SETUP gets blocked by the BSC if EMERGENCY CALLS are
7476 * forbidden by the BSC config. */
7477private function f_TC_assignment_emerg_setup_deny(charstring id) runs on MSC_ConnHdlr {
7478 var PDU_BSSAP emerg_setup_data_ind_bssap;
7479 timer T := 3.0;
7480
7481 f_assignment_emerg_setup()
7482
7483 T.start;
7484 alt {
7485 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_RELEASE)) {
7486 setverdict(pass);
7487 }
7488 [] RSL.receive {
7489 setverdict(fail, "unexpected RSL message!");
7490 }
7491 [] T.timeout {
7492 setverdict(fail, "timout waiting for RR CHANNEL RELEASE!");
7493 }
7494 }
7495}
7496
7497/* EMERGENCY CALL situation #1, allowed globally and by BTS */
7498testcase TC_assignment_emerg_setup_allow() runs on test_CT {
7499 var TestHdlrParams pars := f_gen_test_hdlr_pars();
7500 var MSC_ConnHdlr vc_conn;
7501
7502 f_init(1, true);
7503 f_sleep(1.0);
7504
7505 f_vty_allow_emerg_msc(true);
7506 f_vty_allow_emerg_bts(true, 0);
7507 vc_conn := f_start_handler(refers(f_TC_assignment_emerg_setup_allow), pars);
7508 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007509 f_shutdown_helper();
Philipp Maier783681c2020-07-16 16:47:06 +02007510}
7511
7512/* EMERGENCY CALL situation #2, forbidden globally but allowed by BTS */
7513testcase TC_assignment_emerg_setup_deny_msc() runs on test_CT {
7514 var TestHdlrParams pars := f_gen_test_hdlr_pars();
7515 var MSC_ConnHdlr vc_conn;
7516
7517 f_init(1, true);
7518 f_sleep(1.0);
7519
7520 f_vty_allow_emerg_msc(false);
7521 f_vty_allow_emerg_bts(true, 0);
7522 vc_conn := f_start_handler(refers(f_TC_assignment_emerg_setup_deny), pars);
7523 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007524 f_shutdown_helper();
Philipp Maier783681c2020-07-16 16:47:06 +02007525}
7526
7527/* EMERGENCY CALL situation #3, allowed globally but forbidden by BTS */
7528testcase TC_assignment_emerg_setup_deny_bts() runs on test_CT {
7529 var TestHdlrParams pars := f_gen_test_hdlr_pars();
7530 var MSC_ConnHdlr vc_conn;
7531
7532 /* Note: This simulates a spec violation by the MS, correct MS
7533 * implementations would not try to establish an emergency call because
7534 * the system information tells in advance that emergency calls are
7535 * not forbidden */
7536
7537 f_init(1, true);
7538 f_sleep(1.0);
7539
7540 f_vty_allow_emerg_msc(true);
7541 f_vty_allow_emerg_bts(false, 0);
7542 vc_conn := f_start_handler(refers(f_TC_assignment_emerg_setup_deny), pars);
7543 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007544 f_shutdown_helper();
Philipp Maier783681c2020-07-16 16:47:06 +02007545}
7546
Philipp Maier82812002020-08-13 18:48:27 +02007547/* Test what happens when an emergency call arrives while all TCH channels are
7548 * busy, the BSC is expected to terminate one call in favor of the incoming
7549 * emergency call */
7550testcase TC_emerg_premption() runs on test_CT {
7551 var ASP_RSL_Unitdata rsl_ud;
7552 var integer i;
7553 var integer chreq_total, chreq_nochan;
7554 var RSL_Message rx_rsl;
7555 var RslChannelNr chan_nr;
7556
7557 f_init(1);
7558 f_sleep(1.0);
7559
7560 f_vty_allow_emerg_msc(true);
7561 f_vty_allow_emerg_bts(true, 0);
7562
7563 /* Fill up all channels on the BTS */
7564 chreq_total := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total");
7565 chreq_nochan := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:no_channel");
7566 for (i := 0; i < NUM_TCHF_PER_BTS + NUM_TCHH_PER_BTS + NUM_SDCCH_PER_BTS; i := i+1) {
7567 chan_nr := f_chreq_act_ack('33'O, i);
7568 }
7569 IPA_RSL[0].clear;
7570 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total",
7571 chreq_total + NUM_TCHF_PER_BTS + NUM_TCHH_PER_BTS + NUM_SDCCH_PER_BTS);
7572
7573 /* Send Channel request for emegergency call */
7574 f_ipa_tx(0, ts_RSL_CHAN_RQD('A5'O, 23));
7575
7576 /* Expect the BSC to release one (the first) TCH/F on the BTS */
7577 chan_nr := valueof(t_RslChanNr_Bm(1));
7578 f_expect_chan_rel(0, chan_nr, expect_rr_chan_rel := false, expect_rll_rel_req := false);
7579
7580 /* Expect the BSC to send activate/assign the a channel for the emergency call */
7581 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
7582 chan_nr := rx_rsl.ies[0].body.chan_nr;
7583 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, 33));
7584 rx_rsl := f_exp_ipa_rx(0, tr_RSL_IMM_ASSIGN(0));
Philipp Maier104f4c02020-09-11 18:12:18 +02007585
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007586 f_shutdown_helper();
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007587}
7588
7589/* Hopping parameters per a timeslot */
Vadim Yanitskiybc6654a2020-09-13 01:27:40 +07007590private type record length(0..64) of GsmArfcn ArfcnList;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007591private type record FHParamsTs {
7592 boolean enabled,
7593 uint6_t hsn,
7594 uint6_t maio,
7595 ArfcnList ma
7596};
7597
7598/* Hopping parameters per a transceiver */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007599private type record FHParamsTrx {
7600 GsmArfcn arfcn,
7601 FHParamsTs ts[8]
7602};
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007603
7604/* Randomly generate the hopping parameters for the given timeslot numbers */
7605private function f_TC_fh_params_gen(template integer tr_tn := (1, 3, 5))
7606runs on test_CT return FHParamsTrx {
7607 var FHParamsTrx fhp;
7608
Vadim Yanitskiy3e997362020-09-05 21:08:34 +07007609 /* Generate a random ARFCN, including ARFCN 0 */
7610 fhp.arfcn := f_rnd_int(3);
Vadim Yanitskiye7c8c6e2020-09-13 14:33:03 +07007611
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007612 for (var integer tn := 0; tn < 8; tn := tn + 1) {
7613 if (not match(tn, tr_tn)) {
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007614 fhp.ts[tn].enabled := false;
7615 fhp.ts[tn].ma := { };
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007616 continue;
7617 }
7618
7619 /* Random HSN / MAIO values: 0..63 */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007620 fhp.ts[tn].hsn := f_rnd_int(64);
7621 fhp.ts[tn].maio := f_rnd_int(64);
7622 fhp.ts[tn].ma := { };
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007623
7624 /* Random Mobile Allocation (hopping channels) */
7625 var integer ma_len := 2 + f_rnd_int(9); /* 2..10 channels */
7626 var integer step := 3 + f_rnd_int(4); /* 3..6 stepping */
7627 for (var integer i := 1; i <= ma_len; i := i + 1) {
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007628 fhp.ts[tn].ma := fhp.ts[tn].ma & { i * step };
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007629 }
7630
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007631 fhp.ts[tn].enabled := true;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007632 }
7633
7634 log("f_TC_fh_params_gen(): ", fhp);
7635 return fhp;
7636}
7637
7638/* Make sure that the given Channel Description IE matches the hopping configuration */
7639private function f_TC_fh_params_match_chan_desc(in FHParamsTrx fhp, in ChannelDescription cd)
7640{
7641 var template (present) ChannelDescription tr_cd;
7642 var template (present) MaioHsn tr_maio_hsn;
7643 var uint3_t tn := cd.chan_nr.tn;
7644
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007645 if (fhp.ts[tn].enabled) {
7646 tr_maio_hsn := tr_HsnMaio(fhp.ts[tn].hsn, fhp.ts[tn].maio);
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007647 tr_cd := tr_ChanDescH1(cd.chan_nr, tr_maio_hsn);
7648 } else {
Vadim Yanitskiye7c8c6e2020-09-13 14:33:03 +07007649 tr_cd := tr_ChanDescH0(cd.chan_nr, fhp.arfcn);
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007650 }
7651
7652 if (not match(cd, tr_cd)) {
7653 setverdict(fail, "Channel Description IE does not match: ",
7654 cd, " vs expected ", tr_cd);
7655 }
7656}
7657
7658/* Make sure that the given Mobile Allocation IE matches the hopping configuration */
7659private function f_TC_fh_params_match_ma(in FHParamsTrx fhp, uint3_t tn,
7660 in MobileAllocationLV ma)
7661{
7662 var template MobileAllocationLV tr_ma := f_TC_fh_params_gen_tr_ma(fhp, tn, ma);
7663
7664 if (not match(ma, tr_ma)) {
7665 setverdict(fail, "Mobile Allocation IE does not match (tn := ",
7666 tn, "): ", ma, " vs expected: ", tr_ma);
7667 } else {
7668 setverdict(pass);
7669 }
7670}
7671
7672private function f_TC_fh_params_gen_tr_ma(in FHParamsTrx fhp, uint3_t tn,
7673 in MobileAllocationLV ma)
7674return template MobileAllocationLV {
7675 /* Mobile Allocation IE is expected to be empty if hopping is not enabled */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007676 if (not fhp.ts[tn].enabled) {
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007677 return { len := 0, ma := ''B };
7678 }
7679
7680 var bitstring full_mask := f_pad_bit(''B, 1024, '0'B);
7681 var bitstring slot_mask := f_pad_bit(''B, 1024, '0'B);
7682 var bitstring ma_mask := ''B;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007683
7684 /* Compose the full bit-mask (all channels, up to 1024 entries) */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007685 for (var integer i := 0; i < lengthof(fhp.ts); i := i + 1) {
7686 for (var integer j := 0; j < lengthof(fhp.ts[i].ma); j := j + 1) {
7687 if (full_mask[fhp.ts[i].ma[j]] == '1'B)
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007688 { continue; }
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007689 full_mask[fhp.ts[i].ma[j]] := '1'B;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007690 }
7691 }
7692
Vadim Yanitskiye7c8c6e2020-09-13 14:33:03 +07007693 /* Take ARFCN of the TRX itself into account */
7694 full_mask[fhp.arfcn] := '1'B;
7695
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007696 /* Compose a bit-mask for the given timeslot number */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007697 for (var integer i := 0; i < lengthof(fhp.ts[tn].ma); i := i + 1) {
7698 slot_mask[fhp.ts[tn].ma[i]] := '1'B;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007699 }
7700
7701 /* Finally, compose the Mobile Allocation bit-mask */
Vadim Yanitskiy3e997362020-09-05 21:08:34 +07007702 for (var integer i := 1; i < lengthof(full_mask); i := i + 1) {
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007703 if (full_mask[i] != '1'B)
7704 { continue; }
7705
7706 /* FIXME: ma_mask := ma_mask & slot_mask[i]; // triggers a bug in TITAN */
7707 if (slot_mask[i] == '1'B) {
7708 ma_mask := ma_mask & '1'B;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007709 } else {
7710 ma_mask := ma_mask & '0'B;
7711 }
7712 }
7713
Vadim Yanitskiy3e997362020-09-05 21:08:34 +07007714 /* ARFCN 0 (if present) goes to the last position of the bit-mask */
7715 if (full_mask[0] == '1'B) {
7716 /* FIXME: ma_mask := ma_mask & slot_mask[0]; // triggers a bug in TITAN */
7717 if (slot_mask[0] == '1'B) {
7718 ma_mask := ma_mask & '1'B;
7719 } else {
7720 ma_mask := ma_mask & '0'B;
7721 }
7722 }
7723
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007724 /* Ensure that ma_mask is octet-aligned */
Vadim Yanitskiy2aa02522020-09-06 14:05:23 +07007725 var integer ma_mask_len := (lengthof(ma_mask) + 8 - 1) / 8;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007726 ma_mask := f_pad_bit(ma_mask, ma_mask_len * 8, '0'B);
7727
7728 return { len := ma_mask_len, ma := ma_mask };
7729}
7730
7731/* Configure the hopping parameters in accordance with the given record */
7732private function f_TC_fh_params_set(in FHParamsTrx fhp,
7733 uint8_t bts_nr := 0,
7734 uint8_t trx_nr := 0)
7735runs on test_CT {
7736 /* Enter the configuration node for the given BTS/TRX numbers */
7737 f_vty_enter_cfg_trx(BSCVTY, bts_nr, trx_nr);
7738
Vadim Yanitskiye7c8c6e2020-09-13 14:33:03 +07007739 f_vty_transceive(BSCVTY, "arfcn " & int2str(fhp.arfcn));
7740
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007741 for (var integer tn := 0; tn < lengthof(fhp.ts); tn := tn + 1) {
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007742 f_vty_transceive(BSCVTY, "timeslot " & int2str(tn));
7743
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007744 if (not fhp.ts[tn].enabled) {
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007745 f_vty_transceive(BSCVTY, "hopping enabled 0");
7746 f_vty_transceive(BSCVTY, "exit"); /* go back */
7747 continue;
7748 }
7749
7750 /* Configure HSN / MAIO values */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007751 f_vty_transceive(BSCVTY, "hopping sequence-number " & int2str(fhp.ts[tn].hsn));
7752 f_vty_transceive(BSCVTY, "hopping maio " & int2str(fhp.ts[tn].maio));
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007753
7754 /* Configure the Mobile Allocation (hopping channels) */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007755 for (var integer i := 0; i < lengthof(fhp.ts[tn].ma); i := i + 1) {
7756 f_vty_transceive(BSCVTY, "hopping arfcn add " & int2str(fhp.ts[tn].ma[i]));
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007757 }
7758
7759 f_vty_transceive(BSCVTY, "hopping enabled 1");
7760 f_vty_transceive(BSCVTY, "exit"); /* go back */
7761 }
7762
7763 f_vty_transceive(BSCVTY, "end");
7764}
7765
7766/* Disable frequency hopping on all timeslots */
7767private function f_TC_fh_params_unset(in FHParamsTrx fhp,
7768 uint8_t bts_nr := 0,
Vadim Yanitskiye7c8c6e2020-09-13 14:33:03 +07007769 uint8_t trx_nr := 0,
7770 GsmArfcn arfcn := 871)
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007771runs on test_CT {
7772 /* Enter the configuration node for the given BTS/TRX numbers */
7773 f_vty_enter_cfg_trx(BSCVTY, bts_nr, trx_nr);
7774
Vadim Yanitskiye7c8c6e2020-09-13 14:33:03 +07007775 f_vty_transceive(BSCVTY, "arfcn " & int2str(arfcn));
7776
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007777 for (var integer tn := 0; tn < lengthof(fhp.ts); tn := tn + 1) {
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007778 f_vty_transceive(BSCVTY, "timeslot " & int2str(tn));
7779
7780 /* Delete all ARFCNs from the Mobile Allocation (if any) */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007781 for (var integer i := 0; i < lengthof(fhp.ts[tn].ma); i := i + 1) {
7782 f_vty_transceive(BSCVTY, "hopping arfcn del " & int2str(fhp.ts[tn].ma[i]));
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007783 }
7784
7785 f_vty_transceive(BSCVTY, "hopping enabled 0");
7786 f_vty_transceive(BSCVTY, "exit"); /* go back */
7787 }
7788
7789 f_vty_transceive(BSCVTY, "end");
7790 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
7791}
7792
7793/* Verify presence and correctness of the hopping parameters (HSN, MAIO)
7794 * in the Channel Identification IE of the RSL CHANnel ACTIVation message. */
7795testcase TC_fh_params_chan_activ() runs on test_CT {
7796 var FHParamsTrx fhp := f_TC_fh_params_gen();
7797 var RSL_Message rsl_msg;
7798 var RSL_IE_Body ie;
7799
7800 f_init_vty();
7801
7802 f_TC_fh_params_set(fhp); /* Enable frequency hopping */
7803 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
7804
7805 f_init(1);
7806
7807 /* CS domain: 3 (SDCCH/4+CBCH) + 4 (TCH/F) + 2 (TCH/H) channels available */
7808 for (var integer i := 0; i < 9; i := i + 1) {
7809 f_ipa_tx(0, ts_RSL_CHAN_RQD(f_rnd_ra_cs(), 23));
7810 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
7811
7812 /* Make sure that Channel Identification IE is present */
7813 if (not f_rsl_find_ie(rsl_msg, RSL_IE_CHAN_IDENT, ie)) {
7814 setverdict(fail, "RSL Channel Identification IE is absent");
7815 continue;
7816 }
7817
7818 /* Make sure that hopping parameters (HSN/MAIO) match */
7819 f_TC_fh_params_match_chan_desc(fhp, ie.chan_ident.ch_desc.v);
7820
7821 /* "Mobile Allocation shall be included but empty" - let's check this */
7822 if (ie.chan_ident.ma.v.len != 0) {
7823 setverdict(fail, "Mobile Allocation IE is not empty: ",
7824 ie.chan_ident.ma, ", despite it shall be");
7825 continue;
7826 }
7827 }
7828
7829 /* Disable frequency hopping */
7830 f_TC_fh_params_unset(fhp);
7831
Vadim Yanitskiy21726312020-09-04 01:45:36 +07007832 f_shutdown_helper();
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007833}
7834
7835/* Verify the hopping parameters (HSN, MAIO, MA) in (RR) Immediate Assignment */
7836testcase TC_fh_params_imm_ass() runs on test_CT {
7837 var FHParamsTrx fhp := f_TC_fh_params_gen();
7838 var RSL_Message rsl_msg;
7839 var RSL_IE_Body ie;
7840
7841 f_init_vty();
7842
7843 f_TC_fh_params_set(fhp); /* Enable frequency hopping */
7844 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
7845
7846 f_init(1);
7847
7848 /* CS domain: 3 (SDCCH/4+CBCH) + 4 (TCH/F) + 2 (TCH/H) channels available */
7849 for (var integer i := 0; i < 9; i := i + 1) {
7850 f_ipa_tx(0, ts_RSL_CHAN_RQD(f_rnd_ra_cs(), 23));
7851 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
7852
7853 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(rsl_msg.ies[0].body.chan_nr, 33));
7854 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeC(RSL_MT_IMMEDIATE_ASSIGN_CMD));
7855
7856 /* Make sure that Full Immediate Assign Info IE is present */
7857 if (not f_rsl_find_ie(rsl_msg, RSL_IE_FULL_IMM_ASS_INFO, ie)) {
7858 setverdict(fail, "RSL Full Immediate Assign Info IE is absent");
7859 continue;
7860 }
7861
7862 /* Decode the actual Immediate Assignment message */
7863 var GsmRrMessage rr_msg := dec_GsmRrMessage(ie.full_imm_ass_info.payload);
7864 if (not match(rr_msg.header, t_RrHeader(IMMEDIATE_ASSIGNMENT, ?))) {
7865 setverdict(fail, "Failed to match Immediate Assignment: ", rr_msg);
7866 continue;
7867 }
7868
7869 /* Make sure that hopping parameters (HSN/MAIO) match */
7870 f_TC_fh_params_match_chan_desc(fhp, rr_msg.payload.imm_ass.chan_desc);
7871
7872 /* Make sure that the Mobile Allocation IE matches */
7873 f_TC_fh_params_match_ma(fhp, rr_msg.payload.imm_ass.chan_desc.chan_nr.tn,
7874 rr_msg.payload.imm_ass.mobile_allocation);
7875 }
7876
7877 /* Disable frequency hopping */
7878 f_TC_fh_params_unset(fhp);
Philipp Maier82812002020-08-13 18:48:27 +02007879
Vadim Yanitskiy21726312020-09-04 01:45:36 +07007880 f_shutdown_helper();
Philipp Maier82812002020-08-13 18:48:27 +02007881}
7882
Vadim Yanitskiyaeb54a22020-09-01 06:25:25 +07007883/* Verify the hopping parameters (HSN, MAIO, MA) in (RR) Assignment Command */
7884testcase TC_fh_params_assignment_cmd() runs on test_CT {
7885 var FHParamsTrx fhp := f_TC_fh_params_gen();
7886 var RSL_Message rsl_msg;
7887 var RSL_IE_Body ie;
7888
7889 f_init_vty();
7890
7891 f_TC_fh_params_set(fhp); /* Enable frequency hopping */
7892 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
7893
7894 f_init(1);
7895
7896 /* HACK: work around "Couldn't find Expect for CRCX" */
7897 vc_MGCP.stop;
7898
7899 var template PDU_BSSAP ass_cmd := f_gen_ass_req();
7900 ass_cmd.pdu.bssmap.assignmentRequest.codecList := ts_BSSMAP_IE_CodecList({ts_CodecFR});
7901
7902 /* CS domain (TCH): 4 (TCH/F) + 2 (TCH/H) channels available
7903 * NOTE: only 3 SDCCH/4 channels are available on CCCH+SDCCH4+CBCH */
7904 for (var integer i := 0; i < 3; i := i + 1) {
7905 /* Establish a dedicated channel, so we can trigger (late) TCH assignment */
7906 var DchanTuple dt := f_est_dchan(f_rnd_ra_cs(), 23, f_rnd_octstring(16));
7907
7908 /* Send a BSSMAP Assignment Command, expect CHANnel ACTIVation */
7909 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ass_cmd));
7910 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
7911
7912 /* ACKnowledge CHANnel ACTIVation, expect RSL DATA REQuest */
7913 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(rsl_msg.ies[0].body.chan_nr, 33));
7914 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeR(RSL_MT_DATA_REQ));
7915
7916 /* Make sure that L3 Information IE is present */
7917 if (not f_rsl_find_ie(rsl_msg, RSL_IE_L3_INFO, ie)) {
7918 setverdict(fail, "RSL L3 Information IE is absent");
7919 continue;
7920 }
7921
7922 /* Decode the L3 message and make sure it is (RR) Assignment Command */
7923 var GsmRrL3Message l3_msg := dec_GsmRrL3Message(ie.l3_info.payload);
7924 if (not match(l3_msg.header, t_RrL3Header(ASSIGNMENT_COMMAND))) {
7925 setverdict(fail, "Failed to match Assignment Command: ", l3_msg);
7926 continue;
7927 }
7928
7929 /* Make sure that hopping parameters (HSN/MAIO) match */
7930 var ChannelDescription chan_desc := l3_msg.payload.ass_cmd.chan_desc;
7931 f_TC_fh_params_match_chan_desc(fhp, chan_desc);
7932
7933 /* Make sure that Cell Channel Description IE is present if FH is enabled */
7934 if (chan_desc.h and not ispresent(l3_msg.payload.ass_cmd.cell_chan_desc)) {
Vadim Yanitskiy38d069d2020-09-02 17:18:57 +07007935 setverdict(fail, "FH enabled, but Cell Channel Description IE is absent");
Vadim Yanitskiyaeb54a22020-09-01 06:25:25 +07007936 continue;
7937 }
7938
7939 /* Make sure that the Mobile Allocation IE matches (if present) */
7940 var boolean ma_present := ispresent(l3_msg.payload.ass_cmd.mobile_allocation);
7941 if (chan_desc.h and ma_present) {
7942 f_TC_fh_params_match_ma(fhp, chan_desc.chan_nr.tn,
7943 l3_msg.payload.ass_cmd.mobile_allocation.v);
7944 } else if (chan_desc.h and not ma_present) {
7945 setverdict(fail, "FH enabled, but Mobile Allocation IE is absent");
7946 continue;
7947 } else if (not chan_desc.h and ma_present) {
7948 setverdict(fail, "FH disabled, but Mobile Allocation IE is present");
7949 continue;
7950 }
7951 }
7952
7953 /* Give the IUT some time to release all channels */
7954 f_sleep(3.0);
7955
7956 /* Disable frequency hopping */
7957 f_TC_fh_params_unset(fhp);
7958
Vadim Yanitskiy21726312020-09-04 01:45:36 +07007959 f_shutdown_helper();
Vadim Yanitskiyaeb54a22020-09-01 06:25:25 +07007960}
7961
Vadim Yanitskiy8f5430d2020-09-02 18:51:38 +07007962/* Verify the hopping parameters (HSN, MAIO, MA) in (RR) Handover Command */
7963private function f_TC_fh_params_handover_cmd(in FHParamsTrx fhp)
7964runs on test_CT {
7965 var RSL_Message rsl_msg;
7966 var RSL_IE_Body ie;
7967 var DchanTuple dt;
7968
7969 /* Establish a dedicated channel, so we can trigger handover */
7970 dt := f_est_dchan(f_rnd_ra_cs(), 23, f_rnd_octstring(16));
7971
7972 /* Trigger handover from BTS0 to BTS1 */
7973 f_bts_0_cfg(BSCVTY, { "neighbor bts 1" });
7974 f_vty_handover(BSCVTY, 0, 0, dt.rsl_chan_nr, 1);
7975
7976 /* Expect RSL CHANnel ACTIVation on BTS1/TRX0/TS1 */
7977 rsl_msg := f_exp_ipa_rx(1, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
7978
7979 /* ACKnowledge channel activation and expect (RR) Handover Command */
7980 f_ipa_tx(1, ts_RSL_CHAN_ACT_ACK(rsl_msg.ies[0].body.chan_nr, 33));
7981 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeR(RSL_MT_DATA_REQ));
7982
7983 /* Make sure that L3 Information IE is present */
7984 if (not f_rsl_find_ie(rsl_msg, RSL_IE_L3_INFO, ie)) {
7985 setverdict(fail, "RSL L3 Information IE is absent");
7986 return;
7987 }
7988
7989 /* Decode the L3 message and make sure it is (RR) Handover Command */
7990 var GsmRrL3Message l3_msg := dec_GsmRrL3Message(ie.l3_info.payload);
7991 if (not match(l3_msg.header, t_RrL3Header(HANDOVER_COMMAND))) {
7992 setverdict(fail, "Failed to match Handover Command: ", l3_msg);
7993 return;
7994 }
7995
7996 /* Make sure that we've got SDCCH/8 on TS1 (expected to be hopping) */
7997 var ChannelDescription chan_desc := l3_msg.payload.ho_cmd.chan_desc;
7998 if (not match(chan_desc.chan_nr, t_RslChanNr_SDCCH8(1, ?))) {
7999 setverdict(fail, "Unexpected channel number: ", chan_desc.chan_nr);
8000 return;
8001 }
8002
8003 /* Make sure that hopping parameters (HSN/MAIO) match */
8004 f_TC_fh_params_match_chan_desc(fhp, chan_desc);
8005
8006 /* Make sure that Cell Channel Description IE is present */
8007 if (not ispresent(l3_msg.payload.ho_cmd.cell_chan_desc)) {
8008 setverdict(fail, "FH enabled, but Cell Channel Description IE is absent");
8009 return;
8010 }
8011
8012 /* Make sure that the Mobile Allocation (after time) IE is present and matches */
8013 var boolean ma_present := ispresent(l3_msg.payload.ho_cmd.mobile_allocation);
8014 if (ma_present) {
8015 f_TC_fh_params_match_ma(fhp, chan_desc.chan_nr.tn,
8016 l3_msg.payload.ho_cmd.mobile_allocation.v);
8017 } else {
8018 setverdict(fail, "FH enabled, but Mobile Allocation IE is absent");
8019 return;
8020 }
8021}
8022testcase TC_fh_params_handover_cmd() runs on test_CT {
8023 var FHParamsTrx fhp := f_TC_fh_params_gen();
8024
8025 f_init_vty();
8026
8027 /* (Re)configure TS0 as BCCH and TS1 as SDCCH8 on BTS1/TRX0 */
8028 f_vty_enter_cfg_trx(BSCVTY, bts := 1, trx := 0);
8029
8030 f_vty_transceive(BSCVTY, "timeslot 0");
8031 f_vty_transceive(BSCVTY, "phys_chan_config ccch");
8032 f_vty_transceive(BSCVTY, "exit"); /* go back */
8033
8034 f_vty_transceive(BSCVTY, "timeslot 1");
8035 f_vty_transceive(BSCVTY, "phys_chan_config sdcch8");
8036 f_vty_transceive(BSCVTY, "end"); /* we're done */
8037
8038 f_TC_fh_params_set(fhp, 1); /* Enable frequency hopping on BTS1 */
8039 f_vty_transceive(BSCVTY, "drop bts connection 1 oml");
8040
8041 f_init(2);
8042
8043 f_TC_fh_params_handover_cmd(fhp);
8044
8045 /* Disable frequency hopping on BTS1 */
8046 f_TC_fh_params_unset(fhp, 1);
8047
8048 /* (Re)configure TS0 as CCCH+SDCCH4+CBCH and TS1 as TCH/F */
8049 f_vty_enter_cfg_trx(BSCVTY, bts := 1, trx := 0);
8050
8051 f_vty_transceive(BSCVTY, "timeslot 0");
8052 f_vty_transceive(BSCVTY, "phys_chan_config ccch+sdcch4+cbch");
8053 f_vty_transceive(BSCVTY, "exit"); /* go back */
8054
8055 f_vty_transceive(BSCVTY, "timeslot 1");
8056 f_vty_transceive(BSCVTY, "phys_chan_config tch/f");
8057 f_vty_transceive(BSCVTY, "end"); /* we're done */
8058
8059 f_shutdown_helper();
8060}
8061
Vadim Yanitskiyca974032020-09-01 07:20:39 +07008062/* Verify the hopping parameters in System Information Type 4 */
8063testcase TC_fh_params_si4_cbch() runs on test_CT {
8064 var FHParamsTrx fhp := f_TC_fh_params_gen(tr_tn := 1);
8065 var ASP_RSL_Unitdata rx_rsl_ud;
8066 timer T := 5.0;
8067
8068 f_init_vty();
8069
8070 /* (Re)configure TS0 as BCCH and TS1 as SDCCH8+CBCH */
8071 f_vty_enter_cfg_trx(BSCVTY, trx := 0);
8072
8073 f_vty_transceive(BSCVTY, "timeslot 0");
8074 f_vty_transceive(BSCVTY, "phys_chan_config ccch");
8075 f_vty_transceive(BSCVTY, "exit"); /* go back */
8076
8077 f_vty_transceive(BSCVTY, "timeslot 1");
8078 f_vty_transceive(BSCVTY, "phys_chan_config sdcch8+cbch");
8079 f_vty_transceive(BSCVTY, "end"); /* we're done */
8080
8081 f_TC_fh_params_set(fhp); /* Enable frequency hopping */
8082 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
8083
8084 f_init(1);
8085
8086 T.start;
8087 alt {
8088 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_BCCH_INFO(RSL_SYSTEM_INFO_4))) -> value rx_rsl_ud {
8089 var RSL_IE_Body ie := rx_rsl_ud.rsl.ies[2].body; /* FULL BCCH Information IE */
8090 var SystemInformation si := dec_SystemInformation(ie.other.payload);
8091
8092 /* Make sure that what we decoded is System Information Type 4 */
8093 if (si.header.message_type != SYSTEM_INFORMATION_TYPE_4) {
8094 setverdict(fail, "RSL FULL BCCH Information IE contains: ", si);
8095 repeat;
8096 }
8097
8098 /* Make sure that CBCH Channel Description IE is present */
8099 if (not ispresent(si.payload.si4.cbch_chan_desc)) {
8100 setverdict(fail, "CBCH Channel Description IE is absent");
8101 break;
8102 }
8103
8104 /* Finally, check the hopping parameters (HSN, MAIO) */
8105 var ChannelDescription chan_desc := si.payload.si4.cbch_chan_desc.v;
8106 f_TC_fh_params_match_chan_desc(fhp, chan_desc);
8107
8108 /* 3GPP TS 44.018, section 9.1.36.2 "CBCH Mobile Allocation":
8109 * The CBCH Mobile Allocation IE *shall* be present if FH is enabled. */
8110 if (chan_desc.h and not ispresent(si.payload.si4.cbch_mobile_alloc)) {
8111 setverdict(fail, "FH enabled, but Mobile Allocation IE is absent");
8112 break;
8113 } else if (chan_desc.h and ispresent(si.payload.si4.cbch_mobile_alloc)) {
8114 f_TC_fh_params_match_ma(fhp, chan_desc.chan_nr.tn,
8115 si.payload.si4.cbch_mobile_alloc.v);
8116 }
8117 }
8118 [] IPA_RSL[0].receive { repeat; }
8119 [] T.timeout {
8120 setverdict(fail, "Timeout waiting for RSL BCCH INFOrmation (SI4)");
8121 }
8122 }
8123
8124 /* Disable frequency hopping */
8125 f_TC_fh_params_unset(fhp);
8126
Vadim Yanitskiy8bc46012020-09-06 12:38:01 +07008127 /* (Re)configure TS0 as CCCH+SDCCH4+CBCH and TS1 as TCH/F */
Vadim Yanitskiyca974032020-09-01 07:20:39 +07008128 f_vty_enter_cfg_trx(BSCVTY, trx := 0);
8129
8130 f_vty_transceive(BSCVTY, "timeslot 0");
Vadim Yanitskiy8bc46012020-09-06 12:38:01 +07008131 f_vty_transceive(BSCVTY, "phys_chan_config ccch+sdcch4+cbch");
Vadim Yanitskiyca974032020-09-01 07:20:39 +07008132 f_vty_transceive(BSCVTY, "exit"); /* go back */
8133
8134 f_vty_transceive(BSCVTY, "timeslot 1");
8135 f_vty_transceive(BSCVTY, "phys_chan_config tch/f");
8136 f_vty_transceive(BSCVTY, "end"); /* we're done */
8137
Vadim Yanitskiy21726312020-09-04 01:45:36 +07008138 f_shutdown_helper();
Vadim Yanitskiyca974032020-09-01 07:20:39 +07008139}
8140
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02008141template (value) PDU_BSSAP_LE ts_BSSMAP_LE_BSSLAP(template (value) BSSLAP_PDU bsslap)
8142 := ts_BSSMAP_LE_ConnInfo(BSSMAP_LE_PROT_BSSLAP, data := enc_BSSLAP_PDU(valueof(bsslap)));
8143
8144private function f_match_bsslap(PDU_BSSAP_LE got_bsslap_msg,
8145 template (present) BSSLAP_PDU expect_bsslap)
8146{
8147 var BSSLAP_PDU bsslap := dec_BSSLAP_PDU(got_bsslap_msg.pdu.bssmap.co_info.bsslap_apdu.data);
8148 if (not match(bsslap, expect_bsslap)) {
8149 log("EXPECTING BSSLAP: ", expect_bsslap);
8150 log("GOT BSSLAP: ", bsslap);
8151 setverdict(fail, "BSSLAP is not as expected");
8152 mtc.stop;
8153 }
8154 setverdict(pass);
8155}
8156
8157/* GAD: this is an Ellipsoid point with uncertainty circle, encoded as in 3GPP TS 23.032 §7.3.2. */
8158const octetstring gad_ell_point_unc_circle := '10b0646d0d5f6627'O;
8159
8160private function f_expect_bsslap(template (present) BSSLAP_PDU expect_rx_bsslap) runs on MSC_ConnHdlr {
8161 var PDU_BSSAP_LE rx_bsslap;
8162 BSSAP_LE.receive(tr_BSSMAP_LE_ConnInfo(BSSMAP_LE_PROT_BSSLAP, ?)) -> value(rx_bsslap);
8163 f_match_bsslap(rx_bsslap, expect_rx_bsslap);
8164}
8165
8166/* With an active lchan, start BSSMAP Perform Location Request on A interface, starting BSSMAP-LE Perform Location
8167 * Request on Lb interface. Either with or without the SMLC doing a BSSLAP TA Request. */
8168private function f_lcs_loc_req_for_active_ms(boolean do_ta_request := false) runs on MSC_ConnHdlr {
8169 f_sleep(1.0);
8170
8171 f_establish_fully(omit, omit);
8172 f_bssap_le_register_imsi(g_pars.imsi, omit);
8173
8174 BSSAP.send(valueof(ts_BSSMAP_Perform_Location_Request(ts_BSSMAP_Imsi(g_pars.imsi),
8175 ts_CellId_CGI('262'H, '42'H, 23, 42))));
8176
8177 var PDU_BSSAP_LE plr;
8178 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocReq(BSSMAP_LE_LOC_INFO_CURRENT_GEOGRAPHIC_LOC, ?, ?)) -> value(plr);
8179
8180 if (not do_ta_request) {
8181 /* verify TA Layer 3 in APDU. First the APDU type (BSSLAP), then the BSSLAP data contents. */
8182 var template BSSMAP_LE_IE_APDU expect_apdu := tr_BSSMAP_LE_APDU(BSSMAP_LE_PROT_BSSLAP, ?);
8183 if (not match(plr.pdu.bssmap.perf_loc_req.bsslap_apdu, expect_apdu)) {
8184 log("EXPECTING BSSMAP-LE APDU IE ", expect_apdu);
8185 log("GOT BSSMAP-LE APDU IE ", plr.pdu.bssmap.perf_loc_req.bsslap_apdu);
8186 setverdict(fail, "BSSMAP-LE APDU IE is not as expected");
8187 mtc.stop;
8188 }
8189 var template BSSLAP_PDU expect_ta_layer3 := tr_BSSLAP_TA_Layer3(tr_BSSLAP_IE_TA(0));
8190 var BSSLAP_PDU bsslap := dec_BSSLAP_PDU(plr.pdu.bssmap.perf_loc_req.bsslap_apdu.data);
8191 if (not match(bsslap, expect_ta_layer3)) {
8192 log("EXPECTING BSSLAP TA Layer 3: ", expect_ta_layer3);
8193 log("GOT BSSLAP: ", bsslap);
8194 setverdict(fail, "BSSLAP is not as expected");
8195 mtc.stop;
8196 }
8197 /* OsmoBSC directly sent the TA as BSSLAP APDU in the BSSMAP-LE Perform Location Request to the SMLC. The SMLC
8198 * has no need to request the TA from the BSC and directly responds. */
8199 } else {
8200 /* SMLC wants to ask the TA from the BSC explicitly in a BSSLAP TA Request message */
8201 BSSAP_LE.send(ts_BSSMAP_LE_BSSLAP(ts_BSSLAP_TA_Req));
8202 f_expect_bsslap(tr_BSSLAP_TA_Resp(?, ?));
8203 }
8204
8205 /* SMLC got the TA from the BSC, now responds with geo information data. */
8206 BSSAP_LE.send(ts_BSSMAP_LE_PerfLocResp(gad_ell_point_unc_circle, omit));
8207 BSSAP_LE.receive(BSSAP_LE_Conn_Prim:CONN_PRIM_DISC_IND);
8208 BSSAP.receive(tr_BSSMAP_Perform_Location_Response(tr_BSSMAP_IE_LocationEstimate(gad_ell_point_unc_circle)));
8209
8210 /* The LCS was using an active A-interface conn. It should still remain active after this. */
8211 f_mo_l3_transceive();
8212
8213 f_perform_clear(RSL);
8214
8215 f_sleep(2.0);
8216 setverdict(pass);
8217}
8218
8219/* With an active lchan, start BSSMAP Perform Location Request on A interface, starting BSSMAP-LE Perform Location
8220 * Request on Lb interface. Without the SMLC doing a BSSLAP TA Request. */
8221private function f_tc_lcs_loc_req_for_active_ms(charstring id) runs on MSC_ConnHdlr {
8222 f_lcs_loc_req_for_active_ms(false);
8223}
8224testcase TC_lcs_loc_req_for_active_ms() runs on test_CT {
8225 var MSC_ConnHdlr vc_conn;
8226 var TestHdlrParams pars := f_gen_test_hdlr_pars();
8227
8228 f_init(1, true);
8229 f_sleep(1.0);
8230 vc_conn := f_start_handler(refers(f_tc_lcs_loc_req_for_active_ms), pars);
8231 vc_conn.done;
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01008232 f_shutdown_helper();
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02008233}
8234
8235/* With an active lchan, start BSSMAP Perform Location Request on A interface, starting BSSMAP-LE Perform Location
8236 * Request on Lb interface. With the SMLC doing a BSSLAP TA Request. */
8237private function f_tc_lcs_loc_req_for_active_ms_ta_req(charstring id) runs on MSC_ConnHdlr {
8238 f_lcs_loc_req_for_active_ms(true);
8239}
8240testcase TC_lcs_loc_req_for_active_ms_ta_req() runs on test_CT {
8241 var MSC_ConnHdlr vc_conn;
8242 var TestHdlrParams pars := f_gen_test_hdlr_pars();
8243
8244 f_init(1, true);
8245 f_sleep(1.0);
8246 vc_conn := f_start_handler(refers(f_tc_lcs_loc_req_for_active_ms_ta_req), pars);
8247 vc_conn.done;
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01008248 f_shutdown_helper();
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02008249}
8250
8251/* Clear the A-interface conn only, without doing anything on Abis. Useful for LCS, for cases where there is only an A
8252 * conn without an active lchan. */
8253private function f_clear_A_conn() runs on MSC_ConnHdlr
8254{
8255 var BssmapCause cause := 0;
8256 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
8257 BSSAP.receive(tr_BSSMAP_ClearComplete);
8258 BSSAP.send(RAN_Conn_Prim:MSC_CONN_PRIM_DISC_REQ);
8259
8260 timer no_more_bssap := 5.0;
8261 no_more_bssap.start;
8262 alt {
8263 [] no_more_bssap.timeout { break; }
8264 [] BSSAP.receive(tr_BSSAP_BSSMAP) {
8265 setverdict(fail, "Expected no more BSSAP after Clear Complete");
8266 mtc.stop;
8267 }
8268 }
8269 setverdict(pass);
8270}
8271
8272/* Verify that the A-interface connection is still working, and then clear it, without doing anything on Abis. Useful
8273 * for LCS, for cases where there is only an A conn without an active lchan. */
8274private function f_verify_active_A_conn_and_clear() runs on MSC_ConnHdlr
8275{
8276 f_logp(BSCVTY, "f_verify_active_A_conn_and_clear: test A link, then clear");
8277
8278 /* When an lchan is active, we can send some L3 data from the BTS side and verify that it shows up on the other
8279 * side towards the MSC. When there is no lchan, this is not possible. To probe whether the A-interface
8280 * connection is still up, we need something that echos back on the A-interface. Another LCS request! */
8281 BSSAP.send(valueof(ts_BSSMAP_Perform_Location_Request(ts_BSSMAP_Imsi(g_pars.imsi),
8282 ts_CellId_CGI('262'H, '42'H, 23, 42))));
8283 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocReq(BSSMAP_LE_LOC_INFO_CURRENT_GEOGRAPHIC_LOC, ?, ?));
8284
8285 /* Right, the Perform Location Request showed up on Lb, now we can clear the A conn. */
8286 f_clear_A_conn();
8287 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocAbort(BSSMAP_LE_LCS_CAUSE_REQUEST_ABORTED));
8288 BSSAP_LE.receive(BSSAP_LE_Conn_Prim:CONN_PRIM_DISC_IND);
8289}
8290
8291/* With *no* active lchan, start BSSMAP Perform Location Request on A interface, starting BSSMAP-LE Perform Location
8292 * Request on Lb interface. BSC will Page for the subscriber as soon as we (virtual SMLC) request the TA via BSSLAP.
8293 */
8294private function f_tc_lcs_loc_req_for_idle_ms(charstring id) runs on MSC_ConnHdlr {
8295 f_sleep(1.0);
8296
8297 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
8298 f_bssap_le_register_imsi(g_pars.imsi, omit);
8299
8300 /* Register to receive the Paging Command */
8301 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
8302 g_chan_nr := new_chan_nr;
8303 f_rslem_register(0, g_chan_nr);
8304
8305 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
8306 valueof(ts_BSSMAP_Perform_Location_Request(ts_BSSMAP_Imsi(g_pars.imsi),
8307 ts_CellId_CGI('001'H, '01'H, 1, 0)))));
8308 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
8309
8310 var PDU_BSSAP_LE plr;
8311 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocReq(BSSMAP_LE_LOC_INFO_CURRENT_GEOGRAPHIC_LOC, ?, ?)) -> value(plr);
8312
8313 /* SMLC wants to ask the TA from the BSC explicitly in a BSSLAP TA Request message */
8314 BSSAP_LE.send(ts_BSSMAP_LE_BSSLAP(ts_BSSLAP_TA_Req));
8315
8316 /* OsmoBSC needs to Page */
8317 RSL.receive(tr_RSL_PAGING_CMD(tr_MI_IMSI(g_pars.imsi)));
8318 f_logp(BSCVTY, "got Paging Command");
8319
8320 /* MS requests channel. Since the Paging was for LCS, the Paging Response does not trigger a Complete Layer 3 to
8321 * the MSC, and releases the lchan directly. */
8322 f_perform_compl_l3(RSL, ts_PAG_RESP(valueof(ts_MI_IMSI_LV(g_pars.imsi))), do_clear := false, expect_bssmap_l3 := false);
8323 f_expect_lchan_rel(RSL);
8324
8325 /* From the Paging Response, the TA is now known to the BSC, and it responds to the SMLC. */
8326
8327 f_expect_bsslap(tr_BSSLAP_TA_Resp(?, ?));
8328
8329 /* SMLC got the TA from the BSC, now responds with geo information data. */
8330 BSSAP_LE.send(ts_BSSMAP_LE_PerfLocResp(gad_ell_point_unc_circle, omit));
8331 BSSAP_LE.receive(BSSAP_LE_Conn_Prim:CONN_PRIM_DISC_IND);
8332
8333 BSSAP.receive(tr_BSSMAP_Perform_Location_Response(tr_BSSMAP_IE_LocationEstimate(gad_ell_point_unc_circle)));
8334
8335 /* The lchan is gone, the A-interface conn was created for the LCS only.
8336 * Still it is clearly the MSC's job to decide whether to tear down the conn or not. */
8337 f_verify_active_A_conn_and_clear();
8338
8339 f_sleep(2.0);
8340 setverdict(pass);
8341}
8342testcase TC_lcs_loc_req_for_idle_ms() runs on test_CT {
8343 var MSC_ConnHdlr vc_conn;
8344 var TestHdlrParams pars := f_gen_test_hdlr_pars();
8345
8346 f_init(1, true);
8347 f_sleep(1.0);
8348
8349 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
8350 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
8351
8352 vc_conn := f_start_handler(refers(f_tc_lcs_loc_req_for_idle_ms), pars);
8353 vc_conn.done;
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01008354 f_shutdown_helper();
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02008355}
8356
8357/* With no active lchan, start BSSMAP Perform Location Request on A interface, but omit IMSI; expect failure response.
8358 */
8359private function f_tc_lcs_loc_req_no_subscriber(charstring id) runs on MSC_ConnHdlr {
8360 f_sleep(1.0);
8361
8362 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
8363 f_bssap_le_register_imsi(g_pars.imsi, omit);
8364
8365 /* provoke an abort by omitting both IMSI and IMEI */
8366 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
8367 valueof(ts_BSSMAP_Perform_Location_Request(omit,
8368 ts_CellId_CGI('262'H, '42'H, 23, 42)))));
8369 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
8370
8371 /* BSC tells MSC about failure */
8372 BSSAP.receive(tr_BSSMAP_Perform_Location_Response(
8373 locationEstimate := omit, positioningData := omit,
8374 lCS_Cause := tr_BSSMAP_LcsCause(BSSMAP_LCS_CAUSE_DATA_MISSING_IN_REQ)));
8375
8376 /* There is no lchan. Still the MSC's job to decide whether to tear down the conn or not. */
8377 f_verify_active_A_conn_and_clear();
8378
8379 f_sleep(2.0);
8380 setverdict(pass);
8381}
8382testcase TC_lcs_loc_req_no_subscriber() runs on test_CT {
8383 var MSC_ConnHdlr vc_conn;
8384 var TestHdlrParams pars := f_gen_test_hdlr_pars();
8385
8386 f_init(1, true);
8387 f_sleep(1.0);
8388
8389 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
8390 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
8391
8392 vc_conn := f_start_handler(refers(f_tc_lcs_loc_req_no_subscriber), pars);
8393 vc_conn.done;
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01008394 f_shutdown_helper();
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02008395}
8396
8397/* With an active lchan, start a Perform Location Request on the A-interface, but virtual SMLC does not answer with
8398 * BSSMAP-LE Perform Location Response (before or after sending a BSSLAP TA Request) */
8399private function f_lcs_loc_req_for_active_ms_le_timeout(boolean do_ta) runs on MSC_ConnHdlr {
8400 f_sleep(1.0);
8401
8402 f_establish_fully(omit, omit);
8403 f_bssap_le_register_imsi(g_pars.imsi, omit);
8404
8405 BSSAP.send(valueof(ts_BSSMAP_Perform_Location_Request(ts_BSSMAP_Imsi(g_pars.imsi),
8406 ts_CellId_CGI('262'H, '42'H, 23, 42))));
8407
8408 var PDU_BSSAP_LE plr;
8409 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocReq(BSSMAP_LE_LOC_INFO_CURRENT_GEOGRAPHIC_LOC, ?, ?)) -> value(plr);
8410
8411 if (do_ta) {
8412 /* SMLC wants to ask the TA from the BSC explicitly in a BSSLAP TA Request message */
8413 BSSAP_LE.send(ts_BSSMAP_LE_BSSLAP(ts_BSSLAP_TA_Req));
8414 f_expect_bsslap(tr_BSSLAP_TA_Resp(?, ?));
8415 }
8416
8417 /* SMLC fails to respond, BSC runs into timeout */
8418 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocAbort(BSSMAP_LE_LCS_CAUSE_SYSTEM_FAILURE));
8419 BSSAP_LE.receive(BSSAP_LE_Conn_Prim:CONN_PRIM_DISC_IND);
8420
8421 BSSAP.receive(tr_BSSMAP_Perform_Location_Response(
8422 locationEstimate := omit, positioningData := omit,
8423 lCS_Cause := tr_BSSMAP_LcsCause(BSSMAP_LCS_CAUSE_SYSTEM_FAILURE)));
8424
8425 /* There is no lchan. Still the MSC's job to decide whether to tear down the conn or not. */
8426 f_verify_active_A_conn_and_clear();
8427
8428 f_sleep(2.0);
8429 setverdict(pass);
8430}
8431
8432/* With an active lchan, start a Perform Location Request on the A-interface, but virtual SMLC does not answer with
8433 * BSSMAP-LE Perform Location Response, without sending a BSSLAP TA Request. */
8434private function f_tc_lcs_loc_req_for_active_ms_le_timeout(charstring id) runs on MSC_ConnHdlr {
8435 f_lcs_loc_req_for_active_ms_le_timeout(false);
8436}
8437
8438testcase TC_lcs_loc_req_for_active_ms_le_timeout() runs on test_CT {
8439 var MSC_ConnHdlr vc_conn;
8440 var TestHdlrParams pars := f_gen_test_hdlr_pars();
8441
8442 f_init(1, true);
8443 f_sleep(1.0);
8444 vc_conn := f_start_handler(refers(f_tc_lcs_loc_req_for_active_ms_le_timeout), pars);
8445 vc_conn.done;
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01008446 f_shutdown_helper();
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02008447}
8448
8449/* With an active lchan, start a Perform Location Request on the A-interface, but virtual SMLC does not answer with
8450 * BSSMAP-LE Perform Location Response, after sending a BSSLAP TA Request. */
8451private function f_tc_lcs_loc_req_for_active_ms_le_timeout2(charstring id) runs on MSC_ConnHdlr {
8452 f_lcs_loc_req_for_active_ms_le_timeout(true);
8453}
8454
8455testcase TC_lcs_loc_req_for_active_ms_le_timeout2() runs on test_CT {
8456 var MSC_ConnHdlr vc_conn;
8457 var TestHdlrParams pars := f_gen_test_hdlr_pars();
8458
8459 f_init(1, true);
8460 f_sleep(1.0);
8461 vc_conn := f_start_handler(refers(f_tc_lcs_loc_req_for_active_ms_le_timeout2), pars);
8462 vc_conn.done;
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01008463 f_shutdown_helper();
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02008464}
8465
8466/* With *no* active lchan, start a Perform Location Request, expecting that the MS will be Paged. */
8467private function f_tc_lcs_loc_req_for_idle_ms_no_pag_resp(charstring id) runs on MSC_ConnHdlr {
8468 f_sleep(1.0);
8469
8470 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
8471 f_bssap_le_register_imsi(g_pars.imsi, omit);
8472
8473 /* Register to receive the Paging Command */
8474 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
8475 g_chan_nr := new_chan_nr;
8476 f_rslem_register(0, g_chan_nr);
8477
8478 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
8479 valueof(ts_BSSMAP_Perform_Location_Request(ts_BSSMAP_Imsi(g_pars.imsi),
8480 ts_CellId_CGI('001'H, '01'H, 1, 0)))));
8481 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
8482
8483 var PDU_BSSAP_LE plr;
8484 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocReq(BSSMAP_LE_LOC_INFO_CURRENT_GEOGRAPHIC_LOC, ?, ?)) -> value(plr);
8485
8486 /* SMLC wants to ask the TA from the BSC explicitly in a BSSLAP TA Request message */
8487 BSSAP_LE.send(ts_BSSMAP_LE_BSSLAP(ts_BSSLAP_TA_Req));
8488
8489 /* OsmoBSC needs to Page */
8490 var PDU_BSSAP_LE rx_bsslap;
8491 alt {
8492 [] RSL.receive(tr_RSL_PAGING_CMD(tr_MI_IMSI(g_pars.imsi))) {
8493 f_logp(BSCVTY, "got Paging Command");
8494 repeat;
8495 }
8496 [] BSSAP_LE.receive(tr_BSSMAP_LE_ConnInfo(BSSMAP_LE_PROT_BSSLAP, ?)) -> value(rx_bsslap) {
8497 /* MS does not respond to Paging, TA Req runs into timeout. */
8498 f_match_bsslap(rx_bsslap, tr_BSSLAP_Abort(?));
8499 }
8500 }
8501
8502 /* SMLC responds with failure */
8503 BSSAP_LE.send(ts_BSSMAP_LE_PerfLocResp(omit, BSSMAP_LE_LCS_CAUSE_REQUEST_ABORTED));
8504 BSSAP_LE.receive(BSSAP_LE_Conn_Prim:CONN_PRIM_DISC_IND);
8505
8506 /* BSC tells MSC about failure */
8507 BSSAP.receive(tr_BSSMAP_Perform_Location_Response(
8508 locationEstimate := omit, positioningData := omit,
8509 lCS_Cause := tr_BSSMAP_LcsCause(BSSMAP_LCS_CAUSE_REQUEST_ABORTED)));
8510
8511 /* There is no lchan. Still the MSC's job to decide whether to tear down the conn or not. */
8512 f_verify_active_A_conn_and_clear();
8513
8514 f_sleep(2.0);
8515 setverdict(pass);
8516}
8517testcase TC_lcs_loc_req_for_idle_ms_no_pag_resp() runs on test_CT {
8518 var MSC_ConnHdlr vc_conn;
8519 var TestHdlrParams pars := f_gen_test_hdlr_pars();
8520
8521 f_init(1, true);
8522 f_sleep(1.0);
8523
8524 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
8525 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
8526
8527 vc_conn := f_start_handler(refers(f_tc_lcs_loc_req_for_idle_ms_no_pag_resp), pars);
8528 vc_conn.done;
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01008529 f_shutdown_helper();
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02008530}
8531
8532/* During an ongoing Location Request, the MS sends a CM Service Request. Expect the same A-conn to be re-used / taken
8533 * over. */
8534private function f_tc_cm_service_during_lcs_loc_req(charstring id) runs on MSC_ConnHdlr {
8535 f_sleep(1.0);
8536
8537 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
8538 f_bssap_le_register_imsi(g_pars.imsi, omit);
8539
8540 /* Register to receive the Paging Command */
8541 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
8542 g_chan_nr := new_chan_nr;
8543 f_rslem_register(0, g_chan_nr);
8544
8545 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
8546 valueof(ts_BSSMAP_Perform_Location_Request(ts_BSSMAP_Imsi(g_pars.imsi),
8547 ts_CellId_CGI('001'H, '01'H, 1, 0)))));
8548 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
8549
8550 var PDU_BSSAP_LE plr;
8551 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocReq(BSSMAP_LE_LOC_INFO_CURRENT_GEOGRAPHIC_LOC, ?, ?)) -> value(plr);
8552
8553 /* As the A-interface conn was established for LCS, the MS coincidentally decides to issue a CM Service Request
8554 * and establish Layer 3. It should use the existing A-interface conn. */
8555 f_perform_compl_l3(RSL, valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, valueof(ts_MI_IMSI_LV(g_pars.imsi)))),
8556 do_clear := false, expect_bssmap_l3 := true);
8557
8558 /* SMLC wants to ask the TA from the BSC explicitly in a BSSLAP TA Request message */
8559 BSSAP_LE.send(ts_BSSMAP_LE_BSSLAP(ts_BSSLAP_TA_Req));
8560
8561 /* OsmoBSC already has an lchan, no need to Page, just returns the TA */
8562 f_expect_bsslap(tr_BSSLAP_TA_Resp(?, ?));
8563
8564 /* SMLC got the TA from the BSC, now responds with geo information data. */
8565 BSSAP_LE.send(ts_BSSMAP_LE_PerfLocResp(gad_ell_point_unc_circle, omit));
8566 BSSAP_LE.receive(BSSAP_LE_Conn_Prim:CONN_PRIM_DISC_IND);
8567 BSSAP.receive(tr_BSSMAP_Perform_Location_Response(tr_BSSMAP_IE_LocationEstimate(gad_ell_point_unc_circle)));
8568
8569 /* The lchan should still exist, it was from a CM Service Request. */
8570 f_mo_l3_transceive();
8571
8572 f_perform_clear(RSL);
8573
8574 f_sleep(2.0);
8575 setverdict(pass);
8576}
8577testcase TC_cm_service_during_lcs_loc_req() runs on test_CT {
8578 var MSC_ConnHdlr vc_conn;
8579 var TestHdlrParams pars := f_gen_test_hdlr_pars();
8580
8581 f_init(1, true);
8582 f_sleep(1.0);
8583
8584 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
8585 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
8586
8587 vc_conn := f_start_handler(refers(f_tc_cm_service_during_lcs_loc_req), pars);
8588 vc_conn.done;
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01008589 f_shutdown_helper();
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02008590}
8591
8592/* During an ongoing Perform Location Request, do a Handover, an expect a BSSLAP Reset message from the BSC to indicate
8593 * the new lchan after handover. */
8594private function f_tc_ho_during_lcs_loc_req(charstring id) runs on MSC_ConnHdlr {
8595 f_sleep(1.0);
8596
8597 f_establish_fully(omit, omit);
8598 f_bssap_le_register_imsi(g_pars.imsi, omit);
8599
8600 BSSAP.send(valueof(ts_BSSMAP_Perform_Location_Request(ts_BSSMAP_Imsi(g_pars.imsi),
8601 ts_CellId_CGI('262'H, '42'H, 23, 42))));
8602
8603 var PDU_BSSAP_LE plr;
8604 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocReq(BSSMAP_LE_LOC_INFO_CURRENT_GEOGRAPHIC_LOC, ?, ?)) -> value(plr);
8605
8606 /* SMLC ponders the Location Request, in the meantime the BSC decides to handover */
8607 f_bts_0_cfg(BSCVTY, {"neighbor bts 1"});
8608
8609 var HandoverState hs := {
8610 rr_ho_cmpl_seen := false,
8611 handover_done := false,
8612 old_chan_nr := -
8613 };
8614 /* issue hand-over command on VTY */
8615 f_vty_handover(BSCVTY, 0, 0, g_chan_nr, 1);
8616 /* temporarily suspend DChan processing on BTS1 to avoid race with RSLEM_register */
8617 f_rslem_suspend(RSL1_PROC);
8618
8619 /* From the MGW perspective, a handover is is characterized by
8620 * performing one MDCX operation with the MGW. So we expect to see
8621 * one more MDCX during handover. */
8622 g_media.mgcp_conn[0].mdcx_seen_exp := g_media.mgcp_conn[0].crcx_seen_exp + 1;
8623
8624 alt {
8625 [] as_handover(hs);
8626 }
8627
8628 var PDU_BSSAP_LE rx_bsslap;
8629
8630 interleave {
8631 /* Expect the BSC to inform the MSC about the handover */
8632 [] BSSAP.receive(tr_BSSMAP_HandoverPerformed);
8633
8634 /* Expect the BSC to inform the SMLC about the handover */
8635 [] BSSAP_LE.receive(tr_BSSMAP_LE_ConnInfo(BSSMAP_LE_PROT_BSSLAP, ?)) -> value(rx_bsslap) {
8636 f_match_bsslap(rx_bsslap, tr_BSSLAP_Reset(BSSLAP_CAUSE_INTRA_BSS_HO));
8637 }
8638 }
8639
8640 /* SMLC now responds with geo information data. */
8641 BSSAP_LE.send(ts_BSSMAP_LE_PerfLocResp(gad_ell_point_unc_circle, omit));
8642 BSSAP_LE.receive(BSSAP_LE_Conn_Prim:CONN_PRIM_DISC_IND);
8643 BSSAP.receive(tr_BSSMAP_Perform_Location_Response(tr_BSSMAP_IE_LocationEstimate(gad_ell_point_unc_circle)));
8644
8645 /* lchan still active */
8646 f_mo_l3_transceive(RSL1);
8647
8648 /* MSC decides it is done now. */
8649 f_perform_clear(RSL1);
8650
8651 f_sleep(2.0);
8652 setverdict(pass);
8653}
8654testcase TC_ho_during_lcs_loc_req() runs on test_CT {
8655 var MSC_ConnHdlr vc_conn;
8656 var TestHdlrParams pars := f_gen_test_hdlr_pars();
8657
8658 f_init(2, true);
8659 f_sleep(1.0);
8660 vc_conn := f_start_handler(refers(f_tc_ho_during_lcs_loc_req), pars);
8661 vc_conn.done;
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01008662 f_shutdown_helper();
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02008663}
8664
Neels Hofmeyrbf037052020-10-28 22:52:02 +00008665/* Attempt Complete Layer 3 without any MSC available (OS#4832) */
8666private function f_tc_no_msc(charstring id) runs on MSC_ConnHdlr {
8667 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
8668
8669 /* Also disable attach for the single connected MSC */
8670 f_vty_msc_allow_attach(BSCVTY, { false });
8671
8672 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) ));
8673 f_chan_est(g_pars.ra, l3_enc, g_pars.link_id, g_pars.fn);
8674
8675 /* No MSC is found, expecting a proper release on RSL */
8676 interleave {
8677 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_RELEASE)) {
8678 f_logp(BSCVTY, "Got RSL RR Release");
8679 }
8680 [] RSL.receive(tr_RSL_DEACT_SACCH(g_chan_nr)) {
8681 f_logp(BSCVTY, "Got RSL Deact SACCH");
8682 }
8683 [] RSL.receive(tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL)) {
8684 f_logp(BSCVTY, "Got RSL RF Chan Rel, sending Rel Ack");
8685 RSL.send(ts_RSL_RF_CHAN_REL_ACK(g_chan_nr));
8686 }
8687 }
8688 setverdict(pass);
8689}
8690testcase TC_no_msc() runs on test_CT {
8691
8692 f_init(1, true);
8693 f_sleep(1.0);
8694 var MSC_ConnHdlr vc_conn;
8695 var TestHdlrParams pars := f_gen_test_hdlr_pars();
8696
8697 f_ctrs_bsc_init(counternames_bsc_mscpool);
8698
8699 vc_conn := f_start_handler(refers(f_tc_no_msc), pars);
8700 vc_conn.done;
8701
8702 f_ctrs_bsc_add("mscpool:subscr:no_msc");
8703 f_ctrs_bsc_verify();
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01008704 f_shutdown_helper();
Neels Hofmeyrbf037052020-10-28 22:52:02 +00008705}
8706
Harald Welte0ea2d5e2018-04-07 21:40:29 +02008707/* Dyn PDCH todo:
8708 * activate OSMO as TCH/F
8709 * activate OSMO as TCH/H
8710 * does the BSC-located PCU socket get the updated INFO?
8711 * what if no PCU is connected at the time?
8712 * is the info correct on delayed PCU (re)connect?
8713 */
Harald Welte94e0c342018-04-07 11:33:23 +02008714
Neels Hofmeyr87857ec2021-04-25 16:17:47 +00008715private function f_TC_refuse_mode_modif_to_vamos(charstring id) runs on MSC_ConnHdlr {
8716 var PDU_BSSAP ass_cmd := f_gen_ass_req(g_pars.use_osmux);
8717 var template PDU_BSSAP exp_compl := f_gen_exp_compl(g_pars.use_osmux);
8718
8719 /* puzzle together the ASSIGNMENT REQ for given codec[s] */
8720 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
8721 ass_cmd.pdu.bssmap.assignmentRequest.codecList := g_pars.ass_codec_list;
8722 exp_compl.pdu.bssmap.assignmentComplete.speechCodec.codecElements[0] :=
8723 g_pars.ass_codec_list.codecElements[0];
8724 if (isvalue(g_pars.expect_mr_s0_s7)) {
8725 exp_compl.pdu.bssmap.assignmentComplete.speechCodec.codecElements[0].s0_7 :=
8726 g_pars.expect_mr_s0_s7;
8727 }
8728 }
8729 ass_cmd.pdu.bssmap.assignmentRequest.channelType :=
8730 f_BSSMAP_chtype_from_codec(g_pars.ass_codec_list.codecElements[0]);
8731 log("expecting ASS COMPL like this: ", exp_compl);
8732
8733 f_establish_fully(ass_cmd, exp_compl);
8734
Neels Hofmeyr8746b0d2021-06-01 17:25:39 +02008735 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 +00008736
8737 var RSL_Message rsl;
8738
8739 timer T := 5.0;
8740 T.start;
8741 alt {
8742 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr)) -> value rsl {
8743 var PDU_ML3_NW_MS l3 := dec_PDU_ML3_NW_MS(rsl.ies[2].body.l3_info.payload);
8744 log("Rx L3 from net: ", l3);
8745 if (ischosen(l3.msgs.rrm.channelModeModify)) {
8746 setverdict(fail, "Mode Modify to VAMOS succeeded even though BTS does not support VAMOS");
8747 mtc.stop;
8748 }
8749 }
8750 [] RSL.receive(tr_RSL_MODE_MODIFY_REQ(g_chan_nr, ?)) -> value rsl {
8751 setverdict(fail, "Mode Modify to VAMOS succeeded even though BTS does not support VAMOS");
8752 mtc.stop;
8753 }
8754 [] T.timeout {
8755 /* The BTS does not exhibit BTS_FEAT_VAMOS, so no VAMOS related Mode Modify should happen. */
8756 setverdict(pass);
8757 }
8758 }
8759 T.stop;
8760}
8761
8762/* The BSC does *not* indicate BTS_FEAT_VAMOS; make sure that a channel Mode Modify to VAMOS mode is refused by
8763 * osmo-bsc. */
8764testcase TC_refuse_mode_modif_to_vamos() runs on test_CT {
8765 var TestHdlrParams pars := f_gen_test_hdlr_pars();
8766 var MSC_ConnHdlr vc_conn;
8767
8768 f_init(1, true);
8769 f_sleep(1.0);
8770
8771 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
8772 vc_conn := f_start_handler(refers(f_TC_refuse_mode_modif_to_vamos), pars);
8773 vc_conn.done;
8774 f_shutdown_helper();
8775}
8776
8777/* The BSC does *not* indicate BTS_FEAT_VAMOS; make sure that a channel activation to VAMOS mode is refused by osmo-bsc.
8778 */
8779testcase TC_refuse_chan_act_to_vamos() runs on test_CT {
8780 f_init_vty();
8781
8782 f_init(1, false);
8783 f_sleep(1.0);
8784
8785 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 1 sub-slot 0 activate-vamos fr");
8786
8787 var ASP_RSL_Unitdata rx_rsl_ud;
8788 timer T := 5.0;
8789
8790 T.start;
8791 alt {
8792 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(?, IPAC_PROTO_RSL_TRX0)) -> value rx_rsl_ud {
8793 if (rx_rsl_ud.rsl.msg_type == RSL_MT_CHAN_ACTIV) {
8794 T.stop;
8795 setverdict(fail, "CHANnel ACTivate in VAMOS mode succeeded even though BTS does not support VAMOS");
8796 mtc.stop;
8797 }
8798 repeat;
8799 }
8800 [] T.timeout {
8801 /* The BTS does not exhibit BTS_FEAT_VAMOS, so no VAMOS related CHANnel ACTivate should happen. */
8802 setverdict(pass);
8803 }
8804 }
8805}
8806
Neels Hofmeyrd2d9f332021-04-28 22:23:36 +00008807private function f_TC_reassignment_codec(charstring id) runs on MSC_ConnHdlr {
8808 /* First fully set up a speech lchan */
8809 f_TC_assignment_codec(id);
8810
8811 /* Trigger re-assignment to another lchan */
8812 var AssignmentState assignment_st := valueof(ts_AssignmentStateInit);
8813
8814 /* Re-Assignment should tell the MGW endpoint the new lchan's RTP address and port, so expecting to see exactly
8815 * one MDCX on MGCP. */
8816 g_media.mgcp_conn[0].mdcx_seen_exp := g_media.mgcp_conn[0].mdcx_seen_exp + 1;
8817
8818 /* The new lchan will see all-new IPAC_CRCX and IPAC_MDCX messages telling the BTS the same RTP address and port
8819 * as the old lchan used. */
8820 g_media.bts.ipa_crcx_seen := false;
8821 g_media.bts.ipa_mdcx_seen := false;
8822
8823 /* Send different BTS side RTP port number for the new lchan */
8824 g_media.bts.bts.port_nr := 4223;
8825
8826 f_rslem_register(0, valueof(ts_RslChanNr_Bm(2))); /* <-- FIXME: can we somehow infer the timeslot that will be used? */
8827
8828 /* Trigger re-assignment. */
8829 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot " & int2str(g_chan_nr.tn) & " sub-slot 0 assignment");
8830
8831 timer T := 5.0;
8832 T.start;
8833 alt {
8834 [] as_assignment(assignment_st);
8835 [] as_Media();
8836 [] T.timeout {
8837 break;
8838 }
8839 }
8840
8841 if (not assignment_st.assignment_done) {
8842 setverdict(fail, "Assignment did not complete");
8843 mtc.stop;
8844 }
8845
8846 f_check_mgcp_expectations()
8847 setverdict(pass);
8848
8849 f_sleep(2.0);
8850 log("show lchan summary: ", f_vty_transceive_ret(BSCVTY, "show lchan summary"));
8851
8852 /* Instruct BSC to clear channel */
8853 var BssmapCause cause := 0;
8854 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
8855 interleave {
8856 [] MGCP.receive(tr_DLCX) {}
8857 [] MGCP.receive(tr_DLCX) {}
8858 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_RELEASE)) {}
8859 [] RSL.receive(tr_RSL_DEACT_SACCH(g_chan_nr)) {}
8860 [] RSL.receive(tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL)) {
8861 RSL.send(ts_RSL_RF_CHAN_REL_ACK(g_chan_nr));
8862 }
8863 [] BSSAP.receive(tr_BSSMAP_ClearComplete) {
8864 BSSAP.send(RAN_Conn_Prim:MSC_CONN_PRIM_DISC_REQ);
8865 }
8866 }
8867
8868 f_sleep(0.5);
8869}
8870
8871testcase TC_reassignment_fr() runs on test_CT {
8872 var TestHdlrParams pars := f_gen_test_hdlr_pars();
8873 var MSC_ConnHdlr vc_conn;
8874
8875 f_init(1, true);
8876 f_sleep(1.0);
8877
8878 f_ctrs_bsc_and_bts_init();
8879
8880 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
8881 vc_conn := f_start_handler(refers(f_TC_reassignment_codec), pars);
8882 vc_conn.done;
8883
8884 /* from f_establish_fully() */
8885 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
8886 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
8887 /* from re-assignment */
8888 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
8889 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
8890 f_ctrs_bsc_and_bts_verify();
8891 f_shutdown_helper();
8892}
8893
Neels Hofmeyr87857ec2021-04-25 16:17:47 +00008894
Harald Welte28d943e2017-11-25 15:00:50 +01008895control {
Harald Welte898113b2018-01-31 18:32:21 +01008896 /* CTRL interface testing */
Harald Welte4003d112017-12-09 22:35:39 +01008897 execute( TC_ctrl_msc_connection_status() );
Stefan Sperlingb041b3d2018-01-03 17:14:55 +01008898 execute( TC_ctrl_msc0_connection_status() );
Harald Welte96c94412017-12-09 03:12:45 +01008899 execute( TC_ctrl() );
Neels Hofmeyrf246a922020-05-13 02:27:10 +02008900 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_SCCPlite_SERVER) {
Pau Espin Pedrol5a2d7432019-06-07 19:43:45 +02008901 execute( TC_ctrl_location() );
8902 }
Harald Welte898113b2018-01-31 18:32:21 +01008903
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +02008904 execute( TC_si_default() );
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02008905 execute( TC_si2quater_2_earfcns() );
8906 execute( TC_si2quater_3_earfcns() );
8907 execute( TC_si2quater_4_earfcns() );
8908 execute( TC_si2quater_5_earfcns() );
8909 execute( TC_si2quater_6_earfcns() );
Neels Hofmeyrad132f22020-07-08 02:20:16 +02008910 execute( TC_si2quater_12_earfcns() );
8911 execute( TC_si2quater_23_earfcns() );
8912 execute( TC_si2quater_32_earfcns() );
8913 execute( TC_si2quater_33_earfcns() );
8914 execute( TC_si2quater_42_earfcns() );
8915 execute( TC_si2quater_48_earfcns() );
8916 execute( TC_si2quater_49_earfcns() );
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02008917 execute( TC_si_acc_rotate() );
Alexander Couzens4ad3a352020-09-10 22:29:12 +02008918 execute( TC_si_acc_ramp_rotate() );
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +02008919
Harald Welte898113b2018-01-31 18:32:21 +01008920 /* RSL DCHAN Channel ACtivation / Deactivation */
Harald Welteae026692017-12-09 01:03:01 +01008921 execute( TC_chan_act_noreply() );
Harald Welte4003d112017-12-09 22:35:39 +01008922 execute( TC_chan_act_counter() );
Harald Welteae026692017-12-09 01:03:01 +01008923 execute( TC_chan_act_ack_noest() );
Philipp Maier9c60a622020-07-09 15:08:46 +02008924 execute( TC_chan_act_ack_noest_emerg() );
Philipp Maier606f07d2020-08-12 17:21:58 +02008925 execute( TC_chan_rqd_emerg_deny() );
Harald Welteae026692017-12-09 01:03:01 +01008926 execute( TC_chan_act_ack_est_ind_noreply() );
8927 execute( TC_chan_act_ack_est_ind_refused() );
Harald Welte618ef642017-12-14 14:58:20 +01008928 execute( TC_chan_act_nack() );
Harald Welte799c97b2017-12-14 17:50:30 +01008929 execute( TC_chan_exhaustion() );
Vadim Yanitskiy1ff1fdf2018-11-27 01:32:57 +07008930 execute( TC_chan_deact_silence() );
Harald Welte4003d112017-12-09 22:35:39 +01008931 execute( TC_chan_rel_rll_rel_ind() );
8932 execute( TC_chan_rel_conn_fail() );
8933 execute( TC_chan_rel_hard_clear() );
Pau Espin Pedrol841b90d2021-04-15 16:42:52 +02008934 execute( TC_chan_rel_last_eutran_plmn_hard_clear_no_csfb() );
8935 execute( TC_chan_rel_last_eutran_plmn_hard_clear_csfb() );
Harald Welte99787102019-02-04 10:41:36 +01008936 execute( TC_chan_rel_hard_clear_csfb() );
Harald Welted8c36cd2017-12-09 23:05:31 +01008937 execute( TC_chan_rel_hard_rlsd() );
Harald Welte550daf92018-06-11 19:22:13 +02008938 execute( TC_chan_rel_hard_rlsd_ms_dead() );
Harald Welte85804d42017-12-10 14:11:58 +01008939 execute( TC_chan_rel_a_reset() );
Pau Espin Pedrolc675b612020-01-09 19:55:40 +01008940 execute( TC_chan_rel_sccp_tiar_timeout() );
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02008941 execute( TC_chan_rel_rr_cause() );
Harald Welte6f521d82017-12-11 19:52:02 +01008942
Harald Weltecfe2c962017-12-15 12:09:32 +01008943 execute( TC_outbound_connect() );
Harald Welte898113b2018-01-31 18:32:21 +01008944
8945 /* Assignment related */
Harald Welte16a4adf2017-12-14 18:54:01 +01008946 execute( TC_assignment_cic_only() );
Harald Welte235ebf12017-12-15 14:18:16 +01008947 execute( TC_assignment_csd() );
8948 execute( TC_assignment_ctm() );
8949 execute( TC_assignment_sign() );
Pau Espin Pedrol07866632020-09-03 19:10:55 +02008950 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
8951 execute( TC_assignment_aoip_tla_v6() );
8952 }
Harald Welte235ebf12017-12-15 14:18:16 +01008953 execute( TC_assignment_fr_a5_0() );
8954 execute( TC_assignment_fr_a5_1() );
Neels Hofmeyrf246a922020-05-13 02:27:10 +02008955 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
Harald Welte8f67d1d2018-05-25 20:38:42 +02008956 execute( TC_assignment_fr_a5_1_codec_missing() );
8957 }
Harald Welte235ebf12017-12-15 14:18:16 +01008958 execute( TC_assignment_fr_a5_3() );
Neels Hofmeyr0d8ec532021-06-11 00:09:48 +02008959 execute( TC_assignment_fr_a5_4() );
Neels Hofmeyr0faeb7a2021-06-10 23:59:35 +02008960 execute( TC_assignment_fr_a5_4_fail() );
Neels Hofmeyr04d6e6a2021-06-11 00:10:02 +02008961 execute( TC_assignment_fr_a5_not_sup() );
Harald Welte3c86ea02018-05-10 22:28:05 +02008962 execute( TC_ciph_mode_a5_0() );
8963 execute( TC_ciph_mode_a5_1() );
8964 execute( TC_ciph_mode_a5_3() );
Neels Hofmeyr81ad27f2021-06-11 00:09:40 +02008965 execute( TC_ciph_mode_a5_4() );
Harald Welte16a4adf2017-12-14 18:54:01 +01008966
Harald Welte60aa5762018-03-21 19:33:13 +01008967 execute( TC_assignment_codec_fr() );
Neels Hofmeyr559d5d02021-04-16 16:50:49 +02008968 execute( TC_assignment_codec_fr_by_mode_modify() );
Harald Welte60aa5762018-03-21 19:33:13 +01008969 execute( TC_assignment_codec_hr() );
8970 execute( TC_assignment_codec_efr() );
8971 execute( TC_assignment_codec_amr_f() );
8972 execute( TC_assignment_codec_amr_h() );
Philipp Maier8a581d22019-03-26 18:32:48 +01008973
Neels Hofmeyrf246a922020-05-13 02:27:10 +02008974 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
Philipp Maier8a581d22019-03-26 18:32:48 +01008975 execute( TC_assignment_codec_amr_f_S1() );
8976 execute( TC_assignment_codec_amr_h_S1() );
8977 execute( TC_assignment_codec_amr_f_S124() );
8978 execute( TC_assignment_codec_amr_h_S124() );
8979 execute( TC_assignment_codec_amr_f_S0() );
8980 execute( TC_assignment_codec_amr_f_S02() );
8981 execute( TC_assignment_codec_amr_f_S024() );
8982 execute( TC_assignment_codec_amr_f_S0247() );
8983 execute( TC_assignment_codec_amr_h_S0() );
8984 execute( TC_assignment_codec_amr_h_S02() );
8985 execute( TC_assignment_codec_amr_h_S024() );
8986 execute( TC_assignment_codec_amr_h_S0247() );
8987 execute( TC_assignment_codec_amr_f_S01234567() );
8988 execute( TC_assignment_codec_amr_f_S0234567() );
8989 execute( TC_assignment_codec_amr_f_zero() );
8990 execute( TC_assignment_codec_amr_f_unsupp() );
8991 execute( TC_assignment_codec_amr_h_S7() );
Neels Hofmeyr21863562020-11-26 00:34:33 +00008992 execute( TC_assignment_codec_amr_f_start_mode_auto() );
8993 execute( TC_assignment_codec_amr_h_start_mode_auto() );
Neels Hofmeyr3eb94562020-11-26 02:40:26 +00008994 execute( TC_assignment_codec_amr_f_start_mode_4() );
8995 execute( TC_assignment_codec_amr_h_start_mode_4() );
Neels Hofmeyr454d7922020-11-26 02:24:57 +00008996 execute( TC_assignment_codec_amr_startmode_cruft() );
Philipp Maier8a581d22019-03-26 18:32:48 +01008997 }
Harald Welte60aa5762018-03-21 19:33:13 +01008998
Philipp Maierac09bfc2019-01-08 13:41:39 +01008999 execute( TC_assignment_codec_fr_exhausted_req_hr() );
9000 execute( TC_assignment_codec_fr_exhausted_req_fr() );
9001 execute( TC_assignment_codec_fr_exhausted_req_fr_hr() );
9002 execute( TC_assignment_codec_fr_exhausted_req_hr_fr() );
9003 execute( TC_assignment_codec_hr_exhausted_req_fr() );
9004 execute( TC_assignment_codec_hr_exhausted_req_hr() );
9005 execute( TC_assignment_codec_hr_exhausted_req_hr_fr() );
9006 execute( TC_assignment_codec_hr_exhausted_req_fr_hr() );
9007 execute( TC_assignment_codec_req_hr_fr() );
9008 execute( TC_assignment_codec_req_fr_hr() );
9009
Pau Espin Pedrol58cf6822019-05-28 18:11:33 +02009010 if (mp_enable_osmux_test) {
9011 execute( TC_assignment_osmux() );
9012 }
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02009013
Harald Welte898113b2018-01-31 18:32:21 +01009014 /* RLL Establish Indication on inactive DCHAN / SAPI */
Harald Welte5cd20ed2017-12-13 21:03:20 +01009015 execute( TC_rll_est_ind_inact_lchan() );
9016 execute( TC_rll_est_ind_inval_sapi1() );
9017 execute( TC_rll_est_ind_inval_sapi3() );
9018 execute( TC_rll_est_ind_inval_sacch() );
9019
Vadim Yanitskiy61f784a2020-10-01 21:12:19 +07009020 /* DLCI / RSL Link ID conversion for MO/MT messages on SAPI0/SAPI3 */
9021 execute( TC_tch_dlci_link_id_sapi() );
9022
Vadim Yanitskiy6ef5dfa2020-08-28 18:04:41 +07009023 /* SAPI N Reject triggered by RLL establishment failures */
9024 execute( TC_rll_rel_ind_sapi_n_reject() );
9025 execute( TC_rll_err_ind_sapi_n_reject() );
9026 execute( TC_rll_timeout_sapi_n_reject() );
9027
Harald Welte898113b2018-01-31 18:32:21 +01009028 /* Paging related tests */
Harald Welte6f521d82017-12-11 19:52:02 +01009029 execute( TC_paging_imsi_nochan() );
9030 execute( TC_paging_tmsi_nochan() );
9031 execute( TC_paging_tmsi_any() );
9032 execute( TC_paging_tmsi_sdcch() );
9033 execute( TC_paging_tmsi_tch_f() );
9034 execute( TC_paging_tmsi_tch_hf() );
9035 execute( TC_paging_imsi_nochan_cgi() );
9036 execute( TC_paging_imsi_nochan_lac_ci() );
9037 execute( TC_paging_imsi_nochan_ci() );
9038 execute( TC_paging_imsi_nochan_lai() );
9039 execute( TC_paging_imsi_nochan_lac() );
9040 execute( TC_paging_imsi_nochan_all() );
Harald Welte751d3eb2018-01-31 15:51:06 +01009041 execute( TC_paging_imsi_nochan_plmn_lac_rnc() );
9042 execute( TC_paging_imsi_nochan_rnc() );
9043 execute( TC_paging_imsi_nochan_lac_rnc() );
9044 execute( TC_paging_imsi_nochan_lacs() );
9045 execute( TC_paging_imsi_nochan_lacs_empty() );
Stefan Sperling049a86e2018-03-20 15:51:00 +01009046 execute( TC_paging_imsi_nochan_cgi_unknown_cid() );
Harald Welte10985002017-12-12 09:29:15 +01009047 execute( TC_paging_imsi_a_reset() );
Harald Weltee65d40e2017-12-13 00:09:06 +01009048 execute( TC_paging_imsi_load() );
Philipp Maier779a7922018-02-16 11:00:37 +01009049 execute( TC_paging_counter() );
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01009050 execute( TC_paging_resp_unsol() );
Harald Welte4e9b9cc2017-12-14 18:31:02 +01009051
9052 execute( TC_rsl_drop_counter() );
Stefan Sperling830dc9d2018-02-12 21:08:28 +01009053 execute( TC_rsl_unknown_unit_id() );
9054
9055 execute( TC_oml_unknown_unit_id() );
Harald Welte898113b2018-01-31 18:32:21 +01009056
9057 execute( TC_classmark() );
Harald Welteeddf0e92020-06-21 19:42:15 +02009058 execute( TC_common_id() );
Harald Welte898113b2018-01-31 18:32:21 +01009059 execute( TC_unsol_ass_fail() );
Harald Welteea99a002018-01-31 20:46:43 +01009060 execute( TC_unsol_ass_compl() );
Harald Weltefbf9b5e2018-01-31 20:41:23 +01009061 execute( TC_unsol_ho_fail() );
Harald Weltee3bd6582018-01-31 22:51:25 +01009062 execute( TC_err_82_short_msg() );
Harald Weltee9e02e42018-01-31 23:36:25 +01009063 execute( TC_err_84_unknown_msg() );
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01009064
Harald Welte261af4b2018-02-12 21:20:39 +01009065 execute( TC_ho_int() );
Neels Hofmeyr5f144212020-11-03 15:41:58 +00009066 execute( TC_ho_int_radio_link_failure() );
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01009067
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01009068 execute( TC_ho_out_of_this_bsc() );
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02009069 execute( TC_ho_out_fail_no_msc_response() );
9070 execute( TC_ho_out_fail_rr_ho_failure() );
Neels Hofmeyrd8a602c2019-07-09 19:46:01 +02009071 execute( TC_ho_out_fail_no_result_after_ho_cmd() );
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01009072
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01009073 execute( TC_ho_into_this_bsc() );
Pau Espin Pedrol07866632020-09-03 19:10:55 +02009074 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
9075 execute( TC_ho_into_this_bsc_tla_v6() );
9076 }
Pau Espin Pedrolc08d5522021-04-16 15:40:38 +02009077 execute( TC_srvcc_eutran_to_geran() );
Pau Espin Pedrol35801c32021-04-19 13:03:20 +02009078 execute( TC_srvcc_eutran_to_geran_ho_out() );
Pau Espin Pedrol9ae36d52021-06-15 17:29:43 +02009079 execute( TC_srvcc_eutran_to_geran_forbid_fast_return() );
9080 execute( TC_srvcc_eutran_to_geran_ho_out_forbid_fast_return() );
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01009081 execute( TC_ho_in_fail_msc_clears() );
9082 execute( TC_ho_in_fail_msc_clears_after_ho_detect() );
9083 execute( TC_ho_in_fail_no_detect() );
9084 execute( TC_ho_in_fail_no_detect2() );
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01009085
Neels Hofmeyr91401012019-07-11 00:42:35 +02009086 execute( TC_ho_neighbor_config_1() );
9087 execute( TC_ho_neighbor_config_2() );
9088 execute( TC_ho_neighbor_config_3() );
9089 execute( TC_ho_neighbor_config_4() );
9090 execute( TC_ho_neighbor_config_5() );
9091 execute( TC_ho_neighbor_config_6() );
9092 execute( TC_ho_neighbor_config_7() );
9093
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01009094 execute( TC_bssap_rlsd_does_not_cause_bssmap_reset() );
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01009095 execute( TC_bssmap_clear_does_not_cause_bssmap_reset() );
Neels Hofmeyrfd445c32018-03-09 15:39:31 +01009096 execute( TC_ms_rel_ind_does_not_cause_bssmap_reset() );
Harald Welte94e0c342018-04-07 11:33:23 +02009097
9098 execute( TC_dyn_pdch_ipa_act_deact() );
9099 execute( TC_dyn_pdch_ipa_act_nack() );
9100 execute( TC_dyn_pdch_osmo_act_deact() );
9101 execute( TC_dyn_pdch_osmo_act_nack() );
Harald Welte99f3ca02018-06-14 13:40:29 +02009102
Stefan Sperling0796a822018-10-05 13:01:39 +02009103 execute( TC_chopped_ipa_ping() );
Stefan Sperlingaa1e60f2018-10-15 16:34:07 +02009104 execute( TC_chopped_ipa_payload() );
Stefan Sperling0796a822018-10-05 13:01:39 +02009105
Pau Espin Pedrol8f773632019-11-05 11:46:53 +01009106 /* Power control related */
9107 execute( TC_assignment_verify_ms_power_params_ie() );
Neels Hofmeyr4f118412020-06-04 15:25:10 +02009108
9109 /* MSC pooling */
9110 /* FIXME: in SCCPlite, indicating how many MSCs should be connected does currently not work. Since
9111 * RESET->RESET-ACK is unconditionally negotiated for all configured MSCs, they always all appear as connected
9112 * to osmo-bsc. The MSC pooling tests however require disconnecting selected MSCs, and hence don't work out as
9113 * intended on SCCPlite. So for now, run these only for SCCP/M3UA. */
9114 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
9115 execute( TC_mscpool_L3Compl_on_1_msc() );
9116 execute( TC_mscpool_L3Complete_by_imsi_round_robin() );
9117 execute( TC_mscpool_LU_by_tmsi_null_nri_0_round_robin() );
9118 execute( TC_mscpool_LU_by_tmsi_null_nri_1_round_robin() );
9119 execute( TC_mscpool_L3Complete_by_tmsi_unassigned_nri_round_robin() );
9120 execute( TC_mscpool_L3Complete_by_tmsi_valid_nri_msc_not_connected_round_robin() );
9121 execute( TC_mscpool_L3Complete_by_tmsi_valid_nri_1() );
9122 execute( TC_mscpool_L3Complete_by_tmsi_valid_nri_2() );
9123 execute( TC_mscpool_LU_by_tmsi_from_other_PLMN() );
9124 execute( TC_mscpool_paging_and_response_imsi() );
9125 execute( TC_mscpool_paging_and_response_tmsi() );
9126 execute( TC_mscpool_no_allow_attach_round_robin() );
9127 execute( TC_mscpool_no_allow_attach_valid_nri() );
9128 }
9129
Harald Welte99f3ca02018-06-14 13:40:29 +02009130 /* at bottom as they might crash OsmoBSC before OS#3182 is fixed */
9131 execute( TC_early_conn_fail() );
9132 execute( TC_late_conn_fail() );
9133
Philipp Maier783681c2020-07-16 16:47:06 +02009134 /* Emergency call handling (deny / allow) */
9135 execute( TC_assignment_emerg_setup_allow() );
9136 execute( TC_assignment_emerg_setup_deny_msc() );
9137 execute( TC_assignment_emerg_setup_deny_bts() );
Philipp Maier82812002020-08-13 18:48:27 +02009138 execute( TC_emerg_premption() );
9139
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07009140 /* Frequency hopping parameters handling */
9141 execute( TC_fh_params_chan_activ() );
9142 execute( TC_fh_params_imm_ass() );
Vadim Yanitskiyaeb54a22020-09-01 06:25:25 +07009143 execute( TC_fh_params_assignment_cmd() );
Vadim Yanitskiy8f5430d2020-09-02 18:51:38 +07009144 execute( TC_fh_params_handover_cmd() );
Vadim Yanitskiyca974032020-09-01 07:20:39 +07009145 execute( TC_fh_params_si4_cbch() );
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02009146
9147 if (mp_enable_lcs_tests) {
9148 execute( TC_lcs_loc_req_for_active_ms() );
9149 execute( TC_lcs_loc_req_for_active_ms_ta_req() );
9150 execute( TC_lcs_loc_req_for_idle_ms() );
9151 execute( TC_lcs_loc_req_no_subscriber() );
9152 execute( TC_lcs_loc_req_for_active_ms_le_timeout() );
9153 execute( TC_lcs_loc_req_for_active_ms_le_timeout2() );
9154 execute( TC_lcs_loc_req_for_idle_ms_no_pag_resp() );
9155 execute( TC_cm_service_during_lcs_loc_req() );
9156 execute( TC_ho_during_lcs_loc_req() );
9157 }
Neels Hofmeyrbf037052020-10-28 22:52:02 +00009158
9159 execute( TC_no_msc() );
Neels Hofmeyr87857ec2021-04-25 16:17:47 +00009160
9161 execute( TC_refuse_chan_act_to_vamos() );
9162 execute( TC_refuse_mode_modif_to_vamos() );
Neels Hofmeyrd2d9f332021-04-28 22:23:36 +00009163
9164 execute( TC_reassignment_fr() );
Harald Welte28d943e2017-11-25 15:00:50 +01009165}
9166
9167}