blob: 175b820dcf4054aab452e5031b72f8ea3aea42f8 [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 }
1254}
1255
Harald Welteae026692017-12-09 01:03:01 +01001256/* Test behavior if MSC never answers to CR */
1257testcase TC_chan_act_ack_est_ind_noreply() runs on test_CT {
Harald Weltef77aef62018-01-28 15:35:42 +01001258 var RslLinkId main_dcch := valueof(ts_RslLinkID_DCCH(0));
1259 var IpaStreamId sid := IPAC_PROTO_RSL_TRX0;
Harald Welteae026692017-12-09 01:03:01 +01001260 var RSL_Message rx_rsl;
Harald Weltef77aef62018-01-28 15:35:42 +01001261 var ASP_RSL_Unitdata rx_rsl_ud;
Harald Welteae026692017-12-09 01:03:01 +01001262
Harald Welte89d42e82017-12-17 16:42:41 +01001263 f_init(1);
Harald Welteae026692017-12-09 01:03:01 +01001264
1265 /* Send CHAN RQD and wait for allocation; acknowledge it */
Harald Welted6939652017-12-13 21:02:46 +01001266 var RslChannelNr chan_nr := f_chreq_act_ack();
Harald Welteae026692017-12-09 01:03:01 +01001267
1268 var octetstring l3 := '00010203040506'O
1269 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
1270
1271 BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3)));
1272
1273 /* expect BSC to disable the channel again if there's no response from MSC */
Harald Weltef77aef62018-01-28 15:35:42 +01001274 /* MS waits 20s (T3210) at LU; 10s (T3230) at CM SERV REQ and 5s (T3220) AT detach */
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001275 f_expect_chan_rel(0, chan_nr, expect_rll_rel_req := false);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001276 f_shutdown_helper();
Harald Welteae026692017-12-09 01:03:01 +01001277}
1278
1279/* Test behavior if MSC answers with CREF to CR */
1280testcase TC_chan_act_ack_est_ind_refused() runs on test_CT {
1281 var BSSAP_N_CONNECT_ind rx_c_ind;
1282 var RSL_Message rx_rsl;
1283
Harald Welte89d42e82017-12-17 16:42:41 +01001284 f_init(1);
Harald Welteae026692017-12-09 01:03:01 +01001285
1286 /* Send CHAN RQD and wait for allocation; acknowledge it */
Harald Welted6939652017-12-13 21:02:46 +01001287 var RslChannelNr chan_nr := f_chreq_act_ack();
Harald Welteae026692017-12-09 01:03:01 +01001288
1289 var octetstring l3 := '00010203040506'O
1290 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
1291
1292 BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) -> value rx_c_ind;
1293 BSSAP.send(ts_BSSAP_DISC_req(rx_c_ind.connectionId, 0));
1294
1295 /* expect BSC to disable the channel */
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001296 f_expect_chan_rel(0, chan_nr, expect_rll_rel_req := false);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001297 f_shutdown_helper();
Harald Welteae026692017-12-09 01:03:01 +01001298}
1299
Harald Welte618ef642017-12-14 14:58:20 +01001300/* CHAN RQD -> CHAN ACT -> CHAN ACT NACK -> RF CHAN REL */
1301testcase TC_chan_act_nack() runs on test_CT {
1302 var RSL_Message rx_rsl;
1303 var integer chact_nack;
1304
Harald Welte89d42e82017-12-17 16:42:41 +01001305 f_init(1);
Harald Welte618ef642017-12-14 14:58:20 +01001306
1307 chact_nack := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chan_act:nack");
1308
1309 f_ipa_tx(0, ts_RSL_CHAN_RQD('33'O, 33));
1310 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
1311 var RslChannelNr chan_nr := rx_rsl.ies[0].body.chan_nr;
1312
1313 f_ipa_tx(0, ts_RSL_CHAN_ACT_NACK(chan_nr, RSL_ERR_EQUIPMENT_FAIL));
1314
1315 /* wait for some time to hope the NACK arrives before the CTRL GET below */
1316 f_sleep(0.5);
1317
1318 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chan_act:nack", chact_nack+1);
1319
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001320 f_shutdown_helper();
Harald Welte618ef642017-12-14 14:58:20 +01001321}
1322
Harald Welte799c97b2017-12-14 17:50:30 +01001323/* Test for channel exhaustion due to RACH overload */
1324testcase TC_chan_exhaustion() runs on test_CT {
1325 var ASP_RSL_Unitdata rsl_ud;
1326 var integer i;
1327 var integer chreq_total, chreq_nochan;
1328
Harald Welte89d42e82017-12-17 16:42:41 +01001329 f_init(1);
Harald Welte799c97b2017-12-14 17:50:30 +01001330
1331 chreq_total := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total");
1332 chreq_nochan := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:no_channel");
1333
Pau Espin Pedrolfe200d72018-12-10 12:41:04 +01001334 /* GSM 04.08 Table 9.9a:
1335 * RA = '33'O -> Establishment cause = 0011xxxx (MS dual rate capable and asks for "TCH/H or TCH/F").
1336 * With current setup, expect 4xSDCCH + 4xTCH/F + 1xTCH/H to succeed */
Philipp Maiercb6cc482018-03-26 13:08:00 +02001337 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 +01001338 var RslChannelNr chan_nr := f_chreq_act_ack('33'O, i);
Harald Welte799c97b2017-12-14 17:50:30 +01001339 }
1340
1341 IPA_RSL[0].clear;
1342
Harald Weltedd8cbf32018-01-28 12:07:52 +01001343 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total",
Philipp Maiercb6cc482018-03-26 13:08:00 +02001344 chreq_total + NUM_TCHF_PER_BTS + NUM_TCHH_PER_BTS + NUM_SDCCH_PER_BTS);
Harald Welte799c97b2017-12-14 17:50:30 +01001345
1346 /* now expect additional channel activations to fail */
1347 f_ipa_tx(0, ts_RSL_CHAN_RQD('42'O, 42));
1348
1349 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001350 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV))) {
Harald Welte799c97b2017-12-14 17:50:30 +01001351 setverdict(fail, "Received CHAN ACT ACK without resources?!?");
1352 }
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001353 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_IMM_ASSIGN(?))) -> value rsl_ud {
Harald Welte799c97b2017-12-14 17:50:30 +01001354 var GsmRrMessage rr;
1355 /* match on IMM ASS REJ */
1356 rr := dec_GsmRrMessage(rsl_ud.rsl.ies[1].body.full_imm_ass_info.payload);
1357 if (rr.header.message_type == IMMEDIATE_ASSIGNMENT_REJECT) {
1358 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total",
Philipp Maiercb6cc482018-03-26 13:08:00 +02001359 chreq_total + NUM_TCHF_PER_BTS + NUM_TCHH_PER_BTS + NUM_SDCCH_PER_BTS+1);
Harald Welte799c97b2017-12-14 17:50:30 +01001360 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:no_channel",
1361 chreq_nochan+1);
1362 setverdict(pass);
1363 } else {
1364 repeat;
1365 }
1366 }
1367 [] IPA_RSL[0].receive { repeat; }
1368 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001369 f_shutdown_helper();
Harald Welte799c97b2017-12-14 17:50:30 +01001370}
1371
Vadim Yanitskiy1ff1fdf2018-11-27 01:32:57 +07001372/* Test channel deactivation due to silence from MS */
1373testcase TC_chan_deact_silence() runs on test_CT {
1374 var RslChannelNr chan_nr;
1375
1376 f_init(1);
1377
1378 /* Request for a dedicated channel */
1379 chan_nr := f_chreq_act_ack('23'O);
1380
1381 /* Wait some time until the channel is released */
1382 f_sleep(2.0);
1383
1384 /* Expect CHANnel RELease */
1385 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001386 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL))) {
Vadim Yanitskiy1ff1fdf2018-11-27 01:32:57 +07001387 log("Received CHANnel RELease");
1388 setverdict(pass);
1389 }
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001390 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_IMM_ASSIGN(?))) {
Vadim Yanitskiy1ff1fdf2018-11-27 01:32:57 +07001391 /* See OS#3709, OsmoBSC should not send Immediate
1392 * Assignment Reject since a dedicated channel was
1393 * already allocated, and Immediate Assignment was
1394 * already sent. */
1395 setverdict(fail, "Unexpected Immediate Assignment!");
1396 }
1397 [] IPA_RSL[0].receive {
1398 setverdict(fail, "Unexpected RSL message!");
1399 }
1400 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001401 f_shutdown_helper();
Vadim Yanitskiy1ff1fdf2018-11-27 01:32:57 +07001402}
1403
Harald Weltecfe2c962017-12-15 12:09:32 +01001404/***********************************************************************
1405 * Assignment Testing
1406 ***********************************************************************/
1407
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02001408/* Verify that the BSC refuses any BSSAP connection from the MSC (They are all BSC->MSC direction,
1409 * except for the inter-BSC handover, MT side) */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001410testcase TC_outbound_connect(integer bssap_idx := 0) runs on test_CT {
Harald Welte89d42e82017-12-17 16:42:41 +01001411 f_init(1);
Harald Weltecfe2c962017-12-15 12:09:32 +01001412
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001413 BSSAP.send(ts_BSSAP_CONNECT_req(g_bssap[bssap_idx].sccp_addr_peer, g_bssap[bssap_idx].sccp_addr_own,
1414 2342, ts_BSSMAP_AssignmentReq));
Harald Weltecfe2c962017-12-15 12:09:32 +01001415 BSSAP.receive(tr_BSSAP_DISC_ind(2342, ?, ?));
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001416 f_shutdown_helper();
Harald Weltecfe2c962017-12-15 12:09:32 +01001417}
1418
Harald Welte16a4adf2017-12-14 18:54:01 +01001419/* Test behavior if MSC answers with CREF to CR */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001420testcase TC_assignment_cic_only(integer bssap_idx := 0) runs on test_CT {
Harald Welte16a4adf2017-12-14 18:54:01 +01001421 var BSSAP_N_CONNECT_ind rx_c_ind;
1422 var RSL_Message rx_rsl;
1423 var DchanTuple dt;
1424
Harald Welte89d42e82017-12-17 16:42:41 +01001425 f_init(1);
Harald Welte16a4adf2017-12-14 18:54:01 +01001426
1427 dt := f_est_dchan('23'O, 23, '00000000'O);
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001428 if (mp_bssap_cfg[bssap_idx].transport == BSSAP_TRANSPORT_AoIP) {
Harald Welte17b27da2018-05-25 20:33:53 +02001429 /* send assignment without AoIP IEs */
1430 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_AssignmentReq(ts_BSSMAP_IE_CIC(0, 1))));
1431 } else {
1432 /* Send assignmetn without CIC in IPA case */
1433 var BSSMAP_IE_AoIP_TransportLayerAddress tla :=
1434 valueof(ts_BSSMAP_IE_AoIP_TLA4('01020304'O, 2342));
1435 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_AssignmentReq(omit, tla)));
1436 }
Harald Welte16a4adf2017-12-14 18:54:01 +01001437 alt {
1438 [] BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_AssignmentComplete)) {
1439 setverdict(fail, "AoIP BSC cannot accept ASSIGNMENT without AoIP Transport IE");
1440 }
Harald Welte235ebf12017-12-15 14:18:16 +01001441 /* TODO: Actually expect GSM0808_CAUSE_REQ_A_IF_TYPE_NOT_SUPP */
Harald Welte16a4adf2017-12-14 18:54:01 +01001442 [] BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_AssignmentFail)) {
1443 setverdict(pass);
1444 }
1445 [] BSSAP.receive { repeat; }
1446 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001447 f_shutdown_helper();
Harald Welte16a4adf2017-12-14 18:54:01 +01001448}
1449
Harald Welteed848512018-05-24 22:27:58 +02001450/* generate an assignment request for either AoIP or SCCPlite */
Pau Espin Pedrol07866632020-09-03 19:10:55 +02001451function 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 +02001452 var PDU_BSSAP ass_cmd;
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02001453 var BSSMAP_IE_Osmo_OsmuxCID osmux_cid := valueof(ts_OsmuxCID(0));
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001454 if (mp_bssap_cfg[bssap_idx].transport == BSSAP_TRANSPORT_AoIP) {
Harald Welteed848512018-05-24 22:27:58 +02001455 var BSSMAP_IE_AoIP_TransportLayerAddress tla :=
Pau Espin Pedrol07866632020-09-03 19:10:55 +02001456 valueof(f_ts_BSSMAP_IE_AoIP_TLA(aoip_tla, 2342));
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02001457 if (osmux_enabled) {
1458 ass_cmd := valueof(ts_BSSMAP_AssignmentReq(omit, tla, osmux_cid));
1459 } else {
1460 ass_cmd := valueof(ts_BSSMAP_AssignmentReq(omit, tla));
1461 }
Harald Welteed848512018-05-24 22:27:58 +02001462 } else {
1463 var BSSMAP_IE_CircuitIdentityCode cic := valueof(ts_BSSMAP_IE_CIC(0,1));
Pau Espin Pedrol096d73d2019-06-06 12:49:17 +02001464 ass_cmd := valueof(ts_BSSMAP_AssignmentReq(cic, omit));
Harald Welteed848512018-05-24 22:27:58 +02001465 }
1466 return ass_cmd;
1467}
1468
Pau Espin Pedrol07866632020-09-03 19:10:55 +02001469function 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 +01001470 var PDU_BSSAP ho_req;
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001471 if (mp_bssap_cfg[bssap_idx].transport == BSSAP_TRANSPORT_AoIP) {
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01001472 var BSSMAP_IE_AoIP_TransportLayerAddress tla :=
Pau Espin Pedrol07866632020-09-03 19:10:55 +02001473 valueof(f_ts_BSSMAP_IE_AoIP_TLA(aoip_tla, 2342));
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01001474 ho_req := valueof(ts_BSSMAP_HandoverRequest(omit, tla));
1475 } else {
1476 var BSSMAP_IE_CircuitIdentityCode cic := valueof(ts_BSSMAP_IE_CIC(0,1));
1477 ho_req := valueof(ts_BSSMAP_HandoverRequest(cic, omit));
1478 }
1479 return ho_req;
1480}
1481
Harald Welteed848512018-05-24 22:27:58 +02001482/* generate an assignment complete template for either AoIP or SCCPlite */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001483function f_gen_exp_compl(boolean expect_osmux := false, integer bssap_idx := 0) return template PDU_BSSAP {
Harald Welteed848512018-05-24 22:27:58 +02001484 var template PDU_BSSAP exp_compl;
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02001485 var BSSMAP_IE_Osmo_OsmuxCID osmux_cid := valueof(ts_OsmuxCID(0));
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001486 if (mp_bssap_cfg[bssap_idx].transport == BSSAP_TRANSPORT_AoIP) {
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02001487 if (expect_osmux) {
1488 exp_compl := tr_BSSMAP_AssignmentComplete(omit, ?, osmux_cid);
1489 } else {
1490 exp_compl := tr_BSSMAP_AssignmentComplete(omit, ?, omit);
1491 }
Harald Welteed848512018-05-24 22:27:58 +02001492 } else {
1493 /* CIC is optional "*" as the MSC allocated it */
Pau Espin Pedrol096d73d2019-06-06 12:49:17 +02001494 exp_compl := tr_BSSMAP_AssignmentComplete(*, omit);
Harald Welteed848512018-05-24 22:27:58 +02001495 }
1496 return exp_compl;
1497}
1498
Harald Welte235ebf12017-12-15 14:18:16 +01001499/* Run everything required up to sending a caller-specified assignment command and expect response */
1500function f_assignment_exp(PDU_BSSAP ass_cmd, template PDU_BSSAP exp, charstring fail_text)
1501runs on test_CT {
1502 var BSSAP_N_CONNECT_ind rx_c_ind;
1503 var RSL_Message rx_rsl;
1504 var DchanTuple dt;
1505
Harald Welte89d42e82017-12-17 16:42:41 +01001506 f_init(1);
Harald Welte235ebf12017-12-15 14:18:16 +01001507
1508 dt := f_est_dchan('23'O, 23, '00000000'O);
1509 /* send assignment without AoIP IEs */
1510 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ass_cmd));
1511 alt {
1512 [] BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_AssignmentComplete)) {
1513 if (ischosen(exp.pdu.bssmap.assignmentComplete)) {
1514 setverdict(pass);
1515 } else {
1516 setverdict(fail, fail_text);
1517 }
1518 }
1519 [] BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_AssignmentFail)) {
1520 if (ischosen(exp.pdu.bssmap.assignmentFailure)) {
1521 setverdict(pass);
1522 } else {
1523 setverdict(fail, fail_text);
1524 }
1525 }
1526 [] BSSAP.receive { repeat; }
1527 }
1528}
1529testcase TC_assignment_csd() runs on test_CT {
1530 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
Harald Welteed848512018-05-24 22:27:58 +02001531 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte235ebf12017-12-15 14:18:16 +01001532 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeCSD);
1533 //exp_fail.pdu.bssmap.assignmentFailure.cause.causeValue := int2bit(enum2int(GSM0808_CAUSE_REQ_CODEC_TYPE_OR_CONFIG_UNAVAIL), 7);
1534 f_assignment_exp(ass_cmd, exp_fail, "BSC accepted Assignment for CSD");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001535 f_shutdown_helper();
Harald Welte235ebf12017-12-15 14:18:16 +01001536}
1537
1538testcase TC_assignment_ctm() runs on test_CT {
1539 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
Harald Welteed848512018-05-24 22:27:58 +02001540 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte235ebf12017-12-15 14:18:16 +01001541 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeCTM);
1542 //exp_fail.pdu.bssmap.assignmentFailure.cause.causeValue := int2bit(enum2int(GSM0808_CAUSE_REQ_CODEC_TYPE_OR_CONFIG_UNAVAIL), 7);
1543 f_assignment_exp(ass_cmd, exp_fail, "BSC accepted Assignment for Speech+CTM");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001544 f_shutdown_helper();
Harald Welte235ebf12017-12-15 14:18:16 +01001545}
1546
Harald Welte4003d112017-12-09 22:35:39 +01001547type record DchanTuple {
1548 integer sccp_conn_id,
1549 RslChannelNr rsl_chan_nr
Harald Weltea5d2ab22017-12-09 14:21:42 +01001550}
1551
Harald Welted6939652017-12-13 21:02:46 +01001552/* Send CHAN RQD and wait for allocation; acknowledge it */
1553private function f_chreq_act_ack(OCT1 ra := '23'O, GsmFrameNumber fn := 23)
1554runs on test_CT return RslChannelNr {
1555 var RSL_Message rx_rsl;
1556 f_ipa_tx(0, ts_RSL_CHAN_RQD(ra, fn));
1557 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
1558 var RslChannelNr chan_nr := rx_rsl.ies[0].body.chan_nr;
1559 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, fn+10));
Daniel Willmannf4ac4ce2018-08-02 14:06:30 +02001560 rx_rsl := f_exp_ipa_rx(0, tr_RSL_IMM_ASSIGN(0));
Harald Welted6939652017-12-13 21:02:46 +01001561 return chan_nr;
1562}
1563
Harald Welte4003d112017-12-09 22:35:39 +01001564/* helper function to establish a dedicated channel via BTS and MSC */
1565function f_est_dchan(OCT1 ra, GsmFrameNumber fn, octetstring l3)
1566runs on test_CT return DchanTuple {
1567 var BSSAP_N_CONNECT_ind rx_c_ind;
Harald Welte4003d112017-12-09 22:35:39 +01001568 var DchanTuple dt;
Harald Weltea5d2ab22017-12-09 14:21:42 +01001569
Harald Welte4003d112017-12-09 22:35:39 +01001570 /* Send CHAN RQD and wait for allocation; acknowledge it */
Harald Welted6939652017-12-13 21:02:46 +01001571 dt.rsl_chan_nr := f_chreq_act_ack(ra, fn);
Harald Welte4003d112017-12-09 22:35:39 +01001572
1573 f_ipa_tx(0, ts_RSL_EST_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
1574
1575 BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) -> value rx_c_ind;
1576 dt.sccp_conn_id := rx_c_ind.connectionId;
1577 BSSAP.send(ts_BSSAP_CONNECT_res(dt.sccp_conn_id));
1578
1579 return dt;
Harald Weltea5d2ab22017-12-09 14:21:42 +01001580}
1581
Harald Welte641fcbe2018-06-14 10:58:35 +02001582/* expect RF CAN REL from BTS, acknowledge it and clear the MSC side */
1583private function f_exp_chan_rel_and_clear(DchanTuple dt, integer bts_nr := 0) runs on test_CT {
1584 var RSL_Message rx_rsl;
1585 /* expect BSC to disable the channel */
1586 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), T3101_MAX);
1587 /* respond with CHAN REL ACK */
1588 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(dt.rsl_chan_nr));
1589
1590 /* expect Clear Complete from BSC */
1591 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete));
1592
1593 /* MSC disconnects as instructed. */
1594 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
1595}
1596
Harald Welte4003d112017-12-09 22:35:39 +01001597/* Test behavior of channel release after unilateral RLL REL IND (DISC from MS) */
1598testcase TC_chan_rel_rll_rel_ind() runs on test_CT {
Neels Hofmeyr27f64362018-03-12 01:44:00 +01001599 var BSSAP_N_DATA_ind rx_di;
Harald Welte4003d112017-12-09 22:35:39 +01001600 var DchanTuple dt;
Harald Welte96c94412017-12-09 03:12:45 +01001601
Harald Welte89d42e82017-12-17 16:42:41 +01001602 f_init(1);
Harald Welte96c94412017-12-09 03:12:45 +01001603
Harald Welte4003d112017-12-09 22:35:39 +01001604 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1605
1606 /* simulate RLL REL IND */
1607 f_ipa_tx(0, ts_RSL_REL_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0))));
1608
Neels Hofmeyr27f64362018-03-12 01:44:00 +01001609 /* expect Clear Request on MSC side */
1610 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearRequest)) -> value rx_di;
1611
1612 /* Instruct BSC to clear channel */
1613 var BssmapCause cause := bit2int(rx_di.userData.pdu.bssmap.clearRequest.cause.causeValue);
1614 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
1615
Harald Welte4003d112017-12-09 22:35:39 +01001616 /* expect BSC to disable the channel */
Harald Welte641fcbe2018-06-14 10:58:35 +02001617 f_exp_chan_rel_and_clear(dt, 0);
Neels Hofmeyr27f64362018-03-12 01:44:00 +01001618
1619 /* wait for SCCP emulation to do its job */
1620 f_sleep(1.0);
Harald Welte4003d112017-12-09 22:35:39 +01001621
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001622 f_shutdown_helper();
Harald Welte4003d112017-12-09 22:35:39 +01001623}
1624
1625/* Test behavior of channel release after CONN FAIL IND from BTS */
1626testcase TC_chan_rel_conn_fail() runs on test_CT {
1627 var BSSAP_N_DATA_ind rx_di;
Harald Welte4003d112017-12-09 22:35:39 +01001628 var DchanTuple dt;
1629
Harald Welte89d42e82017-12-17 16:42:41 +01001630 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +01001631
1632 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1633
1634 /* simulate CONN FAIL IND */
Harald Weltea8ed9062017-12-14 09:46:01 +01001635 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 +01001636 /* TODO: different cause values? */
1637
Harald Welte4003d112017-12-09 22:35:39 +01001638 /* expect Clear Request from BSC */
1639 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearRequest)) -> value rx_di;
1640
1641 /* Instruct BSC to clear channel */
1642 var BssmapCause cause := bit2int(rx_di.userData.pdu.bssmap.clearRequest.cause.causeValue);
1643 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
1644
Harald Welte6ff76ea2018-01-28 13:08:01 +01001645 /* expect BSC to disable the channel */
Harald Welte641fcbe2018-06-14 10:58:35 +02001646 f_exp_chan_rel_and_clear(dt, 0);
Harald Welte4003d112017-12-09 22:35:39 +01001647
1648 /* wait for SCCP emulation to do its job */
1649 f_sleep(1.0);
1650
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001651 f_shutdown_helper();
Harald Welte4003d112017-12-09 22:35:39 +01001652}
1653
Harald Welte99f3ca02018-06-14 13:40:29 +02001654/* Test behavior of early CONN FAIL IND from BTS (before EST IND!) */
1655/* See also https://www.osmocom.org/issues/3182 */
1656testcase TC_early_conn_fail() runs on test_CT {
1657 var RSL_Message rx_rsl;
1658 var DchanTuple dt;
1659
1660 f_init(1);
1661
1662 /* BTS->BSC: Send CHAN RQD and wait for allocation; acknowledge it */
Harald Weltec46ea3c2020-10-10 18:46:12 +02001663 dt.rsl_chan_nr := f_chreq_act_ack(f_rnd_ra_cs(), 23);
Harald Welte99f3ca02018-06-14 13:40:29 +02001664
1665 /* BTS->BSC: simulate CONN FAIL IND */
1666 f_ipa_tx(0, ts_RSL_CONN_FAIL_IND(dt.rsl_chan_nr, RSL_ERR_RADIO_LINK_FAIL));
1667
1668 /* BTS->BSC: Expect RF channel release from BSC on Abis */
1669 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), 10.0);
1670
1671 /* BTS<-BSC: respond with CHAN REL ACK */
1672 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(dt.rsl_chan_nr));
1673
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001674 f_shutdown_helper();
Harald Welte99f3ca02018-06-14 13:40:29 +02001675}
1676
1677/* Test behavior of late CONN FAIL IND from BTS (ater REL IND!) */
1678/* See also https://www.osmocom.org/issues/3182 */
1679testcase TC_late_conn_fail() runs on test_CT {
1680 var RSL_Message rx_rsl;
1681 var DchanTuple dt;
1682
1683 f_init(1);
1684
1685 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1686
1687 /* BSC<-MSC: Instruct BSC to clear connection */
1688 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(0)));
1689
1690 /* BTS->BSC: expect BSC to deactivate SACCH */
1691 rx_rsl := f_exp_ipa_rx(0, tr_RSL_DEACT_SACCH(dt.rsl_chan_nr));
1692
1693 /* BTS->BSC: simulate a late CONN FAIL IND from BTS */
1694 f_ipa_tx(0, ts_RSL_CONN_FAIL_IND(dt.rsl_chan_nr, RSL_ERR_RADIO_LINK_FAIL));
1695
1696 /* BTS<-BSC: Expect RF channel release from BSC on Abis */
1697 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), 10.0);
1698 /* BTS->BSC: respond with CHAN REL ACK */
1699 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(dt.rsl_chan_nr));
1700
1701 /* BSC->MSC: expect Clear Complete from BSC */
1702 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete));
1703
1704 /* BSC<-MSC: MSC disconnects as requested. */
1705 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
1706
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001707 f_shutdown_helper();
Harald Welte99f3ca02018-06-14 13:40:29 +02001708}
1709
Neels Hofmeyrf44ccd12018-11-05 19:15:23 +01001710function f_expect_chan_rel(integer bts_nr, RslChannelNr rsl_chan_nr,
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001711 boolean expect_deact_sacch := true,
1712 boolean expect_rr_chan_rel := true,
1713 boolean expect_rll_rel_req := true,
Harald Welte99787102019-02-04 10:41:36 +01001714 boolean handle_rll_rel := true,
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02001715 boolean is_csfb := false,
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02001716 template CellSelIndValue csfb_expect_cells := omit,
1717 template RR_Cause expect_rr_cause := ?
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001718 ) runs on test_CT {
Harald Welte91d54a52018-01-28 15:35:07 +01001719
1720 var RslLinkId main_dcch := valueof(ts_RslLinkID_DCCH(0));
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001721 var boolean got_deact_sacch := false;
1722 var boolean got_rr_chan_rel := false;
1723 var boolean got_rll_rel_req := false;
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02001724 var ASP_RSL_Unitdata ud;
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02001725 var RSL_IE_Body l3_ie;
1726 var PDU_ML3_NW_MS l3;
1727 var RR_Cause got_cause;
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001728 log("f_expect_chan_rel() expecting: expect_deact_sacch=", expect_deact_sacch, " expect_rr_chan_rel=", expect_rr_chan_rel,
1729 " expect_rll_rel_req=", expect_rll_rel_req);
Harald Welte91d54a52018-01-28 15:35:07 +01001730 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001731 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(tr_RSL_DEACT_SACCH(rsl_chan_nr))) {
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001732 got_deact_sacch := true;
Harald Welte91d54a52018-01-28 15:35:07 +01001733 repeat;
1734 }
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02001735 [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 +01001736 got_rr_chan_rel := true;
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02001737
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02001738 if (f_rsl_find_ie(ud.rsl, RSL_IE_L3_INFO, l3_ie) == false) {
1739 setverdict(fail, "cannot find L3");
1740 mtc.stop;
1741 }
1742 l3 := dec_PDU_ML3_NW_MS(l3_ie.l3_info.payload);
1743
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02001744 if (not istemplatekind(csfb_expect_cells, "omit")) {
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02001745 var CellSelIndValue cells := dec_CellSelIndValue(
1746 l3.msgs.rrm.channelRelease.cellSelectionIndicator.cellSelectionIndicatorValue);
1747
1748 log("GOT RR CHANNEL RELEASE CSFB CELLS: ", cells);
1749 if (match(cells, csfb_expect_cells)) {
1750 setverdict(pass);
1751 } else {
1752 log("EXPECTED CSFB CELLS: ", csfb_expect_cells);
1753 setverdict(fail, "Received CSFB cells list on RR Channel Release does not match expectations");
1754 }
1755 }
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02001756
1757 if (not istemplatekind(expect_rr_cause, "omit")) {
1758 int2enum(oct2int(l3.msgs.rrm.channelRelease.rRCause.valuePart), got_cause);
1759 log("GOT CAUSE CODE: ", l3.msgs.rrm.channelRelease.rRCause.valuePart, " = ", got_cause);
1760 if (match(got_cause, expect_rr_cause)) {
1761 setverdict(pass);
1762 } else {
1763 log("EXPECTED CAUSE CODE: ", expect_rr_cause);
1764 setverdict(fail, "Received RR Channel Release Cause code does not match expectations");
1765 }
1766 }
Harald Welte99787102019-02-04 10:41:36 +01001767 repeat;
1768 }
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02001769 [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 +01001770 got_rr_chan_rel := true;
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02001771
1772 if (not istemplatekind(expect_rr_cause, "omit")) {
1773 if (f_rsl_find_ie(ud.rsl, RSL_IE_L3_INFO, l3_ie) == false) {
1774 setverdict(fail, "cannot find L3");
1775 mtc.stop;
1776 }
1777 l3 := dec_PDU_ML3_NW_MS(l3_ie.l3_info.payload);
1778
1779 int2enum(oct2int(l3.msgs.rrm.channelRelease.rRCause.valuePart), got_cause);
1780 log("GOT CAUSE CODE: ", l3.msgs.rrm.channelRelease.rRCause.valuePart, " = ", got_cause);
1781 if (match(got_cause, expect_rr_cause)) {
1782 setverdict(pass);
1783 } else {
1784 log("EXPECTED CAUSE CODE: ", expect_rr_cause);
1785 setverdict(fail, "Received RR Channel Release Cause code does not match expectations");
1786 }
1787 }
Neels Hofmeyr211169d2018-11-07 00:37:29 +01001788 repeat;
1789 }
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001790 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(tr_RSL_REL_REQ(rsl_chan_nr, ?))) {
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001791 got_rll_rel_req := true;
Harald Welte91d54a52018-01-28 15:35:07 +01001792 /* FIXME: Why are we getting this for LinkID SACCH? */
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001793 if (handle_rll_rel) {
1794 f_ipa_tx(0, ts_RSL_REL_CONF(rsl_chan_nr, main_dcch));
1795 }
Harald Welte91d54a52018-01-28 15:35:07 +01001796 repeat;
1797 }
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001798 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL))) {
Harald Welte91d54a52018-01-28 15:35:07 +01001799 /* respond with CHAN REL ACK */
1800 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(rsl_chan_nr));
1801 }
1802 /* ignore any user data */
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001803 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(tr_RSL_MsgTypeR(?))) {
Harald Welte91d54a52018-01-28 15:35:07 +01001804 repeat;
1805 }
1806 }
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001807
1808 log("f_expect_chan_rel() summary: got_deact_sacch=", got_deact_sacch, " got_rr_chan_rel=", got_rr_chan_rel,
1809 " got_rll_rel_req=", got_rll_rel_req);
1810
1811 if (expect_deact_sacch != got_deact_sacch) {
1812 setverdict(fail, "f_expect_chan_rel(): expect_deact_sacch=", expect_deact_sacch, " got_deact_sacch=", got_deact_sacch);
1813 }
1814 if (expect_rr_chan_rel != got_rr_chan_rel) {
1815 setverdict(fail, "f_expect_chan_rel(): expect_rr_chan_rel=", expect_rr_chan_rel, " got_rr_chan_rel=", got_rr_chan_rel);
1816 }
1817 if (expect_rll_rel_req != got_rll_rel_req) {
1818 setverdict(fail, "f_expect_chan_rel(): expect_rll_rel_req=", expect_rll_rel_req, " got_rll_rel_req=", got_rll_rel_req);
1819 }
Harald Welte91d54a52018-01-28 15:35:07 +01001820}
1821
Harald Welte4003d112017-12-09 22:35:39 +01001822/* Test behavior of channel release after hard Clear Command from MSC */
1823testcase TC_chan_rel_hard_clear() runs on test_CT {
1824 var BSSAP_N_DATA_ind rx_di;
Harald Welte4003d112017-12-09 22:35:39 +01001825 var DchanTuple dt;
Harald Welte4003d112017-12-09 22:35:39 +01001826
Harald Welte89d42e82017-12-17 16:42:41 +01001827 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +01001828
1829 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1830
1831 /* Instruct BSC to clear channel */
1832 var BssmapCause cause := 0;
1833 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
1834
1835 /* expect Clear Complete from BSC on A */
1836 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete)) {
1837 /* release the SCCP connection */
1838 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
1839 }
1840
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001841 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001842 f_shutdown_helper();
Harald Welte4003d112017-12-09 22:35:39 +01001843}
1844
Harald Welte99787102019-02-04 10:41:36 +01001845/* Test behavior of channel release after Clear Command with CSFB indicator from MSC */
1846testcase TC_chan_rel_hard_clear_csfb() runs on test_CT {
1847 var BSSAP_N_DATA_ind rx_di;
1848 var DchanTuple dt;
1849
1850 f_init(1);
1851
1852 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1853
1854 /* Instruct BSC to clear channel */
1855 var BssmapCause cause := 0;
1856 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommandCSFB(cause)));
1857
1858 /* expect Clear Complete from BSC on A */
1859 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete)) {
1860 /* release the SCCP connection */
1861 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
1862 }
1863
1864 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 +02001865 f_shutdown_helper();
Harald Welte99787102019-02-04 10:41:36 +01001866}
1867
Harald Welted8c36cd2017-12-09 23:05:31 +01001868/* Test behavior of channel release after hard RLSD from MSC */
1869testcase TC_chan_rel_hard_rlsd() runs on test_CT {
Harald Welted8c36cd2017-12-09 23:05:31 +01001870 var DchanTuple dt;
Harald Welted8c36cd2017-12-09 23:05:31 +01001871
Harald Welte89d42e82017-12-17 16:42:41 +01001872 f_init(1);
Harald Welted8c36cd2017-12-09 23:05:31 +01001873
1874 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1875
1876 /* release the SCCP connection */
1877 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
1878
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001879 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001880 f_shutdown_helper();
Harald Welted8c36cd2017-12-09 23:05:31 +01001881}
1882
Harald Welte550daf92018-06-11 19:22:13 +02001883/* Test behavior of channel release after hard RLSD from MSC and MS is not responding to RLL REL REQ */
1884testcase TC_chan_rel_hard_rlsd_ms_dead() runs on test_CT {
1885 var DchanTuple dt;
1886
1887 f_init(1);
1888
1889 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1890
1891 /* release the SCCP connection */
1892 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
1893
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001894 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001895 f_shutdown_helper();
Harald Welte550daf92018-06-11 19:22:13 +02001896}
1897
Harald Welte85804d42017-12-10 14:11:58 +01001898/* Test behavior of channel release after BSSMAP RESET from MSC */
1899testcase TC_chan_rel_a_reset() runs on test_CT {
Harald Welte85804d42017-12-10 14:11:58 +01001900 var DchanTuple dt;
Harald Welte85804d42017-12-10 14:11:58 +01001901
Harald Welte89d42e82017-12-17 16:42:41 +01001902 f_init(1);
Harald Welte85804d42017-12-10 14:11:58 +01001903
1904 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1905
1906 /* Clear the queue, it might still contain stuff like IMMEDIATE ASSIGN */
1907 IPA_RSL[0].clear;
1908
1909 /* perform BSSAP RESET, expect RESET ACK and DISC.ind on connection */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001910 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 +01001911 interleave {
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001912 [] 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 +01001913 [] BSSAP.receive(tr_BSSAP_DISC_ind(dt.sccp_conn_id, ?, ?)) { }
1914 }
1915
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001916 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001917 f_shutdown_helper();
Harald Welte85804d42017-12-10 14:11:58 +01001918}
1919
Pau Espin Pedrolc675b612020-01-09 19:55:40 +01001920/* Verify T(iar) triggers and releases the channel */
1921testcase TC_chan_rel_sccp_tiar_timeout() runs on test_CT {
1922 var DchanTuple dt;
1923
1924 /* Set T(iar) in BSC low enough that it will trigger before other side
1925 has time to keep alive with a T(ias). Keep recommended ratio of
1926 T(iar) >= T(ias)*2 */
1927 g_bsc_sccp_timer_ias := 2;
1928 g_bsc_sccp_timer_iar := 5;
1929
1930 f_init(1);
1931
1932 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1933 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001934 f_shutdown_helper();
Pau Espin Pedrolc675b612020-01-09 19:55:40 +01001935}
1936
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02001937private function f_tc_chan_rel_rr_cause(myBSSMAP_Cause clear_cmd_cause, template RR_Cause expect_rr_cause)
1938runs on test_CT
1939{
1940 var DchanTuple dt;
1941
1942 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1943 var BssmapCause cause := 0;
1944 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(enum2int(clear_cmd_cause))));
1945 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete)) {
1946 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
1947 }
1948
1949 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false, expect_rr_cause := expect_rr_cause);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001950 f_shutdown_helper();
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02001951}
1952
1953/* Test that Clear Command cause codes affect the RR Channel Release cause code */
1954testcase TC_chan_rel_rr_cause() runs on test_CT {
1955 f_init(1);
1956
1957 f_tc_chan_rel_rr_cause(GSM0808_CAUSE_CALL_CONTROL, GSM48_RR_CAUSE_NORMAL);
1958 f_tc_chan_rel_rr_cause(GSM0808_CAUSE_HANDOVER_SUCCESSFUL, GSM48_RR_CAUSE_NORMAL);
1959 f_tc_chan_rel_rr_cause(GSM0808_CAUSE_PREEMPTION, GSM48_RR_CAUSE_PREMPTIVE_REL);
1960 f_tc_chan_rel_rr_cause(GSM0808_CAUSE_RADIO_INTERFACE_MESSAGE_FAILURE, GSM48_RR_CAUSE_PROT_ERROR_UNSPC);
1961 f_tc_chan_rel_rr_cause(GSM0808_CAUSE_RADIO_INTERFACE_FAILURE, GSM48_RR_CAUSE_ABNORMAL_UNSPEC);
1962 f_tc_chan_rel_rr_cause(GSM0808_CAUSE_EQUIPMENT_FAILURE, GSM48_RR_CAUSE_ABNORMAL_UNSPEC);
1963}
1964
Harald Welte5cd20ed2017-12-13 21:03:20 +01001965/* Test behavior if RSL EST IND for non-active channel */
1966testcase TC_rll_est_ind_inact_lchan() runs on test_CT {
1967 timer T := 2.0;
1968
Harald Welte89d42e82017-12-17 16:42:41 +01001969 f_init(1);
Harald Welte5cd20ed2017-12-13 21:03:20 +01001970
1971 var octetstring l3 := '00010203040506'O;
1972 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(6));
1973 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
1974
1975 T.start;
1976 alt {
1977 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) {
1978 setverdict(fail, "MSC received COMPL L3 for non-active lchan");
1979 }
1980 [] BSSAP.receive {}
1981 [] IPA_RSL[0].receive {}
1982 [] T.timeout {}
1983 }
1984
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001985 f_shutdown_helper();
Harald Welte5cd20ed2017-12-13 21:03:20 +01001986}
1987
1988/* Test behavior if RSL EST IND for invalid SAPI */
1989testcase TC_rll_est_ind_inval_sapi1() runs on test_CT {
1990 var RslChannelNr chan_nr;
1991
Harald Welte89d42e82017-12-17 16:42:41 +01001992 f_init(1);
Harald Welte5cd20ed2017-12-13 21:03:20 +01001993
1994 chan_nr := f_chreq_act_ack()
1995
1996 var octetstring l3 := '00010203040506'O;
1997 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(1)), l3));
1998
1999 timer T := 2.0;
2000 T.start;
2001 alt {
2002 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) {
2003 setverdict(fail, "MSC received COMPL L3 for invalid SAPI 1");
2004 }
2005 [] BSSAP.receive { repeat; }
2006 [] IPA_RSL[0].receive { repeat; }
2007 [] T.timeout {}
2008 }
2009
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002010 f_shutdown_helper();
Harald Welte5cd20ed2017-12-13 21:03:20 +01002011}
2012
2013/* Test behavior if RSL EST IND for invalid SAPI */
2014testcase TC_rll_est_ind_inval_sapi3() runs on test_CT {
2015 timer T := 2.0;
2016
Harald Welte89d42e82017-12-17 16:42:41 +01002017 f_init(1);
Harald Welte5cd20ed2017-12-13 21:03:20 +01002018
2019 var RslChannelNr chan_nr := f_chreq_act_ack();
2020
2021 var octetstring l3 := '00010203040506'O;
2022 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(3)), l3));
2023
2024 T.start;
2025 alt {
2026 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) {
2027 setverdict(fail, "MSC received COMPL L3 for invalid SAPI 3");
2028 }
2029 [] BSSAP.receive { repeat; }
2030 [] IPA_RSL[0].receive { repeat; }
2031 [] T.timeout {}
2032 }
2033
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002034 f_shutdown_helper();
Harald Welte5cd20ed2017-12-13 21:03:20 +01002035}
2036
2037/* Test behavior if RSL EST IND for invalid SACCH */
2038testcase TC_rll_est_ind_inval_sacch() runs on test_CT {
2039 timer T := 2.0;
2040
Harald Welte89d42e82017-12-17 16:42:41 +01002041 f_init(1);
Harald Welte5cd20ed2017-12-13 21:03:20 +01002042
2043 var RslChannelNr chan_nr := f_chreq_act_ack();
2044
2045 var octetstring l3 := '00010203040506'O;
2046 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_SACCH(0)), l3));
2047
2048 T.start;
2049 alt {
2050 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) {
2051 setverdict(fail, "MSC received COMPL L3 for invalid Link SACCH");
2052 }
2053 [] BSSAP.receive { repeat; }
2054 [] IPA_RSL[0].receive { repeat; }
2055 [] T.timeout {}
2056 }
2057
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002058 f_shutdown_helper();
Harald Welte5cd20ed2017-12-13 21:03:20 +01002059}
2060
Vadim Yanitskiy61f784a2020-10-01 21:12:19 +07002061/* Verify DLCI / RSL Link ID conversion for MO/MT messages on SAPI0/SAPI3 */
2062private function f_TC_tch_dlci_link_id_sapi(charstring id) runs on MSC_ConnHdlr {
2063 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
2064 var PDU_BSSAP ass_cmd := f_gen_ass_req();
2065
2066 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
2067 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
2068
2069 f_establish_fully(ass_cmd, exp_compl);
2070
2071 /* SAPI0 has already been established by f_establish_fully(), establish SAPI3 */
2072 RSL.send(ts_RSL_EST_IND(g_chan_nr, ts_RslLinkID_SACCH(3), '0904'O));
2073 /* Expect BSSAP/DTAP on SAPI3 (DLCI IE) */
2074 BSSAP.receive(PDU_BSSAP:{
2075 discriminator := '1'B,
2076 spare := '0000000'B,
2077 dlci := 'C3'O,
2078 lengthIndicator := ?,
2079 pdu := { dtap := '0904'O }
2080 });
2081
2082 /* Send messages on DCCH/SAPI0 and ACCH/SAPI3 */
2083 for (var integer i := 0; i < 32; i := i + 1) {
2084 var octetstring l3 := '09'O & f_rnd_octstring(14);
2085 var template (value) RslLinkId link_id;
2086 var template (value) OCT1 dlci;
2087
2088 if (i mod 2 == 0) {
2089 /* SAPI0 on FACCH or SDCCH */
2090 link_id := ts_RslLinkID_DCCH(0);
2091 dlci := '80'O;
2092 } else {
2093 /* SAPI3 on SACCH */
2094 link_id := ts_RslLinkID_SACCH(3);
2095 dlci := 'C3'O;
2096 }
2097
2098 /* Send MO message: RSL -> BSSAP */
Neels Hofmeyr0aa719b2020-10-12 18:43:09 +00002099 f_mo_l3_transceive(RSL, link_id, dlci, l3);
Vadim Yanitskiy61f784a2020-10-01 21:12:19 +07002100 /* Send MT message: BSSAP -> RSL */
Neels Hofmeyr0aa719b2020-10-12 18:43:09 +00002101 f_mt_l3_transceive(RSL, link_id, dlci, l3);
Vadim Yanitskiy61f784a2020-10-01 21:12:19 +07002102 }
2103}
2104testcase TC_tch_dlci_link_id_sapi() runs on test_CT {
2105 var TestHdlrParams pars := f_gen_test_hdlr_pars();
2106 var MSC_ConnHdlr vc_conn;
2107
2108 f_init(1, true);
2109 f_sleep(1.0);
2110
2111 vc_conn := f_start_handler(refers(f_TC_tch_dlci_link_id_sapi), pars);
2112 vc_conn.done;
2113
2114 f_shutdown_helper();
2115}
2116
Vadim Yanitskiy6ef5dfa2020-08-28 18:04:41 +07002117private function f_exp_sapi_n_reject(template (present) GsmSapi sapi := ?,
2118 template myBSSMAP_Cause cause := ?,
2119 float T_val := 2.0)
2120runs on test_CT {
2121 var BSSAP_N_DATA_ind rx_di;
2122 timer T;
2123
2124 var template BSSMAP_IE_Cause tr_cause := tr_BSSMAP_IE_Cause(cause);
2125 var template PDU_BSSAP tr_pdu := tr_BSSMAP_SAPInReject(sapi);
2126
2127 T.start(T_val);
2128 alt {
2129 [] BSSAP.receive(tr_BSSAP_DATA_ind(?, tr_pdu)) -> value rx_di {
2130 var BSSMAP_IE_Cause rx_cause := rx_di.userData.pdu.bssmap.sAPInReject.cause;
2131 if (not match(rx_cause, tr_cause)) {
2132 setverdict(fail, "Rx unexpected Cause IE: ",
2133 rx_cause, " vs expected ", tr_cause);
2134 }
2135 setverdict(pass);
2136 }
2137 [] BSSAP.receive(BSSAP_N_DATA_ind:?) -> value rx_di {
2138 setverdict(fail, "Rx unexpected BSSAP PDU: ", rx_di);
2139 }
2140 [] T.timeout {
2141 setverdict(fail, "Timeout waiting for BSSMAP SAPI N Reject");
2142 }
2143 }
2144}
2145
2146/* Check if we get SAPI N Reject on receipt of unexpected RLL RELease INDication */
2147testcase TC_rll_rel_ind_sapi_n_reject() runs on test_CT {
2148 var octetstring rnd_data := f_rnd_octstring(16);
2149 var RSL_Message rx_rsl;
2150 var DchanTuple dt;
2151
2152 f_init(1);
2153
2154 /* MS establishes a SAPI=0 link on DCCH */
2155 dt := f_est_dchan(f_rnd_ra_cs(), 23, rnd_data);
2156
2157 /* MSC sends some data on (not yet established) SAPI=3 link */
2158 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSAP_DTAP(rnd_data, '03'O)));
2159 /* BSC attempts to establish a SAPI=3 link on DCCH */
2160 rx_rsl := f_exp_ipa_rx(0, tr_RSL_EST_REQ(dt.rsl_chan_nr, tr_RslLinkID_DCCH(3)));
2161
2162 /* MS sends unexpected RELease INDication on SAPI=3 */
2163 f_ipa_tx(0, ts_RSL_REL_IND(dt.rsl_chan_nr, ts_RslLinkID_DCCH(3)));
2164 /* We expect to receive BSSMAP SAPI N Reject message from the BSC */
2165 f_exp_sapi_n_reject(3, GSM0808_CAUSE_MS_NOT_EQUIPPED);
2166
2167 /* Clean up the connection */
2168 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
2169 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
2170
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002171 f_shutdown_helper();
Vadim Yanitskiy6ef5dfa2020-08-28 18:04:41 +07002172}
2173
2174/* Check if we get SAPI N Reject on receipt of unexpected RLL ERROR INDication */
2175testcase TC_rll_err_ind_sapi_n_reject() runs on test_CT {
2176 var octetstring rnd_data := f_rnd_octstring(16);
2177 var RSL_Message rx_rsl;
2178 var DchanTuple dt;
2179
2180 f_init(1);
2181
2182 /* MS establishes a SAPI=0 link on DCCH */
2183 dt := f_est_dchan(f_rnd_ra_cs(), 23, rnd_data);
2184
2185 /* MSC sends some data on (not yet established) SAPI=3 link */
2186 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSAP_DTAP(rnd_data, '03'O)));
2187 /* BSC attempts to establish a SAPI=3 link on DCCH */
2188 rx_rsl := f_exp_ipa_rx(0, tr_RSL_EST_REQ(dt.rsl_chan_nr, tr_RslLinkID_DCCH(3)));
2189
2190 /* BTS sends unexpected ERROR INDication on SAPI=3 */
2191 f_ipa_tx(0, ts_RSL_ERROR_IND(dt.rsl_chan_nr, ts_RslLinkID_DCCH(3), ''O));
2192 /* We expect to receive BSSMAP SAPI N Reject message from the BSC */
2193 f_exp_sapi_n_reject(3, GSM0808_CAUSE_BSS_NOT_EQUIPPED);
2194
2195 /* Clean up the connection */
2196 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
2197 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
2198
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002199 f_shutdown_helper();
Vadim Yanitskiy6ef5dfa2020-08-28 18:04:41 +07002200}
2201
2202/* Check if we get SAPI N Reject due to a SAPI=3 link establishment timeout */
2203testcase TC_rll_timeout_sapi_n_reject() runs on test_CT {
2204 var octetstring rnd_data := f_rnd_octstring(16);
2205 var RSL_Message rx_rsl;
2206 var DchanTuple dt;
2207
2208 f_init(1);
2209
2210 /* MS establishes a SAPI=0 link on DCCH */
2211 dt := f_est_dchan(f_rnd_ra_cs(), 23, rnd_data);
2212
2213 /* MSC sends some data on (not yet established) SAPI=3 link */
2214 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSAP_DTAP(rnd_data, '03'O)));
2215 /* BSC attempts to establish a SAPI=3 link on DCCH */
2216 rx_rsl := f_exp_ipa_rx(0, tr_RSL_EST_REQ(dt.rsl_chan_nr, tr_RslLinkID_DCCH(3)));
2217
2218 /* MS does not respond, so the link establishment timeout triggers SAPI N Reject */
2219 f_exp_sapi_n_reject(3, GSM0808_CAUSE_BSS_NOT_EQUIPPED, T_val := 8.0);
2220
2221 /* Clean up the connection */
2222 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
2223 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
2224
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002225 f_shutdown_helper();
Vadim Yanitskiy6ef5dfa2020-08-28 18:04:41 +07002226}
2227
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +02002228testcase TC_si_default() runs on test_CT {
2229 f_init(0);
2230 f_init_bts_and_check_sysinfo(0, expect_si := SystemInformationConfig_default);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002231 f_shutdown_helper();
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +02002232}
Harald Welte4003d112017-12-09 22:35:39 +01002233
Neels Hofmeyr56f24782020-07-09 00:50:49 +02002234/* We're testing SI2quater with lists of EARFCNs. Instead of just incrementing EARFCNs, also pick some from the edges of
2235 * the entire value range. This function provides the same EARFCN numbers for the same earfcn_index */
2236private function f_test_si2quater_earfcn_by_idx(integer earfcn_index) return uint16_t
2237{
2238 select (earfcn_index) {
2239 case (0) {
2240 /* E-ARFCN 111 is already added in the osmo-bsc.cfg */
2241 return 111;
2242 }
2243 case (1) {
2244 return 1;
2245 }
2246 case (2) {
2247 return 0;
2248 }
2249 case (3) {
2250 return 65535;
2251 }
2252 case else {
2253 return 23 * (earfcn_index - 3);
2254 }
2255 }
2256}
2257
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02002258function f_test_si2quater(integer total_earfcns, template SystemInformationConfig expect_si,
2259 template CellSelIndValue expect_cells := omit) runs on test_CT {
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002260
2261 f_init(0);
2262
2263 /* E-ARFCN 111 is already added in the osmo-bsc.cfg, so only add more arfcns if total_earfcns > 1 */
2264 for (var integer i := 1; i < total_earfcns; i := i + 1) {
Neels Hofmeyr56f24782020-07-09 00:50:49 +02002265 f_bts_0_cfg(BSCVTY, {"si2quater neighbor-list add earfcn " & int2str(f_test_si2quater_earfcn_by_idx(i))
2266 & " thresh-hi 20 thresh-lo 10 prio 3 qrxlv 22 meas 3"});
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002267 }
2268
2269 f_init_bts_and_check_sysinfo(0, expect_si := expect_si);
2270
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02002271 f_init(1);
2272
2273 if (not istemplatekind(expect_cells, "omit")) {
2274 /* Also check that RR Channel Release contains these EARFCNs.
2275 * (copied code from TC_chan_rel_hard_clear_csfb) */
2276 var BSSAP_N_DATA_ind rx_di;
2277 var DchanTuple dt;
2278
2279 dt := f_est_dchan('23'O, 23, '00010203040506'O);
2280
2281 /* Instruct BSC to clear channel */
2282 var BssmapCause cause := 0;
2283 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommandCSFB(cause)));
2284
2285 /* expect Clear Complete from BSC on A */
2286 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete)) {
2287 /* release the SCCP connection */
2288 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
2289 }
2290
2291 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false, is_csfb := true,
2292 csfb_expect_cells := expect_cells);
2293 }
2294
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002295 for (var integer i := 1; i < total_earfcns; i := i + 1) {
Neels Hofmeyr56f24782020-07-09 00:50:49 +02002296 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 +02002297 }
2298}
2299
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002300private function f_tr_si2quater_earfcns(integer count) return template SI2quaterRestOctetsList
2301{
2302 var template SI2quaterRestOctetsList si2quater := {};
2303 var integer si2quater_count := (count + 2) / 3;
2304
2305 for (var integer i := 0; i < count; i := i + 1) {
Neels Hofmeyr56f24782020-07-09 00:50:49 +02002306 var integer earfcn := f_test_si2quater_earfcn_by_idx(i);
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002307 var integer index := i / 3;
2308 var integer earfcn_index := i mod 3;
2309 if (index >= lengthof(si2quater)) {
2310 si2quater[index] := tr_SI2quaterRestOctets_EUTRAN(index := index, count := si2quater_count - 1);
2311 }
2312 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);
2313 }
2314
2315 return si2quater;
2316}
2317
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02002318private function f_tr_rr_chan_rel_earfcns(integer count) return template CellSelIndValue
2319{
2320 var template CellSelIndValue_EUTRAN_Descrs cells := {};
2321
Alexander Couzensf74b5cb2020-09-10 22:28:40 +02002322 /* the lte neighbors must match the config & vty to pass this test */
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02002323 for (var integer i := 0; i < count; i := i + 1) {
2324 var integer earfcn := f_test_si2quater_earfcn_by_idx(i);
Alexander Couzensf74b5cb2020-09-10 22:28:40 +02002325 cells[i] := tr_CellSelIndValue_EUTRAN_Descr(earfcn, '1'B, 3);
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02002326 }
2327
2328 return tr_CellSelIndValue_EUTRAN(cells);
2329}
2330
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002331private function f_tc_si2quater_n_earfcns(integer n) runs on test_CT
2332{
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002333 var template SystemInformationConfig sic := SystemInformationConfig_default;
Pau Espin Pedrol8ab62e42020-12-18 16:19:11 +01002334 sic.si2quater := f_tr_si2quater_earfcns(n);
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02002335 var template CellSelIndValue cells := f_tr_rr_chan_rel_earfcns(n);
2336 f_test_si2quater(n, sic, cells);
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002337}
2338
2339testcase TC_si2quater_2_earfcns() runs on test_CT {
2340 f_tc_si2quater_n_earfcns(2);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002341 f_shutdown_helper();
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002342}
2343
2344testcase TC_si2quater_3_earfcns() runs on test_CT {
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002345 f_tc_si2quater_n_earfcns(3);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002346 f_shutdown_helper();
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002347}
2348
2349testcase TC_si2quater_4_earfcns() runs on test_CT {
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002350 f_tc_si2quater_n_earfcns(4);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002351 f_shutdown_helper();
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002352}
2353
2354testcase TC_si2quater_5_earfcns() runs on test_CT {
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002355 f_tc_si2quater_n_earfcns(5);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002356 f_shutdown_helper();
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002357}
2358
2359testcase TC_si2quater_6_earfcns() runs on test_CT {
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002360 f_tc_si2quater_n_earfcns(6);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002361 f_shutdown_helper();
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002362}
2363
2364testcase TC_si2quater_12_earfcns() runs on test_CT {
2365 f_tc_si2quater_n_earfcns(12);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002366 f_shutdown_helper();
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002367}
2368
2369testcase TC_si2quater_23_earfcns() runs on test_CT {
2370 f_tc_si2quater_n_earfcns(23);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002371 f_shutdown_helper();
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002372}
2373
2374testcase TC_si2quater_32_earfcns() runs on test_CT {
2375 f_tc_si2quater_n_earfcns(32);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002376 f_shutdown_helper();
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002377}
2378
2379testcase TC_si2quater_33_earfcns() runs on test_CT {
2380 f_tc_si2quater_n_earfcns(33);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002381 f_shutdown_helper();
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002382}
2383
2384testcase TC_si2quater_42_earfcns() runs on test_CT {
2385 f_tc_si2quater_n_earfcns(42);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002386 f_shutdown_helper();
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002387}
2388
2389testcase TC_si2quater_48_earfcns() runs on test_CT {
2390 f_tc_si2quater_n_earfcns(48);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002391 f_shutdown_helper();
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002392}
2393
2394/* verify the VTY error response when adding too many EARFCNs, and showing that osmo-bsc still sends 16 SI2quater with
2395 * 48 EARFCNs. */
2396testcase TC_si2quater_49_earfcns() runs on test_CT {
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002397 var template SystemInformationConfig sic := SystemInformationConfig_default;
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002398 sic.si2quater := f_tr_si2quater_earfcns(48); /* 48, not 49! */
2399 f_init(0);
2400
2401 for (var integer i := 1; i < 48; i := i + 1) {
Neels Hofmeyr56f24782020-07-09 00:50:49 +02002402 f_bts_0_cfg(BSCVTY, {"si2quater neighbor-list add earfcn " & int2str(f_test_si2quater_earfcn_by_idx(i))
2403 & " thresh-hi 20 thresh-lo 10 prio 3 qrxlv 22 meas 3"});
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002404 }
2405
2406 /* The 49th EARFCN no longer fits, expect VTY error */
2407 f_vty_enter_cfg_bts(BSCVTY, 0);
2408 var charstring vty_error;
2409 vty_error := f_vty_transceive_ret(BSCVTY,
2410 "si2quater neighbor-list add earfcn 70 thresh-hi 20 thresh-lo 10 prio 3 qrxlv 22 meas 3")
2411 f_vty_transceive(BSCVTY, "end");
2412
2413 if (f_strstr(vty_error, "Unable to add ARFCN 70") >= 0) {
2414 log("Got expected VTY error: ", vty_error);
2415 setverdict(pass);
2416 } else {
2417 setverdict(fail, "Expected the 49th EUTRAN ARFCN to be rejected by vty config, got: ", vty_error);
2418 }
2419
2420 f_init_bts_and_check_sysinfo(0, expect_si := sic);
2421
2422 for (var integer i := 1; i < 48; i := i + 1) {
Neels Hofmeyr56f24782020-07-09 00:50:49 +02002423 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 +02002424 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002425 f_shutdown_helper();
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002426}
2427
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02002428private function f_acc09_count_allowed(AccessControlClass acc) return uint8_t
2429{
2430 var uint8_t count := 0;
2431 for (var integer i := 5; i < 16; i := i + 1) {
2432 if (acc[i] == '0'B) { /* the list marks barred, we count allowed */
2433 count := count + 1;
2434 }
2435 }
2436 return count;
2437}
2438
Pau Espin Pedrolc6136cd2020-07-24 13:20:02 +02002439private function f_recv_next_si1(integer rsl_idx := 0) runs on test_CT return SystemInformationType1
2440{
2441 var ASP_RSL_Unitdata rx_rsl_ud;
2442 var SystemInformationType1 last_si1;
2443
2444 timer T := 30.0;
2445 T.start;
2446 alt {
2447 [] IPA_RSL[rsl_idx].receive(tr_ASP_RSL_UD((tr_RSL_NO_BCCH_INFO,
2448 tr_RSL_BCCH_INFO,
2449 tr_RSL_NO_SACCH_FILL,
2450 tr_RSL_SACCH_FILL))
2451 ) -> value rx_rsl_ud {
2452 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
2453 if (g_system_information[rsl_idx].si1 == omit) {
2454 repeat;
2455 }
2456 last_si1 := g_system_information[rsl_idx].si1;
2457 g_system_information[rsl_idx].si1 := omit;
2458 T.stop;
2459 }
2460 [] T.timeout { setverdict(fail, "Timeout receiving next SI1"); }
2461 }
2462 return last_si1;
2463}
2464
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02002465/* verify ACC rotate feature */
2466testcase TC_si_acc_rotate() runs on test_CT {
2467 var template SystemInformationConfig sic := SystemInformationConfig_default;
Pau Espin Pedrolc6136cd2020-07-24 13:20:02 +02002468 var SystemInformationType1 last_si1;
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02002469 var AccessControlClass acc;
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02002470 var uint8_t count;
2471 var integer times_allowed[10] := { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
2472
2473 f_init(0, guard_timeout := 60.0);
2474
2475 f_bts_0_cfg(BSCVTY, {"rach access-control-class 5 barred",
2476 "access-control-class-rotate 3",
2477 "access-control-class-rotate-quantum 1"});
2478
2479 /* Init and get first sysinfo */
2480 f_init_bts_and_check_sysinfo(0, expect_si := ?);
2481
Pau Espin Pedrolc6136cd2020-07-24 13:20:02 +02002482 for (var integer i:= 0; i < 20; i := i + 1) {
2483 last_si1 := f_recv_next_si1(0);
2484 acc := last_si1.rach_control.acc;
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02002485 count := f_acc09_count_allowed(acc);
2486 log("RSL: GOT SI1 ACC len=", count, ": ", acc);
2487
2488 if (count != 3) {
2489 log("RSL: EXPECTED SI ACC len=3");
2490 setverdict(fail, "received SI does not match expectations");
2491 break;
2492 }
2493
2494 for (var integer j := 0; j < 10; j := j + 1) {
2495 if (acc[16 - 1 - j] == '0'B) { /* the list marks barred, we count allowed */
2496 times_allowed[j] := times_allowed[j] + 1;
2497 }
2498 }
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02002499 }
2500
2501 for (var integer j := 0; j < 10; j := j + 1) {
2502 log("ACC", j, " allowed ", times_allowed[j], " times" );
2503 if (j != 5 and times_allowed[j] < 3) {
2504 setverdict(fail, "ACC", j, " ERROR: allowed ", times_allowed[j], " < 1 times");
2505 } else if (j == 5 and times_allowed[j] > 0) {
2506 setverdict(fail, "ACC", j, " ERROR: allowed ", times_allowed[j], " > 0 times");
2507 }
2508 }
2509
2510 f_bts_0_cfg(BSCVTY, {"access-control-class-rotate 10",
2511 "rach access-control-class 5 allowed"});
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002512 f_shutdown_helper();
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02002513}
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002514
Pau Espin Pedrolc6136cd2020-07-24 13:20:02 +02002515/* verify ACC startup ramp+rotate feature */
2516testcase TC_si_acc_ramp_rotate() runs on test_CT {
2517 var template SystemInformationConfig sic := SystemInformationConfig_default;
2518 var SystemInformationType1 last_si1;
2519 var AccessControlClass acc;
2520 var ASP_RSL_Unitdata rx_rsl_ud;
2521 var uint8_t count;
2522 var uint8_t prev_count;
2523 var integer times_allowed[10] := { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
2524
2525 f_init(0, guard_timeout := 80.0);
2526
2527 f_bts_0_cfg(BSCVTY, {"rach access-control-class 4 barred",
2528 "access-control-class-rotate 0",
2529 "access-control-class-rotate-quantum 1",
2530 "access-control-class-ramping",
2531 "access-control-class-ramping-step-interval 5",
2532 "access-control-class-ramping-step-size 5"});
2533
2534 /* Init and get first sysinfo */
2535 f_init_bts_and_check_sysinfo(0, expect_si := ?);
2536 last_si1 := g_system_information[0].si1;
2537 acc := last_si1.rach_control.acc;
2538 count := f_acc09_count_allowed(acc);
2539 /* Adm subset size was set to 0 above, so wait until all ACC are barred */
2540 while (count > 0) {
2541 last_si1 := f_recv_next_si1(0);
2542 acc := last_si1.rach_control.acc;
2543 count := f_acc09_count_allowed(acc);
2544 log("RSL: wait len()=0: GOT SI1 ACC len=", count, ": ", acc);
2545 }
2546
2547 /* Increase adm subset size, we should see ramping start up */
2548 f_bts_0_cfg(BSCVTY, {"access-control-class-rotate 10"});
2549 prev_count := 0;
2550 while (true) {
2551 last_si1 := f_recv_next_si1(0);
2552 acc := last_si1.rach_control.acc;
2553 count := f_acc09_count_allowed(acc);
2554 log("RSL: GOT SI1 ACC len=", count, ": ", acc);
2555
2556 if (prev_count > count) {
2557 setverdict(fail, "ACC allowed count dropped while expecting grow: ", prev_count, " -> ", count);
2558 break;
2559 }
2560
2561 if (count == 9) {
2562 break; /* Maximum reached (10 - 1 perm barred), done here */
2563 }
2564
2565 prev_count := count;
2566 }
2567
2568 setverdict(pass);
2569
2570 f_bts_0_cfg(BSCVTY, {"access-control-class-rotate 10",
2571 "rach access-control-class 4 allowed",
2572 "no access-control-class-ramping"});
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002573 f_shutdown_helper();
Pau Espin Pedrolc6136cd2020-07-24 13:20:02 +02002574}
2575
Harald Welte4003d112017-12-09 22:35:39 +01002576testcase TC_ctrl_msc_connection_status() runs on test_CT {
2577 var charstring ctrl_resp;
2578
Harald Welte89d42e82017-12-17 16:42:41 +01002579 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +01002580
2581 /* See https://osmocom.org/issues/2729 */
2582 f_ctrl_get_exp(IPA_CTRL, "msc_connection_status", "connected");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002583 f_shutdown_helper();
Harald Welte4003d112017-12-09 22:35:39 +01002584}
2585
Stefan Sperlingb041b3d2018-01-03 17:14:55 +01002586testcase TC_ctrl_msc0_connection_status() runs on test_CT {
2587 var charstring ctrl_resp;
2588
2589 f_init(1);
Stefan Sperlingb041b3d2018-01-03 17:14:55 +01002590
2591 f_ctrl_get_exp(IPA_CTRL, "msc.0.connection_status", "connected");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002592 f_shutdown_helper();
Stefan Sperlingb041b3d2018-01-03 17:14:55 +01002593}
2594
Harald Welte4003d112017-12-09 22:35:39 +01002595testcase TC_ctrl() runs on test_CT {
2596 var charstring ctrl_resp;
2597
Harald Welte89d42e82017-12-17 16:42:41 +01002598 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +01002599
2600 /* all below values must match the osmo-bsc.cfg config file used */
2601
Harald Welte6a129692018-03-17 17:30:14 +01002602 f_ctrl_get_exp(IPA_CTRL, "mcc", "001");
2603 f_ctrl_get_exp(IPA_CTRL, "mnc", "01");
Oliver Smith75aa0202019-08-19 14:17:50 +02002604 f_ctrl_get_exp(IPA_CTRL, "number-of-bts", "4");
Harald Welte4003d112017-12-09 22:35:39 +01002605
2606 var integer bts_nr := 0;
2607 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "location-area-code", "1");
2608 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "cell-identity", "0");
2609 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "oml-connection-state", "connected");
2610 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "gprs-mode", "gprs");
2611 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "rf_state", "operational,unlocked,on");
2612 f_ctrl_get_exp_trx(IPA_CTRL, bts_nr, 0, "arfcn", "871");
2613 f_ctrl_get_exp_trx(IPA_CTRL, bts_nr, 0, "max-power-reduction", "20");
2614
2615 var integer uptime := str2int(f_ctrl_get_bts(IPA_CTRL, bts_nr, "oml-uptime"));
2616 f_sleep(2.0);
2617 if (str2int(f_ctrl_get_bts(IPA_CTRL, bts_nr, "oml-uptime")) < uptime+1) {
2618 setverdict(fail, "oml-uptime not incrementing as expected");
2619 }
2620 /* TODO: Disconnect RSL, imply that OML is disconnected and check for uptime zero? */
2621
2622 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bsc", 0, "paging:attempted", 0);
2623
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002624 f_shutdown_helper();
Harald Welte96c94412017-12-09 03:12:45 +01002625}
2626
Pau Espin Pedrol5a2d7432019-06-07 19:43:45 +02002627/* Verify that Upon receival of SET "location", BSC forwards a TRAP
2628 "location-state" over the SCCPlite IPA conn */
2629testcase TC_ctrl_location() runs on test_CT {
2630 var MSC_ConnHdlr vc_conn;
2631 var integer bts_nr := 0;
2632
2633 f_init(1, true);
2634 f_sleep(1.0);
2635
2636 f_ctrl_set_bts(IPA_CTRL, bts_nr, "location", "1234567,fix3d,0.340000,0.560000,0.780000");
2637 f_ctrl_exp_trap(SCCPLITE_IPA_CTRL, "bts." & int2str(bts_nr) & ".location-state",
2638 "1234567,fix3d,0.340000,0.560000,0.780000,operational,unlocked,on,001,01");
2639
2640 f_ctrl_set(SCCPLITE_IPA_CTRL, "rf_locked", "1");
2641 f_sleep(2.0);
2642
2643 f_ctrl_set_bts(IPA_CTRL, bts_nr, "location", "1234888,fix3d,0.350000,0.570000,0.790000");
2644 f_ctrl_exp_trap(SCCPLITE_IPA_CTRL, "bts." & int2str(bts_nr) & ".location-state",
2645 "1234888,fix3d,0.350000,0.570000,0.790000,operational,locked,off,001,01");
2646
2647 /* should match the one from config */
2648 f_ctrl_set(SCCPLITE_IPA_CTRL, "rf_locked", "0");
2649
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002650 f_shutdown_helper();
Pau Espin Pedrol5a2d7432019-06-07 19:43:45 +02002651}
2652
Harald Welte6f521d82017-12-11 19:52:02 +01002653
2654/***********************************************************************
2655 * Paging Testing
2656 ***********************************************************************/
2657
2658type record Cell_Identity {
2659 GsmMcc mcc,
2660 GsmMnc mnc,
2661 GsmLac lac,
2662 GsmCellId ci
2663};
Harald Welte24135bd2018-03-17 19:27:53 +01002664private const Cell_Identity cid := { '001'H, '01'H, 1, 0 };
Stefan Sperling049a86e2018-03-20 15:51:00 +01002665private const Cell_Identity unknown_cid := { '678'H, 'f90'H, 1, 0 };
Harald Welte6f521d82017-12-11 19:52:02 +01002666
Harald Welte5d1a2202017-12-13 19:51:29 +01002667type set of integer BtsIdList;
2668
2669private function f_bts_in_list(integer bts_id, BtsIdList bts_ids) return boolean {
2670 for (var integer j := 0; j < sizeof(bts_ids); j := j + 1) {
2671 if (bts_id == bts_ids[j]) {
2672 return true;
2673 }
2674 }
2675 return false;
2676}
Harald Welte6f521d82017-12-11 19:52:02 +01002677
2678/* core paging test helper function; used by most paging test cases */
2679private function f_pageing_helper(hexstring imsi,
2680 template BSSMAP_FIELD_CellIdentificationList cid_list,
Harald Welte5d1a2202017-12-13 19:51:29 +01002681 BtsIdList bts_ids := { 0 },
Harald Welte6f521d82017-12-11 19:52:02 +01002682 template RSL_ChanNeeded rsl_chneed := omit,
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07002683 template (omit) OCT4 tmsi := omit) runs on test_CT
Harald Welte6f521d82017-12-11 19:52:02 +01002684{
2685 var template BSSMAP_IE_ChannelNeeded bssmap_chneed;
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07002686 var template MobileIdentityV mi;
Harald Welte6f521d82017-12-11 19:52:02 +01002687 var RSL_Message rx_rsl;
2688 var integer paging_group := hex2int(imsi[lengthof(imsi)-1]);
Harald Welte5d1a2202017-12-13 19:51:29 +01002689 var integer i;
Harald Welte6f521d82017-12-11 19:52:02 +01002690
2691 f_init();
Harald Welte6f521d82017-12-11 19:52:02 +01002692
2693 /* Clear the queue, it might still contain stuff like BCCH FILLING */
Harald Weltec3068592018-03-17 19:55:31 +01002694 for (i := 0; i < NUM_BTS; i := i + 1) {
2695 IPA_RSL[i].clear;
Harald Welte5d1a2202017-12-13 19:51:29 +01002696 }
Harald Welte6f521d82017-12-11 19:52:02 +01002697
2698 if (isvalue(rsl_chneed)) {
2699 /* The values of 08.08 3.2.2.36 and 08.58 9.3.40 are luckily identical */
2700 bssmap_chneed := ts_BSSMAP_IE_ChanNeeded(int2bit(enum2int(valueof(rsl_chneed)),2));
2701 } else {
2702 bssmap_chneed := omit;
2703 }
2704
Neels Hofmeyrf246a922020-05-13 02:27:10 +02002705 BSSAP.send(ts_BSSAP_UNITDATA_req(g_bssap[0].sccp_addr_peer, g_bssap[0].sccp_addr_own,
2706 ts_BSSMAP_Paging(imsi, cid_list, tmsi, bssmap_chneed)));
Harald Welte6f521d82017-12-11 19:52:02 +01002707
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07002708 if (not istemplatekind(tmsi, "omit")) {
2709 mi := t_MI_TMSI(tmsi);
Harald Welte6f521d82017-12-11 19:52:02 +01002710 } else {
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07002711 mi := tr_MI_IMSI(imsi);
Harald Welte6f521d82017-12-11 19:52:02 +01002712 }
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07002713
Harald Welte5d1a2202017-12-13 19:51:29 +01002714 for (i := 0; i < sizeof(bts_ids); i := i + 1) {
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07002715 rx_rsl := f_exp_ipa_rx(bts_ids[i], tr_RSL_PAGING_CMD(mi));
Harald Welte5d1a2202017-12-13 19:51:29 +01002716 /* check channel type, paging group */
2717 if (rx_rsl.ies[1].body.paging_group != paging_group) {
2718 setverdict(fail, "Paging for wrong paging group");
2719 }
2720 if (ispresent(rsl_chneed) and
2721 rx_rsl.ies[3].body.chan_needed.chan_needed != valueof(rsl_chneed)) {
2722 setverdict(fail, "RSL Channel Needed != BSSMAP Channel Needed");
2723 }
Harald Welte6f521d82017-12-11 19:52:02 +01002724 }
Harald Welte2fccd982018-01-31 15:48:19 +01002725 f_sleep(2.0);
Harald Welte5d1a2202017-12-13 19:51:29 +01002726 /* do a quick check on all not-included BTSs if they received paging */
2727 for (i := 0; i < NUM_BTS; i := i + 1) {
2728 timer T := 0.1;
2729 if (f_bts_in_list(i, bts_ids)) {
2730 continue;
2731 }
2732 T.start;
2733 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07002734 [] IPA_RSL[i].receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD(mi))) {
Harald Welte5d1a2202017-12-13 19:51:29 +01002735 setverdict(fail, "Paging on BTS ", i, " which is not part of ", bts_ids);
2736 }
2737 [] IPA_RSL[i].receive { repeat; }
2738 [] T.timeout { }
2739 }
Harald Welte6f521d82017-12-11 19:52:02 +01002740 }
2741
2742 setverdict(pass);
2743}
2744
Harald Welte5d1a2202017-12-13 19:51:29 +01002745const BtsIdList c_BtsId_all := { 0, 1, 2 };
Harald Welte751d3eb2018-01-31 15:51:06 +01002746const BtsIdList c_BtsId_none := { };
Harald Welte5d1a2202017-12-13 19:51:29 +01002747const BtsIdList c_BtsId_LAC1 := { 0, 1 };
2748const BtsIdList c_BtsId_LAC2 := { 2 };
2749
Harald Welte6f521d82017-12-11 19:52:02 +01002750/* PAGING by IMSI + TMSI */
2751testcase TC_paging_imsi_nochan() runs on test_CT {
2752 var BSSMAP_FIELD_CellIdentificationList cid_list;
2753 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Philipp Maier8c04b0a2018-02-23 13:48:48 +01002754 f_pageing_helper('001010100000001'H, cid_list, c_BtsId_all, omit, omit);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002755 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002756}
2757
2758/* PAGING by IMSI + TMSI */
2759testcase TC_paging_tmsi_nochan() runs on test_CT {
2760 var BSSMAP_FIELD_CellIdentificationList cid_list;
2761 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01002762 f_pageing_helper('001010100000001'H, cid_list, c_BtsId_all, omit, 'A1B2C301'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002763 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002764}
2765
2766/* Paging with different "channel needed' values */
2767testcase TC_paging_tmsi_any() runs on test_CT {
2768 var BSSMAP_FIELD_CellIdentificationList cid_list;
2769 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01002770 f_pageing_helper('001010100000002'H, cid_list, c_BtsId_all, RSL_CHANNEED_ANY, 'A1B2C302'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002771 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002772}
2773testcase TC_paging_tmsi_sdcch() runs on test_CT {
2774 var BSSMAP_FIELD_CellIdentificationList cid_list;
2775 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01002776 f_pageing_helper('001010100000003'H, cid_list, c_BtsId_all, RSL_CHANNEED_SDCCH, 'A1B2C303'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002777 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002778}
2779testcase TC_paging_tmsi_tch_f() runs on test_CT {
2780 var BSSMAP_FIELD_CellIdentificationList cid_list;
2781 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01002782 f_pageing_helper('001010000000004'H, cid_list, c_BtsId_all, RSL_CHANNEED_TCH_F, 'A1B2C304'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002783 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002784}
2785testcase TC_paging_tmsi_tch_hf() runs on test_CT {
2786 var BSSMAP_FIELD_CellIdentificationList cid_list;
2787 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01002788 f_pageing_helper('001010000000005'H, cid_list, c_BtsId_all, RSL_CHANNEED_TCH_ForH, 'A1B2C305'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002789 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002790}
2791
2792/* Paging by CGI */
2793testcase TC_paging_imsi_nochan_cgi() runs on test_CT {
2794 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2795 cid_list := { cIl_CGI := { ts_BSSMAP_CI_CGI(cid.mcc, cid.mnc, cid.lac, cid.ci) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01002796 f_pageing_helper('001010000000006'H, cid_list, { 0 });
Philipp Maier282ca4b2018-02-27 17:17:00 +01002797 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002798}
2799
2800/* Paging by LAC+CI */
2801testcase TC_paging_imsi_nochan_lac_ci() runs on test_CT {
2802 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2803 cid_list := { cIl_LAC_CI := { ts_BSSMAP_CI_LAC_CI(cid.lac, cid.ci) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01002804 f_pageing_helper('001010000000007'H, cid_list, { 0 });
Philipp Maier282ca4b2018-02-27 17:17:00 +01002805 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002806}
2807
2808/* Paging by CI */
2809testcase TC_paging_imsi_nochan_ci() runs on test_CT {
2810 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2811 cid_list := { cIl_CI := { ts_BSSMAP_CI_CI(cid.ci) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01002812 f_pageing_helper('001010000000008'H, cid_list, { 0 });
Philipp Maier282ca4b2018-02-27 17:17:00 +01002813 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002814}
2815
2816/* Paging by LAI */
2817testcase TC_paging_imsi_nochan_lai() runs on test_CT {
2818 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2819 cid_list := { cIl_LAI := { ts_BSSMAP_CI_LAI(cid.mcc, cid.mnc, cid.lac) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01002820 f_pageing_helper('001010000000009'H, cid_list, c_BtsId_LAC1);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002821 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002822}
2823
2824/* Paging by LAC */
2825testcase TC_paging_imsi_nochan_lac() runs on test_CT {
2826 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2827 cid_list := { cIl_LAC := { ts_BSSMAP_CI_LAC(cid.lac) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01002828 f_pageing_helper('001010000000010'H, cid_list, c_BtsId_LAC1);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002829 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002830}
2831
2832/* Paging by "all in BSS" */
2833testcase TC_paging_imsi_nochan_all() runs on test_CT {
2834 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2835 cid_list := { cIl_allInBSS := ''O };
Harald Welte5d1a2202017-12-13 19:51:29 +01002836 f_pageing_helper('001010000000011'H, cid_list, c_BtsId_all);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002837 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002838}
2839
Stefan Sperling7b5e1782018-03-20 19:32:43 +01002840/* Paging by PLMN+LAC+RNC; We do not implement this; Verify nothing is paged */
Harald Welte751d3eb2018-01-31 15:51:06 +01002841testcase TC_paging_imsi_nochan_plmn_lac_rnc() runs on test_CT {
2842 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2843 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 +01002844 f_pageing_helper('001010000000012'H, cid_list, c_BtsId_none);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002845 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01002846}
Harald Welte6f521d82017-12-11 19:52:02 +01002847
Stefan Sperling7b5e1782018-03-20 19:32:43 +01002848/* Paging by RNC; We do not implement this; Verify nothing is paged */
Harald Welte751d3eb2018-01-31 15:51:06 +01002849testcase TC_paging_imsi_nochan_rnc() runs on test_CT {
2850 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2851 cid_list := { cIl_RNC := { int2oct(13, 2) } };
Stefan Sperling7b5e1782018-03-20 19:32:43 +01002852 f_pageing_helper('001010000000013'H, cid_list, c_BtsId_none);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002853 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01002854}
2855
Stefan Sperling7b5e1782018-03-20 19:32:43 +01002856/* Paging by LAC+RNC; We do not implement; Verify nothing is paged */
Harald Welte751d3eb2018-01-31 15:51:06 +01002857testcase TC_paging_imsi_nochan_lac_rnc() runs on test_CT {
2858 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2859 cid_list := { cIl_LAC_RNC := { ts_BSSMAP_CI_LAC_RNC(cid.lac, 14) } };
Stefan Sperling7b5e1782018-03-20 19:32:43 +01002860 f_pageing_helper('001010000000014'H, cid_list, c_BtsId_none);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002861 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01002862}
2863
Harald Welte6f521d82017-12-11 19:52:02 +01002864/* Paging on multiple cells (multiple entries in list): Verify all of them page */
Harald Welte751d3eb2018-01-31 15:51:06 +01002865testcase TC_paging_imsi_nochan_lacs() runs on test_CT {
2866 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2867 cid_list := { cIl_LAC := { ts_BSSMAP_CI_LAC(1), ts_BSSMAP_CI_LAC(2) } };
2868 f_pageing_helper('001010000000015'H, cid_list, c_BtsId_all);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002869 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01002870}
2871
2872/* Paging on empty list: Verify none of them page */
2873testcase TC_paging_imsi_nochan_lacs_empty() runs on test_CT {
2874 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2875 cid_list := { cIl_LAC := { } };
2876 f_pageing_helper('001010000000016'H, cid_list, c_BtsId_none);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002877 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01002878}
2879
Stefan Sperling049a86e2018-03-20 15:51:00 +01002880/* Paging by CGI with unknown MCC/MNC: Verify nothing is paged. */
2881testcase TC_paging_imsi_nochan_cgi_unknown_cid() runs on test_CT {
2882 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2883 cid_list := { cIl_CGI := { ts_BSSMAP_CI_CGI(unknown_cid.mcc, unknown_cid.mnc, unknown_cid.lac, unknown_cid.ci) } };
2884 f_pageing_helper('001010000000006'H, cid_list, c_BtsId_none);
2885 f_shutdown_helper();
2886}
2887
Harald Welte6f521d82017-12-11 19:52:02 +01002888/* Verify paging retransmission interval + count */
2889/* Verify paging stops after channel establishment */
Harald Welte6f521d82017-12-11 19:52:02 +01002890/* Test behavior under paging overload */
Harald Welteae026692017-12-09 01:03:01 +01002891
Harald Weltee65d40e2017-12-13 00:09:06 +01002892/* Verify PCH load */
2893testcase TC_paging_imsi_load() runs on test_CT {
2894 var BSSMAP_FIELD_CellIdentificationList cid_list;
2895 timer T := 4.0;
Harald Welte2caa1062018-03-17 18:19:05 +01002896 timer T_retrans := 1.0;
Harald Weltee65d40e2017-12-13 00:09:06 +01002897 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01002898 f_pageing_helper('001010123456789'H, cid_list, c_BtsId_all);
Harald Weltee65d40e2017-12-13 00:09:06 +01002899
2900 /* tell BSC there is no paging space anymore */
2901 f_ipa_tx(0, ts_RSL_PAGING_LOAD_IND(0));
Harald Welte3b57ab52018-03-17 18:01:10 +01002902 f_sleep(0.2);
2903 IPA_RSL[0].clear;
Harald Weltee65d40e2017-12-13 00:09:06 +01002904
2905 /* Wait for 4 seconds if any more PAGING CMD are received on RSL. Normally,
2906 * there would be 8 retransmissions during 4 seconds */
2907 T.start;
Harald Welte2caa1062018-03-17 18:19:05 +01002908 T_retrans.start;
Harald Weltee65d40e2017-12-13 00:09:06 +01002909 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07002910 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD(?))) {
Harald Weltee65d40e2017-12-13 00:09:06 +01002911 setverdict(fail, "Received PAGING after LOAD_IND(0)");
Daniel Willmannafce8662018-07-06 23:11:32 +02002912 mtc.stop;
Harald Weltee65d40e2017-12-13 00:09:06 +01002913 }
Harald Welte2caa1062018-03-17 18:19:05 +01002914 [] T_retrans.timeout {
2915 /* re-trnsmit the zero-space LOAD IND to avoid BSC 'auto credit' */
2916 f_ipa_tx(0, ts_RSL_PAGING_LOAD_IND(0));
2917 T_retrans.start;
2918 repeat;
2919 }
Harald Weltee65d40e2017-12-13 00:09:06 +01002920 [] T.timeout {
2921 setverdict(pass);
2922 }
2923 }
Philipp Maier282ca4b2018-02-27 17:17:00 +01002924
2925 f_shutdown_helper();
Harald Weltee65d40e2017-12-13 00:09:06 +01002926}
2927
Harald Welte235ebf12017-12-15 14:18:16 +01002928/* Verify Paging Counter */
Harald Welte1ff69992017-12-14 12:31:17 +01002929testcase TC_paging_counter() runs on test_CT {
2930 var BSSMAP_FIELD_CellIdentificationList cid_list;
2931 timer T := 4.0;
2932 var integer i;
2933 var integer paging_attempted_bsc;
2934 var integer paging_attempted_bts[NUM_BTS];
2935 var integer paging_expired_bts[NUM_BTS];
2936 cid_list := valueof(ts_BSSMAP_CIL_noCell);
2937
2938 f_init();
2939
2940 /* read counters before paging */
2941 paging_attempted_bsc := f_ctrl_get_ratectr_abs(IPA_CTRL, "bsc", 0, "paging:attempted");
2942 for (i := 0; i < NUM_BTS; i := i+1) {
2943 paging_attempted_bts[i] := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", i, "paging:attempted");
2944 paging_expired_bts[i] := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", i, "paging:expired");
2945 }
2946
2947 f_pageing_helper('001230000000001'H, cid_list, c_BtsId_all);
2948
2949 /* expect the attempted pages on BSC and each BTSs to have incremented by one */
2950 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bsc", 0, "paging:attempted", paging_attempted_bsc+1);
2951 for (i := 0; i < NUM_BTS; i := i+1) {
2952 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", i, "paging:attempted",
2953 paging_attempted_bts[i]+1);
2954 }
2955
2956 /* assume that 12s later the paging on all BTSs have expired and hence incremented by 1 */
2957 f_sleep(12.0);
2958 for (i := 0; i < NUM_BTS; i := i+1) {
2959 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", i, "paging:expired",
2960 paging_expired_bts[i]+1);
2961 }
Harald Welte1ff69992017-12-14 12:31:17 +01002962
Philipp Maier282ca4b2018-02-27 17:17:00 +01002963 f_shutdown_helper();
Harald Welte1ff69992017-12-14 12:31:17 +01002964}
2965
2966
Harald Welte10985002017-12-12 09:29:15 +01002967/* Verify paging stops after A-RESET */
2968testcase TC_paging_imsi_a_reset() runs on test_CT {
2969 var BSSMAP_FIELD_CellIdentificationList cid_list;
2970 timer T := 3.0;
2971 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01002972 f_pageing_helper('001010123456789'H, cid_list, c_BtsId_all);
Harald Welte10985002017-12-12 09:29:15 +01002973
2974 /* Perform a BSSMAP Reset and wait for ACK */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02002975 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 +01002976 alt {
Neels Hofmeyrf246a922020-05-13 02:27:10 +02002977 [] 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 +01002978 [] BSSAP.receive { repeat; }
2979 }
2980
Daniel Willmanncbef3982018-07-30 09:22:40 +02002981 /* Wait to avoid a possible race condition if a paging message is
2982 * received right before the reset ACK. */
2983 f_sleep(0.2);
2984
Harald Welte10985002017-12-12 09:29:15 +01002985 /* Clear the queue, it might still contain stuff like BCCH FILLING */
Philipp Maier1e6b4422018-02-23 14:02:13 +01002986 for (var integer i := 0; i < sizeof(IPA_RSL); i := i+1) {
2987 IPA_RSL[i].clear;
2988 }
Harald Welte10985002017-12-12 09:29:15 +01002989
2990 /* Wait for 3 seconds if any more PAGING CMD are received on RSL */
2991 T.start;
2992 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07002993 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD(?))) {
Harald Welte10985002017-12-12 09:29:15 +01002994 setverdict(fail, "Received PAGING after A-RESET");
Daniel Willmannafce8662018-07-06 23:11:32 +02002995 mtc.stop;
Harald Welte10985002017-12-12 09:29:15 +01002996 }
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07002997 [] IPA_RSL[1].receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD(?))) {
Harald Welte5d1a2202017-12-13 19:51:29 +01002998 setverdict(fail, "Received PAGING after A-RESET");
Daniel Willmannafce8662018-07-06 23:11:32 +02002999 mtc.stop;
Harald Welte5d1a2202017-12-13 19:51:29 +01003000 }
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07003001 [] IPA_RSL[2].receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD(?))) {
Harald Welte5d1a2202017-12-13 19:51:29 +01003002 setverdict(fail, "Received PAGING after A-RESET");
Daniel Willmannafce8662018-07-06 23:11:32 +02003003 mtc.stop;
Harald Welte5d1a2202017-12-13 19:51:29 +01003004 }
Harald Welte10985002017-12-12 09:29:15 +01003005 [] T.timeout {
3006 setverdict(pass);
3007 }
3008 }
Philipp Maier282ca4b2018-02-27 17:17:00 +01003009
3010 f_shutdown_helper();
Harald Welte10985002017-12-12 09:29:15 +01003011}
Harald Welteae026692017-12-09 01:03:01 +01003012
Philipp Maierf45824a2019-08-14 14:44:10 +02003013/* Verify how we handle unsolicited Paging Response. In case of an unsolicit
3014 * paging response we can not know which MSC is in charge, so we will blindly
3015 * pick the first configured MSC. This behavior is required in order to make
3016 * MT-CSFB calls working because in those cases the BSC can not know that the
3017 * MSC has already paged the subscriver via SGs. So any MT-CSFB call will look
3018 * like an unsolicited Paging Response to the MSC.
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01003019 */
3020testcase TC_paging_resp_unsol() runs on test_CT {
3021
3022 f_init(1);
Philipp Maierf45824a2019-08-14 14:44:10 +02003023 timer T := 5.0;
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01003024
3025 var BSSAP_N_CONNECT_ind rx_c_ind;
3026 var DchanTuple dt;
3027 var PDU_ML3_MS_NW l3 := valueof(ts_PAG_RESP(valueof(ts_MI_IMSI_LV('001010008880018'H))));
Philipp Maierf45824a2019-08-14 14:44:10 +02003028 var octetstring rr_pag_resp := enc_PDU_ML3_MS_NW(l3);
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01003029
3030 /* Send CHAN RQD and wait for allocation; acknowledge it */
3031 dt.rsl_chan_nr := f_chreq_act_ack();
3032
3033 /* Send unsolicited Paging response (no matching Paging CMD stored in BSC) */
3034 f_ipa_tx(0, ts_RSL_EST_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0)), enc_PDU_ML3_MS_NW(l3)));
3035
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01003036
Philipp Maierf45824a2019-08-14 14:44:10 +02003037 /* Expevct a CR with a matching Paging response on the A-Interface */
3038 T.start;
3039 alt {
3040 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(rr_pag_resp))) {
3041 setverdict(pass);
3042 }
3043 [] BSSAP.receive {
3044 setverdict(fail, "Received unexpected message on A-Interface!");
3045 }
3046 [] T.timeout {
3047 setverdict(fail, "Received nothing on A-Interface!");
3048 }
3049 }
3050
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003051 f_shutdown_helper();
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01003052}
3053
Harald Welte4e9b9cc2017-12-14 18:31:02 +01003054/* Test RSL link drop causes counter increment */
3055testcase TC_rsl_drop_counter() runs on test_CT {
3056 var integer rsl_fail;
3057
Harald Welte89d42e82017-12-17 16:42:41 +01003058 f_init(1);
Harald Welte4e9b9cc2017-12-14 18:31:02 +01003059
3060 rsl_fail := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "rsl_fail");
3061
3062 bts[0].rsl.vc_IPA.stop;
3063
3064 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "rsl_fail", rsl_fail+1);
3065
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003066 f_shutdown_helper();
Harald Welte4e9b9cc2017-12-14 18:31:02 +01003067}
3068
3069/* TODO: Test OML link drop causes counter increment */
3070
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003071/* The body of TC_rsl_unknown_unit_id() and TC_oml_unknown_unit_id() tests. */
3072function f_ipa_unknown_unit_id(integer mp_bsc_ipa_port) runs on test_CT return boolean {
3073 timer T := 10.0;
3074
3075 bts[0].rsl.id := "IPA-0-RSL";
3076 bts[0].rsl.vc_IPA := IPA_Emulation_CT.create(bts[0].rsl.id & "-IPA");
3077 bts[0].rsl.ccm_pars := c_IPA_default_ccm_pars;
3078 bts[0].rsl.ccm_pars.name := "Osmocom TTCN-3 BTS Simulator";
Oliver Smith92c2bdb2019-08-20 15:11:24 +02003079 bts[0].rsl.ccm_pars.unit_id := "99/0/0"; /* value which is unknown at BTS */
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003080
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003081 f_ipa_ctrl_start(mp_bsc_ip, mp_bsc_ctrl_port);
3082
3083 f_init_mgcp("VirtMSC");
3084
3085 /* start RSL/OML connection (XXX re-uses RSL port/protocol definitions for OML) */
3086 map(bts[0].rsl.vc_IPA:IPA_PORT, system:IPA);
3087 connect(bts[0].rsl.vc_IPA:IPA_RSL_PORT, self:IPA_RSL[0]);
3088 bts[0].rsl.vc_IPA.start(IPA_Emulation.main_client(mp_bsc_ip, mp_bsc_ipa_port, "", 10000, bts[0].rsl.ccm_pars));
3089
3090 /* wait for IPA OML link to connect and then disconnect */
3091 T.start;
3092 alt {
Vadim Yanitskiya2afacc2020-05-18 21:16:19 +07003093 [] IPA_RSL[0].receive(tr_ASP_IPA_EV(ASP_IPA_EVENT_DOWN)) {
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003094 T.stop;
3095 return true;
3096 }
3097 [] IPA_RSL[0].receive { repeat }
3098 [] T.timeout {
Daniel Willmannafce8662018-07-06 23:11:32 +02003099 return false;
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003100 }
3101 }
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003102 return false;
3103}
3104
3105/* BSC should close an RSL connection from a BTS with unknown unit ID (OS#2714). */
3106testcase TC_rsl_unknown_unit_id() runs on test_CT {
3107 if (f_ipa_unknown_unit_id(mp_bsc_rsl_port)) {
3108 setverdict(pass);
3109 } else {
3110 setverdict(fail, "Timeout RSL waiting for connection to close");
3111 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003112 f_shutdown_helper();
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003113}
3114
3115
3116/* BSC should close an RSL connection from a BTS with unknown unit ID (OS#2714). */
3117testcase TC_oml_unknown_unit_id() runs on test_CT {
3118 if (f_ipa_unknown_unit_id(mp_bsc_oml_port)) {
3119 setverdict(pass);
3120 } else {
3121 setverdict(fail, "Timeout OML waiting for connection to close");
3122 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003123 f_shutdown_helper();
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003124}
3125
3126
Harald Weltec1a2fff2017-12-17 11:06:19 +01003127/***********************************************************************
Harald Welte6811d102019-04-14 22:23:14 +02003128 * "New world" test cases using RSL_Emulation + RAN_Emulation
Harald Weltec1a2fff2017-12-17 11:06:19 +01003129 ***********************************************************************/
3130
Harald Welte6811d102019-04-14 22:23:14 +02003131import from RAN_Emulation all;
Harald Welte47cd0e32020-08-21 12:39:11 +02003132import from BSSAP_LE_Emulation all;
Harald Weltec1a2fff2017-12-17 11:06:19 +01003133import from RSL_Emulation all;
3134import from MSC_ConnectionHandler all;
3135
3136type function void_fn(charstring id) runs on MSC_ConnHdlr;
3137
Harald Welte336820c2018-05-31 20:34:52 +02003138/* helper function to create and connect a MSC_ConnHdlr component */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003139private function f_connect_handler(inout MSC_ConnHdlr vc_conn, integer bssap_idx := 0) runs on test_CT {
3140 connect(vc_conn:RAN, g_bssap[bssap_idx].vc_RAN:PROC);
Daniel Willmann191e0d92018-01-17 12:44:35 +01003141 connect(vc_conn:MGCP_PROC, vc_MGCP:MGCP_PROC);
Harald Weltec1a2fff2017-12-17 11:06:19 +01003142 connect(vc_conn:RSL, bts[0].rsl.vc_RSL:CLIENT_PT);
Harald Weltef70df652018-01-29 22:00:23 +01003143 connect(vc_conn:RSL_PROC, bts[0].rsl.vc_RSL:RSL_PROC);
Philipp Maier88f4ae82018-03-01 14:00:58 +01003144 if (isvalue(bts[1])) {
Philipp Maier956a92f2018-02-16 10:58:07 +01003145 connect(vc_conn:RSL1, bts[1].rsl.vc_RSL:CLIENT_PT);
3146 connect(vc_conn:RSL1_PROC, bts[1].rsl.vc_RSL:RSL_PROC);
3147 }
Neels Hofmeyr91401012019-07-11 00:42:35 +02003148 if (isvalue(bts[2])) {
3149 connect(vc_conn:RSL2, bts[2].rsl.vc_RSL:CLIENT_PT);
3150 connect(vc_conn:RSL2_PROC, bts[2].rsl.vc_RSL:RSL_PROC);
3151 }
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003152 connect(vc_conn:BSSAP, g_bssap[bssap_idx].vc_RAN:CLIENT);
Neels Hofmeyrcfe44062020-10-15 02:28:08 +02003153 if (mp_enable_lcs_tests) {
3154 connect(vc_conn:BSSAP_LE, g_bssap_le.vc_BSSAP_LE:CLIENT);
3155 connect(vc_conn:BSSAP_LE_PROC, g_bssap_le.vc_BSSAP_LE:PROC);
3156 }
Daniel Willmann191e0d92018-01-17 12:44:35 +01003157 connect(vc_conn:MGCP, vc_MGCP:MGCP_CLIENT);
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +02003158 connect(vc_conn:MGCP_MULTI, vc_MGCP:MGCP_CLIENT_MULTI);
Daniel Willmannebdecc02020-08-12 15:30:17 +02003159 connect(vc_conn:STATSD_PROC, vc_STATSD:STATSD_PROC);
Harald Welte336820c2018-05-31 20:34:52 +02003160}
3161
3162function f_start_handler(void_fn fn, template (omit) TestHdlrParams pars := omit)
3163runs on test_CT return MSC_ConnHdlr {
3164 var charstring id := testcasename();
3165 var MSC_ConnHdlr vc_conn;
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003166 var integer bssap_idx := 0;
3167 if (isvalue(pars)) {
3168 bssap_idx := valueof(pars).mscpool.bssap_idx;
3169 }
Harald Welte336820c2018-05-31 20:34:52 +02003170 vc_conn := MSC_ConnHdlr.create(id);
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003171 f_connect_handler(vc_conn, bssap_idx);
Neels Hofmeyr1708d1b2020-10-10 16:56:48 +02003172 /* Emit a marker to appear in the SUT's own logging output */
3173 f_logp(BSCVTY, testcasename() & "() start");
Harald Weltea0630032018-03-20 21:09:55 +01003174 vc_conn.start(f_handler_init(fn, id, pars));
Harald Weltec1a2fff2017-12-17 11:06:19 +01003175 return vc_conn;
3176}
3177
Harald Weltea0630032018-03-20 21:09:55 +01003178/* first function inside ConnHdlr component; sets g_pars + starts function */
3179private function f_handler_init(void_fn fn, charstring id, template (omit) TestHdlrParams pars := omit)
3180runs on MSC_ConnHdlr {
3181 if (isvalue(pars)) {
3182 g_pars := valueof(pars);
3183 }
3184 fn.apply(id);
3185}
3186
Harald Welte3c86ea02018-05-10 22:28:05 +02003187/* Establish signalling channel (non-assignment case) followed by cipher mode */
3188private function f_tc_ciph_mode_a5(charstring id) runs on MSC_ConnHdlr {
Harald Welteed848512018-05-24 22:27:58 +02003189 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3190 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte3c86ea02018-05-10 22:28:05 +02003191 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeSIGNAL);
Philipp Maier23000732018-05-18 11:25:37 +02003192 ass_cmd.pdu.bssmap.assignmentRequest.circuitIdentityCode := omit;
3193 ass_cmd.pdu.bssmap.assignmentRequest.aoIPTransportLayer := omit;
3194 exp_compl.pdu.bssmap.assignmentComplete.circuitIdentityCode := omit;
3195 exp_compl.pdu.bssmap.assignmentComplete.aoIPTransportLayer := omit;
Harald Welte3c86ea02018-05-10 22:28:05 +02003196
Philipp Maier23000732018-05-18 11:25:37 +02003197 f_establish_fully(ass_cmd, exp_compl);
Harald Welte3c86ea02018-05-10 22:28:05 +02003198}
3199testcase TC_ciph_mode_a5_0() runs on test_CT {
3200 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02003201 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte3c86ea02018-05-10 22:28:05 +02003202 pars.encr := valueof(t_EncrParams('01'O, f_rnd_octstring(8)));
3203
3204 f_init(1, true);
3205 f_sleep(1.0);
3206 vc_conn := f_start_handler(refers(f_tc_ciph_mode_a5), pars);
3207 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003208 f_shutdown_helper();
Harald Welte3c86ea02018-05-10 22:28:05 +02003209}
3210testcase TC_ciph_mode_a5_1() runs on test_CT {
3211 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02003212 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte3c86ea02018-05-10 22:28:05 +02003213 pars.encr := valueof(t_EncrParams('02'O, f_rnd_octstring(8)));
3214
3215 f_init(1, true);
3216 f_sleep(1.0);
3217 vc_conn := f_start_handler(refers(f_tc_ciph_mode_a5), pars);
3218 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003219 f_shutdown_helper();
Harald Welte3c86ea02018-05-10 22:28:05 +02003220}
3221testcase TC_ciph_mode_a5_3() runs on test_CT {
3222 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02003223 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte3c86ea02018-05-10 22:28:05 +02003224 pars.encr := valueof(t_EncrParams('08'O, f_rnd_octstring(8)));
3225
3226 f_init(1, true);
3227 f_sleep(1.0);
3228 vc_conn := f_start_handler(refers(f_tc_ciph_mode_a5), pars);
3229 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003230 f_shutdown_helper();
Harald Welte3c86ea02018-05-10 22:28:05 +02003231}
3232
Pau Espin Pedrol07866632020-09-03 19:10:55 +02003233/* establish initial channel, enable ciphering followed by assignment to ciphered channel */
3234private function f_tc_assignment_aoip_tla_v6(charstring id) runs on MSC_ConnHdlr {
3235 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3236 var PDU_BSSAP ass_cmd := f_gen_ass_req(aoip_tla := "::3");
3237 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3238 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
3239
3240 f_establish_fully(ass_cmd, exp_compl);
3241}
3242testcase TC_assignment_aoip_tla_v6() runs on test_CT {
3243 var MSC_ConnHdlr vc_conn;
3244 var TestHdlrParams pars := f_gen_test_hdlr_pars();
3245
3246 f_init(1, true);
3247 f_sleep(1.0);
3248 vc_conn := f_start_handler(refers(f_tc_assignment_aoip_tla_v6), pars);
3249 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003250 f_shutdown_helper();
Pau Espin Pedrol07866632020-09-03 19:10:55 +02003251}
3252
Harald Welte3c86ea02018-05-10 22:28:05 +02003253
3254/* establish initial channel, enable ciphering followed by assignment to ciphered channel */
Harald Welte651fcdc2018-05-10 20:23:16 +02003255private function f_tc_assignment_fr_a5(charstring id) runs on MSC_ConnHdlr {
Harald Welteed848512018-05-24 22:27:58 +02003256 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3257 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Weltec1a2fff2017-12-17 11:06:19 +01003258
Harald Welte552620d2017-12-16 23:21:36 +01003259 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3260 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
Harald Welte73cd2712017-12-17 00:44:52 +01003261
Harald Weltea0630032018-03-20 21:09:55 +01003262 f_establish_fully(ass_cmd, exp_compl);
Harald Welte552620d2017-12-16 23:21:36 +01003263}
Harald Welte552620d2017-12-16 23:21:36 +01003264testcase TC_assignment_fr_a5_0() runs on test_CT {
3265 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02003266 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte651fcdc2018-05-10 20:23:16 +02003267 pars.encr := valueof(t_EncrParams('01'O, f_rnd_octstring(8)));
Harald Welte552620d2017-12-16 23:21:36 +01003268
Harald Welte89d42e82017-12-17 16:42:41 +01003269 f_init(1, true);
Harald Welte552620d2017-12-16 23:21:36 +01003270 f_sleep(1.0);
Harald Welte651fcdc2018-05-10 20:23:16 +02003271 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5), pars);
Harald Welte552620d2017-12-16 23:21:36 +01003272 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003273 f_shutdown_helper();
Harald Welte552620d2017-12-16 23:21:36 +01003274}
Harald Welte552620d2017-12-16 23:21:36 +01003275testcase TC_assignment_fr_a5_1() runs on test_CT {
Harald Weltec1a2fff2017-12-17 11:06:19 +01003276 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02003277 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte651fcdc2018-05-10 20:23:16 +02003278 pars.encr := valueof(t_EncrParams('02'O, f_rnd_octstring(8)));
Harald Weltec1a2fff2017-12-17 11:06:19 +01003279
Harald Welte89d42e82017-12-17 16:42:41 +01003280 f_init(1, true);
Harald Weltec1a2fff2017-12-17 11:06:19 +01003281 f_sleep(1.0);
Harald Welte651fcdc2018-05-10 20:23:16 +02003282 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5), pars);
3283 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003284 f_shutdown_helper();
Harald Welte651fcdc2018-05-10 20:23:16 +02003285}
3286testcase TC_assignment_fr_a5_3() runs on test_CT {
3287 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02003288 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte651fcdc2018-05-10 20:23:16 +02003289 pars.encr := valueof(t_EncrParams('08'O, f_rnd_octstring(8)));
Harald Weltec1a2fff2017-12-17 11:06:19 +01003290
Harald Welte651fcdc2018-05-10 20:23:16 +02003291 f_init(1, true);
3292 f_sleep(1.0);
3293 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5), pars);
Harald Weltec1a2fff2017-12-17 11:06:19 +01003294 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003295 f_shutdown_helper();
Harald Weltec1a2fff2017-12-17 11:06:19 +01003296}
3297
Harald Welte552620d2017-12-16 23:21:36 +01003298/* Expect ASSIGNMENT FAIL if mandatory IE is missing */
3299private function f_tc_assignment_fr_a5_1_codec_missing(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02003300 g_pars := f_gen_test_hdlr_pars();
Harald Welte552620d2017-12-16 23:21:36 +01003301 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
Harald Welteed848512018-05-24 22:27:58 +02003302 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte552620d2017-12-16 23:21:36 +01003303 const OCT8 kc := '0001020304050607'O;
3304
3305 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02003306 /* Omit: ass_cmd.pdu.bssmap.assignmentRequest.codecList */
3307
Harald Weltea0630032018-03-20 21:09:55 +01003308 f_establish_fully(ass_cmd, exp_fail);
Harald Welte552620d2017-12-16 23:21:36 +01003309}
Harald Welte552620d2017-12-16 23:21:36 +01003310testcase TC_assignment_fr_a5_1_codec_missing() runs on test_CT {
3311 var MSC_ConnHdlr vc_conn;
3312
Harald Welte89d42e82017-12-17 16:42:41 +01003313 f_init(1, true);
Harald Welte552620d2017-12-16 23:21:36 +01003314 f_sleep(1.0);
3315
Harald Welte8863fa12018-05-10 20:15:27 +02003316 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5_1_codec_missing));
Harald Welte552620d2017-12-16 23:21:36 +01003317 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003318 f_shutdown_helper();
Harald Welte552620d2017-12-16 23:21:36 +01003319}
3320
Harald Welte552620d2017-12-16 23:21:36 +01003321private function f_tc_assignment_fr_a5_4(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02003322 g_pars := f_gen_test_hdlr_pars();
Harald Welteed848512018-05-24 22:27:58 +02003323 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3324 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte552620d2017-12-16 23:21:36 +01003325 const OCT8 kc := '0001020304050607'O;
3326 const OCT16 kc128 := kc & kc;
3327
3328 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3329 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
Harald Weltea0630032018-03-20 21:09:55 +01003330 f_establish_fully(ass_cmd, exp_compl);
Harald Welte38b2a102017-12-23 02:42:58 +01003331 f_cipher_mode('10'O, kc, kc128, true);
Harald Welte552620d2017-12-16 23:21:36 +01003332 /* TODO: expect GSM0808_CAUSE_CIPHERING_ALGORITHM_NOT_SUPPORTED cause value */
Harald Welte552620d2017-12-16 23:21:36 +01003333}
Harald Welte552620d2017-12-16 23:21:36 +01003334testcase TC_assignment_fr_a5_4() runs on test_CT {
3335 var MSC_ConnHdlr vc_conn;
3336
Harald Welte89d42e82017-12-17 16:42:41 +01003337 f_init(1, true);
Harald Welte552620d2017-12-16 23:21:36 +01003338 f_sleep(1.0);
3339
Harald Welte8863fa12018-05-10 20:15:27 +02003340 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5_4));
Harald Welte552620d2017-12-16 23:21:36 +01003341 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003342 f_shutdown_helper();
Harald Welte552620d2017-12-16 23:21:36 +01003343}
3344
3345
Harald Welte4532e0a2017-12-23 02:05:44 +01003346private function f_tc_assignment_sign(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02003347 g_pars := f_gen_test_hdlr_pars();
Harald Welte4532e0a2017-12-23 02:05:44 +01003348 var template PDU_BSSAP exp_compl := tr_BSSMAP_AssignmentComplete(omit, omit);
Philipp Maier48604732018-10-09 15:00:37 +02003349 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte4532e0a2017-12-23 02:05:44 +01003350 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeSIGNAL);
Daniel Willmannebdecc02020-08-12 15:30:17 +02003351
3352 f_statsd_reset();
Harald Weltea0630032018-03-20 21:09:55 +01003353 f_establish_fully(ass_cmd, exp_compl);
Daniel Willmannebdecc02020-08-12 15:30:17 +02003354
3355 var StatsDExpects expect := {
Daniel Willmannc5398f72020-09-21 10:41:35 +02003356 { name := "TTCN3.bts.0.chreq.total", mtype := "c", min := 1, max := 1},
3357 { name := "TTCN3.bts.0.chreq.successful", mtype := "c", min := 1, max := 1},
Daniel Willmannebdecc02020-08-12 15:30:17 +02003358 { name := "TTCN3.bsc.0.assignment.attempted", mtype := "c", min := 1, max := 1},
3359 { name := "TTCN3.bsc.0.assignment.completed", mtype := "c", min := 1, max := 1}
3360 };
3361 f_statsd_expect(expect);
Harald Welte4532e0a2017-12-23 02:05:44 +01003362}
3363
3364testcase TC_assignment_sign() runs on test_CT {
3365 var MSC_ConnHdlr vc_conn;
3366
3367 f_init(1, true);
3368 f_sleep(1.0);
3369
Harald Welte8863fa12018-05-10 20:15:27 +02003370 vc_conn := f_start_handler(refers(f_tc_assignment_sign));
Harald Welte4532e0a2017-12-23 02:05:44 +01003371 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003372 f_shutdown_helper();
Harald Welte4532e0a2017-12-23 02:05:44 +01003373}
3374
Harald Welte60aa5762018-03-21 19:33:13 +01003375/***********************************************************************
3376 * Codec (list) testing
3377 ***********************************************************************/
3378
3379/* check if the given rsl_mode is compatible with the a_elem */
3380private function f_match_codec(BSSMAP_FIELD_CodecElement a_elem, RSL_IE_ChannelMode rsl_mode)
3381return boolean {
3382 select (a_elem.codecType) {
3383 case (GSM_FR) {
3384 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM1))) {
3385 return true;
3386 }
3387 }
3388 case (GSM_HR) {
3389 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_H, RSL_CMOD_SP_GSM1))) {
3390 return true;
3391 }
3392 }
3393 case (GSM_EFR) {
3394 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM2))) {
3395 return true;
3396 }
3397 }
3398 case (FR_AMR) {
3399 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM3))) {
3400 return true;
3401 }
3402 }
3403 case (HR_AMR) {
3404 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_H, RSL_CMOD_SP_GSM3))) {
3405 return true;
3406 }
3407 }
3408 case else { }
3409 }
3410 return false;
3411}
3412
3413/* check if the given rsl_mode is compatible with the a_list */
3414private function f_match_codecs(BSSMAP_IE_SpeechCodecList a_list, RSL_IE_ChannelMode rsl_mode)
3415return boolean {
3416 for (var integer i := 0; i < sizeof(a_list); i := i+1) {
3417 if (f_match_codec(a_list.codecElements[i], rsl_mode)) {
3418 return true;
3419 }
3420 }
3421 return false;
3422}
3423
3424/* determine BSSMAP_IE_ChannelType from *first* element of BSSMAP_FIELD_CodecElement */
Philipp Maier61f6b572018-07-06 14:03:38 +02003425function f_BSSMAP_chtype_from_codec(BSSMAP_FIELD_CodecElement a_elem)
Harald Welte60aa5762018-03-21 19:33:13 +01003426return BSSMAP_IE_ChannelType {
3427 /* FIXME: actually look at all elements of BSSMAP_IE_SpeechCodecList */
3428 var BSSMAP_IE_ChannelType ret := valueof(ts_BSSMAP_IE_ChannelType);
3429 select (a_elem.codecType) {
3430 case (GSM_FR) {
3431 ret.channelRateAndType := ChRate_TCHF;
3432 ret.speechId_DataIndicator := Spdi_TCHF_FR;
3433 }
3434 case (GSM_HR) {
3435 ret.channelRateAndType := ChRate_TCHH;
3436 ret.speechId_DataIndicator := Spdi_TCHH_HR;
3437 }
3438 case (GSM_EFR) {
3439 ret.channelRateAndType := ChRate_TCHF;
3440 ret.speechId_DataIndicator := Spdi_TCHF_EFR;
3441 }
3442 case (FR_AMR) {
3443 ret.channelRateAndType := ChRate_TCHF;
3444 ret.speechId_DataIndicator := Spdi_TCHF_AMR;
3445 }
3446 case (HR_AMR) {
3447 ret.channelRateAndType := ChRate_TCHH;
3448 ret.speechId_DataIndicator := Spdi_TCHH_AMR;
3449 }
3450 case else {
3451 setverdict(fail, "Unsupported codec ", a_elem);
Daniel Willmannafce8662018-07-06 23:11:32 +02003452 mtc.stop;
Harald Welte60aa5762018-03-21 19:33:13 +01003453 }
3454 }
3455 return ret;
3456}
3457
Harald Weltea63b9102018-03-22 20:36:16 +01003458private function f_rsl_chmod_tmpl_from_codec(BSSMAP_FIELD_CodecElement a_elem)
3459return template RSL_IE_Body {
3460 var template RSL_IE_Body mode_ie := {
3461 chan_mode := {
3462 len := ?,
3463 reserved := ?,
3464 dtx_d := ?,
3465 dtx_u := ?,
3466 spd_ind := RSL_SPDI_SPEECH,
3467 ch_rate_type := -,
3468 coding_alg_rate := -
3469 }
3470 }
3471
3472 select (a_elem.codecType) {
3473 case (GSM_FR) {
3474 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_F;
3475 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM1;
3476 }
3477 case (GSM_HR) {
3478 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_H;
3479 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM1;
3480 }
3481 case (GSM_EFR) {
3482 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_F;
3483 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM2;
3484 }
3485 case (FR_AMR) {
3486 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_F;
3487 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM3;
3488 }
3489 case (HR_AMR) {
3490 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_H;
3491 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM3;
3492 }
3493 }
3494 return mode_ie;
3495}
3496
Harald Welte60aa5762018-03-21 19:33:13 +01003497type record CodecListTest {
3498 BSSMAP_IE_SpeechCodecList codec_list,
3499 charstring id
3500}
3501type record of CodecListTest CodecListTests
3502
3503private function f_TC_assignment_codec(charstring id) runs on MSC_ConnHdlr {
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02003504 var PDU_BSSAP ass_cmd := f_gen_ass_req(g_pars.use_osmux);
3505 var template PDU_BSSAP exp_compl := f_gen_exp_compl(g_pars.use_osmux);
Harald Welte60aa5762018-03-21 19:33:13 +01003506
3507 /* puzzle together the ASSIGNMENT REQ for given codec[s] */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003508 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
Harald Welte79f3f542018-05-25 20:02:37 +02003509 ass_cmd.pdu.bssmap.assignmentRequest.codecList := g_pars.ass_codec_list;
3510 exp_compl.pdu.bssmap.assignmentComplete.speechCodec.codecElements[0] :=
3511 g_pars.ass_codec_list.codecElements[0];
Philipp Maierd0e64b02019-03-13 14:15:23 +01003512 if (isvalue(g_pars.expect_mr_s0_s7)) {
3513 exp_compl.pdu.bssmap.assignmentComplete.speechCodec.codecElements[0].s0_7 :=
3514 g_pars.expect_mr_s0_s7;
3515 }
Harald Welte79f3f542018-05-25 20:02:37 +02003516 }
Harald Welte60aa5762018-03-21 19:33:13 +01003517 ass_cmd.pdu.bssmap.assignmentRequest.channelType :=
3518 f_BSSMAP_chtype_from_codec(g_pars.ass_codec_list.codecElements[0]);
Harald Welte60aa5762018-03-21 19:33:13 +01003519 log("expecting ASS COMPL like this: ", exp_compl);
3520
3521 f_establish_fully(ass_cmd, exp_compl);
Harald Weltea63b9102018-03-22 20:36:16 +01003522
3523 /* Verify that the RSL-side activation actually matches our expectations */
3524 var RSL_Message rsl := f_rslem_get_last_act(RSL_PROC, 0, g_chan_nr);
3525
3526 var RSL_IE_Body mode_ie;
3527 if (f_rsl_find_ie(rsl, RSL_IE_CHAN_MODE, mode_ie) == false) {
3528 setverdict(fail, "Couldn't find CHAN_MODE IE");
Daniel Willmannafce8662018-07-06 23:11:32 +02003529 mtc.stop;
Harald Weltea63b9102018-03-22 20:36:16 +01003530 }
3531 var template RSL_IE_Body t_mode_ie := f_rsl_chmod_tmpl_from_codec(g_pars.ass_codec_list.codecElements[0]);
3532 if (not match(mode_ie, t_mode_ie)) {
3533 setverdict(fail, "RSL Channel Mode IE doesn't match expectation");
3534 }
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02003535
3536 var RSL_IE_Body mr_conf;
3537 if (g_pars.expect_mr_conf_ie != omit) {
3538 if (f_rsl_find_ie(rsl, RSL_IE_MR_CONFIG, mr_conf) == false) {
3539 setverdict(fail, "Missing MR CONFIG IE in RSL Chan Activ");
Daniel Willmannafce8662018-07-06 23:11:32 +02003540 mtc.stop;
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02003541 }
3542 log("found RSL MR CONFIG IE: ", mr_conf);
3543
3544 if (not match(mr_conf, g_pars.expect_mr_conf_ie)) {
3545 setverdict(fail, "RSL MR CONFIG IE does not match expectation. Expected: ",
3546 g_pars.expect_mr_conf_ie);
3547 }
3548 } else {
3549 if (f_rsl_find_ie(rsl, RSL_IE_MR_CONFIG, mr_conf) == true) {
3550 log("found RSL MR CONFIG IE: ", mr_conf);
3551 setverdict(fail, "Found MR CONFIG IE in RSL Chan Activ, expecting omit");
Daniel Willmannafce8662018-07-06 23:11:32 +02003552 mtc.stop;
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02003553 }
3554 }
Harald Welte60aa5762018-03-21 19:33:13 +01003555}
3556
Philipp Maierd0e64b02019-03-13 14:15:23 +01003557private function f_TC_assignment_codec_fail(charstring id) runs on MSC_ConnHdlr {
3558
3559 var PDU_BSSAP ass_cmd := f_gen_ass_req();
3560 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
3561
3562 /* puzzle together the ASSIGNMENT REQ for given codec[s] */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003563 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
Philipp Maierd0e64b02019-03-13 14:15:23 +01003564 ass_cmd.pdu.bssmap.assignmentRequest.codecList := g_pars.ass_codec_list;
3565 }
3566 ass_cmd.pdu.bssmap.assignmentRequest.channelType :=
3567 f_BSSMAP_chtype_from_codec(g_pars.ass_codec_list.codecElements[0]);
3568 log("expecting ASS FAIL like this: ", exp_fail);
3569
3570 f_establish_fully(ass_cmd, exp_fail);
3571}
3572
Harald Welte60aa5762018-03-21 19:33:13 +01003573testcase TC_assignment_codec_fr() runs on test_CT {
Philipp Maier48604732018-10-09 15:00:37 +02003574 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte60aa5762018-03-21 19:33:13 +01003575 var MSC_ConnHdlr vc_conn;
3576
3577 f_init(1, true);
3578 f_sleep(1.0);
3579
3580 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
Harald Welte8863fa12018-05-10 20:15:27 +02003581 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01003582 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003583 f_shutdown_helper();
Harald Welte60aa5762018-03-21 19:33:13 +01003584}
3585
3586testcase TC_assignment_codec_hr() runs on test_CT {
Philipp Maier48604732018-10-09 15:00:37 +02003587 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte60aa5762018-03-21 19:33:13 +01003588 var MSC_ConnHdlr vc_conn;
3589
3590 f_init(1, true);
3591 f_sleep(1.0);
3592
3593 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR}));
Harald Welte8863fa12018-05-10 20:15:27 +02003594 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01003595 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003596 f_shutdown_helper();
Harald Welte60aa5762018-03-21 19:33:13 +01003597}
3598
3599testcase TC_assignment_codec_efr() runs on test_CT {
Philipp Maier48604732018-10-09 15:00:37 +02003600 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte60aa5762018-03-21 19:33:13 +01003601 var MSC_ConnHdlr vc_conn;
3602
3603 f_init(1, true);
3604 f_sleep(1.0);
3605
3606 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecEFR}));
Harald Welte8863fa12018-05-10 20:15:27 +02003607 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01003608 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003609 f_shutdown_helper();
Harald Welte60aa5762018-03-21 19:33:13 +01003610}
3611
Philipp Maierd0e64b02019-03-13 14:15:23 +01003612/* Allow 5,90k only (current default config) */
3613private function f_allow_amr_rate_5_90k() runs on test_CT {
Neels Hofmeyr2a5670b2020-11-25 23:39:57 +00003614 f_vty_cfg_msc(BSCVTY, 0, {
3615 "amr-config 12_2k forbidden",
3616 "amr-config 10_2k forbidden",
3617 "amr-config 7_95k forbidden",
3618 "amr-config 7_40k forbidden",
3619 "amr-config 6_70k forbidden",
3620 "amr-config 5_90k allowed",
3621 "amr-config 5_15k forbidden",
3622 "amr-config 4_75k forbidden"
3623 });
Philipp Maierd0e64b02019-03-13 14:15:23 +01003624}
3625
3626/* Allow 4,75k, 5,90k, 4,70k and 12,2k, which are the most common rates
3627 * ("Config-NB-Code = 1") */
3628private function f_allow_amr_rate_4_75k_5_90k_7_40k_12_20k() runs on test_CT {
Neels Hofmeyr2a5670b2020-11-25 23:39:57 +00003629 f_vty_cfg_msc(BSCVTY, 0, {
3630 "amr-config 12_2k allowed",
3631 "amr-config 10_2k forbidden",
3632 "amr-config 7_95k forbidden",
3633 "amr-config 7_40k allowed",
3634 "amr-config 6_70k forbidden",
3635 "amr-config 5_90k allowed",
3636 "amr-config 5_15k forbidden",
3637 "amr-config 4_75k allowed"
3638 });
Philipp Maierd0e64b02019-03-13 14:15:23 +01003639}
3640
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00003641private function f_vty_amr_start_mode_set(boolean fr, charstring startmode) runs on test_CT {
3642 var charstring tch;
3643 if (fr) {
3644 tch := "tch-f";
3645 } else {
3646 tch := "tch-h";
3647 }
3648 f_vty_cfg_bts(BSCVTY, 0, { "amr " & tch & " start-mode " & startmode });
3649}
3650
3651/* Set the AMR start-mode for this TCH back to the default configuration. */
3652private function f_vty_amr_start_mode_restore(boolean fr) runs on test_CT {
3653 f_vty_amr_start_mode_set(fr, "auto");
3654}
3655
Harald Welte60aa5762018-03-21 19:33:13 +01003656testcase TC_assignment_codec_amr_f() runs on test_CT {
Philipp Maier48604732018-10-09 15:00:37 +02003657 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte60aa5762018-03-21 19:33:13 +01003658 var MSC_ConnHdlr vc_conn;
Philipp Maier7695a0d2018-09-27 17:52:14 +02003659
3660 /* Note: This setups the codec configuration. The parameter payload in
3661 * mr_conf must be consistant with the parameter codecElements in pars
3662 * and also must match the amr-config in osmo-bsc.cfg! */
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02003663 var RSL_IE_Body mr_conf := {
3664 other := {
3665 len := 2,
3666 payload := '2804'O
3667 }
3668 };
Harald Welte60aa5762018-03-21 19:33:13 +01003669
Philipp Maier7695a0d2018-09-27 17:52:14 +02003670 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_F}));
Philipp Maier806f8f12019-03-12 12:13:41 +01003671 pars.ass_codec_list.codecElements[0].s0_7 := '00000100'B; /* 5,90k */
Philipp Maier7695a0d2018-09-27 17:52:14 +02003672 pars.ass_codec_list.codecElements[0].s8_15 := '01010111'B;
3673 pars.expect_mr_conf_ie := mr_conf;
3674
Harald Welte60aa5762018-03-21 19:33:13 +01003675 f_init(1, true);
3676 f_sleep(1.0);
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00003677 f_vty_amr_start_mode_set(true, "1");
Harald Welte60aa5762018-03-21 19:33:13 +01003678
Harald Welte8863fa12018-05-10 20:15:27 +02003679 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01003680 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003681 f_shutdown_helper();
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00003682
3683 f_vty_amr_start_mode_restore(true);
Harald Welte60aa5762018-03-21 19:33:13 +01003684}
3685
3686testcase TC_assignment_codec_amr_h() runs on test_CT {
Philipp Maier48604732018-10-09 15:00:37 +02003687 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte60aa5762018-03-21 19:33:13 +01003688 var MSC_ConnHdlr vc_conn;
Philipp Maier7695a0d2018-09-27 17:52:14 +02003689
3690 /* See note above */
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02003691 var RSL_IE_Body mr_conf := {
3692 other := {
3693 len := 2,
3694 payload := '2804'O
3695 }
3696 };
Harald Welte60aa5762018-03-21 19:33:13 +01003697
Philipp Maier7695a0d2018-09-27 17:52:14 +02003698 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_H}));
Philipp Maier806f8f12019-03-12 12:13:41 +01003699 pars.ass_codec_list.codecElements[0].s0_7 := '00000100'B; /* 5,90k */
Philipp Maier7695a0d2018-09-27 17:52:14 +02003700 pars.ass_codec_list.codecElements[0].s8_15 := '00000111'B;
3701 pars.expect_mr_conf_ie := mr_conf;
3702
Harald Welte60aa5762018-03-21 19:33:13 +01003703 f_init(1, true);
3704 f_sleep(1.0);
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00003705 f_vty_amr_start_mode_set(false, "1");
Harald Welte60aa5762018-03-21 19:33:13 +01003706
Harald Welte8863fa12018-05-10 20:15:27 +02003707 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01003708 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003709 f_shutdown_helper();
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00003710
3711 f_vty_amr_start_mode_restore(false);
Harald Welte60aa5762018-03-21 19:33:13 +01003712}
3713
Neels Hofmeyr454d7922020-11-26 02:24:57 +00003714/* 'amr start-mode auto' should not keep the (unused) 'smod' bits from previous configuration */
3715testcase TC_assignment_codec_amr_startmode_cruft() runs on test_CT {
3716 var TestHdlrParams pars := f_gen_test_hdlr_pars();
3717 var MSC_ConnHdlr vc_conn;
3718
3719 var RSL_IE_Body mr_conf := {
3720 other := {
3721 len := 2,
3722 payload := '2004'O /* <- expect ICMI=0, smod=00 */
3723 }
3724 };
3725
3726 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_F}));
3727 pars.ass_codec_list.codecElements[0].s0_7 := '00000100'B; /* 5,90k */
3728 pars.ass_codec_list.codecElements[0].s8_15 := '01010111'B;
3729 pars.expect_mr_conf_ie := mr_conf;
3730
3731 f_init(1, true);
3732 f_sleep(1.0);
3733
3734 /* First set nonzero start mode bits */
3735 f_vty_amr_start_mode_set(true, "4");
3736 /* Now set to auto, and expect the startmode bits to be zero in the message, i.e. ensure that osmo-bsc does not
3737 * let the startmode bits stick around and has deterministic MultiRate config for 'start-mode auto'; that is
3738 * ensured by above '2004'O, where 'x0xx'O indicates ICMI = 0, spare = 0, smod = 00. */
3739 f_vty_amr_start_mode_set(true, "auto");
3740
3741 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
3742 vc_conn.done;
3743 f_shutdown_helper();
3744
3745 /* Clear the startmode bits to not affect subsequent tests, in case the bits should indeed stick around. */
3746 f_vty_amr_start_mode_set(true, "1");
3747 f_vty_amr_start_mode_restore(true);
3748}
3749
Neels Hofmeyr21863562020-11-26 00:34:33 +00003750function f_TC_assignment_codec_amr(boolean fr, octetstring mrconf, bitstring s8_s0, bitstring exp_s8_s0,
3751 charstring start_mode := "1")
Philipp Maierd0e64b02019-03-13 14:15:23 +01003752runs on test_CT {
3753
3754 var TestHdlrParams pars := f_gen_test_hdlr_pars();
3755 var MSC_ConnHdlr vc_conn;
3756
3757 /* See note above */
3758 var RSL_IE_Body mr_conf := {
3759 other := {
3760 len := lengthof(mrconf),
3761 payload := mrconf
3762 }
3763 };
3764
3765 if (fr) {
3766 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_F}));
3767 } else {
3768 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_H}));
3769 }
3770 pars.ass_codec_list.codecElements[0].s0_7 := s8_s0;
3771 pars.ass_codec_list.codecElements[0].s8_15 := '00000111'B;
3772 pars.expect_mr_conf_ie := mr_conf;
3773 pars.expect_mr_s0_s7 := exp_s8_s0;
3774
3775 f_init(1, true);
3776 f_allow_amr_rate_4_75k_5_90k_7_40k_12_20k();
Neels Hofmeyr21863562020-11-26 00:34:33 +00003777 f_vty_amr_start_mode_set(fr, start_mode);
Philipp Maierd0e64b02019-03-13 14:15:23 +01003778 f_sleep(1.0);
3779
3780 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
3781 vc_conn.done;
3782 f_allow_amr_rate_5_90k();
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00003783 f_vty_amr_start_mode_restore(fr);
Philipp Maierd0e64b02019-03-13 14:15:23 +01003784}
3785
3786function f_TC_assignment_codec_amr_fail(boolean fr, bitstring s8_s0)
3787runs on test_CT {
3788
3789 var TestHdlrParams pars := f_gen_test_hdlr_pars();
3790 var MSC_ConnHdlr vc_conn;
3791
3792 if (fr) {
3793 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_F}));
3794 } else {
3795 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_H}));
3796 }
3797 pars.ass_codec_list.codecElements[0].s0_7 := s8_s0;
3798 pars.ass_codec_list.codecElements[0].s8_15 := '00000111'B;
3799
3800 f_init(1, true);
3801 f_allow_amr_rate_4_75k_5_90k_7_40k_12_20k();
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00003802 f_vty_amr_start_mode_set(fr, "1");
Philipp Maierd0e64b02019-03-13 14:15:23 +01003803 f_sleep(1.0);
3804
3805 vc_conn := f_start_handler(refers(f_TC_assignment_codec_fail), pars);
3806 vc_conn.done;
3807 f_allow_amr_rate_5_90k();
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00003808 f_vty_amr_start_mode_restore(fr);
Philipp Maierd0e64b02019-03-13 14:15:23 +01003809}
3810
3811
3812/* Set S1, we expect an AMR multirate configuration IE with all four rates
3813 * set. */
3814testcase TC_assignment_codec_amr_f_S1() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003815 f_TC_assignment_codec_amr(true, '289520882208'O, '00000010'B, '00000010'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003816 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003817}
3818
3819/* Set S1, we expect an AMR multirate configuration IE with the lower three
3820 * rates set. */
3821testcase TC_assignment_codec_amr_h_S1() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003822 f_TC_assignment_codec_amr(false, '2815208820'O, '00000010'B, '00000010'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003823 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003824}
3825
3826/* Set S1 and two other rates, we expect an AMR MULTIRATE CONFIGURATION IE with
3827 * all four rates (and only S1 set in the ASSIGNMENT COMPLETE) */
3828testcase TC_assignment_codec_amr_f_S124() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003829 f_TC_assignment_codec_amr(true, '289520882208'O, '00010110'B, '00000010'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003830 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003831}
3832
3833/* Set S1 and two other rates, we expect an AMR MULTIRATE CONFIGURATION IE with
3834 * all four rates (and only S1 set in the ASSIGNMENT COMPLETE) */
3835testcase TC_assignment_codec_amr_h_S124() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003836 f_TC_assignment_codec_amr(false, '2815208820'O, '00010110'B, '00000010'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003837 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003838}
3839
3840/* The following block of tests selects more and more rates until all four
3841 * possible rates are in the active set (full rate) */
3842testcase TC_assignment_codec_amr_f_S0() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003843 f_TC_assignment_codec_amr(true, '2801'O, '00000001'B, '00000001'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003844 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003845}
3846
3847testcase TC_assignment_codec_amr_f_S02() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003848 f_TC_assignment_codec_amr(true, '28052080'O, '00000101'B, '00000101'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003849 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003850}
3851
3852testcase TC_assignment_codec_amr_f_S024() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003853 f_TC_assignment_codec_amr(true, '2815208820'O, '00010101'B, '00010101'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003854 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003855}
3856
3857testcase TC_assignment_codec_amr_f_S0247() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003858 f_TC_assignment_codec_amr(true, '289520882208'O, '10010101'B, '10010101'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003859 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003860}
3861
3862/* The following block of tests selects more and more rates until all three
3863 * possible rates are in the active set (half rate) */
3864testcase TC_assignment_codec_amr_h_S0() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003865 f_TC_assignment_codec_amr(false, '2801'O, '00000001'B, '00000001'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003866 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003867}
3868
3869testcase TC_assignment_codec_amr_h_S02() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003870 f_TC_assignment_codec_amr(false, '28052080'O, '00000101'B, '00000101'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003871 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003872}
3873
3874testcase TC_assignment_codec_amr_h_S024() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003875 f_TC_assignment_codec_amr(false, '2815208820'O, '00010101'B, '00010101'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003876 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003877}
3878
3879/* The following block tests what happens when the MSC does offer rate
3880 * configurations that are not supported by the BSC. Normally such situations
3881 * should not happen because the MSC gets informed by the BSC in advance via
3882 * the L3 COMPLETE message which rates are applicable. The MSC should not try
3883 * to offer rates that are not applicable anyway. */
3884
3885testcase TC_assignment_codec_amr_h_S0247() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003886 /* Try to include 12,2k in into the active set even though the channel
3887 * is half rate only. The BSC is expected to remove the 12,0k */
3888 f_TC_assignment_codec_amr(false, '2815208820'O, '10010101'B, '00010101'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003889 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003890}
3891
3892testcase TC_assignment_codec_amr_f_S01234567() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003893 /* See what happens when all rates are selected at once. Since then
3894 * Also S1 is selected, this setting will be prefered and we should
3895 * get 12.2k, 7,40k, 5,90k, and 4,75k in the active set. */
3896 f_TC_assignment_codec_amr(true, '289520882208'O, '11111111'B, '00000010'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003897 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003898}
3899
3900testcase TC_assignment_codec_amr_f_S0234567() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003901 /* Same as above, but with S1 missing, the MSC is then expected to
3902 * select the currently supported rates, which are also 12.2k, 7,40k,
3903 * 5,90k, and 4,75k, into the active set. */
3904 f_TC_assignment_codec_amr(true, '289520882208'O, '11111101'B, '10010101'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003905 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003906}
3907
3908testcase TC_assignment_codec_amr_f_zero() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003909 /* Try to select no rates at all */
3910 f_TC_assignment_codec_amr_fail(true, '00000000'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003911 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003912}
3913
3914testcase TC_assignment_codec_amr_f_unsupp() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003915 /* Try to select only unsupported rates */
3916 f_TC_assignment_codec_amr_fail(true, '01101000'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003917 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003918}
3919
3920testcase TC_assignment_codec_amr_h_S7() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003921 /* Try to select 12,2k for half rate */
3922 f_TC_assignment_codec_amr_fail(false, '10000000'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003923 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003924}
3925
Neels Hofmeyr21863562020-11-26 00:34:33 +00003926testcase TC_assignment_codec_amr_f_start_mode_auto() runs on test_CT {
3927 f_TC_assignment_codec_amr(true, '209520882208'O, '11111111'B, '00000010'B,
3928 start_mode := "auto");
3929}
3930
3931testcase TC_assignment_codec_amr_h_start_mode_auto() runs on test_CT {
3932 f_TC_assignment_codec_amr(false, '2015208820'O, '10010101'B, '00010101'B,
3933 start_mode := "auto");
3934}
3935
Neels Hofmeyr3eb94562020-11-26 02:40:26 +00003936testcase TC_assignment_codec_amr_f_start_mode_4() runs on test_CT {
3937 f_TC_assignment_codec_amr(true, '2b9520882208'O, '11111111'B, '00000010'B,
3938 start_mode := "4");
3939}
3940
3941testcase TC_assignment_codec_amr_h_start_mode_4() runs on test_CT {
3942 f_TC_assignment_codec_amr(false, '2b15208820'O, '10010101'B, '00010101'B,
3943 start_mode := "4");
3944}
3945
Philipp Maierac09bfc2019-01-08 13:41:39 +01003946private function f_disable_all_tch_f() runs on test_CT {
Philipp Maierc704a882019-01-29 15:58:52 +01003947 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 1 sub-slot 0 borken");
3948 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 2 sub-slot 0 borken");
3949 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 3 sub-slot 0 borken");
3950 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 4 sub-slot 0 borken");
Philipp Maierac09bfc2019-01-08 13:41:39 +01003951}
3952
3953private function f_disable_all_tch_h() runs on test_CT {
Philipp Maierc704a882019-01-29 15:58:52 +01003954 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 5 sub-slot 0 borken");
3955 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 5 sub-slot 1 borken");
Philipp Maierac09bfc2019-01-08 13:41:39 +01003956}
3957
3958private function f_enable_all_tch() runs on test_CT {
Philipp Maierc704a882019-01-29 15:58:52 +01003959 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 1 sub-slot 0 unused");
3960 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 2 sub-slot 0 unused");
3961 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 3 sub-slot 0 unused");
3962 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 4 sub-slot 0 unused");
3963 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 5 sub-slot 0 unused");
3964 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 5 sub-slot 1 unused");
Philipp Maierac09bfc2019-01-08 13:41:39 +01003965}
3966
3967/* Allow HR only */
3968private function f_TC_assignment_codec_xr_exhausted_req_hr(charstring id) runs on MSC_ConnHdlr {
3969 g_pars := f_gen_test_hdlr_pars();
3970 var PDU_BSSAP ass_cmd := f_gen_ass_req();
3971 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3972 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3973 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '09'O;
3974 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '05'O;
3975 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR}));
3976 f_establish_fully(ass_cmd, exp_compl);
3977}
3978
3979/* Allow FR only */
3980private function f_TC_assignment_codec_xr_exhausted_req_fr(charstring id) runs on MSC_ConnHdlr {
3981 g_pars := f_gen_test_hdlr_pars();
3982 var PDU_BSSAP ass_cmd := f_gen_ass_req();
3983 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3984 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3985 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '08'O;
3986 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '01'O;
3987 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
3988 f_establish_fully(ass_cmd, exp_compl);
3989}
3990
3991/* Allow HR only (expect assignment failure) */
3992private function f_TC_assignment_codec_xr_exhausted_req_hr_fail(charstring id) runs on MSC_ConnHdlr {
3993 g_pars := f_gen_test_hdlr_pars();
3994 var PDU_BSSAP ass_cmd := f_gen_ass_req();
3995 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
3996 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3997 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '09'O;
3998 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '05'O;
3999 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR}));
4000 f_establish_fully(ass_cmd, exp_fail);
4001}
4002
4003/* Allow FR only (expect assignment failure) */
4004private function f_TC_assignment_codec_xr_exhausted_req_fr_fail(charstring id) runs on MSC_ConnHdlr {
4005 g_pars := f_gen_test_hdlr_pars();
4006 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4007 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
4008 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4009 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '08'O;
4010 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '01'O;
4011 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
4012 f_establish_fully(ass_cmd, exp_fail);
4013}
4014
4015/* Allow FR and HR, but prefer FR */
4016private function f_TC_assignment_codec_fr_exhausted_req_fr_hr(charstring id) runs on MSC_ConnHdlr {
4017 g_pars := f_gen_test_hdlr_pars();
4018 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4019 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4020 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4021 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0A'O; /* Prefer FR */
4022 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8105'O;
4023 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR, ts_CodecHR}));
4024 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000101'B; /* Expect HR */
4025 f_establish_fully(ass_cmd, exp_compl);
4026}
4027
4028/* Allow FR and HR, but prefer HR */
4029private function f_TC_assignment_codec_fr_exhausted_req_hr_fr(charstring id) runs on MSC_ConnHdlr {
4030 g_pars := f_gen_test_hdlr_pars();
4031 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4032 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4033 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4034 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0B'O; /* Prefer HR */
4035 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8501'O;
4036 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR, ts_CodecFR}));
4037 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000101'B; /* Expect HR */
4038 f_establish_fully(ass_cmd, exp_compl);
4039}
4040
4041/* Allow FR and HR, but prefer FR */
4042private function f_TC_assignment_codec_hr_exhausted_req_fr_hr(charstring id) runs on MSC_ConnHdlr {
4043 g_pars := f_gen_test_hdlr_pars();
4044 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4045 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4046 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4047 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0A'O; /* Prefer FR */
4048 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8105'O;
4049 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR, ts_CodecHR}));
4050 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000001'B; /* Expect FR */
4051 f_establish_fully(ass_cmd, exp_compl);
4052}
4053
4054/* Allow FR and HR, but prefer HR */
4055private function f_TC_assignment_codec_hr_exhausted_req_hr_fr(charstring id) runs on MSC_ConnHdlr {
4056 g_pars := f_gen_test_hdlr_pars();
4057 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4058 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4059 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4060 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0B'O; /* Prefer HR */
4061 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8501'O;
4062 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR, ts_CodecFR}));
4063 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000001'B; /* Expect FR */
4064 f_establish_fully(ass_cmd, exp_compl);
4065}
4066
4067/* Request a HR channel while all FR channels are exhausted, this is expected
4068 * to work without conflicts */
4069testcase TC_assignment_codec_fr_exhausted_req_hr() runs on test_CT {
4070 var MSC_ConnHdlr vc_conn;
4071 f_init(1, true);
4072 f_sleep(1.0);
4073 f_enable_all_tch();
4074 f_disable_all_tch_f();
4075 vc_conn := f_start_handler(refers(f_TC_assignment_codec_xr_exhausted_req_hr));
4076 vc_conn.done;
4077 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004078 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004079}
4080
4081/* Request a FR channel while all FR channels are exhausted, this is expected
4082 * to fail. */
4083testcase TC_assignment_codec_fr_exhausted_req_fr() runs on test_CT {
4084 var MSC_ConnHdlr vc_conn;
4085 f_init(1, true);
4086 f_sleep(1.0);
4087 f_enable_all_tch();
4088 f_disable_all_tch_f();
4089 vc_conn := f_start_handler(refers(f_TC_assignment_codec_xr_exhausted_req_fr_fail));
4090 vc_conn.done;
4091 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004092 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004093}
4094
4095/* Request a FR (prefered) or alternatively a HR channel while all FR channels
4096 * are exhausted, this is expected to be resolved by selecting a HR channel. */
4097testcase TC_assignment_codec_fr_exhausted_req_fr_hr() runs on test_CT {
4098 var MSC_ConnHdlr vc_conn;
4099 f_init(1, true);
4100 f_sleep(1.0);
4101 f_enable_all_tch();
4102 f_disable_all_tch_f();
4103 vc_conn := f_start_handler(refers(f_TC_assignment_codec_fr_exhausted_req_fr_hr));
4104 vc_conn.done;
4105 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004106 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004107}
4108
4109/* Request a HR (prefered) or alternatively a FR channel while all FR channels
4110 * are exhausted, this is expected to work without conflicts. */
4111testcase TC_assignment_codec_fr_exhausted_req_hr_fr() runs on test_CT {
4112 var MSC_ConnHdlr vc_conn;
4113 f_init(1, true);
4114 f_sleep(1.0);
4115 f_enable_all_tch();
4116 f_disable_all_tch_f();
4117 vc_conn := f_start_handler(refers(f_TC_assignment_codec_fr_exhausted_req_hr_fr));
4118 vc_conn.done;
4119 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004120 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004121}
4122
4123/* Request a FR channel while all HR channels are exhausted, this is expected
4124 * to work without conflicts */
4125testcase TC_assignment_codec_hr_exhausted_req_fr() runs on test_CT {
4126 var MSC_ConnHdlr vc_conn;
4127 f_init(1, true);
4128 f_sleep(1.0);
4129 f_enable_all_tch();
4130 f_disable_all_tch_h();
4131 vc_conn := f_start_handler(refers(f_TC_assignment_codec_xr_exhausted_req_fr));
4132 vc_conn.done;
4133 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004134 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004135}
4136
4137/* Request a HR channel while all HR channels are exhausted, this is expected
4138 * to fail. */
4139testcase TC_assignment_codec_hr_exhausted_req_hr() runs on test_CT {
4140 var MSC_ConnHdlr vc_conn;
4141 f_init(1, true);
4142 f_sleep(1.0);
4143 f_enable_all_tch();
4144 f_disable_all_tch_h();
4145 vc_conn := f_start_handler(refers(f_TC_assignment_codec_xr_exhausted_req_hr_fail));
4146 vc_conn.done;
4147 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004148 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004149}
4150
4151/* Request a HR (prefered) or alternatively a FR channel while all HR channels
4152 * are exhausted, this is expected to be resolved by selecting a FR channel. */
4153testcase TC_assignment_codec_hr_exhausted_req_hr_fr() runs on test_CT {
4154 var MSC_ConnHdlr vc_conn;
4155 f_init(1, true);
4156 f_sleep(1.0);
4157 f_enable_all_tch();
4158 f_disable_all_tch_h();
4159 vc_conn := f_start_handler(refers(f_TC_assignment_codec_hr_exhausted_req_hr_fr));
4160 vc_conn.done;
4161 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004162 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004163}
4164
4165/* Request a FR (prefered) or alternatively a HR channel while all HR channels
4166 * are exhausted, this is expected to work without conflicts. */
4167testcase TC_assignment_codec_hr_exhausted_req_fr_hr() runs on test_CT {
4168 var MSC_ConnHdlr vc_conn;
4169 f_init(1, true);
4170 f_sleep(1.0);
4171 f_enable_all_tch();
4172 f_disable_all_tch_h();
4173 vc_conn := f_start_handler(refers(f_TC_assignment_codec_hr_exhausted_req_fr_hr));
4174 vc_conn.done;
4175 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004176 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004177}
4178
4179/* Allow FR and HR, but prefer HR */
4180private function f_TC_assignment_codec_req_hr_fr(charstring id) runs on MSC_ConnHdlr {
4181 g_pars := f_gen_test_hdlr_pars();
4182 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4183 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4184 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4185 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0B'O; /* Prefer HR */
4186 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8501'O;
4187 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR, ts_CodecFR}));
4188 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000101'B; /* Expect HR */
4189 f_establish_fully(ass_cmd, exp_compl);
4190}
4191
4192/* Allow FR and HR, but prefer FR */
4193private function f_TC_assignment_codec_req_fr_hr(charstring id) runs on MSC_ConnHdlr {
4194 g_pars := f_gen_test_hdlr_pars();
4195 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4196 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4197 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4198 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0A'O; /* Prefer FR */
4199 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8105'O;
4200 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR, ts_CodecHR}));
4201 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000001'B; /* Expect FR */
4202 f_establish_fully(ass_cmd, exp_compl);
4203}
4204
4205/* Request a HR (prefered) or alternatively a FR channel, it is expected that
4206 * HR, which is the prefered type, is selected. */
4207testcase TC_assignment_codec_req_hr_fr() runs on test_CT {
4208 var MSC_ConnHdlr vc_conn;
4209 f_init(1, true);
4210 f_sleep(1.0);
4211 f_enable_all_tch();
4212 vc_conn := f_start_handler(refers(f_TC_assignment_codec_req_hr_fr));
4213 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004214 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004215}
4216
4217/* Request a FR (prefered) or alternatively a HR channel, it is expected that
4218 * FR, which is the prefered type, is selected. */
4219testcase TC_assignment_codec_req_fr_hr() runs on test_CT {
4220 var MSC_ConnHdlr vc_conn;
4221 f_init(1, true);
4222 f_sleep(1.0);
4223 f_enable_all_tch();
4224 vc_conn := f_start_handler(refers(f_TC_assignment_codec_req_fr_hr));
4225 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004226 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004227}
4228
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02004229testcase TC_assignment_osmux() runs on test_CT {
4230 var TestHdlrParams pars := f_gen_test_hdlr_pars();
4231 var MSC_ConnHdlr vc_conn;
4232
4233 /* See note above */
4234 var RSL_IE_Body mr_conf := {
4235 other := {
4236 len := 2,
4237 payload := '2804'O
4238 }
4239 };
4240
4241 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_H}));
4242 pars.ass_codec_list.codecElements[0].s0_7 := '00000100'B; /* 5,90k */
4243 pars.ass_codec_list.codecElements[0].s8_15 := '00000111'B;
4244 pars.expect_mr_conf_ie := mr_conf;
4245 pars.use_osmux := true;
4246
4247 f_init(1, true, true);
4248 f_sleep(1.0);
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00004249 f_vty_amr_start_mode_set(false, "1");
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02004250
4251 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
4252 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004253 f_shutdown_helper();
Neels Hofmeyra6ab8212020-11-25 23:57:47 +00004254
4255 f_vty_amr_start_mode_restore(false);
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02004256}
4257
Neels Hofmeyr92b12b72018-09-18 14:30:23 +02004258/* test the procedure of the MSC requesting a Classmark Update:
4259 * a) BSSMAP Classmark Request should result in RR CLASSMARK ENQUIRY,
4260 * b) L3 RR CLASSMARK CHANGE should result in BSSMAP CLASSMARK UPDATE */
Harald Welte898113b2018-01-31 18:32:21 +01004261private function f_tc_classmark(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02004262 g_pars := f_gen_test_hdlr_pars();
4263
Harald Weltea0630032018-03-20 21:09:55 +01004264 f_create_chan_and_exp();
Harald Welte898113b2018-01-31 18:32:21 +01004265 /* we should now have a COMPL_L3 at the MSC */
4266 BSSAP.receive(tr_BSSMAP_ComplL3);
4267
Neels Hofmeyr92b12b72018-09-18 14:30:23 +02004268 BSSAP.send(ts_BSSMAP_ClassmarkRequest);
4269 RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_CM_ENQUIRY));
4270
Harald Welte898113b2018-01-31 18:32:21 +01004271 f_rsl_send_l3(ts_RRM_CM_CHG(valueof(ts_CM2)));
4272 BSSAP.receive(tr_BSSMAP_ClassmarkUpd(?, omit));
4273 setverdict(pass);
4274}
4275testcase TC_classmark() runs on test_CT {
4276 var MSC_ConnHdlr vc_conn;
4277 f_init(1, true);
4278 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02004279 vc_conn := f_start_handler(refers(f_tc_classmark));
Harald Welte898113b2018-01-31 18:32:21 +01004280 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004281 f_shutdown_helper();
Harald Welte898113b2018-01-31 18:32:21 +01004282}
4283
Harald Welteeddf0e92020-06-21 19:42:15 +02004284/* Send a CommonID from the simulated MSC and verify that the information is used to
4285 * fill BSC-internal data structures (specifically, bsc_subscr associated with subscr_conn) */
4286private function f_tc_common_id(charstring id) runs on MSC_ConnHdlr {
4287 g_pars := f_gen_test_hdlr_pars();
4288 f_MscConnHdlr_init_vty();
4289
4290 f_create_chan_and_exp();
4291 /* we should now have a COMPL_L3 at the MSC */
4292 BSSAP.receive(tr_BSSMAP_ComplL3);
4293
4294 /* Send CommonID */
4295 BSSAP.send(ts_BSSMAP_CommonId(g_pars.imsi));
4296
4297 /* Use VTY to verify that the IMSI of the subscr_conn is set */
4298 var charstring regex := "*(IMSI: " & hex2str(g_pars.imsi) & ")*";
4299 f_vty_transceive_match_regexp_retry(BSCVTY, "show conns", regex, 0, 4, 1.0);
4300
4301 setverdict(pass);
4302}
4303testcase TC_common_id() runs on test_CT {
4304 var MSC_ConnHdlr vc_conn;
4305 f_init(1, true);
4306 f_sleep(1.0);
4307 vc_conn := f_start_handler(refers(f_tc_common_id));
4308 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004309 f_shutdown_helper();
Harald Welteeddf0e92020-06-21 19:42:15 +02004310}
4311
Harald Weltee3bd6582018-01-31 22:51:25 +01004312private function f_est_single_l3(template PDU_ML3_MS_NW l3) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02004313 g_pars := f_gen_test_hdlr_pars();
Harald Weltea0630032018-03-20 21:09:55 +01004314 f_create_chan_and_exp();
Harald Welte898113b2018-01-31 18:32:21 +01004315 /* we should now have a COMPL_L3 at the MSC */
4316 BSSAP.receive(tr_BSSMAP_ComplL3);
4317
Harald Weltee3bd6582018-01-31 22:51:25 +01004318 /* send the single message we want to send */
4319 f_rsl_send_l3(l3);
4320}
4321
4322private function f_bssap_expect_nothing(float sec := 5.00) runs on MSC_ConnHdlr {
4323 timer T := sec;
4324 var PDU_BSSAP bssap;
Harald Welte898113b2018-01-31 18:32:21 +01004325 T.start;
4326 alt {
Harald Weltee3bd6582018-01-31 22:51:25 +01004327 [] BSSAP.receive(PDU_BSSAP:?) -> value bssap {
4328 setverdict(fail, "Unexpected BSSMAP ", bssap);
Daniel Willmannafce8662018-07-06 23:11:32 +02004329 mtc.stop;
Harald Welte898113b2018-01-31 18:32:21 +01004330 }
4331 [] T.timeout {
4332 setverdict(pass);
4333 }
4334 }
4335}
4336
Harald Weltee3bd6582018-01-31 22:51:25 +01004337/* unsolicited ASSIGNMENT FAIL (without ASSIGN) from MS shouldn't bring BSC down */
4338private function f_tc_unsol_ass_fail(charstring id) runs on MSC_ConnHdlr {
4339 f_est_single_l3(ts_RRM_AssignmentFailure('00'O));
4340 f_bssap_expect_nothing();
4341}
Harald Welte898113b2018-01-31 18:32:21 +01004342testcase TC_unsol_ass_fail() runs on test_CT {
4343 var MSC_ConnHdlr vc_conn;
4344 f_init(1, true);
4345 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02004346 vc_conn := f_start_handler(refers(f_tc_unsol_ass_fail));
Harald Welte898113b2018-01-31 18:32:21 +01004347 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004348 f_shutdown_helper();
Harald Welte898113b2018-01-31 18:32:21 +01004349}
Harald Welte552620d2017-12-16 23:21:36 +01004350
Harald Welteea99a002018-01-31 20:46:43 +01004351
4352/* unsolicited ASSIGNMENT COMPLETE (without ASSIGN) from MS shouldn't bring BSC down */
4353private function f_tc_unsol_ass_compl(charstring id) runs on MSC_ConnHdlr {
Harald Weltee3bd6582018-01-31 22:51:25 +01004354 f_est_single_l3(ts_RRM_AssignmentComplete('00'O));
4355 f_bssap_expect_nothing();
Harald Welteea99a002018-01-31 20:46:43 +01004356}
4357testcase TC_unsol_ass_compl() runs on test_CT {
4358 var MSC_ConnHdlr vc_conn;
4359 f_init(1, true);
4360 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02004361 vc_conn := f_start_handler(refers(f_tc_unsol_ass_compl));
Harald Welteea99a002018-01-31 20:46:43 +01004362 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004363 f_shutdown_helper();
Harald Welteea99a002018-01-31 20:46:43 +01004364}
4365
4366
Harald Weltefbf9b5e2018-01-31 20:41:23 +01004367/* unsolicited HANDOVER FAIL (without ASSIGN) from MS shouldn't bring BSC down */
4368private function f_tc_unsol_ho_fail(charstring id) runs on MSC_ConnHdlr {
Harald Weltee3bd6582018-01-31 22:51:25 +01004369 f_est_single_l3(ts_RRM_HandoverFailure('00'O));
4370 f_bssap_expect_nothing();
Harald Weltefbf9b5e2018-01-31 20:41:23 +01004371}
Harald Weltefbf9b5e2018-01-31 20:41:23 +01004372testcase TC_unsol_ho_fail() runs on test_CT {
4373 var MSC_ConnHdlr vc_conn;
4374 f_init(1, true);
4375 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02004376 vc_conn := f_start_handler(refers(f_tc_unsol_ho_fail));
Harald Weltefbf9b5e2018-01-31 20:41:23 +01004377 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004378 f_shutdown_helper();
Harald Weltefbf9b5e2018-01-31 20:41:23 +01004379}
4380
4381
Harald Weltee3bd6582018-01-31 22:51:25 +01004382/* short message from MS should be ignored */
4383private function f_tc_err_82_short_msg(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02004384 g_pars := f_gen_test_hdlr_pars();
Harald Weltea0630032018-03-20 21:09:55 +01004385 f_create_chan_and_exp();
Harald Weltee3bd6582018-01-31 22:51:25 +01004386 /* we should now have a COMPL_L3 at the MSC */
4387 BSSAP.receive(tr_BSSMAP_ComplL3);
4388
4389 /* send short message */
4390 RSL.send(ts_RSL_DATA_IND(g_chan_nr, valueof(ts_RslLinkID_DCCH(0)), ''O));
4391 f_bssap_expect_nothing();
4392}
4393testcase TC_err_82_short_msg() runs on test_CT {
4394 var MSC_ConnHdlr vc_conn;
4395 f_init(1, true);
4396 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02004397 vc_conn := f_start_handler(refers(f_tc_err_82_short_msg));
Harald Weltee3bd6582018-01-31 22:51:25 +01004398 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004399 f_shutdown_helper();
Harald Weltee3bd6582018-01-31 22:51:25 +01004400}
4401
4402
Harald Weltee9e02e42018-01-31 23:36:25 +01004403/* 24.008 8.4 Unknown message must trigger RR STATUS */
4404private function f_tc_err_84_unknown_msg(charstring id) runs on MSC_ConnHdlr {
4405 f_est_single_l3(ts_RRM_UL_REL('00'O));
4406 timer T := 3.0
4407 alt {
4408 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_STATUS)) {
4409 setverdict(pass);
4410 }
4411 [] BSSAP.receive { setverdict(fail, "unexpected BSSAP"); }
Harald Welte458fd372018-03-21 11:26:23 +01004412 [] T.timeout { setverdict(fail, "Timeout waiting for RR STATUS"); }
Harald Weltee9e02e42018-01-31 23:36:25 +01004413 }
4414}
4415testcase TC_err_84_unknown_msg() runs on test_CT {
4416 var MSC_ConnHdlr vc_conn;
4417 f_init(1, true);
4418 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02004419 vc_conn := f_start_handler(refers(f_tc_err_84_unknown_msg));
Harald Weltee9e02e42018-01-31 23:36:25 +01004420 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004421 f_shutdown_helper();
Harald Weltee9e02e42018-01-31 23:36:25 +01004422}
4423
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004424/***********************************************************************
4425 * Handover
4426 ***********************************************************************/
4427
Harald Welte94e0c342018-04-07 11:33:23 +02004428/* execute a "bts <0-255> trx <0-255> timeslot <0-7> " command on given Dchan */
4429private function f_vty_ts_action(charstring suffix, integer bts_nr, integer trx_nr, integer ts_nr)
4430runs on test_CT {
4431 var charstring cmd := "bts "&int2str(bts_nr)&" trx "&int2str(trx_nr)&
4432 " timeslot "&int2str(ts_nr)&" ";
4433 f_vty_transceive(BSCVTY, cmd & suffix);
4434}
4435
Harald Welte261af4b2018-02-12 21:20:39 +01004436/* 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 +07004437private function f_vty_ss_action(TELNETasp_PT pt, charstring suffix,
4438 uint8_t bts_nr, uint8_t trx_nr,
4439 in RslChannelNr chan_nr)
4440{
Harald Welte261af4b2018-02-12 21:20:39 +01004441 /* FIXME: resolve those from component-global state */
4442 var integer ts_nr := chan_nr.tn;
4443 var integer ss_nr;
4444 if (ischosen(chan_nr.u.ch0)) {
4445 ss_nr := 0;
4446 } else if (ischosen(chan_nr.u.lm)) {
4447 ss_nr := chan_nr.u.lm.sub_chan;
4448 } else if (ischosen(chan_nr.u.sdcch4)) {
4449 ss_nr := chan_nr.u.sdcch4.sub_chan;
4450 } else if (ischosen(chan_nr.u.sdcch8)) {
4451 ss_nr := chan_nr.u.sdcch8.sub_chan;
4452 } else {
4453 setverdict(fail, "Invalid ChanNr ", chan_nr);
Daniel Willmannafce8662018-07-06 23:11:32 +02004454 mtc.stop;
Harald Welte261af4b2018-02-12 21:20:39 +01004455 }
4456
4457 var charstring cmd := "bts "&int2str(bts_nr)&" trx "&int2str(trx_nr)&
4458 " timeslot "&int2str(ts_nr)&" sub-slot "&int2str(ss_nr)&" ";
Vadim Yanitskiy00070722020-09-02 17:27:57 +07004459 f_vty_transceive(pt, cmd & suffix);
Harald Welte261af4b2018-02-12 21:20:39 +01004460}
4461
Neels Hofmeyr91401012019-07-11 00:42:35 +02004462/* Even though the VTY command to trigger handover takes a new BTS number as argument, behind the scenes osmo-bsc always
4463 * translates that to a target ARFCN+BSIC first. See bsc_vty.c trigger_ho_or_as(), which puts the selected BTS' neighbor
4464 * ident key (ARFCN + BSIC) in the struct passed on to handover_request(). handover_start() then resolves that to a
4465 * viable actual neighbor cell. So from the internal osmo-bsc perspective, we always request handover to an ARFCN + BSIC
4466 * pair, not really to a specific BTS number. */
Vadim Yanitskiy00070722020-09-02 17:27:57 +07004467private function f_vty_handover(TELNETasp_PT pt, uint8_t bts_nr, uint8_t trx_nr,
4468 in RslChannelNr chan_nr, uint8_t new_bts_nr)
4469{
4470 f_vty_ss_action(pt, "handover " & int2str(new_bts_nr), bts_nr, trx_nr, chan_nr);
Harald Welte261af4b2018-02-12 21:20:39 +01004471}
4472
4473/* intra-BSC hand-over between BTS0 and BTS1 */
4474private function f_tc_ho_int(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02004475 g_pars := f_gen_test_hdlr_pars();
Harald Welteed848512018-05-24 22:27:58 +02004476 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4477 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte261af4b2018-02-12 21:20:39 +01004478 const OCT8 kc := '0001020304050607'O;
4479
4480 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4481 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
4482
Harald Weltea0630032018-03-20 21:09:55 +01004483 f_establish_fully(ass_cmd, exp_compl);
Neels Hofmeyr666f0432020-07-04 00:53:07 +02004484 f_bts_0_cfg(BSCVTY, {"neighbor bts 1"});
Harald Welte261af4b2018-02-12 21:20:39 +01004485
4486 var HandoverState hs := {
4487 rr_ho_cmpl_seen := false,
4488 handover_done := false,
4489 old_chan_nr := -
4490 };
4491 /* issue hand-over command on VTY */
Vadim Yanitskiy00070722020-09-02 17:27:57 +07004492 f_vty_handover(BSCVTY, 0, 0, g_chan_nr, 1);
Harald Welte261af4b2018-02-12 21:20:39 +01004493 /* temporarily suspend DChan processing on BTS1 to avoid race with RSLEM_register */
4494 f_rslem_suspend(RSL1_PROC);
Philipp Maier3e2af5d2018-07-11 17:01:05 +02004495
4496 /* From the MGW perspective, a handover is is characterized by
4497 * performing one MDCX operation with the MGW. So we expect to see
4498 * one more MDCX during handover. */
4499 g_media.mgcp_conn[0].mdcx_seen_exp := g_media.mgcp_conn[0].crcx_seen_exp + 1;
4500
Harald Welte261af4b2018-02-12 21:20:39 +01004501 alt {
4502 [] as_handover(hs);
Harald Welte261af4b2018-02-12 21:20:39 +01004503 }
Philipp Maier3e2af5d2018-07-11 17:01:05 +02004504
Philipp Maier4dae0652018-11-12 12:03:26 +01004505 /* Since this is an internal handover we expect the BSC to inform the
4506 * MSC about the event */
4507 BSSAP.receive(tr_BSSMAP_HandoverPerformed);
4508
Philipp Maier3e2af5d2018-07-11 17:01:05 +02004509 /* Check the amount of MGCP transactions is still consistant with the
4510 * test expectation */
4511 f_check_mgcp_expectations()
Neels Hofmeyr861a4c12018-11-07 01:23:17 +01004512 f_sleep(0.5);
Harald Welte261af4b2018-02-12 21:20:39 +01004513}
4514
4515testcase TC_ho_int() runs on test_CT {
4516 var MSC_ConnHdlr vc_conn;
4517 f_init(2, true);
4518 f_sleep(1.0);
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004519
4520 f_ctrs_bsc_and_bts_init();
4521
Harald Welte8863fa12018-05-10 20:15:27 +02004522 vc_conn := f_start_handler(refers(f_tc_ho_int));
Harald Welte261af4b2018-02-12 21:20:39 +01004523 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004524
4525 /* from f_establish_fully() */
4526 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
4527 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
4528 /* from handover */
4529 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
4530 f_ctrs_bsc_and_bts_add(0, "handover:completed");
4531 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
4532 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:completed");
4533 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004534 f_shutdown_helper();
Harald Welte261af4b2018-02-12 21:20:39 +01004535}
Harald Weltee9e02e42018-01-31 23:36:25 +01004536
Neels Hofmeyr5f144212020-11-03 15:41:58 +00004537/* intra-BSC hand-over with CONNection FAILure and cause Radio Link Failure: check RR release cause */
4538private function f_tc_ho_int_radio_link_failure(charstring id) runs on MSC_ConnHdlr {
4539 g_pars := f_gen_test_hdlr_pars();
4540 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4541 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4542 const OCT8 kc := '0001020304050607'O;
4543
4544 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4545 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
4546
4547 f_establish_fully(ass_cmd, exp_compl);
4548 f_bts_0_cfg(BSCVTY, {"neighbor bts 1"});
4549
4550 var HandoverState hs := {
4551 rr_ho_cmpl_seen := false,
4552 handover_done := false,
4553 old_chan_nr := -
4554 };
4555 /* issue hand-over command on VTY */
4556 f_vty_handover(BSCVTY, 0, 0, g_chan_nr, 1);
4557 /* temporarily suspend DChan processing on BTS1 to avoid race with RSLEM_register */
4558 f_rslem_suspend(RSL1_PROC);
4559
4560 /* From the MGW perspective, a handover is is characterized by
4561 * performing one MDCX operation with the MGW. So we expect to see
4562 * one more MDCX during handover. */
4563 g_media.mgcp_conn[0].mdcx_seen_exp := g_media.mgcp_conn[0].crcx_seen_exp + 1;
4564
4565 var RSL_Message rsl;
4566 var PDU_ML3_NW_MS l3;
4567 var RslChannelNr new_chan_nr;
4568 var GsmArfcn arfcn;
4569 RSL.receive(tr_RSL_DATA_REQ(g_chan_nr)) -> value rsl {
4570 l3 := dec_PDU_ML3_NW_MS(rsl.ies[2].body.l3_info.payload);
4571 if (not ischosen(l3.msgs.rrm.handoverCommand)) {
4572 setverdict(fail, "Expected handoverCommand");
4573 mtc.stop;
4574 }
4575 }
4576 f_ChDesc2RslChanNr(l3.msgs.rrm.handoverCommand.channelDescription2,
4577 new_chan_nr, arfcn);
4578
4579 f_rslem_register(0, new_chan_nr, RSL1_PROC);
4580
4581 /* resume processing of RSL DChan messages, which was temporarily suspended
4582 * before performing a hand-over */
4583 f_rslem_resume(RSL1_PROC);
4584 RSL1.receive(tr_RSL_IPA_CRCX(new_chan_nr));
4585
4586 f_sleep(1.0);
4587
4588 /* Handover fails because no HANDO DET appears on the new lchan,
4589 * and the old lchan reports a Radio Link Failure. */
4590 RSL.send(ts_RSL_CONN_FAIL_IND(g_chan_nr, RSL_ERR_RADIO_LINK_FAIL));
4591
4592 var PDU_BSSAP rx_clear_request;
4593 BSSAP.receive(tr_BSSMAP_ClearRequest) -> value rx_clear_request;
4594 var BssmapCause cause := bit2int(rx_clear_request.pdu.bssmap.clearRequest.cause.causeValue);
4595 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
4596
4597 var RR_Cause rr_cause := GSM48_RR_CAUSE_ABNORMAL_UNSPEC;
4598
4599 var MgcpCommand mgcp;
4600 interleave {
4601 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_RELEASE(int2oct(enum2int(rr_cause), 1)))) {}
4602 [] RSL.receive(tr_RSL_DEACT_SACCH(g_chan_nr)) {}
4603 [] RSL.receive(tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL)) {
4604 RSL.send(ts_RSL_RF_CHAN_REL_ACK(g_chan_nr));
4605 }
4606 [] RSL1.receive(tr_RSL_DEACT_SACCH(new_chan_nr)) {}
4607 [] RSL1.receive(tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL)) {
4608 RSL1.send(ts_RSL_RF_CHAN_REL_ACK(new_chan_nr));
4609 }
4610 [] BSSAP.receive(tr_BSSMAP_ClearComplete) {}
4611 }
4612
4613 f_sleep(0.5);
4614 setverdict(pass);
4615}
4616testcase TC_ho_int_radio_link_failure() runs on test_CT {
4617 var MSC_ConnHdlr vc_conn;
4618 f_init(2, true);
4619 f_sleep(1.0);
4620
4621 f_ctrs_bsc_and_bts_init();
4622
4623 vc_conn := f_start_handler(refers(f_tc_ho_int_radio_link_failure));
4624 vc_conn.done;
4625
4626 /* from f_establish_fully() */
4627 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
4628 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
4629 /* from handover */
4630 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
4631 f_ctrs_bsc_and_bts_add(0, "handover:stopped");
4632 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
4633 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:stopped");
4634 f_ctrs_bsc_and_bts_verify();
4635 f_shutdown_helper();
4636}
4637
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004638/* Expecting MGCP to DLCX the endpoint's two connections: towards BTS and towards MSC */
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02004639private function f_expect_dlcx_conns() runs on MSC_ConnHdlr {
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004640 var MgcpCommand mgcp;
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +02004641 var template MgcpResponse mgcp_resp;
4642 var MGCP_RecvFrom mrf;
4643 var template MgcpMessage msg_resp;
4644 var template MgcpMessage msg_dlcx := {
4645 command := tr_DLCX()
4646 }
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004647
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +02004648 if (g_pars.aoip) {
4649 MGCP.receive(tr_DLCX()) -> value mgcp {
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004650 log("Got first DLCX: ", mgcp);
4651 MGCP.send(ts_DLCX_ACK2(mgcp.line.trans_id));
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +02004652 };
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004653
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004654 MGCP.receive(tr_DLCX()) -> value mgcp {
4655 log("Got second DLCX: ", mgcp);
4656 MGCP.send(ts_DLCX_ACK2(mgcp.line.trans_id));
4657 };
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +02004658 } else {
4659 /* For SCCPLite, BSC doesn't handle the MSC-side */
4660 MGCP_MULTI.receive(tr_MGCP_RecvFrom_any(msg_dlcx)) -> value mrf {
4661 log("Got first DLCX: ", mrf.msg.command);
4662 msg_resp := {
4663 response := ts_DLCX_ACK2(mrf.msg.command.line.trans_id)
4664 }
4665 MGCP_MULTI.send(t_MGCP_SendToMrf(mrf, msg_resp));
4666 };
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004667 }
4668
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02004669 BSSAP.receive(tr_BSSMAP_ClearComplete);
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004670}
4671
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004672private function f_tc_ho_out_of_this_bsc(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02004673 g_pars := f_gen_test_hdlr_pars();
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004674
4675 var PDU_BSSAP ass_req := f_gen_ass_req();
4676 ass_req.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4677 ass_req.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
4678 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4679 f_establish_fully(ass_req, exp_compl);
4680
Neels Hofmeyr666f0432020-07-04 00:53:07 +02004681 f_bts_0_cfg(BSCVTY, {"neighbor lac 99 arfcn 123 bsic any"});
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004682 f_vty_transceive(BSCVTY, "handover any to arfcn 123 bsic any");
4683
4684 BSSAP.receive(tr_BSSMAP_HandoverRequired);
4685
4686 f_sleep(0.5);
4687 /* The MSC negotiates Handover Request and Handover Request Ack with
4688 * the other BSS and comes back with a BSSMAP Handover Command
4689 * containing an RR Handover Command coming from the target BSS... */
4690
4691 var PDU_ML3_NW_MS rr_ho_cmd := valueof(ts_RR_HandoverCommand);
4692 log("Remote cell's RR Handover Command passed through as L3 Info: ", rr_ho_cmd);
4693 var octetstring rr_ho_cmd_enc := enc_PDU_ML3_NW_MS(rr_ho_cmd);
4694 log("Remote cell's RR Handover Command passed through as L3 Info, encoded: ", rr_ho_cmd_enc);
4695 BSSAP.send(ts_BSSMAP_HandoverCommand(rr_ho_cmd_enc));
4696
4697 /* expect the Handover Command to go out on RR */
4698 var RSL_Message rsl_ho_cmd
4699 RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, ?)) -> value rsl_ho_cmd;
4700 log("RSL Data Req went out to first BTS: ", rsl_ho_cmd);
4701 var RSL_IE_Body rsl_ho_cmd_l3;
4702 if (not f_rsl_find_ie(rsl_ho_cmd, RSL_IE_L3_INFO, rsl_ho_cmd_l3)) {
4703 log("RSL message contains no L3 Info IE, expected RR Handover Command");
4704 setverdict(fail);
4705 } else {
4706 log("Found L3 Info: ", rsl_ho_cmd_l3);
4707 if (rsl_ho_cmd_l3.l3_info.payload != rr_ho_cmd_enc) {
4708 log("FAIL: the BSC sent out a different L3 Info, not matching the RR Handover Command the other BSS forwarded.");
4709 setverdict(fail);
4710 } else {
4711 log("Success: the BSC sent out the same RR Handover Command the other BSS forwarded.");
4712 setverdict(pass);
4713 }
4714 }
4715
4716 /* When the other BSS has reported a completed handover, this side is
4717 * torn down. */
4718
4719 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_HANDOVER_SUCCESSFUL;
4720 var BssmapCause cause := enum2int(cause_val);
4721 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
4722
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02004723 f_expect_dlcx_conns();
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004724 setverdict(pass);
4725 f_sleep(1.0);
4726}
4727testcase TC_ho_out_of_this_bsc() runs on test_CT {
4728 var MSC_ConnHdlr vc_conn;
4729
4730 f_init(1, true);
4731 f_sleep(1.0);
4732
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004733 f_ctrs_bsc_and_bts_init();
4734
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004735 vc_conn := f_start_handler(refers(f_tc_ho_out_of_this_bsc));
4736 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004737
4738 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
4739 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
4740 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
4741 f_ctrs_bsc_and_bts_add(0, "handover:completed");
4742 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
4743 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:completed");
4744 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004745 f_shutdown_helper();
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004746}
4747
Neels Hofmeyr0aa719b2020-10-12 18:43:09 +00004748private function f_mo_l3_transceive(RSL_DCHAN_PT rsl := RSL,
4749 template (value) RslLinkId link_id := ts_RslLinkID_DCCH(0),
Vadim Yanitskiy2ef6a2f2020-10-08 23:17:32 +07004750 template (present) OCT1 dlci := ?,
Vadim Yanitskiyb93aa432020-10-01 14:23:11 +07004751 octetstring l3 := '0123456789'O)
4752runs on MSC_ConnHdlr {
Neels Hofmeyr43654812020-09-25 01:35:35 +02004753 /* The old lchan and conn should still be active. See that arbitrary L3
4754 * is still going through. */
Neels Hofmeyr0aa719b2020-10-12 18:43:09 +00004755 rsl.send(ts_RSL_DATA_IND(g_chan_nr, link_id, l3));
Neels Hofmeyr43654812020-09-25 01:35:35 +02004756 var template PDU_BSSAP exp_data := {
4757 discriminator := '1'B,
4758 spare := '0000000'B,
Vadim Yanitskiyb93aa432020-10-01 14:23:11 +07004759 dlci := dlci,
4760 lengthIndicator := lengthof(l3),
Neels Hofmeyr43654812020-09-25 01:35:35 +02004761 pdu := {
4762 dtap := l3
4763 }
4764 };
4765 BSSAP.receive(exp_data);
4766 setverdict(pass);
4767}
4768
Neels Hofmeyr0aa719b2020-10-12 18:43:09 +00004769private function f_mt_l3_transceive(RSL_DCHAN_PT rsl := RSL,
4770 template (present) RslLinkId link_id := tr_RslLinkID_DCCH(0),
Vadim Yanitskiy0033a3b2020-10-01 22:21:16 +07004771 template (value) OCT1 dlci := '00'O,
4772 octetstring l3 := '0123456789'O)
4773runs on MSC_ConnHdlr {
4774 BSSAP.send(PDU_BSSAP:{
4775 discriminator := '1'B,
4776 spare := '0000000'B,
4777 dlci := dlci,
4778 lengthIndicator := lengthof(l3),
4779 pdu := {
4780 dtap := l3
4781 }
4782 });
Neels Hofmeyr0aa719b2020-10-12 18:43:09 +00004783 rsl.receive(tr_RSL_DATA_REQ(g_chan_nr, link_id, l3));
Vadim Yanitskiy0033a3b2020-10-01 22:21:16 +07004784 setverdict(pass);
4785}
4786
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004787/* BSC asks for inter-BSC HO, but the MSC decides that it won't happen and
4788 * simply never sends a BSSMAP Handover Command. */
4789private function f_tc_ho_out_fail_no_msc_response(charstring id) runs on MSC_ConnHdlr {
Daniel Willmann3b59eb52018-10-29 15:40:55 +01004790 g_pars := f_gen_test_hdlr_pars();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004791
4792 var PDU_BSSAP ass_req := f_gen_ass_req();
4793 ass_req.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4794 ass_req.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
4795 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4796 f_establish_fully(ass_req, exp_compl);
4797
Neels Hofmeyr666f0432020-07-04 00:53:07 +02004798 f_bts_0_cfg(BSCVTY, {"neighbor lac 99 arfcn 123 bsic any"});
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004799 f_vty_transceive(BSCVTY, "handover any to arfcn 123 bsic any");
4800
4801 BSSAP.receive(tr_BSSMAP_HandoverRequired);
4802
4803 /* osmo-bsc should time out 10 seconds after the handover started.
4804 * Let's give it a bit extra. */
4805 f_sleep(15.0);
4806
Vadim Yanitskiy74ae5eb2020-10-01 22:13:29 +07004807 f_mo_l3_transceive();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004808 f_sleep(1.0);
4809}
4810testcase TC_ho_out_fail_no_msc_response() runs on test_CT {
4811 var MSC_ConnHdlr vc_conn;
4812
4813 f_init(1, true);
4814 f_sleep(1.0);
4815
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004816 f_ctrs_bsc_and_bts_init();
4817
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004818 vc_conn := f_start_handler(refers(f_tc_ho_out_fail_no_msc_response));
4819 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004820
4821 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
4822 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
4823 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
4824 f_ctrs_bsc_and_bts_add(0, "handover:timeout");
4825 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
4826 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:timeout");
4827 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004828 f_shutdown_helper();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004829}
4830
4831/* BSC asks for inter-BSC HO, receives BSSMAP Handover Command, but MS reports
4832 * RR Handover Failure. */
4833private function f_tc_ho_out_fail_rr_ho_failure(charstring id) runs on MSC_ConnHdlr {
Daniel Willmann3b59eb52018-10-29 15:40:55 +01004834 g_pars := f_gen_test_hdlr_pars();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004835
4836 var PDU_BSSAP ass_req := f_gen_ass_req();
4837 ass_req.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4838 ass_req.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
4839 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4840 f_establish_fully(ass_req, exp_compl);
4841
Neels Hofmeyr666f0432020-07-04 00:53:07 +02004842 f_bts_0_cfg(BSCVTY, {"neighbor lac 99 arfcn 123 bsic any"});
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004843 f_vty_transceive(BSCVTY, "handover any to arfcn 123 bsic any");
4844
4845 BSSAP.receive(tr_BSSMAP_HandoverRequired);
4846
4847 f_sleep(0.5);
4848 /* The MSC negotiates Handover Request and Handover Request Ack with
4849 * the other BSS and comes back with a BSSMAP Handover Command
4850 * containing an RR Handover Command coming from the target BSS... */
4851
4852 var PDU_ML3_NW_MS rr_ho_cmd := valueof(ts_RR_HandoverCommand);
4853 log("Remote cell's RR Handover Command passed through as L3 Info: ", rr_ho_cmd);
4854 var octetstring rr_ho_cmd_enc := enc_PDU_ML3_NW_MS(rr_ho_cmd);
4855 log("Remote cell's RR Handover Command passed through as L3 Info, encoded: ", rr_ho_cmd_enc);
4856 BSSAP.send(ts_BSSMAP_HandoverCommand(rr_ho_cmd_enc));
4857
4858 /* expect the Handover Command to go out on RR */
4859 var RSL_Message rsl_ho_cmd
4860 RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, ?)) -> value rsl_ho_cmd;
4861 log("RSL Data Req went out to first BTS: ", rsl_ho_cmd);
4862 var RSL_IE_Body rsl_ho_cmd_l3;
4863 if (not f_rsl_find_ie(rsl_ho_cmd, RSL_IE_L3_INFO, rsl_ho_cmd_l3)) {
4864 log("RSL message contains no L3 Info IE, expected RR Handover Command");
4865 setverdict(fail);
4866 } else {
4867 log("Found L3 Info: ", rsl_ho_cmd_l3);
4868 if (rsl_ho_cmd_l3.l3_info.payload != rr_ho_cmd_enc) {
4869 log("FAIL: the BSC sent out a different L3 Info, not matching the RR Handover Command the other BSS forwarded.");
4870 setverdict(fail);
4871 } else {
4872 log("Success: the BSC sent out the same RR Handover Command the other BSS forwarded.");
4873 setverdict(pass);
4874 }
4875 }
4876
4877 f_sleep(0.2);
4878 f_rsl_send_l3(ts_RRM_HandoverFailure('00'O));
4879
4880 /* Should tell the MSC about the failure */
4881 BSSAP.receive(tr_BSSMAP_HandoverFailure);
4882
4883 f_sleep(1.0);
4884
Vadim Yanitskiy74ae5eb2020-10-01 22:13:29 +07004885 f_mo_l3_transceive();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004886 f_sleep(1.0);
4887
4888 setverdict(pass);
4889 f_sleep(1.0);
4890}
4891testcase TC_ho_out_fail_rr_ho_failure() runs on test_CT {
4892 var MSC_ConnHdlr vc_conn;
4893
4894 f_init(1, true);
4895 f_sleep(1.0);
4896
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004897 f_ctrs_bsc_and_bts_init();
4898
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004899 vc_conn := f_start_handler(refers(f_tc_ho_out_fail_rr_ho_failure));
4900 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004901
4902 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
4903 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
4904 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
4905 f_ctrs_bsc_and_bts_add(0, "handover:failed");
4906 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
4907 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:failed");
4908 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004909 f_shutdown_helper();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004910}
4911
Neels Hofmeyr10f2bfa2019-07-09 19:33:29 +02004912/* BSC asks for inter-BSC-out HO, receives BSSMAP Handover Command, but then no reply is received about HO outcome
4913 * (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 +02004914 * and the lchan is released. */
4915private function f_tc_ho_out_fail_no_result_after_ho_cmd(charstring id) runs on MSC_ConnHdlr {
Daniel Willmann3b59eb52018-10-29 15:40:55 +01004916 g_pars := f_gen_test_hdlr_pars();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004917
4918 var PDU_BSSAP ass_req := f_gen_ass_req();
4919 ass_req.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4920 ass_req.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
4921 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4922 f_establish_fully(ass_req, exp_compl);
4923
Neels Hofmeyr666f0432020-07-04 00:53:07 +02004924 f_bts_0_cfg(BSCVTY, {"neighbor lac 99 arfcn 123 bsic any"});
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004925 f_vty_transceive(BSCVTY, "handover any to arfcn 123 bsic any");
4926
4927 BSSAP.receive(tr_BSSMAP_HandoverRequired);
4928
4929 f_sleep(0.5);
4930 /* The MSC negotiates Handover Request and Handover Request Ack with
4931 * the other BSS and comes back with a BSSMAP Handover Command
4932 * containing an RR Handover Command coming from the target BSS... */
4933
4934 var PDU_ML3_NW_MS rr_ho_cmd := valueof(ts_RR_HandoverCommand);
4935 log("Remote cell's RR Handover Command passed through as L3 Info: ", rr_ho_cmd);
4936 var octetstring rr_ho_cmd_enc := enc_PDU_ML3_NW_MS(rr_ho_cmd);
4937 log("Remote cell's RR Handover Command passed through as L3 Info, encoded: ", rr_ho_cmd_enc);
4938 BSSAP.send(ts_BSSMAP_HandoverCommand(rr_ho_cmd_enc));
4939
4940 /* expect the Handover Command to go out on RR */
4941 var RSL_Message rsl_ho_cmd
4942 RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, ?)) -> value rsl_ho_cmd;
4943 log("RSL Data Req went out to first BTS: ", rsl_ho_cmd);
4944 var RSL_IE_Body rsl_ho_cmd_l3;
4945 if (not f_rsl_find_ie(rsl_ho_cmd, RSL_IE_L3_INFO, rsl_ho_cmd_l3)) {
4946 log("RSL message contains no L3 Info IE, expected RR Handover Command");
4947 setverdict(fail);
4948 } else {
4949 log("Found L3 Info: ", rsl_ho_cmd_l3);
4950 if (rsl_ho_cmd_l3.l3_info.payload != rr_ho_cmd_enc) {
4951 log("FAIL: the BSC sent out a different L3 Info, not matching the RR Handover Command the other BSS forwarded.");
4952 setverdict(fail);
4953 } else {
4954 log("Success: the BSC sent out the same RR Handover Command the other BSS forwarded.");
4955 setverdict(pass);
4956 }
4957 }
4958
Neels Hofmeyr10f2bfa2019-07-09 19:33:29 +02004959 /* We get neither success nor failure report from the remote BSS. Eventually T8 times out and we run into 3GPP
4960 * TS 48.008 3.1.5.3.3 "Abnormal Conditions": Clear Request should go to the MSC, and RR should be released
4961 * after Clear Command */
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004962
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02004963 var PDU_BSSAP rx_clear_request;
Neels Hofmeyre1797aa2019-07-09 19:34:04 +02004964 BSSAP.receive(tr_BSSMAP_ClearRequest) -> value rx_clear_request;
4965 log("Got BSSMAP Clear Request");
4966 /* Instruct BSC to clear channel */
4967 var BssmapCause cause := bit2int(rx_clear_request.pdu.bssmap.clearRequest.cause.causeValue);
4968 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
4969
4970 var MgcpCommand mgcp;
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004971 interleave {
Neels Hofmeyr861a4c12018-11-07 01:23:17 +01004972 [] RSL.receive(tr_RSL_DEACT_SACCH(g_chan_nr)) {
4973 log("Got Deact SACCH");
4974 }
Harald Welte924b6ea2019-02-04 01:05:34 +01004975 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_RELEASE)) {
Neels Hofmeyr211169d2018-11-07 00:37:29 +01004976 log("Got RR Release");
4977 }
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004978 [] RSL.receive(tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL)) {
4979 log("Got RF Chan Rel");
4980 RSL.send(ts_RSL_RF_CHAN_REL_ACK(g_chan_nr));
4981 }
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004982 }
4983
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02004984 f_expect_dlcx_conns();
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004985
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004986 setverdict(pass);
4987 f_sleep(1.0);
4988}
Neels Hofmeyrd8a602c2019-07-09 19:46:01 +02004989testcase TC_ho_out_fail_no_result_after_ho_cmd() runs on test_CT {
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004990 var MSC_ConnHdlr vc_conn;
4991
4992 f_init(1, true);
4993 f_sleep(1.0);
4994
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004995 f_ctrs_bsc_and_bts_init();
4996
Neels Hofmeyrd8a602c2019-07-09 19:46:01 +02004997 vc_conn := f_start_handler(refers(f_tc_ho_out_fail_no_result_after_ho_cmd));
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004998 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004999
5000 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5001 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5002 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5003 f_ctrs_bsc_and_bts_add(0, "handover:timeout");
5004 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
5005 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:timeout");
5006 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005007 f_shutdown_helper();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02005008}
5009
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005010private function f_tc_ho_into_this_bsc(charstring id) runs on MSC_ConnHdlr {
5011 /* Hack: the proper way would be to wait for the BSSMAP Handover Request ACK and extract the
5012 * actual assigned chan_nr from its L3 (RR Handover Command) message. But osmo-bsc starts acting
5013 * on the lchan even before we get a chance to evaluate the BSSMAP Handover Request ACK. So we
5014 * need to assume that osmo-bsc will activate TS 1 and already set up this lchan's RSL emulation
5015 * before we get started. */
5016 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
5017 f_rslem_register(0, new_chan_nr);
5018 g_chan_nr := new_chan_nr;
5019 f_sleep(1.0);
5020
5021 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
5022 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
5023 activate(as_Media());
5024
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005025 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Pau Espin Pedrol07866632020-09-03 19:10:55 +02005026 f_gen_handover_req(aoip_tla := g_pars.host_aoip_tla)));
Harald Welte6811d102019-04-14 22:23:14 +02005027 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005028
5029 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
5030
5031 var PDU_BSSAP rx_bssap;
5032 var octetstring ho_command_str;
5033
5034 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
Pau Espin Pedrol76ba5412019-06-10 11:00:33 +02005035
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005036 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
5037 log("Received L3 Info in HO Request Ack: ", ho_command_str);
5038 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
5039 log("L3 Info in HO Request Ack is ", ho_command);
5040
5041 var GsmArfcn arfcn;
5042 var RslChannelNr actual_new_chan_nr;
5043 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
5044 actual_new_chan_nr, arfcn);
5045
5046 if (actual_new_chan_nr != new_chan_nr) {
5047 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
5048 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
5049 setverdict(fail);
5050 return;
5051 }
5052 log("Handover Command chan_nr is", actual_new_chan_nr);
5053
5054 /* Now the MSC forwards the RR Handover Command to the other BSC, which
5055 * tells the MS to handover to the new lchan. Here comes the new MS on
5056 * the new lchan with a Handover RACH: */
5057
5058 /* send handover detect */
5059
5060 RSL.send(ts_RSL_HANDO_DET(new_chan_nr));
5061
5062 BSSAP.receive(tr_BSSMAP_HandoverDetect);
5063
5064 /* send handover complete over the new channel */
5065
5066 var PDU_ML3_MS_NW l3_tx := valueof(ts_RRM_HandoverComplete('00'O));
5067 RSL.send(ts_RSL_EST_IND(new_chan_nr, valueof(ts_RslLinkID_DCCH(0)),
5068 enc_PDU_ML3_MS_NW(l3_tx)));
5069
5070 BSSAP.receive(tr_BSSMAP_HandoverComplete);
5071 setverdict(pass);
5072}
Pau Espin Pedrol07866632020-09-03 19:10:55 +02005073function f_tc_ho_into_this_bsc_main(TestHdlrParams pars) runs on test_CT {
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005074 var MSC_ConnHdlr vc_conn;
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005075
5076 f_init(1, true);
5077 f_sleep(1.0);
5078
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005079 f_ctrs_bsc_and_bts_init();
5080
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005081 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
5082 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005083
5084 vc_conn := f_start_handler(refers(f_tc_ho_into_this_bsc), pars);
5085 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005086
5087 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5088 f_ctrs_bsc_and_bts_add(0, "handover:completed");
5089 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:attempted");
5090 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:completed");
5091 f_ctrs_bsc_and_bts_verify();
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005092}
5093
Pau Espin Pedrol07866632020-09-03 19:10:55 +02005094testcase TC_ho_into_this_bsc() runs on test_CT {
5095 var TestHdlrParams pars := f_gen_test_hdlr_pars();
5096 f_tc_ho_into_this_bsc_main(pars);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005097 f_shutdown_helper();
Pau Espin Pedrol07866632020-09-03 19:10:55 +02005098}
5099
5100testcase TC_ho_into_this_bsc_tla_v6() runs on test_CT {
5101 var TestHdlrParams pars := f_gen_test_hdlr_pars();
5102 pars.host_aoip_tla := "::6";
5103 f_tc_ho_into_this_bsc_main(pars);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005104 f_shutdown_helper();
Pau Espin Pedrol07866632020-09-03 19:10:55 +02005105}
5106
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005107private function f_tc_ho_in_fail_msc_clears(charstring id) runs on MSC_ConnHdlr {
5108 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
5109 f_rslem_register(0, new_chan_nr);
5110 g_chan_nr := new_chan_nr;
5111 f_sleep(1.0);
5112
5113 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
5114 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
5115 activate(as_Media());
5116
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005117 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005118 f_gen_handover_req()));
Harald Welte6811d102019-04-14 22:23:14 +02005119 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005120
5121 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
5122
5123 var PDU_BSSAP rx_bssap;
5124 var octetstring ho_command_str;
5125
5126 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
5127
5128 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
5129 log("Received L3 Info in HO Request Ack: ", ho_command_str);
5130 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
5131 log("L3 Info in HO Request Ack is ", ho_command);
5132
5133 var GsmArfcn arfcn;
5134 var RslChannelNr actual_new_chan_nr;
5135 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
5136 actual_new_chan_nr, arfcn);
5137
5138 if (actual_new_chan_nr != new_chan_nr) {
5139 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
5140 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
5141 setverdict(fail);
5142 return;
5143 }
5144 log("Handover Command chan_nr is", actual_new_chan_nr);
5145
Neels Hofmeyr61ca08d2019-05-06 23:52:22 +02005146 /* For deterministic test results, give some time for the MGW endpoint to be configured */
5147 f_sleep(1.0);
5148
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005149 /* Now the MSC forwards the RR Handover Command to the other BSC, which
5150 * tells the MS to handover to the new lchan. In this case, the MS
5151 * reports a Handover Failure to the old BSS, which forwards a BSSMAP
5152 * Handover Failure to the MSC. The procedure according to 3GPP TS
5153 * 48.008 3.1.5.3.2 "Handover Failure" is then that the MSC sends a
5154 * BSSMAP Clear Command: */
5155
5156 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_RADIO_INTERFACE_FAILURE_REVERSION;
5157 var BssmapCause cause := enum2int(cause_val);
5158 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
5159
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02005160 f_expect_dlcx_conns();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005161 setverdict(pass);
5162 f_sleep(1.0);
5163
5164 setverdict(pass);
5165}
5166testcase TC_ho_in_fail_msc_clears() runs on test_CT {
5167 var MSC_ConnHdlr vc_conn;
5168 var TestHdlrParams pars := f_gen_test_hdlr_pars();
5169
5170 f_init(1, true);
5171 f_sleep(1.0);
5172
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005173 f_ctrs_bsc_and_bts_init();
5174
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005175 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
5176 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005177
5178 vc_conn := f_start_handler(refers(f_tc_ho_in_fail_msc_clears), pars);
5179 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005180
5181 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5182 f_ctrs_bsc_and_bts_add(0, "handover:stopped");
5183 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:attempted");
5184 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:stopped");
5185 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005186 f_shutdown_helper();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005187}
5188
5189private function f_tc_ho_in_fail_msc_clears_after_ho_detect(charstring id) runs on MSC_ConnHdlr {
5190 /* Hack: the proper way would be to wait for the BSSMAP Handover Request ACK and extract the
5191 * actual assigned chan_nr from its L3 (RR Handover Command) message. But osmo-bsc starts acting
5192 * on the lchan even before we get a chance to evaluate the BSSMAP Handover Request ACK. So we
5193 * need to assume that osmo-bsc will activate TS 1 and already set up this lchan's RSL emulation
5194 * before we get started. */
5195 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
5196 f_rslem_register(0, new_chan_nr);
5197 g_chan_nr := new_chan_nr;
5198 f_sleep(1.0);
5199
5200 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
5201 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
5202 activate(as_Media());
5203
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005204 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005205 f_gen_handover_req()));
Harald Welte6811d102019-04-14 22:23:14 +02005206 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005207
5208 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
5209
5210 var PDU_BSSAP rx_bssap;
5211 var octetstring ho_command_str;
5212
5213 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
5214
5215 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
5216 log("Received L3 Info in HO Request Ack: ", ho_command_str);
5217 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
5218 log("L3 Info in HO Request Ack is ", ho_command);
5219
5220 var GsmArfcn arfcn;
5221 var RslChannelNr actual_new_chan_nr;
5222 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
5223 actual_new_chan_nr, arfcn);
5224
5225 if (actual_new_chan_nr != new_chan_nr) {
5226 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
5227 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
5228 setverdict(fail);
5229 return;
5230 }
5231 log("Handover Command chan_nr is", actual_new_chan_nr);
5232
5233 /* Now the MSC forwards the RR Handover Command to the other BSC, which
5234 * tells the MS to handover to the new lchan. Here comes the new MS on
5235 * the new lchan with a Handover RACH: */
5236
5237 /* send handover detect */
5238
5239 RSL.send(ts_RSL_HANDO_DET(new_chan_nr));
5240
5241 BSSAP.receive(tr_BSSMAP_HandoverDetect);
5242
5243 /* The MSC chooses to clear the connection now, maybe we got the
5244 * Handover RACH on the new cell but the MS still signaled Handover
5245 * Failure to the old BSS? */
5246
5247 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_RADIO_INTERFACE_FAILURE_REVERSION;
5248 var BssmapCause cause := enum2int(cause_val);
5249 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
5250
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02005251 f_expect_dlcx_conns();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005252 f_sleep(1.0);
5253}
5254testcase TC_ho_in_fail_msc_clears_after_ho_detect() runs on test_CT {
5255 var MSC_ConnHdlr vc_conn;
5256 var TestHdlrParams pars := f_gen_test_hdlr_pars();
5257
5258 f_init(1, true);
5259 f_sleep(1.0);
5260
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005261 f_ctrs_bsc_and_bts_init();
5262
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005263 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
5264 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005265
5266 vc_conn := f_start_handler(refers(f_tc_ho_in_fail_msc_clears_after_ho_detect), pars);
5267 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005268
5269 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5270 f_ctrs_bsc_and_bts_add(0, "handover:stopped");
5271 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:attempted");
5272 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:stopped");
5273 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005274 f_shutdown_helper();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005275}
5276
5277/* The new BSS's lchan times out before the MSC decides that handover failed. */
5278private function f_tc_ho_in_fail_no_detect(charstring id) runs on MSC_ConnHdlr {
5279 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
5280 f_rslem_register(0, new_chan_nr);
5281 g_chan_nr := new_chan_nr;
5282 f_sleep(1.0);
5283
5284 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
5285 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
5286 activate(as_Media());
5287
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005288 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005289 f_gen_handover_req()));
Harald Welte6811d102019-04-14 22:23:14 +02005290 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005291
5292 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
5293
5294 var PDU_BSSAP rx_bssap;
5295 var octetstring ho_command_str;
5296
5297 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
5298
5299 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
5300 log("Received L3 Info in HO Request Ack: ", ho_command_str);
5301 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
5302 log("L3 Info in HO Request Ack is ", ho_command);
5303
5304 var GsmArfcn arfcn;
5305 var RslChannelNr actual_new_chan_nr;
5306 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
5307 actual_new_chan_nr, arfcn);
5308
5309 if (actual_new_chan_nr != new_chan_nr) {
5310 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
5311 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
5312 setverdict(fail);
5313 return;
5314 }
5315 log("Handover Command chan_nr is", actual_new_chan_nr);
5316
5317 /* Now the MSC forwards the RR Handover Command to the other BSC, which
5318 * tells the MS to handover to the new lchan. But the MS never shows up
5319 * on the new lchan. */
5320
5321 BSSAP.receive(tr_BSSMAP_HandoverFailure);
5322
5323 /* Did osmo-bsc also send a Clear Request? */
5324 timer T := 0.5;
5325 T.start;
5326 alt {
5327 [] BSSAP.receive(tr_BSSMAP_ClearRequest);
5328 [] T.timeout { }
5329 }
5330
5331 /* MSC plays along with a Clear Command (no matter whether osmo-bsc
5332 * asked for it, this is a Handover Failure after all). */
5333
5334 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_RADIO_INTERFACE_FAILURE_REVERSION;
5335 var BssmapCause cause := enum2int(cause_val);
5336 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
5337
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02005338 f_expect_dlcx_conns();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005339 f_sleep(1.0);
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005340}
5341testcase TC_ho_in_fail_no_detect() runs on test_CT {
5342 var MSC_ConnHdlr vc_conn;
5343 var TestHdlrParams pars := f_gen_test_hdlr_pars();
5344
5345 f_init(1, true);
5346 f_sleep(1.0);
5347
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005348 f_ctrs_bsc_and_bts_init();
5349
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005350 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
5351 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005352
5353 vc_conn := f_start_handler(refers(f_tc_ho_in_fail_no_detect), pars);
5354 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005355
5356 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5357 f_ctrs_bsc_and_bts_add(0, "handover:error");
5358 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:attempted");
5359 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:error");
5360 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005361 f_shutdown_helper();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005362}
5363
5364/* Same as f_tc_ho_in_fail_no_detect, but MSC fails to send a Clear Command */
5365private function f_tc_ho_in_fail_no_detect2(charstring id) runs on MSC_ConnHdlr {
5366 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
5367 f_rslem_register(0, new_chan_nr);
5368 g_chan_nr := new_chan_nr;
5369 f_sleep(1.0);
5370
5371 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
5372 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
5373 activate(as_Media());
5374
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005375 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005376 f_gen_handover_req()));
Harald Welte6811d102019-04-14 22:23:14 +02005377 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005378
5379 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
5380
5381 var PDU_BSSAP rx_bssap;
5382 var octetstring ho_command_str;
5383
5384 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
5385
5386 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
5387 log("Received L3 Info in HO Request Ack: ", ho_command_str);
5388 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
5389 log("L3 Info in HO Request Ack is ", ho_command);
5390
5391 var GsmArfcn arfcn;
5392 var RslChannelNr actual_new_chan_nr;
5393 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
5394 actual_new_chan_nr, arfcn);
5395
5396 if (actual_new_chan_nr != new_chan_nr) {
5397 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
5398 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
5399 setverdict(fail);
5400 return;
5401 }
5402 log("Handover Command chan_nr is", actual_new_chan_nr);
5403
5404 /* Now the MSC forwards the RR Handover Command to the other BSC, which
5405 * tells the MS to handover to the new lchan. But the MS never shows up
5406 * on the new lchan. */
5407
5408 BSSAP.receive(tr_BSSMAP_HandoverFailure);
5409
5410 /* MSC plays dumb and sends no Clear Command */
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005411 var PDU_BSSAP rx_clear_request;
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02005412
5413 BSSAP.receive(tr_BSSMAP_ClearRequest) -> value rx_clear_request {
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005414 var BssmapCause cause := bit2int(rx_clear_request.pdu.bssmap.clearRequest.cause.causeValue);
5415 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
5416 };
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02005417 f_expect_dlcx_conns();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005418 f_sleep(1.0);
5419}
5420testcase TC_ho_in_fail_no_detect2() runs on test_CT {
5421 var MSC_ConnHdlr vc_conn;
5422 var TestHdlrParams pars := f_gen_test_hdlr_pars();
5423
5424 f_init(1, true);
5425 f_sleep(1.0);
5426
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005427 f_ctrs_bsc_and_bts_init();
5428
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005429 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
5430 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005431
5432 vc_conn := f_start_handler(refers(f_tc_ho_in_fail_no_detect2), pars);
5433 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005434
5435 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5436 f_ctrs_bsc_and_bts_add(0, "handover:error");
5437 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:attempted");
5438 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:error");
5439 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005440 f_shutdown_helper();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005441}
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005442
Neels Hofmeyr91401012019-07-11 00:42:35 +02005443type record of charstring Commands;
5444
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005445private function f_bts_0_cfg(TELNETasp_PT pt, Commands cmds := {})
Neels Hofmeyr91401012019-07-11 00:42:35 +02005446{
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005447 f_vty_enter_cfg_bts(pt, 0);
Neels Hofmeyr91401012019-07-11 00:42:35 +02005448 for (var integer i := 0; i < sizeof(cmds); i := i+1) {
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005449 f_vty_transceive(pt, cmds[i]);
Neels Hofmeyr91401012019-07-11 00:42:35 +02005450 }
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005451 f_vty_transceive(pt, "end");
Neels Hofmeyr91401012019-07-11 00:42:35 +02005452}
5453
Pau Espin Pedrolc675b612020-01-09 19:55:40 +01005454private function f_cs7_inst_0_cfg(TELNETasp_PT pt, Commands cmds := {})
5455{
5456 f_vty_enter_cfg_cs7_inst(pt, 0);
5457 for (var integer i := 0; i < sizeof(cmds); i := i+1) {
5458 f_vty_transceive(pt, cmds[i]);
5459 }
5460 f_vty_transceive(pt, "end");
5461}
5462
Neels Hofmeyr91401012019-07-11 00:42:35 +02005463private function f_probe_for_handover(charstring log_label,
5464 charstring log_descr,
5465 charstring handover_vty_cmd,
5466 boolean expect_handover,
5467 boolean is_inter_bsc_handover := false)
5468runs on MSC_ConnHdlr
5469{
Neels Hofmeyrb3fc8982020-05-11 00:16:42 +02005470 /* We're going to thwart any and all handover attempts, just be ready to handle (and ignore) handover target
5471 * lchans to be established on bts 1 or bts 2. */
5472 f_rslem_suspend(RSL1_PROC);
5473 f_rslem_suspend(RSL2_PROC);
5474
Neels Hofmeyr91401012019-07-11 00:42:35 +02005475 var RSL_Message rsl;
5476
5477 var charstring log_msg := " (expecting handover)"
5478 if (not expect_handover) {
5479 log_msg := " (expecting NO handover)";
5480 }
5481 log("f_probe_for_handover starting: " & log_label & ": " & log_descr & log_msg);
5482 f_vty_transceive(BSCVTY, handover_vty_cmd);
5483
Neels Hofmeyr91401012019-07-11 00:42:35 +02005484 timer T := 2.0;
5485 T.start;
5486
5487 alt {
5488 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr)) -> value rsl {
5489 var PDU_ML3_NW_MS l3 := dec_PDU_ML3_NW_MS(rsl.ies[2].body.l3_info.payload);
5490 log("Rx L3 from net: ", l3);
5491 if (ischosen(l3.msgs.rrm.handoverCommand)) {
5492 var RslChannelNr new_chan_nr;
5493 var GsmArfcn arfcn;
5494 f_ChDesc2RslChanNr(l3.msgs.rrm.handoverCommand.channelDescription2,
5495 new_chan_nr, arfcn);
5496 log("Handover to new chan ", new_chan_nr, " on ARFCN ", arfcn);
5497 log(l3.msgs.rrm.handoverCommand);
5498
5499 /* Need to register for new lchan on new BTS -- it's either bts 1 or bts 2. It doesn't really
5500 * matter on which BTS it really is, we're not going to follow through an entire handover
5501 * anyway. */
5502 f_rslem_register(0, new_chan_nr, RSL1_PROC);
5503 f_rslem_resume(RSL1_PROC);
5504 f_rslem_register(0, new_chan_nr, RSL2_PROC);
5505 f_rslem_resume(RSL2_PROC);
5506
5507 if (expect_handover and not is_inter_bsc_handover) {
5508 setverdict(pass);
5509 log("f_probe_for_handover(" & log_label & "): Got RSL Handover Command as expected.");
5510 } else {
5511 setverdict(fail, "f_probe_for_handover(" & log_label & "): Expected none, but got RSL Handover Command. "
5512 & log_label & ": " & log_descr);
5513 }
5514
5515 log("f_probe_for_handover(" & log_label & "): Ending the test: Handover Failure stops the procedure.");
5516 /* osmo-bsc has triggered Handover. That's all we need to know for this test, reply with
5517 * Handover Failure. */
5518 f_rsl_send_l3(ts_RRM_HandoverFailure('00'O));
5519
5520 /* target BTS is told to release lchan again; don't care which BTS nor what messages. */
5521 f_sleep(0.5);
5522 RSL1.clear;
5523 RSL2.clear;
5524 log("f_probe_for_handover(" & log_label & "): done (got RSL Handover Command)");
5525 break;
5526 } else {
5527 repeat;
5528 }
5529 }
5530 [] BSSAP.receive(tr_BSSMAP_HandoverRequired) {
5531 if (expect_handover and is_inter_bsc_handover) {
5532 setverdict(pass);
5533 log("f_probe_for_handover(" & log_label & "): Got BSSMAP Handover Required as expected.");
5534 } else {
5535 setverdict(fail, "f_probe_for_handover(" & log_label & "): Expected none, but got BSSMAP Handover Required. "
5536 & log_label & ": " & log_descr);
5537 }
5538
5539 log("f_probe_for_handover(" & log_label & "): done (got BSSMAP Handover Required)");
5540
5541 /* Note: f_tc_ho_neighbor_config_start() sets T7, the timeout for BSSMAP Handover Required, to
5542 * 1 second. There is no legal way to quickly abort a handover after a BSSMAP Handover Required,
5543 * setting a short timeout and waiting is the only way. */
5544 log("f_probe_for_handover(" & log_label & "): waiting for inter-BSC HO to time out...");
5545 f_sleep(1.5);
5546 log("f_probe_for_handover(" & log_label & "): ...done");
5547
5548 break;
5549 }
5550 [] T.timeout {
5551 if (expect_handover) {
5552 setverdict(fail, "f_probe_for_handover(" & log_label & "): Expected Handover, but got none. "
5553 & log_label & ": " & log_descr);
5554 } else {
5555 setverdict(pass);
5556 log("f_probe_for_handover(" & log_label & "): Got no Handover, as expected.");
5557 }
5558 log("f_probe_for_handover(" & log_label & "): done (got no Handover)");
5559 break;
5560 }
5561 }
5562
5563 f_rslem_resume(RSL1_PROC);
5564 f_rslem_resume(RSL2_PROC);
5565 f_sleep(3.0);
5566 RSL.clear;
5567
5568 log("f_probe_for_handover(" & log_label & "): done clearing");
5569}
5570
5571/* Test the effect of various neighbor configuration scenarios:
5572 *
5573 * To avoid complexity, block off any actual handover operation, and always remain on the lchan at bts 0.
5574 * Reconfigure the neighbors for bts 0, trigger a Handover, and probe whether osmo-bsc does or doesn't start HO.
5575 */
5576private function f_tc_ho_neighbor_config_start() runs on MSC_ConnHdlr {
5577 g_pars := f_gen_test_hdlr_pars();
5578 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
5579 var PDU_BSSAP ass_cmd := f_gen_ass_req();
5580 const OCT8 kc := '0001020304050607'O;
5581
5582 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
5583 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
5584
5585 /* Establish lchan at bts 0 */
5586 f_establish_fully(ass_cmd, exp_compl);
5587
5588 /* Shorten the inter-BSC Handover timeout, to not wait so long for inter-BSC Handovers */
5589 f_vty_enter_cfg_network(BSCVTY);
5590 f_vty_transceive(BSCVTY, "timer T7 1");
5591 f_vty_transceive(BSCVTY, "end");
5592}
5593
5594private function f_tc_ho_neighbor_config_1(charstring id) runs on MSC_ConnHdlr {
5595 f_tc_ho_neighbor_config_start();
5596
5597 /*
5598 * bts 0 ARFCN 871 BSIC 10
5599 * bts 1 ARFCN 871 BSIC 11
5600 * bts 2 ARFCN 871 BSIC 12
5601 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
5602 */
5603
5604 log("f_tc_ho_neighbor_config: 1. No 'neighbor' config");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005605 f_bts_0_cfg(BSCVTY, {"no neighbors"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02005606 f_probe_for_handover("1.a", "HO to bts 1 works, implicitly listed as neighbor (legacy behavior when none are configured)",
5607 "handover any to arfcn 871 bsic 11",
5608 true);
5609
5610 f_probe_for_handover("1.b", "HO to unknown cell does not start",
5611 "handover any to arfcn 13 bsic 39",
5612 false);
5613
5614 f_probe_for_handover("1.c", "HO to 871-12 is ambiguous = error",
5615 "handover any to arfcn 871 bsic 12",
5616 false);
5617
5618 f_probe_for_handover("1.d", "HO to 871-11 still works (verify that this test properly cleans up)",
5619 "handover any to arfcn 871 bsic 11",
5620 true);
5621}
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005622testcase TC_ho_neighbor_config_1() runs on test_CT {
5623 var MSC_ConnHdlr vc_conn;
5624 f_init(3, true, guard_timeout := 60.0);
5625 f_sleep(1.0);
5626 f_ctrs_bsc_and_bts_init();
5627 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_1));
5628 vc_conn.done;
5629
5630 /* f_tc_ho_neighbor_config_start() */
5631 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5632 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5633
5634 /* 1.a */
5635 /* "failed" means a handover was triggered and started (which is all this test aims for) and the test ended the
5636 * handover quickly by sending a Handover Failure message. */
5637 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5638 f_ctrs_bsc_and_bts_add(0, "handover:failed");
5639 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
5640 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:failed");
5641
5642 /* 1.b */
5643 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5644 f_ctrs_bsc_and_bts_add(0, "handover:error");
5645
5646 /* 1.c */
5647 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5648 f_ctrs_bsc_and_bts_add(0, "handover:error");
5649
5650 /* 1.d */
5651 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5652 f_ctrs_bsc_and_bts_add(0, "handover:failed");
5653 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
5654 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:failed");
5655
5656 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005657 f_shutdown_helper();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005658}
5659
Neels Hofmeyr91401012019-07-11 00:42:35 +02005660private function f_tc_ho_neighbor_config_2(charstring id) runs on MSC_ConnHdlr {
5661 f_tc_ho_neighbor_config_start();
5662
5663 /*
5664 * bts 0 ARFCN 871 BSIC 10
5665 * bts 1 ARFCN 871 BSIC 11
5666 * bts 2 ARFCN 871 BSIC 12
5667 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
5668 */
5669
5670 log("f_tc_ho_neighbor_config: 2. explicit local neighbor: 'neighbor bts 1'");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005671 f_bts_0_cfg(BSCVTY, {"neighbor bts 1"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02005672 f_sleep(0.5);
5673
5674 f_probe_for_handover("2.a", "HO to bts 1 works, explicitly listed as neighbor",
5675 "handover any to arfcn 871 bsic 11",
5676 true);
5677
5678 f_probe_for_handover("2.b", "HO to bts 2 doesn't work, not listed as neighbor",
5679 "handover any to arfcn 871 bsic 12",
5680 false);
5681}
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005682testcase TC_ho_neighbor_config_2() runs on test_CT {
5683 var MSC_ConnHdlr vc_conn;
5684 f_init(3, true, guard_timeout := 50.0);
5685 f_sleep(1.0);
5686 f_ctrs_bsc_and_bts_init();
5687 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_2));
5688 vc_conn.done;
5689
5690 /* f_tc_ho_neighbor_config_start() */
5691 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5692 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5693
5694 /* 2.a */
5695 /* "failed" means a handover was triggered and started (which is all this test aims for) and the test ended the
5696 * handover quickly by sending a Handover Failure message. */
5697 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5698 f_ctrs_bsc_and_bts_add(0, "handover:failed");
5699 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
5700 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:failed");
5701
5702 /* 2.b */
5703 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5704 f_ctrs_bsc_and_bts_add(0, "handover:error");
5705
5706 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005707 f_shutdown_helper();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005708}
5709
Neels Hofmeyr91401012019-07-11 00:42:35 +02005710private function f_tc_ho_neighbor_config_3(charstring id) runs on MSC_ConnHdlr {
5711 f_tc_ho_neighbor_config_start();
5712
5713 /*
5714 * bts 0 ARFCN 871 BSIC 10
5715 * bts 1 ARFCN 871 BSIC 11
5716 * bts 2 ARFCN 871 BSIC 12
5717 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
5718 */
5719
5720 log("f_tc_ho_neighbor_config: 3. explicit local neighbor: 'neighbor bts 2'");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005721 f_bts_0_cfg(BSCVTY, {"no neighbors", "neighbor bts 2"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02005722 f_sleep(0.5);
5723
5724 f_probe_for_handover("3.a", "HO to bts 1 doesn't work, not listed as neighbor",
5725 "handover any to arfcn 871 bsic 11",
5726 false);
5727 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",
5728 "handover any to arfcn 871 bsic 12",
5729 true);
5730}
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005731testcase TC_ho_neighbor_config_3() runs on test_CT {
5732 var MSC_ConnHdlr vc_conn;
5733 f_init(3, true, guard_timeout := 50.0);
5734 f_sleep(1.0);
5735 f_ctrs_bsc_and_bts_init();
5736 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_3));
5737 vc_conn.done;
5738
5739 /* f_tc_ho_neighbor_config_start() */
5740 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5741 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5742
5743 /* 3.a */
5744 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5745 f_ctrs_bsc_and_bts_add(0, "handover:error");
5746
5747 /* 3.b */
5748 /* "failed" means a handover was triggered and started (which is all this test aims for) and the test ended the
5749 * handover quickly by sending a Handover Failure message. */
5750 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5751 f_ctrs_bsc_and_bts_add(0, "handover:failed");
5752 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
5753 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:failed");
5754
5755 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005756 f_shutdown_helper();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005757}
5758
Neels Hofmeyr91401012019-07-11 00:42:35 +02005759private function f_tc_ho_neighbor_config_4(charstring id) runs on MSC_ConnHdlr {
5760 f_tc_ho_neighbor_config_start();
5761
5762 /*
5763 * bts 0 ARFCN 871 BSIC 10
5764 * bts 1 ARFCN 871 BSIC 11
5765 * bts 2 ARFCN 871 BSIC 12
5766 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
5767 */
5768
5769 log("f_tc_ho_neighbor_config: 4. explicit remote neighbor: 'neighbor lac 99 arfcn 123 bsic 45'");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005770 f_bts_0_cfg(BSCVTY, {"no neighbors", "neighbor lac 99 arfcn 123 bsic 45"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02005771 f_sleep(0.5);
5772
5773 f_probe_for_handover("4.a", "HO to bts 1 doesn't work, not listed as neighbor",
5774 "handover any to arfcn 871 bsic 11",
5775 false);
5776 f_probe_for_handover("4.b", "HO to bts 2 doesn't work, not listed as neighbor",
5777 "handover any to arfcn 871 bsic 12",
5778 false);
5779 f_probe_for_handover("4.c", "HO to 123-45 triggers inter-BSC HO",
5780 "handover any to arfcn 123 bsic 45",
5781 true, true);
5782}
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005783testcase TC_ho_neighbor_config_4() runs on test_CT {
5784 var MSC_ConnHdlr vc_conn;
5785 f_init(3, true, guard_timeout := 50.0);
5786 f_sleep(1.0);
5787 f_ctrs_bsc_and_bts_init();
5788 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_4));
5789 vc_conn.done;
5790
5791 /* f_tc_ho_neighbor_config_start() */
5792 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5793 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5794
5795 /* 4.a */
5796 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5797 f_ctrs_bsc_and_bts_add(0, "handover:error");
5798
5799 /* 4.b */
5800 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5801 f_ctrs_bsc_and_bts_add(0, "handover:error");
5802
5803 /* 4.c */
5804 /* "timeout" means a handover was triggered and started (which is all this test aims for) and the test ended the
5805 * handover quickly by timing out after the Handover Required message */
5806 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5807 f_ctrs_bsc_and_bts_add(0, "handover:timeout");
5808 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
5809 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:timeout");
5810
5811 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005812 f_shutdown_helper();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005813}
5814
Neels Hofmeyr91401012019-07-11 00:42:35 +02005815private function f_tc_ho_neighbor_config_5(charstring id) runs on MSC_ConnHdlr {
5816 f_tc_ho_neighbor_config_start();
5817
5818 /*
5819 * bts 0 ARFCN 871 BSIC 10
5820 * bts 1 ARFCN 871 BSIC 11
5821 * bts 2 ARFCN 871 BSIC 12
5822 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
5823 */
5824
5825 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 +02005826 f_bts_0_cfg(BSCVTY, {"no neighbors", "neighbor lac 99 arfcn 871 bsic 12"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02005827 f_sleep(0.5);
5828
5829 f_probe_for_handover("5.a", "HO to 871-12 triggers inter-BSC HO (ignoring local cells with same ARFCN+BSIC)",
5830 "handover any to arfcn 871 bsic 12",
5831 true, true);
5832}
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005833testcase TC_ho_neighbor_config_5() runs on test_CT {
5834 var MSC_ConnHdlr vc_conn;
5835 f_init(3, true);
5836 f_sleep(1.0);
5837 f_ctrs_bsc_and_bts_init();
5838 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_5));
5839 vc_conn.done;
5840
5841 /* f_tc_ho_neighbor_config_start() */
5842 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5843 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5844
5845 /* 5 */
5846 /* "timeout" means a handover was triggered and started (which is all this test aims for) and the test ended the
5847 * handover quickly by timing out after the Handover Required message */
5848 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5849 f_ctrs_bsc_and_bts_add(0, "handover:timeout");
5850 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
5851 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:timeout");
5852
5853 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005854 f_shutdown_helper();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005855}
5856
Neels Hofmeyr91401012019-07-11 00:42:35 +02005857private function f_tc_ho_neighbor_config_6(charstring id) runs on MSC_ConnHdlr {
5858 f_tc_ho_neighbor_config_start();
5859
5860 /*
5861 * bts 0 ARFCN 871 BSIC 10
5862 * bts 1 ARFCN 871 BSIC 11
5863 * bts 2 ARFCN 871 BSIC 12
5864 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
5865 */
5866
5867 log("f_tc_ho_neighbor_config: 6. config error: explicit local and remote neighbors with ambiguous ARFCN+BSIC:"
5868 & " 'neighbor bts 2; neighbor lac 99 arfcn 871 bsic 12'");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005869 f_bts_0_cfg(BSCVTY, {"no neighbors", "neighbor bts 2", "neighbor lac 99 arfcn 871 bsic 12"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02005870 f_sleep(0.5);
5871
5872 f_probe_for_handover("6.a", "HO to 871-12 is ambiguous = error",
5873 "handover any to arfcn 871 bsic 12",
5874 false);
5875}
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005876testcase TC_ho_neighbor_config_6() runs on test_CT {
5877 var MSC_ConnHdlr vc_conn;
5878 f_init(3, true);
5879 f_sleep(1.0);
5880 f_ctrs_bsc_and_bts_init();
5881 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_6));
5882 vc_conn.done;
5883
5884 /* f_tc_ho_neighbor_config_start() */
5885 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5886 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5887
5888 /* 6.a */
5889 /* "timeout" means a handover was triggered and started (which is all this test aims for) and the test ended the
5890 * handover quickly by timing out after the Handover Required message */
5891 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5892 f_ctrs_bsc_and_bts_add(0, "handover:error");
5893
5894 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005895 f_shutdown_helper();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005896}
5897
Neels Hofmeyr91401012019-07-11 00:42:35 +02005898private function f_tc_ho_neighbor_config_7(charstring id) runs on MSC_ConnHdlr {
5899 f_tc_ho_neighbor_config_start();
5900
5901 /*
5902 * bts 0 ARFCN 871 BSIC 10
5903 * bts 1 ARFCN 871 BSIC 11
5904 * bts 2 ARFCN 871 BSIC 12
5905 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
5906 */
5907
5908 log("f_tc_ho_neighbor_config: 7. explicit local and remote neighbors:"
5909 & " 'neighbor bts 2; neighbor lac 99 arfcn 123 bsic 45'");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005910 f_bts_0_cfg(BSCVTY, {"no neighbors", "neighbor bts 2", "neighbor lac 99 arfcn 123 bsic 45"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02005911 f_sleep(0.5);
5912
5913 f_probe_for_handover("7.a", "HO to 871-12 does HO to bts 2",
5914 "handover any to arfcn 871 bsic 12",
5915 true);
5916 f_probe_for_handover("7.b", "HO to 123-45 triggers inter-BSC HO",
5917 "handover any to arfcn 123 bsic 45",
5918 true, true);
5919}
Neels Hofmeyr91401012019-07-11 00:42:35 +02005920testcase TC_ho_neighbor_config_7() runs on test_CT {
5921 var MSC_ConnHdlr vc_conn;
Neels Hofmeyrf2b88032020-06-16 00:35:04 +02005922 f_init(3, true, guard_timeout := 50.0);
Neels Hofmeyr91401012019-07-11 00:42:35 +02005923 f_sleep(1.0);
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005924 f_ctrs_bsc_and_bts_init();
Neels Hofmeyr91401012019-07-11 00:42:35 +02005925 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_7));
5926 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005927
5928 /* f_tc_ho_neighbor_config_start() */
5929 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5930 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5931
5932 /* 7.a */
5933 /* "failed" means a handover was triggered and started (which is all this test aims for) and the test ended the
5934 * handover quickly by sending a Handover Failure message. */
5935 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5936 f_ctrs_bsc_and_bts_add(0, "handover:failed");
5937 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
5938 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:failed");
5939
5940 /* 7.b */
5941 /* "timeout" means a handover was triggered and started (which is all this test aims for) and the test ended the
5942 * handover quickly by timing out after the Handover Required message */
5943 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5944 f_ctrs_bsc_and_bts_add(0, "handover:timeout");
5945 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
5946 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:timeout");
5947
5948 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005949 f_shutdown_helper();
Neels Hofmeyr91401012019-07-11 00:42:35 +02005950}
5951
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01005952/* OS#3041: Open and close N connections in a normal fashion, and expect no
5953 * BSSMAP Reset just because of that. */
5954testcase TC_bssap_rlsd_does_not_cause_bssmap_reset() runs on test_CT {
5955 var default d;
5956 var integer i;
5957 var DchanTuple dt;
5958
5959 f_init();
5960
5961 /* Wait for initial BSSMAP Reset to pass */
5962 f_sleep(4.0);
5963
5964 d := activate(no_bssmap_reset());
5965
5966 /* Setup up a number of connections and RLSD them again from the MSC
5967 * side. In the buggy behavior, the fourth one triggers BSSMAP Reset.
5968 * Let's do it some more times for good measure. */
Harald Weltec3260d92018-06-11 17:48:16 +02005969 for (i := 0; i < 4; i := i+1) {
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01005970 /* Since we're doing a lot of runs, give each one a fresh
5971 * T_guard from the top. */
5972 T_guard.start;
5973
5974 /* Setup a BSSAP connection and clear it right away. This is
5975 * the MSC telling the BSC about a planned release, it's not an
5976 * erratic loss of a connection. */
Harald Weltea1897182018-06-11 13:53:09 +02005977 dt := f_est_dchan(int2oct(i,1), 23+i, '00010203040506'O);
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01005978
5979 /* MSC disconnects (RLSD). */
5980 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
5981 }
5982
5983 /* In the buggy behavior, a timeout of 2 seconds happens between above
5984 * trigger (logs "SIGTRAN connection down, reconnecting...") and the
5985 * actual BSSMAP Reset. Wait a bit longer just to make sure. */
5986 f_sleep(4.0);
5987
5988 deactivate(d);
5989 f_shutdown_helper();
5990}
Harald Welte552620d2017-12-16 23:21:36 +01005991
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01005992/* OS#3041: Open and close N connections in a normal fashion, and expect no
5993 * BSSMAP Reset just because of that. Invoke the release by a BSSMAP Clear from
5994 * the MSC. */
5995testcase TC_bssmap_clear_does_not_cause_bssmap_reset() runs on test_CT {
5996 var default d;
5997 var integer i;
5998 var DchanTuple dt;
5999 var BSSAP_N_DATA_ind rx_di;
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01006000 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_CALL_CONTROL;
6001 var BssmapCause cause := enum2int(cause_val);
6002
6003 f_init();
6004
6005 /* Wait for initial BSSMAP Reset to pass */
6006 f_sleep(4.0);
6007
6008 d := activate(no_bssmap_reset());
6009
6010 /* Setup up a number of connections and RLSD them again from the MSC
6011 * side. In the buggy behavior, the fourth one triggers BSSMAP Reset.
6012 * Let's do it some more times for good measure. */
6013 for (i := 0; i < 8; i := i+1) {
6014 /* Since we're doing a lot of runs, give each one a fresh
6015 * T_guard from the top. */
6016 T_guard.start;
6017
6018 /* Setup a BSSAP connection and clear it right away. This is
6019 * the MSC telling the BSC about a planned release, it's not an
6020 * erratic loss of a connection. */
Harald Weltea1897182018-06-11 13:53:09 +02006021 dt := f_est_dchan(int2oct(i,1), 23+i, '00010203040506'O);
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01006022
6023 /* Instruct BSC to clear channel */
6024 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
6025
6026 /* expect BSC to disable the channel */
Harald Welte641fcbe2018-06-14 10:58:35 +02006027 f_exp_chan_rel_and_clear(dt, 0);
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01006028 }
6029
6030 /* In the buggy behavior, a timeout of 2 seconds happens between above
6031 * trigger (logs "SIGTRAN connection down, reconnecting...") and the
6032 * actual BSSMAP Reset. Wait a bit longer just to make sure. */
6033 f_sleep(4.0);
6034
6035 deactivate(d);
6036 f_shutdown_helper();
6037}
6038
Neels Hofmeyrfd445c32018-03-09 15:39:31 +01006039/* OS#3041: Open and close N connections in a normal fashion, and expect no
6040 * BSSMAP Reset just because of that. Close connections from the MS side with a
6041 * Release Ind on RSL. */
6042testcase TC_ms_rel_ind_does_not_cause_bssmap_reset() runs on test_CT {
6043 var default d;
6044 var integer i;
6045 var DchanTuple dt;
6046 var BSSAP_N_DATA_ind rx_di;
Neels Hofmeyrfd445c32018-03-09 15:39:31 +01006047 var integer j;
6048
6049 f_init();
6050
6051 /* Wait for initial BSSMAP Reset to pass */
6052 f_sleep(4.0);
6053
6054 d := activate(no_bssmap_reset());
6055
6056 /* Setup up a number of connections and RLSD them again from the MSC
6057 * side. In the buggy behavior, the fourth one triggers BSSMAP Reset.
6058 * Let's do it some more times for good measure. */
6059 for (i := 0; i < 8; i := i+1) {
6060 /* Since we're doing a lot of runs, give each one a fresh
6061 * T_guard from the top. */
6062 T_guard.start;
6063
6064 /* Setup a BSSAP connection and clear it right away. This is
6065 * the MSC telling the BSC about a planned release, it's not an
6066 * erratic loss of a connection. */
6067 dt := f_est_dchan('23'O, 23, '00010203040506'O);
6068
6069 /* simulate RLL REL IND */
6070 f_ipa_tx(0, ts_RSL_REL_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0))));
6071
6072 /* expect Clear Request on MSC side */
6073 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearRequest)) -> value rx_di;
6074
6075 /* Instruct BSC to clear channel */
6076 var BssmapCause cause := bit2int(rx_di.userData.pdu.bssmap.clearRequest.cause.causeValue);
6077 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
6078
6079 /* expect BSC to disable the channel */
Harald Welte641fcbe2018-06-14 10:58:35 +02006080 f_exp_chan_rel_and_clear(dt, 0);
Neels Hofmeyrfd445c32018-03-09 15:39:31 +01006081 }
6082
6083 /* In the buggy behavior, a timeout of 2 seconds happens between above
6084 * trigger (logs "SIGTRAN connection down, reconnecting...") and the
6085 * actual BSSMAP Reset. Wait a bit longer just to make sure. */
6086 f_sleep(4.0);
6087
6088 deactivate(d);
6089 f_shutdown_helper();
6090}
6091
Harald Welte94e0c342018-04-07 11:33:23 +02006092/***********************************************************************
6093 * IPA style dynamic PDCH
6094 ***********************************************************************/
6095
6096private function f_dyn_ipa_pdch_act(integer bts_nr, integer trx_nr, integer ts_nr,
6097 template (omit) RSL_Cause nack := omit)
6098runs on test_CT {
6099 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(ts_nr));
6100 var RSL_Message rsl_unused;
6101 /* ask BSC via VTY to activate a given IPA style chan as PDCH */
6102 f_vty_ts_action("pdch activate", bts_nr, trx_nr, ts_nr);
6103 /* expect the BSC to issue the related RSL command */
6104 rsl_unused := f_exp_ipa_rx(0, tr_RSL_IPA_PDCH_ACT(chan_nr));
6105 if (istemplatekind(nack, "omit")) {
6106 /* respond with a related acknowledgement */
6107 f_ipa_tx(0, ts_RSL_IPA_PDCH_ACT_ACK(chan_nr, ts_RSL_IE_FrameNumber(2342)));
6108 } else {
6109 f_ipa_tx(0, ts_RSL_IPA_PDCH_ACT_NACK(chan_nr, valueof(nack)));
6110 }
6111}
6112
6113private function f_dyn_ipa_pdch_deact(integer bts_nr, integer trx_nr, integer ts_nr,
6114 template (omit) RSL_Cause nack := omit)
6115runs on test_CT {
6116 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(ts_nr));
6117 var RSL_Message rsl_unused;
6118 /* ask BSC via VTY to activate a given IPA style chan as PDCH */
6119 f_vty_ts_action("pdch deactivate", bts_nr, trx_nr, ts_nr);
6120 /* expect the BSC to issue the related RSL command */
6121 rsl_unused := f_exp_ipa_rx(0, tr_RSL_IPA_PDCH_DEACT(chan_nr));
6122 if (istemplatekind(nack, "omit")) {
6123 /* respond with a related acknowledgement */
6124 f_ipa_tx(0, ts_RSL_IPA_PDCH_DEACT_ACK(chan_nr));
6125 } else {
6126 f_ipa_tx(0, ts_RSL_IPA_PDCH_DEACT_NACK(chan_nr, valueof(nack)));
6127 }
6128}
6129
6130private function f_ts_dyn_mode_get(integer bts_nr, integer trx_nr, integer ts_nr)
6131runs on test_CT return charstring {
6132 var charstring cmd, resp;
6133 cmd := "show timeslot "&int2str(bts_nr)&" "&int2str(trx_nr)&" "&int2str(ts_nr);
Stefan Sperlingcff13562018-11-13 15:24:06 +01006134 return f_vty_transceive_match_regexp_retry(BSCVTY, cmd, "*\((*)\)*", 0, 4, 1.0);
Harald Welte94e0c342018-04-07 11:33:23 +02006135}
6136
6137private function f_ts_dyn_mode_assert(integer bts_nr, integer trx_nr, integer ts_nr,
6138 template charstring exp)
6139runs on test_CT {
6140 var charstring mode := f_ts_dyn_mode_get(bts_nr, trx_nr, ts_nr);
6141 if (not match(mode, exp)) {
6142 setverdict(fail, "Unexpected TS Mode: ", mode);
Daniel Willmannafce8662018-07-06 23:11:32 +02006143 mtc.stop;
Harald Welte94e0c342018-04-07 11:33:23 +02006144 }
6145}
6146
6147private function f_ts_set_chcomb(integer bts_nr, integer trx_nr, integer ts_nr, charstring chcomb)
6148runs on test_CT {
6149 f_vty_enter_cfg_ts(BSCVTY, bts_nr, trx_nr, ts_nr);
6150 f_vty_transceive(BSCVTY, "phys_chan_config " & chcomb);
6151 f_vty_transceive(BSCVTY, "end");
6152}
6153
6154private const charstring TCHF_MODE := "TCH/F mode";
6155private const charstring TCHH_MODE := "TCH/H mode";
6156private const charstring PDCH_MODE := "PDCH mode";
6157private const charstring NONE_MODE := "NONE mode";
6158
6159/* Test IPA PDCH activation / deactivation triggered by VTY */
6160testcase TC_dyn_pdch_ipa_act_deact() runs on test_CT {
6161 var RSL_Message rsl_unused;
6162
6163 /* change Timeslot 6 before f_init() starts RSL */
6164 f_init_vty();
6165 f_ts_set_chcomb(0, 0, 6, "TCH/F_PDCH");
6166 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
6167
6168 f_init(1, false);
6169 f_sleep(1.0);
6170
6171 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(6));
6172
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02006173 log("TCH/F_PDCH pchan starts out in TCH/F mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02006174 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
6175 /* The BSC will activate the dynamic PDCH by default, so confirm that */
6176 rsl_unused := f_exp_ipa_rx(0, tr_RSL_IPA_PDCH_ACT(chan_nr));
6177 f_ipa_tx(0, ts_RSL_IPA_PDCH_ACT_ACK(chan_nr, ts_RSL_IE_FrameNumber(2342)));
6178 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02006179 log("TCH/F_PDCH pchan, PDCH ACT was ACKed, so now in PDCH mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02006180 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, PDCH_MODE);
6181
6182 /* De-activate it via VTY */
6183 f_dyn_ipa_pdch_deact(0, 0, chan_nr.tn);
6184 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02006185 log("TCH/F_PDCH pchan, PDCH DEACT via VTY, so now back in TCH/F mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02006186 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
6187
6188 /* re-activate it via VTY */
6189 f_dyn_ipa_pdch_act(0, 0, chan_nr.tn);
6190 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02006191 log("TCH/F_PDCH pchan, PDCH ACT via VTY, so now in PDCH mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02006192 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, PDCH_MODE);
6193
6194 /* and finally de-activate it again */
6195 f_dyn_ipa_pdch_deact(0, 0, chan_nr.tn);
6196 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02006197 log("TCH/F_PDCH pchan, PDCH DEACT via VTY, so now back in TCH/F mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02006198 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
6199
Neels Hofmeyr887e8f12018-06-27 01:01:55 +02006200 /* clean up config */
6201 f_ts_set_chcomb(0, 0, 6, "PDCH");
6202
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006203 f_shutdown_helper();
Harald Welte94e0c342018-04-07 11:33:23 +02006204}
6205
6206/* Test IPA PDCH activation NACK */
6207testcase TC_dyn_pdch_ipa_act_nack() runs on test_CT {
6208 var RSL_Message rsl_unused;
6209
6210 /* change Timeslot 6 before f_init() starts RSL */
6211 f_init_vty();
6212 f_ts_set_chcomb(0, 0, 6, "TCH/F_PDCH");
6213 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
6214
6215 f_init(1, false);
6216 f_sleep(1.0);
6217
6218 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(6));
6219
6220 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
6221 /* The BSC will activate the dynamic PDCH by default, so confirm that */
6222 rsl_unused := f_exp_ipa_rx(0, tr_RSL_IPA_PDCH_ACT(chan_nr));
6223 f_ipa_tx(0, ts_RSL_IPA_PDCH_ACT_ACK(chan_nr, ts_RSL_IE_FrameNumber(2342)));
6224 f_sleep(1.0);
6225 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, PDCH_MODE);
6226
6227 /* De-activate it via VTY */
6228 f_dyn_ipa_pdch_deact(0, 0, chan_nr.tn);
6229 f_sleep(1.0);
6230 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
6231
6232 /* re-activate it via VTY, but fail that; check BSC still assumes TCH/F mode */
6233 f_dyn_ipa_pdch_act(0, 0, chan_nr.tn, RSL_ERR_EQUIPMENT_FAIL);
6234 f_sleep(1.0);
6235 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
6236
Neels Hofmeyr887e8f12018-06-27 01:01:55 +02006237 /* clean up config */
6238 f_ts_set_chcomb(0, 0, 6, "PDCH");
6239
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006240 f_shutdown_helper();
Harald Welte94e0c342018-04-07 11:33:23 +02006241}
6242
6243
6244/***********************************************************************
6245 * Osmocom style dynamic PDCH
6246 ***********************************************************************/
6247
6248private function f_dyn_osmo_pdch_act(integer bts_nr, integer trx_nr, integer ts_nr,
6249 template (omit) RSL_Cause nack := omit)
6250runs on test_CT {
6251 var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(ts_nr));
6252 var RSL_Message rsl_unused;
6253 /* ask BSC via VTY to activate a given IPA style chan as PDCH */
6254 /* FIXME: no VTY command to activate Osmocom PDCH !! */
6255 /* expect the BSC to issue the related RSL command */
6256 rsl_unused := f_exp_ipa_rx(0, tr_RSL_CHAN_ACT(chan_nr, ?));
6257 if (istemplatekind(nack, "omit")) {
6258 /* respond with a related acknowledgement */
6259 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, 2342));
6260 } else {
6261 f_ipa_tx(0, ts_RSL_CHAN_ACT_NACK(chan_nr, valueof(nack)));
6262 }
6263}
6264
6265private function f_dyn_osmo_pdch_deact(integer bts_nr, integer trx_nr, integer ts_nr,
6266 template (omit) RSL_Cause nack := omit)
6267runs on test_CT {
6268 var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(ts_nr));
6269 var RSL_Message rsl_unused;
6270 /* ask BSC via VTY to activate a given IPA style chan as PDCH */
6271 /* FIXME: no VTY command to activate Osmocom PDCH !! */
6272 /* expect the BSC to issue the related RSL command */
6273 rsl_unused := f_exp_ipa_rx(0, tr_RSL_RF_CHAN_REL(chan_nr));
6274 if (istemplatekind(nack, "omit")) {
6275 /* respond with a related acknowledgement */
6276 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(chan_nr));
6277 } else {
6278 //f_ipa_tx(0, ts_RSL_RF_CHAN_REL_NACK(chan_nr, valueof(nack)));
6279 }
6280}
6281
6282/* Test Osmocom dyn PDCH activation / deactivation triggered by VTY */
6283testcase TC_dyn_pdch_osmo_act_deact() runs on test_CT {
6284 var RSL_Message rsl_unused;
6285
6286 /* change Timeslot 6 before f_init() starts RSL */
6287 f_init_vty();
6288 f_ts_set_chcomb(0, 0, 6, "TCH/F_TCH/H_PDCH");
6289 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
6290
6291 f_init(1, false);
6292 f_sleep(1.0);
6293
6294 var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(6));
6295
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02006296 log("TCH/F_TCH/H_PDCH pchan starts out in disabled mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02006297 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, NONE_MODE);
6298 /* The BSC will activate the dynamic PDCH by default, so confirm that */
6299 rsl_unused := f_exp_ipa_rx(0, tr_RSL_CHAN_ACT_PDCH(chan_nr, ?));
6300
6301 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, 2342));
6302 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02006303 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 +02006304 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, PDCH_MODE);
6305
Neels Hofmeyr887e8f12018-06-27 01:01:55 +02006306 /* clean up config */
6307 f_ts_set_chcomb(0, 0, 6, "PDCH");
6308
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006309 f_shutdown_helper();
Harald Welte94e0c342018-04-07 11:33:23 +02006310}
6311
6312/* Test Osmocom dyn PDCH activation NACK behavior */
6313testcase TC_dyn_pdch_osmo_act_nack() runs on test_CT {
6314 var RSL_Message rsl_unused;
6315
6316 /* change Timeslot 6 before f_init() starts RSL */
6317 f_init_vty();
6318 f_ts_set_chcomb(0, 0, 6, "TCH/F_TCH/H_PDCH");
6319 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
6320
6321 f_init(1, false);
6322 f_sleep(1.0);
6323
6324 var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(6));
6325
6326 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, NONE_MODE);
6327 /* The BSC will activate the dynamic PDCH by default, so confirm that */
6328 rsl_unused := f_exp_ipa_rx(0, tr_RSL_CHAN_ACT_PDCH(chan_nr, ?));
6329
6330 /* NACK this activation and expect the "show timeslot" mode still to be NONE */
6331 f_ipa_tx(0, ts_RSL_CHAN_ACT_NACK(chan_nr, RSL_ERR_EQUIPMENT_FAIL));
6332 f_sleep(1.0);
6333 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, NONE_MODE);
6334
Neels Hofmeyr887e8f12018-06-27 01:01:55 +02006335 /* clean up config */
6336 f_ts_set_chcomb(0, 0, 6, "PDCH");
6337
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006338 f_shutdown_helper();
Harald Welte94e0c342018-04-07 11:33:23 +02006339}
6340
Stefan Sperling0796a822018-10-05 13:01:39 +02006341testcase TC_chopped_ipa_ping() runs on test_CT {
Stefan Sperling554123f2018-10-09 14:12:30 +02006342 const Integers bsc_ipa_ports := {mp_bsc_rsl_port, mp_bsc_oml_port, mp_bsc_ctrl_port};
Stefan Sperling0796a822018-10-05 13:01:39 +02006343 for (var integer i := 0; i < lengthof(bsc_ipa_ports); i := i + 1) {
6344 IPA_Testing.f_run_TC_chopped_ipa_ping(mp_bsc_ip, bsc_ipa_ports[i], CONNECT_TO_SERVER);
6345 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006346 f_shutdown_helper();
Stefan Sperling0796a822018-10-05 13:01:39 +02006347}
6348
Stefan Sperlingaa1e60f2018-10-15 16:34:07 +02006349testcase TC_chopped_ipa_payload() runs on test_CT {
6350 const Integers bsc_ipa_ports := {mp_bsc_rsl_port, mp_bsc_oml_port
6351 /* TODO: mp_bsc_ctrl_port does not work yet */};
6352 for (var integer i := 0; i < lengthof(bsc_ipa_ports); i := i + 1) {
6353 IPA_Testing.f_run_TC_chopped_ipa_payload(mp_bsc_ip, bsc_ipa_ports[i], CONNECT_TO_SERVER);
6354 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006355 f_shutdown_helper();
Stefan Sperlingaa1e60f2018-10-15 16:34:07 +02006356}
6357
Pau Espin Pedrol8f773632019-11-05 11:46:53 +01006358/* Verify the BSC sends the MS Power Parameters IE during CHAN ACT to make sure
6359 the BTS does autonomous MS power control loop */
6360testcase TC_assignment_verify_ms_power_params_ie() runs on test_CT {
6361 var MSC_ConnHdlr vc_conn;
6362 var TestHdlrParams pars := f_gen_test_hdlr_pars();
6363 //pars.encr := valueof(t_EncrParams('01'O, f_rnd_octstring(8)));
6364 pars.exp_ms_power_params := true;
6365
6366 f_init(1, true);
6367 f_sleep(1.0);
6368 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5), pars);
6369 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006370 f_shutdown_helper();
Pau Espin Pedrol8f773632019-11-05 11:46:53 +01006371}
Stefan Sperlingaa1e60f2018-10-15 16:34:07 +02006372
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006373/***********************************************************************
6374 * MSC Pooling
6375 ***********************************************************************/
6376
6377function f_tmsi_nri(integer nri_v, octetstring base_tmsi := '42000023'O, integer nri_bitlen := 10) return octetstring
6378{
6379 return int2oct( oct2int(base_tmsi) + bit2int( (int2bit(nri_v, 32) << ( 24 - nri_bitlen)) ),
6380 4);
6381}
6382
6383template MobileIdentityLV ts_MI_TMSI_NRI_LV(integer nri_v, integer nri_bitlen := 10) :=
6384 ts_MI_TMSI_LV(tmsi := f_tmsi_nri(nri_v, nri_bitlen := nri_bitlen));
6385
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02006386private function f_expect_lchan_rel(RSL_DCHAN_PT rsl) runs on MSC_ConnHdlr {
6387 interleave {
6388 [] rsl.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_RELEASE)) {
6389 f_logp(BSCVTY, "Got RSL RR Release");
6390 }
6391 [] rsl.receive(tr_RSL_DEACT_SACCH(g_chan_nr)) {
6392 f_logp(BSCVTY, "Got RSL Deact SACCH");
6393 }
6394 [] rsl.receive(tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL)) {
6395 f_logp(BSCVTY, "Got RSL RF Chan Rel, sending Rel Ack");
6396 rsl.send(ts_RSL_RF_CHAN_REL_ACK(g_chan_nr));
6397 break;
6398 }
6399 }
6400}
6401
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006402private function f_perform_clear(RSL_DCHAN_PT rsl) runs on MSC_ConnHdlr {
Neels Hofmeyr767548a2020-08-09 20:26:07 +00006403 f_logp(BSCVTY, "MSC instructs BSC to clear channel");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006404 BSSAP.send(ts_BSSMAP_ClearCommand(0));
6405 interleave {
6406 [] rsl.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_RELEASE)) {
Neels Hofmeyr767548a2020-08-09 20:26:07 +00006407 f_logp(BSCVTY, "Got RSL RR Release");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006408 }
6409 [] rsl.receive(tr_RSL_DEACT_SACCH(g_chan_nr)) {
Neels Hofmeyr767548a2020-08-09 20:26:07 +00006410 f_logp(BSCVTY, "Got RSL Deact SACCH");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006411 }
6412 [] BSSAP.receive(tr_BSSMAP_ClearComplete) {
Neels Hofmeyr767548a2020-08-09 20:26:07 +00006413 f_logp(BSCVTY, "Got BSSMAP Clear Complete");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006414 /* Also drop the SCCP connection */
6415 BSSAP.send(RAN_Conn_Prim:MSC_CONN_PRIM_DISC_REQ);
6416 }
6417 [] rsl.receive(tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL)) {
Neels Hofmeyr767548a2020-08-09 20:26:07 +00006418 f_logp(BSCVTY, "Got RSL RF Chan Rel, sending Rel Ack");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006419 rsl.send(ts_RSL_RF_CHAN_REL_ACK(g_chan_nr));
6420 }
6421 }
6422}
6423
Neels Hofmeyr66e15092020-10-12 18:44:41 +00006424private 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 +02006425runs on MSC_ConnHdlr {
6426 timer T := 10.0;
6427 var octetstring l3_enc := enc_PDU_ML3_MS_NW(valueof(l3_info));
6428
Neels Hofmeyr767548a2020-08-09 20:26:07 +00006429 f_logp(BSCVTY, "establish channel, send Complete Layer 3 Info");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006430 f_create_bssmap_exp(l3_enc);
6431
6432 /* RSL_Emulation.f_chan_est() on rsl:
6433 * This is basically code dup with s/RSL/rsl from:
6434 * RSL_Emulation.f_chan_est(g_pars.ra, l3_enc, g_pars.link_id, g_pars.fn);
6435 */
6436 var RSL_Message rx_rsl;
6437 var GsmRrMessage rr;
6438
6439 /* request a channel to be established */
6440 rsl.send(ts_RSLDC_ChanRqd(g_pars.ra, g_pars.fn));
6441 /* expect immediate assignment.
6442 * Code dup with s/RSL/rsl from:
6443 * rx_rsl := f_rx_or_fail(tr_RSL_IMM_ASSIGN);
6444 */
6445 timer Tt := 10.0;
6446
6447 /* request a channel to be established */
6448 Tt.start;
6449 alt {
6450 [] rsl.receive(tr_RSL_IMM_ASSIGN) -> value rx_rsl {
6451 Tt.stop;
6452 }
6453 [] rsl.receive {
6454 setverdict(fail, "Unexpected RSL message on DCHAN");
6455 mtc.stop;
6456 }
6457 [] Tt.timeout {
6458 setverdict(fail, "Timeout waiting for RSL on DCHAN");
6459 mtc.stop;
6460 }
6461 }
6462 rr := dec_GsmRrMessage(rx_rsl.ies[1].body.full_imm_ass_info.payload);
6463 g_chan_nr := rr.payload.imm_ass.chan_desc.chan_nr;
6464 rsl.send(ts_RSL_EST_IND(g_chan_nr, valueof(g_pars.link_id), l3_enc));
6465
6466
Neels Hofmeyr66e15092020-10-12 18:44:41 +00006467 if (expect_bssmap_l3) {
6468 f_logp(BSCVTY, "expect BSSAP Complete Layer 3 Info at MSC");
6469 var template PDU_BSSAP exp_l3_compl;
6470 exp_l3_compl := tr_BSSMAP_ComplL3()
6471 if (g_pars.aoip == false) {
6472 exp_l3_compl.pdu.bssmap.completeLayer3Information.codecList := omit;
6473 } else {
6474 exp_l3_compl.pdu.bssmap.completeLayer3Information.codecList := ?;
6475 }
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006476
Neels Hofmeyr66e15092020-10-12 18:44:41 +00006477 var PDU_BSSAP bssap;
6478 T.start;
6479 alt {
6480 [] BSSAP.receive(exp_l3_compl) -> value bssap {
6481 f_logp(BSCVTY, "received expected Complete Layer 3 Info at MSC");
6482 log("rx exp_l3_compl = ", bssap);
6483 }
6484 [] BSSAP.receive(tr_BSSMAP_ComplL3) {
6485 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Received non-matching COMPLETE LAYER 3 INFORMATION");
6486 }
6487 [] T.timeout {
6488 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for COMPLETE LAYER 3 INFORMATION");
6489 }
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006490 }
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006491
Neels Hofmeyr66e15092020-10-12 18:44:41 +00006492 /* start ciphering, if requested */
6493 if (ispresent(g_pars.encr)) {
6494 f_logp(BSCVTY, "start ciphering");
6495 f_cipher_mode(g_pars.encr.enc_alg, g_pars.encr.enc_key);
6496 }
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006497 }
6498
6499 if (do_clear) {
6500 f_perform_clear(rsl);
6501 }
6502 setverdict(pass);
6503 f_sleep(1.0);
6504}
6505
6506private function f_tc_mscpool_compl_l3(charstring id) runs on MSC_ConnHdlr {
6507 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
6508 if (g_pars.mscpool.rsl_idx == 0) {
6509 f_perform_compl_l3(RSL, g_pars.mscpool.l3_info);
6510 } else if (g_pars.mscpool.rsl_idx == 1) {
6511 f_perform_compl_l3(RSL1, g_pars.mscpool.l3_info);
6512 } else if (g_pars.mscpool.rsl_idx == 2) {
6513 f_perform_compl_l3(RSL2, g_pars.mscpool.l3_info);
6514 }
6515}
6516
6517/* Various Complete Layer 3 by IMSI all end up with the first MSC, because the other MSCs are not connected. */
6518private function f_tc_mscpool_L3Compl_on_1_msc(charstring id) runs on MSC_ConnHdlr {
6519 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
6520 f_perform_compl_l3(RSL, ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_IMSI_LV('001010000000001'H)), '00F110'O) );
6521 f_perform_compl_l3(RSL, ts_CM_SERV_REQ(CM_TYPE_MO_SMS, valueof(ts_MI_IMSI_LV('001010000000002'H))) );
6522 f_perform_compl_l3(RSL, ts_PAG_RESP(valueof(ts_MI_IMSI_LV('001010000000003'H))) );
6523 f_perform_compl_l3(RSL, ts_ML3_MO_MM_IMSI_DET_Ind(valueof(ts_MI_IMSI_LV('001010000000004'H))) );
6524}
6525testcase TC_mscpool_L3Compl_on_1_msc() runs on test_CT {
6526
6527 f_init(1, true);
6528 f_sleep(1.0);
6529 var MSC_ConnHdlr vc_conn;
6530 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006531
6532 f_ctrs_msc_init();
6533
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006534 vc_conn := f_start_handler(refers(f_tc_mscpool_L3Compl_on_1_msc), pars);
6535 vc_conn.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006536
6537 f_ctrs_msc_expect(0, "mscpool:subscr:new", 4);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006538 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006539}
6540
6541/* Three Layer 3 Complete by IMSI are round-robin'ed across two connected MSCs */
6542/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
6543 * just as well using only RSL. */
6544testcase TC_mscpool_L3Complete_by_imsi_round_robin() runs on test_CT {
6545
6546 f_init(nr_bts := 3, handler_mode := true, nr_msc := 2);
6547 f_sleep(1.0);
6548
6549 /* Control which MSC gets chosen next by the round-robin, otherwise
6550 * would be randomly affected by which other tests ran before this. */
6551 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
6552
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006553 f_ctrs_msc_init();
6554
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006555 var MSC_ConnHdlr vc_conn1;
6556 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
6557 pars1.mscpool.rsl_idx := 0;
6558 pars1.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_IMSI_LV('001010000000001'H)), '00F110'O));
6559 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6560 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006561 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006562
6563 var MSC_ConnHdlr vc_conn2;
6564 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 1);
6565 pars2.mscpool.rsl_idx := 1;
6566 pars2.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, valueof(ts_MI_IMSI_LV('001010000000002'H))));
6567 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6568 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006569 f_ctrs_msc_expect(1, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006570
6571 /* Test round-robin wrap to the first MSC */
6572 var MSC_ConnHdlr vc_conn3;
6573 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 0);
6574 pars3.mscpool.rsl_idx := 2;
6575 pars3.mscpool.l3_info := valueof(ts_PAG_RESP(valueof(ts_MI_IMSI_LV('001010000000003'H))));
6576 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
6577 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006578 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006579 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006580}
6581
6582/* Three LU by TMSI are round-robin'ed across two connected MSCs, because they contain the NULL-NRI 0
6583 * (configured in osmo-bsc.cfg). */
6584/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
6585 * just as well using only RSL. */
6586testcase TC_mscpool_LU_by_tmsi_null_nri_0_round_robin() runs on test_CT {
6587
6588 f_init(nr_bts := 3, handler_mode := true, nr_msc := 2);
6589 f_sleep(1.0);
6590
6591 /* Control which MSC gets chosen next by the round-robin, otherwise
6592 * would be randomly affected by which other tests ran before this. */
6593 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
6594
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006595 f_ctrs_msc_init();
6596
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006597 var MSC_ConnHdlr vc_conn1;
6598 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
6599 pars1.mscpool.rsl_idx := 0;
6600 pars1.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(0)), '00F110'O));
6601 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6602 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006603 f_ctrs_msc_expect(0, "mscpool:subscr:reattach");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006604
6605 var MSC_ConnHdlr vc_conn2;
6606 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 1);
6607 pars2.mscpool.rsl_idx := 1;
6608 pars2.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(0)), '00F110'O));
6609 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6610 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006611 f_ctrs_msc_expect(1, "mscpool:subscr:reattach");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006612
6613 /* Test round-robin wrap to the first MSC */
6614 var MSC_ConnHdlr vc_conn3;
6615 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 0);
6616 pars3.mscpool.rsl_idx := 2;
6617 pars3.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(0)), '00F110'O));
6618 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
6619 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006620 f_ctrs_msc_expect(0, "mscpool:subscr:reattach");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006621 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006622}
6623
6624/* Three LU by TMSI are round-robin'ed across two connected MSCs, because they contain the NULL-NRI 1
6625 * (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
6626 * NULL-NRI setting is stronger than that. */
6627/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
6628 * just as well using only RSL. */
6629testcase TC_mscpool_LU_by_tmsi_null_nri_1_round_robin() runs on test_CT {
6630
6631 f_init(nr_bts := 3, handler_mode := true, nr_msc := 2);
6632 f_sleep(1.0);
6633
6634 /* Control which MSC gets chosen next by the round-robin, otherwise
6635 * would be randomly affected by which other tests ran before this. */
6636 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
6637
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006638 f_ctrs_msc_init();
6639
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006640 var MSC_ConnHdlr vc_conn1;
6641 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
6642 pars1.mscpool.rsl_idx := 0;
6643 pars1.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(1)), '00F110'O));
6644 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6645 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006646 f_ctrs_msc_expect(0, "mscpool:subscr:reattach");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006647
6648 var MSC_ConnHdlr vc_conn2;
6649 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 1);
6650 pars2.mscpool.rsl_idx := 1;
6651 pars2.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(1)), '00F110'O));
6652 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6653 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006654 f_ctrs_msc_expect(1, "mscpool:subscr:reattach");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006655
6656 /* Test round-robin wrap to the first MSC */
6657 var MSC_ConnHdlr vc_conn3;
6658 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 0);
6659 pars3.mscpool.rsl_idx := 2;
6660 pars3.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(1)), '00F110'O));
6661 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
6662 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006663 f_ctrs_msc_expect(0, "mscpool:subscr:reattach");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006664 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006665}
6666
6667/* Three Layer 3 Complete by TMSI are round-robin'ed across two connected MSCs, because they contain an NRI not
6668 * assigned to any MSC (configured in osmo-bsc.cfg). */
6669/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
6670 * just as well using only RSL. */
6671testcase TC_mscpool_L3Complete_by_tmsi_unassigned_nri_round_robin() runs on test_CT {
6672
6673 f_init(nr_bts := 3, handler_mode := true, nr_msc := 2);
6674 f_sleep(1.0);
6675
6676 /* Control which MSC gets chosen next by the round-robin, otherwise
6677 * would be randomly affected by which other tests ran before this. */
6678 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
6679
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006680 f_ctrs_msc_init();
6681
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006682 var MSC_ConnHdlr vc_conn1;
6683 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
6684 pars1.mscpool.rsl_idx := 0;
6685 /* An NRI that is not assigned to any MSC */
6686 pars1.mscpool.l3_info := valueof(ts_ML3_MO_MM_IMSI_DET_Ind(valueof(ts_MI_TMSI_NRI_LV(1023))));
6687 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6688 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006689 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006690
6691 var MSC_ConnHdlr vc_conn2;
6692 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 1);
6693 pars2.mscpool.rsl_idx := 1;
6694 /* An NRI that is not assigned to any MSC */
6695 pars2.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(768)), '00F110'O));
6696 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6697 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006698 f_ctrs_msc_expect(1, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006699
6700 /* Test round-robin wrap to the first MSC */
6701 var MSC_ConnHdlr vc_conn3;
6702 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 0);
6703 pars3.mscpool.rsl_idx := 2;
6704 /* An NRI that is not assigned to any MSC */
6705 pars3.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_SS_ACT, valueof(ts_MI_TMSI_NRI_LV(819))));
6706 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
6707 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006708 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006709 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006710}
6711
6712/* Three Layer 3 Complete by TMSI are round-robin'ed across two connected MSCs, because they contain an NRI
6713 * assigned to an MSC that is currently not connected (configured in osmo-bsc.cfg). */
6714/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
6715 * just as well using only RSL. */
6716testcase TC_mscpool_L3Complete_by_tmsi_valid_nri_msc_not_connected_round_robin() runs on test_CT {
6717
6718 f_init(nr_bts := 3, handler_mode := true, nr_msc := 2);
6719 f_sleep(1.0);
6720
6721 /* Control which MSC gets chosen next by the round-robin, otherwise
6722 * would be randomly affected by which other tests ran before this. */
6723 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
6724
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006725 f_ctrs_msc_init();
6726
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006727 var MSC_ConnHdlr vc_conn1;
6728 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
6729 pars1.mscpool.rsl_idx := 0;
6730 /* An NRI that is assigned to an unconnected MSC */
6731 pars1.mscpool.l3_info := valueof(ts_PAG_RESP(valueof(ts_MI_TMSI_NRI_LV(512))));
6732 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6733 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006734 f_ctrs_msc_add(2, "mscpool:subscr:attach_lost");
6735 f_ctrs_msc_add(0, "mscpool:subscr:new");
6736 f_ctrs_msc_verify();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006737
6738 var MSC_ConnHdlr vc_conn2;
6739 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 1);
6740 pars2.mscpool.rsl_idx := 1;
6741 /* An NRI that is assigned to an unconnected MSC */
6742 pars2.mscpool.l3_info := valueof(ts_ML3_MO_MM_IMSI_DET_Ind(valueof(ts_MI_TMSI_NRI_LV(767))));
6743 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6744 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006745 f_ctrs_msc_add(2, "mscpool:subscr:attach_lost");
6746 f_ctrs_msc_add(1, "mscpool:subscr:new");
6747 f_ctrs_msc_verify();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006748
6749 /* Test round-robin wrap to the first MSC */
6750 var MSC_ConnHdlr vc_conn3;
6751 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 0);
6752 pars3.mscpool.rsl_idx := 2;
6753 /* An NRI that is assigned to an unconnected MSC */
6754 pars3.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(750)), '00F110'O));
6755 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
6756 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006757 f_ctrs_msc_add(2, "mscpool:subscr:attach_lost");
6758 f_ctrs_msc_add(0, "mscpool:subscr:new");
6759 f_ctrs_msc_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006760 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006761}
6762
6763/* Three Layer 3 Complete by TMSI with valid NRI for the second MSC are all directed to the second MSC (configured in
6764 * osmo-bsc.cfg). */
6765/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
6766 * just as well using only RSL. */
6767testcase TC_mscpool_L3Complete_by_tmsi_valid_nri_1() runs on test_CT {
6768
6769 f_init(nr_bts := 3, handler_mode := true, nr_msc := 2);
6770 f_sleep(1.0);
6771
6772 /* All TMSIs in this test point at the second MSC, set the round robin to point at the first MSC to make sure
6773 * this is not using round-robin. */
6774 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
6775
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006776 f_ctrs_msc_init();
6777
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006778 var MSC_ConnHdlr vc_conn1;
6779 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 1);
6780 pars1.mscpool.rsl_idx := 0;
6781 /* An NRI of the second MSC's range (256-511) */
6782 pars1.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_SMS, valueof(ts_MI_TMSI_NRI_LV(256))));
6783 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6784 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006785 f_ctrs_msc_expect(1, "mscpool:subscr:known");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006786
6787 var MSC_ConnHdlr vc_conn2;
6788 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 1);
6789 pars2.mscpool.rsl_idx := 1;
6790 /* An NRI of the second MSC's range (256-511) */
6791 pars2.mscpool.l3_info := valueof(ts_PAG_RESP(valueof(ts_MI_TMSI_NRI_LV(260))));
6792 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6793 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006794 f_ctrs_msc_expect(1, "mscpool:subscr:known");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006795
6796 var MSC_ConnHdlr vc_conn3;
6797 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 1);
6798 pars3.mscpool.rsl_idx := 2;
6799 /* An NRI of the second MSC's range (256-511) */
6800 pars3.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(511)), '00F110'O));
6801 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
6802 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006803 f_ctrs_msc_expect(1, "mscpool:subscr:known");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006804 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006805}
6806
6807/* Layer 3 Complete by TMSI with valid NRI for the third MSC are directed to the third MSC (configured in osmo-bsc.cfg),
6808 * while a round-robin remains unaffected by that. */
6809/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
6810 * just as well using only RSL. */
6811testcase TC_mscpool_L3Complete_by_tmsi_valid_nri_2() runs on test_CT {
6812
6813 f_init(nr_bts := 3, handler_mode := true, nr_msc := 3);
6814 f_sleep(1.0);
6815
6816 /* All TMSIs in this test point at the third MSC, set the round robin to point at the second MSC to make sure
6817 * this is not using round-robin. */
6818 f_vty_transceive(BSCVTY, "mscpool roundrobin next 1");
6819
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006820 f_ctrs_msc_init();
6821
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006822 var MSC_ConnHdlr vc_conn1;
6823 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 2);
6824 pars1.mscpool.rsl_idx := 0;
6825 /* An NRI of the third MSC's range (512-767) */
6826 pars1.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_SMS, valueof(ts_MI_TMSI_NRI_LV(512))));
6827 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6828 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006829 f_ctrs_msc_expect(2, "mscpool:subscr:known");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006830
6831 var MSC_ConnHdlr vc_conn2;
6832 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 2);
6833 pars2.mscpool.rsl_idx := 1;
6834 /* An NRI of the third MSC's range (512-767) */
6835 pars2.mscpool.l3_info := valueof(ts_PAG_RESP(valueof(ts_MI_TMSI_NRI_LV(678))));
6836 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6837 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006838 f_ctrs_msc_expect(2, "mscpool:subscr:known");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006839
6840 /* The above forwardings to third MSC have not affected the round robin, which still points at the second MSC */
6841 var MSC_ConnHdlr vc_conn3;
6842 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 1);
6843 pars3.mscpool.rsl_idx := 2;
6844 pars3.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_IMSI_LV('001010000000013'H)), '00F110'O));
6845 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
6846 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006847 f_ctrs_msc_expect(1, "mscpool:subscr:new");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006848 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006849}
6850
6851/* LU with a TMSI but indicating a different PLMN in its previous LAI: ignore the NRI. */
6852/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
6853 * just as well using only RSL. */
6854testcase TC_mscpool_LU_by_tmsi_from_other_PLMN() runs on test_CT {
6855
6856 f_init(nr_bts := 3, handler_mode := true, nr_msc := 3);
6857 f_sleep(1.0);
6858
6859 /* The TMSIs in this test points at the second MSC, but since it is from a different PLMN, round-robin is used
6860 * instead, and hits msc 0. */
6861 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
6862
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006863 f_ctrs_msc_init();
6864
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006865 /* An NRI of the second MSC's range (256-511), but a PLMN that doesn't match with osmo-bsc.cfg */
6866 var MSC_ConnHdlr vc_conn1;
6867 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
6868 pars1.mscpool.rsl_idx := 0;
6869 pars1.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(260)), '99F999'O));
6870 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6871 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006872 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006873
6874 /* An NRI of the third MSC's range (512-767) and a matching PLMN gets directed by NRI. */
6875 var MSC_ConnHdlr vc_conn2;
6876 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 2);
6877 pars2.mscpool.rsl_idx := 1;
6878 pars2.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(555)), '00F110'O));
6879 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6880 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006881 f_ctrs_msc_expect(2, "mscpool:subscr:known");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006882 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006883}
6884
6885/* Make sure that whichever MSC paged a subscriber will also get the Paging Response. Page by IMSI, which would be
6886 * round-robined to another MSC, to make sure the Paging->Response relation is stronger than the NRI->MSC mapping. */
6887private function f_tc_mscpool_paging_imsi(charstring id) runs on MSC_ConnHdlr {
6888 var template BSSMAP_FIELD_CellIdentificationList cid_list := { cIl_CI := { ts_BSSMAP_CI_CI(0) } };
6889 //cid_list := { cIl_allInBSS := ''O };
6890 var RSL_ChanNeeded rsl_chneed := RSL_CHANNEED_SDCCH;
6891 var template BSSMAP_IE_ChannelNeeded bssmap_chneed := ts_BSSMAP_IE_ChanNeeded(int2bit(enum2int(valueof(rsl_chneed)),2));
6892 var BSSAP_N_UNITDATA_req paging;
6893 var hexstring imsi := '001010000000123'H;
6894
6895 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
6896
Neels Hofmeyr90f80962020-06-12 16:16:55 +02006897 paging := valueof(ts_BSSAP_UNITDATA_req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006898 valueof(ts_BSSMAP_Paging(imsi, cid_list, omit, bssmap_chneed))));
6899 BSSAP.send(paging);
6900
6901 /* Register any RSL conn so that the Paging Command gets received here. With the current RSL_Emulation's main()
6902 * handling of '[bts_role] IPA_PT.receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD()))' it doesn't matter at all which
6903 * channel number is picked here. */
6904 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(0, RSL_CHAN_NR_INVALID));
6905 f_rslem_register(0, new_chan_nr);
6906 RSL.receive(tr_RSL_PAGING_CMD(tr_MI_IMSI(imsi)));
6907 f_rslem_unregister(0, new_chan_nr);
6908
6909 /* Despite the round robin pointing at the second MSC ('roundrobin next 1'), the earlier Paging for the same IMSI
6910 * causes this Paging Response to go to the first MSC (bssap_idx := 0). */
6911 f_perform_compl_l3(RSL, ts_PAG_RESP(valueof(ts_MI_IMSI_LV(imsi))) );
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006912 f_sleep(1.0);
6913}
6914testcase TC_mscpool_paging_and_response_imsi() runs on test_CT {
6915 f_init(nr_bts := 1, handler_mode := true, nr_msc := 3);
6916 f_sleep(1.0);
6917
6918 /* Testing a Paging on the first MSC to get a Paging Response back to the first MSC. Set round robin to the
6919 * second MSC to make sure we're getting the Paging logic, not a coincidental round robin match. */
6920 f_vty_transceive(BSCVTY, "mscpool roundrobin next 1");
6921
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006922 f_ctrs_msc_init();
6923
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006924 var MSC_ConnHdlr vc_conn1;
6925 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
6926 pars1.mscpool.rsl_idx := 0;
Neels Hofmeyr90f80962020-06-12 16:16:55 +02006927 pars1.sccp_addr_bsc := g_bssap[pars1.mscpool.bssap_idx].sccp_addr_peer;
6928 pars1.sccp_addr_msc := g_bssap[pars1.mscpool.bssap_idx].sccp_addr_own;
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006929 vc_conn1 := f_start_handler(refers(f_tc_mscpool_paging_imsi), pars1);
6930 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006931 f_ctrs_msc_expect(0, "mscpool:subscr:paged");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006932 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006933}
6934
6935/* Make sure that whichever MSC paged a subscriber will also get the Paging Response. Page by TMSI with an NRI value
6936 * that matches a different MSC, to make sure the Paging->Response relation is stronger than the NRI->MSC mapping. */
6937private function f_tc_mscpool_paging_tmsi(charstring id) runs on MSC_ConnHdlr {
6938 var template BSSMAP_FIELD_CellIdentificationList cid_list := { cIl_CI := { ts_BSSMAP_CI_CI(0) } };
6939 //cid_list := { cIl_allInBSS := ''O };
6940 var RSL_ChanNeeded rsl_chneed := RSL_CHANNEED_SDCCH;
6941 var template BSSMAP_IE_ChannelNeeded bssmap_chneed := ts_BSSMAP_IE_ChanNeeded(int2bit(enum2int(valueof(rsl_chneed)),2));
6942 var integer nri_v := 300; /* <-- second MSC's NRI */
6943 var octetstring tmsi := f_tmsi_nri(nri_v);
6944 var BSSAP_N_UNITDATA_req paging;
6945
6946 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
6947
Neels Hofmeyr90f80962020-06-12 16:16:55 +02006948 paging := valueof(ts_BSSAP_UNITDATA_req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006949 valueof(ts_BSSMAP_Paging('001010000000011'H, cid_list, tmsi, bssmap_chneed))));
6950 BSSAP.send(paging);
6951
6952 /* Register any RSL conn so that the Paging Command gets received here. With the current RSL_Emulation's main()
6953 * handling of '[bts_role] IPA_PT.receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD()))' it doesn't matter at all which
6954 * channel number is picked here. */
6955 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(0, RSL_CHAN_NR_INVALID));
6956 f_rslem_register(0, new_chan_nr);
6957 RSL.receive(tr_RSL_PAGING_CMD(t_MI_TMSI(tmsi)));
6958 f_rslem_unregister(0, new_chan_nr);
6959
6960 /* Despite the NRI matching the second MSC (NRI from 'msc 1' in osmo-bsc.cfg) and round robin pointing at the
6961 * third MSC ('roundrobin next 2'), the earlier Paging for the same TMSI causes this Paging Response to go to
6962 * the first MSC (bssap_idx := 0). */
6963 f_perform_compl_l3(RSL, ts_PAG_RESP(valueof(ts_MI_TMSI_NRI_LV(nri_v))) );
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006964 f_sleep(1.0);
6965}
6966testcase TC_mscpool_paging_and_response_tmsi() runs on test_CT {
6967 f_init(nr_bts := 1, handler_mode := true, nr_msc := 3);
6968 f_sleep(1.0);
6969
6970 /* Testing a Paging on the first MSC to get a Paging Response back to the first MSC. Set round robin to the
6971 * third MSC to make sure we're getting the Paging logic, not a coincidental round robin match. */
6972 f_vty_transceive(BSCVTY, "mscpool roundrobin next 2");
6973
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006974 f_ctrs_msc_init();
6975
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006976 var MSC_ConnHdlr vc_conn1;
6977 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
6978 pars1.mscpool.rsl_idx := 0;
Neels Hofmeyr90f80962020-06-12 16:16:55 +02006979 pars1.sccp_addr_bsc := g_bssap[pars1.mscpool.bssap_idx].sccp_addr_peer;
6980 pars1.sccp_addr_msc := g_bssap[pars1.mscpool.bssap_idx].sccp_addr_own;
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006981 vc_conn1 := f_start_handler(refers(f_tc_mscpool_paging_tmsi), pars1);
6982 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006983 f_ctrs_msc_expect(0, "mscpool:subscr:paged");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006984 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006985}
6986
6987/* For round-robin, skip an MSC that has 'no allow-attach' set. */
6988/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
6989 * just as well using only RSL. */
6990testcase TC_mscpool_no_allow_attach_round_robin() runs on test_CT {
6991
6992 f_init(nr_bts := 3, handler_mode := true, nr_msc := 3);
6993 f_sleep(1.0);
Neels Hofmeyra460f1f2020-08-09 20:17:03 +00006994 /* Mark the second MSC as offloading, round-robin should skip this MSC now. */
6995 f_vty_msc_allow_attach(BSCVTY, {true, false, true});
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006996
6997 /* Control which MSC gets chosen next by the round-robin, otherwise
6998 * would be randomly affected by which other tests ran before this. */
6999 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
7000
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007001 f_ctrs_msc_init();
7002
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007003 var MSC_ConnHdlr vc_conn1;
7004 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
7005 pars1.mscpool.rsl_idx := 0;
7006 pars1.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_IMSI_LV('001010000000001'H)), '00F110'O));
7007 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
7008 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007009 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007010
7011 var MSC_ConnHdlr vc_conn2;
7012 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 2);
7013 pars2.mscpool.rsl_idx := 1;
7014 pars2.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, valueof(ts_MI_IMSI_LV('001010000000002'H))));
7015 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
7016 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007017 f_ctrs_msc_expect(2, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007018
7019 var MSC_ConnHdlr vc_conn3;
7020 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 0);
7021 pars3.mscpool.rsl_idx := 2;
7022 pars3.mscpool.l3_info := valueof(ts_PAG_RESP(valueof(ts_MI_IMSI_LV('001010000000003'H))));
7023 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
7024 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007025 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007026 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007027}
7028
7029/* An MSC that has 'no allow-attach' set should still serve subscribers that are already attached according to their
7030 * TMSI NRI. */
7031testcase TC_mscpool_no_allow_attach_valid_nri() runs on test_CT {
7032
7033 f_init(nr_bts := 3, handler_mode := true, nr_msc := 3);
7034 f_sleep(1.0);
7035
Neels Hofmeyra460f1f2020-08-09 20:17:03 +00007036 /* Mark the second MSC as offloading, round-robin should skip this MSC now. */
7037 f_vty_msc_allow_attach(BSCVTY, {true, false, true});
7038
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007039 /* Control which MSC gets chosen next by the round-robin, otherwise
7040 * would be randomly affected by which other tests ran before this. */
7041 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
7042
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007043 f_ctrs_msc_init();
7044
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007045 /* Round robin points at msc 0, but the valid NRI directs to msc 1, even though msc 1 has 'no allow-attach'. */
7046 var MSC_ConnHdlr vc_conn1;
7047 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 1);
7048 pars1.mscpool.rsl_idx := 0;
7049 /* An NRI of the second MSC's range (256-511) */
7050 pars1.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, valueof(ts_MI_TMSI_NRI_LV(260))));
7051 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
7052 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007053 f_ctrs_msc_expect(1, "mscpool:subscr:known");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007054
7055 var MSC_ConnHdlr vc_conn2;
7056 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 0);
7057 pars2.mscpool.rsl_idx := 1;
7058 pars2.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, valueof(ts_MI_IMSI_LV('001010000000002'H))));
7059 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
7060 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007061 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007062
7063 var MSC_ConnHdlr vc_conn3;
7064 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 2);
7065 pars3.mscpool.rsl_idx := 2;
7066 pars3.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, valueof(ts_MI_IMSI_LV('001010000000003'H))));
7067 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
7068 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02007069 f_ctrs_msc_expect(2, "mscpool:subscr:new");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007070 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007071}
7072
Philipp Maier783681c2020-07-16 16:47:06 +02007073/* Allow/Deny emergency calls globally via VTY */
7074private function f_vty_allow_emerg_msc(boolean allow) runs on test_CT {
7075 f_vty_enter_cfg_msc(BSCVTY, 0);
7076 if (allow) {
7077 f_vty_transceive(BSCVTY, "allow-emergency allow");
7078 } else {
7079 f_vty_transceive(BSCVTY, "allow-emergency deny");
7080 }
7081 f_vty_transceive(BSCVTY, "exit");
7082 f_vty_transceive(BSCVTY, "exit");
7083}
7084
7085/* Allow/Deny emergency calls per BTS via VTY */
7086private function f_vty_allow_emerg_bts(boolean allow, integer bts_nr) runs on test_CT {
7087 f_vty_enter_cfg_bts(BSCVTY, bts_nr);
7088 if (allow) {
7089 f_vty_transceive(BSCVTY, "rach emergency call allowed 1");
7090 } else {
7091 f_vty_transceive(BSCVTY, "rach emergency call allowed 0");
7092 }
7093 f_vty_transceive(BSCVTY, "exit");
7094 f_vty_transceive(BSCVTY, "exit");
Neels Hofmeyrb6ed80c2020-10-12 22:52:39 +00007095 f_vty_transceive(BSCVTY, "exit");
Philipp Maier783681c2020-07-16 16:47:06 +02007096}
7097
7098/* Begin assignmet procedure and send an EMERGENCY SETUP (RR) */
7099private function f_assignment_emerg_setup() runs on MSC_ConnHdlr {
7100 var PDU_ML3_MS_NW emerg_setup;
7101 var octetstring emerg_setup_enc;
7102 var RSL_Message emerg_setup_data_ind;
7103
7104 f_establish_fully(omit, omit);
7105
7106 emerg_setup := valueof(ts_ML3_MO_CC_EMERG_SETUP(1, valueof(ts_Bcap_voice)));
7107 emerg_setup_enc := enc_PDU_ML3_MS_NW(emerg_setup);
7108 emerg_setup_data_ind := valueof(ts_RSL_DATA_IND(g_chan_nr, valueof(ts_RslLinkID_DCCH(0)), emerg_setup_enc));
7109
7110 RSL.send(emerg_setup_data_ind);
7111}
7112
7113/* Test if the EMERGENCY SETUP gets passed on to the MSC via A when EMERGENCY
7114 * CALLS are permitted by the BSC config. */
7115private function f_TC_assignment_emerg_setup_allow(charstring id) runs on MSC_ConnHdlr {
7116 var PDU_BSSAP emerg_setup_data_ind_bssap;
7117 var PDU_ML3_MS_NW emerg_setup;
7118 timer T := 3.0;
7119
7120 f_assignment_emerg_setup()
7121
7122 T.start;
7123 alt {
7124 [] BSSAP.receive(tr_BSSAP_DTAP) -> value emerg_setup_data_ind_bssap {
7125 emerg_setup := dec_PDU_ML3_MS_NW(emerg_setup_data_ind_bssap.pdu.dtap);
7126 if (not isbound(emerg_setup.msgs.cc.emergencySetup)) {
7127 setverdict(fail, "no emergency setup");
7128 }
7129 }
7130 [] BSSAP.receive {
7131 setverdict(fail, "unexpected BSSAP message!");
7132 }
7133 [] T.timeout {
7134 setverdict(fail, "timout waiting for EMERGENCY SETUP!");
7135 }
7136 }
7137
7138 setverdict(pass);
7139}
7140
7141/* Test if the EMERGENCY SETUP gets blocked by the BSC if EMERGENCY CALLS are
7142 * forbidden by the BSC config. */
7143private function f_TC_assignment_emerg_setup_deny(charstring id) runs on MSC_ConnHdlr {
7144 var PDU_BSSAP emerg_setup_data_ind_bssap;
7145 timer T := 3.0;
7146
7147 f_assignment_emerg_setup()
7148
7149 T.start;
7150 alt {
7151 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_RELEASE)) {
7152 setverdict(pass);
7153 }
7154 [] RSL.receive {
7155 setverdict(fail, "unexpected RSL message!");
7156 }
7157 [] T.timeout {
7158 setverdict(fail, "timout waiting for RR CHANNEL RELEASE!");
7159 }
7160 }
7161}
7162
7163/* EMERGENCY CALL situation #1, allowed globally and by BTS */
7164testcase TC_assignment_emerg_setup_allow() runs on test_CT {
7165 var TestHdlrParams pars := f_gen_test_hdlr_pars();
7166 var MSC_ConnHdlr vc_conn;
7167
7168 f_init(1, true);
7169 f_sleep(1.0);
7170
7171 f_vty_allow_emerg_msc(true);
7172 f_vty_allow_emerg_bts(true, 0);
7173 vc_conn := f_start_handler(refers(f_TC_assignment_emerg_setup_allow), pars);
7174 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007175 f_shutdown_helper();
Philipp Maier783681c2020-07-16 16:47:06 +02007176}
7177
7178/* EMERGENCY CALL situation #2, forbidden globally but allowed by BTS */
7179testcase TC_assignment_emerg_setup_deny_msc() runs on test_CT {
7180 var TestHdlrParams pars := f_gen_test_hdlr_pars();
7181 var MSC_ConnHdlr vc_conn;
7182
7183 f_init(1, true);
7184 f_sleep(1.0);
7185
7186 f_vty_allow_emerg_msc(false);
7187 f_vty_allow_emerg_bts(true, 0);
7188 vc_conn := f_start_handler(refers(f_TC_assignment_emerg_setup_deny), pars);
7189 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007190 f_shutdown_helper();
Philipp Maier783681c2020-07-16 16:47:06 +02007191}
7192
7193/* EMERGENCY CALL situation #3, allowed globally but forbidden by BTS */
7194testcase TC_assignment_emerg_setup_deny_bts() runs on test_CT {
7195 var TestHdlrParams pars := f_gen_test_hdlr_pars();
7196 var MSC_ConnHdlr vc_conn;
7197
7198 /* Note: This simulates a spec violation by the MS, correct MS
7199 * implementations would not try to establish an emergency call because
7200 * the system information tells in advance that emergency calls are
7201 * not forbidden */
7202
7203 f_init(1, true);
7204 f_sleep(1.0);
7205
7206 f_vty_allow_emerg_msc(true);
7207 f_vty_allow_emerg_bts(false, 0);
7208 vc_conn := f_start_handler(refers(f_TC_assignment_emerg_setup_deny), pars);
7209 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007210 f_shutdown_helper();
Philipp Maier783681c2020-07-16 16:47:06 +02007211}
7212
Philipp Maier82812002020-08-13 18:48:27 +02007213/* Test what happens when an emergency call arrives while all TCH channels are
7214 * busy, the BSC is expected to terminate one call in favor of the incoming
7215 * emergency call */
7216testcase TC_emerg_premption() runs on test_CT {
7217 var ASP_RSL_Unitdata rsl_ud;
7218 var integer i;
7219 var integer chreq_total, chreq_nochan;
7220 var RSL_Message rx_rsl;
7221 var RslChannelNr chan_nr;
7222
7223 f_init(1);
7224 f_sleep(1.0);
7225
7226 f_vty_allow_emerg_msc(true);
7227 f_vty_allow_emerg_bts(true, 0);
7228
7229 /* Fill up all channels on the BTS */
7230 chreq_total := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total");
7231 chreq_nochan := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:no_channel");
7232 for (i := 0; i < NUM_TCHF_PER_BTS + NUM_TCHH_PER_BTS + NUM_SDCCH_PER_BTS; i := i+1) {
7233 chan_nr := f_chreq_act_ack('33'O, i);
7234 }
7235 IPA_RSL[0].clear;
7236 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total",
7237 chreq_total + NUM_TCHF_PER_BTS + NUM_TCHH_PER_BTS + NUM_SDCCH_PER_BTS);
7238
7239 /* Send Channel request for emegergency call */
7240 f_ipa_tx(0, ts_RSL_CHAN_RQD('A5'O, 23));
7241
7242 /* Expect the BSC to release one (the first) TCH/F on the BTS */
7243 chan_nr := valueof(t_RslChanNr_Bm(1));
7244 f_expect_chan_rel(0, chan_nr, expect_rr_chan_rel := false, expect_rll_rel_req := false);
7245
7246 /* Expect the BSC to send activate/assign the a channel for the emergency call */
7247 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
7248 chan_nr := rx_rsl.ies[0].body.chan_nr;
7249 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, 33));
7250 rx_rsl := f_exp_ipa_rx(0, tr_RSL_IMM_ASSIGN(0));
Philipp Maier104f4c02020-09-11 18:12:18 +02007251
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007252 f_shutdown_helper();
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007253}
7254
7255/* Hopping parameters per a timeslot */
Vadim Yanitskiybc6654a2020-09-13 01:27:40 +07007256private type record length(0..64) of GsmArfcn ArfcnList;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007257private type record FHParamsTs {
7258 boolean enabled,
7259 uint6_t hsn,
7260 uint6_t maio,
7261 ArfcnList ma
7262};
7263
7264/* Hopping parameters per a transceiver */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007265private type record FHParamsTrx {
7266 GsmArfcn arfcn,
7267 FHParamsTs ts[8]
7268};
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007269
7270/* Randomly generate the hopping parameters for the given timeslot numbers */
7271private function f_TC_fh_params_gen(template integer tr_tn := (1, 3, 5))
7272runs on test_CT return FHParamsTrx {
7273 var FHParamsTrx fhp;
7274
Vadim Yanitskiy3e997362020-09-05 21:08:34 +07007275 /* Generate a random ARFCN, including ARFCN 0 */
7276 fhp.arfcn := f_rnd_int(3);
Vadim Yanitskiye7c8c6e2020-09-13 14:33:03 +07007277
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007278 for (var integer tn := 0; tn < 8; tn := tn + 1) {
7279 if (not match(tn, tr_tn)) {
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007280 fhp.ts[tn].enabled := false;
7281 fhp.ts[tn].ma := { };
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007282 continue;
7283 }
7284
7285 /* Random HSN / MAIO values: 0..63 */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007286 fhp.ts[tn].hsn := f_rnd_int(64);
7287 fhp.ts[tn].maio := f_rnd_int(64);
7288 fhp.ts[tn].ma := { };
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007289
7290 /* Random Mobile Allocation (hopping channels) */
7291 var integer ma_len := 2 + f_rnd_int(9); /* 2..10 channels */
7292 var integer step := 3 + f_rnd_int(4); /* 3..6 stepping */
7293 for (var integer i := 1; i <= ma_len; i := i + 1) {
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007294 fhp.ts[tn].ma := fhp.ts[tn].ma & { i * step };
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007295 }
7296
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007297 fhp.ts[tn].enabled := true;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007298 }
7299
7300 log("f_TC_fh_params_gen(): ", fhp);
7301 return fhp;
7302}
7303
7304/* Make sure that the given Channel Description IE matches the hopping configuration */
7305private function f_TC_fh_params_match_chan_desc(in FHParamsTrx fhp, in ChannelDescription cd)
7306{
7307 var template (present) ChannelDescription tr_cd;
7308 var template (present) MaioHsn tr_maio_hsn;
7309 var uint3_t tn := cd.chan_nr.tn;
7310
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007311 if (fhp.ts[tn].enabled) {
7312 tr_maio_hsn := tr_HsnMaio(fhp.ts[tn].hsn, fhp.ts[tn].maio);
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007313 tr_cd := tr_ChanDescH1(cd.chan_nr, tr_maio_hsn);
7314 } else {
Vadim Yanitskiye7c8c6e2020-09-13 14:33:03 +07007315 tr_cd := tr_ChanDescH0(cd.chan_nr, fhp.arfcn);
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007316 }
7317
7318 if (not match(cd, tr_cd)) {
7319 setverdict(fail, "Channel Description IE does not match: ",
7320 cd, " vs expected ", tr_cd);
7321 }
7322}
7323
7324/* Make sure that the given Mobile Allocation IE matches the hopping configuration */
7325private function f_TC_fh_params_match_ma(in FHParamsTrx fhp, uint3_t tn,
7326 in MobileAllocationLV ma)
7327{
7328 var template MobileAllocationLV tr_ma := f_TC_fh_params_gen_tr_ma(fhp, tn, ma);
7329
7330 if (not match(ma, tr_ma)) {
7331 setverdict(fail, "Mobile Allocation IE does not match (tn := ",
7332 tn, "): ", ma, " vs expected: ", tr_ma);
7333 } else {
7334 setverdict(pass);
7335 }
7336}
7337
7338private function f_TC_fh_params_gen_tr_ma(in FHParamsTrx fhp, uint3_t tn,
7339 in MobileAllocationLV ma)
7340return template MobileAllocationLV {
7341 /* Mobile Allocation IE is expected to be empty if hopping is not enabled */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007342 if (not fhp.ts[tn].enabled) {
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007343 return { len := 0, ma := ''B };
7344 }
7345
7346 var bitstring full_mask := f_pad_bit(''B, 1024, '0'B);
7347 var bitstring slot_mask := f_pad_bit(''B, 1024, '0'B);
7348 var bitstring ma_mask := ''B;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007349
7350 /* Compose the full bit-mask (all channels, up to 1024 entries) */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007351 for (var integer i := 0; i < lengthof(fhp.ts); i := i + 1) {
7352 for (var integer j := 0; j < lengthof(fhp.ts[i].ma); j := j + 1) {
7353 if (full_mask[fhp.ts[i].ma[j]] == '1'B)
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007354 { continue; }
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007355 full_mask[fhp.ts[i].ma[j]] := '1'B;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007356 }
7357 }
7358
Vadim Yanitskiye7c8c6e2020-09-13 14:33:03 +07007359 /* Take ARFCN of the TRX itself into account */
7360 full_mask[fhp.arfcn] := '1'B;
7361
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007362 /* Compose a bit-mask for the given timeslot number */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007363 for (var integer i := 0; i < lengthof(fhp.ts[tn].ma); i := i + 1) {
7364 slot_mask[fhp.ts[tn].ma[i]] := '1'B;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007365 }
7366
7367 /* Finally, compose the Mobile Allocation bit-mask */
Vadim Yanitskiy3e997362020-09-05 21:08:34 +07007368 for (var integer i := 1; i < lengthof(full_mask); i := i + 1) {
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007369 if (full_mask[i] != '1'B)
7370 { continue; }
7371
7372 /* FIXME: ma_mask := ma_mask & slot_mask[i]; // triggers a bug in TITAN */
7373 if (slot_mask[i] == '1'B) {
7374 ma_mask := ma_mask & '1'B;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007375 } else {
7376 ma_mask := ma_mask & '0'B;
7377 }
7378 }
7379
Vadim Yanitskiy3e997362020-09-05 21:08:34 +07007380 /* ARFCN 0 (if present) goes to the last position of the bit-mask */
7381 if (full_mask[0] == '1'B) {
7382 /* FIXME: ma_mask := ma_mask & slot_mask[0]; // triggers a bug in TITAN */
7383 if (slot_mask[0] == '1'B) {
7384 ma_mask := ma_mask & '1'B;
7385 } else {
7386 ma_mask := ma_mask & '0'B;
7387 }
7388 }
7389
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007390 /* Ensure that ma_mask is octet-aligned */
Vadim Yanitskiy2aa02522020-09-06 14:05:23 +07007391 var integer ma_mask_len := (lengthof(ma_mask) + 8 - 1) / 8;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007392 ma_mask := f_pad_bit(ma_mask, ma_mask_len * 8, '0'B);
7393
7394 return { len := ma_mask_len, ma := ma_mask };
7395}
7396
7397/* Configure the hopping parameters in accordance with the given record */
7398private function f_TC_fh_params_set(in FHParamsTrx fhp,
7399 uint8_t bts_nr := 0,
7400 uint8_t trx_nr := 0)
7401runs on test_CT {
7402 /* Enter the configuration node for the given BTS/TRX numbers */
7403 f_vty_enter_cfg_trx(BSCVTY, bts_nr, trx_nr);
7404
Vadim Yanitskiye7c8c6e2020-09-13 14:33:03 +07007405 f_vty_transceive(BSCVTY, "arfcn " & int2str(fhp.arfcn));
7406
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007407 for (var integer tn := 0; tn < lengthof(fhp.ts); tn := tn + 1) {
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007408 f_vty_transceive(BSCVTY, "timeslot " & int2str(tn));
7409
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007410 if (not fhp.ts[tn].enabled) {
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007411 f_vty_transceive(BSCVTY, "hopping enabled 0");
7412 f_vty_transceive(BSCVTY, "exit"); /* go back */
7413 continue;
7414 }
7415
7416 /* Configure HSN / MAIO values */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007417 f_vty_transceive(BSCVTY, "hopping sequence-number " & int2str(fhp.ts[tn].hsn));
7418 f_vty_transceive(BSCVTY, "hopping maio " & int2str(fhp.ts[tn].maio));
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007419
7420 /* Configure the Mobile Allocation (hopping channels) */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007421 for (var integer i := 0; i < lengthof(fhp.ts[tn].ma); i := i + 1) {
7422 f_vty_transceive(BSCVTY, "hopping arfcn add " & int2str(fhp.ts[tn].ma[i]));
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007423 }
7424
7425 f_vty_transceive(BSCVTY, "hopping enabled 1");
7426 f_vty_transceive(BSCVTY, "exit"); /* go back */
7427 }
7428
7429 f_vty_transceive(BSCVTY, "end");
7430}
7431
7432/* Disable frequency hopping on all timeslots */
7433private function f_TC_fh_params_unset(in FHParamsTrx fhp,
7434 uint8_t bts_nr := 0,
Vadim Yanitskiye7c8c6e2020-09-13 14:33:03 +07007435 uint8_t trx_nr := 0,
7436 GsmArfcn arfcn := 871)
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007437runs on test_CT {
7438 /* Enter the configuration node for the given BTS/TRX numbers */
7439 f_vty_enter_cfg_trx(BSCVTY, bts_nr, trx_nr);
7440
Vadim Yanitskiye7c8c6e2020-09-13 14:33:03 +07007441 f_vty_transceive(BSCVTY, "arfcn " & int2str(arfcn));
7442
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007443 for (var integer tn := 0; tn < lengthof(fhp.ts); tn := tn + 1) {
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007444 f_vty_transceive(BSCVTY, "timeslot " & int2str(tn));
7445
7446 /* Delete all ARFCNs from the Mobile Allocation (if any) */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007447 for (var integer i := 0; i < lengthof(fhp.ts[tn].ma); i := i + 1) {
7448 f_vty_transceive(BSCVTY, "hopping arfcn del " & int2str(fhp.ts[tn].ma[i]));
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007449 }
7450
7451 f_vty_transceive(BSCVTY, "hopping enabled 0");
7452 f_vty_transceive(BSCVTY, "exit"); /* go back */
7453 }
7454
7455 f_vty_transceive(BSCVTY, "end");
7456 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
7457}
7458
7459/* Verify presence and correctness of the hopping parameters (HSN, MAIO)
7460 * in the Channel Identification IE of the RSL CHANnel ACTIVation message. */
7461testcase TC_fh_params_chan_activ() runs on test_CT {
7462 var FHParamsTrx fhp := f_TC_fh_params_gen();
7463 var RSL_Message rsl_msg;
7464 var RSL_IE_Body ie;
7465
7466 f_init_vty();
7467
7468 f_TC_fh_params_set(fhp); /* Enable frequency hopping */
7469 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
7470
7471 f_init(1);
7472
7473 /* CS domain: 3 (SDCCH/4+CBCH) + 4 (TCH/F) + 2 (TCH/H) channels available */
7474 for (var integer i := 0; i < 9; i := i + 1) {
7475 f_ipa_tx(0, ts_RSL_CHAN_RQD(f_rnd_ra_cs(), 23));
7476 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
7477
7478 /* Make sure that Channel Identification IE is present */
7479 if (not f_rsl_find_ie(rsl_msg, RSL_IE_CHAN_IDENT, ie)) {
7480 setverdict(fail, "RSL Channel Identification IE is absent");
7481 continue;
7482 }
7483
7484 /* Make sure that hopping parameters (HSN/MAIO) match */
7485 f_TC_fh_params_match_chan_desc(fhp, ie.chan_ident.ch_desc.v);
7486
7487 /* "Mobile Allocation shall be included but empty" - let's check this */
7488 if (ie.chan_ident.ma.v.len != 0) {
7489 setverdict(fail, "Mobile Allocation IE is not empty: ",
7490 ie.chan_ident.ma, ", despite it shall be");
7491 continue;
7492 }
7493 }
7494
7495 /* Disable frequency hopping */
7496 f_TC_fh_params_unset(fhp);
7497
Vadim Yanitskiy21726312020-09-04 01:45:36 +07007498 f_shutdown_helper();
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007499}
7500
7501/* Verify the hopping parameters (HSN, MAIO, MA) in (RR) Immediate Assignment */
7502testcase TC_fh_params_imm_ass() runs on test_CT {
7503 var FHParamsTrx fhp := f_TC_fh_params_gen();
7504 var RSL_Message rsl_msg;
7505 var RSL_IE_Body ie;
7506
7507 f_init_vty();
7508
7509 f_TC_fh_params_set(fhp); /* Enable frequency hopping */
7510 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
7511
7512 f_init(1);
7513
7514 /* CS domain: 3 (SDCCH/4+CBCH) + 4 (TCH/F) + 2 (TCH/H) channels available */
7515 for (var integer i := 0; i < 9; i := i + 1) {
7516 f_ipa_tx(0, ts_RSL_CHAN_RQD(f_rnd_ra_cs(), 23));
7517 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
7518
7519 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(rsl_msg.ies[0].body.chan_nr, 33));
7520 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeC(RSL_MT_IMMEDIATE_ASSIGN_CMD));
7521
7522 /* Make sure that Full Immediate Assign Info IE is present */
7523 if (not f_rsl_find_ie(rsl_msg, RSL_IE_FULL_IMM_ASS_INFO, ie)) {
7524 setverdict(fail, "RSL Full Immediate Assign Info IE is absent");
7525 continue;
7526 }
7527
7528 /* Decode the actual Immediate Assignment message */
7529 var GsmRrMessage rr_msg := dec_GsmRrMessage(ie.full_imm_ass_info.payload);
7530 if (not match(rr_msg.header, t_RrHeader(IMMEDIATE_ASSIGNMENT, ?))) {
7531 setverdict(fail, "Failed to match Immediate Assignment: ", rr_msg);
7532 continue;
7533 }
7534
7535 /* Make sure that hopping parameters (HSN/MAIO) match */
7536 f_TC_fh_params_match_chan_desc(fhp, rr_msg.payload.imm_ass.chan_desc);
7537
7538 /* Make sure that the Mobile Allocation IE matches */
7539 f_TC_fh_params_match_ma(fhp, rr_msg.payload.imm_ass.chan_desc.chan_nr.tn,
7540 rr_msg.payload.imm_ass.mobile_allocation);
7541 }
7542
7543 /* Disable frequency hopping */
7544 f_TC_fh_params_unset(fhp);
Philipp Maier82812002020-08-13 18:48:27 +02007545
Vadim Yanitskiy21726312020-09-04 01:45:36 +07007546 f_shutdown_helper();
Philipp Maier82812002020-08-13 18:48:27 +02007547}
7548
Vadim Yanitskiyaeb54a22020-09-01 06:25:25 +07007549/* Verify the hopping parameters (HSN, MAIO, MA) in (RR) Assignment Command */
7550testcase TC_fh_params_assignment_cmd() runs on test_CT {
7551 var FHParamsTrx fhp := f_TC_fh_params_gen();
7552 var RSL_Message rsl_msg;
7553 var RSL_IE_Body ie;
7554
7555 f_init_vty();
7556
7557 f_TC_fh_params_set(fhp); /* Enable frequency hopping */
7558 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
7559
7560 f_init(1);
7561
7562 /* HACK: work around "Couldn't find Expect for CRCX" */
7563 vc_MGCP.stop;
7564
7565 var template PDU_BSSAP ass_cmd := f_gen_ass_req();
7566 ass_cmd.pdu.bssmap.assignmentRequest.codecList := ts_BSSMAP_IE_CodecList({ts_CodecFR});
7567
7568 /* CS domain (TCH): 4 (TCH/F) + 2 (TCH/H) channels available
7569 * NOTE: only 3 SDCCH/4 channels are available on CCCH+SDCCH4+CBCH */
7570 for (var integer i := 0; i < 3; i := i + 1) {
7571 /* Establish a dedicated channel, so we can trigger (late) TCH assignment */
7572 var DchanTuple dt := f_est_dchan(f_rnd_ra_cs(), 23, f_rnd_octstring(16));
7573
7574 /* Send a BSSMAP Assignment Command, expect CHANnel ACTIVation */
7575 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ass_cmd));
7576 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
7577
7578 /* ACKnowledge CHANnel ACTIVation, expect RSL DATA REQuest */
7579 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(rsl_msg.ies[0].body.chan_nr, 33));
7580 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeR(RSL_MT_DATA_REQ));
7581
7582 /* Make sure that L3 Information IE is present */
7583 if (not f_rsl_find_ie(rsl_msg, RSL_IE_L3_INFO, ie)) {
7584 setverdict(fail, "RSL L3 Information IE is absent");
7585 continue;
7586 }
7587
7588 /* Decode the L3 message and make sure it is (RR) Assignment Command */
7589 var GsmRrL3Message l3_msg := dec_GsmRrL3Message(ie.l3_info.payload);
7590 if (not match(l3_msg.header, t_RrL3Header(ASSIGNMENT_COMMAND))) {
7591 setverdict(fail, "Failed to match Assignment Command: ", l3_msg);
7592 continue;
7593 }
7594
7595 /* Make sure that hopping parameters (HSN/MAIO) match */
7596 var ChannelDescription chan_desc := l3_msg.payload.ass_cmd.chan_desc;
7597 f_TC_fh_params_match_chan_desc(fhp, chan_desc);
7598
7599 /* Make sure that Cell Channel Description IE is present if FH is enabled */
7600 if (chan_desc.h and not ispresent(l3_msg.payload.ass_cmd.cell_chan_desc)) {
Vadim Yanitskiy38d069d2020-09-02 17:18:57 +07007601 setverdict(fail, "FH enabled, but Cell Channel Description IE is absent");
Vadim Yanitskiyaeb54a22020-09-01 06:25:25 +07007602 continue;
7603 }
7604
7605 /* Make sure that the Mobile Allocation IE matches (if present) */
7606 var boolean ma_present := ispresent(l3_msg.payload.ass_cmd.mobile_allocation);
7607 if (chan_desc.h and ma_present) {
7608 f_TC_fh_params_match_ma(fhp, chan_desc.chan_nr.tn,
7609 l3_msg.payload.ass_cmd.mobile_allocation.v);
7610 } else if (chan_desc.h and not ma_present) {
7611 setverdict(fail, "FH enabled, but Mobile Allocation IE is absent");
7612 continue;
7613 } else if (not chan_desc.h and ma_present) {
7614 setverdict(fail, "FH disabled, but Mobile Allocation IE is present");
7615 continue;
7616 }
7617 }
7618
7619 /* Give the IUT some time to release all channels */
7620 f_sleep(3.0);
7621
7622 /* Disable frequency hopping */
7623 f_TC_fh_params_unset(fhp);
7624
Vadim Yanitskiy21726312020-09-04 01:45:36 +07007625 f_shutdown_helper();
Vadim Yanitskiyaeb54a22020-09-01 06:25:25 +07007626}
7627
Vadim Yanitskiy8f5430d2020-09-02 18:51:38 +07007628/* Verify the hopping parameters (HSN, MAIO, MA) in (RR) Handover Command */
7629private function f_TC_fh_params_handover_cmd(in FHParamsTrx fhp)
7630runs on test_CT {
7631 var RSL_Message rsl_msg;
7632 var RSL_IE_Body ie;
7633 var DchanTuple dt;
7634
7635 /* Establish a dedicated channel, so we can trigger handover */
7636 dt := f_est_dchan(f_rnd_ra_cs(), 23, f_rnd_octstring(16));
7637
7638 /* Trigger handover from BTS0 to BTS1 */
7639 f_bts_0_cfg(BSCVTY, { "neighbor bts 1" });
7640 f_vty_handover(BSCVTY, 0, 0, dt.rsl_chan_nr, 1);
7641
7642 /* Expect RSL CHANnel ACTIVation on BTS1/TRX0/TS1 */
7643 rsl_msg := f_exp_ipa_rx(1, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
7644
7645 /* ACKnowledge channel activation and expect (RR) Handover Command */
7646 f_ipa_tx(1, ts_RSL_CHAN_ACT_ACK(rsl_msg.ies[0].body.chan_nr, 33));
7647 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeR(RSL_MT_DATA_REQ));
7648
7649 /* Make sure that L3 Information IE is present */
7650 if (not f_rsl_find_ie(rsl_msg, RSL_IE_L3_INFO, ie)) {
7651 setverdict(fail, "RSL L3 Information IE is absent");
7652 return;
7653 }
7654
7655 /* Decode the L3 message and make sure it is (RR) Handover Command */
7656 var GsmRrL3Message l3_msg := dec_GsmRrL3Message(ie.l3_info.payload);
7657 if (not match(l3_msg.header, t_RrL3Header(HANDOVER_COMMAND))) {
7658 setverdict(fail, "Failed to match Handover Command: ", l3_msg);
7659 return;
7660 }
7661
7662 /* Make sure that we've got SDCCH/8 on TS1 (expected to be hopping) */
7663 var ChannelDescription chan_desc := l3_msg.payload.ho_cmd.chan_desc;
7664 if (not match(chan_desc.chan_nr, t_RslChanNr_SDCCH8(1, ?))) {
7665 setverdict(fail, "Unexpected channel number: ", chan_desc.chan_nr);
7666 return;
7667 }
7668
7669 /* Make sure that hopping parameters (HSN/MAIO) match */
7670 f_TC_fh_params_match_chan_desc(fhp, chan_desc);
7671
7672 /* Make sure that Cell Channel Description IE is present */
7673 if (not ispresent(l3_msg.payload.ho_cmd.cell_chan_desc)) {
7674 setverdict(fail, "FH enabled, but Cell Channel Description IE is absent");
7675 return;
7676 }
7677
7678 /* Make sure that the Mobile Allocation (after time) IE is present and matches */
7679 var boolean ma_present := ispresent(l3_msg.payload.ho_cmd.mobile_allocation);
7680 if (ma_present) {
7681 f_TC_fh_params_match_ma(fhp, chan_desc.chan_nr.tn,
7682 l3_msg.payload.ho_cmd.mobile_allocation.v);
7683 } else {
7684 setverdict(fail, "FH enabled, but Mobile Allocation IE is absent");
7685 return;
7686 }
7687}
7688testcase TC_fh_params_handover_cmd() runs on test_CT {
7689 var FHParamsTrx fhp := f_TC_fh_params_gen();
7690
7691 f_init_vty();
7692
7693 /* (Re)configure TS0 as BCCH and TS1 as SDCCH8 on BTS1/TRX0 */
7694 f_vty_enter_cfg_trx(BSCVTY, bts := 1, trx := 0);
7695
7696 f_vty_transceive(BSCVTY, "timeslot 0");
7697 f_vty_transceive(BSCVTY, "phys_chan_config ccch");
7698 f_vty_transceive(BSCVTY, "exit"); /* go back */
7699
7700 f_vty_transceive(BSCVTY, "timeslot 1");
7701 f_vty_transceive(BSCVTY, "phys_chan_config sdcch8");
7702 f_vty_transceive(BSCVTY, "end"); /* we're done */
7703
7704 f_TC_fh_params_set(fhp, 1); /* Enable frequency hopping on BTS1 */
7705 f_vty_transceive(BSCVTY, "drop bts connection 1 oml");
7706
7707 f_init(2);
7708
7709 f_TC_fh_params_handover_cmd(fhp);
7710
7711 /* Disable frequency hopping on BTS1 */
7712 f_TC_fh_params_unset(fhp, 1);
7713
7714 /* (Re)configure TS0 as CCCH+SDCCH4+CBCH and TS1 as TCH/F */
7715 f_vty_enter_cfg_trx(BSCVTY, bts := 1, trx := 0);
7716
7717 f_vty_transceive(BSCVTY, "timeslot 0");
7718 f_vty_transceive(BSCVTY, "phys_chan_config ccch+sdcch4+cbch");
7719 f_vty_transceive(BSCVTY, "exit"); /* go back */
7720
7721 f_vty_transceive(BSCVTY, "timeslot 1");
7722 f_vty_transceive(BSCVTY, "phys_chan_config tch/f");
7723 f_vty_transceive(BSCVTY, "end"); /* we're done */
7724
7725 f_shutdown_helper();
7726}
7727
Vadim Yanitskiyca974032020-09-01 07:20:39 +07007728/* Verify the hopping parameters in System Information Type 4 */
7729testcase TC_fh_params_si4_cbch() runs on test_CT {
7730 var FHParamsTrx fhp := f_TC_fh_params_gen(tr_tn := 1);
7731 var ASP_RSL_Unitdata rx_rsl_ud;
7732 timer T := 5.0;
7733
7734 f_init_vty();
7735
7736 /* (Re)configure TS0 as BCCH and TS1 as SDCCH8+CBCH */
7737 f_vty_enter_cfg_trx(BSCVTY, trx := 0);
7738
7739 f_vty_transceive(BSCVTY, "timeslot 0");
7740 f_vty_transceive(BSCVTY, "phys_chan_config ccch");
7741 f_vty_transceive(BSCVTY, "exit"); /* go back */
7742
7743 f_vty_transceive(BSCVTY, "timeslot 1");
7744 f_vty_transceive(BSCVTY, "phys_chan_config sdcch8+cbch");
7745 f_vty_transceive(BSCVTY, "end"); /* we're done */
7746
7747 f_TC_fh_params_set(fhp); /* Enable frequency hopping */
7748 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
7749
7750 f_init(1);
7751
7752 T.start;
7753 alt {
7754 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_BCCH_INFO(RSL_SYSTEM_INFO_4))) -> value rx_rsl_ud {
7755 var RSL_IE_Body ie := rx_rsl_ud.rsl.ies[2].body; /* FULL BCCH Information IE */
7756 var SystemInformation si := dec_SystemInformation(ie.other.payload);
7757
7758 /* Make sure that what we decoded is System Information Type 4 */
7759 if (si.header.message_type != SYSTEM_INFORMATION_TYPE_4) {
7760 setverdict(fail, "RSL FULL BCCH Information IE contains: ", si);
7761 repeat;
7762 }
7763
7764 /* Make sure that CBCH Channel Description IE is present */
7765 if (not ispresent(si.payload.si4.cbch_chan_desc)) {
7766 setverdict(fail, "CBCH Channel Description IE is absent");
7767 break;
7768 }
7769
7770 /* Finally, check the hopping parameters (HSN, MAIO) */
7771 var ChannelDescription chan_desc := si.payload.si4.cbch_chan_desc.v;
7772 f_TC_fh_params_match_chan_desc(fhp, chan_desc);
7773
7774 /* 3GPP TS 44.018, section 9.1.36.2 "CBCH Mobile Allocation":
7775 * The CBCH Mobile Allocation IE *shall* be present if FH is enabled. */
7776 if (chan_desc.h and not ispresent(si.payload.si4.cbch_mobile_alloc)) {
7777 setverdict(fail, "FH enabled, but Mobile Allocation IE is absent");
7778 break;
7779 } else if (chan_desc.h and ispresent(si.payload.si4.cbch_mobile_alloc)) {
7780 f_TC_fh_params_match_ma(fhp, chan_desc.chan_nr.tn,
7781 si.payload.si4.cbch_mobile_alloc.v);
7782 }
7783 }
7784 [] IPA_RSL[0].receive { repeat; }
7785 [] T.timeout {
7786 setverdict(fail, "Timeout waiting for RSL BCCH INFOrmation (SI4)");
7787 }
7788 }
7789
7790 /* Disable frequency hopping */
7791 f_TC_fh_params_unset(fhp);
7792
Vadim Yanitskiy8bc46012020-09-06 12:38:01 +07007793 /* (Re)configure TS0 as CCCH+SDCCH4+CBCH and TS1 as TCH/F */
Vadim Yanitskiyca974032020-09-01 07:20:39 +07007794 f_vty_enter_cfg_trx(BSCVTY, trx := 0);
7795
7796 f_vty_transceive(BSCVTY, "timeslot 0");
Vadim Yanitskiy8bc46012020-09-06 12:38:01 +07007797 f_vty_transceive(BSCVTY, "phys_chan_config ccch+sdcch4+cbch");
Vadim Yanitskiyca974032020-09-01 07:20:39 +07007798 f_vty_transceive(BSCVTY, "exit"); /* go back */
7799
7800 f_vty_transceive(BSCVTY, "timeslot 1");
7801 f_vty_transceive(BSCVTY, "phys_chan_config tch/f");
7802 f_vty_transceive(BSCVTY, "end"); /* we're done */
7803
Vadim Yanitskiy21726312020-09-04 01:45:36 +07007804 f_shutdown_helper();
Vadim Yanitskiyca974032020-09-01 07:20:39 +07007805}
7806
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02007807template (value) PDU_BSSAP_LE ts_BSSMAP_LE_BSSLAP(template (value) BSSLAP_PDU bsslap)
7808 := ts_BSSMAP_LE_ConnInfo(BSSMAP_LE_PROT_BSSLAP, data := enc_BSSLAP_PDU(valueof(bsslap)));
7809
7810private function f_match_bsslap(PDU_BSSAP_LE got_bsslap_msg,
7811 template (present) BSSLAP_PDU expect_bsslap)
7812{
7813 var BSSLAP_PDU bsslap := dec_BSSLAP_PDU(got_bsslap_msg.pdu.bssmap.co_info.bsslap_apdu.data);
7814 if (not match(bsslap, expect_bsslap)) {
7815 log("EXPECTING BSSLAP: ", expect_bsslap);
7816 log("GOT BSSLAP: ", bsslap);
7817 setverdict(fail, "BSSLAP is not as expected");
7818 mtc.stop;
7819 }
7820 setverdict(pass);
7821}
7822
7823/* GAD: this is an Ellipsoid point with uncertainty circle, encoded as in 3GPP TS 23.032 §7.3.2. */
7824const octetstring gad_ell_point_unc_circle := '10b0646d0d5f6627'O;
7825
7826private function f_expect_bsslap(template (present) BSSLAP_PDU expect_rx_bsslap) runs on MSC_ConnHdlr {
7827 var PDU_BSSAP_LE rx_bsslap;
7828 BSSAP_LE.receive(tr_BSSMAP_LE_ConnInfo(BSSMAP_LE_PROT_BSSLAP, ?)) -> value(rx_bsslap);
7829 f_match_bsslap(rx_bsslap, expect_rx_bsslap);
7830}
7831
7832/* With an active lchan, start BSSMAP Perform Location Request on A interface, starting BSSMAP-LE Perform Location
7833 * Request on Lb interface. Either with or without the SMLC doing a BSSLAP TA Request. */
7834private function f_lcs_loc_req_for_active_ms(boolean do_ta_request := false) runs on MSC_ConnHdlr {
7835 f_sleep(1.0);
7836
7837 f_establish_fully(omit, omit);
7838 f_bssap_le_register_imsi(g_pars.imsi, omit);
7839
7840 BSSAP.send(valueof(ts_BSSMAP_Perform_Location_Request(ts_BSSMAP_Imsi(g_pars.imsi),
7841 ts_CellId_CGI('262'H, '42'H, 23, 42))));
7842
7843 var PDU_BSSAP_LE plr;
7844 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocReq(BSSMAP_LE_LOC_INFO_CURRENT_GEOGRAPHIC_LOC, ?, ?)) -> value(plr);
7845
7846 if (not do_ta_request) {
7847 /* verify TA Layer 3 in APDU. First the APDU type (BSSLAP), then the BSSLAP data contents. */
7848 var template BSSMAP_LE_IE_APDU expect_apdu := tr_BSSMAP_LE_APDU(BSSMAP_LE_PROT_BSSLAP, ?);
7849 if (not match(plr.pdu.bssmap.perf_loc_req.bsslap_apdu, expect_apdu)) {
7850 log("EXPECTING BSSMAP-LE APDU IE ", expect_apdu);
7851 log("GOT BSSMAP-LE APDU IE ", plr.pdu.bssmap.perf_loc_req.bsslap_apdu);
7852 setverdict(fail, "BSSMAP-LE APDU IE is not as expected");
7853 mtc.stop;
7854 }
7855 var template BSSLAP_PDU expect_ta_layer3 := tr_BSSLAP_TA_Layer3(tr_BSSLAP_IE_TA(0));
7856 var BSSLAP_PDU bsslap := dec_BSSLAP_PDU(plr.pdu.bssmap.perf_loc_req.bsslap_apdu.data);
7857 if (not match(bsslap, expect_ta_layer3)) {
7858 log("EXPECTING BSSLAP TA Layer 3: ", expect_ta_layer3);
7859 log("GOT BSSLAP: ", bsslap);
7860 setverdict(fail, "BSSLAP is not as expected");
7861 mtc.stop;
7862 }
7863 /* OsmoBSC directly sent the TA as BSSLAP APDU in the BSSMAP-LE Perform Location Request to the SMLC. The SMLC
7864 * has no need to request the TA from the BSC and directly responds. */
7865 } else {
7866 /* SMLC wants to ask the TA from the BSC explicitly in a BSSLAP TA Request message */
7867 BSSAP_LE.send(ts_BSSMAP_LE_BSSLAP(ts_BSSLAP_TA_Req));
7868 f_expect_bsslap(tr_BSSLAP_TA_Resp(?, ?));
7869 }
7870
7871 /* SMLC got the TA from the BSC, now responds with geo information data. */
7872 BSSAP_LE.send(ts_BSSMAP_LE_PerfLocResp(gad_ell_point_unc_circle, omit));
7873 BSSAP_LE.receive(BSSAP_LE_Conn_Prim:CONN_PRIM_DISC_IND);
7874 BSSAP.receive(tr_BSSMAP_Perform_Location_Response(tr_BSSMAP_IE_LocationEstimate(gad_ell_point_unc_circle)));
7875
7876 /* The LCS was using an active A-interface conn. It should still remain active after this. */
7877 f_mo_l3_transceive();
7878
7879 f_perform_clear(RSL);
7880
7881 f_sleep(2.0);
7882 setverdict(pass);
7883}
7884
7885/* With an active lchan, start BSSMAP Perform Location Request on A interface, starting BSSMAP-LE Perform Location
7886 * Request on Lb interface. Without the SMLC doing a BSSLAP TA Request. */
7887private function f_tc_lcs_loc_req_for_active_ms(charstring id) runs on MSC_ConnHdlr {
7888 f_lcs_loc_req_for_active_ms(false);
7889}
7890testcase TC_lcs_loc_req_for_active_ms() runs on test_CT {
7891 var MSC_ConnHdlr vc_conn;
7892 var TestHdlrParams pars := f_gen_test_hdlr_pars();
7893
7894 f_init(1, true);
7895 f_sleep(1.0);
7896 vc_conn := f_start_handler(refers(f_tc_lcs_loc_req_for_active_ms), pars);
7897 vc_conn.done;
7898}
7899
7900/* With an active lchan, start BSSMAP Perform Location Request on A interface, starting BSSMAP-LE Perform Location
7901 * Request on Lb interface. With the SMLC doing a BSSLAP TA Request. */
7902private function f_tc_lcs_loc_req_for_active_ms_ta_req(charstring id) runs on MSC_ConnHdlr {
7903 f_lcs_loc_req_for_active_ms(true);
7904}
7905testcase TC_lcs_loc_req_for_active_ms_ta_req() runs on test_CT {
7906 var MSC_ConnHdlr vc_conn;
7907 var TestHdlrParams pars := f_gen_test_hdlr_pars();
7908
7909 f_init(1, true);
7910 f_sleep(1.0);
7911 vc_conn := f_start_handler(refers(f_tc_lcs_loc_req_for_active_ms_ta_req), pars);
7912 vc_conn.done;
7913}
7914
7915/* Clear the A-interface conn only, without doing anything on Abis. Useful for LCS, for cases where there is only an A
7916 * conn without an active lchan. */
7917private function f_clear_A_conn() runs on MSC_ConnHdlr
7918{
7919 var BssmapCause cause := 0;
7920 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
7921 BSSAP.receive(tr_BSSMAP_ClearComplete);
7922 BSSAP.send(RAN_Conn_Prim:MSC_CONN_PRIM_DISC_REQ);
7923
7924 timer no_more_bssap := 5.0;
7925 no_more_bssap.start;
7926 alt {
7927 [] no_more_bssap.timeout { break; }
7928 [] BSSAP.receive(tr_BSSAP_BSSMAP) {
7929 setverdict(fail, "Expected no more BSSAP after Clear Complete");
7930 mtc.stop;
7931 }
7932 }
7933 setverdict(pass);
7934}
7935
7936/* Verify that the A-interface connection is still working, and then clear it, without doing anything on Abis. Useful
7937 * for LCS, for cases where there is only an A conn without an active lchan. */
7938private function f_verify_active_A_conn_and_clear() runs on MSC_ConnHdlr
7939{
7940 f_logp(BSCVTY, "f_verify_active_A_conn_and_clear: test A link, then clear");
7941
7942 /* When an lchan is active, we can send some L3 data from the BTS side and verify that it shows up on the other
7943 * side towards the MSC. When there is no lchan, this is not possible. To probe whether the A-interface
7944 * connection is still up, we need something that echos back on the A-interface. Another LCS request! */
7945 BSSAP.send(valueof(ts_BSSMAP_Perform_Location_Request(ts_BSSMAP_Imsi(g_pars.imsi),
7946 ts_CellId_CGI('262'H, '42'H, 23, 42))));
7947 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocReq(BSSMAP_LE_LOC_INFO_CURRENT_GEOGRAPHIC_LOC, ?, ?));
7948
7949 /* Right, the Perform Location Request showed up on Lb, now we can clear the A conn. */
7950 f_clear_A_conn();
7951 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocAbort(BSSMAP_LE_LCS_CAUSE_REQUEST_ABORTED));
7952 BSSAP_LE.receive(BSSAP_LE_Conn_Prim:CONN_PRIM_DISC_IND);
7953}
7954
7955/* With *no* active lchan, start BSSMAP Perform Location Request on A interface, starting BSSMAP-LE Perform Location
7956 * Request on Lb interface. BSC will Page for the subscriber as soon as we (virtual SMLC) request the TA via BSSLAP.
7957 */
7958private function f_tc_lcs_loc_req_for_idle_ms(charstring id) runs on MSC_ConnHdlr {
7959 f_sleep(1.0);
7960
7961 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
7962 f_bssap_le_register_imsi(g_pars.imsi, omit);
7963
7964 /* Register to receive the Paging Command */
7965 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
7966 g_chan_nr := new_chan_nr;
7967 f_rslem_register(0, g_chan_nr);
7968
7969 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
7970 valueof(ts_BSSMAP_Perform_Location_Request(ts_BSSMAP_Imsi(g_pars.imsi),
7971 ts_CellId_CGI('001'H, '01'H, 1, 0)))));
7972 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
7973
7974 var PDU_BSSAP_LE plr;
7975 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocReq(BSSMAP_LE_LOC_INFO_CURRENT_GEOGRAPHIC_LOC, ?, ?)) -> value(plr);
7976
7977 /* SMLC wants to ask the TA from the BSC explicitly in a BSSLAP TA Request message */
7978 BSSAP_LE.send(ts_BSSMAP_LE_BSSLAP(ts_BSSLAP_TA_Req));
7979
7980 /* OsmoBSC needs to Page */
7981 RSL.receive(tr_RSL_PAGING_CMD(tr_MI_IMSI(g_pars.imsi)));
7982 f_logp(BSCVTY, "got Paging Command");
7983
7984 /* MS requests channel. Since the Paging was for LCS, the Paging Response does not trigger a Complete Layer 3 to
7985 * the MSC, and releases the lchan directly. */
7986 f_perform_compl_l3(RSL, ts_PAG_RESP(valueof(ts_MI_IMSI_LV(g_pars.imsi))), do_clear := false, expect_bssmap_l3 := false);
7987 f_expect_lchan_rel(RSL);
7988
7989 /* From the Paging Response, the TA is now known to the BSC, and it responds to the SMLC. */
7990
7991 f_expect_bsslap(tr_BSSLAP_TA_Resp(?, ?));
7992
7993 /* SMLC got the TA from the BSC, now responds with geo information data. */
7994 BSSAP_LE.send(ts_BSSMAP_LE_PerfLocResp(gad_ell_point_unc_circle, omit));
7995 BSSAP_LE.receive(BSSAP_LE_Conn_Prim:CONN_PRIM_DISC_IND);
7996
7997 BSSAP.receive(tr_BSSMAP_Perform_Location_Response(tr_BSSMAP_IE_LocationEstimate(gad_ell_point_unc_circle)));
7998
7999 /* The lchan is gone, the A-interface conn was created for the LCS only.
8000 * Still it is clearly the MSC's job to decide whether to tear down the conn or not. */
8001 f_verify_active_A_conn_and_clear();
8002
8003 f_sleep(2.0);
8004 setverdict(pass);
8005}
8006testcase TC_lcs_loc_req_for_idle_ms() runs on test_CT {
8007 var MSC_ConnHdlr vc_conn;
8008 var TestHdlrParams pars := f_gen_test_hdlr_pars();
8009
8010 f_init(1, true);
8011 f_sleep(1.0);
8012
8013 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
8014 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
8015
8016 vc_conn := f_start_handler(refers(f_tc_lcs_loc_req_for_idle_ms), pars);
8017 vc_conn.done;
8018}
8019
8020/* With no active lchan, start BSSMAP Perform Location Request on A interface, but omit IMSI; expect failure response.
8021 */
8022private function f_tc_lcs_loc_req_no_subscriber(charstring id) runs on MSC_ConnHdlr {
8023 f_sleep(1.0);
8024
8025 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
8026 f_bssap_le_register_imsi(g_pars.imsi, omit);
8027
8028 /* provoke an abort by omitting both IMSI and IMEI */
8029 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
8030 valueof(ts_BSSMAP_Perform_Location_Request(omit,
8031 ts_CellId_CGI('262'H, '42'H, 23, 42)))));
8032 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
8033
8034 /* BSC tells MSC about failure */
8035 BSSAP.receive(tr_BSSMAP_Perform_Location_Response(
8036 locationEstimate := omit, positioningData := omit,
8037 lCS_Cause := tr_BSSMAP_LcsCause(BSSMAP_LCS_CAUSE_DATA_MISSING_IN_REQ)));
8038
8039 /* There is no lchan. Still the MSC's job to decide whether to tear down the conn or not. */
8040 f_verify_active_A_conn_and_clear();
8041
8042 f_sleep(2.0);
8043 setverdict(pass);
8044}
8045testcase TC_lcs_loc_req_no_subscriber() runs on test_CT {
8046 var MSC_ConnHdlr vc_conn;
8047 var TestHdlrParams pars := f_gen_test_hdlr_pars();
8048
8049 f_init(1, true);
8050 f_sleep(1.0);
8051
8052 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
8053 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
8054
8055 vc_conn := f_start_handler(refers(f_tc_lcs_loc_req_no_subscriber), pars);
8056 vc_conn.done;
8057}
8058
8059/* With an active lchan, start a Perform Location Request on the A-interface, but virtual SMLC does not answer with
8060 * BSSMAP-LE Perform Location Response (before or after sending a BSSLAP TA Request) */
8061private function f_lcs_loc_req_for_active_ms_le_timeout(boolean do_ta) runs on MSC_ConnHdlr {
8062 f_sleep(1.0);
8063
8064 f_establish_fully(omit, omit);
8065 f_bssap_le_register_imsi(g_pars.imsi, omit);
8066
8067 BSSAP.send(valueof(ts_BSSMAP_Perform_Location_Request(ts_BSSMAP_Imsi(g_pars.imsi),
8068 ts_CellId_CGI('262'H, '42'H, 23, 42))));
8069
8070 var PDU_BSSAP_LE plr;
8071 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocReq(BSSMAP_LE_LOC_INFO_CURRENT_GEOGRAPHIC_LOC, ?, ?)) -> value(plr);
8072
8073 if (do_ta) {
8074 /* SMLC wants to ask the TA from the BSC explicitly in a BSSLAP TA Request message */
8075 BSSAP_LE.send(ts_BSSMAP_LE_BSSLAP(ts_BSSLAP_TA_Req));
8076 f_expect_bsslap(tr_BSSLAP_TA_Resp(?, ?));
8077 }
8078
8079 /* SMLC fails to respond, BSC runs into timeout */
8080 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocAbort(BSSMAP_LE_LCS_CAUSE_SYSTEM_FAILURE));
8081 BSSAP_LE.receive(BSSAP_LE_Conn_Prim:CONN_PRIM_DISC_IND);
8082
8083 BSSAP.receive(tr_BSSMAP_Perform_Location_Response(
8084 locationEstimate := omit, positioningData := omit,
8085 lCS_Cause := tr_BSSMAP_LcsCause(BSSMAP_LCS_CAUSE_SYSTEM_FAILURE)));
8086
8087 /* There is no lchan. Still the MSC's job to decide whether to tear down the conn or not. */
8088 f_verify_active_A_conn_and_clear();
8089
8090 f_sleep(2.0);
8091 setverdict(pass);
8092}
8093
8094/* With an active lchan, start a Perform Location Request on the A-interface, but virtual SMLC does not answer with
8095 * BSSMAP-LE Perform Location Response, without sending a BSSLAP TA Request. */
8096private function f_tc_lcs_loc_req_for_active_ms_le_timeout(charstring id) runs on MSC_ConnHdlr {
8097 f_lcs_loc_req_for_active_ms_le_timeout(false);
8098}
8099
8100testcase TC_lcs_loc_req_for_active_ms_le_timeout() runs on test_CT {
8101 var MSC_ConnHdlr vc_conn;
8102 var TestHdlrParams pars := f_gen_test_hdlr_pars();
8103
8104 f_init(1, true);
8105 f_sleep(1.0);
8106 vc_conn := f_start_handler(refers(f_tc_lcs_loc_req_for_active_ms_le_timeout), pars);
8107 vc_conn.done;
8108}
8109
8110/* With an active lchan, start a Perform Location Request on the A-interface, but virtual SMLC does not answer with
8111 * BSSMAP-LE Perform Location Response, after sending a BSSLAP TA Request. */
8112private function f_tc_lcs_loc_req_for_active_ms_le_timeout2(charstring id) runs on MSC_ConnHdlr {
8113 f_lcs_loc_req_for_active_ms_le_timeout(true);
8114}
8115
8116testcase TC_lcs_loc_req_for_active_ms_le_timeout2() runs on test_CT {
8117 var MSC_ConnHdlr vc_conn;
8118 var TestHdlrParams pars := f_gen_test_hdlr_pars();
8119
8120 f_init(1, true);
8121 f_sleep(1.0);
8122 vc_conn := f_start_handler(refers(f_tc_lcs_loc_req_for_active_ms_le_timeout2), pars);
8123 vc_conn.done;
8124}
8125
8126/* With *no* active lchan, start a Perform Location Request, expecting that the MS will be Paged. */
8127private function f_tc_lcs_loc_req_for_idle_ms_no_pag_resp(charstring id) runs on MSC_ConnHdlr {
8128 f_sleep(1.0);
8129
8130 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
8131 f_bssap_le_register_imsi(g_pars.imsi, omit);
8132
8133 /* Register to receive the Paging Command */
8134 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
8135 g_chan_nr := new_chan_nr;
8136 f_rslem_register(0, g_chan_nr);
8137
8138 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
8139 valueof(ts_BSSMAP_Perform_Location_Request(ts_BSSMAP_Imsi(g_pars.imsi),
8140 ts_CellId_CGI('001'H, '01'H, 1, 0)))));
8141 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
8142
8143 var PDU_BSSAP_LE plr;
8144 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocReq(BSSMAP_LE_LOC_INFO_CURRENT_GEOGRAPHIC_LOC, ?, ?)) -> value(plr);
8145
8146 /* SMLC wants to ask the TA from the BSC explicitly in a BSSLAP TA Request message */
8147 BSSAP_LE.send(ts_BSSMAP_LE_BSSLAP(ts_BSSLAP_TA_Req));
8148
8149 /* OsmoBSC needs to Page */
8150 var PDU_BSSAP_LE rx_bsslap;
8151 alt {
8152 [] RSL.receive(tr_RSL_PAGING_CMD(tr_MI_IMSI(g_pars.imsi))) {
8153 f_logp(BSCVTY, "got Paging Command");
8154 repeat;
8155 }
8156 [] BSSAP_LE.receive(tr_BSSMAP_LE_ConnInfo(BSSMAP_LE_PROT_BSSLAP, ?)) -> value(rx_bsslap) {
8157 /* MS does not respond to Paging, TA Req runs into timeout. */
8158 f_match_bsslap(rx_bsslap, tr_BSSLAP_Abort(?));
8159 }
8160 }
8161
8162 /* SMLC responds with failure */
8163 BSSAP_LE.send(ts_BSSMAP_LE_PerfLocResp(omit, BSSMAP_LE_LCS_CAUSE_REQUEST_ABORTED));
8164 BSSAP_LE.receive(BSSAP_LE_Conn_Prim:CONN_PRIM_DISC_IND);
8165
8166 /* BSC tells MSC about failure */
8167 BSSAP.receive(tr_BSSMAP_Perform_Location_Response(
8168 locationEstimate := omit, positioningData := omit,
8169 lCS_Cause := tr_BSSMAP_LcsCause(BSSMAP_LCS_CAUSE_REQUEST_ABORTED)));
8170
8171 /* There is no lchan. Still the MSC's job to decide whether to tear down the conn or not. */
8172 f_verify_active_A_conn_and_clear();
8173
8174 f_sleep(2.0);
8175 setverdict(pass);
8176}
8177testcase TC_lcs_loc_req_for_idle_ms_no_pag_resp() runs on test_CT {
8178 var MSC_ConnHdlr vc_conn;
8179 var TestHdlrParams pars := f_gen_test_hdlr_pars();
8180
8181 f_init(1, true);
8182 f_sleep(1.0);
8183
8184 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
8185 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
8186
8187 vc_conn := f_start_handler(refers(f_tc_lcs_loc_req_for_idle_ms_no_pag_resp), pars);
8188 vc_conn.done;
8189}
8190
8191/* During an ongoing Location Request, the MS sends a CM Service Request. Expect the same A-conn to be re-used / taken
8192 * over. */
8193private function f_tc_cm_service_during_lcs_loc_req(charstring id) runs on MSC_ConnHdlr {
8194 f_sleep(1.0);
8195
8196 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
8197 f_bssap_le_register_imsi(g_pars.imsi, omit);
8198
8199 /* Register to receive the Paging Command */
8200 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
8201 g_chan_nr := new_chan_nr;
8202 f_rslem_register(0, g_chan_nr);
8203
8204 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
8205 valueof(ts_BSSMAP_Perform_Location_Request(ts_BSSMAP_Imsi(g_pars.imsi),
8206 ts_CellId_CGI('001'H, '01'H, 1, 0)))));
8207 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
8208
8209 var PDU_BSSAP_LE plr;
8210 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocReq(BSSMAP_LE_LOC_INFO_CURRENT_GEOGRAPHIC_LOC, ?, ?)) -> value(plr);
8211
8212 /* As the A-interface conn was established for LCS, the MS coincidentally decides to issue a CM Service Request
8213 * and establish Layer 3. It should use the existing A-interface conn. */
8214 f_perform_compl_l3(RSL, valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, valueof(ts_MI_IMSI_LV(g_pars.imsi)))),
8215 do_clear := false, expect_bssmap_l3 := true);
8216
8217 /* SMLC wants to ask the TA from the BSC explicitly in a BSSLAP TA Request message */
8218 BSSAP_LE.send(ts_BSSMAP_LE_BSSLAP(ts_BSSLAP_TA_Req));
8219
8220 /* OsmoBSC already has an lchan, no need to Page, just returns the TA */
8221 f_expect_bsslap(tr_BSSLAP_TA_Resp(?, ?));
8222
8223 /* SMLC got the TA from the BSC, now responds with geo information data. */
8224 BSSAP_LE.send(ts_BSSMAP_LE_PerfLocResp(gad_ell_point_unc_circle, omit));
8225 BSSAP_LE.receive(BSSAP_LE_Conn_Prim:CONN_PRIM_DISC_IND);
8226 BSSAP.receive(tr_BSSMAP_Perform_Location_Response(tr_BSSMAP_IE_LocationEstimate(gad_ell_point_unc_circle)));
8227
8228 /* The lchan should still exist, it was from a CM Service Request. */
8229 f_mo_l3_transceive();
8230
8231 f_perform_clear(RSL);
8232
8233 f_sleep(2.0);
8234 setverdict(pass);
8235}
8236testcase TC_cm_service_during_lcs_loc_req() runs on test_CT {
8237 var MSC_ConnHdlr vc_conn;
8238 var TestHdlrParams pars := f_gen_test_hdlr_pars();
8239
8240 f_init(1, true);
8241 f_sleep(1.0);
8242
8243 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
8244 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
8245
8246 vc_conn := f_start_handler(refers(f_tc_cm_service_during_lcs_loc_req), pars);
8247 vc_conn.done;
8248}
8249
8250/* During an ongoing Perform Location Request, do a Handover, an expect a BSSLAP Reset message from the BSC to indicate
8251 * the new lchan after handover. */
8252private function f_tc_ho_during_lcs_loc_req(charstring id) runs on MSC_ConnHdlr {
8253 f_sleep(1.0);
8254
8255 f_establish_fully(omit, omit);
8256 f_bssap_le_register_imsi(g_pars.imsi, omit);
8257
8258 BSSAP.send(valueof(ts_BSSMAP_Perform_Location_Request(ts_BSSMAP_Imsi(g_pars.imsi),
8259 ts_CellId_CGI('262'H, '42'H, 23, 42))));
8260
8261 var PDU_BSSAP_LE plr;
8262 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocReq(BSSMAP_LE_LOC_INFO_CURRENT_GEOGRAPHIC_LOC, ?, ?)) -> value(plr);
8263
8264 /* SMLC ponders the Location Request, in the meantime the BSC decides to handover */
8265 f_bts_0_cfg(BSCVTY, {"neighbor bts 1"});
8266
8267 var HandoverState hs := {
8268 rr_ho_cmpl_seen := false,
8269 handover_done := false,
8270 old_chan_nr := -
8271 };
8272 /* issue hand-over command on VTY */
8273 f_vty_handover(BSCVTY, 0, 0, g_chan_nr, 1);
8274 /* temporarily suspend DChan processing on BTS1 to avoid race with RSLEM_register */
8275 f_rslem_suspend(RSL1_PROC);
8276
8277 /* From the MGW perspective, a handover is is characterized by
8278 * performing one MDCX operation with the MGW. So we expect to see
8279 * one more MDCX during handover. */
8280 g_media.mgcp_conn[0].mdcx_seen_exp := g_media.mgcp_conn[0].crcx_seen_exp + 1;
8281
8282 alt {
8283 [] as_handover(hs);
8284 }
8285
8286 var PDU_BSSAP_LE rx_bsslap;
8287
8288 interleave {
8289 /* Expect the BSC to inform the MSC about the handover */
8290 [] BSSAP.receive(tr_BSSMAP_HandoverPerformed);
8291
8292 /* Expect the BSC to inform the SMLC about the handover */
8293 [] BSSAP_LE.receive(tr_BSSMAP_LE_ConnInfo(BSSMAP_LE_PROT_BSSLAP, ?)) -> value(rx_bsslap) {
8294 f_match_bsslap(rx_bsslap, tr_BSSLAP_Reset(BSSLAP_CAUSE_INTRA_BSS_HO));
8295 }
8296 }
8297
8298 /* SMLC now responds with geo information data. */
8299 BSSAP_LE.send(ts_BSSMAP_LE_PerfLocResp(gad_ell_point_unc_circle, omit));
8300 BSSAP_LE.receive(BSSAP_LE_Conn_Prim:CONN_PRIM_DISC_IND);
8301 BSSAP.receive(tr_BSSMAP_Perform_Location_Response(tr_BSSMAP_IE_LocationEstimate(gad_ell_point_unc_circle)));
8302
8303 /* lchan still active */
8304 f_mo_l3_transceive(RSL1);
8305
8306 /* MSC decides it is done now. */
8307 f_perform_clear(RSL1);
8308
8309 f_sleep(2.0);
8310 setverdict(pass);
8311}
8312testcase TC_ho_during_lcs_loc_req() runs on test_CT {
8313 var MSC_ConnHdlr vc_conn;
8314 var TestHdlrParams pars := f_gen_test_hdlr_pars();
8315
8316 f_init(2, true);
8317 f_sleep(1.0);
8318 vc_conn := f_start_handler(refers(f_tc_ho_during_lcs_loc_req), pars);
8319 vc_conn.done;
8320}
8321
Neels Hofmeyrbf037052020-10-28 22:52:02 +00008322/* Attempt Complete Layer 3 without any MSC available (OS#4832) */
8323private function f_tc_no_msc(charstring id) runs on MSC_ConnHdlr {
8324 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
8325
8326 /* Also disable attach for the single connected MSC */
8327 f_vty_msc_allow_attach(BSCVTY, { false });
8328
8329 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) ));
8330 f_chan_est(g_pars.ra, l3_enc, g_pars.link_id, g_pars.fn);
8331
8332 /* No MSC is found, expecting a proper release on RSL */
8333 interleave {
8334 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_RELEASE)) {
8335 f_logp(BSCVTY, "Got RSL RR Release");
8336 }
8337 [] RSL.receive(tr_RSL_DEACT_SACCH(g_chan_nr)) {
8338 f_logp(BSCVTY, "Got RSL Deact SACCH");
8339 }
8340 [] RSL.receive(tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL)) {
8341 f_logp(BSCVTY, "Got RSL RF Chan Rel, sending Rel Ack");
8342 RSL.send(ts_RSL_RF_CHAN_REL_ACK(g_chan_nr));
8343 }
8344 }
8345 setverdict(pass);
8346}
8347testcase TC_no_msc() runs on test_CT {
8348
8349 f_init(1, true);
8350 f_sleep(1.0);
8351 var MSC_ConnHdlr vc_conn;
8352 var TestHdlrParams pars := f_gen_test_hdlr_pars();
8353
8354 f_ctrs_bsc_init(counternames_bsc_mscpool);
8355
8356 vc_conn := f_start_handler(refers(f_tc_no_msc), pars);
8357 vc_conn.done;
8358
8359 f_ctrs_bsc_add("mscpool:subscr:no_msc");
8360 f_ctrs_bsc_verify();
8361}
8362
Harald Welte0ea2d5e2018-04-07 21:40:29 +02008363/* Dyn PDCH todo:
8364 * activate OSMO as TCH/F
8365 * activate OSMO as TCH/H
8366 * does the BSC-located PCU socket get the updated INFO?
8367 * what if no PCU is connected at the time?
8368 * is the info correct on delayed PCU (re)connect?
8369 */
Harald Welte94e0c342018-04-07 11:33:23 +02008370
Harald Welte28d943e2017-11-25 15:00:50 +01008371control {
Harald Welte898113b2018-01-31 18:32:21 +01008372 /* CTRL interface testing */
Harald Welte4003d112017-12-09 22:35:39 +01008373 execute( TC_ctrl_msc_connection_status() );
Stefan Sperlingb041b3d2018-01-03 17:14:55 +01008374 execute( TC_ctrl_msc0_connection_status() );
Harald Welte96c94412017-12-09 03:12:45 +01008375 execute( TC_ctrl() );
Neels Hofmeyrf246a922020-05-13 02:27:10 +02008376 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_SCCPlite_SERVER) {
Pau Espin Pedrol5a2d7432019-06-07 19:43:45 +02008377 execute( TC_ctrl_location() );
8378 }
Harald Welte898113b2018-01-31 18:32:21 +01008379
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +02008380 execute( TC_si_default() );
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02008381 execute( TC_si2quater_2_earfcns() );
8382 execute( TC_si2quater_3_earfcns() );
8383 execute( TC_si2quater_4_earfcns() );
8384 execute( TC_si2quater_5_earfcns() );
8385 execute( TC_si2quater_6_earfcns() );
Neels Hofmeyrad132f22020-07-08 02:20:16 +02008386 execute( TC_si2quater_12_earfcns() );
8387 execute( TC_si2quater_23_earfcns() );
8388 execute( TC_si2quater_32_earfcns() );
8389 execute( TC_si2quater_33_earfcns() );
8390 execute( TC_si2quater_42_earfcns() );
8391 execute( TC_si2quater_48_earfcns() );
8392 execute( TC_si2quater_49_earfcns() );
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02008393 execute( TC_si_acc_rotate() );
Alexander Couzens4ad3a352020-09-10 22:29:12 +02008394 execute( TC_si_acc_ramp_rotate() );
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +02008395
Harald Welte898113b2018-01-31 18:32:21 +01008396 /* RSL DCHAN Channel ACtivation / Deactivation */
Harald Welteae026692017-12-09 01:03:01 +01008397 execute( TC_chan_act_noreply() );
Harald Welte4003d112017-12-09 22:35:39 +01008398 execute( TC_chan_act_counter() );
Harald Welteae026692017-12-09 01:03:01 +01008399 execute( TC_chan_act_ack_noest() );
Philipp Maier9c60a622020-07-09 15:08:46 +02008400 execute( TC_chan_act_ack_noest_emerg() );
Philipp Maier606f07d2020-08-12 17:21:58 +02008401 execute( TC_chan_rqd_emerg_deny() );
Harald Welteae026692017-12-09 01:03:01 +01008402 execute( TC_chan_act_ack_est_ind_noreply() );
8403 execute( TC_chan_act_ack_est_ind_refused() );
Harald Welte618ef642017-12-14 14:58:20 +01008404 execute( TC_chan_act_nack() );
Harald Welte799c97b2017-12-14 17:50:30 +01008405 execute( TC_chan_exhaustion() );
Vadim Yanitskiy1ff1fdf2018-11-27 01:32:57 +07008406 execute( TC_chan_deact_silence() );
Harald Welte4003d112017-12-09 22:35:39 +01008407 execute( TC_chan_rel_rll_rel_ind() );
8408 execute( TC_chan_rel_conn_fail() );
8409 execute( TC_chan_rel_hard_clear() );
Harald Welte99787102019-02-04 10:41:36 +01008410 execute( TC_chan_rel_hard_clear_csfb() );
Harald Welted8c36cd2017-12-09 23:05:31 +01008411 execute( TC_chan_rel_hard_rlsd() );
Harald Welte550daf92018-06-11 19:22:13 +02008412 execute( TC_chan_rel_hard_rlsd_ms_dead() );
Harald Welte85804d42017-12-10 14:11:58 +01008413 execute( TC_chan_rel_a_reset() );
Pau Espin Pedrolc675b612020-01-09 19:55:40 +01008414 execute( TC_chan_rel_sccp_tiar_timeout() );
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02008415 execute( TC_chan_rel_rr_cause() );
Harald Welte6f521d82017-12-11 19:52:02 +01008416
Harald Weltecfe2c962017-12-15 12:09:32 +01008417 execute( TC_outbound_connect() );
Harald Welte898113b2018-01-31 18:32:21 +01008418
8419 /* Assignment related */
Harald Welte16a4adf2017-12-14 18:54:01 +01008420 execute( TC_assignment_cic_only() );
Harald Welte235ebf12017-12-15 14:18:16 +01008421 execute( TC_assignment_csd() );
8422 execute( TC_assignment_ctm() );
8423 execute( TC_assignment_sign() );
Pau Espin Pedrol07866632020-09-03 19:10:55 +02008424 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
8425 execute( TC_assignment_aoip_tla_v6() );
8426 }
Harald Welte235ebf12017-12-15 14:18:16 +01008427 execute( TC_assignment_fr_a5_0() );
8428 execute( TC_assignment_fr_a5_1() );
Neels Hofmeyrf246a922020-05-13 02:27:10 +02008429 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
Harald Welte8f67d1d2018-05-25 20:38:42 +02008430 execute( TC_assignment_fr_a5_1_codec_missing() );
8431 }
Harald Welte235ebf12017-12-15 14:18:16 +01008432 execute( TC_assignment_fr_a5_3() );
8433 execute( TC_assignment_fr_a5_4() );
Harald Welte3c86ea02018-05-10 22:28:05 +02008434 execute( TC_ciph_mode_a5_0() );
8435 execute( TC_ciph_mode_a5_1() );
8436 execute( TC_ciph_mode_a5_3() );
Harald Welte16a4adf2017-12-14 18:54:01 +01008437
Harald Welte60aa5762018-03-21 19:33:13 +01008438 execute( TC_assignment_codec_fr() );
8439 execute( TC_assignment_codec_hr() );
8440 execute( TC_assignment_codec_efr() );
8441 execute( TC_assignment_codec_amr_f() );
8442 execute( TC_assignment_codec_amr_h() );
Philipp Maier8a581d22019-03-26 18:32:48 +01008443
Neels Hofmeyrf246a922020-05-13 02:27:10 +02008444 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
Philipp Maier8a581d22019-03-26 18:32:48 +01008445 execute( TC_assignment_codec_amr_f_S1() );
8446 execute( TC_assignment_codec_amr_h_S1() );
8447 execute( TC_assignment_codec_amr_f_S124() );
8448 execute( TC_assignment_codec_amr_h_S124() );
8449 execute( TC_assignment_codec_amr_f_S0() );
8450 execute( TC_assignment_codec_amr_f_S02() );
8451 execute( TC_assignment_codec_amr_f_S024() );
8452 execute( TC_assignment_codec_amr_f_S0247() );
8453 execute( TC_assignment_codec_amr_h_S0() );
8454 execute( TC_assignment_codec_amr_h_S02() );
8455 execute( TC_assignment_codec_amr_h_S024() );
8456 execute( TC_assignment_codec_amr_h_S0247() );
8457 execute( TC_assignment_codec_amr_f_S01234567() );
8458 execute( TC_assignment_codec_amr_f_S0234567() );
8459 execute( TC_assignment_codec_amr_f_zero() );
8460 execute( TC_assignment_codec_amr_f_unsupp() );
8461 execute( TC_assignment_codec_amr_h_S7() );
Neels Hofmeyr21863562020-11-26 00:34:33 +00008462 execute( TC_assignment_codec_amr_f_start_mode_auto() );
8463 execute( TC_assignment_codec_amr_h_start_mode_auto() );
Neels Hofmeyr3eb94562020-11-26 02:40:26 +00008464 execute( TC_assignment_codec_amr_f_start_mode_4() );
8465 execute( TC_assignment_codec_amr_h_start_mode_4() );
Neels Hofmeyr454d7922020-11-26 02:24:57 +00008466 execute( TC_assignment_codec_amr_startmode_cruft() );
Philipp Maier8a581d22019-03-26 18:32:48 +01008467 }
Harald Welte60aa5762018-03-21 19:33:13 +01008468
Philipp Maierac09bfc2019-01-08 13:41:39 +01008469 execute( TC_assignment_codec_fr_exhausted_req_hr() );
8470 execute( TC_assignment_codec_fr_exhausted_req_fr() );
8471 execute( TC_assignment_codec_fr_exhausted_req_fr_hr() );
8472 execute( TC_assignment_codec_fr_exhausted_req_hr_fr() );
8473 execute( TC_assignment_codec_hr_exhausted_req_fr() );
8474 execute( TC_assignment_codec_hr_exhausted_req_hr() );
8475 execute( TC_assignment_codec_hr_exhausted_req_hr_fr() );
8476 execute( TC_assignment_codec_hr_exhausted_req_fr_hr() );
8477 execute( TC_assignment_codec_req_hr_fr() );
8478 execute( TC_assignment_codec_req_fr_hr() );
8479
Pau Espin Pedrol58cf6822019-05-28 18:11:33 +02008480 if (mp_enable_osmux_test) {
8481 execute( TC_assignment_osmux() );
8482 }
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02008483
Harald Welte898113b2018-01-31 18:32:21 +01008484 /* RLL Establish Indication on inactive DCHAN / SAPI */
Harald Welte5cd20ed2017-12-13 21:03:20 +01008485 execute( TC_rll_est_ind_inact_lchan() );
8486 execute( TC_rll_est_ind_inval_sapi1() );
8487 execute( TC_rll_est_ind_inval_sapi3() );
8488 execute( TC_rll_est_ind_inval_sacch() );
8489
Vadim Yanitskiy61f784a2020-10-01 21:12:19 +07008490 /* DLCI / RSL Link ID conversion for MO/MT messages on SAPI0/SAPI3 */
8491 execute( TC_tch_dlci_link_id_sapi() );
8492
Vadim Yanitskiy6ef5dfa2020-08-28 18:04:41 +07008493 /* SAPI N Reject triggered by RLL establishment failures */
8494 execute( TC_rll_rel_ind_sapi_n_reject() );
8495 execute( TC_rll_err_ind_sapi_n_reject() );
8496 execute( TC_rll_timeout_sapi_n_reject() );
8497
Harald Welte898113b2018-01-31 18:32:21 +01008498 /* Paging related tests */
Harald Welte6f521d82017-12-11 19:52:02 +01008499 execute( TC_paging_imsi_nochan() );
8500 execute( TC_paging_tmsi_nochan() );
8501 execute( TC_paging_tmsi_any() );
8502 execute( TC_paging_tmsi_sdcch() );
8503 execute( TC_paging_tmsi_tch_f() );
8504 execute( TC_paging_tmsi_tch_hf() );
8505 execute( TC_paging_imsi_nochan_cgi() );
8506 execute( TC_paging_imsi_nochan_lac_ci() );
8507 execute( TC_paging_imsi_nochan_ci() );
8508 execute( TC_paging_imsi_nochan_lai() );
8509 execute( TC_paging_imsi_nochan_lac() );
8510 execute( TC_paging_imsi_nochan_all() );
Harald Welte751d3eb2018-01-31 15:51:06 +01008511 execute( TC_paging_imsi_nochan_plmn_lac_rnc() );
8512 execute( TC_paging_imsi_nochan_rnc() );
8513 execute( TC_paging_imsi_nochan_lac_rnc() );
8514 execute( TC_paging_imsi_nochan_lacs() );
8515 execute( TC_paging_imsi_nochan_lacs_empty() );
Stefan Sperling049a86e2018-03-20 15:51:00 +01008516 execute( TC_paging_imsi_nochan_cgi_unknown_cid() );
Harald Welte10985002017-12-12 09:29:15 +01008517 execute( TC_paging_imsi_a_reset() );
Harald Weltee65d40e2017-12-13 00:09:06 +01008518 execute( TC_paging_imsi_load() );
Philipp Maier779a7922018-02-16 11:00:37 +01008519 execute( TC_paging_counter() );
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01008520 execute( TC_paging_resp_unsol() );
Harald Welte4e9b9cc2017-12-14 18:31:02 +01008521
8522 execute( TC_rsl_drop_counter() );
Stefan Sperling830dc9d2018-02-12 21:08:28 +01008523 execute( TC_rsl_unknown_unit_id() );
8524
8525 execute( TC_oml_unknown_unit_id() );
Harald Welte898113b2018-01-31 18:32:21 +01008526
8527 execute( TC_classmark() );
Harald Welteeddf0e92020-06-21 19:42:15 +02008528 execute( TC_common_id() );
Harald Welte898113b2018-01-31 18:32:21 +01008529 execute( TC_unsol_ass_fail() );
Harald Welteea99a002018-01-31 20:46:43 +01008530 execute( TC_unsol_ass_compl() );
Harald Weltefbf9b5e2018-01-31 20:41:23 +01008531 execute( TC_unsol_ho_fail() );
Harald Weltee3bd6582018-01-31 22:51:25 +01008532 execute( TC_err_82_short_msg() );
Harald Weltee9e02e42018-01-31 23:36:25 +01008533 execute( TC_err_84_unknown_msg() );
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01008534
Harald Welte261af4b2018-02-12 21:20:39 +01008535 execute( TC_ho_int() );
Neels Hofmeyr5f144212020-11-03 15:41:58 +00008536 execute( TC_ho_int_radio_link_failure() );
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01008537
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01008538 execute( TC_ho_out_of_this_bsc() );
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02008539 execute( TC_ho_out_fail_no_msc_response() );
8540 execute( TC_ho_out_fail_rr_ho_failure() );
Neels Hofmeyrd8a602c2019-07-09 19:46:01 +02008541 execute( TC_ho_out_fail_no_result_after_ho_cmd() );
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01008542
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01008543 execute( TC_ho_into_this_bsc() );
Pau Espin Pedrol07866632020-09-03 19:10:55 +02008544 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
8545 execute( TC_ho_into_this_bsc_tla_v6() );
8546 }
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01008547 execute( TC_ho_in_fail_msc_clears() );
8548 execute( TC_ho_in_fail_msc_clears_after_ho_detect() );
8549 execute( TC_ho_in_fail_no_detect() );
8550 execute( TC_ho_in_fail_no_detect2() );
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01008551
Neels Hofmeyr91401012019-07-11 00:42:35 +02008552 execute( TC_ho_neighbor_config_1() );
8553 execute( TC_ho_neighbor_config_2() );
8554 execute( TC_ho_neighbor_config_3() );
8555 execute( TC_ho_neighbor_config_4() );
8556 execute( TC_ho_neighbor_config_5() );
8557 execute( TC_ho_neighbor_config_6() );
8558 execute( TC_ho_neighbor_config_7() );
8559
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01008560 execute( TC_bssap_rlsd_does_not_cause_bssmap_reset() );
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01008561 execute( TC_bssmap_clear_does_not_cause_bssmap_reset() );
Neels Hofmeyrfd445c32018-03-09 15:39:31 +01008562 execute( TC_ms_rel_ind_does_not_cause_bssmap_reset() );
Harald Welte94e0c342018-04-07 11:33:23 +02008563
8564 execute( TC_dyn_pdch_ipa_act_deact() );
8565 execute( TC_dyn_pdch_ipa_act_nack() );
8566 execute( TC_dyn_pdch_osmo_act_deact() );
8567 execute( TC_dyn_pdch_osmo_act_nack() );
Harald Welte99f3ca02018-06-14 13:40:29 +02008568
Stefan Sperling0796a822018-10-05 13:01:39 +02008569 execute( TC_chopped_ipa_ping() );
Stefan Sperlingaa1e60f2018-10-15 16:34:07 +02008570 execute( TC_chopped_ipa_payload() );
Stefan Sperling0796a822018-10-05 13:01:39 +02008571
Pau Espin Pedrol8f773632019-11-05 11:46:53 +01008572 /* Power control related */
8573 execute( TC_assignment_verify_ms_power_params_ie() );
Neels Hofmeyr4f118412020-06-04 15:25:10 +02008574
8575 /* MSC pooling */
8576 /* FIXME: in SCCPlite, indicating how many MSCs should be connected does currently not work. Since
8577 * RESET->RESET-ACK is unconditionally negotiated for all configured MSCs, they always all appear as connected
8578 * to osmo-bsc. The MSC pooling tests however require disconnecting selected MSCs, and hence don't work out as
8579 * intended on SCCPlite. So for now, run these only for SCCP/M3UA. */
8580 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
8581 execute( TC_mscpool_L3Compl_on_1_msc() );
8582 execute( TC_mscpool_L3Complete_by_imsi_round_robin() );
8583 execute( TC_mscpool_LU_by_tmsi_null_nri_0_round_robin() );
8584 execute( TC_mscpool_LU_by_tmsi_null_nri_1_round_robin() );
8585 execute( TC_mscpool_L3Complete_by_tmsi_unassigned_nri_round_robin() );
8586 execute( TC_mscpool_L3Complete_by_tmsi_valid_nri_msc_not_connected_round_robin() );
8587 execute( TC_mscpool_L3Complete_by_tmsi_valid_nri_1() );
8588 execute( TC_mscpool_L3Complete_by_tmsi_valid_nri_2() );
8589 execute( TC_mscpool_LU_by_tmsi_from_other_PLMN() );
8590 execute( TC_mscpool_paging_and_response_imsi() );
8591 execute( TC_mscpool_paging_and_response_tmsi() );
8592 execute( TC_mscpool_no_allow_attach_round_robin() );
8593 execute( TC_mscpool_no_allow_attach_valid_nri() );
8594 }
8595
Harald Welte99f3ca02018-06-14 13:40:29 +02008596 /* at bottom as they might crash OsmoBSC before OS#3182 is fixed */
8597 execute( TC_early_conn_fail() );
8598 execute( TC_late_conn_fail() );
8599
Philipp Maier783681c2020-07-16 16:47:06 +02008600 /* Emergency call handling (deny / allow) */
8601 execute( TC_assignment_emerg_setup_allow() );
8602 execute( TC_assignment_emerg_setup_deny_msc() );
8603 execute( TC_assignment_emerg_setup_deny_bts() );
Philipp Maier82812002020-08-13 18:48:27 +02008604 execute( TC_emerg_premption() );
8605
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008606 /* Frequency hopping parameters handling */
8607 execute( TC_fh_params_chan_activ() );
8608 execute( TC_fh_params_imm_ass() );
Vadim Yanitskiyaeb54a22020-09-01 06:25:25 +07008609 execute( TC_fh_params_assignment_cmd() );
Vadim Yanitskiy8f5430d2020-09-02 18:51:38 +07008610 execute( TC_fh_params_handover_cmd() );
Vadim Yanitskiyca974032020-09-01 07:20:39 +07008611 execute( TC_fh_params_si4_cbch() );
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02008612
8613 if (mp_enable_lcs_tests) {
8614 execute( TC_lcs_loc_req_for_active_ms() );
8615 execute( TC_lcs_loc_req_for_active_ms_ta_req() );
8616 execute( TC_lcs_loc_req_for_idle_ms() );
8617 execute( TC_lcs_loc_req_no_subscriber() );
8618 execute( TC_lcs_loc_req_for_active_ms_le_timeout() );
8619 execute( TC_lcs_loc_req_for_active_ms_le_timeout2() );
8620 execute( TC_lcs_loc_req_for_idle_ms_no_pag_resp() );
8621 execute( TC_cm_service_during_lcs_loc_req() );
8622 execute( TC_ho_during_lcs_loc_req() );
8623 }
Neels Hofmeyrbf037052020-10-28 22:52:02 +00008624
8625 execute( TC_no_msc() );
Harald Welte28d943e2017-11-25 15:00:50 +01008626}
8627
8628}