blob: f72ab22440fbeb6a5bc92bea57fb7bebe1dfad14 [file] [log] [blame]
Harald Welte28d943e2017-11-25 15:00:50 +01001module BSC_Tests {
2
Harald Welte21b46bd2017-12-17 19:46:32 +01003/* Integration Tests for OsmoBSC
Harald Weltea0630032018-03-20 21:09:55 +01004 * (C) 2017-2018 by Harald Welte <laforge@gnumonks.org>
Harald Welte21b46bd2017-12-17 19:46:32 +01005 * All rights reserved.
6 *
7 * Released under the terms of GNU General Public License, Version 2 or
8 * (at your option) any later version.
9 *
Harald Welte34b5a952019-05-27 11:54:11 +020010 * SPDX-License-Identifier: GPL-2.0-or-later
11 *
Harald Welte21b46bd2017-12-17 19:46:32 +010012 * This test suite tests OsmoBSC while emulating both multiple BTS + MS as
13 * well as the MSC. See README for more details.
14 *
15 * There are test cases that run in so-called 'handler mode' and test cases
16 * that run directly on top of the BSSAP and RSL CodecPorts. The "handler mode"
17 * tests abstract the multiplexing/demultiplexing of multiple SCCP connections
18 * and/or RSL channels and are hence suitable for higher-level test cases, while
19 * the "raw" tests directly on top of the CodecPorts are more suitable for lower-
20 * level testing.
21 */
22
Neels Hofmeyr4f118412020-06-04 15:25:10 +020023import from Misc_Helpers all;
Harald Welte4003d112017-12-09 22:35:39 +010024import from General_Types all;
Harald Welte28d943e2017-11-25 15:00:50 +010025import from Osmocom_Types all;
Harald Welteae026692017-12-09 01:03:01 +010026import from GSM_Types all;
Harald Welte28d943e2017-11-25 15:00:50 +010027import from IPL4asp_Types all;
28
Harald Welte6f521d82017-12-11 19:52:02 +010029import from BSSAP_Types all;
Harald Welte6811d102019-04-14 22:23:14 +020030import from RAN_Adapter all;
Harald Welte47cd0e32020-08-21 12:39:11 +020031import from BSSAP_LE_Adapter all;
32import from BSSAP_LE_CodecPort all;
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +020033import from BSSAP_LE_Types all;
34import from BSSLAP_Types all;
Harald Welteae026692017-12-09 01:03:01 +010035import from BSSAP_CodecPort all;
36import from BSSMAP_Templates all;
Harald Welte28d943e2017-11-25 15:00:50 +010037import from IPA_Emulation all;
Stefan Sperling830dc9d2018-02-12 21:08:28 +010038import from IPA_CodecPort all;
Harald Welteae026692017-12-09 01:03:01 +010039import from IPA_Types all;
Stefan Sperling0796a822018-10-05 13:01:39 +020040import from IPA_Testing all;
Harald Welteae026692017-12-09 01:03:01 +010041import from RSL_Types all;
Harald Welte624f9632017-12-16 19:26:04 +010042import from RSL_Emulation all;
Daniel Willmann191e0d92018-01-17 12:44:35 +010043import from MGCP_Emulation all;
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +010044import from MGCP_Templates all;
45import from MGCP_Types all;
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +020046import from MGCP_CodecPort all;
Harald Welte28d943e2017-11-25 15:00:50 +010047
Harald Welte96c94412017-12-09 03:12:45 +010048import from Osmocom_CTRL_Functions all;
Harald Weltea5d2ab22017-12-09 14:21:42 +010049import from Osmocom_CTRL_Types all;
Harald Welteffe55fc2018-01-17 22:39:54 +010050import from Osmocom_CTRL_Adapter all;
Harald Welte96c94412017-12-09 03:12:45 +010051
Daniel Willmannebdecc02020-08-12 15:30:17 +020052import from StatsD_Types all;
53import from StatsD_CodecPort all;
54import from StatsD_CodecPort_CtrlFunct all;
55import from StatsD_Checker all;
56
Harald Weltebc03c762018-02-12 18:09:38 +010057import from Osmocom_VTY_Functions all;
58import from TELNETasp_PortType all;
59
Harald Welte6f521d82017-12-11 19:52:02 +010060import from MobileL3_CommonIE_Types all;
Harald Weltee3bd6582018-01-31 22:51:25 +010061import from MobileL3_Types all;
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +010062import from MobileL3_RRM_Types all;
Harald Welte6f521d82017-12-11 19:52:02 +010063import from L3_Templates all;
64import from GSM_RR_Types all;
65
Stefan Sperlingc307e682018-06-14 15:15:46 +020066import from SCCP_Templates all;
Neels Hofmeyr4ff93282018-03-12 04:25:35 +010067import from BSSMAP_Templates all;
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +020068import from BSSMAP_LE_Templates all;
Neels Hofmeyr4ff93282018-03-12 04:25:35 +010069
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +010070import from SCCPasp_Types all;
71
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +020072import from GSM_SystemInformation all;
73import from GSM_RestOctets all;
Neels Hofmeyrad132f22020-07-08 02:20:16 +020074import from TCCConversion_Functions all;
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +020075
Harald Welte5d1a2202017-12-13 19:51:29 +010076const integer NUM_BTS := 3;
Neels Hofmeyrf246a922020-05-13 02:27:10 +020077const integer NUM_MSC := 3;
Harald Welteae026692017-12-09 01:03:01 +010078const float T3101_MAX := 12.0;
Harald Welte28d943e2017-11-25 15:00:50 +010079
Harald Welte799c97b2017-12-14 17:50:30 +010080/* make sure to sync this with the osmo-bts.cfg you're using */
Philipp Maiercb6cc482018-03-26 13:08:00 +020081const integer NUM_TCHH_PER_BTS := 2;
82const integer NUM_TCHF_PER_BTS := 4;
Neels Hofmeyr74083c22020-07-29 00:43:01 +020083const integer NUM_SDCCH_PER_BTS := 3;
Harald Welte799c97b2017-12-14 17:50:30 +010084
Harald Welte4003d112017-12-09 22:35:39 +010085
Harald Welte21b46bd2017-12-17 19:46:32 +010086/* per-BTS state which we keep */
Harald Welte96c94412017-12-09 03:12:45 +010087type record BTS_State {
Harald Welte21b46bd2017-12-17 19:46:32 +010088 /* component reference to the IPA_Client component used for RSL */
Harald Weltea5d2ab22017-12-09 14:21:42 +010089 IPA_Client rsl
Harald Welte96c94412017-12-09 03:12:45 +010090}
91
Neels Hofmeyr22c3f792020-06-17 02:49:28 +020092/* Default list of counters for an 'msc' entity. */
93const CounterNameVals counternames_msc_mscpool := {
94 { "mscpool:subscr:new", 0 },
95 { "mscpool:subscr:known", 0 },
96 { "mscpool:subscr:reattach", 0 },
97 { "mscpool:subscr:attach_lost", 0 },
98 { "mscpool:subscr:paged", 0 }
99};
100
Neels Hofmeyrbf037052020-10-28 22:52:02 +0000101/* List of global mscpool counters, not related to a specific 'msc' entity. */
102const CounterNameVals counternames_bsc_mscpool := {
103 { "mscpool:subscr:no_msc", 0 }
104};
105
Neels Hofmeyr12941bd2020-08-29 03:21:26 +0000106/* Default list of counters for 'bsc' and 'bts' entities. */
107const CounterNameVals counternames_bsc_bts_handover := {
108 { "assignment:attempted", 0 },
109 { "assignment:completed", 0 },
110 { "assignment:stopped", 0 },
111 { "assignment:no_channel", 0 },
112 { "assignment:timeout", 0 },
113 { "assignment:failed", 0 },
114 { "assignment:error", 0 },
115
116 { "handover:attempted", 0 },
117 { "handover:completed", 0 },
118 { "handover:stopped", 0 },
119 { "handover:no_channel", 0 },
120 { "handover:timeout", 0 },
121 { "handover:failed", 0 },
122 { "handover:error", 0 },
123
124 { "intra_cell_ho:attempted", 0 },
125 { "intra_cell_ho:completed", 0 },
126 { "intra_cell_ho:stopped", 0 },
127 { "intra_cell_ho:no_channel", 0 },
128 { "intra_cell_ho:timeout", 0 },
129 { "intra_cell_ho:failed", 0 },
130 { "intra_cell_ho:error", 0 },
131
132 { "intra_bsc_ho:attempted", 0 },
133 { "intra_bsc_ho:completed", 0 },
134 { "intra_bsc_ho:stopped", 0 },
135 { "intra_bsc_ho:no_channel", 0 },
136 { "intra_bsc_ho:timeout", 0 },
137 { "intra_bsc_ho:failed", 0 },
138 { "intra_bsc_ho:error", 0 },
139
140 { "interbsc_ho_out:attempted", 0 },
141 { "interbsc_ho_out:completed", 0 },
142 { "interbsc_ho_out:stopped", 0 },
143 { "interbsc_ho_out:timeout", 0 },
144 { "interbsc_ho_out:failed", 0 },
145 { "interbsc_ho_out:error", 0 },
146
147 { "interbsc_ho_in:attempted", 0 },
148 { "interbsc_ho_in:completed", 0 },
149 { "interbsc_ho_in:stopped", 0 },
150 { "interbsc_ho_in:no_channel", 0 },
151 { "interbsc_ho_in:timeout", 0 },
152 { "interbsc_ho_in:failed", 0 },
153 { "interbsc_ho_in:error", 0 }
154};
155
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +0200156/* Set of all System Information received during one RSL port's startup.
157 * Note that some System Information may be sent on RSL, but lacking actual SI data, to indicate that the BTS should not
158 * broadcast that SI type. That will be reflected as 'omit' here.
159 */
160type record SystemInformationConfig {
161 SystemInformationType1 si1 optional,
162 SystemInformationType2 si2 optional,
163 SystemInformationType2bis si2bis optional,
164 SystemInformationType2ter si2ter optional,
Neels Hofmeyrad132f22020-07-08 02:20:16 +0200165 SI2quaterRestOctetsList si2quater optional,
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +0200166 SystemInformationType3 si3 optional,
167 SystemInformationType4 si4 optional,
168 /* TODO: replace with proper decoding of SI13, implement SI13 in GSM_SystemInformation.ttcn */
169 octetstring si13 optional,
170 SystemInformationType5 si5 optional,
171 SystemInformationType5bis si5bis optional,
172 SystemInformationType5ter si5ter optional,
173 SystemInformationType6 si6 optional
174};
175
176const SystemInformationConfig SystemInformationConfig_omit := {
177 si1 := omit,
178 si2 := omit,
179 si2bis := omit,
180 si2ter := omit,
181 si2quater := omit,
182 si3 := omit,
183 si4 := omit,
184 si13 := omit,
185 si5 := omit,
186 si5bis := omit,
187 si5ter := omit,
188 si6 := omit
189};
190
191/* tr_EUTRAN_CellDesc with defaults used in BSC_Tests.ttcn */
192template EUTRAN_CellDesc tr_EUTRAN_CellDesc_default(template (present) uint16_t e_arfcn := ?,
193 template uint3_t meas_bw := 3)
194:= tr_EUTRAN_CellDesc(e_arfcn := e_arfcn,
195 meas_bw_presence := '1'B,
196 meas_bw := meas_bw);
197
198/* tr_EUTRAN_NeighbourCells with defaults used in BSC_Tests.ttcn */
Harald Welte65e419a2020-08-21 12:38:33 +0200199template EUTRAN_NeighbourCells tr_EUTRAN_NeighbourCells_default(template (present) EUTRAN_CellDescs cell_desc_list := { tr_EUTRAN_CellDesc_default },
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +0200200 template uint3_t prio := 3,
201 template (present) uint5_t thresh_high := 20,
202 template uint5_t thresh_low := 10,
203 template uint5_t qrxlevmin := 22)
204:= tr_EUTRAN_NeighbourCells(
205 cell_desc_list := cell_desc_list,
206 prio_presence := '1'B,
207 prio := prio,
208 thresh_high := thresh_high,
209 thresh_low_presence := '1'B,
210 thresh_low := thresh_low,
211 qrxlevmin_presence := '1'B,
212 qrxlevmin := qrxlevmin);
213
214template SystemInformationConfig SystemInformationConfig_default := {
215 si1 := {
216 cell_chan_desc := '8FB38000000000000000000000000000'O,
217 rach_control := {
218 max_retrans := RACH_MAX_RETRANS_7,
219 tx_integer := '1001'B,
220 cell_barr_access := false,
221 re_not_allowed := true,
222 acc := '0000010000000000'B
223 },
224 rest_octets := ?
225 },
226 si2 := {
227 bcch_freq_list := '00000000000000000000000000000000'O,
228 ncc_permitted := '11111111'B,
229 rach_control := {
230 max_retrans := RACH_MAX_RETRANS_7,
231 tx_integer := '1001'B,
232 cell_barr_access := false,
233 re_not_allowed := true,
234 acc := '0000010000000000'B
235 }
236 },
237 si2bis := omit,
238 si2ter := {
239 extd_bcch_freq_list := '8E320000000000000000000000000800'O,
240 rest_octets := ?
241 },
242 si2quater := {
243 tr_SI2quaterRestOctets_EUTRAN( repeated_neigh_cells := { tr_EUTRAN_NeighbourCells_default } )
244 },
245 si3 := {
246 cell_id := 0,
247 lai := {
248 mcc_mnc := '001F01'H,
249 lac := 1
250 },
251 ctrl_chan_desc := {
252 msc_r99 := true,
253 att := true,
254 bs_ag_blks_res := 1,
255 ccch_conf := CCHAN_DESC_1CCCH_COMBINED,
256 si22ind := false,
257 cbq3 := CBQ3_IU_MODE_NOT_SUPPORTED,
258 spare := '00'B,
259 bs_pa_mfrms := 3,
260 t3212 := 30
261 },
262 cell_options := {
263 dn_ind := false,
264 pwrc := false,
265 dtx := MS_SHALL_USE_UL_DTX,
266 radio_link_tout_div4 := 7
267 },
268 cell_sel_par := {
269 cell_resel_hyst_2dB := 2,
270 ms_txpwr_max_cch := 7,
271 acs := '0'B,
272 neci := true,
273 rxlev_access_min := 0
274 },
275 rach_control := {
276 max_retrans := RACH_MAX_RETRANS_7,
277 tx_integer := '1001'B,
278 cell_barr_access := false,
279 re_not_allowed := true,
280 acc := '0000010000000000'B
281 },
282 rest_octets := {
283 sel_params := {
284 presence := '0'B,
285 params := omit
286 },
287 pwr_offset := {
288 presence := '0'B,
289 offset := omit
290 },
291 si_2ter_ind := '1'B,
292 early_cm_ind := '0'B,
293 sched_where := {
294 presence := '0'B,
295 where := omit
296 },
297 gprs_ind := {
298 presence := '1'B,
299 ind := {
300 ra_colour := 0,
301 si13_pos := '0'B
302 }
303 },
304 umts_early_cm_ind := '1'B,
305 si2_quater_ind := {
306 presence := '1'B,
307 ind := '0'B
308 },
309 iu_mode_ind := omit,
310 si21_ind := {
311 presence := '0'B,
312 pos := omit
313 }
314 }
315 },
316 si4 := {
317 lai := {
318 mcc_mnc := '001F01'H,
319 lac := 1
320 },
321 cell_sel_par := {
322 cell_resel_hyst_2dB := 2,
323 ms_txpwr_max_cch := 7,
324 acs := '0'B,
325 neci := true,
326 rxlev_access_min := 0
327 },
328 rach_control := {
329 max_retrans := RACH_MAX_RETRANS_7,
330 tx_integer := '1001'B,
331 cell_barr_access := false,
332 re_not_allowed := true,
333 acc := '0000010000000000'B
334 },
Neels Hofmeyr74083c22020-07-29 00:43:01 +0200335 cbch_chan_desc := {
336 iei := '64'O,
337 v := {
338 chan_nr := {
339 u := {
340 sdcch4 := {
341 tag := '001'B,
342 sub_chan := 2
343 }
344 },
345 tn := 0
346 },
347 tsc := 2,
348 h := false,
349 arfcn := 871,
350 maio_hsn := omit
351 }
352 },
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +0200353 cbch_mobile_alloc := omit,
354 rest_octets := {
355 sel_params := {
356 presence := '0'B,
357 params := omit
358 },
359 pwr_offset := {
360 presence := '0'B,
361 offset := omit
362 },
363 gprs_ind := {
364 presence := '1'B,
365 ind := {
366 ra_colour := 0,
367 si13_pos := '0'B
368 }
369 },
370 s_presence := '0'B,
371 s := omit
372 }
373 },
374 si13 := '9000185A6FC9E08410AB2B2B2B2B2B2B2B2B2B2B'O,
375 si5 := {
376 bcch_freq_list := '10000000000000000000000000000000'O
377 },
378 si5bis := omit,
379 si5ter := {
380 extd_bcch_freq_list := '9E050020000000000000000000000000'O
381 },
382 si6 := {
383 cell_id := 0,
384 lai := {
385 mcc_mnc := '001F01'H,
386 lac := 1
387 },
388 cell_options := {
389 dtx_ext := '1'B,
390 pwrc := false,
391 dtx := '01'B,
392 radio_link_timeout := '0111'B
393 },
394 ncc_permitted := '11111111'B,
395 rest_octets := ?
396 }
397 };
398
399
400/* List of all the System Information received on all RSL ports */
401type record of SystemInformationConfig SystemInformationConfig_list;
402
403function f_sysinfo_dec_raw(inout SystemInformationConfig si, RSL_Message rsl)
404{
405 var RSL_IE_Body sysinfo_type_ie;
406 var RSL_IE_SysinfoType si_type;
407 var octetstring data;
408
409 if (f_rsl_find_ie(rsl, RSL_IE_SYSINFO_TYPE, sysinfo_type_ie) == false) {
410 setverdict(fail, "Cannot find RSL_IE_SYSINFO_TYPE");
411 mtc.stop;
412 }
413 si_type := sysinfo_type_ie.sysinfo_type;
414
415 if (rsl.msg_type == RSL_MT_BCCH_INFO) {
416 var RSL_IE_Body bcch_ie;
417 if (f_rsl_find_ie(rsl, RSL_IE_FULL_BCCH_INFO, bcch_ie)) {
418 data := bcch_ie.other.payload;
419 }
420 } else if (rsl.msg_type == RSL_MT_SACCH_FILL) {
421 var RSL_IE_Body l3_ie;
422 if (f_rsl_find_ie(rsl, RSL_IE_L3_INFO, l3_ie)) {
423 data := l3_ie.l3_info.payload;
424 }
425 } else {
426 setverdict(fail, "Don't understand this System Information message");
427 mtc.stop;
428 }
429
430 var boolean handled := false;
431
432 if (rsl.msg_type == RSL_MT_BCCH_INFO) {
433 handled := true;
434
435 if (si_type == RSL_SYSTEM_INFO_1) {
436 if (not isbound(data)) {
437 si.si1 := omit;
438 } else {
439 si.si1 := dec_SystemInformation(data).payload.si1;
440 }
441 } else if (si_type == RSL_SYSTEM_INFO_2) {
442 if (not isbound(data)) {
443 si.si2 := omit;
444 } else {
445 si.si2 := dec_SystemInformation(data).payload.si2;
446 }
447 } else if (si_type == RSL_SYSTEM_INFO_2bis) {
448 if (not isbound(data)) {
449 si.si2bis := omit;
450 } else {
451 si.si2bis := dec_SystemInformation(data).payload.si2bis;
452 }
453 } else if (si_type == RSL_SYSTEM_INFO_2ter) {
454 if (not isbound(data)) {
455 si.si2ter := omit;
456 } else {
457 si.si2ter := dec_SystemInformation(data).payload.si2ter;
458 }
459 } else if (si_type == RSL_SYSTEM_INFO_2quater) {
460 if (not isbound(data)) {
461 si.si2quater := {};
462 } else {
463 var SystemInformationType2quater decoded := dec_SystemInformation(data).payload.si2quater;
464 /* this is a *record* of SI2quaterRestOctets! (multiplexed) */
465 si.si2quater[decoded.rest_octets.si2quater_index] := decoded.rest_octets;
466 }
467 } else if (si_type == RSL_SYSTEM_INFO_3) {
468 if (not isbound(data)) {
469 si.si3 := omit;
470 } else {
471 si.si3 := dec_SystemInformation(data).payload.si3;
472 }
473 } else if (si_type == RSL_SYSTEM_INFO_4) {
474 if (not isbound(data)) {
475 si.si4 := omit;
476 } else {
477 si.si4 := dec_SystemInformation(data).payload.si4;
478 }
479 } else if (si_type == RSL_SYSTEM_INFO_13) {
480 if (not isbound(data)) {
481 si.si13 := omit;
482 } else {
483 si.si13 := dec_SystemInformation(data).payload.other;
484 }
485 } else {
486 handled := false;
487 }
488 } else if (rsl.msg_type == RSL_MT_SACCH_FILL) {
489 handled := true;
490
491 if (si_type == RSL_SYSTEM_INFO_5) {
492 if (not isbound(data)) {
493 si.si5 := omit;
494 } else {
495 si.si5 := dec_SystemInformation(data).payload.si5;
496 }
497 } else if (si_type == RSL_SYSTEM_INFO_5bis) {
498 if (not isbound(data)) {
499 si.si5bis := omit;
500 } else {
501 si.si5bis := dec_SystemInformation(data).payload.si5bis;
502 }
503 } else if (si_type == RSL_SYSTEM_INFO_5ter) {
504 if (not isbound(data)) {
505 si.si5ter := omit;
506 } else {
507 si.si5ter := dec_SystemInformation(data).payload.si5ter;
508 }
509 } else if (si_type == RSL_SYSTEM_INFO_6) {
510 if (not isbound(data)) {
511 si.si6 := omit;
512 } else {
513 si.si6 := dec_SystemInformation(data).payload.si6;
514 }
515 } else {
516 handled := false;
517 }
518 }
519
520 if (not handled) {
521 setverdict(fail, "Unexpected SI type in ", rsl.msg_type, " message: ", si_type);
522 }
523}
524
Harald Weltea4ca4462018-02-09 00:17:14 +0100525type component test_CT extends CTRL_Adapter_CT {
Harald Welte21b46bd2017-12-17 19:46:32 +0100526 /* Array of per-BTS state */
Harald Welte96c94412017-12-09 03:12:45 +0100527 var BTS_State bts[NUM_BTS];
Harald Welte89ab1912018-02-23 18:56:29 +0100528 /* RSL common Channel Port (for RSL_Emulation) */
529 port RSL_CCHAN_PT RSL_CCHAN[NUM_BTS];
Harald Welte21b46bd2017-12-17 19:46:32 +0100530 /* array of per-BTS RSL test ports */
Harald Welteae026692017-12-09 01:03:01 +0100531 port IPA_RSL_PT IPA_RSL[NUM_BTS];
Stefan Sperling830dc9d2018-02-12 21:08:28 +0100532 port IPA_CODEC_PT IPA; /* Required for compilation of TC_rsl_unknown_unit_id() */
Pau Espin Pedrol5a2d7432019-06-07 19:43:45 +0200533 /* CTRL muxed over IPA in SCCPlite conn BSC<->MSC (or BSC-NAT) */
534 port IPA_CTRL_PT SCCPLITE_IPA_CTRL;
Harald Weltea5d2ab22017-12-09 14:21:42 +0100535
Daniel Willmann191e0d92018-01-17 12:44:35 +0100536 var MGCP_Emulation_CT vc_MGCP;
Harald Weltebc03c762018-02-12 18:09:38 +0100537 port TELNETasp_PT BSCVTY;
Daniel Willmann191e0d92018-01-17 12:44:35 +0100538
Daniel Willmannebdecc02020-08-12 15:30:17 +0200539 /* StatsD */
540 var StatsD_Checker_CT vc_STATSD;
541
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200542 var RAN_Adapter g_bssap[NUM_MSC];
Harald Welte47cd0e32020-08-21 12:39:11 +0200543 var BSSAP_LE_Adapter g_bssap_le;
Harald Weltea4ca4462018-02-09 00:17:14 +0100544 /* for old legacy-tests only */
545 port BSSAP_CODEC_PT BSSAP;
Harald Welte47cd0e32020-08-21 12:39:11 +0200546 port BSSAP_LE_CODEC_PT BSSAP_LE;
Harald Weltea4ca4462018-02-09 00:17:14 +0100547
Harald Welte21b46bd2017-12-17 19:46:32 +0100548 /* are we initialized yet */
Harald Welte28d943e2017-11-25 15:00:50 +0100549 var boolean g_initialized := false;
Harald Welte21b46bd2017-12-17 19:46:32 +0100550
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200551 /* Osmux is enabled through VTY */
552 var boolean g_osmux_enabled := false;
553
Pau Espin Pedrolc675b612020-01-09 19:55:40 +0100554 /*Configure T(tias) over VTY, seconds */
555 var integer g_bsc_sccp_timer_ias := 7 * 60;
556 /*Configure T(tiar) over VTY, seconds */
557 var integer g_bsc_sccp_timer_iar := 15 * 60;
558
Neels Hofmeyr4fbad7f2020-06-16 00:30:47 +0200559 /* global test case guard timer (actual timeout value is set in f_init()) */
Harald Welteae026692017-12-09 01:03:01 +0100560 timer T_guard := 30.0;
561
Neels Hofmeyr22c3f792020-06-17 02:49:28 +0200562 var CounterNameValsList g_ctr_msc;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +0000563 var CounterNameValsList g_ctr_bsc;
564 var CounterNameValsList g_ctr_bts;
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +0200565
566 /* System Information bytes as received during RSL startup, for each RSL[idx]. */
567 var SystemInformationConfig_list g_system_information := {};
Harald Welte28d943e2017-11-25 15:00:50 +0100568}
569
570modulepar {
Harald Welte21b46bd2017-12-17 19:46:32 +0100571 /* IP address at which the BSC can be reached */
Harald Welte696ddb62017-12-08 14:01:43 +0100572 charstring mp_bsc_ip := "127.0.0.1";
Stefan Sperling830dc9d2018-02-12 21:08:28 +0100573 /* port number to which to establish the IPA OML connections */
574 integer mp_bsc_oml_port := 3002;
Harald Welte21b46bd2017-12-17 19:46:32 +0100575 /* port number to which to establish the IPA RSL connections */
Harald Welte696ddb62017-12-08 14:01:43 +0100576 integer mp_bsc_rsl_port := 3003;
Harald Welte21b46bd2017-12-17 19:46:32 +0100577 /* port number to which to establish the IPA CTRL connection */
Harald Welte96c94412017-12-09 03:12:45 +0100578 integer mp_bsc_ctrl_port := 4249;
Daniel Willmannebdecc02020-08-12 15:30:17 +0200579 /* port number to which to listen for STATSD metrics */
580 integer mp_bsc_statsd_port := 8125;
Daniel Willmann191e0d92018-01-17 12:44:35 +0100581 /* IP address at which the test binds */
582 charstring mp_test_ip := "127.0.0.1";
Harald Weltea4ca4462018-02-09 00:17:14 +0100583
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200584 RAN_Configurations mp_bssap_cfg := {
585 {
586 transport := BSSAP_TRANSPORT_AoIP,
587 sccp_service_type := "mtp3_itu",
588 sctp_addr := { 23905, "127.0.0.1", 2905, "127.0.0.1" },
589 own_pc := 185, /* 0.23.1 first MSC emulation */
590 own_ssn := 254,
591 peer_pc := 187, /* 0.23.3 osmo-bsc */
592 peer_ssn := 254,
593 sio := '83'O,
Harald Weltecb0cc432020-06-21 19:42:31 +0200594 rctx := 1
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200595 },
596 {
597 transport := BSSAP_TRANSPORT_AoIP,
598 sccp_service_type := "mtp3_itu",
599 sctp_addr := { 23906, "127.0.0.1", 2905, "127.0.0.1" },
600 own_pc := 2, /* 0.0.2 second MSC emulation */
601 own_ssn := 254,
602 peer_pc := 187, /* 0.23.3 osmo-bsc */
603 peer_ssn := 254,
604 sio := '83'O,
605 rctx := 2
606 },
607 {
608 transport := BSSAP_TRANSPORT_AoIP,
609 sccp_service_type := "mtp3_itu",
610 sctp_addr := { 23907, "127.0.0.1", 2905, "127.0.0.1" },
611 own_pc := 3, /* 0.0.3 third MSC emulation */
612 own_ssn := 254,
613 peer_pc := 187, /* 0.23.3 osmo-bsc */
614 peer_ssn := 254,
615 sio := '83'O,
616 rctx := 3
617 }
Harald Weltea4ca4462018-02-09 00:17:14 +0100618 };
Pau Espin Pedrol58cf6822019-05-28 18:11:33 +0200619
Harald Welte47cd0e32020-08-21 12:39:11 +0200620 BSSAP_LE_Configuration mp_bssap_le_cfg := {
621 sccp_service_type := "mtp3_itu",
622 sctp_addr := { 23908, "127.0.0.1", 2905, "127.0.0.1" },
Neels Hofmeyrac086c12020-09-18 23:46:42 +0200623 own_pc := 190, /* 0.23.6 SMLC emulation */
Harald Welte47cd0e32020-08-21 12:39:11 +0200624 own_ssn := 252, /* SMLC side SSN */
625 peer_pc := 187, /* 0.23.3 osmo-bsc */
626 peer_ssn := 250, /* BSC side SSN */
627 sio := '83'O,
628 rctx := 6
629 };
Neels Hofmeyrcfe44062020-10-15 02:28:08 +0200630 boolean mp_enable_lcs_tests := true;
Harald Welte47cd0e32020-08-21 12:39:11 +0200631
Pau Espin Pedrol58cf6822019-05-28 18:11:33 +0200632 /* Whether to enable osmux tests. Can be dropped completely and enable
633 unconditionally once new version of osmo-bsc is released (current
634 version: 1.4.1) */
635 boolean mp_enable_osmux_test := true;
Pau Espin Pedrol8f30ccd2019-11-01 17:30:57 +0100636 /* Value set in osmo-bsc.cfg "ms max power" */
637 uint8_t mp_exp_ms_power_level := 7;
Philipp Maiera2083892020-09-21 14:18:36 +0200638
639 boolean mp_media_mgw_offer_ipv6 := true;
Harald Weltea4ca4462018-02-09 00:17:14 +0100640}
641
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200642private function f_gen_test_hdlr_pars(integer bssap_idx := 0) return TestHdlrParams {
Philipp Maier48604732018-10-09 15:00:37 +0200643
644 var TestHdlrParams pars := valueof(t_def_TestHdlrPars);
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200645 if (mp_bssap_cfg[bssap_idx].transport == BSSAP_TRANSPORT_AoIP) {
Philipp Maier48604732018-10-09 15:00:37 +0200646 pars.aoip := true;
647 } else {
648 pars.aoip := false;
649 }
Pau Espin Pedrol8f30ccd2019-11-01 17:30:57 +0100650 pars.exp_ms_power_level := mp_exp_ms_power_level;
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200651 pars.mscpool.bssap_idx := bssap_idx;
Philipp Maiera2083892020-09-21 14:18:36 +0200652 pars.media_mgw_offer_ipv6 := mp_media_mgw_offer_ipv6;
Philipp Maier48604732018-10-09 15:00:37 +0200653
654 return pars;
655}
656
Neels Hofmeyr22c3f792020-06-17 02:49:28 +0200657/* Convenience functions for rate counters using g_ctr_msc. */
658
659private function f_ctrs_msc_init(integer mscs_count := NUM_MSC, CounterNameVals counternames := counternames_msc_mscpool) runs on test_CT {
660 g_ctr_msc := f_counter_name_vals_get_n(IPA_CTRL, "msc", mscs_count, counternames);
661 log("initial msc rate counters: ", g_ctr_msc);
662}
663
664private function f_ctrs_msc_add(integer msc_nr, charstring countername, integer val := 1) runs on test_CT {
Neels Hofmeyr9656e922020-06-30 01:27:01 +0200665 f_counter_name_vals_list_add(g_ctr_msc, msc_nr, countername, val);
Neels Hofmeyr22c3f792020-06-17 02:49:28 +0200666}
667
668/* f_ctrs_msc_init();
669 * f_do_thing(on_msc := 0);
670 * f_do_thing(on_msc := 0);
671 * f_do_other(on_msc := 1);
672 * f_ctrs_msc_add(0, "thing", 2);
673 * f_ctrs_msc_add(1, "other");
674 * f_ctrs_msc_verify();
675 */
676private function f_ctrs_msc_verify() runs on test_CT {
677 log("verifying msc rate counters: ", g_ctr_msc);
678 f_counter_name_vals_expect_n(IPA_CTRL, "msc", g_ctr_msc);
679}
680
681/* convenience: f_ctrs_msc_add() and f_ctrs_msc_verify() in one call.
682 * f_ctrs_msc_init();
683 * f_do_thing(on_msc := 0);
684 * f_do_thing(on_msc := 0);
685 * f_do_thing(on_msc := 0);
686 * f_ctrs_msc_expect(0, "thing", 3);
687 */
688private function f_ctrs_msc_expect(integer msc_nr, charstring countername, integer val := 1) runs on test_CT {
689 f_ctrs_msc_add(msc_nr, countername, val);
690 f_ctrs_msc_verify();
691}
692
Neels Hofmeyr12941bd2020-08-29 03:21:26 +0000693/* Convenience functions for rate counters using g_ctr_bts, always also including g_ctr_bsc. */
694
695private function f_ctrs_bsc_and_bts_init(integer bts_count := NUM_BTS, CounterNameVals counternames := counternames_bsc_bts_handover) runs on test_CT {
696 g_ctr_bts := f_counter_name_vals_get_n(IPA_CTRL, "bts", bts_count, counternames);
697 log("initial bts rate counters: ", g_ctr_bts);
698 f_ctrs_bsc_init(counternames);
699}
700
701private function f_ctrs_bsc_and_bts_add(integer bts_nr, charstring countername, integer val := 1) runs on test_CT {
702 f_counter_name_vals_list_add(g_ctr_bts, bts_nr, countername, val);
703 f_ctrs_bsc_add(countername, val);
704}
705
706/* f_ctrs_bsc_and_bts_init();
707 * f_do_thing(on_bts := 0);
708 * f_do_thing(on_bts := 0);
709 * f_do_other(on_bts := 1);
710 * f_ctrs_bsc_and_bts_add(0, "thing", 2);
711 * f_ctrs_bsc_and_bts_add(1, "other");
712 * f_ctrs_bsc_and_bts_verify();
713 */
714private function f_ctrs_bsc_and_bts_verify() runs on test_CT {
715 f_counter_name_vals_expect_n(IPA_CTRL, "bts", g_ctr_bts);
716 f_ctrs_bsc_verify();
717}
718
719/* convenience: f_ctrs_bsc_and_bts_add() and f_ctrs_bsc_and_bts_verify() in one call.
720 * f_ctrs_bsc_and_bts_init();
721 * f_do_thing(on_bts := 0);
722 * f_do_thing(on_bts := 0);
723 * f_do_thing(on_bts := 0);
724 * f_ctrs_bsc_and_bts_expect(0, "thing", 3);
725 */
726private function f_ctrs_bsc_and_bts_expect(integer bts_nr, charstring countername, integer val := 1) runs on test_CT {
727 f_ctrs_bsc_and_bts_add(bts_nr, countername, val);
728 f_ctrs_bsc_and_bts_verify();
729}
730
731
732/* Convenience functions for rate counters using g_ctr_bsc. */
733
734private function f_ctrs_bsc_init(CounterNameVals counternames := counternames_bsc_bts_handover) runs on test_CT {
735 g_ctr_bsc := f_counter_name_vals_get_n(IPA_CTRL, "bsc", 1, counternames);
736 log("initial bsc rate counters: ", g_ctr_bsc);
737}
738
739private function f_ctrs_bsc_add(charstring countername, integer val := 1) runs on test_CT {
740 f_counter_name_vals_list_add(g_ctr_bsc, 0, countername, val);
741}
742
743/* f_ctrs_bsc_init();
744 * f_do_thing();
745 * f_do_thing();
746 * f_do_other();
747 * f_ctrs_bsc_add("thing", 2);
748 * f_ctrs_bsc_add("other");
749 * f_ctrs_bsc_verify();
750 */
751private function f_ctrs_bsc_verify() runs on test_CT {
752 f_counter_name_vals_expect_n(IPA_CTRL, "bsc", g_ctr_bsc);
753}
754
755/* convenience: f_ctrs_bsc_add() and f_ctrs_bsc_verify() in one call.
756 * f_ctrs_bsc_init();
757 * f_do_thing();
758 * f_ctrs_bsc_expect("thing", 1);
759 */
760private function f_ctrs_bsc_expect(charstring countername, integer val := 1) runs on test_CT {
761 f_ctrs_bsc_add(countername, val);
762 f_ctrs_bsc_verify();
763}
764
Neels Hofmeyr22c3f792020-06-17 02:49:28 +0200765
Philipp Maier282ca4b2018-02-27 17:17:00 +0100766private function f_shutdown_helper() runs on test_CT {
Daniel Willmann637ef6c2018-07-25 10:49:09 +0200767 all component.stop;
Philipp Maier282ca4b2018-02-27 17:17:00 +0100768 setverdict(pass);
Daniel Willmannafce8662018-07-06 23:11:32 +0200769 mtc.stop;
Philipp Maier282ca4b2018-02-27 17:17:00 +0100770}
771
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200772private function f_legacy_bssap_reset(integer bssap_idx := 0) runs on test_CT {
Harald Weltea4ca4462018-02-09 00:17:14 +0100773 var BSSAP_N_UNITDATA_ind ud_ind;
Pau Espin Pedrol24c05992020-09-01 12:54:12 +0200774 var boolean reset_received := false;
Harald Weltea4ca4462018-02-09 00:17:14 +0100775 timer T := 5.0;
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200776 BSSAP.send(ts_BSSAP_UNITDATA_req(g_bssap[bssap_idx].sccp_addr_peer, g_bssap[bssap_idx].sccp_addr_own,
777 ts_BSSMAP_Reset(0, g_osmux_enabled)));
Harald Weltea4ca4462018-02-09 00:17:14 +0100778 T.start;
779 alt {
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200780 [] BSSAP.receive(tr_BSSAP_UNITDATA_ind(g_bssap[bssap_idx].sccp_addr_own, g_bssap[bssap_idx].sccp_addr_peer,
781 tr_BSSMAP_ResetAck(g_osmux_enabled))) {
Neels Hofmeyr4f5d7be2020-10-16 16:28:16 +0200782 log("BSSMAP: Received RESET-ACK in response to RESET, we're ready to go!");
Harald Weltea4ca4462018-02-09 00:17:14 +0100783 }
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200784 [] BSSAP.receive(tr_BSSAP_UNITDATA_ind(?, ?, tr_BSSMAP_Reset(g_osmux_enabled))) -> value ud_ind {
Neels Hofmeyr4f5d7be2020-10-16 16:28:16 +0200785 log("BSSMAP: Respoding to inbound RESET with RESET-ACK");
Harald Weltea4ca4462018-02-09 00:17:14 +0100786 BSSAP.send(ts_BSSAP_UNITDATA_req(ud_ind.callingAddress, ud_ind.calledAddress,
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200787 ts_BSSMAP_ResetAck(g_osmux_enabled)));
Pau Espin Pedrol24c05992020-09-01 12:54:12 +0200788 reset_received := true;
Harald Weltea4ca4462018-02-09 00:17:14 +0100789 repeat;
790 }
791 [] BSSAP.receive { repeat; }
Pau Espin Pedrol24c05992020-09-01 12:54:12 +0200792 [] T.timeout {
Neels Hofmeyr4f5d7be2020-10-16 16:28:16 +0200793 log("BSSMAP: Timeout waiting for RESET-ACK after sending RESET");
Pau Espin Pedrol24c05992020-09-01 12:54:12 +0200794 /* If we received a RESET after ours was sent, it
795 may be a race condition where the other peer beacame
796 available after we sent it, but we are in a desired
797 state anyway, so go forward. */
798 if (not reset_received) {
799 setverdict(fail);
800 }
801 }
Harald Weltea4ca4462018-02-09 00:17:14 +0100802 }
Harald Welte28d943e2017-11-25 15:00:50 +0100803}
804
Harald Welteae026692017-12-09 01:03:01 +0100805type record IPA_Client {
Harald Welte21b46bd2017-12-17 19:46:32 +0100806 /* IPA Emulation component reference */
Harald Welteae026692017-12-09 01:03:01 +0100807 IPA_Emulation_CT vc_IPA,
Harald Welte21b46bd2017-12-17 19:46:32 +0100808 /* Unit-ID and other CCM parameters to use for IPA client emulation */
Harald Welteae026692017-12-09 01:03:01 +0100809 IPA_CCM_Parameters ccm_pars,
Harald Welte21b46bd2017-12-17 19:46:32 +0100810 /* String identifier for this IPA Client */
Harald Welte624f9632017-12-16 19:26:04 +0100811 charstring id,
Harald Welte21b46bd2017-12-17 19:46:32 +0100812 /* Associated RSL Emulation Component (if any). Only used in "Handler mode" */
Harald Welte624f9632017-12-16 19:26:04 +0100813 RSL_Emulation_CT vc_RSL optional
Harald Welte28d943e2017-11-25 15:00:50 +0100814}
815
Harald Welte21b46bd2017-12-17 19:46:32 +0100816/*! Start the IPA/RSL related bits for one IPA_Client.
817 * \param clnt IPA_Client for which to establish
818 * \param bsc_host IP address / hostname of the BSC
819 * \param bsc_port TCP port number of the BSC
820 * \param i number identifying this BTS
821 * \param handler_mode Start an RSL_Emulation_CT component (true) or not (false) */
Harald Welte624f9632017-12-16 19:26:04 +0100822function f_ipa_rsl_start(inout IPA_Client clnt, charstring bsc_host, PortNumber bsc_port, integer i,
823 boolean handler_mode := false)
Harald Welte28d943e2017-11-25 15:00:50 +0100824runs on test_CT {
Harald Welteae026692017-12-09 01:03:01 +0100825 timer T := 10.0;
826
Harald Welte96c94412017-12-09 03:12:45 +0100827 clnt.id := "IPA" & int2str(i) & "-RSL";
Harald Welteae026692017-12-09 01:03:01 +0100828 clnt.vc_IPA := IPA_Emulation_CT.create(clnt.id & "-IPA");
829 clnt.ccm_pars := c_IPA_default_ccm_pars;
830 clnt.ccm_pars.name := "Osmocom TTCN-3 BTS Simulator";
831 clnt.ccm_pars.unit_id := int2str(1234+i) & "/0/0";
Harald Welte624f9632017-12-16 19:26:04 +0100832 if (handler_mode) {
833 clnt.vc_RSL := RSL_Emulation_CT.create(clnt.id & "-RSL");
Harald Welte89ab1912018-02-23 18:56:29 +0100834 connect(clnt.vc_RSL:CCHAN_PT, self:RSL_CCHAN[i]);
Harald Welte624f9632017-12-16 19:26:04 +0100835 }
Harald Welteae026692017-12-09 01:03:01 +0100836
837 map(clnt.vc_IPA:IPA_PORT, system:IPA_CODEC_PT);
Harald Welte624f9632017-12-16 19:26:04 +0100838 if (handler_mode) {
839 connect(clnt.vc_IPA:IPA_RSL_PORT, clnt.vc_RSL:IPA_PT);
840 } else {
841 connect(clnt.vc_IPA:IPA_RSL_PORT, self:IPA_RSL[i]);
842 }
Harald Welteae026692017-12-09 01:03:01 +0100843
Harald Welte5d1a2202017-12-13 19:51:29 +0100844 clnt.vc_IPA.start(IPA_Emulation.main_client(bsc_host, bsc_port, "", 10000+i, clnt.ccm_pars));
Harald Welte624f9632017-12-16 19:26:04 +0100845 if (handler_mode) {
846 clnt.vc_RSL.start(RSL_Emulation.main());
847 return;
848 }
Harald Welteae026692017-12-09 01:03:01 +0100849
850 /* wait for IPA RSL link to connect and send ID ACK */
851 T.start;
852 alt {
Vadim Yanitskiya2afacc2020-05-18 21:16:19 +0700853 [] IPA_RSL[i].receive(tr_ASP_IPA_EV(ASP_IPA_EVENT_ID_ACK)) {
Harald Welteae026692017-12-09 01:03:01 +0100854 T.stop;
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +0700855 IPA_RSL[i].send(ts_ASP_RSL_UD(ts_RSL_PAGING_LOAD_IND(23)));
Harald Welteae026692017-12-09 01:03:01 +0100856 }
Harald Welte60e823a2017-12-10 14:10:59 +0100857 [] IPA_RSL[i].receive(ASP_IPA_Event:?) { repeat }
Harald Welteae026692017-12-09 01:03:01 +0100858 [] IPA_RSL[i].receive { repeat }
859 [] T.timeout {
Harald Welte96c94412017-12-09 03:12:45 +0100860 setverdict(fail, "Timeout RSL waiting for ASP_IPA_EVENT_ID_ACK");
Daniel Willmannafce8662018-07-06 23:11:32 +0200861 mtc.stop;
Harald Welteae026692017-12-09 01:03:01 +0100862 }
863 }
864}
865
Harald Welte12055472018-03-17 20:10:08 +0100866function f_ipa_rsl_stop(inout IPA_Client clnt) runs on test_CT {
867 if (not isbound(clnt) or not isbound(clnt.vc_IPA)) {
868 return;
869 }
870 clnt.vc_IPA.stop;
871 if (isbound(clnt.vc_RSL)) {
872 clnt.vc_RSL.stop;
873 }
874}
875
Harald Welte21b46bd2017-12-17 19:46:32 +0100876/* Wait for the OML connection to be brought up by the external osmo-bts-omldummy */
Harald Weltea5d2ab22017-12-09 14:21:42 +0100877function f_wait_oml(integer bts_nr, charstring status, float secs_max) runs on test_CT {
878 timer T := secs_max;
879 T.start;
880 while (true) {
881 if (f_ctrl_get_bts(IPA_CTRL, bts_nr, "oml-connection-state") == status) {
882 T.stop;
Harald Weltebd868bd2017-12-10 18:28:40 +0100883 /* the 'degraded' state exists from OML connection time, and we have to wait
884 * until all MO's are initialized */
885 T.start(1.0);
886 T.timeout;
Harald Weltea5d2ab22017-12-09 14:21:42 +0100887 return;
888 }
Harald Weltef0d6ac62017-12-17 17:02:21 +0100889 f_sleep(0.1);
Harald Weltea5d2ab22017-12-09 14:21:42 +0100890 if (not T.running) {
Max99253902018-11-16 17:57:39 +0100891 setverdict(fail, "Timeout waiting for BTS" & int2str(bts_nr) & " oml-connection-state ", status);
Daniel Willmannafce8662018-07-06 23:11:32 +0200892 mtc.stop;
Harald Weltea5d2ab22017-12-09 14:21:42 +0100893 }
894 }
895}
896
Harald Welte21b46bd2017-12-17 19:46:32 +0100897/* global altstep for global guard timer; also takes care of responding RESET witH RESET-ACK */
Harald Welteae026692017-12-09 01:03:01 +0100898altstep as_Tguard() runs on test_CT {
Harald Welte60e823a2017-12-10 14:10:59 +0100899 var BSSAP_N_UNITDATA_ind ud_ind;
Neels Hofmeyrcc3f76a2018-03-12 01:43:25 +0100900 [] T_guard.timeout {
901 setverdict(fail, "Timeout of T_guard");
Daniel Willmannafce8662018-07-06 23:11:32 +0200902 mtc.stop;
Neels Hofmeyrcc3f76a2018-03-12 01:43:25 +0100903 }
Harald Welte60e823a2017-12-10 14:10:59 +0100904 /* always respond with RESET ACK to RESET */
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200905 [] BSSAP.receive(tr_BSSAP_UNITDATA_ind(?, ?, tr_BSSMAP_Reset(g_osmux_enabled))) -> value ud_ind {
Harald Welte60e823a2017-12-10 14:10:59 +0100906 BSSAP.send(ts_BSSAP_UNITDATA_req(ud_ind.callingAddress, ud_ind.calledAddress,
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200907 ts_BSSMAP_ResetAck(g_osmux_enabled)));
Harald Welte69c1c262017-12-13 21:02:08 +0100908 repeat;
Harald Welte60e823a2017-12-10 14:10:59 +0100909 }
Harald Welte28d943e2017-11-25 15:00:50 +0100910}
911
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +0100912altstep no_bssmap_reset() runs on test_CT {
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200913 [] BSSAP.receive(tr_BSSAP_UNITDATA_ind(?, ?, tr_BSSMAP_Reset(g_osmux_enabled))) {
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +0100914 setverdict(fail, "unexpected BSSMAP Reset");
Daniel Willmannafce8662018-07-06 23:11:32 +0200915 mtc.stop;
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +0100916 }
917}
918
Daniel Willmann191e0d92018-01-17 12:44:35 +0100919function f_init_mgcp(charstring id) runs on test_CT {
920 id := id & "-MGCP";
921
922 var MGCPOps ops := {
923 create_cb := refers(MGCP_Emulation.ExpectedCreateCallback),
924 unitdata_cb := refers(MGCP_Emulation.DummyUnitdataCallback)
925 };
926 var MGCP_conn_parameters mgcp_pars := {
927 callagent_ip := mp_bsc_ip,
Harald Welte9e4273e2018-01-29 22:01:22 +0100928 callagent_udp_port := -1,
Daniel Willmann191e0d92018-01-17 12:44:35 +0100929 mgw_ip := mp_test_ip,
Pau Espin Pedrol1a026a52019-06-18 17:21:52 +0200930 mgw_udp_port := 2427,
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +0200931 /* Enable it for SCCPlite, since we have 2 MGCP sockets towards MGW (UDP one +
932 the on with MGCP over IPA forwarded from MSC one) */
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200933 multi_conn_mode := (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_SCCPlite_SERVER)
Daniel Willmann191e0d92018-01-17 12:44:35 +0100934 };
935
936 vc_MGCP := MGCP_Emulation_CT.create(id);
937 vc_MGCP.start(MGCP_Emulation.main(ops, mgcp_pars, id));
938}
939
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200940/* Enable or disable (current default) Osmux. When enabling, BSSMAP Reset
941 * contains extra IE (OsmuxSupport) and osmo-bsc will handle AssignReq with
942 * OsmuxCID IE.
943 */
944private function f_vty_allow_osmux(boolean allow) runs on test_CT {
945 f_vty_enter_cfg_msc(BSCVTY, 0);
946 if (allow) {
947 f_vty_transceive(BSCVTY, "osmux on");
948 } else {
949 f_vty_transceive(BSCVTY, "osmux off");
950 }
951 f_vty_transceive(BSCVTY, "exit");
952 f_vty_transceive(BSCVTY, "exit");
953 g_osmux_enabled := allow;
954}
955
Max2253c0b2018-11-06 19:28:05 +0100956function f_init_vty(charstring id := "foo") runs on test_CT {
Harald Welte94e0c342018-04-07 11:33:23 +0200957 if (BSCVTY.checkstate("Mapped")) {
958 /* skip initialization if already executed once */
959 return;
960 }
Harald Weltebc03c762018-02-12 18:09:38 +0100961 map(self:BSCVTY, system:BSCVTY);
962 f_vty_set_prompts(BSCVTY);
963 f_vty_transceive(BSCVTY, "enable");
Pau Espin Pedrolc675b612020-01-09 19:55:40 +0100964 f_cs7_inst_0_cfg(BSCVTY, {"sccp-timer ias " & int2str(g_bsc_sccp_timer_ias),
965 "sccp-timer iar " & int2str(g_bsc_sccp_timer_iar)});
Harald Weltebc03c762018-02-12 18:09:38 +0100966}
967
Neels Hofmeyr767548a2020-08-09 20:26:07 +0000968private function f_logp(TELNETasp_PT pt, charstring log_msg)
Neels Hofmeyr4f118412020-06-04 15:25:10 +0200969{
970 // log on TTCN3 log output
971 log(log_msg);
972 // log in stderr log
Neels Hofmeyr767548a2020-08-09 20:26:07 +0000973 f_vty_transceive(pt, "logp lglobal notice TTCN3 f_logp(): " & log_msg);
Neels Hofmeyr4f118412020-06-04 15:25:10 +0200974}
975
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +0200976private function f_sysinfo_seen(integer rsl_idx, RSL_Message rsl) runs on test_CT
977{
978 if (rsl_idx >= lengthof(g_system_information)) {
979 g_system_information[rsl_idx] := SystemInformationConfig_omit
980 }
981 f_sysinfo_dec_raw(g_system_information[rsl_idx], rsl);
982}
983
984altstep as_catch_RSL_sysinfo(integer rsl_idx) runs on test_CT {
985 var ASP_RSL_Unitdata rx_rsl_ud;
986
987 /* For handler_mode := false, receiving the RSL bootstrap messages directly on IPA_RSL */
988 [] IPA_RSL[rsl_idx].receive(tr_ASP_RSL_UD(tr_RSL_NO_BCCH_INFO)) -> value rx_rsl_ud {
989 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
990 repeat;
991 }
992 [] IPA_RSL[rsl_idx].receive(tr_ASP_RSL_UD(tr_RSL_BCCH_INFO)) -> value rx_rsl_ud {
993 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
994 repeat;
995 }
996 [] IPA_RSL[rsl_idx].receive(tr_ASP_RSL_UD(tr_RSL_NO_SACCH_FILL)) -> value rx_rsl_ud {
997 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
998 repeat;
999 }
1000 [] IPA_RSL[rsl_idx].receive(tr_ASP_RSL_UD(tr_RSL_SACCH_FILL)) -> value rx_rsl_ud {
1001 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
1002 repeat;
1003 }
1004
1005 /* For handler_mode := true, receiving the RSL bootstrap messages via RSL_Emulation */
1006 [] RSL_CCHAN[rsl_idx].receive(tr_ASP_RSL_UD(tr_RSL_NO_BCCH_INFO)) -> value rx_rsl_ud {
1007 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
1008 repeat;
1009 }
1010 [] RSL_CCHAN[rsl_idx].receive(tr_ASP_RSL_UD(tr_RSL_BCCH_INFO)) -> value rx_rsl_ud {
1011 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
1012 repeat;
1013 }
1014 [] RSL_CCHAN[rsl_idx].receive(tr_ASP_RSL_UD(tr_RSL_NO_SACCH_FILL)) -> value rx_rsl_ud {
1015 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
1016 repeat;
1017 }
1018 [] RSL_CCHAN[rsl_idx].receive(tr_ASP_RSL_UD(tr_RSL_SACCH_FILL)) -> value rx_rsl_ud {
1019 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
1020 repeat;
1021 }
1022}
1023
Neels Hofmeyra460f1f2020-08-09 20:17:03 +00001024/* TODO: use BooleanList from COMMON/src/General_Types.ttcn */
1025private type record of boolean my_BooleanList;
1026
1027private function f_vty_msc_allow_attach(TELNETasp_PT pt, my_BooleanList allow_attach_list)
1028{
Neels Hofmeyr8f576712020-08-12 22:49:53 +00001029 var charstring config := f_vty_transceive_ret(pt, "show running-config");
1030
Neels Hofmeyra460f1f2020-08-09 20:17:03 +00001031 for (var integer msc_nr := 0; msc_nr < sizeof(allow_attach_list); msc_nr := msc_nr+1) {
Neels Hofmeyr8f576712020-08-12 22:49:53 +00001032 if (f_strstr(config, "\nmsc " & int2str(msc_nr) & "\n") < 0) {
1033 /* There is no 'msc N' for this msc_nr in the running config, so don't create an empty msc by
1034 * stepping into that config node. */
1035 log("msc ", msc_nr, " is not configured, skipping");
1036 continue;
1037 }
Neels Hofmeyra460f1f2020-08-09 20:17:03 +00001038 f_vty_enter_cfg_msc(pt, msc_nr);
1039 if (allow_attach_list[msc_nr]) {
1040 /* strict := false: ignore if osmo-bsc does not support this config option (latest build) */
1041 f_vty_transceive(pt, "allow-attach", strict := false);
1042 } else {
1043 f_vty_transceive(pt, "no allow-attach", strict := false);
1044 }
1045 f_vty_transceive(pt, "exit");
1046 f_vty_transceive(pt, "exit");
1047 }
1048}
1049
Harald Welte21b46bd2017-12-17 19:46:32 +01001050/* global initialization function
1051 * \param nr_bts Number of BTSs we should start/bring up
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001052 * \param handler_mode Start an RSL_Emulation_CT component (true) or not (false).
1053 * \param nr_msc Number of virtual MSCs to bring up to connect to osmo-bsc.
1054 */
1055function f_init(integer nr_bts := NUM_BTS, boolean handler_mode := false, boolean allow_osmux := false,
Neels Hofmeyr4fbad7f2020-06-16 00:30:47 +02001056 integer nr_msc := 1, float guard_timeout := 30.0) runs on test_CT {
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001057 var integer bssap_idx;
Harald Welte28d943e2017-11-25 15:00:50 +01001058
Harald Welteae026692017-12-09 01:03:01 +01001059 if (g_initialized) {
1060 return;
Harald Welte28d943e2017-11-25 15:00:50 +01001061 }
Harald Welteae026692017-12-09 01:03:01 +01001062 g_initialized := true;
1063
Neels Hofmeyr4fbad7f2020-06-16 00:30:47 +02001064 T_guard.start(guard_timeout);
Daniel Willmanne68f9272018-11-27 15:15:28 +01001065 activate(as_Tguard());
1066
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02001067 f_init_vty("VirtMSC");
Pau Espin Pedrol58cf6822019-05-28 18:11:33 +02001068 if (mp_enable_osmux_test) {
1069 f_vty_allow_osmux(allow_osmux);
1070 }
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02001071
Neels Hofmeyra460f1f2020-08-09 20:17:03 +00001072 var my_BooleanList allow_attach := { false, false, false };
Daniel Willmannebdecc02020-08-12 15:30:17 +02001073 f_init_statsd("VirtMSC", vc_STATSD, mp_test_ip, mp_bsc_statsd_port);
1074
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001075 for (bssap_idx := 0; bssap_idx < nr_msc; bssap_idx := bssap_idx+1) {
Neels Hofmeyra460f1f2020-08-09 20:17:03 +00001076 allow_attach[bssap_idx] := true;
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001077 /* Call a function of our 'parent component' RAN_Adapter_CT to start the
1078 * MSC-side BSSAP emulation */
1079 if (handler_mode) {
1080 var RanOps ranops := MSC_RanOps;
1081 ranops.use_osmux := g_osmux_enabled;
1082 f_ran_adapter_init(g_bssap[bssap_idx], mp_bssap_cfg[bssap_idx], "VirtMSC", ranops);
1083 connect(self:SCCPLITE_IPA_CTRL, g_bssap[bssap_idx].vc_RAN:CTRL_CLIENT);
1084 f_ran_adapter_start(g_bssap[bssap_idx]);
1085 } else {
1086 f_ran_adapter_init(g_bssap[bssap_idx], mp_bssap_cfg[bssap_idx], "VirtMSC", omit);
1087 connect(self:BSSAP, g_bssap[bssap_idx].vc_SCCP:SCCP_SP_PORT);
1088 f_ran_adapter_start(g_bssap[bssap_idx]);
1089 f_legacy_bssap_reset();
1090 }
Harald Welte67089ee2018-01-17 22:19:03 +01001091 }
Harald Welted5833a82018-05-27 16:52:56 +02001092
Neels Hofmeyrcfe44062020-10-15 02:28:08 +02001093 if (mp_enable_lcs_tests) {
1094 if (handler_mode) {
1095 f_bssap_le_adapter_init(g_bssap_le, mp_bssap_le_cfg, "VirtSMLC", SMLC_BssapLeOps);
1096 } else {
1097 f_bssap_le_adapter_init(g_bssap_le, mp_bssap_le_cfg, "VirtSMLC", omit);
1098 connect(self:BSSAP_LE, g_bssap_le.vc_SCCP:SCCP_SP_PORT);
1099 }
1100 f_bssap_le_adapter_start(g_bssap_le);
Harald Welte47cd0e32020-08-21 12:39:11 +02001101 }
Harald Welte47cd0e32020-08-21 12:39:11 +02001102
Neels Hofmeyra460f1f2020-08-09 20:17:03 +00001103 /* start the test with exactly all enabled MSCs allowed to attach */
1104 f_vty_msc_allow_attach(BSCVTY, allow_attach);
1105
Harald Welteffe55fc2018-01-17 22:39:54 +01001106 f_ipa_ctrl_start(mp_bsc_ip, mp_bsc_ctrl_port);
Harald Welte28d943e2017-11-25 15:00:50 +01001107
Daniel Willmann191e0d92018-01-17 12:44:35 +01001108 f_init_mgcp("VirtMSC");
1109
Neels Hofmeyr0b7365b2020-07-04 00:52:34 +02001110 for (var integer i := 0; i < nr_bts; i := i+1) {
1111 f_init_bts(i, handler_mode);
Harald Welte696ddb62017-12-08 14:01:43 +01001112 }
Neels Hofmeyr0b7365b2020-07-04 00:52:34 +02001113}
Harald Welte696ddb62017-12-08 14:01:43 +01001114
Neels Hofmeyr0b7365b2020-07-04 00:52:34 +02001115function f_init_bts(integer bts_idx := 0, boolean handler_mode := false)
1116runs on test_CT {
1117 /* wait until osmo-bts-omldummy has respawned */
1118 f_wait_oml(bts_idx, "degraded", 5.0);
1119
1120 /* start RSL connection */
1121 f_ipa_rsl_start(bts[bts_idx].rsl, mp_bsc_ip, mp_bsc_rsl_port, bts_idx, handler_mode);
1122 /* wait until BSC tells us "connected" */
1123 f_wait_oml(bts_idx, "connected", 5.0);
Harald Welte28d943e2017-11-25 15:00:50 +01001124}
1125
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +02001126function f_init_bts_and_check_sysinfo(integer bts_idx := 0, boolean handler_mode := false,
1127 template SystemInformationConfig expect_si)
1128runs on test_CT {
1129 var default sysinfo := activate(as_catch_RSL_sysinfo(bts_idx));
1130
1131 f_init_bts(bts_idx, handler_mode);
1132
1133 /* Give some time to (hopefully/most likely) collect all system informations from RSL startup.
1134 * We could stop as soon as all expected SI are received, but then we might miss SI that we don't expect and
1135 * that might be sent afterwards. So rather give a generous timeout and be quite sure to catch all SI.
1136 */
1137 f_sleep(5.0);
1138 log("RSL ", bts_idx, " SYSTEM INFORMATION: ", g_system_information[bts_idx]);
1139
1140 deactivate(sysinfo);
1141
1142 if (match(g_system_information[bts_idx], expect_si)) {
1143 setverdict(pass);
1144 } else {
1145 log("RSL ", bts_idx, ": EXPECTED SI: ", expect_si);
1146 log("RSL ", bts_idx, ": GOT SI: ", g_system_information[bts_idx]);
1147 setverdict(fail, "received SI does not match expectations");
1148 return;
1149 }
1150}
1151
Maxd4e56962018-10-31 19:08:25 +01001152/* expect to receive a RSL message matching a specified template on a given BTS / stream */
Harald Welte65e419a2020-08-21 12:38:33 +02001153function 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 +01001154runs on test_CT return RSL_Message {
1155 var ASP_RSL_Unitdata rx_rsl_ud;
1156 timer T := t_secs;
1157
1158 T.start;
1159 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001160 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(t_rx, sid)) -> value rx_rsl_ud {
Harald Welteae026692017-12-09 01:03:01 +01001161 T.stop;
1162 }
1163 [] IPA_RSL[bts_nr].receive { repeat; }
Harald Welteb2917702017-12-10 15:48:52 +01001164 [] T.timeout {
1165 setverdict(fail, "Timeout expecting ", t_rx);
Daniel Willmannafce8662018-07-06 23:11:32 +02001166 mtc.stop;
Harald Welteb2917702017-12-10 15:48:52 +01001167 }
Harald Welteae026692017-12-09 01:03:01 +01001168 }
1169 return rx_rsl_ud.rsl;
1170}
1171
Harald Welte21b46bd2017-12-17 19:46:32 +01001172/* helper function to transmit RSL on a given BTS/stream */
Harald Welte65e419a2020-08-21 12:38:33 +02001173function 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 +01001174runs on test_CT {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001175 IPA_RSL[bts_nr].send(ts_ASP_RSL_UD(t_tx, sid));
Harald Welteae026692017-12-09 01:03:01 +01001176}
1177
1178
Harald Welte4003d112017-12-09 22:35:39 +01001179/* verify we get a CHAN_ACT after CHAN RQD */
Harald Welteae026692017-12-09 01:03:01 +01001180testcase TC_chan_act_noreply() runs on test_CT {
1181 var BSSAP_N_UNITDATA_ind ud_ind;
Harald Welte930d0a72018-03-22 22:08:40 +01001182 var RSL_Message rsl_unused;
Harald Welte28d943e2017-11-25 15:00:50 +01001183
Harald Welte89d42e82017-12-17 16:42:41 +01001184 f_init(1);
Harald Welte28d943e2017-11-25 15:00:50 +01001185
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001186 IPA_RSL[0].send(ts_ASP_RSL_UD(ts_RSL_CHAN_RQD('23'O, 23)));
Harald Welte930d0a72018-03-22 22:08:40 +01001187 rsl_unused := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001188 f_shutdown_helper();
Harald Welte28d943e2017-11-25 15:00:50 +01001189}
1190
Harald Welte4003d112017-12-09 22:35:39 +01001191/* verify if the "chreq:total" counter increments as expected */
1192testcase TC_chan_act_counter() runs on test_CT {
1193 var BSSAP_N_UNITDATA_ind ud_ind;
1194 var integer chreq_total;
Harald Welte930d0a72018-03-22 22:08:40 +01001195 var RSL_Message rsl_unused;
Harald Welte4003d112017-12-09 22:35:39 +01001196
Harald Welte89d42e82017-12-17 16:42:41 +01001197 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +01001198
1199 chreq_total := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total");
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001200 IPA_RSL[0].send(ts_ASP_RSL_UD(ts_RSL_CHAN_RQD('23'O, 23)));
Harald Welte930d0a72018-03-22 22:08:40 +01001201 rsl_unused := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
Harald Welte4003d112017-12-09 22:35:39 +01001202 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total", chreq_total+1);
1203
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001204 f_shutdown_helper();
Harald Welte4003d112017-12-09 22:35:39 +01001205}
1206
Harald Welteae026692017-12-09 01:03:01 +01001207/* CHAN RQD -> CHAN ACT -> CHAN ACT ACK -> RF CHAN REL */
Philipp Maier9c60a622020-07-09 15:08:46 +02001208private function f_TC_chan_act_ack_noest(OCT1 ra := '23'O) runs on test_CT {
Harald Welteae026692017-12-09 01:03:01 +01001209 var RSL_Message rx_rsl;
1210
Harald Welteae026692017-12-09 01:03:01 +01001211 /* Send CHAN RQD and wait for allocation; acknowledge it */
Philipp Maier9c60a622020-07-09 15:08:46 +02001212 var RslChannelNr chan_nr := f_chreq_act_ack(ra);
Harald Welteae026692017-12-09 01:03:01 +01001213
1214 /* expect BSC to disable the channel again if there's no RLL EST IND */
1215 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), T3101_MAX);
1216
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001217 f_shutdown_helper();
Harald Welteae026692017-12-09 01:03:01 +01001218}
1219
Philipp Maier9c60a622020-07-09 15:08:46 +02001220/* Normal variant */
1221testcase TC_chan_act_ack_noest() runs on test_CT {
Philipp Maieraf58db22020-08-12 17:24:40 +02001222 f_init(1);
Philipp Maier9c60a622020-07-09 15:08:46 +02001223 f_TC_chan_act_ack_noest();
1224}
1225
1226/* Emergency call variant */
1227testcase TC_chan_act_ack_noest_emerg() runs on test_CT {
1228 /* See also: 3GPP TS 04.08, Table 9.9, ra=101xxxxx */
Philipp Maieraf58db22020-08-12 17:24:40 +02001229 f_init(1);
1230 f_vty_allow_emerg_bts(true, 0);
Philipp Maier9c60a622020-07-09 15:08:46 +02001231 f_TC_chan_act_ack_noest(ra := 'A5'O);
1232}
1233
Philipp Maier606f07d2020-08-12 17:21:58 +02001234/* Emergency call variant, but emergency calls are not allowed */
1235testcase TC_chan_rqd_emerg_deny() runs on test_CT {
1236 /* See also: 3GPP TS 04.08, Table 9.9, ra=101xxxxx */
1237
1238 var RSL_Message rx_rsl;
1239 var GsmRrMessage rr;
1240
1241 f_init(1);
1242 f_vty_allow_emerg_bts(false, 0);
1243
1244 IPA_RSL[0].clear;
1245 f_ipa_tx(0, ts_RSL_CHAN_RQD('A5'O, 23));
1246
1247 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeC(RSL_MT_IMMEDIATE_ASSIGN_CMD));
1248 rr := dec_GsmRrMessage(rx_rsl.ies[1].body.full_imm_ass_info.payload);
1249 if (rr.header.message_type == IMMEDIATE_ASSIGNMENT_REJECT) {
1250 setverdict(pass);
1251 } else {
1252 setverdict(fail, "immediate assignment not rejected");
1253 }
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01001254
1255 f_shutdown_helper();
Philipp Maier606f07d2020-08-12 17:21:58 +02001256}
1257
Harald Welteae026692017-12-09 01:03:01 +01001258/* Test behavior if MSC never answers to CR */
1259testcase TC_chan_act_ack_est_ind_noreply() runs on test_CT {
Harald Weltef77aef62018-01-28 15:35:42 +01001260 var RslLinkId main_dcch := valueof(ts_RslLinkID_DCCH(0));
1261 var IpaStreamId sid := IPAC_PROTO_RSL_TRX0;
Harald Welteae026692017-12-09 01:03:01 +01001262 var RSL_Message rx_rsl;
Harald Weltef77aef62018-01-28 15:35:42 +01001263 var ASP_RSL_Unitdata rx_rsl_ud;
Harald Welteae026692017-12-09 01:03:01 +01001264
Harald Welte89d42e82017-12-17 16:42:41 +01001265 f_init(1);
Harald Welteae026692017-12-09 01:03:01 +01001266
1267 /* Send CHAN RQD and wait for allocation; acknowledge it */
Harald Welted6939652017-12-13 21:02:46 +01001268 var RslChannelNr chan_nr := f_chreq_act_ack();
Harald Welteae026692017-12-09 01:03:01 +01001269
1270 var octetstring l3 := '00010203040506'O
1271 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
1272
1273 BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3)));
1274
1275 /* expect BSC to disable the channel again if there's no response from MSC */
Harald Weltef77aef62018-01-28 15:35:42 +01001276 /* MS waits 20s (T3210) at LU; 10s (T3230) at CM SERV REQ and 5s (T3220) AT detach */
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001277 f_expect_chan_rel(0, chan_nr, expect_rll_rel_req := false);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001278 f_shutdown_helper();
Harald Welteae026692017-12-09 01:03:01 +01001279}
1280
1281/* Test behavior if MSC answers with CREF to CR */
1282testcase TC_chan_act_ack_est_ind_refused() runs on test_CT {
1283 var BSSAP_N_CONNECT_ind rx_c_ind;
1284 var RSL_Message rx_rsl;
1285
Harald Welte89d42e82017-12-17 16:42:41 +01001286 f_init(1);
Harald Welteae026692017-12-09 01:03:01 +01001287
1288 /* Send CHAN RQD and wait for allocation; acknowledge it */
Harald Welted6939652017-12-13 21:02:46 +01001289 var RslChannelNr chan_nr := f_chreq_act_ack();
Harald Welteae026692017-12-09 01:03:01 +01001290
1291 var octetstring l3 := '00010203040506'O
1292 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
1293
1294 BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) -> value rx_c_ind;
1295 BSSAP.send(ts_BSSAP_DISC_req(rx_c_ind.connectionId, 0));
1296
1297 /* expect BSC to disable the channel */
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001298 f_expect_chan_rel(0, chan_nr, expect_rll_rel_req := false);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001299 f_shutdown_helper();
Harald Welteae026692017-12-09 01:03:01 +01001300}
1301
Harald Welte618ef642017-12-14 14:58:20 +01001302/* CHAN RQD -> CHAN ACT -> CHAN ACT NACK -> RF CHAN REL */
1303testcase TC_chan_act_nack() runs on test_CT {
1304 var RSL_Message rx_rsl;
1305 var integer chact_nack;
1306
Harald Welte89d42e82017-12-17 16:42:41 +01001307 f_init(1);
Harald Welte618ef642017-12-14 14:58:20 +01001308
1309 chact_nack := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chan_act:nack");
1310
1311 f_ipa_tx(0, ts_RSL_CHAN_RQD('33'O, 33));
1312 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
1313 var RslChannelNr chan_nr := rx_rsl.ies[0].body.chan_nr;
1314
1315 f_ipa_tx(0, ts_RSL_CHAN_ACT_NACK(chan_nr, RSL_ERR_EQUIPMENT_FAIL));
1316
1317 /* wait for some time to hope the NACK arrives before the CTRL GET below */
1318 f_sleep(0.5);
1319
1320 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chan_act:nack", chact_nack+1);
1321
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001322 f_shutdown_helper();
Harald Welte618ef642017-12-14 14:58:20 +01001323}
1324
Harald Welte799c97b2017-12-14 17:50:30 +01001325/* Test for channel exhaustion due to RACH overload */
1326testcase TC_chan_exhaustion() runs on test_CT {
1327 var ASP_RSL_Unitdata rsl_ud;
1328 var integer i;
1329 var integer chreq_total, chreq_nochan;
1330
Harald Welte89d42e82017-12-17 16:42:41 +01001331 f_init(1);
Harald Welte799c97b2017-12-14 17:50:30 +01001332
1333 chreq_total := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total");
1334 chreq_nochan := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:no_channel");
1335
Pau Espin Pedrolfe200d72018-12-10 12:41:04 +01001336 /* GSM 04.08 Table 9.9a:
1337 * RA = '33'O -> Establishment cause = 0011xxxx (MS dual rate capable and asks for "TCH/H or TCH/F").
1338 * With current setup, expect 4xSDCCH + 4xTCH/F + 1xTCH/H to succeed */
Philipp Maiercb6cc482018-03-26 13:08:00 +02001339 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 +01001340 var RslChannelNr chan_nr := f_chreq_act_ack('33'O, i);
Harald Welte799c97b2017-12-14 17:50:30 +01001341 }
1342
1343 IPA_RSL[0].clear;
1344
Harald Weltedd8cbf32018-01-28 12:07:52 +01001345 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total",
Philipp Maiercb6cc482018-03-26 13:08:00 +02001346 chreq_total + NUM_TCHF_PER_BTS + NUM_TCHH_PER_BTS + NUM_SDCCH_PER_BTS);
Harald Welte799c97b2017-12-14 17:50:30 +01001347
1348 /* now expect additional channel activations to fail */
1349 f_ipa_tx(0, ts_RSL_CHAN_RQD('42'O, 42));
1350
1351 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001352 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV))) {
Harald Welte799c97b2017-12-14 17:50:30 +01001353 setverdict(fail, "Received CHAN ACT ACK without resources?!?");
1354 }
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001355 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_IMM_ASSIGN(?))) -> value rsl_ud {
Harald Welte799c97b2017-12-14 17:50:30 +01001356 var GsmRrMessage rr;
1357 /* match on IMM ASS REJ */
1358 rr := dec_GsmRrMessage(rsl_ud.rsl.ies[1].body.full_imm_ass_info.payload);
1359 if (rr.header.message_type == IMMEDIATE_ASSIGNMENT_REJECT) {
1360 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total",
Philipp Maiercb6cc482018-03-26 13:08:00 +02001361 chreq_total + NUM_TCHF_PER_BTS + NUM_TCHH_PER_BTS + NUM_SDCCH_PER_BTS+1);
Harald Welte799c97b2017-12-14 17:50:30 +01001362 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:no_channel",
1363 chreq_nochan+1);
1364 setverdict(pass);
1365 } else {
1366 repeat;
1367 }
1368 }
1369 [] IPA_RSL[0].receive { repeat; }
1370 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001371 f_shutdown_helper();
Harald Welte799c97b2017-12-14 17:50:30 +01001372}
1373
Vadim Yanitskiy1ff1fdf2018-11-27 01:32:57 +07001374/* Test channel deactivation due to silence from MS */
1375testcase TC_chan_deact_silence() runs on test_CT {
1376 var RslChannelNr chan_nr;
1377
1378 f_init(1);
1379
1380 /* Request for a dedicated channel */
1381 chan_nr := f_chreq_act_ack('23'O);
1382
1383 /* Wait some time until the channel is released */
1384 f_sleep(2.0);
1385
1386 /* Expect CHANnel RELease */
1387 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001388 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL))) {
Vadim Yanitskiy1ff1fdf2018-11-27 01:32:57 +07001389 log("Received CHANnel RELease");
1390 setverdict(pass);
1391 }
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001392 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_IMM_ASSIGN(?))) {
Vadim Yanitskiy1ff1fdf2018-11-27 01:32:57 +07001393 /* See OS#3709, OsmoBSC should not send Immediate
1394 * Assignment Reject since a dedicated channel was
1395 * already allocated, and Immediate Assignment was
1396 * already sent. */
1397 setverdict(fail, "Unexpected Immediate Assignment!");
1398 }
1399 [] IPA_RSL[0].receive {
1400 setverdict(fail, "Unexpected RSL message!");
1401 }
1402 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001403 f_shutdown_helper();
Vadim Yanitskiy1ff1fdf2018-11-27 01:32:57 +07001404}
1405
Harald Weltecfe2c962017-12-15 12:09:32 +01001406/***********************************************************************
1407 * Assignment Testing
1408 ***********************************************************************/
1409
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02001410/* Verify that the BSC refuses any BSSAP connection from the MSC (They are all BSC->MSC direction,
1411 * except for the inter-BSC handover, MT side) */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001412testcase TC_outbound_connect(integer bssap_idx := 0) runs on test_CT {
Harald Welte89d42e82017-12-17 16:42:41 +01001413 f_init(1);
Harald Weltecfe2c962017-12-15 12:09:32 +01001414
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001415 BSSAP.send(ts_BSSAP_CONNECT_req(g_bssap[bssap_idx].sccp_addr_peer, g_bssap[bssap_idx].sccp_addr_own,
1416 2342, ts_BSSMAP_AssignmentReq));
Harald Weltecfe2c962017-12-15 12:09:32 +01001417 BSSAP.receive(tr_BSSAP_DISC_ind(2342, ?, ?));
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001418 f_shutdown_helper();
Harald Weltecfe2c962017-12-15 12:09:32 +01001419}
1420
Harald Welte16a4adf2017-12-14 18:54:01 +01001421/* Test behavior if MSC answers with CREF to CR */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001422testcase TC_assignment_cic_only(integer bssap_idx := 0) runs on test_CT {
Harald Welte16a4adf2017-12-14 18:54:01 +01001423 var BSSAP_N_CONNECT_ind rx_c_ind;
1424 var RSL_Message rx_rsl;
1425 var DchanTuple dt;
1426
Harald Welte89d42e82017-12-17 16:42:41 +01001427 f_init(1);
Harald Welte16a4adf2017-12-14 18:54:01 +01001428
1429 dt := f_est_dchan('23'O, 23, '00000000'O);
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001430 if (mp_bssap_cfg[bssap_idx].transport == BSSAP_TRANSPORT_AoIP) {
Harald Welte17b27da2018-05-25 20:33:53 +02001431 /* send assignment without AoIP IEs */
1432 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_AssignmentReq(ts_BSSMAP_IE_CIC(0, 1))));
1433 } else {
1434 /* Send assignmetn without CIC in IPA case */
1435 var BSSMAP_IE_AoIP_TransportLayerAddress tla :=
1436 valueof(ts_BSSMAP_IE_AoIP_TLA4('01020304'O, 2342));
1437 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_AssignmentReq(omit, tla)));
1438 }
Harald Welte16a4adf2017-12-14 18:54:01 +01001439 alt {
1440 [] BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_AssignmentComplete)) {
1441 setverdict(fail, "AoIP BSC cannot accept ASSIGNMENT without AoIP Transport IE");
1442 }
Harald Welte235ebf12017-12-15 14:18:16 +01001443 /* TODO: Actually expect GSM0808_CAUSE_REQ_A_IF_TYPE_NOT_SUPP */
Harald Welte16a4adf2017-12-14 18:54:01 +01001444 [] BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_AssignmentFail)) {
1445 setverdict(pass);
1446 }
1447 [] BSSAP.receive { repeat; }
1448 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001449 f_shutdown_helper();
Harald Welte16a4adf2017-12-14 18:54:01 +01001450}
1451
Harald Welteed848512018-05-24 22:27:58 +02001452/* generate an assignment request for either AoIP or SCCPlite */
Pau Espin Pedrol07866632020-09-03 19:10:55 +02001453function 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 +02001454 var PDU_BSSAP ass_cmd;
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02001455 var BSSMAP_IE_Osmo_OsmuxCID osmux_cid := valueof(ts_OsmuxCID(0));
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001456 if (mp_bssap_cfg[bssap_idx].transport == BSSAP_TRANSPORT_AoIP) {
Harald Welteed848512018-05-24 22:27:58 +02001457 var BSSMAP_IE_AoIP_TransportLayerAddress tla :=
Pau Espin Pedrol07866632020-09-03 19:10:55 +02001458 valueof(f_ts_BSSMAP_IE_AoIP_TLA(aoip_tla, 2342));
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02001459 if (osmux_enabled) {
1460 ass_cmd := valueof(ts_BSSMAP_AssignmentReq(omit, tla, osmux_cid));
1461 } else {
1462 ass_cmd := valueof(ts_BSSMAP_AssignmentReq(omit, tla));
1463 }
Harald Welteed848512018-05-24 22:27:58 +02001464 } else {
1465 var BSSMAP_IE_CircuitIdentityCode cic := valueof(ts_BSSMAP_IE_CIC(0,1));
Pau Espin Pedrol096d73d2019-06-06 12:49:17 +02001466 ass_cmd := valueof(ts_BSSMAP_AssignmentReq(cic, omit));
Harald Welteed848512018-05-24 22:27:58 +02001467 }
1468 return ass_cmd;
1469}
1470
Pau Espin Pedrol07866632020-09-03 19:10:55 +02001471function 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 +01001472 var PDU_BSSAP ho_req;
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001473 if (mp_bssap_cfg[bssap_idx].transport == BSSAP_TRANSPORT_AoIP) {
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01001474 var BSSMAP_IE_AoIP_TransportLayerAddress tla :=
Pau Espin Pedrol07866632020-09-03 19:10:55 +02001475 valueof(f_ts_BSSMAP_IE_AoIP_TLA(aoip_tla, 2342));
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01001476 ho_req := valueof(ts_BSSMAP_HandoverRequest(omit, tla));
1477 } else {
1478 var BSSMAP_IE_CircuitIdentityCode cic := valueof(ts_BSSMAP_IE_CIC(0,1));
1479 ho_req := valueof(ts_BSSMAP_HandoverRequest(cic, omit));
1480 }
1481 return ho_req;
1482}
1483
Harald Welteed848512018-05-24 22:27:58 +02001484/* generate an assignment complete template for either AoIP or SCCPlite */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001485function f_gen_exp_compl(boolean expect_osmux := false, integer bssap_idx := 0) return template PDU_BSSAP {
Harald Welteed848512018-05-24 22:27:58 +02001486 var template PDU_BSSAP exp_compl;
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02001487 var BSSMAP_IE_Osmo_OsmuxCID osmux_cid := valueof(ts_OsmuxCID(0));
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001488 if (mp_bssap_cfg[bssap_idx].transport == BSSAP_TRANSPORT_AoIP) {
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02001489 if (expect_osmux) {
1490 exp_compl := tr_BSSMAP_AssignmentComplete(omit, ?, osmux_cid);
1491 } else {
1492 exp_compl := tr_BSSMAP_AssignmentComplete(omit, ?, omit);
1493 }
Harald Welteed848512018-05-24 22:27:58 +02001494 } else {
1495 /* CIC is optional "*" as the MSC allocated it */
Pau Espin Pedrol096d73d2019-06-06 12:49:17 +02001496 exp_compl := tr_BSSMAP_AssignmentComplete(*, omit);
Harald Welteed848512018-05-24 22:27:58 +02001497 }
1498 return exp_compl;
1499}
1500
Harald Welte235ebf12017-12-15 14:18:16 +01001501/* Run everything required up to sending a caller-specified assignment command and expect response */
1502function f_assignment_exp(PDU_BSSAP ass_cmd, template PDU_BSSAP exp, charstring fail_text)
1503runs on test_CT {
1504 var BSSAP_N_CONNECT_ind rx_c_ind;
1505 var RSL_Message rx_rsl;
1506 var DchanTuple dt;
1507
Harald Welte89d42e82017-12-17 16:42:41 +01001508 f_init(1);
Harald Welte235ebf12017-12-15 14:18:16 +01001509
1510 dt := f_est_dchan('23'O, 23, '00000000'O);
1511 /* send assignment without AoIP IEs */
1512 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ass_cmd));
1513 alt {
1514 [] BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_AssignmentComplete)) {
1515 if (ischosen(exp.pdu.bssmap.assignmentComplete)) {
1516 setverdict(pass);
1517 } else {
1518 setverdict(fail, fail_text);
1519 }
1520 }
1521 [] BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_AssignmentFail)) {
1522 if (ischosen(exp.pdu.bssmap.assignmentFailure)) {
1523 setverdict(pass);
1524 } else {
1525 setverdict(fail, fail_text);
1526 }
1527 }
1528 [] BSSAP.receive { repeat; }
1529 }
1530}
1531testcase TC_assignment_csd() runs on test_CT {
1532 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
Harald Welteed848512018-05-24 22:27:58 +02001533 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte235ebf12017-12-15 14:18:16 +01001534 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeCSD);
1535 //exp_fail.pdu.bssmap.assignmentFailure.cause.causeValue := int2bit(enum2int(GSM0808_CAUSE_REQ_CODEC_TYPE_OR_CONFIG_UNAVAIL), 7);
1536 f_assignment_exp(ass_cmd, exp_fail, "BSC accepted Assignment for CSD");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001537 f_shutdown_helper();
Harald Welte235ebf12017-12-15 14:18:16 +01001538}
1539
1540testcase TC_assignment_ctm() runs on test_CT {
1541 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
Harald Welteed848512018-05-24 22:27:58 +02001542 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte235ebf12017-12-15 14:18:16 +01001543 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeCTM);
1544 //exp_fail.pdu.bssmap.assignmentFailure.cause.causeValue := int2bit(enum2int(GSM0808_CAUSE_REQ_CODEC_TYPE_OR_CONFIG_UNAVAIL), 7);
1545 f_assignment_exp(ass_cmd, exp_fail, "BSC accepted Assignment for Speech+CTM");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001546 f_shutdown_helper();
Harald Welte235ebf12017-12-15 14:18:16 +01001547}
1548
Harald Welte4003d112017-12-09 22:35:39 +01001549type record DchanTuple {
1550 integer sccp_conn_id,
1551 RslChannelNr rsl_chan_nr
Harald Weltea5d2ab22017-12-09 14:21:42 +01001552}
1553
Harald Welted6939652017-12-13 21:02:46 +01001554/* Send CHAN RQD and wait for allocation; acknowledge it */
1555private function f_chreq_act_ack(OCT1 ra := '23'O, GsmFrameNumber fn := 23)
1556runs on test_CT return RslChannelNr {
1557 var RSL_Message rx_rsl;
1558 f_ipa_tx(0, ts_RSL_CHAN_RQD(ra, fn));
1559 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
1560 var RslChannelNr chan_nr := rx_rsl.ies[0].body.chan_nr;
1561 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, fn+10));
Daniel Willmannf4ac4ce2018-08-02 14:06:30 +02001562 rx_rsl := f_exp_ipa_rx(0, tr_RSL_IMM_ASSIGN(0));
Harald Welted6939652017-12-13 21:02:46 +01001563 return chan_nr;
1564}
1565
Harald Welte4003d112017-12-09 22:35:39 +01001566/* helper function to establish a dedicated channel via BTS and MSC */
1567function f_est_dchan(OCT1 ra, GsmFrameNumber fn, octetstring l3)
1568runs on test_CT return DchanTuple {
1569 var BSSAP_N_CONNECT_ind rx_c_ind;
Harald Welte4003d112017-12-09 22:35:39 +01001570 var DchanTuple dt;
Harald Weltea5d2ab22017-12-09 14:21:42 +01001571
Harald Welte4003d112017-12-09 22:35:39 +01001572 /* Send CHAN RQD and wait for allocation; acknowledge it */
Harald Welted6939652017-12-13 21:02:46 +01001573 dt.rsl_chan_nr := f_chreq_act_ack(ra, fn);
Harald Welte4003d112017-12-09 22:35:39 +01001574
1575 f_ipa_tx(0, ts_RSL_EST_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
1576
1577 BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) -> value rx_c_ind;
1578 dt.sccp_conn_id := rx_c_ind.connectionId;
1579 BSSAP.send(ts_BSSAP_CONNECT_res(dt.sccp_conn_id));
1580
1581 return dt;
Harald Weltea5d2ab22017-12-09 14:21:42 +01001582}
1583
Harald Welte641fcbe2018-06-14 10:58:35 +02001584/* expect RF CAN REL from BTS, acknowledge it and clear the MSC side */
1585private function f_exp_chan_rel_and_clear(DchanTuple dt, integer bts_nr := 0) runs on test_CT {
1586 var RSL_Message rx_rsl;
1587 /* expect BSC to disable the channel */
1588 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), T3101_MAX);
1589 /* respond with CHAN REL ACK */
1590 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(dt.rsl_chan_nr));
1591
1592 /* expect Clear Complete from BSC */
1593 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete));
1594
1595 /* MSC disconnects as instructed. */
1596 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
1597}
1598
Harald Welte4003d112017-12-09 22:35:39 +01001599/* Test behavior of channel release after unilateral RLL REL IND (DISC from MS) */
1600testcase TC_chan_rel_rll_rel_ind() runs on test_CT {
Neels Hofmeyr27f64362018-03-12 01:44:00 +01001601 var BSSAP_N_DATA_ind rx_di;
Harald Welte4003d112017-12-09 22:35:39 +01001602 var DchanTuple dt;
Harald Welte96c94412017-12-09 03:12:45 +01001603
Harald Welte89d42e82017-12-17 16:42:41 +01001604 f_init(1);
Harald Welte96c94412017-12-09 03:12:45 +01001605
Harald Welte4003d112017-12-09 22:35:39 +01001606 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1607
1608 /* simulate RLL REL IND */
1609 f_ipa_tx(0, ts_RSL_REL_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0))));
1610
Neels Hofmeyr27f64362018-03-12 01:44:00 +01001611 /* expect Clear Request on MSC side */
1612 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearRequest)) -> value rx_di;
1613
1614 /* Instruct BSC to clear channel */
1615 var BssmapCause cause := bit2int(rx_di.userData.pdu.bssmap.clearRequest.cause.causeValue);
1616 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
1617
Harald Welte4003d112017-12-09 22:35:39 +01001618 /* expect BSC to disable the channel */
Harald Welte641fcbe2018-06-14 10:58:35 +02001619 f_exp_chan_rel_and_clear(dt, 0);
Neels Hofmeyr27f64362018-03-12 01:44:00 +01001620
1621 /* wait for SCCP emulation to do its job */
1622 f_sleep(1.0);
Harald Welte4003d112017-12-09 22:35:39 +01001623
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001624 f_shutdown_helper();
Harald Welte4003d112017-12-09 22:35:39 +01001625}
1626
1627/* Test behavior of channel release after CONN FAIL IND from BTS */
1628testcase TC_chan_rel_conn_fail() runs on test_CT {
1629 var BSSAP_N_DATA_ind rx_di;
Harald Welte4003d112017-12-09 22:35:39 +01001630 var DchanTuple dt;
1631
Harald Welte89d42e82017-12-17 16:42:41 +01001632 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +01001633
1634 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1635
1636 /* simulate CONN FAIL IND */
Harald Weltea8ed9062017-12-14 09:46:01 +01001637 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 +01001638 /* TODO: different cause values? */
1639
Harald Welte4003d112017-12-09 22:35:39 +01001640 /* expect Clear Request from BSC */
1641 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearRequest)) -> value rx_di;
1642
1643 /* Instruct BSC to clear channel */
1644 var BssmapCause cause := bit2int(rx_di.userData.pdu.bssmap.clearRequest.cause.causeValue);
1645 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
1646
Harald Welte6ff76ea2018-01-28 13:08:01 +01001647 /* expect BSC to disable the channel */
Harald Welte641fcbe2018-06-14 10:58:35 +02001648 f_exp_chan_rel_and_clear(dt, 0);
Harald Welte4003d112017-12-09 22:35:39 +01001649
1650 /* wait for SCCP emulation to do its job */
1651 f_sleep(1.0);
1652
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001653 f_shutdown_helper();
Harald Welte4003d112017-12-09 22:35:39 +01001654}
1655
Harald Welte99f3ca02018-06-14 13:40:29 +02001656/* Test behavior of early CONN FAIL IND from BTS (before EST IND!) */
1657/* See also https://www.osmocom.org/issues/3182 */
1658testcase TC_early_conn_fail() runs on test_CT {
1659 var RSL_Message rx_rsl;
1660 var DchanTuple dt;
1661
1662 f_init(1);
1663
1664 /* BTS->BSC: Send CHAN RQD and wait for allocation; acknowledge it */
Harald Weltec46ea3c2020-10-10 18:46:12 +02001665 dt.rsl_chan_nr := f_chreq_act_ack(f_rnd_ra_cs(), 23);
Harald Welte99f3ca02018-06-14 13:40:29 +02001666
1667 /* BTS->BSC: simulate CONN FAIL IND */
1668 f_ipa_tx(0, ts_RSL_CONN_FAIL_IND(dt.rsl_chan_nr, RSL_ERR_RADIO_LINK_FAIL));
1669
1670 /* BTS->BSC: Expect RF channel release from BSC on Abis */
1671 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), 10.0);
1672
1673 /* BTS<-BSC: respond with CHAN REL ACK */
1674 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(dt.rsl_chan_nr));
1675
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001676 f_shutdown_helper();
Harald Welte99f3ca02018-06-14 13:40:29 +02001677}
1678
1679/* Test behavior of late CONN FAIL IND from BTS (ater REL IND!) */
1680/* See also https://www.osmocom.org/issues/3182 */
1681testcase TC_late_conn_fail() runs on test_CT {
1682 var RSL_Message rx_rsl;
1683 var DchanTuple dt;
1684
1685 f_init(1);
1686
1687 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1688
1689 /* BSC<-MSC: Instruct BSC to clear connection */
1690 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(0)));
1691
1692 /* BTS->BSC: expect BSC to deactivate SACCH */
1693 rx_rsl := f_exp_ipa_rx(0, tr_RSL_DEACT_SACCH(dt.rsl_chan_nr));
1694
1695 /* BTS->BSC: simulate a late CONN FAIL IND from BTS */
1696 f_ipa_tx(0, ts_RSL_CONN_FAIL_IND(dt.rsl_chan_nr, RSL_ERR_RADIO_LINK_FAIL));
1697
1698 /* BTS<-BSC: Expect RF channel release from BSC on Abis */
1699 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), 10.0);
1700 /* BTS->BSC: respond with CHAN REL ACK */
1701 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(dt.rsl_chan_nr));
1702
1703 /* BSC->MSC: expect Clear Complete from BSC */
1704 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete));
1705
1706 /* BSC<-MSC: MSC disconnects as requested. */
1707 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
1708
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001709 f_shutdown_helper();
Harald Welte99f3ca02018-06-14 13:40:29 +02001710}
1711
Neels Hofmeyrf44ccd12018-11-05 19:15:23 +01001712function f_expect_chan_rel(integer bts_nr, RslChannelNr rsl_chan_nr,
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001713 boolean expect_deact_sacch := true,
1714 boolean expect_rr_chan_rel := true,
1715 boolean expect_rll_rel_req := true,
Harald Welte99787102019-02-04 10:41:36 +01001716 boolean handle_rll_rel := true,
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02001717 boolean is_csfb := false,
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02001718 template CellSelIndValue csfb_expect_cells := omit,
1719 template RR_Cause expect_rr_cause := ?
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001720 ) runs on test_CT {
Harald Welte91d54a52018-01-28 15:35:07 +01001721
1722 var RslLinkId main_dcch := valueof(ts_RslLinkID_DCCH(0));
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001723 var boolean got_deact_sacch := false;
1724 var boolean got_rr_chan_rel := false;
1725 var boolean got_rll_rel_req := false;
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02001726 var ASP_RSL_Unitdata ud;
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02001727 var RSL_IE_Body l3_ie;
1728 var PDU_ML3_NW_MS l3;
1729 var RR_Cause got_cause;
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001730 log("f_expect_chan_rel() expecting: expect_deact_sacch=", expect_deact_sacch, " expect_rr_chan_rel=", expect_rr_chan_rel,
1731 " expect_rll_rel_req=", expect_rll_rel_req);
Harald Welte91d54a52018-01-28 15:35:07 +01001732 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001733 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(tr_RSL_DEACT_SACCH(rsl_chan_nr))) {
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001734 got_deact_sacch := true;
Harald Welte91d54a52018-01-28 15:35:07 +01001735 repeat;
1736 }
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02001737 [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 +01001738 got_rr_chan_rel := true;
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02001739
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02001740 if (f_rsl_find_ie(ud.rsl, RSL_IE_L3_INFO, l3_ie) == false) {
1741 setverdict(fail, "cannot find L3");
1742 mtc.stop;
1743 }
1744 l3 := dec_PDU_ML3_NW_MS(l3_ie.l3_info.payload);
1745
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02001746 if (not istemplatekind(csfb_expect_cells, "omit")) {
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02001747 var CellSelIndValue cells := dec_CellSelIndValue(
1748 l3.msgs.rrm.channelRelease.cellSelectionIndicator.cellSelectionIndicatorValue);
1749
1750 log("GOT RR CHANNEL RELEASE CSFB CELLS: ", cells);
1751 if (match(cells, csfb_expect_cells)) {
1752 setverdict(pass);
1753 } else {
1754 log("EXPECTED CSFB CELLS: ", csfb_expect_cells);
1755 setverdict(fail, "Received CSFB cells list on RR Channel Release does not match expectations");
1756 }
1757 }
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02001758
1759 if (not istemplatekind(expect_rr_cause, "omit")) {
1760 int2enum(oct2int(l3.msgs.rrm.channelRelease.rRCause.valuePart), got_cause);
1761 log("GOT CAUSE CODE: ", l3.msgs.rrm.channelRelease.rRCause.valuePart, " = ", got_cause);
1762 if (match(got_cause, expect_rr_cause)) {
1763 setverdict(pass);
1764 } else {
1765 log("EXPECTED CAUSE CODE: ", expect_rr_cause);
1766 setverdict(fail, "Received RR Channel Release Cause code does not match expectations");
1767 }
1768 }
Harald Welte99787102019-02-04 10:41:36 +01001769 repeat;
1770 }
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02001771 [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 +01001772 got_rr_chan_rel := true;
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02001773
1774 if (not istemplatekind(expect_rr_cause, "omit")) {
1775 if (f_rsl_find_ie(ud.rsl, RSL_IE_L3_INFO, l3_ie) == false) {
1776 setverdict(fail, "cannot find L3");
1777 mtc.stop;
1778 }
1779 l3 := dec_PDU_ML3_NW_MS(l3_ie.l3_info.payload);
1780
1781 int2enum(oct2int(l3.msgs.rrm.channelRelease.rRCause.valuePart), got_cause);
1782 log("GOT CAUSE CODE: ", l3.msgs.rrm.channelRelease.rRCause.valuePart, " = ", got_cause);
1783 if (match(got_cause, expect_rr_cause)) {
1784 setverdict(pass);
1785 } else {
1786 log("EXPECTED CAUSE CODE: ", expect_rr_cause);
1787 setverdict(fail, "Received RR Channel Release Cause code does not match expectations");
1788 }
1789 }
Neels Hofmeyr211169d2018-11-07 00:37:29 +01001790 repeat;
1791 }
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001792 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(tr_RSL_REL_REQ(rsl_chan_nr, ?))) {
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001793 got_rll_rel_req := true;
Harald Welte91d54a52018-01-28 15:35:07 +01001794 /* FIXME: Why are we getting this for LinkID SACCH? */
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001795 if (handle_rll_rel) {
1796 f_ipa_tx(0, ts_RSL_REL_CONF(rsl_chan_nr, main_dcch));
1797 }
Harald Welte91d54a52018-01-28 15:35:07 +01001798 repeat;
1799 }
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001800 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL))) {
Harald Welte91d54a52018-01-28 15:35:07 +01001801 /* respond with CHAN REL ACK */
1802 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(rsl_chan_nr));
1803 }
1804 /* ignore any user data */
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001805 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(tr_RSL_MsgTypeR(?))) {
Harald Welte91d54a52018-01-28 15:35:07 +01001806 repeat;
1807 }
1808 }
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001809
1810 log("f_expect_chan_rel() summary: got_deact_sacch=", got_deact_sacch, " got_rr_chan_rel=", got_rr_chan_rel,
1811 " got_rll_rel_req=", got_rll_rel_req);
1812
1813 if (expect_deact_sacch != got_deact_sacch) {
1814 setverdict(fail, "f_expect_chan_rel(): expect_deact_sacch=", expect_deact_sacch, " got_deact_sacch=", got_deact_sacch);
1815 }
1816 if (expect_rr_chan_rel != got_rr_chan_rel) {
1817 setverdict(fail, "f_expect_chan_rel(): expect_rr_chan_rel=", expect_rr_chan_rel, " got_rr_chan_rel=", got_rr_chan_rel);
1818 }
1819 if (expect_rll_rel_req != got_rll_rel_req) {
1820 setverdict(fail, "f_expect_chan_rel(): expect_rll_rel_req=", expect_rll_rel_req, " got_rll_rel_req=", got_rll_rel_req);
1821 }
Harald Welte91d54a52018-01-28 15:35:07 +01001822}
1823
Harald Welte4003d112017-12-09 22:35:39 +01001824/* Test behavior of channel release after hard Clear Command from MSC */
1825testcase TC_chan_rel_hard_clear() runs on test_CT {
1826 var BSSAP_N_DATA_ind rx_di;
Harald Welte4003d112017-12-09 22:35:39 +01001827 var DchanTuple dt;
Harald Welte4003d112017-12-09 22:35:39 +01001828
Harald Welte89d42e82017-12-17 16:42:41 +01001829 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +01001830
1831 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1832
1833 /* Instruct BSC to clear channel */
1834 var BssmapCause cause := 0;
1835 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
1836
1837 /* expect Clear Complete from BSC on A */
1838 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete)) {
1839 /* release the SCCP connection */
1840 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
1841 }
1842
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001843 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001844 f_shutdown_helper();
Harald Welte4003d112017-12-09 22:35:39 +01001845}
1846
Harald Welte99787102019-02-04 10:41:36 +01001847/* Test behavior of channel release after Clear Command with CSFB indicator from MSC */
1848testcase TC_chan_rel_hard_clear_csfb() runs on test_CT {
1849 var BSSAP_N_DATA_ind rx_di;
1850 var DchanTuple dt;
1851
1852 f_init(1);
1853
1854 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1855
1856 /* Instruct BSC to clear channel */
1857 var BssmapCause cause := 0;
1858 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommandCSFB(cause)));
1859
1860 /* expect Clear Complete from BSC on A */
1861 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete)) {
1862 /* release the SCCP connection */
1863 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
1864 }
1865
1866 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 +02001867 f_shutdown_helper();
Harald Welte99787102019-02-04 10:41:36 +01001868}
1869
Harald Welted8c36cd2017-12-09 23:05:31 +01001870/* Test behavior of channel release after hard RLSD from MSC */
1871testcase TC_chan_rel_hard_rlsd() runs on test_CT {
Harald Welted8c36cd2017-12-09 23:05:31 +01001872 var DchanTuple dt;
Harald Welted8c36cd2017-12-09 23:05:31 +01001873
Harald Welte89d42e82017-12-17 16:42:41 +01001874 f_init(1);
Harald Welted8c36cd2017-12-09 23:05:31 +01001875
1876 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1877
1878 /* release the SCCP connection */
1879 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
1880
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001881 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001882 f_shutdown_helper();
Harald Welted8c36cd2017-12-09 23:05:31 +01001883}
1884
Harald Welte550daf92018-06-11 19:22:13 +02001885/* Test behavior of channel release after hard RLSD from MSC and MS is not responding to RLL REL REQ */
1886testcase TC_chan_rel_hard_rlsd_ms_dead() runs on test_CT {
1887 var DchanTuple dt;
1888
1889 f_init(1);
1890
1891 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1892
1893 /* release the SCCP connection */
1894 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
1895
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001896 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001897 f_shutdown_helper();
Harald Welte550daf92018-06-11 19:22:13 +02001898}
1899
Harald Welte85804d42017-12-10 14:11:58 +01001900/* Test behavior of channel release after BSSMAP RESET from MSC */
1901testcase TC_chan_rel_a_reset() runs on test_CT {
Harald Welte85804d42017-12-10 14:11:58 +01001902 var DchanTuple dt;
Harald Welte85804d42017-12-10 14:11:58 +01001903
Harald Welte89d42e82017-12-17 16:42:41 +01001904 f_init(1);
Harald Welte85804d42017-12-10 14:11:58 +01001905
1906 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1907
1908 /* Clear the queue, it might still contain stuff like IMMEDIATE ASSIGN */
1909 IPA_RSL[0].clear;
1910
1911 /* perform BSSAP RESET, expect RESET ACK and DISC.ind on connection */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001912 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 +01001913 interleave {
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001914 [] 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 +01001915 [] BSSAP.receive(tr_BSSAP_DISC_ind(dt.sccp_conn_id, ?, ?)) { }
1916 }
1917
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001918 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001919 f_shutdown_helper();
Harald Welte85804d42017-12-10 14:11:58 +01001920}
1921
Pau Espin Pedrolc675b612020-01-09 19:55:40 +01001922/* Verify T(iar) triggers and releases the channel */
1923testcase TC_chan_rel_sccp_tiar_timeout() runs on test_CT {
1924 var DchanTuple dt;
1925
1926 /* Set T(iar) in BSC low enough that it will trigger before other side
1927 has time to keep alive with a T(ias). Keep recommended ratio of
1928 T(iar) >= T(ias)*2 */
1929 g_bsc_sccp_timer_ias := 2;
1930 g_bsc_sccp_timer_iar := 5;
1931
1932 f_init(1);
1933
1934 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1935 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001936 f_shutdown_helper();
Pau Espin Pedrolc675b612020-01-09 19:55:40 +01001937}
1938
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02001939private function f_tc_chan_rel_rr_cause(myBSSMAP_Cause clear_cmd_cause, template RR_Cause expect_rr_cause)
1940runs on test_CT
1941{
1942 var DchanTuple dt;
1943
1944 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1945 var BssmapCause cause := 0;
1946 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(enum2int(clear_cmd_cause))));
1947 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete)) {
1948 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
1949 }
1950
1951 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false, expect_rr_cause := expect_rr_cause);
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02001952}
1953
1954/* Test that Clear Command cause codes affect the RR Channel Release cause code */
1955testcase TC_chan_rel_rr_cause() runs on test_CT {
1956 f_init(1);
1957
1958 f_tc_chan_rel_rr_cause(GSM0808_CAUSE_CALL_CONTROL, GSM48_RR_CAUSE_NORMAL);
1959 f_tc_chan_rel_rr_cause(GSM0808_CAUSE_HANDOVER_SUCCESSFUL, GSM48_RR_CAUSE_NORMAL);
1960 f_tc_chan_rel_rr_cause(GSM0808_CAUSE_PREEMPTION, GSM48_RR_CAUSE_PREMPTIVE_REL);
1961 f_tc_chan_rel_rr_cause(GSM0808_CAUSE_RADIO_INTERFACE_MESSAGE_FAILURE, GSM48_RR_CAUSE_PROT_ERROR_UNSPC);
1962 f_tc_chan_rel_rr_cause(GSM0808_CAUSE_RADIO_INTERFACE_FAILURE, GSM48_RR_CAUSE_ABNORMAL_UNSPEC);
1963 f_tc_chan_rel_rr_cause(GSM0808_CAUSE_EQUIPMENT_FAILURE, GSM48_RR_CAUSE_ABNORMAL_UNSPEC);
Vadim Yanitskiye18aebb2021-01-03 13:10:43 +01001964
1965 f_shutdown_helper();
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02001966}
1967
Harald Welte5cd20ed2017-12-13 21:03:20 +01001968/* Test behavior if RSL EST IND for non-active channel */
1969testcase TC_rll_est_ind_inact_lchan() runs on test_CT {
1970 timer T := 2.0;
1971
Harald Welte89d42e82017-12-17 16:42:41 +01001972 f_init(1);
Harald Welte5cd20ed2017-12-13 21:03:20 +01001973
1974 var octetstring l3 := '00010203040506'O;
1975 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(6));
1976 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
1977
1978 T.start;
1979 alt {
1980 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) {
1981 setverdict(fail, "MSC received COMPL L3 for non-active lchan");
1982 }
1983 [] BSSAP.receive {}
1984 [] IPA_RSL[0].receive {}
1985 [] T.timeout {}
1986 }
1987
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001988 f_shutdown_helper();
Harald Welte5cd20ed2017-12-13 21:03:20 +01001989}
1990
1991/* Test behavior if RSL EST IND for invalid SAPI */
1992testcase TC_rll_est_ind_inval_sapi1() runs on test_CT {
1993 var RslChannelNr chan_nr;
1994
Harald Welte89d42e82017-12-17 16:42:41 +01001995 f_init(1);
Harald Welte5cd20ed2017-12-13 21:03:20 +01001996
1997 chan_nr := f_chreq_act_ack()
1998
1999 var octetstring l3 := '00010203040506'O;
2000 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(1)), l3));
2001
2002 timer T := 2.0;
2003 T.start;
2004 alt {
2005 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) {
2006 setverdict(fail, "MSC received COMPL L3 for invalid SAPI 1");
2007 }
2008 [] BSSAP.receive { repeat; }
2009 [] IPA_RSL[0].receive { repeat; }
2010 [] T.timeout {}
2011 }
2012
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002013 f_shutdown_helper();
Harald Welte5cd20ed2017-12-13 21:03:20 +01002014}
2015
2016/* Test behavior if RSL EST IND for invalid SAPI */
2017testcase TC_rll_est_ind_inval_sapi3() runs on test_CT {
2018 timer T := 2.0;
2019
Harald Welte89d42e82017-12-17 16:42:41 +01002020 f_init(1);
Harald Welte5cd20ed2017-12-13 21:03:20 +01002021
2022 var RslChannelNr chan_nr := f_chreq_act_ack();
2023
2024 var octetstring l3 := '00010203040506'O;
2025 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(3)), l3));
2026
2027 T.start;
2028 alt {
2029 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) {
2030 setverdict(fail, "MSC received COMPL L3 for invalid SAPI 3");
2031 }
2032 [] BSSAP.receive { repeat; }
2033 [] IPA_RSL[0].receive { repeat; }
2034 [] T.timeout {}
2035 }
2036
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002037 f_shutdown_helper();
Harald Welte5cd20ed2017-12-13 21:03:20 +01002038}
2039
2040/* Test behavior if RSL EST IND for invalid SACCH */
2041testcase TC_rll_est_ind_inval_sacch() runs on test_CT {
2042 timer T := 2.0;
2043
Harald Welte89d42e82017-12-17 16:42:41 +01002044 f_init(1);
Harald Welte5cd20ed2017-12-13 21:03:20 +01002045
2046 var RslChannelNr chan_nr := f_chreq_act_ack();
2047
2048 var octetstring l3 := '00010203040506'O;
2049 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_SACCH(0)), l3));
2050
2051 T.start;
2052 alt {
2053 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) {
2054 setverdict(fail, "MSC received COMPL L3 for invalid Link SACCH");
2055 }
2056 [] BSSAP.receive { repeat; }
2057 [] IPA_RSL[0].receive { repeat; }
2058 [] T.timeout {}
2059 }
2060
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002061 f_shutdown_helper();
Harald Welte5cd20ed2017-12-13 21:03:20 +01002062}
2063
Vadim Yanitskiy61f784a2020-10-01 21:12:19 +07002064/* Verify DLCI / RSL Link ID conversion for MO/MT messages on SAPI0/SAPI3 */
2065private function f_TC_tch_dlci_link_id_sapi(charstring id) runs on MSC_ConnHdlr {
2066 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
2067 var PDU_BSSAP ass_cmd := f_gen_ass_req();
2068
2069 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
2070 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
2071
2072 f_establish_fully(ass_cmd, exp_compl);
2073
2074 /* SAPI0 has already been established by f_establish_fully(), establish SAPI3 */
2075 RSL.send(ts_RSL_EST_IND(g_chan_nr, ts_RslLinkID_SACCH(3), '0904'O));
2076 /* Expect BSSAP/DTAP on SAPI3 (DLCI IE) */
2077 BSSAP.receive(PDU_BSSAP:{
2078 discriminator := '1'B,
2079 spare := '0000000'B,
2080 dlci := 'C3'O,
2081 lengthIndicator := ?,
2082 pdu := { dtap := '0904'O }
2083 });
2084
2085 /* Send messages on DCCH/SAPI0 and ACCH/SAPI3 */
2086 for (var integer i := 0; i < 32; i := i + 1) {
2087 var octetstring l3 := '09'O & f_rnd_octstring(14);
2088 var template (value) RslLinkId link_id;
2089 var template (value) OCT1 dlci;
2090
2091 if (i mod 2 == 0) {
2092 /* SAPI0 on FACCH or SDCCH */
2093 link_id := ts_RslLinkID_DCCH(0);
2094 dlci := '80'O;
2095 } else {
2096 /* SAPI3 on SACCH */
2097 link_id := ts_RslLinkID_SACCH(3);
2098 dlci := 'C3'O;
2099 }
2100
2101 /* Send MO message: RSL -> BSSAP */
Neels Hofmeyr0aa719b2020-10-12 18:43:09 +00002102 f_mo_l3_transceive(RSL, link_id, dlci, l3);
Vadim Yanitskiy61f784a2020-10-01 21:12:19 +07002103 /* Send MT message: BSSAP -> RSL */
Neels Hofmeyr0aa719b2020-10-12 18:43:09 +00002104 f_mt_l3_transceive(RSL, link_id, dlci, l3);
Vadim Yanitskiy61f784a2020-10-01 21:12:19 +07002105 }
2106}
2107testcase TC_tch_dlci_link_id_sapi() runs on test_CT {
2108 var TestHdlrParams pars := f_gen_test_hdlr_pars();
2109 var MSC_ConnHdlr vc_conn;
2110
2111 f_init(1, true);
2112 f_sleep(1.0);
2113
2114 vc_conn := f_start_handler(refers(f_TC_tch_dlci_link_id_sapi), pars);
2115 vc_conn.done;
2116
2117 f_shutdown_helper();
2118}
2119
Vadim Yanitskiy6ef5dfa2020-08-28 18:04:41 +07002120private function f_exp_sapi_n_reject(template (present) GsmSapi sapi := ?,
2121 template myBSSMAP_Cause cause := ?,
2122 float T_val := 2.0)
2123runs on test_CT {
2124 var BSSAP_N_DATA_ind rx_di;
2125 timer T;
2126
2127 var template BSSMAP_IE_Cause tr_cause := tr_BSSMAP_IE_Cause(cause);
2128 var template PDU_BSSAP tr_pdu := tr_BSSMAP_SAPInReject(sapi);
2129
2130 T.start(T_val);
2131 alt {
2132 [] BSSAP.receive(tr_BSSAP_DATA_ind(?, tr_pdu)) -> value rx_di {
2133 var BSSMAP_IE_Cause rx_cause := rx_di.userData.pdu.bssmap.sAPInReject.cause;
2134 if (not match(rx_cause, tr_cause)) {
2135 setverdict(fail, "Rx unexpected Cause IE: ",
2136 rx_cause, " vs expected ", tr_cause);
2137 }
2138 setverdict(pass);
2139 }
2140 [] BSSAP.receive(BSSAP_N_DATA_ind:?) -> value rx_di {
2141 setverdict(fail, "Rx unexpected BSSAP PDU: ", rx_di);
2142 }
2143 [] T.timeout {
2144 setverdict(fail, "Timeout waiting for BSSMAP SAPI N Reject");
2145 }
2146 }
2147}
2148
2149/* Check if we get SAPI N Reject on receipt of unexpected RLL RELease INDication */
2150testcase TC_rll_rel_ind_sapi_n_reject() runs on test_CT {
2151 var octetstring rnd_data := f_rnd_octstring(16);
2152 var RSL_Message rx_rsl;
2153 var DchanTuple dt;
2154
2155 f_init(1);
2156
2157 /* MS establishes a SAPI=0 link on DCCH */
2158 dt := f_est_dchan(f_rnd_ra_cs(), 23, rnd_data);
2159
2160 /* MSC sends some data on (not yet established) SAPI=3 link */
2161 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSAP_DTAP(rnd_data, '03'O)));
2162 /* BSC attempts to establish a SAPI=3 link on DCCH */
2163 rx_rsl := f_exp_ipa_rx(0, tr_RSL_EST_REQ(dt.rsl_chan_nr, tr_RslLinkID_DCCH(3)));
2164
2165 /* MS sends unexpected RELease INDication on SAPI=3 */
2166 f_ipa_tx(0, ts_RSL_REL_IND(dt.rsl_chan_nr, ts_RslLinkID_DCCH(3)));
2167 /* We expect to receive BSSMAP SAPI N Reject message from the BSC */
2168 f_exp_sapi_n_reject(3, GSM0808_CAUSE_MS_NOT_EQUIPPED);
2169
2170 /* Clean up the connection */
2171 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
2172 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
2173
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002174 f_shutdown_helper();
Vadim Yanitskiy6ef5dfa2020-08-28 18:04:41 +07002175}
2176
2177/* Check if we get SAPI N Reject on receipt of unexpected RLL ERROR INDication */
2178testcase TC_rll_err_ind_sapi_n_reject() runs on test_CT {
2179 var octetstring rnd_data := f_rnd_octstring(16);
2180 var RSL_Message rx_rsl;
2181 var DchanTuple dt;
2182
2183 f_init(1);
2184
2185 /* MS establishes a SAPI=0 link on DCCH */
2186 dt := f_est_dchan(f_rnd_ra_cs(), 23, rnd_data);
2187
2188 /* MSC sends some data on (not yet established) SAPI=3 link */
2189 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSAP_DTAP(rnd_data, '03'O)));
2190 /* BSC attempts to establish a SAPI=3 link on DCCH */
2191 rx_rsl := f_exp_ipa_rx(0, tr_RSL_EST_REQ(dt.rsl_chan_nr, tr_RslLinkID_DCCH(3)));
2192
2193 /* BTS sends unexpected ERROR INDication on SAPI=3 */
2194 f_ipa_tx(0, ts_RSL_ERROR_IND(dt.rsl_chan_nr, ts_RslLinkID_DCCH(3), ''O));
2195 /* We expect to receive BSSMAP SAPI N Reject message from the BSC */
2196 f_exp_sapi_n_reject(3, GSM0808_CAUSE_BSS_NOT_EQUIPPED);
2197
2198 /* Clean up the connection */
2199 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
2200 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
2201
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002202 f_shutdown_helper();
Vadim Yanitskiy6ef5dfa2020-08-28 18:04:41 +07002203}
2204
2205/* Check if we get SAPI N Reject due to a SAPI=3 link establishment timeout */
2206testcase TC_rll_timeout_sapi_n_reject() runs on test_CT {
2207 var octetstring rnd_data := f_rnd_octstring(16);
2208 var RSL_Message rx_rsl;
2209 var DchanTuple dt;
2210
2211 f_init(1);
2212
2213 /* MS establishes a SAPI=0 link on DCCH */
2214 dt := f_est_dchan(f_rnd_ra_cs(), 23, rnd_data);
2215
2216 /* MSC sends some data on (not yet established) SAPI=3 link */
2217 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSAP_DTAP(rnd_data, '03'O)));
2218 /* BSC attempts to establish a SAPI=3 link on DCCH */
2219 rx_rsl := f_exp_ipa_rx(0, tr_RSL_EST_REQ(dt.rsl_chan_nr, tr_RslLinkID_DCCH(3)));
2220
2221 /* MS does not respond, so the link establishment timeout triggers SAPI N Reject */
2222 f_exp_sapi_n_reject(3, GSM0808_CAUSE_BSS_NOT_EQUIPPED, T_val := 8.0);
2223
2224 /* Clean up the connection */
2225 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
2226 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
2227
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002228 f_shutdown_helper();
Vadim Yanitskiy6ef5dfa2020-08-28 18:04:41 +07002229}
2230
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +02002231testcase TC_si_default() runs on test_CT {
2232 f_init(0);
2233 f_init_bts_and_check_sysinfo(0, expect_si := SystemInformationConfig_default);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002234 f_shutdown_helper();
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +02002235}
Harald Welte4003d112017-12-09 22:35:39 +01002236
Neels Hofmeyr56f24782020-07-09 00:50:49 +02002237/* We're testing SI2quater with lists of EARFCNs. Instead of just incrementing EARFCNs, also pick some from the edges of
2238 * the entire value range. This function provides the same EARFCN numbers for the same earfcn_index */
2239private function f_test_si2quater_earfcn_by_idx(integer earfcn_index) return uint16_t
2240{
2241 select (earfcn_index) {
2242 case (0) {
2243 /* E-ARFCN 111 is already added in the osmo-bsc.cfg */
2244 return 111;
2245 }
2246 case (1) {
2247 return 1;
2248 }
2249 case (2) {
2250 return 0;
2251 }
2252 case (3) {
2253 return 65535;
2254 }
2255 case else {
2256 return 23 * (earfcn_index - 3);
2257 }
2258 }
2259}
2260
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02002261function f_test_si2quater(integer total_earfcns, template SystemInformationConfig expect_si,
2262 template CellSelIndValue expect_cells := omit) runs on test_CT {
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002263
2264 f_init(0);
2265
2266 /* E-ARFCN 111 is already added in the osmo-bsc.cfg, so only add more arfcns if total_earfcns > 1 */
2267 for (var integer i := 1; i < total_earfcns; i := i + 1) {
Neels Hofmeyr56f24782020-07-09 00:50:49 +02002268 f_bts_0_cfg(BSCVTY, {"si2quater neighbor-list add earfcn " & int2str(f_test_si2quater_earfcn_by_idx(i))
2269 & " thresh-hi 20 thresh-lo 10 prio 3 qrxlv 22 meas 3"});
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002270 }
2271
2272 f_init_bts_and_check_sysinfo(0, expect_si := expect_si);
2273
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02002274 f_init(1);
2275
2276 if (not istemplatekind(expect_cells, "omit")) {
2277 /* Also check that RR Channel Release contains these EARFCNs.
2278 * (copied code from TC_chan_rel_hard_clear_csfb) */
2279 var BSSAP_N_DATA_ind rx_di;
2280 var DchanTuple dt;
2281
2282 dt := f_est_dchan('23'O, 23, '00010203040506'O);
2283
2284 /* Instruct BSC to clear channel */
2285 var BssmapCause cause := 0;
2286 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommandCSFB(cause)));
2287
2288 /* expect Clear Complete from BSC on A */
2289 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete)) {
2290 /* release the SCCP connection */
2291 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
2292 }
2293
2294 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false, is_csfb := true,
2295 csfb_expect_cells := expect_cells);
2296 }
2297
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002298 for (var integer i := 1; i < total_earfcns; i := i + 1) {
Neels Hofmeyr56f24782020-07-09 00:50:49 +02002299 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 +02002300 }
2301}
2302
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002303private function f_tr_si2quater_earfcns(integer count) return template SI2quaterRestOctetsList
2304{
2305 var template SI2quaterRestOctetsList si2quater := {};
2306 var integer si2quater_count := (count + 2) / 3;
2307
2308 for (var integer i := 0; i < count; i := i + 1) {
Neels Hofmeyr56f24782020-07-09 00:50:49 +02002309 var integer earfcn := f_test_si2quater_earfcn_by_idx(i);
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002310 var integer index := i / 3;
2311 var integer earfcn_index := i mod 3;
2312 if (index >= lengthof(si2quater)) {
2313 si2quater[index] := tr_SI2quaterRestOctets_EUTRAN(index := index, count := si2quater_count - 1);
2314 }
2315 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);
2316 }
2317
2318 return si2quater;
2319}
2320
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02002321private function f_tr_rr_chan_rel_earfcns(integer count) return template CellSelIndValue
2322{
2323 var template CellSelIndValue_EUTRAN_Descrs cells := {};
2324
Alexander Couzensf74b5cb2020-09-10 22:28:40 +02002325 /* the lte neighbors must match the config & vty to pass this test */
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02002326 for (var integer i := 0; i < count; i := i + 1) {
2327 var integer earfcn := f_test_si2quater_earfcn_by_idx(i);
Alexander Couzensf74b5cb2020-09-10 22:28:40 +02002328 cells[i] := tr_CellSelIndValue_EUTRAN_Descr(earfcn, '1'B, 3);
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02002329 }
2330
2331 return tr_CellSelIndValue_EUTRAN(cells);
2332}
2333
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002334private function f_tc_si2quater_n_earfcns(integer n) runs on test_CT
2335{
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002336 var template SystemInformationConfig sic := SystemInformationConfig_default;
Pau Espin Pedrol8ab62e42020-12-18 16:19:11 +01002337 sic.si2quater := f_tr_si2quater_earfcns(n);
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02002338 var template CellSelIndValue cells := f_tr_rr_chan_rel_earfcns(n);
2339 f_test_si2quater(n, sic, cells);
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002340}
2341
2342testcase TC_si2quater_2_earfcns() runs on test_CT {
2343 f_tc_si2quater_n_earfcns(2);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002344 f_shutdown_helper();
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002345}
2346
2347testcase TC_si2quater_3_earfcns() runs on test_CT {
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002348 f_tc_si2quater_n_earfcns(3);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002349 f_shutdown_helper();
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002350}
2351
2352testcase TC_si2quater_4_earfcns() runs on test_CT {
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002353 f_tc_si2quater_n_earfcns(4);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002354 f_shutdown_helper();
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002355}
2356
2357testcase TC_si2quater_5_earfcns() runs on test_CT {
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002358 f_tc_si2quater_n_earfcns(5);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002359 f_shutdown_helper();
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002360}
2361
2362testcase TC_si2quater_6_earfcns() runs on test_CT {
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002363 f_tc_si2quater_n_earfcns(6);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002364 f_shutdown_helper();
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002365}
2366
2367testcase TC_si2quater_12_earfcns() runs on test_CT {
2368 f_tc_si2quater_n_earfcns(12);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002369 f_shutdown_helper();
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002370}
2371
2372testcase TC_si2quater_23_earfcns() runs on test_CT {
2373 f_tc_si2quater_n_earfcns(23);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002374 f_shutdown_helper();
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002375}
2376
2377testcase TC_si2quater_32_earfcns() runs on test_CT {
2378 f_tc_si2quater_n_earfcns(32);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002379 f_shutdown_helper();
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002380}
2381
2382testcase TC_si2quater_33_earfcns() runs on test_CT {
2383 f_tc_si2quater_n_earfcns(33);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002384 f_shutdown_helper();
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002385}
2386
2387testcase TC_si2quater_42_earfcns() runs on test_CT {
2388 f_tc_si2quater_n_earfcns(42);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002389 f_shutdown_helper();
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002390}
2391
2392testcase TC_si2quater_48_earfcns() runs on test_CT {
2393 f_tc_si2quater_n_earfcns(48);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002394 f_shutdown_helper();
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002395}
2396
2397/* verify the VTY error response when adding too many EARFCNs, and showing that osmo-bsc still sends 16 SI2quater with
2398 * 48 EARFCNs. */
2399testcase TC_si2quater_49_earfcns() runs on test_CT {
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002400 var template SystemInformationConfig sic := SystemInformationConfig_default;
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002401 sic.si2quater := f_tr_si2quater_earfcns(48); /* 48, not 49! */
2402 f_init(0);
2403
2404 for (var integer i := 1; i < 48; i := i + 1) {
Neels Hofmeyr56f24782020-07-09 00:50:49 +02002405 f_bts_0_cfg(BSCVTY, {"si2quater neighbor-list add earfcn " & int2str(f_test_si2quater_earfcn_by_idx(i))
2406 & " thresh-hi 20 thresh-lo 10 prio 3 qrxlv 22 meas 3"});
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002407 }
2408
2409 /* The 49th EARFCN no longer fits, expect VTY error */
2410 f_vty_enter_cfg_bts(BSCVTY, 0);
2411 var charstring vty_error;
2412 vty_error := f_vty_transceive_ret(BSCVTY,
2413 "si2quater neighbor-list add earfcn 70 thresh-hi 20 thresh-lo 10 prio 3 qrxlv 22 meas 3")
2414 f_vty_transceive(BSCVTY, "end");
2415
2416 if (f_strstr(vty_error, "Unable to add ARFCN 70") >= 0) {
2417 log("Got expected VTY error: ", vty_error);
2418 setverdict(pass);
2419 } else {
2420 setverdict(fail, "Expected the 49th EUTRAN ARFCN to be rejected by vty config, got: ", vty_error);
2421 }
2422
2423 f_init_bts_and_check_sysinfo(0, expect_si := sic);
2424
2425 for (var integer i := 1; i < 48; i := i + 1) {
Neels Hofmeyr56f24782020-07-09 00:50:49 +02002426 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 +02002427 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002428 f_shutdown_helper();
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002429}
2430
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02002431private function f_acc09_count_allowed(AccessControlClass acc) return uint8_t
2432{
2433 var uint8_t count := 0;
2434 for (var integer i := 5; i < 16; i := i + 1) {
2435 if (acc[i] == '0'B) { /* the list marks barred, we count allowed */
2436 count := count + 1;
2437 }
2438 }
2439 return count;
2440}
2441
Pau Espin Pedrolc6136cd2020-07-24 13:20:02 +02002442private function f_recv_next_si1(integer rsl_idx := 0) runs on test_CT return SystemInformationType1
2443{
2444 var ASP_RSL_Unitdata rx_rsl_ud;
2445 var SystemInformationType1 last_si1;
2446
2447 timer T := 30.0;
2448 T.start;
2449 alt {
2450 [] IPA_RSL[rsl_idx].receive(tr_ASP_RSL_UD((tr_RSL_NO_BCCH_INFO,
2451 tr_RSL_BCCH_INFO,
2452 tr_RSL_NO_SACCH_FILL,
2453 tr_RSL_SACCH_FILL))
2454 ) -> value rx_rsl_ud {
2455 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
2456 if (g_system_information[rsl_idx].si1 == omit) {
2457 repeat;
2458 }
2459 last_si1 := g_system_information[rsl_idx].si1;
2460 g_system_information[rsl_idx].si1 := omit;
2461 T.stop;
2462 }
2463 [] T.timeout { setverdict(fail, "Timeout receiving next SI1"); }
2464 }
2465 return last_si1;
2466}
2467
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02002468/* verify ACC rotate feature */
2469testcase TC_si_acc_rotate() runs on test_CT {
2470 var template SystemInformationConfig sic := SystemInformationConfig_default;
Pau Espin Pedrolc6136cd2020-07-24 13:20:02 +02002471 var SystemInformationType1 last_si1;
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02002472 var AccessControlClass acc;
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02002473 var uint8_t count;
2474 var integer times_allowed[10] := { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
2475
2476 f_init(0, guard_timeout := 60.0);
2477
2478 f_bts_0_cfg(BSCVTY, {"rach access-control-class 5 barred",
2479 "access-control-class-rotate 3",
2480 "access-control-class-rotate-quantum 1"});
2481
2482 /* Init and get first sysinfo */
2483 f_init_bts_and_check_sysinfo(0, expect_si := ?);
2484
Pau Espin Pedrolc6136cd2020-07-24 13:20:02 +02002485 for (var integer i:= 0; i < 20; i := i + 1) {
2486 last_si1 := f_recv_next_si1(0);
2487 acc := last_si1.rach_control.acc;
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02002488 count := f_acc09_count_allowed(acc);
2489 log("RSL: GOT SI1 ACC len=", count, ": ", acc);
2490
2491 if (count != 3) {
2492 log("RSL: EXPECTED SI ACC len=3");
2493 setverdict(fail, "received SI does not match expectations");
2494 break;
2495 }
2496
2497 for (var integer j := 0; j < 10; j := j + 1) {
2498 if (acc[16 - 1 - j] == '0'B) { /* the list marks barred, we count allowed */
2499 times_allowed[j] := times_allowed[j] + 1;
2500 }
2501 }
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02002502 }
2503
2504 for (var integer j := 0; j < 10; j := j + 1) {
2505 log("ACC", j, " allowed ", times_allowed[j], " times" );
2506 if (j != 5 and times_allowed[j] < 3) {
2507 setverdict(fail, "ACC", j, " ERROR: allowed ", times_allowed[j], " < 1 times");
2508 } else if (j == 5 and times_allowed[j] > 0) {
2509 setverdict(fail, "ACC", j, " ERROR: allowed ", times_allowed[j], " > 0 times");
2510 }
2511 }
2512
2513 f_bts_0_cfg(BSCVTY, {"access-control-class-rotate 10",
2514 "rach access-control-class 5 allowed"});
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002515 f_shutdown_helper();
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02002516}
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002517
Pau Espin Pedrolc6136cd2020-07-24 13:20:02 +02002518/* verify ACC startup ramp+rotate feature */
2519testcase TC_si_acc_ramp_rotate() runs on test_CT {
2520 var template SystemInformationConfig sic := SystemInformationConfig_default;
2521 var SystemInformationType1 last_si1;
2522 var AccessControlClass acc;
2523 var ASP_RSL_Unitdata rx_rsl_ud;
2524 var uint8_t count;
2525 var uint8_t prev_count;
2526 var integer times_allowed[10] := { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
2527
2528 f_init(0, guard_timeout := 80.0);
2529
2530 f_bts_0_cfg(BSCVTY, {"rach access-control-class 4 barred",
2531 "access-control-class-rotate 0",
2532 "access-control-class-rotate-quantum 1",
2533 "access-control-class-ramping",
2534 "access-control-class-ramping-step-interval 5",
2535 "access-control-class-ramping-step-size 5"});
2536
2537 /* Init and get first sysinfo */
2538 f_init_bts_and_check_sysinfo(0, expect_si := ?);
2539 last_si1 := g_system_information[0].si1;
2540 acc := last_si1.rach_control.acc;
2541 count := f_acc09_count_allowed(acc);
2542 /* Adm subset size was set to 0 above, so wait until all ACC are barred */
2543 while (count > 0) {
2544 last_si1 := f_recv_next_si1(0);
2545 acc := last_si1.rach_control.acc;
2546 count := f_acc09_count_allowed(acc);
2547 log("RSL: wait len()=0: GOT SI1 ACC len=", count, ": ", acc);
2548 }
2549
2550 /* Increase adm subset size, we should see ramping start up */
2551 f_bts_0_cfg(BSCVTY, {"access-control-class-rotate 10"});
2552 prev_count := 0;
2553 while (true) {
2554 last_si1 := f_recv_next_si1(0);
2555 acc := last_si1.rach_control.acc;
2556 count := f_acc09_count_allowed(acc);
2557 log("RSL: GOT SI1 ACC len=", count, ": ", acc);
2558
2559 if (prev_count > count) {
2560 setverdict(fail, "ACC allowed count dropped while expecting grow: ", prev_count, " -> ", count);
2561 break;
2562 }
2563
2564 if (count == 9) {
2565 break; /* Maximum reached (10 - 1 perm barred), done here */
2566 }
2567
2568 prev_count := count;
2569 }
2570
2571 setverdict(pass);
2572
2573 f_bts_0_cfg(BSCVTY, {"access-control-class-rotate 10",
2574 "rach access-control-class 4 allowed",
2575 "no access-control-class-ramping"});
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002576 f_shutdown_helper();
Pau Espin Pedrolc6136cd2020-07-24 13:20:02 +02002577}
2578
Harald Welte4003d112017-12-09 22:35:39 +01002579testcase TC_ctrl_msc_connection_status() runs on test_CT {
2580 var charstring ctrl_resp;
2581
Harald Welte89d42e82017-12-17 16:42:41 +01002582 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +01002583
2584 /* See https://osmocom.org/issues/2729 */
2585 f_ctrl_get_exp(IPA_CTRL, "msc_connection_status", "connected");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002586 f_shutdown_helper();
Harald Welte4003d112017-12-09 22:35:39 +01002587}
2588
Stefan Sperlingb041b3d2018-01-03 17:14:55 +01002589testcase TC_ctrl_msc0_connection_status() runs on test_CT {
2590 var charstring ctrl_resp;
2591
2592 f_init(1);
Stefan Sperlingb041b3d2018-01-03 17:14:55 +01002593
2594 f_ctrl_get_exp(IPA_CTRL, "msc.0.connection_status", "connected");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002595 f_shutdown_helper();
Stefan Sperlingb041b3d2018-01-03 17:14:55 +01002596}
2597
Harald Welte4003d112017-12-09 22:35:39 +01002598testcase TC_ctrl() runs on test_CT {
2599 var charstring ctrl_resp;
2600
Harald Welte89d42e82017-12-17 16:42:41 +01002601 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +01002602
2603 /* all below values must match the osmo-bsc.cfg config file used */
2604
Harald Welte6a129692018-03-17 17:30:14 +01002605 f_ctrl_get_exp(IPA_CTRL, "mcc", "001");
2606 f_ctrl_get_exp(IPA_CTRL, "mnc", "01");
Oliver Smith75aa0202019-08-19 14:17:50 +02002607 f_ctrl_get_exp(IPA_CTRL, "number-of-bts", "4");
Harald Welte4003d112017-12-09 22:35:39 +01002608
2609 var integer bts_nr := 0;
2610 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "location-area-code", "1");
2611 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "cell-identity", "0");
2612 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "oml-connection-state", "connected");
2613 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "gprs-mode", "gprs");
2614 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "rf_state", "operational,unlocked,on");
2615 f_ctrl_get_exp_trx(IPA_CTRL, bts_nr, 0, "arfcn", "871");
2616 f_ctrl_get_exp_trx(IPA_CTRL, bts_nr, 0, "max-power-reduction", "20");
2617
2618 var integer uptime := str2int(f_ctrl_get_bts(IPA_CTRL, bts_nr, "oml-uptime"));
2619 f_sleep(2.0);
2620 if (str2int(f_ctrl_get_bts(IPA_CTRL, bts_nr, "oml-uptime")) < uptime+1) {
2621 setverdict(fail, "oml-uptime not incrementing as expected");
2622 }
2623 /* TODO: Disconnect RSL, imply that OML is disconnected and check for uptime zero? */
2624
2625 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bsc", 0, "paging:attempted", 0);
2626
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002627 f_shutdown_helper();
Harald Welte96c94412017-12-09 03:12:45 +01002628}
2629
Pau Espin Pedrol5a2d7432019-06-07 19:43:45 +02002630/* Verify that Upon receival of SET "location", BSC forwards a TRAP
2631 "location-state" over the SCCPlite IPA conn */
2632testcase TC_ctrl_location() runs on test_CT {
2633 var MSC_ConnHdlr vc_conn;
2634 var integer bts_nr := 0;
2635
2636 f_init(1, true);
2637 f_sleep(1.0);
2638
2639 f_ctrl_set_bts(IPA_CTRL, bts_nr, "location", "1234567,fix3d,0.340000,0.560000,0.780000");
2640 f_ctrl_exp_trap(SCCPLITE_IPA_CTRL, "bts." & int2str(bts_nr) & ".location-state",
2641 "1234567,fix3d,0.340000,0.560000,0.780000,operational,unlocked,on,001,01");
2642
2643 f_ctrl_set(SCCPLITE_IPA_CTRL, "rf_locked", "1");
2644 f_sleep(2.0);
2645
2646 f_ctrl_set_bts(IPA_CTRL, bts_nr, "location", "1234888,fix3d,0.350000,0.570000,0.790000");
2647 f_ctrl_exp_trap(SCCPLITE_IPA_CTRL, "bts." & int2str(bts_nr) & ".location-state",
2648 "1234888,fix3d,0.350000,0.570000,0.790000,operational,locked,off,001,01");
2649
2650 /* should match the one from config */
2651 f_ctrl_set(SCCPLITE_IPA_CTRL, "rf_locked", "0");
2652
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002653 f_shutdown_helper();
Pau Espin Pedrol5a2d7432019-06-07 19:43:45 +02002654}
2655
Harald Welte6f521d82017-12-11 19:52:02 +01002656
2657/***********************************************************************
2658 * Paging Testing
2659 ***********************************************************************/
2660
2661type record Cell_Identity {
2662 GsmMcc mcc,
2663 GsmMnc mnc,
2664 GsmLac lac,
2665 GsmCellId ci
2666};
Harald Welte24135bd2018-03-17 19:27:53 +01002667private const Cell_Identity cid := { '001'H, '01'H, 1, 0 };
Stefan Sperling049a86e2018-03-20 15:51:00 +01002668private const Cell_Identity unknown_cid := { '678'H, 'f90'H, 1, 0 };
Harald Welte6f521d82017-12-11 19:52:02 +01002669
Harald Welte5d1a2202017-12-13 19:51:29 +01002670type set of integer BtsIdList;
2671
2672private function f_bts_in_list(integer bts_id, BtsIdList bts_ids) return boolean {
2673 for (var integer j := 0; j < sizeof(bts_ids); j := j + 1) {
2674 if (bts_id == bts_ids[j]) {
2675 return true;
2676 }
2677 }
2678 return false;
2679}
Harald Welte6f521d82017-12-11 19:52:02 +01002680
2681/* core paging test helper function; used by most paging test cases */
2682private function f_pageing_helper(hexstring imsi,
2683 template BSSMAP_FIELD_CellIdentificationList cid_list,
Harald Welte5d1a2202017-12-13 19:51:29 +01002684 BtsIdList bts_ids := { 0 },
Harald Welte6f521d82017-12-11 19:52:02 +01002685 template RSL_ChanNeeded rsl_chneed := omit,
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07002686 template (omit) OCT4 tmsi := omit) runs on test_CT
Harald Welte6f521d82017-12-11 19:52:02 +01002687{
2688 var template BSSMAP_IE_ChannelNeeded bssmap_chneed;
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07002689 var template MobileIdentityV mi;
Harald Welte6f521d82017-12-11 19:52:02 +01002690 var RSL_Message rx_rsl;
2691 var integer paging_group := hex2int(imsi[lengthof(imsi)-1]);
Harald Welte5d1a2202017-12-13 19:51:29 +01002692 var integer i;
Harald Welte6f521d82017-12-11 19:52:02 +01002693
2694 f_init();
Harald Welte6f521d82017-12-11 19:52:02 +01002695
2696 /* Clear the queue, it might still contain stuff like BCCH FILLING */
Harald Weltec3068592018-03-17 19:55:31 +01002697 for (i := 0; i < NUM_BTS; i := i + 1) {
2698 IPA_RSL[i].clear;
Harald Welte5d1a2202017-12-13 19:51:29 +01002699 }
Harald Welte6f521d82017-12-11 19:52:02 +01002700
2701 if (isvalue(rsl_chneed)) {
2702 /* The values of 08.08 3.2.2.36 and 08.58 9.3.40 are luckily identical */
2703 bssmap_chneed := ts_BSSMAP_IE_ChanNeeded(int2bit(enum2int(valueof(rsl_chneed)),2));
2704 } else {
2705 bssmap_chneed := omit;
2706 }
2707
Neels Hofmeyrf246a922020-05-13 02:27:10 +02002708 BSSAP.send(ts_BSSAP_UNITDATA_req(g_bssap[0].sccp_addr_peer, g_bssap[0].sccp_addr_own,
2709 ts_BSSMAP_Paging(imsi, cid_list, tmsi, bssmap_chneed)));
Harald Welte6f521d82017-12-11 19:52:02 +01002710
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07002711 if (not istemplatekind(tmsi, "omit")) {
2712 mi := t_MI_TMSI(tmsi);
Harald Welte6f521d82017-12-11 19:52:02 +01002713 } else {
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07002714 mi := tr_MI_IMSI(imsi);
Harald Welte6f521d82017-12-11 19:52:02 +01002715 }
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07002716
Harald Welte5d1a2202017-12-13 19:51:29 +01002717 for (i := 0; i < sizeof(bts_ids); i := i + 1) {
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07002718 rx_rsl := f_exp_ipa_rx(bts_ids[i], tr_RSL_PAGING_CMD(mi));
Harald Welte5d1a2202017-12-13 19:51:29 +01002719 /* check channel type, paging group */
2720 if (rx_rsl.ies[1].body.paging_group != paging_group) {
2721 setverdict(fail, "Paging for wrong paging group");
2722 }
2723 if (ispresent(rsl_chneed) and
2724 rx_rsl.ies[3].body.chan_needed.chan_needed != valueof(rsl_chneed)) {
2725 setverdict(fail, "RSL Channel Needed != BSSMAP Channel Needed");
2726 }
Harald Welte6f521d82017-12-11 19:52:02 +01002727 }
Harald Welte2fccd982018-01-31 15:48:19 +01002728 f_sleep(2.0);
Harald Welte5d1a2202017-12-13 19:51:29 +01002729 /* do a quick check on all not-included BTSs if they received paging */
2730 for (i := 0; i < NUM_BTS; i := i + 1) {
2731 timer T := 0.1;
2732 if (f_bts_in_list(i, bts_ids)) {
2733 continue;
2734 }
2735 T.start;
2736 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07002737 [] IPA_RSL[i].receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD(mi))) {
Harald Welte5d1a2202017-12-13 19:51:29 +01002738 setverdict(fail, "Paging on BTS ", i, " which is not part of ", bts_ids);
2739 }
2740 [] IPA_RSL[i].receive { repeat; }
2741 [] T.timeout { }
2742 }
Harald Welte6f521d82017-12-11 19:52:02 +01002743 }
2744
2745 setverdict(pass);
2746}
2747
Harald Welte5d1a2202017-12-13 19:51:29 +01002748const BtsIdList c_BtsId_all := { 0, 1, 2 };
Harald Welte751d3eb2018-01-31 15:51:06 +01002749const BtsIdList c_BtsId_none := { };
Harald Welte5d1a2202017-12-13 19:51:29 +01002750const BtsIdList c_BtsId_LAC1 := { 0, 1 };
2751const BtsIdList c_BtsId_LAC2 := { 2 };
2752
Harald Welte6f521d82017-12-11 19:52:02 +01002753/* PAGING by IMSI + TMSI */
2754testcase TC_paging_imsi_nochan() runs on test_CT {
2755 var BSSMAP_FIELD_CellIdentificationList cid_list;
2756 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Philipp Maier8c04b0a2018-02-23 13:48:48 +01002757 f_pageing_helper('001010100000001'H, cid_list, c_BtsId_all, omit, omit);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002758 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002759}
2760
2761/* PAGING by IMSI + TMSI */
2762testcase TC_paging_tmsi_nochan() 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('001010100000001'H, cid_list, c_BtsId_all, omit, 'A1B2C301'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002766 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002767}
2768
2769/* Paging with different "channel needed' values */
2770testcase TC_paging_tmsi_any() runs on test_CT {
2771 var BSSMAP_FIELD_CellIdentificationList cid_list;
2772 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01002773 f_pageing_helper('001010100000002'H, cid_list, c_BtsId_all, RSL_CHANNEED_ANY, 'A1B2C302'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002774 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002775}
2776testcase TC_paging_tmsi_sdcch() runs on test_CT {
2777 var BSSMAP_FIELD_CellIdentificationList cid_list;
2778 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01002779 f_pageing_helper('001010100000003'H, cid_list, c_BtsId_all, RSL_CHANNEED_SDCCH, 'A1B2C303'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002780 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002781}
2782testcase TC_paging_tmsi_tch_f() runs on test_CT {
2783 var BSSMAP_FIELD_CellIdentificationList cid_list;
2784 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01002785 f_pageing_helper('001010000000004'H, cid_list, c_BtsId_all, RSL_CHANNEED_TCH_F, 'A1B2C304'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002786 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002787}
2788testcase TC_paging_tmsi_tch_hf() runs on test_CT {
2789 var BSSMAP_FIELD_CellIdentificationList cid_list;
2790 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01002791 f_pageing_helper('001010000000005'H, cid_list, c_BtsId_all, RSL_CHANNEED_TCH_ForH, 'A1B2C305'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002792 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002793}
2794
2795/* Paging by CGI */
2796testcase TC_paging_imsi_nochan_cgi() runs on test_CT {
2797 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2798 cid_list := { cIl_CGI := { ts_BSSMAP_CI_CGI(cid.mcc, cid.mnc, cid.lac, cid.ci) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01002799 f_pageing_helper('001010000000006'H, cid_list, { 0 });
Philipp Maier282ca4b2018-02-27 17:17:00 +01002800 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002801}
2802
2803/* Paging by LAC+CI */
2804testcase TC_paging_imsi_nochan_lac_ci() runs on test_CT {
2805 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2806 cid_list := { cIl_LAC_CI := { ts_BSSMAP_CI_LAC_CI(cid.lac, cid.ci) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01002807 f_pageing_helper('001010000000007'H, cid_list, { 0 });
Philipp Maier282ca4b2018-02-27 17:17:00 +01002808 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002809}
2810
2811/* Paging by CI */
2812testcase TC_paging_imsi_nochan_ci() runs on test_CT {
2813 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2814 cid_list := { cIl_CI := { ts_BSSMAP_CI_CI(cid.ci) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01002815 f_pageing_helper('001010000000008'H, cid_list, { 0 });
Philipp Maier282ca4b2018-02-27 17:17:00 +01002816 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002817}
2818
2819/* Paging by LAI */
2820testcase TC_paging_imsi_nochan_lai() runs on test_CT {
2821 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2822 cid_list := { cIl_LAI := { ts_BSSMAP_CI_LAI(cid.mcc, cid.mnc, cid.lac) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01002823 f_pageing_helper('001010000000009'H, cid_list, c_BtsId_LAC1);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002824 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002825}
2826
2827/* Paging by LAC */
2828testcase TC_paging_imsi_nochan_lac() runs on test_CT {
2829 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2830 cid_list := { cIl_LAC := { ts_BSSMAP_CI_LAC(cid.lac) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01002831 f_pageing_helper('001010000000010'H, cid_list, c_BtsId_LAC1);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002832 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002833}
2834
2835/* Paging by "all in BSS" */
2836testcase TC_paging_imsi_nochan_all() runs on test_CT {
2837 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2838 cid_list := { cIl_allInBSS := ''O };
Harald Welte5d1a2202017-12-13 19:51:29 +01002839 f_pageing_helper('001010000000011'H, cid_list, c_BtsId_all);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002840 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002841}
2842
Stefan Sperling7b5e1782018-03-20 19:32:43 +01002843/* Paging by PLMN+LAC+RNC; We do not implement this; Verify nothing is paged */
Harald Welte751d3eb2018-01-31 15:51:06 +01002844testcase TC_paging_imsi_nochan_plmn_lac_rnc() runs on test_CT {
2845 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2846 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 +01002847 f_pageing_helper('001010000000012'H, cid_list, c_BtsId_none);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002848 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01002849}
Harald Welte6f521d82017-12-11 19:52:02 +01002850
Stefan Sperling7b5e1782018-03-20 19:32:43 +01002851/* Paging by RNC; We do not implement this; Verify nothing is paged */
Harald Welte751d3eb2018-01-31 15:51:06 +01002852testcase TC_paging_imsi_nochan_rnc() runs on test_CT {
2853 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2854 cid_list := { cIl_RNC := { int2oct(13, 2) } };
Stefan Sperling7b5e1782018-03-20 19:32:43 +01002855 f_pageing_helper('001010000000013'H, cid_list, c_BtsId_none);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002856 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01002857}
2858
Stefan Sperling7b5e1782018-03-20 19:32:43 +01002859/* Paging by LAC+RNC; We do not implement; Verify nothing is paged */
Harald Welte751d3eb2018-01-31 15:51:06 +01002860testcase TC_paging_imsi_nochan_lac_rnc() runs on test_CT {
2861 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2862 cid_list := { cIl_LAC_RNC := { ts_BSSMAP_CI_LAC_RNC(cid.lac, 14) } };
Stefan Sperling7b5e1782018-03-20 19:32:43 +01002863 f_pageing_helper('001010000000014'H, cid_list, c_BtsId_none);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002864 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01002865}
2866
Harald Welte6f521d82017-12-11 19:52:02 +01002867/* Paging on multiple cells (multiple entries in list): Verify all of them page */
Harald Welte751d3eb2018-01-31 15:51:06 +01002868testcase TC_paging_imsi_nochan_lacs() runs on test_CT {
2869 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2870 cid_list := { cIl_LAC := { ts_BSSMAP_CI_LAC(1), ts_BSSMAP_CI_LAC(2) } };
2871 f_pageing_helper('001010000000015'H, cid_list, c_BtsId_all);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002872 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01002873}
2874
2875/* Paging on empty list: Verify none of them page */
2876testcase TC_paging_imsi_nochan_lacs_empty() runs on test_CT {
2877 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2878 cid_list := { cIl_LAC := { } };
2879 f_pageing_helper('001010000000016'H, cid_list, c_BtsId_none);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002880 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01002881}
2882
Stefan Sperling049a86e2018-03-20 15:51:00 +01002883/* Paging by CGI with unknown MCC/MNC: Verify nothing is paged. */
2884testcase TC_paging_imsi_nochan_cgi_unknown_cid() runs on test_CT {
2885 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2886 cid_list := { cIl_CGI := { ts_BSSMAP_CI_CGI(unknown_cid.mcc, unknown_cid.mnc, unknown_cid.lac, unknown_cid.ci) } };
2887 f_pageing_helper('001010000000006'H, cid_list, c_BtsId_none);
2888 f_shutdown_helper();
2889}
2890
Harald Welte6f521d82017-12-11 19:52:02 +01002891/* Verify paging retransmission interval + count */
2892/* Verify paging stops after channel establishment */
Harald Welte6f521d82017-12-11 19:52:02 +01002893/* Test behavior under paging overload */
Harald Welteae026692017-12-09 01:03:01 +01002894
Harald Weltee65d40e2017-12-13 00:09:06 +01002895/* Verify PCH load */
2896testcase TC_paging_imsi_load() runs on test_CT {
2897 var BSSMAP_FIELD_CellIdentificationList cid_list;
2898 timer T := 4.0;
Harald Welte2caa1062018-03-17 18:19:05 +01002899 timer T_retrans := 1.0;
Harald Weltee65d40e2017-12-13 00:09:06 +01002900 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01002901 f_pageing_helper('001010123456789'H, cid_list, c_BtsId_all);
Harald Weltee65d40e2017-12-13 00:09:06 +01002902
2903 /* tell BSC there is no paging space anymore */
2904 f_ipa_tx(0, ts_RSL_PAGING_LOAD_IND(0));
Harald Welte3b57ab52018-03-17 18:01:10 +01002905 f_sleep(0.2);
2906 IPA_RSL[0].clear;
Harald Weltee65d40e2017-12-13 00:09:06 +01002907
2908 /* Wait for 4 seconds if any more PAGING CMD are received on RSL. Normally,
2909 * there would be 8 retransmissions during 4 seconds */
2910 T.start;
Harald Welte2caa1062018-03-17 18:19:05 +01002911 T_retrans.start;
Harald Weltee65d40e2017-12-13 00:09:06 +01002912 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07002913 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD(?))) {
Harald Weltee65d40e2017-12-13 00:09:06 +01002914 setverdict(fail, "Received PAGING after LOAD_IND(0)");
Daniel Willmannafce8662018-07-06 23:11:32 +02002915 mtc.stop;
Harald Weltee65d40e2017-12-13 00:09:06 +01002916 }
Harald Welte2caa1062018-03-17 18:19:05 +01002917 [] T_retrans.timeout {
2918 /* re-trnsmit the zero-space LOAD IND to avoid BSC 'auto credit' */
2919 f_ipa_tx(0, ts_RSL_PAGING_LOAD_IND(0));
2920 T_retrans.start;
2921 repeat;
2922 }
Harald Weltee65d40e2017-12-13 00:09:06 +01002923 [] T.timeout {
2924 setverdict(pass);
2925 }
2926 }
Philipp Maier282ca4b2018-02-27 17:17:00 +01002927
2928 f_shutdown_helper();
Harald Weltee65d40e2017-12-13 00:09:06 +01002929}
2930
Harald Welte235ebf12017-12-15 14:18:16 +01002931/* Verify Paging Counter */
Harald Welte1ff69992017-12-14 12:31:17 +01002932testcase TC_paging_counter() runs on test_CT {
2933 var BSSMAP_FIELD_CellIdentificationList cid_list;
2934 timer T := 4.0;
2935 var integer i;
2936 var integer paging_attempted_bsc;
2937 var integer paging_attempted_bts[NUM_BTS];
2938 var integer paging_expired_bts[NUM_BTS];
2939 cid_list := valueof(ts_BSSMAP_CIL_noCell);
2940
2941 f_init();
2942
2943 /* read counters before paging */
2944 paging_attempted_bsc := f_ctrl_get_ratectr_abs(IPA_CTRL, "bsc", 0, "paging:attempted");
2945 for (i := 0; i < NUM_BTS; i := i+1) {
2946 paging_attempted_bts[i] := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", i, "paging:attempted");
2947 paging_expired_bts[i] := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", i, "paging:expired");
2948 }
2949
2950 f_pageing_helper('001230000000001'H, cid_list, c_BtsId_all);
2951
2952 /* expect the attempted pages on BSC and each BTSs to have incremented by one */
2953 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bsc", 0, "paging:attempted", paging_attempted_bsc+1);
2954 for (i := 0; i < NUM_BTS; i := i+1) {
2955 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", i, "paging:attempted",
2956 paging_attempted_bts[i]+1);
2957 }
2958
2959 /* assume that 12s later the paging on all BTSs have expired and hence incremented by 1 */
2960 f_sleep(12.0);
2961 for (i := 0; i < NUM_BTS; i := i+1) {
2962 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", i, "paging:expired",
2963 paging_expired_bts[i]+1);
2964 }
Harald Welte1ff69992017-12-14 12:31:17 +01002965
Philipp Maier282ca4b2018-02-27 17:17:00 +01002966 f_shutdown_helper();
Harald Welte1ff69992017-12-14 12:31:17 +01002967}
2968
2969
Harald Welte10985002017-12-12 09:29:15 +01002970/* Verify paging stops after A-RESET */
2971testcase TC_paging_imsi_a_reset() runs on test_CT {
2972 var BSSMAP_FIELD_CellIdentificationList cid_list;
2973 timer T := 3.0;
2974 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01002975 f_pageing_helper('001010123456789'H, cid_list, c_BtsId_all);
Harald Welte10985002017-12-12 09:29:15 +01002976
2977 /* Perform a BSSMAP Reset and wait for ACK */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02002978 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 +01002979 alt {
Neels Hofmeyrf246a922020-05-13 02:27:10 +02002980 [] 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 +01002981 [] BSSAP.receive { repeat; }
2982 }
2983
Daniel Willmanncbef3982018-07-30 09:22:40 +02002984 /* Wait to avoid a possible race condition if a paging message is
2985 * received right before the reset ACK. */
2986 f_sleep(0.2);
2987
Harald Welte10985002017-12-12 09:29:15 +01002988 /* Clear the queue, it might still contain stuff like BCCH FILLING */
Philipp Maier1e6b4422018-02-23 14:02:13 +01002989 for (var integer i := 0; i < sizeof(IPA_RSL); i := i+1) {
2990 IPA_RSL[i].clear;
2991 }
Harald Welte10985002017-12-12 09:29:15 +01002992
2993 /* Wait for 3 seconds if any more PAGING CMD are received on RSL */
2994 T.start;
2995 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07002996 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD(?))) {
Harald Welte10985002017-12-12 09:29:15 +01002997 setverdict(fail, "Received PAGING after A-RESET");
Daniel Willmannafce8662018-07-06 23:11:32 +02002998 mtc.stop;
Harald Welte10985002017-12-12 09:29:15 +01002999 }
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07003000 [] IPA_RSL[1].receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD(?))) {
Harald Welte5d1a2202017-12-13 19:51:29 +01003001 setverdict(fail, "Received PAGING after A-RESET");
Daniel Willmannafce8662018-07-06 23:11:32 +02003002 mtc.stop;
Harald Welte5d1a2202017-12-13 19:51:29 +01003003 }
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07003004 [] IPA_RSL[2].receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD(?))) {
Harald Welte5d1a2202017-12-13 19:51:29 +01003005 setverdict(fail, "Received PAGING after A-RESET");
Daniel Willmannafce8662018-07-06 23:11:32 +02003006 mtc.stop;
Harald Welte5d1a2202017-12-13 19:51:29 +01003007 }
Harald Welte10985002017-12-12 09:29:15 +01003008 [] T.timeout {
3009 setverdict(pass);
3010 }
3011 }
Philipp Maier282ca4b2018-02-27 17:17:00 +01003012
3013 f_shutdown_helper();
Harald Welte10985002017-12-12 09:29:15 +01003014}
Harald Welteae026692017-12-09 01:03:01 +01003015
Philipp Maierf45824a2019-08-14 14:44:10 +02003016/* Verify how we handle unsolicited Paging Response. In case of an unsolicit
3017 * paging response we can not know which MSC is in charge, so we will blindly
3018 * pick the first configured MSC. This behavior is required in order to make
3019 * MT-CSFB calls working because in those cases the BSC can not know that the
3020 * MSC has already paged the subscriver via SGs. So any MT-CSFB call will look
3021 * like an unsolicited Paging Response to the MSC.
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01003022 */
3023testcase TC_paging_resp_unsol() runs on test_CT {
3024
3025 f_init(1);
Philipp Maierf45824a2019-08-14 14:44:10 +02003026 timer T := 5.0;
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01003027
3028 var BSSAP_N_CONNECT_ind rx_c_ind;
3029 var DchanTuple dt;
3030 var PDU_ML3_MS_NW l3 := valueof(ts_PAG_RESP(valueof(ts_MI_IMSI_LV('001010008880018'H))));
Philipp Maierf45824a2019-08-14 14:44:10 +02003031 var octetstring rr_pag_resp := enc_PDU_ML3_MS_NW(l3);
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01003032
3033 /* Send CHAN RQD and wait for allocation; acknowledge it */
3034 dt.rsl_chan_nr := f_chreq_act_ack();
3035
3036 /* Send unsolicited Paging response (no matching Paging CMD stored in BSC) */
3037 f_ipa_tx(0, ts_RSL_EST_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0)), enc_PDU_ML3_MS_NW(l3)));
3038
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01003039
Philipp Maierf45824a2019-08-14 14:44:10 +02003040 /* Expevct a CR with a matching Paging response on the A-Interface */
3041 T.start;
3042 alt {
3043 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(rr_pag_resp))) {
3044 setverdict(pass);
3045 }
3046 [] BSSAP.receive {
3047 setverdict(fail, "Received unexpected message on A-Interface!");
3048 }
3049 [] T.timeout {
3050 setverdict(fail, "Received nothing on A-Interface!");
3051 }
3052 }
3053
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003054 f_shutdown_helper();
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01003055}
3056
Harald Welte4e9b9cc2017-12-14 18:31:02 +01003057/* Test RSL link drop causes counter increment */
3058testcase TC_rsl_drop_counter() runs on test_CT {
3059 var integer rsl_fail;
3060
Harald Welte89d42e82017-12-17 16:42:41 +01003061 f_init(1);
Harald Welte4e9b9cc2017-12-14 18:31:02 +01003062
3063 rsl_fail := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "rsl_fail");
3064
3065 bts[0].rsl.vc_IPA.stop;
3066
3067 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "rsl_fail", rsl_fail+1);
3068
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003069 f_shutdown_helper();
Harald Welte4e9b9cc2017-12-14 18:31:02 +01003070}
3071
3072/* TODO: Test OML link drop causes counter increment */
3073
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003074/* The body of TC_rsl_unknown_unit_id() and TC_oml_unknown_unit_id() tests. */
3075function f_ipa_unknown_unit_id(integer mp_bsc_ipa_port) runs on test_CT return boolean {
3076 timer T := 10.0;
3077
3078 bts[0].rsl.id := "IPA-0-RSL";
3079 bts[0].rsl.vc_IPA := IPA_Emulation_CT.create(bts[0].rsl.id & "-IPA");
3080 bts[0].rsl.ccm_pars := c_IPA_default_ccm_pars;
3081 bts[0].rsl.ccm_pars.name := "Osmocom TTCN-3 BTS Simulator";
Oliver Smith92c2bdb2019-08-20 15:11:24 +02003082 bts[0].rsl.ccm_pars.unit_id := "99/0/0"; /* value which is unknown at BTS */
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003083
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003084 f_ipa_ctrl_start(mp_bsc_ip, mp_bsc_ctrl_port);
3085
3086 f_init_mgcp("VirtMSC");
3087
3088 /* start RSL/OML connection (XXX re-uses RSL port/protocol definitions for OML) */
3089 map(bts[0].rsl.vc_IPA:IPA_PORT, system:IPA);
3090 connect(bts[0].rsl.vc_IPA:IPA_RSL_PORT, self:IPA_RSL[0]);
3091 bts[0].rsl.vc_IPA.start(IPA_Emulation.main_client(mp_bsc_ip, mp_bsc_ipa_port, "", 10000, bts[0].rsl.ccm_pars));
3092
3093 /* wait for IPA OML link to connect and then disconnect */
3094 T.start;
3095 alt {
Vadim Yanitskiya2afacc2020-05-18 21:16:19 +07003096 [] IPA_RSL[0].receive(tr_ASP_IPA_EV(ASP_IPA_EVENT_DOWN)) {
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003097 T.stop;
3098 return true;
3099 }
3100 [] IPA_RSL[0].receive { repeat }
3101 [] T.timeout {
Daniel Willmannafce8662018-07-06 23:11:32 +02003102 return false;
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003103 }
3104 }
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003105 return false;
3106}
3107
3108/* BSC should close an RSL connection from a BTS with unknown unit ID (OS#2714). */
3109testcase TC_rsl_unknown_unit_id() runs on test_CT {
3110 if (f_ipa_unknown_unit_id(mp_bsc_rsl_port)) {
3111 setverdict(pass);
3112 } else {
3113 setverdict(fail, "Timeout RSL waiting for connection to close");
3114 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003115 f_shutdown_helper();
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003116}
3117
3118
3119/* BSC should close an RSL connection from a BTS with unknown unit ID (OS#2714). */
3120testcase TC_oml_unknown_unit_id() runs on test_CT {
3121 if (f_ipa_unknown_unit_id(mp_bsc_oml_port)) {
3122 setverdict(pass);
3123 } else {
3124 setverdict(fail, "Timeout OML waiting for connection to close");
3125 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003126 f_shutdown_helper();
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003127}
3128
3129
Harald Weltec1a2fff2017-12-17 11:06:19 +01003130/***********************************************************************
Harald Welte6811d102019-04-14 22:23:14 +02003131 * "New world" test cases using RSL_Emulation + RAN_Emulation
Harald Weltec1a2fff2017-12-17 11:06:19 +01003132 ***********************************************************************/
3133
Harald Welte6811d102019-04-14 22:23:14 +02003134import from RAN_Emulation all;
Harald Welte47cd0e32020-08-21 12:39:11 +02003135import from BSSAP_LE_Emulation all;
Harald Weltec1a2fff2017-12-17 11:06:19 +01003136import from RSL_Emulation all;
3137import from MSC_ConnectionHandler all;
3138
3139type function void_fn(charstring id) runs on MSC_ConnHdlr;
3140
Harald Welte336820c2018-05-31 20:34:52 +02003141/* helper function to create and connect a MSC_ConnHdlr component */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003142private function f_connect_handler(inout MSC_ConnHdlr vc_conn, integer bssap_idx := 0) runs on test_CT {
3143 connect(vc_conn:RAN, g_bssap[bssap_idx].vc_RAN:PROC);
Daniel Willmann191e0d92018-01-17 12:44:35 +01003144 connect(vc_conn:MGCP_PROC, vc_MGCP:MGCP_PROC);
Harald Weltec1a2fff2017-12-17 11:06:19 +01003145 connect(vc_conn:RSL, bts[0].rsl.vc_RSL:CLIENT_PT);
Harald Weltef70df652018-01-29 22:00:23 +01003146 connect(vc_conn:RSL_PROC, bts[0].rsl.vc_RSL:RSL_PROC);
Philipp Maier88f4ae82018-03-01 14:00:58 +01003147 if (isvalue(bts[1])) {
Philipp Maier956a92f2018-02-16 10:58:07 +01003148 connect(vc_conn:RSL1, bts[1].rsl.vc_RSL:CLIENT_PT);
3149 connect(vc_conn:RSL1_PROC, bts[1].rsl.vc_RSL:RSL_PROC);
3150 }
Neels Hofmeyr91401012019-07-11 00:42:35 +02003151 if (isvalue(bts[2])) {
3152 connect(vc_conn:RSL2, bts[2].rsl.vc_RSL:CLIENT_PT);
3153 connect(vc_conn:RSL2_PROC, bts[2].rsl.vc_RSL:RSL_PROC);
3154 }
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003155 connect(vc_conn:BSSAP, g_bssap[bssap_idx].vc_RAN:CLIENT);
Neels Hofmeyrcfe44062020-10-15 02:28:08 +02003156 if (mp_enable_lcs_tests) {
3157 connect(vc_conn:BSSAP_LE, g_bssap_le.vc_BSSAP_LE:CLIENT);
3158 connect(vc_conn:BSSAP_LE_PROC, g_bssap_le.vc_BSSAP_LE:PROC);
3159 }
Daniel Willmann191e0d92018-01-17 12:44:35 +01003160 connect(vc_conn:MGCP, vc_MGCP:MGCP_CLIENT);
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +02003161 connect(vc_conn:MGCP_MULTI, vc_MGCP:MGCP_CLIENT_MULTI);
Daniel Willmannebdecc02020-08-12 15:30:17 +02003162 connect(vc_conn:STATSD_PROC, vc_STATSD:STATSD_PROC);
Harald Welte336820c2018-05-31 20:34:52 +02003163}
3164
3165function f_start_handler(void_fn fn, template (omit) TestHdlrParams pars := omit)
3166runs on test_CT return MSC_ConnHdlr {
3167 var charstring id := testcasename();
3168 var MSC_ConnHdlr vc_conn;
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003169 var integer bssap_idx := 0;
3170 if (isvalue(pars)) {
3171 bssap_idx := valueof(pars).mscpool.bssap_idx;
3172 }
Harald Welte336820c2018-05-31 20:34:52 +02003173 vc_conn := MSC_ConnHdlr.create(id);
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003174 f_connect_handler(vc_conn, bssap_idx);
Neels Hofmeyr1708d1b2020-10-10 16:56:48 +02003175 /* Emit a marker to appear in the SUT's own logging output */
3176 f_logp(BSCVTY, testcasename() & "() start");
Harald Weltea0630032018-03-20 21:09:55 +01003177 vc_conn.start(f_handler_init(fn, id, pars));
Harald Weltec1a2fff2017-12-17 11:06:19 +01003178 return vc_conn;
3179}
3180
Harald Weltea0630032018-03-20 21:09:55 +01003181/* first function inside ConnHdlr component; sets g_pars + starts function */
3182private function f_handler_init(void_fn fn, charstring id, template (omit) TestHdlrParams pars := omit)
3183runs on MSC_ConnHdlr {
3184 if (isvalue(pars)) {
3185 g_pars := valueof(pars);
3186 }
3187 fn.apply(id);
3188}
3189
Harald Welte3c86ea02018-05-10 22:28:05 +02003190/* Establish signalling channel (non-assignment case) followed by cipher mode */
3191private function f_tc_ciph_mode_a5(charstring id) runs on MSC_ConnHdlr {
Harald Welteed848512018-05-24 22:27:58 +02003192 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3193 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte3c86ea02018-05-10 22:28:05 +02003194 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeSIGNAL);
Philipp Maier23000732018-05-18 11:25:37 +02003195 ass_cmd.pdu.bssmap.assignmentRequest.circuitIdentityCode := omit;
3196 ass_cmd.pdu.bssmap.assignmentRequest.aoIPTransportLayer := omit;
3197 exp_compl.pdu.bssmap.assignmentComplete.circuitIdentityCode := omit;
3198 exp_compl.pdu.bssmap.assignmentComplete.aoIPTransportLayer := omit;
Harald Welte3c86ea02018-05-10 22:28:05 +02003199
Philipp Maier23000732018-05-18 11:25:37 +02003200 f_establish_fully(ass_cmd, exp_compl);
Harald Welte3c86ea02018-05-10 22:28:05 +02003201}
3202testcase TC_ciph_mode_a5_0() runs on test_CT {
3203 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02003204 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte3c86ea02018-05-10 22:28:05 +02003205 pars.encr := valueof(t_EncrParams('01'O, f_rnd_octstring(8)));
3206
3207 f_init(1, true);
3208 f_sleep(1.0);
3209 vc_conn := f_start_handler(refers(f_tc_ciph_mode_a5), pars);
3210 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003211 f_shutdown_helper();
Harald Welte3c86ea02018-05-10 22:28:05 +02003212}
3213testcase TC_ciph_mode_a5_1() runs on test_CT {
3214 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02003215 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte3c86ea02018-05-10 22:28:05 +02003216 pars.encr := valueof(t_EncrParams('02'O, f_rnd_octstring(8)));
3217
3218 f_init(1, true);
3219 f_sleep(1.0);
3220 vc_conn := f_start_handler(refers(f_tc_ciph_mode_a5), pars);
3221 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003222 f_shutdown_helper();
Harald Welte3c86ea02018-05-10 22:28:05 +02003223}
3224testcase TC_ciph_mode_a5_3() runs on test_CT {
3225 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02003226 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte3c86ea02018-05-10 22:28:05 +02003227 pars.encr := valueof(t_EncrParams('08'O, f_rnd_octstring(8)));
3228
3229 f_init(1, true);
3230 f_sleep(1.0);
3231 vc_conn := f_start_handler(refers(f_tc_ciph_mode_a5), pars);
3232 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003233 f_shutdown_helper();
Harald Welte3c86ea02018-05-10 22:28:05 +02003234}
3235
Pau Espin Pedrol07866632020-09-03 19:10:55 +02003236/* establish initial channel, enable ciphering followed by assignment to ciphered channel */
3237private function f_tc_assignment_aoip_tla_v6(charstring id) runs on MSC_ConnHdlr {
3238 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3239 var PDU_BSSAP ass_cmd := f_gen_ass_req(aoip_tla := "::3");
3240 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3241 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
3242
3243 f_establish_fully(ass_cmd, exp_compl);
3244}
3245testcase TC_assignment_aoip_tla_v6() runs on test_CT {
3246 var MSC_ConnHdlr vc_conn;
3247 var TestHdlrParams pars := f_gen_test_hdlr_pars();
3248
3249 f_init(1, true);
3250 f_sleep(1.0);
3251 vc_conn := f_start_handler(refers(f_tc_assignment_aoip_tla_v6), pars);
3252 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003253 f_shutdown_helper();
Pau Espin Pedrol07866632020-09-03 19:10:55 +02003254}
3255
Harald Welte3c86ea02018-05-10 22:28:05 +02003256
3257/* establish initial channel, enable ciphering followed by assignment to ciphered channel */
Harald Welte651fcdc2018-05-10 20:23:16 +02003258private function f_tc_assignment_fr_a5(charstring id) runs on MSC_ConnHdlr {
Harald Welteed848512018-05-24 22:27:58 +02003259 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3260 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Weltec1a2fff2017-12-17 11:06:19 +01003261
Harald Welte552620d2017-12-16 23:21:36 +01003262 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3263 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
Harald Welte73cd2712017-12-17 00:44:52 +01003264
Harald Weltea0630032018-03-20 21:09:55 +01003265 f_establish_fully(ass_cmd, exp_compl);
Harald Welte552620d2017-12-16 23:21:36 +01003266}
Harald Welte552620d2017-12-16 23:21:36 +01003267testcase TC_assignment_fr_a5_0() runs on test_CT {
3268 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02003269 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte651fcdc2018-05-10 20:23:16 +02003270 pars.encr := valueof(t_EncrParams('01'O, f_rnd_octstring(8)));
Harald Welte552620d2017-12-16 23:21:36 +01003271
Harald Welte89d42e82017-12-17 16:42:41 +01003272 f_init(1, true);
Harald Welte552620d2017-12-16 23:21:36 +01003273 f_sleep(1.0);
Harald Welte651fcdc2018-05-10 20:23:16 +02003274 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5), pars);
Harald Welte552620d2017-12-16 23:21:36 +01003275 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003276 f_shutdown_helper();
Harald Welte552620d2017-12-16 23:21:36 +01003277}
Harald Welte552620d2017-12-16 23:21:36 +01003278testcase TC_assignment_fr_a5_1() runs on test_CT {
Harald Weltec1a2fff2017-12-17 11:06:19 +01003279 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02003280 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte651fcdc2018-05-10 20:23:16 +02003281 pars.encr := valueof(t_EncrParams('02'O, f_rnd_octstring(8)));
Harald Weltec1a2fff2017-12-17 11:06:19 +01003282
Harald Welte89d42e82017-12-17 16:42:41 +01003283 f_init(1, true);
Harald Weltec1a2fff2017-12-17 11:06:19 +01003284 f_sleep(1.0);
Harald Welte651fcdc2018-05-10 20:23:16 +02003285 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5), pars);
3286 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003287 f_shutdown_helper();
Harald Welte651fcdc2018-05-10 20:23:16 +02003288}
3289testcase TC_assignment_fr_a5_3() runs on test_CT {
3290 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02003291 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte651fcdc2018-05-10 20:23:16 +02003292 pars.encr := valueof(t_EncrParams('08'O, f_rnd_octstring(8)));
Harald Weltec1a2fff2017-12-17 11:06:19 +01003293
Harald Welte651fcdc2018-05-10 20:23:16 +02003294 f_init(1, true);
3295 f_sleep(1.0);
3296 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5), pars);
Harald Weltec1a2fff2017-12-17 11:06:19 +01003297 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003298 f_shutdown_helper();
Harald Weltec1a2fff2017-12-17 11:06:19 +01003299}
3300
Harald Welte552620d2017-12-16 23:21:36 +01003301/* Expect ASSIGNMENT FAIL if mandatory IE is missing */
3302private function f_tc_assignment_fr_a5_1_codec_missing(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02003303 g_pars := f_gen_test_hdlr_pars();
Harald Welte552620d2017-12-16 23:21:36 +01003304 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
Harald Welteed848512018-05-24 22:27:58 +02003305 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte552620d2017-12-16 23:21:36 +01003306 const OCT8 kc := '0001020304050607'O;
3307
3308 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02003309 /* Omit: ass_cmd.pdu.bssmap.assignmentRequest.codecList */
3310
Harald Weltea0630032018-03-20 21:09:55 +01003311 f_establish_fully(ass_cmd, exp_fail);
Harald Welte552620d2017-12-16 23:21:36 +01003312}
Harald Welte552620d2017-12-16 23:21:36 +01003313testcase TC_assignment_fr_a5_1_codec_missing() runs on test_CT {
3314 var MSC_ConnHdlr vc_conn;
3315
Harald Welte89d42e82017-12-17 16:42:41 +01003316 f_init(1, true);
Harald Welte552620d2017-12-16 23:21:36 +01003317 f_sleep(1.0);
3318
Harald Welte8863fa12018-05-10 20:15:27 +02003319 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5_1_codec_missing));
Harald Welte552620d2017-12-16 23:21:36 +01003320 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003321 f_shutdown_helper();
Harald Welte552620d2017-12-16 23:21:36 +01003322}
3323
Harald Welte552620d2017-12-16 23:21:36 +01003324private function f_tc_assignment_fr_a5_4(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02003325 g_pars := f_gen_test_hdlr_pars();
Harald Welteed848512018-05-24 22:27:58 +02003326 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3327 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte552620d2017-12-16 23:21:36 +01003328 const OCT8 kc := '0001020304050607'O;
3329 const OCT16 kc128 := kc & kc;
3330
3331 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3332 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
Harald Weltea0630032018-03-20 21:09:55 +01003333 f_establish_fully(ass_cmd, exp_compl);
Harald Welte38b2a102017-12-23 02:42:58 +01003334 f_cipher_mode('10'O, kc, kc128, true);
Harald Welte552620d2017-12-16 23:21:36 +01003335 /* TODO: expect GSM0808_CAUSE_CIPHERING_ALGORITHM_NOT_SUPPORTED cause value */
Harald Welte552620d2017-12-16 23:21:36 +01003336}
Harald Welte552620d2017-12-16 23:21:36 +01003337testcase TC_assignment_fr_a5_4() runs on test_CT {
3338 var MSC_ConnHdlr vc_conn;
3339
Harald Welte89d42e82017-12-17 16:42:41 +01003340 f_init(1, true);
Harald Welte552620d2017-12-16 23:21:36 +01003341 f_sleep(1.0);
3342
Harald Welte8863fa12018-05-10 20:15:27 +02003343 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5_4));
Harald Welte552620d2017-12-16 23:21:36 +01003344 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003345 f_shutdown_helper();
Harald Welte552620d2017-12-16 23:21:36 +01003346}
3347
3348
Harald Welte4532e0a2017-12-23 02:05:44 +01003349private function f_tc_assignment_sign(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02003350 g_pars := f_gen_test_hdlr_pars();
Harald Welte4532e0a2017-12-23 02:05:44 +01003351 var template PDU_BSSAP exp_compl := tr_BSSMAP_AssignmentComplete(omit, omit);
Philipp Maier48604732018-10-09 15:00:37 +02003352 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte4532e0a2017-12-23 02:05:44 +01003353 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeSIGNAL);
Daniel Willmannebdecc02020-08-12 15:30:17 +02003354
3355 f_statsd_reset();
Harald Weltea0630032018-03-20 21:09:55 +01003356 f_establish_fully(ass_cmd, exp_compl);
Daniel Willmannebdecc02020-08-12 15:30:17 +02003357
3358 var StatsDExpects expect := {
Daniel Willmannc5398f72020-09-21 10:41:35 +02003359 { name := "TTCN3.bts.0.chreq.total", mtype := "c", min := 1, max := 1},
3360 { name := "TTCN3.bts.0.chreq.successful", mtype := "c", min := 1, max := 1},
Daniel Willmannebdecc02020-08-12 15:30:17 +02003361 { name := "TTCN3.bsc.0.assignment.attempted", mtype := "c", min := 1, max := 1},
3362 { name := "TTCN3.bsc.0.assignment.completed", mtype := "c", min := 1, max := 1}
3363 };
3364 f_statsd_expect(expect);
Harald Welte4532e0a2017-12-23 02:05:44 +01003365}
3366
3367testcase TC_assignment_sign() runs on test_CT {
3368 var MSC_ConnHdlr vc_conn;
3369
3370 f_init(1, true);
3371 f_sleep(1.0);
3372
Harald Welte8863fa12018-05-10 20:15:27 +02003373 vc_conn := f_start_handler(refers(f_tc_assignment_sign));
Harald Welte4532e0a2017-12-23 02:05:44 +01003374 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003375 f_shutdown_helper();
Harald Welte4532e0a2017-12-23 02:05:44 +01003376}
3377
Harald Welte60aa5762018-03-21 19:33:13 +01003378/***********************************************************************
3379 * Codec (list) testing
3380 ***********************************************************************/
3381
3382/* check if the given rsl_mode is compatible with the a_elem */
3383private function f_match_codec(BSSMAP_FIELD_CodecElement a_elem, RSL_IE_ChannelMode rsl_mode)
3384return boolean {
3385 select (a_elem.codecType) {
3386 case (GSM_FR) {
3387 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM1))) {
3388 return true;
3389 }
3390 }
3391 case (GSM_HR) {
3392 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_H, RSL_CMOD_SP_GSM1))) {
3393 return true;
3394 }
3395 }
3396 case (GSM_EFR) {
3397 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM2))) {
3398 return true;
3399 }
3400 }
3401 case (FR_AMR) {
3402 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM3))) {
3403 return true;
3404 }
3405 }
3406 case (HR_AMR) {
3407 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_H, RSL_CMOD_SP_GSM3))) {
3408 return true;
3409 }
3410 }
3411 case else { }
3412 }
3413 return false;
3414}
3415
3416/* check if the given rsl_mode is compatible with the a_list */
3417private function f_match_codecs(BSSMAP_IE_SpeechCodecList a_list, RSL_IE_ChannelMode rsl_mode)
3418return boolean {
3419 for (var integer i := 0; i < sizeof(a_list); i := i+1) {
3420 if (f_match_codec(a_list.codecElements[i], rsl_mode)) {
3421 return true;
3422 }
3423 }
3424 return false;
3425}
3426
3427/* determine BSSMAP_IE_ChannelType from *first* element of BSSMAP_FIELD_CodecElement */
Philipp Maier61f6b572018-07-06 14:03:38 +02003428function f_BSSMAP_chtype_from_codec(BSSMAP_FIELD_CodecElement a_elem)
Harald Welte60aa5762018-03-21 19:33:13 +01003429return BSSMAP_IE_ChannelType {
3430 /* FIXME: actually look at all elements of BSSMAP_IE_SpeechCodecList */
3431 var BSSMAP_IE_ChannelType ret := valueof(ts_BSSMAP_IE_ChannelType);
3432 select (a_elem.codecType) {
3433 case (GSM_FR) {
3434 ret.channelRateAndType := ChRate_TCHF;
3435 ret.speechId_DataIndicator := Spdi_TCHF_FR;
3436 }
3437 case (GSM_HR) {
3438 ret.channelRateAndType := ChRate_TCHH;
3439 ret.speechId_DataIndicator := Spdi_TCHH_HR;
3440 }
3441 case (GSM_EFR) {
3442 ret.channelRateAndType := ChRate_TCHF;
3443 ret.speechId_DataIndicator := Spdi_TCHF_EFR;
3444 }
3445 case (FR_AMR) {
3446 ret.channelRateAndType := ChRate_TCHF;
3447 ret.speechId_DataIndicator := Spdi_TCHF_AMR;
3448 }
3449 case (HR_AMR) {
3450 ret.channelRateAndType := ChRate_TCHH;
3451 ret.speechId_DataIndicator := Spdi_TCHH_AMR;
3452 }
3453 case else {
3454 setverdict(fail, "Unsupported codec ", a_elem);
Daniel Willmannafce8662018-07-06 23:11:32 +02003455 mtc.stop;
Harald Welte60aa5762018-03-21 19:33:13 +01003456 }
3457 }
3458 return ret;
3459}
3460
Harald Weltea63b9102018-03-22 20:36:16 +01003461private function f_rsl_chmod_tmpl_from_codec(BSSMAP_FIELD_CodecElement a_elem)
3462return template RSL_IE_Body {
3463 var template RSL_IE_Body mode_ie := {
3464 chan_mode := {
3465 len := ?,
3466 reserved := ?,
3467 dtx_d := ?,
3468 dtx_u := ?,
3469 spd_ind := RSL_SPDI_SPEECH,
3470 ch_rate_type := -,
3471 coding_alg_rate := -
3472 }
3473 }
3474
3475 select (a_elem.codecType) {
3476 case (GSM_FR) {
3477 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_F;
3478 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM1;
3479 }
3480 case (GSM_HR) {
3481 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_H;
3482 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM1;
3483 }
3484 case (GSM_EFR) {
3485 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_F;
3486 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM2;
3487 }
3488 case (FR_AMR) {
3489 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_F;
3490 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM3;
3491 }
3492 case (HR_AMR) {
3493 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_H;
3494 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM3;
3495 }
3496 }
3497 return mode_ie;
3498}
3499
Harald Welte60aa5762018-03-21 19:33:13 +01003500type record CodecListTest {
3501 BSSMAP_IE_SpeechCodecList codec_list,
3502 charstring id
3503}
3504type record of CodecListTest CodecListTests
3505
3506private function f_TC_assignment_codec(charstring id) runs on MSC_ConnHdlr {
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02003507 var PDU_BSSAP ass_cmd := f_gen_ass_req(g_pars.use_osmux);
3508 var template PDU_BSSAP exp_compl := f_gen_exp_compl(g_pars.use_osmux);
Harald Welte60aa5762018-03-21 19:33:13 +01003509
3510 /* puzzle together the ASSIGNMENT REQ for given codec[s] */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003511 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
Harald Welte79f3f542018-05-25 20:02:37 +02003512 ass_cmd.pdu.bssmap.assignmentRequest.codecList := g_pars.ass_codec_list;
3513 exp_compl.pdu.bssmap.assignmentComplete.speechCodec.codecElements[0] :=
3514 g_pars.ass_codec_list.codecElements[0];
Philipp Maierd0e64b02019-03-13 14:15:23 +01003515 if (isvalue(g_pars.expect_mr_s0_s7)) {
3516 exp_compl.pdu.bssmap.assignmentComplete.speechCodec.codecElements[0].s0_7 :=
3517 g_pars.expect_mr_s0_s7;
3518 }
Harald Welte79f3f542018-05-25 20:02:37 +02003519 }
Harald Welte60aa5762018-03-21 19:33:13 +01003520 ass_cmd.pdu.bssmap.assignmentRequest.channelType :=
3521 f_BSSMAP_chtype_from_codec(g_pars.ass_codec_list.codecElements[0]);
Harald Welte60aa5762018-03-21 19:33:13 +01003522 log("expecting ASS COMPL like this: ", exp_compl);
3523
3524 f_establish_fully(ass_cmd, exp_compl);
Harald Weltea63b9102018-03-22 20:36:16 +01003525
3526 /* Verify that the RSL-side activation actually matches our expectations */
3527 var RSL_Message rsl := f_rslem_get_last_act(RSL_PROC, 0, g_chan_nr);
3528
3529 var RSL_IE_Body mode_ie;
3530 if (f_rsl_find_ie(rsl, RSL_IE_CHAN_MODE, mode_ie) == false) {
3531 setverdict(fail, "Couldn't find CHAN_MODE IE");
Daniel Willmannafce8662018-07-06 23:11:32 +02003532 mtc.stop;
Harald Weltea63b9102018-03-22 20:36:16 +01003533 }
3534 var template RSL_IE_Body t_mode_ie := f_rsl_chmod_tmpl_from_codec(g_pars.ass_codec_list.codecElements[0]);
3535 if (not match(mode_ie, t_mode_ie)) {
3536 setverdict(fail, "RSL Channel Mode IE doesn't match expectation");
3537 }
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02003538
3539 var RSL_IE_Body mr_conf;
3540 if (g_pars.expect_mr_conf_ie != omit) {
3541 if (f_rsl_find_ie(rsl, RSL_IE_MR_CONFIG, mr_conf) == false) {
3542 setverdict(fail, "Missing MR CONFIG IE in RSL Chan Activ");
Daniel Willmannafce8662018-07-06 23:11:32 +02003543 mtc.stop;
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02003544 }
3545 log("found RSL MR CONFIG IE: ", mr_conf);
3546
3547 if (not match(mr_conf, g_pars.expect_mr_conf_ie)) {
3548 setverdict(fail, "RSL MR CONFIG IE does not match expectation. Expected: ",
3549 g_pars.expect_mr_conf_ie);
3550 }
3551 } else {
3552 if (f_rsl_find_ie(rsl, RSL_IE_MR_CONFIG, mr_conf) == true) {
3553 log("found RSL MR CONFIG IE: ", mr_conf);
3554 setverdict(fail, "Found MR CONFIG IE in RSL Chan Activ, expecting omit");
Daniel Willmannafce8662018-07-06 23:11:32 +02003555 mtc.stop;
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02003556 }
3557 }
Harald Welte60aa5762018-03-21 19:33:13 +01003558}
3559
Philipp Maierd0e64b02019-03-13 14:15:23 +01003560private function f_TC_assignment_codec_fail(charstring id) runs on MSC_ConnHdlr {
3561
3562 var PDU_BSSAP ass_cmd := f_gen_ass_req();
3563 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
3564
3565 /* puzzle together the ASSIGNMENT REQ for given codec[s] */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003566 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
Philipp Maierd0e64b02019-03-13 14:15:23 +01003567 ass_cmd.pdu.bssmap.assignmentRequest.codecList := g_pars.ass_codec_list;
3568 }
3569 ass_cmd.pdu.bssmap.assignmentRequest.channelType :=
3570 f_BSSMAP_chtype_from_codec(g_pars.ass_codec_list.codecElements[0]);
3571 log("expecting ASS FAIL like this: ", exp_fail);
3572
3573 f_establish_fully(ass_cmd, exp_fail);
3574}
3575
Harald Welte60aa5762018-03-21 19:33:13 +01003576testcase TC_assignment_codec_fr() runs on test_CT {
Philipp Maier48604732018-10-09 15:00:37 +02003577 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte60aa5762018-03-21 19:33:13 +01003578 var MSC_ConnHdlr vc_conn;
3579
3580 f_init(1, true);
3581 f_sleep(1.0);
3582
3583 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
Harald Welte8863fa12018-05-10 20:15:27 +02003584 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01003585 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003586 f_shutdown_helper();
Harald Welte60aa5762018-03-21 19:33:13 +01003587}
3588
3589testcase TC_assignment_codec_hr() runs on test_CT {
Philipp Maier48604732018-10-09 15:00:37 +02003590 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte60aa5762018-03-21 19:33:13 +01003591 var MSC_ConnHdlr vc_conn;
3592
3593 f_init(1, true);
3594 f_sleep(1.0);
3595
3596 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR}));
Harald Welte8863fa12018-05-10 20:15:27 +02003597 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01003598 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003599 f_shutdown_helper();
Harald Welte60aa5762018-03-21 19:33:13 +01003600}
3601
3602testcase TC_assignment_codec_efr() runs on test_CT {
Philipp Maier48604732018-10-09 15:00:37 +02003603 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte60aa5762018-03-21 19:33:13 +01003604 var MSC_ConnHdlr vc_conn;
3605
3606 f_init(1, true);
3607 f_sleep(1.0);
3608
3609 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecEFR}));
Harald Welte8863fa12018-05-10 20:15:27 +02003610 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01003611 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003612 f_shutdown_helper();
Harald Welte60aa5762018-03-21 19:33:13 +01003613}
3614
Philipp Maierd0e64b02019-03-13 14:15:23 +01003615/* Allow 5,90k only (current default config) */
3616private function f_allow_amr_rate_5_90k() runs on test_CT {
Neels Hofmeyr2a5670b2020-11-25 23:39:57 +00003617 f_vty_cfg_msc(BSCVTY, 0, {
3618 "amr-config 12_2k forbidden",
3619 "amr-config 10_2k forbidden",
3620 "amr-config 7_95k forbidden",
3621 "amr-config 7_40k forbidden",
3622 "amr-config 6_70k forbidden",
3623 "amr-config 5_90k allowed",
3624 "amr-config 5_15k forbidden",
3625 "amr-config 4_75k forbidden"
3626 });
Philipp Maierd0e64b02019-03-13 14:15:23 +01003627}
3628
3629/* Allow 4,75k, 5,90k, 4,70k and 12,2k, which are the most common rates
3630 * ("Config-NB-Code = 1") */
3631private function f_allow_amr_rate_4_75k_5_90k_7_40k_12_20k() runs on test_CT {
Neels Hofmeyr2a5670b2020-11-25 23:39:57 +00003632 f_vty_cfg_msc(BSCVTY, 0, {
3633 "amr-config 12_2k allowed",
3634 "amr-config 10_2k forbidden",
3635 "amr-config 7_95k forbidden",
3636 "amr-config 7_40k allowed",
3637 "amr-config 6_70k forbidden",
3638 "amr-config 5_90k allowed",
3639 "amr-config 5_15k forbidden",
3640 "amr-config 4_75k allowed"
3641 });
Philipp Maierd0e64b02019-03-13 14:15:23 +01003642}
3643
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00003644private function f_vty_amr_start_mode_set(boolean fr, charstring startmode) runs on test_CT {
3645 var charstring tch;
3646 if (fr) {
3647 tch := "tch-f";
3648 } else {
3649 tch := "tch-h";
3650 }
3651 f_vty_cfg_bts(BSCVTY, 0, { "amr " & tch & " start-mode " & startmode });
3652}
3653
3654/* Set the AMR start-mode for this TCH back to the default configuration. */
3655private function f_vty_amr_start_mode_restore(boolean fr) runs on test_CT {
3656 f_vty_amr_start_mode_set(fr, "auto");
3657}
3658
Harald Welte60aa5762018-03-21 19:33:13 +01003659testcase TC_assignment_codec_amr_f() runs on test_CT {
Philipp Maier48604732018-10-09 15:00:37 +02003660 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte60aa5762018-03-21 19:33:13 +01003661 var MSC_ConnHdlr vc_conn;
Philipp Maier7695a0d2018-09-27 17:52:14 +02003662
3663 /* Note: This setups the codec configuration. The parameter payload in
3664 * mr_conf must be consistant with the parameter codecElements in pars
3665 * and also must match the amr-config in osmo-bsc.cfg! */
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02003666 var RSL_IE_Body mr_conf := {
3667 other := {
3668 len := 2,
3669 payload := '2804'O
3670 }
3671 };
Harald Welte60aa5762018-03-21 19:33:13 +01003672
Philipp Maier7695a0d2018-09-27 17:52:14 +02003673 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_F}));
Philipp Maier806f8f12019-03-12 12:13:41 +01003674 pars.ass_codec_list.codecElements[0].s0_7 := '00000100'B; /* 5,90k */
Philipp Maier7695a0d2018-09-27 17:52:14 +02003675 pars.ass_codec_list.codecElements[0].s8_15 := '01010111'B;
3676 pars.expect_mr_conf_ie := mr_conf;
3677
Harald Welte60aa5762018-03-21 19:33:13 +01003678 f_init(1, true);
3679 f_sleep(1.0);
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00003680 f_vty_amr_start_mode_set(true, "1");
Harald Welte60aa5762018-03-21 19:33:13 +01003681
Harald Welte8863fa12018-05-10 20:15:27 +02003682 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01003683 vc_conn.done;
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00003684
3685 f_vty_amr_start_mode_restore(true);
Vadim Yanitskiy292e5962021-01-03 14:18:47 +01003686 f_shutdown_helper();
Harald Welte60aa5762018-03-21 19:33:13 +01003687}
3688
3689testcase TC_assignment_codec_amr_h() runs on test_CT {
Philipp Maier48604732018-10-09 15:00:37 +02003690 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte60aa5762018-03-21 19:33:13 +01003691 var MSC_ConnHdlr vc_conn;
Philipp Maier7695a0d2018-09-27 17:52:14 +02003692
3693 /* See note above */
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02003694 var RSL_IE_Body mr_conf := {
3695 other := {
3696 len := 2,
3697 payload := '2804'O
3698 }
3699 };
Harald Welte60aa5762018-03-21 19:33:13 +01003700
Philipp Maier7695a0d2018-09-27 17:52:14 +02003701 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_H}));
Philipp Maier806f8f12019-03-12 12:13:41 +01003702 pars.ass_codec_list.codecElements[0].s0_7 := '00000100'B; /* 5,90k */
Philipp Maier7695a0d2018-09-27 17:52:14 +02003703 pars.ass_codec_list.codecElements[0].s8_15 := '00000111'B;
3704 pars.expect_mr_conf_ie := mr_conf;
3705
Harald Welte60aa5762018-03-21 19:33:13 +01003706 f_init(1, true);
3707 f_sleep(1.0);
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00003708 f_vty_amr_start_mode_set(false, "1");
Harald Welte60aa5762018-03-21 19:33:13 +01003709
Harald Welte8863fa12018-05-10 20:15:27 +02003710 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01003711 vc_conn.done;
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00003712
3713 f_vty_amr_start_mode_restore(false);
Vadim Yanitskiy292e5962021-01-03 14:18:47 +01003714 f_shutdown_helper();
Harald Welte60aa5762018-03-21 19:33:13 +01003715}
3716
Neels Hofmeyr454d7922020-11-26 02:24:57 +00003717/* 'amr start-mode auto' should not keep the (unused) 'smod' bits from previous configuration */
3718testcase TC_assignment_codec_amr_startmode_cruft() runs on test_CT {
3719 var TestHdlrParams pars := f_gen_test_hdlr_pars();
3720 var MSC_ConnHdlr vc_conn;
3721
3722 var RSL_IE_Body mr_conf := {
3723 other := {
3724 len := 2,
3725 payload := '2004'O /* <- expect ICMI=0, smod=00 */
3726 }
3727 };
3728
3729 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_F}));
3730 pars.ass_codec_list.codecElements[0].s0_7 := '00000100'B; /* 5,90k */
3731 pars.ass_codec_list.codecElements[0].s8_15 := '01010111'B;
3732 pars.expect_mr_conf_ie := mr_conf;
3733
3734 f_init(1, true);
3735 f_sleep(1.0);
3736
3737 /* First set nonzero start mode bits */
3738 f_vty_amr_start_mode_set(true, "4");
3739 /* Now set to auto, and expect the startmode bits to be zero in the message, i.e. ensure that osmo-bsc does not
3740 * let the startmode bits stick around and has deterministic MultiRate config for 'start-mode auto'; that is
3741 * ensured by above '2004'O, where 'x0xx'O indicates ICMI = 0, spare = 0, smod = 00. */
3742 f_vty_amr_start_mode_set(true, "auto");
3743
3744 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
3745 vc_conn.done;
Neels Hofmeyr454d7922020-11-26 02:24:57 +00003746
3747 /* Clear the startmode bits to not affect subsequent tests, in case the bits should indeed stick around. */
3748 f_vty_amr_start_mode_set(true, "1");
3749 f_vty_amr_start_mode_restore(true);
Vadim Yanitskiy292e5962021-01-03 14:18:47 +01003750 f_shutdown_helper();
Neels Hofmeyr454d7922020-11-26 02:24:57 +00003751}
3752
Neels Hofmeyr21863562020-11-26 00:34:33 +00003753function f_TC_assignment_codec_amr(boolean fr, octetstring mrconf, bitstring s8_s0, bitstring exp_s8_s0,
3754 charstring start_mode := "1")
Philipp Maierd0e64b02019-03-13 14:15:23 +01003755runs on test_CT {
3756
3757 var TestHdlrParams pars := f_gen_test_hdlr_pars();
3758 var MSC_ConnHdlr vc_conn;
3759
3760 /* See note above */
3761 var RSL_IE_Body mr_conf := {
3762 other := {
3763 len := lengthof(mrconf),
3764 payload := mrconf
3765 }
3766 };
3767
3768 if (fr) {
3769 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_F}));
3770 } else {
3771 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_H}));
3772 }
3773 pars.ass_codec_list.codecElements[0].s0_7 := s8_s0;
3774 pars.ass_codec_list.codecElements[0].s8_15 := '00000111'B;
3775 pars.expect_mr_conf_ie := mr_conf;
3776 pars.expect_mr_s0_s7 := exp_s8_s0;
3777
3778 f_init(1, true);
3779 f_allow_amr_rate_4_75k_5_90k_7_40k_12_20k();
Neels Hofmeyr21863562020-11-26 00:34:33 +00003780 f_vty_amr_start_mode_set(fr, start_mode);
Philipp Maierd0e64b02019-03-13 14:15:23 +01003781 f_sleep(1.0);
3782
3783 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
3784 vc_conn.done;
3785 f_allow_amr_rate_5_90k();
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00003786 f_vty_amr_start_mode_restore(fr);
Philipp Maierd0e64b02019-03-13 14:15:23 +01003787}
3788
3789function f_TC_assignment_codec_amr_fail(boolean fr, bitstring s8_s0)
3790runs on test_CT {
3791
3792 var TestHdlrParams pars := f_gen_test_hdlr_pars();
3793 var MSC_ConnHdlr vc_conn;
3794
3795 if (fr) {
3796 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_F}));
3797 } else {
3798 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_H}));
3799 }
3800 pars.ass_codec_list.codecElements[0].s0_7 := s8_s0;
3801 pars.ass_codec_list.codecElements[0].s8_15 := '00000111'B;
3802
3803 f_init(1, true);
3804 f_allow_amr_rate_4_75k_5_90k_7_40k_12_20k();
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00003805 f_vty_amr_start_mode_set(fr, "1");
Philipp Maierd0e64b02019-03-13 14:15:23 +01003806 f_sleep(1.0);
3807
3808 vc_conn := f_start_handler(refers(f_TC_assignment_codec_fail), pars);
3809 vc_conn.done;
3810 f_allow_amr_rate_5_90k();
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00003811 f_vty_amr_start_mode_restore(fr);
Philipp Maierd0e64b02019-03-13 14:15:23 +01003812}
3813
3814
3815/* Set S1, we expect an AMR multirate configuration IE with all four rates
3816 * set. */
3817testcase TC_assignment_codec_amr_f_S1() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003818 f_TC_assignment_codec_amr(true, '289520882208'O, '00000010'B, '00000010'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003819 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003820}
3821
3822/* Set S1, we expect an AMR multirate configuration IE with the lower three
3823 * rates set. */
3824testcase TC_assignment_codec_amr_h_S1() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003825 f_TC_assignment_codec_amr(false, '2815208820'O, '00000010'B, '00000010'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003826 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003827}
3828
3829/* Set S1 and two other rates, we expect an AMR MULTIRATE CONFIGURATION IE with
3830 * all four rates (and only S1 set in the ASSIGNMENT COMPLETE) */
3831testcase TC_assignment_codec_amr_f_S124() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003832 f_TC_assignment_codec_amr(true, '289520882208'O, '00010110'B, '00000010'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003833 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003834}
3835
3836/* Set S1 and two other rates, we expect an AMR MULTIRATE CONFIGURATION IE with
3837 * all four rates (and only S1 set in the ASSIGNMENT COMPLETE) */
3838testcase TC_assignment_codec_amr_h_S124() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003839 f_TC_assignment_codec_amr(false, '2815208820'O, '00010110'B, '00000010'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003840 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003841}
3842
3843/* The following block of tests selects more and more rates until all four
3844 * possible rates are in the active set (full rate) */
3845testcase TC_assignment_codec_amr_f_S0() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003846 f_TC_assignment_codec_amr(true, '2801'O, '00000001'B, '00000001'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003847 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003848}
3849
3850testcase TC_assignment_codec_amr_f_S02() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003851 f_TC_assignment_codec_amr(true, '28052080'O, '00000101'B, '00000101'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003852 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003853}
3854
3855testcase TC_assignment_codec_amr_f_S024() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003856 f_TC_assignment_codec_amr(true, '2815208820'O, '00010101'B, '00010101'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003857 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003858}
3859
3860testcase TC_assignment_codec_amr_f_S0247() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003861 f_TC_assignment_codec_amr(true, '289520882208'O, '10010101'B, '10010101'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003862 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003863}
3864
3865/* The following block of tests selects more and more rates until all three
3866 * possible rates are in the active set (half rate) */
3867testcase TC_assignment_codec_amr_h_S0() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003868 f_TC_assignment_codec_amr(false, '2801'O, '00000001'B, '00000001'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003869 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003870}
3871
3872testcase TC_assignment_codec_amr_h_S02() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003873 f_TC_assignment_codec_amr(false, '28052080'O, '00000101'B, '00000101'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003874 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003875}
3876
3877testcase TC_assignment_codec_amr_h_S024() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003878 f_TC_assignment_codec_amr(false, '2815208820'O, '00010101'B, '00010101'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003879 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003880}
3881
3882/* The following block tests what happens when the MSC does offer rate
3883 * configurations that are not supported by the BSC. Normally such situations
3884 * should not happen because the MSC gets informed by the BSC in advance via
3885 * the L3 COMPLETE message which rates are applicable. The MSC should not try
3886 * to offer rates that are not applicable anyway. */
3887
3888testcase TC_assignment_codec_amr_h_S0247() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003889 /* Try to include 12,2k in into the active set even though the channel
3890 * is half rate only. The BSC is expected to remove the 12,0k */
3891 f_TC_assignment_codec_amr(false, '2815208820'O, '10010101'B, '00010101'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003892 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003893}
3894
3895testcase TC_assignment_codec_amr_f_S01234567() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003896 /* See what happens when all rates are selected at once. Since then
3897 * Also S1 is selected, this setting will be prefered and we should
3898 * get 12.2k, 7,40k, 5,90k, and 4,75k in the active set. */
3899 f_TC_assignment_codec_amr(true, '289520882208'O, '11111111'B, '00000010'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003900 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003901}
3902
3903testcase TC_assignment_codec_amr_f_S0234567() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003904 /* Same as above, but with S1 missing, the MSC is then expected to
3905 * select the currently supported rates, which are also 12.2k, 7,40k,
3906 * 5,90k, and 4,75k, into the active set. */
3907 f_TC_assignment_codec_amr(true, '289520882208'O, '11111101'B, '10010101'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003908 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003909}
3910
3911testcase TC_assignment_codec_amr_f_zero() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003912 /* Try to select no rates at all */
3913 f_TC_assignment_codec_amr_fail(true, '00000000'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003914 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003915}
3916
3917testcase TC_assignment_codec_amr_f_unsupp() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003918 /* Try to select only unsupported rates */
3919 f_TC_assignment_codec_amr_fail(true, '01101000'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003920 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003921}
3922
3923testcase TC_assignment_codec_amr_h_S7() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003924 /* Try to select 12,2k for half rate */
3925 f_TC_assignment_codec_amr_fail(false, '10000000'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003926 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003927}
3928
Neels Hofmeyr21863562020-11-26 00:34:33 +00003929testcase TC_assignment_codec_amr_f_start_mode_auto() runs on test_CT {
3930 f_TC_assignment_codec_amr(true, '209520882208'O, '11111111'B, '00000010'B,
3931 start_mode := "auto");
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01003932 f_shutdown_helper();
Neels Hofmeyr21863562020-11-26 00:34:33 +00003933}
3934
3935testcase TC_assignment_codec_amr_h_start_mode_auto() runs on test_CT {
3936 f_TC_assignment_codec_amr(false, '2015208820'O, '10010101'B, '00010101'B,
3937 start_mode := "auto");
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01003938 f_shutdown_helper();
Neels Hofmeyr21863562020-11-26 00:34:33 +00003939}
3940
Neels Hofmeyr3eb94562020-11-26 02:40:26 +00003941testcase TC_assignment_codec_amr_f_start_mode_4() runs on test_CT {
3942 f_TC_assignment_codec_amr(true, '2b9520882208'O, '11111111'B, '00000010'B,
3943 start_mode := "4");
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01003944 f_shutdown_helper();
Neels Hofmeyr3eb94562020-11-26 02:40:26 +00003945}
3946
3947testcase TC_assignment_codec_amr_h_start_mode_4() runs on test_CT {
3948 f_TC_assignment_codec_amr(false, '2b15208820'O, '10010101'B, '00010101'B,
3949 start_mode := "4");
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01003950 f_shutdown_helper();
Neels Hofmeyr3eb94562020-11-26 02:40:26 +00003951}
3952
Philipp Maierac09bfc2019-01-08 13:41:39 +01003953private function f_disable_all_tch_f() runs on test_CT {
Philipp Maierc704a882019-01-29 15:58:52 +01003954 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 1 sub-slot 0 borken");
3955 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 2 sub-slot 0 borken");
3956 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 3 sub-slot 0 borken");
3957 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 4 sub-slot 0 borken");
Philipp Maierac09bfc2019-01-08 13:41:39 +01003958}
3959
3960private function f_disable_all_tch_h() runs on test_CT {
Philipp Maierc704a882019-01-29 15:58:52 +01003961 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 5 sub-slot 0 borken");
3962 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 5 sub-slot 1 borken");
Philipp Maierac09bfc2019-01-08 13:41:39 +01003963}
3964
3965private function f_enable_all_tch() runs on test_CT {
Philipp Maierc704a882019-01-29 15:58:52 +01003966 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 1 sub-slot 0 unused");
3967 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 2 sub-slot 0 unused");
3968 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 3 sub-slot 0 unused");
3969 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 4 sub-slot 0 unused");
3970 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 5 sub-slot 0 unused");
3971 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 5 sub-slot 1 unused");
Philipp Maierac09bfc2019-01-08 13:41:39 +01003972}
3973
3974/* Allow HR only */
3975private function f_TC_assignment_codec_xr_exhausted_req_hr(charstring id) runs on MSC_ConnHdlr {
3976 g_pars := f_gen_test_hdlr_pars();
3977 var PDU_BSSAP ass_cmd := f_gen_ass_req();
3978 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3979 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3980 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '09'O;
3981 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '05'O;
3982 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR}));
3983 f_establish_fully(ass_cmd, exp_compl);
3984}
3985
3986/* Allow FR only */
3987private function f_TC_assignment_codec_xr_exhausted_req_fr(charstring id) runs on MSC_ConnHdlr {
3988 g_pars := f_gen_test_hdlr_pars();
3989 var PDU_BSSAP ass_cmd := f_gen_ass_req();
3990 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3991 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3992 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '08'O;
3993 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '01'O;
3994 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
3995 f_establish_fully(ass_cmd, exp_compl);
3996}
3997
3998/* Allow HR only (expect assignment failure) */
3999private function f_TC_assignment_codec_xr_exhausted_req_hr_fail(charstring id) runs on MSC_ConnHdlr {
4000 g_pars := f_gen_test_hdlr_pars();
4001 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4002 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
4003 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4004 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '09'O;
4005 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '05'O;
4006 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR}));
4007 f_establish_fully(ass_cmd, exp_fail);
4008}
4009
4010/* Allow FR only (expect assignment failure) */
4011private function f_TC_assignment_codec_xr_exhausted_req_fr_fail(charstring id) runs on MSC_ConnHdlr {
4012 g_pars := f_gen_test_hdlr_pars();
4013 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4014 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
4015 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4016 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '08'O;
4017 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '01'O;
4018 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
4019 f_establish_fully(ass_cmd, exp_fail);
4020}
4021
4022/* Allow FR and HR, but prefer FR */
4023private function f_TC_assignment_codec_fr_exhausted_req_fr_hr(charstring id) runs on MSC_ConnHdlr {
4024 g_pars := f_gen_test_hdlr_pars();
4025 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4026 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4027 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4028 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0A'O; /* Prefer FR */
4029 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8105'O;
4030 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR, ts_CodecHR}));
4031 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000101'B; /* Expect HR */
4032 f_establish_fully(ass_cmd, exp_compl);
4033}
4034
4035/* Allow FR and HR, but prefer HR */
4036private function f_TC_assignment_codec_fr_exhausted_req_hr_fr(charstring id) runs on MSC_ConnHdlr {
4037 g_pars := f_gen_test_hdlr_pars();
4038 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4039 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4040 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4041 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0B'O; /* Prefer HR */
4042 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8501'O;
4043 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR, ts_CodecFR}));
4044 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000101'B; /* Expect HR */
4045 f_establish_fully(ass_cmd, exp_compl);
4046}
4047
4048/* Allow FR and HR, but prefer FR */
4049private function f_TC_assignment_codec_hr_exhausted_req_fr_hr(charstring id) runs on MSC_ConnHdlr {
4050 g_pars := f_gen_test_hdlr_pars();
4051 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4052 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4053 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4054 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0A'O; /* Prefer FR */
4055 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8105'O;
4056 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR, ts_CodecHR}));
4057 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000001'B; /* Expect FR */
4058 f_establish_fully(ass_cmd, exp_compl);
4059}
4060
4061/* Allow FR and HR, but prefer HR */
4062private function f_TC_assignment_codec_hr_exhausted_req_hr_fr(charstring id) runs on MSC_ConnHdlr {
4063 g_pars := f_gen_test_hdlr_pars();
4064 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4065 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4066 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4067 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0B'O; /* Prefer HR */
4068 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8501'O;
4069 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR, ts_CodecFR}));
4070 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000001'B; /* Expect FR */
4071 f_establish_fully(ass_cmd, exp_compl);
4072}
4073
4074/* Request a HR channel while all FR channels are exhausted, this is expected
4075 * to work without conflicts */
4076testcase TC_assignment_codec_fr_exhausted_req_hr() runs on test_CT {
4077 var MSC_ConnHdlr vc_conn;
4078 f_init(1, true);
4079 f_sleep(1.0);
4080 f_enable_all_tch();
4081 f_disable_all_tch_f();
4082 vc_conn := f_start_handler(refers(f_TC_assignment_codec_xr_exhausted_req_hr));
4083 vc_conn.done;
4084 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004085 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004086}
4087
4088/* Request a FR channel while all FR channels are exhausted, this is expected
4089 * to fail. */
4090testcase TC_assignment_codec_fr_exhausted_req_fr() runs on test_CT {
4091 var MSC_ConnHdlr vc_conn;
4092 f_init(1, true);
4093 f_sleep(1.0);
4094 f_enable_all_tch();
4095 f_disable_all_tch_f();
4096 vc_conn := f_start_handler(refers(f_TC_assignment_codec_xr_exhausted_req_fr_fail));
4097 vc_conn.done;
4098 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004099 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004100}
4101
4102/* Request a FR (prefered) or alternatively a HR channel while all FR channels
4103 * are exhausted, this is expected to be resolved by selecting a HR channel. */
4104testcase TC_assignment_codec_fr_exhausted_req_fr_hr() runs on test_CT {
4105 var MSC_ConnHdlr vc_conn;
4106 f_init(1, true);
4107 f_sleep(1.0);
4108 f_enable_all_tch();
4109 f_disable_all_tch_f();
4110 vc_conn := f_start_handler(refers(f_TC_assignment_codec_fr_exhausted_req_fr_hr));
4111 vc_conn.done;
4112 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004113 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004114}
4115
4116/* Request a HR (prefered) or alternatively a FR channel while all FR channels
4117 * are exhausted, this is expected to work without conflicts. */
4118testcase TC_assignment_codec_fr_exhausted_req_hr_fr() runs on test_CT {
4119 var MSC_ConnHdlr vc_conn;
4120 f_init(1, true);
4121 f_sleep(1.0);
4122 f_enable_all_tch();
4123 f_disable_all_tch_f();
4124 vc_conn := f_start_handler(refers(f_TC_assignment_codec_fr_exhausted_req_hr_fr));
4125 vc_conn.done;
4126 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004127 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004128}
4129
4130/* Request a FR channel while all HR channels are exhausted, this is expected
4131 * to work without conflicts */
4132testcase TC_assignment_codec_hr_exhausted_req_fr() runs on test_CT {
4133 var MSC_ConnHdlr vc_conn;
4134 f_init(1, true);
4135 f_sleep(1.0);
4136 f_enable_all_tch();
4137 f_disable_all_tch_h();
4138 vc_conn := f_start_handler(refers(f_TC_assignment_codec_xr_exhausted_req_fr));
4139 vc_conn.done;
4140 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004141 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004142}
4143
4144/* Request a HR channel while all HR channels are exhausted, this is expected
4145 * to fail. */
4146testcase TC_assignment_codec_hr_exhausted_req_hr() runs on test_CT {
4147 var MSC_ConnHdlr vc_conn;
4148 f_init(1, true);
4149 f_sleep(1.0);
4150 f_enable_all_tch();
4151 f_disable_all_tch_h();
4152 vc_conn := f_start_handler(refers(f_TC_assignment_codec_xr_exhausted_req_hr_fail));
4153 vc_conn.done;
4154 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004155 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004156}
4157
4158/* Request a HR (prefered) or alternatively a FR channel while all HR channels
4159 * are exhausted, this is expected to be resolved by selecting a FR channel. */
4160testcase TC_assignment_codec_hr_exhausted_req_hr_fr() runs on test_CT {
4161 var MSC_ConnHdlr vc_conn;
4162 f_init(1, true);
4163 f_sleep(1.0);
4164 f_enable_all_tch();
4165 f_disable_all_tch_h();
4166 vc_conn := f_start_handler(refers(f_TC_assignment_codec_hr_exhausted_req_hr_fr));
4167 vc_conn.done;
4168 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004169 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004170}
4171
4172/* Request a FR (prefered) or alternatively a HR channel while all HR channels
4173 * are exhausted, this is expected to work without conflicts. */
4174testcase TC_assignment_codec_hr_exhausted_req_fr_hr() runs on test_CT {
4175 var MSC_ConnHdlr vc_conn;
4176 f_init(1, true);
4177 f_sleep(1.0);
4178 f_enable_all_tch();
4179 f_disable_all_tch_h();
4180 vc_conn := f_start_handler(refers(f_TC_assignment_codec_hr_exhausted_req_fr_hr));
4181 vc_conn.done;
4182 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004183 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004184}
4185
4186/* Allow FR and HR, but prefer HR */
4187private function f_TC_assignment_codec_req_hr_fr(charstring id) runs on MSC_ConnHdlr {
4188 g_pars := f_gen_test_hdlr_pars();
4189 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4190 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4191 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4192 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0B'O; /* Prefer HR */
4193 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8501'O;
4194 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR, ts_CodecFR}));
4195 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000101'B; /* Expect HR */
4196 f_establish_fully(ass_cmd, exp_compl);
4197}
4198
4199/* Allow FR and HR, but prefer FR */
4200private function f_TC_assignment_codec_req_fr_hr(charstring id) runs on MSC_ConnHdlr {
4201 g_pars := f_gen_test_hdlr_pars();
4202 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4203 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4204 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4205 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0A'O; /* Prefer FR */
4206 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8105'O;
4207 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR, ts_CodecHR}));
4208 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000001'B; /* Expect FR */
4209 f_establish_fully(ass_cmd, exp_compl);
4210}
4211
4212/* Request a HR (prefered) or alternatively a FR channel, it is expected that
4213 * HR, which is the prefered type, is selected. */
4214testcase TC_assignment_codec_req_hr_fr() runs on test_CT {
4215 var MSC_ConnHdlr vc_conn;
4216 f_init(1, true);
4217 f_sleep(1.0);
4218 f_enable_all_tch();
4219 vc_conn := f_start_handler(refers(f_TC_assignment_codec_req_hr_fr));
4220 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004221 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004222}
4223
4224/* Request a FR (prefered) or alternatively a HR channel, it is expected that
4225 * FR, which is the prefered type, is selected. */
4226testcase TC_assignment_codec_req_fr_hr() runs on test_CT {
4227 var MSC_ConnHdlr vc_conn;
4228 f_init(1, true);
4229 f_sleep(1.0);
4230 f_enable_all_tch();
4231 vc_conn := f_start_handler(refers(f_TC_assignment_codec_req_fr_hr));
4232 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004233 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004234}
4235
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02004236testcase TC_assignment_osmux() runs on test_CT {
4237 var TestHdlrParams pars := f_gen_test_hdlr_pars();
4238 var MSC_ConnHdlr vc_conn;
4239
4240 /* See note above */
4241 var RSL_IE_Body mr_conf := {
4242 other := {
4243 len := 2,
4244 payload := '2804'O
4245 }
4246 };
4247
4248 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_H}));
4249 pars.ass_codec_list.codecElements[0].s0_7 := '00000100'B; /* 5,90k */
4250 pars.ass_codec_list.codecElements[0].s8_15 := '00000111'B;
4251 pars.expect_mr_conf_ie := mr_conf;
4252 pars.use_osmux := true;
4253
4254 f_init(1, true, true);
4255 f_sleep(1.0);
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00004256 f_vty_amr_start_mode_set(false, "1");
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02004257
4258 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
4259 vc_conn.done;
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00004260
4261 f_vty_amr_start_mode_restore(false);
Vadim Yanitskiy292e5962021-01-03 14:18:47 +01004262 f_shutdown_helper();
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02004263}
4264
Neels Hofmeyr92b12b72018-09-18 14:30:23 +02004265/* test the procedure of the MSC requesting a Classmark Update:
4266 * a) BSSMAP Classmark Request should result in RR CLASSMARK ENQUIRY,
4267 * b) L3 RR CLASSMARK CHANGE should result in BSSMAP CLASSMARK UPDATE */
Harald Welte898113b2018-01-31 18:32:21 +01004268private function f_tc_classmark(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02004269 g_pars := f_gen_test_hdlr_pars();
4270
Harald Weltea0630032018-03-20 21:09:55 +01004271 f_create_chan_and_exp();
Harald Welte898113b2018-01-31 18:32:21 +01004272 /* we should now have a COMPL_L3 at the MSC */
4273 BSSAP.receive(tr_BSSMAP_ComplL3);
4274
Neels Hofmeyr92b12b72018-09-18 14:30:23 +02004275 BSSAP.send(ts_BSSMAP_ClassmarkRequest);
4276 RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_CM_ENQUIRY));
4277
Harald Welte898113b2018-01-31 18:32:21 +01004278 f_rsl_send_l3(ts_RRM_CM_CHG(valueof(ts_CM2)));
4279 BSSAP.receive(tr_BSSMAP_ClassmarkUpd(?, omit));
4280 setverdict(pass);
4281}
4282testcase TC_classmark() runs on test_CT {
4283 var MSC_ConnHdlr vc_conn;
4284 f_init(1, true);
4285 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02004286 vc_conn := f_start_handler(refers(f_tc_classmark));
Harald Welte898113b2018-01-31 18:32:21 +01004287 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004288 f_shutdown_helper();
Harald Welte898113b2018-01-31 18:32:21 +01004289}
4290
Harald Welteeddf0e92020-06-21 19:42:15 +02004291/* Send a CommonID from the simulated MSC and verify that the information is used to
4292 * fill BSC-internal data structures (specifically, bsc_subscr associated with subscr_conn) */
4293private function f_tc_common_id(charstring id) runs on MSC_ConnHdlr {
4294 g_pars := f_gen_test_hdlr_pars();
4295 f_MscConnHdlr_init_vty();
4296
4297 f_create_chan_and_exp();
4298 /* we should now have a COMPL_L3 at the MSC */
4299 BSSAP.receive(tr_BSSMAP_ComplL3);
4300
4301 /* Send CommonID */
4302 BSSAP.send(ts_BSSMAP_CommonId(g_pars.imsi));
4303
4304 /* Use VTY to verify that the IMSI of the subscr_conn is set */
4305 var charstring regex := "*(IMSI: " & hex2str(g_pars.imsi) & ")*";
4306 f_vty_transceive_match_regexp_retry(BSCVTY, "show conns", regex, 0, 4, 1.0);
4307
4308 setverdict(pass);
4309}
4310testcase TC_common_id() runs on test_CT {
4311 var MSC_ConnHdlr vc_conn;
4312 f_init(1, true);
4313 f_sleep(1.0);
4314 vc_conn := f_start_handler(refers(f_tc_common_id));
4315 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004316 f_shutdown_helper();
Harald Welteeddf0e92020-06-21 19:42:15 +02004317}
4318
Harald Weltee3bd6582018-01-31 22:51:25 +01004319private function f_est_single_l3(template PDU_ML3_MS_NW l3) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02004320 g_pars := f_gen_test_hdlr_pars();
Harald Weltea0630032018-03-20 21:09:55 +01004321 f_create_chan_and_exp();
Harald Welte898113b2018-01-31 18:32:21 +01004322 /* we should now have a COMPL_L3 at the MSC */
4323 BSSAP.receive(tr_BSSMAP_ComplL3);
4324
Harald Weltee3bd6582018-01-31 22:51:25 +01004325 /* send the single message we want to send */
4326 f_rsl_send_l3(l3);
4327}
4328
4329private function f_bssap_expect_nothing(float sec := 5.00) runs on MSC_ConnHdlr {
4330 timer T := sec;
4331 var PDU_BSSAP bssap;
Harald Welte898113b2018-01-31 18:32:21 +01004332 T.start;
4333 alt {
Harald Weltee3bd6582018-01-31 22:51:25 +01004334 [] BSSAP.receive(PDU_BSSAP:?) -> value bssap {
4335 setverdict(fail, "Unexpected BSSMAP ", bssap);
Daniel Willmannafce8662018-07-06 23:11:32 +02004336 mtc.stop;
Harald Welte898113b2018-01-31 18:32:21 +01004337 }
4338 [] T.timeout {
4339 setverdict(pass);
4340 }
4341 }
4342}
4343
Harald Weltee3bd6582018-01-31 22:51:25 +01004344/* unsolicited ASSIGNMENT FAIL (without ASSIGN) from MS shouldn't bring BSC down */
4345private function f_tc_unsol_ass_fail(charstring id) runs on MSC_ConnHdlr {
4346 f_est_single_l3(ts_RRM_AssignmentFailure('00'O));
4347 f_bssap_expect_nothing();
4348}
Harald Welte898113b2018-01-31 18:32:21 +01004349testcase TC_unsol_ass_fail() runs on test_CT {
4350 var MSC_ConnHdlr vc_conn;
4351 f_init(1, true);
4352 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02004353 vc_conn := f_start_handler(refers(f_tc_unsol_ass_fail));
Harald Welte898113b2018-01-31 18:32:21 +01004354 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004355 f_shutdown_helper();
Harald Welte898113b2018-01-31 18:32:21 +01004356}
Harald Welte552620d2017-12-16 23:21:36 +01004357
Harald Welteea99a002018-01-31 20:46:43 +01004358
4359/* unsolicited ASSIGNMENT COMPLETE (without ASSIGN) from MS shouldn't bring BSC down */
4360private function f_tc_unsol_ass_compl(charstring id) runs on MSC_ConnHdlr {
Harald Weltee3bd6582018-01-31 22:51:25 +01004361 f_est_single_l3(ts_RRM_AssignmentComplete('00'O));
4362 f_bssap_expect_nothing();
Harald Welteea99a002018-01-31 20:46:43 +01004363}
4364testcase TC_unsol_ass_compl() runs on test_CT {
4365 var MSC_ConnHdlr vc_conn;
4366 f_init(1, true);
4367 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02004368 vc_conn := f_start_handler(refers(f_tc_unsol_ass_compl));
Harald Welteea99a002018-01-31 20:46:43 +01004369 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004370 f_shutdown_helper();
Harald Welteea99a002018-01-31 20:46:43 +01004371}
4372
4373
Harald Weltefbf9b5e2018-01-31 20:41:23 +01004374/* unsolicited HANDOVER FAIL (without ASSIGN) from MS shouldn't bring BSC down */
4375private function f_tc_unsol_ho_fail(charstring id) runs on MSC_ConnHdlr {
Harald Weltee3bd6582018-01-31 22:51:25 +01004376 f_est_single_l3(ts_RRM_HandoverFailure('00'O));
4377 f_bssap_expect_nothing();
Harald Weltefbf9b5e2018-01-31 20:41:23 +01004378}
Harald Weltefbf9b5e2018-01-31 20:41:23 +01004379testcase TC_unsol_ho_fail() runs on test_CT {
4380 var MSC_ConnHdlr vc_conn;
4381 f_init(1, true);
4382 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02004383 vc_conn := f_start_handler(refers(f_tc_unsol_ho_fail));
Harald Weltefbf9b5e2018-01-31 20:41:23 +01004384 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004385 f_shutdown_helper();
Harald Weltefbf9b5e2018-01-31 20:41:23 +01004386}
4387
4388
Harald Weltee3bd6582018-01-31 22:51:25 +01004389/* short message from MS should be ignored */
4390private function f_tc_err_82_short_msg(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02004391 g_pars := f_gen_test_hdlr_pars();
Harald Weltea0630032018-03-20 21:09:55 +01004392 f_create_chan_and_exp();
Harald Weltee3bd6582018-01-31 22:51:25 +01004393 /* we should now have a COMPL_L3 at the MSC */
4394 BSSAP.receive(tr_BSSMAP_ComplL3);
4395
4396 /* send short message */
4397 RSL.send(ts_RSL_DATA_IND(g_chan_nr, valueof(ts_RslLinkID_DCCH(0)), ''O));
4398 f_bssap_expect_nothing();
4399}
4400testcase TC_err_82_short_msg() runs on test_CT {
4401 var MSC_ConnHdlr vc_conn;
4402 f_init(1, true);
4403 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02004404 vc_conn := f_start_handler(refers(f_tc_err_82_short_msg));
Harald Weltee3bd6582018-01-31 22:51:25 +01004405 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004406 f_shutdown_helper();
Harald Weltee3bd6582018-01-31 22:51:25 +01004407}
4408
4409
Harald Weltee9e02e42018-01-31 23:36:25 +01004410/* 24.008 8.4 Unknown message must trigger RR STATUS */
4411private function f_tc_err_84_unknown_msg(charstring id) runs on MSC_ConnHdlr {
4412 f_est_single_l3(ts_RRM_UL_REL('00'O));
4413 timer T := 3.0
4414 alt {
4415 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_STATUS)) {
4416 setverdict(pass);
4417 }
4418 [] BSSAP.receive { setverdict(fail, "unexpected BSSAP"); }
Harald Welte458fd372018-03-21 11:26:23 +01004419 [] T.timeout { setverdict(fail, "Timeout waiting for RR STATUS"); }
Harald Weltee9e02e42018-01-31 23:36:25 +01004420 }
4421}
4422testcase TC_err_84_unknown_msg() runs on test_CT {
4423 var MSC_ConnHdlr vc_conn;
4424 f_init(1, true);
4425 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02004426 vc_conn := f_start_handler(refers(f_tc_err_84_unknown_msg));
Harald Weltee9e02e42018-01-31 23:36:25 +01004427 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004428 f_shutdown_helper();
Harald Weltee9e02e42018-01-31 23:36:25 +01004429}
4430
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004431/***********************************************************************
4432 * Handover
4433 ***********************************************************************/
4434
Harald Welte94e0c342018-04-07 11:33:23 +02004435/* execute a "bts <0-255> trx <0-255> timeslot <0-7> " command on given Dchan */
4436private function f_vty_ts_action(charstring suffix, integer bts_nr, integer trx_nr, integer ts_nr)
4437runs on test_CT {
4438 var charstring cmd := "bts "&int2str(bts_nr)&" trx "&int2str(trx_nr)&
4439 " timeslot "&int2str(ts_nr)&" ";
4440 f_vty_transceive(BSCVTY, cmd & suffix);
4441}
4442
Harald Welte261af4b2018-02-12 21:20:39 +01004443/* 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 +07004444private function f_vty_ss_action(TELNETasp_PT pt, charstring suffix,
4445 uint8_t bts_nr, uint8_t trx_nr,
4446 in RslChannelNr chan_nr)
4447{
Harald Welte261af4b2018-02-12 21:20:39 +01004448 /* FIXME: resolve those from component-global state */
4449 var integer ts_nr := chan_nr.tn;
4450 var integer ss_nr;
4451 if (ischosen(chan_nr.u.ch0)) {
4452 ss_nr := 0;
4453 } else if (ischosen(chan_nr.u.lm)) {
4454 ss_nr := chan_nr.u.lm.sub_chan;
4455 } else if (ischosen(chan_nr.u.sdcch4)) {
4456 ss_nr := chan_nr.u.sdcch4.sub_chan;
4457 } else if (ischosen(chan_nr.u.sdcch8)) {
4458 ss_nr := chan_nr.u.sdcch8.sub_chan;
4459 } else {
4460 setverdict(fail, "Invalid ChanNr ", chan_nr);
Daniel Willmannafce8662018-07-06 23:11:32 +02004461 mtc.stop;
Harald Welte261af4b2018-02-12 21:20:39 +01004462 }
4463
4464 var charstring cmd := "bts "&int2str(bts_nr)&" trx "&int2str(trx_nr)&
4465 " timeslot "&int2str(ts_nr)&" sub-slot "&int2str(ss_nr)&" ";
Vadim Yanitskiy00070722020-09-02 17:27:57 +07004466 f_vty_transceive(pt, cmd & suffix);
Harald Welte261af4b2018-02-12 21:20:39 +01004467}
4468
Neels Hofmeyr91401012019-07-11 00:42:35 +02004469/* Even though the VTY command to trigger handover takes a new BTS number as argument, behind the scenes osmo-bsc always
4470 * translates that to a target ARFCN+BSIC first. See bsc_vty.c trigger_ho_or_as(), which puts the selected BTS' neighbor
4471 * ident key (ARFCN + BSIC) in the struct passed on to handover_request(). handover_start() then resolves that to a
4472 * viable actual neighbor cell. So from the internal osmo-bsc perspective, we always request handover to an ARFCN + BSIC
4473 * pair, not really to a specific BTS number. */
Vadim Yanitskiy00070722020-09-02 17:27:57 +07004474private function f_vty_handover(TELNETasp_PT pt, uint8_t bts_nr, uint8_t trx_nr,
4475 in RslChannelNr chan_nr, uint8_t new_bts_nr)
4476{
4477 f_vty_ss_action(pt, "handover " & int2str(new_bts_nr), bts_nr, trx_nr, chan_nr);
Harald Welte261af4b2018-02-12 21:20:39 +01004478}
4479
4480/* intra-BSC hand-over between BTS0 and BTS1 */
4481private function f_tc_ho_int(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02004482 g_pars := f_gen_test_hdlr_pars();
Harald Welteed848512018-05-24 22:27:58 +02004483 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4484 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte261af4b2018-02-12 21:20:39 +01004485 const OCT8 kc := '0001020304050607'O;
4486
4487 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4488 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
4489
Harald Weltea0630032018-03-20 21:09:55 +01004490 f_establish_fully(ass_cmd, exp_compl);
Neels Hofmeyr666f0432020-07-04 00:53:07 +02004491 f_bts_0_cfg(BSCVTY, {"neighbor bts 1"});
Harald Welte261af4b2018-02-12 21:20:39 +01004492
4493 var HandoverState hs := {
4494 rr_ho_cmpl_seen := false,
4495 handover_done := false,
4496 old_chan_nr := -
4497 };
4498 /* issue hand-over command on VTY */
Vadim Yanitskiy00070722020-09-02 17:27:57 +07004499 f_vty_handover(BSCVTY, 0, 0, g_chan_nr, 1);
Harald Welte261af4b2018-02-12 21:20:39 +01004500 /* temporarily suspend DChan processing on BTS1 to avoid race with RSLEM_register */
4501 f_rslem_suspend(RSL1_PROC);
Philipp Maier3e2af5d2018-07-11 17:01:05 +02004502
4503 /* From the MGW perspective, a handover is is characterized by
4504 * performing one MDCX operation with the MGW. So we expect to see
4505 * one more MDCX during handover. */
4506 g_media.mgcp_conn[0].mdcx_seen_exp := g_media.mgcp_conn[0].crcx_seen_exp + 1;
4507
Harald Welte261af4b2018-02-12 21:20:39 +01004508 alt {
4509 [] as_handover(hs);
Harald Welte261af4b2018-02-12 21:20:39 +01004510 }
Philipp Maier3e2af5d2018-07-11 17:01:05 +02004511
Philipp Maier4dae0652018-11-12 12:03:26 +01004512 /* Since this is an internal handover we expect the BSC to inform the
4513 * MSC about the event */
4514 BSSAP.receive(tr_BSSMAP_HandoverPerformed);
4515
Philipp Maier3e2af5d2018-07-11 17:01:05 +02004516 /* Check the amount of MGCP transactions is still consistant with the
4517 * test expectation */
4518 f_check_mgcp_expectations()
Neels Hofmeyr861a4c12018-11-07 01:23:17 +01004519 f_sleep(0.5);
Harald Welte261af4b2018-02-12 21:20:39 +01004520}
4521
4522testcase TC_ho_int() runs on test_CT {
4523 var MSC_ConnHdlr vc_conn;
4524 f_init(2, true);
4525 f_sleep(1.0);
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004526
4527 f_ctrs_bsc_and_bts_init();
4528
Harald Welte8863fa12018-05-10 20:15:27 +02004529 vc_conn := f_start_handler(refers(f_tc_ho_int));
Harald Welte261af4b2018-02-12 21:20:39 +01004530 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004531
4532 /* from f_establish_fully() */
4533 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
4534 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
4535 /* from handover */
4536 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
4537 f_ctrs_bsc_and_bts_add(0, "handover:completed");
4538 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
4539 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:completed");
4540 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004541 f_shutdown_helper();
Harald Welte261af4b2018-02-12 21:20:39 +01004542}
Harald Weltee9e02e42018-01-31 23:36:25 +01004543
Neels Hofmeyr5f144212020-11-03 15:41:58 +00004544/* intra-BSC hand-over with CONNection FAILure and cause Radio Link Failure: check RR release cause */
4545private function f_tc_ho_int_radio_link_failure(charstring id) runs on MSC_ConnHdlr {
4546 g_pars := f_gen_test_hdlr_pars();
4547 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4548 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4549 const OCT8 kc := '0001020304050607'O;
4550
4551 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4552 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
4553
4554 f_establish_fully(ass_cmd, exp_compl);
4555 f_bts_0_cfg(BSCVTY, {"neighbor bts 1"});
4556
4557 var HandoverState hs := {
4558 rr_ho_cmpl_seen := false,
4559 handover_done := false,
4560 old_chan_nr := -
4561 };
4562 /* issue hand-over command on VTY */
4563 f_vty_handover(BSCVTY, 0, 0, g_chan_nr, 1);
4564 /* temporarily suspend DChan processing on BTS1 to avoid race with RSLEM_register */
4565 f_rslem_suspend(RSL1_PROC);
4566
4567 /* From the MGW perspective, a handover is is characterized by
4568 * performing one MDCX operation with the MGW. So we expect to see
4569 * one more MDCX during handover. */
4570 g_media.mgcp_conn[0].mdcx_seen_exp := g_media.mgcp_conn[0].crcx_seen_exp + 1;
4571
4572 var RSL_Message rsl;
4573 var PDU_ML3_NW_MS l3;
4574 var RslChannelNr new_chan_nr;
4575 var GsmArfcn arfcn;
4576 RSL.receive(tr_RSL_DATA_REQ(g_chan_nr)) -> value rsl {
4577 l3 := dec_PDU_ML3_NW_MS(rsl.ies[2].body.l3_info.payload);
4578 if (not ischosen(l3.msgs.rrm.handoverCommand)) {
4579 setverdict(fail, "Expected handoverCommand");
4580 mtc.stop;
4581 }
4582 }
4583 f_ChDesc2RslChanNr(l3.msgs.rrm.handoverCommand.channelDescription2,
4584 new_chan_nr, arfcn);
4585
4586 f_rslem_register(0, new_chan_nr, RSL1_PROC);
4587
4588 /* resume processing of RSL DChan messages, which was temporarily suspended
4589 * before performing a hand-over */
4590 f_rslem_resume(RSL1_PROC);
4591 RSL1.receive(tr_RSL_IPA_CRCX(new_chan_nr));
4592
4593 f_sleep(1.0);
4594
4595 /* Handover fails because no HANDO DET appears on the new lchan,
4596 * and the old lchan reports a Radio Link Failure. */
4597 RSL.send(ts_RSL_CONN_FAIL_IND(g_chan_nr, RSL_ERR_RADIO_LINK_FAIL));
4598
4599 var PDU_BSSAP rx_clear_request;
4600 BSSAP.receive(tr_BSSMAP_ClearRequest) -> value rx_clear_request;
4601 var BssmapCause cause := bit2int(rx_clear_request.pdu.bssmap.clearRequest.cause.causeValue);
4602 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
4603
4604 var RR_Cause rr_cause := GSM48_RR_CAUSE_ABNORMAL_UNSPEC;
4605
4606 var MgcpCommand mgcp;
4607 interleave {
4608 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_RELEASE(int2oct(enum2int(rr_cause), 1)))) {}
4609 [] RSL.receive(tr_RSL_DEACT_SACCH(g_chan_nr)) {}
4610 [] RSL.receive(tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL)) {
4611 RSL.send(ts_RSL_RF_CHAN_REL_ACK(g_chan_nr));
4612 }
4613 [] RSL1.receive(tr_RSL_DEACT_SACCH(new_chan_nr)) {}
4614 [] RSL1.receive(tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL)) {
4615 RSL1.send(ts_RSL_RF_CHAN_REL_ACK(new_chan_nr));
4616 }
4617 [] BSSAP.receive(tr_BSSMAP_ClearComplete) {}
4618 }
4619
4620 f_sleep(0.5);
4621 setverdict(pass);
4622}
4623testcase TC_ho_int_radio_link_failure() runs on test_CT {
4624 var MSC_ConnHdlr vc_conn;
4625 f_init(2, true);
4626 f_sleep(1.0);
4627
4628 f_ctrs_bsc_and_bts_init();
4629
4630 vc_conn := f_start_handler(refers(f_tc_ho_int_radio_link_failure));
4631 vc_conn.done;
4632
4633 /* from f_establish_fully() */
4634 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
4635 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
4636 /* from handover */
4637 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
4638 f_ctrs_bsc_and_bts_add(0, "handover:stopped");
4639 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
4640 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:stopped");
4641 f_ctrs_bsc_and_bts_verify();
4642 f_shutdown_helper();
4643}
4644
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004645/* Expecting MGCP to DLCX the endpoint's two connections: towards BTS and towards MSC */
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02004646private function f_expect_dlcx_conns() runs on MSC_ConnHdlr {
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004647 var MgcpCommand mgcp;
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +02004648 var template MgcpResponse mgcp_resp;
4649 var MGCP_RecvFrom mrf;
4650 var template MgcpMessage msg_resp;
4651 var template MgcpMessage msg_dlcx := {
4652 command := tr_DLCX()
4653 }
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004654
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +02004655 if (g_pars.aoip) {
4656 MGCP.receive(tr_DLCX()) -> value mgcp {
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004657 log("Got first DLCX: ", mgcp);
4658 MGCP.send(ts_DLCX_ACK2(mgcp.line.trans_id));
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +02004659 };
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004660
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004661 MGCP.receive(tr_DLCX()) -> value mgcp {
4662 log("Got second DLCX: ", mgcp);
4663 MGCP.send(ts_DLCX_ACK2(mgcp.line.trans_id));
4664 };
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +02004665 } else {
4666 /* For SCCPLite, BSC doesn't handle the MSC-side */
4667 MGCP_MULTI.receive(tr_MGCP_RecvFrom_any(msg_dlcx)) -> value mrf {
4668 log("Got first DLCX: ", mrf.msg.command);
4669 msg_resp := {
4670 response := ts_DLCX_ACK2(mrf.msg.command.line.trans_id)
4671 }
4672 MGCP_MULTI.send(t_MGCP_SendToMrf(mrf, msg_resp));
4673 };
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004674 }
4675
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02004676 BSSAP.receive(tr_BSSMAP_ClearComplete);
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004677}
4678
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004679private function f_tc_ho_out_of_this_bsc(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02004680 g_pars := f_gen_test_hdlr_pars();
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004681
4682 var PDU_BSSAP ass_req := f_gen_ass_req();
4683 ass_req.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4684 ass_req.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
4685 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4686 f_establish_fully(ass_req, exp_compl);
4687
Neels Hofmeyr666f0432020-07-04 00:53:07 +02004688 f_bts_0_cfg(BSCVTY, {"neighbor lac 99 arfcn 123 bsic any"});
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004689 f_vty_transceive(BSCVTY, "handover any to arfcn 123 bsic any");
4690
4691 BSSAP.receive(tr_BSSMAP_HandoverRequired);
4692
4693 f_sleep(0.5);
4694 /* The MSC negotiates Handover Request and Handover Request Ack with
4695 * the other BSS and comes back with a BSSMAP Handover Command
4696 * containing an RR Handover Command coming from the target BSS... */
4697
4698 var PDU_ML3_NW_MS rr_ho_cmd := valueof(ts_RR_HandoverCommand);
4699 log("Remote cell's RR Handover Command passed through as L3 Info: ", rr_ho_cmd);
4700 var octetstring rr_ho_cmd_enc := enc_PDU_ML3_NW_MS(rr_ho_cmd);
4701 log("Remote cell's RR Handover Command passed through as L3 Info, encoded: ", rr_ho_cmd_enc);
4702 BSSAP.send(ts_BSSMAP_HandoverCommand(rr_ho_cmd_enc));
4703
4704 /* expect the Handover Command to go out on RR */
4705 var RSL_Message rsl_ho_cmd
4706 RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, ?)) -> value rsl_ho_cmd;
4707 log("RSL Data Req went out to first BTS: ", rsl_ho_cmd);
4708 var RSL_IE_Body rsl_ho_cmd_l3;
4709 if (not f_rsl_find_ie(rsl_ho_cmd, RSL_IE_L3_INFO, rsl_ho_cmd_l3)) {
4710 log("RSL message contains no L3 Info IE, expected RR Handover Command");
4711 setverdict(fail);
4712 } else {
4713 log("Found L3 Info: ", rsl_ho_cmd_l3);
4714 if (rsl_ho_cmd_l3.l3_info.payload != rr_ho_cmd_enc) {
4715 log("FAIL: the BSC sent out a different L3 Info, not matching the RR Handover Command the other BSS forwarded.");
4716 setverdict(fail);
4717 } else {
4718 log("Success: the BSC sent out the same RR Handover Command the other BSS forwarded.");
4719 setverdict(pass);
4720 }
4721 }
4722
4723 /* When the other BSS has reported a completed handover, this side is
4724 * torn down. */
4725
4726 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_HANDOVER_SUCCESSFUL;
4727 var BssmapCause cause := enum2int(cause_val);
4728 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
4729
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02004730 f_expect_dlcx_conns();
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004731 setverdict(pass);
4732 f_sleep(1.0);
4733}
4734testcase TC_ho_out_of_this_bsc() runs on test_CT {
4735 var MSC_ConnHdlr vc_conn;
4736
4737 f_init(1, true);
4738 f_sleep(1.0);
4739
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004740 f_ctrs_bsc_and_bts_init();
4741
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004742 vc_conn := f_start_handler(refers(f_tc_ho_out_of_this_bsc));
4743 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004744
4745 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
4746 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
4747 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
4748 f_ctrs_bsc_and_bts_add(0, "handover:completed");
4749 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
4750 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:completed");
4751 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004752 f_shutdown_helper();
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004753}
4754
Neels Hofmeyr0aa719b2020-10-12 18:43:09 +00004755private function f_mo_l3_transceive(RSL_DCHAN_PT rsl := RSL,
4756 template (value) RslLinkId link_id := ts_RslLinkID_DCCH(0),
Vadim Yanitskiy2ef6a2f2020-10-08 23:17:32 +07004757 template (present) OCT1 dlci := ?,
Vadim Yanitskiyb93aa432020-10-01 14:23:11 +07004758 octetstring l3 := '0123456789'O)
4759runs on MSC_ConnHdlr {
Neels Hofmeyr43654812020-09-25 01:35:35 +02004760 /* The old lchan and conn should still be active. See that arbitrary L3
4761 * is still going through. */
Neels Hofmeyr0aa719b2020-10-12 18:43:09 +00004762 rsl.send(ts_RSL_DATA_IND(g_chan_nr, link_id, l3));
Neels Hofmeyr43654812020-09-25 01:35:35 +02004763 var template PDU_BSSAP exp_data := {
4764 discriminator := '1'B,
4765 spare := '0000000'B,
Vadim Yanitskiyb93aa432020-10-01 14:23:11 +07004766 dlci := dlci,
4767 lengthIndicator := lengthof(l3),
Neels Hofmeyr43654812020-09-25 01:35:35 +02004768 pdu := {
4769 dtap := l3
4770 }
4771 };
4772 BSSAP.receive(exp_data);
4773 setverdict(pass);
4774}
4775
Neels Hofmeyr0aa719b2020-10-12 18:43:09 +00004776private function f_mt_l3_transceive(RSL_DCHAN_PT rsl := RSL,
4777 template (present) RslLinkId link_id := tr_RslLinkID_DCCH(0),
Vadim Yanitskiy0033a3b2020-10-01 22:21:16 +07004778 template (value) OCT1 dlci := '00'O,
4779 octetstring l3 := '0123456789'O)
4780runs on MSC_ConnHdlr {
4781 BSSAP.send(PDU_BSSAP:{
4782 discriminator := '1'B,
4783 spare := '0000000'B,
4784 dlci := dlci,
4785 lengthIndicator := lengthof(l3),
4786 pdu := {
4787 dtap := l3
4788 }
4789 });
Neels Hofmeyr0aa719b2020-10-12 18:43:09 +00004790 rsl.receive(tr_RSL_DATA_REQ(g_chan_nr, link_id, l3));
Vadim Yanitskiy0033a3b2020-10-01 22:21:16 +07004791 setverdict(pass);
4792}
4793
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004794/* BSC asks for inter-BSC HO, but the MSC decides that it won't happen and
4795 * simply never sends a BSSMAP Handover Command. */
4796private function f_tc_ho_out_fail_no_msc_response(charstring id) runs on MSC_ConnHdlr {
Daniel Willmann3b59eb52018-10-29 15:40:55 +01004797 g_pars := f_gen_test_hdlr_pars();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004798
4799 var PDU_BSSAP ass_req := f_gen_ass_req();
4800 ass_req.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4801 ass_req.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
4802 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4803 f_establish_fully(ass_req, exp_compl);
4804
Neels Hofmeyr666f0432020-07-04 00:53:07 +02004805 f_bts_0_cfg(BSCVTY, {"neighbor lac 99 arfcn 123 bsic any"});
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004806 f_vty_transceive(BSCVTY, "handover any to arfcn 123 bsic any");
4807
4808 BSSAP.receive(tr_BSSMAP_HandoverRequired);
4809
4810 /* osmo-bsc should time out 10 seconds after the handover started.
4811 * Let's give it a bit extra. */
4812 f_sleep(15.0);
4813
Vadim Yanitskiy74ae5eb2020-10-01 22:13:29 +07004814 f_mo_l3_transceive();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004815 f_sleep(1.0);
4816}
4817testcase TC_ho_out_fail_no_msc_response() runs on test_CT {
4818 var MSC_ConnHdlr vc_conn;
4819
4820 f_init(1, true);
4821 f_sleep(1.0);
4822
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004823 f_ctrs_bsc_and_bts_init();
4824
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004825 vc_conn := f_start_handler(refers(f_tc_ho_out_fail_no_msc_response));
4826 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004827
4828 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
4829 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
4830 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
4831 f_ctrs_bsc_and_bts_add(0, "handover:timeout");
4832 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
4833 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:timeout");
4834 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004835 f_shutdown_helper();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004836}
4837
4838/* BSC asks for inter-BSC HO, receives BSSMAP Handover Command, but MS reports
4839 * RR Handover Failure. */
4840private function f_tc_ho_out_fail_rr_ho_failure(charstring id) runs on MSC_ConnHdlr {
Daniel Willmann3b59eb52018-10-29 15:40:55 +01004841 g_pars := f_gen_test_hdlr_pars();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004842
4843 var PDU_BSSAP ass_req := f_gen_ass_req();
4844 ass_req.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4845 ass_req.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
4846 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4847 f_establish_fully(ass_req, exp_compl);
4848
Neels Hofmeyr666f0432020-07-04 00:53:07 +02004849 f_bts_0_cfg(BSCVTY, {"neighbor lac 99 arfcn 123 bsic any"});
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004850 f_vty_transceive(BSCVTY, "handover any to arfcn 123 bsic any");
4851
4852 BSSAP.receive(tr_BSSMAP_HandoverRequired);
4853
4854 f_sleep(0.5);
4855 /* The MSC negotiates Handover Request and Handover Request Ack with
4856 * the other BSS and comes back with a BSSMAP Handover Command
4857 * containing an RR Handover Command coming from the target BSS... */
4858
4859 var PDU_ML3_NW_MS rr_ho_cmd := valueof(ts_RR_HandoverCommand);
4860 log("Remote cell's RR Handover Command passed through as L3 Info: ", rr_ho_cmd);
4861 var octetstring rr_ho_cmd_enc := enc_PDU_ML3_NW_MS(rr_ho_cmd);
4862 log("Remote cell's RR Handover Command passed through as L3 Info, encoded: ", rr_ho_cmd_enc);
4863 BSSAP.send(ts_BSSMAP_HandoverCommand(rr_ho_cmd_enc));
4864
4865 /* expect the Handover Command to go out on RR */
4866 var RSL_Message rsl_ho_cmd
4867 RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, ?)) -> value rsl_ho_cmd;
4868 log("RSL Data Req went out to first BTS: ", rsl_ho_cmd);
4869 var RSL_IE_Body rsl_ho_cmd_l3;
4870 if (not f_rsl_find_ie(rsl_ho_cmd, RSL_IE_L3_INFO, rsl_ho_cmd_l3)) {
4871 log("RSL message contains no L3 Info IE, expected RR Handover Command");
4872 setverdict(fail);
4873 } else {
4874 log("Found L3 Info: ", rsl_ho_cmd_l3);
4875 if (rsl_ho_cmd_l3.l3_info.payload != rr_ho_cmd_enc) {
4876 log("FAIL: the BSC sent out a different L3 Info, not matching the RR Handover Command the other BSS forwarded.");
4877 setverdict(fail);
4878 } else {
4879 log("Success: the BSC sent out the same RR Handover Command the other BSS forwarded.");
4880 setverdict(pass);
4881 }
4882 }
4883
4884 f_sleep(0.2);
4885 f_rsl_send_l3(ts_RRM_HandoverFailure('00'O));
4886
4887 /* Should tell the MSC about the failure */
4888 BSSAP.receive(tr_BSSMAP_HandoverFailure);
4889
4890 f_sleep(1.0);
4891
Vadim Yanitskiy74ae5eb2020-10-01 22:13:29 +07004892 f_mo_l3_transceive();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004893 f_sleep(1.0);
4894
4895 setverdict(pass);
4896 f_sleep(1.0);
4897}
4898testcase TC_ho_out_fail_rr_ho_failure() runs on test_CT {
4899 var MSC_ConnHdlr vc_conn;
4900
4901 f_init(1, true);
4902 f_sleep(1.0);
4903
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004904 f_ctrs_bsc_and_bts_init();
4905
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004906 vc_conn := f_start_handler(refers(f_tc_ho_out_fail_rr_ho_failure));
4907 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004908
4909 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
4910 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
4911 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
4912 f_ctrs_bsc_and_bts_add(0, "handover:failed");
4913 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
4914 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:failed");
4915 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004916 f_shutdown_helper();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004917}
4918
Neels Hofmeyr10f2bfa2019-07-09 19:33:29 +02004919/* BSC asks for inter-BSC-out HO, receives BSSMAP Handover Command, but then no reply is received about HO outcome
4920 * (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 +02004921 * and the lchan is released. */
4922private function f_tc_ho_out_fail_no_result_after_ho_cmd(charstring id) runs on MSC_ConnHdlr {
Daniel Willmann3b59eb52018-10-29 15:40:55 +01004923 g_pars := f_gen_test_hdlr_pars();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004924
4925 var PDU_BSSAP ass_req := f_gen_ass_req();
4926 ass_req.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4927 ass_req.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
4928 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4929 f_establish_fully(ass_req, exp_compl);
4930
Neels Hofmeyr666f0432020-07-04 00:53:07 +02004931 f_bts_0_cfg(BSCVTY, {"neighbor lac 99 arfcn 123 bsic any"});
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004932 f_vty_transceive(BSCVTY, "handover any to arfcn 123 bsic any");
4933
4934 BSSAP.receive(tr_BSSMAP_HandoverRequired);
4935
4936 f_sleep(0.5);
4937 /* The MSC negotiates Handover Request and Handover Request Ack with
4938 * the other BSS and comes back with a BSSMAP Handover Command
4939 * containing an RR Handover Command coming from the target BSS... */
4940
4941 var PDU_ML3_NW_MS rr_ho_cmd := valueof(ts_RR_HandoverCommand);
4942 log("Remote cell's RR Handover Command passed through as L3 Info: ", rr_ho_cmd);
4943 var octetstring rr_ho_cmd_enc := enc_PDU_ML3_NW_MS(rr_ho_cmd);
4944 log("Remote cell's RR Handover Command passed through as L3 Info, encoded: ", rr_ho_cmd_enc);
4945 BSSAP.send(ts_BSSMAP_HandoverCommand(rr_ho_cmd_enc));
4946
4947 /* expect the Handover Command to go out on RR */
4948 var RSL_Message rsl_ho_cmd
4949 RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, ?)) -> value rsl_ho_cmd;
4950 log("RSL Data Req went out to first BTS: ", rsl_ho_cmd);
4951 var RSL_IE_Body rsl_ho_cmd_l3;
4952 if (not f_rsl_find_ie(rsl_ho_cmd, RSL_IE_L3_INFO, rsl_ho_cmd_l3)) {
4953 log("RSL message contains no L3 Info IE, expected RR Handover Command");
4954 setverdict(fail);
4955 } else {
4956 log("Found L3 Info: ", rsl_ho_cmd_l3);
4957 if (rsl_ho_cmd_l3.l3_info.payload != rr_ho_cmd_enc) {
4958 log("FAIL: the BSC sent out a different L3 Info, not matching the RR Handover Command the other BSS forwarded.");
4959 setverdict(fail);
4960 } else {
4961 log("Success: the BSC sent out the same RR Handover Command the other BSS forwarded.");
4962 setverdict(pass);
4963 }
4964 }
4965
Neels Hofmeyr10f2bfa2019-07-09 19:33:29 +02004966 /* We get neither success nor failure report from the remote BSS. Eventually T8 times out and we run into 3GPP
4967 * TS 48.008 3.1.5.3.3 "Abnormal Conditions": Clear Request should go to the MSC, and RR should be released
4968 * after Clear Command */
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004969
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02004970 var PDU_BSSAP rx_clear_request;
Neels Hofmeyre1797aa2019-07-09 19:34:04 +02004971 BSSAP.receive(tr_BSSMAP_ClearRequest) -> value rx_clear_request;
4972 log("Got BSSMAP Clear Request");
4973 /* Instruct BSC to clear channel */
4974 var BssmapCause cause := bit2int(rx_clear_request.pdu.bssmap.clearRequest.cause.causeValue);
4975 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
4976
4977 var MgcpCommand mgcp;
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004978 interleave {
Neels Hofmeyr861a4c12018-11-07 01:23:17 +01004979 [] RSL.receive(tr_RSL_DEACT_SACCH(g_chan_nr)) {
4980 log("Got Deact SACCH");
4981 }
Harald Welte924b6ea2019-02-04 01:05:34 +01004982 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_RELEASE)) {
Neels Hofmeyr211169d2018-11-07 00:37:29 +01004983 log("Got RR Release");
4984 }
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004985 [] RSL.receive(tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL)) {
4986 log("Got RF Chan Rel");
4987 RSL.send(ts_RSL_RF_CHAN_REL_ACK(g_chan_nr));
4988 }
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004989 }
4990
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02004991 f_expect_dlcx_conns();
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004992
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004993 setverdict(pass);
4994 f_sleep(1.0);
4995}
Neels Hofmeyrd8a602c2019-07-09 19:46:01 +02004996testcase TC_ho_out_fail_no_result_after_ho_cmd() runs on test_CT {
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004997 var MSC_ConnHdlr vc_conn;
4998
4999 f_init(1, true);
5000 f_sleep(1.0);
5001
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005002 f_ctrs_bsc_and_bts_init();
5003
Neels Hofmeyrd8a602c2019-07-09 19:46:01 +02005004 vc_conn := f_start_handler(refers(f_tc_ho_out_fail_no_result_after_ho_cmd));
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005005 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005006
5007 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5008 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5009 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5010 f_ctrs_bsc_and_bts_add(0, "handover:timeout");
5011 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
5012 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:timeout");
5013 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005014 f_shutdown_helper();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005015}
5016
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005017private function f_tc_ho_into_this_bsc(charstring id) runs on MSC_ConnHdlr {
5018 /* Hack: the proper way would be to wait for the BSSMAP Handover Request ACK and extract the
5019 * actual assigned chan_nr from its L3 (RR Handover Command) message. But osmo-bsc starts acting
5020 * on the lchan even before we get a chance to evaluate the BSSMAP Handover Request ACK. So we
5021 * need to assume that osmo-bsc will activate TS 1 and already set up this lchan's RSL emulation
5022 * before we get started. */
5023 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
5024 f_rslem_register(0, new_chan_nr);
5025 g_chan_nr := new_chan_nr;
5026 f_sleep(1.0);
5027
5028 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
5029 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
5030 activate(as_Media());
5031
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005032 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Pau Espin Pedrol07866632020-09-03 19:10:55 +02005033 f_gen_handover_req(aoip_tla := g_pars.host_aoip_tla)));
Harald Welte6811d102019-04-14 22:23:14 +02005034 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005035
5036 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
5037
5038 var PDU_BSSAP rx_bssap;
5039 var octetstring ho_command_str;
5040
5041 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
Pau Espin Pedrol76ba5412019-06-10 11:00:33 +02005042
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005043 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
5044 log("Received L3 Info in HO Request Ack: ", ho_command_str);
5045 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
5046 log("L3 Info in HO Request Ack is ", ho_command);
5047
5048 var GsmArfcn arfcn;
5049 var RslChannelNr actual_new_chan_nr;
5050 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
5051 actual_new_chan_nr, arfcn);
5052
5053 if (actual_new_chan_nr != new_chan_nr) {
5054 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
5055 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
5056 setverdict(fail);
5057 return;
5058 }
5059 log("Handover Command chan_nr is", actual_new_chan_nr);
5060
5061 /* Now the MSC forwards the RR Handover Command to the other BSC, which
5062 * tells the MS to handover to the new lchan. Here comes the new MS on
5063 * the new lchan with a Handover RACH: */
5064
5065 /* send handover detect */
5066
5067 RSL.send(ts_RSL_HANDO_DET(new_chan_nr));
5068
5069 BSSAP.receive(tr_BSSMAP_HandoverDetect);
5070
5071 /* send handover complete over the new channel */
5072
5073 var PDU_ML3_MS_NW l3_tx := valueof(ts_RRM_HandoverComplete('00'O));
5074 RSL.send(ts_RSL_EST_IND(new_chan_nr, valueof(ts_RslLinkID_DCCH(0)),
5075 enc_PDU_ML3_MS_NW(l3_tx)));
5076
5077 BSSAP.receive(tr_BSSMAP_HandoverComplete);
5078 setverdict(pass);
5079}
Pau Espin Pedrol07866632020-09-03 19:10:55 +02005080function f_tc_ho_into_this_bsc_main(TestHdlrParams pars) runs on test_CT {
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005081 var MSC_ConnHdlr vc_conn;
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005082
5083 f_init(1, true);
5084 f_sleep(1.0);
5085
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005086 f_ctrs_bsc_and_bts_init();
5087
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005088 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
5089 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005090
5091 vc_conn := f_start_handler(refers(f_tc_ho_into_this_bsc), pars);
5092 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005093
5094 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5095 f_ctrs_bsc_and_bts_add(0, "handover:completed");
5096 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:attempted");
5097 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:completed");
5098 f_ctrs_bsc_and_bts_verify();
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01005099 f_shutdown_helper();
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005100}
5101
Pau Espin Pedrol07866632020-09-03 19:10:55 +02005102testcase TC_ho_into_this_bsc() runs on test_CT {
5103 var TestHdlrParams pars := f_gen_test_hdlr_pars();
5104 f_tc_ho_into_this_bsc_main(pars);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005105 f_shutdown_helper();
Pau Espin Pedrol07866632020-09-03 19:10:55 +02005106}
5107
5108testcase TC_ho_into_this_bsc_tla_v6() runs on test_CT {
5109 var TestHdlrParams pars := f_gen_test_hdlr_pars();
5110 pars.host_aoip_tla := "::6";
5111 f_tc_ho_into_this_bsc_main(pars);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005112 f_shutdown_helper();
Pau Espin Pedrol07866632020-09-03 19:10:55 +02005113}
5114
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005115private function f_tc_ho_in_fail_msc_clears(charstring id) runs on MSC_ConnHdlr {
5116 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
5117 f_rslem_register(0, new_chan_nr);
5118 g_chan_nr := new_chan_nr;
5119 f_sleep(1.0);
5120
5121 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
5122 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
5123 activate(as_Media());
5124
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005125 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005126 f_gen_handover_req()));
Harald Welte6811d102019-04-14 22:23:14 +02005127 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005128
5129 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
5130
5131 var PDU_BSSAP rx_bssap;
5132 var octetstring ho_command_str;
5133
5134 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
5135
5136 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
5137 log("Received L3 Info in HO Request Ack: ", ho_command_str);
5138 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
5139 log("L3 Info in HO Request Ack is ", ho_command);
5140
5141 var GsmArfcn arfcn;
5142 var RslChannelNr actual_new_chan_nr;
5143 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
5144 actual_new_chan_nr, arfcn);
5145
5146 if (actual_new_chan_nr != new_chan_nr) {
5147 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
5148 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
5149 setverdict(fail);
5150 return;
5151 }
5152 log("Handover Command chan_nr is", actual_new_chan_nr);
5153
Neels Hofmeyr61ca08d2019-05-06 23:52:22 +02005154 /* For deterministic test results, give some time for the MGW endpoint to be configured */
5155 f_sleep(1.0);
5156
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005157 /* Now the MSC forwards the RR Handover Command to the other BSC, which
5158 * tells the MS to handover to the new lchan. In this case, the MS
5159 * reports a Handover Failure to the old BSS, which forwards a BSSMAP
5160 * Handover Failure to the MSC. The procedure according to 3GPP TS
5161 * 48.008 3.1.5.3.2 "Handover Failure" is then that the MSC sends a
5162 * BSSMAP Clear Command: */
5163
5164 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_RADIO_INTERFACE_FAILURE_REVERSION;
5165 var BssmapCause cause := enum2int(cause_val);
5166 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
5167
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02005168 f_expect_dlcx_conns();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005169 setverdict(pass);
5170 f_sleep(1.0);
5171
5172 setverdict(pass);
5173}
5174testcase TC_ho_in_fail_msc_clears() runs on test_CT {
5175 var MSC_ConnHdlr vc_conn;
5176 var TestHdlrParams pars := f_gen_test_hdlr_pars();
5177
5178 f_init(1, true);
5179 f_sleep(1.0);
5180
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005181 f_ctrs_bsc_and_bts_init();
5182
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005183 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
5184 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005185
5186 vc_conn := f_start_handler(refers(f_tc_ho_in_fail_msc_clears), pars);
5187 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005188
5189 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5190 f_ctrs_bsc_and_bts_add(0, "handover:stopped");
5191 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:attempted");
5192 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:stopped");
5193 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005194 f_shutdown_helper();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005195}
5196
5197private function f_tc_ho_in_fail_msc_clears_after_ho_detect(charstring id) runs on MSC_ConnHdlr {
5198 /* Hack: the proper way would be to wait for the BSSMAP Handover Request ACK and extract the
5199 * actual assigned chan_nr from its L3 (RR Handover Command) message. But osmo-bsc starts acting
5200 * on the lchan even before we get a chance to evaluate the BSSMAP Handover Request ACK. So we
5201 * need to assume that osmo-bsc will activate TS 1 and already set up this lchan's RSL emulation
5202 * before we get started. */
5203 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
5204 f_rslem_register(0, new_chan_nr);
5205 g_chan_nr := new_chan_nr;
5206 f_sleep(1.0);
5207
5208 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
5209 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
5210 activate(as_Media());
5211
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005212 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005213 f_gen_handover_req()));
Harald Welte6811d102019-04-14 22:23:14 +02005214 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005215
5216 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
5217
5218 var PDU_BSSAP rx_bssap;
5219 var octetstring ho_command_str;
5220
5221 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
5222
5223 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
5224 log("Received L3 Info in HO Request Ack: ", ho_command_str);
5225 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
5226 log("L3 Info in HO Request Ack is ", ho_command);
5227
5228 var GsmArfcn arfcn;
5229 var RslChannelNr actual_new_chan_nr;
5230 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
5231 actual_new_chan_nr, arfcn);
5232
5233 if (actual_new_chan_nr != new_chan_nr) {
5234 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
5235 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
5236 setverdict(fail);
5237 return;
5238 }
5239 log("Handover Command chan_nr is", actual_new_chan_nr);
5240
5241 /* Now the MSC forwards the RR Handover Command to the other BSC, which
5242 * tells the MS to handover to the new lchan. Here comes the new MS on
5243 * the new lchan with a Handover RACH: */
5244
5245 /* send handover detect */
5246
5247 RSL.send(ts_RSL_HANDO_DET(new_chan_nr));
5248
5249 BSSAP.receive(tr_BSSMAP_HandoverDetect);
5250
5251 /* The MSC chooses to clear the connection now, maybe we got the
5252 * Handover RACH on the new cell but the MS still signaled Handover
5253 * Failure to the old BSS? */
5254
5255 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_RADIO_INTERFACE_FAILURE_REVERSION;
5256 var BssmapCause cause := enum2int(cause_val);
5257 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
5258
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02005259 f_expect_dlcx_conns();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005260 f_sleep(1.0);
5261}
5262testcase TC_ho_in_fail_msc_clears_after_ho_detect() runs on test_CT {
5263 var MSC_ConnHdlr vc_conn;
5264 var TestHdlrParams pars := f_gen_test_hdlr_pars();
5265
5266 f_init(1, true);
5267 f_sleep(1.0);
5268
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005269 f_ctrs_bsc_and_bts_init();
5270
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005271 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
5272 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005273
5274 vc_conn := f_start_handler(refers(f_tc_ho_in_fail_msc_clears_after_ho_detect), pars);
5275 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005276
5277 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5278 f_ctrs_bsc_and_bts_add(0, "handover:stopped");
5279 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:attempted");
5280 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:stopped");
5281 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005282 f_shutdown_helper();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005283}
5284
5285/* The new BSS's lchan times out before the MSC decides that handover failed. */
5286private function f_tc_ho_in_fail_no_detect(charstring id) runs on MSC_ConnHdlr {
5287 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
5288 f_rslem_register(0, new_chan_nr);
5289 g_chan_nr := new_chan_nr;
5290 f_sleep(1.0);
5291
5292 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
5293 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
5294 activate(as_Media());
5295
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005296 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005297 f_gen_handover_req()));
Harald Welte6811d102019-04-14 22:23:14 +02005298 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005299
5300 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
5301
5302 var PDU_BSSAP rx_bssap;
5303 var octetstring ho_command_str;
5304
5305 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
5306
5307 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
5308 log("Received L3 Info in HO Request Ack: ", ho_command_str);
5309 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
5310 log("L3 Info in HO Request Ack is ", ho_command);
5311
5312 var GsmArfcn arfcn;
5313 var RslChannelNr actual_new_chan_nr;
5314 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
5315 actual_new_chan_nr, arfcn);
5316
5317 if (actual_new_chan_nr != new_chan_nr) {
5318 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
5319 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
5320 setverdict(fail);
5321 return;
5322 }
5323 log("Handover Command chan_nr is", actual_new_chan_nr);
5324
5325 /* Now the MSC forwards the RR Handover Command to the other BSC, which
5326 * tells the MS to handover to the new lchan. But the MS never shows up
5327 * on the new lchan. */
5328
5329 BSSAP.receive(tr_BSSMAP_HandoverFailure);
5330
5331 /* Did osmo-bsc also send a Clear Request? */
5332 timer T := 0.5;
5333 T.start;
5334 alt {
5335 [] BSSAP.receive(tr_BSSMAP_ClearRequest);
5336 [] T.timeout { }
5337 }
5338
5339 /* MSC plays along with a Clear Command (no matter whether osmo-bsc
5340 * asked for it, this is a Handover Failure after all). */
5341
5342 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_RADIO_INTERFACE_FAILURE_REVERSION;
5343 var BssmapCause cause := enum2int(cause_val);
5344 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
5345
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02005346 f_expect_dlcx_conns();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005347 f_sleep(1.0);
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005348}
5349testcase TC_ho_in_fail_no_detect() runs on test_CT {
5350 var MSC_ConnHdlr vc_conn;
5351 var TestHdlrParams pars := f_gen_test_hdlr_pars();
5352
5353 f_init(1, true);
5354 f_sleep(1.0);
5355
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005356 f_ctrs_bsc_and_bts_init();
5357
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005358 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
5359 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005360
5361 vc_conn := f_start_handler(refers(f_tc_ho_in_fail_no_detect), pars);
5362 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005363
5364 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5365 f_ctrs_bsc_and_bts_add(0, "handover:error");
5366 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:attempted");
5367 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:error");
5368 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005369 f_shutdown_helper();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005370}
5371
5372/* Same as f_tc_ho_in_fail_no_detect, but MSC fails to send a Clear Command */
5373private function f_tc_ho_in_fail_no_detect2(charstring id) runs on MSC_ConnHdlr {
5374 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
5375 f_rslem_register(0, new_chan_nr);
5376 g_chan_nr := new_chan_nr;
5377 f_sleep(1.0);
5378
5379 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
5380 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
5381 activate(as_Media());
5382
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005383 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005384 f_gen_handover_req()));
Harald Welte6811d102019-04-14 22:23:14 +02005385 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005386
5387 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
5388
5389 var PDU_BSSAP rx_bssap;
5390 var octetstring ho_command_str;
5391
5392 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
5393
5394 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
5395 log("Received L3 Info in HO Request Ack: ", ho_command_str);
5396 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
5397 log("L3 Info in HO Request Ack is ", ho_command);
5398
5399 var GsmArfcn arfcn;
5400 var RslChannelNr actual_new_chan_nr;
5401 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
5402 actual_new_chan_nr, arfcn);
5403
5404 if (actual_new_chan_nr != new_chan_nr) {
5405 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
5406 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
5407 setverdict(fail);
5408 return;
5409 }
5410 log("Handover Command chan_nr is", actual_new_chan_nr);
5411
5412 /* Now the MSC forwards the RR Handover Command to the other BSC, which
5413 * tells the MS to handover to the new lchan. But the MS never shows up
5414 * on the new lchan. */
5415
5416 BSSAP.receive(tr_BSSMAP_HandoverFailure);
5417
5418 /* MSC plays dumb and sends no Clear Command */
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005419 var PDU_BSSAP rx_clear_request;
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02005420
5421 BSSAP.receive(tr_BSSMAP_ClearRequest) -> value rx_clear_request {
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005422 var BssmapCause cause := bit2int(rx_clear_request.pdu.bssmap.clearRequest.cause.causeValue);
5423 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
5424 };
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02005425 f_expect_dlcx_conns();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005426 f_sleep(1.0);
5427}
5428testcase TC_ho_in_fail_no_detect2() runs on test_CT {
5429 var MSC_ConnHdlr vc_conn;
5430 var TestHdlrParams pars := f_gen_test_hdlr_pars();
5431
5432 f_init(1, true);
5433 f_sleep(1.0);
5434
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005435 f_ctrs_bsc_and_bts_init();
5436
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005437 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
5438 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005439
5440 vc_conn := f_start_handler(refers(f_tc_ho_in_fail_no_detect2), pars);
5441 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005442
5443 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5444 f_ctrs_bsc_and_bts_add(0, "handover:error");
5445 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:attempted");
5446 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:error");
5447 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005448 f_shutdown_helper();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005449}
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005450
Neels Hofmeyr91401012019-07-11 00:42:35 +02005451type record of charstring Commands;
5452
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005453private function f_bts_0_cfg(TELNETasp_PT pt, Commands cmds := {})
Neels Hofmeyr91401012019-07-11 00:42:35 +02005454{
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005455 f_vty_enter_cfg_bts(pt, 0);
Neels Hofmeyr91401012019-07-11 00:42:35 +02005456 for (var integer i := 0; i < sizeof(cmds); i := i+1) {
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005457 f_vty_transceive(pt, cmds[i]);
Neels Hofmeyr91401012019-07-11 00:42:35 +02005458 }
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005459 f_vty_transceive(pt, "end");
Neels Hofmeyr91401012019-07-11 00:42:35 +02005460}
5461
Pau Espin Pedrolc675b612020-01-09 19:55:40 +01005462private function f_cs7_inst_0_cfg(TELNETasp_PT pt, Commands cmds := {})
5463{
5464 f_vty_enter_cfg_cs7_inst(pt, 0);
5465 for (var integer i := 0; i < sizeof(cmds); i := i+1) {
5466 f_vty_transceive(pt, cmds[i]);
5467 }
5468 f_vty_transceive(pt, "end");
5469}
5470
Neels Hofmeyr91401012019-07-11 00:42:35 +02005471private function f_probe_for_handover(charstring log_label,
5472 charstring log_descr,
5473 charstring handover_vty_cmd,
5474 boolean expect_handover,
5475 boolean is_inter_bsc_handover := false)
5476runs on MSC_ConnHdlr
5477{
Neels Hofmeyrb3fc8982020-05-11 00:16:42 +02005478 /* We're going to thwart any and all handover attempts, just be ready to handle (and ignore) handover target
5479 * lchans to be established on bts 1 or bts 2. */
5480 f_rslem_suspend(RSL1_PROC);
5481 f_rslem_suspend(RSL2_PROC);
5482
Neels Hofmeyr91401012019-07-11 00:42:35 +02005483 var RSL_Message rsl;
5484
5485 var charstring log_msg := " (expecting handover)"
5486 if (not expect_handover) {
5487 log_msg := " (expecting NO handover)";
5488 }
5489 log("f_probe_for_handover starting: " & log_label & ": " & log_descr & log_msg);
5490 f_vty_transceive(BSCVTY, handover_vty_cmd);
5491
Neels Hofmeyr91401012019-07-11 00:42:35 +02005492 timer T := 2.0;
5493 T.start;
5494
5495 alt {
5496 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr)) -> value rsl {
5497 var PDU_ML3_NW_MS l3 := dec_PDU_ML3_NW_MS(rsl.ies[2].body.l3_info.payload);
5498 log("Rx L3 from net: ", l3);
5499 if (ischosen(l3.msgs.rrm.handoverCommand)) {
5500 var RslChannelNr new_chan_nr;
5501 var GsmArfcn arfcn;
5502 f_ChDesc2RslChanNr(l3.msgs.rrm.handoverCommand.channelDescription2,
5503 new_chan_nr, arfcn);
5504 log("Handover to new chan ", new_chan_nr, " on ARFCN ", arfcn);
5505 log(l3.msgs.rrm.handoverCommand);
5506
5507 /* Need to register for new lchan on new BTS -- it's either bts 1 or bts 2. It doesn't really
5508 * matter on which BTS it really is, we're not going to follow through an entire handover
5509 * anyway. */
5510 f_rslem_register(0, new_chan_nr, RSL1_PROC);
5511 f_rslem_resume(RSL1_PROC);
5512 f_rslem_register(0, new_chan_nr, RSL2_PROC);
5513 f_rslem_resume(RSL2_PROC);
5514
5515 if (expect_handover and not is_inter_bsc_handover) {
5516 setverdict(pass);
5517 log("f_probe_for_handover(" & log_label & "): Got RSL Handover Command as expected.");
5518 } else {
5519 setverdict(fail, "f_probe_for_handover(" & log_label & "): Expected none, but got RSL Handover Command. "
5520 & log_label & ": " & log_descr);
5521 }
5522
5523 log("f_probe_for_handover(" & log_label & "): Ending the test: Handover Failure stops the procedure.");
5524 /* osmo-bsc has triggered Handover. That's all we need to know for this test, reply with
5525 * Handover Failure. */
5526 f_rsl_send_l3(ts_RRM_HandoverFailure('00'O));
5527
5528 /* target BTS is told to release lchan again; don't care which BTS nor what messages. */
5529 f_sleep(0.5);
5530 RSL1.clear;
5531 RSL2.clear;
5532 log("f_probe_for_handover(" & log_label & "): done (got RSL Handover Command)");
5533 break;
5534 } else {
5535 repeat;
5536 }
5537 }
5538 [] BSSAP.receive(tr_BSSMAP_HandoverRequired) {
5539 if (expect_handover and is_inter_bsc_handover) {
5540 setverdict(pass);
5541 log("f_probe_for_handover(" & log_label & "): Got BSSMAP Handover Required as expected.");
5542 } else {
5543 setverdict(fail, "f_probe_for_handover(" & log_label & "): Expected none, but got BSSMAP Handover Required. "
5544 & log_label & ": " & log_descr);
5545 }
5546
5547 log("f_probe_for_handover(" & log_label & "): done (got BSSMAP Handover Required)");
5548
5549 /* Note: f_tc_ho_neighbor_config_start() sets T7, the timeout for BSSMAP Handover Required, to
5550 * 1 second. There is no legal way to quickly abort a handover after a BSSMAP Handover Required,
5551 * setting a short timeout and waiting is the only way. */
5552 log("f_probe_for_handover(" & log_label & "): waiting for inter-BSC HO to time out...");
5553 f_sleep(1.5);
5554 log("f_probe_for_handover(" & log_label & "): ...done");
5555
5556 break;
5557 }
5558 [] T.timeout {
5559 if (expect_handover) {
5560 setverdict(fail, "f_probe_for_handover(" & log_label & "): Expected Handover, but got none. "
5561 & log_label & ": " & log_descr);
5562 } else {
5563 setverdict(pass);
5564 log("f_probe_for_handover(" & log_label & "): Got no Handover, as expected.");
5565 }
5566 log("f_probe_for_handover(" & log_label & "): done (got no Handover)");
5567 break;
5568 }
5569 }
5570
5571 f_rslem_resume(RSL1_PROC);
5572 f_rslem_resume(RSL2_PROC);
5573 f_sleep(3.0);
5574 RSL.clear;
5575
5576 log("f_probe_for_handover(" & log_label & "): done clearing");
5577}
5578
5579/* Test the effect of various neighbor configuration scenarios:
5580 *
5581 * To avoid complexity, block off any actual handover operation, and always remain on the lchan at bts 0.
5582 * Reconfigure the neighbors for bts 0, trigger a Handover, and probe whether osmo-bsc does or doesn't start HO.
5583 */
5584private function f_tc_ho_neighbor_config_start() runs on MSC_ConnHdlr {
5585 g_pars := f_gen_test_hdlr_pars();
5586 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
5587 var PDU_BSSAP ass_cmd := f_gen_ass_req();
5588 const OCT8 kc := '0001020304050607'O;
5589
5590 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
5591 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
5592
5593 /* Establish lchan at bts 0 */
5594 f_establish_fully(ass_cmd, exp_compl);
5595
5596 /* Shorten the inter-BSC Handover timeout, to not wait so long for inter-BSC Handovers */
5597 f_vty_enter_cfg_network(BSCVTY);
5598 f_vty_transceive(BSCVTY, "timer T7 1");
5599 f_vty_transceive(BSCVTY, "end");
5600}
5601
5602private function f_tc_ho_neighbor_config_1(charstring id) runs on MSC_ConnHdlr {
5603 f_tc_ho_neighbor_config_start();
5604
5605 /*
5606 * bts 0 ARFCN 871 BSIC 10
5607 * bts 1 ARFCN 871 BSIC 11
5608 * bts 2 ARFCN 871 BSIC 12
5609 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
5610 */
5611
5612 log("f_tc_ho_neighbor_config: 1. No 'neighbor' config");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005613 f_bts_0_cfg(BSCVTY, {"no neighbors"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02005614 f_probe_for_handover("1.a", "HO to bts 1 works, implicitly listed as neighbor (legacy behavior when none are configured)",
5615 "handover any to arfcn 871 bsic 11",
5616 true);
5617
5618 f_probe_for_handover("1.b", "HO to unknown cell does not start",
5619 "handover any to arfcn 13 bsic 39",
5620 false);
5621
5622 f_probe_for_handover("1.c", "HO to 871-12 is ambiguous = error",
5623 "handover any to arfcn 871 bsic 12",
5624 false);
5625
5626 f_probe_for_handover("1.d", "HO to 871-11 still works (verify that this test properly cleans up)",
5627 "handover any to arfcn 871 bsic 11",
5628 true);
5629}
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005630testcase TC_ho_neighbor_config_1() runs on test_CT {
5631 var MSC_ConnHdlr vc_conn;
5632 f_init(3, true, guard_timeout := 60.0);
5633 f_sleep(1.0);
5634 f_ctrs_bsc_and_bts_init();
5635 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_1));
5636 vc_conn.done;
5637
5638 /* f_tc_ho_neighbor_config_start() */
5639 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5640 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5641
5642 /* 1.a */
5643 /* "failed" means a handover was triggered and started (which is all this test aims for) and the test ended the
5644 * handover quickly by sending a Handover Failure message. */
5645 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5646 f_ctrs_bsc_and_bts_add(0, "handover:failed");
5647 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
5648 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:failed");
5649
5650 /* 1.b */
5651 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5652 f_ctrs_bsc_and_bts_add(0, "handover:error");
5653
5654 /* 1.c */
5655 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5656 f_ctrs_bsc_and_bts_add(0, "handover:error");
5657
5658 /* 1.d */
5659 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5660 f_ctrs_bsc_and_bts_add(0, "handover:failed");
5661 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
5662 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:failed");
5663
5664 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005665 f_shutdown_helper();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005666}
5667
Neels Hofmeyr91401012019-07-11 00:42:35 +02005668private function f_tc_ho_neighbor_config_2(charstring id) runs on MSC_ConnHdlr {
5669 f_tc_ho_neighbor_config_start();
5670
5671 /*
5672 * bts 0 ARFCN 871 BSIC 10
5673 * bts 1 ARFCN 871 BSIC 11
5674 * bts 2 ARFCN 871 BSIC 12
5675 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
5676 */
5677
5678 log("f_tc_ho_neighbor_config: 2. explicit local neighbor: 'neighbor bts 1'");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005679 f_bts_0_cfg(BSCVTY, {"neighbor bts 1"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02005680 f_sleep(0.5);
5681
5682 f_probe_for_handover("2.a", "HO to bts 1 works, explicitly listed as neighbor",
5683 "handover any to arfcn 871 bsic 11",
5684 true);
5685
5686 f_probe_for_handover("2.b", "HO to bts 2 doesn't work, not listed as neighbor",
5687 "handover any to arfcn 871 bsic 12",
5688 false);
5689}
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005690testcase TC_ho_neighbor_config_2() runs on test_CT {
5691 var MSC_ConnHdlr vc_conn;
5692 f_init(3, true, guard_timeout := 50.0);
5693 f_sleep(1.0);
5694 f_ctrs_bsc_and_bts_init();
5695 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_2));
5696 vc_conn.done;
5697
5698 /* f_tc_ho_neighbor_config_start() */
5699 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5700 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5701
5702 /* 2.a */
5703 /* "failed" means a handover was triggered and started (which is all this test aims for) and the test ended the
5704 * handover quickly by sending a Handover Failure message. */
5705 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5706 f_ctrs_bsc_and_bts_add(0, "handover:failed");
5707 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
5708 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:failed");
5709
5710 /* 2.b */
5711 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5712 f_ctrs_bsc_and_bts_add(0, "handover:error");
5713
5714 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005715 f_shutdown_helper();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005716}
5717
Neels Hofmeyr91401012019-07-11 00:42:35 +02005718private function f_tc_ho_neighbor_config_3(charstring id) runs on MSC_ConnHdlr {
5719 f_tc_ho_neighbor_config_start();
5720
5721 /*
5722 * bts 0 ARFCN 871 BSIC 10
5723 * bts 1 ARFCN 871 BSIC 11
5724 * bts 2 ARFCN 871 BSIC 12
5725 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
5726 */
5727
5728 log("f_tc_ho_neighbor_config: 3. explicit local neighbor: 'neighbor bts 2'");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005729 f_bts_0_cfg(BSCVTY, {"no neighbors", "neighbor bts 2"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02005730 f_sleep(0.5);
5731
5732 f_probe_for_handover("3.a", "HO to bts 1 doesn't work, not listed as neighbor",
5733 "handover any to arfcn 871 bsic 11",
5734 false);
5735 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",
5736 "handover any to arfcn 871 bsic 12",
5737 true);
5738}
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005739testcase TC_ho_neighbor_config_3() runs on test_CT {
5740 var MSC_ConnHdlr vc_conn;
5741 f_init(3, true, guard_timeout := 50.0);
5742 f_sleep(1.0);
5743 f_ctrs_bsc_and_bts_init();
5744 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_3));
5745 vc_conn.done;
5746
5747 /* f_tc_ho_neighbor_config_start() */
5748 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5749 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5750
5751 /* 3.a */
5752 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5753 f_ctrs_bsc_and_bts_add(0, "handover:error");
5754
5755 /* 3.b */
5756 /* "failed" means a handover was triggered and started (which is all this test aims for) and the test ended the
5757 * handover quickly by sending a Handover Failure message. */
5758 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5759 f_ctrs_bsc_and_bts_add(0, "handover:failed");
5760 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
5761 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:failed");
5762
5763 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005764 f_shutdown_helper();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005765}
5766
Neels Hofmeyr91401012019-07-11 00:42:35 +02005767private function f_tc_ho_neighbor_config_4(charstring id) runs on MSC_ConnHdlr {
5768 f_tc_ho_neighbor_config_start();
5769
5770 /*
5771 * bts 0 ARFCN 871 BSIC 10
5772 * bts 1 ARFCN 871 BSIC 11
5773 * bts 2 ARFCN 871 BSIC 12
5774 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
5775 */
5776
5777 log("f_tc_ho_neighbor_config: 4. explicit remote neighbor: 'neighbor lac 99 arfcn 123 bsic 45'");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005778 f_bts_0_cfg(BSCVTY, {"no neighbors", "neighbor lac 99 arfcn 123 bsic 45"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02005779 f_sleep(0.5);
5780
5781 f_probe_for_handover("4.a", "HO to bts 1 doesn't work, not listed as neighbor",
5782 "handover any to arfcn 871 bsic 11",
5783 false);
5784 f_probe_for_handover("4.b", "HO to bts 2 doesn't work, not listed as neighbor",
5785 "handover any to arfcn 871 bsic 12",
5786 false);
5787 f_probe_for_handover("4.c", "HO to 123-45 triggers inter-BSC HO",
5788 "handover any to arfcn 123 bsic 45",
5789 true, true);
5790}
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005791testcase TC_ho_neighbor_config_4() runs on test_CT {
5792 var MSC_ConnHdlr vc_conn;
5793 f_init(3, true, guard_timeout := 50.0);
5794 f_sleep(1.0);
5795 f_ctrs_bsc_and_bts_init();
5796 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_4));
5797 vc_conn.done;
5798
5799 /* f_tc_ho_neighbor_config_start() */
5800 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5801 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5802
5803 /* 4.a */
5804 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5805 f_ctrs_bsc_and_bts_add(0, "handover:error");
5806
5807 /* 4.b */
5808 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5809 f_ctrs_bsc_and_bts_add(0, "handover:error");
5810
5811 /* 4.c */
5812 /* "timeout" means a handover was triggered and started (which is all this test aims for) and the test ended the
5813 * handover quickly by timing out after the Handover Required message */
5814 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5815 f_ctrs_bsc_and_bts_add(0, "handover:timeout");
5816 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
5817 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:timeout");
5818
5819 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005820 f_shutdown_helper();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005821}
5822
Neels Hofmeyr91401012019-07-11 00:42:35 +02005823private function f_tc_ho_neighbor_config_5(charstring id) runs on MSC_ConnHdlr {
5824 f_tc_ho_neighbor_config_start();
5825
5826 /*
5827 * bts 0 ARFCN 871 BSIC 10
5828 * bts 1 ARFCN 871 BSIC 11
5829 * bts 2 ARFCN 871 BSIC 12
5830 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
5831 */
5832
5833 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 +02005834 f_bts_0_cfg(BSCVTY, {"no neighbors", "neighbor lac 99 arfcn 871 bsic 12"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02005835 f_sleep(0.5);
5836
5837 f_probe_for_handover("5.a", "HO to 871-12 triggers inter-BSC HO (ignoring local cells with same ARFCN+BSIC)",
5838 "handover any to arfcn 871 bsic 12",
5839 true, true);
5840}
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005841testcase TC_ho_neighbor_config_5() runs on test_CT {
5842 var MSC_ConnHdlr vc_conn;
5843 f_init(3, true);
5844 f_sleep(1.0);
5845 f_ctrs_bsc_and_bts_init();
5846 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_5));
5847 vc_conn.done;
5848
5849 /* f_tc_ho_neighbor_config_start() */
5850 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5851 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5852
5853 /* 5 */
5854 /* "timeout" means a handover was triggered and started (which is all this test aims for) and the test ended the
5855 * handover quickly by timing out after the Handover Required message */
5856 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5857 f_ctrs_bsc_and_bts_add(0, "handover:timeout");
5858 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
5859 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:timeout");
5860
5861 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005862 f_shutdown_helper();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005863}
5864
Neels Hofmeyr91401012019-07-11 00:42:35 +02005865private function f_tc_ho_neighbor_config_6(charstring id) runs on MSC_ConnHdlr {
5866 f_tc_ho_neighbor_config_start();
5867
5868 /*
5869 * bts 0 ARFCN 871 BSIC 10
5870 * bts 1 ARFCN 871 BSIC 11
5871 * bts 2 ARFCN 871 BSIC 12
5872 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
5873 */
5874
5875 log("f_tc_ho_neighbor_config: 6. config error: explicit local and remote neighbors with ambiguous ARFCN+BSIC:"
5876 & " 'neighbor bts 2; neighbor lac 99 arfcn 871 bsic 12'");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005877 f_bts_0_cfg(BSCVTY, {"no neighbors", "neighbor bts 2", "neighbor lac 99 arfcn 871 bsic 12"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02005878 f_sleep(0.5);
5879
5880 f_probe_for_handover("6.a", "HO to 871-12 is ambiguous = error",
5881 "handover any to arfcn 871 bsic 12",
5882 false);
5883}
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005884testcase TC_ho_neighbor_config_6() runs on test_CT {
5885 var MSC_ConnHdlr vc_conn;
5886 f_init(3, true);
5887 f_sleep(1.0);
5888 f_ctrs_bsc_and_bts_init();
5889 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_6));
5890 vc_conn.done;
5891
5892 /* f_tc_ho_neighbor_config_start() */
5893 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5894 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5895
5896 /* 6.a */
5897 /* "timeout" means a handover was triggered and started (which is all this test aims for) and the test ended the
5898 * handover quickly by timing out after the Handover Required message */
5899 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5900 f_ctrs_bsc_and_bts_add(0, "handover:error");
5901
5902 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005903 f_shutdown_helper();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005904}
5905
Neels Hofmeyr91401012019-07-11 00:42:35 +02005906private function f_tc_ho_neighbor_config_7(charstring id) runs on MSC_ConnHdlr {
5907 f_tc_ho_neighbor_config_start();
5908
5909 /*
5910 * bts 0 ARFCN 871 BSIC 10
5911 * bts 1 ARFCN 871 BSIC 11
5912 * bts 2 ARFCN 871 BSIC 12
5913 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
5914 */
5915
5916 log("f_tc_ho_neighbor_config: 7. explicit local and remote neighbors:"
5917 & " 'neighbor bts 2; neighbor lac 99 arfcn 123 bsic 45'");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005918 f_bts_0_cfg(BSCVTY, {"no neighbors", "neighbor bts 2", "neighbor lac 99 arfcn 123 bsic 45"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02005919 f_sleep(0.5);
5920
5921 f_probe_for_handover("7.a", "HO to 871-12 does HO to bts 2",
5922 "handover any to arfcn 871 bsic 12",
5923 true);
5924 f_probe_for_handover("7.b", "HO to 123-45 triggers inter-BSC HO",
5925 "handover any to arfcn 123 bsic 45",
5926 true, true);
5927}
Neels Hofmeyr91401012019-07-11 00:42:35 +02005928testcase TC_ho_neighbor_config_7() runs on test_CT {
5929 var MSC_ConnHdlr vc_conn;
Neels Hofmeyrf2b88032020-06-16 00:35:04 +02005930 f_init(3, true, guard_timeout := 50.0);
Neels Hofmeyr91401012019-07-11 00:42:35 +02005931 f_sleep(1.0);
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005932 f_ctrs_bsc_and_bts_init();
Neels Hofmeyr91401012019-07-11 00:42:35 +02005933 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_7));
5934 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005935
5936 /* f_tc_ho_neighbor_config_start() */
5937 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5938 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5939
5940 /* 7.a */
5941 /* "failed" means a handover was triggered and started (which is all this test aims for) and the test ended the
5942 * handover quickly by sending a Handover Failure message. */
5943 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5944 f_ctrs_bsc_and_bts_add(0, "handover:failed");
5945 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
5946 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:failed");
5947
5948 /* 7.b */
5949 /* "timeout" means a handover was triggered and started (which is all this test aims for) and the test ended the
5950 * handover quickly by timing out after the Handover Required message */
5951 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5952 f_ctrs_bsc_and_bts_add(0, "handover:timeout");
5953 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
5954 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:timeout");
5955
5956 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005957 f_shutdown_helper();
Neels Hofmeyr91401012019-07-11 00:42:35 +02005958}
5959
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01005960/* OS#3041: Open and close N connections in a normal fashion, and expect no
5961 * BSSMAP Reset just because of that. */
5962testcase TC_bssap_rlsd_does_not_cause_bssmap_reset() runs on test_CT {
5963 var default d;
5964 var integer i;
5965 var DchanTuple dt;
5966
5967 f_init();
5968
5969 /* Wait for initial BSSMAP Reset to pass */
5970 f_sleep(4.0);
5971
5972 d := activate(no_bssmap_reset());
5973
5974 /* Setup up a number of connections and RLSD them again from the MSC
5975 * side. In the buggy behavior, the fourth one triggers BSSMAP Reset.
5976 * Let's do it some more times for good measure. */
Harald Weltec3260d92018-06-11 17:48:16 +02005977 for (i := 0; i < 4; i := i+1) {
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01005978 /* Since we're doing a lot of runs, give each one a fresh
5979 * T_guard from the top. */
5980 T_guard.start;
5981
5982 /* Setup a BSSAP connection and clear it right away. This is
5983 * the MSC telling the BSC about a planned release, it's not an
5984 * erratic loss of a connection. */
Harald Weltea1897182018-06-11 13:53:09 +02005985 dt := f_est_dchan(int2oct(i,1), 23+i, '00010203040506'O);
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01005986
5987 /* MSC disconnects (RLSD). */
5988 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
5989 }
5990
5991 /* In the buggy behavior, a timeout of 2 seconds happens between above
5992 * trigger (logs "SIGTRAN connection down, reconnecting...") and the
5993 * actual BSSMAP Reset. Wait a bit longer just to make sure. */
5994 f_sleep(4.0);
5995
5996 deactivate(d);
5997 f_shutdown_helper();
5998}
Harald Welte552620d2017-12-16 23:21:36 +01005999
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01006000/* OS#3041: Open and close N connections in a normal fashion, and expect no
6001 * BSSMAP Reset just because of that. Invoke the release by a BSSMAP Clear from
6002 * the MSC. */
6003testcase TC_bssmap_clear_does_not_cause_bssmap_reset() runs on test_CT {
6004 var default d;
6005 var integer i;
6006 var DchanTuple dt;
6007 var BSSAP_N_DATA_ind rx_di;
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01006008 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_CALL_CONTROL;
6009 var BssmapCause cause := enum2int(cause_val);
6010
6011 f_init();
6012
6013 /* Wait for initial BSSMAP Reset to pass */
6014 f_sleep(4.0);
6015
6016 d := activate(no_bssmap_reset());
6017
6018 /* Setup up a number of connections and RLSD them again from the MSC
6019 * side. In the buggy behavior, the fourth one triggers BSSMAP Reset.
6020 * Let's do it some more times for good measure. */
6021 for (i := 0; i < 8; i := i+1) {
6022 /* Since we're doing a lot of runs, give each one a fresh
6023 * T_guard from the top. */
6024 T_guard.start;
6025
6026 /* Setup a BSSAP connection and clear it right away. This is
6027 * the MSC telling the BSC about a planned release, it's not an
6028 * erratic loss of a connection. */
Harald Weltea1897182018-06-11 13:53:09 +02006029 dt := f_est_dchan(int2oct(i,1), 23+i, '00010203040506'O);
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01006030
6031 /* Instruct BSC to clear channel */
6032 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
6033
6034 /* expect BSC to disable the channel */
Harald Welte641fcbe2018-06-14 10:58:35 +02006035 f_exp_chan_rel_and_clear(dt, 0);
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01006036 }
6037
6038 /* In the buggy behavior, a timeout of 2 seconds happens between above
6039 * trigger (logs "SIGTRAN connection down, reconnecting...") and the
6040 * actual BSSMAP Reset. Wait a bit longer just to make sure. */
6041 f_sleep(4.0);
6042
6043 deactivate(d);
6044 f_shutdown_helper();
6045}
6046
Neels Hofmeyrfd445c32018-03-09 15:39:31 +01006047/* OS#3041: Open and close N connections in a normal fashion, and expect no
6048 * BSSMAP Reset just because of that. Close connections from the MS side with a
6049 * Release Ind on RSL. */
6050testcase TC_ms_rel_ind_does_not_cause_bssmap_reset() runs on test_CT {
6051 var default d;
6052 var integer i;
6053 var DchanTuple dt;
6054 var BSSAP_N_DATA_ind rx_di;
Neels Hofmeyrfd445c32018-03-09 15:39:31 +01006055 var integer j;
6056
6057 f_init();
6058
6059 /* Wait for initial BSSMAP Reset to pass */
6060 f_sleep(4.0);
6061
6062 d := activate(no_bssmap_reset());
6063
6064 /* Setup up a number of connections and RLSD them again from the MSC
6065 * side. In the buggy behavior, the fourth one triggers BSSMAP Reset.
6066 * Let's do it some more times for good measure. */
6067 for (i := 0; i < 8; i := i+1) {
6068 /* Since we're doing a lot of runs, give each one a fresh
6069 * T_guard from the top. */
6070 T_guard.start;
6071
6072 /* Setup a BSSAP connection and clear it right away. This is
6073 * the MSC telling the BSC about a planned release, it's not an
6074 * erratic loss of a connection. */
6075 dt := f_est_dchan('23'O, 23, '00010203040506'O);
6076
6077 /* simulate RLL REL IND */
6078 f_ipa_tx(0, ts_RSL_REL_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0))));
6079
6080 /* expect Clear Request on MSC side */
6081 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearRequest)) -> value rx_di;
6082
6083 /* Instruct BSC to clear channel */
6084 var BssmapCause cause := bit2int(rx_di.userData.pdu.bssmap.clearRequest.cause.causeValue);
6085 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
6086
6087 /* expect BSC to disable the channel */
Harald Welte641fcbe2018-06-14 10:58:35 +02006088 f_exp_chan_rel_and_clear(dt, 0);
Neels Hofmeyrfd445c32018-03-09 15:39:31 +01006089 }
6090
6091 /* In the buggy behavior, a timeout of 2 seconds happens between above
6092 * trigger (logs "SIGTRAN connection down, reconnecting...") and the
6093 * actual BSSMAP Reset. Wait a bit longer just to make sure. */
6094 f_sleep(4.0);
6095
6096 deactivate(d);
6097 f_shutdown_helper();
6098}
6099
Harald Welte94e0c342018-04-07 11:33:23 +02006100/***********************************************************************
6101 * IPA style dynamic PDCH
6102 ***********************************************************************/
6103
6104private function f_dyn_ipa_pdch_act(integer bts_nr, integer trx_nr, integer ts_nr,
6105 template (omit) RSL_Cause nack := omit)
6106runs on test_CT {
6107 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(ts_nr));
6108 var RSL_Message rsl_unused;
6109 /* ask BSC via VTY to activate a given IPA style chan as PDCH */
6110 f_vty_ts_action("pdch activate", bts_nr, trx_nr, ts_nr);
6111 /* expect the BSC to issue the related RSL command */
6112 rsl_unused := f_exp_ipa_rx(0, tr_RSL_IPA_PDCH_ACT(chan_nr));
6113 if (istemplatekind(nack, "omit")) {
6114 /* respond with a related acknowledgement */
6115 f_ipa_tx(0, ts_RSL_IPA_PDCH_ACT_ACK(chan_nr, ts_RSL_IE_FrameNumber(2342)));
6116 } else {
6117 f_ipa_tx(0, ts_RSL_IPA_PDCH_ACT_NACK(chan_nr, valueof(nack)));
6118 }
6119}
6120
6121private function f_dyn_ipa_pdch_deact(integer bts_nr, integer trx_nr, integer ts_nr,
6122 template (omit) RSL_Cause nack := omit)
6123runs on test_CT {
6124 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(ts_nr));
6125 var RSL_Message rsl_unused;
6126 /* ask BSC via VTY to activate a given IPA style chan as PDCH */
6127 f_vty_ts_action("pdch deactivate", bts_nr, trx_nr, ts_nr);
6128 /* expect the BSC to issue the related RSL command */
6129 rsl_unused := f_exp_ipa_rx(0, tr_RSL_IPA_PDCH_DEACT(chan_nr));
6130 if (istemplatekind(nack, "omit")) {
6131 /* respond with a related acknowledgement */
6132 f_ipa_tx(0, ts_RSL_IPA_PDCH_DEACT_ACK(chan_nr));
6133 } else {
6134 f_ipa_tx(0, ts_RSL_IPA_PDCH_DEACT_NACK(chan_nr, valueof(nack)));
6135 }
6136}
6137
6138private function f_ts_dyn_mode_get(integer bts_nr, integer trx_nr, integer ts_nr)
6139runs on test_CT return charstring {
6140 var charstring cmd, resp;
6141 cmd := "show timeslot "&int2str(bts_nr)&" "&int2str(trx_nr)&" "&int2str(ts_nr);
Stefan Sperlingcff13562018-11-13 15:24:06 +01006142 return f_vty_transceive_match_regexp_retry(BSCVTY, cmd, "*\((*)\)*", 0, 4, 1.0);
Harald Welte94e0c342018-04-07 11:33:23 +02006143}
6144
6145private function f_ts_dyn_mode_assert(integer bts_nr, integer trx_nr, integer ts_nr,
6146 template charstring exp)
6147runs on test_CT {
6148 var charstring mode := f_ts_dyn_mode_get(bts_nr, trx_nr, ts_nr);
6149 if (not match(mode, exp)) {
6150 setverdict(fail, "Unexpected TS Mode: ", mode);
Daniel Willmannafce8662018-07-06 23:11:32 +02006151 mtc.stop;
Harald Welte94e0c342018-04-07 11:33:23 +02006152 }
6153}
6154
6155private function f_ts_set_chcomb(integer bts_nr, integer trx_nr, integer ts_nr, charstring chcomb)
6156runs on test_CT {
6157 f_vty_enter_cfg_ts(BSCVTY, bts_nr, trx_nr, ts_nr);
6158 f_vty_transceive(BSCVTY, "phys_chan_config " & chcomb);
6159 f_vty_transceive(BSCVTY, "end");
6160}
6161
6162private const charstring TCHF_MODE := "TCH/F mode";
6163private const charstring TCHH_MODE := "TCH/H mode";
6164private const charstring PDCH_MODE := "PDCH mode";
6165private const charstring NONE_MODE := "NONE mode";
6166
6167/* Test IPA PDCH activation / deactivation triggered by VTY */
6168testcase TC_dyn_pdch_ipa_act_deact() runs on test_CT {
6169 var RSL_Message rsl_unused;
6170
6171 /* change Timeslot 6 before f_init() starts RSL */
6172 f_init_vty();
6173 f_ts_set_chcomb(0, 0, 6, "TCH/F_PDCH");
6174 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
6175
6176 f_init(1, false);
6177 f_sleep(1.0);
6178
6179 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(6));
6180
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02006181 log("TCH/F_PDCH pchan starts out in TCH/F mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02006182 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
6183 /* The BSC will activate the dynamic PDCH by default, so confirm that */
6184 rsl_unused := f_exp_ipa_rx(0, tr_RSL_IPA_PDCH_ACT(chan_nr));
6185 f_ipa_tx(0, ts_RSL_IPA_PDCH_ACT_ACK(chan_nr, ts_RSL_IE_FrameNumber(2342)));
6186 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02006187 log("TCH/F_PDCH pchan, PDCH ACT was ACKed, so now in PDCH mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02006188 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, PDCH_MODE);
6189
6190 /* De-activate it via VTY */
6191 f_dyn_ipa_pdch_deact(0, 0, chan_nr.tn);
6192 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02006193 log("TCH/F_PDCH pchan, PDCH DEACT via VTY, so now back in TCH/F mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02006194 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
6195
6196 /* re-activate it via VTY */
6197 f_dyn_ipa_pdch_act(0, 0, chan_nr.tn);
6198 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02006199 log("TCH/F_PDCH pchan, PDCH ACT via VTY, so now in PDCH mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02006200 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, PDCH_MODE);
6201
6202 /* and finally de-activate it again */
6203 f_dyn_ipa_pdch_deact(0, 0, chan_nr.tn);
6204 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02006205 log("TCH/F_PDCH pchan, PDCH DEACT via VTY, so now back in TCH/F mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02006206 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
6207
Neels Hofmeyr887e8f12018-06-27 01:01:55 +02006208 /* clean up config */
6209 f_ts_set_chcomb(0, 0, 6, "PDCH");
6210
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006211 f_shutdown_helper();
Harald Welte94e0c342018-04-07 11:33:23 +02006212}
6213
6214/* Test IPA PDCH activation NACK */
6215testcase TC_dyn_pdch_ipa_act_nack() runs on test_CT {
6216 var RSL_Message rsl_unused;
6217
6218 /* change Timeslot 6 before f_init() starts RSL */
6219 f_init_vty();
6220 f_ts_set_chcomb(0, 0, 6, "TCH/F_PDCH");
6221 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
6222
6223 f_init(1, false);
6224 f_sleep(1.0);
6225
6226 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(6));
6227
6228 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
6229 /* The BSC will activate the dynamic PDCH by default, so confirm that */
6230 rsl_unused := f_exp_ipa_rx(0, tr_RSL_IPA_PDCH_ACT(chan_nr));
6231 f_ipa_tx(0, ts_RSL_IPA_PDCH_ACT_ACK(chan_nr, ts_RSL_IE_FrameNumber(2342)));
6232 f_sleep(1.0);
6233 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, PDCH_MODE);
6234
6235 /* De-activate it via VTY */
6236 f_dyn_ipa_pdch_deact(0, 0, chan_nr.tn);
6237 f_sleep(1.0);
6238 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
6239
6240 /* re-activate it via VTY, but fail that; check BSC still assumes TCH/F mode */
6241 f_dyn_ipa_pdch_act(0, 0, chan_nr.tn, RSL_ERR_EQUIPMENT_FAIL);
6242 f_sleep(1.0);
6243 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
6244
Neels Hofmeyr887e8f12018-06-27 01:01:55 +02006245 /* clean up config */
6246 f_ts_set_chcomb(0, 0, 6, "PDCH");
6247
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006248 f_shutdown_helper();
Harald Welte94e0c342018-04-07 11:33:23 +02006249}
6250
6251
6252/***********************************************************************
6253 * Osmocom style dynamic PDCH
6254 ***********************************************************************/
6255
6256private function f_dyn_osmo_pdch_act(integer bts_nr, integer trx_nr, integer ts_nr,
6257 template (omit) RSL_Cause nack := omit)
6258runs on test_CT {
6259 var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(ts_nr));
6260 var RSL_Message rsl_unused;
6261 /* ask BSC via VTY to activate a given IPA style chan as PDCH */
6262 /* FIXME: no VTY command to activate Osmocom PDCH !! */
6263 /* expect the BSC to issue the related RSL command */
6264 rsl_unused := f_exp_ipa_rx(0, tr_RSL_CHAN_ACT(chan_nr, ?));
6265 if (istemplatekind(nack, "omit")) {
6266 /* respond with a related acknowledgement */
6267 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, 2342));
6268 } else {
6269 f_ipa_tx(0, ts_RSL_CHAN_ACT_NACK(chan_nr, valueof(nack)));
6270 }
6271}
6272
6273private function f_dyn_osmo_pdch_deact(integer bts_nr, integer trx_nr, integer ts_nr,
6274 template (omit) RSL_Cause nack := omit)
6275runs on test_CT {
6276 var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(ts_nr));
6277 var RSL_Message rsl_unused;
6278 /* ask BSC via VTY to activate a given IPA style chan as PDCH */
6279 /* FIXME: no VTY command to activate Osmocom PDCH !! */
6280 /* expect the BSC to issue the related RSL command */
6281 rsl_unused := f_exp_ipa_rx(0, tr_RSL_RF_CHAN_REL(chan_nr));
6282 if (istemplatekind(nack, "omit")) {
6283 /* respond with a related acknowledgement */
6284 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(chan_nr));
6285 } else {
6286 //f_ipa_tx(0, ts_RSL_RF_CHAN_REL_NACK(chan_nr, valueof(nack)));
6287 }
6288}
6289
6290/* Test Osmocom dyn PDCH activation / deactivation triggered by VTY */
6291testcase TC_dyn_pdch_osmo_act_deact() runs on test_CT {
6292 var RSL_Message rsl_unused;
6293
6294 /* change Timeslot 6 before f_init() starts RSL */
6295 f_init_vty();
6296 f_ts_set_chcomb(0, 0, 6, "TCH/F_TCH/H_PDCH");
6297 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
6298
6299 f_init(1, false);
6300 f_sleep(1.0);
6301
6302 var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(6));
6303
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02006304 log("TCH/F_TCH/H_PDCH pchan starts out in disabled mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02006305 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, NONE_MODE);
6306 /* The BSC will activate the dynamic PDCH by default, so confirm that */
6307 rsl_unused := f_exp_ipa_rx(0, tr_RSL_CHAN_ACT_PDCH(chan_nr, ?));
6308
6309 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, 2342));
6310 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02006311 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 +02006312 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, PDCH_MODE);
6313
Neels Hofmeyr887e8f12018-06-27 01:01:55 +02006314 /* clean up config */
6315 f_ts_set_chcomb(0, 0, 6, "PDCH");
6316
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006317 f_shutdown_helper();
Harald Welte94e0c342018-04-07 11:33:23 +02006318}
6319
6320/* Test Osmocom dyn PDCH activation NACK behavior */
6321testcase TC_dyn_pdch_osmo_act_nack() runs on test_CT {
6322 var RSL_Message rsl_unused;
6323
6324 /* change Timeslot 6 before f_init() starts RSL */
6325 f_init_vty();
6326 f_ts_set_chcomb(0, 0, 6, "TCH/F_TCH/H_PDCH");
6327 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
6328
6329 f_init(1, false);
6330 f_sleep(1.0);
6331
6332 var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(6));
6333
6334 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, NONE_MODE);
6335 /* The BSC will activate the dynamic PDCH by default, so confirm that */
6336 rsl_unused := f_exp_ipa_rx(0, tr_RSL_CHAN_ACT_PDCH(chan_nr, ?));
6337
6338 /* NACK this activation and expect the "show timeslot" mode still to be NONE */
6339 f_ipa_tx(0, ts_RSL_CHAN_ACT_NACK(chan_nr, RSL_ERR_EQUIPMENT_FAIL));
6340 f_sleep(1.0);
6341 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, NONE_MODE);
6342
Neels Hofmeyr887e8f12018-06-27 01:01:55 +02006343 /* clean up config */
6344 f_ts_set_chcomb(0, 0, 6, "PDCH");
6345
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006346 f_shutdown_helper();
Harald Welte94e0c342018-04-07 11:33:23 +02006347}
6348
Stefan Sperling0796a822018-10-05 13:01:39 +02006349testcase TC_chopped_ipa_ping() runs on test_CT {
Stefan Sperling554123f2018-10-09 14:12:30 +02006350 const Integers bsc_ipa_ports := {mp_bsc_rsl_port, mp_bsc_oml_port, mp_bsc_ctrl_port};
Stefan Sperling0796a822018-10-05 13:01:39 +02006351 for (var integer i := 0; i < lengthof(bsc_ipa_ports); i := i + 1) {
6352 IPA_Testing.f_run_TC_chopped_ipa_ping(mp_bsc_ip, bsc_ipa_ports[i], CONNECT_TO_SERVER);
6353 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006354 f_shutdown_helper();
Stefan Sperling0796a822018-10-05 13:01:39 +02006355}
6356
Stefan Sperlingaa1e60f2018-10-15 16:34:07 +02006357testcase TC_chopped_ipa_payload() runs on test_CT {
6358 const Integers bsc_ipa_ports := {mp_bsc_rsl_port, mp_bsc_oml_port
6359 /* TODO: mp_bsc_ctrl_port does not work yet */};
6360 for (var integer i := 0; i < lengthof(bsc_ipa_ports); i := i + 1) {
6361 IPA_Testing.f_run_TC_chopped_ipa_payload(mp_bsc_ip, bsc_ipa_ports[i], CONNECT_TO_SERVER);
6362 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006363 f_shutdown_helper();
Stefan Sperlingaa1e60f2018-10-15 16:34:07 +02006364}
6365
Pau Espin Pedrol8f773632019-11-05 11:46:53 +01006366/* Verify the BSC sends the MS Power Parameters IE during CHAN ACT to make sure
6367 the BTS does autonomous MS power control loop */
6368testcase TC_assignment_verify_ms_power_params_ie() runs on test_CT {
6369 var MSC_ConnHdlr vc_conn;
6370 var TestHdlrParams pars := f_gen_test_hdlr_pars();
6371 //pars.encr := valueof(t_EncrParams('01'O, f_rnd_octstring(8)));
6372 pars.exp_ms_power_params := true;
6373
6374 f_init(1, true);
6375 f_sleep(1.0);
6376 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5), pars);
6377 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006378 f_shutdown_helper();
Pau Espin Pedrol8f773632019-11-05 11:46:53 +01006379}
Stefan Sperlingaa1e60f2018-10-15 16:34:07 +02006380
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006381/***********************************************************************
6382 * MSC Pooling
6383 ***********************************************************************/
6384
6385function f_tmsi_nri(integer nri_v, octetstring base_tmsi := '42000023'O, integer nri_bitlen := 10) return octetstring
6386{
6387 return int2oct( oct2int(base_tmsi) + bit2int( (int2bit(nri_v, 32) << ( 24 - nri_bitlen)) ),
6388 4);
6389}
6390
6391template MobileIdentityLV ts_MI_TMSI_NRI_LV(integer nri_v, integer nri_bitlen := 10) :=
6392 ts_MI_TMSI_LV(tmsi := f_tmsi_nri(nri_v, nri_bitlen := nri_bitlen));
6393
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02006394private function f_expect_lchan_rel(RSL_DCHAN_PT rsl) runs on MSC_ConnHdlr {
6395 interleave {
6396 [] rsl.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_RELEASE)) {
6397 f_logp(BSCVTY, "Got RSL RR Release");
6398 }
6399 [] rsl.receive(tr_RSL_DEACT_SACCH(g_chan_nr)) {
6400 f_logp(BSCVTY, "Got RSL Deact SACCH");
6401 }
6402 [] rsl.receive(tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL)) {
6403 f_logp(BSCVTY, "Got RSL RF Chan Rel, sending Rel Ack");
6404 rsl.send(ts_RSL_RF_CHAN_REL_ACK(g_chan_nr));
6405 break;
6406 }
6407 }
6408}
6409
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006410private function f_perform_clear(RSL_DCHAN_PT rsl) runs on MSC_ConnHdlr {
Neels Hofmeyr767548a2020-08-09 20:26:07 +00006411 f_logp(BSCVTY, "MSC instructs BSC to clear channel");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006412 BSSAP.send(ts_BSSMAP_ClearCommand(0));
6413 interleave {
6414 [] rsl.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_RELEASE)) {
Neels Hofmeyr767548a2020-08-09 20:26:07 +00006415 f_logp(BSCVTY, "Got RSL RR Release");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006416 }
6417 [] rsl.receive(tr_RSL_DEACT_SACCH(g_chan_nr)) {
Neels Hofmeyr767548a2020-08-09 20:26:07 +00006418 f_logp(BSCVTY, "Got RSL Deact SACCH");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006419 }
6420 [] BSSAP.receive(tr_BSSMAP_ClearComplete) {
Neels Hofmeyr767548a2020-08-09 20:26:07 +00006421 f_logp(BSCVTY, "Got BSSMAP Clear Complete");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006422 /* Also drop the SCCP connection */
6423 BSSAP.send(RAN_Conn_Prim:MSC_CONN_PRIM_DISC_REQ);
6424 }
6425 [] rsl.receive(tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL)) {
Neels Hofmeyr767548a2020-08-09 20:26:07 +00006426 f_logp(BSCVTY, "Got RSL RF Chan Rel, sending Rel Ack");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006427 rsl.send(ts_RSL_RF_CHAN_REL_ACK(g_chan_nr));
6428 }
6429 }
6430}
6431
Neels Hofmeyr66e15092020-10-12 18:44:41 +00006432private 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 +02006433runs on MSC_ConnHdlr {
6434 timer T := 10.0;
6435 var octetstring l3_enc := enc_PDU_ML3_MS_NW(valueof(l3_info));
6436
Neels Hofmeyr767548a2020-08-09 20:26:07 +00006437 f_logp(BSCVTY, "establish channel, send Complete Layer 3 Info");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006438 f_create_bssmap_exp(l3_enc);
6439
6440 /* RSL_Emulation.f_chan_est() on rsl:
6441 * This is basically code dup with s/RSL/rsl from:
6442 * RSL_Emulation.f_chan_est(g_pars.ra, l3_enc, g_pars.link_id, g_pars.fn);
6443 */
6444 var RSL_Message rx_rsl;
6445 var GsmRrMessage rr;
6446
6447 /* request a channel to be established */
6448 rsl.send(ts_RSLDC_ChanRqd(g_pars.ra, g_pars.fn));
6449 /* expect immediate assignment.
6450 * Code dup with s/RSL/rsl from:
6451 * rx_rsl := f_rx_or_fail(tr_RSL_IMM_ASSIGN);
6452 */
6453 timer Tt := 10.0;
6454
6455 /* request a channel to be established */
6456 Tt.start;
6457 alt {
6458 [] rsl.receive(tr_RSL_IMM_ASSIGN) -> value rx_rsl {
6459 Tt.stop;
6460 }
6461 [] rsl.receive {
6462 setverdict(fail, "Unexpected RSL message on DCHAN");
6463 mtc.stop;
6464 }
6465 [] Tt.timeout {
6466 setverdict(fail, "Timeout waiting for RSL on DCHAN");
6467 mtc.stop;
6468 }
6469 }
6470 rr := dec_GsmRrMessage(rx_rsl.ies[1].body.full_imm_ass_info.payload);
6471 g_chan_nr := rr.payload.imm_ass.chan_desc.chan_nr;
6472 rsl.send(ts_RSL_EST_IND(g_chan_nr, valueof(g_pars.link_id), l3_enc));
6473
6474
Neels Hofmeyr66e15092020-10-12 18:44:41 +00006475 if (expect_bssmap_l3) {
6476 f_logp(BSCVTY, "expect BSSAP Complete Layer 3 Info at MSC");
6477 var template PDU_BSSAP exp_l3_compl;
6478 exp_l3_compl := tr_BSSMAP_ComplL3()
6479 if (g_pars.aoip == false) {
6480 exp_l3_compl.pdu.bssmap.completeLayer3Information.codecList := omit;
6481 } else {
6482 exp_l3_compl.pdu.bssmap.completeLayer3Information.codecList := ?;
6483 }
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006484
Neels Hofmeyr66e15092020-10-12 18:44:41 +00006485 var PDU_BSSAP bssap;
6486 T.start;
6487 alt {
6488 [] BSSAP.receive(exp_l3_compl) -> value bssap {
6489 f_logp(BSCVTY, "received expected Complete Layer 3 Info at MSC");
6490 log("rx exp_l3_compl = ", bssap);
6491 }
6492 [] BSSAP.receive(tr_BSSMAP_ComplL3) {
6493 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Received non-matching COMPLETE LAYER 3 INFORMATION");
6494 }
6495 [] T.timeout {
6496 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for COMPLETE LAYER 3 INFORMATION");
6497 }
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006498 }
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006499
Neels Hofmeyr66e15092020-10-12 18:44:41 +00006500 /* start ciphering, if requested */
6501 if (ispresent(g_pars.encr)) {
6502 f_logp(BSCVTY, "start ciphering");
6503 f_cipher_mode(g_pars.encr.enc_alg, g_pars.encr.enc_key);
6504 }
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006505 }
6506
6507 if (do_clear) {
6508 f_perform_clear(rsl);
6509 }
6510 setverdict(pass);
6511 f_sleep(1.0);
6512}
6513
6514private function f_tc_mscpool_compl_l3(charstring id) runs on MSC_ConnHdlr {
6515 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
6516 if (g_pars.mscpool.rsl_idx == 0) {
6517 f_perform_compl_l3(RSL, g_pars.mscpool.l3_info);
6518 } else if (g_pars.mscpool.rsl_idx == 1) {
6519 f_perform_compl_l3(RSL1, g_pars.mscpool.l3_info);
6520 } else if (g_pars.mscpool.rsl_idx == 2) {
6521 f_perform_compl_l3(RSL2, g_pars.mscpool.l3_info);
6522 }
6523}
6524
6525/* Various Complete Layer 3 by IMSI all end up with the first MSC, because the other MSCs are not connected. */
6526private function f_tc_mscpool_L3Compl_on_1_msc(charstring id) runs on MSC_ConnHdlr {
6527 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
6528 f_perform_compl_l3(RSL, ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_IMSI_LV('001010000000001'H)), '00F110'O) );
6529 f_perform_compl_l3(RSL, ts_CM_SERV_REQ(CM_TYPE_MO_SMS, valueof(ts_MI_IMSI_LV('001010000000002'H))) );
6530 f_perform_compl_l3(RSL, ts_PAG_RESP(valueof(ts_MI_IMSI_LV('001010000000003'H))) );
6531 f_perform_compl_l3(RSL, ts_ML3_MO_MM_IMSI_DET_Ind(valueof(ts_MI_IMSI_LV('001010000000004'H))) );
6532}
6533testcase TC_mscpool_L3Compl_on_1_msc() runs on test_CT {
6534
6535 f_init(1, true);
6536 f_sleep(1.0);
6537 var MSC_ConnHdlr vc_conn;
6538 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006539
6540 f_ctrs_msc_init();
6541
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006542 vc_conn := f_start_handler(refers(f_tc_mscpool_L3Compl_on_1_msc), pars);
6543 vc_conn.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006544
6545 f_ctrs_msc_expect(0, "mscpool:subscr:new", 4);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006546 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006547}
6548
6549/* Three Layer 3 Complete by IMSI are round-robin'ed across two connected MSCs */
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_imsi_round_robin() runs on test_CT {
6553
6554 f_init(nr_bts := 3, handler_mode := true, nr_msc := 2);
6555 f_sleep(1.0);
6556
6557 /* Control which MSC gets chosen next by the round-robin, otherwise
6558 * would be randomly affected by which other tests ran before this. */
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 := 0);
6565 pars1.mscpool.rsl_idx := 0;
6566 pars1.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_IMSI_LV('001010000000001'H)), '00F110'O));
6567 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6568 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006569 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006570
6571 var MSC_ConnHdlr vc_conn2;
6572 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 1);
6573 pars2.mscpool.rsl_idx := 1;
6574 pars2.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, valueof(ts_MI_IMSI_LV('001010000000002'H))));
6575 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6576 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006577 f_ctrs_msc_expect(1, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006578
6579 /* Test round-robin wrap to the first MSC */
6580 var MSC_ConnHdlr vc_conn3;
6581 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 0);
6582 pars3.mscpool.rsl_idx := 2;
6583 pars3.mscpool.l3_info := valueof(ts_PAG_RESP(valueof(ts_MI_IMSI_LV('001010000000003'H))));
6584 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
6585 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006586 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006587 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006588}
6589
6590/* Three LU by TMSI are round-robin'ed across two connected MSCs, because they contain the NULL-NRI 0
6591 * (configured in osmo-bsc.cfg). */
6592/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
6593 * just as well using only RSL. */
6594testcase TC_mscpool_LU_by_tmsi_null_nri_0_round_robin() runs on test_CT {
6595
6596 f_init(nr_bts := 3, handler_mode := true, nr_msc := 2);
6597 f_sleep(1.0);
6598
6599 /* Control which MSC gets chosen next by the round-robin, otherwise
6600 * would be randomly affected by which other tests ran before this. */
6601 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
6602
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006603 f_ctrs_msc_init();
6604
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006605 var MSC_ConnHdlr vc_conn1;
6606 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
6607 pars1.mscpool.rsl_idx := 0;
6608 pars1.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(0)), '00F110'O));
6609 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6610 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006611 f_ctrs_msc_expect(0, "mscpool:subscr:reattach");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006612
6613 var MSC_ConnHdlr vc_conn2;
6614 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 1);
6615 pars2.mscpool.rsl_idx := 1;
6616 pars2.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(0)), '00F110'O));
6617 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6618 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006619 f_ctrs_msc_expect(1, "mscpool:subscr:reattach");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006620
6621 /* Test round-robin wrap to the first MSC */
6622 var MSC_ConnHdlr vc_conn3;
6623 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 0);
6624 pars3.mscpool.rsl_idx := 2;
6625 pars3.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(0)), '00F110'O));
6626 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
6627 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006628 f_ctrs_msc_expect(0, "mscpool:subscr:reattach");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006629 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006630}
6631
6632/* Three LU by TMSI are round-robin'ed across two connected MSCs, because they contain the NULL-NRI 1
6633 * (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
6634 * NULL-NRI setting is stronger than that. */
6635/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
6636 * just as well using only RSL. */
6637testcase TC_mscpool_LU_by_tmsi_null_nri_1_round_robin() runs on test_CT {
6638
6639 f_init(nr_bts := 3, handler_mode := true, nr_msc := 2);
6640 f_sleep(1.0);
6641
6642 /* Control which MSC gets chosen next by the round-robin, otherwise
6643 * would be randomly affected by which other tests ran before this. */
6644 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
6645
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006646 f_ctrs_msc_init();
6647
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006648 var MSC_ConnHdlr vc_conn1;
6649 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
6650 pars1.mscpool.rsl_idx := 0;
6651 pars1.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(1)), '00F110'O));
6652 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6653 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006654 f_ctrs_msc_expect(0, "mscpool:subscr:reattach");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006655
6656 var MSC_ConnHdlr vc_conn2;
6657 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 1);
6658 pars2.mscpool.rsl_idx := 1;
6659 pars2.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(1)), '00F110'O));
6660 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6661 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006662 f_ctrs_msc_expect(1, "mscpool:subscr:reattach");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006663
6664 /* Test round-robin wrap to the first MSC */
6665 var MSC_ConnHdlr vc_conn3;
6666 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 0);
6667 pars3.mscpool.rsl_idx := 2;
6668 pars3.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(1)), '00F110'O));
6669 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
6670 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006671 f_ctrs_msc_expect(0, "mscpool:subscr:reattach");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006672 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006673}
6674
6675/* Three Layer 3 Complete by TMSI are round-robin'ed across two connected MSCs, because they contain an NRI not
6676 * assigned to any MSC (configured in osmo-bsc.cfg). */
6677/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
6678 * just as well using only RSL. */
6679testcase TC_mscpool_L3Complete_by_tmsi_unassigned_nri_round_robin() runs on test_CT {
6680
6681 f_init(nr_bts := 3, handler_mode := true, nr_msc := 2);
6682 f_sleep(1.0);
6683
6684 /* Control which MSC gets chosen next by the round-robin, otherwise
6685 * would be randomly affected by which other tests ran before this. */
6686 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
6687
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006688 f_ctrs_msc_init();
6689
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006690 var MSC_ConnHdlr vc_conn1;
6691 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
6692 pars1.mscpool.rsl_idx := 0;
6693 /* An NRI that is not assigned to any MSC */
6694 pars1.mscpool.l3_info := valueof(ts_ML3_MO_MM_IMSI_DET_Ind(valueof(ts_MI_TMSI_NRI_LV(1023))));
6695 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6696 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006697 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006698
6699 var MSC_ConnHdlr vc_conn2;
6700 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 1);
6701 pars2.mscpool.rsl_idx := 1;
6702 /* An NRI that is not assigned to any MSC */
6703 pars2.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(768)), '00F110'O));
6704 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6705 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006706 f_ctrs_msc_expect(1, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006707
6708 /* Test round-robin wrap to the first MSC */
6709 var MSC_ConnHdlr vc_conn3;
6710 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 0);
6711 pars3.mscpool.rsl_idx := 2;
6712 /* An NRI that is not assigned to any MSC */
6713 pars3.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_SS_ACT, valueof(ts_MI_TMSI_NRI_LV(819))));
6714 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
6715 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006716 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006717 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006718}
6719
6720/* Three Layer 3 Complete by TMSI are round-robin'ed across two connected MSCs, because they contain an NRI
6721 * assigned to an MSC that is currently not connected (configured in osmo-bsc.cfg). */
6722/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
6723 * just as well using only RSL. */
6724testcase TC_mscpool_L3Complete_by_tmsi_valid_nri_msc_not_connected_round_robin() runs on test_CT {
6725
6726 f_init(nr_bts := 3, handler_mode := true, nr_msc := 2);
6727 f_sleep(1.0);
6728
6729 /* Control which MSC gets chosen next by the round-robin, otherwise
6730 * would be randomly affected by which other tests ran before this. */
6731 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
6732
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006733 f_ctrs_msc_init();
6734
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006735 var MSC_ConnHdlr vc_conn1;
6736 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
6737 pars1.mscpool.rsl_idx := 0;
6738 /* An NRI that is assigned to an unconnected MSC */
6739 pars1.mscpool.l3_info := valueof(ts_PAG_RESP(valueof(ts_MI_TMSI_NRI_LV(512))));
6740 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6741 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006742 f_ctrs_msc_add(2, "mscpool:subscr:attach_lost");
6743 f_ctrs_msc_add(0, "mscpool:subscr:new");
6744 f_ctrs_msc_verify();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006745
6746 var MSC_ConnHdlr vc_conn2;
6747 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 1);
6748 pars2.mscpool.rsl_idx := 1;
6749 /* An NRI that is assigned to an unconnected MSC */
6750 pars2.mscpool.l3_info := valueof(ts_ML3_MO_MM_IMSI_DET_Ind(valueof(ts_MI_TMSI_NRI_LV(767))));
6751 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6752 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006753 f_ctrs_msc_add(2, "mscpool:subscr:attach_lost");
6754 f_ctrs_msc_add(1, "mscpool:subscr:new");
6755 f_ctrs_msc_verify();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006756
6757 /* Test round-robin wrap to the first MSC */
6758 var MSC_ConnHdlr vc_conn3;
6759 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 0);
6760 pars3.mscpool.rsl_idx := 2;
6761 /* An NRI that is assigned to an unconnected MSC */
6762 pars3.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(750)), '00F110'O));
6763 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
6764 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006765 f_ctrs_msc_add(2, "mscpool:subscr:attach_lost");
6766 f_ctrs_msc_add(0, "mscpool:subscr:new");
6767 f_ctrs_msc_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006768 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006769}
6770
6771/* Three Layer 3 Complete by TMSI with valid NRI for the second MSC are all directed to the second MSC (configured in
6772 * osmo-bsc.cfg). */
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_L3Complete_by_tmsi_valid_nri_1() runs on test_CT {
6776
6777 f_init(nr_bts := 3, handler_mode := true, nr_msc := 2);
6778 f_sleep(1.0);
6779
6780 /* All TMSIs in this test point at the second MSC, set the round robin to point at the first MSC to make sure
6781 * this is not using round-robin. */
6782 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
6783
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006784 f_ctrs_msc_init();
6785
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006786 var MSC_ConnHdlr vc_conn1;
6787 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 1);
6788 pars1.mscpool.rsl_idx := 0;
6789 /* An NRI of the second MSC's range (256-511) */
6790 pars1.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_SMS, valueof(ts_MI_TMSI_NRI_LV(256))));
6791 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6792 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006793 f_ctrs_msc_expect(1, "mscpool:subscr:known");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006794
6795 var MSC_ConnHdlr vc_conn2;
6796 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 1);
6797 pars2.mscpool.rsl_idx := 1;
6798 /* An NRI of the second MSC's range (256-511) */
6799 pars2.mscpool.l3_info := valueof(ts_PAG_RESP(valueof(ts_MI_TMSI_NRI_LV(260))));
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(1, "mscpool:subscr:known");
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 := 1);
6806 pars3.mscpool.rsl_idx := 2;
6807 /* An NRI of the second MSC's range (256-511) */
6808 pars3.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(511)), '00F110'O));
6809 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
6810 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006811 f_ctrs_msc_expect(1, "mscpool:subscr:known");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006812 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006813}
6814
6815/* Layer 3 Complete by TMSI with valid NRI for the third MSC are directed to the third MSC (configured in osmo-bsc.cfg),
6816 * while a round-robin remains unaffected by that. */
6817/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
6818 * just as well using only RSL. */
6819testcase TC_mscpool_L3Complete_by_tmsi_valid_nri_2() runs on test_CT {
6820
6821 f_init(nr_bts := 3, handler_mode := true, nr_msc := 3);
6822 f_sleep(1.0);
6823
6824 /* All TMSIs in this test point at the third MSC, set the round robin to point at the second MSC to make sure
6825 * this is not using round-robin. */
6826 f_vty_transceive(BSCVTY, "mscpool roundrobin next 1");
6827
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006828 f_ctrs_msc_init();
6829
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006830 var MSC_ConnHdlr vc_conn1;
6831 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 2);
6832 pars1.mscpool.rsl_idx := 0;
6833 /* An NRI of the third MSC's range (512-767) */
6834 pars1.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_SMS, valueof(ts_MI_TMSI_NRI_LV(512))));
6835 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6836 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006837 f_ctrs_msc_expect(2, "mscpool:subscr:known");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006838
6839 var MSC_ConnHdlr vc_conn2;
6840 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 2);
6841 pars2.mscpool.rsl_idx := 1;
6842 /* An NRI of the third MSC's range (512-767) */
6843 pars2.mscpool.l3_info := valueof(ts_PAG_RESP(valueof(ts_MI_TMSI_NRI_LV(678))));
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(2, "mscpool:subscr:known");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006847
6848 /* The above forwardings to third MSC have not affected the round robin, which still points at the second MSC */
6849 var MSC_ConnHdlr vc_conn3;
6850 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 1);
6851 pars3.mscpool.rsl_idx := 2;
6852 pars3.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_IMSI_LV('001010000000013'H)), '00F110'O));
6853 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
6854 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006855 f_ctrs_msc_expect(1, "mscpool:subscr:new");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006856 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006857}
6858
6859/* LU with a TMSI but indicating a different PLMN in its previous LAI: ignore the NRI. */
6860/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
6861 * just as well using only RSL. */
6862testcase TC_mscpool_LU_by_tmsi_from_other_PLMN() runs on test_CT {
6863
6864 f_init(nr_bts := 3, handler_mode := true, nr_msc := 3);
6865 f_sleep(1.0);
6866
6867 /* The TMSIs in this test points at the second MSC, but since it is from a different PLMN, round-robin is used
6868 * instead, and hits msc 0. */
6869 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
6870
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006871 f_ctrs_msc_init();
6872
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006873 /* An NRI of the second MSC's range (256-511), but a PLMN that doesn't match with osmo-bsc.cfg */
6874 var MSC_ConnHdlr vc_conn1;
6875 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
6876 pars1.mscpool.rsl_idx := 0;
6877 pars1.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(260)), '99F999'O));
6878 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6879 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006880 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006881
6882 /* An NRI of the third MSC's range (512-767) and a matching PLMN gets directed by NRI. */
6883 var MSC_ConnHdlr vc_conn2;
6884 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 2);
6885 pars2.mscpool.rsl_idx := 1;
6886 pars2.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(555)), '00F110'O));
6887 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6888 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006889 f_ctrs_msc_expect(2, "mscpool:subscr:known");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006890 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006891}
6892
6893/* Make sure that whichever MSC paged a subscriber will also get the Paging Response. Page by IMSI, which would be
6894 * round-robined to another MSC, to make sure the Paging->Response relation is stronger than the NRI->MSC mapping. */
6895private function f_tc_mscpool_paging_imsi(charstring id) runs on MSC_ConnHdlr {
6896 var template BSSMAP_FIELD_CellIdentificationList cid_list := { cIl_CI := { ts_BSSMAP_CI_CI(0) } };
6897 //cid_list := { cIl_allInBSS := ''O };
6898 var RSL_ChanNeeded rsl_chneed := RSL_CHANNEED_SDCCH;
6899 var template BSSMAP_IE_ChannelNeeded bssmap_chneed := ts_BSSMAP_IE_ChanNeeded(int2bit(enum2int(valueof(rsl_chneed)),2));
6900 var BSSAP_N_UNITDATA_req paging;
6901 var hexstring imsi := '001010000000123'H;
6902
6903 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
6904
Neels Hofmeyr90f80962020-06-12 16:16:55 +02006905 paging := valueof(ts_BSSAP_UNITDATA_req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006906 valueof(ts_BSSMAP_Paging(imsi, cid_list, omit, bssmap_chneed))));
6907 BSSAP.send(paging);
6908
6909 /* Register any RSL conn so that the Paging Command gets received here. With the current RSL_Emulation's main()
6910 * handling of '[bts_role] IPA_PT.receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD()))' it doesn't matter at all which
6911 * channel number is picked here. */
6912 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(0, RSL_CHAN_NR_INVALID));
6913 f_rslem_register(0, new_chan_nr);
6914 RSL.receive(tr_RSL_PAGING_CMD(tr_MI_IMSI(imsi)));
6915 f_rslem_unregister(0, new_chan_nr);
6916
6917 /* Despite the round robin pointing at the second MSC ('roundrobin next 1'), the earlier Paging for the same IMSI
6918 * causes this Paging Response to go to the first MSC (bssap_idx := 0). */
6919 f_perform_compl_l3(RSL, ts_PAG_RESP(valueof(ts_MI_IMSI_LV(imsi))) );
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006920 f_sleep(1.0);
6921}
6922testcase TC_mscpool_paging_and_response_imsi() runs on test_CT {
6923 f_init(nr_bts := 1, handler_mode := true, nr_msc := 3);
6924 f_sleep(1.0);
6925
6926 /* Testing a Paging on the first MSC to get a Paging Response back to the first MSC. Set round robin to the
6927 * second MSC to make sure we're getting the Paging logic, not a coincidental round robin match. */
6928 f_vty_transceive(BSCVTY, "mscpool roundrobin next 1");
6929
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006930 f_ctrs_msc_init();
6931
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006932 var MSC_ConnHdlr vc_conn1;
6933 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
6934 pars1.mscpool.rsl_idx := 0;
Neels Hofmeyr90f80962020-06-12 16:16:55 +02006935 pars1.sccp_addr_bsc := g_bssap[pars1.mscpool.bssap_idx].sccp_addr_peer;
6936 pars1.sccp_addr_msc := g_bssap[pars1.mscpool.bssap_idx].sccp_addr_own;
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006937 vc_conn1 := f_start_handler(refers(f_tc_mscpool_paging_imsi), pars1);
6938 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006939 f_ctrs_msc_expect(0, "mscpool:subscr:paged");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006940 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006941}
6942
6943/* Make sure that whichever MSC paged a subscriber will also get the Paging Response. Page by TMSI with an NRI value
6944 * that matches a different MSC, to make sure the Paging->Response relation is stronger than the NRI->MSC mapping. */
6945private function f_tc_mscpool_paging_tmsi(charstring id) runs on MSC_ConnHdlr {
6946 var template BSSMAP_FIELD_CellIdentificationList cid_list := { cIl_CI := { ts_BSSMAP_CI_CI(0) } };
6947 //cid_list := { cIl_allInBSS := ''O };
6948 var RSL_ChanNeeded rsl_chneed := RSL_CHANNEED_SDCCH;
6949 var template BSSMAP_IE_ChannelNeeded bssmap_chneed := ts_BSSMAP_IE_ChanNeeded(int2bit(enum2int(valueof(rsl_chneed)),2));
6950 var integer nri_v := 300; /* <-- second MSC's NRI */
6951 var octetstring tmsi := f_tmsi_nri(nri_v);
6952 var BSSAP_N_UNITDATA_req paging;
6953
6954 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
6955
Neels Hofmeyr90f80962020-06-12 16:16:55 +02006956 paging := valueof(ts_BSSAP_UNITDATA_req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006957 valueof(ts_BSSMAP_Paging('001010000000011'H, cid_list, tmsi, bssmap_chneed))));
6958 BSSAP.send(paging);
6959
6960 /* Register any RSL conn so that the Paging Command gets received here. With the current RSL_Emulation's main()
6961 * handling of '[bts_role] IPA_PT.receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD()))' it doesn't matter at all which
6962 * channel number is picked here. */
6963 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(0, RSL_CHAN_NR_INVALID));
6964 f_rslem_register(0, new_chan_nr);
6965 RSL.receive(tr_RSL_PAGING_CMD(t_MI_TMSI(tmsi)));
6966 f_rslem_unregister(0, new_chan_nr);
6967
6968 /* Despite the NRI matching the second MSC (NRI from 'msc 1' in osmo-bsc.cfg) and round robin pointing at the
6969 * third MSC ('roundrobin next 2'), the earlier Paging for the same TMSI causes this Paging Response to go to
6970 * the first MSC (bssap_idx := 0). */
6971 f_perform_compl_l3(RSL, ts_PAG_RESP(valueof(ts_MI_TMSI_NRI_LV(nri_v))) );
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006972 f_sleep(1.0);
6973}
6974testcase TC_mscpool_paging_and_response_tmsi() runs on test_CT {
6975 f_init(nr_bts := 1, handler_mode := true, nr_msc := 3);
6976 f_sleep(1.0);
6977
6978 /* Testing a Paging on the first MSC to get a Paging Response back to the first MSC. Set round robin to the
6979 * third MSC to make sure we're getting the Paging logic, not a coincidental round robin match. */
6980 f_vty_transceive(BSCVTY, "mscpool roundrobin next 2");
6981
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006982 f_ctrs_msc_init();
6983
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006984 var MSC_ConnHdlr vc_conn1;
6985 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
6986 pars1.mscpool.rsl_idx := 0;
Neels Hofmeyr90f80962020-06-12 16:16:55 +02006987 pars1.sccp_addr_bsc := g_bssap[pars1.mscpool.bssap_idx].sccp_addr_peer;
6988 pars1.sccp_addr_msc := g_bssap[pars1.mscpool.bssap_idx].sccp_addr_own;
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006989 vc_conn1 := f_start_handler(refers(f_tc_mscpool_paging_tmsi), pars1);
6990 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006991 f_ctrs_msc_expect(0, "mscpool:subscr:paged");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006992 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006993}
6994
6995/* For round-robin, skip an MSC that has 'no allow-attach' set. */
6996/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
6997 * just as well using only RSL. */
6998testcase TC_mscpool_no_allow_attach_round_robin() runs on test_CT {
6999
7000 f_init(nr_bts := 3, handler_mode := true, nr_msc := 3);
7001 f_sleep(1.0);
Neels Hofmeyra460f1f2020-08-09 20:17:03 +00007002 /* Mark the second MSC as offloading, round-robin should skip this MSC now. */
7003 f_vty_msc_allow_attach(BSCVTY, {true, false, true});
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007004
7005 /* Control which MSC gets chosen next by the round-robin, otherwise
7006 * would be randomly affected by which other tests ran before this. */
7007 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
7008
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007009 f_ctrs_msc_init();
7010
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007011 var MSC_ConnHdlr vc_conn1;
7012 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
7013 pars1.mscpool.rsl_idx := 0;
7014 pars1.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_IMSI_LV('001010000000001'H)), '00F110'O));
7015 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
7016 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007017 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007018
7019 var MSC_ConnHdlr vc_conn2;
7020 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 2);
7021 pars2.mscpool.rsl_idx := 1;
7022 pars2.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, valueof(ts_MI_IMSI_LV('001010000000002'H))));
7023 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
7024 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007025 f_ctrs_msc_expect(2, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007026
7027 var MSC_ConnHdlr vc_conn3;
7028 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 0);
7029 pars3.mscpool.rsl_idx := 2;
7030 pars3.mscpool.l3_info := valueof(ts_PAG_RESP(valueof(ts_MI_IMSI_LV('001010000000003'H))));
7031 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
7032 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007033 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007034 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007035}
7036
7037/* An MSC that has 'no allow-attach' set should still serve subscribers that are already attached according to their
7038 * TMSI NRI. */
7039testcase TC_mscpool_no_allow_attach_valid_nri() runs on test_CT {
7040
7041 f_init(nr_bts := 3, handler_mode := true, nr_msc := 3);
7042 f_sleep(1.0);
7043
Neels Hofmeyra460f1f2020-08-09 20:17:03 +00007044 /* Mark the second MSC as offloading, round-robin should skip this MSC now. */
7045 f_vty_msc_allow_attach(BSCVTY, {true, false, true});
7046
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007047 /* Control which MSC gets chosen next by the round-robin, otherwise
7048 * would be randomly affected by which other tests ran before this. */
7049 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
7050
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007051 f_ctrs_msc_init();
7052
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007053 /* Round robin points at msc 0, but the valid NRI directs to msc 1, even though msc 1 has 'no allow-attach'. */
7054 var MSC_ConnHdlr vc_conn1;
7055 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 1);
7056 pars1.mscpool.rsl_idx := 0;
7057 /* An NRI of the second MSC's range (256-511) */
7058 pars1.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, valueof(ts_MI_TMSI_NRI_LV(260))));
7059 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
7060 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007061 f_ctrs_msc_expect(1, "mscpool:subscr:known");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007062
7063 var MSC_ConnHdlr vc_conn2;
7064 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 0);
7065 pars2.mscpool.rsl_idx := 1;
7066 pars2.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, valueof(ts_MI_IMSI_LV('001010000000002'H))));
7067 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
7068 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007069 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007070
7071 var MSC_ConnHdlr vc_conn3;
7072 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 2);
7073 pars3.mscpool.rsl_idx := 2;
7074 pars3.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, valueof(ts_MI_IMSI_LV('001010000000003'H))));
7075 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
7076 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007077 f_ctrs_msc_expect(2, "mscpool:subscr:new");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007078 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007079}
7080
Philipp Maier783681c2020-07-16 16:47:06 +02007081/* Allow/Deny emergency calls globally via VTY */
7082private function f_vty_allow_emerg_msc(boolean allow) runs on test_CT {
7083 f_vty_enter_cfg_msc(BSCVTY, 0);
7084 if (allow) {
7085 f_vty_transceive(BSCVTY, "allow-emergency allow");
7086 } else {
7087 f_vty_transceive(BSCVTY, "allow-emergency deny");
7088 }
7089 f_vty_transceive(BSCVTY, "exit");
7090 f_vty_transceive(BSCVTY, "exit");
7091}
7092
7093/* Allow/Deny emergency calls per BTS via VTY */
7094private function f_vty_allow_emerg_bts(boolean allow, integer bts_nr) runs on test_CT {
7095 f_vty_enter_cfg_bts(BSCVTY, bts_nr);
7096 if (allow) {
7097 f_vty_transceive(BSCVTY, "rach emergency call allowed 1");
7098 } else {
7099 f_vty_transceive(BSCVTY, "rach emergency call allowed 0");
7100 }
7101 f_vty_transceive(BSCVTY, "exit");
7102 f_vty_transceive(BSCVTY, "exit");
Neels Hofmeyrb6ed80c2020-10-12 22:52:39 +00007103 f_vty_transceive(BSCVTY, "exit");
Philipp Maier783681c2020-07-16 16:47:06 +02007104}
7105
7106/* Begin assignmet procedure and send an EMERGENCY SETUP (RR) */
7107private function f_assignment_emerg_setup() runs on MSC_ConnHdlr {
7108 var PDU_ML3_MS_NW emerg_setup;
7109 var octetstring emerg_setup_enc;
7110 var RSL_Message emerg_setup_data_ind;
7111
7112 f_establish_fully(omit, omit);
7113
7114 emerg_setup := valueof(ts_ML3_MO_CC_EMERG_SETUP(1, valueof(ts_Bcap_voice)));
7115 emerg_setup_enc := enc_PDU_ML3_MS_NW(emerg_setup);
7116 emerg_setup_data_ind := valueof(ts_RSL_DATA_IND(g_chan_nr, valueof(ts_RslLinkID_DCCH(0)), emerg_setup_enc));
7117
7118 RSL.send(emerg_setup_data_ind);
7119}
7120
7121/* Test if the EMERGENCY SETUP gets passed on to the MSC via A when EMERGENCY
7122 * CALLS are permitted by the BSC config. */
7123private function f_TC_assignment_emerg_setup_allow(charstring id) runs on MSC_ConnHdlr {
7124 var PDU_BSSAP emerg_setup_data_ind_bssap;
7125 var PDU_ML3_MS_NW emerg_setup;
7126 timer T := 3.0;
7127
7128 f_assignment_emerg_setup()
7129
7130 T.start;
7131 alt {
7132 [] BSSAP.receive(tr_BSSAP_DTAP) -> value emerg_setup_data_ind_bssap {
7133 emerg_setup := dec_PDU_ML3_MS_NW(emerg_setup_data_ind_bssap.pdu.dtap);
7134 if (not isbound(emerg_setup.msgs.cc.emergencySetup)) {
7135 setverdict(fail, "no emergency setup");
7136 }
7137 }
7138 [] BSSAP.receive {
7139 setverdict(fail, "unexpected BSSAP message!");
7140 }
7141 [] T.timeout {
7142 setverdict(fail, "timout waiting for EMERGENCY SETUP!");
7143 }
7144 }
7145
7146 setverdict(pass);
7147}
7148
7149/* Test if the EMERGENCY SETUP gets blocked by the BSC if EMERGENCY CALLS are
7150 * forbidden by the BSC config. */
7151private function f_TC_assignment_emerg_setup_deny(charstring id) runs on MSC_ConnHdlr {
7152 var PDU_BSSAP emerg_setup_data_ind_bssap;
7153 timer T := 3.0;
7154
7155 f_assignment_emerg_setup()
7156
7157 T.start;
7158 alt {
7159 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_RELEASE)) {
7160 setverdict(pass);
7161 }
7162 [] RSL.receive {
7163 setverdict(fail, "unexpected RSL message!");
7164 }
7165 [] T.timeout {
7166 setverdict(fail, "timout waiting for RR CHANNEL RELEASE!");
7167 }
7168 }
7169}
7170
7171/* EMERGENCY CALL situation #1, allowed globally and by BTS */
7172testcase TC_assignment_emerg_setup_allow() runs on test_CT {
7173 var TestHdlrParams pars := f_gen_test_hdlr_pars();
7174 var MSC_ConnHdlr vc_conn;
7175
7176 f_init(1, true);
7177 f_sleep(1.0);
7178
7179 f_vty_allow_emerg_msc(true);
7180 f_vty_allow_emerg_bts(true, 0);
7181 vc_conn := f_start_handler(refers(f_TC_assignment_emerg_setup_allow), pars);
7182 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007183 f_shutdown_helper();
Philipp Maier783681c2020-07-16 16:47:06 +02007184}
7185
7186/* EMERGENCY CALL situation #2, forbidden globally but allowed by BTS */
7187testcase TC_assignment_emerg_setup_deny_msc() runs on test_CT {
7188 var TestHdlrParams pars := f_gen_test_hdlr_pars();
7189 var MSC_ConnHdlr vc_conn;
7190
7191 f_init(1, true);
7192 f_sleep(1.0);
7193
7194 f_vty_allow_emerg_msc(false);
7195 f_vty_allow_emerg_bts(true, 0);
7196 vc_conn := f_start_handler(refers(f_TC_assignment_emerg_setup_deny), pars);
7197 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007198 f_shutdown_helper();
Philipp Maier783681c2020-07-16 16:47:06 +02007199}
7200
7201/* EMERGENCY CALL situation #3, allowed globally but forbidden by BTS */
7202testcase TC_assignment_emerg_setup_deny_bts() runs on test_CT {
7203 var TestHdlrParams pars := f_gen_test_hdlr_pars();
7204 var MSC_ConnHdlr vc_conn;
7205
7206 /* Note: This simulates a spec violation by the MS, correct MS
7207 * implementations would not try to establish an emergency call because
7208 * the system information tells in advance that emergency calls are
7209 * not forbidden */
7210
7211 f_init(1, true);
7212 f_sleep(1.0);
7213
7214 f_vty_allow_emerg_msc(true);
7215 f_vty_allow_emerg_bts(false, 0);
7216 vc_conn := f_start_handler(refers(f_TC_assignment_emerg_setup_deny), pars);
7217 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007218 f_shutdown_helper();
Philipp Maier783681c2020-07-16 16:47:06 +02007219}
7220
Philipp Maier82812002020-08-13 18:48:27 +02007221/* Test what happens when an emergency call arrives while all TCH channels are
7222 * busy, the BSC is expected to terminate one call in favor of the incoming
7223 * emergency call */
7224testcase TC_emerg_premption() runs on test_CT {
7225 var ASP_RSL_Unitdata rsl_ud;
7226 var integer i;
7227 var integer chreq_total, chreq_nochan;
7228 var RSL_Message rx_rsl;
7229 var RslChannelNr chan_nr;
7230
7231 f_init(1);
7232 f_sleep(1.0);
7233
7234 f_vty_allow_emerg_msc(true);
7235 f_vty_allow_emerg_bts(true, 0);
7236
7237 /* Fill up all channels on the BTS */
7238 chreq_total := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total");
7239 chreq_nochan := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:no_channel");
7240 for (i := 0; i < NUM_TCHF_PER_BTS + NUM_TCHH_PER_BTS + NUM_SDCCH_PER_BTS; i := i+1) {
7241 chan_nr := f_chreq_act_ack('33'O, i);
7242 }
7243 IPA_RSL[0].clear;
7244 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total",
7245 chreq_total + NUM_TCHF_PER_BTS + NUM_TCHH_PER_BTS + NUM_SDCCH_PER_BTS);
7246
7247 /* Send Channel request for emegergency call */
7248 f_ipa_tx(0, ts_RSL_CHAN_RQD('A5'O, 23));
7249
7250 /* Expect the BSC to release one (the first) TCH/F on the BTS */
7251 chan_nr := valueof(t_RslChanNr_Bm(1));
7252 f_expect_chan_rel(0, chan_nr, expect_rr_chan_rel := false, expect_rll_rel_req := false);
7253
7254 /* Expect the BSC to send activate/assign the a channel for the emergency call */
7255 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
7256 chan_nr := rx_rsl.ies[0].body.chan_nr;
7257 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, 33));
7258 rx_rsl := f_exp_ipa_rx(0, tr_RSL_IMM_ASSIGN(0));
Philipp Maier104f4c02020-09-11 18:12:18 +02007259
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007260 f_shutdown_helper();
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007261}
7262
7263/* Hopping parameters per a timeslot */
Vadim Yanitskiybc6654a2020-09-13 01:27:40 +07007264private type record length(0..64) of GsmArfcn ArfcnList;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007265private type record FHParamsTs {
7266 boolean enabled,
7267 uint6_t hsn,
7268 uint6_t maio,
7269 ArfcnList ma
7270};
7271
7272/* Hopping parameters per a transceiver */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007273private type record FHParamsTrx {
7274 GsmArfcn arfcn,
7275 FHParamsTs ts[8]
7276};
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007277
7278/* Randomly generate the hopping parameters for the given timeslot numbers */
7279private function f_TC_fh_params_gen(template integer tr_tn := (1, 3, 5))
7280runs on test_CT return FHParamsTrx {
7281 var FHParamsTrx fhp;
7282
Vadim Yanitskiy3e997362020-09-05 21:08:34 +07007283 /* Generate a random ARFCN, including ARFCN 0 */
7284 fhp.arfcn := f_rnd_int(3);
Vadim Yanitskiye7c8c6e2020-09-13 14:33:03 +07007285
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007286 for (var integer tn := 0; tn < 8; tn := tn + 1) {
7287 if (not match(tn, tr_tn)) {
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007288 fhp.ts[tn].enabled := false;
7289 fhp.ts[tn].ma := { };
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007290 continue;
7291 }
7292
7293 /* Random HSN / MAIO values: 0..63 */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007294 fhp.ts[tn].hsn := f_rnd_int(64);
7295 fhp.ts[tn].maio := f_rnd_int(64);
7296 fhp.ts[tn].ma := { };
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007297
7298 /* Random Mobile Allocation (hopping channels) */
7299 var integer ma_len := 2 + f_rnd_int(9); /* 2..10 channels */
7300 var integer step := 3 + f_rnd_int(4); /* 3..6 stepping */
7301 for (var integer i := 1; i <= ma_len; i := i + 1) {
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007302 fhp.ts[tn].ma := fhp.ts[tn].ma & { i * step };
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007303 }
7304
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007305 fhp.ts[tn].enabled := true;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007306 }
7307
7308 log("f_TC_fh_params_gen(): ", fhp);
7309 return fhp;
7310}
7311
7312/* Make sure that the given Channel Description IE matches the hopping configuration */
7313private function f_TC_fh_params_match_chan_desc(in FHParamsTrx fhp, in ChannelDescription cd)
7314{
7315 var template (present) ChannelDescription tr_cd;
7316 var template (present) MaioHsn tr_maio_hsn;
7317 var uint3_t tn := cd.chan_nr.tn;
7318
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007319 if (fhp.ts[tn].enabled) {
7320 tr_maio_hsn := tr_HsnMaio(fhp.ts[tn].hsn, fhp.ts[tn].maio);
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007321 tr_cd := tr_ChanDescH1(cd.chan_nr, tr_maio_hsn);
7322 } else {
Vadim Yanitskiye7c8c6e2020-09-13 14:33:03 +07007323 tr_cd := tr_ChanDescH0(cd.chan_nr, fhp.arfcn);
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007324 }
7325
7326 if (not match(cd, tr_cd)) {
7327 setverdict(fail, "Channel Description IE does not match: ",
7328 cd, " vs expected ", tr_cd);
7329 }
7330}
7331
7332/* Make sure that the given Mobile Allocation IE matches the hopping configuration */
7333private function f_TC_fh_params_match_ma(in FHParamsTrx fhp, uint3_t tn,
7334 in MobileAllocationLV ma)
7335{
7336 var template MobileAllocationLV tr_ma := f_TC_fh_params_gen_tr_ma(fhp, tn, ma);
7337
7338 if (not match(ma, tr_ma)) {
7339 setverdict(fail, "Mobile Allocation IE does not match (tn := ",
7340 tn, "): ", ma, " vs expected: ", tr_ma);
7341 } else {
7342 setverdict(pass);
7343 }
7344}
7345
7346private function f_TC_fh_params_gen_tr_ma(in FHParamsTrx fhp, uint3_t tn,
7347 in MobileAllocationLV ma)
7348return template MobileAllocationLV {
7349 /* Mobile Allocation IE is expected to be empty if hopping is not enabled */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007350 if (not fhp.ts[tn].enabled) {
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007351 return { len := 0, ma := ''B };
7352 }
7353
7354 var bitstring full_mask := f_pad_bit(''B, 1024, '0'B);
7355 var bitstring slot_mask := f_pad_bit(''B, 1024, '0'B);
7356 var bitstring ma_mask := ''B;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007357
7358 /* Compose the full bit-mask (all channels, up to 1024 entries) */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007359 for (var integer i := 0; i < lengthof(fhp.ts); i := i + 1) {
7360 for (var integer j := 0; j < lengthof(fhp.ts[i].ma); j := j + 1) {
7361 if (full_mask[fhp.ts[i].ma[j]] == '1'B)
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007362 { continue; }
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007363 full_mask[fhp.ts[i].ma[j]] := '1'B;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007364 }
7365 }
7366
Vadim Yanitskiye7c8c6e2020-09-13 14:33:03 +07007367 /* Take ARFCN of the TRX itself into account */
7368 full_mask[fhp.arfcn] := '1'B;
7369
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007370 /* Compose a bit-mask for the given timeslot number */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007371 for (var integer i := 0; i < lengthof(fhp.ts[tn].ma); i := i + 1) {
7372 slot_mask[fhp.ts[tn].ma[i]] := '1'B;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007373 }
7374
7375 /* Finally, compose the Mobile Allocation bit-mask */
Vadim Yanitskiy3e997362020-09-05 21:08:34 +07007376 for (var integer i := 1; i < lengthof(full_mask); i := i + 1) {
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007377 if (full_mask[i] != '1'B)
7378 { continue; }
7379
7380 /* FIXME: ma_mask := ma_mask & slot_mask[i]; // triggers a bug in TITAN */
7381 if (slot_mask[i] == '1'B) {
7382 ma_mask := ma_mask & '1'B;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007383 } else {
7384 ma_mask := ma_mask & '0'B;
7385 }
7386 }
7387
Vadim Yanitskiy3e997362020-09-05 21:08:34 +07007388 /* ARFCN 0 (if present) goes to the last position of the bit-mask */
7389 if (full_mask[0] == '1'B) {
7390 /* FIXME: ma_mask := ma_mask & slot_mask[0]; // triggers a bug in TITAN */
7391 if (slot_mask[0] == '1'B) {
7392 ma_mask := ma_mask & '1'B;
7393 } else {
7394 ma_mask := ma_mask & '0'B;
7395 }
7396 }
7397
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007398 /* Ensure that ma_mask is octet-aligned */
Vadim Yanitskiy2aa02522020-09-06 14:05:23 +07007399 var integer ma_mask_len := (lengthof(ma_mask) + 8 - 1) / 8;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007400 ma_mask := f_pad_bit(ma_mask, ma_mask_len * 8, '0'B);
7401
7402 return { len := ma_mask_len, ma := ma_mask };
7403}
7404
7405/* Configure the hopping parameters in accordance with the given record */
7406private function f_TC_fh_params_set(in FHParamsTrx fhp,
7407 uint8_t bts_nr := 0,
7408 uint8_t trx_nr := 0)
7409runs on test_CT {
7410 /* Enter the configuration node for the given BTS/TRX numbers */
7411 f_vty_enter_cfg_trx(BSCVTY, bts_nr, trx_nr);
7412
Vadim Yanitskiye7c8c6e2020-09-13 14:33:03 +07007413 f_vty_transceive(BSCVTY, "arfcn " & int2str(fhp.arfcn));
7414
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007415 for (var integer tn := 0; tn < lengthof(fhp.ts); tn := tn + 1) {
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007416 f_vty_transceive(BSCVTY, "timeslot " & int2str(tn));
7417
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007418 if (not fhp.ts[tn].enabled) {
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007419 f_vty_transceive(BSCVTY, "hopping enabled 0");
7420 f_vty_transceive(BSCVTY, "exit"); /* go back */
7421 continue;
7422 }
7423
7424 /* Configure HSN / MAIO values */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007425 f_vty_transceive(BSCVTY, "hopping sequence-number " & int2str(fhp.ts[tn].hsn));
7426 f_vty_transceive(BSCVTY, "hopping maio " & int2str(fhp.ts[tn].maio));
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007427
7428 /* Configure the Mobile Allocation (hopping channels) */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007429 for (var integer i := 0; i < lengthof(fhp.ts[tn].ma); i := i + 1) {
7430 f_vty_transceive(BSCVTY, "hopping arfcn add " & int2str(fhp.ts[tn].ma[i]));
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007431 }
7432
7433 f_vty_transceive(BSCVTY, "hopping enabled 1");
7434 f_vty_transceive(BSCVTY, "exit"); /* go back */
7435 }
7436
7437 f_vty_transceive(BSCVTY, "end");
7438}
7439
7440/* Disable frequency hopping on all timeslots */
7441private function f_TC_fh_params_unset(in FHParamsTrx fhp,
7442 uint8_t bts_nr := 0,
Vadim Yanitskiye7c8c6e2020-09-13 14:33:03 +07007443 uint8_t trx_nr := 0,
7444 GsmArfcn arfcn := 871)
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007445runs on test_CT {
7446 /* Enter the configuration node for the given BTS/TRX numbers */
7447 f_vty_enter_cfg_trx(BSCVTY, bts_nr, trx_nr);
7448
Vadim Yanitskiye7c8c6e2020-09-13 14:33:03 +07007449 f_vty_transceive(BSCVTY, "arfcn " & int2str(arfcn));
7450
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007451 for (var integer tn := 0; tn < lengthof(fhp.ts); tn := tn + 1) {
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007452 f_vty_transceive(BSCVTY, "timeslot " & int2str(tn));
7453
7454 /* Delete all ARFCNs from the Mobile Allocation (if any) */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007455 for (var integer i := 0; i < lengthof(fhp.ts[tn].ma); i := i + 1) {
7456 f_vty_transceive(BSCVTY, "hopping arfcn del " & int2str(fhp.ts[tn].ma[i]));
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007457 }
7458
7459 f_vty_transceive(BSCVTY, "hopping enabled 0");
7460 f_vty_transceive(BSCVTY, "exit"); /* go back */
7461 }
7462
7463 f_vty_transceive(BSCVTY, "end");
7464 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
7465}
7466
7467/* Verify presence and correctness of the hopping parameters (HSN, MAIO)
7468 * in the Channel Identification IE of the RSL CHANnel ACTIVation message. */
7469testcase TC_fh_params_chan_activ() runs on test_CT {
7470 var FHParamsTrx fhp := f_TC_fh_params_gen();
7471 var RSL_Message rsl_msg;
7472 var RSL_IE_Body ie;
7473
7474 f_init_vty();
7475
7476 f_TC_fh_params_set(fhp); /* Enable frequency hopping */
7477 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
7478
7479 f_init(1);
7480
7481 /* CS domain: 3 (SDCCH/4+CBCH) + 4 (TCH/F) + 2 (TCH/H) channels available */
7482 for (var integer i := 0; i < 9; i := i + 1) {
7483 f_ipa_tx(0, ts_RSL_CHAN_RQD(f_rnd_ra_cs(), 23));
7484 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
7485
7486 /* Make sure that Channel Identification IE is present */
7487 if (not f_rsl_find_ie(rsl_msg, RSL_IE_CHAN_IDENT, ie)) {
7488 setverdict(fail, "RSL Channel Identification IE is absent");
7489 continue;
7490 }
7491
7492 /* Make sure that hopping parameters (HSN/MAIO) match */
7493 f_TC_fh_params_match_chan_desc(fhp, ie.chan_ident.ch_desc.v);
7494
7495 /* "Mobile Allocation shall be included but empty" - let's check this */
7496 if (ie.chan_ident.ma.v.len != 0) {
7497 setverdict(fail, "Mobile Allocation IE is not empty: ",
7498 ie.chan_ident.ma, ", despite it shall be");
7499 continue;
7500 }
7501 }
7502
7503 /* Disable frequency hopping */
7504 f_TC_fh_params_unset(fhp);
7505
Vadim Yanitskiy21726312020-09-04 01:45:36 +07007506 f_shutdown_helper();
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007507}
7508
7509/* Verify the hopping parameters (HSN, MAIO, MA) in (RR) Immediate Assignment */
7510testcase TC_fh_params_imm_ass() runs on test_CT {
7511 var FHParamsTrx fhp := f_TC_fh_params_gen();
7512 var RSL_Message rsl_msg;
7513 var RSL_IE_Body ie;
7514
7515 f_init_vty();
7516
7517 f_TC_fh_params_set(fhp); /* Enable frequency hopping */
7518 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
7519
7520 f_init(1);
7521
7522 /* CS domain: 3 (SDCCH/4+CBCH) + 4 (TCH/F) + 2 (TCH/H) channels available */
7523 for (var integer i := 0; i < 9; i := i + 1) {
7524 f_ipa_tx(0, ts_RSL_CHAN_RQD(f_rnd_ra_cs(), 23));
7525 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
7526
7527 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(rsl_msg.ies[0].body.chan_nr, 33));
7528 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeC(RSL_MT_IMMEDIATE_ASSIGN_CMD));
7529
7530 /* Make sure that Full Immediate Assign Info IE is present */
7531 if (not f_rsl_find_ie(rsl_msg, RSL_IE_FULL_IMM_ASS_INFO, ie)) {
7532 setverdict(fail, "RSL Full Immediate Assign Info IE is absent");
7533 continue;
7534 }
7535
7536 /* Decode the actual Immediate Assignment message */
7537 var GsmRrMessage rr_msg := dec_GsmRrMessage(ie.full_imm_ass_info.payload);
7538 if (not match(rr_msg.header, t_RrHeader(IMMEDIATE_ASSIGNMENT, ?))) {
7539 setverdict(fail, "Failed to match Immediate Assignment: ", rr_msg);
7540 continue;
7541 }
7542
7543 /* Make sure that hopping parameters (HSN/MAIO) match */
7544 f_TC_fh_params_match_chan_desc(fhp, rr_msg.payload.imm_ass.chan_desc);
7545
7546 /* Make sure that the Mobile Allocation IE matches */
7547 f_TC_fh_params_match_ma(fhp, rr_msg.payload.imm_ass.chan_desc.chan_nr.tn,
7548 rr_msg.payload.imm_ass.mobile_allocation);
7549 }
7550
7551 /* Disable frequency hopping */
7552 f_TC_fh_params_unset(fhp);
Philipp Maier82812002020-08-13 18:48:27 +02007553
Vadim Yanitskiy21726312020-09-04 01:45:36 +07007554 f_shutdown_helper();
Philipp Maier82812002020-08-13 18:48:27 +02007555}
7556
Vadim Yanitskiyaeb54a22020-09-01 06:25:25 +07007557/* Verify the hopping parameters (HSN, MAIO, MA) in (RR) Assignment Command */
7558testcase TC_fh_params_assignment_cmd() runs on test_CT {
7559 var FHParamsTrx fhp := f_TC_fh_params_gen();
7560 var RSL_Message rsl_msg;
7561 var RSL_IE_Body ie;
7562
7563 f_init_vty();
7564
7565 f_TC_fh_params_set(fhp); /* Enable frequency hopping */
7566 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
7567
7568 f_init(1);
7569
7570 /* HACK: work around "Couldn't find Expect for CRCX" */
7571 vc_MGCP.stop;
7572
7573 var template PDU_BSSAP ass_cmd := f_gen_ass_req();
7574 ass_cmd.pdu.bssmap.assignmentRequest.codecList := ts_BSSMAP_IE_CodecList({ts_CodecFR});
7575
7576 /* CS domain (TCH): 4 (TCH/F) + 2 (TCH/H) channels available
7577 * NOTE: only 3 SDCCH/4 channels are available on CCCH+SDCCH4+CBCH */
7578 for (var integer i := 0; i < 3; i := i + 1) {
7579 /* Establish a dedicated channel, so we can trigger (late) TCH assignment */
7580 var DchanTuple dt := f_est_dchan(f_rnd_ra_cs(), 23, f_rnd_octstring(16));
7581
7582 /* Send a BSSMAP Assignment Command, expect CHANnel ACTIVation */
7583 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ass_cmd));
7584 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
7585
7586 /* ACKnowledge CHANnel ACTIVation, expect RSL DATA REQuest */
7587 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(rsl_msg.ies[0].body.chan_nr, 33));
7588 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeR(RSL_MT_DATA_REQ));
7589
7590 /* Make sure that L3 Information IE is present */
7591 if (not f_rsl_find_ie(rsl_msg, RSL_IE_L3_INFO, ie)) {
7592 setverdict(fail, "RSL L3 Information IE is absent");
7593 continue;
7594 }
7595
7596 /* Decode the L3 message and make sure it is (RR) Assignment Command */
7597 var GsmRrL3Message l3_msg := dec_GsmRrL3Message(ie.l3_info.payload);
7598 if (not match(l3_msg.header, t_RrL3Header(ASSIGNMENT_COMMAND))) {
7599 setverdict(fail, "Failed to match Assignment Command: ", l3_msg);
7600 continue;
7601 }
7602
7603 /* Make sure that hopping parameters (HSN/MAIO) match */
7604 var ChannelDescription chan_desc := l3_msg.payload.ass_cmd.chan_desc;
7605 f_TC_fh_params_match_chan_desc(fhp, chan_desc);
7606
7607 /* Make sure that Cell Channel Description IE is present if FH is enabled */
7608 if (chan_desc.h and not ispresent(l3_msg.payload.ass_cmd.cell_chan_desc)) {
Vadim Yanitskiy38d069d2020-09-02 17:18:57 +07007609 setverdict(fail, "FH enabled, but Cell Channel Description IE is absent");
Vadim Yanitskiyaeb54a22020-09-01 06:25:25 +07007610 continue;
7611 }
7612
7613 /* Make sure that the Mobile Allocation IE matches (if present) */
7614 var boolean ma_present := ispresent(l3_msg.payload.ass_cmd.mobile_allocation);
7615 if (chan_desc.h and ma_present) {
7616 f_TC_fh_params_match_ma(fhp, chan_desc.chan_nr.tn,
7617 l3_msg.payload.ass_cmd.mobile_allocation.v);
7618 } else if (chan_desc.h and not ma_present) {
7619 setverdict(fail, "FH enabled, but Mobile Allocation IE is absent");
7620 continue;
7621 } else if (not chan_desc.h and ma_present) {
7622 setverdict(fail, "FH disabled, but Mobile Allocation IE is present");
7623 continue;
7624 }
7625 }
7626
7627 /* Give the IUT some time to release all channels */
7628 f_sleep(3.0);
7629
7630 /* Disable frequency hopping */
7631 f_TC_fh_params_unset(fhp);
7632
Vadim Yanitskiy21726312020-09-04 01:45:36 +07007633 f_shutdown_helper();
Vadim Yanitskiyaeb54a22020-09-01 06:25:25 +07007634}
7635
Vadim Yanitskiy8f5430d2020-09-02 18:51:38 +07007636/* Verify the hopping parameters (HSN, MAIO, MA) in (RR) Handover Command */
7637private function f_TC_fh_params_handover_cmd(in FHParamsTrx fhp)
7638runs on test_CT {
7639 var RSL_Message rsl_msg;
7640 var RSL_IE_Body ie;
7641 var DchanTuple dt;
7642
7643 /* Establish a dedicated channel, so we can trigger handover */
7644 dt := f_est_dchan(f_rnd_ra_cs(), 23, f_rnd_octstring(16));
7645
7646 /* Trigger handover from BTS0 to BTS1 */
7647 f_bts_0_cfg(BSCVTY, { "neighbor bts 1" });
7648 f_vty_handover(BSCVTY, 0, 0, dt.rsl_chan_nr, 1);
7649
7650 /* Expect RSL CHANnel ACTIVation on BTS1/TRX0/TS1 */
7651 rsl_msg := f_exp_ipa_rx(1, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
7652
7653 /* ACKnowledge channel activation and expect (RR) Handover Command */
7654 f_ipa_tx(1, ts_RSL_CHAN_ACT_ACK(rsl_msg.ies[0].body.chan_nr, 33));
7655 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeR(RSL_MT_DATA_REQ));
7656
7657 /* Make sure that L3 Information IE is present */
7658 if (not f_rsl_find_ie(rsl_msg, RSL_IE_L3_INFO, ie)) {
7659 setverdict(fail, "RSL L3 Information IE is absent");
7660 return;
7661 }
7662
7663 /* Decode the L3 message and make sure it is (RR) Handover Command */
7664 var GsmRrL3Message l3_msg := dec_GsmRrL3Message(ie.l3_info.payload);
7665 if (not match(l3_msg.header, t_RrL3Header(HANDOVER_COMMAND))) {
7666 setverdict(fail, "Failed to match Handover Command: ", l3_msg);
7667 return;
7668 }
7669
7670 /* Make sure that we've got SDCCH/8 on TS1 (expected to be hopping) */
7671 var ChannelDescription chan_desc := l3_msg.payload.ho_cmd.chan_desc;
7672 if (not match(chan_desc.chan_nr, t_RslChanNr_SDCCH8(1, ?))) {
7673 setverdict(fail, "Unexpected channel number: ", chan_desc.chan_nr);
7674 return;
7675 }
7676
7677 /* Make sure that hopping parameters (HSN/MAIO) match */
7678 f_TC_fh_params_match_chan_desc(fhp, chan_desc);
7679
7680 /* Make sure that Cell Channel Description IE is present */
7681 if (not ispresent(l3_msg.payload.ho_cmd.cell_chan_desc)) {
7682 setverdict(fail, "FH enabled, but Cell Channel Description IE is absent");
7683 return;
7684 }
7685
7686 /* Make sure that the Mobile Allocation (after time) IE is present and matches */
7687 var boolean ma_present := ispresent(l3_msg.payload.ho_cmd.mobile_allocation);
7688 if (ma_present) {
7689 f_TC_fh_params_match_ma(fhp, chan_desc.chan_nr.tn,
7690 l3_msg.payload.ho_cmd.mobile_allocation.v);
7691 } else {
7692 setverdict(fail, "FH enabled, but Mobile Allocation IE is absent");
7693 return;
7694 }
7695}
7696testcase TC_fh_params_handover_cmd() runs on test_CT {
7697 var FHParamsTrx fhp := f_TC_fh_params_gen();
7698
7699 f_init_vty();
7700
7701 /* (Re)configure TS0 as BCCH and TS1 as SDCCH8 on BTS1/TRX0 */
7702 f_vty_enter_cfg_trx(BSCVTY, bts := 1, trx := 0);
7703
7704 f_vty_transceive(BSCVTY, "timeslot 0");
7705 f_vty_transceive(BSCVTY, "phys_chan_config ccch");
7706 f_vty_transceive(BSCVTY, "exit"); /* go back */
7707
7708 f_vty_transceive(BSCVTY, "timeslot 1");
7709 f_vty_transceive(BSCVTY, "phys_chan_config sdcch8");
7710 f_vty_transceive(BSCVTY, "end"); /* we're done */
7711
7712 f_TC_fh_params_set(fhp, 1); /* Enable frequency hopping on BTS1 */
7713 f_vty_transceive(BSCVTY, "drop bts connection 1 oml");
7714
7715 f_init(2);
7716
7717 f_TC_fh_params_handover_cmd(fhp);
7718
7719 /* Disable frequency hopping on BTS1 */
7720 f_TC_fh_params_unset(fhp, 1);
7721
7722 /* (Re)configure TS0 as CCCH+SDCCH4+CBCH and TS1 as TCH/F */
7723 f_vty_enter_cfg_trx(BSCVTY, bts := 1, trx := 0);
7724
7725 f_vty_transceive(BSCVTY, "timeslot 0");
7726 f_vty_transceive(BSCVTY, "phys_chan_config ccch+sdcch4+cbch");
7727 f_vty_transceive(BSCVTY, "exit"); /* go back */
7728
7729 f_vty_transceive(BSCVTY, "timeslot 1");
7730 f_vty_transceive(BSCVTY, "phys_chan_config tch/f");
7731 f_vty_transceive(BSCVTY, "end"); /* we're done */
7732
7733 f_shutdown_helper();
7734}
7735
Vadim Yanitskiyca974032020-09-01 07:20:39 +07007736/* Verify the hopping parameters in System Information Type 4 */
7737testcase TC_fh_params_si4_cbch() runs on test_CT {
7738 var FHParamsTrx fhp := f_TC_fh_params_gen(tr_tn := 1);
7739 var ASP_RSL_Unitdata rx_rsl_ud;
7740 timer T := 5.0;
7741
7742 f_init_vty();
7743
7744 /* (Re)configure TS0 as BCCH and TS1 as SDCCH8+CBCH */
7745 f_vty_enter_cfg_trx(BSCVTY, trx := 0);
7746
7747 f_vty_transceive(BSCVTY, "timeslot 0");
7748 f_vty_transceive(BSCVTY, "phys_chan_config ccch");
7749 f_vty_transceive(BSCVTY, "exit"); /* go back */
7750
7751 f_vty_transceive(BSCVTY, "timeslot 1");
7752 f_vty_transceive(BSCVTY, "phys_chan_config sdcch8+cbch");
7753 f_vty_transceive(BSCVTY, "end"); /* we're done */
7754
7755 f_TC_fh_params_set(fhp); /* Enable frequency hopping */
7756 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
7757
7758 f_init(1);
7759
7760 T.start;
7761 alt {
7762 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_BCCH_INFO(RSL_SYSTEM_INFO_4))) -> value rx_rsl_ud {
7763 var RSL_IE_Body ie := rx_rsl_ud.rsl.ies[2].body; /* FULL BCCH Information IE */
7764 var SystemInformation si := dec_SystemInformation(ie.other.payload);
7765
7766 /* Make sure that what we decoded is System Information Type 4 */
7767 if (si.header.message_type != SYSTEM_INFORMATION_TYPE_4) {
7768 setverdict(fail, "RSL FULL BCCH Information IE contains: ", si);
7769 repeat;
7770 }
7771
7772 /* Make sure that CBCH Channel Description IE is present */
7773 if (not ispresent(si.payload.si4.cbch_chan_desc)) {
7774 setverdict(fail, "CBCH Channel Description IE is absent");
7775 break;
7776 }
7777
7778 /* Finally, check the hopping parameters (HSN, MAIO) */
7779 var ChannelDescription chan_desc := si.payload.si4.cbch_chan_desc.v;
7780 f_TC_fh_params_match_chan_desc(fhp, chan_desc);
7781
7782 /* 3GPP TS 44.018, section 9.1.36.2 "CBCH Mobile Allocation":
7783 * The CBCH Mobile Allocation IE *shall* be present if FH is enabled. */
7784 if (chan_desc.h and not ispresent(si.payload.si4.cbch_mobile_alloc)) {
7785 setverdict(fail, "FH enabled, but Mobile Allocation IE is absent");
7786 break;
7787 } else if (chan_desc.h and ispresent(si.payload.si4.cbch_mobile_alloc)) {
7788 f_TC_fh_params_match_ma(fhp, chan_desc.chan_nr.tn,
7789 si.payload.si4.cbch_mobile_alloc.v);
7790 }
7791 }
7792 [] IPA_RSL[0].receive { repeat; }
7793 [] T.timeout {
7794 setverdict(fail, "Timeout waiting for RSL BCCH INFOrmation (SI4)");
7795 }
7796 }
7797
7798 /* Disable frequency hopping */
7799 f_TC_fh_params_unset(fhp);
7800
Vadim Yanitskiy8bc46012020-09-06 12:38:01 +07007801 /* (Re)configure TS0 as CCCH+SDCCH4+CBCH and TS1 as TCH/F */
Vadim Yanitskiyca974032020-09-01 07:20:39 +07007802 f_vty_enter_cfg_trx(BSCVTY, trx := 0);
7803
7804 f_vty_transceive(BSCVTY, "timeslot 0");
Vadim Yanitskiy8bc46012020-09-06 12:38:01 +07007805 f_vty_transceive(BSCVTY, "phys_chan_config ccch+sdcch4+cbch");
Vadim Yanitskiyca974032020-09-01 07:20:39 +07007806 f_vty_transceive(BSCVTY, "exit"); /* go back */
7807
7808 f_vty_transceive(BSCVTY, "timeslot 1");
7809 f_vty_transceive(BSCVTY, "phys_chan_config tch/f");
7810 f_vty_transceive(BSCVTY, "end"); /* we're done */
7811
Vadim Yanitskiy21726312020-09-04 01:45:36 +07007812 f_shutdown_helper();
Vadim Yanitskiyca974032020-09-01 07:20:39 +07007813}
7814
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02007815template (value) PDU_BSSAP_LE ts_BSSMAP_LE_BSSLAP(template (value) BSSLAP_PDU bsslap)
7816 := ts_BSSMAP_LE_ConnInfo(BSSMAP_LE_PROT_BSSLAP, data := enc_BSSLAP_PDU(valueof(bsslap)));
7817
7818private function f_match_bsslap(PDU_BSSAP_LE got_bsslap_msg,
7819 template (present) BSSLAP_PDU expect_bsslap)
7820{
7821 var BSSLAP_PDU bsslap := dec_BSSLAP_PDU(got_bsslap_msg.pdu.bssmap.co_info.bsslap_apdu.data);
7822 if (not match(bsslap, expect_bsslap)) {
7823 log("EXPECTING BSSLAP: ", expect_bsslap);
7824 log("GOT BSSLAP: ", bsslap);
7825 setverdict(fail, "BSSLAP is not as expected");
7826 mtc.stop;
7827 }
7828 setverdict(pass);
7829}
7830
7831/* GAD: this is an Ellipsoid point with uncertainty circle, encoded as in 3GPP TS 23.032 §7.3.2. */
7832const octetstring gad_ell_point_unc_circle := '10b0646d0d5f6627'O;
7833
7834private function f_expect_bsslap(template (present) BSSLAP_PDU expect_rx_bsslap) runs on MSC_ConnHdlr {
7835 var PDU_BSSAP_LE rx_bsslap;
7836 BSSAP_LE.receive(tr_BSSMAP_LE_ConnInfo(BSSMAP_LE_PROT_BSSLAP, ?)) -> value(rx_bsslap);
7837 f_match_bsslap(rx_bsslap, expect_rx_bsslap);
7838}
7839
7840/* With an active lchan, start BSSMAP Perform Location Request on A interface, starting BSSMAP-LE Perform Location
7841 * Request on Lb interface. Either with or without the SMLC doing a BSSLAP TA Request. */
7842private function f_lcs_loc_req_for_active_ms(boolean do_ta_request := false) runs on MSC_ConnHdlr {
7843 f_sleep(1.0);
7844
7845 f_establish_fully(omit, omit);
7846 f_bssap_le_register_imsi(g_pars.imsi, omit);
7847
7848 BSSAP.send(valueof(ts_BSSMAP_Perform_Location_Request(ts_BSSMAP_Imsi(g_pars.imsi),
7849 ts_CellId_CGI('262'H, '42'H, 23, 42))));
7850
7851 var PDU_BSSAP_LE plr;
7852 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocReq(BSSMAP_LE_LOC_INFO_CURRENT_GEOGRAPHIC_LOC, ?, ?)) -> value(plr);
7853
7854 if (not do_ta_request) {
7855 /* verify TA Layer 3 in APDU. First the APDU type (BSSLAP), then the BSSLAP data contents. */
7856 var template BSSMAP_LE_IE_APDU expect_apdu := tr_BSSMAP_LE_APDU(BSSMAP_LE_PROT_BSSLAP, ?);
7857 if (not match(plr.pdu.bssmap.perf_loc_req.bsslap_apdu, expect_apdu)) {
7858 log("EXPECTING BSSMAP-LE APDU IE ", expect_apdu);
7859 log("GOT BSSMAP-LE APDU IE ", plr.pdu.bssmap.perf_loc_req.bsslap_apdu);
7860 setverdict(fail, "BSSMAP-LE APDU IE is not as expected");
7861 mtc.stop;
7862 }
7863 var template BSSLAP_PDU expect_ta_layer3 := tr_BSSLAP_TA_Layer3(tr_BSSLAP_IE_TA(0));
7864 var BSSLAP_PDU bsslap := dec_BSSLAP_PDU(plr.pdu.bssmap.perf_loc_req.bsslap_apdu.data);
7865 if (not match(bsslap, expect_ta_layer3)) {
7866 log("EXPECTING BSSLAP TA Layer 3: ", expect_ta_layer3);
7867 log("GOT BSSLAP: ", bsslap);
7868 setverdict(fail, "BSSLAP is not as expected");
7869 mtc.stop;
7870 }
7871 /* OsmoBSC directly sent the TA as BSSLAP APDU in the BSSMAP-LE Perform Location Request to the SMLC. The SMLC
7872 * has no need to request the TA from the BSC and directly responds. */
7873 } else {
7874 /* SMLC wants to ask the TA from the BSC explicitly in a BSSLAP TA Request message */
7875 BSSAP_LE.send(ts_BSSMAP_LE_BSSLAP(ts_BSSLAP_TA_Req));
7876 f_expect_bsslap(tr_BSSLAP_TA_Resp(?, ?));
7877 }
7878
7879 /* SMLC got the TA from the BSC, now responds with geo information data. */
7880 BSSAP_LE.send(ts_BSSMAP_LE_PerfLocResp(gad_ell_point_unc_circle, omit));
7881 BSSAP_LE.receive(BSSAP_LE_Conn_Prim:CONN_PRIM_DISC_IND);
7882 BSSAP.receive(tr_BSSMAP_Perform_Location_Response(tr_BSSMAP_IE_LocationEstimate(gad_ell_point_unc_circle)));
7883
7884 /* The LCS was using an active A-interface conn. It should still remain active after this. */
7885 f_mo_l3_transceive();
7886
7887 f_perform_clear(RSL);
7888
7889 f_sleep(2.0);
7890 setverdict(pass);
7891}
7892
7893/* With an active lchan, start BSSMAP Perform Location Request on A interface, starting BSSMAP-LE Perform Location
7894 * Request on Lb interface. Without the SMLC doing a BSSLAP TA Request. */
7895private function f_tc_lcs_loc_req_for_active_ms(charstring id) runs on MSC_ConnHdlr {
7896 f_lcs_loc_req_for_active_ms(false);
7897}
7898testcase TC_lcs_loc_req_for_active_ms() runs on test_CT {
7899 var MSC_ConnHdlr vc_conn;
7900 var TestHdlrParams pars := f_gen_test_hdlr_pars();
7901
7902 f_init(1, true);
7903 f_sleep(1.0);
7904 vc_conn := f_start_handler(refers(f_tc_lcs_loc_req_for_active_ms), pars);
7905 vc_conn.done;
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01007906 f_shutdown_helper();
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02007907}
7908
7909/* With an active lchan, start BSSMAP Perform Location Request on A interface, starting BSSMAP-LE Perform Location
7910 * Request on Lb interface. With the SMLC doing a BSSLAP TA Request. */
7911private function f_tc_lcs_loc_req_for_active_ms_ta_req(charstring id) runs on MSC_ConnHdlr {
7912 f_lcs_loc_req_for_active_ms(true);
7913}
7914testcase TC_lcs_loc_req_for_active_ms_ta_req() runs on test_CT {
7915 var MSC_ConnHdlr vc_conn;
7916 var TestHdlrParams pars := f_gen_test_hdlr_pars();
7917
7918 f_init(1, true);
7919 f_sleep(1.0);
7920 vc_conn := f_start_handler(refers(f_tc_lcs_loc_req_for_active_ms_ta_req), pars);
7921 vc_conn.done;
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01007922 f_shutdown_helper();
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02007923}
7924
7925/* Clear the A-interface conn only, without doing anything on Abis. Useful for LCS, for cases where there is only an A
7926 * conn without an active lchan. */
7927private function f_clear_A_conn() runs on MSC_ConnHdlr
7928{
7929 var BssmapCause cause := 0;
7930 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
7931 BSSAP.receive(tr_BSSMAP_ClearComplete);
7932 BSSAP.send(RAN_Conn_Prim:MSC_CONN_PRIM_DISC_REQ);
7933
7934 timer no_more_bssap := 5.0;
7935 no_more_bssap.start;
7936 alt {
7937 [] no_more_bssap.timeout { break; }
7938 [] BSSAP.receive(tr_BSSAP_BSSMAP) {
7939 setverdict(fail, "Expected no more BSSAP after Clear Complete");
7940 mtc.stop;
7941 }
7942 }
7943 setverdict(pass);
7944}
7945
7946/* Verify that the A-interface connection is still working, and then clear it, without doing anything on Abis. Useful
7947 * for LCS, for cases where there is only an A conn without an active lchan. */
7948private function f_verify_active_A_conn_and_clear() runs on MSC_ConnHdlr
7949{
7950 f_logp(BSCVTY, "f_verify_active_A_conn_and_clear: test A link, then clear");
7951
7952 /* When an lchan is active, we can send some L3 data from the BTS side and verify that it shows up on the other
7953 * side towards the MSC. When there is no lchan, this is not possible. To probe whether the A-interface
7954 * connection is still up, we need something that echos back on the A-interface. Another LCS request! */
7955 BSSAP.send(valueof(ts_BSSMAP_Perform_Location_Request(ts_BSSMAP_Imsi(g_pars.imsi),
7956 ts_CellId_CGI('262'H, '42'H, 23, 42))));
7957 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocReq(BSSMAP_LE_LOC_INFO_CURRENT_GEOGRAPHIC_LOC, ?, ?));
7958
7959 /* Right, the Perform Location Request showed up on Lb, now we can clear the A conn. */
7960 f_clear_A_conn();
7961 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocAbort(BSSMAP_LE_LCS_CAUSE_REQUEST_ABORTED));
7962 BSSAP_LE.receive(BSSAP_LE_Conn_Prim:CONN_PRIM_DISC_IND);
7963}
7964
7965/* With *no* active lchan, start BSSMAP Perform Location Request on A interface, starting BSSMAP-LE Perform Location
7966 * Request on Lb interface. BSC will Page for the subscriber as soon as we (virtual SMLC) request the TA via BSSLAP.
7967 */
7968private function f_tc_lcs_loc_req_for_idle_ms(charstring id) runs on MSC_ConnHdlr {
7969 f_sleep(1.0);
7970
7971 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
7972 f_bssap_le_register_imsi(g_pars.imsi, omit);
7973
7974 /* Register to receive the Paging Command */
7975 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
7976 g_chan_nr := new_chan_nr;
7977 f_rslem_register(0, g_chan_nr);
7978
7979 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
7980 valueof(ts_BSSMAP_Perform_Location_Request(ts_BSSMAP_Imsi(g_pars.imsi),
7981 ts_CellId_CGI('001'H, '01'H, 1, 0)))));
7982 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
7983
7984 var PDU_BSSAP_LE plr;
7985 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocReq(BSSMAP_LE_LOC_INFO_CURRENT_GEOGRAPHIC_LOC, ?, ?)) -> value(plr);
7986
7987 /* SMLC wants to ask the TA from the BSC explicitly in a BSSLAP TA Request message */
7988 BSSAP_LE.send(ts_BSSMAP_LE_BSSLAP(ts_BSSLAP_TA_Req));
7989
7990 /* OsmoBSC needs to Page */
7991 RSL.receive(tr_RSL_PAGING_CMD(tr_MI_IMSI(g_pars.imsi)));
7992 f_logp(BSCVTY, "got Paging Command");
7993
7994 /* MS requests channel. Since the Paging was for LCS, the Paging Response does not trigger a Complete Layer 3 to
7995 * the MSC, and releases the lchan directly. */
7996 f_perform_compl_l3(RSL, ts_PAG_RESP(valueof(ts_MI_IMSI_LV(g_pars.imsi))), do_clear := false, expect_bssmap_l3 := false);
7997 f_expect_lchan_rel(RSL);
7998
7999 /* From the Paging Response, the TA is now known to the BSC, and it responds to the SMLC. */
8000
8001 f_expect_bsslap(tr_BSSLAP_TA_Resp(?, ?));
8002
8003 /* SMLC got the TA from the BSC, now responds with geo information data. */
8004 BSSAP_LE.send(ts_BSSMAP_LE_PerfLocResp(gad_ell_point_unc_circle, omit));
8005 BSSAP_LE.receive(BSSAP_LE_Conn_Prim:CONN_PRIM_DISC_IND);
8006
8007 BSSAP.receive(tr_BSSMAP_Perform_Location_Response(tr_BSSMAP_IE_LocationEstimate(gad_ell_point_unc_circle)));
8008
8009 /* The lchan is gone, the A-interface conn was created for the LCS only.
8010 * Still it is clearly the MSC's job to decide whether to tear down the conn or not. */
8011 f_verify_active_A_conn_and_clear();
8012
8013 f_sleep(2.0);
8014 setverdict(pass);
8015}
8016testcase TC_lcs_loc_req_for_idle_ms() runs on test_CT {
8017 var MSC_ConnHdlr vc_conn;
8018 var TestHdlrParams pars := f_gen_test_hdlr_pars();
8019
8020 f_init(1, true);
8021 f_sleep(1.0);
8022
8023 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
8024 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
8025
8026 vc_conn := f_start_handler(refers(f_tc_lcs_loc_req_for_idle_ms), pars);
8027 vc_conn.done;
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01008028 f_shutdown_helper();
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02008029}
8030
8031/* With no active lchan, start BSSMAP Perform Location Request on A interface, but omit IMSI; expect failure response.
8032 */
8033private function f_tc_lcs_loc_req_no_subscriber(charstring id) runs on MSC_ConnHdlr {
8034 f_sleep(1.0);
8035
8036 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
8037 f_bssap_le_register_imsi(g_pars.imsi, omit);
8038
8039 /* provoke an abort by omitting both IMSI and IMEI */
8040 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
8041 valueof(ts_BSSMAP_Perform_Location_Request(omit,
8042 ts_CellId_CGI('262'H, '42'H, 23, 42)))));
8043 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
8044
8045 /* BSC tells MSC about failure */
8046 BSSAP.receive(tr_BSSMAP_Perform_Location_Response(
8047 locationEstimate := omit, positioningData := omit,
8048 lCS_Cause := tr_BSSMAP_LcsCause(BSSMAP_LCS_CAUSE_DATA_MISSING_IN_REQ)));
8049
8050 /* There is no lchan. Still the MSC's job to decide whether to tear down the conn or not. */
8051 f_verify_active_A_conn_and_clear();
8052
8053 f_sleep(2.0);
8054 setverdict(pass);
8055}
8056testcase TC_lcs_loc_req_no_subscriber() runs on test_CT {
8057 var MSC_ConnHdlr vc_conn;
8058 var TestHdlrParams pars := f_gen_test_hdlr_pars();
8059
8060 f_init(1, true);
8061 f_sleep(1.0);
8062
8063 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
8064 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
8065
8066 vc_conn := f_start_handler(refers(f_tc_lcs_loc_req_no_subscriber), pars);
8067 vc_conn.done;
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01008068 f_shutdown_helper();
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02008069}
8070
8071/* With an active lchan, start a Perform Location Request on the A-interface, but virtual SMLC does not answer with
8072 * BSSMAP-LE Perform Location Response (before or after sending a BSSLAP TA Request) */
8073private function f_lcs_loc_req_for_active_ms_le_timeout(boolean do_ta) runs on MSC_ConnHdlr {
8074 f_sleep(1.0);
8075
8076 f_establish_fully(omit, omit);
8077 f_bssap_le_register_imsi(g_pars.imsi, omit);
8078
8079 BSSAP.send(valueof(ts_BSSMAP_Perform_Location_Request(ts_BSSMAP_Imsi(g_pars.imsi),
8080 ts_CellId_CGI('262'H, '42'H, 23, 42))));
8081
8082 var PDU_BSSAP_LE plr;
8083 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocReq(BSSMAP_LE_LOC_INFO_CURRENT_GEOGRAPHIC_LOC, ?, ?)) -> value(plr);
8084
8085 if (do_ta) {
8086 /* SMLC wants to ask the TA from the BSC explicitly in a BSSLAP TA Request message */
8087 BSSAP_LE.send(ts_BSSMAP_LE_BSSLAP(ts_BSSLAP_TA_Req));
8088 f_expect_bsslap(tr_BSSLAP_TA_Resp(?, ?));
8089 }
8090
8091 /* SMLC fails to respond, BSC runs into timeout */
8092 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocAbort(BSSMAP_LE_LCS_CAUSE_SYSTEM_FAILURE));
8093 BSSAP_LE.receive(BSSAP_LE_Conn_Prim:CONN_PRIM_DISC_IND);
8094
8095 BSSAP.receive(tr_BSSMAP_Perform_Location_Response(
8096 locationEstimate := omit, positioningData := omit,
8097 lCS_Cause := tr_BSSMAP_LcsCause(BSSMAP_LCS_CAUSE_SYSTEM_FAILURE)));
8098
8099 /* There is no lchan. Still the MSC's job to decide whether to tear down the conn or not. */
8100 f_verify_active_A_conn_and_clear();
8101
8102 f_sleep(2.0);
8103 setverdict(pass);
8104}
8105
8106/* With an active lchan, start a Perform Location Request on the A-interface, but virtual SMLC does not answer with
8107 * BSSMAP-LE Perform Location Response, without sending a BSSLAP TA Request. */
8108private function f_tc_lcs_loc_req_for_active_ms_le_timeout(charstring id) runs on MSC_ConnHdlr {
8109 f_lcs_loc_req_for_active_ms_le_timeout(false);
8110}
8111
8112testcase TC_lcs_loc_req_for_active_ms_le_timeout() runs on test_CT {
8113 var MSC_ConnHdlr vc_conn;
8114 var TestHdlrParams pars := f_gen_test_hdlr_pars();
8115
8116 f_init(1, true);
8117 f_sleep(1.0);
8118 vc_conn := f_start_handler(refers(f_tc_lcs_loc_req_for_active_ms_le_timeout), pars);
8119 vc_conn.done;
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01008120 f_shutdown_helper();
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02008121}
8122
8123/* With an active lchan, start a Perform Location Request on the A-interface, but virtual SMLC does not answer with
8124 * BSSMAP-LE Perform Location Response, after sending a BSSLAP TA Request. */
8125private function f_tc_lcs_loc_req_for_active_ms_le_timeout2(charstring id) runs on MSC_ConnHdlr {
8126 f_lcs_loc_req_for_active_ms_le_timeout(true);
8127}
8128
8129testcase TC_lcs_loc_req_for_active_ms_le_timeout2() runs on test_CT {
8130 var MSC_ConnHdlr vc_conn;
8131 var TestHdlrParams pars := f_gen_test_hdlr_pars();
8132
8133 f_init(1, true);
8134 f_sleep(1.0);
8135 vc_conn := f_start_handler(refers(f_tc_lcs_loc_req_for_active_ms_le_timeout2), pars);
8136 vc_conn.done;
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01008137 f_shutdown_helper();
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02008138}
8139
8140/* With *no* active lchan, start a Perform Location Request, expecting that the MS will be Paged. */
8141private function f_tc_lcs_loc_req_for_idle_ms_no_pag_resp(charstring id) runs on MSC_ConnHdlr {
8142 f_sleep(1.0);
8143
8144 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
8145 f_bssap_le_register_imsi(g_pars.imsi, omit);
8146
8147 /* Register to receive the Paging Command */
8148 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
8149 g_chan_nr := new_chan_nr;
8150 f_rslem_register(0, g_chan_nr);
8151
8152 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
8153 valueof(ts_BSSMAP_Perform_Location_Request(ts_BSSMAP_Imsi(g_pars.imsi),
8154 ts_CellId_CGI('001'H, '01'H, 1, 0)))));
8155 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
8156
8157 var PDU_BSSAP_LE plr;
8158 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocReq(BSSMAP_LE_LOC_INFO_CURRENT_GEOGRAPHIC_LOC, ?, ?)) -> value(plr);
8159
8160 /* SMLC wants to ask the TA from the BSC explicitly in a BSSLAP TA Request message */
8161 BSSAP_LE.send(ts_BSSMAP_LE_BSSLAP(ts_BSSLAP_TA_Req));
8162
8163 /* OsmoBSC needs to Page */
8164 var PDU_BSSAP_LE rx_bsslap;
8165 alt {
8166 [] RSL.receive(tr_RSL_PAGING_CMD(tr_MI_IMSI(g_pars.imsi))) {
8167 f_logp(BSCVTY, "got Paging Command");
8168 repeat;
8169 }
8170 [] BSSAP_LE.receive(tr_BSSMAP_LE_ConnInfo(BSSMAP_LE_PROT_BSSLAP, ?)) -> value(rx_bsslap) {
8171 /* MS does not respond to Paging, TA Req runs into timeout. */
8172 f_match_bsslap(rx_bsslap, tr_BSSLAP_Abort(?));
8173 }
8174 }
8175
8176 /* SMLC responds with failure */
8177 BSSAP_LE.send(ts_BSSMAP_LE_PerfLocResp(omit, BSSMAP_LE_LCS_CAUSE_REQUEST_ABORTED));
8178 BSSAP_LE.receive(BSSAP_LE_Conn_Prim:CONN_PRIM_DISC_IND);
8179
8180 /* BSC tells MSC about failure */
8181 BSSAP.receive(tr_BSSMAP_Perform_Location_Response(
8182 locationEstimate := omit, positioningData := omit,
8183 lCS_Cause := tr_BSSMAP_LcsCause(BSSMAP_LCS_CAUSE_REQUEST_ABORTED)));
8184
8185 /* There is no lchan. Still the MSC's job to decide whether to tear down the conn or not. */
8186 f_verify_active_A_conn_and_clear();
8187
8188 f_sleep(2.0);
8189 setverdict(pass);
8190}
8191testcase TC_lcs_loc_req_for_idle_ms_no_pag_resp() runs on test_CT {
8192 var MSC_ConnHdlr vc_conn;
8193 var TestHdlrParams pars := f_gen_test_hdlr_pars();
8194
8195 f_init(1, true);
8196 f_sleep(1.0);
8197
8198 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
8199 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
8200
8201 vc_conn := f_start_handler(refers(f_tc_lcs_loc_req_for_idle_ms_no_pag_resp), pars);
8202 vc_conn.done;
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01008203 f_shutdown_helper();
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02008204}
8205
8206/* During an ongoing Location Request, the MS sends a CM Service Request. Expect the same A-conn to be re-used / taken
8207 * over. */
8208private function f_tc_cm_service_during_lcs_loc_req(charstring id) runs on MSC_ConnHdlr {
8209 f_sleep(1.0);
8210
8211 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
8212 f_bssap_le_register_imsi(g_pars.imsi, omit);
8213
8214 /* Register to receive the Paging Command */
8215 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
8216 g_chan_nr := new_chan_nr;
8217 f_rslem_register(0, g_chan_nr);
8218
8219 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
8220 valueof(ts_BSSMAP_Perform_Location_Request(ts_BSSMAP_Imsi(g_pars.imsi),
8221 ts_CellId_CGI('001'H, '01'H, 1, 0)))));
8222 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
8223
8224 var PDU_BSSAP_LE plr;
8225 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocReq(BSSMAP_LE_LOC_INFO_CURRENT_GEOGRAPHIC_LOC, ?, ?)) -> value(plr);
8226
8227 /* As the A-interface conn was established for LCS, the MS coincidentally decides to issue a CM Service Request
8228 * and establish Layer 3. It should use the existing A-interface conn. */
8229 f_perform_compl_l3(RSL, valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, valueof(ts_MI_IMSI_LV(g_pars.imsi)))),
8230 do_clear := false, expect_bssmap_l3 := true);
8231
8232 /* SMLC wants to ask the TA from the BSC explicitly in a BSSLAP TA Request message */
8233 BSSAP_LE.send(ts_BSSMAP_LE_BSSLAP(ts_BSSLAP_TA_Req));
8234
8235 /* OsmoBSC already has an lchan, no need to Page, just returns the TA */
8236 f_expect_bsslap(tr_BSSLAP_TA_Resp(?, ?));
8237
8238 /* SMLC got the TA from the BSC, now responds with geo information data. */
8239 BSSAP_LE.send(ts_BSSMAP_LE_PerfLocResp(gad_ell_point_unc_circle, omit));
8240 BSSAP_LE.receive(BSSAP_LE_Conn_Prim:CONN_PRIM_DISC_IND);
8241 BSSAP.receive(tr_BSSMAP_Perform_Location_Response(tr_BSSMAP_IE_LocationEstimate(gad_ell_point_unc_circle)));
8242
8243 /* The lchan should still exist, it was from a CM Service Request. */
8244 f_mo_l3_transceive();
8245
8246 f_perform_clear(RSL);
8247
8248 f_sleep(2.0);
8249 setverdict(pass);
8250}
8251testcase TC_cm_service_during_lcs_loc_req() runs on test_CT {
8252 var MSC_ConnHdlr vc_conn;
8253 var TestHdlrParams pars := f_gen_test_hdlr_pars();
8254
8255 f_init(1, true);
8256 f_sleep(1.0);
8257
8258 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
8259 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
8260
8261 vc_conn := f_start_handler(refers(f_tc_cm_service_during_lcs_loc_req), pars);
8262 vc_conn.done;
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01008263 f_shutdown_helper();
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02008264}
8265
8266/* During an ongoing Perform Location Request, do a Handover, an expect a BSSLAP Reset message from the BSC to indicate
8267 * the new lchan after handover. */
8268private function f_tc_ho_during_lcs_loc_req(charstring id) runs on MSC_ConnHdlr {
8269 f_sleep(1.0);
8270
8271 f_establish_fully(omit, omit);
8272 f_bssap_le_register_imsi(g_pars.imsi, omit);
8273
8274 BSSAP.send(valueof(ts_BSSMAP_Perform_Location_Request(ts_BSSMAP_Imsi(g_pars.imsi),
8275 ts_CellId_CGI('262'H, '42'H, 23, 42))));
8276
8277 var PDU_BSSAP_LE plr;
8278 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocReq(BSSMAP_LE_LOC_INFO_CURRENT_GEOGRAPHIC_LOC, ?, ?)) -> value(plr);
8279
8280 /* SMLC ponders the Location Request, in the meantime the BSC decides to handover */
8281 f_bts_0_cfg(BSCVTY, {"neighbor bts 1"});
8282
8283 var HandoverState hs := {
8284 rr_ho_cmpl_seen := false,
8285 handover_done := false,
8286 old_chan_nr := -
8287 };
8288 /* issue hand-over command on VTY */
8289 f_vty_handover(BSCVTY, 0, 0, g_chan_nr, 1);
8290 /* temporarily suspend DChan processing on BTS1 to avoid race with RSLEM_register */
8291 f_rslem_suspend(RSL1_PROC);
8292
8293 /* From the MGW perspective, a handover is is characterized by
8294 * performing one MDCX operation with the MGW. So we expect to see
8295 * one more MDCX during handover. */
8296 g_media.mgcp_conn[0].mdcx_seen_exp := g_media.mgcp_conn[0].crcx_seen_exp + 1;
8297
8298 alt {
8299 [] as_handover(hs);
8300 }
8301
8302 var PDU_BSSAP_LE rx_bsslap;
8303
8304 interleave {
8305 /* Expect the BSC to inform the MSC about the handover */
8306 [] BSSAP.receive(tr_BSSMAP_HandoverPerformed);
8307
8308 /* Expect the BSC to inform the SMLC about the handover */
8309 [] BSSAP_LE.receive(tr_BSSMAP_LE_ConnInfo(BSSMAP_LE_PROT_BSSLAP, ?)) -> value(rx_bsslap) {
8310 f_match_bsslap(rx_bsslap, tr_BSSLAP_Reset(BSSLAP_CAUSE_INTRA_BSS_HO));
8311 }
8312 }
8313
8314 /* SMLC now responds with geo information data. */
8315 BSSAP_LE.send(ts_BSSMAP_LE_PerfLocResp(gad_ell_point_unc_circle, omit));
8316 BSSAP_LE.receive(BSSAP_LE_Conn_Prim:CONN_PRIM_DISC_IND);
8317 BSSAP.receive(tr_BSSMAP_Perform_Location_Response(tr_BSSMAP_IE_LocationEstimate(gad_ell_point_unc_circle)));
8318
8319 /* lchan still active */
8320 f_mo_l3_transceive(RSL1);
8321
8322 /* MSC decides it is done now. */
8323 f_perform_clear(RSL1);
8324
8325 f_sleep(2.0);
8326 setverdict(pass);
8327}
8328testcase TC_ho_during_lcs_loc_req() runs on test_CT {
8329 var MSC_ConnHdlr vc_conn;
8330 var TestHdlrParams pars := f_gen_test_hdlr_pars();
8331
8332 f_init(2, true);
8333 f_sleep(1.0);
8334 vc_conn := f_start_handler(refers(f_tc_ho_during_lcs_loc_req), pars);
8335 vc_conn.done;
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01008336 f_shutdown_helper();
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02008337}
8338
Neels Hofmeyrbf037052020-10-28 22:52:02 +00008339/* Attempt Complete Layer 3 without any MSC available (OS#4832) */
8340private function f_tc_no_msc(charstring id) runs on MSC_ConnHdlr {
8341 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
8342
8343 /* Also disable attach for the single connected MSC */
8344 f_vty_msc_allow_attach(BSCVTY, { false });
8345
8346 var octetstring l3_enc := enc_PDU_ML3_MS_NW(valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_IMSI_LV('001010000100001'H)), '00F110'O) ));
8347 f_chan_est(g_pars.ra, l3_enc, g_pars.link_id, g_pars.fn);
8348
8349 /* No MSC is found, expecting a proper release on RSL */
8350 interleave {
8351 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_RELEASE)) {
8352 f_logp(BSCVTY, "Got RSL RR Release");
8353 }
8354 [] RSL.receive(tr_RSL_DEACT_SACCH(g_chan_nr)) {
8355 f_logp(BSCVTY, "Got RSL Deact SACCH");
8356 }
8357 [] RSL.receive(tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL)) {
8358 f_logp(BSCVTY, "Got RSL RF Chan Rel, sending Rel Ack");
8359 RSL.send(ts_RSL_RF_CHAN_REL_ACK(g_chan_nr));
8360 }
8361 }
8362 setverdict(pass);
8363}
8364testcase TC_no_msc() runs on test_CT {
8365
8366 f_init(1, true);
8367 f_sleep(1.0);
8368 var MSC_ConnHdlr vc_conn;
8369 var TestHdlrParams pars := f_gen_test_hdlr_pars();
8370
8371 f_ctrs_bsc_init(counternames_bsc_mscpool);
8372
8373 vc_conn := f_start_handler(refers(f_tc_no_msc), pars);
8374 vc_conn.done;
8375
8376 f_ctrs_bsc_add("mscpool:subscr:no_msc");
8377 f_ctrs_bsc_verify();
Vadim Yanitskiy8ca840e2021-01-03 14:16:35 +01008378 f_shutdown_helper();
Neels Hofmeyrbf037052020-10-28 22:52:02 +00008379}
8380
Harald Welte0ea2d5e2018-04-07 21:40:29 +02008381/* Dyn PDCH todo:
8382 * activate OSMO as TCH/F
8383 * activate OSMO as TCH/H
8384 * does the BSC-located PCU socket get the updated INFO?
8385 * what if no PCU is connected at the time?
8386 * is the info correct on delayed PCU (re)connect?
8387 */
Harald Welte94e0c342018-04-07 11:33:23 +02008388
Harald Welte28d943e2017-11-25 15:00:50 +01008389control {
Harald Welte898113b2018-01-31 18:32:21 +01008390 /* CTRL interface testing */
Harald Welte4003d112017-12-09 22:35:39 +01008391 execute( TC_ctrl_msc_connection_status() );
Stefan Sperlingb041b3d2018-01-03 17:14:55 +01008392 execute( TC_ctrl_msc0_connection_status() );
Harald Welte96c94412017-12-09 03:12:45 +01008393 execute( TC_ctrl() );
Neels Hofmeyrf246a922020-05-13 02:27:10 +02008394 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_SCCPlite_SERVER) {
Pau Espin Pedrol5a2d7432019-06-07 19:43:45 +02008395 execute( TC_ctrl_location() );
8396 }
Harald Welte898113b2018-01-31 18:32:21 +01008397
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +02008398 execute( TC_si_default() );
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02008399 execute( TC_si2quater_2_earfcns() );
8400 execute( TC_si2quater_3_earfcns() );
8401 execute( TC_si2quater_4_earfcns() );
8402 execute( TC_si2quater_5_earfcns() );
8403 execute( TC_si2quater_6_earfcns() );
Neels Hofmeyrad132f22020-07-08 02:20:16 +02008404 execute( TC_si2quater_12_earfcns() );
8405 execute( TC_si2quater_23_earfcns() );
8406 execute( TC_si2quater_32_earfcns() );
8407 execute( TC_si2quater_33_earfcns() );
8408 execute( TC_si2quater_42_earfcns() );
8409 execute( TC_si2quater_48_earfcns() );
8410 execute( TC_si2quater_49_earfcns() );
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02008411 execute( TC_si_acc_rotate() );
Alexander Couzens4ad3a352020-09-10 22:29:12 +02008412 execute( TC_si_acc_ramp_rotate() );
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +02008413
Harald Welte898113b2018-01-31 18:32:21 +01008414 /* RSL DCHAN Channel ACtivation / Deactivation */
Harald Welteae026692017-12-09 01:03:01 +01008415 execute( TC_chan_act_noreply() );
Harald Welte4003d112017-12-09 22:35:39 +01008416 execute( TC_chan_act_counter() );
Harald Welteae026692017-12-09 01:03:01 +01008417 execute( TC_chan_act_ack_noest() );
Philipp Maier9c60a622020-07-09 15:08:46 +02008418 execute( TC_chan_act_ack_noest_emerg() );
Philipp Maier606f07d2020-08-12 17:21:58 +02008419 execute( TC_chan_rqd_emerg_deny() );
Harald Welteae026692017-12-09 01:03:01 +01008420 execute( TC_chan_act_ack_est_ind_noreply() );
8421 execute( TC_chan_act_ack_est_ind_refused() );
Harald Welte618ef642017-12-14 14:58:20 +01008422 execute( TC_chan_act_nack() );
Harald Welte799c97b2017-12-14 17:50:30 +01008423 execute( TC_chan_exhaustion() );
Vadim Yanitskiy1ff1fdf2018-11-27 01:32:57 +07008424 execute( TC_chan_deact_silence() );
Harald Welte4003d112017-12-09 22:35:39 +01008425 execute( TC_chan_rel_rll_rel_ind() );
8426 execute( TC_chan_rel_conn_fail() );
8427 execute( TC_chan_rel_hard_clear() );
Harald Welte99787102019-02-04 10:41:36 +01008428 execute( TC_chan_rel_hard_clear_csfb() );
Harald Welted8c36cd2017-12-09 23:05:31 +01008429 execute( TC_chan_rel_hard_rlsd() );
Harald Welte550daf92018-06-11 19:22:13 +02008430 execute( TC_chan_rel_hard_rlsd_ms_dead() );
Harald Welte85804d42017-12-10 14:11:58 +01008431 execute( TC_chan_rel_a_reset() );
Pau Espin Pedrolc675b612020-01-09 19:55:40 +01008432 execute( TC_chan_rel_sccp_tiar_timeout() );
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02008433 execute( TC_chan_rel_rr_cause() );
Harald Welte6f521d82017-12-11 19:52:02 +01008434
Harald Weltecfe2c962017-12-15 12:09:32 +01008435 execute( TC_outbound_connect() );
Harald Welte898113b2018-01-31 18:32:21 +01008436
8437 /* Assignment related */
Harald Welte16a4adf2017-12-14 18:54:01 +01008438 execute( TC_assignment_cic_only() );
Harald Welte235ebf12017-12-15 14:18:16 +01008439 execute( TC_assignment_csd() );
8440 execute( TC_assignment_ctm() );
8441 execute( TC_assignment_sign() );
Pau Espin Pedrol07866632020-09-03 19:10:55 +02008442 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
8443 execute( TC_assignment_aoip_tla_v6() );
8444 }
Harald Welte235ebf12017-12-15 14:18:16 +01008445 execute( TC_assignment_fr_a5_0() );
8446 execute( TC_assignment_fr_a5_1() );
Neels Hofmeyrf246a922020-05-13 02:27:10 +02008447 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
Harald Welte8f67d1d2018-05-25 20:38:42 +02008448 execute( TC_assignment_fr_a5_1_codec_missing() );
8449 }
Harald Welte235ebf12017-12-15 14:18:16 +01008450 execute( TC_assignment_fr_a5_3() );
8451 execute( TC_assignment_fr_a5_4() );
Harald Welte3c86ea02018-05-10 22:28:05 +02008452 execute( TC_ciph_mode_a5_0() );
8453 execute( TC_ciph_mode_a5_1() );
8454 execute( TC_ciph_mode_a5_3() );
Harald Welte16a4adf2017-12-14 18:54:01 +01008455
Harald Welte60aa5762018-03-21 19:33:13 +01008456 execute( TC_assignment_codec_fr() );
8457 execute( TC_assignment_codec_hr() );
8458 execute( TC_assignment_codec_efr() );
8459 execute( TC_assignment_codec_amr_f() );
8460 execute( TC_assignment_codec_amr_h() );
Philipp Maier8a581d22019-03-26 18:32:48 +01008461
Neels Hofmeyrf246a922020-05-13 02:27:10 +02008462 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
Philipp Maier8a581d22019-03-26 18:32:48 +01008463 execute( TC_assignment_codec_amr_f_S1() );
8464 execute( TC_assignment_codec_amr_h_S1() );
8465 execute( TC_assignment_codec_amr_f_S124() );
8466 execute( TC_assignment_codec_amr_h_S124() );
8467 execute( TC_assignment_codec_amr_f_S0() );
8468 execute( TC_assignment_codec_amr_f_S02() );
8469 execute( TC_assignment_codec_amr_f_S024() );
8470 execute( TC_assignment_codec_amr_f_S0247() );
8471 execute( TC_assignment_codec_amr_h_S0() );
8472 execute( TC_assignment_codec_amr_h_S02() );
8473 execute( TC_assignment_codec_amr_h_S024() );
8474 execute( TC_assignment_codec_amr_h_S0247() );
8475 execute( TC_assignment_codec_amr_f_S01234567() );
8476 execute( TC_assignment_codec_amr_f_S0234567() );
8477 execute( TC_assignment_codec_amr_f_zero() );
8478 execute( TC_assignment_codec_amr_f_unsupp() );
8479 execute( TC_assignment_codec_amr_h_S7() );
Neels Hofmeyr21863562020-11-26 00:34:33 +00008480 execute( TC_assignment_codec_amr_f_start_mode_auto() );
8481 execute( TC_assignment_codec_amr_h_start_mode_auto() );
Neels Hofmeyr3eb94562020-11-26 02:40:26 +00008482 execute( TC_assignment_codec_amr_f_start_mode_4() );
8483 execute( TC_assignment_codec_amr_h_start_mode_4() );
Neels Hofmeyr454d7922020-11-26 02:24:57 +00008484 execute( TC_assignment_codec_amr_startmode_cruft() );
Philipp Maier8a581d22019-03-26 18:32:48 +01008485 }
Harald Welte60aa5762018-03-21 19:33:13 +01008486
Philipp Maierac09bfc2019-01-08 13:41:39 +01008487 execute( TC_assignment_codec_fr_exhausted_req_hr() );
8488 execute( TC_assignment_codec_fr_exhausted_req_fr() );
8489 execute( TC_assignment_codec_fr_exhausted_req_fr_hr() );
8490 execute( TC_assignment_codec_fr_exhausted_req_hr_fr() );
8491 execute( TC_assignment_codec_hr_exhausted_req_fr() );
8492 execute( TC_assignment_codec_hr_exhausted_req_hr() );
8493 execute( TC_assignment_codec_hr_exhausted_req_hr_fr() );
8494 execute( TC_assignment_codec_hr_exhausted_req_fr_hr() );
8495 execute( TC_assignment_codec_req_hr_fr() );
8496 execute( TC_assignment_codec_req_fr_hr() );
8497
Pau Espin Pedrol58cf6822019-05-28 18:11:33 +02008498 if (mp_enable_osmux_test) {
8499 execute( TC_assignment_osmux() );
8500 }
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02008501
Harald Welte898113b2018-01-31 18:32:21 +01008502 /* RLL Establish Indication on inactive DCHAN / SAPI */
Harald Welte5cd20ed2017-12-13 21:03:20 +01008503 execute( TC_rll_est_ind_inact_lchan() );
8504 execute( TC_rll_est_ind_inval_sapi1() );
8505 execute( TC_rll_est_ind_inval_sapi3() );
8506 execute( TC_rll_est_ind_inval_sacch() );
8507
Vadim Yanitskiy61f784a2020-10-01 21:12:19 +07008508 /* DLCI / RSL Link ID conversion for MO/MT messages on SAPI0/SAPI3 */
8509 execute( TC_tch_dlci_link_id_sapi() );
8510
Vadim Yanitskiy6ef5dfa2020-08-28 18:04:41 +07008511 /* SAPI N Reject triggered by RLL establishment failures */
8512 execute( TC_rll_rel_ind_sapi_n_reject() );
8513 execute( TC_rll_err_ind_sapi_n_reject() );
8514 execute( TC_rll_timeout_sapi_n_reject() );
8515
Harald Welte898113b2018-01-31 18:32:21 +01008516 /* Paging related tests */
Harald Welte6f521d82017-12-11 19:52:02 +01008517 execute( TC_paging_imsi_nochan() );
8518 execute( TC_paging_tmsi_nochan() );
8519 execute( TC_paging_tmsi_any() );
8520 execute( TC_paging_tmsi_sdcch() );
8521 execute( TC_paging_tmsi_tch_f() );
8522 execute( TC_paging_tmsi_tch_hf() );
8523 execute( TC_paging_imsi_nochan_cgi() );
8524 execute( TC_paging_imsi_nochan_lac_ci() );
8525 execute( TC_paging_imsi_nochan_ci() );
8526 execute( TC_paging_imsi_nochan_lai() );
8527 execute( TC_paging_imsi_nochan_lac() );
8528 execute( TC_paging_imsi_nochan_all() );
Harald Welte751d3eb2018-01-31 15:51:06 +01008529 execute( TC_paging_imsi_nochan_plmn_lac_rnc() );
8530 execute( TC_paging_imsi_nochan_rnc() );
8531 execute( TC_paging_imsi_nochan_lac_rnc() );
8532 execute( TC_paging_imsi_nochan_lacs() );
8533 execute( TC_paging_imsi_nochan_lacs_empty() );
Stefan Sperling049a86e2018-03-20 15:51:00 +01008534 execute( TC_paging_imsi_nochan_cgi_unknown_cid() );
Harald Welte10985002017-12-12 09:29:15 +01008535 execute( TC_paging_imsi_a_reset() );
Harald Weltee65d40e2017-12-13 00:09:06 +01008536 execute( TC_paging_imsi_load() );
Philipp Maier779a7922018-02-16 11:00:37 +01008537 execute( TC_paging_counter() );
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01008538 execute( TC_paging_resp_unsol() );
Harald Welte4e9b9cc2017-12-14 18:31:02 +01008539
8540 execute( TC_rsl_drop_counter() );
Stefan Sperling830dc9d2018-02-12 21:08:28 +01008541 execute( TC_rsl_unknown_unit_id() );
8542
8543 execute( TC_oml_unknown_unit_id() );
Harald Welte898113b2018-01-31 18:32:21 +01008544
8545 execute( TC_classmark() );
Harald Welteeddf0e92020-06-21 19:42:15 +02008546 execute( TC_common_id() );
Harald Welte898113b2018-01-31 18:32:21 +01008547 execute( TC_unsol_ass_fail() );
Harald Welteea99a002018-01-31 20:46:43 +01008548 execute( TC_unsol_ass_compl() );
Harald Weltefbf9b5e2018-01-31 20:41:23 +01008549 execute( TC_unsol_ho_fail() );
Harald Weltee3bd6582018-01-31 22:51:25 +01008550 execute( TC_err_82_short_msg() );
Harald Weltee9e02e42018-01-31 23:36:25 +01008551 execute( TC_err_84_unknown_msg() );
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01008552
Harald Welte261af4b2018-02-12 21:20:39 +01008553 execute( TC_ho_int() );
Neels Hofmeyr5f144212020-11-03 15:41:58 +00008554 execute( TC_ho_int_radio_link_failure() );
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01008555
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01008556 execute( TC_ho_out_of_this_bsc() );
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02008557 execute( TC_ho_out_fail_no_msc_response() );
8558 execute( TC_ho_out_fail_rr_ho_failure() );
Neels Hofmeyrd8a602c2019-07-09 19:46:01 +02008559 execute( TC_ho_out_fail_no_result_after_ho_cmd() );
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01008560
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01008561 execute( TC_ho_into_this_bsc() );
Pau Espin Pedrol07866632020-09-03 19:10:55 +02008562 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
8563 execute( TC_ho_into_this_bsc_tla_v6() );
8564 }
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01008565 execute( TC_ho_in_fail_msc_clears() );
8566 execute( TC_ho_in_fail_msc_clears_after_ho_detect() );
8567 execute( TC_ho_in_fail_no_detect() );
8568 execute( TC_ho_in_fail_no_detect2() );
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01008569
Neels Hofmeyr91401012019-07-11 00:42:35 +02008570 execute( TC_ho_neighbor_config_1() );
8571 execute( TC_ho_neighbor_config_2() );
8572 execute( TC_ho_neighbor_config_3() );
8573 execute( TC_ho_neighbor_config_4() );
8574 execute( TC_ho_neighbor_config_5() );
8575 execute( TC_ho_neighbor_config_6() );
8576 execute( TC_ho_neighbor_config_7() );
8577
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01008578 execute( TC_bssap_rlsd_does_not_cause_bssmap_reset() );
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01008579 execute( TC_bssmap_clear_does_not_cause_bssmap_reset() );
Neels Hofmeyrfd445c32018-03-09 15:39:31 +01008580 execute( TC_ms_rel_ind_does_not_cause_bssmap_reset() );
Harald Welte94e0c342018-04-07 11:33:23 +02008581
8582 execute( TC_dyn_pdch_ipa_act_deact() );
8583 execute( TC_dyn_pdch_ipa_act_nack() );
8584 execute( TC_dyn_pdch_osmo_act_deact() );
8585 execute( TC_dyn_pdch_osmo_act_nack() );
Harald Welte99f3ca02018-06-14 13:40:29 +02008586
Stefan Sperling0796a822018-10-05 13:01:39 +02008587 execute( TC_chopped_ipa_ping() );
Stefan Sperlingaa1e60f2018-10-15 16:34:07 +02008588 execute( TC_chopped_ipa_payload() );
Stefan Sperling0796a822018-10-05 13:01:39 +02008589
Pau Espin Pedrol8f773632019-11-05 11:46:53 +01008590 /* Power control related */
8591 execute( TC_assignment_verify_ms_power_params_ie() );
Neels Hofmeyr4f118412020-06-04 15:25:10 +02008592
8593 /* MSC pooling */
8594 /* FIXME: in SCCPlite, indicating how many MSCs should be connected does currently not work. Since
8595 * RESET->RESET-ACK is unconditionally negotiated for all configured MSCs, they always all appear as connected
8596 * to osmo-bsc. The MSC pooling tests however require disconnecting selected MSCs, and hence don't work out as
8597 * intended on SCCPlite. So for now, run these only for SCCP/M3UA. */
8598 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
8599 execute( TC_mscpool_L3Compl_on_1_msc() );
8600 execute( TC_mscpool_L3Complete_by_imsi_round_robin() );
8601 execute( TC_mscpool_LU_by_tmsi_null_nri_0_round_robin() );
8602 execute( TC_mscpool_LU_by_tmsi_null_nri_1_round_robin() );
8603 execute( TC_mscpool_L3Complete_by_tmsi_unassigned_nri_round_robin() );
8604 execute( TC_mscpool_L3Complete_by_tmsi_valid_nri_msc_not_connected_round_robin() );
8605 execute( TC_mscpool_L3Complete_by_tmsi_valid_nri_1() );
8606 execute( TC_mscpool_L3Complete_by_tmsi_valid_nri_2() );
8607 execute( TC_mscpool_LU_by_tmsi_from_other_PLMN() );
8608 execute( TC_mscpool_paging_and_response_imsi() );
8609 execute( TC_mscpool_paging_and_response_tmsi() );
8610 execute( TC_mscpool_no_allow_attach_round_robin() );
8611 execute( TC_mscpool_no_allow_attach_valid_nri() );
8612 }
8613
Harald Welte99f3ca02018-06-14 13:40:29 +02008614 /* at bottom as they might crash OsmoBSC before OS#3182 is fixed */
8615 execute( TC_early_conn_fail() );
8616 execute( TC_late_conn_fail() );
8617
Philipp Maier783681c2020-07-16 16:47:06 +02008618 /* Emergency call handling (deny / allow) */
8619 execute( TC_assignment_emerg_setup_allow() );
8620 execute( TC_assignment_emerg_setup_deny_msc() );
8621 execute( TC_assignment_emerg_setup_deny_bts() );
Philipp Maier82812002020-08-13 18:48:27 +02008622 execute( TC_emerg_premption() );
8623
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008624 /* Frequency hopping parameters handling */
8625 execute( TC_fh_params_chan_activ() );
8626 execute( TC_fh_params_imm_ass() );
Vadim Yanitskiyaeb54a22020-09-01 06:25:25 +07008627 execute( TC_fh_params_assignment_cmd() );
Vadim Yanitskiy8f5430d2020-09-02 18:51:38 +07008628 execute( TC_fh_params_handover_cmd() );
Vadim Yanitskiyca974032020-09-01 07:20:39 +07008629 execute( TC_fh_params_si4_cbch() );
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02008630
8631 if (mp_enable_lcs_tests) {
8632 execute( TC_lcs_loc_req_for_active_ms() );
8633 execute( TC_lcs_loc_req_for_active_ms_ta_req() );
8634 execute( TC_lcs_loc_req_for_idle_ms() );
8635 execute( TC_lcs_loc_req_no_subscriber() );
8636 execute( TC_lcs_loc_req_for_active_ms_le_timeout() );
8637 execute( TC_lcs_loc_req_for_active_ms_le_timeout2() );
8638 execute( TC_lcs_loc_req_for_idle_ms_no_pag_resp() );
8639 execute( TC_cm_service_during_lcs_loc_req() );
8640 execute( TC_ho_during_lcs_loc_req() );
8641 }
Neels Hofmeyrbf037052020-10-28 22:52:02 +00008642
8643 execute( TC_no_msc() );
Harald Welte28d943e2017-11-25 15:00:50 +01008644}
8645
8646}