blob: 4bab05536c9a6d0d5630a773be3b64404ec234f3 [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" },
Neels Hofmeyrac086c12020-09-18 23:46:42 +0200615 own_pc := 190, /* 0.23.6 SMLC emulation */
Harald Welte47cd0e32020-08-21 12:39:11 +0200616 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 };
Neels Hofmeyrcfe44062020-10-15 02:28:08 +0200622 boolean mp_enable_lcs_tests := true;
Harald Welte47cd0e32020-08-21 12:39:11 +0200623
Pau Espin Pedrol58cf6822019-05-28 18:11:33 +0200624 /* Whether to enable osmux tests. Can be dropped completely and enable
625 unconditionally once new version of osmo-bsc is released (current
626 version: 1.4.1) */
627 boolean mp_enable_osmux_test := true;
Pau Espin Pedrol8f30ccd2019-11-01 17:30:57 +0100628 /* Value set in osmo-bsc.cfg "ms max power" */
629 uint8_t mp_exp_ms_power_level := 7;
Philipp Maiera2083892020-09-21 14:18:36 +0200630
631 boolean mp_media_mgw_offer_ipv6 := true;
Harald Weltea4ca4462018-02-09 00:17:14 +0100632}
633
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200634private function f_gen_test_hdlr_pars(integer bssap_idx := 0) return TestHdlrParams {
Philipp Maier48604732018-10-09 15:00:37 +0200635
636 var TestHdlrParams pars := valueof(t_def_TestHdlrPars);
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200637 if (mp_bssap_cfg[bssap_idx].transport == BSSAP_TRANSPORT_AoIP) {
Philipp Maier48604732018-10-09 15:00:37 +0200638 pars.aoip := true;
639 } else {
640 pars.aoip := false;
641 }
Pau Espin Pedrol8f30ccd2019-11-01 17:30:57 +0100642 pars.exp_ms_power_level := mp_exp_ms_power_level;
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200643 pars.mscpool.bssap_idx := bssap_idx;
Philipp Maiera2083892020-09-21 14:18:36 +0200644 pars.media_mgw_offer_ipv6 := mp_media_mgw_offer_ipv6;
Philipp Maier48604732018-10-09 15:00:37 +0200645
646 return pars;
647}
648
Neels Hofmeyr22c3f792020-06-17 02:49:28 +0200649/* Convenience functions for rate counters using g_ctr_msc. */
650
651private function f_ctrs_msc_init(integer mscs_count := NUM_MSC, CounterNameVals counternames := counternames_msc_mscpool) runs on test_CT {
652 g_ctr_msc := f_counter_name_vals_get_n(IPA_CTRL, "msc", mscs_count, counternames);
653 log("initial msc rate counters: ", g_ctr_msc);
654}
655
656private function f_ctrs_msc_add(integer msc_nr, charstring countername, integer val := 1) runs on test_CT {
Neels Hofmeyr9656e922020-06-30 01:27:01 +0200657 f_counter_name_vals_list_add(g_ctr_msc, msc_nr, countername, val);
Neels Hofmeyr22c3f792020-06-17 02:49:28 +0200658}
659
660/* f_ctrs_msc_init();
661 * f_do_thing(on_msc := 0);
662 * f_do_thing(on_msc := 0);
663 * f_do_other(on_msc := 1);
664 * f_ctrs_msc_add(0, "thing", 2);
665 * f_ctrs_msc_add(1, "other");
666 * f_ctrs_msc_verify();
667 */
668private function f_ctrs_msc_verify() runs on test_CT {
669 log("verifying msc rate counters: ", g_ctr_msc);
670 f_counter_name_vals_expect_n(IPA_CTRL, "msc", g_ctr_msc);
671}
672
673/* convenience: f_ctrs_msc_add() and f_ctrs_msc_verify() in one call.
674 * f_ctrs_msc_init();
675 * f_do_thing(on_msc := 0);
676 * f_do_thing(on_msc := 0);
677 * f_do_thing(on_msc := 0);
678 * f_ctrs_msc_expect(0, "thing", 3);
679 */
680private function f_ctrs_msc_expect(integer msc_nr, charstring countername, integer val := 1) runs on test_CT {
681 f_ctrs_msc_add(msc_nr, countername, val);
682 f_ctrs_msc_verify();
683}
684
Neels Hofmeyr12941bd2020-08-29 03:21:26 +0000685/* Convenience functions for rate counters using g_ctr_bts, always also including g_ctr_bsc. */
686
687private function f_ctrs_bsc_and_bts_init(integer bts_count := NUM_BTS, CounterNameVals counternames := counternames_bsc_bts_handover) runs on test_CT {
688 g_ctr_bts := f_counter_name_vals_get_n(IPA_CTRL, "bts", bts_count, counternames);
689 log("initial bts rate counters: ", g_ctr_bts);
690 f_ctrs_bsc_init(counternames);
691}
692
693private function f_ctrs_bsc_and_bts_add(integer bts_nr, charstring countername, integer val := 1) runs on test_CT {
694 f_counter_name_vals_list_add(g_ctr_bts, bts_nr, countername, val);
695 f_ctrs_bsc_add(countername, val);
696}
697
698/* f_ctrs_bsc_and_bts_init();
699 * f_do_thing(on_bts := 0);
700 * f_do_thing(on_bts := 0);
701 * f_do_other(on_bts := 1);
702 * f_ctrs_bsc_and_bts_add(0, "thing", 2);
703 * f_ctrs_bsc_and_bts_add(1, "other");
704 * f_ctrs_bsc_and_bts_verify();
705 */
706private function f_ctrs_bsc_and_bts_verify() runs on test_CT {
707 f_counter_name_vals_expect_n(IPA_CTRL, "bts", g_ctr_bts);
708 f_ctrs_bsc_verify();
709}
710
711/* convenience: f_ctrs_bsc_and_bts_add() and f_ctrs_bsc_and_bts_verify() in one call.
712 * f_ctrs_bsc_and_bts_init();
713 * f_do_thing(on_bts := 0);
714 * f_do_thing(on_bts := 0);
715 * f_do_thing(on_bts := 0);
716 * f_ctrs_bsc_and_bts_expect(0, "thing", 3);
717 */
718private function f_ctrs_bsc_and_bts_expect(integer bts_nr, charstring countername, integer val := 1) runs on test_CT {
719 f_ctrs_bsc_and_bts_add(bts_nr, countername, val);
720 f_ctrs_bsc_and_bts_verify();
721}
722
723
724/* Convenience functions for rate counters using g_ctr_bsc. */
725
726private function f_ctrs_bsc_init(CounterNameVals counternames := counternames_bsc_bts_handover) runs on test_CT {
727 g_ctr_bsc := f_counter_name_vals_get_n(IPA_CTRL, "bsc", 1, counternames);
728 log("initial bsc rate counters: ", g_ctr_bsc);
729}
730
731private function f_ctrs_bsc_add(charstring countername, integer val := 1) runs on test_CT {
732 f_counter_name_vals_list_add(g_ctr_bsc, 0, countername, val);
733}
734
735/* f_ctrs_bsc_init();
736 * f_do_thing();
737 * f_do_thing();
738 * f_do_other();
739 * f_ctrs_bsc_add("thing", 2);
740 * f_ctrs_bsc_add("other");
741 * f_ctrs_bsc_verify();
742 */
743private function f_ctrs_bsc_verify() runs on test_CT {
744 f_counter_name_vals_expect_n(IPA_CTRL, "bsc", g_ctr_bsc);
745}
746
747/* convenience: f_ctrs_bsc_add() and f_ctrs_bsc_verify() in one call.
748 * f_ctrs_bsc_init();
749 * f_do_thing();
750 * f_ctrs_bsc_expect("thing", 1);
751 */
752private function f_ctrs_bsc_expect(charstring countername, integer val := 1) runs on test_CT {
753 f_ctrs_bsc_add(countername, val);
754 f_ctrs_bsc_verify();
755}
756
Neels Hofmeyr22c3f792020-06-17 02:49:28 +0200757
Philipp Maier282ca4b2018-02-27 17:17:00 +0100758private function f_shutdown_helper() runs on test_CT {
Daniel Willmann637ef6c2018-07-25 10:49:09 +0200759 all component.stop;
Philipp Maier282ca4b2018-02-27 17:17:00 +0100760 setverdict(pass);
Daniel Willmannafce8662018-07-06 23:11:32 +0200761 mtc.stop;
Philipp Maier282ca4b2018-02-27 17:17:00 +0100762}
763
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200764private function f_legacy_bssap_reset(integer bssap_idx := 0) runs on test_CT {
Harald Weltea4ca4462018-02-09 00:17:14 +0100765 var BSSAP_N_UNITDATA_ind ud_ind;
Pau Espin Pedrol24c05992020-09-01 12:54:12 +0200766 var boolean reset_received := false;
Harald Weltea4ca4462018-02-09 00:17:14 +0100767 timer T := 5.0;
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200768 BSSAP.send(ts_BSSAP_UNITDATA_req(g_bssap[bssap_idx].sccp_addr_peer, g_bssap[bssap_idx].sccp_addr_own,
769 ts_BSSMAP_Reset(0, g_osmux_enabled)));
Harald Weltea4ca4462018-02-09 00:17:14 +0100770 T.start;
771 alt {
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200772 [] BSSAP.receive(tr_BSSAP_UNITDATA_ind(g_bssap[bssap_idx].sccp_addr_own, g_bssap[bssap_idx].sccp_addr_peer,
773 tr_BSSMAP_ResetAck(g_osmux_enabled))) {
Harald Weltea4ca4462018-02-09 00:17:14 +0100774 log("Received RESET-ACK in response to RESET, we're ready to go!");
775 }
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200776 [] BSSAP.receive(tr_BSSAP_UNITDATA_ind(?, ?, tr_BSSMAP_Reset(g_osmux_enabled))) -> value ud_ind {
Harald Weltea4ca4462018-02-09 00:17:14 +0100777 log("Respoding to inbound RESET with RESET-ACK");
778 BSSAP.send(ts_BSSAP_UNITDATA_req(ud_ind.callingAddress, ud_ind.calledAddress,
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200779 ts_BSSMAP_ResetAck(g_osmux_enabled)));
Pau Espin Pedrol24c05992020-09-01 12:54:12 +0200780 reset_received := true;
Harald Weltea4ca4462018-02-09 00:17:14 +0100781 repeat;
782 }
783 [] BSSAP.receive { repeat; }
Pau Espin Pedrol24c05992020-09-01 12:54:12 +0200784 [] T.timeout {
785 log("Timeout waiting for RESET-ACK after sending RESET");
786 /* If we received a RESET after ours was sent, it
787 may be a race condition where the other peer beacame
788 available after we sent it, but we are in a desired
789 state anyway, so go forward. */
790 if (not reset_received) {
791 setverdict(fail);
792 }
793 }
Harald Weltea4ca4462018-02-09 00:17:14 +0100794 }
Harald Welte28d943e2017-11-25 15:00:50 +0100795}
796
Harald Welteae026692017-12-09 01:03:01 +0100797type record IPA_Client {
Harald Welte21b46bd2017-12-17 19:46:32 +0100798 /* IPA Emulation component reference */
Harald Welteae026692017-12-09 01:03:01 +0100799 IPA_Emulation_CT vc_IPA,
Harald Welte21b46bd2017-12-17 19:46:32 +0100800 /* Unit-ID and other CCM parameters to use for IPA client emulation */
Harald Welteae026692017-12-09 01:03:01 +0100801 IPA_CCM_Parameters ccm_pars,
Harald Welte21b46bd2017-12-17 19:46:32 +0100802 /* String identifier for this IPA Client */
Harald Welte624f9632017-12-16 19:26:04 +0100803 charstring id,
Harald Welte21b46bd2017-12-17 19:46:32 +0100804 /* Associated RSL Emulation Component (if any). Only used in "Handler mode" */
Harald Welte624f9632017-12-16 19:26:04 +0100805 RSL_Emulation_CT vc_RSL optional
Harald Welte28d943e2017-11-25 15:00:50 +0100806}
807
Harald Welte21b46bd2017-12-17 19:46:32 +0100808/*! Start the IPA/RSL related bits for one IPA_Client.
809 * \param clnt IPA_Client for which to establish
810 * \param bsc_host IP address / hostname of the BSC
811 * \param bsc_port TCP port number of the BSC
812 * \param i number identifying this BTS
813 * \param handler_mode Start an RSL_Emulation_CT component (true) or not (false) */
Harald Welte624f9632017-12-16 19:26:04 +0100814function f_ipa_rsl_start(inout IPA_Client clnt, charstring bsc_host, PortNumber bsc_port, integer i,
815 boolean handler_mode := false)
Harald Welte28d943e2017-11-25 15:00:50 +0100816runs on test_CT {
Harald Welteae026692017-12-09 01:03:01 +0100817 timer T := 10.0;
818
Harald Welte96c94412017-12-09 03:12:45 +0100819 clnt.id := "IPA" & int2str(i) & "-RSL";
Harald Welteae026692017-12-09 01:03:01 +0100820 clnt.vc_IPA := IPA_Emulation_CT.create(clnt.id & "-IPA");
821 clnt.ccm_pars := c_IPA_default_ccm_pars;
822 clnt.ccm_pars.name := "Osmocom TTCN-3 BTS Simulator";
823 clnt.ccm_pars.unit_id := int2str(1234+i) & "/0/0";
Harald Welte624f9632017-12-16 19:26:04 +0100824 if (handler_mode) {
825 clnt.vc_RSL := RSL_Emulation_CT.create(clnt.id & "-RSL");
Harald Welte89ab1912018-02-23 18:56:29 +0100826 connect(clnt.vc_RSL:CCHAN_PT, self:RSL_CCHAN[i]);
Harald Welte624f9632017-12-16 19:26:04 +0100827 }
Harald Welteae026692017-12-09 01:03:01 +0100828
829 map(clnt.vc_IPA:IPA_PORT, system:IPA_CODEC_PT);
Harald Welte624f9632017-12-16 19:26:04 +0100830 if (handler_mode) {
831 connect(clnt.vc_IPA:IPA_RSL_PORT, clnt.vc_RSL:IPA_PT);
832 } else {
833 connect(clnt.vc_IPA:IPA_RSL_PORT, self:IPA_RSL[i]);
834 }
Harald Welteae026692017-12-09 01:03:01 +0100835
Harald Welte5d1a2202017-12-13 19:51:29 +0100836 clnt.vc_IPA.start(IPA_Emulation.main_client(bsc_host, bsc_port, "", 10000+i, clnt.ccm_pars));
Harald Welte624f9632017-12-16 19:26:04 +0100837 if (handler_mode) {
838 clnt.vc_RSL.start(RSL_Emulation.main());
839 return;
840 }
Harald Welteae026692017-12-09 01:03:01 +0100841
842 /* wait for IPA RSL link to connect and send ID ACK */
843 T.start;
844 alt {
Vadim Yanitskiya2afacc2020-05-18 21:16:19 +0700845 [] IPA_RSL[i].receive(tr_ASP_IPA_EV(ASP_IPA_EVENT_ID_ACK)) {
Harald Welteae026692017-12-09 01:03:01 +0100846 T.stop;
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +0700847 IPA_RSL[i].send(ts_ASP_RSL_UD(ts_RSL_PAGING_LOAD_IND(23)));
Harald Welteae026692017-12-09 01:03:01 +0100848 }
Harald Welte60e823a2017-12-10 14:10:59 +0100849 [] IPA_RSL[i].receive(ASP_IPA_Event:?) { repeat }
Harald Welteae026692017-12-09 01:03:01 +0100850 [] IPA_RSL[i].receive { repeat }
851 [] T.timeout {
Harald Welte96c94412017-12-09 03:12:45 +0100852 setverdict(fail, "Timeout RSL waiting for ASP_IPA_EVENT_ID_ACK");
Daniel Willmannafce8662018-07-06 23:11:32 +0200853 mtc.stop;
Harald Welteae026692017-12-09 01:03:01 +0100854 }
855 }
856}
857
Harald Welte12055472018-03-17 20:10:08 +0100858function f_ipa_rsl_stop(inout IPA_Client clnt) runs on test_CT {
859 if (not isbound(clnt) or not isbound(clnt.vc_IPA)) {
860 return;
861 }
862 clnt.vc_IPA.stop;
863 if (isbound(clnt.vc_RSL)) {
864 clnt.vc_RSL.stop;
865 }
866}
867
Harald Welte21b46bd2017-12-17 19:46:32 +0100868/* Wait for the OML connection to be brought up by the external osmo-bts-omldummy */
Harald Weltea5d2ab22017-12-09 14:21:42 +0100869function f_wait_oml(integer bts_nr, charstring status, float secs_max) runs on test_CT {
870 timer T := secs_max;
871 T.start;
872 while (true) {
873 if (f_ctrl_get_bts(IPA_CTRL, bts_nr, "oml-connection-state") == status) {
874 T.stop;
Harald Weltebd868bd2017-12-10 18:28:40 +0100875 /* the 'degraded' state exists from OML connection time, and we have to wait
876 * until all MO's are initialized */
877 T.start(1.0);
878 T.timeout;
Harald Weltea5d2ab22017-12-09 14:21:42 +0100879 return;
880 }
Harald Weltef0d6ac62017-12-17 17:02:21 +0100881 f_sleep(0.1);
Harald Weltea5d2ab22017-12-09 14:21:42 +0100882 if (not T.running) {
Max99253902018-11-16 17:57:39 +0100883 setverdict(fail, "Timeout waiting for BTS" & int2str(bts_nr) & " oml-connection-state ", status);
Daniel Willmannafce8662018-07-06 23:11:32 +0200884 mtc.stop;
Harald Weltea5d2ab22017-12-09 14:21:42 +0100885 }
886 }
887}
888
Harald Welte21b46bd2017-12-17 19:46:32 +0100889/* global altstep for global guard timer; also takes care of responding RESET witH RESET-ACK */
Harald Welteae026692017-12-09 01:03:01 +0100890altstep as_Tguard() runs on test_CT {
Harald Welte60e823a2017-12-10 14:10:59 +0100891 var BSSAP_N_UNITDATA_ind ud_ind;
Neels Hofmeyrcc3f76a2018-03-12 01:43:25 +0100892 [] T_guard.timeout {
893 setverdict(fail, "Timeout of T_guard");
Daniel Willmannafce8662018-07-06 23:11:32 +0200894 mtc.stop;
Neels Hofmeyrcc3f76a2018-03-12 01:43:25 +0100895 }
Harald Welte60e823a2017-12-10 14:10:59 +0100896 /* always respond with RESET ACK to RESET */
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200897 [] BSSAP.receive(tr_BSSAP_UNITDATA_ind(?, ?, tr_BSSMAP_Reset(g_osmux_enabled))) -> value ud_ind {
Harald Welte60e823a2017-12-10 14:10:59 +0100898 BSSAP.send(ts_BSSAP_UNITDATA_req(ud_ind.callingAddress, ud_ind.calledAddress,
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200899 ts_BSSMAP_ResetAck(g_osmux_enabled)));
Harald Welte69c1c262017-12-13 21:02:08 +0100900 repeat;
Harald Welte60e823a2017-12-10 14:10:59 +0100901 }
Harald Welte28d943e2017-11-25 15:00:50 +0100902}
903
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +0100904altstep no_bssmap_reset() runs on test_CT {
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200905 [] BSSAP.receive(tr_BSSAP_UNITDATA_ind(?, ?, tr_BSSMAP_Reset(g_osmux_enabled))) {
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +0100906 setverdict(fail, "unexpected BSSMAP Reset");
Daniel Willmannafce8662018-07-06 23:11:32 +0200907 mtc.stop;
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +0100908 }
909}
910
Daniel Willmann191e0d92018-01-17 12:44:35 +0100911function f_init_mgcp(charstring id) runs on test_CT {
912 id := id & "-MGCP";
913
914 var MGCPOps ops := {
915 create_cb := refers(MGCP_Emulation.ExpectedCreateCallback),
916 unitdata_cb := refers(MGCP_Emulation.DummyUnitdataCallback)
917 };
918 var MGCP_conn_parameters mgcp_pars := {
919 callagent_ip := mp_bsc_ip,
Harald Welte9e4273e2018-01-29 22:01:22 +0100920 callagent_udp_port := -1,
Daniel Willmann191e0d92018-01-17 12:44:35 +0100921 mgw_ip := mp_test_ip,
Pau Espin Pedrol1a026a52019-06-18 17:21:52 +0200922 mgw_udp_port := 2427,
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +0200923 /* Enable it for SCCPlite, since we have 2 MGCP sockets towards MGW (UDP one +
924 the on with MGCP over IPA forwarded from MSC one) */
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200925 multi_conn_mode := (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_SCCPlite_SERVER)
Daniel Willmann191e0d92018-01-17 12:44:35 +0100926 };
927
928 vc_MGCP := MGCP_Emulation_CT.create(id);
929 vc_MGCP.start(MGCP_Emulation.main(ops, mgcp_pars, id));
930}
931
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200932/* Enable or disable (current default) Osmux. When enabling, BSSMAP Reset
933 * contains extra IE (OsmuxSupport) and osmo-bsc will handle AssignReq with
934 * OsmuxCID IE.
935 */
936private function f_vty_allow_osmux(boolean allow) runs on test_CT {
937 f_vty_enter_cfg_msc(BSCVTY, 0);
938 if (allow) {
939 f_vty_transceive(BSCVTY, "osmux on");
940 } else {
941 f_vty_transceive(BSCVTY, "osmux off");
942 }
943 f_vty_transceive(BSCVTY, "exit");
944 f_vty_transceive(BSCVTY, "exit");
945 g_osmux_enabled := allow;
946}
947
Max2253c0b2018-11-06 19:28:05 +0100948function f_init_vty(charstring id := "foo") runs on test_CT {
Harald Welte94e0c342018-04-07 11:33:23 +0200949 if (BSCVTY.checkstate("Mapped")) {
950 /* skip initialization if already executed once */
951 return;
952 }
Harald Weltebc03c762018-02-12 18:09:38 +0100953 map(self:BSCVTY, system:BSCVTY);
954 f_vty_set_prompts(BSCVTY);
955 f_vty_transceive(BSCVTY, "enable");
Pau Espin Pedrolc675b612020-01-09 19:55:40 +0100956 f_cs7_inst_0_cfg(BSCVTY, {"sccp-timer ias " & int2str(g_bsc_sccp_timer_ias),
957 "sccp-timer iar " & int2str(g_bsc_sccp_timer_iar)});
Harald Weltebc03c762018-02-12 18:09:38 +0100958}
959
Neels Hofmeyr767548a2020-08-09 20:26:07 +0000960private function f_logp(TELNETasp_PT pt, charstring log_msg)
Neels Hofmeyr4f118412020-06-04 15:25:10 +0200961{
962 // log on TTCN3 log output
963 log(log_msg);
964 // log in stderr log
Neels Hofmeyr767548a2020-08-09 20:26:07 +0000965 f_vty_transceive(pt, "logp lglobal notice TTCN3 f_logp(): " & log_msg);
Neels Hofmeyr4f118412020-06-04 15:25:10 +0200966}
967
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +0200968private function f_sysinfo_seen(integer rsl_idx, RSL_Message rsl) runs on test_CT
969{
970 if (rsl_idx >= lengthof(g_system_information)) {
971 g_system_information[rsl_idx] := SystemInformationConfig_omit
972 }
973 f_sysinfo_dec_raw(g_system_information[rsl_idx], rsl);
974}
975
976altstep as_catch_RSL_sysinfo(integer rsl_idx) runs on test_CT {
977 var ASP_RSL_Unitdata rx_rsl_ud;
978
979 /* For handler_mode := false, receiving the RSL bootstrap messages directly on IPA_RSL */
980 [] IPA_RSL[rsl_idx].receive(tr_ASP_RSL_UD(tr_RSL_NO_BCCH_INFO)) -> value rx_rsl_ud {
981 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
982 repeat;
983 }
984 [] IPA_RSL[rsl_idx].receive(tr_ASP_RSL_UD(tr_RSL_BCCH_INFO)) -> value rx_rsl_ud {
985 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
986 repeat;
987 }
988 [] IPA_RSL[rsl_idx].receive(tr_ASP_RSL_UD(tr_RSL_NO_SACCH_FILL)) -> value rx_rsl_ud {
989 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
990 repeat;
991 }
992 [] IPA_RSL[rsl_idx].receive(tr_ASP_RSL_UD(tr_RSL_SACCH_FILL)) -> value rx_rsl_ud {
993 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
994 repeat;
995 }
996
997 /* For handler_mode := true, receiving the RSL bootstrap messages via RSL_Emulation */
998 [] RSL_CCHAN[rsl_idx].receive(tr_ASP_RSL_UD(tr_RSL_NO_BCCH_INFO)) -> value rx_rsl_ud {
999 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
1000 repeat;
1001 }
1002 [] RSL_CCHAN[rsl_idx].receive(tr_ASP_RSL_UD(tr_RSL_BCCH_INFO)) -> value rx_rsl_ud {
1003 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
1004 repeat;
1005 }
1006 [] RSL_CCHAN[rsl_idx].receive(tr_ASP_RSL_UD(tr_RSL_NO_SACCH_FILL)) -> value rx_rsl_ud {
1007 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
1008 repeat;
1009 }
1010 [] RSL_CCHAN[rsl_idx].receive(tr_ASP_RSL_UD(tr_RSL_SACCH_FILL)) -> value rx_rsl_ud {
1011 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
1012 repeat;
1013 }
1014}
1015
Neels Hofmeyra460f1f2020-08-09 20:17:03 +00001016/* TODO: use BooleanList from COMMON/src/General_Types.ttcn */
1017private type record of boolean my_BooleanList;
1018
1019private function f_vty_msc_allow_attach(TELNETasp_PT pt, my_BooleanList allow_attach_list)
1020{
Neels Hofmeyr8f576712020-08-12 22:49:53 +00001021 var charstring config := f_vty_transceive_ret(pt, "show running-config");
1022
Neels Hofmeyra460f1f2020-08-09 20:17:03 +00001023 for (var integer msc_nr := 0; msc_nr < sizeof(allow_attach_list); msc_nr := msc_nr+1) {
Neels Hofmeyr8f576712020-08-12 22:49:53 +00001024 if (f_strstr(config, "\nmsc " & int2str(msc_nr) & "\n") < 0) {
1025 /* There is no 'msc N' for this msc_nr in the running config, so don't create an empty msc by
1026 * stepping into that config node. */
1027 log("msc ", msc_nr, " is not configured, skipping");
1028 continue;
1029 }
Neels Hofmeyra460f1f2020-08-09 20:17:03 +00001030 f_vty_enter_cfg_msc(pt, msc_nr);
1031 if (allow_attach_list[msc_nr]) {
1032 /* strict := false: ignore if osmo-bsc does not support this config option (latest build) */
1033 f_vty_transceive(pt, "allow-attach", strict := false);
1034 } else {
1035 f_vty_transceive(pt, "no allow-attach", strict := false);
1036 }
1037 f_vty_transceive(pt, "exit");
1038 f_vty_transceive(pt, "exit");
1039 }
1040}
1041
Harald Welte21b46bd2017-12-17 19:46:32 +01001042/* global initialization function
1043 * \param nr_bts Number of BTSs we should start/bring up
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001044 * \param handler_mode Start an RSL_Emulation_CT component (true) or not (false).
1045 * \param nr_msc Number of virtual MSCs to bring up to connect to osmo-bsc.
1046 */
1047function f_init(integer nr_bts := NUM_BTS, boolean handler_mode := false, boolean allow_osmux := false,
Neels Hofmeyr4fbad7f2020-06-16 00:30:47 +02001048 integer nr_msc := 1, float guard_timeout := 30.0) runs on test_CT {
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001049 var integer bssap_idx;
Harald Welte28d943e2017-11-25 15:00:50 +01001050
Harald Welteae026692017-12-09 01:03:01 +01001051 if (g_initialized) {
1052 return;
Harald Welte28d943e2017-11-25 15:00:50 +01001053 }
Harald Welteae026692017-12-09 01:03:01 +01001054 g_initialized := true;
1055
Neels Hofmeyr4fbad7f2020-06-16 00:30:47 +02001056 T_guard.start(guard_timeout);
Daniel Willmanne68f9272018-11-27 15:15:28 +01001057 activate(as_Tguard());
1058
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02001059 f_init_vty("VirtMSC");
Pau Espin Pedrol58cf6822019-05-28 18:11:33 +02001060 if (mp_enable_osmux_test) {
1061 f_vty_allow_osmux(allow_osmux);
1062 }
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02001063
Neels Hofmeyra460f1f2020-08-09 20:17:03 +00001064 var my_BooleanList allow_attach := { false, false, false };
Daniel Willmannebdecc02020-08-12 15:30:17 +02001065 f_init_statsd("VirtMSC", vc_STATSD, mp_test_ip, mp_bsc_statsd_port);
1066
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001067 for (bssap_idx := 0; bssap_idx < nr_msc; bssap_idx := bssap_idx+1) {
Neels Hofmeyra460f1f2020-08-09 20:17:03 +00001068 allow_attach[bssap_idx] := true;
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001069 /* Call a function of our 'parent component' RAN_Adapter_CT to start the
1070 * MSC-side BSSAP emulation */
1071 if (handler_mode) {
1072 var RanOps ranops := MSC_RanOps;
1073 ranops.use_osmux := g_osmux_enabled;
1074 f_ran_adapter_init(g_bssap[bssap_idx], mp_bssap_cfg[bssap_idx], "VirtMSC", ranops);
1075 connect(self:SCCPLITE_IPA_CTRL, g_bssap[bssap_idx].vc_RAN:CTRL_CLIENT);
1076 f_ran_adapter_start(g_bssap[bssap_idx]);
1077 } else {
1078 f_ran_adapter_init(g_bssap[bssap_idx], mp_bssap_cfg[bssap_idx], "VirtMSC", omit);
1079 connect(self:BSSAP, g_bssap[bssap_idx].vc_SCCP:SCCP_SP_PORT);
1080 f_ran_adapter_start(g_bssap[bssap_idx]);
1081 f_legacy_bssap_reset();
1082 }
Harald Welte67089ee2018-01-17 22:19:03 +01001083 }
Harald Welted5833a82018-05-27 16:52:56 +02001084
Neels Hofmeyrcfe44062020-10-15 02:28:08 +02001085 if (mp_enable_lcs_tests) {
1086 if (handler_mode) {
1087 f_bssap_le_adapter_init(g_bssap_le, mp_bssap_le_cfg, "VirtSMLC", SMLC_BssapLeOps);
1088 } else {
1089 f_bssap_le_adapter_init(g_bssap_le, mp_bssap_le_cfg, "VirtSMLC", omit);
1090 connect(self:BSSAP_LE, g_bssap_le.vc_SCCP:SCCP_SP_PORT);
1091 }
1092 f_bssap_le_adapter_start(g_bssap_le);
Harald Welte47cd0e32020-08-21 12:39:11 +02001093 }
Harald Welte47cd0e32020-08-21 12:39:11 +02001094
Neels Hofmeyra460f1f2020-08-09 20:17:03 +00001095 /* start the test with exactly all enabled MSCs allowed to attach */
1096 f_vty_msc_allow_attach(BSCVTY, allow_attach);
1097
Harald Welteffe55fc2018-01-17 22:39:54 +01001098 f_ipa_ctrl_start(mp_bsc_ip, mp_bsc_ctrl_port);
Harald Welte28d943e2017-11-25 15:00:50 +01001099
Daniel Willmann191e0d92018-01-17 12:44:35 +01001100 f_init_mgcp("VirtMSC");
1101
Neels Hofmeyr0b7365b2020-07-04 00:52:34 +02001102 for (var integer i := 0; i < nr_bts; i := i+1) {
1103 f_init_bts(i, handler_mode);
Harald Welte696ddb62017-12-08 14:01:43 +01001104 }
Neels Hofmeyr0b7365b2020-07-04 00:52:34 +02001105}
Harald Welte696ddb62017-12-08 14:01:43 +01001106
Neels Hofmeyr0b7365b2020-07-04 00:52:34 +02001107function f_init_bts(integer bts_idx := 0, boolean handler_mode := false)
1108runs on test_CT {
1109 /* wait until osmo-bts-omldummy has respawned */
1110 f_wait_oml(bts_idx, "degraded", 5.0);
1111
1112 /* start RSL connection */
1113 f_ipa_rsl_start(bts[bts_idx].rsl, mp_bsc_ip, mp_bsc_rsl_port, bts_idx, handler_mode);
1114 /* wait until BSC tells us "connected" */
1115 f_wait_oml(bts_idx, "connected", 5.0);
Harald Welte28d943e2017-11-25 15:00:50 +01001116}
1117
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +02001118function f_init_bts_and_check_sysinfo(integer bts_idx := 0, boolean handler_mode := false,
1119 template SystemInformationConfig expect_si)
1120runs on test_CT {
1121 var default sysinfo := activate(as_catch_RSL_sysinfo(bts_idx));
1122
1123 f_init_bts(bts_idx, handler_mode);
1124
1125 /* Give some time to (hopefully/most likely) collect all system informations from RSL startup.
1126 * We could stop as soon as all expected SI are received, but then we might miss SI that we don't expect and
1127 * that might be sent afterwards. So rather give a generous timeout and be quite sure to catch all SI.
1128 */
1129 f_sleep(5.0);
1130 log("RSL ", bts_idx, " SYSTEM INFORMATION: ", g_system_information[bts_idx]);
1131
1132 deactivate(sysinfo);
1133
1134 if (match(g_system_information[bts_idx], expect_si)) {
1135 setverdict(pass);
1136 } else {
1137 log("RSL ", bts_idx, ": EXPECTED SI: ", expect_si);
1138 log("RSL ", bts_idx, ": GOT SI: ", g_system_information[bts_idx]);
1139 setverdict(fail, "received SI does not match expectations");
1140 return;
1141 }
1142}
1143
Maxd4e56962018-10-31 19:08:25 +01001144/* expect to receive a RSL message matching a specified template on a given BTS / stream */
Harald Welte65e419a2020-08-21 12:38:33 +02001145function 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 +01001146runs on test_CT return RSL_Message {
1147 var ASP_RSL_Unitdata rx_rsl_ud;
1148 timer T := t_secs;
1149
1150 T.start;
1151 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001152 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(t_rx, sid)) -> value rx_rsl_ud {
Harald Welteae026692017-12-09 01:03:01 +01001153 T.stop;
1154 }
1155 [] IPA_RSL[bts_nr].receive { repeat; }
Harald Welteb2917702017-12-10 15:48:52 +01001156 [] T.timeout {
1157 setverdict(fail, "Timeout expecting ", t_rx);
Daniel Willmannafce8662018-07-06 23:11:32 +02001158 mtc.stop;
Harald Welteb2917702017-12-10 15:48:52 +01001159 }
Harald Welteae026692017-12-09 01:03:01 +01001160 }
1161 return rx_rsl_ud.rsl;
1162}
1163
Harald Welte21b46bd2017-12-17 19:46:32 +01001164/* helper function to transmit RSL on a given BTS/stream */
Harald Welte65e419a2020-08-21 12:38:33 +02001165function 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 +01001166runs on test_CT {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001167 IPA_RSL[bts_nr].send(ts_ASP_RSL_UD(t_tx, sid));
Harald Welteae026692017-12-09 01:03:01 +01001168}
1169
1170
Harald Welte4003d112017-12-09 22:35:39 +01001171/* verify we get a CHAN_ACT after CHAN RQD */
Harald Welteae026692017-12-09 01:03:01 +01001172testcase TC_chan_act_noreply() runs on test_CT {
1173 var BSSAP_N_UNITDATA_ind ud_ind;
Harald Welte930d0a72018-03-22 22:08:40 +01001174 var RSL_Message rsl_unused;
Harald Welte28d943e2017-11-25 15:00:50 +01001175
Harald Welte89d42e82017-12-17 16:42:41 +01001176 f_init(1);
Harald Welte28d943e2017-11-25 15:00:50 +01001177
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001178 IPA_RSL[0].send(ts_ASP_RSL_UD(ts_RSL_CHAN_RQD('23'O, 23)));
Harald Welte930d0a72018-03-22 22:08:40 +01001179 rsl_unused := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001180 f_shutdown_helper();
Harald Welte28d943e2017-11-25 15:00:50 +01001181}
1182
Harald Welte4003d112017-12-09 22:35:39 +01001183/* verify if the "chreq:total" counter increments as expected */
1184testcase TC_chan_act_counter() runs on test_CT {
1185 var BSSAP_N_UNITDATA_ind ud_ind;
1186 var integer chreq_total;
Harald Welte930d0a72018-03-22 22:08:40 +01001187 var RSL_Message rsl_unused;
Harald Welte4003d112017-12-09 22:35:39 +01001188
Harald Welte89d42e82017-12-17 16:42:41 +01001189 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +01001190
1191 chreq_total := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total");
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001192 IPA_RSL[0].send(ts_ASP_RSL_UD(ts_RSL_CHAN_RQD('23'O, 23)));
Harald Welte930d0a72018-03-22 22:08:40 +01001193 rsl_unused := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
Harald Welte4003d112017-12-09 22:35:39 +01001194 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total", chreq_total+1);
1195
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001196 f_shutdown_helper();
Harald Welte4003d112017-12-09 22:35:39 +01001197}
1198
Harald Welteae026692017-12-09 01:03:01 +01001199/* CHAN RQD -> CHAN ACT -> CHAN ACT ACK -> RF CHAN REL */
Philipp Maier9c60a622020-07-09 15:08:46 +02001200private function f_TC_chan_act_ack_noest(OCT1 ra := '23'O) runs on test_CT {
Harald Welteae026692017-12-09 01:03:01 +01001201 var RSL_Message rx_rsl;
1202
Harald Welteae026692017-12-09 01:03:01 +01001203 /* Send CHAN RQD and wait for allocation; acknowledge it */
Philipp Maier9c60a622020-07-09 15:08:46 +02001204 var RslChannelNr chan_nr := f_chreq_act_ack(ra);
Harald Welteae026692017-12-09 01:03:01 +01001205
1206 /* expect BSC to disable the channel again if there's no RLL EST IND */
1207 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), T3101_MAX);
1208
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001209 f_shutdown_helper();
Harald Welteae026692017-12-09 01:03:01 +01001210}
1211
Philipp Maier9c60a622020-07-09 15:08:46 +02001212/* Normal variant */
1213testcase TC_chan_act_ack_noest() runs on test_CT {
Philipp Maieraf58db22020-08-12 17:24:40 +02001214 f_init(1);
Philipp Maier9c60a622020-07-09 15:08:46 +02001215 f_TC_chan_act_ack_noest();
1216}
1217
1218/* Emergency call variant */
1219testcase TC_chan_act_ack_noest_emerg() runs on test_CT {
1220 /* See also: 3GPP TS 04.08, Table 9.9, ra=101xxxxx */
Philipp Maieraf58db22020-08-12 17:24:40 +02001221 f_init(1);
1222 f_vty_allow_emerg_bts(true, 0);
Philipp Maier9c60a622020-07-09 15:08:46 +02001223 f_TC_chan_act_ack_noest(ra := 'A5'O);
1224}
1225
Philipp Maier606f07d2020-08-12 17:21:58 +02001226/* Emergency call variant, but emergency calls are not allowed */
1227testcase TC_chan_rqd_emerg_deny() runs on test_CT {
1228 /* See also: 3GPP TS 04.08, Table 9.9, ra=101xxxxx */
1229
1230 var RSL_Message rx_rsl;
1231 var GsmRrMessage rr;
1232
1233 f_init(1);
1234 f_vty_allow_emerg_bts(false, 0);
1235
1236 IPA_RSL[0].clear;
1237 f_ipa_tx(0, ts_RSL_CHAN_RQD('A5'O, 23));
1238
1239 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeC(RSL_MT_IMMEDIATE_ASSIGN_CMD));
1240 rr := dec_GsmRrMessage(rx_rsl.ies[1].body.full_imm_ass_info.payload);
1241 if (rr.header.message_type == IMMEDIATE_ASSIGNMENT_REJECT) {
1242 setverdict(pass);
1243 } else {
1244 setverdict(fail, "immediate assignment not rejected");
1245 }
1246}
1247
Harald Welteae026692017-12-09 01:03:01 +01001248/* Test behavior if MSC never answers to CR */
1249testcase TC_chan_act_ack_est_ind_noreply() runs on test_CT {
Harald Weltef77aef62018-01-28 15:35:42 +01001250 var RslLinkId main_dcch := valueof(ts_RslLinkID_DCCH(0));
1251 var IpaStreamId sid := IPAC_PROTO_RSL_TRX0;
Harald Welteae026692017-12-09 01:03:01 +01001252 var RSL_Message rx_rsl;
Harald Weltef77aef62018-01-28 15:35:42 +01001253 var ASP_RSL_Unitdata rx_rsl_ud;
Harald Welteae026692017-12-09 01:03:01 +01001254
Harald Welte89d42e82017-12-17 16:42:41 +01001255 f_init(1);
Harald Welteae026692017-12-09 01:03:01 +01001256
1257 /* Send CHAN RQD and wait for allocation; acknowledge it */
Harald Welted6939652017-12-13 21:02:46 +01001258 var RslChannelNr chan_nr := f_chreq_act_ack();
Harald Welteae026692017-12-09 01:03:01 +01001259
1260 var octetstring l3 := '00010203040506'O
1261 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
1262
1263 BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3)));
1264
1265 /* expect BSC to disable the channel again if there's no response from MSC */
Harald Weltef77aef62018-01-28 15:35:42 +01001266 /* MS waits 20s (T3210) at LU; 10s (T3230) at CM SERV REQ and 5s (T3220) AT detach */
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001267 f_expect_chan_rel(0, chan_nr, expect_rll_rel_req := false);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001268 f_shutdown_helper();
Harald Welteae026692017-12-09 01:03:01 +01001269}
1270
1271/* Test behavior if MSC answers with CREF to CR */
1272testcase TC_chan_act_ack_est_ind_refused() runs on test_CT {
1273 var BSSAP_N_CONNECT_ind rx_c_ind;
1274 var RSL_Message rx_rsl;
1275
Harald Welte89d42e82017-12-17 16:42:41 +01001276 f_init(1);
Harald Welteae026692017-12-09 01:03:01 +01001277
1278 /* Send CHAN RQD and wait for allocation; acknowledge it */
Harald Welted6939652017-12-13 21:02:46 +01001279 var RslChannelNr chan_nr := f_chreq_act_ack();
Harald Welteae026692017-12-09 01:03:01 +01001280
1281 var octetstring l3 := '00010203040506'O
1282 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
1283
1284 BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) -> value rx_c_ind;
1285 BSSAP.send(ts_BSSAP_DISC_req(rx_c_ind.connectionId, 0));
1286
1287 /* expect BSC to disable the channel */
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001288 f_expect_chan_rel(0, chan_nr, expect_rll_rel_req := false);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001289 f_shutdown_helper();
Harald Welteae026692017-12-09 01:03:01 +01001290}
1291
Harald Welte618ef642017-12-14 14:58:20 +01001292/* CHAN RQD -> CHAN ACT -> CHAN ACT NACK -> RF CHAN REL */
1293testcase TC_chan_act_nack() runs on test_CT {
1294 var RSL_Message rx_rsl;
1295 var integer chact_nack;
1296
Harald Welte89d42e82017-12-17 16:42:41 +01001297 f_init(1);
Harald Welte618ef642017-12-14 14:58:20 +01001298
1299 chact_nack := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chan_act:nack");
1300
1301 f_ipa_tx(0, ts_RSL_CHAN_RQD('33'O, 33));
1302 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
1303 var RslChannelNr chan_nr := rx_rsl.ies[0].body.chan_nr;
1304
1305 f_ipa_tx(0, ts_RSL_CHAN_ACT_NACK(chan_nr, RSL_ERR_EQUIPMENT_FAIL));
1306
1307 /* wait for some time to hope the NACK arrives before the CTRL GET below */
1308 f_sleep(0.5);
1309
1310 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chan_act:nack", chact_nack+1);
1311
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001312 f_shutdown_helper();
Harald Welte618ef642017-12-14 14:58:20 +01001313}
1314
Harald Welte799c97b2017-12-14 17:50:30 +01001315/* Test for channel exhaustion due to RACH overload */
1316testcase TC_chan_exhaustion() runs on test_CT {
1317 var ASP_RSL_Unitdata rsl_ud;
1318 var integer i;
1319 var integer chreq_total, chreq_nochan;
1320
Harald Welte89d42e82017-12-17 16:42:41 +01001321 f_init(1);
Harald Welte799c97b2017-12-14 17:50:30 +01001322
1323 chreq_total := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total");
1324 chreq_nochan := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:no_channel");
1325
Pau Espin Pedrolfe200d72018-12-10 12:41:04 +01001326 /* GSM 04.08 Table 9.9a:
1327 * RA = '33'O -> Establishment cause = 0011xxxx (MS dual rate capable and asks for "TCH/H or TCH/F").
1328 * With current setup, expect 4xSDCCH + 4xTCH/F + 1xTCH/H to succeed */
Philipp Maiercb6cc482018-03-26 13:08:00 +02001329 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 +01001330 var RslChannelNr chan_nr := f_chreq_act_ack('33'O, i);
Harald Welte799c97b2017-12-14 17:50:30 +01001331 }
1332
1333 IPA_RSL[0].clear;
1334
Harald Weltedd8cbf32018-01-28 12:07:52 +01001335 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total",
Philipp Maiercb6cc482018-03-26 13:08:00 +02001336 chreq_total + NUM_TCHF_PER_BTS + NUM_TCHH_PER_BTS + NUM_SDCCH_PER_BTS);
Harald Welte799c97b2017-12-14 17:50:30 +01001337
1338 /* now expect additional channel activations to fail */
1339 f_ipa_tx(0, ts_RSL_CHAN_RQD('42'O, 42));
1340
1341 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001342 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV))) {
Harald Welte799c97b2017-12-14 17:50:30 +01001343 setverdict(fail, "Received CHAN ACT ACK without resources?!?");
1344 }
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001345 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_IMM_ASSIGN(?))) -> value rsl_ud {
Harald Welte799c97b2017-12-14 17:50:30 +01001346 var GsmRrMessage rr;
1347 /* match on IMM ASS REJ */
1348 rr := dec_GsmRrMessage(rsl_ud.rsl.ies[1].body.full_imm_ass_info.payload);
1349 if (rr.header.message_type == IMMEDIATE_ASSIGNMENT_REJECT) {
1350 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total",
Philipp Maiercb6cc482018-03-26 13:08:00 +02001351 chreq_total + NUM_TCHF_PER_BTS + NUM_TCHH_PER_BTS + NUM_SDCCH_PER_BTS+1);
Harald Welte799c97b2017-12-14 17:50:30 +01001352 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:no_channel",
1353 chreq_nochan+1);
1354 setverdict(pass);
1355 } else {
1356 repeat;
1357 }
1358 }
1359 [] IPA_RSL[0].receive { repeat; }
1360 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001361 f_shutdown_helper();
Harald Welte799c97b2017-12-14 17:50:30 +01001362}
1363
Vadim Yanitskiy1ff1fdf2018-11-27 01:32:57 +07001364/* Test channel deactivation due to silence from MS */
1365testcase TC_chan_deact_silence() runs on test_CT {
1366 var RslChannelNr chan_nr;
1367
1368 f_init(1);
1369
1370 /* Request for a dedicated channel */
1371 chan_nr := f_chreq_act_ack('23'O);
1372
1373 /* Wait some time until the channel is released */
1374 f_sleep(2.0);
1375
1376 /* Expect CHANnel RELease */
1377 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001378 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL))) {
Vadim Yanitskiy1ff1fdf2018-11-27 01:32:57 +07001379 log("Received CHANnel RELease");
1380 setverdict(pass);
1381 }
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001382 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_IMM_ASSIGN(?))) {
Vadim Yanitskiy1ff1fdf2018-11-27 01:32:57 +07001383 /* See OS#3709, OsmoBSC should not send Immediate
1384 * Assignment Reject since a dedicated channel was
1385 * already allocated, and Immediate Assignment was
1386 * already sent. */
1387 setverdict(fail, "Unexpected Immediate Assignment!");
1388 }
1389 [] IPA_RSL[0].receive {
1390 setverdict(fail, "Unexpected RSL message!");
1391 }
1392 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001393 f_shutdown_helper();
Vadim Yanitskiy1ff1fdf2018-11-27 01:32:57 +07001394}
1395
Harald Weltecfe2c962017-12-15 12:09:32 +01001396/***********************************************************************
1397 * Assignment Testing
1398 ***********************************************************************/
1399
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02001400/* Verify that the BSC refuses any BSSAP connection from the MSC (They are all BSC->MSC direction,
1401 * except for the inter-BSC handover, MT side) */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001402testcase TC_outbound_connect(integer bssap_idx := 0) runs on test_CT {
Harald Welte89d42e82017-12-17 16:42:41 +01001403 f_init(1);
Harald Weltecfe2c962017-12-15 12:09:32 +01001404
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001405 BSSAP.send(ts_BSSAP_CONNECT_req(g_bssap[bssap_idx].sccp_addr_peer, g_bssap[bssap_idx].sccp_addr_own,
1406 2342, ts_BSSMAP_AssignmentReq));
Harald Weltecfe2c962017-12-15 12:09:32 +01001407 BSSAP.receive(tr_BSSAP_DISC_ind(2342, ?, ?));
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001408 f_shutdown_helper();
Harald Weltecfe2c962017-12-15 12:09:32 +01001409}
1410
Harald Welte16a4adf2017-12-14 18:54:01 +01001411/* Test behavior if MSC answers with CREF to CR */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001412testcase TC_assignment_cic_only(integer bssap_idx := 0) runs on test_CT {
Harald Welte16a4adf2017-12-14 18:54:01 +01001413 var BSSAP_N_CONNECT_ind rx_c_ind;
1414 var RSL_Message rx_rsl;
1415 var DchanTuple dt;
1416
Harald Welte89d42e82017-12-17 16:42:41 +01001417 f_init(1);
Harald Welte16a4adf2017-12-14 18:54:01 +01001418
1419 dt := f_est_dchan('23'O, 23, '00000000'O);
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001420 if (mp_bssap_cfg[bssap_idx].transport == BSSAP_TRANSPORT_AoIP) {
Harald Welte17b27da2018-05-25 20:33:53 +02001421 /* send assignment without AoIP IEs */
1422 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_AssignmentReq(ts_BSSMAP_IE_CIC(0, 1))));
1423 } else {
1424 /* Send assignmetn without CIC in IPA case */
1425 var BSSMAP_IE_AoIP_TransportLayerAddress tla :=
1426 valueof(ts_BSSMAP_IE_AoIP_TLA4('01020304'O, 2342));
1427 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_AssignmentReq(omit, tla)));
1428 }
Harald Welte16a4adf2017-12-14 18:54:01 +01001429 alt {
1430 [] BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_AssignmentComplete)) {
1431 setverdict(fail, "AoIP BSC cannot accept ASSIGNMENT without AoIP Transport IE");
1432 }
Harald Welte235ebf12017-12-15 14:18:16 +01001433 /* TODO: Actually expect GSM0808_CAUSE_REQ_A_IF_TYPE_NOT_SUPP */
Harald Welte16a4adf2017-12-14 18:54:01 +01001434 [] BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_AssignmentFail)) {
1435 setverdict(pass);
1436 }
1437 [] BSSAP.receive { repeat; }
1438 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001439 f_shutdown_helper();
Harald Welte16a4adf2017-12-14 18:54:01 +01001440}
1441
Harald Welteed848512018-05-24 22:27:58 +02001442/* generate an assignment request for either AoIP or SCCPlite */
Pau Espin Pedrol07866632020-09-03 19:10:55 +02001443function 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 +02001444 var PDU_BSSAP ass_cmd;
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02001445 var BSSMAP_IE_Osmo_OsmuxCID osmux_cid := valueof(ts_OsmuxCID(0));
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001446 if (mp_bssap_cfg[bssap_idx].transport == BSSAP_TRANSPORT_AoIP) {
Harald Welteed848512018-05-24 22:27:58 +02001447 var BSSMAP_IE_AoIP_TransportLayerAddress tla :=
Pau Espin Pedrol07866632020-09-03 19:10:55 +02001448 valueof(f_ts_BSSMAP_IE_AoIP_TLA(aoip_tla, 2342));
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02001449 if (osmux_enabled) {
1450 ass_cmd := valueof(ts_BSSMAP_AssignmentReq(omit, tla, osmux_cid));
1451 } else {
1452 ass_cmd := valueof(ts_BSSMAP_AssignmentReq(omit, tla));
1453 }
Harald Welteed848512018-05-24 22:27:58 +02001454 } else {
1455 var BSSMAP_IE_CircuitIdentityCode cic := valueof(ts_BSSMAP_IE_CIC(0,1));
Pau Espin Pedrol096d73d2019-06-06 12:49:17 +02001456 ass_cmd := valueof(ts_BSSMAP_AssignmentReq(cic, omit));
Harald Welteed848512018-05-24 22:27:58 +02001457 }
1458 return ass_cmd;
1459}
1460
Pau Espin Pedrol07866632020-09-03 19:10:55 +02001461function 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 +01001462 var PDU_BSSAP ho_req;
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001463 if (mp_bssap_cfg[bssap_idx].transport == BSSAP_TRANSPORT_AoIP) {
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01001464 var BSSMAP_IE_AoIP_TransportLayerAddress tla :=
Pau Espin Pedrol07866632020-09-03 19:10:55 +02001465 valueof(f_ts_BSSMAP_IE_AoIP_TLA(aoip_tla, 2342));
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01001466 ho_req := valueof(ts_BSSMAP_HandoverRequest(omit, tla));
1467 } else {
1468 var BSSMAP_IE_CircuitIdentityCode cic := valueof(ts_BSSMAP_IE_CIC(0,1));
1469 ho_req := valueof(ts_BSSMAP_HandoverRequest(cic, omit));
1470 }
1471 return ho_req;
1472}
1473
Harald Welteed848512018-05-24 22:27:58 +02001474/* generate an assignment complete template for either AoIP or SCCPlite */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001475function f_gen_exp_compl(boolean expect_osmux := false, integer bssap_idx := 0) return template PDU_BSSAP {
Harald Welteed848512018-05-24 22:27:58 +02001476 var template PDU_BSSAP exp_compl;
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02001477 var BSSMAP_IE_Osmo_OsmuxCID osmux_cid := valueof(ts_OsmuxCID(0));
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001478 if (mp_bssap_cfg[bssap_idx].transport == BSSAP_TRANSPORT_AoIP) {
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02001479 if (expect_osmux) {
1480 exp_compl := tr_BSSMAP_AssignmentComplete(omit, ?, osmux_cid);
1481 } else {
1482 exp_compl := tr_BSSMAP_AssignmentComplete(omit, ?, omit);
1483 }
Harald Welteed848512018-05-24 22:27:58 +02001484 } else {
1485 /* CIC is optional "*" as the MSC allocated it */
Pau Espin Pedrol096d73d2019-06-06 12:49:17 +02001486 exp_compl := tr_BSSMAP_AssignmentComplete(*, omit);
Harald Welteed848512018-05-24 22:27:58 +02001487 }
1488 return exp_compl;
1489}
1490
Harald Welte235ebf12017-12-15 14:18:16 +01001491/* Run everything required up to sending a caller-specified assignment command and expect response */
1492function f_assignment_exp(PDU_BSSAP ass_cmd, template PDU_BSSAP exp, charstring fail_text)
1493runs on test_CT {
1494 var BSSAP_N_CONNECT_ind rx_c_ind;
1495 var RSL_Message rx_rsl;
1496 var DchanTuple dt;
1497
Harald Welte89d42e82017-12-17 16:42:41 +01001498 f_init(1);
Harald Welte235ebf12017-12-15 14:18:16 +01001499
1500 dt := f_est_dchan('23'O, 23, '00000000'O);
1501 /* send assignment without AoIP IEs */
1502 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ass_cmd));
1503 alt {
1504 [] BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_AssignmentComplete)) {
1505 if (ischosen(exp.pdu.bssmap.assignmentComplete)) {
1506 setverdict(pass);
1507 } else {
1508 setverdict(fail, fail_text);
1509 }
1510 }
1511 [] BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_AssignmentFail)) {
1512 if (ischosen(exp.pdu.bssmap.assignmentFailure)) {
1513 setverdict(pass);
1514 } else {
1515 setverdict(fail, fail_text);
1516 }
1517 }
1518 [] BSSAP.receive { repeat; }
1519 }
1520}
1521testcase TC_assignment_csd() runs on test_CT {
1522 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
Harald Welteed848512018-05-24 22:27:58 +02001523 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte235ebf12017-12-15 14:18:16 +01001524 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeCSD);
1525 //exp_fail.pdu.bssmap.assignmentFailure.cause.causeValue := int2bit(enum2int(GSM0808_CAUSE_REQ_CODEC_TYPE_OR_CONFIG_UNAVAIL), 7);
1526 f_assignment_exp(ass_cmd, exp_fail, "BSC accepted Assignment for CSD");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001527 f_shutdown_helper();
Harald Welte235ebf12017-12-15 14:18:16 +01001528}
1529
1530testcase TC_assignment_ctm() runs on test_CT {
1531 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
Harald Welteed848512018-05-24 22:27:58 +02001532 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte235ebf12017-12-15 14:18:16 +01001533 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeCTM);
1534 //exp_fail.pdu.bssmap.assignmentFailure.cause.causeValue := int2bit(enum2int(GSM0808_CAUSE_REQ_CODEC_TYPE_OR_CONFIG_UNAVAIL), 7);
1535 f_assignment_exp(ass_cmd, exp_fail, "BSC accepted Assignment for Speech+CTM");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001536 f_shutdown_helper();
Harald Welte235ebf12017-12-15 14:18:16 +01001537}
1538
Harald Welte4003d112017-12-09 22:35:39 +01001539type record DchanTuple {
1540 integer sccp_conn_id,
1541 RslChannelNr rsl_chan_nr
Harald Weltea5d2ab22017-12-09 14:21:42 +01001542}
1543
Harald Welted6939652017-12-13 21:02:46 +01001544/* Send CHAN RQD and wait for allocation; acknowledge it */
1545private function f_chreq_act_ack(OCT1 ra := '23'O, GsmFrameNumber fn := 23)
1546runs on test_CT return RslChannelNr {
1547 var RSL_Message rx_rsl;
1548 f_ipa_tx(0, ts_RSL_CHAN_RQD(ra, fn));
1549 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
1550 var RslChannelNr chan_nr := rx_rsl.ies[0].body.chan_nr;
1551 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, fn+10));
Daniel Willmannf4ac4ce2018-08-02 14:06:30 +02001552 rx_rsl := f_exp_ipa_rx(0, tr_RSL_IMM_ASSIGN(0));
Harald Welted6939652017-12-13 21:02:46 +01001553 return chan_nr;
1554}
1555
Harald Welte4003d112017-12-09 22:35:39 +01001556/* helper function to establish a dedicated channel via BTS and MSC */
1557function f_est_dchan(OCT1 ra, GsmFrameNumber fn, octetstring l3)
1558runs on test_CT return DchanTuple {
1559 var BSSAP_N_CONNECT_ind rx_c_ind;
Harald Welte4003d112017-12-09 22:35:39 +01001560 var DchanTuple dt;
Harald Weltea5d2ab22017-12-09 14:21:42 +01001561
Harald Welte4003d112017-12-09 22:35:39 +01001562 /* Send CHAN RQD and wait for allocation; acknowledge it */
Harald Welted6939652017-12-13 21:02:46 +01001563 dt.rsl_chan_nr := f_chreq_act_ack(ra, fn);
Harald Welte4003d112017-12-09 22:35:39 +01001564
1565 f_ipa_tx(0, ts_RSL_EST_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
1566
1567 BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) -> value rx_c_ind;
1568 dt.sccp_conn_id := rx_c_ind.connectionId;
1569 BSSAP.send(ts_BSSAP_CONNECT_res(dt.sccp_conn_id));
1570
1571 return dt;
Harald Weltea5d2ab22017-12-09 14:21:42 +01001572}
1573
Harald Welte641fcbe2018-06-14 10:58:35 +02001574/* expect RF CAN REL from BTS, acknowledge it and clear the MSC side */
1575private function f_exp_chan_rel_and_clear(DchanTuple dt, integer bts_nr := 0) runs on test_CT {
1576 var RSL_Message rx_rsl;
1577 /* expect BSC to disable the channel */
1578 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), T3101_MAX);
1579 /* respond with CHAN REL ACK */
1580 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(dt.rsl_chan_nr));
1581
1582 /* expect Clear Complete from BSC */
1583 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete));
1584
1585 /* MSC disconnects as instructed. */
1586 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
1587}
1588
Harald Welte4003d112017-12-09 22:35:39 +01001589/* Test behavior of channel release after unilateral RLL REL IND (DISC from MS) */
1590testcase TC_chan_rel_rll_rel_ind() runs on test_CT {
Neels Hofmeyr27f64362018-03-12 01:44:00 +01001591 var BSSAP_N_DATA_ind rx_di;
Harald Welte4003d112017-12-09 22:35:39 +01001592 var DchanTuple dt;
Harald Welte96c94412017-12-09 03:12:45 +01001593
Harald Welte89d42e82017-12-17 16:42:41 +01001594 f_init(1);
Harald Welte96c94412017-12-09 03:12:45 +01001595
Harald Welte4003d112017-12-09 22:35:39 +01001596 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1597
1598 /* simulate RLL REL IND */
1599 f_ipa_tx(0, ts_RSL_REL_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0))));
1600
Neels Hofmeyr27f64362018-03-12 01:44:00 +01001601 /* expect Clear Request on MSC side */
1602 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearRequest)) -> value rx_di;
1603
1604 /* Instruct BSC to clear channel */
1605 var BssmapCause cause := bit2int(rx_di.userData.pdu.bssmap.clearRequest.cause.causeValue);
1606 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
1607
Harald Welte4003d112017-12-09 22:35:39 +01001608 /* expect BSC to disable the channel */
Harald Welte641fcbe2018-06-14 10:58:35 +02001609 f_exp_chan_rel_and_clear(dt, 0);
Neels Hofmeyr27f64362018-03-12 01:44:00 +01001610
1611 /* wait for SCCP emulation to do its job */
1612 f_sleep(1.0);
Harald Welte4003d112017-12-09 22:35:39 +01001613
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001614 f_shutdown_helper();
Harald Welte4003d112017-12-09 22:35:39 +01001615}
1616
1617/* Test behavior of channel release after CONN FAIL IND from BTS */
1618testcase TC_chan_rel_conn_fail() runs on test_CT {
1619 var BSSAP_N_DATA_ind rx_di;
Harald Welte4003d112017-12-09 22:35:39 +01001620 var DchanTuple dt;
1621
Harald Welte89d42e82017-12-17 16:42:41 +01001622 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +01001623
1624 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1625
1626 /* simulate CONN FAIL IND */
Harald Weltea8ed9062017-12-14 09:46:01 +01001627 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 +01001628 /* TODO: different cause values? */
1629
Harald Welte4003d112017-12-09 22:35:39 +01001630 /* expect Clear Request from BSC */
1631 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearRequest)) -> value rx_di;
1632
1633 /* Instruct BSC to clear channel */
1634 var BssmapCause cause := bit2int(rx_di.userData.pdu.bssmap.clearRequest.cause.causeValue);
1635 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
1636
Harald Welte6ff76ea2018-01-28 13:08:01 +01001637 /* expect BSC to disable the channel */
Harald Welte641fcbe2018-06-14 10:58:35 +02001638 f_exp_chan_rel_and_clear(dt, 0);
Harald Welte4003d112017-12-09 22:35:39 +01001639
1640 /* wait for SCCP emulation to do its job */
1641 f_sleep(1.0);
1642
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001643 f_shutdown_helper();
Harald Welte4003d112017-12-09 22:35:39 +01001644}
1645
Harald Welte99f3ca02018-06-14 13:40:29 +02001646/* Test behavior of early CONN FAIL IND from BTS (before EST IND!) */
1647/* See also https://www.osmocom.org/issues/3182 */
1648testcase TC_early_conn_fail() runs on test_CT {
1649 var RSL_Message rx_rsl;
1650 var DchanTuple dt;
1651
1652 f_init(1);
1653
1654 /* BTS->BSC: Send CHAN RQD and wait for allocation; acknowledge it */
Harald Weltec46ea3c2020-10-10 18:46:12 +02001655 dt.rsl_chan_nr := f_chreq_act_ack(f_rnd_ra_cs(), 23);
Harald Welte99f3ca02018-06-14 13:40:29 +02001656
1657 /* BTS->BSC: simulate CONN FAIL IND */
1658 f_ipa_tx(0, ts_RSL_CONN_FAIL_IND(dt.rsl_chan_nr, RSL_ERR_RADIO_LINK_FAIL));
1659
1660 /* BTS->BSC: Expect RF channel release from BSC on Abis */
1661 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), 10.0);
1662
1663 /* BTS<-BSC: respond with CHAN REL ACK */
1664 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(dt.rsl_chan_nr));
1665
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001666 f_shutdown_helper();
Harald Welte99f3ca02018-06-14 13:40:29 +02001667}
1668
1669/* Test behavior of late CONN FAIL IND from BTS (ater REL IND!) */
1670/* See also https://www.osmocom.org/issues/3182 */
1671testcase TC_late_conn_fail() runs on test_CT {
1672 var RSL_Message rx_rsl;
1673 var DchanTuple dt;
1674
1675 f_init(1);
1676
1677 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1678
1679 /* BSC<-MSC: Instruct BSC to clear connection */
1680 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(0)));
1681
1682 /* BTS->BSC: expect BSC to deactivate SACCH */
1683 rx_rsl := f_exp_ipa_rx(0, tr_RSL_DEACT_SACCH(dt.rsl_chan_nr));
1684
1685 /* BTS->BSC: simulate a late CONN FAIL IND from BTS */
1686 f_ipa_tx(0, ts_RSL_CONN_FAIL_IND(dt.rsl_chan_nr, RSL_ERR_RADIO_LINK_FAIL));
1687
1688 /* BTS<-BSC: Expect RF channel release from BSC on Abis */
1689 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), 10.0);
1690 /* BTS->BSC: respond with CHAN REL ACK */
1691 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(dt.rsl_chan_nr));
1692
1693 /* BSC->MSC: expect Clear Complete from BSC */
1694 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete));
1695
1696 /* BSC<-MSC: MSC disconnects as requested. */
1697 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
1698
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001699 f_shutdown_helper();
Harald Welte99f3ca02018-06-14 13:40:29 +02001700}
1701
Neels Hofmeyrf44ccd12018-11-05 19:15:23 +01001702function f_expect_chan_rel(integer bts_nr, RslChannelNr rsl_chan_nr,
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001703 boolean expect_deact_sacch := true,
1704 boolean expect_rr_chan_rel := true,
1705 boolean expect_rll_rel_req := true,
Harald Welte99787102019-02-04 10:41:36 +01001706 boolean handle_rll_rel := true,
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02001707 boolean is_csfb := false,
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02001708 template CellSelIndValue csfb_expect_cells := omit,
1709 template RR_Cause expect_rr_cause := ?
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001710 ) runs on test_CT {
Harald Welte91d54a52018-01-28 15:35:07 +01001711
1712 var RslLinkId main_dcch := valueof(ts_RslLinkID_DCCH(0));
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001713 var boolean got_deact_sacch := false;
1714 var boolean got_rr_chan_rel := false;
1715 var boolean got_rll_rel_req := false;
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02001716 var ASP_RSL_Unitdata ud;
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02001717 var RSL_IE_Body l3_ie;
1718 var PDU_ML3_NW_MS l3;
1719 var RR_Cause got_cause;
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001720 log("f_expect_chan_rel() expecting: expect_deact_sacch=", expect_deact_sacch, " expect_rr_chan_rel=", expect_rr_chan_rel,
1721 " expect_rll_rel_req=", expect_rll_rel_req);
Harald Welte91d54a52018-01-28 15:35:07 +01001722 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001723 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(tr_RSL_DEACT_SACCH(rsl_chan_nr))) {
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001724 got_deact_sacch := true;
Harald Welte91d54a52018-01-28 15:35:07 +01001725 repeat;
1726 }
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02001727 [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 +01001728 got_rr_chan_rel := true;
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02001729
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02001730 if (f_rsl_find_ie(ud.rsl, RSL_IE_L3_INFO, l3_ie) == false) {
1731 setverdict(fail, "cannot find L3");
1732 mtc.stop;
1733 }
1734 l3 := dec_PDU_ML3_NW_MS(l3_ie.l3_info.payload);
1735
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02001736 if (not istemplatekind(csfb_expect_cells, "omit")) {
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02001737 var CellSelIndValue cells := dec_CellSelIndValue(
1738 l3.msgs.rrm.channelRelease.cellSelectionIndicator.cellSelectionIndicatorValue);
1739
1740 log("GOT RR CHANNEL RELEASE CSFB CELLS: ", cells);
1741 if (match(cells, csfb_expect_cells)) {
1742 setverdict(pass);
1743 } else {
1744 log("EXPECTED CSFB CELLS: ", csfb_expect_cells);
1745 setverdict(fail, "Received CSFB cells list on RR Channel Release does not match expectations");
1746 }
1747 }
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02001748
1749 if (not istemplatekind(expect_rr_cause, "omit")) {
1750 int2enum(oct2int(l3.msgs.rrm.channelRelease.rRCause.valuePart), got_cause);
1751 log("GOT CAUSE CODE: ", l3.msgs.rrm.channelRelease.rRCause.valuePart, " = ", got_cause);
1752 if (match(got_cause, expect_rr_cause)) {
1753 setverdict(pass);
1754 } else {
1755 log("EXPECTED CAUSE CODE: ", expect_rr_cause);
1756 setverdict(fail, "Received RR Channel Release Cause code does not match expectations");
1757 }
1758 }
Harald Welte99787102019-02-04 10:41:36 +01001759 repeat;
1760 }
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02001761 [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 +01001762 got_rr_chan_rel := true;
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02001763
1764 if (not istemplatekind(expect_rr_cause, "omit")) {
1765 if (f_rsl_find_ie(ud.rsl, RSL_IE_L3_INFO, l3_ie) == false) {
1766 setverdict(fail, "cannot find L3");
1767 mtc.stop;
1768 }
1769 l3 := dec_PDU_ML3_NW_MS(l3_ie.l3_info.payload);
1770
1771 int2enum(oct2int(l3.msgs.rrm.channelRelease.rRCause.valuePart), got_cause);
1772 log("GOT CAUSE CODE: ", l3.msgs.rrm.channelRelease.rRCause.valuePart, " = ", got_cause);
1773 if (match(got_cause, expect_rr_cause)) {
1774 setverdict(pass);
1775 } else {
1776 log("EXPECTED CAUSE CODE: ", expect_rr_cause);
1777 setverdict(fail, "Received RR Channel Release Cause code does not match expectations");
1778 }
1779 }
Neels Hofmeyr211169d2018-11-07 00:37:29 +01001780 repeat;
1781 }
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001782 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(tr_RSL_REL_REQ(rsl_chan_nr, ?))) {
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001783 got_rll_rel_req := true;
Harald Welte91d54a52018-01-28 15:35:07 +01001784 /* FIXME: Why are we getting this for LinkID SACCH? */
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001785 if (handle_rll_rel) {
1786 f_ipa_tx(0, ts_RSL_REL_CONF(rsl_chan_nr, main_dcch));
1787 }
Harald Welte91d54a52018-01-28 15:35:07 +01001788 repeat;
1789 }
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001790 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL))) {
Harald Welte91d54a52018-01-28 15:35:07 +01001791 /* respond with CHAN REL ACK */
1792 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(rsl_chan_nr));
1793 }
1794 /* ignore any user data */
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001795 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(tr_RSL_MsgTypeR(?))) {
Harald Welte91d54a52018-01-28 15:35:07 +01001796 repeat;
1797 }
1798 }
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001799
1800 log("f_expect_chan_rel() summary: got_deact_sacch=", got_deact_sacch, " got_rr_chan_rel=", got_rr_chan_rel,
1801 " got_rll_rel_req=", got_rll_rel_req);
1802
1803 if (expect_deact_sacch != got_deact_sacch) {
1804 setverdict(fail, "f_expect_chan_rel(): expect_deact_sacch=", expect_deact_sacch, " got_deact_sacch=", got_deact_sacch);
1805 }
1806 if (expect_rr_chan_rel != got_rr_chan_rel) {
1807 setverdict(fail, "f_expect_chan_rel(): expect_rr_chan_rel=", expect_rr_chan_rel, " got_rr_chan_rel=", got_rr_chan_rel);
1808 }
1809 if (expect_rll_rel_req != got_rll_rel_req) {
1810 setverdict(fail, "f_expect_chan_rel(): expect_rll_rel_req=", expect_rll_rel_req, " got_rll_rel_req=", got_rll_rel_req);
1811 }
Harald Welte91d54a52018-01-28 15:35:07 +01001812}
1813
Harald Welte4003d112017-12-09 22:35:39 +01001814/* Test behavior of channel release after hard Clear Command from MSC */
1815testcase TC_chan_rel_hard_clear() runs on test_CT {
1816 var BSSAP_N_DATA_ind rx_di;
Harald Welte4003d112017-12-09 22:35:39 +01001817 var DchanTuple dt;
Harald Welte4003d112017-12-09 22:35:39 +01001818
Harald Welte89d42e82017-12-17 16:42:41 +01001819 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +01001820
1821 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1822
1823 /* Instruct BSC to clear channel */
1824 var BssmapCause cause := 0;
1825 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
1826
1827 /* expect Clear Complete from BSC on A */
1828 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete)) {
1829 /* release the SCCP connection */
1830 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
1831 }
1832
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001833 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001834 f_shutdown_helper();
Harald Welte4003d112017-12-09 22:35:39 +01001835}
1836
Harald Welte99787102019-02-04 10:41:36 +01001837/* Test behavior of channel release after Clear Command with CSFB indicator from MSC */
1838testcase TC_chan_rel_hard_clear_csfb() runs on test_CT {
1839 var BSSAP_N_DATA_ind rx_di;
1840 var DchanTuple dt;
1841
1842 f_init(1);
1843
1844 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1845
1846 /* Instruct BSC to clear channel */
1847 var BssmapCause cause := 0;
1848 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommandCSFB(cause)));
1849
1850 /* expect Clear Complete from BSC on A */
1851 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete)) {
1852 /* release the SCCP connection */
1853 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
1854 }
1855
1856 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 +02001857 f_shutdown_helper();
Harald Welte99787102019-02-04 10:41:36 +01001858}
1859
Harald Welted8c36cd2017-12-09 23:05:31 +01001860/* Test behavior of channel release after hard RLSD from MSC */
1861testcase TC_chan_rel_hard_rlsd() runs on test_CT {
Harald Welted8c36cd2017-12-09 23:05:31 +01001862 var DchanTuple dt;
Harald Welted8c36cd2017-12-09 23:05:31 +01001863
Harald Welte89d42e82017-12-17 16:42:41 +01001864 f_init(1);
Harald Welted8c36cd2017-12-09 23:05:31 +01001865
1866 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1867
1868 /* release the SCCP connection */
1869 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
1870
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001871 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001872 f_shutdown_helper();
Harald Welted8c36cd2017-12-09 23:05:31 +01001873}
1874
Harald Welte550daf92018-06-11 19:22:13 +02001875/* Test behavior of channel release after hard RLSD from MSC and MS is not responding to RLL REL REQ */
1876testcase TC_chan_rel_hard_rlsd_ms_dead() runs on test_CT {
1877 var DchanTuple dt;
1878
1879 f_init(1);
1880
1881 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1882
1883 /* release the SCCP connection */
1884 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
1885
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001886 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001887 f_shutdown_helper();
Harald Welte550daf92018-06-11 19:22:13 +02001888}
1889
Harald Welte85804d42017-12-10 14:11:58 +01001890/* Test behavior of channel release after BSSMAP RESET from MSC */
1891testcase TC_chan_rel_a_reset() runs on test_CT {
Harald Welte85804d42017-12-10 14:11:58 +01001892 var DchanTuple dt;
Harald Welte85804d42017-12-10 14:11:58 +01001893
Harald Welte89d42e82017-12-17 16:42:41 +01001894 f_init(1);
Harald Welte85804d42017-12-10 14:11:58 +01001895
1896 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1897
1898 /* Clear the queue, it might still contain stuff like IMMEDIATE ASSIGN */
1899 IPA_RSL[0].clear;
1900
1901 /* perform BSSAP RESET, expect RESET ACK and DISC.ind on connection */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001902 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 +01001903 interleave {
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001904 [] 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 +01001905 [] BSSAP.receive(tr_BSSAP_DISC_ind(dt.sccp_conn_id, ?, ?)) { }
1906 }
1907
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001908 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001909 f_shutdown_helper();
Harald Welte85804d42017-12-10 14:11:58 +01001910}
1911
Pau Espin Pedrolc675b612020-01-09 19:55:40 +01001912/* Verify T(iar) triggers and releases the channel */
1913testcase TC_chan_rel_sccp_tiar_timeout() runs on test_CT {
1914 var DchanTuple dt;
1915
1916 /* Set T(iar) in BSC low enough that it will trigger before other side
1917 has time to keep alive with a T(ias). Keep recommended ratio of
1918 T(iar) >= T(ias)*2 */
1919 g_bsc_sccp_timer_ias := 2;
1920 g_bsc_sccp_timer_iar := 5;
1921
1922 f_init(1);
1923
1924 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1925 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001926 f_shutdown_helper();
Pau Espin Pedrolc675b612020-01-09 19:55:40 +01001927}
1928
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02001929private function f_tc_chan_rel_rr_cause(myBSSMAP_Cause clear_cmd_cause, template RR_Cause expect_rr_cause)
1930runs on test_CT
1931{
1932 var DchanTuple dt;
1933
1934 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1935 var BssmapCause cause := 0;
1936 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(enum2int(clear_cmd_cause))));
1937 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete)) {
1938 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
1939 }
1940
1941 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 +02001942 f_shutdown_helper();
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02001943}
1944
1945/* Test that Clear Command cause codes affect the RR Channel Release cause code */
1946testcase TC_chan_rel_rr_cause() runs on test_CT {
1947 f_init(1);
1948
1949 f_tc_chan_rel_rr_cause(GSM0808_CAUSE_CALL_CONTROL, GSM48_RR_CAUSE_NORMAL);
1950 f_tc_chan_rel_rr_cause(GSM0808_CAUSE_HANDOVER_SUCCESSFUL, GSM48_RR_CAUSE_NORMAL);
1951 f_tc_chan_rel_rr_cause(GSM0808_CAUSE_PREEMPTION, GSM48_RR_CAUSE_PREMPTIVE_REL);
1952 f_tc_chan_rel_rr_cause(GSM0808_CAUSE_RADIO_INTERFACE_MESSAGE_FAILURE, GSM48_RR_CAUSE_PROT_ERROR_UNSPC);
1953 f_tc_chan_rel_rr_cause(GSM0808_CAUSE_RADIO_INTERFACE_FAILURE, GSM48_RR_CAUSE_ABNORMAL_UNSPEC);
1954 f_tc_chan_rel_rr_cause(GSM0808_CAUSE_EQUIPMENT_FAILURE, GSM48_RR_CAUSE_ABNORMAL_UNSPEC);
1955}
1956
Harald Welte5cd20ed2017-12-13 21:03:20 +01001957/* Test behavior if RSL EST IND for non-active channel */
1958testcase TC_rll_est_ind_inact_lchan() runs on test_CT {
1959 timer T := 2.0;
1960
Harald Welte89d42e82017-12-17 16:42:41 +01001961 f_init(1);
Harald Welte5cd20ed2017-12-13 21:03:20 +01001962
1963 var octetstring l3 := '00010203040506'O;
1964 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(6));
1965 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
1966
1967 T.start;
1968 alt {
1969 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) {
1970 setverdict(fail, "MSC received COMPL L3 for non-active lchan");
1971 }
1972 [] BSSAP.receive {}
1973 [] IPA_RSL[0].receive {}
1974 [] T.timeout {}
1975 }
1976
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001977 f_shutdown_helper();
Harald Welte5cd20ed2017-12-13 21:03:20 +01001978}
1979
1980/* Test behavior if RSL EST IND for invalid SAPI */
1981testcase TC_rll_est_ind_inval_sapi1() runs on test_CT {
1982 var RslChannelNr chan_nr;
1983
Harald Welte89d42e82017-12-17 16:42:41 +01001984 f_init(1);
Harald Welte5cd20ed2017-12-13 21:03:20 +01001985
1986 chan_nr := f_chreq_act_ack()
1987
1988 var octetstring l3 := '00010203040506'O;
1989 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(1)), l3));
1990
1991 timer T := 2.0;
1992 T.start;
1993 alt {
1994 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) {
1995 setverdict(fail, "MSC received COMPL L3 for invalid SAPI 1");
1996 }
1997 [] BSSAP.receive { repeat; }
1998 [] IPA_RSL[0].receive { repeat; }
1999 [] T.timeout {}
2000 }
2001
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002002 f_shutdown_helper();
Harald Welte5cd20ed2017-12-13 21:03:20 +01002003}
2004
2005/* Test behavior if RSL EST IND for invalid SAPI */
2006testcase TC_rll_est_ind_inval_sapi3() runs on test_CT {
2007 timer T := 2.0;
2008
Harald Welte89d42e82017-12-17 16:42:41 +01002009 f_init(1);
Harald Welte5cd20ed2017-12-13 21:03:20 +01002010
2011 var RslChannelNr chan_nr := f_chreq_act_ack();
2012
2013 var octetstring l3 := '00010203040506'O;
2014 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(3)), l3));
2015
2016 T.start;
2017 alt {
2018 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) {
2019 setverdict(fail, "MSC received COMPL L3 for invalid SAPI 3");
2020 }
2021 [] BSSAP.receive { repeat; }
2022 [] IPA_RSL[0].receive { repeat; }
2023 [] T.timeout {}
2024 }
2025
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002026 f_shutdown_helper();
Harald Welte5cd20ed2017-12-13 21:03:20 +01002027}
2028
2029/* Test behavior if RSL EST IND for invalid SACCH */
2030testcase TC_rll_est_ind_inval_sacch() runs on test_CT {
2031 timer T := 2.0;
2032
Harald Welte89d42e82017-12-17 16:42:41 +01002033 f_init(1);
Harald Welte5cd20ed2017-12-13 21:03:20 +01002034
2035 var RslChannelNr chan_nr := f_chreq_act_ack();
2036
2037 var octetstring l3 := '00010203040506'O;
2038 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_SACCH(0)), l3));
2039
2040 T.start;
2041 alt {
2042 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) {
2043 setverdict(fail, "MSC received COMPL L3 for invalid Link SACCH");
2044 }
2045 [] BSSAP.receive { repeat; }
2046 [] IPA_RSL[0].receive { repeat; }
2047 [] T.timeout {}
2048 }
2049
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002050 f_shutdown_helper();
Harald Welte5cd20ed2017-12-13 21:03:20 +01002051}
2052
Vadim Yanitskiy61f784a2020-10-01 21:12:19 +07002053/* Verify DLCI / RSL Link ID conversion for MO/MT messages on SAPI0/SAPI3 */
2054private function f_TC_tch_dlci_link_id_sapi(charstring id) runs on MSC_ConnHdlr {
2055 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
2056 var PDU_BSSAP ass_cmd := f_gen_ass_req();
2057
2058 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
2059 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
2060
2061 f_establish_fully(ass_cmd, exp_compl);
2062
2063 /* SAPI0 has already been established by f_establish_fully(), establish SAPI3 */
2064 RSL.send(ts_RSL_EST_IND(g_chan_nr, ts_RslLinkID_SACCH(3), '0904'O));
2065 /* Expect BSSAP/DTAP on SAPI3 (DLCI IE) */
2066 BSSAP.receive(PDU_BSSAP:{
2067 discriminator := '1'B,
2068 spare := '0000000'B,
2069 dlci := 'C3'O,
2070 lengthIndicator := ?,
2071 pdu := { dtap := '0904'O }
2072 });
2073
2074 /* Send messages on DCCH/SAPI0 and ACCH/SAPI3 */
2075 for (var integer i := 0; i < 32; i := i + 1) {
2076 var octetstring l3 := '09'O & f_rnd_octstring(14);
2077 var template (value) RslLinkId link_id;
2078 var template (value) OCT1 dlci;
2079
2080 if (i mod 2 == 0) {
2081 /* SAPI0 on FACCH or SDCCH */
2082 link_id := ts_RslLinkID_DCCH(0);
2083 dlci := '80'O;
2084 } else {
2085 /* SAPI3 on SACCH */
2086 link_id := ts_RslLinkID_SACCH(3);
2087 dlci := 'C3'O;
2088 }
2089
2090 /* Send MO message: RSL -> BSSAP */
Neels Hofmeyr0aa719b2020-10-12 18:43:09 +00002091 f_mo_l3_transceive(RSL, link_id, dlci, l3);
Vadim Yanitskiy61f784a2020-10-01 21:12:19 +07002092 /* Send MT message: BSSAP -> RSL */
Neels Hofmeyr0aa719b2020-10-12 18:43:09 +00002093 f_mt_l3_transceive(RSL, link_id, dlci, l3);
Vadim Yanitskiy61f784a2020-10-01 21:12:19 +07002094 }
2095}
2096testcase TC_tch_dlci_link_id_sapi() runs on test_CT {
2097 var TestHdlrParams pars := f_gen_test_hdlr_pars();
2098 var MSC_ConnHdlr vc_conn;
2099
2100 f_init(1, true);
2101 f_sleep(1.0);
2102
2103 vc_conn := f_start_handler(refers(f_TC_tch_dlci_link_id_sapi), pars);
2104 vc_conn.done;
2105
2106 f_shutdown_helper();
2107}
2108
Vadim Yanitskiy6ef5dfa2020-08-28 18:04:41 +07002109private function f_exp_sapi_n_reject(template (present) GsmSapi sapi := ?,
2110 template myBSSMAP_Cause cause := ?,
2111 float T_val := 2.0)
2112runs on test_CT {
2113 var BSSAP_N_DATA_ind rx_di;
2114 timer T;
2115
2116 var template BSSMAP_IE_Cause tr_cause := tr_BSSMAP_IE_Cause(cause);
2117 var template PDU_BSSAP tr_pdu := tr_BSSMAP_SAPInReject(sapi);
2118
2119 T.start(T_val);
2120 alt {
2121 [] BSSAP.receive(tr_BSSAP_DATA_ind(?, tr_pdu)) -> value rx_di {
2122 var BSSMAP_IE_Cause rx_cause := rx_di.userData.pdu.bssmap.sAPInReject.cause;
2123 if (not match(rx_cause, tr_cause)) {
2124 setverdict(fail, "Rx unexpected Cause IE: ",
2125 rx_cause, " vs expected ", tr_cause);
2126 }
2127 setverdict(pass);
2128 }
2129 [] BSSAP.receive(BSSAP_N_DATA_ind:?) -> value rx_di {
2130 setverdict(fail, "Rx unexpected BSSAP PDU: ", rx_di);
2131 }
2132 [] T.timeout {
2133 setverdict(fail, "Timeout waiting for BSSMAP SAPI N Reject");
2134 }
2135 }
2136}
2137
2138/* Check if we get SAPI N Reject on receipt of unexpected RLL RELease INDication */
2139testcase TC_rll_rel_ind_sapi_n_reject() runs on test_CT {
2140 var octetstring rnd_data := f_rnd_octstring(16);
2141 var RSL_Message rx_rsl;
2142 var DchanTuple dt;
2143
2144 f_init(1);
2145
2146 /* MS establishes a SAPI=0 link on DCCH */
2147 dt := f_est_dchan(f_rnd_ra_cs(), 23, rnd_data);
2148
2149 /* MSC sends some data on (not yet established) SAPI=3 link */
2150 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSAP_DTAP(rnd_data, '03'O)));
2151 /* BSC attempts to establish a SAPI=3 link on DCCH */
2152 rx_rsl := f_exp_ipa_rx(0, tr_RSL_EST_REQ(dt.rsl_chan_nr, tr_RslLinkID_DCCH(3)));
2153
2154 /* MS sends unexpected RELease INDication on SAPI=3 */
2155 f_ipa_tx(0, ts_RSL_REL_IND(dt.rsl_chan_nr, ts_RslLinkID_DCCH(3)));
2156 /* We expect to receive BSSMAP SAPI N Reject message from the BSC */
2157 f_exp_sapi_n_reject(3, GSM0808_CAUSE_MS_NOT_EQUIPPED);
2158
2159 /* Clean up the connection */
2160 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
2161 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
2162
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002163 f_shutdown_helper();
Vadim Yanitskiy6ef5dfa2020-08-28 18:04:41 +07002164}
2165
2166/* Check if we get SAPI N Reject on receipt of unexpected RLL ERROR INDication */
2167testcase TC_rll_err_ind_sapi_n_reject() runs on test_CT {
2168 var octetstring rnd_data := f_rnd_octstring(16);
2169 var RSL_Message rx_rsl;
2170 var DchanTuple dt;
2171
2172 f_init(1);
2173
2174 /* MS establishes a SAPI=0 link on DCCH */
2175 dt := f_est_dchan(f_rnd_ra_cs(), 23, rnd_data);
2176
2177 /* MSC sends some data on (not yet established) SAPI=3 link */
2178 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSAP_DTAP(rnd_data, '03'O)));
2179 /* BSC attempts to establish a SAPI=3 link on DCCH */
2180 rx_rsl := f_exp_ipa_rx(0, tr_RSL_EST_REQ(dt.rsl_chan_nr, tr_RslLinkID_DCCH(3)));
2181
2182 /* BTS sends unexpected ERROR INDication on SAPI=3 */
2183 f_ipa_tx(0, ts_RSL_ERROR_IND(dt.rsl_chan_nr, ts_RslLinkID_DCCH(3), ''O));
2184 /* We expect to receive BSSMAP SAPI N Reject message from the BSC */
2185 f_exp_sapi_n_reject(3, GSM0808_CAUSE_BSS_NOT_EQUIPPED);
2186
2187 /* Clean up the connection */
2188 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
2189 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
2190
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002191 f_shutdown_helper();
Vadim Yanitskiy6ef5dfa2020-08-28 18:04:41 +07002192}
2193
2194/* Check if we get SAPI N Reject due to a SAPI=3 link establishment timeout */
2195testcase TC_rll_timeout_sapi_n_reject() runs on test_CT {
2196 var octetstring rnd_data := f_rnd_octstring(16);
2197 var RSL_Message rx_rsl;
2198 var DchanTuple dt;
2199
2200 f_init(1);
2201
2202 /* MS establishes a SAPI=0 link on DCCH */
2203 dt := f_est_dchan(f_rnd_ra_cs(), 23, rnd_data);
2204
2205 /* MSC sends some data on (not yet established) SAPI=3 link */
2206 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSAP_DTAP(rnd_data, '03'O)));
2207 /* BSC attempts to establish a SAPI=3 link on DCCH */
2208 rx_rsl := f_exp_ipa_rx(0, tr_RSL_EST_REQ(dt.rsl_chan_nr, tr_RslLinkID_DCCH(3)));
2209
2210 /* MS does not respond, so the link establishment timeout triggers SAPI N Reject */
2211 f_exp_sapi_n_reject(3, GSM0808_CAUSE_BSS_NOT_EQUIPPED, T_val := 8.0);
2212
2213 /* Clean up the connection */
2214 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
2215 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
2216
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002217 f_shutdown_helper();
Vadim Yanitskiy6ef5dfa2020-08-28 18:04:41 +07002218}
2219
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +02002220testcase TC_si_default() runs on test_CT {
2221 f_init(0);
2222 f_init_bts_and_check_sysinfo(0, expect_si := SystemInformationConfig_default);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002223 f_shutdown_helper();
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +02002224}
Harald Welte4003d112017-12-09 22:35:39 +01002225
Neels Hofmeyr56f24782020-07-09 00:50:49 +02002226/* We're testing SI2quater with lists of EARFCNs. Instead of just incrementing EARFCNs, also pick some from the edges of
2227 * the entire value range. This function provides the same EARFCN numbers for the same earfcn_index */
2228private function f_test_si2quater_earfcn_by_idx(integer earfcn_index) return uint16_t
2229{
2230 select (earfcn_index) {
2231 case (0) {
2232 /* E-ARFCN 111 is already added in the osmo-bsc.cfg */
2233 return 111;
2234 }
2235 case (1) {
2236 return 1;
2237 }
2238 case (2) {
2239 return 0;
2240 }
2241 case (3) {
2242 return 65535;
2243 }
2244 case else {
2245 return 23 * (earfcn_index - 3);
2246 }
2247 }
2248}
2249
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02002250function f_test_si2quater(integer total_earfcns, template SystemInformationConfig expect_si,
2251 template CellSelIndValue expect_cells := omit) runs on test_CT {
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002252
2253 f_init(0);
2254
2255 /* E-ARFCN 111 is already added in the osmo-bsc.cfg, so only add more arfcns if total_earfcns > 1 */
2256 for (var integer i := 1; i < total_earfcns; i := i + 1) {
Neels Hofmeyr56f24782020-07-09 00:50:49 +02002257 f_bts_0_cfg(BSCVTY, {"si2quater neighbor-list add earfcn " & int2str(f_test_si2quater_earfcn_by_idx(i))
2258 & " thresh-hi 20 thresh-lo 10 prio 3 qrxlv 22 meas 3"});
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002259 }
2260
2261 f_init_bts_and_check_sysinfo(0, expect_si := expect_si);
2262
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02002263 f_init(1);
2264
2265 if (not istemplatekind(expect_cells, "omit")) {
2266 /* Also check that RR Channel Release contains these EARFCNs.
2267 * (copied code from TC_chan_rel_hard_clear_csfb) */
2268 var BSSAP_N_DATA_ind rx_di;
2269 var DchanTuple dt;
2270
2271 dt := f_est_dchan('23'O, 23, '00010203040506'O);
2272
2273 /* Instruct BSC to clear channel */
2274 var BssmapCause cause := 0;
2275 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommandCSFB(cause)));
2276
2277 /* expect Clear Complete from BSC on A */
2278 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete)) {
2279 /* release the SCCP connection */
2280 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
2281 }
2282
2283 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false, is_csfb := true,
2284 csfb_expect_cells := expect_cells);
2285 }
2286
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002287 for (var integer i := 1; i < total_earfcns; i := i + 1) {
Neels Hofmeyr56f24782020-07-09 00:50:49 +02002288 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 +02002289 }
2290}
2291
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002292private function f_tr_si2quater_earfcns(integer count) return template SI2quaterRestOctetsList
2293{
2294 var template SI2quaterRestOctetsList si2quater := {};
2295 var integer si2quater_count := (count + 2) / 3;
2296
2297 for (var integer i := 0; i < count; i := i + 1) {
Neels Hofmeyr56f24782020-07-09 00:50:49 +02002298 var integer earfcn := f_test_si2quater_earfcn_by_idx(i);
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002299 var integer index := i / 3;
2300 var integer earfcn_index := i mod 3;
2301 if (index >= lengthof(si2quater)) {
2302 si2quater[index] := tr_SI2quaterRestOctets_EUTRAN(index := index, count := si2quater_count - 1);
2303 }
2304 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);
2305 }
2306
2307 return si2quater;
2308}
2309
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02002310private function f_tr_rr_chan_rel_earfcns(integer count) return template CellSelIndValue
2311{
2312 var template CellSelIndValue_EUTRAN_Descrs cells := {};
2313
Alexander Couzensf74b5cb2020-09-10 22:28:40 +02002314 /* the lte neighbors must match the config & vty to pass this test */
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02002315 for (var integer i := 0; i < count; i := i + 1) {
2316 var integer earfcn := f_test_si2quater_earfcn_by_idx(i);
Alexander Couzensf74b5cb2020-09-10 22:28:40 +02002317 cells[i] := tr_CellSelIndValue_EUTRAN_Descr(earfcn, '1'B, 3);
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02002318 }
2319
2320 return tr_CellSelIndValue_EUTRAN(cells);
2321}
2322
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002323private function f_tc_si2quater_n_earfcns(integer n) runs on test_CT
2324{
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002325 var template SystemInformationConfig sic := SystemInformationConfig_default;
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002326 sic.si2quater := f_tr_si2quater_earfcns(n);
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02002327 var template CellSelIndValue cells := f_tr_rr_chan_rel_earfcns(n);
2328 f_test_si2quater(n, sic, cells);
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002329}
2330
2331testcase TC_si2quater_2_earfcns() runs on test_CT {
2332 f_tc_si2quater_n_earfcns(2);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002333 f_shutdown_helper();
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002334}
2335
2336testcase TC_si2quater_3_earfcns() runs on test_CT {
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002337 f_tc_si2quater_n_earfcns(3);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002338 f_shutdown_helper();
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002339}
2340
2341testcase TC_si2quater_4_earfcns() runs on test_CT {
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002342 f_tc_si2quater_n_earfcns(4);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002343 f_shutdown_helper();
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002344}
2345
2346testcase TC_si2quater_5_earfcns() runs on test_CT {
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002347 f_tc_si2quater_n_earfcns(5);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002348 f_shutdown_helper();
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002349}
2350
2351testcase TC_si2quater_6_earfcns() runs on test_CT {
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002352 f_tc_si2quater_n_earfcns(6);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002353 f_shutdown_helper();
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002354}
2355
2356testcase TC_si2quater_12_earfcns() runs on test_CT {
2357 f_tc_si2quater_n_earfcns(12);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002358 f_shutdown_helper();
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002359}
2360
2361testcase TC_si2quater_23_earfcns() runs on test_CT {
2362 f_tc_si2quater_n_earfcns(23);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002363 f_shutdown_helper();
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002364}
2365
2366testcase TC_si2quater_32_earfcns() runs on test_CT {
2367 f_tc_si2quater_n_earfcns(32);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002368 f_shutdown_helper();
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002369}
2370
2371testcase TC_si2quater_33_earfcns() runs on test_CT {
2372 f_tc_si2quater_n_earfcns(33);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002373 f_shutdown_helper();
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002374}
2375
2376testcase TC_si2quater_42_earfcns() runs on test_CT {
2377 f_tc_si2quater_n_earfcns(42);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002378 f_shutdown_helper();
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002379}
2380
2381testcase TC_si2quater_48_earfcns() runs on test_CT {
2382 f_tc_si2quater_n_earfcns(48);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002383 f_shutdown_helper();
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002384}
2385
2386/* verify the VTY error response when adding too many EARFCNs, and showing that osmo-bsc still sends 16 SI2quater with
2387 * 48 EARFCNs. */
2388testcase TC_si2quater_49_earfcns() runs on test_CT {
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002389 var template SystemInformationConfig sic := SystemInformationConfig_default;
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002390 sic.si2quater := f_tr_si2quater_earfcns(48); /* 48, not 49! */
2391 f_init(0);
2392
2393 for (var integer i := 1; i < 48; i := i + 1) {
Neels Hofmeyr56f24782020-07-09 00:50:49 +02002394 f_bts_0_cfg(BSCVTY, {"si2quater neighbor-list add earfcn " & int2str(f_test_si2quater_earfcn_by_idx(i))
2395 & " thresh-hi 20 thresh-lo 10 prio 3 qrxlv 22 meas 3"});
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002396 }
2397
2398 /* The 49th EARFCN no longer fits, expect VTY error */
2399 f_vty_enter_cfg_bts(BSCVTY, 0);
2400 var charstring vty_error;
2401 vty_error := f_vty_transceive_ret(BSCVTY,
2402 "si2quater neighbor-list add earfcn 70 thresh-hi 20 thresh-lo 10 prio 3 qrxlv 22 meas 3")
2403 f_vty_transceive(BSCVTY, "end");
2404
2405 if (f_strstr(vty_error, "Unable to add ARFCN 70") >= 0) {
2406 log("Got expected VTY error: ", vty_error);
2407 setverdict(pass);
2408 } else {
2409 setverdict(fail, "Expected the 49th EUTRAN ARFCN to be rejected by vty config, got: ", vty_error);
2410 }
2411
2412 f_init_bts_and_check_sysinfo(0, expect_si := sic);
2413
2414 for (var integer i := 1; i < 48; i := i + 1) {
Neels Hofmeyr56f24782020-07-09 00:50:49 +02002415 f_bts_0_cfg(BSCVTY, {"si2quater neighbor-list del earfcn " & int2str(f_test_si2quater_earfcn_by_idx(i))});
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002416 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002417 f_shutdown_helper();
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002418}
2419
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02002420private function f_acc09_count_allowed(AccessControlClass acc) return uint8_t
2421{
2422 var uint8_t count := 0;
2423 for (var integer i := 5; i < 16; i := i + 1) {
2424 if (acc[i] == '0'B) { /* the list marks barred, we count allowed */
2425 count := count + 1;
2426 }
2427 }
2428 return count;
2429}
2430
Pau Espin Pedrolc6136cd2020-07-24 13:20:02 +02002431private function f_recv_next_si1(integer rsl_idx := 0) runs on test_CT return SystemInformationType1
2432{
2433 var ASP_RSL_Unitdata rx_rsl_ud;
2434 var SystemInformationType1 last_si1;
2435
2436 timer T := 30.0;
2437 T.start;
2438 alt {
2439 [] IPA_RSL[rsl_idx].receive(tr_ASP_RSL_UD((tr_RSL_NO_BCCH_INFO,
2440 tr_RSL_BCCH_INFO,
2441 tr_RSL_NO_SACCH_FILL,
2442 tr_RSL_SACCH_FILL))
2443 ) -> value rx_rsl_ud {
2444 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
2445 if (g_system_information[rsl_idx].si1 == omit) {
2446 repeat;
2447 }
2448 last_si1 := g_system_information[rsl_idx].si1;
2449 g_system_information[rsl_idx].si1 := omit;
2450 T.stop;
2451 }
2452 [] T.timeout { setverdict(fail, "Timeout receiving next SI1"); }
2453 }
2454 return last_si1;
2455}
2456
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02002457/* verify ACC rotate feature */
2458testcase TC_si_acc_rotate() runs on test_CT {
2459 var template SystemInformationConfig sic := SystemInformationConfig_default;
Pau Espin Pedrolc6136cd2020-07-24 13:20:02 +02002460 var SystemInformationType1 last_si1;
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02002461 var AccessControlClass acc;
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02002462 var uint8_t count;
2463 var integer times_allowed[10] := { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
2464
2465 f_init(0, guard_timeout := 60.0);
2466
2467 f_bts_0_cfg(BSCVTY, {"rach access-control-class 5 barred",
2468 "access-control-class-rotate 3",
2469 "access-control-class-rotate-quantum 1"});
2470
2471 /* Init and get first sysinfo */
2472 f_init_bts_and_check_sysinfo(0, expect_si := ?);
2473
Pau Espin Pedrolc6136cd2020-07-24 13:20:02 +02002474 for (var integer i:= 0; i < 20; i := i + 1) {
2475 last_si1 := f_recv_next_si1(0);
2476 acc := last_si1.rach_control.acc;
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02002477 count := f_acc09_count_allowed(acc);
2478 log("RSL: GOT SI1 ACC len=", count, ": ", acc);
2479
2480 if (count != 3) {
2481 log("RSL: EXPECTED SI ACC len=3");
2482 setverdict(fail, "received SI does not match expectations");
2483 break;
2484 }
2485
2486 for (var integer j := 0; j < 10; j := j + 1) {
2487 if (acc[16 - 1 - j] == '0'B) { /* the list marks barred, we count allowed */
2488 times_allowed[j] := times_allowed[j] + 1;
2489 }
2490 }
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02002491 }
2492
2493 for (var integer j := 0; j < 10; j := j + 1) {
2494 log("ACC", j, " allowed ", times_allowed[j], " times" );
2495 if (j != 5 and times_allowed[j] < 3) {
2496 setverdict(fail, "ACC", j, " ERROR: allowed ", times_allowed[j], " < 1 times");
2497 } else if (j == 5 and times_allowed[j] > 0) {
2498 setverdict(fail, "ACC", j, " ERROR: allowed ", times_allowed[j], " > 0 times");
2499 }
2500 }
2501
2502 f_bts_0_cfg(BSCVTY, {"access-control-class-rotate 10",
2503 "rach access-control-class 5 allowed"});
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002504 f_shutdown_helper();
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02002505}
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002506
Pau Espin Pedrolc6136cd2020-07-24 13:20:02 +02002507/* verify ACC startup ramp+rotate feature */
2508testcase TC_si_acc_ramp_rotate() runs on test_CT {
2509 var template SystemInformationConfig sic := SystemInformationConfig_default;
2510 var SystemInformationType1 last_si1;
2511 var AccessControlClass acc;
2512 var ASP_RSL_Unitdata rx_rsl_ud;
2513 var uint8_t count;
2514 var uint8_t prev_count;
2515 var integer times_allowed[10] := { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
2516
2517 f_init(0, guard_timeout := 80.0);
2518
2519 f_bts_0_cfg(BSCVTY, {"rach access-control-class 4 barred",
2520 "access-control-class-rotate 0",
2521 "access-control-class-rotate-quantum 1",
2522 "access-control-class-ramping",
2523 "access-control-class-ramping-step-interval 5",
2524 "access-control-class-ramping-step-size 5"});
2525
2526 /* Init and get first sysinfo */
2527 f_init_bts_and_check_sysinfo(0, expect_si := ?);
2528 last_si1 := g_system_information[0].si1;
2529 acc := last_si1.rach_control.acc;
2530 count := f_acc09_count_allowed(acc);
2531 /* Adm subset size was set to 0 above, so wait until all ACC are barred */
2532 while (count > 0) {
2533 last_si1 := f_recv_next_si1(0);
2534 acc := last_si1.rach_control.acc;
2535 count := f_acc09_count_allowed(acc);
2536 log("RSL: wait len()=0: GOT SI1 ACC len=", count, ": ", acc);
2537 }
2538
2539 /* Increase adm subset size, we should see ramping start up */
2540 f_bts_0_cfg(BSCVTY, {"access-control-class-rotate 10"});
2541 prev_count := 0;
2542 while (true) {
2543 last_si1 := f_recv_next_si1(0);
2544 acc := last_si1.rach_control.acc;
2545 count := f_acc09_count_allowed(acc);
2546 log("RSL: GOT SI1 ACC len=", count, ": ", acc);
2547
2548 if (prev_count > count) {
2549 setverdict(fail, "ACC allowed count dropped while expecting grow: ", prev_count, " -> ", count);
2550 break;
2551 }
2552
2553 if (count == 9) {
2554 break; /* Maximum reached (10 - 1 perm barred), done here */
2555 }
2556
2557 prev_count := count;
2558 }
2559
2560 setverdict(pass);
2561
2562 f_bts_0_cfg(BSCVTY, {"access-control-class-rotate 10",
2563 "rach access-control-class 4 allowed",
2564 "no access-control-class-ramping"});
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002565 f_shutdown_helper();
Pau Espin Pedrolc6136cd2020-07-24 13:20:02 +02002566}
2567
Harald Welte4003d112017-12-09 22:35:39 +01002568testcase TC_ctrl_msc_connection_status() runs on test_CT {
2569 var charstring ctrl_resp;
2570
Harald Welte89d42e82017-12-17 16:42:41 +01002571 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +01002572
2573 /* See https://osmocom.org/issues/2729 */
2574 f_ctrl_get_exp(IPA_CTRL, "msc_connection_status", "connected");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002575 f_shutdown_helper();
Harald Welte4003d112017-12-09 22:35:39 +01002576}
2577
Stefan Sperlingb041b3d2018-01-03 17:14:55 +01002578testcase TC_ctrl_msc0_connection_status() runs on test_CT {
2579 var charstring ctrl_resp;
2580
2581 f_init(1);
Stefan Sperlingb041b3d2018-01-03 17:14:55 +01002582
2583 f_ctrl_get_exp(IPA_CTRL, "msc.0.connection_status", "connected");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002584 f_shutdown_helper();
Stefan Sperlingb041b3d2018-01-03 17:14:55 +01002585}
2586
Harald Welte4003d112017-12-09 22:35:39 +01002587testcase TC_ctrl() runs on test_CT {
2588 var charstring ctrl_resp;
2589
Harald Welte89d42e82017-12-17 16:42:41 +01002590 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +01002591
2592 /* all below values must match the osmo-bsc.cfg config file used */
2593
Harald Welte6a129692018-03-17 17:30:14 +01002594 f_ctrl_get_exp(IPA_CTRL, "mcc", "001");
2595 f_ctrl_get_exp(IPA_CTRL, "mnc", "01");
Oliver Smith75aa0202019-08-19 14:17:50 +02002596 f_ctrl_get_exp(IPA_CTRL, "number-of-bts", "4");
Harald Welte4003d112017-12-09 22:35:39 +01002597
2598 var integer bts_nr := 0;
2599 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "location-area-code", "1");
2600 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "cell-identity", "0");
2601 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "oml-connection-state", "connected");
2602 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "gprs-mode", "gprs");
2603 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "rf_state", "operational,unlocked,on");
2604 f_ctrl_get_exp_trx(IPA_CTRL, bts_nr, 0, "arfcn", "871");
2605 f_ctrl_get_exp_trx(IPA_CTRL, bts_nr, 0, "max-power-reduction", "20");
2606
2607 var integer uptime := str2int(f_ctrl_get_bts(IPA_CTRL, bts_nr, "oml-uptime"));
2608 f_sleep(2.0);
2609 if (str2int(f_ctrl_get_bts(IPA_CTRL, bts_nr, "oml-uptime")) < uptime+1) {
2610 setverdict(fail, "oml-uptime not incrementing as expected");
2611 }
2612 /* TODO: Disconnect RSL, imply that OML is disconnected and check for uptime zero? */
2613
2614 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bsc", 0, "paging:attempted", 0);
2615
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002616 f_shutdown_helper();
Harald Welte96c94412017-12-09 03:12:45 +01002617}
2618
Pau Espin Pedrol5a2d7432019-06-07 19:43:45 +02002619/* Verify that Upon receival of SET "location", BSC forwards a TRAP
2620 "location-state" over the SCCPlite IPA conn */
2621testcase TC_ctrl_location() runs on test_CT {
2622 var MSC_ConnHdlr vc_conn;
2623 var integer bts_nr := 0;
2624
2625 f_init(1, true);
2626 f_sleep(1.0);
2627
2628 f_ctrl_set_bts(IPA_CTRL, bts_nr, "location", "1234567,fix3d,0.340000,0.560000,0.780000");
2629 f_ctrl_exp_trap(SCCPLITE_IPA_CTRL, "bts." & int2str(bts_nr) & ".location-state",
2630 "1234567,fix3d,0.340000,0.560000,0.780000,operational,unlocked,on,001,01");
2631
2632 f_ctrl_set(SCCPLITE_IPA_CTRL, "rf_locked", "1");
2633 f_sleep(2.0);
2634
2635 f_ctrl_set_bts(IPA_CTRL, bts_nr, "location", "1234888,fix3d,0.350000,0.570000,0.790000");
2636 f_ctrl_exp_trap(SCCPLITE_IPA_CTRL, "bts." & int2str(bts_nr) & ".location-state",
2637 "1234888,fix3d,0.350000,0.570000,0.790000,operational,locked,off,001,01");
2638
2639 /* should match the one from config */
2640 f_ctrl_set(SCCPLITE_IPA_CTRL, "rf_locked", "0");
2641
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002642 f_shutdown_helper();
Pau Espin Pedrol5a2d7432019-06-07 19:43:45 +02002643}
2644
Harald Welte6f521d82017-12-11 19:52:02 +01002645
2646/***********************************************************************
2647 * Paging Testing
2648 ***********************************************************************/
2649
2650type record Cell_Identity {
2651 GsmMcc mcc,
2652 GsmMnc mnc,
2653 GsmLac lac,
2654 GsmCellId ci
2655};
Harald Welte24135bd2018-03-17 19:27:53 +01002656private const Cell_Identity cid := { '001'H, '01'H, 1, 0 };
Stefan Sperling049a86e2018-03-20 15:51:00 +01002657private const Cell_Identity unknown_cid := { '678'H, 'f90'H, 1, 0 };
Harald Welte6f521d82017-12-11 19:52:02 +01002658
Harald Welte5d1a2202017-12-13 19:51:29 +01002659type set of integer BtsIdList;
2660
2661private function f_bts_in_list(integer bts_id, BtsIdList bts_ids) return boolean {
2662 for (var integer j := 0; j < sizeof(bts_ids); j := j + 1) {
2663 if (bts_id == bts_ids[j]) {
2664 return true;
2665 }
2666 }
2667 return false;
2668}
Harald Welte6f521d82017-12-11 19:52:02 +01002669
2670/* core paging test helper function; used by most paging test cases */
2671private function f_pageing_helper(hexstring imsi,
2672 template BSSMAP_FIELD_CellIdentificationList cid_list,
Harald Welte5d1a2202017-12-13 19:51:29 +01002673 BtsIdList bts_ids := { 0 },
Harald Welte6f521d82017-12-11 19:52:02 +01002674 template RSL_ChanNeeded rsl_chneed := omit,
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07002675 template (omit) OCT4 tmsi := omit) runs on test_CT
Harald Welte6f521d82017-12-11 19:52:02 +01002676{
2677 var template BSSMAP_IE_ChannelNeeded bssmap_chneed;
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07002678 var template MobileIdentityV mi;
Harald Welte6f521d82017-12-11 19:52:02 +01002679 var RSL_Message rx_rsl;
2680 var integer paging_group := hex2int(imsi[lengthof(imsi)-1]);
Harald Welte5d1a2202017-12-13 19:51:29 +01002681 var integer i;
Harald Welte6f521d82017-12-11 19:52:02 +01002682
2683 f_init();
Harald Welte6f521d82017-12-11 19:52:02 +01002684
2685 /* Clear the queue, it might still contain stuff like BCCH FILLING */
Harald Weltec3068592018-03-17 19:55:31 +01002686 for (i := 0; i < NUM_BTS; i := i + 1) {
2687 IPA_RSL[i].clear;
Harald Welte5d1a2202017-12-13 19:51:29 +01002688 }
Harald Welte6f521d82017-12-11 19:52:02 +01002689
2690 if (isvalue(rsl_chneed)) {
2691 /* The values of 08.08 3.2.2.36 and 08.58 9.3.40 are luckily identical */
2692 bssmap_chneed := ts_BSSMAP_IE_ChanNeeded(int2bit(enum2int(valueof(rsl_chneed)),2));
2693 } else {
2694 bssmap_chneed := omit;
2695 }
2696
Neels Hofmeyrf246a922020-05-13 02:27:10 +02002697 BSSAP.send(ts_BSSAP_UNITDATA_req(g_bssap[0].sccp_addr_peer, g_bssap[0].sccp_addr_own,
2698 ts_BSSMAP_Paging(imsi, cid_list, tmsi, bssmap_chneed)));
Harald Welte6f521d82017-12-11 19:52:02 +01002699
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07002700 if (not istemplatekind(tmsi, "omit")) {
2701 mi := t_MI_TMSI(tmsi);
Harald Welte6f521d82017-12-11 19:52:02 +01002702 } else {
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07002703 mi := tr_MI_IMSI(imsi);
Harald Welte6f521d82017-12-11 19:52:02 +01002704 }
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07002705
Harald Welte5d1a2202017-12-13 19:51:29 +01002706 for (i := 0; i < sizeof(bts_ids); i := i + 1) {
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07002707 rx_rsl := f_exp_ipa_rx(bts_ids[i], tr_RSL_PAGING_CMD(mi));
Harald Welte5d1a2202017-12-13 19:51:29 +01002708 /* check channel type, paging group */
2709 if (rx_rsl.ies[1].body.paging_group != paging_group) {
2710 setverdict(fail, "Paging for wrong paging group");
2711 }
2712 if (ispresent(rsl_chneed) and
2713 rx_rsl.ies[3].body.chan_needed.chan_needed != valueof(rsl_chneed)) {
2714 setverdict(fail, "RSL Channel Needed != BSSMAP Channel Needed");
2715 }
Harald Welte6f521d82017-12-11 19:52:02 +01002716 }
Harald Welte2fccd982018-01-31 15:48:19 +01002717 f_sleep(2.0);
Harald Welte5d1a2202017-12-13 19:51:29 +01002718 /* do a quick check on all not-included BTSs if they received paging */
2719 for (i := 0; i < NUM_BTS; i := i + 1) {
2720 timer T := 0.1;
2721 if (f_bts_in_list(i, bts_ids)) {
2722 continue;
2723 }
2724 T.start;
2725 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07002726 [] IPA_RSL[i].receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD(mi))) {
Harald Welte5d1a2202017-12-13 19:51:29 +01002727 setverdict(fail, "Paging on BTS ", i, " which is not part of ", bts_ids);
2728 }
2729 [] IPA_RSL[i].receive { repeat; }
2730 [] T.timeout { }
2731 }
Harald Welte6f521d82017-12-11 19:52:02 +01002732 }
2733
2734 setverdict(pass);
2735}
2736
Harald Welte5d1a2202017-12-13 19:51:29 +01002737const BtsIdList c_BtsId_all := { 0, 1, 2 };
Harald Welte751d3eb2018-01-31 15:51:06 +01002738const BtsIdList c_BtsId_none := { };
Harald Welte5d1a2202017-12-13 19:51:29 +01002739const BtsIdList c_BtsId_LAC1 := { 0, 1 };
2740const BtsIdList c_BtsId_LAC2 := { 2 };
2741
Harald Welte6f521d82017-12-11 19:52:02 +01002742/* PAGING by IMSI + TMSI */
2743testcase TC_paging_imsi_nochan() runs on test_CT {
2744 var BSSMAP_FIELD_CellIdentificationList cid_list;
2745 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Philipp Maier8c04b0a2018-02-23 13:48:48 +01002746 f_pageing_helper('001010100000001'H, cid_list, c_BtsId_all, omit, omit);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002747 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002748}
2749
2750/* PAGING by IMSI + TMSI */
2751testcase TC_paging_tmsi_nochan() runs on test_CT {
2752 var BSSMAP_FIELD_CellIdentificationList cid_list;
2753 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01002754 f_pageing_helper('001010100000001'H, cid_list, c_BtsId_all, omit, 'A1B2C301'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002755 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002756}
2757
2758/* Paging with different "channel needed' values */
2759testcase TC_paging_tmsi_any() runs on test_CT {
2760 var BSSMAP_FIELD_CellIdentificationList cid_list;
2761 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01002762 f_pageing_helper('001010100000002'H, cid_list, c_BtsId_all, RSL_CHANNEED_ANY, 'A1B2C302'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002763 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002764}
2765testcase TC_paging_tmsi_sdcch() runs on test_CT {
2766 var BSSMAP_FIELD_CellIdentificationList cid_list;
2767 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01002768 f_pageing_helper('001010100000003'H, cid_list, c_BtsId_all, RSL_CHANNEED_SDCCH, 'A1B2C303'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002769 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002770}
2771testcase TC_paging_tmsi_tch_f() runs on test_CT {
2772 var BSSMAP_FIELD_CellIdentificationList cid_list;
2773 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01002774 f_pageing_helper('001010000000004'H, cid_list, c_BtsId_all, RSL_CHANNEED_TCH_F, 'A1B2C304'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002775 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002776}
2777testcase TC_paging_tmsi_tch_hf() runs on test_CT {
2778 var BSSMAP_FIELD_CellIdentificationList cid_list;
2779 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01002780 f_pageing_helper('001010000000005'H, cid_list, c_BtsId_all, RSL_CHANNEED_TCH_ForH, 'A1B2C305'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002781 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002782}
2783
2784/* Paging by CGI */
2785testcase TC_paging_imsi_nochan_cgi() runs on test_CT {
2786 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2787 cid_list := { cIl_CGI := { ts_BSSMAP_CI_CGI(cid.mcc, cid.mnc, cid.lac, cid.ci) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01002788 f_pageing_helper('001010000000006'H, cid_list, { 0 });
Philipp Maier282ca4b2018-02-27 17:17:00 +01002789 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002790}
2791
2792/* Paging by LAC+CI */
2793testcase TC_paging_imsi_nochan_lac_ci() runs on test_CT {
2794 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2795 cid_list := { cIl_LAC_CI := { ts_BSSMAP_CI_LAC_CI(cid.lac, cid.ci) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01002796 f_pageing_helper('001010000000007'H, cid_list, { 0 });
Philipp Maier282ca4b2018-02-27 17:17:00 +01002797 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002798}
2799
2800/* Paging by CI */
2801testcase TC_paging_imsi_nochan_ci() runs on test_CT {
2802 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2803 cid_list := { cIl_CI := { ts_BSSMAP_CI_CI(cid.ci) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01002804 f_pageing_helper('001010000000008'H, cid_list, { 0 });
Philipp Maier282ca4b2018-02-27 17:17:00 +01002805 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002806}
2807
2808/* Paging by LAI */
2809testcase TC_paging_imsi_nochan_lai() runs on test_CT {
2810 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2811 cid_list := { cIl_LAI := { ts_BSSMAP_CI_LAI(cid.mcc, cid.mnc, cid.lac) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01002812 f_pageing_helper('001010000000009'H, cid_list, c_BtsId_LAC1);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002813 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002814}
2815
2816/* Paging by LAC */
2817testcase TC_paging_imsi_nochan_lac() runs on test_CT {
2818 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2819 cid_list := { cIl_LAC := { ts_BSSMAP_CI_LAC(cid.lac) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01002820 f_pageing_helper('001010000000010'H, cid_list, c_BtsId_LAC1);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002821 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002822}
2823
2824/* Paging by "all in BSS" */
2825testcase TC_paging_imsi_nochan_all() runs on test_CT {
2826 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2827 cid_list := { cIl_allInBSS := ''O };
Harald Welte5d1a2202017-12-13 19:51:29 +01002828 f_pageing_helper('001010000000011'H, cid_list, c_BtsId_all);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002829 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002830}
2831
Stefan Sperling7b5e1782018-03-20 19:32:43 +01002832/* Paging by PLMN+LAC+RNC; We do not implement this; Verify nothing is paged */
Harald Welte751d3eb2018-01-31 15:51:06 +01002833testcase TC_paging_imsi_nochan_plmn_lac_rnc() runs on test_CT {
2834 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2835 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 +01002836 f_pageing_helper('001010000000012'H, cid_list, c_BtsId_none);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002837 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01002838}
Harald Welte6f521d82017-12-11 19:52:02 +01002839
Stefan Sperling7b5e1782018-03-20 19:32:43 +01002840/* Paging by RNC; We do not implement this; Verify nothing is paged */
Harald Welte751d3eb2018-01-31 15:51:06 +01002841testcase TC_paging_imsi_nochan_rnc() runs on test_CT {
2842 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2843 cid_list := { cIl_RNC := { int2oct(13, 2) } };
Stefan Sperling7b5e1782018-03-20 19:32:43 +01002844 f_pageing_helper('001010000000013'H, cid_list, c_BtsId_none);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002845 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01002846}
2847
Stefan Sperling7b5e1782018-03-20 19:32:43 +01002848/* Paging by LAC+RNC; We do not implement; Verify nothing is paged */
Harald Welte751d3eb2018-01-31 15:51:06 +01002849testcase TC_paging_imsi_nochan_lac_rnc() runs on test_CT {
2850 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2851 cid_list := { cIl_LAC_RNC := { ts_BSSMAP_CI_LAC_RNC(cid.lac, 14) } };
Stefan Sperling7b5e1782018-03-20 19:32:43 +01002852 f_pageing_helper('001010000000014'H, cid_list, c_BtsId_none);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002853 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01002854}
2855
Harald Welte6f521d82017-12-11 19:52:02 +01002856/* Paging on multiple cells (multiple entries in list): Verify all of them page */
Harald Welte751d3eb2018-01-31 15:51:06 +01002857testcase TC_paging_imsi_nochan_lacs() runs on test_CT {
2858 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2859 cid_list := { cIl_LAC := { ts_BSSMAP_CI_LAC(1), ts_BSSMAP_CI_LAC(2) } };
2860 f_pageing_helper('001010000000015'H, cid_list, c_BtsId_all);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002861 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01002862}
2863
2864/* Paging on empty list: Verify none of them page */
2865testcase TC_paging_imsi_nochan_lacs_empty() runs on test_CT {
2866 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2867 cid_list := { cIl_LAC := { } };
2868 f_pageing_helper('001010000000016'H, cid_list, c_BtsId_none);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002869 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01002870}
2871
Stefan Sperling049a86e2018-03-20 15:51:00 +01002872/* Paging by CGI with unknown MCC/MNC: Verify nothing is paged. */
2873testcase TC_paging_imsi_nochan_cgi_unknown_cid() runs on test_CT {
2874 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2875 cid_list := { cIl_CGI := { ts_BSSMAP_CI_CGI(unknown_cid.mcc, unknown_cid.mnc, unknown_cid.lac, unknown_cid.ci) } };
2876 f_pageing_helper('001010000000006'H, cid_list, c_BtsId_none);
2877 f_shutdown_helper();
2878}
2879
Harald Welte6f521d82017-12-11 19:52:02 +01002880/* Verify paging retransmission interval + count */
2881/* Verify paging stops after channel establishment */
Harald Welte6f521d82017-12-11 19:52:02 +01002882/* Test behavior under paging overload */
Harald Welteae026692017-12-09 01:03:01 +01002883
Harald Weltee65d40e2017-12-13 00:09:06 +01002884/* Verify PCH load */
2885testcase TC_paging_imsi_load() runs on test_CT {
2886 var BSSMAP_FIELD_CellIdentificationList cid_list;
2887 timer T := 4.0;
Harald Welte2caa1062018-03-17 18:19:05 +01002888 timer T_retrans := 1.0;
Harald Weltee65d40e2017-12-13 00:09:06 +01002889 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01002890 f_pageing_helper('001010123456789'H, cid_list, c_BtsId_all);
Harald Weltee65d40e2017-12-13 00:09:06 +01002891
2892 /* tell BSC there is no paging space anymore */
2893 f_ipa_tx(0, ts_RSL_PAGING_LOAD_IND(0));
Harald Welte3b57ab52018-03-17 18:01:10 +01002894 f_sleep(0.2);
2895 IPA_RSL[0].clear;
Harald Weltee65d40e2017-12-13 00:09:06 +01002896
2897 /* Wait for 4 seconds if any more PAGING CMD are received on RSL. Normally,
2898 * there would be 8 retransmissions during 4 seconds */
2899 T.start;
Harald Welte2caa1062018-03-17 18:19:05 +01002900 T_retrans.start;
Harald Weltee65d40e2017-12-13 00:09:06 +01002901 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07002902 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD(?))) {
Harald Weltee65d40e2017-12-13 00:09:06 +01002903 setverdict(fail, "Received PAGING after LOAD_IND(0)");
Daniel Willmannafce8662018-07-06 23:11:32 +02002904 mtc.stop;
Harald Weltee65d40e2017-12-13 00:09:06 +01002905 }
Harald Welte2caa1062018-03-17 18:19:05 +01002906 [] T_retrans.timeout {
2907 /* re-trnsmit the zero-space LOAD IND to avoid BSC 'auto credit' */
2908 f_ipa_tx(0, ts_RSL_PAGING_LOAD_IND(0));
2909 T_retrans.start;
2910 repeat;
2911 }
Harald Weltee65d40e2017-12-13 00:09:06 +01002912 [] T.timeout {
2913 setverdict(pass);
2914 }
2915 }
Philipp Maier282ca4b2018-02-27 17:17:00 +01002916
2917 f_shutdown_helper();
Harald Weltee65d40e2017-12-13 00:09:06 +01002918}
2919
Harald Welte235ebf12017-12-15 14:18:16 +01002920/* Verify Paging Counter */
Harald Welte1ff69992017-12-14 12:31:17 +01002921testcase TC_paging_counter() runs on test_CT {
2922 var BSSMAP_FIELD_CellIdentificationList cid_list;
2923 timer T := 4.0;
2924 var integer i;
2925 var integer paging_attempted_bsc;
2926 var integer paging_attempted_bts[NUM_BTS];
2927 var integer paging_expired_bts[NUM_BTS];
2928 cid_list := valueof(ts_BSSMAP_CIL_noCell);
2929
2930 f_init();
2931
2932 /* read counters before paging */
2933 paging_attempted_bsc := f_ctrl_get_ratectr_abs(IPA_CTRL, "bsc", 0, "paging:attempted");
2934 for (i := 0; i < NUM_BTS; i := i+1) {
2935 paging_attempted_bts[i] := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", i, "paging:attempted");
2936 paging_expired_bts[i] := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", i, "paging:expired");
2937 }
2938
2939 f_pageing_helper('001230000000001'H, cid_list, c_BtsId_all);
2940
2941 /* expect the attempted pages on BSC and each BTSs to have incremented by one */
2942 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bsc", 0, "paging:attempted", paging_attempted_bsc+1);
2943 for (i := 0; i < NUM_BTS; i := i+1) {
2944 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", i, "paging:attempted",
2945 paging_attempted_bts[i]+1);
2946 }
2947
2948 /* assume that 12s later the paging on all BTSs have expired and hence incremented by 1 */
2949 f_sleep(12.0);
2950 for (i := 0; i < NUM_BTS; i := i+1) {
2951 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", i, "paging:expired",
2952 paging_expired_bts[i]+1);
2953 }
Harald Welte1ff69992017-12-14 12:31:17 +01002954
Philipp Maier282ca4b2018-02-27 17:17:00 +01002955 f_shutdown_helper();
Harald Welte1ff69992017-12-14 12:31:17 +01002956}
2957
2958
Harald Welte10985002017-12-12 09:29:15 +01002959/* Verify paging stops after A-RESET */
2960testcase TC_paging_imsi_a_reset() runs on test_CT {
2961 var BSSMAP_FIELD_CellIdentificationList cid_list;
2962 timer T := 3.0;
2963 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01002964 f_pageing_helper('001010123456789'H, cid_list, c_BtsId_all);
Harald Welte10985002017-12-12 09:29:15 +01002965
2966 /* Perform a BSSMAP Reset and wait for ACK */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02002967 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 +01002968 alt {
Neels Hofmeyrf246a922020-05-13 02:27:10 +02002969 [] 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 +01002970 [] BSSAP.receive { repeat; }
2971 }
2972
Daniel Willmanncbef3982018-07-30 09:22:40 +02002973 /* Wait to avoid a possible race condition if a paging message is
2974 * received right before the reset ACK. */
2975 f_sleep(0.2);
2976
Harald Welte10985002017-12-12 09:29:15 +01002977 /* Clear the queue, it might still contain stuff like BCCH FILLING */
Philipp Maier1e6b4422018-02-23 14:02:13 +01002978 for (var integer i := 0; i < sizeof(IPA_RSL); i := i+1) {
2979 IPA_RSL[i].clear;
2980 }
Harald Welte10985002017-12-12 09:29:15 +01002981
2982 /* Wait for 3 seconds if any more PAGING CMD are received on RSL */
2983 T.start;
2984 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07002985 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD(?))) {
Harald Welte10985002017-12-12 09:29:15 +01002986 setverdict(fail, "Received PAGING after A-RESET");
Daniel Willmannafce8662018-07-06 23:11:32 +02002987 mtc.stop;
Harald Welte10985002017-12-12 09:29:15 +01002988 }
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07002989 [] IPA_RSL[1].receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD(?))) {
Harald Welte5d1a2202017-12-13 19:51:29 +01002990 setverdict(fail, "Received PAGING after A-RESET");
Daniel Willmannafce8662018-07-06 23:11:32 +02002991 mtc.stop;
Harald Welte5d1a2202017-12-13 19:51:29 +01002992 }
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07002993 [] IPA_RSL[2].receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD(?))) {
Harald Welte5d1a2202017-12-13 19:51:29 +01002994 setverdict(fail, "Received PAGING after A-RESET");
Daniel Willmannafce8662018-07-06 23:11:32 +02002995 mtc.stop;
Harald Welte5d1a2202017-12-13 19:51:29 +01002996 }
Harald Welte10985002017-12-12 09:29:15 +01002997 [] T.timeout {
2998 setverdict(pass);
2999 }
3000 }
Philipp Maier282ca4b2018-02-27 17:17:00 +01003001
3002 f_shutdown_helper();
Harald Welte10985002017-12-12 09:29:15 +01003003}
Harald Welteae026692017-12-09 01:03:01 +01003004
Philipp Maierf45824a2019-08-14 14:44:10 +02003005/* Verify how we handle unsolicited Paging Response. In case of an unsolicit
3006 * paging response we can not know which MSC is in charge, so we will blindly
3007 * pick the first configured MSC. This behavior is required in order to make
3008 * MT-CSFB calls working because in those cases the BSC can not know that the
3009 * MSC has already paged the subscriver via SGs. So any MT-CSFB call will look
3010 * like an unsolicited Paging Response to the MSC.
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01003011 */
3012testcase TC_paging_resp_unsol() runs on test_CT {
3013
3014 f_init(1);
Philipp Maierf45824a2019-08-14 14:44:10 +02003015 timer T := 5.0;
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01003016
3017 var BSSAP_N_CONNECT_ind rx_c_ind;
3018 var DchanTuple dt;
3019 var PDU_ML3_MS_NW l3 := valueof(ts_PAG_RESP(valueof(ts_MI_IMSI_LV('001010008880018'H))));
Philipp Maierf45824a2019-08-14 14:44:10 +02003020 var octetstring rr_pag_resp := enc_PDU_ML3_MS_NW(l3);
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01003021
3022 /* Send CHAN RQD and wait for allocation; acknowledge it */
3023 dt.rsl_chan_nr := f_chreq_act_ack();
3024
3025 /* Send unsolicited Paging response (no matching Paging CMD stored in BSC) */
3026 f_ipa_tx(0, ts_RSL_EST_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0)), enc_PDU_ML3_MS_NW(l3)));
3027
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01003028
Philipp Maierf45824a2019-08-14 14:44:10 +02003029 /* Expevct a CR with a matching Paging response on the A-Interface */
3030 T.start;
3031 alt {
3032 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(rr_pag_resp))) {
3033 setverdict(pass);
3034 }
3035 [] BSSAP.receive {
3036 setverdict(fail, "Received unexpected message on A-Interface!");
3037 }
3038 [] T.timeout {
3039 setverdict(fail, "Received nothing on A-Interface!");
3040 }
3041 }
3042
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003043 f_shutdown_helper();
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01003044}
3045
Harald Welte4e9b9cc2017-12-14 18:31:02 +01003046/* Test RSL link drop causes counter increment */
3047testcase TC_rsl_drop_counter() runs on test_CT {
3048 var integer rsl_fail;
3049
Harald Welte89d42e82017-12-17 16:42:41 +01003050 f_init(1);
Harald Welte4e9b9cc2017-12-14 18:31:02 +01003051
3052 rsl_fail := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "rsl_fail");
3053
3054 bts[0].rsl.vc_IPA.stop;
3055
3056 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "rsl_fail", rsl_fail+1);
3057
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003058 f_shutdown_helper();
Harald Welte4e9b9cc2017-12-14 18:31:02 +01003059}
3060
3061/* TODO: Test OML link drop causes counter increment */
3062
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003063/* The body of TC_rsl_unknown_unit_id() and TC_oml_unknown_unit_id() tests. */
3064function f_ipa_unknown_unit_id(integer mp_bsc_ipa_port) runs on test_CT return boolean {
3065 timer T := 10.0;
3066
3067 bts[0].rsl.id := "IPA-0-RSL";
3068 bts[0].rsl.vc_IPA := IPA_Emulation_CT.create(bts[0].rsl.id & "-IPA");
3069 bts[0].rsl.ccm_pars := c_IPA_default_ccm_pars;
3070 bts[0].rsl.ccm_pars.name := "Osmocom TTCN-3 BTS Simulator";
Oliver Smith92c2bdb2019-08-20 15:11:24 +02003071 bts[0].rsl.ccm_pars.unit_id := "99/0/0"; /* value which is unknown at BTS */
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003072
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003073 f_ipa_ctrl_start(mp_bsc_ip, mp_bsc_ctrl_port);
3074
3075 f_init_mgcp("VirtMSC");
3076
3077 /* start RSL/OML connection (XXX re-uses RSL port/protocol definitions for OML) */
3078 map(bts[0].rsl.vc_IPA:IPA_PORT, system:IPA);
3079 connect(bts[0].rsl.vc_IPA:IPA_RSL_PORT, self:IPA_RSL[0]);
3080 bts[0].rsl.vc_IPA.start(IPA_Emulation.main_client(mp_bsc_ip, mp_bsc_ipa_port, "", 10000, bts[0].rsl.ccm_pars));
3081
3082 /* wait for IPA OML link to connect and then disconnect */
3083 T.start;
3084 alt {
Vadim Yanitskiya2afacc2020-05-18 21:16:19 +07003085 [] IPA_RSL[0].receive(tr_ASP_IPA_EV(ASP_IPA_EVENT_DOWN)) {
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003086 T.stop;
3087 return true;
3088 }
3089 [] IPA_RSL[0].receive { repeat }
3090 [] T.timeout {
Daniel Willmannafce8662018-07-06 23:11:32 +02003091 return false;
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003092 }
3093 }
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003094 return false;
3095}
3096
3097/* BSC should close an RSL connection from a BTS with unknown unit ID (OS#2714). */
3098testcase TC_rsl_unknown_unit_id() runs on test_CT {
3099 if (f_ipa_unknown_unit_id(mp_bsc_rsl_port)) {
3100 setverdict(pass);
3101 } else {
3102 setverdict(fail, "Timeout RSL waiting for connection to close");
3103 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003104 f_shutdown_helper();
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003105}
3106
3107
3108/* BSC should close an RSL connection from a BTS with unknown unit ID (OS#2714). */
3109testcase TC_oml_unknown_unit_id() runs on test_CT {
3110 if (f_ipa_unknown_unit_id(mp_bsc_oml_port)) {
3111 setverdict(pass);
3112 } else {
3113 setverdict(fail, "Timeout OML waiting for connection to close");
3114 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003115 f_shutdown_helper();
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003116}
3117
3118
Harald Weltec1a2fff2017-12-17 11:06:19 +01003119/***********************************************************************
Harald Welte6811d102019-04-14 22:23:14 +02003120 * "New world" test cases using RSL_Emulation + RAN_Emulation
Harald Weltec1a2fff2017-12-17 11:06:19 +01003121 ***********************************************************************/
3122
Harald Welte6811d102019-04-14 22:23:14 +02003123import from RAN_Emulation all;
Harald Welte47cd0e32020-08-21 12:39:11 +02003124import from BSSAP_LE_Emulation all;
Harald Weltec1a2fff2017-12-17 11:06:19 +01003125import from RSL_Emulation all;
3126import from MSC_ConnectionHandler all;
3127
3128type function void_fn(charstring id) runs on MSC_ConnHdlr;
3129
Harald Welte336820c2018-05-31 20:34:52 +02003130/* helper function to create and connect a MSC_ConnHdlr component */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003131private function f_connect_handler(inout MSC_ConnHdlr vc_conn, integer bssap_idx := 0) runs on test_CT {
3132 connect(vc_conn:RAN, g_bssap[bssap_idx].vc_RAN:PROC);
Daniel Willmann191e0d92018-01-17 12:44:35 +01003133 connect(vc_conn:MGCP_PROC, vc_MGCP:MGCP_PROC);
Harald Weltec1a2fff2017-12-17 11:06:19 +01003134 connect(vc_conn:RSL, bts[0].rsl.vc_RSL:CLIENT_PT);
Harald Weltef70df652018-01-29 22:00:23 +01003135 connect(vc_conn:RSL_PROC, bts[0].rsl.vc_RSL:RSL_PROC);
Philipp Maier88f4ae82018-03-01 14:00:58 +01003136 if (isvalue(bts[1])) {
Philipp Maier956a92f2018-02-16 10:58:07 +01003137 connect(vc_conn:RSL1, bts[1].rsl.vc_RSL:CLIENT_PT);
3138 connect(vc_conn:RSL1_PROC, bts[1].rsl.vc_RSL:RSL_PROC);
3139 }
Neels Hofmeyr91401012019-07-11 00:42:35 +02003140 if (isvalue(bts[2])) {
3141 connect(vc_conn:RSL2, bts[2].rsl.vc_RSL:CLIENT_PT);
3142 connect(vc_conn:RSL2_PROC, bts[2].rsl.vc_RSL:RSL_PROC);
3143 }
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003144 connect(vc_conn:BSSAP, g_bssap[bssap_idx].vc_RAN:CLIENT);
Neels Hofmeyrcfe44062020-10-15 02:28:08 +02003145 if (mp_enable_lcs_tests) {
3146 connect(vc_conn:BSSAP_LE, g_bssap_le.vc_BSSAP_LE:CLIENT);
3147 connect(vc_conn:BSSAP_LE_PROC, g_bssap_le.vc_BSSAP_LE:PROC);
3148 }
Daniel Willmann191e0d92018-01-17 12:44:35 +01003149 connect(vc_conn:MGCP, vc_MGCP:MGCP_CLIENT);
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +02003150 connect(vc_conn:MGCP_MULTI, vc_MGCP:MGCP_CLIENT_MULTI);
Daniel Willmannebdecc02020-08-12 15:30:17 +02003151 connect(vc_conn:STATSD_PROC, vc_STATSD:STATSD_PROC);
Harald Welte336820c2018-05-31 20:34:52 +02003152}
3153
3154function f_start_handler(void_fn fn, template (omit) TestHdlrParams pars := omit)
3155runs on test_CT return MSC_ConnHdlr {
3156 var charstring id := testcasename();
3157 var MSC_ConnHdlr vc_conn;
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003158 var integer bssap_idx := 0;
3159 if (isvalue(pars)) {
3160 bssap_idx := valueof(pars).mscpool.bssap_idx;
3161 }
Harald Welte336820c2018-05-31 20:34:52 +02003162 vc_conn := MSC_ConnHdlr.create(id);
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003163 f_connect_handler(vc_conn, bssap_idx);
Harald Weltea0630032018-03-20 21:09:55 +01003164 vc_conn.start(f_handler_init(fn, id, pars));
Harald Weltec1a2fff2017-12-17 11:06:19 +01003165 return vc_conn;
3166}
3167
Harald Weltea0630032018-03-20 21:09:55 +01003168/* first function inside ConnHdlr component; sets g_pars + starts function */
3169private function f_handler_init(void_fn fn, charstring id, template (omit) TestHdlrParams pars := omit)
3170runs on MSC_ConnHdlr {
3171 if (isvalue(pars)) {
3172 g_pars := valueof(pars);
3173 }
3174 fn.apply(id);
3175}
3176
Harald Welte3c86ea02018-05-10 22:28:05 +02003177/* Establish signalling channel (non-assignment case) followed by cipher mode */
3178private function f_tc_ciph_mode_a5(charstring id) runs on MSC_ConnHdlr {
Harald Welteed848512018-05-24 22:27:58 +02003179 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3180 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte3c86ea02018-05-10 22:28:05 +02003181 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeSIGNAL);
Philipp Maier23000732018-05-18 11:25:37 +02003182 ass_cmd.pdu.bssmap.assignmentRequest.circuitIdentityCode := omit;
3183 ass_cmd.pdu.bssmap.assignmentRequest.aoIPTransportLayer := omit;
3184 exp_compl.pdu.bssmap.assignmentComplete.circuitIdentityCode := omit;
3185 exp_compl.pdu.bssmap.assignmentComplete.aoIPTransportLayer := omit;
Harald Welte3c86ea02018-05-10 22:28:05 +02003186
Philipp Maier23000732018-05-18 11:25:37 +02003187 f_establish_fully(ass_cmd, exp_compl);
Harald Welte3c86ea02018-05-10 22:28:05 +02003188}
3189testcase TC_ciph_mode_a5_0() runs on test_CT {
3190 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02003191 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte3c86ea02018-05-10 22:28:05 +02003192 pars.encr := valueof(t_EncrParams('01'O, f_rnd_octstring(8)));
3193
3194 f_init(1, true);
3195 f_sleep(1.0);
3196 vc_conn := f_start_handler(refers(f_tc_ciph_mode_a5), pars);
3197 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003198 f_shutdown_helper();
Harald Welte3c86ea02018-05-10 22:28:05 +02003199}
3200testcase TC_ciph_mode_a5_1() runs on test_CT {
3201 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02003202 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte3c86ea02018-05-10 22:28:05 +02003203 pars.encr := valueof(t_EncrParams('02'O, f_rnd_octstring(8)));
3204
3205 f_init(1, true);
3206 f_sleep(1.0);
3207 vc_conn := f_start_handler(refers(f_tc_ciph_mode_a5), pars);
3208 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003209 f_shutdown_helper();
Harald Welte3c86ea02018-05-10 22:28:05 +02003210}
3211testcase TC_ciph_mode_a5_3() runs on test_CT {
3212 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02003213 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte3c86ea02018-05-10 22:28:05 +02003214 pars.encr := valueof(t_EncrParams('08'O, f_rnd_octstring(8)));
3215
3216 f_init(1, true);
3217 f_sleep(1.0);
3218 vc_conn := f_start_handler(refers(f_tc_ciph_mode_a5), pars);
3219 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003220 f_shutdown_helper();
Harald Welte3c86ea02018-05-10 22:28:05 +02003221}
3222
Pau Espin Pedrol07866632020-09-03 19:10:55 +02003223/* establish initial channel, enable ciphering followed by assignment to ciphered channel */
3224private function f_tc_assignment_aoip_tla_v6(charstring id) runs on MSC_ConnHdlr {
3225 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3226 var PDU_BSSAP ass_cmd := f_gen_ass_req(aoip_tla := "::3");
3227 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3228 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
3229
3230 f_establish_fully(ass_cmd, exp_compl);
3231}
3232testcase TC_assignment_aoip_tla_v6() runs on test_CT {
3233 var MSC_ConnHdlr vc_conn;
3234 var TestHdlrParams pars := f_gen_test_hdlr_pars();
3235
3236 f_init(1, true);
3237 f_sleep(1.0);
3238 vc_conn := f_start_handler(refers(f_tc_assignment_aoip_tla_v6), pars);
3239 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003240 f_shutdown_helper();
Pau Espin Pedrol07866632020-09-03 19:10:55 +02003241}
3242
Harald Welte3c86ea02018-05-10 22:28:05 +02003243
3244/* establish initial channel, enable ciphering followed by assignment to ciphered channel */
Harald Welte651fcdc2018-05-10 20:23:16 +02003245private function f_tc_assignment_fr_a5(charstring id) runs on MSC_ConnHdlr {
Harald Welteed848512018-05-24 22:27:58 +02003246 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3247 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Weltec1a2fff2017-12-17 11:06:19 +01003248
Harald Welte552620d2017-12-16 23:21:36 +01003249 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3250 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
Harald Welte73cd2712017-12-17 00:44:52 +01003251
Harald Weltea0630032018-03-20 21:09:55 +01003252 f_establish_fully(ass_cmd, exp_compl);
Harald Welte552620d2017-12-16 23:21:36 +01003253}
Harald Welte552620d2017-12-16 23:21:36 +01003254testcase TC_assignment_fr_a5_0() runs on test_CT {
3255 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02003256 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte651fcdc2018-05-10 20:23:16 +02003257 pars.encr := valueof(t_EncrParams('01'O, f_rnd_octstring(8)));
Harald Welte552620d2017-12-16 23:21:36 +01003258
Harald Welte89d42e82017-12-17 16:42:41 +01003259 f_init(1, true);
Harald Welte552620d2017-12-16 23:21:36 +01003260 f_sleep(1.0);
Harald Welte651fcdc2018-05-10 20:23:16 +02003261 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5), pars);
Harald Welte552620d2017-12-16 23:21:36 +01003262 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003263 f_shutdown_helper();
Harald Welte552620d2017-12-16 23:21:36 +01003264}
Harald Welte552620d2017-12-16 23:21:36 +01003265testcase TC_assignment_fr_a5_1() runs on test_CT {
Harald Weltec1a2fff2017-12-17 11:06:19 +01003266 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02003267 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte651fcdc2018-05-10 20:23:16 +02003268 pars.encr := valueof(t_EncrParams('02'O, f_rnd_octstring(8)));
Harald Weltec1a2fff2017-12-17 11:06:19 +01003269
Harald Welte89d42e82017-12-17 16:42:41 +01003270 f_init(1, true);
Harald Weltec1a2fff2017-12-17 11:06:19 +01003271 f_sleep(1.0);
Harald Welte651fcdc2018-05-10 20:23:16 +02003272 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5), pars);
3273 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003274 f_shutdown_helper();
Harald Welte651fcdc2018-05-10 20:23:16 +02003275}
3276testcase TC_assignment_fr_a5_3() runs on test_CT {
3277 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02003278 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte651fcdc2018-05-10 20:23:16 +02003279 pars.encr := valueof(t_EncrParams('08'O, f_rnd_octstring(8)));
Harald Weltec1a2fff2017-12-17 11:06:19 +01003280
Harald Welte651fcdc2018-05-10 20:23:16 +02003281 f_init(1, true);
3282 f_sleep(1.0);
3283 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5), pars);
Harald Weltec1a2fff2017-12-17 11:06:19 +01003284 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003285 f_shutdown_helper();
Harald Weltec1a2fff2017-12-17 11:06:19 +01003286}
3287
Harald Welte552620d2017-12-16 23:21:36 +01003288/* Expect ASSIGNMENT FAIL if mandatory IE is missing */
3289private function f_tc_assignment_fr_a5_1_codec_missing(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02003290 g_pars := f_gen_test_hdlr_pars();
Harald Welte552620d2017-12-16 23:21:36 +01003291 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
Harald Welteed848512018-05-24 22:27:58 +02003292 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte552620d2017-12-16 23:21:36 +01003293 const OCT8 kc := '0001020304050607'O;
3294
3295 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02003296 /* Omit: ass_cmd.pdu.bssmap.assignmentRequest.codecList */
3297
Harald Weltea0630032018-03-20 21:09:55 +01003298 f_establish_fully(ass_cmd, exp_fail);
Harald Welte552620d2017-12-16 23:21:36 +01003299}
Harald Welte552620d2017-12-16 23:21:36 +01003300testcase TC_assignment_fr_a5_1_codec_missing() runs on test_CT {
3301 var MSC_ConnHdlr vc_conn;
3302
Harald Welte89d42e82017-12-17 16:42:41 +01003303 f_init(1, true);
Harald Welte552620d2017-12-16 23:21:36 +01003304 f_sleep(1.0);
3305
Harald Welte8863fa12018-05-10 20:15:27 +02003306 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5_1_codec_missing));
Harald Welte552620d2017-12-16 23:21:36 +01003307 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003308 f_shutdown_helper();
Harald Welte552620d2017-12-16 23:21:36 +01003309}
3310
Harald Welte552620d2017-12-16 23:21:36 +01003311private function f_tc_assignment_fr_a5_4(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02003312 g_pars := f_gen_test_hdlr_pars();
Harald Welteed848512018-05-24 22:27:58 +02003313 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3314 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte552620d2017-12-16 23:21:36 +01003315 const OCT8 kc := '0001020304050607'O;
3316 const OCT16 kc128 := kc & kc;
3317
3318 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3319 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
Harald Weltea0630032018-03-20 21:09:55 +01003320 f_establish_fully(ass_cmd, exp_compl);
Harald Welte38b2a102017-12-23 02:42:58 +01003321 f_cipher_mode('10'O, kc, kc128, true);
Harald Welte552620d2017-12-16 23:21:36 +01003322 /* TODO: expect GSM0808_CAUSE_CIPHERING_ALGORITHM_NOT_SUPPORTED cause value */
Harald Welte552620d2017-12-16 23:21:36 +01003323}
Harald Welte552620d2017-12-16 23:21:36 +01003324testcase TC_assignment_fr_a5_4() runs on test_CT {
3325 var MSC_ConnHdlr vc_conn;
3326
Harald Welte89d42e82017-12-17 16:42:41 +01003327 f_init(1, true);
Harald Welte552620d2017-12-16 23:21:36 +01003328 f_sleep(1.0);
3329
Harald Welte8863fa12018-05-10 20:15:27 +02003330 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5_4));
Harald Welte552620d2017-12-16 23:21:36 +01003331 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003332 f_shutdown_helper();
Harald Welte552620d2017-12-16 23:21:36 +01003333}
3334
3335
Harald Welte4532e0a2017-12-23 02:05:44 +01003336private function f_tc_assignment_sign(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02003337 g_pars := f_gen_test_hdlr_pars();
Harald Welte4532e0a2017-12-23 02:05:44 +01003338 var template PDU_BSSAP exp_compl := tr_BSSMAP_AssignmentComplete(omit, omit);
Philipp Maier48604732018-10-09 15:00:37 +02003339 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte4532e0a2017-12-23 02:05:44 +01003340 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeSIGNAL);
Daniel Willmannebdecc02020-08-12 15:30:17 +02003341
3342 f_statsd_reset();
Harald Weltea0630032018-03-20 21:09:55 +01003343 f_establish_fully(ass_cmd, exp_compl);
Daniel Willmannebdecc02020-08-12 15:30:17 +02003344
3345 var StatsDExpects expect := {
Daniel Willmannc5398f72020-09-21 10:41:35 +02003346 { name := "TTCN3.bts.0.chreq.total", mtype := "c", min := 1, max := 1},
3347 { name := "TTCN3.bts.0.chreq.successful", mtype := "c", min := 1, max := 1},
Daniel Willmannebdecc02020-08-12 15:30:17 +02003348 { name := "TTCN3.bsc.0.assignment.attempted", mtype := "c", min := 1, max := 1},
3349 { name := "TTCN3.bsc.0.assignment.completed", mtype := "c", min := 1, max := 1}
3350 };
3351 f_statsd_expect(expect);
Harald Welte4532e0a2017-12-23 02:05:44 +01003352}
3353
3354testcase TC_assignment_sign() runs on test_CT {
3355 var MSC_ConnHdlr vc_conn;
3356
3357 f_init(1, true);
3358 f_sleep(1.0);
3359
Harald Welte8863fa12018-05-10 20:15:27 +02003360 vc_conn := f_start_handler(refers(f_tc_assignment_sign));
Harald Welte4532e0a2017-12-23 02:05:44 +01003361 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003362 f_shutdown_helper();
Harald Welte4532e0a2017-12-23 02:05:44 +01003363}
3364
Harald Welte60aa5762018-03-21 19:33:13 +01003365/***********************************************************************
3366 * Codec (list) testing
3367 ***********************************************************************/
3368
3369/* check if the given rsl_mode is compatible with the a_elem */
3370private function f_match_codec(BSSMAP_FIELD_CodecElement a_elem, RSL_IE_ChannelMode rsl_mode)
3371return boolean {
3372 select (a_elem.codecType) {
3373 case (GSM_FR) {
3374 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM1))) {
3375 return true;
3376 }
3377 }
3378 case (GSM_HR) {
3379 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_H, RSL_CMOD_SP_GSM1))) {
3380 return true;
3381 }
3382 }
3383 case (GSM_EFR) {
3384 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM2))) {
3385 return true;
3386 }
3387 }
3388 case (FR_AMR) {
3389 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM3))) {
3390 return true;
3391 }
3392 }
3393 case (HR_AMR) {
3394 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_H, RSL_CMOD_SP_GSM3))) {
3395 return true;
3396 }
3397 }
3398 case else { }
3399 }
3400 return false;
3401}
3402
3403/* check if the given rsl_mode is compatible with the a_list */
3404private function f_match_codecs(BSSMAP_IE_SpeechCodecList a_list, RSL_IE_ChannelMode rsl_mode)
3405return boolean {
3406 for (var integer i := 0; i < sizeof(a_list); i := i+1) {
3407 if (f_match_codec(a_list.codecElements[i], rsl_mode)) {
3408 return true;
3409 }
3410 }
3411 return false;
3412}
3413
3414/* determine BSSMAP_IE_ChannelType from *first* element of BSSMAP_FIELD_CodecElement */
Philipp Maier61f6b572018-07-06 14:03:38 +02003415function f_BSSMAP_chtype_from_codec(BSSMAP_FIELD_CodecElement a_elem)
Harald Welte60aa5762018-03-21 19:33:13 +01003416return BSSMAP_IE_ChannelType {
3417 /* FIXME: actually look at all elements of BSSMAP_IE_SpeechCodecList */
3418 var BSSMAP_IE_ChannelType ret := valueof(ts_BSSMAP_IE_ChannelType);
3419 select (a_elem.codecType) {
3420 case (GSM_FR) {
3421 ret.channelRateAndType := ChRate_TCHF;
3422 ret.speechId_DataIndicator := Spdi_TCHF_FR;
3423 }
3424 case (GSM_HR) {
3425 ret.channelRateAndType := ChRate_TCHH;
3426 ret.speechId_DataIndicator := Spdi_TCHH_HR;
3427 }
3428 case (GSM_EFR) {
3429 ret.channelRateAndType := ChRate_TCHF;
3430 ret.speechId_DataIndicator := Spdi_TCHF_EFR;
3431 }
3432 case (FR_AMR) {
3433 ret.channelRateAndType := ChRate_TCHF;
3434 ret.speechId_DataIndicator := Spdi_TCHF_AMR;
3435 }
3436 case (HR_AMR) {
3437 ret.channelRateAndType := ChRate_TCHH;
3438 ret.speechId_DataIndicator := Spdi_TCHH_AMR;
3439 }
3440 case else {
3441 setverdict(fail, "Unsupported codec ", a_elem);
Daniel Willmannafce8662018-07-06 23:11:32 +02003442 mtc.stop;
Harald Welte60aa5762018-03-21 19:33:13 +01003443 }
3444 }
3445 return ret;
3446}
3447
Harald Weltea63b9102018-03-22 20:36:16 +01003448private function f_rsl_chmod_tmpl_from_codec(BSSMAP_FIELD_CodecElement a_elem)
3449return template RSL_IE_Body {
3450 var template RSL_IE_Body mode_ie := {
3451 chan_mode := {
3452 len := ?,
3453 reserved := ?,
3454 dtx_d := ?,
3455 dtx_u := ?,
3456 spd_ind := RSL_SPDI_SPEECH,
3457 ch_rate_type := -,
3458 coding_alg_rate := -
3459 }
3460 }
3461
3462 select (a_elem.codecType) {
3463 case (GSM_FR) {
3464 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_F;
3465 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM1;
3466 }
3467 case (GSM_HR) {
3468 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_H;
3469 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM1;
3470 }
3471 case (GSM_EFR) {
3472 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_F;
3473 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM2;
3474 }
3475 case (FR_AMR) {
3476 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_F;
3477 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM3;
3478 }
3479 case (HR_AMR) {
3480 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_H;
3481 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM3;
3482 }
3483 }
3484 return mode_ie;
3485}
3486
Harald Welte60aa5762018-03-21 19:33:13 +01003487type record CodecListTest {
3488 BSSMAP_IE_SpeechCodecList codec_list,
3489 charstring id
3490}
3491type record of CodecListTest CodecListTests
3492
3493private function f_TC_assignment_codec(charstring id) runs on MSC_ConnHdlr {
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02003494 var PDU_BSSAP ass_cmd := f_gen_ass_req(g_pars.use_osmux);
3495 var template PDU_BSSAP exp_compl := f_gen_exp_compl(g_pars.use_osmux);
Harald Welte60aa5762018-03-21 19:33:13 +01003496
3497 /* puzzle together the ASSIGNMENT REQ for given codec[s] */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003498 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
Harald Welte79f3f542018-05-25 20:02:37 +02003499 ass_cmd.pdu.bssmap.assignmentRequest.codecList := g_pars.ass_codec_list;
3500 exp_compl.pdu.bssmap.assignmentComplete.speechCodec.codecElements[0] :=
3501 g_pars.ass_codec_list.codecElements[0];
Philipp Maierd0e64b02019-03-13 14:15:23 +01003502 if (isvalue(g_pars.expect_mr_s0_s7)) {
3503 exp_compl.pdu.bssmap.assignmentComplete.speechCodec.codecElements[0].s0_7 :=
3504 g_pars.expect_mr_s0_s7;
3505 }
Harald Welte79f3f542018-05-25 20:02:37 +02003506 }
Harald Welte60aa5762018-03-21 19:33:13 +01003507 ass_cmd.pdu.bssmap.assignmentRequest.channelType :=
3508 f_BSSMAP_chtype_from_codec(g_pars.ass_codec_list.codecElements[0]);
Harald Welte60aa5762018-03-21 19:33:13 +01003509 log("expecting ASS COMPL like this: ", exp_compl);
3510
3511 f_establish_fully(ass_cmd, exp_compl);
Harald Weltea63b9102018-03-22 20:36:16 +01003512
3513 /* Verify that the RSL-side activation actually matches our expectations */
3514 var RSL_Message rsl := f_rslem_get_last_act(RSL_PROC, 0, g_chan_nr);
3515
3516 var RSL_IE_Body mode_ie;
3517 if (f_rsl_find_ie(rsl, RSL_IE_CHAN_MODE, mode_ie) == false) {
3518 setverdict(fail, "Couldn't find CHAN_MODE IE");
Daniel Willmannafce8662018-07-06 23:11:32 +02003519 mtc.stop;
Harald Weltea63b9102018-03-22 20:36:16 +01003520 }
3521 var template RSL_IE_Body t_mode_ie := f_rsl_chmod_tmpl_from_codec(g_pars.ass_codec_list.codecElements[0]);
3522 if (not match(mode_ie, t_mode_ie)) {
3523 setverdict(fail, "RSL Channel Mode IE doesn't match expectation");
3524 }
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02003525
3526 var RSL_IE_Body mr_conf;
3527 if (g_pars.expect_mr_conf_ie != omit) {
3528 if (f_rsl_find_ie(rsl, RSL_IE_MR_CONFIG, mr_conf) == false) {
3529 setverdict(fail, "Missing MR CONFIG IE in RSL Chan Activ");
Daniel Willmannafce8662018-07-06 23:11:32 +02003530 mtc.stop;
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02003531 }
3532 log("found RSL MR CONFIG IE: ", mr_conf);
3533
3534 if (not match(mr_conf, g_pars.expect_mr_conf_ie)) {
3535 setverdict(fail, "RSL MR CONFIG IE does not match expectation. Expected: ",
3536 g_pars.expect_mr_conf_ie);
3537 }
3538 } else {
3539 if (f_rsl_find_ie(rsl, RSL_IE_MR_CONFIG, mr_conf) == true) {
3540 log("found RSL MR CONFIG IE: ", mr_conf);
3541 setverdict(fail, "Found MR CONFIG IE in RSL Chan Activ, expecting omit");
Daniel Willmannafce8662018-07-06 23:11:32 +02003542 mtc.stop;
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02003543 }
3544 }
Harald Welte60aa5762018-03-21 19:33:13 +01003545}
3546
Philipp Maierd0e64b02019-03-13 14:15:23 +01003547private function f_TC_assignment_codec_fail(charstring id) runs on MSC_ConnHdlr {
3548
3549 var PDU_BSSAP ass_cmd := f_gen_ass_req();
3550 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
3551
3552 /* puzzle together the ASSIGNMENT REQ for given codec[s] */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003553 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
Philipp Maierd0e64b02019-03-13 14:15:23 +01003554 ass_cmd.pdu.bssmap.assignmentRequest.codecList := g_pars.ass_codec_list;
3555 }
3556 ass_cmd.pdu.bssmap.assignmentRequest.channelType :=
3557 f_BSSMAP_chtype_from_codec(g_pars.ass_codec_list.codecElements[0]);
3558 log("expecting ASS FAIL like this: ", exp_fail);
3559
3560 f_establish_fully(ass_cmd, exp_fail);
3561}
3562
Harald Welte60aa5762018-03-21 19:33:13 +01003563testcase TC_assignment_codec_fr() runs on test_CT {
Philipp Maier48604732018-10-09 15:00:37 +02003564 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte60aa5762018-03-21 19:33:13 +01003565 var MSC_ConnHdlr vc_conn;
3566
3567 f_init(1, true);
3568 f_sleep(1.0);
3569
3570 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
Harald Welte8863fa12018-05-10 20:15:27 +02003571 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01003572 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003573 f_shutdown_helper();
Harald Welte60aa5762018-03-21 19:33:13 +01003574}
3575
3576testcase TC_assignment_codec_hr() runs on test_CT {
Philipp Maier48604732018-10-09 15:00:37 +02003577 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte60aa5762018-03-21 19:33:13 +01003578 var MSC_ConnHdlr vc_conn;
3579
3580 f_init(1, true);
3581 f_sleep(1.0);
3582
3583 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR}));
Harald Welte8863fa12018-05-10 20:15:27 +02003584 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01003585 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003586 f_shutdown_helper();
Harald Welte60aa5762018-03-21 19:33:13 +01003587}
3588
3589testcase TC_assignment_codec_efr() runs on test_CT {
Philipp Maier48604732018-10-09 15:00:37 +02003590 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte60aa5762018-03-21 19:33:13 +01003591 var MSC_ConnHdlr vc_conn;
3592
3593 f_init(1, true);
3594 f_sleep(1.0);
3595
3596 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecEFR}));
Harald Welte8863fa12018-05-10 20:15:27 +02003597 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01003598 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003599 f_shutdown_helper();
Harald Welte60aa5762018-03-21 19:33:13 +01003600}
3601
Philipp Maierd0e64b02019-03-13 14:15:23 +01003602/* Allow 5,90k only (current default config) */
3603private function f_allow_amr_rate_5_90k() runs on test_CT {
3604 f_vty_enter_cfg_msc(BSCVTY, 0);
3605 f_vty_transceive(BSCVTY, "amr-config 12_2k forbidden");
3606 f_vty_transceive(BSCVTY, "amr-config 10_2k forbidden");
3607 f_vty_transceive(BSCVTY, "amr-config 7_95k forbidden");
3608 f_vty_transceive(BSCVTY, "amr-config 7_40k forbidden");
3609 f_vty_transceive(BSCVTY, "amr-config 6_70k forbidden");
3610 f_vty_transceive(BSCVTY, "amr-config 5_90k allowed");
3611 f_vty_transceive(BSCVTY, "amr-config 5_15k forbidden");
3612 f_vty_transceive(BSCVTY, "amr-config 4_75k forbidden");
3613 f_vty_transceive(BSCVTY, "exit");
3614 f_vty_transceive(BSCVTY, "exit");
3615}
3616
3617/* Allow 4,75k, 5,90k, 4,70k and 12,2k, which are the most common rates
3618 * ("Config-NB-Code = 1") */
3619private function f_allow_amr_rate_4_75k_5_90k_7_40k_12_20k() runs on test_CT {
3620 f_vty_enter_cfg_msc(BSCVTY, 0);
3621 f_vty_transceive(BSCVTY, "amr-config 12_2k allowed");
3622 f_vty_transceive(BSCVTY, "amr-config 10_2k forbidden");
3623 f_vty_transceive(BSCVTY, "amr-config 7_95k forbidden");
3624 f_vty_transceive(BSCVTY, "amr-config 7_40k allowed");
3625 f_vty_transceive(BSCVTY, "amr-config 6_70k forbidden");
3626 f_vty_transceive(BSCVTY, "amr-config 5_90k allowed");
3627 f_vty_transceive(BSCVTY, "amr-config 5_15k forbidden");
3628 f_vty_transceive(BSCVTY, "amr-config 4_75k allowed");
3629 f_vty_transceive(BSCVTY, "exit");
3630 f_vty_transceive(BSCVTY, "exit");
3631}
3632
Harald Welte60aa5762018-03-21 19:33:13 +01003633testcase TC_assignment_codec_amr_f() runs on test_CT {
Philipp Maier48604732018-10-09 15:00:37 +02003634 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte60aa5762018-03-21 19:33:13 +01003635 var MSC_ConnHdlr vc_conn;
Philipp Maier7695a0d2018-09-27 17:52:14 +02003636
3637 /* Note: This setups the codec configuration. The parameter payload in
3638 * mr_conf must be consistant with the parameter codecElements in pars
3639 * and also must match the amr-config in osmo-bsc.cfg! */
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02003640 var RSL_IE_Body mr_conf := {
3641 other := {
3642 len := 2,
3643 payload := '2804'O
3644 }
3645 };
Harald Welte60aa5762018-03-21 19:33:13 +01003646
Philipp Maier7695a0d2018-09-27 17:52:14 +02003647 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_F}));
Philipp Maier806f8f12019-03-12 12:13:41 +01003648 pars.ass_codec_list.codecElements[0].s0_7 := '00000100'B; /* 5,90k */
Philipp Maier7695a0d2018-09-27 17:52:14 +02003649 pars.ass_codec_list.codecElements[0].s8_15 := '01010111'B;
3650 pars.expect_mr_conf_ie := mr_conf;
3651
Harald Welte60aa5762018-03-21 19:33:13 +01003652 f_init(1, true);
3653 f_sleep(1.0);
3654
Harald Welte8863fa12018-05-10 20:15:27 +02003655 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01003656 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003657 f_shutdown_helper();
Harald Welte60aa5762018-03-21 19:33:13 +01003658}
3659
3660testcase TC_assignment_codec_amr_h() runs on test_CT {
Philipp Maier48604732018-10-09 15:00:37 +02003661 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte60aa5762018-03-21 19:33:13 +01003662 var MSC_ConnHdlr vc_conn;
Philipp Maier7695a0d2018-09-27 17:52:14 +02003663
3664 /* See note above */
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02003665 var RSL_IE_Body mr_conf := {
3666 other := {
3667 len := 2,
3668 payload := '2804'O
3669 }
3670 };
Harald Welte60aa5762018-03-21 19:33:13 +01003671
Philipp Maier7695a0d2018-09-27 17:52:14 +02003672 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_H}));
Philipp Maier806f8f12019-03-12 12:13:41 +01003673 pars.ass_codec_list.codecElements[0].s0_7 := '00000100'B; /* 5,90k */
Philipp Maier7695a0d2018-09-27 17:52:14 +02003674 pars.ass_codec_list.codecElements[0].s8_15 := '00000111'B;
3675 pars.expect_mr_conf_ie := mr_conf;
3676
Harald Welte60aa5762018-03-21 19:33:13 +01003677 f_init(1, true);
3678 f_sleep(1.0);
3679
Harald Welte8863fa12018-05-10 20:15:27 +02003680 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01003681 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003682 f_shutdown_helper();
Harald Welte60aa5762018-03-21 19:33:13 +01003683}
3684
Philipp Maierd0e64b02019-03-13 14:15:23 +01003685function f_TC_assignment_codec_amr(boolean fr, octetstring mrconf, bitstring s8_s0, bitstring exp_s8_s0)
3686runs on test_CT {
3687
3688 var TestHdlrParams pars := f_gen_test_hdlr_pars();
3689 var MSC_ConnHdlr vc_conn;
3690
3691 /* See note above */
3692 var RSL_IE_Body mr_conf := {
3693 other := {
3694 len := lengthof(mrconf),
3695 payload := mrconf
3696 }
3697 };
3698
3699 if (fr) {
3700 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_F}));
3701 } else {
3702 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_H}));
3703 }
3704 pars.ass_codec_list.codecElements[0].s0_7 := s8_s0;
3705 pars.ass_codec_list.codecElements[0].s8_15 := '00000111'B;
3706 pars.expect_mr_conf_ie := mr_conf;
3707 pars.expect_mr_s0_s7 := exp_s8_s0;
3708
3709 f_init(1, true);
3710 f_allow_amr_rate_4_75k_5_90k_7_40k_12_20k();
3711 f_sleep(1.0);
3712
3713 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
3714 vc_conn.done;
3715 f_allow_amr_rate_5_90k();
3716}
3717
3718function f_TC_assignment_codec_amr_fail(boolean fr, bitstring s8_s0)
3719runs on test_CT {
3720
3721 var TestHdlrParams pars := f_gen_test_hdlr_pars();
3722 var MSC_ConnHdlr vc_conn;
3723
3724 if (fr) {
3725 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_F}));
3726 } else {
3727 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_H}));
3728 }
3729 pars.ass_codec_list.codecElements[0].s0_7 := s8_s0;
3730 pars.ass_codec_list.codecElements[0].s8_15 := '00000111'B;
3731
3732 f_init(1, true);
3733 f_allow_amr_rate_4_75k_5_90k_7_40k_12_20k();
3734 f_sleep(1.0);
3735
3736 vc_conn := f_start_handler(refers(f_TC_assignment_codec_fail), pars);
3737 vc_conn.done;
3738 f_allow_amr_rate_5_90k();
3739}
3740
3741
3742/* Set S1, we expect an AMR multirate configuration IE with all four rates
3743 * set. */
3744testcase TC_assignment_codec_amr_f_S1() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003745 f_TC_assignment_codec_amr(true, '289520882208'O, '00000010'B, '00000010'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003746 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003747}
3748
3749/* Set S1, we expect an AMR multirate configuration IE with the lower three
3750 * rates set. */
3751testcase TC_assignment_codec_amr_h_S1() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003752 f_TC_assignment_codec_amr(false, '2815208820'O, '00000010'B, '00000010'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003753 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003754}
3755
3756/* Set S1 and two other rates, we expect an AMR MULTIRATE CONFIGURATION IE with
3757 * all four rates (and only S1 set in the ASSIGNMENT COMPLETE) */
3758testcase TC_assignment_codec_amr_f_S124() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003759 f_TC_assignment_codec_amr(true, '289520882208'O, '00010110'B, '00000010'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003760 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003761}
3762
3763/* Set S1 and two other rates, we expect an AMR MULTIRATE CONFIGURATION IE with
3764 * all four rates (and only S1 set in the ASSIGNMENT COMPLETE) */
3765testcase TC_assignment_codec_amr_h_S124() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003766 f_TC_assignment_codec_amr(false, '2815208820'O, '00010110'B, '00000010'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003767 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003768}
3769
3770/* The following block of tests selects more and more rates until all four
3771 * possible rates are in the active set (full rate) */
3772testcase TC_assignment_codec_amr_f_S0() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003773 f_TC_assignment_codec_amr(true, '2801'O, '00000001'B, '00000001'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003774 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003775}
3776
3777testcase TC_assignment_codec_amr_f_S02() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003778 f_TC_assignment_codec_amr(true, '28052080'O, '00000101'B, '00000101'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003779 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003780}
3781
3782testcase TC_assignment_codec_amr_f_S024() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003783 f_TC_assignment_codec_amr(true, '2815208820'O, '00010101'B, '00010101'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003784 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003785}
3786
3787testcase TC_assignment_codec_amr_f_S0247() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003788 f_TC_assignment_codec_amr(true, '289520882208'O, '10010101'B, '10010101'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003789 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003790}
3791
3792/* The following block of tests selects more and more rates until all three
3793 * possible rates are in the active set (half rate) */
3794testcase TC_assignment_codec_amr_h_S0() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003795 f_TC_assignment_codec_amr(false, '2801'O, '00000001'B, '00000001'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003796 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003797}
3798
3799testcase TC_assignment_codec_amr_h_S02() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003800 f_TC_assignment_codec_amr(false, '28052080'O, '00000101'B, '00000101'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003801 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003802}
3803
3804testcase TC_assignment_codec_amr_h_S024() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003805 f_TC_assignment_codec_amr(false, '2815208820'O, '00010101'B, '00010101'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003806 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003807}
3808
3809/* The following block tests what happens when the MSC does offer rate
3810 * configurations that are not supported by the BSC. Normally such situations
3811 * should not happen because the MSC gets informed by the BSC in advance via
3812 * the L3 COMPLETE message which rates are applicable. The MSC should not try
3813 * to offer rates that are not applicable anyway. */
3814
3815testcase TC_assignment_codec_amr_h_S0247() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003816 /* Try to include 12,2k in into the active set even though the channel
3817 * is half rate only. The BSC is expected to remove the 12,0k */
3818 f_TC_assignment_codec_amr(false, '2815208820'O, '10010101'B, '00010101'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003819 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003820}
3821
3822testcase TC_assignment_codec_amr_f_S01234567() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003823 /* See what happens when all rates are selected at once. Since then
3824 * Also S1 is selected, this setting will be prefered and we should
3825 * get 12.2k, 7,40k, 5,90k, and 4,75k in the active set. */
3826 f_TC_assignment_codec_amr(true, '289520882208'O, '11111111'B, '00000010'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003827 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003828}
3829
3830testcase TC_assignment_codec_amr_f_S0234567() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003831 /* Same as above, but with S1 missing, the MSC is then expected to
3832 * select the currently supported rates, which are also 12.2k, 7,40k,
3833 * 5,90k, and 4,75k, into the active set. */
3834 f_TC_assignment_codec_amr(true, '289520882208'O, '11111101'B, '10010101'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_zero() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003839 /* Try to select no rates at all */
3840 f_TC_assignment_codec_amr_fail(true, '00000000'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_f_unsupp() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003845 /* Try to select only unsupported rates */
3846 f_TC_assignment_codec_amr_fail(true, '01101000'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003847 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003848}
3849
3850testcase TC_assignment_codec_amr_h_S7() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003851 /* Try to select 12,2k for half rate */
3852 f_TC_assignment_codec_amr_fail(false, '10000000'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003853 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003854}
3855
Philipp Maierac09bfc2019-01-08 13:41:39 +01003856private function f_disable_all_tch_f() runs on test_CT {
Philipp Maierc704a882019-01-29 15:58:52 +01003857 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 1 sub-slot 0 borken");
3858 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 2 sub-slot 0 borken");
3859 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 3 sub-slot 0 borken");
3860 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 4 sub-slot 0 borken");
Philipp Maierac09bfc2019-01-08 13:41:39 +01003861}
3862
3863private function f_disable_all_tch_h() runs on test_CT {
Philipp Maierc704a882019-01-29 15:58:52 +01003864 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 5 sub-slot 0 borken");
3865 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 5 sub-slot 1 borken");
Philipp Maierac09bfc2019-01-08 13:41:39 +01003866}
3867
3868private function f_enable_all_tch() runs on test_CT {
Philipp Maierc704a882019-01-29 15:58:52 +01003869 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 1 sub-slot 0 unused");
3870 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 2 sub-slot 0 unused");
3871 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 3 sub-slot 0 unused");
3872 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 4 sub-slot 0 unused");
3873 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 5 sub-slot 0 unused");
3874 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 5 sub-slot 1 unused");
Philipp Maierac09bfc2019-01-08 13:41:39 +01003875}
3876
3877/* Allow HR only */
3878private function f_TC_assignment_codec_xr_exhausted_req_hr(charstring id) runs on MSC_ConnHdlr {
3879 g_pars := f_gen_test_hdlr_pars();
3880 var PDU_BSSAP ass_cmd := f_gen_ass_req();
3881 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3882 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3883 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '09'O;
3884 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '05'O;
3885 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR}));
3886 f_establish_fully(ass_cmd, exp_compl);
3887}
3888
3889/* Allow FR only */
3890private function f_TC_assignment_codec_xr_exhausted_req_fr(charstring id) runs on MSC_ConnHdlr {
3891 g_pars := f_gen_test_hdlr_pars();
3892 var PDU_BSSAP ass_cmd := f_gen_ass_req();
3893 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3894 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3895 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '08'O;
3896 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '01'O;
3897 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
3898 f_establish_fully(ass_cmd, exp_compl);
3899}
3900
3901/* Allow HR only (expect assignment failure) */
3902private function f_TC_assignment_codec_xr_exhausted_req_hr_fail(charstring id) runs on MSC_ConnHdlr {
3903 g_pars := f_gen_test_hdlr_pars();
3904 var PDU_BSSAP ass_cmd := f_gen_ass_req();
3905 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
3906 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3907 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '09'O;
3908 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '05'O;
3909 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR}));
3910 f_establish_fully(ass_cmd, exp_fail);
3911}
3912
3913/* Allow FR only (expect assignment failure) */
3914private function f_TC_assignment_codec_xr_exhausted_req_fr_fail(charstring id) runs on MSC_ConnHdlr {
3915 g_pars := f_gen_test_hdlr_pars();
3916 var PDU_BSSAP ass_cmd := f_gen_ass_req();
3917 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
3918 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3919 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '08'O;
3920 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '01'O;
3921 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
3922 f_establish_fully(ass_cmd, exp_fail);
3923}
3924
3925/* Allow FR and HR, but prefer FR */
3926private function f_TC_assignment_codec_fr_exhausted_req_fr_hr(charstring id) runs on MSC_ConnHdlr {
3927 g_pars := f_gen_test_hdlr_pars();
3928 var PDU_BSSAP ass_cmd := f_gen_ass_req();
3929 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3930 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3931 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0A'O; /* Prefer FR */
3932 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8105'O;
3933 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR, ts_CodecHR}));
3934 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000101'B; /* Expect HR */
3935 f_establish_fully(ass_cmd, exp_compl);
3936}
3937
3938/* Allow FR and HR, but prefer HR */
3939private function f_TC_assignment_codec_fr_exhausted_req_hr_fr(charstring id) runs on MSC_ConnHdlr {
3940 g_pars := f_gen_test_hdlr_pars();
3941 var PDU_BSSAP ass_cmd := f_gen_ass_req();
3942 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3943 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3944 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0B'O; /* Prefer HR */
3945 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8501'O;
3946 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR, ts_CodecFR}));
3947 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000101'B; /* Expect HR */
3948 f_establish_fully(ass_cmd, exp_compl);
3949}
3950
3951/* Allow FR and HR, but prefer FR */
3952private function f_TC_assignment_codec_hr_exhausted_req_fr_hr(charstring id) runs on MSC_ConnHdlr {
3953 g_pars := f_gen_test_hdlr_pars();
3954 var PDU_BSSAP ass_cmd := f_gen_ass_req();
3955 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3956 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3957 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0A'O; /* Prefer FR */
3958 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8105'O;
3959 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR, ts_CodecHR}));
3960 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000001'B; /* Expect FR */
3961 f_establish_fully(ass_cmd, exp_compl);
3962}
3963
3964/* Allow FR and HR, but prefer HR */
3965private function f_TC_assignment_codec_hr_exhausted_req_hr_fr(charstring id) runs on MSC_ConnHdlr {
3966 g_pars := f_gen_test_hdlr_pars();
3967 var PDU_BSSAP ass_cmd := f_gen_ass_req();
3968 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3969 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3970 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0B'O; /* Prefer HR */
3971 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8501'O;
3972 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR, ts_CodecFR}));
3973 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000001'B; /* Expect FR */
3974 f_establish_fully(ass_cmd, exp_compl);
3975}
3976
3977/* Request a HR channel while all FR channels are exhausted, this is expected
3978 * to work without conflicts */
3979testcase TC_assignment_codec_fr_exhausted_req_hr() runs on test_CT {
3980 var MSC_ConnHdlr vc_conn;
3981 f_init(1, true);
3982 f_sleep(1.0);
3983 f_enable_all_tch();
3984 f_disable_all_tch_f();
3985 vc_conn := f_start_handler(refers(f_TC_assignment_codec_xr_exhausted_req_hr));
3986 vc_conn.done;
3987 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003988 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01003989}
3990
3991/* Request a FR channel while all FR channels are exhausted, this is expected
3992 * to fail. */
3993testcase TC_assignment_codec_fr_exhausted_req_fr() runs on test_CT {
3994 var MSC_ConnHdlr vc_conn;
3995 f_init(1, true);
3996 f_sleep(1.0);
3997 f_enable_all_tch();
3998 f_disable_all_tch_f();
3999 vc_conn := f_start_handler(refers(f_TC_assignment_codec_xr_exhausted_req_fr_fail));
4000 vc_conn.done;
4001 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004002 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004003}
4004
4005/* Request a FR (prefered) or alternatively a HR channel while all FR channels
4006 * are exhausted, this is expected to be resolved by selecting a HR channel. */
4007testcase TC_assignment_codec_fr_exhausted_req_fr_hr() runs on test_CT {
4008 var MSC_ConnHdlr vc_conn;
4009 f_init(1, true);
4010 f_sleep(1.0);
4011 f_enable_all_tch();
4012 f_disable_all_tch_f();
4013 vc_conn := f_start_handler(refers(f_TC_assignment_codec_fr_exhausted_req_fr_hr));
4014 vc_conn.done;
4015 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004016 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004017}
4018
4019/* Request a HR (prefered) or alternatively a FR channel while all FR channels
4020 * are exhausted, this is expected to work without conflicts. */
4021testcase TC_assignment_codec_fr_exhausted_req_hr_fr() runs on test_CT {
4022 var MSC_ConnHdlr vc_conn;
4023 f_init(1, true);
4024 f_sleep(1.0);
4025 f_enable_all_tch();
4026 f_disable_all_tch_f();
4027 vc_conn := f_start_handler(refers(f_TC_assignment_codec_fr_exhausted_req_hr_fr));
4028 vc_conn.done;
4029 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004030 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004031}
4032
4033/* Request a FR channel while all HR channels are exhausted, this is expected
4034 * to work without conflicts */
4035testcase TC_assignment_codec_hr_exhausted_req_fr() runs on test_CT {
4036 var MSC_ConnHdlr vc_conn;
4037 f_init(1, true);
4038 f_sleep(1.0);
4039 f_enable_all_tch();
4040 f_disable_all_tch_h();
4041 vc_conn := f_start_handler(refers(f_TC_assignment_codec_xr_exhausted_req_fr));
4042 vc_conn.done;
4043 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004044 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004045}
4046
4047/* Request a HR channel while all HR channels are exhausted, this is expected
4048 * to fail. */
4049testcase TC_assignment_codec_hr_exhausted_req_hr() runs on test_CT {
4050 var MSC_ConnHdlr vc_conn;
4051 f_init(1, true);
4052 f_sleep(1.0);
4053 f_enable_all_tch();
4054 f_disable_all_tch_h();
4055 vc_conn := f_start_handler(refers(f_TC_assignment_codec_xr_exhausted_req_hr_fail));
4056 vc_conn.done;
4057 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004058 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004059}
4060
4061/* Request a HR (prefered) or alternatively a FR channel while all HR channels
4062 * are exhausted, this is expected to be resolved by selecting a FR channel. */
4063testcase TC_assignment_codec_hr_exhausted_req_hr_fr() runs on test_CT {
4064 var MSC_ConnHdlr vc_conn;
4065 f_init(1, true);
4066 f_sleep(1.0);
4067 f_enable_all_tch();
4068 f_disable_all_tch_h();
4069 vc_conn := f_start_handler(refers(f_TC_assignment_codec_hr_exhausted_req_hr_fr));
4070 vc_conn.done;
4071 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004072 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004073}
4074
4075/* Request a FR (prefered) or alternatively a HR channel while all HR channels
4076 * are exhausted, this is expected to work without conflicts. */
4077testcase TC_assignment_codec_hr_exhausted_req_fr_hr() runs on test_CT {
4078 var MSC_ConnHdlr vc_conn;
4079 f_init(1, true);
4080 f_sleep(1.0);
4081 f_enable_all_tch();
4082 f_disable_all_tch_h();
4083 vc_conn := f_start_handler(refers(f_TC_assignment_codec_hr_exhausted_req_fr_hr));
4084 vc_conn.done;
4085 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004086 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004087}
4088
4089/* Allow FR and HR, but prefer HR */
4090private function f_TC_assignment_codec_req_hr_fr(charstring id) runs on MSC_ConnHdlr {
4091 g_pars := f_gen_test_hdlr_pars();
4092 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4093 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4094 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4095 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0B'O; /* Prefer HR */
4096 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8501'O;
4097 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR, ts_CodecFR}));
4098 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000101'B; /* Expect HR */
4099 f_establish_fully(ass_cmd, exp_compl);
4100}
4101
4102/* Allow FR and HR, but prefer FR */
4103private function f_TC_assignment_codec_req_fr_hr(charstring id) runs on MSC_ConnHdlr {
4104 g_pars := f_gen_test_hdlr_pars();
4105 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4106 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4107 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4108 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0A'O; /* Prefer FR */
4109 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8105'O;
4110 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR, ts_CodecHR}));
4111 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000001'B; /* Expect FR */
4112 f_establish_fully(ass_cmd, exp_compl);
4113}
4114
4115/* Request a HR (prefered) or alternatively a FR channel, it is expected that
4116 * HR, which is the prefered type, is selected. */
4117testcase TC_assignment_codec_req_hr_fr() runs on test_CT {
4118 var MSC_ConnHdlr vc_conn;
4119 f_init(1, true);
4120 f_sleep(1.0);
4121 f_enable_all_tch();
4122 vc_conn := f_start_handler(refers(f_TC_assignment_codec_req_hr_fr));
4123 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004124 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004125}
4126
4127/* Request a FR (prefered) or alternatively a HR channel, it is expected that
4128 * FR, which is the prefered type, is selected. */
4129testcase TC_assignment_codec_req_fr_hr() runs on test_CT {
4130 var MSC_ConnHdlr vc_conn;
4131 f_init(1, true);
4132 f_sleep(1.0);
4133 f_enable_all_tch();
4134 vc_conn := f_start_handler(refers(f_TC_assignment_codec_req_fr_hr));
4135 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004136 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004137}
4138
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02004139testcase TC_assignment_osmux() runs on test_CT {
4140 var TestHdlrParams pars := f_gen_test_hdlr_pars();
4141 var MSC_ConnHdlr vc_conn;
4142
4143 /* See note above */
4144 var RSL_IE_Body mr_conf := {
4145 other := {
4146 len := 2,
4147 payload := '2804'O
4148 }
4149 };
4150
4151 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_H}));
4152 pars.ass_codec_list.codecElements[0].s0_7 := '00000100'B; /* 5,90k */
4153 pars.ass_codec_list.codecElements[0].s8_15 := '00000111'B;
4154 pars.expect_mr_conf_ie := mr_conf;
4155 pars.use_osmux := true;
4156
4157 f_init(1, true, true);
4158 f_sleep(1.0);
4159
4160 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
4161 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004162 f_shutdown_helper();
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02004163}
4164
Neels Hofmeyr92b12b72018-09-18 14:30:23 +02004165/* test the procedure of the MSC requesting a Classmark Update:
4166 * a) BSSMAP Classmark Request should result in RR CLASSMARK ENQUIRY,
4167 * b) L3 RR CLASSMARK CHANGE should result in BSSMAP CLASSMARK UPDATE */
Harald Welte898113b2018-01-31 18:32:21 +01004168private function f_tc_classmark(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02004169 g_pars := f_gen_test_hdlr_pars();
4170
Harald Weltea0630032018-03-20 21:09:55 +01004171 f_create_chan_and_exp();
Harald Welte898113b2018-01-31 18:32:21 +01004172 /* we should now have a COMPL_L3 at the MSC */
4173 BSSAP.receive(tr_BSSMAP_ComplL3);
4174
Neels Hofmeyr92b12b72018-09-18 14:30:23 +02004175 BSSAP.send(ts_BSSMAP_ClassmarkRequest);
4176 RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_CM_ENQUIRY));
4177
Harald Welte898113b2018-01-31 18:32:21 +01004178 f_rsl_send_l3(ts_RRM_CM_CHG(valueof(ts_CM2)));
4179 BSSAP.receive(tr_BSSMAP_ClassmarkUpd(?, omit));
4180 setverdict(pass);
4181}
4182testcase TC_classmark() runs on test_CT {
4183 var MSC_ConnHdlr vc_conn;
4184 f_init(1, true);
4185 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02004186 vc_conn := f_start_handler(refers(f_tc_classmark));
Harald Welte898113b2018-01-31 18:32:21 +01004187 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004188 f_shutdown_helper();
Harald Welte898113b2018-01-31 18:32:21 +01004189}
4190
Harald Welteeddf0e92020-06-21 19:42:15 +02004191/* Send a CommonID from the simulated MSC and verify that the information is used to
4192 * fill BSC-internal data structures (specifically, bsc_subscr associated with subscr_conn) */
4193private function f_tc_common_id(charstring id) runs on MSC_ConnHdlr {
4194 g_pars := f_gen_test_hdlr_pars();
4195 f_MscConnHdlr_init_vty();
4196
4197 f_create_chan_and_exp();
4198 /* we should now have a COMPL_L3 at the MSC */
4199 BSSAP.receive(tr_BSSMAP_ComplL3);
4200
4201 /* Send CommonID */
4202 BSSAP.send(ts_BSSMAP_CommonId(g_pars.imsi));
4203
4204 /* Use VTY to verify that the IMSI of the subscr_conn is set */
4205 var charstring regex := "*(IMSI: " & hex2str(g_pars.imsi) & ")*";
4206 f_vty_transceive_match_regexp_retry(BSCVTY, "show conns", regex, 0, 4, 1.0);
4207
4208 setverdict(pass);
4209}
4210testcase TC_common_id() runs on test_CT {
4211 var MSC_ConnHdlr vc_conn;
4212 f_init(1, true);
4213 f_sleep(1.0);
4214 vc_conn := f_start_handler(refers(f_tc_common_id));
4215 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004216 f_shutdown_helper();
Harald Welteeddf0e92020-06-21 19:42:15 +02004217}
4218
Harald Weltee3bd6582018-01-31 22:51:25 +01004219private function f_est_single_l3(template PDU_ML3_MS_NW l3) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02004220 g_pars := f_gen_test_hdlr_pars();
Harald Weltea0630032018-03-20 21:09:55 +01004221 f_create_chan_and_exp();
Harald Welte898113b2018-01-31 18:32:21 +01004222 /* we should now have a COMPL_L3 at the MSC */
4223 BSSAP.receive(tr_BSSMAP_ComplL3);
4224
Harald Weltee3bd6582018-01-31 22:51:25 +01004225 /* send the single message we want to send */
4226 f_rsl_send_l3(l3);
4227}
4228
4229private function f_bssap_expect_nothing(float sec := 5.00) runs on MSC_ConnHdlr {
4230 timer T := sec;
4231 var PDU_BSSAP bssap;
Harald Welte898113b2018-01-31 18:32:21 +01004232 T.start;
4233 alt {
Harald Weltee3bd6582018-01-31 22:51:25 +01004234 [] BSSAP.receive(PDU_BSSAP:?) -> value bssap {
4235 setverdict(fail, "Unexpected BSSMAP ", bssap);
Daniel Willmannafce8662018-07-06 23:11:32 +02004236 mtc.stop;
Harald Welte898113b2018-01-31 18:32:21 +01004237 }
4238 [] T.timeout {
4239 setverdict(pass);
4240 }
4241 }
4242}
4243
Harald Weltee3bd6582018-01-31 22:51:25 +01004244/* unsolicited ASSIGNMENT FAIL (without ASSIGN) from MS shouldn't bring BSC down */
4245private function f_tc_unsol_ass_fail(charstring id) runs on MSC_ConnHdlr {
4246 f_est_single_l3(ts_RRM_AssignmentFailure('00'O));
4247 f_bssap_expect_nothing();
4248}
Harald Welte898113b2018-01-31 18:32:21 +01004249testcase TC_unsol_ass_fail() runs on test_CT {
4250 var MSC_ConnHdlr vc_conn;
4251 f_init(1, true);
4252 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02004253 vc_conn := f_start_handler(refers(f_tc_unsol_ass_fail));
Harald Welte898113b2018-01-31 18:32:21 +01004254 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004255 f_shutdown_helper();
Harald Welte898113b2018-01-31 18:32:21 +01004256}
Harald Welte552620d2017-12-16 23:21:36 +01004257
Harald Welteea99a002018-01-31 20:46:43 +01004258
4259/* unsolicited ASSIGNMENT COMPLETE (without ASSIGN) from MS shouldn't bring BSC down */
4260private function f_tc_unsol_ass_compl(charstring id) runs on MSC_ConnHdlr {
Harald Weltee3bd6582018-01-31 22:51:25 +01004261 f_est_single_l3(ts_RRM_AssignmentComplete('00'O));
4262 f_bssap_expect_nothing();
Harald Welteea99a002018-01-31 20:46:43 +01004263}
4264testcase TC_unsol_ass_compl() runs on test_CT {
4265 var MSC_ConnHdlr vc_conn;
4266 f_init(1, true);
4267 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02004268 vc_conn := f_start_handler(refers(f_tc_unsol_ass_compl));
Harald Welteea99a002018-01-31 20:46:43 +01004269 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004270 f_shutdown_helper();
Harald Welteea99a002018-01-31 20:46:43 +01004271}
4272
4273
Harald Weltefbf9b5e2018-01-31 20:41:23 +01004274/* unsolicited HANDOVER FAIL (without ASSIGN) from MS shouldn't bring BSC down */
4275private function f_tc_unsol_ho_fail(charstring id) runs on MSC_ConnHdlr {
Harald Weltee3bd6582018-01-31 22:51:25 +01004276 f_est_single_l3(ts_RRM_HandoverFailure('00'O));
4277 f_bssap_expect_nothing();
Harald Weltefbf9b5e2018-01-31 20:41:23 +01004278}
Harald Weltefbf9b5e2018-01-31 20:41:23 +01004279testcase TC_unsol_ho_fail() runs on test_CT {
4280 var MSC_ConnHdlr vc_conn;
4281 f_init(1, true);
4282 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02004283 vc_conn := f_start_handler(refers(f_tc_unsol_ho_fail));
Harald Weltefbf9b5e2018-01-31 20:41:23 +01004284 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004285 f_shutdown_helper();
Harald Weltefbf9b5e2018-01-31 20:41:23 +01004286}
4287
4288
Harald Weltee3bd6582018-01-31 22:51:25 +01004289/* short message from MS should be ignored */
4290private function f_tc_err_82_short_msg(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02004291 g_pars := f_gen_test_hdlr_pars();
Harald Weltea0630032018-03-20 21:09:55 +01004292 f_create_chan_and_exp();
Harald Weltee3bd6582018-01-31 22:51:25 +01004293 /* we should now have a COMPL_L3 at the MSC */
4294 BSSAP.receive(tr_BSSMAP_ComplL3);
4295
4296 /* send short message */
4297 RSL.send(ts_RSL_DATA_IND(g_chan_nr, valueof(ts_RslLinkID_DCCH(0)), ''O));
4298 f_bssap_expect_nothing();
4299}
4300testcase TC_err_82_short_msg() runs on test_CT {
4301 var MSC_ConnHdlr vc_conn;
4302 f_init(1, true);
4303 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02004304 vc_conn := f_start_handler(refers(f_tc_err_82_short_msg));
Harald Weltee3bd6582018-01-31 22:51:25 +01004305 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004306 f_shutdown_helper();
Harald Weltee3bd6582018-01-31 22:51:25 +01004307}
4308
4309
Harald Weltee9e02e42018-01-31 23:36:25 +01004310/* 24.008 8.4 Unknown message must trigger RR STATUS */
4311private function f_tc_err_84_unknown_msg(charstring id) runs on MSC_ConnHdlr {
4312 f_est_single_l3(ts_RRM_UL_REL('00'O));
4313 timer T := 3.0
4314 alt {
4315 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_STATUS)) {
4316 setverdict(pass);
4317 }
4318 [] BSSAP.receive { setverdict(fail, "unexpected BSSAP"); }
Harald Welte458fd372018-03-21 11:26:23 +01004319 [] T.timeout { setverdict(fail, "Timeout waiting for RR STATUS"); }
Harald Weltee9e02e42018-01-31 23:36:25 +01004320 }
4321}
4322testcase TC_err_84_unknown_msg() runs on test_CT {
4323 var MSC_ConnHdlr vc_conn;
4324 f_init(1, true);
4325 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02004326 vc_conn := f_start_handler(refers(f_tc_err_84_unknown_msg));
Harald Weltee9e02e42018-01-31 23:36:25 +01004327 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004328 f_shutdown_helper();
Harald Weltee9e02e42018-01-31 23:36:25 +01004329}
4330
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004331/***********************************************************************
4332 * Handover
4333 ***********************************************************************/
4334
Harald Welte94e0c342018-04-07 11:33:23 +02004335/* execute a "bts <0-255> trx <0-255> timeslot <0-7> " command on given Dchan */
4336private function f_vty_ts_action(charstring suffix, integer bts_nr, integer trx_nr, integer ts_nr)
4337runs on test_CT {
4338 var charstring cmd := "bts "&int2str(bts_nr)&" trx "&int2str(trx_nr)&
4339 " timeslot "&int2str(ts_nr)&" ";
4340 f_vty_transceive(BSCVTY, cmd & suffix);
4341}
4342
Harald Welte261af4b2018-02-12 21:20:39 +01004343/* 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 +07004344private function f_vty_ss_action(TELNETasp_PT pt, charstring suffix,
4345 uint8_t bts_nr, uint8_t trx_nr,
4346 in RslChannelNr chan_nr)
4347{
Harald Welte261af4b2018-02-12 21:20:39 +01004348 /* FIXME: resolve those from component-global state */
4349 var integer ts_nr := chan_nr.tn;
4350 var integer ss_nr;
4351 if (ischosen(chan_nr.u.ch0)) {
4352 ss_nr := 0;
4353 } else if (ischosen(chan_nr.u.lm)) {
4354 ss_nr := chan_nr.u.lm.sub_chan;
4355 } else if (ischosen(chan_nr.u.sdcch4)) {
4356 ss_nr := chan_nr.u.sdcch4.sub_chan;
4357 } else if (ischosen(chan_nr.u.sdcch8)) {
4358 ss_nr := chan_nr.u.sdcch8.sub_chan;
4359 } else {
4360 setverdict(fail, "Invalid ChanNr ", chan_nr);
Daniel Willmannafce8662018-07-06 23:11:32 +02004361 mtc.stop;
Harald Welte261af4b2018-02-12 21:20:39 +01004362 }
4363
4364 var charstring cmd := "bts "&int2str(bts_nr)&" trx "&int2str(trx_nr)&
4365 " timeslot "&int2str(ts_nr)&" sub-slot "&int2str(ss_nr)&" ";
Vadim Yanitskiy00070722020-09-02 17:27:57 +07004366 f_vty_transceive(pt, cmd & suffix);
Harald Welte261af4b2018-02-12 21:20:39 +01004367}
4368
Neels Hofmeyr91401012019-07-11 00:42:35 +02004369/* Even though the VTY command to trigger handover takes a new BTS number as argument, behind the scenes osmo-bsc always
4370 * translates that to a target ARFCN+BSIC first. See bsc_vty.c trigger_ho_or_as(), which puts the selected BTS' neighbor
4371 * ident key (ARFCN + BSIC) in the struct passed on to handover_request(). handover_start() then resolves that to a
4372 * viable actual neighbor cell. So from the internal osmo-bsc perspective, we always request handover to an ARFCN + BSIC
4373 * pair, not really to a specific BTS number. */
Vadim Yanitskiy00070722020-09-02 17:27:57 +07004374private function f_vty_handover(TELNETasp_PT pt, uint8_t bts_nr, uint8_t trx_nr,
4375 in RslChannelNr chan_nr, uint8_t new_bts_nr)
4376{
4377 f_vty_ss_action(pt, "handover " & int2str(new_bts_nr), bts_nr, trx_nr, chan_nr);
Harald Welte261af4b2018-02-12 21:20:39 +01004378}
4379
4380/* intra-BSC hand-over between BTS0 and BTS1 */
4381private function f_tc_ho_int(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02004382 g_pars := f_gen_test_hdlr_pars();
Harald Welteed848512018-05-24 22:27:58 +02004383 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4384 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte261af4b2018-02-12 21:20:39 +01004385 const OCT8 kc := '0001020304050607'O;
4386
4387 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4388 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
4389
Harald Weltea0630032018-03-20 21:09:55 +01004390 f_establish_fully(ass_cmd, exp_compl);
Neels Hofmeyr666f0432020-07-04 00:53:07 +02004391 f_bts_0_cfg(BSCVTY, {"neighbor bts 1"});
Harald Welte261af4b2018-02-12 21:20:39 +01004392
4393 var HandoverState hs := {
4394 rr_ho_cmpl_seen := false,
4395 handover_done := false,
4396 old_chan_nr := -
4397 };
4398 /* issue hand-over command on VTY */
Vadim Yanitskiy00070722020-09-02 17:27:57 +07004399 f_vty_handover(BSCVTY, 0, 0, g_chan_nr, 1);
Harald Welte261af4b2018-02-12 21:20:39 +01004400 /* temporarily suspend DChan processing on BTS1 to avoid race with RSLEM_register */
4401 f_rslem_suspend(RSL1_PROC);
Philipp Maier3e2af5d2018-07-11 17:01:05 +02004402
4403 /* From the MGW perspective, a handover is is characterized by
4404 * performing one MDCX operation with the MGW. So we expect to see
4405 * one more MDCX during handover. */
4406 g_media.mgcp_conn[0].mdcx_seen_exp := g_media.mgcp_conn[0].crcx_seen_exp + 1;
4407
Harald Welte261af4b2018-02-12 21:20:39 +01004408 alt {
4409 [] as_handover(hs);
Harald Welte261af4b2018-02-12 21:20:39 +01004410 }
Philipp Maier3e2af5d2018-07-11 17:01:05 +02004411
Philipp Maier4dae0652018-11-12 12:03:26 +01004412 /* Since this is an internal handover we expect the BSC to inform the
4413 * MSC about the event */
4414 BSSAP.receive(tr_BSSMAP_HandoverPerformed);
4415
Philipp Maier3e2af5d2018-07-11 17:01:05 +02004416 /* Check the amount of MGCP transactions is still consistant with the
4417 * test expectation */
4418 f_check_mgcp_expectations()
Neels Hofmeyr861a4c12018-11-07 01:23:17 +01004419 f_sleep(0.5);
Harald Welte261af4b2018-02-12 21:20:39 +01004420}
4421
4422testcase TC_ho_int() runs on test_CT {
4423 var MSC_ConnHdlr vc_conn;
4424 f_init(2, true);
4425 f_sleep(1.0);
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004426
4427 f_ctrs_bsc_and_bts_init();
4428
Harald Welte8863fa12018-05-10 20:15:27 +02004429 vc_conn := f_start_handler(refers(f_tc_ho_int));
Harald Welte261af4b2018-02-12 21:20:39 +01004430 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004431
4432 /* from f_establish_fully() */
4433 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
4434 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
4435 /* from handover */
4436 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
4437 f_ctrs_bsc_and_bts_add(0, "handover:completed");
4438 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
4439 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:completed");
4440 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004441 f_shutdown_helper();
Harald Welte261af4b2018-02-12 21:20:39 +01004442}
Harald Weltee9e02e42018-01-31 23:36:25 +01004443
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004444/* Expecting MGCP to DLCX the endpoint's two connections: towards BTS and towards MSC */
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02004445private function f_expect_dlcx_conns() runs on MSC_ConnHdlr {
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004446 var MgcpCommand mgcp;
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +02004447 var template MgcpResponse mgcp_resp;
4448 var MGCP_RecvFrom mrf;
4449 var template MgcpMessage msg_resp;
4450 var template MgcpMessage msg_dlcx := {
4451 command := tr_DLCX()
4452 }
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004453
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +02004454 if (g_pars.aoip) {
4455 MGCP.receive(tr_DLCX()) -> value mgcp {
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004456 log("Got first DLCX: ", mgcp);
4457 MGCP.send(ts_DLCX_ACK2(mgcp.line.trans_id));
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +02004458 };
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004459
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004460 MGCP.receive(tr_DLCX()) -> value mgcp {
4461 log("Got second DLCX: ", mgcp);
4462 MGCP.send(ts_DLCX_ACK2(mgcp.line.trans_id));
4463 };
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +02004464 } else {
4465 /* For SCCPLite, BSC doesn't handle the MSC-side */
4466 MGCP_MULTI.receive(tr_MGCP_RecvFrom_any(msg_dlcx)) -> value mrf {
4467 log("Got first DLCX: ", mrf.msg.command);
4468 msg_resp := {
4469 response := ts_DLCX_ACK2(mrf.msg.command.line.trans_id)
4470 }
4471 MGCP_MULTI.send(t_MGCP_SendToMrf(mrf, msg_resp));
4472 };
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004473 }
4474
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02004475 BSSAP.receive(tr_BSSMAP_ClearComplete);
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004476}
4477
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004478private function f_tc_ho_out_of_this_bsc(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02004479 g_pars := f_gen_test_hdlr_pars();
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004480
4481 var PDU_BSSAP ass_req := f_gen_ass_req();
4482 ass_req.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4483 ass_req.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
4484 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4485 f_establish_fully(ass_req, exp_compl);
4486
Neels Hofmeyr666f0432020-07-04 00:53:07 +02004487 f_bts_0_cfg(BSCVTY, {"neighbor lac 99 arfcn 123 bsic any"});
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004488 f_vty_transceive(BSCVTY, "handover any to arfcn 123 bsic any");
4489
4490 BSSAP.receive(tr_BSSMAP_HandoverRequired);
4491
4492 f_sleep(0.5);
4493 /* The MSC negotiates Handover Request and Handover Request Ack with
4494 * the other BSS and comes back with a BSSMAP Handover Command
4495 * containing an RR Handover Command coming from the target BSS... */
4496
4497 var PDU_ML3_NW_MS rr_ho_cmd := valueof(ts_RR_HandoverCommand);
4498 log("Remote cell's RR Handover Command passed through as L3 Info: ", rr_ho_cmd);
4499 var octetstring rr_ho_cmd_enc := enc_PDU_ML3_NW_MS(rr_ho_cmd);
4500 log("Remote cell's RR Handover Command passed through as L3 Info, encoded: ", rr_ho_cmd_enc);
4501 BSSAP.send(ts_BSSMAP_HandoverCommand(rr_ho_cmd_enc));
4502
4503 /* expect the Handover Command to go out on RR */
4504 var RSL_Message rsl_ho_cmd
4505 RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, ?)) -> value rsl_ho_cmd;
4506 log("RSL Data Req went out to first BTS: ", rsl_ho_cmd);
4507 var RSL_IE_Body rsl_ho_cmd_l3;
4508 if (not f_rsl_find_ie(rsl_ho_cmd, RSL_IE_L3_INFO, rsl_ho_cmd_l3)) {
4509 log("RSL message contains no L3 Info IE, expected RR Handover Command");
4510 setverdict(fail);
4511 } else {
4512 log("Found L3 Info: ", rsl_ho_cmd_l3);
4513 if (rsl_ho_cmd_l3.l3_info.payload != rr_ho_cmd_enc) {
4514 log("FAIL: the BSC sent out a different L3 Info, not matching the RR Handover Command the other BSS forwarded.");
4515 setverdict(fail);
4516 } else {
4517 log("Success: the BSC sent out the same RR Handover Command the other BSS forwarded.");
4518 setverdict(pass);
4519 }
4520 }
4521
4522 /* When the other BSS has reported a completed handover, this side is
4523 * torn down. */
4524
4525 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_HANDOVER_SUCCESSFUL;
4526 var BssmapCause cause := enum2int(cause_val);
4527 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
4528
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02004529 f_expect_dlcx_conns();
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004530 setverdict(pass);
4531 f_sleep(1.0);
4532}
4533testcase TC_ho_out_of_this_bsc() runs on test_CT {
4534 var MSC_ConnHdlr vc_conn;
4535
4536 f_init(1, true);
4537 f_sleep(1.0);
4538
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004539 f_ctrs_bsc_and_bts_init();
4540
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004541 vc_conn := f_start_handler(refers(f_tc_ho_out_of_this_bsc));
4542 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004543
4544 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
4545 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
4546 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
4547 f_ctrs_bsc_and_bts_add(0, "handover:completed");
4548 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
4549 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:completed");
4550 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004551 f_shutdown_helper();
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004552}
4553
Neels Hofmeyr0aa719b2020-10-12 18:43:09 +00004554private function f_mo_l3_transceive(RSL_DCHAN_PT rsl := RSL,
4555 template (value) RslLinkId link_id := ts_RslLinkID_DCCH(0),
Vadim Yanitskiy2ef6a2f2020-10-08 23:17:32 +07004556 template (present) OCT1 dlci := ?,
Vadim Yanitskiyb93aa432020-10-01 14:23:11 +07004557 octetstring l3 := '0123456789'O)
4558runs on MSC_ConnHdlr {
Neels Hofmeyr43654812020-09-25 01:35:35 +02004559 /* The old lchan and conn should still be active. See that arbitrary L3
4560 * is still going through. */
Neels Hofmeyr0aa719b2020-10-12 18:43:09 +00004561 rsl.send(ts_RSL_DATA_IND(g_chan_nr, link_id, l3));
Neels Hofmeyr43654812020-09-25 01:35:35 +02004562 var template PDU_BSSAP exp_data := {
4563 discriminator := '1'B,
4564 spare := '0000000'B,
Vadim Yanitskiyb93aa432020-10-01 14:23:11 +07004565 dlci := dlci,
4566 lengthIndicator := lengthof(l3),
Neels Hofmeyr43654812020-09-25 01:35:35 +02004567 pdu := {
4568 dtap := l3
4569 }
4570 };
4571 BSSAP.receive(exp_data);
4572 setverdict(pass);
4573}
4574
Neels Hofmeyr0aa719b2020-10-12 18:43:09 +00004575private function f_mt_l3_transceive(RSL_DCHAN_PT rsl := RSL,
4576 template (present) RslLinkId link_id := tr_RslLinkID_DCCH(0),
Vadim Yanitskiy0033a3b2020-10-01 22:21:16 +07004577 template (value) OCT1 dlci := '00'O,
4578 octetstring l3 := '0123456789'O)
4579runs on MSC_ConnHdlr {
4580 BSSAP.send(PDU_BSSAP:{
4581 discriminator := '1'B,
4582 spare := '0000000'B,
4583 dlci := dlci,
4584 lengthIndicator := lengthof(l3),
4585 pdu := {
4586 dtap := l3
4587 }
4588 });
Neels Hofmeyr0aa719b2020-10-12 18:43:09 +00004589 rsl.receive(tr_RSL_DATA_REQ(g_chan_nr, link_id, l3));
Vadim Yanitskiy0033a3b2020-10-01 22:21:16 +07004590 setverdict(pass);
4591}
4592
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004593/* BSC asks for inter-BSC HO, but the MSC decides that it won't happen and
4594 * simply never sends a BSSMAP Handover Command. */
4595private function f_tc_ho_out_fail_no_msc_response(charstring id) runs on MSC_ConnHdlr {
Daniel Willmann3b59eb52018-10-29 15:40:55 +01004596 g_pars := f_gen_test_hdlr_pars();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004597
4598 var PDU_BSSAP ass_req := f_gen_ass_req();
4599 ass_req.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4600 ass_req.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
4601 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4602 f_establish_fully(ass_req, exp_compl);
4603
Neels Hofmeyr666f0432020-07-04 00:53:07 +02004604 f_bts_0_cfg(BSCVTY, {"neighbor lac 99 arfcn 123 bsic any"});
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004605 f_vty_transceive(BSCVTY, "handover any to arfcn 123 bsic any");
4606
4607 BSSAP.receive(tr_BSSMAP_HandoverRequired);
4608
4609 /* osmo-bsc should time out 10 seconds after the handover started.
4610 * Let's give it a bit extra. */
4611 f_sleep(15.0);
4612
Vadim Yanitskiy74ae5eb2020-10-01 22:13:29 +07004613 f_mo_l3_transceive();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004614 f_sleep(1.0);
4615}
4616testcase TC_ho_out_fail_no_msc_response() runs on test_CT {
4617 var MSC_ConnHdlr vc_conn;
4618
4619 f_init(1, true);
4620 f_sleep(1.0);
4621
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004622 f_ctrs_bsc_and_bts_init();
4623
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004624 vc_conn := f_start_handler(refers(f_tc_ho_out_fail_no_msc_response));
4625 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004626
4627 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
4628 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
4629 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
4630 f_ctrs_bsc_and_bts_add(0, "handover:timeout");
4631 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
4632 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:timeout");
4633 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004634 f_shutdown_helper();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004635}
4636
4637/* BSC asks for inter-BSC HO, receives BSSMAP Handover Command, but MS reports
4638 * RR Handover Failure. */
4639private function f_tc_ho_out_fail_rr_ho_failure(charstring id) runs on MSC_ConnHdlr {
Daniel Willmann3b59eb52018-10-29 15:40:55 +01004640 g_pars := f_gen_test_hdlr_pars();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004641
4642 var PDU_BSSAP ass_req := f_gen_ass_req();
4643 ass_req.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4644 ass_req.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
4645 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4646 f_establish_fully(ass_req, exp_compl);
4647
Neels Hofmeyr666f0432020-07-04 00:53:07 +02004648 f_bts_0_cfg(BSCVTY, {"neighbor lac 99 arfcn 123 bsic any"});
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004649 f_vty_transceive(BSCVTY, "handover any to arfcn 123 bsic any");
4650
4651 BSSAP.receive(tr_BSSMAP_HandoverRequired);
4652
4653 f_sleep(0.5);
4654 /* The MSC negotiates Handover Request and Handover Request Ack with
4655 * the other BSS and comes back with a BSSMAP Handover Command
4656 * containing an RR Handover Command coming from the target BSS... */
4657
4658 var PDU_ML3_NW_MS rr_ho_cmd := valueof(ts_RR_HandoverCommand);
4659 log("Remote cell's RR Handover Command passed through as L3 Info: ", rr_ho_cmd);
4660 var octetstring rr_ho_cmd_enc := enc_PDU_ML3_NW_MS(rr_ho_cmd);
4661 log("Remote cell's RR Handover Command passed through as L3 Info, encoded: ", rr_ho_cmd_enc);
4662 BSSAP.send(ts_BSSMAP_HandoverCommand(rr_ho_cmd_enc));
4663
4664 /* expect the Handover Command to go out on RR */
4665 var RSL_Message rsl_ho_cmd
4666 RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, ?)) -> value rsl_ho_cmd;
4667 log("RSL Data Req went out to first BTS: ", rsl_ho_cmd);
4668 var RSL_IE_Body rsl_ho_cmd_l3;
4669 if (not f_rsl_find_ie(rsl_ho_cmd, RSL_IE_L3_INFO, rsl_ho_cmd_l3)) {
4670 log("RSL message contains no L3 Info IE, expected RR Handover Command");
4671 setverdict(fail);
4672 } else {
4673 log("Found L3 Info: ", rsl_ho_cmd_l3);
4674 if (rsl_ho_cmd_l3.l3_info.payload != rr_ho_cmd_enc) {
4675 log("FAIL: the BSC sent out a different L3 Info, not matching the RR Handover Command the other BSS forwarded.");
4676 setverdict(fail);
4677 } else {
4678 log("Success: the BSC sent out the same RR Handover Command the other BSS forwarded.");
4679 setverdict(pass);
4680 }
4681 }
4682
4683 f_sleep(0.2);
4684 f_rsl_send_l3(ts_RRM_HandoverFailure('00'O));
4685
4686 /* Should tell the MSC about the failure */
4687 BSSAP.receive(tr_BSSMAP_HandoverFailure);
4688
4689 f_sleep(1.0);
4690
Vadim Yanitskiy74ae5eb2020-10-01 22:13:29 +07004691 f_mo_l3_transceive();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004692 f_sleep(1.0);
4693
4694 setverdict(pass);
4695 f_sleep(1.0);
4696}
4697testcase TC_ho_out_fail_rr_ho_failure() runs on test_CT {
4698 var MSC_ConnHdlr vc_conn;
4699
4700 f_init(1, true);
4701 f_sleep(1.0);
4702
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004703 f_ctrs_bsc_and_bts_init();
4704
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004705 vc_conn := f_start_handler(refers(f_tc_ho_out_fail_rr_ho_failure));
4706 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004707
4708 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
4709 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
4710 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
4711 f_ctrs_bsc_and_bts_add(0, "handover:failed");
4712 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
4713 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:failed");
4714 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004715 f_shutdown_helper();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004716}
4717
Neels Hofmeyr10f2bfa2019-07-09 19:33:29 +02004718/* BSC asks for inter-BSC-out HO, receives BSSMAP Handover Command, but then no reply is received about HO outcome
4719 * (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 +02004720 * and the lchan is released. */
4721private function f_tc_ho_out_fail_no_result_after_ho_cmd(charstring id) runs on MSC_ConnHdlr {
Daniel Willmann3b59eb52018-10-29 15:40:55 +01004722 g_pars := f_gen_test_hdlr_pars();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004723
4724 var PDU_BSSAP ass_req := f_gen_ass_req();
4725 ass_req.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4726 ass_req.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
4727 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4728 f_establish_fully(ass_req, exp_compl);
4729
Neels Hofmeyr666f0432020-07-04 00:53:07 +02004730 f_bts_0_cfg(BSCVTY, {"neighbor lac 99 arfcn 123 bsic any"});
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004731 f_vty_transceive(BSCVTY, "handover any to arfcn 123 bsic any");
4732
4733 BSSAP.receive(tr_BSSMAP_HandoverRequired);
4734
4735 f_sleep(0.5);
4736 /* The MSC negotiates Handover Request and Handover Request Ack with
4737 * the other BSS and comes back with a BSSMAP Handover Command
4738 * containing an RR Handover Command coming from the target BSS... */
4739
4740 var PDU_ML3_NW_MS rr_ho_cmd := valueof(ts_RR_HandoverCommand);
4741 log("Remote cell's RR Handover Command passed through as L3 Info: ", rr_ho_cmd);
4742 var octetstring rr_ho_cmd_enc := enc_PDU_ML3_NW_MS(rr_ho_cmd);
4743 log("Remote cell's RR Handover Command passed through as L3 Info, encoded: ", rr_ho_cmd_enc);
4744 BSSAP.send(ts_BSSMAP_HandoverCommand(rr_ho_cmd_enc));
4745
4746 /* expect the Handover Command to go out on RR */
4747 var RSL_Message rsl_ho_cmd
4748 RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, ?)) -> value rsl_ho_cmd;
4749 log("RSL Data Req went out to first BTS: ", rsl_ho_cmd);
4750 var RSL_IE_Body rsl_ho_cmd_l3;
4751 if (not f_rsl_find_ie(rsl_ho_cmd, RSL_IE_L3_INFO, rsl_ho_cmd_l3)) {
4752 log("RSL message contains no L3 Info IE, expected RR Handover Command");
4753 setverdict(fail);
4754 } else {
4755 log("Found L3 Info: ", rsl_ho_cmd_l3);
4756 if (rsl_ho_cmd_l3.l3_info.payload != rr_ho_cmd_enc) {
4757 log("FAIL: the BSC sent out a different L3 Info, not matching the RR Handover Command the other BSS forwarded.");
4758 setverdict(fail);
4759 } else {
4760 log("Success: the BSC sent out the same RR Handover Command the other BSS forwarded.");
4761 setverdict(pass);
4762 }
4763 }
4764
Neels Hofmeyr10f2bfa2019-07-09 19:33:29 +02004765 /* We get neither success nor failure report from the remote BSS. Eventually T8 times out and we run into 3GPP
4766 * TS 48.008 3.1.5.3.3 "Abnormal Conditions": Clear Request should go to the MSC, and RR should be released
4767 * after Clear Command */
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004768
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02004769 var PDU_BSSAP rx_clear_request;
Neels Hofmeyre1797aa2019-07-09 19:34:04 +02004770 BSSAP.receive(tr_BSSMAP_ClearRequest) -> value rx_clear_request;
4771 log("Got BSSMAP Clear Request");
4772 /* Instruct BSC to clear channel */
4773 var BssmapCause cause := bit2int(rx_clear_request.pdu.bssmap.clearRequest.cause.causeValue);
4774 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
4775
4776 var MgcpCommand mgcp;
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004777 interleave {
Neels Hofmeyr861a4c12018-11-07 01:23:17 +01004778 [] RSL.receive(tr_RSL_DEACT_SACCH(g_chan_nr)) {
4779 log("Got Deact SACCH");
4780 }
Harald Welte924b6ea2019-02-04 01:05:34 +01004781 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_RELEASE)) {
Neels Hofmeyr211169d2018-11-07 00:37:29 +01004782 log("Got RR Release");
4783 }
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004784 [] RSL.receive(tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL)) {
4785 log("Got RF Chan Rel");
4786 RSL.send(ts_RSL_RF_CHAN_REL_ACK(g_chan_nr));
4787 }
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004788 }
4789
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02004790 f_expect_dlcx_conns();
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004791
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004792 setverdict(pass);
4793 f_sleep(1.0);
4794}
Neels Hofmeyrd8a602c2019-07-09 19:46:01 +02004795testcase TC_ho_out_fail_no_result_after_ho_cmd() runs on test_CT {
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004796 var MSC_ConnHdlr vc_conn;
4797
4798 f_init(1, true);
4799 f_sleep(1.0);
4800
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004801 f_ctrs_bsc_and_bts_init();
4802
Neels Hofmeyrd8a602c2019-07-09 19:46:01 +02004803 vc_conn := f_start_handler(refers(f_tc_ho_out_fail_no_result_after_ho_cmd));
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004804 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004805
4806 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
4807 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
4808 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
4809 f_ctrs_bsc_and_bts_add(0, "handover:timeout");
4810 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
4811 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:timeout");
4812 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004813 f_shutdown_helper();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004814}
4815
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004816private function f_tc_ho_into_this_bsc(charstring id) runs on MSC_ConnHdlr {
4817 /* Hack: the proper way would be to wait for the BSSMAP Handover Request ACK and extract the
4818 * actual assigned chan_nr from its L3 (RR Handover Command) message. But osmo-bsc starts acting
4819 * on the lchan even before we get a chance to evaluate the BSSMAP Handover Request ACK. So we
4820 * need to assume that osmo-bsc will activate TS 1 and already set up this lchan's RSL emulation
4821 * before we get started. */
4822 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
4823 f_rslem_register(0, new_chan_nr);
4824 g_chan_nr := new_chan_nr;
4825 f_sleep(1.0);
4826
4827 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
4828 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
4829 activate(as_Media());
4830
Neels Hofmeyr90f80962020-06-12 16:16:55 +02004831 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Pau Espin Pedrol07866632020-09-03 19:10:55 +02004832 f_gen_handover_req(aoip_tla := g_pars.host_aoip_tla)));
Harald Welte6811d102019-04-14 22:23:14 +02004833 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004834
4835 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
4836
4837 var PDU_BSSAP rx_bssap;
4838 var octetstring ho_command_str;
4839
4840 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
Pau Espin Pedrol76ba5412019-06-10 11:00:33 +02004841
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004842 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
4843 log("Received L3 Info in HO Request Ack: ", ho_command_str);
4844 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
4845 log("L3 Info in HO Request Ack is ", ho_command);
4846
4847 var GsmArfcn arfcn;
4848 var RslChannelNr actual_new_chan_nr;
4849 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
4850 actual_new_chan_nr, arfcn);
4851
4852 if (actual_new_chan_nr != new_chan_nr) {
4853 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
4854 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
4855 setverdict(fail);
4856 return;
4857 }
4858 log("Handover Command chan_nr is", actual_new_chan_nr);
4859
4860 /* Now the MSC forwards the RR Handover Command to the other BSC, which
4861 * tells the MS to handover to the new lchan. Here comes the new MS on
4862 * the new lchan with a Handover RACH: */
4863
4864 /* send handover detect */
4865
4866 RSL.send(ts_RSL_HANDO_DET(new_chan_nr));
4867
4868 BSSAP.receive(tr_BSSMAP_HandoverDetect);
4869
4870 /* send handover complete over the new channel */
4871
4872 var PDU_ML3_MS_NW l3_tx := valueof(ts_RRM_HandoverComplete('00'O));
4873 RSL.send(ts_RSL_EST_IND(new_chan_nr, valueof(ts_RslLinkID_DCCH(0)),
4874 enc_PDU_ML3_MS_NW(l3_tx)));
4875
4876 BSSAP.receive(tr_BSSMAP_HandoverComplete);
4877 setverdict(pass);
4878}
Pau Espin Pedrol07866632020-09-03 19:10:55 +02004879function f_tc_ho_into_this_bsc_main(TestHdlrParams pars) runs on test_CT {
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004880 var MSC_ConnHdlr vc_conn;
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004881
4882 f_init(1, true);
4883 f_sleep(1.0);
4884
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004885 f_ctrs_bsc_and_bts_init();
4886
Neels Hofmeyr90f80962020-06-12 16:16:55 +02004887 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
4888 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004889
4890 vc_conn := f_start_handler(refers(f_tc_ho_into_this_bsc), pars);
4891 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004892
4893 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
4894 f_ctrs_bsc_and_bts_add(0, "handover:completed");
4895 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:attempted");
4896 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:completed");
4897 f_ctrs_bsc_and_bts_verify();
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004898}
4899
Pau Espin Pedrol07866632020-09-03 19:10:55 +02004900testcase TC_ho_into_this_bsc() runs on test_CT {
4901 var TestHdlrParams pars := f_gen_test_hdlr_pars();
4902 f_tc_ho_into_this_bsc_main(pars);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004903 f_shutdown_helper();
Pau Espin Pedrol07866632020-09-03 19:10:55 +02004904}
4905
4906testcase TC_ho_into_this_bsc_tla_v6() runs on test_CT {
4907 var TestHdlrParams pars := f_gen_test_hdlr_pars();
4908 pars.host_aoip_tla := "::6";
4909 f_tc_ho_into_this_bsc_main(pars);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004910 f_shutdown_helper();
Pau Espin Pedrol07866632020-09-03 19:10:55 +02004911}
4912
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01004913private function f_tc_ho_in_fail_msc_clears(charstring id) runs on MSC_ConnHdlr {
4914 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
4915 f_rslem_register(0, new_chan_nr);
4916 g_chan_nr := new_chan_nr;
4917 f_sleep(1.0);
4918
4919 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
4920 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
4921 activate(as_Media());
4922
Neels Hofmeyr90f80962020-06-12 16:16:55 +02004923 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01004924 f_gen_handover_req()));
Harald Welte6811d102019-04-14 22:23:14 +02004925 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01004926
4927 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
4928
4929 var PDU_BSSAP rx_bssap;
4930 var octetstring ho_command_str;
4931
4932 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
4933
4934 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
4935 log("Received L3 Info in HO Request Ack: ", ho_command_str);
4936 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
4937 log("L3 Info in HO Request Ack is ", ho_command);
4938
4939 var GsmArfcn arfcn;
4940 var RslChannelNr actual_new_chan_nr;
4941 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
4942 actual_new_chan_nr, arfcn);
4943
4944 if (actual_new_chan_nr != new_chan_nr) {
4945 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
4946 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
4947 setverdict(fail);
4948 return;
4949 }
4950 log("Handover Command chan_nr is", actual_new_chan_nr);
4951
Neels Hofmeyr61ca08d2019-05-06 23:52:22 +02004952 /* For deterministic test results, give some time for the MGW endpoint to be configured */
4953 f_sleep(1.0);
4954
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01004955 /* Now the MSC forwards the RR Handover Command to the other BSC, which
4956 * tells the MS to handover to the new lchan. In this case, the MS
4957 * reports a Handover Failure to the old BSS, which forwards a BSSMAP
4958 * Handover Failure to the MSC. The procedure according to 3GPP TS
4959 * 48.008 3.1.5.3.2 "Handover Failure" is then that the MSC sends a
4960 * BSSMAP Clear Command: */
4961
4962 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_RADIO_INTERFACE_FAILURE_REVERSION;
4963 var BssmapCause cause := enum2int(cause_val);
4964 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
4965
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02004966 f_expect_dlcx_conns();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01004967 setverdict(pass);
4968 f_sleep(1.0);
4969
4970 setverdict(pass);
4971}
4972testcase TC_ho_in_fail_msc_clears() runs on test_CT {
4973 var MSC_ConnHdlr vc_conn;
4974 var TestHdlrParams pars := f_gen_test_hdlr_pars();
4975
4976 f_init(1, true);
4977 f_sleep(1.0);
4978
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004979 f_ctrs_bsc_and_bts_init();
4980
Neels Hofmeyr90f80962020-06-12 16:16:55 +02004981 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
4982 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01004983
4984 vc_conn := f_start_handler(refers(f_tc_ho_in_fail_msc_clears), pars);
4985 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004986
4987 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
4988 f_ctrs_bsc_and_bts_add(0, "handover:stopped");
4989 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:attempted");
4990 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:stopped");
4991 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004992 f_shutdown_helper();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01004993}
4994
4995private function f_tc_ho_in_fail_msc_clears_after_ho_detect(charstring id) runs on MSC_ConnHdlr {
4996 /* Hack: the proper way would be to wait for the BSSMAP Handover Request ACK and extract the
4997 * actual assigned chan_nr from its L3 (RR Handover Command) message. But osmo-bsc starts acting
4998 * on the lchan even before we get a chance to evaluate the BSSMAP Handover Request ACK. So we
4999 * need to assume that osmo-bsc will activate TS 1 and already set up this lchan's RSL emulation
5000 * before we get started. */
5001 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
5002 f_rslem_register(0, new_chan_nr);
5003 g_chan_nr := new_chan_nr;
5004 f_sleep(1.0);
5005
5006 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
5007 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
5008 activate(as_Media());
5009
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005010 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005011 f_gen_handover_req()));
Harald Welte6811d102019-04-14 22:23:14 +02005012 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005013
5014 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
5015
5016 var PDU_BSSAP rx_bssap;
5017 var octetstring ho_command_str;
5018
5019 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
5020
5021 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
5022 log("Received L3 Info in HO Request Ack: ", ho_command_str);
5023 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
5024 log("L3 Info in HO Request Ack is ", ho_command);
5025
5026 var GsmArfcn arfcn;
5027 var RslChannelNr actual_new_chan_nr;
5028 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
5029 actual_new_chan_nr, arfcn);
5030
5031 if (actual_new_chan_nr != new_chan_nr) {
5032 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
5033 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
5034 setverdict(fail);
5035 return;
5036 }
5037 log("Handover Command chan_nr is", actual_new_chan_nr);
5038
5039 /* Now the MSC forwards the RR Handover Command to the other BSC, which
5040 * tells the MS to handover to the new lchan. Here comes the new MS on
5041 * the new lchan with a Handover RACH: */
5042
5043 /* send handover detect */
5044
5045 RSL.send(ts_RSL_HANDO_DET(new_chan_nr));
5046
5047 BSSAP.receive(tr_BSSMAP_HandoverDetect);
5048
5049 /* The MSC chooses to clear the connection now, maybe we got the
5050 * Handover RACH on the new cell but the MS still signaled Handover
5051 * Failure to the old BSS? */
5052
5053 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_RADIO_INTERFACE_FAILURE_REVERSION;
5054 var BssmapCause cause := enum2int(cause_val);
5055 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
5056
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02005057 f_expect_dlcx_conns();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005058 f_sleep(1.0);
5059}
5060testcase TC_ho_in_fail_msc_clears_after_ho_detect() runs on test_CT {
5061 var MSC_ConnHdlr vc_conn;
5062 var TestHdlrParams pars := f_gen_test_hdlr_pars();
5063
5064 f_init(1, true);
5065 f_sleep(1.0);
5066
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005067 f_ctrs_bsc_and_bts_init();
5068
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005069 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
5070 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005071
5072 vc_conn := f_start_handler(refers(f_tc_ho_in_fail_msc_clears_after_ho_detect), pars);
5073 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005074
5075 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5076 f_ctrs_bsc_and_bts_add(0, "handover:stopped");
5077 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:attempted");
5078 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:stopped");
5079 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005080 f_shutdown_helper();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005081}
5082
5083/* The new BSS's lchan times out before the MSC decides that handover failed. */
5084private function f_tc_ho_in_fail_no_detect(charstring id) runs on MSC_ConnHdlr {
5085 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
5086 f_rslem_register(0, new_chan_nr);
5087 g_chan_nr := new_chan_nr;
5088 f_sleep(1.0);
5089
5090 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
5091 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
5092 activate(as_Media());
5093
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005094 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005095 f_gen_handover_req()));
Harald Welte6811d102019-04-14 22:23:14 +02005096 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005097
5098 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
5099
5100 var PDU_BSSAP rx_bssap;
5101 var octetstring ho_command_str;
5102
5103 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
5104
5105 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
5106 log("Received L3 Info in HO Request Ack: ", ho_command_str);
5107 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
5108 log("L3 Info in HO Request Ack is ", ho_command);
5109
5110 var GsmArfcn arfcn;
5111 var RslChannelNr actual_new_chan_nr;
5112 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
5113 actual_new_chan_nr, arfcn);
5114
5115 if (actual_new_chan_nr != new_chan_nr) {
5116 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
5117 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
5118 setverdict(fail);
5119 return;
5120 }
5121 log("Handover Command chan_nr is", actual_new_chan_nr);
5122
5123 /* Now the MSC forwards the RR Handover Command to the other BSC, which
5124 * tells the MS to handover to the new lchan. But the MS never shows up
5125 * on the new lchan. */
5126
5127 BSSAP.receive(tr_BSSMAP_HandoverFailure);
5128
5129 /* Did osmo-bsc also send a Clear Request? */
5130 timer T := 0.5;
5131 T.start;
5132 alt {
5133 [] BSSAP.receive(tr_BSSMAP_ClearRequest);
5134 [] T.timeout { }
5135 }
5136
5137 /* MSC plays along with a Clear Command (no matter whether osmo-bsc
5138 * asked for it, this is a Handover Failure after all). */
5139
5140 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_RADIO_INTERFACE_FAILURE_REVERSION;
5141 var BssmapCause cause := enum2int(cause_val);
5142 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
5143
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02005144 f_expect_dlcx_conns();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005145 f_sleep(1.0);
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005146}
5147testcase TC_ho_in_fail_no_detect() runs on test_CT {
5148 var MSC_ConnHdlr vc_conn;
5149 var TestHdlrParams pars := f_gen_test_hdlr_pars();
5150
5151 f_init(1, true);
5152 f_sleep(1.0);
5153
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005154 f_ctrs_bsc_and_bts_init();
5155
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005156 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
5157 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005158
5159 vc_conn := f_start_handler(refers(f_tc_ho_in_fail_no_detect), pars);
5160 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005161
5162 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5163 f_ctrs_bsc_and_bts_add(0, "handover:error");
5164 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:attempted");
5165 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:error");
5166 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005167 f_shutdown_helper();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005168}
5169
5170/* Same as f_tc_ho_in_fail_no_detect, but MSC fails to send a Clear Command */
5171private function f_tc_ho_in_fail_no_detect2(charstring id) runs on MSC_ConnHdlr {
5172 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
5173 f_rslem_register(0, new_chan_nr);
5174 g_chan_nr := new_chan_nr;
5175 f_sleep(1.0);
5176
5177 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
5178 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
5179 activate(as_Media());
5180
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005181 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005182 f_gen_handover_req()));
Harald Welte6811d102019-04-14 22:23:14 +02005183 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005184
5185 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
5186
5187 var PDU_BSSAP rx_bssap;
5188 var octetstring ho_command_str;
5189
5190 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
5191
5192 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
5193 log("Received L3 Info in HO Request Ack: ", ho_command_str);
5194 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
5195 log("L3 Info in HO Request Ack is ", ho_command);
5196
5197 var GsmArfcn arfcn;
5198 var RslChannelNr actual_new_chan_nr;
5199 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
5200 actual_new_chan_nr, arfcn);
5201
5202 if (actual_new_chan_nr != new_chan_nr) {
5203 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
5204 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
5205 setverdict(fail);
5206 return;
5207 }
5208 log("Handover Command chan_nr is", actual_new_chan_nr);
5209
5210 /* Now the MSC forwards the RR Handover Command to the other BSC, which
5211 * tells the MS to handover to the new lchan. But the MS never shows up
5212 * on the new lchan. */
5213
5214 BSSAP.receive(tr_BSSMAP_HandoverFailure);
5215
5216 /* MSC plays dumb and sends no Clear Command */
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005217 var PDU_BSSAP rx_clear_request;
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02005218
5219 BSSAP.receive(tr_BSSMAP_ClearRequest) -> value rx_clear_request {
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005220 var BssmapCause cause := bit2int(rx_clear_request.pdu.bssmap.clearRequest.cause.causeValue);
5221 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
5222 };
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02005223 f_expect_dlcx_conns();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005224 f_sleep(1.0);
5225}
5226testcase TC_ho_in_fail_no_detect2() runs on test_CT {
5227 var MSC_ConnHdlr vc_conn;
5228 var TestHdlrParams pars := f_gen_test_hdlr_pars();
5229
5230 f_init(1, true);
5231 f_sleep(1.0);
5232
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005233 f_ctrs_bsc_and_bts_init();
5234
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005235 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
5236 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005237
5238 vc_conn := f_start_handler(refers(f_tc_ho_in_fail_no_detect2), pars);
5239 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005240
5241 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5242 f_ctrs_bsc_and_bts_add(0, "handover:error");
5243 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:attempted");
5244 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:error");
5245 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005246 f_shutdown_helper();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005247}
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005248
Neels Hofmeyr91401012019-07-11 00:42:35 +02005249type record of charstring Commands;
5250
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005251private function f_bts_0_cfg(TELNETasp_PT pt, Commands cmds := {})
Neels Hofmeyr91401012019-07-11 00:42:35 +02005252{
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005253 f_vty_enter_cfg_bts(pt, 0);
Neels Hofmeyr91401012019-07-11 00:42:35 +02005254 for (var integer i := 0; i < sizeof(cmds); i := i+1) {
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005255 f_vty_transceive(pt, cmds[i]);
Neels Hofmeyr91401012019-07-11 00:42:35 +02005256 }
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005257 f_vty_transceive(pt, "end");
Neels Hofmeyr91401012019-07-11 00:42:35 +02005258}
5259
Pau Espin Pedrolc675b612020-01-09 19:55:40 +01005260private function f_cs7_inst_0_cfg(TELNETasp_PT pt, Commands cmds := {})
5261{
5262 f_vty_enter_cfg_cs7_inst(pt, 0);
5263 for (var integer i := 0; i < sizeof(cmds); i := i+1) {
5264 f_vty_transceive(pt, cmds[i]);
5265 }
5266 f_vty_transceive(pt, "end");
5267}
5268
Neels Hofmeyr91401012019-07-11 00:42:35 +02005269private function f_probe_for_handover(charstring log_label,
5270 charstring log_descr,
5271 charstring handover_vty_cmd,
5272 boolean expect_handover,
5273 boolean is_inter_bsc_handover := false)
5274runs on MSC_ConnHdlr
5275{
Neels Hofmeyrb3fc8982020-05-11 00:16:42 +02005276 /* We're going to thwart any and all handover attempts, just be ready to handle (and ignore) handover target
5277 * lchans to be established on bts 1 or bts 2. */
5278 f_rslem_suspend(RSL1_PROC);
5279 f_rslem_suspend(RSL2_PROC);
5280
Neels Hofmeyr91401012019-07-11 00:42:35 +02005281 var RSL_Message rsl;
5282
5283 var charstring log_msg := " (expecting handover)"
5284 if (not expect_handover) {
5285 log_msg := " (expecting NO handover)";
5286 }
5287 log("f_probe_for_handover starting: " & log_label & ": " & log_descr & log_msg);
5288 f_vty_transceive(BSCVTY, handover_vty_cmd);
5289
Neels Hofmeyr91401012019-07-11 00:42:35 +02005290 timer T := 2.0;
5291 T.start;
5292
5293 alt {
5294 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr)) -> value rsl {
5295 var PDU_ML3_NW_MS l3 := dec_PDU_ML3_NW_MS(rsl.ies[2].body.l3_info.payload);
5296 log("Rx L3 from net: ", l3);
5297 if (ischosen(l3.msgs.rrm.handoverCommand)) {
5298 var RslChannelNr new_chan_nr;
5299 var GsmArfcn arfcn;
5300 f_ChDesc2RslChanNr(l3.msgs.rrm.handoverCommand.channelDescription2,
5301 new_chan_nr, arfcn);
5302 log("Handover to new chan ", new_chan_nr, " on ARFCN ", arfcn);
5303 log(l3.msgs.rrm.handoverCommand);
5304
5305 /* Need to register for new lchan on new BTS -- it's either bts 1 or bts 2. It doesn't really
5306 * matter on which BTS it really is, we're not going to follow through an entire handover
5307 * anyway. */
5308 f_rslem_register(0, new_chan_nr, RSL1_PROC);
5309 f_rslem_resume(RSL1_PROC);
5310 f_rslem_register(0, new_chan_nr, RSL2_PROC);
5311 f_rslem_resume(RSL2_PROC);
5312
5313 if (expect_handover and not is_inter_bsc_handover) {
5314 setverdict(pass);
5315 log("f_probe_for_handover(" & log_label & "): Got RSL Handover Command as expected.");
5316 } else {
5317 setverdict(fail, "f_probe_for_handover(" & log_label & "): Expected none, but got RSL Handover Command. "
5318 & log_label & ": " & log_descr);
5319 }
5320
5321 log("f_probe_for_handover(" & log_label & "): Ending the test: Handover Failure stops the procedure.");
5322 /* osmo-bsc has triggered Handover. That's all we need to know for this test, reply with
5323 * Handover Failure. */
5324 f_rsl_send_l3(ts_RRM_HandoverFailure('00'O));
5325
5326 /* target BTS is told to release lchan again; don't care which BTS nor what messages. */
5327 f_sleep(0.5);
5328 RSL1.clear;
5329 RSL2.clear;
5330 log("f_probe_for_handover(" & log_label & "): done (got RSL Handover Command)");
5331 break;
5332 } else {
5333 repeat;
5334 }
5335 }
5336 [] BSSAP.receive(tr_BSSMAP_HandoverRequired) {
5337 if (expect_handover and is_inter_bsc_handover) {
5338 setverdict(pass);
5339 log("f_probe_for_handover(" & log_label & "): Got BSSMAP Handover Required as expected.");
5340 } else {
5341 setverdict(fail, "f_probe_for_handover(" & log_label & "): Expected none, but got BSSMAP Handover Required. "
5342 & log_label & ": " & log_descr);
5343 }
5344
5345 log("f_probe_for_handover(" & log_label & "): done (got BSSMAP Handover Required)");
5346
5347 /* Note: f_tc_ho_neighbor_config_start() sets T7, the timeout for BSSMAP Handover Required, to
5348 * 1 second. There is no legal way to quickly abort a handover after a BSSMAP Handover Required,
5349 * setting a short timeout and waiting is the only way. */
5350 log("f_probe_for_handover(" & log_label & "): waiting for inter-BSC HO to time out...");
5351 f_sleep(1.5);
5352 log("f_probe_for_handover(" & log_label & "): ...done");
5353
5354 break;
5355 }
5356 [] T.timeout {
5357 if (expect_handover) {
5358 setverdict(fail, "f_probe_for_handover(" & log_label & "): Expected Handover, but got none. "
5359 & log_label & ": " & log_descr);
5360 } else {
5361 setverdict(pass);
5362 log("f_probe_for_handover(" & log_label & "): Got no Handover, as expected.");
5363 }
5364 log("f_probe_for_handover(" & log_label & "): done (got no Handover)");
5365 break;
5366 }
5367 }
5368
5369 f_rslem_resume(RSL1_PROC);
5370 f_rslem_resume(RSL2_PROC);
5371 f_sleep(3.0);
5372 RSL.clear;
5373
5374 log("f_probe_for_handover(" & log_label & "): done clearing");
5375}
5376
5377/* Test the effect of various neighbor configuration scenarios:
5378 *
5379 * To avoid complexity, block off any actual handover operation, and always remain on the lchan at bts 0.
5380 * Reconfigure the neighbors for bts 0, trigger a Handover, and probe whether osmo-bsc does or doesn't start HO.
5381 */
5382private function f_tc_ho_neighbor_config_start() runs on MSC_ConnHdlr {
5383 g_pars := f_gen_test_hdlr_pars();
5384 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
5385 var PDU_BSSAP ass_cmd := f_gen_ass_req();
5386 const OCT8 kc := '0001020304050607'O;
5387
5388 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
5389 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
5390
5391 /* Establish lchan at bts 0 */
5392 f_establish_fully(ass_cmd, exp_compl);
5393
5394 /* Shorten the inter-BSC Handover timeout, to not wait so long for inter-BSC Handovers */
5395 f_vty_enter_cfg_network(BSCVTY);
5396 f_vty_transceive(BSCVTY, "timer T7 1");
5397 f_vty_transceive(BSCVTY, "end");
5398}
5399
5400private function f_tc_ho_neighbor_config_1(charstring id) runs on MSC_ConnHdlr {
5401 f_tc_ho_neighbor_config_start();
5402
5403 /*
5404 * bts 0 ARFCN 871 BSIC 10
5405 * bts 1 ARFCN 871 BSIC 11
5406 * bts 2 ARFCN 871 BSIC 12
5407 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
5408 */
5409
5410 log("f_tc_ho_neighbor_config: 1. No 'neighbor' config");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005411 f_bts_0_cfg(BSCVTY, {"no neighbors"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02005412 f_probe_for_handover("1.a", "HO to bts 1 works, implicitly listed as neighbor (legacy behavior when none are configured)",
5413 "handover any to arfcn 871 bsic 11",
5414 true);
5415
5416 f_probe_for_handover("1.b", "HO to unknown cell does not start",
5417 "handover any to arfcn 13 bsic 39",
5418 false);
5419
5420 f_probe_for_handover("1.c", "HO to 871-12 is ambiguous = error",
5421 "handover any to arfcn 871 bsic 12",
5422 false);
5423
5424 f_probe_for_handover("1.d", "HO to 871-11 still works (verify that this test properly cleans up)",
5425 "handover any to arfcn 871 bsic 11",
5426 true);
5427}
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005428testcase TC_ho_neighbor_config_1() runs on test_CT {
5429 var MSC_ConnHdlr vc_conn;
5430 f_init(3, true, guard_timeout := 60.0);
5431 f_sleep(1.0);
5432 f_ctrs_bsc_and_bts_init();
5433 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_1));
5434 vc_conn.done;
5435
5436 /* f_tc_ho_neighbor_config_start() */
5437 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5438 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5439
5440 /* 1.a */
5441 /* "failed" means a handover was triggered and started (which is all this test aims for) and the test ended the
5442 * handover quickly by sending a Handover Failure message. */
5443 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5444 f_ctrs_bsc_and_bts_add(0, "handover:failed");
5445 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
5446 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:failed");
5447
5448 /* 1.b */
5449 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5450 f_ctrs_bsc_and_bts_add(0, "handover:error");
5451
5452 /* 1.c */
5453 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5454 f_ctrs_bsc_and_bts_add(0, "handover:error");
5455
5456 /* 1.d */
5457 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5458 f_ctrs_bsc_and_bts_add(0, "handover:failed");
5459 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
5460 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:failed");
5461
5462 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005463 f_shutdown_helper();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005464}
5465
Neels Hofmeyr91401012019-07-11 00:42:35 +02005466private function f_tc_ho_neighbor_config_2(charstring id) runs on MSC_ConnHdlr {
5467 f_tc_ho_neighbor_config_start();
5468
5469 /*
5470 * bts 0 ARFCN 871 BSIC 10
5471 * bts 1 ARFCN 871 BSIC 11
5472 * bts 2 ARFCN 871 BSIC 12
5473 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
5474 */
5475
5476 log("f_tc_ho_neighbor_config: 2. explicit local neighbor: 'neighbor bts 1'");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005477 f_bts_0_cfg(BSCVTY, {"neighbor bts 1"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02005478 f_sleep(0.5);
5479
5480 f_probe_for_handover("2.a", "HO to bts 1 works, explicitly listed as neighbor",
5481 "handover any to arfcn 871 bsic 11",
5482 true);
5483
5484 f_probe_for_handover("2.b", "HO to bts 2 doesn't work, not listed as neighbor",
5485 "handover any to arfcn 871 bsic 12",
5486 false);
5487}
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005488testcase TC_ho_neighbor_config_2() runs on test_CT {
5489 var MSC_ConnHdlr vc_conn;
5490 f_init(3, true, guard_timeout := 50.0);
5491 f_sleep(1.0);
5492 f_ctrs_bsc_and_bts_init();
5493 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_2));
5494 vc_conn.done;
5495
5496 /* f_tc_ho_neighbor_config_start() */
5497 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5498 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5499
5500 /* 2.a */
5501 /* "failed" means a handover was triggered and started (which is all this test aims for) and the test ended the
5502 * handover quickly by sending a Handover Failure message. */
5503 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5504 f_ctrs_bsc_and_bts_add(0, "handover:failed");
5505 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
5506 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:failed");
5507
5508 /* 2.b */
5509 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5510 f_ctrs_bsc_and_bts_add(0, "handover:error");
5511
5512 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005513 f_shutdown_helper();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005514}
5515
Neels Hofmeyr91401012019-07-11 00:42:35 +02005516private function f_tc_ho_neighbor_config_3(charstring id) runs on MSC_ConnHdlr {
5517 f_tc_ho_neighbor_config_start();
5518
5519 /*
5520 * bts 0 ARFCN 871 BSIC 10
5521 * bts 1 ARFCN 871 BSIC 11
5522 * bts 2 ARFCN 871 BSIC 12
5523 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
5524 */
5525
5526 log("f_tc_ho_neighbor_config: 3. explicit local neighbor: 'neighbor bts 2'");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005527 f_bts_0_cfg(BSCVTY, {"no neighbors", "neighbor bts 2"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02005528 f_sleep(0.5);
5529
5530 f_probe_for_handover("3.a", "HO to bts 1 doesn't work, not listed as neighbor",
5531 "handover any to arfcn 871 bsic 11",
5532 false);
5533 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",
5534 "handover any to arfcn 871 bsic 12",
5535 true);
5536}
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005537testcase TC_ho_neighbor_config_3() runs on test_CT {
5538 var MSC_ConnHdlr vc_conn;
5539 f_init(3, true, guard_timeout := 50.0);
5540 f_sleep(1.0);
5541 f_ctrs_bsc_and_bts_init();
5542 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_3));
5543 vc_conn.done;
5544
5545 /* f_tc_ho_neighbor_config_start() */
5546 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5547 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5548
5549 /* 3.a */
5550 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5551 f_ctrs_bsc_and_bts_add(0, "handover:error");
5552
5553 /* 3.b */
5554 /* "failed" means a handover was triggered and started (which is all this test aims for) and the test ended the
5555 * handover quickly by sending a Handover Failure message. */
5556 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5557 f_ctrs_bsc_and_bts_add(0, "handover:failed");
5558 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
5559 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:failed");
5560
5561 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005562 f_shutdown_helper();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005563}
5564
Neels Hofmeyr91401012019-07-11 00:42:35 +02005565private function f_tc_ho_neighbor_config_4(charstring id) runs on MSC_ConnHdlr {
5566 f_tc_ho_neighbor_config_start();
5567
5568 /*
5569 * bts 0 ARFCN 871 BSIC 10
5570 * bts 1 ARFCN 871 BSIC 11
5571 * bts 2 ARFCN 871 BSIC 12
5572 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
5573 */
5574
5575 log("f_tc_ho_neighbor_config: 4. explicit remote neighbor: 'neighbor lac 99 arfcn 123 bsic 45'");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005576 f_bts_0_cfg(BSCVTY, {"no neighbors", "neighbor lac 99 arfcn 123 bsic 45"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02005577 f_sleep(0.5);
5578
5579 f_probe_for_handover("4.a", "HO to bts 1 doesn't work, not listed as neighbor",
5580 "handover any to arfcn 871 bsic 11",
5581 false);
5582 f_probe_for_handover("4.b", "HO to bts 2 doesn't work, not listed as neighbor",
5583 "handover any to arfcn 871 bsic 12",
5584 false);
5585 f_probe_for_handover("4.c", "HO to 123-45 triggers inter-BSC HO",
5586 "handover any to arfcn 123 bsic 45",
5587 true, true);
5588}
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005589testcase TC_ho_neighbor_config_4() runs on test_CT {
5590 var MSC_ConnHdlr vc_conn;
5591 f_init(3, true, guard_timeout := 50.0);
5592 f_sleep(1.0);
5593 f_ctrs_bsc_and_bts_init();
5594 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_4));
5595 vc_conn.done;
5596
5597 /* f_tc_ho_neighbor_config_start() */
5598 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5599 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5600
5601 /* 4.a */
5602 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5603 f_ctrs_bsc_and_bts_add(0, "handover:error");
5604
5605 /* 4.b */
5606 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5607 f_ctrs_bsc_and_bts_add(0, "handover:error");
5608
5609 /* 4.c */
5610 /* "timeout" means a handover was triggered and started (which is all this test aims for) and the test ended the
5611 * handover quickly by timing out after the Handover Required message */
5612 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5613 f_ctrs_bsc_and_bts_add(0, "handover:timeout");
5614 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
5615 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:timeout");
5616
5617 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005618 f_shutdown_helper();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005619}
5620
Neels Hofmeyr91401012019-07-11 00:42:35 +02005621private function f_tc_ho_neighbor_config_5(charstring id) runs on MSC_ConnHdlr {
5622 f_tc_ho_neighbor_config_start();
5623
5624 /*
5625 * bts 0 ARFCN 871 BSIC 10
5626 * bts 1 ARFCN 871 BSIC 11
5627 * bts 2 ARFCN 871 BSIC 12
5628 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
5629 */
5630
5631 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 +02005632 f_bts_0_cfg(BSCVTY, {"no neighbors", "neighbor lac 99 arfcn 871 bsic 12"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02005633 f_sleep(0.5);
5634
5635 f_probe_for_handover("5.a", "HO to 871-12 triggers inter-BSC HO (ignoring local cells with same ARFCN+BSIC)",
5636 "handover any to arfcn 871 bsic 12",
5637 true, true);
5638}
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005639testcase TC_ho_neighbor_config_5() runs on test_CT {
5640 var MSC_ConnHdlr vc_conn;
5641 f_init(3, true);
5642 f_sleep(1.0);
5643 f_ctrs_bsc_and_bts_init();
5644 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_5));
5645 vc_conn.done;
5646
5647 /* f_tc_ho_neighbor_config_start() */
5648 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5649 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5650
5651 /* 5 */
5652 /* "timeout" means a handover was triggered and started (which is all this test aims for) and the test ended the
5653 * handover quickly by timing out after the Handover Required message */
5654 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5655 f_ctrs_bsc_and_bts_add(0, "handover:timeout");
5656 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
5657 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:timeout");
5658
5659 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005660 f_shutdown_helper();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005661}
5662
Neels Hofmeyr91401012019-07-11 00:42:35 +02005663private function f_tc_ho_neighbor_config_6(charstring id) runs on MSC_ConnHdlr {
5664 f_tc_ho_neighbor_config_start();
5665
5666 /*
5667 * bts 0 ARFCN 871 BSIC 10
5668 * bts 1 ARFCN 871 BSIC 11
5669 * bts 2 ARFCN 871 BSIC 12
5670 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
5671 */
5672
5673 log("f_tc_ho_neighbor_config: 6. config error: explicit local and remote neighbors with ambiguous ARFCN+BSIC:"
5674 & " 'neighbor bts 2; neighbor lac 99 arfcn 871 bsic 12'");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005675 f_bts_0_cfg(BSCVTY, {"no neighbors", "neighbor bts 2", "neighbor lac 99 arfcn 871 bsic 12"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02005676 f_sleep(0.5);
5677
5678 f_probe_for_handover("6.a", "HO to 871-12 is ambiguous = error",
5679 "handover any to arfcn 871 bsic 12",
5680 false);
5681}
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005682testcase TC_ho_neighbor_config_6() runs on test_CT {
5683 var MSC_ConnHdlr vc_conn;
5684 f_init(3, true);
5685 f_sleep(1.0);
5686 f_ctrs_bsc_and_bts_init();
5687 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_6));
5688 vc_conn.done;
5689
5690 /* f_tc_ho_neighbor_config_start() */
5691 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5692 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5693
5694 /* 6.a */
5695 /* "timeout" means a handover was triggered and started (which is all this test aims for) and the test ended the
5696 * handover quickly by timing out after the Handover Required message */
5697 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5698 f_ctrs_bsc_and_bts_add(0, "handover:error");
5699
5700 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005701 f_shutdown_helper();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005702}
5703
Neels Hofmeyr91401012019-07-11 00:42:35 +02005704private function f_tc_ho_neighbor_config_7(charstring id) runs on MSC_ConnHdlr {
5705 f_tc_ho_neighbor_config_start();
5706
5707 /*
5708 * bts 0 ARFCN 871 BSIC 10
5709 * bts 1 ARFCN 871 BSIC 11
5710 * bts 2 ARFCN 871 BSIC 12
5711 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
5712 */
5713
5714 log("f_tc_ho_neighbor_config: 7. explicit local and remote neighbors:"
5715 & " 'neighbor bts 2; neighbor lac 99 arfcn 123 bsic 45'");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005716 f_bts_0_cfg(BSCVTY, {"no neighbors", "neighbor bts 2", "neighbor lac 99 arfcn 123 bsic 45"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02005717 f_sleep(0.5);
5718
5719 f_probe_for_handover("7.a", "HO to 871-12 does HO to bts 2",
5720 "handover any to arfcn 871 bsic 12",
5721 true);
5722 f_probe_for_handover("7.b", "HO to 123-45 triggers inter-BSC HO",
5723 "handover any to arfcn 123 bsic 45",
5724 true, true);
5725}
Neels Hofmeyr91401012019-07-11 00:42:35 +02005726testcase TC_ho_neighbor_config_7() runs on test_CT {
5727 var MSC_ConnHdlr vc_conn;
Neels Hofmeyrf2b88032020-06-16 00:35:04 +02005728 f_init(3, true, guard_timeout := 50.0);
Neels Hofmeyr91401012019-07-11 00:42:35 +02005729 f_sleep(1.0);
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005730 f_ctrs_bsc_and_bts_init();
Neels Hofmeyr91401012019-07-11 00:42:35 +02005731 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_7));
5732 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005733
5734 /* f_tc_ho_neighbor_config_start() */
5735 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5736 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5737
5738 /* 7.a */
5739 /* "failed" means a handover was triggered and started (which is all this test aims for) and the test ended the
5740 * handover quickly by sending a Handover Failure message. */
5741 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5742 f_ctrs_bsc_and_bts_add(0, "handover:failed");
5743 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
5744 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:failed");
5745
5746 /* 7.b */
5747 /* "timeout" means a handover was triggered and started (which is all this test aims for) and the test ended the
5748 * handover quickly by timing out after the Handover Required message */
5749 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5750 f_ctrs_bsc_and_bts_add(0, "handover:timeout");
5751 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
5752 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:timeout");
5753
5754 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005755 f_shutdown_helper();
Neels Hofmeyr91401012019-07-11 00:42:35 +02005756}
5757
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01005758/* OS#3041: Open and close N connections in a normal fashion, and expect no
5759 * BSSMAP Reset just because of that. */
5760testcase TC_bssap_rlsd_does_not_cause_bssmap_reset() runs on test_CT {
5761 var default d;
5762 var integer i;
5763 var DchanTuple dt;
5764
5765 f_init();
5766
5767 /* Wait for initial BSSMAP Reset to pass */
5768 f_sleep(4.0);
5769
5770 d := activate(no_bssmap_reset());
5771
5772 /* Setup up a number of connections and RLSD them again from the MSC
5773 * side. In the buggy behavior, the fourth one triggers BSSMAP Reset.
5774 * Let's do it some more times for good measure. */
Harald Weltec3260d92018-06-11 17:48:16 +02005775 for (i := 0; i < 4; i := i+1) {
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01005776 /* Since we're doing a lot of runs, give each one a fresh
5777 * T_guard from the top. */
5778 T_guard.start;
5779
5780 /* Setup a BSSAP connection and clear it right away. This is
5781 * the MSC telling the BSC about a planned release, it's not an
5782 * erratic loss of a connection. */
Harald Weltea1897182018-06-11 13:53:09 +02005783 dt := f_est_dchan(int2oct(i,1), 23+i, '00010203040506'O);
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01005784
5785 /* MSC disconnects (RLSD). */
5786 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
5787 }
5788
5789 /* In the buggy behavior, a timeout of 2 seconds happens between above
5790 * trigger (logs "SIGTRAN connection down, reconnecting...") and the
5791 * actual BSSMAP Reset. Wait a bit longer just to make sure. */
5792 f_sleep(4.0);
5793
5794 deactivate(d);
5795 f_shutdown_helper();
5796}
Harald Welte552620d2017-12-16 23:21:36 +01005797
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01005798/* OS#3041: Open and close N connections in a normal fashion, and expect no
5799 * BSSMAP Reset just because of that. Invoke the release by a BSSMAP Clear from
5800 * the MSC. */
5801testcase TC_bssmap_clear_does_not_cause_bssmap_reset() runs on test_CT {
5802 var default d;
5803 var integer i;
5804 var DchanTuple dt;
5805 var BSSAP_N_DATA_ind rx_di;
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01005806 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_CALL_CONTROL;
5807 var BssmapCause cause := enum2int(cause_val);
5808
5809 f_init();
5810
5811 /* Wait for initial BSSMAP Reset to pass */
5812 f_sleep(4.0);
5813
5814 d := activate(no_bssmap_reset());
5815
5816 /* Setup up a number of connections and RLSD them again from the MSC
5817 * side. In the buggy behavior, the fourth one triggers BSSMAP Reset.
5818 * Let's do it some more times for good measure. */
5819 for (i := 0; i < 8; i := i+1) {
5820 /* Since we're doing a lot of runs, give each one a fresh
5821 * T_guard from the top. */
5822 T_guard.start;
5823
5824 /* Setup a BSSAP connection and clear it right away. This is
5825 * the MSC telling the BSC about a planned release, it's not an
5826 * erratic loss of a connection. */
Harald Weltea1897182018-06-11 13:53:09 +02005827 dt := f_est_dchan(int2oct(i,1), 23+i, '00010203040506'O);
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01005828
5829 /* Instruct BSC to clear channel */
5830 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
5831
5832 /* expect BSC to disable the channel */
Harald Welte641fcbe2018-06-14 10:58:35 +02005833 f_exp_chan_rel_and_clear(dt, 0);
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01005834 }
5835
5836 /* In the buggy behavior, a timeout of 2 seconds happens between above
5837 * trigger (logs "SIGTRAN connection down, reconnecting...") and the
5838 * actual BSSMAP Reset. Wait a bit longer just to make sure. */
5839 f_sleep(4.0);
5840
5841 deactivate(d);
5842 f_shutdown_helper();
5843}
5844
Neels Hofmeyrfd445c32018-03-09 15:39:31 +01005845/* OS#3041: Open and close N connections in a normal fashion, and expect no
5846 * BSSMAP Reset just because of that. Close connections from the MS side with a
5847 * Release Ind on RSL. */
5848testcase TC_ms_rel_ind_does_not_cause_bssmap_reset() runs on test_CT {
5849 var default d;
5850 var integer i;
5851 var DchanTuple dt;
5852 var BSSAP_N_DATA_ind rx_di;
Neels Hofmeyrfd445c32018-03-09 15:39:31 +01005853 var integer j;
5854
5855 f_init();
5856
5857 /* Wait for initial BSSMAP Reset to pass */
5858 f_sleep(4.0);
5859
5860 d := activate(no_bssmap_reset());
5861
5862 /* Setup up a number of connections and RLSD them again from the MSC
5863 * side. In the buggy behavior, the fourth one triggers BSSMAP Reset.
5864 * Let's do it some more times for good measure. */
5865 for (i := 0; i < 8; i := i+1) {
5866 /* Since we're doing a lot of runs, give each one a fresh
5867 * T_guard from the top. */
5868 T_guard.start;
5869
5870 /* Setup a BSSAP connection and clear it right away. This is
5871 * the MSC telling the BSC about a planned release, it's not an
5872 * erratic loss of a connection. */
5873 dt := f_est_dchan('23'O, 23, '00010203040506'O);
5874
5875 /* simulate RLL REL IND */
5876 f_ipa_tx(0, ts_RSL_REL_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0))));
5877
5878 /* expect Clear Request on MSC side */
5879 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearRequest)) -> value rx_di;
5880
5881 /* Instruct BSC to clear channel */
5882 var BssmapCause cause := bit2int(rx_di.userData.pdu.bssmap.clearRequest.cause.causeValue);
5883 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
5884
5885 /* expect BSC to disable the channel */
Harald Welte641fcbe2018-06-14 10:58:35 +02005886 f_exp_chan_rel_and_clear(dt, 0);
Neels Hofmeyrfd445c32018-03-09 15:39:31 +01005887 }
5888
5889 /* In the buggy behavior, a timeout of 2 seconds happens between above
5890 * trigger (logs "SIGTRAN connection down, reconnecting...") and the
5891 * actual BSSMAP Reset. Wait a bit longer just to make sure. */
5892 f_sleep(4.0);
5893
5894 deactivate(d);
5895 f_shutdown_helper();
5896}
5897
Harald Welte94e0c342018-04-07 11:33:23 +02005898/***********************************************************************
5899 * IPA style dynamic PDCH
5900 ***********************************************************************/
5901
5902private function f_dyn_ipa_pdch_act(integer bts_nr, integer trx_nr, integer ts_nr,
5903 template (omit) RSL_Cause nack := omit)
5904runs on test_CT {
5905 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(ts_nr));
5906 var RSL_Message rsl_unused;
5907 /* ask BSC via VTY to activate a given IPA style chan as PDCH */
5908 f_vty_ts_action("pdch activate", bts_nr, trx_nr, ts_nr);
5909 /* expect the BSC to issue the related RSL command */
5910 rsl_unused := f_exp_ipa_rx(0, tr_RSL_IPA_PDCH_ACT(chan_nr));
5911 if (istemplatekind(nack, "omit")) {
5912 /* respond with a related acknowledgement */
5913 f_ipa_tx(0, ts_RSL_IPA_PDCH_ACT_ACK(chan_nr, ts_RSL_IE_FrameNumber(2342)));
5914 } else {
5915 f_ipa_tx(0, ts_RSL_IPA_PDCH_ACT_NACK(chan_nr, valueof(nack)));
5916 }
5917}
5918
5919private function f_dyn_ipa_pdch_deact(integer bts_nr, integer trx_nr, integer ts_nr,
5920 template (omit) RSL_Cause nack := omit)
5921runs on test_CT {
5922 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(ts_nr));
5923 var RSL_Message rsl_unused;
5924 /* ask BSC via VTY to activate a given IPA style chan as PDCH */
5925 f_vty_ts_action("pdch deactivate", bts_nr, trx_nr, ts_nr);
5926 /* expect the BSC to issue the related RSL command */
5927 rsl_unused := f_exp_ipa_rx(0, tr_RSL_IPA_PDCH_DEACT(chan_nr));
5928 if (istemplatekind(nack, "omit")) {
5929 /* respond with a related acknowledgement */
5930 f_ipa_tx(0, ts_RSL_IPA_PDCH_DEACT_ACK(chan_nr));
5931 } else {
5932 f_ipa_tx(0, ts_RSL_IPA_PDCH_DEACT_NACK(chan_nr, valueof(nack)));
5933 }
5934}
5935
5936private function f_ts_dyn_mode_get(integer bts_nr, integer trx_nr, integer ts_nr)
5937runs on test_CT return charstring {
5938 var charstring cmd, resp;
5939 cmd := "show timeslot "&int2str(bts_nr)&" "&int2str(trx_nr)&" "&int2str(ts_nr);
Stefan Sperlingcff13562018-11-13 15:24:06 +01005940 return f_vty_transceive_match_regexp_retry(BSCVTY, cmd, "*\((*)\)*", 0, 4, 1.0);
Harald Welte94e0c342018-04-07 11:33:23 +02005941}
5942
5943private function f_ts_dyn_mode_assert(integer bts_nr, integer trx_nr, integer ts_nr,
5944 template charstring exp)
5945runs on test_CT {
5946 var charstring mode := f_ts_dyn_mode_get(bts_nr, trx_nr, ts_nr);
5947 if (not match(mode, exp)) {
5948 setverdict(fail, "Unexpected TS Mode: ", mode);
Daniel Willmannafce8662018-07-06 23:11:32 +02005949 mtc.stop;
Harald Welte94e0c342018-04-07 11:33:23 +02005950 }
5951}
5952
5953private function f_ts_set_chcomb(integer bts_nr, integer trx_nr, integer ts_nr, charstring chcomb)
5954runs on test_CT {
5955 f_vty_enter_cfg_ts(BSCVTY, bts_nr, trx_nr, ts_nr);
5956 f_vty_transceive(BSCVTY, "phys_chan_config " & chcomb);
5957 f_vty_transceive(BSCVTY, "end");
5958}
5959
5960private const charstring TCHF_MODE := "TCH/F mode";
5961private const charstring TCHH_MODE := "TCH/H mode";
5962private const charstring PDCH_MODE := "PDCH mode";
5963private const charstring NONE_MODE := "NONE mode";
5964
5965/* Test IPA PDCH activation / deactivation triggered by VTY */
5966testcase TC_dyn_pdch_ipa_act_deact() runs on test_CT {
5967 var RSL_Message rsl_unused;
5968
5969 /* change Timeslot 6 before f_init() starts RSL */
5970 f_init_vty();
5971 f_ts_set_chcomb(0, 0, 6, "TCH/F_PDCH");
5972 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
5973
5974 f_init(1, false);
5975 f_sleep(1.0);
5976
5977 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(6));
5978
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02005979 log("TCH/F_PDCH pchan starts out in TCH/F mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02005980 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
5981 /* The BSC will activate the dynamic PDCH by default, so confirm that */
5982 rsl_unused := f_exp_ipa_rx(0, tr_RSL_IPA_PDCH_ACT(chan_nr));
5983 f_ipa_tx(0, ts_RSL_IPA_PDCH_ACT_ACK(chan_nr, ts_RSL_IE_FrameNumber(2342)));
5984 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02005985 log("TCH/F_PDCH pchan, PDCH ACT was ACKed, so now in PDCH mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02005986 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, PDCH_MODE);
5987
5988 /* De-activate it via VTY */
5989 f_dyn_ipa_pdch_deact(0, 0, chan_nr.tn);
5990 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02005991 log("TCH/F_PDCH pchan, PDCH DEACT via VTY, so now back in TCH/F mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02005992 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
5993
5994 /* re-activate it via VTY */
5995 f_dyn_ipa_pdch_act(0, 0, chan_nr.tn);
5996 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02005997 log("TCH/F_PDCH pchan, PDCH ACT via VTY, so now in PDCH mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02005998 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, PDCH_MODE);
5999
6000 /* and finally de-activate it again */
6001 f_dyn_ipa_pdch_deact(0, 0, chan_nr.tn);
6002 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02006003 log("TCH/F_PDCH pchan, PDCH DEACT via VTY, so now back in TCH/F mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02006004 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
6005
Neels Hofmeyr887e8f12018-06-27 01:01:55 +02006006 /* clean up config */
6007 f_ts_set_chcomb(0, 0, 6, "PDCH");
6008
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006009 f_shutdown_helper();
Harald Welte94e0c342018-04-07 11:33:23 +02006010}
6011
6012/* Test IPA PDCH activation NACK */
6013testcase TC_dyn_pdch_ipa_act_nack() runs on test_CT {
6014 var RSL_Message rsl_unused;
6015
6016 /* change Timeslot 6 before f_init() starts RSL */
6017 f_init_vty();
6018 f_ts_set_chcomb(0, 0, 6, "TCH/F_PDCH");
6019 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
6020
6021 f_init(1, false);
6022 f_sleep(1.0);
6023
6024 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(6));
6025
6026 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
6027 /* The BSC will activate the dynamic PDCH by default, so confirm that */
6028 rsl_unused := f_exp_ipa_rx(0, tr_RSL_IPA_PDCH_ACT(chan_nr));
6029 f_ipa_tx(0, ts_RSL_IPA_PDCH_ACT_ACK(chan_nr, ts_RSL_IE_FrameNumber(2342)));
6030 f_sleep(1.0);
6031 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, PDCH_MODE);
6032
6033 /* De-activate it via VTY */
6034 f_dyn_ipa_pdch_deact(0, 0, chan_nr.tn);
6035 f_sleep(1.0);
6036 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
6037
6038 /* re-activate it via VTY, but fail that; check BSC still assumes TCH/F mode */
6039 f_dyn_ipa_pdch_act(0, 0, chan_nr.tn, RSL_ERR_EQUIPMENT_FAIL);
6040 f_sleep(1.0);
6041 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
6042
Neels Hofmeyr887e8f12018-06-27 01:01:55 +02006043 /* clean up config */
6044 f_ts_set_chcomb(0, 0, 6, "PDCH");
6045
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006046 f_shutdown_helper();
Harald Welte94e0c342018-04-07 11:33:23 +02006047}
6048
6049
6050/***********************************************************************
6051 * Osmocom style dynamic PDCH
6052 ***********************************************************************/
6053
6054private function f_dyn_osmo_pdch_act(integer bts_nr, integer trx_nr, integer ts_nr,
6055 template (omit) RSL_Cause nack := omit)
6056runs on test_CT {
6057 var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(ts_nr));
6058 var RSL_Message rsl_unused;
6059 /* ask BSC via VTY to activate a given IPA style chan as PDCH */
6060 /* FIXME: no VTY command to activate Osmocom PDCH !! */
6061 /* expect the BSC to issue the related RSL command */
6062 rsl_unused := f_exp_ipa_rx(0, tr_RSL_CHAN_ACT(chan_nr, ?));
6063 if (istemplatekind(nack, "omit")) {
6064 /* respond with a related acknowledgement */
6065 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, 2342));
6066 } else {
6067 f_ipa_tx(0, ts_RSL_CHAN_ACT_NACK(chan_nr, valueof(nack)));
6068 }
6069}
6070
6071private function f_dyn_osmo_pdch_deact(integer bts_nr, integer trx_nr, integer ts_nr,
6072 template (omit) RSL_Cause nack := omit)
6073runs on test_CT {
6074 var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(ts_nr));
6075 var RSL_Message rsl_unused;
6076 /* ask BSC via VTY to activate a given IPA style chan as PDCH */
6077 /* FIXME: no VTY command to activate Osmocom PDCH !! */
6078 /* expect the BSC to issue the related RSL command */
6079 rsl_unused := f_exp_ipa_rx(0, tr_RSL_RF_CHAN_REL(chan_nr));
6080 if (istemplatekind(nack, "omit")) {
6081 /* respond with a related acknowledgement */
6082 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(chan_nr));
6083 } else {
6084 //f_ipa_tx(0, ts_RSL_RF_CHAN_REL_NACK(chan_nr, valueof(nack)));
6085 }
6086}
6087
6088/* Test Osmocom dyn PDCH activation / deactivation triggered by VTY */
6089testcase TC_dyn_pdch_osmo_act_deact() runs on test_CT {
6090 var RSL_Message rsl_unused;
6091
6092 /* change Timeslot 6 before f_init() starts RSL */
6093 f_init_vty();
6094 f_ts_set_chcomb(0, 0, 6, "TCH/F_TCH/H_PDCH");
6095 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
6096
6097 f_init(1, false);
6098 f_sleep(1.0);
6099
6100 var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(6));
6101
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02006102 log("TCH/F_TCH/H_PDCH pchan starts out in disabled mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02006103 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, NONE_MODE);
6104 /* The BSC will activate the dynamic PDCH by default, so confirm that */
6105 rsl_unused := f_exp_ipa_rx(0, tr_RSL_CHAN_ACT_PDCH(chan_nr, ?));
6106
6107 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, 2342));
6108 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02006109 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 +02006110 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, PDCH_MODE);
6111
Neels Hofmeyr887e8f12018-06-27 01:01:55 +02006112 /* clean up config */
6113 f_ts_set_chcomb(0, 0, 6, "PDCH");
6114
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006115 f_shutdown_helper();
Harald Welte94e0c342018-04-07 11:33:23 +02006116}
6117
6118/* Test Osmocom dyn PDCH activation NACK behavior */
6119testcase TC_dyn_pdch_osmo_act_nack() runs on test_CT {
6120 var RSL_Message rsl_unused;
6121
6122 /* change Timeslot 6 before f_init() starts RSL */
6123 f_init_vty();
6124 f_ts_set_chcomb(0, 0, 6, "TCH/F_TCH/H_PDCH");
6125 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
6126
6127 f_init(1, false);
6128 f_sleep(1.0);
6129
6130 var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(6));
6131
6132 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, NONE_MODE);
6133 /* The BSC will activate the dynamic PDCH by default, so confirm that */
6134 rsl_unused := f_exp_ipa_rx(0, tr_RSL_CHAN_ACT_PDCH(chan_nr, ?));
6135
6136 /* NACK this activation and expect the "show timeslot" mode still to be NONE */
6137 f_ipa_tx(0, ts_RSL_CHAN_ACT_NACK(chan_nr, RSL_ERR_EQUIPMENT_FAIL));
6138 f_sleep(1.0);
6139 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, NONE_MODE);
6140
Neels Hofmeyr887e8f12018-06-27 01:01:55 +02006141 /* clean up config */
6142 f_ts_set_chcomb(0, 0, 6, "PDCH");
6143
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006144 f_shutdown_helper();
Harald Welte94e0c342018-04-07 11:33:23 +02006145}
6146
Stefan Sperling0796a822018-10-05 13:01:39 +02006147testcase TC_chopped_ipa_ping() runs on test_CT {
Stefan Sperling554123f2018-10-09 14:12:30 +02006148 const Integers bsc_ipa_ports := {mp_bsc_rsl_port, mp_bsc_oml_port, mp_bsc_ctrl_port};
Stefan Sperling0796a822018-10-05 13:01:39 +02006149 for (var integer i := 0; i < lengthof(bsc_ipa_ports); i := i + 1) {
6150 IPA_Testing.f_run_TC_chopped_ipa_ping(mp_bsc_ip, bsc_ipa_ports[i], CONNECT_TO_SERVER);
6151 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006152 f_shutdown_helper();
Stefan Sperling0796a822018-10-05 13:01:39 +02006153}
6154
Stefan Sperlingaa1e60f2018-10-15 16:34:07 +02006155testcase TC_chopped_ipa_payload() runs on test_CT {
6156 const Integers bsc_ipa_ports := {mp_bsc_rsl_port, mp_bsc_oml_port
6157 /* TODO: mp_bsc_ctrl_port does not work yet */};
6158 for (var integer i := 0; i < lengthof(bsc_ipa_ports); i := i + 1) {
6159 IPA_Testing.f_run_TC_chopped_ipa_payload(mp_bsc_ip, bsc_ipa_ports[i], CONNECT_TO_SERVER);
6160 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006161 f_shutdown_helper();
Stefan Sperlingaa1e60f2018-10-15 16:34:07 +02006162}
6163
Pau Espin Pedrol8f773632019-11-05 11:46:53 +01006164/* Verify the BSC sends the MS Power Parameters IE during CHAN ACT to make sure
6165 the BTS does autonomous MS power control loop */
6166testcase TC_assignment_verify_ms_power_params_ie() runs on test_CT {
6167 var MSC_ConnHdlr vc_conn;
6168 var TestHdlrParams pars := f_gen_test_hdlr_pars();
6169 //pars.encr := valueof(t_EncrParams('01'O, f_rnd_octstring(8)));
6170 pars.exp_ms_power_params := true;
6171
6172 f_init(1, true);
6173 f_sleep(1.0);
6174 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5), pars);
6175 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006176 f_shutdown_helper();
Pau Espin Pedrol8f773632019-11-05 11:46:53 +01006177}
Stefan Sperlingaa1e60f2018-10-15 16:34:07 +02006178
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006179/***********************************************************************
6180 * MSC Pooling
6181 ***********************************************************************/
6182
6183function f_tmsi_nri(integer nri_v, octetstring base_tmsi := '42000023'O, integer nri_bitlen := 10) return octetstring
6184{
6185 return int2oct( oct2int(base_tmsi) + bit2int( (int2bit(nri_v, 32) << ( 24 - nri_bitlen)) ),
6186 4);
6187}
6188
6189template MobileIdentityLV ts_MI_TMSI_NRI_LV(integer nri_v, integer nri_bitlen := 10) :=
6190 ts_MI_TMSI_LV(tmsi := f_tmsi_nri(nri_v, nri_bitlen := nri_bitlen));
6191
6192private function f_perform_clear(RSL_DCHAN_PT rsl) runs on MSC_ConnHdlr {
Neels Hofmeyr767548a2020-08-09 20:26:07 +00006193 f_logp(BSCVTY, "MSC instructs BSC to clear channel");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006194 BSSAP.send(ts_BSSMAP_ClearCommand(0));
6195 interleave {
6196 [] rsl.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_RELEASE)) {
Neels Hofmeyr767548a2020-08-09 20:26:07 +00006197 f_logp(BSCVTY, "Got RSL RR Release");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006198 }
6199 [] rsl.receive(tr_RSL_DEACT_SACCH(g_chan_nr)) {
Neels Hofmeyr767548a2020-08-09 20:26:07 +00006200 f_logp(BSCVTY, "Got RSL Deact SACCH");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006201 }
6202 [] BSSAP.receive(tr_BSSMAP_ClearComplete) {
Neels Hofmeyr767548a2020-08-09 20:26:07 +00006203 f_logp(BSCVTY, "Got BSSMAP Clear Complete");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006204 /* Also drop the SCCP connection */
6205 BSSAP.send(RAN_Conn_Prim:MSC_CONN_PRIM_DISC_REQ);
6206 }
6207 [] rsl.receive(tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL)) {
Neels Hofmeyr767548a2020-08-09 20:26:07 +00006208 f_logp(BSCVTY, "Got RSL RF Chan Rel, sending Rel Ack");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006209 rsl.send(ts_RSL_RF_CHAN_REL_ACK(g_chan_nr));
6210 }
6211 }
6212}
6213
Neels Hofmeyr66e15092020-10-12 18:44:41 +00006214private function f_perform_compl_l3(RSL_DCHAN_PT rsl, template PDU_ML3_MS_NW l3_info, boolean do_clear := true, boolean expect_bssmap_l3 := true)
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006215runs on MSC_ConnHdlr {
6216 timer T := 10.0;
6217 var octetstring l3_enc := enc_PDU_ML3_MS_NW(valueof(l3_info));
6218
Neels Hofmeyr767548a2020-08-09 20:26:07 +00006219 f_logp(BSCVTY, "establish channel, send Complete Layer 3 Info");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006220 f_create_bssmap_exp(l3_enc);
6221
6222 /* RSL_Emulation.f_chan_est() on rsl:
6223 * This is basically code dup with s/RSL/rsl from:
6224 * RSL_Emulation.f_chan_est(g_pars.ra, l3_enc, g_pars.link_id, g_pars.fn);
6225 */
6226 var RSL_Message rx_rsl;
6227 var GsmRrMessage rr;
6228
6229 /* request a channel to be established */
6230 rsl.send(ts_RSLDC_ChanRqd(g_pars.ra, g_pars.fn));
6231 /* expect immediate assignment.
6232 * Code dup with s/RSL/rsl from:
6233 * rx_rsl := f_rx_or_fail(tr_RSL_IMM_ASSIGN);
6234 */
6235 timer Tt := 10.0;
6236
6237 /* request a channel to be established */
6238 Tt.start;
6239 alt {
6240 [] rsl.receive(tr_RSL_IMM_ASSIGN) -> value rx_rsl {
6241 Tt.stop;
6242 }
6243 [] rsl.receive {
6244 setverdict(fail, "Unexpected RSL message on DCHAN");
6245 mtc.stop;
6246 }
6247 [] Tt.timeout {
6248 setverdict(fail, "Timeout waiting for RSL on DCHAN");
6249 mtc.stop;
6250 }
6251 }
6252 rr := dec_GsmRrMessage(rx_rsl.ies[1].body.full_imm_ass_info.payload);
6253 g_chan_nr := rr.payload.imm_ass.chan_desc.chan_nr;
6254 rsl.send(ts_RSL_EST_IND(g_chan_nr, valueof(g_pars.link_id), l3_enc));
6255
6256
Neels Hofmeyr66e15092020-10-12 18:44:41 +00006257 if (expect_bssmap_l3) {
6258 f_logp(BSCVTY, "expect BSSAP Complete Layer 3 Info at MSC");
6259 var template PDU_BSSAP exp_l3_compl;
6260 exp_l3_compl := tr_BSSMAP_ComplL3()
6261 if (g_pars.aoip == false) {
6262 exp_l3_compl.pdu.bssmap.completeLayer3Information.codecList := omit;
6263 } else {
6264 exp_l3_compl.pdu.bssmap.completeLayer3Information.codecList := ?;
6265 }
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006266
Neels Hofmeyr66e15092020-10-12 18:44:41 +00006267 var PDU_BSSAP bssap;
6268 T.start;
6269 alt {
6270 [] BSSAP.receive(exp_l3_compl) -> value bssap {
6271 f_logp(BSCVTY, "received expected Complete Layer 3 Info at MSC");
6272 log("rx exp_l3_compl = ", bssap);
6273 }
6274 [] BSSAP.receive(tr_BSSMAP_ComplL3) {
6275 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Received non-matching COMPLETE LAYER 3 INFORMATION");
6276 }
6277 [] T.timeout {
6278 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for COMPLETE LAYER 3 INFORMATION");
6279 }
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006280 }
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006281
Neels Hofmeyr66e15092020-10-12 18:44:41 +00006282 /* start ciphering, if requested */
6283 if (ispresent(g_pars.encr)) {
6284 f_logp(BSCVTY, "start ciphering");
6285 f_cipher_mode(g_pars.encr.enc_alg, g_pars.encr.enc_key);
6286 }
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006287 }
6288
6289 if (do_clear) {
6290 f_perform_clear(rsl);
6291 }
6292 setverdict(pass);
6293 f_sleep(1.0);
6294}
6295
6296private function f_tc_mscpool_compl_l3(charstring id) runs on MSC_ConnHdlr {
6297 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
6298 if (g_pars.mscpool.rsl_idx == 0) {
6299 f_perform_compl_l3(RSL, g_pars.mscpool.l3_info);
6300 } else if (g_pars.mscpool.rsl_idx == 1) {
6301 f_perform_compl_l3(RSL1, g_pars.mscpool.l3_info);
6302 } else if (g_pars.mscpool.rsl_idx == 2) {
6303 f_perform_compl_l3(RSL2, g_pars.mscpool.l3_info);
6304 }
6305}
6306
6307/* Various Complete Layer 3 by IMSI all end up with the first MSC, because the other MSCs are not connected. */
6308private function f_tc_mscpool_L3Compl_on_1_msc(charstring id) runs on MSC_ConnHdlr {
6309 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
6310 f_perform_compl_l3(RSL, ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_IMSI_LV('001010000000001'H)), '00F110'O) );
6311 f_perform_compl_l3(RSL, ts_CM_SERV_REQ(CM_TYPE_MO_SMS, valueof(ts_MI_IMSI_LV('001010000000002'H))) );
6312 f_perform_compl_l3(RSL, ts_PAG_RESP(valueof(ts_MI_IMSI_LV('001010000000003'H))) );
6313 f_perform_compl_l3(RSL, ts_ML3_MO_MM_IMSI_DET_Ind(valueof(ts_MI_IMSI_LV('001010000000004'H))) );
6314}
6315testcase TC_mscpool_L3Compl_on_1_msc() runs on test_CT {
6316
6317 f_init(1, true);
6318 f_sleep(1.0);
6319 var MSC_ConnHdlr vc_conn;
6320 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006321
6322 f_ctrs_msc_init();
6323
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006324 vc_conn := f_start_handler(refers(f_tc_mscpool_L3Compl_on_1_msc), pars);
6325 vc_conn.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006326
6327 f_ctrs_msc_expect(0, "mscpool:subscr:new", 4);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006328 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006329}
6330
6331/* Three Layer 3 Complete by IMSI are round-robin'ed across two connected MSCs */
6332/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
6333 * just as well using only RSL. */
6334testcase TC_mscpool_L3Complete_by_imsi_round_robin() runs on test_CT {
6335
6336 f_init(nr_bts := 3, handler_mode := true, nr_msc := 2);
6337 f_sleep(1.0);
6338
6339 /* Control which MSC gets chosen next by the round-robin, otherwise
6340 * would be randomly affected by which other tests ran before this. */
6341 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
6342
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006343 f_ctrs_msc_init();
6344
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006345 var MSC_ConnHdlr vc_conn1;
6346 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
6347 pars1.mscpool.rsl_idx := 0;
6348 pars1.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_IMSI_LV('001010000000001'H)), '00F110'O));
6349 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6350 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006351 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006352
6353 var MSC_ConnHdlr vc_conn2;
6354 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 1);
6355 pars2.mscpool.rsl_idx := 1;
6356 pars2.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, valueof(ts_MI_IMSI_LV('001010000000002'H))));
6357 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6358 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006359 f_ctrs_msc_expect(1, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006360
6361 /* Test round-robin wrap to the first MSC */
6362 var MSC_ConnHdlr vc_conn3;
6363 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 0);
6364 pars3.mscpool.rsl_idx := 2;
6365 pars3.mscpool.l3_info := valueof(ts_PAG_RESP(valueof(ts_MI_IMSI_LV('001010000000003'H))));
6366 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
6367 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006368 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006369 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006370}
6371
6372/* Three LU by TMSI are round-robin'ed across two connected MSCs, because they contain the NULL-NRI 0
6373 * (configured in osmo-bsc.cfg). */
6374/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
6375 * just as well using only RSL. */
6376testcase TC_mscpool_LU_by_tmsi_null_nri_0_round_robin() runs on test_CT {
6377
6378 f_init(nr_bts := 3, handler_mode := true, nr_msc := 2);
6379 f_sleep(1.0);
6380
6381 /* Control which MSC gets chosen next by the round-robin, otherwise
6382 * would be randomly affected by which other tests ran before this. */
6383 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
6384
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006385 f_ctrs_msc_init();
6386
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006387 var MSC_ConnHdlr vc_conn1;
6388 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
6389 pars1.mscpool.rsl_idx := 0;
6390 pars1.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(0)), '00F110'O));
6391 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6392 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006393 f_ctrs_msc_expect(0, "mscpool:subscr:reattach");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006394
6395 var MSC_ConnHdlr vc_conn2;
6396 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 1);
6397 pars2.mscpool.rsl_idx := 1;
6398 pars2.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(0)), '00F110'O));
6399 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6400 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006401 f_ctrs_msc_expect(1, "mscpool:subscr:reattach");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006402
6403 /* Test round-robin wrap to the first MSC */
6404 var MSC_ConnHdlr vc_conn3;
6405 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 0);
6406 pars3.mscpool.rsl_idx := 2;
6407 pars3.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(0)), '00F110'O));
6408 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
6409 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006410 f_ctrs_msc_expect(0, "mscpool:subscr:reattach");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006411 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006412}
6413
6414/* Three LU by TMSI are round-robin'ed across two connected MSCs, because they contain the NULL-NRI 1
6415 * (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
6416 * NULL-NRI setting is stronger than that. */
6417/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
6418 * just as well using only RSL. */
6419testcase TC_mscpool_LU_by_tmsi_null_nri_1_round_robin() runs on test_CT {
6420
6421 f_init(nr_bts := 3, handler_mode := true, nr_msc := 2);
6422 f_sleep(1.0);
6423
6424 /* Control which MSC gets chosen next by the round-robin, otherwise
6425 * would be randomly affected by which other tests ran before this. */
6426 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
6427
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006428 f_ctrs_msc_init();
6429
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006430 var MSC_ConnHdlr vc_conn1;
6431 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
6432 pars1.mscpool.rsl_idx := 0;
6433 pars1.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(1)), '00F110'O));
6434 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6435 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006436 f_ctrs_msc_expect(0, "mscpool:subscr:reattach");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006437
6438 var MSC_ConnHdlr vc_conn2;
6439 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 1);
6440 pars2.mscpool.rsl_idx := 1;
6441 pars2.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(1)), '00F110'O));
6442 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6443 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006444 f_ctrs_msc_expect(1, "mscpool:subscr:reattach");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006445
6446 /* Test round-robin wrap to the first MSC */
6447 var MSC_ConnHdlr vc_conn3;
6448 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 0);
6449 pars3.mscpool.rsl_idx := 2;
6450 pars3.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(1)), '00F110'O));
6451 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
6452 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006453 f_ctrs_msc_expect(0, "mscpool:subscr:reattach");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006454 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006455}
6456
6457/* Three Layer 3 Complete by TMSI are round-robin'ed across two connected MSCs, because they contain an NRI not
6458 * assigned to any MSC (configured in osmo-bsc.cfg). */
6459/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
6460 * just as well using only RSL. */
6461testcase TC_mscpool_L3Complete_by_tmsi_unassigned_nri_round_robin() runs on test_CT {
6462
6463 f_init(nr_bts := 3, handler_mode := true, nr_msc := 2);
6464 f_sleep(1.0);
6465
6466 /* Control which MSC gets chosen next by the round-robin, otherwise
6467 * would be randomly affected by which other tests ran before this. */
6468 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
6469
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006470 f_ctrs_msc_init();
6471
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006472 var MSC_ConnHdlr vc_conn1;
6473 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
6474 pars1.mscpool.rsl_idx := 0;
6475 /* An NRI that is not assigned to any MSC */
6476 pars1.mscpool.l3_info := valueof(ts_ML3_MO_MM_IMSI_DET_Ind(valueof(ts_MI_TMSI_NRI_LV(1023))));
6477 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6478 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006479 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006480
6481 var MSC_ConnHdlr vc_conn2;
6482 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 1);
6483 pars2.mscpool.rsl_idx := 1;
6484 /* An NRI that is not assigned to any MSC */
6485 pars2.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(768)), '00F110'O));
6486 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6487 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006488 f_ctrs_msc_expect(1, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006489
6490 /* Test round-robin wrap to the first MSC */
6491 var MSC_ConnHdlr vc_conn3;
6492 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 0);
6493 pars3.mscpool.rsl_idx := 2;
6494 /* An NRI that is not assigned to any MSC */
6495 pars3.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_SS_ACT, valueof(ts_MI_TMSI_NRI_LV(819))));
6496 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
6497 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006498 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006499 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006500}
6501
6502/* Three Layer 3 Complete by TMSI are round-robin'ed across two connected MSCs, because they contain an NRI
6503 * assigned to an MSC that is currently not connected (configured in osmo-bsc.cfg). */
6504/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
6505 * just as well using only RSL. */
6506testcase TC_mscpool_L3Complete_by_tmsi_valid_nri_msc_not_connected_round_robin() runs on test_CT {
6507
6508 f_init(nr_bts := 3, handler_mode := true, nr_msc := 2);
6509 f_sleep(1.0);
6510
6511 /* Control which MSC gets chosen next by the round-robin, otherwise
6512 * would be randomly affected by which other tests ran before this. */
6513 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
6514
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006515 f_ctrs_msc_init();
6516
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006517 var MSC_ConnHdlr vc_conn1;
6518 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
6519 pars1.mscpool.rsl_idx := 0;
6520 /* An NRI that is assigned to an unconnected MSC */
6521 pars1.mscpool.l3_info := valueof(ts_PAG_RESP(valueof(ts_MI_TMSI_NRI_LV(512))));
6522 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6523 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006524 f_ctrs_msc_add(2, "mscpool:subscr:attach_lost");
6525 f_ctrs_msc_add(0, "mscpool:subscr:new");
6526 f_ctrs_msc_verify();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006527
6528 var MSC_ConnHdlr vc_conn2;
6529 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 1);
6530 pars2.mscpool.rsl_idx := 1;
6531 /* An NRI that is assigned to an unconnected MSC */
6532 pars2.mscpool.l3_info := valueof(ts_ML3_MO_MM_IMSI_DET_Ind(valueof(ts_MI_TMSI_NRI_LV(767))));
6533 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6534 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006535 f_ctrs_msc_add(2, "mscpool:subscr:attach_lost");
6536 f_ctrs_msc_add(1, "mscpool:subscr:new");
6537 f_ctrs_msc_verify();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006538
6539 /* Test round-robin wrap to the first MSC */
6540 var MSC_ConnHdlr vc_conn3;
6541 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 0);
6542 pars3.mscpool.rsl_idx := 2;
6543 /* An NRI that is assigned to an unconnected MSC */
6544 pars3.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(750)), '00F110'O));
6545 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
6546 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006547 f_ctrs_msc_add(2, "mscpool:subscr:attach_lost");
6548 f_ctrs_msc_add(0, "mscpool:subscr:new");
6549 f_ctrs_msc_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006550 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006551}
6552
6553/* Three Layer 3 Complete by TMSI with valid NRI for the second MSC are all directed to the second MSC (configured in
6554 * osmo-bsc.cfg). */
6555/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
6556 * just as well using only RSL. */
6557testcase TC_mscpool_L3Complete_by_tmsi_valid_nri_1() runs on test_CT {
6558
6559 f_init(nr_bts := 3, handler_mode := true, nr_msc := 2);
6560 f_sleep(1.0);
6561
6562 /* All TMSIs in this test point at the second MSC, set the round robin to point at the first MSC to make sure
6563 * this is not using round-robin. */
6564 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
6565
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006566 f_ctrs_msc_init();
6567
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006568 var MSC_ConnHdlr vc_conn1;
6569 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 1);
6570 pars1.mscpool.rsl_idx := 0;
6571 /* An NRI of the second MSC's range (256-511) */
6572 pars1.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_SMS, valueof(ts_MI_TMSI_NRI_LV(256))));
6573 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6574 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006575 f_ctrs_msc_expect(1, "mscpool:subscr:known");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006576
6577 var MSC_ConnHdlr vc_conn2;
6578 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 1);
6579 pars2.mscpool.rsl_idx := 1;
6580 /* An NRI of the second MSC's range (256-511) */
6581 pars2.mscpool.l3_info := valueof(ts_PAG_RESP(valueof(ts_MI_TMSI_NRI_LV(260))));
6582 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6583 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006584 f_ctrs_msc_expect(1, "mscpool:subscr:known");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006585
6586 var MSC_ConnHdlr vc_conn3;
6587 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 1);
6588 pars3.mscpool.rsl_idx := 2;
6589 /* An NRI of the second MSC's range (256-511) */
6590 pars3.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(511)), '00F110'O));
6591 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
6592 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006593 f_ctrs_msc_expect(1, "mscpool:subscr:known");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006594 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006595}
6596
6597/* Layer 3 Complete by TMSI with valid NRI for the third MSC are directed to the third MSC (configured in osmo-bsc.cfg),
6598 * while a round-robin remains unaffected by that. */
6599/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
6600 * just as well using only RSL. */
6601testcase TC_mscpool_L3Complete_by_tmsi_valid_nri_2() runs on test_CT {
6602
6603 f_init(nr_bts := 3, handler_mode := true, nr_msc := 3);
6604 f_sleep(1.0);
6605
6606 /* All TMSIs in this test point at the third MSC, set the round robin to point at the second MSC to make sure
6607 * this is not using round-robin. */
6608 f_vty_transceive(BSCVTY, "mscpool roundrobin next 1");
6609
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006610 f_ctrs_msc_init();
6611
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006612 var MSC_ConnHdlr vc_conn1;
6613 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 2);
6614 pars1.mscpool.rsl_idx := 0;
6615 /* An NRI of the third MSC's range (512-767) */
6616 pars1.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_SMS, valueof(ts_MI_TMSI_NRI_LV(512))));
6617 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6618 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006619 f_ctrs_msc_expect(2, "mscpool:subscr:known");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006620
6621 var MSC_ConnHdlr vc_conn2;
6622 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 2);
6623 pars2.mscpool.rsl_idx := 1;
6624 /* An NRI of the third MSC's range (512-767) */
6625 pars2.mscpool.l3_info := valueof(ts_PAG_RESP(valueof(ts_MI_TMSI_NRI_LV(678))));
6626 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6627 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006628 f_ctrs_msc_expect(2, "mscpool:subscr:known");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006629
6630 /* The above forwardings to third MSC have not affected the round robin, which still points at the second MSC */
6631 var MSC_ConnHdlr vc_conn3;
6632 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 1);
6633 pars3.mscpool.rsl_idx := 2;
6634 pars3.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_IMSI_LV('001010000000013'H)), '00F110'O));
6635 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
6636 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006637 f_ctrs_msc_expect(1, "mscpool:subscr:new");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006638 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006639}
6640
6641/* LU with a TMSI but indicating a different PLMN in its previous LAI: ignore the NRI. */
6642/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
6643 * just as well using only RSL. */
6644testcase TC_mscpool_LU_by_tmsi_from_other_PLMN() runs on test_CT {
6645
6646 f_init(nr_bts := 3, handler_mode := true, nr_msc := 3);
6647 f_sleep(1.0);
6648
6649 /* The TMSIs in this test points at the second MSC, but since it is from a different PLMN, round-robin is used
6650 * instead, and hits msc 0. */
6651 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
6652
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006653 f_ctrs_msc_init();
6654
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006655 /* An NRI of the second MSC's range (256-511), but a PLMN that doesn't match with osmo-bsc.cfg */
6656 var MSC_ConnHdlr vc_conn1;
6657 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
6658 pars1.mscpool.rsl_idx := 0;
6659 pars1.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(260)), '99F999'O));
6660 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6661 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006662 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006663
6664 /* An NRI of the third MSC's range (512-767) and a matching PLMN gets directed by NRI. */
6665 var MSC_ConnHdlr vc_conn2;
6666 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 2);
6667 pars2.mscpool.rsl_idx := 1;
6668 pars2.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(555)), '00F110'O));
6669 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6670 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006671 f_ctrs_msc_expect(2, "mscpool:subscr:known");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006672 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006673}
6674
6675/* Make sure that whichever MSC paged a subscriber will also get the Paging Response. Page by IMSI, which would be
6676 * round-robined to another MSC, to make sure the Paging->Response relation is stronger than the NRI->MSC mapping. */
6677private function f_tc_mscpool_paging_imsi(charstring id) runs on MSC_ConnHdlr {
6678 var template BSSMAP_FIELD_CellIdentificationList cid_list := { cIl_CI := { ts_BSSMAP_CI_CI(0) } };
6679 //cid_list := { cIl_allInBSS := ''O };
6680 var RSL_ChanNeeded rsl_chneed := RSL_CHANNEED_SDCCH;
6681 var template BSSMAP_IE_ChannelNeeded bssmap_chneed := ts_BSSMAP_IE_ChanNeeded(int2bit(enum2int(valueof(rsl_chneed)),2));
6682 var BSSAP_N_UNITDATA_req paging;
6683 var hexstring imsi := '001010000000123'H;
6684
6685 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
6686
Neels Hofmeyr90f80962020-06-12 16:16:55 +02006687 paging := valueof(ts_BSSAP_UNITDATA_req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006688 valueof(ts_BSSMAP_Paging(imsi, cid_list, omit, bssmap_chneed))));
6689 BSSAP.send(paging);
6690
6691 /* Register any RSL conn so that the Paging Command gets received here. With the current RSL_Emulation's main()
6692 * handling of '[bts_role] IPA_PT.receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD()))' it doesn't matter at all which
6693 * channel number is picked here. */
6694 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(0, RSL_CHAN_NR_INVALID));
6695 f_rslem_register(0, new_chan_nr);
6696 RSL.receive(tr_RSL_PAGING_CMD(tr_MI_IMSI(imsi)));
6697 f_rslem_unregister(0, new_chan_nr);
6698
6699 /* Despite the round robin pointing at the second MSC ('roundrobin next 1'), the earlier Paging for the same IMSI
6700 * causes this Paging Response to go to the first MSC (bssap_idx := 0). */
6701 f_perform_compl_l3(RSL, ts_PAG_RESP(valueof(ts_MI_IMSI_LV(imsi))) );
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006702 f_sleep(1.0);
6703}
6704testcase TC_mscpool_paging_and_response_imsi() runs on test_CT {
6705 f_init(nr_bts := 1, handler_mode := true, nr_msc := 3);
6706 f_sleep(1.0);
6707
6708 /* Testing a Paging on the first MSC to get a Paging Response back to the first MSC. Set round robin to the
6709 * second MSC to make sure we're getting the Paging logic, not a coincidental round robin match. */
6710 f_vty_transceive(BSCVTY, "mscpool roundrobin next 1");
6711
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006712 f_ctrs_msc_init();
6713
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006714 var MSC_ConnHdlr vc_conn1;
6715 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
6716 pars1.mscpool.rsl_idx := 0;
Neels Hofmeyr90f80962020-06-12 16:16:55 +02006717 pars1.sccp_addr_bsc := g_bssap[pars1.mscpool.bssap_idx].sccp_addr_peer;
6718 pars1.sccp_addr_msc := g_bssap[pars1.mscpool.bssap_idx].sccp_addr_own;
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006719 vc_conn1 := f_start_handler(refers(f_tc_mscpool_paging_imsi), pars1);
6720 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006721 f_ctrs_msc_expect(0, "mscpool:subscr:paged");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006722 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006723}
6724
6725/* Make sure that whichever MSC paged a subscriber will also get the Paging Response. Page by TMSI with an NRI value
6726 * that matches a different MSC, to make sure the Paging->Response relation is stronger than the NRI->MSC mapping. */
6727private function f_tc_mscpool_paging_tmsi(charstring id) runs on MSC_ConnHdlr {
6728 var template BSSMAP_FIELD_CellIdentificationList cid_list := { cIl_CI := { ts_BSSMAP_CI_CI(0) } };
6729 //cid_list := { cIl_allInBSS := ''O };
6730 var RSL_ChanNeeded rsl_chneed := RSL_CHANNEED_SDCCH;
6731 var template BSSMAP_IE_ChannelNeeded bssmap_chneed := ts_BSSMAP_IE_ChanNeeded(int2bit(enum2int(valueof(rsl_chneed)),2));
6732 var integer nri_v := 300; /* <-- second MSC's NRI */
6733 var octetstring tmsi := f_tmsi_nri(nri_v);
6734 var BSSAP_N_UNITDATA_req paging;
6735
6736 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
6737
Neels Hofmeyr90f80962020-06-12 16:16:55 +02006738 paging := valueof(ts_BSSAP_UNITDATA_req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006739 valueof(ts_BSSMAP_Paging('001010000000011'H, cid_list, tmsi, bssmap_chneed))));
6740 BSSAP.send(paging);
6741
6742 /* Register any RSL conn so that the Paging Command gets received here. With the current RSL_Emulation's main()
6743 * handling of '[bts_role] IPA_PT.receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD()))' it doesn't matter at all which
6744 * channel number is picked here. */
6745 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(0, RSL_CHAN_NR_INVALID));
6746 f_rslem_register(0, new_chan_nr);
6747 RSL.receive(tr_RSL_PAGING_CMD(t_MI_TMSI(tmsi)));
6748 f_rslem_unregister(0, new_chan_nr);
6749
6750 /* Despite the NRI matching the second MSC (NRI from 'msc 1' in osmo-bsc.cfg) and round robin pointing at the
6751 * third MSC ('roundrobin next 2'), the earlier Paging for the same TMSI causes this Paging Response to go to
6752 * the first MSC (bssap_idx := 0). */
6753 f_perform_compl_l3(RSL, ts_PAG_RESP(valueof(ts_MI_TMSI_NRI_LV(nri_v))) );
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006754 f_sleep(1.0);
6755}
6756testcase TC_mscpool_paging_and_response_tmsi() runs on test_CT {
6757 f_init(nr_bts := 1, handler_mode := true, nr_msc := 3);
6758 f_sleep(1.0);
6759
6760 /* Testing a Paging on the first MSC to get a Paging Response back to the first MSC. Set round robin to the
6761 * third MSC to make sure we're getting the Paging logic, not a coincidental round robin match. */
6762 f_vty_transceive(BSCVTY, "mscpool roundrobin next 2");
6763
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006764 f_ctrs_msc_init();
6765
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006766 var MSC_ConnHdlr vc_conn1;
6767 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
6768 pars1.mscpool.rsl_idx := 0;
Neels Hofmeyr90f80962020-06-12 16:16:55 +02006769 pars1.sccp_addr_bsc := g_bssap[pars1.mscpool.bssap_idx].sccp_addr_peer;
6770 pars1.sccp_addr_msc := g_bssap[pars1.mscpool.bssap_idx].sccp_addr_own;
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006771 vc_conn1 := f_start_handler(refers(f_tc_mscpool_paging_tmsi), pars1);
6772 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006773 f_ctrs_msc_expect(0, "mscpool:subscr:paged");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006774 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006775}
6776
6777/* For round-robin, skip an MSC that has 'no allow-attach' set. */
6778/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
6779 * just as well using only RSL. */
6780testcase TC_mscpool_no_allow_attach_round_robin() runs on test_CT {
6781
6782 f_init(nr_bts := 3, handler_mode := true, nr_msc := 3);
6783 f_sleep(1.0);
Neels Hofmeyra460f1f2020-08-09 20:17:03 +00006784 /* Mark the second MSC as offloading, round-robin should skip this MSC now. */
6785 f_vty_msc_allow_attach(BSCVTY, {true, false, true});
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006786
6787 /* Control which MSC gets chosen next by the round-robin, otherwise
6788 * would be randomly affected by which other tests ran before this. */
6789 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
6790
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006791 f_ctrs_msc_init();
6792
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006793 var MSC_ConnHdlr vc_conn1;
6794 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
6795 pars1.mscpool.rsl_idx := 0;
6796 pars1.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_IMSI_LV('001010000000001'H)), '00F110'O));
6797 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6798 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006799 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006800
6801 var MSC_ConnHdlr vc_conn2;
6802 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 2);
6803 pars2.mscpool.rsl_idx := 1;
6804 pars2.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, valueof(ts_MI_IMSI_LV('001010000000002'H))));
6805 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6806 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006807 f_ctrs_msc_expect(2, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006808
6809 var MSC_ConnHdlr vc_conn3;
6810 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 0);
6811 pars3.mscpool.rsl_idx := 2;
6812 pars3.mscpool.l3_info := valueof(ts_PAG_RESP(valueof(ts_MI_IMSI_LV('001010000000003'H))));
6813 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
6814 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006815 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006816 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006817}
6818
6819/* An MSC that has 'no allow-attach' set should still serve subscribers that are already attached according to their
6820 * TMSI NRI. */
6821testcase TC_mscpool_no_allow_attach_valid_nri() runs on test_CT {
6822
6823 f_init(nr_bts := 3, handler_mode := true, nr_msc := 3);
6824 f_sleep(1.0);
6825
Neels Hofmeyra460f1f2020-08-09 20:17:03 +00006826 /* Mark the second MSC as offloading, round-robin should skip this MSC now. */
6827 f_vty_msc_allow_attach(BSCVTY, {true, false, true});
6828
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006829 /* Control which MSC gets chosen next by the round-robin, otherwise
6830 * would be randomly affected by which other tests ran before this. */
6831 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
6832
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006833 f_ctrs_msc_init();
6834
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006835 /* Round robin points at msc 0, but the valid NRI directs to msc 1, even though msc 1 has 'no allow-attach'. */
6836 var MSC_ConnHdlr vc_conn1;
6837 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 1);
6838 pars1.mscpool.rsl_idx := 0;
6839 /* An NRI of the second MSC's range (256-511) */
6840 pars1.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, valueof(ts_MI_TMSI_NRI_LV(260))));
6841 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6842 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006843 f_ctrs_msc_expect(1, "mscpool:subscr:known");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006844
6845 var MSC_ConnHdlr vc_conn2;
6846 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 0);
6847 pars2.mscpool.rsl_idx := 1;
6848 pars2.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, valueof(ts_MI_IMSI_LV('001010000000002'H))));
6849 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6850 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006851 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006852
6853 var MSC_ConnHdlr vc_conn3;
6854 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 2);
6855 pars3.mscpool.rsl_idx := 2;
6856 pars3.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, valueof(ts_MI_IMSI_LV('001010000000003'H))));
6857 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
6858 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006859 f_ctrs_msc_expect(2, "mscpool:subscr:new");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006860 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006861}
6862
Philipp Maier783681c2020-07-16 16:47:06 +02006863/* Allow/Deny emergency calls globally via VTY */
6864private function f_vty_allow_emerg_msc(boolean allow) runs on test_CT {
6865 f_vty_enter_cfg_msc(BSCVTY, 0);
6866 if (allow) {
6867 f_vty_transceive(BSCVTY, "allow-emergency allow");
6868 } else {
6869 f_vty_transceive(BSCVTY, "allow-emergency deny");
6870 }
6871 f_vty_transceive(BSCVTY, "exit");
6872 f_vty_transceive(BSCVTY, "exit");
6873}
6874
6875/* Allow/Deny emergency calls per BTS via VTY */
6876private function f_vty_allow_emerg_bts(boolean allow, integer bts_nr) runs on test_CT {
6877 f_vty_enter_cfg_bts(BSCVTY, bts_nr);
6878 if (allow) {
6879 f_vty_transceive(BSCVTY, "rach emergency call allowed 1");
6880 } else {
6881 f_vty_transceive(BSCVTY, "rach emergency call allowed 0");
6882 }
6883 f_vty_transceive(BSCVTY, "exit");
6884 f_vty_transceive(BSCVTY, "exit");
Neels Hofmeyrb6ed80c2020-10-12 22:52:39 +00006885 f_vty_transceive(BSCVTY, "exit");
Philipp Maier783681c2020-07-16 16:47:06 +02006886}
6887
6888/* Begin assignmet procedure and send an EMERGENCY SETUP (RR) */
6889private function f_assignment_emerg_setup() runs on MSC_ConnHdlr {
6890 var PDU_ML3_MS_NW emerg_setup;
6891 var octetstring emerg_setup_enc;
6892 var RSL_Message emerg_setup_data_ind;
6893
6894 f_establish_fully(omit, omit);
6895
6896 emerg_setup := valueof(ts_ML3_MO_CC_EMERG_SETUP(1, valueof(ts_Bcap_voice)));
6897 emerg_setup_enc := enc_PDU_ML3_MS_NW(emerg_setup);
6898 emerg_setup_data_ind := valueof(ts_RSL_DATA_IND(g_chan_nr, valueof(ts_RslLinkID_DCCH(0)), emerg_setup_enc));
6899
6900 RSL.send(emerg_setup_data_ind);
6901}
6902
6903/* Test if the EMERGENCY SETUP gets passed on to the MSC via A when EMERGENCY
6904 * CALLS are permitted by the BSC config. */
6905private function f_TC_assignment_emerg_setup_allow(charstring id) runs on MSC_ConnHdlr {
6906 var PDU_BSSAP emerg_setup_data_ind_bssap;
6907 var PDU_ML3_MS_NW emerg_setup;
6908 timer T := 3.0;
6909
6910 f_assignment_emerg_setup()
6911
6912 T.start;
6913 alt {
6914 [] BSSAP.receive(tr_BSSAP_DTAP) -> value emerg_setup_data_ind_bssap {
6915 emerg_setup := dec_PDU_ML3_MS_NW(emerg_setup_data_ind_bssap.pdu.dtap);
6916 if (not isbound(emerg_setup.msgs.cc.emergencySetup)) {
6917 setverdict(fail, "no emergency setup");
6918 }
6919 }
6920 [] BSSAP.receive {
6921 setverdict(fail, "unexpected BSSAP message!");
6922 }
6923 [] T.timeout {
6924 setverdict(fail, "timout waiting for EMERGENCY SETUP!");
6925 }
6926 }
6927
6928 setverdict(pass);
6929}
6930
6931/* Test if the EMERGENCY SETUP gets blocked by the BSC if EMERGENCY CALLS are
6932 * forbidden by the BSC config. */
6933private function f_TC_assignment_emerg_setup_deny(charstring id) runs on MSC_ConnHdlr {
6934 var PDU_BSSAP emerg_setup_data_ind_bssap;
6935 timer T := 3.0;
6936
6937 f_assignment_emerg_setup()
6938
6939 T.start;
6940 alt {
6941 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_RELEASE)) {
6942 setverdict(pass);
6943 }
6944 [] RSL.receive {
6945 setverdict(fail, "unexpected RSL message!");
6946 }
6947 [] T.timeout {
6948 setverdict(fail, "timout waiting for RR CHANNEL RELEASE!");
6949 }
6950 }
6951}
6952
6953/* EMERGENCY CALL situation #1, allowed globally and by BTS */
6954testcase TC_assignment_emerg_setup_allow() runs on test_CT {
6955 var TestHdlrParams pars := f_gen_test_hdlr_pars();
6956 var MSC_ConnHdlr vc_conn;
6957
6958 f_init(1, true);
6959 f_sleep(1.0);
6960
6961 f_vty_allow_emerg_msc(true);
6962 f_vty_allow_emerg_bts(true, 0);
6963 vc_conn := f_start_handler(refers(f_TC_assignment_emerg_setup_allow), pars);
6964 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006965 f_shutdown_helper();
Philipp Maier783681c2020-07-16 16:47:06 +02006966}
6967
6968/* EMERGENCY CALL situation #2, forbidden globally but allowed by BTS */
6969testcase TC_assignment_emerg_setup_deny_msc() runs on test_CT {
6970 var TestHdlrParams pars := f_gen_test_hdlr_pars();
6971 var MSC_ConnHdlr vc_conn;
6972
6973 f_init(1, true);
6974 f_sleep(1.0);
6975
6976 f_vty_allow_emerg_msc(false);
6977 f_vty_allow_emerg_bts(true, 0);
6978 vc_conn := f_start_handler(refers(f_TC_assignment_emerg_setup_deny), pars);
6979 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006980 f_shutdown_helper();
Philipp Maier783681c2020-07-16 16:47:06 +02006981}
6982
6983/* EMERGENCY CALL situation #3, allowed globally but forbidden by BTS */
6984testcase TC_assignment_emerg_setup_deny_bts() runs on test_CT {
6985 var TestHdlrParams pars := f_gen_test_hdlr_pars();
6986 var MSC_ConnHdlr vc_conn;
6987
6988 /* Note: This simulates a spec violation by the MS, correct MS
6989 * implementations would not try to establish an emergency call because
6990 * the system information tells in advance that emergency calls are
6991 * not forbidden */
6992
6993 f_init(1, true);
6994 f_sleep(1.0);
6995
6996 f_vty_allow_emerg_msc(true);
6997 f_vty_allow_emerg_bts(false, 0);
6998 vc_conn := f_start_handler(refers(f_TC_assignment_emerg_setup_deny), pars);
6999 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007000 f_shutdown_helper();
Philipp Maier783681c2020-07-16 16:47:06 +02007001}
7002
Philipp Maier82812002020-08-13 18:48:27 +02007003/* Test what happens when an emergency call arrives while all TCH channels are
7004 * busy, the BSC is expected to terminate one call in favor of the incoming
7005 * emergency call */
7006testcase TC_emerg_premption() runs on test_CT {
7007 var ASP_RSL_Unitdata rsl_ud;
7008 var integer i;
7009 var integer chreq_total, chreq_nochan;
7010 var RSL_Message rx_rsl;
7011 var RslChannelNr chan_nr;
7012
7013 f_init(1);
7014 f_sleep(1.0);
7015
7016 f_vty_allow_emerg_msc(true);
7017 f_vty_allow_emerg_bts(true, 0);
7018
7019 /* Fill up all channels on the BTS */
7020 chreq_total := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total");
7021 chreq_nochan := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:no_channel");
7022 for (i := 0; i < NUM_TCHF_PER_BTS + NUM_TCHH_PER_BTS + NUM_SDCCH_PER_BTS; i := i+1) {
7023 chan_nr := f_chreq_act_ack('33'O, i);
7024 }
7025 IPA_RSL[0].clear;
7026 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total",
7027 chreq_total + NUM_TCHF_PER_BTS + NUM_TCHH_PER_BTS + NUM_SDCCH_PER_BTS);
7028
7029 /* Send Channel request for emegergency call */
7030 f_ipa_tx(0, ts_RSL_CHAN_RQD('A5'O, 23));
7031
7032 /* Expect the BSC to release one (the first) TCH/F on the BTS */
7033 chan_nr := valueof(t_RslChanNr_Bm(1));
7034 f_expect_chan_rel(0, chan_nr, expect_rr_chan_rel := false, expect_rll_rel_req := false);
7035
7036 /* Expect the BSC to send activate/assign the a channel for the emergency call */
7037 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
7038 chan_nr := rx_rsl.ies[0].body.chan_nr;
7039 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, 33));
7040 rx_rsl := f_exp_ipa_rx(0, tr_RSL_IMM_ASSIGN(0));
Philipp Maier104f4c02020-09-11 18:12:18 +02007041
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007042 f_shutdown_helper();
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007043}
7044
7045/* Hopping parameters per a timeslot */
Vadim Yanitskiybc6654a2020-09-13 01:27:40 +07007046private type record length(0..64) of GsmArfcn ArfcnList;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007047private type record FHParamsTs {
7048 boolean enabled,
7049 uint6_t hsn,
7050 uint6_t maio,
7051 ArfcnList ma
7052};
7053
7054/* Hopping parameters per a transceiver */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007055private type record FHParamsTrx {
7056 GsmArfcn arfcn,
7057 FHParamsTs ts[8]
7058};
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007059
7060/* Randomly generate the hopping parameters for the given timeslot numbers */
7061private function f_TC_fh_params_gen(template integer tr_tn := (1, 3, 5))
7062runs on test_CT return FHParamsTrx {
7063 var FHParamsTrx fhp;
7064
Vadim Yanitskiy3e997362020-09-05 21:08:34 +07007065 /* Generate a random ARFCN, including ARFCN 0 */
7066 fhp.arfcn := f_rnd_int(3);
Vadim Yanitskiye7c8c6e2020-09-13 14:33:03 +07007067
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007068 for (var integer tn := 0; tn < 8; tn := tn + 1) {
7069 if (not match(tn, tr_tn)) {
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007070 fhp.ts[tn].enabled := false;
7071 fhp.ts[tn].ma := { };
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007072 continue;
7073 }
7074
7075 /* Random HSN / MAIO values: 0..63 */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007076 fhp.ts[tn].hsn := f_rnd_int(64);
7077 fhp.ts[tn].maio := f_rnd_int(64);
7078 fhp.ts[tn].ma := { };
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007079
7080 /* Random Mobile Allocation (hopping channels) */
7081 var integer ma_len := 2 + f_rnd_int(9); /* 2..10 channels */
7082 var integer step := 3 + f_rnd_int(4); /* 3..6 stepping */
7083 for (var integer i := 1; i <= ma_len; i := i + 1) {
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007084 fhp.ts[tn].ma := fhp.ts[tn].ma & { i * step };
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007085 }
7086
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007087 fhp.ts[tn].enabled := true;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007088 }
7089
7090 log("f_TC_fh_params_gen(): ", fhp);
7091 return fhp;
7092}
7093
7094/* Make sure that the given Channel Description IE matches the hopping configuration */
7095private function f_TC_fh_params_match_chan_desc(in FHParamsTrx fhp, in ChannelDescription cd)
7096{
7097 var template (present) ChannelDescription tr_cd;
7098 var template (present) MaioHsn tr_maio_hsn;
7099 var uint3_t tn := cd.chan_nr.tn;
7100
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007101 if (fhp.ts[tn].enabled) {
7102 tr_maio_hsn := tr_HsnMaio(fhp.ts[tn].hsn, fhp.ts[tn].maio);
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007103 tr_cd := tr_ChanDescH1(cd.chan_nr, tr_maio_hsn);
7104 } else {
Vadim Yanitskiye7c8c6e2020-09-13 14:33:03 +07007105 tr_cd := tr_ChanDescH0(cd.chan_nr, fhp.arfcn);
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007106 }
7107
7108 if (not match(cd, tr_cd)) {
7109 setverdict(fail, "Channel Description IE does not match: ",
7110 cd, " vs expected ", tr_cd);
7111 }
7112}
7113
7114/* Make sure that the given Mobile Allocation IE matches the hopping configuration */
7115private function f_TC_fh_params_match_ma(in FHParamsTrx fhp, uint3_t tn,
7116 in MobileAllocationLV ma)
7117{
7118 var template MobileAllocationLV tr_ma := f_TC_fh_params_gen_tr_ma(fhp, tn, ma);
7119
7120 if (not match(ma, tr_ma)) {
7121 setverdict(fail, "Mobile Allocation IE does not match (tn := ",
7122 tn, "): ", ma, " vs expected: ", tr_ma);
7123 } else {
7124 setverdict(pass);
7125 }
7126}
7127
7128private function f_TC_fh_params_gen_tr_ma(in FHParamsTrx fhp, uint3_t tn,
7129 in MobileAllocationLV ma)
7130return template MobileAllocationLV {
7131 /* Mobile Allocation IE is expected to be empty if hopping is not enabled */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007132 if (not fhp.ts[tn].enabled) {
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007133 return { len := 0, ma := ''B };
7134 }
7135
7136 var bitstring full_mask := f_pad_bit(''B, 1024, '0'B);
7137 var bitstring slot_mask := f_pad_bit(''B, 1024, '0'B);
7138 var bitstring ma_mask := ''B;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007139
7140 /* Compose the full bit-mask (all channels, up to 1024 entries) */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007141 for (var integer i := 0; i < lengthof(fhp.ts); i := i + 1) {
7142 for (var integer j := 0; j < lengthof(fhp.ts[i].ma); j := j + 1) {
7143 if (full_mask[fhp.ts[i].ma[j]] == '1'B)
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007144 { continue; }
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007145 full_mask[fhp.ts[i].ma[j]] := '1'B;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007146 }
7147 }
7148
Vadim Yanitskiye7c8c6e2020-09-13 14:33:03 +07007149 /* Take ARFCN of the TRX itself into account */
7150 full_mask[fhp.arfcn] := '1'B;
7151
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007152 /* Compose a bit-mask for the given timeslot number */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007153 for (var integer i := 0; i < lengthof(fhp.ts[tn].ma); i := i + 1) {
7154 slot_mask[fhp.ts[tn].ma[i]] := '1'B;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007155 }
7156
7157 /* Finally, compose the Mobile Allocation bit-mask */
Vadim Yanitskiy3e997362020-09-05 21:08:34 +07007158 for (var integer i := 1; i < lengthof(full_mask); i := i + 1) {
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007159 if (full_mask[i] != '1'B)
7160 { continue; }
7161
7162 /* FIXME: ma_mask := ma_mask & slot_mask[i]; // triggers a bug in TITAN */
7163 if (slot_mask[i] == '1'B) {
7164 ma_mask := ma_mask & '1'B;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007165 } else {
7166 ma_mask := ma_mask & '0'B;
7167 }
7168 }
7169
Vadim Yanitskiy3e997362020-09-05 21:08:34 +07007170 /* ARFCN 0 (if present) goes to the last position of the bit-mask */
7171 if (full_mask[0] == '1'B) {
7172 /* FIXME: ma_mask := ma_mask & slot_mask[0]; // triggers a bug in TITAN */
7173 if (slot_mask[0] == '1'B) {
7174 ma_mask := ma_mask & '1'B;
7175 } else {
7176 ma_mask := ma_mask & '0'B;
7177 }
7178 }
7179
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007180 /* Ensure that ma_mask is octet-aligned */
Vadim Yanitskiy2aa02522020-09-06 14:05:23 +07007181 var integer ma_mask_len := (lengthof(ma_mask) + 8 - 1) / 8;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007182 ma_mask := f_pad_bit(ma_mask, ma_mask_len * 8, '0'B);
7183
7184 return { len := ma_mask_len, ma := ma_mask };
7185}
7186
7187/* Configure the hopping parameters in accordance with the given record */
7188private function f_TC_fh_params_set(in FHParamsTrx fhp,
7189 uint8_t bts_nr := 0,
7190 uint8_t trx_nr := 0)
7191runs on test_CT {
7192 /* Enter the configuration node for the given BTS/TRX numbers */
7193 f_vty_enter_cfg_trx(BSCVTY, bts_nr, trx_nr);
7194
Vadim Yanitskiye7c8c6e2020-09-13 14:33:03 +07007195 f_vty_transceive(BSCVTY, "arfcn " & int2str(fhp.arfcn));
7196
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007197 for (var integer tn := 0; tn < lengthof(fhp.ts); tn := tn + 1) {
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007198 f_vty_transceive(BSCVTY, "timeslot " & int2str(tn));
7199
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007200 if (not fhp.ts[tn].enabled) {
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007201 f_vty_transceive(BSCVTY, "hopping enabled 0");
7202 f_vty_transceive(BSCVTY, "exit"); /* go back */
7203 continue;
7204 }
7205
7206 /* Configure HSN / MAIO values */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007207 f_vty_transceive(BSCVTY, "hopping sequence-number " & int2str(fhp.ts[tn].hsn));
7208 f_vty_transceive(BSCVTY, "hopping maio " & int2str(fhp.ts[tn].maio));
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007209
7210 /* Configure the Mobile Allocation (hopping channels) */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007211 for (var integer i := 0; i < lengthof(fhp.ts[tn].ma); i := i + 1) {
7212 f_vty_transceive(BSCVTY, "hopping arfcn add " & int2str(fhp.ts[tn].ma[i]));
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007213 }
7214
7215 f_vty_transceive(BSCVTY, "hopping enabled 1");
7216 f_vty_transceive(BSCVTY, "exit"); /* go back */
7217 }
7218
7219 f_vty_transceive(BSCVTY, "end");
7220}
7221
7222/* Disable frequency hopping on all timeslots */
7223private function f_TC_fh_params_unset(in FHParamsTrx fhp,
7224 uint8_t bts_nr := 0,
Vadim Yanitskiye7c8c6e2020-09-13 14:33:03 +07007225 uint8_t trx_nr := 0,
7226 GsmArfcn arfcn := 871)
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007227runs on test_CT {
7228 /* Enter the configuration node for the given BTS/TRX numbers */
7229 f_vty_enter_cfg_trx(BSCVTY, bts_nr, trx_nr);
7230
Vadim Yanitskiye7c8c6e2020-09-13 14:33:03 +07007231 f_vty_transceive(BSCVTY, "arfcn " & int2str(arfcn));
7232
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007233 for (var integer tn := 0; tn < lengthof(fhp.ts); tn := tn + 1) {
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007234 f_vty_transceive(BSCVTY, "timeslot " & int2str(tn));
7235
7236 /* Delete all ARFCNs from the Mobile Allocation (if any) */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007237 for (var integer i := 0; i < lengthof(fhp.ts[tn].ma); i := i + 1) {
7238 f_vty_transceive(BSCVTY, "hopping arfcn del " & int2str(fhp.ts[tn].ma[i]));
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007239 }
7240
7241 f_vty_transceive(BSCVTY, "hopping enabled 0");
7242 f_vty_transceive(BSCVTY, "exit"); /* go back */
7243 }
7244
7245 f_vty_transceive(BSCVTY, "end");
7246 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
7247}
7248
7249/* Verify presence and correctness of the hopping parameters (HSN, MAIO)
7250 * in the Channel Identification IE of the RSL CHANnel ACTIVation message. */
7251testcase TC_fh_params_chan_activ() runs on test_CT {
7252 var FHParamsTrx fhp := f_TC_fh_params_gen();
7253 var RSL_Message rsl_msg;
7254 var RSL_IE_Body ie;
7255
7256 f_init_vty();
7257
7258 f_TC_fh_params_set(fhp); /* Enable frequency hopping */
7259 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
7260
7261 f_init(1);
7262
7263 /* CS domain: 3 (SDCCH/4+CBCH) + 4 (TCH/F) + 2 (TCH/H) channels available */
7264 for (var integer i := 0; i < 9; i := i + 1) {
7265 f_ipa_tx(0, ts_RSL_CHAN_RQD(f_rnd_ra_cs(), 23));
7266 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
7267
7268 /* Make sure that Channel Identification IE is present */
7269 if (not f_rsl_find_ie(rsl_msg, RSL_IE_CHAN_IDENT, ie)) {
7270 setverdict(fail, "RSL Channel Identification IE is absent");
7271 continue;
7272 }
7273
7274 /* Make sure that hopping parameters (HSN/MAIO) match */
7275 f_TC_fh_params_match_chan_desc(fhp, ie.chan_ident.ch_desc.v);
7276
7277 /* "Mobile Allocation shall be included but empty" - let's check this */
7278 if (ie.chan_ident.ma.v.len != 0) {
7279 setverdict(fail, "Mobile Allocation IE is not empty: ",
7280 ie.chan_ident.ma, ", despite it shall be");
7281 continue;
7282 }
7283 }
7284
7285 /* Disable frequency hopping */
7286 f_TC_fh_params_unset(fhp);
7287
Vadim Yanitskiy21726312020-09-04 01:45:36 +07007288 f_shutdown_helper();
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007289}
7290
7291/* Verify the hopping parameters (HSN, MAIO, MA) in (RR) Immediate Assignment */
7292testcase TC_fh_params_imm_ass() runs on test_CT {
7293 var FHParamsTrx fhp := f_TC_fh_params_gen();
7294 var RSL_Message rsl_msg;
7295 var RSL_IE_Body ie;
7296
7297 f_init_vty();
7298
7299 f_TC_fh_params_set(fhp); /* Enable frequency hopping */
7300 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
7301
7302 f_init(1);
7303
7304 /* CS domain: 3 (SDCCH/4+CBCH) + 4 (TCH/F) + 2 (TCH/H) channels available */
7305 for (var integer i := 0; i < 9; i := i + 1) {
7306 f_ipa_tx(0, ts_RSL_CHAN_RQD(f_rnd_ra_cs(), 23));
7307 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
7308
7309 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(rsl_msg.ies[0].body.chan_nr, 33));
7310 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeC(RSL_MT_IMMEDIATE_ASSIGN_CMD));
7311
7312 /* Make sure that Full Immediate Assign Info IE is present */
7313 if (not f_rsl_find_ie(rsl_msg, RSL_IE_FULL_IMM_ASS_INFO, ie)) {
7314 setverdict(fail, "RSL Full Immediate Assign Info IE is absent");
7315 continue;
7316 }
7317
7318 /* Decode the actual Immediate Assignment message */
7319 var GsmRrMessage rr_msg := dec_GsmRrMessage(ie.full_imm_ass_info.payload);
7320 if (not match(rr_msg.header, t_RrHeader(IMMEDIATE_ASSIGNMENT, ?))) {
7321 setverdict(fail, "Failed to match Immediate Assignment: ", rr_msg);
7322 continue;
7323 }
7324
7325 /* Make sure that hopping parameters (HSN/MAIO) match */
7326 f_TC_fh_params_match_chan_desc(fhp, rr_msg.payload.imm_ass.chan_desc);
7327
7328 /* Make sure that the Mobile Allocation IE matches */
7329 f_TC_fh_params_match_ma(fhp, rr_msg.payload.imm_ass.chan_desc.chan_nr.tn,
7330 rr_msg.payload.imm_ass.mobile_allocation);
7331 }
7332
7333 /* Disable frequency hopping */
7334 f_TC_fh_params_unset(fhp);
Philipp Maier82812002020-08-13 18:48:27 +02007335
Vadim Yanitskiy21726312020-09-04 01:45:36 +07007336 f_shutdown_helper();
Philipp Maier82812002020-08-13 18:48:27 +02007337}
7338
Vadim Yanitskiyaeb54a22020-09-01 06:25:25 +07007339/* Verify the hopping parameters (HSN, MAIO, MA) in (RR) Assignment Command */
7340testcase TC_fh_params_assignment_cmd() runs on test_CT {
7341 var FHParamsTrx fhp := f_TC_fh_params_gen();
7342 var RSL_Message rsl_msg;
7343 var RSL_IE_Body ie;
7344
7345 f_init_vty();
7346
7347 f_TC_fh_params_set(fhp); /* Enable frequency hopping */
7348 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
7349
7350 f_init(1);
7351
7352 /* HACK: work around "Couldn't find Expect for CRCX" */
7353 vc_MGCP.stop;
7354
7355 var template PDU_BSSAP ass_cmd := f_gen_ass_req();
7356 ass_cmd.pdu.bssmap.assignmentRequest.codecList := ts_BSSMAP_IE_CodecList({ts_CodecFR});
7357
7358 /* CS domain (TCH): 4 (TCH/F) + 2 (TCH/H) channels available
7359 * NOTE: only 3 SDCCH/4 channels are available on CCCH+SDCCH4+CBCH */
7360 for (var integer i := 0; i < 3; i := i + 1) {
7361 /* Establish a dedicated channel, so we can trigger (late) TCH assignment */
7362 var DchanTuple dt := f_est_dchan(f_rnd_ra_cs(), 23, f_rnd_octstring(16));
7363
7364 /* Send a BSSMAP Assignment Command, expect CHANnel ACTIVation */
7365 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ass_cmd));
7366 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
7367
7368 /* ACKnowledge CHANnel ACTIVation, expect RSL DATA REQuest */
7369 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(rsl_msg.ies[0].body.chan_nr, 33));
7370 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeR(RSL_MT_DATA_REQ));
7371
7372 /* Make sure that L3 Information IE is present */
7373 if (not f_rsl_find_ie(rsl_msg, RSL_IE_L3_INFO, ie)) {
7374 setverdict(fail, "RSL L3 Information IE is absent");
7375 continue;
7376 }
7377
7378 /* Decode the L3 message and make sure it is (RR) Assignment Command */
7379 var GsmRrL3Message l3_msg := dec_GsmRrL3Message(ie.l3_info.payload);
7380 if (not match(l3_msg.header, t_RrL3Header(ASSIGNMENT_COMMAND))) {
7381 setverdict(fail, "Failed to match Assignment Command: ", l3_msg);
7382 continue;
7383 }
7384
7385 /* Make sure that hopping parameters (HSN/MAIO) match */
7386 var ChannelDescription chan_desc := l3_msg.payload.ass_cmd.chan_desc;
7387 f_TC_fh_params_match_chan_desc(fhp, chan_desc);
7388
7389 /* Make sure that Cell Channel Description IE is present if FH is enabled */
7390 if (chan_desc.h and not ispresent(l3_msg.payload.ass_cmd.cell_chan_desc)) {
Vadim Yanitskiy38d069d2020-09-02 17:18:57 +07007391 setverdict(fail, "FH enabled, but Cell Channel Description IE is absent");
Vadim Yanitskiyaeb54a22020-09-01 06:25:25 +07007392 continue;
7393 }
7394
7395 /* Make sure that the Mobile Allocation IE matches (if present) */
7396 var boolean ma_present := ispresent(l3_msg.payload.ass_cmd.mobile_allocation);
7397 if (chan_desc.h and ma_present) {
7398 f_TC_fh_params_match_ma(fhp, chan_desc.chan_nr.tn,
7399 l3_msg.payload.ass_cmd.mobile_allocation.v);
7400 } else if (chan_desc.h and not ma_present) {
7401 setverdict(fail, "FH enabled, but Mobile Allocation IE is absent");
7402 continue;
7403 } else if (not chan_desc.h and ma_present) {
7404 setverdict(fail, "FH disabled, but Mobile Allocation IE is present");
7405 continue;
7406 }
7407 }
7408
7409 /* Give the IUT some time to release all channels */
7410 f_sleep(3.0);
7411
7412 /* Disable frequency hopping */
7413 f_TC_fh_params_unset(fhp);
7414
Vadim Yanitskiy21726312020-09-04 01:45:36 +07007415 f_shutdown_helper();
Vadim Yanitskiyaeb54a22020-09-01 06:25:25 +07007416}
7417
Vadim Yanitskiy8f5430d2020-09-02 18:51:38 +07007418/* Verify the hopping parameters (HSN, MAIO, MA) in (RR) Handover Command */
7419private function f_TC_fh_params_handover_cmd(in FHParamsTrx fhp)
7420runs on test_CT {
7421 var RSL_Message rsl_msg;
7422 var RSL_IE_Body ie;
7423 var DchanTuple dt;
7424
7425 /* Establish a dedicated channel, so we can trigger handover */
7426 dt := f_est_dchan(f_rnd_ra_cs(), 23, f_rnd_octstring(16));
7427
7428 /* Trigger handover from BTS0 to BTS1 */
7429 f_bts_0_cfg(BSCVTY, { "neighbor bts 1" });
7430 f_vty_handover(BSCVTY, 0, 0, dt.rsl_chan_nr, 1);
7431
7432 /* Expect RSL CHANnel ACTIVation on BTS1/TRX0/TS1 */
7433 rsl_msg := f_exp_ipa_rx(1, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
7434
7435 /* ACKnowledge channel activation and expect (RR) Handover Command */
7436 f_ipa_tx(1, ts_RSL_CHAN_ACT_ACK(rsl_msg.ies[0].body.chan_nr, 33));
7437 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeR(RSL_MT_DATA_REQ));
7438
7439 /* Make sure that L3 Information IE is present */
7440 if (not f_rsl_find_ie(rsl_msg, RSL_IE_L3_INFO, ie)) {
7441 setverdict(fail, "RSL L3 Information IE is absent");
7442 return;
7443 }
7444
7445 /* Decode the L3 message and make sure it is (RR) Handover Command */
7446 var GsmRrL3Message l3_msg := dec_GsmRrL3Message(ie.l3_info.payload);
7447 if (not match(l3_msg.header, t_RrL3Header(HANDOVER_COMMAND))) {
7448 setverdict(fail, "Failed to match Handover Command: ", l3_msg);
7449 return;
7450 }
7451
7452 /* Make sure that we've got SDCCH/8 on TS1 (expected to be hopping) */
7453 var ChannelDescription chan_desc := l3_msg.payload.ho_cmd.chan_desc;
7454 if (not match(chan_desc.chan_nr, t_RslChanNr_SDCCH8(1, ?))) {
7455 setverdict(fail, "Unexpected channel number: ", chan_desc.chan_nr);
7456 return;
7457 }
7458
7459 /* Make sure that hopping parameters (HSN/MAIO) match */
7460 f_TC_fh_params_match_chan_desc(fhp, chan_desc);
7461
7462 /* Make sure that Cell Channel Description IE is present */
7463 if (not ispresent(l3_msg.payload.ho_cmd.cell_chan_desc)) {
7464 setverdict(fail, "FH enabled, but Cell Channel Description IE is absent");
7465 return;
7466 }
7467
7468 /* Make sure that the Mobile Allocation (after time) IE is present and matches */
7469 var boolean ma_present := ispresent(l3_msg.payload.ho_cmd.mobile_allocation);
7470 if (ma_present) {
7471 f_TC_fh_params_match_ma(fhp, chan_desc.chan_nr.tn,
7472 l3_msg.payload.ho_cmd.mobile_allocation.v);
7473 } else {
7474 setverdict(fail, "FH enabled, but Mobile Allocation IE is absent");
7475 return;
7476 }
7477}
7478testcase TC_fh_params_handover_cmd() runs on test_CT {
7479 var FHParamsTrx fhp := f_TC_fh_params_gen();
7480
7481 f_init_vty();
7482
7483 /* (Re)configure TS0 as BCCH and TS1 as SDCCH8 on BTS1/TRX0 */
7484 f_vty_enter_cfg_trx(BSCVTY, bts := 1, trx := 0);
7485
7486 f_vty_transceive(BSCVTY, "timeslot 0");
7487 f_vty_transceive(BSCVTY, "phys_chan_config ccch");
7488 f_vty_transceive(BSCVTY, "exit"); /* go back */
7489
7490 f_vty_transceive(BSCVTY, "timeslot 1");
7491 f_vty_transceive(BSCVTY, "phys_chan_config sdcch8");
7492 f_vty_transceive(BSCVTY, "end"); /* we're done */
7493
7494 f_TC_fh_params_set(fhp, 1); /* Enable frequency hopping on BTS1 */
7495 f_vty_transceive(BSCVTY, "drop bts connection 1 oml");
7496
7497 f_init(2);
7498
7499 f_TC_fh_params_handover_cmd(fhp);
7500
7501 /* Disable frequency hopping on BTS1 */
7502 f_TC_fh_params_unset(fhp, 1);
7503
7504 /* (Re)configure TS0 as CCCH+SDCCH4+CBCH and TS1 as TCH/F */
7505 f_vty_enter_cfg_trx(BSCVTY, bts := 1, trx := 0);
7506
7507 f_vty_transceive(BSCVTY, "timeslot 0");
7508 f_vty_transceive(BSCVTY, "phys_chan_config ccch+sdcch4+cbch");
7509 f_vty_transceive(BSCVTY, "exit"); /* go back */
7510
7511 f_vty_transceive(BSCVTY, "timeslot 1");
7512 f_vty_transceive(BSCVTY, "phys_chan_config tch/f");
7513 f_vty_transceive(BSCVTY, "end"); /* we're done */
7514
7515 f_shutdown_helper();
7516}
7517
Vadim Yanitskiyca974032020-09-01 07:20:39 +07007518/* Verify the hopping parameters in System Information Type 4 */
7519testcase TC_fh_params_si4_cbch() runs on test_CT {
7520 var FHParamsTrx fhp := f_TC_fh_params_gen(tr_tn := 1);
7521 var ASP_RSL_Unitdata rx_rsl_ud;
7522 timer T := 5.0;
7523
7524 f_init_vty();
7525
7526 /* (Re)configure TS0 as BCCH and TS1 as SDCCH8+CBCH */
7527 f_vty_enter_cfg_trx(BSCVTY, trx := 0);
7528
7529 f_vty_transceive(BSCVTY, "timeslot 0");
7530 f_vty_transceive(BSCVTY, "phys_chan_config ccch");
7531 f_vty_transceive(BSCVTY, "exit"); /* go back */
7532
7533 f_vty_transceive(BSCVTY, "timeslot 1");
7534 f_vty_transceive(BSCVTY, "phys_chan_config sdcch8+cbch");
7535 f_vty_transceive(BSCVTY, "end"); /* we're done */
7536
7537 f_TC_fh_params_set(fhp); /* Enable frequency hopping */
7538 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
7539
7540 f_init(1);
7541
7542 T.start;
7543 alt {
7544 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_BCCH_INFO(RSL_SYSTEM_INFO_4))) -> value rx_rsl_ud {
7545 var RSL_IE_Body ie := rx_rsl_ud.rsl.ies[2].body; /* FULL BCCH Information IE */
7546 var SystemInformation si := dec_SystemInformation(ie.other.payload);
7547
7548 /* Make sure that what we decoded is System Information Type 4 */
7549 if (si.header.message_type != SYSTEM_INFORMATION_TYPE_4) {
7550 setverdict(fail, "RSL FULL BCCH Information IE contains: ", si);
7551 repeat;
7552 }
7553
7554 /* Make sure that CBCH Channel Description IE is present */
7555 if (not ispresent(si.payload.si4.cbch_chan_desc)) {
7556 setverdict(fail, "CBCH Channel Description IE is absent");
7557 break;
7558 }
7559
7560 /* Finally, check the hopping parameters (HSN, MAIO) */
7561 var ChannelDescription chan_desc := si.payload.si4.cbch_chan_desc.v;
7562 f_TC_fh_params_match_chan_desc(fhp, chan_desc);
7563
7564 /* 3GPP TS 44.018, section 9.1.36.2 "CBCH Mobile Allocation":
7565 * The CBCH Mobile Allocation IE *shall* be present if FH is enabled. */
7566 if (chan_desc.h and not ispresent(si.payload.si4.cbch_mobile_alloc)) {
7567 setverdict(fail, "FH enabled, but Mobile Allocation IE is absent");
7568 break;
7569 } else if (chan_desc.h and ispresent(si.payload.si4.cbch_mobile_alloc)) {
7570 f_TC_fh_params_match_ma(fhp, chan_desc.chan_nr.tn,
7571 si.payload.si4.cbch_mobile_alloc.v);
7572 }
7573 }
7574 [] IPA_RSL[0].receive { repeat; }
7575 [] T.timeout {
7576 setverdict(fail, "Timeout waiting for RSL BCCH INFOrmation (SI4)");
7577 }
7578 }
7579
7580 /* Disable frequency hopping */
7581 f_TC_fh_params_unset(fhp);
7582
Vadim Yanitskiy8bc46012020-09-06 12:38:01 +07007583 /* (Re)configure TS0 as CCCH+SDCCH4+CBCH and TS1 as TCH/F */
Vadim Yanitskiyca974032020-09-01 07:20:39 +07007584 f_vty_enter_cfg_trx(BSCVTY, trx := 0);
7585
7586 f_vty_transceive(BSCVTY, "timeslot 0");
Vadim Yanitskiy8bc46012020-09-06 12:38:01 +07007587 f_vty_transceive(BSCVTY, "phys_chan_config ccch+sdcch4+cbch");
Vadim Yanitskiyca974032020-09-01 07:20:39 +07007588 f_vty_transceive(BSCVTY, "exit"); /* go back */
7589
7590 f_vty_transceive(BSCVTY, "timeslot 1");
7591 f_vty_transceive(BSCVTY, "phys_chan_config tch/f");
7592 f_vty_transceive(BSCVTY, "end"); /* we're done */
7593
Vadim Yanitskiy21726312020-09-04 01:45:36 +07007594 f_shutdown_helper();
Vadim Yanitskiyca974032020-09-01 07:20:39 +07007595}
7596
Harald Welte0ea2d5e2018-04-07 21:40:29 +02007597/* Dyn PDCH todo:
7598 * activate OSMO as TCH/F
7599 * activate OSMO as TCH/H
7600 * does the BSC-located PCU socket get the updated INFO?
7601 * what if no PCU is connected at the time?
7602 * is the info correct on delayed PCU (re)connect?
7603 */
Harald Welte94e0c342018-04-07 11:33:23 +02007604
Harald Welte28d943e2017-11-25 15:00:50 +01007605control {
Harald Welte898113b2018-01-31 18:32:21 +01007606 /* CTRL interface testing */
Harald Welte4003d112017-12-09 22:35:39 +01007607 execute( TC_ctrl_msc_connection_status() );
Stefan Sperlingb041b3d2018-01-03 17:14:55 +01007608 execute( TC_ctrl_msc0_connection_status() );
Harald Welte96c94412017-12-09 03:12:45 +01007609 execute( TC_ctrl() );
Neels Hofmeyrf246a922020-05-13 02:27:10 +02007610 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_SCCPlite_SERVER) {
Pau Espin Pedrol5a2d7432019-06-07 19:43:45 +02007611 execute( TC_ctrl_location() );
7612 }
Harald Welte898113b2018-01-31 18:32:21 +01007613
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +02007614 execute( TC_si_default() );
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02007615 execute( TC_si2quater_2_earfcns() );
7616 execute( TC_si2quater_3_earfcns() );
7617 execute( TC_si2quater_4_earfcns() );
7618 execute( TC_si2quater_5_earfcns() );
7619 execute( TC_si2quater_6_earfcns() );
Neels Hofmeyrad132f22020-07-08 02:20:16 +02007620 execute( TC_si2quater_12_earfcns() );
7621 execute( TC_si2quater_23_earfcns() );
7622 execute( TC_si2quater_32_earfcns() );
7623 execute( TC_si2quater_33_earfcns() );
7624 execute( TC_si2quater_42_earfcns() );
7625 execute( TC_si2quater_48_earfcns() );
7626 execute( TC_si2quater_49_earfcns() );
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02007627 execute( TC_si_acc_rotate() );
Alexander Couzens4ad3a352020-09-10 22:29:12 +02007628 execute( TC_si_acc_ramp_rotate() );
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +02007629
Harald Welte898113b2018-01-31 18:32:21 +01007630 /* RSL DCHAN Channel ACtivation / Deactivation */
Harald Welteae026692017-12-09 01:03:01 +01007631 execute( TC_chan_act_noreply() );
Harald Welte4003d112017-12-09 22:35:39 +01007632 execute( TC_chan_act_counter() );
Harald Welteae026692017-12-09 01:03:01 +01007633 execute( TC_chan_act_ack_noest() );
Philipp Maier9c60a622020-07-09 15:08:46 +02007634 execute( TC_chan_act_ack_noest_emerg() );
Philipp Maier606f07d2020-08-12 17:21:58 +02007635 execute( TC_chan_rqd_emerg_deny() );
Harald Welteae026692017-12-09 01:03:01 +01007636 execute( TC_chan_act_ack_est_ind_noreply() );
7637 execute( TC_chan_act_ack_est_ind_refused() );
Harald Welte618ef642017-12-14 14:58:20 +01007638 execute( TC_chan_act_nack() );
Harald Welte799c97b2017-12-14 17:50:30 +01007639 execute( TC_chan_exhaustion() );
Vadim Yanitskiy1ff1fdf2018-11-27 01:32:57 +07007640 execute( TC_chan_deact_silence() );
Harald Welte4003d112017-12-09 22:35:39 +01007641 execute( TC_chan_rel_rll_rel_ind() );
7642 execute( TC_chan_rel_conn_fail() );
7643 execute( TC_chan_rel_hard_clear() );
Harald Welte99787102019-02-04 10:41:36 +01007644 execute( TC_chan_rel_hard_clear_csfb() );
Harald Welted8c36cd2017-12-09 23:05:31 +01007645 execute( TC_chan_rel_hard_rlsd() );
Harald Welte550daf92018-06-11 19:22:13 +02007646 execute( TC_chan_rel_hard_rlsd_ms_dead() );
Harald Welte85804d42017-12-10 14:11:58 +01007647 execute( TC_chan_rel_a_reset() );
Pau Espin Pedrolc675b612020-01-09 19:55:40 +01007648 execute( TC_chan_rel_sccp_tiar_timeout() );
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02007649 execute( TC_chan_rel_rr_cause() );
Harald Welte6f521d82017-12-11 19:52:02 +01007650
Harald Weltecfe2c962017-12-15 12:09:32 +01007651 execute( TC_outbound_connect() );
Harald Welte898113b2018-01-31 18:32:21 +01007652
7653 /* Assignment related */
Harald Welte16a4adf2017-12-14 18:54:01 +01007654 execute( TC_assignment_cic_only() );
Harald Welte235ebf12017-12-15 14:18:16 +01007655 execute( TC_assignment_csd() );
7656 execute( TC_assignment_ctm() );
7657 execute( TC_assignment_sign() );
Pau Espin Pedrol07866632020-09-03 19:10:55 +02007658 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
7659 execute( TC_assignment_aoip_tla_v6() );
7660 }
Harald Welte235ebf12017-12-15 14:18:16 +01007661 execute( TC_assignment_fr_a5_0() );
7662 execute( TC_assignment_fr_a5_1() );
Neels Hofmeyrf246a922020-05-13 02:27:10 +02007663 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
Harald Welte8f67d1d2018-05-25 20:38:42 +02007664 execute( TC_assignment_fr_a5_1_codec_missing() );
7665 }
Harald Welte235ebf12017-12-15 14:18:16 +01007666 execute( TC_assignment_fr_a5_3() );
7667 execute( TC_assignment_fr_a5_4() );
Harald Welte3c86ea02018-05-10 22:28:05 +02007668 execute( TC_ciph_mode_a5_0() );
7669 execute( TC_ciph_mode_a5_1() );
7670 execute( TC_ciph_mode_a5_3() );
Harald Welte16a4adf2017-12-14 18:54:01 +01007671
Harald Welte60aa5762018-03-21 19:33:13 +01007672 execute( TC_assignment_codec_fr() );
7673 execute( TC_assignment_codec_hr() );
7674 execute( TC_assignment_codec_efr() );
7675 execute( TC_assignment_codec_amr_f() );
7676 execute( TC_assignment_codec_amr_h() );
Philipp Maier8a581d22019-03-26 18:32:48 +01007677
Neels Hofmeyrf246a922020-05-13 02:27:10 +02007678 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
Philipp Maier8a581d22019-03-26 18:32:48 +01007679 execute( TC_assignment_codec_amr_f_S1() );
7680 execute( TC_assignment_codec_amr_h_S1() );
7681 execute( TC_assignment_codec_amr_f_S124() );
7682 execute( TC_assignment_codec_amr_h_S124() );
7683 execute( TC_assignment_codec_amr_f_S0() );
7684 execute( TC_assignment_codec_amr_f_S02() );
7685 execute( TC_assignment_codec_amr_f_S024() );
7686 execute( TC_assignment_codec_amr_f_S0247() );
7687 execute( TC_assignment_codec_amr_h_S0() );
7688 execute( TC_assignment_codec_amr_h_S02() );
7689 execute( TC_assignment_codec_amr_h_S024() );
7690 execute( TC_assignment_codec_amr_h_S0247() );
7691 execute( TC_assignment_codec_amr_f_S01234567() );
7692 execute( TC_assignment_codec_amr_f_S0234567() );
7693 execute( TC_assignment_codec_amr_f_zero() );
7694 execute( TC_assignment_codec_amr_f_unsupp() );
7695 execute( TC_assignment_codec_amr_h_S7() );
7696 }
Harald Welte60aa5762018-03-21 19:33:13 +01007697
Philipp Maierac09bfc2019-01-08 13:41:39 +01007698 execute( TC_assignment_codec_fr_exhausted_req_hr() );
7699 execute( TC_assignment_codec_fr_exhausted_req_fr() );
7700 execute( TC_assignment_codec_fr_exhausted_req_fr_hr() );
7701 execute( TC_assignment_codec_fr_exhausted_req_hr_fr() );
7702 execute( TC_assignment_codec_hr_exhausted_req_fr() );
7703 execute( TC_assignment_codec_hr_exhausted_req_hr() );
7704 execute( TC_assignment_codec_hr_exhausted_req_hr_fr() );
7705 execute( TC_assignment_codec_hr_exhausted_req_fr_hr() );
7706 execute( TC_assignment_codec_req_hr_fr() );
7707 execute( TC_assignment_codec_req_fr_hr() );
7708
Pau Espin Pedrol58cf6822019-05-28 18:11:33 +02007709 if (mp_enable_osmux_test) {
7710 execute( TC_assignment_osmux() );
7711 }
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02007712
Harald Welte898113b2018-01-31 18:32:21 +01007713 /* RLL Establish Indication on inactive DCHAN / SAPI */
Harald Welte5cd20ed2017-12-13 21:03:20 +01007714 execute( TC_rll_est_ind_inact_lchan() );
7715 execute( TC_rll_est_ind_inval_sapi1() );
7716 execute( TC_rll_est_ind_inval_sapi3() );
7717 execute( TC_rll_est_ind_inval_sacch() );
7718
Vadim Yanitskiy61f784a2020-10-01 21:12:19 +07007719 /* DLCI / RSL Link ID conversion for MO/MT messages on SAPI0/SAPI3 */
7720 execute( TC_tch_dlci_link_id_sapi() );
7721
Vadim Yanitskiy6ef5dfa2020-08-28 18:04:41 +07007722 /* SAPI N Reject triggered by RLL establishment failures */
7723 execute( TC_rll_rel_ind_sapi_n_reject() );
7724 execute( TC_rll_err_ind_sapi_n_reject() );
7725 execute( TC_rll_timeout_sapi_n_reject() );
7726
Harald Welte898113b2018-01-31 18:32:21 +01007727 /* Paging related tests */
Harald Welte6f521d82017-12-11 19:52:02 +01007728 execute( TC_paging_imsi_nochan() );
7729 execute( TC_paging_tmsi_nochan() );
7730 execute( TC_paging_tmsi_any() );
7731 execute( TC_paging_tmsi_sdcch() );
7732 execute( TC_paging_tmsi_tch_f() );
7733 execute( TC_paging_tmsi_tch_hf() );
7734 execute( TC_paging_imsi_nochan_cgi() );
7735 execute( TC_paging_imsi_nochan_lac_ci() );
7736 execute( TC_paging_imsi_nochan_ci() );
7737 execute( TC_paging_imsi_nochan_lai() );
7738 execute( TC_paging_imsi_nochan_lac() );
7739 execute( TC_paging_imsi_nochan_all() );
Harald Welte751d3eb2018-01-31 15:51:06 +01007740 execute( TC_paging_imsi_nochan_plmn_lac_rnc() );
7741 execute( TC_paging_imsi_nochan_rnc() );
7742 execute( TC_paging_imsi_nochan_lac_rnc() );
7743 execute( TC_paging_imsi_nochan_lacs() );
7744 execute( TC_paging_imsi_nochan_lacs_empty() );
Stefan Sperling049a86e2018-03-20 15:51:00 +01007745 execute( TC_paging_imsi_nochan_cgi_unknown_cid() );
Harald Welte10985002017-12-12 09:29:15 +01007746 execute( TC_paging_imsi_a_reset() );
Harald Weltee65d40e2017-12-13 00:09:06 +01007747 execute( TC_paging_imsi_load() );
Philipp Maier779a7922018-02-16 11:00:37 +01007748 execute( TC_paging_counter() );
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01007749 execute( TC_paging_resp_unsol() );
Harald Welte4e9b9cc2017-12-14 18:31:02 +01007750
7751 execute( TC_rsl_drop_counter() );
Stefan Sperling830dc9d2018-02-12 21:08:28 +01007752 execute( TC_rsl_unknown_unit_id() );
7753
7754 execute( TC_oml_unknown_unit_id() );
Harald Welte898113b2018-01-31 18:32:21 +01007755
7756 execute( TC_classmark() );
Harald Welteeddf0e92020-06-21 19:42:15 +02007757 execute( TC_common_id() );
Harald Welte898113b2018-01-31 18:32:21 +01007758 execute( TC_unsol_ass_fail() );
Harald Welteea99a002018-01-31 20:46:43 +01007759 execute( TC_unsol_ass_compl() );
Harald Weltefbf9b5e2018-01-31 20:41:23 +01007760 execute( TC_unsol_ho_fail() );
Harald Weltee3bd6582018-01-31 22:51:25 +01007761 execute( TC_err_82_short_msg() );
Harald Weltee9e02e42018-01-31 23:36:25 +01007762 execute( TC_err_84_unknown_msg() );
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01007763
Harald Welte261af4b2018-02-12 21:20:39 +01007764 execute( TC_ho_int() );
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01007765
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01007766 execute( TC_ho_out_of_this_bsc() );
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02007767 execute( TC_ho_out_fail_no_msc_response() );
7768 execute( TC_ho_out_fail_rr_ho_failure() );
Neels Hofmeyrd8a602c2019-07-09 19:46:01 +02007769 execute( TC_ho_out_fail_no_result_after_ho_cmd() );
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01007770
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01007771 execute( TC_ho_into_this_bsc() );
Pau Espin Pedrol07866632020-09-03 19:10:55 +02007772 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
7773 execute( TC_ho_into_this_bsc_tla_v6() );
7774 }
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01007775 execute( TC_ho_in_fail_msc_clears() );
7776 execute( TC_ho_in_fail_msc_clears_after_ho_detect() );
7777 execute( TC_ho_in_fail_no_detect() );
7778 execute( TC_ho_in_fail_no_detect2() );
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01007779
Neels Hofmeyr91401012019-07-11 00:42:35 +02007780 execute( TC_ho_neighbor_config_1() );
7781 execute( TC_ho_neighbor_config_2() );
7782 execute( TC_ho_neighbor_config_3() );
7783 execute( TC_ho_neighbor_config_4() );
7784 execute( TC_ho_neighbor_config_5() );
7785 execute( TC_ho_neighbor_config_6() );
7786 execute( TC_ho_neighbor_config_7() );
7787
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01007788 execute( TC_bssap_rlsd_does_not_cause_bssmap_reset() );
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01007789 execute( TC_bssmap_clear_does_not_cause_bssmap_reset() );
Neels Hofmeyrfd445c32018-03-09 15:39:31 +01007790 execute( TC_ms_rel_ind_does_not_cause_bssmap_reset() );
Harald Welte94e0c342018-04-07 11:33:23 +02007791
7792 execute( TC_dyn_pdch_ipa_act_deact() );
7793 execute( TC_dyn_pdch_ipa_act_nack() );
7794 execute( TC_dyn_pdch_osmo_act_deact() );
7795 execute( TC_dyn_pdch_osmo_act_nack() );
Harald Welte99f3ca02018-06-14 13:40:29 +02007796
Stefan Sperling0796a822018-10-05 13:01:39 +02007797 execute( TC_chopped_ipa_ping() );
Stefan Sperlingaa1e60f2018-10-15 16:34:07 +02007798 execute( TC_chopped_ipa_payload() );
Stefan Sperling0796a822018-10-05 13:01:39 +02007799
Pau Espin Pedrol8f773632019-11-05 11:46:53 +01007800 /* Power control related */
7801 execute( TC_assignment_verify_ms_power_params_ie() );
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007802
7803 /* MSC pooling */
7804 /* FIXME: in SCCPlite, indicating how many MSCs should be connected does currently not work. Since
7805 * RESET->RESET-ACK is unconditionally negotiated for all configured MSCs, they always all appear as connected
7806 * to osmo-bsc. The MSC pooling tests however require disconnecting selected MSCs, and hence don't work out as
7807 * intended on SCCPlite. So for now, run these only for SCCP/M3UA. */
7808 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
7809 execute( TC_mscpool_L3Compl_on_1_msc() );
7810 execute( TC_mscpool_L3Complete_by_imsi_round_robin() );
7811 execute( TC_mscpool_LU_by_tmsi_null_nri_0_round_robin() );
7812 execute( TC_mscpool_LU_by_tmsi_null_nri_1_round_robin() );
7813 execute( TC_mscpool_L3Complete_by_tmsi_unassigned_nri_round_robin() );
7814 execute( TC_mscpool_L3Complete_by_tmsi_valid_nri_msc_not_connected_round_robin() );
7815 execute( TC_mscpool_L3Complete_by_tmsi_valid_nri_1() );
7816 execute( TC_mscpool_L3Complete_by_tmsi_valid_nri_2() );
7817 execute( TC_mscpool_LU_by_tmsi_from_other_PLMN() );
7818 execute( TC_mscpool_paging_and_response_imsi() );
7819 execute( TC_mscpool_paging_and_response_tmsi() );
7820 execute( TC_mscpool_no_allow_attach_round_robin() );
7821 execute( TC_mscpool_no_allow_attach_valid_nri() );
7822 }
7823
Harald Welte99f3ca02018-06-14 13:40:29 +02007824 /* at bottom as they might crash OsmoBSC before OS#3182 is fixed */
7825 execute( TC_early_conn_fail() );
7826 execute( TC_late_conn_fail() );
7827
Philipp Maier783681c2020-07-16 16:47:06 +02007828 /* Emergency call handling (deny / allow) */
7829 execute( TC_assignment_emerg_setup_allow() );
7830 execute( TC_assignment_emerg_setup_deny_msc() );
7831 execute( TC_assignment_emerg_setup_deny_bts() );
Philipp Maier82812002020-08-13 18:48:27 +02007832 execute( TC_emerg_premption() );
7833
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007834 /* Frequency hopping parameters handling */
7835 execute( TC_fh_params_chan_activ() );
7836 execute( TC_fh_params_imm_ass() );
Vadim Yanitskiyaeb54a22020-09-01 06:25:25 +07007837 execute( TC_fh_params_assignment_cmd() );
Vadim Yanitskiy8f5430d2020-09-02 18:51:38 +07007838 execute( TC_fh_params_handover_cmd() );
Vadim Yanitskiyca974032020-09-01 07:20:39 +07007839 execute( TC_fh_params_si4_cbch() );
Harald Welte28d943e2017-11-25 15:00:50 +01007840}
7841
7842}