blob: b33f000a85422c71311f8197523b28a01ddcd9e4 [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 };
622
Pau Espin Pedrol58cf6822019-05-28 18:11:33 +0200623 /* Whether to enable osmux tests. Can be dropped completely and enable
624 unconditionally once new version of osmo-bsc is released (current
625 version: 1.4.1) */
626 boolean mp_enable_osmux_test := true;
Pau Espin Pedrol8f30ccd2019-11-01 17:30:57 +0100627 /* Value set in osmo-bsc.cfg "ms max power" */
628 uint8_t mp_exp_ms_power_level := 7;
Philipp Maiera2083892020-09-21 14:18:36 +0200629
630 boolean mp_media_mgw_offer_ipv6 := true;
Harald Weltea4ca4462018-02-09 00:17:14 +0100631}
632
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200633private function f_gen_test_hdlr_pars(integer bssap_idx := 0) return TestHdlrParams {
Philipp Maier48604732018-10-09 15:00:37 +0200634
635 var TestHdlrParams pars := valueof(t_def_TestHdlrPars);
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200636 if (mp_bssap_cfg[bssap_idx].transport == BSSAP_TRANSPORT_AoIP) {
Philipp Maier48604732018-10-09 15:00:37 +0200637 pars.aoip := true;
638 } else {
639 pars.aoip := false;
640 }
Pau Espin Pedrol8f30ccd2019-11-01 17:30:57 +0100641 pars.exp_ms_power_level := mp_exp_ms_power_level;
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200642 pars.mscpool.bssap_idx := bssap_idx;
Philipp Maiera2083892020-09-21 14:18:36 +0200643 pars.media_mgw_offer_ipv6 := mp_media_mgw_offer_ipv6;
Philipp Maier48604732018-10-09 15:00:37 +0200644
645 return pars;
646}
647
Neels Hofmeyr22c3f792020-06-17 02:49:28 +0200648/* Convenience functions for rate counters using g_ctr_msc. */
649
650private function f_ctrs_msc_init(integer mscs_count := NUM_MSC, CounterNameVals counternames := counternames_msc_mscpool) runs on test_CT {
651 g_ctr_msc := f_counter_name_vals_get_n(IPA_CTRL, "msc", mscs_count, counternames);
652 log("initial msc rate counters: ", g_ctr_msc);
653}
654
655private function f_ctrs_msc_add(integer msc_nr, charstring countername, integer val := 1) runs on test_CT {
Neels Hofmeyr9656e922020-06-30 01:27:01 +0200656 f_counter_name_vals_list_add(g_ctr_msc, msc_nr, countername, val);
Neels Hofmeyr22c3f792020-06-17 02:49:28 +0200657}
658
659/* f_ctrs_msc_init();
660 * f_do_thing(on_msc := 0);
661 * f_do_thing(on_msc := 0);
662 * f_do_other(on_msc := 1);
663 * f_ctrs_msc_add(0, "thing", 2);
664 * f_ctrs_msc_add(1, "other");
665 * f_ctrs_msc_verify();
666 */
667private function f_ctrs_msc_verify() runs on test_CT {
668 log("verifying msc rate counters: ", g_ctr_msc);
669 f_counter_name_vals_expect_n(IPA_CTRL, "msc", g_ctr_msc);
670}
671
672/* convenience: f_ctrs_msc_add() and f_ctrs_msc_verify() in one call.
673 * f_ctrs_msc_init();
674 * f_do_thing(on_msc := 0);
675 * f_do_thing(on_msc := 0);
676 * f_do_thing(on_msc := 0);
677 * f_ctrs_msc_expect(0, "thing", 3);
678 */
679private function f_ctrs_msc_expect(integer msc_nr, charstring countername, integer val := 1) runs on test_CT {
680 f_ctrs_msc_add(msc_nr, countername, val);
681 f_ctrs_msc_verify();
682}
683
Neels Hofmeyr12941bd2020-08-29 03:21:26 +0000684/* Convenience functions for rate counters using g_ctr_bts, always also including g_ctr_bsc. */
685
686private function f_ctrs_bsc_and_bts_init(integer bts_count := NUM_BTS, CounterNameVals counternames := counternames_bsc_bts_handover) runs on test_CT {
687 g_ctr_bts := f_counter_name_vals_get_n(IPA_CTRL, "bts", bts_count, counternames);
688 log("initial bts rate counters: ", g_ctr_bts);
689 f_ctrs_bsc_init(counternames);
690}
691
692private function f_ctrs_bsc_and_bts_add(integer bts_nr, charstring countername, integer val := 1) runs on test_CT {
693 f_counter_name_vals_list_add(g_ctr_bts, bts_nr, countername, val);
694 f_ctrs_bsc_add(countername, val);
695}
696
697/* f_ctrs_bsc_and_bts_init();
698 * f_do_thing(on_bts := 0);
699 * f_do_thing(on_bts := 0);
700 * f_do_other(on_bts := 1);
701 * f_ctrs_bsc_and_bts_add(0, "thing", 2);
702 * f_ctrs_bsc_and_bts_add(1, "other");
703 * f_ctrs_bsc_and_bts_verify();
704 */
705private function f_ctrs_bsc_and_bts_verify() runs on test_CT {
706 f_counter_name_vals_expect_n(IPA_CTRL, "bts", g_ctr_bts);
707 f_ctrs_bsc_verify();
708}
709
710/* convenience: f_ctrs_bsc_and_bts_add() and f_ctrs_bsc_and_bts_verify() in one call.
711 * f_ctrs_bsc_and_bts_init();
712 * f_do_thing(on_bts := 0);
713 * f_do_thing(on_bts := 0);
714 * f_do_thing(on_bts := 0);
715 * f_ctrs_bsc_and_bts_expect(0, "thing", 3);
716 */
717private function f_ctrs_bsc_and_bts_expect(integer bts_nr, charstring countername, integer val := 1) runs on test_CT {
718 f_ctrs_bsc_and_bts_add(bts_nr, countername, val);
719 f_ctrs_bsc_and_bts_verify();
720}
721
722
723/* Convenience functions for rate counters using g_ctr_bsc. */
724
725private function f_ctrs_bsc_init(CounterNameVals counternames := counternames_bsc_bts_handover) runs on test_CT {
726 g_ctr_bsc := f_counter_name_vals_get_n(IPA_CTRL, "bsc", 1, counternames);
727 log("initial bsc rate counters: ", g_ctr_bsc);
728}
729
730private function f_ctrs_bsc_add(charstring countername, integer val := 1) runs on test_CT {
731 f_counter_name_vals_list_add(g_ctr_bsc, 0, countername, val);
732}
733
734/* f_ctrs_bsc_init();
735 * f_do_thing();
736 * f_do_thing();
737 * f_do_other();
738 * f_ctrs_bsc_add("thing", 2);
739 * f_ctrs_bsc_add("other");
740 * f_ctrs_bsc_verify();
741 */
742private function f_ctrs_bsc_verify() runs on test_CT {
743 f_counter_name_vals_expect_n(IPA_CTRL, "bsc", g_ctr_bsc);
744}
745
746/* convenience: f_ctrs_bsc_add() and f_ctrs_bsc_verify() in one call.
747 * f_ctrs_bsc_init();
748 * f_do_thing();
749 * f_ctrs_bsc_expect("thing", 1);
750 */
751private function f_ctrs_bsc_expect(charstring countername, integer val := 1) runs on test_CT {
752 f_ctrs_bsc_add(countername, val);
753 f_ctrs_bsc_verify();
754}
755
Neels Hofmeyr22c3f792020-06-17 02:49:28 +0200756
Philipp Maier282ca4b2018-02-27 17:17:00 +0100757private function f_shutdown_helper() runs on test_CT {
Daniel Willmann637ef6c2018-07-25 10:49:09 +0200758 all component.stop;
Philipp Maier282ca4b2018-02-27 17:17:00 +0100759 setverdict(pass);
Daniel Willmannafce8662018-07-06 23:11:32 +0200760 mtc.stop;
Philipp Maier282ca4b2018-02-27 17:17:00 +0100761}
762
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200763private function f_legacy_bssap_reset(integer bssap_idx := 0) runs on test_CT {
Harald Weltea4ca4462018-02-09 00:17:14 +0100764 var BSSAP_N_UNITDATA_ind ud_ind;
Pau Espin Pedrol24c05992020-09-01 12:54:12 +0200765 var boolean reset_received := false;
Harald Weltea4ca4462018-02-09 00:17:14 +0100766 timer T := 5.0;
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200767 BSSAP.send(ts_BSSAP_UNITDATA_req(g_bssap[bssap_idx].sccp_addr_peer, g_bssap[bssap_idx].sccp_addr_own,
768 ts_BSSMAP_Reset(0, g_osmux_enabled)));
Harald Weltea4ca4462018-02-09 00:17:14 +0100769 T.start;
770 alt {
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200771 [] BSSAP.receive(tr_BSSAP_UNITDATA_ind(g_bssap[bssap_idx].sccp_addr_own, g_bssap[bssap_idx].sccp_addr_peer,
772 tr_BSSMAP_ResetAck(g_osmux_enabled))) {
Harald Weltea4ca4462018-02-09 00:17:14 +0100773 log("Received RESET-ACK in response to RESET, we're ready to go!");
774 }
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200775 [] BSSAP.receive(tr_BSSAP_UNITDATA_ind(?, ?, tr_BSSMAP_Reset(g_osmux_enabled))) -> value ud_ind {
Harald Weltea4ca4462018-02-09 00:17:14 +0100776 log("Respoding to inbound RESET with RESET-ACK");
777 BSSAP.send(ts_BSSAP_UNITDATA_req(ud_ind.callingAddress, ud_ind.calledAddress,
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200778 ts_BSSMAP_ResetAck(g_osmux_enabled)));
Pau Espin Pedrol24c05992020-09-01 12:54:12 +0200779 reset_received := true;
Harald Weltea4ca4462018-02-09 00:17:14 +0100780 repeat;
781 }
782 [] BSSAP.receive { repeat; }
Pau Espin Pedrol24c05992020-09-01 12:54:12 +0200783 [] T.timeout {
784 log("Timeout waiting for RESET-ACK after sending RESET");
785 /* If we received a RESET after ours was sent, it
786 may be a race condition where the other peer beacame
787 available after we sent it, but we are in a desired
788 state anyway, so go forward. */
789 if (not reset_received) {
790 setverdict(fail);
791 }
792 }
Harald Weltea4ca4462018-02-09 00:17:14 +0100793 }
Harald Welte28d943e2017-11-25 15:00:50 +0100794}
795
Harald Welteae026692017-12-09 01:03:01 +0100796type record IPA_Client {
Harald Welte21b46bd2017-12-17 19:46:32 +0100797 /* IPA Emulation component reference */
Harald Welteae026692017-12-09 01:03:01 +0100798 IPA_Emulation_CT vc_IPA,
Harald Welte21b46bd2017-12-17 19:46:32 +0100799 /* Unit-ID and other CCM parameters to use for IPA client emulation */
Harald Welteae026692017-12-09 01:03:01 +0100800 IPA_CCM_Parameters ccm_pars,
Harald Welte21b46bd2017-12-17 19:46:32 +0100801 /* String identifier for this IPA Client */
Harald Welte624f9632017-12-16 19:26:04 +0100802 charstring id,
Harald Welte21b46bd2017-12-17 19:46:32 +0100803 /* Associated RSL Emulation Component (if any). Only used in "Handler mode" */
Harald Welte624f9632017-12-16 19:26:04 +0100804 RSL_Emulation_CT vc_RSL optional
Harald Welte28d943e2017-11-25 15:00:50 +0100805}
806
Harald Welte21b46bd2017-12-17 19:46:32 +0100807/*! Start the IPA/RSL related bits for one IPA_Client.
808 * \param clnt IPA_Client for which to establish
809 * \param bsc_host IP address / hostname of the BSC
810 * \param bsc_port TCP port number of the BSC
811 * \param i number identifying this BTS
812 * \param handler_mode Start an RSL_Emulation_CT component (true) or not (false) */
Harald Welte624f9632017-12-16 19:26:04 +0100813function f_ipa_rsl_start(inout IPA_Client clnt, charstring bsc_host, PortNumber bsc_port, integer i,
814 boolean handler_mode := false)
Harald Welte28d943e2017-11-25 15:00:50 +0100815runs on test_CT {
Harald Welteae026692017-12-09 01:03:01 +0100816 timer T := 10.0;
817
Harald Welte96c94412017-12-09 03:12:45 +0100818 clnt.id := "IPA" & int2str(i) & "-RSL";
Harald Welteae026692017-12-09 01:03:01 +0100819 clnt.vc_IPA := IPA_Emulation_CT.create(clnt.id & "-IPA");
820 clnt.ccm_pars := c_IPA_default_ccm_pars;
821 clnt.ccm_pars.name := "Osmocom TTCN-3 BTS Simulator";
822 clnt.ccm_pars.unit_id := int2str(1234+i) & "/0/0";
Harald Welte624f9632017-12-16 19:26:04 +0100823 if (handler_mode) {
824 clnt.vc_RSL := RSL_Emulation_CT.create(clnt.id & "-RSL");
Harald Welte89ab1912018-02-23 18:56:29 +0100825 connect(clnt.vc_RSL:CCHAN_PT, self:RSL_CCHAN[i]);
Harald Welte624f9632017-12-16 19:26:04 +0100826 }
Harald Welteae026692017-12-09 01:03:01 +0100827
828 map(clnt.vc_IPA:IPA_PORT, system:IPA_CODEC_PT);
Harald Welte624f9632017-12-16 19:26:04 +0100829 if (handler_mode) {
830 connect(clnt.vc_IPA:IPA_RSL_PORT, clnt.vc_RSL:IPA_PT);
831 } else {
832 connect(clnt.vc_IPA:IPA_RSL_PORT, self:IPA_RSL[i]);
833 }
Harald Welteae026692017-12-09 01:03:01 +0100834
Harald Welte5d1a2202017-12-13 19:51:29 +0100835 clnt.vc_IPA.start(IPA_Emulation.main_client(bsc_host, bsc_port, "", 10000+i, clnt.ccm_pars));
Harald Welte624f9632017-12-16 19:26:04 +0100836 if (handler_mode) {
837 clnt.vc_RSL.start(RSL_Emulation.main());
838 return;
839 }
Harald Welteae026692017-12-09 01:03:01 +0100840
841 /* wait for IPA RSL link to connect and send ID ACK */
842 T.start;
843 alt {
Vadim Yanitskiya2afacc2020-05-18 21:16:19 +0700844 [] IPA_RSL[i].receive(tr_ASP_IPA_EV(ASP_IPA_EVENT_ID_ACK)) {
Harald Welteae026692017-12-09 01:03:01 +0100845 T.stop;
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +0700846 IPA_RSL[i].send(ts_ASP_RSL_UD(ts_RSL_PAGING_LOAD_IND(23)));
Harald Welteae026692017-12-09 01:03:01 +0100847 }
Harald Welte60e823a2017-12-10 14:10:59 +0100848 [] IPA_RSL[i].receive(ASP_IPA_Event:?) { repeat }
Harald Welteae026692017-12-09 01:03:01 +0100849 [] IPA_RSL[i].receive { repeat }
850 [] T.timeout {
Harald Welte96c94412017-12-09 03:12:45 +0100851 setverdict(fail, "Timeout RSL waiting for ASP_IPA_EVENT_ID_ACK");
Daniel Willmannafce8662018-07-06 23:11:32 +0200852 mtc.stop;
Harald Welteae026692017-12-09 01:03:01 +0100853 }
854 }
855}
856
Harald Welte12055472018-03-17 20:10:08 +0100857function f_ipa_rsl_stop(inout IPA_Client clnt) runs on test_CT {
858 if (not isbound(clnt) or not isbound(clnt.vc_IPA)) {
859 return;
860 }
861 clnt.vc_IPA.stop;
862 if (isbound(clnt.vc_RSL)) {
863 clnt.vc_RSL.stop;
864 }
865}
866
Harald Welte21b46bd2017-12-17 19:46:32 +0100867/* Wait for the OML connection to be brought up by the external osmo-bts-omldummy */
Harald Weltea5d2ab22017-12-09 14:21:42 +0100868function f_wait_oml(integer bts_nr, charstring status, float secs_max) runs on test_CT {
869 timer T := secs_max;
870 T.start;
871 while (true) {
872 if (f_ctrl_get_bts(IPA_CTRL, bts_nr, "oml-connection-state") == status) {
873 T.stop;
Harald Weltebd868bd2017-12-10 18:28:40 +0100874 /* the 'degraded' state exists from OML connection time, and we have to wait
875 * until all MO's are initialized */
876 T.start(1.0);
877 T.timeout;
Harald Weltea5d2ab22017-12-09 14:21:42 +0100878 return;
879 }
Harald Weltef0d6ac62017-12-17 17:02:21 +0100880 f_sleep(0.1);
Harald Weltea5d2ab22017-12-09 14:21:42 +0100881 if (not T.running) {
Max99253902018-11-16 17:57:39 +0100882 setverdict(fail, "Timeout waiting for BTS" & int2str(bts_nr) & " oml-connection-state ", status);
Daniel Willmannafce8662018-07-06 23:11:32 +0200883 mtc.stop;
Harald Weltea5d2ab22017-12-09 14:21:42 +0100884 }
885 }
886}
887
Harald Welte21b46bd2017-12-17 19:46:32 +0100888/* global altstep for global guard timer; also takes care of responding RESET witH RESET-ACK */
Harald Welteae026692017-12-09 01:03:01 +0100889altstep as_Tguard() runs on test_CT {
Harald Welte60e823a2017-12-10 14:10:59 +0100890 var BSSAP_N_UNITDATA_ind ud_ind;
Neels Hofmeyrcc3f76a2018-03-12 01:43:25 +0100891 [] T_guard.timeout {
892 setverdict(fail, "Timeout of T_guard");
Daniel Willmannafce8662018-07-06 23:11:32 +0200893 mtc.stop;
Neels Hofmeyrcc3f76a2018-03-12 01:43:25 +0100894 }
Harald Welte60e823a2017-12-10 14:10:59 +0100895 /* always respond with RESET ACK to RESET */
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200896 [] BSSAP.receive(tr_BSSAP_UNITDATA_ind(?, ?, tr_BSSMAP_Reset(g_osmux_enabled))) -> value ud_ind {
Harald Welte60e823a2017-12-10 14:10:59 +0100897 BSSAP.send(ts_BSSAP_UNITDATA_req(ud_ind.callingAddress, ud_ind.calledAddress,
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200898 ts_BSSMAP_ResetAck(g_osmux_enabled)));
Harald Welte69c1c262017-12-13 21:02:08 +0100899 repeat;
Harald Welte60e823a2017-12-10 14:10:59 +0100900 }
Harald Welte28d943e2017-11-25 15:00:50 +0100901}
902
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +0100903altstep no_bssmap_reset() runs on test_CT {
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200904 [] BSSAP.receive(tr_BSSAP_UNITDATA_ind(?, ?, tr_BSSMAP_Reset(g_osmux_enabled))) {
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +0100905 setverdict(fail, "unexpected BSSMAP Reset");
Daniel Willmannafce8662018-07-06 23:11:32 +0200906 mtc.stop;
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +0100907 }
908}
909
Daniel Willmann191e0d92018-01-17 12:44:35 +0100910function f_init_mgcp(charstring id) runs on test_CT {
911 id := id & "-MGCP";
912
913 var MGCPOps ops := {
914 create_cb := refers(MGCP_Emulation.ExpectedCreateCallback),
915 unitdata_cb := refers(MGCP_Emulation.DummyUnitdataCallback)
916 };
917 var MGCP_conn_parameters mgcp_pars := {
918 callagent_ip := mp_bsc_ip,
Harald Welte9e4273e2018-01-29 22:01:22 +0100919 callagent_udp_port := -1,
Daniel Willmann191e0d92018-01-17 12:44:35 +0100920 mgw_ip := mp_test_ip,
Pau Espin Pedrol1a026a52019-06-18 17:21:52 +0200921 mgw_udp_port := 2427,
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +0200922 /* Enable it for SCCPlite, since we have 2 MGCP sockets towards MGW (UDP one +
923 the on with MGCP over IPA forwarded from MSC one) */
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200924 multi_conn_mode := (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_SCCPlite_SERVER)
Daniel Willmann191e0d92018-01-17 12:44:35 +0100925 };
926
927 vc_MGCP := MGCP_Emulation_CT.create(id);
928 vc_MGCP.start(MGCP_Emulation.main(ops, mgcp_pars, id));
929}
930
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200931/* Enable or disable (current default) Osmux. When enabling, BSSMAP Reset
932 * contains extra IE (OsmuxSupport) and osmo-bsc will handle AssignReq with
933 * OsmuxCID IE.
934 */
935private function f_vty_allow_osmux(boolean allow) runs on test_CT {
936 f_vty_enter_cfg_msc(BSCVTY, 0);
937 if (allow) {
938 f_vty_transceive(BSCVTY, "osmux on");
939 } else {
940 f_vty_transceive(BSCVTY, "osmux off");
941 }
942 f_vty_transceive(BSCVTY, "exit");
943 f_vty_transceive(BSCVTY, "exit");
944 g_osmux_enabled := allow;
945}
946
Max2253c0b2018-11-06 19:28:05 +0100947function f_init_vty(charstring id := "foo") runs on test_CT {
Harald Welte94e0c342018-04-07 11:33:23 +0200948 if (BSCVTY.checkstate("Mapped")) {
949 /* skip initialization if already executed once */
950 return;
951 }
Harald Weltebc03c762018-02-12 18:09:38 +0100952 map(self:BSCVTY, system:BSCVTY);
953 f_vty_set_prompts(BSCVTY);
954 f_vty_transceive(BSCVTY, "enable");
Pau Espin Pedrolc675b612020-01-09 19:55:40 +0100955 f_cs7_inst_0_cfg(BSCVTY, {"sccp-timer ias " & int2str(g_bsc_sccp_timer_ias),
956 "sccp-timer iar " & int2str(g_bsc_sccp_timer_iar)});
Harald Weltebc03c762018-02-12 18:09:38 +0100957}
958
Neels Hofmeyr767548a2020-08-09 20:26:07 +0000959private function f_logp(TELNETasp_PT pt, charstring log_msg)
Neels Hofmeyr4f118412020-06-04 15:25:10 +0200960{
961 // log on TTCN3 log output
962 log(log_msg);
963 // log in stderr log
Neels Hofmeyr767548a2020-08-09 20:26:07 +0000964 f_vty_transceive(pt, "logp lglobal notice TTCN3 f_logp(): " & log_msg);
Neels Hofmeyr4f118412020-06-04 15:25:10 +0200965}
966
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +0200967private function f_sysinfo_seen(integer rsl_idx, RSL_Message rsl) runs on test_CT
968{
969 if (rsl_idx >= lengthof(g_system_information)) {
970 g_system_information[rsl_idx] := SystemInformationConfig_omit
971 }
972 f_sysinfo_dec_raw(g_system_information[rsl_idx], rsl);
973}
974
975altstep as_catch_RSL_sysinfo(integer rsl_idx) runs on test_CT {
976 var ASP_RSL_Unitdata rx_rsl_ud;
977
978 /* For handler_mode := false, receiving the RSL bootstrap messages directly on IPA_RSL */
979 [] IPA_RSL[rsl_idx].receive(tr_ASP_RSL_UD(tr_RSL_NO_BCCH_INFO)) -> value rx_rsl_ud {
980 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
981 repeat;
982 }
983 [] IPA_RSL[rsl_idx].receive(tr_ASP_RSL_UD(tr_RSL_BCCH_INFO)) -> value rx_rsl_ud {
984 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
985 repeat;
986 }
987 [] IPA_RSL[rsl_idx].receive(tr_ASP_RSL_UD(tr_RSL_NO_SACCH_FILL)) -> value rx_rsl_ud {
988 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
989 repeat;
990 }
991 [] IPA_RSL[rsl_idx].receive(tr_ASP_RSL_UD(tr_RSL_SACCH_FILL)) -> value rx_rsl_ud {
992 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
993 repeat;
994 }
995
996 /* For handler_mode := true, receiving the RSL bootstrap messages via RSL_Emulation */
997 [] RSL_CCHAN[rsl_idx].receive(tr_ASP_RSL_UD(tr_RSL_NO_BCCH_INFO)) -> value rx_rsl_ud {
998 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
999 repeat;
1000 }
1001 [] RSL_CCHAN[rsl_idx].receive(tr_ASP_RSL_UD(tr_RSL_BCCH_INFO)) -> value rx_rsl_ud {
1002 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
1003 repeat;
1004 }
1005 [] RSL_CCHAN[rsl_idx].receive(tr_ASP_RSL_UD(tr_RSL_NO_SACCH_FILL)) -> value rx_rsl_ud {
1006 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
1007 repeat;
1008 }
1009 [] RSL_CCHAN[rsl_idx].receive(tr_ASP_RSL_UD(tr_RSL_SACCH_FILL)) -> value rx_rsl_ud {
1010 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
1011 repeat;
1012 }
1013}
1014
Neels Hofmeyra460f1f2020-08-09 20:17:03 +00001015/* TODO: use BooleanList from COMMON/src/General_Types.ttcn */
1016private type record of boolean my_BooleanList;
1017
1018private function f_vty_msc_allow_attach(TELNETasp_PT pt, my_BooleanList allow_attach_list)
1019{
Neels Hofmeyr8f576712020-08-12 22:49:53 +00001020 var charstring config := f_vty_transceive_ret(pt, "show running-config");
1021
Neels Hofmeyra460f1f2020-08-09 20:17:03 +00001022 for (var integer msc_nr := 0; msc_nr < sizeof(allow_attach_list); msc_nr := msc_nr+1) {
Neels Hofmeyr8f576712020-08-12 22:49:53 +00001023 if (f_strstr(config, "\nmsc " & int2str(msc_nr) & "\n") < 0) {
1024 /* There is no 'msc N' for this msc_nr in the running config, so don't create an empty msc by
1025 * stepping into that config node. */
1026 log("msc ", msc_nr, " is not configured, skipping");
1027 continue;
1028 }
Neels Hofmeyra460f1f2020-08-09 20:17:03 +00001029 f_vty_enter_cfg_msc(pt, msc_nr);
1030 if (allow_attach_list[msc_nr]) {
1031 /* strict := false: ignore if osmo-bsc does not support this config option (latest build) */
1032 f_vty_transceive(pt, "allow-attach", strict := false);
1033 } else {
1034 f_vty_transceive(pt, "no allow-attach", strict := false);
1035 }
1036 f_vty_transceive(pt, "exit");
1037 f_vty_transceive(pt, "exit");
1038 }
1039}
1040
Harald Welte21b46bd2017-12-17 19:46:32 +01001041/* global initialization function
1042 * \param nr_bts Number of BTSs we should start/bring up
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001043 * \param handler_mode Start an RSL_Emulation_CT component (true) or not (false).
1044 * \param nr_msc Number of virtual MSCs to bring up to connect to osmo-bsc.
1045 */
1046function f_init(integer nr_bts := NUM_BTS, boolean handler_mode := false, boolean allow_osmux := false,
Neels Hofmeyr4fbad7f2020-06-16 00:30:47 +02001047 integer nr_msc := 1, float guard_timeout := 30.0) runs on test_CT {
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001048 var integer bssap_idx;
Harald Welte28d943e2017-11-25 15:00:50 +01001049
Harald Welteae026692017-12-09 01:03:01 +01001050 if (g_initialized) {
1051 return;
Harald Welte28d943e2017-11-25 15:00:50 +01001052 }
Harald Welteae026692017-12-09 01:03:01 +01001053 g_initialized := true;
1054
Neels Hofmeyr4fbad7f2020-06-16 00:30:47 +02001055 T_guard.start(guard_timeout);
Daniel Willmanne68f9272018-11-27 15:15:28 +01001056 activate(as_Tguard());
1057
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02001058 f_init_vty("VirtMSC");
Pau Espin Pedrol58cf6822019-05-28 18:11:33 +02001059 if (mp_enable_osmux_test) {
1060 f_vty_allow_osmux(allow_osmux);
1061 }
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02001062
Neels Hofmeyra460f1f2020-08-09 20:17:03 +00001063 var my_BooleanList allow_attach := { false, false, false };
Daniel Willmannebdecc02020-08-12 15:30:17 +02001064 f_init_statsd("VirtMSC", vc_STATSD, mp_test_ip, mp_bsc_statsd_port);
1065
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001066 for (bssap_idx := 0; bssap_idx < nr_msc; bssap_idx := bssap_idx+1) {
Neels Hofmeyra460f1f2020-08-09 20:17:03 +00001067 allow_attach[bssap_idx] := true;
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001068 /* Call a function of our 'parent component' RAN_Adapter_CT to start the
1069 * MSC-side BSSAP emulation */
1070 if (handler_mode) {
1071 var RanOps ranops := MSC_RanOps;
1072 ranops.use_osmux := g_osmux_enabled;
1073 f_ran_adapter_init(g_bssap[bssap_idx], mp_bssap_cfg[bssap_idx], "VirtMSC", ranops);
1074 connect(self:SCCPLITE_IPA_CTRL, g_bssap[bssap_idx].vc_RAN:CTRL_CLIENT);
1075 f_ran_adapter_start(g_bssap[bssap_idx]);
1076 } else {
1077 f_ran_adapter_init(g_bssap[bssap_idx], mp_bssap_cfg[bssap_idx], "VirtMSC", omit);
1078 connect(self:BSSAP, g_bssap[bssap_idx].vc_SCCP:SCCP_SP_PORT);
1079 f_ran_adapter_start(g_bssap[bssap_idx]);
1080 f_legacy_bssap_reset();
1081 }
Harald Welte67089ee2018-01-17 22:19:03 +01001082 }
Harald Welted5833a82018-05-27 16:52:56 +02001083
Harald Welte47cd0e32020-08-21 12:39:11 +02001084 if (handler_mode) {
1085 f_bssap_le_adapter_init(g_bssap_le, mp_bssap_le_cfg, "VirtSMLC", SMLC_BssapLeOps);
1086 } else {
1087 f_bssap_le_adapter_init(g_bssap_le, mp_bssap_le_cfg, "VirtSMLC", omit);
1088 connect(self:BSSAP_LE, g_bssap_le.vc_SCCP:SCCP_SP_PORT);
1089 }
1090 f_bssap_le_adapter_start(g_bssap_le);
1091
Neels Hofmeyra460f1f2020-08-09 20:17:03 +00001092 /* start the test with exactly all enabled MSCs allowed to attach */
1093 f_vty_msc_allow_attach(BSCVTY, allow_attach);
1094
Harald Welteffe55fc2018-01-17 22:39:54 +01001095 f_ipa_ctrl_start(mp_bsc_ip, mp_bsc_ctrl_port);
Harald Welte28d943e2017-11-25 15:00:50 +01001096
Daniel Willmann191e0d92018-01-17 12:44:35 +01001097 f_init_mgcp("VirtMSC");
1098
Neels Hofmeyr0b7365b2020-07-04 00:52:34 +02001099 for (var integer i := 0; i < nr_bts; i := i+1) {
1100 f_init_bts(i, handler_mode);
Harald Welte696ddb62017-12-08 14:01:43 +01001101 }
Neels Hofmeyr0b7365b2020-07-04 00:52:34 +02001102}
Harald Welte696ddb62017-12-08 14:01:43 +01001103
Neels Hofmeyr0b7365b2020-07-04 00:52:34 +02001104function f_init_bts(integer bts_idx := 0, boolean handler_mode := false)
1105runs on test_CT {
1106 /* wait until osmo-bts-omldummy has respawned */
1107 f_wait_oml(bts_idx, "degraded", 5.0);
1108
1109 /* start RSL connection */
1110 f_ipa_rsl_start(bts[bts_idx].rsl, mp_bsc_ip, mp_bsc_rsl_port, bts_idx, handler_mode);
1111 /* wait until BSC tells us "connected" */
1112 f_wait_oml(bts_idx, "connected", 5.0);
Harald Welte28d943e2017-11-25 15:00:50 +01001113}
1114
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +02001115function f_init_bts_and_check_sysinfo(integer bts_idx := 0, boolean handler_mode := false,
1116 template SystemInformationConfig expect_si)
1117runs on test_CT {
1118 var default sysinfo := activate(as_catch_RSL_sysinfo(bts_idx));
1119
1120 f_init_bts(bts_idx, handler_mode);
1121
1122 /* Give some time to (hopefully/most likely) collect all system informations from RSL startup.
1123 * We could stop as soon as all expected SI are received, but then we might miss SI that we don't expect and
1124 * that might be sent afterwards. So rather give a generous timeout and be quite sure to catch all SI.
1125 */
1126 f_sleep(5.0);
1127 log("RSL ", bts_idx, " SYSTEM INFORMATION: ", g_system_information[bts_idx]);
1128
1129 deactivate(sysinfo);
1130
1131 if (match(g_system_information[bts_idx], expect_si)) {
1132 setverdict(pass);
1133 } else {
1134 log("RSL ", bts_idx, ": EXPECTED SI: ", expect_si);
1135 log("RSL ", bts_idx, ": GOT SI: ", g_system_information[bts_idx]);
1136 setverdict(fail, "received SI does not match expectations");
1137 return;
1138 }
1139}
1140
Maxd4e56962018-10-31 19:08:25 +01001141/* expect to receive a RSL message matching a specified template on a given BTS / stream */
Harald Welte65e419a2020-08-21 12:38:33 +02001142function f_exp_ipa_rx(integer bts_nr, template (present) RSL_Message t_rx, float t_secs := 2.0, IpaStreamId sid := IPAC_PROTO_RSL_TRX0)
Harald Welteae026692017-12-09 01:03:01 +01001143runs on test_CT return RSL_Message {
1144 var ASP_RSL_Unitdata rx_rsl_ud;
1145 timer T := t_secs;
1146
1147 T.start;
1148 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001149 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(t_rx, sid)) -> value rx_rsl_ud {
Harald Welteae026692017-12-09 01:03:01 +01001150 T.stop;
1151 }
1152 [] IPA_RSL[bts_nr].receive { repeat; }
Harald Welteb2917702017-12-10 15:48:52 +01001153 [] T.timeout {
1154 setverdict(fail, "Timeout expecting ", t_rx);
Daniel Willmannafce8662018-07-06 23:11:32 +02001155 mtc.stop;
Harald Welteb2917702017-12-10 15:48:52 +01001156 }
Harald Welteae026692017-12-09 01:03:01 +01001157 }
1158 return rx_rsl_ud.rsl;
1159}
1160
Harald Welte21b46bd2017-12-17 19:46:32 +01001161/* helper function to transmit RSL on a given BTS/stream */
Harald Welte65e419a2020-08-21 12:38:33 +02001162function f_ipa_tx(integer bts_nr, template (value) RSL_Message t_tx, IpaStreamId sid := IPAC_PROTO_RSL_TRX0)
Harald Welteae026692017-12-09 01:03:01 +01001163runs on test_CT {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001164 IPA_RSL[bts_nr].send(ts_ASP_RSL_UD(t_tx, sid));
Harald Welteae026692017-12-09 01:03:01 +01001165}
1166
1167
Harald Welte4003d112017-12-09 22:35:39 +01001168/* verify we get a CHAN_ACT after CHAN RQD */
Harald Welteae026692017-12-09 01:03:01 +01001169testcase TC_chan_act_noreply() runs on test_CT {
1170 var BSSAP_N_UNITDATA_ind ud_ind;
Harald Welte930d0a72018-03-22 22:08:40 +01001171 var RSL_Message rsl_unused;
Harald Welte28d943e2017-11-25 15:00:50 +01001172
Harald Welte89d42e82017-12-17 16:42:41 +01001173 f_init(1);
Harald Welte28d943e2017-11-25 15:00:50 +01001174
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001175 IPA_RSL[0].send(ts_ASP_RSL_UD(ts_RSL_CHAN_RQD('23'O, 23)));
Harald Welte930d0a72018-03-22 22:08:40 +01001176 rsl_unused := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001177 f_shutdown_helper();
Harald Welte28d943e2017-11-25 15:00:50 +01001178}
1179
Harald Welte4003d112017-12-09 22:35:39 +01001180/* verify if the "chreq:total" counter increments as expected */
1181testcase TC_chan_act_counter() runs on test_CT {
1182 var BSSAP_N_UNITDATA_ind ud_ind;
1183 var integer chreq_total;
Harald Welte930d0a72018-03-22 22:08:40 +01001184 var RSL_Message rsl_unused;
Harald Welte4003d112017-12-09 22:35:39 +01001185
Harald Welte89d42e82017-12-17 16:42:41 +01001186 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +01001187
1188 chreq_total := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total");
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001189 IPA_RSL[0].send(ts_ASP_RSL_UD(ts_RSL_CHAN_RQD('23'O, 23)));
Harald Welte930d0a72018-03-22 22:08:40 +01001190 rsl_unused := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
Harald Welte4003d112017-12-09 22:35:39 +01001191 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total", chreq_total+1);
1192
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001193 f_shutdown_helper();
Harald Welte4003d112017-12-09 22:35:39 +01001194}
1195
Harald Welteae026692017-12-09 01:03:01 +01001196/* CHAN RQD -> CHAN ACT -> CHAN ACT ACK -> RF CHAN REL */
Philipp Maier9c60a622020-07-09 15:08:46 +02001197private function f_TC_chan_act_ack_noest(OCT1 ra := '23'O) runs on test_CT {
Harald Welteae026692017-12-09 01:03:01 +01001198 var RSL_Message rx_rsl;
1199
Harald Welteae026692017-12-09 01:03:01 +01001200 /* Send CHAN RQD and wait for allocation; acknowledge it */
Philipp Maier9c60a622020-07-09 15:08:46 +02001201 var RslChannelNr chan_nr := f_chreq_act_ack(ra);
Harald Welteae026692017-12-09 01:03:01 +01001202
1203 /* expect BSC to disable the channel again if there's no RLL EST IND */
1204 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), T3101_MAX);
1205
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001206 f_shutdown_helper();
Harald Welteae026692017-12-09 01:03:01 +01001207}
1208
Philipp Maier9c60a622020-07-09 15:08:46 +02001209/* Normal variant */
1210testcase TC_chan_act_ack_noest() runs on test_CT {
Philipp Maieraf58db22020-08-12 17:24:40 +02001211 f_init(1);
Philipp Maier9c60a622020-07-09 15:08:46 +02001212 f_TC_chan_act_ack_noest();
1213}
1214
1215/* Emergency call variant */
1216testcase TC_chan_act_ack_noest_emerg() runs on test_CT {
1217 /* See also: 3GPP TS 04.08, Table 9.9, ra=101xxxxx */
Philipp Maieraf58db22020-08-12 17:24:40 +02001218 f_init(1);
1219 f_vty_allow_emerg_bts(true, 0);
Philipp Maier9c60a622020-07-09 15:08:46 +02001220 f_TC_chan_act_ack_noest(ra := 'A5'O);
1221}
1222
Philipp Maier606f07d2020-08-12 17:21:58 +02001223/* Emergency call variant, but emergency calls are not allowed */
1224testcase TC_chan_rqd_emerg_deny() runs on test_CT {
1225 /* See also: 3GPP TS 04.08, Table 9.9, ra=101xxxxx */
1226
1227 var RSL_Message rx_rsl;
1228 var GsmRrMessage rr;
1229
1230 f_init(1);
1231 f_vty_allow_emerg_bts(false, 0);
1232
1233 IPA_RSL[0].clear;
1234 f_ipa_tx(0, ts_RSL_CHAN_RQD('A5'O, 23));
1235
1236 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeC(RSL_MT_IMMEDIATE_ASSIGN_CMD));
1237 rr := dec_GsmRrMessage(rx_rsl.ies[1].body.full_imm_ass_info.payload);
1238 if (rr.header.message_type == IMMEDIATE_ASSIGNMENT_REJECT) {
1239 setverdict(pass);
1240 } else {
1241 setverdict(fail, "immediate assignment not rejected");
1242 }
1243}
1244
Harald Welteae026692017-12-09 01:03:01 +01001245/* Test behavior if MSC never answers to CR */
1246testcase TC_chan_act_ack_est_ind_noreply() runs on test_CT {
Harald Weltef77aef62018-01-28 15:35:42 +01001247 var RslLinkId main_dcch := valueof(ts_RslLinkID_DCCH(0));
1248 var IpaStreamId sid := IPAC_PROTO_RSL_TRX0;
Harald Welteae026692017-12-09 01:03:01 +01001249 var RSL_Message rx_rsl;
Harald Weltef77aef62018-01-28 15:35:42 +01001250 var ASP_RSL_Unitdata rx_rsl_ud;
Harald Welteae026692017-12-09 01:03:01 +01001251
Harald Welte89d42e82017-12-17 16:42:41 +01001252 f_init(1);
Harald Welteae026692017-12-09 01:03:01 +01001253
1254 /* Send CHAN RQD and wait for allocation; acknowledge it */
Harald Welted6939652017-12-13 21:02:46 +01001255 var RslChannelNr chan_nr := f_chreq_act_ack();
Harald Welteae026692017-12-09 01:03:01 +01001256
1257 var octetstring l3 := '00010203040506'O
1258 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
1259
1260 BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3)));
1261
1262 /* expect BSC to disable the channel again if there's no response from MSC */
Harald Weltef77aef62018-01-28 15:35:42 +01001263 /* MS waits 20s (T3210) at LU; 10s (T3230) at CM SERV REQ and 5s (T3220) AT detach */
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001264 f_expect_chan_rel(0, chan_nr, expect_rll_rel_req := false);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001265 f_shutdown_helper();
Harald Welteae026692017-12-09 01:03:01 +01001266}
1267
1268/* Test behavior if MSC answers with CREF to CR */
1269testcase TC_chan_act_ack_est_ind_refused() runs on test_CT {
1270 var BSSAP_N_CONNECT_ind rx_c_ind;
1271 var RSL_Message rx_rsl;
1272
Harald Welte89d42e82017-12-17 16:42:41 +01001273 f_init(1);
Harald Welteae026692017-12-09 01:03:01 +01001274
1275 /* Send CHAN RQD and wait for allocation; acknowledge it */
Harald Welted6939652017-12-13 21:02:46 +01001276 var RslChannelNr chan_nr := f_chreq_act_ack();
Harald Welteae026692017-12-09 01:03:01 +01001277
1278 var octetstring l3 := '00010203040506'O
1279 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
1280
1281 BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) -> value rx_c_ind;
1282 BSSAP.send(ts_BSSAP_DISC_req(rx_c_ind.connectionId, 0));
1283
1284 /* expect BSC to disable the channel */
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001285 f_expect_chan_rel(0, chan_nr, expect_rll_rel_req := false);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001286 f_shutdown_helper();
Harald Welteae026692017-12-09 01:03:01 +01001287}
1288
Harald Welte618ef642017-12-14 14:58:20 +01001289/* CHAN RQD -> CHAN ACT -> CHAN ACT NACK -> RF CHAN REL */
1290testcase TC_chan_act_nack() runs on test_CT {
1291 var RSL_Message rx_rsl;
1292 var integer chact_nack;
1293
Harald Welte89d42e82017-12-17 16:42:41 +01001294 f_init(1);
Harald Welte618ef642017-12-14 14:58:20 +01001295
1296 chact_nack := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chan_act:nack");
1297
1298 f_ipa_tx(0, ts_RSL_CHAN_RQD('33'O, 33));
1299 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
1300 var RslChannelNr chan_nr := rx_rsl.ies[0].body.chan_nr;
1301
1302 f_ipa_tx(0, ts_RSL_CHAN_ACT_NACK(chan_nr, RSL_ERR_EQUIPMENT_FAIL));
1303
1304 /* wait for some time to hope the NACK arrives before the CTRL GET below */
1305 f_sleep(0.5);
1306
1307 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chan_act:nack", chact_nack+1);
1308
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001309 f_shutdown_helper();
Harald Welte618ef642017-12-14 14:58:20 +01001310}
1311
Harald Welte799c97b2017-12-14 17:50:30 +01001312/* Test for channel exhaustion due to RACH overload */
1313testcase TC_chan_exhaustion() runs on test_CT {
1314 var ASP_RSL_Unitdata rsl_ud;
1315 var integer i;
1316 var integer chreq_total, chreq_nochan;
1317
Harald Welte89d42e82017-12-17 16:42:41 +01001318 f_init(1);
Harald Welte799c97b2017-12-14 17:50:30 +01001319
1320 chreq_total := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total");
1321 chreq_nochan := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:no_channel");
1322
Pau Espin Pedrolfe200d72018-12-10 12:41:04 +01001323 /* GSM 04.08 Table 9.9a:
1324 * RA = '33'O -> Establishment cause = 0011xxxx (MS dual rate capable and asks for "TCH/H or TCH/F").
1325 * With current setup, expect 4xSDCCH + 4xTCH/F + 1xTCH/H to succeed */
Philipp Maiercb6cc482018-03-26 13:08:00 +02001326 for (i := 0; i < NUM_TCHF_PER_BTS + NUM_TCHH_PER_BTS + NUM_SDCCH_PER_BTS; i := i+1) {
Pau Espin Pedrolfe200d72018-12-10 12:41:04 +01001327 var RslChannelNr chan_nr := f_chreq_act_ack('33'O, i);
Harald Welte799c97b2017-12-14 17:50:30 +01001328 }
1329
1330 IPA_RSL[0].clear;
1331
Harald Weltedd8cbf32018-01-28 12:07:52 +01001332 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total",
Philipp Maiercb6cc482018-03-26 13:08:00 +02001333 chreq_total + NUM_TCHF_PER_BTS + NUM_TCHH_PER_BTS + NUM_SDCCH_PER_BTS);
Harald Welte799c97b2017-12-14 17:50:30 +01001334
1335 /* now expect additional channel activations to fail */
1336 f_ipa_tx(0, ts_RSL_CHAN_RQD('42'O, 42));
1337
1338 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001339 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV))) {
Harald Welte799c97b2017-12-14 17:50:30 +01001340 setverdict(fail, "Received CHAN ACT ACK without resources?!?");
1341 }
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001342 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_IMM_ASSIGN(?))) -> value rsl_ud {
Harald Welte799c97b2017-12-14 17:50:30 +01001343 var GsmRrMessage rr;
1344 /* match on IMM ASS REJ */
1345 rr := dec_GsmRrMessage(rsl_ud.rsl.ies[1].body.full_imm_ass_info.payload);
1346 if (rr.header.message_type == IMMEDIATE_ASSIGNMENT_REJECT) {
1347 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total",
Philipp Maiercb6cc482018-03-26 13:08:00 +02001348 chreq_total + NUM_TCHF_PER_BTS + NUM_TCHH_PER_BTS + NUM_SDCCH_PER_BTS+1);
Harald Welte799c97b2017-12-14 17:50:30 +01001349 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:no_channel",
1350 chreq_nochan+1);
1351 setverdict(pass);
1352 } else {
1353 repeat;
1354 }
1355 }
1356 [] IPA_RSL[0].receive { repeat; }
1357 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001358 f_shutdown_helper();
Harald Welte799c97b2017-12-14 17:50:30 +01001359}
1360
Vadim Yanitskiy1ff1fdf2018-11-27 01:32:57 +07001361/* Test channel deactivation due to silence from MS */
1362testcase TC_chan_deact_silence() runs on test_CT {
1363 var RslChannelNr chan_nr;
1364
1365 f_init(1);
1366
1367 /* Request for a dedicated channel */
1368 chan_nr := f_chreq_act_ack('23'O);
1369
1370 /* Wait some time until the channel is released */
1371 f_sleep(2.0);
1372
1373 /* Expect CHANnel RELease */
1374 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001375 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL))) {
Vadim Yanitskiy1ff1fdf2018-11-27 01:32:57 +07001376 log("Received CHANnel RELease");
1377 setverdict(pass);
1378 }
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001379 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_IMM_ASSIGN(?))) {
Vadim Yanitskiy1ff1fdf2018-11-27 01:32:57 +07001380 /* See OS#3709, OsmoBSC should not send Immediate
1381 * Assignment Reject since a dedicated channel was
1382 * already allocated, and Immediate Assignment was
1383 * already sent. */
1384 setverdict(fail, "Unexpected Immediate Assignment!");
1385 }
1386 [] IPA_RSL[0].receive {
1387 setverdict(fail, "Unexpected RSL message!");
1388 }
1389 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001390 f_shutdown_helper();
Vadim Yanitskiy1ff1fdf2018-11-27 01:32:57 +07001391}
1392
Harald Weltecfe2c962017-12-15 12:09:32 +01001393/***********************************************************************
1394 * Assignment Testing
1395 ***********************************************************************/
1396
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02001397/* Verify that the BSC refuses any BSSAP connection from the MSC (They are all BSC->MSC direction,
1398 * except for the inter-BSC handover, MT side) */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001399testcase TC_outbound_connect(integer bssap_idx := 0) runs on test_CT {
Harald Welte89d42e82017-12-17 16:42:41 +01001400 f_init(1);
Harald Weltecfe2c962017-12-15 12:09:32 +01001401
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001402 BSSAP.send(ts_BSSAP_CONNECT_req(g_bssap[bssap_idx].sccp_addr_peer, g_bssap[bssap_idx].sccp_addr_own,
1403 2342, ts_BSSMAP_AssignmentReq));
Harald Weltecfe2c962017-12-15 12:09:32 +01001404 BSSAP.receive(tr_BSSAP_DISC_ind(2342, ?, ?));
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001405 f_shutdown_helper();
Harald Weltecfe2c962017-12-15 12:09:32 +01001406}
1407
Harald Welte16a4adf2017-12-14 18:54:01 +01001408/* Test behavior if MSC answers with CREF to CR */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001409testcase TC_assignment_cic_only(integer bssap_idx := 0) runs on test_CT {
Harald Welte16a4adf2017-12-14 18:54:01 +01001410 var BSSAP_N_CONNECT_ind rx_c_ind;
1411 var RSL_Message rx_rsl;
1412 var DchanTuple dt;
1413
Harald Welte89d42e82017-12-17 16:42:41 +01001414 f_init(1);
Harald Welte16a4adf2017-12-14 18:54:01 +01001415
1416 dt := f_est_dchan('23'O, 23, '00000000'O);
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001417 if (mp_bssap_cfg[bssap_idx].transport == BSSAP_TRANSPORT_AoIP) {
Harald Welte17b27da2018-05-25 20:33:53 +02001418 /* send assignment without AoIP IEs */
1419 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_AssignmentReq(ts_BSSMAP_IE_CIC(0, 1))));
1420 } else {
1421 /* Send assignmetn without CIC in IPA case */
1422 var BSSMAP_IE_AoIP_TransportLayerAddress tla :=
1423 valueof(ts_BSSMAP_IE_AoIP_TLA4('01020304'O, 2342));
1424 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_AssignmentReq(omit, tla)));
1425 }
Harald Welte16a4adf2017-12-14 18:54:01 +01001426 alt {
1427 [] BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_AssignmentComplete)) {
1428 setverdict(fail, "AoIP BSC cannot accept ASSIGNMENT without AoIP Transport IE");
1429 }
Harald Welte235ebf12017-12-15 14:18:16 +01001430 /* TODO: Actually expect GSM0808_CAUSE_REQ_A_IF_TYPE_NOT_SUPP */
Harald Welte16a4adf2017-12-14 18:54:01 +01001431 [] BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_AssignmentFail)) {
1432 setverdict(pass);
1433 }
1434 [] BSSAP.receive { repeat; }
1435 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001436 f_shutdown_helper();
Harald Welte16a4adf2017-12-14 18:54:01 +01001437}
1438
Harald Welteed848512018-05-24 22:27:58 +02001439/* generate an assignment request for either AoIP or SCCPlite */
Pau Espin Pedrol07866632020-09-03 19:10:55 +02001440function f_gen_ass_req(boolean osmux_enabled := false, integer bssap_idx := 0, charstring aoip_tla := "1.2.3.4") return PDU_BSSAP {
Harald Welteed848512018-05-24 22:27:58 +02001441 var PDU_BSSAP ass_cmd;
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02001442 var BSSMAP_IE_Osmo_OsmuxCID osmux_cid := valueof(ts_OsmuxCID(0));
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001443 if (mp_bssap_cfg[bssap_idx].transport == BSSAP_TRANSPORT_AoIP) {
Harald Welteed848512018-05-24 22:27:58 +02001444 var BSSMAP_IE_AoIP_TransportLayerAddress tla :=
Pau Espin Pedrol07866632020-09-03 19:10:55 +02001445 valueof(f_ts_BSSMAP_IE_AoIP_TLA(aoip_tla, 2342));
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02001446 if (osmux_enabled) {
1447 ass_cmd := valueof(ts_BSSMAP_AssignmentReq(omit, tla, osmux_cid));
1448 } else {
1449 ass_cmd := valueof(ts_BSSMAP_AssignmentReq(omit, tla));
1450 }
Harald Welteed848512018-05-24 22:27:58 +02001451 } else {
1452 var BSSMAP_IE_CircuitIdentityCode cic := valueof(ts_BSSMAP_IE_CIC(0,1));
Pau Espin Pedrol096d73d2019-06-06 12:49:17 +02001453 ass_cmd := valueof(ts_BSSMAP_AssignmentReq(cic, omit));
Harald Welteed848512018-05-24 22:27:58 +02001454 }
1455 return ass_cmd;
1456}
1457
Pau Espin Pedrol07866632020-09-03 19:10:55 +02001458function f_gen_handover_req(integer bssap_idx := 0, charstring aoip_tla := "1.2.3.4") return PDU_BSSAP {
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01001459 var PDU_BSSAP ho_req;
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001460 if (mp_bssap_cfg[bssap_idx].transport == BSSAP_TRANSPORT_AoIP) {
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01001461 var BSSMAP_IE_AoIP_TransportLayerAddress tla :=
Pau Espin Pedrol07866632020-09-03 19:10:55 +02001462 valueof(f_ts_BSSMAP_IE_AoIP_TLA(aoip_tla, 2342));
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01001463 ho_req := valueof(ts_BSSMAP_HandoverRequest(omit, tla));
1464 } else {
1465 var BSSMAP_IE_CircuitIdentityCode cic := valueof(ts_BSSMAP_IE_CIC(0,1));
1466 ho_req := valueof(ts_BSSMAP_HandoverRequest(cic, omit));
1467 }
1468 return ho_req;
1469}
1470
Harald Welteed848512018-05-24 22:27:58 +02001471/* generate an assignment complete template for either AoIP or SCCPlite */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001472function f_gen_exp_compl(boolean expect_osmux := false, integer bssap_idx := 0) return template PDU_BSSAP {
Harald Welteed848512018-05-24 22:27:58 +02001473 var template PDU_BSSAP exp_compl;
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02001474 var BSSMAP_IE_Osmo_OsmuxCID osmux_cid := valueof(ts_OsmuxCID(0));
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001475 if (mp_bssap_cfg[bssap_idx].transport == BSSAP_TRANSPORT_AoIP) {
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02001476 if (expect_osmux) {
1477 exp_compl := tr_BSSMAP_AssignmentComplete(omit, ?, osmux_cid);
1478 } else {
1479 exp_compl := tr_BSSMAP_AssignmentComplete(omit, ?, omit);
1480 }
Harald Welteed848512018-05-24 22:27:58 +02001481 } else {
1482 /* CIC is optional "*" as the MSC allocated it */
Pau Espin Pedrol096d73d2019-06-06 12:49:17 +02001483 exp_compl := tr_BSSMAP_AssignmentComplete(*, omit);
Harald Welteed848512018-05-24 22:27:58 +02001484 }
1485 return exp_compl;
1486}
1487
Harald Welte235ebf12017-12-15 14:18:16 +01001488/* Run everything required up to sending a caller-specified assignment command and expect response */
1489function f_assignment_exp(PDU_BSSAP ass_cmd, template PDU_BSSAP exp, charstring fail_text)
1490runs on test_CT {
1491 var BSSAP_N_CONNECT_ind rx_c_ind;
1492 var RSL_Message rx_rsl;
1493 var DchanTuple dt;
1494
Harald Welte89d42e82017-12-17 16:42:41 +01001495 f_init(1);
Harald Welte235ebf12017-12-15 14:18:16 +01001496
1497 dt := f_est_dchan('23'O, 23, '00000000'O);
1498 /* send assignment without AoIP IEs */
1499 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ass_cmd));
1500 alt {
1501 [] BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_AssignmentComplete)) {
1502 if (ischosen(exp.pdu.bssmap.assignmentComplete)) {
1503 setverdict(pass);
1504 } else {
1505 setverdict(fail, fail_text);
1506 }
1507 }
1508 [] BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_AssignmentFail)) {
1509 if (ischosen(exp.pdu.bssmap.assignmentFailure)) {
1510 setverdict(pass);
1511 } else {
1512 setverdict(fail, fail_text);
1513 }
1514 }
1515 [] BSSAP.receive { repeat; }
1516 }
1517}
1518testcase TC_assignment_csd() runs on test_CT {
1519 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
Harald Welteed848512018-05-24 22:27:58 +02001520 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte235ebf12017-12-15 14:18:16 +01001521 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeCSD);
1522 //exp_fail.pdu.bssmap.assignmentFailure.cause.causeValue := int2bit(enum2int(GSM0808_CAUSE_REQ_CODEC_TYPE_OR_CONFIG_UNAVAIL), 7);
1523 f_assignment_exp(ass_cmd, exp_fail, "BSC accepted Assignment for CSD");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001524 f_shutdown_helper();
Harald Welte235ebf12017-12-15 14:18:16 +01001525}
1526
1527testcase TC_assignment_ctm() runs on test_CT {
1528 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
Harald Welteed848512018-05-24 22:27:58 +02001529 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte235ebf12017-12-15 14:18:16 +01001530 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeCTM);
1531 //exp_fail.pdu.bssmap.assignmentFailure.cause.causeValue := int2bit(enum2int(GSM0808_CAUSE_REQ_CODEC_TYPE_OR_CONFIG_UNAVAIL), 7);
1532 f_assignment_exp(ass_cmd, exp_fail, "BSC accepted Assignment for Speech+CTM");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001533 f_shutdown_helper();
Harald Welte235ebf12017-12-15 14:18:16 +01001534}
1535
Harald Welte4003d112017-12-09 22:35:39 +01001536type record DchanTuple {
1537 integer sccp_conn_id,
1538 RslChannelNr rsl_chan_nr
Harald Weltea5d2ab22017-12-09 14:21:42 +01001539}
1540
Harald Welted6939652017-12-13 21:02:46 +01001541/* Send CHAN RQD and wait for allocation; acknowledge it */
1542private function f_chreq_act_ack(OCT1 ra := '23'O, GsmFrameNumber fn := 23)
1543runs on test_CT return RslChannelNr {
1544 var RSL_Message rx_rsl;
1545 f_ipa_tx(0, ts_RSL_CHAN_RQD(ra, fn));
1546 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
1547 var RslChannelNr chan_nr := rx_rsl.ies[0].body.chan_nr;
1548 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, fn+10));
Daniel Willmannf4ac4ce2018-08-02 14:06:30 +02001549 rx_rsl := f_exp_ipa_rx(0, tr_RSL_IMM_ASSIGN(0));
Harald Welted6939652017-12-13 21:02:46 +01001550 return chan_nr;
1551}
1552
Harald Welte4003d112017-12-09 22:35:39 +01001553/* helper function to establish a dedicated channel via BTS and MSC */
1554function f_est_dchan(OCT1 ra, GsmFrameNumber fn, octetstring l3)
1555runs on test_CT return DchanTuple {
1556 var BSSAP_N_CONNECT_ind rx_c_ind;
Harald Welte4003d112017-12-09 22:35:39 +01001557 var DchanTuple dt;
Harald Weltea5d2ab22017-12-09 14:21:42 +01001558
Harald Welte4003d112017-12-09 22:35:39 +01001559 /* Send CHAN RQD and wait for allocation; acknowledge it */
Harald Welted6939652017-12-13 21:02:46 +01001560 dt.rsl_chan_nr := f_chreq_act_ack(ra, fn);
Harald Welte4003d112017-12-09 22:35:39 +01001561
1562 f_ipa_tx(0, ts_RSL_EST_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
1563
1564 BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) -> value rx_c_ind;
1565 dt.sccp_conn_id := rx_c_ind.connectionId;
1566 BSSAP.send(ts_BSSAP_CONNECT_res(dt.sccp_conn_id));
1567
1568 return dt;
Harald Weltea5d2ab22017-12-09 14:21:42 +01001569}
1570
Harald Welte641fcbe2018-06-14 10:58:35 +02001571/* expect RF CAN REL from BTS, acknowledge it and clear the MSC side */
1572private function f_exp_chan_rel_and_clear(DchanTuple dt, integer bts_nr := 0) runs on test_CT {
1573 var RSL_Message rx_rsl;
1574 /* expect BSC to disable the channel */
1575 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), T3101_MAX);
1576 /* respond with CHAN REL ACK */
1577 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(dt.rsl_chan_nr));
1578
1579 /* expect Clear Complete from BSC */
1580 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete));
1581
1582 /* MSC disconnects as instructed. */
1583 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
1584}
1585
Harald Welte4003d112017-12-09 22:35:39 +01001586/* Test behavior of channel release after unilateral RLL REL IND (DISC from MS) */
1587testcase TC_chan_rel_rll_rel_ind() runs on test_CT {
Neels Hofmeyr27f64362018-03-12 01:44:00 +01001588 var BSSAP_N_DATA_ind rx_di;
Harald Welte4003d112017-12-09 22:35:39 +01001589 var DchanTuple dt;
Harald Welte96c94412017-12-09 03:12:45 +01001590
Harald Welte89d42e82017-12-17 16:42:41 +01001591 f_init(1);
Harald Welte96c94412017-12-09 03:12:45 +01001592
Harald Welte4003d112017-12-09 22:35:39 +01001593 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1594
1595 /* simulate RLL REL IND */
1596 f_ipa_tx(0, ts_RSL_REL_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0))));
1597
Neels Hofmeyr27f64362018-03-12 01:44:00 +01001598 /* expect Clear Request on MSC side */
1599 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearRequest)) -> value rx_di;
1600
1601 /* Instruct BSC to clear channel */
1602 var BssmapCause cause := bit2int(rx_di.userData.pdu.bssmap.clearRequest.cause.causeValue);
1603 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
1604
Harald Welte4003d112017-12-09 22:35:39 +01001605 /* expect BSC to disable the channel */
Harald Welte641fcbe2018-06-14 10:58:35 +02001606 f_exp_chan_rel_and_clear(dt, 0);
Neels Hofmeyr27f64362018-03-12 01:44:00 +01001607
1608 /* wait for SCCP emulation to do its job */
1609 f_sleep(1.0);
Harald Welte4003d112017-12-09 22:35:39 +01001610
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001611 f_shutdown_helper();
Harald Welte4003d112017-12-09 22:35:39 +01001612}
1613
1614/* Test behavior of channel release after CONN FAIL IND from BTS */
1615testcase TC_chan_rel_conn_fail() runs on test_CT {
1616 var BSSAP_N_DATA_ind rx_di;
Harald Welte4003d112017-12-09 22:35:39 +01001617 var DchanTuple dt;
1618
Harald Welte89d42e82017-12-17 16:42:41 +01001619 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +01001620
1621 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1622
1623 /* simulate CONN FAIL IND */
Harald Weltea8ed9062017-12-14 09:46:01 +01001624 f_ipa_tx(0, ts_RSL_CONN_FAIL_IND(dt.rsl_chan_nr, RSL_ERR_RADIO_LINK_FAIL));
Harald Welte4003d112017-12-09 22:35:39 +01001625 /* TODO: different cause values? */
1626
Harald Welte4003d112017-12-09 22:35:39 +01001627 /* expect Clear Request from BSC */
1628 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearRequest)) -> value rx_di;
1629
1630 /* Instruct BSC to clear channel */
1631 var BssmapCause cause := bit2int(rx_di.userData.pdu.bssmap.clearRequest.cause.causeValue);
1632 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
1633
Harald Welte6ff76ea2018-01-28 13:08:01 +01001634 /* expect BSC to disable the channel */
Harald Welte641fcbe2018-06-14 10:58:35 +02001635 f_exp_chan_rel_and_clear(dt, 0);
Harald Welte4003d112017-12-09 22:35:39 +01001636
1637 /* wait for SCCP emulation to do its job */
1638 f_sleep(1.0);
1639
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001640 f_shutdown_helper();
Harald Welte4003d112017-12-09 22:35:39 +01001641}
1642
Harald Welte99f3ca02018-06-14 13:40:29 +02001643/* Test behavior of early CONN FAIL IND from BTS (before EST IND!) */
1644/* See also https://www.osmocom.org/issues/3182 */
1645testcase TC_early_conn_fail() runs on test_CT {
1646 var RSL_Message rx_rsl;
1647 var DchanTuple dt;
1648
1649 f_init(1);
1650
1651 /* BTS->BSC: Send CHAN RQD and wait for allocation; acknowledge it */
Harald Weltec46ea3c2020-10-10 18:46:12 +02001652 dt.rsl_chan_nr := f_chreq_act_ack(f_rnd_ra_cs(), 23);
Harald Welte99f3ca02018-06-14 13:40:29 +02001653
1654 /* BTS->BSC: simulate CONN FAIL IND */
1655 f_ipa_tx(0, ts_RSL_CONN_FAIL_IND(dt.rsl_chan_nr, RSL_ERR_RADIO_LINK_FAIL));
1656
1657 /* BTS->BSC: Expect RF channel release from BSC on Abis */
1658 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), 10.0);
1659
1660 /* BTS<-BSC: respond with CHAN REL ACK */
1661 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(dt.rsl_chan_nr));
1662
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001663 f_shutdown_helper();
Harald Welte99f3ca02018-06-14 13:40:29 +02001664}
1665
1666/* Test behavior of late CONN FAIL IND from BTS (ater REL IND!) */
1667/* See also https://www.osmocom.org/issues/3182 */
1668testcase TC_late_conn_fail() runs on test_CT {
1669 var RSL_Message rx_rsl;
1670 var DchanTuple dt;
1671
1672 f_init(1);
1673
1674 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1675
1676 /* BSC<-MSC: Instruct BSC to clear connection */
1677 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(0)));
1678
1679 /* BTS->BSC: expect BSC to deactivate SACCH */
1680 rx_rsl := f_exp_ipa_rx(0, tr_RSL_DEACT_SACCH(dt.rsl_chan_nr));
1681
1682 /* BTS->BSC: simulate a late CONN FAIL IND from BTS */
1683 f_ipa_tx(0, ts_RSL_CONN_FAIL_IND(dt.rsl_chan_nr, RSL_ERR_RADIO_LINK_FAIL));
1684
1685 /* BTS<-BSC: Expect RF channel release from BSC on Abis */
1686 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), 10.0);
1687 /* BTS->BSC: respond with CHAN REL ACK */
1688 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(dt.rsl_chan_nr));
1689
1690 /* BSC->MSC: expect Clear Complete from BSC */
1691 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete));
1692
1693 /* BSC<-MSC: MSC disconnects as requested. */
1694 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
1695
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001696 f_shutdown_helper();
Harald Welte99f3ca02018-06-14 13:40:29 +02001697}
1698
Neels Hofmeyrf44ccd12018-11-05 19:15:23 +01001699function f_expect_chan_rel(integer bts_nr, RslChannelNr rsl_chan_nr,
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001700 boolean expect_deact_sacch := true,
1701 boolean expect_rr_chan_rel := true,
1702 boolean expect_rll_rel_req := true,
Harald Welte99787102019-02-04 10:41:36 +01001703 boolean handle_rll_rel := true,
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02001704 boolean is_csfb := false,
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02001705 template CellSelIndValue csfb_expect_cells := omit,
1706 template RR_Cause expect_rr_cause := ?
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001707 ) runs on test_CT {
Harald Welte91d54a52018-01-28 15:35:07 +01001708
1709 var RslLinkId main_dcch := valueof(ts_RslLinkID_DCCH(0));
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001710 var boolean got_deact_sacch := false;
1711 var boolean got_rr_chan_rel := false;
1712 var boolean got_rll_rel_req := false;
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02001713 var ASP_RSL_Unitdata ud;
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02001714 var RSL_IE_Body l3_ie;
1715 var PDU_ML3_NW_MS l3;
1716 var RR_Cause got_cause;
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001717 log("f_expect_chan_rel() expecting: expect_deact_sacch=", expect_deact_sacch, " expect_rr_chan_rel=", expect_rr_chan_rel,
1718 " expect_rll_rel_req=", expect_rll_rel_req);
Harald Welte91d54a52018-01-28 15:35:07 +01001719 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001720 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(tr_RSL_DEACT_SACCH(rsl_chan_nr))) {
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001721 got_deact_sacch := true;
Harald Welte91d54a52018-01-28 15:35:07 +01001722 repeat;
1723 }
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02001724 [is_csfb] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(tr_RSL_DATA_REQ(rsl_chan_nr, ?, decmatch tr_RRM_RR_RELEASE_CSFB))) -> value ud {
Harald Welte99787102019-02-04 10:41:36 +01001725 got_rr_chan_rel := true;
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02001726
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02001727 if (f_rsl_find_ie(ud.rsl, RSL_IE_L3_INFO, l3_ie) == false) {
1728 setverdict(fail, "cannot find L3");
1729 mtc.stop;
1730 }
1731 l3 := dec_PDU_ML3_NW_MS(l3_ie.l3_info.payload);
1732
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02001733 if (not istemplatekind(csfb_expect_cells, "omit")) {
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02001734 var CellSelIndValue cells := dec_CellSelIndValue(
1735 l3.msgs.rrm.channelRelease.cellSelectionIndicator.cellSelectionIndicatorValue);
1736
1737 log("GOT RR CHANNEL RELEASE CSFB CELLS: ", cells);
1738 if (match(cells, csfb_expect_cells)) {
1739 setverdict(pass);
1740 } else {
1741 log("EXPECTED CSFB CELLS: ", csfb_expect_cells);
1742 setverdict(fail, "Received CSFB cells list on RR Channel Release does not match expectations");
1743 }
1744 }
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02001745
1746 if (not istemplatekind(expect_rr_cause, "omit")) {
1747 int2enum(oct2int(l3.msgs.rrm.channelRelease.rRCause.valuePart), got_cause);
1748 log("GOT CAUSE CODE: ", l3.msgs.rrm.channelRelease.rRCause.valuePart, " = ", got_cause);
1749 if (match(got_cause, expect_rr_cause)) {
1750 setverdict(pass);
1751 } else {
1752 log("EXPECTED CAUSE CODE: ", expect_rr_cause);
1753 setverdict(fail, "Received RR Channel Release Cause code does not match expectations");
1754 }
1755 }
Harald Welte99787102019-02-04 10:41:36 +01001756 repeat;
1757 }
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02001758 [not is_csfb] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(tr_RSL_DATA_REQ(rsl_chan_nr, ?, decmatch tr_RRM_RR_RELEASE))) -> value ud {
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001759 got_rr_chan_rel := true;
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02001760
1761 if (not istemplatekind(expect_rr_cause, "omit")) {
1762 if (f_rsl_find_ie(ud.rsl, RSL_IE_L3_INFO, l3_ie) == false) {
1763 setverdict(fail, "cannot find L3");
1764 mtc.stop;
1765 }
1766 l3 := dec_PDU_ML3_NW_MS(l3_ie.l3_info.payload);
1767
1768 int2enum(oct2int(l3.msgs.rrm.channelRelease.rRCause.valuePart), got_cause);
1769 log("GOT CAUSE CODE: ", l3.msgs.rrm.channelRelease.rRCause.valuePart, " = ", got_cause);
1770 if (match(got_cause, expect_rr_cause)) {
1771 setverdict(pass);
1772 } else {
1773 log("EXPECTED CAUSE CODE: ", expect_rr_cause);
1774 setverdict(fail, "Received RR Channel Release Cause code does not match expectations");
1775 }
1776 }
Neels Hofmeyr211169d2018-11-07 00:37:29 +01001777 repeat;
1778 }
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001779 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(tr_RSL_REL_REQ(rsl_chan_nr, ?))) {
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001780 got_rll_rel_req := true;
Harald Welte91d54a52018-01-28 15:35:07 +01001781 /* FIXME: Why are we getting this for LinkID SACCH? */
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001782 if (handle_rll_rel) {
1783 f_ipa_tx(0, ts_RSL_REL_CONF(rsl_chan_nr, main_dcch));
1784 }
Harald Welte91d54a52018-01-28 15:35:07 +01001785 repeat;
1786 }
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001787 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL))) {
Harald Welte91d54a52018-01-28 15:35:07 +01001788 /* respond with CHAN REL ACK */
1789 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(rsl_chan_nr));
1790 }
1791 /* ignore any user data */
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001792 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(tr_RSL_MsgTypeR(?))) {
Harald Welte91d54a52018-01-28 15:35:07 +01001793 repeat;
1794 }
1795 }
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001796
1797 log("f_expect_chan_rel() summary: got_deact_sacch=", got_deact_sacch, " got_rr_chan_rel=", got_rr_chan_rel,
1798 " got_rll_rel_req=", got_rll_rel_req);
1799
1800 if (expect_deact_sacch != got_deact_sacch) {
1801 setverdict(fail, "f_expect_chan_rel(): expect_deact_sacch=", expect_deact_sacch, " got_deact_sacch=", got_deact_sacch);
1802 }
1803 if (expect_rr_chan_rel != got_rr_chan_rel) {
1804 setverdict(fail, "f_expect_chan_rel(): expect_rr_chan_rel=", expect_rr_chan_rel, " got_rr_chan_rel=", got_rr_chan_rel);
1805 }
1806 if (expect_rll_rel_req != got_rll_rel_req) {
1807 setverdict(fail, "f_expect_chan_rel(): expect_rll_rel_req=", expect_rll_rel_req, " got_rll_rel_req=", got_rll_rel_req);
1808 }
Harald Welte91d54a52018-01-28 15:35:07 +01001809}
1810
Harald Welte4003d112017-12-09 22:35:39 +01001811/* Test behavior of channel release after hard Clear Command from MSC */
1812testcase TC_chan_rel_hard_clear() runs on test_CT {
1813 var BSSAP_N_DATA_ind rx_di;
Harald Welte4003d112017-12-09 22:35:39 +01001814 var DchanTuple dt;
Harald Welte4003d112017-12-09 22:35:39 +01001815
Harald Welte89d42e82017-12-17 16:42:41 +01001816 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +01001817
1818 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1819
1820 /* Instruct BSC to clear channel */
1821 var BssmapCause cause := 0;
1822 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
1823
1824 /* expect Clear Complete from BSC on A */
1825 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete)) {
1826 /* release the SCCP connection */
1827 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
1828 }
1829
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001830 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001831 f_shutdown_helper();
Harald Welte4003d112017-12-09 22:35:39 +01001832}
1833
Harald Welte99787102019-02-04 10:41:36 +01001834/* Test behavior of channel release after Clear Command with CSFB indicator from MSC */
1835testcase TC_chan_rel_hard_clear_csfb() runs on test_CT {
1836 var BSSAP_N_DATA_ind rx_di;
1837 var DchanTuple dt;
1838
1839 f_init(1);
1840
1841 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1842
1843 /* Instruct BSC to clear channel */
1844 var BssmapCause cause := 0;
1845 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommandCSFB(cause)));
1846
1847 /* expect Clear Complete from BSC on A */
1848 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete)) {
1849 /* release the SCCP connection */
1850 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
1851 }
1852
1853 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false, is_csfb := true);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001854 f_shutdown_helper();
Harald Welte99787102019-02-04 10:41:36 +01001855}
1856
Harald Welted8c36cd2017-12-09 23:05:31 +01001857/* Test behavior of channel release after hard RLSD from MSC */
1858testcase TC_chan_rel_hard_rlsd() runs on test_CT {
Harald Welted8c36cd2017-12-09 23:05:31 +01001859 var DchanTuple dt;
Harald Welted8c36cd2017-12-09 23:05:31 +01001860
Harald Welte89d42e82017-12-17 16:42:41 +01001861 f_init(1);
Harald Welted8c36cd2017-12-09 23:05:31 +01001862
1863 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1864
1865 /* release the SCCP connection */
1866 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
1867
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001868 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001869 f_shutdown_helper();
Harald Welted8c36cd2017-12-09 23:05:31 +01001870}
1871
Harald Welte550daf92018-06-11 19:22:13 +02001872/* Test behavior of channel release after hard RLSD from MSC and MS is not responding to RLL REL REQ */
1873testcase TC_chan_rel_hard_rlsd_ms_dead() runs on test_CT {
1874 var DchanTuple dt;
1875
1876 f_init(1);
1877
1878 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1879
1880 /* release the SCCP connection */
1881 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
1882
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001883 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001884 f_shutdown_helper();
Harald Welte550daf92018-06-11 19:22:13 +02001885}
1886
Harald Welte85804d42017-12-10 14:11:58 +01001887/* Test behavior of channel release after BSSMAP RESET from MSC */
1888testcase TC_chan_rel_a_reset() runs on test_CT {
Harald Welte85804d42017-12-10 14:11:58 +01001889 var DchanTuple dt;
Harald Welte85804d42017-12-10 14:11:58 +01001890
Harald Welte89d42e82017-12-17 16:42:41 +01001891 f_init(1);
Harald Welte85804d42017-12-10 14:11:58 +01001892
1893 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1894
1895 /* Clear the queue, it might still contain stuff like IMMEDIATE ASSIGN */
1896 IPA_RSL[0].clear;
1897
1898 /* perform BSSAP RESET, expect RESET ACK and DISC.ind on connection */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001899 BSSAP.send(ts_BSSAP_UNITDATA_req(g_bssap[0].sccp_addr_peer, g_bssap[0].sccp_addr_own, ts_BSSMAP_Reset(0, g_osmux_enabled)));
Harald Welte85804d42017-12-10 14:11:58 +01001900 interleave {
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001901 [] BSSAP.receive(tr_BSSAP_UNITDATA_ind(g_bssap[0].sccp_addr_own, g_bssap[0].sccp_addr_peer, tr_BSSMAP_ResetAck(g_osmux_enabled))) { }
Harald Welte85804d42017-12-10 14:11:58 +01001902 [] BSSAP.receive(tr_BSSAP_DISC_ind(dt.sccp_conn_id, ?, ?)) { }
1903 }
1904
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001905 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001906 f_shutdown_helper();
Harald Welte85804d42017-12-10 14:11:58 +01001907}
1908
Pau Espin Pedrolc675b612020-01-09 19:55:40 +01001909/* Verify T(iar) triggers and releases the channel */
1910testcase TC_chan_rel_sccp_tiar_timeout() runs on test_CT {
1911 var DchanTuple dt;
1912
1913 /* Set T(iar) in BSC low enough that it will trigger before other side
1914 has time to keep alive with a T(ias). Keep recommended ratio of
1915 T(iar) >= T(ias)*2 */
1916 g_bsc_sccp_timer_ias := 2;
1917 g_bsc_sccp_timer_iar := 5;
1918
1919 f_init(1);
1920
1921 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1922 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001923 f_shutdown_helper();
Pau Espin Pedrolc675b612020-01-09 19:55:40 +01001924}
1925
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02001926private function f_tc_chan_rel_rr_cause(myBSSMAP_Cause clear_cmd_cause, template RR_Cause expect_rr_cause)
1927runs on test_CT
1928{
1929 var DchanTuple dt;
1930
1931 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1932 var BssmapCause cause := 0;
1933 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(enum2int(clear_cmd_cause))));
1934 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete)) {
1935 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
1936 }
1937
1938 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false, expect_rr_cause := expect_rr_cause);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001939 f_shutdown_helper();
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02001940}
1941
1942/* Test that Clear Command cause codes affect the RR Channel Release cause code */
1943testcase TC_chan_rel_rr_cause() runs on test_CT {
1944 f_init(1);
1945
1946 f_tc_chan_rel_rr_cause(GSM0808_CAUSE_CALL_CONTROL, GSM48_RR_CAUSE_NORMAL);
1947 f_tc_chan_rel_rr_cause(GSM0808_CAUSE_HANDOVER_SUCCESSFUL, GSM48_RR_CAUSE_NORMAL);
1948 f_tc_chan_rel_rr_cause(GSM0808_CAUSE_PREEMPTION, GSM48_RR_CAUSE_PREMPTIVE_REL);
1949 f_tc_chan_rel_rr_cause(GSM0808_CAUSE_RADIO_INTERFACE_MESSAGE_FAILURE, GSM48_RR_CAUSE_PROT_ERROR_UNSPC);
1950 f_tc_chan_rel_rr_cause(GSM0808_CAUSE_RADIO_INTERFACE_FAILURE, GSM48_RR_CAUSE_ABNORMAL_UNSPEC);
1951 f_tc_chan_rel_rr_cause(GSM0808_CAUSE_EQUIPMENT_FAILURE, GSM48_RR_CAUSE_ABNORMAL_UNSPEC);
1952}
1953
Harald Welte5cd20ed2017-12-13 21:03:20 +01001954/* Test behavior if RSL EST IND for non-active channel */
1955testcase TC_rll_est_ind_inact_lchan() runs on test_CT {
1956 timer T := 2.0;
1957
Harald Welte89d42e82017-12-17 16:42:41 +01001958 f_init(1);
Harald Welte5cd20ed2017-12-13 21:03:20 +01001959
1960 var octetstring l3 := '00010203040506'O;
1961 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(6));
1962 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
1963
1964 T.start;
1965 alt {
1966 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) {
1967 setverdict(fail, "MSC received COMPL L3 for non-active lchan");
1968 }
1969 [] BSSAP.receive {}
1970 [] IPA_RSL[0].receive {}
1971 [] T.timeout {}
1972 }
1973
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001974 f_shutdown_helper();
Harald Welte5cd20ed2017-12-13 21:03:20 +01001975}
1976
1977/* Test behavior if RSL EST IND for invalid SAPI */
1978testcase TC_rll_est_ind_inval_sapi1() runs on test_CT {
1979 var RslChannelNr chan_nr;
1980
Harald Welte89d42e82017-12-17 16:42:41 +01001981 f_init(1);
Harald Welte5cd20ed2017-12-13 21:03:20 +01001982
1983 chan_nr := f_chreq_act_ack()
1984
1985 var octetstring l3 := '00010203040506'O;
1986 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(1)), l3));
1987
1988 timer T := 2.0;
1989 T.start;
1990 alt {
1991 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) {
1992 setverdict(fail, "MSC received COMPL L3 for invalid SAPI 1");
1993 }
1994 [] BSSAP.receive { repeat; }
1995 [] IPA_RSL[0].receive { repeat; }
1996 [] T.timeout {}
1997 }
1998
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001999 f_shutdown_helper();
Harald Welte5cd20ed2017-12-13 21:03:20 +01002000}
2001
2002/* Test behavior if RSL EST IND for invalid SAPI */
2003testcase TC_rll_est_ind_inval_sapi3() runs on test_CT {
2004 timer T := 2.0;
2005
Harald Welte89d42e82017-12-17 16:42:41 +01002006 f_init(1);
Harald Welte5cd20ed2017-12-13 21:03:20 +01002007
2008 var RslChannelNr chan_nr := f_chreq_act_ack();
2009
2010 var octetstring l3 := '00010203040506'O;
2011 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(3)), l3));
2012
2013 T.start;
2014 alt {
2015 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) {
2016 setverdict(fail, "MSC received COMPL L3 for invalid SAPI 3");
2017 }
2018 [] BSSAP.receive { repeat; }
2019 [] IPA_RSL[0].receive { repeat; }
2020 [] T.timeout {}
2021 }
2022
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002023 f_shutdown_helper();
Harald Welte5cd20ed2017-12-13 21:03:20 +01002024}
2025
2026/* Test behavior if RSL EST IND for invalid SACCH */
2027testcase TC_rll_est_ind_inval_sacch() runs on test_CT {
2028 timer T := 2.0;
2029
Harald Welte89d42e82017-12-17 16:42:41 +01002030 f_init(1);
Harald Welte5cd20ed2017-12-13 21:03:20 +01002031
2032 var RslChannelNr chan_nr := f_chreq_act_ack();
2033
2034 var octetstring l3 := '00010203040506'O;
2035 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_SACCH(0)), l3));
2036
2037 T.start;
2038 alt {
2039 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) {
2040 setverdict(fail, "MSC received COMPL L3 for invalid Link SACCH");
2041 }
2042 [] BSSAP.receive { repeat; }
2043 [] IPA_RSL[0].receive { repeat; }
2044 [] T.timeout {}
2045 }
2046
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002047 f_shutdown_helper();
Harald Welte5cd20ed2017-12-13 21:03:20 +01002048}
2049
Vadim Yanitskiy61f784a2020-10-01 21:12:19 +07002050/* Verify DLCI / RSL Link ID conversion for MO/MT messages on SAPI0/SAPI3 */
2051private function f_TC_tch_dlci_link_id_sapi(charstring id) runs on MSC_ConnHdlr {
2052 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
2053 var PDU_BSSAP ass_cmd := f_gen_ass_req();
2054
2055 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
2056 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
2057
2058 f_establish_fully(ass_cmd, exp_compl);
2059
2060 /* SAPI0 has already been established by f_establish_fully(), establish SAPI3 */
2061 RSL.send(ts_RSL_EST_IND(g_chan_nr, ts_RslLinkID_SACCH(3), '0904'O));
2062 /* Expect BSSAP/DTAP on SAPI3 (DLCI IE) */
2063 BSSAP.receive(PDU_BSSAP:{
2064 discriminator := '1'B,
2065 spare := '0000000'B,
2066 dlci := 'C3'O,
2067 lengthIndicator := ?,
2068 pdu := { dtap := '0904'O }
2069 });
2070
2071 /* Send messages on DCCH/SAPI0 and ACCH/SAPI3 */
2072 for (var integer i := 0; i < 32; i := i + 1) {
2073 var octetstring l3 := '09'O & f_rnd_octstring(14);
2074 var template (value) RslLinkId link_id;
2075 var template (value) OCT1 dlci;
2076
2077 if (i mod 2 == 0) {
2078 /* SAPI0 on FACCH or SDCCH */
2079 link_id := ts_RslLinkID_DCCH(0);
2080 dlci := '80'O;
2081 } else {
2082 /* SAPI3 on SACCH */
2083 link_id := ts_RslLinkID_SACCH(3);
2084 dlci := 'C3'O;
2085 }
2086
2087 /* Send MO message: RSL -> BSSAP */
2088 f_mo_l3_transceive(link_id, dlci, l3);
2089 /* Send MT message: BSSAP -> RSL */
2090 f_mt_l3_transceive(link_id, dlci, l3);
2091 }
2092}
2093testcase TC_tch_dlci_link_id_sapi() runs on test_CT {
2094 var TestHdlrParams pars := f_gen_test_hdlr_pars();
2095 var MSC_ConnHdlr vc_conn;
2096
2097 f_init(1, true);
2098 f_sleep(1.0);
2099
2100 vc_conn := f_start_handler(refers(f_TC_tch_dlci_link_id_sapi), pars);
2101 vc_conn.done;
2102
2103 f_shutdown_helper();
2104}
2105
Vadim Yanitskiy6ef5dfa2020-08-28 18:04:41 +07002106private function f_exp_sapi_n_reject(template (present) GsmSapi sapi := ?,
2107 template myBSSMAP_Cause cause := ?,
2108 float T_val := 2.0)
2109runs on test_CT {
2110 var BSSAP_N_DATA_ind rx_di;
2111 timer T;
2112
2113 var template BSSMAP_IE_Cause tr_cause := tr_BSSMAP_IE_Cause(cause);
2114 var template PDU_BSSAP tr_pdu := tr_BSSMAP_SAPInReject(sapi);
2115
2116 T.start(T_val);
2117 alt {
2118 [] BSSAP.receive(tr_BSSAP_DATA_ind(?, tr_pdu)) -> value rx_di {
2119 var BSSMAP_IE_Cause rx_cause := rx_di.userData.pdu.bssmap.sAPInReject.cause;
2120 if (not match(rx_cause, tr_cause)) {
2121 setverdict(fail, "Rx unexpected Cause IE: ",
2122 rx_cause, " vs expected ", tr_cause);
2123 }
2124 setverdict(pass);
2125 }
2126 [] BSSAP.receive(BSSAP_N_DATA_ind:?) -> value rx_di {
2127 setverdict(fail, "Rx unexpected BSSAP PDU: ", rx_di);
2128 }
2129 [] T.timeout {
2130 setverdict(fail, "Timeout waiting for BSSMAP SAPI N Reject");
2131 }
2132 }
2133}
2134
2135/* Check if we get SAPI N Reject on receipt of unexpected RLL RELease INDication */
2136testcase TC_rll_rel_ind_sapi_n_reject() runs on test_CT {
2137 var octetstring rnd_data := f_rnd_octstring(16);
2138 var RSL_Message rx_rsl;
2139 var DchanTuple dt;
2140
2141 f_init(1);
2142
2143 /* MS establishes a SAPI=0 link on DCCH */
2144 dt := f_est_dchan(f_rnd_ra_cs(), 23, rnd_data);
2145
2146 /* MSC sends some data on (not yet established) SAPI=3 link */
2147 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSAP_DTAP(rnd_data, '03'O)));
2148 /* BSC attempts to establish a SAPI=3 link on DCCH */
2149 rx_rsl := f_exp_ipa_rx(0, tr_RSL_EST_REQ(dt.rsl_chan_nr, tr_RslLinkID_DCCH(3)));
2150
2151 /* MS sends unexpected RELease INDication on SAPI=3 */
2152 f_ipa_tx(0, ts_RSL_REL_IND(dt.rsl_chan_nr, ts_RslLinkID_DCCH(3)));
2153 /* We expect to receive BSSMAP SAPI N Reject message from the BSC */
2154 f_exp_sapi_n_reject(3, GSM0808_CAUSE_MS_NOT_EQUIPPED);
2155
2156 /* Clean up the connection */
2157 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
2158 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
2159
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002160 f_shutdown_helper();
Vadim Yanitskiy6ef5dfa2020-08-28 18:04:41 +07002161}
2162
2163/* Check if we get SAPI N Reject on receipt of unexpected RLL ERROR INDication */
2164testcase TC_rll_err_ind_sapi_n_reject() runs on test_CT {
2165 var octetstring rnd_data := f_rnd_octstring(16);
2166 var RSL_Message rx_rsl;
2167 var DchanTuple dt;
2168
2169 f_init(1);
2170
2171 /* MS establishes a SAPI=0 link on DCCH */
2172 dt := f_est_dchan(f_rnd_ra_cs(), 23, rnd_data);
2173
2174 /* MSC sends some data on (not yet established) SAPI=3 link */
2175 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSAP_DTAP(rnd_data, '03'O)));
2176 /* BSC attempts to establish a SAPI=3 link on DCCH */
2177 rx_rsl := f_exp_ipa_rx(0, tr_RSL_EST_REQ(dt.rsl_chan_nr, tr_RslLinkID_DCCH(3)));
2178
2179 /* BTS sends unexpected ERROR INDication on SAPI=3 */
2180 f_ipa_tx(0, ts_RSL_ERROR_IND(dt.rsl_chan_nr, ts_RslLinkID_DCCH(3), ''O));
2181 /* We expect to receive BSSMAP SAPI N Reject message from the BSC */
2182 f_exp_sapi_n_reject(3, GSM0808_CAUSE_BSS_NOT_EQUIPPED);
2183
2184 /* Clean up the connection */
2185 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
2186 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
2187
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002188 f_shutdown_helper();
Vadim Yanitskiy6ef5dfa2020-08-28 18:04:41 +07002189}
2190
2191/* Check if we get SAPI N Reject due to a SAPI=3 link establishment timeout */
2192testcase TC_rll_timeout_sapi_n_reject() runs on test_CT {
2193 var octetstring rnd_data := f_rnd_octstring(16);
2194 var RSL_Message rx_rsl;
2195 var DchanTuple dt;
2196
2197 f_init(1);
2198
2199 /* MS establishes a SAPI=0 link on DCCH */
2200 dt := f_est_dchan(f_rnd_ra_cs(), 23, rnd_data);
2201
2202 /* MSC sends some data on (not yet established) SAPI=3 link */
2203 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSAP_DTAP(rnd_data, '03'O)));
2204 /* BSC attempts to establish a SAPI=3 link on DCCH */
2205 rx_rsl := f_exp_ipa_rx(0, tr_RSL_EST_REQ(dt.rsl_chan_nr, tr_RslLinkID_DCCH(3)));
2206
2207 /* MS does not respond, so the link establishment timeout triggers SAPI N Reject */
2208 f_exp_sapi_n_reject(3, GSM0808_CAUSE_BSS_NOT_EQUIPPED, T_val := 8.0);
2209
2210 /* Clean up the connection */
2211 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
2212 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
2213
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002214 f_shutdown_helper();
Vadim Yanitskiy6ef5dfa2020-08-28 18:04:41 +07002215}
2216
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +02002217testcase TC_si_default() runs on test_CT {
2218 f_init(0);
2219 f_init_bts_and_check_sysinfo(0, expect_si := SystemInformationConfig_default);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002220 f_shutdown_helper();
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +02002221}
Harald Welte4003d112017-12-09 22:35:39 +01002222
Neels Hofmeyr56f24782020-07-09 00:50:49 +02002223/* We're testing SI2quater with lists of EARFCNs. Instead of just incrementing EARFCNs, also pick some from the edges of
2224 * the entire value range. This function provides the same EARFCN numbers for the same earfcn_index */
2225private function f_test_si2quater_earfcn_by_idx(integer earfcn_index) return uint16_t
2226{
2227 select (earfcn_index) {
2228 case (0) {
2229 /* E-ARFCN 111 is already added in the osmo-bsc.cfg */
2230 return 111;
2231 }
2232 case (1) {
2233 return 1;
2234 }
2235 case (2) {
2236 return 0;
2237 }
2238 case (3) {
2239 return 65535;
2240 }
2241 case else {
2242 return 23 * (earfcn_index - 3);
2243 }
2244 }
2245}
2246
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02002247function f_test_si2quater(integer total_earfcns, template SystemInformationConfig expect_si,
2248 template CellSelIndValue expect_cells := omit) runs on test_CT {
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002249
2250 f_init(0);
2251
2252 /* E-ARFCN 111 is already added in the osmo-bsc.cfg, so only add more arfcns if total_earfcns > 1 */
2253 for (var integer i := 1; i < total_earfcns; i := i + 1) {
Neels Hofmeyr56f24782020-07-09 00:50:49 +02002254 f_bts_0_cfg(BSCVTY, {"si2quater neighbor-list add earfcn " & int2str(f_test_si2quater_earfcn_by_idx(i))
2255 & " thresh-hi 20 thresh-lo 10 prio 3 qrxlv 22 meas 3"});
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002256 }
2257
2258 f_init_bts_and_check_sysinfo(0, expect_si := expect_si);
2259
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02002260 f_init(1);
2261
2262 if (not istemplatekind(expect_cells, "omit")) {
2263 /* Also check that RR Channel Release contains these EARFCNs.
2264 * (copied code from TC_chan_rel_hard_clear_csfb) */
2265 var BSSAP_N_DATA_ind rx_di;
2266 var DchanTuple dt;
2267
2268 dt := f_est_dchan('23'O, 23, '00010203040506'O);
2269
2270 /* Instruct BSC to clear channel */
2271 var BssmapCause cause := 0;
2272 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommandCSFB(cause)));
2273
2274 /* expect Clear Complete from BSC on A */
2275 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete)) {
2276 /* release the SCCP connection */
2277 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
2278 }
2279
2280 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false, is_csfb := true,
2281 csfb_expect_cells := expect_cells);
2282 }
2283
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002284 for (var integer i := 1; i < total_earfcns; i := i + 1) {
Neels Hofmeyr56f24782020-07-09 00:50:49 +02002285 f_bts_0_cfg(BSCVTY, {"si2quater neighbor-list del earfcn " & int2str(f_test_si2quater_earfcn_by_idx(i))});
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002286 }
2287}
2288
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002289private function f_tr_si2quater_earfcns(integer count) return template SI2quaterRestOctetsList
2290{
2291 var template SI2quaterRestOctetsList si2quater := {};
2292 var integer si2quater_count := (count + 2) / 3;
2293
2294 for (var integer i := 0; i < count; i := i + 1) {
Neels Hofmeyr56f24782020-07-09 00:50:49 +02002295 var integer earfcn := f_test_si2quater_earfcn_by_idx(i);
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002296 var integer index := i / 3;
2297 var integer earfcn_index := i mod 3;
2298 if (index >= lengthof(si2quater)) {
2299 si2quater[index] := tr_SI2quaterRestOctets_EUTRAN(index := index, count := si2quater_count - 1);
2300 }
2301 si2quater[index].rel_additions.rel5.rel6.rel7.rel8.prio_eutran_params_desc.desc.eutran_params_desc.desc.repeated_neigh_cells[0].cell_desc_list[earfcn_index] := tr_EUTRAN_CellDesc_default(e_arfcn := earfcn);
2302 }
2303
2304 return si2quater;
2305}
2306
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02002307private function f_tr_rr_chan_rel_earfcns(integer count) return template CellSelIndValue
2308{
2309 var template CellSelIndValue_EUTRAN_Descrs cells := {};
2310
Alexander Couzensf74b5cb2020-09-10 22:28:40 +02002311 /* the lte neighbors must match the config & vty to pass this test */
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02002312 for (var integer i := 0; i < count; i := i + 1) {
2313 var integer earfcn := f_test_si2quater_earfcn_by_idx(i);
Alexander Couzensf74b5cb2020-09-10 22:28:40 +02002314 cells[i] := tr_CellSelIndValue_EUTRAN_Descr(earfcn, '1'B, 3);
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02002315 }
2316
2317 return tr_CellSelIndValue_EUTRAN(cells);
2318}
2319
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002320private function f_tc_si2quater_n_earfcns(integer n) runs on test_CT
2321{
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002322 var template SystemInformationConfig sic := SystemInformationConfig_default;
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002323 sic.si2quater := f_tr_si2quater_earfcns(n);
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02002324 var template CellSelIndValue cells := f_tr_rr_chan_rel_earfcns(n);
2325 f_test_si2quater(n, sic, cells);
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002326}
2327
2328testcase TC_si2quater_2_earfcns() runs on test_CT {
2329 f_tc_si2quater_n_earfcns(2);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002330 f_shutdown_helper();
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002331}
2332
2333testcase TC_si2quater_3_earfcns() runs on test_CT {
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002334 f_tc_si2quater_n_earfcns(3);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002335 f_shutdown_helper();
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002336}
2337
2338testcase TC_si2quater_4_earfcns() runs on test_CT {
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002339 f_tc_si2quater_n_earfcns(4);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002340 f_shutdown_helper();
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002341}
2342
2343testcase TC_si2quater_5_earfcns() runs on test_CT {
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002344 f_tc_si2quater_n_earfcns(5);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002345 f_shutdown_helper();
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002346}
2347
2348testcase TC_si2quater_6_earfcns() runs on test_CT {
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002349 f_tc_si2quater_n_earfcns(6);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002350 f_shutdown_helper();
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002351}
2352
2353testcase TC_si2quater_12_earfcns() runs on test_CT {
2354 f_tc_si2quater_n_earfcns(12);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002355 f_shutdown_helper();
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002356}
2357
2358testcase TC_si2quater_23_earfcns() runs on test_CT {
2359 f_tc_si2quater_n_earfcns(23);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002360 f_shutdown_helper();
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002361}
2362
2363testcase TC_si2quater_32_earfcns() runs on test_CT {
2364 f_tc_si2quater_n_earfcns(32);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002365 f_shutdown_helper();
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002366}
2367
2368testcase TC_si2quater_33_earfcns() runs on test_CT {
2369 f_tc_si2quater_n_earfcns(33);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002370 f_shutdown_helper();
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002371}
2372
2373testcase TC_si2quater_42_earfcns() runs on test_CT {
2374 f_tc_si2quater_n_earfcns(42);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002375 f_shutdown_helper();
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002376}
2377
2378testcase TC_si2quater_48_earfcns() runs on test_CT {
2379 f_tc_si2quater_n_earfcns(48);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002380 f_shutdown_helper();
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002381}
2382
2383/* verify the VTY error response when adding too many EARFCNs, and showing that osmo-bsc still sends 16 SI2quater with
2384 * 48 EARFCNs. */
2385testcase TC_si2quater_49_earfcns() runs on test_CT {
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002386 var template SystemInformationConfig sic := SystemInformationConfig_default;
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002387 sic.si2quater := f_tr_si2quater_earfcns(48); /* 48, not 49! */
2388 f_init(0);
2389
2390 for (var integer i := 1; i < 48; i := i + 1) {
Neels Hofmeyr56f24782020-07-09 00:50:49 +02002391 f_bts_0_cfg(BSCVTY, {"si2quater neighbor-list add earfcn " & int2str(f_test_si2quater_earfcn_by_idx(i))
2392 & " thresh-hi 20 thresh-lo 10 prio 3 qrxlv 22 meas 3"});
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002393 }
2394
2395 /* The 49th EARFCN no longer fits, expect VTY error */
2396 f_vty_enter_cfg_bts(BSCVTY, 0);
2397 var charstring vty_error;
2398 vty_error := f_vty_transceive_ret(BSCVTY,
2399 "si2quater neighbor-list add earfcn 70 thresh-hi 20 thresh-lo 10 prio 3 qrxlv 22 meas 3")
2400 f_vty_transceive(BSCVTY, "end");
2401
2402 if (f_strstr(vty_error, "Unable to add ARFCN 70") >= 0) {
2403 log("Got expected VTY error: ", vty_error);
2404 setverdict(pass);
2405 } else {
2406 setverdict(fail, "Expected the 49th EUTRAN ARFCN to be rejected by vty config, got: ", vty_error);
2407 }
2408
2409 f_init_bts_and_check_sysinfo(0, expect_si := sic);
2410
2411 for (var integer i := 1; i < 48; i := i + 1) {
Neels Hofmeyr56f24782020-07-09 00:50:49 +02002412 f_bts_0_cfg(BSCVTY, {"si2quater neighbor-list del earfcn " & int2str(f_test_si2quater_earfcn_by_idx(i))});
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002413 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002414 f_shutdown_helper();
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002415}
2416
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02002417private function f_acc09_count_allowed(AccessControlClass acc) return uint8_t
2418{
2419 var uint8_t count := 0;
2420 for (var integer i := 5; i < 16; i := i + 1) {
2421 if (acc[i] == '0'B) { /* the list marks barred, we count allowed */
2422 count := count + 1;
2423 }
2424 }
2425 return count;
2426}
2427
Pau Espin Pedrolc6136cd2020-07-24 13:20:02 +02002428private function f_recv_next_si1(integer rsl_idx := 0) runs on test_CT return SystemInformationType1
2429{
2430 var ASP_RSL_Unitdata rx_rsl_ud;
2431 var SystemInformationType1 last_si1;
2432
2433 timer T := 30.0;
2434 T.start;
2435 alt {
2436 [] IPA_RSL[rsl_idx].receive(tr_ASP_RSL_UD((tr_RSL_NO_BCCH_INFO,
2437 tr_RSL_BCCH_INFO,
2438 tr_RSL_NO_SACCH_FILL,
2439 tr_RSL_SACCH_FILL))
2440 ) -> value rx_rsl_ud {
2441 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
2442 if (g_system_information[rsl_idx].si1 == omit) {
2443 repeat;
2444 }
2445 last_si1 := g_system_information[rsl_idx].si1;
2446 g_system_information[rsl_idx].si1 := omit;
2447 T.stop;
2448 }
2449 [] T.timeout { setverdict(fail, "Timeout receiving next SI1"); }
2450 }
2451 return last_si1;
2452}
2453
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02002454/* verify ACC rotate feature */
2455testcase TC_si_acc_rotate() runs on test_CT {
2456 var template SystemInformationConfig sic := SystemInformationConfig_default;
Pau Espin Pedrolc6136cd2020-07-24 13:20:02 +02002457 var SystemInformationType1 last_si1;
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02002458 var AccessControlClass acc;
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02002459 var uint8_t count;
2460 var integer times_allowed[10] := { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
2461
2462 f_init(0, guard_timeout := 60.0);
2463
2464 f_bts_0_cfg(BSCVTY, {"rach access-control-class 5 barred",
2465 "access-control-class-rotate 3",
2466 "access-control-class-rotate-quantum 1"});
2467
2468 /* Init and get first sysinfo */
2469 f_init_bts_and_check_sysinfo(0, expect_si := ?);
2470
Pau Espin Pedrolc6136cd2020-07-24 13:20:02 +02002471 for (var integer i:= 0; i < 20; i := i + 1) {
2472 last_si1 := f_recv_next_si1(0);
2473 acc := last_si1.rach_control.acc;
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02002474 count := f_acc09_count_allowed(acc);
2475 log("RSL: GOT SI1 ACC len=", count, ": ", acc);
2476
2477 if (count != 3) {
2478 log("RSL: EXPECTED SI ACC len=3");
2479 setverdict(fail, "received SI does not match expectations");
2480 break;
2481 }
2482
2483 for (var integer j := 0; j < 10; j := j + 1) {
2484 if (acc[16 - 1 - j] == '0'B) { /* the list marks barred, we count allowed */
2485 times_allowed[j] := times_allowed[j] + 1;
2486 }
2487 }
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02002488 }
2489
2490 for (var integer j := 0; j < 10; j := j + 1) {
2491 log("ACC", j, " allowed ", times_allowed[j], " times" );
2492 if (j != 5 and times_allowed[j] < 3) {
2493 setverdict(fail, "ACC", j, " ERROR: allowed ", times_allowed[j], " < 1 times");
2494 } else if (j == 5 and times_allowed[j] > 0) {
2495 setverdict(fail, "ACC", j, " ERROR: allowed ", times_allowed[j], " > 0 times");
2496 }
2497 }
2498
2499 f_bts_0_cfg(BSCVTY, {"access-control-class-rotate 10",
2500 "rach access-control-class 5 allowed"});
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002501 f_shutdown_helper();
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02002502}
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002503
Pau Espin Pedrolc6136cd2020-07-24 13:20:02 +02002504/* verify ACC startup ramp+rotate feature */
2505testcase TC_si_acc_ramp_rotate() runs on test_CT {
2506 var template SystemInformationConfig sic := SystemInformationConfig_default;
2507 var SystemInformationType1 last_si1;
2508 var AccessControlClass acc;
2509 var ASP_RSL_Unitdata rx_rsl_ud;
2510 var uint8_t count;
2511 var uint8_t prev_count;
2512 var integer times_allowed[10] := { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
2513
2514 f_init(0, guard_timeout := 80.0);
2515
2516 f_bts_0_cfg(BSCVTY, {"rach access-control-class 4 barred",
2517 "access-control-class-rotate 0",
2518 "access-control-class-rotate-quantum 1",
2519 "access-control-class-ramping",
2520 "access-control-class-ramping-step-interval 5",
2521 "access-control-class-ramping-step-size 5"});
2522
2523 /* Init and get first sysinfo */
2524 f_init_bts_and_check_sysinfo(0, expect_si := ?);
2525 last_si1 := g_system_information[0].si1;
2526 acc := last_si1.rach_control.acc;
2527 count := f_acc09_count_allowed(acc);
2528 /* Adm subset size was set to 0 above, so wait until all ACC are barred */
2529 while (count > 0) {
2530 last_si1 := f_recv_next_si1(0);
2531 acc := last_si1.rach_control.acc;
2532 count := f_acc09_count_allowed(acc);
2533 log("RSL: wait len()=0: GOT SI1 ACC len=", count, ": ", acc);
2534 }
2535
2536 /* Increase adm subset size, we should see ramping start up */
2537 f_bts_0_cfg(BSCVTY, {"access-control-class-rotate 10"});
2538 prev_count := 0;
2539 while (true) {
2540 last_si1 := f_recv_next_si1(0);
2541 acc := last_si1.rach_control.acc;
2542 count := f_acc09_count_allowed(acc);
2543 log("RSL: GOT SI1 ACC len=", count, ": ", acc);
2544
2545 if (prev_count > count) {
2546 setverdict(fail, "ACC allowed count dropped while expecting grow: ", prev_count, " -> ", count);
2547 break;
2548 }
2549
2550 if (count == 9) {
2551 break; /* Maximum reached (10 - 1 perm barred), done here */
2552 }
2553
2554 prev_count := count;
2555 }
2556
2557 setverdict(pass);
2558
2559 f_bts_0_cfg(BSCVTY, {"access-control-class-rotate 10",
2560 "rach access-control-class 4 allowed",
2561 "no access-control-class-ramping"});
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002562 f_shutdown_helper();
Pau Espin Pedrolc6136cd2020-07-24 13:20:02 +02002563}
2564
Harald Welte4003d112017-12-09 22:35:39 +01002565testcase TC_ctrl_msc_connection_status() runs on test_CT {
2566 var charstring ctrl_resp;
2567
Harald Welte89d42e82017-12-17 16:42:41 +01002568 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +01002569
2570 /* See https://osmocom.org/issues/2729 */
2571 f_ctrl_get_exp(IPA_CTRL, "msc_connection_status", "connected");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002572 f_shutdown_helper();
Harald Welte4003d112017-12-09 22:35:39 +01002573}
2574
Stefan Sperlingb041b3d2018-01-03 17:14:55 +01002575testcase TC_ctrl_msc0_connection_status() runs on test_CT {
2576 var charstring ctrl_resp;
2577
2578 f_init(1);
Stefan Sperlingb041b3d2018-01-03 17:14:55 +01002579
2580 f_ctrl_get_exp(IPA_CTRL, "msc.0.connection_status", "connected");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002581 f_shutdown_helper();
Stefan Sperlingb041b3d2018-01-03 17:14:55 +01002582}
2583
Harald Welte4003d112017-12-09 22:35:39 +01002584testcase TC_ctrl() runs on test_CT {
2585 var charstring ctrl_resp;
2586
Harald Welte89d42e82017-12-17 16:42:41 +01002587 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +01002588
2589 /* all below values must match the osmo-bsc.cfg config file used */
2590
Harald Welte6a129692018-03-17 17:30:14 +01002591 f_ctrl_get_exp(IPA_CTRL, "mcc", "001");
2592 f_ctrl_get_exp(IPA_CTRL, "mnc", "01");
Oliver Smith75aa0202019-08-19 14:17:50 +02002593 f_ctrl_get_exp(IPA_CTRL, "number-of-bts", "4");
Harald Welte4003d112017-12-09 22:35:39 +01002594
2595 var integer bts_nr := 0;
2596 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "location-area-code", "1");
2597 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "cell-identity", "0");
2598 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "oml-connection-state", "connected");
2599 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "gprs-mode", "gprs");
2600 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "rf_state", "operational,unlocked,on");
2601 f_ctrl_get_exp_trx(IPA_CTRL, bts_nr, 0, "arfcn", "871");
2602 f_ctrl_get_exp_trx(IPA_CTRL, bts_nr, 0, "max-power-reduction", "20");
2603
2604 var integer uptime := str2int(f_ctrl_get_bts(IPA_CTRL, bts_nr, "oml-uptime"));
2605 f_sleep(2.0);
2606 if (str2int(f_ctrl_get_bts(IPA_CTRL, bts_nr, "oml-uptime")) < uptime+1) {
2607 setverdict(fail, "oml-uptime not incrementing as expected");
2608 }
2609 /* TODO: Disconnect RSL, imply that OML is disconnected and check for uptime zero? */
2610
2611 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bsc", 0, "paging:attempted", 0);
2612
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002613 f_shutdown_helper();
Harald Welte96c94412017-12-09 03:12:45 +01002614}
2615
Pau Espin Pedrol5a2d7432019-06-07 19:43:45 +02002616/* Verify that Upon receival of SET "location", BSC forwards a TRAP
2617 "location-state" over the SCCPlite IPA conn */
2618testcase TC_ctrl_location() runs on test_CT {
2619 var MSC_ConnHdlr vc_conn;
2620 var integer bts_nr := 0;
2621
2622 f_init(1, true);
2623 f_sleep(1.0);
2624
2625 f_ctrl_set_bts(IPA_CTRL, bts_nr, "location", "1234567,fix3d,0.340000,0.560000,0.780000");
2626 f_ctrl_exp_trap(SCCPLITE_IPA_CTRL, "bts." & int2str(bts_nr) & ".location-state",
2627 "1234567,fix3d,0.340000,0.560000,0.780000,operational,unlocked,on,001,01");
2628
2629 f_ctrl_set(SCCPLITE_IPA_CTRL, "rf_locked", "1");
2630 f_sleep(2.0);
2631
2632 f_ctrl_set_bts(IPA_CTRL, bts_nr, "location", "1234888,fix3d,0.350000,0.570000,0.790000");
2633 f_ctrl_exp_trap(SCCPLITE_IPA_CTRL, "bts." & int2str(bts_nr) & ".location-state",
2634 "1234888,fix3d,0.350000,0.570000,0.790000,operational,locked,off,001,01");
2635
2636 /* should match the one from config */
2637 f_ctrl_set(SCCPLITE_IPA_CTRL, "rf_locked", "0");
2638
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002639 f_shutdown_helper();
Pau Espin Pedrol5a2d7432019-06-07 19:43:45 +02002640}
2641
Harald Welte6f521d82017-12-11 19:52:02 +01002642
2643/***********************************************************************
2644 * Paging Testing
2645 ***********************************************************************/
2646
2647type record Cell_Identity {
2648 GsmMcc mcc,
2649 GsmMnc mnc,
2650 GsmLac lac,
2651 GsmCellId ci
2652};
Harald Welte24135bd2018-03-17 19:27:53 +01002653private const Cell_Identity cid := { '001'H, '01'H, 1, 0 };
Stefan Sperling049a86e2018-03-20 15:51:00 +01002654private const Cell_Identity unknown_cid := { '678'H, 'f90'H, 1, 0 };
Harald Welte6f521d82017-12-11 19:52:02 +01002655
Harald Welte5d1a2202017-12-13 19:51:29 +01002656type set of integer BtsIdList;
2657
2658private function f_bts_in_list(integer bts_id, BtsIdList bts_ids) return boolean {
2659 for (var integer j := 0; j < sizeof(bts_ids); j := j + 1) {
2660 if (bts_id == bts_ids[j]) {
2661 return true;
2662 }
2663 }
2664 return false;
2665}
Harald Welte6f521d82017-12-11 19:52:02 +01002666
2667/* core paging test helper function; used by most paging test cases */
2668private function f_pageing_helper(hexstring imsi,
2669 template BSSMAP_FIELD_CellIdentificationList cid_list,
Harald Welte5d1a2202017-12-13 19:51:29 +01002670 BtsIdList bts_ids := { 0 },
Harald Welte6f521d82017-12-11 19:52:02 +01002671 template RSL_ChanNeeded rsl_chneed := omit,
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07002672 template (omit) OCT4 tmsi := omit) runs on test_CT
Harald Welte6f521d82017-12-11 19:52:02 +01002673{
2674 var template BSSMAP_IE_ChannelNeeded bssmap_chneed;
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07002675 var template MobileIdentityV mi;
Harald Welte6f521d82017-12-11 19:52:02 +01002676 var RSL_Message rx_rsl;
2677 var integer paging_group := hex2int(imsi[lengthof(imsi)-1]);
Harald Welte5d1a2202017-12-13 19:51:29 +01002678 var integer i;
Harald Welte6f521d82017-12-11 19:52:02 +01002679
2680 f_init();
Harald Welte6f521d82017-12-11 19:52:02 +01002681
2682 /* Clear the queue, it might still contain stuff like BCCH FILLING */
Harald Weltec3068592018-03-17 19:55:31 +01002683 for (i := 0; i < NUM_BTS; i := i + 1) {
2684 IPA_RSL[i].clear;
Harald Welte5d1a2202017-12-13 19:51:29 +01002685 }
Harald Welte6f521d82017-12-11 19:52:02 +01002686
2687 if (isvalue(rsl_chneed)) {
2688 /* The values of 08.08 3.2.2.36 and 08.58 9.3.40 are luckily identical */
2689 bssmap_chneed := ts_BSSMAP_IE_ChanNeeded(int2bit(enum2int(valueof(rsl_chneed)),2));
2690 } else {
2691 bssmap_chneed := omit;
2692 }
2693
Neels Hofmeyrf246a922020-05-13 02:27:10 +02002694 BSSAP.send(ts_BSSAP_UNITDATA_req(g_bssap[0].sccp_addr_peer, g_bssap[0].sccp_addr_own,
2695 ts_BSSMAP_Paging(imsi, cid_list, tmsi, bssmap_chneed)));
Harald Welte6f521d82017-12-11 19:52:02 +01002696
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07002697 if (not istemplatekind(tmsi, "omit")) {
2698 mi := t_MI_TMSI(tmsi);
Harald Welte6f521d82017-12-11 19:52:02 +01002699 } else {
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07002700 mi := tr_MI_IMSI(imsi);
Harald Welte6f521d82017-12-11 19:52:02 +01002701 }
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07002702
Harald Welte5d1a2202017-12-13 19:51:29 +01002703 for (i := 0; i < sizeof(bts_ids); i := i + 1) {
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07002704 rx_rsl := f_exp_ipa_rx(bts_ids[i], tr_RSL_PAGING_CMD(mi));
Harald Welte5d1a2202017-12-13 19:51:29 +01002705 /* check channel type, paging group */
2706 if (rx_rsl.ies[1].body.paging_group != paging_group) {
2707 setverdict(fail, "Paging for wrong paging group");
2708 }
2709 if (ispresent(rsl_chneed) and
2710 rx_rsl.ies[3].body.chan_needed.chan_needed != valueof(rsl_chneed)) {
2711 setverdict(fail, "RSL Channel Needed != BSSMAP Channel Needed");
2712 }
Harald Welte6f521d82017-12-11 19:52:02 +01002713 }
Harald Welte2fccd982018-01-31 15:48:19 +01002714 f_sleep(2.0);
Harald Welte5d1a2202017-12-13 19:51:29 +01002715 /* do a quick check on all not-included BTSs if they received paging */
2716 for (i := 0; i < NUM_BTS; i := i + 1) {
2717 timer T := 0.1;
2718 if (f_bts_in_list(i, bts_ids)) {
2719 continue;
2720 }
2721 T.start;
2722 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07002723 [] IPA_RSL[i].receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD(mi))) {
Harald Welte5d1a2202017-12-13 19:51:29 +01002724 setverdict(fail, "Paging on BTS ", i, " which is not part of ", bts_ids);
2725 }
2726 [] IPA_RSL[i].receive { repeat; }
2727 [] T.timeout { }
2728 }
Harald Welte6f521d82017-12-11 19:52:02 +01002729 }
2730
2731 setverdict(pass);
2732}
2733
Harald Welte5d1a2202017-12-13 19:51:29 +01002734const BtsIdList c_BtsId_all := { 0, 1, 2 };
Harald Welte751d3eb2018-01-31 15:51:06 +01002735const BtsIdList c_BtsId_none := { };
Harald Welte5d1a2202017-12-13 19:51:29 +01002736const BtsIdList c_BtsId_LAC1 := { 0, 1 };
2737const BtsIdList c_BtsId_LAC2 := { 2 };
2738
Harald Welte6f521d82017-12-11 19:52:02 +01002739/* PAGING by IMSI + TMSI */
2740testcase TC_paging_imsi_nochan() runs on test_CT {
2741 var BSSMAP_FIELD_CellIdentificationList cid_list;
2742 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Philipp Maier8c04b0a2018-02-23 13:48:48 +01002743 f_pageing_helper('001010100000001'H, cid_list, c_BtsId_all, omit, omit);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002744 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002745}
2746
2747/* PAGING by IMSI + TMSI */
2748testcase TC_paging_tmsi_nochan() runs on test_CT {
2749 var BSSMAP_FIELD_CellIdentificationList cid_list;
2750 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01002751 f_pageing_helper('001010100000001'H, cid_list, c_BtsId_all, omit, 'A1B2C301'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002752 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002753}
2754
2755/* Paging with different "channel needed' values */
2756testcase TC_paging_tmsi_any() runs on test_CT {
2757 var BSSMAP_FIELD_CellIdentificationList cid_list;
2758 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01002759 f_pageing_helper('001010100000002'H, cid_list, c_BtsId_all, RSL_CHANNEED_ANY, 'A1B2C302'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002760 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002761}
2762testcase TC_paging_tmsi_sdcch() runs on test_CT {
2763 var BSSMAP_FIELD_CellIdentificationList cid_list;
2764 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01002765 f_pageing_helper('001010100000003'H, cid_list, c_BtsId_all, RSL_CHANNEED_SDCCH, 'A1B2C303'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002766 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002767}
2768testcase TC_paging_tmsi_tch_f() runs on test_CT {
2769 var BSSMAP_FIELD_CellIdentificationList cid_list;
2770 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01002771 f_pageing_helper('001010000000004'H, cid_list, c_BtsId_all, RSL_CHANNEED_TCH_F, 'A1B2C304'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002772 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002773}
2774testcase TC_paging_tmsi_tch_hf() runs on test_CT {
2775 var BSSMAP_FIELD_CellIdentificationList cid_list;
2776 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01002777 f_pageing_helper('001010000000005'H, cid_list, c_BtsId_all, RSL_CHANNEED_TCH_ForH, 'A1B2C305'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002778 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002779}
2780
2781/* Paging by CGI */
2782testcase TC_paging_imsi_nochan_cgi() runs on test_CT {
2783 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2784 cid_list := { cIl_CGI := { ts_BSSMAP_CI_CGI(cid.mcc, cid.mnc, cid.lac, cid.ci) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01002785 f_pageing_helper('001010000000006'H, cid_list, { 0 });
Philipp Maier282ca4b2018-02-27 17:17:00 +01002786 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002787}
2788
2789/* Paging by LAC+CI */
2790testcase TC_paging_imsi_nochan_lac_ci() runs on test_CT {
2791 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2792 cid_list := { cIl_LAC_CI := { ts_BSSMAP_CI_LAC_CI(cid.lac, cid.ci) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01002793 f_pageing_helper('001010000000007'H, cid_list, { 0 });
Philipp Maier282ca4b2018-02-27 17:17:00 +01002794 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002795}
2796
2797/* Paging by CI */
2798testcase TC_paging_imsi_nochan_ci() runs on test_CT {
2799 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2800 cid_list := { cIl_CI := { ts_BSSMAP_CI_CI(cid.ci) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01002801 f_pageing_helper('001010000000008'H, cid_list, { 0 });
Philipp Maier282ca4b2018-02-27 17:17:00 +01002802 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002803}
2804
2805/* Paging by LAI */
2806testcase TC_paging_imsi_nochan_lai() runs on test_CT {
2807 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2808 cid_list := { cIl_LAI := { ts_BSSMAP_CI_LAI(cid.mcc, cid.mnc, cid.lac) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01002809 f_pageing_helper('001010000000009'H, cid_list, c_BtsId_LAC1);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002810 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002811}
2812
2813/* Paging by LAC */
2814testcase TC_paging_imsi_nochan_lac() runs on test_CT {
2815 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2816 cid_list := { cIl_LAC := { ts_BSSMAP_CI_LAC(cid.lac) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01002817 f_pageing_helper('001010000000010'H, cid_list, c_BtsId_LAC1);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002818 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002819}
2820
2821/* Paging by "all in BSS" */
2822testcase TC_paging_imsi_nochan_all() runs on test_CT {
2823 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2824 cid_list := { cIl_allInBSS := ''O };
Harald Welte5d1a2202017-12-13 19:51:29 +01002825 f_pageing_helper('001010000000011'H, cid_list, c_BtsId_all);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002826 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002827}
2828
Stefan Sperling7b5e1782018-03-20 19:32:43 +01002829/* Paging by PLMN+LAC+RNC; We do not implement this; Verify nothing is paged */
Harald Welte751d3eb2018-01-31 15:51:06 +01002830testcase TC_paging_imsi_nochan_plmn_lac_rnc() runs on test_CT {
2831 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2832 cid_list := { cIl_PLMN_LAC_RNC := { ts_BSSMAP_CI_PLMN_LAC_RNC(cid.mcc, cid.mnc, cid.lac, 12) } };
Stefan Sperling7b5e1782018-03-20 19:32:43 +01002833 f_pageing_helper('001010000000012'H, cid_list, c_BtsId_none);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002834 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01002835}
Harald Welte6f521d82017-12-11 19:52:02 +01002836
Stefan Sperling7b5e1782018-03-20 19:32:43 +01002837/* Paging by RNC; We do not implement this; Verify nothing is paged */
Harald Welte751d3eb2018-01-31 15:51:06 +01002838testcase TC_paging_imsi_nochan_rnc() runs on test_CT {
2839 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2840 cid_list := { cIl_RNC := { int2oct(13, 2) } };
Stefan Sperling7b5e1782018-03-20 19:32:43 +01002841 f_pageing_helper('001010000000013'H, cid_list, c_BtsId_none);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002842 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01002843}
2844
Stefan Sperling7b5e1782018-03-20 19:32:43 +01002845/* Paging by LAC+RNC; We do not implement; Verify nothing is paged */
Harald Welte751d3eb2018-01-31 15:51:06 +01002846testcase TC_paging_imsi_nochan_lac_rnc() runs on test_CT {
2847 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2848 cid_list := { cIl_LAC_RNC := { ts_BSSMAP_CI_LAC_RNC(cid.lac, 14) } };
Stefan Sperling7b5e1782018-03-20 19:32:43 +01002849 f_pageing_helper('001010000000014'H, cid_list, c_BtsId_none);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002850 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01002851}
2852
Harald Welte6f521d82017-12-11 19:52:02 +01002853/* Paging on multiple cells (multiple entries in list): Verify all of them page */
Harald Welte751d3eb2018-01-31 15:51:06 +01002854testcase TC_paging_imsi_nochan_lacs() runs on test_CT {
2855 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2856 cid_list := { cIl_LAC := { ts_BSSMAP_CI_LAC(1), ts_BSSMAP_CI_LAC(2) } };
2857 f_pageing_helper('001010000000015'H, cid_list, c_BtsId_all);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002858 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01002859}
2860
2861/* Paging on empty list: Verify none of them page */
2862testcase TC_paging_imsi_nochan_lacs_empty() runs on test_CT {
2863 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2864 cid_list := { cIl_LAC := { } };
2865 f_pageing_helper('001010000000016'H, cid_list, c_BtsId_none);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002866 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01002867}
2868
Stefan Sperling049a86e2018-03-20 15:51:00 +01002869/* Paging by CGI with unknown MCC/MNC: Verify nothing is paged. */
2870testcase TC_paging_imsi_nochan_cgi_unknown_cid() runs on test_CT {
2871 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2872 cid_list := { cIl_CGI := { ts_BSSMAP_CI_CGI(unknown_cid.mcc, unknown_cid.mnc, unknown_cid.lac, unknown_cid.ci) } };
2873 f_pageing_helper('001010000000006'H, cid_list, c_BtsId_none);
2874 f_shutdown_helper();
2875}
2876
Harald Welte6f521d82017-12-11 19:52:02 +01002877/* Verify paging retransmission interval + count */
2878/* Verify paging stops after channel establishment */
Harald Welte6f521d82017-12-11 19:52:02 +01002879/* Test behavior under paging overload */
Harald Welteae026692017-12-09 01:03:01 +01002880
Harald Weltee65d40e2017-12-13 00:09:06 +01002881/* Verify PCH load */
2882testcase TC_paging_imsi_load() runs on test_CT {
2883 var BSSMAP_FIELD_CellIdentificationList cid_list;
2884 timer T := 4.0;
Harald Welte2caa1062018-03-17 18:19:05 +01002885 timer T_retrans := 1.0;
Harald Weltee65d40e2017-12-13 00:09:06 +01002886 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01002887 f_pageing_helper('001010123456789'H, cid_list, c_BtsId_all);
Harald Weltee65d40e2017-12-13 00:09:06 +01002888
2889 /* tell BSC there is no paging space anymore */
2890 f_ipa_tx(0, ts_RSL_PAGING_LOAD_IND(0));
Harald Welte3b57ab52018-03-17 18:01:10 +01002891 f_sleep(0.2);
2892 IPA_RSL[0].clear;
Harald Weltee65d40e2017-12-13 00:09:06 +01002893
2894 /* Wait for 4 seconds if any more PAGING CMD are received on RSL. Normally,
2895 * there would be 8 retransmissions during 4 seconds */
2896 T.start;
Harald Welte2caa1062018-03-17 18:19:05 +01002897 T_retrans.start;
Harald Weltee65d40e2017-12-13 00:09:06 +01002898 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07002899 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD(?))) {
Harald Weltee65d40e2017-12-13 00:09:06 +01002900 setverdict(fail, "Received PAGING after LOAD_IND(0)");
Daniel Willmannafce8662018-07-06 23:11:32 +02002901 mtc.stop;
Harald Weltee65d40e2017-12-13 00:09:06 +01002902 }
Harald Welte2caa1062018-03-17 18:19:05 +01002903 [] T_retrans.timeout {
2904 /* re-trnsmit the zero-space LOAD IND to avoid BSC 'auto credit' */
2905 f_ipa_tx(0, ts_RSL_PAGING_LOAD_IND(0));
2906 T_retrans.start;
2907 repeat;
2908 }
Harald Weltee65d40e2017-12-13 00:09:06 +01002909 [] T.timeout {
2910 setverdict(pass);
2911 }
2912 }
Philipp Maier282ca4b2018-02-27 17:17:00 +01002913
2914 f_shutdown_helper();
Harald Weltee65d40e2017-12-13 00:09:06 +01002915}
2916
Harald Welte235ebf12017-12-15 14:18:16 +01002917/* Verify Paging Counter */
Harald Welte1ff69992017-12-14 12:31:17 +01002918testcase TC_paging_counter() runs on test_CT {
2919 var BSSMAP_FIELD_CellIdentificationList cid_list;
2920 timer T := 4.0;
2921 var integer i;
2922 var integer paging_attempted_bsc;
2923 var integer paging_attempted_bts[NUM_BTS];
2924 var integer paging_expired_bts[NUM_BTS];
2925 cid_list := valueof(ts_BSSMAP_CIL_noCell);
2926
2927 f_init();
2928
2929 /* read counters before paging */
2930 paging_attempted_bsc := f_ctrl_get_ratectr_abs(IPA_CTRL, "bsc", 0, "paging:attempted");
2931 for (i := 0; i < NUM_BTS; i := i+1) {
2932 paging_attempted_bts[i] := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", i, "paging:attempted");
2933 paging_expired_bts[i] := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", i, "paging:expired");
2934 }
2935
2936 f_pageing_helper('001230000000001'H, cid_list, c_BtsId_all);
2937
2938 /* expect the attempted pages on BSC and each BTSs to have incremented by one */
2939 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bsc", 0, "paging:attempted", paging_attempted_bsc+1);
2940 for (i := 0; i < NUM_BTS; i := i+1) {
2941 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", i, "paging:attempted",
2942 paging_attempted_bts[i]+1);
2943 }
2944
2945 /* assume that 12s later the paging on all BTSs have expired and hence incremented by 1 */
2946 f_sleep(12.0);
2947 for (i := 0; i < NUM_BTS; i := i+1) {
2948 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", i, "paging:expired",
2949 paging_expired_bts[i]+1);
2950 }
Harald Welte1ff69992017-12-14 12:31:17 +01002951
Philipp Maier282ca4b2018-02-27 17:17:00 +01002952 f_shutdown_helper();
Harald Welte1ff69992017-12-14 12:31:17 +01002953}
2954
2955
Harald Welte10985002017-12-12 09:29:15 +01002956/* Verify paging stops after A-RESET */
2957testcase TC_paging_imsi_a_reset() runs on test_CT {
2958 var BSSMAP_FIELD_CellIdentificationList cid_list;
2959 timer T := 3.0;
2960 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01002961 f_pageing_helper('001010123456789'H, cid_list, c_BtsId_all);
Harald Welte10985002017-12-12 09:29:15 +01002962
2963 /* Perform a BSSMAP Reset and wait for ACK */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02002964 BSSAP.send(ts_BSSAP_UNITDATA_req(g_bssap[0].sccp_addr_peer, g_bssap[0].sccp_addr_own, ts_BSSMAP_Reset(0, g_osmux_enabled)));
Harald Welte10985002017-12-12 09:29:15 +01002965 alt {
Neels Hofmeyrf246a922020-05-13 02:27:10 +02002966 [] BSSAP.receive(tr_BSSAP_UNITDATA_ind(g_bssap[0].sccp_addr_own, g_bssap[0].sccp_addr_peer, tr_BSSMAP_ResetAck(g_osmux_enabled))) { }
Harald Welte10985002017-12-12 09:29:15 +01002967 [] BSSAP.receive { repeat; }
2968 }
2969
Daniel Willmanncbef3982018-07-30 09:22:40 +02002970 /* Wait to avoid a possible race condition if a paging message is
2971 * received right before the reset ACK. */
2972 f_sleep(0.2);
2973
Harald Welte10985002017-12-12 09:29:15 +01002974 /* Clear the queue, it might still contain stuff like BCCH FILLING */
Philipp Maier1e6b4422018-02-23 14:02:13 +01002975 for (var integer i := 0; i < sizeof(IPA_RSL); i := i+1) {
2976 IPA_RSL[i].clear;
2977 }
Harald Welte10985002017-12-12 09:29:15 +01002978
2979 /* Wait for 3 seconds if any more PAGING CMD are received on RSL */
2980 T.start;
2981 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07002982 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD(?))) {
Harald Welte10985002017-12-12 09:29:15 +01002983 setverdict(fail, "Received PAGING after A-RESET");
Daniel Willmannafce8662018-07-06 23:11:32 +02002984 mtc.stop;
Harald Welte10985002017-12-12 09:29:15 +01002985 }
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07002986 [] IPA_RSL[1].receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD(?))) {
Harald Welte5d1a2202017-12-13 19:51:29 +01002987 setverdict(fail, "Received PAGING after A-RESET");
Daniel Willmannafce8662018-07-06 23:11:32 +02002988 mtc.stop;
Harald Welte5d1a2202017-12-13 19:51:29 +01002989 }
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07002990 [] IPA_RSL[2].receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD(?))) {
Harald Welte5d1a2202017-12-13 19:51:29 +01002991 setverdict(fail, "Received PAGING after A-RESET");
Daniel Willmannafce8662018-07-06 23:11:32 +02002992 mtc.stop;
Harald Welte5d1a2202017-12-13 19:51:29 +01002993 }
Harald Welte10985002017-12-12 09:29:15 +01002994 [] T.timeout {
2995 setverdict(pass);
2996 }
2997 }
Philipp Maier282ca4b2018-02-27 17:17:00 +01002998
2999 f_shutdown_helper();
Harald Welte10985002017-12-12 09:29:15 +01003000}
Harald Welteae026692017-12-09 01:03:01 +01003001
Philipp Maierf45824a2019-08-14 14:44:10 +02003002/* Verify how we handle unsolicited Paging Response. In case of an unsolicit
3003 * paging response we can not know which MSC is in charge, so we will blindly
3004 * pick the first configured MSC. This behavior is required in order to make
3005 * MT-CSFB calls working because in those cases the BSC can not know that the
3006 * MSC has already paged the subscriver via SGs. So any MT-CSFB call will look
3007 * like an unsolicited Paging Response to the MSC.
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01003008 */
3009testcase TC_paging_resp_unsol() runs on test_CT {
3010
3011 f_init(1);
Philipp Maierf45824a2019-08-14 14:44:10 +02003012 timer T := 5.0;
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01003013
3014 var BSSAP_N_CONNECT_ind rx_c_ind;
3015 var DchanTuple dt;
3016 var PDU_ML3_MS_NW l3 := valueof(ts_PAG_RESP(valueof(ts_MI_IMSI_LV('001010008880018'H))));
Philipp Maierf45824a2019-08-14 14:44:10 +02003017 var octetstring rr_pag_resp := enc_PDU_ML3_MS_NW(l3);
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01003018
3019 /* Send CHAN RQD and wait for allocation; acknowledge it */
3020 dt.rsl_chan_nr := f_chreq_act_ack();
3021
3022 /* Send unsolicited Paging response (no matching Paging CMD stored in BSC) */
3023 f_ipa_tx(0, ts_RSL_EST_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0)), enc_PDU_ML3_MS_NW(l3)));
3024
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01003025
Philipp Maierf45824a2019-08-14 14:44:10 +02003026 /* Expevct a CR with a matching Paging response on the A-Interface */
3027 T.start;
3028 alt {
3029 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(rr_pag_resp))) {
3030 setverdict(pass);
3031 }
3032 [] BSSAP.receive {
3033 setverdict(fail, "Received unexpected message on A-Interface!");
3034 }
3035 [] T.timeout {
3036 setverdict(fail, "Received nothing on A-Interface!");
3037 }
3038 }
3039
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003040 f_shutdown_helper();
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01003041}
3042
Harald Welte4e9b9cc2017-12-14 18:31:02 +01003043/* Test RSL link drop causes counter increment */
3044testcase TC_rsl_drop_counter() runs on test_CT {
3045 var integer rsl_fail;
3046
Harald Welte89d42e82017-12-17 16:42:41 +01003047 f_init(1);
Harald Welte4e9b9cc2017-12-14 18:31:02 +01003048
3049 rsl_fail := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "rsl_fail");
3050
3051 bts[0].rsl.vc_IPA.stop;
3052
3053 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "rsl_fail", rsl_fail+1);
3054
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003055 f_shutdown_helper();
Harald Welte4e9b9cc2017-12-14 18:31:02 +01003056}
3057
3058/* TODO: Test OML link drop causes counter increment */
3059
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003060/* The body of TC_rsl_unknown_unit_id() and TC_oml_unknown_unit_id() tests. */
3061function f_ipa_unknown_unit_id(integer mp_bsc_ipa_port) runs on test_CT return boolean {
3062 timer T := 10.0;
3063
3064 bts[0].rsl.id := "IPA-0-RSL";
3065 bts[0].rsl.vc_IPA := IPA_Emulation_CT.create(bts[0].rsl.id & "-IPA");
3066 bts[0].rsl.ccm_pars := c_IPA_default_ccm_pars;
3067 bts[0].rsl.ccm_pars.name := "Osmocom TTCN-3 BTS Simulator";
Oliver Smith92c2bdb2019-08-20 15:11:24 +02003068 bts[0].rsl.ccm_pars.unit_id := "99/0/0"; /* value which is unknown at BTS */
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003069
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003070 f_ipa_ctrl_start(mp_bsc_ip, mp_bsc_ctrl_port);
3071
3072 f_init_mgcp("VirtMSC");
3073
3074 /* start RSL/OML connection (XXX re-uses RSL port/protocol definitions for OML) */
3075 map(bts[0].rsl.vc_IPA:IPA_PORT, system:IPA);
3076 connect(bts[0].rsl.vc_IPA:IPA_RSL_PORT, self:IPA_RSL[0]);
3077 bts[0].rsl.vc_IPA.start(IPA_Emulation.main_client(mp_bsc_ip, mp_bsc_ipa_port, "", 10000, bts[0].rsl.ccm_pars));
3078
3079 /* wait for IPA OML link to connect and then disconnect */
3080 T.start;
3081 alt {
Vadim Yanitskiya2afacc2020-05-18 21:16:19 +07003082 [] IPA_RSL[0].receive(tr_ASP_IPA_EV(ASP_IPA_EVENT_DOWN)) {
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003083 T.stop;
3084 return true;
3085 }
3086 [] IPA_RSL[0].receive { repeat }
3087 [] T.timeout {
Daniel Willmannafce8662018-07-06 23:11:32 +02003088 return false;
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003089 }
3090 }
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003091 return false;
3092}
3093
3094/* BSC should close an RSL connection from a BTS with unknown unit ID (OS#2714). */
3095testcase TC_rsl_unknown_unit_id() runs on test_CT {
3096 if (f_ipa_unknown_unit_id(mp_bsc_rsl_port)) {
3097 setverdict(pass);
3098 } else {
3099 setverdict(fail, "Timeout RSL waiting for connection to close");
3100 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003101 f_shutdown_helper();
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003102}
3103
3104
3105/* BSC should close an RSL connection from a BTS with unknown unit ID (OS#2714). */
3106testcase TC_oml_unknown_unit_id() runs on test_CT {
3107 if (f_ipa_unknown_unit_id(mp_bsc_oml_port)) {
3108 setverdict(pass);
3109 } else {
3110 setverdict(fail, "Timeout OML waiting for connection to close");
3111 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003112 f_shutdown_helper();
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003113}
3114
3115
Harald Weltec1a2fff2017-12-17 11:06:19 +01003116/***********************************************************************
Harald Welte6811d102019-04-14 22:23:14 +02003117 * "New world" test cases using RSL_Emulation + RAN_Emulation
Harald Weltec1a2fff2017-12-17 11:06:19 +01003118 ***********************************************************************/
3119
Harald Welte6811d102019-04-14 22:23:14 +02003120import from RAN_Emulation all;
Harald Welte47cd0e32020-08-21 12:39:11 +02003121import from BSSAP_LE_Emulation all;
Harald Weltec1a2fff2017-12-17 11:06:19 +01003122import from RSL_Emulation all;
3123import from MSC_ConnectionHandler all;
3124
3125type function void_fn(charstring id) runs on MSC_ConnHdlr;
3126
Harald Welte336820c2018-05-31 20:34:52 +02003127/* helper function to create and connect a MSC_ConnHdlr component */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003128private function f_connect_handler(inout MSC_ConnHdlr vc_conn, integer bssap_idx := 0) runs on test_CT {
3129 connect(vc_conn:RAN, g_bssap[bssap_idx].vc_RAN:PROC);
Daniel Willmann191e0d92018-01-17 12:44:35 +01003130 connect(vc_conn:MGCP_PROC, vc_MGCP:MGCP_PROC);
Harald Weltec1a2fff2017-12-17 11:06:19 +01003131 connect(vc_conn:RSL, bts[0].rsl.vc_RSL:CLIENT_PT);
Harald Weltef70df652018-01-29 22:00:23 +01003132 connect(vc_conn:RSL_PROC, bts[0].rsl.vc_RSL:RSL_PROC);
Philipp Maier88f4ae82018-03-01 14:00:58 +01003133 if (isvalue(bts[1])) {
Philipp Maier956a92f2018-02-16 10:58:07 +01003134 connect(vc_conn:RSL1, bts[1].rsl.vc_RSL:CLIENT_PT);
3135 connect(vc_conn:RSL1_PROC, bts[1].rsl.vc_RSL:RSL_PROC);
3136 }
Neels Hofmeyr91401012019-07-11 00:42:35 +02003137 if (isvalue(bts[2])) {
3138 connect(vc_conn:RSL2, bts[2].rsl.vc_RSL:CLIENT_PT);
3139 connect(vc_conn:RSL2_PROC, bts[2].rsl.vc_RSL:RSL_PROC);
3140 }
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003141 connect(vc_conn:BSSAP, g_bssap[bssap_idx].vc_RAN:CLIENT);
Harald Welte47cd0e32020-08-21 12:39:11 +02003142 connect(vc_conn:BSSAP_LE, g_bssap_le.vc_BSSAP_LE:CLIENT);
Neels Hofmeyr269c73c2020-09-18 23:45:18 +02003143 connect(vc_conn:BSSAP_LE_PROC, g_bssap_le.vc_BSSAP_LE:PROC);
Daniel Willmann191e0d92018-01-17 12:44:35 +01003144 connect(vc_conn:MGCP, vc_MGCP:MGCP_CLIENT);
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +02003145 connect(vc_conn:MGCP_MULTI, vc_MGCP:MGCP_CLIENT_MULTI);
Daniel Willmannebdecc02020-08-12 15:30:17 +02003146 connect(vc_conn:STATSD_PROC, vc_STATSD:STATSD_PROC);
Harald Welte336820c2018-05-31 20:34:52 +02003147}
3148
3149function f_start_handler(void_fn fn, template (omit) TestHdlrParams pars := omit)
3150runs on test_CT return MSC_ConnHdlr {
3151 var charstring id := testcasename();
3152 var MSC_ConnHdlr vc_conn;
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003153 var integer bssap_idx := 0;
3154 if (isvalue(pars)) {
3155 bssap_idx := valueof(pars).mscpool.bssap_idx;
3156 }
Harald Welte336820c2018-05-31 20:34:52 +02003157 vc_conn := MSC_ConnHdlr.create(id);
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003158 f_connect_handler(vc_conn, bssap_idx);
Harald Weltea0630032018-03-20 21:09:55 +01003159 vc_conn.start(f_handler_init(fn, id, pars));
Harald Weltec1a2fff2017-12-17 11:06:19 +01003160 return vc_conn;
3161}
3162
Harald Weltea0630032018-03-20 21:09:55 +01003163/* first function inside ConnHdlr component; sets g_pars + starts function */
3164private function f_handler_init(void_fn fn, charstring id, template (omit) TestHdlrParams pars := omit)
3165runs on MSC_ConnHdlr {
3166 if (isvalue(pars)) {
3167 g_pars := valueof(pars);
3168 }
3169 fn.apply(id);
3170}
3171
Harald Welte3c86ea02018-05-10 22:28:05 +02003172/* Establish signalling channel (non-assignment case) followed by cipher mode */
3173private function f_tc_ciph_mode_a5(charstring id) runs on MSC_ConnHdlr {
Harald Welteed848512018-05-24 22:27:58 +02003174 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3175 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte3c86ea02018-05-10 22:28:05 +02003176 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeSIGNAL);
Philipp Maier23000732018-05-18 11:25:37 +02003177 ass_cmd.pdu.bssmap.assignmentRequest.circuitIdentityCode := omit;
3178 ass_cmd.pdu.bssmap.assignmentRequest.aoIPTransportLayer := omit;
3179 exp_compl.pdu.bssmap.assignmentComplete.circuitIdentityCode := omit;
3180 exp_compl.pdu.bssmap.assignmentComplete.aoIPTransportLayer := omit;
Harald Welte3c86ea02018-05-10 22:28:05 +02003181
Philipp Maier23000732018-05-18 11:25:37 +02003182 f_establish_fully(ass_cmd, exp_compl);
Harald Welte3c86ea02018-05-10 22:28:05 +02003183}
3184testcase TC_ciph_mode_a5_0() runs on test_CT {
3185 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02003186 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte3c86ea02018-05-10 22:28:05 +02003187 pars.encr := valueof(t_EncrParams('01'O, f_rnd_octstring(8)));
3188
3189 f_init(1, true);
3190 f_sleep(1.0);
3191 vc_conn := f_start_handler(refers(f_tc_ciph_mode_a5), pars);
3192 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003193 f_shutdown_helper();
Harald Welte3c86ea02018-05-10 22:28:05 +02003194}
3195testcase TC_ciph_mode_a5_1() runs on test_CT {
3196 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02003197 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte3c86ea02018-05-10 22:28:05 +02003198 pars.encr := valueof(t_EncrParams('02'O, f_rnd_octstring(8)));
3199
3200 f_init(1, true);
3201 f_sleep(1.0);
3202 vc_conn := f_start_handler(refers(f_tc_ciph_mode_a5), pars);
3203 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003204 f_shutdown_helper();
Harald Welte3c86ea02018-05-10 22:28:05 +02003205}
3206testcase TC_ciph_mode_a5_3() runs on test_CT {
3207 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02003208 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte3c86ea02018-05-10 22:28:05 +02003209 pars.encr := valueof(t_EncrParams('08'O, f_rnd_octstring(8)));
3210
3211 f_init(1, true);
3212 f_sleep(1.0);
3213 vc_conn := f_start_handler(refers(f_tc_ciph_mode_a5), pars);
3214 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003215 f_shutdown_helper();
Harald Welte3c86ea02018-05-10 22:28:05 +02003216}
3217
Pau Espin Pedrol07866632020-09-03 19:10:55 +02003218/* establish initial channel, enable ciphering followed by assignment to ciphered channel */
3219private function f_tc_assignment_aoip_tla_v6(charstring id) runs on MSC_ConnHdlr {
3220 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3221 var PDU_BSSAP ass_cmd := f_gen_ass_req(aoip_tla := "::3");
3222 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3223 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
3224
3225 f_establish_fully(ass_cmd, exp_compl);
3226}
3227testcase TC_assignment_aoip_tla_v6() runs on test_CT {
3228 var MSC_ConnHdlr vc_conn;
3229 var TestHdlrParams pars := f_gen_test_hdlr_pars();
3230
3231 f_init(1, true);
3232 f_sleep(1.0);
3233 vc_conn := f_start_handler(refers(f_tc_assignment_aoip_tla_v6), pars);
3234 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003235 f_shutdown_helper();
Pau Espin Pedrol07866632020-09-03 19:10:55 +02003236}
3237
Harald Welte3c86ea02018-05-10 22:28:05 +02003238
3239/* establish initial channel, enable ciphering followed by assignment to ciphered channel */
Harald Welte651fcdc2018-05-10 20:23:16 +02003240private function f_tc_assignment_fr_a5(charstring id) runs on MSC_ConnHdlr {
Harald Welteed848512018-05-24 22:27:58 +02003241 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3242 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Weltec1a2fff2017-12-17 11:06:19 +01003243
Harald Welte552620d2017-12-16 23:21:36 +01003244 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3245 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
Harald Welte73cd2712017-12-17 00:44:52 +01003246
Harald Weltea0630032018-03-20 21:09:55 +01003247 f_establish_fully(ass_cmd, exp_compl);
Harald Welte552620d2017-12-16 23:21:36 +01003248}
Harald Welte552620d2017-12-16 23:21:36 +01003249testcase TC_assignment_fr_a5_0() runs on test_CT {
3250 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02003251 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte651fcdc2018-05-10 20:23:16 +02003252 pars.encr := valueof(t_EncrParams('01'O, f_rnd_octstring(8)));
Harald Welte552620d2017-12-16 23:21:36 +01003253
Harald Welte89d42e82017-12-17 16:42:41 +01003254 f_init(1, true);
Harald Welte552620d2017-12-16 23:21:36 +01003255 f_sleep(1.0);
Harald Welte651fcdc2018-05-10 20:23:16 +02003256 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5), pars);
Harald Welte552620d2017-12-16 23:21:36 +01003257 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003258 f_shutdown_helper();
Harald Welte552620d2017-12-16 23:21:36 +01003259}
Harald Welte552620d2017-12-16 23:21:36 +01003260testcase TC_assignment_fr_a5_1() runs on test_CT {
Harald Weltec1a2fff2017-12-17 11:06:19 +01003261 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02003262 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte651fcdc2018-05-10 20:23:16 +02003263 pars.encr := valueof(t_EncrParams('02'O, f_rnd_octstring(8)));
Harald Weltec1a2fff2017-12-17 11:06:19 +01003264
Harald Welte89d42e82017-12-17 16:42:41 +01003265 f_init(1, true);
Harald Weltec1a2fff2017-12-17 11:06:19 +01003266 f_sleep(1.0);
Harald Welte651fcdc2018-05-10 20:23:16 +02003267 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5), pars);
3268 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003269 f_shutdown_helper();
Harald Welte651fcdc2018-05-10 20:23:16 +02003270}
3271testcase TC_assignment_fr_a5_3() runs on test_CT {
3272 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02003273 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte651fcdc2018-05-10 20:23:16 +02003274 pars.encr := valueof(t_EncrParams('08'O, f_rnd_octstring(8)));
Harald Weltec1a2fff2017-12-17 11:06:19 +01003275
Harald Welte651fcdc2018-05-10 20:23:16 +02003276 f_init(1, true);
3277 f_sleep(1.0);
3278 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5), pars);
Harald Weltec1a2fff2017-12-17 11:06:19 +01003279 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003280 f_shutdown_helper();
Harald Weltec1a2fff2017-12-17 11:06:19 +01003281}
3282
Harald Welte552620d2017-12-16 23:21:36 +01003283/* Expect ASSIGNMENT FAIL if mandatory IE is missing */
3284private function f_tc_assignment_fr_a5_1_codec_missing(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02003285 g_pars := f_gen_test_hdlr_pars();
Harald Welte552620d2017-12-16 23:21:36 +01003286 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
Harald Welteed848512018-05-24 22:27:58 +02003287 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte552620d2017-12-16 23:21:36 +01003288 const OCT8 kc := '0001020304050607'O;
3289
3290 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02003291 /* Omit: ass_cmd.pdu.bssmap.assignmentRequest.codecList */
3292
Harald Weltea0630032018-03-20 21:09:55 +01003293 f_establish_fully(ass_cmd, exp_fail);
Harald Welte552620d2017-12-16 23:21:36 +01003294}
Harald Welte552620d2017-12-16 23:21:36 +01003295testcase TC_assignment_fr_a5_1_codec_missing() runs on test_CT {
3296 var MSC_ConnHdlr vc_conn;
3297
Harald Welte89d42e82017-12-17 16:42:41 +01003298 f_init(1, true);
Harald Welte552620d2017-12-16 23:21:36 +01003299 f_sleep(1.0);
3300
Harald Welte8863fa12018-05-10 20:15:27 +02003301 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5_1_codec_missing));
Harald Welte552620d2017-12-16 23:21:36 +01003302 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003303 f_shutdown_helper();
Harald Welte552620d2017-12-16 23:21:36 +01003304}
3305
Harald Welte552620d2017-12-16 23:21:36 +01003306private function f_tc_assignment_fr_a5_4(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02003307 g_pars := f_gen_test_hdlr_pars();
Harald Welteed848512018-05-24 22:27:58 +02003308 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3309 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte552620d2017-12-16 23:21:36 +01003310 const OCT8 kc := '0001020304050607'O;
3311 const OCT16 kc128 := kc & kc;
3312
3313 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3314 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
Harald Weltea0630032018-03-20 21:09:55 +01003315 f_establish_fully(ass_cmd, exp_compl);
Harald Welte38b2a102017-12-23 02:42:58 +01003316 f_cipher_mode('10'O, kc, kc128, true);
Harald Welte552620d2017-12-16 23:21:36 +01003317 /* TODO: expect GSM0808_CAUSE_CIPHERING_ALGORITHM_NOT_SUPPORTED cause value */
Harald Welte552620d2017-12-16 23:21:36 +01003318}
Harald Welte552620d2017-12-16 23:21:36 +01003319testcase TC_assignment_fr_a5_4() runs on test_CT {
3320 var MSC_ConnHdlr vc_conn;
3321
Harald Welte89d42e82017-12-17 16:42:41 +01003322 f_init(1, true);
Harald Welte552620d2017-12-16 23:21:36 +01003323 f_sleep(1.0);
3324
Harald Welte8863fa12018-05-10 20:15:27 +02003325 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5_4));
Harald Welte552620d2017-12-16 23:21:36 +01003326 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003327 f_shutdown_helper();
Harald Welte552620d2017-12-16 23:21:36 +01003328}
3329
3330
Harald Welte4532e0a2017-12-23 02:05:44 +01003331private function f_tc_assignment_sign(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02003332 g_pars := f_gen_test_hdlr_pars();
Harald Welte4532e0a2017-12-23 02:05:44 +01003333 var template PDU_BSSAP exp_compl := tr_BSSMAP_AssignmentComplete(omit, omit);
Philipp Maier48604732018-10-09 15:00:37 +02003334 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte4532e0a2017-12-23 02:05:44 +01003335 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeSIGNAL);
Daniel Willmannebdecc02020-08-12 15:30:17 +02003336
3337 f_statsd_reset();
Harald Weltea0630032018-03-20 21:09:55 +01003338 f_establish_fully(ass_cmd, exp_compl);
Daniel Willmannebdecc02020-08-12 15:30:17 +02003339
3340 var StatsDExpects expect := {
Daniel Willmannc5398f72020-09-21 10:41:35 +02003341 { name := "TTCN3.bts.0.chreq.total", mtype := "c", min := 1, max := 1},
3342 { name := "TTCN3.bts.0.chreq.successful", mtype := "c", min := 1, max := 1},
Daniel Willmannebdecc02020-08-12 15:30:17 +02003343 { name := "TTCN3.bsc.0.assignment.attempted", mtype := "c", min := 1, max := 1},
3344 { name := "TTCN3.bsc.0.assignment.completed", mtype := "c", min := 1, max := 1}
3345 };
3346 f_statsd_expect(expect);
Harald Welte4532e0a2017-12-23 02:05:44 +01003347}
3348
3349testcase TC_assignment_sign() runs on test_CT {
3350 var MSC_ConnHdlr vc_conn;
3351
3352 f_init(1, true);
3353 f_sleep(1.0);
3354
Harald Welte8863fa12018-05-10 20:15:27 +02003355 vc_conn := f_start_handler(refers(f_tc_assignment_sign));
Harald Welte4532e0a2017-12-23 02:05:44 +01003356 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003357 f_shutdown_helper();
Harald Welte4532e0a2017-12-23 02:05:44 +01003358}
3359
Harald Welte60aa5762018-03-21 19:33:13 +01003360/***********************************************************************
3361 * Codec (list) testing
3362 ***********************************************************************/
3363
3364/* check if the given rsl_mode is compatible with the a_elem */
3365private function f_match_codec(BSSMAP_FIELD_CodecElement a_elem, RSL_IE_ChannelMode rsl_mode)
3366return boolean {
3367 select (a_elem.codecType) {
3368 case (GSM_FR) {
3369 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM1))) {
3370 return true;
3371 }
3372 }
3373 case (GSM_HR) {
3374 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_H, RSL_CMOD_SP_GSM1))) {
3375 return true;
3376 }
3377 }
3378 case (GSM_EFR) {
3379 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM2))) {
3380 return true;
3381 }
3382 }
3383 case (FR_AMR) {
3384 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM3))) {
3385 return true;
3386 }
3387 }
3388 case (HR_AMR) {
3389 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_H, RSL_CMOD_SP_GSM3))) {
3390 return true;
3391 }
3392 }
3393 case else { }
3394 }
3395 return false;
3396}
3397
3398/* check if the given rsl_mode is compatible with the a_list */
3399private function f_match_codecs(BSSMAP_IE_SpeechCodecList a_list, RSL_IE_ChannelMode rsl_mode)
3400return boolean {
3401 for (var integer i := 0; i < sizeof(a_list); i := i+1) {
3402 if (f_match_codec(a_list.codecElements[i], rsl_mode)) {
3403 return true;
3404 }
3405 }
3406 return false;
3407}
3408
3409/* determine BSSMAP_IE_ChannelType from *first* element of BSSMAP_FIELD_CodecElement */
Philipp Maier61f6b572018-07-06 14:03:38 +02003410function f_BSSMAP_chtype_from_codec(BSSMAP_FIELD_CodecElement a_elem)
Harald Welte60aa5762018-03-21 19:33:13 +01003411return BSSMAP_IE_ChannelType {
3412 /* FIXME: actually look at all elements of BSSMAP_IE_SpeechCodecList */
3413 var BSSMAP_IE_ChannelType ret := valueof(ts_BSSMAP_IE_ChannelType);
3414 select (a_elem.codecType) {
3415 case (GSM_FR) {
3416 ret.channelRateAndType := ChRate_TCHF;
3417 ret.speechId_DataIndicator := Spdi_TCHF_FR;
3418 }
3419 case (GSM_HR) {
3420 ret.channelRateAndType := ChRate_TCHH;
3421 ret.speechId_DataIndicator := Spdi_TCHH_HR;
3422 }
3423 case (GSM_EFR) {
3424 ret.channelRateAndType := ChRate_TCHF;
3425 ret.speechId_DataIndicator := Spdi_TCHF_EFR;
3426 }
3427 case (FR_AMR) {
3428 ret.channelRateAndType := ChRate_TCHF;
3429 ret.speechId_DataIndicator := Spdi_TCHF_AMR;
3430 }
3431 case (HR_AMR) {
3432 ret.channelRateAndType := ChRate_TCHH;
3433 ret.speechId_DataIndicator := Spdi_TCHH_AMR;
3434 }
3435 case else {
3436 setverdict(fail, "Unsupported codec ", a_elem);
Daniel Willmannafce8662018-07-06 23:11:32 +02003437 mtc.stop;
Harald Welte60aa5762018-03-21 19:33:13 +01003438 }
3439 }
3440 return ret;
3441}
3442
Harald Weltea63b9102018-03-22 20:36:16 +01003443private function f_rsl_chmod_tmpl_from_codec(BSSMAP_FIELD_CodecElement a_elem)
3444return template RSL_IE_Body {
3445 var template RSL_IE_Body mode_ie := {
3446 chan_mode := {
3447 len := ?,
3448 reserved := ?,
3449 dtx_d := ?,
3450 dtx_u := ?,
3451 spd_ind := RSL_SPDI_SPEECH,
3452 ch_rate_type := -,
3453 coding_alg_rate := -
3454 }
3455 }
3456
3457 select (a_elem.codecType) {
3458 case (GSM_FR) {
3459 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_F;
3460 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM1;
3461 }
3462 case (GSM_HR) {
3463 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_H;
3464 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM1;
3465 }
3466 case (GSM_EFR) {
3467 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_F;
3468 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM2;
3469 }
3470 case (FR_AMR) {
3471 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_F;
3472 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM3;
3473 }
3474 case (HR_AMR) {
3475 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_H;
3476 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM3;
3477 }
3478 }
3479 return mode_ie;
3480}
3481
Harald Welte60aa5762018-03-21 19:33:13 +01003482type record CodecListTest {
3483 BSSMAP_IE_SpeechCodecList codec_list,
3484 charstring id
3485}
3486type record of CodecListTest CodecListTests
3487
3488private function f_TC_assignment_codec(charstring id) runs on MSC_ConnHdlr {
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02003489 var PDU_BSSAP ass_cmd := f_gen_ass_req(g_pars.use_osmux);
3490 var template PDU_BSSAP exp_compl := f_gen_exp_compl(g_pars.use_osmux);
Harald Welte60aa5762018-03-21 19:33:13 +01003491
3492 /* puzzle together the ASSIGNMENT REQ for given codec[s] */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003493 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
Harald Welte79f3f542018-05-25 20:02:37 +02003494 ass_cmd.pdu.bssmap.assignmentRequest.codecList := g_pars.ass_codec_list;
3495 exp_compl.pdu.bssmap.assignmentComplete.speechCodec.codecElements[0] :=
3496 g_pars.ass_codec_list.codecElements[0];
Philipp Maierd0e64b02019-03-13 14:15:23 +01003497 if (isvalue(g_pars.expect_mr_s0_s7)) {
3498 exp_compl.pdu.bssmap.assignmentComplete.speechCodec.codecElements[0].s0_7 :=
3499 g_pars.expect_mr_s0_s7;
3500 }
Harald Welte79f3f542018-05-25 20:02:37 +02003501 }
Harald Welte60aa5762018-03-21 19:33:13 +01003502 ass_cmd.pdu.bssmap.assignmentRequest.channelType :=
3503 f_BSSMAP_chtype_from_codec(g_pars.ass_codec_list.codecElements[0]);
Harald Welte60aa5762018-03-21 19:33:13 +01003504 log("expecting ASS COMPL like this: ", exp_compl);
3505
3506 f_establish_fully(ass_cmd, exp_compl);
Harald Weltea63b9102018-03-22 20:36:16 +01003507
3508 /* Verify that the RSL-side activation actually matches our expectations */
3509 var RSL_Message rsl := f_rslem_get_last_act(RSL_PROC, 0, g_chan_nr);
3510
3511 var RSL_IE_Body mode_ie;
3512 if (f_rsl_find_ie(rsl, RSL_IE_CHAN_MODE, mode_ie) == false) {
3513 setverdict(fail, "Couldn't find CHAN_MODE IE");
Daniel Willmannafce8662018-07-06 23:11:32 +02003514 mtc.stop;
Harald Weltea63b9102018-03-22 20:36:16 +01003515 }
3516 var template RSL_IE_Body t_mode_ie := f_rsl_chmod_tmpl_from_codec(g_pars.ass_codec_list.codecElements[0]);
3517 if (not match(mode_ie, t_mode_ie)) {
3518 setverdict(fail, "RSL Channel Mode IE doesn't match expectation");
3519 }
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02003520
3521 var RSL_IE_Body mr_conf;
3522 if (g_pars.expect_mr_conf_ie != omit) {
3523 if (f_rsl_find_ie(rsl, RSL_IE_MR_CONFIG, mr_conf) == false) {
3524 setverdict(fail, "Missing MR CONFIG IE in RSL Chan Activ");
Daniel Willmannafce8662018-07-06 23:11:32 +02003525 mtc.stop;
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02003526 }
3527 log("found RSL MR CONFIG IE: ", mr_conf);
3528
3529 if (not match(mr_conf, g_pars.expect_mr_conf_ie)) {
3530 setverdict(fail, "RSL MR CONFIG IE does not match expectation. Expected: ",
3531 g_pars.expect_mr_conf_ie);
3532 }
3533 } else {
3534 if (f_rsl_find_ie(rsl, RSL_IE_MR_CONFIG, mr_conf) == true) {
3535 log("found RSL MR CONFIG IE: ", mr_conf);
3536 setverdict(fail, "Found MR CONFIG IE in RSL Chan Activ, expecting omit");
Daniel Willmannafce8662018-07-06 23:11:32 +02003537 mtc.stop;
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02003538 }
3539 }
Harald Welte60aa5762018-03-21 19:33:13 +01003540}
3541
Philipp Maierd0e64b02019-03-13 14:15:23 +01003542private function f_TC_assignment_codec_fail(charstring id) runs on MSC_ConnHdlr {
3543
3544 var PDU_BSSAP ass_cmd := f_gen_ass_req();
3545 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
3546
3547 /* puzzle together the ASSIGNMENT REQ for given codec[s] */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003548 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
Philipp Maierd0e64b02019-03-13 14:15:23 +01003549 ass_cmd.pdu.bssmap.assignmentRequest.codecList := g_pars.ass_codec_list;
3550 }
3551 ass_cmd.pdu.bssmap.assignmentRequest.channelType :=
3552 f_BSSMAP_chtype_from_codec(g_pars.ass_codec_list.codecElements[0]);
3553 log("expecting ASS FAIL like this: ", exp_fail);
3554
3555 f_establish_fully(ass_cmd, exp_fail);
3556}
3557
Harald Welte60aa5762018-03-21 19:33:13 +01003558testcase TC_assignment_codec_fr() runs on test_CT {
Philipp Maier48604732018-10-09 15:00:37 +02003559 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte60aa5762018-03-21 19:33:13 +01003560 var MSC_ConnHdlr vc_conn;
3561
3562 f_init(1, true);
3563 f_sleep(1.0);
3564
3565 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
Harald Welte8863fa12018-05-10 20:15:27 +02003566 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01003567 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003568 f_shutdown_helper();
Harald Welte60aa5762018-03-21 19:33:13 +01003569}
3570
3571testcase TC_assignment_codec_hr() runs on test_CT {
Philipp Maier48604732018-10-09 15:00:37 +02003572 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte60aa5762018-03-21 19:33:13 +01003573 var MSC_ConnHdlr vc_conn;
3574
3575 f_init(1, true);
3576 f_sleep(1.0);
3577
3578 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR}));
Harald Welte8863fa12018-05-10 20:15:27 +02003579 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01003580 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003581 f_shutdown_helper();
Harald Welte60aa5762018-03-21 19:33:13 +01003582}
3583
3584testcase TC_assignment_codec_efr() runs on test_CT {
Philipp Maier48604732018-10-09 15:00:37 +02003585 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte60aa5762018-03-21 19:33:13 +01003586 var MSC_ConnHdlr vc_conn;
3587
3588 f_init(1, true);
3589 f_sleep(1.0);
3590
3591 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecEFR}));
Harald Welte8863fa12018-05-10 20:15:27 +02003592 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01003593 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003594 f_shutdown_helper();
Harald Welte60aa5762018-03-21 19:33:13 +01003595}
3596
Philipp Maierd0e64b02019-03-13 14:15:23 +01003597/* Allow 5,90k only (current default config) */
3598private function f_allow_amr_rate_5_90k() runs on test_CT {
3599 f_vty_enter_cfg_msc(BSCVTY, 0);
3600 f_vty_transceive(BSCVTY, "amr-config 12_2k forbidden");
3601 f_vty_transceive(BSCVTY, "amr-config 10_2k forbidden");
3602 f_vty_transceive(BSCVTY, "amr-config 7_95k forbidden");
3603 f_vty_transceive(BSCVTY, "amr-config 7_40k forbidden");
3604 f_vty_transceive(BSCVTY, "amr-config 6_70k forbidden");
3605 f_vty_transceive(BSCVTY, "amr-config 5_90k allowed");
3606 f_vty_transceive(BSCVTY, "amr-config 5_15k forbidden");
3607 f_vty_transceive(BSCVTY, "amr-config 4_75k forbidden");
3608 f_vty_transceive(BSCVTY, "exit");
3609 f_vty_transceive(BSCVTY, "exit");
3610}
3611
3612/* Allow 4,75k, 5,90k, 4,70k and 12,2k, which are the most common rates
3613 * ("Config-NB-Code = 1") */
3614private function f_allow_amr_rate_4_75k_5_90k_7_40k_12_20k() runs on test_CT {
3615 f_vty_enter_cfg_msc(BSCVTY, 0);
3616 f_vty_transceive(BSCVTY, "amr-config 12_2k allowed");
3617 f_vty_transceive(BSCVTY, "amr-config 10_2k forbidden");
3618 f_vty_transceive(BSCVTY, "amr-config 7_95k forbidden");
3619 f_vty_transceive(BSCVTY, "amr-config 7_40k allowed");
3620 f_vty_transceive(BSCVTY, "amr-config 6_70k forbidden");
3621 f_vty_transceive(BSCVTY, "amr-config 5_90k allowed");
3622 f_vty_transceive(BSCVTY, "amr-config 5_15k forbidden");
3623 f_vty_transceive(BSCVTY, "amr-config 4_75k allowed");
3624 f_vty_transceive(BSCVTY, "exit");
3625 f_vty_transceive(BSCVTY, "exit");
3626}
3627
Harald Welte60aa5762018-03-21 19:33:13 +01003628testcase TC_assignment_codec_amr_f() runs on test_CT {
Philipp Maier48604732018-10-09 15:00:37 +02003629 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte60aa5762018-03-21 19:33:13 +01003630 var MSC_ConnHdlr vc_conn;
Philipp Maier7695a0d2018-09-27 17:52:14 +02003631
3632 /* Note: This setups the codec configuration. The parameter payload in
3633 * mr_conf must be consistant with the parameter codecElements in pars
3634 * and also must match the amr-config in osmo-bsc.cfg! */
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02003635 var RSL_IE_Body mr_conf := {
3636 other := {
3637 len := 2,
3638 payload := '2804'O
3639 }
3640 };
Harald Welte60aa5762018-03-21 19:33:13 +01003641
Philipp Maier7695a0d2018-09-27 17:52:14 +02003642 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_F}));
Philipp Maier806f8f12019-03-12 12:13:41 +01003643 pars.ass_codec_list.codecElements[0].s0_7 := '00000100'B; /* 5,90k */
Philipp Maier7695a0d2018-09-27 17:52:14 +02003644 pars.ass_codec_list.codecElements[0].s8_15 := '01010111'B;
3645 pars.expect_mr_conf_ie := mr_conf;
3646
Harald Welte60aa5762018-03-21 19:33:13 +01003647 f_init(1, true);
3648 f_sleep(1.0);
3649
Harald Welte8863fa12018-05-10 20:15:27 +02003650 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01003651 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003652 f_shutdown_helper();
Harald Welte60aa5762018-03-21 19:33:13 +01003653}
3654
3655testcase TC_assignment_codec_amr_h() runs on test_CT {
Philipp Maier48604732018-10-09 15:00:37 +02003656 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte60aa5762018-03-21 19:33:13 +01003657 var MSC_ConnHdlr vc_conn;
Philipp Maier7695a0d2018-09-27 17:52:14 +02003658
3659 /* See note above */
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02003660 var RSL_IE_Body mr_conf := {
3661 other := {
3662 len := 2,
3663 payload := '2804'O
3664 }
3665 };
Harald Welte60aa5762018-03-21 19:33:13 +01003666
Philipp Maier7695a0d2018-09-27 17:52:14 +02003667 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_H}));
Philipp Maier806f8f12019-03-12 12:13:41 +01003668 pars.ass_codec_list.codecElements[0].s0_7 := '00000100'B; /* 5,90k */
Philipp Maier7695a0d2018-09-27 17:52:14 +02003669 pars.ass_codec_list.codecElements[0].s8_15 := '00000111'B;
3670 pars.expect_mr_conf_ie := mr_conf;
3671
Harald Welte60aa5762018-03-21 19:33:13 +01003672 f_init(1, true);
3673 f_sleep(1.0);
3674
Harald Welte8863fa12018-05-10 20:15:27 +02003675 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01003676 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003677 f_shutdown_helper();
Harald Welte60aa5762018-03-21 19:33:13 +01003678}
3679
Philipp Maierd0e64b02019-03-13 14:15:23 +01003680function f_TC_assignment_codec_amr(boolean fr, octetstring mrconf, bitstring s8_s0, bitstring exp_s8_s0)
3681runs on test_CT {
3682
3683 var TestHdlrParams pars := f_gen_test_hdlr_pars();
3684 var MSC_ConnHdlr vc_conn;
3685
3686 /* See note above */
3687 var RSL_IE_Body mr_conf := {
3688 other := {
3689 len := lengthof(mrconf),
3690 payload := mrconf
3691 }
3692 };
3693
3694 if (fr) {
3695 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_F}));
3696 } else {
3697 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_H}));
3698 }
3699 pars.ass_codec_list.codecElements[0].s0_7 := s8_s0;
3700 pars.ass_codec_list.codecElements[0].s8_15 := '00000111'B;
3701 pars.expect_mr_conf_ie := mr_conf;
3702 pars.expect_mr_s0_s7 := exp_s8_s0;
3703
3704 f_init(1, true);
3705 f_allow_amr_rate_4_75k_5_90k_7_40k_12_20k();
3706 f_sleep(1.0);
3707
3708 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
3709 vc_conn.done;
3710 f_allow_amr_rate_5_90k();
3711}
3712
3713function f_TC_assignment_codec_amr_fail(boolean fr, bitstring s8_s0)
3714runs on test_CT {
3715
3716 var TestHdlrParams pars := f_gen_test_hdlr_pars();
3717 var MSC_ConnHdlr vc_conn;
3718
3719 if (fr) {
3720 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_F}));
3721 } else {
3722 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_H}));
3723 }
3724 pars.ass_codec_list.codecElements[0].s0_7 := s8_s0;
3725 pars.ass_codec_list.codecElements[0].s8_15 := '00000111'B;
3726
3727 f_init(1, true);
3728 f_allow_amr_rate_4_75k_5_90k_7_40k_12_20k();
3729 f_sleep(1.0);
3730
3731 vc_conn := f_start_handler(refers(f_TC_assignment_codec_fail), pars);
3732 vc_conn.done;
3733 f_allow_amr_rate_5_90k();
3734}
3735
3736
3737/* Set S1, we expect an AMR multirate configuration IE with all four rates
3738 * set. */
3739testcase TC_assignment_codec_amr_f_S1() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003740 f_TC_assignment_codec_amr(true, '289520882208'O, '00000010'B, '00000010'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003741 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003742}
3743
3744/* Set S1, we expect an AMR multirate configuration IE with the lower three
3745 * rates set. */
3746testcase TC_assignment_codec_amr_h_S1() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003747 f_TC_assignment_codec_amr(false, '2815208820'O, '00000010'B, '00000010'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003748 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003749}
3750
3751/* Set S1 and two other rates, we expect an AMR MULTIRATE CONFIGURATION IE with
3752 * all four rates (and only S1 set in the ASSIGNMENT COMPLETE) */
3753testcase TC_assignment_codec_amr_f_S124() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003754 f_TC_assignment_codec_amr(true, '289520882208'O, '00010110'B, '00000010'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003755 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003756}
3757
3758/* Set S1 and two other rates, we expect an AMR MULTIRATE CONFIGURATION IE with
3759 * all four rates (and only S1 set in the ASSIGNMENT COMPLETE) */
3760testcase TC_assignment_codec_amr_h_S124() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003761 f_TC_assignment_codec_amr(false, '2815208820'O, '00010110'B, '00000010'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003762 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003763}
3764
3765/* The following block of tests selects more and more rates until all four
3766 * possible rates are in the active set (full rate) */
3767testcase TC_assignment_codec_amr_f_S0() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003768 f_TC_assignment_codec_amr(true, '2801'O, '00000001'B, '00000001'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003769 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003770}
3771
3772testcase TC_assignment_codec_amr_f_S02() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003773 f_TC_assignment_codec_amr(true, '28052080'O, '00000101'B, '00000101'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_S024() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003778 f_TC_assignment_codec_amr(true, '2815208820'O, '00010101'B, '00010101'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_S0247() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003783 f_TC_assignment_codec_amr(true, '289520882208'O, '10010101'B, '10010101'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003784 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003785}
3786
3787/* The following block of tests selects more and more rates until all three
3788 * possible rates are in the active set (half rate) */
3789testcase TC_assignment_codec_amr_h_S0() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003790 f_TC_assignment_codec_amr(false, '2801'O, '00000001'B, '00000001'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003791 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003792}
3793
3794testcase TC_assignment_codec_amr_h_S02() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003795 f_TC_assignment_codec_amr(false, '28052080'O, '00000101'B, '00000101'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_S024() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003800 f_TC_assignment_codec_amr(false, '2815208820'O, '00010101'B, '00010101'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003801 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003802}
3803
3804/* The following block tests what happens when the MSC does offer rate
3805 * configurations that are not supported by the BSC. Normally such situations
3806 * should not happen because the MSC gets informed by the BSC in advance via
3807 * the L3 COMPLETE message which rates are applicable. The MSC should not try
3808 * to offer rates that are not applicable anyway. */
3809
3810testcase TC_assignment_codec_amr_h_S0247() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003811 /* Try to include 12,2k in into the active set even though the channel
3812 * is half rate only. The BSC is expected to remove the 12,0k */
3813 f_TC_assignment_codec_amr(false, '2815208820'O, '10010101'B, '00010101'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003814 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003815}
3816
3817testcase TC_assignment_codec_amr_f_S01234567() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003818 /* See what happens when all rates are selected at once. Since then
3819 * Also S1 is selected, this setting will be prefered and we should
3820 * get 12.2k, 7,40k, 5,90k, and 4,75k in the active set. */
3821 f_TC_assignment_codec_amr(true, '289520882208'O, '11111111'B, '00000010'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003822 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003823}
3824
3825testcase TC_assignment_codec_amr_f_S0234567() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003826 /* Same as above, but with S1 missing, the MSC is then expected to
3827 * select the currently supported rates, which are also 12.2k, 7,40k,
3828 * 5,90k, and 4,75k, into the active set. */
3829 f_TC_assignment_codec_amr(true, '289520882208'O, '11111101'B, '10010101'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003830 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003831}
3832
3833testcase TC_assignment_codec_amr_f_zero() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003834 /* Try to select no rates at all */
3835 f_TC_assignment_codec_amr_fail(true, '00000000'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003836 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003837}
3838
3839testcase TC_assignment_codec_amr_f_unsupp() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003840 /* Try to select only unsupported rates */
3841 f_TC_assignment_codec_amr_fail(true, '01101000'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003842 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003843}
3844
3845testcase TC_assignment_codec_amr_h_S7() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003846 /* Try to select 12,2k for half rate */
3847 f_TC_assignment_codec_amr_fail(false, '10000000'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003848 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003849}
3850
Philipp Maierac09bfc2019-01-08 13:41:39 +01003851private function f_disable_all_tch_f() runs on test_CT {
Philipp Maierc704a882019-01-29 15:58:52 +01003852 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 1 sub-slot 0 borken");
3853 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 2 sub-slot 0 borken");
3854 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 3 sub-slot 0 borken");
3855 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 4 sub-slot 0 borken");
Philipp Maierac09bfc2019-01-08 13:41:39 +01003856}
3857
3858private function f_disable_all_tch_h() runs on test_CT {
Philipp Maierc704a882019-01-29 15:58:52 +01003859 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 5 sub-slot 0 borken");
3860 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 5 sub-slot 1 borken");
Philipp Maierac09bfc2019-01-08 13:41:39 +01003861}
3862
3863private function f_enable_all_tch() runs on test_CT {
Philipp Maierc704a882019-01-29 15:58:52 +01003864 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 1 sub-slot 0 unused");
3865 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 2 sub-slot 0 unused");
3866 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 3 sub-slot 0 unused");
3867 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 4 sub-slot 0 unused");
3868 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 5 sub-slot 0 unused");
3869 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 5 sub-slot 1 unused");
Philipp Maierac09bfc2019-01-08 13:41:39 +01003870}
3871
3872/* Allow HR only */
3873private function f_TC_assignment_codec_xr_exhausted_req_hr(charstring id) runs on MSC_ConnHdlr {
3874 g_pars := f_gen_test_hdlr_pars();
3875 var PDU_BSSAP ass_cmd := f_gen_ass_req();
3876 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3877 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3878 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '09'O;
3879 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '05'O;
3880 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR}));
3881 f_establish_fully(ass_cmd, exp_compl);
3882}
3883
3884/* Allow FR only */
3885private function f_TC_assignment_codec_xr_exhausted_req_fr(charstring id) runs on MSC_ConnHdlr {
3886 g_pars := f_gen_test_hdlr_pars();
3887 var PDU_BSSAP ass_cmd := f_gen_ass_req();
3888 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3889 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3890 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '08'O;
3891 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '01'O;
3892 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
3893 f_establish_fully(ass_cmd, exp_compl);
3894}
3895
3896/* Allow HR only (expect assignment failure) */
3897private function f_TC_assignment_codec_xr_exhausted_req_hr_fail(charstring id) runs on MSC_ConnHdlr {
3898 g_pars := f_gen_test_hdlr_pars();
3899 var PDU_BSSAP ass_cmd := f_gen_ass_req();
3900 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
3901 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3902 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '09'O;
3903 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '05'O;
3904 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR}));
3905 f_establish_fully(ass_cmd, exp_fail);
3906}
3907
3908/* Allow FR only (expect assignment failure) */
3909private function f_TC_assignment_codec_xr_exhausted_req_fr_fail(charstring id) runs on MSC_ConnHdlr {
3910 g_pars := f_gen_test_hdlr_pars();
3911 var PDU_BSSAP ass_cmd := f_gen_ass_req();
3912 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
3913 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3914 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '08'O;
3915 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '01'O;
3916 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
3917 f_establish_fully(ass_cmd, exp_fail);
3918}
3919
3920/* Allow FR and HR, but prefer FR */
3921private function f_TC_assignment_codec_fr_exhausted_req_fr_hr(charstring id) runs on MSC_ConnHdlr {
3922 g_pars := f_gen_test_hdlr_pars();
3923 var PDU_BSSAP ass_cmd := f_gen_ass_req();
3924 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3925 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3926 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0A'O; /* Prefer FR */
3927 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8105'O;
3928 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR, ts_CodecHR}));
3929 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000101'B; /* Expect HR */
3930 f_establish_fully(ass_cmd, exp_compl);
3931}
3932
3933/* Allow FR and HR, but prefer HR */
3934private function f_TC_assignment_codec_fr_exhausted_req_hr_fr(charstring id) runs on MSC_ConnHdlr {
3935 g_pars := f_gen_test_hdlr_pars();
3936 var PDU_BSSAP ass_cmd := f_gen_ass_req();
3937 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3938 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3939 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0B'O; /* Prefer HR */
3940 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8501'O;
3941 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR, ts_CodecFR}));
3942 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000101'B; /* Expect HR */
3943 f_establish_fully(ass_cmd, exp_compl);
3944}
3945
3946/* Allow FR and HR, but prefer FR */
3947private function f_TC_assignment_codec_hr_exhausted_req_fr_hr(charstring id) runs on MSC_ConnHdlr {
3948 g_pars := f_gen_test_hdlr_pars();
3949 var PDU_BSSAP ass_cmd := f_gen_ass_req();
3950 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3951 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3952 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0A'O; /* Prefer FR */
3953 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8105'O;
3954 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR, ts_CodecHR}));
3955 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000001'B; /* Expect FR */
3956 f_establish_fully(ass_cmd, exp_compl);
3957}
3958
3959/* Allow FR and HR, but prefer HR */
3960private function f_TC_assignment_codec_hr_exhausted_req_hr_fr(charstring id) runs on MSC_ConnHdlr {
3961 g_pars := f_gen_test_hdlr_pars();
3962 var PDU_BSSAP ass_cmd := f_gen_ass_req();
3963 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3964 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3965 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0B'O; /* Prefer HR */
3966 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8501'O;
3967 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR, ts_CodecFR}));
3968 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000001'B; /* Expect FR */
3969 f_establish_fully(ass_cmd, exp_compl);
3970}
3971
3972/* Request a HR channel while all FR channels are exhausted, this is expected
3973 * to work without conflicts */
3974testcase TC_assignment_codec_fr_exhausted_req_hr() runs on test_CT {
3975 var MSC_ConnHdlr vc_conn;
3976 f_init(1, true);
3977 f_sleep(1.0);
3978 f_enable_all_tch();
3979 f_disable_all_tch_f();
3980 vc_conn := f_start_handler(refers(f_TC_assignment_codec_xr_exhausted_req_hr));
3981 vc_conn.done;
3982 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003983 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01003984}
3985
3986/* Request a FR channel while all FR channels are exhausted, this is expected
3987 * to fail. */
3988testcase TC_assignment_codec_fr_exhausted_req_fr() runs on test_CT {
3989 var MSC_ConnHdlr vc_conn;
3990 f_init(1, true);
3991 f_sleep(1.0);
3992 f_enable_all_tch();
3993 f_disable_all_tch_f();
3994 vc_conn := f_start_handler(refers(f_TC_assignment_codec_xr_exhausted_req_fr_fail));
3995 vc_conn.done;
3996 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003997 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01003998}
3999
4000/* Request a FR (prefered) or alternatively a HR channel while all FR channels
4001 * are exhausted, this is expected to be resolved by selecting a HR channel. */
4002testcase TC_assignment_codec_fr_exhausted_req_fr_hr() runs on test_CT {
4003 var MSC_ConnHdlr vc_conn;
4004 f_init(1, true);
4005 f_sleep(1.0);
4006 f_enable_all_tch();
4007 f_disable_all_tch_f();
4008 vc_conn := f_start_handler(refers(f_TC_assignment_codec_fr_exhausted_req_fr_hr));
4009 vc_conn.done;
4010 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004011 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004012}
4013
4014/* Request a HR (prefered) or alternatively a FR channel while all FR channels
4015 * are exhausted, this is expected to work without conflicts. */
4016testcase TC_assignment_codec_fr_exhausted_req_hr_fr() runs on test_CT {
4017 var MSC_ConnHdlr vc_conn;
4018 f_init(1, true);
4019 f_sleep(1.0);
4020 f_enable_all_tch();
4021 f_disable_all_tch_f();
4022 vc_conn := f_start_handler(refers(f_TC_assignment_codec_fr_exhausted_req_hr_fr));
4023 vc_conn.done;
4024 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004025 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004026}
4027
4028/* Request a FR channel while all HR channels are exhausted, this is expected
4029 * to work without conflicts */
4030testcase TC_assignment_codec_hr_exhausted_req_fr() runs on test_CT {
4031 var MSC_ConnHdlr vc_conn;
4032 f_init(1, true);
4033 f_sleep(1.0);
4034 f_enable_all_tch();
4035 f_disable_all_tch_h();
4036 vc_conn := f_start_handler(refers(f_TC_assignment_codec_xr_exhausted_req_fr));
4037 vc_conn.done;
4038 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004039 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004040}
4041
4042/* Request a HR channel while all HR channels are exhausted, this is expected
4043 * to fail. */
4044testcase TC_assignment_codec_hr_exhausted_req_hr() runs on test_CT {
4045 var MSC_ConnHdlr vc_conn;
4046 f_init(1, true);
4047 f_sleep(1.0);
4048 f_enable_all_tch();
4049 f_disable_all_tch_h();
4050 vc_conn := f_start_handler(refers(f_TC_assignment_codec_xr_exhausted_req_hr_fail));
4051 vc_conn.done;
4052 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004053 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004054}
4055
4056/* Request a HR (prefered) or alternatively a FR channel while all HR channels
4057 * are exhausted, this is expected to be resolved by selecting a FR channel. */
4058testcase TC_assignment_codec_hr_exhausted_req_hr_fr() runs on test_CT {
4059 var MSC_ConnHdlr vc_conn;
4060 f_init(1, true);
4061 f_sleep(1.0);
4062 f_enable_all_tch();
4063 f_disable_all_tch_h();
4064 vc_conn := f_start_handler(refers(f_TC_assignment_codec_hr_exhausted_req_hr_fr));
4065 vc_conn.done;
4066 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004067 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004068}
4069
4070/* Request a FR (prefered) or alternatively a HR channel while all HR channels
4071 * are exhausted, this is expected to work without conflicts. */
4072testcase TC_assignment_codec_hr_exhausted_req_fr_hr() runs on test_CT {
4073 var MSC_ConnHdlr vc_conn;
4074 f_init(1, true);
4075 f_sleep(1.0);
4076 f_enable_all_tch();
4077 f_disable_all_tch_h();
4078 vc_conn := f_start_handler(refers(f_TC_assignment_codec_hr_exhausted_req_fr_hr));
4079 vc_conn.done;
4080 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004081 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004082}
4083
4084/* Allow FR and HR, but prefer HR */
4085private function f_TC_assignment_codec_req_hr_fr(charstring id) runs on MSC_ConnHdlr {
4086 g_pars := f_gen_test_hdlr_pars();
4087 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4088 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4089 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4090 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0B'O; /* Prefer HR */
4091 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8501'O;
4092 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR, ts_CodecFR}));
4093 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000101'B; /* Expect HR */
4094 f_establish_fully(ass_cmd, exp_compl);
4095}
4096
4097/* Allow FR and HR, but prefer FR */
4098private function f_TC_assignment_codec_req_fr_hr(charstring id) runs on MSC_ConnHdlr {
4099 g_pars := f_gen_test_hdlr_pars();
4100 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4101 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4102 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4103 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0A'O; /* Prefer FR */
4104 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8105'O;
4105 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR, ts_CodecHR}));
4106 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000001'B; /* Expect FR */
4107 f_establish_fully(ass_cmd, exp_compl);
4108}
4109
4110/* Request a HR (prefered) or alternatively a FR channel, it is expected that
4111 * HR, which is the prefered type, is selected. */
4112testcase TC_assignment_codec_req_hr_fr() runs on test_CT {
4113 var MSC_ConnHdlr vc_conn;
4114 f_init(1, true);
4115 f_sleep(1.0);
4116 f_enable_all_tch();
4117 vc_conn := f_start_handler(refers(f_TC_assignment_codec_req_hr_fr));
4118 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004119 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004120}
4121
4122/* Request a FR (prefered) or alternatively a HR channel, it is expected that
4123 * FR, which is the prefered type, is selected. */
4124testcase TC_assignment_codec_req_fr_hr() runs on test_CT {
4125 var MSC_ConnHdlr vc_conn;
4126 f_init(1, true);
4127 f_sleep(1.0);
4128 f_enable_all_tch();
4129 vc_conn := f_start_handler(refers(f_TC_assignment_codec_req_fr_hr));
4130 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004131 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004132}
4133
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02004134testcase TC_assignment_osmux() runs on test_CT {
4135 var TestHdlrParams pars := f_gen_test_hdlr_pars();
4136 var MSC_ConnHdlr vc_conn;
4137
4138 /* See note above */
4139 var RSL_IE_Body mr_conf := {
4140 other := {
4141 len := 2,
4142 payload := '2804'O
4143 }
4144 };
4145
4146 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_H}));
4147 pars.ass_codec_list.codecElements[0].s0_7 := '00000100'B; /* 5,90k */
4148 pars.ass_codec_list.codecElements[0].s8_15 := '00000111'B;
4149 pars.expect_mr_conf_ie := mr_conf;
4150 pars.use_osmux := true;
4151
4152 f_init(1, true, true);
4153 f_sleep(1.0);
4154
4155 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
4156 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004157 f_shutdown_helper();
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02004158}
4159
Neels Hofmeyr92b12b72018-09-18 14:30:23 +02004160/* test the procedure of the MSC requesting a Classmark Update:
4161 * a) BSSMAP Classmark Request should result in RR CLASSMARK ENQUIRY,
4162 * b) L3 RR CLASSMARK CHANGE should result in BSSMAP CLASSMARK UPDATE */
Harald Welte898113b2018-01-31 18:32:21 +01004163private function f_tc_classmark(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02004164 g_pars := f_gen_test_hdlr_pars();
4165
Harald Weltea0630032018-03-20 21:09:55 +01004166 f_create_chan_and_exp();
Harald Welte898113b2018-01-31 18:32:21 +01004167 /* we should now have a COMPL_L3 at the MSC */
4168 BSSAP.receive(tr_BSSMAP_ComplL3);
4169
Neels Hofmeyr92b12b72018-09-18 14:30:23 +02004170 BSSAP.send(ts_BSSMAP_ClassmarkRequest);
4171 RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_CM_ENQUIRY));
4172
Harald Welte898113b2018-01-31 18:32:21 +01004173 f_rsl_send_l3(ts_RRM_CM_CHG(valueof(ts_CM2)));
4174 BSSAP.receive(tr_BSSMAP_ClassmarkUpd(?, omit));
4175 setverdict(pass);
4176}
4177testcase TC_classmark() runs on test_CT {
4178 var MSC_ConnHdlr vc_conn;
4179 f_init(1, true);
4180 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02004181 vc_conn := f_start_handler(refers(f_tc_classmark));
Harald Welte898113b2018-01-31 18:32:21 +01004182 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004183 f_shutdown_helper();
Harald Welte898113b2018-01-31 18:32:21 +01004184}
4185
Harald Welteeddf0e92020-06-21 19:42:15 +02004186/* Send a CommonID from the simulated MSC and verify that the information is used to
4187 * fill BSC-internal data structures (specifically, bsc_subscr associated with subscr_conn) */
4188private function f_tc_common_id(charstring id) runs on MSC_ConnHdlr {
4189 g_pars := f_gen_test_hdlr_pars();
4190 f_MscConnHdlr_init_vty();
4191
4192 f_create_chan_and_exp();
4193 /* we should now have a COMPL_L3 at the MSC */
4194 BSSAP.receive(tr_BSSMAP_ComplL3);
4195
4196 /* Send CommonID */
4197 BSSAP.send(ts_BSSMAP_CommonId(g_pars.imsi));
4198
4199 /* Use VTY to verify that the IMSI of the subscr_conn is set */
4200 var charstring regex := "*(IMSI: " & hex2str(g_pars.imsi) & ")*";
4201 f_vty_transceive_match_regexp_retry(BSCVTY, "show conns", regex, 0, 4, 1.0);
4202
4203 setverdict(pass);
4204}
4205testcase TC_common_id() runs on test_CT {
4206 var MSC_ConnHdlr vc_conn;
4207 f_init(1, true);
4208 f_sleep(1.0);
4209 vc_conn := f_start_handler(refers(f_tc_common_id));
4210 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004211 f_shutdown_helper();
Harald Welteeddf0e92020-06-21 19:42:15 +02004212}
4213
Harald Weltee3bd6582018-01-31 22:51:25 +01004214private function f_est_single_l3(template PDU_ML3_MS_NW l3) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02004215 g_pars := f_gen_test_hdlr_pars();
Harald Weltea0630032018-03-20 21:09:55 +01004216 f_create_chan_and_exp();
Harald Welte898113b2018-01-31 18:32:21 +01004217 /* we should now have a COMPL_L3 at the MSC */
4218 BSSAP.receive(tr_BSSMAP_ComplL3);
4219
Harald Weltee3bd6582018-01-31 22:51:25 +01004220 /* send the single message we want to send */
4221 f_rsl_send_l3(l3);
4222}
4223
4224private function f_bssap_expect_nothing(float sec := 5.00) runs on MSC_ConnHdlr {
4225 timer T := sec;
4226 var PDU_BSSAP bssap;
Harald Welte898113b2018-01-31 18:32:21 +01004227 T.start;
4228 alt {
Harald Weltee3bd6582018-01-31 22:51:25 +01004229 [] BSSAP.receive(PDU_BSSAP:?) -> value bssap {
4230 setverdict(fail, "Unexpected BSSMAP ", bssap);
Daniel Willmannafce8662018-07-06 23:11:32 +02004231 mtc.stop;
Harald Welte898113b2018-01-31 18:32:21 +01004232 }
4233 [] T.timeout {
4234 setverdict(pass);
4235 }
4236 }
4237}
4238
Harald Weltee3bd6582018-01-31 22:51:25 +01004239/* unsolicited ASSIGNMENT FAIL (without ASSIGN) from MS shouldn't bring BSC down */
4240private function f_tc_unsol_ass_fail(charstring id) runs on MSC_ConnHdlr {
4241 f_est_single_l3(ts_RRM_AssignmentFailure('00'O));
4242 f_bssap_expect_nothing();
4243}
Harald Welte898113b2018-01-31 18:32:21 +01004244testcase TC_unsol_ass_fail() runs on test_CT {
4245 var MSC_ConnHdlr vc_conn;
4246 f_init(1, true);
4247 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02004248 vc_conn := f_start_handler(refers(f_tc_unsol_ass_fail));
Harald Welte898113b2018-01-31 18:32:21 +01004249 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004250 f_shutdown_helper();
Harald Welte898113b2018-01-31 18:32:21 +01004251}
Harald Welte552620d2017-12-16 23:21:36 +01004252
Harald Welteea99a002018-01-31 20:46:43 +01004253
4254/* unsolicited ASSIGNMENT COMPLETE (without ASSIGN) from MS shouldn't bring BSC down */
4255private function f_tc_unsol_ass_compl(charstring id) runs on MSC_ConnHdlr {
Harald Weltee3bd6582018-01-31 22:51:25 +01004256 f_est_single_l3(ts_RRM_AssignmentComplete('00'O));
4257 f_bssap_expect_nothing();
Harald Welteea99a002018-01-31 20:46:43 +01004258}
4259testcase TC_unsol_ass_compl() runs on test_CT {
4260 var MSC_ConnHdlr vc_conn;
4261 f_init(1, true);
4262 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02004263 vc_conn := f_start_handler(refers(f_tc_unsol_ass_compl));
Harald Welteea99a002018-01-31 20:46:43 +01004264 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004265 f_shutdown_helper();
Harald Welteea99a002018-01-31 20:46:43 +01004266}
4267
4268
Harald Weltefbf9b5e2018-01-31 20:41:23 +01004269/* unsolicited HANDOVER FAIL (without ASSIGN) from MS shouldn't bring BSC down */
4270private function f_tc_unsol_ho_fail(charstring id) runs on MSC_ConnHdlr {
Harald Weltee3bd6582018-01-31 22:51:25 +01004271 f_est_single_l3(ts_RRM_HandoverFailure('00'O));
4272 f_bssap_expect_nothing();
Harald Weltefbf9b5e2018-01-31 20:41:23 +01004273}
Harald Weltefbf9b5e2018-01-31 20:41:23 +01004274testcase TC_unsol_ho_fail() runs on test_CT {
4275 var MSC_ConnHdlr vc_conn;
4276 f_init(1, true);
4277 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02004278 vc_conn := f_start_handler(refers(f_tc_unsol_ho_fail));
Harald Weltefbf9b5e2018-01-31 20:41:23 +01004279 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004280 f_shutdown_helper();
Harald Weltefbf9b5e2018-01-31 20:41:23 +01004281}
4282
4283
Harald Weltee3bd6582018-01-31 22:51:25 +01004284/* short message from MS should be ignored */
4285private function f_tc_err_82_short_msg(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02004286 g_pars := f_gen_test_hdlr_pars();
Harald Weltea0630032018-03-20 21:09:55 +01004287 f_create_chan_and_exp();
Harald Weltee3bd6582018-01-31 22:51:25 +01004288 /* we should now have a COMPL_L3 at the MSC */
4289 BSSAP.receive(tr_BSSMAP_ComplL3);
4290
4291 /* send short message */
4292 RSL.send(ts_RSL_DATA_IND(g_chan_nr, valueof(ts_RslLinkID_DCCH(0)), ''O));
4293 f_bssap_expect_nothing();
4294}
4295testcase TC_err_82_short_msg() runs on test_CT {
4296 var MSC_ConnHdlr vc_conn;
4297 f_init(1, true);
4298 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02004299 vc_conn := f_start_handler(refers(f_tc_err_82_short_msg));
Harald Weltee3bd6582018-01-31 22:51:25 +01004300 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004301 f_shutdown_helper();
Harald Weltee3bd6582018-01-31 22:51:25 +01004302}
4303
4304
Harald Weltee9e02e42018-01-31 23:36:25 +01004305/* 24.008 8.4 Unknown message must trigger RR STATUS */
4306private function f_tc_err_84_unknown_msg(charstring id) runs on MSC_ConnHdlr {
4307 f_est_single_l3(ts_RRM_UL_REL('00'O));
4308 timer T := 3.0
4309 alt {
4310 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_STATUS)) {
4311 setverdict(pass);
4312 }
4313 [] BSSAP.receive { setverdict(fail, "unexpected BSSAP"); }
Harald Welte458fd372018-03-21 11:26:23 +01004314 [] T.timeout { setverdict(fail, "Timeout waiting for RR STATUS"); }
Harald Weltee9e02e42018-01-31 23:36:25 +01004315 }
4316}
4317testcase TC_err_84_unknown_msg() runs on test_CT {
4318 var MSC_ConnHdlr vc_conn;
4319 f_init(1, true);
4320 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02004321 vc_conn := f_start_handler(refers(f_tc_err_84_unknown_msg));
Harald Weltee9e02e42018-01-31 23:36:25 +01004322 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004323 f_shutdown_helper();
Harald Weltee9e02e42018-01-31 23:36:25 +01004324}
4325
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004326/***********************************************************************
4327 * Handover
4328 ***********************************************************************/
4329
Harald Welte94e0c342018-04-07 11:33:23 +02004330/* execute a "bts <0-255> trx <0-255> timeslot <0-7> " command on given Dchan */
4331private function f_vty_ts_action(charstring suffix, integer bts_nr, integer trx_nr, integer ts_nr)
4332runs on test_CT {
4333 var charstring cmd := "bts "&int2str(bts_nr)&" trx "&int2str(trx_nr)&
4334 " timeslot "&int2str(ts_nr)&" ";
4335 f_vty_transceive(BSCVTY, cmd & suffix);
4336}
4337
Harald Welte261af4b2018-02-12 21:20:39 +01004338/* 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 +07004339private function f_vty_ss_action(TELNETasp_PT pt, charstring suffix,
4340 uint8_t bts_nr, uint8_t trx_nr,
4341 in RslChannelNr chan_nr)
4342{
Harald Welte261af4b2018-02-12 21:20:39 +01004343 /* FIXME: resolve those from component-global state */
4344 var integer ts_nr := chan_nr.tn;
4345 var integer ss_nr;
4346 if (ischosen(chan_nr.u.ch0)) {
4347 ss_nr := 0;
4348 } else if (ischosen(chan_nr.u.lm)) {
4349 ss_nr := chan_nr.u.lm.sub_chan;
4350 } else if (ischosen(chan_nr.u.sdcch4)) {
4351 ss_nr := chan_nr.u.sdcch4.sub_chan;
4352 } else if (ischosen(chan_nr.u.sdcch8)) {
4353 ss_nr := chan_nr.u.sdcch8.sub_chan;
4354 } else {
4355 setverdict(fail, "Invalid ChanNr ", chan_nr);
Daniel Willmannafce8662018-07-06 23:11:32 +02004356 mtc.stop;
Harald Welte261af4b2018-02-12 21:20:39 +01004357 }
4358
4359 var charstring cmd := "bts "&int2str(bts_nr)&" trx "&int2str(trx_nr)&
4360 " timeslot "&int2str(ts_nr)&" sub-slot "&int2str(ss_nr)&" ";
Vadim Yanitskiy00070722020-09-02 17:27:57 +07004361 f_vty_transceive(pt, cmd & suffix);
Harald Welte261af4b2018-02-12 21:20:39 +01004362}
4363
Neels Hofmeyr91401012019-07-11 00:42:35 +02004364/* Even though the VTY command to trigger handover takes a new BTS number as argument, behind the scenes osmo-bsc always
4365 * translates that to a target ARFCN+BSIC first. See bsc_vty.c trigger_ho_or_as(), which puts the selected BTS' neighbor
4366 * ident key (ARFCN + BSIC) in the struct passed on to handover_request(). handover_start() then resolves that to a
4367 * viable actual neighbor cell. So from the internal osmo-bsc perspective, we always request handover to an ARFCN + BSIC
4368 * pair, not really to a specific BTS number. */
Vadim Yanitskiy00070722020-09-02 17:27:57 +07004369private function f_vty_handover(TELNETasp_PT pt, uint8_t bts_nr, uint8_t trx_nr,
4370 in RslChannelNr chan_nr, uint8_t new_bts_nr)
4371{
4372 f_vty_ss_action(pt, "handover " & int2str(new_bts_nr), bts_nr, trx_nr, chan_nr);
Harald Welte261af4b2018-02-12 21:20:39 +01004373}
4374
4375/* intra-BSC hand-over between BTS0 and BTS1 */
4376private function f_tc_ho_int(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02004377 g_pars := f_gen_test_hdlr_pars();
Harald Welteed848512018-05-24 22:27:58 +02004378 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4379 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte261af4b2018-02-12 21:20:39 +01004380 const OCT8 kc := '0001020304050607'O;
4381
4382 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4383 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
4384
Harald Weltea0630032018-03-20 21:09:55 +01004385 f_establish_fully(ass_cmd, exp_compl);
Neels Hofmeyr666f0432020-07-04 00:53:07 +02004386 f_bts_0_cfg(BSCVTY, {"neighbor bts 1"});
Harald Welte261af4b2018-02-12 21:20:39 +01004387
4388 var HandoverState hs := {
4389 rr_ho_cmpl_seen := false,
4390 handover_done := false,
4391 old_chan_nr := -
4392 };
4393 /* issue hand-over command on VTY */
Vadim Yanitskiy00070722020-09-02 17:27:57 +07004394 f_vty_handover(BSCVTY, 0, 0, g_chan_nr, 1);
Harald Welte261af4b2018-02-12 21:20:39 +01004395 /* temporarily suspend DChan processing on BTS1 to avoid race with RSLEM_register */
4396 f_rslem_suspend(RSL1_PROC);
Philipp Maier3e2af5d2018-07-11 17:01:05 +02004397
4398 /* From the MGW perspective, a handover is is characterized by
4399 * performing one MDCX operation with the MGW. So we expect to see
4400 * one more MDCX during handover. */
4401 g_media.mgcp_conn[0].mdcx_seen_exp := g_media.mgcp_conn[0].crcx_seen_exp + 1;
4402
Harald Welte261af4b2018-02-12 21:20:39 +01004403 alt {
4404 [] as_handover(hs);
Harald Welte261af4b2018-02-12 21:20:39 +01004405 }
Philipp Maier3e2af5d2018-07-11 17:01:05 +02004406
Philipp Maier4dae0652018-11-12 12:03:26 +01004407 /* Since this is an internal handover we expect the BSC to inform the
4408 * MSC about the event */
4409 BSSAP.receive(tr_BSSMAP_HandoverPerformed);
4410
Philipp Maier3e2af5d2018-07-11 17:01:05 +02004411 /* Check the amount of MGCP transactions is still consistant with the
4412 * test expectation */
4413 f_check_mgcp_expectations()
Neels Hofmeyr861a4c12018-11-07 01:23:17 +01004414 f_sleep(0.5);
Harald Welte261af4b2018-02-12 21:20:39 +01004415}
4416
4417testcase TC_ho_int() runs on test_CT {
4418 var MSC_ConnHdlr vc_conn;
4419 f_init(2, true);
4420 f_sleep(1.0);
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004421
4422 f_ctrs_bsc_and_bts_init();
4423
Harald Welte8863fa12018-05-10 20:15:27 +02004424 vc_conn := f_start_handler(refers(f_tc_ho_int));
Harald Welte261af4b2018-02-12 21:20:39 +01004425 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004426
4427 /* from f_establish_fully() */
4428 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
4429 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
4430 /* from handover */
4431 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
4432 f_ctrs_bsc_and_bts_add(0, "handover:completed");
4433 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
4434 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:completed");
4435 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004436 f_shutdown_helper();
Harald Welte261af4b2018-02-12 21:20:39 +01004437}
Harald Weltee9e02e42018-01-31 23:36:25 +01004438
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004439/* Expecting MGCP to DLCX the endpoint's two connections: towards BTS and towards MSC */
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02004440private function f_expect_dlcx_conns() runs on MSC_ConnHdlr {
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004441 var MgcpCommand mgcp;
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +02004442 var template MgcpResponse mgcp_resp;
4443 var MGCP_RecvFrom mrf;
4444 var template MgcpMessage msg_resp;
4445 var template MgcpMessage msg_dlcx := {
4446 command := tr_DLCX()
4447 }
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004448
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +02004449 if (g_pars.aoip) {
4450 MGCP.receive(tr_DLCX()) -> value mgcp {
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004451 log("Got first DLCX: ", mgcp);
4452 MGCP.send(ts_DLCX_ACK2(mgcp.line.trans_id));
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +02004453 };
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004454
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004455 MGCP.receive(tr_DLCX()) -> value mgcp {
4456 log("Got second DLCX: ", mgcp);
4457 MGCP.send(ts_DLCX_ACK2(mgcp.line.trans_id));
4458 };
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +02004459 } else {
4460 /* For SCCPLite, BSC doesn't handle the MSC-side */
4461 MGCP_MULTI.receive(tr_MGCP_RecvFrom_any(msg_dlcx)) -> value mrf {
4462 log("Got first DLCX: ", mrf.msg.command);
4463 msg_resp := {
4464 response := ts_DLCX_ACK2(mrf.msg.command.line.trans_id)
4465 }
4466 MGCP_MULTI.send(t_MGCP_SendToMrf(mrf, msg_resp));
4467 };
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004468 }
4469
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02004470 BSSAP.receive(tr_BSSMAP_ClearComplete);
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004471}
4472
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004473private function f_tc_ho_out_of_this_bsc(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02004474 g_pars := f_gen_test_hdlr_pars();
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004475
4476 var PDU_BSSAP ass_req := f_gen_ass_req();
4477 ass_req.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4478 ass_req.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
4479 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4480 f_establish_fully(ass_req, exp_compl);
4481
Neels Hofmeyr666f0432020-07-04 00:53:07 +02004482 f_bts_0_cfg(BSCVTY, {"neighbor lac 99 arfcn 123 bsic any"});
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004483 f_vty_transceive(BSCVTY, "handover any to arfcn 123 bsic any");
4484
4485 BSSAP.receive(tr_BSSMAP_HandoverRequired);
4486
4487 f_sleep(0.5);
4488 /* The MSC negotiates Handover Request and Handover Request Ack with
4489 * the other BSS and comes back with a BSSMAP Handover Command
4490 * containing an RR Handover Command coming from the target BSS... */
4491
4492 var PDU_ML3_NW_MS rr_ho_cmd := valueof(ts_RR_HandoverCommand);
4493 log("Remote cell's RR Handover Command passed through as L3 Info: ", rr_ho_cmd);
4494 var octetstring rr_ho_cmd_enc := enc_PDU_ML3_NW_MS(rr_ho_cmd);
4495 log("Remote cell's RR Handover Command passed through as L3 Info, encoded: ", rr_ho_cmd_enc);
4496 BSSAP.send(ts_BSSMAP_HandoverCommand(rr_ho_cmd_enc));
4497
4498 /* expect the Handover Command to go out on RR */
4499 var RSL_Message rsl_ho_cmd
4500 RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, ?)) -> value rsl_ho_cmd;
4501 log("RSL Data Req went out to first BTS: ", rsl_ho_cmd);
4502 var RSL_IE_Body rsl_ho_cmd_l3;
4503 if (not f_rsl_find_ie(rsl_ho_cmd, RSL_IE_L3_INFO, rsl_ho_cmd_l3)) {
4504 log("RSL message contains no L3 Info IE, expected RR Handover Command");
4505 setverdict(fail);
4506 } else {
4507 log("Found L3 Info: ", rsl_ho_cmd_l3);
4508 if (rsl_ho_cmd_l3.l3_info.payload != rr_ho_cmd_enc) {
4509 log("FAIL: the BSC sent out a different L3 Info, not matching the RR Handover Command the other BSS forwarded.");
4510 setverdict(fail);
4511 } else {
4512 log("Success: the BSC sent out the same RR Handover Command the other BSS forwarded.");
4513 setverdict(pass);
4514 }
4515 }
4516
4517 /* When the other BSS has reported a completed handover, this side is
4518 * torn down. */
4519
4520 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_HANDOVER_SUCCESSFUL;
4521 var BssmapCause cause := enum2int(cause_val);
4522 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
4523
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02004524 f_expect_dlcx_conns();
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004525 setverdict(pass);
4526 f_sleep(1.0);
4527}
4528testcase TC_ho_out_of_this_bsc() runs on test_CT {
4529 var MSC_ConnHdlr vc_conn;
4530
4531 f_init(1, true);
4532 f_sleep(1.0);
4533
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004534 f_ctrs_bsc_and_bts_init();
4535
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004536 vc_conn := f_start_handler(refers(f_tc_ho_out_of_this_bsc));
4537 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004538
4539 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
4540 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
4541 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
4542 f_ctrs_bsc_and_bts_add(0, "handover:completed");
4543 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
4544 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:completed");
4545 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004546 f_shutdown_helper();
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004547}
4548
Vadim Yanitskiyb93aa432020-10-01 14:23:11 +07004549private function f_mo_l3_transceive(template (value) RslLinkId link_id := ts_RslLinkID_DCCH(0),
Vadim Yanitskiy2ef6a2f2020-10-08 23:17:32 +07004550 template (present) OCT1 dlci := ?,
Vadim Yanitskiyb93aa432020-10-01 14:23:11 +07004551 octetstring l3 := '0123456789'O)
4552runs on MSC_ConnHdlr {
Neels Hofmeyr43654812020-09-25 01:35:35 +02004553 /* The old lchan and conn should still be active. See that arbitrary L3
4554 * is still going through. */
Vadim Yanitskiyb93aa432020-10-01 14:23:11 +07004555 RSL.send(ts_RSL_DATA_IND(g_chan_nr, link_id, l3));
Neels Hofmeyr43654812020-09-25 01:35:35 +02004556 var template PDU_BSSAP exp_data := {
4557 discriminator := '1'B,
4558 spare := '0000000'B,
Vadim Yanitskiyb93aa432020-10-01 14:23:11 +07004559 dlci := dlci,
4560 lengthIndicator := lengthof(l3),
Neels Hofmeyr43654812020-09-25 01:35:35 +02004561 pdu := {
4562 dtap := l3
4563 }
4564 };
4565 BSSAP.receive(exp_data);
4566 setverdict(pass);
4567}
4568
Vadim Yanitskiy0033a3b2020-10-01 22:21:16 +07004569private function f_mt_l3_transceive(template (present) RslLinkId link_id := tr_RslLinkID_DCCH(0),
4570 template (value) OCT1 dlci := '00'O,
4571 octetstring l3 := '0123456789'O)
4572runs on MSC_ConnHdlr {
4573 BSSAP.send(PDU_BSSAP:{
4574 discriminator := '1'B,
4575 spare := '0000000'B,
4576 dlci := dlci,
4577 lengthIndicator := lengthof(l3),
4578 pdu := {
4579 dtap := l3
4580 }
4581 });
4582 RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, link_id, l3));
4583 setverdict(pass);
4584}
4585
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004586/* BSC asks for inter-BSC HO, but the MSC decides that it won't happen and
4587 * simply never sends a BSSMAP Handover Command. */
4588private function f_tc_ho_out_fail_no_msc_response(charstring id) runs on MSC_ConnHdlr {
Daniel Willmann3b59eb52018-10-29 15:40:55 +01004589 g_pars := f_gen_test_hdlr_pars();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004590
4591 var PDU_BSSAP ass_req := f_gen_ass_req();
4592 ass_req.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4593 ass_req.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
4594 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4595 f_establish_fully(ass_req, exp_compl);
4596
Neels Hofmeyr666f0432020-07-04 00:53:07 +02004597 f_bts_0_cfg(BSCVTY, {"neighbor lac 99 arfcn 123 bsic any"});
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004598 f_vty_transceive(BSCVTY, "handover any to arfcn 123 bsic any");
4599
4600 BSSAP.receive(tr_BSSMAP_HandoverRequired);
4601
4602 /* osmo-bsc should time out 10 seconds after the handover started.
4603 * Let's give it a bit extra. */
4604 f_sleep(15.0);
4605
Vadim Yanitskiy74ae5eb2020-10-01 22:13:29 +07004606 f_mo_l3_transceive();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004607 f_sleep(1.0);
4608}
4609testcase TC_ho_out_fail_no_msc_response() runs on test_CT {
4610 var MSC_ConnHdlr vc_conn;
4611
4612 f_init(1, true);
4613 f_sleep(1.0);
4614
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004615 f_ctrs_bsc_and_bts_init();
4616
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004617 vc_conn := f_start_handler(refers(f_tc_ho_out_fail_no_msc_response));
4618 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004619
4620 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
4621 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
4622 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
4623 f_ctrs_bsc_and_bts_add(0, "handover:timeout");
4624 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
4625 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:timeout");
4626 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004627 f_shutdown_helper();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004628}
4629
4630/* BSC asks for inter-BSC HO, receives BSSMAP Handover Command, but MS reports
4631 * RR Handover Failure. */
4632private function f_tc_ho_out_fail_rr_ho_failure(charstring id) runs on MSC_ConnHdlr {
Daniel Willmann3b59eb52018-10-29 15:40:55 +01004633 g_pars := f_gen_test_hdlr_pars();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004634
4635 var PDU_BSSAP ass_req := f_gen_ass_req();
4636 ass_req.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4637 ass_req.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
4638 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4639 f_establish_fully(ass_req, exp_compl);
4640
Neels Hofmeyr666f0432020-07-04 00:53:07 +02004641 f_bts_0_cfg(BSCVTY, {"neighbor lac 99 arfcn 123 bsic any"});
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004642 f_vty_transceive(BSCVTY, "handover any to arfcn 123 bsic any");
4643
4644 BSSAP.receive(tr_BSSMAP_HandoverRequired);
4645
4646 f_sleep(0.5);
4647 /* The MSC negotiates Handover Request and Handover Request Ack with
4648 * the other BSS and comes back with a BSSMAP Handover Command
4649 * containing an RR Handover Command coming from the target BSS... */
4650
4651 var PDU_ML3_NW_MS rr_ho_cmd := valueof(ts_RR_HandoverCommand);
4652 log("Remote cell's RR Handover Command passed through as L3 Info: ", rr_ho_cmd);
4653 var octetstring rr_ho_cmd_enc := enc_PDU_ML3_NW_MS(rr_ho_cmd);
4654 log("Remote cell's RR Handover Command passed through as L3 Info, encoded: ", rr_ho_cmd_enc);
4655 BSSAP.send(ts_BSSMAP_HandoverCommand(rr_ho_cmd_enc));
4656
4657 /* expect the Handover Command to go out on RR */
4658 var RSL_Message rsl_ho_cmd
4659 RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, ?)) -> value rsl_ho_cmd;
4660 log("RSL Data Req went out to first BTS: ", rsl_ho_cmd);
4661 var RSL_IE_Body rsl_ho_cmd_l3;
4662 if (not f_rsl_find_ie(rsl_ho_cmd, RSL_IE_L3_INFO, rsl_ho_cmd_l3)) {
4663 log("RSL message contains no L3 Info IE, expected RR Handover Command");
4664 setverdict(fail);
4665 } else {
4666 log("Found L3 Info: ", rsl_ho_cmd_l3);
4667 if (rsl_ho_cmd_l3.l3_info.payload != rr_ho_cmd_enc) {
4668 log("FAIL: the BSC sent out a different L3 Info, not matching the RR Handover Command the other BSS forwarded.");
4669 setverdict(fail);
4670 } else {
4671 log("Success: the BSC sent out the same RR Handover Command the other BSS forwarded.");
4672 setverdict(pass);
4673 }
4674 }
4675
4676 f_sleep(0.2);
4677 f_rsl_send_l3(ts_RRM_HandoverFailure('00'O));
4678
4679 /* Should tell the MSC about the failure */
4680 BSSAP.receive(tr_BSSMAP_HandoverFailure);
4681
4682 f_sleep(1.0);
4683
Vadim Yanitskiy74ae5eb2020-10-01 22:13:29 +07004684 f_mo_l3_transceive();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004685 f_sleep(1.0);
4686
4687 setverdict(pass);
4688 f_sleep(1.0);
4689}
4690testcase TC_ho_out_fail_rr_ho_failure() runs on test_CT {
4691 var MSC_ConnHdlr vc_conn;
4692
4693 f_init(1, true);
4694 f_sleep(1.0);
4695
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004696 f_ctrs_bsc_and_bts_init();
4697
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004698 vc_conn := f_start_handler(refers(f_tc_ho_out_fail_rr_ho_failure));
4699 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004700
4701 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
4702 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
4703 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
4704 f_ctrs_bsc_and_bts_add(0, "handover:failed");
4705 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
4706 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:failed");
4707 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004708 f_shutdown_helper();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004709}
4710
Neels Hofmeyr10f2bfa2019-07-09 19:33:29 +02004711/* BSC asks for inter-BSC-out HO, receives BSSMAP Handover Command, but then no reply is received about HO outcome
4712 * (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 +02004713 * and the lchan is released. */
4714private function f_tc_ho_out_fail_no_result_after_ho_cmd(charstring id) runs on MSC_ConnHdlr {
Daniel Willmann3b59eb52018-10-29 15:40:55 +01004715 g_pars := f_gen_test_hdlr_pars();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004716
4717 var PDU_BSSAP ass_req := f_gen_ass_req();
4718 ass_req.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4719 ass_req.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
4720 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4721 f_establish_fully(ass_req, exp_compl);
4722
Neels Hofmeyr666f0432020-07-04 00:53:07 +02004723 f_bts_0_cfg(BSCVTY, {"neighbor lac 99 arfcn 123 bsic any"});
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004724 f_vty_transceive(BSCVTY, "handover any to arfcn 123 bsic any");
4725
4726 BSSAP.receive(tr_BSSMAP_HandoverRequired);
4727
4728 f_sleep(0.5);
4729 /* The MSC negotiates Handover Request and Handover Request Ack with
4730 * the other BSS and comes back with a BSSMAP Handover Command
4731 * containing an RR Handover Command coming from the target BSS... */
4732
4733 var PDU_ML3_NW_MS rr_ho_cmd := valueof(ts_RR_HandoverCommand);
4734 log("Remote cell's RR Handover Command passed through as L3 Info: ", rr_ho_cmd);
4735 var octetstring rr_ho_cmd_enc := enc_PDU_ML3_NW_MS(rr_ho_cmd);
4736 log("Remote cell's RR Handover Command passed through as L3 Info, encoded: ", rr_ho_cmd_enc);
4737 BSSAP.send(ts_BSSMAP_HandoverCommand(rr_ho_cmd_enc));
4738
4739 /* expect the Handover Command to go out on RR */
4740 var RSL_Message rsl_ho_cmd
4741 RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, ?)) -> value rsl_ho_cmd;
4742 log("RSL Data Req went out to first BTS: ", rsl_ho_cmd);
4743 var RSL_IE_Body rsl_ho_cmd_l3;
4744 if (not f_rsl_find_ie(rsl_ho_cmd, RSL_IE_L3_INFO, rsl_ho_cmd_l3)) {
4745 log("RSL message contains no L3 Info IE, expected RR Handover Command");
4746 setverdict(fail);
4747 } else {
4748 log("Found L3 Info: ", rsl_ho_cmd_l3);
4749 if (rsl_ho_cmd_l3.l3_info.payload != rr_ho_cmd_enc) {
4750 log("FAIL: the BSC sent out a different L3 Info, not matching the RR Handover Command the other BSS forwarded.");
4751 setverdict(fail);
4752 } else {
4753 log("Success: the BSC sent out the same RR Handover Command the other BSS forwarded.");
4754 setverdict(pass);
4755 }
4756 }
4757
Neels Hofmeyr10f2bfa2019-07-09 19:33:29 +02004758 /* We get neither success nor failure report from the remote BSS. Eventually T8 times out and we run into 3GPP
4759 * TS 48.008 3.1.5.3.3 "Abnormal Conditions": Clear Request should go to the MSC, and RR should be released
4760 * after Clear Command */
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004761
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02004762 var PDU_BSSAP rx_clear_request;
Neels Hofmeyre1797aa2019-07-09 19:34:04 +02004763 BSSAP.receive(tr_BSSMAP_ClearRequest) -> value rx_clear_request;
4764 log("Got BSSMAP Clear Request");
4765 /* Instruct BSC to clear channel */
4766 var BssmapCause cause := bit2int(rx_clear_request.pdu.bssmap.clearRequest.cause.causeValue);
4767 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
4768
4769 var MgcpCommand mgcp;
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004770 interleave {
Neels Hofmeyr861a4c12018-11-07 01:23:17 +01004771 [] RSL.receive(tr_RSL_DEACT_SACCH(g_chan_nr)) {
4772 log("Got Deact SACCH");
4773 }
Harald Welte924b6ea2019-02-04 01:05:34 +01004774 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_RELEASE)) {
Neels Hofmeyr211169d2018-11-07 00:37:29 +01004775 log("Got RR Release");
4776 }
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004777 [] RSL.receive(tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL)) {
4778 log("Got RF Chan Rel");
4779 RSL.send(ts_RSL_RF_CHAN_REL_ACK(g_chan_nr));
4780 }
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004781 }
4782
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02004783 f_expect_dlcx_conns();
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004784
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004785 setverdict(pass);
4786 f_sleep(1.0);
4787}
Neels Hofmeyrd8a602c2019-07-09 19:46:01 +02004788testcase TC_ho_out_fail_no_result_after_ho_cmd() runs on test_CT {
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004789 var MSC_ConnHdlr vc_conn;
4790
4791 f_init(1, true);
4792 f_sleep(1.0);
4793
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004794 f_ctrs_bsc_and_bts_init();
4795
Neels Hofmeyrd8a602c2019-07-09 19:46:01 +02004796 vc_conn := f_start_handler(refers(f_tc_ho_out_fail_no_result_after_ho_cmd));
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004797 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004798
4799 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
4800 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
4801 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
4802 f_ctrs_bsc_and_bts_add(0, "handover:timeout");
4803 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
4804 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:timeout");
4805 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004806 f_shutdown_helper();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004807}
4808
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004809private function f_tc_ho_into_this_bsc(charstring id) runs on MSC_ConnHdlr {
4810 /* Hack: the proper way would be to wait for the BSSMAP Handover Request ACK and extract the
4811 * actual assigned chan_nr from its L3 (RR Handover Command) message. But osmo-bsc starts acting
4812 * on the lchan even before we get a chance to evaluate the BSSMAP Handover Request ACK. So we
4813 * need to assume that osmo-bsc will activate TS 1 and already set up this lchan's RSL emulation
4814 * before we get started. */
4815 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
4816 f_rslem_register(0, new_chan_nr);
4817 g_chan_nr := new_chan_nr;
4818 f_sleep(1.0);
4819
4820 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
4821 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
4822 activate(as_Media());
4823
Neels Hofmeyr90f80962020-06-12 16:16:55 +02004824 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Pau Espin Pedrol07866632020-09-03 19:10:55 +02004825 f_gen_handover_req(aoip_tla := g_pars.host_aoip_tla)));
Harald Welte6811d102019-04-14 22:23:14 +02004826 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004827
4828 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
4829
4830 var PDU_BSSAP rx_bssap;
4831 var octetstring ho_command_str;
4832
4833 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
Pau Espin Pedrol76ba5412019-06-10 11:00:33 +02004834
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004835 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
4836 log("Received L3 Info in HO Request Ack: ", ho_command_str);
4837 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
4838 log("L3 Info in HO Request Ack is ", ho_command);
4839
4840 var GsmArfcn arfcn;
4841 var RslChannelNr actual_new_chan_nr;
4842 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
4843 actual_new_chan_nr, arfcn);
4844
4845 if (actual_new_chan_nr != new_chan_nr) {
4846 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
4847 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
4848 setverdict(fail);
4849 return;
4850 }
4851 log("Handover Command chan_nr is", actual_new_chan_nr);
4852
4853 /* Now the MSC forwards the RR Handover Command to the other BSC, which
4854 * tells the MS to handover to the new lchan. Here comes the new MS on
4855 * the new lchan with a Handover RACH: */
4856
4857 /* send handover detect */
4858
4859 RSL.send(ts_RSL_HANDO_DET(new_chan_nr));
4860
4861 BSSAP.receive(tr_BSSMAP_HandoverDetect);
4862
4863 /* send handover complete over the new channel */
4864
4865 var PDU_ML3_MS_NW l3_tx := valueof(ts_RRM_HandoverComplete('00'O));
4866 RSL.send(ts_RSL_EST_IND(new_chan_nr, valueof(ts_RslLinkID_DCCH(0)),
4867 enc_PDU_ML3_MS_NW(l3_tx)));
4868
4869 BSSAP.receive(tr_BSSMAP_HandoverComplete);
4870 setverdict(pass);
4871}
Pau Espin Pedrol07866632020-09-03 19:10:55 +02004872function f_tc_ho_into_this_bsc_main(TestHdlrParams pars) runs on test_CT {
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004873 var MSC_ConnHdlr vc_conn;
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004874
4875 f_init(1, true);
4876 f_sleep(1.0);
4877
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004878 f_ctrs_bsc_and_bts_init();
4879
Neels Hofmeyr90f80962020-06-12 16:16:55 +02004880 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
4881 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004882
4883 vc_conn := f_start_handler(refers(f_tc_ho_into_this_bsc), pars);
4884 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004885
4886 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
4887 f_ctrs_bsc_and_bts_add(0, "handover:completed");
4888 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:attempted");
4889 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:completed");
4890 f_ctrs_bsc_and_bts_verify();
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004891}
4892
Pau Espin Pedrol07866632020-09-03 19:10:55 +02004893testcase TC_ho_into_this_bsc() runs on test_CT {
4894 var TestHdlrParams pars := f_gen_test_hdlr_pars();
4895 f_tc_ho_into_this_bsc_main(pars);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004896 f_shutdown_helper();
Pau Espin Pedrol07866632020-09-03 19:10:55 +02004897}
4898
4899testcase TC_ho_into_this_bsc_tla_v6() runs on test_CT {
4900 var TestHdlrParams pars := f_gen_test_hdlr_pars();
4901 pars.host_aoip_tla := "::6";
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
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01004906private function f_tc_ho_in_fail_msc_clears(charstring id) runs on MSC_ConnHdlr {
4907 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
4908 f_rslem_register(0, new_chan_nr);
4909 g_chan_nr := new_chan_nr;
4910 f_sleep(1.0);
4911
4912 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
4913 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
4914 activate(as_Media());
4915
Neels Hofmeyr90f80962020-06-12 16:16:55 +02004916 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01004917 f_gen_handover_req()));
Harald Welte6811d102019-04-14 22:23:14 +02004918 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01004919
4920 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
4921
4922 var PDU_BSSAP rx_bssap;
4923 var octetstring ho_command_str;
4924
4925 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
4926
4927 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
4928 log("Received L3 Info in HO Request Ack: ", ho_command_str);
4929 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
4930 log("L3 Info in HO Request Ack is ", ho_command);
4931
4932 var GsmArfcn arfcn;
4933 var RslChannelNr actual_new_chan_nr;
4934 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
4935 actual_new_chan_nr, arfcn);
4936
4937 if (actual_new_chan_nr != new_chan_nr) {
4938 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
4939 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
4940 setverdict(fail);
4941 return;
4942 }
4943 log("Handover Command chan_nr is", actual_new_chan_nr);
4944
Neels Hofmeyr61ca08d2019-05-06 23:52:22 +02004945 /* For deterministic test results, give some time for the MGW endpoint to be configured */
4946 f_sleep(1.0);
4947
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01004948 /* Now the MSC forwards the RR Handover Command to the other BSC, which
4949 * tells the MS to handover to the new lchan. In this case, the MS
4950 * reports a Handover Failure to the old BSS, which forwards a BSSMAP
4951 * Handover Failure to the MSC. The procedure according to 3GPP TS
4952 * 48.008 3.1.5.3.2 "Handover Failure" is then that the MSC sends a
4953 * BSSMAP Clear Command: */
4954
4955 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_RADIO_INTERFACE_FAILURE_REVERSION;
4956 var BssmapCause cause := enum2int(cause_val);
4957 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
4958
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02004959 f_expect_dlcx_conns();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01004960 setverdict(pass);
4961 f_sleep(1.0);
4962
4963 setverdict(pass);
4964}
4965testcase TC_ho_in_fail_msc_clears() runs on test_CT {
4966 var MSC_ConnHdlr vc_conn;
4967 var TestHdlrParams pars := f_gen_test_hdlr_pars();
4968
4969 f_init(1, true);
4970 f_sleep(1.0);
4971
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004972 f_ctrs_bsc_and_bts_init();
4973
Neels Hofmeyr90f80962020-06-12 16:16:55 +02004974 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
4975 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01004976
4977 vc_conn := f_start_handler(refers(f_tc_ho_in_fail_msc_clears), pars);
4978 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004979
4980 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
4981 f_ctrs_bsc_and_bts_add(0, "handover:stopped");
4982 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:attempted");
4983 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:stopped");
4984 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004985 f_shutdown_helper();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01004986}
4987
4988private function f_tc_ho_in_fail_msc_clears_after_ho_detect(charstring id) runs on MSC_ConnHdlr {
4989 /* Hack: the proper way would be to wait for the BSSMAP Handover Request ACK and extract the
4990 * actual assigned chan_nr from its L3 (RR Handover Command) message. But osmo-bsc starts acting
4991 * on the lchan even before we get a chance to evaluate the BSSMAP Handover Request ACK. So we
4992 * need to assume that osmo-bsc will activate TS 1 and already set up this lchan's RSL emulation
4993 * before we get started. */
4994 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
4995 f_rslem_register(0, new_chan_nr);
4996 g_chan_nr := new_chan_nr;
4997 f_sleep(1.0);
4998
4999 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
5000 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
5001 activate(as_Media());
5002
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005003 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005004 f_gen_handover_req()));
Harald Welte6811d102019-04-14 22:23:14 +02005005 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005006
5007 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
5008
5009 var PDU_BSSAP rx_bssap;
5010 var octetstring ho_command_str;
5011
5012 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
5013
5014 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
5015 log("Received L3 Info in HO Request Ack: ", ho_command_str);
5016 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
5017 log("L3 Info in HO Request Ack is ", ho_command);
5018
5019 var GsmArfcn arfcn;
5020 var RslChannelNr actual_new_chan_nr;
5021 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
5022 actual_new_chan_nr, arfcn);
5023
5024 if (actual_new_chan_nr != new_chan_nr) {
5025 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
5026 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
5027 setverdict(fail);
5028 return;
5029 }
5030 log("Handover Command chan_nr is", actual_new_chan_nr);
5031
5032 /* Now the MSC forwards the RR Handover Command to the other BSC, which
5033 * tells the MS to handover to the new lchan. Here comes the new MS on
5034 * the new lchan with a Handover RACH: */
5035
5036 /* send handover detect */
5037
5038 RSL.send(ts_RSL_HANDO_DET(new_chan_nr));
5039
5040 BSSAP.receive(tr_BSSMAP_HandoverDetect);
5041
5042 /* The MSC chooses to clear the connection now, maybe we got the
5043 * Handover RACH on the new cell but the MS still signaled Handover
5044 * Failure to the old BSS? */
5045
5046 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_RADIO_INTERFACE_FAILURE_REVERSION;
5047 var BssmapCause cause := enum2int(cause_val);
5048 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
5049
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02005050 f_expect_dlcx_conns();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005051 f_sleep(1.0);
5052}
5053testcase TC_ho_in_fail_msc_clears_after_ho_detect() runs on test_CT {
5054 var MSC_ConnHdlr vc_conn;
5055 var TestHdlrParams pars := f_gen_test_hdlr_pars();
5056
5057 f_init(1, true);
5058 f_sleep(1.0);
5059
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005060 f_ctrs_bsc_and_bts_init();
5061
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005062 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
5063 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005064
5065 vc_conn := f_start_handler(refers(f_tc_ho_in_fail_msc_clears_after_ho_detect), pars);
5066 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005067
5068 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5069 f_ctrs_bsc_and_bts_add(0, "handover:stopped");
5070 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:attempted");
5071 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:stopped");
5072 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005073 f_shutdown_helper();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005074}
5075
5076/* The new BSS's lchan times out before the MSC decides that handover failed. */
5077private function f_tc_ho_in_fail_no_detect(charstring id) runs on MSC_ConnHdlr {
5078 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
5079 f_rslem_register(0, new_chan_nr);
5080 g_chan_nr := new_chan_nr;
5081 f_sleep(1.0);
5082
5083 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
5084 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
5085 activate(as_Media());
5086
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005087 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005088 f_gen_handover_req()));
Harald Welte6811d102019-04-14 22:23:14 +02005089 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005090
5091 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
5092
5093 var PDU_BSSAP rx_bssap;
5094 var octetstring ho_command_str;
5095
5096 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
5097
5098 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
5099 log("Received L3 Info in HO Request Ack: ", ho_command_str);
5100 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
5101 log("L3 Info in HO Request Ack is ", ho_command);
5102
5103 var GsmArfcn arfcn;
5104 var RslChannelNr actual_new_chan_nr;
5105 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
5106 actual_new_chan_nr, arfcn);
5107
5108 if (actual_new_chan_nr != new_chan_nr) {
5109 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
5110 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
5111 setverdict(fail);
5112 return;
5113 }
5114 log("Handover Command chan_nr is", actual_new_chan_nr);
5115
5116 /* Now the MSC forwards the RR Handover Command to the other BSC, which
5117 * tells the MS to handover to the new lchan. But the MS never shows up
5118 * on the new lchan. */
5119
5120 BSSAP.receive(tr_BSSMAP_HandoverFailure);
5121
5122 /* Did osmo-bsc also send a Clear Request? */
5123 timer T := 0.5;
5124 T.start;
5125 alt {
5126 [] BSSAP.receive(tr_BSSMAP_ClearRequest);
5127 [] T.timeout { }
5128 }
5129
5130 /* MSC plays along with a Clear Command (no matter whether osmo-bsc
5131 * asked for it, this is a Handover Failure after all). */
5132
5133 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_RADIO_INTERFACE_FAILURE_REVERSION;
5134 var BssmapCause cause := enum2int(cause_val);
5135 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
5136
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02005137 f_expect_dlcx_conns();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005138 f_sleep(1.0);
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005139}
5140testcase TC_ho_in_fail_no_detect() runs on test_CT {
5141 var MSC_ConnHdlr vc_conn;
5142 var TestHdlrParams pars := f_gen_test_hdlr_pars();
5143
5144 f_init(1, true);
5145 f_sleep(1.0);
5146
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005147 f_ctrs_bsc_and_bts_init();
5148
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005149 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
5150 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005151
5152 vc_conn := f_start_handler(refers(f_tc_ho_in_fail_no_detect), pars);
5153 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005154
5155 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5156 f_ctrs_bsc_and_bts_add(0, "handover:error");
5157 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:attempted");
5158 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:error");
5159 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005160 f_shutdown_helper();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005161}
5162
5163/* Same as f_tc_ho_in_fail_no_detect, but MSC fails to send a Clear Command */
5164private function f_tc_ho_in_fail_no_detect2(charstring id) runs on MSC_ConnHdlr {
5165 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
5166 f_rslem_register(0, new_chan_nr);
5167 g_chan_nr := new_chan_nr;
5168 f_sleep(1.0);
5169
5170 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
5171 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
5172 activate(as_Media());
5173
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005174 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005175 f_gen_handover_req()));
Harald Welte6811d102019-04-14 22:23:14 +02005176 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005177
5178 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
5179
5180 var PDU_BSSAP rx_bssap;
5181 var octetstring ho_command_str;
5182
5183 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
5184
5185 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
5186 log("Received L3 Info in HO Request Ack: ", ho_command_str);
5187 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
5188 log("L3 Info in HO Request Ack is ", ho_command);
5189
5190 var GsmArfcn arfcn;
5191 var RslChannelNr actual_new_chan_nr;
5192 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
5193 actual_new_chan_nr, arfcn);
5194
5195 if (actual_new_chan_nr != new_chan_nr) {
5196 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
5197 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
5198 setverdict(fail);
5199 return;
5200 }
5201 log("Handover Command chan_nr is", actual_new_chan_nr);
5202
5203 /* Now the MSC forwards the RR Handover Command to the other BSC, which
5204 * tells the MS to handover to the new lchan. But the MS never shows up
5205 * on the new lchan. */
5206
5207 BSSAP.receive(tr_BSSMAP_HandoverFailure);
5208
5209 /* MSC plays dumb and sends no Clear Command */
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005210 var PDU_BSSAP rx_clear_request;
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02005211
5212 BSSAP.receive(tr_BSSMAP_ClearRequest) -> value rx_clear_request {
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005213 var BssmapCause cause := bit2int(rx_clear_request.pdu.bssmap.clearRequest.cause.causeValue);
5214 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
5215 };
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02005216 f_expect_dlcx_conns();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005217 f_sleep(1.0);
5218}
5219testcase TC_ho_in_fail_no_detect2() runs on test_CT {
5220 var MSC_ConnHdlr vc_conn;
5221 var TestHdlrParams pars := f_gen_test_hdlr_pars();
5222
5223 f_init(1, true);
5224 f_sleep(1.0);
5225
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005226 f_ctrs_bsc_and_bts_init();
5227
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005228 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
5229 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005230
5231 vc_conn := f_start_handler(refers(f_tc_ho_in_fail_no_detect2), pars);
5232 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005233
5234 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5235 f_ctrs_bsc_and_bts_add(0, "handover:error");
5236 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:attempted");
5237 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:error");
5238 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005239 f_shutdown_helper();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005240}
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005241
Neels Hofmeyr91401012019-07-11 00:42:35 +02005242type record of charstring Commands;
5243
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005244private function f_bts_0_cfg(TELNETasp_PT pt, Commands cmds := {})
Neels Hofmeyr91401012019-07-11 00:42:35 +02005245{
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005246 f_vty_enter_cfg_bts(pt, 0);
Neels Hofmeyr91401012019-07-11 00:42:35 +02005247 for (var integer i := 0; i < sizeof(cmds); i := i+1) {
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005248 f_vty_transceive(pt, cmds[i]);
Neels Hofmeyr91401012019-07-11 00:42:35 +02005249 }
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005250 f_vty_transceive(pt, "end");
Neels Hofmeyr91401012019-07-11 00:42:35 +02005251}
5252
Pau Espin Pedrolc675b612020-01-09 19:55:40 +01005253private function f_cs7_inst_0_cfg(TELNETasp_PT pt, Commands cmds := {})
5254{
5255 f_vty_enter_cfg_cs7_inst(pt, 0);
5256 for (var integer i := 0; i < sizeof(cmds); i := i+1) {
5257 f_vty_transceive(pt, cmds[i]);
5258 }
5259 f_vty_transceive(pt, "end");
5260}
5261
Neels Hofmeyr91401012019-07-11 00:42:35 +02005262private function f_probe_for_handover(charstring log_label,
5263 charstring log_descr,
5264 charstring handover_vty_cmd,
5265 boolean expect_handover,
5266 boolean is_inter_bsc_handover := false)
5267runs on MSC_ConnHdlr
5268{
Neels Hofmeyrb3fc8982020-05-11 00:16:42 +02005269 /* We're going to thwart any and all handover attempts, just be ready to handle (and ignore) handover target
5270 * lchans to be established on bts 1 or bts 2. */
5271 f_rslem_suspend(RSL1_PROC);
5272 f_rslem_suspend(RSL2_PROC);
5273
Neels Hofmeyr91401012019-07-11 00:42:35 +02005274 var RSL_Message rsl;
5275
5276 var charstring log_msg := " (expecting handover)"
5277 if (not expect_handover) {
5278 log_msg := " (expecting NO handover)";
5279 }
5280 log("f_probe_for_handover starting: " & log_label & ": " & log_descr & log_msg);
5281 f_vty_transceive(BSCVTY, handover_vty_cmd);
5282
Neels Hofmeyr91401012019-07-11 00:42:35 +02005283 timer T := 2.0;
5284 T.start;
5285
5286 alt {
5287 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr)) -> value rsl {
5288 var PDU_ML3_NW_MS l3 := dec_PDU_ML3_NW_MS(rsl.ies[2].body.l3_info.payload);
5289 log("Rx L3 from net: ", l3);
5290 if (ischosen(l3.msgs.rrm.handoverCommand)) {
5291 var RslChannelNr new_chan_nr;
5292 var GsmArfcn arfcn;
5293 f_ChDesc2RslChanNr(l3.msgs.rrm.handoverCommand.channelDescription2,
5294 new_chan_nr, arfcn);
5295 log("Handover to new chan ", new_chan_nr, " on ARFCN ", arfcn);
5296 log(l3.msgs.rrm.handoverCommand);
5297
5298 /* Need to register for new lchan on new BTS -- it's either bts 1 or bts 2. It doesn't really
5299 * matter on which BTS it really is, we're not going to follow through an entire handover
5300 * anyway. */
5301 f_rslem_register(0, new_chan_nr, RSL1_PROC);
5302 f_rslem_resume(RSL1_PROC);
5303 f_rslem_register(0, new_chan_nr, RSL2_PROC);
5304 f_rslem_resume(RSL2_PROC);
5305
5306 if (expect_handover and not is_inter_bsc_handover) {
5307 setverdict(pass);
5308 log("f_probe_for_handover(" & log_label & "): Got RSL Handover Command as expected.");
5309 } else {
5310 setverdict(fail, "f_probe_for_handover(" & log_label & "): Expected none, but got RSL Handover Command. "
5311 & log_label & ": " & log_descr);
5312 }
5313
5314 log("f_probe_for_handover(" & log_label & "): Ending the test: Handover Failure stops the procedure.");
5315 /* osmo-bsc has triggered Handover. That's all we need to know for this test, reply with
5316 * Handover Failure. */
5317 f_rsl_send_l3(ts_RRM_HandoverFailure('00'O));
5318
5319 /* target BTS is told to release lchan again; don't care which BTS nor what messages. */
5320 f_sleep(0.5);
5321 RSL1.clear;
5322 RSL2.clear;
5323 log("f_probe_for_handover(" & log_label & "): done (got RSL Handover Command)");
5324 break;
5325 } else {
5326 repeat;
5327 }
5328 }
5329 [] BSSAP.receive(tr_BSSMAP_HandoverRequired) {
5330 if (expect_handover and is_inter_bsc_handover) {
5331 setverdict(pass);
5332 log("f_probe_for_handover(" & log_label & "): Got BSSMAP Handover Required as expected.");
5333 } else {
5334 setverdict(fail, "f_probe_for_handover(" & log_label & "): Expected none, but got BSSMAP Handover Required. "
5335 & log_label & ": " & log_descr);
5336 }
5337
5338 log("f_probe_for_handover(" & log_label & "): done (got BSSMAP Handover Required)");
5339
5340 /* Note: f_tc_ho_neighbor_config_start() sets T7, the timeout for BSSMAP Handover Required, to
5341 * 1 second. There is no legal way to quickly abort a handover after a BSSMAP Handover Required,
5342 * setting a short timeout and waiting is the only way. */
5343 log("f_probe_for_handover(" & log_label & "): waiting for inter-BSC HO to time out...");
5344 f_sleep(1.5);
5345 log("f_probe_for_handover(" & log_label & "): ...done");
5346
5347 break;
5348 }
5349 [] T.timeout {
5350 if (expect_handover) {
5351 setverdict(fail, "f_probe_for_handover(" & log_label & "): Expected Handover, but got none. "
5352 & log_label & ": " & log_descr);
5353 } else {
5354 setverdict(pass);
5355 log("f_probe_for_handover(" & log_label & "): Got no Handover, as expected.");
5356 }
5357 log("f_probe_for_handover(" & log_label & "): done (got no Handover)");
5358 break;
5359 }
5360 }
5361
5362 f_rslem_resume(RSL1_PROC);
5363 f_rslem_resume(RSL2_PROC);
5364 f_sleep(3.0);
5365 RSL.clear;
5366
5367 log("f_probe_for_handover(" & log_label & "): done clearing");
5368}
5369
5370/* Test the effect of various neighbor configuration scenarios:
5371 *
5372 * To avoid complexity, block off any actual handover operation, and always remain on the lchan at bts 0.
5373 * Reconfigure the neighbors for bts 0, trigger a Handover, and probe whether osmo-bsc does or doesn't start HO.
5374 */
5375private function f_tc_ho_neighbor_config_start() runs on MSC_ConnHdlr {
5376 g_pars := f_gen_test_hdlr_pars();
5377 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
5378 var PDU_BSSAP ass_cmd := f_gen_ass_req();
5379 const OCT8 kc := '0001020304050607'O;
5380
5381 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
5382 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
5383
5384 /* Establish lchan at bts 0 */
5385 f_establish_fully(ass_cmd, exp_compl);
5386
5387 /* Shorten the inter-BSC Handover timeout, to not wait so long for inter-BSC Handovers */
5388 f_vty_enter_cfg_network(BSCVTY);
5389 f_vty_transceive(BSCVTY, "timer T7 1");
5390 f_vty_transceive(BSCVTY, "end");
5391}
5392
5393private function f_tc_ho_neighbor_config_1(charstring id) runs on MSC_ConnHdlr {
5394 f_tc_ho_neighbor_config_start();
5395
5396 /*
5397 * bts 0 ARFCN 871 BSIC 10
5398 * bts 1 ARFCN 871 BSIC 11
5399 * bts 2 ARFCN 871 BSIC 12
5400 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
5401 */
5402
5403 log("f_tc_ho_neighbor_config: 1. No 'neighbor' config");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005404 f_bts_0_cfg(BSCVTY, {"no neighbors"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02005405 f_probe_for_handover("1.a", "HO to bts 1 works, implicitly listed as neighbor (legacy behavior when none are configured)",
5406 "handover any to arfcn 871 bsic 11",
5407 true);
5408
5409 f_probe_for_handover("1.b", "HO to unknown cell does not start",
5410 "handover any to arfcn 13 bsic 39",
5411 false);
5412
5413 f_probe_for_handover("1.c", "HO to 871-12 is ambiguous = error",
5414 "handover any to arfcn 871 bsic 12",
5415 false);
5416
5417 f_probe_for_handover("1.d", "HO to 871-11 still works (verify that this test properly cleans up)",
5418 "handover any to arfcn 871 bsic 11",
5419 true);
5420}
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005421testcase TC_ho_neighbor_config_1() runs on test_CT {
5422 var MSC_ConnHdlr vc_conn;
5423 f_init(3, true, guard_timeout := 60.0);
5424 f_sleep(1.0);
5425 f_ctrs_bsc_and_bts_init();
5426 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_1));
5427 vc_conn.done;
5428
5429 /* f_tc_ho_neighbor_config_start() */
5430 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5431 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5432
5433 /* 1.a */
5434 /* "failed" means a handover was triggered and started (which is all this test aims for) and the test ended the
5435 * handover quickly by sending a Handover Failure message. */
5436 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5437 f_ctrs_bsc_and_bts_add(0, "handover:failed");
5438 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
5439 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:failed");
5440
5441 /* 1.b */
5442 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5443 f_ctrs_bsc_and_bts_add(0, "handover:error");
5444
5445 /* 1.c */
5446 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5447 f_ctrs_bsc_and_bts_add(0, "handover:error");
5448
5449 /* 1.d */
5450 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5451 f_ctrs_bsc_and_bts_add(0, "handover:failed");
5452 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
5453 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:failed");
5454
5455 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005456 f_shutdown_helper();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005457}
5458
Neels Hofmeyr91401012019-07-11 00:42:35 +02005459private function f_tc_ho_neighbor_config_2(charstring id) runs on MSC_ConnHdlr {
5460 f_tc_ho_neighbor_config_start();
5461
5462 /*
5463 * bts 0 ARFCN 871 BSIC 10
5464 * bts 1 ARFCN 871 BSIC 11
5465 * bts 2 ARFCN 871 BSIC 12
5466 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
5467 */
5468
5469 log("f_tc_ho_neighbor_config: 2. explicit local neighbor: 'neighbor bts 1'");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005470 f_bts_0_cfg(BSCVTY, {"neighbor bts 1"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02005471 f_sleep(0.5);
5472
5473 f_probe_for_handover("2.a", "HO to bts 1 works, explicitly listed as neighbor",
5474 "handover any to arfcn 871 bsic 11",
5475 true);
5476
5477 f_probe_for_handover("2.b", "HO to bts 2 doesn't work, not listed as neighbor",
5478 "handover any to arfcn 871 bsic 12",
5479 false);
5480}
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005481testcase TC_ho_neighbor_config_2() runs on test_CT {
5482 var MSC_ConnHdlr vc_conn;
5483 f_init(3, true, guard_timeout := 50.0);
5484 f_sleep(1.0);
5485 f_ctrs_bsc_and_bts_init();
5486 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_2));
5487 vc_conn.done;
5488
5489 /* f_tc_ho_neighbor_config_start() */
5490 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5491 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5492
5493 /* 2.a */
5494 /* "failed" means a handover was triggered and started (which is all this test aims for) and the test ended the
5495 * handover quickly by sending a Handover Failure message. */
5496 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5497 f_ctrs_bsc_and_bts_add(0, "handover:failed");
5498 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
5499 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:failed");
5500
5501 /* 2.b */
5502 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5503 f_ctrs_bsc_and_bts_add(0, "handover:error");
5504
5505 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005506 f_shutdown_helper();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005507}
5508
Neels Hofmeyr91401012019-07-11 00:42:35 +02005509private function f_tc_ho_neighbor_config_3(charstring id) runs on MSC_ConnHdlr {
5510 f_tc_ho_neighbor_config_start();
5511
5512 /*
5513 * bts 0 ARFCN 871 BSIC 10
5514 * bts 1 ARFCN 871 BSIC 11
5515 * bts 2 ARFCN 871 BSIC 12
5516 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
5517 */
5518
5519 log("f_tc_ho_neighbor_config: 3. explicit local neighbor: 'neighbor bts 2'");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005520 f_bts_0_cfg(BSCVTY, {"no neighbors", "neighbor bts 2"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02005521 f_sleep(0.5);
5522
5523 f_probe_for_handover("3.a", "HO to bts 1 doesn't work, not listed as neighbor",
5524 "handover any to arfcn 871 bsic 11",
5525 false);
5526 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",
5527 "handover any to arfcn 871 bsic 12",
5528 true);
5529}
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005530testcase TC_ho_neighbor_config_3() runs on test_CT {
5531 var MSC_ConnHdlr vc_conn;
5532 f_init(3, true, guard_timeout := 50.0);
5533 f_sleep(1.0);
5534 f_ctrs_bsc_and_bts_init();
5535 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_3));
5536 vc_conn.done;
5537
5538 /* f_tc_ho_neighbor_config_start() */
5539 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5540 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5541
5542 /* 3.a */
5543 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5544 f_ctrs_bsc_and_bts_add(0, "handover:error");
5545
5546 /* 3.b */
5547 /* "failed" means a handover was triggered and started (which is all this test aims for) and the test ended the
5548 * handover quickly by sending a Handover Failure message. */
5549 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5550 f_ctrs_bsc_and_bts_add(0, "handover:failed");
5551 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
5552 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:failed");
5553
5554 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005555 f_shutdown_helper();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005556}
5557
Neels Hofmeyr91401012019-07-11 00:42:35 +02005558private function f_tc_ho_neighbor_config_4(charstring id) runs on MSC_ConnHdlr {
5559 f_tc_ho_neighbor_config_start();
5560
5561 /*
5562 * bts 0 ARFCN 871 BSIC 10
5563 * bts 1 ARFCN 871 BSIC 11
5564 * bts 2 ARFCN 871 BSIC 12
5565 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
5566 */
5567
5568 log("f_tc_ho_neighbor_config: 4. explicit remote neighbor: 'neighbor lac 99 arfcn 123 bsic 45'");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005569 f_bts_0_cfg(BSCVTY, {"no neighbors", "neighbor lac 99 arfcn 123 bsic 45"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02005570 f_sleep(0.5);
5571
5572 f_probe_for_handover("4.a", "HO to bts 1 doesn't work, not listed as neighbor",
5573 "handover any to arfcn 871 bsic 11",
5574 false);
5575 f_probe_for_handover("4.b", "HO to bts 2 doesn't work, not listed as neighbor",
5576 "handover any to arfcn 871 bsic 12",
5577 false);
5578 f_probe_for_handover("4.c", "HO to 123-45 triggers inter-BSC HO",
5579 "handover any to arfcn 123 bsic 45",
5580 true, true);
5581}
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005582testcase TC_ho_neighbor_config_4() runs on test_CT {
5583 var MSC_ConnHdlr vc_conn;
5584 f_init(3, true, guard_timeout := 50.0);
5585 f_sleep(1.0);
5586 f_ctrs_bsc_and_bts_init();
5587 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_4));
5588 vc_conn.done;
5589
5590 /* f_tc_ho_neighbor_config_start() */
5591 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5592 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5593
5594 /* 4.a */
5595 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5596 f_ctrs_bsc_and_bts_add(0, "handover:error");
5597
5598 /* 4.b */
5599 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5600 f_ctrs_bsc_and_bts_add(0, "handover:error");
5601
5602 /* 4.c */
5603 /* "timeout" means a handover was triggered and started (which is all this test aims for) and the test ended the
5604 * handover quickly by timing out after the Handover Required message */
5605 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5606 f_ctrs_bsc_and_bts_add(0, "handover:timeout");
5607 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
5608 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:timeout");
5609
5610 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005611 f_shutdown_helper();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005612}
5613
Neels Hofmeyr91401012019-07-11 00:42:35 +02005614private function f_tc_ho_neighbor_config_5(charstring id) runs on MSC_ConnHdlr {
5615 f_tc_ho_neighbor_config_start();
5616
5617 /*
5618 * bts 0 ARFCN 871 BSIC 10
5619 * bts 1 ARFCN 871 BSIC 11
5620 * bts 2 ARFCN 871 BSIC 12
5621 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
5622 */
5623
5624 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 +02005625 f_bts_0_cfg(BSCVTY, {"no neighbors", "neighbor lac 99 arfcn 871 bsic 12"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02005626 f_sleep(0.5);
5627
5628 f_probe_for_handover("5.a", "HO to 871-12 triggers inter-BSC HO (ignoring local cells with same ARFCN+BSIC)",
5629 "handover any to arfcn 871 bsic 12",
5630 true, true);
5631}
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005632testcase TC_ho_neighbor_config_5() runs on test_CT {
5633 var MSC_ConnHdlr vc_conn;
5634 f_init(3, true);
5635 f_sleep(1.0);
5636 f_ctrs_bsc_and_bts_init();
5637 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_5));
5638 vc_conn.done;
5639
5640 /* f_tc_ho_neighbor_config_start() */
5641 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5642 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5643
5644 /* 5 */
5645 /* "timeout" means a handover was triggered and started (which is all this test aims for) and the test ended the
5646 * handover quickly by timing out after the Handover Required message */
5647 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5648 f_ctrs_bsc_and_bts_add(0, "handover:timeout");
5649 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
5650 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:timeout");
5651
5652 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005653 f_shutdown_helper();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005654}
5655
Neels Hofmeyr91401012019-07-11 00:42:35 +02005656private function f_tc_ho_neighbor_config_6(charstring id) runs on MSC_ConnHdlr {
5657 f_tc_ho_neighbor_config_start();
5658
5659 /*
5660 * bts 0 ARFCN 871 BSIC 10
5661 * bts 1 ARFCN 871 BSIC 11
5662 * bts 2 ARFCN 871 BSIC 12
5663 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
5664 */
5665
5666 log("f_tc_ho_neighbor_config: 6. config error: explicit local and remote neighbors with ambiguous ARFCN+BSIC:"
5667 & " 'neighbor bts 2; neighbor lac 99 arfcn 871 bsic 12'");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005668 f_bts_0_cfg(BSCVTY, {"no neighbors", "neighbor bts 2", "neighbor lac 99 arfcn 871 bsic 12"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02005669 f_sleep(0.5);
5670
5671 f_probe_for_handover("6.a", "HO to 871-12 is ambiguous = error",
5672 "handover any to arfcn 871 bsic 12",
5673 false);
5674}
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005675testcase TC_ho_neighbor_config_6() runs on test_CT {
5676 var MSC_ConnHdlr vc_conn;
5677 f_init(3, true);
5678 f_sleep(1.0);
5679 f_ctrs_bsc_and_bts_init();
5680 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_6));
5681 vc_conn.done;
5682
5683 /* f_tc_ho_neighbor_config_start() */
5684 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5685 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5686
5687 /* 6.a */
5688 /* "timeout" means a handover was triggered and started (which is all this test aims for) and the test ended the
5689 * handover quickly by timing out after the Handover Required message */
5690 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5691 f_ctrs_bsc_and_bts_add(0, "handover:error");
5692
5693 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005694 f_shutdown_helper();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005695}
5696
Neels Hofmeyr91401012019-07-11 00:42:35 +02005697private function f_tc_ho_neighbor_config_7(charstring id) runs on MSC_ConnHdlr {
5698 f_tc_ho_neighbor_config_start();
5699
5700 /*
5701 * bts 0 ARFCN 871 BSIC 10
5702 * bts 1 ARFCN 871 BSIC 11
5703 * bts 2 ARFCN 871 BSIC 12
5704 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
5705 */
5706
5707 log("f_tc_ho_neighbor_config: 7. explicit local and remote neighbors:"
5708 & " 'neighbor bts 2; neighbor lac 99 arfcn 123 bsic 45'");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005709 f_bts_0_cfg(BSCVTY, {"no neighbors", "neighbor bts 2", "neighbor lac 99 arfcn 123 bsic 45"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02005710 f_sleep(0.5);
5711
5712 f_probe_for_handover("7.a", "HO to 871-12 does HO to bts 2",
5713 "handover any to arfcn 871 bsic 12",
5714 true);
5715 f_probe_for_handover("7.b", "HO to 123-45 triggers inter-BSC HO",
5716 "handover any to arfcn 123 bsic 45",
5717 true, true);
5718}
Neels Hofmeyr91401012019-07-11 00:42:35 +02005719testcase TC_ho_neighbor_config_7() runs on test_CT {
5720 var MSC_ConnHdlr vc_conn;
Neels Hofmeyrf2b88032020-06-16 00:35:04 +02005721 f_init(3, true, guard_timeout := 50.0);
Neels Hofmeyr91401012019-07-11 00:42:35 +02005722 f_sleep(1.0);
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005723 f_ctrs_bsc_and_bts_init();
Neels Hofmeyr91401012019-07-11 00:42:35 +02005724 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_7));
5725 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005726
5727 /* f_tc_ho_neighbor_config_start() */
5728 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5729 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5730
5731 /* 7.a */
5732 /* "failed" means a handover was triggered and started (which is all this test aims for) and the test ended the
5733 * handover quickly by sending a Handover Failure message. */
5734 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5735 f_ctrs_bsc_and_bts_add(0, "handover:failed");
5736 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
5737 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:failed");
5738
5739 /* 7.b */
5740 /* "timeout" means a handover was triggered and started (which is all this test aims for) and the test ended the
5741 * handover quickly by timing out after the Handover Required message */
5742 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5743 f_ctrs_bsc_and_bts_add(0, "handover:timeout");
5744 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
5745 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:timeout");
5746
5747 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005748 f_shutdown_helper();
Neels Hofmeyr91401012019-07-11 00:42:35 +02005749}
5750
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01005751/* OS#3041: Open and close N connections in a normal fashion, and expect no
5752 * BSSMAP Reset just because of that. */
5753testcase TC_bssap_rlsd_does_not_cause_bssmap_reset() runs on test_CT {
5754 var default d;
5755 var integer i;
5756 var DchanTuple dt;
5757
5758 f_init();
5759
5760 /* Wait for initial BSSMAP Reset to pass */
5761 f_sleep(4.0);
5762
5763 d := activate(no_bssmap_reset());
5764
5765 /* Setup up a number of connections and RLSD them again from the MSC
5766 * side. In the buggy behavior, the fourth one triggers BSSMAP Reset.
5767 * Let's do it some more times for good measure. */
Harald Weltec3260d92018-06-11 17:48:16 +02005768 for (i := 0; i < 4; i := i+1) {
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01005769 /* Since we're doing a lot of runs, give each one a fresh
5770 * T_guard from the top. */
5771 T_guard.start;
5772
5773 /* Setup a BSSAP connection and clear it right away. This is
5774 * the MSC telling the BSC about a planned release, it's not an
5775 * erratic loss of a connection. */
Harald Weltea1897182018-06-11 13:53:09 +02005776 dt := f_est_dchan(int2oct(i,1), 23+i, '00010203040506'O);
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01005777
5778 /* MSC disconnects (RLSD). */
5779 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
5780 }
5781
5782 /* In the buggy behavior, a timeout of 2 seconds happens between above
5783 * trigger (logs "SIGTRAN connection down, reconnecting...") and the
5784 * actual BSSMAP Reset. Wait a bit longer just to make sure. */
5785 f_sleep(4.0);
5786
5787 deactivate(d);
5788 f_shutdown_helper();
5789}
Harald Welte552620d2017-12-16 23:21:36 +01005790
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01005791/* OS#3041: Open and close N connections in a normal fashion, and expect no
5792 * BSSMAP Reset just because of that. Invoke the release by a BSSMAP Clear from
5793 * the MSC. */
5794testcase TC_bssmap_clear_does_not_cause_bssmap_reset() runs on test_CT {
5795 var default d;
5796 var integer i;
5797 var DchanTuple dt;
5798 var BSSAP_N_DATA_ind rx_di;
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01005799 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_CALL_CONTROL;
5800 var BssmapCause cause := enum2int(cause_val);
5801
5802 f_init();
5803
5804 /* Wait for initial BSSMAP Reset to pass */
5805 f_sleep(4.0);
5806
5807 d := activate(no_bssmap_reset());
5808
5809 /* Setup up a number of connections and RLSD them again from the MSC
5810 * side. In the buggy behavior, the fourth one triggers BSSMAP Reset.
5811 * Let's do it some more times for good measure. */
5812 for (i := 0; i < 8; i := i+1) {
5813 /* Since we're doing a lot of runs, give each one a fresh
5814 * T_guard from the top. */
5815 T_guard.start;
5816
5817 /* Setup a BSSAP connection and clear it right away. This is
5818 * the MSC telling the BSC about a planned release, it's not an
5819 * erratic loss of a connection. */
Harald Weltea1897182018-06-11 13:53:09 +02005820 dt := f_est_dchan(int2oct(i,1), 23+i, '00010203040506'O);
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01005821
5822 /* Instruct BSC to clear channel */
5823 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
5824
5825 /* expect BSC to disable the channel */
Harald Welte641fcbe2018-06-14 10:58:35 +02005826 f_exp_chan_rel_and_clear(dt, 0);
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01005827 }
5828
5829 /* In the buggy behavior, a timeout of 2 seconds happens between above
5830 * trigger (logs "SIGTRAN connection down, reconnecting...") and the
5831 * actual BSSMAP Reset. Wait a bit longer just to make sure. */
5832 f_sleep(4.0);
5833
5834 deactivate(d);
5835 f_shutdown_helper();
5836}
5837
Neels Hofmeyrfd445c32018-03-09 15:39:31 +01005838/* OS#3041: Open and close N connections in a normal fashion, and expect no
5839 * BSSMAP Reset just because of that. Close connections from the MS side with a
5840 * Release Ind on RSL. */
5841testcase TC_ms_rel_ind_does_not_cause_bssmap_reset() runs on test_CT {
5842 var default d;
5843 var integer i;
5844 var DchanTuple dt;
5845 var BSSAP_N_DATA_ind rx_di;
Neels Hofmeyrfd445c32018-03-09 15:39:31 +01005846 var integer j;
5847
5848 f_init();
5849
5850 /* Wait for initial BSSMAP Reset to pass */
5851 f_sleep(4.0);
5852
5853 d := activate(no_bssmap_reset());
5854
5855 /* Setup up a number of connections and RLSD them again from the MSC
5856 * side. In the buggy behavior, the fourth one triggers BSSMAP Reset.
5857 * Let's do it some more times for good measure. */
5858 for (i := 0; i < 8; i := i+1) {
5859 /* Since we're doing a lot of runs, give each one a fresh
5860 * T_guard from the top. */
5861 T_guard.start;
5862
5863 /* Setup a BSSAP connection and clear it right away. This is
5864 * the MSC telling the BSC about a planned release, it's not an
5865 * erratic loss of a connection. */
5866 dt := f_est_dchan('23'O, 23, '00010203040506'O);
5867
5868 /* simulate RLL REL IND */
5869 f_ipa_tx(0, ts_RSL_REL_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0))));
5870
5871 /* expect Clear Request on MSC side */
5872 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearRequest)) -> value rx_di;
5873
5874 /* Instruct BSC to clear channel */
5875 var BssmapCause cause := bit2int(rx_di.userData.pdu.bssmap.clearRequest.cause.causeValue);
5876 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
5877
5878 /* expect BSC to disable the channel */
Harald Welte641fcbe2018-06-14 10:58:35 +02005879 f_exp_chan_rel_and_clear(dt, 0);
Neels Hofmeyrfd445c32018-03-09 15:39:31 +01005880 }
5881
5882 /* In the buggy behavior, a timeout of 2 seconds happens between above
5883 * trigger (logs "SIGTRAN connection down, reconnecting...") and the
5884 * actual BSSMAP Reset. Wait a bit longer just to make sure. */
5885 f_sleep(4.0);
5886
5887 deactivate(d);
5888 f_shutdown_helper();
5889}
5890
Harald Welte94e0c342018-04-07 11:33:23 +02005891/***********************************************************************
5892 * IPA style dynamic PDCH
5893 ***********************************************************************/
5894
5895private function f_dyn_ipa_pdch_act(integer bts_nr, integer trx_nr, integer ts_nr,
5896 template (omit) RSL_Cause nack := omit)
5897runs on test_CT {
5898 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(ts_nr));
5899 var RSL_Message rsl_unused;
5900 /* ask BSC via VTY to activate a given IPA style chan as PDCH */
5901 f_vty_ts_action("pdch activate", bts_nr, trx_nr, ts_nr);
5902 /* expect the BSC to issue the related RSL command */
5903 rsl_unused := f_exp_ipa_rx(0, tr_RSL_IPA_PDCH_ACT(chan_nr));
5904 if (istemplatekind(nack, "omit")) {
5905 /* respond with a related acknowledgement */
5906 f_ipa_tx(0, ts_RSL_IPA_PDCH_ACT_ACK(chan_nr, ts_RSL_IE_FrameNumber(2342)));
5907 } else {
5908 f_ipa_tx(0, ts_RSL_IPA_PDCH_ACT_NACK(chan_nr, valueof(nack)));
5909 }
5910}
5911
5912private function f_dyn_ipa_pdch_deact(integer bts_nr, integer trx_nr, integer ts_nr,
5913 template (omit) RSL_Cause nack := omit)
5914runs on test_CT {
5915 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(ts_nr));
5916 var RSL_Message rsl_unused;
5917 /* ask BSC via VTY to activate a given IPA style chan as PDCH */
5918 f_vty_ts_action("pdch deactivate", bts_nr, trx_nr, ts_nr);
5919 /* expect the BSC to issue the related RSL command */
5920 rsl_unused := f_exp_ipa_rx(0, tr_RSL_IPA_PDCH_DEACT(chan_nr));
5921 if (istemplatekind(nack, "omit")) {
5922 /* respond with a related acknowledgement */
5923 f_ipa_tx(0, ts_RSL_IPA_PDCH_DEACT_ACK(chan_nr));
5924 } else {
5925 f_ipa_tx(0, ts_RSL_IPA_PDCH_DEACT_NACK(chan_nr, valueof(nack)));
5926 }
5927}
5928
5929private function f_ts_dyn_mode_get(integer bts_nr, integer trx_nr, integer ts_nr)
5930runs on test_CT return charstring {
5931 var charstring cmd, resp;
5932 cmd := "show timeslot "&int2str(bts_nr)&" "&int2str(trx_nr)&" "&int2str(ts_nr);
Stefan Sperlingcff13562018-11-13 15:24:06 +01005933 return f_vty_transceive_match_regexp_retry(BSCVTY, cmd, "*\((*)\)*", 0, 4, 1.0);
Harald Welte94e0c342018-04-07 11:33:23 +02005934}
5935
5936private function f_ts_dyn_mode_assert(integer bts_nr, integer trx_nr, integer ts_nr,
5937 template charstring exp)
5938runs on test_CT {
5939 var charstring mode := f_ts_dyn_mode_get(bts_nr, trx_nr, ts_nr);
5940 if (not match(mode, exp)) {
5941 setverdict(fail, "Unexpected TS Mode: ", mode);
Daniel Willmannafce8662018-07-06 23:11:32 +02005942 mtc.stop;
Harald Welte94e0c342018-04-07 11:33:23 +02005943 }
5944}
5945
5946private function f_ts_set_chcomb(integer bts_nr, integer trx_nr, integer ts_nr, charstring chcomb)
5947runs on test_CT {
5948 f_vty_enter_cfg_ts(BSCVTY, bts_nr, trx_nr, ts_nr);
5949 f_vty_transceive(BSCVTY, "phys_chan_config " & chcomb);
5950 f_vty_transceive(BSCVTY, "end");
5951}
5952
5953private const charstring TCHF_MODE := "TCH/F mode";
5954private const charstring TCHH_MODE := "TCH/H mode";
5955private const charstring PDCH_MODE := "PDCH mode";
5956private const charstring NONE_MODE := "NONE mode";
5957
5958/* Test IPA PDCH activation / deactivation triggered by VTY */
5959testcase TC_dyn_pdch_ipa_act_deact() runs on test_CT {
5960 var RSL_Message rsl_unused;
5961
5962 /* change Timeslot 6 before f_init() starts RSL */
5963 f_init_vty();
5964 f_ts_set_chcomb(0, 0, 6, "TCH/F_PDCH");
5965 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
5966
5967 f_init(1, false);
5968 f_sleep(1.0);
5969
5970 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(6));
5971
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02005972 log("TCH/F_PDCH pchan starts out in TCH/F mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02005973 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
5974 /* The BSC will activate the dynamic PDCH by default, so confirm that */
5975 rsl_unused := f_exp_ipa_rx(0, tr_RSL_IPA_PDCH_ACT(chan_nr));
5976 f_ipa_tx(0, ts_RSL_IPA_PDCH_ACT_ACK(chan_nr, ts_RSL_IE_FrameNumber(2342)));
5977 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02005978 log("TCH/F_PDCH pchan, PDCH ACT was ACKed, so now in PDCH mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02005979 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, PDCH_MODE);
5980
5981 /* De-activate it via VTY */
5982 f_dyn_ipa_pdch_deact(0, 0, chan_nr.tn);
5983 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02005984 log("TCH/F_PDCH pchan, PDCH DEACT via VTY, so now back in TCH/F mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02005985 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
5986
5987 /* re-activate it via VTY */
5988 f_dyn_ipa_pdch_act(0, 0, chan_nr.tn);
5989 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02005990 log("TCH/F_PDCH pchan, PDCH ACT via VTY, so now in PDCH mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02005991 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, PDCH_MODE);
5992
5993 /* and finally de-activate it again */
5994 f_dyn_ipa_pdch_deact(0, 0, chan_nr.tn);
5995 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02005996 log("TCH/F_PDCH pchan, PDCH DEACT via VTY, so now back in TCH/F mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02005997 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
5998
Neels Hofmeyr887e8f12018-06-27 01:01:55 +02005999 /* clean up config */
6000 f_ts_set_chcomb(0, 0, 6, "PDCH");
6001
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006002 f_shutdown_helper();
Harald Welte94e0c342018-04-07 11:33:23 +02006003}
6004
6005/* Test IPA PDCH activation NACK */
6006testcase TC_dyn_pdch_ipa_act_nack() runs on test_CT {
6007 var RSL_Message rsl_unused;
6008
6009 /* change Timeslot 6 before f_init() starts RSL */
6010 f_init_vty();
6011 f_ts_set_chcomb(0, 0, 6, "TCH/F_PDCH");
6012 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
6013
6014 f_init(1, false);
6015 f_sleep(1.0);
6016
6017 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(6));
6018
6019 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
6020 /* The BSC will activate the dynamic PDCH by default, so confirm that */
6021 rsl_unused := f_exp_ipa_rx(0, tr_RSL_IPA_PDCH_ACT(chan_nr));
6022 f_ipa_tx(0, ts_RSL_IPA_PDCH_ACT_ACK(chan_nr, ts_RSL_IE_FrameNumber(2342)));
6023 f_sleep(1.0);
6024 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, PDCH_MODE);
6025
6026 /* De-activate it via VTY */
6027 f_dyn_ipa_pdch_deact(0, 0, chan_nr.tn);
6028 f_sleep(1.0);
6029 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
6030
6031 /* re-activate it via VTY, but fail that; check BSC still assumes TCH/F mode */
6032 f_dyn_ipa_pdch_act(0, 0, chan_nr.tn, RSL_ERR_EQUIPMENT_FAIL);
6033 f_sleep(1.0);
6034 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
6035
Neels Hofmeyr887e8f12018-06-27 01:01:55 +02006036 /* clean up config */
6037 f_ts_set_chcomb(0, 0, 6, "PDCH");
6038
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006039 f_shutdown_helper();
Harald Welte94e0c342018-04-07 11:33:23 +02006040}
6041
6042
6043/***********************************************************************
6044 * Osmocom style dynamic PDCH
6045 ***********************************************************************/
6046
6047private function f_dyn_osmo_pdch_act(integer bts_nr, integer trx_nr, integer ts_nr,
6048 template (omit) RSL_Cause nack := omit)
6049runs on test_CT {
6050 var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(ts_nr));
6051 var RSL_Message rsl_unused;
6052 /* ask BSC via VTY to activate a given IPA style chan as PDCH */
6053 /* FIXME: no VTY command to activate Osmocom PDCH !! */
6054 /* expect the BSC to issue the related RSL command */
6055 rsl_unused := f_exp_ipa_rx(0, tr_RSL_CHAN_ACT(chan_nr, ?));
6056 if (istemplatekind(nack, "omit")) {
6057 /* respond with a related acknowledgement */
6058 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, 2342));
6059 } else {
6060 f_ipa_tx(0, ts_RSL_CHAN_ACT_NACK(chan_nr, valueof(nack)));
6061 }
6062}
6063
6064private function f_dyn_osmo_pdch_deact(integer bts_nr, integer trx_nr, integer ts_nr,
6065 template (omit) RSL_Cause nack := omit)
6066runs on test_CT {
6067 var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(ts_nr));
6068 var RSL_Message rsl_unused;
6069 /* ask BSC via VTY to activate a given IPA style chan as PDCH */
6070 /* FIXME: no VTY command to activate Osmocom PDCH !! */
6071 /* expect the BSC to issue the related RSL command */
6072 rsl_unused := f_exp_ipa_rx(0, tr_RSL_RF_CHAN_REL(chan_nr));
6073 if (istemplatekind(nack, "omit")) {
6074 /* respond with a related acknowledgement */
6075 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(chan_nr));
6076 } else {
6077 //f_ipa_tx(0, ts_RSL_RF_CHAN_REL_NACK(chan_nr, valueof(nack)));
6078 }
6079}
6080
6081/* Test Osmocom dyn PDCH activation / deactivation triggered by VTY */
6082testcase TC_dyn_pdch_osmo_act_deact() runs on test_CT {
6083 var RSL_Message rsl_unused;
6084
6085 /* change Timeslot 6 before f_init() starts RSL */
6086 f_init_vty();
6087 f_ts_set_chcomb(0, 0, 6, "TCH/F_TCH/H_PDCH");
6088 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
6089
6090 f_init(1, false);
6091 f_sleep(1.0);
6092
6093 var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(6));
6094
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02006095 log("TCH/F_TCH/H_PDCH pchan starts out in disabled mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02006096 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, NONE_MODE);
6097 /* The BSC will activate the dynamic PDCH by default, so confirm that */
6098 rsl_unused := f_exp_ipa_rx(0, tr_RSL_CHAN_ACT_PDCH(chan_nr, ?));
6099
6100 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, 2342));
6101 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02006102 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 +02006103 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, PDCH_MODE);
6104
Neels Hofmeyr887e8f12018-06-27 01:01:55 +02006105 /* clean up config */
6106 f_ts_set_chcomb(0, 0, 6, "PDCH");
6107
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006108 f_shutdown_helper();
Harald Welte94e0c342018-04-07 11:33:23 +02006109}
6110
6111/* Test Osmocom dyn PDCH activation NACK behavior */
6112testcase TC_dyn_pdch_osmo_act_nack() runs on test_CT {
6113 var RSL_Message rsl_unused;
6114
6115 /* change Timeslot 6 before f_init() starts RSL */
6116 f_init_vty();
6117 f_ts_set_chcomb(0, 0, 6, "TCH/F_TCH/H_PDCH");
6118 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
6119
6120 f_init(1, false);
6121 f_sleep(1.0);
6122
6123 var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(6));
6124
6125 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, NONE_MODE);
6126 /* The BSC will activate the dynamic PDCH by default, so confirm that */
6127 rsl_unused := f_exp_ipa_rx(0, tr_RSL_CHAN_ACT_PDCH(chan_nr, ?));
6128
6129 /* NACK this activation and expect the "show timeslot" mode still to be NONE */
6130 f_ipa_tx(0, ts_RSL_CHAN_ACT_NACK(chan_nr, RSL_ERR_EQUIPMENT_FAIL));
6131 f_sleep(1.0);
6132 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, NONE_MODE);
6133
Neels Hofmeyr887e8f12018-06-27 01:01:55 +02006134 /* clean up config */
6135 f_ts_set_chcomb(0, 0, 6, "PDCH");
6136
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006137 f_shutdown_helper();
Harald Welte94e0c342018-04-07 11:33:23 +02006138}
6139
Stefan Sperling0796a822018-10-05 13:01:39 +02006140testcase TC_chopped_ipa_ping() runs on test_CT {
Stefan Sperling554123f2018-10-09 14:12:30 +02006141 const Integers bsc_ipa_ports := {mp_bsc_rsl_port, mp_bsc_oml_port, mp_bsc_ctrl_port};
Stefan Sperling0796a822018-10-05 13:01:39 +02006142 for (var integer i := 0; i < lengthof(bsc_ipa_ports); i := i + 1) {
6143 IPA_Testing.f_run_TC_chopped_ipa_ping(mp_bsc_ip, bsc_ipa_ports[i], CONNECT_TO_SERVER);
6144 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006145 f_shutdown_helper();
Stefan Sperling0796a822018-10-05 13:01:39 +02006146}
6147
Stefan Sperlingaa1e60f2018-10-15 16:34:07 +02006148testcase TC_chopped_ipa_payload() runs on test_CT {
6149 const Integers bsc_ipa_ports := {mp_bsc_rsl_port, mp_bsc_oml_port
6150 /* TODO: mp_bsc_ctrl_port does not work yet */};
6151 for (var integer i := 0; i < lengthof(bsc_ipa_ports); i := i + 1) {
6152 IPA_Testing.f_run_TC_chopped_ipa_payload(mp_bsc_ip, bsc_ipa_ports[i], CONNECT_TO_SERVER);
6153 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006154 f_shutdown_helper();
Stefan Sperlingaa1e60f2018-10-15 16:34:07 +02006155}
6156
Pau Espin Pedrol8f773632019-11-05 11:46:53 +01006157/* Verify the BSC sends the MS Power Parameters IE during CHAN ACT to make sure
6158 the BTS does autonomous MS power control loop */
6159testcase TC_assignment_verify_ms_power_params_ie() runs on test_CT {
6160 var MSC_ConnHdlr vc_conn;
6161 var TestHdlrParams pars := f_gen_test_hdlr_pars();
6162 //pars.encr := valueof(t_EncrParams('01'O, f_rnd_octstring(8)));
6163 pars.exp_ms_power_params := true;
6164
6165 f_init(1, true);
6166 f_sleep(1.0);
6167 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5), pars);
6168 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006169 f_shutdown_helper();
Pau Espin Pedrol8f773632019-11-05 11:46:53 +01006170}
Stefan Sperlingaa1e60f2018-10-15 16:34:07 +02006171
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006172/***********************************************************************
6173 * MSC Pooling
6174 ***********************************************************************/
6175
6176function f_tmsi_nri(integer nri_v, octetstring base_tmsi := '42000023'O, integer nri_bitlen := 10) return octetstring
6177{
6178 return int2oct( oct2int(base_tmsi) + bit2int( (int2bit(nri_v, 32) << ( 24 - nri_bitlen)) ),
6179 4);
6180}
6181
6182template MobileIdentityLV ts_MI_TMSI_NRI_LV(integer nri_v, integer nri_bitlen := 10) :=
6183 ts_MI_TMSI_LV(tmsi := f_tmsi_nri(nri_v, nri_bitlen := nri_bitlen));
6184
6185private function f_perform_clear(RSL_DCHAN_PT rsl) runs on MSC_ConnHdlr {
Neels Hofmeyr767548a2020-08-09 20:26:07 +00006186 f_logp(BSCVTY, "MSC instructs BSC to clear channel");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006187 BSSAP.send(ts_BSSMAP_ClearCommand(0));
6188 interleave {
6189 [] rsl.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_RELEASE)) {
Neels Hofmeyr767548a2020-08-09 20:26:07 +00006190 f_logp(BSCVTY, "Got RSL RR Release");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006191 }
6192 [] rsl.receive(tr_RSL_DEACT_SACCH(g_chan_nr)) {
Neels Hofmeyr767548a2020-08-09 20:26:07 +00006193 f_logp(BSCVTY, "Got RSL Deact SACCH");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006194 }
6195 [] BSSAP.receive(tr_BSSMAP_ClearComplete) {
Neels Hofmeyr767548a2020-08-09 20:26:07 +00006196 f_logp(BSCVTY, "Got BSSMAP Clear Complete");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006197 /* Also drop the SCCP connection */
6198 BSSAP.send(RAN_Conn_Prim:MSC_CONN_PRIM_DISC_REQ);
6199 }
6200 [] rsl.receive(tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL)) {
Neels Hofmeyr767548a2020-08-09 20:26:07 +00006201 f_logp(BSCVTY, "Got RSL RF Chan Rel, sending Rel Ack");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006202 rsl.send(ts_RSL_RF_CHAN_REL_ACK(g_chan_nr));
6203 }
6204 }
6205}
6206
6207private function f_perform_compl_l3(RSL_DCHAN_PT rsl, template PDU_ML3_MS_NW l3_info, boolean do_clear := true)
6208runs on MSC_ConnHdlr {
6209 timer T := 10.0;
6210 var octetstring l3_enc := enc_PDU_ML3_MS_NW(valueof(l3_info));
6211
Neels Hofmeyr767548a2020-08-09 20:26:07 +00006212 f_logp(BSCVTY, "establish channel, send Complete Layer 3 Info");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006213 f_create_bssmap_exp(l3_enc);
6214
6215 /* RSL_Emulation.f_chan_est() on rsl:
6216 * This is basically code dup with s/RSL/rsl from:
6217 * RSL_Emulation.f_chan_est(g_pars.ra, l3_enc, g_pars.link_id, g_pars.fn);
6218 */
6219 var RSL_Message rx_rsl;
6220 var GsmRrMessage rr;
6221
6222 /* request a channel to be established */
6223 rsl.send(ts_RSLDC_ChanRqd(g_pars.ra, g_pars.fn));
6224 /* expect immediate assignment.
6225 * Code dup with s/RSL/rsl from:
6226 * rx_rsl := f_rx_or_fail(tr_RSL_IMM_ASSIGN);
6227 */
6228 timer Tt := 10.0;
6229
6230 /* request a channel to be established */
6231 Tt.start;
6232 alt {
6233 [] rsl.receive(tr_RSL_IMM_ASSIGN) -> value rx_rsl {
6234 Tt.stop;
6235 }
6236 [] rsl.receive {
6237 setverdict(fail, "Unexpected RSL message on DCHAN");
6238 mtc.stop;
6239 }
6240 [] Tt.timeout {
6241 setverdict(fail, "Timeout waiting for RSL on DCHAN");
6242 mtc.stop;
6243 }
6244 }
6245 rr := dec_GsmRrMessage(rx_rsl.ies[1].body.full_imm_ass_info.payload);
6246 g_chan_nr := rr.payload.imm_ass.chan_desc.chan_nr;
6247 rsl.send(ts_RSL_EST_IND(g_chan_nr, valueof(g_pars.link_id), l3_enc));
6248
6249
Neels Hofmeyr767548a2020-08-09 20:26:07 +00006250 f_logp(BSCVTY, "expect BSSAP Complete Layer 3 Info at MSC");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006251 var template PDU_BSSAP exp_l3_compl;
6252 exp_l3_compl := tr_BSSMAP_ComplL3()
6253 if (g_pars.aoip == false) {
6254 exp_l3_compl.pdu.bssmap.completeLayer3Information.codecList := omit;
6255 } else {
6256 exp_l3_compl.pdu.bssmap.completeLayer3Information.codecList := ?;
6257 }
6258
6259 var PDU_BSSAP bssap;
6260 T.start;
6261 alt {
6262 [] BSSAP.receive(exp_l3_compl) -> value bssap {
Neels Hofmeyr767548a2020-08-09 20:26:07 +00006263 f_logp(BSCVTY, "received expected Complete Layer 3 Info at MSC");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006264 log("rx exp_l3_compl = ", bssap);
6265 }
6266 [] BSSAP.receive(tr_BSSMAP_ComplL3) {
6267 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Received non-matching COMPLETE LAYER 3 INFORMATION");
6268 }
6269 [] T.timeout {
6270 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for COMPLETE LAYER 3 INFORMATION");
6271 }
6272 }
6273
6274 /* start ciphering, if requested */
6275 if (ispresent(g_pars.encr)) {
Neels Hofmeyr767548a2020-08-09 20:26:07 +00006276 f_logp(BSCVTY, "start ciphering");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006277 f_cipher_mode(g_pars.encr.enc_alg, g_pars.encr.enc_key);
6278 }
6279
6280 if (do_clear) {
6281 f_perform_clear(rsl);
6282 }
6283 setverdict(pass);
6284 f_sleep(1.0);
6285}
6286
6287private function f_tc_mscpool_compl_l3(charstring id) runs on MSC_ConnHdlr {
6288 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
6289 if (g_pars.mscpool.rsl_idx == 0) {
6290 f_perform_compl_l3(RSL, g_pars.mscpool.l3_info);
6291 } else if (g_pars.mscpool.rsl_idx == 1) {
6292 f_perform_compl_l3(RSL1, g_pars.mscpool.l3_info);
6293 } else if (g_pars.mscpool.rsl_idx == 2) {
6294 f_perform_compl_l3(RSL2, g_pars.mscpool.l3_info);
6295 }
6296}
6297
6298/* Various Complete Layer 3 by IMSI all end up with the first MSC, because the other MSCs are not connected. */
6299private function f_tc_mscpool_L3Compl_on_1_msc(charstring id) runs on MSC_ConnHdlr {
6300 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
6301 f_perform_compl_l3(RSL, ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_IMSI_LV('001010000000001'H)), '00F110'O) );
6302 f_perform_compl_l3(RSL, ts_CM_SERV_REQ(CM_TYPE_MO_SMS, valueof(ts_MI_IMSI_LV('001010000000002'H))) );
6303 f_perform_compl_l3(RSL, ts_PAG_RESP(valueof(ts_MI_IMSI_LV('001010000000003'H))) );
6304 f_perform_compl_l3(RSL, ts_ML3_MO_MM_IMSI_DET_Ind(valueof(ts_MI_IMSI_LV('001010000000004'H))) );
6305}
6306testcase TC_mscpool_L3Compl_on_1_msc() runs on test_CT {
6307
6308 f_init(1, true);
6309 f_sleep(1.0);
6310 var MSC_ConnHdlr vc_conn;
6311 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006312
6313 f_ctrs_msc_init();
6314
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006315 vc_conn := f_start_handler(refers(f_tc_mscpool_L3Compl_on_1_msc), pars);
6316 vc_conn.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006317
6318 f_ctrs_msc_expect(0, "mscpool:subscr:new", 4);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006319 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006320}
6321
6322/* Three Layer 3 Complete by IMSI are round-robin'ed across two connected MSCs */
6323/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
6324 * just as well using only RSL. */
6325testcase TC_mscpool_L3Complete_by_imsi_round_robin() runs on test_CT {
6326
6327 f_init(nr_bts := 3, handler_mode := true, nr_msc := 2);
6328 f_sleep(1.0);
6329
6330 /* Control which MSC gets chosen next by the round-robin, otherwise
6331 * would be randomly affected by which other tests ran before this. */
6332 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
6333
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006334 f_ctrs_msc_init();
6335
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006336 var MSC_ConnHdlr vc_conn1;
6337 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
6338 pars1.mscpool.rsl_idx := 0;
6339 pars1.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_IMSI_LV('001010000000001'H)), '00F110'O));
6340 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6341 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006342 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006343
6344 var MSC_ConnHdlr vc_conn2;
6345 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 1);
6346 pars2.mscpool.rsl_idx := 1;
6347 pars2.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, valueof(ts_MI_IMSI_LV('001010000000002'H))));
6348 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6349 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006350 f_ctrs_msc_expect(1, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006351
6352 /* Test round-robin wrap to the first MSC */
6353 var MSC_ConnHdlr vc_conn3;
6354 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 0);
6355 pars3.mscpool.rsl_idx := 2;
6356 pars3.mscpool.l3_info := valueof(ts_PAG_RESP(valueof(ts_MI_IMSI_LV('001010000000003'H))));
6357 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
6358 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006359 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006360 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006361}
6362
6363/* Three LU by TMSI are round-robin'ed across two connected MSCs, because they contain the NULL-NRI 0
6364 * (configured in osmo-bsc.cfg). */
6365/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
6366 * just as well using only RSL. */
6367testcase TC_mscpool_LU_by_tmsi_null_nri_0_round_robin() runs on test_CT {
6368
6369 f_init(nr_bts := 3, handler_mode := true, nr_msc := 2);
6370 f_sleep(1.0);
6371
6372 /* Control which MSC gets chosen next by the round-robin, otherwise
6373 * would be randomly affected by which other tests ran before this. */
6374 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
6375
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006376 f_ctrs_msc_init();
6377
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006378 var MSC_ConnHdlr vc_conn1;
6379 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
6380 pars1.mscpool.rsl_idx := 0;
6381 pars1.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(0)), '00F110'O));
6382 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6383 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006384 f_ctrs_msc_expect(0, "mscpool:subscr:reattach");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006385
6386 var MSC_ConnHdlr vc_conn2;
6387 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 1);
6388 pars2.mscpool.rsl_idx := 1;
6389 pars2.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(0)), '00F110'O));
6390 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6391 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006392 f_ctrs_msc_expect(1, "mscpool:subscr:reattach");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006393
6394 /* Test round-robin wrap to the first MSC */
6395 var MSC_ConnHdlr vc_conn3;
6396 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 0);
6397 pars3.mscpool.rsl_idx := 2;
6398 pars3.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(0)), '00F110'O));
6399 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
6400 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006401 f_ctrs_msc_expect(0, "mscpool:subscr:reattach");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006402 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006403}
6404
6405/* Three LU by TMSI are round-robin'ed across two connected MSCs, because they contain the NULL-NRI 1
6406 * (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
6407 * NULL-NRI setting is stronger than that. */
6408/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
6409 * just as well using only RSL. */
6410testcase TC_mscpool_LU_by_tmsi_null_nri_1_round_robin() runs on test_CT {
6411
6412 f_init(nr_bts := 3, handler_mode := true, nr_msc := 2);
6413 f_sleep(1.0);
6414
6415 /* Control which MSC gets chosen next by the round-robin, otherwise
6416 * would be randomly affected by which other tests ran before this. */
6417 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
6418
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006419 f_ctrs_msc_init();
6420
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006421 var MSC_ConnHdlr vc_conn1;
6422 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
6423 pars1.mscpool.rsl_idx := 0;
6424 pars1.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(1)), '00F110'O));
6425 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6426 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006427 f_ctrs_msc_expect(0, "mscpool:subscr:reattach");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006428
6429 var MSC_ConnHdlr vc_conn2;
6430 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 1);
6431 pars2.mscpool.rsl_idx := 1;
6432 pars2.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(1)), '00F110'O));
6433 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6434 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006435 f_ctrs_msc_expect(1, "mscpool:subscr:reattach");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006436
6437 /* Test round-robin wrap to the first MSC */
6438 var MSC_ConnHdlr vc_conn3;
6439 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 0);
6440 pars3.mscpool.rsl_idx := 2;
6441 pars3.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(1)), '00F110'O));
6442 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
6443 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006444 f_ctrs_msc_expect(0, "mscpool:subscr:reattach");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006445 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006446}
6447
6448/* Three Layer 3 Complete by TMSI are round-robin'ed across two connected MSCs, because they contain an NRI not
6449 * assigned to any MSC (configured in osmo-bsc.cfg). */
6450/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
6451 * just as well using only RSL. */
6452testcase TC_mscpool_L3Complete_by_tmsi_unassigned_nri_round_robin() runs on test_CT {
6453
6454 f_init(nr_bts := 3, handler_mode := true, nr_msc := 2);
6455 f_sleep(1.0);
6456
6457 /* Control which MSC gets chosen next by the round-robin, otherwise
6458 * would be randomly affected by which other tests ran before this. */
6459 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
6460
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006461 f_ctrs_msc_init();
6462
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006463 var MSC_ConnHdlr vc_conn1;
6464 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
6465 pars1.mscpool.rsl_idx := 0;
6466 /* An NRI that is not assigned to any MSC */
6467 pars1.mscpool.l3_info := valueof(ts_ML3_MO_MM_IMSI_DET_Ind(valueof(ts_MI_TMSI_NRI_LV(1023))));
6468 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6469 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006470 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006471
6472 var MSC_ConnHdlr vc_conn2;
6473 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 1);
6474 pars2.mscpool.rsl_idx := 1;
6475 /* An NRI that is not assigned to any MSC */
6476 pars2.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(768)), '00F110'O));
6477 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6478 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006479 f_ctrs_msc_expect(1, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006480
6481 /* Test round-robin wrap to the first MSC */
6482 var MSC_ConnHdlr vc_conn3;
6483 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 0);
6484 pars3.mscpool.rsl_idx := 2;
6485 /* An NRI that is not assigned to any MSC */
6486 pars3.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_SS_ACT, valueof(ts_MI_TMSI_NRI_LV(819))));
6487 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
6488 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006489 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006490 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006491}
6492
6493/* Three Layer 3 Complete by TMSI are round-robin'ed across two connected MSCs, because they contain an NRI
6494 * assigned to an MSC that is currently not connected (configured in osmo-bsc.cfg). */
6495/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
6496 * just as well using only RSL. */
6497testcase TC_mscpool_L3Complete_by_tmsi_valid_nri_msc_not_connected_round_robin() runs on test_CT {
6498
6499 f_init(nr_bts := 3, handler_mode := true, nr_msc := 2);
6500 f_sleep(1.0);
6501
6502 /* Control which MSC gets chosen next by the round-robin, otherwise
6503 * would be randomly affected by which other tests ran before this. */
6504 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
6505
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006506 f_ctrs_msc_init();
6507
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006508 var MSC_ConnHdlr vc_conn1;
6509 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
6510 pars1.mscpool.rsl_idx := 0;
6511 /* An NRI that is assigned to an unconnected MSC */
6512 pars1.mscpool.l3_info := valueof(ts_PAG_RESP(valueof(ts_MI_TMSI_NRI_LV(512))));
6513 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6514 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006515 f_ctrs_msc_add(2, "mscpool:subscr:attach_lost");
6516 f_ctrs_msc_add(0, "mscpool:subscr:new");
6517 f_ctrs_msc_verify();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006518
6519 var MSC_ConnHdlr vc_conn2;
6520 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 1);
6521 pars2.mscpool.rsl_idx := 1;
6522 /* An NRI that is assigned to an unconnected MSC */
6523 pars2.mscpool.l3_info := valueof(ts_ML3_MO_MM_IMSI_DET_Ind(valueof(ts_MI_TMSI_NRI_LV(767))));
6524 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6525 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006526 f_ctrs_msc_add(2, "mscpool:subscr:attach_lost");
6527 f_ctrs_msc_add(1, "mscpool:subscr:new");
6528 f_ctrs_msc_verify();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006529
6530 /* Test round-robin wrap to the first MSC */
6531 var MSC_ConnHdlr vc_conn3;
6532 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 0);
6533 pars3.mscpool.rsl_idx := 2;
6534 /* An NRI that is assigned to an unconnected MSC */
6535 pars3.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(750)), '00F110'O));
6536 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
6537 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006538 f_ctrs_msc_add(2, "mscpool:subscr:attach_lost");
6539 f_ctrs_msc_add(0, "mscpool:subscr:new");
6540 f_ctrs_msc_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006541 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006542}
6543
6544/* Three Layer 3 Complete by TMSI with valid NRI for the second MSC are all directed to the second MSC (configured in
6545 * osmo-bsc.cfg). */
6546/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
6547 * just as well using only RSL. */
6548testcase TC_mscpool_L3Complete_by_tmsi_valid_nri_1() runs on test_CT {
6549
6550 f_init(nr_bts := 3, handler_mode := true, nr_msc := 2);
6551 f_sleep(1.0);
6552
6553 /* All TMSIs in this test point at the second MSC, set the round robin to point at the first MSC to make sure
6554 * this is not using round-robin. */
6555 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
6556
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006557 f_ctrs_msc_init();
6558
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006559 var MSC_ConnHdlr vc_conn1;
6560 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 1);
6561 pars1.mscpool.rsl_idx := 0;
6562 /* An NRI of the second MSC's range (256-511) */
6563 pars1.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_SMS, valueof(ts_MI_TMSI_NRI_LV(256))));
6564 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6565 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006566 f_ctrs_msc_expect(1, "mscpool:subscr:known");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006567
6568 var MSC_ConnHdlr vc_conn2;
6569 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 1);
6570 pars2.mscpool.rsl_idx := 1;
6571 /* An NRI of the second MSC's range (256-511) */
6572 pars2.mscpool.l3_info := valueof(ts_PAG_RESP(valueof(ts_MI_TMSI_NRI_LV(260))));
6573 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6574 vc_conn2.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_conn3;
6578 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 1);
6579 pars3.mscpool.rsl_idx := 2;
6580 /* An NRI of the second MSC's range (256-511) */
6581 pars3.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(511)), '00F110'O));
6582 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
6583 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006584 f_ctrs_msc_expect(1, "mscpool:subscr:known");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006585 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006586}
6587
6588/* Layer 3 Complete by TMSI with valid NRI for the third MSC are directed to the third MSC (configured in osmo-bsc.cfg),
6589 * while a round-robin remains unaffected by that. */
6590/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
6591 * just as well using only RSL. */
6592testcase TC_mscpool_L3Complete_by_tmsi_valid_nri_2() runs on test_CT {
6593
6594 f_init(nr_bts := 3, handler_mode := true, nr_msc := 3);
6595 f_sleep(1.0);
6596
6597 /* All TMSIs in this test point at the third MSC, set the round robin to point at the second MSC to make sure
6598 * this is not using round-robin. */
6599 f_vty_transceive(BSCVTY, "mscpool roundrobin next 1");
6600
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006601 f_ctrs_msc_init();
6602
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006603 var MSC_ConnHdlr vc_conn1;
6604 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 2);
6605 pars1.mscpool.rsl_idx := 0;
6606 /* An NRI of the third MSC's range (512-767) */
6607 pars1.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_SMS, valueof(ts_MI_TMSI_NRI_LV(512))));
6608 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6609 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006610 f_ctrs_msc_expect(2, "mscpool:subscr:known");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006611
6612 var MSC_ConnHdlr vc_conn2;
6613 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 2);
6614 pars2.mscpool.rsl_idx := 1;
6615 /* An NRI of the third MSC's range (512-767) */
6616 pars2.mscpool.l3_info := valueof(ts_PAG_RESP(valueof(ts_MI_TMSI_NRI_LV(678))));
6617 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6618 vc_conn2.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 /* The above forwardings to third MSC have not affected the round robin, which still points at the second MSC */
6622 var MSC_ConnHdlr vc_conn3;
6623 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 1);
6624 pars3.mscpool.rsl_idx := 2;
6625 pars3.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_IMSI_LV('001010000000013'H)), '00F110'O));
6626 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
6627 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006628 f_ctrs_msc_expect(1, "mscpool:subscr:new");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006629 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006630}
6631
6632/* LU with a TMSI but indicating a different PLMN in its previous LAI: ignore the NRI. */
6633/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
6634 * just as well using only RSL. */
6635testcase TC_mscpool_LU_by_tmsi_from_other_PLMN() runs on test_CT {
6636
6637 f_init(nr_bts := 3, handler_mode := true, nr_msc := 3);
6638 f_sleep(1.0);
6639
6640 /* The TMSIs in this test points at the second MSC, but since it is from a different PLMN, round-robin is used
6641 * instead, and hits msc 0. */
6642 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
6643
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006644 f_ctrs_msc_init();
6645
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006646 /* An NRI of the second MSC's range (256-511), but a PLMN that doesn't match with osmo-bsc.cfg */
6647 var MSC_ConnHdlr vc_conn1;
6648 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
6649 pars1.mscpool.rsl_idx := 0;
6650 pars1.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(260)), '99F999'O));
6651 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6652 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006653 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006654
6655 /* An NRI of the third MSC's range (512-767) and a matching PLMN gets directed by NRI. */
6656 var MSC_ConnHdlr vc_conn2;
6657 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 2);
6658 pars2.mscpool.rsl_idx := 1;
6659 pars2.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(555)), '00F110'O));
6660 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6661 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006662 f_ctrs_msc_expect(2, "mscpool:subscr:known");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006663 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006664}
6665
6666/* Make sure that whichever MSC paged a subscriber will also get the Paging Response. Page by IMSI, which would be
6667 * round-robined to another MSC, to make sure the Paging->Response relation is stronger than the NRI->MSC mapping. */
6668private function f_tc_mscpool_paging_imsi(charstring id) runs on MSC_ConnHdlr {
6669 var template BSSMAP_FIELD_CellIdentificationList cid_list := { cIl_CI := { ts_BSSMAP_CI_CI(0) } };
6670 //cid_list := { cIl_allInBSS := ''O };
6671 var RSL_ChanNeeded rsl_chneed := RSL_CHANNEED_SDCCH;
6672 var template BSSMAP_IE_ChannelNeeded bssmap_chneed := ts_BSSMAP_IE_ChanNeeded(int2bit(enum2int(valueof(rsl_chneed)),2));
6673 var BSSAP_N_UNITDATA_req paging;
6674 var hexstring imsi := '001010000000123'H;
6675
6676 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
6677
Neels Hofmeyr90f80962020-06-12 16:16:55 +02006678 paging := valueof(ts_BSSAP_UNITDATA_req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006679 valueof(ts_BSSMAP_Paging(imsi, cid_list, omit, bssmap_chneed))));
6680 BSSAP.send(paging);
6681
6682 /* Register any RSL conn so that the Paging Command gets received here. With the current RSL_Emulation's main()
6683 * handling of '[bts_role] IPA_PT.receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD()))' it doesn't matter at all which
6684 * channel number is picked here. */
6685 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(0, RSL_CHAN_NR_INVALID));
6686 f_rslem_register(0, new_chan_nr);
6687 RSL.receive(tr_RSL_PAGING_CMD(tr_MI_IMSI(imsi)));
6688 f_rslem_unregister(0, new_chan_nr);
6689
6690 /* Despite the round robin pointing at the second MSC ('roundrobin next 1'), the earlier Paging for the same IMSI
6691 * causes this Paging Response to go to the first MSC (bssap_idx := 0). */
6692 f_perform_compl_l3(RSL, ts_PAG_RESP(valueof(ts_MI_IMSI_LV(imsi))) );
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006693 f_sleep(1.0);
6694}
6695testcase TC_mscpool_paging_and_response_imsi() runs on test_CT {
6696 f_init(nr_bts := 1, handler_mode := true, nr_msc := 3);
6697 f_sleep(1.0);
6698
6699 /* Testing a Paging on the first MSC to get a Paging Response back to the first MSC. Set round robin to the
6700 * second MSC to make sure we're getting the Paging logic, not a coincidental round robin match. */
6701 f_vty_transceive(BSCVTY, "mscpool roundrobin next 1");
6702
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006703 f_ctrs_msc_init();
6704
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006705 var MSC_ConnHdlr vc_conn1;
6706 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
6707 pars1.mscpool.rsl_idx := 0;
Neels Hofmeyr90f80962020-06-12 16:16:55 +02006708 pars1.sccp_addr_bsc := g_bssap[pars1.mscpool.bssap_idx].sccp_addr_peer;
6709 pars1.sccp_addr_msc := g_bssap[pars1.mscpool.bssap_idx].sccp_addr_own;
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006710 vc_conn1 := f_start_handler(refers(f_tc_mscpool_paging_imsi), pars1);
6711 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006712 f_ctrs_msc_expect(0, "mscpool:subscr:paged");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006713 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006714}
6715
6716/* Make sure that whichever MSC paged a subscriber will also get the Paging Response. Page by TMSI with an NRI value
6717 * that matches a different MSC, to make sure the Paging->Response relation is stronger than the NRI->MSC mapping. */
6718private function f_tc_mscpool_paging_tmsi(charstring id) runs on MSC_ConnHdlr {
6719 var template BSSMAP_FIELD_CellIdentificationList cid_list := { cIl_CI := { ts_BSSMAP_CI_CI(0) } };
6720 //cid_list := { cIl_allInBSS := ''O };
6721 var RSL_ChanNeeded rsl_chneed := RSL_CHANNEED_SDCCH;
6722 var template BSSMAP_IE_ChannelNeeded bssmap_chneed := ts_BSSMAP_IE_ChanNeeded(int2bit(enum2int(valueof(rsl_chneed)),2));
6723 var integer nri_v := 300; /* <-- second MSC's NRI */
6724 var octetstring tmsi := f_tmsi_nri(nri_v);
6725 var BSSAP_N_UNITDATA_req paging;
6726
6727 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
6728
Neels Hofmeyr90f80962020-06-12 16:16:55 +02006729 paging := valueof(ts_BSSAP_UNITDATA_req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006730 valueof(ts_BSSMAP_Paging('001010000000011'H, cid_list, tmsi, bssmap_chneed))));
6731 BSSAP.send(paging);
6732
6733 /* Register any RSL conn so that the Paging Command gets received here. With the current RSL_Emulation's main()
6734 * handling of '[bts_role] IPA_PT.receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD()))' it doesn't matter at all which
6735 * channel number is picked here. */
6736 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(0, RSL_CHAN_NR_INVALID));
6737 f_rslem_register(0, new_chan_nr);
6738 RSL.receive(tr_RSL_PAGING_CMD(t_MI_TMSI(tmsi)));
6739 f_rslem_unregister(0, new_chan_nr);
6740
6741 /* Despite the NRI matching the second MSC (NRI from 'msc 1' in osmo-bsc.cfg) and round robin pointing at the
6742 * third MSC ('roundrobin next 2'), the earlier Paging for the same TMSI causes this Paging Response to go to
6743 * the first MSC (bssap_idx := 0). */
6744 f_perform_compl_l3(RSL, ts_PAG_RESP(valueof(ts_MI_TMSI_NRI_LV(nri_v))) );
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006745 f_sleep(1.0);
6746}
6747testcase TC_mscpool_paging_and_response_tmsi() runs on test_CT {
6748 f_init(nr_bts := 1, handler_mode := true, nr_msc := 3);
6749 f_sleep(1.0);
6750
6751 /* Testing a Paging on the first MSC to get a Paging Response back to the first MSC. Set round robin to the
6752 * third MSC to make sure we're getting the Paging logic, not a coincidental round robin match. */
6753 f_vty_transceive(BSCVTY, "mscpool roundrobin next 2");
6754
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006755 f_ctrs_msc_init();
6756
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006757 var MSC_ConnHdlr vc_conn1;
6758 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
6759 pars1.mscpool.rsl_idx := 0;
Neels Hofmeyr90f80962020-06-12 16:16:55 +02006760 pars1.sccp_addr_bsc := g_bssap[pars1.mscpool.bssap_idx].sccp_addr_peer;
6761 pars1.sccp_addr_msc := g_bssap[pars1.mscpool.bssap_idx].sccp_addr_own;
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006762 vc_conn1 := f_start_handler(refers(f_tc_mscpool_paging_tmsi), pars1);
6763 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006764 f_ctrs_msc_expect(0, "mscpool:subscr:paged");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006765 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006766}
6767
6768/* For round-robin, skip an MSC that has 'no allow-attach' set. */
6769/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
6770 * just as well using only RSL. */
6771testcase TC_mscpool_no_allow_attach_round_robin() runs on test_CT {
6772
6773 f_init(nr_bts := 3, handler_mode := true, nr_msc := 3);
6774 f_sleep(1.0);
Neels Hofmeyra460f1f2020-08-09 20:17:03 +00006775 /* Mark the second MSC as offloading, round-robin should skip this MSC now. */
6776 f_vty_msc_allow_attach(BSCVTY, {true, false, true});
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006777
6778 /* Control which MSC gets chosen next by the round-robin, otherwise
6779 * would be randomly affected by which other tests ran before this. */
6780 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
6781
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006782 f_ctrs_msc_init();
6783
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006784 var MSC_ConnHdlr vc_conn1;
6785 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
6786 pars1.mscpool.rsl_idx := 0;
6787 pars1.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_IMSI_LV('001010000000001'H)), '00F110'O));
6788 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6789 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006790 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006791
6792 var MSC_ConnHdlr vc_conn2;
6793 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 2);
6794 pars2.mscpool.rsl_idx := 1;
6795 pars2.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, valueof(ts_MI_IMSI_LV('001010000000002'H))));
6796 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6797 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006798 f_ctrs_msc_expect(2, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006799
6800 var MSC_ConnHdlr vc_conn3;
6801 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 0);
6802 pars3.mscpool.rsl_idx := 2;
6803 pars3.mscpool.l3_info := valueof(ts_PAG_RESP(valueof(ts_MI_IMSI_LV('001010000000003'H))));
6804 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
6805 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006806 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006807 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006808}
6809
6810/* An MSC that has 'no allow-attach' set should still serve subscribers that are already attached according to their
6811 * TMSI NRI. */
6812testcase TC_mscpool_no_allow_attach_valid_nri() runs on test_CT {
6813
6814 f_init(nr_bts := 3, handler_mode := true, nr_msc := 3);
6815 f_sleep(1.0);
6816
Neels Hofmeyra460f1f2020-08-09 20:17:03 +00006817 /* Mark the second MSC as offloading, round-robin should skip this MSC now. */
6818 f_vty_msc_allow_attach(BSCVTY, {true, false, true});
6819
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006820 /* Control which MSC gets chosen next by the round-robin, otherwise
6821 * would be randomly affected by which other tests ran before this. */
6822 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
6823
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006824 f_ctrs_msc_init();
6825
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006826 /* Round robin points at msc 0, but the valid NRI directs to msc 1, even though msc 1 has 'no allow-attach'. */
6827 var MSC_ConnHdlr vc_conn1;
6828 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 1);
6829 pars1.mscpool.rsl_idx := 0;
6830 /* An NRI of the second MSC's range (256-511) */
6831 pars1.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, valueof(ts_MI_TMSI_NRI_LV(260))));
6832 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6833 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006834 f_ctrs_msc_expect(1, "mscpool:subscr:known");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006835
6836 var MSC_ConnHdlr vc_conn2;
6837 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 0);
6838 pars2.mscpool.rsl_idx := 1;
6839 pars2.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, valueof(ts_MI_IMSI_LV('001010000000002'H))));
6840 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6841 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006842 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006843
6844 var MSC_ConnHdlr vc_conn3;
6845 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 2);
6846 pars3.mscpool.rsl_idx := 2;
6847 pars3.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, valueof(ts_MI_IMSI_LV('001010000000003'H))));
6848 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
6849 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006850 f_ctrs_msc_expect(2, "mscpool:subscr:new");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006851 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006852}
6853
Philipp Maier783681c2020-07-16 16:47:06 +02006854/* Allow/Deny emergency calls globally via VTY */
6855private function f_vty_allow_emerg_msc(boolean allow) runs on test_CT {
6856 f_vty_enter_cfg_msc(BSCVTY, 0);
6857 if (allow) {
6858 f_vty_transceive(BSCVTY, "allow-emergency allow");
6859 } else {
6860 f_vty_transceive(BSCVTY, "allow-emergency deny");
6861 }
6862 f_vty_transceive(BSCVTY, "exit");
6863 f_vty_transceive(BSCVTY, "exit");
6864}
6865
6866/* Allow/Deny emergency calls per BTS via VTY */
6867private function f_vty_allow_emerg_bts(boolean allow, integer bts_nr) runs on test_CT {
6868 f_vty_enter_cfg_bts(BSCVTY, bts_nr);
6869 if (allow) {
6870 f_vty_transceive(BSCVTY, "rach emergency call allowed 1");
6871 } else {
6872 f_vty_transceive(BSCVTY, "rach emergency call allowed 0");
6873 }
6874 f_vty_transceive(BSCVTY, "exit");
6875 f_vty_transceive(BSCVTY, "exit");
Neels Hofmeyrb6ed80c2020-10-12 22:52:39 +00006876 f_vty_transceive(BSCVTY, "exit");
Philipp Maier783681c2020-07-16 16:47:06 +02006877}
6878
6879/* Begin assignmet procedure and send an EMERGENCY SETUP (RR) */
6880private function f_assignment_emerg_setup() runs on MSC_ConnHdlr {
6881 var PDU_ML3_MS_NW emerg_setup;
6882 var octetstring emerg_setup_enc;
6883 var RSL_Message emerg_setup_data_ind;
6884
6885 f_establish_fully(omit, omit);
6886
6887 emerg_setup := valueof(ts_ML3_MO_CC_EMERG_SETUP(1, valueof(ts_Bcap_voice)));
6888 emerg_setup_enc := enc_PDU_ML3_MS_NW(emerg_setup);
6889 emerg_setup_data_ind := valueof(ts_RSL_DATA_IND(g_chan_nr, valueof(ts_RslLinkID_DCCH(0)), emerg_setup_enc));
6890
6891 RSL.send(emerg_setup_data_ind);
6892}
6893
6894/* Test if the EMERGENCY SETUP gets passed on to the MSC via A when EMERGENCY
6895 * CALLS are permitted by the BSC config. */
6896private function f_TC_assignment_emerg_setup_allow(charstring id) runs on MSC_ConnHdlr {
6897 var PDU_BSSAP emerg_setup_data_ind_bssap;
6898 var PDU_ML3_MS_NW emerg_setup;
6899 timer T := 3.0;
6900
6901 f_assignment_emerg_setup()
6902
6903 T.start;
6904 alt {
6905 [] BSSAP.receive(tr_BSSAP_DTAP) -> value emerg_setup_data_ind_bssap {
6906 emerg_setup := dec_PDU_ML3_MS_NW(emerg_setup_data_ind_bssap.pdu.dtap);
6907 if (not isbound(emerg_setup.msgs.cc.emergencySetup)) {
6908 setverdict(fail, "no emergency setup");
6909 }
6910 }
6911 [] BSSAP.receive {
6912 setverdict(fail, "unexpected BSSAP message!");
6913 }
6914 [] T.timeout {
6915 setverdict(fail, "timout waiting for EMERGENCY SETUP!");
6916 }
6917 }
6918
6919 setverdict(pass);
6920}
6921
6922/* Test if the EMERGENCY SETUP gets blocked by the BSC if EMERGENCY CALLS are
6923 * forbidden by the BSC config. */
6924private function f_TC_assignment_emerg_setup_deny(charstring id) runs on MSC_ConnHdlr {
6925 var PDU_BSSAP emerg_setup_data_ind_bssap;
6926 timer T := 3.0;
6927
6928 f_assignment_emerg_setup()
6929
6930 T.start;
6931 alt {
6932 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_RELEASE)) {
6933 setverdict(pass);
6934 }
6935 [] RSL.receive {
6936 setverdict(fail, "unexpected RSL message!");
6937 }
6938 [] T.timeout {
6939 setverdict(fail, "timout waiting for RR CHANNEL RELEASE!");
6940 }
6941 }
6942}
6943
6944/* EMERGENCY CALL situation #1, allowed globally and by BTS */
6945testcase TC_assignment_emerg_setup_allow() runs on test_CT {
6946 var TestHdlrParams pars := f_gen_test_hdlr_pars();
6947 var MSC_ConnHdlr vc_conn;
6948
6949 f_init(1, true);
6950 f_sleep(1.0);
6951
6952 f_vty_allow_emerg_msc(true);
6953 f_vty_allow_emerg_bts(true, 0);
6954 vc_conn := f_start_handler(refers(f_TC_assignment_emerg_setup_allow), pars);
6955 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006956 f_shutdown_helper();
Philipp Maier783681c2020-07-16 16:47:06 +02006957}
6958
6959/* EMERGENCY CALL situation #2, forbidden globally but allowed by BTS */
6960testcase TC_assignment_emerg_setup_deny_msc() runs on test_CT {
6961 var TestHdlrParams pars := f_gen_test_hdlr_pars();
6962 var MSC_ConnHdlr vc_conn;
6963
6964 f_init(1, true);
6965 f_sleep(1.0);
6966
6967 f_vty_allow_emerg_msc(false);
6968 f_vty_allow_emerg_bts(true, 0);
6969 vc_conn := f_start_handler(refers(f_TC_assignment_emerg_setup_deny), pars);
6970 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006971 f_shutdown_helper();
Philipp Maier783681c2020-07-16 16:47:06 +02006972}
6973
6974/* EMERGENCY CALL situation #3, allowed globally but forbidden by BTS */
6975testcase TC_assignment_emerg_setup_deny_bts() runs on test_CT {
6976 var TestHdlrParams pars := f_gen_test_hdlr_pars();
6977 var MSC_ConnHdlr vc_conn;
6978
6979 /* Note: This simulates a spec violation by the MS, correct MS
6980 * implementations would not try to establish an emergency call because
6981 * the system information tells in advance that emergency calls are
6982 * not forbidden */
6983
6984 f_init(1, true);
6985 f_sleep(1.0);
6986
6987 f_vty_allow_emerg_msc(true);
6988 f_vty_allow_emerg_bts(false, 0);
6989 vc_conn := f_start_handler(refers(f_TC_assignment_emerg_setup_deny), pars);
6990 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006991 f_shutdown_helper();
Philipp Maier783681c2020-07-16 16:47:06 +02006992}
6993
Philipp Maier82812002020-08-13 18:48:27 +02006994/* Test what happens when an emergency call arrives while all TCH channels are
6995 * busy, the BSC is expected to terminate one call in favor of the incoming
6996 * emergency call */
6997testcase TC_emerg_premption() runs on test_CT {
6998 var ASP_RSL_Unitdata rsl_ud;
6999 var integer i;
7000 var integer chreq_total, chreq_nochan;
7001 var RSL_Message rx_rsl;
7002 var RslChannelNr chan_nr;
7003
7004 f_init(1);
7005 f_sleep(1.0);
7006
7007 f_vty_allow_emerg_msc(true);
7008 f_vty_allow_emerg_bts(true, 0);
7009
7010 /* Fill up all channels on the BTS */
7011 chreq_total := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total");
7012 chreq_nochan := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:no_channel");
7013 for (i := 0; i < NUM_TCHF_PER_BTS + NUM_TCHH_PER_BTS + NUM_SDCCH_PER_BTS; i := i+1) {
7014 chan_nr := f_chreq_act_ack('33'O, i);
7015 }
7016 IPA_RSL[0].clear;
7017 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total",
7018 chreq_total + NUM_TCHF_PER_BTS + NUM_TCHH_PER_BTS + NUM_SDCCH_PER_BTS);
7019
7020 /* Send Channel request for emegergency call */
7021 f_ipa_tx(0, ts_RSL_CHAN_RQD('A5'O, 23));
7022
7023 /* Expect the BSC to release one (the first) TCH/F on the BTS */
7024 chan_nr := valueof(t_RslChanNr_Bm(1));
7025 f_expect_chan_rel(0, chan_nr, expect_rr_chan_rel := false, expect_rll_rel_req := false);
7026
7027 /* Expect the BSC to send activate/assign the a channel for the emergency call */
7028 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
7029 chan_nr := rx_rsl.ies[0].body.chan_nr;
7030 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, 33));
7031 rx_rsl := f_exp_ipa_rx(0, tr_RSL_IMM_ASSIGN(0));
Philipp Maier104f4c02020-09-11 18:12:18 +02007032
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007033 f_shutdown_helper();
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007034}
7035
7036/* Hopping parameters per a timeslot */
Vadim Yanitskiybc6654a2020-09-13 01:27:40 +07007037private type record length(0..64) of GsmArfcn ArfcnList;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007038private type record FHParamsTs {
7039 boolean enabled,
7040 uint6_t hsn,
7041 uint6_t maio,
7042 ArfcnList ma
7043};
7044
7045/* Hopping parameters per a transceiver */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007046private type record FHParamsTrx {
7047 GsmArfcn arfcn,
7048 FHParamsTs ts[8]
7049};
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007050
7051/* Randomly generate the hopping parameters for the given timeslot numbers */
7052private function f_TC_fh_params_gen(template integer tr_tn := (1, 3, 5))
7053runs on test_CT return FHParamsTrx {
7054 var FHParamsTrx fhp;
7055
Vadim Yanitskiy3e997362020-09-05 21:08:34 +07007056 /* Generate a random ARFCN, including ARFCN 0 */
7057 fhp.arfcn := f_rnd_int(3);
Vadim Yanitskiye7c8c6e2020-09-13 14:33:03 +07007058
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007059 for (var integer tn := 0; tn < 8; tn := tn + 1) {
7060 if (not match(tn, tr_tn)) {
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007061 fhp.ts[tn].enabled := false;
7062 fhp.ts[tn].ma := { };
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007063 continue;
7064 }
7065
7066 /* Random HSN / MAIO values: 0..63 */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007067 fhp.ts[tn].hsn := f_rnd_int(64);
7068 fhp.ts[tn].maio := f_rnd_int(64);
7069 fhp.ts[tn].ma := { };
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007070
7071 /* Random Mobile Allocation (hopping channels) */
7072 var integer ma_len := 2 + f_rnd_int(9); /* 2..10 channels */
7073 var integer step := 3 + f_rnd_int(4); /* 3..6 stepping */
7074 for (var integer i := 1; i <= ma_len; i := i + 1) {
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007075 fhp.ts[tn].ma := fhp.ts[tn].ma & { i * step };
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007076 }
7077
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007078 fhp.ts[tn].enabled := true;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007079 }
7080
7081 log("f_TC_fh_params_gen(): ", fhp);
7082 return fhp;
7083}
7084
7085/* Make sure that the given Channel Description IE matches the hopping configuration */
7086private function f_TC_fh_params_match_chan_desc(in FHParamsTrx fhp, in ChannelDescription cd)
7087{
7088 var template (present) ChannelDescription tr_cd;
7089 var template (present) MaioHsn tr_maio_hsn;
7090 var uint3_t tn := cd.chan_nr.tn;
7091
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007092 if (fhp.ts[tn].enabled) {
7093 tr_maio_hsn := tr_HsnMaio(fhp.ts[tn].hsn, fhp.ts[tn].maio);
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007094 tr_cd := tr_ChanDescH1(cd.chan_nr, tr_maio_hsn);
7095 } else {
Vadim Yanitskiye7c8c6e2020-09-13 14:33:03 +07007096 tr_cd := tr_ChanDescH0(cd.chan_nr, fhp.arfcn);
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007097 }
7098
7099 if (not match(cd, tr_cd)) {
7100 setverdict(fail, "Channel Description IE does not match: ",
7101 cd, " vs expected ", tr_cd);
7102 }
7103}
7104
7105/* Make sure that the given Mobile Allocation IE matches the hopping configuration */
7106private function f_TC_fh_params_match_ma(in FHParamsTrx fhp, uint3_t tn,
7107 in MobileAllocationLV ma)
7108{
7109 var template MobileAllocationLV tr_ma := f_TC_fh_params_gen_tr_ma(fhp, tn, ma);
7110
7111 if (not match(ma, tr_ma)) {
7112 setverdict(fail, "Mobile Allocation IE does not match (tn := ",
7113 tn, "): ", ma, " vs expected: ", tr_ma);
7114 } else {
7115 setverdict(pass);
7116 }
7117}
7118
7119private function f_TC_fh_params_gen_tr_ma(in FHParamsTrx fhp, uint3_t tn,
7120 in MobileAllocationLV ma)
7121return template MobileAllocationLV {
7122 /* Mobile Allocation IE is expected to be empty if hopping is not enabled */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007123 if (not fhp.ts[tn].enabled) {
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007124 return { len := 0, ma := ''B };
7125 }
7126
7127 var bitstring full_mask := f_pad_bit(''B, 1024, '0'B);
7128 var bitstring slot_mask := f_pad_bit(''B, 1024, '0'B);
7129 var bitstring ma_mask := ''B;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007130
7131 /* Compose the full bit-mask (all channels, up to 1024 entries) */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007132 for (var integer i := 0; i < lengthof(fhp.ts); i := i + 1) {
7133 for (var integer j := 0; j < lengthof(fhp.ts[i].ma); j := j + 1) {
7134 if (full_mask[fhp.ts[i].ma[j]] == '1'B)
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007135 { continue; }
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007136 full_mask[fhp.ts[i].ma[j]] := '1'B;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007137 }
7138 }
7139
Vadim Yanitskiye7c8c6e2020-09-13 14:33:03 +07007140 /* Take ARFCN of the TRX itself into account */
7141 full_mask[fhp.arfcn] := '1'B;
7142
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007143 /* Compose a bit-mask for the given timeslot number */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007144 for (var integer i := 0; i < lengthof(fhp.ts[tn].ma); i := i + 1) {
7145 slot_mask[fhp.ts[tn].ma[i]] := '1'B;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007146 }
7147
7148 /* Finally, compose the Mobile Allocation bit-mask */
Vadim Yanitskiy3e997362020-09-05 21:08:34 +07007149 for (var integer i := 1; i < lengthof(full_mask); i := i + 1) {
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007150 if (full_mask[i] != '1'B)
7151 { continue; }
7152
7153 /* FIXME: ma_mask := ma_mask & slot_mask[i]; // triggers a bug in TITAN */
7154 if (slot_mask[i] == '1'B) {
7155 ma_mask := ma_mask & '1'B;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007156 } else {
7157 ma_mask := ma_mask & '0'B;
7158 }
7159 }
7160
Vadim Yanitskiy3e997362020-09-05 21:08:34 +07007161 /* ARFCN 0 (if present) goes to the last position of the bit-mask */
7162 if (full_mask[0] == '1'B) {
7163 /* FIXME: ma_mask := ma_mask & slot_mask[0]; // triggers a bug in TITAN */
7164 if (slot_mask[0] == '1'B) {
7165 ma_mask := ma_mask & '1'B;
7166 } else {
7167 ma_mask := ma_mask & '0'B;
7168 }
7169 }
7170
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007171 /* Ensure that ma_mask is octet-aligned */
Vadim Yanitskiy2aa02522020-09-06 14:05:23 +07007172 var integer ma_mask_len := (lengthof(ma_mask) + 8 - 1) / 8;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007173 ma_mask := f_pad_bit(ma_mask, ma_mask_len * 8, '0'B);
7174
7175 return { len := ma_mask_len, ma := ma_mask };
7176}
7177
7178/* Configure the hopping parameters in accordance with the given record */
7179private function f_TC_fh_params_set(in FHParamsTrx fhp,
7180 uint8_t bts_nr := 0,
7181 uint8_t trx_nr := 0)
7182runs on test_CT {
7183 /* Enter the configuration node for the given BTS/TRX numbers */
7184 f_vty_enter_cfg_trx(BSCVTY, bts_nr, trx_nr);
7185
Vadim Yanitskiye7c8c6e2020-09-13 14:33:03 +07007186 f_vty_transceive(BSCVTY, "arfcn " & int2str(fhp.arfcn));
7187
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007188 for (var integer tn := 0; tn < lengthof(fhp.ts); tn := tn + 1) {
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007189 f_vty_transceive(BSCVTY, "timeslot " & int2str(tn));
7190
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007191 if (not fhp.ts[tn].enabled) {
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007192 f_vty_transceive(BSCVTY, "hopping enabled 0");
7193 f_vty_transceive(BSCVTY, "exit"); /* go back */
7194 continue;
7195 }
7196
7197 /* Configure HSN / MAIO values */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007198 f_vty_transceive(BSCVTY, "hopping sequence-number " & int2str(fhp.ts[tn].hsn));
7199 f_vty_transceive(BSCVTY, "hopping maio " & int2str(fhp.ts[tn].maio));
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007200
7201 /* Configure the Mobile Allocation (hopping channels) */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007202 for (var integer i := 0; i < lengthof(fhp.ts[tn].ma); i := i + 1) {
7203 f_vty_transceive(BSCVTY, "hopping arfcn add " & int2str(fhp.ts[tn].ma[i]));
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007204 }
7205
7206 f_vty_transceive(BSCVTY, "hopping enabled 1");
7207 f_vty_transceive(BSCVTY, "exit"); /* go back */
7208 }
7209
7210 f_vty_transceive(BSCVTY, "end");
7211}
7212
7213/* Disable frequency hopping on all timeslots */
7214private function f_TC_fh_params_unset(in FHParamsTrx fhp,
7215 uint8_t bts_nr := 0,
Vadim Yanitskiye7c8c6e2020-09-13 14:33:03 +07007216 uint8_t trx_nr := 0,
7217 GsmArfcn arfcn := 871)
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007218runs on test_CT {
7219 /* Enter the configuration node for the given BTS/TRX numbers */
7220 f_vty_enter_cfg_trx(BSCVTY, bts_nr, trx_nr);
7221
Vadim Yanitskiye7c8c6e2020-09-13 14:33:03 +07007222 f_vty_transceive(BSCVTY, "arfcn " & int2str(arfcn));
7223
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007224 for (var integer tn := 0; tn < lengthof(fhp.ts); tn := tn + 1) {
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007225 f_vty_transceive(BSCVTY, "timeslot " & int2str(tn));
7226
7227 /* Delete all ARFCNs from the Mobile Allocation (if any) */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007228 for (var integer i := 0; i < lengthof(fhp.ts[tn].ma); i := i + 1) {
7229 f_vty_transceive(BSCVTY, "hopping arfcn del " & int2str(fhp.ts[tn].ma[i]));
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007230 }
7231
7232 f_vty_transceive(BSCVTY, "hopping enabled 0");
7233 f_vty_transceive(BSCVTY, "exit"); /* go back */
7234 }
7235
7236 f_vty_transceive(BSCVTY, "end");
7237 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
7238}
7239
7240/* Verify presence and correctness of the hopping parameters (HSN, MAIO)
7241 * in the Channel Identification IE of the RSL CHANnel ACTIVation message. */
7242testcase TC_fh_params_chan_activ() runs on test_CT {
7243 var FHParamsTrx fhp := f_TC_fh_params_gen();
7244 var RSL_Message rsl_msg;
7245 var RSL_IE_Body ie;
7246
7247 f_init_vty();
7248
7249 f_TC_fh_params_set(fhp); /* Enable frequency hopping */
7250 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
7251
7252 f_init(1);
7253
7254 /* CS domain: 3 (SDCCH/4+CBCH) + 4 (TCH/F) + 2 (TCH/H) channels available */
7255 for (var integer i := 0; i < 9; i := i + 1) {
7256 f_ipa_tx(0, ts_RSL_CHAN_RQD(f_rnd_ra_cs(), 23));
7257 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
7258
7259 /* Make sure that Channel Identification IE is present */
7260 if (not f_rsl_find_ie(rsl_msg, RSL_IE_CHAN_IDENT, ie)) {
7261 setverdict(fail, "RSL Channel Identification IE is absent");
7262 continue;
7263 }
7264
7265 /* Make sure that hopping parameters (HSN/MAIO) match */
7266 f_TC_fh_params_match_chan_desc(fhp, ie.chan_ident.ch_desc.v);
7267
7268 /* "Mobile Allocation shall be included but empty" - let's check this */
7269 if (ie.chan_ident.ma.v.len != 0) {
7270 setverdict(fail, "Mobile Allocation IE is not empty: ",
7271 ie.chan_ident.ma, ", despite it shall be");
7272 continue;
7273 }
7274 }
7275
7276 /* Disable frequency hopping */
7277 f_TC_fh_params_unset(fhp);
7278
Vadim Yanitskiy21726312020-09-04 01:45:36 +07007279 f_shutdown_helper();
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007280}
7281
7282/* Verify the hopping parameters (HSN, MAIO, MA) in (RR) Immediate Assignment */
7283testcase TC_fh_params_imm_ass() runs on test_CT {
7284 var FHParamsTrx fhp := f_TC_fh_params_gen();
7285 var RSL_Message rsl_msg;
7286 var RSL_IE_Body ie;
7287
7288 f_init_vty();
7289
7290 f_TC_fh_params_set(fhp); /* Enable frequency hopping */
7291 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
7292
7293 f_init(1);
7294
7295 /* CS domain: 3 (SDCCH/4+CBCH) + 4 (TCH/F) + 2 (TCH/H) channels available */
7296 for (var integer i := 0; i < 9; i := i + 1) {
7297 f_ipa_tx(0, ts_RSL_CHAN_RQD(f_rnd_ra_cs(), 23));
7298 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
7299
7300 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(rsl_msg.ies[0].body.chan_nr, 33));
7301 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeC(RSL_MT_IMMEDIATE_ASSIGN_CMD));
7302
7303 /* Make sure that Full Immediate Assign Info IE is present */
7304 if (not f_rsl_find_ie(rsl_msg, RSL_IE_FULL_IMM_ASS_INFO, ie)) {
7305 setverdict(fail, "RSL Full Immediate Assign Info IE is absent");
7306 continue;
7307 }
7308
7309 /* Decode the actual Immediate Assignment message */
7310 var GsmRrMessage rr_msg := dec_GsmRrMessage(ie.full_imm_ass_info.payload);
7311 if (not match(rr_msg.header, t_RrHeader(IMMEDIATE_ASSIGNMENT, ?))) {
7312 setverdict(fail, "Failed to match Immediate Assignment: ", rr_msg);
7313 continue;
7314 }
7315
7316 /* Make sure that hopping parameters (HSN/MAIO) match */
7317 f_TC_fh_params_match_chan_desc(fhp, rr_msg.payload.imm_ass.chan_desc);
7318
7319 /* Make sure that the Mobile Allocation IE matches */
7320 f_TC_fh_params_match_ma(fhp, rr_msg.payload.imm_ass.chan_desc.chan_nr.tn,
7321 rr_msg.payload.imm_ass.mobile_allocation);
7322 }
7323
7324 /* Disable frequency hopping */
7325 f_TC_fh_params_unset(fhp);
Philipp Maier82812002020-08-13 18:48:27 +02007326
Vadim Yanitskiy21726312020-09-04 01:45:36 +07007327 f_shutdown_helper();
Philipp Maier82812002020-08-13 18:48:27 +02007328}
7329
Vadim Yanitskiyaeb54a22020-09-01 06:25:25 +07007330/* Verify the hopping parameters (HSN, MAIO, MA) in (RR) Assignment Command */
7331testcase TC_fh_params_assignment_cmd() runs on test_CT {
7332 var FHParamsTrx fhp := f_TC_fh_params_gen();
7333 var RSL_Message rsl_msg;
7334 var RSL_IE_Body ie;
7335
7336 f_init_vty();
7337
7338 f_TC_fh_params_set(fhp); /* Enable frequency hopping */
7339 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
7340
7341 f_init(1);
7342
7343 /* HACK: work around "Couldn't find Expect for CRCX" */
7344 vc_MGCP.stop;
7345
7346 var template PDU_BSSAP ass_cmd := f_gen_ass_req();
7347 ass_cmd.pdu.bssmap.assignmentRequest.codecList := ts_BSSMAP_IE_CodecList({ts_CodecFR});
7348
7349 /* CS domain (TCH): 4 (TCH/F) + 2 (TCH/H) channels available
7350 * NOTE: only 3 SDCCH/4 channels are available on CCCH+SDCCH4+CBCH */
7351 for (var integer i := 0; i < 3; i := i + 1) {
7352 /* Establish a dedicated channel, so we can trigger (late) TCH assignment */
7353 var DchanTuple dt := f_est_dchan(f_rnd_ra_cs(), 23, f_rnd_octstring(16));
7354
7355 /* Send a BSSMAP Assignment Command, expect CHANnel ACTIVation */
7356 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ass_cmd));
7357 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
7358
7359 /* ACKnowledge CHANnel ACTIVation, expect RSL DATA REQuest */
7360 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(rsl_msg.ies[0].body.chan_nr, 33));
7361 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeR(RSL_MT_DATA_REQ));
7362
7363 /* Make sure that L3 Information IE is present */
7364 if (not f_rsl_find_ie(rsl_msg, RSL_IE_L3_INFO, ie)) {
7365 setverdict(fail, "RSL L3 Information IE is absent");
7366 continue;
7367 }
7368
7369 /* Decode the L3 message and make sure it is (RR) Assignment Command */
7370 var GsmRrL3Message l3_msg := dec_GsmRrL3Message(ie.l3_info.payload);
7371 if (not match(l3_msg.header, t_RrL3Header(ASSIGNMENT_COMMAND))) {
7372 setverdict(fail, "Failed to match Assignment Command: ", l3_msg);
7373 continue;
7374 }
7375
7376 /* Make sure that hopping parameters (HSN/MAIO) match */
7377 var ChannelDescription chan_desc := l3_msg.payload.ass_cmd.chan_desc;
7378 f_TC_fh_params_match_chan_desc(fhp, chan_desc);
7379
7380 /* Make sure that Cell Channel Description IE is present if FH is enabled */
7381 if (chan_desc.h and not ispresent(l3_msg.payload.ass_cmd.cell_chan_desc)) {
Vadim Yanitskiy38d069d2020-09-02 17:18:57 +07007382 setverdict(fail, "FH enabled, but Cell Channel Description IE is absent");
Vadim Yanitskiyaeb54a22020-09-01 06:25:25 +07007383 continue;
7384 }
7385
7386 /* Make sure that the Mobile Allocation IE matches (if present) */
7387 var boolean ma_present := ispresent(l3_msg.payload.ass_cmd.mobile_allocation);
7388 if (chan_desc.h and ma_present) {
7389 f_TC_fh_params_match_ma(fhp, chan_desc.chan_nr.tn,
7390 l3_msg.payload.ass_cmd.mobile_allocation.v);
7391 } else if (chan_desc.h and not ma_present) {
7392 setverdict(fail, "FH enabled, but Mobile Allocation IE is absent");
7393 continue;
7394 } else if (not chan_desc.h and ma_present) {
7395 setverdict(fail, "FH disabled, but Mobile Allocation IE is present");
7396 continue;
7397 }
7398 }
7399
7400 /* Give the IUT some time to release all channels */
7401 f_sleep(3.0);
7402
7403 /* Disable frequency hopping */
7404 f_TC_fh_params_unset(fhp);
7405
Vadim Yanitskiy21726312020-09-04 01:45:36 +07007406 f_shutdown_helper();
Vadim Yanitskiyaeb54a22020-09-01 06:25:25 +07007407}
7408
Vadim Yanitskiy8f5430d2020-09-02 18:51:38 +07007409/* Verify the hopping parameters (HSN, MAIO, MA) in (RR) Handover Command */
7410private function f_TC_fh_params_handover_cmd(in FHParamsTrx fhp)
7411runs on test_CT {
7412 var RSL_Message rsl_msg;
7413 var RSL_IE_Body ie;
7414 var DchanTuple dt;
7415
7416 /* Establish a dedicated channel, so we can trigger handover */
7417 dt := f_est_dchan(f_rnd_ra_cs(), 23, f_rnd_octstring(16));
7418
7419 /* Trigger handover from BTS0 to BTS1 */
7420 f_bts_0_cfg(BSCVTY, { "neighbor bts 1" });
7421 f_vty_handover(BSCVTY, 0, 0, dt.rsl_chan_nr, 1);
7422
7423 /* Expect RSL CHANnel ACTIVation on BTS1/TRX0/TS1 */
7424 rsl_msg := f_exp_ipa_rx(1, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
7425
7426 /* ACKnowledge channel activation and expect (RR) Handover Command */
7427 f_ipa_tx(1, ts_RSL_CHAN_ACT_ACK(rsl_msg.ies[0].body.chan_nr, 33));
7428 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeR(RSL_MT_DATA_REQ));
7429
7430 /* Make sure that L3 Information IE is present */
7431 if (not f_rsl_find_ie(rsl_msg, RSL_IE_L3_INFO, ie)) {
7432 setverdict(fail, "RSL L3 Information IE is absent");
7433 return;
7434 }
7435
7436 /* Decode the L3 message and make sure it is (RR) Handover Command */
7437 var GsmRrL3Message l3_msg := dec_GsmRrL3Message(ie.l3_info.payload);
7438 if (not match(l3_msg.header, t_RrL3Header(HANDOVER_COMMAND))) {
7439 setverdict(fail, "Failed to match Handover Command: ", l3_msg);
7440 return;
7441 }
7442
7443 /* Make sure that we've got SDCCH/8 on TS1 (expected to be hopping) */
7444 var ChannelDescription chan_desc := l3_msg.payload.ho_cmd.chan_desc;
7445 if (not match(chan_desc.chan_nr, t_RslChanNr_SDCCH8(1, ?))) {
7446 setverdict(fail, "Unexpected channel number: ", chan_desc.chan_nr);
7447 return;
7448 }
7449
7450 /* Make sure that hopping parameters (HSN/MAIO) match */
7451 f_TC_fh_params_match_chan_desc(fhp, chan_desc);
7452
7453 /* Make sure that Cell Channel Description IE is present */
7454 if (not ispresent(l3_msg.payload.ho_cmd.cell_chan_desc)) {
7455 setverdict(fail, "FH enabled, but Cell Channel Description IE is absent");
7456 return;
7457 }
7458
7459 /* Make sure that the Mobile Allocation (after time) IE is present and matches */
7460 var boolean ma_present := ispresent(l3_msg.payload.ho_cmd.mobile_allocation);
7461 if (ma_present) {
7462 f_TC_fh_params_match_ma(fhp, chan_desc.chan_nr.tn,
7463 l3_msg.payload.ho_cmd.mobile_allocation.v);
7464 } else {
7465 setverdict(fail, "FH enabled, but Mobile Allocation IE is absent");
7466 return;
7467 }
7468}
7469testcase TC_fh_params_handover_cmd() runs on test_CT {
7470 var FHParamsTrx fhp := f_TC_fh_params_gen();
7471
7472 f_init_vty();
7473
7474 /* (Re)configure TS0 as BCCH and TS1 as SDCCH8 on BTS1/TRX0 */
7475 f_vty_enter_cfg_trx(BSCVTY, bts := 1, trx := 0);
7476
7477 f_vty_transceive(BSCVTY, "timeslot 0");
7478 f_vty_transceive(BSCVTY, "phys_chan_config ccch");
7479 f_vty_transceive(BSCVTY, "exit"); /* go back */
7480
7481 f_vty_transceive(BSCVTY, "timeslot 1");
7482 f_vty_transceive(BSCVTY, "phys_chan_config sdcch8");
7483 f_vty_transceive(BSCVTY, "end"); /* we're done */
7484
7485 f_TC_fh_params_set(fhp, 1); /* Enable frequency hopping on BTS1 */
7486 f_vty_transceive(BSCVTY, "drop bts connection 1 oml");
7487
7488 f_init(2);
7489
7490 f_TC_fh_params_handover_cmd(fhp);
7491
7492 /* Disable frequency hopping on BTS1 */
7493 f_TC_fh_params_unset(fhp, 1);
7494
7495 /* (Re)configure TS0 as CCCH+SDCCH4+CBCH and TS1 as TCH/F */
7496 f_vty_enter_cfg_trx(BSCVTY, bts := 1, trx := 0);
7497
7498 f_vty_transceive(BSCVTY, "timeslot 0");
7499 f_vty_transceive(BSCVTY, "phys_chan_config ccch+sdcch4+cbch");
7500 f_vty_transceive(BSCVTY, "exit"); /* go back */
7501
7502 f_vty_transceive(BSCVTY, "timeslot 1");
7503 f_vty_transceive(BSCVTY, "phys_chan_config tch/f");
7504 f_vty_transceive(BSCVTY, "end"); /* we're done */
7505
7506 f_shutdown_helper();
7507}
7508
Vadim Yanitskiyca974032020-09-01 07:20:39 +07007509/* Verify the hopping parameters in System Information Type 4 */
7510testcase TC_fh_params_si4_cbch() runs on test_CT {
7511 var FHParamsTrx fhp := f_TC_fh_params_gen(tr_tn := 1);
7512 var ASP_RSL_Unitdata rx_rsl_ud;
7513 timer T := 5.0;
7514
7515 f_init_vty();
7516
7517 /* (Re)configure TS0 as BCCH and TS1 as SDCCH8+CBCH */
7518 f_vty_enter_cfg_trx(BSCVTY, trx := 0);
7519
7520 f_vty_transceive(BSCVTY, "timeslot 0");
7521 f_vty_transceive(BSCVTY, "phys_chan_config ccch");
7522 f_vty_transceive(BSCVTY, "exit"); /* go back */
7523
7524 f_vty_transceive(BSCVTY, "timeslot 1");
7525 f_vty_transceive(BSCVTY, "phys_chan_config sdcch8+cbch");
7526 f_vty_transceive(BSCVTY, "end"); /* we're done */
7527
7528 f_TC_fh_params_set(fhp); /* Enable frequency hopping */
7529 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
7530
7531 f_init(1);
7532
7533 T.start;
7534 alt {
7535 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_BCCH_INFO(RSL_SYSTEM_INFO_4))) -> value rx_rsl_ud {
7536 var RSL_IE_Body ie := rx_rsl_ud.rsl.ies[2].body; /* FULL BCCH Information IE */
7537 var SystemInformation si := dec_SystemInformation(ie.other.payload);
7538
7539 /* Make sure that what we decoded is System Information Type 4 */
7540 if (si.header.message_type != SYSTEM_INFORMATION_TYPE_4) {
7541 setverdict(fail, "RSL FULL BCCH Information IE contains: ", si);
7542 repeat;
7543 }
7544
7545 /* Make sure that CBCH Channel Description IE is present */
7546 if (not ispresent(si.payload.si4.cbch_chan_desc)) {
7547 setverdict(fail, "CBCH Channel Description IE is absent");
7548 break;
7549 }
7550
7551 /* Finally, check the hopping parameters (HSN, MAIO) */
7552 var ChannelDescription chan_desc := si.payload.si4.cbch_chan_desc.v;
7553 f_TC_fh_params_match_chan_desc(fhp, chan_desc);
7554
7555 /* 3GPP TS 44.018, section 9.1.36.2 "CBCH Mobile Allocation":
7556 * The CBCH Mobile Allocation IE *shall* be present if FH is enabled. */
7557 if (chan_desc.h and not ispresent(si.payload.si4.cbch_mobile_alloc)) {
7558 setverdict(fail, "FH enabled, but Mobile Allocation IE is absent");
7559 break;
7560 } else if (chan_desc.h and ispresent(si.payload.si4.cbch_mobile_alloc)) {
7561 f_TC_fh_params_match_ma(fhp, chan_desc.chan_nr.tn,
7562 si.payload.si4.cbch_mobile_alloc.v);
7563 }
7564 }
7565 [] IPA_RSL[0].receive { repeat; }
7566 [] T.timeout {
7567 setverdict(fail, "Timeout waiting for RSL BCCH INFOrmation (SI4)");
7568 }
7569 }
7570
7571 /* Disable frequency hopping */
7572 f_TC_fh_params_unset(fhp);
7573
Vadim Yanitskiy8bc46012020-09-06 12:38:01 +07007574 /* (Re)configure TS0 as CCCH+SDCCH4+CBCH and TS1 as TCH/F */
Vadim Yanitskiyca974032020-09-01 07:20:39 +07007575 f_vty_enter_cfg_trx(BSCVTY, trx := 0);
7576
7577 f_vty_transceive(BSCVTY, "timeslot 0");
Vadim Yanitskiy8bc46012020-09-06 12:38:01 +07007578 f_vty_transceive(BSCVTY, "phys_chan_config ccch+sdcch4+cbch");
Vadim Yanitskiyca974032020-09-01 07:20:39 +07007579 f_vty_transceive(BSCVTY, "exit"); /* go back */
7580
7581 f_vty_transceive(BSCVTY, "timeslot 1");
7582 f_vty_transceive(BSCVTY, "phys_chan_config tch/f");
7583 f_vty_transceive(BSCVTY, "end"); /* we're done */
7584
Vadim Yanitskiy21726312020-09-04 01:45:36 +07007585 f_shutdown_helper();
Vadim Yanitskiyca974032020-09-01 07:20:39 +07007586}
7587
Harald Welte0ea2d5e2018-04-07 21:40:29 +02007588/* Dyn PDCH todo:
7589 * activate OSMO as TCH/F
7590 * activate OSMO as TCH/H
7591 * does the BSC-located PCU socket get the updated INFO?
7592 * what if no PCU is connected at the time?
7593 * is the info correct on delayed PCU (re)connect?
7594 */
Harald Welte94e0c342018-04-07 11:33:23 +02007595
Harald Welte28d943e2017-11-25 15:00:50 +01007596control {
Harald Welte898113b2018-01-31 18:32:21 +01007597 /* CTRL interface testing */
Harald Welte4003d112017-12-09 22:35:39 +01007598 execute( TC_ctrl_msc_connection_status() );
Stefan Sperlingb041b3d2018-01-03 17:14:55 +01007599 execute( TC_ctrl_msc0_connection_status() );
Harald Welte96c94412017-12-09 03:12:45 +01007600 execute( TC_ctrl() );
Neels Hofmeyrf246a922020-05-13 02:27:10 +02007601 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_SCCPlite_SERVER) {
Pau Espin Pedrol5a2d7432019-06-07 19:43:45 +02007602 execute( TC_ctrl_location() );
7603 }
Harald Welte898113b2018-01-31 18:32:21 +01007604
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +02007605 execute( TC_si_default() );
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02007606 execute( TC_si2quater_2_earfcns() );
7607 execute( TC_si2quater_3_earfcns() );
7608 execute( TC_si2quater_4_earfcns() );
7609 execute( TC_si2quater_5_earfcns() );
7610 execute( TC_si2quater_6_earfcns() );
Neels Hofmeyrad132f22020-07-08 02:20:16 +02007611 execute( TC_si2quater_12_earfcns() );
7612 execute( TC_si2quater_23_earfcns() );
7613 execute( TC_si2quater_32_earfcns() );
7614 execute( TC_si2quater_33_earfcns() );
7615 execute( TC_si2quater_42_earfcns() );
7616 execute( TC_si2quater_48_earfcns() );
7617 execute( TC_si2quater_49_earfcns() );
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02007618 execute( TC_si_acc_rotate() );
Alexander Couzens4ad3a352020-09-10 22:29:12 +02007619 execute( TC_si_acc_ramp_rotate() );
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +02007620
Harald Welte898113b2018-01-31 18:32:21 +01007621 /* RSL DCHAN Channel ACtivation / Deactivation */
Harald Welteae026692017-12-09 01:03:01 +01007622 execute( TC_chan_act_noreply() );
Harald Welte4003d112017-12-09 22:35:39 +01007623 execute( TC_chan_act_counter() );
Harald Welteae026692017-12-09 01:03:01 +01007624 execute( TC_chan_act_ack_noest() );
Philipp Maier9c60a622020-07-09 15:08:46 +02007625 execute( TC_chan_act_ack_noest_emerg() );
Philipp Maier606f07d2020-08-12 17:21:58 +02007626 execute( TC_chan_rqd_emerg_deny() );
Harald Welteae026692017-12-09 01:03:01 +01007627 execute( TC_chan_act_ack_est_ind_noreply() );
7628 execute( TC_chan_act_ack_est_ind_refused() );
Harald Welte618ef642017-12-14 14:58:20 +01007629 execute( TC_chan_act_nack() );
Harald Welte799c97b2017-12-14 17:50:30 +01007630 execute( TC_chan_exhaustion() );
Vadim Yanitskiy1ff1fdf2018-11-27 01:32:57 +07007631 execute( TC_chan_deact_silence() );
Harald Welte4003d112017-12-09 22:35:39 +01007632 execute( TC_chan_rel_rll_rel_ind() );
7633 execute( TC_chan_rel_conn_fail() );
7634 execute( TC_chan_rel_hard_clear() );
Harald Welte99787102019-02-04 10:41:36 +01007635 execute( TC_chan_rel_hard_clear_csfb() );
Harald Welted8c36cd2017-12-09 23:05:31 +01007636 execute( TC_chan_rel_hard_rlsd() );
Harald Welte550daf92018-06-11 19:22:13 +02007637 execute( TC_chan_rel_hard_rlsd_ms_dead() );
Harald Welte85804d42017-12-10 14:11:58 +01007638 execute( TC_chan_rel_a_reset() );
Pau Espin Pedrolc675b612020-01-09 19:55:40 +01007639 execute( TC_chan_rel_sccp_tiar_timeout() );
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02007640 execute( TC_chan_rel_rr_cause() );
Harald Welte6f521d82017-12-11 19:52:02 +01007641
Harald Weltecfe2c962017-12-15 12:09:32 +01007642 execute( TC_outbound_connect() );
Harald Welte898113b2018-01-31 18:32:21 +01007643
7644 /* Assignment related */
Harald Welte16a4adf2017-12-14 18:54:01 +01007645 execute( TC_assignment_cic_only() );
Harald Welte235ebf12017-12-15 14:18:16 +01007646 execute( TC_assignment_csd() );
7647 execute( TC_assignment_ctm() );
7648 execute( TC_assignment_sign() );
Pau Espin Pedrol07866632020-09-03 19:10:55 +02007649 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
7650 execute( TC_assignment_aoip_tla_v6() );
7651 }
Harald Welte235ebf12017-12-15 14:18:16 +01007652 execute( TC_assignment_fr_a5_0() );
7653 execute( TC_assignment_fr_a5_1() );
Neels Hofmeyrf246a922020-05-13 02:27:10 +02007654 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
Harald Welte8f67d1d2018-05-25 20:38:42 +02007655 execute( TC_assignment_fr_a5_1_codec_missing() );
7656 }
Harald Welte235ebf12017-12-15 14:18:16 +01007657 execute( TC_assignment_fr_a5_3() );
7658 execute( TC_assignment_fr_a5_4() );
Harald Welte3c86ea02018-05-10 22:28:05 +02007659 execute( TC_ciph_mode_a5_0() );
7660 execute( TC_ciph_mode_a5_1() );
7661 execute( TC_ciph_mode_a5_3() );
Harald Welte16a4adf2017-12-14 18:54:01 +01007662
Harald Welte60aa5762018-03-21 19:33:13 +01007663 execute( TC_assignment_codec_fr() );
7664 execute( TC_assignment_codec_hr() );
7665 execute( TC_assignment_codec_efr() );
7666 execute( TC_assignment_codec_amr_f() );
7667 execute( TC_assignment_codec_amr_h() );
Philipp Maier8a581d22019-03-26 18:32:48 +01007668
Neels Hofmeyrf246a922020-05-13 02:27:10 +02007669 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
Philipp Maier8a581d22019-03-26 18:32:48 +01007670 execute( TC_assignment_codec_amr_f_S1() );
7671 execute( TC_assignment_codec_amr_h_S1() );
7672 execute( TC_assignment_codec_amr_f_S124() );
7673 execute( TC_assignment_codec_amr_h_S124() );
7674 execute( TC_assignment_codec_amr_f_S0() );
7675 execute( TC_assignment_codec_amr_f_S02() );
7676 execute( TC_assignment_codec_amr_f_S024() );
7677 execute( TC_assignment_codec_amr_f_S0247() );
7678 execute( TC_assignment_codec_amr_h_S0() );
7679 execute( TC_assignment_codec_amr_h_S02() );
7680 execute( TC_assignment_codec_amr_h_S024() );
7681 execute( TC_assignment_codec_amr_h_S0247() );
7682 execute( TC_assignment_codec_amr_f_S01234567() );
7683 execute( TC_assignment_codec_amr_f_S0234567() );
7684 execute( TC_assignment_codec_amr_f_zero() );
7685 execute( TC_assignment_codec_amr_f_unsupp() );
7686 execute( TC_assignment_codec_amr_h_S7() );
7687 }
Harald Welte60aa5762018-03-21 19:33:13 +01007688
Philipp Maierac09bfc2019-01-08 13:41:39 +01007689 execute( TC_assignment_codec_fr_exhausted_req_hr() );
7690 execute( TC_assignment_codec_fr_exhausted_req_fr() );
7691 execute( TC_assignment_codec_fr_exhausted_req_fr_hr() );
7692 execute( TC_assignment_codec_fr_exhausted_req_hr_fr() );
7693 execute( TC_assignment_codec_hr_exhausted_req_fr() );
7694 execute( TC_assignment_codec_hr_exhausted_req_hr() );
7695 execute( TC_assignment_codec_hr_exhausted_req_hr_fr() );
7696 execute( TC_assignment_codec_hr_exhausted_req_fr_hr() );
7697 execute( TC_assignment_codec_req_hr_fr() );
7698 execute( TC_assignment_codec_req_fr_hr() );
7699
Pau Espin Pedrol58cf6822019-05-28 18:11:33 +02007700 if (mp_enable_osmux_test) {
7701 execute( TC_assignment_osmux() );
7702 }
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02007703
Harald Welte898113b2018-01-31 18:32:21 +01007704 /* RLL Establish Indication on inactive DCHAN / SAPI */
Harald Welte5cd20ed2017-12-13 21:03:20 +01007705 execute( TC_rll_est_ind_inact_lchan() );
7706 execute( TC_rll_est_ind_inval_sapi1() );
7707 execute( TC_rll_est_ind_inval_sapi3() );
7708 execute( TC_rll_est_ind_inval_sacch() );
7709
Vadim Yanitskiy61f784a2020-10-01 21:12:19 +07007710 /* DLCI / RSL Link ID conversion for MO/MT messages on SAPI0/SAPI3 */
7711 execute( TC_tch_dlci_link_id_sapi() );
7712
Vadim Yanitskiy6ef5dfa2020-08-28 18:04:41 +07007713 /* SAPI N Reject triggered by RLL establishment failures */
7714 execute( TC_rll_rel_ind_sapi_n_reject() );
7715 execute( TC_rll_err_ind_sapi_n_reject() );
7716 execute( TC_rll_timeout_sapi_n_reject() );
7717
Harald Welte898113b2018-01-31 18:32:21 +01007718 /* Paging related tests */
Harald Welte6f521d82017-12-11 19:52:02 +01007719 execute( TC_paging_imsi_nochan() );
7720 execute( TC_paging_tmsi_nochan() );
7721 execute( TC_paging_tmsi_any() );
7722 execute( TC_paging_tmsi_sdcch() );
7723 execute( TC_paging_tmsi_tch_f() );
7724 execute( TC_paging_tmsi_tch_hf() );
7725 execute( TC_paging_imsi_nochan_cgi() );
7726 execute( TC_paging_imsi_nochan_lac_ci() );
7727 execute( TC_paging_imsi_nochan_ci() );
7728 execute( TC_paging_imsi_nochan_lai() );
7729 execute( TC_paging_imsi_nochan_lac() );
7730 execute( TC_paging_imsi_nochan_all() );
Harald Welte751d3eb2018-01-31 15:51:06 +01007731 execute( TC_paging_imsi_nochan_plmn_lac_rnc() );
7732 execute( TC_paging_imsi_nochan_rnc() );
7733 execute( TC_paging_imsi_nochan_lac_rnc() );
7734 execute( TC_paging_imsi_nochan_lacs() );
7735 execute( TC_paging_imsi_nochan_lacs_empty() );
Stefan Sperling049a86e2018-03-20 15:51:00 +01007736 execute( TC_paging_imsi_nochan_cgi_unknown_cid() );
Harald Welte10985002017-12-12 09:29:15 +01007737 execute( TC_paging_imsi_a_reset() );
Harald Weltee65d40e2017-12-13 00:09:06 +01007738 execute( TC_paging_imsi_load() );
Philipp Maier779a7922018-02-16 11:00:37 +01007739 execute( TC_paging_counter() );
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01007740 execute( TC_paging_resp_unsol() );
Harald Welte4e9b9cc2017-12-14 18:31:02 +01007741
7742 execute( TC_rsl_drop_counter() );
Stefan Sperling830dc9d2018-02-12 21:08:28 +01007743 execute( TC_rsl_unknown_unit_id() );
7744
7745 execute( TC_oml_unknown_unit_id() );
Harald Welte898113b2018-01-31 18:32:21 +01007746
7747 execute( TC_classmark() );
Harald Welteeddf0e92020-06-21 19:42:15 +02007748 execute( TC_common_id() );
Harald Welte898113b2018-01-31 18:32:21 +01007749 execute( TC_unsol_ass_fail() );
Harald Welteea99a002018-01-31 20:46:43 +01007750 execute( TC_unsol_ass_compl() );
Harald Weltefbf9b5e2018-01-31 20:41:23 +01007751 execute( TC_unsol_ho_fail() );
Harald Weltee3bd6582018-01-31 22:51:25 +01007752 execute( TC_err_82_short_msg() );
Harald Weltee9e02e42018-01-31 23:36:25 +01007753 execute( TC_err_84_unknown_msg() );
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01007754
Harald Welte261af4b2018-02-12 21:20:39 +01007755 execute( TC_ho_int() );
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01007756
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01007757 execute( TC_ho_out_of_this_bsc() );
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02007758 execute( TC_ho_out_fail_no_msc_response() );
7759 execute( TC_ho_out_fail_rr_ho_failure() );
Neels Hofmeyrd8a602c2019-07-09 19:46:01 +02007760 execute( TC_ho_out_fail_no_result_after_ho_cmd() );
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01007761
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01007762 execute( TC_ho_into_this_bsc() );
Pau Espin Pedrol07866632020-09-03 19:10:55 +02007763 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
7764 execute( TC_ho_into_this_bsc_tla_v6() );
7765 }
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01007766 execute( TC_ho_in_fail_msc_clears() );
7767 execute( TC_ho_in_fail_msc_clears_after_ho_detect() );
7768 execute( TC_ho_in_fail_no_detect() );
7769 execute( TC_ho_in_fail_no_detect2() );
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01007770
Neels Hofmeyr91401012019-07-11 00:42:35 +02007771 execute( TC_ho_neighbor_config_1() );
7772 execute( TC_ho_neighbor_config_2() );
7773 execute( TC_ho_neighbor_config_3() );
7774 execute( TC_ho_neighbor_config_4() );
7775 execute( TC_ho_neighbor_config_5() );
7776 execute( TC_ho_neighbor_config_6() );
7777 execute( TC_ho_neighbor_config_7() );
7778
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01007779 execute( TC_bssap_rlsd_does_not_cause_bssmap_reset() );
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01007780 execute( TC_bssmap_clear_does_not_cause_bssmap_reset() );
Neels Hofmeyrfd445c32018-03-09 15:39:31 +01007781 execute( TC_ms_rel_ind_does_not_cause_bssmap_reset() );
Harald Welte94e0c342018-04-07 11:33:23 +02007782
7783 execute( TC_dyn_pdch_ipa_act_deact() );
7784 execute( TC_dyn_pdch_ipa_act_nack() );
7785 execute( TC_dyn_pdch_osmo_act_deact() );
7786 execute( TC_dyn_pdch_osmo_act_nack() );
Harald Welte99f3ca02018-06-14 13:40:29 +02007787
Stefan Sperling0796a822018-10-05 13:01:39 +02007788 execute( TC_chopped_ipa_ping() );
Stefan Sperlingaa1e60f2018-10-15 16:34:07 +02007789 execute( TC_chopped_ipa_payload() );
Stefan Sperling0796a822018-10-05 13:01:39 +02007790
Pau Espin Pedrol8f773632019-11-05 11:46:53 +01007791 /* Power control related */
7792 execute( TC_assignment_verify_ms_power_params_ie() );
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007793
7794 /* MSC pooling */
7795 /* FIXME: in SCCPlite, indicating how many MSCs should be connected does currently not work. Since
7796 * RESET->RESET-ACK is unconditionally negotiated for all configured MSCs, they always all appear as connected
7797 * to osmo-bsc. The MSC pooling tests however require disconnecting selected MSCs, and hence don't work out as
7798 * intended on SCCPlite. So for now, run these only for SCCP/M3UA. */
7799 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
7800 execute( TC_mscpool_L3Compl_on_1_msc() );
7801 execute( TC_mscpool_L3Complete_by_imsi_round_robin() );
7802 execute( TC_mscpool_LU_by_tmsi_null_nri_0_round_robin() );
7803 execute( TC_mscpool_LU_by_tmsi_null_nri_1_round_robin() );
7804 execute( TC_mscpool_L3Complete_by_tmsi_unassigned_nri_round_robin() );
7805 execute( TC_mscpool_L3Complete_by_tmsi_valid_nri_msc_not_connected_round_robin() );
7806 execute( TC_mscpool_L3Complete_by_tmsi_valid_nri_1() );
7807 execute( TC_mscpool_L3Complete_by_tmsi_valid_nri_2() );
7808 execute( TC_mscpool_LU_by_tmsi_from_other_PLMN() );
7809 execute( TC_mscpool_paging_and_response_imsi() );
7810 execute( TC_mscpool_paging_and_response_tmsi() );
7811 execute( TC_mscpool_no_allow_attach_round_robin() );
7812 execute( TC_mscpool_no_allow_attach_valid_nri() );
7813 }
7814
Harald Welte99f3ca02018-06-14 13:40:29 +02007815 /* at bottom as they might crash OsmoBSC before OS#3182 is fixed */
7816 execute( TC_early_conn_fail() );
7817 execute( TC_late_conn_fail() );
7818
Philipp Maier783681c2020-07-16 16:47:06 +02007819 /* Emergency call handling (deny / allow) */
7820 execute( TC_assignment_emerg_setup_allow() );
7821 execute( TC_assignment_emerg_setup_deny_msc() );
7822 execute( TC_assignment_emerg_setup_deny_bts() );
Philipp Maier82812002020-08-13 18:48:27 +02007823 execute( TC_emerg_premption() );
7824
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007825 /* Frequency hopping parameters handling */
7826 execute( TC_fh_params_chan_activ() );
7827 execute( TC_fh_params_imm_ass() );
Vadim Yanitskiyaeb54a22020-09-01 06:25:25 +07007828 execute( TC_fh_params_assignment_cmd() );
Vadim Yanitskiy8f5430d2020-09-02 18:51:38 +07007829 execute( TC_fh_params_handover_cmd() );
Vadim Yanitskiyca974032020-09-01 07:20:39 +07007830 execute( TC_fh_params_si4_cbch() );
Harald Welte28d943e2017-11-25 15:00:50 +01007831}
7832
7833}