blob: 8adf113ec798d6aa70c9a70d219361febfc8ed63 [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;
Harald Welteae026692017-12-09 01:03:01 +010033import from BSSAP_CodecPort all;
34import from BSSMAP_Templates all;
Harald Welte28d943e2017-11-25 15:00:50 +010035import from IPA_Emulation all;
Stefan Sperling830dc9d2018-02-12 21:08:28 +010036import from IPA_CodecPort all;
Harald Welteae026692017-12-09 01:03:01 +010037import from IPA_Types all;
Stefan Sperling0796a822018-10-05 13:01:39 +020038import from IPA_Testing all;
Harald Welteae026692017-12-09 01:03:01 +010039import from RSL_Types all;
Harald Welte624f9632017-12-16 19:26:04 +010040import from RSL_Emulation all;
Daniel Willmann191e0d92018-01-17 12:44:35 +010041import from MGCP_Emulation all;
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +010042import from MGCP_Templates all;
43import from MGCP_Types all;
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +020044import from MGCP_CodecPort all;
Harald Welte28d943e2017-11-25 15:00:50 +010045
Harald Welte96c94412017-12-09 03:12:45 +010046import from Osmocom_CTRL_Functions all;
Harald Weltea5d2ab22017-12-09 14:21:42 +010047import from Osmocom_CTRL_Types all;
Harald Welteffe55fc2018-01-17 22:39:54 +010048import from Osmocom_CTRL_Adapter all;
Harald Welte96c94412017-12-09 03:12:45 +010049
Daniel Willmannebdecc02020-08-12 15:30:17 +020050import from StatsD_Types all;
51import from StatsD_CodecPort all;
52import from StatsD_CodecPort_CtrlFunct all;
53import from StatsD_Checker all;
54
Harald Weltebc03c762018-02-12 18:09:38 +010055import from Osmocom_VTY_Functions all;
56import from TELNETasp_PortType all;
57
Harald Welte6f521d82017-12-11 19:52:02 +010058import from MobileL3_CommonIE_Types all;
Harald Weltee3bd6582018-01-31 22:51:25 +010059import from MobileL3_Types all;
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +010060import from MobileL3_RRM_Types all;
Harald Welte6f521d82017-12-11 19:52:02 +010061import from L3_Templates all;
62import from GSM_RR_Types all;
63
Stefan Sperlingc307e682018-06-14 15:15:46 +020064import from SCCP_Templates all;
Neels Hofmeyr4ff93282018-03-12 04:25:35 +010065import from BSSMAP_Templates all;
66
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +010067import from SCCPasp_Types all;
68
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +020069import from GSM_SystemInformation all;
70import from GSM_RestOctets all;
Neels Hofmeyrad132f22020-07-08 02:20:16 +020071import from TCCConversion_Functions all;
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +020072
Harald Welte5d1a2202017-12-13 19:51:29 +010073const integer NUM_BTS := 3;
Neels Hofmeyrf246a922020-05-13 02:27:10 +020074const integer NUM_MSC := 3;
Harald Welteae026692017-12-09 01:03:01 +010075const float T3101_MAX := 12.0;
Harald Welte28d943e2017-11-25 15:00:50 +010076
Harald Welte799c97b2017-12-14 17:50:30 +010077/* make sure to sync this with the osmo-bts.cfg you're using */
Philipp Maiercb6cc482018-03-26 13:08:00 +020078const integer NUM_TCHH_PER_BTS := 2;
79const integer NUM_TCHF_PER_BTS := 4;
Neels Hofmeyr74083c22020-07-29 00:43:01 +020080const integer NUM_SDCCH_PER_BTS := 3;
Harald Welte799c97b2017-12-14 17:50:30 +010081
Harald Welte4003d112017-12-09 22:35:39 +010082
Harald Welte21b46bd2017-12-17 19:46:32 +010083/* per-BTS state which we keep */
Harald Welte96c94412017-12-09 03:12:45 +010084type record BTS_State {
Harald Welte21b46bd2017-12-17 19:46:32 +010085 /* component reference to the IPA_Client component used for RSL */
Harald Weltea5d2ab22017-12-09 14:21:42 +010086 IPA_Client rsl
Harald Welte96c94412017-12-09 03:12:45 +010087}
88
Neels Hofmeyr22c3f792020-06-17 02:49:28 +020089/* Default list of counters for an 'msc' entity. */
90const CounterNameVals counternames_msc_mscpool := {
91 { "mscpool:subscr:new", 0 },
92 { "mscpool:subscr:known", 0 },
93 { "mscpool:subscr:reattach", 0 },
94 { "mscpool:subscr:attach_lost", 0 },
95 { "mscpool:subscr:paged", 0 }
96};
97
Neels Hofmeyr12941bd2020-08-29 03:21:26 +000098/* Default list of counters for 'bsc' and 'bts' entities. */
99const CounterNameVals counternames_bsc_bts_handover := {
100 { "assignment:attempted", 0 },
101 { "assignment:completed", 0 },
102 { "assignment:stopped", 0 },
103 { "assignment:no_channel", 0 },
104 { "assignment:timeout", 0 },
105 { "assignment:failed", 0 },
106 { "assignment:error", 0 },
107
108 { "handover:attempted", 0 },
109 { "handover:completed", 0 },
110 { "handover:stopped", 0 },
111 { "handover:no_channel", 0 },
112 { "handover:timeout", 0 },
113 { "handover:failed", 0 },
114 { "handover:error", 0 },
115
116 { "intra_cell_ho:attempted", 0 },
117 { "intra_cell_ho:completed", 0 },
118 { "intra_cell_ho:stopped", 0 },
119 { "intra_cell_ho:no_channel", 0 },
120 { "intra_cell_ho:timeout", 0 },
121 { "intra_cell_ho:failed", 0 },
122 { "intra_cell_ho:error", 0 },
123
124 { "intra_bsc_ho:attempted", 0 },
125 { "intra_bsc_ho:completed", 0 },
126 { "intra_bsc_ho:stopped", 0 },
127 { "intra_bsc_ho:no_channel", 0 },
128 { "intra_bsc_ho:timeout", 0 },
129 { "intra_bsc_ho:failed", 0 },
130 { "intra_bsc_ho:error", 0 },
131
132 { "interbsc_ho_out:attempted", 0 },
133 { "interbsc_ho_out:completed", 0 },
134 { "interbsc_ho_out:stopped", 0 },
135 { "interbsc_ho_out:timeout", 0 },
136 { "interbsc_ho_out:failed", 0 },
137 { "interbsc_ho_out:error", 0 },
138
139 { "interbsc_ho_in:attempted", 0 },
140 { "interbsc_ho_in:completed", 0 },
141 { "interbsc_ho_in:stopped", 0 },
142 { "interbsc_ho_in:no_channel", 0 },
143 { "interbsc_ho_in:timeout", 0 },
144 { "interbsc_ho_in:failed", 0 },
145 { "interbsc_ho_in:error", 0 }
146};
147
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +0200148/* Set of all System Information received during one RSL port's startup.
149 * Note that some System Information may be sent on RSL, but lacking actual SI data, to indicate that the BTS should not
150 * broadcast that SI type. That will be reflected as 'omit' here.
151 */
152type record SystemInformationConfig {
153 SystemInformationType1 si1 optional,
154 SystemInformationType2 si2 optional,
155 SystemInformationType2bis si2bis optional,
156 SystemInformationType2ter si2ter optional,
Neels Hofmeyrad132f22020-07-08 02:20:16 +0200157 SI2quaterRestOctetsList si2quater optional,
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +0200158 SystemInformationType3 si3 optional,
159 SystemInformationType4 si4 optional,
160 /* TODO: replace with proper decoding of SI13, implement SI13 in GSM_SystemInformation.ttcn */
161 octetstring si13 optional,
162 SystemInformationType5 si5 optional,
163 SystemInformationType5bis si5bis optional,
164 SystemInformationType5ter si5ter optional,
165 SystemInformationType6 si6 optional
166};
167
168const SystemInformationConfig SystemInformationConfig_omit := {
169 si1 := omit,
170 si2 := omit,
171 si2bis := omit,
172 si2ter := omit,
173 si2quater := omit,
174 si3 := omit,
175 si4 := omit,
176 si13 := omit,
177 si5 := omit,
178 si5bis := omit,
179 si5ter := omit,
180 si6 := omit
181};
182
183/* tr_EUTRAN_CellDesc with defaults used in BSC_Tests.ttcn */
184template EUTRAN_CellDesc tr_EUTRAN_CellDesc_default(template (present) uint16_t e_arfcn := ?,
185 template uint3_t meas_bw := 3)
186:= tr_EUTRAN_CellDesc(e_arfcn := e_arfcn,
187 meas_bw_presence := '1'B,
188 meas_bw := meas_bw);
189
190/* tr_EUTRAN_NeighbourCells with defaults used in BSC_Tests.ttcn */
Harald Welte65e419a2020-08-21 12:38:33 +0200191template EUTRAN_NeighbourCells tr_EUTRAN_NeighbourCells_default(template (present) EUTRAN_CellDescs cell_desc_list := { tr_EUTRAN_CellDesc_default },
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +0200192 template uint3_t prio := 3,
193 template (present) uint5_t thresh_high := 20,
194 template uint5_t thresh_low := 10,
195 template uint5_t qrxlevmin := 22)
196:= tr_EUTRAN_NeighbourCells(
197 cell_desc_list := cell_desc_list,
198 prio_presence := '1'B,
199 prio := prio,
200 thresh_high := thresh_high,
201 thresh_low_presence := '1'B,
202 thresh_low := thresh_low,
203 qrxlevmin_presence := '1'B,
204 qrxlevmin := qrxlevmin);
205
206template SystemInformationConfig SystemInformationConfig_default := {
207 si1 := {
208 cell_chan_desc := '8FB38000000000000000000000000000'O,
209 rach_control := {
210 max_retrans := RACH_MAX_RETRANS_7,
211 tx_integer := '1001'B,
212 cell_barr_access := false,
213 re_not_allowed := true,
214 acc := '0000010000000000'B
215 },
216 rest_octets := ?
217 },
218 si2 := {
219 bcch_freq_list := '00000000000000000000000000000000'O,
220 ncc_permitted := '11111111'B,
221 rach_control := {
222 max_retrans := RACH_MAX_RETRANS_7,
223 tx_integer := '1001'B,
224 cell_barr_access := false,
225 re_not_allowed := true,
226 acc := '0000010000000000'B
227 }
228 },
229 si2bis := omit,
230 si2ter := {
231 extd_bcch_freq_list := '8E320000000000000000000000000800'O,
232 rest_octets := ?
233 },
234 si2quater := {
235 tr_SI2quaterRestOctets_EUTRAN( repeated_neigh_cells := { tr_EUTRAN_NeighbourCells_default } )
236 },
237 si3 := {
238 cell_id := 0,
239 lai := {
240 mcc_mnc := '001F01'H,
241 lac := 1
242 },
243 ctrl_chan_desc := {
244 msc_r99 := true,
245 att := true,
246 bs_ag_blks_res := 1,
247 ccch_conf := CCHAN_DESC_1CCCH_COMBINED,
248 si22ind := false,
249 cbq3 := CBQ3_IU_MODE_NOT_SUPPORTED,
250 spare := '00'B,
251 bs_pa_mfrms := 3,
252 t3212 := 30
253 },
254 cell_options := {
255 dn_ind := false,
256 pwrc := false,
257 dtx := MS_SHALL_USE_UL_DTX,
258 radio_link_tout_div4 := 7
259 },
260 cell_sel_par := {
261 cell_resel_hyst_2dB := 2,
262 ms_txpwr_max_cch := 7,
263 acs := '0'B,
264 neci := true,
265 rxlev_access_min := 0
266 },
267 rach_control := {
268 max_retrans := RACH_MAX_RETRANS_7,
269 tx_integer := '1001'B,
270 cell_barr_access := false,
271 re_not_allowed := true,
272 acc := '0000010000000000'B
273 },
274 rest_octets := {
275 sel_params := {
276 presence := '0'B,
277 params := omit
278 },
279 pwr_offset := {
280 presence := '0'B,
281 offset := omit
282 },
283 si_2ter_ind := '1'B,
284 early_cm_ind := '0'B,
285 sched_where := {
286 presence := '0'B,
287 where := omit
288 },
289 gprs_ind := {
290 presence := '1'B,
291 ind := {
292 ra_colour := 0,
293 si13_pos := '0'B
294 }
295 },
296 umts_early_cm_ind := '1'B,
297 si2_quater_ind := {
298 presence := '1'B,
299 ind := '0'B
300 },
301 iu_mode_ind := omit,
302 si21_ind := {
303 presence := '0'B,
304 pos := omit
305 }
306 }
307 },
308 si4 := {
309 lai := {
310 mcc_mnc := '001F01'H,
311 lac := 1
312 },
313 cell_sel_par := {
314 cell_resel_hyst_2dB := 2,
315 ms_txpwr_max_cch := 7,
316 acs := '0'B,
317 neci := true,
318 rxlev_access_min := 0
319 },
320 rach_control := {
321 max_retrans := RACH_MAX_RETRANS_7,
322 tx_integer := '1001'B,
323 cell_barr_access := false,
324 re_not_allowed := true,
325 acc := '0000010000000000'B
326 },
Neels Hofmeyr74083c22020-07-29 00:43:01 +0200327 cbch_chan_desc := {
328 iei := '64'O,
329 v := {
330 chan_nr := {
331 u := {
332 sdcch4 := {
333 tag := '001'B,
334 sub_chan := 2
335 }
336 },
337 tn := 0
338 },
339 tsc := 2,
340 h := false,
341 arfcn := 871,
342 maio_hsn := omit
343 }
344 },
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +0200345 cbch_mobile_alloc := omit,
346 rest_octets := {
347 sel_params := {
348 presence := '0'B,
349 params := omit
350 },
351 pwr_offset := {
352 presence := '0'B,
353 offset := omit
354 },
355 gprs_ind := {
356 presence := '1'B,
357 ind := {
358 ra_colour := 0,
359 si13_pos := '0'B
360 }
361 },
362 s_presence := '0'B,
363 s := omit
364 }
365 },
366 si13 := '9000185A6FC9E08410AB2B2B2B2B2B2B2B2B2B2B'O,
367 si5 := {
368 bcch_freq_list := '10000000000000000000000000000000'O
369 },
370 si5bis := omit,
371 si5ter := {
372 extd_bcch_freq_list := '9E050020000000000000000000000000'O
373 },
374 si6 := {
375 cell_id := 0,
376 lai := {
377 mcc_mnc := '001F01'H,
378 lac := 1
379 },
380 cell_options := {
381 dtx_ext := '1'B,
382 pwrc := false,
383 dtx := '01'B,
384 radio_link_timeout := '0111'B
385 },
386 ncc_permitted := '11111111'B,
387 rest_octets := ?
388 }
389 };
390
391
392/* List of all the System Information received on all RSL ports */
393type record of SystemInformationConfig SystemInformationConfig_list;
394
395function f_sysinfo_dec_raw(inout SystemInformationConfig si, RSL_Message rsl)
396{
397 var RSL_IE_Body sysinfo_type_ie;
398 var RSL_IE_SysinfoType si_type;
399 var octetstring data;
400
401 if (f_rsl_find_ie(rsl, RSL_IE_SYSINFO_TYPE, sysinfo_type_ie) == false) {
402 setverdict(fail, "Cannot find RSL_IE_SYSINFO_TYPE");
403 mtc.stop;
404 }
405 si_type := sysinfo_type_ie.sysinfo_type;
406
407 if (rsl.msg_type == RSL_MT_BCCH_INFO) {
408 var RSL_IE_Body bcch_ie;
409 if (f_rsl_find_ie(rsl, RSL_IE_FULL_BCCH_INFO, bcch_ie)) {
410 data := bcch_ie.other.payload;
411 }
412 } else if (rsl.msg_type == RSL_MT_SACCH_FILL) {
413 var RSL_IE_Body l3_ie;
414 if (f_rsl_find_ie(rsl, RSL_IE_L3_INFO, l3_ie)) {
415 data := l3_ie.l3_info.payload;
416 }
417 } else {
418 setverdict(fail, "Don't understand this System Information message");
419 mtc.stop;
420 }
421
422 var boolean handled := false;
423
424 if (rsl.msg_type == RSL_MT_BCCH_INFO) {
425 handled := true;
426
427 if (si_type == RSL_SYSTEM_INFO_1) {
428 if (not isbound(data)) {
429 si.si1 := omit;
430 } else {
431 si.si1 := dec_SystemInformation(data).payload.si1;
432 }
433 } else if (si_type == RSL_SYSTEM_INFO_2) {
434 if (not isbound(data)) {
435 si.si2 := omit;
436 } else {
437 si.si2 := dec_SystemInformation(data).payload.si2;
438 }
439 } else if (si_type == RSL_SYSTEM_INFO_2bis) {
440 if (not isbound(data)) {
441 si.si2bis := omit;
442 } else {
443 si.si2bis := dec_SystemInformation(data).payload.si2bis;
444 }
445 } else if (si_type == RSL_SYSTEM_INFO_2ter) {
446 if (not isbound(data)) {
447 si.si2ter := omit;
448 } else {
449 si.si2ter := dec_SystemInformation(data).payload.si2ter;
450 }
451 } else if (si_type == RSL_SYSTEM_INFO_2quater) {
452 if (not isbound(data)) {
453 si.si2quater := {};
454 } else {
455 var SystemInformationType2quater decoded := dec_SystemInformation(data).payload.si2quater;
456 /* this is a *record* of SI2quaterRestOctets! (multiplexed) */
457 si.si2quater[decoded.rest_octets.si2quater_index] := decoded.rest_octets;
458 }
459 } else if (si_type == RSL_SYSTEM_INFO_3) {
460 if (not isbound(data)) {
461 si.si3 := omit;
462 } else {
463 si.si3 := dec_SystemInformation(data).payload.si3;
464 }
465 } else if (si_type == RSL_SYSTEM_INFO_4) {
466 if (not isbound(data)) {
467 si.si4 := omit;
468 } else {
469 si.si4 := dec_SystemInformation(data).payload.si4;
470 }
471 } else if (si_type == RSL_SYSTEM_INFO_13) {
472 if (not isbound(data)) {
473 si.si13 := omit;
474 } else {
475 si.si13 := dec_SystemInformation(data).payload.other;
476 }
477 } else {
478 handled := false;
479 }
480 } else if (rsl.msg_type == RSL_MT_SACCH_FILL) {
481 handled := true;
482
483 if (si_type == RSL_SYSTEM_INFO_5) {
484 if (not isbound(data)) {
485 si.si5 := omit;
486 } else {
487 si.si5 := dec_SystemInformation(data).payload.si5;
488 }
489 } else if (si_type == RSL_SYSTEM_INFO_5bis) {
490 if (not isbound(data)) {
491 si.si5bis := omit;
492 } else {
493 si.si5bis := dec_SystemInformation(data).payload.si5bis;
494 }
495 } else if (si_type == RSL_SYSTEM_INFO_5ter) {
496 if (not isbound(data)) {
497 si.si5ter := omit;
498 } else {
499 si.si5ter := dec_SystemInformation(data).payload.si5ter;
500 }
501 } else if (si_type == RSL_SYSTEM_INFO_6) {
502 if (not isbound(data)) {
503 si.si6 := omit;
504 } else {
505 si.si6 := dec_SystemInformation(data).payload.si6;
506 }
507 } else {
508 handled := false;
509 }
510 }
511
512 if (not handled) {
513 setverdict(fail, "Unexpected SI type in ", rsl.msg_type, " message: ", si_type);
514 }
515}
516
Harald Weltea4ca4462018-02-09 00:17:14 +0100517type component test_CT extends CTRL_Adapter_CT {
Harald Welte21b46bd2017-12-17 19:46:32 +0100518 /* Array of per-BTS state */
Harald Welte96c94412017-12-09 03:12:45 +0100519 var BTS_State bts[NUM_BTS];
Harald Welte89ab1912018-02-23 18:56:29 +0100520 /* RSL common Channel Port (for RSL_Emulation) */
521 port RSL_CCHAN_PT RSL_CCHAN[NUM_BTS];
Harald Welte21b46bd2017-12-17 19:46:32 +0100522 /* array of per-BTS RSL test ports */
Harald Welteae026692017-12-09 01:03:01 +0100523 port IPA_RSL_PT IPA_RSL[NUM_BTS];
Stefan Sperling830dc9d2018-02-12 21:08:28 +0100524 port IPA_CODEC_PT IPA; /* Required for compilation of TC_rsl_unknown_unit_id() */
Pau Espin Pedrol5a2d7432019-06-07 19:43:45 +0200525 /* CTRL muxed over IPA in SCCPlite conn BSC<->MSC (or BSC-NAT) */
526 port IPA_CTRL_PT SCCPLITE_IPA_CTRL;
Harald Weltea5d2ab22017-12-09 14:21:42 +0100527
Daniel Willmann191e0d92018-01-17 12:44:35 +0100528 var MGCP_Emulation_CT vc_MGCP;
Harald Weltebc03c762018-02-12 18:09:38 +0100529 port TELNETasp_PT BSCVTY;
Daniel Willmann191e0d92018-01-17 12:44:35 +0100530
Daniel Willmannebdecc02020-08-12 15:30:17 +0200531 /* StatsD */
532 var StatsD_Checker_CT vc_STATSD;
533
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200534 var RAN_Adapter g_bssap[NUM_MSC];
Harald Welte47cd0e32020-08-21 12:39:11 +0200535 var BSSAP_LE_Adapter g_bssap_le;
Harald Weltea4ca4462018-02-09 00:17:14 +0100536 /* for old legacy-tests only */
537 port BSSAP_CODEC_PT BSSAP;
Harald Welte47cd0e32020-08-21 12:39:11 +0200538 port BSSAP_LE_CODEC_PT BSSAP_LE;
Harald Weltea4ca4462018-02-09 00:17:14 +0100539
Harald Welte21b46bd2017-12-17 19:46:32 +0100540 /* are we initialized yet */
Harald Welte28d943e2017-11-25 15:00:50 +0100541 var boolean g_initialized := false;
Harald Welte21b46bd2017-12-17 19:46:32 +0100542
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200543 /* Osmux is enabled through VTY */
544 var boolean g_osmux_enabled := false;
545
Pau Espin Pedrolc675b612020-01-09 19:55:40 +0100546 /*Configure T(tias) over VTY, seconds */
547 var integer g_bsc_sccp_timer_ias := 7 * 60;
548 /*Configure T(tiar) over VTY, seconds */
549 var integer g_bsc_sccp_timer_iar := 15 * 60;
550
Neels Hofmeyr4fbad7f2020-06-16 00:30:47 +0200551 /* global test case guard timer (actual timeout value is set in f_init()) */
Harald Welteae026692017-12-09 01:03:01 +0100552 timer T_guard := 30.0;
553
Neels Hofmeyr22c3f792020-06-17 02:49:28 +0200554 var CounterNameValsList g_ctr_msc;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +0000555 var CounterNameValsList g_ctr_bsc;
556 var CounterNameValsList g_ctr_bts;
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +0200557
558 /* System Information bytes as received during RSL startup, for each RSL[idx]. */
559 var SystemInformationConfig_list g_system_information := {};
Harald Welte28d943e2017-11-25 15:00:50 +0100560}
561
562modulepar {
Harald Welte21b46bd2017-12-17 19:46:32 +0100563 /* IP address at which the BSC can be reached */
Harald Welte696ddb62017-12-08 14:01:43 +0100564 charstring mp_bsc_ip := "127.0.0.1";
Stefan Sperling830dc9d2018-02-12 21:08:28 +0100565 /* port number to which to establish the IPA OML connections */
566 integer mp_bsc_oml_port := 3002;
Harald Welte21b46bd2017-12-17 19:46:32 +0100567 /* port number to which to establish the IPA RSL connections */
Harald Welte696ddb62017-12-08 14:01:43 +0100568 integer mp_bsc_rsl_port := 3003;
Harald Welte21b46bd2017-12-17 19:46:32 +0100569 /* port number to which to establish the IPA CTRL connection */
Harald Welte96c94412017-12-09 03:12:45 +0100570 integer mp_bsc_ctrl_port := 4249;
Daniel Willmannebdecc02020-08-12 15:30:17 +0200571 /* port number to which to listen for STATSD metrics */
572 integer mp_bsc_statsd_port := 8125;
Daniel Willmann191e0d92018-01-17 12:44:35 +0100573 /* IP address at which the test binds */
574 charstring mp_test_ip := "127.0.0.1";
Harald Weltea4ca4462018-02-09 00:17:14 +0100575
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200576 RAN_Configurations mp_bssap_cfg := {
577 {
578 transport := BSSAP_TRANSPORT_AoIP,
579 sccp_service_type := "mtp3_itu",
580 sctp_addr := { 23905, "127.0.0.1", 2905, "127.0.0.1" },
581 own_pc := 185, /* 0.23.1 first MSC emulation */
582 own_ssn := 254,
583 peer_pc := 187, /* 0.23.3 osmo-bsc */
584 peer_ssn := 254,
585 sio := '83'O,
Harald Weltecb0cc432020-06-21 19:42:31 +0200586 rctx := 1
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200587 },
588 {
589 transport := BSSAP_TRANSPORT_AoIP,
590 sccp_service_type := "mtp3_itu",
591 sctp_addr := { 23906, "127.0.0.1", 2905, "127.0.0.1" },
592 own_pc := 2, /* 0.0.2 second MSC emulation */
593 own_ssn := 254,
594 peer_pc := 187, /* 0.23.3 osmo-bsc */
595 peer_ssn := 254,
596 sio := '83'O,
597 rctx := 2
598 },
599 {
600 transport := BSSAP_TRANSPORT_AoIP,
601 sccp_service_type := "mtp3_itu",
602 sctp_addr := { 23907, "127.0.0.1", 2905, "127.0.0.1" },
603 own_pc := 3, /* 0.0.3 third MSC emulation */
604 own_ssn := 254,
605 peer_pc := 187, /* 0.23.3 osmo-bsc */
606 peer_ssn := 254,
607 sio := '83'O,
608 rctx := 3
609 }
Harald Weltea4ca4462018-02-09 00:17:14 +0100610 };
Pau Espin Pedrol58cf6822019-05-28 18:11:33 +0200611
Harald Welte47cd0e32020-08-21 12:39:11 +0200612 BSSAP_LE_Configuration mp_bssap_le_cfg := {
613 sccp_service_type := "mtp3_itu",
614 sctp_addr := { 23908, "127.0.0.1", 2905, "127.0.0.1" },
615 own_pc := 6, /* 0.0.6 SMLC emulation */
616 own_ssn := 252, /* SMLC side SSN */
617 peer_pc := 187, /* 0.23.3 osmo-bsc */
618 peer_ssn := 250, /* BSC side SSN */
619 sio := '83'O,
620 rctx := 6
621 };
622
Pau Espin Pedrol58cf6822019-05-28 18:11:33 +0200623 /* Whether to enable osmux tests. Can be dropped completely and enable
624 unconditionally once new version of osmo-bsc is released (current
625 version: 1.4.1) */
626 boolean mp_enable_osmux_test := true;
Pau Espin Pedrol8f30ccd2019-11-01 17:30:57 +0100627 /* Value set in osmo-bsc.cfg "ms max power" */
628 uint8_t mp_exp_ms_power_level := 7;
Philipp Maiera2083892020-09-21 14:18:36 +0200629
630 boolean mp_media_mgw_offer_ipv6 := true;
Harald Weltea4ca4462018-02-09 00:17:14 +0100631}
632
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200633private function f_gen_test_hdlr_pars(integer bssap_idx := 0) return TestHdlrParams {
Philipp Maier48604732018-10-09 15:00:37 +0200634
635 var TestHdlrParams pars := valueof(t_def_TestHdlrPars);
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200636 if (mp_bssap_cfg[bssap_idx].transport == BSSAP_TRANSPORT_AoIP) {
Philipp Maier48604732018-10-09 15:00:37 +0200637 pars.aoip := true;
638 } else {
639 pars.aoip := false;
640 }
Pau Espin Pedrol8f30ccd2019-11-01 17:30:57 +0100641 pars.exp_ms_power_level := mp_exp_ms_power_level;
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200642 pars.mscpool.bssap_idx := bssap_idx;
Philipp Maiera2083892020-09-21 14:18:36 +0200643 pars.media_mgw_offer_ipv6 := mp_media_mgw_offer_ipv6;
Philipp Maier48604732018-10-09 15:00:37 +0200644
645 return pars;
646}
647
Neels Hofmeyr22c3f792020-06-17 02:49:28 +0200648/* Convenience functions for rate counters using g_ctr_msc. */
649
650private function f_ctrs_msc_init(integer mscs_count := NUM_MSC, CounterNameVals counternames := counternames_msc_mscpool) runs on test_CT {
651 g_ctr_msc := f_counter_name_vals_get_n(IPA_CTRL, "msc", mscs_count, counternames);
652 log("initial msc rate counters: ", g_ctr_msc);
653}
654
655private function f_ctrs_msc_add(integer msc_nr, charstring countername, integer val := 1) runs on test_CT {
Neels Hofmeyr9656e922020-06-30 01:27:01 +0200656 f_counter_name_vals_list_add(g_ctr_msc, msc_nr, countername, val);
Neels Hofmeyr22c3f792020-06-17 02:49:28 +0200657}
658
659/* f_ctrs_msc_init();
660 * f_do_thing(on_msc := 0);
661 * f_do_thing(on_msc := 0);
662 * f_do_other(on_msc := 1);
663 * f_ctrs_msc_add(0, "thing", 2);
664 * f_ctrs_msc_add(1, "other");
665 * f_ctrs_msc_verify();
666 */
667private function f_ctrs_msc_verify() runs on test_CT {
668 log("verifying msc rate counters: ", g_ctr_msc);
669 f_counter_name_vals_expect_n(IPA_CTRL, "msc", g_ctr_msc);
670}
671
672/* convenience: f_ctrs_msc_add() and f_ctrs_msc_verify() in one call.
673 * f_ctrs_msc_init();
674 * f_do_thing(on_msc := 0);
675 * f_do_thing(on_msc := 0);
676 * f_do_thing(on_msc := 0);
677 * f_ctrs_msc_expect(0, "thing", 3);
678 */
679private function f_ctrs_msc_expect(integer msc_nr, charstring countername, integer val := 1) runs on test_CT {
680 f_ctrs_msc_add(msc_nr, countername, val);
681 f_ctrs_msc_verify();
682}
683
Neels Hofmeyr12941bd2020-08-29 03:21:26 +0000684/* Convenience functions for rate counters using g_ctr_bts, always also including g_ctr_bsc. */
685
686private function f_ctrs_bsc_and_bts_init(integer bts_count := NUM_BTS, CounterNameVals counternames := counternames_bsc_bts_handover) runs on test_CT {
687 g_ctr_bts := f_counter_name_vals_get_n(IPA_CTRL, "bts", bts_count, counternames);
688 log("initial bts rate counters: ", g_ctr_bts);
689 f_ctrs_bsc_init(counternames);
690}
691
692private function f_ctrs_bsc_and_bts_add(integer bts_nr, charstring countername, integer val := 1) runs on test_CT {
693 f_counter_name_vals_list_add(g_ctr_bts, bts_nr, countername, val);
694 f_ctrs_bsc_add(countername, val);
695}
696
697/* f_ctrs_bsc_and_bts_init();
698 * f_do_thing(on_bts := 0);
699 * f_do_thing(on_bts := 0);
700 * f_do_other(on_bts := 1);
701 * f_ctrs_bsc_and_bts_add(0, "thing", 2);
702 * f_ctrs_bsc_and_bts_add(1, "other");
703 * f_ctrs_bsc_and_bts_verify();
704 */
705private function f_ctrs_bsc_and_bts_verify() runs on test_CT {
706 f_counter_name_vals_expect_n(IPA_CTRL, "bts", g_ctr_bts);
707 f_ctrs_bsc_verify();
708}
709
710/* convenience: f_ctrs_bsc_and_bts_add() and f_ctrs_bsc_and_bts_verify() in one call.
711 * f_ctrs_bsc_and_bts_init();
712 * f_do_thing(on_bts := 0);
713 * f_do_thing(on_bts := 0);
714 * f_do_thing(on_bts := 0);
715 * f_ctrs_bsc_and_bts_expect(0, "thing", 3);
716 */
717private function f_ctrs_bsc_and_bts_expect(integer bts_nr, charstring countername, integer val := 1) runs on test_CT {
718 f_ctrs_bsc_and_bts_add(bts_nr, countername, val);
719 f_ctrs_bsc_and_bts_verify();
720}
721
722
723/* Convenience functions for rate counters using g_ctr_bsc. */
724
725private function f_ctrs_bsc_init(CounterNameVals counternames := counternames_bsc_bts_handover) runs on test_CT {
726 g_ctr_bsc := f_counter_name_vals_get_n(IPA_CTRL, "bsc", 1, counternames);
727 log("initial bsc rate counters: ", g_ctr_bsc);
728}
729
730private function f_ctrs_bsc_add(charstring countername, integer val := 1) runs on test_CT {
731 f_counter_name_vals_list_add(g_ctr_bsc, 0, countername, val);
732}
733
734/* f_ctrs_bsc_init();
735 * f_do_thing();
736 * f_do_thing();
737 * f_do_other();
738 * f_ctrs_bsc_add("thing", 2);
739 * f_ctrs_bsc_add("other");
740 * f_ctrs_bsc_verify();
741 */
742private function f_ctrs_bsc_verify() runs on test_CT {
743 f_counter_name_vals_expect_n(IPA_CTRL, "bsc", g_ctr_bsc);
744}
745
746/* convenience: f_ctrs_bsc_add() and f_ctrs_bsc_verify() in one call.
747 * f_ctrs_bsc_init();
748 * f_do_thing();
749 * f_ctrs_bsc_expect("thing", 1);
750 */
751private function f_ctrs_bsc_expect(charstring countername, integer val := 1) runs on test_CT {
752 f_ctrs_bsc_add(countername, val);
753 f_ctrs_bsc_verify();
754}
755
Neels Hofmeyr22c3f792020-06-17 02:49:28 +0200756
Philipp Maier282ca4b2018-02-27 17:17:00 +0100757private function f_shutdown_helper() runs on test_CT {
Daniel Willmann637ef6c2018-07-25 10:49:09 +0200758 all component.stop;
Philipp Maier282ca4b2018-02-27 17:17:00 +0100759 setverdict(pass);
Daniel Willmannafce8662018-07-06 23:11:32 +0200760 mtc.stop;
Philipp Maier282ca4b2018-02-27 17:17:00 +0100761}
762
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200763private function f_legacy_bssap_reset(integer bssap_idx := 0) runs on test_CT {
Harald Weltea4ca4462018-02-09 00:17:14 +0100764 var BSSAP_N_UNITDATA_ind ud_ind;
Pau Espin Pedrol24c05992020-09-01 12:54:12 +0200765 var boolean reset_received := false;
Harald Weltea4ca4462018-02-09 00:17:14 +0100766 timer T := 5.0;
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200767 BSSAP.send(ts_BSSAP_UNITDATA_req(g_bssap[bssap_idx].sccp_addr_peer, g_bssap[bssap_idx].sccp_addr_own,
768 ts_BSSMAP_Reset(0, g_osmux_enabled)));
Harald Weltea4ca4462018-02-09 00:17:14 +0100769 T.start;
770 alt {
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200771 [] BSSAP.receive(tr_BSSAP_UNITDATA_ind(g_bssap[bssap_idx].sccp_addr_own, g_bssap[bssap_idx].sccp_addr_peer,
772 tr_BSSMAP_ResetAck(g_osmux_enabled))) {
Harald Weltea4ca4462018-02-09 00:17:14 +0100773 log("Received RESET-ACK in response to RESET, we're ready to go!");
774 }
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200775 [] BSSAP.receive(tr_BSSAP_UNITDATA_ind(?, ?, tr_BSSMAP_Reset(g_osmux_enabled))) -> value ud_ind {
Harald Weltea4ca4462018-02-09 00:17:14 +0100776 log("Respoding to inbound RESET with RESET-ACK");
777 BSSAP.send(ts_BSSAP_UNITDATA_req(ud_ind.callingAddress, ud_ind.calledAddress,
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200778 ts_BSSMAP_ResetAck(g_osmux_enabled)));
Pau Espin Pedrol24c05992020-09-01 12:54:12 +0200779 reset_received := true;
Harald Weltea4ca4462018-02-09 00:17:14 +0100780 repeat;
781 }
782 [] BSSAP.receive { repeat; }
Pau Espin Pedrol24c05992020-09-01 12:54:12 +0200783 [] T.timeout {
784 log("Timeout waiting for RESET-ACK after sending RESET");
785 /* If we received a RESET after ours was sent, it
786 may be a race condition where the other peer beacame
787 available after we sent it, but we are in a desired
788 state anyway, so go forward. */
789 if (not reset_received) {
790 setverdict(fail);
791 }
792 }
Harald Weltea4ca4462018-02-09 00:17:14 +0100793 }
Harald Welte28d943e2017-11-25 15:00:50 +0100794}
795
Harald Welteae026692017-12-09 01:03:01 +0100796type record IPA_Client {
Harald Welte21b46bd2017-12-17 19:46:32 +0100797 /* IPA Emulation component reference */
Harald Welteae026692017-12-09 01:03:01 +0100798 IPA_Emulation_CT vc_IPA,
Harald Welte21b46bd2017-12-17 19:46:32 +0100799 /* Unit-ID and other CCM parameters to use for IPA client emulation */
Harald Welteae026692017-12-09 01:03:01 +0100800 IPA_CCM_Parameters ccm_pars,
Harald Welte21b46bd2017-12-17 19:46:32 +0100801 /* String identifier for this IPA Client */
Harald Welte624f9632017-12-16 19:26:04 +0100802 charstring id,
Harald Welte21b46bd2017-12-17 19:46:32 +0100803 /* Associated RSL Emulation Component (if any). Only used in "Handler mode" */
Harald Welte624f9632017-12-16 19:26:04 +0100804 RSL_Emulation_CT vc_RSL optional
Harald Welte28d943e2017-11-25 15:00:50 +0100805}
806
Harald Welte21b46bd2017-12-17 19:46:32 +0100807/*! Start the IPA/RSL related bits for one IPA_Client.
808 * \param clnt IPA_Client for which to establish
809 * \param bsc_host IP address / hostname of the BSC
810 * \param bsc_port TCP port number of the BSC
811 * \param i number identifying this BTS
812 * \param handler_mode Start an RSL_Emulation_CT component (true) or not (false) */
Harald Welte624f9632017-12-16 19:26:04 +0100813function f_ipa_rsl_start(inout IPA_Client clnt, charstring bsc_host, PortNumber bsc_port, integer i,
814 boolean handler_mode := false)
Harald Welte28d943e2017-11-25 15:00:50 +0100815runs on test_CT {
Harald Welteae026692017-12-09 01:03:01 +0100816 timer T := 10.0;
817
Harald Welte96c94412017-12-09 03:12:45 +0100818 clnt.id := "IPA" & int2str(i) & "-RSL";
Harald Welteae026692017-12-09 01:03:01 +0100819 clnt.vc_IPA := IPA_Emulation_CT.create(clnt.id & "-IPA");
820 clnt.ccm_pars := c_IPA_default_ccm_pars;
821 clnt.ccm_pars.name := "Osmocom TTCN-3 BTS Simulator";
822 clnt.ccm_pars.unit_id := int2str(1234+i) & "/0/0";
Harald Welte624f9632017-12-16 19:26:04 +0100823 if (handler_mode) {
824 clnt.vc_RSL := RSL_Emulation_CT.create(clnt.id & "-RSL");
Harald Welte89ab1912018-02-23 18:56:29 +0100825 connect(clnt.vc_RSL:CCHAN_PT, self:RSL_CCHAN[i]);
Harald Welte624f9632017-12-16 19:26:04 +0100826 }
Harald Welteae026692017-12-09 01:03:01 +0100827
828 map(clnt.vc_IPA:IPA_PORT, system:IPA_CODEC_PT);
Harald Welte624f9632017-12-16 19:26:04 +0100829 if (handler_mode) {
830 connect(clnt.vc_IPA:IPA_RSL_PORT, clnt.vc_RSL:IPA_PT);
831 } else {
832 connect(clnt.vc_IPA:IPA_RSL_PORT, self:IPA_RSL[i]);
833 }
Harald Welteae026692017-12-09 01:03:01 +0100834
Harald Welte5d1a2202017-12-13 19:51:29 +0100835 clnt.vc_IPA.start(IPA_Emulation.main_client(bsc_host, bsc_port, "", 10000+i, clnt.ccm_pars));
Harald Welte624f9632017-12-16 19:26:04 +0100836 if (handler_mode) {
837 clnt.vc_RSL.start(RSL_Emulation.main());
838 return;
839 }
Harald Welteae026692017-12-09 01:03:01 +0100840
841 /* wait for IPA RSL link to connect and send ID ACK */
842 T.start;
843 alt {
Vadim Yanitskiya2afacc2020-05-18 21:16:19 +0700844 [] IPA_RSL[i].receive(tr_ASP_IPA_EV(ASP_IPA_EVENT_ID_ACK)) {
Harald Welteae026692017-12-09 01:03:01 +0100845 T.stop;
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +0700846 IPA_RSL[i].send(ts_ASP_RSL_UD(ts_RSL_PAGING_LOAD_IND(23)));
Harald Welteae026692017-12-09 01:03:01 +0100847 }
Harald Welte60e823a2017-12-10 14:10:59 +0100848 [] IPA_RSL[i].receive(ASP_IPA_Event:?) { repeat }
Harald Welteae026692017-12-09 01:03:01 +0100849 [] IPA_RSL[i].receive { repeat }
850 [] T.timeout {
Harald Welte96c94412017-12-09 03:12:45 +0100851 setverdict(fail, "Timeout RSL waiting for ASP_IPA_EVENT_ID_ACK");
Daniel Willmannafce8662018-07-06 23:11:32 +0200852 mtc.stop;
Harald Welteae026692017-12-09 01:03:01 +0100853 }
854 }
855}
856
Harald Welte12055472018-03-17 20:10:08 +0100857function f_ipa_rsl_stop(inout IPA_Client clnt) runs on test_CT {
858 if (not isbound(clnt) or not isbound(clnt.vc_IPA)) {
859 return;
860 }
861 clnt.vc_IPA.stop;
862 if (isbound(clnt.vc_RSL)) {
863 clnt.vc_RSL.stop;
864 }
865}
866
Harald Welte21b46bd2017-12-17 19:46:32 +0100867/* Wait for the OML connection to be brought up by the external osmo-bts-omldummy */
Harald Weltea5d2ab22017-12-09 14:21:42 +0100868function f_wait_oml(integer bts_nr, charstring status, float secs_max) runs on test_CT {
869 timer T := secs_max;
870 T.start;
871 while (true) {
872 if (f_ctrl_get_bts(IPA_CTRL, bts_nr, "oml-connection-state") == status) {
873 T.stop;
Harald Weltebd868bd2017-12-10 18:28:40 +0100874 /* the 'degraded' state exists from OML connection time, and we have to wait
875 * until all MO's are initialized */
876 T.start(1.0);
877 T.timeout;
Harald Weltea5d2ab22017-12-09 14:21:42 +0100878 return;
879 }
Harald Weltef0d6ac62017-12-17 17:02:21 +0100880 f_sleep(0.1);
Harald Weltea5d2ab22017-12-09 14:21:42 +0100881 if (not T.running) {
Max99253902018-11-16 17:57:39 +0100882 setverdict(fail, "Timeout waiting for BTS" & int2str(bts_nr) & " oml-connection-state ", status);
Daniel Willmannafce8662018-07-06 23:11:32 +0200883 mtc.stop;
Harald Weltea5d2ab22017-12-09 14:21:42 +0100884 }
885 }
886}
887
Harald Welte21b46bd2017-12-17 19:46:32 +0100888/* global altstep for global guard timer; also takes care of responding RESET witH RESET-ACK */
Harald Welteae026692017-12-09 01:03:01 +0100889altstep as_Tguard() runs on test_CT {
Harald Welte60e823a2017-12-10 14:10:59 +0100890 var BSSAP_N_UNITDATA_ind ud_ind;
Neels Hofmeyrcc3f76a2018-03-12 01:43:25 +0100891 [] T_guard.timeout {
892 setverdict(fail, "Timeout of T_guard");
Daniel Willmannafce8662018-07-06 23:11:32 +0200893 mtc.stop;
Neels Hofmeyrcc3f76a2018-03-12 01:43:25 +0100894 }
Harald Welte60e823a2017-12-10 14:10:59 +0100895 /* always respond with RESET ACK to RESET */
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200896 [] BSSAP.receive(tr_BSSAP_UNITDATA_ind(?, ?, tr_BSSMAP_Reset(g_osmux_enabled))) -> value ud_ind {
Harald Welte60e823a2017-12-10 14:10:59 +0100897 BSSAP.send(ts_BSSAP_UNITDATA_req(ud_ind.callingAddress, ud_ind.calledAddress,
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200898 ts_BSSMAP_ResetAck(g_osmux_enabled)));
Harald Welte69c1c262017-12-13 21:02:08 +0100899 repeat;
Harald Welte60e823a2017-12-10 14:10:59 +0100900 }
Harald Welte28d943e2017-11-25 15:00:50 +0100901}
902
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +0100903altstep no_bssmap_reset() runs on test_CT {
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200904 [] BSSAP.receive(tr_BSSAP_UNITDATA_ind(?, ?, tr_BSSMAP_Reset(g_osmux_enabled))) {
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +0100905 setverdict(fail, "unexpected BSSMAP Reset");
Daniel Willmannafce8662018-07-06 23:11:32 +0200906 mtc.stop;
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +0100907 }
908}
909
Daniel Willmann191e0d92018-01-17 12:44:35 +0100910function f_init_mgcp(charstring id) runs on test_CT {
911 id := id & "-MGCP";
912
913 var MGCPOps ops := {
914 create_cb := refers(MGCP_Emulation.ExpectedCreateCallback),
915 unitdata_cb := refers(MGCP_Emulation.DummyUnitdataCallback)
916 };
917 var MGCP_conn_parameters mgcp_pars := {
918 callagent_ip := mp_bsc_ip,
Harald Welte9e4273e2018-01-29 22:01:22 +0100919 callagent_udp_port := -1,
Daniel Willmann191e0d92018-01-17 12:44:35 +0100920 mgw_ip := mp_test_ip,
Pau Espin Pedrol1a026a52019-06-18 17:21:52 +0200921 mgw_udp_port := 2427,
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +0200922 /* Enable it for SCCPlite, since we have 2 MGCP sockets towards MGW (UDP one +
923 the on with MGCP over IPA forwarded from MSC one) */
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200924 multi_conn_mode := (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_SCCPlite_SERVER)
Daniel Willmann191e0d92018-01-17 12:44:35 +0100925 };
926
927 vc_MGCP := MGCP_Emulation_CT.create(id);
928 vc_MGCP.start(MGCP_Emulation.main(ops, mgcp_pars, id));
929}
930
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200931/* Enable or disable (current default) Osmux. When enabling, BSSMAP Reset
932 * contains extra IE (OsmuxSupport) and osmo-bsc will handle AssignReq with
933 * OsmuxCID IE.
934 */
935private function f_vty_allow_osmux(boolean allow) runs on test_CT {
936 f_vty_enter_cfg_msc(BSCVTY, 0);
937 if (allow) {
938 f_vty_transceive(BSCVTY, "osmux on");
939 } else {
940 f_vty_transceive(BSCVTY, "osmux off");
941 }
942 f_vty_transceive(BSCVTY, "exit");
943 f_vty_transceive(BSCVTY, "exit");
944 g_osmux_enabled := allow;
945}
946
Max2253c0b2018-11-06 19:28:05 +0100947function f_init_vty(charstring id := "foo") runs on test_CT {
Harald Welte94e0c342018-04-07 11:33:23 +0200948 if (BSCVTY.checkstate("Mapped")) {
949 /* skip initialization if already executed once */
950 return;
951 }
Harald Weltebc03c762018-02-12 18:09:38 +0100952 map(self:BSCVTY, system:BSCVTY);
953 f_vty_set_prompts(BSCVTY);
954 f_vty_transceive(BSCVTY, "enable");
Pau Espin Pedrolc675b612020-01-09 19:55:40 +0100955 f_cs7_inst_0_cfg(BSCVTY, {"sccp-timer ias " & int2str(g_bsc_sccp_timer_ias),
956 "sccp-timer iar " & int2str(g_bsc_sccp_timer_iar)});
Harald Weltebc03c762018-02-12 18:09:38 +0100957}
958
Neels Hofmeyr767548a2020-08-09 20:26:07 +0000959private function f_logp(TELNETasp_PT pt, charstring log_msg)
Neels Hofmeyr4f118412020-06-04 15:25:10 +0200960{
961 // log on TTCN3 log output
962 log(log_msg);
963 // log in stderr log
Neels Hofmeyr767548a2020-08-09 20:26:07 +0000964 f_vty_transceive(pt, "logp lglobal notice TTCN3 f_logp(): " & log_msg);
Neels Hofmeyr4f118412020-06-04 15:25:10 +0200965}
966
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +0200967private function f_sysinfo_seen(integer rsl_idx, RSL_Message rsl) runs on test_CT
968{
969 if (rsl_idx >= lengthof(g_system_information)) {
970 g_system_information[rsl_idx] := SystemInformationConfig_omit
971 }
972 f_sysinfo_dec_raw(g_system_information[rsl_idx], rsl);
973}
974
975altstep as_catch_RSL_sysinfo(integer rsl_idx) runs on test_CT {
976 var ASP_RSL_Unitdata rx_rsl_ud;
977
978 /* For handler_mode := false, receiving the RSL bootstrap messages directly on IPA_RSL */
979 [] IPA_RSL[rsl_idx].receive(tr_ASP_RSL_UD(tr_RSL_NO_BCCH_INFO)) -> value rx_rsl_ud {
980 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
981 repeat;
982 }
983 [] IPA_RSL[rsl_idx].receive(tr_ASP_RSL_UD(tr_RSL_BCCH_INFO)) -> value rx_rsl_ud {
984 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
985 repeat;
986 }
987 [] IPA_RSL[rsl_idx].receive(tr_ASP_RSL_UD(tr_RSL_NO_SACCH_FILL)) -> value rx_rsl_ud {
988 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
989 repeat;
990 }
991 [] IPA_RSL[rsl_idx].receive(tr_ASP_RSL_UD(tr_RSL_SACCH_FILL)) -> value rx_rsl_ud {
992 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
993 repeat;
994 }
995
996 /* For handler_mode := true, receiving the RSL bootstrap messages via RSL_Emulation */
997 [] RSL_CCHAN[rsl_idx].receive(tr_ASP_RSL_UD(tr_RSL_NO_BCCH_INFO)) -> value rx_rsl_ud {
998 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
999 repeat;
1000 }
1001 [] RSL_CCHAN[rsl_idx].receive(tr_ASP_RSL_UD(tr_RSL_BCCH_INFO)) -> value rx_rsl_ud {
1002 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
1003 repeat;
1004 }
1005 [] RSL_CCHAN[rsl_idx].receive(tr_ASP_RSL_UD(tr_RSL_NO_SACCH_FILL)) -> value rx_rsl_ud {
1006 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
1007 repeat;
1008 }
1009 [] RSL_CCHAN[rsl_idx].receive(tr_ASP_RSL_UD(tr_RSL_SACCH_FILL)) -> value rx_rsl_ud {
1010 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
1011 repeat;
1012 }
1013}
1014
Neels Hofmeyra460f1f2020-08-09 20:17:03 +00001015/* TODO: use BooleanList from COMMON/src/General_Types.ttcn */
1016private type record of boolean my_BooleanList;
1017
1018private function f_vty_msc_allow_attach(TELNETasp_PT pt, my_BooleanList allow_attach_list)
1019{
Neels Hofmeyr8f576712020-08-12 22:49:53 +00001020 var charstring config := f_vty_transceive_ret(pt, "show running-config");
1021
Neels Hofmeyra460f1f2020-08-09 20:17:03 +00001022 for (var integer msc_nr := 0; msc_nr < sizeof(allow_attach_list); msc_nr := msc_nr+1) {
Neels Hofmeyr8f576712020-08-12 22:49:53 +00001023 if (f_strstr(config, "\nmsc " & int2str(msc_nr) & "\n") < 0) {
1024 /* There is no 'msc N' for this msc_nr in the running config, so don't create an empty msc by
1025 * stepping into that config node. */
1026 log("msc ", msc_nr, " is not configured, skipping");
1027 continue;
1028 }
Neels Hofmeyra460f1f2020-08-09 20:17:03 +00001029 f_vty_enter_cfg_msc(pt, msc_nr);
1030 if (allow_attach_list[msc_nr]) {
1031 /* strict := false: ignore if osmo-bsc does not support this config option (latest build) */
1032 f_vty_transceive(pt, "allow-attach", strict := false);
1033 } else {
1034 f_vty_transceive(pt, "no allow-attach", strict := false);
1035 }
1036 f_vty_transceive(pt, "exit");
1037 f_vty_transceive(pt, "exit");
1038 }
1039}
1040
Harald Welte21b46bd2017-12-17 19:46:32 +01001041/* global initialization function
1042 * \param nr_bts Number of BTSs we should start/bring up
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001043 * \param handler_mode Start an RSL_Emulation_CT component (true) or not (false).
1044 * \param nr_msc Number of virtual MSCs to bring up to connect to osmo-bsc.
1045 */
1046function f_init(integer nr_bts := NUM_BTS, boolean handler_mode := false, boolean allow_osmux := false,
Neels Hofmeyr4fbad7f2020-06-16 00:30:47 +02001047 integer nr_msc := 1, float guard_timeout := 30.0) runs on test_CT {
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001048 var integer bssap_idx;
Harald Welte28d943e2017-11-25 15:00:50 +01001049
Harald Welteae026692017-12-09 01:03:01 +01001050 if (g_initialized) {
1051 return;
Harald Welte28d943e2017-11-25 15:00:50 +01001052 }
Harald Welteae026692017-12-09 01:03:01 +01001053 g_initialized := true;
1054
Neels Hofmeyr4fbad7f2020-06-16 00:30:47 +02001055 T_guard.start(guard_timeout);
Daniel Willmanne68f9272018-11-27 15:15:28 +01001056 activate(as_Tguard());
1057
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02001058 f_init_vty("VirtMSC");
Pau Espin Pedrol58cf6822019-05-28 18:11:33 +02001059 if (mp_enable_osmux_test) {
1060 f_vty_allow_osmux(allow_osmux);
1061 }
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02001062
Neels Hofmeyra460f1f2020-08-09 20:17:03 +00001063 var my_BooleanList allow_attach := { false, false, false };
Daniel Willmannebdecc02020-08-12 15:30:17 +02001064 f_init_statsd("VirtMSC", vc_STATSD, mp_test_ip, mp_bsc_statsd_port);
1065
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001066 for (bssap_idx := 0; bssap_idx < nr_msc; bssap_idx := bssap_idx+1) {
Neels Hofmeyra460f1f2020-08-09 20:17:03 +00001067 allow_attach[bssap_idx] := true;
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001068 /* Call a function of our 'parent component' RAN_Adapter_CT to start the
1069 * MSC-side BSSAP emulation */
1070 if (handler_mode) {
1071 var RanOps ranops := MSC_RanOps;
1072 ranops.use_osmux := g_osmux_enabled;
1073 f_ran_adapter_init(g_bssap[bssap_idx], mp_bssap_cfg[bssap_idx], "VirtMSC", ranops);
1074 connect(self:SCCPLITE_IPA_CTRL, g_bssap[bssap_idx].vc_RAN:CTRL_CLIENT);
1075 f_ran_adapter_start(g_bssap[bssap_idx]);
1076 } else {
1077 f_ran_adapter_init(g_bssap[bssap_idx], mp_bssap_cfg[bssap_idx], "VirtMSC", omit);
1078 connect(self:BSSAP, g_bssap[bssap_idx].vc_SCCP:SCCP_SP_PORT);
1079 f_ran_adapter_start(g_bssap[bssap_idx]);
1080 f_legacy_bssap_reset();
1081 }
Harald Welte67089ee2018-01-17 22:19:03 +01001082 }
Harald Welted5833a82018-05-27 16:52:56 +02001083
Harald Welte47cd0e32020-08-21 12:39:11 +02001084 if (handler_mode) {
1085 f_bssap_le_adapter_init(g_bssap_le, mp_bssap_le_cfg, "VirtSMLC", SMLC_BssapLeOps);
1086 } else {
1087 f_bssap_le_adapter_init(g_bssap_le, mp_bssap_le_cfg, "VirtSMLC", omit);
1088 connect(self:BSSAP_LE, g_bssap_le.vc_SCCP:SCCP_SP_PORT);
1089 }
1090 f_bssap_le_adapter_start(g_bssap_le);
1091
Neels Hofmeyra460f1f2020-08-09 20:17:03 +00001092 /* start the test with exactly all enabled MSCs allowed to attach */
1093 f_vty_msc_allow_attach(BSCVTY, allow_attach);
1094
Harald Welteffe55fc2018-01-17 22:39:54 +01001095 f_ipa_ctrl_start(mp_bsc_ip, mp_bsc_ctrl_port);
Harald Welte28d943e2017-11-25 15:00:50 +01001096
Daniel Willmann191e0d92018-01-17 12:44:35 +01001097 f_init_mgcp("VirtMSC");
1098
Neels Hofmeyr0b7365b2020-07-04 00:52:34 +02001099 for (var integer i := 0; i < nr_bts; i := i+1) {
1100 f_init_bts(i, handler_mode);
Harald Welte696ddb62017-12-08 14:01:43 +01001101 }
Neels Hofmeyr0b7365b2020-07-04 00:52:34 +02001102}
Harald Welte696ddb62017-12-08 14:01:43 +01001103
Neels Hofmeyr0b7365b2020-07-04 00:52:34 +02001104function f_init_bts(integer bts_idx := 0, boolean handler_mode := false)
1105runs on test_CT {
1106 /* wait until osmo-bts-omldummy has respawned */
1107 f_wait_oml(bts_idx, "degraded", 5.0);
1108
1109 /* start RSL connection */
1110 f_ipa_rsl_start(bts[bts_idx].rsl, mp_bsc_ip, mp_bsc_rsl_port, bts_idx, handler_mode);
1111 /* wait until BSC tells us "connected" */
1112 f_wait_oml(bts_idx, "connected", 5.0);
Harald Welte28d943e2017-11-25 15:00:50 +01001113}
1114
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +02001115function f_init_bts_and_check_sysinfo(integer bts_idx := 0, boolean handler_mode := false,
1116 template SystemInformationConfig expect_si)
1117runs on test_CT {
1118 var default sysinfo := activate(as_catch_RSL_sysinfo(bts_idx));
1119
1120 f_init_bts(bts_idx, handler_mode);
1121
1122 /* Give some time to (hopefully/most likely) collect all system informations from RSL startup.
1123 * We could stop as soon as all expected SI are received, but then we might miss SI that we don't expect and
1124 * that might be sent afterwards. So rather give a generous timeout and be quite sure to catch all SI.
1125 */
1126 f_sleep(5.0);
1127 log("RSL ", bts_idx, " SYSTEM INFORMATION: ", g_system_information[bts_idx]);
1128
1129 deactivate(sysinfo);
1130
1131 if (match(g_system_information[bts_idx], expect_si)) {
1132 setverdict(pass);
1133 } else {
1134 log("RSL ", bts_idx, ": EXPECTED SI: ", expect_si);
1135 log("RSL ", bts_idx, ": GOT SI: ", g_system_information[bts_idx]);
1136 setverdict(fail, "received SI does not match expectations");
1137 return;
1138 }
1139}
1140
Maxd4e56962018-10-31 19:08:25 +01001141/* expect to receive a RSL message matching a specified template on a given BTS / stream */
Harald Welte65e419a2020-08-21 12:38:33 +02001142function 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 +01001143runs on test_CT return RSL_Message {
1144 var ASP_RSL_Unitdata rx_rsl_ud;
1145 timer T := t_secs;
1146
1147 T.start;
1148 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001149 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(t_rx, sid)) -> value rx_rsl_ud {
Harald Welteae026692017-12-09 01:03:01 +01001150 T.stop;
1151 }
1152 [] IPA_RSL[bts_nr].receive { repeat; }
Harald Welteb2917702017-12-10 15:48:52 +01001153 [] T.timeout {
1154 setverdict(fail, "Timeout expecting ", t_rx);
Daniel Willmannafce8662018-07-06 23:11:32 +02001155 mtc.stop;
Harald Welteb2917702017-12-10 15:48:52 +01001156 }
Harald Welteae026692017-12-09 01:03:01 +01001157 }
1158 return rx_rsl_ud.rsl;
1159}
1160
Harald Welte21b46bd2017-12-17 19:46:32 +01001161/* helper function to transmit RSL on a given BTS/stream */
Harald Welte65e419a2020-08-21 12:38:33 +02001162function 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 +01001163runs on test_CT {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001164 IPA_RSL[bts_nr].send(ts_ASP_RSL_UD(t_tx, sid));
Harald Welteae026692017-12-09 01:03:01 +01001165}
1166
1167
Harald Welte4003d112017-12-09 22:35:39 +01001168/* verify we get a CHAN_ACT after CHAN RQD */
Harald Welteae026692017-12-09 01:03:01 +01001169testcase TC_chan_act_noreply() runs on test_CT {
1170 var BSSAP_N_UNITDATA_ind ud_ind;
Harald Welte930d0a72018-03-22 22:08:40 +01001171 var RSL_Message rsl_unused;
Harald Welte28d943e2017-11-25 15:00:50 +01001172
Harald Welte89d42e82017-12-17 16:42:41 +01001173 f_init(1);
Harald Welte28d943e2017-11-25 15:00:50 +01001174
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001175 IPA_RSL[0].send(ts_ASP_RSL_UD(ts_RSL_CHAN_RQD('23'O, 23)));
Harald Welte930d0a72018-03-22 22:08:40 +01001176 rsl_unused := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001177 f_shutdown_helper();
Harald Welte28d943e2017-11-25 15:00:50 +01001178}
1179
Harald Welte4003d112017-12-09 22:35:39 +01001180/* verify if the "chreq:total" counter increments as expected */
1181testcase TC_chan_act_counter() runs on test_CT {
1182 var BSSAP_N_UNITDATA_ind ud_ind;
1183 var integer chreq_total;
Harald Welte930d0a72018-03-22 22:08:40 +01001184 var RSL_Message rsl_unused;
Harald Welte4003d112017-12-09 22:35:39 +01001185
Harald Welte89d42e82017-12-17 16:42:41 +01001186 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +01001187
1188 chreq_total := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total");
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001189 IPA_RSL[0].send(ts_ASP_RSL_UD(ts_RSL_CHAN_RQD('23'O, 23)));
Harald Welte930d0a72018-03-22 22:08:40 +01001190 rsl_unused := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
Harald Welte4003d112017-12-09 22:35:39 +01001191 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total", chreq_total+1);
1192
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001193 f_shutdown_helper();
Harald Welte4003d112017-12-09 22:35:39 +01001194}
1195
Harald Welteae026692017-12-09 01:03:01 +01001196/* CHAN RQD -> CHAN ACT -> CHAN ACT ACK -> RF CHAN REL */
Philipp Maier9c60a622020-07-09 15:08:46 +02001197private function f_TC_chan_act_ack_noest(OCT1 ra := '23'O) runs on test_CT {
Harald Welteae026692017-12-09 01:03:01 +01001198 var RSL_Message rx_rsl;
1199
Harald Welteae026692017-12-09 01:03:01 +01001200 /* Send CHAN RQD and wait for allocation; acknowledge it */
Philipp Maier9c60a622020-07-09 15:08:46 +02001201 var RslChannelNr chan_nr := f_chreq_act_ack(ra);
Harald Welteae026692017-12-09 01:03:01 +01001202
1203 /* expect BSC to disable the channel again if there's no RLL EST IND */
1204 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), T3101_MAX);
1205
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001206 f_shutdown_helper();
Harald Welteae026692017-12-09 01:03:01 +01001207}
1208
Philipp Maier9c60a622020-07-09 15:08:46 +02001209/* Normal variant */
1210testcase TC_chan_act_ack_noest() runs on test_CT {
Philipp Maieraf58db22020-08-12 17:24:40 +02001211 f_init(1);
Philipp Maier9c60a622020-07-09 15:08:46 +02001212 f_TC_chan_act_ack_noest();
1213}
1214
1215/* Emergency call variant */
1216testcase TC_chan_act_ack_noest_emerg() runs on test_CT {
1217 /* See also: 3GPP TS 04.08, Table 9.9, ra=101xxxxx */
Philipp Maieraf58db22020-08-12 17:24:40 +02001218 f_init(1);
1219 f_vty_allow_emerg_bts(true, 0);
Philipp Maier9c60a622020-07-09 15:08:46 +02001220 f_TC_chan_act_ack_noest(ra := 'A5'O);
1221}
1222
Philipp Maier606f07d2020-08-12 17:21:58 +02001223/* Emergency call variant, but emergency calls are not allowed */
1224testcase TC_chan_rqd_emerg_deny() runs on test_CT {
1225 /* See also: 3GPP TS 04.08, Table 9.9, ra=101xxxxx */
1226
1227 var RSL_Message rx_rsl;
1228 var GsmRrMessage rr;
1229
1230 f_init(1);
1231 f_vty_allow_emerg_bts(false, 0);
1232
1233 IPA_RSL[0].clear;
1234 f_ipa_tx(0, ts_RSL_CHAN_RQD('A5'O, 23));
1235
1236 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeC(RSL_MT_IMMEDIATE_ASSIGN_CMD));
1237 rr := dec_GsmRrMessage(rx_rsl.ies[1].body.full_imm_ass_info.payload);
1238 if (rr.header.message_type == IMMEDIATE_ASSIGNMENT_REJECT) {
1239 setverdict(pass);
1240 } else {
1241 setverdict(fail, "immediate assignment not rejected");
1242 }
1243}
1244
Harald Welteae026692017-12-09 01:03:01 +01001245/* Test behavior if MSC never answers to CR */
1246testcase TC_chan_act_ack_est_ind_noreply() runs on test_CT {
Harald Weltef77aef62018-01-28 15:35:42 +01001247 var RslLinkId main_dcch := valueof(ts_RslLinkID_DCCH(0));
1248 var IpaStreamId sid := IPAC_PROTO_RSL_TRX0;
Harald Welteae026692017-12-09 01:03:01 +01001249 var RSL_Message rx_rsl;
Harald Weltef77aef62018-01-28 15:35:42 +01001250 var ASP_RSL_Unitdata rx_rsl_ud;
Harald Welteae026692017-12-09 01:03:01 +01001251
Harald Welte89d42e82017-12-17 16:42:41 +01001252 f_init(1);
Harald Welteae026692017-12-09 01:03:01 +01001253
1254 /* Send CHAN RQD and wait for allocation; acknowledge it */
Harald Welted6939652017-12-13 21:02:46 +01001255 var RslChannelNr chan_nr := f_chreq_act_ack();
Harald Welteae026692017-12-09 01:03:01 +01001256
1257 var octetstring l3 := '00010203040506'O
1258 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
1259
1260 BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3)));
1261
1262 /* expect BSC to disable the channel again if there's no response from MSC */
Harald Weltef77aef62018-01-28 15:35:42 +01001263 /* MS waits 20s (T3210) at LU; 10s (T3230) at CM SERV REQ and 5s (T3220) AT detach */
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001264 f_expect_chan_rel(0, chan_nr, expect_rll_rel_req := false);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001265 f_shutdown_helper();
Harald Welteae026692017-12-09 01:03:01 +01001266}
1267
1268/* Test behavior if MSC answers with CREF to CR */
1269testcase TC_chan_act_ack_est_ind_refused() runs on test_CT {
1270 var BSSAP_N_CONNECT_ind rx_c_ind;
1271 var RSL_Message rx_rsl;
1272
Harald Welte89d42e82017-12-17 16:42:41 +01001273 f_init(1);
Harald Welteae026692017-12-09 01:03:01 +01001274
1275 /* Send CHAN RQD and wait for allocation; acknowledge it */
Harald Welted6939652017-12-13 21:02:46 +01001276 var RslChannelNr chan_nr := f_chreq_act_ack();
Harald Welteae026692017-12-09 01:03:01 +01001277
1278 var octetstring l3 := '00010203040506'O
1279 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
1280
1281 BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) -> value rx_c_ind;
1282 BSSAP.send(ts_BSSAP_DISC_req(rx_c_ind.connectionId, 0));
1283
1284 /* expect BSC to disable the channel */
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001285 f_expect_chan_rel(0, chan_nr, expect_rll_rel_req := false);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001286 f_shutdown_helper();
Harald Welteae026692017-12-09 01:03:01 +01001287}
1288
Harald Welte618ef642017-12-14 14:58:20 +01001289/* CHAN RQD -> CHAN ACT -> CHAN ACT NACK -> RF CHAN REL */
1290testcase TC_chan_act_nack() runs on test_CT {
1291 var RSL_Message rx_rsl;
1292 var integer chact_nack;
1293
Harald Welte89d42e82017-12-17 16:42:41 +01001294 f_init(1);
Harald Welte618ef642017-12-14 14:58:20 +01001295
1296 chact_nack := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chan_act:nack");
1297
1298 f_ipa_tx(0, ts_RSL_CHAN_RQD('33'O, 33));
1299 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
1300 var RslChannelNr chan_nr := rx_rsl.ies[0].body.chan_nr;
1301
1302 f_ipa_tx(0, ts_RSL_CHAN_ACT_NACK(chan_nr, RSL_ERR_EQUIPMENT_FAIL));
1303
1304 /* wait for some time to hope the NACK arrives before the CTRL GET below */
1305 f_sleep(0.5);
1306
1307 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chan_act:nack", chact_nack+1);
1308
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001309 f_shutdown_helper();
Harald Welte618ef642017-12-14 14:58:20 +01001310}
1311
Harald Welte799c97b2017-12-14 17:50:30 +01001312/* Test for channel exhaustion due to RACH overload */
1313testcase TC_chan_exhaustion() runs on test_CT {
1314 var ASP_RSL_Unitdata rsl_ud;
1315 var integer i;
1316 var integer chreq_total, chreq_nochan;
1317
Harald Welte89d42e82017-12-17 16:42:41 +01001318 f_init(1);
Harald Welte799c97b2017-12-14 17:50:30 +01001319
1320 chreq_total := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total");
1321 chreq_nochan := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:no_channel");
1322
Pau Espin Pedrolfe200d72018-12-10 12:41:04 +01001323 /* GSM 04.08 Table 9.9a:
1324 * RA = '33'O -> Establishment cause = 0011xxxx (MS dual rate capable and asks for "TCH/H or TCH/F").
1325 * With current setup, expect 4xSDCCH + 4xTCH/F + 1xTCH/H to succeed */
Philipp Maiercb6cc482018-03-26 13:08:00 +02001326 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 +01001327 var RslChannelNr chan_nr := f_chreq_act_ack('33'O, i);
Harald Welte799c97b2017-12-14 17:50:30 +01001328 }
1329
1330 IPA_RSL[0].clear;
1331
Harald Weltedd8cbf32018-01-28 12:07:52 +01001332 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total",
Philipp Maiercb6cc482018-03-26 13:08:00 +02001333 chreq_total + NUM_TCHF_PER_BTS + NUM_TCHH_PER_BTS + NUM_SDCCH_PER_BTS);
Harald Welte799c97b2017-12-14 17:50:30 +01001334
1335 /* now expect additional channel activations to fail */
1336 f_ipa_tx(0, ts_RSL_CHAN_RQD('42'O, 42));
1337
1338 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001339 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV))) {
Harald Welte799c97b2017-12-14 17:50:30 +01001340 setverdict(fail, "Received CHAN ACT ACK without resources?!?");
1341 }
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001342 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_IMM_ASSIGN(?))) -> value rsl_ud {
Harald Welte799c97b2017-12-14 17:50:30 +01001343 var GsmRrMessage rr;
1344 /* match on IMM ASS REJ */
1345 rr := dec_GsmRrMessage(rsl_ud.rsl.ies[1].body.full_imm_ass_info.payload);
1346 if (rr.header.message_type == IMMEDIATE_ASSIGNMENT_REJECT) {
1347 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total",
Philipp Maiercb6cc482018-03-26 13:08:00 +02001348 chreq_total + NUM_TCHF_PER_BTS + NUM_TCHH_PER_BTS + NUM_SDCCH_PER_BTS+1);
Harald Welte799c97b2017-12-14 17:50:30 +01001349 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:no_channel",
1350 chreq_nochan+1);
1351 setverdict(pass);
1352 } else {
1353 repeat;
1354 }
1355 }
1356 [] IPA_RSL[0].receive { repeat; }
1357 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001358 f_shutdown_helper();
Harald Welte799c97b2017-12-14 17:50:30 +01001359}
1360
Vadim Yanitskiy1ff1fdf2018-11-27 01:32:57 +07001361/* Test channel deactivation due to silence from MS */
1362testcase TC_chan_deact_silence() runs on test_CT {
1363 var RslChannelNr chan_nr;
1364
1365 f_init(1);
1366
1367 /* Request for a dedicated channel */
1368 chan_nr := f_chreq_act_ack('23'O);
1369
1370 /* Wait some time until the channel is released */
1371 f_sleep(2.0);
1372
1373 /* Expect CHANnel RELease */
1374 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001375 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL))) {
Vadim Yanitskiy1ff1fdf2018-11-27 01:32:57 +07001376 log("Received CHANnel RELease");
1377 setverdict(pass);
1378 }
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001379 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_IMM_ASSIGN(?))) {
Vadim Yanitskiy1ff1fdf2018-11-27 01:32:57 +07001380 /* See OS#3709, OsmoBSC should not send Immediate
1381 * Assignment Reject since a dedicated channel was
1382 * already allocated, and Immediate Assignment was
1383 * already sent. */
1384 setverdict(fail, "Unexpected Immediate Assignment!");
1385 }
1386 [] IPA_RSL[0].receive {
1387 setverdict(fail, "Unexpected RSL message!");
1388 }
1389 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001390 f_shutdown_helper();
Vadim Yanitskiy1ff1fdf2018-11-27 01:32:57 +07001391}
1392
Harald Weltecfe2c962017-12-15 12:09:32 +01001393/***********************************************************************
1394 * Assignment Testing
1395 ***********************************************************************/
1396
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02001397/* Verify that the BSC refuses any BSSAP connection from the MSC (They are all BSC->MSC direction,
1398 * except for the inter-BSC handover, MT side) */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001399testcase TC_outbound_connect(integer bssap_idx := 0) runs on test_CT {
Harald Welte89d42e82017-12-17 16:42:41 +01001400 f_init(1);
Harald Weltecfe2c962017-12-15 12:09:32 +01001401
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001402 BSSAP.send(ts_BSSAP_CONNECT_req(g_bssap[bssap_idx].sccp_addr_peer, g_bssap[bssap_idx].sccp_addr_own,
1403 2342, ts_BSSMAP_AssignmentReq));
Harald Weltecfe2c962017-12-15 12:09:32 +01001404 BSSAP.receive(tr_BSSAP_DISC_ind(2342, ?, ?));
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001405 f_shutdown_helper();
Harald Weltecfe2c962017-12-15 12:09:32 +01001406}
1407
Harald Welte16a4adf2017-12-14 18:54:01 +01001408/* Test behavior if MSC answers with CREF to CR */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001409testcase TC_assignment_cic_only(integer bssap_idx := 0) runs on test_CT {
Harald Welte16a4adf2017-12-14 18:54:01 +01001410 var BSSAP_N_CONNECT_ind rx_c_ind;
1411 var RSL_Message rx_rsl;
1412 var DchanTuple dt;
1413
Harald Welte89d42e82017-12-17 16:42:41 +01001414 f_init(1);
Harald Welte16a4adf2017-12-14 18:54:01 +01001415
1416 dt := f_est_dchan('23'O, 23, '00000000'O);
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001417 if (mp_bssap_cfg[bssap_idx].transport == BSSAP_TRANSPORT_AoIP) {
Harald Welte17b27da2018-05-25 20:33:53 +02001418 /* send assignment without AoIP IEs */
1419 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_AssignmentReq(ts_BSSMAP_IE_CIC(0, 1))));
1420 } else {
1421 /* Send assignmetn without CIC in IPA case */
1422 var BSSMAP_IE_AoIP_TransportLayerAddress tla :=
1423 valueof(ts_BSSMAP_IE_AoIP_TLA4('01020304'O, 2342));
1424 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_AssignmentReq(omit, tla)));
1425 }
Harald Welte16a4adf2017-12-14 18:54:01 +01001426 alt {
1427 [] BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_AssignmentComplete)) {
1428 setverdict(fail, "AoIP BSC cannot accept ASSIGNMENT without AoIP Transport IE");
1429 }
Harald Welte235ebf12017-12-15 14:18:16 +01001430 /* TODO: Actually expect GSM0808_CAUSE_REQ_A_IF_TYPE_NOT_SUPP */
Harald Welte16a4adf2017-12-14 18:54:01 +01001431 [] BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_AssignmentFail)) {
1432 setverdict(pass);
1433 }
1434 [] BSSAP.receive { repeat; }
1435 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001436 f_shutdown_helper();
Harald Welte16a4adf2017-12-14 18:54:01 +01001437}
1438
Harald Welteed848512018-05-24 22:27:58 +02001439/* generate an assignment request for either AoIP or SCCPlite */
Pau Espin Pedrol07866632020-09-03 19:10:55 +02001440function 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 +02001441 var PDU_BSSAP ass_cmd;
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02001442 var BSSMAP_IE_Osmo_OsmuxCID osmux_cid := valueof(ts_OsmuxCID(0));
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001443 if (mp_bssap_cfg[bssap_idx].transport == BSSAP_TRANSPORT_AoIP) {
Harald Welteed848512018-05-24 22:27:58 +02001444 var BSSMAP_IE_AoIP_TransportLayerAddress tla :=
Pau Espin Pedrol07866632020-09-03 19:10:55 +02001445 valueof(f_ts_BSSMAP_IE_AoIP_TLA(aoip_tla, 2342));
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02001446 if (osmux_enabled) {
1447 ass_cmd := valueof(ts_BSSMAP_AssignmentReq(omit, tla, osmux_cid));
1448 } else {
1449 ass_cmd := valueof(ts_BSSMAP_AssignmentReq(omit, tla));
1450 }
Harald Welteed848512018-05-24 22:27:58 +02001451 } else {
1452 var BSSMAP_IE_CircuitIdentityCode cic := valueof(ts_BSSMAP_IE_CIC(0,1));
Pau Espin Pedrol096d73d2019-06-06 12:49:17 +02001453 ass_cmd := valueof(ts_BSSMAP_AssignmentReq(cic, omit));
Harald Welteed848512018-05-24 22:27:58 +02001454 }
1455 return ass_cmd;
1456}
1457
Pau Espin Pedrol07866632020-09-03 19:10:55 +02001458function f_gen_handover_req(integer bssap_idx := 0, charstring aoip_tla := "1.2.3.4") return PDU_BSSAP {
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01001459 var PDU_BSSAP ho_req;
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001460 if (mp_bssap_cfg[bssap_idx].transport == BSSAP_TRANSPORT_AoIP) {
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01001461 var BSSMAP_IE_AoIP_TransportLayerAddress tla :=
Pau Espin Pedrol07866632020-09-03 19:10:55 +02001462 valueof(f_ts_BSSMAP_IE_AoIP_TLA(aoip_tla, 2342));
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01001463 ho_req := valueof(ts_BSSMAP_HandoverRequest(omit, tla));
1464 } else {
1465 var BSSMAP_IE_CircuitIdentityCode cic := valueof(ts_BSSMAP_IE_CIC(0,1));
1466 ho_req := valueof(ts_BSSMAP_HandoverRequest(cic, omit));
1467 }
1468 return ho_req;
1469}
1470
Harald Welteed848512018-05-24 22:27:58 +02001471/* generate an assignment complete template for either AoIP or SCCPlite */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001472function f_gen_exp_compl(boolean expect_osmux := false, integer bssap_idx := 0) return template PDU_BSSAP {
Harald Welteed848512018-05-24 22:27:58 +02001473 var template PDU_BSSAP exp_compl;
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02001474 var BSSMAP_IE_Osmo_OsmuxCID osmux_cid := valueof(ts_OsmuxCID(0));
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001475 if (mp_bssap_cfg[bssap_idx].transport == BSSAP_TRANSPORT_AoIP) {
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02001476 if (expect_osmux) {
1477 exp_compl := tr_BSSMAP_AssignmentComplete(omit, ?, osmux_cid);
1478 } else {
1479 exp_compl := tr_BSSMAP_AssignmentComplete(omit, ?, omit);
1480 }
Harald Welteed848512018-05-24 22:27:58 +02001481 } else {
1482 /* CIC is optional "*" as the MSC allocated it */
Pau Espin Pedrol096d73d2019-06-06 12:49:17 +02001483 exp_compl := tr_BSSMAP_AssignmentComplete(*, omit);
Harald Welteed848512018-05-24 22:27:58 +02001484 }
1485 return exp_compl;
1486}
1487
Harald Welte235ebf12017-12-15 14:18:16 +01001488/* Run everything required up to sending a caller-specified assignment command and expect response */
1489function f_assignment_exp(PDU_BSSAP ass_cmd, template PDU_BSSAP exp, charstring fail_text)
1490runs on test_CT {
1491 var BSSAP_N_CONNECT_ind rx_c_ind;
1492 var RSL_Message rx_rsl;
1493 var DchanTuple dt;
1494
Harald Welte89d42e82017-12-17 16:42:41 +01001495 f_init(1);
Harald Welte235ebf12017-12-15 14:18:16 +01001496
1497 dt := f_est_dchan('23'O, 23, '00000000'O);
1498 /* send assignment without AoIP IEs */
1499 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ass_cmd));
1500 alt {
1501 [] BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_AssignmentComplete)) {
1502 if (ischosen(exp.pdu.bssmap.assignmentComplete)) {
1503 setverdict(pass);
1504 } else {
1505 setverdict(fail, fail_text);
1506 }
1507 }
1508 [] BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_AssignmentFail)) {
1509 if (ischosen(exp.pdu.bssmap.assignmentFailure)) {
1510 setverdict(pass);
1511 } else {
1512 setverdict(fail, fail_text);
1513 }
1514 }
1515 [] BSSAP.receive { repeat; }
1516 }
1517}
1518testcase TC_assignment_csd() runs on test_CT {
1519 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
Harald Welteed848512018-05-24 22:27:58 +02001520 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte235ebf12017-12-15 14:18:16 +01001521 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeCSD);
1522 //exp_fail.pdu.bssmap.assignmentFailure.cause.causeValue := int2bit(enum2int(GSM0808_CAUSE_REQ_CODEC_TYPE_OR_CONFIG_UNAVAIL), 7);
1523 f_assignment_exp(ass_cmd, exp_fail, "BSC accepted Assignment for CSD");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001524 f_shutdown_helper();
Harald Welte235ebf12017-12-15 14:18:16 +01001525}
1526
1527testcase TC_assignment_ctm() runs on test_CT {
1528 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
Harald Welteed848512018-05-24 22:27:58 +02001529 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte235ebf12017-12-15 14:18:16 +01001530 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeCTM);
1531 //exp_fail.pdu.bssmap.assignmentFailure.cause.causeValue := int2bit(enum2int(GSM0808_CAUSE_REQ_CODEC_TYPE_OR_CONFIG_UNAVAIL), 7);
1532 f_assignment_exp(ass_cmd, exp_fail, "BSC accepted Assignment for Speech+CTM");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001533 f_shutdown_helper();
Harald Welte235ebf12017-12-15 14:18:16 +01001534}
1535
Harald Welte4003d112017-12-09 22:35:39 +01001536type record DchanTuple {
1537 integer sccp_conn_id,
1538 RslChannelNr rsl_chan_nr
Harald Weltea5d2ab22017-12-09 14:21:42 +01001539}
1540
Harald Welted6939652017-12-13 21:02:46 +01001541/* Send CHAN RQD and wait for allocation; acknowledge it */
1542private function f_chreq_act_ack(OCT1 ra := '23'O, GsmFrameNumber fn := 23)
1543runs on test_CT return RslChannelNr {
1544 var RSL_Message rx_rsl;
1545 f_ipa_tx(0, ts_RSL_CHAN_RQD(ra, fn));
1546 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
1547 var RslChannelNr chan_nr := rx_rsl.ies[0].body.chan_nr;
1548 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, fn+10));
Daniel Willmannf4ac4ce2018-08-02 14:06:30 +02001549 rx_rsl := f_exp_ipa_rx(0, tr_RSL_IMM_ASSIGN(0));
Harald Welted6939652017-12-13 21:02:46 +01001550 return chan_nr;
1551}
1552
Harald Welte4003d112017-12-09 22:35:39 +01001553/* helper function to establish a dedicated channel via BTS and MSC */
1554function f_est_dchan(OCT1 ra, GsmFrameNumber fn, octetstring l3)
1555runs on test_CT return DchanTuple {
1556 var BSSAP_N_CONNECT_ind rx_c_ind;
Harald Welte4003d112017-12-09 22:35:39 +01001557 var DchanTuple dt;
Harald Weltea5d2ab22017-12-09 14:21:42 +01001558
Harald Welte4003d112017-12-09 22:35:39 +01001559 /* Send CHAN RQD and wait for allocation; acknowledge it */
Harald Welted6939652017-12-13 21:02:46 +01001560 dt.rsl_chan_nr := f_chreq_act_ack(ra, fn);
Harald Welte4003d112017-12-09 22:35:39 +01001561
1562 f_ipa_tx(0, ts_RSL_EST_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
1563
1564 BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) -> value rx_c_ind;
1565 dt.sccp_conn_id := rx_c_ind.connectionId;
1566 BSSAP.send(ts_BSSAP_CONNECT_res(dt.sccp_conn_id));
1567
1568 return dt;
Harald Weltea5d2ab22017-12-09 14:21:42 +01001569}
1570
Harald Welte641fcbe2018-06-14 10:58:35 +02001571/* expect RF CAN REL from BTS, acknowledge it and clear the MSC side */
1572private function f_exp_chan_rel_and_clear(DchanTuple dt, integer bts_nr := 0) runs on test_CT {
1573 var RSL_Message rx_rsl;
1574 /* expect BSC to disable the channel */
1575 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), T3101_MAX);
1576 /* respond with CHAN REL ACK */
1577 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(dt.rsl_chan_nr));
1578
1579 /* expect Clear Complete from BSC */
1580 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete));
1581
1582 /* MSC disconnects as instructed. */
1583 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
1584}
1585
Harald Welte4003d112017-12-09 22:35:39 +01001586/* Test behavior of channel release after unilateral RLL REL IND (DISC from MS) */
1587testcase TC_chan_rel_rll_rel_ind() runs on test_CT {
Neels Hofmeyr27f64362018-03-12 01:44:00 +01001588 var BSSAP_N_DATA_ind rx_di;
Harald Welte4003d112017-12-09 22:35:39 +01001589 var DchanTuple dt;
Harald Welte96c94412017-12-09 03:12:45 +01001590
Harald Welte89d42e82017-12-17 16:42:41 +01001591 f_init(1);
Harald Welte96c94412017-12-09 03:12:45 +01001592
Harald Welte4003d112017-12-09 22:35:39 +01001593 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1594
1595 /* simulate RLL REL IND */
1596 f_ipa_tx(0, ts_RSL_REL_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0))));
1597
Neels Hofmeyr27f64362018-03-12 01:44:00 +01001598 /* expect Clear Request on MSC side */
1599 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearRequest)) -> value rx_di;
1600
1601 /* Instruct BSC to clear channel */
1602 var BssmapCause cause := bit2int(rx_di.userData.pdu.bssmap.clearRequest.cause.causeValue);
1603 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
1604
Harald Welte4003d112017-12-09 22:35:39 +01001605 /* expect BSC to disable the channel */
Harald Welte641fcbe2018-06-14 10:58:35 +02001606 f_exp_chan_rel_and_clear(dt, 0);
Neels Hofmeyr27f64362018-03-12 01:44:00 +01001607
1608 /* wait for SCCP emulation to do its job */
1609 f_sleep(1.0);
Harald Welte4003d112017-12-09 22:35:39 +01001610
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001611 f_shutdown_helper();
Harald Welte4003d112017-12-09 22:35:39 +01001612}
1613
1614/* Test behavior of channel release after CONN FAIL IND from BTS */
1615testcase TC_chan_rel_conn_fail() runs on test_CT {
1616 var BSSAP_N_DATA_ind rx_di;
Harald Welte4003d112017-12-09 22:35:39 +01001617 var DchanTuple dt;
1618
Harald Welte89d42e82017-12-17 16:42:41 +01001619 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +01001620
1621 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1622
1623 /* simulate CONN FAIL IND */
Harald Weltea8ed9062017-12-14 09:46:01 +01001624 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 +01001625 /* TODO: different cause values? */
1626
Harald Welte4003d112017-12-09 22:35:39 +01001627 /* expect Clear Request from BSC */
1628 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearRequest)) -> value rx_di;
1629
1630 /* Instruct BSC to clear channel */
1631 var BssmapCause cause := bit2int(rx_di.userData.pdu.bssmap.clearRequest.cause.causeValue);
1632 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
1633
Harald Welte6ff76ea2018-01-28 13:08:01 +01001634 /* expect BSC to disable the channel */
Harald Welte641fcbe2018-06-14 10:58:35 +02001635 f_exp_chan_rel_and_clear(dt, 0);
Harald Welte4003d112017-12-09 22:35:39 +01001636
1637 /* wait for SCCP emulation to do its job */
1638 f_sleep(1.0);
1639
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001640 f_shutdown_helper();
Harald Welte4003d112017-12-09 22:35:39 +01001641}
1642
Harald Welte99f3ca02018-06-14 13:40:29 +02001643/* Test behavior of early CONN FAIL IND from BTS (before EST IND!) */
1644/* See also https://www.osmocom.org/issues/3182 */
1645testcase TC_early_conn_fail() runs on test_CT {
1646 var RSL_Message rx_rsl;
1647 var DchanTuple dt;
1648
1649 f_init(1);
1650
1651 /* BTS->BSC: Send CHAN RQD and wait for allocation; acknowledge it */
Harald Weltec46ea3c2020-10-10 18:46:12 +02001652 dt.rsl_chan_nr := f_chreq_act_ack(f_rnd_ra_cs(), 23);
Harald Welte99f3ca02018-06-14 13:40:29 +02001653
1654 /* BTS->BSC: simulate CONN FAIL IND */
1655 f_ipa_tx(0, ts_RSL_CONN_FAIL_IND(dt.rsl_chan_nr, RSL_ERR_RADIO_LINK_FAIL));
1656
1657 /* BTS->BSC: Expect RF channel release from BSC on Abis */
1658 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), 10.0);
1659
1660 /* BTS<-BSC: respond with CHAN REL ACK */
1661 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(dt.rsl_chan_nr));
1662
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001663 f_shutdown_helper();
Harald Welte99f3ca02018-06-14 13:40:29 +02001664}
1665
1666/* Test behavior of late CONN FAIL IND from BTS (ater REL IND!) */
1667/* See also https://www.osmocom.org/issues/3182 */
1668testcase TC_late_conn_fail() runs on test_CT {
1669 var RSL_Message rx_rsl;
1670 var DchanTuple dt;
1671
1672 f_init(1);
1673
1674 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1675
1676 /* BSC<-MSC: Instruct BSC to clear connection */
1677 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(0)));
1678
1679 /* BTS->BSC: expect BSC to deactivate SACCH */
1680 rx_rsl := f_exp_ipa_rx(0, tr_RSL_DEACT_SACCH(dt.rsl_chan_nr));
1681
1682 /* BTS->BSC: simulate a late CONN FAIL IND from BTS */
1683 f_ipa_tx(0, ts_RSL_CONN_FAIL_IND(dt.rsl_chan_nr, RSL_ERR_RADIO_LINK_FAIL));
1684
1685 /* BTS<-BSC: Expect RF channel release from BSC on Abis */
1686 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), 10.0);
1687 /* BTS->BSC: respond with CHAN REL ACK */
1688 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(dt.rsl_chan_nr));
1689
1690 /* BSC->MSC: expect Clear Complete from BSC */
1691 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete));
1692
1693 /* BSC<-MSC: MSC disconnects as requested. */
1694 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
1695
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001696 f_shutdown_helper();
Harald Welte99f3ca02018-06-14 13:40:29 +02001697}
1698
Neels Hofmeyrf44ccd12018-11-05 19:15:23 +01001699function f_expect_chan_rel(integer bts_nr, RslChannelNr rsl_chan_nr,
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001700 boolean expect_deact_sacch := true,
1701 boolean expect_rr_chan_rel := true,
1702 boolean expect_rll_rel_req := true,
Harald Welte99787102019-02-04 10:41:36 +01001703 boolean handle_rll_rel := true,
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02001704 boolean is_csfb := false,
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02001705 template CellSelIndValue csfb_expect_cells := omit,
1706 template RR_Cause expect_rr_cause := ?
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001707 ) runs on test_CT {
Harald Welte91d54a52018-01-28 15:35:07 +01001708
1709 var RslLinkId main_dcch := valueof(ts_RslLinkID_DCCH(0));
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001710 var boolean got_deact_sacch := false;
1711 var boolean got_rr_chan_rel := false;
1712 var boolean got_rll_rel_req := false;
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02001713 var ASP_RSL_Unitdata ud;
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02001714 var RSL_IE_Body l3_ie;
1715 var PDU_ML3_NW_MS l3;
1716 var RR_Cause got_cause;
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001717 log("f_expect_chan_rel() expecting: expect_deact_sacch=", expect_deact_sacch, " expect_rr_chan_rel=", expect_rr_chan_rel,
1718 " expect_rll_rel_req=", expect_rll_rel_req);
Harald Welte91d54a52018-01-28 15:35:07 +01001719 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001720 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(tr_RSL_DEACT_SACCH(rsl_chan_nr))) {
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001721 got_deact_sacch := true;
Harald Welte91d54a52018-01-28 15:35:07 +01001722 repeat;
1723 }
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02001724 [is_csfb] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(tr_RSL_DATA_REQ(rsl_chan_nr, ?, decmatch tr_RRM_RR_RELEASE_CSFB))) -> value ud {
Harald Welte99787102019-02-04 10:41:36 +01001725 got_rr_chan_rel := true;
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02001726
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02001727 if (f_rsl_find_ie(ud.rsl, RSL_IE_L3_INFO, l3_ie) == false) {
1728 setverdict(fail, "cannot find L3");
1729 mtc.stop;
1730 }
1731 l3 := dec_PDU_ML3_NW_MS(l3_ie.l3_info.payload);
1732
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02001733 if (not istemplatekind(csfb_expect_cells, "omit")) {
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02001734 var CellSelIndValue cells := dec_CellSelIndValue(
1735 l3.msgs.rrm.channelRelease.cellSelectionIndicator.cellSelectionIndicatorValue);
1736
1737 log("GOT RR CHANNEL RELEASE CSFB CELLS: ", cells);
1738 if (match(cells, csfb_expect_cells)) {
1739 setverdict(pass);
1740 } else {
1741 log("EXPECTED CSFB CELLS: ", csfb_expect_cells);
1742 setverdict(fail, "Received CSFB cells list on RR Channel Release does not match expectations");
1743 }
1744 }
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02001745
1746 if (not istemplatekind(expect_rr_cause, "omit")) {
1747 int2enum(oct2int(l3.msgs.rrm.channelRelease.rRCause.valuePart), got_cause);
1748 log("GOT CAUSE CODE: ", l3.msgs.rrm.channelRelease.rRCause.valuePart, " = ", got_cause);
1749 if (match(got_cause, expect_rr_cause)) {
1750 setverdict(pass);
1751 } else {
1752 log("EXPECTED CAUSE CODE: ", expect_rr_cause);
1753 setverdict(fail, "Received RR Channel Release Cause code does not match expectations");
1754 }
1755 }
Harald Welte99787102019-02-04 10:41:36 +01001756 repeat;
1757 }
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02001758 [not is_csfb] 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 +01001759 got_rr_chan_rel := true;
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02001760
1761 if (not istemplatekind(expect_rr_cause, "omit")) {
1762 if (f_rsl_find_ie(ud.rsl, RSL_IE_L3_INFO, l3_ie) == false) {
1763 setverdict(fail, "cannot find L3");
1764 mtc.stop;
1765 }
1766 l3 := dec_PDU_ML3_NW_MS(l3_ie.l3_info.payload);
1767
1768 int2enum(oct2int(l3.msgs.rrm.channelRelease.rRCause.valuePart), got_cause);
1769 log("GOT CAUSE CODE: ", l3.msgs.rrm.channelRelease.rRCause.valuePart, " = ", got_cause);
1770 if (match(got_cause, expect_rr_cause)) {
1771 setverdict(pass);
1772 } else {
1773 log("EXPECTED CAUSE CODE: ", expect_rr_cause);
1774 setverdict(fail, "Received RR Channel Release Cause code does not match expectations");
1775 }
1776 }
Neels Hofmeyr211169d2018-11-07 00:37:29 +01001777 repeat;
1778 }
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001779 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(tr_RSL_REL_REQ(rsl_chan_nr, ?))) {
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001780 got_rll_rel_req := true;
Harald Welte91d54a52018-01-28 15:35:07 +01001781 /* FIXME: Why are we getting this for LinkID SACCH? */
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001782 if (handle_rll_rel) {
1783 f_ipa_tx(0, ts_RSL_REL_CONF(rsl_chan_nr, main_dcch));
1784 }
Harald Welte91d54a52018-01-28 15:35:07 +01001785 repeat;
1786 }
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001787 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL))) {
Harald Welte91d54a52018-01-28 15:35:07 +01001788 /* respond with CHAN REL ACK */
1789 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(rsl_chan_nr));
1790 }
1791 /* ignore any user data */
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001792 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(tr_RSL_MsgTypeR(?))) {
Harald Welte91d54a52018-01-28 15:35:07 +01001793 repeat;
1794 }
1795 }
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001796
1797 log("f_expect_chan_rel() summary: got_deact_sacch=", got_deact_sacch, " got_rr_chan_rel=", got_rr_chan_rel,
1798 " got_rll_rel_req=", got_rll_rel_req);
1799
1800 if (expect_deact_sacch != got_deact_sacch) {
1801 setverdict(fail, "f_expect_chan_rel(): expect_deact_sacch=", expect_deact_sacch, " got_deact_sacch=", got_deact_sacch);
1802 }
1803 if (expect_rr_chan_rel != got_rr_chan_rel) {
1804 setverdict(fail, "f_expect_chan_rel(): expect_rr_chan_rel=", expect_rr_chan_rel, " got_rr_chan_rel=", got_rr_chan_rel);
1805 }
1806 if (expect_rll_rel_req != got_rll_rel_req) {
1807 setverdict(fail, "f_expect_chan_rel(): expect_rll_rel_req=", expect_rll_rel_req, " got_rll_rel_req=", got_rll_rel_req);
1808 }
Harald Welte91d54a52018-01-28 15:35:07 +01001809}
1810
Harald Welte4003d112017-12-09 22:35:39 +01001811/* Test behavior of channel release after hard Clear Command from MSC */
1812testcase TC_chan_rel_hard_clear() runs on test_CT {
1813 var BSSAP_N_DATA_ind rx_di;
Harald Welte4003d112017-12-09 22:35:39 +01001814 var DchanTuple dt;
Harald Welte4003d112017-12-09 22:35:39 +01001815
Harald Welte89d42e82017-12-17 16:42:41 +01001816 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +01001817
1818 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1819
1820 /* Instruct BSC to clear channel */
1821 var BssmapCause cause := 0;
1822 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
1823
1824 /* expect Clear Complete from BSC on A */
1825 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete)) {
1826 /* release the SCCP connection */
1827 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
1828 }
1829
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001830 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001831 f_shutdown_helper();
Harald Welte4003d112017-12-09 22:35:39 +01001832}
1833
Harald Welte99787102019-02-04 10:41:36 +01001834/* Test behavior of channel release after Clear Command with CSFB indicator from MSC */
1835testcase TC_chan_rel_hard_clear_csfb() runs on test_CT {
1836 var BSSAP_N_DATA_ind rx_di;
1837 var DchanTuple dt;
1838
1839 f_init(1);
1840
1841 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1842
1843 /* Instruct BSC to clear channel */
1844 var BssmapCause cause := 0;
1845 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommandCSFB(cause)));
1846
1847 /* expect Clear Complete from BSC on A */
1848 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete)) {
1849 /* release the SCCP connection */
1850 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
1851 }
1852
1853 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false, is_csfb := true);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001854 f_shutdown_helper();
Harald Welte99787102019-02-04 10:41:36 +01001855}
1856
Harald Welted8c36cd2017-12-09 23:05:31 +01001857/* Test behavior of channel release after hard RLSD from MSC */
1858testcase TC_chan_rel_hard_rlsd() runs on test_CT {
Harald Welted8c36cd2017-12-09 23:05:31 +01001859 var DchanTuple dt;
Harald Welted8c36cd2017-12-09 23:05:31 +01001860
Harald Welte89d42e82017-12-17 16:42:41 +01001861 f_init(1);
Harald Welted8c36cd2017-12-09 23:05:31 +01001862
1863 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1864
1865 /* release the SCCP connection */
1866 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
1867
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001868 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001869 f_shutdown_helper();
Harald Welted8c36cd2017-12-09 23:05:31 +01001870}
1871
Harald Welte550daf92018-06-11 19:22:13 +02001872/* Test behavior of channel release after hard RLSD from MSC and MS is not responding to RLL REL REQ */
1873testcase TC_chan_rel_hard_rlsd_ms_dead() runs on test_CT {
1874 var DchanTuple dt;
1875
1876 f_init(1);
1877
1878 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1879
1880 /* release the SCCP connection */
1881 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
1882
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001883 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001884 f_shutdown_helper();
Harald Welte550daf92018-06-11 19:22:13 +02001885}
1886
Harald Welte85804d42017-12-10 14:11:58 +01001887/* Test behavior of channel release after BSSMAP RESET from MSC */
1888testcase TC_chan_rel_a_reset() runs on test_CT {
Harald Welte85804d42017-12-10 14:11:58 +01001889 var DchanTuple dt;
Harald Welte85804d42017-12-10 14:11:58 +01001890
Harald Welte89d42e82017-12-17 16:42:41 +01001891 f_init(1);
Harald Welte85804d42017-12-10 14:11:58 +01001892
1893 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1894
1895 /* Clear the queue, it might still contain stuff like IMMEDIATE ASSIGN */
1896 IPA_RSL[0].clear;
1897
1898 /* perform BSSAP RESET, expect RESET ACK and DISC.ind on connection */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001899 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 +01001900 interleave {
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001901 [] 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 +01001902 [] BSSAP.receive(tr_BSSAP_DISC_ind(dt.sccp_conn_id, ?, ?)) { }
1903 }
1904
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001905 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001906 f_shutdown_helper();
Harald Welte85804d42017-12-10 14:11:58 +01001907}
1908
Pau Espin Pedrolc675b612020-01-09 19:55:40 +01001909/* Verify T(iar) triggers and releases the channel */
1910testcase TC_chan_rel_sccp_tiar_timeout() runs on test_CT {
1911 var DchanTuple dt;
1912
1913 /* Set T(iar) in BSC low enough that it will trigger before other side
1914 has time to keep alive with a T(ias). Keep recommended ratio of
1915 T(iar) >= T(ias)*2 */
1916 g_bsc_sccp_timer_ias := 2;
1917 g_bsc_sccp_timer_iar := 5;
1918
1919 f_init(1);
1920
1921 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1922 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001923 f_shutdown_helper();
Pau Espin Pedrolc675b612020-01-09 19:55:40 +01001924}
1925
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02001926private function f_tc_chan_rel_rr_cause(myBSSMAP_Cause clear_cmd_cause, template RR_Cause expect_rr_cause)
1927runs on test_CT
1928{
1929 var DchanTuple dt;
1930
1931 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1932 var BssmapCause cause := 0;
1933 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(enum2int(clear_cmd_cause))));
1934 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete)) {
1935 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
1936 }
1937
1938 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false, expect_rr_cause := expect_rr_cause);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001939 f_shutdown_helper();
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02001940}
1941
1942/* Test that Clear Command cause codes affect the RR Channel Release cause code */
1943testcase TC_chan_rel_rr_cause() runs on test_CT {
1944 f_init(1);
1945
1946 f_tc_chan_rel_rr_cause(GSM0808_CAUSE_CALL_CONTROL, GSM48_RR_CAUSE_NORMAL);
1947 f_tc_chan_rel_rr_cause(GSM0808_CAUSE_HANDOVER_SUCCESSFUL, GSM48_RR_CAUSE_NORMAL);
1948 f_tc_chan_rel_rr_cause(GSM0808_CAUSE_PREEMPTION, GSM48_RR_CAUSE_PREMPTIVE_REL);
1949 f_tc_chan_rel_rr_cause(GSM0808_CAUSE_RADIO_INTERFACE_MESSAGE_FAILURE, GSM48_RR_CAUSE_PROT_ERROR_UNSPC);
1950 f_tc_chan_rel_rr_cause(GSM0808_CAUSE_RADIO_INTERFACE_FAILURE, GSM48_RR_CAUSE_ABNORMAL_UNSPEC);
1951 f_tc_chan_rel_rr_cause(GSM0808_CAUSE_EQUIPMENT_FAILURE, GSM48_RR_CAUSE_ABNORMAL_UNSPEC);
1952}
1953
Harald Welte5cd20ed2017-12-13 21:03:20 +01001954/* Test behavior if RSL EST IND for non-active channel */
1955testcase TC_rll_est_ind_inact_lchan() runs on test_CT {
1956 timer T := 2.0;
1957
Harald Welte89d42e82017-12-17 16:42:41 +01001958 f_init(1);
Harald Welte5cd20ed2017-12-13 21:03:20 +01001959
1960 var octetstring l3 := '00010203040506'O;
1961 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(6));
1962 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
1963
1964 T.start;
1965 alt {
1966 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) {
1967 setverdict(fail, "MSC received COMPL L3 for non-active lchan");
1968 }
1969 [] BSSAP.receive {}
1970 [] IPA_RSL[0].receive {}
1971 [] T.timeout {}
1972 }
1973
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001974 f_shutdown_helper();
Harald Welte5cd20ed2017-12-13 21:03:20 +01001975}
1976
1977/* Test behavior if RSL EST IND for invalid SAPI */
1978testcase TC_rll_est_ind_inval_sapi1() runs on test_CT {
1979 var RslChannelNr chan_nr;
1980
Harald Welte89d42e82017-12-17 16:42:41 +01001981 f_init(1);
Harald Welte5cd20ed2017-12-13 21:03:20 +01001982
1983 chan_nr := f_chreq_act_ack()
1984
1985 var octetstring l3 := '00010203040506'O;
1986 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(1)), l3));
1987
1988 timer T := 2.0;
1989 T.start;
1990 alt {
1991 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) {
1992 setverdict(fail, "MSC received COMPL L3 for invalid SAPI 1");
1993 }
1994 [] BSSAP.receive { repeat; }
1995 [] IPA_RSL[0].receive { repeat; }
1996 [] T.timeout {}
1997 }
1998
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001999 f_shutdown_helper();
Harald Welte5cd20ed2017-12-13 21:03:20 +01002000}
2001
2002/* Test behavior if RSL EST IND for invalid SAPI */
2003testcase TC_rll_est_ind_inval_sapi3() runs on test_CT {
2004 timer T := 2.0;
2005
Harald Welte89d42e82017-12-17 16:42:41 +01002006 f_init(1);
Harald Welte5cd20ed2017-12-13 21:03:20 +01002007
2008 var RslChannelNr chan_nr := f_chreq_act_ack();
2009
2010 var octetstring l3 := '00010203040506'O;
2011 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(3)), l3));
2012
2013 T.start;
2014 alt {
2015 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) {
2016 setverdict(fail, "MSC received COMPL L3 for invalid SAPI 3");
2017 }
2018 [] BSSAP.receive { repeat; }
2019 [] IPA_RSL[0].receive { repeat; }
2020 [] T.timeout {}
2021 }
2022
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002023 f_shutdown_helper();
Harald Welte5cd20ed2017-12-13 21:03:20 +01002024}
2025
2026/* Test behavior if RSL EST IND for invalid SACCH */
2027testcase TC_rll_est_ind_inval_sacch() runs on test_CT {
2028 timer T := 2.0;
2029
Harald Welte89d42e82017-12-17 16:42:41 +01002030 f_init(1);
Harald Welte5cd20ed2017-12-13 21:03:20 +01002031
2032 var RslChannelNr chan_nr := f_chreq_act_ack();
2033
2034 var octetstring l3 := '00010203040506'O;
2035 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_SACCH(0)), l3));
2036
2037 T.start;
2038 alt {
2039 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) {
2040 setverdict(fail, "MSC received COMPL L3 for invalid Link SACCH");
2041 }
2042 [] BSSAP.receive { repeat; }
2043 [] IPA_RSL[0].receive { repeat; }
2044 [] T.timeout {}
2045 }
2046
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002047 f_shutdown_helper();
Harald Welte5cd20ed2017-12-13 21:03:20 +01002048}
2049
Vadim Yanitskiy61f784a2020-10-01 21:12:19 +07002050/* Verify DLCI / RSL Link ID conversion for MO/MT messages on SAPI0/SAPI3 */
2051private function f_TC_tch_dlci_link_id_sapi(charstring id) runs on MSC_ConnHdlr {
2052 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
2053 var PDU_BSSAP ass_cmd := f_gen_ass_req();
2054
2055 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
2056 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
2057
2058 f_establish_fully(ass_cmd, exp_compl);
2059
2060 /* SAPI0 has already been established by f_establish_fully(), establish SAPI3 */
2061 RSL.send(ts_RSL_EST_IND(g_chan_nr, ts_RslLinkID_SACCH(3), '0904'O));
2062 /* Expect BSSAP/DTAP on SAPI3 (DLCI IE) */
2063 BSSAP.receive(PDU_BSSAP:{
2064 discriminator := '1'B,
2065 spare := '0000000'B,
2066 dlci := 'C3'O,
2067 lengthIndicator := ?,
2068 pdu := { dtap := '0904'O }
2069 });
2070
2071 /* Send messages on DCCH/SAPI0 and ACCH/SAPI3 */
2072 for (var integer i := 0; i < 32; i := i + 1) {
2073 var octetstring l3 := '09'O & f_rnd_octstring(14);
2074 var template (value) RslLinkId link_id;
2075 var template (value) OCT1 dlci;
2076
2077 if (i mod 2 == 0) {
2078 /* SAPI0 on FACCH or SDCCH */
2079 link_id := ts_RslLinkID_DCCH(0);
2080 dlci := '80'O;
2081 } else {
2082 /* SAPI3 on SACCH */
2083 link_id := ts_RslLinkID_SACCH(3);
2084 dlci := 'C3'O;
2085 }
2086
2087 /* Send MO message: RSL -> BSSAP */
2088 f_mo_l3_transceive(link_id, dlci, l3);
2089 /* Send MT message: BSSAP -> RSL */
2090 f_mt_l3_transceive(link_id, dlci, l3);
2091 }
2092}
2093testcase TC_tch_dlci_link_id_sapi() runs on test_CT {
2094 var TestHdlrParams pars := f_gen_test_hdlr_pars();
2095 var MSC_ConnHdlr vc_conn;
2096
2097 f_init(1, true);
2098 f_sleep(1.0);
2099
2100 vc_conn := f_start_handler(refers(f_TC_tch_dlci_link_id_sapi), pars);
2101 vc_conn.done;
2102
2103 f_shutdown_helper();
2104}
2105
Vadim Yanitskiy6ef5dfa2020-08-28 18:04:41 +07002106private function f_exp_sapi_n_reject(template (present) GsmSapi sapi := ?,
2107 template myBSSMAP_Cause cause := ?,
2108 float T_val := 2.0)
2109runs on test_CT {
2110 var BSSAP_N_DATA_ind rx_di;
2111 timer T;
2112
2113 var template BSSMAP_IE_Cause tr_cause := tr_BSSMAP_IE_Cause(cause);
2114 var template PDU_BSSAP tr_pdu := tr_BSSMAP_SAPInReject(sapi);
2115
2116 T.start(T_val);
2117 alt {
2118 [] BSSAP.receive(tr_BSSAP_DATA_ind(?, tr_pdu)) -> value rx_di {
2119 var BSSMAP_IE_Cause rx_cause := rx_di.userData.pdu.bssmap.sAPInReject.cause;
2120 if (not match(rx_cause, tr_cause)) {
2121 setverdict(fail, "Rx unexpected Cause IE: ",
2122 rx_cause, " vs expected ", tr_cause);
2123 }
2124 setverdict(pass);
2125 }
2126 [] BSSAP.receive(BSSAP_N_DATA_ind:?) -> value rx_di {
2127 setverdict(fail, "Rx unexpected BSSAP PDU: ", rx_di);
2128 }
2129 [] T.timeout {
2130 setverdict(fail, "Timeout waiting for BSSMAP SAPI N Reject");
2131 }
2132 }
2133}
2134
2135/* Check if we get SAPI N Reject on receipt of unexpected RLL RELease INDication */
2136testcase TC_rll_rel_ind_sapi_n_reject() runs on test_CT {
2137 var octetstring rnd_data := f_rnd_octstring(16);
2138 var RSL_Message rx_rsl;
2139 var DchanTuple dt;
2140
2141 f_init(1);
2142
2143 /* MS establishes a SAPI=0 link on DCCH */
2144 dt := f_est_dchan(f_rnd_ra_cs(), 23, rnd_data);
2145
2146 /* MSC sends some data on (not yet established) SAPI=3 link */
2147 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSAP_DTAP(rnd_data, '03'O)));
2148 /* BSC attempts to establish a SAPI=3 link on DCCH */
2149 rx_rsl := f_exp_ipa_rx(0, tr_RSL_EST_REQ(dt.rsl_chan_nr, tr_RslLinkID_DCCH(3)));
2150
2151 /* MS sends unexpected RELease INDication on SAPI=3 */
2152 f_ipa_tx(0, ts_RSL_REL_IND(dt.rsl_chan_nr, ts_RslLinkID_DCCH(3)));
2153 /* We expect to receive BSSMAP SAPI N Reject message from the BSC */
2154 f_exp_sapi_n_reject(3, GSM0808_CAUSE_MS_NOT_EQUIPPED);
2155
2156 /* Clean up the connection */
2157 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
2158 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
2159
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002160 f_shutdown_helper();
Vadim Yanitskiy6ef5dfa2020-08-28 18:04:41 +07002161}
2162
2163/* Check if we get SAPI N Reject on receipt of unexpected RLL ERROR INDication */
2164testcase TC_rll_err_ind_sapi_n_reject() runs on test_CT {
2165 var octetstring rnd_data := f_rnd_octstring(16);
2166 var RSL_Message rx_rsl;
2167 var DchanTuple dt;
2168
2169 f_init(1);
2170
2171 /* MS establishes a SAPI=0 link on DCCH */
2172 dt := f_est_dchan(f_rnd_ra_cs(), 23, rnd_data);
2173
2174 /* MSC sends some data on (not yet established) SAPI=3 link */
2175 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSAP_DTAP(rnd_data, '03'O)));
2176 /* BSC attempts to establish a SAPI=3 link on DCCH */
2177 rx_rsl := f_exp_ipa_rx(0, tr_RSL_EST_REQ(dt.rsl_chan_nr, tr_RslLinkID_DCCH(3)));
2178
2179 /* BTS sends unexpected ERROR INDication on SAPI=3 */
2180 f_ipa_tx(0, ts_RSL_ERROR_IND(dt.rsl_chan_nr, ts_RslLinkID_DCCH(3), ''O));
2181 /* We expect to receive BSSMAP SAPI N Reject message from the BSC */
2182 f_exp_sapi_n_reject(3, GSM0808_CAUSE_BSS_NOT_EQUIPPED);
2183
2184 /* Clean up the connection */
2185 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
2186 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
2187
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002188 f_shutdown_helper();
Vadim Yanitskiy6ef5dfa2020-08-28 18:04:41 +07002189}
2190
2191/* Check if we get SAPI N Reject due to a SAPI=3 link establishment timeout */
2192testcase TC_rll_timeout_sapi_n_reject() runs on test_CT {
2193 var octetstring rnd_data := f_rnd_octstring(16);
2194 var RSL_Message rx_rsl;
2195 var DchanTuple dt;
2196
2197 f_init(1);
2198
2199 /* MS establishes a SAPI=0 link on DCCH */
2200 dt := f_est_dchan(f_rnd_ra_cs(), 23, rnd_data);
2201
2202 /* MSC sends some data on (not yet established) SAPI=3 link */
2203 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSAP_DTAP(rnd_data, '03'O)));
2204 /* BSC attempts to establish a SAPI=3 link on DCCH */
2205 rx_rsl := f_exp_ipa_rx(0, tr_RSL_EST_REQ(dt.rsl_chan_nr, tr_RslLinkID_DCCH(3)));
2206
2207 /* MS does not respond, so the link establishment timeout triggers SAPI N Reject */
2208 f_exp_sapi_n_reject(3, GSM0808_CAUSE_BSS_NOT_EQUIPPED, T_val := 8.0);
2209
2210 /* Clean up the connection */
2211 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
2212 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
2213
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002214 f_shutdown_helper();
Vadim Yanitskiy6ef5dfa2020-08-28 18:04:41 +07002215}
2216
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +02002217testcase TC_si_default() runs on test_CT {
2218 f_init(0);
2219 f_init_bts_and_check_sysinfo(0, expect_si := SystemInformationConfig_default);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002220 f_shutdown_helper();
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +02002221}
Harald Welte4003d112017-12-09 22:35:39 +01002222
Neels Hofmeyr56f24782020-07-09 00:50:49 +02002223/* We're testing SI2quater with lists of EARFCNs. Instead of just incrementing EARFCNs, also pick some from the edges of
2224 * the entire value range. This function provides the same EARFCN numbers for the same earfcn_index */
2225private function f_test_si2quater_earfcn_by_idx(integer earfcn_index) return uint16_t
2226{
2227 select (earfcn_index) {
2228 case (0) {
2229 /* E-ARFCN 111 is already added in the osmo-bsc.cfg */
2230 return 111;
2231 }
2232 case (1) {
2233 return 1;
2234 }
2235 case (2) {
2236 return 0;
2237 }
2238 case (3) {
2239 return 65535;
2240 }
2241 case else {
2242 return 23 * (earfcn_index - 3);
2243 }
2244 }
2245}
2246
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02002247function f_test_si2quater(integer total_earfcns, template SystemInformationConfig expect_si,
2248 template CellSelIndValue expect_cells := omit) runs on test_CT {
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002249
2250 f_init(0);
2251
2252 /* E-ARFCN 111 is already added in the osmo-bsc.cfg, so only add more arfcns if total_earfcns > 1 */
2253 for (var integer i := 1; i < total_earfcns; i := i + 1) {
Neels Hofmeyr56f24782020-07-09 00:50:49 +02002254 f_bts_0_cfg(BSCVTY, {"si2quater neighbor-list add earfcn " & int2str(f_test_si2quater_earfcn_by_idx(i))
2255 & " thresh-hi 20 thresh-lo 10 prio 3 qrxlv 22 meas 3"});
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002256 }
2257
2258 f_init_bts_and_check_sysinfo(0, expect_si := expect_si);
2259
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02002260 f_init(1);
2261
2262 if (not istemplatekind(expect_cells, "omit")) {
2263 /* Also check that RR Channel Release contains these EARFCNs.
2264 * (copied code from TC_chan_rel_hard_clear_csfb) */
2265 var BSSAP_N_DATA_ind rx_di;
2266 var DchanTuple dt;
2267
2268 dt := f_est_dchan('23'O, 23, '00010203040506'O);
2269
2270 /* Instruct BSC to clear channel */
2271 var BssmapCause cause := 0;
2272 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommandCSFB(cause)));
2273
2274 /* expect Clear Complete from BSC on A */
2275 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete)) {
2276 /* release the SCCP connection */
2277 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
2278 }
2279
2280 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false, is_csfb := true,
2281 csfb_expect_cells := expect_cells);
2282 }
2283
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002284 for (var integer i := 1; i < total_earfcns; i := i + 1) {
Neels Hofmeyr56f24782020-07-09 00:50:49 +02002285 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 +02002286 }
2287}
2288
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002289private function f_tr_si2quater_earfcns(integer count) return template SI2quaterRestOctetsList
2290{
2291 var template SI2quaterRestOctetsList si2quater := {};
2292 var integer si2quater_count := (count + 2) / 3;
2293
2294 for (var integer i := 0; i < count; i := i + 1) {
Neels Hofmeyr56f24782020-07-09 00:50:49 +02002295 var integer earfcn := f_test_si2quater_earfcn_by_idx(i);
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002296 var integer index := i / 3;
2297 var integer earfcn_index := i mod 3;
2298 if (index >= lengthof(si2quater)) {
2299 si2quater[index] := tr_SI2quaterRestOctets_EUTRAN(index := index, count := si2quater_count - 1);
2300 }
2301 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);
2302 }
2303
2304 return si2quater;
2305}
2306
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02002307private function f_tr_rr_chan_rel_earfcns(integer count) return template CellSelIndValue
2308{
2309 var template CellSelIndValue_EUTRAN_Descrs cells := {};
2310
Alexander Couzensf74b5cb2020-09-10 22:28:40 +02002311 /* the lte neighbors must match the config & vty to pass this test */
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02002312 for (var integer i := 0; i < count; i := i + 1) {
2313 var integer earfcn := f_test_si2quater_earfcn_by_idx(i);
Alexander Couzensf74b5cb2020-09-10 22:28:40 +02002314 cells[i] := tr_CellSelIndValue_EUTRAN_Descr(earfcn, '1'B, 3);
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02002315 }
2316
2317 return tr_CellSelIndValue_EUTRAN(cells);
2318}
2319
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002320private function f_tc_si2quater_n_earfcns(integer n) runs on test_CT
2321{
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002322 var template SystemInformationConfig sic := SystemInformationConfig_default;
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002323 sic.si2quater := f_tr_si2quater_earfcns(n);
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02002324 var template CellSelIndValue cells := f_tr_rr_chan_rel_earfcns(n);
2325 f_test_si2quater(n, sic, cells);
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002326}
2327
2328testcase TC_si2quater_2_earfcns() runs on test_CT {
2329 f_tc_si2quater_n_earfcns(2);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002330 f_shutdown_helper();
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002331}
2332
2333testcase TC_si2quater_3_earfcns() runs on test_CT {
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002334 f_tc_si2quater_n_earfcns(3);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002335 f_shutdown_helper();
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002336}
2337
2338testcase TC_si2quater_4_earfcns() runs on test_CT {
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002339 f_tc_si2quater_n_earfcns(4);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002340 f_shutdown_helper();
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002341}
2342
2343testcase TC_si2quater_5_earfcns() runs on test_CT {
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002344 f_tc_si2quater_n_earfcns(5);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002345 f_shutdown_helper();
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002346}
2347
2348testcase TC_si2quater_6_earfcns() runs on test_CT {
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002349 f_tc_si2quater_n_earfcns(6);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002350 f_shutdown_helper();
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002351}
2352
2353testcase TC_si2quater_12_earfcns() runs on test_CT {
2354 f_tc_si2quater_n_earfcns(12);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002355 f_shutdown_helper();
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002356}
2357
2358testcase TC_si2quater_23_earfcns() runs on test_CT {
2359 f_tc_si2quater_n_earfcns(23);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002360 f_shutdown_helper();
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002361}
2362
2363testcase TC_si2quater_32_earfcns() runs on test_CT {
2364 f_tc_si2quater_n_earfcns(32);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002365 f_shutdown_helper();
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002366}
2367
2368testcase TC_si2quater_33_earfcns() runs on test_CT {
2369 f_tc_si2quater_n_earfcns(33);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002370 f_shutdown_helper();
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002371}
2372
2373testcase TC_si2quater_42_earfcns() runs on test_CT {
2374 f_tc_si2quater_n_earfcns(42);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002375 f_shutdown_helper();
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002376}
2377
2378testcase TC_si2quater_48_earfcns() runs on test_CT {
2379 f_tc_si2quater_n_earfcns(48);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002380 f_shutdown_helper();
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002381}
2382
2383/* verify the VTY error response when adding too many EARFCNs, and showing that osmo-bsc still sends 16 SI2quater with
2384 * 48 EARFCNs. */
2385testcase TC_si2quater_49_earfcns() runs on test_CT {
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002386 var template SystemInformationConfig sic := SystemInformationConfig_default;
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002387 sic.si2quater := f_tr_si2quater_earfcns(48); /* 48, not 49! */
2388 f_init(0);
2389
2390 for (var integer i := 1; i < 48; i := i + 1) {
Neels Hofmeyr56f24782020-07-09 00:50:49 +02002391 f_bts_0_cfg(BSCVTY, {"si2quater neighbor-list add earfcn " & int2str(f_test_si2quater_earfcn_by_idx(i))
2392 & " thresh-hi 20 thresh-lo 10 prio 3 qrxlv 22 meas 3"});
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002393 }
2394
2395 /* The 49th EARFCN no longer fits, expect VTY error */
2396 f_vty_enter_cfg_bts(BSCVTY, 0);
2397 var charstring vty_error;
2398 vty_error := f_vty_transceive_ret(BSCVTY,
2399 "si2quater neighbor-list add earfcn 70 thresh-hi 20 thresh-lo 10 prio 3 qrxlv 22 meas 3")
2400 f_vty_transceive(BSCVTY, "end");
2401
2402 if (f_strstr(vty_error, "Unable to add ARFCN 70") >= 0) {
2403 log("Got expected VTY error: ", vty_error);
2404 setverdict(pass);
2405 } else {
2406 setverdict(fail, "Expected the 49th EUTRAN ARFCN to be rejected by vty config, got: ", vty_error);
2407 }
2408
2409 f_init_bts_and_check_sysinfo(0, expect_si := sic);
2410
2411 for (var integer i := 1; i < 48; i := i + 1) {
Neels Hofmeyr56f24782020-07-09 00:50:49 +02002412 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 +02002413 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002414 f_shutdown_helper();
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002415}
2416
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02002417private function f_acc09_count_allowed(AccessControlClass acc) return uint8_t
2418{
2419 var uint8_t count := 0;
2420 for (var integer i := 5; i < 16; i := i + 1) {
2421 if (acc[i] == '0'B) { /* the list marks barred, we count allowed */
2422 count := count + 1;
2423 }
2424 }
2425 return count;
2426}
2427
Pau Espin Pedrolc6136cd2020-07-24 13:20:02 +02002428private function f_recv_next_si1(integer rsl_idx := 0) runs on test_CT return SystemInformationType1
2429{
2430 var ASP_RSL_Unitdata rx_rsl_ud;
2431 var SystemInformationType1 last_si1;
2432
2433 timer T := 30.0;
2434 T.start;
2435 alt {
2436 [] IPA_RSL[rsl_idx].receive(tr_ASP_RSL_UD((tr_RSL_NO_BCCH_INFO,
2437 tr_RSL_BCCH_INFO,
2438 tr_RSL_NO_SACCH_FILL,
2439 tr_RSL_SACCH_FILL))
2440 ) -> value rx_rsl_ud {
2441 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
2442 if (g_system_information[rsl_idx].si1 == omit) {
2443 repeat;
2444 }
2445 last_si1 := g_system_information[rsl_idx].si1;
2446 g_system_information[rsl_idx].si1 := omit;
2447 T.stop;
2448 }
2449 [] T.timeout { setverdict(fail, "Timeout receiving next SI1"); }
2450 }
2451 return last_si1;
2452}
2453
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02002454/* verify ACC rotate feature */
2455testcase TC_si_acc_rotate() runs on test_CT {
2456 var template SystemInformationConfig sic := SystemInformationConfig_default;
Pau Espin Pedrolc6136cd2020-07-24 13:20:02 +02002457 var SystemInformationType1 last_si1;
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02002458 var AccessControlClass acc;
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02002459 var uint8_t count;
2460 var integer times_allowed[10] := { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
2461
2462 f_init(0, guard_timeout := 60.0);
2463
2464 f_bts_0_cfg(BSCVTY, {"rach access-control-class 5 barred",
2465 "access-control-class-rotate 3",
2466 "access-control-class-rotate-quantum 1"});
2467
2468 /* Init and get first sysinfo */
2469 f_init_bts_and_check_sysinfo(0, expect_si := ?);
2470
Pau Espin Pedrolc6136cd2020-07-24 13:20:02 +02002471 for (var integer i:= 0; i < 20; i := i + 1) {
2472 last_si1 := f_recv_next_si1(0);
2473 acc := last_si1.rach_control.acc;
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02002474 count := f_acc09_count_allowed(acc);
2475 log("RSL: GOT SI1 ACC len=", count, ": ", acc);
2476
2477 if (count != 3) {
2478 log("RSL: EXPECTED SI ACC len=3");
2479 setverdict(fail, "received SI does not match expectations");
2480 break;
2481 }
2482
2483 for (var integer j := 0; j < 10; j := j + 1) {
2484 if (acc[16 - 1 - j] == '0'B) { /* the list marks barred, we count allowed */
2485 times_allowed[j] := times_allowed[j] + 1;
2486 }
2487 }
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02002488 }
2489
2490 for (var integer j := 0; j < 10; j := j + 1) {
2491 log("ACC", j, " allowed ", times_allowed[j], " times" );
2492 if (j != 5 and times_allowed[j] < 3) {
2493 setverdict(fail, "ACC", j, " ERROR: allowed ", times_allowed[j], " < 1 times");
2494 } else if (j == 5 and times_allowed[j] > 0) {
2495 setverdict(fail, "ACC", j, " ERROR: allowed ", times_allowed[j], " > 0 times");
2496 }
2497 }
2498
2499 f_bts_0_cfg(BSCVTY, {"access-control-class-rotate 10",
2500 "rach access-control-class 5 allowed"});
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002501 f_shutdown_helper();
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02002502}
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002503
Pau Espin Pedrolc6136cd2020-07-24 13:20:02 +02002504/* verify ACC startup ramp+rotate feature */
2505testcase TC_si_acc_ramp_rotate() runs on test_CT {
2506 var template SystemInformationConfig sic := SystemInformationConfig_default;
2507 var SystemInformationType1 last_si1;
2508 var AccessControlClass acc;
2509 var ASP_RSL_Unitdata rx_rsl_ud;
2510 var uint8_t count;
2511 var uint8_t prev_count;
2512 var integer times_allowed[10] := { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
2513
2514 f_init(0, guard_timeout := 80.0);
2515
2516 f_bts_0_cfg(BSCVTY, {"rach access-control-class 4 barred",
2517 "access-control-class-rotate 0",
2518 "access-control-class-rotate-quantum 1",
2519 "access-control-class-ramping",
2520 "access-control-class-ramping-step-interval 5",
2521 "access-control-class-ramping-step-size 5"});
2522
2523 /* Init and get first sysinfo */
2524 f_init_bts_and_check_sysinfo(0, expect_si := ?);
2525 last_si1 := g_system_information[0].si1;
2526 acc := last_si1.rach_control.acc;
2527 count := f_acc09_count_allowed(acc);
2528 /* Adm subset size was set to 0 above, so wait until all ACC are barred */
2529 while (count > 0) {
2530 last_si1 := f_recv_next_si1(0);
2531 acc := last_si1.rach_control.acc;
2532 count := f_acc09_count_allowed(acc);
2533 log("RSL: wait len()=0: GOT SI1 ACC len=", count, ": ", acc);
2534 }
2535
2536 /* Increase adm subset size, we should see ramping start up */
2537 f_bts_0_cfg(BSCVTY, {"access-control-class-rotate 10"});
2538 prev_count := 0;
2539 while (true) {
2540 last_si1 := f_recv_next_si1(0);
2541 acc := last_si1.rach_control.acc;
2542 count := f_acc09_count_allowed(acc);
2543 log("RSL: GOT SI1 ACC len=", count, ": ", acc);
2544
2545 if (prev_count > count) {
2546 setverdict(fail, "ACC allowed count dropped while expecting grow: ", prev_count, " -> ", count);
2547 break;
2548 }
2549
2550 if (count == 9) {
2551 break; /* Maximum reached (10 - 1 perm barred), done here */
2552 }
2553
2554 prev_count := count;
2555 }
2556
2557 setverdict(pass);
2558
2559 f_bts_0_cfg(BSCVTY, {"access-control-class-rotate 10",
2560 "rach access-control-class 4 allowed",
2561 "no access-control-class-ramping"});
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002562 f_shutdown_helper();
Pau Espin Pedrolc6136cd2020-07-24 13:20:02 +02002563}
2564
Harald Welte4003d112017-12-09 22:35:39 +01002565testcase TC_ctrl_msc_connection_status() runs on test_CT {
2566 var charstring ctrl_resp;
2567
Harald Welte89d42e82017-12-17 16:42:41 +01002568 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +01002569
2570 /* See https://osmocom.org/issues/2729 */
2571 f_ctrl_get_exp(IPA_CTRL, "msc_connection_status", "connected");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002572 f_shutdown_helper();
Harald Welte4003d112017-12-09 22:35:39 +01002573}
2574
Stefan Sperlingb041b3d2018-01-03 17:14:55 +01002575testcase TC_ctrl_msc0_connection_status() runs on test_CT {
2576 var charstring ctrl_resp;
2577
2578 f_init(1);
Stefan Sperlingb041b3d2018-01-03 17:14:55 +01002579
2580 f_ctrl_get_exp(IPA_CTRL, "msc.0.connection_status", "connected");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002581 f_shutdown_helper();
Stefan Sperlingb041b3d2018-01-03 17:14:55 +01002582}
2583
Harald Welte4003d112017-12-09 22:35:39 +01002584testcase TC_ctrl() runs on test_CT {
2585 var charstring ctrl_resp;
2586
Harald Welte89d42e82017-12-17 16:42:41 +01002587 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +01002588
2589 /* all below values must match the osmo-bsc.cfg config file used */
2590
Harald Welte6a129692018-03-17 17:30:14 +01002591 f_ctrl_get_exp(IPA_CTRL, "mcc", "001");
2592 f_ctrl_get_exp(IPA_CTRL, "mnc", "01");
Oliver Smith75aa0202019-08-19 14:17:50 +02002593 f_ctrl_get_exp(IPA_CTRL, "number-of-bts", "4");
Harald Welte4003d112017-12-09 22:35:39 +01002594
2595 var integer bts_nr := 0;
2596 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "location-area-code", "1");
2597 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "cell-identity", "0");
2598 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "oml-connection-state", "connected");
2599 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "gprs-mode", "gprs");
2600 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "rf_state", "operational,unlocked,on");
2601 f_ctrl_get_exp_trx(IPA_CTRL, bts_nr, 0, "arfcn", "871");
2602 f_ctrl_get_exp_trx(IPA_CTRL, bts_nr, 0, "max-power-reduction", "20");
2603
2604 var integer uptime := str2int(f_ctrl_get_bts(IPA_CTRL, bts_nr, "oml-uptime"));
2605 f_sleep(2.0);
2606 if (str2int(f_ctrl_get_bts(IPA_CTRL, bts_nr, "oml-uptime")) < uptime+1) {
2607 setverdict(fail, "oml-uptime not incrementing as expected");
2608 }
2609 /* TODO: Disconnect RSL, imply that OML is disconnected and check for uptime zero? */
2610
2611 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bsc", 0, "paging:attempted", 0);
2612
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002613 f_shutdown_helper();
Harald Welte96c94412017-12-09 03:12:45 +01002614}
2615
Pau Espin Pedrol5a2d7432019-06-07 19:43:45 +02002616/* Verify that Upon receival of SET "location", BSC forwards a TRAP
2617 "location-state" over the SCCPlite IPA conn */
2618testcase TC_ctrl_location() runs on test_CT {
2619 var MSC_ConnHdlr vc_conn;
2620 var integer bts_nr := 0;
2621
2622 f_init(1, true);
2623 f_sleep(1.0);
2624
2625 f_ctrl_set_bts(IPA_CTRL, bts_nr, "location", "1234567,fix3d,0.340000,0.560000,0.780000");
2626 f_ctrl_exp_trap(SCCPLITE_IPA_CTRL, "bts." & int2str(bts_nr) & ".location-state",
2627 "1234567,fix3d,0.340000,0.560000,0.780000,operational,unlocked,on,001,01");
2628
2629 f_ctrl_set(SCCPLITE_IPA_CTRL, "rf_locked", "1");
2630 f_sleep(2.0);
2631
2632 f_ctrl_set_bts(IPA_CTRL, bts_nr, "location", "1234888,fix3d,0.350000,0.570000,0.790000");
2633 f_ctrl_exp_trap(SCCPLITE_IPA_CTRL, "bts." & int2str(bts_nr) & ".location-state",
2634 "1234888,fix3d,0.350000,0.570000,0.790000,operational,locked,off,001,01");
2635
2636 /* should match the one from config */
2637 f_ctrl_set(SCCPLITE_IPA_CTRL, "rf_locked", "0");
2638
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002639 f_shutdown_helper();
Pau Espin Pedrol5a2d7432019-06-07 19:43:45 +02002640}
2641
Harald Welte6f521d82017-12-11 19:52:02 +01002642
2643/***********************************************************************
2644 * Paging Testing
2645 ***********************************************************************/
2646
2647type record Cell_Identity {
2648 GsmMcc mcc,
2649 GsmMnc mnc,
2650 GsmLac lac,
2651 GsmCellId ci
2652};
Harald Welte24135bd2018-03-17 19:27:53 +01002653private const Cell_Identity cid := { '001'H, '01'H, 1, 0 };
Stefan Sperling049a86e2018-03-20 15:51:00 +01002654private const Cell_Identity unknown_cid := { '678'H, 'f90'H, 1, 0 };
Harald Welte6f521d82017-12-11 19:52:02 +01002655
Harald Welte5d1a2202017-12-13 19:51:29 +01002656type set of integer BtsIdList;
2657
2658private function f_bts_in_list(integer bts_id, BtsIdList bts_ids) return boolean {
2659 for (var integer j := 0; j < sizeof(bts_ids); j := j + 1) {
2660 if (bts_id == bts_ids[j]) {
2661 return true;
2662 }
2663 }
2664 return false;
2665}
Harald Welte6f521d82017-12-11 19:52:02 +01002666
2667/* core paging test helper function; used by most paging test cases */
2668private function f_pageing_helper(hexstring imsi,
2669 template BSSMAP_FIELD_CellIdentificationList cid_list,
Harald Welte5d1a2202017-12-13 19:51:29 +01002670 BtsIdList bts_ids := { 0 },
Harald Welte6f521d82017-12-11 19:52:02 +01002671 template RSL_ChanNeeded rsl_chneed := omit,
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07002672 template (omit) OCT4 tmsi := omit) runs on test_CT
Harald Welte6f521d82017-12-11 19:52:02 +01002673{
2674 var template BSSMAP_IE_ChannelNeeded bssmap_chneed;
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07002675 var template MobileIdentityV mi;
Harald Welte6f521d82017-12-11 19:52:02 +01002676 var RSL_Message rx_rsl;
2677 var integer paging_group := hex2int(imsi[lengthof(imsi)-1]);
Harald Welte5d1a2202017-12-13 19:51:29 +01002678 var integer i;
Harald Welte6f521d82017-12-11 19:52:02 +01002679
2680 f_init();
Harald Welte6f521d82017-12-11 19:52:02 +01002681
2682 /* Clear the queue, it might still contain stuff like BCCH FILLING */
Harald Weltec3068592018-03-17 19:55:31 +01002683 for (i := 0; i < NUM_BTS; i := i + 1) {
2684 IPA_RSL[i].clear;
Harald Welte5d1a2202017-12-13 19:51:29 +01002685 }
Harald Welte6f521d82017-12-11 19:52:02 +01002686
2687 if (isvalue(rsl_chneed)) {
2688 /* The values of 08.08 3.2.2.36 and 08.58 9.3.40 are luckily identical */
2689 bssmap_chneed := ts_BSSMAP_IE_ChanNeeded(int2bit(enum2int(valueof(rsl_chneed)),2));
2690 } else {
2691 bssmap_chneed := omit;
2692 }
2693
Neels Hofmeyrf246a922020-05-13 02:27:10 +02002694 BSSAP.send(ts_BSSAP_UNITDATA_req(g_bssap[0].sccp_addr_peer, g_bssap[0].sccp_addr_own,
2695 ts_BSSMAP_Paging(imsi, cid_list, tmsi, bssmap_chneed)));
Harald Welte6f521d82017-12-11 19:52:02 +01002696
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07002697 if (not istemplatekind(tmsi, "omit")) {
2698 mi := t_MI_TMSI(tmsi);
Harald Welte6f521d82017-12-11 19:52:02 +01002699 } else {
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07002700 mi := tr_MI_IMSI(imsi);
Harald Welte6f521d82017-12-11 19:52:02 +01002701 }
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07002702
Harald Welte5d1a2202017-12-13 19:51:29 +01002703 for (i := 0; i < sizeof(bts_ids); i := i + 1) {
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07002704 rx_rsl := f_exp_ipa_rx(bts_ids[i], tr_RSL_PAGING_CMD(mi));
Harald Welte5d1a2202017-12-13 19:51:29 +01002705 /* check channel type, paging group */
2706 if (rx_rsl.ies[1].body.paging_group != paging_group) {
2707 setverdict(fail, "Paging for wrong paging group");
2708 }
2709 if (ispresent(rsl_chneed) and
2710 rx_rsl.ies[3].body.chan_needed.chan_needed != valueof(rsl_chneed)) {
2711 setverdict(fail, "RSL Channel Needed != BSSMAP Channel Needed");
2712 }
Harald Welte6f521d82017-12-11 19:52:02 +01002713 }
Harald Welte2fccd982018-01-31 15:48:19 +01002714 f_sleep(2.0);
Harald Welte5d1a2202017-12-13 19:51:29 +01002715 /* do a quick check on all not-included BTSs if they received paging */
2716 for (i := 0; i < NUM_BTS; i := i + 1) {
2717 timer T := 0.1;
2718 if (f_bts_in_list(i, bts_ids)) {
2719 continue;
2720 }
2721 T.start;
2722 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07002723 [] IPA_RSL[i].receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD(mi))) {
Harald Welte5d1a2202017-12-13 19:51:29 +01002724 setverdict(fail, "Paging on BTS ", i, " which is not part of ", bts_ids);
2725 }
2726 [] IPA_RSL[i].receive { repeat; }
2727 [] T.timeout { }
2728 }
Harald Welte6f521d82017-12-11 19:52:02 +01002729 }
2730
2731 setverdict(pass);
2732}
2733
Harald Welte5d1a2202017-12-13 19:51:29 +01002734const BtsIdList c_BtsId_all := { 0, 1, 2 };
Harald Welte751d3eb2018-01-31 15:51:06 +01002735const BtsIdList c_BtsId_none := { };
Harald Welte5d1a2202017-12-13 19:51:29 +01002736const BtsIdList c_BtsId_LAC1 := { 0, 1 };
2737const BtsIdList c_BtsId_LAC2 := { 2 };
2738
Harald Welte6f521d82017-12-11 19:52:02 +01002739/* PAGING by IMSI + TMSI */
2740testcase TC_paging_imsi_nochan() runs on test_CT {
2741 var BSSMAP_FIELD_CellIdentificationList cid_list;
2742 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Philipp Maier8c04b0a2018-02-23 13:48:48 +01002743 f_pageing_helper('001010100000001'H, cid_list, c_BtsId_all, omit, omit);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002744 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002745}
2746
2747/* PAGING by IMSI + TMSI */
2748testcase TC_paging_tmsi_nochan() runs on test_CT {
2749 var BSSMAP_FIELD_CellIdentificationList cid_list;
2750 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01002751 f_pageing_helper('001010100000001'H, cid_list, c_BtsId_all, omit, 'A1B2C301'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002752 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002753}
2754
2755/* Paging with different "channel needed' values */
2756testcase TC_paging_tmsi_any() runs on test_CT {
2757 var BSSMAP_FIELD_CellIdentificationList cid_list;
2758 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01002759 f_pageing_helper('001010100000002'H, cid_list, c_BtsId_all, RSL_CHANNEED_ANY, 'A1B2C302'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002760 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002761}
2762testcase TC_paging_tmsi_sdcch() runs on test_CT {
2763 var BSSMAP_FIELD_CellIdentificationList cid_list;
2764 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01002765 f_pageing_helper('001010100000003'H, cid_list, c_BtsId_all, RSL_CHANNEED_SDCCH, 'A1B2C303'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002766 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002767}
2768testcase TC_paging_tmsi_tch_f() runs on test_CT {
2769 var BSSMAP_FIELD_CellIdentificationList cid_list;
2770 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01002771 f_pageing_helper('001010000000004'H, cid_list, c_BtsId_all, RSL_CHANNEED_TCH_F, 'A1B2C304'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002772 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002773}
2774testcase TC_paging_tmsi_tch_hf() runs on test_CT {
2775 var BSSMAP_FIELD_CellIdentificationList cid_list;
2776 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01002777 f_pageing_helper('001010000000005'H, cid_list, c_BtsId_all, RSL_CHANNEED_TCH_ForH, 'A1B2C305'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002778 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002779}
2780
2781/* Paging by CGI */
2782testcase TC_paging_imsi_nochan_cgi() runs on test_CT {
2783 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2784 cid_list := { cIl_CGI := { ts_BSSMAP_CI_CGI(cid.mcc, cid.mnc, cid.lac, cid.ci) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01002785 f_pageing_helper('001010000000006'H, cid_list, { 0 });
Philipp Maier282ca4b2018-02-27 17:17:00 +01002786 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002787}
2788
2789/* Paging by LAC+CI */
2790testcase TC_paging_imsi_nochan_lac_ci() runs on test_CT {
2791 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2792 cid_list := { cIl_LAC_CI := { ts_BSSMAP_CI_LAC_CI(cid.lac, cid.ci) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01002793 f_pageing_helper('001010000000007'H, cid_list, { 0 });
Philipp Maier282ca4b2018-02-27 17:17:00 +01002794 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002795}
2796
2797/* Paging by CI */
2798testcase TC_paging_imsi_nochan_ci() runs on test_CT {
2799 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2800 cid_list := { cIl_CI := { ts_BSSMAP_CI_CI(cid.ci) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01002801 f_pageing_helper('001010000000008'H, cid_list, { 0 });
Philipp Maier282ca4b2018-02-27 17:17:00 +01002802 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002803}
2804
2805/* Paging by LAI */
2806testcase TC_paging_imsi_nochan_lai() runs on test_CT {
2807 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2808 cid_list := { cIl_LAI := { ts_BSSMAP_CI_LAI(cid.mcc, cid.mnc, cid.lac) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01002809 f_pageing_helper('001010000000009'H, cid_list, c_BtsId_LAC1);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002810 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002811}
2812
2813/* Paging by LAC */
2814testcase TC_paging_imsi_nochan_lac() runs on test_CT {
2815 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2816 cid_list := { cIl_LAC := { ts_BSSMAP_CI_LAC(cid.lac) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01002817 f_pageing_helper('001010000000010'H, cid_list, c_BtsId_LAC1);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002818 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002819}
2820
2821/* Paging by "all in BSS" */
2822testcase TC_paging_imsi_nochan_all() runs on test_CT {
2823 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2824 cid_list := { cIl_allInBSS := ''O };
Harald Welte5d1a2202017-12-13 19:51:29 +01002825 f_pageing_helper('001010000000011'H, cid_list, c_BtsId_all);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002826 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002827}
2828
Stefan Sperling7b5e1782018-03-20 19:32:43 +01002829/* Paging by PLMN+LAC+RNC; We do not implement this; Verify nothing is paged */
Harald Welte751d3eb2018-01-31 15:51:06 +01002830testcase TC_paging_imsi_nochan_plmn_lac_rnc() runs on test_CT {
2831 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2832 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 +01002833 f_pageing_helper('001010000000012'H, cid_list, c_BtsId_none);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002834 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01002835}
Harald Welte6f521d82017-12-11 19:52:02 +01002836
Stefan Sperling7b5e1782018-03-20 19:32:43 +01002837/* Paging by RNC; We do not implement this; Verify nothing is paged */
Harald Welte751d3eb2018-01-31 15:51:06 +01002838testcase TC_paging_imsi_nochan_rnc() runs on test_CT {
2839 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2840 cid_list := { cIl_RNC := { int2oct(13, 2) } };
Stefan Sperling7b5e1782018-03-20 19:32:43 +01002841 f_pageing_helper('001010000000013'H, cid_list, c_BtsId_none);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002842 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01002843}
2844
Stefan Sperling7b5e1782018-03-20 19:32:43 +01002845/* Paging by LAC+RNC; We do not implement; Verify nothing is paged */
Harald Welte751d3eb2018-01-31 15:51:06 +01002846testcase TC_paging_imsi_nochan_lac_rnc() runs on test_CT {
2847 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2848 cid_list := { cIl_LAC_RNC := { ts_BSSMAP_CI_LAC_RNC(cid.lac, 14) } };
Stefan Sperling7b5e1782018-03-20 19:32:43 +01002849 f_pageing_helper('001010000000014'H, cid_list, c_BtsId_none);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002850 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01002851}
2852
Harald Welte6f521d82017-12-11 19:52:02 +01002853/* Paging on multiple cells (multiple entries in list): Verify all of them page */
Harald Welte751d3eb2018-01-31 15:51:06 +01002854testcase TC_paging_imsi_nochan_lacs() runs on test_CT {
2855 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2856 cid_list := { cIl_LAC := { ts_BSSMAP_CI_LAC(1), ts_BSSMAP_CI_LAC(2) } };
2857 f_pageing_helper('001010000000015'H, cid_list, c_BtsId_all);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002858 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01002859}
2860
2861/* Paging on empty list: Verify none of them page */
2862testcase TC_paging_imsi_nochan_lacs_empty() runs on test_CT {
2863 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2864 cid_list := { cIl_LAC := { } };
2865 f_pageing_helper('001010000000016'H, cid_list, c_BtsId_none);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002866 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01002867}
2868
Stefan Sperling049a86e2018-03-20 15:51:00 +01002869/* Paging by CGI with unknown MCC/MNC: Verify nothing is paged. */
2870testcase TC_paging_imsi_nochan_cgi_unknown_cid() runs on test_CT {
2871 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2872 cid_list := { cIl_CGI := { ts_BSSMAP_CI_CGI(unknown_cid.mcc, unknown_cid.mnc, unknown_cid.lac, unknown_cid.ci) } };
2873 f_pageing_helper('001010000000006'H, cid_list, c_BtsId_none);
2874 f_shutdown_helper();
2875}
2876
Harald Welte6f521d82017-12-11 19:52:02 +01002877/* Verify paging retransmission interval + count */
2878/* Verify paging stops after channel establishment */
Harald Welte6f521d82017-12-11 19:52:02 +01002879/* Test behavior under paging overload */
Harald Welteae026692017-12-09 01:03:01 +01002880
Harald Weltee65d40e2017-12-13 00:09:06 +01002881/* Verify PCH load */
2882testcase TC_paging_imsi_load() runs on test_CT {
2883 var BSSMAP_FIELD_CellIdentificationList cid_list;
2884 timer T := 4.0;
Harald Welte2caa1062018-03-17 18:19:05 +01002885 timer T_retrans := 1.0;
Harald Weltee65d40e2017-12-13 00:09:06 +01002886 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01002887 f_pageing_helper('001010123456789'H, cid_list, c_BtsId_all);
Harald Weltee65d40e2017-12-13 00:09:06 +01002888
2889 /* tell BSC there is no paging space anymore */
2890 f_ipa_tx(0, ts_RSL_PAGING_LOAD_IND(0));
Harald Welte3b57ab52018-03-17 18:01:10 +01002891 f_sleep(0.2);
2892 IPA_RSL[0].clear;
Harald Weltee65d40e2017-12-13 00:09:06 +01002893
2894 /* Wait for 4 seconds if any more PAGING CMD are received on RSL. Normally,
2895 * there would be 8 retransmissions during 4 seconds */
2896 T.start;
Harald Welte2caa1062018-03-17 18:19:05 +01002897 T_retrans.start;
Harald Weltee65d40e2017-12-13 00:09:06 +01002898 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07002899 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD(?))) {
Harald Weltee65d40e2017-12-13 00:09:06 +01002900 setverdict(fail, "Received PAGING after LOAD_IND(0)");
Daniel Willmannafce8662018-07-06 23:11:32 +02002901 mtc.stop;
Harald Weltee65d40e2017-12-13 00:09:06 +01002902 }
Harald Welte2caa1062018-03-17 18:19:05 +01002903 [] T_retrans.timeout {
2904 /* re-trnsmit the zero-space LOAD IND to avoid BSC 'auto credit' */
2905 f_ipa_tx(0, ts_RSL_PAGING_LOAD_IND(0));
2906 T_retrans.start;
2907 repeat;
2908 }
Harald Weltee65d40e2017-12-13 00:09:06 +01002909 [] T.timeout {
2910 setverdict(pass);
2911 }
2912 }
Philipp Maier282ca4b2018-02-27 17:17:00 +01002913
2914 f_shutdown_helper();
Harald Weltee65d40e2017-12-13 00:09:06 +01002915}
2916
Harald Welte235ebf12017-12-15 14:18:16 +01002917/* Verify Paging Counter */
Harald Welte1ff69992017-12-14 12:31:17 +01002918testcase TC_paging_counter() runs on test_CT {
2919 var BSSMAP_FIELD_CellIdentificationList cid_list;
2920 timer T := 4.0;
2921 var integer i;
2922 var integer paging_attempted_bsc;
2923 var integer paging_attempted_bts[NUM_BTS];
2924 var integer paging_expired_bts[NUM_BTS];
2925 cid_list := valueof(ts_BSSMAP_CIL_noCell);
2926
2927 f_init();
2928
2929 /* read counters before paging */
2930 paging_attempted_bsc := f_ctrl_get_ratectr_abs(IPA_CTRL, "bsc", 0, "paging:attempted");
2931 for (i := 0; i < NUM_BTS; i := i+1) {
2932 paging_attempted_bts[i] := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", i, "paging:attempted");
2933 paging_expired_bts[i] := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", i, "paging:expired");
2934 }
2935
2936 f_pageing_helper('001230000000001'H, cid_list, c_BtsId_all);
2937
2938 /* expect the attempted pages on BSC and each BTSs to have incremented by one */
2939 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bsc", 0, "paging:attempted", paging_attempted_bsc+1);
2940 for (i := 0; i < NUM_BTS; i := i+1) {
2941 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", i, "paging:attempted",
2942 paging_attempted_bts[i]+1);
2943 }
2944
2945 /* assume that 12s later the paging on all BTSs have expired and hence incremented by 1 */
2946 f_sleep(12.0);
2947 for (i := 0; i < NUM_BTS; i := i+1) {
2948 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", i, "paging:expired",
2949 paging_expired_bts[i]+1);
2950 }
Harald Welte1ff69992017-12-14 12:31:17 +01002951
Philipp Maier282ca4b2018-02-27 17:17:00 +01002952 f_shutdown_helper();
Harald Welte1ff69992017-12-14 12:31:17 +01002953}
2954
2955
Harald Welte10985002017-12-12 09:29:15 +01002956/* Verify paging stops after A-RESET */
2957testcase TC_paging_imsi_a_reset() runs on test_CT {
2958 var BSSMAP_FIELD_CellIdentificationList cid_list;
2959 timer T := 3.0;
2960 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01002961 f_pageing_helper('001010123456789'H, cid_list, c_BtsId_all);
Harald Welte10985002017-12-12 09:29:15 +01002962
2963 /* Perform a BSSMAP Reset and wait for ACK */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02002964 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 +01002965 alt {
Neels Hofmeyrf246a922020-05-13 02:27:10 +02002966 [] 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 +01002967 [] BSSAP.receive { repeat; }
2968 }
2969
Daniel Willmanncbef3982018-07-30 09:22:40 +02002970 /* Wait to avoid a possible race condition if a paging message is
2971 * received right before the reset ACK. */
2972 f_sleep(0.2);
2973
Harald Welte10985002017-12-12 09:29:15 +01002974 /* Clear the queue, it might still contain stuff like BCCH FILLING */
Philipp Maier1e6b4422018-02-23 14:02:13 +01002975 for (var integer i := 0; i < sizeof(IPA_RSL); i := i+1) {
2976 IPA_RSL[i].clear;
2977 }
Harald Welte10985002017-12-12 09:29:15 +01002978
2979 /* Wait for 3 seconds if any more PAGING CMD are received on RSL */
2980 T.start;
2981 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07002982 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD(?))) {
Harald Welte10985002017-12-12 09:29:15 +01002983 setverdict(fail, "Received PAGING after A-RESET");
Daniel Willmannafce8662018-07-06 23:11:32 +02002984 mtc.stop;
Harald Welte10985002017-12-12 09:29:15 +01002985 }
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07002986 [] IPA_RSL[1].receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD(?))) {
Harald Welte5d1a2202017-12-13 19:51:29 +01002987 setverdict(fail, "Received PAGING after A-RESET");
Daniel Willmannafce8662018-07-06 23:11:32 +02002988 mtc.stop;
Harald Welte5d1a2202017-12-13 19:51:29 +01002989 }
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07002990 [] IPA_RSL[2].receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD(?))) {
Harald Welte5d1a2202017-12-13 19:51:29 +01002991 setverdict(fail, "Received PAGING after A-RESET");
Daniel Willmannafce8662018-07-06 23:11:32 +02002992 mtc.stop;
Harald Welte5d1a2202017-12-13 19:51:29 +01002993 }
Harald Welte10985002017-12-12 09:29:15 +01002994 [] T.timeout {
2995 setverdict(pass);
2996 }
2997 }
Philipp Maier282ca4b2018-02-27 17:17:00 +01002998
2999 f_shutdown_helper();
Harald Welte10985002017-12-12 09:29:15 +01003000}
Harald Welteae026692017-12-09 01:03:01 +01003001
Philipp Maierf45824a2019-08-14 14:44:10 +02003002/* Verify how we handle unsolicited Paging Response. In case of an unsolicit
3003 * paging response we can not know which MSC is in charge, so we will blindly
3004 * pick the first configured MSC. This behavior is required in order to make
3005 * MT-CSFB calls working because in those cases the BSC can not know that the
3006 * MSC has already paged the subscriver via SGs. So any MT-CSFB call will look
3007 * like an unsolicited Paging Response to the MSC.
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01003008 */
3009testcase TC_paging_resp_unsol() runs on test_CT {
3010
3011 f_init(1);
Philipp Maierf45824a2019-08-14 14:44:10 +02003012 timer T := 5.0;
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01003013
3014 var BSSAP_N_CONNECT_ind rx_c_ind;
3015 var DchanTuple dt;
3016 var PDU_ML3_MS_NW l3 := valueof(ts_PAG_RESP(valueof(ts_MI_IMSI_LV('001010008880018'H))));
Philipp Maierf45824a2019-08-14 14:44:10 +02003017 var octetstring rr_pag_resp := enc_PDU_ML3_MS_NW(l3);
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01003018
3019 /* Send CHAN RQD and wait for allocation; acknowledge it */
3020 dt.rsl_chan_nr := f_chreq_act_ack();
3021
3022 /* Send unsolicited Paging response (no matching Paging CMD stored in BSC) */
3023 f_ipa_tx(0, ts_RSL_EST_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0)), enc_PDU_ML3_MS_NW(l3)));
3024
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01003025
Philipp Maierf45824a2019-08-14 14:44:10 +02003026 /* Expevct a CR with a matching Paging response on the A-Interface */
3027 T.start;
3028 alt {
3029 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(rr_pag_resp))) {
3030 setverdict(pass);
3031 }
3032 [] BSSAP.receive {
3033 setverdict(fail, "Received unexpected message on A-Interface!");
3034 }
3035 [] T.timeout {
3036 setverdict(fail, "Received nothing on A-Interface!");
3037 }
3038 }
3039
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003040 f_shutdown_helper();
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01003041}
3042
Harald Welte4e9b9cc2017-12-14 18:31:02 +01003043/* Test RSL link drop causes counter increment */
3044testcase TC_rsl_drop_counter() runs on test_CT {
3045 var integer rsl_fail;
3046
Harald Welte89d42e82017-12-17 16:42:41 +01003047 f_init(1);
Harald Welte4e9b9cc2017-12-14 18:31:02 +01003048
3049 rsl_fail := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "rsl_fail");
3050
3051 bts[0].rsl.vc_IPA.stop;
3052
3053 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "rsl_fail", rsl_fail+1);
3054
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003055 f_shutdown_helper();
Harald Welte4e9b9cc2017-12-14 18:31:02 +01003056}
3057
3058/* TODO: Test OML link drop causes counter increment */
3059
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003060/* The body of TC_rsl_unknown_unit_id() and TC_oml_unknown_unit_id() tests. */
3061function f_ipa_unknown_unit_id(integer mp_bsc_ipa_port) runs on test_CT return boolean {
3062 timer T := 10.0;
3063
3064 bts[0].rsl.id := "IPA-0-RSL";
3065 bts[0].rsl.vc_IPA := IPA_Emulation_CT.create(bts[0].rsl.id & "-IPA");
3066 bts[0].rsl.ccm_pars := c_IPA_default_ccm_pars;
3067 bts[0].rsl.ccm_pars.name := "Osmocom TTCN-3 BTS Simulator";
Oliver Smith92c2bdb2019-08-20 15:11:24 +02003068 bts[0].rsl.ccm_pars.unit_id := "99/0/0"; /* value which is unknown at BTS */
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003069
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003070 f_ipa_ctrl_start(mp_bsc_ip, mp_bsc_ctrl_port);
3071
3072 f_init_mgcp("VirtMSC");
3073
3074 /* start RSL/OML connection (XXX re-uses RSL port/protocol definitions for OML) */
3075 map(bts[0].rsl.vc_IPA:IPA_PORT, system:IPA);
3076 connect(bts[0].rsl.vc_IPA:IPA_RSL_PORT, self:IPA_RSL[0]);
3077 bts[0].rsl.vc_IPA.start(IPA_Emulation.main_client(mp_bsc_ip, mp_bsc_ipa_port, "", 10000, bts[0].rsl.ccm_pars));
3078
3079 /* wait for IPA OML link to connect and then disconnect */
3080 T.start;
3081 alt {
Vadim Yanitskiya2afacc2020-05-18 21:16:19 +07003082 [] IPA_RSL[0].receive(tr_ASP_IPA_EV(ASP_IPA_EVENT_DOWN)) {
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003083 T.stop;
3084 return true;
3085 }
3086 [] IPA_RSL[0].receive { repeat }
3087 [] T.timeout {
Daniel Willmannafce8662018-07-06 23:11:32 +02003088 return false;
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003089 }
3090 }
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003091 return false;
3092}
3093
3094/* BSC should close an RSL connection from a BTS with unknown unit ID (OS#2714). */
3095testcase TC_rsl_unknown_unit_id() runs on test_CT {
3096 if (f_ipa_unknown_unit_id(mp_bsc_rsl_port)) {
3097 setverdict(pass);
3098 } else {
3099 setverdict(fail, "Timeout RSL waiting for connection to close");
3100 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003101 f_shutdown_helper();
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003102}
3103
3104
3105/* BSC should close an RSL connection from a BTS with unknown unit ID (OS#2714). */
3106testcase TC_oml_unknown_unit_id() runs on test_CT {
3107 if (f_ipa_unknown_unit_id(mp_bsc_oml_port)) {
3108 setverdict(pass);
3109 } else {
3110 setverdict(fail, "Timeout OML waiting for connection to close");
3111 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003112 f_shutdown_helper();
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003113}
3114
3115
Harald Weltec1a2fff2017-12-17 11:06:19 +01003116/***********************************************************************
Harald Welte6811d102019-04-14 22:23:14 +02003117 * "New world" test cases using RSL_Emulation + RAN_Emulation
Harald Weltec1a2fff2017-12-17 11:06:19 +01003118 ***********************************************************************/
3119
Harald Welte6811d102019-04-14 22:23:14 +02003120import from RAN_Emulation all;
Harald Welte47cd0e32020-08-21 12:39:11 +02003121import from BSSAP_LE_Emulation all;
Harald Weltec1a2fff2017-12-17 11:06:19 +01003122import from RSL_Emulation all;
3123import from MSC_ConnectionHandler all;
3124
3125type function void_fn(charstring id) runs on MSC_ConnHdlr;
3126
Harald Welte336820c2018-05-31 20:34:52 +02003127/* helper function to create and connect a MSC_ConnHdlr component */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003128private function f_connect_handler(inout MSC_ConnHdlr vc_conn, integer bssap_idx := 0) runs on test_CT {
3129 connect(vc_conn:RAN, g_bssap[bssap_idx].vc_RAN:PROC);
Daniel Willmann191e0d92018-01-17 12:44:35 +01003130 connect(vc_conn:MGCP_PROC, vc_MGCP:MGCP_PROC);
Harald Weltec1a2fff2017-12-17 11:06:19 +01003131 connect(vc_conn:RSL, bts[0].rsl.vc_RSL:CLIENT_PT);
Harald Weltef70df652018-01-29 22:00:23 +01003132 connect(vc_conn:RSL_PROC, bts[0].rsl.vc_RSL:RSL_PROC);
Philipp Maier88f4ae82018-03-01 14:00:58 +01003133 if (isvalue(bts[1])) {
Philipp Maier956a92f2018-02-16 10:58:07 +01003134 connect(vc_conn:RSL1, bts[1].rsl.vc_RSL:CLIENT_PT);
3135 connect(vc_conn:RSL1_PROC, bts[1].rsl.vc_RSL:RSL_PROC);
3136 }
Neels Hofmeyr91401012019-07-11 00:42:35 +02003137 if (isvalue(bts[2])) {
3138 connect(vc_conn:RSL2, bts[2].rsl.vc_RSL:CLIENT_PT);
3139 connect(vc_conn:RSL2_PROC, bts[2].rsl.vc_RSL:RSL_PROC);
3140 }
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003141 connect(vc_conn:BSSAP, g_bssap[bssap_idx].vc_RAN:CLIENT);
Harald Welte47cd0e32020-08-21 12:39:11 +02003142 connect(vc_conn:BSSAP_LE, g_bssap_le.vc_BSSAP_LE:CLIENT);
Daniel Willmann191e0d92018-01-17 12:44:35 +01003143 connect(vc_conn:MGCP, vc_MGCP:MGCP_CLIENT);
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +02003144 connect(vc_conn:MGCP_MULTI, vc_MGCP:MGCP_CLIENT_MULTI);
Daniel Willmannebdecc02020-08-12 15:30:17 +02003145 connect(vc_conn:STATSD_PROC, vc_STATSD:STATSD_PROC);
Harald Welte336820c2018-05-31 20:34:52 +02003146}
3147
3148function f_start_handler(void_fn fn, template (omit) TestHdlrParams pars := omit)
3149runs on test_CT return MSC_ConnHdlr {
3150 var charstring id := testcasename();
3151 var MSC_ConnHdlr vc_conn;
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003152 var integer bssap_idx := 0;
3153 if (isvalue(pars)) {
3154 bssap_idx := valueof(pars).mscpool.bssap_idx;
3155 }
Harald Welte336820c2018-05-31 20:34:52 +02003156 vc_conn := MSC_ConnHdlr.create(id);
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003157 f_connect_handler(vc_conn, bssap_idx);
Harald Weltea0630032018-03-20 21:09:55 +01003158 vc_conn.start(f_handler_init(fn, id, pars));
Harald Weltec1a2fff2017-12-17 11:06:19 +01003159 return vc_conn;
3160}
3161
Harald Weltea0630032018-03-20 21:09:55 +01003162/* first function inside ConnHdlr component; sets g_pars + starts function */
3163private function f_handler_init(void_fn fn, charstring id, template (omit) TestHdlrParams pars := omit)
3164runs on MSC_ConnHdlr {
3165 if (isvalue(pars)) {
3166 g_pars := valueof(pars);
3167 }
3168 fn.apply(id);
3169}
3170
Harald Welte3c86ea02018-05-10 22:28:05 +02003171/* Establish signalling channel (non-assignment case) followed by cipher mode */
3172private function f_tc_ciph_mode_a5(charstring id) runs on MSC_ConnHdlr {
Harald Welteed848512018-05-24 22:27:58 +02003173 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3174 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte3c86ea02018-05-10 22:28:05 +02003175 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeSIGNAL);
Philipp Maier23000732018-05-18 11:25:37 +02003176 ass_cmd.pdu.bssmap.assignmentRequest.circuitIdentityCode := omit;
3177 ass_cmd.pdu.bssmap.assignmentRequest.aoIPTransportLayer := omit;
3178 exp_compl.pdu.bssmap.assignmentComplete.circuitIdentityCode := omit;
3179 exp_compl.pdu.bssmap.assignmentComplete.aoIPTransportLayer := omit;
Harald Welte3c86ea02018-05-10 22:28:05 +02003180
Philipp Maier23000732018-05-18 11:25:37 +02003181 f_establish_fully(ass_cmd, exp_compl);
Harald Welte3c86ea02018-05-10 22:28:05 +02003182}
3183testcase TC_ciph_mode_a5_0() runs on test_CT {
3184 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02003185 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte3c86ea02018-05-10 22:28:05 +02003186 pars.encr := valueof(t_EncrParams('01'O, f_rnd_octstring(8)));
3187
3188 f_init(1, true);
3189 f_sleep(1.0);
3190 vc_conn := f_start_handler(refers(f_tc_ciph_mode_a5), pars);
3191 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003192 f_shutdown_helper();
Harald Welte3c86ea02018-05-10 22:28:05 +02003193}
3194testcase TC_ciph_mode_a5_1() runs on test_CT {
3195 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02003196 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte3c86ea02018-05-10 22:28:05 +02003197 pars.encr := valueof(t_EncrParams('02'O, f_rnd_octstring(8)));
3198
3199 f_init(1, true);
3200 f_sleep(1.0);
3201 vc_conn := f_start_handler(refers(f_tc_ciph_mode_a5), pars);
3202 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003203 f_shutdown_helper();
Harald Welte3c86ea02018-05-10 22:28:05 +02003204}
3205testcase TC_ciph_mode_a5_3() runs on test_CT {
3206 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02003207 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte3c86ea02018-05-10 22:28:05 +02003208 pars.encr := valueof(t_EncrParams('08'O, f_rnd_octstring(8)));
3209
3210 f_init(1, true);
3211 f_sleep(1.0);
3212 vc_conn := f_start_handler(refers(f_tc_ciph_mode_a5), pars);
3213 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003214 f_shutdown_helper();
Harald Welte3c86ea02018-05-10 22:28:05 +02003215}
3216
Pau Espin Pedrol07866632020-09-03 19:10:55 +02003217/* establish initial channel, enable ciphering followed by assignment to ciphered channel */
3218private function f_tc_assignment_aoip_tla_v6(charstring id) runs on MSC_ConnHdlr {
3219 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3220 var PDU_BSSAP ass_cmd := f_gen_ass_req(aoip_tla := "::3");
3221 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3222 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
3223
3224 f_establish_fully(ass_cmd, exp_compl);
3225}
3226testcase TC_assignment_aoip_tla_v6() runs on test_CT {
3227 var MSC_ConnHdlr vc_conn;
3228 var TestHdlrParams pars := f_gen_test_hdlr_pars();
3229
3230 f_init(1, true);
3231 f_sleep(1.0);
3232 vc_conn := f_start_handler(refers(f_tc_assignment_aoip_tla_v6), pars);
3233 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003234 f_shutdown_helper();
Pau Espin Pedrol07866632020-09-03 19:10:55 +02003235}
3236
Harald Welte3c86ea02018-05-10 22:28:05 +02003237
3238/* establish initial channel, enable ciphering followed by assignment to ciphered channel */
Harald Welte651fcdc2018-05-10 20:23:16 +02003239private function f_tc_assignment_fr_a5(charstring id) runs on MSC_ConnHdlr {
Harald Welteed848512018-05-24 22:27:58 +02003240 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3241 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Weltec1a2fff2017-12-17 11:06:19 +01003242
Harald Welte552620d2017-12-16 23:21:36 +01003243 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3244 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
Harald Welte73cd2712017-12-17 00:44:52 +01003245
Harald Weltea0630032018-03-20 21:09:55 +01003246 f_establish_fully(ass_cmd, exp_compl);
Harald Welte552620d2017-12-16 23:21:36 +01003247}
Harald Welte552620d2017-12-16 23:21:36 +01003248testcase TC_assignment_fr_a5_0() runs on test_CT {
3249 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02003250 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte651fcdc2018-05-10 20:23:16 +02003251 pars.encr := valueof(t_EncrParams('01'O, f_rnd_octstring(8)));
Harald Welte552620d2017-12-16 23:21:36 +01003252
Harald Welte89d42e82017-12-17 16:42:41 +01003253 f_init(1, true);
Harald Welte552620d2017-12-16 23:21:36 +01003254 f_sleep(1.0);
Harald Welte651fcdc2018-05-10 20:23:16 +02003255 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5), pars);
Harald Welte552620d2017-12-16 23:21:36 +01003256 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003257 f_shutdown_helper();
Harald Welte552620d2017-12-16 23:21:36 +01003258}
Harald Welte552620d2017-12-16 23:21:36 +01003259testcase TC_assignment_fr_a5_1() runs on test_CT {
Harald Weltec1a2fff2017-12-17 11:06:19 +01003260 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02003261 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte651fcdc2018-05-10 20:23:16 +02003262 pars.encr := valueof(t_EncrParams('02'O, f_rnd_octstring(8)));
Harald Weltec1a2fff2017-12-17 11:06:19 +01003263
Harald Welte89d42e82017-12-17 16:42:41 +01003264 f_init(1, true);
Harald Weltec1a2fff2017-12-17 11:06:19 +01003265 f_sleep(1.0);
Harald Welte651fcdc2018-05-10 20:23:16 +02003266 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5), pars);
3267 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003268 f_shutdown_helper();
Harald Welte651fcdc2018-05-10 20:23:16 +02003269}
3270testcase TC_assignment_fr_a5_3() runs on test_CT {
3271 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02003272 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte651fcdc2018-05-10 20:23:16 +02003273 pars.encr := valueof(t_EncrParams('08'O, f_rnd_octstring(8)));
Harald Weltec1a2fff2017-12-17 11:06:19 +01003274
Harald Welte651fcdc2018-05-10 20:23:16 +02003275 f_init(1, true);
3276 f_sleep(1.0);
3277 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5), pars);
Harald Weltec1a2fff2017-12-17 11:06:19 +01003278 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003279 f_shutdown_helper();
Harald Weltec1a2fff2017-12-17 11:06:19 +01003280}
3281
Harald Welte552620d2017-12-16 23:21:36 +01003282/* Expect ASSIGNMENT FAIL if mandatory IE is missing */
3283private function f_tc_assignment_fr_a5_1_codec_missing(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02003284 g_pars := f_gen_test_hdlr_pars();
Harald Welte552620d2017-12-16 23:21:36 +01003285 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
Harald Welteed848512018-05-24 22:27:58 +02003286 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte552620d2017-12-16 23:21:36 +01003287 const OCT8 kc := '0001020304050607'O;
3288
3289 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02003290 /* Omit: ass_cmd.pdu.bssmap.assignmentRequest.codecList */
3291
Harald Weltea0630032018-03-20 21:09:55 +01003292 f_establish_fully(ass_cmd, exp_fail);
Harald Welte552620d2017-12-16 23:21:36 +01003293}
Harald Welte552620d2017-12-16 23:21:36 +01003294testcase TC_assignment_fr_a5_1_codec_missing() runs on test_CT {
3295 var MSC_ConnHdlr vc_conn;
3296
Harald Welte89d42e82017-12-17 16:42:41 +01003297 f_init(1, true);
Harald Welte552620d2017-12-16 23:21:36 +01003298 f_sleep(1.0);
3299
Harald Welte8863fa12018-05-10 20:15:27 +02003300 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5_1_codec_missing));
Harald Welte552620d2017-12-16 23:21:36 +01003301 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003302 f_shutdown_helper();
Harald Welte552620d2017-12-16 23:21:36 +01003303}
3304
Harald Welte552620d2017-12-16 23:21:36 +01003305private function f_tc_assignment_fr_a5_4(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02003306 g_pars := f_gen_test_hdlr_pars();
Harald Welteed848512018-05-24 22:27:58 +02003307 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3308 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte552620d2017-12-16 23:21:36 +01003309 const OCT8 kc := '0001020304050607'O;
3310 const OCT16 kc128 := kc & kc;
3311
3312 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3313 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
Harald Weltea0630032018-03-20 21:09:55 +01003314 f_establish_fully(ass_cmd, exp_compl);
Harald Welte38b2a102017-12-23 02:42:58 +01003315 f_cipher_mode('10'O, kc, kc128, true);
Harald Welte552620d2017-12-16 23:21:36 +01003316 /* TODO: expect GSM0808_CAUSE_CIPHERING_ALGORITHM_NOT_SUPPORTED cause value */
Harald Welte552620d2017-12-16 23:21:36 +01003317}
Harald Welte552620d2017-12-16 23:21:36 +01003318testcase TC_assignment_fr_a5_4() runs on test_CT {
3319 var MSC_ConnHdlr vc_conn;
3320
Harald Welte89d42e82017-12-17 16:42:41 +01003321 f_init(1, true);
Harald Welte552620d2017-12-16 23:21:36 +01003322 f_sleep(1.0);
3323
Harald Welte8863fa12018-05-10 20:15:27 +02003324 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5_4));
Harald Welte552620d2017-12-16 23:21:36 +01003325 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003326 f_shutdown_helper();
Harald Welte552620d2017-12-16 23:21:36 +01003327}
3328
3329
Harald Welte4532e0a2017-12-23 02:05:44 +01003330private function f_tc_assignment_sign(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02003331 g_pars := f_gen_test_hdlr_pars();
Harald Welte4532e0a2017-12-23 02:05:44 +01003332 var template PDU_BSSAP exp_compl := tr_BSSMAP_AssignmentComplete(omit, omit);
Philipp Maier48604732018-10-09 15:00:37 +02003333 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte4532e0a2017-12-23 02:05:44 +01003334 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeSIGNAL);
Daniel Willmannebdecc02020-08-12 15:30:17 +02003335
3336 f_statsd_reset();
Harald Weltea0630032018-03-20 21:09:55 +01003337 f_establish_fully(ass_cmd, exp_compl);
Daniel Willmannebdecc02020-08-12 15:30:17 +02003338
3339 var StatsDExpects expect := {
Daniel Willmannc5398f72020-09-21 10:41:35 +02003340 { name := "TTCN3.bts.0.chreq.total", mtype := "c", min := 1, max := 1},
3341 { name := "TTCN3.bts.0.chreq.successful", mtype := "c", min := 1, max := 1},
Daniel Willmannebdecc02020-08-12 15:30:17 +02003342 { name := "TTCN3.bsc.0.assignment.attempted", mtype := "c", min := 1, max := 1},
3343 { name := "TTCN3.bsc.0.assignment.completed", mtype := "c", min := 1, max := 1}
3344 };
3345 f_statsd_expect(expect);
Harald Welte4532e0a2017-12-23 02:05:44 +01003346}
3347
3348testcase TC_assignment_sign() runs on test_CT {
3349 var MSC_ConnHdlr vc_conn;
3350
3351 f_init(1, true);
3352 f_sleep(1.0);
3353
Harald Welte8863fa12018-05-10 20:15:27 +02003354 vc_conn := f_start_handler(refers(f_tc_assignment_sign));
Harald Welte4532e0a2017-12-23 02:05:44 +01003355 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003356 f_shutdown_helper();
Harald Welte4532e0a2017-12-23 02:05:44 +01003357}
3358
Harald Welte60aa5762018-03-21 19:33:13 +01003359/***********************************************************************
3360 * Codec (list) testing
3361 ***********************************************************************/
3362
3363/* check if the given rsl_mode is compatible with the a_elem */
3364private function f_match_codec(BSSMAP_FIELD_CodecElement a_elem, RSL_IE_ChannelMode rsl_mode)
3365return boolean {
3366 select (a_elem.codecType) {
3367 case (GSM_FR) {
3368 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM1))) {
3369 return true;
3370 }
3371 }
3372 case (GSM_HR) {
3373 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_H, RSL_CMOD_SP_GSM1))) {
3374 return true;
3375 }
3376 }
3377 case (GSM_EFR) {
3378 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM2))) {
3379 return true;
3380 }
3381 }
3382 case (FR_AMR) {
3383 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM3))) {
3384 return true;
3385 }
3386 }
3387 case (HR_AMR) {
3388 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_H, RSL_CMOD_SP_GSM3))) {
3389 return true;
3390 }
3391 }
3392 case else { }
3393 }
3394 return false;
3395}
3396
3397/* check if the given rsl_mode is compatible with the a_list */
3398private function f_match_codecs(BSSMAP_IE_SpeechCodecList a_list, RSL_IE_ChannelMode rsl_mode)
3399return boolean {
3400 for (var integer i := 0; i < sizeof(a_list); i := i+1) {
3401 if (f_match_codec(a_list.codecElements[i], rsl_mode)) {
3402 return true;
3403 }
3404 }
3405 return false;
3406}
3407
3408/* determine BSSMAP_IE_ChannelType from *first* element of BSSMAP_FIELD_CodecElement */
Philipp Maier61f6b572018-07-06 14:03:38 +02003409function f_BSSMAP_chtype_from_codec(BSSMAP_FIELD_CodecElement a_elem)
Harald Welte60aa5762018-03-21 19:33:13 +01003410return BSSMAP_IE_ChannelType {
3411 /* FIXME: actually look at all elements of BSSMAP_IE_SpeechCodecList */
3412 var BSSMAP_IE_ChannelType ret := valueof(ts_BSSMAP_IE_ChannelType);
3413 select (a_elem.codecType) {
3414 case (GSM_FR) {
3415 ret.channelRateAndType := ChRate_TCHF;
3416 ret.speechId_DataIndicator := Spdi_TCHF_FR;
3417 }
3418 case (GSM_HR) {
3419 ret.channelRateAndType := ChRate_TCHH;
3420 ret.speechId_DataIndicator := Spdi_TCHH_HR;
3421 }
3422 case (GSM_EFR) {
3423 ret.channelRateAndType := ChRate_TCHF;
3424 ret.speechId_DataIndicator := Spdi_TCHF_EFR;
3425 }
3426 case (FR_AMR) {
3427 ret.channelRateAndType := ChRate_TCHF;
3428 ret.speechId_DataIndicator := Spdi_TCHF_AMR;
3429 }
3430 case (HR_AMR) {
3431 ret.channelRateAndType := ChRate_TCHH;
3432 ret.speechId_DataIndicator := Spdi_TCHH_AMR;
3433 }
3434 case else {
3435 setverdict(fail, "Unsupported codec ", a_elem);
Daniel Willmannafce8662018-07-06 23:11:32 +02003436 mtc.stop;
Harald Welte60aa5762018-03-21 19:33:13 +01003437 }
3438 }
3439 return ret;
3440}
3441
Harald Weltea63b9102018-03-22 20:36:16 +01003442private function f_rsl_chmod_tmpl_from_codec(BSSMAP_FIELD_CodecElement a_elem)
3443return template RSL_IE_Body {
3444 var template RSL_IE_Body mode_ie := {
3445 chan_mode := {
3446 len := ?,
3447 reserved := ?,
3448 dtx_d := ?,
3449 dtx_u := ?,
3450 spd_ind := RSL_SPDI_SPEECH,
3451 ch_rate_type := -,
3452 coding_alg_rate := -
3453 }
3454 }
3455
3456 select (a_elem.codecType) {
3457 case (GSM_FR) {
3458 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_F;
3459 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM1;
3460 }
3461 case (GSM_HR) {
3462 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_H;
3463 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM1;
3464 }
3465 case (GSM_EFR) {
3466 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_F;
3467 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM2;
3468 }
3469 case (FR_AMR) {
3470 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_F;
3471 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM3;
3472 }
3473 case (HR_AMR) {
3474 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_H;
3475 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM3;
3476 }
3477 }
3478 return mode_ie;
3479}
3480
Harald Welte60aa5762018-03-21 19:33:13 +01003481type record CodecListTest {
3482 BSSMAP_IE_SpeechCodecList codec_list,
3483 charstring id
3484}
3485type record of CodecListTest CodecListTests
3486
3487private function f_TC_assignment_codec(charstring id) runs on MSC_ConnHdlr {
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02003488 var PDU_BSSAP ass_cmd := f_gen_ass_req(g_pars.use_osmux);
3489 var template PDU_BSSAP exp_compl := f_gen_exp_compl(g_pars.use_osmux);
Harald Welte60aa5762018-03-21 19:33:13 +01003490
3491 /* puzzle together the ASSIGNMENT REQ for given codec[s] */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003492 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
Harald Welte79f3f542018-05-25 20:02:37 +02003493 ass_cmd.pdu.bssmap.assignmentRequest.codecList := g_pars.ass_codec_list;
3494 exp_compl.pdu.bssmap.assignmentComplete.speechCodec.codecElements[0] :=
3495 g_pars.ass_codec_list.codecElements[0];
Philipp Maierd0e64b02019-03-13 14:15:23 +01003496 if (isvalue(g_pars.expect_mr_s0_s7)) {
3497 exp_compl.pdu.bssmap.assignmentComplete.speechCodec.codecElements[0].s0_7 :=
3498 g_pars.expect_mr_s0_s7;
3499 }
Harald Welte79f3f542018-05-25 20:02:37 +02003500 }
Harald Welte60aa5762018-03-21 19:33:13 +01003501 ass_cmd.pdu.bssmap.assignmentRequest.channelType :=
3502 f_BSSMAP_chtype_from_codec(g_pars.ass_codec_list.codecElements[0]);
Harald Welte60aa5762018-03-21 19:33:13 +01003503 log("expecting ASS COMPL like this: ", exp_compl);
3504
3505 f_establish_fully(ass_cmd, exp_compl);
Harald Weltea63b9102018-03-22 20:36:16 +01003506
3507 /* Verify that the RSL-side activation actually matches our expectations */
3508 var RSL_Message rsl := f_rslem_get_last_act(RSL_PROC, 0, g_chan_nr);
3509
3510 var RSL_IE_Body mode_ie;
3511 if (f_rsl_find_ie(rsl, RSL_IE_CHAN_MODE, mode_ie) == false) {
3512 setverdict(fail, "Couldn't find CHAN_MODE IE");
Daniel Willmannafce8662018-07-06 23:11:32 +02003513 mtc.stop;
Harald Weltea63b9102018-03-22 20:36:16 +01003514 }
3515 var template RSL_IE_Body t_mode_ie := f_rsl_chmod_tmpl_from_codec(g_pars.ass_codec_list.codecElements[0]);
3516 if (not match(mode_ie, t_mode_ie)) {
3517 setverdict(fail, "RSL Channel Mode IE doesn't match expectation");
3518 }
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02003519
3520 var RSL_IE_Body mr_conf;
3521 if (g_pars.expect_mr_conf_ie != omit) {
3522 if (f_rsl_find_ie(rsl, RSL_IE_MR_CONFIG, mr_conf) == false) {
3523 setverdict(fail, "Missing MR CONFIG IE in RSL Chan Activ");
Daniel Willmannafce8662018-07-06 23:11:32 +02003524 mtc.stop;
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02003525 }
3526 log("found RSL MR CONFIG IE: ", mr_conf);
3527
3528 if (not match(mr_conf, g_pars.expect_mr_conf_ie)) {
3529 setverdict(fail, "RSL MR CONFIG IE does not match expectation. Expected: ",
3530 g_pars.expect_mr_conf_ie);
3531 }
3532 } else {
3533 if (f_rsl_find_ie(rsl, RSL_IE_MR_CONFIG, mr_conf) == true) {
3534 log("found RSL MR CONFIG IE: ", mr_conf);
3535 setverdict(fail, "Found MR CONFIG IE in RSL Chan Activ, expecting omit");
Daniel Willmannafce8662018-07-06 23:11:32 +02003536 mtc.stop;
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02003537 }
3538 }
Harald Welte60aa5762018-03-21 19:33:13 +01003539}
3540
Philipp Maierd0e64b02019-03-13 14:15:23 +01003541private function f_TC_assignment_codec_fail(charstring id) runs on MSC_ConnHdlr {
3542
3543 var PDU_BSSAP ass_cmd := f_gen_ass_req();
3544 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
3545
3546 /* puzzle together the ASSIGNMENT REQ for given codec[s] */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003547 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
Philipp Maierd0e64b02019-03-13 14:15:23 +01003548 ass_cmd.pdu.bssmap.assignmentRequest.codecList := g_pars.ass_codec_list;
3549 }
3550 ass_cmd.pdu.bssmap.assignmentRequest.channelType :=
3551 f_BSSMAP_chtype_from_codec(g_pars.ass_codec_list.codecElements[0]);
3552 log("expecting ASS FAIL like this: ", exp_fail);
3553
3554 f_establish_fully(ass_cmd, exp_fail);
3555}
3556
Harald Welte60aa5762018-03-21 19:33:13 +01003557testcase TC_assignment_codec_fr() runs on test_CT {
Philipp Maier48604732018-10-09 15:00:37 +02003558 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte60aa5762018-03-21 19:33:13 +01003559 var MSC_ConnHdlr vc_conn;
3560
3561 f_init(1, true);
3562 f_sleep(1.0);
3563
3564 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
Harald Welte8863fa12018-05-10 20:15:27 +02003565 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01003566 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003567 f_shutdown_helper();
Harald Welte60aa5762018-03-21 19:33:13 +01003568}
3569
3570testcase TC_assignment_codec_hr() runs on test_CT {
Philipp Maier48604732018-10-09 15:00:37 +02003571 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte60aa5762018-03-21 19:33:13 +01003572 var MSC_ConnHdlr vc_conn;
3573
3574 f_init(1, true);
3575 f_sleep(1.0);
3576
3577 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR}));
Harald Welte8863fa12018-05-10 20:15:27 +02003578 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01003579 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003580 f_shutdown_helper();
Harald Welte60aa5762018-03-21 19:33:13 +01003581}
3582
3583testcase TC_assignment_codec_efr() runs on test_CT {
Philipp Maier48604732018-10-09 15:00:37 +02003584 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte60aa5762018-03-21 19:33:13 +01003585 var MSC_ConnHdlr vc_conn;
3586
3587 f_init(1, true);
3588 f_sleep(1.0);
3589
3590 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecEFR}));
Harald Welte8863fa12018-05-10 20:15:27 +02003591 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01003592 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003593 f_shutdown_helper();
Harald Welte60aa5762018-03-21 19:33:13 +01003594}
3595
Philipp Maierd0e64b02019-03-13 14:15:23 +01003596/* Allow 5,90k only (current default config) */
3597private function f_allow_amr_rate_5_90k() runs on test_CT {
3598 f_vty_enter_cfg_msc(BSCVTY, 0);
3599 f_vty_transceive(BSCVTY, "amr-config 12_2k forbidden");
3600 f_vty_transceive(BSCVTY, "amr-config 10_2k forbidden");
3601 f_vty_transceive(BSCVTY, "amr-config 7_95k forbidden");
3602 f_vty_transceive(BSCVTY, "amr-config 7_40k forbidden");
3603 f_vty_transceive(BSCVTY, "amr-config 6_70k forbidden");
3604 f_vty_transceive(BSCVTY, "amr-config 5_90k allowed");
3605 f_vty_transceive(BSCVTY, "amr-config 5_15k forbidden");
3606 f_vty_transceive(BSCVTY, "amr-config 4_75k forbidden");
3607 f_vty_transceive(BSCVTY, "exit");
3608 f_vty_transceive(BSCVTY, "exit");
3609}
3610
3611/* Allow 4,75k, 5,90k, 4,70k and 12,2k, which are the most common rates
3612 * ("Config-NB-Code = 1") */
3613private function f_allow_amr_rate_4_75k_5_90k_7_40k_12_20k() runs on test_CT {
3614 f_vty_enter_cfg_msc(BSCVTY, 0);
3615 f_vty_transceive(BSCVTY, "amr-config 12_2k allowed");
3616 f_vty_transceive(BSCVTY, "amr-config 10_2k forbidden");
3617 f_vty_transceive(BSCVTY, "amr-config 7_95k forbidden");
3618 f_vty_transceive(BSCVTY, "amr-config 7_40k allowed");
3619 f_vty_transceive(BSCVTY, "amr-config 6_70k forbidden");
3620 f_vty_transceive(BSCVTY, "amr-config 5_90k allowed");
3621 f_vty_transceive(BSCVTY, "amr-config 5_15k forbidden");
3622 f_vty_transceive(BSCVTY, "amr-config 4_75k allowed");
3623 f_vty_transceive(BSCVTY, "exit");
3624 f_vty_transceive(BSCVTY, "exit");
3625}
3626
Harald Welte60aa5762018-03-21 19:33:13 +01003627testcase TC_assignment_codec_amr_f() runs on test_CT {
Philipp Maier48604732018-10-09 15:00:37 +02003628 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte60aa5762018-03-21 19:33:13 +01003629 var MSC_ConnHdlr vc_conn;
Philipp Maier7695a0d2018-09-27 17:52:14 +02003630
3631 /* Note: This setups the codec configuration. The parameter payload in
3632 * mr_conf must be consistant with the parameter codecElements in pars
3633 * and also must match the amr-config in osmo-bsc.cfg! */
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02003634 var RSL_IE_Body mr_conf := {
3635 other := {
3636 len := 2,
3637 payload := '2804'O
3638 }
3639 };
Harald Welte60aa5762018-03-21 19:33:13 +01003640
Philipp Maier7695a0d2018-09-27 17:52:14 +02003641 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_F}));
Philipp Maier806f8f12019-03-12 12:13:41 +01003642 pars.ass_codec_list.codecElements[0].s0_7 := '00000100'B; /* 5,90k */
Philipp Maier7695a0d2018-09-27 17:52:14 +02003643 pars.ass_codec_list.codecElements[0].s8_15 := '01010111'B;
3644 pars.expect_mr_conf_ie := mr_conf;
3645
Harald Welte60aa5762018-03-21 19:33:13 +01003646 f_init(1, true);
3647 f_sleep(1.0);
3648
Harald Welte8863fa12018-05-10 20:15:27 +02003649 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01003650 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003651 f_shutdown_helper();
Harald Welte60aa5762018-03-21 19:33:13 +01003652}
3653
3654testcase TC_assignment_codec_amr_h() runs on test_CT {
Philipp Maier48604732018-10-09 15:00:37 +02003655 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte60aa5762018-03-21 19:33:13 +01003656 var MSC_ConnHdlr vc_conn;
Philipp Maier7695a0d2018-09-27 17:52:14 +02003657
3658 /* See note above */
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02003659 var RSL_IE_Body mr_conf := {
3660 other := {
3661 len := 2,
3662 payload := '2804'O
3663 }
3664 };
Harald Welte60aa5762018-03-21 19:33:13 +01003665
Philipp Maier7695a0d2018-09-27 17:52:14 +02003666 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_H}));
Philipp Maier806f8f12019-03-12 12:13:41 +01003667 pars.ass_codec_list.codecElements[0].s0_7 := '00000100'B; /* 5,90k */
Philipp Maier7695a0d2018-09-27 17:52:14 +02003668 pars.ass_codec_list.codecElements[0].s8_15 := '00000111'B;
3669 pars.expect_mr_conf_ie := mr_conf;
3670
Harald Welte60aa5762018-03-21 19:33:13 +01003671 f_init(1, true);
3672 f_sleep(1.0);
3673
Harald Welte8863fa12018-05-10 20:15:27 +02003674 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01003675 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003676 f_shutdown_helper();
Harald Welte60aa5762018-03-21 19:33:13 +01003677}
3678
Philipp Maierd0e64b02019-03-13 14:15:23 +01003679function f_TC_assignment_codec_amr(boolean fr, octetstring mrconf, bitstring s8_s0, bitstring exp_s8_s0)
3680runs on test_CT {
3681
3682 var TestHdlrParams pars := f_gen_test_hdlr_pars();
3683 var MSC_ConnHdlr vc_conn;
3684
3685 /* See note above */
3686 var RSL_IE_Body mr_conf := {
3687 other := {
3688 len := lengthof(mrconf),
3689 payload := mrconf
3690 }
3691 };
3692
3693 if (fr) {
3694 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_F}));
3695 } else {
3696 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_H}));
3697 }
3698 pars.ass_codec_list.codecElements[0].s0_7 := s8_s0;
3699 pars.ass_codec_list.codecElements[0].s8_15 := '00000111'B;
3700 pars.expect_mr_conf_ie := mr_conf;
3701 pars.expect_mr_s0_s7 := exp_s8_s0;
3702
3703 f_init(1, true);
3704 f_allow_amr_rate_4_75k_5_90k_7_40k_12_20k();
3705 f_sleep(1.0);
3706
3707 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
3708 vc_conn.done;
3709 f_allow_amr_rate_5_90k();
3710}
3711
3712function f_TC_assignment_codec_amr_fail(boolean fr, bitstring s8_s0)
3713runs on test_CT {
3714
3715 var TestHdlrParams pars := f_gen_test_hdlr_pars();
3716 var MSC_ConnHdlr vc_conn;
3717
3718 if (fr) {
3719 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_F}));
3720 } else {
3721 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_H}));
3722 }
3723 pars.ass_codec_list.codecElements[0].s0_7 := s8_s0;
3724 pars.ass_codec_list.codecElements[0].s8_15 := '00000111'B;
3725
3726 f_init(1, true);
3727 f_allow_amr_rate_4_75k_5_90k_7_40k_12_20k();
3728 f_sleep(1.0);
3729
3730 vc_conn := f_start_handler(refers(f_TC_assignment_codec_fail), pars);
3731 vc_conn.done;
3732 f_allow_amr_rate_5_90k();
3733}
3734
3735
3736/* Set S1, we expect an AMR multirate configuration IE with all four rates
3737 * set. */
3738testcase TC_assignment_codec_amr_f_S1() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003739 f_TC_assignment_codec_amr(true, '289520882208'O, '00000010'B, '00000010'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003740 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003741}
3742
3743/* Set S1, we expect an AMR multirate configuration IE with the lower three
3744 * rates set. */
3745testcase TC_assignment_codec_amr_h_S1() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003746 f_TC_assignment_codec_amr(false, '2815208820'O, '00000010'B, '00000010'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003747 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003748}
3749
3750/* Set S1 and two other rates, we expect an AMR MULTIRATE CONFIGURATION IE with
3751 * all four rates (and only S1 set in the ASSIGNMENT COMPLETE) */
3752testcase TC_assignment_codec_amr_f_S124() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003753 f_TC_assignment_codec_amr(true, '289520882208'O, '00010110'B, '00000010'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003754 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003755}
3756
3757/* Set S1 and two other rates, we expect an AMR MULTIRATE CONFIGURATION IE with
3758 * all four rates (and only S1 set in the ASSIGNMENT COMPLETE) */
3759testcase TC_assignment_codec_amr_h_S124() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003760 f_TC_assignment_codec_amr(false, '2815208820'O, '00010110'B, '00000010'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003761 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003762}
3763
3764/* The following block of tests selects more and more rates until all four
3765 * possible rates are in the active set (full rate) */
3766testcase TC_assignment_codec_amr_f_S0() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003767 f_TC_assignment_codec_amr(true, '2801'O, '00000001'B, '00000001'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003768 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003769}
3770
3771testcase TC_assignment_codec_amr_f_S02() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003772 f_TC_assignment_codec_amr(true, '28052080'O, '00000101'B, '00000101'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003773 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003774}
3775
3776testcase TC_assignment_codec_amr_f_S024() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003777 f_TC_assignment_codec_amr(true, '2815208820'O, '00010101'B, '00010101'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003778 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003779}
3780
3781testcase TC_assignment_codec_amr_f_S0247() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003782 f_TC_assignment_codec_amr(true, '289520882208'O, '10010101'B, '10010101'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003783 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003784}
3785
3786/* The following block of tests selects more and more rates until all three
3787 * possible rates are in the active set (half rate) */
3788testcase TC_assignment_codec_amr_h_S0() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003789 f_TC_assignment_codec_amr(false, '2801'O, '00000001'B, '00000001'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003790 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003791}
3792
3793testcase TC_assignment_codec_amr_h_S02() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003794 f_TC_assignment_codec_amr(false, '28052080'O, '00000101'B, '00000101'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003795 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003796}
3797
3798testcase TC_assignment_codec_amr_h_S024() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003799 f_TC_assignment_codec_amr(false, '2815208820'O, '00010101'B, '00010101'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003800 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003801}
3802
3803/* The following block tests what happens when the MSC does offer rate
3804 * configurations that are not supported by the BSC. Normally such situations
3805 * should not happen because the MSC gets informed by the BSC in advance via
3806 * the L3 COMPLETE message which rates are applicable. The MSC should not try
3807 * to offer rates that are not applicable anyway. */
3808
3809testcase TC_assignment_codec_amr_h_S0247() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003810 /* Try to include 12,2k in into the active set even though the channel
3811 * is half rate only. The BSC is expected to remove the 12,0k */
3812 f_TC_assignment_codec_amr(false, '2815208820'O, '10010101'B, '00010101'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003813 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003814}
3815
3816testcase TC_assignment_codec_amr_f_S01234567() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003817 /* See what happens when all rates are selected at once. Since then
3818 * Also S1 is selected, this setting will be prefered and we should
3819 * get 12.2k, 7,40k, 5,90k, and 4,75k in the active set. */
3820 f_TC_assignment_codec_amr(true, '289520882208'O, '11111111'B, '00000010'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003821 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003822}
3823
3824testcase TC_assignment_codec_amr_f_S0234567() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003825 /* Same as above, but with S1 missing, the MSC is then expected to
3826 * select the currently supported rates, which are also 12.2k, 7,40k,
3827 * 5,90k, and 4,75k, into the active set. */
3828 f_TC_assignment_codec_amr(true, '289520882208'O, '11111101'B, '10010101'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003829 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003830}
3831
3832testcase TC_assignment_codec_amr_f_zero() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003833 /* Try to select no rates at all */
3834 f_TC_assignment_codec_amr_fail(true, '00000000'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003835 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003836}
3837
3838testcase TC_assignment_codec_amr_f_unsupp() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003839 /* Try to select only unsupported rates */
3840 f_TC_assignment_codec_amr_fail(true, '01101000'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003841 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003842}
3843
3844testcase TC_assignment_codec_amr_h_S7() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003845 /* Try to select 12,2k for half rate */
3846 f_TC_assignment_codec_amr_fail(false, '10000000'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003847 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003848}
3849
Philipp Maierac09bfc2019-01-08 13:41:39 +01003850private function f_disable_all_tch_f() runs on test_CT {
Philipp Maierc704a882019-01-29 15:58:52 +01003851 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 1 sub-slot 0 borken");
3852 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 2 sub-slot 0 borken");
3853 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 3 sub-slot 0 borken");
3854 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 4 sub-slot 0 borken");
Philipp Maierac09bfc2019-01-08 13:41:39 +01003855}
3856
3857private function f_disable_all_tch_h() runs on test_CT {
Philipp Maierc704a882019-01-29 15:58:52 +01003858 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 5 sub-slot 0 borken");
3859 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 5 sub-slot 1 borken");
Philipp Maierac09bfc2019-01-08 13:41:39 +01003860}
3861
3862private function f_enable_all_tch() runs on test_CT {
Philipp Maierc704a882019-01-29 15:58:52 +01003863 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 1 sub-slot 0 unused");
3864 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 2 sub-slot 0 unused");
3865 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 3 sub-slot 0 unused");
3866 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 4 sub-slot 0 unused");
3867 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 5 sub-slot 0 unused");
3868 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 5 sub-slot 1 unused");
Philipp Maierac09bfc2019-01-08 13:41:39 +01003869}
3870
3871/* Allow HR only */
3872private function f_TC_assignment_codec_xr_exhausted_req_hr(charstring id) runs on MSC_ConnHdlr {
3873 g_pars := f_gen_test_hdlr_pars();
3874 var PDU_BSSAP ass_cmd := f_gen_ass_req();
3875 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3876 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3877 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '09'O;
3878 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '05'O;
3879 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR}));
3880 f_establish_fully(ass_cmd, exp_compl);
3881}
3882
3883/* Allow FR only */
3884private function f_TC_assignment_codec_xr_exhausted_req_fr(charstring id) runs on MSC_ConnHdlr {
3885 g_pars := f_gen_test_hdlr_pars();
3886 var PDU_BSSAP ass_cmd := f_gen_ass_req();
3887 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3888 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3889 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '08'O;
3890 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '01'O;
3891 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
3892 f_establish_fully(ass_cmd, exp_compl);
3893}
3894
3895/* Allow HR only (expect assignment failure) */
3896private function f_TC_assignment_codec_xr_exhausted_req_hr_fail(charstring id) runs on MSC_ConnHdlr {
3897 g_pars := f_gen_test_hdlr_pars();
3898 var PDU_BSSAP ass_cmd := f_gen_ass_req();
3899 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
3900 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3901 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '09'O;
3902 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '05'O;
3903 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR}));
3904 f_establish_fully(ass_cmd, exp_fail);
3905}
3906
3907/* Allow FR only (expect assignment failure) */
3908private function f_TC_assignment_codec_xr_exhausted_req_fr_fail(charstring id) runs on MSC_ConnHdlr {
3909 g_pars := f_gen_test_hdlr_pars();
3910 var PDU_BSSAP ass_cmd := f_gen_ass_req();
3911 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
3912 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3913 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '08'O;
3914 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '01'O;
3915 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
3916 f_establish_fully(ass_cmd, exp_fail);
3917}
3918
3919/* Allow FR and HR, but prefer FR */
3920private function f_TC_assignment_codec_fr_exhausted_req_fr_hr(charstring id) runs on MSC_ConnHdlr {
3921 g_pars := f_gen_test_hdlr_pars();
3922 var PDU_BSSAP ass_cmd := f_gen_ass_req();
3923 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3924 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3925 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0A'O; /* Prefer FR */
3926 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8105'O;
3927 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR, ts_CodecHR}));
3928 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000101'B; /* Expect HR */
3929 f_establish_fully(ass_cmd, exp_compl);
3930}
3931
3932/* Allow FR and HR, but prefer HR */
3933private function f_TC_assignment_codec_fr_exhausted_req_hr_fr(charstring id) runs on MSC_ConnHdlr {
3934 g_pars := f_gen_test_hdlr_pars();
3935 var PDU_BSSAP ass_cmd := f_gen_ass_req();
3936 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3937 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3938 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0B'O; /* Prefer HR */
3939 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8501'O;
3940 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR, ts_CodecFR}));
3941 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000101'B; /* Expect HR */
3942 f_establish_fully(ass_cmd, exp_compl);
3943}
3944
3945/* Allow FR and HR, but prefer FR */
3946private function f_TC_assignment_codec_hr_exhausted_req_fr_hr(charstring id) runs on MSC_ConnHdlr {
3947 g_pars := f_gen_test_hdlr_pars();
3948 var PDU_BSSAP ass_cmd := f_gen_ass_req();
3949 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3950 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3951 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0A'O; /* Prefer FR */
3952 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8105'O;
3953 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR, ts_CodecHR}));
3954 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000001'B; /* Expect FR */
3955 f_establish_fully(ass_cmd, exp_compl);
3956}
3957
3958/* Allow FR and HR, but prefer HR */
3959private function f_TC_assignment_codec_hr_exhausted_req_hr_fr(charstring id) runs on MSC_ConnHdlr {
3960 g_pars := f_gen_test_hdlr_pars();
3961 var PDU_BSSAP ass_cmd := f_gen_ass_req();
3962 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3963 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3964 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0B'O; /* Prefer HR */
3965 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8501'O;
3966 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR, ts_CodecFR}));
3967 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000001'B; /* Expect FR */
3968 f_establish_fully(ass_cmd, exp_compl);
3969}
3970
3971/* Request a HR channel while all FR channels are exhausted, this is expected
3972 * to work without conflicts */
3973testcase TC_assignment_codec_fr_exhausted_req_hr() runs on test_CT {
3974 var MSC_ConnHdlr vc_conn;
3975 f_init(1, true);
3976 f_sleep(1.0);
3977 f_enable_all_tch();
3978 f_disable_all_tch_f();
3979 vc_conn := f_start_handler(refers(f_TC_assignment_codec_xr_exhausted_req_hr));
3980 vc_conn.done;
3981 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003982 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01003983}
3984
3985/* Request a FR channel while all FR channels are exhausted, this is expected
3986 * to fail. */
3987testcase TC_assignment_codec_fr_exhausted_req_fr() runs on test_CT {
3988 var MSC_ConnHdlr vc_conn;
3989 f_init(1, true);
3990 f_sleep(1.0);
3991 f_enable_all_tch();
3992 f_disable_all_tch_f();
3993 vc_conn := f_start_handler(refers(f_TC_assignment_codec_xr_exhausted_req_fr_fail));
3994 vc_conn.done;
3995 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003996 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01003997}
3998
3999/* Request a FR (prefered) or alternatively a HR channel while all FR channels
4000 * are exhausted, this is expected to be resolved by selecting a HR channel. */
4001testcase TC_assignment_codec_fr_exhausted_req_fr_hr() runs on test_CT {
4002 var MSC_ConnHdlr vc_conn;
4003 f_init(1, true);
4004 f_sleep(1.0);
4005 f_enable_all_tch();
4006 f_disable_all_tch_f();
4007 vc_conn := f_start_handler(refers(f_TC_assignment_codec_fr_exhausted_req_fr_hr));
4008 vc_conn.done;
4009 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004010 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004011}
4012
4013/* Request a HR (prefered) or alternatively a FR channel while all FR channels
4014 * are exhausted, this is expected to work without conflicts. */
4015testcase TC_assignment_codec_fr_exhausted_req_hr_fr() runs on test_CT {
4016 var MSC_ConnHdlr vc_conn;
4017 f_init(1, true);
4018 f_sleep(1.0);
4019 f_enable_all_tch();
4020 f_disable_all_tch_f();
4021 vc_conn := f_start_handler(refers(f_TC_assignment_codec_fr_exhausted_req_hr_fr));
4022 vc_conn.done;
4023 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004024 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004025}
4026
4027/* Request a FR channel while all HR channels are exhausted, this is expected
4028 * to work without conflicts */
4029testcase TC_assignment_codec_hr_exhausted_req_fr() runs on test_CT {
4030 var MSC_ConnHdlr vc_conn;
4031 f_init(1, true);
4032 f_sleep(1.0);
4033 f_enable_all_tch();
4034 f_disable_all_tch_h();
4035 vc_conn := f_start_handler(refers(f_TC_assignment_codec_xr_exhausted_req_fr));
4036 vc_conn.done;
4037 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004038 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004039}
4040
4041/* Request a HR channel while all HR channels are exhausted, this is expected
4042 * to fail. */
4043testcase TC_assignment_codec_hr_exhausted_req_hr() runs on test_CT {
4044 var MSC_ConnHdlr vc_conn;
4045 f_init(1, true);
4046 f_sleep(1.0);
4047 f_enable_all_tch();
4048 f_disable_all_tch_h();
4049 vc_conn := f_start_handler(refers(f_TC_assignment_codec_xr_exhausted_req_hr_fail));
4050 vc_conn.done;
4051 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004052 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004053}
4054
4055/* Request a HR (prefered) or alternatively a FR channel while all HR channels
4056 * are exhausted, this is expected to be resolved by selecting a FR channel. */
4057testcase TC_assignment_codec_hr_exhausted_req_hr_fr() runs on test_CT {
4058 var MSC_ConnHdlr vc_conn;
4059 f_init(1, true);
4060 f_sleep(1.0);
4061 f_enable_all_tch();
4062 f_disable_all_tch_h();
4063 vc_conn := f_start_handler(refers(f_TC_assignment_codec_hr_exhausted_req_hr_fr));
4064 vc_conn.done;
4065 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004066 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004067}
4068
4069/* Request a FR (prefered) or alternatively a HR channel while all HR channels
4070 * are exhausted, this is expected to work without conflicts. */
4071testcase TC_assignment_codec_hr_exhausted_req_fr_hr() runs on test_CT {
4072 var MSC_ConnHdlr vc_conn;
4073 f_init(1, true);
4074 f_sleep(1.0);
4075 f_enable_all_tch();
4076 f_disable_all_tch_h();
4077 vc_conn := f_start_handler(refers(f_TC_assignment_codec_hr_exhausted_req_fr_hr));
4078 vc_conn.done;
4079 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004080 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004081}
4082
4083/* Allow FR and HR, but prefer HR */
4084private function f_TC_assignment_codec_req_hr_fr(charstring id) runs on MSC_ConnHdlr {
4085 g_pars := f_gen_test_hdlr_pars();
4086 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4087 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4088 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4089 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0B'O; /* Prefer HR */
4090 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8501'O;
4091 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR, ts_CodecFR}));
4092 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000101'B; /* Expect HR */
4093 f_establish_fully(ass_cmd, exp_compl);
4094}
4095
4096/* Allow FR and HR, but prefer FR */
4097private function f_TC_assignment_codec_req_fr_hr(charstring id) runs on MSC_ConnHdlr {
4098 g_pars := f_gen_test_hdlr_pars();
4099 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4100 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4101 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4102 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0A'O; /* Prefer FR */
4103 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8105'O;
4104 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR, ts_CodecHR}));
4105 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000001'B; /* Expect FR */
4106 f_establish_fully(ass_cmd, exp_compl);
4107}
4108
4109/* Request a HR (prefered) or alternatively a FR channel, it is expected that
4110 * HR, which is the prefered type, is selected. */
4111testcase TC_assignment_codec_req_hr_fr() runs on test_CT {
4112 var MSC_ConnHdlr vc_conn;
4113 f_init(1, true);
4114 f_sleep(1.0);
4115 f_enable_all_tch();
4116 vc_conn := f_start_handler(refers(f_TC_assignment_codec_req_hr_fr));
4117 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004118 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004119}
4120
4121/* Request a FR (prefered) or alternatively a HR channel, it is expected that
4122 * FR, which is the prefered type, is selected. */
4123testcase TC_assignment_codec_req_fr_hr() runs on test_CT {
4124 var MSC_ConnHdlr vc_conn;
4125 f_init(1, true);
4126 f_sleep(1.0);
4127 f_enable_all_tch();
4128 vc_conn := f_start_handler(refers(f_TC_assignment_codec_req_fr_hr));
4129 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004130 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004131}
4132
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02004133testcase TC_assignment_osmux() runs on test_CT {
4134 var TestHdlrParams pars := f_gen_test_hdlr_pars();
4135 var MSC_ConnHdlr vc_conn;
4136
4137 /* See note above */
4138 var RSL_IE_Body mr_conf := {
4139 other := {
4140 len := 2,
4141 payload := '2804'O
4142 }
4143 };
4144
4145 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_H}));
4146 pars.ass_codec_list.codecElements[0].s0_7 := '00000100'B; /* 5,90k */
4147 pars.ass_codec_list.codecElements[0].s8_15 := '00000111'B;
4148 pars.expect_mr_conf_ie := mr_conf;
4149 pars.use_osmux := true;
4150
4151 f_init(1, true, true);
4152 f_sleep(1.0);
4153
4154 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
4155 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004156 f_shutdown_helper();
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02004157}
4158
Neels Hofmeyr92b12b72018-09-18 14:30:23 +02004159/* test the procedure of the MSC requesting a Classmark Update:
4160 * a) BSSMAP Classmark Request should result in RR CLASSMARK ENQUIRY,
4161 * b) L3 RR CLASSMARK CHANGE should result in BSSMAP CLASSMARK UPDATE */
Harald Welte898113b2018-01-31 18:32:21 +01004162private function f_tc_classmark(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02004163 g_pars := f_gen_test_hdlr_pars();
4164
Harald Weltea0630032018-03-20 21:09:55 +01004165 f_create_chan_and_exp();
Harald Welte898113b2018-01-31 18:32:21 +01004166 /* we should now have a COMPL_L3 at the MSC */
4167 BSSAP.receive(tr_BSSMAP_ComplL3);
4168
Neels Hofmeyr92b12b72018-09-18 14:30:23 +02004169 BSSAP.send(ts_BSSMAP_ClassmarkRequest);
4170 RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_CM_ENQUIRY));
4171
Harald Welte898113b2018-01-31 18:32:21 +01004172 f_rsl_send_l3(ts_RRM_CM_CHG(valueof(ts_CM2)));
4173 BSSAP.receive(tr_BSSMAP_ClassmarkUpd(?, omit));
4174 setverdict(pass);
4175}
4176testcase TC_classmark() runs on test_CT {
4177 var MSC_ConnHdlr vc_conn;
4178 f_init(1, true);
4179 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02004180 vc_conn := f_start_handler(refers(f_tc_classmark));
Harald Welte898113b2018-01-31 18:32:21 +01004181 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004182 f_shutdown_helper();
Harald Welte898113b2018-01-31 18:32:21 +01004183}
4184
Harald Welteeddf0e92020-06-21 19:42:15 +02004185/* Send a CommonID from the simulated MSC and verify that the information is used to
4186 * fill BSC-internal data structures (specifically, bsc_subscr associated with subscr_conn) */
4187private function f_tc_common_id(charstring id) runs on MSC_ConnHdlr {
4188 g_pars := f_gen_test_hdlr_pars();
4189 f_MscConnHdlr_init_vty();
4190
4191 f_create_chan_and_exp();
4192 /* we should now have a COMPL_L3 at the MSC */
4193 BSSAP.receive(tr_BSSMAP_ComplL3);
4194
4195 /* Send CommonID */
4196 BSSAP.send(ts_BSSMAP_CommonId(g_pars.imsi));
4197
4198 /* Use VTY to verify that the IMSI of the subscr_conn is set */
4199 var charstring regex := "*(IMSI: " & hex2str(g_pars.imsi) & ")*";
4200 f_vty_transceive_match_regexp_retry(BSCVTY, "show conns", regex, 0, 4, 1.0);
4201
4202 setverdict(pass);
4203}
4204testcase TC_common_id() runs on test_CT {
4205 var MSC_ConnHdlr vc_conn;
4206 f_init(1, true);
4207 f_sleep(1.0);
4208 vc_conn := f_start_handler(refers(f_tc_common_id));
4209 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004210 f_shutdown_helper();
Harald Welteeddf0e92020-06-21 19:42:15 +02004211}
4212
Harald Weltee3bd6582018-01-31 22:51:25 +01004213private function f_est_single_l3(template PDU_ML3_MS_NW l3) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02004214 g_pars := f_gen_test_hdlr_pars();
Harald Weltea0630032018-03-20 21:09:55 +01004215 f_create_chan_and_exp();
Harald Welte898113b2018-01-31 18:32:21 +01004216 /* we should now have a COMPL_L3 at the MSC */
4217 BSSAP.receive(tr_BSSMAP_ComplL3);
4218
Harald Weltee3bd6582018-01-31 22:51:25 +01004219 /* send the single message we want to send */
4220 f_rsl_send_l3(l3);
4221}
4222
4223private function f_bssap_expect_nothing(float sec := 5.00) runs on MSC_ConnHdlr {
4224 timer T := sec;
4225 var PDU_BSSAP bssap;
Harald Welte898113b2018-01-31 18:32:21 +01004226 T.start;
4227 alt {
Harald Weltee3bd6582018-01-31 22:51:25 +01004228 [] BSSAP.receive(PDU_BSSAP:?) -> value bssap {
4229 setverdict(fail, "Unexpected BSSMAP ", bssap);
Daniel Willmannafce8662018-07-06 23:11:32 +02004230 mtc.stop;
Harald Welte898113b2018-01-31 18:32:21 +01004231 }
4232 [] T.timeout {
4233 setverdict(pass);
4234 }
4235 }
4236}
4237
Harald Weltee3bd6582018-01-31 22:51:25 +01004238/* unsolicited ASSIGNMENT FAIL (without ASSIGN) from MS shouldn't bring BSC down */
4239private function f_tc_unsol_ass_fail(charstring id) runs on MSC_ConnHdlr {
4240 f_est_single_l3(ts_RRM_AssignmentFailure('00'O));
4241 f_bssap_expect_nothing();
4242}
Harald Welte898113b2018-01-31 18:32:21 +01004243testcase TC_unsol_ass_fail() runs on test_CT {
4244 var MSC_ConnHdlr vc_conn;
4245 f_init(1, true);
4246 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02004247 vc_conn := f_start_handler(refers(f_tc_unsol_ass_fail));
Harald Welte898113b2018-01-31 18:32:21 +01004248 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004249 f_shutdown_helper();
Harald Welte898113b2018-01-31 18:32:21 +01004250}
Harald Welte552620d2017-12-16 23:21:36 +01004251
Harald Welteea99a002018-01-31 20:46:43 +01004252
4253/* unsolicited ASSIGNMENT COMPLETE (without ASSIGN) from MS shouldn't bring BSC down */
4254private function f_tc_unsol_ass_compl(charstring id) runs on MSC_ConnHdlr {
Harald Weltee3bd6582018-01-31 22:51:25 +01004255 f_est_single_l3(ts_RRM_AssignmentComplete('00'O));
4256 f_bssap_expect_nothing();
Harald Welteea99a002018-01-31 20:46:43 +01004257}
4258testcase TC_unsol_ass_compl() runs on test_CT {
4259 var MSC_ConnHdlr vc_conn;
4260 f_init(1, true);
4261 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02004262 vc_conn := f_start_handler(refers(f_tc_unsol_ass_compl));
Harald Welteea99a002018-01-31 20:46:43 +01004263 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004264 f_shutdown_helper();
Harald Welteea99a002018-01-31 20:46:43 +01004265}
4266
4267
Harald Weltefbf9b5e2018-01-31 20:41:23 +01004268/* unsolicited HANDOVER FAIL (without ASSIGN) from MS shouldn't bring BSC down */
4269private function f_tc_unsol_ho_fail(charstring id) runs on MSC_ConnHdlr {
Harald Weltee3bd6582018-01-31 22:51:25 +01004270 f_est_single_l3(ts_RRM_HandoverFailure('00'O));
4271 f_bssap_expect_nothing();
Harald Weltefbf9b5e2018-01-31 20:41:23 +01004272}
Harald Weltefbf9b5e2018-01-31 20:41:23 +01004273testcase TC_unsol_ho_fail() runs on test_CT {
4274 var MSC_ConnHdlr vc_conn;
4275 f_init(1, true);
4276 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02004277 vc_conn := f_start_handler(refers(f_tc_unsol_ho_fail));
Harald Weltefbf9b5e2018-01-31 20:41:23 +01004278 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004279 f_shutdown_helper();
Harald Weltefbf9b5e2018-01-31 20:41:23 +01004280}
4281
4282
Harald Weltee3bd6582018-01-31 22:51:25 +01004283/* short message from MS should be ignored */
4284private function f_tc_err_82_short_msg(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02004285 g_pars := f_gen_test_hdlr_pars();
Harald Weltea0630032018-03-20 21:09:55 +01004286 f_create_chan_and_exp();
Harald Weltee3bd6582018-01-31 22:51:25 +01004287 /* we should now have a COMPL_L3 at the MSC */
4288 BSSAP.receive(tr_BSSMAP_ComplL3);
4289
4290 /* send short message */
4291 RSL.send(ts_RSL_DATA_IND(g_chan_nr, valueof(ts_RslLinkID_DCCH(0)), ''O));
4292 f_bssap_expect_nothing();
4293}
4294testcase TC_err_82_short_msg() runs on test_CT {
4295 var MSC_ConnHdlr vc_conn;
4296 f_init(1, true);
4297 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02004298 vc_conn := f_start_handler(refers(f_tc_err_82_short_msg));
Harald Weltee3bd6582018-01-31 22:51:25 +01004299 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004300 f_shutdown_helper();
Harald Weltee3bd6582018-01-31 22:51:25 +01004301}
4302
4303
Harald Weltee9e02e42018-01-31 23:36:25 +01004304/* 24.008 8.4 Unknown message must trigger RR STATUS */
4305private function f_tc_err_84_unknown_msg(charstring id) runs on MSC_ConnHdlr {
4306 f_est_single_l3(ts_RRM_UL_REL('00'O));
4307 timer T := 3.0
4308 alt {
4309 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_STATUS)) {
4310 setverdict(pass);
4311 }
4312 [] BSSAP.receive { setverdict(fail, "unexpected BSSAP"); }
Harald Welte458fd372018-03-21 11:26:23 +01004313 [] T.timeout { setverdict(fail, "Timeout waiting for RR STATUS"); }
Harald Weltee9e02e42018-01-31 23:36:25 +01004314 }
4315}
4316testcase TC_err_84_unknown_msg() runs on test_CT {
4317 var MSC_ConnHdlr vc_conn;
4318 f_init(1, true);
4319 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02004320 vc_conn := f_start_handler(refers(f_tc_err_84_unknown_msg));
Harald Weltee9e02e42018-01-31 23:36:25 +01004321 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004322 f_shutdown_helper();
Harald Weltee9e02e42018-01-31 23:36:25 +01004323}
4324
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004325/***********************************************************************
4326 * Handover
4327 ***********************************************************************/
4328
Harald Welte94e0c342018-04-07 11:33:23 +02004329/* execute a "bts <0-255> trx <0-255> timeslot <0-7> " command on given Dchan */
4330private function f_vty_ts_action(charstring suffix, integer bts_nr, integer trx_nr, integer ts_nr)
4331runs on test_CT {
4332 var charstring cmd := "bts "&int2str(bts_nr)&" trx "&int2str(trx_nr)&
4333 " timeslot "&int2str(ts_nr)&" ";
4334 f_vty_transceive(BSCVTY, cmd & suffix);
4335}
4336
Harald Welte261af4b2018-02-12 21:20:39 +01004337/* 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 +07004338private function f_vty_ss_action(TELNETasp_PT pt, charstring suffix,
4339 uint8_t bts_nr, uint8_t trx_nr,
4340 in RslChannelNr chan_nr)
4341{
Harald Welte261af4b2018-02-12 21:20:39 +01004342 /* FIXME: resolve those from component-global state */
4343 var integer ts_nr := chan_nr.tn;
4344 var integer ss_nr;
4345 if (ischosen(chan_nr.u.ch0)) {
4346 ss_nr := 0;
4347 } else if (ischosen(chan_nr.u.lm)) {
4348 ss_nr := chan_nr.u.lm.sub_chan;
4349 } else if (ischosen(chan_nr.u.sdcch4)) {
4350 ss_nr := chan_nr.u.sdcch4.sub_chan;
4351 } else if (ischosen(chan_nr.u.sdcch8)) {
4352 ss_nr := chan_nr.u.sdcch8.sub_chan;
4353 } else {
4354 setverdict(fail, "Invalid ChanNr ", chan_nr);
Daniel Willmannafce8662018-07-06 23:11:32 +02004355 mtc.stop;
Harald Welte261af4b2018-02-12 21:20:39 +01004356 }
4357
4358 var charstring cmd := "bts "&int2str(bts_nr)&" trx "&int2str(trx_nr)&
4359 " timeslot "&int2str(ts_nr)&" sub-slot "&int2str(ss_nr)&" ";
Vadim Yanitskiy00070722020-09-02 17:27:57 +07004360 f_vty_transceive(pt, cmd & suffix);
Harald Welte261af4b2018-02-12 21:20:39 +01004361}
4362
Neels Hofmeyr91401012019-07-11 00:42:35 +02004363/* Even though the VTY command to trigger handover takes a new BTS number as argument, behind the scenes osmo-bsc always
4364 * translates that to a target ARFCN+BSIC first. See bsc_vty.c trigger_ho_or_as(), which puts the selected BTS' neighbor
4365 * ident key (ARFCN + BSIC) in the struct passed on to handover_request(). handover_start() then resolves that to a
4366 * viable actual neighbor cell. So from the internal osmo-bsc perspective, we always request handover to an ARFCN + BSIC
4367 * pair, not really to a specific BTS number. */
Vadim Yanitskiy00070722020-09-02 17:27:57 +07004368private function f_vty_handover(TELNETasp_PT pt, uint8_t bts_nr, uint8_t trx_nr,
4369 in RslChannelNr chan_nr, uint8_t new_bts_nr)
4370{
4371 f_vty_ss_action(pt, "handover " & int2str(new_bts_nr), bts_nr, trx_nr, chan_nr);
Harald Welte261af4b2018-02-12 21:20:39 +01004372}
4373
4374/* intra-BSC hand-over between BTS0 and BTS1 */
4375private function f_tc_ho_int(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02004376 g_pars := f_gen_test_hdlr_pars();
Harald Welteed848512018-05-24 22:27:58 +02004377 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4378 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte261af4b2018-02-12 21:20:39 +01004379 const OCT8 kc := '0001020304050607'O;
4380
4381 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4382 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
4383
Harald Weltea0630032018-03-20 21:09:55 +01004384 f_establish_fully(ass_cmd, exp_compl);
Neels Hofmeyr666f0432020-07-04 00:53:07 +02004385 f_bts_0_cfg(BSCVTY, {"neighbor bts 1"});
Harald Welte261af4b2018-02-12 21:20:39 +01004386
4387 var HandoverState hs := {
4388 rr_ho_cmpl_seen := false,
4389 handover_done := false,
4390 old_chan_nr := -
4391 };
4392 /* issue hand-over command on VTY */
Vadim Yanitskiy00070722020-09-02 17:27:57 +07004393 f_vty_handover(BSCVTY, 0, 0, g_chan_nr, 1);
Harald Welte261af4b2018-02-12 21:20:39 +01004394 /* temporarily suspend DChan processing on BTS1 to avoid race with RSLEM_register */
4395 f_rslem_suspend(RSL1_PROC);
Philipp Maier3e2af5d2018-07-11 17:01:05 +02004396
4397 /* From the MGW perspective, a handover is is characterized by
4398 * performing one MDCX operation with the MGW. So we expect to see
4399 * one more MDCX during handover. */
4400 g_media.mgcp_conn[0].mdcx_seen_exp := g_media.mgcp_conn[0].crcx_seen_exp + 1;
4401
Harald Welte261af4b2018-02-12 21:20:39 +01004402 alt {
4403 [] as_handover(hs);
Harald Welte261af4b2018-02-12 21:20:39 +01004404 }
Philipp Maier3e2af5d2018-07-11 17:01:05 +02004405
Philipp Maier4dae0652018-11-12 12:03:26 +01004406 /* Since this is an internal handover we expect the BSC to inform the
4407 * MSC about the event */
4408 BSSAP.receive(tr_BSSMAP_HandoverPerformed);
4409
Philipp Maier3e2af5d2018-07-11 17:01:05 +02004410 /* Check the amount of MGCP transactions is still consistant with the
4411 * test expectation */
4412 f_check_mgcp_expectations()
Neels Hofmeyr861a4c12018-11-07 01:23:17 +01004413 f_sleep(0.5);
Harald Welte261af4b2018-02-12 21:20:39 +01004414}
4415
4416testcase TC_ho_int() runs on test_CT {
4417 var MSC_ConnHdlr vc_conn;
4418 f_init(2, true);
4419 f_sleep(1.0);
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004420
4421 f_ctrs_bsc_and_bts_init();
4422
Harald Welte8863fa12018-05-10 20:15:27 +02004423 vc_conn := f_start_handler(refers(f_tc_ho_int));
Harald Welte261af4b2018-02-12 21:20:39 +01004424 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004425
4426 /* from f_establish_fully() */
4427 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
4428 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
4429 /* from handover */
4430 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
4431 f_ctrs_bsc_and_bts_add(0, "handover:completed");
4432 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
4433 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:completed");
4434 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004435 f_shutdown_helper();
Harald Welte261af4b2018-02-12 21:20:39 +01004436}
Harald Weltee9e02e42018-01-31 23:36:25 +01004437
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004438/* Expecting MGCP to DLCX the endpoint's two connections: towards BTS and towards MSC */
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02004439private function f_expect_dlcx_conns() runs on MSC_ConnHdlr {
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004440 var MgcpCommand mgcp;
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +02004441 var template MgcpResponse mgcp_resp;
4442 var MGCP_RecvFrom mrf;
4443 var template MgcpMessage msg_resp;
4444 var template MgcpMessage msg_dlcx := {
4445 command := tr_DLCX()
4446 }
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004447
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +02004448 if (g_pars.aoip) {
4449 MGCP.receive(tr_DLCX()) -> value mgcp {
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004450 log("Got first DLCX: ", mgcp);
4451 MGCP.send(ts_DLCX_ACK2(mgcp.line.trans_id));
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +02004452 };
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004453
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004454 MGCP.receive(tr_DLCX()) -> value mgcp {
4455 log("Got second DLCX: ", mgcp);
4456 MGCP.send(ts_DLCX_ACK2(mgcp.line.trans_id));
4457 };
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +02004458 } else {
4459 /* For SCCPLite, BSC doesn't handle the MSC-side */
4460 MGCP_MULTI.receive(tr_MGCP_RecvFrom_any(msg_dlcx)) -> value mrf {
4461 log("Got first DLCX: ", mrf.msg.command);
4462 msg_resp := {
4463 response := ts_DLCX_ACK2(mrf.msg.command.line.trans_id)
4464 }
4465 MGCP_MULTI.send(t_MGCP_SendToMrf(mrf, msg_resp));
4466 };
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004467 }
4468
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02004469 BSSAP.receive(tr_BSSMAP_ClearComplete);
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004470}
4471
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004472private function f_tc_ho_out_of_this_bsc(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02004473 g_pars := f_gen_test_hdlr_pars();
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004474
4475 var PDU_BSSAP ass_req := f_gen_ass_req();
4476 ass_req.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4477 ass_req.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
4478 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4479 f_establish_fully(ass_req, exp_compl);
4480
Neels Hofmeyr666f0432020-07-04 00:53:07 +02004481 f_bts_0_cfg(BSCVTY, {"neighbor lac 99 arfcn 123 bsic any"});
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004482 f_vty_transceive(BSCVTY, "handover any to arfcn 123 bsic any");
4483
4484 BSSAP.receive(tr_BSSMAP_HandoverRequired);
4485
4486 f_sleep(0.5);
4487 /* The MSC negotiates Handover Request and Handover Request Ack with
4488 * the other BSS and comes back with a BSSMAP Handover Command
4489 * containing an RR Handover Command coming from the target BSS... */
4490
4491 var PDU_ML3_NW_MS rr_ho_cmd := valueof(ts_RR_HandoverCommand);
4492 log("Remote cell's RR Handover Command passed through as L3 Info: ", rr_ho_cmd);
4493 var octetstring rr_ho_cmd_enc := enc_PDU_ML3_NW_MS(rr_ho_cmd);
4494 log("Remote cell's RR Handover Command passed through as L3 Info, encoded: ", rr_ho_cmd_enc);
4495 BSSAP.send(ts_BSSMAP_HandoverCommand(rr_ho_cmd_enc));
4496
4497 /* expect the Handover Command to go out on RR */
4498 var RSL_Message rsl_ho_cmd
4499 RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, ?)) -> value rsl_ho_cmd;
4500 log("RSL Data Req went out to first BTS: ", rsl_ho_cmd);
4501 var RSL_IE_Body rsl_ho_cmd_l3;
4502 if (not f_rsl_find_ie(rsl_ho_cmd, RSL_IE_L3_INFO, rsl_ho_cmd_l3)) {
4503 log("RSL message contains no L3 Info IE, expected RR Handover Command");
4504 setverdict(fail);
4505 } else {
4506 log("Found L3 Info: ", rsl_ho_cmd_l3);
4507 if (rsl_ho_cmd_l3.l3_info.payload != rr_ho_cmd_enc) {
4508 log("FAIL: the BSC sent out a different L3 Info, not matching the RR Handover Command the other BSS forwarded.");
4509 setverdict(fail);
4510 } else {
4511 log("Success: the BSC sent out the same RR Handover Command the other BSS forwarded.");
4512 setverdict(pass);
4513 }
4514 }
4515
4516 /* When the other BSS has reported a completed handover, this side is
4517 * torn down. */
4518
4519 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_HANDOVER_SUCCESSFUL;
4520 var BssmapCause cause := enum2int(cause_val);
4521 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
4522
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02004523 f_expect_dlcx_conns();
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004524 setverdict(pass);
4525 f_sleep(1.0);
4526}
4527testcase TC_ho_out_of_this_bsc() runs on test_CT {
4528 var MSC_ConnHdlr vc_conn;
4529
4530 f_init(1, true);
4531 f_sleep(1.0);
4532
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004533 f_ctrs_bsc_and_bts_init();
4534
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004535 vc_conn := f_start_handler(refers(f_tc_ho_out_of_this_bsc));
4536 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004537
4538 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
4539 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
4540 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
4541 f_ctrs_bsc_and_bts_add(0, "handover:completed");
4542 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
4543 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:completed");
4544 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004545 f_shutdown_helper();
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004546}
4547
Vadim Yanitskiyb93aa432020-10-01 14:23:11 +07004548private function f_mo_l3_transceive(template (value) RslLinkId link_id := ts_RslLinkID_DCCH(0),
Vadim Yanitskiy2ef6a2f2020-10-08 23:17:32 +07004549 template (present) OCT1 dlci := ?,
Vadim Yanitskiyb93aa432020-10-01 14:23:11 +07004550 octetstring l3 := '0123456789'O)
4551runs on MSC_ConnHdlr {
Neels Hofmeyr43654812020-09-25 01:35:35 +02004552 /* The old lchan and conn should still be active. See that arbitrary L3
4553 * is still going through. */
Vadim Yanitskiyb93aa432020-10-01 14:23:11 +07004554 RSL.send(ts_RSL_DATA_IND(g_chan_nr, link_id, l3));
Neels Hofmeyr43654812020-09-25 01:35:35 +02004555 var template PDU_BSSAP exp_data := {
4556 discriminator := '1'B,
4557 spare := '0000000'B,
Vadim Yanitskiyb93aa432020-10-01 14:23:11 +07004558 dlci := dlci,
4559 lengthIndicator := lengthof(l3),
Neels Hofmeyr43654812020-09-25 01:35:35 +02004560 pdu := {
4561 dtap := l3
4562 }
4563 };
4564 BSSAP.receive(exp_data);
4565 setverdict(pass);
4566}
4567
Vadim Yanitskiy0033a3b2020-10-01 22:21:16 +07004568private function f_mt_l3_transceive(template (present) RslLinkId link_id := tr_RslLinkID_DCCH(0),
4569 template (value) OCT1 dlci := '00'O,
4570 octetstring l3 := '0123456789'O)
4571runs on MSC_ConnHdlr {
4572 BSSAP.send(PDU_BSSAP:{
4573 discriminator := '1'B,
4574 spare := '0000000'B,
4575 dlci := dlci,
4576 lengthIndicator := lengthof(l3),
4577 pdu := {
4578 dtap := l3
4579 }
4580 });
4581 RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, link_id, l3));
4582 setverdict(pass);
4583}
4584
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004585/* BSC asks for inter-BSC HO, but the MSC decides that it won't happen and
4586 * simply never sends a BSSMAP Handover Command. */
4587private function f_tc_ho_out_fail_no_msc_response(charstring id) runs on MSC_ConnHdlr {
Daniel Willmann3b59eb52018-10-29 15:40:55 +01004588 g_pars := f_gen_test_hdlr_pars();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004589
4590 var PDU_BSSAP ass_req := f_gen_ass_req();
4591 ass_req.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4592 ass_req.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
4593 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4594 f_establish_fully(ass_req, exp_compl);
4595
Neels Hofmeyr666f0432020-07-04 00:53:07 +02004596 f_bts_0_cfg(BSCVTY, {"neighbor lac 99 arfcn 123 bsic any"});
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004597 f_vty_transceive(BSCVTY, "handover any to arfcn 123 bsic any");
4598
4599 BSSAP.receive(tr_BSSMAP_HandoverRequired);
4600
4601 /* osmo-bsc should time out 10 seconds after the handover started.
4602 * Let's give it a bit extra. */
4603 f_sleep(15.0);
4604
Vadim Yanitskiy74ae5eb2020-10-01 22:13:29 +07004605 f_mo_l3_transceive();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004606 f_sleep(1.0);
4607}
4608testcase TC_ho_out_fail_no_msc_response() runs on test_CT {
4609 var MSC_ConnHdlr vc_conn;
4610
4611 f_init(1, true);
4612 f_sleep(1.0);
4613
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004614 f_ctrs_bsc_and_bts_init();
4615
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004616 vc_conn := f_start_handler(refers(f_tc_ho_out_fail_no_msc_response));
4617 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004618
4619 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
4620 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
4621 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
4622 f_ctrs_bsc_and_bts_add(0, "handover:timeout");
4623 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
4624 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:timeout");
4625 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004626 f_shutdown_helper();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004627}
4628
4629/* BSC asks for inter-BSC HO, receives BSSMAP Handover Command, but MS reports
4630 * RR Handover Failure. */
4631private function f_tc_ho_out_fail_rr_ho_failure(charstring id) runs on MSC_ConnHdlr {
Daniel Willmann3b59eb52018-10-29 15:40:55 +01004632 g_pars := f_gen_test_hdlr_pars();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004633
4634 var PDU_BSSAP ass_req := f_gen_ass_req();
4635 ass_req.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4636 ass_req.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
4637 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4638 f_establish_fully(ass_req, exp_compl);
4639
Neels Hofmeyr666f0432020-07-04 00:53:07 +02004640 f_bts_0_cfg(BSCVTY, {"neighbor lac 99 arfcn 123 bsic any"});
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004641 f_vty_transceive(BSCVTY, "handover any to arfcn 123 bsic any");
4642
4643 BSSAP.receive(tr_BSSMAP_HandoverRequired);
4644
4645 f_sleep(0.5);
4646 /* The MSC negotiates Handover Request and Handover Request Ack with
4647 * the other BSS and comes back with a BSSMAP Handover Command
4648 * containing an RR Handover Command coming from the target BSS... */
4649
4650 var PDU_ML3_NW_MS rr_ho_cmd := valueof(ts_RR_HandoverCommand);
4651 log("Remote cell's RR Handover Command passed through as L3 Info: ", rr_ho_cmd);
4652 var octetstring rr_ho_cmd_enc := enc_PDU_ML3_NW_MS(rr_ho_cmd);
4653 log("Remote cell's RR Handover Command passed through as L3 Info, encoded: ", rr_ho_cmd_enc);
4654 BSSAP.send(ts_BSSMAP_HandoverCommand(rr_ho_cmd_enc));
4655
4656 /* expect the Handover Command to go out on RR */
4657 var RSL_Message rsl_ho_cmd
4658 RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, ?)) -> value rsl_ho_cmd;
4659 log("RSL Data Req went out to first BTS: ", rsl_ho_cmd);
4660 var RSL_IE_Body rsl_ho_cmd_l3;
4661 if (not f_rsl_find_ie(rsl_ho_cmd, RSL_IE_L3_INFO, rsl_ho_cmd_l3)) {
4662 log("RSL message contains no L3 Info IE, expected RR Handover Command");
4663 setverdict(fail);
4664 } else {
4665 log("Found L3 Info: ", rsl_ho_cmd_l3);
4666 if (rsl_ho_cmd_l3.l3_info.payload != rr_ho_cmd_enc) {
4667 log("FAIL: the BSC sent out a different L3 Info, not matching the RR Handover Command the other BSS forwarded.");
4668 setverdict(fail);
4669 } else {
4670 log("Success: the BSC sent out the same RR Handover Command the other BSS forwarded.");
4671 setverdict(pass);
4672 }
4673 }
4674
4675 f_sleep(0.2);
4676 f_rsl_send_l3(ts_RRM_HandoverFailure('00'O));
4677
4678 /* Should tell the MSC about the failure */
4679 BSSAP.receive(tr_BSSMAP_HandoverFailure);
4680
4681 f_sleep(1.0);
4682
Vadim Yanitskiy74ae5eb2020-10-01 22:13:29 +07004683 f_mo_l3_transceive();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004684 f_sleep(1.0);
4685
4686 setverdict(pass);
4687 f_sleep(1.0);
4688}
4689testcase TC_ho_out_fail_rr_ho_failure() runs on test_CT {
4690 var MSC_ConnHdlr vc_conn;
4691
4692 f_init(1, true);
4693 f_sleep(1.0);
4694
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004695 f_ctrs_bsc_and_bts_init();
4696
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004697 vc_conn := f_start_handler(refers(f_tc_ho_out_fail_rr_ho_failure));
4698 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004699
4700 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
4701 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
4702 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
4703 f_ctrs_bsc_and_bts_add(0, "handover:failed");
4704 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
4705 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:failed");
4706 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004707 f_shutdown_helper();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004708}
4709
Neels Hofmeyr10f2bfa2019-07-09 19:33:29 +02004710/* BSC asks for inter-BSC-out HO, receives BSSMAP Handover Command, but then no reply is received about HO outcome
4711 * (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 +02004712 * and the lchan is released. */
4713private function f_tc_ho_out_fail_no_result_after_ho_cmd(charstring id) runs on MSC_ConnHdlr {
Daniel Willmann3b59eb52018-10-29 15:40:55 +01004714 g_pars := f_gen_test_hdlr_pars();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004715
4716 var PDU_BSSAP ass_req := f_gen_ass_req();
4717 ass_req.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4718 ass_req.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
4719 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4720 f_establish_fully(ass_req, exp_compl);
4721
Neels Hofmeyr666f0432020-07-04 00:53:07 +02004722 f_bts_0_cfg(BSCVTY, {"neighbor lac 99 arfcn 123 bsic any"});
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004723 f_vty_transceive(BSCVTY, "handover any to arfcn 123 bsic any");
4724
4725 BSSAP.receive(tr_BSSMAP_HandoverRequired);
4726
4727 f_sleep(0.5);
4728 /* The MSC negotiates Handover Request and Handover Request Ack with
4729 * the other BSS and comes back with a BSSMAP Handover Command
4730 * containing an RR Handover Command coming from the target BSS... */
4731
4732 var PDU_ML3_NW_MS rr_ho_cmd := valueof(ts_RR_HandoverCommand);
4733 log("Remote cell's RR Handover Command passed through as L3 Info: ", rr_ho_cmd);
4734 var octetstring rr_ho_cmd_enc := enc_PDU_ML3_NW_MS(rr_ho_cmd);
4735 log("Remote cell's RR Handover Command passed through as L3 Info, encoded: ", rr_ho_cmd_enc);
4736 BSSAP.send(ts_BSSMAP_HandoverCommand(rr_ho_cmd_enc));
4737
4738 /* expect the Handover Command to go out on RR */
4739 var RSL_Message rsl_ho_cmd
4740 RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, ?)) -> value rsl_ho_cmd;
4741 log("RSL Data Req went out to first BTS: ", rsl_ho_cmd);
4742 var RSL_IE_Body rsl_ho_cmd_l3;
4743 if (not f_rsl_find_ie(rsl_ho_cmd, RSL_IE_L3_INFO, rsl_ho_cmd_l3)) {
4744 log("RSL message contains no L3 Info IE, expected RR Handover Command");
4745 setverdict(fail);
4746 } else {
4747 log("Found L3 Info: ", rsl_ho_cmd_l3);
4748 if (rsl_ho_cmd_l3.l3_info.payload != rr_ho_cmd_enc) {
4749 log("FAIL: the BSC sent out a different L3 Info, not matching the RR Handover Command the other BSS forwarded.");
4750 setverdict(fail);
4751 } else {
4752 log("Success: the BSC sent out the same RR Handover Command the other BSS forwarded.");
4753 setverdict(pass);
4754 }
4755 }
4756
Neels Hofmeyr10f2bfa2019-07-09 19:33:29 +02004757 /* We get neither success nor failure report from the remote BSS. Eventually T8 times out and we run into 3GPP
4758 * TS 48.008 3.1.5.3.3 "Abnormal Conditions": Clear Request should go to the MSC, and RR should be released
4759 * after Clear Command */
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004760
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02004761 var PDU_BSSAP rx_clear_request;
Neels Hofmeyre1797aa2019-07-09 19:34:04 +02004762 BSSAP.receive(tr_BSSMAP_ClearRequest) -> value rx_clear_request;
4763 log("Got BSSMAP Clear Request");
4764 /* Instruct BSC to clear channel */
4765 var BssmapCause cause := bit2int(rx_clear_request.pdu.bssmap.clearRequest.cause.causeValue);
4766 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
4767
4768 var MgcpCommand mgcp;
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004769 interleave {
Neels Hofmeyr861a4c12018-11-07 01:23:17 +01004770 [] RSL.receive(tr_RSL_DEACT_SACCH(g_chan_nr)) {
4771 log("Got Deact SACCH");
4772 }
Harald Welte924b6ea2019-02-04 01:05:34 +01004773 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_RELEASE)) {
Neels Hofmeyr211169d2018-11-07 00:37:29 +01004774 log("Got RR Release");
4775 }
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004776 [] RSL.receive(tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL)) {
4777 log("Got RF Chan Rel");
4778 RSL.send(ts_RSL_RF_CHAN_REL_ACK(g_chan_nr));
4779 }
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004780 }
4781
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02004782 f_expect_dlcx_conns();
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004783
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004784 setverdict(pass);
4785 f_sleep(1.0);
4786}
Neels Hofmeyrd8a602c2019-07-09 19:46:01 +02004787testcase TC_ho_out_fail_no_result_after_ho_cmd() runs on test_CT {
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004788 var MSC_ConnHdlr vc_conn;
4789
4790 f_init(1, true);
4791 f_sleep(1.0);
4792
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004793 f_ctrs_bsc_and_bts_init();
4794
Neels Hofmeyrd8a602c2019-07-09 19:46:01 +02004795 vc_conn := f_start_handler(refers(f_tc_ho_out_fail_no_result_after_ho_cmd));
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004796 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004797
4798 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
4799 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
4800 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
4801 f_ctrs_bsc_and_bts_add(0, "handover:timeout");
4802 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
4803 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:timeout");
4804 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004805 f_shutdown_helper();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004806}
4807
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004808private function f_tc_ho_into_this_bsc(charstring id) runs on MSC_ConnHdlr {
4809 /* Hack: the proper way would be to wait for the BSSMAP Handover Request ACK and extract the
4810 * actual assigned chan_nr from its L3 (RR Handover Command) message. But osmo-bsc starts acting
4811 * on the lchan even before we get a chance to evaluate the BSSMAP Handover Request ACK. So we
4812 * need to assume that osmo-bsc will activate TS 1 and already set up this lchan's RSL emulation
4813 * before we get started. */
4814 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
4815 f_rslem_register(0, new_chan_nr);
4816 g_chan_nr := new_chan_nr;
4817 f_sleep(1.0);
4818
4819 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
4820 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
4821 activate(as_Media());
4822
Neels Hofmeyr90f80962020-06-12 16:16:55 +02004823 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Pau Espin Pedrol07866632020-09-03 19:10:55 +02004824 f_gen_handover_req(aoip_tla := g_pars.host_aoip_tla)));
Harald Welte6811d102019-04-14 22:23:14 +02004825 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004826
4827 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
4828
4829 var PDU_BSSAP rx_bssap;
4830 var octetstring ho_command_str;
4831
4832 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
Pau Espin Pedrol76ba5412019-06-10 11:00:33 +02004833
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004834 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
4835 log("Received L3 Info in HO Request Ack: ", ho_command_str);
4836 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
4837 log("L3 Info in HO Request Ack is ", ho_command);
4838
4839 var GsmArfcn arfcn;
4840 var RslChannelNr actual_new_chan_nr;
4841 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
4842 actual_new_chan_nr, arfcn);
4843
4844 if (actual_new_chan_nr != new_chan_nr) {
4845 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
4846 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
4847 setverdict(fail);
4848 return;
4849 }
4850 log("Handover Command chan_nr is", actual_new_chan_nr);
4851
4852 /* Now the MSC forwards the RR Handover Command to the other BSC, which
4853 * tells the MS to handover to the new lchan. Here comes the new MS on
4854 * the new lchan with a Handover RACH: */
4855
4856 /* send handover detect */
4857
4858 RSL.send(ts_RSL_HANDO_DET(new_chan_nr));
4859
4860 BSSAP.receive(tr_BSSMAP_HandoverDetect);
4861
4862 /* send handover complete over the new channel */
4863
4864 var PDU_ML3_MS_NW l3_tx := valueof(ts_RRM_HandoverComplete('00'O));
4865 RSL.send(ts_RSL_EST_IND(new_chan_nr, valueof(ts_RslLinkID_DCCH(0)),
4866 enc_PDU_ML3_MS_NW(l3_tx)));
4867
4868 BSSAP.receive(tr_BSSMAP_HandoverComplete);
4869 setverdict(pass);
4870}
Pau Espin Pedrol07866632020-09-03 19:10:55 +02004871function f_tc_ho_into_this_bsc_main(TestHdlrParams pars) runs on test_CT {
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004872 var MSC_ConnHdlr vc_conn;
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004873
4874 f_init(1, true);
4875 f_sleep(1.0);
4876
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004877 f_ctrs_bsc_and_bts_init();
4878
Neels Hofmeyr90f80962020-06-12 16:16:55 +02004879 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
4880 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004881
4882 vc_conn := f_start_handler(refers(f_tc_ho_into_this_bsc), pars);
4883 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004884
4885 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
4886 f_ctrs_bsc_and_bts_add(0, "handover:completed");
4887 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:attempted");
4888 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:completed");
4889 f_ctrs_bsc_and_bts_verify();
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004890}
4891
Pau Espin Pedrol07866632020-09-03 19:10:55 +02004892testcase TC_ho_into_this_bsc() runs on test_CT {
4893 var TestHdlrParams pars := f_gen_test_hdlr_pars();
4894 f_tc_ho_into_this_bsc_main(pars);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004895 f_shutdown_helper();
Pau Espin Pedrol07866632020-09-03 19:10:55 +02004896}
4897
4898testcase TC_ho_into_this_bsc_tla_v6() runs on test_CT {
4899 var TestHdlrParams pars := f_gen_test_hdlr_pars();
4900 pars.host_aoip_tla := "::6";
4901 f_tc_ho_into_this_bsc_main(pars);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004902 f_shutdown_helper();
Pau Espin Pedrol07866632020-09-03 19:10:55 +02004903}
4904
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01004905private function f_tc_ho_in_fail_msc_clears(charstring id) runs on MSC_ConnHdlr {
4906 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
4907 f_rslem_register(0, new_chan_nr);
4908 g_chan_nr := new_chan_nr;
4909 f_sleep(1.0);
4910
4911 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
4912 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
4913 activate(as_Media());
4914
Neels Hofmeyr90f80962020-06-12 16:16:55 +02004915 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01004916 f_gen_handover_req()));
Harald Welte6811d102019-04-14 22:23:14 +02004917 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01004918
4919 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
4920
4921 var PDU_BSSAP rx_bssap;
4922 var octetstring ho_command_str;
4923
4924 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
4925
4926 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
4927 log("Received L3 Info in HO Request Ack: ", ho_command_str);
4928 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
4929 log("L3 Info in HO Request Ack is ", ho_command);
4930
4931 var GsmArfcn arfcn;
4932 var RslChannelNr actual_new_chan_nr;
4933 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
4934 actual_new_chan_nr, arfcn);
4935
4936 if (actual_new_chan_nr != new_chan_nr) {
4937 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
4938 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
4939 setverdict(fail);
4940 return;
4941 }
4942 log("Handover Command chan_nr is", actual_new_chan_nr);
4943
Neels Hofmeyr61ca08d2019-05-06 23:52:22 +02004944 /* For deterministic test results, give some time for the MGW endpoint to be configured */
4945 f_sleep(1.0);
4946
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01004947 /* Now the MSC forwards the RR Handover Command to the other BSC, which
4948 * tells the MS to handover to the new lchan. In this case, the MS
4949 * reports a Handover Failure to the old BSS, which forwards a BSSMAP
4950 * Handover Failure to the MSC. The procedure according to 3GPP TS
4951 * 48.008 3.1.5.3.2 "Handover Failure" is then that the MSC sends a
4952 * BSSMAP Clear Command: */
4953
4954 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_RADIO_INTERFACE_FAILURE_REVERSION;
4955 var BssmapCause cause := enum2int(cause_val);
4956 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
4957
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02004958 f_expect_dlcx_conns();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01004959 setverdict(pass);
4960 f_sleep(1.0);
4961
4962 setverdict(pass);
4963}
4964testcase TC_ho_in_fail_msc_clears() runs on test_CT {
4965 var MSC_ConnHdlr vc_conn;
4966 var TestHdlrParams pars := f_gen_test_hdlr_pars();
4967
4968 f_init(1, true);
4969 f_sleep(1.0);
4970
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004971 f_ctrs_bsc_and_bts_init();
4972
Neels Hofmeyr90f80962020-06-12 16:16:55 +02004973 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
4974 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01004975
4976 vc_conn := f_start_handler(refers(f_tc_ho_in_fail_msc_clears), pars);
4977 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004978
4979 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
4980 f_ctrs_bsc_and_bts_add(0, "handover:stopped");
4981 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:attempted");
4982 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:stopped");
4983 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004984 f_shutdown_helper();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01004985}
4986
4987private function f_tc_ho_in_fail_msc_clears_after_ho_detect(charstring id) runs on MSC_ConnHdlr {
4988 /* Hack: the proper way would be to wait for the BSSMAP Handover Request ACK and extract the
4989 * actual assigned chan_nr from its L3 (RR Handover Command) message. But osmo-bsc starts acting
4990 * on the lchan even before we get a chance to evaluate the BSSMAP Handover Request ACK. So we
4991 * need to assume that osmo-bsc will activate TS 1 and already set up this lchan's RSL emulation
4992 * before we get started. */
4993 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
4994 f_rslem_register(0, new_chan_nr);
4995 g_chan_nr := new_chan_nr;
4996 f_sleep(1.0);
4997
4998 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
4999 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
5000 activate(as_Media());
5001
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005002 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005003 f_gen_handover_req()));
Harald Welte6811d102019-04-14 22:23:14 +02005004 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005005
5006 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
5007
5008 var PDU_BSSAP rx_bssap;
5009 var octetstring ho_command_str;
5010
5011 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
5012
5013 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
5014 log("Received L3 Info in HO Request Ack: ", ho_command_str);
5015 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
5016 log("L3 Info in HO Request Ack is ", ho_command);
5017
5018 var GsmArfcn arfcn;
5019 var RslChannelNr actual_new_chan_nr;
5020 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
5021 actual_new_chan_nr, arfcn);
5022
5023 if (actual_new_chan_nr != new_chan_nr) {
5024 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
5025 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
5026 setverdict(fail);
5027 return;
5028 }
5029 log("Handover Command chan_nr is", actual_new_chan_nr);
5030
5031 /* Now the MSC forwards the RR Handover Command to the other BSC, which
5032 * tells the MS to handover to the new lchan. Here comes the new MS on
5033 * the new lchan with a Handover RACH: */
5034
5035 /* send handover detect */
5036
5037 RSL.send(ts_RSL_HANDO_DET(new_chan_nr));
5038
5039 BSSAP.receive(tr_BSSMAP_HandoverDetect);
5040
5041 /* The MSC chooses to clear the connection now, maybe we got the
5042 * Handover RACH on the new cell but the MS still signaled Handover
5043 * Failure to the old BSS? */
5044
5045 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_RADIO_INTERFACE_FAILURE_REVERSION;
5046 var BssmapCause cause := enum2int(cause_val);
5047 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
5048
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02005049 f_expect_dlcx_conns();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005050 f_sleep(1.0);
5051}
5052testcase TC_ho_in_fail_msc_clears_after_ho_detect() runs on test_CT {
5053 var MSC_ConnHdlr vc_conn;
5054 var TestHdlrParams pars := f_gen_test_hdlr_pars();
5055
5056 f_init(1, true);
5057 f_sleep(1.0);
5058
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005059 f_ctrs_bsc_and_bts_init();
5060
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005061 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
5062 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005063
5064 vc_conn := f_start_handler(refers(f_tc_ho_in_fail_msc_clears_after_ho_detect), pars);
5065 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005066
5067 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5068 f_ctrs_bsc_and_bts_add(0, "handover:stopped");
5069 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:attempted");
5070 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:stopped");
5071 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005072 f_shutdown_helper();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005073}
5074
5075/* The new BSS's lchan times out before the MSC decides that handover failed. */
5076private function f_tc_ho_in_fail_no_detect(charstring id) runs on MSC_ConnHdlr {
5077 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
5078 f_rslem_register(0, new_chan_nr);
5079 g_chan_nr := new_chan_nr;
5080 f_sleep(1.0);
5081
5082 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
5083 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
5084 activate(as_Media());
5085
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005086 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005087 f_gen_handover_req()));
Harald Welte6811d102019-04-14 22:23:14 +02005088 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005089
5090 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
5091
5092 var PDU_BSSAP rx_bssap;
5093 var octetstring ho_command_str;
5094
5095 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
5096
5097 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
5098 log("Received L3 Info in HO Request Ack: ", ho_command_str);
5099 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
5100 log("L3 Info in HO Request Ack is ", ho_command);
5101
5102 var GsmArfcn arfcn;
5103 var RslChannelNr actual_new_chan_nr;
5104 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
5105 actual_new_chan_nr, arfcn);
5106
5107 if (actual_new_chan_nr != new_chan_nr) {
5108 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
5109 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
5110 setverdict(fail);
5111 return;
5112 }
5113 log("Handover Command chan_nr is", actual_new_chan_nr);
5114
5115 /* Now the MSC forwards the RR Handover Command to the other BSC, which
5116 * tells the MS to handover to the new lchan. But the MS never shows up
5117 * on the new lchan. */
5118
5119 BSSAP.receive(tr_BSSMAP_HandoverFailure);
5120
5121 /* Did osmo-bsc also send a Clear Request? */
5122 timer T := 0.5;
5123 T.start;
5124 alt {
5125 [] BSSAP.receive(tr_BSSMAP_ClearRequest);
5126 [] T.timeout { }
5127 }
5128
5129 /* MSC plays along with a Clear Command (no matter whether osmo-bsc
5130 * asked for it, this is a Handover Failure after all). */
5131
5132 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_RADIO_INTERFACE_FAILURE_REVERSION;
5133 var BssmapCause cause := enum2int(cause_val);
5134 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
5135
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02005136 f_expect_dlcx_conns();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005137 f_sleep(1.0);
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005138}
5139testcase TC_ho_in_fail_no_detect() runs on test_CT {
5140 var MSC_ConnHdlr vc_conn;
5141 var TestHdlrParams pars := f_gen_test_hdlr_pars();
5142
5143 f_init(1, true);
5144 f_sleep(1.0);
5145
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005146 f_ctrs_bsc_and_bts_init();
5147
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005148 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
5149 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005150
5151 vc_conn := f_start_handler(refers(f_tc_ho_in_fail_no_detect), pars);
5152 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005153
5154 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5155 f_ctrs_bsc_and_bts_add(0, "handover:error");
5156 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:attempted");
5157 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:error");
5158 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005159 f_shutdown_helper();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005160}
5161
5162/* Same as f_tc_ho_in_fail_no_detect, but MSC fails to send a Clear Command */
5163private function f_tc_ho_in_fail_no_detect2(charstring id) runs on MSC_ConnHdlr {
5164 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
5165 f_rslem_register(0, new_chan_nr);
5166 g_chan_nr := new_chan_nr;
5167 f_sleep(1.0);
5168
5169 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
5170 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
5171 activate(as_Media());
5172
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005173 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005174 f_gen_handover_req()));
Harald Welte6811d102019-04-14 22:23:14 +02005175 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005176
5177 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
5178
5179 var PDU_BSSAP rx_bssap;
5180 var octetstring ho_command_str;
5181
5182 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
5183
5184 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
5185 log("Received L3 Info in HO Request Ack: ", ho_command_str);
5186 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
5187 log("L3 Info in HO Request Ack is ", ho_command);
5188
5189 var GsmArfcn arfcn;
5190 var RslChannelNr actual_new_chan_nr;
5191 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
5192 actual_new_chan_nr, arfcn);
5193
5194 if (actual_new_chan_nr != new_chan_nr) {
5195 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
5196 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
5197 setverdict(fail);
5198 return;
5199 }
5200 log("Handover Command chan_nr is", actual_new_chan_nr);
5201
5202 /* Now the MSC forwards the RR Handover Command to the other BSC, which
5203 * tells the MS to handover to the new lchan. But the MS never shows up
5204 * on the new lchan. */
5205
5206 BSSAP.receive(tr_BSSMAP_HandoverFailure);
5207
5208 /* MSC plays dumb and sends no Clear Command */
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005209 var PDU_BSSAP rx_clear_request;
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02005210
5211 BSSAP.receive(tr_BSSMAP_ClearRequest) -> value rx_clear_request {
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005212 var BssmapCause cause := bit2int(rx_clear_request.pdu.bssmap.clearRequest.cause.causeValue);
5213 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
5214 };
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02005215 f_expect_dlcx_conns();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005216 f_sleep(1.0);
5217}
5218testcase TC_ho_in_fail_no_detect2() runs on test_CT {
5219 var MSC_ConnHdlr vc_conn;
5220 var TestHdlrParams pars := f_gen_test_hdlr_pars();
5221
5222 f_init(1, true);
5223 f_sleep(1.0);
5224
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005225 f_ctrs_bsc_and_bts_init();
5226
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005227 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
5228 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005229
5230 vc_conn := f_start_handler(refers(f_tc_ho_in_fail_no_detect2), pars);
5231 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005232
5233 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5234 f_ctrs_bsc_and_bts_add(0, "handover:error");
5235 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:attempted");
5236 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:error");
5237 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005238 f_shutdown_helper();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005239}
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005240
Neels Hofmeyr91401012019-07-11 00:42:35 +02005241type record of charstring Commands;
5242
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005243private function f_bts_0_cfg(TELNETasp_PT pt, Commands cmds := {})
Neels Hofmeyr91401012019-07-11 00:42:35 +02005244{
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005245 f_vty_enter_cfg_bts(pt, 0);
Neels Hofmeyr91401012019-07-11 00:42:35 +02005246 for (var integer i := 0; i < sizeof(cmds); i := i+1) {
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005247 f_vty_transceive(pt, cmds[i]);
Neels Hofmeyr91401012019-07-11 00:42:35 +02005248 }
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005249 f_vty_transceive(pt, "end");
Neels Hofmeyr91401012019-07-11 00:42:35 +02005250}
5251
Pau Espin Pedrolc675b612020-01-09 19:55:40 +01005252private function f_cs7_inst_0_cfg(TELNETasp_PT pt, Commands cmds := {})
5253{
5254 f_vty_enter_cfg_cs7_inst(pt, 0);
5255 for (var integer i := 0; i < sizeof(cmds); i := i+1) {
5256 f_vty_transceive(pt, cmds[i]);
5257 }
5258 f_vty_transceive(pt, "end");
5259}
5260
Neels Hofmeyr91401012019-07-11 00:42:35 +02005261private function f_probe_for_handover(charstring log_label,
5262 charstring log_descr,
5263 charstring handover_vty_cmd,
5264 boolean expect_handover,
5265 boolean is_inter_bsc_handover := false)
5266runs on MSC_ConnHdlr
5267{
Neels Hofmeyrb3fc8982020-05-11 00:16:42 +02005268 /* We're going to thwart any and all handover attempts, just be ready to handle (and ignore) handover target
5269 * lchans to be established on bts 1 or bts 2. */
5270 f_rslem_suspend(RSL1_PROC);
5271 f_rslem_suspend(RSL2_PROC);
5272
Neels Hofmeyr91401012019-07-11 00:42:35 +02005273 var RSL_Message rsl;
5274
5275 var charstring log_msg := " (expecting handover)"
5276 if (not expect_handover) {
5277 log_msg := " (expecting NO handover)";
5278 }
5279 log("f_probe_for_handover starting: " & log_label & ": " & log_descr & log_msg);
5280 f_vty_transceive(BSCVTY, handover_vty_cmd);
5281
Neels Hofmeyr91401012019-07-11 00:42:35 +02005282 timer T := 2.0;
5283 T.start;
5284
5285 alt {
5286 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr)) -> value rsl {
5287 var PDU_ML3_NW_MS l3 := dec_PDU_ML3_NW_MS(rsl.ies[2].body.l3_info.payload);
5288 log("Rx L3 from net: ", l3);
5289 if (ischosen(l3.msgs.rrm.handoverCommand)) {
5290 var RslChannelNr new_chan_nr;
5291 var GsmArfcn arfcn;
5292 f_ChDesc2RslChanNr(l3.msgs.rrm.handoverCommand.channelDescription2,
5293 new_chan_nr, arfcn);
5294 log("Handover to new chan ", new_chan_nr, " on ARFCN ", arfcn);
5295 log(l3.msgs.rrm.handoverCommand);
5296
5297 /* Need to register for new lchan on new BTS -- it's either bts 1 or bts 2. It doesn't really
5298 * matter on which BTS it really is, we're not going to follow through an entire handover
5299 * anyway. */
5300 f_rslem_register(0, new_chan_nr, RSL1_PROC);
5301 f_rslem_resume(RSL1_PROC);
5302 f_rslem_register(0, new_chan_nr, RSL2_PROC);
5303 f_rslem_resume(RSL2_PROC);
5304
5305 if (expect_handover and not is_inter_bsc_handover) {
5306 setverdict(pass);
5307 log("f_probe_for_handover(" & log_label & "): Got RSL Handover Command as expected.");
5308 } else {
5309 setverdict(fail, "f_probe_for_handover(" & log_label & "): Expected none, but got RSL Handover Command. "
5310 & log_label & ": " & log_descr);
5311 }
5312
5313 log("f_probe_for_handover(" & log_label & "): Ending the test: Handover Failure stops the procedure.");
5314 /* osmo-bsc has triggered Handover. That's all we need to know for this test, reply with
5315 * Handover Failure. */
5316 f_rsl_send_l3(ts_RRM_HandoverFailure('00'O));
5317
5318 /* target BTS is told to release lchan again; don't care which BTS nor what messages. */
5319 f_sleep(0.5);
5320 RSL1.clear;
5321 RSL2.clear;
5322 log("f_probe_for_handover(" & log_label & "): done (got RSL Handover Command)");
5323 break;
5324 } else {
5325 repeat;
5326 }
5327 }
5328 [] BSSAP.receive(tr_BSSMAP_HandoverRequired) {
5329 if (expect_handover and is_inter_bsc_handover) {
5330 setverdict(pass);
5331 log("f_probe_for_handover(" & log_label & "): Got BSSMAP Handover Required as expected.");
5332 } else {
5333 setverdict(fail, "f_probe_for_handover(" & log_label & "): Expected none, but got BSSMAP Handover Required. "
5334 & log_label & ": " & log_descr);
5335 }
5336
5337 log("f_probe_for_handover(" & log_label & "): done (got BSSMAP Handover Required)");
5338
5339 /* Note: f_tc_ho_neighbor_config_start() sets T7, the timeout for BSSMAP Handover Required, to
5340 * 1 second. There is no legal way to quickly abort a handover after a BSSMAP Handover Required,
5341 * setting a short timeout and waiting is the only way. */
5342 log("f_probe_for_handover(" & log_label & "): waiting for inter-BSC HO to time out...");
5343 f_sleep(1.5);
5344 log("f_probe_for_handover(" & log_label & "): ...done");
5345
5346 break;
5347 }
5348 [] T.timeout {
5349 if (expect_handover) {
5350 setverdict(fail, "f_probe_for_handover(" & log_label & "): Expected Handover, but got none. "
5351 & log_label & ": " & log_descr);
5352 } else {
5353 setverdict(pass);
5354 log("f_probe_for_handover(" & log_label & "): Got no Handover, as expected.");
5355 }
5356 log("f_probe_for_handover(" & log_label & "): done (got no Handover)");
5357 break;
5358 }
5359 }
5360
5361 f_rslem_resume(RSL1_PROC);
5362 f_rslem_resume(RSL2_PROC);
5363 f_sleep(3.0);
5364 RSL.clear;
5365
5366 log("f_probe_for_handover(" & log_label & "): done clearing");
5367}
5368
5369/* Test the effect of various neighbor configuration scenarios:
5370 *
5371 * To avoid complexity, block off any actual handover operation, and always remain on the lchan at bts 0.
5372 * Reconfigure the neighbors for bts 0, trigger a Handover, and probe whether osmo-bsc does or doesn't start HO.
5373 */
5374private function f_tc_ho_neighbor_config_start() runs on MSC_ConnHdlr {
5375 g_pars := f_gen_test_hdlr_pars();
5376 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
5377 var PDU_BSSAP ass_cmd := f_gen_ass_req();
5378 const OCT8 kc := '0001020304050607'O;
5379
5380 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
5381 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
5382
5383 /* Establish lchan at bts 0 */
5384 f_establish_fully(ass_cmd, exp_compl);
5385
5386 /* Shorten the inter-BSC Handover timeout, to not wait so long for inter-BSC Handovers */
5387 f_vty_enter_cfg_network(BSCVTY);
5388 f_vty_transceive(BSCVTY, "timer T7 1");
5389 f_vty_transceive(BSCVTY, "end");
5390}
5391
5392private function f_tc_ho_neighbor_config_1(charstring id) runs on MSC_ConnHdlr {
5393 f_tc_ho_neighbor_config_start();
5394
5395 /*
5396 * bts 0 ARFCN 871 BSIC 10
5397 * bts 1 ARFCN 871 BSIC 11
5398 * bts 2 ARFCN 871 BSIC 12
5399 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
5400 */
5401
5402 log("f_tc_ho_neighbor_config: 1. No 'neighbor' config");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005403 f_bts_0_cfg(BSCVTY, {"no neighbors"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02005404 f_probe_for_handover("1.a", "HO to bts 1 works, implicitly listed as neighbor (legacy behavior when none are configured)",
5405 "handover any to arfcn 871 bsic 11",
5406 true);
5407
5408 f_probe_for_handover("1.b", "HO to unknown cell does not start",
5409 "handover any to arfcn 13 bsic 39",
5410 false);
5411
5412 f_probe_for_handover("1.c", "HO to 871-12 is ambiguous = error",
5413 "handover any to arfcn 871 bsic 12",
5414 false);
5415
5416 f_probe_for_handover("1.d", "HO to 871-11 still works (verify that this test properly cleans up)",
5417 "handover any to arfcn 871 bsic 11",
5418 true);
5419}
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005420testcase TC_ho_neighbor_config_1() runs on test_CT {
5421 var MSC_ConnHdlr vc_conn;
5422 f_init(3, true, guard_timeout := 60.0);
5423 f_sleep(1.0);
5424 f_ctrs_bsc_and_bts_init();
5425 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_1));
5426 vc_conn.done;
5427
5428 /* f_tc_ho_neighbor_config_start() */
5429 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5430 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5431
5432 /* 1.a */
5433 /* "failed" means a handover was triggered and started (which is all this test aims for) and the test ended the
5434 * handover quickly by sending a Handover Failure message. */
5435 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5436 f_ctrs_bsc_and_bts_add(0, "handover:failed");
5437 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
5438 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:failed");
5439
5440 /* 1.b */
5441 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5442 f_ctrs_bsc_and_bts_add(0, "handover:error");
5443
5444 /* 1.c */
5445 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5446 f_ctrs_bsc_and_bts_add(0, "handover:error");
5447
5448 /* 1.d */
5449 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5450 f_ctrs_bsc_and_bts_add(0, "handover:failed");
5451 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
5452 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:failed");
5453
5454 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005455 f_shutdown_helper();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005456}
5457
Neels Hofmeyr91401012019-07-11 00:42:35 +02005458private function f_tc_ho_neighbor_config_2(charstring id) runs on MSC_ConnHdlr {
5459 f_tc_ho_neighbor_config_start();
5460
5461 /*
5462 * bts 0 ARFCN 871 BSIC 10
5463 * bts 1 ARFCN 871 BSIC 11
5464 * bts 2 ARFCN 871 BSIC 12
5465 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
5466 */
5467
5468 log("f_tc_ho_neighbor_config: 2. explicit local neighbor: 'neighbor bts 1'");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005469 f_bts_0_cfg(BSCVTY, {"neighbor bts 1"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02005470 f_sleep(0.5);
5471
5472 f_probe_for_handover("2.a", "HO to bts 1 works, explicitly listed as neighbor",
5473 "handover any to arfcn 871 bsic 11",
5474 true);
5475
5476 f_probe_for_handover("2.b", "HO to bts 2 doesn't work, not listed as neighbor",
5477 "handover any to arfcn 871 bsic 12",
5478 false);
5479}
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005480testcase TC_ho_neighbor_config_2() runs on test_CT {
5481 var MSC_ConnHdlr vc_conn;
5482 f_init(3, true, guard_timeout := 50.0);
5483 f_sleep(1.0);
5484 f_ctrs_bsc_and_bts_init();
5485 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_2));
5486 vc_conn.done;
5487
5488 /* f_tc_ho_neighbor_config_start() */
5489 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5490 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5491
5492 /* 2.a */
5493 /* "failed" means a handover was triggered and started (which is all this test aims for) and the test ended the
5494 * handover quickly by sending a Handover Failure message. */
5495 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5496 f_ctrs_bsc_and_bts_add(0, "handover:failed");
5497 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
5498 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:failed");
5499
5500 /* 2.b */
5501 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5502 f_ctrs_bsc_and_bts_add(0, "handover:error");
5503
5504 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005505 f_shutdown_helper();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005506}
5507
Neels Hofmeyr91401012019-07-11 00:42:35 +02005508private function f_tc_ho_neighbor_config_3(charstring id) runs on MSC_ConnHdlr {
5509 f_tc_ho_neighbor_config_start();
5510
5511 /*
5512 * bts 0 ARFCN 871 BSIC 10
5513 * bts 1 ARFCN 871 BSIC 11
5514 * bts 2 ARFCN 871 BSIC 12
5515 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
5516 */
5517
5518 log("f_tc_ho_neighbor_config: 3. explicit local neighbor: 'neighbor bts 2'");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005519 f_bts_0_cfg(BSCVTY, {"no neighbors", "neighbor bts 2"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02005520 f_sleep(0.5);
5521
5522 f_probe_for_handover("3.a", "HO to bts 1 doesn't work, not listed as neighbor",
5523 "handover any to arfcn 871 bsic 11",
5524 false);
5525 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",
5526 "handover any to arfcn 871 bsic 12",
5527 true);
5528}
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005529testcase TC_ho_neighbor_config_3() runs on test_CT {
5530 var MSC_ConnHdlr vc_conn;
5531 f_init(3, true, guard_timeout := 50.0);
5532 f_sleep(1.0);
5533 f_ctrs_bsc_and_bts_init();
5534 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_3));
5535 vc_conn.done;
5536
5537 /* f_tc_ho_neighbor_config_start() */
5538 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5539 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5540
5541 /* 3.a */
5542 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5543 f_ctrs_bsc_and_bts_add(0, "handover:error");
5544
5545 /* 3.b */
5546 /* "failed" means a handover was triggered and started (which is all this test aims for) and the test ended the
5547 * handover quickly by sending a Handover Failure message. */
5548 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5549 f_ctrs_bsc_and_bts_add(0, "handover:failed");
5550 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
5551 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:failed");
5552
5553 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005554 f_shutdown_helper();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005555}
5556
Neels Hofmeyr91401012019-07-11 00:42:35 +02005557private function f_tc_ho_neighbor_config_4(charstring id) runs on MSC_ConnHdlr {
5558 f_tc_ho_neighbor_config_start();
5559
5560 /*
5561 * bts 0 ARFCN 871 BSIC 10
5562 * bts 1 ARFCN 871 BSIC 11
5563 * bts 2 ARFCN 871 BSIC 12
5564 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
5565 */
5566
5567 log("f_tc_ho_neighbor_config: 4. explicit remote neighbor: 'neighbor lac 99 arfcn 123 bsic 45'");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005568 f_bts_0_cfg(BSCVTY, {"no neighbors", "neighbor lac 99 arfcn 123 bsic 45"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02005569 f_sleep(0.5);
5570
5571 f_probe_for_handover("4.a", "HO to bts 1 doesn't work, not listed as neighbor",
5572 "handover any to arfcn 871 bsic 11",
5573 false);
5574 f_probe_for_handover("4.b", "HO to bts 2 doesn't work, not listed as neighbor",
5575 "handover any to arfcn 871 bsic 12",
5576 false);
5577 f_probe_for_handover("4.c", "HO to 123-45 triggers inter-BSC HO",
5578 "handover any to arfcn 123 bsic 45",
5579 true, true);
5580}
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005581testcase TC_ho_neighbor_config_4() runs on test_CT {
5582 var MSC_ConnHdlr vc_conn;
5583 f_init(3, true, guard_timeout := 50.0);
5584 f_sleep(1.0);
5585 f_ctrs_bsc_and_bts_init();
5586 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_4));
5587 vc_conn.done;
5588
5589 /* f_tc_ho_neighbor_config_start() */
5590 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5591 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5592
5593 /* 4.a */
5594 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5595 f_ctrs_bsc_and_bts_add(0, "handover:error");
5596
5597 /* 4.b */
5598 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5599 f_ctrs_bsc_and_bts_add(0, "handover:error");
5600
5601 /* 4.c */
5602 /* "timeout" means a handover was triggered and started (which is all this test aims for) and the test ended the
5603 * handover quickly by timing out after the Handover Required message */
5604 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5605 f_ctrs_bsc_and_bts_add(0, "handover:timeout");
5606 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
5607 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:timeout");
5608
5609 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005610 f_shutdown_helper();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005611}
5612
Neels Hofmeyr91401012019-07-11 00:42:35 +02005613private function f_tc_ho_neighbor_config_5(charstring id) runs on MSC_ConnHdlr {
5614 f_tc_ho_neighbor_config_start();
5615
5616 /*
5617 * bts 0 ARFCN 871 BSIC 10
5618 * bts 1 ARFCN 871 BSIC 11
5619 * bts 2 ARFCN 871 BSIC 12
5620 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
5621 */
5622
5623 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 +02005624 f_bts_0_cfg(BSCVTY, {"no neighbors", "neighbor lac 99 arfcn 871 bsic 12"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02005625 f_sleep(0.5);
5626
5627 f_probe_for_handover("5.a", "HO to 871-12 triggers inter-BSC HO (ignoring local cells with same ARFCN+BSIC)",
5628 "handover any to arfcn 871 bsic 12",
5629 true, true);
5630}
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005631testcase TC_ho_neighbor_config_5() runs on test_CT {
5632 var MSC_ConnHdlr vc_conn;
5633 f_init(3, true);
5634 f_sleep(1.0);
5635 f_ctrs_bsc_and_bts_init();
5636 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_5));
5637 vc_conn.done;
5638
5639 /* f_tc_ho_neighbor_config_start() */
5640 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5641 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5642
5643 /* 5 */
5644 /* "timeout" means a handover was triggered and started (which is all this test aims for) and the test ended the
5645 * handover quickly by timing out after the Handover Required message */
5646 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5647 f_ctrs_bsc_and_bts_add(0, "handover:timeout");
5648 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
5649 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:timeout");
5650
5651 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005652 f_shutdown_helper();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005653}
5654
Neels Hofmeyr91401012019-07-11 00:42:35 +02005655private function f_tc_ho_neighbor_config_6(charstring id) runs on MSC_ConnHdlr {
5656 f_tc_ho_neighbor_config_start();
5657
5658 /*
5659 * bts 0 ARFCN 871 BSIC 10
5660 * bts 1 ARFCN 871 BSIC 11
5661 * bts 2 ARFCN 871 BSIC 12
5662 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
5663 */
5664
5665 log("f_tc_ho_neighbor_config: 6. config error: explicit local and remote neighbors with ambiguous ARFCN+BSIC:"
5666 & " 'neighbor bts 2; neighbor lac 99 arfcn 871 bsic 12'");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005667 f_bts_0_cfg(BSCVTY, {"no neighbors", "neighbor bts 2", "neighbor lac 99 arfcn 871 bsic 12"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02005668 f_sleep(0.5);
5669
5670 f_probe_for_handover("6.a", "HO to 871-12 is ambiguous = error",
5671 "handover any to arfcn 871 bsic 12",
5672 false);
5673}
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005674testcase TC_ho_neighbor_config_6() runs on test_CT {
5675 var MSC_ConnHdlr vc_conn;
5676 f_init(3, true);
5677 f_sleep(1.0);
5678 f_ctrs_bsc_and_bts_init();
5679 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_6));
5680 vc_conn.done;
5681
5682 /* f_tc_ho_neighbor_config_start() */
5683 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5684 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5685
5686 /* 6.a */
5687 /* "timeout" means a handover was triggered and started (which is all this test aims for) and the test ended the
5688 * handover quickly by timing out after the Handover Required message */
5689 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5690 f_ctrs_bsc_and_bts_add(0, "handover:error");
5691
5692 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005693 f_shutdown_helper();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005694}
5695
Neels Hofmeyr91401012019-07-11 00:42:35 +02005696private function f_tc_ho_neighbor_config_7(charstring id) runs on MSC_ConnHdlr {
5697 f_tc_ho_neighbor_config_start();
5698
5699 /*
5700 * bts 0 ARFCN 871 BSIC 10
5701 * bts 1 ARFCN 871 BSIC 11
5702 * bts 2 ARFCN 871 BSIC 12
5703 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
5704 */
5705
5706 log("f_tc_ho_neighbor_config: 7. explicit local and remote neighbors:"
5707 & " 'neighbor bts 2; neighbor lac 99 arfcn 123 bsic 45'");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005708 f_bts_0_cfg(BSCVTY, {"no neighbors", "neighbor bts 2", "neighbor lac 99 arfcn 123 bsic 45"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02005709 f_sleep(0.5);
5710
5711 f_probe_for_handover("7.a", "HO to 871-12 does HO to bts 2",
5712 "handover any to arfcn 871 bsic 12",
5713 true);
5714 f_probe_for_handover("7.b", "HO to 123-45 triggers inter-BSC HO",
5715 "handover any to arfcn 123 bsic 45",
5716 true, true);
5717}
Neels Hofmeyr91401012019-07-11 00:42:35 +02005718testcase TC_ho_neighbor_config_7() runs on test_CT {
5719 var MSC_ConnHdlr vc_conn;
Neels Hofmeyrf2b88032020-06-16 00:35:04 +02005720 f_init(3, true, guard_timeout := 50.0);
Neels Hofmeyr91401012019-07-11 00:42:35 +02005721 f_sleep(1.0);
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005722 f_ctrs_bsc_and_bts_init();
Neels Hofmeyr91401012019-07-11 00:42:35 +02005723 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_7));
5724 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005725
5726 /* f_tc_ho_neighbor_config_start() */
5727 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5728 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5729
5730 /* 7.a */
5731 /* "failed" means a handover was triggered and started (which is all this test aims for) and the test ended the
5732 * handover quickly by sending a Handover Failure message. */
5733 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5734 f_ctrs_bsc_and_bts_add(0, "handover:failed");
5735 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
5736 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:failed");
5737
5738 /* 7.b */
5739 /* "timeout" means a handover was triggered and started (which is all this test aims for) and the test ended the
5740 * handover quickly by timing out after the Handover Required message */
5741 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5742 f_ctrs_bsc_and_bts_add(0, "handover:timeout");
5743 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
5744 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:timeout");
5745
5746 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005747 f_shutdown_helper();
Neels Hofmeyr91401012019-07-11 00:42:35 +02005748}
5749
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01005750/* OS#3041: Open and close N connections in a normal fashion, and expect no
5751 * BSSMAP Reset just because of that. */
5752testcase TC_bssap_rlsd_does_not_cause_bssmap_reset() runs on test_CT {
5753 var default d;
5754 var integer i;
5755 var DchanTuple dt;
5756
5757 f_init();
5758
5759 /* Wait for initial BSSMAP Reset to pass */
5760 f_sleep(4.0);
5761
5762 d := activate(no_bssmap_reset());
5763
5764 /* Setup up a number of connections and RLSD them again from the MSC
5765 * side. In the buggy behavior, the fourth one triggers BSSMAP Reset.
5766 * Let's do it some more times for good measure. */
Harald Weltec3260d92018-06-11 17:48:16 +02005767 for (i := 0; i < 4; i := i+1) {
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01005768 /* Since we're doing a lot of runs, give each one a fresh
5769 * T_guard from the top. */
5770 T_guard.start;
5771
5772 /* Setup a BSSAP connection and clear it right away. This is
5773 * the MSC telling the BSC about a planned release, it's not an
5774 * erratic loss of a connection. */
Harald Weltea1897182018-06-11 13:53:09 +02005775 dt := f_est_dchan(int2oct(i,1), 23+i, '00010203040506'O);
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01005776
5777 /* MSC disconnects (RLSD). */
5778 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
5779 }
5780
5781 /* In the buggy behavior, a timeout of 2 seconds happens between above
5782 * trigger (logs "SIGTRAN connection down, reconnecting...") and the
5783 * actual BSSMAP Reset. Wait a bit longer just to make sure. */
5784 f_sleep(4.0);
5785
5786 deactivate(d);
5787 f_shutdown_helper();
5788}
Harald Welte552620d2017-12-16 23:21:36 +01005789
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01005790/* OS#3041: Open and close N connections in a normal fashion, and expect no
5791 * BSSMAP Reset just because of that. Invoke the release by a BSSMAP Clear from
5792 * the MSC. */
5793testcase TC_bssmap_clear_does_not_cause_bssmap_reset() runs on test_CT {
5794 var default d;
5795 var integer i;
5796 var DchanTuple dt;
5797 var BSSAP_N_DATA_ind rx_di;
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01005798 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_CALL_CONTROL;
5799 var BssmapCause cause := enum2int(cause_val);
5800
5801 f_init();
5802
5803 /* Wait for initial BSSMAP Reset to pass */
5804 f_sleep(4.0);
5805
5806 d := activate(no_bssmap_reset());
5807
5808 /* Setup up a number of connections and RLSD them again from the MSC
5809 * side. In the buggy behavior, the fourth one triggers BSSMAP Reset.
5810 * Let's do it some more times for good measure. */
5811 for (i := 0; i < 8; i := i+1) {
5812 /* Since we're doing a lot of runs, give each one a fresh
5813 * T_guard from the top. */
5814 T_guard.start;
5815
5816 /* Setup a BSSAP connection and clear it right away. This is
5817 * the MSC telling the BSC about a planned release, it's not an
5818 * erratic loss of a connection. */
Harald Weltea1897182018-06-11 13:53:09 +02005819 dt := f_est_dchan(int2oct(i,1), 23+i, '00010203040506'O);
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01005820
5821 /* Instruct BSC to clear channel */
5822 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
5823
5824 /* expect BSC to disable the channel */
Harald Welte641fcbe2018-06-14 10:58:35 +02005825 f_exp_chan_rel_and_clear(dt, 0);
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01005826 }
5827
5828 /* In the buggy behavior, a timeout of 2 seconds happens between above
5829 * trigger (logs "SIGTRAN connection down, reconnecting...") and the
5830 * actual BSSMAP Reset. Wait a bit longer just to make sure. */
5831 f_sleep(4.0);
5832
5833 deactivate(d);
5834 f_shutdown_helper();
5835}
5836
Neels Hofmeyrfd445c32018-03-09 15:39:31 +01005837/* OS#3041: Open and close N connections in a normal fashion, and expect no
5838 * BSSMAP Reset just because of that. Close connections from the MS side with a
5839 * Release Ind on RSL. */
5840testcase TC_ms_rel_ind_does_not_cause_bssmap_reset() runs on test_CT {
5841 var default d;
5842 var integer i;
5843 var DchanTuple dt;
5844 var BSSAP_N_DATA_ind rx_di;
Neels Hofmeyrfd445c32018-03-09 15:39:31 +01005845 var integer j;
5846
5847 f_init();
5848
5849 /* Wait for initial BSSMAP Reset to pass */
5850 f_sleep(4.0);
5851
5852 d := activate(no_bssmap_reset());
5853
5854 /* Setup up a number of connections and RLSD them again from the MSC
5855 * side. In the buggy behavior, the fourth one triggers BSSMAP Reset.
5856 * Let's do it some more times for good measure. */
5857 for (i := 0; i < 8; i := i+1) {
5858 /* Since we're doing a lot of runs, give each one a fresh
5859 * T_guard from the top. */
5860 T_guard.start;
5861
5862 /* Setup a BSSAP connection and clear it right away. This is
5863 * the MSC telling the BSC about a planned release, it's not an
5864 * erratic loss of a connection. */
5865 dt := f_est_dchan('23'O, 23, '00010203040506'O);
5866
5867 /* simulate RLL REL IND */
5868 f_ipa_tx(0, ts_RSL_REL_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0))));
5869
5870 /* expect Clear Request on MSC side */
5871 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearRequest)) -> value rx_di;
5872
5873 /* Instruct BSC to clear channel */
5874 var BssmapCause cause := bit2int(rx_di.userData.pdu.bssmap.clearRequest.cause.causeValue);
5875 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
5876
5877 /* expect BSC to disable the channel */
Harald Welte641fcbe2018-06-14 10:58:35 +02005878 f_exp_chan_rel_and_clear(dt, 0);
Neels Hofmeyrfd445c32018-03-09 15:39:31 +01005879 }
5880
5881 /* In the buggy behavior, a timeout of 2 seconds happens between above
5882 * trigger (logs "SIGTRAN connection down, reconnecting...") and the
5883 * actual BSSMAP Reset. Wait a bit longer just to make sure. */
5884 f_sleep(4.0);
5885
5886 deactivate(d);
5887 f_shutdown_helper();
5888}
5889
Harald Welte94e0c342018-04-07 11:33:23 +02005890/***********************************************************************
5891 * IPA style dynamic PDCH
5892 ***********************************************************************/
5893
5894private function f_dyn_ipa_pdch_act(integer bts_nr, integer trx_nr, integer ts_nr,
5895 template (omit) RSL_Cause nack := omit)
5896runs on test_CT {
5897 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(ts_nr));
5898 var RSL_Message rsl_unused;
5899 /* ask BSC via VTY to activate a given IPA style chan as PDCH */
5900 f_vty_ts_action("pdch activate", bts_nr, trx_nr, ts_nr);
5901 /* expect the BSC to issue the related RSL command */
5902 rsl_unused := f_exp_ipa_rx(0, tr_RSL_IPA_PDCH_ACT(chan_nr));
5903 if (istemplatekind(nack, "omit")) {
5904 /* respond with a related acknowledgement */
5905 f_ipa_tx(0, ts_RSL_IPA_PDCH_ACT_ACK(chan_nr, ts_RSL_IE_FrameNumber(2342)));
5906 } else {
5907 f_ipa_tx(0, ts_RSL_IPA_PDCH_ACT_NACK(chan_nr, valueof(nack)));
5908 }
5909}
5910
5911private function f_dyn_ipa_pdch_deact(integer bts_nr, integer trx_nr, integer ts_nr,
5912 template (omit) RSL_Cause nack := omit)
5913runs on test_CT {
5914 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(ts_nr));
5915 var RSL_Message rsl_unused;
5916 /* ask BSC via VTY to activate a given IPA style chan as PDCH */
5917 f_vty_ts_action("pdch deactivate", bts_nr, trx_nr, ts_nr);
5918 /* expect the BSC to issue the related RSL command */
5919 rsl_unused := f_exp_ipa_rx(0, tr_RSL_IPA_PDCH_DEACT(chan_nr));
5920 if (istemplatekind(nack, "omit")) {
5921 /* respond with a related acknowledgement */
5922 f_ipa_tx(0, ts_RSL_IPA_PDCH_DEACT_ACK(chan_nr));
5923 } else {
5924 f_ipa_tx(0, ts_RSL_IPA_PDCH_DEACT_NACK(chan_nr, valueof(nack)));
5925 }
5926}
5927
5928private function f_ts_dyn_mode_get(integer bts_nr, integer trx_nr, integer ts_nr)
5929runs on test_CT return charstring {
5930 var charstring cmd, resp;
5931 cmd := "show timeslot "&int2str(bts_nr)&" "&int2str(trx_nr)&" "&int2str(ts_nr);
Stefan Sperlingcff13562018-11-13 15:24:06 +01005932 return f_vty_transceive_match_regexp_retry(BSCVTY, cmd, "*\((*)\)*", 0, 4, 1.0);
Harald Welte94e0c342018-04-07 11:33:23 +02005933}
5934
5935private function f_ts_dyn_mode_assert(integer bts_nr, integer trx_nr, integer ts_nr,
5936 template charstring exp)
5937runs on test_CT {
5938 var charstring mode := f_ts_dyn_mode_get(bts_nr, trx_nr, ts_nr);
5939 if (not match(mode, exp)) {
5940 setverdict(fail, "Unexpected TS Mode: ", mode);
Daniel Willmannafce8662018-07-06 23:11:32 +02005941 mtc.stop;
Harald Welte94e0c342018-04-07 11:33:23 +02005942 }
5943}
5944
5945private function f_ts_set_chcomb(integer bts_nr, integer trx_nr, integer ts_nr, charstring chcomb)
5946runs on test_CT {
5947 f_vty_enter_cfg_ts(BSCVTY, bts_nr, trx_nr, ts_nr);
5948 f_vty_transceive(BSCVTY, "phys_chan_config " & chcomb);
5949 f_vty_transceive(BSCVTY, "end");
5950}
5951
5952private const charstring TCHF_MODE := "TCH/F mode";
5953private const charstring TCHH_MODE := "TCH/H mode";
5954private const charstring PDCH_MODE := "PDCH mode";
5955private const charstring NONE_MODE := "NONE mode";
5956
5957/* Test IPA PDCH activation / deactivation triggered by VTY */
5958testcase TC_dyn_pdch_ipa_act_deact() runs on test_CT {
5959 var RSL_Message rsl_unused;
5960
5961 /* change Timeslot 6 before f_init() starts RSL */
5962 f_init_vty();
5963 f_ts_set_chcomb(0, 0, 6, "TCH/F_PDCH");
5964 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
5965
5966 f_init(1, false);
5967 f_sleep(1.0);
5968
5969 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(6));
5970
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02005971 log("TCH/F_PDCH pchan starts out in TCH/F mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02005972 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
5973 /* The BSC will activate the dynamic PDCH by default, so confirm that */
5974 rsl_unused := f_exp_ipa_rx(0, tr_RSL_IPA_PDCH_ACT(chan_nr));
5975 f_ipa_tx(0, ts_RSL_IPA_PDCH_ACT_ACK(chan_nr, ts_RSL_IE_FrameNumber(2342)));
5976 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02005977 log("TCH/F_PDCH pchan, PDCH ACT was ACKed, so now in PDCH mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02005978 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, PDCH_MODE);
5979
5980 /* De-activate it via VTY */
5981 f_dyn_ipa_pdch_deact(0, 0, chan_nr.tn);
5982 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02005983 log("TCH/F_PDCH pchan, PDCH DEACT via VTY, so now back in TCH/F mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02005984 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
5985
5986 /* re-activate it via VTY */
5987 f_dyn_ipa_pdch_act(0, 0, chan_nr.tn);
5988 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02005989 log("TCH/F_PDCH pchan, PDCH ACT via VTY, so now in PDCH mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02005990 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, PDCH_MODE);
5991
5992 /* and finally de-activate it again */
5993 f_dyn_ipa_pdch_deact(0, 0, chan_nr.tn);
5994 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02005995 log("TCH/F_PDCH pchan, PDCH DEACT via VTY, so now back in TCH/F mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02005996 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
5997
Neels Hofmeyr887e8f12018-06-27 01:01:55 +02005998 /* clean up config */
5999 f_ts_set_chcomb(0, 0, 6, "PDCH");
6000
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006001 f_shutdown_helper();
Harald Welte94e0c342018-04-07 11:33:23 +02006002}
6003
6004/* Test IPA PDCH activation NACK */
6005testcase TC_dyn_pdch_ipa_act_nack() runs on test_CT {
6006 var RSL_Message rsl_unused;
6007
6008 /* change Timeslot 6 before f_init() starts RSL */
6009 f_init_vty();
6010 f_ts_set_chcomb(0, 0, 6, "TCH/F_PDCH");
6011 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
6012
6013 f_init(1, false);
6014 f_sleep(1.0);
6015
6016 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(6));
6017
6018 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
6019 /* The BSC will activate the dynamic PDCH by default, so confirm that */
6020 rsl_unused := f_exp_ipa_rx(0, tr_RSL_IPA_PDCH_ACT(chan_nr));
6021 f_ipa_tx(0, ts_RSL_IPA_PDCH_ACT_ACK(chan_nr, ts_RSL_IE_FrameNumber(2342)));
6022 f_sleep(1.0);
6023 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, PDCH_MODE);
6024
6025 /* De-activate it via VTY */
6026 f_dyn_ipa_pdch_deact(0, 0, chan_nr.tn);
6027 f_sleep(1.0);
6028 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
6029
6030 /* re-activate it via VTY, but fail that; check BSC still assumes TCH/F mode */
6031 f_dyn_ipa_pdch_act(0, 0, chan_nr.tn, RSL_ERR_EQUIPMENT_FAIL);
6032 f_sleep(1.0);
6033 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
6034
Neels Hofmeyr887e8f12018-06-27 01:01:55 +02006035 /* clean up config */
6036 f_ts_set_chcomb(0, 0, 6, "PDCH");
6037
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006038 f_shutdown_helper();
Harald Welte94e0c342018-04-07 11:33:23 +02006039}
6040
6041
6042/***********************************************************************
6043 * Osmocom style dynamic PDCH
6044 ***********************************************************************/
6045
6046private function f_dyn_osmo_pdch_act(integer bts_nr, integer trx_nr, integer ts_nr,
6047 template (omit) RSL_Cause nack := omit)
6048runs on test_CT {
6049 var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(ts_nr));
6050 var RSL_Message rsl_unused;
6051 /* ask BSC via VTY to activate a given IPA style chan as PDCH */
6052 /* FIXME: no VTY command to activate Osmocom PDCH !! */
6053 /* expect the BSC to issue the related RSL command */
6054 rsl_unused := f_exp_ipa_rx(0, tr_RSL_CHAN_ACT(chan_nr, ?));
6055 if (istemplatekind(nack, "omit")) {
6056 /* respond with a related acknowledgement */
6057 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, 2342));
6058 } else {
6059 f_ipa_tx(0, ts_RSL_CHAN_ACT_NACK(chan_nr, valueof(nack)));
6060 }
6061}
6062
6063private function f_dyn_osmo_pdch_deact(integer bts_nr, integer trx_nr, integer ts_nr,
6064 template (omit) RSL_Cause nack := omit)
6065runs on test_CT {
6066 var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(ts_nr));
6067 var RSL_Message rsl_unused;
6068 /* ask BSC via VTY to activate a given IPA style chan as PDCH */
6069 /* FIXME: no VTY command to activate Osmocom PDCH !! */
6070 /* expect the BSC to issue the related RSL command */
6071 rsl_unused := f_exp_ipa_rx(0, tr_RSL_RF_CHAN_REL(chan_nr));
6072 if (istemplatekind(nack, "omit")) {
6073 /* respond with a related acknowledgement */
6074 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(chan_nr));
6075 } else {
6076 //f_ipa_tx(0, ts_RSL_RF_CHAN_REL_NACK(chan_nr, valueof(nack)));
6077 }
6078}
6079
6080/* Test Osmocom dyn PDCH activation / deactivation triggered by VTY */
6081testcase TC_dyn_pdch_osmo_act_deact() runs on test_CT {
6082 var RSL_Message rsl_unused;
6083
6084 /* change Timeslot 6 before f_init() starts RSL */
6085 f_init_vty();
6086 f_ts_set_chcomb(0, 0, 6, "TCH/F_TCH/H_PDCH");
6087 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
6088
6089 f_init(1, false);
6090 f_sleep(1.0);
6091
6092 var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(6));
6093
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02006094 log("TCH/F_TCH/H_PDCH pchan starts out in disabled mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02006095 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, NONE_MODE);
6096 /* The BSC will activate the dynamic PDCH by default, so confirm that */
6097 rsl_unused := f_exp_ipa_rx(0, tr_RSL_CHAN_ACT_PDCH(chan_nr, ?));
6098
6099 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, 2342));
6100 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02006101 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 +02006102 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, PDCH_MODE);
6103
Neels Hofmeyr887e8f12018-06-27 01:01:55 +02006104 /* clean up config */
6105 f_ts_set_chcomb(0, 0, 6, "PDCH");
6106
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006107 f_shutdown_helper();
Harald Welte94e0c342018-04-07 11:33:23 +02006108}
6109
6110/* Test Osmocom dyn PDCH activation NACK behavior */
6111testcase TC_dyn_pdch_osmo_act_nack() runs on test_CT {
6112 var RSL_Message rsl_unused;
6113
6114 /* change Timeslot 6 before f_init() starts RSL */
6115 f_init_vty();
6116 f_ts_set_chcomb(0, 0, 6, "TCH/F_TCH/H_PDCH");
6117 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
6118
6119 f_init(1, false);
6120 f_sleep(1.0);
6121
6122 var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(6));
6123
6124 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, NONE_MODE);
6125 /* The BSC will activate the dynamic PDCH by default, so confirm that */
6126 rsl_unused := f_exp_ipa_rx(0, tr_RSL_CHAN_ACT_PDCH(chan_nr, ?));
6127
6128 /* NACK this activation and expect the "show timeslot" mode still to be NONE */
6129 f_ipa_tx(0, ts_RSL_CHAN_ACT_NACK(chan_nr, RSL_ERR_EQUIPMENT_FAIL));
6130 f_sleep(1.0);
6131 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, NONE_MODE);
6132
Neels Hofmeyr887e8f12018-06-27 01:01:55 +02006133 /* clean up config */
6134 f_ts_set_chcomb(0, 0, 6, "PDCH");
6135
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006136 f_shutdown_helper();
Harald Welte94e0c342018-04-07 11:33:23 +02006137}
6138
Stefan Sperling0796a822018-10-05 13:01:39 +02006139testcase TC_chopped_ipa_ping() runs on test_CT {
Stefan Sperling554123f2018-10-09 14:12:30 +02006140 const Integers bsc_ipa_ports := {mp_bsc_rsl_port, mp_bsc_oml_port, mp_bsc_ctrl_port};
Stefan Sperling0796a822018-10-05 13:01:39 +02006141 for (var integer i := 0; i < lengthof(bsc_ipa_ports); i := i + 1) {
6142 IPA_Testing.f_run_TC_chopped_ipa_ping(mp_bsc_ip, bsc_ipa_ports[i], CONNECT_TO_SERVER);
6143 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006144 f_shutdown_helper();
Stefan Sperling0796a822018-10-05 13:01:39 +02006145}
6146
Stefan Sperlingaa1e60f2018-10-15 16:34:07 +02006147testcase TC_chopped_ipa_payload() runs on test_CT {
6148 const Integers bsc_ipa_ports := {mp_bsc_rsl_port, mp_bsc_oml_port
6149 /* TODO: mp_bsc_ctrl_port does not work yet */};
6150 for (var integer i := 0; i < lengthof(bsc_ipa_ports); i := i + 1) {
6151 IPA_Testing.f_run_TC_chopped_ipa_payload(mp_bsc_ip, bsc_ipa_ports[i], CONNECT_TO_SERVER);
6152 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006153 f_shutdown_helper();
Stefan Sperlingaa1e60f2018-10-15 16:34:07 +02006154}
6155
Pau Espin Pedrol8f773632019-11-05 11:46:53 +01006156/* Verify the BSC sends the MS Power Parameters IE during CHAN ACT to make sure
6157 the BTS does autonomous MS power control loop */
6158testcase TC_assignment_verify_ms_power_params_ie() runs on test_CT {
6159 var MSC_ConnHdlr vc_conn;
6160 var TestHdlrParams pars := f_gen_test_hdlr_pars();
6161 //pars.encr := valueof(t_EncrParams('01'O, f_rnd_octstring(8)));
6162 pars.exp_ms_power_params := true;
6163
6164 f_init(1, true);
6165 f_sleep(1.0);
6166 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5), pars);
6167 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006168 f_shutdown_helper();
Pau Espin Pedrol8f773632019-11-05 11:46:53 +01006169}
Stefan Sperlingaa1e60f2018-10-15 16:34:07 +02006170
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006171/***********************************************************************
6172 * MSC Pooling
6173 ***********************************************************************/
6174
6175function f_tmsi_nri(integer nri_v, octetstring base_tmsi := '42000023'O, integer nri_bitlen := 10) return octetstring
6176{
6177 return int2oct( oct2int(base_tmsi) + bit2int( (int2bit(nri_v, 32) << ( 24 - nri_bitlen)) ),
6178 4);
6179}
6180
6181template MobileIdentityLV ts_MI_TMSI_NRI_LV(integer nri_v, integer nri_bitlen := 10) :=
6182 ts_MI_TMSI_LV(tmsi := f_tmsi_nri(nri_v, nri_bitlen := nri_bitlen));
6183
6184private function f_perform_clear(RSL_DCHAN_PT rsl) runs on MSC_ConnHdlr {
Neels Hofmeyr767548a2020-08-09 20:26:07 +00006185 f_logp(BSCVTY, "MSC instructs BSC to clear channel");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006186 BSSAP.send(ts_BSSMAP_ClearCommand(0));
6187 interleave {
6188 [] rsl.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_RELEASE)) {
Neels Hofmeyr767548a2020-08-09 20:26:07 +00006189 f_logp(BSCVTY, "Got RSL RR Release");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006190 }
6191 [] rsl.receive(tr_RSL_DEACT_SACCH(g_chan_nr)) {
Neels Hofmeyr767548a2020-08-09 20:26:07 +00006192 f_logp(BSCVTY, "Got RSL Deact SACCH");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006193 }
6194 [] BSSAP.receive(tr_BSSMAP_ClearComplete) {
Neels Hofmeyr767548a2020-08-09 20:26:07 +00006195 f_logp(BSCVTY, "Got BSSMAP Clear Complete");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006196 /* Also drop the SCCP connection */
6197 BSSAP.send(RAN_Conn_Prim:MSC_CONN_PRIM_DISC_REQ);
6198 }
6199 [] rsl.receive(tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL)) {
Neels Hofmeyr767548a2020-08-09 20:26:07 +00006200 f_logp(BSCVTY, "Got RSL RF Chan Rel, sending Rel Ack");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006201 rsl.send(ts_RSL_RF_CHAN_REL_ACK(g_chan_nr));
6202 }
6203 }
6204}
6205
6206private function f_perform_compl_l3(RSL_DCHAN_PT rsl, template PDU_ML3_MS_NW l3_info, boolean do_clear := true)
6207runs on MSC_ConnHdlr {
6208 timer T := 10.0;
6209 var octetstring l3_enc := enc_PDU_ML3_MS_NW(valueof(l3_info));
6210
Neels Hofmeyr767548a2020-08-09 20:26:07 +00006211 f_logp(BSCVTY, "establish channel, send Complete Layer 3 Info");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006212 f_create_bssmap_exp(l3_enc);
6213
6214 /* RSL_Emulation.f_chan_est() on rsl:
6215 * This is basically code dup with s/RSL/rsl from:
6216 * RSL_Emulation.f_chan_est(g_pars.ra, l3_enc, g_pars.link_id, g_pars.fn);
6217 */
6218 var RSL_Message rx_rsl;
6219 var GsmRrMessage rr;
6220
6221 /* request a channel to be established */
6222 rsl.send(ts_RSLDC_ChanRqd(g_pars.ra, g_pars.fn));
6223 /* expect immediate assignment.
6224 * Code dup with s/RSL/rsl from:
6225 * rx_rsl := f_rx_or_fail(tr_RSL_IMM_ASSIGN);
6226 */
6227 timer Tt := 10.0;
6228
6229 /* request a channel to be established */
6230 Tt.start;
6231 alt {
6232 [] rsl.receive(tr_RSL_IMM_ASSIGN) -> value rx_rsl {
6233 Tt.stop;
6234 }
6235 [] rsl.receive {
6236 setverdict(fail, "Unexpected RSL message on DCHAN");
6237 mtc.stop;
6238 }
6239 [] Tt.timeout {
6240 setverdict(fail, "Timeout waiting for RSL on DCHAN");
6241 mtc.stop;
6242 }
6243 }
6244 rr := dec_GsmRrMessage(rx_rsl.ies[1].body.full_imm_ass_info.payload);
6245 g_chan_nr := rr.payload.imm_ass.chan_desc.chan_nr;
6246 rsl.send(ts_RSL_EST_IND(g_chan_nr, valueof(g_pars.link_id), l3_enc));
6247
6248
Neels Hofmeyr767548a2020-08-09 20:26:07 +00006249 f_logp(BSCVTY, "expect BSSAP Complete Layer 3 Info at MSC");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006250 var template PDU_BSSAP exp_l3_compl;
6251 exp_l3_compl := tr_BSSMAP_ComplL3()
6252 if (g_pars.aoip == false) {
6253 exp_l3_compl.pdu.bssmap.completeLayer3Information.codecList := omit;
6254 } else {
6255 exp_l3_compl.pdu.bssmap.completeLayer3Information.codecList := ?;
6256 }
6257
6258 var PDU_BSSAP bssap;
6259 T.start;
6260 alt {
6261 [] BSSAP.receive(exp_l3_compl) -> value bssap {
Neels Hofmeyr767548a2020-08-09 20:26:07 +00006262 f_logp(BSCVTY, "received expected Complete Layer 3 Info at MSC");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006263 log("rx exp_l3_compl = ", bssap);
6264 }
6265 [] BSSAP.receive(tr_BSSMAP_ComplL3) {
6266 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Received non-matching COMPLETE LAYER 3 INFORMATION");
6267 }
6268 [] T.timeout {
6269 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for COMPLETE LAYER 3 INFORMATION");
6270 }
6271 }
6272
6273 /* start ciphering, if requested */
6274 if (ispresent(g_pars.encr)) {
Neels Hofmeyr767548a2020-08-09 20:26:07 +00006275 f_logp(BSCVTY, "start ciphering");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006276 f_cipher_mode(g_pars.encr.enc_alg, g_pars.encr.enc_key);
6277 }
6278
6279 if (do_clear) {
6280 f_perform_clear(rsl);
6281 }
6282 setverdict(pass);
6283 f_sleep(1.0);
6284}
6285
6286private function f_tc_mscpool_compl_l3(charstring id) runs on MSC_ConnHdlr {
6287 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
6288 if (g_pars.mscpool.rsl_idx == 0) {
6289 f_perform_compl_l3(RSL, g_pars.mscpool.l3_info);
6290 } else if (g_pars.mscpool.rsl_idx == 1) {
6291 f_perform_compl_l3(RSL1, g_pars.mscpool.l3_info);
6292 } else if (g_pars.mscpool.rsl_idx == 2) {
6293 f_perform_compl_l3(RSL2, g_pars.mscpool.l3_info);
6294 }
6295}
6296
6297/* Various Complete Layer 3 by IMSI all end up with the first MSC, because the other MSCs are not connected. */
6298private function f_tc_mscpool_L3Compl_on_1_msc(charstring id) runs on MSC_ConnHdlr {
6299 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
6300 f_perform_compl_l3(RSL, ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_IMSI_LV('001010000000001'H)), '00F110'O) );
6301 f_perform_compl_l3(RSL, ts_CM_SERV_REQ(CM_TYPE_MO_SMS, valueof(ts_MI_IMSI_LV('001010000000002'H))) );
6302 f_perform_compl_l3(RSL, ts_PAG_RESP(valueof(ts_MI_IMSI_LV('001010000000003'H))) );
6303 f_perform_compl_l3(RSL, ts_ML3_MO_MM_IMSI_DET_Ind(valueof(ts_MI_IMSI_LV('001010000000004'H))) );
6304}
6305testcase TC_mscpool_L3Compl_on_1_msc() runs on test_CT {
6306
6307 f_init(1, true);
6308 f_sleep(1.0);
6309 var MSC_ConnHdlr vc_conn;
6310 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006311
6312 f_ctrs_msc_init();
6313
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006314 vc_conn := f_start_handler(refers(f_tc_mscpool_L3Compl_on_1_msc), pars);
6315 vc_conn.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006316
6317 f_ctrs_msc_expect(0, "mscpool:subscr:new", 4);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006318 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006319}
6320
6321/* Three Layer 3 Complete by IMSI are round-robin'ed across two connected MSCs */
6322/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
6323 * just as well using only RSL. */
6324testcase TC_mscpool_L3Complete_by_imsi_round_robin() runs on test_CT {
6325
6326 f_init(nr_bts := 3, handler_mode := true, nr_msc := 2);
6327 f_sleep(1.0);
6328
6329 /* Control which MSC gets chosen next by the round-robin, otherwise
6330 * would be randomly affected by which other tests ran before this. */
6331 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
6332
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006333 f_ctrs_msc_init();
6334
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006335 var MSC_ConnHdlr vc_conn1;
6336 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
6337 pars1.mscpool.rsl_idx := 0;
6338 pars1.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_IMSI_LV('001010000000001'H)), '00F110'O));
6339 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6340 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006341 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006342
6343 var MSC_ConnHdlr vc_conn2;
6344 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 1);
6345 pars2.mscpool.rsl_idx := 1;
6346 pars2.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, valueof(ts_MI_IMSI_LV('001010000000002'H))));
6347 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6348 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006349 f_ctrs_msc_expect(1, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006350
6351 /* Test round-robin wrap to the first MSC */
6352 var MSC_ConnHdlr vc_conn3;
6353 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 0);
6354 pars3.mscpool.rsl_idx := 2;
6355 pars3.mscpool.l3_info := valueof(ts_PAG_RESP(valueof(ts_MI_IMSI_LV('001010000000003'H))));
6356 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
6357 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006358 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006359 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006360}
6361
6362/* Three LU by TMSI are round-robin'ed across two connected MSCs, because they contain the NULL-NRI 0
6363 * (configured in osmo-bsc.cfg). */
6364/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
6365 * just as well using only RSL. */
6366testcase TC_mscpool_LU_by_tmsi_null_nri_0_round_robin() runs on test_CT {
6367
6368 f_init(nr_bts := 3, handler_mode := true, nr_msc := 2);
6369 f_sleep(1.0);
6370
6371 /* Control which MSC gets chosen next by the round-robin, otherwise
6372 * would be randomly affected by which other tests ran before this. */
6373 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
6374
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006375 f_ctrs_msc_init();
6376
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006377 var MSC_ConnHdlr vc_conn1;
6378 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
6379 pars1.mscpool.rsl_idx := 0;
6380 pars1.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(0)), '00F110'O));
6381 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6382 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006383 f_ctrs_msc_expect(0, "mscpool:subscr:reattach");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006384
6385 var MSC_ConnHdlr vc_conn2;
6386 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 1);
6387 pars2.mscpool.rsl_idx := 1;
6388 pars2.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(0)), '00F110'O));
6389 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6390 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006391 f_ctrs_msc_expect(1, "mscpool:subscr:reattach");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006392
6393 /* Test round-robin wrap to the first MSC */
6394 var MSC_ConnHdlr vc_conn3;
6395 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 0);
6396 pars3.mscpool.rsl_idx := 2;
6397 pars3.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(0)), '00F110'O));
6398 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
6399 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006400 f_ctrs_msc_expect(0, "mscpool:subscr:reattach");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006401 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006402}
6403
6404/* Three LU by TMSI are round-robin'ed across two connected MSCs, because they contain the NULL-NRI 1
6405 * (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
6406 * NULL-NRI setting is stronger than that. */
6407/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
6408 * just as well using only RSL. */
6409testcase TC_mscpool_LU_by_tmsi_null_nri_1_round_robin() runs on test_CT {
6410
6411 f_init(nr_bts := 3, handler_mode := true, nr_msc := 2);
6412 f_sleep(1.0);
6413
6414 /* Control which MSC gets chosen next by the round-robin, otherwise
6415 * would be randomly affected by which other tests ran before this. */
6416 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
6417
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006418 f_ctrs_msc_init();
6419
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006420 var MSC_ConnHdlr vc_conn1;
6421 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
6422 pars1.mscpool.rsl_idx := 0;
6423 pars1.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(1)), '00F110'O));
6424 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6425 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006426 f_ctrs_msc_expect(0, "mscpool:subscr:reattach");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006427
6428 var MSC_ConnHdlr vc_conn2;
6429 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 1);
6430 pars2.mscpool.rsl_idx := 1;
6431 pars2.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(1)), '00F110'O));
6432 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6433 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006434 f_ctrs_msc_expect(1, "mscpool:subscr:reattach");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006435
6436 /* Test round-robin wrap to the first MSC */
6437 var MSC_ConnHdlr vc_conn3;
6438 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 0);
6439 pars3.mscpool.rsl_idx := 2;
6440 pars3.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(1)), '00F110'O));
6441 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
6442 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006443 f_ctrs_msc_expect(0, "mscpool:subscr:reattach");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006444 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006445}
6446
6447/* Three Layer 3 Complete by TMSI are round-robin'ed across two connected MSCs, because they contain an NRI not
6448 * assigned to any MSC (configured in osmo-bsc.cfg). */
6449/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
6450 * just as well using only RSL. */
6451testcase TC_mscpool_L3Complete_by_tmsi_unassigned_nri_round_robin() runs on test_CT {
6452
6453 f_init(nr_bts := 3, handler_mode := true, nr_msc := 2);
6454 f_sleep(1.0);
6455
6456 /* Control which MSC gets chosen next by the round-robin, otherwise
6457 * would be randomly affected by which other tests ran before this. */
6458 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
6459
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006460 f_ctrs_msc_init();
6461
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006462 var MSC_ConnHdlr vc_conn1;
6463 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
6464 pars1.mscpool.rsl_idx := 0;
6465 /* An NRI that is not assigned to any MSC */
6466 pars1.mscpool.l3_info := valueof(ts_ML3_MO_MM_IMSI_DET_Ind(valueof(ts_MI_TMSI_NRI_LV(1023))));
6467 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6468 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006469 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006470
6471 var MSC_ConnHdlr vc_conn2;
6472 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 1);
6473 pars2.mscpool.rsl_idx := 1;
6474 /* An NRI that is not assigned to any MSC */
6475 pars2.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(768)), '00F110'O));
6476 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6477 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006478 f_ctrs_msc_expect(1, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006479
6480 /* Test round-robin wrap to the first MSC */
6481 var MSC_ConnHdlr vc_conn3;
6482 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 0);
6483 pars3.mscpool.rsl_idx := 2;
6484 /* An NRI that is not assigned to any MSC */
6485 pars3.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_SS_ACT, valueof(ts_MI_TMSI_NRI_LV(819))));
6486 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
6487 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006488 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006489 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006490}
6491
6492/* Three Layer 3 Complete by TMSI are round-robin'ed across two connected MSCs, because they contain an NRI
6493 * assigned to an MSC that is currently not connected (configured in osmo-bsc.cfg). */
6494/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
6495 * just as well using only RSL. */
6496testcase TC_mscpool_L3Complete_by_tmsi_valid_nri_msc_not_connected_round_robin() runs on test_CT {
6497
6498 f_init(nr_bts := 3, handler_mode := true, nr_msc := 2);
6499 f_sleep(1.0);
6500
6501 /* Control which MSC gets chosen next by the round-robin, otherwise
6502 * would be randomly affected by which other tests ran before this. */
6503 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
6504
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006505 f_ctrs_msc_init();
6506
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006507 var MSC_ConnHdlr vc_conn1;
6508 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
6509 pars1.mscpool.rsl_idx := 0;
6510 /* An NRI that is assigned to an unconnected MSC */
6511 pars1.mscpool.l3_info := valueof(ts_PAG_RESP(valueof(ts_MI_TMSI_NRI_LV(512))));
6512 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6513 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006514 f_ctrs_msc_add(2, "mscpool:subscr:attach_lost");
6515 f_ctrs_msc_add(0, "mscpool:subscr:new");
6516 f_ctrs_msc_verify();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006517
6518 var MSC_ConnHdlr vc_conn2;
6519 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 1);
6520 pars2.mscpool.rsl_idx := 1;
6521 /* An NRI that is assigned to an unconnected MSC */
6522 pars2.mscpool.l3_info := valueof(ts_ML3_MO_MM_IMSI_DET_Ind(valueof(ts_MI_TMSI_NRI_LV(767))));
6523 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6524 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006525 f_ctrs_msc_add(2, "mscpool:subscr:attach_lost");
6526 f_ctrs_msc_add(1, "mscpool:subscr:new");
6527 f_ctrs_msc_verify();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006528
6529 /* Test round-robin wrap to the first MSC */
6530 var MSC_ConnHdlr vc_conn3;
6531 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 0);
6532 pars3.mscpool.rsl_idx := 2;
6533 /* An NRI that is assigned to an unconnected MSC */
6534 pars3.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(750)), '00F110'O));
6535 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
6536 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006537 f_ctrs_msc_add(2, "mscpool:subscr:attach_lost");
6538 f_ctrs_msc_add(0, "mscpool:subscr:new");
6539 f_ctrs_msc_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006540 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006541}
6542
6543/* Three Layer 3 Complete by TMSI with valid NRI for the second MSC are all directed to the second MSC (configured in
6544 * osmo-bsc.cfg). */
6545/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
6546 * just as well using only RSL. */
6547testcase TC_mscpool_L3Complete_by_tmsi_valid_nri_1() runs on test_CT {
6548
6549 f_init(nr_bts := 3, handler_mode := true, nr_msc := 2);
6550 f_sleep(1.0);
6551
6552 /* All TMSIs in this test point at the second MSC, set the round robin to point at the first MSC to make sure
6553 * this is not using round-robin. */
6554 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
6555
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006556 f_ctrs_msc_init();
6557
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006558 var MSC_ConnHdlr vc_conn1;
6559 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 1);
6560 pars1.mscpool.rsl_idx := 0;
6561 /* An NRI of the second MSC's range (256-511) */
6562 pars1.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_SMS, valueof(ts_MI_TMSI_NRI_LV(256))));
6563 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6564 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006565 f_ctrs_msc_expect(1, "mscpool:subscr:known");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006566
6567 var MSC_ConnHdlr vc_conn2;
6568 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 1);
6569 pars2.mscpool.rsl_idx := 1;
6570 /* An NRI of the second MSC's range (256-511) */
6571 pars2.mscpool.l3_info := valueof(ts_PAG_RESP(valueof(ts_MI_TMSI_NRI_LV(260))));
6572 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6573 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006574 f_ctrs_msc_expect(1, "mscpool:subscr:known");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006575
6576 var MSC_ConnHdlr vc_conn3;
6577 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 1);
6578 pars3.mscpool.rsl_idx := 2;
6579 /* An NRI of the second MSC's range (256-511) */
6580 pars3.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(511)), '00F110'O));
6581 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
6582 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006583 f_ctrs_msc_expect(1, "mscpool:subscr:known");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006584 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006585}
6586
6587/* Layer 3 Complete by TMSI with valid NRI for the third MSC are directed to the third MSC (configured in osmo-bsc.cfg),
6588 * while a round-robin remains unaffected by that. */
6589/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
6590 * just as well using only RSL. */
6591testcase TC_mscpool_L3Complete_by_tmsi_valid_nri_2() runs on test_CT {
6592
6593 f_init(nr_bts := 3, handler_mode := true, nr_msc := 3);
6594 f_sleep(1.0);
6595
6596 /* All TMSIs in this test point at the third MSC, set the round robin to point at the second MSC to make sure
6597 * this is not using round-robin. */
6598 f_vty_transceive(BSCVTY, "mscpool roundrobin next 1");
6599
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006600 f_ctrs_msc_init();
6601
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006602 var MSC_ConnHdlr vc_conn1;
6603 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 2);
6604 pars1.mscpool.rsl_idx := 0;
6605 /* An NRI of the third MSC's range (512-767) */
6606 pars1.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_SMS, valueof(ts_MI_TMSI_NRI_LV(512))));
6607 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6608 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006609 f_ctrs_msc_expect(2, "mscpool:subscr:known");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006610
6611 var MSC_ConnHdlr vc_conn2;
6612 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 2);
6613 pars2.mscpool.rsl_idx := 1;
6614 /* An NRI of the third MSC's range (512-767) */
6615 pars2.mscpool.l3_info := valueof(ts_PAG_RESP(valueof(ts_MI_TMSI_NRI_LV(678))));
6616 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6617 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006618 f_ctrs_msc_expect(2, "mscpool:subscr:known");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006619
6620 /* The above forwardings to third MSC have not affected the round robin, which still points at the second MSC */
6621 var MSC_ConnHdlr vc_conn3;
6622 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 1);
6623 pars3.mscpool.rsl_idx := 2;
6624 pars3.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_IMSI_LV('001010000000013'H)), '00F110'O));
6625 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
6626 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006627 f_ctrs_msc_expect(1, "mscpool:subscr:new");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006628 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006629}
6630
6631/* LU with a TMSI but indicating a different PLMN in its previous LAI: ignore the NRI. */
6632/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
6633 * just as well using only RSL. */
6634testcase TC_mscpool_LU_by_tmsi_from_other_PLMN() runs on test_CT {
6635
6636 f_init(nr_bts := 3, handler_mode := true, nr_msc := 3);
6637 f_sleep(1.0);
6638
6639 /* The TMSIs in this test points at the second MSC, but since it is from a different PLMN, round-robin is used
6640 * instead, and hits msc 0. */
6641 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
6642
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006643 f_ctrs_msc_init();
6644
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006645 /* An NRI of the second MSC's range (256-511), but a PLMN that doesn't match with osmo-bsc.cfg */
6646 var MSC_ConnHdlr vc_conn1;
6647 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
6648 pars1.mscpool.rsl_idx := 0;
6649 pars1.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(260)), '99F999'O));
6650 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6651 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006652 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006653
6654 /* An NRI of the third MSC's range (512-767) and a matching PLMN gets directed by NRI. */
6655 var MSC_ConnHdlr vc_conn2;
6656 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 2);
6657 pars2.mscpool.rsl_idx := 1;
6658 pars2.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(555)), '00F110'O));
6659 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6660 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006661 f_ctrs_msc_expect(2, "mscpool:subscr:known");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006662 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006663}
6664
6665/* Make sure that whichever MSC paged a subscriber will also get the Paging Response. Page by IMSI, which would be
6666 * round-robined to another MSC, to make sure the Paging->Response relation is stronger than the NRI->MSC mapping. */
6667private function f_tc_mscpool_paging_imsi(charstring id) runs on MSC_ConnHdlr {
6668 var template BSSMAP_FIELD_CellIdentificationList cid_list := { cIl_CI := { ts_BSSMAP_CI_CI(0) } };
6669 //cid_list := { cIl_allInBSS := ''O };
6670 var RSL_ChanNeeded rsl_chneed := RSL_CHANNEED_SDCCH;
6671 var template BSSMAP_IE_ChannelNeeded bssmap_chneed := ts_BSSMAP_IE_ChanNeeded(int2bit(enum2int(valueof(rsl_chneed)),2));
6672 var BSSAP_N_UNITDATA_req paging;
6673 var hexstring imsi := '001010000000123'H;
6674
6675 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
6676
Neels Hofmeyr90f80962020-06-12 16:16:55 +02006677 paging := valueof(ts_BSSAP_UNITDATA_req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006678 valueof(ts_BSSMAP_Paging(imsi, cid_list, omit, bssmap_chneed))));
6679 BSSAP.send(paging);
6680
6681 /* Register any RSL conn so that the Paging Command gets received here. With the current RSL_Emulation's main()
6682 * handling of '[bts_role] IPA_PT.receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD()))' it doesn't matter at all which
6683 * channel number is picked here. */
6684 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(0, RSL_CHAN_NR_INVALID));
6685 f_rslem_register(0, new_chan_nr);
6686 RSL.receive(tr_RSL_PAGING_CMD(tr_MI_IMSI(imsi)));
6687 f_rslem_unregister(0, new_chan_nr);
6688
6689 /* Despite the round robin pointing at the second MSC ('roundrobin next 1'), the earlier Paging for the same IMSI
6690 * causes this Paging Response to go to the first MSC (bssap_idx := 0). */
6691 f_perform_compl_l3(RSL, ts_PAG_RESP(valueof(ts_MI_IMSI_LV(imsi))) );
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006692 f_sleep(1.0);
6693}
6694testcase TC_mscpool_paging_and_response_imsi() runs on test_CT {
6695 f_init(nr_bts := 1, handler_mode := true, nr_msc := 3);
6696 f_sleep(1.0);
6697
6698 /* Testing a Paging on the first MSC to get a Paging Response back to the first MSC. Set round robin to the
6699 * second MSC to make sure we're getting the Paging logic, not a coincidental round robin match. */
6700 f_vty_transceive(BSCVTY, "mscpool roundrobin next 1");
6701
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006702 f_ctrs_msc_init();
6703
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006704 var MSC_ConnHdlr vc_conn1;
6705 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
6706 pars1.mscpool.rsl_idx := 0;
Neels Hofmeyr90f80962020-06-12 16:16:55 +02006707 pars1.sccp_addr_bsc := g_bssap[pars1.mscpool.bssap_idx].sccp_addr_peer;
6708 pars1.sccp_addr_msc := g_bssap[pars1.mscpool.bssap_idx].sccp_addr_own;
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006709 vc_conn1 := f_start_handler(refers(f_tc_mscpool_paging_imsi), pars1);
6710 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006711 f_ctrs_msc_expect(0, "mscpool:subscr:paged");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006712 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006713}
6714
6715/* Make sure that whichever MSC paged a subscriber will also get the Paging Response. Page by TMSI with an NRI value
6716 * that matches a different MSC, to make sure the Paging->Response relation is stronger than the NRI->MSC mapping. */
6717private function f_tc_mscpool_paging_tmsi(charstring id) runs on MSC_ConnHdlr {
6718 var template BSSMAP_FIELD_CellIdentificationList cid_list := { cIl_CI := { ts_BSSMAP_CI_CI(0) } };
6719 //cid_list := { cIl_allInBSS := ''O };
6720 var RSL_ChanNeeded rsl_chneed := RSL_CHANNEED_SDCCH;
6721 var template BSSMAP_IE_ChannelNeeded bssmap_chneed := ts_BSSMAP_IE_ChanNeeded(int2bit(enum2int(valueof(rsl_chneed)),2));
6722 var integer nri_v := 300; /* <-- second MSC's NRI */
6723 var octetstring tmsi := f_tmsi_nri(nri_v);
6724 var BSSAP_N_UNITDATA_req paging;
6725
6726 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
6727
Neels Hofmeyr90f80962020-06-12 16:16:55 +02006728 paging := valueof(ts_BSSAP_UNITDATA_req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006729 valueof(ts_BSSMAP_Paging('001010000000011'H, cid_list, tmsi, bssmap_chneed))));
6730 BSSAP.send(paging);
6731
6732 /* Register any RSL conn so that the Paging Command gets received here. With the current RSL_Emulation's main()
6733 * handling of '[bts_role] IPA_PT.receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD()))' it doesn't matter at all which
6734 * channel number is picked here. */
6735 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(0, RSL_CHAN_NR_INVALID));
6736 f_rslem_register(0, new_chan_nr);
6737 RSL.receive(tr_RSL_PAGING_CMD(t_MI_TMSI(tmsi)));
6738 f_rslem_unregister(0, new_chan_nr);
6739
6740 /* Despite the NRI matching the second MSC (NRI from 'msc 1' in osmo-bsc.cfg) and round robin pointing at the
6741 * third MSC ('roundrobin next 2'), the earlier Paging for the same TMSI causes this Paging Response to go to
6742 * the first MSC (bssap_idx := 0). */
6743 f_perform_compl_l3(RSL, ts_PAG_RESP(valueof(ts_MI_TMSI_NRI_LV(nri_v))) );
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006744 f_sleep(1.0);
6745}
6746testcase TC_mscpool_paging_and_response_tmsi() runs on test_CT {
6747 f_init(nr_bts := 1, handler_mode := true, nr_msc := 3);
6748 f_sleep(1.0);
6749
6750 /* Testing a Paging on the first MSC to get a Paging Response back to the first MSC. Set round robin to the
6751 * third MSC to make sure we're getting the Paging logic, not a coincidental round robin match. */
6752 f_vty_transceive(BSCVTY, "mscpool roundrobin next 2");
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;
Neels Hofmeyr90f80962020-06-12 16:16:55 +02006759 pars1.sccp_addr_bsc := g_bssap[pars1.mscpool.bssap_idx].sccp_addr_peer;
6760 pars1.sccp_addr_msc := g_bssap[pars1.mscpool.bssap_idx].sccp_addr_own;
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006761 vc_conn1 := f_start_handler(refers(f_tc_mscpool_paging_tmsi), pars1);
6762 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006763 f_ctrs_msc_expect(0, "mscpool:subscr:paged");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006764 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006765}
6766
6767/* For round-robin, skip an MSC that has 'no allow-attach' set. */
6768/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
6769 * just as well using only RSL. */
6770testcase TC_mscpool_no_allow_attach_round_robin() runs on test_CT {
6771
6772 f_init(nr_bts := 3, handler_mode := true, nr_msc := 3);
6773 f_sleep(1.0);
Neels Hofmeyra460f1f2020-08-09 20:17:03 +00006774 /* Mark the second MSC as offloading, round-robin should skip this MSC now. */
6775 f_vty_msc_allow_attach(BSCVTY, {true, false, true});
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006776
6777 /* Control which MSC gets chosen next by the round-robin, otherwise
6778 * would be randomly affected by which other tests ran before this. */
6779 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
6780
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006781 f_ctrs_msc_init();
6782
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006783 var MSC_ConnHdlr vc_conn1;
6784 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
6785 pars1.mscpool.rsl_idx := 0;
6786 pars1.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_IMSI_LV('001010000000001'H)), '00F110'O));
6787 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6788 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006789 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006790
6791 var MSC_ConnHdlr vc_conn2;
6792 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 2);
6793 pars2.mscpool.rsl_idx := 1;
6794 pars2.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, valueof(ts_MI_IMSI_LV('001010000000002'H))));
6795 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6796 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006797 f_ctrs_msc_expect(2, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006798
6799 var MSC_ConnHdlr vc_conn3;
6800 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 0);
6801 pars3.mscpool.rsl_idx := 2;
6802 pars3.mscpool.l3_info := valueof(ts_PAG_RESP(valueof(ts_MI_IMSI_LV('001010000000003'H))));
6803 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
6804 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006805 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006806 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006807}
6808
6809/* An MSC that has 'no allow-attach' set should still serve subscribers that are already attached according to their
6810 * TMSI NRI. */
6811testcase TC_mscpool_no_allow_attach_valid_nri() runs on test_CT {
6812
6813 f_init(nr_bts := 3, handler_mode := true, nr_msc := 3);
6814 f_sleep(1.0);
6815
Neels Hofmeyra460f1f2020-08-09 20:17:03 +00006816 /* Mark the second MSC as offloading, round-robin should skip this MSC now. */
6817 f_vty_msc_allow_attach(BSCVTY, {true, false, true});
6818
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006819 /* Control which MSC gets chosen next by the round-robin, otherwise
6820 * would be randomly affected by which other tests ran before this. */
6821 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
6822
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006823 f_ctrs_msc_init();
6824
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006825 /* Round robin points at msc 0, but the valid NRI directs to msc 1, even though msc 1 has 'no allow-attach'. */
6826 var MSC_ConnHdlr vc_conn1;
6827 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 1);
6828 pars1.mscpool.rsl_idx := 0;
6829 /* An NRI of the second MSC's range (256-511) */
6830 pars1.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, valueof(ts_MI_TMSI_NRI_LV(260))));
6831 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6832 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006833 f_ctrs_msc_expect(1, "mscpool:subscr:known");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006834
6835 var MSC_ConnHdlr vc_conn2;
6836 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 0);
6837 pars2.mscpool.rsl_idx := 1;
6838 pars2.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, valueof(ts_MI_IMSI_LV('001010000000002'H))));
6839 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6840 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006841 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006842
6843 var MSC_ConnHdlr vc_conn3;
6844 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 2);
6845 pars3.mscpool.rsl_idx := 2;
6846 pars3.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, valueof(ts_MI_IMSI_LV('001010000000003'H))));
6847 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
6848 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006849 f_ctrs_msc_expect(2, "mscpool:subscr:new");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006850 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006851}
6852
Philipp Maier783681c2020-07-16 16:47:06 +02006853/* Allow/Deny emergency calls globally via VTY */
6854private function f_vty_allow_emerg_msc(boolean allow) runs on test_CT {
6855 f_vty_enter_cfg_msc(BSCVTY, 0);
6856 if (allow) {
6857 f_vty_transceive(BSCVTY, "allow-emergency allow");
6858 } else {
6859 f_vty_transceive(BSCVTY, "allow-emergency deny");
6860 }
6861 f_vty_transceive(BSCVTY, "exit");
6862 f_vty_transceive(BSCVTY, "exit");
6863}
6864
6865/* Allow/Deny emergency calls per BTS via VTY */
6866private function f_vty_allow_emerg_bts(boolean allow, integer bts_nr) runs on test_CT {
6867 f_vty_enter_cfg_bts(BSCVTY, bts_nr);
6868 if (allow) {
6869 f_vty_transceive(BSCVTY, "rach emergency call allowed 1");
6870 } else {
6871 f_vty_transceive(BSCVTY, "rach emergency call allowed 0");
6872 }
6873 f_vty_transceive(BSCVTY, "exit");
6874 f_vty_transceive(BSCVTY, "exit");
Neels Hofmeyrb6ed80c2020-10-12 22:52:39 +00006875 f_vty_transceive(BSCVTY, "exit");
Philipp Maier783681c2020-07-16 16:47:06 +02006876}
6877
6878/* Begin assignmet procedure and send an EMERGENCY SETUP (RR) */
6879private function f_assignment_emerg_setup() runs on MSC_ConnHdlr {
6880 var PDU_ML3_MS_NW emerg_setup;
6881 var octetstring emerg_setup_enc;
6882 var RSL_Message emerg_setup_data_ind;
6883
6884 f_establish_fully(omit, omit);
6885
6886 emerg_setup := valueof(ts_ML3_MO_CC_EMERG_SETUP(1, valueof(ts_Bcap_voice)));
6887 emerg_setup_enc := enc_PDU_ML3_MS_NW(emerg_setup);
6888 emerg_setup_data_ind := valueof(ts_RSL_DATA_IND(g_chan_nr, valueof(ts_RslLinkID_DCCH(0)), emerg_setup_enc));
6889
6890 RSL.send(emerg_setup_data_ind);
6891}
6892
6893/* Test if the EMERGENCY SETUP gets passed on to the MSC via A when EMERGENCY
6894 * CALLS are permitted by the BSC config. */
6895private function f_TC_assignment_emerg_setup_allow(charstring id) runs on MSC_ConnHdlr {
6896 var PDU_BSSAP emerg_setup_data_ind_bssap;
6897 var PDU_ML3_MS_NW emerg_setup;
6898 timer T := 3.0;
6899
6900 f_assignment_emerg_setup()
6901
6902 T.start;
6903 alt {
6904 [] BSSAP.receive(tr_BSSAP_DTAP) -> value emerg_setup_data_ind_bssap {
6905 emerg_setup := dec_PDU_ML3_MS_NW(emerg_setup_data_ind_bssap.pdu.dtap);
6906 if (not isbound(emerg_setup.msgs.cc.emergencySetup)) {
6907 setverdict(fail, "no emergency setup");
6908 }
6909 }
6910 [] BSSAP.receive {
6911 setverdict(fail, "unexpected BSSAP message!");
6912 }
6913 [] T.timeout {
6914 setverdict(fail, "timout waiting for EMERGENCY SETUP!");
6915 }
6916 }
6917
6918 setverdict(pass);
6919}
6920
6921/* Test if the EMERGENCY SETUP gets blocked by the BSC if EMERGENCY CALLS are
6922 * forbidden by the BSC config. */
6923private function f_TC_assignment_emerg_setup_deny(charstring id) runs on MSC_ConnHdlr {
6924 var PDU_BSSAP emerg_setup_data_ind_bssap;
6925 timer T := 3.0;
6926
6927 f_assignment_emerg_setup()
6928
6929 T.start;
6930 alt {
6931 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_RELEASE)) {
6932 setverdict(pass);
6933 }
6934 [] RSL.receive {
6935 setverdict(fail, "unexpected RSL message!");
6936 }
6937 [] T.timeout {
6938 setverdict(fail, "timout waiting for RR CHANNEL RELEASE!");
6939 }
6940 }
6941}
6942
6943/* EMERGENCY CALL situation #1, allowed globally and by BTS */
6944testcase TC_assignment_emerg_setup_allow() runs on test_CT {
6945 var TestHdlrParams pars := f_gen_test_hdlr_pars();
6946 var MSC_ConnHdlr vc_conn;
6947
6948 f_init(1, true);
6949 f_sleep(1.0);
6950
6951 f_vty_allow_emerg_msc(true);
6952 f_vty_allow_emerg_bts(true, 0);
6953 vc_conn := f_start_handler(refers(f_TC_assignment_emerg_setup_allow), pars);
6954 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006955 f_shutdown_helper();
Philipp Maier783681c2020-07-16 16:47:06 +02006956}
6957
6958/* EMERGENCY CALL situation #2, forbidden globally but allowed by BTS */
6959testcase TC_assignment_emerg_setup_deny_msc() runs on test_CT {
6960 var TestHdlrParams pars := f_gen_test_hdlr_pars();
6961 var MSC_ConnHdlr vc_conn;
6962
6963 f_init(1, true);
6964 f_sleep(1.0);
6965
6966 f_vty_allow_emerg_msc(false);
6967 f_vty_allow_emerg_bts(true, 0);
6968 vc_conn := f_start_handler(refers(f_TC_assignment_emerg_setup_deny), pars);
6969 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006970 f_shutdown_helper();
Philipp Maier783681c2020-07-16 16:47:06 +02006971}
6972
6973/* EMERGENCY CALL situation #3, allowed globally but forbidden by BTS */
6974testcase TC_assignment_emerg_setup_deny_bts() runs on test_CT {
6975 var TestHdlrParams pars := f_gen_test_hdlr_pars();
6976 var MSC_ConnHdlr vc_conn;
6977
6978 /* Note: This simulates a spec violation by the MS, correct MS
6979 * implementations would not try to establish an emergency call because
6980 * the system information tells in advance that emergency calls are
6981 * not forbidden */
6982
6983 f_init(1, true);
6984 f_sleep(1.0);
6985
6986 f_vty_allow_emerg_msc(true);
6987 f_vty_allow_emerg_bts(false, 0);
6988 vc_conn := f_start_handler(refers(f_TC_assignment_emerg_setup_deny), pars);
6989 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006990 f_shutdown_helper();
Philipp Maier783681c2020-07-16 16:47:06 +02006991}
6992
Philipp Maier82812002020-08-13 18:48:27 +02006993/* Test what happens when an emergency call arrives while all TCH channels are
6994 * busy, the BSC is expected to terminate one call in favor of the incoming
6995 * emergency call */
6996testcase TC_emerg_premption() runs on test_CT {
6997 var ASP_RSL_Unitdata rsl_ud;
6998 var integer i;
6999 var integer chreq_total, chreq_nochan;
7000 var RSL_Message rx_rsl;
7001 var RslChannelNr chan_nr;
7002
7003 f_init(1);
7004 f_sleep(1.0);
7005
7006 f_vty_allow_emerg_msc(true);
7007 f_vty_allow_emerg_bts(true, 0);
7008
7009 /* Fill up all channels on the BTS */
7010 chreq_total := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total");
7011 chreq_nochan := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:no_channel");
7012 for (i := 0; i < NUM_TCHF_PER_BTS + NUM_TCHH_PER_BTS + NUM_SDCCH_PER_BTS; i := i+1) {
7013 chan_nr := f_chreq_act_ack('33'O, i);
7014 }
7015 IPA_RSL[0].clear;
7016 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total",
7017 chreq_total + NUM_TCHF_PER_BTS + NUM_TCHH_PER_BTS + NUM_SDCCH_PER_BTS);
7018
7019 /* Send Channel request for emegergency call */
7020 f_ipa_tx(0, ts_RSL_CHAN_RQD('A5'O, 23));
7021
7022 /* Expect the BSC to release one (the first) TCH/F on the BTS */
7023 chan_nr := valueof(t_RslChanNr_Bm(1));
7024 f_expect_chan_rel(0, chan_nr, expect_rr_chan_rel := false, expect_rll_rel_req := false);
7025
7026 /* Expect the BSC to send activate/assign the a channel for the emergency call */
7027 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
7028 chan_nr := rx_rsl.ies[0].body.chan_nr;
7029 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, 33));
7030 rx_rsl := f_exp_ipa_rx(0, tr_RSL_IMM_ASSIGN(0));
Philipp Maier104f4c02020-09-11 18:12:18 +02007031
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007032 f_shutdown_helper();
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007033}
7034
7035/* Hopping parameters per a timeslot */
Vadim Yanitskiybc6654a2020-09-13 01:27:40 +07007036private type record length(0..64) of GsmArfcn ArfcnList;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007037private type record FHParamsTs {
7038 boolean enabled,
7039 uint6_t hsn,
7040 uint6_t maio,
7041 ArfcnList ma
7042};
7043
7044/* Hopping parameters per a transceiver */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007045private type record FHParamsTrx {
7046 GsmArfcn arfcn,
7047 FHParamsTs ts[8]
7048};
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007049
7050/* Randomly generate the hopping parameters for the given timeslot numbers */
7051private function f_TC_fh_params_gen(template integer tr_tn := (1, 3, 5))
7052runs on test_CT return FHParamsTrx {
7053 var FHParamsTrx fhp;
7054
Vadim Yanitskiy3e997362020-09-05 21:08:34 +07007055 /* Generate a random ARFCN, including ARFCN 0 */
7056 fhp.arfcn := f_rnd_int(3);
Vadim Yanitskiye7c8c6e2020-09-13 14:33:03 +07007057
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007058 for (var integer tn := 0; tn < 8; tn := tn + 1) {
7059 if (not match(tn, tr_tn)) {
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007060 fhp.ts[tn].enabled := false;
7061 fhp.ts[tn].ma := { };
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007062 continue;
7063 }
7064
7065 /* Random HSN / MAIO values: 0..63 */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007066 fhp.ts[tn].hsn := f_rnd_int(64);
7067 fhp.ts[tn].maio := f_rnd_int(64);
7068 fhp.ts[tn].ma := { };
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007069
7070 /* Random Mobile Allocation (hopping channels) */
7071 var integer ma_len := 2 + f_rnd_int(9); /* 2..10 channels */
7072 var integer step := 3 + f_rnd_int(4); /* 3..6 stepping */
7073 for (var integer i := 1; i <= ma_len; i := i + 1) {
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007074 fhp.ts[tn].ma := fhp.ts[tn].ma & { i * step };
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007075 }
7076
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007077 fhp.ts[tn].enabled := true;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007078 }
7079
7080 log("f_TC_fh_params_gen(): ", fhp);
7081 return fhp;
7082}
7083
7084/* Make sure that the given Channel Description IE matches the hopping configuration */
7085private function f_TC_fh_params_match_chan_desc(in FHParamsTrx fhp, in ChannelDescription cd)
7086{
7087 var template (present) ChannelDescription tr_cd;
7088 var template (present) MaioHsn tr_maio_hsn;
7089 var uint3_t tn := cd.chan_nr.tn;
7090
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007091 if (fhp.ts[tn].enabled) {
7092 tr_maio_hsn := tr_HsnMaio(fhp.ts[tn].hsn, fhp.ts[tn].maio);
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007093 tr_cd := tr_ChanDescH1(cd.chan_nr, tr_maio_hsn);
7094 } else {
Vadim Yanitskiye7c8c6e2020-09-13 14:33:03 +07007095 tr_cd := tr_ChanDescH0(cd.chan_nr, fhp.arfcn);
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007096 }
7097
7098 if (not match(cd, tr_cd)) {
7099 setverdict(fail, "Channel Description IE does not match: ",
7100 cd, " vs expected ", tr_cd);
7101 }
7102}
7103
7104/* Make sure that the given Mobile Allocation IE matches the hopping configuration */
7105private function f_TC_fh_params_match_ma(in FHParamsTrx fhp, uint3_t tn,
7106 in MobileAllocationLV ma)
7107{
7108 var template MobileAllocationLV tr_ma := f_TC_fh_params_gen_tr_ma(fhp, tn, ma);
7109
7110 if (not match(ma, tr_ma)) {
7111 setverdict(fail, "Mobile Allocation IE does not match (tn := ",
7112 tn, "): ", ma, " vs expected: ", tr_ma);
7113 } else {
7114 setverdict(pass);
7115 }
7116}
7117
7118private function f_TC_fh_params_gen_tr_ma(in FHParamsTrx fhp, uint3_t tn,
7119 in MobileAllocationLV ma)
7120return template MobileAllocationLV {
7121 /* Mobile Allocation IE is expected to be empty if hopping is not enabled */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007122 if (not fhp.ts[tn].enabled) {
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007123 return { len := 0, ma := ''B };
7124 }
7125
7126 var bitstring full_mask := f_pad_bit(''B, 1024, '0'B);
7127 var bitstring slot_mask := f_pad_bit(''B, 1024, '0'B);
7128 var bitstring ma_mask := ''B;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007129
7130 /* Compose the full bit-mask (all channels, up to 1024 entries) */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007131 for (var integer i := 0; i < lengthof(fhp.ts); i := i + 1) {
7132 for (var integer j := 0; j < lengthof(fhp.ts[i].ma); j := j + 1) {
7133 if (full_mask[fhp.ts[i].ma[j]] == '1'B)
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007134 { continue; }
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007135 full_mask[fhp.ts[i].ma[j]] := '1'B;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007136 }
7137 }
7138
Vadim Yanitskiye7c8c6e2020-09-13 14:33:03 +07007139 /* Take ARFCN of the TRX itself into account */
7140 full_mask[fhp.arfcn] := '1'B;
7141
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007142 /* Compose a bit-mask for the given timeslot number */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007143 for (var integer i := 0; i < lengthof(fhp.ts[tn].ma); i := i + 1) {
7144 slot_mask[fhp.ts[tn].ma[i]] := '1'B;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007145 }
7146
7147 /* Finally, compose the Mobile Allocation bit-mask */
Vadim Yanitskiy3e997362020-09-05 21:08:34 +07007148 for (var integer i := 1; i < lengthof(full_mask); i := i + 1) {
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007149 if (full_mask[i] != '1'B)
7150 { continue; }
7151
7152 /* FIXME: ma_mask := ma_mask & slot_mask[i]; // triggers a bug in TITAN */
7153 if (slot_mask[i] == '1'B) {
7154 ma_mask := ma_mask & '1'B;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007155 } else {
7156 ma_mask := ma_mask & '0'B;
7157 }
7158 }
7159
Vadim Yanitskiy3e997362020-09-05 21:08:34 +07007160 /* ARFCN 0 (if present) goes to the last position of the bit-mask */
7161 if (full_mask[0] == '1'B) {
7162 /* FIXME: ma_mask := ma_mask & slot_mask[0]; // triggers a bug in TITAN */
7163 if (slot_mask[0] == '1'B) {
7164 ma_mask := ma_mask & '1'B;
7165 } else {
7166 ma_mask := ma_mask & '0'B;
7167 }
7168 }
7169
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007170 /* Ensure that ma_mask is octet-aligned */
Vadim Yanitskiy2aa02522020-09-06 14:05:23 +07007171 var integer ma_mask_len := (lengthof(ma_mask) + 8 - 1) / 8;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007172 ma_mask := f_pad_bit(ma_mask, ma_mask_len * 8, '0'B);
7173
7174 return { len := ma_mask_len, ma := ma_mask };
7175}
7176
7177/* Configure the hopping parameters in accordance with the given record */
7178private function f_TC_fh_params_set(in FHParamsTrx fhp,
7179 uint8_t bts_nr := 0,
7180 uint8_t trx_nr := 0)
7181runs on test_CT {
7182 /* Enter the configuration node for the given BTS/TRX numbers */
7183 f_vty_enter_cfg_trx(BSCVTY, bts_nr, trx_nr);
7184
Vadim Yanitskiye7c8c6e2020-09-13 14:33:03 +07007185 f_vty_transceive(BSCVTY, "arfcn " & int2str(fhp.arfcn));
7186
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007187 for (var integer tn := 0; tn < lengthof(fhp.ts); tn := tn + 1) {
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007188 f_vty_transceive(BSCVTY, "timeslot " & int2str(tn));
7189
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007190 if (not fhp.ts[tn].enabled) {
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007191 f_vty_transceive(BSCVTY, "hopping enabled 0");
7192 f_vty_transceive(BSCVTY, "exit"); /* go back */
7193 continue;
7194 }
7195
7196 /* Configure HSN / MAIO values */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007197 f_vty_transceive(BSCVTY, "hopping sequence-number " & int2str(fhp.ts[tn].hsn));
7198 f_vty_transceive(BSCVTY, "hopping maio " & int2str(fhp.ts[tn].maio));
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007199
7200 /* Configure the Mobile Allocation (hopping channels) */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007201 for (var integer i := 0; i < lengthof(fhp.ts[tn].ma); i := i + 1) {
7202 f_vty_transceive(BSCVTY, "hopping arfcn add " & int2str(fhp.ts[tn].ma[i]));
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007203 }
7204
7205 f_vty_transceive(BSCVTY, "hopping enabled 1");
7206 f_vty_transceive(BSCVTY, "exit"); /* go back */
7207 }
7208
7209 f_vty_transceive(BSCVTY, "end");
7210}
7211
7212/* Disable frequency hopping on all timeslots */
7213private function f_TC_fh_params_unset(in FHParamsTrx fhp,
7214 uint8_t bts_nr := 0,
Vadim Yanitskiye7c8c6e2020-09-13 14:33:03 +07007215 uint8_t trx_nr := 0,
7216 GsmArfcn arfcn := 871)
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007217runs on test_CT {
7218 /* Enter the configuration node for the given BTS/TRX numbers */
7219 f_vty_enter_cfg_trx(BSCVTY, bts_nr, trx_nr);
7220
Vadim Yanitskiye7c8c6e2020-09-13 14:33:03 +07007221 f_vty_transceive(BSCVTY, "arfcn " & int2str(arfcn));
7222
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007223 for (var integer tn := 0; tn < lengthof(fhp.ts); tn := tn + 1) {
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007224 f_vty_transceive(BSCVTY, "timeslot " & int2str(tn));
7225
7226 /* Delete all ARFCNs from the Mobile Allocation (if any) */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007227 for (var integer i := 0; i < lengthof(fhp.ts[tn].ma); i := i + 1) {
7228 f_vty_transceive(BSCVTY, "hopping arfcn del " & int2str(fhp.ts[tn].ma[i]));
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007229 }
7230
7231 f_vty_transceive(BSCVTY, "hopping enabled 0");
7232 f_vty_transceive(BSCVTY, "exit"); /* go back */
7233 }
7234
7235 f_vty_transceive(BSCVTY, "end");
7236 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
7237}
7238
7239/* Verify presence and correctness of the hopping parameters (HSN, MAIO)
7240 * in the Channel Identification IE of the RSL CHANnel ACTIVation message. */
7241testcase TC_fh_params_chan_activ() runs on test_CT {
7242 var FHParamsTrx fhp := f_TC_fh_params_gen();
7243 var RSL_Message rsl_msg;
7244 var RSL_IE_Body ie;
7245
7246 f_init_vty();
7247
7248 f_TC_fh_params_set(fhp); /* Enable frequency hopping */
7249 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
7250
7251 f_init(1);
7252
7253 /* CS domain: 3 (SDCCH/4+CBCH) + 4 (TCH/F) + 2 (TCH/H) channels available */
7254 for (var integer i := 0; i < 9; i := i + 1) {
7255 f_ipa_tx(0, ts_RSL_CHAN_RQD(f_rnd_ra_cs(), 23));
7256 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
7257
7258 /* Make sure that Channel Identification IE is present */
7259 if (not f_rsl_find_ie(rsl_msg, RSL_IE_CHAN_IDENT, ie)) {
7260 setverdict(fail, "RSL Channel Identification IE is absent");
7261 continue;
7262 }
7263
7264 /* Make sure that hopping parameters (HSN/MAIO) match */
7265 f_TC_fh_params_match_chan_desc(fhp, ie.chan_ident.ch_desc.v);
7266
7267 /* "Mobile Allocation shall be included but empty" - let's check this */
7268 if (ie.chan_ident.ma.v.len != 0) {
7269 setverdict(fail, "Mobile Allocation IE is not empty: ",
7270 ie.chan_ident.ma, ", despite it shall be");
7271 continue;
7272 }
7273 }
7274
7275 /* Disable frequency hopping */
7276 f_TC_fh_params_unset(fhp);
7277
Vadim Yanitskiy21726312020-09-04 01:45:36 +07007278 f_shutdown_helper();
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007279}
7280
7281/* Verify the hopping parameters (HSN, MAIO, MA) in (RR) Immediate Assignment */
7282testcase TC_fh_params_imm_ass() runs on test_CT {
7283 var FHParamsTrx fhp := f_TC_fh_params_gen();
7284 var RSL_Message rsl_msg;
7285 var RSL_IE_Body ie;
7286
7287 f_init_vty();
7288
7289 f_TC_fh_params_set(fhp); /* Enable frequency hopping */
7290 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
7291
7292 f_init(1);
7293
7294 /* CS domain: 3 (SDCCH/4+CBCH) + 4 (TCH/F) + 2 (TCH/H) channels available */
7295 for (var integer i := 0; i < 9; i := i + 1) {
7296 f_ipa_tx(0, ts_RSL_CHAN_RQD(f_rnd_ra_cs(), 23));
7297 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
7298
7299 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(rsl_msg.ies[0].body.chan_nr, 33));
7300 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeC(RSL_MT_IMMEDIATE_ASSIGN_CMD));
7301
7302 /* Make sure that Full Immediate Assign Info IE is present */
7303 if (not f_rsl_find_ie(rsl_msg, RSL_IE_FULL_IMM_ASS_INFO, ie)) {
7304 setverdict(fail, "RSL Full Immediate Assign Info IE is absent");
7305 continue;
7306 }
7307
7308 /* Decode the actual Immediate Assignment message */
7309 var GsmRrMessage rr_msg := dec_GsmRrMessage(ie.full_imm_ass_info.payload);
7310 if (not match(rr_msg.header, t_RrHeader(IMMEDIATE_ASSIGNMENT, ?))) {
7311 setverdict(fail, "Failed to match Immediate Assignment: ", rr_msg);
7312 continue;
7313 }
7314
7315 /* Make sure that hopping parameters (HSN/MAIO) match */
7316 f_TC_fh_params_match_chan_desc(fhp, rr_msg.payload.imm_ass.chan_desc);
7317
7318 /* Make sure that the Mobile Allocation IE matches */
7319 f_TC_fh_params_match_ma(fhp, rr_msg.payload.imm_ass.chan_desc.chan_nr.tn,
7320 rr_msg.payload.imm_ass.mobile_allocation);
7321 }
7322
7323 /* Disable frequency hopping */
7324 f_TC_fh_params_unset(fhp);
Philipp Maier82812002020-08-13 18:48:27 +02007325
Vadim Yanitskiy21726312020-09-04 01:45:36 +07007326 f_shutdown_helper();
Philipp Maier82812002020-08-13 18:48:27 +02007327}
7328
Vadim Yanitskiyaeb54a22020-09-01 06:25:25 +07007329/* Verify the hopping parameters (HSN, MAIO, MA) in (RR) Assignment Command */
7330testcase TC_fh_params_assignment_cmd() runs on test_CT {
7331 var FHParamsTrx fhp := f_TC_fh_params_gen();
7332 var RSL_Message rsl_msg;
7333 var RSL_IE_Body ie;
7334
7335 f_init_vty();
7336
7337 f_TC_fh_params_set(fhp); /* Enable frequency hopping */
7338 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
7339
7340 f_init(1);
7341
7342 /* HACK: work around "Couldn't find Expect for CRCX" */
7343 vc_MGCP.stop;
7344
7345 var template PDU_BSSAP ass_cmd := f_gen_ass_req();
7346 ass_cmd.pdu.bssmap.assignmentRequest.codecList := ts_BSSMAP_IE_CodecList({ts_CodecFR});
7347
7348 /* CS domain (TCH): 4 (TCH/F) + 2 (TCH/H) channels available
7349 * NOTE: only 3 SDCCH/4 channels are available on CCCH+SDCCH4+CBCH */
7350 for (var integer i := 0; i < 3; i := i + 1) {
7351 /* Establish a dedicated channel, so we can trigger (late) TCH assignment */
7352 var DchanTuple dt := f_est_dchan(f_rnd_ra_cs(), 23, f_rnd_octstring(16));
7353
7354 /* Send a BSSMAP Assignment Command, expect CHANnel ACTIVation */
7355 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ass_cmd));
7356 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
7357
7358 /* ACKnowledge CHANnel ACTIVation, expect RSL DATA REQuest */
7359 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(rsl_msg.ies[0].body.chan_nr, 33));
7360 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeR(RSL_MT_DATA_REQ));
7361
7362 /* Make sure that L3 Information IE is present */
7363 if (not f_rsl_find_ie(rsl_msg, RSL_IE_L3_INFO, ie)) {
7364 setverdict(fail, "RSL L3 Information IE is absent");
7365 continue;
7366 }
7367
7368 /* Decode the L3 message and make sure it is (RR) Assignment Command */
7369 var GsmRrL3Message l3_msg := dec_GsmRrL3Message(ie.l3_info.payload);
7370 if (not match(l3_msg.header, t_RrL3Header(ASSIGNMENT_COMMAND))) {
7371 setverdict(fail, "Failed to match Assignment Command: ", l3_msg);
7372 continue;
7373 }
7374
7375 /* Make sure that hopping parameters (HSN/MAIO) match */
7376 var ChannelDescription chan_desc := l3_msg.payload.ass_cmd.chan_desc;
7377 f_TC_fh_params_match_chan_desc(fhp, chan_desc);
7378
7379 /* Make sure that Cell Channel Description IE is present if FH is enabled */
7380 if (chan_desc.h and not ispresent(l3_msg.payload.ass_cmd.cell_chan_desc)) {
Vadim Yanitskiy38d069d2020-09-02 17:18:57 +07007381 setverdict(fail, "FH enabled, but Cell Channel Description IE is absent");
Vadim Yanitskiyaeb54a22020-09-01 06:25:25 +07007382 continue;
7383 }
7384
7385 /* Make sure that the Mobile Allocation IE matches (if present) */
7386 var boolean ma_present := ispresent(l3_msg.payload.ass_cmd.mobile_allocation);
7387 if (chan_desc.h and ma_present) {
7388 f_TC_fh_params_match_ma(fhp, chan_desc.chan_nr.tn,
7389 l3_msg.payload.ass_cmd.mobile_allocation.v);
7390 } else if (chan_desc.h and not ma_present) {
7391 setverdict(fail, "FH enabled, but Mobile Allocation IE is absent");
7392 continue;
7393 } else if (not chan_desc.h and ma_present) {
7394 setverdict(fail, "FH disabled, but Mobile Allocation IE is present");
7395 continue;
7396 }
7397 }
7398
7399 /* Give the IUT some time to release all channels */
7400 f_sleep(3.0);
7401
7402 /* Disable frequency hopping */
7403 f_TC_fh_params_unset(fhp);
7404
Vadim Yanitskiy21726312020-09-04 01:45:36 +07007405 f_shutdown_helper();
Vadim Yanitskiyaeb54a22020-09-01 06:25:25 +07007406}
7407
Vadim Yanitskiy8f5430d2020-09-02 18:51:38 +07007408/* Verify the hopping parameters (HSN, MAIO, MA) in (RR) Handover Command */
7409private function f_TC_fh_params_handover_cmd(in FHParamsTrx fhp)
7410runs on test_CT {
7411 var RSL_Message rsl_msg;
7412 var RSL_IE_Body ie;
7413 var DchanTuple dt;
7414
7415 /* Establish a dedicated channel, so we can trigger handover */
7416 dt := f_est_dchan(f_rnd_ra_cs(), 23, f_rnd_octstring(16));
7417
7418 /* Trigger handover from BTS0 to BTS1 */
7419 f_bts_0_cfg(BSCVTY, { "neighbor bts 1" });
7420 f_vty_handover(BSCVTY, 0, 0, dt.rsl_chan_nr, 1);
7421
7422 /* Expect RSL CHANnel ACTIVation on BTS1/TRX0/TS1 */
7423 rsl_msg := f_exp_ipa_rx(1, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
7424
7425 /* ACKnowledge channel activation and expect (RR) Handover Command */
7426 f_ipa_tx(1, ts_RSL_CHAN_ACT_ACK(rsl_msg.ies[0].body.chan_nr, 33));
7427 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeR(RSL_MT_DATA_REQ));
7428
7429 /* Make sure that L3 Information IE is present */
7430 if (not f_rsl_find_ie(rsl_msg, RSL_IE_L3_INFO, ie)) {
7431 setverdict(fail, "RSL L3 Information IE is absent");
7432 return;
7433 }
7434
7435 /* Decode the L3 message and make sure it is (RR) Handover Command */
7436 var GsmRrL3Message l3_msg := dec_GsmRrL3Message(ie.l3_info.payload);
7437 if (not match(l3_msg.header, t_RrL3Header(HANDOVER_COMMAND))) {
7438 setverdict(fail, "Failed to match Handover Command: ", l3_msg);
7439 return;
7440 }
7441
7442 /* Make sure that we've got SDCCH/8 on TS1 (expected to be hopping) */
7443 var ChannelDescription chan_desc := l3_msg.payload.ho_cmd.chan_desc;
7444 if (not match(chan_desc.chan_nr, t_RslChanNr_SDCCH8(1, ?))) {
7445 setverdict(fail, "Unexpected channel number: ", chan_desc.chan_nr);
7446 return;
7447 }
7448
7449 /* Make sure that hopping parameters (HSN/MAIO) match */
7450 f_TC_fh_params_match_chan_desc(fhp, chan_desc);
7451
7452 /* Make sure that Cell Channel Description IE is present */
7453 if (not ispresent(l3_msg.payload.ho_cmd.cell_chan_desc)) {
7454 setverdict(fail, "FH enabled, but Cell Channel Description IE is absent");
7455 return;
7456 }
7457
7458 /* Make sure that the Mobile Allocation (after time) IE is present and matches */
7459 var boolean ma_present := ispresent(l3_msg.payload.ho_cmd.mobile_allocation);
7460 if (ma_present) {
7461 f_TC_fh_params_match_ma(fhp, chan_desc.chan_nr.tn,
7462 l3_msg.payload.ho_cmd.mobile_allocation.v);
7463 } else {
7464 setverdict(fail, "FH enabled, but Mobile Allocation IE is absent");
7465 return;
7466 }
7467}
7468testcase TC_fh_params_handover_cmd() runs on test_CT {
7469 var FHParamsTrx fhp := f_TC_fh_params_gen();
7470
7471 f_init_vty();
7472
7473 /* (Re)configure TS0 as BCCH and TS1 as SDCCH8 on BTS1/TRX0 */
7474 f_vty_enter_cfg_trx(BSCVTY, bts := 1, trx := 0);
7475
7476 f_vty_transceive(BSCVTY, "timeslot 0");
7477 f_vty_transceive(BSCVTY, "phys_chan_config ccch");
7478 f_vty_transceive(BSCVTY, "exit"); /* go back */
7479
7480 f_vty_transceive(BSCVTY, "timeslot 1");
7481 f_vty_transceive(BSCVTY, "phys_chan_config sdcch8");
7482 f_vty_transceive(BSCVTY, "end"); /* we're done */
7483
7484 f_TC_fh_params_set(fhp, 1); /* Enable frequency hopping on BTS1 */
7485 f_vty_transceive(BSCVTY, "drop bts connection 1 oml");
7486
7487 f_init(2);
7488
7489 f_TC_fh_params_handover_cmd(fhp);
7490
7491 /* Disable frequency hopping on BTS1 */
7492 f_TC_fh_params_unset(fhp, 1);
7493
7494 /* (Re)configure TS0 as CCCH+SDCCH4+CBCH and TS1 as TCH/F */
7495 f_vty_enter_cfg_trx(BSCVTY, bts := 1, trx := 0);
7496
7497 f_vty_transceive(BSCVTY, "timeslot 0");
7498 f_vty_transceive(BSCVTY, "phys_chan_config ccch+sdcch4+cbch");
7499 f_vty_transceive(BSCVTY, "exit"); /* go back */
7500
7501 f_vty_transceive(BSCVTY, "timeslot 1");
7502 f_vty_transceive(BSCVTY, "phys_chan_config tch/f");
7503 f_vty_transceive(BSCVTY, "end"); /* we're done */
7504
7505 f_shutdown_helper();
7506}
7507
Vadim Yanitskiyca974032020-09-01 07:20:39 +07007508/* Verify the hopping parameters in System Information Type 4 */
7509testcase TC_fh_params_si4_cbch() runs on test_CT {
7510 var FHParamsTrx fhp := f_TC_fh_params_gen(tr_tn := 1);
7511 var ASP_RSL_Unitdata rx_rsl_ud;
7512 timer T := 5.0;
7513
7514 f_init_vty();
7515
7516 /* (Re)configure TS0 as BCCH and TS1 as SDCCH8+CBCH */
7517 f_vty_enter_cfg_trx(BSCVTY, trx := 0);
7518
7519 f_vty_transceive(BSCVTY, "timeslot 0");
7520 f_vty_transceive(BSCVTY, "phys_chan_config ccch");
7521 f_vty_transceive(BSCVTY, "exit"); /* go back */
7522
7523 f_vty_transceive(BSCVTY, "timeslot 1");
7524 f_vty_transceive(BSCVTY, "phys_chan_config sdcch8+cbch");
7525 f_vty_transceive(BSCVTY, "end"); /* we're done */
7526
7527 f_TC_fh_params_set(fhp); /* Enable frequency hopping */
7528 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
7529
7530 f_init(1);
7531
7532 T.start;
7533 alt {
7534 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_BCCH_INFO(RSL_SYSTEM_INFO_4))) -> value rx_rsl_ud {
7535 var RSL_IE_Body ie := rx_rsl_ud.rsl.ies[2].body; /* FULL BCCH Information IE */
7536 var SystemInformation si := dec_SystemInformation(ie.other.payload);
7537
7538 /* Make sure that what we decoded is System Information Type 4 */
7539 if (si.header.message_type != SYSTEM_INFORMATION_TYPE_4) {
7540 setverdict(fail, "RSL FULL BCCH Information IE contains: ", si);
7541 repeat;
7542 }
7543
7544 /* Make sure that CBCH Channel Description IE is present */
7545 if (not ispresent(si.payload.si4.cbch_chan_desc)) {
7546 setverdict(fail, "CBCH Channel Description IE is absent");
7547 break;
7548 }
7549
7550 /* Finally, check the hopping parameters (HSN, MAIO) */
7551 var ChannelDescription chan_desc := si.payload.si4.cbch_chan_desc.v;
7552 f_TC_fh_params_match_chan_desc(fhp, chan_desc);
7553
7554 /* 3GPP TS 44.018, section 9.1.36.2 "CBCH Mobile Allocation":
7555 * The CBCH Mobile Allocation IE *shall* be present if FH is enabled. */
7556 if (chan_desc.h and not ispresent(si.payload.si4.cbch_mobile_alloc)) {
7557 setverdict(fail, "FH enabled, but Mobile Allocation IE is absent");
7558 break;
7559 } else if (chan_desc.h and ispresent(si.payload.si4.cbch_mobile_alloc)) {
7560 f_TC_fh_params_match_ma(fhp, chan_desc.chan_nr.tn,
7561 si.payload.si4.cbch_mobile_alloc.v);
7562 }
7563 }
7564 [] IPA_RSL[0].receive { repeat; }
7565 [] T.timeout {
7566 setverdict(fail, "Timeout waiting for RSL BCCH INFOrmation (SI4)");
7567 }
7568 }
7569
7570 /* Disable frequency hopping */
7571 f_TC_fh_params_unset(fhp);
7572
Vadim Yanitskiy8bc46012020-09-06 12:38:01 +07007573 /* (Re)configure TS0 as CCCH+SDCCH4+CBCH and TS1 as TCH/F */
Vadim Yanitskiyca974032020-09-01 07:20:39 +07007574 f_vty_enter_cfg_trx(BSCVTY, trx := 0);
7575
7576 f_vty_transceive(BSCVTY, "timeslot 0");
Vadim Yanitskiy8bc46012020-09-06 12:38:01 +07007577 f_vty_transceive(BSCVTY, "phys_chan_config ccch+sdcch4+cbch");
Vadim Yanitskiyca974032020-09-01 07:20:39 +07007578 f_vty_transceive(BSCVTY, "exit"); /* go back */
7579
7580 f_vty_transceive(BSCVTY, "timeslot 1");
7581 f_vty_transceive(BSCVTY, "phys_chan_config tch/f");
7582 f_vty_transceive(BSCVTY, "end"); /* we're done */
7583
Vadim Yanitskiy21726312020-09-04 01:45:36 +07007584 f_shutdown_helper();
Vadim Yanitskiyca974032020-09-01 07:20:39 +07007585}
7586
Harald Welte0ea2d5e2018-04-07 21:40:29 +02007587/* Dyn PDCH todo:
7588 * activate OSMO as TCH/F
7589 * activate OSMO as TCH/H
7590 * does the BSC-located PCU socket get the updated INFO?
7591 * what if no PCU is connected at the time?
7592 * is the info correct on delayed PCU (re)connect?
7593 */
Harald Welte94e0c342018-04-07 11:33:23 +02007594
Harald Welte28d943e2017-11-25 15:00:50 +01007595control {
Harald Welte898113b2018-01-31 18:32:21 +01007596 /* CTRL interface testing */
Harald Welte4003d112017-12-09 22:35:39 +01007597 execute( TC_ctrl_msc_connection_status() );
Stefan Sperlingb041b3d2018-01-03 17:14:55 +01007598 execute( TC_ctrl_msc0_connection_status() );
Harald Welte96c94412017-12-09 03:12:45 +01007599 execute( TC_ctrl() );
Neels Hofmeyrf246a922020-05-13 02:27:10 +02007600 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_SCCPlite_SERVER) {
Pau Espin Pedrol5a2d7432019-06-07 19:43:45 +02007601 execute( TC_ctrl_location() );
7602 }
Harald Welte898113b2018-01-31 18:32:21 +01007603
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +02007604 execute( TC_si_default() );
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02007605 execute( TC_si2quater_2_earfcns() );
7606 execute( TC_si2quater_3_earfcns() );
7607 execute( TC_si2quater_4_earfcns() );
7608 execute( TC_si2quater_5_earfcns() );
7609 execute( TC_si2quater_6_earfcns() );
Neels Hofmeyrad132f22020-07-08 02:20:16 +02007610 execute( TC_si2quater_12_earfcns() );
7611 execute( TC_si2quater_23_earfcns() );
7612 execute( TC_si2quater_32_earfcns() );
7613 execute( TC_si2quater_33_earfcns() );
7614 execute( TC_si2quater_42_earfcns() );
7615 execute( TC_si2quater_48_earfcns() );
7616 execute( TC_si2quater_49_earfcns() );
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02007617 execute( TC_si_acc_rotate() );
Alexander Couzens4ad3a352020-09-10 22:29:12 +02007618 execute( TC_si_acc_ramp_rotate() );
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +02007619
Harald Welte898113b2018-01-31 18:32:21 +01007620 /* RSL DCHAN Channel ACtivation / Deactivation */
Harald Welteae026692017-12-09 01:03:01 +01007621 execute( TC_chan_act_noreply() );
Harald Welte4003d112017-12-09 22:35:39 +01007622 execute( TC_chan_act_counter() );
Harald Welteae026692017-12-09 01:03:01 +01007623 execute( TC_chan_act_ack_noest() );
Philipp Maier9c60a622020-07-09 15:08:46 +02007624 execute( TC_chan_act_ack_noest_emerg() );
Philipp Maier606f07d2020-08-12 17:21:58 +02007625 execute( TC_chan_rqd_emerg_deny() );
Harald Welteae026692017-12-09 01:03:01 +01007626 execute( TC_chan_act_ack_est_ind_noreply() );
7627 execute( TC_chan_act_ack_est_ind_refused() );
Harald Welte618ef642017-12-14 14:58:20 +01007628 execute( TC_chan_act_nack() );
Harald Welte799c97b2017-12-14 17:50:30 +01007629 execute( TC_chan_exhaustion() );
Vadim Yanitskiy1ff1fdf2018-11-27 01:32:57 +07007630 execute( TC_chan_deact_silence() );
Harald Welte4003d112017-12-09 22:35:39 +01007631 execute( TC_chan_rel_rll_rel_ind() );
7632 execute( TC_chan_rel_conn_fail() );
7633 execute( TC_chan_rel_hard_clear() );
Harald Welte99787102019-02-04 10:41:36 +01007634 execute( TC_chan_rel_hard_clear_csfb() );
Harald Welted8c36cd2017-12-09 23:05:31 +01007635 execute( TC_chan_rel_hard_rlsd() );
Harald Welte550daf92018-06-11 19:22:13 +02007636 execute( TC_chan_rel_hard_rlsd_ms_dead() );
Harald Welte85804d42017-12-10 14:11:58 +01007637 execute( TC_chan_rel_a_reset() );
Pau Espin Pedrolc675b612020-01-09 19:55:40 +01007638 execute( TC_chan_rel_sccp_tiar_timeout() );
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02007639 execute( TC_chan_rel_rr_cause() );
Harald Welte6f521d82017-12-11 19:52:02 +01007640
Harald Weltecfe2c962017-12-15 12:09:32 +01007641 execute( TC_outbound_connect() );
Harald Welte898113b2018-01-31 18:32:21 +01007642
7643 /* Assignment related */
Harald Welte16a4adf2017-12-14 18:54:01 +01007644 execute( TC_assignment_cic_only() );
Harald Welte235ebf12017-12-15 14:18:16 +01007645 execute( TC_assignment_csd() );
7646 execute( TC_assignment_ctm() );
7647 execute( TC_assignment_sign() );
Pau Espin Pedrol07866632020-09-03 19:10:55 +02007648 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
7649 execute( TC_assignment_aoip_tla_v6() );
7650 }
Harald Welte235ebf12017-12-15 14:18:16 +01007651 execute( TC_assignment_fr_a5_0() );
7652 execute( TC_assignment_fr_a5_1() );
Neels Hofmeyrf246a922020-05-13 02:27:10 +02007653 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
Harald Welte8f67d1d2018-05-25 20:38:42 +02007654 execute( TC_assignment_fr_a5_1_codec_missing() );
7655 }
Harald Welte235ebf12017-12-15 14:18:16 +01007656 execute( TC_assignment_fr_a5_3() );
7657 execute( TC_assignment_fr_a5_4() );
Harald Welte3c86ea02018-05-10 22:28:05 +02007658 execute( TC_ciph_mode_a5_0() );
7659 execute( TC_ciph_mode_a5_1() );
7660 execute( TC_ciph_mode_a5_3() );
Harald Welte16a4adf2017-12-14 18:54:01 +01007661
Harald Welte60aa5762018-03-21 19:33:13 +01007662 execute( TC_assignment_codec_fr() );
7663 execute( TC_assignment_codec_hr() );
7664 execute( TC_assignment_codec_efr() );
7665 execute( TC_assignment_codec_amr_f() );
7666 execute( TC_assignment_codec_amr_h() );
Philipp Maier8a581d22019-03-26 18:32:48 +01007667
Neels Hofmeyrf246a922020-05-13 02:27:10 +02007668 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
Philipp Maier8a581d22019-03-26 18:32:48 +01007669 execute( TC_assignment_codec_amr_f_S1() );
7670 execute( TC_assignment_codec_amr_h_S1() );
7671 execute( TC_assignment_codec_amr_f_S124() );
7672 execute( TC_assignment_codec_amr_h_S124() );
7673 execute( TC_assignment_codec_amr_f_S0() );
7674 execute( TC_assignment_codec_amr_f_S02() );
7675 execute( TC_assignment_codec_amr_f_S024() );
7676 execute( TC_assignment_codec_amr_f_S0247() );
7677 execute( TC_assignment_codec_amr_h_S0() );
7678 execute( TC_assignment_codec_amr_h_S02() );
7679 execute( TC_assignment_codec_amr_h_S024() );
7680 execute( TC_assignment_codec_amr_h_S0247() );
7681 execute( TC_assignment_codec_amr_f_S01234567() );
7682 execute( TC_assignment_codec_amr_f_S0234567() );
7683 execute( TC_assignment_codec_amr_f_zero() );
7684 execute( TC_assignment_codec_amr_f_unsupp() );
7685 execute( TC_assignment_codec_amr_h_S7() );
7686 }
Harald Welte60aa5762018-03-21 19:33:13 +01007687
Philipp Maierac09bfc2019-01-08 13:41:39 +01007688 execute( TC_assignment_codec_fr_exhausted_req_hr() );
7689 execute( TC_assignment_codec_fr_exhausted_req_fr() );
7690 execute( TC_assignment_codec_fr_exhausted_req_fr_hr() );
7691 execute( TC_assignment_codec_fr_exhausted_req_hr_fr() );
7692 execute( TC_assignment_codec_hr_exhausted_req_fr() );
7693 execute( TC_assignment_codec_hr_exhausted_req_hr() );
7694 execute( TC_assignment_codec_hr_exhausted_req_hr_fr() );
7695 execute( TC_assignment_codec_hr_exhausted_req_fr_hr() );
7696 execute( TC_assignment_codec_req_hr_fr() );
7697 execute( TC_assignment_codec_req_fr_hr() );
7698
Pau Espin Pedrol58cf6822019-05-28 18:11:33 +02007699 if (mp_enable_osmux_test) {
7700 execute( TC_assignment_osmux() );
7701 }
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02007702
Harald Welte898113b2018-01-31 18:32:21 +01007703 /* RLL Establish Indication on inactive DCHAN / SAPI */
Harald Welte5cd20ed2017-12-13 21:03:20 +01007704 execute( TC_rll_est_ind_inact_lchan() );
7705 execute( TC_rll_est_ind_inval_sapi1() );
7706 execute( TC_rll_est_ind_inval_sapi3() );
7707 execute( TC_rll_est_ind_inval_sacch() );
7708
Vadim Yanitskiy61f784a2020-10-01 21:12:19 +07007709 /* DLCI / RSL Link ID conversion for MO/MT messages on SAPI0/SAPI3 */
7710 execute( TC_tch_dlci_link_id_sapi() );
7711
Vadim Yanitskiy6ef5dfa2020-08-28 18:04:41 +07007712 /* SAPI N Reject triggered by RLL establishment failures */
7713 execute( TC_rll_rel_ind_sapi_n_reject() );
7714 execute( TC_rll_err_ind_sapi_n_reject() );
7715 execute( TC_rll_timeout_sapi_n_reject() );
7716
Harald Welte898113b2018-01-31 18:32:21 +01007717 /* Paging related tests */
Harald Welte6f521d82017-12-11 19:52:02 +01007718 execute( TC_paging_imsi_nochan() );
7719 execute( TC_paging_tmsi_nochan() );
7720 execute( TC_paging_tmsi_any() );
7721 execute( TC_paging_tmsi_sdcch() );
7722 execute( TC_paging_tmsi_tch_f() );
7723 execute( TC_paging_tmsi_tch_hf() );
7724 execute( TC_paging_imsi_nochan_cgi() );
7725 execute( TC_paging_imsi_nochan_lac_ci() );
7726 execute( TC_paging_imsi_nochan_ci() );
7727 execute( TC_paging_imsi_nochan_lai() );
7728 execute( TC_paging_imsi_nochan_lac() );
7729 execute( TC_paging_imsi_nochan_all() );
Harald Welte751d3eb2018-01-31 15:51:06 +01007730 execute( TC_paging_imsi_nochan_plmn_lac_rnc() );
7731 execute( TC_paging_imsi_nochan_rnc() );
7732 execute( TC_paging_imsi_nochan_lac_rnc() );
7733 execute( TC_paging_imsi_nochan_lacs() );
7734 execute( TC_paging_imsi_nochan_lacs_empty() );
Stefan Sperling049a86e2018-03-20 15:51:00 +01007735 execute( TC_paging_imsi_nochan_cgi_unknown_cid() );
Harald Welte10985002017-12-12 09:29:15 +01007736 execute( TC_paging_imsi_a_reset() );
Harald Weltee65d40e2017-12-13 00:09:06 +01007737 execute( TC_paging_imsi_load() );
Philipp Maier779a7922018-02-16 11:00:37 +01007738 execute( TC_paging_counter() );
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01007739 execute( TC_paging_resp_unsol() );
Harald Welte4e9b9cc2017-12-14 18:31:02 +01007740
7741 execute( TC_rsl_drop_counter() );
Stefan Sperling830dc9d2018-02-12 21:08:28 +01007742 execute( TC_rsl_unknown_unit_id() );
7743
7744 execute( TC_oml_unknown_unit_id() );
Harald Welte898113b2018-01-31 18:32:21 +01007745
7746 execute( TC_classmark() );
Harald Welteeddf0e92020-06-21 19:42:15 +02007747 execute( TC_common_id() );
Harald Welte898113b2018-01-31 18:32:21 +01007748 execute( TC_unsol_ass_fail() );
Harald Welteea99a002018-01-31 20:46:43 +01007749 execute( TC_unsol_ass_compl() );
Harald Weltefbf9b5e2018-01-31 20:41:23 +01007750 execute( TC_unsol_ho_fail() );
Harald Weltee3bd6582018-01-31 22:51:25 +01007751 execute( TC_err_82_short_msg() );
Harald Weltee9e02e42018-01-31 23:36:25 +01007752 execute( TC_err_84_unknown_msg() );
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01007753
Harald Welte261af4b2018-02-12 21:20:39 +01007754 execute( TC_ho_int() );
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01007755
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01007756 execute( TC_ho_out_of_this_bsc() );
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02007757 execute( TC_ho_out_fail_no_msc_response() );
7758 execute( TC_ho_out_fail_rr_ho_failure() );
Neels Hofmeyrd8a602c2019-07-09 19:46:01 +02007759 execute( TC_ho_out_fail_no_result_after_ho_cmd() );
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01007760
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01007761 execute( TC_ho_into_this_bsc() );
Pau Espin Pedrol07866632020-09-03 19:10:55 +02007762 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
7763 execute( TC_ho_into_this_bsc_tla_v6() );
7764 }
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01007765 execute( TC_ho_in_fail_msc_clears() );
7766 execute( TC_ho_in_fail_msc_clears_after_ho_detect() );
7767 execute( TC_ho_in_fail_no_detect() );
7768 execute( TC_ho_in_fail_no_detect2() );
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01007769
Neels Hofmeyr91401012019-07-11 00:42:35 +02007770 execute( TC_ho_neighbor_config_1() );
7771 execute( TC_ho_neighbor_config_2() );
7772 execute( TC_ho_neighbor_config_3() );
7773 execute( TC_ho_neighbor_config_4() );
7774 execute( TC_ho_neighbor_config_5() );
7775 execute( TC_ho_neighbor_config_6() );
7776 execute( TC_ho_neighbor_config_7() );
7777
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01007778 execute( TC_bssap_rlsd_does_not_cause_bssmap_reset() );
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01007779 execute( TC_bssmap_clear_does_not_cause_bssmap_reset() );
Neels Hofmeyrfd445c32018-03-09 15:39:31 +01007780 execute( TC_ms_rel_ind_does_not_cause_bssmap_reset() );
Harald Welte94e0c342018-04-07 11:33:23 +02007781
7782 execute( TC_dyn_pdch_ipa_act_deact() );
7783 execute( TC_dyn_pdch_ipa_act_nack() );
7784 execute( TC_dyn_pdch_osmo_act_deact() );
7785 execute( TC_dyn_pdch_osmo_act_nack() );
Harald Welte99f3ca02018-06-14 13:40:29 +02007786
Stefan Sperling0796a822018-10-05 13:01:39 +02007787 execute( TC_chopped_ipa_ping() );
Stefan Sperlingaa1e60f2018-10-15 16:34:07 +02007788 execute( TC_chopped_ipa_payload() );
Stefan Sperling0796a822018-10-05 13:01:39 +02007789
Pau Espin Pedrol8f773632019-11-05 11:46:53 +01007790 /* Power control related */
7791 execute( TC_assignment_verify_ms_power_params_ie() );
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007792
7793 /* MSC pooling */
7794 /* FIXME: in SCCPlite, indicating how many MSCs should be connected does currently not work. Since
7795 * RESET->RESET-ACK is unconditionally negotiated for all configured MSCs, they always all appear as connected
7796 * to osmo-bsc. The MSC pooling tests however require disconnecting selected MSCs, and hence don't work out as
7797 * intended on SCCPlite. So for now, run these only for SCCP/M3UA. */
7798 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
7799 execute( TC_mscpool_L3Compl_on_1_msc() );
7800 execute( TC_mscpool_L3Complete_by_imsi_round_robin() );
7801 execute( TC_mscpool_LU_by_tmsi_null_nri_0_round_robin() );
7802 execute( TC_mscpool_LU_by_tmsi_null_nri_1_round_robin() );
7803 execute( TC_mscpool_L3Complete_by_tmsi_unassigned_nri_round_robin() );
7804 execute( TC_mscpool_L3Complete_by_tmsi_valid_nri_msc_not_connected_round_robin() );
7805 execute( TC_mscpool_L3Complete_by_tmsi_valid_nri_1() );
7806 execute( TC_mscpool_L3Complete_by_tmsi_valid_nri_2() );
7807 execute( TC_mscpool_LU_by_tmsi_from_other_PLMN() );
7808 execute( TC_mscpool_paging_and_response_imsi() );
7809 execute( TC_mscpool_paging_and_response_tmsi() );
7810 execute( TC_mscpool_no_allow_attach_round_robin() );
7811 execute( TC_mscpool_no_allow_attach_valid_nri() );
7812 }
7813
Harald Welte99f3ca02018-06-14 13:40:29 +02007814 /* at bottom as they might crash OsmoBSC before OS#3182 is fixed */
7815 execute( TC_early_conn_fail() );
7816 execute( TC_late_conn_fail() );
7817
Philipp Maier783681c2020-07-16 16:47:06 +02007818 /* Emergency call handling (deny / allow) */
7819 execute( TC_assignment_emerg_setup_allow() );
7820 execute( TC_assignment_emerg_setup_deny_msc() );
7821 execute( TC_assignment_emerg_setup_deny_bts() );
Philipp Maier82812002020-08-13 18:48:27 +02007822 execute( TC_emerg_premption() );
7823
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007824 /* Frequency hopping parameters handling */
7825 execute( TC_fh_params_chan_activ() );
7826 execute( TC_fh_params_imm_ass() );
Vadim Yanitskiyaeb54a22020-09-01 06:25:25 +07007827 execute( TC_fh_params_assignment_cmd() );
Vadim Yanitskiy8f5430d2020-09-02 18:51:38 +07007828 execute( TC_fh_params_handover_cmd() );
Vadim Yanitskiyca974032020-09-01 07:20:39 +07007829 execute( TC_fh_params_si4_cbch() );
Harald Welte28d943e2017-11-25 15:00:50 +01007830}
7831
7832}