blob: 16afbf87490bdf51f0f145f7843973617af4fe13 [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 Hofmeyr4f118412020-06-04 15:25:10 +020023import from Misc_Helpers all;
Harald Welte4003d112017-12-09 22:35:39 +010024import from General_Types all;
Harald Welte28d943e2017-11-25 15:00:50 +010025import from Osmocom_Types all;
Harald Welteae026692017-12-09 01:03:01 +010026import from GSM_Types all;
Harald Welte28d943e2017-11-25 15:00:50 +010027import from IPL4asp_Types all;
28
Harald Welte6f521d82017-12-11 19:52:02 +010029import from BSSAP_Types all;
Harald Welte6811d102019-04-14 22:23:14 +020030import from RAN_Adapter all;
Harald Welte47cd0e32020-08-21 12:39:11 +020031import from BSSAP_LE_Adapter all;
32import from BSSAP_LE_CodecPort all;
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +020033import from BSSAP_LE_Types all;
34import from BSSLAP_Types all;
Harald Welteae026692017-12-09 01:03:01 +010035import from BSSAP_CodecPort all;
36import from BSSMAP_Templates all;
Harald Welte28d943e2017-11-25 15:00:50 +010037import from IPA_Emulation all;
Stefan Sperling830dc9d2018-02-12 21:08:28 +010038import from IPA_CodecPort all;
Harald Welteae026692017-12-09 01:03:01 +010039import from IPA_Types all;
Stefan Sperling0796a822018-10-05 13:01:39 +020040import from IPA_Testing all;
Harald Welteae026692017-12-09 01:03:01 +010041import from RSL_Types all;
Harald Welte624f9632017-12-16 19:26:04 +010042import from RSL_Emulation all;
Daniel Willmann191e0d92018-01-17 12:44:35 +010043import from MGCP_Emulation all;
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +010044import from MGCP_Templates all;
45import from MGCP_Types all;
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +020046import from MGCP_CodecPort all;
Harald Welte28d943e2017-11-25 15:00:50 +010047
Harald Welte96c94412017-12-09 03:12:45 +010048import from Osmocom_CTRL_Functions all;
Harald Weltea5d2ab22017-12-09 14:21:42 +010049import from Osmocom_CTRL_Types all;
Harald Welteffe55fc2018-01-17 22:39:54 +010050import from Osmocom_CTRL_Adapter all;
Harald Welte96c94412017-12-09 03:12:45 +010051
Daniel Willmannebdecc02020-08-12 15:30:17 +020052import from StatsD_Types all;
53import from StatsD_CodecPort all;
54import from StatsD_CodecPort_CtrlFunct all;
55import from StatsD_Checker all;
56
Harald Weltebc03c762018-02-12 18:09:38 +010057import from Osmocom_VTY_Functions all;
58import from TELNETasp_PortType all;
59
Harald Welte6f521d82017-12-11 19:52:02 +010060import from MobileL3_CommonIE_Types all;
Harald Weltee3bd6582018-01-31 22:51:25 +010061import from MobileL3_Types all;
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +010062import from MobileL3_RRM_Types all;
Harald Welte6f521d82017-12-11 19:52:02 +010063import from L3_Templates all;
64import from GSM_RR_Types all;
65
Stefan Sperlingc307e682018-06-14 15:15:46 +020066import from SCCP_Templates all;
Neels Hofmeyr4ff93282018-03-12 04:25:35 +010067import from BSSMAP_Templates all;
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +020068import from BSSMAP_LE_Templates all;
Neels Hofmeyr4ff93282018-03-12 04:25:35 +010069
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +010070import from SCCPasp_Types all;
71
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +020072import from GSM_SystemInformation all;
73import from GSM_RestOctets all;
Neels Hofmeyrad132f22020-07-08 02:20:16 +020074import from TCCConversion_Functions all;
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +020075
Harald Welte5d1a2202017-12-13 19:51:29 +010076const integer NUM_BTS := 3;
Neels Hofmeyrf246a922020-05-13 02:27:10 +020077const integer NUM_MSC := 3;
Harald Welteae026692017-12-09 01:03:01 +010078const float T3101_MAX := 12.0;
Harald Welte28d943e2017-11-25 15:00:50 +010079
Harald Welte799c97b2017-12-14 17:50:30 +010080/* make sure to sync this with the osmo-bts.cfg you're using */
Philipp Maiercb6cc482018-03-26 13:08:00 +020081const integer NUM_TCHH_PER_BTS := 2;
82const integer NUM_TCHF_PER_BTS := 4;
Neels Hofmeyr74083c22020-07-29 00:43:01 +020083const integer NUM_SDCCH_PER_BTS := 3;
Harald Welte799c97b2017-12-14 17:50:30 +010084
Harald Welte4003d112017-12-09 22:35:39 +010085
Harald Welte21b46bd2017-12-17 19:46:32 +010086/* per-BTS state which we keep */
Harald Welte96c94412017-12-09 03:12:45 +010087type record BTS_State {
Harald Welte21b46bd2017-12-17 19:46:32 +010088 /* component reference to the IPA_Client component used for RSL */
Harald Weltea5d2ab22017-12-09 14:21:42 +010089 IPA_Client rsl
Harald Welte96c94412017-12-09 03:12:45 +010090}
91
Neels Hofmeyr22c3f792020-06-17 02:49:28 +020092/* Default list of counters for an 'msc' entity. */
93const CounterNameVals counternames_msc_mscpool := {
94 { "mscpool:subscr:new", 0 },
95 { "mscpool:subscr:known", 0 },
96 { "mscpool:subscr:reattach", 0 },
97 { "mscpool:subscr:attach_lost", 0 },
98 { "mscpool:subscr:paged", 0 }
99};
100
Neels Hofmeyrbf037052020-10-28 22:52:02 +0000101/* List of global mscpool counters, not related to a specific 'msc' entity. */
102const CounterNameVals counternames_bsc_mscpool := {
103 { "mscpool:subscr:no_msc", 0 }
104};
105
Neels Hofmeyr12941bd2020-08-29 03:21:26 +0000106/* Default list of counters for 'bsc' and 'bts' entities. */
107const CounterNameVals counternames_bsc_bts_handover := {
108 { "assignment:attempted", 0 },
109 { "assignment:completed", 0 },
110 { "assignment:stopped", 0 },
111 { "assignment:no_channel", 0 },
112 { "assignment:timeout", 0 },
113 { "assignment:failed", 0 },
114 { "assignment:error", 0 },
115
116 { "handover:attempted", 0 },
117 { "handover:completed", 0 },
118 { "handover:stopped", 0 },
119 { "handover:no_channel", 0 },
120 { "handover:timeout", 0 },
121 { "handover:failed", 0 },
122 { "handover:error", 0 },
123
124 { "intra_cell_ho:attempted", 0 },
125 { "intra_cell_ho:completed", 0 },
126 { "intra_cell_ho:stopped", 0 },
127 { "intra_cell_ho:no_channel", 0 },
128 { "intra_cell_ho:timeout", 0 },
129 { "intra_cell_ho:failed", 0 },
130 { "intra_cell_ho:error", 0 },
131
132 { "intra_bsc_ho:attempted", 0 },
133 { "intra_bsc_ho:completed", 0 },
134 { "intra_bsc_ho:stopped", 0 },
135 { "intra_bsc_ho:no_channel", 0 },
136 { "intra_bsc_ho:timeout", 0 },
137 { "intra_bsc_ho:failed", 0 },
138 { "intra_bsc_ho:error", 0 },
139
140 { "interbsc_ho_out:attempted", 0 },
141 { "interbsc_ho_out:completed", 0 },
142 { "interbsc_ho_out:stopped", 0 },
143 { "interbsc_ho_out:timeout", 0 },
144 { "interbsc_ho_out:failed", 0 },
145 { "interbsc_ho_out:error", 0 },
146
147 { "interbsc_ho_in:attempted", 0 },
148 { "interbsc_ho_in:completed", 0 },
149 { "interbsc_ho_in:stopped", 0 },
150 { "interbsc_ho_in:no_channel", 0 },
151 { "interbsc_ho_in:timeout", 0 },
152 { "interbsc_ho_in:failed", 0 },
153 { "interbsc_ho_in:error", 0 }
154};
155
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +0200156/* Set of all System Information received during one RSL port's startup.
157 * Note that some System Information may be sent on RSL, but lacking actual SI data, to indicate that the BTS should not
158 * broadcast that SI type. That will be reflected as 'omit' here.
159 */
160type record SystemInformationConfig {
161 SystemInformationType1 si1 optional,
162 SystemInformationType2 si2 optional,
163 SystemInformationType2bis si2bis optional,
164 SystemInformationType2ter si2ter optional,
Neels Hofmeyrad132f22020-07-08 02:20:16 +0200165 SI2quaterRestOctetsList si2quater optional,
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +0200166 SystemInformationType3 si3 optional,
167 SystemInformationType4 si4 optional,
Pau Espin Pedrol28652d82021-02-09 20:20:17 +0100168 SystemInformationType13 si13 optional,
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +0200169 SystemInformationType5 si5 optional,
170 SystemInformationType5bis si5bis optional,
171 SystemInformationType5ter si5ter optional,
172 SystemInformationType6 si6 optional
173};
174
175const SystemInformationConfig SystemInformationConfig_omit := {
176 si1 := omit,
177 si2 := omit,
178 si2bis := omit,
179 si2ter := omit,
180 si2quater := omit,
181 si3 := omit,
182 si4 := omit,
183 si13 := omit,
184 si5 := omit,
185 si5bis := omit,
186 si5ter := omit,
187 si6 := omit
188};
189
190/* tr_EUTRAN_CellDesc with defaults used in BSC_Tests.ttcn */
191template EUTRAN_CellDesc tr_EUTRAN_CellDesc_default(template (present) uint16_t e_arfcn := ?,
192 template uint3_t meas_bw := 3)
193:= tr_EUTRAN_CellDesc(e_arfcn := e_arfcn,
194 meas_bw_presence := '1'B,
195 meas_bw := meas_bw);
196
197/* tr_EUTRAN_NeighbourCells with defaults used in BSC_Tests.ttcn */
Harald Welte65e419a2020-08-21 12:38:33 +0200198template EUTRAN_NeighbourCells tr_EUTRAN_NeighbourCells_default(template (present) EUTRAN_CellDescs cell_desc_list := { tr_EUTRAN_CellDesc_default },
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +0200199 template uint3_t prio := 3,
200 template (present) uint5_t thresh_high := 20,
201 template uint5_t thresh_low := 10,
202 template uint5_t qrxlevmin := 22)
203:= tr_EUTRAN_NeighbourCells(
204 cell_desc_list := cell_desc_list,
205 prio_presence := '1'B,
206 prio := prio,
207 thresh_high := thresh_high,
208 thresh_low_presence := '1'B,
209 thresh_low := thresh_low,
210 qrxlevmin_presence := '1'B,
211 qrxlevmin := qrxlevmin);
212
213template SystemInformationConfig SystemInformationConfig_default := {
214 si1 := {
215 cell_chan_desc := '8FB38000000000000000000000000000'O,
216 rach_control := {
217 max_retrans := RACH_MAX_RETRANS_7,
218 tx_integer := '1001'B,
219 cell_barr_access := false,
220 re_not_allowed := true,
221 acc := '0000010000000000'B
222 },
223 rest_octets := ?
224 },
225 si2 := {
226 bcch_freq_list := '00000000000000000000000000000000'O,
227 ncc_permitted := '11111111'B,
228 rach_control := {
229 max_retrans := RACH_MAX_RETRANS_7,
230 tx_integer := '1001'B,
231 cell_barr_access := false,
232 re_not_allowed := true,
233 acc := '0000010000000000'B
234 }
235 },
236 si2bis := omit,
237 si2ter := {
238 extd_bcch_freq_list := '8E320000000000000000000000000800'O,
239 rest_octets := ?
240 },
241 si2quater := {
242 tr_SI2quaterRestOctets_EUTRAN( repeated_neigh_cells := { tr_EUTRAN_NeighbourCells_default } )
243 },
244 si3 := {
245 cell_id := 0,
246 lai := {
247 mcc_mnc := '001F01'H,
248 lac := 1
249 },
250 ctrl_chan_desc := {
251 msc_r99 := true,
252 att := true,
253 bs_ag_blks_res := 1,
254 ccch_conf := CCHAN_DESC_1CCCH_COMBINED,
255 si22ind := false,
256 cbq3 := CBQ3_IU_MODE_NOT_SUPPORTED,
257 spare := '00'B,
258 bs_pa_mfrms := 3,
259 t3212 := 30
260 },
261 cell_options := {
262 dn_ind := false,
263 pwrc := false,
264 dtx := MS_SHALL_USE_UL_DTX,
265 radio_link_tout_div4 := 7
266 },
267 cell_sel_par := {
268 cell_resel_hyst_2dB := 2,
269 ms_txpwr_max_cch := 7,
270 acs := '0'B,
271 neci := true,
272 rxlev_access_min := 0
273 },
274 rach_control := {
275 max_retrans := RACH_MAX_RETRANS_7,
276 tx_integer := '1001'B,
277 cell_barr_access := false,
278 re_not_allowed := true,
279 acc := '0000010000000000'B
280 },
281 rest_octets := {
282 sel_params := {
283 presence := '0'B,
284 params := omit
285 },
286 pwr_offset := {
287 presence := '0'B,
288 offset := omit
289 },
290 si_2ter_ind := '1'B,
291 early_cm_ind := '0'B,
292 sched_where := {
293 presence := '0'B,
294 where := omit
295 },
296 gprs_ind := {
297 presence := '1'B,
298 ind := {
299 ra_colour := 0,
300 si13_pos := '0'B
301 }
302 },
303 umts_early_cm_ind := '1'B,
304 si2_quater_ind := {
305 presence := '1'B,
306 ind := '0'B
307 },
308 iu_mode_ind := omit,
309 si21_ind := {
310 presence := '0'B,
311 pos := omit
312 }
313 }
314 },
315 si4 := {
316 lai := {
317 mcc_mnc := '001F01'H,
318 lac := 1
319 },
320 cell_sel_par := {
321 cell_resel_hyst_2dB := 2,
322 ms_txpwr_max_cch := 7,
323 acs := '0'B,
324 neci := true,
325 rxlev_access_min := 0
326 },
327 rach_control := {
328 max_retrans := RACH_MAX_RETRANS_7,
329 tx_integer := '1001'B,
330 cell_barr_access := false,
331 re_not_allowed := true,
332 acc := '0000010000000000'B
333 },
Neels Hofmeyr74083c22020-07-29 00:43:01 +0200334 cbch_chan_desc := {
335 iei := '64'O,
336 v := {
337 chan_nr := {
338 u := {
339 sdcch4 := {
340 tag := '001'B,
341 sub_chan := 2
342 }
343 },
344 tn := 0
345 },
346 tsc := 2,
347 h := false,
348 arfcn := 871,
349 maio_hsn := omit
350 }
351 },
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +0200352 cbch_mobile_alloc := omit,
353 rest_octets := {
354 sel_params := {
355 presence := '0'B,
356 params := omit
357 },
358 pwr_offset := {
359 presence := '0'B,
360 offset := omit
361 },
362 gprs_ind := {
363 presence := '1'B,
364 ind := {
365 ra_colour := 0,
366 si13_pos := '0'B
367 }
368 },
369 s_presence := '0'B,
370 s := omit
371 }
372 },
Pau Espin Pedrol28652d82021-02-09 20:20:17 +0100373 si13 := {
374 rest_octets := {
375 presence := '1'B,
376 bcch_change_mark := ?,
377 si_change_field := '0000'B,
378 presence2 := '0'B,
379 si13_change_mark := omit,
380 gprs_ma := omit,
381 zero := '0'B, /* PBCCH not present in cell */
382 rac := 0,
383 spgc_ccch_sup := '0'B,
384 priority_access_thr := '110'B,
385 network_control_order := '00'B,
386 gprs_cell_opts := {
387 nmo := '01'B,
388 t3168 := '011'B,
389 t3192 := '010'B,
390 drx_timer_max := '011'B,
391 access_burst_type := '0'B,
392 control_ack_type := '1'B,
393 bs_cv_max := 15,
394 pan_presence := '1'B,
395 pan_dec := 1,
396 pan_inc := 1,
397 pan_max := '111'B,
398 ext_info_presence := ?,
399 ext_info_length := *,
400 ext_info := *
401 },
402 gprs_pwr_ctrl_params := {
403 alpha := 0,
404 t_avg_w := '10000'B,
405 t_avg_t := '10000'B,
406 pc_meas_chan := '0'B,
407 n_avg_i := '1000'B
408 }
409 }
410 },
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +0200411 si5 := {
412 bcch_freq_list := '10000000000000000000000000000000'O
413 },
414 si5bis := omit,
415 si5ter := {
416 extd_bcch_freq_list := '9E050020000000000000000000000000'O
417 },
418 si6 := {
419 cell_id := 0,
420 lai := {
421 mcc_mnc := '001F01'H,
422 lac := 1
423 },
424 cell_options := {
425 dtx_ext := '1'B,
426 pwrc := false,
427 dtx := '01'B,
428 radio_link_timeout := '0111'B
429 },
430 ncc_permitted := '11111111'B,
431 rest_octets := ?
432 }
433 };
434
435
436/* List of all the System Information received on all RSL ports */
437type record of SystemInformationConfig SystemInformationConfig_list;
438
439function f_sysinfo_dec_raw(inout SystemInformationConfig si, RSL_Message rsl)
440{
441 var RSL_IE_Body sysinfo_type_ie;
442 var RSL_IE_SysinfoType si_type;
443 var octetstring data;
444
445 if (f_rsl_find_ie(rsl, RSL_IE_SYSINFO_TYPE, sysinfo_type_ie) == false) {
446 setverdict(fail, "Cannot find RSL_IE_SYSINFO_TYPE");
447 mtc.stop;
448 }
449 si_type := sysinfo_type_ie.sysinfo_type;
450
451 if (rsl.msg_type == RSL_MT_BCCH_INFO) {
452 var RSL_IE_Body bcch_ie;
453 if (f_rsl_find_ie(rsl, RSL_IE_FULL_BCCH_INFO, bcch_ie)) {
454 data := bcch_ie.other.payload;
455 }
456 } else if (rsl.msg_type == RSL_MT_SACCH_FILL) {
457 var RSL_IE_Body l3_ie;
458 if (f_rsl_find_ie(rsl, RSL_IE_L3_INFO, l3_ie)) {
459 data := l3_ie.l3_info.payload;
460 }
461 } else {
462 setverdict(fail, "Don't understand this System Information message");
463 mtc.stop;
464 }
465
466 var boolean handled := false;
467
468 if (rsl.msg_type == RSL_MT_BCCH_INFO) {
469 handled := true;
470
471 if (si_type == RSL_SYSTEM_INFO_1) {
472 if (not isbound(data)) {
473 si.si1 := omit;
474 } else {
475 si.si1 := dec_SystemInformation(data).payload.si1;
476 }
477 } else if (si_type == RSL_SYSTEM_INFO_2) {
478 if (not isbound(data)) {
479 si.si2 := omit;
480 } else {
481 si.si2 := dec_SystemInformation(data).payload.si2;
482 }
483 } else if (si_type == RSL_SYSTEM_INFO_2bis) {
484 if (not isbound(data)) {
485 si.si2bis := omit;
486 } else {
487 si.si2bis := dec_SystemInformation(data).payload.si2bis;
488 }
489 } else if (si_type == RSL_SYSTEM_INFO_2ter) {
490 if (not isbound(data)) {
491 si.si2ter := omit;
492 } else {
493 si.si2ter := dec_SystemInformation(data).payload.si2ter;
494 }
495 } else if (si_type == RSL_SYSTEM_INFO_2quater) {
496 if (not isbound(data)) {
497 si.si2quater := {};
498 } else {
499 var SystemInformationType2quater decoded := dec_SystemInformation(data).payload.si2quater;
500 /* this is a *record* of SI2quaterRestOctets! (multiplexed) */
501 si.si2quater[decoded.rest_octets.si2quater_index] := decoded.rest_octets;
502 }
503 } else if (si_type == RSL_SYSTEM_INFO_3) {
504 if (not isbound(data)) {
505 si.si3 := omit;
506 } else {
507 si.si3 := dec_SystemInformation(data).payload.si3;
508 }
509 } else if (si_type == RSL_SYSTEM_INFO_4) {
510 if (not isbound(data)) {
511 si.si4 := omit;
512 } else {
513 si.si4 := dec_SystemInformation(data).payload.si4;
514 }
515 } else if (si_type == RSL_SYSTEM_INFO_13) {
516 if (not isbound(data)) {
517 si.si13 := omit;
518 } else {
Pau Espin Pedrol28652d82021-02-09 20:20:17 +0100519 si.si13 := dec_SystemInformation(data).payload.si13;
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +0200520 }
521 } else {
522 handled := false;
523 }
524 } else if (rsl.msg_type == RSL_MT_SACCH_FILL) {
525 handled := true;
526
527 if (si_type == RSL_SYSTEM_INFO_5) {
528 if (not isbound(data)) {
529 si.si5 := omit;
530 } else {
531 si.si5 := dec_SystemInformation(data).payload.si5;
532 }
533 } else if (si_type == RSL_SYSTEM_INFO_5bis) {
534 if (not isbound(data)) {
535 si.si5bis := omit;
536 } else {
537 si.si5bis := dec_SystemInformation(data).payload.si5bis;
538 }
539 } else if (si_type == RSL_SYSTEM_INFO_5ter) {
540 if (not isbound(data)) {
541 si.si5ter := omit;
542 } else {
543 si.si5ter := dec_SystemInformation(data).payload.si5ter;
544 }
545 } else if (si_type == RSL_SYSTEM_INFO_6) {
546 if (not isbound(data)) {
547 si.si6 := omit;
548 } else {
549 si.si6 := dec_SystemInformation(data).payload.si6;
550 }
551 } else {
552 handled := false;
553 }
554 }
555
556 if (not handled) {
557 setverdict(fail, "Unexpected SI type in ", rsl.msg_type, " message: ", si_type);
558 }
559}
560
Harald Weltea4ca4462018-02-09 00:17:14 +0100561type component test_CT extends CTRL_Adapter_CT {
Harald Welte21b46bd2017-12-17 19:46:32 +0100562 /* Array of per-BTS state */
Harald Welte96c94412017-12-09 03:12:45 +0100563 var BTS_State bts[NUM_BTS];
Harald Welte89ab1912018-02-23 18:56:29 +0100564 /* RSL common Channel Port (for RSL_Emulation) */
565 port RSL_CCHAN_PT RSL_CCHAN[NUM_BTS];
Harald Welte21b46bd2017-12-17 19:46:32 +0100566 /* array of per-BTS RSL test ports */
Harald Welteae026692017-12-09 01:03:01 +0100567 port IPA_RSL_PT IPA_RSL[NUM_BTS];
Stefan Sperling830dc9d2018-02-12 21:08:28 +0100568 port IPA_CODEC_PT IPA; /* Required for compilation of TC_rsl_unknown_unit_id() */
Pau Espin Pedrol5a2d7432019-06-07 19:43:45 +0200569 /* CTRL muxed over IPA in SCCPlite conn BSC<->MSC (or BSC-NAT) */
570 port IPA_CTRL_PT SCCPLITE_IPA_CTRL;
Harald Weltea5d2ab22017-12-09 14:21:42 +0100571
Daniel Willmann191e0d92018-01-17 12:44:35 +0100572 var MGCP_Emulation_CT vc_MGCP;
Harald Weltebc03c762018-02-12 18:09:38 +0100573 port TELNETasp_PT BSCVTY;
Daniel Willmann191e0d92018-01-17 12:44:35 +0100574
Daniel Willmannebdecc02020-08-12 15:30:17 +0200575 /* StatsD */
576 var StatsD_Checker_CT vc_STATSD;
577
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200578 var RAN_Adapter g_bssap[NUM_MSC];
Harald Welte47cd0e32020-08-21 12:39:11 +0200579 var BSSAP_LE_Adapter g_bssap_le;
Harald Weltea4ca4462018-02-09 00:17:14 +0100580 /* for old legacy-tests only */
581 port BSSAP_CODEC_PT BSSAP;
Harald Welte47cd0e32020-08-21 12:39:11 +0200582 port BSSAP_LE_CODEC_PT BSSAP_LE;
Harald Weltea4ca4462018-02-09 00:17:14 +0100583
Harald Welte21b46bd2017-12-17 19:46:32 +0100584 /* are we initialized yet */
Harald Welte28d943e2017-11-25 15:00:50 +0100585 var boolean g_initialized := false;
Harald Welte21b46bd2017-12-17 19:46:32 +0100586
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200587 /* Osmux is enabled through VTY */
588 var boolean g_osmux_enabled := false;
589
Pau Espin Pedrolc675b612020-01-09 19:55:40 +0100590 /*Configure T(tias) over VTY, seconds */
591 var integer g_bsc_sccp_timer_ias := 7 * 60;
592 /*Configure T(tiar) over VTY, seconds */
593 var integer g_bsc_sccp_timer_iar := 15 * 60;
594
Neels Hofmeyr4fbad7f2020-06-16 00:30:47 +0200595 /* global test case guard timer (actual timeout value is set in f_init()) */
Harald Welteae026692017-12-09 01:03:01 +0100596 timer T_guard := 30.0;
597
Neels Hofmeyr22c3f792020-06-17 02:49:28 +0200598 var CounterNameValsList g_ctr_msc;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +0000599 var CounterNameValsList g_ctr_bsc;
600 var CounterNameValsList g_ctr_bts;
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +0200601
602 /* System Information bytes as received during RSL startup, for each RSL[idx]. */
603 var SystemInformationConfig_list g_system_information := {};
Harald Welte28d943e2017-11-25 15:00:50 +0100604}
605
606modulepar {
Harald Welte21b46bd2017-12-17 19:46:32 +0100607 /* IP address at which the BSC can be reached */
Harald Welte696ddb62017-12-08 14:01:43 +0100608 charstring mp_bsc_ip := "127.0.0.1";
Stefan Sperling830dc9d2018-02-12 21:08:28 +0100609 /* port number to which to establish the IPA OML connections */
610 integer mp_bsc_oml_port := 3002;
Harald Welte21b46bd2017-12-17 19:46:32 +0100611 /* port number to which to establish the IPA RSL connections */
Harald Welte696ddb62017-12-08 14:01:43 +0100612 integer mp_bsc_rsl_port := 3003;
Harald Welte21b46bd2017-12-17 19:46:32 +0100613 /* port number to which to establish the IPA CTRL connection */
Harald Welte96c94412017-12-09 03:12:45 +0100614 integer mp_bsc_ctrl_port := 4249;
Daniel Willmannebdecc02020-08-12 15:30:17 +0200615 /* port number to which to listen for STATSD metrics */
616 integer mp_bsc_statsd_port := 8125;
Daniel Willmann191e0d92018-01-17 12:44:35 +0100617 /* IP address at which the test binds */
618 charstring mp_test_ip := "127.0.0.1";
Harald Weltea4ca4462018-02-09 00:17:14 +0100619
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200620 RAN_Configurations mp_bssap_cfg := {
621 {
622 transport := BSSAP_TRANSPORT_AoIP,
623 sccp_service_type := "mtp3_itu",
624 sctp_addr := { 23905, "127.0.0.1", 2905, "127.0.0.1" },
625 own_pc := 185, /* 0.23.1 first MSC emulation */
626 own_ssn := 254,
627 peer_pc := 187, /* 0.23.3 osmo-bsc */
628 peer_ssn := 254,
629 sio := '83'O,
Harald Weltecb0cc432020-06-21 19:42:31 +0200630 rctx := 1
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200631 },
632 {
633 transport := BSSAP_TRANSPORT_AoIP,
634 sccp_service_type := "mtp3_itu",
635 sctp_addr := { 23906, "127.0.0.1", 2905, "127.0.0.1" },
636 own_pc := 2, /* 0.0.2 second MSC emulation */
637 own_ssn := 254,
638 peer_pc := 187, /* 0.23.3 osmo-bsc */
639 peer_ssn := 254,
640 sio := '83'O,
641 rctx := 2
642 },
643 {
644 transport := BSSAP_TRANSPORT_AoIP,
645 sccp_service_type := "mtp3_itu",
646 sctp_addr := { 23907, "127.0.0.1", 2905, "127.0.0.1" },
647 own_pc := 3, /* 0.0.3 third MSC emulation */
648 own_ssn := 254,
649 peer_pc := 187, /* 0.23.3 osmo-bsc */
650 peer_ssn := 254,
651 sio := '83'O,
652 rctx := 3
653 }
Harald Weltea4ca4462018-02-09 00:17:14 +0100654 };
Pau Espin Pedrol58cf6822019-05-28 18:11:33 +0200655
Harald Welte47cd0e32020-08-21 12:39:11 +0200656 BSSAP_LE_Configuration mp_bssap_le_cfg := {
657 sccp_service_type := "mtp3_itu",
658 sctp_addr := { 23908, "127.0.0.1", 2905, "127.0.0.1" },
Neels Hofmeyrac086c12020-09-18 23:46:42 +0200659 own_pc := 190, /* 0.23.6 SMLC emulation */
Harald Welte47cd0e32020-08-21 12:39:11 +0200660 own_ssn := 252, /* SMLC side SSN */
661 peer_pc := 187, /* 0.23.3 osmo-bsc */
662 peer_ssn := 250, /* BSC side SSN */
663 sio := '83'O,
664 rctx := 6
665 };
Neels Hofmeyrcfe44062020-10-15 02:28:08 +0200666 boolean mp_enable_lcs_tests := true;
Harald Welte47cd0e32020-08-21 12:39:11 +0200667
Pau Espin Pedrol58cf6822019-05-28 18:11:33 +0200668 /* Whether to enable osmux tests. Can be dropped completely and enable
669 unconditionally once new version of osmo-bsc is released (current
670 version: 1.4.1) */
671 boolean mp_enable_osmux_test := true;
Pau Espin Pedrol8f30ccd2019-11-01 17:30:57 +0100672 /* Value set in osmo-bsc.cfg "ms max power" */
673 uint8_t mp_exp_ms_power_level := 7;
Harald Weltea4ca4462018-02-09 00:17:14 +0100674}
675
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200676private function f_gen_test_hdlr_pars(integer bssap_idx := 0) return TestHdlrParams {
Philipp Maier48604732018-10-09 15:00:37 +0200677
678 var TestHdlrParams pars := valueof(t_def_TestHdlrPars);
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200679 if (mp_bssap_cfg[bssap_idx].transport == BSSAP_TRANSPORT_AoIP) {
Philipp Maier48604732018-10-09 15:00:37 +0200680 pars.aoip := true;
681 } else {
682 pars.aoip := false;
683 }
Pau Espin Pedrol8f30ccd2019-11-01 17:30:57 +0100684 pars.exp_ms_power_level := mp_exp_ms_power_level;
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200685 pars.mscpool.bssap_idx := bssap_idx;
Philipp Maier48604732018-10-09 15:00:37 +0200686
687 return pars;
688}
689
Neels Hofmeyr22c3f792020-06-17 02:49:28 +0200690/* Convenience functions for rate counters using g_ctr_msc. */
691
692private function f_ctrs_msc_init(integer mscs_count := NUM_MSC, CounterNameVals counternames := counternames_msc_mscpool) runs on test_CT {
693 g_ctr_msc := f_counter_name_vals_get_n(IPA_CTRL, "msc", mscs_count, counternames);
694 log("initial msc rate counters: ", g_ctr_msc);
695}
696
697private function f_ctrs_msc_add(integer msc_nr, charstring countername, integer val := 1) runs on test_CT {
Neels Hofmeyr9656e922020-06-30 01:27:01 +0200698 f_counter_name_vals_list_add(g_ctr_msc, msc_nr, countername, val);
Neels Hofmeyr22c3f792020-06-17 02:49:28 +0200699}
700
701/* f_ctrs_msc_init();
702 * f_do_thing(on_msc := 0);
703 * f_do_thing(on_msc := 0);
704 * f_do_other(on_msc := 1);
705 * f_ctrs_msc_add(0, "thing", 2);
706 * f_ctrs_msc_add(1, "other");
707 * f_ctrs_msc_verify();
708 */
709private function f_ctrs_msc_verify() runs on test_CT {
710 log("verifying msc rate counters: ", g_ctr_msc);
711 f_counter_name_vals_expect_n(IPA_CTRL, "msc", g_ctr_msc);
712}
713
714/* convenience: f_ctrs_msc_add() and f_ctrs_msc_verify() in one call.
715 * f_ctrs_msc_init();
716 * f_do_thing(on_msc := 0);
717 * f_do_thing(on_msc := 0);
718 * f_do_thing(on_msc := 0);
719 * f_ctrs_msc_expect(0, "thing", 3);
720 */
721private function f_ctrs_msc_expect(integer msc_nr, charstring countername, integer val := 1) runs on test_CT {
722 f_ctrs_msc_add(msc_nr, countername, val);
723 f_ctrs_msc_verify();
724}
725
Neels Hofmeyr12941bd2020-08-29 03:21:26 +0000726/* Convenience functions for rate counters using g_ctr_bts, always also including g_ctr_bsc. */
727
728private function f_ctrs_bsc_and_bts_init(integer bts_count := NUM_BTS, CounterNameVals counternames := counternames_bsc_bts_handover) runs on test_CT {
729 g_ctr_bts := f_counter_name_vals_get_n(IPA_CTRL, "bts", bts_count, counternames);
730 log("initial bts rate counters: ", g_ctr_bts);
731 f_ctrs_bsc_init(counternames);
732}
733
734private function f_ctrs_bsc_and_bts_add(integer bts_nr, charstring countername, integer val := 1) runs on test_CT {
735 f_counter_name_vals_list_add(g_ctr_bts, bts_nr, countername, val);
736 f_ctrs_bsc_add(countername, val);
737}
738
739/* f_ctrs_bsc_and_bts_init();
740 * f_do_thing(on_bts := 0);
741 * f_do_thing(on_bts := 0);
742 * f_do_other(on_bts := 1);
743 * f_ctrs_bsc_and_bts_add(0, "thing", 2);
744 * f_ctrs_bsc_and_bts_add(1, "other");
745 * f_ctrs_bsc_and_bts_verify();
746 */
747private function f_ctrs_bsc_and_bts_verify() runs on test_CT {
748 f_counter_name_vals_expect_n(IPA_CTRL, "bts", g_ctr_bts);
749 f_ctrs_bsc_verify();
750}
751
752/* convenience: f_ctrs_bsc_and_bts_add() and f_ctrs_bsc_and_bts_verify() in one call.
753 * f_ctrs_bsc_and_bts_init();
754 * f_do_thing(on_bts := 0);
755 * f_do_thing(on_bts := 0);
756 * f_do_thing(on_bts := 0);
757 * f_ctrs_bsc_and_bts_expect(0, "thing", 3);
758 */
759private function f_ctrs_bsc_and_bts_expect(integer bts_nr, charstring countername, integer val := 1) runs on test_CT {
760 f_ctrs_bsc_and_bts_add(bts_nr, countername, val);
761 f_ctrs_bsc_and_bts_verify();
762}
763
764
765/* Convenience functions for rate counters using g_ctr_bsc. */
766
767private function f_ctrs_bsc_init(CounterNameVals counternames := counternames_bsc_bts_handover) runs on test_CT {
768 g_ctr_bsc := f_counter_name_vals_get_n(IPA_CTRL, "bsc", 1, counternames);
769 log("initial bsc rate counters: ", g_ctr_bsc);
770}
771
772private function f_ctrs_bsc_add(charstring countername, integer val := 1) runs on test_CT {
773 f_counter_name_vals_list_add(g_ctr_bsc, 0, countername, val);
774}
775
776/* f_ctrs_bsc_init();
777 * f_do_thing();
778 * f_do_thing();
779 * f_do_other();
780 * f_ctrs_bsc_add("thing", 2);
781 * f_ctrs_bsc_add("other");
782 * f_ctrs_bsc_verify();
783 */
784private function f_ctrs_bsc_verify() runs on test_CT {
785 f_counter_name_vals_expect_n(IPA_CTRL, "bsc", g_ctr_bsc);
786}
787
788/* convenience: f_ctrs_bsc_add() and f_ctrs_bsc_verify() in one call.
789 * f_ctrs_bsc_init();
790 * f_do_thing();
791 * f_ctrs_bsc_expect("thing", 1);
792 */
793private function f_ctrs_bsc_expect(charstring countername, integer val := 1) runs on test_CT {
794 f_ctrs_bsc_add(countername, val);
795 f_ctrs_bsc_verify();
796}
797
Neels Hofmeyr22c3f792020-06-17 02:49:28 +0200798
Philipp Maier282ca4b2018-02-27 17:17:00 +0100799private function f_shutdown_helper() runs on test_CT {
Daniel Willmann637ef6c2018-07-25 10:49:09 +0200800 all component.stop;
Philipp Maier282ca4b2018-02-27 17:17:00 +0100801 setverdict(pass);
Daniel Willmannafce8662018-07-06 23:11:32 +0200802 mtc.stop;
Philipp Maier282ca4b2018-02-27 17:17:00 +0100803}
804
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200805private function f_legacy_bssap_reset(integer bssap_idx := 0) runs on test_CT {
Harald Weltea4ca4462018-02-09 00:17:14 +0100806 var BSSAP_N_UNITDATA_ind ud_ind;
Pau Espin Pedrol24c05992020-09-01 12:54:12 +0200807 var boolean reset_received := false;
Harald Weltea4ca4462018-02-09 00:17:14 +0100808 timer T := 5.0;
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200809 BSSAP.send(ts_BSSAP_UNITDATA_req(g_bssap[bssap_idx].sccp_addr_peer, g_bssap[bssap_idx].sccp_addr_own,
810 ts_BSSMAP_Reset(0, g_osmux_enabled)));
Harald Weltea4ca4462018-02-09 00:17:14 +0100811 T.start;
812 alt {
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200813 [] BSSAP.receive(tr_BSSAP_UNITDATA_ind(g_bssap[bssap_idx].sccp_addr_own, g_bssap[bssap_idx].sccp_addr_peer,
814 tr_BSSMAP_ResetAck(g_osmux_enabled))) {
Neels Hofmeyr4f5d7be2020-10-16 16:28:16 +0200815 log("BSSMAP: Received RESET-ACK in response to RESET, we're ready to go!");
Harald Weltea4ca4462018-02-09 00:17:14 +0100816 }
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200817 [] BSSAP.receive(tr_BSSAP_UNITDATA_ind(?, ?, tr_BSSMAP_Reset(g_osmux_enabled))) -> value ud_ind {
Neels Hofmeyr4f5d7be2020-10-16 16:28:16 +0200818 log("BSSMAP: Respoding to inbound RESET with RESET-ACK");
Harald Weltea4ca4462018-02-09 00:17:14 +0100819 BSSAP.send(ts_BSSAP_UNITDATA_req(ud_ind.callingAddress, ud_ind.calledAddress,
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200820 ts_BSSMAP_ResetAck(g_osmux_enabled)));
Pau Espin Pedrol24c05992020-09-01 12:54:12 +0200821 reset_received := true;
Harald Weltea4ca4462018-02-09 00:17:14 +0100822 repeat;
823 }
824 [] BSSAP.receive { repeat; }
Pau Espin Pedrol24c05992020-09-01 12:54:12 +0200825 [] T.timeout {
Neels Hofmeyr4f5d7be2020-10-16 16:28:16 +0200826 log("BSSMAP: Timeout waiting for RESET-ACK after sending RESET");
Pau Espin Pedrol24c05992020-09-01 12:54:12 +0200827 /* If we received a RESET after ours was sent, it
828 may be a race condition where the other peer beacame
829 available after we sent it, but we are in a desired
830 state anyway, so go forward. */
831 if (not reset_received) {
832 setverdict(fail);
833 }
834 }
Harald Weltea4ca4462018-02-09 00:17:14 +0100835 }
Harald Welte28d943e2017-11-25 15:00:50 +0100836}
837
Harald Welteae026692017-12-09 01:03:01 +0100838type record IPA_Client {
Harald Welte21b46bd2017-12-17 19:46:32 +0100839 /* IPA Emulation component reference */
Harald Welteae026692017-12-09 01:03:01 +0100840 IPA_Emulation_CT vc_IPA,
Harald Welte21b46bd2017-12-17 19:46:32 +0100841 /* Unit-ID and other CCM parameters to use for IPA client emulation */
Harald Welteae026692017-12-09 01:03:01 +0100842 IPA_CCM_Parameters ccm_pars,
Harald Welte21b46bd2017-12-17 19:46:32 +0100843 /* String identifier for this IPA Client */
Harald Welte624f9632017-12-16 19:26:04 +0100844 charstring id,
Harald Welte21b46bd2017-12-17 19:46:32 +0100845 /* Associated RSL Emulation Component (if any). Only used in "Handler mode" */
Harald Welte624f9632017-12-16 19:26:04 +0100846 RSL_Emulation_CT vc_RSL optional
Harald Welte28d943e2017-11-25 15:00:50 +0100847}
848
Harald Welte21b46bd2017-12-17 19:46:32 +0100849/*! Start the IPA/RSL related bits for one IPA_Client.
850 * \param clnt IPA_Client for which to establish
851 * \param bsc_host IP address / hostname of the BSC
852 * \param bsc_port TCP port number of the BSC
853 * \param i number identifying this BTS
854 * \param handler_mode Start an RSL_Emulation_CT component (true) or not (false) */
Harald Welte624f9632017-12-16 19:26:04 +0100855function f_ipa_rsl_start(inout IPA_Client clnt, charstring bsc_host, PortNumber bsc_port, integer i,
856 boolean handler_mode := false)
Harald Welte28d943e2017-11-25 15:00:50 +0100857runs on test_CT {
Harald Welteae026692017-12-09 01:03:01 +0100858 timer T := 10.0;
859
Harald Welte96c94412017-12-09 03:12:45 +0100860 clnt.id := "IPA" & int2str(i) & "-RSL";
Harald Welteae026692017-12-09 01:03:01 +0100861 clnt.vc_IPA := IPA_Emulation_CT.create(clnt.id & "-IPA");
862 clnt.ccm_pars := c_IPA_default_ccm_pars;
863 clnt.ccm_pars.name := "Osmocom TTCN-3 BTS Simulator";
864 clnt.ccm_pars.unit_id := int2str(1234+i) & "/0/0";
Harald Welte624f9632017-12-16 19:26:04 +0100865 if (handler_mode) {
866 clnt.vc_RSL := RSL_Emulation_CT.create(clnt.id & "-RSL");
Harald Welte89ab1912018-02-23 18:56:29 +0100867 connect(clnt.vc_RSL:CCHAN_PT, self:RSL_CCHAN[i]);
Harald Welte624f9632017-12-16 19:26:04 +0100868 }
Harald Welteae026692017-12-09 01:03:01 +0100869
870 map(clnt.vc_IPA:IPA_PORT, system:IPA_CODEC_PT);
Harald Welte624f9632017-12-16 19:26:04 +0100871 if (handler_mode) {
872 connect(clnt.vc_IPA:IPA_RSL_PORT, clnt.vc_RSL:IPA_PT);
873 } else {
874 connect(clnt.vc_IPA:IPA_RSL_PORT, self:IPA_RSL[i]);
875 }
Harald Welteae026692017-12-09 01:03:01 +0100876
Harald Welte5d1a2202017-12-13 19:51:29 +0100877 clnt.vc_IPA.start(IPA_Emulation.main_client(bsc_host, bsc_port, "", 10000+i, clnt.ccm_pars));
Harald Welte624f9632017-12-16 19:26:04 +0100878 if (handler_mode) {
879 clnt.vc_RSL.start(RSL_Emulation.main());
880 return;
881 }
Harald Welteae026692017-12-09 01:03:01 +0100882
883 /* wait for IPA RSL link to connect and send ID ACK */
884 T.start;
885 alt {
Vadim Yanitskiya2afacc2020-05-18 21:16:19 +0700886 [] IPA_RSL[i].receive(tr_ASP_IPA_EV(ASP_IPA_EVENT_ID_ACK)) {
Harald Welteae026692017-12-09 01:03:01 +0100887 T.stop;
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +0700888 IPA_RSL[i].send(ts_ASP_RSL_UD(ts_RSL_PAGING_LOAD_IND(23)));
Harald Welteae026692017-12-09 01:03:01 +0100889 }
Harald Welte60e823a2017-12-10 14:10:59 +0100890 [] IPA_RSL[i].receive(ASP_IPA_Event:?) { repeat }
Harald Welteae026692017-12-09 01:03:01 +0100891 [] IPA_RSL[i].receive { repeat }
892 [] T.timeout {
Harald Welte96c94412017-12-09 03:12:45 +0100893 setverdict(fail, "Timeout RSL waiting for ASP_IPA_EVENT_ID_ACK");
Daniel Willmannafce8662018-07-06 23:11:32 +0200894 mtc.stop;
Harald Welteae026692017-12-09 01:03:01 +0100895 }
896 }
897}
898
Harald Welte12055472018-03-17 20:10:08 +0100899function f_ipa_rsl_stop(inout IPA_Client clnt) runs on test_CT {
900 if (not isbound(clnt) or not isbound(clnt.vc_IPA)) {
901 return;
902 }
903 clnt.vc_IPA.stop;
904 if (isbound(clnt.vc_RSL)) {
905 clnt.vc_RSL.stop;
906 }
907}
908
Harald Welte21b46bd2017-12-17 19:46:32 +0100909/* Wait for the OML connection to be brought up by the external osmo-bts-omldummy */
Harald Weltea5d2ab22017-12-09 14:21:42 +0100910function f_wait_oml(integer bts_nr, charstring status, float secs_max) runs on test_CT {
911 timer T := secs_max;
912 T.start;
913 while (true) {
914 if (f_ctrl_get_bts(IPA_CTRL, bts_nr, "oml-connection-state") == status) {
915 T.stop;
Harald Weltebd868bd2017-12-10 18:28:40 +0100916 /* the 'degraded' state exists from OML connection time, and we have to wait
917 * until all MO's are initialized */
918 T.start(1.0);
919 T.timeout;
Harald Weltea5d2ab22017-12-09 14:21:42 +0100920 return;
921 }
Harald Weltef0d6ac62017-12-17 17:02:21 +0100922 f_sleep(0.1);
Harald Weltea5d2ab22017-12-09 14:21:42 +0100923 if (not T.running) {
Max99253902018-11-16 17:57:39 +0100924 setverdict(fail, "Timeout waiting for BTS" & int2str(bts_nr) & " oml-connection-state ", status);
Daniel Willmannafce8662018-07-06 23:11:32 +0200925 mtc.stop;
Harald Weltea5d2ab22017-12-09 14:21:42 +0100926 }
927 }
928}
929
Harald Welte21b46bd2017-12-17 19:46:32 +0100930/* global altstep for global guard timer; also takes care of responding RESET witH RESET-ACK */
Harald Welteae026692017-12-09 01:03:01 +0100931altstep as_Tguard() runs on test_CT {
Harald Welte60e823a2017-12-10 14:10:59 +0100932 var BSSAP_N_UNITDATA_ind ud_ind;
Neels Hofmeyrcc3f76a2018-03-12 01:43:25 +0100933 [] T_guard.timeout {
934 setverdict(fail, "Timeout of T_guard");
Daniel Willmannafce8662018-07-06 23:11:32 +0200935 mtc.stop;
Neels Hofmeyrcc3f76a2018-03-12 01:43:25 +0100936 }
Harald Welte60e823a2017-12-10 14:10:59 +0100937 /* always respond with RESET ACK to RESET */
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200938 [] BSSAP.receive(tr_BSSAP_UNITDATA_ind(?, ?, tr_BSSMAP_Reset(g_osmux_enabled))) -> value ud_ind {
Harald Welte60e823a2017-12-10 14:10:59 +0100939 BSSAP.send(ts_BSSAP_UNITDATA_req(ud_ind.callingAddress, ud_ind.calledAddress,
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200940 ts_BSSMAP_ResetAck(g_osmux_enabled)));
Harald Welte69c1c262017-12-13 21:02:08 +0100941 repeat;
Harald Welte60e823a2017-12-10 14:10:59 +0100942 }
Harald Welte28d943e2017-11-25 15:00:50 +0100943}
944
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +0100945altstep no_bssmap_reset() runs on test_CT {
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200946 [] BSSAP.receive(tr_BSSAP_UNITDATA_ind(?, ?, tr_BSSMAP_Reset(g_osmux_enabled))) {
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +0100947 setverdict(fail, "unexpected BSSMAP Reset");
Daniel Willmannafce8662018-07-06 23:11:32 +0200948 mtc.stop;
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +0100949 }
950}
951
Daniel Willmann191e0d92018-01-17 12:44:35 +0100952function f_init_mgcp(charstring id) runs on test_CT {
953 id := id & "-MGCP";
954
955 var MGCPOps ops := {
956 create_cb := refers(MGCP_Emulation.ExpectedCreateCallback),
957 unitdata_cb := refers(MGCP_Emulation.DummyUnitdataCallback)
958 };
959 var MGCP_conn_parameters mgcp_pars := {
960 callagent_ip := mp_bsc_ip,
Harald Welte9e4273e2018-01-29 22:01:22 +0100961 callagent_udp_port := -1,
Daniel Willmann191e0d92018-01-17 12:44:35 +0100962 mgw_ip := mp_test_ip,
Pau Espin Pedrol1a026a52019-06-18 17:21:52 +0200963 mgw_udp_port := 2427,
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +0200964 /* Enable it for SCCPlite, since we have 2 MGCP sockets towards MGW (UDP one +
965 the on with MGCP over IPA forwarded from MSC one) */
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200966 multi_conn_mode := (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_SCCPlite_SERVER)
Daniel Willmann191e0d92018-01-17 12:44:35 +0100967 };
968
969 vc_MGCP := MGCP_Emulation_CT.create(id);
970 vc_MGCP.start(MGCP_Emulation.main(ops, mgcp_pars, id));
971}
972
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200973/* Enable or disable (current default) Osmux. When enabling, BSSMAP Reset
974 * contains extra IE (OsmuxSupport) and osmo-bsc will handle AssignReq with
975 * OsmuxCID IE.
976 */
977private function f_vty_allow_osmux(boolean allow) runs on test_CT {
978 f_vty_enter_cfg_msc(BSCVTY, 0);
979 if (allow) {
980 f_vty_transceive(BSCVTY, "osmux on");
981 } else {
982 f_vty_transceive(BSCVTY, "osmux off");
983 }
984 f_vty_transceive(BSCVTY, "exit");
985 f_vty_transceive(BSCVTY, "exit");
986 g_osmux_enabled := allow;
987}
988
Max2253c0b2018-11-06 19:28:05 +0100989function f_init_vty(charstring id := "foo") runs on test_CT {
Harald Welte94e0c342018-04-07 11:33:23 +0200990 if (BSCVTY.checkstate("Mapped")) {
991 /* skip initialization if already executed once */
992 return;
993 }
Harald Weltebc03c762018-02-12 18:09:38 +0100994 map(self:BSCVTY, system:BSCVTY);
995 f_vty_set_prompts(BSCVTY);
996 f_vty_transceive(BSCVTY, "enable");
Pau Espin Pedrolc675b612020-01-09 19:55:40 +0100997 f_cs7_inst_0_cfg(BSCVTY, {"sccp-timer ias " & int2str(g_bsc_sccp_timer_ias),
998 "sccp-timer iar " & int2str(g_bsc_sccp_timer_iar)});
Harald Weltebc03c762018-02-12 18:09:38 +0100999}
1000
Neels Hofmeyr767548a2020-08-09 20:26:07 +00001001private function f_logp(TELNETasp_PT pt, charstring log_msg)
Neels Hofmeyr4f118412020-06-04 15:25:10 +02001002{
1003 // log on TTCN3 log output
1004 log(log_msg);
1005 // log in stderr log
Neels Hofmeyr767548a2020-08-09 20:26:07 +00001006 f_vty_transceive(pt, "logp lglobal notice TTCN3 f_logp(): " & log_msg);
Neels Hofmeyr4f118412020-06-04 15:25:10 +02001007}
1008
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +02001009private function f_sysinfo_seen(integer rsl_idx, RSL_Message rsl) runs on test_CT
1010{
1011 if (rsl_idx >= lengthof(g_system_information)) {
1012 g_system_information[rsl_idx] := SystemInformationConfig_omit
1013 }
1014 f_sysinfo_dec_raw(g_system_information[rsl_idx], rsl);
1015}
1016
1017altstep as_catch_RSL_sysinfo(integer rsl_idx) runs on test_CT {
1018 var ASP_RSL_Unitdata rx_rsl_ud;
1019
1020 /* For handler_mode := false, receiving the RSL bootstrap messages directly on IPA_RSL */
1021 [] IPA_RSL[rsl_idx].receive(tr_ASP_RSL_UD(tr_RSL_NO_BCCH_INFO)) -> value rx_rsl_ud {
1022 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
1023 repeat;
1024 }
1025 [] IPA_RSL[rsl_idx].receive(tr_ASP_RSL_UD(tr_RSL_BCCH_INFO)) -> value rx_rsl_ud {
1026 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
1027 repeat;
1028 }
1029 [] IPA_RSL[rsl_idx].receive(tr_ASP_RSL_UD(tr_RSL_NO_SACCH_FILL)) -> value rx_rsl_ud {
1030 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
1031 repeat;
1032 }
1033 [] IPA_RSL[rsl_idx].receive(tr_ASP_RSL_UD(tr_RSL_SACCH_FILL)) -> value rx_rsl_ud {
1034 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
1035 repeat;
1036 }
1037
1038 /* For handler_mode := true, receiving the RSL bootstrap messages via RSL_Emulation */
1039 [] RSL_CCHAN[rsl_idx].receive(tr_ASP_RSL_UD(tr_RSL_NO_BCCH_INFO)) -> value rx_rsl_ud {
1040 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
1041 repeat;
1042 }
1043 [] RSL_CCHAN[rsl_idx].receive(tr_ASP_RSL_UD(tr_RSL_BCCH_INFO)) -> value rx_rsl_ud {
1044 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
1045 repeat;
1046 }
1047 [] RSL_CCHAN[rsl_idx].receive(tr_ASP_RSL_UD(tr_RSL_NO_SACCH_FILL)) -> value rx_rsl_ud {
1048 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
1049 repeat;
1050 }
1051 [] RSL_CCHAN[rsl_idx].receive(tr_ASP_RSL_UD(tr_RSL_SACCH_FILL)) -> value rx_rsl_ud {
1052 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
1053 repeat;
1054 }
1055}
1056
Neels Hofmeyra460f1f2020-08-09 20:17:03 +00001057/* TODO: use BooleanList from COMMON/src/General_Types.ttcn */
1058private type record of boolean my_BooleanList;
1059
1060private function f_vty_msc_allow_attach(TELNETasp_PT pt, my_BooleanList allow_attach_list)
1061{
Neels Hofmeyr8f576712020-08-12 22:49:53 +00001062 var charstring config := f_vty_transceive_ret(pt, "show running-config");
1063
Neels Hofmeyra460f1f2020-08-09 20:17:03 +00001064 for (var integer msc_nr := 0; msc_nr < sizeof(allow_attach_list); msc_nr := msc_nr+1) {
Neels Hofmeyr8f576712020-08-12 22:49:53 +00001065 if (f_strstr(config, "\nmsc " & int2str(msc_nr) & "\n") < 0) {
1066 /* There is no 'msc N' for this msc_nr in the running config, so don't create an empty msc by
1067 * stepping into that config node. */
1068 log("msc ", msc_nr, " is not configured, skipping");
1069 continue;
1070 }
Neels Hofmeyra460f1f2020-08-09 20:17:03 +00001071 f_vty_enter_cfg_msc(pt, msc_nr);
1072 if (allow_attach_list[msc_nr]) {
1073 /* strict := false: ignore if osmo-bsc does not support this config option (latest build) */
1074 f_vty_transceive(pt, "allow-attach", strict := false);
1075 } else {
1076 f_vty_transceive(pt, "no allow-attach", strict := false);
1077 }
1078 f_vty_transceive(pt, "exit");
1079 f_vty_transceive(pt, "exit");
1080 }
1081}
1082
Harald Welte21b46bd2017-12-17 19:46:32 +01001083/* global initialization function
1084 * \param nr_bts Number of BTSs we should start/bring up
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001085 * \param handler_mode Start an RSL_Emulation_CT component (true) or not (false).
1086 * \param nr_msc Number of virtual MSCs to bring up to connect to osmo-bsc.
1087 */
1088function f_init(integer nr_bts := NUM_BTS, boolean handler_mode := false, boolean allow_osmux := false,
Neels Hofmeyr4fbad7f2020-06-16 00:30:47 +02001089 integer nr_msc := 1, float guard_timeout := 30.0) runs on test_CT {
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001090 var integer bssap_idx;
Harald Welte28d943e2017-11-25 15:00:50 +01001091
Harald Welteae026692017-12-09 01:03:01 +01001092 if (g_initialized) {
1093 return;
Harald Welte28d943e2017-11-25 15:00:50 +01001094 }
Harald Welteae026692017-12-09 01:03:01 +01001095 g_initialized := true;
1096
Neels Hofmeyr4fbad7f2020-06-16 00:30:47 +02001097 T_guard.start(guard_timeout);
Daniel Willmanne68f9272018-11-27 15:15:28 +01001098 activate(as_Tguard());
1099
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02001100 f_init_vty("VirtMSC");
Pau Espin Pedrol58cf6822019-05-28 18:11:33 +02001101 if (mp_enable_osmux_test) {
1102 f_vty_allow_osmux(allow_osmux);
1103 }
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02001104
Neels Hofmeyra460f1f2020-08-09 20:17:03 +00001105 var my_BooleanList allow_attach := { false, false, false };
Daniel Willmannebdecc02020-08-12 15:30:17 +02001106 f_init_statsd("VirtMSC", vc_STATSD, mp_test_ip, mp_bsc_statsd_port);
1107
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001108 for (bssap_idx := 0; bssap_idx < nr_msc; bssap_idx := bssap_idx+1) {
Neels Hofmeyra460f1f2020-08-09 20:17:03 +00001109 allow_attach[bssap_idx] := true;
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001110 /* Call a function of our 'parent component' RAN_Adapter_CT to start the
1111 * MSC-side BSSAP emulation */
1112 if (handler_mode) {
1113 var RanOps ranops := MSC_RanOps;
1114 ranops.use_osmux := g_osmux_enabled;
1115 f_ran_adapter_init(g_bssap[bssap_idx], mp_bssap_cfg[bssap_idx], "VirtMSC", ranops);
1116 connect(self:SCCPLITE_IPA_CTRL, g_bssap[bssap_idx].vc_RAN:CTRL_CLIENT);
1117 f_ran_adapter_start(g_bssap[bssap_idx]);
1118 } else {
1119 f_ran_adapter_init(g_bssap[bssap_idx], mp_bssap_cfg[bssap_idx], "VirtMSC", omit);
1120 connect(self:BSSAP, g_bssap[bssap_idx].vc_SCCP:SCCP_SP_PORT);
1121 f_ran_adapter_start(g_bssap[bssap_idx]);
1122 f_legacy_bssap_reset();
1123 }
Harald Welte67089ee2018-01-17 22:19:03 +01001124 }
Harald Welted5833a82018-05-27 16:52:56 +02001125
Neels Hofmeyrcfe44062020-10-15 02:28:08 +02001126 if (mp_enable_lcs_tests) {
1127 if (handler_mode) {
1128 f_bssap_le_adapter_init(g_bssap_le, mp_bssap_le_cfg, "VirtSMLC", SMLC_BssapLeOps);
1129 } else {
1130 f_bssap_le_adapter_init(g_bssap_le, mp_bssap_le_cfg, "VirtSMLC", omit);
1131 connect(self:BSSAP_LE, g_bssap_le.vc_SCCP:SCCP_SP_PORT);
1132 }
1133 f_bssap_le_adapter_start(g_bssap_le);
Harald Welte47cd0e32020-08-21 12:39:11 +02001134 }
Harald Welte47cd0e32020-08-21 12:39:11 +02001135
Neels Hofmeyra460f1f2020-08-09 20:17:03 +00001136 /* start the test with exactly all enabled MSCs allowed to attach */
1137 f_vty_msc_allow_attach(BSCVTY, allow_attach);
1138
Pau Espin Pedrol9a5b8ff2021-01-04 19:01:31 +01001139 f_ipa_ctrl_start_client(mp_bsc_ip, mp_bsc_ctrl_port);
Harald Welte28d943e2017-11-25 15:00:50 +01001140
Daniel Willmann191e0d92018-01-17 12:44:35 +01001141 f_init_mgcp("VirtMSC");
1142
Neels Hofmeyr0b7365b2020-07-04 00:52:34 +02001143 for (var integer i := 0; i < nr_bts; i := i+1) {
1144 f_init_bts(i, handler_mode);
Harald Welte696ddb62017-12-08 14:01:43 +01001145 }
Neels Hofmeyr0b7365b2020-07-04 00:52:34 +02001146}
Harald Welte696ddb62017-12-08 14:01:43 +01001147
Neels Hofmeyr0b7365b2020-07-04 00:52:34 +02001148function f_init_bts(integer bts_idx := 0, boolean handler_mode := false)
1149runs on test_CT {
1150 /* wait until osmo-bts-omldummy has respawned */
1151 f_wait_oml(bts_idx, "degraded", 5.0);
1152
1153 /* start RSL connection */
1154 f_ipa_rsl_start(bts[bts_idx].rsl, mp_bsc_ip, mp_bsc_rsl_port, bts_idx, handler_mode);
1155 /* wait until BSC tells us "connected" */
1156 f_wait_oml(bts_idx, "connected", 5.0);
Harald Welte28d943e2017-11-25 15:00:50 +01001157}
1158
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +02001159function f_init_bts_and_check_sysinfo(integer bts_idx := 0, boolean handler_mode := false,
1160 template SystemInformationConfig expect_si)
1161runs on test_CT {
1162 var default sysinfo := activate(as_catch_RSL_sysinfo(bts_idx));
1163
1164 f_init_bts(bts_idx, handler_mode);
1165
1166 /* Give some time to (hopefully/most likely) collect all system informations from RSL startup.
1167 * We could stop as soon as all expected SI are received, but then we might miss SI that we don't expect and
1168 * that might be sent afterwards. So rather give a generous timeout and be quite sure to catch all SI.
1169 */
1170 f_sleep(5.0);
1171 log("RSL ", bts_idx, " SYSTEM INFORMATION: ", g_system_information[bts_idx]);
1172
1173 deactivate(sysinfo);
1174
1175 if (match(g_system_information[bts_idx], expect_si)) {
1176 setverdict(pass);
1177 } else {
1178 log("RSL ", bts_idx, ": EXPECTED SI: ", expect_si);
1179 log("RSL ", bts_idx, ": GOT SI: ", g_system_information[bts_idx]);
1180 setverdict(fail, "received SI does not match expectations");
1181 return;
1182 }
1183}
1184
Maxd4e56962018-10-31 19:08:25 +01001185/* expect to receive a RSL message matching a specified template on a given BTS / stream */
Harald Welte65e419a2020-08-21 12:38:33 +02001186function 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 +01001187runs on test_CT return RSL_Message {
1188 var ASP_RSL_Unitdata rx_rsl_ud;
1189 timer T := t_secs;
1190
1191 T.start;
1192 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001193 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(t_rx, sid)) -> value rx_rsl_ud {
Harald Welteae026692017-12-09 01:03:01 +01001194 T.stop;
1195 }
1196 [] IPA_RSL[bts_nr].receive { repeat; }
Harald Welteb2917702017-12-10 15:48:52 +01001197 [] T.timeout {
1198 setverdict(fail, "Timeout expecting ", t_rx);
Daniel Willmannafce8662018-07-06 23:11:32 +02001199 mtc.stop;
Harald Welteb2917702017-12-10 15:48:52 +01001200 }
Harald Welteae026692017-12-09 01:03:01 +01001201 }
1202 return rx_rsl_ud.rsl;
1203}
1204
Harald Welte21b46bd2017-12-17 19:46:32 +01001205/* helper function to transmit RSL on a given BTS/stream */
Harald Welte65e419a2020-08-21 12:38:33 +02001206function 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 +01001207runs on test_CT {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001208 IPA_RSL[bts_nr].send(ts_ASP_RSL_UD(t_tx, sid));
Harald Welteae026692017-12-09 01:03:01 +01001209}
1210
1211
Harald Welte4003d112017-12-09 22:35:39 +01001212/* verify we get a CHAN_ACT after CHAN RQD */
Harald Welteae026692017-12-09 01:03:01 +01001213testcase TC_chan_act_noreply() runs on test_CT {
1214 var BSSAP_N_UNITDATA_ind ud_ind;
Harald Welte930d0a72018-03-22 22:08:40 +01001215 var RSL_Message rsl_unused;
Harald Welte28d943e2017-11-25 15:00:50 +01001216
Harald Welte89d42e82017-12-17 16:42:41 +01001217 f_init(1);
Harald Welte28d943e2017-11-25 15:00:50 +01001218
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001219 IPA_RSL[0].send(ts_ASP_RSL_UD(ts_RSL_CHAN_RQD('23'O, 23)));
Harald Welte930d0a72018-03-22 22:08:40 +01001220 rsl_unused := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001221 f_shutdown_helper();
Harald Welte28d943e2017-11-25 15:00:50 +01001222}
1223
Harald Welte4003d112017-12-09 22:35:39 +01001224/* verify if the "chreq:total" counter increments as expected */
1225testcase TC_chan_act_counter() runs on test_CT {
1226 var BSSAP_N_UNITDATA_ind ud_ind;
1227 var integer chreq_total;
Harald Welte930d0a72018-03-22 22:08:40 +01001228 var RSL_Message rsl_unused;
Harald Welte4003d112017-12-09 22:35:39 +01001229
Harald Welte89d42e82017-12-17 16:42:41 +01001230 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +01001231
1232 chreq_total := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total");
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001233 IPA_RSL[0].send(ts_ASP_RSL_UD(ts_RSL_CHAN_RQD('23'O, 23)));
Harald Welte930d0a72018-03-22 22:08:40 +01001234 rsl_unused := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
Harald Welte4003d112017-12-09 22:35:39 +01001235 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total", chreq_total+1);
1236
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001237 f_shutdown_helper();
Harald Welte4003d112017-12-09 22:35:39 +01001238}
1239
Harald Welteae026692017-12-09 01:03:01 +01001240/* CHAN RQD -> CHAN ACT -> CHAN ACT ACK -> RF CHAN REL */
Philipp Maier9c60a622020-07-09 15:08:46 +02001241private function f_TC_chan_act_ack_noest(OCT1 ra := '23'O) runs on test_CT {
Harald Welteae026692017-12-09 01:03:01 +01001242 var RSL_Message rx_rsl;
1243
Harald Welteae026692017-12-09 01:03:01 +01001244 /* Send CHAN RQD and wait for allocation; acknowledge it */
Philipp Maier9c60a622020-07-09 15:08:46 +02001245 var RslChannelNr chan_nr := f_chreq_act_ack(ra);
Harald Welteae026692017-12-09 01:03:01 +01001246
1247 /* expect BSC to disable the channel again if there's no RLL EST IND */
1248 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), T3101_MAX);
1249
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001250 f_shutdown_helper();
Harald Welteae026692017-12-09 01:03:01 +01001251}
1252
Philipp Maier9c60a622020-07-09 15:08:46 +02001253/* Normal variant */
1254testcase TC_chan_act_ack_noest() runs on test_CT {
Philipp Maieraf58db22020-08-12 17:24:40 +02001255 f_init(1);
Philipp Maier9c60a622020-07-09 15:08:46 +02001256 f_TC_chan_act_ack_noest();
1257}
1258
1259/* Emergency call variant */
1260testcase TC_chan_act_ack_noest_emerg() runs on test_CT {
1261 /* See also: 3GPP TS 04.08, Table 9.9, ra=101xxxxx */
Philipp Maieraf58db22020-08-12 17:24:40 +02001262 f_init(1);
1263 f_vty_allow_emerg_bts(true, 0);
Philipp Maier9c60a622020-07-09 15:08:46 +02001264 f_TC_chan_act_ack_noest(ra := 'A5'O);
1265}
1266
Philipp Maier606f07d2020-08-12 17:21:58 +02001267/* Emergency call variant, but emergency calls are not allowed */
1268testcase TC_chan_rqd_emerg_deny() runs on test_CT {
1269 /* See also: 3GPP TS 04.08, Table 9.9, ra=101xxxxx */
1270
1271 var RSL_Message rx_rsl;
1272 var GsmRrMessage rr;
1273
1274 f_init(1);
1275 f_vty_allow_emerg_bts(false, 0);
1276
1277 IPA_RSL[0].clear;
1278 f_ipa_tx(0, ts_RSL_CHAN_RQD('A5'O, 23));
1279
1280 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeC(RSL_MT_IMMEDIATE_ASSIGN_CMD));
1281 rr := dec_GsmRrMessage(rx_rsl.ies[1].body.full_imm_ass_info.payload);
1282 if (rr.header.message_type == IMMEDIATE_ASSIGNMENT_REJECT) {
1283 setverdict(pass);
1284 } else {
1285 setverdict(fail, "immediate assignment not rejected");
1286 }
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01001287
1288 f_shutdown_helper();
Philipp Maier606f07d2020-08-12 17:21:58 +02001289}
1290
Harald Welteae026692017-12-09 01:03:01 +01001291/* Test behavior if MSC never answers to CR */
1292testcase TC_chan_act_ack_est_ind_noreply() runs on test_CT {
Harald Weltef77aef62018-01-28 15:35:42 +01001293 var RslLinkId main_dcch := valueof(ts_RslLinkID_DCCH(0));
1294 var IpaStreamId sid := IPAC_PROTO_RSL_TRX0;
Harald Welteae026692017-12-09 01:03:01 +01001295 var RSL_Message rx_rsl;
Harald Weltef77aef62018-01-28 15:35:42 +01001296 var ASP_RSL_Unitdata rx_rsl_ud;
Harald Welteae026692017-12-09 01:03:01 +01001297
Harald Welte89d42e82017-12-17 16:42:41 +01001298 f_init(1);
Harald Welteae026692017-12-09 01:03:01 +01001299
1300 /* Send CHAN RQD and wait for allocation; acknowledge it */
Harald Welted6939652017-12-13 21:02:46 +01001301 var RslChannelNr chan_nr := f_chreq_act_ack();
Harald Welteae026692017-12-09 01:03:01 +01001302
1303 var octetstring l3 := '00010203040506'O
1304 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
1305
1306 BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3)));
1307
1308 /* expect BSC to disable the channel again if there's no response from MSC */
Harald Weltef77aef62018-01-28 15:35:42 +01001309 /* MS waits 20s (T3210) at LU; 10s (T3230) at CM SERV REQ and 5s (T3220) AT detach */
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001310 f_expect_chan_rel(0, chan_nr, expect_rll_rel_req := false);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001311 f_shutdown_helper();
Harald Welteae026692017-12-09 01:03:01 +01001312}
1313
1314/* Test behavior if MSC answers with CREF to CR */
1315testcase TC_chan_act_ack_est_ind_refused() runs on test_CT {
1316 var BSSAP_N_CONNECT_ind rx_c_ind;
1317 var RSL_Message rx_rsl;
1318
Harald Welte89d42e82017-12-17 16:42:41 +01001319 f_init(1);
Harald Welteae026692017-12-09 01:03:01 +01001320
1321 /* Send CHAN RQD and wait for allocation; acknowledge it */
Harald Welted6939652017-12-13 21:02:46 +01001322 var RslChannelNr chan_nr := f_chreq_act_ack();
Harald Welteae026692017-12-09 01:03:01 +01001323
1324 var octetstring l3 := '00010203040506'O
1325 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
1326
1327 BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) -> value rx_c_ind;
1328 BSSAP.send(ts_BSSAP_DISC_req(rx_c_ind.connectionId, 0));
1329
1330 /* expect BSC to disable the channel */
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001331 f_expect_chan_rel(0, chan_nr, expect_rll_rel_req := false);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001332 f_shutdown_helper();
Harald Welteae026692017-12-09 01:03:01 +01001333}
1334
Harald Welte618ef642017-12-14 14:58:20 +01001335/* CHAN RQD -> CHAN ACT -> CHAN ACT NACK -> RF CHAN REL */
1336testcase TC_chan_act_nack() runs on test_CT {
1337 var RSL_Message rx_rsl;
1338 var integer chact_nack;
1339
Harald Welte89d42e82017-12-17 16:42:41 +01001340 f_init(1);
Harald Welte618ef642017-12-14 14:58:20 +01001341
1342 chact_nack := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chan_act:nack");
1343
1344 f_ipa_tx(0, ts_RSL_CHAN_RQD('33'O, 33));
1345 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
1346 var RslChannelNr chan_nr := rx_rsl.ies[0].body.chan_nr;
1347
1348 f_ipa_tx(0, ts_RSL_CHAN_ACT_NACK(chan_nr, RSL_ERR_EQUIPMENT_FAIL));
1349
1350 /* wait for some time to hope the NACK arrives before the CTRL GET below */
1351 f_sleep(0.5);
1352
1353 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chan_act:nack", chact_nack+1);
1354
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001355 f_shutdown_helper();
Harald Welte618ef642017-12-14 14:58:20 +01001356}
1357
Harald Welte799c97b2017-12-14 17:50:30 +01001358/* Test for channel exhaustion due to RACH overload */
1359testcase TC_chan_exhaustion() runs on test_CT {
1360 var ASP_RSL_Unitdata rsl_ud;
1361 var integer i;
1362 var integer chreq_total, chreq_nochan;
1363
Harald Welte89d42e82017-12-17 16:42:41 +01001364 f_init(1);
Harald Welte799c97b2017-12-14 17:50:30 +01001365
1366 chreq_total := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total");
1367 chreq_nochan := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:no_channel");
1368
Pau Espin Pedrolfe200d72018-12-10 12:41:04 +01001369 /* GSM 04.08 Table 9.9a:
1370 * RA = '33'O -> Establishment cause = 0011xxxx (MS dual rate capable and asks for "TCH/H or TCH/F").
1371 * With current setup, expect 4xSDCCH + 4xTCH/F + 1xTCH/H to succeed */
Philipp Maiercb6cc482018-03-26 13:08:00 +02001372 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 +01001373 var RslChannelNr chan_nr := f_chreq_act_ack('33'O, i);
Harald Welte799c97b2017-12-14 17:50:30 +01001374 }
1375
1376 IPA_RSL[0].clear;
1377
Harald Weltedd8cbf32018-01-28 12:07:52 +01001378 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total",
Philipp Maiercb6cc482018-03-26 13:08:00 +02001379 chreq_total + NUM_TCHF_PER_BTS + NUM_TCHH_PER_BTS + NUM_SDCCH_PER_BTS);
Harald Welte799c97b2017-12-14 17:50:30 +01001380
1381 /* now expect additional channel activations to fail */
1382 f_ipa_tx(0, ts_RSL_CHAN_RQD('42'O, 42));
1383
1384 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001385 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV))) {
Harald Welte799c97b2017-12-14 17:50:30 +01001386 setverdict(fail, "Received CHAN ACT ACK without resources?!?");
1387 }
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001388 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_IMM_ASSIGN(?))) -> value rsl_ud {
Harald Welte799c97b2017-12-14 17:50:30 +01001389 var GsmRrMessage rr;
1390 /* match on IMM ASS REJ */
1391 rr := dec_GsmRrMessage(rsl_ud.rsl.ies[1].body.full_imm_ass_info.payload);
1392 if (rr.header.message_type == IMMEDIATE_ASSIGNMENT_REJECT) {
1393 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total",
Philipp Maiercb6cc482018-03-26 13:08:00 +02001394 chreq_total + NUM_TCHF_PER_BTS + NUM_TCHH_PER_BTS + NUM_SDCCH_PER_BTS+1);
Harald Welte799c97b2017-12-14 17:50:30 +01001395 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:no_channel",
1396 chreq_nochan+1);
1397 setverdict(pass);
1398 } else {
1399 repeat;
1400 }
1401 }
1402 [] IPA_RSL[0].receive { repeat; }
1403 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001404 f_shutdown_helper();
Harald Welte799c97b2017-12-14 17:50:30 +01001405}
1406
Vadim Yanitskiy1ff1fdf2018-11-27 01:32:57 +07001407/* Test channel deactivation due to silence from MS */
1408testcase TC_chan_deact_silence() runs on test_CT {
1409 var RslChannelNr chan_nr;
1410
1411 f_init(1);
1412
1413 /* Request for a dedicated channel */
1414 chan_nr := f_chreq_act_ack('23'O);
1415
1416 /* Wait some time until the channel is released */
1417 f_sleep(2.0);
1418
1419 /* Expect CHANnel RELease */
1420 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001421 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL))) {
Vadim Yanitskiy1ff1fdf2018-11-27 01:32:57 +07001422 log("Received CHANnel RELease");
1423 setverdict(pass);
1424 }
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001425 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_IMM_ASSIGN(?))) {
Vadim Yanitskiy1ff1fdf2018-11-27 01:32:57 +07001426 /* See OS#3709, OsmoBSC should not send Immediate
1427 * Assignment Reject since a dedicated channel was
1428 * already allocated, and Immediate Assignment was
1429 * already sent. */
1430 setverdict(fail, "Unexpected Immediate Assignment!");
1431 }
1432 [] IPA_RSL[0].receive {
1433 setverdict(fail, "Unexpected RSL message!");
1434 }
1435 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001436 f_shutdown_helper();
Vadim Yanitskiy1ff1fdf2018-11-27 01:32:57 +07001437}
1438
Harald Weltecfe2c962017-12-15 12:09:32 +01001439/***********************************************************************
1440 * Assignment Testing
1441 ***********************************************************************/
1442
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02001443/* Verify that the BSC refuses any BSSAP connection from the MSC (They are all BSC->MSC direction,
1444 * except for the inter-BSC handover, MT side) */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001445testcase TC_outbound_connect(integer bssap_idx := 0) runs on test_CT {
Harald Welte89d42e82017-12-17 16:42:41 +01001446 f_init(1);
Harald Weltecfe2c962017-12-15 12:09:32 +01001447
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001448 BSSAP.send(ts_BSSAP_CONNECT_req(g_bssap[bssap_idx].sccp_addr_peer, g_bssap[bssap_idx].sccp_addr_own,
1449 2342, ts_BSSMAP_AssignmentReq));
Harald Weltecfe2c962017-12-15 12:09:32 +01001450 BSSAP.receive(tr_BSSAP_DISC_ind(2342, ?, ?));
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001451 f_shutdown_helper();
Harald Weltecfe2c962017-12-15 12:09:32 +01001452}
1453
Harald Welte16a4adf2017-12-14 18:54:01 +01001454/* Test behavior if MSC answers with CREF to CR */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001455testcase TC_assignment_cic_only(integer bssap_idx := 0) runs on test_CT {
Harald Welte16a4adf2017-12-14 18:54:01 +01001456 var BSSAP_N_CONNECT_ind rx_c_ind;
1457 var RSL_Message rx_rsl;
1458 var DchanTuple dt;
1459
Harald Welte89d42e82017-12-17 16:42:41 +01001460 f_init(1);
Harald Welte16a4adf2017-12-14 18:54:01 +01001461
1462 dt := f_est_dchan('23'O, 23, '00000000'O);
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001463 if (mp_bssap_cfg[bssap_idx].transport == BSSAP_TRANSPORT_AoIP) {
Harald Welte17b27da2018-05-25 20:33:53 +02001464 /* send assignment without AoIP IEs */
1465 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_AssignmentReq(ts_BSSMAP_IE_CIC(0, 1))));
1466 } else {
1467 /* Send assignmetn without CIC in IPA case */
1468 var BSSMAP_IE_AoIP_TransportLayerAddress tla :=
1469 valueof(ts_BSSMAP_IE_AoIP_TLA4('01020304'O, 2342));
1470 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_AssignmentReq(omit, tla)));
1471 }
Harald Welte16a4adf2017-12-14 18:54:01 +01001472 alt {
1473 [] BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_AssignmentComplete)) {
1474 setverdict(fail, "AoIP BSC cannot accept ASSIGNMENT without AoIP Transport IE");
1475 }
Harald Welte235ebf12017-12-15 14:18:16 +01001476 /* TODO: Actually expect GSM0808_CAUSE_REQ_A_IF_TYPE_NOT_SUPP */
Harald Welte16a4adf2017-12-14 18:54:01 +01001477 [] BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_AssignmentFail)) {
1478 setverdict(pass);
1479 }
1480 [] BSSAP.receive { repeat; }
1481 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001482 f_shutdown_helper();
Harald Welte16a4adf2017-12-14 18:54:01 +01001483}
1484
Harald Welteed848512018-05-24 22:27:58 +02001485/* generate an assignment request for either AoIP or SCCPlite */
Pau Espin Pedrol07866632020-09-03 19:10:55 +02001486function 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 +02001487 var PDU_BSSAP ass_cmd;
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02001488 var BSSMAP_IE_Osmo_OsmuxCID osmux_cid := valueof(ts_OsmuxCID(0));
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001489 if (mp_bssap_cfg[bssap_idx].transport == BSSAP_TRANSPORT_AoIP) {
Harald Welteed848512018-05-24 22:27:58 +02001490 var BSSMAP_IE_AoIP_TransportLayerAddress tla :=
Pau Espin Pedrol07866632020-09-03 19:10:55 +02001491 valueof(f_ts_BSSMAP_IE_AoIP_TLA(aoip_tla, 2342));
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02001492 if (osmux_enabled) {
1493 ass_cmd := valueof(ts_BSSMAP_AssignmentReq(omit, tla, osmux_cid));
1494 } else {
1495 ass_cmd := valueof(ts_BSSMAP_AssignmentReq(omit, tla));
1496 }
Harald Welteed848512018-05-24 22:27:58 +02001497 } else {
1498 var BSSMAP_IE_CircuitIdentityCode cic := valueof(ts_BSSMAP_IE_CIC(0,1));
Pau Espin Pedrol096d73d2019-06-06 12:49:17 +02001499 ass_cmd := valueof(ts_BSSMAP_AssignmentReq(cic, omit));
Harald Welteed848512018-05-24 22:27:58 +02001500 }
1501 return ass_cmd;
1502}
1503
Pau Espin Pedrolc08d5522021-04-16 15:40:38 +02001504function f_gen_handover_req(integer bssap_idx := 0, charstring aoip_tla := "1.2.3.4",
1505 template (omit) BSSMAP_oldToNewBSSIEs oldToNewBSSIEs := omit) return PDU_BSSAP {
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01001506 var PDU_BSSAP ho_req;
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001507 if (mp_bssap_cfg[bssap_idx].transport == BSSAP_TRANSPORT_AoIP) {
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01001508 var BSSMAP_IE_AoIP_TransportLayerAddress tla :=
Pau Espin Pedrol07866632020-09-03 19:10:55 +02001509 valueof(f_ts_BSSMAP_IE_AoIP_TLA(aoip_tla, 2342));
Pau Espin Pedrolc08d5522021-04-16 15:40:38 +02001510 ho_req := valueof(ts_BSSMAP_HandoverRequest(omit, tla, oldToNewBSSIEs := oldToNewBSSIEs));
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01001511 } else {
1512 var BSSMAP_IE_CircuitIdentityCode cic := valueof(ts_BSSMAP_IE_CIC(0,1));
Pau Espin Pedrolc08d5522021-04-16 15:40:38 +02001513 ho_req := valueof(ts_BSSMAP_HandoverRequest(cic, omit, oldToNewBSSIEs := oldToNewBSSIEs));
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01001514 }
1515 return ho_req;
1516}
1517
Harald Welteed848512018-05-24 22:27:58 +02001518/* generate an assignment complete template for either AoIP or SCCPlite */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001519function f_gen_exp_compl(boolean expect_osmux := false, integer bssap_idx := 0) return template PDU_BSSAP {
Harald Welteed848512018-05-24 22:27:58 +02001520 var template PDU_BSSAP exp_compl;
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02001521 var BSSMAP_IE_Osmo_OsmuxCID osmux_cid := valueof(ts_OsmuxCID(0));
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001522 if (mp_bssap_cfg[bssap_idx].transport == BSSAP_TRANSPORT_AoIP) {
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02001523 if (expect_osmux) {
1524 exp_compl := tr_BSSMAP_AssignmentComplete(omit, ?, osmux_cid);
1525 } else {
1526 exp_compl := tr_BSSMAP_AssignmentComplete(omit, ?, omit);
1527 }
Harald Welteed848512018-05-24 22:27:58 +02001528 } else {
1529 /* CIC is optional "*" as the MSC allocated it */
Pau Espin Pedrol096d73d2019-06-06 12:49:17 +02001530 exp_compl := tr_BSSMAP_AssignmentComplete(*, omit);
Harald Welteed848512018-05-24 22:27:58 +02001531 }
1532 return exp_compl;
1533}
1534
Harald Welte235ebf12017-12-15 14:18:16 +01001535/* Run everything required up to sending a caller-specified assignment command and expect response */
1536function f_assignment_exp(PDU_BSSAP ass_cmd, template PDU_BSSAP exp, charstring fail_text)
1537runs on test_CT {
1538 var BSSAP_N_CONNECT_ind rx_c_ind;
1539 var RSL_Message rx_rsl;
1540 var DchanTuple dt;
1541
Harald Welte89d42e82017-12-17 16:42:41 +01001542 f_init(1);
Harald Welte235ebf12017-12-15 14:18:16 +01001543
1544 dt := f_est_dchan('23'O, 23, '00000000'O);
1545 /* send assignment without AoIP IEs */
1546 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ass_cmd));
1547 alt {
1548 [] BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_AssignmentComplete)) {
1549 if (ischosen(exp.pdu.bssmap.assignmentComplete)) {
1550 setverdict(pass);
1551 } else {
1552 setverdict(fail, fail_text);
1553 }
1554 }
1555 [] BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_AssignmentFail)) {
1556 if (ischosen(exp.pdu.bssmap.assignmentFailure)) {
1557 setverdict(pass);
1558 } else {
1559 setverdict(fail, fail_text);
1560 }
1561 }
1562 [] BSSAP.receive { repeat; }
1563 }
1564}
1565testcase TC_assignment_csd() runs on test_CT {
1566 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
Harald Welteed848512018-05-24 22:27:58 +02001567 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte235ebf12017-12-15 14:18:16 +01001568 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeCSD);
1569 //exp_fail.pdu.bssmap.assignmentFailure.cause.causeValue := int2bit(enum2int(GSM0808_CAUSE_REQ_CODEC_TYPE_OR_CONFIG_UNAVAIL), 7);
1570 f_assignment_exp(ass_cmd, exp_fail, "BSC accepted Assignment for CSD");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001571 f_shutdown_helper();
Harald Welte235ebf12017-12-15 14:18:16 +01001572}
1573
1574testcase TC_assignment_ctm() runs on test_CT {
1575 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
Harald Welteed848512018-05-24 22:27:58 +02001576 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte235ebf12017-12-15 14:18:16 +01001577 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeCTM);
1578 //exp_fail.pdu.bssmap.assignmentFailure.cause.causeValue := int2bit(enum2int(GSM0808_CAUSE_REQ_CODEC_TYPE_OR_CONFIG_UNAVAIL), 7);
1579 f_assignment_exp(ass_cmd, exp_fail, "BSC accepted Assignment for Speech+CTM");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001580 f_shutdown_helper();
Harald Welte235ebf12017-12-15 14:18:16 +01001581}
1582
Harald Welte4003d112017-12-09 22:35:39 +01001583type record DchanTuple {
1584 integer sccp_conn_id,
1585 RslChannelNr rsl_chan_nr
Harald Weltea5d2ab22017-12-09 14:21:42 +01001586}
1587
Harald Welted6939652017-12-13 21:02:46 +01001588/* Send CHAN RQD and wait for allocation; acknowledge it */
1589private function f_chreq_act_ack(OCT1 ra := '23'O, GsmFrameNumber fn := 23)
1590runs on test_CT return RslChannelNr {
1591 var RSL_Message rx_rsl;
1592 f_ipa_tx(0, ts_RSL_CHAN_RQD(ra, fn));
1593 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
1594 var RslChannelNr chan_nr := rx_rsl.ies[0].body.chan_nr;
1595 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, fn+10));
Daniel Willmannf4ac4ce2018-08-02 14:06:30 +02001596 rx_rsl := f_exp_ipa_rx(0, tr_RSL_IMM_ASSIGN(0));
Harald Welted6939652017-12-13 21:02:46 +01001597 return chan_nr;
1598}
1599
Harald Welte4003d112017-12-09 22:35:39 +01001600/* helper function to establish a dedicated channel via BTS and MSC */
1601function f_est_dchan(OCT1 ra, GsmFrameNumber fn, octetstring l3)
1602runs on test_CT return DchanTuple {
1603 var BSSAP_N_CONNECT_ind rx_c_ind;
Harald Welte4003d112017-12-09 22:35:39 +01001604 var DchanTuple dt;
Harald Weltea5d2ab22017-12-09 14:21:42 +01001605
Harald Welte4003d112017-12-09 22:35:39 +01001606 /* Send CHAN RQD and wait for allocation; acknowledge it */
Harald Welted6939652017-12-13 21:02:46 +01001607 dt.rsl_chan_nr := f_chreq_act_ack(ra, fn);
Harald Welte4003d112017-12-09 22:35:39 +01001608
1609 f_ipa_tx(0, ts_RSL_EST_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
1610
1611 BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) -> value rx_c_ind;
1612 dt.sccp_conn_id := rx_c_ind.connectionId;
1613 BSSAP.send(ts_BSSAP_CONNECT_res(dt.sccp_conn_id));
1614
1615 return dt;
Harald Weltea5d2ab22017-12-09 14:21:42 +01001616}
1617
Harald Welte641fcbe2018-06-14 10:58:35 +02001618/* expect RF CAN REL from BTS, acknowledge it and clear the MSC side */
1619private function f_exp_chan_rel_and_clear(DchanTuple dt, integer bts_nr := 0) runs on test_CT {
1620 var RSL_Message rx_rsl;
1621 /* expect BSC to disable the channel */
1622 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), T3101_MAX);
1623 /* respond with CHAN REL ACK */
1624 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(dt.rsl_chan_nr));
1625
1626 /* expect Clear Complete from BSC */
1627 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete));
1628
1629 /* MSC disconnects as instructed. */
1630 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
1631}
1632
Harald Welte4003d112017-12-09 22:35:39 +01001633/* Test behavior of channel release after unilateral RLL REL IND (DISC from MS) */
1634testcase TC_chan_rel_rll_rel_ind() runs on test_CT {
Neels Hofmeyr27f64362018-03-12 01:44:00 +01001635 var BSSAP_N_DATA_ind rx_di;
Harald Welte4003d112017-12-09 22:35:39 +01001636 var DchanTuple dt;
Harald Welte96c94412017-12-09 03:12:45 +01001637
Harald Welte89d42e82017-12-17 16:42:41 +01001638 f_init(1);
Harald Welte96c94412017-12-09 03:12:45 +01001639
Harald Welte4003d112017-12-09 22:35:39 +01001640 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1641
1642 /* simulate RLL REL IND */
1643 f_ipa_tx(0, ts_RSL_REL_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0))));
1644
Neels Hofmeyr27f64362018-03-12 01:44:00 +01001645 /* expect Clear Request on MSC side */
1646 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearRequest)) -> value rx_di;
1647
1648 /* Instruct BSC to clear channel */
1649 var BssmapCause cause := bit2int(rx_di.userData.pdu.bssmap.clearRequest.cause.causeValue);
1650 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
1651
Harald Welte4003d112017-12-09 22:35:39 +01001652 /* expect BSC to disable the channel */
Harald Welte641fcbe2018-06-14 10:58:35 +02001653 f_exp_chan_rel_and_clear(dt, 0);
Neels Hofmeyr27f64362018-03-12 01:44:00 +01001654
1655 /* wait for SCCP emulation to do its job */
1656 f_sleep(1.0);
Harald Welte4003d112017-12-09 22:35:39 +01001657
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001658 f_shutdown_helper();
Harald Welte4003d112017-12-09 22:35:39 +01001659}
1660
1661/* Test behavior of channel release after CONN FAIL IND from BTS */
1662testcase TC_chan_rel_conn_fail() runs on test_CT {
1663 var BSSAP_N_DATA_ind rx_di;
Harald Welte4003d112017-12-09 22:35:39 +01001664 var DchanTuple dt;
1665
Harald Welte89d42e82017-12-17 16:42:41 +01001666 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +01001667
1668 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1669
1670 /* simulate CONN FAIL IND */
Harald Weltea8ed9062017-12-14 09:46:01 +01001671 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 +01001672 /* TODO: different cause values? */
1673
Harald Welte4003d112017-12-09 22:35:39 +01001674 /* expect Clear Request from BSC */
1675 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearRequest)) -> value rx_di;
1676
1677 /* Instruct BSC to clear channel */
1678 var BssmapCause cause := bit2int(rx_di.userData.pdu.bssmap.clearRequest.cause.causeValue);
1679 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
1680
Harald Welte6ff76ea2018-01-28 13:08:01 +01001681 /* expect BSC to disable the channel */
Harald Welte641fcbe2018-06-14 10:58:35 +02001682 f_exp_chan_rel_and_clear(dt, 0);
Harald Welte4003d112017-12-09 22:35:39 +01001683
1684 /* wait for SCCP emulation to do its job */
1685 f_sleep(1.0);
1686
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001687 f_shutdown_helper();
Harald Welte4003d112017-12-09 22:35:39 +01001688}
1689
Harald Welte99f3ca02018-06-14 13:40:29 +02001690/* Test behavior of early CONN FAIL IND from BTS (before EST IND!) */
1691/* See also https://www.osmocom.org/issues/3182 */
1692testcase TC_early_conn_fail() runs on test_CT {
1693 var RSL_Message rx_rsl;
1694 var DchanTuple dt;
1695
1696 f_init(1);
1697
1698 /* BTS->BSC: Send CHAN RQD and wait for allocation; acknowledge it */
Harald Weltec46ea3c2020-10-10 18:46:12 +02001699 dt.rsl_chan_nr := f_chreq_act_ack(f_rnd_ra_cs(), 23);
Harald Welte99f3ca02018-06-14 13:40:29 +02001700
1701 /* BTS->BSC: simulate CONN FAIL IND */
1702 f_ipa_tx(0, ts_RSL_CONN_FAIL_IND(dt.rsl_chan_nr, RSL_ERR_RADIO_LINK_FAIL));
1703
1704 /* BTS->BSC: Expect RF channel release from BSC on Abis */
1705 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), 10.0);
1706
1707 /* BTS<-BSC: respond with CHAN REL ACK */
1708 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(dt.rsl_chan_nr));
1709
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001710 f_shutdown_helper();
Harald Welte99f3ca02018-06-14 13:40:29 +02001711}
1712
1713/* Test behavior of late CONN FAIL IND from BTS (ater REL IND!) */
1714/* See also https://www.osmocom.org/issues/3182 */
1715testcase TC_late_conn_fail() runs on test_CT {
1716 var RSL_Message rx_rsl;
1717 var DchanTuple dt;
1718
1719 f_init(1);
1720
1721 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1722
1723 /* BSC<-MSC: Instruct BSC to clear connection */
1724 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(0)));
1725
1726 /* BTS->BSC: expect BSC to deactivate SACCH */
1727 rx_rsl := f_exp_ipa_rx(0, tr_RSL_DEACT_SACCH(dt.rsl_chan_nr));
1728
1729 /* BTS->BSC: simulate a late CONN FAIL IND from BTS */
1730 f_ipa_tx(0, ts_RSL_CONN_FAIL_IND(dt.rsl_chan_nr, RSL_ERR_RADIO_LINK_FAIL));
1731
1732 /* BTS<-BSC: Expect RF channel release from BSC on Abis */
1733 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), 10.0);
1734 /* BTS->BSC: respond with CHAN REL ACK */
1735 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(dt.rsl_chan_nr));
1736
1737 /* BSC->MSC: expect Clear Complete from BSC */
1738 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete));
1739
1740 /* BSC<-MSC: MSC disconnects as requested. */
1741 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
1742
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001743 f_shutdown_helper();
Harald Welte99f3ca02018-06-14 13:40:29 +02001744}
1745
Neels Hofmeyrf44ccd12018-11-05 19:15:23 +01001746function f_expect_chan_rel(integer bts_nr, RslChannelNr rsl_chan_nr,
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001747 boolean expect_deact_sacch := true,
1748 boolean expect_rr_chan_rel := true,
1749 boolean expect_rll_rel_req := true,
Harald Welte99787102019-02-04 10:41:36 +01001750 boolean handle_rll_rel := true,
Pau Espin Pedrol36bd4fa2021-04-15 13:00:24 +02001751 template CellSelIndValue expect_cells := omit,
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02001752 template RR_Cause expect_rr_cause := ?
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001753 ) runs on test_CT {
Harald Welte91d54a52018-01-28 15:35:07 +01001754
1755 var RslLinkId main_dcch := valueof(ts_RslLinkID_DCCH(0));
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001756 var boolean got_deact_sacch := false;
1757 var boolean got_rr_chan_rel := false;
1758 var boolean got_rll_rel_req := false;
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02001759 var ASP_RSL_Unitdata ud;
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02001760 var RSL_IE_Body l3_ie;
1761 var PDU_ML3_NW_MS l3;
1762 var RR_Cause got_cause;
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001763 log("f_expect_chan_rel() expecting: expect_deact_sacch=", expect_deact_sacch, " expect_rr_chan_rel=", expect_rr_chan_rel,
1764 " expect_rll_rel_req=", expect_rll_rel_req);
Harald Welte91d54a52018-01-28 15:35:07 +01001765 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001766 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(tr_RSL_DEACT_SACCH(rsl_chan_nr))) {
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001767 got_deact_sacch := true;
Harald Welte91d54a52018-01-28 15:35:07 +01001768 repeat;
1769 }
Pau Espin Pedrol841b90d2021-04-15 16:42:52 +02001770 [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 +01001771 got_rr_chan_rel := true;
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02001772
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02001773 if (f_rsl_find_ie(ud.rsl, RSL_IE_L3_INFO, l3_ie) == false) {
1774 setverdict(fail, "cannot find L3");
1775 mtc.stop;
1776 }
1777 l3 := dec_PDU_ML3_NW_MS(l3_ie.l3_info.payload);
1778
Pau Espin Pedrol36bd4fa2021-04-15 13:00:24 +02001779 if (not istemplatekind(expect_cells, "omit")) {
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02001780 var CellSelIndValue cells := dec_CellSelIndValue(
1781 l3.msgs.rrm.channelRelease.cellSelectionIndicator.cellSelectionIndicatorValue);
1782
Pau Espin Pedrol36bd4fa2021-04-15 13:00:24 +02001783 log("GOT RR CHANNEL RELEASE WITH CELLS: ", cells);
1784 if (match(cells, expect_cells)) {
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02001785 setverdict(pass);
1786 } else {
Pau Espin Pedrol36bd4fa2021-04-15 13:00:24 +02001787 log("EXPECTED CELLS: ", expect_cells);
1788 setverdict(fail, "Received cells list on RR Channel Release does not match expectations");
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02001789 }
1790 }
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02001791
1792 if (not istemplatekind(expect_rr_cause, "omit")) {
1793 int2enum(oct2int(l3.msgs.rrm.channelRelease.rRCause.valuePart), got_cause);
1794 log("GOT CAUSE CODE: ", l3.msgs.rrm.channelRelease.rRCause.valuePart, " = ", got_cause);
1795 if (match(got_cause, expect_rr_cause)) {
1796 setverdict(pass);
1797 } else {
1798 log("EXPECTED CAUSE CODE: ", expect_rr_cause);
1799 setverdict(fail, "Received RR Channel Release Cause code does not match expectations");
1800 }
1801 }
Harald Welte99787102019-02-04 10:41:36 +01001802 repeat;
1803 }
Pau Espin Pedrol841b90d2021-04-15 16:42:52 +02001804 [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 +01001805 got_rr_chan_rel := true;
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02001806
1807 if (not istemplatekind(expect_rr_cause, "omit")) {
1808 if (f_rsl_find_ie(ud.rsl, RSL_IE_L3_INFO, l3_ie) == false) {
1809 setverdict(fail, "cannot find L3");
1810 mtc.stop;
1811 }
1812 l3 := dec_PDU_ML3_NW_MS(l3_ie.l3_info.payload);
1813
1814 int2enum(oct2int(l3.msgs.rrm.channelRelease.rRCause.valuePart), got_cause);
1815 log("GOT CAUSE CODE: ", l3.msgs.rrm.channelRelease.rRCause.valuePart, " = ", got_cause);
1816 if (match(got_cause, expect_rr_cause)) {
1817 setverdict(pass);
1818 } else {
1819 log("EXPECTED CAUSE CODE: ", expect_rr_cause);
1820 setverdict(fail, "Received RR Channel Release Cause code does not match expectations");
1821 }
1822 }
Neels Hofmeyr211169d2018-11-07 00:37:29 +01001823 repeat;
1824 }
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001825 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(tr_RSL_REL_REQ(rsl_chan_nr, ?))) {
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001826 got_rll_rel_req := true;
Harald Welte91d54a52018-01-28 15:35:07 +01001827 /* FIXME: Why are we getting this for LinkID SACCH? */
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001828 if (handle_rll_rel) {
1829 f_ipa_tx(0, ts_RSL_REL_CONF(rsl_chan_nr, main_dcch));
1830 }
Harald Welte91d54a52018-01-28 15:35:07 +01001831 repeat;
1832 }
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001833 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL))) {
Harald Welte91d54a52018-01-28 15:35:07 +01001834 /* respond with CHAN REL ACK */
1835 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(rsl_chan_nr));
1836 }
1837 /* ignore any user data */
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001838 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(tr_RSL_MsgTypeR(?))) {
Harald Welte91d54a52018-01-28 15:35:07 +01001839 repeat;
1840 }
1841 }
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001842
1843 log("f_expect_chan_rel() summary: got_deact_sacch=", got_deact_sacch, " got_rr_chan_rel=", got_rr_chan_rel,
1844 " got_rll_rel_req=", got_rll_rel_req);
1845
1846 if (expect_deact_sacch != got_deact_sacch) {
1847 setverdict(fail, "f_expect_chan_rel(): expect_deact_sacch=", expect_deact_sacch, " got_deact_sacch=", got_deact_sacch);
1848 }
1849 if (expect_rr_chan_rel != got_rr_chan_rel) {
1850 setverdict(fail, "f_expect_chan_rel(): expect_rr_chan_rel=", expect_rr_chan_rel, " got_rr_chan_rel=", got_rr_chan_rel);
1851 }
1852 if (expect_rll_rel_req != got_rll_rel_req) {
1853 setverdict(fail, "f_expect_chan_rel(): expect_rll_rel_req=", expect_rll_rel_req, " got_rll_rel_req=", got_rll_rel_req);
1854 }
Harald Welte91d54a52018-01-28 15:35:07 +01001855}
1856
Harald Welte4003d112017-12-09 22:35:39 +01001857/* Test behavior of channel release after hard Clear Command from MSC */
1858testcase TC_chan_rel_hard_clear() runs on test_CT {
1859 var BSSAP_N_DATA_ind rx_di;
Harald Welte4003d112017-12-09 22:35:39 +01001860 var DchanTuple dt;
Harald Welte4003d112017-12-09 22:35:39 +01001861
Harald Welte89d42e82017-12-17 16:42:41 +01001862 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +01001863
1864 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1865
1866 /* Instruct BSC to clear channel */
1867 var BssmapCause cause := 0;
1868 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
1869
1870 /* expect Clear Complete from BSC on A */
1871 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete)) {
1872 /* release the SCCP connection */
1873 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
1874 }
1875
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001876 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001877 f_shutdown_helper();
Harald Welte4003d112017-12-09 22:35:39 +01001878}
1879
Pau Espin Pedrol841b90d2021-04-15 16:42:52 +02001880function f_TC_chan_rel_last_eutran_plmn_hard_clear(boolean tx_csfb_ind) runs on test_CT {
1881 var BSSAP_N_DATA_ind rx_di;
1882 var DchanTuple dt;
1883
1884 f_init(1);
1885
1886 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1887 /* Send CommonID with some random PLMN (BSC doesn't take it into account
1888 /* yet when generating the EUTRAN neigh list in RR CHannel Release) */
1889 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_CommonId('001019876543210'H, '323454'O)));
1890
1891 /* Instruct BSC to clear channel */
1892 var BssmapCause cause := 0;
1893 if (tx_csfb_ind) {
1894 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommandCSFB(cause)));
1895 } else {
1896 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
1897 }
1898
1899 /* expect Clear Complete from BSC on A */
1900 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete)) {
1901 /* release the SCCP connection */
1902 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
1903 }
1904
1905 /* 1 neighbor is added by default in osmo-bts.cfg and
1906 SystemInformationConfig_default, use that: */
1907 var template CellSelIndValue exp_cells := f_tr_rr_chan_rel_earfcns(1);
1908
1909 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false, expect_cells := exp_cells);
1910 f_shutdown_helper();
1911}
1912
1913/* Test behavior of RR Channel rRelease after Clear Command without CSFB indicator
1914 from MSC, previously receiving any CommonID containing the "Last Used E-UTRAN
1915 PLMN Id". According to spec (3GPP TS 48.008 sec 3.1.30) that's the bit requesting
1916 EUTRAN neighbor list sent later on by BSC in RR Channel, so receiving CSFB
1917 Indicator or not shouldn't matter at all. */
1918testcase TC_chan_rel_last_eutran_plmn_hard_clear_no_csfb() runs on test_CT {
1919 f_TC_chan_rel_last_eutran_plmn_hard_clear(false);
1920}
1921
1922/* Test behavior of RR Channel rRelease after Clear Command with CSFB indicator from
1923 MSC, previously receiving any CommonID containing the "Last Used E-UTRAN PLMN
1924 Id". According to spec (3GPP TS 48.008 sec 3.1.30) that's the bit requesting
1925 EUTRAN neighbor list sent later on by BSC in RR Channel. */
1926testcase TC_chan_rel_last_eutran_plmn_hard_clear_csfb() runs on test_CT {
1927 f_TC_chan_rel_last_eutran_plmn_hard_clear(true);
1928}
1929
1930/* Test behavior of RR Channel Release after Clear Command with CSFB indicator from
1931 MSC, without receiving any CommonID containing the "Last Used E-UTRAN PLMN
1932 Id". According to spec (TS 48.008 version 16.0.0 Release 16 "3.2.1.21") the
1933 CSFB Indicator should not be used anymore, and hence, there should be no
1934 EUTRAN neighbor list sent by BSC in RR Channel release since no CommonId with
1935 Last Used E-UTRAN PLMN Id" IE was sent for this conn. */
Harald Welte99787102019-02-04 10:41:36 +01001936testcase TC_chan_rel_hard_clear_csfb() runs on test_CT {
1937 var BSSAP_N_DATA_ind rx_di;
1938 var DchanTuple dt;
1939
1940 f_init(1);
1941
1942 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1943
1944 /* Instruct BSC to clear channel */
1945 var BssmapCause cause := 0;
1946 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommandCSFB(cause)));
1947
1948 /* expect Clear Complete from BSC on A */
1949 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete)) {
1950 /* release the SCCP connection */
1951 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
1952 }
1953
Pau Espin Pedrol841b90d2021-04-15 16:42:52 +02001954 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001955 f_shutdown_helper();
Harald Welte99787102019-02-04 10:41:36 +01001956}
1957
Harald Welted8c36cd2017-12-09 23:05:31 +01001958/* Test behavior of channel release after hard RLSD from MSC */
1959testcase TC_chan_rel_hard_rlsd() runs on test_CT {
Harald Welted8c36cd2017-12-09 23:05:31 +01001960 var DchanTuple dt;
Harald Welted8c36cd2017-12-09 23:05:31 +01001961
Harald Welte89d42e82017-12-17 16:42:41 +01001962 f_init(1);
Harald Welted8c36cd2017-12-09 23:05:31 +01001963
1964 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1965
1966 /* release the SCCP connection */
1967 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
1968
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001969 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001970 f_shutdown_helper();
Harald Welted8c36cd2017-12-09 23:05:31 +01001971}
1972
Harald Welte550daf92018-06-11 19:22:13 +02001973/* Test behavior of channel release after hard RLSD from MSC and MS is not responding to RLL REL REQ */
1974testcase TC_chan_rel_hard_rlsd_ms_dead() runs on test_CT {
1975 var DchanTuple dt;
1976
1977 f_init(1);
1978
1979 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1980
1981 /* release the SCCP connection */
1982 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
1983
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001984 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001985 f_shutdown_helper();
Harald Welte550daf92018-06-11 19:22:13 +02001986}
1987
Harald Welte85804d42017-12-10 14:11:58 +01001988/* Test behavior of channel release after BSSMAP RESET from MSC */
1989testcase TC_chan_rel_a_reset() runs on test_CT {
Harald Welte85804d42017-12-10 14:11:58 +01001990 var DchanTuple dt;
Harald Welte85804d42017-12-10 14:11:58 +01001991
Harald Welte89d42e82017-12-17 16:42:41 +01001992 f_init(1);
Harald Welte85804d42017-12-10 14:11:58 +01001993
1994 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1995
1996 /* Clear the queue, it might still contain stuff like IMMEDIATE ASSIGN */
1997 IPA_RSL[0].clear;
1998
1999 /* perform BSSAP RESET, expect RESET ACK and DISC.ind on connection */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02002000 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 +01002001 interleave {
Neels Hofmeyrf246a922020-05-13 02:27:10 +02002002 [] 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 +01002003 [] BSSAP.receive(tr_BSSAP_DISC_ind(dt.sccp_conn_id, ?, ?)) { }
2004 }
2005
Neels Hofmeyra5302c82018-11-04 23:09:58 +01002006 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002007 f_shutdown_helper();
Harald Welte85804d42017-12-10 14:11:58 +01002008}
2009
Pau Espin Pedrolc675b612020-01-09 19:55:40 +01002010/* Verify T(iar) triggers and releases the channel */
2011testcase TC_chan_rel_sccp_tiar_timeout() runs on test_CT {
2012 var DchanTuple dt;
2013
2014 /* Set T(iar) in BSC low enough that it will trigger before other side
2015 has time to keep alive with a T(ias). Keep recommended ratio of
2016 T(iar) >= T(ias)*2 */
2017 g_bsc_sccp_timer_ias := 2;
2018 g_bsc_sccp_timer_iar := 5;
2019
2020 f_init(1);
2021
2022 dt := f_est_dchan('23'O, 23, '00010203040506'O);
2023 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002024 f_shutdown_helper();
Pau Espin Pedrolc675b612020-01-09 19:55:40 +01002025}
2026
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02002027private function f_tc_chan_rel_rr_cause(myBSSMAP_Cause clear_cmd_cause, template RR_Cause expect_rr_cause)
2028runs on test_CT
2029{
2030 var DchanTuple dt;
2031
2032 dt := f_est_dchan('23'O, 23, '00010203040506'O);
2033 var BssmapCause cause := 0;
2034 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(enum2int(clear_cmd_cause))));
2035 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete)) {
2036 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
2037 }
2038
2039 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 +02002040}
2041
2042/* Test that Clear Command cause codes affect the RR Channel Release cause code */
2043testcase TC_chan_rel_rr_cause() runs on test_CT {
2044 f_init(1);
2045
2046 f_tc_chan_rel_rr_cause(GSM0808_CAUSE_CALL_CONTROL, GSM48_RR_CAUSE_NORMAL);
2047 f_tc_chan_rel_rr_cause(GSM0808_CAUSE_HANDOVER_SUCCESSFUL, GSM48_RR_CAUSE_NORMAL);
2048 f_tc_chan_rel_rr_cause(GSM0808_CAUSE_PREEMPTION, GSM48_RR_CAUSE_PREMPTIVE_REL);
2049 f_tc_chan_rel_rr_cause(GSM0808_CAUSE_RADIO_INTERFACE_MESSAGE_FAILURE, GSM48_RR_CAUSE_PROT_ERROR_UNSPC);
2050 f_tc_chan_rel_rr_cause(GSM0808_CAUSE_RADIO_INTERFACE_FAILURE, GSM48_RR_CAUSE_ABNORMAL_UNSPEC);
2051 f_tc_chan_rel_rr_cause(GSM0808_CAUSE_EQUIPMENT_FAILURE, GSM48_RR_CAUSE_ABNORMAL_UNSPEC);
Vadim Yanitskiye18aebb2021-01-03 13:10:43 +01002052
2053 f_shutdown_helper();
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02002054}
2055
Harald Welte5cd20ed2017-12-13 21:03:20 +01002056/* Test behavior if RSL EST IND for non-active channel */
2057testcase TC_rll_est_ind_inact_lchan() runs on test_CT {
2058 timer T := 2.0;
2059
Harald Welte89d42e82017-12-17 16:42:41 +01002060 f_init(1);
Harald Welte5cd20ed2017-12-13 21:03:20 +01002061
2062 var octetstring l3 := '00010203040506'O;
2063 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(6));
2064 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
2065
2066 T.start;
2067 alt {
2068 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) {
2069 setverdict(fail, "MSC received COMPL L3 for non-active lchan");
2070 }
2071 [] BSSAP.receive {}
2072 [] IPA_RSL[0].receive {}
2073 [] T.timeout {}
2074 }
2075
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002076 f_shutdown_helper();
Harald Welte5cd20ed2017-12-13 21:03:20 +01002077}
2078
2079/* Test behavior if RSL EST IND for invalid SAPI */
2080testcase TC_rll_est_ind_inval_sapi1() runs on test_CT {
2081 var RslChannelNr chan_nr;
2082
Harald Welte89d42e82017-12-17 16:42:41 +01002083 f_init(1);
Harald Welte5cd20ed2017-12-13 21:03:20 +01002084
2085 chan_nr := f_chreq_act_ack()
2086
2087 var octetstring l3 := '00010203040506'O;
2088 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(1)), l3));
2089
2090 timer T := 2.0;
2091 T.start;
2092 alt {
2093 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) {
2094 setverdict(fail, "MSC received COMPL L3 for invalid SAPI 1");
2095 }
2096 [] BSSAP.receive { repeat; }
2097 [] IPA_RSL[0].receive { repeat; }
2098 [] T.timeout {}
2099 }
2100
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002101 f_shutdown_helper();
Harald Welte5cd20ed2017-12-13 21:03:20 +01002102}
2103
2104/* Test behavior if RSL EST IND for invalid SAPI */
2105testcase TC_rll_est_ind_inval_sapi3() runs on test_CT {
2106 timer T := 2.0;
2107
Harald Welte89d42e82017-12-17 16:42:41 +01002108 f_init(1);
Harald Welte5cd20ed2017-12-13 21:03:20 +01002109
2110 var RslChannelNr chan_nr := f_chreq_act_ack();
2111
2112 var octetstring l3 := '00010203040506'O;
2113 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(3)), l3));
2114
2115 T.start;
2116 alt {
2117 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) {
2118 setverdict(fail, "MSC received COMPL L3 for invalid SAPI 3");
2119 }
2120 [] BSSAP.receive { repeat; }
2121 [] IPA_RSL[0].receive { repeat; }
2122 [] T.timeout {}
2123 }
2124
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002125 f_shutdown_helper();
Harald Welte5cd20ed2017-12-13 21:03:20 +01002126}
2127
2128/* Test behavior if RSL EST IND for invalid SACCH */
2129testcase TC_rll_est_ind_inval_sacch() runs on test_CT {
2130 timer T := 2.0;
2131
Harald Welte89d42e82017-12-17 16:42:41 +01002132 f_init(1);
Harald Welte5cd20ed2017-12-13 21:03:20 +01002133
2134 var RslChannelNr chan_nr := f_chreq_act_ack();
2135
2136 var octetstring l3 := '00010203040506'O;
2137 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_SACCH(0)), l3));
2138
2139 T.start;
2140 alt {
2141 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) {
2142 setverdict(fail, "MSC received COMPL L3 for invalid Link SACCH");
2143 }
2144 [] BSSAP.receive { repeat; }
2145 [] IPA_RSL[0].receive { repeat; }
2146 [] T.timeout {}
2147 }
2148
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002149 f_shutdown_helper();
Harald Welte5cd20ed2017-12-13 21:03:20 +01002150}
2151
Vadim Yanitskiy61f784a2020-10-01 21:12:19 +07002152/* Verify DLCI / RSL Link ID conversion for MO/MT messages on SAPI0/SAPI3 */
2153private function f_TC_tch_dlci_link_id_sapi(charstring id) runs on MSC_ConnHdlr {
2154 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
2155 var PDU_BSSAP ass_cmd := f_gen_ass_req();
2156
2157 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
2158 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
2159
2160 f_establish_fully(ass_cmd, exp_compl);
2161
2162 /* SAPI0 has already been established by f_establish_fully(), establish SAPI3 */
2163 RSL.send(ts_RSL_EST_IND(g_chan_nr, ts_RslLinkID_SACCH(3), '0904'O));
2164 /* Expect BSSAP/DTAP on SAPI3 (DLCI IE) */
2165 BSSAP.receive(PDU_BSSAP:{
2166 discriminator := '1'B,
2167 spare := '0000000'B,
2168 dlci := 'C3'O,
2169 lengthIndicator := ?,
2170 pdu := { dtap := '0904'O }
2171 });
2172
2173 /* Send messages on DCCH/SAPI0 and ACCH/SAPI3 */
2174 for (var integer i := 0; i < 32; i := i + 1) {
2175 var octetstring l3 := '09'O & f_rnd_octstring(14);
2176 var template (value) RslLinkId link_id;
2177 var template (value) OCT1 dlci;
2178
2179 if (i mod 2 == 0) {
2180 /* SAPI0 on FACCH or SDCCH */
2181 link_id := ts_RslLinkID_DCCH(0);
2182 dlci := '80'O;
2183 } else {
2184 /* SAPI3 on SACCH */
2185 link_id := ts_RslLinkID_SACCH(3);
2186 dlci := 'C3'O;
2187 }
2188
2189 /* Send MO message: RSL -> BSSAP */
Neels Hofmeyr0aa719b2020-10-12 18:43:09 +00002190 f_mo_l3_transceive(RSL, link_id, dlci, l3);
Vadim Yanitskiy61f784a2020-10-01 21:12:19 +07002191 /* Send MT message: BSSAP -> RSL */
Neels Hofmeyr0aa719b2020-10-12 18:43:09 +00002192 f_mt_l3_transceive(RSL, link_id, dlci, l3);
Vadim Yanitskiy61f784a2020-10-01 21:12:19 +07002193 }
2194}
2195testcase TC_tch_dlci_link_id_sapi() runs on test_CT {
2196 var TestHdlrParams pars := f_gen_test_hdlr_pars();
2197 var MSC_ConnHdlr vc_conn;
2198
2199 f_init(1, true);
2200 f_sleep(1.0);
2201
2202 vc_conn := f_start_handler(refers(f_TC_tch_dlci_link_id_sapi), pars);
2203 vc_conn.done;
2204
2205 f_shutdown_helper();
2206}
2207
Vadim Yanitskiy6ef5dfa2020-08-28 18:04:41 +07002208private function f_exp_sapi_n_reject(template (present) GsmSapi sapi := ?,
2209 template myBSSMAP_Cause cause := ?,
2210 float T_val := 2.0)
2211runs on test_CT {
2212 var BSSAP_N_DATA_ind rx_di;
2213 timer T;
2214
2215 var template BSSMAP_IE_Cause tr_cause := tr_BSSMAP_IE_Cause(cause);
2216 var template PDU_BSSAP tr_pdu := tr_BSSMAP_SAPInReject(sapi);
2217
2218 T.start(T_val);
2219 alt {
2220 [] BSSAP.receive(tr_BSSAP_DATA_ind(?, tr_pdu)) -> value rx_di {
2221 var BSSMAP_IE_Cause rx_cause := rx_di.userData.pdu.bssmap.sAPInReject.cause;
2222 if (not match(rx_cause, tr_cause)) {
2223 setverdict(fail, "Rx unexpected Cause IE: ",
2224 rx_cause, " vs expected ", tr_cause);
2225 }
2226 setverdict(pass);
2227 }
2228 [] BSSAP.receive(BSSAP_N_DATA_ind:?) -> value rx_di {
2229 setverdict(fail, "Rx unexpected BSSAP PDU: ", rx_di);
2230 }
2231 [] T.timeout {
2232 setverdict(fail, "Timeout waiting for BSSMAP SAPI N Reject");
2233 }
2234 }
2235}
2236
2237/* Check if we get SAPI N Reject on receipt of unexpected RLL RELease INDication */
2238testcase TC_rll_rel_ind_sapi_n_reject() runs on test_CT {
2239 var octetstring rnd_data := f_rnd_octstring(16);
2240 var RSL_Message rx_rsl;
2241 var DchanTuple dt;
2242
2243 f_init(1);
2244
2245 /* MS establishes a SAPI=0 link on DCCH */
2246 dt := f_est_dchan(f_rnd_ra_cs(), 23, rnd_data);
2247
2248 /* MSC sends some data on (not yet established) SAPI=3 link */
2249 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSAP_DTAP(rnd_data, '03'O)));
2250 /* BSC attempts to establish a SAPI=3 link on DCCH */
2251 rx_rsl := f_exp_ipa_rx(0, tr_RSL_EST_REQ(dt.rsl_chan_nr, tr_RslLinkID_DCCH(3)));
2252
2253 /* MS sends unexpected RELease INDication on SAPI=3 */
2254 f_ipa_tx(0, ts_RSL_REL_IND(dt.rsl_chan_nr, ts_RslLinkID_DCCH(3)));
2255 /* We expect to receive BSSMAP SAPI N Reject message from the BSC */
2256 f_exp_sapi_n_reject(3, GSM0808_CAUSE_MS_NOT_EQUIPPED);
2257
2258 /* Clean up the connection */
2259 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
2260 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
2261
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002262 f_shutdown_helper();
Vadim Yanitskiy6ef5dfa2020-08-28 18:04:41 +07002263}
2264
2265/* Check if we get SAPI N Reject on receipt of unexpected RLL ERROR INDication */
2266testcase TC_rll_err_ind_sapi_n_reject() runs on test_CT {
2267 var octetstring rnd_data := f_rnd_octstring(16);
2268 var RSL_Message rx_rsl;
2269 var DchanTuple dt;
2270
2271 f_init(1);
2272
2273 /* MS establishes a SAPI=0 link on DCCH */
2274 dt := f_est_dchan(f_rnd_ra_cs(), 23, rnd_data);
2275
2276 /* MSC sends some data on (not yet established) SAPI=3 link */
2277 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSAP_DTAP(rnd_data, '03'O)));
2278 /* BSC attempts to establish a SAPI=3 link on DCCH */
2279 rx_rsl := f_exp_ipa_rx(0, tr_RSL_EST_REQ(dt.rsl_chan_nr, tr_RslLinkID_DCCH(3)));
2280
2281 /* BTS sends unexpected ERROR INDication on SAPI=3 */
2282 f_ipa_tx(0, ts_RSL_ERROR_IND(dt.rsl_chan_nr, ts_RslLinkID_DCCH(3), ''O));
2283 /* We expect to receive BSSMAP SAPI N Reject message from the BSC */
2284 f_exp_sapi_n_reject(3, GSM0808_CAUSE_BSS_NOT_EQUIPPED);
2285
2286 /* Clean up the connection */
2287 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
2288 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
2289
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002290 f_shutdown_helper();
Vadim Yanitskiy6ef5dfa2020-08-28 18:04:41 +07002291}
2292
2293/* Check if we get SAPI N Reject due to a SAPI=3 link establishment timeout */
2294testcase TC_rll_timeout_sapi_n_reject() runs on test_CT {
2295 var octetstring rnd_data := f_rnd_octstring(16);
2296 var RSL_Message rx_rsl;
2297 var DchanTuple dt;
2298
2299 f_init(1);
2300
2301 /* MS establishes a SAPI=0 link on DCCH */
2302 dt := f_est_dchan(f_rnd_ra_cs(), 23, rnd_data);
2303
2304 /* MSC sends some data on (not yet established) SAPI=3 link */
2305 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSAP_DTAP(rnd_data, '03'O)));
2306 /* BSC attempts to establish a SAPI=3 link on DCCH */
2307 rx_rsl := f_exp_ipa_rx(0, tr_RSL_EST_REQ(dt.rsl_chan_nr, tr_RslLinkID_DCCH(3)));
2308
2309 /* MS does not respond, so the link establishment timeout triggers SAPI N Reject */
2310 f_exp_sapi_n_reject(3, GSM0808_CAUSE_BSS_NOT_EQUIPPED, T_val := 8.0);
2311
2312 /* Clean up the connection */
2313 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
2314 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
2315
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002316 f_shutdown_helper();
Vadim Yanitskiy6ef5dfa2020-08-28 18:04:41 +07002317}
2318
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +02002319testcase TC_si_default() runs on test_CT {
2320 f_init(0);
2321 f_init_bts_and_check_sysinfo(0, expect_si := SystemInformationConfig_default);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002322 f_shutdown_helper();
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +02002323}
Harald Welte4003d112017-12-09 22:35:39 +01002324
Neels Hofmeyr56f24782020-07-09 00:50:49 +02002325/* We're testing SI2quater with lists of EARFCNs. Instead of just incrementing EARFCNs, also pick some from the edges of
2326 * the entire value range. This function provides the same EARFCN numbers for the same earfcn_index */
2327private function f_test_si2quater_earfcn_by_idx(integer earfcn_index) return uint16_t
2328{
2329 select (earfcn_index) {
2330 case (0) {
2331 /* E-ARFCN 111 is already added in the osmo-bsc.cfg */
2332 return 111;
2333 }
2334 case (1) {
2335 return 1;
2336 }
2337 case (2) {
2338 return 0;
2339 }
2340 case (3) {
2341 return 65535;
2342 }
2343 case else {
2344 return 23 * (earfcn_index - 3);
2345 }
2346 }
2347}
2348
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02002349function f_test_si2quater(integer total_earfcns, template SystemInformationConfig expect_si,
2350 template CellSelIndValue expect_cells := omit) runs on test_CT {
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002351
2352 f_init(0);
2353
2354 /* E-ARFCN 111 is already added in the osmo-bsc.cfg, so only add more arfcns if total_earfcns > 1 */
2355 for (var integer i := 1; i < total_earfcns; i := i + 1) {
Neels Hofmeyr56f24782020-07-09 00:50:49 +02002356 f_bts_0_cfg(BSCVTY, {"si2quater neighbor-list add earfcn " & int2str(f_test_si2quater_earfcn_by_idx(i))
2357 & " thresh-hi 20 thresh-lo 10 prio 3 qrxlv 22 meas 3"});
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002358 }
2359
2360 f_init_bts_and_check_sysinfo(0, expect_si := expect_si);
2361
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02002362 if (not istemplatekind(expect_cells, "omit")) {
2363 /* Also check that RR Channel Release contains these EARFCNs.
2364 * (copied code from TC_chan_rel_hard_clear_csfb) */
2365 var BSSAP_N_DATA_ind rx_di;
2366 var DchanTuple dt;
2367
2368 dt := f_est_dchan('23'O, 23, '00010203040506'O);
Pau Espin Pedrold0046312021-04-19 16:35:58 +02002369 /* Send CommonID with some random PLMN (BSC doesn't take it into account
2370 * yet when generating the EUTRAN neigh list in RR CHannel Release) */
2371 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_CommonId('001019876543210'H, '323454'O)));
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02002372
2373 /* Instruct BSC to clear channel */
2374 var BssmapCause cause := 0;
2375 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommandCSFB(cause)));
2376
2377 /* expect Clear Complete from BSC on A */
2378 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete)) {
2379 /* release the SCCP connection */
2380 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
2381 }
2382
Pau Espin Pedrol841b90d2021-04-15 16:42:52 +02002383 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 +02002384 }
2385
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002386 for (var integer i := 1; i < total_earfcns; i := i + 1) {
Neels Hofmeyr56f24782020-07-09 00:50:49 +02002387 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 +02002388 }
2389}
2390
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002391private function f_tr_si2quater_earfcns(integer count) return template SI2quaterRestOctetsList
2392{
2393 var template SI2quaterRestOctetsList si2quater := {};
2394 var integer si2quater_count := (count + 2) / 3;
2395
2396 for (var integer i := 0; i < count; i := i + 1) {
Neels Hofmeyr56f24782020-07-09 00:50:49 +02002397 var integer earfcn := f_test_si2quater_earfcn_by_idx(i);
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002398 var integer index := i / 3;
2399 var integer earfcn_index := i mod 3;
2400 if (index >= lengthof(si2quater)) {
2401 si2quater[index] := tr_SI2quaterRestOctets_EUTRAN(index := index, count := si2quater_count - 1);
2402 }
2403 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);
2404 }
2405
2406 return si2quater;
2407}
2408
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02002409private function f_tr_rr_chan_rel_earfcns(integer count) return template CellSelIndValue
2410{
2411 var template CellSelIndValue_EUTRAN_Descrs cells := {};
2412
Alexander Couzensf74b5cb2020-09-10 22:28:40 +02002413 /* the lte neighbors must match the config & vty to pass this test */
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02002414 for (var integer i := 0; i < count; i := i + 1) {
2415 var integer earfcn := f_test_si2quater_earfcn_by_idx(i);
Alexander Couzensf74b5cb2020-09-10 22:28:40 +02002416 cells[i] := tr_CellSelIndValue_EUTRAN_Descr(earfcn, '1'B, 3);
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02002417 }
2418
2419 return tr_CellSelIndValue_EUTRAN(cells);
2420}
2421
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002422private function f_tc_si2quater_n_earfcns(integer n) runs on test_CT
2423{
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002424 var template SystemInformationConfig sic := SystemInformationConfig_default;
Pau Espin Pedrol8ab62e42020-12-18 16:19:11 +01002425 sic.si2quater := f_tr_si2quater_earfcns(n);
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02002426 var template CellSelIndValue cells := f_tr_rr_chan_rel_earfcns(n);
2427 f_test_si2quater(n, sic, cells);
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002428}
2429
2430testcase TC_si2quater_2_earfcns() runs on test_CT {
2431 f_tc_si2quater_n_earfcns(2);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002432 f_shutdown_helper();
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002433}
2434
2435testcase TC_si2quater_3_earfcns() runs on test_CT {
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002436 f_tc_si2quater_n_earfcns(3);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002437 f_shutdown_helper();
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002438}
2439
2440testcase TC_si2quater_4_earfcns() runs on test_CT {
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002441 f_tc_si2quater_n_earfcns(4);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002442 f_shutdown_helper();
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002443}
2444
2445testcase TC_si2quater_5_earfcns() runs on test_CT {
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002446 f_tc_si2quater_n_earfcns(5);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002447 f_shutdown_helper();
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002448}
2449
2450testcase TC_si2quater_6_earfcns() runs on test_CT {
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002451 f_tc_si2quater_n_earfcns(6);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002452 f_shutdown_helper();
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002453}
2454
2455testcase TC_si2quater_12_earfcns() runs on test_CT {
2456 f_tc_si2quater_n_earfcns(12);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002457 f_shutdown_helper();
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002458}
2459
2460testcase TC_si2quater_23_earfcns() runs on test_CT {
2461 f_tc_si2quater_n_earfcns(23);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002462 f_shutdown_helper();
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002463}
2464
2465testcase TC_si2quater_32_earfcns() runs on test_CT {
2466 f_tc_si2quater_n_earfcns(32);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002467 f_shutdown_helper();
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002468}
2469
2470testcase TC_si2quater_33_earfcns() runs on test_CT {
2471 f_tc_si2quater_n_earfcns(33);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002472 f_shutdown_helper();
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002473}
2474
2475testcase TC_si2quater_42_earfcns() runs on test_CT {
2476 f_tc_si2quater_n_earfcns(42);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002477 f_shutdown_helper();
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002478}
2479
2480testcase TC_si2quater_48_earfcns() runs on test_CT {
2481 f_tc_si2quater_n_earfcns(48);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002482 f_shutdown_helper();
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002483}
2484
2485/* verify the VTY error response when adding too many EARFCNs, and showing that osmo-bsc still sends 16 SI2quater with
2486 * 48 EARFCNs. */
2487testcase TC_si2quater_49_earfcns() runs on test_CT {
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002488 var template SystemInformationConfig sic := SystemInformationConfig_default;
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002489 sic.si2quater := f_tr_si2quater_earfcns(48); /* 48, not 49! */
2490 f_init(0);
2491
2492 for (var integer i := 1; i < 48; i := i + 1) {
Neels Hofmeyr56f24782020-07-09 00:50:49 +02002493 f_bts_0_cfg(BSCVTY, {"si2quater neighbor-list add earfcn " & int2str(f_test_si2quater_earfcn_by_idx(i))
2494 & " thresh-hi 20 thresh-lo 10 prio 3 qrxlv 22 meas 3"});
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002495 }
2496
2497 /* The 49th EARFCN no longer fits, expect VTY error */
2498 f_vty_enter_cfg_bts(BSCVTY, 0);
2499 var charstring vty_error;
2500 vty_error := f_vty_transceive_ret(BSCVTY,
2501 "si2quater neighbor-list add earfcn 70 thresh-hi 20 thresh-lo 10 prio 3 qrxlv 22 meas 3")
2502 f_vty_transceive(BSCVTY, "end");
2503
2504 if (f_strstr(vty_error, "Unable to add ARFCN 70") >= 0) {
2505 log("Got expected VTY error: ", vty_error);
2506 setverdict(pass);
2507 } else {
2508 setverdict(fail, "Expected the 49th EUTRAN ARFCN to be rejected by vty config, got: ", vty_error);
2509 }
2510
2511 f_init_bts_and_check_sysinfo(0, expect_si := sic);
2512
2513 for (var integer i := 1; i < 48; i := i + 1) {
Neels Hofmeyr56f24782020-07-09 00:50:49 +02002514 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 +02002515 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002516 f_shutdown_helper();
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002517}
2518
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02002519private function f_acc09_count_allowed(AccessControlClass acc) return uint8_t
2520{
2521 var uint8_t count := 0;
2522 for (var integer i := 5; i < 16; i := i + 1) {
2523 if (acc[i] == '0'B) { /* the list marks barred, we count allowed */
2524 count := count + 1;
2525 }
2526 }
2527 return count;
2528}
2529
Pau Espin Pedrolc6136cd2020-07-24 13:20:02 +02002530private function f_recv_next_si1(integer rsl_idx := 0) runs on test_CT return SystemInformationType1
2531{
2532 var ASP_RSL_Unitdata rx_rsl_ud;
2533 var SystemInformationType1 last_si1;
2534
2535 timer T := 30.0;
2536 T.start;
2537 alt {
2538 [] IPA_RSL[rsl_idx].receive(tr_ASP_RSL_UD((tr_RSL_NO_BCCH_INFO,
2539 tr_RSL_BCCH_INFO,
2540 tr_RSL_NO_SACCH_FILL,
2541 tr_RSL_SACCH_FILL))
2542 ) -> value rx_rsl_ud {
2543 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
2544 if (g_system_information[rsl_idx].si1 == omit) {
2545 repeat;
2546 }
2547 last_si1 := g_system_information[rsl_idx].si1;
2548 g_system_information[rsl_idx].si1 := omit;
2549 T.stop;
2550 }
Vadim Yanitskiy79ebd5e2021-01-04 00:12:55 +01002551 [] IPA_RSL[rsl_idx].receive { repeat; }
Pau Espin Pedrolc6136cd2020-07-24 13:20:02 +02002552 [] T.timeout { setverdict(fail, "Timeout receiving next SI1"); }
2553 }
2554 return last_si1;
2555}
2556
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02002557/* verify ACC rotate feature */
2558testcase TC_si_acc_rotate() runs on test_CT {
2559 var template SystemInformationConfig sic := SystemInformationConfig_default;
Pau Espin Pedrolc6136cd2020-07-24 13:20:02 +02002560 var SystemInformationType1 last_si1;
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02002561 var AccessControlClass acc;
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02002562 var uint8_t count;
2563 var integer times_allowed[10] := { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
2564
2565 f_init(0, guard_timeout := 60.0);
2566
2567 f_bts_0_cfg(BSCVTY, {"rach access-control-class 5 barred",
2568 "access-control-class-rotate 3",
2569 "access-control-class-rotate-quantum 1"});
2570
2571 /* Init and get first sysinfo */
2572 f_init_bts_and_check_sysinfo(0, expect_si := ?);
2573
Pau Espin Pedrolc6136cd2020-07-24 13:20:02 +02002574 for (var integer i:= 0; i < 20; i := i + 1) {
2575 last_si1 := f_recv_next_si1(0);
2576 acc := last_si1.rach_control.acc;
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02002577 count := f_acc09_count_allowed(acc);
2578 log("RSL: GOT SI1 ACC len=", count, ": ", acc);
2579
2580 if (count != 3) {
2581 log("RSL: EXPECTED SI ACC len=3");
2582 setverdict(fail, "received SI does not match expectations");
2583 break;
2584 }
2585
2586 for (var integer j := 0; j < 10; j := j + 1) {
2587 if (acc[16 - 1 - j] == '0'B) { /* the list marks barred, we count allowed */
2588 times_allowed[j] := times_allowed[j] + 1;
2589 }
2590 }
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02002591 }
2592
2593 for (var integer j := 0; j < 10; j := j + 1) {
2594 log("ACC", j, " allowed ", times_allowed[j], " times" );
2595 if (j != 5 and times_allowed[j] < 3) {
2596 setverdict(fail, "ACC", j, " ERROR: allowed ", times_allowed[j], " < 1 times");
2597 } else if (j == 5 and times_allowed[j] > 0) {
2598 setverdict(fail, "ACC", j, " ERROR: allowed ", times_allowed[j], " > 0 times");
2599 }
2600 }
2601
2602 f_bts_0_cfg(BSCVTY, {"access-control-class-rotate 10",
2603 "rach access-control-class 5 allowed"});
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002604 f_shutdown_helper();
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02002605}
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002606
Pau Espin Pedrolc6136cd2020-07-24 13:20:02 +02002607/* verify ACC startup ramp+rotate feature */
2608testcase TC_si_acc_ramp_rotate() runs on test_CT {
2609 var template SystemInformationConfig sic := SystemInformationConfig_default;
2610 var SystemInformationType1 last_si1;
2611 var AccessControlClass acc;
2612 var ASP_RSL_Unitdata rx_rsl_ud;
2613 var uint8_t count;
2614 var uint8_t prev_count;
2615 var integer times_allowed[10] := { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
2616
2617 f_init(0, guard_timeout := 80.0);
2618
2619 f_bts_0_cfg(BSCVTY, {"rach access-control-class 4 barred",
2620 "access-control-class-rotate 0",
2621 "access-control-class-rotate-quantum 1",
2622 "access-control-class-ramping",
2623 "access-control-class-ramping-step-interval 5",
2624 "access-control-class-ramping-step-size 5"});
2625
2626 /* Init and get first sysinfo */
2627 f_init_bts_and_check_sysinfo(0, expect_si := ?);
2628 last_si1 := g_system_information[0].si1;
2629 acc := last_si1.rach_control.acc;
2630 count := f_acc09_count_allowed(acc);
2631 /* Adm subset size was set to 0 above, so wait until all ACC are barred */
2632 while (count > 0) {
2633 last_si1 := f_recv_next_si1(0);
2634 acc := last_si1.rach_control.acc;
2635 count := f_acc09_count_allowed(acc);
2636 log("RSL: wait len()=0: GOT SI1 ACC len=", count, ": ", acc);
2637 }
2638
2639 /* Increase adm subset size, we should see ramping start up */
2640 f_bts_0_cfg(BSCVTY, {"access-control-class-rotate 10"});
2641 prev_count := 0;
2642 while (true) {
2643 last_si1 := f_recv_next_si1(0);
2644 acc := last_si1.rach_control.acc;
2645 count := f_acc09_count_allowed(acc);
2646 log("RSL: GOT SI1 ACC len=", count, ": ", acc);
2647
2648 if (prev_count > count) {
2649 setverdict(fail, "ACC allowed count dropped while expecting grow: ", prev_count, " -> ", count);
2650 break;
2651 }
2652
2653 if (count == 9) {
2654 break; /* Maximum reached (10 - 1 perm barred), done here */
2655 }
2656
2657 prev_count := count;
2658 }
2659
2660 setverdict(pass);
2661
2662 f_bts_0_cfg(BSCVTY, {"access-control-class-rotate 10",
2663 "rach access-control-class 4 allowed",
2664 "no access-control-class-ramping"});
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002665 f_shutdown_helper();
Pau Espin Pedrolc6136cd2020-07-24 13:20:02 +02002666}
2667
Harald Welte4003d112017-12-09 22:35:39 +01002668testcase TC_ctrl_msc_connection_status() runs on test_CT {
2669 var charstring ctrl_resp;
2670
Harald Welte89d42e82017-12-17 16:42:41 +01002671 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +01002672
2673 /* See https://osmocom.org/issues/2729 */
2674 f_ctrl_get_exp(IPA_CTRL, "msc_connection_status", "connected");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002675 f_shutdown_helper();
Harald Welte4003d112017-12-09 22:35:39 +01002676}
2677
Stefan Sperlingb041b3d2018-01-03 17:14:55 +01002678testcase TC_ctrl_msc0_connection_status() runs on test_CT {
2679 var charstring ctrl_resp;
2680
2681 f_init(1);
Stefan Sperlingb041b3d2018-01-03 17:14:55 +01002682
2683 f_ctrl_get_exp(IPA_CTRL, "msc.0.connection_status", "connected");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002684 f_shutdown_helper();
Stefan Sperlingb041b3d2018-01-03 17:14:55 +01002685}
2686
Harald Welte4003d112017-12-09 22:35:39 +01002687testcase TC_ctrl() runs on test_CT {
2688 var charstring ctrl_resp;
2689
Harald Welte89d42e82017-12-17 16:42:41 +01002690 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +01002691
2692 /* all below values must match the osmo-bsc.cfg config file used */
2693
Harald Welte6a129692018-03-17 17:30:14 +01002694 f_ctrl_get_exp(IPA_CTRL, "mcc", "001");
2695 f_ctrl_get_exp(IPA_CTRL, "mnc", "01");
Oliver Smith75aa0202019-08-19 14:17:50 +02002696 f_ctrl_get_exp(IPA_CTRL, "number-of-bts", "4");
Harald Welte4003d112017-12-09 22:35:39 +01002697
2698 var integer bts_nr := 0;
2699 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "location-area-code", "1");
2700 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "cell-identity", "0");
2701 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "oml-connection-state", "connected");
2702 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "gprs-mode", "gprs");
2703 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "rf_state", "operational,unlocked,on");
2704 f_ctrl_get_exp_trx(IPA_CTRL, bts_nr, 0, "arfcn", "871");
2705 f_ctrl_get_exp_trx(IPA_CTRL, bts_nr, 0, "max-power-reduction", "20");
2706
2707 var integer uptime := str2int(f_ctrl_get_bts(IPA_CTRL, bts_nr, "oml-uptime"));
2708 f_sleep(2.0);
2709 if (str2int(f_ctrl_get_bts(IPA_CTRL, bts_nr, "oml-uptime")) < uptime+1) {
2710 setverdict(fail, "oml-uptime not incrementing as expected");
2711 }
2712 /* TODO: Disconnect RSL, imply that OML is disconnected and check for uptime zero? */
2713
2714 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bsc", 0, "paging:attempted", 0);
2715
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002716 f_shutdown_helper();
Harald Welte96c94412017-12-09 03:12:45 +01002717}
2718
Pau Espin Pedrol5a2d7432019-06-07 19:43:45 +02002719/* Verify that Upon receival of SET "location", BSC forwards a TRAP
2720 "location-state" over the SCCPlite IPA conn */
2721testcase TC_ctrl_location() runs on test_CT {
2722 var MSC_ConnHdlr vc_conn;
2723 var integer bts_nr := 0;
2724
2725 f_init(1, true);
2726 f_sleep(1.0);
2727
2728 f_ctrl_set_bts(IPA_CTRL, bts_nr, "location", "1234567,fix3d,0.340000,0.560000,0.780000");
2729 f_ctrl_exp_trap(SCCPLITE_IPA_CTRL, "bts." & int2str(bts_nr) & ".location-state",
2730 "1234567,fix3d,0.340000,0.560000,0.780000,operational,unlocked,on,001,01");
2731
2732 f_ctrl_set(SCCPLITE_IPA_CTRL, "rf_locked", "1");
2733 f_sleep(2.0);
2734
2735 f_ctrl_set_bts(IPA_CTRL, bts_nr, "location", "1234888,fix3d,0.350000,0.570000,0.790000");
2736 f_ctrl_exp_trap(SCCPLITE_IPA_CTRL, "bts." & int2str(bts_nr) & ".location-state",
2737 "1234888,fix3d,0.350000,0.570000,0.790000,operational,locked,off,001,01");
2738
2739 /* should match the one from config */
2740 f_ctrl_set(SCCPLITE_IPA_CTRL, "rf_locked", "0");
2741
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002742 f_shutdown_helper();
Pau Espin Pedrol5a2d7432019-06-07 19:43:45 +02002743}
2744
Harald Welte6f521d82017-12-11 19:52:02 +01002745
2746/***********************************************************************
2747 * Paging Testing
2748 ***********************************************************************/
2749
2750type record Cell_Identity {
2751 GsmMcc mcc,
2752 GsmMnc mnc,
2753 GsmLac lac,
2754 GsmCellId ci
2755};
Harald Welte24135bd2018-03-17 19:27:53 +01002756private const Cell_Identity cid := { '001'H, '01'H, 1, 0 };
Stefan Sperling049a86e2018-03-20 15:51:00 +01002757private const Cell_Identity unknown_cid := { '678'H, 'f90'H, 1, 0 };
Harald Welte6f521d82017-12-11 19:52:02 +01002758
Harald Welte5d1a2202017-12-13 19:51:29 +01002759type set of integer BtsIdList;
2760
2761private function f_bts_in_list(integer bts_id, BtsIdList bts_ids) return boolean {
2762 for (var integer j := 0; j < sizeof(bts_ids); j := j + 1) {
2763 if (bts_id == bts_ids[j]) {
2764 return true;
2765 }
2766 }
2767 return false;
2768}
Harald Welte6f521d82017-12-11 19:52:02 +01002769
2770/* core paging test helper function; used by most paging test cases */
2771private function f_pageing_helper(hexstring imsi,
2772 template BSSMAP_FIELD_CellIdentificationList cid_list,
Harald Welte5d1a2202017-12-13 19:51:29 +01002773 BtsIdList bts_ids := { 0 },
Harald Welte6f521d82017-12-11 19:52:02 +01002774 template RSL_ChanNeeded rsl_chneed := omit,
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07002775 template (omit) OCT4 tmsi := omit) runs on test_CT
Harald Welte6f521d82017-12-11 19:52:02 +01002776{
2777 var template BSSMAP_IE_ChannelNeeded bssmap_chneed;
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07002778 var template MobileIdentityV mi;
Harald Welte6f521d82017-12-11 19:52:02 +01002779 var RSL_Message rx_rsl;
2780 var integer paging_group := hex2int(imsi[lengthof(imsi)-1]);
Harald Welte5d1a2202017-12-13 19:51:29 +01002781 var integer i;
Harald Welte6f521d82017-12-11 19:52:02 +01002782
2783 f_init();
Harald Welte6f521d82017-12-11 19:52:02 +01002784
2785 /* Clear the queue, it might still contain stuff like BCCH FILLING */
Harald Weltec3068592018-03-17 19:55:31 +01002786 for (i := 0; i < NUM_BTS; i := i + 1) {
2787 IPA_RSL[i].clear;
Harald Welte5d1a2202017-12-13 19:51:29 +01002788 }
Harald Welte6f521d82017-12-11 19:52:02 +01002789
2790 if (isvalue(rsl_chneed)) {
2791 /* The values of 08.08 3.2.2.36 and 08.58 9.3.40 are luckily identical */
2792 bssmap_chneed := ts_BSSMAP_IE_ChanNeeded(int2bit(enum2int(valueof(rsl_chneed)),2));
2793 } else {
2794 bssmap_chneed := omit;
2795 }
2796
Neels Hofmeyrf246a922020-05-13 02:27:10 +02002797 BSSAP.send(ts_BSSAP_UNITDATA_req(g_bssap[0].sccp_addr_peer, g_bssap[0].sccp_addr_own,
2798 ts_BSSMAP_Paging(imsi, cid_list, tmsi, bssmap_chneed)));
Harald Welte6f521d82017-12-11 19:52:02 +01002799
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07002800 if (not istemplatekind(tmsi, "omit")) {
2801 mi := t_MI_TMSI(tmsi);
Harald Welte6f521d82017-12-11 19:52:02 +01002802 } else {
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07002803 mi := tr_MI_IMSI(imsi);
Harald Welte6f521d82017-12-11 19:52:02 +01002804 }
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07002805
Harald Welte5d1a2202017-12-13 19:51:29 +01002806 for (i := 0; i < sizeof(bts_ids); i := i + 1) {
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07002807 rx_rsl := f_exp_ipa_rx(bts_ids[i], tr_RSL_PAGING_CMD(mi));
Harald Welte5d1a2202017-12-13 19:51:29 +01002808 /* check channel type, paging group */
2809 if (rx_rsl.ies[1].body.paging_group != paging_group) {
2810 setverdict(fail, "Paging for wrong paging group");
2811 }
2812 if (ispresent(rsl_chneed) and
2813 rx_rsl.ies[3].body.chan_needed.chan_needed != valueof(rsl_chneed)) {
2814 setverdict(fail, "RSL Channel Needed != BSSMAP Channel Needed");
2815 }
Harald Welte6f521d82017-12-11 19:52:02 +01002816 }
Harald Welte2fccd982018-01-31 15:48:19 +01002817 f_sleep(2.0);
Harald Welte5d1a2202017-12-13 19:51:29 +01002818 /* do a quick check on all not-included BTSs if they received paging */
2819 for (i := 0; i < NUM_BTS; i := i + 1) {
2820 timer T := 0.1;
2821 if (f_bts_in_list(i, bts_ids)) {
2822 continue;
2823 }
2824 T.start;
2825 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07002826 [] IPA_RSL[i].receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD(mi))) {
Harald Welte5d1a2202017-12-13 19:51:29 +01002827 setverdict(fail, "Paging on BTS ", i, " which is not part of ", bts_ids);
2828 }
2829 [] IPA_RSL[i].receive { repeat; }
2830 [] T.timeout { }
2831 }
Harald Welte6f521d82017-12-11 19:52:02 +01002832 }
2833
2834 setverdict(pass);
2835}
2836
Harald Welte5d1a2202017-12-13 19:51:29 +01002837const BtsIdList c_BtsId_all := { 0, 1, 2 };
Harald Welte751d3eb2018-01-31 15:51:06 +01002838const BtsIdList c_BtsId_none := { };
Harald Welte5d1a2202017-12-13 19:51:29 +01002839const BtsIdList c_BtsId_LAC1 := { 0, 1 };
2840const BtsIdList c_BtsId_LAC2 := { 2 };
2841
Harald Welte6f521d82017-12-11 19:52:02 +01002842/* PAGING by IMSI + TMSI */
2843testcase TC_paging_imsi_nochan() runs on test_CT {
2844 var BSSMAP_FIELD_CellIdentificationList cid_list;
2845 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Philipp Maier8c04b0a2018-02-23 13:48:48 +01002846 f_pageing_helper('001010100000001'H, cid_list, c_BtsId_all, omit, omit);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002847 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002848}
2849
2850/* PAGING by IMSI + TMSI */
2851testcase TC_paging_tmsi_nochan() runs on test_CT {
2852 var BSSMAP_FIELD_CellIdentificationList cid_list;
2853 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01002854 f_pageing_helper('001010100000001'H, cid_list, c_BtsId_all, omit, 'A1B2C301'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002855 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002856}
2857
2858/* Paging with different "channel needed' values */
2859testcase TC_paging_tmsi_any() runs on test_CT {
2860 var BSSMAP_FIELD_CellIdentificationList cid_list;
2861 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01002862 f_pageing_helper('001010100000002'H, cid_list, c_BtsId_all, RSL_CHANNEED_ANY, 'A1B2C302'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002863 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002864}
2865testcase TC_paging_tmsi_sdcch() runs on test_CT {
2866 var BSSMAP_FIELD_CellIdentificationList cid_list;
2867 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01002868 f_pageing_helper('001010100000003'H, cid_list, c_BtsId_all, RSL_CHANNEED_SDCCH, 'A1B2C303'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002869 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002870}
2871testcase TC_paging_tmsi_tch_f() runs on test_CT {
2872 var BSSMAP_FIELD_CellIdentificationList cid_list;
2873 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01002874 f_pageing_helper('001010000000004'H, cid_list, c_BtsId_all, RSL_CHANNEED_TCH_F, 'A1B2C304'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002875 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002876}
2877testcase TC_paging_tmsi_tch_hf() runs on test_CT {
2878 var BSSMAP_FIELD_CellIdentificationList cid_list;
2879 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01002880 f_pageing_helper('001010000000005'H, cid_list, c_BtsId_all, RSL_CHANNEED_TCH_ForH, 'A1B2C305'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002881 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002882}
2883
2884/* Paging by CGI */
2885testcase TC_paging_imsi_nochan_cgi() runs on test_CT {
2886 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2887 cid_list := { cIl_CGI := { ts_BSSMAP_CI_CGI(cid.mcc, cid.mnc, cid.lac, cid.ci) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01002888 f_pageing_helper('001010000000006'H, cid_list, { 0 });
Philipp Maier282ca4b2018-02-27 17:17:00 +01002889 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002890}
2891
2892/* Paging by LAC+CI */
2893testcase TC_paging_imsi_nochan_lac_ci() runs on test_CT {
2894 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2895 cid_list := { cIl_LAC_CI := { ts_BSSMAP_CI_LAC_CI(cid.lac, cid.ci) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01002896 f_pageing_helper('001010000000007'H, cid_list, { 0 });
Philipp Maier282ca4b2018-02-27 17:17:00 +01002897 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002898}
2899
2900/* Paging by CI */
2901testcase TC_paging_imsi_nochan_ci() runs on test_CT {
2902 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2903 cid_list := { cIl_CI := { ts_BSSMAP_CI_CI(cid.ci) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01002904 f_pageing_helper('001010000000008'H, cid_list, { 0 });
Philipp Maier282ca4b2018-02-27 17:17:00 +01002905 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002906}
2907
2908/* Paging by LAI */
2909testcase TC_paging_imsi_nochan_lai() runs on test_CT {
2910 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2911 cid_list := { cIl_LAI := { ts_BSSMAP_CI_LAI(cid.mcc, cid.mnc, cid.lac) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01002912 f_pageing_helper('001010000000009'H, cid_list, c_BtsId_LAC1);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002913 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002914}
2915
2916/* Paging by LAC */
2917testcase TC_paging_imsi_nochan_lac() runs on test_CT {
2918 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2919 cid_list := { cIl_LAC := { ts_BSSMAP_CI_LAC(cid.lac) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01002920 f_pageing_helper('001010000000010'H, cid_list, c_BtsId_LAC1);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002921 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002922}
2923
2924/* Paging by "all in BSS" */
2925testcase TC_paging_imsi_nochan_all() runs on test_CT {
2926 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2927 cid_list := { cIl_allInBSS := ''O };
Harald Welte5d1a2202017-12-13 19:51:29 +01002928 f_pageing_helper('001010000000011'H, cid_list, c_BtsId_all);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002929 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002930}
2931
Stefan Sperling7b5e1782018-03-20 19:32:43 +01002932/* Paging by PLMN+LAC+RNC; We do not implement this; Verify nothing is paged */
Harald Welte751d3eb2018-01-31 15:51:06 +01002933testcase TC_paging_imsi_nochan_plmn_lac_rnc() runs on test_CT {
2934 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2935 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 +01002936 f_pageing_helper('001010000000012'H, cid_list, c_BtsId_none);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002937 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01002938}
Harald Welte6f521d82017-12-11 19:52:02 +01002939
Stefan Sperling7b5e1782018-03-20 19:32:43 +01002940/* Paging by RNC; We do not implement this; Verify nothing is paged */
Harald Welte751d3eb2018-01-31 15:51:06 +01002941testcase TC_paging_imsi_nochan_rnc() runs on test_CT {
2942 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2943 cid_list := { cIl_RNC := { int2oct(13, 2) } };
Stefan Sperling7b5e1782018-03-20 19:32:43 +01002944 f_pageing_helper('001010000000013'H, cid_list, c_BtsId_none);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002945 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01002946}
2947
Stefan Sperling7b5e1782018-03-20 19:32:43 +01002948/* Paging by LAC+RNC; We do not implement; Verify nothing is paged */
Harald Welte751d3eb2018-01-31 15:51:06 +01002949testcase TC_paging_imsi_nochan_lac_rnc() runs on test_CT {
2950 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2951 cid_list := { cIl_LAC_RNC := { ts_BSSMAP_CI_LAC_RNC(cid.lac, 14) } };
Stefan Sperling7b5e1782018-03-20 19:32:43 +01002952 f_pageing_helper('001010000000014'H, cid_list, c_BtsId_none);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002953 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01002954}
2955
Harald Welte6f521d82017-12-11 19:52:02 +01002956/* Paging on multiple cells (multiple entries in list): Verify all of them page */
Harald Welte751d3eb2018-01-31 15:51:06 +01002957testcase TC_paging_imsi_nochan_lacs() runs on test_CT {
2958 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2959 cid_list := { cIl_LAC := { ts_BSSMAP_CI_LAC(1), ts_BSSMAP_CI_LAC(2) } };
2960 f_pageing_helper('001010000000015'H, cid_list, c_BtsId_all);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002961 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01002962}
2963
2964/* Paging on empty list: Verify none of them page */
2965testcase TC_paging_imsi_nochan_lacs_empty() runs on test_CT {
2966 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2967 cid_list := { cIl_LAC := { } };
2968 f_pageing_helper('001010000000016'H, cid_list, c_BtsId_none);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002969 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01002970}
2971
Stefan Sperling049a86e2018-03-20 15:51:00 +01002972/* Paging by CGI with unknown MCC/MNC: Verify nothing is paged. */
2973testcase TC_paging_imsi_nochan_cgi_unknown_cid() runs on test_CT {
2974 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2975 cid_list := { cIl_CGI := { ts_BSSMAP_CI_CGI(unknown_cid.mcc, unknown_cid.mnc, unknown_cid.lac, unknown_cid.ci) } };
2976 f_pageing_helper('001010000000006'H, cid_list, c_BtsId_none);
2977 f_shutdown_helper();
2978}
2979
Harald Welte6f521d82017-12-11 19:52:02 +01002980/* Verify paging retransmission interval + count */
2981/* Verify paging stops after channel establishment */
Harald Welte6f521d82017-12-11 19:52:02 +01002982/* Test behavior under paging overload */
Harald Welteae026692017-12-09 01:03:01 +01002983
Harald Weltee65d40e2017-12-13 00:09:06 +01002984/* Verify PCH load */
2985testcase TC_paging_imsi_load() runs on test_CT {
2986 var BSSMAP_FIELD_CellIdentificationList cid_list;
2987 timer T := 4.0;
Harald Welte2caa1062018-03-17 18:19:05 +01002988 timer T_retrans := 1.0;
Harald Weltee65d40e2017-12-13 00:09:06 +01002989 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01002990 f_pageing_helper('001010123456789'H, cid_list, c_BtsId_all);
Harald Weltee65d40e2017-12-13 00:09:06 +01002991
2992 /* tell BSC there is no paging space anymore */
2993 f_ipa_tx(0, ts_RSL_PAGING_LOAD_IND(0));
Harald Welte3b57ab52018-03-17 18:01:10 +01002994 f_sleep(0.2);
2995 IPA_RSL[0].clear;
Harald Weltee65d40e2017-12-13 00:09:06 +01002996
2997 /* Wait for 4 seconds if any more PAGING CMD are received on RSL. Normally,
2998 * there would be 8 retransmissions during 4 seconds */
2999 T.start;
Harald Welte2caa1062018-03-17 18:19:05 +01003000 T_retrans.start;
Harald Weltee65d40e2017-12-13 00:09:06 +01003001 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07003002 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD(?))) {
Harald Weltee65d40e2017-12-13 00:09:06 +01003003 setverdict(fail, "Received PAGING after LOAD_IND(0)");
Daniel Willmannafce8662018-07-06 23:11:32 +02003004 mtc.stop;
Harald Weltee65d40e2017-12-13 00:09:06 +01003005 }
Harald Welte2caa1062018-03-17 18:19:05 +01003006 [] T_retrans.timeout {
3007 /* re-trnsmit the zero-space LOAD IND to avoid BSC 'auto credit' */
3008 f_ipa_tx(0, ts_RSL_PAGING_LOAD_IND(0));
3009 T_retrans.start;
3010 repeat;
3011 }
Harald Weltee65d40e2017-12-13 00:09:06 +01003012 [] T.timeout {
3013 setverdict(pass);
3014 }
3015 }
Philipp Maier282ca4b2018-02-27 17:17:00 +01003016
3017 f_shutdown_helper();
Harald Weltee65d40e2017-12-13 00:09:06 +01003018}
3019
Harald Welte235ebf12017-12-15 14:18:16 +01003020/* Verify Paging Counter */
Harald Welte1ff69992017-12-14 12:31:17 +01003021testcase TC_paging_counter() runs on test_CT {
3022 var BSSMAP_FIELD_CellIdentificationList cid_list;
3023 timer T := 4.0;
3024 var integer i;
3025 var integer paging_attempted_bsc;
3026 var integer paging_attempted_bts[NUM_BTS];
3027 var integer paging_expired_bts[NUM_BTS];
3028 cid_list := valueof(ts_BSSMAP_CIL_noCell);
3029
3030 f_init();
3031
3032 /* read counters before paging */
3033 paging_attempted_bsc := f_ctrl_get_ratectr_abs(IPA_CTRL, "bsc", 0, "paging:attempted");
3034 for (i := 0; i < NUM_BTS; i := i+1) {
3035 paging_attempted_bts[i] := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", i, "paging:attempted");
3036 paging_expired_bts[i] := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", i, "paging:expired");
3037 }
3038
3039 f_pageing_helper('001230000000001'H, cid_list, c_BtsId_all);
3040
3041 /* expect the attempted pages on BSC and each BTSs to have incremented by one */
3042 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bsc", 0, "paging:attempted", paging_attempted_bsc+1);
3043 for (i := 0; i < NUM_BTS; i := i+1) {
3044 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", i, "paging:attempted",
3045 paging_attempted_bts[i]+1);
3046 }
3047
3048 /* assume that 12s later the paging on all BTSs have expired and hence incremented by 1 */
3049 f_sleep(12.0);
3050 for (i := 0; i < NUM_BTS; i := i+1) {
3051 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", i, "paging:expired",
3052 paging_expired_bts[i]+1);
3053 }
Harald Welte1ff69992017-12-14 12:31:17 +01003054
Philipp Maier282ca4b2018-02-27 17:17:00 +01003055 f_shutdown_helper();
Harald Welte1ff69992017-12-14 12:31:17 +01003056}
3057
3058
Harald Welte10985002017-12-12 09:29:15 +01003059/* Verify paging stops after A-RESET */
3060testcase TC_paging_imsi_a_reset() runs on test_CT {
3061 var BSSMAP_FIELD_CellIdentificationList cid_list;
3062 timer T := 3.0;
3063 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01003064 f_pageing_helper('001010123456789'H, cid_list, c_BtsId_all);
Harald Welte10985002017-12-12 09:29:15 +01003065
3066 /* Perform a BSSMAP Reset and wait for ACK */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003067 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 +01003068 alt {
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003069 [] 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 +01003070 [] BSSAP.receive { repeat; }
3071 }
3072
Daniel Willmanncbef3982018-07-30 09:22:40 +02003073 /* Wait to avoid a possible race condition if a paging message is
3074 * received right before the reset ACK. */
3075 f_sleep(0.2);
3076
Harald Welte10985002017-12-12 09:29:15 +01003077 /* Clear the queue, it might still contain stuff like BCCH FILLING */
Philipp Maier1e6b4422018-02-23 14:02:13 +01003078 for (var integer i := 0; i < sizeof(IPA_RSL); i := i+1) {
3079 IPA_RSL[i].clear;
3080 }
Harald Welte10985002017-12-12 09:29:15 +01003081
3082 /* Wait for 3 seconds if any more PAGING CMD are received on RSL */
3083 T.start;
3084 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07003085 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD(?))) {
Harald Welte10985002017-12-12 09:29:15 +01003086 setverdict(fail, "Received PAGING after A-RESET");
Daniel Willmannafce8662018-07-06 23:11:32 +02003087 mtc.stop;
Harald Welte10985002017-12-12 09:29:15 +01003088 }
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07003089 [] IPA_RSL[1].receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD(?))) {
Harald Welte5d1a2202017-12-13 19:51:29 +01003090 setverdict(fail, "Received PAGING after A-RESET");
Daniel Willmannafce8662018-07-06 23:11:32 +02003091 mtc.stop;
Harald Welte5d1a2202017-12-13 19:51:29 +01003092 }
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07003093 [] IPA_RSL[2].receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD(?))) {
Harald Welte5d1a2202017-12-13 19:51:29 +01003094 setverdict(fail, "Received PAGING after A-RESET");
Daniel Willmannafce8662018-07-06 23:11:32 +02003095 mtc.stop;
Harald Welte5d1a2202017-12-13 19:51:29 +01003096 }
Harald Welte10985002017-12-12 09:29:15 +01003097 [] T.timeout {
3098 setverdict(pass);
3099 }
3100 }
Philipp Maier282ca4b2018-02-27 17:17:00 +01003101
3102 f_shutdown_helper();
Harald Welte10985002017-12-12 09:29:15 +01003103}
Harald Welteae026692017-12-09 01:03:01 +01003104
Philipp Maierf45824a2019-08-14 14:44:10 +02003105/* Verify how we handle unsolicited Paging Response. In case of an unsolicit
3106 * paging response we can not know which MSC is in charge, so we will blindly
3107 * pick the first configured MSC. This behavior is required in order to make
3108 * MT-CSFB calls working because in those cases the BSC can not know that the
3109 * MSC has already paged the subscriver via SGs. So any MT-CSFB call will look
3110 * like an unsolicited Paging Response to the MSC.
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01003111 */
3112testcase TC_paging_resp_unsol() runs on test_CT {
3113
3114 f_init(1);
Philipp Maierf45824a2019-08-14 14:44:10 +02003115 timer T := 5.0;
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01003116
3117 var BSSAP_N_CONNECT_ind rx_c_ind;
3118 var DchanTuple dt;
3119 var PDU_ML3_MS_NW l3 := valueof(ts_PAG_RESP(valueof(ts_MI_IMSI_LV('001010008880018'H))));
Philipp Maierf45824a2019-08-14 14:44:10 +02003120 var octetstring rr_pag_resp := enc_PDU_ML3_MS_NW(l3);
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01003121
3122 /* Send CHAN RQD and wait for allocation; acknowledge it */
3123 dt.rsl_chan_nr := f_chreq_act_ack();
3124
3125 /* Send unsolicited Paging response (no matching Paging CMD stored in BSC) */
3126 f_ipa_tx(0, ts_RSL_EST_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0)), enc_PDU_ML3_MS_NW(l3)));
3127
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01003128
Philipp Maierf45824a2019-08-14 14:44:10 +02003129 /* Expevct a CR with a matching Paging response on the A-Interface */
3130 T.start;
3131 alt {
3132 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(rr_pag_resp))) {
3133 setverdict(pass);
3134 }
3135 [] BSSAP.receive {
3136 setverdict(fail, "Received unexpected message on A-Interface!");
3137 }
3138 [] T.timeout {
3139 setverdict(fail, "Received nothing on A-Interface!");
3140 }
3141 }
3142
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003143 f_shutdown_helper();
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01003144}
3145
Harald Welte4e9b9cc2017-12-14 18:31:02 +01003146/* Test RSL link drop causes counter increment */
3147testcase TC_rsl_drop_counter() runs on test_CT {
3148 var integer rsl_fail;
3149
Harald Welte89d42e82017-12-17 16:42:41 +01003150 f_init(1);
Harald Welte4e9b9cc2017-12-14 18:31:02 +01003151
3152 rsl_fail := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "rsl_fail");
3153
3154 bts[0].rsl.vc_IPA.stop;
3155
3156 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "rsl_fail", rsl_fail+1);
3157
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003158 f_shutdown_helper();
Harald Welte4e9b9cc2017-12-14 18:31:02 +01003159}
3160
3161/* TODO: Test OML link drop causes counter increment */
3162
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003163/* The body of TC_rsl_unknown_unit_id() and TC_oml_unknown_unit_id() tests. */
3164function f_ipa_unknown_unit_id(integer mp_bsc_ipa_port) runs on test_CT return boolean {
3165 timer T := 10.0;
3166
3167 bts[0].rsl.id := "IPA-0-RSL";
3168 bts[0].rsl.vc_IPA := IPA_Emulation_CT.create(bts[0].rsl.id & "-IPA");
3169 bts[0].rsl.ccm_pars := c_IPA_default_ccm_pars;
3170 bts[0].rsl.ccm_pars.name := "Osmocom TTCN-3 BTS Simulator";
Oliver Smith92c2bdb2019-08-20 15:11:24 +02003171 bts[0].rsl.ccm_pars.unit_id := "99/0/0"; /* value which is unknown at BTS */
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003172
Pau Espin Pedrol9a5b8ff2021-01-04 19:01:31 +01003173 f_ipa_ctrl_start_client(mp_bsc_ip, mp_bsc_ctrl_port);
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003174
3175 f_init_mgcp("VirtMSC");
3176
3177 /* start RSL/OML connection (XXX re-uses RSL port/protocol definitions for OML) */
3178 map(bts[0].rsl.vc_IPA:IPA_PORT, system:IPA);
3179 connect(bts[0].rsl.vc_IPA:IPA_RSL_PORT, self:IPA_RSL[0]);
3180 bts[0].rsl.vc_IPA.start(IPA_Emulation.main_client(mp_bsc_ip, mp_bsc_ipa_port, "", 10000, bts[0].rsl.ccm_pars));
3181
3182 /* wait for IPA OML link to connect and then disconnect */
3183 T.start;
3184 alt {
Vadim Yanitskiya2afacc2020-05-18 21:16:19 +07003185 [] IPA_RSL[0].receive(tr_ASP_IPA_EV(ASP_IPA_EVENT_DOWN)) {
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003186 T.stop;
3187 return true;
3188 }
3189 [] IPA_RSL[0].receive { repeat }
3190 [] T.timeout {
Daniel Willmannafce8662018-07-06 23:11:32 +02003191 return false;
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003192 }
3193 }
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003194 return false;
3195}
3196
3197/* BSC should close an RSL connection from a BTS with unknown unit ID (OS#2714). */
3198testcase TC_rsl_unknown_unit_id() runs on test_CT {
3199 if (f_ipa_unknown_unit_id(mp_bsc_rsl_port)) {
3200 setverdict(pass);
3201 } else {
3202 setverdict(fail, "Timeout RSL waiting for connection to close");
3203 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003204 f_shutdown_helper();
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003205}
3206
3207
3208/* BSC should close an RSL connection from a BTS with unknown unit ID (OS#2714). */
3209testcase TC_oml_unknown_unit_id() runs on test_CT {
3210 if (f_ipa_unknown_unit_id(mp_bsc_oml_port)) {
3211 setverdict(pass);
3212 } else {
3213 setverdict(fail, "Timeout OML waiting for connection to close");
3214 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003215 f_shutdown_helper();
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003216}
3217
3218
Harald Weltec1a2fff2017-12-17 11:06:19 +01003219/***********************************************************************
Harald Welte6811d102019-04-14 22:23:14 +02003220 * "New world" test cases using RSL_Emulation + RAN_Emulation
Harald Weltec1a2fff2017-12-17 11:06:19 +01003221 ***********************************************************************/
3222
Harald Welte6811d102019-04-14 22:23:14 +02003223import from RAN_Emulation all;
Harald Welte47cd0e32020-08-21 12:39:11 +02003224import from BSSAP_LE_Emulation all;
Harald Weltec1a2fff2017-12-17 11:06:19 +01003225import from RSL_Emulation all;
3226import from MSC_ConnectionHandler all;
3227
3228type function void_fn(charstring id) runs on MSC_ConnHdlr;
3229
Harald Welte336820c2018-05-31 20:34:52 +02003230/* helper function to create and connect a MSC_ConnHdlr component */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003231private function f_connect_handler(inout MSC_ConnHdlr vc_conn, integer bssap_idx := 0) runs on test_CT {
3232 connect(vc_conn:RAN, g_bssap[bssap_idx].vc_RAN:PROC);
Daniel Willmann191e0d92018-01-17 12:44:35 +01003233 connect(vc_conn:MGCP_PROC, vc_MGCP:MGCP_PROC);
Harald Weltec1a2fff2017-12-17 11:06:19 +01003234 connect(vc_conn:RSL, bts[0].rsl.vc_RSL:CLIENT_PT);
Harald Weltef70df652018-01-29 22:00:23 +01003235 connect(vc_conn:RSL_PROC, bts[0].rsl.vc_RSL:RSL_PROC);
Philipp Maier88f4ae82018-03-01 14:00:58 +01003236 if (isvalue(bts[1])) {
Philipp Maier956a92f2018-02-16 10:58:07 +01003237 connect(vc_conn:RSL1, bts[1].rsl.vc_RSL:CLIENT_PT);
3238 connect(vc_conn:RSL1_PROC, bts[1].rsl.vc_RSL:RSL_PROC);
3239 }
Neels Hofmeyr91401012019-07-11 00:42:35 +02003240 if (isvalue(bts[2])) {
3241 connect(vc_conn:RSL2, bts[2].rsl.vc_RSL:CLIENT_PT);
3242 connect(vc_conn:RSL2_PROC, bts[2].rsl.vc_RSL:RSL_PROC);
3243 }
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003244 connect(vc_conn:BSSAP, g_bssap[bssap_idx].vc_RAN:CLIENT);
Neels Hofmeyrcfe44062020-10-15 02:28:08 +02003245 if (mp_enable_lcs_tests) {
3246 connect(vc_conn:BSSAP_LE, g_bssap_le.vc_BSSAP_LE:CLIENT);
3247 connect(vc_conn:BSSAP_LE_PROC, g_bssap_le.vc_BSSAP_LE:PROC);
3248 }
Daniel Willmann191e0d92018-01-17 12:44:35 +01003249 connect(vc_conn:MGCP, vc_MGCP:MGCP_CLIENT);
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +02003250 connect(vc_conn:MGCP_MULTI, vc_MGCP:MGCP_CLIENT_MULTI);
Daniel Willmannebdecc02020-08-12 15:30:17 +02003251 connect(vc_conn:STATSD_PROC, vc_STATSD:STATSD_PROC);
Harald Welte336820c2018-05-31 20:34:52 +02003252}
3253
3254function f_start_handler(void_fn fn, template (omit) TestHdlrParams pars := omit)
3255runs on test_CT return MSC_ConnHdlr {
3256 var charstring id := testcasename();
3257 var MSC_ConnHdlr vc_conn;
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003258 var integer bssap_idx := 0;
3259 if (isvalue(pars)) {
3260 bssap_idx := valueof(pars).mscpool.bssap_idx;
3261 }
Harald Welte336820c2018-05-31 20:34:52 +02003262 vc_conn := MSC_ConnHdlr.create(id);
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003263 f_connect_handler(vc_conn, bssap_idx);
Neels Hofmeyr1708d1b2020-10-10 16:56:48 +02003264 /* Emit a marker to appear in the SUT's own logging output */
3265 f_logp(BSCVTY, testcasename() & "() start");
Harald Weltea0630032018-03-20 21:09:55 +01003266 vc_conn.start(f_handler_init(fn, id, pars));
Harald Weltec1a2fff2017-12-17 11:06:19 +01003267 return vc_conn;
3268}
3269
Harald Weltea0630032018-03-20 21:09:55 +01003270/* first function inside ConnHdlr component; sets g_pars + starts function */
3271private function f_handler_init(void_fn fn, charstring id, template (omit) TestHdlrParams pars := omit)
3272runs on MSC_ConnHdlr {
3273 if (isvalue(pars)) {
3274 g_pars := valueof(pars);
3275 }
3276 fn.apply(id);
3277}
3278
Harald Welte3c86ea02018-05-10 22:28:05 +02003279/* Establish signalling channel (non-assignment case) followed by cipher mode */
3280private function f_tc_ciph_mode_a5(charstring id) runs on MSC_ConnHdlr {
Harald Welteed848512018-05-24 22:27:58 +02003281 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3282 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte3c86ea02018-05-10 22:28:05 +02003283 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeSIGNAL);
Philipp Maier23000732018-05-18 11:25:37 +02003284 ass_cmd.pdu.bssmap.assignmentRequest.circuitIdentityCode := omit;
3285 ass_cmd.pdu.bssmap.assignmentRequest.aoIPTransportLayer := omit;
3286 exp_compl.pdu.bssmap.assignmentComplete.circuitIdentityCode := omit;
3287 exp_compl.pdu.bssmap.assignmentComplete.aoIPTransportLayer := omit;
Harald Welte3c86ea02018-05-10 22:28:05 +02003288
Philipp Maier23000732018-05-18 11:25:37 +02003289 f_establish_fully(ass_cmd, exp_compl);
Harald Welte3c86ea02018-05-10 22:28:05 +02003290}
3291testcase TC_ciph_mode_a5_0() runs on test_CT {
3292 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02003293 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte3c86ea02018-05-10 22:28:05 +02003294 pars.encr := valueof(t_EncrParams('01'O, f_rnd_octstring(8)));
3295
3296 f_init(1, true);
3297 f_sleep(1.0);
3298 vc_conn := f_start_handler(refers(f_tc_ciph_mode_a5), pars);
3299 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003300 f_shutdown_helper();
Harald Welte3c86ea02018-05-10 22:28:05 +02003301}
3302testcase TC_ciph_mode_a5_1() runs on test_CT {
3303 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02003304 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte3c86ea02018-05-10 22:28:05 +02003305 pars.encr := valueof(t_EncrParams('02'O, f_rnd_octstring(8)));
3306
3307 f_init(1, true);
3308 f_sleep(1.0);
3309 vc_conn := f_start_handler(refers(f_tc_ciph_mode_a5), pars);
3310 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003311 f_shutdown_helper();
Harald Welte3c86ea02018-05-10 22:28:05 +02003312}
3313testcase TC_ciph_mode_a5_3() runs on test_CT {
3314 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02003315 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte3c86ea02018-05-10 22:28:05 +02003316 pars.encr := valueof(t_EncrParams('08'O, f_rnd_octstring(8)));
3317
3318 f_init(1, true);
3319 f_sleep(1.0);
3320 vc_conn := f_start_handler(refers(f_tc_ciph_mode_a5), pars);
3321 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003322 f_shutdown_helper();
Harald Welte3c86ea02018-05-10 22:28:05 +02003323}
3324
Pau Espin Pedrol07866632020-09-03 19:10:55 +02003325/* establish initial channel, enable ciphering followed by assignment to ciphered channel */
3326private function f_tc_assignment_aoip_tla_v6(charstring id) runs on MSC_ConnHdlr {
3327 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3328 var PDU_BSSAP ass_cmd := f_gen_ass_req(aoip_tla := "::3");
3329 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3330 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
3331
3332 f_establish_fully(ass_cmd, exp_compl);
3333}
3334testcase TC_assignment_aoip_tla_v6() runs on test_CT {
3335 var MSC_ConnHdlr vc_conn;
3336 var TestHdlrParams pars := f_gen_test_hdlr_pars();
3337
3338 f_init(1, true);
3339 f_sleep(1.0);
3340 vc_conn := f_start_handler(refers(f_tc_assignment_aoip_tla_v6), pars);
3341 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003342 f_shutdown_helper();
Pau Espin Pedrol07866632020-09-03 19:10:55 +02003343}
3344
Harald Welte3c86ea02018-05-10 22:28:05 +02003345
3346/* establish initial channel, enable ciphering followed by assignment to ciphered channel */
Harald Welte651fcdc2018-05-10 20:23:16 +02003347private function f_tc_assignment_fr_a5(charstring id) runs on MSC_ConnHdlr {
Harald Welteed848512018-05-24 22:27:58 +02003348 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3349 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Weltec1a2fff2017-12-17 11:06:19 +01003350
Harald Welte552620d2017-12-16 23:21:36 +01003351 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3352 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
Harald Welte73cd2712017-12-17 00:44:52 +01003353
Harald Weltea0630032018-03-20 21:09:55 +01003354 f_establish_fully(ass_cmd, exp_compl);
Harald Welte552620d2017-12-16 23:21:36 +01003355}
Harald Welte552620d2017-12-16 23:21:36 +01003356testcase TC_assignment_fr_a5_0() runs on test_CT {
3357 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02003358 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte651fcdc2018-05-10 20:23:16 +02003359 pars.encr := valueof(t_EncrParams('01'O, f_rnd_octstring(8)));
Harald Welte552620d2017-12-16 23:21:36 +01003360
Harald Welte89d42e82017-12-17 16:42:41 +01003361 f_init(1, true);
Harald Welte552620d2017-12-16 23:21:36 +01003362 f_sleep(1.0);
Harald Welte651fcdc2018-05-10 20:23:16 +02003363 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5), pars);
Harald Welte552620d2017-12-16 23:21:36 +01003364 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003365 f_shutdown_helper();
Harald Welte552620d2017-12-16 23:21:36 +01003366}
Harald Welte552620d2017-12-16 23:21:36 +01003367testcase TC_assignment_fr_a5_1() runs on test_CT {
Harald Weltec1a2fff2017-12-17 11:06:19 +01003368 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02003369 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte651fcdc2018-05-10 20:23:16 +02003370 pars.encr := valueof(t_EncrParams('02'O, f_rnd_octstring(8)));
Harald Weltec1a2fff2017-12-17 11:06:19 +01003371
Harald Welte89d42e82017-12-17 16:42:41 +01003372 f_init(1, true);
Harald Weltec1a2fff2017-12-17 11:06:19 +01003373 f_sleep(1.0);
Harald Welte651fcdc2018-05-10 20:23:16 +02003374 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5), pars);
3375 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003376 f_shutdown_helper();
Harald Welte651fcdc2018-05-10 20:23:16 +02003377}
3378testcase TC_assignment_fr_a5_3() runs on test_CT {
3379 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02003380 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte651fcdc2018-05-10 20:23:16 +02003381 pars.encr := valueof(t_EncrParams('08'O, f_rnd_octstring(8)));
Harald Weltec1a2fff2017-12-17 11:06:19 +01003382
Harald Welte651fcdc2018-05-10 20:23:16 +02003383 f_init(1, true);
3384 f_sleep(1.0);
3385 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5), pars);
Harald Weltec1a2fff2017-12-17 11:06:19 +01003386 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003387 f_shutdown_helper();
Harald Weltec1a2fff2017-12-17 11:06:19 +01003388}
3389
Harald Welte552620d2017-12-16 23:21:36 +01003390/* Expect ASSIGNMENT FAIL if mandatory IE is missing */
3391private function f_tc_assignment_fr_a5_1_codec_missing(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02003392 g_pars := f_gen_test_hdlr_pars();
Harald Welte552620d2017-12-16 23:21:36 +01003393 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
Harald Welteed848512018-05-24 22:27:58 +02003394 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte552620d2017-12-16 23:21:36 +01003395 const OCT8 kc := '0001020304050607'O;
3396
3397 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02003398 /* Omit: ass_cmd.pdu.bssmap.assignmentRequest.codecList */
3399
Harald Weltea0630032018-03-20 21:09:55 +01003400 f_establish_fully(ass_cmd, exp_fail);
Harald Welte552620d2017-12-16 23:21:36 +01003401}
Harald Welte552620d2017-12-16 23:21:36 +01003402testcase TC_assignment_fr_a5_1_codec_missing() runs on test_CT {
3403 var MSC_ConnHdlr vc_conn;
3404
Harald Welte89d42e82017-12-17 16:42:41 +01003405 f_init(1, true);
Harald Welte552620d2017-12-16 23:21:36 +01003406 f_sleep(1.0);
3407
Harald Welte8863fa12018-05-10 20:15:27 +02003408 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5_1_codec_missing));
Harald Welte552620d2017-12-16 23:21:36 +01003409 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003410 f_shutdown_helper();
Harald Welte552620d2017-12-16 23:21:36 +01003411}
3412
Harald Welte552620d2017-12-16 23:21:36 +01003413private function f_tc_assignment_fr_a5_4(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02003414 g_pars := f_gen_test_hdlr_pars();
Harald Welteed848512018-05-24 22:27:58 +02003415 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3416 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte552620d2017-12-16 23:21:36 +01003417 const OCT8 kc := '0001020304050607'O;
3418 const OCT16 kc128 := kc & kc;
3419
3420 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3421 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
Harald Weltea0630032018-03-20 21:09:55 +01003422 f_establish_fully(ass_cmd, exp_compl);
Harald Welte38b2a102017-12-23 02:42:58 +01003423 f_cipher_mode('10'O, kc, kc128, true);
Harald Welte552620d2017-12-16 23:21:36 +01003424 /* TODO: expect GSM0808_CAUSE_CIPHERING_ALGORITHM_NOT_SUPPORTED cause value */
Harald Welte552620d2017-12-16 23:21:36 +01003425}
Harald Welte552620d2017-12-16 23:21:36 +01003426testcase TC_assignment_fr_a5_4() runs on test_CT {
3427 var MSC_ConnHdlr vc_conn;
3428
Harald Welte89d42e82017-12-17 16:42:41 +01003429 f_init(1, true);
Harald Welte552620d2017-12-16 23:21:36 +01003430 f_sleep(1.0);
3431
Harald Welte8863fa12018-05-10 20:15:27 +02003432 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5_4));
Harald Welte552620d2017-12-16 23:21:36 +01003433 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003434 f_shutdown_helper();
Harald Welte552620d2017-12-16 23:21:36 +01003435}
3436
3437
Harald Welte4532e0a2017-12-23 02:05:44 +01003438private function f_tc_assignment_sign(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02003439 g_pars := f_gen_test_hdlr_pars();
Harald Welte4532e0a2017-12-23 02:05:44 +01003440 var template PDU_BSSAP exp_compl := tr_BSSMAP_AssignmentComplete(omit, omit);
Philipp Maier48604732018-10-09 15:00:37 +02003441 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte4532e0a2017-12-23 02:05:44 +01003442 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeSIGNAL);
Daniel Willmannebdecc02020-08-12 15:30:17 +02003443
3444 f_statsd_reset();
Harald Weltea0630032018-03-20 21:09:55 +01003445 f_establish_fully(ass_cmd, exp_compl);
Daniel Willmannebdecc02020-08-12 15:30:17 +02003446
3447 var StatsDExpects expect := {
Daniel Willmannc5398f72020-09-21 10:41:35 +02003448 { name := "TTCN3.bts.0.chreq.total", mtype := "c", min := 1, max := 1},
3449 { name := "TTCN3.bts.0.chreq.successful", mtype := "c", min := 1, max := 1},
Daniel Willmannebdecc02020-08-12 15:30:17 +02003450 { name := "TTCN3.bsc.0.assignment.attempted", mtype := "c", min := 1, max := 1},
3451 { name := "TTCN3.bsc.0.assignment.completed", mtype := "c", min := 1, max := 1}
3452 };
3453 f_statsd_expect(expect);
Harald Welte4532e0a2017-12-23 02:05:44 +01003454}
3455
3456testcase TC_assignment_sign() runs on test_CT {
3457 var MSC_ConnHdlr vc_conn;
3458
3459 f_init(1, true);
3460 f_sleep(1.0);
3461
Harald Welte8863fa12018-05-10 20:15:27 +02003462 vc_conn := f_start_handler(refers(f_tc_assignment_sign));
Harald Welte4532e0a2017-12-23 02:05:44 +01003463 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003464 f_shutdown_helper();
Harald Welte4532e0a2017-12-23 02:05:44 +01003465}
3466
Harald Welte60aa5762018-03-21 19:33:13 +01003467/***********************************************************************
3468 * Codec (list) testing
3469 ***********************************************************************/
3470
3471/* check if the given rsl_mode is compatible with the a_elem */
3472private function f_match_codec(BSSMAP_FIELD_CodecElement a_elem, RSL_IE_ChannelMode rsl_mode)
3473return boolean {
3474 select (a_elem.codecType) {
3475 case (GSM_FR) {
3476 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM1))) {
3477 return true;
3478 }
3479 }
3480 case (GSM_HR) {
3481 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_H, RSL_CMOD_SP_GSM1))) {
3482 return true;
3483 }
3484 }
3485 case (GSM_EFR) {
3486 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM2))) {
3487 return true;
3488 }
3489 }
3490 case (FR_AMR) {
3491 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM3))) {
3492 return true;
3493 }
3494 }
3495 case (HR_AMR) {
3496 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_H, RSL_CMOD_SP_GSM3))) {
3497 return true;
3498 }
3499 }
3500 case else { }
3501 }
3502 return false;
3503}
3504
3505/* check if the given rsl_mode is compatible with the a_list */
3506private function f_match_codecs(BSSMAP_IE_SpeechCodecList a_list, RSL_IE_ChannelMode rsl_mode)
3507return boolean {
3508 for (var integer i := 0; i < sizeof(a_list); i := i+1) {
3509 if (f_match_codec(a_list.codecElements[i], rsl_mode)) {
3510 return true;
3511 }
3512 }
3513 return false;
3514}
3515
3516/* determine BSSMAP_IE_ChannelType from *first* element of BSSMAP_FIELD_CodecElement */
Philipp Maier61f6b572018-07-06 14:03:38 +02003517function f_BSSMAP_chtype_from_codec(BSSMAP_FIELD_CodecElement a_elem)
Harald Welte60aa5762018-03-21 19:33:13 +01003518return BSSMAP_IE_ChannelType {
3519 /* FIXME: actually look at all elements of BSSMAP_IE_SpeechCodecList */
3520 var BSSMAP_IE_ChannelType ret := valueof(ts_BSSMAP_IE_ChannelType);
3521 select (a_elem.codecType) {
3522 case (GSM_FR) {
3523 ret.channelRateAndType := ChRate_TCHF;
3524 ret.speechId_DataIndicator := Spdi_TCHF_FR;
3525 }
3526 case (GSM_HR) {
3527 ret.channelRateAndType := ChRate_TCHH;
3528 ret.speechId_DataIndicator := Spdi_TCHH_HR;
3529 }
3530 case (GSM_EFR) {
3531 ret.channelRateAndType := ChRate_TCHF;
3532 ret.speechId_DataIndicator := Spdi_TCHF_EFR;
3533 }
3534 case (FR_AMR) {
3535 ret.channelRateAndType := ChRate_TCHF;
3536 ret.speechId_DataIndicator := Spdi_TCHF_AMR;
3537 }
3538 case (HR_AMR) {
3539 ret.channelRateAndType := ChRate_TCHH;
3540 ret.speechId_DataIndicator := Spdi_TCHH_AMR;
3541 }
3542 case else {
3543 setverdict(fail, "Unsupported codec ", a_elem);
Daniel Willmannafce8662018-07-06 23:11:32 +02003544 mtc.stop;
Harald Welte60aa5762018-03-21 19:33:13 +01003545 }
3546 }
3547 return ret;
3548}
3549
Harald Weltea63b9102018-03-22 20:36:16 +01003550private function f_rsl_chmod_tmpl_from_codec(BSSMAP_FIELD_CodecElement a_elem)
3551return template RSL_IE_Body {
3552 var template RSL_IE_Body mode_ie := {
3553 chan_mode := {
3554 len := ?,
3555 reserved := ?,
3556 dtx_d := ?,
3557 dtx_u := ?,
3558 spd_ind := RSL_SPDI_SPEECH,
3559 ch_rate_type := -,
3560 coding_alg_rate := -
3561 }
3562 }
3563
3564 select (a_elem.codecType) {
3565 case (GSM_FR) {
3566 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_F;
3567 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM1;
3568 }
3569 case (GSM_HR) {
3570 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_H;
3571 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM1;
3572 }
3573 case (GSM_EFR) {
3574 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_F;
3575 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM2;
3576 }
3577 case (FR_AMR) {
3578 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_F;
3579 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM3;
3580 }
3581 case (HR_AMR) {
3582 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_H;
3583 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM3;
3584 }
3585 }
3586 return mode_ie;
3587}
3588
Harald Welte60aa5762018-03-21 19:33:13 +01003589type record CodecListTest {
3590 BSSMAP_IE_SpeechCodecList codec_list,
3591 charstring id
3592}
3593type record of CodecListTest CodecListTests
3594
3595private function f_TC_assignment_codec(charstring id) runs on MSC_ConnHdlr {
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02003596 var PDU_BSSAP ass_cmd := f_gen_ass_req(g_pars.use_osmux);
3597 var template PDU_BSSAP exp_compl := f_gen_exp_compl(g_pars.use_osmux);
Harald Welte60aa5762018-03-21 19:33:13 +01003598
3599 /* puzzle together the ASSIGNMENT REQ for given codec[s] */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003600 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
Harald Welte79f3f542018-05-25 20:02:37 +02003601 ass_cmd.pdu.bssmap.assignmentRequest.codecList := g_pars.ass_codec_list;
3602 exp_compl.pdu.bssmap.assignmentComplete.speechCodec.codecElements[0] :=
3603 g_pars.ass_codec_list.codecElements[0];
Philipp Maierd0e64b02019-03-13 14:15:23 +01003604 if (isvalue(g_pars.expect_mr_s0_s7)) {
3605 exp_compl.pdu.bssmap.assignmentComplete.speechCodec.codecElements[0].s0_7 :=
3606 g_pars.expect_mr_s0_s7;
3607 }
Harald Welte79f3f542018-05-25 20:02:37 +02003608 }
Harald Welte60aa5762018-03-21 19:33:13 +01003609 ass_cmd.pdu.bssmap.assignmentRequest.channelType :=
3610 f_BSSMAP_chtype_from_codec(g_pars.ass_codec_list.codecElements[0]);
Harald Welte60aa5762018-03-21 19:33:13 +01003611 log("expecting ASS COMPL like this: ", exp_compl);
3612
3613 f_establish_fully(ass_cmd, exp_compl);
Harald Weltea63b9102018-03-22 20:36:16 +01003614
3615 /* Verify that the RSL-side activation actually matches our expectations */
3616 var RSL_Message rsl := f_rslem_get_last_act(RSL_PROC, 0, g_chan_nr);
3617
3618 var RSL_IE_Body mode_ie;
3619 if (f_rsl_find_ie(rsl, RSL_IE_CHAN_MODE, mode_ie) == false) {
3620 setverdict(fail, "Couldn't find CHAN_MODE IE");
Daniel Willmannafce8662018-07-06 23:11:32 +02003621 mtc.stop;
Harald Weltea63b9102018-03-22 20:36:16 +01003622 }
3623 var template RSL_IE_Body t_mode_ie := f_rsl_chmod_tmpl_from_codec(g_pars.ass_codec_list.codecElements[0]);
3624 if (not match(mode_ie, t_mode_ie)) {
3625 setverdict(fail, "RSL Channel Mode IE doesn't match expectation");
3626 }
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02003627
3628 var RSL_IE_Body mr_conf;
3629 if (g_pars.expect_mr_conf_ie != omit) {
3630 if (f_rsl_find_ie(rsl, RSL_IE_MR_CONFIG, mr_conf) == false) {
3631 setverdict(fail, "Missing MR CONFIG IE in RSL Chan Activ");
Daniel Willmannafce8662018-07-06 23:11:32 +02003632 mtc.stop;
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02003633 }
3634 log("found RSL MR CONFIG IE: ", mr_conf);
3635
3636 if (not match(mr_conf, g_pars.expect_mr_conf_ie)) {
3637 setverdict(fail, "RSL MR CONFIG IE does not match expectation. Expected: ",
3638 g_pars.expect_mr_conf_ie);
3639 }
3640 } else {
3641 if (f_rsl_find_ie(rsl, RSL_IE_MR_CONFIG, mr_conf) == true) {
3642 log("found RSL MR CONFIG IE: ", mr_conf);
3643 setverdict(fail, "Found MR CONFIG IE in RSL Chan Activ, expecting omit");
Daniel Willmannafce8662018-07-06 23:11:32 +02003644 mtc.stop;
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02003645 }
3646 }
Harald Welte60aa5762018-03-21 19:33:13 +01003647}
3648
Philipp Maierd0e64b02019-03-13 14:15:23 +01003649private function f_TC_assignment_codec_fail(charstring id) runs on MSC_ConnHdlr {
3650
3651 var PDU_BSSAP ass_cmd := f_gen_ass_req();
3652 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
3653
3654 /* puzzle together the ASSIGNMENT REQ for given codec[s] */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003655 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
Philipp Maierd0e64b02019-03-13 14:15:23 +01003656 ass_cmd.pdu.bssmap.assignmentRequest.codecList := g_pars.ass_codec_list;
3657 }
3658 ass_cmd.pdu.bssmap.assignmentRequest.channelType :=
3659 f_BSSMAP_chtype_from_codec(g_pars.ass_codec_list.codecElements[0]);
3660 log("expecting ASS FAIL like this: ", exp_fail);
3661
3662 f_establish_fully(ass_cmd, exp_fail);
3663}
3664
Harald Welte60aa5762018-03-21 19:33:13 +01003665testcase TC_assignment_codec_fr() runs on test_CT {
Philipp Maier48604732018-10-09 15:00:37 +02003666 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte60aa5762018-03-21 19:33:13 +01003667 var MSC_ConnHdlr vc_conn;
3668
3669 f_init(1, true);
3670 f_sleep(1.0);
3671
3672 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
Harald Welte8863fa12018-05-10 20:15:27 +02003673 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01003674 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003675 f_shutdown_helper();
Harald Welte60aa5762018-03-21 19:33:13 +01003676}
3677
3678testcase TC_assignment_codec_hr() runs on test_CT {
Philipp Maier48604732018-10-09 15:00:37 +02003679 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte60aa5762018-03-21 19:33:13 +01003680 var MSC_ConnHdlr vc_conn;
3681
3682 f_init(1, true);
3683 f_sleep(1.0);
3684
3685 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR}));
Harald Welte8863fa12018-05-10 20:15:27 +02003686 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01003687 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003688 f_shutdown_helper();
Harald Welte60aa5762018-03-21 19:33:13 +01003689}
3690
3691testcase TC_assignment_codec_efr() runs on test_CT {
Philipp Maier48604732018-10-09 15:00:37 +02003692 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte60aa5762018-03-21 19:33:13 +01003693 var MSC_ConnHdlr vc_conn;
3694
3695 f_init(1, true);
3696 f_sleep(1.0);
3697
3698 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecEFR}));
Harald Welte8863fa12018-05-10 20:15:27 +02003699 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01003700 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003701 f_shutdown_helper();
Harald Welte60aa5762018-03-21 19:33:13 +01003702}
3703
Philipp Maierd0e64b02019-03-13 14:15:23 +01003704/* Allow 5,90k only (current default config) */
3705private function f_allow_amr_rate_5_90k() runs on test_CT {
Neels Hofmeyr2a5670b2020-11-25 23:39:57 +00003706 f_vty_cfg_msc(BSCVTY, 0, {
3707 "amr-config 12_2k forbidden",
3708 "amr-config 10_2k forbidden",
3709 "amr-config 7_95k forbidden",
3710 "amr-config 7_40k forbidden",
3711 "amr-config 6_70k forbidden",
3712 "amr-config 5_90k allowed",
3713 "amr-config 5_15k forbidden",
3714 "amr-config 4_75k forbidden"
3715 });
Philipp Maierd0e64b02019-03-13 14:15:23 +01003716}
3717
3718/* Allow 4,75k, 5,90k, 4,70k and 12,2k, which are the most common rates
3719 * ("Config-NB-Code = 1") */
3720private function f_allow_amr_rate_4_75k_5_90k_7_40k_12_20k() runs on test_CT {
Neels Hofmeyr2a5670b2020-11-25 23:39:57 +00003721 f_vty_cfg_msc(BSCVTY, 0, {
3722 "amr-config 12_2k allowed",
3723 "amr-config 10_2k forbidden",
3724 "amr-config 7_95k forbidden",
3725 "amr-config 7_40k allowed",
3726 "amr-config 6_70k forbidden",
3727 "amr-config 5_90k allowed",
3728 "amr-config 5_15k forbidden",
3729 "amr-config 4_75k allowed"
3730 });
Philipp Maierd0e64b02019-03-13 14:15:23 +01003731}
3732
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00003733private function f_vty_amr_start_mode_set(boolean fr, charstring startmode) runs on test_CT {
3734 var charstring tch;
3735 if (fr) {
3736 tch := "tch-f";
3737 } else {
3738 tch := "tch-h";
3739 }
3740 f_vty_cfg_bts(BSCVTY, 0, { "amr " & tch & " start-mode " & startmode });
3741}
3742
3743/* Set the AMR start-mode for this TCH back to the default configuration. */
3744private function f_vty_amr_start_mode_restore(boolean fr) runs on test_CT {
3745 f_vty_amr_start_mode_set(fr, "auto");
3746}
3747
Harald Welte60aa5762018-03-21 19:33:13 +01003748testcase TC_assignment_codec_amr_f() runs on test_CT {
Philipp Maier48604732018-10-09 15:00:37 +02003749 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte60aa5762018-03-21 19:33:13 +01003750 var MSC_ConnHdlr vc_conn;
Philipp Maier7695a0d2018-09-27 17:52:14 +02003751
3752 /* Note: This setups the codec configuration. The parameter payload in
3753 * mr_conf must be consistant with the parameter codecElements in pars
3754 * and also must match the amr-config in osmo-bsc.cfg! */
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02003755 var RSL_IE_Body mr_conf := {
3756 other := {
3757 len := 2,
3758 payload := '2804'O
3759 }
3760 };
Harald Welte60aa5762018-03-21 19:33:13 +01003761
Philipp Maier7695a0d2018-09-27 17:52:14 +02003762 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_F}));
Philipp Maier806f8f12019-03-12 12:13:41 +01003763 pars.ass_codec_list.codecElements[0].s0_7 := '00000100'B; /* 5,90k */
Philipp Maier7695a0d2018-09-27 17:52:14 +02003764 pars.ass_codec_list.codecElements[0].s8_15 := '01010111'B;
3765 pars.expect_mr_conf_ie := mr_conf;
3766
Harald Welte60aa5762018-03-21 19:33:13 +01003767 f_init(1, true);
3768 f_sleep(1.0);
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00003769 f_vty_amr_start_mode_set(true, "1");
Harald Welte60aa5762018-03-21 19:33:13 +01003770
Harald Welte8863fa12018-05-10 20:15:27 +02003771 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01003772 vc_conn.done;
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00003773
3774 f_vty_amr_start_mode_restore(true);
Vadim Yanitskiy292e5962021-01-03 14:18:47 +01003775 f_shutdown_helper();
Harald Welte60aa5762018-03-21 19:33:13 +01003776}
3777
3778testcase TC_assignment_codec_amr_h() runs on test_CT {
Philipp Maier48604732018-10-09 15:00:37 +02003779 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte60aa5762018-03-21 19:33:13 +01003780 var MSC_ConnHdlr vc_conn;
Philipp Maier7695a0d2018-09-27 17:52:14 +02003781
3782 /* See note above */
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02003783 var RSL_IE_Body mr_conf := {
3784 other := {
3785 len := 2,
3786 payload := '2804'O
3787 }
3788 };
Harald Welte60aa5762018-03-21 19:33:13 +01003789
Philipp Maier7695a0d2018-09-27 17:52:14 +02003790 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_H}));
Philipp Maier806f8f12019-03-12 12:13:41 +01003791 pars.ass_codec_list.codecElements[0].s0_7 := '00000100'B; /* 5,90k */
Philipp Maier7695a0d2018-09-27 17:52:14 +02003792 pars.ass_codec_list.codecElements[0].s8_15 := '00000111'B;
3793 pars.expect_mr_conf_ie := mr_conf;
3794
Harald Welte60aa5762018-03-21 19:33:13 +01003795 f_init(1, true);
3796 f_sleep(1.0);
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00003797 f_vty_amr_start_mode_set(false, "1");
Harald Welte60aa5762018-03-21 19:33:13 +01003798
Harald Welte8863fa12018-05-10 20:15:27 +02003799 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01003800 vc_conn.done;
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00003801
3802 f_vty_amr_start_mode_restore(false);
Vadim Yanitskiy292e5962021-01-03 14:18:47 +01003803 f_shutdown_helper();
Harald Welte60aa5762018-03-21 19:33:13 +01003804}
3805
Neels Hofmeyr454d7922020-11-26 02:24:57 +00003806/* 'amr start-mode auto' should not keep the (unused) 'smod' bits from previous configuration */
3807testcase TC_assignment_codec_amr_startmode_cruft() runs on test_CT {
3808 var TestHdlrParams pars := f_gen_test_hdlr_pars();
3809 var MSC_ConnHdlr vc_conn;
3810
3811 var RSL_IE_Body mr_conf := {
3812 other := {
3813 len := 2,
3814 payload := '2004'O /* <- expect ICMI=0, smod=00 */
3815 }
3816 };
3817
3818 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_F}));
3819 pars.ass_codec_list.codecElements[0].s0_7 := '00000100'B; /* 5,90k */
3820 pars.ass_codec_list.codecElements[0].s8_15 := '01010111'B;
3821 pars.expect_mr_conf_ie := mr_conf;
3822
3823 f_init(1, true);
3824 f_sleep(1.0);
3825
3826 /* First set nonzero start mode bits */
3827 f_vty_amr_start_mode_set(true, "4");
3828 /* Now set to auto, and expect the startmode bits to be zero in the message, i.e. ensure that osmo-bsc does not
3829 * let the startmode bits stick around and has deterministic MultiRate config for 'start-mode auto'; that is
3830 * ensured by above '2004'O, where 'x0xx'O indicates ICMI = 0, spare = 0, smod = 00. */
3831 f_vty_amr_start_mode_set(true, "auto");
3832
3833 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
3834 vc_conn.done;
Neels Hofmeyr454d7922020-11-26 02:24:57 +00003835
3836 /* Clear the startmode bits to not affect subsequent tests, in case the bits should indeed stick around. */
3837 f_vty_amr_start_mode_set(true, "1");
3838 f_vty_amr_start_mode_restore(true);
Vadim Yanitskiy292e5962021-01-03 14:18:47 +01003839 f_shutdown_helper();
Neels Hofmeyr454d7922020-11-26 02:24:57 +00003840}
3841
Neels Hofmeyr21863562020-11-26 00:34:33 +00003842function f_TC_assignment_codec_amr(boolean fr, octetstring mrconf, bitstring s8_s0, bitstring exp_s8_s0,
3843 charstring start_mode := "1")
Philipp Maierd0e64b02019-03-13 14:15:23 +01003844runs on test_CT {
3845
3846 var TestHdlrParams pars := f_gen_test_hdlr_pars();
3847 var MSC_ConnHdlr vc_conn;
3848
3849 /* See note above */
3850 var RSL_IE_Body mr_conf := {
3851 other := {
3852 len := lengthof(mrconf),
3853 payload := mrconf
3854 }
3855 };
3856
3857 if (fr) {
3858 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_F}));
3859 } else {
3860 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_H}));
3861 }
3862 pars.ass_codec_list.codecElements[0].s0_7 := s8_s0;
3863 pars.ass_codec_list.codecElements[0].s8_15 := '00000111'B;
3864 pars.expect_mr_conf_ie := mr_conf;
3865 pars.expect_mr_s0_s7 := exp_s8_s0;
3866
3867 f_init(1, true);
3868 f_allow_amr_rate_4_75k_5_90k_7_40k_12_20k();
Neels Hofmeyr21863562020-11-26 00:34:33 +00003869 f_vty_amr_start_mode_set(fr, start_mode);
Philipp Maierd0e64b02019-03-13 14:15:23 +01003870 f_sleep(1.0);
3871
3872 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
3873 vc_conn.done;
3874 f_allow_amr_rate_5_90k();
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00003875 f_vty_amr_start_mode_restore(fr);
Philipp Maierd0e64b02019-03-13 14:15:23 +01003876}
3877
3878function f_TC_assignment_codec_amr_fail(boolean fr, bitstring s8_s0)
3879runs on test_CT {
3880
3881 var TestHdlrParams pars := f_gen_test_hdlr_pars();
3882 var MSC_ConnHdlr vc_conn;
3883
3884 if (fr) {
3885 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_F}));
3886 } else {
3887 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_H}));
3888 }
3889 pars.ass_codec_list.codecElements[0].s0_7 := s8_s0;
3890 pars.ass_codec_list.codecElements[0].s8_15 := '00000111'B;
3891
3892 f_init(1, true);
3893 f_allow_amr_rate_4_75k_5_90k_7_40k_12_20k();
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00003894 f_vty_amr_start_mode_set(fr, "1");
Philipp Maierd0e64b02019-03-13 14:15:23 +01003895 f_sleep(1.0);
3896
3897 vc_conn := f_start_handler(refers(f_TC_assignment_codec_fail), pars);
3898 vc_conn.done;
3899 f_allow_amr_rate_5_90k();
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00003900 f_vty_amr_start_mode_restore(fr);
Philipp Maierd0e64b02019-03-13 14:15:23 +01003901}
3902
3903
3904/* Set S1, we expect an AMR multirate configuration IE with all four rates
3905 * set. */
3906testcase TC_assignment_codec_amr_f_S1() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003907 f_TC_assignment_codec_amr(true, '289520882208'O, '00000010'B, '00000010'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003908 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003909}
3910
3911/* Set S1, we expect an AMR multirate configuration IE with the lower three
3912 * rates set. */
3913testcase TC_assignment_codec_amr_h_S1() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003914 f_TC_assignment_codec_amr(false, '2815208820'O, '00000010'B, '00000010'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003915 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003916}
3917
3918/* Set S1 and two other rates, we expect an AMR MULTIRATE CONFIGURATION IE with
3919 * all four rates (and only S1 set in the ASSIGNMENT COMPLETE) */
3920testcase TC_assignment_codec_amr_f_S124() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003921 f_TC_assignment_codec_amr(true, '289520882208'O, '00010110'B, '00000010'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003922 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003923}
3924
3925/* Set S1 and two other rates, we expect an AMR MULTIRATE CONFIGURATION IE with
3926 * all four rates (and only S1 set in the ASSIGNMENT COMPLETE) */
3927testcase TC_assignment_codec_amr_h_S124() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003928 f_TC_assignment_codec_amr(false, '2815208820'O, '00010110'B, '00000010'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003929 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003930}
3931
3932/* The following block of tests selects more and more rates until all four
3933 * possible rates are in the active set (full rate) */
3934testcase TC_assignment_codec_amr_f_S0() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003935 f_TC_assignment_codec_amr(true, '2801'O, '00000001'B, '00000001'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003936 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003937}
3938
3939testcase TC_assignment_codec_amr_f_S02() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003940 f_TC_assignment_codec_amr(true, '28052080'O, '00000101'B, '00000101'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003941 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003942}
3943
3944testcase TC_assignment_codec_amr_f_S024() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003945 f_TC_assignment_codec_amr(true, '2815208820'O, '00010101'B, '00010101'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003946 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003947}
3948
3949testcase TC_assignment_codec_amr_f_S0247() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003950 f_TC_assignment_codec_amr(true, '289520882208'O, '10010101'B, '10010101'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003951 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003952}
3953
3954/* The following block of tests selects more and more rates until all three
3955 * possible rates are in the active set (half rate) */
3956testcase TC_assignment_codec_amr_h_S0() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003957 f_TC_assignment_codec_amr(false, '2801'O, '00000001'B, '00000001'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003958 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003959}
3960
3961testcase TC_assignment_codec_amr_h_S02() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003962 f_TC_assignment_codec_amr(false, '28052080'O, '00000101'B, '00000101'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003963 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003964}
3965
3966testcase TC_assignment_codec_amr_h_S024() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003967 f_TC_assignment_codec_amr(false, '2815208820'O, '00010101'B, '00010101'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003968 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003969}
3970
3971/* The following block tests what happens when the MSC does offer rate
3972 * configurations that are not supported by the BSC. Normally such situations
3973 * should not happen because the MSC gets informed by the BSC in advance via
3974 * the L3 COMPLETE message which rates are applicable. The MSC should not try
3975 * to offer rates that are not applicable anyway. */
3976
3977testcase TC_assignment_codec_amr_h_S0247() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003978 /* Try to include 12,2k in into the active set even though the channel
3979 * is half rate only. The BSC is expected to remove the 12,0k */
3980 f_TC_assignment_codec_amr(false, '2815208820'O, '10010101'B, '00010101'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003981 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003982}
3983
3984testcase TC_assignment_codec_amr_f_S01234567() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003985 /* See what happens when all rates are selected at once. Since then
3986 * Also S1 is selected, this setting will be prefered and we should
3987 * get 12.2k, 7,40k, 5,90k, and 4,75k in the active set. */
3988 f_TC_assignment_codec_amr(true, '289520882208'O, '11111111'B, '00000010'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003989 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003990}
3991
3992testcase TC_assignment_codec_amr_f_S0234567() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003993 /* Same as above, but with S1 missing, the MSC is then expected to
3994 * select the currently supported rates, which are also 12.2k, 7,40k,
3995 * 5,90k, and 4,75k, into the active set. */
3996 f_TC_assignment_codec_amr(true, '289520882208'O, '11111101'B, '10010101'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003997 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003998}
3999
4000testcase TC_assignment_codec_amr_f_zero() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02004001 /* Try to select no rates at all */
4002 f_TC_assignment_codec_amr_fail(true, '00000000'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004003 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01004004}
4005
4006testcase TC_assignment_codec_amr_f_unsupp() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02004007 /* Try to select only unsupported rates */
4008 f_TC_assignment_codec_amr_fail(true, '01101000'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004009 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01004010}
4011
4012testcase TC_assignment_codec_amr_h_S7() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02004013 /* Try to select 12,2k for half rate */
4014 f_TC_assignment_codec_amr_fail(false, '10000000'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004015 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01004016}
4017
Neels Hofmeyr21863562020-11-26 00:34:33 +00004018testcase TC_assignment_codec_amr_f_start_mode_auto() runs on test_CT {
4019 f_TC_assignment_codec_amr(true, '209520882208'O, '11111111'B, '00000010'B,
4020 start_mode := "auto");
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01004021 f_shutdown_helper();
Neels Hofmeyr21863562020-11-26 00:34:33 +00004022}
4023
4024testcase TC_assignment_codec_amr_h_start_mode_auto() runs on test_CT {
4025 f_TC_assignment_codec_amr(false, '2015208820'O, '10010101'B, '00010101'B,
4026 start_mode := "auto");
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01004027 f_shutdown_helper();
Neels Hofmeyr21863562020-11-26 00:34:33 +00004028}
4029
Neels Hofmeyr3eb94562020-11-26 02:40:26 +00004030testcase TC_assignment_codec_amr_f_start_mode_4() runs on test_CT {
Vadim Yanitskiy7815f482021-01-03 17:07:37 +01004031 /* "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 +00004032 f_TC_assignment_codec_amr(true, '2b9520882208'O, '11111111'B, '00000010'B,
4033 start_mode := "4");
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01004034 f_shutdown_helper();
Neels Hofmeyr3eb94562020-11-26 02:40:26 +00004035}
4036
4037testcase TC_assignment_codec_amr_h_start_mode_4() runs on test_CT {
Vadim Yanitskiy7815f482021-01-03 17:07:37 +01004038 /* "amr tch-h modes 0 2 4" => total 3 modes and start mode 4 => '10'B on the wire */
4039 f_TC_assignment_codec_amr(false, '2a15208820'O, '10010101'B, '00010101'B,
Neels Hofmeyr3eb94562020-11-26 02:40:26 +00004040 start_mode := "4");
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01004041 f_shutdown_helper();
Neels Hofmeyr3eb94562020-11-26 02:40:26 +00004042}
4043
Philipp Maierac09bfc2019-01-08 13:41:39 +01004044private function f_disable_all_tch_f() runs on test_CT {
Philipp Maierc704a882019-01-29 15:58:52 +01004045 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 1 sub-slot 0 borken");
4046 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 2 sub-slot 0 borken");
4047 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 3 sub-slot 0 borken");
4048 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 4 sub-slot 0 borken");
Philipp Maierac09bfc2019-01-08 13:41:39 +01004049}
4050
4051private function f_disable_all_tch_h() runs on test_CT {
Philipp Maierc704a882019-01-29 15:58:52 +01004052 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 5 sub-slot 0 borken");
4053 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 5 sub-slot 1 borken");
Philipp Maierac09bfc2019-01-08 13:41:39 +01004054}
4055
4056private function f_enable_all_tch() runs on test_CT {
Philipp Maierc704a882019-01-29 15:58:52 +01004057 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 1 sub-slot 0 unused");
4058 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 2 sub-slot 0 unused");
4059 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 3 sub-slot 0 unused");
4060 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 4 sub-slot 0 unused");
4061 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 5 sub-slot 0 unused");
4062 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 5 sub-slot 1 unused");
Philipp Maierac09bfc2019-01-08 13:41:39 +01004063}
4064
4065/* Allow HR only */
4066private function f_TC_assignment_codec_xr_exhausted_req_hr(charstring id) runs on MSC_ConnHdlr {
4067 g_pars := f_gen_test_hdlr_pars();
4068 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4069 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4070 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4071 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '09'O;
4072 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '05'O;
4073 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR}));
4074 f_establish_fully(ass_cmd, exp_compl);
4075}
4076
4077/* Allow FR only */
4078private function f_TC_assignment_codec_xr_exhausted_req_fr(charstring id) runs on MSC_ConnHdlr {
4079 g_pars := f_gen_test_hdlr_pars();
4080 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4081 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4082 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4083 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '08'O;
4084 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '01'O;
4085 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
4086 f_establish_fully(ass_cmd, exp_compl);
4087}
4088
4089/* Allow HR only (expect assignment failure) */
4090private function f_TC_assignment_codec_xr_exhausted_req_hr_fail(charstring id) runs on MSC_ConnHdlr {
4091 g_pars := f_gen_test_hdlr_pars();
4092 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4093 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
4094 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4095 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '09'O;
4096 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '05'O;
4097 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR}));
4098 f_establish_fully(ass_cmd, exp_fail);
4099}
4100
4101/* Allow FR only (expect assignment failure) */
4102private function f_TC_assignment_codec_xr_exhausted_req_fr_fail(charstring id) runs on MSC_ConnHdlr {
4103 g_pars := f_gen_test_hdlr_pars();
4104 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4105 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
4106 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4107 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '08'O;
4108 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '01'O;
4109 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
4110 f_establish_fully(ass_cmd, exp_fail);
4111}
4112
4113/* Allow FR and HR, but prefer FR */
4114private function f_TC_assignment_codec_fr_exhausted_req_fr_hr(charstring id) runs on MSC_ConnHdlr {
4115 g_pars := f_gen_test_hdlr_pars();
4116 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4117 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4118 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4119 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0A'O; /* Prefer FR */
4120 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8105'O;
4121 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR, ts_CodecHR}));
4122 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000101'B; /* Expect HR */
4123 f_establish_fully(ass_cmd, exp_compl);
4124}
4125
4126/* Allow FR and HR, but prefer HR */
4127private function f_TC_assignment_codec_fr_exhausted_req_hr_fr(charstring id) runs on MSC_ConnHdlr {
4128 g_pars := f_gen_test_hdlr_pars();
4129 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4130 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4131 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4132 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0B'O; /* Prefer HR */
4133 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8501'O;
4134 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR, ts_CodecFR}));
4135 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000101'B; /* Expect HR */
4136 f_establish_fully(ass_cmd, exp_compl);
4137}
4138
4139/* Allow FR and HR, but prefer FR */
4140private function f_TC_assignment_codec_hr_exhausted_req_fr_hr(charstring id) runs on MSC_ConnHdlr {
4141 g_pars := f_gen_test_hdlr_pars();
4142 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4143 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4144 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4145 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0A'O; /* Prefer FR */
4146 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8105'O;
4147 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR, ts_CodecHR}));
4148 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000001'B; /* Expect FR */
4149 f_establish_fully(ass_cmd, exp_compl);
4150}
4151
4152/* Allow FR and HR, but prefer HR */
4153private function f_TC_assignment_codec_hr_exhausted_req_hr_fr(charstring id) runs on MSC_ConnHdlr {
4154 g_pars := f_gen_test_hdlr_pars();
4155 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4156 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4157 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4158 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0B'O; /* Prefer HR */
4159 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8501'O;
4160 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR, ts_CodecFR}));
4161 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000001'B; /* Expect FR */
4162 f_establish_fully(ass_cmd, exp_compl);
4163}
4164
4165/* Request a HR channel while all FR channels are exhausted, this is expected
4166 * to work without conflicts */
4167testcase TC_assignment_codec_fr_exhausted_req_hr() runs on test_CT {
4168 var MSC_ConnHdlr vc_conn;
4169 f_init(1, true);
4170 f_sleep(1.0);
4171 f_enable_all_tch();
4172 f_disable_all_tch_f();
4173 vc_conn := f_start_handler(refers(f_TC_assignment_codec_xr_exhausted_req_hr));
4174 vc_conn.done;
4175 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004176 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004177}
4178
4179/* Request a FR channel while all FR channels are exhausted, this is expected
4180 * to fail. */
4181testcase TC_assignment_codec_fr_exhausted_req_fr() runs on test_CT {
4182 var MSC_ConnHdlr vc_conn;
4183 f_init(1, true);
4184 f_sleep(1.0);
4185 f_enable_all_tch();
4186 f_disable_all_tch_f();
4187 vc_conn := f_start_handler(refers(f_TC_assignment_codec_xr_exhausted_req_fr_fail));
4188 vc_conn.done;
4189 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004190 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004191}
4192
4193/* Request a FR (prefered) or alternatively a HR channel while all FR channels
4194 * are exhausted, this is expected to be resolved by selecting a HR channel. */
4195testcase TC_assignment_codec_fr_exhausted_req_fr_hr() runs on test_CT {
4196 var MSC_ConnHdlr vc_conn;
4197 f_init(1, true);
4198 f_sleep(1.0);
4199 f_enable_all_tch();
4200 f_disable_all_tch_f();
4201 vc_conn := f_start_handler(refers(f_TC_assignment_codec_fr_exhausted_req_fr_hr));
4202 vc_conn.done;
4203 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004204 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004205}
4206
4207/* Request a HR (prefered) or alternatively a FR channel while all FR channels
4208 * are exhausted, this is expected to work without conflicts. */
4209testcase TC_assignment_codec_fr_exhausted_req_hr_fr() runs on test_CT {
4210 var MSC_ConnHdlr vc_conn;
4211 f_init(1, true);
4212 f_sleep(1.0);
4213 f_enable_all_tch();
4214 f_disable_all_tch_f();
4215 vc_conn := f_start_handler(refers(f_TC_assignment_codec_fr_exhausted_req_hr_fr));
4216 vc_conn.done;
4217 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004218 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004219}
4220
4221/* Request a FR channel while all HR channels are exhausted, this is expected
4222 * to work without conflicts */
4223testcase TC_assignment_codec_hr_exhausted_req_fr() runs on test_CT {
4224 var MSC_ConnHdlr vc_conn;
4225 f_init(1, true);
4226 f_sleep(1.0);
4227 f_enable_all_tch();
4228 f_disable_all_tch_h();
4229 vc_conn := f_start_handler(refers(f_TC_assignment_codec_xr_exhausted_req_fr));
4230 vc_conn.done;
4231 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004232 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004233}
4234
4235/* Request a HR channel while all HR channels are exhausted, this is expected
4236 * to fail. */
4237testcase TC_assignment_codec_hr_exhausted_req_hr() runs on test_CT {
4238 var MSC_ConnHdlr vc_conn;
4239 f_init(1, true);
4240 f_sleep(1.0);
4241 f_enable_all_tch();
4242 f_disable_all_tch_h();
4243 vc_conn := f_start_handler(refers(f_TC_assignment_codec_xr_exhausted_req_hr_fail));
4244 vc_conn.done;
4245 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004246 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004247}
4248
4249/* Request a HR (prefered) or alternatively a FR channel while all HR channels
4250 * are exhausted, this is expected to be resolved by selecting a FR channel. */
4251testcase TC_assignment_codec_hr_exhausted_req_hr_fr() runs on test_CT {
4252 var MSC_ConnHdlr vc_conn;
4253 f_init(1, true);
4254 f_sleep(1.0);
4255 f_enable_all_tch();
4256 f_disable_all_tch_h();
4257 vc_conn := f_start_handler(refers(f_TC_assignment_codec_hr_exhausted_req_hr_fr));
4258 vc_conn.done;
4259 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004260 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004261}
4262
4263/* Request a FR (prefered) or alternatively a HR channel while all HR channels
4264 * are exhausted, this is expected to work without conflicts. */
4265testcase TC_assignment_codec_hr_exhausted_req_fr_hr() runs on test_CT {
4266 var MSC_ConnHdlr vc_conn;
4267 f_init(1, true);
4268 f_sleep(1.0);
4269 f_enable_all_tch();
4270 f_disable_all_tch_h();
4271 vc_conn := f_start_handler(refers(f_TC_assignment_codec_hr_exhausted_req_fr_hr));
4272 vc_conn.done;
4273 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004274 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004275}
4276
4277/* Allow FR and HR, but prefer HR */
4278private function f_TC_assignment_codec_req_hr_fr(charstring id) runs on MSC_ConnHdlr {
4279 g_pars := f_gen_test_hdlr_pars();
4280 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4281 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4282 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4283 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0B'O; /* Prefer HR */
4284 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8501'O;
4285 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR, ts_CodecFR}));
4286 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000101'B; /* Expect HR */
4287 f_establish_fully(ass_cmd, exp_compl);
4288}
4289
4290/* Allow FR and HR, but prefer FR */
4291private function f_TC_assignment_codec_req_fr_hr(charstring id) runs on MSC_ConnHdlr {
4292 g_pars := f_gen_test_hdlr_pars();
4293 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4294 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4295 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4296 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0A'O; /* Prefer FR */
4297 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8105'O;
4298 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR, ts_CodecHR}));
4299 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000001'B; /* Expect FR */
4300 f_establish_fully(ass_cmd, exp_compl);
4301}
4302
4303/* Request a HR (prefered) or alternatively a FR channel, it is expected that
4304 * HR, which is the prefered type, is selected. */
4305testcase TC_assignment_codec_req_hr_fr() runs on test_CT {
4306 var MSC_ConnHdlr vc_conn;
4307 f_init(1, true);
4308 f_sleep(1.0);
4309 f_enable_all_tch();
4310 vc_conn := f_start_handler(refers(f_TC_assignment_codec_req_hr_fr));
4311 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004312 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004313}
4314
4315/* Request a FR (prefered) or alternatively a HR channel, it is expected that
4316 * FR, which is the prefered type, is selected. */
4317testcase TC_assignment_codec_req_fr_hr() runs on test_CT {
4318 var MSC_ConnHdlr vc_conn;
4319 f_init(1, true);
4320 f_sleep(1.0);
4321 f_enable_all_tch();
4322 vc_conn := f_start_handler(refers(f_TC_assignment_codec_req_fr_hr));
4323 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004324 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004325}
4326
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02004327testcase TC_assignment_osmux() runs on test_CT {
4328 var TestHdlrParams pars := f_gen_test_hdlr_pars();
4329 var MSC_ConnHdlr vc_conn;
4330
4331 /* See note above */
4332 var RSL_IE_Body mr_conf := {
4333 other := {
4334 len := 2,
4335 payload := '2804'O
4336 }
4337 };
4338
4339 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_H}));
4340 pars.ass_codec_list.codecElements[0].s0_7 := '00000100'B; /* 5,90k */
4341 pars.ass_codec_list.codecElements[0].s8_15 := '00000111'B;
4342 pars.expect_mr_conf_ie := mr_conf;
4343 pars.use_osmux := true;
4344
4345 f_init(1, true, true);
4346 f_sleep(1.0);
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00004347 f_vty_amr_start_mode_set(false, "1");
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02004348
4349 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
4350 vc_conn.done;
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00004351
4352 f_vty_amr_start_mode_restore(false);
Vadim Yanitskiy292e5962021-01-03 14:18:47 +01004353 f_shutdown_helper();
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02004354}
4355
Neels Hofmeyr92b12b72018-09-18 14:30:23 +02004356/* test the procedure of the MSC requesting a Classmark Update:
4357 * a) BSSMAP Classmark Request should result in RR CLASSMARK ENQUIRY,
4358 * b) L3 RR CLASSMARK CHANGE should result in BSSMAP CLASSMARK UPDATE */
Harald Welte898113b2018-01-31 18:32:21 +01004359private function f_tc_classmark(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02004360 g_pars := f_gen_test_hdlr_pars();
4361
Harald Weltea0630032018-03-20 21:09:55 +01004362 f_create_chan_and_exp();
Harald Welte898113b2018-01-31 18:32:21 +01004363 /* we should now have a COMPL_L3 at the MSC */
4364 BSSAP.receive(tr_BSSMAP_ComplL3);
4365
Neels Hofmeyr92b12b72018-09-18 14:30:23 +02004366 BSSAP.send(ts_BSSMAP_ClassmarkRequest);
4367 RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_CM_ENQUIRY));
4368
Harald Welte898113b2018-01-31 18:32:21 +01004369 f_rsl_send_l3(ts_RRM_CM_CHG(valueof(ts_CM2)));
4370 BSSAP.receive(tr_BSSMAP_ClassmarkUpd(?, omit));
4371 setverdict(pass);
4372}
4373testcase TC_classmark() runs on test_CT {
4374 var MSC_ConnHdlr vc_conn;
4375 f_init(1, true);
4376 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02004377 vc_conn := f_start_handler(refers(f_tc_classmark));
Harald Welte898113b2018-01-31 18:32:21 +01004378 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004379 f_shutdown_helper();
Harald Welte898113b2018-01-31 18:32:21 +01004380}
4381
Harald Welteeddf0e92020-06-21 19:42:15 +02004382/* Send a CommonID from the simulated MSC and verify that the information is used to
4383 * fill BSC-internal data structures (specifically, bsc_subscr associated with subscr_conn) */
4384private function f_tc_common_id(charstring id) runs on MSC_ConnHdlr {
4385 g_pars := f_gen_test_hdlr_pars();
4386 f_MscConnHdlr_init_vty();
4387
4388 f_create_chan_and_exp();
4389 /* we should now have a COMPL_L3 at the MSC */
4390 BSSAP.receive(tr_BSSMAP_ComplL3);
4391
4392 /* Send CommonID */
4393 BSSAP.send(ts_BSSMAP_CommonId(g_pars.imsi));
4394
4395 /* Use VTY to verify that the IMSI of the subscr_conn is set */
4396 var charstring regex := "*(IMSI: " & hex2str(g_pars.imsi) & ")*";
4397 f_vty_transceive_match_regexp_retry(BSCVTY, "show conns", regex, 0, 4, 1.0);
4398
4399 setverdict(pass);
4400}
4401testcase TC_common_id() runs on test_CT {
4402 var MSC_ConnHdlr vc_conn;
4403 f_init(1, true);
4404 f_sleep(1.0);
4405 vc_conn := f_start_handler(refers(f_tc_common_id));
4406 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004407 f_shutdown_helper();
Harald Welteeddf0e92020-06-21 19:42:15 +02004408}
4409
Harald Weltee3bd6582018-01-31 22:51:25 +01004410private function f_est_single_l3(template PDU_ML3_MS_NW l3) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02004411 g_pars := f_gen_test_hdlr_pars();
Harald Weltea0630032018-03-20 21:09:55 +01004412 f_create_chan_and_exp();
Harald Welte898113b2018-01-31 18:32:21 +01004413 /* we should now have a COMPL_L3 at the MSC */
4414 BSSAP.receive(tr_BSSMAP_ComplL3);
4415
Harald Weltee3bd6582018-01-31 22:51:25 +01004416 /* send the single message we want to send */
4417 f_rsl_send_l3(l3);
4418}
4419
4420private function f_bssap_expect_nothing(float sec := 5.00) runs on MSC_ConnHdlr {
4421 timer T := sec;
4422 var PDU_BSSAP bssap;
Harald Welte898113b2018-01-31 18:32:21 +01004423 T.start;
4424 alt {
Harald Weltee3bd6582018-01-31 22:51:25 +01004425 [] BSSAP.receive(PDU_BSSAP:?) -> value bssap {
4426 setverdict(fail, "Unexpected BSSMAP ", bssap);
Daniel Willmannafce8662018-07-06 23:11:32 +02004427 mtc.stop;
Harald Welte898113b2018-01-31 18:32:21 +01004428 }
4429 [] T.timeout {
4430 setverdict(pass);
4431 }
4432 }
4433}
4434
Harald Weltee3bd6582018-01-31 22:51:25 +01004435/* unsolicited ASSIGNMENT FAIL (without ASSIGN) from MS shouldn't bring BSC down */
4436private function f_tc_unsol_ass_fail(charstring id) runs on MSC_ConnHdlr {
4437 f_est_single_l3(ts_RRM_AssignmentFailure('00'O));
4438 f_bssap_expect_nothing();
4439}
Harald Welte898113b2018-01-31 18:32:21 +01004440testcase TC_unsol_ass_fail() runs on test_CT {
4441 var MSC_ConnHdlr vc_conn;
4442 f_init(1, true);
4443 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02004444 vc_conn := f_start_handler(refers(f_tc_unsol_ass_fail));
Harald Welte898113b2018-01-31 18:32:21 +01004445 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004446 f_shutdown_helper();
Harald Welte898113b2018-01-31 18:32:21 +01004447}
Harald Welte552620d2017-12-16 23:21:36 +01004448
Harald Welteea99a002018-01-31 20:46:43 +01004449
4450/* unsolicited ASSIGNMENT COMPLETE (without ASSIGN) from MS shouldn't bring BSC down */
4451private function f_tc_unsol_ass_compl(charstring id) runs on MSC_ConnHdlr {
Harald Weltee3bd6582018-01-31 22:51:25 +01004452 f_est_single_l3(ts_RRM_AssignmentComplete('00'O));
4453 f_bssap_expect_nothing();
Harald Welteea99a002018-01-31 20:46:43 +01004454}
4455testcase TC_unsol_ass_compl() runs on test_CT {
4456 var MSC_ConnHdlr vc_conn;
4457 f_init(1, true);
4458 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02004459 vc_conn := f_start_handler(refers(f_tc_unsol_ass_compl));
Harald Welteea99a002018-01-31 20:46:43 +01004460 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004461 f_shutdown_helper();
Harald Welteea99a002018-01-31 20:46:43 +01004462}
4463
4464
Harald Weltefbf9b5e2018-01-31 20:41:23 +01004465/* unsolicited HANDOVER FAIL (without ASSIGN) from MS shouldn't bring BSC down */
4466private function f_tc_unsol_ho_fail(charstring id) runs on MSC_ConnHdlr {
Harald Weltee3bd6582018-01-31 22:51:25 +01004467 f_est_single_l3(ts_RRM_HandoverFailure('00'O));
4468 f_bssap_expect_nothing();
Harald Weltefbf9b5e2018-01-31 20:41:23 +01004469}
Harald Weltefbf9b5e2018-01-31 20:41:23 +01004470testcase TC_unsol_ho_fail() runs on test_CT {
4471 var MSC_ConnHdlr vc_conn;
4472 f_init(1, true);
4473 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02004474 vc_conn := f_start_handler(refers(f_tc_unsol_ho_fail));
Harald Weltefbf9b5e2018-01-31 20:41:23 +01004475 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004476 f_shutdown_helper();
Harald Weltefbf9b5e2018-01-31 20:41:23 +01004477}
4478
4479
Harald Weltee3bd6582018-01-31 22:51:25 +01004480/* short message from MS should be ignored */
4481private function f_tc_err_82_short_msg(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02004482 g_pars := f_gen_test_hdlr_pars();
Harald Weltea0630032018-03-20 21:09:55 +01004483 f_create_chan_and_exp();
Harald Weltee3bd6582018-01-31 22:51:25 +01004484 /* we should now have a COMPL_L3 at the MSC */
4485 BSSAP.receive(tr_BSSMAP_ComplL3);
4486
4487 /* send short message */
4488 RSL.send(ts_RSL_DATA_IND(g_chan_nr, valueof(ts_RslLinkID_DCCH(0)), ''O));
4489 f_bssap_expect_nothing();
4490}
4491testcase TC_err_82_short_msg() runs on test_CT {
4492 var MSC_ConnHdlr vc_conn;
4493 f_init(1, true);
4494 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02004495 vc_conn := f_start_handler(refers(f_tc_err_82_short_msg));
Harald Weltee3bd6582018-01-31 22:51:25 +01004496 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004497 f_shutdown_helper();
Harald Weltee3bd6582018-01-31 22:51:25 +01004498}
4499
4500
Harald Weltee9e02e42018-01-31 23:36:25 +01004501/* 24.008 8.4 Unknown message must trigger RR STATUS */
4502private function f_tc_err_84_unknown_msg(charstring id) runs on MSC_ConnHdlr {
4503 f_est_single_l3(ts_RRM_UL_REL('00'O));
4504 timer T := 3.0
4505 alt {
4506 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_STATUS)) {
4507 setverdict(pass);
4508 }
4509 [] BSSAP.receive { setverdict(fail, "unexpected BSSAP"); }
Harald Welte458fd372018-03-21 11:26:23 +01004510 [] T.timeout { setverdict(fail, "Timeout waiting for RR STATUS"); }
Harald Weltee9e02e42018-01-31 23:36:25 +01004511 }
4512}
4513testcase TC_err_84_unknown_msg() runs on test_CT {
4514 var MSC_ConnHdlr vc_conn;
4515 f_init(1, true);
4516 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02004517 vc_conn := f_start_handler(refers(f_tc_err_84_unknown_msg));
Harald Weltee9e02e42018-01-31 23:36:25 +01004518 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004519 f_shutdown_helper();
Harald Weltee9e02e42018-01-31 23:36:25 +01004520}
4521
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004522/***********************************************************************
4523 * Handover
4524 ***********************************************************************/
4525
Harald Welte94e0c342018-04-07 11:33:23 +02004526/* execute a "bts <0-255> trx <0-255> timeslot <0-7> " command on given Dchan */
4527private function f_vty_ts_action(charstring suffix, integer bts_nr, integer trx_nr, integer ts_nr)
4528runs on test_CT {
4529 var charstring cmd := "bts "&int2str(bts_nr)&" trx "&int2str(trx_nr)&
4530 " timeslot "&int2str(ts_nr)&" ";
4531 f_vty_transceive(BSCVTY, cmd & suffix);
4532}
4533
Harald Welte261af4b2018-02-12 21:20:39 +01004534/* 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 +07004535private function f_vty_ss_action(TELNETasp_PT pt, charstring suffix,
4536 uint8_t bts_nr, uint8_t trx_nr,
4537 in RslChannelNr chan_nr)
4538{
Harald Welte261af4b2018-02-12 21:20:39 +01004539 /* FIXME: resolve those from component-global state */
4540 var integer ts_nr := chan_nr.tn;
4541 var integer ss_nr;
4542 if (ischosen(chan_nr.u.ch0)) {
4543 ss_nr := 0;
4544 } else if (ischosen(chan_nr.u.lm)) {
4545 ss_nr := chan_nr.u.lm.sub_chan;
4546 } else if (ischosen(chan_nr.u.sdcch4)) {
4547 ss_nr := chan_nr.u.sdcch4.sub_chan;
4548 } else if (ischosen(chan_nr.u.sdcch8)) {
4549 ss_nr := chan_nr.u.sdcch8.sub_chan;
4550 } else {
4551 setverdict(fail, "Invalid ChanNr ", chan_nr);
Daniel Willmannafce8662018-07-06 23:11:32 +02004552 mtc.stop;
Harald Welte261af4b2018-02-12 21:20:39 +01004553 }
4554
4555 var charstring cmd := "bts "&int2str(bts_nr)&" trx "&int2str(trx_nr)&
4556 " timeslot "&int2str(ts_nr)&" sub-slot "&int2str(ss_nr)&" ";
Vadim Yanitskiy00070722020-09-02 17:27:57 +07004557 f_vty_transceive(pt, cmd & suffix);
Harald Welte261af4b2018-02-12 21:20:39 +01004558}
4559
Neels Hofmeyr91401012019-07-11 00:42:35 +02004560/* Even though the VTY command to trigger handover takes a new BTS number as argument, behind the scenes osmo-bsc always
4561 * translates that to a target ARFCN+BSIC first. See bsc_vty.c trigger_ho_or_as(), which puts the selected BTS' neighbor
4562 * ident key (ARFCN + BSIC) in the struct passed on to handover_request(). handover_start() then resolves that to a
4563 * viable actual neighbor cell. So from the internal osmo-bsc perspective, we always request handover to an ARFCN + BSIC
4564 * pair, not really to a specific BTS number. */
Vadim Yanitskiy00070722020-09-02 17:27:57 +07004565private function f_vty_handover(TELNETasp_PT pt, uint8_t bts_nr, uint8_t trx_nr,
4566 in RslChannelNr chan_nr, uint8_t new_bts_nr)
4567{
4568 f_vty_ss_action(pt, "handover " & int2str(new_bts_nr), bts_nr, trx_nr, chan_nr);
Harald Welte261af4b2018-02-12 21:20:39 +01004569}
4570
4571/* intra-BSC hand-over between BTS0 and BTS1 */
4572private function f_tc_ho_int(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02004573 g_pars := f_gen_test_hdlr_pars();
Harald Welteed848512018-05-24 22:27:58 +02004574 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4575 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte261af4b2018-02-12 21:20:39 +01004576 const OCT8 kc := '0001020304050607'O;
4577
4578 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4579 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
4580
Harald Weltea0630032018-03-20 21:09:55 +01004581 f_establish_fully(ass_cmd, exp_compl);
Neels Hofmeyr666f0432020-07-04 00:53:07 +02004582 f_bts_0_cfg(BSCVTY, {"neighbor bts 1"});
Harald Welte261af4b2018-02-12 21:20:39 +01004583
4584 var HandoverState hs := {
4585 rr_ho_cmpl_seen := false,
4586 handover_done := false,
4587 old_chan_nr := -
4588 };
4589 /* issue hand-over command on VTY */
Vadim Yanitskiy00070722020-09-02 17:27:57 +07004590 f_vty_handover(BSCVTY, 0, 0, g_chan_nr, 1);
Harald Welte261af4b2018-02-12 21:20:39 +01004591 /* temporarily suspend DChan processing on BTS1 to avoid race with RSLEM_register */
4592 f_rslem_suspend(RSL1_PROC);
Philipp Maier3e2af5d2018-07-11 17:01:05 +02004593
4594 /* From the MGW perspective, a handover is is characterized by
4595 * performing one MDCX operation with the MGW. So we expect to see
4596 * one more MDCX during handover. */
4597 g_media.mgcp_conn[0].mdcx_seen_exp := g_media.mgcp_conn[0].crcx_seen_exp + 1;
4598
Harald Welte261af4b2018-02-12 21:20:39 +01004599 alt {
4600 [] as_handover(hs);
Harald Welte261af4b2018-02-12 21:20:39 +01004601 }
Philipp Maier3e2af5d2018-07-11 17:01:05 +02004602
Philipp Maier4dae0652018-11-12 12:03:26 +01004603 /* Since this is an internal handover we expect the BSC to inform the
4604 * MSC about the event */
4605 BSSAP.receive(tr_BSSMAP_HandoverPerformed);
4606
Philipp Maier3e2af5d2018-07-11 17:01:05 +02004607 /* Check the amount of MGCP transactions is still consistant with the
4608 * test expectation */
4609 f_check_mgcp_expectations()
Neels Hofmeyr861a4c12018-11-07 01:23:17 +01004610 f_sleep(0.5);
Harald Welte261af4b2018-02-12 21:20:39 +01004611}
4612
4613testcase TC_ho_int() runs on test_CT {
4614 var MSC_ConnHdlr vc_conn;
4615 f_init(2, true);
4616 f_sleep(1.0);
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004617
4618 f_ctrs_bsc_and_bts_init();
4619
Harald Welte8863fa12018-05-10 20:15:27 +02004620 vc_conn := f_start_handler(refers(f_tc_ho_int));
Harald Welte261af4b2018-02-12 21:20:39 +01004621 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004622
4623 /* from f_establish_fully() */
4624 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
4625 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
4626 /* from handover */
4627 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
4628 f_ctrs_bsc_and_bts_add(0, "handover:completed");
4629 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
4630 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:completed");
4631 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004632 f_shutdown_helper();
Harald Welte261af4b2018-02-12 21:20:39 +01004633}
Harald Weltee9e02e42018-01-31 23:36:25 +01004634
Neels Hofmeyr5f144212020-11-03 15:41:58 +00004635/* intra-BSC hand-over with CONNection FAILure and cause Radio Link Failure: check RR release cause */
4636private function f_tc_ho_int_radio_link_failure(charstring id) runs on MSC_ConnHdlr {
4637 g_pars := f_gen_test_hdlr_pars();
4638 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4639 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4640 const OCT8 kc := '0001020304050607'O;
4641
4642 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4643 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
4644
4645 f_establish_fully(ass_cmd, exp_compl);
4646 f_bts_0_cfg(BSCVTY, {"neighbor bts 1"});
4647
4648 var HandoverState hs := {
4649 rr_ho_cmpl_seen := false,
4650 handover_done := false,
4651 old_chan_nr := -
4652 };
4653 /* issue hand-over command on VTY */
4654 f_vty_handover(BSCVTY, 0, 0, g_chan_nr, 1);
4655 /* temporarily suspend DChan processing on BTS1 to avoid race with RSLEM_register */
4656 f_rslem_suspend(RSL1_PROC);
4657
4658 /* From the MGW perspective, a handover is is characterized by
4659 * performing one MDCX operation with the MGW. So we expect to see
4660 * one more MDCX during handover. */
4661 g_media.mgcp_conn[0].mdcx_seen_exp := g_media.mgcp_conn[0].crcx_seen_exp + 1;
4662
4663 var RSL_Message rsl;
4664 var PDU_ML3_NW_MS l3;
4665 var RslChannelNr new_chan_nr;
4666 var GsmArfcn arfcn;
4667 RSL.receive(tr_RSL_DATA_REQ(g_chan_nr)) -> value rsl {
4668 l3 := dec_PDU_ML3_NW_MS(rsl.ies[2].body.l3_info.payload);
4669 if (not ischosen(l3.msgs.rrm.handoverCommand)) {
4670 setverdict(fail, "Expected handoverCommand");
4671 mtc.stop;
4672 }
4673 }
4674 f_ChDesc2RslChanNr(l3.msgs.rrm.handoverCommand.channelDescription2,
4675 new_chan_nr, arfcn);
4676
4677 f_rslem_register(0, new_chan_nr, RSL1_PROC);
4678
4679 /* resume processing of RSL DChan messages, which was temporarily suspended
4680 * before performing a hand-over */
4681 f_rslem_resume(RSL1_PROC);
4682 RSL1.receive(tr_RSL_IPA_CRCX(new_chan_nr));
4683
4684 f_sleep(1.0);
4685
4686 /* Handover fails because no HANDO DET appears on the new lchan,
4687 * and the old lchan reports a Radio Link Failure. */
4688 RSL.send(ts_RSL_CONN_FAIL_IND(g_chan_nr, RSL_ERR_RADIO_LINK_FAIL));
4689
4690 var PDU_BSSAP rx_clear_request;
4691 BSSAP.receive(tr_BSSMAP_ClearRequest) -> value rx_clear_request;
4692 var BssmapCause cause := bit2int(rx_clear_request.pdu.bssmap.clearRequest.cause.causeValue);
4693 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
4694
4695 var RR_Cause rr_cause := GSM48_RR_CAUSE_ABNORMAL_UNSPEC;
4696
4697 var MgcpCommand mgcp;
4698 interleave {
4699 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_RELEASE(int2oct(enum2int(rr_cause), 1)))) {}
4700 [] RSL.receive(tr_RSL_DEACT_SACCH(g_chan_nr)) {}
4701 [] RSL.receive(tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL)) {
4702 RSL.send(ts_RSL_RF_CHAN_REL_ACK(g_chan_nr));
4703 }
4704 [] RSL1.receive(tr_RSL_DEACT_SACCH(new_chan_nr)) {}
4705 [] RSL1.receive(tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL)) {
4706 RSL1.send(ts_RSL_RF_CHAN_REL_ACK(new_chan_nr));
4707 }
4708 [] BSSAP.receive(tr_BSSMAP_ClearComplete) {}
4709 }
4710
4711 f_sleep(0.5);
4712 setverdict(pass);
4713}
4714testcase TC_ho_int_radio_link_failure() runs on test_CT {
4715 var MSC_ConnHdlr vc_conn;
4716 f_init(2, true);
4717 f_sleep(1.0);
4718
4719 f_ctrs_bsc_and_bts_init();
4720
4721 vc_conn := f_start_handler(refers(f_tc_ho_int_radio_link_failure));
4722 vc_conn.done;
4723
4724 /* from f_establish_fully() */
4725 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
4726 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
4727 /* from handover */
4728 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
4729 f_ctrs_bsc_and_bts_add(0, "handover:stopped");
4730 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
4731 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:stopped");
4732 f_ctrs_bsc_and_bts_verify();
4733 f_shutdown_helper();
4734}
4735
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004736/* Expecting MGCP to DLCX the endpoint's two connections: towards BTS and towards MSC */
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02004737private function f_expect_dlcx_conns() runs on MSC_ConnHdlr {
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004738 var MgcpCommand mgcp;
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +02004739 var template MgcpResponse mgcp_resp;
4740 var MGCP_RecvFrom mrf;
4741 var template MgcpMessage msg_resp;
4742 var template MgcpMessage msg_dlcx := {
4743 command := tr_DLCX()
4744 }
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004745
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +02004746 if (g_pars.aoip) {
4747 MGCP.receive(tr_DLCX()) -> value mgcp {
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004748 log("Got first DLCX: ", mgcp);
4749 MGCP.send(ts_DLCX_ACK2(mgcp.line.trans_id));
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +02004750 };
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004751
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004752 MGCP.receive(tr_DLCX()) -> value mgcp {
4753 log("Got second DLCX: ", mgcp);
4754 MGCP.send(ts_DLCX_ACK2(mgcp.line.trans_id));
4755 };
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +02004756 } else {
4757 /* For SCCPLite, BSC doesn't handle the MSC-side */
4758 MGCP_MULTI.receive(tr_MGCP_RecvFrom_any(msg_dlcx)) -> value mrf {
4759 log("Got first DLCX: ", mrf.msg.command);
4760 msg_resp := {
4761 response := ts_DLCX_ACK2(mrf.msg.command.line.trans_id)
4762 }
4763 MGCP_MULTI.send(t_MGCP_SendToMrf(mrf, msg_resp));
4764 };
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004765 }
4766
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02004767 BSSAP.receive(tr_BSSMAP_ClearComplete);
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004768}
4769
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004770private function f_tc_ho_out_of_this_bsc(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02004771 g_pars := f_gen_test_hdlr_pars();
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004772
4773 var PDU_BSSAP ass_req := f_gen_ass_req();
4774 ass_req.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4775 ass_req.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
4776 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4777 f_establish_fully(ass_req, exp_compl);
4778
Neels Hofmeyr666f0432020-07-04 00:53:07 +02004779 f_bts_0_cfg(BSCVTY, {"neighbor lac 99 arfcn 123 bsic any"});
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004780 f_vty_transceive(BSCVTY, "handover any to arfcn 123 bsic any");
4781
4782 BSSAP.receive(tr_BSSMAP_HandoverRequired);
4783
4784 f_sleep(0.5);
4785 /* The MSC negotiates Handover Request and Handover Request Ack with
4786 * the other BSS and comes back with a BSSMAP Handover Command
4787 * containing an RR Handover Command coming from the target BSS... */
4788
4789 var PDU_ML3_NW_MS rr_ho_cmd := valueof(ts_RR_HandoverCommand);
4790 log("Remote cell's RR Handover Command passed through as L3 Info: ", rr_ho_cmd);
4791 var octetstring rr_ho_cmd_enc := enc_PDU_ML3_NW_MS(rr_ho_cmd);
4792 log("Remote cell's RR Handover Command passed through as L3 Info, encoded: ", rr_ho_cmd_enc);
4793 BSSAP.send(ts_BSSMAP_HandoverCommand(rr_ho_cmd_enc));
4794
4795 /* expect the Handover Command to go out on RR */
4796 var RSL_Message rsl_ho_cmd
4797 RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, ?)) -> value rsl_ho_cmd;
4798 log("RSL Data Req went out to first BTS: ", rsl_ho_cmd);
4799 var RSL_IE_Body rsl_ho_cmd_l3;
4800 if (not f_rsl_find_ie(rsl_ho_cmd, RSL_IE_L3_INFO, rsl_ho_cmd_l3)) {
4801 log("RSL message contains no L3 Info IE, expected RR Handover Command");
4802 setverdict(fail);
4803 } else {
4804 log("Found L3 Info: ", rsl_ho_cmd_l3);
4805 if (rsl_ho_cmd_l3.l3_info.payload != rr_ho_cmd_enc) {
4806 log("FAIL: the BSC sent out a different L3 Info, not matching the RR Handover Command the other BSS forwarded.");
4807 setverdict(fail);
4808 } else {
4809 log("Success: the BSC sent out the same RR Handover Command the other BSS forwarded.");
4810 setverdict(pass);
4811 }
4812 }
4813
4814 /* When the other BSS has reported a completed handover, this side is
4815 * torn down. */
4816
4817 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_HANDOVER_SUCCESSFUL;
4818 var BssmapCause cause := enum2int(cause_val);
4819 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
4820
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02004821 f_expect_dlcx_conns();
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004822 setverdict(pass);
4823 f_sleep(1.0);
4824}
4825testcase TC_ho_out_of_this_bsc() runs on test_CT {
4826 var MSC_ConnHdlr vc_conn;
4827
4828 f_init(1, true);
4829 f_sleep(1.0);
4830
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004831 f_ctrs_bsc_and_bts_init();
4832
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004833 vc_conn := f_start_handler(refers(f_tc_ho_out_of_this_bsc));
4834 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004835
4836 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
4837 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
4838 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
4839 f_ctrs_bsc_and_bts_add(0, "handover:completed");
4840 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
4841 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:completed");
4842 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004843 f_shutdown_helper();
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004844}
4845
Neels Hofmeyr0aa719b2020-10-12 18:43:09 +00004846private function f_mo_l3_transceive(RSL_DCHAN_PT rsl := RSL,
4847 template (value) RslLinkId link_id := ts_RslLinkID_DCCH(0),
Vadim Yanitskiy2ef6a2f2020-10-08 23:17:32 +07004848 template (present) OCT1 dlci := ?,
Vadim Yanitskiyb93aa432020-10-01 14:23:11 +07004849 octetstring l3 := '0123456789'O)
4850runs on MSC_ConnHdlr {
Neels Hofmeyr43654812020-09-25 01:35:35 +02004851 /* The old lchan and conn should still be active. See that arbitrary L3
4852 * is still going through. */
Neels Hofmeyr0aa719b2020-10-12 18:43:09 +00004853 rsl.send(ts_RSL_DATA_IND(g_chan_nr, link_id, l3));
Neels Hofmeyr43654812020-09-25 01:35:35 +02004854 var template PDU_BSSAP exp_data := {
4855 discriminator := '1'B,
4856 spare := '0000000'B,
Vadim Yanitskiyb93aa432020-10-01 14:23:11 +07004857 dlci := dlci,
4858 lengthIndicator := lengthof(l3),
Neels Hofmeyr43654812020-09-25 01:35:35 +02004859 pdu := {
4860 dtap := l3
4861 }
4862 };
4863 BSSAP.receive(exp_data);
4864 setverdict(pass);
4865}
4866
Neels Hofmeyr0aa719b2020-10-12 18:43:09 +00004867private function f_mt_l3_transceive(RSL_DCHAN_PT rsl := RSL,
4868 template (present) RslLinkId link_id := tr_RslLinkID_DCCH(0),
Vadim Yanitskiy0033a3b2020-10-01 22:21:16 +07004869 template (value) OCT1 dlci := '00'O,
4870 octetstring l3 := '0123456789'O)
4871runs on MSC_ConnHdlr {
4872 BSSAP.send(PDU_BSSAP:{
4873 discriminator := '1'B,
4874 spare := '0000000'B,
4875 dlci := dlci,
4876 lengthIndicator := lengthof(l3),
4877 pdu := {
4878 dtap := l3
4879 }
4880 });
Neels Hofmeyr0aa719b2020-10-12 18:43:09 +00004881 rsl.receive(tr_RSL_DATA_REQ(g_chan_nr, link_id, l3));
Vadim Yanitskiy0033a3b2020-10-01 22:21:16 +07004882 setverdict(pass);
4883}
4884
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004885/* BSC asks for inter-BSC HO, but the MSC decides that it won't happen and
4886 * simply never sends a BSSMAP Handover Command. */
4887private function f_tc_ho_out_fail_no_msc_response(charstring id) runs on MSC_ConnHdlr {
Daniel Willmann3b59eb52018-10-29 15:40:55 +01004888 g_pars := f_gen_test_hdlr_pars();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004889
4890 var PDU_BSSAP ass_req := f_gen_ass_req();
4891 ass_req.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4892 ass_req.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
4893 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4894 f_establish_fully(ass_req, exp_compl);
4895
Neels Hofmeyr666f0432020-07-04 00:53:07 +02004896 f_bts_0_cfg(BSCVTY, {"neighbor lac 99 arfcn 123 bsic any"});
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004897 f_vty_transceive(BSCVTY, "handover any to arfcn 123 bsic any");
4898
4899 BSSAP.receive(tr_BSSMAP_HandoverRequired);
4900
4901 /* osmo-bsc should time out 10 seconds after the handover started.
4902 * Let's give it a bit extra. */
4903 f_sleep(15.0);
4904
Vadim Yanitskiy74ae5eb2020-10-01 22:13:29 +07004905 f_mo_l3_transceive();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004906 f_sleep(1.0);
4907}
4908testcase TC_ho_out_fail_no_msc_response() runs on test_CT {
4909 var MSC_ConnHdlr vc_conn;
4910
4911 f_init(1, true);
4912 f_sleep(1.0);
4913
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004914 f_ctrs_bsc_and_bts_init();
4915
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004916 vc_conn := f_start_handler(refers(f_tc_ho_out_fail_no_msc_response));
4917 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004918
4919 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
4920 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
4921 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
4922 f_ctrs_bsc_and_bts_add(0, "handover:timeout");
4923 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
4924 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:timeout");
4925 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004926 f_shutdown_helper();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004927}
4928
4929/* BSC asks for inter-BSC HO, receives BSSMAP Handover Command, but MS reports
4930 * RR Handover Failure. */
4931private function f_tc_ho_out_fail_rr_ho_failure(charstring id) runs on MSC_ConnHdlr {
Daniel Willmann3b59eb52018-10-29 15:40:55 +01004932 g_pars := f_gen_test_hdlr_pars();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004933
4934 var PDU_BSSAP ass_req := f_gen_ass_req();
4935 ass_req.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4936 ass_req.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
4937 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4938 f_establish_fully(ass_req, exp_compl);
4939
Neels Hofmeyr666f0432020-07-04 00:53:07 +02004940 f_bts_0_cfg(BSCVTY, {"neighbor lac 99 arfcn 123 bsic any"});
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004941 f_vty_transceive(BSCVTY, "handover any to arfcn 123 bsic any");
4942
4943 BSSAP.receive(tr_BSSMAP_HandoverRequired);
4944
4945 f_sleep(0.5);
4946 /* The MSC negotiates Handover Request and Handover Request Ack with
4947 * the other BSS and comes back with a BSSMAP Handover Command
4948 * containing an RR Handover Command coming from the target BSS... */
4949
4950 var PDU_ML3_NW_MS rr_ho_cmd := valueof(ts_RR_HandoverCommand);
4951 log("Remote cell's RR Handover Command passed through as L3 Info: ", rr_ho_cmd);
4952 var octetstring rr_ho_cmd_enc := enc_PDU_ML3_NW_MS(rr_ho_cmd);
4953 log("Remote cell's RR Handover Command passed through as L3 Info, encoded: ", rr_ho_cmd_enc);
4954 BSSAP.send(ts_BSSMAP_HandoverCommand(rr_ho_cmd_enc));
4955
4956 /* expect the Handover Command to go out on RR */
4957 var RSL_Message rsl_ho_cmd
4958 RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, ?)) -> value rsl_ho_cmd;
4959 log("RSL Data Req went out to first BTS: ", rsl_ho_cmd);
4960 var RSL_IE_Body rsl_ho_cmd_l3;
4961 if (not f_rsl_find_ie(rsl_ho_cmd, RSL_IE_L3_INFO, rsl_ho_cmd_l3)) {
4962 log("RSL message contains no L3 Info IE, expected RR Handover Command");
4963 setverdict(fail);
4964 } else {
4965 log("Found L3 Info: ", rsl_ho_cmd_l3);
4966 if (rsl_ho_cmd_l3.l3_info.payload != rr_ho_cmd_enc) {
4967 log("FAIL: the BSC sent out a different L3 Info, not matching the RR Handover Command the other BSS forwarded.");
4968 setverdict(fail);
4969 } else {
4970 log("Success: the BSC sent out the same RR Handover Command the other BSS forwarded.");
4971 setverdict(pass);
4972 }
4973 }
4974
4975 f_sleep(0.2);
4976 f_rsl_send_l3(ts_RRM_HandoverFailure('00'O));
4977
4978 /* Should tell the MSC about the failure */
4979 BSSAP.receive(tr_BSSMAP_HandoverFailure);
4980
4981 f_sleep(1.0);
4982
Vadim Yanitskiy74ae5eb2020-10-01 22:13:29 +07004983 f_mo_l3_transceive();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004984 f_sleep(1.0);
4985
4986 setverdict(pass);
4987 f_sleep(1.0);
4988}
4989testcase TC_ho_out_fail_rr_ho_failure() runs on test_CT {
4990 var MSC_ConnHdlr vc_conn;
4991
4992 f_init(1, true);
4993 f_sleep(1.0);
4994
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004995 f_ctrs_bsc_and_bts_init();
4996
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004997 vc_conn := f_start_handler(refers(f_tc_ho_out_fail_rr_ho_failure));
4998 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004999
5000 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5001 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5002 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5003 f_ctrs_bsc_and_bts_add(0, "handover:failed");
5004 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
5005 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:failed");
5006 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005007 f_shutdown_helper();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005008}
5009
Neels Hofmeyr10f2bfa2019-07-09 19:33:29 +02005010/* BSC asks for inter-BSC-out HO, receives BSSMAP Handover Command, but then no reply is received about HO outcome
5011 * (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 +02005012 * and the lchan is released. */
5013private function f_tc_ho_out_fail_no_result_after_ho_cmd(charstring id) runs on MSC_ConnHdlr {
Daniel Willmann3b59eb52018-10-29 15:40:55 +01005014 g_pars := f_gen_test_hdlr_pars();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005015
5016 var PDU_BSSAP ass_req := f_gen_ass_req();
5017 ass_req.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
5018 ass_req.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
5019 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
5020 f_establish_fully(ass_req, exp_compl);
5021
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005022 f_bts_0_cfg(BSCVTY, {"neighbor lac 99 arfcn 123 bsic any"});
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005023 f_vty_transceive(BSCVTY, "handover any to arfcn 123 bsic any");
5024
5025 BSSAP.receive(tr_BSSMAP_HandoverRequired);
5026
5027 f_sleep(0.5);
5028 /* The MSC negotiates Handover Request and Handover Request Ack with
5029 * the other BSS and comes back with a BSSMAP Handover Command
5030 * containing an RR Handover Command coming from the target BSS... */
5031
5032 var PDU_ML3_NW_MS rr_ho_cmd := valueof(ts_RR_HandoverCommand);
5033 log("Remote cell's RR Handover Command passed through as L3 Info: ", rr_ho_cmd);
5034 var octetstring rr_ho_cmd_enc := enc_PDU_ML3_NW_MS(rr_ho_cmd);
5035 log("Remote cell's RR Handover Command passed through as L3 Info, encoded: ", rr_ho_cmd_enc);
5036 BSSAP.send(ts_BSSMAP_HandoverCommand(rr_ho_cmd_enc));
5037
5038 /* expect the Handover Command to go out on RR */
5039 var RSL_Message rsl_ho_cmd
5040 RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, ?)) -> value rsl_ho_cmd;
5041 log("RSL Data Req went out to first BTS: ", rsl_ho_cmd);
5042 var RSL_IE_Body rsl_ho_cmd_l3;
5043 if (not f_rsl_find_ie(rsl_ho_cmd, RSL_IE_L3_INFO, rsl_ho_cmd_l3)) {
5044 log("RSL message contains no L3 Info IE, expected RR Handover Command");
5045 setverdict(fail);
5046 } else {
5047 log("Found L3 Info: ", rsl_ho_cmd_l3);
5048 if (rsl_ho_cmd_l3.l3_info.payload != rr_ho_cmd_enc) {
5049 log("FAIL: the BSC sent out a different L3 Info, not matching the RR Handover Command the other BSS forwarded.");
5050 setverdict(fail);
5051 } else {
5052 log("Success: the BSC sent out the same RR Handover Command the other BSS forwarded.");
5053 setverdict(pass);
5054 }
5055 }
5056
Neels Hofmeyr10f2bfa2019-07-09 19:33:29 +02005057 /* We get neither success nor failure report from the remote BSS. Eventually T8 times out and we run into 3GPP
5058 * TS 48.008 3.1.5.3.3 "Abnormal Conditions": Clear Request should go to the MSC, and RR should be released
5059 * after Clear Command */
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005060
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02005061 var PDU_BSSAP rx_clear_request;
Neels Hofmeyre1797aa2019-07-09 19:34:04 +02005062 BSSAP.receive(tr_BSSMAP_ClearRequest) -> value rx_clear_request;
5063 log("Got BSSMAP Clear Request");
5064 /* Instruct BSC to clear channel */
5065 var BssmapCause cause := bit2int(rx_clear_request.pdu.bssmap.clearRequest.cause.causeValue);
5066 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
5067
5068 var MgcpCommand mgcp;
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005069 interleave {
Neels Hofmeyr861a4c12018-11-07 01:23:17 +01005070 [] RSL.receive(tr_RSL_DEACT_SACCH(g_chan_nr)) {
5071 log("Got Deact SACCH");
5072 }
Harald Welte924b6ea2019-02-04 01:05:34 +01005073 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_RELEASE)) {
Neels Hofmeyr211169d2018-11-07 00:37:29 +01005074 log("Got RR Release");
5075 }
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005076 [] RSL.receive(tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL)) {
5077 log("Got RF Chan Rel");
5078 RSL.send(ts_RSL_RF_CHAN_REL_ACK(g_chan_nr));
5079 }
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005080 }
5081
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02005082 f_expect_dlcx_conns();
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02005083
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005084 setverdict(pass);
5085 f_sleep(1.0);
5086}
Neels Hofmeyrd8a602c2019-07-09 19:46:01 +02005087testcase TC_ho_out_fail_no_result_after_ho_cmd() runs on test_CT {
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005088 var MSC_ConnHdlr vc_conn;
5089
5090 f_init(1, true);
5091 f_sleep(1.0);
5092
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005093 f_ctrs_bsc_and_bts_init();
5094
Neels Hofmeyrd8a602c2019-07-09 19:46:01 +02005095 vc_conn := f_start_handler(refers(f_tc_ho_out_fail_no_result_after_ho_cmd));
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005096 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005097
5098 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5099 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5100 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5101 f_ctrs_bsc_and_bts_add(0, "handover:timeout");
5102 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
5103 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:timeout");
5104 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005105 f_shutdown_helper();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005106}
5107
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005108private function f_tc_ho_into_this_bsc(charstring id) runs on MSC_ConnHdlr {
5109 /* Hack: the proper way would be to wait for the BSSMAP Handover Request ACK and extract the
5110 * actual assigned chan_nr from its L3 (RR Handover Command) message. But osmo-bsc starts acting
5111 * on the lchan even before we get a chance to evaluate the BSSMAP Handover Request ACK. So we
5112 * need to assume that osmo-bsc will activate TS 1 and already set up this lchan's RSL emulation
5113 * before we get started. */
Pau Espin Pedrolc08d5522021-04-16 15:40:38 +02005114 var template (omit) BSSMAP_oldToNewBSSIEs oldToNewBSSIEs := omit;
5115 var template PDU_ML3_NW_MS exp_rr_rel_tmpl := tr_RRM_RR_RELEASE;
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005116 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
5117 f_rslem_register(0, new_chan_nr);
5118 g_chan_nr := new_chan_nr;
5119 f_sleep(1.0);
5120
5121 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
5122 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
5123 activate(as_Media());
5124
Pau Espin Pedrolc08d5522021-04-16 15:40:38 +02005125 if (not istemplatekind(g_pars.last_used_eutran_plmn, "omit")) {
5126 oldToNewBSSIEs := f_ts_BSSMAP_oldToNewBSSIEs(ts_BSSMAP_LastUsedEUTRANPLMNId(g_pars.last_used_eutran_plmn));
5127 exp_rr_rel_tmpl := tr_RRM_RR_RELEASE_CellSelectInd;
5128 }
5129
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005130 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Pau Espin Pedrolc08d5522021-04-16 15:40:38 +02005131 f_gen_handover_req(aoip_tla := g_pars.host_aoip_tla,
5132 oldToNewBSSIEs := oldToNewBSSIEs)));
Harald Welte6811d102019-04-14 22:23:14 +02005133 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005134
5135 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
5136
5137 var PDU_BSSAP rx_bssap;
5138 var octetstring ho_command_str;
5139
5140 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
Pau Espin Pedrol76ba5412019-06-10 11:00:33 +02005141
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005142 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
5143 log("Received L3 Info in HO Request Ack: ", ho_command_str);
5144 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
5145 log("L3 Info in HO Request Ack is ", ho_command);
5146
5147 var GsmArfcn arfcn;
5148 var RslChannelNr actual_new_chan_nr;
5149 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
5150 actual_new_chan_nr, arfcn);
5151
5152 if (actual_new_chan_nr != new_chan_nr) {
5153 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
5154 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
5155 setverdict(fail);
5156 return;
5157 }
5158 log("Handover Command chan_nr is", actual_new_chan_nr);
5159
5160 /* Now the MSC forwards the RR Handover Command to the other BSC, which
5161 * tells the MS to handover to the new lchan. Here comes the new MS on
5162 * the new lchan with a Handover RACH: */
5163
5164 /* send handover detect */
5165
5166 RSL.send(ts_RSL_HANDO_DET(new_chan_nr));
5167
5168 BSSAP.receive(tr_BSSMAP_HandoverDetect);
5169
5170 /* send handover complete over the new channel */
5171
5172 var PDU_ML3_MS_NW l3_tx := valueof(ts_RRM_HandoverComplete('00'O));
5173 RSL.send(ts_RSL_EST_IND(new_chan_nr, valueof(ts_RslLinkID_DCCH(0)),
5174 enc_PDU_ML3_MS_NW(l3_tx)));
5175
5176 BSSAP.receive(tr_BSSMAP_HandoverComplete);
Pau Espin Pedrolc08d5522021-04-16 15:40:38 +02005177
5178 f_perform_clear(RSL, exp_rr_rel_tmpl);
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005179 setverdict(pass);
5180}
Pau Espin Pedrol07866632020-09-03 19:10:55 +02005181function f_tc_ho_into_this_bsc_main(TestHdlrParams pars) runs on test_CT {
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005182 var MSC_ConnHdlr vc_conn;
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005183
5184 f_init(1, true);
5185 f_sleep(1.0);
5186
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005187 f_ctrs_bsc_and_bts_init();
5188
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005189 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
5190 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005191
5192 vc_conn := f_start_handler(refers(f_tc_ho_into_this_bsc), pars);
5193 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005194
5195 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5196 f_ctrs_bsc_and_bts_add(0, "handover:completed");
5197 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:attempted");
5198 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:completed");
5199 f_ctrs_bsc_and_bts_verify();
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005200}
5201
Pau Espin Pedrol07866632020-09-03 19:10:55 +02005202testcase TC_ho_into_this_bsc() runs on test_CT {
5203 var TestHdlrParams pars := f_gen_test_hdlr_pars();
5204 f_tc_ho_into_this_bsc_main(pars);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005205 f_shutdown_helper();
Pau Espin Pedrol07866632020-09-03 19:10:55 +02005206}
5207
5208testcase TC_ho_into_this_bsc_tla_v6() runs on test_CT {
5209 var TestHdlrParams pars := f_gen_test_hdlr_pars();
5210 pars.host_aoip_tla := "::6";
5211 f_tc_ho_into_this_bsc_main(pars);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005212 f_shutdown_helper();
Pau Espin Pedrol07866632020-09-03 19:10:55 +02005213}
5214
Pau Espin Pedrolc08d5522021-04-16 15:40:38 +02005215/* Similar to TC_ho_into_this_bsc, but when in SRVCC, HO Req contains "Old BSS
5216 to New BSS Information" IE with "Last Used E-UTRAN PLMN Id", whihch, when the
5217 channel is later released (RR CHannel Release), should trigger inclusion of
5218 IE "Cell Selection Indicator after Release of all TCH and SDCCH" with E-UTRAN
5219 neighbors. */
5220testcase TC_srvcc_eutran_to_geran() runs on test_CT {
5221 var TestHdlrParams pars := f_gen_test_hdlr_pars();
5222 pars.last_used_eutran_plmn := '323454'O;
5223 f_tc_ho_into_this_bsc_main(pars);
5224 f_shutdown_helper();
5225}
5226
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005227private function f_tc_ho_in_fail_msc_clears(charstring id) runs on MSC_ConnHdlr {
5228 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
5229 f_rslem_register(0, new_chan_nr);
5230 g_chan_nr := new_chan_nr;
5231 f_sleep(1.0);
5232
5233 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
5234 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
5235 activate(as_Media());
5236
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005237 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005238 f_gen_handover_req()));
Harald Welte6811d102019-04-14 22:23:14 +02005239 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005240
5241 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
5242
5243 var PDU_BSSAP rx_bssap;
5244 var octetstring ho_command_str;
5245
5246 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
5247
5248 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
5249 log("Received L3 Info in HO Request Ack: ", ho_command_str);
5250 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
5251 log("L3 Info in HO Request Ack is ", ho_command);
5252
5253 var GsmArfcn arfcn;
5254 var RslChannelNr actual_new_chan_nr;
5255 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
5256 actual_new_chan_nr, arfcn);
5257
5258 if (actual_new_chan_nr != new_chan_nr) {
5259 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
5260 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
5261 setverdict(fail);
5262 return;
5263 }
5264 log("Handover Command chan_nr is", actual_new_chan_nr);
5265
Neels Hofmeyr61ca08d2019-05-06 23:52:22 +02005266 /* For deterministic test results, give some time for the MGW endpoint to be configured */
5267 f_sleep(1.0);
5268
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005269 /* Now the MSC forwards the RR Handover Command to the other BSC, which
5270 * tells the MS to handover to the new lchan. In this case, the MS
5271 * reports a Handover Failure to the old BSS, which forwards a BSSMAP
5272 * Handover Failure to the MSC. The procedure according to 3GPP TS
5273 * 48.008 3.1.5.3.2 "Handover Failure" is then that the MSC sends a
5274 * BSSMAP Clear Command: */
5275
5276 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_RADIO_INTERFACE_FAILURE_REVERSION;
5277 var BssmapCause cause := enum2int(cause_val);
5278 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
5279
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02005280 f_expect_dlcx_conns();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005281 setverdict(pass);
5282 f_sleep(1.0);
5283
5284 setverdict(pass);
5285}
5286testcase TC_ho_in_fail_msc_clears() runs on test_CT {
5287 var MSC_ConnHdlr vc_conn;
5288 var TestHdlrParams pars := f_gen_test_hdlr_pars();
5289
5290 f_init(1, true);
5291 f_sleep(1.0);
5292
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005293 f_ctrs_bsc_and_bts_init();
5294
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005295 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
5296 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005297
5298 vc_conn := f_start_handler(refers(f_tc_ho_in_fail_msc_clears), pars);
5299 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005300
5301 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5302 f_ctrs_bsc_and_bts_add(0, "handover:stopped");
5303 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:attempted");
5304 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:stopped");
5305 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005306 f_shutdown_helper();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005307}
5308
5309private function f_tc_ho_in_fail_msc_clears_after_ho_detect(charstring id) runs on MSC_ConnHdlr {
5310 /* Hack: the proper way would be to wait for the BSSMAP Handover Request ACK and extract the
5311 * actual assigned chan_nr from its L3 (RR Handover Command) message. But osmo-bsc starts acting
5312 * on the lchan even before we get a chance to evaluate the BSSMAP Handover Request ACK. So we
5313 * need to assume that osmo-bsc will activate TS 1 and already set up this lchan's RSL emulation
5314 * before we get started. */
5315 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
5316 f_rslem_register(0, new_chan_nr);
5317 g_chan_nr := new_chan_nr;
5318 f_sleep(1.0);
5319
5320 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
5321 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
5322 activate(as_Media());
5323
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005324 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005325 f_gen_handover_req()));
Harald Welte6811d102019-04-14 22:23:14 +02005326 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005327
5328 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
5329
5330 var PDU_BSSAP rx_bssap;
5331 var octetstring ho_command_str;
5332
5333 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
5334
5335 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
5336 log("Received L3 Info in HO Request Ack: ", ho_command_str);
5337 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
5338 log("L3 Info in HO Request Ack is ", ho_command);
5339
5340 var GsmArfcn arfcn;
5341 var RslChannelNr actual_new_chan_nr;
5342 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
5343 actual_new_chan_nr, arfcn);
5344
5345 if (actual_new_chan_nr != new_chan_nr) {
5346 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
5347 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
5348 setverdict(fail);
5349 return;
5350 }
5351 log("Handover Command chan_nr is", actual_new_chan_nr);
5352
5353 /* Now the MSC forwards the RR Handover Command to the other BSC, which
5354 * tells the MS to handover to the new lchan. Here comes the new MS on
5355 * the new lchan with a Handover RACH: */
5356
5357 /* send handover detect */
5358
5359 RSL.send(ts_RSL_HANDO_DET(new_chan_nr));
5360
5361 BSSAP.receive(tr_BSSMAP_HandoverDetect);
5362
5363 /* The MSC chooses to clear the connection now, maybe we got the
5364 * Handover RACH on the new cell but the MS still signaled Handover
5365 * Failure to the old BSS? */
5366
5367 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_RADIO_INTERFACE_FAILURE_REVERSION;
5368 var BssmapCause cause := enum2int(cause_val);
5369 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
5370
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02005371 f_expect_dlcx_conns();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005372 f_sleep(1.0);
5373}
5374testcase TC_ho_in_fail_msc_clears_after_ho_detect() runs on test_CT {
5375 var MSC_ConnHdlr vc_conn;
5376 var TestHdlrParams pars := f_gen_test_hdlr_pars();
5377
5378 f_init(1, true);
5379 f_sleep(1.0);
5380
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005381 f_ctrs_bsc_and_bts_init();
5382
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005383 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
5384 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005385
5386 vc_conn := f_start_handler(refers(f_tc_ho_in_fail_msc_clears_after_ho_detect), pars);
5387 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005388
5389 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5390 f_ctrs_bsc_and_bts_add(0, "handover:stopped");
5391 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:attempted");
5392 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:stopped");
5393 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005394 f_shutdown_helper();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005395}
5396
5397/* The new BSS's lchan times out before the MSC decides that handover failed. */
5398private function f_tc_ho_in_fail_no_detect(charstring id) runs on MSC_ConnHdlr {
5399 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
5400 f_rslem_register(0, new_chan_nr);
5401 g_chan_nr := new_chan_nr;
5402 f_sleep(1.0);
5403
5404 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
5405 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
5406 activate(as_Media());
5407
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005408 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005409 f_gen_handover_req()));
Harald Welte6811d102019-04-14 22:23:14 +02005410 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005411
5412 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
5413
5414 var PDU_BSSAP rx_bssap;
5415 var octetstring ho_command_str;
5416
5417 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
5418
5419 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
5420 log("Received L3 Info in HO Request Ack: ", ho_command_str);
5421 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
5422 log("L3 Info in HO Request Ack is ", ho_command);
5423
5424 var GsmArfcn arfcn;
5425 var RslChannelNr actual_new_chan_nr;
5426 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
5427 actual_new_chan_nr, arfcn);
5428
5429 if (actual_new_chan_nr != new_chan_nr) {
5430 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
5431 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
5432 setverdict(fail);
5433 return;
5434 }
5435 log("Handover Command chan_nr is", actual_new_chan_nr);
5436
5437 /* Now the MSC forwards the RR Handover Command to the other BSC, which
5438 * tells the MS to handover to the new lchan. But the MS never shows up
5439 * on the new lchan. */
5440
5441 BSSAP.receive(tr_BSSMAP_HandoverFailure);
5442
5443 /* Did osmo-bsc also send a Clear Request? */
5444 timer T := 0.5;
5445 T.start;
5446 alt {
5447 [] BSSAP.receive(tr_BSSMAP_ClearRequest);
5448 [] T.timeout { }
5449 }
5450
5451 /* MSC plays along with a Clear Command (no matter whether osmo-bsc
5452 * asked for it, this is a Handover Failure after all). */
5453
5454 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_RADIO_INTERFACE_FAILURE_REVERSION;
5455 var BssmapCause cause := enum2int(cause_val);
5456 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
5457
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02005458 f_expect_dlcx_conns();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005459 f_sleep(1.0);
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005460}
5461testcase TC_ho_in_fail_no_detect() runs on test_CT {
5462 var MSC_ConnHdlr vc_conn;
5463 var TestHdlrParams pars := f_gen_test_hdlr_pars();
5464
5465 f_init(1, true);
5466 f_sleep(1.0);
5467
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005468 f_ctrs_bsc_and_bts_init();
5469
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005470 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
5471 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005472
5473 vc_conn := f_start_handler(refers(f_tc_ho_in_fail_no_detect), pars);
5474 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005475
5476 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5477 f_ctrs_bsc_and_bts_add(0, "handover:error");
5478 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:attempted");
5479 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:error");
5480 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005481 f_shutdown_helper();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005482}
5483
5484/* Same as f_tc_ho_in_fail_no_detect, but MSC fails to send a Clear Command */
5485private function f_tc_ho_in_fail_no_detect2(charstring id) runs on MSC_ConnHdlr {
5486 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
5487 f_rslem_register(0, new_chan_nr);
5488 g_chan_nr := new_chan_nr;
5489 f_sleep(1.0);
5490
5491 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
5492 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
5493 activate(as_Media());
5494
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005495 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005496 f_gen_handover_req()));
Harald Welte6811d102019-04-14 22:23:14 +02005497 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005498
5499 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
5500
5501 var PDU_BSSAP rx_bssap;
5502 var octetstring ho_command_str;
5503
5504 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
5505
5506 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
5507 log("Received L3 Info in HO Request Ack: ", ho_command_str);
5508 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
5509 log("L3 Info in HO Request Ack is ", ho_command);
5510
5511 var GsmArfcn arfcn;
5512 var RslChannelNr actual_new_chan_nr;
5513 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
5514 actual_new_chan_nr, arfcn);
5515
5516 if (actual_new_chan_nr != new_chan_nr) {
5517 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
5518 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
5519 setverdict(fail);
5520 return;
5521 }
5522 log("Handover Command chan_nr is", actual_new_chan_nr);
5523
5524 /* Now the MSC forwards the RR Handover Command to the other BSC, which
5525 * tells the MS to handover to the new lchan. But the MS never shows up
5526 * on the new lchan. */
5527
5528 BSSAP.receive(tr_BSSMAP_HandoverFailure);
5529
5530 /* MSC plays dumb and sends no Clear Command */
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005531 var PDU_BSSAP rx_clear_request;
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02005532
5533 BSSAP.receive(tr_BSSMAP_ClearRequest) -> value rx_clear_request {
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005534 var BssmapCause cause := bit2int(rx_clear_request.pdu.bssmap.clearRequest.cause.causeValue);
5535 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
5536 };
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02005537 f_expect_dlcx_conns();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005538 f_sleep(1.0);
5539}
5540testcase TC_ho_in_fail_no_detect2() runs on test_CT {
5541 var MSC_ConnHdlr vc_conn;
5542 var TestHdlrParams pars := f_gen_test_hdlr_pars();
5543
5544 f_init(1, true);
5545 f_sleep(1.0);
5546
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005547 f_ctrs_bsc_and_bts_init();
5548
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005549 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
5550 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005551
5552 vc_conn := f_start_handler(refers(f_tc_ho_in_fail_no_detect2), pars);
5553 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005554
5555 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5556 f_ctrs_bsc_and_bts_add(0, "handover:error");
5557 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:attempted");
5558 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:error");
5559 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005560 f_shutdown_helper();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005561}
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005562
Neels Hofmeyr91401012019-07-11 00:42:35 +02005563type record of charstring Commands;
5564
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005565private function f_bts_0_cfg(TELNETasp_PT pt, Commands cmds := {})
Neels Hofmeyr91401012019-07-11 00:42:35 +02005566{
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005567 f_vty_enter_cfg_bts(pt, 0);
Neels Hofmeyr91401012019-07-11 00:42:35 +02005568 for (var integer i := 0; i < sizeof(cmds); i := i+1) {
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005569 f_vty_transceive(pt, cmds[i]);
Neels Hofmeyr91401012019-07-11 00:42:35 +02005570 }
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005571 f_vty_transceive(pt, "end");
Neels Hofmeyr91401012019-07-11 00:42:35 +02005572}
5573
Pau Espin Pedrolc675b612020-01-09 19:55:40 +01005574private function f_cs7_inst_0_cfg(TELNETasp_PT pt, Commands cmds := {})
5575{
5576 f_vty_enter_cfg_cs7_inst(pt, 0);
5577 for (var integer i := 0; i < sizeof(cmds); i := i+1) {
5578 f_vty_transceive(pt, cmds[i]);
5579 }
5580 f_vty_transceive(pt, "end");
5581}
5582
Neels Hofmeyr91401012019-07-11 00:42:35 +02005583private function f_probe_for_handover(charstring log_label,
5584 charstring log_descr,
5585 charstring handover_vty_cmd,
5586 boolean expect_handover,
5587 boolean is_inter_bsc_handover := false)
5588runs on MSC_ConnHdlr
5589{
Neels Hofmeyrb3fc8982020-05-11 00:16:42 +02005590 /* We're going to thwart any and all handover attempts, just be ready to handle (and ignore) handover target
5591 * lchans to be established on bts 1 or bts 2. */
5592 f_rslem_suspend(RSL1_PROC);
5593 f_rslem_suspend(RSL2_PROC);
5594
Neels Hofmeyr91401012019-07-11 00:42:35 +02005595 var RSL_Message rsl;
5596
5597 var charstring log_msg := " (expecting handover)"
5598 if (not expect_handover) {
5599 log_msg := " (expecting NO handover)";
5600 }
5601 log("f_probe_for_handover starting: " & log_label & ": " & log_descr & log_msg);
5602 f_vty_transceive(BSCVTY, handover_vty_cmd);
5603
Neels Hofmeyr91401012019-07-11 00:42:35 +02005604 timer T := 2.0;
5605 T.start;
5606
5607 alt {
5608 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr)) -> value rsl {
5609 var PDU_ML3_NW_MS l3 := dec_PDU_ML3_NW_MS(rsl.ies[2].body.l3_info.payload);
5610 log("Rx L3 from net: ", l3);
5611 if (ischosen(l3.msgs.rrm.handoverCommand)) {
5612 var RslChannelNr new_chan_nr;
5613 var GsmArfcn arfcn;
5614 f_ChDesc2RslChanNr(l3.msgs.rrm.handoverCommand.channelDescription2,
5615 new_chan_nr, arfcn);
5616 log("Handover to new chan ", new_chan_nr, " on ARFCN ", arfcn);
5617 log(l3.msgs.rrm.handoverCommand);
5618
5619 /* Need to register for new lchan on new BTS -- it's either bts 1 or bts 2. It doesn't really
5620 * matter on which BTS it really is, we're not going to follow through an entire handover
5621 * anyway. */
5622 f_rslem_register(0, new_chan_nr, RSL1_PROC);
5623 f_rslem_resume(RSL1_PROC);
5624 f_rslem_register(0, new_chan_nr, RSL2_PROC);
5625 f_rslem_resume(RSL2_PROC);
5626
5627 if (expect_handover and not is_inter_bsc_handover) {
5628 setverdict(pass);
5629 log("f_probe_for_handover(" & log_label & "): Got RSL Handover Command as expected.");
5630 } else {
5631 setverdict(fail, "f_probe_for_handover(" & log_label & "): Expected none, but got RSL Handover Command. "
5632 & log_label & ": " & log_descr);
5633 }
5634
5635 log("f_probe_for_handover(" & log_label & "): Ending the test: Handover Failure stops the procedure.");
5636 /* osmo-bsc has triggered Handover. That's all we need to know for this test, reply with
5637 * Handover Failure. */
5638 f_rsl_send_l3(ts_RRM_HandoverFailure('00'O));
5639
5640 /* target BTS is told to release lchan again; don't care which BTS nor what messages. */
5641 f_sleep(0.5);
5642 RSL1.clear;
5643 RSL2.clear;
5644 log("f_probe_for_handover(" & log_label & "): done (got RSL Handover Command)");
5645 break;
5646 } else {
5647 repeat;
5648 }
5649 }
5650 [] BSSAP.receive(tr_BSSMAP_HandoverRequired) {
5651 if (expect_handover and is_inter_bsc_handover) {
5652 setverdict(pass);
5653 log("f_probe_for_handover(" & log_label & "): Got BSSMAP Handover Required as expected.");
5654 } else {
5655 setverdict(fail, "f_probe_for_handover(" & log_label & "): Expected none, but got BSSMAP Handover Required. "
5656 & log_label & ": " & log_descr);
5657 }
5658
5659 log("f_probe_for_handover(" & log_label & "): done (got BSSMAP Handover Required)");
5660
5661 /* Note: f_tc_ho_neighbor_config_start() sets T7, the timeout for BSSMAP Handover Required, to
5662 * 1 second. There is no legal way to quickly abort a handover after a BSSMAP Handover Required,
5663 * setting a short timeout and waiting is the only way. */
5664 log("f_probe_for_handover(" & log_label & "): waiting for inter-BSC HO to time out...");
5665 f_sleep(1.5);
5666 log("f_probe_for_handover(" & log_label & "): ...done");
5667
5668 break;
5669 }
5670 [] T.timeout {
5671 if (expect_handover) {
5672 setverdict(fail, "f_probe_for_handover(" & log_label & "): Expected Handover, but got none. "
5673 & log_label & ": " & log_descr);
5674 } else {
5675 setverdict(pass);
5676 log("f_probe_for_handover(" & log_label & "): Got no Handover, as expected.");
5677 }
5678 log("f_probe_for_handover(" & log_label & "): done (got no Handover)");
5679 break;
5680 }
5681 }
5682
5683 f_rslem_resume(RSL1_PROC);
5684 f_rslem_resume(RSL2_PROC);
5685 f_sleep(3.0);
5686 RSL.clear;
5687
5688 log("f_probe_for_handover(" & log_label & "): done clearing");
5689}
5690
5691/* Test the effect of various neighbor configuration scenarios:
5692 *
5693 * To avoid complexity, block off any actual handover operation, and always remain on the lchan at bts 0.
5694 * Reconfigure the neighbors for bts 0, trigger a Handover, and probe whether osmo-bsc does or doesn't start HO.
5695 */
5696private function f_tc_ho_neighbor_config_start() runs on MSC_ConnHdlr {
5697 g_pars := f_gen_test_hdlr_pars();
5698 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
5699 var PDU_BSSAP ass_cmd := f_gen_ass_req();
5700 const OCT8 kc := '0001020304050607'O;
5701
5702 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
5703 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
5704
5705 /* Establish lchan at bts 0 */
5706 f_establish_fully(ass_cmd, exp_compl);
5707
5708 /* Shorten the inter-BSC Handover timeout, to not wait so long for inter-BSC Handovers */
5709 f_vty_enter_cfg_network(BSCVTY);
5710 f_vty_transceive(BSCVTY, "timer T7 1");
5711 f_vty_transceive(BSCVTY, "end");
5712}
5713
5714private function f_tc_ho_neighbor_config_1(charstring id) runs on MSC_ConnHdlr {
5715 f_tc_ho_neighbor_config_start();
5716
5717 /*
5718 * bts 0 ARFCN 871 BSIC 10
5719 * bts 1 ARFCN 871 BSIC 11
5720 * bts 2 ARFCN 871 BSIC 12
5721 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
5722 */
5723
5724 log("f_tc_ho_neighbor_config: 1. No 'neighbor' config");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005725 f_bts_0_cfg(BSCVTY, {"no neighbors"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02005726 f_probe_for_handover("1.a", "HO to bts 1 works, implicitly listed as neighbor (legacy behavior when none are configured)",
5727 "handover any to arfcn 871 bsic 11",
5728 true);
5729
5730 f_probe_for_handover("1.b", "HO to unknown cell does not start",
5731 "handover any to arfcn 13 bsic 39",
5732 false);
5733
5734 f_probe_for_handover("1.c", "HO to 871-12 is ambiguous = error",
5735 "handover any to arfcn 871 bsic 12",
5736 false);
5737
5738 f_probe_for_handover("1.d", "HO to 871-11 still works (verify that this test properly cleans up)",
5739 "handover any to arfcn 871 bsic 11",
5740 true);
5741}
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005742testcase TC_ho_neighbor_config_1() runs on test_CT {
5743 var MSC_ConnHdlr vc_conn;
5744 f_init(3, true, guard_timeout := 60.0);
5745 f_sleep(1.0);
5746 f_ctrs_bsc_and_bts_init();
5747 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_1));
5748 vc_conn.done;
5749
5750 /* f_tc_ho_neighbor_config_start() */
5751 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5752 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5753
5754 /* 1.a */
5755 /* "failed" means a handover was triggered and started (which is all this test aims for) and the test ended the
5756 * handover quickly by sending a Handover Failure message. */
5757 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5758 f_ctrs_bsc_and_bts_add(0, "handover:failed");
5759 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
5760 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:failed");
5761
5762 /* 1.b */
5763 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5764 f_ctrs_bsc_and_bts_add(0, "handover:error");
5765
5766 /* 1.c */
5767 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5768 f_ctrs_bsc_and_bts_add(0, "handover:error");
5769
5770 /* 1.d */
5771 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5772 f_ctrs_bsc_and_bts_add(0, "handover:failed");
5773 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
5774 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:failed");
5775
5776 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005777 f_shutdown_helper();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005778}
5779
Neels Hofmeyr91401012019-07-11 00:42:35 +02005780private function f_tc_ho_neighbor_config_2(charstring id) runs on MSC_ConnHdlr {
5781 f_tc_ho_neighbor_config_start();
5782
5783 /*
5784 * bts 0 ARFCN 871 BSIC 10
5785 * bts 1 ARFCN 871 BSIC 11
5786 * bts 2 ARFCN 871 BSIC 12
5787 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
5788 */
5789
5790 log("f_tc_ho_neighbor_config: 2. explicit local neighbor: 'neighbor bts 1'");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005791 f_bts_0_cfg(BSCVTY, {"neighbor bts 1"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02005792 f_sleep(0.5);
5793
5794 f_probe_for_handover("2.a", "HO to bts 1 works, explicitly listed as neighbor",
5795 "handover any to arfcn 871 bsic 11",
5796 true);
5797
5798 f_probe_for_handover("2.b", "HO to bts 2 doesn't work, not listed as neighbor",
5799 "handover any to arfcn 871 bsic 12",
5800 false);
5801}
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005802testcase TC_ho_neighbor_config_2() runs on test_CT {
5803 var MSC_ConnHdlr vc_conn;
5804 f_init(3, true, guard_timeout := 50.0);
5805 f_sleep(1.0);
5806 f_ctrs_bsc_and_bts_init();
5807 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_2));
5808 vc_conn.done;
5809
5810 /* f_tc_ho_neighbor_config_start() */
5811 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5812 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5813
5814 /* 2.a */
5815 /* "failed" means a handover was triggered and started (which is all this test aims for) and the test ended the
5816 * handover quickly by sending a Handover Failure message. */
5817 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5818 f_ctrs_bsc_and_bts_add(0, "handover:failed");
5819 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
5820 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:failed");
5821
5822 /* 2.b */
5823 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5824 f_ctrs_bsc_and_bts_add(0, "handover:error");
5825
5826 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005827 f_shutdown_helper();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005828}
5829
Neels Hofmeyr91401012019-07-11 00:42:35 +02005830private function f_tc_ho_neighbor_config_3(charstring id) runs on MSC_ConnHdlr {
5831 f_tc_ho_neighbor_config_start();
5832
5833 /*
5834 * bts 0 ARFCN 871 BSIC 10
5835 * bts 1 ARFCN 871 BSIC 11
5836 * bts 2 ARFCN 871 BSIC 12
5837 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
5838 */
5839
5840 log("f_tc_ho_neighbor_config: 3. explicit local neighbor: 'neighbor bts 2'");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005841 f_bts_0_cfg(BSCVTY, {"no neighbors", "neighbor bts 2"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02005842 f_sleep(0.5);
5843
5844 f_probe_for_handover("3.a", "HO to bts 1 doesn't work, not listed as neighbor",
5845 "handover any to arfcn 871 bsic 11",
5846 false);
5847 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",
5848 "handover any to arfcn 871 bsic 12",
5849 true);
5850}
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005851testcase TC_ho_neighbor_config_3() runs on test_CT {
5852 var MSC_ConnHdlr vc_conn;
5853 f_init(3, true, guard_timeout := 50.0);
5854 f_sleep(1.0);
5855 f_ctrs_bsc_and_bts_init();
5856 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_3));
5857 vc_conn.done;
5858
5859 /* f_tc_ho_neighbor_config_start() */
5860 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5861 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5862
5863 /* 3.a */
5864 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5865 f_ctrs_bsc_and_bts_add(0, "handover:error");
5866
5867 /* 3.b */
5868 /* "failed" means a handover was triggered and started (which is all this test aims for) and the test ended the
5869 * handover quickly by sending a Handover Failure message. */
5870 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5871 f_ctrs_bsc_and_bts_add(0, "handover:failed");
5872 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
5873 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:failed");
5874
5875 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005876 f_shutdown_helper();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005877}
5878
Neels Hofmeyr91401012019-07-11 00:42:35 +02005879private function f_tc_ho_neighbor_config_4(charstring id) runs on MSC_ConnHdlr {
5880 f_tc_ho_neighbor_config_start();
5881
5882 /*
5883 * bts 0 ARFCN 871 BSIC 10
5884 * bts 1 ARFCN 871 BSIC 11
5885 * bts 2 ARFCN 871 BSIC 12
5886 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
5887 */
5888
5889 log("f_tc_ho_neighbor_config: 4. explicit remote neighbor: 'neighbor lac 99 arfcn 123 bsic 45'");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005890 f_bts_0_cfg(BSCVTY, {"no neighbors", "neighbor lac 99 arfcn 123 bsic 45"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02005891 f_sleep(0.5);
5892
5893 f_probe_for_handover("4.a", "HO to bts 1 doesn't work, not listed as neighbor",
5894 "handover any to arfcn 871 bsic 11",
5895 false);
5896 f_probe_for_handover("4.b", "HO to bts 2 doesn't work, not listed as neighbor",
5897 "handover any to arfcn 871 bsic 12",
5898 false);
5899 f_probe_for_handover("4.c", "HO to 123-45 triggers inter-BSC HO",
5900 "handover any to arfcn 123 bsic 45",
5901 true, true);
5902}
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005903testcase TC_ho_neighbor_config_4() runs on test_CT {
5904 var MSC_ConnHdlr vc_conn;
5905 f_init(3, true, guard_timeout := 50.0);
5906 f_sleep(1.0);
5907 f_ctrs_bsc_and_bts_init();
5908 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_4));
5909 vc_conn.done;
5910
5911 /* f_tc_ho_neighbor_config_start() */
5912 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5913 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5914
5915 /* 4.a */
5916 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5917 f_ctrs_bsc_and_bts_add(0, "handover:error");
5918
5919 /* 4.b */
5920 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5921 f_ctrs_bsc_and_bts_add(0, "handover:error");
5922
5923 /* 4.c */
5924 /* "timeout" means a handover was triggered and started (which is all this test aims for) and the test ended the
5925 * handover quickly by timing out after the Handover Required message */
5926 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5927 f_ctrs_bsc_and_bts_add(0, "handover:timeout");
5928 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
5929 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:timeout");
5930
5931 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005932 f_shutdown_helper();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005933}
5934
Neels Hofmeyr91401012019-07-11 00:42:35 +02005935private function f_tc_ho_neighbor_config_5(charstring id) runs on MSC_ConnHdlr {
5936 f_tc_ho_neighbor_config_start();
5937
5938 /*
5939 * bts 0 ARFCN 871 BSIC 10
5940 * bts 1 ARFCN 871 BSIC 11
5941 * bts 2 ARFCN 871 BSIC 12
5942 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
5943 */
5944
5945 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 +02005946 f_bts_0_cfg(BSCVTY, {"no neighbors", "neighbor lac 99 arfcn 871 bsic 12"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02005947 f_sleep(0.5);
5948
5949 f_probe_for_handover("5.a", "HO to 871-12 triggers inter-BSC HO (ignoring local cells with same ARFCN+BSIC)",
5950 "handover any to arfcn 871 bsic 12",
5951 true, true);
5952}
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005953testcase TC_ho_neighbor_config_5() runs on test_CT {
5954 var MSC_ConnHdlr vc_conn;
5955 f_init(3, true);
5956 f_sleep(1.0);
5957 f_ctrs_bsc_and_bts_init();
5958 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_5));
5959 vc_conn.done;
5960
5961 /* f_tc_ho_neighbor_config_start() */
5962 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5963 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5964
5965 /* 5 */
5966 /* "timeout" means a handover was triggered and started (which is all this test aims for) and the test ended the
5967 * handover quickly by timing out after the Handover Required message */
5968 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5969 f_ctrs_bsc_and_bts_add(0, "handover:timeout");
5970 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
5971 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:timeout");
5972
5973 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005974 f_shutdown_helper();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005975}
5976
Neels Hofmeyr91401012019-07-11 00:42:35 +02005977private function f_tc_ho_neighbor_config_6(charstring id) runs on MSC_ConnHdlr {
5978 f_tc_ho_neighbor_config_start();
5979
5980 /*
5981 * bts 0 ARFCN 871 BSIC 10
5982 * bts 1 ARFCN 871 BSIC 11
5983 * bts 2 ARFCN 871 BSIC 12
5984 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
5985 */
5986
5987 log("f_tc_ho_neighbor_config: 6. config error: explicit local and remote neighbors with ambiguous ARFCN+BSIC:"
5988 & " 'neighbor bts 2; neighbor lac 99 arfcn 871 bsic 12'");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005989 f_bts_0_cfg(BSCVTY, {"no neighbors", "neighbor bts 2", "neighbor lac 99 arfcn 871 bsic 12"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02005990 f_sleep(0.5);
5991
5992 f_probe_for_handover("6.a", "HO to 871-12 is ambiguous = error",
5993 "handover any to arfcn 871 bsic 12",
5994 false);
5995}
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005996testcase TC_ho_neighbor_config_6() runs on test_CT {
5997 var MSC_ConnHdlr vc_conn;
5998 f_init(3, true);
5999 f_sleep(1.0);
6000 f_ctrs_bsc_and_bts_init();
6001 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_6));
6002 vc_conn.done;
6003
6004 /* f_tc_ho_neighbor_config_start() */
6005 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
6006 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
6007
6008 /* 6.a */
6009 /* "timeout" means a handover was triggered and started (which is all this test aims for) and the test ended the
6010 * handover quickly by timing out after the Handover Required message */
6011 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
6012 f_ctrs_bsc_and_bts_add(0, "handover:error");
6013
6014 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006015 f_shutdown_helper();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006016}
6017
Neels Hofmeyr91401012019-07-11 00:42:35 +02006018private function f_tc_ho_neighbor_config_7(charstring id) runs on MSC_ConnHdlr {
6019 f_tc_ho_neighbor_config_start();
6020
6021 /*
6022 * bts 0 ARFCN 871 BSIC 10
6023 * bts 1 ARFCN 871 BSIC 11
6024 * bts 2 ARFCN 871 BSIC 12
6025 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
6026 */
6027
6028 log("f_tc_ho_neighbor_config: 7. explicit local and remote neighbors:"
6029 & " 'neighbor bts 2; neighbor lac 99 arfcn 123 bsic 45'");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02006030 f_bts_0_cfg(BSCVTY, {"no neighbors", "neighbor bts 2", "neighbor lac 99 arfcn 123 bsic 45"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02006031 f_sleep(0.5);
6032
6033 f_probe_for_handover("7.a", "HO to 871-12 does HO to bts 2",
6034 "handover any to arfcn 871 bsic 12",
6035 true);
6036 f_probe_for_handover("7.b", "HO to 123-45 triggers inter-BSC HO",
6037 "handover any to arfcn 123 bsic 45",
6038 true, true);
6039}
Neels Hofmeyr91401012019-07-11 00:42:35 +02006040testcase TC_ho_neighbor_config_7() runs on test_CT {
6041 var MSC_ConnHdlr vc_conn;
Neels Hofmeyrf2b88032020-06-16 00:35:04 +02006042 f_init(3, true, guard_timeout := 50.0);
Neels Hofmeyr91401012019-07-11 00:42:35 +02006043 f_sleep(1.0);
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006044 f_ctrs_bsc_and_bts_init();
Neels Hofmeyr91401012019-07-11 00:42:35 +02006045 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_7));
6046 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00006047
6048 /* f_tc_ho_neighbor_config_start() */
6049 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
6050 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
6051
6052 /* 7.a */
6053 /* "failed" means a handover was triggered and started (which is all this test aims for) and the test ended the
6054 * handover quickly by sending a Handover Failure message. */
6055 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
6056 f_ctrs_bsc_and_bts_add(0, "handover:failed");
6057 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
6058 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:failed");
6059
6060 /* 7.b */
6061 /* "timeout" means a handover was triggered and started (which is all this test aims for) and the test ended the
6062 * handover quickly by timing out after the Handover Required message */
6063 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
6064 f_ctrs_bsc_and_bts_add(0, "handover:timeout");
6065 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
6066 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:timeout");
6067
6068 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006069 f_shutdown_helper();
Neels Hofmeyr91401012019-07-11 00:42:35 +02006070}
6071
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01006072/* OS#3041: Open and close N connections in a normal fashion, and expect no
6073 * BSSMAP Reset just because of that. */
6074testcase TC_bssap_rlsd_does_not_cause_bssmap_reset() runs on test_CT {
6075 var default d;
6076 var integer i;
6077 var DchanTuple dt;
6078
6079 f_init();
6080
6081 /* Wait for initial BSSMAP Reset to pass */
6082 f_sleep(4.0);
6083
6084 d := activate(no_bssmap_reset());
6085
6086 /* Setup up a number of connections and RLSD them again from the MSC
6087 * side. In the buggy behavior, the fourth one triggers BSSMAP Reset.
6088 * Let's do it some more times for good measure. */
Harald Weltec3260d92018-06-11 17:48:16 +02006089 for (i := 0; i < 4; i := i+1) {
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01006090 /* Since we're doing a lot of runs, give each one a fresh
6091 * T_guard from the top. */
6092 T_guard.start;
6093
6094 /* Setup a BSSAP connection and clear it right away. This is
6095 * the MSC telling the BSC about a planned release, it's not an
6096 * erratic loss of a connection. */
Harald Weltea1897182018-06-11 13:53:09 +02006097 dt := f_est_dchan(int2oct(i,1), 23+i, '00010203040506'O);
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01006098
6099 /* MSC disconnects (RLSD). */
6100 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
6101 }
6102
6103 /* In the buggy behavior, a timeout of 2 seconds happens between above
6104 * trigger (logs "SIGTRAN connection down, reconnecting...") and the
6105 * actual BSSMAP Reset. Wait a bit longer just to make sure. */
6106 f_sleep(4.0);
6107
6108 deactivate(d);
6109 f_shutdown_helper();
6110}
Harald Welte552620d2017-12-16 23:21:36 +01006111
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01006112/* OS#3041: Open and close N connections in a normal fashion, and expect no
6113 * BSSMAP Reset just because of that. Invoke the release by a BSSMAP Clear from
6114 * the MSC. */
6115testcase TC_bssmap_clear_does_not_cause_bssmap_reset() runs on test_CT {
6116 var default d;
6117 var integer i;
6118 var DchanTuple dt;
6119 var BSSAP_N_DATA_ind rx_di;
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01006120 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_CALL_CONTROL;
6121 var BssmapCause cause := enum2int(cause_val);
6122
6123 f_init();
6124
6125 /* Wait for initial BSSMAP Reset to pass */
6126 f_sleep(4.0);
6127
6128 d := activate(no_bssmap_reset());
6129
6130 /* Setup up a number of connections and RLSD them again from the MSC
6131 * side. In the buggy behavior, the fourth one triggers BSSMAP Reset.
6132 * Let's do it some more times for good measure. */
6133 for (i := 0; i < 8; i := i+1) {
6134 /* Since we're doing a lot of runs, give each one a fresh
6135 * T_guard from the top. */
6136 T_guard.start;
6137
6138 /* Setup a BSSAP connection and clear it right away. This is
6139 * the MSC telling the BSC about a planned release, it's not an
6140 * erratic loss of a connection. */
Harald Weltea1897182018-06-11 13:53:09 +02006141 dt := f_est_dchan(int2oct(i,1), 23+i, '00010203040506'O);
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01006142
6143 /* Instruct BSC to clear channel */
6144 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
6145
6146 /* expect BSC to disable the channel */
Harald Welte641fcbe2018-06-14 10:58:35 +02006147 f_exp_chan_rel_and_clear(dt, 0);
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01006148 }
6149
6150 /* In the buggy behavior, a timeout of 2 seconds happens between above
6151 * trigger (logs "SIGTRAN connection down, reconnecting...") and the
6152 * actual BSSMAP Reset. Wait a bit longer just to make sure. */
6153 f_sleep(4.0);
6154
6155 deactivate(d);
6156 f_shutdown_helper();
6157}
6158
Neels Hofmeyrfd445c32018-03-09 15:39:31 +01006159/* OS#3041: Open and close N connections in a normal fashion, and expect no
6160 * BSSMAP Reset just because of that. Close connections from the MS side with a
6161 * Release Ind on RSL. */
6162testcase TC_ms_rel_ind_does_not_cause_bssmap_reset() runs on test_CT {
6163 var default d;
6164 var integer i;
6165 var DchanTuple dt;
6166 var BSSAP_N_DATA_ind rx_di;
Neels Hofmeyrfd445c32018-03-09 15:39:31 +01006167 var integer j;
6168
6169 f_init();
6170
6171 /* Wait for initial BSSMAP Reset to pass */
6172 f_sleep(4.0);
6173
6174 d := activate(no_bssmap_reset());
6175
6176 /* Setup up a number of connections and RLSD them again from the MSC
6177 * side. In the buggy behavior, the fourth one triggers BSSMAP Reset.
6178 * Let's do it some more times for good measure. */
6179 for (i := 0; i < 8; i := i+1) {
6180 /* Since we're doing a lot of runs, give each one a fresh
6181 * T_guard from the top. */
6182 T_guard.start;
6183
6184 /* Setup a BSSAP connection and clear it right away. This is
6185 * the MSC telling the BSC about a planned release, it's not an
6186 * erratic loss of a connection. */
6187 dt := f_est_dchan('23'O, 23, '00010203040506'O);
6188
6189 /* simulate RLL REL IND */
6190 f_ipa_tx(0, ts_RSL_REL_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0))));
6191
6192 /* expect Clear Request on MSC side */
6193 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearRequest)) -> value rx_di;
6194
6195 /* Instruct BSC to clear channel */
6196 var BssmapCause cause := bit2int(rx_di.userData.pdu.bssmap.clearRequest.cause.causeValue);
6197 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
6198
6199 /* expect BSC to disable the channel */
Harald Welte641fcbe2018-06-14 10:58:35 +02006200 f_exp_chan_rel_and_clear(dt, 0);
Neels Hofmeyrfd445c32018-03-09 15:39:31 +01006201 }
6202
6203 /* In the buggy behavior, a timeout of 2 seconds happens between above
6204 * trigger (logs "SIGTRAN connection down, reconnecting...") and the
6205 * actual BSSMAP Reset. Wait a bit longer just to make sure. */
6206 f_sleep(4.0);
6207
6208 deactivate(d);
6209 f_shutdown_helper();
6210}
6211
Harald Welte94e0c342018-04-07 11:33:23 +02006212/***********************************************************************
6213 * IPA style dynamic PDCH
6214 ***********************************************************************/
6215
6216private function f_dyn_ipa_pdch_act(integer bts_nr, integer trx_nr, integer ts_nr,
6217 template (omit) RSL_Cause nack := omit)
6218runs on test_CT {
6219 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(ts_nr));
6220 var RSL_Message rsl_unused;
6221 /* ask BSC via VTY to activate a given IPA style chan as PDCH */
6222 f_vty_ts_action("pdch activate", bts_nr, trx_nr, ts_nr);
6223 /* expect the BSC to issue the related RSL command */
6224 rsl_unused := f_exp_ipa_rx(0, tr_RSL_IPA_PDCH_ACT(chan_nr));
6225 if (istemplatekind(nack, "omit")) {
6226 /* respond with a related acknowledgement */
6227 f_ipa_tx(0, ts_RSL_IPA_PDCH_ACT_ACK(chan_nr, ts_RSL_IE_FrameNumber(2342)));
6228 } else {
6229 f_ipa_tx(0, ts_RSL_IPA_PDCH_ACT_NACK(chan_nr, valueof(nack)));
6230 }
6231}
6232
6233private function f_dyn_ipa_pdch_deact(integer bts_nr, integer trx_nr, integer ts_nr,
6234 template (omit) RSL_Cause nack := omit)
6235runs on test_CT {
6236 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(ts_nr));
6237 var RSL_Message rsl_unused;
6238 /* ask BSC via VTY to activate a given IPA style chan as PDCH */
6239 f_vty_ts_action("pdch deactivate", bts_nr, trx_nr, ts_nr);
6240 /* expect the BSC to issue the related RSL command */
6241 rsl_unused := f_exp_ipa_rx(0, tr_RSL_IPA_PDCH_DEACT(chan_nr));
6242 if (istemplatekind(nack, "omit")) {
6243 /* respond with a related acknowledgement */
6244 f_ipa_tx(0, ts_RSL_IPA_PDCH_DEACT_ACK(chan_nr));
6245 } else {
6246 f_ipa_tx(0, ts_RSL_IPA_PDCH_DEACT_NACK(chan_nr, valueof(nack)));
6247 }
6248}
6249
6250private function f_ts_dyn_mode_get(integer bts_nr, integer trx_nr, integer ts_nr)
6251runs on test_CT return charstring {
6252 var charstring cmd, resp;
6253 cmd := "show timeslot "&int2str(bts_nr)&" "&int2str(trx_nr)&" "&int2str(ts_nr);
Stefan Sperlingcff13562018-11-13 15:24:06 +01006254 return f_vty_transceive_match_regexp_retry(BSCVTY, cmd, "*\((*)\)*", 0, 4, 1.0);
Harald Welte94e0c342018-04-07 11:33:23 +02006255}
6256
6257private function f_ts_dyn_mode_assert(integer bts_nr, integer trx_nr, integer ts_nr,
6258 template charstring exp)
6259runs on test_CT {
6260 var charstring mode := f_ts_dyn_mode_get(bts_nr, trx_nr, ts_nr);
6261 if (not match(mode, exp)) {
6262 setverdict(fail, "Unexpected TS Mode: ", mode);
Daniel Willmannafce8662018-07-06 23:11:32 +02006263 mtc.stop;
Harald Welte94e0c342018-04-07 11:33:23 +02006264 }
6265}
6266
6267private function f_ts_set_chcomb(integer bts_nr, integer trx_nr, integer ts_nr, charstring chcomb)
6268runs on test_CT {
6269 f_vty_enter_cfg_ts(BSCVTY, bts_nr, trx_nr, ts_nr);
6270 f_vty_transceive(BSCVTY, "phys_chan_config " & chcomb);
6271 f_vty_transceive(BSCVTY, "end");
6272}
6273
6274private const charstring TCHF_MODE := "TCH/F mode";
6275private const charstring TCHH_MODE := "TCH/H mode";
6276private const charstring PDCH_MODE := "PDCH mode";
6277private const charstring NONE_MODE := "NONE mode";
6278
6279/* Test IPA PDCH activation / deactivation triggered by VTY */
6280testcase TC_dyn_pdch_ipa_act_deact() runs on test_CT {
6281 var RSL_Message rsl_unused;
6282
6283 /* change Timeslot 6 before f_init() starts RSL */
6284 f_init_vty();
6285 f_ts_set_chcomb(0, 0, 6, "TCH/F_PDCH");
6286 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
6287
6288 f_init(1, false);
6289 f_sleep(1.0);
6290
6291 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(6));
6292
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02006293 log("TCH/F_PDCH pchan starts out in TCH/F mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02006294 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
6295 /* The BSC will activate the dynamic PDCH by default, so confirm that */
6296 rsl_unused := f_exp_ipa_rx(0, tr_RSL_IPA_PDCH_ACT(chan_nr));
6297 f_ipa_tx(0, ts_RSL_IPA_PDCH_ACT_ACK(chan_nr, ts_RSL_IE_FrameNumber(2342)));
6298 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02006299 log("TCH/F_PDCH pchan, PDCH ACT was ACKed, so now in PDCH mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02006300 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, PDCH_MODE);
6301
6302 /* De-activate it via VTY */
6303 f_dyn_ipa_pdch_deact(0, 0, chan_nr.tn);
6304 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02006305 log("TCH/F_PDCH pchan, PDCH DEACT via VTY, so now back in TCH/F mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02006306 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
6307
6308 /* re-activate it via VTY */
6309 f_dyn_ipa_pdch_act(0, 0, chan_nr.tn);
6310 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02006311 log("TCH/F_PDCH pchan, PDCH ACT via VTY, so now in PDCH mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02006312 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, PDCH_MODE);
6313
6314 /* and finally de-activate it again */
6315 f_dyn_ipa_pdch_deact(0, 0, chan_nr.tn);
6316 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02006317 log("TCH/F_PDCH pchan, PDCH DEACT via VTY, so now back in TCH/F mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02006318 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
6319
Neels Hofmeyr887e8f12018-06-27 01:01:55 +02006320 /* clean up config */
6321 f_ts_set_chcomb(0, 0, 6, "PDCH");
6322
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006323 f_shutdown_helper();
Harald Welte94e0c342018-04-07 11:33:23 +02006324}
6325
6326/* Test IPA PDCH activation NACK */
6327testcase TC_dyn_pdch_ipa_act_nack() runs on test_CT {
6328 var RSL_Message rsl_unused;
6329
6330 /* change Timeslot 6 before f_init() starts RSL */
6331 f_init_vty();
6332 f_ts_set_chcomb(0, 0, 6, "TCH/F_PDCH");
6333 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
6334
6335 f_init(1, false);
6336 f_sleep(1.0);
6337
6338 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(6));
6339
6340 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
6341 /* The BSC will activate the dynamic PDCH by default, so confirm that */
6342 rsl_unused := f_exp_ipa_rx(0, tr_RSL_IPA_PDCH_ACT(chan_nr));
6343 f_ipa_tx(0, ts_RSL_IPA_PDCH_ACT_ACK(chan_nr, ts_RSL_IE_FrameNumber(2342)));
6344 f_sleep(1.0);
6345 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, PDCH_MODE);
6346
6347 /* De-activate it via VTY */
6348 f_dyn_ipa_pdch_deact(0, 0, chan_nr.tn);
6349 f_sleep(1.0);
6350 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
6351
6352 /* re-activate it via VTY, but fail that; check BSC still assumes TCH/F mode */
6353 f_dyn_ipa_pdch_act(0, 0, chan_nr.tn, RSL_ERR_EQUIPMENT_FAIL);
6354 f_sleep(1.0);
6355 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
6356
Neels Hofmeyr887e8f12018-06-27 01:01:55 +02006357 /* clean up config */
6358 f_ts_set_chcomb(0, 0, 6, "PDCH");
6359
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006360 f_shutdown_helper();
Harald Welte94e0c342018-04-07 11:33:23 +02006361}
6362
6363
6364/***********************************************************************
6365 * Osmocom style dynamic PDCH
6366 ***********************************************************************/
6367
6368private function f_dyn_osmo_pdch_act(integer bts_nr, integer trx_nr, integer ts_nr,
6369 template (omit) RSL_Cause nack := omit)
6370runs on test_CT {
6371 var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(ts_nr));
6372 var RSL_Message rsl_unused;
6373 /* ask BSC via VTY to activate a given IPA style chan as PDCH */
6374 /* FIXME: no VTY command to activate Osmocom PDCH !! */
6375 /* expect the BSC to issue the related RSL command */
6376 rsl_unused := f_exp_ipa_rx(0, tr_RSL_CHAN_ACT(chan_nr, ?));
6377 if (istemplatekind(nack, "omit")) {
6378 /* respond with a related acknowledgement */
6379 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, 2342));
6380 } else {
6381 f_ipa_tx(0, ts_RSL_CHAN_ACT_NACK(chan_nr, valueof(nack)));
6382 }
6383}
6384
6385private function f_dyn_osmo_pdch_deact(integer bts_nr, integer trx_nr, integer ts_nr,
6386 template (omit) RSL_Cause nack := omit)
6387runs on test_CT {
6388 var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(ts_nr));
6389 var RSL_Message rsl_unused;
6390 /* ask BSC via VTY to activate a given IPA style chan as PDCH */
6391 /* FIXME: no VTY command to activate Osmocom PDCH !! */
6392 /* expect the BSC to issue the related RSL command */
6393 rsl_unused := f_exp_ipa_rx(0, tr_RSL_RF_CHAN_REL(chan_nr));
6394 if (istemplatekind(nack, "omit")) {
6395 /* respond with a related acknowledgement */
6396 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(chan_nr));
6397 } else {
6398 //f_ipa_tx(0, ts_RSL_RF_CHAN_REL_NACK(chan_nr, valueof(nack)));
6399 }
6400}
6401
6402/* Test Osmocom dyn PDCH activation / deactivation triggered by VTY */
6403testcase TC_dyn_pdch_osmo_act_deact() runs on test_CT {
6404 var RSL_Message rsl_unused;
6405
6406 /* change Timeslot 6 before f_init() starts RSL */
6407 f_init_vty();
6408 f_ts_set_chcomb(0, 0, 6, "TCH/F_TCH/H_PDCH");
6409 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
6410
6411 f_init(1, false);
6412 f_sleep(1.0);
6413
6414 var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(6));
6415
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02006416 log("TCH/F_TCH/H_PDCH pchan starts out in disabled mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02006417 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, NONE_MODE);
6418 /* The BSC will activate the dynamic PDCH by default, so confirm that */
6419 rsl_unused := f_exp_ipa_rx(0, tr_RSL_CHAN_ACT_PDCH(chan_nr, ?));
6420
6421 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, 2342));
6422 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02006423 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 +02006424 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, PDCH_MODE);
6425
Neels Hofmeyr887e8f12018-06-27 01:01:55 +02006426 /* clean up config */
6427 f_ts_set_chcomb(0, 0, 6, "PDCH");
6428
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006429 f_shutdown_helper();
Harald Welte94e0c342018-04-07 11:33:23 +02006430}
6431
6432/* Test Osmocom dyn PDCH activation NACK behavior */
6433testcase TC_dyn_pdch_osmo_act_nack() runs on test_CT {
6434 var RSL_Message rsl_unused;
6435
6436 /* change Timeslot 6 before f_init() starts RSL */
6437 f_init_vty();
6438 f_ts_set_chcomb(0, 0, 6, "TCH/F_TCH/H_PDCH");
6439 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
6440
6441 f_init(1, false);
6442 f_sleep(1.0);
6443
6444 var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(6));
6445
6446 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, NONE_MODE);
6447 /* The BSC will activate the dynamic PDCH by default, so confirm that */
6448 rsl_unused := f_exp_ipa_rx(0, tr_RSL_CHAN_ACT_PDCH(chan_nr, ?));
6449
6450 /* NACK this activation and expect the "show timeslot" mode still to be NONE */
6451 f_ipa_tx(0, ts_RSL_CHAN_ACT_NACK(chan_nr, RSL_ERR_EQUIPMENT_FAIL));
6452 f_sleep(1.0);
6453 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, NONE_MODE);
6454
Neels Hofmeyr887e8f12018-06-27 01:01:55 +02006455 /* clean up config */
6456 f_ts_set_chcomb(0, 0, 6, "PDCH");
6457
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006458 f_shutdown_helper();
Harald Welte94e0c342018-04-07 11:33:23 +02006459}
6460
Stefan Sperling0796a822018-10-05 13:01:39 +02006461testcase TC_chopped_ipa_ping() runs on test_CT {
Stefan Sperling554123f2018-10-09 14:12:30 +02006462 const Integers bsc_ipa_ports := {mp_bsc_rsl_port, mp_bsc_oml_port, mp_bsc_ctrl_port};
Stefan Sperling0796a822018-10-05 13:01:39 +02006463 for (var integer i := 0; i < lengthof(bsc_ipa_ports); i := i + 1) {
6464 IPA_Testing.f_run_TC_chopped_ipa_ping(mp_bsc_ip, bsc_ipa_ports[i], CONNECT_TO_SERVER);
6465 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006466 f_shutdown_helper();
Stefan Sperling0796a822018-10-05 13:01:39 +02006467}
6468
Stefan Sperlingaa1e60f2018-10-15 16:34:07 +02006469testcase TC_chopped_ipa_payload() runs on test_CT {
6470 const Integers bsc_ipa_ports := {mp_bsc_rsl_port, mp_bsc_oml_port
6471 /* TODO: mp_bsc_ctrl_port does not work yet */};
6472 for (var integer i := 0; i < lengthof(bsc_ipa_ports); i := i + 1) {
6473 IPA_Testing.f_run_TC_chopped_ipa_payload(mp_bsc_ip, bsc_ipa_ports[i], CONNECT_TO_SERVER);
6474 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006475 f_shutdown_helper();
Stefan Sperlingaa1e60f2018-10-15 16:34:07 +02006476}
6477
Pau Espin Pedrol8f773632019-11-05 11:46:53 +01006478/* Verify the BSC sends the MS Power Parameters IE during CHAN ACT to make sure
6479 the BTS does autonomous MS power control loop */
6480testcase TC_assignment_verify_ms_power_params_ie() runs on test_CT {
6481 var MSC_ConnHdlr vc_conn;
6482 var TestHdlrParams pars := f_gen_test_hdlr_pars();
6483 //pars.encr := valueof(t_EncrParams('01'O, f_rnd_octstring(8)));
6484 pars.exp_ms_power_params := true;
6485
6486 f_init(1, true);
6487 f_sleep(1.0);
6488 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5), pars);
6489 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006490 f_shutdown_helper();
Pau Espin Pedrol8f773632019-11-05 11:46:53 +01006491}
Stefan Sperlingaa1e60f2018-10-15 16:34:07 +02006492
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006493/***********************************************************************
6494 * MSC Pooling
6495 ***********************************************************************/
6496
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006497template MobileIdentityLV ts_MI_TMSI_NRI_LV(integer nri_v, integer nri_bitlen := 10) :=
Harald Weltebf397612021-01-14 20:39:46 +01006498 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 +02006499
Pau Espin Pedrolc08d5522021-04-16 15:40:38 +02006500private function f_expect_lchan_rel(RSL_DCHAN_PT rsl, template PDU_ML3_NW_MS exp_rr_rel_tmpl := tr_RRM_RR_RELEASE)
6501runs on MSC_ConnHdlr {
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02006502 interleave {
Pau Espin Pedrolc08d5522021-04-16 15:40:38 +02006503 [] rsl.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch exp_rr_rel_tmpl)) {
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02006504 f_logp(BSCVTY, "Got RSL RR Release");
6505 }
6506 [] rsl.receive(tr_RSL_DEACT_SACCH(g_chan_nr)) {
6507 f_logp(BSCVTY, "Got RSL Deact SACCH");
6508 }
6509 [] rsl.receive(tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL)) {
6510 f_logp(BSCVTY, "Got RSL RF Chan Rel, sending Rel Ack");
6511 rsl.send(ts_RSL_RF_CHAN_REL_ACK(g_chan_nr));
6512 break;
6513 }
6514 }
6515}
6516
Pau Espin Pedrolc08d5522021-04-16 15:40:38 +02006517private function f_perform_clear(RSL_DCHAN_PT rsl, template PDU_ML3_NW_MS exp_rr_rel_tmpl := tr_RRM_RR_RELEASE)
6518runs on MSC_ConnHdlr {
Neels Hofmeyr767548a2020-08-09 20:26:07 +00006519 f_logp(BSCVTY, "MSC instructs BSC to clear channel");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006520 BSSAP.send(ts_BSSMAP_ClearCommand(0));
6521 interleave {
Pau Espin Pedrolc08d5522021-04-16 15:40:38 +02006522 [] rsl.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch exp_rr_rel_tmpl)) {
Neels Hofmeyr767548a2020-08-09 20:26:07 +00006523 f_logp(BSCVTY, "Got RSL RR Release");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006524 }
6525 [] rsl.receive(tr_RSL_DEACT_SACCH(g_chan_nr)) {
Neels Hofmeyr767548a2020-08-09 20:26:07 +00006526 f_logp(BSCVTY, "Got RSL Deact SACCH");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006527 }
6528 [] BSSAP.receive(tr_BSSMAP_ClearComplete) {
Neels Hofmeyr767548a2020-08-09 20:26:07 +00006529 f_logp(BSCVTY, "Got BSSMAP Clear Complete");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006530 /* Also drop the SCCP connection */
6531 BSSAP.send(RAN_Conn_Prim:MSC_CONN_PRIM_DISC_REQ);
6532 }
6533 [] rsl.receive(tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL)) {
Neels Hofmeyr767548a2020-08-09 20:26:07 +00006534 f_logp(BSCVTY, "Got RSL RF Chan Rel, sending Rel Ack");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006535 rsl.send(ts_RSL_RF_CHAN_REL_ACK(g_chan_nr));
6536 }
6537 }
6538}
6539
Neels Hofmeyr66e15092020-10-12 18:44:41 +00006540private 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 +02006541runs on MSC_ConnHdlr {
6542 timer T := 10.0;
6543 var octetstring l3_enc := enc_PDU_ML3_MS_NW(valueof(l3_info));
6544
Neels Hofmeyr767548a2020-08-09 20:26:07 +00006545 f_logp(BSCVTY, "establish channel, send Complete Layer 3 Info");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006546 f_create_bssmap_exp(l3_enc);
6547
6548 /* RSL_Emulation.f_chan_est() on rsl:
6549 * This is basically code dup with s/RSL/rsl from:
6550 * RSL_Emulation.f_chan_est(g_pars.ra, l3_enc, g_pars.link_id, g_pars.fn);
6551 */
6552 var RSL_Message rx_rsl;
6553 var GsmRrMessage rr;
6554
6555 /* request a channel to be established */
6556 rsl.send(ts_RSLDC_ChanRqd(g_pars.ra, g_pars.fn));
6557 /* expect immediate assignment.
6558 * Code dup with s/RSL/rsl from:
6559 * rx_rsl := f_rx_or_fail(tr_RSL_IMM_ASSIGN);
6560 */
6561 timer Tt := 10.0;
6562
6563 /* request a channel to be established */
6564 Tt.start;
6565 alt {
6566 [] rsl.receive(tr_RSL_IMM_ASSIGN) -> value rx_rsl {
6567 Tt.stop;
6568 }
6569 [] rsl.receive {
6570 setverdict(fail, "Unexpected RSL message on DCHAN");
6571 mtc.stop;
6572 }
6573 [] Tt.timeout {
6574 setverdict(fail, "Timeout waiting for RSL on DCHAN");
6575 mtc.stop;
6576 }
6577 }
6578 rr := dec_GsmRrMessage(rx_rsl.ies[1].body.full_imm_ass_info.payload);
6579 g_chan_nr := rr.payload.imm_ass.chan_desc.chan_nr;
6580 rsl.send(ts_RSL_EST_IND(g_chan_nr, valueof(g_pars.link_id), l3_enc));
6581
6582
Neels Hofmeyr66e15092020-10-12 18:44:41 +00006583 if (expect_bssmap_l3) {
6584 f_logp(BSCVTY, "expect BSSAP Complete Layer 3 Info at MSC");
6585 var template PDU_BSSAP exp_l3_compl;
6586 exp_l3_compl := tr_BSSMAP_ComplL3()
6587 if (g_pars.aoip == false) {
6588 exp_l3_compl.pdu.bssmap.completeLayer3Information.codecList := omit;
6589 } else {
6590 exp_l3_compl.pdu.bssmap.completeLayer3Information.codecList := ?;
6591 }
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006592
Neels Hofmeyr66e15092020-10-12 18:44:41 +00006593 var PDU_BSSAP bssap;
6594 T.start;
6595 alt {
6596 [] BSSAP.receive(exp_l3_compl) -> value bssap {
6597 f_logp(BSCVTY, "received expected Complete Layer 3 Info at MSC");
6598 log("rx exp_l3_compl = ", bssap);
6599 }
6600 [] BSSAP.receive(tr_BSSMAP_ComplL3) {
6601 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Received non-matching COMPLETE LAYER 3 INFORMATION");
6602 }
6603 [] T.timeout {
6604 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for COMPLETE LAYER 3 INFORMATION");
6605 }
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006606 }
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006607
Neels Hofmeyr66e15092020-10-12 18:44:41 +00006608 /* start ciphering, if requested */
6609 if (ispresent(g_pars.encr)) {
6610 f_logp(BSCVTY, "start ciphering");
6611 f_cipher_mode(g_pars.encr.enc_alg, g_pars.encr.enc_key);
6612 }
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006613 }
6614
6615 if (do_clear) {
6616 f_perform_clear(rsl);
6617 }
6618 setverdict(pass);
6619 f_sleep(1.0);
6620}
6621
6622private function f_tc_mscpool_compl_l3(charstring id) runs on MSC_ConnHdlr {
6623 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
6624 if (g_pars.mscpool.rsl_idx == 0) {
6625 f_perform_compl_l3(RSL, g_pars.mscpool.l3_info);
6626 } else if (g_pars.mscpool.rsl_idx == 1) {
6627 f_perform_compl_l3(RSL1, g_pars.mscpool.l3_info);
6628 } else if (g_pars.mscpool.rsl_idx == 2) {
6629 f_perform_compl_l3(RSL2, g_pars.mscpool.l3_info);
6630 }
6631}
6632
6633/* Various Complete Layer 3 by IMSI all end up with the first MSC, because the other MSCs are not connected. */
6634private function f_tc_mscpool_L3Compl_on_1_msc(charstring id) runs on MSC_ConnHdlr {
6635 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
6636 f_perform_compl_l3(RSL, ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_IMSI_LV('001010000000001'H)), '00F110'O) );
6637 f_perform_compl_l3(RSL, ts_CM_SERV_REQ(CM_TYPE_MO_SMS, valueof(ts_MI_IMSI_LV('001010000000002'H))) );
6638 f_perform_compl_l3(RSL, ts_PAG_RESP(valueof(ts_MI_IMSI_LV('001010000000003'H))) );
6639 f_perform_compl_l3(RSL, ts_ML3_MO_MM_IMSI_DET_Ind(valueof(ts_MI_IMSI_LV('001010000000004'H))) );
6640}
6641testcase TC_mscpool_L3Compl_on_1_msc() runs on test_CT {
6642
6643 f_init(1, true);
6644 f_sleep(1.0);
6645 var MSC_ConnHdlr vc_conn;
6646 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006647
6648 f_ctrs_msc_init();
6649
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006650 vc_conn := f_start_handler(refers(f_tc_mscpool_L3Compl_on_1_msc), pars);
6651 vc_conn.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006652
6653 f_ctrs_msc_expect(0, "mscpool:subscr:new", 4);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006654 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006655}
6656
6657/* Three Layer 3 Complete by IMSI are round-robin'ed across two connected MSCs */
6658/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
6659 * just as well using only RSL. */
6660testcase TC_mscpool_L3Complete_by_imsi_round_robin() runs on test_CT {
6661
6662 f_init(nr_bts := 3, handler_mode := true, nr_msc := 2);
6663 f_sleep(1.0);
6664
6665 /* Control which MSC gets chosen next by the round-robin, otherwise
6666 * would be randomly affected by which other tests ran before this. */
6667 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
6668
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006669 f_ctrs_msc_init();
6670
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006671 var MSC_ConnHdlr vc_conn1;
6672 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
6673 pars1.mscpool.rsl_idx := 0;
6674 pars1.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_IMSI_LV('001010000000001'H)), '00F110'O));
6675 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6676 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006677 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006678
6679 var MSC_ConnHdlr vc_conn2;
6680 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 1);
6681 pars2.mscpool.rsl_idx := 1;
6682 pars2.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, valueof(ts_MI_IMSI_LV('001010000000002'H))));
6683 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6684 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006685 f_ctrs_msc_expect(1, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006686
6687 /* Test round-robin wrap to the first MSC */
6688 var MSC_ConnHdlr vc_conn3;
6689 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 0);
6690 pars3.mscpool.rsl_idx := 2;
6691 pars3.mscpool.l3_info := valueof(ts_PAG_RESP(valueof(ts_MI_IMSI_LV('001010000000003'H))));
6692 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
6693 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006694 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006695 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006696}
6697
6698/* Three LU by TMSI are round-robin'ed across two connected MSCs, because they contain the NULL-NRI 0
6699 * (configured in osmo-bsc.cfg). */
6700/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
6701 * just as well using only RSL. */
6702testcase TC_mscpool_LU_by_tmsi_null_nri_0_round_robin() runs on test_CT {
6703
6704 f_init(nr_bts := 3, handler_mode := true, nr_msc := 2);
6705 f_sleep(1.0);
6706
6707 /* Control which MSC gets chosen next by the round-robin, otherwise
6708 * would be randomly affected by which other tests ran before this. */
6709 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
6710
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006711 f_ctrs_msc_init();
6712
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006713 var MSC_ConnHdlr vc_conn1;
6714 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
6715 pars1.mscpool.rsl_idx := 0;
6716 pars1.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(0)), '00F110'O));
6717 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6718 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006719 f_ctrs_msc_expect(0, "mscpool:subscr:reattach");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006720
6721 var MSC_ConnHdlr vc_conn2;
6722 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 1);
6723 pars2.mscpool.rsl_idx := 1;
6724 pars2.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(0)), '00F110'O));
6725 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6726 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006727 f_ctrs_msc_expect(1, "mscpool:subscr:reattach");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006728
6729 /* Test round-robin wrap to the first MSC */
6730 var MSC_ConnHdlr vc_conn3;
6731 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 0);
6732 pars3.mscpool.rsl_idx := 2;
6733 pars3.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(0)), '00F110'O));
6734 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
6735 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006736 f_ctrs_msc_expect(0, "mscpool:subscr:reattach");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006737 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006738}
6739
6740/* Three LU by TMSI are round-robin'ed across two connected MSCs, because they contain the NULL-NRI 1
6741 * (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
6742 * NULL-NRI setting is stronger than that. */
6743/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
6744 * just as well using only RSL. */
6745testcase TC_mscpool_LU_by_tmsi_null_nri_1_round_robin() runs on test_CT {
6746
6747 f_init(nr_bts := 3, handler_mode := true, nr_msc := 2);
6748 f_sleep(1.0);
6749
6750 /* Control which MSC gets chosen next by the round-robin, otherwise
6751 * would be randomly affected by which other tests ran before this. */
6752 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
6753
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006754 f_ctrs_msc_init();
6755
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006756 var MSC_ConnHdlr vc_conn1;
6757 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
6758 pars1.mscpool.rsl_idx := 0;
6759 pars1.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(1)), '00F110'O));
6760 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6761 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006762 f_ctrs_msc_expect(0, "mscpool:subscr:reattach");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006763
6764 var MSC_ConnHdlr vc_conn2;
6765 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 1);
6766 pars2.mscpool.rsl_idx := 1;
6767 pars2.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(1)), '00F110'O));
6768 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6769 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006770 f_ctrs_msc_expect(1, "mscpool:subscr:reattach");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006771
6772 /* Test round-robin wrap to the first MSC */
6773 var MSC_ConnHdlr vc_conn3;
6774 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 0);
6775 pars3.mscpool.rsl_idx := 2;
6776 pars3.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(1)), '00F110'O));
6777 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
6778 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006779 f_ctrs_msc_expect(0, "mscpool:subscr:reattach");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006780 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006781}
6782
6783/* Three Layer 3 Complete by TMSI are round-robin'ed across two connected MSCs, because they contain an NRI not
6784 * assigned to any MSC (configured in osmo-bsc.cfg). */
6785/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
6786 * just as well using only RSL. */
6787testcase TC_mscpool_L3Complete_by_tmsi_unassigned_nri_round_robin() runs on test_CT {
6788
6789 f_init(nr_bts := 3, handler_mode := true, nr_msc := 2);
6790 f_sleep(1.0);
6791
6792 /* Control which MSC gets chosen next by the round-robin, otherwise
6793 * would be randomly affected by which other tests ran before this. */
6794 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
6795
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006796 f_ctrs_msc_init();
6797
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006798 var MSC_ConnHdlr vc_conn1;
6799 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
6800 pars1.mscpool.rsl_idx := 0;
6801 /* An NRI that is not assigned to any MSC */
6802 pars1.mscpool.l3_info := valueof(ts_ML3_MO_MM_IMSI_DET_Ind(valueof(ts_MI_TMSI_NRI_LV(1023))));
6803 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6804 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006805 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006806
6807 var MSC_ConnHdlr vc_conn2;
6808 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 1);
6809 pars2.mscpool.rsl_idx := 1;
6810 /* An NRI that is not assigned to any MSC */
6811 pars2.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(768)), '00F110'O));
6812 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6813 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006814 f_ctrs_msc_expect(1, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006815
6816 /* Test round-robin wrap to the first MSC */
6817 var MSC_ConnHdlr vc_conn3;
6818 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 0);
6819 pars3.mscpool.rsl_idx := 2;
6820 /* An NRI that is not assigned to any MSC */
6821 pars3.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_SS_ACT, valueof(ts_MI_TMSI_NRI_LV(819))));
6822 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
6823 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006824 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006825 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006826}
6827
6828/* Three Layer 3 Complete by TMSI are round-robin'ed across two connected MSCs, because they contain an NRI
6829 * assigned to an MSC that is currently not connected (configured in osmo-bsc.cfg). */
6830/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
6831 * just as well using only RSL. */
6832testcase TC_mscpool_L3Complete_by_tmsi_valid_nri_msc_not_connected_round_robin() runs on test_CT {
6833
6834 f_init(nr_bts := 3, handler_mode := true, nr_msc := 2);
6835 f_sleep(1.0);
6836
6837 /* Control which MSC gets chosen next by the round-robin, otherwise
6838 * would be randomly affected by which other tests ran before this. */
6839 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
6840
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006841 f_ctrs_msc_init();
6842
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006843 var MSC_ConnHdlr vc_conn1;
6844 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
6845 pars1.mscpool.rsl_idx := 0;
6846 /* An NRI that is assigned to an unconnected MSC */
6847 pars1.mscpool.l3_info := valueof(ts_PAG_RESP(valueof(ts_MI_TMSI_NRI_LV(512))));
6848 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6849 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006850 f_ctrs_msc_add(2, "mscpool:subscr:attach_lost");
6851 f_ctrs_msc_add(0, "mscpool:subscr:new");
6852 f_ctrs_msc_verify();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006853
6854 var MSC_ConnHdlr vc_conn2;
6855 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 1);
6856 pars2.mscpool.rsl_idx := 1;
6857 /* An NRI that is assigned to an unconnected MSC */
6858 pars2.mscpool.l3_info := valueof(ts_ML3_MO_MM_IMSI_DET_Ind(valueof(ts_MI_TMSI_NRI_LV(767))));
6859 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6860 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006861 f_ctrs_msc_add(2, "mscpool:subscr:attach_lost");
6862 f_ctrs_msc_add(1, "mscpool:subscr:new");
6863 f_ctrs_msc_verify();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006864
6865 /* Test round-robin wrap to the first MSC */
6866 var MSC_ConnHdlr vc_conn3;
6867 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 0);
6868 pars3.mscpool.rsl_idx := 2;
6869 /* An NRI that is assigned to an unconnected MSC */
6870 pars3.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(750)), '00F110'O));
6871 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
6872 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006873 f_ctrs_msc_add(2, "mscpool:subscr:attach_lost");
6874 f_ctrs_msc_add(0, "mscpool:subscr:new");
6875 f_ctrs_msc_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006876 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006877}
6878
6879/* Three Layer 3 Complete by TMSI with valid NRI for the second MSC are all directed to the second MSC (configured in
6880 * osmo-bsc.cfg). */
6881/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
6882 * just as well using only RSL. */
6883testcase TC_mscpool_L3Complete_by_tmsi_valid_nri_1() runs on test_CT {
6884
6885 f_init(nr_bts := 3, handler_mode := true, nr_msc := 2);
6886 f_sleep(1.0);
6887
6888 /* All TMSIs in this test point at the second MSC, set the round robin to point at the first MSC to make sure
6889 * this is not using round-robin. */
6890 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
6891
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006892 f_ctrs_msc_init();
6893
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006894 var MSC_ConnHdlr vc_conn1;
6895 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 1);
6896 pars1.mscpool.rsl_idx := 0;
6897 /* An NRI of the second MSC's range (256-511) */
6898 pars1.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_SMS, valueof(ts_MI_TMSI_NRI_LV(256))));
6899 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6900 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006901 f_ctrs_msc_expect(1, "mscpool:subscr:known");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006902
6903 var MSC_ConnHdlr vc_conn2;
6904 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 1);
6905 pars2.mscpool.rsl_idx := 1;
6906 /* An NRI of the second MSC's range (256-511) */
6907 pars2.mscpool.l3_info := valueof(ts_PAG_RESP(valueof(ts_MI_TMSI_NRI_LV(260))));
6908 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6909 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006910 f_ctrs_msc_expect(1, "mscpool:subscr:known");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006911
6912 var MSC_ConnHdlr vc_conn3;
6913 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 1);
6914 pars3.mscpool.rsl_idx := 2;
6915 /* An NRI of the second MSC's range (256-511) */
6916 pars3.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(511)), '00F110'O));
6917 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
6918 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006919 f_ctrs_msc_expect(1, "mscpool:subscr:known");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006920 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006921}
6922
6923/* Layer 3 Complete by TMSI with valid NRI for the third MSC are directed to the third MSC (configured in osmo-bsc.cfg),
6924 * while a round-robin remains unaffected by that. */
6925/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
6926 * just as well using only RSL. */
6927testcase TC_mscpool_L3Complete_by_tmsi_valid_nri_2() runs on test_CT {
6928
6929 f_init(nr_bts := 3, handler_mode := true, nr_msc := 3);
6930 f_sleep(1.0);
6931
6932 /* All TMSIs in this test point at the third MSC, set the round robin to point at the second MSC to make sure
6933 * this is not using round-robin. */
6934 f_vty_transceive(BSCVTY, "mscpool roundrobin next 1");
6935
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006936 f_ctrs_msc_init();
6937
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006938 var MSC_ConnHdlr vc_conn1;
6939 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 2);
6940 pars1.mscpool.rsl_idx := 0;
6941 /* An NRI of the third MSC's range (512-767) */
6942 pars1.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_SMS, valueof(ts_MI_TMSI_NRI_LV(512))));
6943 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6944 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006945 f_ctrs_msc_expect(2, "mscpool:subscr:known");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006946
6947 var MSC_ConnHdlr vc_conn2;
6948 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 2);
6949 pars2.mscpool.rsl_idx := 1;
6950 /* An NRI of the third MSC's range (512-767) */
6951 pars2.mscpool.l3_info := valueof(ts_PAG_RESP(valueof(ts_MI_TMSI_NRI_LV(678))));
6952 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6953 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006954 f_ctrs_msc_expect(2, "mscpool:subscr:known");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006955
6956 /* The above forwardings to third MSC have not affected the round robin, which still points at the second MSC */
6957 var MSC_ConnHdlr vc_conn3;
6958 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 1);
6959 pars3.mscpool.rsl_idx := 2;
6960 pars3.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_IMSI_LV('001010000000013'H)), '00F110'O));
6961 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
6962 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006963 f_ctrs_msc_expect(1, "mscpool:subscr:new");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006964 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006965}
6966
6967/* LU with a TMSI but indicating a different PLMN in its previous LAI: ignore the NRI. */
6968/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
6969 * just as well using only RSL. */
6970testcase TC_mscpool_LU_by_tmsi_from_other_PLMN() runs on test_CT {
6971
6972 f_init(nr_bts := 3, handler_mode := true, nr_msc := 3);
6973 f_sleep(1.0);
6974
6975 /* The TMSIs in this test points at the second MSC, but since it is from a different PLMN, round-robin is used
6976 * instead, and hits msc 0. */
6977 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
6978
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006979 f_ctrs_msc_init();
6980
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006981 /* An NRI of the second MSC's range (256-511), but a PLMN that doesn't match with osmo-bsc.cfg */
6982 var MSC_ConnHdlr vc_conn1;
6983 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
6984 pars1.mscpool.rsl_idx := 0;
6985 pars1.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(260)), '99F999'O));
6986 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6987 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006988 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006989
6990 /* An NRI of the third MSC's range (512-767) and a matching PLMN gets directed by NRI. */
6991 var MSC_ConnHdlr vc_conn2;
6992 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 2);
6993 pars2.mscpool.rsl_idx := 1;
6994 pars2.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(555)), '00F110'O));
6995 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6996 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006997 f_ctrs_msc_expect(2, "mscpool:subscr:known");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006998 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006999}
7000
7001/* Make sure that whichever MSC paged a subscriber will also get the Paging Response. Page by IMSI, which would be
7002 * round-robined to another MSC, to make sure the Paging->Response relation is stronger than the NRI->MSC mapping. */
7003private function f_tc_mscpool_paging_imsi(charstring id) runs on MSC_ConnHdlr {
7004 var template BSSMAP_FIELD_CellIdentificationList cid_list := { cIl_CI := { ts_BSSMAP_CI_CI(0) } };
7005 //cid_list := { cIl_allInBSS := ''O };
7006 var RSL_ChanNeeded rsl_chneed := RSL_CHANNEED_SDCCH;
7007 var template BSSMAP_IE_ChannelNeeded bssmap_chneed := ts_BSSMAP_IE_ChanNeeded(int2bit(enum2int(valueof(rsl_chneed)),2));
7008 var BSSAP_N_UNITDATA_req paging;
7009 var hexstring imsi := '001010000000123'H;
7010
7011 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
7012
Neels Hofmeyr90f80962020-06-12 16:16:55 +02007013 paging := valueof(ts_BSSAP_UNITDATA_req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007014 valueof(ts_BSSMAP_Paging(imsi, cid_list, omit, bssmap_chneed))));
7015 BSSAP.send(paging);
7016
7017 /* Register any RSL conn so that the Paging Command gets received here. With the current RSL_Emulation's main()
7018 * handling of '[bts_role] IPA_PT.receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD()))' it doesn't matter at all which
7019 * channel number is picked here. */
7020 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(0, RSL_CHAN_NR_INVALID));
7021 f_rslem_register(0, new_chan_nr);
7022 RSL.receive(tr_RSL_PAGING_CMD(tr_MI_IMSI(imsi)));
7023 f_rslem_unregister(0, new_chan_nr);
7024
7025 /* Despite the round robin pointing at the second MSC ('roundrobin next 1'), the earlier Paging for the same IMSI
7026 * causes this Paging Response to go to the first MSC (bssap_idx := 0). */
7027 f_perform_compl_l3(RSL, ts_PAG_RESP(valueof(ts_MI_IMSI_LV(imsi))) );
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007028 f_sleep(1.0);
7029}
7030testcase TC_mscpool_paging_and_response_imsi() runs on test_CT {
7031 f_init(nr_bts := 1, handler_mode := true, nr_msc := 3);
7032 f_sleep(1.0);
7033
7034 /* Testing a Paging on the first MSC to get a Paging Response back to the first MSC. Set round robin to the
7035 * second MSC to make sure we're getting the Paging logic, not a coincidental round robin match. */
7036 f_vty_transceive(BSCVTY, "mscpool roundrobin next 1");
7037
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007038 f_ctrs_msc_init();
7039
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007040 var MSC_ConnHdlr vc_conn1;
7041 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
7042 pars1.mscpool.rsl_idx := 0;
Neels Hofmeyr90f80962020-06-12 16:16:55 +02007043 pars1.sccp_addr_bsc := g_bssap[pars1.mscpool.bssap_idx].sccp_addr_peer;
7044 pars1.sccp_addr_msc := g_bssap[pars1.mscpool.bssap_idx].sccp_addr_own;
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007045 vc_conn1 := f_start_handler(refers(f_tc_mscpool_paging_imsi), pars1);
7046 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007047 f_ctrs_msc_expect(0, "mscpool:subscr:paged");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007048 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007049}
7050
7051/* Make sure that whichever MSC paged a subscriber will also get the Paging Response. Page by TMSI with an NRI value
7052 * that matches a different MSC, to make sure the Paging->Response relation is stronger than the NRI->MSC mapping. */
7053private function f_tc_mscpool_paging_tmsi(charstring id) runs on MSC_ConnHdlr {
7054 var template BSSMAP_FIELD_CellIdentificationList cid_list := { cIl_CI := { ts_BSSMAP_CI_CI(0) } };
7055 //cid_list := { cIl_allInBSS := ''O };
7056 var RSL_ChanNeeded rsl_chneed := RSL_CHANNEED_SDCCH;
7057 var template BSSMAP_IE_ChannelNeeded bssmap_chneed := ts_BSSMAP_IE_ChanNeeded(int2bit(enum2int(valueof(rsl_chneed)),2));
7058 var integer nri_v := 300; /* <-- second MSC's NRI */
Harald Weltebf397612021-01-14 20:39:46 +01007059 var octetstring tmsi := f_gen_tmsi(suffix := 0, nri_v := nri_v);
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007060 var BSSAP_N_UNITDATA_req paging;
7061
7062 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
7063
Neels Hofmeyr90f80962020-06-12 16:16:55 +02007064 paging := valueof(ts_BSSAP_UNITDATA_req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007065 valueof(ts_BSSMAP_Paging('001010000000011'H, cid_list, tmsi, bssmap_chneed))));
7066 BSSAP.send(paging);
7067
7068 /* Register any RSL conn so that the Paging Command gets received here. With the current RSL_Emulation's main()
7069 * handling of '[bts_role] IPA_PT.receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD()))' it doesn't matter at all which
7070 * channel number is picked here. */
7071 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(0, RSL_CHAN_NR_INVALID));
7072 f_rslem_register(0, new_chan_nr);
7073 RSL.receive(tr_RSL_PAGING_CMD(t_MI_TMSI(tmsi)));
7074 f_rslem_unregister(0, new_chan_nr);
7075
7076 /* Despite the NRI matching the second MSC (NRI from 'msc 1' in osmo-bsc.cfg) and round robin pointing at the
7077 * third MSC ('roundrobin next 2'), the earlier Paging for the same TMSI causes this Paging Response to go to
7078 * the first MSC (bssap_idx := 0). */
7079 f_perform_compl_l3(RSL, ts_PAG_RESP(valueof(ts_MI_TMSI_NRI_LV(nri_v))) );
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007080 f_sleep(1.0);
7081}
7082testcase TC_mscpool_paging_and_response_tmsi() runs on test_CT {
7083 f_init(nr_bts := 1, handler_mode := true, nr_msc := 3);
7084 f_sleep(1.0);
7085
7086 /* Testing a Paging on the first MSC to get a Paging Response back to the first MSC. Set round robin to the
7087 * third MSC to make sure we're getting the Paging logic, not a coincidental round robin match. */
7088 f_vty_transceive(BSCVTY, "mscpool roundrobin next 2");
7089
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007090 f_ctrs_msc_init();
7091
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007092 var MSC_ConnHdlr vc_conn1;
7093 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
7094 pars1.mscpool.rsl_idx := 0;
Neels Hofmeyr90f80962020-06-12 16:16:55 +02007095 pars1.sccp_addr_bsc := g_bssap[pars1.mscpool.bssap_idx].sccp_addr_peer;
7096 pars1.sccp_addr_msc := g_bssap[pars1.mscpool.bssap_idx].sccp_addr_own;
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007097 vc_conn1 := f_start_handler(refers(f_tc_mscpool_paging_tmsi), pars1);
7098 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007099 f_ctrs_msc_expect(0, "mscpool:subscr:paged");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007100 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007101}
7102
7103/* For round-robin, skip an MSC that has 'no allow-attach' set. */
7104/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
7105 * just as well using only RSL. */
7106testcase TC_mscpool_no_allow_attach_round_robin() runs on test_CT {
7107
7108 f_init(nr_bts := 3, handler_mode := true, nr_msc := 3);
7109 f_sleep(1.0);
Neels Hofmeyra460f1f2020-08-09 20:17:03 +00007110 /* Mark the second MSC as offloading, round-robin should skip this MSC now. */
7111 f_vty_msc_allow_attach(BSCVTY, {true, false, true});
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007112
7113 /* Control which MSC gets chosen next by the round-robin, otherwise
7114 * would be randomly affected by which other tests ran before this. */
7115 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
7116
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007117 f_ctrs_msc_init();
7118
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007119 var MSC_ConnHdlr vc_conn1;
7120 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
7121 pars1.mscpool.rsl_idx := 0;
7122 pars1.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_IMSI_LV('001010000000001'H)), '00F110'O));
7123 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
7124 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007125 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007126
7127 var MSC_ConnHdlr vc_conn2;
7128 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 2);
7129 pars2.mscpool.rsl_idx := 1;
7130 pars2.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, valueof(ts_MI_IMSI_LV('001010000000002'H))));
7131 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
7132 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007133 f_ctrs_msc_expect(2, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007134
7135 var MSC_ConnHdlr vc_conn3;
7136 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 0);
7137 pars3.mscpool.rsl_idx := 2;
7138 pars3.mscpool.l3_info := valueof(ts_PAG_RESP(valueof(ts_MI_IMSI_LV('001010000000003'H))));
7139 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
7140 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007141 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007142 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007143}
7144
7145/* An MSC that has 'no allow-attach' set should still serve subscribers that are already attached according to their
7146 * TMSI NRI. */
7147testcase TC_mscpool_no_allow_attach_valid_nri() runs on test_CT {
7148
7149 f_init(nr_bts := 3, handler_mode := true, nr_msc := 3);
7150 f_sleep(1.0);
7151
Neels Hofmeyra460f1f2020-08-09 20:17:03 +00007152 /* Mark the second MSC as offloading, round-robin should skip this MSC now. */
7153 f_vty_msc_allow_attach(BSCVTY, {true, false, true});
7154
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007155 /* Control which MSC gets chosen next by the round-robin, otherwise
7156 * would be randomly affected by which other tests ran before this. */
7157 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
7158
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007159 f_ctrs_msc_init();
7160
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007161 /* Round robin points at msc 0, but the valid NRI directs to msc 1, even though msc 1 has 'no allow-attach'. */
7162 var MSC_ConnHdlr vc_conn1;
7163 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 1);
7164 pars1.mscpool.rsl_idx := 0;
7165 /* An NRI of the second MSC's range (256-511) */
7166 pars1.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, valueof(ts_MI_TMSI_NRI_LV(260))));
7167 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
7168 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007169 f_ctrs_msc_expect(1, "mscpool:subscr:known");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007170
7171 var MSC_ConnHdlr vc_conn2;
7172 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 0);
7173 pars2.mscpool.rsl_idx := 1;
7174 pars2.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, valueof(ts_MI_IMSI_LV('001010000000002'H))));
7175 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
7176 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007177 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007178
7179 var MSC_ConnHdlr vc_conn3;
7180 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 2);
7181 pars3.mscpool.rsl_idx := 2;
7182 pars3.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, valueof(ts_MI_IMSI_LV('001010000000003'H))));
7183 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
7184 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007185 f_ctrs_msc_expect(2, "mscpool:subscr:new");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007186 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007187}
7188
Philipp Maier783681c2020-07-16 16:47:06 +02007189/* Allow/Deny emergency calls globally via VTY */
7190private function f_vty_allow_emerg_msc(boolean allow) runs on test_CT {
7191 f_vty_enter_cfg_msc(BSCVTY, 0);
7192 if (allow) {
7193 f_vty_transceive(BSCVTY, "allow-emergency allow");
7194 } else {
7195 f_vty_transceive(BSCVTY, "allow-emergency deny");
7196 }
7197 f_vty_transceive(BSCVTY, "exit");
7198 f_vty_transceive(BSCVTY, "exit");
7199}
7200
7201/* Allow/Deny emergency calls per BTS via VTY */
7202private function f_vty_allow_emerg_bts(boolean allow, integer bts_nr) runs on test_CT {
7203 f_vty_enter_cfg_bts(BSCVTY, bts_nr);
7204 if (allow) {
7205 f_vty_transceive(BSCVTY, "rach emergency call allowed 1");
7206 } else {
7207 f_vty_transceive(BSCVTY, "rach emergency call allowed 0");
7208 }
7209 f_vty_transceive(BSCVTY, "exit");
7210 f_vty_transceive(BSCVTY, "exit");
Neels Hofmeyrb6ed80c2020-10-12 22:52:39 +00007211 f_vty_transceive(BSCVTY, "exit");
Philipp Maier783681c2020-07-16 16:47:06 +02007212}
7213
7214/* Begin assignmet procedure and send an EMERGENCY SETUP (RR) */
7215private function f_assignment_emerg_setup() runs on MSC_ConnHdlr {
7216 var PDU_ML3_MS_NW emerg_setup;
7217 var octetstring emerg_setup_enc;
7218 var RSL_Message emerg_setup_data_ind;
7219
7220 f_establish_fully(omit, omit);
7221
7222 emerg_setup := valueof(ts_ML3_MO_CC_EMERG_SETUP(1, valueof(ts_Bcap_voice)));
7223 emerg_setup_enc := enc_PDU_ML3_MS_NW(emerg_setup);
7224 emerg_setup_data_ind := valueof(ts_RSL_DATA_IND(g_chan_nr, valueof(ts_RslLinkID_DCCH(0)), emerg_setup_enc));
7225
7226 RSL.send(emerg_setup_data_ind);
7227}
7228
7229/* Test if the EMERGENCY SETUP gets passed on to the MSC via A when EMERGENCY
7230 * CALLS are permitted by the BSC config. */
7231private function f_TC_assignment_emerg_setup_allow(charstring id) runs on MSC_ConnHdlr {
7232 var PDU_BSSAP emerg_setup_data_ind_bssap;
7233 var PDU_ML3_MS_NW emerg_setup;
7234 timer T := 3.0;
7235
7236 f_assignment_emerg_setup()
7237
7238 T.start;
7239 alt {
7240 [] BSSAP.receive(tr_BSSAP_DTAP) -> value emerg_setup_data_ind_bssap {
7241 emerg_setup := dec_PDU_ML3_MS_NW(emerg_setup_data_ind_bssap.pdu.dtap);
7242 if (not isbound(emerg_setup.msgs.cc.emergencySetup)) {
7243 setverdict(fail, "no emergency setup");
7244 }
7245 }
7246 [] BSSAP.receive {
7247 setverdict(fail, "unexpected BSSAP message!");
7248 }
7249 [] T.timeout {
7250 setverdict(fail, "timout waiting for EMERGENCY SETUP!");
7251 }
7252 }
7253
7254 setverdict(pass);
7255}
7256
7257/* Test if the EMERGENCY SETUP gets blocked by the BSC if EMERGENCY CALLS are
7258 * forbidden by the BSC config. */
7259private function f_TC_assignment_emerg_setup_deny(charstring id) runs on MSC_ConnHdlr {
7260 var PDU_BSSAP emerg_setup_data_ind_bssap;
7261 timer T := 3.0;
7262
7263 f_assignment_emerg_setup()
7264
7265 T.start;
7266 alt {
7267 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_RELEASE)) {
7268 setverdict(pass);
7269 }
7270 [] RSL.receive {
7271 setverdict(fail, "unexpected RSL message!");
7272 }
7273 [] T.timeout {
7274 setverdict(fail, "timout waiting for RR CHANNEL RELEASE!");
7275 }
7276 }
7277}
7278
7279/* EMERGENCY CALL situation #1, allowed globally and by BTS */
7280testcase TC_assignment_emerg_setup_allow() runs on test_CT {
7281 var TestHdlrParams pars := f_gen_test_hdlr_pars();
7282 var MSC_ConnHdlr vc_conn;
7283
7284 f_init(1, true);
7285 f_sleep(1.0);
7286
7287 f_vty_allow_emerg_msc(true);
7288 f_vty_allow_emerg_bts(true, 0);
7289 vc_conn := f_start_handler(refers(f_TC_assignment_emerg_setup_allow), pars);
7290 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007291 f_shutdown_helper();
Philipp Maier783681c2020-07-16 16:47:06 +02007292}
7293
7294/* EMERGENCY CALL situation #2, forbidden globally but allowed by BTS */
7295testcase TC_assignment_emerg_setup_deny_msc() runs on test_CT {
7296 var TestHdlrParams pars := f_gen_test_hdlr_pars();
7297 var MSC_ConnHdlr vc_conn;
7298
7299 f_init(1, true);
7300 f_sleep(1.0);
7301
7302 f_vty_allow_emerg_msc(false);
7303 f_vty_allow_emerg_bts(true, 0);
7304 vc_conn := f_start_handler(refers(f_TC_assignment_emerg_setup_deny), pars);
7305 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007306 f_shutdown_helper();
Philipp Maier783681c2020-07-16 16:47:06 +02007307}
7308
7309/* EMERGENCY CALL situation #3, allowed globally but forbidden by BTS */
7310testcase TC_assignment_emerg_setup_deny_bts() runs on test_CT {
7311 var TestHdlrParams pars := f_gen_test_hdlr_pars();
7312 var MSC_ConnHdlr vc_conn;
7313
7314 /* Note: This simulates a spec violation by the MS, correct MS
7315 * implementations would not try to establish an emergency call because
7316 * the system information tells in advance that emergency calls are
7317 * not forbidden */
7318
7319 f_init(1, true);
7320 f_sleep(1.0);
7321
7322 f_vty_allow_emerg_msc(true);
7323 f_vty_allow_emerg_bts(false, 0);
7324 vc_conn := f_start_handler(refers(f_TC_assignment_emerg_setup_deny), pars);
7325 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007326 f_shutdown_helper();
Philipp Maier783681c2020-07-16 16:47:06 +02007327}
7328
Philipp Maier82812002020-08-13 18:48:27 +02007329/* Test what happens when an emergency call arrives while all TCH channels are
7330 * busy, the BSC is expected to terminate one call in favor of the incoming
7331 * emergency call */
7332testcase TC_emerg_premption() runs on test_CT {
7333 var ASP_RSL_Unitdata rsl_ud;
7334 var integer i;
7335 var integer chreq_total, chreq_nochan;
7336 var RSL_Message rx_rsl;
7337 var RslChannelNr chan_nr;
7338
7339 f_init(1);
7340 f_sleep(1.0);
7341
7342 f_vty_allow_emerg_msc(true);
7343 f_vty_allow_emerg_bts(true, 0);
7344
7345 /* Fill up all channels on the BTS */
7346 chreq_total := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total");
7347 chreq_nochan := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:no_channel");
7348 for (i := 0; i < NUM_TCHF_PER_BTS + NUM_TCHH_PER_BTS + NUM_SDCCH_PER_BTS; i := i+1) {
7349 chan_nr := f_chreq_act_ack('33'O, i);
7350 }
7351 IPA_RSL[0].clear;
7352 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total",
7353 chreq_total + NUM_TCHF_PER_BTS + NUM_TCHH_PER_BTS + NUM_SDCCH_PER_BTS);
7354
7355 /* Send Channel request for emegergency call */
7356 f_ipa_tx(0, ts_RSL_CHAN_RQD('A5'O, 23));
7357
7358 /* Expect the BSC to release one (the first) TCH/F on the BTS */
7359 chan_nr := valueof(t_RslChanNr_Bm(1));
7360 f_expect_chan_rel(0, chan_nr, expect_rr_chan_rel := false, expect_rll_rel_req := false);
7361
7362 /* Expect the BSC to send activate/assign the a channel for the emergency call */
7363 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
7364 chan_nr := rx_rsl.ies[0].body.chan_nr;
7365 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, 33));
7366 rx_rsl := f_exp_ipa_rx(0, tr_RSL_IMM_ASSIGN(0));
Philipp Maier104f4c02020-09-11 18:12:18 +02007367
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007368 f_shutdown_helper();
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007369}
7370
7371/* Hopping parameters per a timeslot */
Vadim Yanitskiybc6654a2020-09-13 01:27:40 +07007372private type record length(0..64) of GsmArfcn ArfcnList;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007373private type record FHParamsTs {
7374 boolean enabled,
7375 uint6_t hsn,
7376 uint6_t maio,
7377 ArfcnList ma
7378};
7379
7380/* Hopping parameters per a transceiver */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007381private type record FHParamsTrx {
7382 GsmArfcn arfcn,
7383 FHParamsTs ts[8]
7384};
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007385
7386/* Randomly generate the hopping parameters for the given timeslot numbers */
7387private function f_TC_fh_params_gen(template integer tr_tn := (1, 3, 5))
7388runs on test_CT return FHParamsTrx {
7389 var FHParamsTrx fhp;
7390
Vadim Yanitskiy3e997362020-09-05 21:08:34 +07007391 /* Generate a random ARFCN, including ARFCN 0 */
7392 fhp.arfcn := f_rnd_int(3);
Vadim Yanitskiye7c8c6e2020-09-13 14:33:03 +07007393
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007394 for (var integer tn := 0; tn < 8; tn := tn + 1) {
7395 if (not match(tn, tr_tn)) {
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007396 fhp.ts[tn].enabled := false;
7397 fhp.ts[tn].ma := { };
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007398 continue;
7399 }
7400
7401 /* Random HSN / MAIO values: 0..63 */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007402 fhp.ts[tn].hsn := f_rnd_int(64);
7403 fhp.ts[tn].maio := f_rnd_int(64);
7404 fhp.ts[tn].ma := { };
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007405
7406 /* Random Mobile Allocation (hopping channels) */
7407 var integer ma_len := 2 + f_rnd_int(9); /* 2..10 channels */
7408 var integer step := 3 + f_rnd_int(4); /* 3..6 stepping */
7409 for (var integer i := 1; i <= ma_len; i := i + 1) {
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007410 fhp.ts[tn].ma := fhp.ts[tn].ma & { i * step };
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007411 }
7412
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007413 fhp.ts[tn].enabled := true;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007414 }
7415
7416 log("f_TC_fh_params_gen(): ", fhp);
7417 return fhp;
7418}
7419
7420/* Make sure that the given Channel Description IE matches the hopping configuration */
7421private function f_TC_fh_params_match_chan_desc(in FHParamsTrx fhp, in ChannelDescription cd)
7422{
7423 var template (present) ChannelDescription tr_cd;
7424 var template (present) MaioHsn tr_maio_hsn;
7425 var uint3_t tn := cd.chan_nr.tn;
7426
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007427 if (fhp.ts[tn].enabled) {
7428 tr_maio_hsn := tr_HsnMaio(fhp.ts[tn].hsn, fhp.ts[tn].maio);
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007429 tr_cd := tr_ChanDescH1(cd.chan_nr, tr_maio_hsn);
7430 } else {
Vadim Yanitskiye7c8c6e2020-09-13 14:33:03 +07007431 tr_cd := tr_ChanDescH0(cd.chan_nr, fhp.arfcn);
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007432 }
7433
7434 if (not match(cd, tr_cd)) {
7435 setverdict(fail, "Channel Description IE does not match: ",
7436 cd, " vs expected ", tr_cd);
7437 }
7438}
7439
7440/* Make sure that the given Mobile Allocation IE matches the hopping configuration */
7441private function f_TC_fh_params_match_ma(in FHParamsTrx fhp, uint3_t tn,
7442 in MobileAllocationLV ma)
7443{
7444 var template MobileAllocationLV tr_ma := f_TC_fh_params_gen_tr_ma(fhp, tn, ma);
7445
7446 if (not match(ma, tr_ma)) {
7447 setverdict(fail, "Mobile Allocation IE does not match (tn := ",
7448 tn, "): ", ma, " vs expected: ", tr_ma);
7449 } else {
7450 setverdict(pass);
7451 }
7452}
7453
7454private function f_TC_fh_params_gen_tr_ma(in FHParamsTrx fhp, uint3_t tn,
7455 in MobileAllocationLV ma)
7456return template MobileAllocationLV {
7457 /* Mobile Allocation IE is expected to be empty if hopping is not enabled */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007458 if (not fhp.ts[tn].enabled) {
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007459 return { len := 0, ma := ''B };
7460 }
7461
7462 var bitstring full_mask := f_pad_bit(''B, 1024, '0'B);
7463 var bitstring slot_mask := f_pad_bit(''B, 1024, '0'B);
7464 var bitstring ma_mask := ''B;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007465
7466 /* Compose the full bit-mask (all channels, up to 1024 entries) */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007467 for (var integer i := 0; i < lengthof(fhp.ts); i := i + 1) {
7468 for (var integer j := 0; j < lengthof(fhp.ts[i].ma); j := j + 1) {
7469 if (full_mask[fhp.ts[i].ma[j]] == '1'B)
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007470 { continue; }
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007471 full_mask[fhp.ts[i].ma[j]] := '1'B;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007472 }
7473 }
7474
Vadim Yanitskiye7c8c6e2020-09-13 14:33:03 +07007475 /* Take ARFCN of the TRX itself into account */
7476 full_mask[fhp.arfcn] := '1'B;
7477
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007478 /* Compose a bit-mask for the given timeslot number */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007479 for (var integer i := 0; i < lengthof(fhp.ts[tn].ma); i := i + 1) {
7480 slot_mask[fhp.ts[tn].ma[i]] := '1'B;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007481 }
7482
7483 /* Finally, compose the Mobile Allocation bit-mask */
Vadim Yanitskiy3e997362020-09-05 21:08:34 +07007484 for (var integer i := 1; i < lengthof(full_mask); i := i + 1) {
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007485 if (full_mask[i] != '1'B)
7486 { continue; }
7487
7488 /* FIXME: ma_mask := ma_mask & slot_mask[i]; // triggers a bug in TITAN */
7489 if (slot_mask[i] == '1'B) {
7490 ma_mask := ma_mask & '1'B;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007491 } else {
7492 ma_mask := ma_mask & '0'B;
7493 }
7494 }
7495
Vadim Yanitskiy3e997362020-09-05 21:08:34 +07007496 /* ARFCN 0 (if present) goes to the last position of the bit-mask */
7497 if (full_mask[0] == '1'B) {
7498 /* FIXME: ma_mask := ma_mask & slot_mask[0]; // triggers a bug in TITAN */
7499 if (slot_mask[0] == '1'B) {
7500 ma_mask := ma_mask & '1'B;
7501 } else {
7502 ma_mask := ma_mask & '0'B;
7503 }
7504 }
7505
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007506 /* Ensure that ma_mask is octet-aligned */
Vadim Yanitskiy2aa02522020-09-06 14:05:23 +07007507 var integer ma_mask_len := (lengthof(ma_mask) + 8 - 1) / 8;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007508 ma_mask := f_pad_bit(ma_mask, ma_mask_len * 8, '0'B);
7509
7510 return { len := ma_mask_len, ma := ma_mask };
7511}
7512
7513/* Configure the hopping parameters in accordance with the given record */
7514private function f_TC_fh_params_set(in FHParamsTrx fhp,
7515 uint8_t bts_nr := 0,
7516 uint8_t trx_nr := 0)
7517runs on test_CT {
7518 /* Enter the configuration node for the given BTS/TRX numbers */
7519 f_vty_enter_cfg_trx(BSCVTY, bts_nr, trx_nr);
7520
Vadim Yanitskiye7c8c6e2020-09-13 14:33:03 +07007521 f_vty_transceive(BSCVTY, "arfcn " & int2str(fhp.arfcn));
7522
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007523 for (var integer tn := 0; tn < lengthof(fhp.ts); tn := tn + 1) {
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007524 f_vty_transceive(BSCVTY, "timeslot " & int2str(tn));
7525
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007526 if (not fhp.ts[tn].enabled) {
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007527 f_vty_transceive(BSCVTY, "hopping enabled 0");
7528 f_vty_transceive(BSCVTY, "exit"); /* go back */
7529 continue;
7530 }
7531
7532 /* Configure HSN / MAIO values */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007533 f_vty_transceive(BSCVTY, "hopping sequence-number " & int2str(fhp.ts[tn].hsn));
7534 f_vty_transceive(BSCVTY, "hopping maio " & int2str(fhp.ts[tn].maio));
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007535
7536 /* Configure the Mobile Allocation (hopping channels) */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007537 for (var integer i := 0; i < lengthof(fhp.ts[tn].ma); i := i + 1) {
7538 f_vty_transceive(BSCVTY, "hopping arfcn add " & int2str(fhp.ts[tn].ma[i]));
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007539 }
7540
7541 f_vty_transceive(BSCVTY, "hopping enabled 1");
7542 f_vty_transceive(BSCVTY, "exit"); /* go back */
7543 }
7544
7545 f_vty_transceive(BSCVTY, "end");
7546}
7547
7548/* Disable frequency hopping on all timeslots */
7549private function f_TC_fh_params_unset(in FHParamsTrx fhp,
7550 uint8_t bts_nr := 0,
Vadim Yanitskiye7c8c6e2020-09-13 14:33:03 +07007551 uint8_t trx_nr := 0,
7552 GsmArfcn arfcn := 871)
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007553runs on test_CT {
7554 /* Enter the configuration node for the given BTS/TRX numbers */
7555 f_vty_enter_cfg_trx(BSCVTY, bts_nr, trx_nr);
7556
Vadim Yanitskiye7c8c6e2020-09-13 14:33:03 +07007557 f_vty_transceive(BSCVTY, "arfcn " & int2str(arfcn));
7558
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007559 for (var integer tn := 0; tn < lengthof(fhp.ts); tn := tn + 1) {
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007560 f_vty_transceive(BSCVTY, "timeslot " & int2str(tn));
7561
7562 /* Delete all ARFCNs from the Mobile Allocation (if any) */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007563 for (var integer i := 0; i < lengthof(fhp.ts[tn].ma); i := i + 1) {
7564 f_vty_transceive(BSCVTY, "hopping arfcn del " & int2str(fhp.ts[tn].ma[i]));
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007565 }
7566
7567 f_vty_transceive(BSCVTY, "hopping enabled 0");
7568 f_vty_transceive(BSCVTY, "exit"); /* go back */
7569 }
7570
7571 f_vty_transceive(BSCVTY, "end");
7572 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
7573}
7574
7575/* Verify presence and correctness of the hopping parameters (HSN, MAIO)
7576 * in the Channel Identification IE of the RSL CHANnel ACTIVation message. */
7577testcase TC_fh_params_chan_activ() runs on test_CT {
7578 var FHParamsTrx fhp := f_TC_fh_params_gen();
7579 var RSL_Message rsl_msg;
7580 var RSL_IE_Body ie;
7581
7582 f_init_vty();
7583
7584 f_TC_fh_params_set(fhp); /* Enable frequency hopping */
7585 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
7586
7587 f_init(1);
7588
7589 /* CS domain: 3 (SDCCH/4+CBCH) + 4 (TCH/F) + 2 (TCH/H) channels available */
7590 for (var integer i := 0; i < 9; i := i + 1) {
7591 f_ipa_tx(0, ts_RSL_CHAN_RQD(f_rnd_ra_cs(), 23));
7592 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
7593
7594 /* Make sure that Channel Identification IE is present */
7595 if (not f_rsl_find_ie(rsl_msg, RSL_IE_CHAN_IDENT, ie)) {
7596 setverdict(fail, "RSL Channel Identification IE is absent");
7597 continue;
7598 }
7599
7600 /* Make sure that hopping parameters (HSN/MAIO) match */
7601 f_TC_fh_params_match_chan_desc(fhp, ie.chan_ident.ch_desc.v);
7602
7603 /* "Mobile Allocation shall be included but empty" - let's check this */
7604 if (ie.chan_ident.ma.v.len != 0) {
7605 setverdict(fail, "Mobile Allocation IE is not empty: ",
7606 ie.chan_ident.ma, ", despite it shall be");
7607 continue;
7608 }
7609 }
7610
7611 /* Disable frequency hopping */
7612 f_TC_fh_params_unset(fhp);
7613
Vadim Yanitskiy21726312020-09-04 01:45:36 +07007614 f_shutdown_helper();
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007615}
7616
7617/* Verify the hopping parameters (HSN, MAIO, MA) in (RR) Immediate Assignment */
7618testcase TC_fh_params_imm_ass() runs on test_CT {
7619 var FHParamsTrx fhp := f_TC_fh_params_gen();
7620 var RSL_Message rsl_msg;
7621 var RSL_IE_Body ie;
7622
7623 f_init_vty();
7624
7625 f_TC_fh_params_set(fhp); /* Enable frequency hopping */
7626 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
7627
7628 f_init(1);
7629
7630 /* CS domain: 3 (SDCCH/4+CBCH) + 4 (TCH/F) + 2 (TCH/H) channels available */
7631 for (var integer i := 0; i < 9; i := i + 1) {
7632 f_ipa_tx(0, ts_RSL_CHAN_RQD(f_rnd_ra_cs(), 23));
7633 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
7634
7635 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(rsl_msg.ies[0].body.chan_nr, 33));
7636 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeC(RSL_MT_IMMEDIATE_ASSIGN_CMD));
7637
7638 /* Make sure that Full Immediate Assign Info IE is present */
7639 if (not f_rsl_find_ie(rsl_msg, RSL_IE_FULL_IMM_ASS_INFO, ie)) {
7640 setverdict(fail, "RSL Full Immediate Assign Info IE is absent");
7641 continue;
7642 }
7643
7644 /* Decode the actual Immediate Assignment message */
7645 var GsmRrMessage rr_msg := dec_GsmRrMessage(ie.full_imm_ass_info.payload);
7646 if (not match(rr_msg.header, t_RrHeader(IMMEDIATE_ASSIGNMENT, ?))) {
7647 setverdict(fail, "Failed to match Immediate Assignment: ", rr_msg);
7648 continue;
7649 }
7650
7651 /* Make sure that hopping parameters (HSN/MAIO) match */
7652 f_TC_fh_params_match_chan_desc(fhp, rr_msg.payload.imm_ass.chan_desc);
7653
7654 /* Make sure that the Mobile Allocation IE matches */
7655 f_TC_fh_params_match_ma(fhp, rr_msg.payload.imm_ass.chan_desc.chan_nr.tn,
7656 rr_msg.payload.imm_ass.mobile_allocation);
7657 }
7658
7659 /* Disable frequency hopping */
7660 f_TC_fh_params_unset(fhp);
Philipp Maier82812002020-08-13 18:48:27 +02007661
Vadim Yanitskiy21726312020-09-04 01:45:36 +07007662 f_shutdown_helper();
Philipp Maier82812002020-08-13 18:48:27 +02007663}
7664
Vadim Yanitskiyaeb54a22020-09-01 06:25:25 +07007665/* Verify the hopping parameters (HSN, MAIO, MA) in (RR) Assignment Command */
7666testcase TC_fh_params_assignment_cmd() runs on test_CT {
7667 var FHParamsTrx fhp := f_TC_fh_params_gen();
7668 var RSL_Message rsl_msg;
7669 var RSL_IE_Body ie;
7670
7671 f_init_vty();
7672
7673 f_TC_fh_params_set(fhp); /* Enable frequency hopping */
7674 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
7675
7676 f_init(1);
7677
7678 /* HACK: work around "Couldn't find Expect for CRCX" */
7679 vc_MGCP.stop;
7680
7681 var template PDU_BSSAP ass_cmd := f_gen_ass_req();
7682 ass_cmd.pdu.bssmap.assignmentRequest.codecList := ts_BSSMAP_IE_CodecList({ts_CodecFR});
7683
7684 /* CS domain (TCH): 4 (TCH/F) + 2 (TCH/H) channels available
7685 * NOTE: only 3 SDCCH/4 channels are available on CCCH+SDCCH4+CBCH */
7686 for (var integer i := 0; i < 3; i := i + 1) {
7687 /* Establish a dedicated channel, so we can trigger (late) TCH assignment */
7688 var DchanTuple dt := f_est_dchan(f_rnd_ra_cs(), 23, f_rnd_octstring(16));
7689
7690 /* Send a BSSMAP Assignment Command, expect CHANnel ACTIVation */
7691 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ass_cmd));
7692 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
7693
7694 /* ACKnowledge CHANnel ACTIVation, expect RSL DATA REQuest */
7695 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(rsl_msg.ies[0].body.chan_nr, 33));
7696 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeR(RSL_MT_DATA_REQ));
7697
7698 /* Make sure that L3 Information IE is present */
7699 if (not f_rsl_find_ie(rsl_msg, RSL_IE_L3_INFO, ie)) {
7700 setverdict(fail, "RSL L3 Information IE is absent");
7701 continue;
7702 }
7703
7704 /* Decode the L3 message and make sure it is (RR) Assignment Command */
7705 var GsmRrL3Message l3_msg := dec_GsmRrL3Message(ie.l3_info.payload);
7706 if (not match(l3_msg.header, t_RrL3Header(ASSIGNMENT_COMMAND))) {
7707 setverdict(fail, "Failed to match Assignment Command: ", l3_msg);
7708 continue;
7709 }
7710
7711 /* Make sure that hopping parameters (HSN/MAIO) match */
7712 var ChannelDescription chan_desc := l3_msg.payload.ass_cmd.chan_desc;
7713 f_TC_fh_params_match_chan_desc(fhp, chan_desc);
7714
7715 /* Make sure that Cell Channel Description IE is present if FH is enabled */
7716 if (chan_desc.h and not ispresent(l3_msg.payload.ass_cmd.cell_chan_desc)) {
Vadim Yanitskiy38d069d2020-09-02 17:18:57 +07007717 setverdict(fail, "FH enabled, but Cell Channel Description IE is absent");
Vadim Yanitskiyaeb54a22020-09-01 06:25:25 +07007718 continue;
7719 }
7720
7721 /* Make sure that the Mobile Allocation IE matches (if present) */
7722 var boolean ma_present := ispresent(l3_msg.payload.ass_cmd.mobile_allocation);
7723 if (chan_desc.h and ma_present) {
7724 f_TC_fh_params_match_ma(fhp, chan_desc.chan_nr.tn,
7725 l3_msg.payload.ass_cmd.mobile_allocation.v);
7726 } else if (chan_desc.h and not ma_present) {
7727 setverdict(fail, "FH enabled, but Mobile Allocation IE is absent");
7728 continue;
7729 } else if (not chan_desc.h and ma_present) {
7730 setverdict(fail, "FH disabled, but Mobile Allocation IE is present");
7731 continue;
7732 }
7733 }
7734
7735 /* Give the IUT some time to release all channels */
7736 f_sleep(3.0);
7737
7738 /* Disable frequency hopping */
7739 f_TC_fh_params_unset(fhp);
7740
Vadim Yanitskiy21726312020-09-04 01:45:36 +07007741 f_shutdown_helper();
Vadim Yanitskiyaeb54a22020-09-01 06:25:25 +07007742}
7743
Vadim Yanitskiy8f5430d2020-09-02 18:51:38 +07007744/* Verify the hopping parameters (HSN, MAIO, MA) in (RR) Handover Command */
7745private function f_TC_fh_params_handover_cmd(in FHParamsTrx fhp)
7746runs on test_CT {
7747 var RSL_Message rsl_msg;
7748 var RSL_IE_Body ie;
7749 var DchanTuple dt;
7750
7751 /* Establish a dedicated channel, so we can trigger handover */
7752 dt := f_est_dchan(f_rnd_ra_cs(), 23, f_rnd_octstring(16));
7753
7754 /* Trigger handover from BTS0 to BTS1 */
7755 f_bts_0_cfg(BSCVTY, { "neighbor bts 1" });
7756 f_vty_handover(BSCVTY, 0, 0, dt.rsl_chan_nr, 1);
7757
7758 /* Expect RSL CHANnel ACTIVation on BTS1/TRX0/TS1 */
7759 rsl_msg := f_exp_ipa_rx(1, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
7760
7761 /* ACKnowledge channel activation and expect (RR) Handover Command */
7762 f_ipa_tx(1, ts_RSL_CHAN_ACT_ACK(rsl_msg.ies[0].body.chan_nr, 33));
7763 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeR(RSL_MT_DATA_REQ));
7764
7765 /* Make sure that L3 Information IE is present */
7766 if (not f_rsl_find_ie(rsl_msg, RSL_IE_L3_INFO, ie)) {
7767 setverdict(fail, "RSL L3 Information IE is absent");
7768 return;
7769 }
7770
7771 /* Decode the L3 message and make sure it is (RR) Handover Command */
7772 var GsmRrL3Message l3_msg := dec_GsmRrL3Message(ie.l3_info.payload);
7773 if (not match(l3_msg.header, t_RrL3Header(HANDOVER_COMMAND))) {
7774 setverdict(fail, "Failed to match Handover Command: ", l3_msg);
7775 return;
7776 }
7777
7778 /* Make sure that we've got SDCCH/8 on TS1 (expected to be hopping) */
7779 var ChannelDescription chan_desc := l3_msg.payload.ho_cmd.chan_desc;
7780 if (not match(chan_desc.chan_nr, t_RslChanNr_SDCCH8(1, ?))) {
7781 setverdict(fail, "Unexpected channel number: ", chan_desc.chan_nr);
7782 return;
7783 }
7784
7785 /* Make sure that hopping parameters (HSN/MAIO) match */
7786 f_TC_fh_params_match_chan_desc(fhp, chan_desc);
7787
7788 /* Make sure that Cell Channel Description IE is present */
7789 if (not ispresent(l3_msg.payload.ho_cmd.cell_chan_desc)) {
7790 setverdict(fail, "FH enabled, but Cell Channel Description IE is absent");
7791 return;
7792 }
7793
7794 /* Make sure that the Mobile Allocation (after time) IE is present and matches */
7795 var boolean ma_present := ispresent(l3_msg.payload.ho_cmd.mobile_allocation);
7796 if (ma_present) {
7797 f_TC_fh_params_match_ma(fhp, chan_desc.chan_nr.tn,
7798 l3_msg.payload.ho_cmd.mobile_allocation.v);
7799 } else {
7800 setverdict(fail, "FH enabled, but Mobile Allocation IE is absent");
7801 return;
7802 }
7803}
7804testcase TC_fh_params_handover_cmd() runs on test_CT {
7805 var FHParamsTrx fhp := f_TC_fh_params_gen();
7806
7807 f_init_vty();
7808
7809 /* (Re)configure TS0 as BCCH and TS1 as SDCCH8 on BTS1/TRX0 */
7810 f_vty_enter_cfg_trx(BSCVTY, bts := 1, trx := 0);
7811
7812 f_vty_transceive(BSCVTY, "timeslot 0");
7813 f_vty_transceive(BSCVTY, "phys_chan_config ccch");
7814 f_vty_transceive(BSCVTY, "exit"); /* go back */
7815
7816 f_vty_transceive(BSCVTY, "timeslot 1");
7817 f_vty_transceive(BSCVTY, "phys_chan_config sdcch8");
7818 f_vty_transceive(BSCVTY, "end"); /* we're done */
7819
7820 f_TC_fh_params_set(fhp, 1); /* Enable frequency hopping on BTS1 */
7821 f_vty_transceive(BSCVTY, "drop bts connection 1 oml");
7822
7823 f_init(2);
7824
7825 f_TC_fh_params_handover_cmd(fhp);
7826
7827 /* Disable frequency hopping on BTS1 */
7828 f_TC_fh_params_unset(fhp, 1);
7829
7830 /* (Re)configure TS0 as CCCH+SDCCH4+CBCH and TS1 as TCH/F */
7831 f_vty_enter_cfg_trx(BSCVTY, bts := 1, trx := 0);
7832
7833 f_vty_transceive(BSCVTY, "timeslot 0");
7834 f_vty_transceive(BSCVTY, "phys_chan_config ccch+sdcch4+cbch");
7835 f_vty_transceive(BSCVTY, "exit"); /* go back */
7836
7837 f_vty_transceive(BSCVTY, "timeslot 1");
7838 f_vty_transceive(BSCVTY, "phys_chan_config tch/f");
7839 f_vty_transceive(BSCVTY, "end"); /* we're done */
7840
7841 f_shutdown_helper();
7842}
7843
Vadim Yanitskiyca974032020-09-01 07:20:39 +07007844/* Verify the hopping parameters in System Information Type 4 */
7845testcase TC_fh_params_si4_cbch() runs on test_CT {
7846 var FHParamsTrx fhp := f_TC_fh_params_gen(tr_tn := 1);
7847 var ASP_RSL_Unitdata rx_rsl_ud;
7848 timer T := 5.0;
7849
7850 f_init_vty();
7851
7852 /* (Re)configure TS0 as BCCH and TS1 as SDCCH8+CBCH */
7853 f_vty_enter_cfg_trx(BSCVTY, trx := 0);
7854
7855 f_vty_transceive(BSCVTY, "timeslot 0");
7856 f_vty_transceive(BSCVTY, "phys_chan_config ccch");
7857 f_vty_transceive(BSCVTY, "exit"); /* go back */
7858
7859 f_vty_transceive(BSCVTY, "timeslot 1");
7860 f_vty_transceive(BSCVTY, "phys_chan_config sdcch8+cbch");
7861 f_vty_transceive(BSCVTY, "end"); /* we're done */
7862
7863 f_TC_fh_params_set(fhp); /* Enable frequency hopping */
7864 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
7865
7866 f_init(1);
7867
7868 T.start;
7869 alt {
7870 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_BCCH_INFO(RSL_SYSTEM_INFO_4))) -> value rx_rsl_ud {
7871 var RSL_IE_Body ie := rx_rsl_ud.rsl.ies[2].body; /* FULL BCCH Information IE */
7872 var SystemInformation si := dec_SystemInformation(ie.other.payload);
7873
7874 /* Make sure that what we decoded is System Information Type 4 */
7875 if (si.header.message_type != SYSTEM_INFORMATION_TYPE_4) {
7876 setverdict(fail, "RSL FULL BCCH Information IE contains: ", si);
7877 repeat;
7878 }
7879
7880 /* Make sure that CBCH Channel Description IE is present */
7881 if (not ispresent(si.payload.si4.cbch_chan_desc)) {
7882 setverdict(fail, "CBCH Channel Description IE is absent");
7883 break;
7884 }
7885
7886 /* Finally, check the hopping parameters (HSN, MAIO) */
7887 var ChannelDescription chan_desc := si.payload.si4.cbch_chan_desc.v;
7888 f_TC_fh_params_match_chan_desc(fhp, chan_desc);
7889
7890 /* 3GPP TS 44.018, section 9.1.36.2 "CBCH Mobile Allocation":
7891 * The CBCH Mobile Allocation IE *shall* be present if FH is enabled. */
7892 if (chan_desc.h and not ispresent(si.payload.si4.cbch_mobile_alloc)) {
7893 setverdict(fail, "FH enabled, but Mobile Allocation IE is absent");
7894 break;
7895 } else if (chan_desc.h and ispresent(si.payload.si4.cbch_mobile_alloc)) {
7896 f_TC_fh_params_match_ma(fhp, chan_desc.chan_nr.tn,
7897 si.payload.si4.cbch_mobile_alloc.v);
7898 }
7899 }
7900 [] IPA_RSL[0].receive { repeat; }
7901 [] T.timeout {
7902 setverdict(fail, "Timeout waiting for RSL BCCH INFOrmation (SI4)");
7903 }
7904 }
7905
7906 /* Disable frequency hopping */
7907 f_TC_fh_params_unset(fhp);
7908
Vadim Yanitskiy8bc46012020-09-06 12:38:01 +07007909 /* (Re)configure TS0 as CCCH+SDCCH4+CBCH and TS1 as TCH/F */
Vadim Yanitskiyca974032020-09-01 07:20:39 +07007910 f_vty_enter_cfg_trx(BSCVTY, trx := 0);
7911
7912 f_vty_transceive(BSCVTY, "timeslot 0");
Vadim Yanitskiy8bc46012020-09-06 12:38:01 +07007913 f_vty_transceive(BSCVTY, "phys_chan_config ccch+sdcch4+cbch");
Vadim Yanitskiyca974032020-09-01 07:20:39 +07007914 f_vty_transceive(BSCVTY, "exit"); /* go back */
7915
7916 f_vty_transceive(BSCVTY, "timeslot 1");
7917 f_vty_transceive(BSCVTY, "phys_chan_config tch/f");
7918 f_vty_transceive(BSCVTY, "end"); /* we're done */
7919
Vadim Yanitskiy21726312020-09-04 01:45:36 +07007920 f_shutdown_helper();
Vadim Yanitskiyca974032020-09-01 07:20:39 +07007921}
7922
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02007923template (value) PDU_BSSAP_LE ts_BSSMAP_LE_BSSLAP(template (value) BSSLAP_PDU bsslap)
7924 := ts_BSSMAP_LE_ConnInfo(BSSMAP_LE_PROT_BSSLAP, data := enc_BSSLAP_PDU(valueof(bsslap)));
7925
7926private function f_match_bsslap(PDU_BSSAP_LE got_bsslap_msg,
7927 template (present) BSSLAP_PDU expect_bsslap)
7928{
7929 var BSSLAP_PDU bsslap := dec_BSSLAP_PDU(got_bsslap_msg.pdu.bssmap.co_info.bsslap_apdu.data);
7930 if (not match(bsslap, expect_bsslap)) {
7931 log("EXPECTING BSSLAP: ", expect_bsslap);
7932 log("GOT BSSLAP: ", bsslap);
7933 setverdict(fail, "BSSLAP is not as expected");
7934 mtc.stop;
7935 }
7936 setverdict(pass);
7937}
7938
7939/* GAD: this is an Ellipsoid point with uncertainty circle, encoded as in 3GPP TS 23.032 §7.3.2. */
7940const octetstring gad_ell_point_unc_circle := '10b0646d0d5f6627'O;
7941
7942private function f_expect_bsslap(template (present) BSSLAP_PDU expect_rx_bsslap) runs on MSC_ConnHdlr {
7943 var PDU_BSSAP_LE rx_bsslap;
7944 BSSAP_LE.receive(tr_BSSMAP_LE_ConnInfo(BSSMAP_LE_PROT_BSSLAP, ?)) -> value(rx_bsslap);
7945 f_match_bsslap(rx_bsslap, expect_rx_bsslap);
7946}
7947
7948/* With an active lchan, start BSSMAP Perform Location Request on A interface, starting BSSMAP-LE Perform Location
7949 * Request on Lb interface. Either with or without the SMLC doing a BSSLAP TA Request. */
7950private function f_lcs_loc_req_for_active_ms(boolean do_ta_request := false) runs on MSC_ConnHdlr {
7951 f_sleep(1.0);
7952
7953 f_establish_fully(omit, omit);
7954 f_bssap_le_register_imsi(g_pars.imsi, omit);
7955
7956 BSSAP.send(valueof(ts_BSSMAP_Perform_Location_Request(ts_BSSMAP_Imsi(g_pars.imsi),
7957 ts_CellId_CGI('262'H, '42'H, 23, 42))));
7958
7959 var PDU_BSSAP_LE plr;
7960 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocReq(BSSMAP_LE_LOC_INFO_CURRENT_GEOGRAPHIC_LOC, ?, ?)) -> value(plr);
7961
7962 if (not do_ta_request) {
7963 /* verify TA Layer 3 in APDU. First the APDU type (BSSLAP), then the BSSLAP data contents. */
7964 var template BSSMAP_LE_IE_APDU expect_apdu := tr_BSSMAP_LE_APDU(BSSMAP_LE_PROT_BSSLAP, ?);
7965 if (not match(plr.pdu.bssmap.perf_loc_req.bsslap_apdu, expect_apdu)) {
7966 log("EXPECTING BSSMAP-LE APDU IE ", expect_apdu);
7967 log("GOT BSSMAP-LE APDU IE ", plr.pdu.bssmap.perf_loc_req.bsslap_apdu);
7968 setverdict(fail, "BSSMAP-LE APDU IE is not as expected");
7969 mtc.stop;
7970 }
7971 var template BSSLAP_PDU expect_ta_layer3 := tr_BSSLAP_TA_Layer3(tr_BSSLAP_IE_TA(0));
7972 var BSSLAP_PDU bsslap := dec_BSSLAP_PDU(plr.pdu.bssmap.perf_loc_req.bsslap_apdu.data);
7973 if (not match(bsslap, expect_ta_layer3)) {
7974 log("EXPECTING BSSLAP TA Layer 3: ", expect_ta_layer3);
7975 log("GOT BSSLAP: ", bsslap);
7976 setverdict(fail, "BSSLAP is not as expected");
7977 mtc.stop;
7978 }
7979 /* OsmoBSC directly sent the TA as BSSLAP APDU in the BSSMAP-LE Perform Location Request to the SMLC. The SMLC
7980 * has no need to request the TA from the BSC and directly responds. */
7981 } else {
7982 /* SMLC wants to ask the TA from the BSC explicitly in a BSSLAP TA Request message */
7983 BSSAP_LE.send(ts_BSSMAP_LE_BSSLAP(ts_BSSLAP_TA_Req));
7984 f_expect_bsslap(tr_BSSLAP_TA_Resp(?, ?));
7985 }
7986
7987 /* SMLC got the TA from the BSC, now responds with geo information data. */
7988 BSSAP_LE.send(ts_BSSMAP_LE_PerfLocResp(gad_ell_point_unc_circle, omit));
7989 BSSAP_LE.receive(BSSAP_LE_Conn_Prim:CONN_PRIM_DISC_IND);
7990 BSSAP.receive(tr_BSSMAP_Perform_Location_Response(tr_BSSMAP_IE_LocationEstimate(gad_ell_point_unc_circle)));
7991
7992 /* The LCS was using an active A-interface conn. It should still remain active after this. */
7993 f_mo_l3_transceive();
7994
7995 f_perform_clear(RSL);
7996
7997 f_sleep(2.0);
7998 setverdict(pass);
7999}
8000
8001/* With an active lchan, start BSSMAP Perform Location Request on A interface, starting BSSMAP-LE Perform Location
8002 * Request on Lb interface. Without the SMLC doing a BSSLAP TA Request. */
8003private function f_tc_lcs_loc_req_for_active_ms(charstring id) runs on MSC_ConnHdlr {
8004 f_lcs_loc_req_for_active_ms(false);
8005}
8006testcase TC_lcs_loc_req_for_active_ms() runs on test_CT {
8007 var MSC_ConnHdlr vc_conn;
8008 var TestHdlrParams pars := f_gen_test_hdlr_pars();
8009
8010 f_init(1, true);
8011 f_sleep(1.0);
8012 vc_conn := f_start_handler(refers(f_tc_lcs_loc_req_for_active_ms), pars);
8013 vc_conn.done;
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01008014 f_shutdown_helper();
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02008015}
8016
8017/* With an active lchan, start BSSMAP Perform Location Request on A interface, starting BSSMAP-LE Perform Location
8018 * Request on Lb interface. With the SMLC doing a BSSLAP TA Request. */
8019private function f_tc_lcs_loc_req_for_active_ms_ta_req(charstring id) runs on MSC_ConnHdlr {
8020 f_lcs_loc_req_for_active_ms(true);
8021}
8022testcase TC_lcs_loc_req_for_active_ms_ta_req() runs on test_CT {
8023 var MSC_ConnHdlr vc_conn;
8024 var TestHdlrParams pars := f_gen_test_hdlr_pars();
8025
8026 f_init(1, true);
8027 f_sleep(1.0);
8028 vc_conn := f_start_handler(refers(f_tc_lcs_loc_req_for_active_ms_ta_req), pars);
8029 vc_conn.done;
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01008030 f_shutdown_helper();
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02008031}
8032
8033/* Clear the A-interface conn only, without doing anything on Abis. Useful for LCS, for cases where there is only an A
8034 * conn without an active lchan. */
8035private function f_clear_A_conn() runs on MSC_ConnHdlr
8036{
8037 var BssmapCause cause := 0;
8038 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
8039 BSSAP.receive(tr_BSSMAP_ClearComplete);
8040 BSSAP.send(RAN_Conn_Prim:MSC_CONN_PRIM_DISC_REQ);
8041
8042 timer no_more_bssap := 5.0;
8043 no_more_bssap.start;
8044 alt {
8045 [] no_more_bssap.timeout { break; }
8046 [] BSSAP.receive(tr_BSSAP_BSSMAP) {
8047 setverdict(fail, "Expected no more BSSAP after Clear Complete");
8048 mtc.stop;
8049 }
8050 }
8051 setverdict(pass);
8052}
8053
8054/* Verify that the A-interface connection is still working, and then clear it, without doing anything on Abis. Useful
8055 * for LCS, for cases where there is only an A conn without an active lchan. */
8056private function f_verify_active_A_conn_and_clear() runs on MSC_ConnHdlr
8057{
8058 f_logp(BSCVTY, "f_verify_active_A_conn_and_clear: test A link, then clear");
8059
8060 /* When an lchan is active, we can send some L3 data from the BTS side and verify that it shows up on the other
8061 * side towards the MSC. When there is no lchan, this is not possible. To probe whether the A-interface
8062 * connection is still up, we need something that echos back on the A-interface. Another LCS request! */
8063 BSSAP.send(valueof(ts_BSSMAP_Perform_Location_Request(ts_BSSMAP_Imsi(g_pars.imsi),
8064 ts_CellId_CGI('262'H, '42'H, 23, 42))));
8065 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocReq(BSSMAP_LE_LOC_INFO_CURRENT_GEOGRAPHIC_LOC, ?, ?));
8066
8067 /* Right, the Perform Location Request showed up on Lb, now we can clear the A conn. */
8068 f_clear_A_conn();
8069 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocAbort(BSSMAP_LE_LCS_CAUSE_REQUEST_ABORTED));
8070 BSSAP_LE.receive(BSSAP_LE_Conn_Prim:CONN_PRIM_DISC_IND);
8071}
8072
8073/* With *no* active lchan, start BSSMAP Perform Location Request on A interface, starting BSSMAP-LE Perform Location
8074 * Request on Lb interface. BSC will Page for the subscriber as soon as we (virtual SMLC) request the TA via BSSLAP.
8075 */
8076private function f_tc_lcs_loc_req_for_idle_ms(charstring id) runs on MSC_ConnHdlr {
8077 f_sleep(1.0);
8078
8079 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
8080 f_bssap_le_register_imsi(g_pars.imsi, omit);
8081
8082 /* Register to receive the Paging Command */
8083 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
8084 g_chan_nr := new_chan_nr;
8085 f_rslem_register(0, g_chan_nr);
8086
8087 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
8088 valueof(ts_BSSMAP_Perform_Location_Request(ts_BSSMAP_Imsi(g_pars.imsi),
8089 ts_CellId_CGI('001'H, '01'H, 1, 0)))));
8090 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
8091
8092 var PDU_BSSAP_LE plr;
8093 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocReq(BSSMAP_LE_LOC_INFO_CURRENT_GEOGRAPHIC_LOC, ?, ?)) -> value(plr);
8094
8095 /* SMLC wants to ask the TA from the BSC explicitly in a BSSLAP TA Request message */
8096 BSSAP_LE.send(ts_BSSMAP_LE_BSSLAP(ts_BSSLAP_TA_Req));
8097
8098 /* OsmoBSC needs to Page */
8099 RSL.receive(tr_RSL_PAGING_CMD(tr_MI_IMSI(g_pars.imsi)));
8100 f_logp(BSCVTY, "got Paging Command");
8101
8102 /* MS requests channel. Since the Paging was for LCS, the Paging Response does not trigger a Complete Layer 3 to
8103 * the MSC, and releases the lchan directly. */
8104 f_perform_compl_l3(RSL, ts_PAG_RESP(valueof(ts_MI_IMSI_LV(g_pars.imsi))), do_clear := false, expect_bssmap_l3 := false);
8105 f_expect_lchan_rel(RSL);
8106
8107 /* From the Paging Response, the TA is now known to the BSC, and it responds to the SMLC. */
8108
8109 f_expect_bsslap(tr_BSSLAP_TA_Resp(?, ?));
8110
8111 /* SMLC got the TA from the BSC, now responds with geo information data. */
8112 BSSAP_LE.send(ts_BSSMAP_LE_PerfLocResp(gad_ell_point_unc_circle, omit));
8113 BSSAP_LE.receive(BSSAP_LE_Conn_Prim:CONN_PRIM_DISC_IND);
8114
8115 BSSAP.receive(tr_BSSMAP_Perform_Location_Response(tr_BSSMAP_IE_LocationEstimate(gad_ell_point_unc_circle)));
8116
8117 /* The lchan is gone, the A-interface conn was created for the LCS only.
8118 * Still it is clearly the MSC's job to decide whether to tear down the conn or not. */
8119 f_verify_active_A_conn_and_clear();
8120
8121 f_sleep(2.0);
8122 setverdict(pass);
8123}
8124testcase TC_lcs_loc_req_for_idle_ms() runs on test_CT {
8125 var MSC_ConnHdlr vc_conn;
8126 var TestHdlrParams pars := f_gen_test_hdlr_pars();
8127
8128 f_init(1, true);
8129 f_sleep(1.0);
8130
8131 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
8132 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
8133
8134 vc_conn := f_start_handler(refers(f_tc_lcs_loc_req_for_idle_ms), pars);
8135 vc_conn.done;
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01008136 f_shutdown_helper();
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02008137}
8138
8139/* With no active lchan, start BSSMAP Perform Location Request on A interface, but omit IMSI; expect failure response.
8140 */
8141private function f_tc_lcs_loc_req_no_subscriber(charstring id) runs on MSC_ConnHdlr {
8142 f_sleep(1.0);
8143
8144 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
8145 f_bssap_le_register_imsi(g_pars.imsi, omit);
8146
8147 /* provoke an abort by omitting both IMSI and IMEI */
8148 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
8149 valueof(ts_BSSMAP_Perform_Location_Request(omit,
8150 ts_CellId_CGI('262'H, '42'H, 23, 42)))));
8151 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
8152
8153 /* BSC tells MSC about failure */
8154 BSSAP.receive(tr_BSSMAP_Perform_Location_Response(
8155 locationEstimate := omit, positioningData := omit,
8156 lCS_Cause := tr_BSSMAP_LcsCause(BSSMAP_LCS_CAUSE_DATA_MISSING_IN_REQ)));
8157
8158 /* There is no lchan. Still the MSC's job to decide whether to tear down the conn or not. */
8159 f_verify_active_A_conn_and_clear();
8160
8161 f_sleep(2.0);
8162 setverdict(pass);
8163}
8164testcase TC_lcs_loc_req_no_subscriber() runs on test_CT {
8165 var MSC_ConnHdlr vc_conn;
8166 var TestHdlrParams pars := f_gen_test_hdlr_pars();
8167
8168 f_init(1, true);
8169 f_sleep(1.0);
8170
8171 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
8172 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
8173
8174 vc_conn := f_start_handler(refers(f_tc_lcs_loc_req_no_subscriber), pars);
8175 vc_conn.done;
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01008176 f_shutdown_helper();
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02008177}
8178
8179/* With an active lchan, start a Perform Location Request on the A-interface, but virtual SMLC does not answer with
8180 * BSSMAP-LE Perform Location Response (before or after sending a BSSLAP TA Request) */
8181private function f_lcs_loc_req_for_active_ms_le_timeout(boolean do_ta) runs on MSC_ConnHdlr {
8182 f_sleep(1.0);
8183
8184 f_establish_fully(omit, omit);
8185 f_bssap_le_register_imsi(g_pars.imsi, omit);
8186
8187 BSSAP.send(valueof(ts_BSSMAP_Perform_Location_Request(ts_BSSMAP_Imsi(g_pars.imsi),
8188 ts_CellId_CGI('262'H, '42'H, 23, 42))));
8189
8190 var PDU_BSSAP_LE plr;
8191 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocReq(BSSMAP_LE_LOC_INFO_CURRENT_GEOGRAPHIC_LOC, ?, ?)) -> value(plr);
8192
8193 if (do_ta) {
8194 /* SMLC wants to ask the TA from the BSC explicitly in a BSSLAP TA Request message */
8195 BSSAP_LE.send(ts_BSSMAP_LE_BSSLAP(ts_BSSLAP_TA_Req));
8196 f_expect_bsslap(tr_BSSLAP_TA_Resp(?, ?));
8197 }
8198
8199 /* SMLC fails to respond, BSC runs into timeout */
8200 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocAbort(BSSMAP_LE_LCS_CAUSE_SYSTEM_FAILURE));
8201 BSSAP_LE.receive(BSSAP_LE_Conn_Prim:CONN_PRIM_DISC_IND);
8202
8203 BSSAP.receive(tr_BSSMAP_Perform_Location_Response(
8204 locationEstimate := omit, positioningData := omit,
8205 lCS_Cause := tr_BSSMAP_LcsCause(BSSMAP_LCS_CAUSE_SYSTEM_FAILURE)));
8206
8207 /* There is no lchan. Still the MSC's job to decide whether to tear down the conn or not. */
8208 f_verify_active_A_conn_and_clear();
8209
8210 f_sleep(2.0);
8211 setverdict(pass);
8212}
8213
8214/* With an active lchan, start a Perform Location Request on the A-interface, but virtual SMLC does not answer with
8215 * BSSMAP-LE Perform Location Response, without sending a BSSLAP TA Request. */
8216private function f_tc_lcs_loc_req_for_active_ms_le_timeout(charstring id) runs on MSC_ConnHdlr {
8217 f_lcs_loc_req_for_active_ms_le_timeout(false);
8218}
8219
8220testcase TC_lcs_loc_req_for_active_ms_le_timeout() runs on test_CT {
8221 var MSC_ConnHdlr vc_conn;
8222 var TestHdlrParams pars := f_gen_test_hdlr_pars();
8223
8224 f_init(1, true);
8225 f_sleep(1.0);
8226 vc_conn := f_start_handler(refers(f_tc_lcs_loc_req_for_active_ms_le_timeout), pars);
8227 vc_conn.done;
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01008228 f_shutdown_helper();
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02008229}
8230
8231/* With an active lchan, start a Perform Location Request on the A-interface, but virtual SMLC does not answer with
8232 * BSSMAP-LE Perform Location Response, after sending a BSSLAP TA Request. */
8233private function f_tc_lcs_loc_req_for_active_ms_le_timeout2(charstring id) runs on MSC_ConnHdlr {
8234 f_lcs_loc_req_for_active_ms_le_timeout(true);
8235}
8236
8237testcase TC_lcs_loc_req_for_active_ms_le_timeout2() runs on test_CT {
8238 var MSC_ConnHdlr vc_conn;
8239 var TestHdlrParams pars := f_gen_test_hdlr_pars();
8240
8241 f_init(1, true);
8242 f_sleep(1.0);
8243 vc_conn := f_start_handler(refers(f_tc_lcs_loc_req_for_active_ms_le_timeout2), pars);
8244 vc_conn.done;
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01008245 f_shutdown_helper();
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02008246}
8247
8248/* With *no* active lchan, start a Perform Location Request, expecting that the MS will be Paged. */
8249private function f_tc_lcs_loc_req_for_idle_ms_no_pag_resp(charstring id) runs on MSC_ConnHdlr {
8250 f_sleep(1.0);
8251
8252 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
8253 f_bssap_le_register_imsi(g_pars.imsi, omit);
8254
8255 /* Register to receive the Paging Command */
8256 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
8257 g_chan_nr := new_chan_nr;
8258 f_rslem_register(0, g_chan_nr);
8259
8260 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
8261 valueof(ts_BSSMAP_Perform_Location_Request(ts_BSSMAP_Imsi(g_pars.imsi),
8262 ts_CellId_CGI('001'H, '01'H, 1, 0)))));
8263 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
8264
8265 var PDU_BSSAP_LE plr;
8266 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocReq(BSSMAP_LE_LOC_INFO_CURRENT_GEOGRAPHIC_LOC, ?, ?)) -> value(plr);
8267
8268 /* SMLC wants to ask the TA from the BSC explicitly in a BSSLAP TA Request message */
8269 BSSAP_LE.send(ts_BSSMAP_LE_BSSLAP(ts_BSSLAP_TA_Req));
8270
8271 /* OsmoBSC needs to Page */
8272 var PDU_BSSAP_LE rx_bsslap;
8273 alt {
8274 [] RSL.receive(tr_RSL_PAGING_CMD(tr_MI_IMSI(g_pars.imsi))) {
8275 f_logp(BSCVTY, "got Paging Command");
8276 repeat;
8277 }
8278 [] BSSAP_LE.receive(tr_BSSMAP_LE_ConnInfo(BSSMAP_LE_PROT_BSSLAP, ?)) -> value(rx_bsslap) {
8279 /* MS does not respond to Paging, TA Req runs into timeout. */
8280 f_match_bsslap(rx_bsslap, tr_BSSLAP_Abort(?));
8281 }
8282 }
8283
8284 /* SMLC responds with failure */
8285 BSSAP_LE.send(ts_BSSMAP_LE_PerfLocResp(omit, BSSMAP_LE_LCS_CAUSE_REQUEST_ABORTED));
8286 BSSAP_LE.receive(BSSAP_LE_Conn_Prim:CONN_PRIM_DISC_IND);
8287
8288 /* BSC tells MSC about failure */
8289 BSSAP.receive(tr_BSSMAP_Perform_Location_Response(
8290 locationEstimate := omit, positioningData := omit,
8291 lCS_Cause := tr_BSSMAP_LcsCause(BSSMAP_LCS_CAUSE_REQUEST_ABORTED)));
8292
8293 /* There is no lchan. Still the MSC's job to decide whether to tear down the conn or not. */
8294 f_verify_active_A_conn_and_clear();
8295
8296 f_sleep(2.0);
8297 setverdict(pass);
8298}
8299testcase TC_lcs_loc_req_for_idle_ms_no_pag_resp() runs on test_CT {
8300 var MSC_ConnHdlr vc_conn;
8301 var TestHdlrParams pars := f_gen_test_hdlr_pars();
8302
8303 f_init(1, true);
8304 f_sleep(1.0);
8305
8306 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
8307 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
8308
8309 vc_conn := f_start_handler(refers(f_tc_lcs_loc_req_for_idle_ms_no_pag_resp), pars);
8310 vc_conn.done;
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01008311 f_shutdown_helper();
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02008312}
8313
8314/* During an ongoing Location Request, the MS sends a CM Service Request. Expect the same A-conn to be re-used / taken
8315 * over. */
8316private function f_tc_cm_service_during_lcs_loc_req(charstring id) runs on MSC_ConnHdlr {
8317 f_sleep(1.0);
8318
8319 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
8320 f_bssap_le_register_imsi(g_pars.imsi, omit);
8321
8322 /* Register to receive the Paging Command */
8323 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
8324 g_chan_nr := new_chan_nr;
8325 f_rslem_register(0, g_chan_nr);
8326
8327 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
8328 valueof(ts_BSSMAP_Perform_Location_Request(ts_BSSMAP_Imsi(g_pars.imsi),
8329 ts_CellId_CGI('001'H, '01'H, 1, 0)))));
8330 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
8331
8332 var PDU_BSSAP_LE plr;
8333 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocReq(BSSMAP_LE_LOC_INFO_CURRENT_GEOGRAPHIC_LOC, ?, ?)) -> value(plr);
8334
8335 /* As the A-interface conn was established for LCS, the MS coincidentally decides to issue a CM Service Request
8336 * and establish Layer 3. It should use the existing A-interface conn. */
8337 f_perform_compl_l3(RSL, valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, valueof(ts_MI_IMSI_LV(g_pars.imsi)))),
8338 do_clear := false, expect_bssmap_l3 := true);
8339
8340 /* SMLC wants to ask the TA from the BSC explicitly in a BSSLAP TA Request message */
8341 BSSAP_LE.send(ts_BSSMAP_LE_BSSLAP(ts_BSSLAP_TA_Req));
8342
8343 /* OsmoBSC already has an lchan, no need to Page, just returns the TA */
8344 f_expect_bsslap(tr_BSSLAP_TA_Resp(?, ?));
8345
8346 /* SMLC got the TA from the BSC, now responds with geo information data. */
8347 BSSAP_LE.send(ts_BSSMAP_LE_PerfLocResp(gad_ell_point_unc_circle, omit));
8348 BSSAP_LE.receive(BSSAP_LE_Conn_Prim:CONN_PRIM_DISC_IND);
8349 BSSAP.receive(tr_BSSMAP_Perform_Location_Response(tr_BSSMAP_IE_LocationEstimate(gad_ell_point_unc_circle)));
8350
8351 /* The lchan should still exist, it was from a CM Service Request. */
8352 f_mo_l3_transceive();
8353
8354 f_perform_clear(RSL);
8355
8356 f_sleep(2.0);
8357 setverdict(pass);
8358}
8359testcase TC_cm_service_during_lcs_loc_req() runs on test_CT {
8360 var MSC_ConnHdlr vc_conn;
8361 var TestHdlrParams pars := f_gen_test_hdlr_pars();
8362
8363 f_init(1, true);
8364 f_sleep(1.0);
8365
8366 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
8367 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
8368
8369 vc_conn := f_start_handler(refers(f_tc_cm_service_during_lcs_loc_req), pars);
8370 vc_conn.done;
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01008371 f_shutdown_helper();
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02008372}
8373
8374/* During an ongoing Perform Location Request, do a Handover, an expect a BSSLAP Reset message from the BSC to indicate
8375 * the new lchan after handover. */
8376private function f_tc_ho_during_lcs_loc_req(charstring id) runs on MSC_ConnHdlr {
8377 f_sleep(1.0);
8378
8379 f_establish_fully(omit, omit);
8380 f_bssap_le_register_imsi(g_pars.imsi, omit);
8381
8382 BSSAP.send(valueof(ts_BSSMAP_Perform_Location_Request(ts_BSSMAP_Imsi(g_pars.imsi),
8383 ts_CellId_CGI('262'H, '42'H, 23, 42))));
8384
8385 var PDU_BSSAP_LE plr;
8386 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocReq(BSSMAP_LE_LOC_INFO_CURRENT_GEOGRAPHIC_LOC, ?, ?)) -> value(plr);
8387
8388 /* SMLC ponders the Location Request, in the meantime the BSC decides to handover */
8389 f_bts_0_cfg(BSCVTY, {"neighbor bts 1"});
8390
8391 var HandoverState hs := {
8392 rr_ho_cmpl_seen := false,
8393 handover_done := false,
8394 old_chan_nr := -
8395 };
8396 /* issue hand-over command on VTY */
8397 f_vty_handover(BSCVTY, 0, 0, g_chan_nr, 1);
8398 /* temporarily suspend DChan processing on BTS1 to avoid race with RSLEM_register */
8399 f_rslem_suspend(RSL1_PROC);
8400
8401 /* From the MGW perspective, a handover is is characterized by
8402 * performing one MDCX operation with the MGW. So we expect to see
8403 * one more MDCX during handover. */
8404 g_media.mgcp_conn[0].mdcx_seen_exp := g_media.mgcp_conn[0].crcx_seen_exp + 1;
8405
8406 alt {
8407 [] as_handover(hs);
8408 }
8409
8410 var PDU_BSSAP_LE rx_bsslap;
8411
8412 interleave {
8413 /* Expect the BSC to inform the MSC about the handover */
8414 [] BSSAP.receive(tr_BSSMAP_HandoverPerformed);
8415
8416 /* Expect the BSC to inform the SMLC about the handover */
8417 [] BSSAP_LE.receive(tr_BSSMAP_LE_ConnInfo(BSSMAP_LE_PROT_BSSLAP, ?)) -> value(rx_bsslap) {
8418 f_match_bsslap(rx_bsslap, tr_BSSLAP_Reset(BSSLAP_CAUSE_INTRA_BSS_HO));
8419 }
8420 }
8421
8422 /* SMLC now responds with geo information data. */
8423 BSSAP_LE.send(ts_BSSMAP_LE_PerfLocResp(gad_ell_point_unc_circle, omit));
8424 BSSAP_LE.receive(BSSAP_LE_Conn_Prim:CONN_PRIM_DISC_IND);
8425 BSSAP.receive(tr_BSSMAP_Perform_Location_Response(tr_BSSMAP_IE_LocationEstimate(gad_ell_point_unc_circle)));
8426
8427 /* lchan still active */
8428 f_mo_l3_transceive(RSL1);
8429
8430 /* MSC decides it is done now. */
8431 f_perform_clear(RSL1);
8432
8433 f_sleep(2.0);
8434 setverdict(pass);
8435}
8436testcase TC_ho_during_lcs_loc_req() runs on test_CT {
8437 var MSC_ConnHdlr vc_conn;
8438 var TestHdlrParams pars := f_gen_test_hdlr_pars();
8439
8440 f_init(2, true);
8441 f_sleep(1.0);
8442 vc_conn := f_start_handler(refers(f_tc_ho_during_lcs_loc_req), pars);
8443 vc_conn.done;
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01008444 f_shutdown_helper();
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02008445}
8446
Neels Hofmeyrbf037052020-10-28 22:52:02 +00008447/* Attempt Complete Layer 3 without any MSC available (OS#4832) */
8448private function f_tc_no_msc(charstring id) runs on MSC_ConnHdlr {
8449 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
8450
8451 /* Also disable attach for the single connected MSC */
8452 f_vty_msc_allow_attach(BSCVTY, { false });
8453
8454 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) ));
8455 f_chan_est(g_pars.ra, l3_enc, g_pars.link_id, g_pars.fn);
8456
8457 /* No MSC is found, expecting a proper release on RSL */
8458 interleave {
8459 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_RELEASE)) {
8460 f_logp(BSCVTY, "Got RSL RR Release");
8461 }
8462 [] RSL.receive(tr_RSL_DEACT_SACCH(g_chan_nr)) {
8463 f_logp(BSCVTY, "Got RSL Deact SACCH");
8464 }
8465 [] RSL.receive(tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL)) {
8466 f_logp(BSCVTY, "Got RSL RF Chan Rel, sending Rel Ack");
8467 RSL.send(ts_RSL_RF_CHAN_REL_ACK(g_chan_nr));
8468 }
8469 }
8470 setverdict(pass);
8471}
8472testcase TC_no_msc() runs on test_CT {
8473
8474 f_init(1, true);
8475 f_sleep(1.0);
8476 var MSC_ConnHdlr vc_conn;
8477 var TestHdlrParams pars := f_gen_test_hdlr_pars();
8478
8479 f_ctrs_bsc_init(counternames_bsc_mscpool);
8480
8481 vc_conn := f_start_handler(refers(f_tc_no_msc), pars);
8482 vc_conn.done;
8483
8484 f_ctrs_bsc_add("mscpool:subscr:no_msc");
8485 f_ctrs_bsc_verify();
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01008486 f_shutdown_helper();
Neels Hofmeyrbf037052020-10-28 22:52:02 +00008487}
8488
Harald Welte0ea2d5e2018-04-07 21:40:29 +02008489/* Dyn PDCH todo:
8490 * activate OSMO as TCH/F
8491 * activate OSMO as TCH/H
8492 * does the BSC-located PCU socket get the updated INFO?
8493 * what if no PCU is connected at the time?
8494 * is the info correct on delayed PCU (re)connect?
8495 */
Harald Welte94e0c342018-04-07 11:33:23 +02008496
Harald Welte28d943e2017-11-25 15:00:50 +01008497control {
Harald Welte898113b2018-01-31 18:32:21 +01008498 /* CTRL interface testing */
Harald Welte4003d112017-12-09 22:35:39 +01008499 execute( TC_ctrl_msc_connection_status() );
Stefan Sperlingb041b3d2018-01-03 17:14:55 +01008500 execute( TC_ctrl_msc0_connection_status() );
Harald Welte96c94412017-12-09 03:12:45 +01008501 execute( TC_ctrl() );
Neels Hofmeyrf246a922020-05-13 02:27:10 +02008502 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_SCCPlite_SERVER) {
Pau Espin Pedrol5a2d7432019-06-07 19:43:45 +02008503 execute( TC_ctrl_location() );
8504 }
Harald Welte898113b2018-01-31 18:32:21 +01008505
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +02008506 execute( TC_si_default() );
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02008507 execute( TC_si2quater_2_earfcns() );
8508 execute( TC_si2quater_3_earfcns() );
8509 execute( TC_si2quater_4_earfcns() );
8510 execute( TC_si2quater_5_earfcns() );
8511 execute( TC_si2quater_6_earfcns() );
Neels Hofmeyrad132f22020-07-08 02:20:16 +02008512 execute( TC_si2quater_12_earfcns() );
8513 execute( TC_si2quater_23_earfcns() );
8514 execute( TC_si2quater_32_earfcns() );
8515 execute( TC_si2quater_33_earfcns() );
8516 execute( TC_si2quater_42_earfcns() );
8517 execute( TC_si2quater_48_earfcns() );
8518 execute( TC_si2quater_49_earfcns() );
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02008519 execute( TC_si_acc_rotate() );
Alexander Couzens4ad3a352020-09-10 22:29:12 +02008520 execute( TC_si_acc_ramp_rotate() );
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +02008521
Harald Welte898113b2018-01-31 18:32:21 +01008522 /* RSL DCHAN Channel ACtivation / Deactivation */
Harald Welteae026692017-12-09 01:03:01 +01008523 execute( TC_chan_act_noreply() );
Harald Welte4003d112017-12-09 22:35:39 +01008524 execute( TC_chan_act_counter() );
Harald Welteae026692017-12-09 01:03:01 +01008525 execute( TC_chan_act_ack_noest() );
Philipp Maier9c60a622020-07-09 15:08:46 +02008526 execute( TC_chan_act_ack_noest_emerg() );
Philipp Maier606f07d2020-08-12 17:21:58 +02008527 execute( TC_chan_rqd_emerg_deny() );
Harald Welteae026692017-12-09 01:03:01 +01008528 execute( TC_chan_act_ack_est_ind_noreply() );
8529 execute( TC_chan_act_ack_est_ind_refused() );
Harald Welte618ef642017-12-14 14:58:20 +01008530 execute( TC_chan_act_nack() );
Harald Welte799c97b2017-12-14 17:50:30 +01008531 execute( TC_chan_exhaustion() );
Vadim Yanitskiy1ff1fdf2018-11-27 01:32:57 +07008532 execute( TC_chan_deact_silence() );
Harald Welte4003d112017-12-09 22:35:39 +01008533 execute( TC_chan_rel_rll_rel_ind() );
8534 execute( TC_chan_rel_conn_fail() );
8535 execute( TC_chan_rel_hard_clear() );
Pau Espin Pedrol841b90d2021-04-15 16:42:52 +02008536 execute( TC_chan_rel_last_eutran_plmn_hard_clear_no_csfb() );
8537 execute( TC_chan_rel_last_eutran_plmn_hard_clear_csfb() );
Harald Welte99787102019-02-04 10:41:36 +01008538 execute( TC_chan_rel_hard_clear_csfb() );
Harald Welted8c36cd2017-12-09 23:05:31 +01008539 execute( TC_chan_rel_hard_rlsd() );
Harald Welte550daf92018-06-11 19:22:13 +02008540 execute( TC_chan_rel_hard_rlsd_ms_dead() );
Harald Welte85804d42017-12-10 14:11:58 +01008541 execute( TC_chan_rel_a_reset() );
Pau Espin Pedrolc675b612020-01-09 19:55:40 +01008542 execute( TC_chan_rel_sccp_tiar_timeout() );
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02008543 execute( TC_chan_rel_rr_cause() );
Harald Welte6f521d82017-12-11 19:52:02 +01008544
Harald Weltecfe2c962017-12-15 12:09:32 +01008545 execute( TC_outbound_connect() );
Harald Welte898113b2018-01-31 18:32:21 +01008546
8547 /* Assignment related */
Harald Welte16a4adf2017-12-14 18:54:01 +01008548 execute( TC_assignment_cic_only() );
Harald Welte235ebf12017-12-15 14:18:16 +01008549 execute( TC_assignment_csd() );
8550 execute( TC_assignment_ctm() );
8551 execute( TC_assignment_sign() );
Pau Espin Pedrol07866632020-09-03 19:10:55 +02008552 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
8553 execute( TC_assignment_aoip_tla_v6() );
8554 }
Harald Welte235ebf12017-12-15 14:18:16 +01008555 execute( TC_assignment_fr_a5_0() );
8556 execute( TC_assignment_fr_a5_1() );
Neels Hofmeyrf246a922020-05-13 02:27:10 +02008557 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
Harald Welte8f67d1d2018-05-25 20:38:42 +02008558 execute( TC_assignment_fr_a5_1_codec_missing() );
8559 }
Harald Welte235ebf12017-12-15 14:18:16 +01008560 execute( TC_assignment_fr_a5_3() );
8561 execute( TC_assignment_fr_a5_4() );
Harald Welte3c86ea02018-05-10 22:28:05 +02008562 execute( TC_ciph_mode_a5_0() );
8563 execute( TC_ciph_mode_a5_1() );
8564 execute( TC_ciph_mode_a5_3() );
Harald Welte16a4adf2017-12-14 18:54:01 +01008565
Harald Welte60aa5762018-03-21 19:33:13 +01008566 execute( TC_assignment_codec_fr() );
8567 execute( TC_assignment_codec_hr() );
8568 execute( TC_assignment_codec_efr() );
8569 execute( TC_assignment_codec_amr_f() );
8570 execute( TC_assignment_codec_amr_h() );
Philipp Maier8a581d22019-03-26 18:32:48 +01008571
Neels Hofmeyrf246a922020-05-13 02:27:10 +02008572 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
Philipp Maier8a581d22019-03-26 18:32:48 +01008573 execute( TC_assignment_codec_amr_f_S1() );
8574 execute( TC_assignment_codec_amr_h_S1() );
8575 execute( TC_assignment_codec_amr_f_S124() );
8576 execute( TC_assignment_codec_amr_h_S124() );
8577 execute( TC_assignment_codec_amr_f_S0() );
8578 execute( TC_assignment_codec_amr_f_S02() );
8579 execute( TC_assignment_codec_amr_f_S024() );
8580 execute( TC_assignment_codec_amr_f_S0247() );
8581 execute( TC_assignment_codec_amr_h_S0() );
8582 execute( TC_assignment_codec_amr_h_S02() );
8583 execute( TC_assignment_codec_amr_h_S024() );
8584 execute( TC_assignment_codec_amr_h_S0247() );
8585 execute( TC_assignment_codec_amr_f_S01234567() );
8586 execute( TC_assignment_codec_amr_f_S0234567() );
8587 execute( TC_assignment_codec_amr_f_zero() );
8588 execute( TC_assignment_codec_amr_f_unsupp() );
8589 execute( TC_assignment_codec_amr_h_S7() );
Neels Hofmeyr21863562020-11-26 00:34:33 +00008590 execute( TC_assignment_codec_amr_f_start_mode_auto() );
8591 execute( TC_assignment_codec_amr_h_start_mode_auto() );
Neels Hofmeyr3eb94562020-11-26 02:40:26 +00008592 execute( TC_assignment_codec_amr_f_start_mode_4() );
8593 execute( TC_assignment_codec_amr_h_start_mode_4() );
Neels Hofmeyr454d7922020-11-26 02:24:57 +00008594 execute( TC_assignment_codec_amr_startmode_cruft() );
Philipp Maier8a581d22019-03-26 18:32:48 +01008595 }
Harald Welte60aa5762018-03-21 19:33:13 +01008596
Philipp Maierac09bfc2019-01-08 13:41:39 +01008597 execute( TC_assignment_codec_fr_exhausted_req_hr() );
8598 execute( TC_assignment_codec_fr_exhausted_req_fr() );
8599 execute( TC_assignment_codec_fr_exhausted_req_fr_hr() );
8600 execute( TC_assignment_codec_fr_exhausted_req_hr_fr() );
8601 execute( TC_assignment_codec_hr_exhausted_req_fr() );
8602 execute( TC_assignment_codec_hr_exhausted_req_hr() );
8603 execute( TC_assignment_codec_hr_exhausted_req_hr_fr() );
8604 execute( TC_assignment_codec_hr_exhausted_req_fr_hr() );
8605 execute( TC_assignment_codec_req_hr_fr() );
8606 execute( TC_assignment_codec_req_fr_hr() );
8607
Pau Espin Pedrol58cf6822019-05-28 18:11:33 +02008608 if (mp_enable_osmux_test) {
8609 execute( TC_assignment_osmux() );
8610 }
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02008611
Harald Welte898113b2018-01-31 18:32:21 +01008612 /* RLL Establish Indication on inactive DCHAN / SAPI */
Harald Welte5cd20ed2017-12-13 21:03:20 +01008613 execute( TC_rll_est_ind_inact_lchan() );
8614 execute( TC_rll_est_ind_inval_sapi1() );
8615 execute( TC_rll_est_ind_inval_sapi3() );
8616 execute( TC_rll_est_ind_inval_sacch() );
8617
Vadim Yanitskiy61f784a2020-10-01 21:12:19 +07008618 /* DLCI / RSL Link ID conversion for MO/MT messages on SAPI0/SAPI3 */
8619 execute( TC_tch_dlci_link_id_sapi() );
8620
Vadim Yanitskiy6ef5dfa2020-08-28 18:04:41 +07008621 /* SAPI N Reject triggered by RLL establishment failures */
8622 execute( TC_rll_rel_ind_sapi_n_reject() );
8623 execute( TC_rll_err_ind_sapi_n_reject() );
8624 execute( TC_rll_timeout_sapi_n_reject() );
8625
Harald Welte898113b2018-01-31 18:32:21 +01008626 /* Paging related tests */
Harald Welte6f521d82017-12-11 19:52:02 +01008627 execute( TC_paging_imsi_nochan() );
8628 execute( TC_paging_tmsi_nochan() );
8629 execute( TC_paging_tmsi_any() );
8630 execute( TC_paging_tmsi_sdcch() );
8631 execute( TC_paging_tmsi_tch_f() );
8632 execute( TC_paging_tmsi_tch_hf() );
8633 execute( TC_paging_imsi_nochan_cgi() );
8634 execute( TC_paging_imsi_nochan_lac_ci() );
8635 execute( TC_paging_imsi_nochan_ci() );
8636 execute( TC_paging_imsi_nochan_lai() );
8637 execute( TC_paging_imsi_nochan_lac() );
8638 execute( TC_paging_imsi_nochan_all() );
Harald Welte751d3eb2018-01-31 15:51:06 +01008639 execute( TC_paging_imsi_nochan_plmn_lac_rnc() );
8640 execute( TC_paging_imsi_nochan_rnc() );
8641 execute( TC_paging_imsi_nochan_lac_rnc() );
8642 execute( TC_paging_imsi_nochan_lacs() );
8643 execute( TC_paging_imsi_nochan_lacs_empty() );
Stefan Sperling049a86e2018-03-20 15:51:00 +01008644 execute( TC_paging_imsi_nochan_cgi_unknown_cid() );
Harald Welte10985002017-12-12 09:29:15 +01008645 execute( TC_paging_imsi_a_reset() );
Harald Weltee65d40e2017-12-13 00:09:06 +01008646 execute( TC_paging_imsi_load() );
Philipp Maier779a7922018-02-16 11:00:37 +01008647 execute( TC_paging_counter() );
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01008648 execute( TC_paging_resp_unsol() );
Harald Welte4e9b9cc2017-12-14 18:31:02 +01008649
8650 execute( TC_rsl_drop_counter() );
Stefan Sperling830dc9d2018-02-12 21:08:28 +01008651 execute( TC_rsl_unknown_unit_id() );
8652
8653 execute( TC_oml_unknown_unit_id() );
Harald Welte898113b2018-01-31 18:32:21 +01008654
8655 execute( TC_classmark() );
Harald Welteeddf0e92020-06-21 19:42:15 +02008656 execute( TC_common_id() );
Harald Welte898113b2018-01-31 18:32:21 +01008657 execute( TC_unsol_ass_fail() );
Harald Welteea99a002018-01-31 20:46:43 +01008658 execute( TC_unsol_ass_compl() );
Harald Weltefbf9b5e2018-01-31 20:41:23 +01008659 execute( TC_unsol_ho_fail() );
Harald Weltee3bd6582018-01-31 22:51:25 +01008660 execute( TC_err_82_short_msg() );
Harald Weltee9e02e42018-01-31 23:36:25 +01008661 execute( TC_err_84_unknown_msg() );
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01008662
Harald Welte261af4b2018-02-12 21:20:39 +01008663 execute( TC_ho_int() );
Neels Hofmeyr5f144212020-11-03 15:41:58 +00008664 execute( TC_ho_int_radio_link_failure() );
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01008665
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01008666 execute( TC_ho_out_of_this_bsc() );
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02008667 execute( TC_ho_out_fail_no_msc_response() );
8668 execute( TC_ho_out_fail_rr_ho_failure() );
Neels Hofmeyrd8a602c2019-07-09 19:46:01 +02008669 execute( TC_ho_out_fail_no_result_after_ho_cmd() );
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01008670
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01008671 execute( TC_ho_into_this_bsc() );
Pau Espin Pedrol07866632020-09-03 19:10:55 +02008672 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
8673 execute( TC_ho_into_this_bsc_tla_v6() );
8674 }
Pau Espin Pedrolc08d5522021-04-16 15:40:38 +02008675 execute( TC_srvcc_eutran_to_geran() );
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01008676 execute( TC_ho_in_fail_msc_clears() );
8677 execute( TC_ho_in_fail_msc_clears_after_ho_detect() );
8678 execute( TC_ho_in_fail_no_detect() );
8679 execute( TC_ho_in_fail_no_detect2() );
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01008680
Neels Hofmeyr91401012019-07-11 00:42:35 +02008681 execute( TC_ho_neighbor_config_1() );
8682 execute( TC_ho_neighbor_config_2() );
8683 execute( TC_ho_neighbor_config_3() );
8684 execute( TC_ho_neighbor_config_4() );
8685 execute( TC_ho_neighbor_config_5() );
8686 execute( TC_ho_neighbor_config_6() );
8687 execute( TC_ho_neighbor_config_7() );
8688
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01008689 execute( TC_bssap_rlsd_does_not_cause_bssmap_reset() );
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01008690 execute( TC_bssmap_clear_does_not_cause_bssmap_reset() );
Neels Hofmeyrfd445c32018-03-09 15:39:31 +01008691 execute( TC_ms_rel_ind_does_not_cause_bssmap_reset() );
Harald Welte94e0c342018-04-07 11:33:23 +02008692
8693 execute( TC_dyn_pdch_ipa_act_deact() );
8694 execute( TC_dyn_pdch_ipa_act_nack() );
8695 execute( TC_dyn_pdch_osmo_act_deact() );
8696 execute( TC_dyn_pdch_osmo_act_nack() );
Harald Welte99f3ca02018-06-14 13:40:29 +02008697
Stefan Sperling0796a822018-10-05 13:01:39 +02008698 execute( TC_chopped_ipa_ping() );
Stefan Sperlingaa1e60f2018-10-15 16:34:07 +02008699 execute( TC_chopped_ipa_payload() );
Stefan Sperling0796a822018-10-05 13:01:39 +02008700
Pau Espin Pedrol8f773632019-11-05 11:46:53 +01008701 /* Power control related */
8702 execute( TC_assignment_verify_ms_power_params_ie() );
Neels Hofmeyr4f118412020-06-04 15:25:10 +02008703
8704 /* MSC pooling */
8705 /* FIXME: in SCCPlite, indicating how many MSCs should be connected does currently not work. Since
8706 * RESET->RESET-ACK is unconditionally negotiated for all configured MSCs, they always all appear as connected
8707 * to osmo-bsc. The MSC pooling tests however require disconnecting selected MSCs, and hence don't work out as
8708 * intended on SCCPlite. So for now, run these only for SCCP/M3UA. */
8709 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
8710 execute( TC_mscpool_L3Compl_on_1_msc() );
8711 execute( TC_mscpool_L3Complete_by_imsi_round_robin() );
8712 execute( TC_mscpool_LU_by_tmsi_null_nri_0_round_robin() );
8713 execute( TC_mscpool_LU_by_tmsi_null_nri_1_round_robin() );
8714 execute( TC_mscpool_L3Complete_by_tmsi_unassigned_nri_round_robin() );
8715 execute( TC_mscpool_L3Complete_by_tmsi_valid_nri_msc_not_connected_round_robin() );
8716 execute( TC_mscpool_L3Complete_by_tmsi_valid_nri_1() );
8717 execute( TC_mscpool_L3Complete_by_tmsi_valid_nri_2() );
8718 execute( TC_mscpool_LU_by_tmsi_from_other_PLMN() );
8719 execute( TC_mscpool_paging_and_response_imsi() );
8720 execute( TC_mscpool_paging_and_response_tmsi() );
8721 execute( TC_mscpool_no_allow_attach_round_robin() );
8722 execute( TC_mscpool_no_allow_attach_valid_nri() );
8723 }
8724
Harald Welte99f3ca02018-06-14 13:40:29 +02008725 /* at bottom as they might crash OsmoBSC before OS#3182 is fixed */
8726 execute( TC_early_conn_fail() );
8727 execute( TC_late_conn_fail() );
8728
Philipp Maier783681c2020-07-16 16:47:06 +02008729 /* Emergency call handling (deny / allow) */
8730 execute( TC_assignment_emerg_setup_allow() );
8731 execute( TC_assignment_emerg_setup_deny_msc() );
8732 execute( TC_assignment_emerg_setup_deny_bts() );
Philipp Maier82812002020-08-13 18:48:27 +02008733 execute( TC_emerg_premption() );
8734
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008735 /* Frequency hopping parameters handling */
8736 execute( TC_fh_params_chan_activ() );
8737 execute( TC_fh_params_imm_ass() );
Vadim Yanitskiyaeb54a22020-09-01 06:25:25 +07008738 execute( TC_fh_params_assignment_cmd() );
Vadim Yanitskiy8f5430d2020-09-02 18:51:38 +07008739 execute( TC_fh_params_handover_cmd() );
Vadim Yanitskiyca974032020-09-01 07:20:39 +07008740 execute( TC_fh_params_si4_cbch() );
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02008741
8742 if (mp_enable_lcs_tests) {
8743 execute( TC_lcs_loc_req_for_active_ms() );
8744 execute( TC_lcs_loc_req_for_active_ms_ta_req() );
8745 execute( TC_lcs_loc_req_for_idle_ms() );
8746 execute( TC_lcs_loc_req_no_subscriber() );
8747 execute( TC_lcs_loc_req_for_active_ms_le_timeout() );
8748 execute( TC_lcs_loc_req_for_active_ms_le_timeout2() );
8749 execute( TC_lcs_loc_req_for_idle_ms_no_pag_resp() );
8750 execute( TC_cm_service_during_lcs_loc_req() );
8751 execute( TC_ho_during_lcs_loc_req() );
8752 }
Neels Hofmeyrbf037052020-10-28 22:52:02 +00008753
8754 execute( TC_no_msc() );
Harald Welte28d943e2017-11-25 15:00:50 +01008755}
8756
8757}