blob: d926ad80cefa4b2ce1a2c7a822fc1acbaf4ef31b [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 */
Neels Hofmeyr0aa719b2020-10-12 18:43:09 +00002088 f_mo_l3_transceive(RSL, link_id, dlci, l3);
Vadim Yanitskiy61f784a2020-10-01 21:12:19 +07002089 /* Send MT message: BSSAP -> RSL */
Neels Hofmeyr0aa719b2020-10-12 18:43:09 +00002090 f_mt_l3_transceive(RSL, link_id, dlci, l3);
Vadim Yanitskiy61f784a2020-10-01 21:12:19 +07002091 }
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
Neels Hofmeyr0aa719b2020-10-12 18:43:09 +00004549private function f_mo_l3_transceive(RSL_DCHAN_PT rsl := RSL,
4550 template (value) RslLinkId link_id := ts_RslLinkID_DCCH(0),
Vadim Yanitskiy2ef6a2f2020-10-08 23:17:32 +07004551 template (present) OCT1 dlci := ?,
Vadim Yanitskiyb93aa432020-10-01 14:23:11 +07004552 octetstring l3 := '0123456789'O)
4553runs on MSC_ConnHdlr {
Neels Hofmeyr43654812020-09-25 01:35:35 +02004554 /* The old lchan and conn should still be active. See that arbitrary L3
4555 * is still going through. */
Neels Hofmeyr0aa719b2020-10-12 18:43:09 +00004556 rsl.send(ts_RSL_DATA_IND(g_chan_nr, link_id, l3));
Neels Hofmeyr43654812020-09-25 01:35:35 +02004557 var template PDU_BSSAP exp_data := {
4558 discriminator := '1'B,
4559 spare := '0000000'B,
Vadim Yanitskiyb93aa432020-10-01 14:23:11 +07004560 dlci := dlci,
4561 lengthIndicator := lengthof(l3),
Neels Hofmeyr43654812020-09-25 01:35:35 +02004562 pdu := {
4563 dtap := l3
4564 }
4565 };
4566 BSSAP.receive(exp_data);
4567 setverdict(pass);
4568}
4569
Neels Hofmeyr0aa719b2020-10-12 18:43:09 +00004570private function f_mt_l3_transceive(RSL_DCHAN_PT rsl := RSL,
4571 template (present) RslLinkId link_id := tr_RslLinkID_DCCH(0),
Vadim Yanitskiy0033a3b2020-10-01 22:21:16 +07004572 template (value) OCT1 dlci := '00'O,
4573 octetstring l3 := '0123456789'O)
4574runs on MSC_ConnHdlr {
4575 BSSAP.send(PDU_BSSAP:{
4576 discriminator := '1'B,
4577 spare := '0000000'B,
4578 dlci := dlci,
4579 lengthIndicator := lengthof(l3),
4580 pdu := {
4581 dtap := l3
4582 }
4583 });
Neels Hofmeyr0aa719b2020-10-12 18:43:09 +00004584 rsl.receive(tr_RSL_DATA_REQ(g_chan_nr, link_id, l3));
Vadim Yanitskiy0033a3b2020-10-01 22:21:16 +07004585 setverdict(pass);
4586}
4587
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004588/* BSC asks for inter-BSC HO, but the MSC decides that it won't happen and
4589 * simply never sends a BSSMAP Handover Command. */
4590private function f_tc_ho_out_fail_no_msc_response(charstring id) runs on MSC_ConnHdlr {
Daniel Willmann3b59eb52018-10-29 15:40:55 +01004591 g_pars := f_gen_test_hdlr_pars();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004592
4593 var PDU_BSSAP ass_req := f_gen_ass_req();
4594 ass_req.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4595 ass_req.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
4596 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4597 f_establish_fully(ass_req, exp_compl);
4598
Neels Hofmeyr666f0432020-07-04 00:53:07 +02004599 f_bts_0_cfg(BSCVTY, {"neighbor lac 99 arfcn 123 bsic any"});
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004600 f_vty_transceive(BSCVTY, "handover any to arfcn 123 bsic any");
4601
4602 BSSAP.receive(tr_BSSMAP_HandoverRequired);
4603
4604 /* osmo-bsc should time out 10 seconds after the handover started.
4605 * Let's give it a bit extra. */
4606 f_sleep(15.0);
4607
Vadim Yanitskiy74ae5eb2020-10-01 22:13:29 +07004608 f_mo_l3_transceive();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004609 f_sleep(1.0);
4610}
4611testcase TC_ho_out_fail_no_msc_response() runs on test_CT {
4612 var MSC_ConnHdlr vc_conn;
4613
4614 f_init(1, true);
4615 f_sleep(1.0);
4616
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004617 f_ctrs_bsc_and_bts_init();
4618
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004619 vc_conn := f_start_handler(refers(f_tc_ho_out_fail_no_msc_response));
4620 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004621
4622 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
4623 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
4624 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
4625 f_ctrs_bsc_and_bts_add(0, "handover:timeout");
4626 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
4627 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:timeout");
4628 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004629 f_shutdown_helper();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004630}
4631
4632/* BSC asks for inter-BSC HO, receives BSSMAP Handover Command, but MS reports
4633 * RR Handover Failure. */
4634private function f_tc_ho_out_fail_rr_ho_failure(charstring id) runs on MSC_ConnHdlr {
Daniel Willmann3b59eb52018-10-29 15:40:55 +01004635 g_pars := f_gen_test_hdlr_pars();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004636
4637 var PDU_BSSAP ass_req := f_gen_ass_req();
4638 ass_req.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4639 ass_req.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
4640 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4641 f_establish_fully(ass_req, exp_compl);
4642
Neels Hofmeyr666f0432020-07-04 00:53:07 +02004643 f_bts_0_cfg(BSCVTY, {"neighbor lac 99 arfcn 123 bsic any"});
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004644 f_vty_transceive(BSCVTY, "handover any to arfcn 123 bsic any");
4645
4646 BSSAP.receive(tr_BSSMAP_HandoverRequired);
4647
4648 f_sleep(0.5);
4649 /* The MSC negotiates Handover Request and Handover Request Ack with
4650 * the other BSS and comes back with a BSSMAP Handover Command
4651 * containing an RR Handover Command coming from the target BSS... */
4652
4653 var PDU_ML3_NW_MS rr_ho_cmd := valueof(ts_RR_HandoverCommand);
4654 log("Remote cell's RR Handover Command passed through as L3 Info: ", rr_ho_cmd);
4655 var octetstring rr_ho_cmd_enc := enc_PDU_ML3_NW_MS(rr_ho_cmd);
4656 log("Remote cell's RR Handover Command passed through as L3 Info, encoded: ", rr_ho_cmd_enc);
4657 BSSAP.send(ts_BSSMAP_HandoverCommand(rr_ho_cmd_enc));
4658
4659 /* expect the Handover Command to go out on RR */
4660 var RSL_Message rsl_ho_cmd
4661 RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, ?)) -> value rsl_ho_cmd;
4662 log("RSL Data Req went out to first BTS: ", rsl_ho_cmd);
4663 var RSL_IE_Body rsl_ho_cmd_l3;
4664 if (not f_rsl_find_ie(rsl_ho_cmd, RSL_IE_L3_INFO, rsl_ho_cmd_l3)) {
4665 log("RSL message contains no L3 Info IE, expected RR Handover Command");
4666 setverdict(fail);
4667 } else {
4668 log("Found L3 Info: ", rsl_ho_cmd_l3);
4669 if (rsl_ho_cmd_l3.l3_info.payload != rr_ho_cmd_enc) {
4670 log("FAIL: the BSC sent out a different L3 Info, not matching the RR Handover Command the other BSS forwarded.");
4671 setverdict(fail);
4672 } else {
4673 log("Success: the BSC sent out the same RR Handover Command the other BSS forwarded.");
4674 setverdict(pass);
4675 }
4676 }
4677
4678 f_sleep(0.2);
4679 f_rsl_send_l3(ts_RRM_HandoverFailure('00'O));
4680
4681 /* Should tell the MSC about the failure */
4682 BSSAP.receive(tr_BSSMAP_HandoverFailure);
4683
4684 f_sleep(1.0);
4685
Vadim Yanitskiy74ae5eb2020-10-01 22:13:29 +07004686 f_mo_l3_transceive();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004687 f_sleep(1.0);
4688
4689 setverdict(pass);
4690 f_sleep(1.0);
4691}
4692testcase TC_ho_out_fail_rr_ho_failure() runs on test_CT {
4693 var MSC_ConnHdlr vc_conn;
4694
4695 f_init(1, true);
4696 f_sleep(1.0);
4697
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004698 f_ctrs_bsc_and_bts_init();
4699
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004700 vc_conn := f_start_handler(refers(f_tc_ho_out_fail_rr_ho_failure));
4701 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004702
4703 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
4704 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
4705 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
4706 f_ctrs_bsc_and_bts_add(0, "handover:failed");
4707 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
4708 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:failed");
4709 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004710 f_shutdown_helper();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004711}
4712
Neels Hofmeyr10f2bfa2019-07-09 19:33:29 +02004713/* BSC asks for inter-BSC-out HO, receives BSSMAP Handover Command, but then no reply is received about HO outcome
4714 * (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 +02004715 * and the lchan is released. */
4716private function f_tc_ho_out_fail_no_result_after_ho_cmd(charstring id) runs on MSC_ConnHdlr {
Daniel Willmann3b59eb52018-10-29 15:40:55 +01004717 g_pars := f_gen_test_hdlr_pars();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004718
4719 var PDU_BSSAP ass_req := f_gen_ass_req();
4720 ass_req.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4721 ass_req.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
4722 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4723 f_establish_fully(ass_req, exp_compl);
4724
Neels Hofmeyr666f0432020-07-04 00:53:07 +02004725 f_bts_0_cfg(BSCVTY, {"neighbor lac 99 arfcn 123 bsic any"});
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004726 f_vty_transceive(BSCVTY, "handover any to arfcn 123 bsic any");
4727
4728 BSSAP.receive(tr_BSSMAP_HandoverRequired);
4729
4730 f_sleep(0.5);
4731 /* The MSC negotiates Handover Request and Handover Request Ack with
4732 * the other BSS and comes back with a BSSMAP Handover Command
4733 * containing an RR Handover Command coming from the target BSS... */
4734
4735 var PDU_ML3_NW_MS rr_ho_cmd := valueof(ts_RR_HandoverCommand);
4736 log("Remote cell's RR Handover Command passed through as L3 Info: ", rr_ho_cmd);
4737 var octetstring rr_ho_cmd_enc := enc_PDU_ML3_NW_MS(rr_ho_cmd);
4738 log("Remote cell's RR Handover Command passed through as L3 Info, encoded: ", rr_ho_cmd_enc);
4739 BSSAP.send(ts_BSSMAP_HandoverCommand(rr_ho_cmd_enc));
4740
4741 /* expect the Handover Command to go out on RR */
4742 var RSL_Message rsl_ho_cmd
4743 RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, ?)) -> value rsl_ho_cmd;
4744 log("RSL Data Req went out to first BTS: ", rsl_ho_cmd);
4745 var RSL_IE_Body rsl_ho_cmd_l3;
4746 if (not f_rsl_find_ie(rsl_ho_cmd, RSL_IE_L3_INFO, rsl_ho_cmd_l3)) {
4747 log("RSL message contains no L3 Info IE, expected RR Handover Command");
4748 setverdict(fail);
4749 } else {
4750 log("Found L3 Info: ", rsl_ho_cmd_l3);
4751 if (rsl_ho_cmd_l3.l3_info.payload != rr_ho_cmd_enc) {
4752 log("FAIL: the BSC sent out a different L3 Info, not matching the RR Handover Command the other BSS forwarded.");
4753 setverdict(fail);
4754 } else {
4755 log("Success: the BSC sent out the same RR Handover Command the other BSS forwarded.");
4756 setverdict(pass);
4757 }
4758 }
4759
Neels Hofmeyr10f2bfa2019-07-09 19:33:29 +02004760 /* We get neither success nor failure report from the remote BSS. Eventually T8 times out and we run into 3GPP
4761 * TS 48.008 3.1.5.3.3 "Abnormal Conditions": Clear Request should go to the MSC, and RR should be released
4762 * after Clear Command */
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004763
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02004764 var PDU_BSSAP rx_clear_request;
Neels Hofmeyre1797aa2019-07-09 19:34:04 +02004765 BSSAP.receive(tr_BSSMAP_ClearRequest) -> value rx_clear_request;
4766 log("Got BSSMAP Clear Request");
4767 /* Instruct BSC to clear channel */
4768 var BssmapCause cause := bit2int(rx_clear_request.pdu.bssmap.clearRequest.cause.causeValue);
4769 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
4770
4771 var MgcpCommand mgcp;
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004772 interleave {
Neels Hofmeyr861a4c12018-11-07 01:23:17 +01004773 [] RSL.receive(tr_RSL_DEACT_SACCH(g_chan_nr)) {
4774 log("Got Deact SACCH");
4775 }
Harald Welte924b6ea2019-02-04 01:05:34 +01004776 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_RELEASE)) {
Neels Hofmeyr211169d2018-11-07 00:37:29 +01004777 log("Got RR Release");
4778 }
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004779 [] RSL.receive(tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL)) {
4780 log("Got RF Chan Rel");
4781 RSL.send(ts_RSL_RF_CHAN_REL_ACK(g_chan_nr));
4782 }
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004783 }
4784
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02004785 f_expect_dlcx_conns();
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004786
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004787 setverdict(pass);
4788 f_sleep(1.0);
4789}
Neels Hofmeyrd8a602c2019-07-09 19:46:01 +02004790testcase TC_ho_out_fail_no_result_after_ho_cmd() runs on test_CT {
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004791 var MSC_ConnHdlr vc_conn;
4792
4793 f_init(1, true);
4794 f_sleep(1.0);
4795
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004796 f_ctrs_bsc_and_bts_init();
4797
Neels Hofmeyrd8a602c2019-07-09 19:46:01 +02004798 vc_conn := f_start_handler(refers(f_tc_ho_out_fail_no_result_after_ho_cmd));
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004799 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004800
4801 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
4802 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
4803 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
4804 f_ctrs_bsc_and_bts_add(0, "handover:timeout");
4805 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
4806 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:timeout");
4807 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004808 f_shutdown_helper();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004809}
4810
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004811private function f_tc_ho_into_this_bsc(charstring id) runs on MSC_ConnHdlr {
4812 /* Hack: the proper way would be to wait for the BSSMAP Handover Request ACK and extract the
4813 * actual assigned chan_nr from its L3 (RR Handover Command) message. But osmo-bsc starts acting
4814 * on the lchan even before we get a chance to evaluate the BSSMAP Handover Request ACK. So we
4815 * need to assume that osmo-bsc will activate TS 1 and already set up this lchan's RSL emulation
4816 * before we get started. */
4817 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
4818 f_rslem_register(0, new_chan_nr);
4819 g_chan_nr := new_chan_nr;
4820 f_sleep(1.0);
4821
4822 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
4823 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
4824 activate(as_Media());
4825
Neels Hofmeyr90f80962020-06-12 16:16:55 +02004826 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Pau Espin Pedrol07866632020-09-03 19:10:55 +02004827 f_gen_handover_req(aoip_tla := g_pars.host_aoip_tla)));
Harald Welte6811d102019-04-14 22:23:14 +02004828 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004829
4830 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
4831
4832 var PDU_BSSAP rx_bssap;
4833 var octetstring ho_command_str;
4834
4835 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
Pau Espin Pedrol76ba5412019-06-10 11:00:33 +02004836
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004837 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
4838 log("Received L3 Info in HO Request Ack: ", ho_command_str);
4839 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
4840 log("L3 Info in HO Request Ack is ", ho_command);
4841
4842 var GsmArfcn arfcn;
4843 var RslChannelNr actual_new_chan_nr;
4844 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
4845 actual_new_chan_nr, arfcn);
4846
4847 if (actual_new_chan_nr != new_chan_nr) {
4848 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
4849 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
4850 setverdict(fail);
4851 return;
4852 }
4853 log("Handover Command chan_nr is", actual_new_chan_nr);
4854
4855 /* Now the MSC forwards the RR Handover Command to the other BSC, which
4856 * tells the MS to handover to the new lchan. Here comes the new MS on
4857 * the new lchan with a Handover RACH: */
4858
4859 /* send handover detect */
4860
4861 RSL.send(ts_RSL_HANDO_DET(new_chan_nr));
4862
4863 BSSAP.receive(tr_BSSMAP_HandoverDetect);
4864
4865 /* send handover complete over the new channel */
4866
4867 var PDU_ML3_MS_NW l3_tx := valueof(ts_RRM_HandoverComplete('00'O));
4868 RSL.send(ts_RSL_EST_IND(new_chan_nr, valueof(ts_RslLinkID_DCCH(0)),
4869 enc_PDU_ML3_MS_NW(l3_tx)));
4870
4871 BSSAP.receive(tr_BSSMAP_HandoverComplete);
4872 setverdict(pass);
4873}
Pau Espin Pedrol07866632020-09-03 19:10:55 +02004874function f_tc_ho_into_this_bsc_main(TestHdlrParams pars) runs on test_CT {
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004875 var MSC_ConnHdlr vc_conn;
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004876
4877 f_init(1, true);
4878 f_sleep(1.0);
4879
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004880 f_ctrs_bsc_and_bts_init();
4881
Neels Hofmeyr90f80962020-06-12 16:16:55 +02004882 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
4883 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004884
4885 vc_conn := f_start_handler(refers(f_tc_ho_into_this_bsc), pars);
4886 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004887
4888 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
4889 f_ctrs_bsc_and_bts_add(0, "handover:completed");
4890 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:attempted");
4891 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:completed");
4892 f_ctrs_bsc_and_bts_verify();
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004893}
4894
Pau Espin Pedrol07866632020-09-03 19:10:55 +02004895testcase TC_ho_into_this_bsc() runs on test_CT {
4896 var TestHdlrParams pars := f_gen_test_hdlr_pars();
4897 f_tc_ho_into_this_bsc_main(pars);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004898 f_shutdown_helper();
Pau Espin Pedrol07866632020-09-03 19:10:55 +02004899}
4900
4901testcase TC_ho_into_this_bsc_tla_v6() runs on test_CT {
4902 var TestHdlrParams pars := f_gen_test_hdlr_pars();
4903 pars.host_aoip_tla := "::6";
4904 f_tc_ho_into_this_bsc_main(pars);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004905 f_shutdown_helper();
Pau Espin Pedrol07866632020-09-03 19:10:55 +02004906}
4907
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01004908private function f_tc_ho_in_fail_msc_clears(charstring id) runs on MSC_ConnHdlr {
4909 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
4910 f_rslem_register(0, new_chan_nr);
4911 g_chan_nr := new_chan_nr;
4912 f_sleep(1.0);
4913
4914 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
4915 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
4916 activate(as_Media());
4917
Neels Hofmeyr90f80962020-06-12 16:16:55 +02004918 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01004919 f_gen_handover_req()));
Harald Welte6811d102019-04-14 22:23:14 +02004920 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01004921
4922 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
4923
4924 var PDU_BSSAP rx_bssap;
4925 var octetstring ho_command_str;
4926
4927 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
4928
4929 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
4930 log("Received L3 Info in HO Request Ack: ", ho_command_str);
4931 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
4932 log("L3 Info in HO Request Ack is ", ho_command);
4933
4934 var GsmArfcn arfcn;
4935 var RslChannelNr actual_new_chan_nr;
4936 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
4937 actual_new_chan_nr, arfcn);
4938
4939 if (actual_new_chan_nr != new_chan_nr) {
4940 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
4941 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
4942 setverdict(fail);
4943 return;
4944 }
4945 log("Handover Command chan_nr is", actual_new_chan_nr);
4946
Neels Hofmeyr61ca08d2019-05-06 23:52:22 +02004947 /* For deterministic test results, give some time for the MGW endpoint to be configured */
4948 f_sleep(1.0);
4949
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01004950 /* Now the MSC forwards the RR Handover Command to the other BSC, which
4951 * tells the MS to handover to the new lchan. In this case, the MS
4952 * reports a Handover Failure to the old BSS, which forwards a BSSMAP
4953 * Handover Failure to the MSC. The procedure according to 3GPP TS
4954 * 48.008 3.1.5.3.2 "Handover Failure" is then that the MSC sends a
4955 * BSSMAP Clear Command: */
4956
4957 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_RADIO_INTERFACE_FAILURE_REVERSION;
4958 var BssmapCause cause := enum2int(cause_val);
4959 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
4960
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02004961 f_expect_dlcx_conns();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01004962 setverdict(pass);
4963 f_sleep(1.0);
4964
4965 setverdict(pass);
4966}
4967testcase TC_ho_in_fail_msc_clears() runs on test_CT {
4968 var MSC_ConnHdlr vc_conn;
4969 var TestHdlrParams pars := f_gen_test_hdlr_pars();
4970
4971 f_init(1, true);
4972 f_sleep(1.0);
4973
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004974 f_ctrs_bsc_and_bts_init();
4975
Neels Hofmeyr90f80962020-06-12 16:16:55 +02004976 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
4977 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01004978
4979 vc_conn := f_start_handler(refers(f_tc_ho_in_fail_msc_clears), pars);
4980 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004981
4982 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
4983 f_ctrs_bsc_and_bts_add(0, "handover:stopped");
4984 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:attempted");
4985 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:stopped");
4986 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004987 f_shutdown_helper();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01004988}
4989
4990private function f_tc_ho_in_fail_msc_clears_after_ho_detect(charstring id) runs on MSC_ConnHdlr {
4991 /* Hack: the proper way would be to wait for the BSSMAP Handover Request ACK and extract the
4992 * actual assigned chan_nr from its L3 (RR Handover Command) message. But osmo-bsc starts acting
4993 * on the lchan even before we get a chance to evaluate the BSSMAP Handover Request ACK. So we
4994 * need to assume that osmo-bsc will activate TS 1 and already set up this lchan's RSL emulation
4995 * before we get started. */
4996 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
4997 f_rslem_register(0, new_chan_nr);
4998 g_chan_nr := new_chan_nr;
4999 f_sleep(1.0);
5000
5001 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
5002 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
5003 activate(as_Media());
5004
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005005 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005006 f_gen_handover_req()));
Harald Welte6811d102019-04-14 22:23:14 +02005007 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005008
5009 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
5010
5011 var PDU_BSSAP rx_bssap;
5012 var octetstring ho_command_str;
5013
5014 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
5015
5016 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
5017 log("Received L3 Info in HO Request Ack: ", ho_command_str);
5018 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
5019 log("L3 Info in HO Request Ack is ", ho_command);
5020
5021 var GsmArfcn arfcn;
5022 var RslChannelNr actual_new_chan_nr;
5023 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
5024 actual_new_chan_nr, arfcn);
5025
5026 if (actual_new_chan_nr != new_chan_nr) {
5027 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
5028 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
5029 setverdict(fail);
5030 return;
5031 }
5032 log("Handover Command chan_nr is", actual_new_chan_nr);
5033
5034 /* Now the MSC forwards the RR Handover Command to the other BSC, which
5035 * tells the MS to handover to the new lchan. Here comes the new MS on
5036 * the new lchan with a Handover RACH: */
5037
5038 /* send handover detect */
5039
5040 RSL.send(ts_RSL_HANDO_DET(new_chan_nr));
5041
5042 BSSAP.receive(tr_BSSMAP_HandoverDetect);
5043
5044 /* The MSC chooses to clear the connection now, maybe we got the
5045 * Handover RACH on the new cell but the MS still signaled Handover
5046 * Failure to the old BSS? */
5047
5048 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_RADIO_INTERFACE_FAILURE_REVERSION;
5049 var BssmapCause cause := enum2int(cause_val);
5050 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
5051
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02005052 f_expect_dlcx_conns();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005053 f_sleep(1.0);
5054}
5055testcase TC_ho_in_fail_msc_clears_after_ho_detect() runs on test_CT {
5056 var MSC_ConnHdlr vc_conn;
5057 var TestHdlrParams pars := f_gen_test_hdlr_pars();
5058
5059 f_init(1, true);
5060 f_sleep(1.0);
5061
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005062 f_ctrs_bsc_and_bts_init();
5063
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005064 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
5065 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005066
5067 vc_conn := f_start_handler(refers(f_tc_ho_in_fail_msc_clears_after_ho_detect), pars);
5068 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005069
5070 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5071 f_ctrs_bsc_and_bts_add(0, "handover:stopped");
5072 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:attempted");
5073 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:stopped");
5074 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005075 f_shutdown_helper();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005076}
5077
5078/* The new BSS's lchan times out before the MSC decides that handover failed. */
5079private function f_tc_ho_in_fail_no_detect(charstring id) runs on MSC_ConnHdlr {
5080 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
5081 f_rslem_register(0, new_chan_nr);
5082 g_chan_nr := new_chan_nr;
5083 f_sleep(1.0);
5084
5085 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
5086 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
5087 activate(as_Media());
5088
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005089 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005090 f_gen_handover_req()));
Harald Welte6811d102019-04-14 22:23:14 +02005091 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005092
5093 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
5094
5095 var PDU_BSSAP rx_bssap;
5096 var octetstring ho_command_str;
5097
5098 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
5099
5100 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
5101 log("Received L3 Info in HO Request Ack: ", ho_command_str);
5102 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
5103 log("L3 Info in HO Request Ack is ", ho_command);
5104
5105 var GsmArfcn arfcn;
5106 var RslChannelNr actual_new_chan_nr;
5107 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
5108 actual_new_chan_nr, arfcn);
5109
5110 if (actual_new_chan_nr != new_chan_nr) {
5111 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
5112 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
5113 setverdict(fail);
5114 return;
5115 }
5116 log("Handover Command chan_nr is", actual_new_chan_nr);
5117
5118 /* Now the MSC forwards the RR Handover Command to the other BSC, which
5119 * tells the MS to handover to the new lchan. But the MS never shows up
5120 * on the new lchan. */
5121
5122 BSSAP.receive(tr_BSSMAP_HandoverFailure);
5123
5124 /* Did osmo-bsc also send a Clear Request? */
5125 timer T := 0.5;
5126 T.start;
5127 alt {
5128 [] BSSAP.receive(tr_BSSMAP_ClearRequest);
5129 [] T.timeout { }
5130 }
5131
5132 /* MSC plays along with a Clear Command (no matter whether osmo-bsc
5133 * asked for it, this is a Handover Failure after all). */
5134
5135 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_RADIO_INTERFACE_FAILURE_REVERSION;
5136 var BssmapCause cause := enum2int(cause_val);
5137 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
5138
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02005139 f_expect_dlcx_conns();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005140 f_sleep(1.0);
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005141}
5142testcase TC_ho_in_fail_no_detect() runs on test_CT {
5143 var MSC_ConnHdlr vc_conn;
5144 var TestHdlrParams pars := f_gen_test_hdlr_pars();
5145
5146 f_init(1, true);
5147 f_sleep(1.0);
5148
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005149 f_ctrs_bsc_and_bts_init();
5150
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005151 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
5152 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005153
5154 vc_conn := f_start_handler(refers(f_tc_ho_in_fail_no_detect), pars);
5155 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005156
5157 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5158 f_ctrs_bsc_and_bts_add(0, "handover:error");
5159 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:attempted");
5160 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:error");
5161 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005162 f_shutdown_helper();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005163}
5164
5165/* Same as f_tc_ho_in_fail_no_detect, but MSC fails to send a Clear Command */
5166private function f_tc_ho_in_fail_no_detect2(charstring id) runs on MSC_ConnHdlr {
5167 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
5168 f_rslem_register(0, new_chan_nr);
5169 g_chan_nr := new_chan_nr;
5170 f_sleep(1.0);
5171
5172 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
5173 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
5174 activate(as_Media());
5175
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005176 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005177 f_gen_handover_req()));
Harald Welte6811d102019-04-14 22:23:14 +02005178 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005179
5180 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
5181
5182 var PDU_BSSAP rx_bssap;
5183 var octetstring ho_command_str;
5184
5185 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
5186
5187 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
5188 log("Received L3 Info in HO Request Ack: ", ho_command_str);
5189 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
5190 log("L3 Info in HO Request Ack is ", ho_command);
5191
5192 var GsmArfcn arfcn;
5193 var RslChannelNr actual_new_chan_nr;
5194 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
5195 actual_new_chan_nr, arfcn);
5196
5197 if (actual_new_chan_nr != new_chan_nr) {
5198 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
5199 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
5200 setverdict(fail);
5201 return;
5202 }
5203 log("Handover Command chan_nr is", actual_new_chan_nr);
5204
5205 /* Now the MSC forwards the RR Handover Command to the other BSC, which
5206 * tells the MS to handover to the new lchan. But the MS never shows up
5207 * on the new lchan. */
5208
5209 BSSAP.receive(tr_BSSMAP_HandoverFailure);
5210
5211 /* MSC plays dumb and sends no Clear Command */
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005212 var PDU_BSSAP rx_clear_request;
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02005213
5214 BSSAP.receive(tr_BSSMAP_ClearRequest) -> value rx_clear_request {
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005215 var BssmapCause cause := bit2int(rx_clear_request.pdu.bssmap.clearRequest.cause.causeValue);
5216 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
5217 };
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02005218 f_expect_dlcx_conns();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005219 f_sleep(1.0);
5220}
5221testcase TC_ho_in_fail_no_detect2() runs on test_CT {
5222 var MSC_ConnHdlr vc_conn;
5223 var TestHdlrParams pars := f_gen_test_hdlr_pars();
5224
5225 f_init(1, true);
5226 f_sleep(1.0);
5227
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005228 f_ctrs_bsc_and_bts_init();
5229
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005230 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
5231 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005232
5233 vc_conn := f_start_handler(refers(f_tc_ho_in_fail_no_detect2), pars);
5234 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005235
5236 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5237 f_ctrs_bsc_and_bts_add(0, "handover:error");
5238 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:attempted");
5239 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:error");
5240 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005241 f_shutdown_helper();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005242}
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005243
Neels Hofmeyr91401012019-07-11 00:42:35 +02005244type record of charstring Commands;
5245
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005246private function f_bts_0_cfg(TELNETasp_PT pt, Commands cmds := {})
Neels Hofmeyr91401012019-07-11 00:42:35 +02005247{
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005248 f_vty_enter_cfg_bts(pt, 0);
Neels Hofmeyr91401012019-07-11 00:42:35 +02005249 for (var integer i := 0; i < sizeof(cmds); i := i+1) {
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005250 f_vty_transceive(pt, cmds[i]);
Neels Hofmeyr91401012019-07-11 00:42:35 +02005251 }
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005252 f_vty_transceive(pt, "end");
Neels Hofmeyr91401012019-07-11 00:42:35 +02005253}
5254
Pau Espin Pedrolc675b612020-01-09 19:55:40 +01005255private function f_cs7_inst_0_cfg(TELNETasp_PT pt, Commands cmds := {})
5256{
5257 f_vty_enter_cfg_cs7_inst(pt, 0);
5258 for (var integer i := 0; i < sizeof(cmds); i := i+1) {
5259 f_vty_transceive(pt, cmds[i]);
5260 }
5261 f_vty_transceive(pt, "end");
5262}
5263
Neels Hofmeyr91401012019-07-11 00:42:35 +02005264private function f_probe_for_handover(charstring log_label,
5265 charstring log_descr,
5266 charstring handover_vty_cmd,
5267 boolean expect_handover,
5268 boolean is_inter_bsc_handover := false)
5269runs on MSC_ConnHdlr
5270{
Neels Hofmeyrb3fc8982020-05-11 00:16:42 +02005271 /* We're going to thwart any and all handover attempts, just be ready to handle (and ignore) handover target
5272 * lchans to be established on bts 1 or bts 2. */
5273 f_rslem_suspend(RSL1_PROC);
5274 f_rslem_suspend(RSL2_PROC);
5275
Neels Hofmeyr91401012019-07-11 00:42:35 +02005276 var RSL_Message rsl;
5277
5278 var charstring log_msg := " (expecting handover)"
5279 if (not expect_handover) {
5280 log_msg := " (expecting NO handover)";
5281 }
5282 log("f_probe_for_handover starting: " & log_label & ": " & log_descr & log_msg);
5283 f_vty_transceive(BSCVTY, handover_vty_cmd);
5284
Neels Hofmeyr91401012019-07-11 00:42:35 +02005285 timer T := 2.0;
5286 T.start;
5287
5288 alt {
5289 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr)) -> value rsl {
5290 var PDU_ML3_NW_MS l3 := dec_PDU_ML3_NW_MS(rsl.ies[2].body.l3_info.payload);
5291 log("Rx L3 from net: ", l3);
5292 if (ischosen(l3.msgs.rrm.handoverCommand)) {
5293 var RslChannelNr new_chan_nr;
5294 var GsmArfcn arfcn;
5295 f_ChDesc2RslChanNr(l3.msgs.rrm.handoverCommand.channelDescription2,
5296 new_chan_nr, arfcn);
5297 log("Handover to new chan ", new_chan_nr, " on ARFCN ", arfcn);
5298 log(l3.msgs.rrm.handoverCommand);
5299
5300 /* Need to register for new lchan on new BTS -- it's either bts 1 or bts 2. It doesn't really
5301 * matter on which BTS it really is, we're not going to follow through an entire handover
5302 * anyway. */
5303 f_rslem_register(0, new_chan_nr, RSL1_PROC);
5304 f_rslem_resume(RSL1_PROC);
5305 f_rslem_register(0, new_chan_nr, RSL2_PROC);
5306 f_rslem_resume(RSL2_PROC);
5307
5308 if (expect_handover and not is_inter_bsc_handover) {
5309 setverdict(pass);
5310 log("f_probe_for_handover(" & log_label & "): Got RSL Handover Command as expected.");
5311 } else {
5312 setverdict(fail, "f_probe_for_handover(" & log_label & "): Expected none, but got RSL Handover Command. "
5313 & log_label & ": " & log_descr);
5314 }
5315
5316 log("f_probe_for_handover(" & log_label & "): Ending the test: Handover Failure stops the procedure.");
5317 /* osmo-bsc has triggered Handover. That's all we need to know for this test, reply with
5318 * Handover Failure. */
5319 f_rsl_send_l3(ts_RRM_HandoverFailure('00'O));
5320
5321 /* target BTS is told to release lchan again; don't care which BTS nor what messages. */
5322 f_sleep(0.5);
5323 RSL1.clear;
5324 RSL2.clear;
5325 log("f_probe_for_handover(" & log_label & "): done (got RSL Handover Command)");
5326 break;
5327 } else {
5328 repeat;
5329 }
5330 }
5331 [] BSSAP.receive(tr_BSSMAP_HandoverRequired) {
5332 if (expect_handover and is_inter_bsc_handover) {
5333 setverdict(pass);
5334 log("f_probe_for_handover(" & log_label & "): Got BSSMAP Handover Required as expected.");
5335 } else {
5336 setverdict(fail, "f_probe_for_handover(" & log_label & "): Expected none, but got BSSMAP Handover Required. "
5337 & log_label & ": " & log_descr);
5338 }
5339
5340 log("f_probe_for_handover(" & log_label & "): done (got BSSMAP Handover Required)");
5341
5342 /* Note: f_tc_ho_neighbor_config_start() sets T7, the timeout for BSSMAP Handover Required, to
5343 * 1 second. There is no legal way to quickly abort a handover after a BSSMAP Handover Required,
5344 * setting a short timeout and waiting is the only way. */
5345 log("f_probe_for_handover(" & log_label & "): waiting for inter-BSC HO to time out...");
5346 f_sleep(1.5);
5347 log("f_probe_for_handover(" & log_label & "): ...done");
5348
5349 break;
5350 }
5351 [] T.timeout {
5352 if (expect_handover) {
5353 setverdict(fail, "f_probe_for_handover(" & log_label & "): Expected Handover, but got none. "
5354 & log_label & ": " & log_descr);
5355 } else {
5356 setverdict(pass);
5357 log("f_probe_for_handover(" & log_label & "): Got no Handover, as expected.");
5358 }
5359 log("f_probe_for_handover(" & log_label & "): done (got no Handover)");
5360 break;
5361 }
5362 }
5363
5364 f_rslem_resume(RSL1_PROC);
5365 f_rslem_resume(RSL2_PROC);
5366 f_sleep(3.0);
5367 RSL.clear;
5368
5369 log("f_probe_for_handover(" & log_label & "): done clearing");
5370}
5371
5372/* Test the effect of various neighbor configuration scenarios:
5373 *
5374 * To avoid complexity, block off any actual handover operation, and always remain on the lchan at bts 0.
5375 * Reconfigure the neighbors for bts 0, trigger a Handover, and probe whether osmo-bsc does or doesn't start HO.
5376 */
5377private function f_tc_ho_neighbor_config_start() runs on MSC_ConnHdlr {
5378 g_pars := f_gen_test_hdlr_pars();
5379 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
5380 var PDU_BSSAP ass_cmd := f_gen_ass_req();
5381 const OCT8 kc := '0001020304050607'O;
5382
5383 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
5384 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
5385
5386 /* Establish lchan at bts 0 */
5387 f_establish_fully(ass_cmd, exp_compl);
5388
5389 /* Shorten the inter-BSC Handover timeout, to not wait so long for inter-BSC Handovers */
5390 f_vty_enter_cfg_network(BSCVTY);
5391 f_vty_transceive(BSCVTY, "timer T7 1");
5392 f_vty_transceive(BSCVTY, "end");
5393}
5394
5395private function f_tc_ho_neighbor_config_1(charstring id) runs on MSC_ConnHdlr {
5396 f_tc_ho_neighbor_config_start();
5397
5398 /*
5399 * bts 0 ARFCN 871 BSIC 10
5400 * bts 1 ARFCN 871 BSIC 11
5401 * bts 2 ARFCN 871 BSIC 12
5402 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
5403 */
5404
5405 log("f_tc_ho_neighbor_config: 1. No 'neighbor' config");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005406 f_bts_0_cfg(BSCVTY, {"no neighbors"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02005407 f_probe_for_handover("1.a", "HO to bts 1 works, implicitly listed as neighbor (legacy behavior when none are configured)",
5408 "handover any to arfcn 871 bsic 11",
5409 true);
5410
5411 f_probe_for_handover("1.b", "HO to unknown cell does not start",
5412 "handover any to arfcn 13 bsic 39",
5413 false);
5414
5415 f_probe_for_handover("1.c", "HO to 871-12 is ambiguous = error",
5416 "handover any to arfcn 871 bsic 12",
5417 false);
5418
5419 f_probe_for_handover("1.d", "HO to 871-11 still works (verify that this test properly cleans up)",
5420 "handover any to arfcn 871 bsic 11",
5421 true);
5422}
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005423testcase TC_ho_neighbor_config_1() runs on test_CT {
5424 var MSC_ConnHdlr vc_conn;
5425 f_init(3, true, guard_timeout := 60.0);
5426 f_sleep(1.0);
5427 f_ctrs_bsc_and_bts_init();
5428 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_1));
5429 vc_conn.done;
5430
5431 /* f_tc_ho_neighbor_config_start() */
5432 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5433 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5434
5435 /* 1.a */
5436 /* "failed" means a handover was triggered and started (which is all this test aims for) and the test ended the
5437 * handover quickly by sending a Handover Failure message. */
5438 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5439 f_ctrs_bsc_and_bts_add(0, "handover:failed");
5440 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
5441 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:failed");
5442
5443 /* 1.b */
5444 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5445 f_ctrs_bsc_and_bts_add(0, "handover:error");
5446
5447 /* 1.c */
5448 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5449 f_ctrs_bsc_and_bts_add(0, "handover:error");
5450
5451 /* 1.d */
5452 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5453 f_ctrs_bsc_and_bts_add(0, "handover:failed");
5454 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
5455 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:failed");
5456
5457 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005458 f_shutdown_helper();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005459}
5460
Neels Hofmeyr91401012019-07-11 00:42:35 +02005461private function f_tc_ho_neighbor_config_2(charstring id) runs on MSC_ConnHdlr {
5462 f_tc_ho_neighbor_config_start();
5463
5464 /*
5465 * bts 0 ARFCN 871 BSIC 10
5466 * bts 1 ARFCN 871 BSIC 11
5467 * bts 2 ARFCN 871 BSIC 12
5468 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
5469 */
5470
5471 log("f_tc_ho_neighbor_config: 2. explicit local neighbor: 'neighbor bts 1'");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005472 f_bts_0_cfg(BSCVTY, {"neighbor bts 1"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02005473 f_sleep(0.5);
5474
5475 f_probe_for_handover("2.a", "HO to bts 1 works, explicitly listed as neighbor",
5476 "handover any to arfcn 871 bsic 11",
5477 true);
5478
5479 f_probe_for_handover("2.b", "HO to bts 2 doesn't work, not listed as neighbor",
5480 "handover any to arfcn 871 bsic 12",
5481 false);
5482}
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005483testcase TC_ho_neighbor_config_2() runs on test_CT {
5484 var MSC_ConnHdlr vc_conn;
5485 f_init(3, true, guard_timeout := 50.0);
5486 f_sleep(1.0);
5487 f_ctrs_bsc_and_bts_init();
5488 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_2));
5489 vc_conn.done;
5490
5491 /* f_tc_ho_neighbor_config_start() */
5492 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5493 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5494
5495 /* 2.a */
5496 /* "failed" means a handover was triggered and started (which is all this test aims for) and the test ended the
5497 * handover quickly by sending a Handover Failure message. */
5498 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5499 f_ctrs_bsc_and_bts_add(0, "handover:failed");
5500 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
5501 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:failed");
5502
5503 /* 2.b */
5504 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5505 f_ctrs_bsc_and_bts_add(0, "handover:error");
5506
5507 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005508 f_shutdown_helper();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005509}
5510
Neels Hofmeyr91401012019-07-11 00:42:35 +02005511private function f_tc_ho_neighbor_config_3(charstring id) runs on MSC_ConnHdlr {
5512 f_tc_ho_neighbor_config_start();
5513
5514 /*
5515 * bts 0 ARFCN 871 BSIC 10
5516 * bts 1 ARFCN 871 BSIC 11
5517 * bts 2 ARFCN 871 BSIC 12
5518 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
5519 */
5520
5521 log("f_tc_ho_neighbor_config: 3. explicit local neighbor: 'neighbor bts 2'");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005522 f_bts_0_cfg(BSCVTY, {"no neighbors", "neighbor bts 2"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02005523 f_sleep(0.5);
5524
5525 f_probe_for_handover("3.a", "HO to bts 1 doesn't work, not listed as neighbor",
5526 "handover any to arfcn 871 bsic 11",
5527 false);
5528 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",
5529 "handover any to arfcn 871 bsic 12",
5530 true);
5531}
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005532testcase TC_ho_neighbor_config_3() runs on test_CT {
5533 var MSC_ConnHdlr vc_conn;
5534 f_init(3, true, guard_timeout := 50.0);
5535 f_sleep(1.0);
5536 f_ctrs_bsc_and_bts_init();
5537 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_3));
5538 vc_conn.done;
5539
5540 /* f_tc_ho_neighbor_config_start() */
5541 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5542 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5543
5544 /* 3.a */
5545 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5546 f_ctrs_bsc_and_bts_add(0, "handover:error");
5547
5548 /* 3.b */
5549 /* "failed" means a handover was triggered and started (which is all this test aims for) and the test ended the
5550 * handover quickly by sending a Handover Failure message. */
5551 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5552 f_ctrs_bsc_and_bts_add(0, "handover:failed");
5553 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
5554 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:failed");
5555
5556 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005557 f_shutdown_helper();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005558}
5559
Neels Hofmeyr91401012019-07-11 00:42:35 +02005560private function f_tc_ho_neighbor_config_4(charstring id) runs on MSC_ConnHdlr {
5561 f_tc_ho_neighbor_config_start();
5562
5563 /*
5564 * bts 0 ARFCN 871 BSIC 10
5565 * bts 1 ARFCN 871 BSIC 11
5566 * bts 2 ARFCN 871 BSIC 12
5567 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
5568 */
5569
5570 log("f_tc_ho_neighbor_config: 4. explicit remote neighbor: 'neighbor lac 99 arfcn 123 bsic 45'");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005571 f_bts_0_cfg(BSCVTY, {"no neighbors", "neighbor lac 99 arfcn 123 bsic 45"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02005572 f_sleep(0.5);
5573
5574 f_probe_for_handover("4.a", "HO to bts 1 doesn't work, not listed as neighbor",
5575 "handover any to arfcn 871 bsic 11",
5576 false);
5577 f_probe_for_handover("4.b", "HO to bts 2 doesn't work, not listed as neighbor",
5578 "handover any to arfcn 871 bsic 12",
5579 false);
5580 f_probe_for_handover("4.c", "HO to 123-45 triggers inter-BSC HO",
5581 "handover any to arfcn 123 bsic 45",
5582 true, true);
5583}
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005584testcase TC_ho_neighbor_config_4() runs on test_CT {
5585 var MSC_ConnHdlr vc_conn;
5586 f_init(3, true, guard_timeout := 50.0);
5587 f_sleep(1.0);
5588 f_ctrs_bsc_and_bts_init();
5589 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_4));
5590 vc_conn.done;
5591
5592 /* f_tc_ho_neighbor_config_start() */
5593 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5594 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5595
5596 /* 4.a */
5597 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5598 f_ctrs_bsc_and_bts_add(0, "handover:error");
5599
5600 /* 4.b */
5601 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5602 f_ctrs_bsc_and_bts_add(0, "handover:error");
5603
5604 /* 4.c */
5605 /* "timeout" means a handover was triggered and started (which is all this test aims for) and the test ended the
5606 * handover quickly by timing out after the Handover Required message */
5607 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5608 f_ctrs_bsc_and_bts_add(0, "handover:timeout");
5609 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
5610 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:timeout");
5611
5612 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005613 f_shutdown_helper();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005614}
5615
Neels Hofmeyr91401012019-07-11 00:42:35 +02005616private function f_tc_ho_neighbor_config_5(charstring id) runs on MSC_ConnHdlr {
5617 f_tc_ho_neighbor_config_start();
5618
5619 /*
5620 * bts 0 ARFCN 871 BSIC 10
5621 * bts 1 ARFCN 871 BSIC 11
5622 * bts 2 ARFCN 871 BSIC 12
5623 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
5624 */
5625
5626 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 +02005627 f_bts_0_cfg(BSCVTY, {"no neighbors", "neighbor lac 99 arfcn 871 bsic 12"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02005628 f_sleep(0.5);
5629
5630 f_probe_for_handover("5.a", "HO to 871-12 triggers inter-BSC HO (ignoring local cells with same ARFCN+BSIC)",
5631 "handover any to arfcn 871 bsic 12",
5632 true, true);
5633}
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005634testcase TC_ho_neighbor_config_5() runs on test_CT {
5635 var MSC_ConnHdlr vc_conn;
5636 f_init(3, true);
5637 f_sleep(1.0);
5638 f_ctrs_bsc_and_bts_init();
5639 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_5));
5640 vc_conn.done;
5641
5642 /* f_tc_ho_neighbor_config_start() */
5643 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5644 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5645
5646 /* 5 */
5647 /* "timeout" means a handover was triggered and started (which is all this test aims for) and the test ended the
5648 * handover quickly by timing out after the Handover Required message */
5649 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5650 f_ctrs_bsc_and_bts_add(0, "handover:timeout");
5651 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
5652 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:timeout");
5653
5654 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005655 f_shutdown_helper();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005656}
5657
Neels Hofmeyr91401012019-07-11 00:42:35 +02005658private function f_tc_ho_neighbor_config_6(charstring id) runs on MSC_ConnHdlr {
5659 f_tc_ho_neighbor_config_start();
5660
5661 /*
5662 * bts 0 ARFCN 871 BSIC 10
5663 * bts 1 ARFCN 871 BSIC 11
5664 * bts 2 ARFCN 871 BSIC 12
5665 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
5666 */
5667
5668 log("f_tc_ho_neighbor_config: 6. config error: explicit local and remote neighbors with ambiguous ARFCN+BSIC:"
5669 & " 'neighbor bts 2; neighbor lac 99 arfcn 871 bsic 12'");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005670 f_bts_0_cfg(BSCVTY, {"no neighbors", "neighbor bts 2", "neighbor lac 99 arfcn 871 bsic 12"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02005671 f_sleep(0.5);
5672
5673 f_probe_for_handover("6.a", "HO to 871-12 is ambiguous = error",
5674 "handover any to arfcn 871 bsic 12",
5675 false);
5676}
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005677testcase TC_ho_neighbor_config_6() runs on test_CT {
5678 var MSC_ConnHdlr vc_conn;
5679 f_init(3, true);
5680 f_sleep(1.0);
5681 f_ctrs_bsc_and_bts_init();
5682 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_6));
5683 vc_conn.done;
5684
5685 /* f_tc_ho_neighbor_config_start() */
5686 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5687 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5688
5689 /* 6.a */
5690 /* "timeout" means a handover was triggered and started (which is all this test aims for) and the test ended the
5691 * handover quickly by timing out after the Handover Required message */
5692 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5693 f_ctrs_bsc_and_bts_add(0, "handover:error");
5694
5695 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005696 f_shutdown_helper();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005697}
5698
Neels Hofmeyr91401012019-07-11 00:42:35 +02005699private function f_tc_ho_neighbor_config_7(charstring id) runs on MSC_ConnHdlr {
5700 f_tc_ho_neighbor_config_start();
5701
5702 /*
5703 * bts 0 ARFCN 871 BSIC 10
5704 * bts 1 ARFCN 871 BSIC 11
5705 * bts 2 ARFCN 871 BSIC 12
5706 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
5707 */
5708
5709 log("f_tc_ho_neighbor_config: 7. explicit local and remote neighbors:"
5710 & " 'neighbor bts 2; neighbor lac 99 arfcn 123 bsic 45'");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005711 f_bts_0_cfg(BSCVTY, {"no neighbors", "neighbor bts 2", "neighbor lac 99 arfcn 123 bsic 45"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02005712 f_sleep(0.5);
5713
5714 f_probe_for_handover("7.a", "HO to 871-12 does HO to bts 2",
5715 "handover any to arfcn 871 bsic 12",
5716 true);
5717 f_probe_for_handover("7.b", "HO to 123-45 triggers inter-BSC HO",
5718 "handover any to arfcn 123 bsic 45",
5719 true, true);
5720}
Neels Hofmeyr91401012019-07-11 00:42:35 +02005721testcase TC_ho_neighbor_config_7() runs on test_CT {
5722 var MSC_ConnHdlr vc_conn;
Neels Hofmeyrf2b88032020-06-16 00:35:04 +02005723 f_init(3, true, guard_timeout := 50.0);
Neels Hofmeyr91401012019-07-11 00:42:35 +02005724 f_sleep(1.0);
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005725 f_ctrs_bsc_and_bts_init();
Neels Hofmeyr91401012019-07-11 00:42:35 +02005726 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_7));
5727 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005728
5729 /* f_tc_ho_neighbor_config_start() */
5730 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5731 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5732
5733 /* 7.a */
5734 /* "failed" means a handover was triggered and started (which is all this test aims for) and the test ended the
5735 * handover quickly by sending a Handover Failure message. */
5736 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5737 f_ctrs_bsc_and_bts_add(0, "handover:failed");
5738 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
5739 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:failed");
5740
5741 /* 7.b */
5742 /* "timeout" means a handover was triggered and started (which is all this test aims for) and the test ended the
5743 * handover quickly by timing out after the Handover Required message */
5744 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5745 f_ctrs_bsc_and_bts_add(0, "handover:timeout");
5746 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
5747 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:timeout");
5748
5749 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005750 f_shutdown_helper();
Neels Hofmeyr91401012019-07-11 00:42:35 +02005751}
5752
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01005753/* OS#3041: Open and close N connections in a normal fashion, and expect no
5754 * BSSMAP Reset just because of that. */
5755testcase TC_bssap_rlsd_does_not_cause_bssmap_reset() runs on test_CT {
5756 var default d;
5757 var integer i;
5758 var DchanTuple dt;
5759
5760 f_init();
5761
5762 /* Wait for initial BSSMAP Reset to pass */
5763 f_sleep(4.0);
5764
5765 d := activate(no_bssmap_reset());
5766
5767 /* Setup up a number of connections and RLSD them again from the MSC
5768 * side. In the buggy behavior, the fourth one triggers BSSMAP Reset.
5769 * Let's do it some more times for good measure. */
Harald Weltec3260d92018-06-11 17:48:16 +02005770 for (i := 0; i < 4; i := i+1) {
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01005771 /* Since we're doing a lot of runs, give each one a fresh
5772 * T_guard from the top. */
5773 T_guard.start;
5774
5775 /* Setup a BSSAP connection and clear it right away. This is
5776 * the MSC telling the BSC about a planned release, it's not an
5777 * erratic loss of a connection. */
Harald Weltea1897182018-06-11 13:53:09 +02005778 dt := f_est_dchan(int2oct(i,1), 23+i, '00010203040506'O);
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01005779
5780 /* MSC disconnects (RLSD). */
5781 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
5782 }
5783
5784 /* In the buggy behavior, a timeout of 2 seconds happens between above
5785 * trigger (logs "SIGTRAN connection down, reconnecting...") and the
5786 * actual BSSMAP Reset. Wait a bit longer just to make sure. */
5787 f_sleep(4.0);
5788
5789 deactivate(d);
5790 f_shutdown_helper();
5791}
Harald Welte552620d2017-12-16 23:21:36 +01005792
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01005793/* OS#3041: Open and close N connections in a normal fashion, and expect no
5794 * BSSMAP Reset just because of that. Invoke the release by a BSSMAP Clear from
5795 * the MSC. */
5796testcase TC_bssmap_clear_does_not_cause_bssmap_reset() runs on test_CT {
5797 var default d;
5798 var integer i;
5799 var DchanTuple dt;
5800 var BSSAP_N_DATA_ind rx_di;
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01005801 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_CALL_CONTROL;
5802 var BssmapCause cause := enum2int(cause_val);
5803
5804 f_init();
5805
5806 /* Wait for initial BSSMAP Reset to pass */
5807 f_sleep(4.0);
5808
5809 d := activate(no_bssmap_reset());
5810
5811 /* Setup up a number of connections and RLSD them again from the MSC
5812 * side. In the buggy behavior, the fourth one triggers BSSMAP Reset.
5813 * Let's do it some more times for good measure. */
5814 for (i := 0; i < 8; i := i+1) {
5815 /* Since we're doing a lot of runs, give each one a fresh
5816 * T_guard from the top. */
5817 T_guard.start;
5818
5819 /* Setup a BSSAP connection and clear it right away. This is
5820 * the MSC telling the BSC about a planned release, it's not an
5821 * erratic loss of a connection. */
Harald Weltea1897182018-06-11 13:53:09 +02005822 dt := f_est_dchan(int2oct(i,1), 23+i, '00010203040506'O);
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01005823
5824 /* Instruct BSC to clear channel */
5825 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
5826
5827 /* expect BSC to disable the channel */
Harald Welte641fcbe2018-06-14 10:58:35 +02005828 f_exp_chan_rel_and_clear(dt, 0);
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01005829 }
5830
5831 /* In the buggy behavior, a timeout of 2 seconds happens between above
5832 * trigger (logs "SIGTRAN connection down, reconnecting...") and the
5833 * actual BSSMAP Reset. Wait a bit longer just to make sure. */
5834 f_sleep(4.0);
5835
5836 deactivate(d);
5837 f_shutdown_helper();
5838}
5839
Neels Hofmeyrfd445c32018-03-09 15:39:31 +01005840/* OS#3041: Open and close N connections in a normal fashion, and expect no
5841 * BSSMAP Reset just because of that. Close connections from the MS side with a
5842 * Release Ind on RSL. */
5843testcase TC_ms_rel_ind_does_not_cause_bssmap_reset() runs on test_CT {
5844 var default d;
5845 var integer i;
5846 var DchanTuple dt;
5847 var BSSAP_N_DATA_ind rx_di;
Neels Hofmeyrfd445c32018-03-09 15:39:31 +01005848 var integer j;
5849
5850 f_init();
5851
5852 /* Wait for initial BSSMAP Reset to pass */
5853 f_sleep(4.0);
5854
5855 d := activate(no_bssmap_reset());
5856
5857 /* Setup up a number of connections and RLSD them again from the MSC
5858 * side. In the buggy behavior, the fourth one triggers BSSMAP Reset.
5859 * Let's do it some more times for good measure. */
5860 for (i := 0; i < 8; i := i+1) {
5861 /* Since we're doing a lot of runs, give each one a fresh
5862 * T_guard from the top. */
5863 T_guard.start;
5864
5865 /* Setup a BSSAP connection and clear it right away. This is
5866 * the MSC telling the BSC about a planned release, it's not an
5867 * erratic loss of a connection. */
5868 dt := f_est_dchan('23'O, 23, '00010203040506'O);
5869
5870 /* simulate RLL REL IND */
5871 f_ipa_tx(0, ts_RSL_REL_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0))));
5872
5873 /* expect Clear Request on MSC side */
5874 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearRequest)) -> value rx_di;
5875
5876 /* Instruct BSC to clear channel */
5877 var BssmapCause cause := bit2int(rx_di.userData.pdu.bssmap.clearRequest.cause.causeValue);
5878 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
5879
5880 /* expect BSC to disable the channel */
Harald Welte641fcbe2018-06-14 10:58:35 +02005881 f_exp_chan_rel_and_clear(dt, 0);
Neels Hofmeyrfd445c32018-03-09 15:39:31 +01005882 }
5883
5884 /* In the buggy behavior, a timeout of 2 seconds happens between above
5885 * trigger (logs "SIGTRAN connection down, reconnecting...") and the
5886 * actual BSSMAP Reset. Wait a bit longer just to make sure. */
5887 f_sleep(4.0);
5888
5889 deactivate(d);
5890 f_shutdown_helper();
5891}
5892
Harald Welte94e0c342018-04-07 11:33:23 +02005893/***********************************************************************
5894 * IPA style dynamic PDCH
5895 ***********************************************************************/
5896
5897private function f_dyn_ipa_pdch_act(integer bts_nr, integer trx_nr, integer ts_nr,
5898 template (omit) RSL_Cause nack := omit)
5899runs on test_CT {
5900 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(ts_nr));
5901 var RSL_Message rsl_unused;
5902 /* ask BSC via VTY to activate a given IPA style chan as PDCH */
5903 f_vty_ts_action("pdch activate", bts_nr, trx_nr, ts_nr);
5904 /* expect the BSC to issue the related RSL command */
5905 rsl_unused := f_exp_ipa_rx(0, tr_RSL_IPA_PDCH_ACT(chan_nr));
5906 if (istemplatekind(nack, "omit")) {
5907 /* respond with a related acknowledgement */
5908 f_ipa_tx(0, ts_RSL_IPA_PDCH_ACT_ACK(chan_nr, ts_RSL_IE_FrameNumber(2342)));
5909 } else {
5910 f_ipa_tx(0, ts_RSL_IPA_PDCH_ACT_NACK(chan_nr, valueof(nack)));
5911 }
5912}
5913
5914private function f_dyn_ipa_pdch_deact(integer bts_nr, integer trx_nr, integer ts_nr,
5915 template (omit) RSL_Cause nack := omit)
5916runs on test_CT {
5917 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(ts_nr));
5918 var RSL_Message rsl_unused;
5919 /* ask BSC via VTY to activate a given IPA style chan as PDCH */
5920 f_vty_ts_action("pdch deactivate", bts_nr, trx_nr, ts_nr);
5921 /* expect the BSC to issue the related RSL command */
5922 rsl_unused := f_exp_ipa_rx(0, tr_RSL_IPA_PDCH_DEACT(chan_nr));
5923 if (istemplatekind(nack, "omit")) {
5924 /* respond with a related acknowledgement */
5925 f_ipa_tx(0, ts_RSL_IPA_PDCH_DEACT_ACK(chan_nr));
5926 } else {
5927 f_ipa_tx(0, ts_RSL_IPA_PDCH_DEACT_NACK(chan_nr, valueof(nack)));
5928 }
5929}
5930
5931private function f_ts_dyn_mode_get(integer bts_nr, integer trx_nr, integer ts_nr)
5932runs on test_CT return charstring {
5933 var charstring cmd, resp;
5934 cmd := "show timeslot "&int2str(bts_nr)&" "&int2str(trx_nr)&" "&int2str(ts_nr);
Stefan Sperlingcff13562018-11-13 15:24:06 +01005935 return f_vty_transceive_match_regexp_retry(BSCVTY, cmd, "*\((*)\)*", 0, 4, 1.0);
Harald Welte94e0c342018-04-07 11:33:23 +02005936}
5937
5938private function f_ts_dyn_mode_assert(integer bts_nr, integer trx_nr, integer ts_nr,
5939 template charstring exp)
5940runs on test_CT {
5941 var charstring mode := f_ts_dyn_mode_get(bts_nr, trx_nr, ts_nr);
5942 if (not match(mode, exp)) {
5943 setverdict(fail, "Unexpected TS Mode: ", mode);
Daniel Willmannafce8662018-07-06 23:11:32 +02005944 mtc.stop;
Harald Welte94e0c342018-04-07 11:33:23 +02005945 }
5946}
5947
5948private function f_ts_set_chcomb(integer bts_nr, integer trx_nr, integer ts_nr, charstring chcomb)
5949runs on test_CT {
5950 f_vty_enter_cfg_ts(BSCVTY, bts_nr, trx_nr, ts_nr);
5951 f_vty_transceive(BSCVTY, "phys_chan_config " & chcomb);
5952 f_vty_transceive(BSCVTY, "end");
5953}
5954
5955private const charstring TCHF_MODE := "TCH/F mode";
5956private const charstring TCHH_MODE := "TCH/H mode";
5957private const charstring PDCH_MODE := "PDCH mode";
5958private const charstring NONE_MODE := "NONE mode";
5959
5960/* Test IPA PDCH activation / deactivation triggered by VTY */
5961testcase TC_dyn_pdch_ipa_act_deact() runs on test_CT {
5962 var RSL_Message rsl_unused;
5963
5964 /* change Timeslot 6 before f_init() starts RSL */
5965 f_init_vty();
5966 f_ts_set_chcomb(0, 0, 6, "TCH/F_PDCH");
5967 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
5968
5969 f_init(1, false);
5970 f_sleep(1.0);
5971
5972 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(6));
5973
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02005974 log("TCH/F_PDCH pchan starts out in TCH/F mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02005975 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
5976 /* The BSC will activate the dynamic PDCH by default, so confirm that */
5977 rsl_unused := f_exp_ipa_rx(0, tr_RSL_IPA_PDCH_ACT(chan_nr));
5978 f_ipa_tx(0, ts_RSL_IPA_PDCH_ACT_ACK(chan_nr, ts_RSL_IE_FrameNumber(2342)));
5979 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02005980 log("TCH/F_PDCH pchan, PDCH ACT was ACKed, so now in PDCH mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02005981 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, PDCH_MODE);
5982
5983 /* De-activate it via VTY */
5984 f_dyn_ipa_pdch_deact(0, 0, chan_nr.tn);
5985 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02005986 log("TCH/F_PDCH pchan, PDCH DEACT via VTY, so now back in TCH/F mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02005987 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
5988
5989 /* re-activate it via VTY */
5990 f_dyn_ipa_pdch_act(0, 0, chan_nr.tn);
5991 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02005992 log("TCH/F_PDCH pchan, PDCH ACT via VTY, so now in PDCH mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02005993 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, PDCH_MODE);
5994
5995 /* and finally de-activate it again */
5996 f_dyn_ipa_pdch_deact(0, 0, chan_nr.tn);
5997 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02005998 log("TCH/F_PDCH pchan, PDCH DEACT via VTY, so now back in TCH/F mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02005999 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
6000
Neels Hofmeyr887e8f12018-06-27 01:01:55 +02006001 /* clean up config */
6002 f_ts_set_chcomb(0, 0, 6, "PDCH");
6003
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006004 f_shutdown_helper();
Harald Welte94e0c342018-04-07 11:33:23 +02006005}
6006
6007/* Test IPA PDCH activation NACK */
6008testcase TC_dyn_pdch_ipa_act_nack() runs on test_CT {
6009 var RSL_Message rsl_unused;
6010
6011 /* change Timeslot 6 before f_init() starts RSL */
6012 f_init_vty();
6013 f_ts_set_chcomb(0, 0, 6, "TCH/F_PDCH");
6014 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
6015
6016 f_init(1, false);
6017 f_sleep(1.0);
6018
6019 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(6));
6020
6021 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
6022 /* The BSC will activate the dynamic PDCH by default, so confirm that */
6023 rsl_unused := f_exp_ipa_rx(0, tr_RSL_IPA_PDCH_ACT(chan_nr));
6024 f_ipa_tx(0, ts_RSL_IPA_PDCH_ACT_ACK(chan_nr, ts_RSL_IE_FrameNumber(2342)));
6025 f_sleep(1.0);
6026 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, PDCH_MODE);
6027
6028 /* De-activate it via VTY */
6029 f_dyn_ipa_pdch_deact(0, 0, chan_nr.tn);
6030 f_sleep(1.0);
6031 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
6032
6033 /* re-activate it via VTY, but fail that; check BSC still assumes TCH/F mode */
6034 f_dyn_ipa_pdch_act(0, 0, chan_nr.tn, RSL_ERR_EQUIPMENT_FAIL);
6035 f_sleep(1.0);
6036 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
6037
Neels Hofmeyr887e8f12018-06-27 01:01:55 +02006038 /* clean up config */
6039 f_ts_set_chcomb(0, 0, 6, "PDCH");
6040
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006041 f_shutdown_helper();
Harald Welte94e0c342018-04-07 11:33:23 +02006042}
6043
6044
6045/***********************************************************************
6046 * Osmocom style dynamic PDCH
6047 ***********************************************************************/
6048
6049private function f_dyn_osmo_pdch_act(integer bts_nr, integer trx_nr, integer ts_nr,
6050 template (omit) RSL_Cause nack := omit)
6051runs on test_CT {
6052 var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(ts_nr));
6053 var RSL_Message rsl_unused;
6054 /* ask BSC via VTY to activate a given IPA style chan as PDCH */
6055 /* FIXME: no VTY command to activate Osmocom PDCH !! */
6056 /* expect the BSC to issue the related RSL command */
6057 rsl_unused := f_exp_ipa_rx(0, tr_RSL_CHAN_ACT(chan_nr, ?));
6058 if (istemplatekind(nack, "omit")) {
6059 /* respond with a related acknowledgement */
6060 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, 2342));
6061 } else {
6062 f_ipa_tx(0, ts_RSL_CHAN_ACT_NACK(chan_nr, valueof(nack)));
6063 }
6064}
6065
6066private function f_dyn_osmo_pdch_deact(integer bts_nr, integer trx_nr, integer ts_nr,
6067 template (omit) RSL_Cause nack := omit)
6068runs on test_CT {
6069 var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(ts_nr));
6070 var RSL_Message rsl_unused;
6071 /* ask BSC via VTY to activate a given IPA style chan as PDCH */
6072 /* FIXME: no VTY command to activate Osmocom PDCH !! */
6073 /* expect the BSC to issue the related RSL command */
6074 rsl_unused := f_exp_ipa_rx(0, tr_RSL_RF_CHAN_REL(chan_nr));
6075 if (istemplatekind(nack, "omit")) {
6076 /* respond with a related acknowledgement */
6077 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(chan_nr));
6078 } else {
6079 //f_ipa_tx(0, ts_RSL_RF_CHAN_REL_NACK(chan_nr, valueof(nack)));
6080 }
6081}
6082
6083/* Test Osmocom dyn PDCH activation / deactivation triggered by VTY */
6084testcase TC_dyn_pdch_osmo_act_deact() runs on test_CT {
6085 var RSL_Message rsl_unused;
6086
6087 /* change Timeslot 6 before f_init() starts RSL */
6088 f_init_vty();
6089 f_ts_set_chcomb(0, 0, 6, "TCH/F_TCH/H_PDCH");
6090 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
6091
6092 f_init(1, false);
6093 f_sleep(1.0);
6094
6095 var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(6));
6096
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02006097 log("TCH/F_TCH/H_PDCH pchan starts out in disabled mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02006098 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, NONE_MODE);
6099 /* The BSC will activate the dynamic PDCH by default, so confirm that */
6100 rsl_unused := f_exp_ipa_rx(0, tr_RSL_CHAN_ACT_PDCH(chan_nr, ?));
6101
6102 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, 2342));
6103 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02006104 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 +02006105 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, PDCH_MODE);
6106
Neels Hofmeyr887e8f12018-06-27 01:01:55 +02006107 /* clean up config */
6108 f_ts_set_chcomb(0, 0, 6, "PDCH");
6109
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006110 f_shutdown_helper();
Harald Welte94e0c342018-04-07 11:33:23 +02006111}
6112
6113/* Test Osmocom dyn PDCH activation NACK behavior */
6114testcase TC_dyn_pdch_osmo_act_nack() runs on test_CT {
6115 var RSL_Message rsl_unused;
6116
6117 /* change Timeslot 6 before f_init() starts RSL */
6118 f_init_vty();
6119 f_ts_set_chcomb(0, 0, 6, "TCH/F_TCH/H_PDCH");
6120 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
6121
6122 f_init(1, false);
6123 f_sleep(1.0);
6124
6125 var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(6));
6126
6127 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, NONE_MODE);
6128 /* The BSC will activate the dynamic PDCH by default, so confirm that */
6129 rsl_unused := f_exp_ipa_rx(0, tr_RSL_CHAN_ACT_PDCH(chan_nr, ?));
6130
6131 /* NACK this activation and expect the "show timeslot" mode still to be NONE */
6132 f_ipa_tx(0, ts_RSL_CHAN_ACT_NACK(chan_nr, RSL_ERR_EQUIPMENT_FAIL));
6133 f_sleep(1.0);
6134 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, NONE_MODE);
6135
Neels Hofmeyr887e8f12018-06-27 01:01:55 +02006136 /* clean up config */
6137 f_ts_set_chcomb(0, 0, 6, "PDCH");
6138
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006139 f_shutdown_helper();
Harald Welte94e0c342018-04-07 11:33:23 +02006140}
6141
Stefan Sperling0796a822018-10-05 13:01:39 +02006142testcase TC_chopped_ipa_ping() runs on test_CT {
Stefan Sperling554123f2018-10-09 14:12:30 +02006143 const Integers bsc_ipa_ports := {mp_bsc_rsl_port, mp_bsc_oml_port, mp_bsc_ctrl_port};
Stefan Sperling0796a822018-10-05 13:01:39 +02006144 for (var integer i := 0; i < lengthof(bsc_ipa_ports); i := i + 1) {
6145 IPA_Testing.f_run_TC_chopped_ipa_ping(mp_bsc_ip, bsc_ipa_ports[i], CONNECT_TO_SERVER);
6146 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006147 f_shutdown_helper();
Stefan Sperling0796a822018-10-05 13:01:39 +02006148}
6149
Stefan Sperlingaa1e60f2018-10-15 16:34:07 +02006150testcase TC_chopped_ipa_payload() runs on test_CT {
6151 const Integers bsc_ipa_ports := {mp_bsc_rsl_port, mp_bsc_oml_port
6152 /* TODO: mp_bsc_ctrl_port does not work yet */};
6153 for (var integer i := 0; i < lengthof(bsc_ipa_ports); i := i + 1) {
6154 IPA_Testing.f_run_TC_chopped_ipa_payload(mp_bsc_ip, bsc_ipa_ports[i], CONNECT_TO_SERVER);
6155 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006156 f_shutdown_helper();
Stefan Sperlingaa1e60f2018-10-15 16:34:07 +02006157}
6158
Pau Espin Pedrol8f773632019-11-05 11:46:53 +01006159/* Verify the BSC sends the MS Power Parameters IE during CHAN ACT to make sure
6160 the BTS does autonomous MS power control loop */
6161testcase TC_assignment_verify_ms_power_params_ie() runs on test_CT {
6162 var MSC_ConnHdlr vc_conn;
6163 var TestHdlrParams pars := f_gen_test_hdlr_pars();
6164 //pars.encr := valueof(t_EncrParams('01'O, f_rnd_octstring(8)));
6165 pars.exp_ms_power_params := true;
6166
6167 f_init(1, true);
6168 f_sleep(1.0);
6169 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5), pars);
6170 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006171 f_shutdown_helper();
Pau Espin Pedrol8f773632019-11-05 11:46:53 +01006172}
Stefan Sperlingaa1e60f2018-10-15 16:34:07 +02006173
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006174/***********************************************************************
6175 * MSC Pooling
6176 ***********************************************************************/
6177
6178function f_tmsi_nri(integer nri_v, octetstring base_tmsi := '42000023'O, integer nri_bitlen := 10) return octetstring
6179{
6180 return int2oct( oct2int(base_tmsi) + bit2int( (int2bit(nri_v, 32) << ( 24 - nri_bitlen)) ),
6181 4);
6182}
6183
6184template MobileIdentityLV ts_MI_TMSI_NRI_LV(integer nri_v, integer nri_bitlen := 10) :=
6185 ts_MI_TMSI_LV(tmsi := f_tmsi_nri(nri_v, nri_bitlen := nri_bitlen));
6186
6187private function f_perform_clear(RSL_DCHAN_PT rsl) runs on MSC_ConnHdlr {
Neels Hofmeyr767548a2020-08-09 20:26:07 +00006188 f_logp(BSCVTY, "MSC instructs BSC to clear channel");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006189 BSSAP.send(ts_BSSMAP_ClearCommand(0));
6190 interleave {
6191 [] rsl.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_RELEASE)) {
Neels Hofmeyr767548a2020-08-09 20:26:07 +00006192 f_logp(BSCVTY, "Got RSL RR Release");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006193 }
6194 [] rsl.receive(tr_RSL_DEACT_SACCH(g_chan_nr)) {
Neels Hofmeyr767548a2020-08-09 20:26:07 +00006195 f_logp(BSCVTY, "Got RSL Deact SACCH");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006196 }
6197 [] BSSAP.receive(tr_BSSMAP_ClearComplete) {
Neels Hofmeyr767548a2020-08-09 20:26:07 +00006198 f_logp(BSCVTY, "Got BSSMAP Clear Complete");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006199 /* Also drop the SCCP connection */
6200 BSSAP.send(RAN_Conn_Prim:MSC_CONN_PRIM_DISC_REQ);
6201 }
6202 [] rsl.receive(tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL)) {
Neels Hofmeyr767548a2020-08-09 20:26:07 +00006203 f_logp(BSCVTY, "Got RSL RF Chan Rel, sending Rel Ack");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006204 rsl.send(ts_RSL_RF_CHAN_REL_ACK(g_chan_nr));
6205 }
6206 }
6207}
6208
Neels Hofmeyr66e15092020-10-12 18:44:41 +00006209private function f_perform_compl_l3(RSL_DCHAN_PT rsl, template PDU_ML3_MS_NW l3_info, boolean do_clear := true, boolean expect_bssmap_l3 := true)
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006210runs on MSC_ConnHdlr {
6211 timer T := 10.0;
6212 var octetstring l3_enc := enc_PDU_ML3_MS_NW(valueof(l3_info));
6213
Neels Hofmeyr767548a2020-08-09 20:26:07 +00006214 f_logp(BSCVTY, "establish channel, send Complete Layer 3 Info");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006215 f_create_bssmap_exp(l3_enc);
6216
6217 /* RSL_Emulation.f_chan_est() on rsl:
6218 * This is basically code dup with s/RSL/rsl from:
6219 * RSL_Emulation.f_chan_est(g_pars.ra, l3_enc, g_pars.link_id, g_pars.fn);
6220 */
6221 var RSL_Message rx_rsl;
6222 var GsmRrMessage rr;
6223
6224 /* request a channel to be established */
6225 rsl.send(ts_RSLDC_ChanRqd(g_pars.ra, g_pars.fn));
6226 /* expect immediate assignment.
6227 * Code dup with s/RSL/rsl from:
6228 * rx_rsl := f_rx_or_fail(tr_RSL_IMM_ASSIGN);
6229 */
6230 timer Tt := 10.0;
6231
6232 /* request a channel to be established */
6233 Tt.start;
6234 alt {
6235 [] rsl.receive(tr_RSL_IMM_ASSIGN) -> value rx_rsl {
6236 Tt.stop;
6237 }
6238 [] rsl.receive {
6239 setverdict(fail, "Unexpected RSL message on DCHAN");
6240 mtc.stop;
6241 }
6242 [] Tt.timeout {
6243 setverdict(fail, "Timeout waiting for RSL on DCHAN");
6244 mtc.stop;
6245 }
6246 }
6247 rr := dec_GsmRrMessage(rx_rsl.ies[1].body.full_imm_ass_info.payload);
6248 g_chan_nr := rr.payload.imm_ass.chan_desc.chan_nr;
6249 rsl.send(ts_RSL_EST_IND(g_chan_nr, valueof(g_pars.link_id), l3_enc));
6250
6251
Neels Hofmeyr66e15092020-10-12 18:44:41 +00006252 if (expect_bssmap_l3) {
6253 f_logp(BSCVTY, "expect BSSAP Complete Layer 3 Info at MSC");
6254 var template PDU_BSSAP exp_l3_compl;
6255 exp_l3_compl := tr_BSSMAP_ComplL3()
6256 if (g_pars.aoip == false) {
6257 exp_l3_compl.pdu.bssmap.completeLayer3Information.codecList := omit;
6258 } else {
6259 exp_l3_compl.pdu.bssmap.completeLayer3Information.codecList := ?;
6260 }
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006261
Neels Hofmeyr66e15092020-10-12 18:44:41 +00006262 var PDU_BSSAP bssap;
6263 T.start;
6264 alt {
6265 [] BSSAP.receive(exp_l3_compl) -> value bssap {
6266 f_logp(BSCVTY, "received expected Complete Layer 3 Info at MSC");
6267 log("rx exp_l3_compl = ", bssap);
6268 }
6269 [] BSSAP.receive(tr_BSSMAP_ComplL3) {
6270 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Received non-matching COMPLETE LAYER 3 INFORMATION");
6271 }
6272 [] T.timeout {
6273 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for COMPLETE LAYER 3 INFORMATION");
6274 }
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006275 }
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006276
Neels Hofmeyr66e15092020-10-12 18:44:41 +00006277 /* start ciphering, if requested */
6278 if (ispresent(g_pars.encr)) {
6279 f_logp(BSCVTY, "start ciphering");
6280 f_cipher_mode(g_pars.encr.enc_alg, g_pars.encr.enc_key);
6281 }
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006282 }
6283
6284 if (do_clear) {
6285 f_perform_clear(rsl);
6286 }
6287 setverdict(pass);
6288 f_sleep(1.0);
6289}
6290
6291private function f_tc_mscpool_compl_l3(charstring id) runs on MSC_ConnHdlr {
6292 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
6293 if (g_pars.mscpool.rsl_idx == 0) {
6294 f_perform_compl_l3(RSL, g_pars.mscpool.l3_info);
6295 } else if (g_pars.mscpool.rsl_idx == 1) {
6296 f_perform_compl_l3(RSL1, g_pars.mscpool.l3_info);
6297 } else if (g_pars.mscpool.rsl_idx == 2) {
6298 f_perform_compl_l3(RSL2, g_pars.mscpool.l3_info);
6299 }
6300}
6301
6302/* Various Complete Layer 3 by IMSI all end up with the first MSC, because the other MSCs are not connected. */
6303private function f_tc_mscpool_L3Compl_on_1_msc(charstring id) runs on MSC_ConnHdlr {
6304 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
6305 f_perform_compl_l3(RSL, ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_IMSI_LV('001010000000001'H)), '00F110'O) );
6306 f_perform_compl_l3(RSL, ts_CM_SERV_REQ(CM_TYPE_MO_SMS, valueof(ts_MI_IMSI_LV('001010000000002'H))) );
6307 f_perform_compl_l3(RSL, ts_PAG_RESP(valueof(ts_MI_IMSI_LV('001010000000003'H))) );
6308 f_perform_compl_l3(RSL, ts_ML3_MO_MM_IMSI_DET_Ind(valueof(ts_MI_IMSI_LV('001010000000004'H))) );
6309}
6310testcase TC_mscpool_L3Compl_on_1_msc() runs on test_CT {
6311
6312 f_init(1, true);
6313 f_sleep(1.0);
6314 var MSC_ConnHdlr vc_conn;
6315 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006316
6317 f_ctrs_msc_init();
6318
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006319 vc_conn := f_start_handler(refers(f_tc_mscpool_L3Compl_on_1_msc), pars);
6320 vc_conn.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006321
6322 f_ctrs_msc_expect(0, "mscpool:subscr:new", 4);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006323 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006324}
6325
6326/* Three Layer 3 Complete by IMSI are round-robin'ed across two connected MSCs */
6327/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
6328 * just as well using only RSL. */
6329testcase TC_mscpool_L3Complete_by_imsi_round_robin() runs on test_CT {
6330
6331 f_init(nr_bts := 3, handler_mode := true, nr_msc := 2);
6332 f_sleep(1.0);
6333
6334 /* Control which MSC gets chosen next by the round-robin, otherwise
6335 * would be randomly affected by which other tests ran before this. */
6336 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
6337
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006338 f_ctrs_msc_init();
6339
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006340 var MSC_ConnHdlr vc_conn1;
6341 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
6342 pars1.mscpool.rsl_idx := 0;
6343 pars1.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_IMSI_LV('001010000000001'H)), '00F110'O));
6344 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6345 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006346 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006347
6348 var MSC_ConnHdlr vc_conn2;
6349 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 1);
6350 pars2.mscpool.rsl_idx := 1;
6351 pars2.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, valueof(ts_MI_IMSI_LV('001010000000002'H))));
6352 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6353 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006354 f_ctrs_msc_expect(1, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006355
6356 /* Test round-robin wrap to the first MSC */
6357 var MSC_ConnHdlr vc_conn3;
6358 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 0);
6359 pars3.mscpool.rsl_idx := 2;
6360 pars3.mscpool.l3_info := valueof(ts_PAG_RESP(valueof(ts_MI_IMSI_LV('001010000000003'H))));
6361 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
6362 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006363 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006364 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006365}
6366
6367/* Three LU by TMSI are round-robin'ed across two connected MSCs, because they contain the NULL-NRI 0
6368 * (configured in osmo-bsc.cfg). */
6369/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
6370 * just as well using only RSL. */
6371testcase TC_mscpool_LU_by_tmsi_null_nri_0_round_robin() runs on test_CT {
6372
6373 f_init(nr_bts := 3, handler_mode := true, nr_msc := 2);
6374 f_sleep(1.0);
6375
6376 /* Control which MSC gets chosen next by the round-robin, otherwise
6377 * would be randomly affected by which other tests ran before this. */
6378 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
6379
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006380 f_ctrs_msc_init();
6381
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006382 var MSC_ConnHdlr vc_conn1;
6383 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
6384 pars1.mscpool.rsl_idx := 0;
6385 pars1.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(0)), '00F110'O));
6386 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6387 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006388 f_ctrs_msc_expect(0, "mscpool:subscr:reattach");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006389
6390 var MSC_ConnHdlr vc_conn2;
6391 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 1);
6392 pars2.mscpool.rsl_idx := 1;
6393 pars2.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(0)), '00F110'O));
6394 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6395 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006396 f_ctrs_msc_expect(1, "mscpool:subscr:reattach");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006397
6398 /* Test round-robin wrap to the first MSC */
6399 var MSC_ConnHdlr vc_conn3;
6400 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 0);
6401 pars3.mscpool.rsl_idx := 2;
6402 pars3.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(0)), '00F110'O));
6403 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
6404 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006405 f_ctrs_msc_expect(0, "mscpool:subscr:reattach");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006406 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006407}
6408
6409/* Three LU by TMSI are round-robin'ed across two connected MSCs, because they contain the NULL-NRI 1
6410 * (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
6411 * NULL-NRI setting is stronger than that. */
6412/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
6413 * just as well using only RSL. */
6414testcase TC_mscpool_LU_by_tmsi_null_nri_1_round_robin() runs on test_CT {
6415
6416 f_init(nr_bts := 3, handler_mode := true, nr_msc := 2);
6417 f_sleep(1.0);
6418
6419 /* Control which MSC gets chosen next by the round-robin, otherwise
6420 * would be randomly affected by which other tests ran before this. */
6421 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
6422
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006423 f_ctrs_msc_init();
6424
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006425 var MSC_ConnHdlr vc_conn1;
6426 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
6427 pars1.mscpool.rsl_idx := 0;
6428 pars1.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(1)), '00F110'O));
6429 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6430 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006431 f_ctrs_msc_expect(0, "mscpool:subscr:reattach");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006432
6433 var MSC_ConnHdlr vc_conn2;
6434 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 1);
6435 pars2.mscpool.rsl_idx := 1;
6436 pars2.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(1)), '00F110'O));
6437 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6438 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006439 f_ctrs_msc_expect(1, "mscpool:subscr:reattach");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006440
6441 /* Test round-robin wrap to the first MSC */
6442 var MSC_ConnHdlr vc_conn3;
6443 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 0);
6444 pars3.mscpool.rsl_idx := 2;
6445 pars3.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(1)), '00F110'O));
6446 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
6447 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006448 f_ctrs_msc_expect(0, "mscpool:subscr:reattach");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006449 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006450}
6451
6452/* Three Layer 3 Complete by TMSI are round-robin'ed across two connected MSCs, because they contain an NRI not
6453 * assigned to any MSC (configured in osmo-bsc.cfg). */
6454/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
6455 * just as well using only RSL. */
6456testcase TC_mscpool_L3Complete_by_tmsi_unassigned_nri_round_robin() runs on test_CT {
6457
6458 f_init(nr_bts := 3, handler_mode := true, nr_msc := 2);
6459 f_sleep(1.0);
6460
6461 /* Control which MSC gets chosen next by the round-robin, otherwise
6462 * would be randomly affected by which other tests ran before this. */
6463 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
6464
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006465 f_ctrs_msc_init();
6466
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006467 var MSC_ConnHdlr vc_conn1;
6468 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
6469 pars1.mscpool.rsl_idx := 0;
6470 /* An NRI that is not assigned to any MSC */
6471 pars1.mscpool.l3_info := valueof(ts_ML3_MO_MM_IMSI_DET_Ind(valueof(ts_MI_TMSI_NRI_LV(1023))));
6472 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6473 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006474 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006475
6476 var MSC_ConnHdlr vc_conn2;
6477 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 1);
6478 pars2.mscpool.rsl_idx := 1;
6479 /* An NRI that is not assigned to any MSC */
6480 pars2.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(768)), '00F110'O));
6481 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6482 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006483 f_ctrs_msc_expect(1, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006484
6485 /* Test round-robin wrap to the first MSC */
6486 var MSC_ConnHdlr vc_conn3;
6487 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 0);
6488 pars3.mscpool.rsl_idx := 2;
6489 /* An NRI that is not assigned to any MSC */
6490 pars3.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_SS_ACT, valueof(ts_MI_TMSI_NRI_LV(819))));
6491 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
6492 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006493 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006494 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006495}
6496
6497/* Three Layer 3 Complete by TMSI are round-robin'ed across two connected MSCs, because they contain an NRI
6498 * assigned to an MSC that is currently not connected (configured in osmo-bsc.cfg). */
6499/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
6500 * just as well using only RSL. */
6501testcase TC_mscpool_L3Complete_by_tmsi_valid_nri_msc_not_connected_round_robin() runs on test_CT {
6502
6503 f_init(nr_bts := 3, handler_mode := true, nr_msc := 2);
6504 f_sleep(1.0);
6505
6506 /* Control which MSC gets chosen next by the round-robin, otherwise
6507 * would be randomly affected by which other tests ran before this. */
6508 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
6509
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006510 f_ctrs_msc_init();
6511
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006512 var MSC_ConnHdlr vc_conn1;
6513 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
6514 pars1.mscpool.rsl_idx := 0;
6515 /* An NRI that is assigned to an unconnected MSC */
6516 pars1.mscpool.l3_info := valueof(ts_PAG_RESP(valueof(ts_MI_TMSI_NRI_LV(512))));
6517 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6518 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006519 f_ctrs_msc_add(2, "mscpool:subscr:attach_lost");
6520 f_ctrs_msc_add(0, "mscpool:subscr:new");
6521 f_ctrs_msc_verify();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006522
6523 var MSC_ConnHdlr vc_conn2;
6524 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 1);
6525 pars2.mscpool.rsl_idx := 1;
6526 /* An NRI that is assigned to an unconnected MSC */
6527 pars2.mscpool.l3_info := valueof(ts_ML3_MO_MM_IMSI_DET_Ind(valueof(ts_MI_TMSI_NRI_LV(767))));
6528 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6529 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006530 f_ctrs_msc_add(2, "mscpool:subscr:attach_lost");
6531 f_ctrs_msc_add(1, "mscpool:subscr:new");
6532 f_ctrs_msc_verify();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006533
6534 /* Test round-robin wrap to the first MSC */
6535 var MSC_ConnHdlr vc_conn3;
6536 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 0);
6537 pars3.mscpool.rsl_idx := 2;
6538 /* An NRI that is assigned to an unconnected MSC */
6539 pars3.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(750)), '00F110'O));
6540 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
6541 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006542 f_ctrs_msc_add(2, "mscpool:subscr:attach_lost");
6543 f_ctrs_msc_add(0, "mscpool:subscr:new");
6544 f_ctrs_msc_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006545 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006546}
6547
6548/* Three Layer 3 Complete by TMSI with valid NRI for the second MSC are all directed to the second MSC (configured in
6549 * osmo-bsc.cfg). */
6550/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
6551 * just as well using only RSL. */
6552testcase TC_mscpool_L3Complete_by_tmsi_valid_nri_1() runs on test_CT {
6553
6554 f_init(nr_bts := 3, handler_mode := true, nr_msc := 2);
6555 f_sleep(1.0);
6556
6557 /* All TMSIs in this test point at the second MSC, set the round robin to point at the first MSC to make sure
6558 * this is not using round-robin. */
6559 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
6560
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006561 f_ctrs_msc_init();
6562
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006563 var MSC_ConnHdlr vc_conn1;
6564 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 1);
6565 pars1.mscpool.rsl_idx := 0;
6566 /* An NRI of the second MSC's range (256-511) */
6567 pars1.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_SMS, valueof(ts_MI_TMSI_NRI_LV(256))));
6568 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6569 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006570 f_ctrs_msc_expect(1, "mscpool:subscr:known");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006571
6572 var MSC_ConnHdlr vc_conn2;
6573 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 1);
6574 pars2.mscpool.rsl_idx := 1;
6575 /* An NRI of the second MSC's range (256-511) */
6576 pars2.mscpool.l3_info := valueof(ts_PAG_RESP(valueof(ts_MI_TMSI_NRI_LV(260))));
6577 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6578 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006579 f_ctrs_msc_expect(1, "mscpool:subscr:known");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006580
6581 var MSC_ConnHdlr vc_conn3;
6582 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 1);
6583 pars3.mscpool.rsl_idx := 2;
6584 /* An NRI of the second MSC's range (256-511) */
6585 pars3.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(511)), '00F110'O));
6586 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
6587 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006588 f_ctrs_msc_expect(1, "mscpool:subscr:known");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006589 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006590}
6591
6592/* Layer 3 Complete by TMSI with valid NRI for the third MSC are directed to the third MSC (configured in osmo-bsc.cfg),
6593 * while a round-robin remains unaffected by that. */
6594/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
6595 * just as well using only RSL. */
6596testcase TC_mscpool_L3Complete_by_tmsi_valid_nri_2() runs on test_CT {
6597
6598 f_init(nr_bts := 3, handler_mode := true, nr_msc := 3);
6599 f_sleep(1.0);
6600
6601 /* All TMSIs in this test point at the third MSC, set the round robin to point at the second MSC to make sure
6602 * this is not using round-robin. */
6603 f_vty_transceive(BSCVTY, "mscpool roundrobin next 1");
6604
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006605 f_ctrs_msc_init();
6606
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006607 var MSC_ConnHdlr vc_conn1;
6608 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 2);
6609 pars1.mscpool.rsl_idx := 0;
6610 /* An NRI of the third MSC's range (512-767) */
6611 pars1.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_SMS, valueof(ts_MI_TMSI_NRI_LV(512))));
6612 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6613 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006614 f_ctrs_msc_expect(2, "mscpool:subscr:known");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006615
6616 var MSC_ConnHdlr vc_conn2;
6617 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 2);
6618 pars2.mscpool.rsl_idx := 1;
6619 /* An NRI of the third MSC's range (512-767) */
6620 pars2.mscpool.l3_info := valueof(ts_PAG_RESP(valueof(ts_MI_TMSI_NRI_LV(678))));
6621 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6622 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006623 f_ctrs_msc_expect(2, "mscpool:subscr:known");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006624
6625 /* The above forwardings to third MSC have not affected the round robin, which still points at the second MSC */
6626 var MSC_ConnHdlr vc_conn3;
6627 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 1);
6628 pars3.mscpool.rsl_idx := 2;
6629 pars3.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_IMSI_LV('001010000000013'H)), '00F110'O));
6630 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
6631 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006632 f_ctrs_msc_expect(1, "mscpool:subscr:new");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006633 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006634}
6635
6636/* LU with a TMSI but indicating a different PLMN in its previous LAI: ignore the NRI. */
6637/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
6638 * just as well using only RSL. */
6639testcase TC_mscpool_LU_by_tmsi_from_other_PLMN() runs on test_CT {
6640
6641 f_init(nr_bts := 3, handler_mode := true, nr_msc := 3);
6642 f_sleep(1.0);
6643
6644 /* The TMSIs in this test points at the second MSC, but since it is from a different PLMN, round-robin is used
6645 * instead, and hits msc 0. */
6646 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
6647
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006648 f_ctrs_msc_init();
6649
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006650 /* An NRI of the second MSC's range (256-511), but a PLMN that doesn't match with osmo-bsc.cfg */
6651 var MSC_ConnHdlr vc_conn1;
6652 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
6653 pars1.mscpool.rsl_idx := 0;
6654 pars1.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(260)), '99F999'O));
6655 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6656 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006657 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006658
6659 /* An NRI of the third MSC's range (512-767) and a matching PLMN gets directed by NRI. */
6660 var MSC_ConnHdlr vc_conn2;
6661 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 2);
6662 pars2.mscpool.rsl_idx := 1;
6663 pars2.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(555)), '00F110'O));
6664 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6665 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006666 f_ctrs_msc_expect(2, "mscpool:subscr:known");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006667 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006668}
6669
6670/* Make sure that whichever MSC paged a subscriber will also get the Paging Response. Page by IMSI, which would be
6671 * round-robined to another MSC, to make sure the Paging->Response relation is stronger than the NRI->MSC mapping. */
6672private function f_tc_mscpool_paging_imsi(charstring id) runs on MSC_ConnHdlr {
6673 var template BSSMAP_FIELD_CellIdentificationList cid_list := { cIl_CI := { ts_BSSMAP_CI_CI(0) } };
6674 //cid_list := { cIl_allInBSS := ''O };
6675 var RSL_ChanNeeded rsl_chneed := RSL_CHANNEED_SDCCH;
6676 var template BSSMAP_IE_ChannelNeeded bssmap_chneed := ts_BSSMAP_IE_ChanNeeded(int2bit(enum2int(valueof(rsl_chneed)),2));
6677 var BSSAP_N_UNITDATA_req paging;
6678 var hexstring imsi := '001010000000123'H;
6679
6680 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
6681
Neels Hofmeyr90f80962020-06-12 16:16:55 +02006682 paging := valueof(ts_BSSAP_UNITDATA_req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006683 valueof(ts_BSSMAP_Paging(imsi, cid_list, omit, bssmap_chneed))));
6684 BSSAP.send(paging);
6685
6686 /* Register any RSL conn so that the Paging Command gets received here. With the current RSL_Emulation's main()
6687 * handling of '[bts_role] IPA_PT.receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD()))' it doesn't matter at all which
6688 * channel number is picked here. */
6689 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(0, RSL_CHAN_NR_INVALID));
6690 f_rslem_register(0, new_chan_nr);
6691 RSL.receive(tr_RSL_PAGING_CMD(tr_MI_IMSI(imsi)));
6692 f_rslem_unregister(0, new_chan_nr);
6693
6694 /* Despite the round robin pointing at the second MSC ('roundrobin next 1'), the earlier Paging for the same IMSI
6695 * causes this Paging Response to go to the first MSC (bssap_idx := 0). */
6696 f_perform_compl_l3(RSL, ts_PAG_RESP(valueof(ts_MI_IMSI_LV(imsi))) );
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006697 f_sleep(1.0);
6698}
6699testcase TC_mscpool_paging_and_response_imsi() runs on test_CT {
6700 f_init(nr_bts := 1, handler_mode := true, nr_msc := 3);
6701 f_sleep(1.0);
6702
6703 /* Testing a Paging on the first MSC to get a Paging Response back to the first MSC. Set round robin to the
6704 * second MSC to make sure we're getting the Paging logic, not a coincidental round robin match. */
6705 f_vty_transceive(BSCVTY, "mscpool roundrobin next 1");
6706
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006707 f_ctrs_msc_init();
6708
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006709 var MSC_ConnHdlr vc_conn1;
6710 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
6711 pars1.mscpool.rsl_idx := 0;
Neels Hofmeyr90f80962020-06-12 16:16:55 +02006712 pars1.sccp_addr_bsc := g_bssap[pars1.mscpool.bssap_idx].sccp_addr_peer;
6713 pars1.sccp_addr_msc := g_bssap[pars1.mscpool.bssap_idx].sccp_addr_own;
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006714 vc_conn1 := f_start_handler(refers(f_tc_mscpool_paging_imsi), pars1);
6715 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006716 f_ctrs_msc_expect(0, "mscpool:subscr:paged");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006717 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006718}
6719
6720/* Make sure that whichever MSC paged a subscriber will also get the Paging Response. Page by TMSI with an NRI value
6721 * that matches a different MSC, to make sure the Paging->Response relation is stronger than the NRI->MSC mapping. */
6722private function f_tc_mscpool_paging_tmsi(charstring id) runs on MSC_ConnHdlr {
6723 var template BSSMAP_FIELD_CellIdentificationList cid_list := { cIl_CI := { ts_BSSMAP_CI_CI(0) } };
6724 //cid_list := { cIl_allInBSS := ''O };
6725 var RSL_ChanNeeded rsl_chneed := RSL_CHANNEED_SDCCH;
6726 var template BSSMAP_IE_ChannelNeeded bssmap_chneed := ts_BSSMAP_IE_ChanNeeded(int2bit(enum2int(valueof(rsl_chneed)),2));
6727 var integer nri_v := 300; /* <-- second MSC's NRI */
6728 var octetstring tmsi := f_tmsi_nri(nri_v);
6729 var BSSAP_N_UNITDATA_req paging;
6730
6731 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
6732
Neels Hofmeyr90f80962020-06-12 16:16:55 +02006733 paging := valueof(ts_BSSAP_UNITDATA_req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006734 valueof(ts_BSSMAP_Paging('001010000000011'H, cid_list, tmsi, bssmap_chneed))));
6735 BSSAP.send(paging);
6736
6737 /* Register any RSL conn so that the Paging Command gets received here. With the current RSL_Emulation's main()
6738 * handling of '[bts_role] IPA_PT.receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD()))' it doesn't matter at all which
6739 * channel number is picked here. */
6740 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(0, RSL_CHAN_NR_INVALID));
6741 f_rslem_register(0, new_chan_nr);
6742 RSL.receive(tr_RSL_PAGING_CMD(t_MI_TMSI(tmsi)));
6743 f_rslem_unregister(0, new_chan_nr);
6744
6745 /* Despite the NRI matching the second MSC (NRI from 'msc 1' in osmo-bsc.cfg) and round robin pointing at the
6746 * third MSC ('roundrobin next 2'), the earlier Paging for the same TMSI causes this Paging Response to go to
6747 * the first MSC (bssap_idx := 0). */
6748 f_perform_compl_l3(RSL, ts_PAG_RESP(valueof(ts_MI_TMSI_NRI_LV(nri_v))) );
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006749 f_sleep(1.0);
6750}
6751testcase TC_mscpool_paging_and_response_tmsi() runs on test_CT {
6752 f_init(nr_bts := 1, handler_mode := true, nr_msc := 3);
6753 f_sleep(1.0);
6754
6755 /* Testing a Paging on the first MSC to get a Paging Response back to the first MSC. Set round robin to the
6756 * third MSC to make sure we're getting the Paging logic, not a coincidental round robin match. */
6757 f_vty_transceive(BSCVTY, "mscpool roundrobin next 2");
6758
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006759 f_ctrs_msc_init();
6760
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006761 var MSC_ConnHdlr vc_conn1;
6762 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
6763 pars1.mscpool.rsl_idx := 0;
Neels Hofmeyr90f80962020-06-12 16:16:55 +02006764 pars1.sccp_addr_bsc := g_bssap[pars1.mscpool.bssap_idx].sccp_addr_peer;
6765 pars1.sccp_addr_msc := g_bssap[pars1.mscpool.bssap_idx].sccp_addr_own;
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006766 vc_conn1 := f_start_handler(refers(f_tc_mscpool_paging_tmsi), pars1);
6767 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006768 f_ctrs_msc_expect(0, "mscpool:subscr:paged");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006769 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006770}
6771
6772/* For round-robin, skip an MSC that has 'no allow-attach' set. */
6773/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
6774 * just as well using only RSL. */
6775testcase TC_mscpool_no_allow_attach_round_robin() runs on test_CT {
6776
6777 f_init(nr_bts := 3, handler_mode := true, nr_msc := 3);
6778 f_sleep(1.0);
Neels Hofmeyra460f1f2020-08-09 20:17:03 +00006779 /* Mark the second MSC as offloading, round-robin should skip this MSC now. */
6780 f_vty_msc_allow_attach(BSCVTY, {true, false, true});
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006781
6782 /* Control which MSC gets chosen next by the round-robin, otherwise
6783 * would be randomly affected by which other tests ran before this. */
6784 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
6785
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006786 f_ctrs_msc_init();
6787
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006788 var MSC_ConnHdlr vc_conn1;
6789 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
6790 pars1.mscpool.rsl_idx := 0;
6791 pars1.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_IMSI_LV('001010000000001'H)), '00F110'O));
6792 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6793 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006794 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006795
6796 var MSC_ConnHdlr vc_conn2;
6797 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 2);
6798 pars2.mscpool.rsl_idx := 1;
6799 pars2.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, valueof(ts_MI_IMSI_LV('001010000000002'H))));
6800 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6801 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006802 f_ctrs_msc_expect(2, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006803
6804 var MSC_ConnHdlr vc_conn3;
6805 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 0);
6806 pars3.mscpool.rsl_idx := 2;
6807 pars3.mscpool.l3_info := valueof(ts_PAG_RESP(valueof(ts_MI_IMSI_LV('001010000000003'H))));
6808 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
6809 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006810 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006811 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006812}
6813
6814/* An MSC that has 'no allow-attach' set should still serve subscribers that are already attached according to their
6815 * TMSI NRI. */
6816testcase TC_mscpool_no_allow_attach_valid_nri() runs on test_CT {
6817
6818 f_init(nr_bts := 3, handler_mode := true, nr_msc := 3);
6819 f_sleep(1.0);
6820
Neels Hofmeyra460f1f2020-08-09 20:17:03 +00006821 /* Mark the second MSC as offloading, round-robin should skip this MSC now. */
6822 f_vty_msc_allow_attach(BSCVTY, {true, false, true});
6823
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006824 /* Control which MSC gets chosen next by the round-robin, otherwise
6825 * would be randomly affected by which other tests ran before this. */
6826 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
6827
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006828 f_ctrs_msc_init();
6829
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006830 /* Round robin points at msc 0, but the valid NRI directs to msc 1, even though msc 1 has 'no allow-attach'. */
6831 var MSC_ConnHdlr vc_conn1;
6832 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 1);
6833 pars1.mscpool.rsl_idx := 0;
6834 /* An NRI of the second MSC's range (256-511) */
6835 pars1.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, valueof(ts_MI_TMSI_NRI_LV(260))));
6836 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6837 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006838 f_ctrs_msc_expect(1, "mscpool:subscr:known");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006839
6840 var MSC_ConnHdlr vc_conn2;
6841 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 0);
6842 pars2.mscpool.rsl_idx := 1;
6843 pars2.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, valueof(ts_MI_IMSI_LV('001010000000002'H))));
6844 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6845 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006846 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006847
6848 var MSC_ConnHdlr vc_conn3;
6849 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 2);
6850 pars3.mscpool.rsl_idx := 2;
6851 pars3.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, valueof(ts_MI_IMSI_LV('001010000000003'H))));
6852 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
6853 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006854 f_ctrs_msc_expect(2, "mscpool:subscr:new");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006855 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006856}
6857
Philipp Maier783681c2020-07-16 16:47:06 +02006858/* Allow/Deny emergency calls globally via VTY */
6859private function f_vty_allow_emerg_msc(boolean allow) runs on test_CT {
6860 f_vty_enter_cfg_msc(BSCVTY, 0);
6861 if (allow) {
6862 f_vty_transceive(BSCVTY, "allow-emergency allow");
6863 } else {
6864 f_vty_transceive(BSCVTY, "allow-emergency deny");
6865 }
6866 f_vty_transceive(BSCVTY, "exit");
6867 f_vty_transceive(BSCVTY, "exit");
6868}
6869
6870/* Allow/Deny emergency calls per BTS via VTY */
6871private function f_vty_allow_emerg_bts(boolean allow, integer bts_nr) runs on test_CT {
6872 f_vty_enter_cfg_bts(BSCVTY, bts_nr);
6873 if (allow) {
6874 f_vty_transceive(BSCVTY, "rach emergency call allowed 1");
6875 } else {
6876 f_vty_transceive(BSCVTY, "rach emergency call allowed 0");
6877 }
6878 f_vty_transceive(BSCVTY, "exit");
6879 f_vty_transceive(BSCVTY, "exit");
Neels Hofmeyrb6ed80c2020-10-12 22:52:39 +00006880 f_vty_transceive(BSCVTY, "exit");
Philipp Maier783681c2020-07-16 16:47:06 +02006881}
6882
6883/* Begin assignmet procedure and send an EMERGENCY SETUP (RR) */
6884private function f_assignment_emerg_setup() runs on MSC_ConnHdlr {
6885 var PDU_ML3_MS_NW emerg_setup;
6886 var octetstring emerg_setup_enc;
6887 var RSL_Message emerg_setup_data_ind;
6888
6889 f_establish_fully(omit, omit);
6890
6891 emerg_setup := valueof(ts_ML3_MO_CC_EMERG_SETUP(1, valueof(ts_Bcap_voice)));
6892 emerg_setup_enc := enc_PDU_ML3_MS_NW(emerg_setup);
6893 emerg_setup_data_ind := valueof(ts_RSL_DATA_IND(g_chan_nr, valueof(ts_RslLinkID_DCCH(0)), emerg_setup_enc));
6894
6895 RSL.send(emerg_setup_data_ind);
6896}
6897
6898/* Test if the EMERGENCY SETUP gets passed on to the MSC via A when EMERGENCY
6899 * CALLS are permitted by the BSC config. */
6900private function f_TC_assignment_emerg_setup_allow(charstring id) runs on MSC_ConnHdlr {
6901 var PDU_BSSAP emerg_setup_data_ind_bssap;
6902 var PDU_ML3_MS_NW emerg_setup;
6903 timer T := 3.0;
6904
6905 f_assignment_emerg_setup()
6906
6907 T.start;
6908 alt {
6909 [] BSSAP.receive(tr_BSSAP_DTAP) -> value emerg_setup_data_ind_bssap {
6910 emerg_setup := dec_PDU_ML3_MS_NW(emerg_setup_data_ind_bssap.pdu.dtap);
6911 if (not isbound(emerg_setup.msgs.cc.emergencySetup)) {
6912 setverdict(fail, "no emergency setup");
6913 }
6914 }
6915 [] BSSAP.receive {
6916 setverdict(fail, "unexpected BSSAP message!");
6917 }
6918 [] T.timeout {
6919 setverdict(fail, "timout waiting for EMERGENCY SETUP!");
6920 }
6921 }
6922
6923 setverdict(pass);
6924}
6925
6926/* Test if the EMERGENCY SETUP gets blocked by the BSC if EMERGENCY CALLS are
6927 * forbidden by the BSC config. */
6928private function f_TC_assignment_emerg_setup_deny(charstring id) runs on MSC_ConnHdlr {
6929 var PDU_BSSAP emerg_setup_data_ind_bssap;
6930 timer T := 3.0;
6931
6932 f_assignment_emerg_setup()
6933
6934 T.start;
6935 alt {
6936 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_RELEASE)) {
6937 setverdict(pass);
6938 }
6939 [] RSL.receive {
6940 setverdict(fail, "unexpected RSL message!");
6941 }
6942 [] T.timeout {
6943 setverdict(fail, "timout waiting for RR CHANNEL RELEASE!");
6944 }
6945 }
6946}
6947
6948/* EMERGENCY CALL situation #1, allowed globally and by BTS */
6949testcase TC_assignment_emerg_setup_allow() runs on test_CT {
6950 var TestHdlrParams pars := f_gen_test_hdlr_pars();
6951 var MSC_ConnHdlr vc_conn;
6952
6953 f_init(1, true);
6954 f_sleep(1.0);
6955
6956 f_vty_allow_emerg_msc(true);
6957 f_vty_allow_emerg_bts(true, 0);
6958 vc_conn := f_start_handler(refers(f_TC_assignment_emerg_setup_allow), pars);
6959 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006960 f_shutdown_helper();
Philipp Maier783681c2020-07-16 16:47:06 +02006961}
6962
6963/* EMERGENCY CALL situation #2, forbidden globally but allowed by BTS */
6964testcase TC_assignment_emerg_setup_deny_msc() runs on test_CT {
6965 var TestHdlrParams pars := f_gen_test_hdlr_pars();
6966 var MSC_ConnHdlr vc_conn;
6967
6968 f_init(1, true);
6969 f_sleep(1.0);
6970
6971 f_vty_allow_emerg_msc(false);
6972 f_vty_allow_emerg_bts(true, 0);
6973 vc_conn := f_start_handler(refers(f_TC_assignment_emerg_setup_deny), pars);
6974 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006975 f_shutdown_helper();
Philipp Maier783681c2020-07-16 16:47:06 +02006976}
6977
6978/* EMERGENCY CALL situation #3, allowed globally but forbidden by BTS */
6979testcase TC_assignment_emerg_setup_deny_bts() runs on test_CT {
6980 var TestHdlrParams pars := f_gen_test_hdlr_pars();
6981 var MSC_ConnHdlr vc_conn;
6982
6983 /* Note: This simulates a spec violation by the MS, correct MS
6984 * implementations would not try to establish an emergency call because
6985 * the system information tells in advance that emergency calls are
6986 * not forbidden */
6987
6988 f_init(1, true);
6989 f_sleep(1.0);
6990
6991 f_vty_allow_emerg_msc(true);
6992 f_vty_allow_emerg_bts(false, 0);
6993 vc_conn := f_start_handler(refers(f_TC_assignment_emerg_setup_deny), pars);
6994 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006995 f_shutdown_helper();
Philipp Maier783681c2020-07-16 16:47:06 +02006996}
6997
Philipp Maier82812002020-08-13 18:48:27 +02006998/* Test what happens when an emergency call arrives while all TCH channels are
6999 * busy, the BSC is expected to terminate one call in favor of the incoming
7000 * emergency call */
7001testcase TC_emerg_premption() runs on test_CT {
7002 var ASP_RSL_Unitdata rsl_ud;
7003 var integer i;
7004 var integer chreq_total, chreq_nochan;
7005 var RSL_Message rx_rsl;
7006 var RslChannelNr chan_nr;
7007
7008 f_init(1);
7009 f_sleep(1.0);
7010
7011 f_vty_allow_emerg_msc(true);
7012 f_vty_allow_emerg_bts(true, 0);
7013
7014 /* Fill up all channels on the BTS */
7015 chreq_total := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total");
7016 chreq_nochan := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:no_channel");
7017 for (i := 0; i < NUM_TCHF_PER_BTS + NUM_TCHH_PER_BTS + NUM_SDCCH_PER_BTS; i := i+1) {
7018 chan_nr := f_chreq_act_ack('33'O, i);
7019 }
7020 IPA_RSL[0].clear;
7021 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total",
7022 chreq_total + NUM_TCHF_PER_BTS + NUM_TCHH_PER_BTS + NUM_SDCCH_PER_BTS);
7023
7024 /* Send Channel request for emegergency call */
7025 f_ipa_tx(0, ts_RSL_CHAN_RQD('A5'O, 23));
7026
7027 /* Expect the BSC to release one (the first) TCH/F on the BTS */
7028 chan_nr := valueof(t_RslChanNr_Bm(1));
7029 f_expect_chan_rel(0, chan_nr, expect_rr_chan_rel := false, expect_rll_rel_req := false);
7030
7031 /* Expect the BSC to send activate/assign the a channel for the emergency call */
7032 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
7033 chan_nr := rx_rsl.ies[0].body.chan_nr;
7034 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, 33));
7035 rx_rsl := f_exp_ipa_rx(0, tr_RSL_IMM_ASSIGN(0));
Philipp Maier104f4c02020-09-11 18:12:18 +02007036
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007037 f_shutdown_helper();
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007038}
7039
7040/* Hopping parameters per a timeslot */
Vadim Yanitskiybc6654a2020-09-13 01:27:40 +07007041private type record length(0..64) of GsmArfcn ArfcnList;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007042private type record FHParamsTs {
7043 boolean enabled,
7044 uint6_t hsn,
7045 uint6_t maio,
7046 ArfcnList ma
7047};
7048
7049/* Hopping parameters per a transceiver */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007050private type record FHParamsTrx {
7051 GsmArfcn arfcn,
7052 FHParamsTs ts[8]
7053};
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007054
7055/* Randomly generate the hopping parameters for the given timeslot numbers */
7056private function f_TC_fh_params_gen(template integer tr_tn := (1, 3, 5))
7057runs on test_CT return FHParamsTrx {
7058 var FHParamsTrx fhp;
7059
Vadim Yanitskiy3e997362020-09-05 21:08:34 +07007060 /* Generate a random ARFCN, including ARFCN 0 */
7061 fhp.arfcn := f_rnd_int(3);
Vadim Yanitskiye7c8c6e2020-09-13 14:33:03 +07007062
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007063 for (var integer tn := 0; tn < 8; tn := tn + 1) {
7064 if (not match(tn, tr_tn)) {
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007065 fhp.ts[tn].enabled := false;
7066 fhp.ts[tn].ma := { };
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007067 continue;
7068 }
7069
7070 /* Random HSN / MAIO values: 0..63 */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007071 fhp.ts[tn].hsn := f_rnd_int(64);
7072 fhp.ts[tn].maio := f_rnd_int(64);
7073 fhp.ts[tn].ma := { };
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007074
7075 /* Random Mobile Allocation (hopping channels) */
7076 var integer ma_len := 2 + f_rnd_int(9); /* 2..10 channels */
7077 var integer step := 3 + f_rnd_int(4); /* 3..6 stepping */
7078 for (var integer i := 1; i <= ma_len; i := i + 1) {
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007079 fhp.ts[tn].ma := fhp.ts[tn].ma & { i * step };
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007080 }
7081
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007082 fhp.ts[tn].enabled := true;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007083 }
7084
7085 log("f_TC_fh_params_gen(): ", fhp);
7086 return fhp;
7087}
7088
7089/* Make sure that the given Channel Description IE matches the hopping configuration */
7090private function f_TC_fh_params_match_chan_desc(in FHParamsTrx fhp, in ChannelDescription cd)
7091{
7092 var template (present) ChannelDescription tr_cd;
7093 var template (present) MaioHsn tr_maio_hsn;
7094 var uint3_t tn := cd.chan_nr.tn;
7095
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007096 if (fhp.ts[tn].enabled) {
7097 tr_maio_hsn := tr_HsnMaio(fhp.ts[tn].hsn, fhp.ts[tn].maio);
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007098 tr_cd := tr_ChanDescH1(cd.chan_nr, tr_maio_hsn);
7099 } else {
Vadim Yanitskiye7c8c6e2020-09-13 14:33:03 +07007100 tr_cd := tr_ChanDescH0(cd.chan_nr, fhp.arfcn);
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007101 }
7102
7103 if (not match(cd, tr_cd)) {
7104 setverdict(fail, "Channel Description IE does not match: ",
7105 cd, " vs expected ", tr_cd);
7106 }
7107}
7108
7109/* Make sure that the given Mobile Allocation IE matches the hopping configuration */
7110private function f_TC_fh_params_match_ma(in FHParamsTrx fhp, uint3_t tn,
7111 in MobileAllocationLV ma)
7112{
7113 var template MobileAllocationLV tr_ma := f_TC_fh_params_gen_tr_ma(fhp, tn, ma);
7114
7115 if (not match(ma, tr_ma)) {
7116 setverdict(fail, "Mobile Allocation IE does not match (tn := ",
7117 tn, "): ", ma, " vs expected: ", tr_ma);
7118 } else {
7119 setverdict(pass);
7120 }
7121}
7122
7123private function f_TC_fh_params_gen_tr_ma(in FHParamsTrx fhp, uint3_t tn,
7124 in MobileAllocationLV ma)
7125return template MobileAllocationLV {
7126 /* Mobile Allocation IE is expected to be empty if hopping is not enabled */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007127 if (not fhp.ts[tn].enabled) {
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007128 return { len := 0, ma := ''B };
7129 }
7130
7131 var bitstring full_mask := f_pad_bit(''B, 1024, '0'B);
7132 var bitstring slot_mask := f_pad_bit(''B, 1024, '0'B);
7133 var bitstring ma_mask := ''B;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007134
7135 /* Compose the full bit-mask (all channels, up to 1024 entries) */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007136 for (var integer i := 0; i < lengthof(fhp.ts); i := i + 1) {
7137 for (var integer j := 0; j < lengthof(fhp.ts[i].ma); j := j + 1) {
7138 if (full_mask[fhp.ts[i].ma[j]] == '1'B)
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007139 { continue; }
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007140 full_mask[fhp.ts[i].ma[j]] := '1'B;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007141 }
7142 }
7143
Vadim Yanitskiye7c8c6e2020-09-13 14:33:03 +07007144 /* Take ARFCN of the TRX itself into account */
7145 full_mask[fhp.arfcn] := '1'B;
7146
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007147 /* Compose a bit-mask for the given timeslot number */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007148 for (var integer i := 0; i < lengthof(fhp.ts[tn].ma); i := i + 1) {
7149 slot_mask[fhp.ts[tn].ma[i]] := '1'B;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007150 }
7151
7152 /* Finally, compose the Mobile Allocation bit-mask */
Vadim Yanitskiy3e997362020-09-05 21:08:34 +07007153 for (var integer i := 1; i < lengthof(full_mask); i := i + 1) {
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007154 if (full_mask[i] != '1'B)
7155 { continue; }
7156
7157 /* FIXME: ma_mask := ma_mask & slot_mask[i]; // triggers a bug in TITAN */
7158 if (slot_mask[i] == '1'B) {
7159 ma_mask := ma_mask & '1'B;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007160 } else {
7161 ma_mask := ma_mask & '0'B;
7162 }
7163 }
7164
Vadim Yanitskiy3e997362020-09-05 21:08:34 +07007165 /* ARFCN 0 (if present) goes to the last position of the bit-mask */
7166 if (full_mask[0] == '1'B) {
7167 /* FIXME: ma_mask := ma_mask & slot_mask[0]; // triggers a bug in TITAN */
7168 if (slot_mask[0] == '1'B) {
7169 ma_mask := ma_mask & '1'B;
7170 } else {
7171 ma_mask := ma_mask & '0'B;
7172 }
7173 }
7174
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007175 /* Ensure that ma_mask is octet-aligned */
Vadim Yanitskiy2aa02522020-09-06 14:05:23 +07007176 var integer ma_mask_len := (lengthof(ma_mask) + 8 - 1) / 8;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007177 ma_mask := f_pad_bit(ma_mask, ma_mask_len * 8, '0'B);
7178
7179 return { len := ma_mask_len, ma := ma_mask };
7180}
7181
7182/* Configure the hopping parameters in accordance with the given record */
7183private function f_TC_fh_params_set(in FHParamsTrx fhp,
7184 uint8_t bts_nr := 0,
7185 uint8_t trx_nr := 0)
7186runs on test_CT {
7187 /* Enter the configuration node for the given BTS/TRX numbers */
7188 f_vty_enter_cfg_trx(BSCVTY, bts_nr, trx_nr);
7189
Vadim Yanitskiye7c8c6e2020-09-13 14:33:03 +07007190 f_vty_transceive(BSCVTY, "arfcn " & int2str(fhp.arfcn));
7191
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007192 for (var integer tn := 0; tn < lengthof(fhp.ts); tn := tn + 1) {
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007193 f_vty_transceive(BSCVTY, "timeslot " & int2str(tn));
7194
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007195 if (not fhp.ts[tn].enabled) {
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007196 f_vty_transceive(BSCVTY, "hopping enabled 0");
7197 f_vty_transceive(BSCVTY, "exit"); /* go back */
7198 continue;
7199 }
7200
7201 /* Configure HSN / MAIO values */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007202 f_vty_transceive(BSCVTY, "hopping sequence-number " & int2str(fhp.ts[tn].hsn));
7203 f_vty_transceive(BSCVTY, "hopping maio " & int2str(fhp.ts[tn].maio));
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007204
7205 /* Configure the Mobile Allocation (hopping channels) */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007206 for (var integer i := 0; i < lengthof(fhp.ts[tn].ma); i := i + 1) {
7207 f_vty_transceive(BSCVTY, "hopping arfcn add " & int2str(fhp.ts[tn].ma[i]));
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007208 }
7209
7210 f_vty_transceive(BSCVTY, "hopping enabled 1");
7211 f_vty_transceive(BSCVTY, "exit"); /* go back */
7212 }
7213
7214 f_vty_transceive(BSCVTY, "end");
7215}
7216
7217/* Disable frequency hopping on all timeslots */
7218private function f_TC_fh_params_unset(in FHParamsTrx fhp,
7219 uint8_t bts_nr := 0,
Vadim Yanitskiye7c8c6e2020-09-13 14:33:03 +07007220 uint8_t trx_nr := 0,
7221 GsmArfcn arfcn := 871)
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007222runs on test_CT {
7223 /* Enter the configuration node for the given BTS/TRX numbers */
7224 f_vty_enter_cfg_trx(BSCVTY, bts_nr, trx_nr);
7225
Vadim Yanitskiye7c8c6e2020-09-13 14:33:03 +07007226 f_vty_transceive(BSCVTY, "arfcn " & int2str(arfcn));
7227
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007228 for (var integer tn := 0; tn < lengthof(fhp.ts); tn := tn + 1) {
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007229 f_vty_transceive(BSCVTY, "timeslot " & int2str(tn));
7230
7231 /* Delete all ARFCNs from the Mobile Allocation (if any) */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007232 for (var integer i := 0; i < lengthof(fhp.ts[tn].ma); i := i + 1) {
7233 f_vty_transceive(BSCVTY, "hopping arfcn del " & int2str(fhp.ts[tn].ma[i]));
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007234 }
7235
7236 f_vty_transceive(BSCVTY, "hopping enabled 0");
7237 f_vty_transceive(BSCVTY, "exit"); /* go back */
7238 }
7239
7240 f_vty_transceive(BSCVTY, "end");
7241 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
7242}
7243
7244/* Verify presence and correctness of the hopping parameters (HSN, MAIO)
7245 * in the Channel Identification IE of the RSL CHANnel ACTIVation message. */
7246testcase TC_fh_params_chan_activ() runs on test_CT {
7247 var FHParamsTrx fhp := f_TC_fh_params_gen();
7248 var RSL_Message rsl_msg;
7249 var RSL_IE_Body ie;
7250
7251 f_init_vty();
7252
7253 f_TC_fh_params_set(fhp); /* Enable frequency hopping */
7254 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
7255
7256 f_init(1);
7257
7258 /* CS domain: 3 (SDCCH/4+CBCH) + 4 (TCH/F) + 2 (TCH/H) channels available */
7259 for (var integer i := 0; i < 9; i := i + 1) {
7260 f_ipa_tx(0, ts_RSL_CHAN_RQD(f_rnd_ra_cs(), 23));
7261 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
7262
7263 /* Make sure that Channel Identification IE is present */
7264 if (not f_rsl_find_ie(rsl_msg, RSL_IE_CHAN_IDENT, ie)) {
7265 setverdict(fail, "RSL Channel Identification IE is absent");
7266 continue;
7267 }
7268
7269 /* Make sure that hopping parameters (HSN/MAIO) match */
7270 f_TC_fh_params_match_chan_desc(fhp, ie.chan_ident.ch_desc.v);
7271
7272 /* "Mobile Allocation shall be included but empty" - let's check this */
7273 if (ie.chan_ident.ma.v.len != 0) {
7274 setverdict(fail, "Mobile Allocation IE is not empty: ",
7275 ie.chan_ident.ma, ", despite it shall be");
7276 continue;
7277 }
7278 }
7279
7280 /* Disable frequency hopping */
7281 f_TC_fh_params_unset(fhp);
7282
Vadim Yanitskiy21726312020-09-04 01:45:36 +07007283 f_shutdown_helper();
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007284}
7285
7286/* Verify the hopping parameters (HSN, MAIO, MA) in (RR) Immediate Assignment */
7287testcase TC_fh_params_imm_ass() runs on test_CT {
7288 var FHParamsTrx fhp := f_TC_fh_params_gen();
7289 var RSL_Message rsl_msg;
7290 var RSL_IE_Body ie;
7291
7292 f_init_vty();
7293
7294 f_TC_fh_params_set(fhp); /* Enable frequency hopping */
7295 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
7296
7297 f_init(1);
7298
7299 /* CS domain: 3 (SDCCH/4+CBCH) + 4 (TCH/F) + 2 (TCH/H) channels available */
7300 for (var integer i := 0; i < 9; i := i + 1) {
7301 f_ipa_tx(0, ts_RSL_CHAN_RQD(f_rnd_ra_cs(), 23));
7302 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
7303
7304 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(rsl_msg.ies[0].body.chan_nr, 33));
7305 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeC(RSL_MT_IMMEDIATE_ASSIGN_CMD));
7306
7307 /* Make sure that Full Immediate Assign Info IE is present */
7308 if (not f_rsl_find_ie(rsl_msg, RSL_IE_FULL_IMM_ASS_INFO, ie)) {
7309 setverdict(fail, "RSL Full Immediate Assign Info IE is absent");
7310 continue;
7311 }
7312
7313 /* Decode the actual Immediate Assignment message */
7314 var GsmRrMessage rr_msg := dec_GsmRrMessage(ie.full_imm_ass_info.payload);
7315 if (not match(rr_msg.header, t_RrHeader(IMMEDIATE_ASSIGNMENT, ?))) {
7316 setverdict(fail, "Failed to match Immediate Assignment: ", rr_msg);
7317 continue;
7318 }
7319
7320 /* Make sure that hopping parameters (HSN/MAIO) match */
7321 f_TC_fh_params_match_chan_desc(fhp, rr_msg.payload.imm_ass.chan_desc);
7322
7323 /* Make sure that the Mobile Allocation IE matches */
7324 f_TC_fh_params_match_ma(fhp, rr_msg.payload.imm_ass.chan_desc.chan_nr.tn,
7325 rr_msg.payload.imm_ass.mobile_allocation);
7326 }
7327
7328 /* Disable frequency hopping */
7329 f_TC_fh_params_unset(fhp);
Philipp Maier82812002020-08-13 18:48:27 +02007330
Vadim Yanitskiy21726312020-09-04 01:45:36 +07007331 f_shutdown_helper();
Philipp Maier82812002020-08-13 18:48:27 +02007332}
7333
Vadim Yanitskiyaeb54a22020-09-01 06:25:25 +07007334/* Verify the hopping parameters (HSN, MAIO, MA) in (RR) Assignment Command */
7335testcase TC_fh_params_assignment_cmd() runs on test_CT {
7336 var FHParamsTrx fhp := f_TC_fh_params_gen();
7337 var RSL_Message rsl_msg;
7338 var RSL_IE_Body ie;
7339
7340 f_init_vty();
7341
7342 f_TC_fh_params_set(fhp); /* Enable frequency hopping */
7343 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
7344
7345 f_init(1);
7346
7347 /* HACK: work around "Couldn't find Expect for CRCX" */
7348 vc_MGCP.stop;
7349
7350 var template PDU_BSSAP ass_cmd := f_gen_ass_req();
7351 ass_cmd.pdu.bssmap.assignmentRequest.codecList := ts_BSSMAP_IE_CodecList({ts_CodecFR});
7352
7353 /* CS domain (TCH): 4 (TCH/F) + 2 (TCH/H) channels available
7354 * NOTE: only 3 SDCCH/4 channels are available on CCCH+SDCCH4+CBCH */
7355 for (var integer i := 0; i < 3; i := i + 1) {
7356 /* Establish a dedicated channel, so we can trigger (late) TCH assignment */
7357 var DchanTuple dt := f_est_dchan(f_rnd_ra_cs(), 23, f_rnd_octstring(16));
7358
7359 /* Send a BSSMAP Assignment Command, expect CHANnel ACTIVation */
7360 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ass_cmd));
7361 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
7362
7363 /* ACKnowledge CHANnel ACTIVation, expect RSL DATA REQuest */
7364 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(rsl_msg.ies[0].body.chan_nr, 33));
7365 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeR(RSL_MT_DATA_REQ));
7366
7367 /* Make sure that L3 Information IE is present */
7368 if (not f_rsl_find_ie(rsl_msg, RSL_IE_L3_INFO, ie)) {
7369 setverdict(fail, "RSL L3 Information IE is absent");
7370 continue;
7371 }
7372
7373 /* Decode the L3 message and make sure it is (RR) Assignment Command */
7374 var GsmRrL3Message l3_msg := dec_GsmRrL3Message(ie.l3_info.payload);
7375 if (not match(l3_msg.header, t_RrL3Header(ASSIGNMENT_COMMAND))) {
7376 setverdict(fail, "Failed to match Assignment Command: ", l3_msg);
7377 continue;
7378 }
7379
7380 /* Make sure that hopping parameters (HSN/MAIO) match */
7381 var ChannelDescription chan_desc := l3_msg.payload.ass_cmd.chan_desc;
7382 f_TC_fh_params_match_chan_desc(fhp, chan_desc);
7383
7384 /* Make sure that Cell Channel Description IE is present if FH is enabled */
7385 if (chan_desc.h and not ispresent(l3_msg.payload.ass_cmd.cell_chan_desc)) {
Vadim Yanitskiy38d069d2020-09-02 17:18:57 +07007386 setverdict(fail, "FH enabled, but Cell Channel Description IE is absent");
Vadim Yanitskiyaeb54a22020-09-01 06:25:25 +07007387 continue;
7388 }
7389
7390 /* Make sure that the Mobile Allocation IE matches (if present) */
7391 var boolean ma_present := ispresent(l3_msg.payload.ass_cmd.mobile_allocation);
7392 if (chan_desc.h and ma_present) {
7393 f_TC_fh_params_match_ma(fhp, chan_desc.chan_nr.tn,
7394 l3_msg.payload.ass_cmd.mobile_allocation.v);
7395 } else if (chan_desc.h and not ma_present) {
7396 setverdict(fail, "FH enabled, but Mobile Allocation IE is absent");
7397 continue;
7398 } else if (not chan_desc.h and ma_present) {
7399 setverdict(fail, "FH disabled, but Mobile Allocation IE is present");
7400 continue;
7401 }
7402 }
7403
7404 /* Give the IUT some time to release all channels */
7405 f_sleep(3.0);
7406
7407 /* Disable frequency hopping */
7408 f_TC_fh_params_unset(fhp);
7409
Vadim Yanitskiy21726312020-09-04 01:45:36 +07007410 f_shutdown_helper();
Vadim Yanitskiyaeb54a22020-09-01 06:25:25 +07007411}
7412
Vadim Yanitskiy8f5430d2020-09-02 18:51:38 +07007413/* Verify the hopping parameters (HSN, MAIO, MA) in (RR) Handover Command */
7414private function f_TC_fh_params_handover_cmd(in FHParamsTrx fhp)
7415runs on test_CT {
7416 var RSL_Message rsl_msg;
7417 var RSL_IE_Body ie;
7418 var DchanTuple dt;
7419
7420 /* Establish a dedicated channel, so we can trigger handover */
7421 dt := f_est_dchan(f_rnd_ra_cs(), 23, f_rnd_octstring(16));
7422
7423 /* Trigger handover from BTS0 to BTS1 */
7424 f_bts_0_cfg(BSCVTY, { "neighbor bts 1" });
7425 f_vty_handover(BSCVTY, 0, 0, dt.rsl_chan_nr, 1);
7426
7427 /* Expect RSL CHANnel ACTIVation on BTS1/TRX0/TS1 */
7428 rsl_msg := f_exp_ipa_rx(1, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
7429
7430 /* ACKnowledge channel activation and expect (RR) Handover Command */
7431 f_ipa_tx(1, ts_RSL_CHAN_ACT_ACK(rsl_msg.ies[0].body.chan_nr, 33));
7432 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeR(RSL_MT_DATA_REQ));
7433
7434 /* Make sure that L3 Information IE is present */
7435 if (not f_rsl_find_ie(rsl_msg, RSL_IE_L3_INFO, ie)) {
7436 setverdict(fail, "RSL L3 Information IE is absent");
7437 return;
7438 }
7439
7440 /* Decode the L3 message and make sure it is (RR) Handover Command */
7441 var GsmRrL3Message l3_msg := dec_GsmRrL3Message(ie.l3_info.payload);
7442 if (not match(l3_msg.header, t_RrL3Header(HANDOVER_COMMAND))) {
7443 setverdict(fail, "Failed to match Handover Command: ", l3_msg);
7444 return;
7445 }
7446
7447 /* Make sure that we've got SDCCH/8 on TS1 (expected to be hopping) */
7448 var ChannelDescription chan_desc := l3_msg.payload.ho_cmd.chan_desc;
7449 if (not match(chan_desc.chan_nr, t_RslChanNr_SDCCH8(1, ?))) {
7450 setverdict(fail, "Unexpected channel number: ", chan_desc.chan_nr);
7451 return;
7452 }
7453
7454 /* Make sure that hopping parameters (HSN/MAIO) match */
7455 f_TC_fh_params_match_chan_desc(fhp, chan_desc);
7456
7457 /* Make sure that Cell Channel Description IE is present */
7458 if (not ispresent(l3_msg.payload.ho_cmd.cell_chan_desc)) {
7459 setverdict(fail, "FH enabled, but Cell Channel Description IE is absent");
7460 return;
7461 }
7462
7463 /* Make sure that the Mobile Allocation (after time) IE is present and matches */
7464 var boolean ma_present := ispresent(l3_msg.payload.ho_cmd.mobile_allocation);
7465 if (ma_present) {
7466 f_TC_fh_params_match_ma(fhp, chan_desc.chan_nr.tn,
7467 l3_msg.payload.ho_cmd.mobile_allocation.v);
7468 } else {
7469 setverdict(fail, "FH enabled, but Mobile Allocation IE is absent");
7470 return;
7471 }
7472}
7473testcase TC_fh_params_handover_cmd() runs on test_CT {
7474 var FHParamsTrx fhp := f_TC_fh_params_gen();
7475
7476 f_init_vty();
7477
7478 /* (Re)configure TS0 as BCCH and TS1 as SDCCH8 on BTS1/TRX0 */
7479 f_vty_enter_cfg_trx(BSCVTY, bts := 1, trx := 0);
7480
7481 f_vty_transceive(BSCVTY, "timeslot 0");
7482 f_vty_transceive(BSCVTY, "phys_chan_config ccch");
7483 f_vty_transceive(BSCVTY, "exit"); /* go back */
7484
7485 f_vty_transceive(BSCVTY, "timeslot 1");
7486 f_vty_transceive(BSCVTY, "phys_chan_config sdcch8");
7487 f_vty_transceive(BSCVTY, "end"); /* we're done */
7488
7489 f_TC_fh_params_set(fhp, 1); /* Enable frequency hopping on BTS1 */
7490 f_vty_transceive(BSCVTY, "drop bts connection 1 oml");
7491
7492 f_init(2);
7493
7494 f_TC_fh_params_handover_cmd(fhp);
7495
7496 /* Disable frequency hopping on BTS1 */
7497 f_TC_fh_params_unset(fhp, 1);
7498
7499 /* (Re)configure TS0 as CCCH+SDCCH4+CBCH and TS1 as TCH/F */
7500 f_vty_enter_cfg_trx(BSCVTY, bts := 1, trx := 0);
7501
7502 f_vty_transceive(BSCVTY, "timeslot 0");
7503 f_vty_transceive(BSCVTY, "phys_chan_config ccch+sdcch4+cbch");
7504 f_vty_transceive(BSCVTY, "exit"); /* go back */
7505
7506 f_vty_transceive(BSCVTY, "timeslot 1");
7507 f_vty_transceive(BSCVTY, "phys_chan_config tch/f");
7508 f_vty_transceive(BSCVTY, "end"); /* we're done */
7509
7510 f_shutdown_helper();
7511}
7512
Vadim Yanitskiyca974032020-09-01 07:20:39 +07007513/* Verify the hopping parameters in System Information Type 4 */
7514testcase TC_fh_params_si4_cbch() runs on test_CT {
7515 var FHParamsTrx fhp := f_TC_fh_params_gen(tr_tn := 1);
7516 var ASP_RSL_Unitdata rx_rsl_ud;
7517 timer T := 5.0;
7518
7519 f_init_vty();
7520
7521 /* (Re)configure TS0 as BCCH and TS1 as SDCCH8+CBCH */
7522 f_vty_enter_cfg_trx(BSCVTY, trx := 0);
7523
7524 f_vty_transceive(BSCVTY, "timeslot 0");
7525 f_vty_transceive(BSCVTY, "phys_chan_config ccch");
7526 f_vty_transceive(BSCVTY, "exit"); /* go back */
7527
7528 f_vty_transceive(BSCVTY, "timeslot 1");
7529 f_vty_transceive(BSCVTY, "phys_chan_config sdcch8+cbch");
7530 f_vty_transceive(BSCVTY, "end"); /* we're done */
7531
7532 f_TC_fh_params_set(fhp); /* Enable frequency hopping */
7533 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
7534
7535 f_init(1);
7536
7537 T.start;
7538 alt {
7539 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_BCCH_INFO(RSL_SYSTEM_INFO_4))) -> value rx_rsl_ud {
7540 var RSL_IE_Body ie := rx_rsl_ud.rsl.ies[2].body; /* FULL BCCH Information IE */
7541 var SystemInformation si := dec_SystemInformation(ie.other.payload);
7542
7543 /* Make sure that what we decoded is System Information Type 4 */
7544 if (si.header.message_type != SYSTEM_INFORMATION_TYPE_4) {
7545 setverdict(fail, "RSL FULL BCCH Information IE contains: ", si);
7546 repeat;
7547 }
7548
7549 /* Make sure that CBCH Channel Description IE is present */
7550 if (not ispresent(si.payload.si4.cbch_chan_desc)) {
7551 setverdict(fail, "CBCH Channel Description IE is absent");
7552 break;
7553 }
7554
7555 /* Finally, check the hopping parameters (HSN, MAIO) */
7556 var ChannelDescription chan_desc := si.payload.si4.cbch_chan_desc.v;
7557 f_TC_fh_params_match_chan_desc(fhp, chan_desc);
7558
7559 /* 3GPP TS 44.018, section 9.1.36.2 "CBCH Mobile Allocation":
7560 * The CBCH Mobile Allocation IE *shall* be present if FH is enabled. */
7561 if (chan_desc.h and not ispresent(si.payload.si4.cbch_mobile_alloc)) {
7562 setverdict(fail, "FH enabled, but Mobile Allocation IE is absent");
7563 break;
7564 } else if (chan_desc.h and ispresent(si.payload.si4.cbch_mobile_alloc)) {
7565 f_TC_fh_params_match_ma(fhp, chan_desc.chan_nr.tn,
7566 si.payload.si4.cbch_mobile_alloc.v);
7567 }
7568 }
7569 [] IPA_RSL[0].receive { repeat; }
7570 [] T.timeout {
7571 setverdict(fail, "Timeout waiting for RSL BCCH INFOrmation (SI4)");
7572 }
7573 }
7574
7575 /* Disable frequency hopping */
7576 f_TC_fh_params_unset(fhp);
7577
Vadim Yanitskiy8bc46012020-09-06 12:38:01 +07007578 /* (Re)configure TS0 as CCCH+SDCCH4+CBCH and TS1 as TCH/F */
Vadim Yanitskiyca974032020-09-01 07:20:39 +07007579 f_vty_enter_cfg_trx(BSCVTY, trx := 0);
7580
7581 f_vty_transceive(BSCVTY, "timeslot 0");
Vadim Yanitskiy8bc46012020-09-06 12:38:01 +07007582 f_vty_transceive(BSCVTY, "phys_chan_config ccch+sdcch4+cbch");
Vadim Yanitskiyca974032020-09-01 07:20:39 +07007583 f_vty_transceive(BSCVTY, "exit"); /* go back */
7584
7585 f_vty_transceive(BSCVTY, "timeslot 1");
7586 f_vty_transceive(BSCVTY, "phys_chan_config tch/f");
7587 f_vty_transceive(BSCVTY, "end"); /* we're done */
7588
Vadim Yanitskiy21726312020-09-04 01:45:36 +07007589 f_shutdown_helper();
Vadim Yanitskiyca974032020-09-01 07:20:39 +07007590}
7591
Harald Welte0ea2d5e2018-04-07 21:40:29 +02007592/* Dyn PDCH todo:
7593 * activate OSMO as TCH/F
7594 * activate OSMO as TCH/H
7595 * does the BSC-located PCU socket get the updated INFO?
7596 * what if no PCU is connected at the time?
7597 * is the info correct on delayed PCU (re)connect?
7598 */
Harald Welte94e0c342018-04-07 11:33:23 +02007599
Harald Welte28d943e2017-11-25 15:00:50 +01007600control {
Harald Welte898113b2018-01-31 18:32:21 +01007601 /* CTRL interface testing */
Harald Welte4003d112017-12-09 22:35:39 +01007602 execute( TC_ctrl_msc_connection_status() );
Stefan Sperlingb041b3d2018-01-03 17:14:55 +01007603 execute( TC_ctrl_msc0_connection_status() );
Harald Welte96c94412017-12-09 03:12:45 +01007604 execute( TC_ctrl() );
Neels Hofmeyrf246a922020-05-13 02:27:10 +02007605 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_SCCPlite_SERVER) {
Pau Espin Pedrol5a2d7432019-06-07 19:43:45 +02007606 execute( TC_ctrl_location() );
7607 }
Harald Welte898113b2018-01-31 18:32:21 +01007608
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +02007609 execute( TC_si_default() );
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02007610 execute( TC_si2quater_2_earfcns() );
7611 execute( TC_si2quater_3_earfcns() );
7612 execute( TC_si2quater_4_earfcns() );
7613 execute( TC_si2quater_5_earfcns() );
7614 execute( TC_si2quater_6_earfcns() );
Neels Hofmeyrad132f22020-07-08 02:20:16 +02007615 execute( TC_si2quater_12_earfcns() );
7616 execute( TC_si2quater_23_earfcns() );
7617 execute( TC_si2quater_32_earfcns() );
7618 execute( TC_si2quater_33_earfcns() );
7619 execute( TC_si2quater_42_earfcns() );
7620 execute( TC_si2quater_48_earfcns() );
7621 execute( TC_si2quater_49_earfcns() );
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02007622 execute( TC_si_acc_rotate() );
Alexander Couzens4ad3a352020-09-10 22:29:12 +02007623 execute( TC_si_acc_ramp_rotate() );
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +02007624
Harald Welte898113b2018-01-31 18:32:21 +01007625 /* RSL DCHAN Channel ACtivation / Deactivation */
Harald Welteae026692017-12-09 01:03:01 +01007626 execute( TC_chan_act_noreply() );
Harald Welte4003d112017-12-09 22:35:39 +01007627 execute( TC_chan_act_counter() );
Harald Welteae026692017-12-09 01:03:01 +01007628 execute( TC_chan_act_ack_noest() );
Philipp Maier9c60a622020-07-09 15:08:46 +02007629 execute( TC_chan_act_ack_noest_emerg() );
Philipp Maier606f07d2020-08-12 17:21:58 +02007630 execute( TC_chan_rqd_emerg_deny() );
Harald Welteae026692017-12-09 01:03:01 +01007631 execute( TC_chan_act_ack_est_ind_noreply() );
7632 execute( TC_chan_act_ack_est_ind_refused() );
Harald Welte618ef642017-12-14 14:58:20 +01007633 execute( TC_chan_act_nack() );
Harald Welte799c97b2017-12-14 17:50:30 +01007634 execute( TC_chan_exhaustion() );
Vadim Yanitskiy1ff1fdf2018-11-27 01:32:57 +07007635 execute( TC_chan_deact_silence() );
Harald Welte4003d112017-12-09 22:35:39 +01007636 execute( TC_chan_rel_rll_rel_ind() );
7637 execute( TC_chan_rel_conn_fail() );
7638 execute( TC_chan_rel_hard_clear() );
Harald Welte99787102019-02-04 10:41:36 +01007639 execute( TC_chan_rel_hard_clear_csfb() );
Harald Welted8c36cd2017-12-09 23:05:31 +01007640 execute( TC_chan_rel_hard_rlsd() );
Harald Welte550daf92018-06-11 19:22:13 +02007641 execute( TC_chan_rel_hard_rlsd_ms_dead() );
Harald Welte85804d42017-12-10 14:11:58 +01007642 execute( TC_chan_rel_a_reset() );
Pau Espin Pedrolc675b612020-01-09 19:55:40 +01007643 execute( TC_chan_rel_sccp_tiar_timeout() );
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02007644 execute( TC_chan_rel_rr_cause() );
Harald Welte6f521d82017-12-11 19:52:02 +01007645
Harald Weltecfe2c962017-12-15 12:09:32 +01007646 execute( TC_outbound_connect() );
Harald Welte898113b2018-01-31 18:32:21 +01007647
7648 /* Assignment related */
Harald Welte16a4adf2017-12-14 18:54:01 +01007649 execute( TC_assignment_cic_only() );
Harald Welte235ebf12017-12-15 14:18:16 +01007650 execute( TC_assignment_csd() );
7651 execute( TC_assignment_ctm() );
7652 execute( TC_assignment_sign() );
Pau Espin Pedrol07866632020-09-03 19:10:55 +02007653 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
7654 execute( TC_assignment_aoip_tla_v6() );
7655 }
Harald Welte235ebf12017-12-15 14:18:16 +01007656 execute( TC_assignment_fr_a5_0() );
7657 execute( TC_assignment_fr_a5_1() );
Neels Hofmeyrf246a922020-05-13 02:27:10 +02007658 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
Harald Welte8f67d1d2018-05-25 20:38:42 +02007659 execute( TC_assignment_fr_a5_1_codec_missing() );
7660 }
Harald Welte235ebf12017-12-15 14:18:16 +01007661 execute( TC_assignment_fr_a5_3() );
7662 execute( TC_assignment_fr_a5_4() );
Harald Welte3c86ea02018-05-10 22:28:05 +02007663 execute( TC_ciph_mode_a5_0() );
7664 execute( TC_ciph_mode_a5_1() );
7665 execute( TC_ciph_mode_a5_3() );
Harald Welte16a4adf2017-12-14 18:54:01 +01007666
Harald Welte60aa5762018-03-21 19:33:13 +01007667 execute( TC_assignment_codec_fr() );
7668 execute( TC_assignment_codec_hr() );
7669 execute( TC_assignment_codec_efr() );
7670 execute( TC_assignment_codec_amr_f() );
7671 execute( TC_assignment_codec_amr_h() );
Philipp Maier8a581d22019-03-26 18:32:48 +01007672
Neels Hofmeyrf246a922020-05-13 02:27:10 +02007673 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
Philipp Maier8a581d22019-03-26 18:32:48 +01007674 execute( TC_assignment_codec_amr_f_S1() );
7675 execute( TC_assignment_codec_amr_h_S1() );
7676 execute( TC_assignment_codec_amr_f_S124() );
7677 execute( TC_assignment_codec_amr_h_S124() );
7678 execute( TC_assignment_codec_amr_f_S0() );
7679 execute( TC_assignment_codec_amr_f_S02() );
7680 execute( TC_assignment_codec_amr_f_S024() );
7681 execute( TC_assignment_codec_amr_f_S0247() );
7682 execute( TC_assignment_codec_amr_h_S0() );
7683 execute( TC_assignment_codec_amr_h_S02() );
7684 execute( TC_assignment_codec_amr_h_S024() );
7685 execute( TC_assignment_codec_amr_h_S0247() );
7686 execute( TC_assignment_codec_amr_f_S01234567() );
7687 execute( TC_assignment_codec_amr_f_S0234567() );
7688 execute( TC_assignment_codec_amr_f_zero() );
7689 execute( TC_assignment_codec_amr_f_unsupp() );
7690 execute( TC_assignment_codec_amr_h_S7() );
7691 }
Harald Welte60aa5762018-03-21 19:33:13 +01007692
Philipp Maierac09bfc2019-01-08 13:41:39 +01007693 execute( TC_assignment_codec_fr_exhausted_req_hr() );
7694 execute( TC_assignment_codec_fr_exhausted_req_fr() );
7695 execute( TC_assignment_codec_fr_exhausted_req_fr_hr() );
7696 execute( TC_assignment_codec_fr_exhausted_req_hr_fr() );
7697 execute( TC_assignment_codec_hr_exhausted_req_fr() );
7698 execute( TC_assignment_codec_hr_exhausted_req_hr() );
7699 execute( TC_assignment_codec_hr_exhausted_req_hr_fr() );
7700 execute( TC_assignment_codec_hr_exhausted_req_fr_hr() );
7701 execute( TC_assignment_codec_req_hr_fr() );
7702 execute( TC_assignment_codec_req_fr_hr() );
7703
Pau Espin Pedrol58cf6822019-05-28 18:11:33 +02007704 if (mp_enable_osmux_test) {
7705 execute( TC_assignment_osmux() );
7706 }
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02007707
Harald Welte898113b2018-01-31 18:32:21 +01007708 /* RLL Establish Indication on inactive DCHAN / SAPI */
Harald Welte5cd20ed2017-12-13 21:03:20 +01007709 execute( TC_rll_est_ind_inact_lchan() );
7710 execute( TC_rll_est_ind_inval_sapi1() );
7711 execute( TC_rll_est_ind_inval_sapi3() );
7712 execute( TC_rll_est_ind_inval_sacch() );
7713
Vadim Yanitskiy61f784a2020-10-01 21:12:19 +07007714 /* DLCI / RSL Link ID conversion for MO/MT messages on SAPI0/SAPI3 */
7715 execute( TC_tch_dlci_link_id_sapi() );
7716
Vadim Yanitskiy6ef5dfa2020-08-28 18:04:41 +07007717 /* SAPI N Reject triggered by RLL establishment failures */
7718 execute( TC_rll_rel_ind_sapi_n_reject() );
7719 execute( TC_rll_err_ind_sapi_n_reject() );
7720 execute( TC_rll_timeout_sapi_n_reject() );
7721
Harald Welte898113b2018-01-31 18:32:21 +01007722 /* Paging related tests */
Harald Welte6f521d82017-12-11 19:52:02 +01007723 execute( TC_paging_imsi_nochan() );
7724 execute( TC_paging_tmsi_nochan() );
7725 execute( TC_paging_tmsi_any() );
7726 execute( TC_paging_tmsi_sdcch() );
7727 execute( TC_paging_tmsi_tch_f() );
7728 execute( TC_paging_tmsi_tch_hf() );
7729 execute( TC_paging_imsi_nochan_cgi() );
7730 execute( TC_paging_imsi_nochan_lac_ci() );
7731 execute( TC_paging_imsi_nochan_ci() );
7732 execute( TC_paging_imsi_nochan_lai() );
7733 execute( TC_paging_imsi_nochan_lac() );
7734 execute( TC_paging_imsi_nochan_all() );
Harald Welte751d3eb2018-01-31 15:51:06 +01007735 execute( TC_paging_imsi_nochan_plmn_lac_rnc() );
7736 execute( TC_paging_imsi_nochan_rnc() );
7737 execute( TC_paging_imsi_nochan_lac_rnc() );
7738 execute( TC_paging_imsi_nochan_lacs() );
7739 execute( TC_paging_imsi_nochan_lacs_empty() );
Stefan Sperling049a86e2018-03-20 15:51:00 +01007740 execute( TC_paging_imsi_nochan_cgi_unknown_cid() );
Harald Welte10985002017-12-12 09:29:15 +01007741 execute( TC_paging_imsi_a_reset() );
Harald Weltee65d40e2017-12-13 00:09:06 +01007742 execute( TC_paging_imsi_load() );
Philipp Maier779a7922018-02-16 11:00:37 +01007743 execute( TC_paging_counter() );
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01007744 execute( TC_paging_resp_unsol() );
Harald Welte4e9b9cc2017-12-14 18:31:02 +01007745
7746 execute( TC_rsl_drop_counter() );
Stefan Sperling830dc9d2018-02-12 21:08:28 +01007747 execute( TC_rsl_unknown_unit_id() );
7748
7749 execute( TC_oml_unknown_unit_id() );
Harald Welte898113b2018-01-31 18:32:21 +01007750
7751 execute( TC_classmark() );
Harald Welteeddf0e92020-06-21 19:42:15 +02007752 execute( TC_common_id() );
Harald Welte898113b2018-01-31 18:32:21 +01007753 execute( TC_unsol_ass_fail() );
Harald Welteea99a002018-01-31 20:46:43 +01007754 execute( TC_unsol_ass_compl() );
Harald Weltefbf9b5e2018-01-31 20:41:23 +01007755 execute( TC_unsol_ho_fail() );
Harald Weltee3bd6582018-01-31 22:51:25 +01007756 execute( TC_err_82_short_msg() );
Harald Weltee9e02e42018-01-31 23:36:25 +01007757 execute( TC_err_84_unknown_msg() );
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01007758
Harald Welte261af4b2018-02-12 21:20:39 +01007759 execute( TC_ho_int() );
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01007760
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01007761 execute( TC_ho_out_of_this_bsc() );
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02007762 execute( TC_ho_out_fail_no_msc_response() );
7763 execute( TC_ho_out_fail_rr_ho_failure() );
Neels Hofmeyrd8a602c2019-07-09 19:46:01 +02007764 execute( TC_ho_out_fail_no_result_after_ho_cmd() );
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01007765
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01007766 execute( TC_ho_into_this_bsc() );
Pau Espin Pedrol07866632020-09-03 19:10:55 +02007767 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
7768 execute( TC_ho_into_this_bsc_tla_v6() );
7769 }
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01007770 execute( TC_ho_in_fail_msc_clears() );
7771 execute( TC_ho_in_fail_msc_clears_after_ho_detect() );
7772 execute( TC_ho_in_fail_no_detect() );
7773 execute( TC_ho_in_fail_no_detect2() );
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01007774
Neels Hofmeyr91401012019-07-11 00:42:35 +02007775 execute( TC_ho_neighbor_config_1() );
7776 execute( TC_ho_neighbor_config_2() );
7777 execute( TC_ho_neighbor_config_3() );
7778 execute( TC_ho_neighbor_config_4() );
7779 execute( TC_ho_neighbor_config_5() );
7780 execute( TC_ho_neighbor_config_6() );
7781 execute( TC_ho_neighbor_config_7() );
7782
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01007783 execute( TC_bssap_rlsd_does_not_cause_bssmap_reset() );
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01007784 execute( TC_bssmap_clear_does_not_cause_bssmap_reset() );
Neels Hofmeyrfd445c32018-03-09 15:39:31 +01007785 execute( TC_ms_rel_ind_does_not_cause_bssmap_reset() );
Harald Welte94e0c342018-04-07 11:33:23 +02007786
7787 execute( TC_dyn_pdch_ipa_act_deact() );
7788 execute( TC_dyn_pdch_ipa_act_nack() );
7789 execute( TC_dyn_pdch_osmo_act_deact() );
7790 execute( TC_dyn_pdch_osmo_act_nack() );
Harald Welte99f3ca02018-06-14 13:40:29 +02007791
Stefan Sperling0796a822018-10-05 13:01:39 +02007792 execute( TC_chopped_ipa_ping() );
Stefan Sperlingaa1e60f2018-10-15 16:34:07 +02007793 execute( TC_chopped_ipa_payload() );
Stefan Sperling0796a822018-10-05 13:01:39 +02007794
Pau Espin Pedrol8f773632019-11-05 11:46:53 +01007795 /* Power control related */
7796 execute( TC_assignment_verify_ms_power_params_ie() );
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007797
7798 /* MSC pooling */
7799 /* FIXME: in SCCPlite, indicating how many MSCs should be connected does currently not work. Since
7800 * RESET->RESET-ACK is unconditionally negotiated for all configured MSCs, they always all appear as connected
7801 * to osmo-bsc. The MSC pooling tests however require disconnecting selected MSCs, and hence don't work out as
7802 * intended on SCCPlite. So for now, run these only for SCCP/M3UA. */
7803 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
7804 execute( TC_mscpool_L3Compl_on_1_msc() );
7805 execute( TC_mscpool_L3Complete_by_imsi_round_robin() );
7806 execute( TC_mscpool_LU_by_tmsi_null_nri_0_round_robin() );
7807 execute( TC_mscpool_LU_by_tmsi_null_nri_1_round_robin() );
7808 execute( TC_mscpool_L3Complete_by_tmsi_unassigned_nri_round_robin() );
7809 execute( TC_mscpool_L3Complete_by_tmsi_valid_nri_msc_not_connected_round_robin() );
7810 execute( TC_mscpool_L3Complete_by_tmsi_valid_nri_1() );
7811 execute( TC_mscpool_L3Complete_by_tmsi_valid_nri_2() );
7812 execute( TC_mscpool_LU_by_tmsi_from_other_PLMN() );
7813 execute( TC_mscpool_paging_and_response_imsi() );
7814 execute( TC_mscpool_paging_and_response_tmsi() );
7815 execute( TC_mscpool_no_allow_attach_round_robin() );
7816 execute( TC_mscpool_no_allow_attach_valid_nri() );
7817 }
7818
Harald Welte99f3ca02018-06-14 13:40:29 +02007819 /* at bottom as they might crash OsmoBSC before OS#3182 is fixed */
7820 execute( TC_early_conn_fail() );
7821 execute( TC_late_conn_fail() );
7822
Philipp Maier783681c2020-07-16 16:47:06 +02007823 /* Emergency call handling (deny / allow) */
7824 execute( TC_assignment_emerg_setup_allow() );
7825 execute( TC_assignment_emerg_setup_deny_msc() );
7826 execute( TC_assignment_emerg_setup_deny_bts() );
Philipp Maier82812002020-08-13 18:48:27 +02007827 execute( TC_emerg_premption() );
7828
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007829 /* Frequency hopping parameters handling */
7830 execute( TC_fh_params_chan_activ() );
7831 execute( TC_fh_params_imm_ass() );
Vadim Yanitskiyaeb54a22020-09-01 06:25:25 +07007832 execute( TC_fh_params_assignment_cmd() );
Vadim Yanitskiy8f5430d2020-09-02 18:51:38 +07007833 execute( TC_fh_params_handover_cmd() );
Vadim Yanitskiyca974032020-09-01 07:20:39 +07007834 execute( TC_fh_params_si4_cbch() );
Harald Welte28d943e2017-11-25 15:00:50 +01007835}
7836
7837}