blob: 9a6cce33647d3d94198781dec3766e8a452b1fcd [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 Hofmeyr12941bd2020-08-29 03:21:26 +0000101/* Default list of counters for 'bsc' and 'bts' entities. */
102const CounterNameVals counternames_bsc_bts_handover := {
103 { "assignment:attempted", 0 },
104 { "assignment:completed", 0 },
105 { "assignment:stopped", 0 },
106 { "assignment:no_channel", 0 },
107 { "assignment:timeout", 0 },
108 { "assignment:failed", 0 },
109 { "assignment:error", 0 },
110
111 { "handover:attempted", 0 },
112 { "handover:completed", 0 },
113 { "handover:stopped", 0 },
114 { "handover:no_channel", 0 },
115 { "handover:timeout", 0 },
116 { "handover:failed", 0 },
117 { "handover:error", 0 },
118
119 { "intra_cell_ho:attempted", 0 },
120 { "intra_cell_ho:completed", 0 },
121 { "intra_cell_ho:stopped", 0 },
122 { "intra_cell_ho:no_channel", 0 },
123 { "intra_cell_ho:timeout", 0 },
124 { "intra_cell_ho:failed", 0 },
125 { "intra_cell_ho:error", 0 },
126
127 { "intra_bsc_ho:attempted", 0 },
128 { "intra_bsc_ho:completed", 0 },
129 { "intra_bsc_ho:stopped", 0 },
130 { "intra_bsc_ho:no_channel", 0 },
131 { "intra_bsc_ho:timeout", 0 },
132 { "intra_bsc_ho:failed", 0 },
133 { "intra_bsc_ho:error", 0 },
134
135 { "interbsc_ho_out:attempted", 0 },
136 { "interbsc_ho_out:completed", 0 },
137 { "interbsc_ho_out:stopped", 0 },
138 { "interbsc_ho_out:timeout", 0 },
139 { "interbsc_ho_out:failed", 0 },
140 { "interbsc_ho_out:error", 0 },
141
142 { "interbsc_ho_in:attempted", 0 },
143 { "interbsc_ho_in:completed", 0 },
144 { "interbsc_ho_in:stopped", 0 },
145 { "interbsc_ho_in:no_channel", 0 },
146 { "interbsc_ho_in:timeout", 0 },
147 { "interbsc_ho_in:failed", 0 },
148 { "interbsc_ho_in:error", 0 }
149};
150
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +0200151/* Set of all System Information received during one RSL port's startup.
152 * Note that some System Information may be sent on RSL, but lacking actual SI data, to indicate that the BTS should not
153 * broadcast that SI type. That will be reflected as 'omit' here.
154 */
155type record SystemInformationConfig {
156 SystemInformationType1 si1 optional,
157 SystemInformationType2 si2 optional,
158 SystemInformationType2bis si2bis optional,
159 SystemInformationType2ter si2ter optional,
Neels Hofmeyrad132f22020-07-08 02:20:16 +0200160 SI2quaterRestOctetsList si2quater optional,
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +0200161 SystemInformationType3 si3 optional,
162 SystemInformationType4 si4 optional,
163 /* TODO: replace with proper decoding of SI13, implement SI13 in GSM_SystemInformation.ttcn */
164 octetstring si13 optional,
165 SystemInformationType5 si5 optional,
166 SystemInformationType5bis si5bis optional,
167 SystemInformationType5ter si5ter optional,
168 SystemInformationType6 si6 optional
169};
170
171const SystemInformationConfig SystemInformationConfig_omit := {
172 si1 := omit,
173 si2 := omit,
174 si2bis := omit,
175 si2ter := omit,
176 si2quater := omit,
177 si3 := omit,
178 si4 := omit,
179 si13 := omit,
180 si5 := omit,
181 si5bis := omit,
182 si5ter := omit,
183 si6 := omit
184};
185
186/* tr_EUTRAN_CellDesc with defaults used in BSC_Tests.ttcn */
187template EUTRAN_CellDesc tr_EUTRAN_CellDesc_default(template (present) uint16_t e_arfcn := ?,
188 template uint3_t meas_bw := 3)
189:= tr_EUTRAN_CellDesc(e_arfcn := e_arfcn,
190 meas_bw_presence := '1'B,
191 meas_bw := meas_bw);
192
193/* tr_EUTRAN_NeighbourCells with defaults used in BSC_Tests.ttcn */
Harald Welte65e419a2020-08-21 12:38:33 +0200194template EUTRAN_NeighbourCells tr_EUTRAN_NeighbourCells_default(template (present) EUTRAN_CellDescs cell_desc_list := { tr_EUTRAN_CellDesc_default },
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +0200195 template uint3_t prio := 3,
196 template (present) uint5_t thresh_high := 20,
197 template uint5_t thresh_low := 10,
198 template uint5_t qrxlevmin := 22)
199:= tr_EUTRAN_NeighbourCells(
200 cell_desc_list := cell_desc_list,
201 prio_presence := '1'B,
202 prio := prio,
203 thresh_high := thresh_high,
204 thresh_low_presence := '1'B,
205 thresh_low := thresh_low,
206 qrxlevmin_presence := '1'B,
207 qrxlevmin := qrxlevmin);
208
209template SystemInformationConfig SystemInformationConfig_default := {
210 si1 := {
211 cell_chan_desc := '8FB38000000000000000000000000000'O,
212 rach_control := {
213 max_retrans := RACH_MAX_RETRANS_7,
214 tx_integer := '1001'B,
215 cell_barr_access := false,
216 re_not_allowed := true,
217 acc := '0000010000000000'B
218 },
219 rest_octets := ?
220 },
221 si2 := {
222 bcch_freq_list := '00000000000000000000000000000000'O,
223 ncc_permitted := '11111111'B,
224 rach_control := {
225 max_retrans := RACH_MAX_RETRANS_7,
226 tx_integer := '1001'B,
227 cell_barr_access := false,
228 re_not_allowed := true,
229 acc := '0000010000000000'B
230 }
231 },
232 si2bis := omit,
233 si2ter := {
234 extd_bcch_freq_list := '8E320000000000000000000000000800'O,
235 rest_octets := ?
236 },
237 si2quater := {
238 tr_SI2quaterRestOctets_EUTRAN( repeated_neigh_cells := { tr_EUTRAN_NeighbourCells_default } )
239 },
240 si3 := {
241 cell_id := 0,
242 lai := {
243 mcc_mnc := '001F01'H,
244 lac := 1
245 },
246 ctrl_chan_desc := {
247 msc_r99 := true,
248 att := true,
249 bs_ag_blks_res := 1,
250 ccch_conf := CCHAN_DESC_1CCCH_COMBINED,
251 si22ind := false,
252 cbq3 := CBQ3_IU_MODE_NOT_SUPPORTED,
253 spare := '00'B,
254 bs_pa_mfrms := 3,
255 t3212 := 30
256 },
257 cell_options := {
258 dn_ind := false,
259 pwrc := false,
260 dtx := MS_SHALL_USE_UL_DTX,
261 radio_link_tout_div4 := 7
262 },
263 cell_sel_par := {
264 cell_resel_hyst_2dB := 2,
265 ms_txpwr_max_cch := 7,
266 acs := '0'B,
267 neci := true,
268 rxlev_access_min := 0
269 },
270 rach_control := {
271 max_retrans := RACH_MAX_RETRANS_7,
272 tx_integer := '1001'B,
273 cell_barr_access := false,
274 re_not_allowed := true,
275 acc := '0000010000000000'B
276 },
277 rest_octets := {
278 sel_params := {
279 presence := '0'B,
280 params := omit
281 },
282 pwr_offset := {
283 presence := '0'B,
284 offset := omit
285 },
286 si_2ter_ind := '1'B,
287 early_cm_ind := '0'B,
288 sched_where := {
289 presence := '0'B,
290 where := omit
291 },
292 gprs_ind := {
293 presence := '1'B,
294 ind := {
295 ra_colour := 0,
296 si13_pos := '0'B
297 }
298 },
299 umts_early_cm_ind := '1'B,
300 si2_quater_ind := {
301 presence := '1'B,
302 ind := '0'B
303 },
304 iu_mode_ind := omit,
305 si21_ind := {
306 presence := '0'B,
307 pos := omit
308 }
309 }
310 },
311 si4 := {
312 lai := {
313 mcc_mnc := '001F01'H,
314 lac := 1
315 },
316 cell_sel_par := {
317 cell_resel_hyst_2dB := 2,
318 ms_txpwr_max_cch := 7,
319 acs := '0'B,
320 neci := true,
321 rxlev_access_min := 0
322 },
323 rach_control := {
324 max_retrans := RACH_MAX_RETRANS_7,
325 tx_integer := '1001'B,
326 cell_barr_access := false,
327 re_not_allowed := true,
328 acc := '0000010000000000'B
329 },
Neels Hofmeyr74083c22020-07-29 00:43:01 +0200330 cbch_chan_desc := {
331 iei := '64'O,
332 v := {
333 chan_nr := {
334 u := {
335 sdcch4 := {
336 tag := '001'B,
337 sub_chan := 2
338 }
339 },
340 tn := 0
341 },
342 tsc := 2,
343 h := false,
344 arfcn := 871,
345 maio_hsn := omit
346 }
347 },
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +0200348 cbch_mobile_alloc := omit,
349 rest_octets := {
350 sel_params := {
351 presence := '0'B,
352 params := omit
353 },
354 pwr_offset := {
355 presence := '0'B,
356 offset := omit
357 },
358 gprs_ind := {
359 presence := '1'B,
360 ind := {
361 ra_colour := 0,
362 si13_pos := '0'B
363 }
364 },
365 s_presence := '0'B,
366 s := omit
367 }
368 },
369 si13 := '9000185A6FC9E08410AB2B2B2B2B2B2B2B2B2B2B'O,
370 si5 := {
371 bcch_freq_list := '10000000000000000000000000000000'O
372 },
373 si5bis := omit,
374 si5ter := {
375 extd_bcch_freq_list := '9E050020000000000000000000000000'O
376 },
377 si6 := {
378 cell_id := 0,
379 lai := {
380 mcc_mnc := '001F01'H,
381 lac := 1
382 },
383 cell_options := {
384 dtx_ext := '1'B,
385 pwrc := false,
386 dtx := '01'B,
387 radio_link_timeout := '0111'B
388 },
389 ncc_permitted := '11111111'B,
390 rest_octets := ?
391 }
392 };
393
394
395/* List of all the System Information received on all RSL ports */
396type record of SystemInformationConfig SystemInformationConfig_list;
397
398function f_sysinfo_dec_raw(inout SystemInformationConfig si, RSL_Message rsl)
399{
400 var RSL_IE_Body sysinfo_type_ie;
401 var RSL_IE_SysinfoType si_type;
402 var octetstring data;
403
404 if (f_rsl_find_ie(rsl, RSL_IE_SYSINFO_TYPE, sysinfo_type_ie) == false) {
405 setverdict(fail, "Cannot find RSL_IE_SYSINFO_TYPE");
406 mtc.stop;
407 }
408 si_type := sysinfo_type_ie.sysinfo_type;
409
410 if (rsl.msg_type == RSL_MT_BCCH_INFO) {
411 var RSL_IE_Body bcch_ie;
412 if (f_rsl_find_ie(rsl, RSL_IE_FULL_BCCH_INFO, bcch_ie)) {
413 data := bcch_ie.other.payload;
414 }
415 } else if (rsl.msg_type == RSL_MT_SACCH_FILL) {
416 var RSL_IE_Body l3_ie;
417 if (f_rsl_find_ie(rsl, RSL_IE_L3_INFO, l3_ie)) {
418 data := l3_ie.l3_info.payload;
419 }
420 } else {
421 setverdict(fail, "Don't understand this System Information message");
422 mtc.stop;
423 }
424
425 var boolean handled := false;
426
427 if (rsl.msg_type == RSL_MT_BCCH_INFO) {
428 handled := true;
429
430 if (si_type == RSL_SYSTEM_INFO_1) {
431 if (not isbound(data)) {
432 si.si1 := omit;
433 } else {
434 si.si1 := dec_SystemInformation(data).payload.si1;
435 }
436 } else if (si_type == RSL_SYSTEM_INFO_2) {
437 if (not isbound(data)) {
438 si.si2 := omit;
439 } else {
440 si.si2 := dec_SystemInformation(data).payload.si2;
441 }
442 } else if (si_type == RSL_SYSTEM_INFO_2bis) {
443 if (not isbound(data)) {
444 si.si2bis := omit;
445 } else {
446 si.si2bis := dec_SystemInformation(data).payload.si2bis;
447 }
448 } else if (si_type == RSL_SYSTEM_INFO_2ter) {
449 if (not isbound(data)) {
450 si.si2ter := omit;
451 } else {
452 si.si2ter := dec_SystemInformation(data).payload.si2ter;
453 }
454 } else if (si_type == RSL_SYSTEM_INFO_2quater) {
455 if (not isbound(data)) {
456 si.si2quater := {};
457 } else {
458 var SystemInformationType2quater decoded := dec_SystemInformation(data).payload.si2quater;
459 /* this is a *record* of SI2quaterRestOctets! (multiplexed) */
460 si.si2quater[decoded.rest_octets.si2quater_index] := decoded.rest_octets;
461 }
462 } else if (si_type == RSL_SYSTEM_INFO_3) {
463 if (not isbound(data)) {
464 si.si3 := omit;
465 } else {
466 si.si3 := dec_SystemInformation(data).payload.si3;
467 }
468 } else if (si_type == RSL_SYSTEM_INFO_4) {
469 if (not isbound(data)) {
470 si.si4 := omit;
471 } else {
472 si.si4 := dec_SystemInformation(data).payload.si4;
473 }
474 } else if (si_type == RSL_SYSTEM_INFO_13) {
475 if (not isbound(data)) {
476 si.si13 := omit;
477 } else {
478 si.si13 := dec_SystemInformation(data).payload.other;
479 }
480 } else {
481 handled := false;
482 }
483 } else if (rsl.msg_type == RSL_MT_SACCH_FILL) {
484 handled := true;
485
486 if (si_type == RSL_SYSTEM_INFO_5) {
487 if (not isbound(data)) {
488 si.si5 := omit;
489 } else {
490 si.si5 := dec_SystemInformation(data).payload.si5;
491 }
492 } else if (si_type == RSL_SYSTEM_INFO_5bis) {
493 if (not isbound(data)) {
494 si.si5bis := omit;
495 } else {
496 si.si5bis := dec_SystemInformation(data).payload.si5bis;
497 }
498 } else if (si_type == RSL_SYSTEM_INFO_5ter) {
499 if (not isbound(data)) {
500 si.si5ter := omit;
501 } else {
502 si.si5ter := dec_SystemInformation(data).payload.si5ter;
503 }
504 } else if (si_type == RSL_SYSTEM_INFO_6) {
505 if (not isbound(data)) {
506 si.si6 := omit;
507 } else {
508 si.si6 := dec_SystemInformation(data).payload.si6;
509 }
510 } else {
511 handled := false;
512 }
513 }
514
515 if (not handled) {
516 setverdict(fail, "Unexpected SI type in ", rsl.msg_type, " message: ", si_type);
517 }
518}
519
Harald Weltea4ca4462018-02-09 00:17:14 +0100520type component test_CT extends CTRL_Adapter_CT {
Harald Welte21b46bd2017-12-17 19:46:32 +0100521 /* Array of per-BTS state */
Harald Welte96c94412017-12-09 03:12:45 +0100522 var BTS_State bts[NUM_BTS];
Harald Welte89ab1912018-02-23 18:56:29 +0100523 /* RSL common Channel Port (for RSL_Emulation) */
524 port RSL_CCHAN_PT RSL_CCHAN[NUM_BTS];
Harald Welte21b46bd2017-12-17 19:46:32 +0100525 /* array of per-BTS RSL test ports */
Harald Welteae026692017-12-09 01:03:01 +0100526 port IPA_RSL_PT IPA_RSL[NUM_BTS];
Stefan Sperling830dc9d2018-02-12 21:08:28 +0100527 port IPA_CODEC_PT IPA; /* Required for compilation of TC_rsl_unknown_unit_id() */
Pau Espin Pedrol5a2d7432019-06-07 19:43:45 +0200528 /* CTRL muxed over IPA in SCCPlite conn BSC<->MSC (or BSC-NAT) */
529 port IPA_CTRL_PT SCCPLITE_IPA_CTRL;
Harald Weltea5d2ab22017-12-09 14:21:42 +0100530
Daniel Willmann191e0d92018-01-17 12:44:35 +0100531 var MGCP_Emulation_CT vc_MGCP;
Harald Weltebc03c762018-02-12 18:09:38 +0100532 port TELNETasp_PT BSCVTY;
Daniel Willmann191e0d92018-01-17 12:44:35 +0100533
Daniel Willmannebdecc02020-08-12 15:30:17 +0200534 /* StatsD */
535 var StatsD_Checker_CT vc_STATSD;
536
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200537 var RAN_Adapter g_bssap[NUM_MSC];
Harald Welte47cd0e32020-08-21 12:39:11 +0200538 var BSSAP_LE_Adapter g_bssap_le;
Harald Weltea4ca4462018-02-09 00:17:14 +0100539 /* for old legacy-tests only */
540 port BSSAP_CODEC_PT BSSAP;
Harald Welte47cd0e32020-08-21 12:39:11 +0200541 port BSSAP_LE_CODEC_PT BSSAP_LE;
Harald Weltea4ca4462018-02-09 00:17:14 +0100542
Harald Welte21b46bd2017-12-17 19:46:32 +0100543 /* are we initialized yet */
Harald Welte28d943e2017-11-25 15:00:50 +0100544 var boolean g_initialized := false;
Harald Welte21b46bd2017-12-17 19:46:32 +0100545
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200546 /* Osmux is enabled through VTY */
547 var boolean g_osmux_enabled := false;
548
Pau Espin Pedrolc675b612020-01-09 19:55:40 +0100549 /*Configure T(tias) over VTY, seconds */
550 var integer g_bsc_sccp_timer_ias := 7 * 60;
551 /*Configure T(tiar) over VTY, seconds */
552 var integer g_bsc_sccp_timer_iar := 15 * 60;
553
Neels Hofmeyr4fbad7f2020-06-16 00:30:47 +0200554 /* global test case guard timer (actual timeout value is set in f_init()) */
Harald Welteae026692017-12-09 01:03:01 +0100555 timer T_guard := 30.0;
556
Neels Hofmeyr22c3f792020-06-17 02:49:28 +0200557 var CounterNameValsList g_ctr_msc;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +0000558 var CounterNameValsList g_ctr_bsc;
559 var CounterNameValsList g_ctr_bts;
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +0200560
561 /* System Information bytes as received during RSL startup, for each RSL[idx]. */
562 var SystemInformationConfig_list g_system_information := {};
Harald Welte28d943e2017-11-25 15:00:50 +0100563}
564
565modulepar {
Harald Welte21b46bd2017-12-17 19:46:32 +0100566 /* IP address at which the BSC can be reached */
Harald Welte696ddb62017-12-08 14:01:43 +0100567 charstring mp_bsc_ip := "127.0.0.1";
Stefan Sperling830dc9d2018-02-12 21:08:28 +0100568 /* port number to which to establish the IPA OML connections */
569 integer mp_bsc_oml_port := 3002;
Harald Welte21b46bd2017-12-17 19:46:32 +0100570 /* port number to which to establish the IPA RSL connections */
Harald Welte696ddb62017-12-08 14:01:43 +0100571 integer mp_bsc_rsl_port := 3003;
Harald Welte21b46bd2017-12-17 19:46:32 +0100572 /* port number to which to establish the IPA CTRL connection */
Harald Welte96c94412017-12-09 03:12:45 +0100573 integer mp_bsc_ctrl_port := 4249;
Daniel Willmannebdecc02020-08-12 15:30:17 +0200574 /* port number to which to listen for STATSD metrics */
575 integer mp_bsc_statsd_port := 8125;
Daniel Willmann191e0d92018-01-17 12:44:35 +0100576 /* IP address at which the test binds */
577 charstring mp_test_ip := "127.0.0.1";
Harald Weltea4ca4462018-02-09 00:17:14 +0100578
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200579 RAN_Configurations mp_bssap_cfg := {
580 {
581 transport := BSSAP_TRANSPORT_AoIP,
582 sccp_service_type := "mtp3_itu",
583 sctp_addr := { 23905, "127.0.0.1", 2905, "127.0.0.1" },
584 own_pc := 185, /* 0.23.1 first MSC emulation */
585 own_ssn := 254,
586 peer_pc := 187, /* 0.23.3 osmo-bsc */
587 peer_ssn := 254,
588 sio := '83'O,
Harald Weltecb0cc432020-06-21 19:42:31 +0200589 rctx := 1
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200590 },
591 {
592 transport := BSSAP_TRANSPORT_AoIP,
593 sccp_service_type := "mtp3_itu",
594 sctp_addr := { 23906, "127.0.0.1", 2905, "127.0.0.1" },
595 own_pc := 2, /* 0.0.2 second MSC emulation */
596 own_ssn := 254,
597 peer_pc := 187, /* 0.23.3 osmo-bsc */
598 peer_ssn := 254,
599 sio := '83'O,
600 rctx := 2
601 },
602 {
603 transport := BSSAP_TRANSPORT_AoIP,
604 sccp_service_type := "mtp3_itu",
605 sctp_addr := { 23907, "127.0.0.1", 2905, "127.0.0.1" },
606 own_pc := 3, /* 0.0.3 third MSC emulation */
607 own_ssn := 254,
608 peer_pc := 187, /* 0.23.3 osmo-bsc */
609 peer_ssn := 254,
610 sio := '83'O,
611 rctx := 3
612 }
Harald Weltea4ca4462018-02-09 00:17:14 +0100613 };
Pau Espin Pedrol58cf6822019-05-28 18:11:33 +0200614
Harald Welte47cd0e32020-08-21 12:39:11 +0200615 BSSAP_LE_Configuration mp_bssap_le_cfg := {
616 sccp_service_type := "mtp3_itu",
617 sctp_addr := { 23908, "127.0.0.1", 2905, "127.0.0.1" },
Neels Hofmeyrac086c12020-09-18 23:46:42 +0200618 own_pc := 190, /* 0.23.6 SMLC emulation */
Harald Welte47cd0e32020-08-21 12:39:11 +0200619 own_ssn := 252, /* SMLC side SSN */
620 peer_pc := 187, /* 0.23.3 osmo-bsc */
621 peer_ssn := 250, /* BSC side SSN */
622 sio := '83'O,
623 rctx := 6
624 };
Neels Hofmeyrcfe44062020-10-15 02:28:08 +0200625 boolean mp_enable_lcs_tests := true;
Harald Welte47cd0e32020-08-21 12:39:11 +0200626
Pau Espin Pedrol58cf6822019-05-28 18:11:33 +0200627 /* Whether to enable osmux tests. Can be dropped completely and enable
628 unconditionally once new version of osmo-bsc is released (current
629 version: 1.4.1) */
630 boolean mp_enable_osmux_test := true;
Pau Espin Pedrol8f30ccd2019-11-01 17:30:57 +0100631 /* Value set in osmo-bsc.cfg "ms max power" */
632 uint8_t mp_exp_ms_power_level := 7;
Philipp Maiera2083892020-09-21 14:18:36 +0200633
634 boolean mp_media_mgw_offer_ipv6 := true;
Harald Weltea4ca4462018-02-09 00:17:14 +0100635}
636
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200637private function f_gen_test_hdlr_pars(integer bssap_idx := 0) return TestHdlrParams {
Philipp Maier48604732018-10-09 15:00:37 +0200638
639 var TestHdlrParams pars := valueof(t_def_TestHdlrPars);
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200640 if (mp_bssap_cfg[bssap_idx].transport == BSSAP_TRANSPORT_AoIP) {
Philipp Maier48604732018-10-09 15:00:37 +0200641 pars.aoip := true;
642 } else {
643 pars.aoip := false;
644 }
Pau Espin Pedrol8f30ccd2019-11-01 17:30:57 +0100645 pars.exp_ms_power_level := mp_exp_ms_power_level;
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200646 pars.mscpool.bssap_idx := bssap_idx;
Philipp Maiera2083892020-09-21 14:18:36 +0200647 pars.media_mgw_offer_ipv6 := mp_media_mgw_offer_ipv6;
Philipp Maier48604732018-10-09 15:00:37 +0200648
649 return pars;
650}
651
Neels Hofmeyr22c3f792020-06-17 02:49:28 +0200652/* Convenience functions for rate counters using g_ctr_msc. */
653
654private function f_ctrs_msc_init(integer mscs_count := NUM_MSC, CounterNameVals counternames := counternames_msc_mscpool) runs on test_CT {
655 g_ctr_msc := f_counter_name_vals_get_n(IPA_CTRL, "msc", mscs_count, counternames);
656 log("initial msc rate counters: ", g_ctr_msc);
657}
658
659private function f_ctrs_msc_add(integer msc_nr, charstring countername, integer val := 1) runs on test_CT {
Neels Hofmeyr9656e922020-06-30 01:27:01 +0200660 f_counter_name_vals_list_add(g_ctr_msc, msc_nr, countername, val);
Neels Hofmeyr22c3f792020-06-17 02:49:28 +0200661}
662
663/* f_ctrs_msc_init();
664 * f_do_thing(on_msc := 0);
665 * f_do_thing(on_msc := 0);
666 * f_do_other(on_msc := 1);
667 * f_ctrs_msc_add(0, "thing", 2);
668 * f_ctrs_msc_add(1, "other");
669 * f_ctrs_msc_verify();
670 */
671private function f_ctrs_msc_verify() runs on test_CT {
672 log("verifying msc rate counters: ", g_ctr_msc);
673 f_counter_name_vals_expect_n(IPA_CTRL, "msc", g_ctr_msc);
674}
675
676/* convenience: f_ctrs_msc_add() and f_ctrs_msc_verify() in one call.
677 * f_ctrs_msc_init();
678 * f_do_thing(on_msc := 0);
679 * f_do_thing(on_msc := 0);
680 * f_do_thing(on_msc := 0);
681 * f_ctrs_msc_expect(0, "thing", 3);
682 */
683private function f_ctrs_msc_expect(integer msc_nr, charstring countername, integer val := 1) runs on test_CT {
684 f_ctrs_msc_add(msc_nr, countername, val);
685 f_ctrs_msc_verify();
686}
687
Neels Hofmeyr12941bd2020-08-29 03:21:26 +0000688/* Convenience functions for rate counters using g_ctr_bts, always also including g_ctr_bsc. */
689
690private function f_ctrs_bsc_and_bts_init(integer bts_count := NUM_BTS, CounterNameVals counternames := counternames_bsc_bts_handover) runs on test_CT {
691 g_ctr_bts := f_counter_name_vals_get_n(IPA_CTRL, "bts", bts_count, counternames);
692 log("initial bts rate counters: ", g_ctr_bts);
693 f_ctrs_bsc_init(counternames);
694}
695
696private function f_ctrs_bsc_and_bts_add(integer bts_nr, charstring countername, integer val := 1) runs on test_CT {
697 f_counter_name_vals_list_add(g_ctr_bts, bts_nr, countername, val);
698 f_ctrs_bsc_add(countername, val);
699}
700
701/* f_ctrs_bsc_and_bts_init();
702 * f_do_thing(on_bts := 0);
703 * f_do_thing(on_bts := 0);
704 * f_do_other(on_bts := 1);
705 * f_ctrs_bsc_and_bts_add(0, "thing", 2);
706 * f_ctrs_bsc_and_bts_add(1, "other");
707 * f_ctrs_bsc_and_bts_verify();
708 */
709private function f_ctrs_bsc_and_bts_verify() runs on test_CT {
710 f_counter_name_vals_expect_n(IPA_CTRL, "bts", g_ctr_bts);
711 f_ctrs_bsc_verify();
712}
713
714/* convenience: f_ctrs_bsc_and_bts_add() and f_ctrs_bsc_and_bts_verify() in one call.
715 * f_ctrs_bsc_and_bts_init();
716 * f_do_thing(on_bts := 0);
717 * f_do_thing(on_bts := 0);
718 * f_do_thing(on_bts := 0);
719 * f_ctrs_bsc_and_bts_expect(0, "thing", 3);
720 */
721private function f_ctrs_bsc_and_bts_expect(integer bts_nr, charstring countername, integer val := 1) runs on test_CT {
722 f_ctrs_bsc_and_bts_add(bts_nr, countername, val);
723 f_ctrs_bsc_and_bts_verify();
724}
725
726
727/* Convenience functions for rate counters using g_ctr_bsc. */
728
729private function f_ctrs_bsc_init(CounterNameVals counternames := counternames_bsc_bts_handover) runs on test_CT {
730 g_ctr_bsc := f_counter_name_vals_get_n(IPA_CTRL, "bsc", 1, counternames);
731 log("initial bsc rate counters: ", g_ctr_bsc);
732}
733
734private function f_ctrs_bsc_add(charstring countername, integer val := 1) runs on test_CT {
735 f_counter_name_vals_list_add(g_ctr_bsc, 0, countername, val);
736}
737
738/* f_ctrs_bsc_init();
739 * f_do_thing();
740 * f_do_thing();
741 * f_do_other();
742 * f_ctrs_bsc_add("thing", 2);
743 * f_ctrs_bsc_add("other");
744 * f_ctrs_bsc_verify();
745 */
746private function f_ctrs_bsc_verify() runs on test_CT {
747 f_counter_name_vals_expect_n(IPA_CTRL, "bsc", g_ctr_bsc);
748}
749
750/* convenience: f_ctrs_bsc_add() and f_ctrs_bsc_verify() in one call.
751 * f_ctrs_bsc_init();
752 * f_do_thing();
753 * f_ctrs_bsc_expect("thing", 1);
754 */
755private function f_ctrs_bsc_expect(charstring countername, integer val := 1) runs on test_CT {
756 f_ctrs_bsc_add(countername, val);
757 f_ctrs_bsc_verify();
758}
759
Neels Hofmeyr22c3f792020-06-17 02:49:28 +0200760
Philipp Maier282ca4b2018-02-27 17:17:00 +0100761private function f_shutdown_helper() runs on test_CT {
Daniel Willmann637ef6c2018-07-25 10:49:09 +0200762 all component.stop;
Philipp Maier282ca4b2018-02-27 17:17:00 +0100763 setverdict(pass);
Daniel Willmannafce8662018-07-06 23:11:32 +0200764 mtc.stop;
Philipp Maier282ca4b2018-02-27 17:17:00 +0100765}
766
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200767private function f_legacy_bssap_reset(integer bssap_idx := 0) runs on test_CT {
Harald Weltea4ca4462018-02-09 00:17:14 +0100768 var BSSAP_N_UNITDATA_ind ud_ind;
Pau Espin Pedrol24c05992020-09-01 12:54:12 +0200769 var boolean reset_received := false;
Harald Weltea4ca4462018-02-09 00:17:14 +0100770 timer T := 5.0;
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200771 BSSAP.send(ts_BSSAP_UNITDATA_req(g_bssap[bssap_idx].sccp_addr_peer, g_bssap[bssap_idx].sccp_addr_own,
772 ts_BSSMAP_Reset(0, g_osmux_enabled)));
Harald Weltea4ca4462018-02-09 00:17:14 +0100773 T.start;
774 alt {
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200775 [] BSSAP.receive(tr_BSSAP_UNITDATA_ind(g_bssap[bssap_idx].sccp_addr_own, g_bssap[bssap_idx].sccp_addr_peer,
776 tr_BSSMAP_ResetAck(g_osmux_enabled))) {
Harald Weltea4ca4462018-02-09 00:17:14 +0100777 log("Received RESET-ACK in response to RESET, we're ready to go!");
778 }
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200779 [] BSSAP.receive(tr_BSSAP_UNITDATA_ind(?, ?, tr_BSSMAP_Reset(g_osmux_enabled))) -> value ud_ind {
Harald Weltea4ca4462018-02-09 00:17:14 +0100780 log("Respoding to inbound RESET with RESET-ACK");
781 BSSAP.send(ts_BSSAP_UNITDATA_req(ud_ind.callingAddress, ud_ind.calledAddress,
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200782 ts_BSSMAP_ResetAck(g_osmux_enabled)));
Pau Espin Pedrol24c05992020-09-01 12:54:12 +0200783 reset_received := true;
Harald Weltea4ca4462018-02-09 00:17:14 +0100784 repeat;
785 }
786 [] BSSAP.receive { repeat; }
Pau Espin Pedrol24c05992020-09-01 12:54:12 +0200787 [] T.timeout {
788 log("Timeout waiting for RESET-ACK after sending RESET");
789 /* If we received a RESET after ours was sent, it
790 may be a race condition where the other peer beacame
791 available after we sent it, but we are in a desired
792 state anyway, so go forward. */
793 if (not reset_received) {
794 setverdict(fail);
795 }
796 }
Harald Weltea4ca4462018-02-09 00:17:14 +0100797 }
Harald Welte28d943e2017-11-25 15:00:50 +0100798}
799
Harald Welteae026692017-12-09 01:03:01 +0100800type record IPA_Client {
Harald Welte21b46bd2017-12-17 19:46:32 +0100801 /* IPA Emulation component reference */
Harald Welteae026692017-12-09 01:03:01 +0100802 IPA_Emulation_CT vc_IPA,
Harald Welte21b46bd2017-12-17 19:46:32 +0100803 /* Unit-ID and other CCM parameters to use for IPA client emulation */
Harald Welteae026692017-12-09 01:03:01 +0100804 IPA_CCM_Parameters ccm_pars,
Harald Welte21b46bd2017-12-17 19:46:32 +0100805 /* String identifier for this IPA Client */
Harald Welte624f9632017-12-16 19:26:04 +0100806 charstring id,
Harald Welte21b46bd2017-12-17 19:46:32 +0100807 /* Associated RSL Emulation Component (if any). Only used in "Handler mode" */
Harald Welte624f9632017-12-16 19:26:04 +0100808 RSL_Emulation_CT vc_RSL optional
Harald Welte28d943e2017-11-25 15:00:50 +0100809}
810
Harald Welte21b46bd2017-12-17 19:46:32 +0100811/*! Start the IPA/RSL related bits for one IPA_Client.
812 * \param clnt IPA_Client for which to establish
813 * \param bsc_host IP address / hostname of the BSC
814 * \param bsc_port TCP port number of the BSC
815 * \param i number identifying this BTS
816 * \param handler_mode Start an RSL_Emulation_CT component (true) or not (false) */
Harald Welte624f9632017-12-16 19:26:04 +0100817function f_ipa_rsl_start(inout IPA_Client clnt, charstring bsc_host, PortNumber bsc_port, integer i,
818 boolean handler_mode := false)
Harald Welte28d943e2017-11-25 15:00:50 +0100819runs on test_CT {
Harald Welteae026692017-12-09 01:03:01 +0100820 timer T := 10.0;
821
Harald Welte96c94412017-12-09 03:12:45 +0100822 clnt.id := "IPA" & int2str(i) & "-RSL";
Harald Welteae026692017-12-09 01:03:01 +0100823 clnt.vc_IPA := IPA_Emulation_CT.create(clnt.id & "-IPA");
824 clnt.ccm_pars := c_IPA_default_ccm_pars;
825 clnt.ccm_pars.name := "Osmocom TTCN-3 BTS Simulator";
826 clnt.ccm_pars.unit_id := int2str(1234+i) & "/0/0";
Harald Welte624f9632017-12-16 19:26:04 +0100827 if (handler_mode) {
828 clnt.vc_RSL := RSL_Emulation_CT.create(clnt.id & "-RSL");
Harald Welte89ab1912018-02-23 18:56:29 +0100829 connect(clnt.vc_RSL:CCHAN_PT, self:RSL_CCHAN[i]);
Harald Welte624f9632017-12-16 19:26:04 +0100830 }
Harald Welteae026692017-12-09 01:03:01 +0100831
832 map(clnt.vc_IPA:IPA_PORT, system:IPA_CODEC_PT);
Harald Welte624f9632017-12-16 19:26:04 +0100833 if (handler_mode) {
834 connect(clnt.vc_IPA:IPA_RSL_PORT, clnt.vc_RSL:IPA_PT);
835 } else {
836 connect(clnt.vc_IPA:IPA_RSL_PORT, self:IPA_RSL[i]);
837 }
Harald Welteae026692017-12-09 01:03:01 +0100838
Harald Welte5d1a2202017-12-13 19:51:29 +0100839 clnt.vc_IPA.start(IPA_Emulation.main_client(bsc_host, bsc_port, "", 10000+i, clnt.ccm_pars));
Harald Welte624f9632017-12-16 19:26:04 +0100840 if (handler_mode) {
841 clnt.vc_RSL.start(RSL_Emulation.main());
842 return;
843 }
Harald Welteae026692017-12-09 01:03:01 +0100844
845 /* wait for IPA RSL link to connect and send ID ACK */
846 T.start;
847 alt {
Vadim Yanitskiya2afacc2020-05-18 21:16:19 +0700848 [] IPA_RSL[i].receive(tr_ASP_IPA_EV(ASP_IPA_EVENT_ID_ACK)) {
Harald Welteae026692017-12-09 01:03:01 +0100849 T.stop;
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +0700850 IPA_RSL[i].send(ts_ASP_RSL_UD(ts_RSL_PAGING_LOAD_IND(23)));
Harald Welteae026692017-12-09 01:03:01 +0100851 }
Harald Welte60e823a2017-12-10 14:10:59 +0100852 [] IPA_RSL[i].receive(ASP_IPA_Event:?) { repeat }
Harald Welteae026692017-12-09 01:03:01 +0100853 [] IPA_RSL[i].receive { repeat }
854 [] T.timeout {
Harald Welte96c94412017-12-09 03:12:45 +0100855 setverdict(fail, "Timeout RSL waiting for ASP_IPA_EVENT_ID_ACK");
Daniel Willmannafce8662018-07-06 23:11:32 +0200856 mtc.stop;
Harald Welteae026692017-12-09 01:03:01 +0100857 }
858 }
859}
860
Harald Welte12055472018-03-17 20:10:08 +0100861function f_ipa_rsl_stop(inout IPA_Client clnt) runs on test_CT {
862 if (not isbound(clnt) or not isbound(clnt.vc_IPA)) {
863 return;
864 }
865 clnt.vc_IPA.stop;
866 if (isbound(clnt.vc_RSL)) {
867 clnt.vc_RSL.stop;
868 }
869}
870
Harald Welte21b46bd2017-12-17 19:46:32 +0100871/* Wait for the OML connection to be brought up by the external osmo-bts-omldummy */
Harald Weltea5d2ab22017-12-09 14:21:42 +0100872function f_wait_oml(integer bts_nr, charstring status, float secs_max) runs on test_CT {
873 timer T := secs_max;
874 T.start;
875 while (true) {
876 if (f_ctrl_get_bts(IPA_CTRL, bts_nr, "oml-connection-state") == status) {
877 T.stop;
Harald Weltebd868bd2017-12-10 18:28:40 +0100878 /* the 'degraded' state exists from OML connection time, and we have to wait
879 * until all MO's are initialized */
880 T.start(1.0);
881 T.timeout;
Harald Weltea5d2ab22017-12-09 14:21:42 +0100882 return;
883 }
Harald Weltef0d6ac62017-12-17 17:02:21 +0100884 f_sleep(0.1);
Harald Weltea5d2ab22017-12-09 14:21:42 +0100885 if (not T.running) {
Max99253902018-11-16 17:57:39 +0100886 setverdict(fail, "Timeout waiting for BTS" & int2str(bts_nr) & " oml-connection-state ", status);
Daniel Willmannafce8662018-07-06 23:11:32 +0200887 mtc.stop;
Harald Weltea5d2ab22017-12-09 14:21:42 +0100888 }
889 }
890}
891
Harald Welte21b46bd2017-12-17 19:46:32 +0100892/* global altstep for global guard timer; also takes care of responding RESET witH RESET-ACK */
Harald Welteae026692017-12-09 01:03:01 +0100893altstep as_Tguard() runs on test_CT {
Harald Welte60e823a2017-12-10 14:10:59 +0100894 var BSSAP_N_UNITDATA_ind ud_ind;
Neels Hofmeyrcc3f76a2018-03-12 01:43:25 +0100895 [] T_guard.timeout {
896 setverdict(fail, "Timeout of T_guard");
Daniel Willmannafce8662018-07-06 23:11:32 +0200897 mtc.stop;
Neels Hofmeyrcc3f76a2018-03-12 01:43:25 +0100898 }
Harald Welte60e823a2017-12-10 14:10:59 +0100899 /* always respond with RESET ACK to RESET */
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200900 [] BSSAP.receive(tr_BSSAP_UNITDATA_ind(?, ?, tr_BSSMAP_Reset(g_osmux_enabled))) -> value ud_ind {
Harald Welte60e823a2017-12-10 14:10:59 +0100901 BSSAP.send(ts_BSSAP_UNITDATA_req(ud_ind.callingAddress, ud_ind.calledAddress,
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200902 ts_BSSMAP_ResetAck(g_osmux_enabled)));
Harald Welte69c1c262017-12-13 21:02:08 +0100903 repeat;
Harald Welte60e823a2017-12-10 14:10:59 +0100904 }
Harald Welte28d943e2017-11-25 15:00:50 +0100905}
906
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +0100907altstep no_bssmap_reset() runs on test_CT {
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200908 [] BSSAP.receive(tr_BSSAP_UNITDATA_ind(?, ?, tr_BSSMAP_Reset(g_osmux_enabled))) {
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +0100909 setverdict(fail, "unexpected BSSMAP Reset");
Daniel Willmannafce8662018-07-06 23:11:32 +0200910 mtc.stop;
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +0100911 }
912}
913
Daniel Willmann191e0d92018-01-17 12:44:35 +0100914function f_init_mgcp(charstring id) runs on test_CT {
915 id := id & "-MGCP";
916
917 var MGCPOps ops := {
918 create_cb := refers(MGCP_Emulation.ExpectedCreateCallback),
919 unitdata_cb := refers(MGCP_Emulation.DummyUnitdataCallback)
920 };
921 var MGCP_conn_parameters mgcp_pars := {
922 callagent_ip := mp_bsc_ip,
Harald Welte9e4273e2018-01-29 22:01:22 +0100923 callagent_udp_port := -1,
Daniel Willmann191e0d92018-01-17 12:44:35 +0100924 mgw_ip := mp_test_ip,
Pau Espin Pedrol1a026a52019-06-18 17:21:52 +0200925 mgw_udp_port := 2427,
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +0200926 /* Enable it for SCCPlite, since we have 2 MGCP sockets towards MGW (UDP one +
927 the on with MGCP over IPA forwarded from MSC one) */
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200928 multi_conn_mode := (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_SCCPlite_SERVER)
Daniel Willmann191e0d92018-01-17 12:44:35 +0100929 };
930
931 vc_MGCP := MGCP_Emulation_CT.create(id);
932 vc_MGCP.start(MGCP_Emulation.main(ops, mgcp_pars, id));
933}
934
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200935/* Enable or disable (current default) Osmux. When enabling, BSSMAP Reset
936 * contains extra IE (OsmuxSupport) and osmo-bsc will handle AssignReq with
937 * OsmuxCID IE.
938 */
939private function f_vty_allow_osmux(boolean allow) runs on test_CT {
940 f_vty_enter_cfg_msc(BSCVTY, 0);
941 if (allow) {
942 f_vty_transceive(BSCVTY, "osmux on");
943 } else {
944 f_vty_transceive(BSCVTY, "osmux off");
945 }
946 f_vty_transceive(BSCVTY, "exit");
947 f_vty_transceive(BSCVTY, "exit");
948 g_osmux_enabled := allow;
949}
950
Max2253c0b2018-11-06 19:28:05 +0100951function f_init_vty(charstring id := "foo") runs on test_CT {
Harald Welte94e0c342018-04-07 11:33:23 +0200952 if (BSCVTY.checkstate("Mapped")) {
953 /* skip initialization if already executed once */
954 return;
955 }
Harald Weltebc03c762018-02-12 18:09:38 +0100956 map(self:BSCVTY, system:BSCVTY);
957 f_vty_set_prompts(BSCVTY);
958 f_vty_transceive(BSCVTY, "enable");
Pau Espin Pedrolc675b612020-01-09 19:55:40 +0100959 f_cs7_inst_0_cfg(BSCVTY, {"sccp-timer ias " & int2str(g_bsc_sccp_timer_ias),
960 "sccp-timer iar " & int2str(g_bsc_sccp_timer_iar)});
Harald Weltebc03c762018-02-12 18:09:38 +0100961}
962
Neels Hofmeyr767548a2020-08-09 20:26:07 +0000963private function f_logp(TELNETasp_PT pt, charstring log_msg)
Neels Hofmeyr4f118412020-06-04 15:25:10 +0200964{
965 // log on TTCN3 log output
966 log(log_msg);
967 // log in stderr log
Neels Hofmeyr767548a2020-08-09 20:26:07 +0000968 f_vty_transceive(pt, "logp lglobal notice TTCN3 f_logp(): " & log_msg);
Neels Hofmeyr4f118412020-06-04 15:25:10 +0200969}
970
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +0200971private function f_sysinfo_seen(integer rsl_idx, RSL_Message rsl) runs on test_CT
972{
973 if (rsl_idx >= lengthof(g_system_information)) {
974 g_system_information[rsl_idx] := SystemInformationConfig_omit
975 }
976 f_sysinfo_dec_raw(g_system_information[rsl_idx], rsl);
977}
978
979altstep as_catch_RSL_sysinfo(integer rsl_idx) runs on test_CT {
980 var ASP_RSL_Unitdata rx_rsl_ud;
981
982 /* For handler_mode := false, receiving the RSL bootstrap messages directly on IPA_RSL */
983 [] IPA_RSL[rsl_idx].receive(tr_ASP_RSL_UD(tr_RSL_NO_BCCH_INFO)) -> value rx_rsl_ud {
984 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
985 repeat;
986 }
987 [] IPA_RSL[rsl_idx].receive(tr_ASP_RSL_UD(tr_RSL_BCCH_INFO)) -> value rx_rsl_ud {
988 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
989 repeat;
990 }
991 [] IPA_RSL[rsl_idx].receive(tr_ASP_RSL_UD(tr_RSL_NO_SACCH_FILL)) -> value rx_rsl_ud {
992 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
993 repeat;
994 }
995 [] IPA_RSL[rsl_idx].receive(tr_ASP_RSL_UD(tr_RSL_SACCH_FILL)) -> value rx_rsl_ud {
996 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
997 repeat;
998 }
999
1000 /* For handler_mode := true, receiving the RSL bootstrap messages via RSL_Emulation */
1001 [] RSL_CCHAN[rsl_idx].receive(tr_ASP_RSL_UD(tr_RSL_NO_BCCH_INFO)) -> value rx_rsl_ud {
1002 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
1003 repeat;
1004 }
1005 [] RSL_CCHAN[rsl_idx].receive(tr_ASP_RSL_UD(tr_RSL_BCCH_INFO)) -> value rx_rsl_ud {
1006 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
1007 repeat;
1008 }
1009 [] RSL_CCHAN[rsl_idx].receive(tr_ASP_RSL_UD(tr_RSL_NO_SACCH_FILL)) -> value rx_rsl_ud {
1010 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
1011 repeat;
1012 }
1013 [] RSL_CCHAN[rsl_idx].receive(tr_ASP_RSL_UD(tr_RSL_SACCH_FILL)) -> value rx_rsl_ud {
1014 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
1015 repeat;
1016 }
1017}
1018
Neels Hofmeyra460f1f2020-08-09 20:17:03 +00001019/* TODO: use BooleanList from COMMON/src/General_Types.ttcn */
1020private type record of boolean my_BooleanList;
1021
1022private function f_vty_msc_allow_attach(TELNETasp_PT pt, my_BooleanList allow_attach_list)
1023{
Neels Hofmeyr8f576712020-08-12 22:49:53 +00001024 var charstring config := f_vty_transceive_ret(pt, "show running-config");
1025
Neels Hofmeyra460f1f2020-08-09 20:17:03 +00001026 for (var integer msc_nr := 0; msc_nr < sizeof(allow_attach_list); msc_nr := msc_nr+1) {
Neels Hofmeyr8f576712020-08-12 22:49:53 +00001027 if (f_strstr(config, "\nmsc " & int2str(msc_nr) & "\n") < 0) {
1028 /* There is no 'msc N' for this msc_nr in the running config, so don't create an empty msc by
1029 * stepping into that config node. */
1030 log("msc ", msc_nr, " is not configured, skipping");
1031 continue;
1032 }
Neels Hofmeyra460f1f2020-08-09 20:17:03 +00001033 f_vty_enter_cfg_msc(pt, msc_nr);
1034 if (allow_attach_list[msc_nr]) {
1035 /* strict := false: ignore if osmo-bsc does not support this config option (latest build) */
1036 f_vty_transceive(pt, "allow-attach", strict := false);
1037 } else {
1038 f_vty_transceive(pt, "no allow-attach", strict := false);
1039 }
1040 f_vty_transceive(pt, "exit");
1041 f_vty_transceive(pt, "exit");
1042 }
1043}
1044
Harald Welte21b46bd2017-12-17 19:46:32 +01001045/* global initialization function
1046 * \param nr_bts Number of BTSs we should start/bring up
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001047 * \param handler_mode Start an RSL_Emulation_CT component (true) or not (false).
1048 * \param nr_msc Number of virtual MSCs to bring up to connect to osmo-bsc.
1049 */
1050function f_init(integer nr_bts := NUM_BTS, boolean handler_mode := false, boolean allow_osmux := false,
Neels Hofmeyr4fbad7f2020-06-16 00:30:47 +02001051 integer nr_msc := 1, float guard_timeout := 30.0) runs on test_CT {
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001052 var integer bssap_idx;
Harald Welte28d943e2017-11-25 15:00:50 +01001053
Harald Welteae026692017-12-09 01:03:01 +01001054 if (g_initialized) {
1055 return;
Harald Welte28d943e2017-11-25 15:00:50 +01001056 }
Harald Welteae026692017-12-09 01:03:01 +01001057 g_initialized := true;
1058
Neels Hofmeyr4fbad7f2020-06-16 00:30:47 +02001059 T_guard.start(guard_timeout);
Daniel Willmanne68f9272018-11-27 15:15:28 +01001060 activate(as_Tguard());
1061
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02001062 f_init_vty("VirtMSC");
Pau Espin Pedrol58cf6822019-05-28 18:11:33 +02001063 if (mp_enable_osmux_test) {
1064 f_vty_allow_osmux(allow_osmux);
1065 }
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02001066
Neels Hofmeyra460f1f2020-08-09 20:17:03 +00001067 var my_BooleanList allow_attach := { false, false, false };
Daniel Willmannebdecc02020-08-12 15:30:17 +02001068 f_init_statsd("VirtMSC", vc_STATSD, mp_test_ip, mp_bsc_statsd_port);
1069
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001070 for (bssap_idx := 0; bssap_idx < nr_msc; bssap_idx := bssap_idx+1) {
Neels Hofmeyra460f1f2020-08-09 20:17:03 +00001071 allow_attach[bssap_idx] := true;
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001072 /* Call a function of our 'parent component' RAN_Adapter_CT to start the
1073 * MSC-side BSSAP emulation */
1074 if (handler_mode) {
1075 var RanOps ranops := MSC_RanOps;
1076 ranops.use_osmux := g_osmux_enabled;
1077 f_ran_adapter_init(g_bssap[bssap_idx], mp_bssap_cfg[bssap_idx], "VirtMSC", ranops);
1078 connect(self:SCCPLITE_IPA_CTRL, g_bssap[bssap_idx].vc_RAN:CTRL_CLIENT);
1079 f_ran_adapter_start(g_bssap[bssap_idx]);
1080 } else {
1081 f_ran_adapter_init(g_bssap[bssap_idx], mp_bssap_cfg[bssap_idx], "VirtMSC", omit);
1082 connect(self:BSSAP, g_bssap[bssap_idx].vc_SCCP:SCCP_SP_PORT);
1083 f_ran_adapter_start(g_bssap[bssap_idx]);
1084 f_legacy_bssap_reset();
1085 }
Harald Welte67089ee2018-01-17 22:19:03 +01001086 }
Harald Welted5833a82018-05-27 16:52:56 +02001087
Neels Hofmeyrcfe44062020-10-15 02:28:08 +02001088 if (mp_enable_lcs_tests) {
1089 if (handler_mode) {
1090 f_bssap_le_adapter_init(g_bssap_le, mp_bssap_le_cfg, "VirtSMLC", SMLC_BssapLeOps);
1091 } else {
1092 f_bssap_le_adapter_init(g_bssap_le, mp_bssap_le_cfg, "VirtSMLC", omit);
1093 connect(self:BSSAP_LE, g_bssap_le.vc_SCCP:SCCP_SP_PORT);
1094 }
1095 f_bssap_le_adapter_start(g_bssap_le);
Harald Welte47cd0e32020-08-21 12:39:11 +02001096 }
Harald Welte47cd0e32020-08-21 12:39:11 +02001097
Neels Hofmeyra460f1f2020-08-09 20:17:03 +00001098 /* start the test with exactly all enabled MSCs allowed to attach */
1099 f_vty_msc_allow_attach(BSCVTY, allow_attach);
1100
Harald Welteffe55fc2018-01-17 22:39:54 +01001101 f_ipa_ctrl_start(mp_bsc_ip, mp_bsc_ctrl_port);
Harald Welte28d943e2017-11-25 15:00:50 +01001102
Daniel Willmann191e0d92018-01-17 12:44:35 +01001103 f_init_mgcp("VirtMSC");
1104
Neels Hofmeyr0b7365b2020-07-04 00:52:34 +02001105 for (var integer i := 0; i < nr_bts; i := i+1) {
1106 f_init_bts(i, handler_mode);
Harald Welte696ddb62017-12-08 14:01:43 +01001107 }
Neels Hofmeyr0b7365b2020-07-04 00:52:34 +02001108}
Harald Welte696ddb62017-12-08 14:01:43 +01001109
Neels Hofmeyr0b7365b2020-07-04 00:52:34 +02001110function f_init_bts(integer bts_idx := 0, boolean handler_mode := false)
1111runs on test_CT {
1112 /* wait until osmo-bts-omldummy has respawned */
1113 f_wait_oml(bts_idx, "degraded", 5.0);
1114
1115 /* start RSL connection */
1116 f_ipa_rsl_start(bts[bts_idx].rsl, mp_bsc_ip, mp_bsc_rsl_port, bts_idx, handler_mode);
1117 /* wait until BSC tells us "connected" */
1118 f_wait_oml(bts_idx, "connected", 5.0);
Harald Welte28d943e2017-11-25 15:00:50 +01001119}
1120
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +02001121function f_init_bts_and_check_sysinfo(integer bts_idx := 0, boolean handler_mode := false,
1122 template SystemInformationConfig expect_si)
1123runs on test_CT {
1124 var default sysinfo := activate(as_catch_RSL_sysinfo(bts_idx));
1125
1126 f_init_bts(bts_idx, handler_mode);
1127
1128 /* Give some time to (hopefully/most likely) collect all system informations from RSL startup.
1129 * We could stop as soon as all expected SI are received, but then we might miss SI that we don't expect and
1130 * that might be sent afterwards. So rather give a generous timeout and be quite sure to catch all SI.
1131 */
1132 f_sleep(5.0);
1133 log("RSL ", bts_idx, " SYSTEM INFORMATION: ", g_system_information[bts_idx]);
1134
1135 deactivate(sysinfo);
1136
1137 if (match(g_system_information[bts_idx], expect_si)) {
1138 setverdict(pass);
1139 } else {
1140 log("RSL ", bts_idx, ": EXPECTED SI: ", expect_si);
1141 log("RSL ", bts_idx, ": GOT SI: ", g_system_information[bts_idx]);
1142 setverdict(fail, "received SI does not match expectations");
1143 return;
1144 }
1145}
1146
Maxd4e56962018-10-31 19:08:25 +01001147/* expect to receive a RSL message matching a specified template on a given BTS / stream */
Harald Welte65e419a2020-08-21 12:38:33 +02001148function 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 +01001149runs on test_CT return RSL_Message {
1150 var ASP_RSL_Unitdata rx_rsl_ud;
1151 timer T := t_secs;
1152
1153 T.start;
1154 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001155 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(t_rx, sid)) -> value rx_rsl_ud {
Harald Welteae026692017-12-09 01:03:01 +01001156 T.stop;
1157 }
1158 [] IPA_RSL[bts_nr].receive { repeat; }
Harald Welteb2917702017-12-10 15:48:52 +01001159 [] T.timeout {
1160 setverdict(fail, "Timeout expecting ", t_rx);
Daniel Willmannafce8662018-07-06 23:11:32 +02001161 mtc.stop;
Harald Welteb2917702017-12-10 15:48:52 +01001162 }
Harald Welteae026692017-12-09 01:03:01 +01001163 }
1164 return rx_rsl_ud.rsl;
1165}
1166
Harald Welte21b46bd2017-12-17 19:46:32 +01001167/* helper function to transmit RSL on a given BTS/stream */
Harald Welte65e419a2020-08-21 12:38:33 +02001168function 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 +01001169runs on test_CT {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001170 IPA_RSL[bts_nr].send(ts_ASP_RSL_UD(t_tx, sid));
Harald Welteae026692017-12-09 01:03:01 +01001171}
1172
1173
Harald Welte4003d112017-12-09 22:35:39 +01001174/* verify we get a CHAN_ACT after CHAN RQD */
Harald Welteae026692017-12-09 01:03:01 +01001175testcase TC_chan_act_noreply() runs on test_CT {
1176 var BSSAP_N_UNITDATA_ind ud_ind;
Harald Welte930d0a72018-03-22 22:08:40 +01001177 var RSL_Message rsl_unused;
Harald Welte28d943e2017-11-25 15:00:50 +01001178
Harald Welte89d42e82017-12-17 16:42:41 +01001179 f_init(1);
Harald Welte28d943e2017-11-25 15:00:50 +01001180
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001181 IPA_RSL[0].send(ts_ASP_RSL_UD(ts_RSL_CHAN_RQD('23'O, 23)));
Harald Welte930d0a72018-03-22 22:08:40 +01001182 rsl_unused := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001183 f_shutdown_helper();
Harald Welte28d943e2017-11-25 15:00:50 +01001184}
1185
Harald Welte4003d112017-12-09 22:35:39 +01001186/* verify if the "chreq:total" counter increments as expected */
1187testcase TC_chan_act_counter() runs on test_CT {
1188 var BSSAP_N_UNITDATA_ind ud_ind;
1189 var integer chreq_total;
Harald Welte930d0a72018-03-22 22:08:40 +01001190 var RSL_Message rsl_unused;
Harald Welte4003d112017-12-09 22:35:39 +01001191
Harald Welte89d42e82017-12-17 16:42:41 +01001192 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +01001193
1194 chreq_total := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total");
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001195 IPA_RSL[0].send(ts_ASP_RSL_UD(ts_RSL_CHAN_RQD('23'O, 23)));
Harald Welte930d0a72018-03-22 22:08:40 +01001196 rsl_unused := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
Harald Welte4003d112017-12-09 22:35:39 +01001197 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total", chreq_total+1);
1198
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001199 f_shutdown_helper();
Harald Welte4003d112017-12-09 22:35:39 +01001200}
1201
Harald Welteae026692017-12-09 01:03:01 +01001202/* CHAN RQD -> CHAN ACT -> CHAN ACT ACK -> RF CHAN REL */
Philipp Maier9c60a622020-07-09 15:08:46 +02001203private function f_TC_chan_act_ack_noest(OCT1 ra := '23'O) runs on test_CT {
Harald Welteae026692017-12-09 01:03:01 +01001204 var RSL_Message rx_rsl;
1205
Harald Welteae026692017-12-09 01:03:01 +01001206 /* Send CHAN RQD and wait for allocation; acknowledge it */
Philipp Maier9c60a622020-07-09 15:08:46 +02001207 var RslChannelNr chan_nr := f_chreq_act_ack(ra);
Harald Welteae026692017-12-09 01:03:01 +01001208
1209 /* expect BSC to disable the channel again if there's no RLL EST IND */
1210 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), T3101_MAX);
1211
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001212 f_shutdown_helper();
Harald Welteae026692017-12-09 01:03:01 +01001213}
1214
Philipp Maier9c60a622020-07-09 15:08:46 +02001215/* Normal variant */
1216testcase TC_chan_act_ack_noest() runs on test_CT {
Philipp Maieraf58db22020-08-12 17:24:40 +02001217 f_init(1);
Philipp Maier9c60a622020-07-09 15:08:46 +02001218 f_TC_chan_act_ack_noest();
1219}
1220
1221/* Emergency call variant */
1222testcase TC_chan_act_ack_noest_emerg() runs on test_CT {
1223 /* See also: 3GPP TS 04.08, Table 9.9, ra=101xxxxx */
Philipp Maieraf58db22020-08-12 17:24:40 +02001224 f_init(1);
1225 f_vty_allow_emerg_bts(true, 0);
Philipp Maier9c60a622020-07-09 15:08:46 +02001226 f_TC_chan_act_ack_noest(ra := 'A5'O);
1227}
1228
Philipp Maier606f07d2020-08-12 17:21:58 +02001229/* Emergency call variant, but emergency calls are not allowed */
1230testcase TC_chan_rqd_emerg_deny() runs on test_CT {
1231 /* See also: 3GPP TS 04.08, Table 9.9, ra=101xxxxx */
1232
1233 var RSL_Message rx_rsl;
1234 var GsmRrMessage rr;
1235
1236 f_init(1);
1237 f_vty_allow_emerg_bts(false, 0);
1238
1239 IPA_RSL[0].clear;
1240 f_ipa_tx(0, ts_RSL_CHAN_RQD('A5'O, 23));
1241
1242 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeC(RSL_MT_IMMEDIATE_ASSIGN_CMD));
1243 rr := dec_GsmRrMessage(rx_rsl.ies[1].body.full_imm_ass_info.payload);
1244 if (rr.header.message_type == IMMEDIATE_ASSIGNMENT_REJECT) {
1245 setverdict(pass);
1246 } else {
1247 setverdict(fail, "immediate assignment not rejected");
1248 }
1249}
1250
Harald Welteae026692017-12-09 01:03:01 +01001251/* Test behavior if MSC never answers to CR */
1252testcase TC_chan_act_ack_est_ind_noreply() runs on test_CT {
Harald Weltef77aef62018-01-28 15:35:42 +01001253 var RslLinkId main_dcch := valueof(ts_RslLinkID_DCCH(0));
1254 var IpaStreamId sid := IPAC_PROTO_RSL_TRX0;
Harald Welteae026692017-12-09 01:03:01 +01001255 var RSL_Message rx_rsl;
Harald Weltef77aef62018-01-28 15:35:42 +01001256 var ASP_RSL_Unitdata rx_rsl_ud;
Harald Welteae026692017-12-09 01:03:01 +01001257
Harald Welte89d42e82017-12-17 16:42:41 +01001258 f_init(1);
Harald Welteae026692017-12-09 01:03:01 +01001259
1260 /* Send CHAN RQD and wait for allocation; acknowledge it */
Harald Welted6939652017-12-13 21:02:46 +01001261 var RslChannelNr chan_nr := f_chreq_act_ack();
Harald Welteae026692017-12-09 01:03:01 +01001262
1263 var octetstring l3 := '00010203040506'O
1264 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
1265
1266 BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3)));
1267
1268 /* expect BSC to disable the channel again if there's no response from MSC */
Harald Weltef77aef62018-01-28 15:35:42 +01001269 /* MS waits 20s (T3210) at LU; 10s (T3230) at CM SERV REQ and 5s (T3220) AT detach */
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001270 f_expect_chan_rel(0, chan_nr, expect_rll_rel_req := false);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001271 f_shutdown_helper();
Harald Welteae026692017-12-09 01:03:01 +01001272}
1273
1274/* Test behavior if MSC answers with CREF to CR */
1275testcase TC_chan_act_ack_est_ind_refused() runs on test_CT {
1276 var BSSAP_N_CONNECT_ind rx_c_ind;
1277 var RSL_Message rx_rsl;
1278
Harald Welte89d42e82017-12-17 16:42:41 +01001279 f_init(1);
Harald Welteae026692017-12-09 01:03:01 +01001280
1281 /* Send CHAN RQD and wait for allocation; acknowledge it */
Harald Welted6939652017-12-13 21:02:46 +01001282 var RslChannelNr chan_nr := f_chreq_act_ack();
Harald Welteae026692017-12-09 01:03:01 +01001283
1284 var octetstring l3 := '00010203040506'O
1285 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
1286
1287 BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) -> value rx_c_ind;
1288 BSSAP.send(ts_BSSAP_DISC_req(rx_c_ind.connectionId, 0));
1289
1290 /* expect BSC to disable the channel */
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001291 f_expect_chan_rel(0, chan_nr, expect_rll_rel_req := false);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001292 f_shutdown_helper();
Harald Welteae026692017-12-09 01:03:01 +01001293}
1294
Harald Welte618ef642017-12-14 14:58:20 +01001295/* CHAN RQD -> CHAN ACT -> CHAN ACT NACK -> RF CHAN REL */
1296testcase TC_chan_act_nack() runs on test_CT {
1297 var RSL_Message rx_rsl;
1298 var integer chact_nack;
1299
Harald Welte89d42e82017-12-17 16:42:41 +01001300 f_init(1);
Harald Welte618ef642017-12-14 14:58:20 +01001301
1302 chact_nack := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chan_act:nack");
1303
1304 f_ipa_tx(0, ts_RSL_CHAN_RQD('33'O, 33));
1305 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
1306 var RslChannelNr chan_nr := rx_rsl.ies[0].body.chan_nr;
1307
1308 f_ipa_tx(0, ts_RSL_CHAN_ACT_NACK(chan_nr, RSL_ERR_EQUIPMENT_FAIL));
1309
1310 /* wait for some time to hope the NACK arrives before the CTRL GET below */
1311 f_sleep(0.5);
1312
1313 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chan_act:nack", chact_nack+1);
1314
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001315 f_shutdown_helper();
Harald Welte618ef642017-12-14 14:58:20 +01001316}
1317
Harald Welte799c97b2017-12-14 17:50:30 +01001318/* Test for channel exhaustion due to RACH overload */
1319testcase TC_chan_exhaustion() runs on test_CT {
1320 var ASP_RSL_Unitdata rsl_ud;
1321 var integer i;
1322 var integer chreq_total, chreq_nochan;
1323
Harald Welte89d42e82017-12-17 16:42:41 +01001324 f_init(1);
Harald Welte799c97b2017-12-14 17:50:30 +01001325
1326 chreq_total := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total");
1327 chreq_nochan := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:no_channel");
1328
Pau Espin Pedrolfe200d72018-12-10 12:41:04 +01001329 /* GSM 04.08 Table 9.9a:
1330 * RA = '33'O -> Establishment cause = 0011xxxx (MS dual rate capable and asks for "TCH/H or TCH/F").
1331 * With current setup, expect 4xSDCCH + 4xTCH/F + 1xTCH/H to succeed */
Philipp Maiercb6cc482018-03-26 13:08:00 +02001332 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 +01001333 var RslChannelNr chan_nr := f_chreq_act_ack('33'O, i);
Harald Welte799c97b2017-12-14 17:50:30 +01001334 }
1335
1336 IPA_RSL[0].clear;
1337
Harald Weltedd8cbf32018-01-28 12:07:52 +01001338 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total",
Philipp Maiercb6cc482018-03-26 13:08:00 +02001339 chreq_total + NUM_TCHF_PER_BTS + NUM_TCHH_PER_BTS + NUM_SDCCH_PER_BTS);
Harald Welte799c97b2017-12-14 17:50:30 +01001340
1341 /* now expect additional channel activations to fail */
1342 f_ipa_tx(0, ts_RSL_CHAN_RQD('42'O, 42));
1343
1344 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001345 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV))) {
Harald Welte799c97b2017-12-14 17:50:30 +01001346 setverdict(fail, "Received CHAN ACT ACK without resources?!?");
1347 }
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001348 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_IMM_ASSIGN(?))) -> value rsl_ud {
Harald Welte799c97b2017-12-14 17:50:30 +01001349 var GsmRrMessage rr;
1350 /* match on IMM ASS REJ */
1351 rr := dec_GsmRrMessage(rsl_ud.rsl.ies[1].body.full_imm_ass_info.payload);
1352 if (rr.header.message_type == IMMEDIATE_ASSIGNMENT_REJECT) {
1353 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total",
Philipp Maiercb6cc482018-03-26 13:08:00 +02001354 chreq_total + NUM_TCHF_PER_BTS + NUM_TCHH_PER_BTS + NUM_SDCCH_PER_BTS+1);
Harald Welte799c97b2017-12-14 17:50:30 +01001355 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:no_channel",
1356 chreq_nochan+1);
1357 setverdict(pass);
1358 } else {
1359 repeat;
1360 }
1361 }
1362 [] IPA_RSL[0].receive { repeat; }
1363 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001364 f_shutdown_helper();
Harald Welte799c97b2017-12-14 17:50:30 +01001365}
1366
Vadim Yanitskiy1ff1fdf2018-11-27 01:32:57 +07001367/* Test channel deactivation due to silence from MS */
1368testcase TC_chan_deact_silence() runs on test_CT {
1369 var RslChannelNr chan_nr;
1370
1371 f_init(1);
1372
1373 /* Request for a dedicated channel */
1374 chan_nr := f_chreq_act_ack('23'O);
1375
1376 /* Wait some time until the channel is released */
1377 f_sleep(2.0);
1378
1379 /* Expect CHANnel RELease */
1380 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001381 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL))) {
Vadim Yanitskiy1ff1fdf2018-11-27 01:32:57 +07001382 log("Received CHANnel RELease");
1383 setverdict(pass);
1384 }
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001385 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_IMM_ASSIGN(?))) {
Vadim Yanitskiy1ff1fdf2018-11-27 01:32:57 +07001386 /* See OS#3709, OsmoBSC should not send Immediate
1387 * Assignment Reject since a dedicated channel was
1388 * already allocated, and Immediate Assignment was
1389 * already sent. */
1390 setverdict(fail, "Unexpected Immediate Assignment!");
1391 }
1392 [] IPA_RSL[0].receive {
1393 setverdict(fail, "Unexpected RSL message!");
1394 }
1395 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001396 f_shutdown_helper();
Vadim Yanitskiy1ff1fdf2018-11-27 01:32:57 +07001397}
1398
Harald Weltecfe2c962017-12-15 12:09:32 +01001399/***********************************************************************
1400 * Assignment Testing
1401 ***********************************************************************/
1402
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02001403/* Verify that the BSC refuses any BSSAP connection from the MSC (They are all BSC->MSC direction,
1404 * except for the inter-BSC handover, MT side) */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001405testcase TC_outbound_connect(integer bssap_idx := 0) runs on test_CT {
Harald Welte89d42e82017-12-17 16:42:41 +01001406 f_init(1);
Harald Weltecfe2c962017-12-15 12:09:32 +01001407
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001408 BSSAP.send(ts_BSSAP_CONNECT_req(g_bssap[bssap_idx].sccp_addr_peer, g_bssap[bssap_idx].sccp_addr_own,
1409 2342, ts_BSSMAP_AssignmentReq));
Harald Weltecfe2c962017-12-15 12:09:32 +01001410 BSSAP.receive(tr_BSSAP_DISC_ind(2342, ?, ?));
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001411 f_shutdown_helper();
Harald Weltecfe2c962017-12-15 12:09:32 +01001412}
1413
Harald Welte16a4adf2017-12-14 18:54:01 +01001414/* Test behavior if MSC answers with CREF to CR */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001415testcase TC_assignment_cic_only(integer bssap_idx := 0) runs on test_CT {
Harald Welte16a4adf2017-12-14 18:54:01 +01001416 var BSSAP_N_CONNECT_ind rx_c_ind;
1417 var RSL_Message rx_rsl;
1418 var DchanTuple dt;
1419
Harald Welte89d42e82017-12-17 16:42:41 +01001420 f_init(1);
Harald Welte16a4adf2017-12-14 18:54:01 +01001421
1422 dt := f_est_dchan('23'O, 23, '00000000'O);
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001423 if (mp_bssap_cfg[bssap_idx].transport == BSSAP_TRANSPORT_AoIP) {
Harald Welte17b27da2018-05-25 20:33:53 +02001424 /* send assignment without AoIP IEs */
1425 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_AssignmentReq(ts_BSSMAP_IE_CIC(0, 1))));
1426 } else {
1427 /* Send assignmetn without CIC in IPA case */
1428 var BSSMAP_IE_AoIP_TransportLayerAddress tla :=
1429 valueof(ts_BSSMAP_IE_AoIP_TLA4('01020304'O, 2342));
1430 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_AssignmentReq(omit, tla)));
1431 }
Harald Welte16a4adf2017-12-14 18:54:01 +01001432 alt {
1433 [] BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_AssignmentComplete)) {
1434 setverdict(fail, "AoIP BSC cannot accept ASSIGNMENT without AoIP Transport IE");
1435 }
Harald Welte235ebf12017-12-15 14:18:16 +01001436 /* TODO: Actually expect GSM0808_CAUSE_REQ_A_IF_TYPE_NOT_SUPP */
Harald Welte16a4adf2017-12-14 18:54:01 +01001437 [] BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_AssignmentFail)) {
1438 setverdict(pass);
1439 }
1440 [] BSSAP.receive { repeat; }
1441 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001442 f_shutdown_helper();
Harald Welte16a4adf2017-12-14 18:54:01 +01001443}
1444
Harald Welteed848512018-05-24 22:27:58 +02001445/* generate an assignment request for either AoIP or SCCPlite */
Pau Espin Pedrol07866632020-09-03 19:10:55 +02001446function 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 +02001447 var PDU_BSSAP ass_cmd;
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02001448 var BSSMAP_IE_Osmo_OsmuxCID osmux_cid := valueof(ts_OsmuxCID(0));
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001449 if (mp_bssap_cfg[bssap_idx].transport == BSSAP_TRANSPORT_AoIP) {
Harald Welteed848512018-05-24 22:27:58 +02001450 var BSSMAP_IE_AoIP_TransportLayerAddress tla :=
Pau Espin Pedrol07866632020-09-03 19:10:55 +02001451 valueof(f_ts_BSSMAP_IE_AoIP_TLA(aoip_tla, 2342));
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02001452 if (osmux_enabled) {
1453 ass_cmd := valueof(ts_BSSMAP_AssignmentReq(omit, tla, osmux_cid));
1454 } else {
1455 ass_cmd := valueof(ts_BSSMAP_AssignmentReq(omit, tla));
1456 }
Harald Welteed848512018-05-24 22:27:58 +02001457 } else {
1458 var BSSMAP_IE_CircuitIdentityCode cic := valueof(ts_BSSMAP_IE_CIC(0,1));
Pau Espin Pedrol096d73d2019-06-06 12:49:17 +02001459 ass_cmd := valueof(ts_BSSMAP_AssignmentReq(cic, omit));
Harald Welteed848512018-05-24 22:27:58 +02001460 }
1461 return ass_cmd;
1462}
1463
Pau Espin Pedrol07866632020-09-03 19:10:55 +02001464function 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 +01001465 var PDU_BSSAP ho_req;
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001466 if (mp_bssap_cfg[bssap_idx].transport == BSSAP_TRANSPORT_AoIP) {
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01001467 var BSSMAP_IE_AoIP_TransportLayerAddress tla :=
Pau Espin Pedrol07866632020-09-03 19:10:55 +02001468 valueof(f_ts_BSSMAP_IE_AoIP_TLA(aoip_tla, 2342));
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01001469 ho_req := valueof(ts_BSSMAP_HandoverRequest(omit, tla));
1470 } else {
1471 var BSSMAP_IE_CircuitIdentityCode cic := valueof(ts_BSSMAP_IE_CIC(0,1));
1472 ho_req := valueof(ts_BSSMAP_HandoverRequest(cic, omit));
1473 }
1474 return ho_req;
1475}
1476
Harald Welteed848512018-05-24 22:27:58 +02001477/* generate an assignment complete template for either AoIP or SCCPlite */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001478function f_gen_exp_compl(boolean expect_osmux := false, integer bssap_idx := 0) return template PDU_BSSAP {
Harald Welteed848512018-05-24 22:27:58 +02001479 var template PDU_BSSAP exp_compl;
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02001480 var BSSMAP_IE_Osmo_OsmuxCID osmux_cid := valueof(ts_OsmuxCID(0));
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001481 if (mp_bssap_cfg[bssap_idx].transport == BSSAP_TRANSPORT_AoIP) {
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02001482 if (expect_osmux) {
1483 exp_compl := tr_BSSMAP_AssignmentComplete(omit, ?, osmux_cid);
1484 } else {
1485 exp_compl := tr_BSSMAP_AssignmentComplete(omit, ?, omit);
1486 }
Harald Welteed848512018-05-24 22:27:58 +02001487 } else {
1488 /* CIC is optional "*" as the MSC allocated it */
Pau Espin Pedrol096d73d2019-06-06 12:49:17 +02001489 exp_compl := tr_BSSMAP_AssignmentComplete(*, omit);
Harald Welteed848512018-05-24 22:27:58 +02001490 }
1491 return exp_compl;
1492}
1493
Harald Welte235ebf12017-12-15 14:18:16 +01001494/* Run everything required up to sending a caller-specified assignment command and expect response */
1495function f_assignment_exp(PDU_BSSAP ass_cmd, template PDU_BSSAP exp, charstring fail_text)
1496runs on test_CT {
1497 var BSSAP_N_CONNECT_ind rx_c_ind;
1498 var RSL_Message rx_rsl;
1499 var DchanTuple dt;
1500
Harald Welte89d42e82017-12-17 16:42:41 +01001501 f_init(1);
Harald Welte235ebf12017-12-15 14:18:16 +01001502
1503 dt := f_est_dchan('23'O, 23, '00000000'O);
1504 /* send assignment without AoIP IEs */
1505 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ass_cmd));
1506 alt {
1507 [] BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_AssignmentComplete)) {
1508 if (ischosen(exp.pdu.bssmap.assignmentComplete)) {
1509 setverdict(pass);
1510 } else {
1511 setverdict(fail, fail_text);
1512 }
1513 }
1514 [] BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_AssignmentFail)) {
1515 if (ischosen(exp.pdu.bssmap.assignmentFailure)) {
1516 setverdict(pass);
1517 } else {
1518 setverdict(fail, fail_text);
1519 }
1520 }
1521 [] BSSAP.receive { repeat; }
1522 }
1523}
1524testcase TC_assignment_csd() runs on test_CT {
1525 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
Harald Welteed848512018-05-24 22:27:58 +02001526 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte235ebf12017-12-15 14:18:16 +01001527 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeCSD);
1528 //exp_fail.pdu.bssmap.assignmentFailure.cause.causeValue := int2bit(enum2int(GSM0808_CAUSE_REQ_CODEC_TYPE_OR_CONFIG_UNAVAIL), 7);
1529 f_assignment_exp(ass_cmd, exp_fail, "BSC accepted Assignment for CSD");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001530 f_shutdown_helper();
Harald Welte235ebf12017-12-15 14:18:16 +01001531}
1532
1533testcase TC_assignment_ctm() runs on test_CT {
1534 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
Harald Welteed848512018-05-24 22:27:58 +02001535 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte235ebf12017-12-15 14:18:16 +01001536 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeCTM);
1537 //exp_fail.pdu.bssmap.assignmentFailure.cause.causeValue := int2bit(enum2int(GSM0808_CAUSE_REQ_CODEC_TYPE_OR_CONFIG_UNAVAIL), 7);
1538 f_assignment_exp(ass_cmd, exp_fail, "BSC accepted Assignment for Speech+CTM");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001539 f_shutdown_helper();
Harald Welte235ebf12017-12-15 14:18:16 +01001540}
1541
Harald Welte4003d112017-12-09 22:35:39 +01001542type record DchanTuple {
1543 integer sccp_conn_id,
1544 RslChannelNr rsl_chan_nr
Harald Weltea5d2ab22017-12-09 14:21:42 +01001545}
1546
Harald Welted6939652017-12-13 21:02:46 +01001547/* Send CHAN RQD and wait for allocation; acknowledge it */
1548private function f_chreq_act_ack(OCT1 ra := '23'O, GsmFrameNumber fn := 23)
1549runs on test_CT return RslChannelNr {
1550 var RSL_Message rx_rsl;
1551 f_ipa_tx(0, ts_RSL_CHAN_RQD(ra, fn));
1552 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
1553 var RslChannelNr chan_nr := rx_rsl.ies[0].body.chan_nr;
1554 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, fn+10));
Daniel Willmannf4ac4ce2018-08-02 14:06:30 +02001555 rx_rsl := f_exp_ipa_rx(0, tr_RSL_IMM_ASSIGN(0));
Harald Welted6939652017-12-13 21:02:46 +01001556 return chan_nr;
1557}
1558
Harald Welte4003d112017-12-09 22:35:39 +01001559/* helper function to establish a dedicated channel via BTS and MSC */
1560function f_est_dchan(OCT1 ra, GsmFrameNumber fn, octetstring l3)
1561runs on test_CT return DchanTuple {
1562 var BSSAP_N_CONNECT_ind rx_c_ind;
Harald Welte4003d112017-12-09 22:35:39 +01001563 var DchanTuple dt;
Harald Weltea5d2ab22017-12-09 14:21:42 +01001564
Harald Welte4003d112017-12-09 22:35:39 +01001565 /* Send CHAN RQD and wait for allocation; acknowledge it */
Harald Welted6939652017-12-13 21:02:46 +01001566 dt.rsl_chan_nr := f_chreq_act_ack(ra, fn);
Harald Welte4003d112017-12-09 22:35:39 +01001567
1568 f_ipa_tx(0, ts_RSL_EST_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
1569
1570 BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) -> value rx_c_ind;
1571 dt.sccp_conn_id := rx_c_ind.connectionId;
1572 BSSAP.send(ts_BSSAP_CONNECT_res(dt.sccp_conn_id));
1573
1574 return dt;
Harald Weltea5d2ab22017-12-09 14:21:42 +01001575}
1576
Harald Welte641fcbe2018-06-14 10:58:35 +02001577/* expect RF CAN REL from BTS, acknowledge it and clear the MSC side */
1578private function f_exp_chan_rel_and_clear(DchanTuple dt, integer bts_nr := 0) runs on test_CT {
1579 var RSL_Message rx_rsl;
1580 /* expect BSC to disable the channel */
1581 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), T3101_MAX);
1582 /* respond with CHAN REL ACK */
1583 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(dt.rsl_chan_nr));
1584
1585 /* expect Clear Complete from BSC */
1586 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete));
1587
1588 /* MSC disconnects as instructed. */
1589 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
1590}
1591
Harald Welte4003d112017-12-09 22:35:39 +01001592/* Test behavior of channel release after unilateral RLL REL IND (DISC from MS) */
1593testcase TC_chan_rel_rll_rel_ind() runs on test_CT {
Neels Hofmeyr27f64362018-03-12 01:44:00 +01001594 var BSSAP_N_DATA_ind rx_di;
Harald Welte4003d112017-12-09 22:35:39 +01001595 var DchanTuple dt;
Harald Welte96c94412017-12-09 03:12:45 +01001596
Harald Welte89d42e82017-12-17 16:42:41 +01001597 f_init(1);
Harald Welte96c94412017-12-09 03:12:45 +01001598
Harald Welte4003d112017-12-09 22:35:39 +01001599 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1600
1601 /* simulate RLL REL IND */
1602 f_ipa_tx(0, ts_RSL_REL_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0))));
1603
Neels Hofmeyr27f64362018-03-12 01:44:00 +01001604 /* expect Clear Request on MSC side */
1605 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearRequest)) -> value rx_di;
1606
1607 /* Instruct BSC to clear channel */
1608 var BssmapCause cause := bit2int(rx_di.userData.pdu.bssmap.clearRequest.cause.causeValue);
1609 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
1610
Harald Welte4003d112017-12-09 22:35:39 +01001611 /* expect BSC to disable the channel */
Harald Welte641fcbe2018-06-14 10:58:35 +02001612 f_exp_chan_rel_and_clear(dt, 0);
Neels Hofmeyr27f64362018-03-12 01:44:00 +01001613
1614 /* wait for SCCP emulation to do its job */
1615 f_sleep(1.0);
Harald Welte4003d112017-12-09 22:35:39 +01001616
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001617 f_shutdown_helper();
Harald Welte4003d112017-12-09 22:35:39 +01001618}
1619
1620/* Test behavior of channel release after CONN FAIL IND from BTS */
1621testcase TC_chan_rel_conn_fail() runs on test_CT {
1622 var BSSAP_N_DATA_ind rx_di;
Harald Welte4003d112017-12-09 22:35:39 +01001623 var DchanTuple dt;
1624
Harald Welte89d42e82017-12-17 16:42:41 +01001625 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +01001626
1627 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1628
1629 /* simulate CONN FAIL IND */
Harald Weltea8ed9062017-12-14 09:46:01 +01001630 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 +01001631 /* TODO: different cause values? */
1632
Harald Welte4003d112017-12-09 22:35:39 +01001633 /* expect Clear Request from BSC */
1634 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearRequest)) -> value rx_di;
1635
1636 /* Instruct BSC to clear channel */
1637 var BssmapCause cause := bit2int(rx_di.userData.pdu.bssmap.clearRequest.cause.causeValue);
1638 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
1639
Harald Welte6ff76ea2018-01-28 13:08:01 +01001640 /* expect BSC to disable the channel */
Harald Welte641fcbe2018-06-14 10:58:35 +02001641 f_exp_chan_rel_and_clear(dt, 0);
Harald Welte4003d112017-12-09 22:35:39 +01001642
1643 /* wait for SCCP emulation to do its job */
1644 f_sleep(1.0);
1645
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001646 f_shutdown_helper();
Harald Welte4003d112017-12-09 22:35:39 +01001647}
1648
Harald Welte99f3ca02018-06-14 13:40:29 +02001649/* Test behavior of early CONN FAIL IND from BTS (before EST IND!) */
1650/* See also https://www.osmocom.org/issues/3182 */
1651testcase TC_early_conn_fail() runs on test_CT {
1652 var RSL_Message rx_rsl;
1653 var DchanTuple dt;
1654
1655 f_init(1);
1656
1657 /* BTS->BSC: Send CHAN RQD and wait for allocation; acknowledge it */
Harald Weltec46ea3c2020-10-10 18:46:12 +02001658 dt.rsl_chan_nr := f_chreq_act_ack(f_rnd_ra_cs(), 23);
Harald Welte99f3ca02018-06-14 13:40:29 +02001659
1660 /* BTS->BSC: simulate CONN FAIL IND */
1661 f_ipa_tx(0, ts_RSL_CONN_FAIL_IND(dt.rsl_chan_nr, RSL_ERR_RADIO_LINK_FAIL));
1662
1663 /* BTS->BSC: Expect RF channel release from BSC on Abis */
1664 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), 10.0);
1665
1666 /* BTS<-BSC: respond with CHAN REL ACK */
1667 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(dt.rsl_chan_nr));
1668
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001669 f_shutdown_helper();
Harald Welte99f3ca02018-06-14 13:40:29 +02001670}
1671
1672/* Test behavior of late CONN FAIL IND from BTS (ater REL IND!) */
1673/* See also https://www.osmocom.org/issues/3182 */
1674testcase TC_late_conn_fail() runs on test_CT {
1675 var RSL_Message rx_rsl;
1676 var DchanTuple dt;
1677
1678 f_init(1);
1679
1680 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1681
1682 /* BSC<-MSC: Instruct BSC to clear connection */
1683 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(0)));
1684
1685 /* BTS->BSC: expect BSC to deactivate SACCH */
1686 rx_rsl := f_exp_ipa_rx(0, tr_RSL_DEACT_SACCH(dt.rsl_chan_nr));
1687
1688 /* BTS->BSC: simulate a late CONN FAIL IND from BTS */
1689 f_ipa_tx(0, ts_RSL_CONN_FAIL_IND(dt.rsl_chan_nr, RSL_ERR_RADIO_LINK_FAIL));
1690
1691 /* BTS<-BSC: Expect RF channel release from BSC on Abis */
1692 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), 10.0);
1693 /* BTS->BSC: respond with CHAN REL ACK */
1694 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(dt.rsl_chan_nr));
1695
1696 /* BSC->MSC: expect Clear Complete from BSC */
1697 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete));
1698
1699 /* BSC<-MSC: MSC disconnects as requested. */
1700 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
1701
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001702 f_shutdown_helper();
Harald Welte99f3ca02018-06-14 13:40:29 +02001703}
1704
Neels Hofmeyrf44ccd12018-11-05 19:15:23 +01001705function f_expect_chan_rel(integer bts_nr, RslChannelNr rsl_chan_nr,
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001706 boolean expect_deact_sacch := true,
1707 boolean expect_rr_chan_rel := true,
1708 boolean expect_rll_rel_req := true,
Harald Welte99787102019-02-04 10:41:36 +01001709 boolean handle_rll_rel := true,
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02001710 boolean is_csfb := false,
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02001711 template CellSelIndValue csfb_expect_cells := omit,
1712 template RR_Cause expect_rr_cause := ?
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001713 ) runs on test_CT {
Harald Welte91d54a52018-01-28 15:35:07 +01001714
1715 var RslLinkId main_dcch := valueof(ts_RslLinkID_DCCH(0));
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001716 var boolean got_deact_sacch := false;
1717 var boolean got_rr_chan_rel := false;
1718 var boolean got_rll_rel_req := false;
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02001719 var ASP_RSL_Unitdata ud;
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02001720 var RSL_IE_Body l3_ie;
1721 var PDU_ML3_NW_MS l3;
1722 var RR_Cause got_cause;
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001723 log("f_expect_chan_rel() expecting: expect_deact_sacch=", expect_deact_sacch, " expect_rr_chan_rel=", expect_rr_chan_rel,
1724 " expect_rll_rel_req=", expect_rll_rel_req);
Harald Welte91d54a52018-01-28 15:35:07 +01001725 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001726 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(tr_RSL_DEACT_SACCH(rsl_chan_nr))) {
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001727 got_deact_sacch := true;
Harald Welte91d54a52018-01-28 15:35:07 +01001728 repeat;
1729 }
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02001730 [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 +01001731 got_rr_chan_rel := true;
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02001732
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02001733 if (f_rsl_find_ie(ud.rsl, RSL_IE_L3_INFO, l3_ie) == false) {
1734 setverdict(fail, "cannot find L3");
1735 mtc.stop;
1736 }
1737 l3 := dec_PDU_ML3_NW_MS(l3_ie.l3_info.payload);
1738
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02001739 if (not istemplatekind(csfb_expect_cells, "omit")) {
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02001740 var CellSelIndValue cells := dec_CellSelIndValue(
1741 l3.msgs.rrm.channelRelease.cellSelectionIndicator.cellSelectionIndicatorValue);
1742
1743 log("GOT RR CHANNEL RELEASE CSFB CELLS: ", cells);
1744 if (match(cells, csfb_expect_cells)) {
1745 setverdict(pass);
1746 } else {
1747 log("EXPECTED CSFB CELLS: ", csfb_expect_cells);
1748 setverdict(fail, "Received CSFB cells list on RR Channel Release does not match expectations");
1749 }
1750 }
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02001751
1752 if (not istemplatekind(expect_rr_cause, "omit")) {
1753 int2enum(oct2int(l3.msgs.rrm.channelRelease.rRCause.valuePart), got_cause);
1754 log("GOT CAUSE CODE: ", l3.msgs.rrm.channelRelease.rRCause.valuePart, " = ", got_cause);
1755 if (match(got_cause, expect_rr_cause)) {
1756 setverdict(pass);
1757 } else {
1758 log("EXPECTED CAUSE CODE: ", expect_rr_cause);
1759 setverdict(fail, "Received RR Channel Release Cause code does not match expectations");
1760 }
1761 }
Harald Welte99787102019-02-04 10:41:36 +01001762 repeat;
1763 }
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02001764 [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 +01001765 got_rr_chan_rel := true;
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02001766
1767 if (not istemplatekind(expect_rr_cause, "omit")) {
1768 if (f_rsl_find_ie(ud.rsl, RSL_IE_L3_INFO, l3_ie) == false) {
1769 setverdict(fail, "cannot find L3");
1770 mtc.stop;
1771 }
1772 l3 := dec_PDU_ML3_NW_MS(l3_ie.l3_info.payload);
1773
1774 int2enum(oct2int(l3.msgs.rrm.channelRelease.rRCause.valuePart), got_cause);
1775 log("GOT CAUSE CODE: ", l3.msgs.rrm.channelRelease.rRCause.valuePart, " = ", got_cause);
1776 if (match(got_cause, expect_rr_cause)) {
1777 setverdict(pass);
1778 } else {
1779 log("EXPECTED CAUSE CODE: ", expect_rr_cause);
1780 setverdict(fail, "Received RR Channel Release Cause code does not match expectations");
1781 }
1782 }
Neels Hofmeyr211169d2018-11-07 00:37:29 +01001783 repeat;
1784 }
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001785 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(tr_RSL_REL_REQ(rsl_chan_nr, ?))) {
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001786 got_rll_rel_req := true;
Harald Welte91d54a52018-01-28 15:35:07 +01001787 /* FIXME: Why are we getting this for LinkID SACCH? */
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001788 if (handle_rll_rel) {
1789 f_ipa_tx(0, ts_RSL_REL_CONF(rsl_chan_nr, main_dcch));
1790 }
Harald Welte91d54a52018-01-28 15:35:07 +01001791 repeat;
1792 }
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001793 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL))) {
Harald Welte91d54a52018-01-28 15:35:07 +01001794 /* respond with CHAN REL ACK */
1795 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(rsl_chan_nr));
1796 }
1797 /* ignore any user data */
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001798 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(tr_RSL_MsgTypeR(?))) {
Harald Welte91d54a52018-01-28 15:35:07 +01001799 repeat;
1800 }
1801 }
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001802
1803 log("f_expect_chan_rel() summary: got_deact_sacch=", got_deact_sacch, " got_rr_chan_rel=", got_rr_chan_rel,
1804 " got_rll_rel_req=", got_rll_rel_req);
1805
1806 if (expect_deact_sacch != got_deact_sacch) {
1807 setverdict(fail, "f_expect_chan_rel(): expect_deact_sacch=", expect_deact_sacch, " got_deact_sacch=", got_deact_sacch);
1808 }
1809 if (expect_rr_chan_rel != got_rr_chan_rel) {
1810 setverdict(fail, "f_expect_chan_rel(): expect_rr_chan_rel=", expect_rr_chan_rel, " got_rr_chan_rel=", got_rr_chan_rel);
1811 }
1812 if (expect_rll_rel_req != got_rll_rel_req) {
1813 setverdict(fail, "f_expect_chan_rel(): expect_rll_rel_req=", expect_rll_rel_req, " got_rll_rel_req=", got_rll_rel_req);
1814 }
Harald Welte91d54a52018-01-28 15:35:07 +01001815}
1816
Harald Welte4003d112017-12-09 22:35:39 +01001817/* Test behavior of channel release after hard Clear Command from MSC */
1818testcase TC_chan_rel_hard_clear() runs on test_CT {
1819 var BSSAP_N_DATA_ind rx_di;
Harald Welte4003d112017-12-09 22:35:39 +01001820 var DchanTuple dt;
Harald Welte4003d112017-12-09 22:35:39 +01001821
Harald Welte89d42e82017-12-17 16:42:41 +01001822 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +01001823
1824 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1825
1826 /* Instruct BSC to clear channel */
1827 var BssmapCause cause := 0;
1828 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
1829
1830 /* expect Clear Complete from BSC on A */
1831 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete)) {
1832 /* release the SCCP connection */
1833 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
1834 }
1835
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001836 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001837 f_shutdown_helper();
Harald Welte4003d112017-12-09 22:35:39 +01001838}
1839
Harald Welte99787102019-02-04 10:41:36 +01001840/* Test behavior of channel release after Clear Command with CSFB indicator from MSC */
1841testcase TC_chan_rel_hard_clear_csfb() runs on test_CT {
1842 var BSSAP_N_DATA_ind rx_di;
1843 var DchanTuple dt;
1844
1845 f_init(1);
1846
1847 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1848
1849 /* Instruct BSC to clear channel */
1850 var BssmapCause cause := 0;
1851 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommandCSFB(cause)));
1852
1853 /* expect Clear Complete from BSC on A */
1854 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete)) {
1855 /* release the SCCP connection */
1856 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
1857 }
1858
1859 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 +02001860 f_shutdown_helper();
Harald Welte99787102019-02-04 10:41:36 +01001861}
1862
Harald Welted8c36cd2017-12-09 23:05:31 +01001863/* Test behavior of channel release after hard RLSD from MSC */
1864testcase TC_chan_rel_hard_rlsd() runs on test_CT {
Harald Welted8c36cd2017-12-09 23:05:31 +01001865 var DchanTuple dt;
Harald Welted8c36cd2017-12-09 23:05:31 +01001866
Harald Welte89d42e82017-12-17 16:42:41 +01001867 f_init(1);
Harald Welted8c36cd2017-12-09 23:05:31 +01001868
1869 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1870
1871 /* release the SCCP connection */
1872 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
1873
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001874 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001875 f_shutdown_helper();
Harald Welted8c36cd2017-12-09 23:05:31 +01001876}
1877
Harald Welte550daf92018-06-11 19:22:13 +02001878/* Test behavior of channel release after hard RLSD from MSC and MS is not responding to RLL REL REQ */
1879testcase TC_chan_rel_hard_rlsd_ms_dead() runs on test_CT {
1880 var DchanTuple dt;
1881
1882 f_init(1);
1883
1884 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1885
1886 /* release the SCCP connection */
1887 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
1888
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001889 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001890 f_shutdown_helper();
Harald Welte550daf92018-06-11 19:22:13 +02001891}
1892
Harald Welte85804d42017-12-10 14:11:58 +01001893/* Test behavior of channel release after BSSMAP RESET from MSC */
1894testcase TC_chan_rel_a_reset() runs on test_CT {
Harald Welte85804d42017-12-10 14:11:58 +01001895 var DchanTuple dt;
Harald Welte85804d42017-12-10 14:11:58 +01001896
Harald Welte89d42e82017-12-17 16:42:41 +01001897 f_init(1);
Harald Welte85804d42017-12-10 14:11:58 +01001898
1899 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1900
1901 /* Clear the queue, it might still contain stuff like IMMEDIATE ASSIGN */
1902 IPA_RSL[0].clear;
1903
1904 /* perform BSSAP RESET, expect RESET ACK and DISC.ind on connection */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001905 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 +01001906 interleave {
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001907 [] 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 +01001908 [] BSSAP.receive(tr_BSSAP_DISC_ind(dt.sccp_conn_id, ?, ?)) { }
1909 }
1910
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001911 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001912 f_shutdown_helper();
Harald Welte85804d42017-12-10 14:11:58 +01001913}
1914
Pau Espin Pedrolc675b612020-01-09 19:55:40 +01001915/* Verify T(iar) triggers and releases the channel */
1916testcase TC_chan_rel_sccp_tiar_timeout() runs on test_CT {
1917 var DchanTuple dt;
1918
1919 /* Set T(iar) in BSC low enough that it will trigger before other side
1920 has time to keep alive with a T(ias). Keep recommended ratio of
1921 T(iar) >= T(ias)*2 */
1922 g_bsc_sccp_timer_ias := 2;
1923 g_bsc_sccp_timer_iar := 5;
1924
1925 f_init(1);
1926
1927 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1928 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001929 f_shutdown_helper();
Pau Espin Pedrolc675b612020-01-09 19:55:40 +01001930}
1931
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02001932private function f_tc_chan_rel_rr_cause(myBSSMAP_Cause clear_cmd_cause, template RR_Cause expect_rr_cause)
1933runs on test_CT
1934{
1935 var DchanTuple dt;
1936
1937 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1938 var BssmapCause cause := 0;
1939 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(enum2int(clear_cmd_cause))));
1940 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete)) {
1941 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
1942 }
1943
1944 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 +02001945 f_shutdown_helper();
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02001946}
1947
1948/* Test that Clear Command cause codes affect the RR Channel Release cause code */
1949testcase TC_chan_rel_rr_cause() runs on test_CT {
1950 f_init(1);
1951
1952 f_tc_chan_rel_rr_cause(GSM0808_CAUSE_CALL_CONTROL, GSM48_RR_CAUSE_NORMAL);
1953 f_tc_chan_rel_rr_cause(GSM0808_CAUSE_HANDOVER_SUCCESSFUL, GSM48_RR_CAUSE_NORMAL);
1954 f_tc_chan_rel_rr_cause(GSM0808_CAUSE_PREEMPTION, GSM48_RR_CAUSE_PREMPTIVE_REL);
1955 f_tc_chan_rel_rr_cause(GSM0808_CAUSE_RADIO_INTERFACE_MESSAGE_FAILURE, GSM48_RR_CAUSE_PROT_ERROR_UNSPC);
1956 f_tc_chan_rel_rr_cause(GSM0808_CAUSE_RADIO_INTERFACE_FAILURE, GSM48_RR_CAUSE_ABNORMAL_UNSPEC);
1957 f_tc_chan_rel_rr_cause(GSM0808_CAUSE_EQUIPMENT_FAILURE, GSM48_RR_CAUSE_ABNORMAL_UNSPEC);
1958}
1959
Harald Welte5cd20ed2017-12-13 21:03:20 +01001960/* Test behavior if RSL EST IND for non-active channel */
1961testcase TC_rll_est_ind_inact_lchan() runs on test_CT {
1962 timer T := 2.0;
1963
Harald Welte89d42e82017-12-17 16:42:41 +01001964 f_init(1);
Harald Welte5cd20ed2017-12-13 21:03:20 +01001965
1966 var octetstring l3 := '00010203040506'O;
1967 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(6));
1968 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
1969
1970 T.start;
1971 alt {
1972 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) {
1973 setverdict(fail, "MSC received COMPL L3 for non-active lchan");
1974 }
1975 [] BSSAP.receive {}
1976 [] IPA_RSL[0].receive {}
1977 [] T.timeout {}
1978 }
1979
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001980 f_shutdown_helper();
Harald Welte5cd20ed2017-12-13 21:03:20 +01001981}
1982
1983/* Test behavior if RSL EST IND for invalid SAPI */
1984testcase TC_rll_est_ind_inval_sapi1() runs on test_CT {
1985 var RslChannelNr chan_nr;
1986
Harald Welte89d42e82017-12-17 16:42:41 +01001987 f_init(1);
Harald Welte5cd20ed2017-12-13 21:03:20 +01001988
1989 chan_nr := f_chreq_act_ack()
1990
1991 var octetstring l3 := '00010203040506'O;
1992 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(1)), l3));
1993
1994 timer T := 2.0;
1995 T.start;
1996 alt {
1997 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) {
1998 setverdict(fail, "MSC received COMPL L3 for invalid SAPI 1");
1999 }
2000 [] BSSAP.receive { repeat; }
2001 [] IPA_RSL[0].receive { repeat; }
2002 [] T.timeout {}
2003 }
2004
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002005 f_shutdown_helper();
Harald Welte5cd20ed2017-12-13 21:03:20 +01002006}
2007
2008/* Test behavior if RSL EST IND for invalid SAPI */
2009testcase TC_rll_est_ind_inval_sapi3() runs on test_CT {
2010 timer T := 2.0;
2011
Harald Welte89d42e82017-12-17 16:42:41 +01002012 f_init(1);
Harald Welte5cd20ed2017-12-13 21:03:20 +01002013
2014 var RslChannelNr chan_nr := f_chreq_act_ack();
2015
2016 var octetstring l3 := '00010203040506'O;
2017 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(3)), l3));
2018
2019 T.start;
2020 alt {
2021 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) {
2022 setverdict(fail, "MSC received COMPL L3 for invalid SAPI 3");
2023 }
2024 [] BSSAP.receive { repeat; }
2025 [] IPA_RSL[0].receive { repeat; }
2026 [] T.timeout {}
2027 }
2028
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002029 f_shutdown_helper();
Harald Welte5cd20ed2017-12-13 21:03:20 +01002030}
2031
2032/* Test behavior if RSL EST IND for invalid SACCH */
2033testcase TC_rll_est_ind_inval_sacch() runs on test_CT {
2034 timer T := 2.0;
2035
Harald Welte89d42e82017-12-17 16:42:41 +01002036 f_init(1);
Harald Welte5cd20ed2017-12-13 21:03:20 +01002037
2038 var RslChannelNr chan_nr := f_chreq_act_ack();
2039
2040 var octetstring l3 := '00010203040506'O;
2041 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_SACCH(0)), l3));
2042
2043 T.start;
2044 alt {
2045 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) {
2046 setverdict(fail, "MSC received COMPL L3 for invalid Link SACCH");
2047 }
2048 [] BSSAP.receive { repeat; }
2049 [] IPA_RSL[0].receive { repeat; }
2050 [] T.timeout {}
2051 }
2052
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002053 f_shutdown_helper();
Harald Welte5cd20ed2017-12-13 21:03:20 +01002054}
2055
Vadim Yanitskiy61f784a2020-10-01 21:12:19 +07002056/* Verify DLCI / RSL Link ID conversion for MO/MT messages on SAPI0/SAPI3 */
2057private function f_TC_tch_dlci_link_id_sapi(charstring id) runs on MSC_ConnHdlr {
2058 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
2059 var PDU_BSSAP ass_cmd := f_gen_ass_req();
2060
2061 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
2062 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
2063
2064 f_establish_fully(ass_cmd, exp_compl);
2065
2066 /* SAPI0 has already been established by f_establish_fully(), establish SAPI3 */
2067 RSL.send(ts_RSL_EST_IND(g_chan_nr, ts_RslLinkID_SACCH(3), '0904'O));
2068 /* Expect BSSAP/DTAP on SAPI3 (DLCI IE) */
2069 BSSAP.receive(PDU_BSSAP:{
2070 discriminator := '1'B,
2071 spare := '0000000'B,
2072 dlci := 'C3'O,
2073 lengthIndicator := ?,
2074 pdu := { dtap := '0904'O }
2075 });
2076
2077 /* Send messages on DCCH/SAPI0 and ACCH/SAPI3 */
2078 for (var integer i := 0; i < 32; i := i + 1) {
2079 var octetstring l3 := '09'O & f_rnd_octstring(14);
2080 var template (value) RslLinkId link_id;
2081 var template (value) OCT1 dlci;
2082
2083 if (i mod 2 == 0) {
2084 /* SAPI0 on FACCH or SDCCH */
2085 link_id := ts_RslLinkID_DCCH(0);
2086 dlci := '80'O;
2087 } else {
2088 /* SAPI3 on SACCH */
2089 link_id := ts_RslLinkID_SACCH(3);
2090 dlci := 'C3'O;
2091 }
2092
2093 /* Send MO message: RSL -> BSSAP */
Neels Hofmeyr0aa719b2020-10-12 18:43:09 +00002094 f_mo_l3_transceive(RSL, link_id, dlci, l3);
Vadim Yanitskiy61f784a2020-10-01 21:12:19 +07002095 /* Send MT message: BSSAP -> RSL */
Neels Hofmeyr0aa719b2020-10-12 18:43:09 +00002096 f_mt_l3_transceive(RSL, link_id, dlci, l3);
Vadim Yanitskiy61f784a2020-10-01 21:12:19 +07002097 }
2098}
2099testcase TC_tch_dlci_link_id_sapi() runs on test_CT {
2100 var TestHdlrParams pars := f_gen_test_hdlr_pars();
2101 var MSC_ConnHdlr vc_conn;
2102
2103 f_init(1, true);
2104 f_sleep(1.0);
2105
2106 vc_conn := f_start_handler(refers(f_TC_tch_dlci_link_id_sapi), pars);
2107 vc_conn.done;
2108
2109 f_shutdown_helper();
2110}
2111
Vadim Yanitskiy6ef5dfa2020-08-28 18:04:41 +07002112private function f_exp_sapi_n_reject(template (present) GsmSapi sapi := ?,
2113 template myBSSMAP_Cause cause := ?,
2114 float T_val := 2.0)
2115runs on test_CT {
2116 var BSSAP_N_DATA_ind rx_di;
2117 timer T;
2118
2119 var template BSSMAP_IE_Cause tr_cause := tr_BSSMAP_IE_Cause(cause);
2120 var template PDU_BSSAP tr_pdu := tr_BSSMAP_SAPInReject(sapi);
2121
2122 T.start(T_val);
2123 alt {
2124 [] BSSAP.receive(tr_BSSAP_DATA_ind(?, tr_pdu)) -> value rx_di {
2125 var BSSMAP_IE_Cause rx_cause := rx_di.userData.pdu.bssmap.sAPInReject.cause;
2126 if (not match(rx_cause, tr_cause)) {
2127 setverdict(fail, "Rx unexpected Cause IE: ",
2128 rx_cause, " vs expected ", tr_cause);
2129 }
2130 setverdict(pass);
2131 }
2132 [] BSSAP.receive(BSSAP_N_DATA_ind:?) -> value rx_di {
2133 setverdict(fail, "Rx unexpected BSSAP PDU: ", rx_di);
2134 }
2135 [] T.timeout {
2136 setverdict(fail, "Timeout waiting for BSSMAP SAPI N Reject");
2137 }
2138 }
2139}
2140
2141/* Check if we get SAPI N Reject on receipt of unexpected RLL RELease INDication */
2142testcase TC_rll_rel_ind_sapi_n_reject() runs on test_CT {
2143 var octetstring rnd_data := f_rnd_octstring(16);
2144 var RSL_Message rx_rsl;
2145 var DchanTuple dt;
2146
2147 f_init(1);
2148
2149 /* MS establishes a SAPI=0 link on DCCH */
2150 dt := f_est_dchan(f_rnd_ra_cs(), 23, rnd_data);
2151
2152 /* MSC sends some data on (not yet established) SAPI=3 link */
2153 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSAP_DTAP(rnd_data, '03'O)));
2154 /* BSC attempts to establish a SAPI=3 link on DCCH */
2155 rx_rsl := f_exp_ipa_rx(0, tr_RSL_EST_REQ(dt.rsl_chan_nr, tr_RslLinkID_DCCH(3)));
2156
2157 /* MS sends unexpected RELease INDication on SAPI=3 */
2158 f_ipa_tx(0, ts_RSL_REL_IND(dt.rsl_chan_nr, ts_RslLinkID_DCCH(3)));
2159 /* We expect to receive BSSMAP SAPI N Reject message from the BSC */
2160 f_exp_sapi_n_reject(3, GSM0808_CAUSE_MS_NOT_EQUIPPED);
2161
2162 /* Clean up the connection */
2163 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
2164 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
2165
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002166 f_shutdown_helper();
Vadim Yanitskiy6ef5dfa2020-08-28 18:04:41 +07002167}
2168
2169/* Check if we get SAPI N Reject on receipt of unexpected RLL ERROR INDication */
2170testcase TC_rll_err_ind_sapi_n_reject() runs on test_CT {
2171 var octetstring rnd_data := f_rnd_octstring(16);
2172 var RSL_Message rx_rsl;
2173 var DchanTuple dt;
2174
2175 f_init(1);
2176
2177 /* MS establishes a SAPI=0 link on DCCH */
2178 dt := f_est_dchan(f_rnd_ra_cs(), 23, rnd_data);
2179
2180 /* MSC sends some data on (not yet established) SAPI=3 link */
2181 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSAP_DTAP(rnd_data, '03'O)));
2182 /* BSC attempts to establish a SAPI=3 link on DCCH */
2183 rx_rsl := f_exp_ipa_rx(0, tr_RSL_EST_REQ(dt.rsl_chan_nr, tr_RslLinkID_DCCH(3)));
2184
2185 /* BTS sends unexpected ERROR INDication on SAPI=3 */
2186 f_ipa_tx(0, ts_RSL_ERROR_IND(dt.rsl_chan_nr, ts_RslLinkID_DCCH(3), ''O));
2187 /* We expect to receive BSSMAP SAPI N Reject message from the BSC */
2188 f_exp_sapi_n_reject(3, GSM0808_CAUSE_BSS_NOT_EQUIPPED);
2189
2190 /* Clean up the connection */
2191 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
2192 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
2193
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002194 f_shutdown_helper();
Vadim Yanitskiy6ef5dfa2020-08-28 18:04:41 +07002195}
2196
2197/* Check if we get SAPI N Reject due to a SAPI=3 link establishment timeout */
2198testcase TC_rll_timeout_sapi_n_reject() runs on test_CT {
2199 var octetstring rnd_data := f_rnd_octstring(16);
2200 var RSL_Message rx_rsl;
2201 var DchanTuple dt;
2202
2203 f_init(1);
2204
2205 /* MS establishes a SAPI=0 link on DCCH */
2206 dt := f_est_dchan(f_rnd_ra_cs(), 23, rnd_data);
2207
2208 /* MSC sends some data on (not yet established) SAPI=3 link */
2209 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSAP_DTAP(rnd_data, '03'O)));
2210 /* BSC attempts to establish a SAPI=3 link on DCCH */
2211 rx_rsl := f_exp_ipa_rx(0, tr_RSL_EST_REQ(dt.rsl_chan_nr, tr_RslLinkID_DCCH(3)));
2212
2213 /* MS does not respond, so the link establishment timeout triggers SAPI N Reject */
2214 f_exp_sapi_n_reject(3, GSM0808_CAUSE_BSS_NOT_EQUIPPED, T_val := 8.0);
2215
2216 /* Clean up the connection */
2217 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
2218 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
2219
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002220 f_shutdown_helper();
Vadim Yanitskiy6ef5dfa2020-08-28 18:04:41 +07002221}
2222
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +02002223testcase TC_si_default() runs on test_CT {
2224 f_init(0);
2225 f_init_bts_and_check_sysinfo(0, expect_si := SystemInformationConfig_default);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002226 f_shutdown_helper();
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +02002227}
Harald Welte4003d112017-12-09 22:35:39 +01002228
Neels Hofmeyr56f24782020-07-09 00:50:49 +02002229/* We're testing SI2quater with lists of EARFCNs. Instead of just incrementing EARFCNs, also pick some from the edges of
2230 * the entire value range. This function provides the same EARFCN numbers for the same earfcn_index */
2231private function f_test_si2quater_earfcn_by_idx(integer earfcn_index) return uint16_t
2232{
2233 select (earfcn_index) {
2234 case (0) {
2235 /* E-ARFCN 111 is already added in the osmo-bsc.cfg */
2236 return 111;
2237 }
2238 case (1) {
2239 return 1;
2240 }
2241 case (2) {
2242 return 0;
2243 }
2244 case (3) {
2245 return 65535;
2246 }
2247 case else {
2248 return 23 * (earfcn_index - 3);
2249 }
2250 }
2251}
2252
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02002253function f_test_si2quater(integer total_earfcns, template SystemInformationConfig expect_si,
2254 template CellSelIndValue expect_cells := omit) runs on test_CT {
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002255
2256 f_init(0);
2257
2258 /* E-ARFCN 111 is already added in the osmo-bsc.cfg, so only add more arfcns if total_earfcns > 1 */
2259 for (var integer i := 1; i < total_earfcns; i := i + 1) {
Neels Hofmeyr56f24782020-07-09 00:50:49 +02002260 f_bts_0_cfg(BSCVTY, {"si2quater neighbor-list add earfcn " & int2str(f_test_si2quater_earfcn_by_idx(i))
2261 & " thresh-hi 20 thresh-lo 10 prio 3 qrxlv 22 meas 3"});
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002262 }
2263
2264 f_init_bts_and_check_sysinfo(0, expect_si := expect_si);
2265
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02002266 f_init(1);
2267
2268 if (not istemplatekind(expect_cells, "omit")) {
2269 /* Also check that RR Channel Release contains these EARFCNs.
2270 * (copied code from TC_chan_rel_hard_clear_csfb) */
2271 var BSSAP_N_DATA_ind rx_di;
2272 var DchanTuple dt;
2273
2274 dt := f_est_dchan('23'O, 23, '00010203040506'O);
2275
2276 /* Instruct BSC to clear channel */
2277 var BssmapCause cause := 0;
2278 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommandCSFB(cause)));
2279
2280 /* expect Clear Complete from BSC on A */
2281 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete)) {
2282 /* release the SCCP connection */
2283 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
2284 }
2285
2286 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false, is_csfb := true,
2287 csfb_expect_cells := expect_cells);
2288 }
2289
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002290 for (var integer i := 1; i < total_earfcns; i := i + 1) {
Neels Hofmeyr56f24782020-07-09 00:50:49 +02002291 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 +02002292 }
2293}
2294
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002295private function f_tr_si2quater_earfcns(integer count) return template SI2quaterRestOctetsList
2296{
2297 var template SI2quaterRestOctetsList si2quater := {};
2298 var integer si2quater_count := (count + 2) / 3;
2299
2300 for (var integer i := 0; i < count; i := i + 1) {
Neels Hofmeyr56f24782020-07-09 00:50:49 +02002301 var integer earfcn := f_test_si2quater_earfcn_by_idx(i);
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002302 var integer index := i / 3;
2303 var integer earfcn_index := i mod 3;
2304 if (index >= lengthof(si2quater)) {
2305 si2quater[index] := tr_SI2quaterRestOctets_EUTRAN(index := index, count := si2quater_count - 1);
2306 }
2307 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);
2308 }
2309
2310 return si2quater;
2311}
2312
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02002313private function f_tr_rr_chan_rel_earfcns(integer count) return template CellSelIndValue
2314{
2315 var template CellSelIndValue_EUTRAN_Descrs cells := {};
2316
Alexander Couzensf74b5cb2020-09-10 22:28:40 +02002317 /* the lte neighbors must match the config & vty to pass this test */
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02002318 for (var integer i := 0; i < count; i := i + 1) {
2319 var integer earfcn := f_test_si2quater_earfcn_by_idx(i);
Alexander Couzensf74b5cb2020-09-10 22:28:40 +02002320 cells[i] := tr_CellSelIndValue_EUTRAN_Descr(earfcn, '1'B, 3);
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02002321 }
2322
2323 return tr_CellSelIndValue_EUTRAN(cells);
2324}
2325
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002326private function f_tc_si2quater_n_earfcns(integer n) runs on test_CT
2327{
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002328 var template SystemInformationConfig sic := SystemInformationConfig_default;
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002329 sic.si2quater := f_tr_si2quater_earfcns(n);
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02002330 var template CellSelIndValue cells := f_tr_rr_chan_rel_earfcns(n);
2331 f_test_si2quater(n, sic, cells);
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002332}
2333
2334testcase TC_si2quater_2_earfcns() runs on test_CT {
2335 f_tc_si2quater_n_earfcns(2);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002336 f_shutdown_helper();
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002337}
2338
2339testcase TC_si2quater_3_earfcns() runs on test_CT {
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002340 f_tc_si2quater_n_earfcns(3);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002341 f_shutdown_helper();
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002342}
2343
2344testcase TC_si2quater_4_earfcns() runs on test_CT {
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002345 f_tc_si2quater_n_earfcns(4);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002346 f_shutdown_helper();
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002347}
2348
2349testcase TC_si2quater_5_earfcns() runs on test_CT {
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002350 f_tc_si2quater_n_earfcns(5);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002351 f_shutdown_helper();
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002352}
2353
2354testcase TC_si2quater_6_earfcns() runs on test_CT {
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002355 f_tc_si2quater_n_earfcns(6);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002356 f_shutdown_helper();
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002357}
2358
2359testcase TC_si2quater_12_earfcns() runs on test_CT {
2360 f_tc_si2quater_n_earfcns(12);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002361 f_shutdown_helper();
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002362}
2363
2364testcase TC_si2quater_23_earfcns() runs on test_CT {
2365 f_tc_si2quater_n_earfcns(23);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002366 f_shutdown_helper();
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002367}
2368
2369testcase TC_si2quater_32_earfcns() runs on test_CT {
2370 f_tc_si2quater_n_earfcns(32);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002371 f_shutdown_helper();
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002372}
2373
2374testcase TC_si2quater_33_earfcns() runs on test_CT {
2375 f_tc_si2quater_n_earfcns(33);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002376 f_shutdown_helper();
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002377}
2378
2379testcase TC_si2quater_42_earfcns() runs on test_CT {
2380 f_tc_si2quater_n_earfcns(42);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002381 f_shutdown_helper();
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002382}
2383
2384testcase TC_si2quater_48_earfcns() runs on test_CT {
2385 f_tc_si2quater_n_earfcns(48);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002386 f_shutdown_helper();
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002387}
2388
2389/* verify the VTY error response when adding too many EARFCNs, and showing that osmo-bsc still sends 16 SI2quater with
2390 * 48 EARFCNs. */
2391testcase TC_si2quater_49_earfcns() runs on test_CT {
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002392 var template SystemInformationConfig sic := SystemInformationConfig_default;
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002393 sic.si2quater := f_tr_si2quater_earfcns(48); /* 48, not 49! */
2394 f_init(0);
2395
2396 for (var integer i := 1; i < 48; i := i + 1) {
Neels Hofmeyr56f24782020-07-09 00:50:49 +02002397 f_bts_0_cfg(BSCVTY, {"si2quater neighbor-list add earfcn " & int2str(f_test_si2quater_earfcn_by_idx(i))
2398 & " thresh-hi 20 thresh-lo 10 prio 3 qrxlv 22 meas 3"});
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002399 }
2400
2401 /* The 49th EARFCN no longer fits, expect VTY error */
2402 f_vty_enter_cfg_bts(BSCVTY, 0);
2403 var charstring vty_error;
2404 vty_error := f_vty_transceive_ret(BSCVTY,
2405 "si2quater neighbor-list add earfcn 70 thresh-hi 20 thresh-lo 10 prio 3 qrxlv 22 meas 3")
2406 f_vty_transceive(BSCVTY, "end");
2407
2408 if (f_strstr(vty_error, "Unable to add ARFCN 70") >= 0) {
2409 log("Got expected VTY error: ", vty_error);
2410 setverdict(pass);
2411 } else {
2412 setverdict(fail, "Expected the 49th EUTRAN ARFCN to be rejected by vty config, got: ", vty_error);
2413 }
2414
2415 f_init_bts_and_check_sysinfo(0, expect_si := sic);
2416
2417 for (var integer i := 1; i < 48; i := i + 1) {
Neels Hofmeyr56f24782020-07-09 00:50:49 +02002418 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 +02002419 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002420 f_shutdown_helper();
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002421}
2422
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02002423private function f_acc09_count_allowed(AccessControlClass acc) return uint8_t
2424{
2425 var uint8_t count := 0;
2426 for (var integer i := 5; i < 16; i := i + 1) {
2427 if (acc[i] == '0'B) { /* the list marks barred, we count allowed */
2428 count := count + 1;
2429 }
2430 }
2431 return count;
2432}
2433
Pau Espin Pedrolc6136cd2020-07-24 13:20:02 +02002434private function f_recv_next_si1(integer rsl_idx := 0) runs on test_CT return SystemInformationType1
2435{
2436 var ASP_RSL_Unitdata rx_rsl_ud;
2437 var SystemInformationType1 last_si1;
2438
2439 timer T := 30.0;
2440 T.start;
2441 alt {
2442 [] IPA_RSL[rsl_idx].receive(tr_ASP_RSL_UD((tr_RSL_NO_BCCH_INFO,
2443 tr_RSL_BCCH_INFO,
2444 tr_RSL_NO_SACCH_FILL,
2445 tr_RSL_SACCH_FILL))
2446 ) -> value rx_rsl_ud {
2447 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
2448 if (g_system_information[rsl_idx].si1 == omit) {
2449 repeat;
2450 }
2451 last_si1 := g_system_information[rsl_idx].si1;
2452 g_system_information[rsl_idx].si1 := omit;
2453 T.stop;
2454 }
2455 [] T.timeout { setverdict(fail, "Timeout receiving next SI1"); }
2456 }
2457 return last_si1;
2458}
2459
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02002460/* verify ACC rotate feature */
2461testcase TC_si_acc_rotate() runs on test_CT {
2462 var template SystemInformationConfig sic := SystemInformationConfig_default;
Pau Espin Pedrolc6136cd2020-07-24 13:20:02 +02002463 var SystemInformationType1 last_si1;
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02002464 var AccessControlClass acc;
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02002465 var uint8_t count;
2466 var integer times_allowed[10] := { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
2467
2468 f_init(0, guard_timeout := 60.0);
2469
2470 f_bts_0_cfg(BSCVTY, {"rach access-control-class 5 barred",
2471 "access-control-class-rotate 3",
2472 "access-control-class-rotate-quantum 1"});
2473
2474 /* Init and get first sysinfo */
2475 f_init_bts_and_check_sysinfo(0, expect_si := ?);
2476
Pau Espin Pedrolc6136cd2020-07-24 13:20:02 +02002477 for (var integer i:= 0; i < 20; i := i + 1) {
2478 last_si1 := f_recv_next_si1(0);
2479 acc := last_si1.rach_control.acc;
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02002480 count := f_acc09_count_allowed(acc);
2481 log("RSL: GOT SI1 ACC len=", count, ": ", acc);
2482
2483 if (count != 3) {
2484 log("RSL: EXPECTED SI ACC len=3");
2485 setverdict(fail, "received SI does not match expectations");
2486 break;
2487 }
2488
2489 for (var integer j := 0; j < 10; j := j + 1) {
2490 if (acc[16 - 1 - j] == '0'B) { /* the list marks barred, we count allowed */
2491 times_allowed[j] := times_allowed[j] + 1;
2492 }
2493 }
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02002494 }
2495
2496 for (var integer j := 0; j < 10; j := j + 1) {
2497 log("ACC", j, " allowed ", times_allowed[j], " times" );
2498 if (j != 5 and times_allowed[j] < 3) {
2499 setverdict(fail, "ACC", j, " ERROR: allowed ", times_allowed[j], " < 1 times");
2500 } else if (j == 5 and times_allowed[j] > 0) {
2501 setverdict(fail, "ACC", j, " ERROR: allowed ", times_allowed[j], " > 0 times");
2502 }
2503 }
2504
2505 f_bts_0_cfg(BSCVTY, {"access-control-class-rotate 10",
2506 "rach access-control-class 5 allowed"});
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002507 f_shutdown_helper();
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02002508}
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002509
Pau Espin Pedrolc6136cd2020-07-24 13:20:02 +02002510/* verify ACC startup ramp+rotate feature */
2511testcase TC_si_acc_ramp_rotate() runs on test_CT {
2512 var template SystemInformationConfig sic := SystemInformationConfig_default;
2513 var SystemInformationType1 last_si1;
2514 var AccessControlClass acc;
2515 var ASP_RSL_Unitdata rx_rsl_ud;
2516 var uint8_t count;
2517 var uint8_t prev_count;
2518 var integer times_allowed[10] := { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
2519
2520 f_init(0, guard_timeout := 80.0);
2521
2522 f_bts_0_cfg(BSCVTY, {"rach access-control-class 4 barred",
2523 "access-control-class-rotate 0",
2524 "access-control-class-rotate-quantum 1",
2525 "access-control-class-ramping",
2526 "access-control-class-ramping-step-interval 5",
2527 "access-control-class-ramping-step-size 5"});
2528
2529 /* Init and get first sysinfo */
2530 f_init_bts_and_check_sysinfo(0, expect_si := ?);
2531 last_si1 := g_system_information[0].si1;
2532 acc := last_si1.rach_control.acc;
2533 count := f_acc09_count_allowed(acc);
2534 /* Adm subset size was set to 0 above, so wait until all ACC are barred */
2535 while (count > 0) {
2536 last_si1 := f_recv_next_si1(0);
2537 acc := last_si1.rach_control.acc;
2538 count := f_acc09_count_allowed(acc);
2539 log("RSL: wait len()=0: GOT SI1 ACC len=", count, ": ", acc);
2540 }
2541
2542 /* Increase adm subset size, we should see ramping start up */
2543 f_bts_0_cfg(BSCVTY, {"access-control-class-rotate 10"});
2544 prev_count := 0;
2545 while (true) {
2546 last_si1 := f_recv_next_si1(0);
2547 acc := last_si1.rach_control.acc;
2548 count := f_acc09_count_allowed(acc);
2549 log("RSL: GOT SI1 ACC len=", count, ": ", acc);
2550
2551 if (prev_count > count) {
2552 setverdict(fail, "ACC allowed count dropped while expecting grow: ", prev_count, " -> ", count);
2553 break;
2554 }
2555
2556 if (count == 9) {
2557 break; /* Maximum reached (10 - 1 perm barred), done here */
2558 }
2559
2560 prev_count := count;
2561 }
2562
2563 setverdict(pass);
2564
2565 f_bts_0_cfg(BSCVTY, {"access-control-class-rotate 10",
2566 "rach access-control-class 4 allowed",
2567 "no access-control-class-ramping"});
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002568 f_shutdown_helper();
Pau Espin Pedrolc6136cd2020-07-24 13:20:02 +02002569}
2570
Harald Welte4003d112017-12-09 22:35:39 +01002571testcase TC_ctrl_msc_connection_status() runs on test_CT {
2572 var charstring ctrl_resp;
2573
Harald Welte89d42e82017-12-17 16:42:41 +01002574 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +01002575
2576 /* See https://osmocom.org/issues/2729 */
2577 f_ctrl_get_exp(IPA_CTRL, "msc_connection_status", "connected");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002578 f_shutdown_helper();
Harald Welte4003d112017-12-09 22:35:39 +01002579}
2580
Stefan Sperlingb041b3d2018-01-03 17:14:55 +01002581testcase TC_ctrl_msc0_connection_status() runs on test_CT {
2582 var charstring ctrl_resp;
2583
2584 f_init(1);
Stefan Sperlingb041b3d2018-01-03 17:14:55 +01002585
2586 f_ctrl_get_exp(IPA_CTRL, "msc.0.connection_status", "connected");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002587 f_shutdown_helper();
Stefan Sperlingb041b3d2018-01-03 17:14:55 +01002588}
2589
Harald Welte4003d112017-12-09 22:35:39 +01002590testcase TC_ctrl() runs on test_CT {
2591 var charstring ctrl_resp;
2592
Harald Welte89d42e82017-12-17 16:42:41 +01002593 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +01002594
2595 /* all below values must match the osmo-bsc.cfg config file used */
2596
Harald Welte6a129692018-03-17 17:30:14 +01002597 f_ctrl_get_exp(IPA_CTRL, "mcc", "001");
2598 f_ctrl_get_exp(IPA_CTRL, "mnc", "01");
Oliver Smith75aa0202019-08-19 14:17:50 +02002599 f_ctrl_get_exp(IPA_CTRL, "number-of-bts", "4");
Harald Welte4003d112017-12-09 22:35:39 +01002600
2601 var integer bts_nr := 0;
2602 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "location-area-code", "1");
2603 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "cell-identity", "0");
2604 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "oml-connection-state", "connected");
2605 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "gprs-mode", "gprs");
2606 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "rf_state", "operational,unlocked,on");
2607 f_ctrl_get_exp_trx(IPA_CTRL, bts_nr, 0, "arfcn", "871");
2608 f_ctrl_get_exp_trx(IPA_CTRL, bts_nr, 0, "max-power-reduction", "20");
2609
2610 var integer uptime := str2int(f_ctrl_get_bts(IPA_CTRL, bts_nr, "oml-uptime"));
2611 f_sleep(2.0);
2612 if (str2int(f_ctrl_get_bts(IPA_CTRL, bts_nr, "oml-uptime")) < uptime+1) {
2613 setverdict(fail, "oml-uptime not incrementing as expected");
2614 }
2615 /* TODO: Disconnect RSL, imply that OML is disconnected and check for uptime zero? */
2616
2617 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bsc", 0, "paging:attempted", 0);
2618
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002619 f_shutdown_helper();
Harald Welte96c94412017-12-09 03:12:45 +01002620}
2621
Pau Espin Pedrol5a2d7432019-06-07 19:43:45 +02002622/* Verify that Upon receival of SET "location", BSC forwards a TRAP
2623 "location-state" over the SCCPlite IPA conn */
2624testcase TC_ctrl_location() runs on test_CT {
2625 var MSC_ConnHdlr vc_conn;
2626 var integer bts_nr := 0;
2627
2628 f_init(1, true);
2629 f_sleep(1.0);
2630
2631 f_ctrl_set_bts(IPA_CTRL, bts_nr, "location", "1234567,fix3d,0.340000,0.560000,0.780000");
2632 f_ctrl_exp_trap(SCCPLITE_IPA_CTRL, "bts." & int2str(bts_nr) & ".location-state",
2633 "1234567,fix3d,0.340000,0.560000,0.780000,operational,unlocked,on,001,01");
2634
2635 f_ctrl_set(SCCPLITE_IPA_CTRL, "rf_locked", "1");
2636 f_sleep(2.0);
2637
2638 f_ctrl_set_bts(IPA_CTRL, bts_nr, "location", "1234888,fix3d,0.350000,0.570000,0.790000");
2639 f_ctrl_exp_trap(SCCPLITE_IPA_CTRL, "bts." & int2str(bts_nr) & ".location-state",
2640 "1234888,fix3d,0.350000,0.570000,0.790000,operational,locked,off,001,01");
2641
2642 /* should match the one from config */
2643 f_ctrl_set(SCCPLITE_IPA_CTRL, "rf_locked", "0");
2644
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002645 f_shutdown_helper();
Pau Espin Pedrol5a2d7432019-06-07 19:43:45 +02002646}
2647
Harald Welte6f521d82017-12-11 19:52:02 +01002648
2649/***********************************************************************
2650 * Paging Testing
2651 ***********************************************************************/
2652
2653type record Cell_Identity {
2654 GsmMcc mcc,
2655 GsmMnc mnc,
2656 GsmLac lac,
2657 GsmCellId ci
2658};
Harald Welte24135bd2018-03-17 19:27:53 +01002659private const Cell_Identity cid := { '001'H, '01'H, 1, 0 };
Stefan Sperling049a86e2018-03-20 15:51:00 +01002660private const Cell_Identity unknown_cid := { '678'H, 'f90'H, 1, 0 };
Harald Welte6f521d82017-12-11 19:52:02 +01002661
Harald Welte5d1a2202017-12-13 19:51:29 +01002662type set of integer BtsIdList;
2663
2664private function f_bts_in_list(integer bts_id, BtsIdList bts_ids) return boolean {
2665 for (var integer j := 0; j < sizeof(bts_ids); j := j + 1) {
2666 if (bts_id == bts_ids[j]) {
2667 return true;
2668 }
2669 }
2670 return false;
2671}
Harald Welte6f521d82017-12-11 19:52:02 +01002672
2673/* core paging test helper function; used by most paging test cases */
2674private function f_pageing_helper(hexstring imsi,
2675 template BSSMAP_FIELD_CellIdentificationList cid_list,
Harald Welte5d1a2202017-12-13 19:51:29 +01002676 BtsIdList bts_ids := { 0 },
Harald Welte6f521d82017-12-11 19:52:02 +01002677 template RSL_ChanNeeded rsl_chneed := omit,
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07002678 template (omit) OCT4 tmsi := omit) runs on test_CT
Harald Welte6f521d82017-12-11 19:52:02 +01002679{
2680 var template BSSMAP_IE_ChannelNeeded bssmap_chneed;
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07002681 var template MobileIdentityV mi;
Harald Welte6f521d82017-12-11 19:52:02 +01002682 var RSL_Message rx_rsl;
2683 var integer paging_group := hex2int(imsi[lengthof(imsi)-1]);
Harald Welte5d1a2202017-12-13 19:51:29 +01002684 var integer i;
Harald Welte6f521d82017-12-11 19:52:02 +01002685
2686 f_init();
Harald Welte6f521d82017-12-11 19:52:02 +01002687
2688 /* Clear the queue, it might still contain stuff like BCCH FILLING */
Harald Weltec3068592018-03-17 19:55:31 +01002689 for (i := 0; i < NUM_BTS; i := i + 1) {
2690 IPA_RSL[i].clear;
Harald Welte5d1a2202017-12-13 19:51:29 +01002691 }
Harald Welte6f521d82017-12-11 19:52:02 +01002692
2693 if (isvalue(rsl_chneed)) {
2694 /* The values of 08.08 3.2.2.36 and 08.58 9.3.40 are luckily identical */
2695 bssmap_chneed := ts_BSSMAP_IE_ChanNeeded(int2bit(enum2int(valueof(rsl_chneed)),2));
2696 } else {
2697 bssmap_chneed := omit;
2698 }
2699
Neels Hofmeyrf246a922020-05-13 02:27:10 +02002700 BSSAP.send(ts_BSSAP_UNITDATA_req(g_bssap[0].sccp_addr_peer, g_bssap[0].sccp_addr_own,
2701 ts_BSSMAP_Paging(imsi, cid_list, tmsi, bssmap_chneed)));
Harald Welte6f521d82017-12-11 19:52:02 +01002702
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07002703 if (not istemplatekind(tmsi, "omit")) {
2704 mi := t_MI_TMSI(tmsi);
Harald Welte6f521d82017-12-11 19:52:02 +01002705 } else {
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07002706 mi := tr_MI_IMSI(imsi);
Harald Welte6f521d82017-12-11 19:52:02 +01002707 }
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07002708
Harald Welte5d1a2202017-12-13 19:51:29 +01002709 for (i := 0; i < sizeof(bts_ids); i := i + 1) {
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07002710 rx_rsl := f_exp_ipa_rx(bts_ids[i], tr_RSL_PAGING_CMD(mi));
Harald Welte5d1a2202017-12-13 19:51:29 +01002711 /* check channel type, paging group */
2712 if (rx_rsl.ies[1].body.paging_group != paging_group) {
2713 setverdict(fail, "Paging for wrong paging group");
2714 }
2715 if (ispresent(rsl_chneed) and
2716 rx_rsl.ies[3].body.chan_needed.chan_needed != valueof(rsl_chneed)) {
2717 setverdict(fail, "RSL Channel Needed != BSSMAP Channel Needed");
2718 }
Harald Welte6f521d82017-12-11 19:52:02 +01002719 }
Harald Welte2fccd982018-01-31 15:48:19 +01002720 f_sleep(2.0);
Harald Welte5d1a2202017-12-13 19:51:29 +01002721 /* do a quick check on all not-included BTSs if they received paging */
2722 for (i := 0; i < NUM_BTS; i := i + 1) {
2723 timer T := 0.1;
2724 if (f_bts_in_list(i, bts_ids)) {
2725 continue;
2726 }
2727 T.start;
2728 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07002729 [] IPA_RSL[i].receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD(mi))) {
Harald Welte5d1a2202017-12-13 19:51:29 +01002730 setverdict(fail, "Paging on BTS ", i, " which is not part of ", bts_ids);
2731 }
2732 [] IPA_RSL[i].receive { repeat; }
2733 [] T.timeout { }
2734 }
Harald Welte6f521d82017-12-11 19:52:02 +01002735 }
2736
2737 setverdict(pass);
2738}
2739
Harald Welte5d1a2202017-12-13 19:51:29 +01002740const BtsIdList c_BtsId_all := { 0, 1, 2 };
Harald Welte751d3eb2018-01-31 15:51:06 +01002741const BtsIdList c_BtsId_none := { };
Harald Welte5d1a2202017-12-13 19:51:29 +01002742const BtsIdList c_BtsId_LAC1 := { 0, 1 };
2743const BtsIdList c_BtsId_LAC2 := { 2 };
2744
Harald Welte6f521d82017-12-11 19:52:02 +01002745/* PAGING by IMSI + TMSI */
2746testcase TC_paging_imsi_nochan() runs on test_CT {
2747 var BSSMAP_FIELD_CellIdentificationList cid_list;
2748 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Philipp Maier8c04b0a2018-02-23 13:48:48 +01002749 f_pageing_helper('001010100000001'H, cid_list, c_BtsId_all, omit, omit);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002750 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002751}
2752
2753/* PAGING by IMSI + TMSI */
2754testcase TC_paging_tmsi_nochan() runs on test_CT {
2755 var BSSMAP_FIELD_CellIdentificationList cid_list;
2756 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01002757 f_pageing_helper('001010100000001'H, cid_list, c_BtsId_all, omit, 'A1B2C301'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002758 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002759}
2760
2761/* Paging with different "channel needed' values */
2762testcase TC_paging_tmsi_any() runs on test_CT {
2763 var BSSMAP_FIELD_CellIdentificationList cid_list;
2764 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01002765 f_pageing_helper('001010100000002'H, cid_list, c_BtsId_all, RSL_CHANNEED_ANY, 'A1B2C302'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002766 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002767}
2768testcase TC_paging_tmsi_sdcch() runs on test_CT {
2769 var BSSMAP_FIELD_CellIdentificationList cid_list;
2770 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01002771 f_pageing_helper('001010100000003'H, cid_list, c_BtsId_all, RSL_CHANNEED_SDCCH, 'A1B2C303'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002772 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002773}
2774testcase TC_paging_tmsi_tch_f() runs on test_CT {
2775 var BSSMAP_FIELD_CellIdentificationList cid_list;
2776 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01002777 f_pageing_helper('001010000000004'H, cid_list, c_BtsId_all, RSL_CHANNEED_TCH_F, 'A1B2C304'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002778 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002779}
2780testcase TC_paging_tmsi_tch_hf() runs on test_CT {
2781 var BSSMAP_FIELD_CellIdentificationList cid_list;
2782 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01002783 f_pageing_helper('001010000000005'H, cid_list, c_BtsId_all, RSL_CHANNEED_TCH_ForH, 'A1B2C305'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002784 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002785}
2786
2787/* Paging by CGI */
2788testcase TC_paging_imsi_nochan_cgi() runs on test_CT {
2789 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2790 cid_list := { cIl_CGI := { ts_BSSMAP_CI_CGI(cid.mcc, cid.mnc, cid.lac, cid.ci) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01002791 f_pageing_helper('001010000000006'H, cid_list, { 0 });
Philipp Maier282ca4b2018-02-27 17:17:00 +01002792 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002793}
2794
2795/* Paging by LAC+CI */
2796testcase TC_paging_imsi_nochan_lac_ci() runs on test_CT {
2797 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2798 cid_list := { cIl_LAC_CI := { ts_BSSMAP_CI_LAC_CI(cid.lac, cid.ci) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01002799 f_pageing_helper('001010000000007'H, cid_list, { 0 });
Philipp Maier282ca4b2018-02-27 17:17:00 +01002800 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002801}
2802
2803/* Paging by CI */
2804testcase TC_paging_imsi_nochan_ci() runs on test_CT {
2805 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2806 cid_list := { cIl_CI := { ts_BSSMAP_CI_CI(cid.ci) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01002807 f_pageing_helper('001010000000008'H, cid_list, { 0 });
Philipp Maier282ca4b2018-02-27 17:17:00 +01002808 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002809}
2810
2811/* Paging by LAI */
2812testcase TC_paging_imsi_nochan_lai() runs on test_CT {
2813 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2814 cid_list := { cIl_LAI := { ts_BSSMAP_CI_LAI(cid.mcc, cid.mnc, cid.lac) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01002815 f_pageing_helper('001010000000009'H, cid_list, c_BtsId_LAC1);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002816 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002817}
2818
2819/* Paging by LAC */
2820testcase TC_paging_imsi_nochan_lac() runs on test_CT {
2821 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2822 cid_list := { cIl_LAC := { ts_BSSMAP_CI_LAC(cid.lac) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01002823 f_pageing_helper('001010000000010'H, cid_list, c_BtsId_LAC1);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002824 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002825}
2826
2827/* Paging by "all in BSS" */
2828testcase TC_paging_imsi_nochan_all() runs on test_CT {
2829 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2830 cid_list := { cIl_allInBSS := ''O };
Harald Welte5d1a2202017-12-13 19:51:29 +01002831 f_pageing_helper('001010000000011'H, cid_list, c_BtsId_all);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002832 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002833}
2834
Stefan Sperling7b5e1782018-03-20 19:32:43 +01002835/* Paging by PLMN+LAC+RNC; We do not implement this; Verify nothing is paged */
Harald Welte751d3eb2018-01-31 15:51:06 +01002836testcase TC_paging_imsi_nochan_plmn_lac_rnc() runs on test_CT {
2837 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2838 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 +01002839 f_pageing_helper('001010000000012'H, cid_list, c_BtsId_none);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002840 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01002841}
Harald Welte6f521d82017-12-11 19:52:02 +01002842
Stefan Sperling7b5e1782018-03-20 19:32:43 +01002843/* Paging by RNC; We do not implement this; Verify nothing is paged */
Harald Welte751d3eb2018-01-31 15:51:06 +01002844testcase TC_paging_imsi_nochan_rnc() runs on test_CT {
2845 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2846 cid_list := { cIl_RNC := { int2oct(13, 2) } };
Stefan Sperling7b5e1782018-03-20 19:32:43 +01002847 f_pageing_helper('001010000000013'H, cid_list, c_BtsId_none);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002848 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01002849}
2850
Stefan Sperling7b5e1782018-03-20 19:32:43 +01002851/* Paging by LAC+RNC; We do not implement; Verify nothing is paged */
Harald Welte751d3eb2018-01-31 15:51:06 +01002852testcase TC_paging_imsi_nochan_lac_rnc() runs on test_CT {
2853 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2854 cid_list := { cIl_LAC_RNC := { ts_BSSMAP_CI_LAC_RNC(cid.lac, 14) } };
Stefan Sperling7b5e1782018-03-20 19:32:43 +01002855 f_pageing_helper('001010000000014'H, cid_list, c_BtsId_none);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002856 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01002857}
2858
Harald Welte6f521d82017-12-11 19:52:02 +01002859/* Paging on multiple cells (multiple entries in list): Verify all of them page */
Harald Welte751d3eb2018-01-31 15:51:06 +01002860testcase TC_paging_imsi_nochan_lacs() runs on test_CT {
2861 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2862 cid_list := { cIl_LAC := { ts_BSSMAP_CI_LAC(1), ts_BSSMAP_CI_LAC(2) } };
2863 f_pageing_helper('001010000000015'H, cid_list, c_BtsId_all);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002864 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01002865}
2866
2867/* Paging on empty list: Verify none of them page */
2868testcase TC_paging_imsi_nochan_lacs_empty() runs on test_CT {
2869 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2870 cid_list := { cIl_LAC := { } };
2871 f_pageing_helper('001010000000016'H, cid_list, c_BtsId_none);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002872 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01002873}
2874
Stefan Sperling049a86e2018-03-20 15:51:00 +01002875/* Paging by CGI with unknown MCC/MNC: Verify nothing is paged. */
2876testcase TC_paging_imsi_nochan_cgi_unknown_cid() runs on test_CT {
2877 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2878 cid_list := { cIl_CGI := { ts_BSSMAP_CI_CGI(unknown_cid.mcc, unknown_cid.mnc, unknown_cid.lac, unknown_cid.ci) } };
2879 f_pageing_helper('001010000000006'H, cid_list, c_BtsId_none);
2880 f_shutdown_helper();
2881}
2882
Harald Welte6f521d82017-12-11 19:52:02 +01002883/* Verify paging retransmission interval + count */
2884/* Verify paging stops after channel establishment */
Harald Welte6f521d82017-12-11 19:52:02 +01002885/* Test behavior under paging overload */
Harald Welteae026692017-12-09 01:03:01 +01002886
Harald Weltee65d40e2017-12-13 00:09:06 +01002887/* Verify PCH load */
2888testcase TC_paging_imsi_load() runs on test_CT {
2889 var BSSMAP_FIELD_CellIdentificationList cid_list;
2890 timer T := 4.0;
Harald Welte2caa1062018-03-17 18:19:05 +01002891 timer T_retrans := 1.0;
Harald Weltee65d40e2017-12-13 00:09:06 +01002892 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01002893 f_pageing_helper('001010123456789'H, cid_list, c_BtsId_all);
Harald Weltee65d40e2017-12-13 00:09:06 +01002894
2895 /* tell BSC there is no paging space anymore */
2896 f_ipa_tx(0, ts_RSL_PAGING_LOAD_IND(0));
Harald Welte3b57ab52018-03-17 18:01:10 +01002897 f_sleep(0.2);
2898 IPA_RSL[0].clear;
Harald Weltee65d40e2017-12-13 00:09:06 +01002899
2900 /* Wait for 4 seconds if any more PAGING CMD are received on RSL. Normally,
2901 * there would be 8 retransmissions during 4 seconds */
2902 T.start;
Harald Welte2caa1062018-03-17 18:19:05 +01002903 T_retrans.start;
Harald Weltee65d40e2017-12-13 00:09:06 +01002904 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07002905 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD(?))) {
Harald Weltee65d40e2017-12-13 00:09:06 +01002906 setverdict(fail, "Received PAGING after LOAD_IND(0)");
Daniel Willmannafce8662018-07-06 23:11:32 +02002907 mtc.stop;
Harald Weltee65d40e2017-12-13 00:09:06 +01002908 }
Harald Welte2caa1062018-03-17 18:19:05 +01002909 [] T_retrans.timeout {
2910 /* re-trnsmit the zero-space LOAD IND to avoid BSC 'auto credit' */
2911 f_ipa_tx(0, ts_RSL_PAGING_LOAD_IND(0));
2912 T_retrans.start;
2913 repeat;
2914 }
Harald Weltee65d40e2017-12-13 00:09:06 +01002915 [] T.timeout {
2916 setverdict(pass);
2917 }
2918 }
Philipp Maier282ca4b2018-02-27 17:17:00 +01002919
2920 f_shutdown_helper();
Harald Weltee65d40e2017-12-13 00:09:06 +01002921}
2922
Harald Welte235ebf12017-12-15 14:18:16 +01002923/* Verify Paging Counter */
Harald Welte1ff69992017-12-14 12:31:17 +01002924testcase TC_paging_counter() runs on test_CT {
2925 var BSSMAP_FIELD_CellIdentificationList cid_list;
2926 timer T := 4.0;
2927 var integer i;
2928 var integer paging_attempted_bsc;
2929 var integer paging_attempted_bts[NUM_BTS];
2930 var integer paging_expired_bts[NUM_BTS];
2931 cid_list := valueof(ts_BSSMAP_CIL_noCell);
2932
2933 f_init();
2934
2935 /* read counters before paging */
2936 paging_attempted_bsc := f_ctrl_get_ratectr_abs(IPA_CTRL, "bsc", 0, "paging:attempted");
2937 for (i := 0; i < NUM_BTS; i := i+1) {
2938 paging_attempted_bts[i] := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", i, "paging:attempted");
2939 paging_expired_bts[i] := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", i, "paging:expired");
2940 }
2941
2942 f_pageing_helper('001230000000001'H, cid_list, c_BtsId_all);
2943
2944 /* expect the attempted pages on BSC and each BTSs to have incremented by one */
2945 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bsc", 0, "paging:attempted", paging_attempted_bsc+1);
2946 for (i := 0; i < NUM_BTS; i := i+1) {
2947 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", i, "paging:attempted",
2948 paging_attempted_bts[i]+1);
2949 }
2950
2951 /* assume that 12s later the paging on all BTSs have expired and hence incremented by 1 */
2952 f_sleep(12.0);
2953 for (i := 0; i < NUM_BTS; i := i+1) {
2954 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", i, "paging:expired",
2955 paging_expired_bts[i]+1);
2956 }
Harald Welte1ff69992017-12-14 12:31:17 +01002957
Philipp Maier282ca4b2018-02-27 17:17:00 +01002958 f_shutdown_helper();
Harald Welte1ff69992017-12-14 12:31:17 +01002959}
2960
2961
Harald Welte10985002017-12-12 09:29:15 +01002962/* Verify paging stops after A-RESET */
2963testcase TC_paging_imsi_a_reset() runs on test_CT {
2964 var BSSMAP_FIELD_CellIdentificationList cid_list;
2965 timer T := 3.0;
2966 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01002967 f_pageing_helper('001010123456789'H, cid_list, c_BtsId_all);
Harald Welte10985002017-12-12 09:29:15 +01002968
2969 /* Perform a BSSMAP Reset and wait for ACK */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02002970 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 +01002971 alt {
Neels Hofmeyrf246a922020-05-13 02:27:10 +02002972 [] 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 +01002973 [] BSSAP.receive { repeat; }
2974 }
2975
Daniel Willmanncbef3982018-07-30 09:22:40 +02002976 /* Wait to avoid a possible race condition if a paging message is
2977 * received right before the reset ACK. */
2978 f_sleep(0.2);
2979
Harald Welte10985002017-12-12 09:29:15 +01002980 /* Clear the queue, it might still contain stuff like BCCH FILLING */
Philipp Maier1e6b4422018-02-23 14:02:13 +01002981 for (var integer i := 0; i < sizeof(IPA_RSL); i := i+1) {
2982 IPA_RSL[i].clear;
2983 }
Harald Welte10985002017-12-12 09:29:15 +01002984
2985 /* Wait for 3 seconds if any more PAGING CMD are received on RSL */
2986 T.start;
2987 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07002988 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD(?))) {
Harald Welte10985002017-12-12 09:29:15 +01002989 setverdict(fail, "Received PAGING after A-RESET");
Daniel Willmannafce8662018-07-06 23:11:32 +02002990 mtc.stop;
Harald Welte10985002017-12-12 09:29:15 +01002991 }
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07002992 [] IPA_RSL[1].receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD(?))) {
Harald Welte5d1a2202017-12-13 19:51:29 +01002993 setverdict(fail, "Received PAGING after A-RESET");
Daniel Willmannafce8662018-07-06 23:11:32 +02002994 mtc.stop;
Harald Welte5d1a2202017-12-13 19:51:29 +01002995 }
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07002996 [] IPA_RSL[2].receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD(?))) {
Harald Welte5d1a2202017-12-13 19:51:29 +01002997 setverdict(fail, "Received PAGING after A-RESET");
Daniel Willmannafce8662018-07-06 23:11:32 +02002998 mtc.stop;
Harald Welte5d1a2202017-12-13 19:51:29 +01002999 }
Harald Welte10985002017-12-12 09:29:15 +01003000 [] T.timeout {
3001 setverdict(pass);
3002 }
3003 }
Philipp Maier282ca4b2018-02-27 17:17:00 +01003004
3005 f_shutdown_helper();
Harald Welte10985002017-12-12 09:29:15 +01003006}
Harald Welteae026692017-12-09 01:03:01 +01003007
Philipp Maierf45824a2019-08-14 14:44:10 +02003008/* Verify how we handle unsolicited Paging Response. In case of an unsolicit
3009 * paging response we can not know which MSC is in charge, so we will blindly
3010 * pick the first configured MSC. This behavior is required in order to make
3011 * MT-CSFB calls working because in those cases the BSC can not know that the
3012 * MSC has already paged the subscriver via SGs. So any MT-CSFB call will look
3013 * like an unsolicited Paging Response to the MSC.
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01003014 */
3015testcase TC_paging_resp_unsol() runs on test_CT {
3016
3017 f_init(1);
Philipp Maierf45824a2019-08-14 14:44:10 +02003018 timer T := 5.0;
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01003019
3020 var BSSAP_N_CONNECT_ind rx_c_ind;
3021 var DchanTuple dt;
3022 var PDU_ML3_MS_NW l3 := valueof(ts_PAG_RESP(valueof(ts_MI_IMSI_LV('001010008880018'H))));
Philipp Maierf45824a2019-08-14 14:44:10 +02003023 var octetstring rr_pag_resp := enc_PDU_ML3_MS_NW(l3);
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01003024
3025 /* Send CHAN RQD and wait for allocation; acknowledge it */
3026 dt.rsl_chan_nr := f_chreq_act_ack();
3027
3028 /* Send unsolicited Paging response (no matching Paging CMD stored in BSC) */
3029 f_ipa_tx(0, ts_RSL_EST_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0)), enc_PDU_ML3_MS_NW(l3)));
3030
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01003031
Philipp Maierf45824a2019-08-14 14:44:10 +02003032 /* Expevct a CR with a matching Paging response on the A-Interface */
3033 T.start;
3034 alt {
3035 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(rr_pag_resp))) {
3036 setverdict(pass);
3037 }
3038 [] BSSAP.receive {
3039 setverdict(fail, "Received unexpected message on A-Interface!");
3040 }
3041 [] T.timeout {
3042 setverdict(fail, "Received nothing on A-Interface!");
3043 }
3044 }
3045
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003046 f_shutdown_helper();
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01003047}
3048
Harald Welte4e9b9cc2017-12-14 18:31:02 +01003049/* Test RSL link drop causes counter increment */
3050testcase TC_rsl_drop_counter() runs on test_CT {
3051 var integer rsl_fail;
3052
Harald Welte89d42e82017-12-17 16:42:41 +01003053 f_init(1);
Harald Welte4e9b9cc2017-12-14 18:31:02 +01003054
3055 rsl_fail := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "rsl_fail");
3056
3057 bts[0].rsl.vc_IPA.stop;
3058
3059 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "rsl_fail", rsl_fail+1);
3060
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003061 f_shutdown_helper();
Harald Welte4e9b9cc2017-12-14 18:31:02 +01003062}
3063
3064/* TODO: Test OML link drop causes counter increment */
3065
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003066/* The body of TC_rsl_unknown_unit_id() and TC_oml_unknown_unit_id() tests. */
3067function f_ipa_unknown_unit_id(integer mp_bsc_ipa_port) runs on test_CT return boolean {
3068 timer T := 10.0;
3069
3070 bts[0].rsl.id := "IPA-0-RSL";
3071 bts[0].rsl.vc_IPA := IPA_Emulation_CT.create(bts[0].rsl.id & "-IPA");
3072 bts[0].rsl.ccm_pars := c_IPA_default_ccm_pars;
3073 bts[0].rsl.ccm_pars.name := "Osmocom TTCN-3 BTS Simulator";
Oliver Smith92c2bdb2019-08-20 15:11:24 +02003074 bts[0].rsl.ccm_pars.unit_id := "99/0/0"; /* value which is unknown at BTS */
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003075
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003076 f_ipa_ctrl_start(mp_bsc_ip, mp_bsc_ctrl_port);
3077
3078 f_init_mgcp("VirtMSC");
3079
3080 /* start RSL/OML connection (XXX re-uses RSL port/protocol definitions for OML) */
3081 map(bts[0].rsl.vc_IPA:IPA_PORT, system:IPA);
3082 connect(bts[0].rsl.vc_IPA:IPA_RSL_PORT, self:IPA_RSL[0]);
3083 bts[0].rsl.vc_IPA.start(IPA_Emulation.main_client(mp_bsc_ip, mp_bsc_ipa_port, "", 10000, bts[0].rsl.ccm_pars));
3084
3085 /* wait for IPA OML link to connect and then disconnect */
3086 T.start;
3087 alt {
Vadim Yanitskiya2afacc2020-05-18 21:16:19 +07003088 [] IPA_RSL[0].receive(tr_ASP_IPA_EV(ASP_IPA_EVENT_DOWN)) {
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003089 T.stop;
3090 return true;
3091 }
3092 [] IPA_RSL[0].receive { repeat }
3093 [] T.timeout {
Daniel Willmannafce8662018-07-06 23:11:32 +02003094 return false;
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003095 }
3096 }
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003097 return false;
3098}
3099
3100/* BSC should close an RSL connection from a BTS with unknown unit ID (OS#2714). */
3101testcase TC_rsl_unknown_unit_id() runs on test_CT {
3102 if (f_ipa_unknown_unit_id(mp_bsc_rsl_port)) {
3103 setverdict(pass);
3104 } else {
3105 setverdict(fail, "Timeout RSL waiting for connection to close");
3106 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003107 f_shutdown_helper();
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003108}
3109
3110
3111/* BSC should close an RSL connection from a BTS with unknown unit ID (OS#2714). */
3112testcase TC_oml_unknown_unit_id() runs on test_CT {
3113 if (f_ipa_unknown_unit_id(mp_bsc_oml_port)) {
3114 setverdict(pass);
3115 } else {
3116 setverdict(fail, "Timeout OML waiting for connection to close");
3117 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003118 f_shutdown_helper();
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003119}
3120
3121
Harald Weltec1a2fff2017-12-17 11:06:19 +01003122/***********************************************************************
Harald Welte6811d102019-04-14 22:23:14 +02003123 * "New world" test cases using RSL_Emulation + RAN_Emulation
Harald Weltec1a2fff2017-12-17 11:06:19 +01003124 ***********************************************************************/
3125
Harald Welte6811d102019-04-14 22:23:14 +02003126import from RAN_Emulation all;
Harald Welte47cd0e32020-08-21 12:39:11 +02003127import from BSSAP_LE_Emulation all;
Harald Weltec1a2fff2017-12-17 11:06:19 +01003128import from RSL_Emulation all;
3129import from MSC_ConnectionHandler all;
3130
3131type function void_fn(charstring id) runs on MSC_ConnHdlr;
3132
Harald Welte336820c2018-05-31 20:34:52 +02003133/* helper function to create and connect a MSC_ConnHdlr component */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003134private function f_connect_handler(inout MSC_ConnHdlr vc_conn, integer bssap_idx := 0) runs on test_CT {
3135 connect(vc_conn:RAN, g_bssap[bssap_idx].vc_RAN:PROC);
Daniel Willmann191e0d92018-01-17 12:44:35 +01003136 connect(vc_conn:MGCP_PROC, vc_MGCP:MGCP_PROC);
Harald Weltec1a2fff2017-12-17 11:06:19 +01003137 connect(vc_conn:RSL, bts[0].rsl.vc_RSL:CLIENT_PT);
Harald Weltef70df652018-01-29 22:00:23 +01003138 connect(vc_conn:RSL_PROC, bts[0].rsl.vc_RSL:RSL_PROC);
Philipp Maier88f4ae82018-03-01 14:00:58 +01003139 if (isvalue(bts[1])) {
Philipp Maier956a92f2018-02-16 10:58:07 +01003140 connect(vc_conn:RSL1, bts[1].rsl.vc_RSL:CLIENT_PT);
3141 connect(vc_conn:RSL1_PROC, bts[1].rsl.vc_RSL:RSL_PROC);
3142 }
Neels Hofmeyr91401012019-07-11 00:42:35 +02003143 if (isvalue(bts[2])) {
3144 connect(vc_conn:RSL2, bts[2].rsl.vc_RSL:CLIENT_PT);
3145 connect(vc_conn:RSL2_PROC, bts[2].rsl.vc_RSL:RSL_PROC);
3146 }
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003147 connect(vc_conn:BSSAP, g_bssap[bssap_idx].vc_RAN:CLIENT);
Neels Hofmeyrcfe44062020-10-15 02:28:08 +02003148 if (mp_enable_lcs_tests) {
3149 connect(vc_conn:BSSAP_LE, g_bssap_le.vc_BSSAP_LE:CLIENT);
3150 connect(vc_conn:BSSAP_LE_PROC, g_bssap_le.vc_BSSAP_LE:PROC);
3151 }
Daniel Willmann191e0d92018-01-17 12:44:35 +01003152 connect(vc_conn:MGCP, vc_MGCP:MGCP_CLIENT);
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +02003153 connect(vc_conn:MGCP_MULTI, vc_MGCP:MGCP_CLIENT_MULTI);
Daniel Willmannebdecc02020-08-12 15:30:17 +02003154 connect(vc_conn:STATSD_PROC, vc_STATSD:STATSD_PROC);
Harald Welte336820c2018-05-31 20:34:52 +02003155}
3156
3157function f_start_handler(void_fn fn, template (omit) TestHdlrParams pars := omit)
3158runs on test_CT return MSC_ConnHdlr {
3159 var charstring id := testcasename();
3160 var MSC_ConnHdlr vc_conn;
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003161 var integer bssap_idx := 0;
3162 if (isvalue(pars)) {
3163 bssap_idx := valueof(pars).mscpool.bssap_idx;
3164 }
Harald Welte336820c2018-05-31 20:34:52 +02003165 vc_conn := MSC_ConnHdlr.create(id);
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003166 f_connect_handler(vc_conn, bssap_idx);
Harald Weltea0630032018-03-20 21:09:55 +01003167 vc_conn.start(f_handler_init(fn, id, pars));
Harald Weltec1a2fff2017-12-17 11:06:19 +01003168 return vc_conn;
3169}
3170
Harald Weltea0630032018-03-20 21:09:55 +01003171/* first function inside ConnHdlr component; sets g_pars + starts function */
3172private function f_handler_init(void_fn fn, charstring id, template (omit) TestHdlrParams pars := omit)
3173runs on MSC_ConnHdlr {
3174 if (isvalue(pars)) {
3175 g_pars := valueof(pars);
3176 }
3177 fn.apply(id);
3178}
3179
Harald Welte3c86ea02018-05-10 22:28:05 +02003180/* Establish signalling channel (non-assignment case) followed by cipher mode */
3181private function f_tc_ciph_mode_a5(charstring id) runs on MSC_ConnHdlr {
Harald Welteed848512018-05-24 22:27:58 +02003182 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3183 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte3c86ea02018-05-10 22:28:05 +02003184 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeSIGNAL);
Philipp Maier23000732018-05-18 11:25:37 +02003185 ass_cmd.pdu.bssmap.assignmentRequest.circuitIdentityCode := omit;
3186 ass_cmd.pdu.bssmap.assignmentRequest.aoIPTransportLayer := omit;
3187 exp_compl.pdu.bssmap.assignmentComplete.circuitIdentityCode := omit;
3188 exp_compl.pdu.bssmap.assignmentComplete.aoIPTransportLayer := omit;
Harald Welte3c86ea02018-05-10 22:28:05 +02003189
Philipp Maier23000732018-05-18 11:25:37 +02003190 f_establish_fully(ass_cmd, exp_compl);
Harald Welte3c86ea02018-05-10 22:28:05 +02003191}
3192testcase TC_ciph_mode_a5_0() runs on test_CT {
3193 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02003194 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte3c86ea02018-05-10 22:28:05 +02003195 pars.encr := valueof(t_EncrParams('01'O, f_rnd_octstring(8)));
3196
3197 f_init(1, true);
3198 f_sleep(1.0);
3199 vc_conn := f_start_handler(refers(f_tc_ciph_mode_a5), pars);
3200 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003201 f_shutdown_helper();
Harald Welte3c86ea02018-05-10 22:28:05 +02003202}
3203testcase TC_ciph_mode_a5_1() runs on test_CT {
3204 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02003205 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte3c86ea02018-05-10 22:28:05 +02003206 pars.encr := valueof(t_EncrParams('02'O, f_rnd_octstring(8)));
3207
3208 f_init(1, true);
3209 f_sleep(1.0);
3210 vc_conn := f_start_handler(refers(f_tc_ciph_mode_a5), pars);
3211 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003212 f_shutdown_helper();
Harald Welte3c86ea02018-05-10 22:28:05 +02003213}
3214testcase TC_ciph_mode_a5_3() runs on test_CT {
3215 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02003216 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte3c86ea02018-05-10 22:28:05 +02003217 pars.encr := valueof(t_EncrParams('08'O, f_rnd_octstring(8)));
3218
3219 f_init(1, true);
3220 f_sleep(1.0);
3221 vc_conn := f_start_handler(refers(f_tc_ciph_mode_a5), pars);
3222 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003223 f_shutdown_helper();
Harald Welte3c86ea02018-05-10 22:28:05 +02003224}
3225
Pau Espin Pedrol07866632020-09-03 19:10:55 +02003226/* establish initial channel, enable ciphering followed by assignment to ciphered channel */
3227private function f_tc_assignment_aoip_tla_v6(charstring id) runs on MSC_ConnHdlr {
3228 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3229 var PDU_BSSAP ass_cmd := f_gen_ass_req(aoip_tla := "::3");
3230 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3231 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
3232
3233 f_establish_fully(ass_cmd, exp_compl);
3234}
3235testcase TC_assignment_aoip_tla_v6() runs on test_CT {
3236 var MSC_ConnHdlr vc_conn;
3237 var TestHdlrParams pars := f_gen_test_hdlr_pars();
3238
3239 f_init(1, true);
3240 f_sleep(1.0);
3241 vc_conn := f_start_handler(refers(f_tc_assignment_aoip_tla_v6), pars);
3242 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003243 f_shutdown_helper();
Pau Espin Pedrol07866632020-09-03 19:10:55 +02003244}
3245
Harald Welte3c86ea02018-05-10 22:28:05 +02003246
3247/* establish initial channel, enable ciphering followed by assignment to ciphered channel */
Harald Welte651fcdc2018-05-10 20:23:16 +02003248private function f_tc_assignment_fr_a5(charstring id) runs on MSC_ConnHdlr {
Harald Welteed848512018-05-24 22:27:58 +02003249 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3250 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Weltec1a2fff2017-12-17 11:06:19 +01003251
Harald Welte552620d2017-12-16 23:21:36 +01003252 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3253 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
Harald Welte73cd2712017-12-17 00:44:52 +01003254
Harald Weltea0630032018-03-20 21:09:55 +01003255 f_establish_fully(ass_cmd, exp_compl);
Harald Welte552620d2017-12-16 23:21:36 +01003256}
Harald Welte552620d2017-12-16 23:21:36 +01003257testcase TC_assignment_fr_a5_0() runs on test_CT {
3258 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02003259 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte651fcdc2018-05-10 20:23:16 +02003260 pars.encr := valueof(t_EncrParams('01'O, f_rnd_octstring(8)));
Harald Welte552620d2017-12-16 23:21:36 +01003261
Harald Welte89d42e82017-12-17 16:42:41 +01003262 f_init(1, true);
Harald Welte552620d2017-12-16 23:21:36 +01003263 f_sleep(1.0);
Harald Welte651fcdc2018-05-10 20:23:16 +02003264 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5), pars);
Harald Welte552620d2017-12-16 23:21:36 +01003265 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003266 f_shutdown_helper();
Harald Welte552620d2017-12-16 23:21:36 +01003267}
Harald Welte552620d2017-12-16 23:21:36 +01003268testcase TC_assignment_fr_a5_1() runs on test_CT {
Harald Weltec1a2fff2017-12-17 11:06:19 +01003269 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02003270 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte651fcdc2018-05-10 20:23:16 +02003271 pars.encr := valueof(t_EncrParams('02'O, f_rnd_octstring(8)));
Harald Weltec1a2fff2017-12-17 11:06:19 +01003272
Harald Welte89d42e82017-12-17 16:42:41 +01003273 f_init(1, true);
Harald Weltec1a2fff2017-12-17 11:06:19 +01003274 f_sleep(1.0);
Harald Welte651fcdc2018-05-10 20:23:16 +02003275 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5), pars);
3276 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003277 f_shutdown_helper();
Harald Welte651fcdc2018-05-10 20:23:16 +02003278}
3279testcase TC_assignment_fr_a5_3() runs on test_CT {
3280 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02003281 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte651fcdc2018-05-10 20:23:16 +02003282 pars.encr := valueof(t_EncrParams('08'O, f_rnd_octstring(8)));
Harald Weltec1a2fff2017-12-17 11:06:19 +01003283
Harald Welte651fcdc2018-05-10 20:23:16 +02003284 f_init(1, true);
3285 f_sleep(1.0);
3286 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5), pars);
Harald Weltec1a2fff2017-12-17 11:06:19 +01003287 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003288 f_shutdown_helper();
Harald Weltec1a2fff2017-12-17 11:06:19 +01003289}
3290
Harald Welte552620d2017-12-16 23:21:36 +01003291/* Expect ASSIGNMENT FAIL if mandatory IE is missing */
3292private function f_tc_assignment_fr_a5_1_codec_missing(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02003293 g_pars := f_gen_test_hdlr_pars();
Harald Welte552620d2017-12-16 23:21:36 +01003294 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
Harald Welteed848512018-05-24 22:27:58 +02003295 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte552620d2017-12-16 23:21:36 +01003296 const OCT8 kc := '0001020304050607'O;
3297
3298 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02003299 /* Omit: ass_cmd.pdu.bssmap.assignmentRequest.codecList */
3300
Harald Weltea0630032018-03-20 21:09:55 +01003301 f_establish_fully(ass_cmd, exp_fail);
Harald Welte552620d2017-12-16 23:21:36 +01003302}
Harald Welte552620d2017-12-16 23:21:36 +01003303testcase TC_assignment_fr_a5_1_codec_missing() runs on test_CT {
3304 var MSC_ConnHdlr vc_conn;
3305
Harald Welte89d42e82017-12-17 16:42:41 +01003306 f_init(1, true);
Harald Welte552620d2017-12-16 23:21:36 +01003307 f_sleep(1.0);
3308
Harald Welte8863fa12018-05-10 20:15:27 +02003309 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5_1_codec_missing));
Harald Welte552620d2017-12-16 23:21:36 +01003310 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003311 f_shutdown_helper();
Harald Welte552620d2017-12-16 23:21:36 +01003312}
3313
Harald Welte552620d2017-12-16 23:21:36 +01003314private function f_tc_assignment_fr_a5_4(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02003315 g_pars := f_gen_test_hdlr_pars();
Harald Welteed848512018-05-24 22:27:58 +02003316 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3317 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte552620d2017-12-16 23:21:36 +01003318 const OCT8 kc := '0001020304050607'O;
3319 const OCT16 kc128 := kc & kc;
3320
3321 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3322 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
Harald Weltea0630032018-03-20 21:09:55 +01003323 f_establish_fully(ass_cmd, exp_compl);
Harald Welte38b2a102017-12-23 02:42:58 +01003324 f_cipher_mode('10'O, kc, kc128, true);
Harald Welte552620d2017-12-16 23:21:36 +01003325 /* TODO: expect GSM0808_CAUSE_CIPHERING_ALGORITHM_NOT_SUPPORTED cause value */
Harald Welte552620d2017-12-16 23:21:36 +01003326}
Harald Welte552620d2017-12-16 23:21:36 +01003327testcase TC_assignment_fr_a5_4() runs on test_CT {
3328 var MSC_ConnHdlr vc_conn;
3329
Harald Welte89d42e82017-12-17 16:42:41 +01003330 f_init(1, true);
Harald Welte552620d2017-12-16 23:21:36 +01003331 f_sleep(1.0);
3332
Harald Welte8863fa12018-05-10 20:15:27 +02003333 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5_4));
Harald Welte552620d2017-12-16 23:21:36 +01003334 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003335 f_shutdown_helper();
Harald Welte552620d2017-12-16 23:21:36 +01003336}
3337
3338
Harald Welte4532e0a2017-12-23 02:05:44 +01003339private function f_tc_assignment_sign(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02003340 g_pars := f_gen_test_hdlr_pars();
Harald Welte4532e0a2017-12-23 02:05:44 +01003341 var template PDU_BSSAP exp_compl := tr_BSSMAP_AssignmentComplete(omit, omit);
Philipp Maier48604732018-10-09 15:00:37 +02003342 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte4532e0a2017-12-23 02:05:44 +01003343 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeSIGNAL);
Daniel Willmannebdecc02020-08-12 15:30:17 +02003344
3345 f_statsd_reset();
Harald Weltea0630032018-03-20 21:09:55 +01003346 f_establish_fully(ass_cmd, exp_compl);
Daniel Willmannebdecc02020-08-12 15:30:17 +02003347
3348 var StatsDExpects expect := {
Daniel Willmannc5398f72020-09-21 10:41:35 +02003349 { name := "TTCN3.bts.0.chreq.total", mtype := "c", min := 1, max := 1},
3350 { name := "TTCN3.bts.0.chreq.successful", mtype := "c", min := 1, max := 1},
Daniel Willmannebdecc02020-08-12 15:30:17 +02003351 { name := "TTCN3.bsc.0.assignment.attempted", mtype := "c", min := 1, max := 1},
3352 { name := "TTCN3.bsc.0.assignment.completed", mtype := "c", min := 1, max := 1}
3353 };
3354 f_statsd_expect(expect);
Harald Welte4532e0a2017-12-23 02:05:44 +01003355}
3356
3357testcase TC_assignment_sign() runs on test_CT {
3358 var MSC_ConnHdlr vc_conn;
3359
3360 f_init(1, true);
3361 f_sleep(1.0);
3362
Harald Welte8863fa12018-05-10 20:15:27 +02003363 vc_conn := f_start_handler(refers(f_tc_assignment_sign));
Harald Welte4532e0a2017-12-23 02:05:44 +01003364 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003365 f_shutdown_helper();
Harald Welte4532e0a2017-12-23 02:05:44 +01003366}
3367
Harald Welte60aa5762018-03-21 19:33:13 +01003368/***********************************************************************
3369 * Codec (list) testing
3370 ***********************************************************************/
3371
3372/* check if the given rsl_mode is compatible with the a_elem */
3373private function f_match_codec(BSSMAP_FIELD_CodecElement a_elem, RSL_IE_ChannelMode rsl_mode)
3374return boolean {
3375 select (a_elem.codecType) {
3376 case (GSM_FR) {
3377 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM1))) {
3378 return true;
3379 }
3380 }
3381 case (GSM_HR) {
3382 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_H, RSL_CMOD_SP_GSM1))) {
3383 return true;
3384 }
3385 }
3386 case (GSM_EFR) {
3387 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM2))) {
3388 return true;
3389 }
3390 }
3391 case (FR_AMR) {
3392 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM3))) {
3393 return true;
3394 }
3395 }
3396 case (HR_AMR) {
3397 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_H, RSL_CMOD_SP_GSM3))) {
3398 return true;
3399 }
3400 }
3401 case else { }
3402 }
3403 return false;
3404}
3405
3406/* check if the given rsl_mode is compatible with the a_list */
3407private function f_match_codecs(BSSMAP_IE_SpeechCodecList a_list, RSL_IE_ChannelMode rsl_mode)
3408return boolean {
3409 for (var integer i := 0; i < sizeof(a_list); i := i+1) {
3410 if (f_match_codec(a_list.codecElements[i], rsl_mode)) {
3411 return true;
3412 }
3413 }
3414 return false;
3415}
3416
3417/* determine BSSMAP_IE_ChannelType from *first* element of BSSMAP_FIELD_CodecElement */
Philipp Maier61f6b572018-07-06 14:03:38 +02003418function f_BSSMAP_chtype_from_codec(BSSMAP_FIELD_CodecElement a_elem)
Harald Welte60aa5762018-03-21 19:33:13 +01003419return BSSMAP_IE_ChannelType {
3420 /* FIXME: actually look at all elements of BSSMAP_IE_SpeechCodecList */
3421 var BSSMAP_IE_ChannelType ret := valueof(ts_BSSMAP_IE_ChannelType);
3422 select (a_elem.codecType) {
3423 case (GSM_FR) {
3424 ret.channelRateAndType := ChRate_TCHF;
3425 ret.speechId_DataIndicator := Spdi_TCHF_FR;
3426 }
3427 case (GSM_HR) {
3428 ret.channelRateAndType := ChRate_TCHH;
3429 ret.speechId_DataIndicator := Spdi_TCHH_HR;
3430 }
3431 case (GSM_EFR) {
3432 ret.channelRateAndType := ChRate_TCHF;
3433 ret.speechId_DataIndicator := Spdi_TCHF_EFR;
3434 }
3435 case (FR_AMR) {
3436 ret.channelRateAndType := ChRate_TCHF;
3437 ret.speechId_DataIndicator := Spdi_TCHF_AMR;
3438 }
3439 case (HR_AMR) {
3440 ret.channelRateAndType := ChRate_TCHH;
3441 ret.speechId_DataIndicator := Spdi_TCHH_AMR;
3442 }
3443 case else {
3444 setverdict(fail, "Unsupported codec ", a_elem);
Daniel Willmannafce8662018-07-06 23:11:32 +02003445 mtc.stop;
Harald Welte60aa5762018-03-21 19:33:13 +01003446 }
3447 }
3448 return ret;
3449}
3450
Harald Weltea63b9102018-03-22 20:36:16 +01003451private function f_rsl_chmod_tmpl_from_codec(BSSMAP_FIELD_CodecElement a_elem)
3452return template RSL_IE_Body {
3453 var template RSL_IE_Body mode_ie := {
3454 chan_mode := {
3455 len := ?,
3456 reserved := ?,
3457 dtx_d := ?,
3458 dtx_u := ?,
3459 spd_ind := RSL_SPDI_SPEECH,
3460 ch_rate_type := -,
3461 coding_alg_rate := -
3462 }
3463 }
3464
3465 select (a_elem.codecType) {
3466 case (GSM_FR) {
3467 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_F;
3468 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM1;
3469 }
3470 case (GSM_HR) {
3471 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_H;
3472 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM1;
3473 }
3474 case (GSM_EFR) {
3475 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_F;
3476 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM2;
3477 }
3478 case (FR_AMR) {
3479 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_F;
3480 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM3;
3481 }
3482 case (HR_AMR) {
3483 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_H;
3484 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM3;
3485 }
3486 }
3487 return mode_ie;
3488}
3489
Harald Welte60aa5762018-03-21 19:33:13 +01003490type record CodecListTest {
3491 BSSMAP_IE_SpeechCodecList codec_list,
3492 charstring id
3493}
3494type record of CodecListTest CodecListTests
3495
3496private function f_TC_assignment_codec(charstring id) runs on MSC_ConnHdlr {
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02003497 var PDU_BSSAP ass_cmd := f_gen_ass_req(g_pars.use_osmux);
3498 var template PDU_BSSAP exp_compl := f_gen_exp_compl(g_pars.use_osmux);
Harald Welte60aa5762018-03-21 19:33:13 +01003499
3500 /* puzzle together the ASSIGNMENT REQ for given codec[s] */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003501 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
Harald Welte79f3f542018-05-25 20:02:37 +02003502 ass_cmd.pdu.bssmap.assignmentRequest.codecList := g_pars.ass_codec_list;
3503 exp_compl.pdu.bssmap.assignmentComplete.speechCodec.codecElements[0] :=
3504 g_pars.ass_codec_list.codecElements[0];
Philipp Maierd0e64b02019-03-13 14:15:23 +01003505 if (isvalue(g_pars.expect_mr_s0_s7)) {
3506 exp_compl.pdu.bssmap.assignmentComplete.speechCodec.codecElements[0].s0_7 :=
3507 g_pars.expect_mr_s0_s7;
3508 }
Harald Welte79f3f542018-05-25 20:02:37 +02003509 }
Harald Welte60aa5762018-03-21 19:33:13 +01003510 ass_cmd.pdu.bssmap.assignmentRequest.channelType :=
3511 f_BSSMAP_chtype_from_codec(g_pars.ass_codec_list.codecElements[0]);
Harald Welte60aa5762018-03-21 19:33:13 +01003512 log("expecting ASS COMPL like this: ", exp_compl);
3513
3514 f_establish_fully(ass_cmd, exp_compl);
Harald Weltea63b9102018-03-22 20:36:16 +01003515
3516 /* Verify that the RSL-side activation actually matches our expectations */
3517 var RSL_Message rsl := f_rslem_get_last_act(RSL_PROC, 0, g_chan_nr);
3518
3519 var RSL_IE_Body mode_ie;
3520 if (f_rsl_find_ie(rsl, RSL_IE_CHAN_MODE, mode_ie) == false) {
3521 setverdict(fail, "Couldn't find CHAN_MODE IE");
Daniel Willmannafce8662018-07-06 23:11:32 +02003522 mtc.stop;
Harald Weltea63b9102018-03-22 20:36:16 +01003523 }
3524 var template RSL_IE_Body t_mode_ie := f_rsl_chmod_tmpl_from_codec(g_pars.ass_codec_list.codecElements[0]);
3525 if (not match(mode_ie, t_mode_ie)) {
3526 setverdict(fail, "RSL Channel Mode IE doesn't match expectation");
3527 }
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02003528
3529 var RSL_IE_Body mr_conf;
3530 if (g_pars.expect_mr_conf_ie != omit) {
3531 if (f_rsl_find_ie(rsl, RSL_IE_MR_CONFIG, mr_conf) == false) {
3532 setverdict(fail, "Missing MR CONFIG IE in RSL Chan Activ");
Daniel Willmannafce8662018-07-06 23:11:32 +02003533 mtc.stop;
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02003534 }
3535 log("found RSL MR CONFIG IE: ", mr_conf);
3536
3537 if (not match(mr_conf, g_pars.expect_mr_conf_ie)) {
3538 setverdict(fail, "RSL MR CONFIG IE does not match expectation. Expected: ",
3539 g_pars.expect_mr_conf_ie);
3540 }
3541 } else {
3542 if (f_rsl_find_ie(rsl, RSL_IE_MR_CONFIG, mr_conf) == true) {
3543 log("found RSL MR CONFIG IE: ", mr_conf);
3544 setverdict(fail, "Found MR CONFIG IE in RSL Chan Activ, expecting omit");
Daniel Willmannafce8662018-07-06 23:11:32 +02003545 mtc.stop;
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02003546 }
3547 }
Harald Welte60aa5762018-03-21 19:33:13 +01003548}
3549
Philipp Maierd0e64b02019-03-13 14:15:23 +01003550private function f_TC_assignment_codec_fail(charstring id) runs on MSC_ConnHdlr {
3551
3552 var PDU_BSSAP ass_cmd := f_gen_ass_req();
3553 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
3554
3555 /* puzzle together the ASSIGNMENT REQ for given codec[s] */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003556 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
Philipp Maierd0e64b02019-03-13 14:15:23 +01003557 ass_cmd.pdu.bssmap.assignmentRequest.codecList := g_pars.ass_codec_list;
3558 }
3559 ass_cmd.pdu.bssmap.assignmentRequest.channelType :=
3560 f_BSSMAP_chtype_from_codec(g_pars.ass_codec_list.codecElements[0]);
3561 log("expecting ASS FAIL like this: ", exp_fail);
3562
3563 f_establish_fully(ass_cmd, exp_fail);
3564}
3565
Harald Welte60aa5762018-03-21 19:33:13 +01003566testcase TC_assignment_codec_fr() runs on test_CT {
Philipp Maier48604732018-10-09 15:00:37 +02003567 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte60aa5762018-03-21 19:33:13 +01003568 var MSC_ConnHdlr vc_conn;
3569
3570 f_init(1, true);
3571 f_sleep(1.0);
3572
3573 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
Harald Welte8863fa12018-05-10 20:15:27 +02003574 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01003575 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003576 f_shutdown_helper();
Harald Welte60aa5762018-03-21 19:33:13 +01003577}
3578
3579testcase TC_assignment_codec_hr() runs on test_CT {
Philipp Maier48604732018-10-09 15:00:37 +02003580 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte60aa5762018-03-21 19:33:13 +01003581 var MSC_ConnHdlr vc_conn;
3582
3583 f_init(1, true);
3584 f_sleep(1.0);
3585
3586 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR}));
Harald Welte8863fa12018-05-10 20:15:27 +02003587 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01003588 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003589 f_shutdown_helper();
Harald Welte60aa5762018-03-21 19:33:13 +01003590}
3591
3592testcase TC_assignment_codec_efr() runs on test_CT {
Philipp Maier48604732018-10-09 15:00:37 +02003593 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte60aa5762018-03-21 19:33:13 +01003594 var MSC_ConnHdlr vc_conn;
3595
3596 f_init(1, true);
3597 f_sleep(1.0);
3598
3599 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecEFR}));
Harald Welte8863fa12018-05-10 20:15:27 +02003600 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01003601 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003602 f_shutdown_helper();
Harald Welte60aa5762018-03-21 19:33:13 +01003603}
3604
Philipp Maierd0e64b02019-03-13 14:15:23 +01003605/* Allow 5,90k only (current default config) */
3606private function f_allow_amr_rate_5_90k() runs on test_CT {
3607 f_vty_enter_cfg_msc(BSCVTY, 0);
3608 f_vty_transceive(BSCVTY, "amr-config 12_2k forbidden");
3609 f_vty_transceive(BSCVTY, "amr-config 10_2k forbidden");
3610 f_vty_transceive(BSCVTY, "amr-config 7_95k forbidden");
3611 f_vty_transceive(BSCVTY, "amr-config 7_40k forbidden");
3612 f_vty_transceive(BSCVTY, "amr-config 6_70k forbidden");
3613 f_vty_transceive(BSCVTY, "amr-config 5_90k allowed");
3614 f_vty_transceive(BSCVTY, "amr-config 5_15k forbidden");
3615 f_vty_transceive(BSCVTY, "amr-config 4_75k forbidden");
3616 f_vty_transceive(BSCVTY, "exit");
3617 f_vty_transceive(BSCVTY, "exit");
3618}
3619
3620/* Allow 4,75k, 5,90k, 4,70k and 12,2k, which are the most common rates
3621 * ("Config-NB-Code = 1") */
3622private function f_allow_amr_rate_4_75k_5_90k_7_40k_12_20k() runs on test_CT {
3623 f_vty_enter_cfg_msc(BSCVTY, 0);
3624 f_vty_transceive(BSCVTY, "amr-config 12_2k allowed");
3625 f_vty_transceive(BSCVTY, "amr-config 10_2k forbidden");
3626 f_vty_transceive(BSCVTY, "amr-config 7_95k forbidden");
3627 f_vty_transceive(BSCVTY, "amr-config 7_40k allowed");
3628 f_vty_transceive(BSCVTY, "amr-config 6_70k forbidden");
3629 f_vty_transceive(BSCVTY, "amr-config 5_90k allowed");
3630 f_vty_transceive(BSCVTY, "amr-config 5_15k forbidden");
3631 f_vty_transceive(BSCVTY, "amr-config 4_75k allowed");
3632 f_vty_transceive(BSCVTY, "exit");
3633 f_vty_transceive(BSCVTY, "exit");
3634}
3635
Harald Welte60aa5762018-03-21 19:33:13 +01003636testcase TC_assignment_codec_amr_f() runs on test_CT {
Philipp Maier48604732018-10-09 15:00:37 +02003637 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte60aa5762018-03-21 19:33:13 +01003638 var MSC_ConnHdlr vc_conn;
Philipp Maier7695a0d2018-09-27 17:52:14 +02003639
3640 /* Note: This setups the codec configuration. The parameter payload in
3641 * mr_conf must be consistant with the parameter codecElements in pars
3642 * and also must match the amr-config in osmo-bsc.cfg! */
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02003643 var RSL_IE_Body mr_conf := {
3644 other := {
3645 len := 2,
3646 payload := '2804'O
3647 }
3648 };
Harald Welte60aa5762018-03-21 19:33:13 +01003649
Philipp Maier7695a0d2018-09-27 17:52:14 +02003650 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_F}));
Philipp Maier806f8f12019-03-12 12:13:41 +01003651 pars.ass_codec_list.codecElements[0].s0_7 := '00000100'B; /* 5,90k */
Philipp Maier7695a0d2018-09-27 17:52:14 +02003652 pars.ass_codec_list.codecElements[0].s8_15 := '01010111'B;
3653 pars.expect_mr_conf_ie := mr_conf;
3654
Harald Welte60aa5762018-03-21 19:33:13 +01003655 f_init(1, true);
3656 f_sleep(1.0);
3657
Harald Welte8863fa12018-05-10 20:15:27 +02003658 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01003659 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003660 f_shutdown_helper();
Harald Welte60aa5762018-03-21 19:33:13 +01003661}
3662
3663testcase TC_assignment_codec_amr_h() runs on test_CT {
Philipp Maier48604732018-10-09 15:00:37 +02003664 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte60aa5762018-03-21 19:33:13 +01003665 var MSC_ConnHdlr vc_conn;
Philipp Maier7695a0d2018-09-27 17:52:14 +02003666
3667 /* See note above */
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02003668 var RSL_IE_Body mr_conf := {
3669 other := {
3670 len := 2,
3671 payload := '2804'O
3672 }
3673 };
Harald Welte60aa5762018-03-21 19:33:13 +01003674
Philipp Maier7695a0d2018-09-27 17:52:14 +02003675 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_H}));
Philipp Maier806f8f12019-03-12 12:13:41 +01003676 pars.ass_codec_list.codecElements[0].s0_7 := '00000100'B; /* 5,90k */
Philipp Maier7695a0d2018-09-27 17:52:14 +02003677 pars.ass_codec_list.codecElements[0].s8_15 := '00000111'B;
3678 pars.expect_mr_conf_ie := mr_conf;
3679
Harald Welte60aa5762018-03-21 19:33:13 +01003680 f_init(1, true);
3681 f_sleep(1.0);
3682
Harald Welte8863fa12018-05-10 20:15:27 +02003683 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01003684 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003685 f_shutdown_helper();
Harald Welte60aa5762018-03-21 19:33:13 +01003686}
3687
Philipp Maierd0e64b02019-03-13 14:15:23 +01003688function f_TC_assignment_codec_amr(boolean fr, octetstring mrconf, bitstring s8_s0, bitstring exp_s8_s0)
3689runs on test_CT {
3690
3691 var TestHdlrParams pars := f_gen_test_hdlr_pars();
3692 var MSC_ConnHdlr vc_conn;
3693
3694 /* See note above */
3695 var RSL_IE_Body mr_conf := {
3696 other := {
3697 len := lengthof(mrconf),
3698 payload := mrconf
3699 }
3700 };
3701
3702 if (fr) {
3703 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_F}));
3704 } else {
3705 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_H}));
3706 }
3707 pars.ass_codec_list.codecElements[0].s0_7 := s8_s0;
3708 pars.ass_codec_list.codecElements[0].s8_15 := '00000111'B;
3709 pars.expect_mr_conf_ie := mr_conf;
3710 pars.expect_mr_s0_s7 := exp_s8_s0;
3711
3712 f_init(1, true);
3713 f_allow_amr_rate_4_75k_5_90k_7_40k_12_20k();
3714 f_sleep(1.0);
3715
3716 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
3717 vc_conn.done;
3718 f_allow_amr_rate_5_90k();
3719}
3720
3721function f_TC_assignment_codec_amr_fail(boolean fr, bitstring s8_s0)
3722runs on test_CT {
3723
3724 var TestHdlrParams pars := f_gen_test_hdlr_pars();
3725 var MSC_ConnHdlr vc_conn;
3726
3727 if (fr) {
3728 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_F}));
3729 } else {
3730 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_H}));
3731 }
3732 pars.ass_codec_list.codecElements[0].s0_7 := s8_s0;
3733 pars.ass_codec_list.codecElements[0].s8_15 := '00000111'B;
3734
3735 f_init(1, true);
3736 f_allow_amr_rate_4_75k_5_90k_7_40k_12_20k();
3737 f_sleep(1.0);
3738
3739 vc_conn := f_start_handler(refers(f_TC_assignment_codec_fail), pars);
3740 vc_conn.done;
3741 f_allow_amr_rate_5_90k();
3742}
3743
3744
3745/* Set S1, we expect an AMR multirate configuration IE with all four rates
3746 * set. */
3747testcase TC_assignment_codec_amr_f_S1() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003748 f_TC_assignment_codec_amr(true, '289520882208'O, '00000010'B, '00000010'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003749 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003750}
3751
3752/* Set S1, we expect an AMR multirate configuration IE with the lower three
3753 * rates set. */
3754testcase TC_assignment_codec_amr_h_S1() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003755 f_TC_assignment_codec_amr(false, '2815208820'O, '00000010'B, '00000010'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003756 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003757}
3758
3759/* Set S1 and two other rates, we expect an AMR MULTIRATE CONFIGURATION IE with
3760 * all four rates (and only S1 set in the ASSIGNMENT COMPLETE) */
3761testcase TC_assignment_codec_amr_f_S124() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003762 f_TC_assignment_codec_amr(true, '289520882208'O, '00010110'B, '00000010'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003763 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003764}
3765
3766/* Set S1 and two other rates, we expect an AMR MULTIRATE CONFIGURATION IE with
3767 * all four rates (and only S1 set in the ASSIGNMENT COMPLETE) */
3768testcase TC_assignment_codec_amr_h_S124() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003769 f_TC_assignment_codec_amr(false, '2815208820'O, '00010110'B, '00000010'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003770 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003771}
3772
3773/* The following block of tests selects more and more rates until all four
3774 * possible rates are in the active set (full rate) */
3775testcase TC_assignment_codec_amr_f_S0() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003776 f_TC_assignment_codec_amr(true, '2801'O, '00000001'B, '00000001'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003777 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003778}
3779
3780testcase TC_assignment_codec_amr_f_S02() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003781 f_TC_assignment_codec_amr(true, '28052080'O, '00000101'B, '00000101'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003782 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003783}
3784
3785testcase TC_assignment_codec_amr_f_S024() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003786 f_TC_assignment_codec_amr(true, '2815208820'O, '00010101'B, '00010101'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003787 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003788}
3789
3790testcase TC_assignment_codec_amr_f_S0247() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003791 f_TC_assignment_codec_amr(true, '289520882208'O, '10010101'B, '10010101'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003792 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003793}
3794
3795/* The following block of tests selects more and more rates until all three
3796 * possible rates are in the active set (half rate) */
3797testcase TC_assignment_codec_amr_h_S0() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003798 f_TC_assignment_codec_amr(false, '2801'O, '00000001'B, '00000001'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003799 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003800}
3801
3802testcase TC_assignment_codec_amr_h_S02() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003803 f_TC_assignment_codec_amr(false, '28052080'O, '00000101'B, '00000101'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003804 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003805}
3806
3807testcase TC_assignment_codec_amr_h_S024() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003808 f_TC_assignment_codec_amr(false, '2815208820'O, '00010101'B, '00010101'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003809 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003810}
3811
3812/* The following block tests what happens when the MSC does offer rate
3813 * configurations that are not supported by the BSC. Normally such situations
3814 * should not happen because the MSC gets informed by the BSC in advance via
3815 * the L3 COMPLETE message which rates are applicable. The MSC should not try
3816 * to offer rates that are not applicable anyway. */
3817
3818testcase TC_assignment_codec_amr_h_S0247() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003819 /* Try to include 12,2k in into the active set even though the channel
3820 * is half rate only. The BSC is expected to remove the 12,0k */
3821 f_TC_assignment_codec_amr(false, '2815208820'O, '10010101'B, '00010101'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003822 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003823}
3824
3825testcase TC_assignment_codec_amr_f_S01234567() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003826 /* See what happens when all rates are selected at once. Since then
3827 * Also S1 is selected, this setting will be prefered and we should
3828 * get 12.2k, 7,40k, 5,90k, and 4,75k in the active set. */
3829 f_TC_assignment_codec_amr(true, '289520882208'O, '11111111'B, '00000010'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003830 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003831}
3832
3833testcase TC_assignment_codec_amr_f_S0234567() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003834 /* Same as above, but with S1 missing, the MSC is then expected to
3835 * select the currently supported rates, which are also 12.2k, 7,40k,
3836 * 5,90k, and 4,75k, into the active set. */
3837 f_TC_assignment_codec_amr(true, '289520882208'O, '11111101'B, '10010101'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003838 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003839}
3840
3841testcase TC_assignment_codec_amr_f_zero() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003842 /* Try to select no rates at all */
3843 f_TC_assignment_codec_amr_fail(true, '00000000'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_unsupp() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003848 /* Try to select only unsupported rates */
3849 f_TC_assignment_codec_amr_fail(true, '01101000'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003850 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003851}
3852
3853testcase TC_assignment_codec_amr_h_S7() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003854 /* Try to select 12,2k for half rate */
3855 f_TC_assignment_codec_amr_fail(false, '10000000'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003856 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003857}
3858
Philipp Maierac09bfc2019-01-08 13:41:39 +01003859private function f_disable_all_tch_f() runs on test_CT {
Philipp Maierc704a882019-01-29 15:58:52 +01003860 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 1 sub-slot 0 borken");
3861 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 2 sub-slot 0 borken");
3862 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 3 sub-slot 0 borken");
3863 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 4 sub-slot 0 borken");
Philipp Maierac09bfc2019-01-08 13:41:39 +01003864}
3865
3866private function f_disable_all_tch_h() runs on test_CT {
Philipp Maierc704a882019-01-29 15:58:52 +01003867 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 5 sub-slot 0 borken");
3868 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 5 sub-slot 1 borken");
Philipp Maierac09bfc2019-01-08 13:41:39 +01003869}
3870
3871private function f_enable_all_tch() runs on test_CT {
Philipp Maierc704a882019-01-29 15:58:52 +01003872 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 1 sub-slot 0 unused");
3873 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 2 sub-slot 0 unused");
3874 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 3 sub-slot 0 unused");
3875 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 4 sub-slot 0 unused");
3876 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 5 sub-slot 0 unused");
3877 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 5 sub-slot 1 unused");
Philipp Maierac09bfc2019-01-08 13:41:39 +01003878}
3879
3880/* Allow HR only */
3881private function f_TC_assignment_codec_xr_exhausted_req_hr(charstring id) runs on MSC_ConnHdlr {
3882 g_pars := f_gen_test_hdlr_pars();
3883 var PDU_BSSAP ass_cmd := f_gen_ass_req();
3884 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3885 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3886 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '09'O;
3887 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '05'O;
3888 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR}));
3889 f_establish_fully(ass_cmd, exp_compl);
3890}
3891
3892/* Allow FR only */
3893private function f_TC_assignment_codec_xr_exhausted_req_fr(charstring id) runs on MSC_ConnHdlr {
3894 g_pars := f_gen_test_hdlr_pars();
3895 var PDU_BSSAP ass_cmd := f_gen_ass_req();
3896 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3897 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3898 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '08'O;
3899 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '01'O;
3900 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
3901 f_establish_fully(ass_cmd, exp_compl);
3902}
3903
3904/* Allow HR only (expect assignment failure) */
3905private function f_TC_assignment_codec_xr_exhausted_req_hr_fail(charstring id) runs on MSC_ConnHdlr {
3906 g_pars := f_gen_test_hdlr_pars();
3907 var PDU_BSSAP ass_cmd := f_gen_ass_req();
3908 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
3909 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3910 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '09'O;
3911 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '05'O;
3912 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR}));
3913 f_establish_fully(ass_cmd, exp_fail);
3914}
3915
3916/* Allow FR only (expect assignment failure) */
3917private function f_TC_assignment_codec_xr_exhausted_req_fr_fail(charstring id) runs on MSC_ConnHdlr {
3918 g_pars := f_gen_test_hdlr_pars();
3919 var PDU_BSSAP ass_cmd := f_gen_ass_req();
3920 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
3921 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3922 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '08'O;
3923 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '01'O;
3924 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
3925 f_establish_fully(ass_cmd, exp_fail);
3926}
3927
3928/* Allow FR and HR, but prefer FR */
3929private function f_TC_assignment_codec_fr_exhausted_req_fr_hr(charstring id) runs on MSC_ConnHdlr {
3930 g_pars := f_gen_test_hdlr_pars();
3931 var PDU_BSSAP ass_cmd := f_gen_ass_req();
3932 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3933 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3934 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0A'O; /* Prefer FR */
3935 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8105'O;
3936 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR, ts_CodecHR}));
3937 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000101'B; /* Expect HR */
3938 f_establish_fully(ass_cmd, exp_compl);
3939}
3940
3941/* Allow FR and HR, but prefer HR */
3942private function f_TC_assignment_codec_fr_exhausted_req_hr_fr(charstring id) runs on MSC_ConnHdlr {
3943 g_pars := f_gen_test_hdlr_pars();
3944 var PDU_BSSAP ass_cmd := f_gen_ass_req();
3945 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3946 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3947 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0B'O; /* Prefer HR */
3948 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8501'O;
3949 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR, ts_CodecFR}));
3950 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000101'B; /* Expect HR */
3951 f_establish_fully(ass_cmd, exp_compl);
3952}
3953
3954/* Allow FR and HR, but prefer FR */
3955private function f_TC_assignment_codec_hr_exhausted_req_fr_hr(charstring id) runs on MSC_ConnHdlr {
3956 g_pars := f_gen_test_hdlr_pars();
3957 var PDU_BSSAP ass_cmd := f_gen_ass_req();
3958 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3959 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3960 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0A'O; /* Prefer FR */
3961 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8105'O;
3962 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR, ts_CodecHR}));
3963 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000001'B; /* Expect FR */
3964 f_establish_fully(ass_cmd, exp_compl);
3965}
3966
3967/* Allow FR and HR, but prefer HR */
3968private function f_TC_assignment_codec_hr_exhausted_req_hr_fr(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 := '0B'O; /* Prefer HR */
3974 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8501'O;
3975 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR, ts_CodecFR}));
3976 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000001'B; /* Expect FR */
3977 f_establish_fully(ass_cmd, exp_compl);
3978}
3979
3980/* Request a HR channel while all FR channels are exhausted, this is expected
3981 * to work without conflicts */
3982testcase TC_assignment_codec_fr_exhausted_req_hr() runs on test_CT {
3983 var MSC_ConnHdlr vc_conn;
3984 f_init(1, true);
3985 f_sleep(1.0);
3986 f_enable_all_tch();
3987 f_disable_all_tch_f();
3988 vc_conn := f_start_handler(refers(f_TC_assignment_codec_xr_exhausted_req_hr));
3989 vc_conn.done;
3990 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003991 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01003992}
3993
3994/* Request a FR channel while all FR channels are exhausted, this is expected
3995 * to fail. */
3996testcase TC_assignment_codec_fr_exhausted_req_fr() runs on test_CT {
3997 var MSC_ConnHdlr vc_conn;
3998 f_init(1, true);
3999 f_sleep(1.0);
4000 f_enable_all_tch();
4001 f_disable_all_tch_f();
4002 vc_conn := f_start_handler(refers(f_TC_assignment_codec_xr_exhausted_req_fr_fail));
4003 vc_conn.done;
4004 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004005 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004006}
4007
4008/* Request a FR (prefered) or alternatively a HR channel while all FR channels
4009 * are exhausted, this is expected to be resolved by selecting a HR channel. */
4010testcase TC_assignment_codec_fr_exhausted_req_fr_hr() runs on test_CT {
4011 var MSC_ConnHdlr vc_conn;
4012 f_init(1, true);
4013 f_sleep(1.0);
4014 f_enable_all_tch();
4015 f_disable_all_tch_f();
4016 vc_conn := f_start_handler(refers(f_TC_assignment_codec_fr_exhausted_req_fr_hr));
4017 vc_conn.done;
4018 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004019 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004020}
4021
4022/* Request a HR (prefered) or alternatively a FR channel while all FR channels
4023 * are exhausted, this is expected to work without conflicts. */
4024testcase TC_assignment_codec_fr_exhausted_req_hr_fr() runs on test_CT {
4025 var MSC_ConnHdlr vc_conn;
4026 f_init(1, true);
4027 f_sleep(1.0);
4028 f_enable_all_tch();
4029 f_disable_all_tch_f();
4030 vc_conn := f_start_handler(refers(f_TC_assignment_codec_fr_exhausted_req_hr_fr));
4031 vc_conn.done;
4032 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004033 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004034}
4035
4036/* Request a FR channel while all HR channels are exhausted, this is expected
4037 * to work without conflicts */
4038testcase TC_assignment_codec_hr_exhausted_req_fr() runs on test_CT {
4039 var MSC_ConnHdlr vc_conn;
4040 f_init(1, true);
4041 f_sleep(1.0);
4042 f_enable_all_tch();
4043 f_disable_all_tch_h();
4044 vc_conn := f_start_handler(refers(f_TC_assignment_codec_xr_exhausted_req_fr));
4045 vc_conn.done;
4046 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004047 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004048}
4049
4050/* Request a HR channel while all HR channels are exhausted, this is expected
4051 * to fail. */
4052testcase TC_assignment_codec_hr_exhausted_req_hr() runs on test_CT {
4053 var MSC_ConnHdlr vc_conn;
4054 f_init(1, true);
4055 f_sleep(1.0);
4056 f_enable_all_tch();
4057 f_disable_all_tch_h();
4058 vc_conn := f_start_handler(refers(f_TC_assignment_codec_xr_exhausted_req_hr_fail));
4059 vc_conn.done;
4060 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004061 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004062}
4063
4064/* Request a HR (prefered) or alternatively a FR channel while all HR channels
4065 * are exhausted, this is expected to be resolved by selecting a FR channel. */
4066testcase TC_assignment_codec_hr_exhausted_req_hr_fr() runs on test_CT {
4067 var MSC_ConnHdlr vc_conn;
4068 f_init(1, true);
4069 f_sleep(1.0);
4070 f_enable_all_tch();
4071 f_disable_all_tch_h();
4072 vc_conn := f_start_handler(refers(f_TC_assignment_codec_hr_exhausted_req_hr_fr));
4073 vc_conn.done;
4074 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004075 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004076}
4077
4078/* Request a FR (prefered) or alternatively a HR channel while all HR channels
4079 * are exhausted, this is expected to work without conflicts. */
4080testcase TC_assignment_codec_hr_exhausted_req_fr_hr() runs on test_CT {
4081 var MSC_ConnHdlr vc_conn;
4082 f_init(1, true);
4083 f_sleep(1.0);
4084 f_enable_all_tch();
4085 f_disable_all_tch_h();
4086 vc_conn := f_start_handler(refers(f_TC_assignment_codec_hr_exhausted_req_fr_hr));
4087 vc_conn.done;
4088 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004089 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004090}
4091
4092/* Allow FR and HR, but prefer HR */
4093private function f_TC_assignment_codec_req_hr_fr(charstring id) runs on MSC_ConnHdlr {
4094 g_pars := f_gen_test_hdlr_pars();
4095 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4096 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4097 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4098 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0B'O; /* Prefer HR */
4099 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8501'O;
4100 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR, ts_CodecFR}));
4101 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000101'B; /* Expect HR */
4102 f_establish_fully(ass_cmd, exp_compl);
4103}
4104
4105/* Allow FR and HR, but prefer FR */
4106private function f_TC_assignment_codec_req_fr_hr(charstring id) runs on MSC_ConnHdlr {
4107 g_pars := f_gen_test_hdlr_pars();
4108 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4109 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4110 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4111 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0A'O; /* Prefer FR */
4112 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8105'O;
4113 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR, ts_CodecHR}));
4114 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000001'B; /* Expect FR */
4115 f_establish_fully(ass_cmd, exp_compl);
4116}
4117
4118/* Request a HR (prefered) or alternatively a FR channel, it is expected that
4119 * HR, which is the prefered type, is selected. */
4120testcase TC_assignment_codec_req_hr_fr() runs on test_CT {
4121 var MSC_ConnHdlr vc_conn;
4122 f_init(1, true);
4123 f_sleep(1.0);
4124 f_enable_all_tch();
4125 vc_conn := f_start_handler(refers(f_TC_assignment_codec_req_hr_fr));
4126 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004127 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004128}
4129
4130/* Request a FR (prefered) or alternatively a HR channel, it is expected that
4131 * FR, which is the prefered type, is selected. */
4132testcase TC_assignment_codec_req_fr_hr() runs on test_CT {
4133 var MSC_ConnHdlr vc_conn;
4134 f_init(1, true);
4135 f_sleep(1.0);
4136 f_enable_all_tch();
4137 vc_conn := f_start_handler(refers(f_TC_assignment_codec_req_fr_hr));
4138 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004139 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004140}
4141
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02004142testcase TC_assignment_osmux() runs on test_CT {
4143 var TestHdlrParams pars := f_gen_test_hdlr_pars();
4144 var MSC_ConnHdlr vc_conn;
4145
4146 /* See note above */
4147 var RSL_IE_Body mr_conf := {
4148 other := {
4149 len := 2,
4150 payload := '2804'O
4151 }
4152 };
4153
4154 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_H}));
4155 pars.ass_codec_list.codecElements[0].s0_7 := '00000100'B; /* 5,90k */
4156 pars.ass_codec_list.codecElements[0].s8_15 := '00000111'B;
4157 pars.expect_mr_conf_ie := mr_conf;
4158 pars.use_osmux := true;
4159
4160 f_init(1, true, true);
4161 f_sleep(1.0);
4162
4163 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
4164 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004165 f_shutdown_helper();
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02004166}
4167
Neels Hofmeyr92b12b72018-09-18 14:30:23 +02004168/* test the procedure of the MSC requesting a Classmark Update:
4169 * a) BSSMAP Classmark Request should result in RR CLASSMARK ENQUIRY,
4170 * b) L3 RR CLASSMARK CHANGE should result in BSSMAP CLASSMARK UPDATE */
Harald Welte898113b2018-01-31 18:32:21 +01004171private function f_tc_classmark(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02004172 g_pars := f_gen_test_hdlr_pars();
4173
Harald Weltea0630032018-03-20 21:09:55 +01004174 f_create_chan_and_exp();
Harald Welte898113b2018-01-31 18:32:21 +01004175 /* we should now have a COMPL_L3 at the MSC */
4176 BSSAP.receive(tr_BSSMAP_ComplL3);
4177
Neels Hofmeyr92b12b72018-09-18 14:30:23 +02004178 BSSAP.send(ts_BSSMAP_ClassmarkRequest);
4179 RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_CM_ENQUIRY));
4180
Harald Welte898113b2018-01-31 18:32:21 +01004181 f_rsl_send_l3(ts_RRM_CM_CHG(valueof(ts_CM2)));
4182 BSSAP.receive(tr_BSSMAP_ClassmarkUpd(?, omit));
4183 setverdict(pass);
4184}
4185testcase TC_classmark() runs on test_CT {
4186 var MSC_ConnHdlr vc_conn;
4187 f_init(1, true);
4188 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02004189 vc_conn := f_start_handler(refers(f_tc_classmark));
Harald Welte898113b2018-01-31 18:32:21 +01004190 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004191 f_shutdown_helper();
Harald Welte898113b2018-01-31 18:32:21 +01004192}
4193
Harald Welteeddf0e92020-06-21 19:42:15 +02004194/* Send a CommonID from the simulated MSC and verify that the information is used to
4195 * fill BSC-internal data structures (specifically, bsc_subscr associated with subscr_conn) */
4196private function f_tc_common_id(charstring id) runs on MSC_ConnHdlr {
4197 g_pars := f_gen_test_hdlr_pars();
4198 f_MscConnHdlr_init_vty();
4199
4200 f_create_chan_and_exp();
4201 /* we should now have a COMPL_L3 at the MSC */
4202 BSSAP.receive(tr_BSSMAP_ComplL3);
4203
4204 /* Send CommonID */
4205 BSSAP.send(ts_BSSMAP_CommonId(g_pars.imsi));
4206
4207 /* Use VTY to verify that the IMSI of the subscr_conn is set */
4208 var charstring regex := "*(IMSI: " & hex2str(g_pars.imsi) & ")*";
4209 f_vty_transceive_match_regexp_retry(BSCVTY, "show conns", regex, 0, 4, 1.0);
4210
4211 setverdict(pass);
4212}
4213testcase TC_common_id() runs on test_CT {
4214 var MSC_ConnHdlr vc_conn;
4215 f_init(1, true);
4216 f_sleep(1.0);
4217 vc_conn := f_start_handler(refers(f_tc_common_id));
4218 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004219 f_shutdown_helper();
Harald Welteeddf0e92020-06-21 19:42:15 +02004220}
4221
Harald Weltee3bd6582018-01-31 22:51:25 +01004222private function f_est_single_l3(template PDU_ML3_MS_NW l3) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02004223 g_pars := f_gen_test_hdlr_pars();
Harald Weltea0630032018-03-20 21:09:55 +01004224 f_create_chan_and_exp();
Harald Welte898113b2018-01-31 18:32:21 +01004225 /* we should now have a COMPL_L3 at the MSC */
4226 BSSAP.receive(tr_BSSMAP_ComplL3);
4227
Harald Weltee3bd6582018-01-31 22:51:25 +01004228 /* send the single message we want to send */
4229 f_rsl_send_l3(l3);
4230}
4231
4232private function f_bssap_expect_nothing(float sec := 5.00) runs on MSC_ConnHdlr {
4233 timer T := sec;
4234 var PDU_BSSAP bssap;
Harald Welte898113b2018-01-31 18:32:21 +01004235 T.start;
4236 alt {
Harald Weltee3bd6582018-01-31 22:51:25 +01004237 [] BSSAP.receive(PDU_BSSAP:?) -> value bssap {
4238 setverdict(fail, "Unexpected BSSMAP ", bssap);
Daniel Willmannafce8662018-07-06 23:11:32 +02004239 mtc.stop;
Harald Welte898113b2018-01-31 18:32:21 +01004240 }
4241 [] T.timeout {
4242 setverdict(pass);
4243 }
4244 }
4245}
4246
Harald Weltee3bd6582018-01-31 22:51:25 +01004247/* unsolicited ASSIGNMENT FAIL (without ASSIGN) from MS shouldn't bring BSC down */
4248private function f_tc_unsol_ass_fail(charstring id) runs on MSC_ConnHdlr {
4249 f_est_single_l3(ts_RRM_AssignmentFailure('00'O));
4250 f_bssap_expect_nothing();
4251}
Harald Welte898113b2018-01-31 18:32:21 +01004252testcase TC_unsol_ass_fail() runs on test_CT {
4253 var MSC_ConnHdlr vc_conn;
4254 f_init(1, true);
4255 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02004256 vc_conn := f_start_handler(refers(f_tc_unsol_ass_fail));
Harald Welte898113b2018-01-31 18:32:21 +01004257 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004258 f_shutdown_helper();
Harald Welte898113b2018-01-31 18:32:21 +01004259}
Harald Welte552620d2017-12-16 23:21:36 +01004260
Harald Welteea99a002018-01-31 20:46:43 +01004261
4262/* unsolicited ASSIGNMENT COMPLETE (without ASSIGN) from MS shouldn't bring BSC down */
4263private function f_tc_unsol_ass_compl(charstring id) runs on MSC_ConnHdlr {
Harald Weltee3bd6582018-01-31 22:51:25 +01004264 f_est_single_l3(ts_RRM_AssignmentComplete('00'O));
4265 f_bssap_expect_nothing();
Harald Welteea99a002018-01-31 20:46:43 +01004266}
4267testcase TC_unsol_ass_compl() runs on test_CT {
4268 var MSC_ConnHdlr vc_conn;
4269 f_init(1, true);
4270 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02004271 vc_conn := f_start_handler(refers(f_tc_unsol_ass_compl));
Harald Welteea99a002018-01-31 20:46:43 +01004272 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004273 f_shutdown_helper();
Harald Welteea99a002018-01-31 20:46:43 +01004274}
4275
4276
Harald Weltefbf9b5e2018-01-31 20:41:23 +01004277/* unsolicited HANDOVER FAIL (without ASSIGN) from MS shouldn't bring BSC down */
4278private function f_tc_unsol_ho_fail(charstring id) runs on MSC_ConnHdlr {
Harald Weltee3bd6582018-01-31 22:51:25 +01004279 f_est_single_l3(ts_RRM_HandoverFailure('00'O));
4280 f_bssap_expect_nothing();
Harald Weltefbf9b5e2018-01-31 20:41:23 +01004281}
Harald Weltefbf9b5e2018-01-31 20:41:23 +01004282testcase TC_unsol_ho_fail() runs on test_CT {
4283 var MSC_ConnHdlr vc_conn;
4284 f_init(1, true);
4285 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02004286 vc_conn := f_start_handler(refers(f_tc_unsol_ho_fail));
Harald Weltefbf9b5e2018-01-31 20:41:23 +01004287 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004288 f_shutdown_helper();
Harald Weltefbf9b5e2018-01-31 20:41:23 +01004289}
4290
4291
Harald Weltee3bd6582018-01-31 22:51:25 +01004292/* short message from MS should be ignored */
4293private function f_tc_err_82_short_msg(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02004294 g_pars := f_gen_test_hdlr_pars();
Harald Weltea0630032018-03-20 21:09:55 +01004295 f_create_chan_and_exp();
Harald Weltee3bd6582018-01-31 22:51:25 +01004296 /* we should now have a COMPL_L3 at the MSC */
4297 BSSAP.receive(tr_BSSMAP_ComplL3);
4298
4299 /* send short message */
4300 RSL.send(ts_RSL_DATA_IND(g_chan_nr, valueof(ts_RslLinkID_DCCH(0)), ''O));
4301 f_bssap_expect_nothing();
4302}
4303testcase TC_err_82_short_msg() runs on test_CT {
4304 var MSC_ConnHdlr vc_conn;
4305 f_init(1, true);
4306 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02004307 vc_conn := f_start_handler(refers(f_tc_err_82_short_msg));
Harald Weltee3bd6582018-01-31 22:51:25 +01004308 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004309 f_shutdown_helper();
Harald Weltee3bd6582018-01-31 22:51:25 +01004310}
4311
4312
Harald Weltee9e02e42018-01-31 23:36:25 +01004313/* 24.008 8.4 Unknown message must trigger RR STATUS */
4314private function f_tc_err_84_unknown_msg(charstring id) runs on MSC_ConnHdlr {
4315 f_est_single_l3(ts_RRM_UL_REL('00'O));
4316 timer T := 3.0
4317 alt {
4318 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_STATUS)) {
4319 setverdict(pass);
4320 }
4321 [] BSSAP.receive { setverdict(fail, "unexpected BSSAP"); }
Harald Welte458fd372018-03-21 11:26:23 +01004322 [] T.timeout { setverdict(fail, "Timeout waiting for RR STATUS"); }
Harald Weltee9e02e42018-01-31 23:36:25 +01004323 }
4324}
4325testcase TC_err_84_unknown_msg() runs on test_CT {
4326 var MSC_ConnHdlr vc_conn;
4327 f_init(1, true);
4328 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02004329 vc_conn := f_start_handler(refers(f_tc_err_84_unknown_msg));
Harald Weltee9e02e42018-01-31 23:36:25 +01004330 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004331 f_shutdown_helper();
Harald Weltee9e02e42018-01-31 23:36:25 +01004332}
4333
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004334/***********************************************************************
4335 * Handover
4336 ***********************************************************************/
4337
Harald Welte94e0c342018-04-07 11:33:23 +02004338/* execute a "bts <0-255> trx <0-255> timeslot <0-7> " command on given Dchan */
4339private function f_vty_ts_action(charstring suffix, integer bts_nr, integer trx_nr, integer ts_nr)
4340runs on test_CT {
4341 var charstring cmd := "bts "&int2str(bts_nr)&" trx "&int2str(trx_nr)&
4342 " timeslot "&int2str(ts_nr)&" ";
4343 f_vty_transceive(BSCVTY, cmd & suffix);
4344}
4345
Harald Welte261af4b2018-02-12 21:20:39 +01004346/* 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 +07004347private function f_vty_ss_action(TELNETasp_PT pt, charstring suffix,
4348 uint8_t bts_nr, uint8_t trx_nr,
4349 in RslChannelNr chan_nr)
4350{
Harald Welte261af4b2018-02-12 21:20:39 +01004351 /* FIXME: resolve those from component-global state */
4352 var integer ts_nr := chan_nr.tn;
4353 var integer ss_nr;
4354 if (ischosen(chan_nr.u.ch0)) {
4355 ss_nr := 0;
4356 } else if (ischosen(chan_nr.u.lm)) {
4357 ss_nr := chan_nr.u.lm.sub_chan;
4358 } else if (ischosen(chan_nr.u.sdcch4)) {
4359 ss_nr := chan_nr.u.sdcch4.sub_chan;
4360 } else if (ischosen(chan_nr.u.sdcch8)) {
4361 ss_nr := chan_nr.u.sdcch8.sub_chan;
4362 } else {
4363 setverdict(fail, "Invalid ChanNr ", chan_nr);
Daniel Willmannafce8662018-07-06 23:11:32 +02004364 mtc.stop;
Harald Welte261af4b2018-02-12 21:20:39 +01004365 }
4366
4367 var charstring cmd := "bts "&int2str(bts_nr)&" trx "&int2str(trx_nr)&
4368 " timeslot "&int2str(ts_nr)&" sub-slot "&int2str(ss_nr)&" ";
Vadim Yanitskiy00070722020-09-02 17:27:57 +07004369 f_vty_transceive(pt, cmd & suffix);
Harald Welte261af4b2018-02-12 21:20:39 +01004370}
4371
Neels Hofmeyr91401012019-07-11 00:42:35 +02004372/* Even though the VTY command to trigger handover takes a new BTS number as argument, behind the scenes osmo-bsc always
4373 * translates that to a target ARFCN+BSIC first. See bsc_vty.c trigger_ho_or_as(), which puts the selected BTS' neighbor
4374 * ident key (ARFCN + BSIC) in the struct passed on to handover_request(). handover_start() then resolves that to a
4375 * viable actual neighbor cell. So from the internal osmo-bsc perspective, we always request handover to an ARFCN + BSIC
4376 * pair, not really to a specific BTS number. */
Vadim Yanitskiy00070722020-09-02 17:27:57 +07004377private function f_vty_handover(TELNETasp_PT pt, uint8_t bts_nr, uint8_t trx_nr,
4378 in RslChannelNr chan_nr, uint8_t new_bts_nr)
4379{
4380 f_vty_ss_action(pt, "handover " & int2str(new_bts_nr), bts_nr, trx_nr, chan_nr);
Harald Welte261af4b2018-02-12 21:20:39 +01004381}
4382
4383/* intra-BSC hand-over between BTS0 and BTS1 */
4384private function f_tc_ho_int(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02004385 g_pars := f_gen_test_hdlr_pars();
Harald Welteed848512018-05-24 22:27:58 +02004386 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4387 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte261af4b2018-02-12 21:20:39 +01004388 const OCT8 kc := '0001020304050607'O;
4389
4390 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4391 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
4392
Harald Weltea0630032018-03-20 21:09:55 +01004393 f_establish_fully(ass_cmd, exp_compl);
Neels Hofmeyr666f0432020-07-04 00:53:07 +02004394 f_bts_0_cfg(BSCVTY, {"neighbor bts 1"});
Harald Welte261af4b2018-02-12 21:20:39 +01004395
4396 var HandoverState hs := {
4397 rr_ho_cmpl_seen := false,
4398 handover_done := false,
4399 old_chan_nr := -
4400 };
4401 /* issue hand-over command on VTY */
Vadim Yanitskiy00070722020-09-02 17:27:57 +07004402 f_vty_handover(BSCVTY, 0, 0, g_chan_nr, 1);
Harald Welte261af4b2018-02-12 21:20:39 +01004403 /* temporarily suspend DChan processing on BTS1 to avoid race with RSLEM_register */
4404 f_rslem_suspend(RSL1_PROC);
Philipp Maier3e2af5d2018-07-11 17:01:05 +02004405
4406 /* From the MGW perspective, a handover is is characterized by
4407 * performing one MDCX operation with the MGW. So we expect to see
4408 * one more MDCX during handover. */
4409 g_media.mgcp_conn[0].mdcx_seen_exp := g_media.mgcp_conn[0].crcx_seen_exp + 1;
4410
Harald Welte261af4b2018-02-12 21:20:39 +01004411 alt {
4412 [] as_handover(hs);
Harald Welte261af4b2018-02-12 21:20:39 +01004413 }
Philipp Maier3e2af5d2018-07-11 17:01:05 +02004414
Philipp Maier4dae0652018-11-12 12:03:26 +01004415 /* Since this is an internal handover we expect the BSC to inform the
4416 * MSC about the event */
4417 BSSAP.receive(tr_BSSMAP_HandoverPerformed);
4418
Philipp Maier3e2af5d2018-07-11 17:01:05 +02004419 /* Check the amount of MGCP transactions is still consistant with the
4420 * test expectation */
4421 f_check_mgcp_expectations()
Neels Hofmeyr861a4c12018-11-07 01:23:17 +01004422 f_sleep(0.5);
Harald Welte261af4b2018-02-12 21:20:39 +01004423}
4424
4425testcase TC_ho_int() runs on test_CT {
4426 var MSC_ConnHdlr vc_conn;
4427 f_init(2, true);
4428 f_sleep(1.0);
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004429
4430 f_ctrs_bsc_and_bts_init();
4431
Harald Welte8863fa12018-05-10 20:15:27 +02004432 vc_conn := f_start_handler(refers(f_tc_ho_int));
Harald Welte261af4b2018-02-12 21:20:39 +01004433 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004434
4435 /* from f_establish_fully() */
4436 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
4437 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
4438 /* from handover */
4439 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
4440 f_ctrs_bsc_and_bts_add(0, "handover:completed");
4441 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
4442 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:completed");
4443 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004444 f_shutdown_helper();
Harald Welte261af4b2018-02-12 21:20:39 +01004445}
Harald Weltee9e02e42018-01-31 23:36:25 +01004446
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004447/* Expecting MGCP to DLCX the endpoint's two connections: towards BTS and towards MSC */
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02004448private function f_expect_dlcx_conns() runs on MSC_ConnHdlr {
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004449 var MgcpCommand mgcp;
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +02004450 var template MgcpResponse mgcp_resp;
4451 var MGCP_RecvFrom mrf;
4452 var template MgcpMessage msg_resp;
4453 var template MgcpMessage msg_dlcx := {
4454 command := tr_DLCX()
4455 }
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004456
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +02004457 if (g_pars.aoip) {
4458 MGCP.receive(tr_DLCX()) -> value mgcp {
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004459 log("Got first DLCX: ", mgcp);
4460 MGCP.send(ts_DLCX_ACK2(mgcp.line.trans_id));
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +02004461 };
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004462
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004463 MGCP.receive(tr_DLCX()) -> value mgcp {
4464 log("Got second DLCX: ", mgcp);
4465 MGCP.send(ts_DLCX_ACK2(mgcp.line.trans_id));
4466 };
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +02004467 } else {
4468 /* For SCCPLite, BSC doesn't handle the MSC-side */
4469 MGCP_MULTI.receive(tr_MGCP_RecvFrom_any(msg_dlcx)) -> value mrf {
4470 log("Got first DLCX: ", mrf.msg.command);
4471 msg_resp := {
4472 response := ts_DLCX_ACK2(mrf.msg.command.line.trans_id)
4473 }
4474 MGCP_MULTI.send(t_MGCP_SendToMrf(mrf, msg_resp));
4475 };
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004476 }
4477
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02004478 BSSAP.receive(tr_BSSMAP_ClearComplete);
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004479}
4480
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004481private function f_tc_ho_out_of_this_bsc(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02004482 g_pars := f_gen_test_hdlr_pars();
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004483
4484 var PDU_BSSAP ass_req := f_gen_ass_req();
4485 ass_req.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4486 ass_req.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
4487 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4488 f_establish_fully(ass_req, exp_compl);
4489
Neels Hofmeyr666f0432020-07-04 00:53:07 +02004490 f_bts_0_cfg(BSCVTY, {"neighbor lac 99 arfcn 123 bsic any"});
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004491 f_vty_transceive(BSCVTY, "handover any to arfcn 123 bsic any");
4492
4493 BSSAP.receive(tr_BSSMAP_HandoverRequired);
4494
4495 f_sleep(0.5);
4496 /* The MSC negotiates Handover Request and Handover Request Ack with
4497 * the other BSS and comes back with a BSSMAP Handover Command
4498 * containing an RR Handover Command coming from the target BSS... */
4499
4500 var PDU_ML3_NW_MS rr_ho_cmd := valueof(ts_RR_HandoverCommand);
4501 log("Remote cell's RR Handover Command passed through as L3 Info: ", rr_ho_cmd);
4502 var octetstring rr_ho_cmd_enc := enc_PDU_ML3_NW_MS(rr_ho_cmd);
4503 log("Remote cell's RR Handover Command passed through as L3 Info, encoded: ", rr_ho_cmd_enc);
4504 BSSAP.send(ts_BSSMAP_HandoverCommand(rr_ho_cmd_enc));
4505
4506 /* expect the Handover Command to go out on RR */
4507 var RSL_Message rsl_ho_cmd
4508 RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, ?)) -> value rsl_ho_cmd;
4509 log("RSL Data Req went out to first BTS: ", rsl_ho_cmd);
4510 var RSL_IE_Body rsl_ho_cmd_l3;
4511 if (not f_rsl_find_ie(rsl_ho_cmd, RSL_IE_L3_INFO, rsl_ho_cmd_l3)) {
4512 log("RSL message contains no L3 Info IE, expected RR Handover Command");
4513 setverdict(fail);
4514 } else {
4515 log("Found L3 Info: ", rsl_ho_cmd_l3);
4516 if (rsl_ho_cmd_l3.l3_info.payload != rr_ho_cmd_enc) {
4517 log("FAIL: the BSC sent out a different L3 Info, not matching the RR Handover Command the other BSS forwarded.");
4518 setverdict(fail);
4519 } else {
4520 log("Success: the BSC sent out the same RR Handover Command the other BSS forwarded.");
4521 setverdict(pass);
4522 }
4523 }
4524
4525 /* When the other BSS has reported a completed handover, this side is
4526 * torn down. */
4527
4528 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_HANDOVER_SUCCESSFUL;
4529 var BssmapCause cause := enum2int(cause_val);
4530 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
4531
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02004532 f_expect_dlcx_conns();
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004533 setverdict(pass);
4534 f_sleep(1.0);
4535}
4536testcase TC_ho_out_of_this_bsc() runs on test_CT {
4537 var MSC_ConnHdlr vc_conn;
4538
4539 f_init(1, true);
4540 f_sleep(1.0);
4541
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004542 f_ctrs_bsc_and_bts_init();
4543
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004544 vc_conn := f_start_handler(refers(f_tc_ho_out_of_this_bsc));
4545 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004546
4547 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
4548 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
4549 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
4550 f_ctrs_bsc_and_bts_add(0, "handover:completed");
4551 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
4552 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:completed");
4553 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004554 f_shutdown_helper();
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004555}
4556
Neels Hofmeyr0aa719b2020-10-12 18:43:09 +00004557private function f_mo_l3_transceive(RSL_DCHAN_PT rsl := RSL,
4558 template (value) RslLinkId link_id := ts_RslLinkID_DCCH(0),
Vadim Yanitskiy2ef6a2f2020-10-08 23:17:32 +07004559 template (present) OCT1 dlci := ?,
Vadim Yanitskiyb93aa432020-10-01 14:23:11 +07004560 octetstring l3 := '0123456789'O)
4561runs on MSC_ConnHdlr {
Neels Hofmeyr43654812020-09-25 01:35:35 +02004562 /* The old lchan and conn should still be active. See that arbitrary L3
4563 * is still going through. */
Neels Hofmeyr0aa719b2020-10-12 18:43:09 +00004564 rsl.send(ts_RSL_DATA_IND(g_chan_nr, link_id, l3));
Neels Hofmeyr43654812020-09-25 01:35:35 +02004565 var template PDU_BSSAP exp_data := {
4566 discriminator := '1'B,
4567 spare := '0000000'B,
Vadim Yanitskiyb93aa432020-10-01 14:23:11 +07004568 dlci := dlci,
4569 lengthIndicator := lengthof(l3),
Neels Hofmeyr43654812020-09-25 01:35:35 +02004570 pdu := {
4571 dtap := l3
4572 }
4573 };
4574 BSSAP.receive(exp_data);
4575 setverdict(pass);
4576}
4577
Neels Hofmeyr0aa719b2020-10-12 18:43:09 +00004578private function f_mt_l3_transceive(RSL_DCHAN_PT rsl := RSL,
4579 template (present) RslLinkId link_id := tr_RslLinkID_DCCH(0),
Vadim Yanitskiy0033a3b2020-10-01 22:21:16 +07004580 template (value) OCT1 dlci := '00'O,
4581 octetstring l3 := '0123456789'O)
4582runs on MSC_ConnHdlr {
4583 BSSAP.send(PDU_BSSAP:{
4584 discriminator := '1'B,
4585 spare := '0000000'B,
4586 dlci := dlci,
4587 lengthIndicator := lengthof(l3),
4588 pdu := {
4589 dtap := l3
4590 }
4591 });
Neels Hofmeyr0aa719b2020-10-12 18:43:09 +00004592 rsl.receive(tr_RSL_DATA_REQ(g_chan_nr, link_id, l3));
Vadim Yanitskiy0033a3b2020-10-01 22:21:16 +07004593 setverdict(pass);
4594}
4595
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004596/* BSC asks for inter-BSC HO, but the MSC decides that it won't happen and
4597 * simply never sends a BSSMAP Handover Command. */
4598private function f_tc_ho_out_fail_no_msc_response(charstring id) runs on MSC_ConnHdlr {
Daniel Willmann3b59eb52018-10-29 15:40:55 +01004599 g_pars := f_gen_test_hdlr_pars();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004600
4601 var PDU_BSSAP ass_req := f_gen_ass_req();
4602 ass_req.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4603 ass_req.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
4604 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4605 f_establish_fully(ass_req, exp_compl);
4606
Neels Hofmeyr666f0432020-07-04 00:53:07 +02004607 f_bts_0_cfg(BSCVTY, {"neighbor lac 99 arfcn 123 bsic any"});
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004608 f_vty_transceive(BSCVTY, "handover any to arfcn 123 bsic any");
4609
4610 BSSAP.receive(tr_BSSMAP_HandoverRequired);
4611
4612 /* osmo-bsc should time out 10 seconds after the handover started.
4613 * Let's give it a bit extra. */
4614 f_sleep(15.0);
4615
Vadim Yanitskiy74ae5eb2020-10-01 22:13:29 +07004616 f_mo_l3_transceive();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004617 f_sleep(1.0);
4618}
4619testcase TC_ho_out_fail_no_msc_response() runs on test_CT {
4620 var MSC_ConnHdlr vc_conn;
4621
4622 f_init(1, true);
4623 f_sleep(1.0);
4624
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004625 f_ctrs_bsc_and_bts_init();
4626
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004627 vc_conn := f_start_handler(refers(f_tc_ho_out_fail_no_msc_response));
4628 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004629
4630 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
4631 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
4632 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
4633 f_ctrs_bsc_and_bts_add(0, "handover:timeout");
4634 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
4635 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:timeout");
4636 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004637 f_shutdown_helper();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004638}
4639
4640/* BSC asks for inter-BSC HO, receives BSSMAP Handover Command, but MS reports
4641 * RR Handover Failure. */
4642private function f_tc_ho_out_fail_rr_ho_failure(charstring id) runs on MSC_ConnHdlr {
Daniel Willmann3b59eb52018-10-29 15:40:55 +01004643 g_pars := f_gen_test_hdlr_pars();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004644
4645 var PDU_BSSAP ass_req := f_gen_ass_req();
4646 ass_req.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4647 ass_req.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
4648 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4649 f_establish_fully(ass_req, exp_compl);
4650
Neels Hofmeyr666f0432020-07-04 00:53:07 +02004651 f_bts_0_cfg(BSCVTY, {"neighbor lac 99 arfcn 123 bsic any"});
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004652 f_vty_transceive(BSCVTY, "handover any to arfcn 123 bsic any");
4653
4654 BSSAP.receive(tr_BSSMAP_HandoverRequired);
4655
4656 f_sleep(0.5);
4657 /* The MSC negotiates Handover Request and Handover Request Ack with
4658 * the other BSS and comes back with a BSSMAP Handover Command
4659 * containing an RR Handover Command coming from the target BSS... */
4660
4661 var PDU_ML3_NW_MS rr_ho_cmd := valueof(ts_RR_HandoverCommand);
4662 log("Remote cell's RR Handover Command passed through as L3 Info: ", rr_ho_cmd);
4663 var octetstring rr_ho_cmd_enc := enc_PDU_ML3_NW_MS(rr_ho_cmd);
4664 log("Remote cell's RR Handover Command passed through as L3 Info, encoded: ", rr_ho_cmd_enc);
4665 BSSAP.send(ts_BSSMAP_HandoverCommand(rr_ho_cmd_enc));
4666
4667 /* expect the Handover Command to go out on RR */
4668 var RSL_Message rsl_ho_cmd
4669 RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, ?)) -> value rsl_ho_cmd;
4670 log("RSL Data Req went out to first BTS: ", rsl_ho_cmd);
4671 var RSL_IE_Body rsl_ho_cmd_l3;
4672 if (not f_rsl_find_ie(rsl_ho_cmd, RSL_IE_L3_INFO, rsl_ho_cmd_l3)) {
4673 log("RSL message contains no L3 Info IE, expected RR Handover Command");
4674 setverdict(fail);
4675 } else {
4676 log("Found L3 Info: ", rsl_ho_cmd_l3);
4677 if (rsl_ho_cmd_l3.l3_info.payload != rr_ho_cmd_enc) {
4678 log("FAIL: the BSC sent out a different L3 Info, not matching the RR Handover Command the other BSS forwarded.");
4679 setverdict(fail);
4680 } else {
4681 log("Success: the BSC sent out the same RR Handover Command the other BSS forwarded.");
4682 setverdict(pass);
4683 }
4684 }
4685
4686 f_sleep(0.2);
4687 f_rsl_send_l3(ts_RRM_HandoverFailure('00'O));
4688
4689 /* Should tell the MSC about the failure */
4690 BSSAP.receive(tr_BSSMAP_HandoverFailure);
4691
4692 f_sleep(1.0);
4693
Vadim Yanitskiy74ae5eb2020-10-01 22:13:29 +07004694 f_mo_l3_transceive();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004695 f_sleep(1.0);
4696
4697 setverdict(pass);
4698 f_sleep(1.0);
4699}
4700testcase TC_ho_out_fail_rr_ho_failure() runs on test_CT {
4701 var MSC_ConnHdlr vc_conn;
4702
4703 f_init(1, true);
4704 f_sleep(1.0);
4705
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004706 f_ctrs_bsc_and_bts_init();
4707
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004708 vc_conn := f_start_handler(refers(f_tc_ho_out_fail_rr_ho_failure));
4709 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004710
4711 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
4712 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
4713 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
4714 f_ctrs_bsc_and_bts_add(0, "handover:failed");
4715 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
4716 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:failed");
4717 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004718 f_shutdown_helper();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004719}
4720
Neels Hofmeyr10f2bfa2019-07-09 19:33:29 +02004721/* BSC asks for inter-BSC-out HO, receives BSSMAP Handover Command, but then no reply is received about HO outcome
4722 * (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 +02004723 * and the lchan is released. */
4724private function f_tc_ho_out_fail_no_result_after_ho_cmd(charstring id) runs on MSC_ConnHdlr {
Daniel Willmann3b59eb52018-10-29 15:40:55 +01004725 g_pars := f_gen_test_hdlr_pars();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004726
4727 var PDU_BSSAP ass_req := f_gen_ass_req();
4728 ass_req.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4729 ass_req.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
4730 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4731 f_establish_fully(ass_req, exp_compl);
4732
Neels Hofmeyr666f0432020-07-04 00:53:07 +02004733 f_bts_0_cfg(BSCVTY, {"neighbor lac 99 arfcn 123 bsic any"});
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004734 f_vty_transceive(BSCVTY, "handover any to arfcn 123 bsic any");
4735
4736 BSSAP.receive(tr_BSSMAP_HandoverRequired);
4737
4738 f_sleep(0.5);
4739 /* The MSC negotiates Handover Request and Handover Request Ack with
4740 * the other BSS and comes back with a BSSMAP Handover Command
4741 * containing an RR Handover Command coming from the target BSS... */
4742
4743 var PDU_ML3_NW_MS rr_ho_cmd := valueof(ts_RR_HandoverCommand);
4744 log("Remote cell's RR Handover Command passed through as L3 Info: ", rr_ho_cmd);
4745 var octetstring rr_ho_cmd_enc := enc_PDU_ML3_NW_MS(rr_ho_cmd);
4746 log("Remote cell's RR Handover Command passed through as L3 Info, encoded: ", rr_ho_cmd_enc);
4747 BSSAP.send(ts_BSSMAP_HandoverCommand(rr_ho_cmd_enc));
4748
4749 /* expect the Handover Command to go out on RR */
4750 var RSL_Message rsl_ho_cmd
4751 RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, ?)) -> value rsl_ho_cmd;
4752 log("RSL Data Req went out to first BTS: ", rsl_ho_cmd);
4753 var RSL_IE_Body rsl_ho_cmd_l3;
4754 if (not f_rsl_find_ie(rsl_ho_cmd, RSL_IE_L3_INFO, rsl_ho_cmd_l3)) {
4755 log("RSL message contains no L3 Info IE, expected RR Handover Command");
4756 setverdict(fail);
4757 } else {
4758 log("Found L3 Info: ", rsl_ho_cmd_l3);
4759 if (rsl_ho_cmd_l3.l3_info.payload != rr_ho_cmd_enc) {
4760 log("FAIL: the BSC sent out a different L3 Info, not matching the RR Handover Command the other BSS forwarded.");
4761 setverdict(fail);
4762 } else {
4763 log("Success: the BSC sent out the same RR Handover Command the other BSS forwarded.");
4764 setverdict(pass);
4765 }
4766 }
4767
Neels Hofmeyr10f2bfa2019-07-09 19:33:29 +02004768 /* We get neither success nor failure report from the remote BSS. Eventually T8 times out and we run into 3GPP
4769 * TS 48.008 3.1.5.3.3 "Abnormal Conditions": Clear Request should go to the MSC, and RR should be released
4770 * after Clear Command */
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004771
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02004772 var PDU_BSSAP rx_clear_request;
Neels Hofmeyre1797aa2019-07-09 19:34:04 +02004773 BSSAP.receive(tr_BSSMAP_ClearRequest) -> value rx_clear_request;
4774 log("Got BSSMAP Clear Request");
4775 /* Instruct BSC to clear channel */
4776 var BssmapCause cause := bit2int(rx_clear_request.pdu.bssmap.clearRequest.cause.causeValue);
4777 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
4778
4779 var MgcpCommand mgcp;
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004780 interleave {
Neels Hofmeyr861a4c12018-11-07 01:23:17 +01004781 [] RSL.receive(tr_RSL_DEACT_SACCH(g_chan_nr)) {
4782 log("Got Deact SACCH");
4783 }
Harald Welte924b6ea2019-02-04 01:05:34 +01004784 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_RELEASE)) {
Neels Hofmeyr211169d2018-11-07 00:37:29 +01004785 log("Got RR Release");
4786 }
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004787 [] RSL.receive(tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL)) {
4788 log("Got RF Chan Rel");
4789 RSL.send(ts_RSL_RF_CHAN_REL_ACK(g_chan_nr));
4790 }
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004791 }
4792
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02004793 f_expect_dlcx_conns();
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004794
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004795 setverdict(pass);
4796 f_sleep(1.0);
4797}
Neels Hofmeyrd8a602c2019-07-09 19:46:01 +02004798testcase TC_ho_out_fail_no_result_after_ho_cmd() runs on test_CT {
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004799 var MSC_ConnHdlr vc_conn;
4800
4801 f_init(1, true);
4802 f_sleep(1.0);
4803
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004804 f_ctrs_bsc_and_bts_init();
4805
Neels Hofmeyrd8a602c2019-07-09 19:46:01 +02004806 vc_conn := f_start_handler(refers(f_tc_ho_out_fail_no_result_after_ho_cmd));
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004807 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004808
4809 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
4810 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
4811 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
4812 f_ctrs_bsc_and_bts_add(0, "handover:timeout");
4813 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
4814 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:timeout");
4815 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004816 f_shutdown_helper();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004817}
4818
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004819private function f_tc_ho_into_this_bsc(charstring id) runs on MSC_ConnHdlr {
4820 /* Hack: the proper way would be to wait for the BSSMAP Handover Request ACK and extract the
4821 * actual assigned chan_nr from its L3 (RR Handover Command) message. But osmo-bsc starts acting
4822 * on the lchan even before we get a chance to evaluate the BSSMAP Handover Request ACK. So we
4823 * need to assume that osmo-bsc will activate TS 1 and already set up this lchan's RSL emulation
4824 * before we get started. */
4825 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
4826 f_rslem_register(0, new_chan_nr);
4827 g_chan_nr := new_chan_nr;
4828 f_sleep(1.0);
4829
4830 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
4831 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
4832 activate(as_Media());
4833
Neels Hofmeyr90f80962020-06-12 16:16:55 +02004834 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Pau Espin Pedrol07866632020-09-03 19:10:55 +02004835 f_gen_handover_req(aoip_tla := g_pars.host_aoip_tla)));
Harald Welte6811d102019-04-14 22:23:14 +02004836 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004837
4838 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
4839
4840 var PDU_BSSAP rx_bssap;
4841 var octetstring ho_command_str;
4842
4843 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
Pau Espin Pedrol76ba5412019-06-10 11:00:33 +02004844
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004845 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
4846 log("Received L3 Info in HO Request Ack: ", ho_command_str);
4847 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
4848 log("L3 Info in HO Request Ack is ", ho_command);
4849
4850 var GsmArfcn arfcn;
4851 var RslChannelNr actual_new_chan_nr;
4852 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
4853 actual_new_chan_nr, arfcn);
4854
4855 if (actual_new_chan_nr != new_chan_nr) {
4856 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
4857 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
4858 setverdict(fail);
4859 return;
4860 }
4861 log("Handover Command chan_nr is", actual_new_chan_nr);
4862
4863 /* Now the MSC forwards the RR Handover Command to the other BSC, which
4864 * tells the MS to handover to the new lchan. Here comes the new MS on
4865 * the new lchan with a Handover RACH: */
4866
4867 /* send handover detect */
4868
4869 RSL.send(ts_RSL_HANDO_DET(new_chan_nr));
4870
4871 BSSAP.receive(tr_BSSMAP_HandoverDetect);
4872
4873 /* send handover complete over the new channel */
4874
4875 var PDU_ML3_MS_NW l3_tx := valueof(ts_RRM_HandoverComplete('00'O));
4876 RSL.send(ts_RSL_EST_IND(new_chan_nr, valueof(ts_RslLinkID_DCCH(0)),
4877 enc_PDU_ML3_MS_NW(l3_tx)));
4878
4879 BSSAP.receive(tr_BSSMAP_HandoverComplete);
4880 setverdict(pass);
4881}
Pau Espin Pedrol07866632020-09-03 19:10:55 +02004882function f_tc_ho_into_this_bsc_main(TestHdlrParams pars) runs on test_CT {
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004883 var MSC_ConnHdlr vc_conn;
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004884
4885 f_init(1, true);
4886 f_sleep(1.0);
4887
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004888 f_ctrs_bsc_and_bts_init();
4889
Neels Hofmeyr90f80962020-06-12 16:16:55 +02004890 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
4891 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004892
4893 vc_conn := f_start_handler(refers(f_tc_ho_into_this_bsc), pars);
4894 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004895
4896 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
4897 f_ctrs_bsc_and_bts_add(0, "handover:completed");
4898 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:attempted");
4899 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:completed");
4900 f_ctrs_bsc_and_bts_verify();
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004901}
4902
Pau Espin Pedrol07866632020-09-03 19:10:55 +02004903testcase TC_ho_into_this_bsc() runs on test_CT {
4904 var TestHdlrParams pars := f_gen_test_hdlr_pars();
4905 f_tc_ho_into_this_bsc_main(pars);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004906 f_shutdown_helper();
Pau Espin Pedrol07866632020-09-03 19:10:55 +02004907}
4908
4909testcase TC_ho_into_this_bsc_tla_v6() runs on test_CT {
4910 var TestHdlrParams pars := f_gen_test_hdlr_pars();
4911 pars.host_aoip_tla := "::6";
4912 f_tc_ho_into_this_bsc_main(pars);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004913 f_shutdown_helper();
Pau Espin Pedrol07866632020-09-03 19:10:55 +02004914}
4915
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01004916private function f_tc_ho_in_fail_msc_clears(charstring id) runs on MSC_ConnHdlr {
4917 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
4918 f_rslem_register(0, new_chan_nr);
4919 g_chan_nr := new_chan_nr;
4920 f_sleep(1.0);
4921
4922 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
4923 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
4924 activate(as_Media());
4925
Neels Hofmeyr90f80962020-06-12 16:16:55 +02004926 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01004927 f_gen_handover_req()));
Harald Welte6811d102019-04-14 22:23:14 +02004928 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01004929
4930 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
4931
4932 var PDU_BSSAP rx_bssap;
4933 var octetstring ho_command_str;
4934
4935 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
4936
4937 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
4938 log("Received L3 Info in HO Request Ack: ", ho_command_str);
4939 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
4940 log("L3 Info in HO Request Ack is ", ho_command);
4941
4942 var GsmArfcn arfcn;
4943 var RslChannelNr actual_new_chan_nr;
4944 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
4945 actual_new_chan_nr, arfcn);
4946
4947 if (actual_new_chan_nr != new_chan_nr) {
4948 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
4949 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
4950 setverdict(fail);
4951 return;
4952 }
4953 log("Handover Command chan_nr is", actual_new_chan_nr);
4954
Neels Hofmeyr61ca08d2019-05-06 23:52:22 +02004955 /* For deterministic test results, give some time for the MGW endpoint to be configured */
4956 f_sleep(1.0);
4957
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01004958 /* Now the MSC forwards the RR Handover Command to the other BSC, which
4959 * tells the MS to handover to the new lchan. In this case, the MS
4960 * reports a Handover Failure to the old BSS, which forwards a BSSMAP
4961 * Handover Failure to the MSC. The procedure according to 3GPP TS
4962 * 48.008 3.1.5.3.2 "Handover Failure" is then that the MSC sends a
4963 * BSSMAP Clear Command: */
4964
4965 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_RADIO_INTERFACE_FAILURE_REVERSION;
4966 var BssmapCause cause := enum2int(cause_val);
4967 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
4968
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02004969 f_expect_dlcx_conns();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01004970 setverdict(pass);
4971 f_sleep(1.0);
4972
4973 setverdict(pass);
4974}
4975testcase TC_ho_in_fail_msc_clears() runs on test_CT {
4976 var MSC_ConnHdlr vc_conn;
4977 var TestHdlrParams pars := f_gen_test_hdlr_pars();
4978
4979 f_init(1, true);
4980 f_sleep(1.0);
4981
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004982 f_ctrs_bsc_and_bts_init();
4983
Neels Hofmeyr90f80962020-06-12 16:16:55 +02004984 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
4985 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01004986
4987 vc_conn := f_start_handler(refers(f_tc_ho_in_fail_msc_clears), pars);
4988 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004989
4990 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
4991 f_ctrs_bsc_and_bts_add(0, "handover:stopped");
4992 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:attempted");
4993 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:stopped");
4994 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004995 f_shutdown_helper();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01004996}
4997
4998private function f_tc_ho_in_fail_msc_clears_after_ho_detect(charstring id) runs on MSC_ConnHdlr {
4999 /* Hack: the proper way would be to wait for the BSSMAP Handover Request ACK and extract the
5000 * actual assigned chan_nr from its L3 (RR Handover Command) message. But osmo-bsc starts acting
5001 * on the lchan even before we get a chance to evaluate the BSSMAP Handover Request ACK. So we
5002 * need to assume that osmo-bsc will activate TS 1 and already set up this lchan's RSL emulation
5003 * before we get started. */
5004 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
5005 f_rslem_register(0, new_chan_nr);
5006 g_chan_nr := new_chan_nr;
5007 f_sleep(1.0);
5008
5009 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
5010 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
5011 activate(as_Media());
5012
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005013 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005014 f_gen_handover_req()));
Harald Welte6811d102019-04-14 22:23:14 +02005015 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005016
5017 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
5018
5019 var PDU_BSSAP rx_bssap;
5020 var octetstring ho_command_str;
5021
5022 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
5023
5024 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
5025 log("Received L3 Info in HO Request Ack: ", ho_command_str);
5026 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
5027 log("L3 Info in HO Request Ack is ", ho_command);
5028
5029 var GsmArfcn arfcn;
5030 var RslChannelNr actual_new_chan_nr;
5031 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
5032 actual_new_chan_nr, arfcn);
5033
5034 if (actual_new_chan_nr != new_chan_nr) {
5035 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
5036 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
5037 setverdict(fail);
5038 return;
5039 }
5040 log("Handover Command chan_nr is", actual_new_chan_nr);
5041
5042 /* Now the MSC forwards the RR Handover Command to the other BSC, which
5043 * tells the MS to handover to the new lchan. Here comes the new MS on
5044 * the new lchan with a Handover RACH: */
5045
5046 /* send handover detect */
5047
5048 RSL.send(ts_RSL_HANDO_DET(new_chan_nr));
5049
5050 BSSAP.receive(tr_BSSMAP_HandoverDetect);
5051
5052 /* The MSC chooses to clear the connection now, maybe we got the
5053 * Handover RACH on the new cell but the MS still signaled Handover
5054 * Failure to the old BSS? */
5055
5056 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_RADIO_INTERFACE_FAILURE_REVERSION;
5057 var BssmapCause cause := enum2int(cause_val);
5058 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
5059
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02005060 f_expect_dlcx_conns();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005061 f_sleep(1.0);
5062}
5063testcase TC_ho_in_fail_msc_clears_after_ho_detect() runs on test_CT {
5064 var MSC_ConnHdlr vc_conn;
5065 var TestHdlrParams pars := f_gen_test_hdlr_pars();
5066
5067 f_init(1, true);
5068 f_sleep(1.0);
5069
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005070 f_ctrs_bsc_and_bts_init();
5071
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005072 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
5073 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005074
5075 vc_conn := f_start_handler(refers(f_tc_ho_in_fail_msc_clears_after_ho_detect), pars);
5076 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005077
5078 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5079 f_ctrs_bsc_and_bts_add(0, "handover:stopped");
5080 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:attempted");
5081 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:stopped");
5082 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005083 f_shutdown_helper();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005084}
5085
5086/* The new BSS's lchan times out before the MSC decides that handover failed. */
5087private function f_tc_ho_in_fail_no_detect(charstring id) runs on MSC_ConnHdlr {
5088 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
5089 f_rslem_register(0, new_chan_nr);
5090 g_chan_nr := new_chan_nr;
5091 f_sleep(1.0);
5092
5093 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
5094 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
5095 activate(as_Media());
5096
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005097 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005098 f_gen_handover_req()));
Harald Welte6811d102019-04-14 22:23:14 +02005099 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005100
5101 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
5102
5103 var PDU_BSSAP rx_bssap;
5104 var octetstring ho_command_str;
5105
5106 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
5107
5108 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
5109 log("Received L3 Info in HO Request Ack: ", ho_command_str);
5110 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
5111 log("L3 Info in HO Request Ack is ", ho_command);
5112
5113 var GsmArfcn arfcn;
5114 var RslChannelNr actual_new_chan_nr;
5115 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
5116 actual_new_chan_nr, arfcn);
5117
5118 if (actual_new_chan_nr != new_chan_nr) {
5119 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
5120 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
5121 setverdict(fail);
5122 return;
5123 }
5124 log("Handover Command chan_nr is", actual_new_chan_nr);
5125
5126 /* Now the MSC forwards the RR Handover Command to the other BSC, which
5127 * tells the MS to handover to the new lchan. But the MS never shows up
5128 * on the new lchan. */
5129
5130 BSSAP.receive(tr_BSSMAP_HandoverFailure);
5131
5132 /* Did osmo-bsc also send a Clear Request? */
5133 timer T := 0.5;
5134 T.start;
5135 alt {
5136 [] BSSAP.receive(tr_BSSMAP_ClearRequest);
5137 [] T.timeout { }
5138 }
5139
5140 /* MSC plays along with a Clear Command (no matter whether osmo-bsc
5141 * asked for it, this is a Handover Failure after all). */
5142
5143 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_RADIO_INTERFACE_FAILURE_REVERSION;
5144 var BssmapCause cause := enum2int(cause_val);
5145 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
5146
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02005147 f_expect_dlcx_conns();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005148 f_sleep(1.0);
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005149}
5150testcase TC_ho_in_fail_no_detect() runs on test_CT {
5151 var MSC_ConnHdlr vc_conn;
5152 var TestHdlrParams pars := f_gen_test_hdlr_pars();
5153
5154 f_init(1, true);
5155 f_sleep(1.0);
5156
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005157 f_ctrs_bsc_and_bts_init();
5158
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005159 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
5160 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005161
5162 vc_conn := f_start_handler(refers(f_tc_ho_in_fail_no_detect), pars);
5163 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005164
5165 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5166 f_ctrs_bsc_and_bts_add(0, "handover:error");
5167 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:attempted");
5168 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:error");
5169 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005170 f_shutdown_helper();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005171}
5172
5173/* Same as f_tc_ho_in_fail_no_detect, but MSC fails to send a Clear Command */
5174private function f_tc_ho_in_fail_no_detect2(charstring id) runs on MSC_ConnHdlr {
5175 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
5176 f_rslem_register(0, new_chan_nr);
5177 g_chan_nr := new_chan_nr;
5178 f_sleep(1.0);
5179
5180 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
5181 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
5182 activate(as_Media());
5183
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005184 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005185 f_gen_handover_req()));
Harald Welte6811d102019-04-14 22:23:14 +02005186 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005187
5188 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
5189
5190 var PDU_BSSAP rx_bssap;
5191 var octetstring ho_command_str;
5192
5193 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
5194
5195 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
5196 log("Received L3 Info in HO Request Ack: ", ho_command_str);
5197 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
5198 log("L3 Info in HO Request Ack is ", ho_command);
5199
5200 var GsmArfcn arfcn;
5201 var RslChannelNr actual_new_chan_nr;
5202 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
5203 actual_new_chan_nr, arfcn);
5204
5205 if (actual_new_chan_nr != new_chan_nr) {
5206 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
5207 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
5208 setverdict(fail);
5209 return;
5210 }
5211 log("Handover Command chan_nr is", actual_new_chan_nr);
5212
5213 /* Now the MSC forwards the RR Handover Command to the other BSC, which
5214 * tells the MS to handover to the new lchan. But the MS never shows up
5215 * on the new lchan. */
5216
5217 BSSAP.receive(tr_BSSMAP_HandoverFailure);
5218
5219 /* MSC plays dumb and sends no Clear Command */
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005220 var PDU_BSSAP rx_clear_request;
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02005221
5222 BSSAP.receive(tr_BSSMAP_ClearRequest) -> value rx_clear_request {
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005223 var BssmapCause cause := bit2int(rx_clear_request.pdu.bssmap.clearRequest.cause.causeValue);
5224 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
5225 };
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02005226 f_expect_dlcx_conns();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005227 f_sleep(1.0);
5228}
5229testcase TC_ho_in_fail_no_detect2() runs on test_CT {
5230 var MSC_ConnHdlr vc_conn;
5231 var TestHdlrParams pars := f_gen_test_hdlr_pars();
5232
5233 f_init(1, true);
5234 f_sleep(1.0);
5235
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005236 f_ctrs_bsc_and_bts_init();
5237
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005238 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
5239 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005240
5241 vc_conn := f_start_handler(refers(f_tc_ho_in_fail_no_detect2), pars);
5242 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005243
5244 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5245 f_ctrs_bsc_and_bts_add(0, "handover:error");
5246 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:attempted");
5247 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:error");
5248 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005249 f_shutdown_helper();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005250}
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005251
Neels Hofmeyr91401012019-07-11 00:42:35 +02005252type record of charstring Commands;
5253
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005254private function f_bts_0_cfg(TELNETasp_PT pt, Commands cmds := {})
Neels Hofmeyr91401012019-07-11 00:42:35 +02005255{
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005256 f_vty_enter_cfg_bts(pt, 0);
Neels Hofmeyr91401012019-07-11 00:42:35 +02005257 for (var integer i := 0; i < sizeof(cmds); i := i+1) {
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005258 f_vty_transceive(pt, cmds[i]);
Neels Hofmeyr91401012019-07-11 00:42:35 +02005259 }
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005260 f_vty_transceive(pt, "end");
Neels Hofmeyr91401012019-07-11 00:42:35 +02005261}
5262
Pau Espin Pedrolc675b612020-01-09 19:55:40 +01005263private function f_cs7_inst_0_cfg(TELNETasp_PT pt, Commands cmds := {})
5264{
5265 f_vty_enter_cfg_cs7_inst(pt, 0);
5266 for (var integer i := 0; i < sizeof(cmds); i := i+1) {
5267 f_vty_transceive(pt, cmds[i]);
5268 }
5269 f_vty_transceive(pt, "end");
5270}
5271
Neels Hofmeyr91401012019-07-11 00:42:35 +02005272private function f_probe_for_handover(charstring log_label,
5273 charstring log_descr,
5274 charstring handover_vty_cmd,
5275 boolean expect_handover,
5276 boolean is_inter_bsc_handover := false)
5277runs on MSC_ConnHdlr
5278{
Neels Hofmeyrb3fc8982020-05-11 00:16:42 +02005279 /* We're going to thwart any and all handover attempts, just be ready to handle (and ignore) handover target
5280 * lchans to be established on bts 1 or bts 2. */
5281 f_rslem_suspend(RSL1_PROC);
5282 f_rslem_suspend(RSL2_PROC);
5283
Neels Hofmeyr91401012019-07-11 00:42:35 +02005284 var RSL_Message rsl;
5285
5286 var charstring log_msg := " (expecting handover)"
5287 if (not expect_handover) {
5288 log_msg := " (expecting NO handover)";
5289 }
5290 log("f_probe_for_handover starting: " & log_label & ": " & log_descr & log_msg);
5291 f_vty_transceive(BSCVTY, handover_vty_cmd);
5292
Neels Hofmeyr91401012019-07-11 00:42:35 +02005293 timer T := 2.0;
5294 T.start;
5295
5296 alt {
5297 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr)) -> value rsl {
5298 var PDU_ML3_NW_MS l3 := dec_PDU_ML3_NW_MS(rsl.ies[2].body.l3_info.payload);
5299 log("Rx L3 from net: ", l3);
5300 if (ischosen(l3.msgs.rrm.handoverCommand)) {
5301 var RslChannelNr new_chan_nr;
5302 var GsmArfcn arfcn;
5303 f_ChDesc2RslChanNr(l3.msgs.rrm.handoverCommand.channelDescription2,
5304 new_chan_nr, arfcn);
5305 log("Handover to new chan ", new_chan_nr, " on ARFCN ", arfcn);
5306 log(l3.msgs.rrm.handoverCommand);
5307
5308 /* Need to register for new lchan on new BTS -- it's either bts 1 or bts 2. It doesn't really
5309 * matter on which BTS it really is, we're not going to follow through an entire handover
5310 * anyway. */
5311 f_rslem_register(0, new_chan_nr, RSL1_PROC);
5312 f_rslem_resume(RSL1_PROC);
5313 f_rslem_register(0, new_chan_nr, RSL2_PROC);
5314 f_rslem_resume(RSL2_PROC);
5315
5316 if (expect_handover and not is_inter_bsc_handover) {
5317 setverdict(pass);
5318 log("f_probe_for_handover(" & log_label & "): Got RSL Handover Command as expected.");
5319 } else {
5320 setverdict(fail, "f_probe_for_handover(" & log_label & "): Expected none, but got RSL Handover Command. "
5321 & log_label & ": " & log_descr);
5322 }
5323
5324 log("f_probe_for_handover(" & log_label & "): Ending the test: Handover Failure stops the procedure.");
5325 /* osmo-bsc has triggered Handover. That's all we need to know for this test, reply with
5326 * Handover Failure. */
5327 f_rsl_send_l3(ts_RRM_HandoverFailure('00'O));
5328
5329 /* target BTS is told to release lchan again; don't care which BTS nor what messages. */
5330 f_sleep(0.5);
5331 RSL1.clear;
5332 RSL2.clear;
5333 log("f_probe_for_handover(" & log_label & "): done (got RSL Handover Command)");
5334 break;
5335 } else {
5336 repeat;
5337 }
5338 }
5339 [] BSSAP.receive(tr_BSSMAP_HandoverRequired) {
5340 if (expect_handover and is_inter_bsc_handover) {
5341 setverdict(pass);
5342 log("f_probe_for_handover(" & log_label & "): Got BSSMAP Handover Required as expected.");
5343 } else {
5344 setverdict(fail, "f_probe_for_handover(" & log_label & "): Expected none, but got BSSMAP Handover Required. "
5345 & log_label & ": " & log_descr);
5346 }
5347
5348 log("f_probe_for_handover(" & log_label & "): done (got BSSMAP Handover Required)");
5349
5350 /* Note: f_tc_ho_neighbor_config_start() sets T7, the timeout for BSSMAP Handover Required, to
5351 * 1 second. There is no legal way to quickly abort a handover after a BSSMAP Handover Required,
5352 * setting a short timeout and waiting is the only way. */
5353 log("f_probe_for_handover(" & log_label & "): waiting for inter-BSC HO to time out...");
5354 f_sleep(1.5);
5355 log("f_probe_for_handover(" & log_label & "): ...done");
5356
5357 break;
5358 }
5359 [] T.timeout {
5360 if (expect_handover) {
5361 setverdict(fail, "f_probe_for_handover(" & log_label & "): Expected Handover, but got none. "
5362 & log_label & ": " & log_descr);
5363 } else {
5364 setverdict(pass);
5365 log("f_probe_for_handover(" & log_label & "): Got no Handover, as expected.");
5366 }
5367 log("f_probe_for_handover(" & log_label & "): done (got no Handover)");
5368 break;
5369 }
5370 }
5371
5372 f_rslem_resume(RSL1_PROC);
5373 f_rslem_resume(RSL2_PROC);
5374 f_sleep(3.0);
5375 RSL.clear;
5376
5377 log("f_probe_for_handover(" & log_label & "): done clearing");
5378}
5379
5380/* Test the effect of various neighbor configuration scenarios:
5381 *
5382 * To avoid complexity, block off any actual handover operation, and always remain on the lchan at bts 0.
5383 * Reconfigure the neighbors for bts 0, trigger a Handover, and probe whether osmo-bsc does or doesn't start HO.
5384 */
5385private function f_tc_ho_neighbor_config_start() runs on MSC_ConnHdlr {
5386 g_pars := f_gen_test_hdlr_pars();
5387 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
5388 var PDU_BSSAP ass_cmd := f_gen_ass_req();
5389 const OCT8 kc := '0001020304050607'O;
5390
5391 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
5392 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
5393
5394 /* Establish lchan at bts 0 */
5395 f_establish_fully(ass_cmd, exp_compl);
5396
5397 /* Shorten the inter-BSC Handover timeout, to not wait so long for inter-BSC Handovers */
5398 f_vty_enter_cfg_network(BSCVTY);
5399 f_vty_transceive(BSCVTY, "timer T7 1");
5400 f_vty_transceive(BSCVTY, "end");
5401}
5402
5403private function f_tc_ho_neighbor_config_1(charstring id) runs on MSC_ConnHdlr {
5404 f_tc_ho_neighbor_config_start();
5405
5406 /*
5407 * bts 0 ARFCN 871 BSIC 10
5408 * bts 1 ARFCN 871 BSIC 11
5409 * bts 2 ARFCN 871 BSIC 12
5410 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
5411 */
5412
5413 log("f_tc_ho_neighbor_config: 1. No 'neighbor' config");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005414 f_bts_0_cfg(BSCVTY, {"no neighbors"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02005415 f_probe_for_handover("1.a", "HO to bts 1 works, implicitly listed as neighbor (legacy behavior when none are configured)",
5416 "handover any to arfcn 871 bsic 11",
5417 true);
5418
5419 f_probe_for_handover("1.b", "HO to unknown cell does not start",
5420 "handover any to arfcn 13 bsic 39",
5421 false);
5422
5423 f_probe_for_handover("1.c", "HO to 871-12 is ambiguous = error",
5424 "handover any to arfcn 871 bsic 12",
5425 false);
5426
5427 f_probe_for_handover("1.d", "HO to 871-11 still works (verify that this test properly cleans up)",
5428 "handover any to arfcn 871 bsic 11",
5429 true);
5430}
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005431testcase TC_ho_neighbor_config_1() runs on test_CT {
5432 var MSC_ConnHdlr vc_conn;
5433 f_init(3, true, guard_timeout := 60.0);
5434 f_sleep(1.0);
5435 f_ctrs_bsc_and_bts_init();
5436 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_1));
5437 vc_conn.done;
5438
5439 /* f_tc_ho_neighbor_config_start() */
5440 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5441 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5442
5443 /* 1.a */
5444 /* "failed" means a handover was triggered and started (which is all this test aims for) and the test ended the
5445 * handover quickly by sending a Handover Failure message. */
5446 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5447 f_ctrs_bsc_and_bts_add(0, "handover:failed");
5448 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
5449 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:failed");
5450
5451 /* 1.b */
5452 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5453 f_ctrs_bsc_and_bts_add(0, "handover:error");
5454
5455 /* 1.c */
5456 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5457 f_ctrs_bsc_and_bts_add(0, "handover:error");
5458
5459 /* 1.d */
5460 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5461 f_ctrs_bsc_and_bts_add(0, "handover:failed");
5462 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
5463 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:failed");
5464
5465 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005466 f_shutdown_helper();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005467}
5468
Neels Hofmeyr91401012019-07-11 00:42:35 +02005469private function f_tc_ho_neighbor_config_2(charstring id) runs on MSC_ConnHdlr {
5470 f_tc_ho_neighbor_config_start();
5471
5472 /*
5473 * bts 0 ARFCN 871 BSIC 10
5474 * bts 1 ARFCN 871 BSIC 11
5475 * bts 2 ARFCN 871 BSIC 12
5476 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
5477 */
5478
5479 log("f_tc_ho_neighbor_config: 2. explicit local neighbor: 'neighbor bts 1'");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005480 f_bts_0_cfg(BSCVTY, {"neighbor bts 1"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02005481 f_sleep(0.5);
5482
5483 f_probe_for_handover("2.a", "HO to bts 1 works, explicitly listed as neighbor",
5484 "handover any to arfcn 871 bsic 11",
5485 true);
5486
5487 f_probe_for_handover("2.b", "HO to bts 2 doesn't work, not listed as neighbor",
5488 "handover any to arfcn 871 bsic 12",
5489 false);
5490}
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005491testcase TC_ho_neighbor_config_2() runs on test_CT {
5492 var MSC_ConnHdlr vc_conn;
5493 f_init(3, true, guard_timeout := 50.0);
5494 f_sleep(1.0);
5495 f_ctrs_bsc_and_bts_init();
5496 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_2));
5497 vc_conn.done;
5498
5499 /* f_tc_ho_neighbor_config_start() */
5500 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5501 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5502
5503 /* 2.a */
5504 /* "failed" means a handover was triggered and started (which is all this test aims for) and the test ended the
5505 * handover quickly by sending a Handover Failure message. */
5506 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5507 f_ctrs_bsc_and_bts_add(0, "handover:failed");
5508 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
5509 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:failed");
5510
5511 /* 2.b */
5512 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5513 f_ctrs_bsc_and_bts_add(0, "handover:error");
5514
5515 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005516 f_shutdown_helper();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005517}
5518
Neels Hofmeyr91401012019-07-11 00:42:35 +02005519private function f_tc_ho_neighbor_config_3(charstring id) runs on MSC_ConnHdlr {
5520 f_tc_ho_neighbor_config_start();
5521
5522 /*
5523 * bts 0 ARFCN 871 BSIC 10
5524 * bts 1 ARFCN 871 BSIC 11
5525 * bts 2 ARFCN 871 BSIC 12
5526 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
5527 */
5528
5529 log("f_tc_ho_neighbor_config: 3. explicit local neighbor: 'neighbor bts 2'");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005530 f_bts_0_cfg(BSCVTY, {"no neighbors", "neighbor bts 2"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02005531 f_sleep(0.5);
5532
5533 f_probe_for_handover("3.a", "HO to bts 1 doesn't work, not listed as neighbor",
5534 "handover any to arfcn 871 bsic 11",
5535 false);
5536 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",
5537 "handover any to arfcn 871 bsic 12",
5538 true);
5539}
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005540testcase TC_ho_neighbor_config_3() runs on test_CT {
5541 var MSC_ConnHdlr vc_conn;
5542 f_init(3, true, guard_timeout := 50.0);
5543 f_sleep(1.0);
5544 f_ctrs_bsc_and_bts_init();
5545 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_3));
5546 vc_conn.done;
5547
5548 /* f_tc_ho_neighbor_config_start() */
5549 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5550 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5551
5552 /* 3.a */
5553 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5554 f_ctrs_bsc_and_bts_add(0, "handover:error");
5555
5556 /* 3.b */
5557 /* "failed" means a handover was triggered and started (which is all this test aims for) and the test ended the
5558 * handover quickly by sending a Handover Failure message. */
5559 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5560 f_ctrs_bsc_and_bts_add(0, "handover:failed");
5561 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
5562 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:failed");
5563
5564 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005565 f_shutdown_helper();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005566}
5567
Neels Hofmeyr91401012019-07-11 00:42:35 +02005568private function f_tc_ho_neighbor_config_4(charstring id) runs on MSC_ConnHdlr {
5569 f_tc_ho_neighbor_config_start();
5570
5571 /*
5572 * bts 0 ARFCN 871 BSIC 10
5573 * bts 1 ARFCN 871 BSIC 11
5574 * bts 2 ARFCN 871 BSIC 12
5575 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
5576 */
5577
5578 log("f_tc_ho_neighbor_config: 4. explicit remote neighbor: 'neighbor lac 99 arfcn 123 bsic 45'");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005579 f_bts_0_cfg(BSCVTY, {"no neighbors", "neighbor lac 99 arfcn 123 bsic 45"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02005580 f_sleep(0.5);
5581
5582 f_probe_for_handover("4.a", "HO to bts 1 doesn't work, not listed as neighbor",
5583 "handover any to arfcn 871 bsic 11",
5584 false);
5585 f_probe_for_handover("4.b", "HO to bts 2 doesn't work, not listed as neighbor",
5586 "handover any to arfcn 871 bsic 12",
5587 false);
5588 f_probe_for_handover("4.c", "HO to 123-45 triggers inter-BSC HO",
5589 "handover any to arfcn 123 bsic 45",
5590 true, true);
5591}
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005592testcase TC_ho_neighbor_config_4() runs on test_CT {
5593 var MSC_ConnHdlr vc_conn;
5594 f_init(3, true, guard_timeout := 50.0);
5595 f_sleep(1.0);
5596 f_ctrs_bsc_and_bts_init();
5597 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_4));
5598 vc_conn.done;
5599
5600 /* f_tc_ho_neighbor_config_start() */
5601 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5602 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5603
5604 /* 4.a */
5605 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5606 f_ctrs_bsc_and_bts_add(0, "handover:error");
5607
5608 /* 4.b */
5609 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5610 f_ctrs_bsc_and_bts_add(0, "handover:error");
5611
5612 /* 4.c */
5613 /* "timeout" means a handover was triggered and started (which is all this test aims for) and the test ended the
5614 * handover quickly by timing out after the Handover Required message */
5615 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5616 f_ctrs_bsc_and_bts_add(0, "handover:timeout");
5617 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
5618 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:timeout");
5619
5620 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005621 f_shutdown_helper();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005622}
5623
Neels Hofmeyr91401012019-07-11 00:42:35 +02005624private function f_tc_ho_neighbor_config_5(charstring id) runs on MSC_ConnHdlr {
5625 f_tc_ho_neighbor_config_start();
5626
5627 /*
5628 * bts 0 ARFCN 871 BSIC 10
5629 * bts 1 ARFCN 871 BSIC 11
5630 * bts 2 ARFCN 871 BSIC 12
5631 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
5632 */
5633
5634 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 +02005635 f_bts_0_cfg(BSCVTY, {"no neighbors", "neighbor lac 99 arfcn 871 bsic 12"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02005636 f_sleep(0.5);
5637
5638 f_probe_for_handover("5.a", "HO to 871-12 triggers inter-BSC HO (ignoring local cells with same ARFCN+BSIC)",
5639 "handover any to arfcn 871 bsic 12",
5640 true, true);
5641}
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005642testcase TC_ho_neighbor_config_5() runs on test_CT {
5643 var MSC_ConnHdlr vc_conn;
5644 f_init(3, true);
5645 f_sleep(1.0);
5646 f_ctrs_bsc_and_bts_init();
5647 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_5));
5648 vc_conn.done;
5649
5650 /* f_tc_ho_neighbor_config_start() */
5651 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5652 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5653
5654 /* 5 */
5655 /* "timeout" means a handover was triggered and started (which is all this test aims for) and the test ended the
5656 * handover quickly by timing out after the Handover Required message */
5657 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5658 f_ctrs_bsc_and_bts_add(0, "handover:timeout");
5659 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
5660 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:timeout");
5661
5662 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005663 f_shutdown_helper();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005664}
5665
Neels Hofmeyr91401012019-07-11 00:42:35 +02005666private function f_tc_ho_neighbor_config_6(charstring id) runs on MSC_ConnHdlr {
5667 f_tc_ho_neighbor_config_start();
5668
5669 /*
5670 * bts 0 ARFCN 871 BSIC 10
5671 * bts 1 ARFCN 871 BSIC 11
5672 * bts 2 ARFCN 871 BSIC 12
5673 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
5674 */
5675
5676 log("f_tc_ho_neighbor_config: 6. config error: explicit local and remote neighbors with ambiguous ARFCN+BSIC:"
5677 & " 'neighbor bts 2; neighbor lac 99 arfcn 871 bsic 12'");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005678 f_bts_0_cfg(BSCVTY, {"no neighbors", "neighbor bts 2", "neighbor lac 99 arfcn 871 bsic 12"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02005679 f_sleep(0.5);
5680
5681 f_probe_for_handover("6.a", "HO to 871-12 is ambiguous = error",
5682 "handover any to arfcn 871 bsic 12",
5683 false);
5684}
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005685testcase TC_ho_neighbor_config_6() runs on test_CT {
5686 var MSC_ConnHdlr vc_conn;
5687 f_init(3, true);
5688 f_sleep(1.0);
5689 f_ctrs_bsc_and_bts_init();
5690 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_6));
5691 vc_conn.done;
5692
5693 /* f_tc_ho_neighbor_config_start() */
5694 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5695 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5696
5697 /* 6.a */
5698 /* "timeout" means a handover was triggered and started (which is all this test aims for) and the test ended the
5699 * handover quickly by timing out after the Handover Required message */
5700 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5701 f_ctrs_bsc_and_bts_add(0, "handover:error");
5702
5703 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005704 f_shutdown_helper();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005705}
5706
Neels Hofmeyr91401012019-07-11 00:42:35 +02005707private function f_tc_ho_neighbor_config_7(charstring id) runs on MSC_ConnHdlr {
5708 f_tc_ho_neighbor_config_start();
5709
5710 /*
5711 * bts 0 ARFCN 871 BSIC 10
5712 * bts 1 ARFCN 871 BSIC 11
5713 * bts 2 ARFCN 871 BSIC 12
5714 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
5715 */
5716
5717 log("f_tc_ho_neighbor_config: 7. explicit local and remote neighbors:"
5718 & " 'neighbor bts 2; neighbor lac 99 arfcn 123 bsic 45'");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005719 f_bts_0_cfg(BSCVTY, {"no neighbors", "neighbor bts 2", "neighbor lac 99 arfcn 123 bsic 45"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02005720 f_sleep(0.5);
5721
5722 f_probe_for_handover("7.a", "HO to 871-12 does HO to bts 2",
5723 "handover any to arfcn 871 bsic 12",
5724 true);
5725 f_probe_for_handover("7.b", "HO to 123-45 triggers inter-BSC HO",
5726 "handover any to arfcn 123 bsic 45",
5727 true, true);
5728}
Neels Hofmeyr91401012019-07-11 00:42:35 +02005729testcase TC_ho_neighbor_config_7() runs on test_CT {
5730 var MSC_ConnHdlr vc_conn;
Neels Hofmeyrf2b88032020-06-16 00:35:04 +02005731 f_init(3, true, guard_timeout := 50.0);
Neels Hofmeyr91401012019-07-11 00:42:35 +02005732 f_sleep(1.0);
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005733 f_ctrs_bsc_and_bts_init();
Neels Hofmeyr91401012019-07-11 00:42:35 +02005734 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_7));
5735 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005736
5737 /* f_tc_ho_neighbor_config_start() */
5738 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5739 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5740
5741 /* 7.a */
5742 /* "failed" means a handover was triggered and started (which is all this test aims for) and the test ended the
5743 * handover quickly by sending a Handover Failure message. */
5744 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5745 f_ctrs_bsc_and_bts_add(0, "handover:failed");
5746 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
5747 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:failed");
5748
5749 /* 7.b */
5750 /* "timeout" means a handover was triggered and started (which is all this test aims for) and the test ended the
5751 * handover quickly by timing out after the Handover Required message */
5752 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5753 f_ctrs_bsc_and_bts_add(0, "handover:timeout");
5754 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
5755 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:timeout");
5756
5757 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005758 f_shutdown_helper();
Neels Hofmeyr91401012019-07-11 00:42:35 +02005759}
5760
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01005761/* OS#3041: Open and close N connections in a normal fashion, and expect no
5762 * BSSMAP Reset just because of that. */
5763testcase TC_bssap_rlsd_does_not_cause_bssmap_reset() runs on test_CT {
5764 var default d;
5765 var integer i;
5766 var DchanTuple dt;
5767
5768 f_init();
5769
5770 /* Wait for initial BSSMAP Reset to pass */
5771 f_sleep(4.0);
5772
5773 d := activate(no_bssmap_reset());
5774
5775 /* Setup up a number of connections and RLSD them again from the MSC
5776 * side. In the buggy behavior, the fourth one triggers BSSMAP Reset.
5777 * Let's do it some more times for good measure. */
Harald Weltec3260d92018-06-11 17:48:16 +02005778 for (i := 0; i < 4; i := i+1) {
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01005779 /* Since we're doing a lot of runs, give each one a fresh
5780 * T_guard from the top. */
5781 T_guard.start;
5782
5783 /* Setup a BSSAP connection and clear it right away. This is
5784 * the MSC telling the BSC about a planned release, it's not an
5785 * erratic loss of a connection. */
Harald Weltea1897182018-06-11 13:53:09 +02005786 dt := f_est_dchan(int2oct(i,1), 23+i, '00010203040506'O);
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01005787
5788 /* MSC disconnects (RLSD). */
5789 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
5790 }
5791
5792 /* In the buggy behavior, a timeout of 2 seconds happens between above
5793 * trigger (logs "SIGTRAN connection down, reconnecting...") and the
5794 * actual BSSMAP Reset. Wait a bit longer just to make sure. */
5795 f_sleep(4.0);
5796
5797 deactivate(d);
5798 f_shutdown_helper();
5799}
Harald Welte552620d2017-12-16 23:21:36 +01005800
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01005801/* OS#3041: Open and close N connections in a normal fashion, and expect no
5802 * BSSMAP Reset just because of that. Invoke the release by a BSSMAP Clear from
5803 * the MSC. */
5804testcase TC_bssmap_clear_does_not_cause_bssmap_reset() runs on test_CT {
5805 var default d;
5806 var integer i;
5807 var DchanTuple dt;
5808 var BSSAP_N_DATA_ind rx_di;
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01005809 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_CALL_CONTROL;
5810 var BssmapCause cause := enum2int(cause_val);
5811
5812 f_init();
5813
5814 /* Wait for initial BSSMAP Reset to pass */
5815 f_sleep(4.0);
5816
5817 d := activate(no_bssmap_reset());
5818
5819 /* Setup up a number of connections and RLSD them again from the MSC
5820 * side. In the buggy behavior, the fourth one triggers BSSMAP Reset.
5821 * Let's do it some more times for good measure. */
5822 for (i := 0; i < 8; i := i+1) {
5823 /* Since we're doing a lot of runs, give each one a fresh
5824 * T_guard from the top. */
5825 T_guard.start;
5826
5827 /* Setup a BSSAP connection and clear it right away. This is
5828 * the MSC telling the BSC about a planned release, it's not an
5829 * erratic loss of a connection. */
Harald Weltea1897182018-06-11 13:53:09 +02005830 dt := f_est_dchan(int2oct(i,1), 23+i, '00010203040506'O);
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01005831
5832 /* Instruct BSC to clear channel */
5833 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
5834
5835 /* expect BSC to disable the channel */
Harald Welte641fcbe2018-06-14 10:58:35 +02005836 f_exp_chan_rel_and_clear(dt, 0);
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01005837 }
5838
5839 /* In the buggy behavior, a timeout of 2 seconds happens between above
5840 * trigger (logs "SIGTRAN connection down, reconnecting...") and the
5841 * actual BSSMAP Reset. Wait a bit longer just to make sure. */
5842 f_sleep(4.0);
5843
5844 deactivate(d);
5845 f_shutdown_helper();
5846}
5847
Neels Hofmeyrfd445c32018-03-09 15:39:31 +01005848/* OS#3041: Open and close N connections in a normal fashion, and expect no
5849 * BSSMAP Reset just because of that. Close connections from the MS side with a
5850 * Release Ind on RSL. */
5851testcase TC_ms_rel_ind_does_not_cause_bssmap_reset() runs on test_CT {
5852 var default d;
5853 var integer i;
5854 var DchanTuple dt;
5855 var BSSAP_N_DATA_ind rx_di;
Neels Hofmeyrfd445c32018-03-09 15:39:31 +01005856 var integer j;
5857
5858 f_init();
5859
5860 /* Wait for initial BSSMAP Reset to pass */
5861 f_sleep(4.0);
5862
5863 d := activate(no_bssmap_reset());
5864
5865 /* Setup up a number of connections and RLSD them again from the MSC
5866 * side. In the buggy behavior, the fourth one triggers BSSMAP Reset.
5867 * Let's do it some more times for good measure. */
5868 for (i := 0; i < 8; i := i+1) {
5869 /* Since we're doing a lot of runs, give each one a fresh
5870 * T_guard from the top. */
5871 T_guard.start;
5872
5873 /* Setup a BSSAP connection and clear it right away. This is
5874 * the MSC telling the BSC about a planned release, it's not an
5875 * erratic loss of a connection. */
5876 dt := f_est_dchan('23'O, 23, '00010203040506'O);
5877
5878 /* simulate RLL REL IND */
5879 f_ipa_tx(0, ts_RSL_REL_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0))));
5880
5881 /* expect Clear Request on MSC side */
5882 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearRequest)) -> value rx_di;
5883
5884 /* Instruct BSC to clear channel */
5885 var BssmapCause cause := bit2int(rx_di.userData.pdu.bssmap.clearRequest.cause.causeValue);
5886 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
5887
5888 /* expect BSC to disable the channel */
Harald Welte641fcbe2018-06-14 10:58:35 +02005889 f_exp_chan_rel_and_clear(dt, 0);
Neels Hofmeyrfd445c32018-03-09 15:39:31 +01005890 }
5891
5892 /* In the buggy behavior, a timeout of 2 seconds happens between above
5893 * trigger (logs "SIGTRAN connection down, reconnecting...") and the
5894 * actual BSSMAP Reset. Wait a bit longer just to make sure. */
5895 f_sleep(4.0);
5896
5897 deactivate(d);
5898 f_shutdown_helper();
5899}
5900
Harald Welte94e0c342018-04-07 11:33:23 +02005901/***********************************************************************
5902 * IPA style dynamic PDCH
5903 ***********************************************************************/
5904
5905private function f_dyn_ipa_pdch_act(integer bts_nr, integer trx_nr, integer ts_nr,
5906 template (omit) RSL_Cause nack := omit)
5907runs on test_CT {
5908 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(ts_nr));
5909 var RSL_Message rsl_unused;
5910 /* ask BSC via VTY to activate a given IPA style chan as PDCH */
5911 f_vty_ts_action("pdch activate", bts_nr, trx_nr, ts_nr);
5912 /* expect the BSC to issue the related RSL command */
5913 rsl_unused := f_exp_ipa_rx(0, tr_RSL_IPA_PDCH_ACT(chan_nr));
5914 if (istemplatekind(nack, "omit")) {
5915 /* respond with a related acknowledgement */
5916 f_ipa_tx(0, ts_RSL_IPA_PDCH_ACT_ACK(chan_nr, ts_RSL_IE_FrameNumber(2342)));
5917 } else {
5918 f_ipa_tx(0, ts_RSL_IPA_PDCH_ACT_NACK(chan_nr, valueof(nack)));
5919 }
5920}
5921
5922private function f_dyn_ipa_pdch_deact(integer bts_nr, integer trx_nr, integer ts_nr,
5923 template (omit) RSL_Cause nack := omit)
5924runs on test_CT {
5925 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(ts_nr));
5926 var RSL_Message rsl_unused;
5927 /* ask BSC via VTY to activate a given IPA style chan as PDCH */
5928 f_vty_ts_action("pdch deactivate", bts_nr, trx_nr, ts_nr);
5929 /* expect the BSC to issue the related RSL command */
5930 rsl_unused := f_exp_ipa_rx(0, tr_RSL_IPA_PDCH_DEACT(chan_nr));
5931 if (istemplatekind(nack, "omit")) {
5932 /* respond with a related acknowledgement */
5933 f_ipa_tx(0, ts_RSL_IPA_PDCH_DEACT_ACK(chan_nr));
5934 } else {
5935 f_ipa_tx(0, ts_RSL_IPA_PDCH_DEACT_NACK(chan_nr, valueof(nack)));
5936 }
5937}
5938
5939private function f_ts_dyn_mode_get(integer bts_nr, integer trx_nr, integer ts_nr)
5940runs on test_CT return charstring {
5941 var charstring cmd, resp;
5942 cmd := "show timeslot "&int2str(bts_nr)&" "&int2str(trx_nr)&" "&int2str(ts_nr);
Stefan Sperlingcff13562018-11-13 15:24:06 +01005943 return f_vty_transceive_match_regexp_retry(BSCVTY, cmd, "*\((*)\)*", 0, 4, 1.0);
Harald Welte94e0c342018-04-07 11:33:23 +02005944}
5945
5946private function f_ts_dyn_mode_assert(integer bts_nr, integer trx_nr, integer ts_nr,
5947 template charstring exp)
5948runs on test_CT {
5949 var charstring mode := f_ts_dyn_mode_get(bts_nr, trx_nr, ts_nr);
5950 if (not match(mode, exp)) {
5951 setverdict(fail, "Unexpected TS Mode: ", mode);
Daniel Willmannafce8662018-07-06 23:11:32 +02005952 mtc.stop;
Harald Welte94e0c342018-04-07 11:33:23 +02005953 }
5954}
5955
5956private function f_ts_set_chcomb(integer bts_nr, integer trx_nr, integer ts_nr, charstring chcomb)
5957runs on test_CT {
5958 f_vty_enter_cfg_ts(BSCVTY, bts_nr, trx_nr, ts_nr);
5959 f_vty_transceive(BSCVTY, "phys_chan_config " & chcomb);
5960 f_vty_transceive(BSCVTY, "end");
5961}
5962
5963private const charstring TCHF_MODE := "TCH/F mode";
5964private const charstring TCHH_MODE := "TCH/H mode";
5965private const charstring PDCH_MODE := "PDCH mode";
5966private const charstring NONE_MODE := "NONE mode";
5967
5968/* Test IPA PDCH activation / deactivation triggered by VTY */
5969testcase TC_dyn_pdch_ipa_act_deact() runs on test_CT {
5970 var RSL_Message rsl_unused;
5971
5972 /* change Timeslot 6 before f_init() starts RSL */
5973 f_init_vty();
5974 f_ts_set_chcomb(0, 0, 6, "TCH/F_PDCH");
5975 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
5976
5977 f_init(1, false);
5978 f_sleep(1.0);
5979
5980 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(6));
5981
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02005982 log("TCH/F_PDCH pchan starts out in TCH/F mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02005983 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
5984 /* The BSC will activate the dynamic PDCH by default, so confirm that */
5985 rsl_unused := f_exp_ipa_rx(0, tr_RSL_IPA_PDCH_ACT(chan_nr));
5986 f_ipa_tx(0, ts_RSL_IPA_PDCH_ACT_ACK(chan_nr, ts_RSL_IE_FrameNumber(2342)));
5987 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02005988 log("TCH/F_PDCH pchan, PDCH ACT was ACKed, so now in PDCH mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02005989 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, PDCH_MODE);
5990
5991 /* De-activate it via VTY */
5992 f_dyn_ipa_pdch_deact(0, 0, chan_nr.tn);
5993 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02005994 log("TCH/F_PDCH pchan, PDCH DEACT via VTY, so now back in TCH/F mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02005995 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
5996
5997 /* re-activate it via VTY */
5998 f_dyn_ipa_pdch_act(0, 0, chan_nr.tn);
5999 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02006000 log("TCH/F_PDCH pchan, PDCH ACT via VTY, so now in PDCH mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02006001 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, PDCH_MODE);
6002
6003 /* and finally de-activate it again */
6004 f_dyn_ipa_pdch_deact(0, 0, chan_nr.tn);
6005 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02006006 log("TCH/F_PDCH pchan, PDCH DEACT via VTY, so now back in TCH/F mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02006007 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
6008
Neels Hofmeyr887e8f12018-06-27 01:01:55 +02006009 /* clean up config */
6010 f_ts_set_chcomb(0, 0, 6, "PDCH");
6011
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006012 f_shutdown_helper();
Harald Welte94e0c342018-04-07 11:33:23 +02006013}
6014
6015/* Test IPA PDCH activation NACK */
6016testcase TC_dyn_pdch_ipa_act_nack() runs on test_CT {
6017 var RSL_Message rsl_unused;
6018
6019 /* change Timeslot 6 before f_init() starts RSL */
6020 f_init_vty();
6021 f_ts_set_chcomb(0, 0, 6, "TCH/F_PDCH");
6022 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
6023
6024 f_init(1, false);
6025 f_sleep(1.0);
6026
6027 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(6));
6028
6029 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
6030 /* The BSC will activate the dynamic PDCH by default, so confirm that */
6031 rsl_unused := f_exp_ipa_rx(0, tr_RSL_IPA_PDCH_ACT(chan_nr));
6032 f_ipa_tx(0, ts_RSL_IPA_PDCH_ACT_ACK(chan_nr, ts_RSL_IE_FrameNumber(2342)));
6033 f_sleep(1.0);
6034 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, PDCH_MODE);
6035
6036 /* De-activate it via VTY */
6037 f_dyn_ipa_pdch_deact(0, 0, chan_nr.tn);
6038 f_sleep(1.0);
6039 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
6040
6041 /* re-activate it via VTY, but fail that; check BSC still assumes TCH/F mode */
6042 f_dyn_ipa_pdch_act(0, 0, chan_nr.tn, RSL_ERR_EQUIPMENT_FAIL);
6043 f_sleep(1.0);
6044 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
6045
Neels Hofmeyr887e8f12018-06-27 01:01:55 +02006046 /* clean up config */
6047 f_ts_set_chcomb(0, 0, 6, "PDCH");
6048
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006049 f_shutdown_helper();
Harald Welte94e0c342018-04-07 11:33:23 +02006050}
6051
6052
6053/***********************************************************************
6054 * Osmocom style dynamic PDCH
6055 ***********************************************************************/
6056
6057private function f_dyn_osmo_pdch_act(integer bts_nr, integer trx_nr, integer ts_nr,
6058 template (omit) RSL_Cause nack := omit)
6059runs on test_CT {
6060 var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(ts_nr));
6061 var RSL_Message rsl_unused;
6062 /* ask BSC via VTY to activate a given IPA style chan as PDCH */
6063 /* FIXME: no VTY command to activate Osmocom PDCH !! */
6064 /* expect the BSC to issue the related RSL command */
6065 rsl_unused := f_exp_ipa_rx(0, tr_RSL_CHAN_ACT(chan_nr, ?));
6066 if (istemplatekind(nack, "omit")) {
6067 /* respond with a related acknowledgement */
6068 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, 2342));
6069 } else {
6070 f_ipa_tx(0, ts_RSL_CHAN_ACT_NACK(chan_nr, valueof(nack)));
6071 }
6072}
6073
6074private function f_dyn_osmo_pdch_deact(integer bts_nr, integer trx_nr, integer ts_nr,
6075 template (omit) RSL_Cause nack := omit)
6076runs on test_CT {
6077 var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(ts_nr));
6078 var RSL_Message rsl_unused;
6079 /* ask BSC via VTY to activate a given IPA style chan as PDCH */
6080 /* FIXME: no VTY command to activate Osmocom PDCH !! */
6081 /* expect the BSC to issue the related RSL command */
6082 rsl_unused := f_exp_ipa_rx(0, tr_RSL_RF_CHAN_REL(chan_nr));
6083 if (istemplatekind(nack, "omit")) {
6084 /* respond with a related acknowledgement */
6085 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(chan_nr));
6086 } else {
6087 //f_ipa_tx(0, ts_RSL_RF_CHAN_REL_NACK(chan_nr, valueof(nack)));
6088 }
6089}
6090
6091/* Test Osmocom dyn PDCH activation / deactivation triggered by VTY */
6092testcase TC_dyn_pdch_osmo_act_deact() runs on test_CT {
6093 var RSL_Message rsl_unused;
6094
6095 /* change Timeslot 6 before f_init() starts RSL */
6096 f_init_vty();
6097 f_ts_set_chcomb(0, 0, 6, "TCH/F_TCH/H_PDCH");
6098 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
6099
6100 f_init(1, false);
6101 f_sleep(1.0);
6102
6103 var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(6));
6104
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02006105 log("TCH/F_TCH/H_PDCH pchan starts out in disabled mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02006106 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, NONE_MODE);
6107 /* The BSC will activate the dynamic PDCH by default, so confirm that */
6108 rsl_unused := f_exp_ipa_rx(0, tr_RSL_CHAN_ACT_PDCH(chan_nr, ?));
6109
6110 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, 2342));
6111 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02006112 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 +02006113 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, PDCH_MODE);
6114
Neels Hofmeyr887e8f12018-06-27 01:01:55 +02006115 /* clean up config */
6116 f_ts_set_chcomb(0, 0, 6, "PDCH");
6117
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006118 f_shutdown_helper();
Harald Welte94e0c342018-04-07 11:33:23 +02006119}
6120
6121/* Test Osmocom dyn PDCH activation NACK behavior */
6122testcase TC_dyn_pdch_osmo_act_nack() runs on test_CT {
6123 var RSL_Message rsl_unused;
6124
6125 /* change Timeslot 6 before f_init() starts RSL */
6126 f_init_vty();
6127 f_ts_set_chcomb(0, 0, 6, "TCH/F_TCH/H_PDCH");
6128 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
6129
6130 f_init(1, false);
6131 f_sleep(1.0);
6132
6133 var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(6));
6134
6135 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, NONE_MODE);
6136 /* The BSC will activate the dynamic PDCH by default, so confirm that */
6137 rsl_unused := f_exp_ipa_rx(0, tr_RSL_CHAN_ACT_PDCH(chan_nr, ?));
6138
6139 /* NACK this activation and expect the "show timeslot" mode still to be NONE */
6140 f_ipa_tx(0, ts_RSL_CHAN_ACT_NACK(chan_nr, RSL_ERR_EQUIPMENT_FAIL));
6141 f_sleep(1.0);
6142 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, NONE_MODE);
6143
Neels Hofmeyr887e8f12018-06-27 01:01:55 +02006144 /* clean up config */
6145 f_ts_set_chcomb(0, 0, 6, "PDCH");
6146
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006147 f_shutdown_helper();
Harald Welte94e0c342018-04-07 11:33:23 +02006148}
6149
Stefan Sperling0796a822018-10-05 13:01:39 +02006150testcase TC_chopped_ipa_ping() runs on test_CT {
Stefan Sperling554123f2018-10-09 14:12:30 +02006151 const Integers bsc_ipa_ports := {mp_bsc_rsl_port, mp_bsc_oml_port, mp_bsc_ctrl_port};
Stefan Sperling0796a822018-10-05 13:01:39 +02006152 for (var integer i := 0; i < lengthof(bsc_ipa_ports); i := i + 1) {
6153 IPA_Testing.f_run_TC_chopped_ipa_ping(mp_bsc_ip, bsc_ipa_ports[i], CONNECT_TO_SERVER);
6154 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006155 f_shutdown_helper();
Stefan Sperling0796a822018-10-05 13:01:39 +02006156}
6157
Stefan Sperlingaa1e60f2018-10-15 16:34:07 +02006158testcase TC_chopped_ipa_payload() runs on test_CT {
6159 const Integers bsc_ipa_ports := {mp_bsc_rsl_port, mp_bsc_oml_port
6160 /* TODO: mp_bsc_ctrl_port does not work yet */};
6161 for (var integer i := 0; i < lengthof(bsc_ipa_ports); i := i + 1) {
6162 IPA_Testing.f_run_TC_chopped_ipa_payload(mp_bsc_ip, bsc_ipa_ports[i], CONNECT_TO_SERVER);
6163 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006164 f_shutdown_helper();
Stefan Sperlingaa1e60f2018-10-15 16:34:07 +02006165}
6166
Pau Espin Pedrol8f773632019-11-05 11:46:53 +01006167/* Verify the BSC sends the MS Power Parameters IE during CHAN ACT to make sure
6168 the BTS does autonomous MS power control loop */
6169testcase TC_assignment_verify_ms_power_params_ie() runs on test_CT {
6170 var MSC_ConnHdlr vc_conn;
6171 var TestHdlrParams pars := f_gen_test_hdlr_pars();
6172 //pars.encr := valueof(t_EncrParams('01'O, f_rnd_octstring(8)));
6173 pars.exp_ms_power_params := true;
6174
6175 f_init(1, true);
6176 f_sleep(1.0);
6177 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5), pars);
6178 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006179 f_shutdown_helper();
Pau Espin Pedrol8f773632019-11-05 11:46:53 +01006180}
Stefan Sperlingaa1e60f2018-10-15 16:34:07 +02006181
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006182/***********************************************************************
6183 * MSC Pooling
6184 ***********************************************************************/
6185
6186function f_tmsi_nri(integer nri_v, octetstring base_tmsi := '42000023'O, integer nri_bitlen := 10) return octetstring
6187{
6188 return int2oct( oct2int(base_tmsi) + bit2int( (int2bit(nri_v, 32) << ( 24 - nri_bitlen)) ),
6189 4);
6190}
6191
6192template MobileIdentityLV ts_MI_TMSI_NRI_LV(integer nri_v, integer nri_bitlen := 10) :=
6193 ts_MI_TMSI_LV(tmsi := f_tmsi_nri(nri_v, nri_bitlen := nri_bitlen));
6194
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02006195private function f_expect_lchan_rel(RSL_DCHAN_PT rsl) runs on MSC_ConnHdlr {
6196 interleave {
6197 [] rsl.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_RELEASE)) {
6198 f_logp(BSCVTY, "Got RSL RR Release");
6199 }
6200 [] rsl.receive(tr_RSL_DEACT_SACCH(g_chan_nr)) {
6201 f_logp(BSCVTY, "Got RSL Deact SACCH");
6202 }
6203 [] rsl.receive(tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL)) {
6204 f_logp(BSCVTY, "Got RSL RF Chan Rel, sending Rel Ack");
6205 rsl.send(ts_RSL_RF_CHAN_REL_ACK(g_chan_nr));
6206 break;
6207 }
6208 }
6209}
6210
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006211private function f_perform_clear(RSL_DCHAN_PT rsl) runs on MSC_ConnHdlr {
Neels Hofmeyr767548a2020-08-09 20:26:07 +00006212 f_logp(BSCVTY, "MSC instructs BSC to clear channel");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006213 BSSAP.send(ts_BSSMAP_ClearCommand(0));
6214 interleave {
6215 [] rsl.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_RELEASE)) {
Neels Hofmeyr767548a2020-08-09 20:26:07 +00006216 f_logp(BSCVTY, "Got RSL RR Release");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006217 }
6218 [] rsl.receive(tr_RSL_DEACT_SACCH(g_chan_nr)) {
Neels Hofmeyr767548a2020-08-09 20:26:07 +00006219 f_logp(BSCVTY, "Got RSL Deact SACCH");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006220 }
6221 [] BSSAP.receive(tr_BSSMAP_ClearComplete) {
Neels Hofmeyr767548a2020-08-09 20:26:07 +00006222 f_logp(BSCVTY, "Got BSSMAP Clear Complete");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006223 /* Also drop the SCCP connection */
6224 BSSAP.send(RAN_Conn_Prim:MSC_CONN_PRIM_DISC_REQ);
6225 }
6226 [] rsl.receive(tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL)) {
Neels Hofmeyr767548a2020-08-09 20:26:07 +00006227 f_logp(BSCVTY, "Got RSL RF Chan Rel, sending Rel Ack");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006228 rsl.send(ts_RSL_RF_CHAN_REL_ACK(g_chan_nr));
6229 }
6230 }
6231}
6232
Neels Hofmeyr66e15092020-10-12 18:44:41 +00006233private 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 +02006234runs on MSC_ConnHdlr {
6235 timer T := 10.0;
6236 var octetstring l3_enc := enc_PDU_ML3_MS_NW(valueof(l3_info));
6237
Neels Hofmeyr767548a2020-08-09 20:26:07 +00006238 f_logp(BSCVTY, "establish channel, send Complete Layer 3 Info");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006239 f_create_bssmap_exp(l3_enc);
6240
6241 /* RSL_Emulation.f_chan_est() on rsl:
6242 * This is basically code dup with s/RSL/rsl from:
6243 * RSL_Emulation.f_chan_est(g_pars.ra, l3_enc, g_pars.link_id, g_pars.fn);
6244 */
6245 var RSL_Message rx_rsl;
6246 var GsmRrMessage rr;
6247
6248 /* request a channel to be established */
6249 rsl.send(ts_RSLDC_ChanRqd(g_pars.ra, g_pars.fn));
6250 /* expect immediate assignment.
6251 * Code dup with s/RSL/rsl from:
6252 * rx_rsl := f_rx_or_fail(tr_RSL_IMM_ASSIGN);
6253 */
6254 timer Tt := 10.0;
6255
6256 /* request a channel to be established */
6257 Tt.start;
6258 alt {
6259 [] rsl.receive(tr_RSL_IMM_ASSIGN) -> value rx_rsl {
6260 Tt.stop;
6261 }
6262 [] rsl.receive {
6263 setverdict(fail, "Unexpected RSL message on DCHAN");
6264 mtc.stop;
6265 }
6266 [] Tt.timeout {
6267 setverdict(fail, "Timeout waiting for RSL on DCHAN");
6268 mtc.stop;
6269 }
6270 }
6271 rr := dec_GsmRrMessage(rx_rsl.ies[1].body.full_imm_ass_info.payload);
6272 g_chan_nr := rr.payload.imm_ass.chan_desc.chan_nr;
6273 rsl.send(ts_RSL_EST_IND(g_chan_nr, valueof(g_pars.link_id), l3_enc));
6274
6275
Neels Hofmeyr66e15092020-10-12 18:44:41 +00006276 if (expect_bssmap_l3) {
6277 f_logp(BSCVTY, "expect BSSAP Complete Layer 3 Info at MSC");
6278 var template PDU_BSSAP exp_l3_compl;
6279 exp_l3_compl := tr_BSSMAP_ComplL3()
6280 if (g_pars.aoip == false) {
6281 exp_l3_compl.pdu.bssmap.completeLayer3Information.codecList := omit;
6282 } else {
6283 exp_l3_compl.pdu.bssmap.completeLayer3Information.codecList := ?;
6284 }
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006285
Neels Hofmeyr66e15092020-10-12 18:44:41 +00006286 var PDU_BSSAP bssap;
6287 T.start;
6288 alt {
6289 [] BSSAP.receive(exp_l3_compl) -> value bssap {
6290 f_logp(BSCVTY, "received expected Complete Layer 3 Info at MSC");
6291 log("rx exp_l3_compl = ", bssap);
6292 }
6293 [] BSSAP.receive(tr_BSSMAP_ComplL3) {
6294 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Received non-matching COMPLETE LAYER 3 INFORMATION");
6295 }
6296 [] T.timeout {
6297 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for COMPLETE LAYER 3 INFORMATION");
6298 }
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006299 }
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006300
Neels Hofmeyr66e15092020-10-12 18:44:41 +00006301 /* start ciphering, if requested */
6302 if (ispresent(g_pars.encr)) {
6303 f_logp(BSCVTY, "start ciphering");
6304 f_cipher_mode(g_pars.encr.enc_alg, g_pars.encr.enc_key);
6305 }
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006306 }
6307
6308 if (do_clear) {
6309 f_perform_clear(rsl);
6310 }
6311 setverdict(pass);
6312 f_sleep(1.0);
6313}
6314
6315private function f_tc_mscpool_compl_l3(charstring id) runs on MSC_ConnHdlr {
6316 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
6317 if (g_pars.mscpool.rsl_idx == 0) {
6318 f_perform_compl_l3(RSL, g_pars.mscpool.l3_info);
6319 } else if (g_pars.mscpool.rsl_idx == 1) {
6320 f_perform_compl_l3(RSL1, g_pars.mscpool.l3_info);
6321 } else if (g_pars.mscpool.rsl_idx == 2) {
6322 f_perform_compl_l3(RSL2, g_pars.mscpool.l3_info);
6323 }
6324}
6325
6326/* Various Complete Layer 3 by IMSI all end up with the first MSC, because the other MSCs are not connected. */
6327private function f_tc_mscpool_L3Compl_on_1_msc(charstring id) runs on MSC_ConnHdlr {
6328 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
6329 f_perform_compl_l3(RSL, ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_IMSI_LV('001010000000001'H)), '00F110'O) );
6330 f_perform_compl_l3(RSL, ts_CM_SERV_REQ(CM_TYPE_MO_SMS, valueof(ts_MI_IMSI_LV('001010000000002'H))) );
6331 f_perform_compl_l3(RSL, ts_PAG_RESP(valueof(ts_MI_IMSI_LV('001010000000003'H))) );
6332 f_perform_compl_l3(RSL, ts_ML3_MO_MM_IMSI_DET_Ind(valueof(ts_MI_IMSI_LV('001010000000004'H))) );
6333}
6334testcase TC_mscpool_L3Compl_on_1_msc() runs on test_CT {
6335
6336 f_init(1, true);
6337 f_sleep(1.0);
6338 var MSC_ConnHdlr vc_conn;
6339 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006340
6341 f_ctrs_msc_init();
6342
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006343 vc_conn := f_start_handler(refers(f_tc_mscpool_L3Compl_on_1_msc), pars);
6344 vc_conn.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006345
6346 f_ctrs_msc_expect(0, "mscpool:subscr:new", 4);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006347 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006348}
6349
6350/* Three Layer 3 Complete by IMSI are round-robin'ed across two connected MSCs */
6351/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
6352 * just as well using only RSL. */
6353testcase TC_mscpool_L3Complete_by_imsi_round_robin() runs on test_CT {
6354
6355 f_init(nr_bts := 3, handler_mode := true, nr_msc := 2);
6356 f_sleep(1.0);
6357
6358 /* Control which MSC gets chosen next by the round-robin, otherwise
6359 * would be randomly affected by which other tests ran before this. */
6360 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
6361
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006362 f_ctrs_msc_init();
6363
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006364 var MSC_ConnHdlr vc_conn1;
6365 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
6366 pars1.mscpool.rsl_idx := 0;
6367 pars1.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_IMSI_LV('001010000000001'H)), '00F110'O));
6368 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6369 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006370 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006371
6372 var MSC_ConnHdlr vc_conn2;
6373 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 1);
6374 pars2.mscpool.rsl_idx := 1;
6375 pars2.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, valueof(ts_MI_IMSI_LV('001010000000002'H))));
6376 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6377 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006378 f_ctrs_msc_expect(1, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006379
6380 /* Test round-robin wrap to the first MSC */
6381 var MSC_ConnHdlr vc_conn3;
6382 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 0);
6383 pars3.mscpool.rsl_idx := 2;
6384 pars3.mscpool.l3_info := valueof(ts_PAG_RESP(valueof(ts_MI_IMSI_LV('001010000000003'H))));
6385 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
6386 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006387 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006388 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006389}
6390
6391/* Three LU by TMSI are round-robin'ed across two connected MSCs, because they contain the NULL-NRI 0
6392 * (configured in osmo-bsc.cfg). */
6393/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
6394 * just as well using only RSL. */
6395testcase TC_mscpool_LU_by_tmsi_null_nri_0_round_robin() runs on test_CT {
6396
6397 f_init(nr_bts := 3, handler_mode := true, nr_msc := 2);
6398 f_sleep(1.0);
6399
6400 /* Control which MSC gets chosen next by the round-robin, otherwise
6401 * would be randomly affected by which other tests ran before this. */
6402 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
6403
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006404 f_ctrs_msc_init();
6405
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006406 var MSC_ConnHdlr vc_conn1;
6407 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
6408 pars1.mscpool.rsl_idx := 0;
6409 pars1.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(0)), '00F110'O));
6410 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6411 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006412 f_ctrs_msc_expect(0, "mscpool:subscr:reattach");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006413
6414 var MSC_ConnHdlr vc_conn2;
6415 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 1);
6416 pars2.mscpool.rsl_idx := 1;
6417 pars2.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(0)), '00F110'O));
6418 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6419 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006420 f_ctrs_msc_expect(1, "mscpool:subscr:reattach");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006421
6422 /* Test round-robin wrap to the first MSC */
6423 var MSC_ConnHdlr vc_conn3;
6424 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 0);
6425 pars3.mscpool.rsl_idx := 2;
6426 pars3.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(0)), '00F110'O));
6427 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
6428 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006429 f_ctrs_msc_expect(0, "mscpool:subscr:reattach");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006430 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006431}
6432
6433/* Three LU by TMSI are round-robin'ed across two connected MSCs, because they contain the NULL-NRI 1
6434 * (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
6435 * NULL-NRI setting is stronger than that. */
6436/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
6437 * just as well using only RSL. */
6438testcase TC_mscpool_LU_by_tmsi_null_nri_1_round_robin() runs on test_CT {
6439
6440 f_init(nr_bts := 3, handler_mode := true, nr_msc := 2);
6441 f_sleep(1.0);
6442
6443 /* Control which MSC gets chosen next by the round-robin, otherwise
6444 * would be randomly affected by which other tests ran before this. */
6445 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
6446
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006447 f_ctrs_msc_init();
6448
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006449 var MSC_ConnHdlr vc_conn1;
6450 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
6451 pars1.mscpool.rsl_idx := 0;
6452 pars1.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(1)), '00F110'O));
6453 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6454 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006455 f_ctrs_msc_expect(0, "mscpool:subscr:reattach");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006456
6457 var MSC_ConnHdlr vc_conn2;
6458 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 1);
6459 pars2.mscpool.rsl_idx := 1;
6460 pars2.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(1)), '00F110'O));
6461 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6462 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006463 f_ctrs_msc_expect(1, "mscpool:subscr:reattach");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006464
6465 /* Test round-robin wrap to the first MSC */
6466 var MSC_ConnHdlr vc_conn3;
6467 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 0);
6468 pars3.mscpool.rsl_idx := 2;
6469 pars3.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(1)), '00F110'O));
6470 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
6471 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006472 f_ctrs_msc_expect(0, "mscpool:subscr:reattach");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006473 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006474}
6475
6476/* Three Layer 3 Complete by TMSI are round-robin'ed across two connected MSCs, because they contain an NRI not
6477 * assigned to any MSC (configured in osmo-bsc.cfg). */
6478/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
6479 * just as well using only RSL. */
6480testcase TC_mscpool_L3Complete_by_tmsi_unassigned_nri_round_robin() runs on test_CT {
6481
6482 f_init(nr_bts := 3, handler_mode := true, nr_msc := 2);
6483 f_sleep(1.0);
6484
6485 /* Control which MSC gets chosen next by the round-robin, otherwise
6486 * would be randomly affected by which other tests ran before this. */
6487 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
6488
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006489 f_ctrs_msc_init();
6490
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006491 var MSC_ConnHdlr vc_conn1;
6492 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
6493 pars1.mscpool.rsl_idx := 0;
6494 /* An NRI that is not assigned to any MSC */
6495 pars1.mscpool.l3_info := valueof(ts_ML3_MO_MM_IMSI_DET_Ind(valueof(ts_MI_TMSI_NRI_LV(1023))));
6496 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6497 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006498 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006499
6500 var MSC_ConnHdlr vc_conn2;
6501 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 1);
6502 pars2.mscpool.rsl_idx := 1;
6503 /* An NRI that is not assigned to any MSC */
6504 pars2.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(768)), '00F110'O));
6505 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6506 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006507 f_ctrs_msc_expect(1, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006508
6509 /* Test round-robin wrap to the first MSC */
6510 var MSC_ConnHdlr vc_conn3;
6511 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 0);
6512 pars3.mscpool.rsl_idx := 2;
6513 /* An NRI that is not assigned to any MSC */
6514 pars3.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_SS_ACT, valueof(ts_MI_TMSI_NRI_LV(819))));
6515 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
6516 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006517 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006518 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006519}
6520
6521/* Three Layer 3 Complete by TMSI are round-robin'ed across two connected MSCs, because they contain an NRI
6522 * assigned to an MSC that is currently not connected (configured in osmo-bsc.cfg). */
6523/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
6524 * just as well using only RSL. */
6525testcase TC_mscpool_L3Complete_by_tmsi_valid_nri_msc_not_connected_round_robin() runs on test_CT {
6526
6527 f_init(nr_bts := 3, handler_mode := true, nr_msc := 2);
6528 f_sleep(1.0);
6529
6530 /* Control which MSC gets chosen next by the round-robin, otherwise
6531 * would be randomly affected by which other tests ran before this. */
6532 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
6533
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006534 f_ctrs_msc_init();
6535
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006536 var MSC_ConnHdlr vc_conn1;
6537 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
6538 pars1.mscpool.rsl_idx := 0;
6539 /* An NRI that is assigned to an unconnected MSC */
6540 pars1.mscpool.l3_info := valueof(ts_PAG_RESP(valueof(ts_MI_TMSI_NRI_LV(512))));
6541 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6542 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006543 f_ctrs_msc_add(2, "mscpool:subscr:attach_lost");
6544 f_ctrs_msc_add(0, "mscpool:subscr:new");
6545 f_ctrs_msc_verify();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006546
6547 var MSC_ConnHdlr vc_conn2;
6548 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 1);
6549 pars2.mscpool.rsl_idx := 1;
6550 /* An NRI that is assigned to an unconnected MSC */
6551 pars2.mscpool.l3_info := valueof(ts_ML3_MO_MM_IMSI_DET_Ind(valueof(ts_MI_TMSI_NRI_LV(767))));
6552 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6553 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006554 f_ctrs_msc_add(2, "mscpool:subscr:attach_lost");
6555 f_ctrs_msc_add(1, "mscpool:subscr:new");
6556 f_ctrs_msc_verify();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006557
6558 /* Test round-robin wrap to the first MSC */
6559 var MSC_ConnHdlr vc_conn3;
6560 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 0);
6561 pars3.mscpool.rsl_idx := 2;
6562 /* An NRI that is assigned to an unconnected MSC */
6563 pars3.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(750)), '00F110'O));
6564 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
6565 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006566 f_ctrs_msc_add(2, "mscpool:subscr:attach_lost");
6567 f_ctrs_msc_add(0, "mscpool:subscr:new");
6568 f_ctrs_msc_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006569 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006570}
6571
6572/* Three Layer 3 Complete by TMSI with valid NRI for the second MSC are all directed to the second MSC (configured in
6573 * osmo-bsc.cfg). */
6574/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
6575 * just as well using only RSL. */
6576testcase TC_mscpool_L3Complete_by_tmsi_valid_nri_1() runs on test_CT {
6577
6578 f_init(nr_bts := 3, handler_mode := true, nr_msc := 2);
6579 f_sleep(1.0);
6580
6581 /* All TMSIs in this test point at the second MSC, set the round robin to point at the first MSC to make sure
6582 * this is not using round-robin. */
6583 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
6584
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006585 f_ctrs_msc_init();
6586
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006587 var MSC_ConnHdlr vc_conn1;
6588 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 1);
6589 pars1.mscpool.rsl_idx := 0;
6590 /* An NRI of the second MSC's range (256-511) */
6591 pars1.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_SMS, valueof(ts_MI_TMSI_NRI_LV(256))));
6592 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6593 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006594 f_ctrs_msc_expect(1, "mscpool:subscr:known");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006595
6596 var MSC_ConnHdlr vc_conn2;
6597 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 1);
6598 pars2.mscpool.rsl_idx := 1;
6599 /* An NRI of the second MSC's range (256-511) */
6600 pars2.mscpool.l3_info := valueof(ts_PAG_RESP(valueof(ts_MI_TMSI_NRI_LV(260))));
6601 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6602 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006603 f_ctrs_msc_expect(1, "mscpool:subscr:known");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006604
6605 var MSC_ConnHdlr vc_conn3;
6606 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 1);
6607 pars3.mscpool.rsl_idx := 2;
6608 /* An NRI of the second MSC's range (256-511) */
6609 pars3.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(511)), '00F110'O));
6610 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
6611 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006612 f_ctrs_msc_expect(1, "mscpool:subscr:known");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006613 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006614}
6615
6616/* Layer 3 Complete by TMSI with valid NRI for the third MSC are directed to the third MSC (configured in osmo-bsc.cfg),
6617 * while a round-robin remains unaffected by that. */
6618/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
6619 * just as well using only RSL. */
6620testcase TC_mscpool_L3Complete_by_tmsi_valid_nri_2() runs on test_CT {
6621
6622 f_init(nr_bts := 3, handler_mode := true, nr_msc := 3);
6623 f_sleep(1.0);
6624
6625 /* All TMSIs in this test point at the third MSC, set the round robin to point at the second MSC to make sure
6626 * this is not using round-robin. */
6627 f_vty_transceive(BSCVTY, "mscpool roundrobin next 1");
6628
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006629 f_ctrs_msc_init();
6630
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006631 var MSC_ConnHdlr vc_conn1;
6632 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 2);
6633 pars1.mscpool.rsl_idx := 0;
6634 /* An NRI of the third MSC's range (512-767) */
6635 pars1.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_SMS, valueof(ts_MI_TMSI_NRI_LV(512))));
6636 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6637 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006638 f_ctrs_msc_expect(2, "mscpool:subscr:known");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006639
6640 var MSC_ConnHdlr vc_conn2;
6641 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 2);
6642 pars2.mscpool.rsl_idx := 1;
6643 /* An NRI of the third MSC's range (512-767) */
6644 pars2.mscpool.l3_info := valueof(ts_PAG_RESP(valueof(ts_MI_TMSI_NRI_LV(678))));
6645 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6646 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006647 f_ctrs_msc_expect(2, "mscpool:subscr:known");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006648
6649 /* The above forwardings to third MSC have not affected the round robin, which still points at the second MSC */
6650 var MSC_ConnHdlr vc_conn3;
6651 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 1);
6652 pars3.mscpool.rsl_idx := 2;
6653 pars3.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_IMSI_LV('001010000000013'H)), '00F110'O));
6654 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
6655 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006656 f_ctrs_msc_expect(1, "mscpool:subscr:new");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006657 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006658}
6659
6660/* LU with a TMSI but indicating a different PLMN in its previous LAI: ignore the NRI. */
6661/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
6662 * just as well using only RSL. */
6663testcase TC_mscpool_LU_by_tmsi_from_other_PLMN() runs on test_CT {
6664
6665 f_init(nr_bts := 3, handler_mode := true, nr_msc := 3);
6666 f_sleep(1.0);
6667
6668 /* The TMSIs in this test points at the second MSC, but since it is from a different PLMN, round-robin is used
6669 * instead, and hits msc 0. */
6670 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
6671
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006672 f_ctrs_msc_init();
6673
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006674 /* An NRI of the second MSC's range (256-511), but a PLMN that doesn't match with osmo-bsc.cfg */
6675 var MSC_ConnHdlr vc_conn1;
6676 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
6677 pars1.mscpool.rsl_idx := 0;
6678 pars1.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(260)), '99F999'O));
6679 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6680 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006681 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006682
6683 /* An NRI of the third MSC's range (512-767) and a matching PLMN gets directed by NRI. */
6684 var MSC_ConnHdlr vc_conn2;
6685 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 2);
6686 pars2.mscpool.rsl_idx := 1;
6687 pars2.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(555)), '00F110'O));
6688 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6689 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006690 f_ctrs_msc_expect(2, "mscpool:subscr:known");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006691 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006692}
6693
6694/* Make sure that whichever MSC paged a subscriber will also get the Paging Response. Page by IMSI, which would be
6695 * round-robined to another MSC, to make sure the Paging->Response relation is stronger than the NRI->MSC mapping. */
6696private function f_tc_mscpool_paging_imsi(charstring id) runs on MSC_ConnHdlr {
6697 var template BSSMAP_FIELD_CellIdentificationList cid_list := { cIl_CI := { ts_BSSMAP_CI_CI(0) } };
6698 //cid_list := { cIl_allInBSS := ''O };
6699 var RSL_ChanNeeded rsl_chneed := RSL_CHANNEED_SDCCH;
6700 var template BSSMAP_IE_ChannelNeeded bssmap_chneed := ts_BSSMAP_IE_ChanNeeded(int2bit(enum2int(valueof(rsl_chneed)),2));
6701 var BSSAP_N_UNITDATA_req paging;
6702 var hexstring imsi := '001010000000123'H;
6703
6704 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
6705
Neels Hofmeyr90f80962020-06-12 16:16:55 +02006706 paging := valueof(ts_BSSAP_UNITDATA_req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006707 valueof(ts_BSSMAP_Paging(imsi, cid_list, omit, bssmap_chneed))));
6708 BSSAP.send(paging);
6709
6710 /* Register any RSL conn so that the Paging Command gets received here. With the current RSL_Emulation's main()
6711 * handling of '[bts_role] IPA_PT.receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD()))' it doesn't matter at all which
6712 * channel number is picked here. */
6713 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(0, RSL_CHAN_NR_INVALID));
6714 f_rslem_register(0, new_chan_nr);
6715 RSL.receive(tr_RSL_PAGING_CMD(tr_MI_IMSI(imsi)));
6716 f_rslem_unregister(0, new_chan_nr);
6717
6718 /* Despite the round robin pointing at the second MSC ('roundrobin next 1'), the earlier Paging for the same IMSI
6719 * causes this Paging Response to go to the first MSC (bssap_idx := 0). */
6720 f_perform_compl_l3(RSL, ts_PAG_RESP(valueof(ts_MI_IMSI_LV(imsi))) );
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006721 f_sleep(1.0);
6722}
6723testcase TC_mscpool_paging_and_response_imsi() runs on test_CT {
6724 f_init(nr_bts := 1, handler_mode := true, nr_msc := 3);
6725 f_sleep(1.0);
6726
6727 /* Testing a Paging on the first MSC to get a Paging Response back to the first MSC. Set round robin to the
6728 * second MSC to make sure we're getting the Paging logic, not a coincidental round robin match. */
6729 f_vty_transceive(BSCVTY, "mscpool roundrobin next 1");
6730
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006731 f_ctrs_msc_init();
6732
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006733 var MSC_ConnHdlr vc_conn1;
6734 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
6735 pars1.mscpool.rsl_idx := 0;
Neels Hofmeyr90f80962020-06-12 16:16:55 +02006736 pars1.sccp_addr_bsc := g_bssap[pars1.mscpool.bssap_idx].sccp_addr_peer;
6737 pars1.sccp_addr_msc := g_bssap[pars1.mscpool.bssap_idx].sccp_addr_own;
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006738 vc_conn1 := f_start_handler(refers(f_tc_mscpool_paging_imsi), pars1);
6739 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006740 f_ctrs_msc_expect(0, "mscpool:subscr:paged");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006741 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006742}
6743
6744/* Make sure that whichever MSC paged a subscriber will also get the Paging Response. Page by TMSI with an NRI value
6745 * that matches a different MSC, to make sure the Paging->Response relation is stronger than the NRI->MSC mapping. */
6746private function f_tc_mscpool_paging_tmsi(charstring id) runs on MSC_ConnHdlr {
6747 var template BSSMAP_FIELD_CellIdentificationList cid_list := { cIl_CI := { ts_BSSMAP_CI_CI(0) } };
6748 //cid_list := { cIl_allInBSS := ''O };
6749 var RSL_ChanNeeded rsl_chneed := RSL_CHANNEED_SDCCH;
6750 var template BSSMAP_IE_ChannelNeeded bssmap_chneed := ts_BSSMAP_IE_ChanNeeded(int2bit(enum2int(valueof(rsl_chneed)),2));
6751 var integer nri_v := 300; /* <-- second MSC's NRI */
6752 var octetstring tmsi := f_tmsi_nri(nri_v);
6753 var BSSAP_N_UNITDATA_req paging;
6754
6755 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
6756
Neels Hofmeyr90f80962020-06-12 16:16:55 +02006757 paging := valueof(ts_BSSAP_UNITDATA_req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006758 valueof(ts_BSSMAP_Paging('001010000000011'H, cid_list, tmsi, bssmap_chneed))));
6759 BSSAP.send(paging);
6760
6761 /* Register any RSL conn so that the Paging Command gets received here. With the current RSL_Emulation's main()
6762 * handling of '[bts_role] IPA_PT.receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD()))' it doesn't matter at all which
6763 * channel number is picked here. */
6764 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(0, RSL_CHAN_NR_INVALID));
6765 f_rslem_register(0, new_chan_nr);
6766 RSL.receive(tr_RSL_PAGING_CMD(t_MI_TMSI(tmsi)));
6767 f_rslem_unregister(0, new_chan_nr);
6768
6769 /* Despite the NRI matching the second MSC (NRI from 'msc 1' in osmo-bsc.cfg) and round robin pointing at the
6770 * third MSC ('roundrobin next 2'), the earlier Paging for the same TMSI causes this Paging Response to go to
6771 * the first MSC (bssap_idx := 0). */
6772 f_perform_compl_l3(RSL, ts_PAG_RESP(valueof(ts_MI_TMSI_NRI_LV(nri_v))) );
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006773 f_sleep(1.0);
6774}
6775testcase TC_mscpool_paging_and_response_tmsi() runs on test_CT {
6776 f_init(nr_bts := 1, handler_mode := true, nr_msc := 3);
6777 f_sleep(1.0);
6778
6779 /* Testing a Paging on the first MSC to get a Paging Response back to the first MSC. Set round robin to the
6780 * third MSC to make sure we're getting the Paging logic, not a coincidental round robin match. */
6781 f_vty_transceive(BSCVTY, "mscpool roundrobin next 2");
6782
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006783 f_ctrs_msc_init();
6784
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006785 var MSC_ConnHdlr vc_conn1;
6786 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
6787 pars1.mscpool.rsl_idx := 0;
Neels Hofmeyr90f80962020-06-12 16:16:55 +02006788 pars1.sccp_addr_bsc := g_bssap[pars1.mscpool.bssap_idx].sccp_addr_peer;
6789 pars1.sccp_addr_msc := g_bssap[pars1.mscpool.bssap_idx].sccp_addr_own;
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006790 vc_conn1 := f_start_handler(refers(f_tc_mscpool_paging_tmsi), pars1);
6791 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006792 f_ctrs_msc_expect(0, "mscpool:subscr:paged");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006793 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006794}
6795
6796/* For round-robin, skip an MSC that has 'no allow-attach' set. */
6797/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
6798 * just as well using only RSL. */
6799testcase TC_mscpool_no_allow_attach_round_robin() runs on test_CT {
6800
6801 f_init(nr_bts := 3, handler_mode := true, nr_msc := 3);
6802 f_sleep(1.0);
Neels Hofmeyra460f1f2020-08-09 20:17:03 +00006803 /* Mark the second MSC as offloading, round-robin should skip this MSC now. */
6804 f_vty_msc_allow_attach(BSCVTY, {true, false, true});
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006805
6806 /* Control which MSC gets chosen next by the round-robin, otherwise
6807 * would be randomly affected by which other tests ran before this. */
6808 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
6809
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006810 f_ctrs_msc_init();
6811
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006812 var MSC_ConnHdlr vc_conn1;
6813 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
6814 pars1.mscpool.rsl_idx := 0;
6815 pars1.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_IMSI_LV('001010000000001'H)), '00F110'O));
6816 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6817 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006818 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006819
6820 var MSC_ConnHdlr vc_conn2;
6821 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 2);
6822 pars2.mscpool.rsl_idx := 1;
6823 pars2.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, valueof(ts_MI_IMSI_LV('001010000000002'H))));
6824 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6825 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006826 f_ctrs_msc_expect(2, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006827
6828 var MSC_ConnHdlr vc_conn3;
6829 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 0);
6830 pars3.mscpool.rsl_idx := 2;
6831 pars3.mscpool.l3_info := valueof(ts_PAG_RESP(valueof(ts_MI_IMSI_LV('001010000000003'H))));
6832 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
6833 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006834 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006835 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006836}
6837
6838/* An MSC that has 'no allow-attach' set should still serve subscribers that are already attached according to their
6839 * TMSI NRI. */
6840testcase TC_mscpool_no_allow_attach_valid_nri() runs on test_CT {
6841
6842 f_init(nr_bts := 3, handler_mode := true, nr_msc := 3);
6843 f_sleep(1.0);
6844
Neels Hofmeyra460f1f2020-08-09 20:17:03 +00006845 /* Mark the second MSC as offloading, round-robin should skip this MSC now. */
6846 f_vty_msc_allow_attach(BSCVTY, {true, false, true});
6847
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006848 /* Control which MSC gets chosen next by the round-robin, otherwise
6849 * would be randomly affected by which other tests ran before this. */
6850 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
6851
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006852 f_ctrs_msc_init();
6853
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006854 /* Round robin points at msc 0, but the valid NRI directs to msc 1, even though msc 1 has 'no allow-attach'. */
6855 var MSC_ConnHdlr vc_conn1;
6856 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 1);
6857 pars1.mscpool.rsl_idx := 0;
6858 /* An NRI of the second MSC's range (256-511) */
6859 pars1.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, valueof(ts_MI_TMSI_NRI_LV(260))));
6860 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6861 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006862 f_ctrs_msc_expect(1, "mscpool:subscr:known");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006863
6864 var MSC_ConnHdlr vc_conn2;
6865 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 0);
6866 pars2.mscpool.rsl_idx := 1;
6867 pars2.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, valueof(ts_MI_IMSI_LV('001010000000002'H))));
6868 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6869 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006870 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006871
6872 var MSC_ConnHdlr vc_conn3;
6873 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 2);
6874 pars3.mscpool.rsl_idx := 2;
6875 pars3.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, valueof(ts_MI_IMSI_LV('001010000000003'H))));
6876 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
6877 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006878 f_ctrs_msc_expect(2, "mscpool:subscr:new");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006879 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006880}
6881
Philipp Maier783681c2020-07-16 16:47:06 +02006882/* Allow/Deny emergency calls globally via VTY */
6883private function f_vty_allow_emerg_msc(boolean allow) runs on test_CT {
6884 f_vty_enter_cfg_msc(BSCVTY, 0);
6885 if (allow) {
6886 f_vty_transceive(BSCVTY, "allow-emergency allow");
6887 } else {
6888 f_vty_transceive(BSCVTY, "allow-emergency deny");
6889 }
6890 f_vty_transceive(BSCVTY, "exit");
6891 f_vty_transceive(BSCVTY, "exit");
6892}
6893
6894/* Allow/Deny emergency calls per BTS via VTY */
6895private function f_vty_allow_emerg_bts(boolean allow, integer bts_nr) runs on test_CT {
6896 f_vty_enter_cfg_bts(BSCVTY, bts_nr);
6897 if (allow) {
6898 f_vty_transceive(BSCVTY, "rach emergency call allowed 1");
6899 } else {
6900 f_vty_transceive(BSCVTY, "rach emergency call allowed 0");
6901 }
6902 f_vty_transceive(BSCVTY, "exit");
6903 f_vty_transceive(BSCVTY, "exit");
Neels Hofmeyrb6ed80c2020-10-12 22:52:39 +00006904 f_vty_transceive(BSCVTY, "exit");
Philipp Maier783681c2020-07-16 16:47:06 +02006905}
6906
6907/* Begin assignmet procedure and send an EMERGENCY SETUP (RR) */
6908private function f_assignment_emerg_setup() runs on MSC_ConnHdlr {
6909 var PDU_ML3_MS_NW emerg_setup;
6910 var octetstring emerg_setup_enc;
6911 var RSL_Message emerg_setup_data_ind;
6912
6913 f_establish_fully(omit, omit);
6914
6915 emerg_setup := valueof(ts_ML3_MO_CC_EMERG_SETUP(1, valueof(ts_Bcap_voice)));
6916 emerg_setup_enc := enc_PDU_ML3_MS_NW(emerg_setup);
6917 emerg_setup_data_ind := valueof(ts_RSL_DATA_IND(g_chan_nr, valueof(ts_RslLinkID_DCCH(0)), emerg_setup_enc));
6918
6919 RSL.send(emerg_setup_data_ind);
6920}
6921
6922/* Test if the EMERGENCY SETUP gets passed on to the MSC via A when EMERGENCY
6923 * CALLS are permitted by the BSC config. */
6924private function f_TC_assignment_emerg_setup_allow(charstring id) runs on MSC_ConnHdlr {
6925 var PDU_BSSAP emerg_setup_data_ind_bssap;
6926 var PDU_ML3_MS_NW emerg_setup;
6927 timer T := 3.0;
6928
6929 f_assignment_emerg_setup()
6930
6931 T.start;
6932 alt {
6933 [] BSSAP.receive(tr_BSSAP_DTAP) -> value emerg_setup_data_ind_bssap {
6934 emerg_setup := dec_PDU_ML3_MS_NW(emerg_setup_data_ind_bssap.pdu.dtap);
6935 if (not isbound(emerg_setup.msgs.cc.emergencySetup)) {
6936 setverdict(fail, "no emergency setup");
6937 }
6938 }
6939 [] BSSAP.receive {
6940 setverdict(fail, "unexpected BSSAP message!");
6941 }
6942 [] T.timeout {
6943 setverdict(fail, "timout waiting for EMERGENCY SETUP!");
6944 }
6945 }
6946
6947 setverdict(pass);
6948}
6949
6950/* Test if the EMERGENCY SETUP gets blocked by the BSC if EMERGENCY CALLS are
6951 * forbidden by the BSC config. */
6952private function f_TC_assignment_emerg_setup_deny(charstring id) runs on MSC_ConnHdlr {
6953 var PDU_BSSAP emerg_setup_data_ind_bssap;
6954 timer T := 3.0;
6955
6956 f_assignment_emerg_setup()
6957
6958 T.start;
6959 alt {
6960 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_RELEASE)) {
6961 setverdict(pass);
6962 }
6963 [] RSL.receive {
6964 setverdict(fail, "unexpected RSL message!");
6965 }
6966 [] T.timeout {
6967 setverdict(fail, "timout waiting for RR CHANNEL RELEASE!");
6968 }
6969 }
6970}
6971
6972/* EMERGENCY CALL situation #1, allowed globally and by BTS */
6973testcase TC_assignment_emerg_setup_allow() runs on test_CT {
6974 var TestHdlrParams pars := f_gen_test_hdlr_pars();
6975 var MSC_ConnHdlr vc_conn;
6976
6977 f_init(1, true);
6978 f_sleep(1.0);
6979
6980 f_vty_allow_emerg_msc(true);
6981 f_vty_allow_emerg_bts(true, 0);
6982 vc_conn := f_start_handler(refers(f_TC_assignment_emerg_setup_allow), pars);
6983 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006984 f_shutdown_helper();
Philipp Maier783681c2020-07-16 16:47:06 +02006985}
6986
6987/* EMERGENCY CALL situation #2, forbidden globally but allowed by BTS */
6988testcase TC_assignment_emerg_setup_deny_msc() runs on test_CT {
6989 var TestHdlrParams pars := f_gen_test_hdlr_pars();
6990 var MSC_ConnHdlr vc_conn;
6991
6992 f_init(1, true);
6993 f_sleep(1.0);
6994
6995 f_vty_allow_emerg_msc(false);
6996 f_vty_allow_emerg_bts(true, 0);
6997 vc_conn := f_start_handler(refers(f_TC_assignment_emerg_setup_deny), pars);
6998 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006999 f_shutdown_helper();
Philipp Maier783681c2020-07-16 16:47:06 +02007000}
7001
7002/* EMERGENCY CALL situation #3, allowed globally but forbidden by BTS */
7003testcase TC_assignment_emerg_setup_deny_bts() runs on test_CT {
7004 var TestHdlrParams pars := f_gen_test_hdlr_pars();
7005 var MSC_ConnHdlr vc_conn;
7006
7007 /* Note: This simulates a spec violation by the MS, correct MS
7008 * implementations would not try to establish an emergency call because
7009 * the system information tells in advance that emergency calls are
7010 * not forbidden */
7011
7012 f_init(1, true);
7013 f_sleep(1.0);
7014
7015 f_vty_allow_emerg_msc(true);
7016 f_vty_allow_emerg_bts(false, 0);
7017 vc_conn := f_start_handler(refers(f_TC_assignment_emerg_setup_deny), pars);
7018 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007019 f_shutdown_helper();
Philipp Maier783681c2020-07-16 16:47:06 +02007020}
7021
Philipp Maier82812002020-08-13 18:48:27 +02007022/* Test what happens when an emergency call arrives while all TCH channels are
7023 * busy, the BSC is expected to terminate one call in favor of the incoming
7024 * emergency call */
7025testcase TC_emerg_premption() runs on test_CT {
7026 var ASP_RSL_Unitdata rsl_ud;
7027 var integer i;
7028 var integer chreq_total, chreq_nochan;
7029 var RSL_Message rx_rsl;
7030 var RslChannelNr chan_nr;
7031
7032 f_init(1);
7033 f_sleep(1.0);
7034
7035 f_vty_allow_emerg_msc(true);
7036 f_vty_allow_emerg_bts(true, 0);
7037
7038 /* Fill up all channels on the BTS */
7039 chreq_total := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total");
7040 chreq_nochan := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:no_channel");
7041 for (i := 0; i < NUM_TCHF_PER_BTS + NUM_TCHH_PER_BTS + NUM_SDCCH_PER_BTS; i := i+1) {
7042 chan_nr := f_chreq_act_ack('33'O, i);
7043 }
7044 IPA_RSL[0].clear;
7045 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total",
7046 chreq_total + NUM_TCHF_PER_BTS + NUM_TCHH_PER_BTS + NUM_SDCCH_PER_BTS);
7047
7048 /* Send Channel request for emegergency call */
7049 f_ipa_tx(0, ts_RSL_CHAN_RQD('A5'O, 23));
7050
7051 /* Expect the BSC to release one (the first) TCH/F on the BTS */
7052 chan_nr := valueof(t_RslChanNr_Bm(1));
7053 f_expect_chan_rel(0, chan_nr, expect_rr_chan_rel := false, expect_rll_rel_req := false);
7054
7055 /* Expect the BSC to send activate/assign the a channel for the emergency call */
7056 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
7057 chan_nr := rx_rsl.ies[0].body.chan_nr;
7058 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, 33));
7059 rx_rsl := f_exp_ipa_rx(0, tr_RSL_IMM_ASSIGN(0));
Philipp Maier104f4c02020-09-11 18:12:18 +02007060
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007061 f_shutdown_helper();
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007062}
7063
7064/* Hopping parameters per a timeslot */
Vadim Yanitskiybc6654a2020-09-13 01:27:40 +07007065private type record length(0..64) of GsmArfcn ArfcnList;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007066private type record FHParamsTs {
7067 boolean enabled,
7068 uint6_t hsn,
7069 uint6_t maio,
7070 ArfcnList ma
7071};
7072
7073/* Hopping parameters per a transceiver */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007074private type record FHParamsTrx {
7075 GsmArfcn arfcn,
7076 FHParamsTs ts[8]
7077};
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007078
7079/* Randomly generate the hopping parameters for the given timeslot numbers */
7080private function f_TC_fh_params_gen(template integer tr_tn := (1, 3, 5))
7081runs on test_CT return FHParamsTrx {
7082 var FHParamsTrx fhp;
7083
Vadim Yanitskiy3e997362020-09-05 21:08:34 +07007084 /* Generate a random ARFCN, including ARFCN 0 */
7085 fhp.arfcn := f_rnd_int(3);
Vadim Yanitskiye7c8c6e2020-09-13 14:33:03 +07007086
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007087 for (var integer tn := 0; tn < 8; tn := tn + 1) {
7088 if (not match(tn, tr_tn)) {
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007089 fhp.ts[tn].enabled := false;
7090 fhp.ts[tn].ma := { };
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007091 continue;
7092 }
7093
7094 /* Random HSN / MAIO values: 0..63 */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007095 fhp.ts[tn].hsn := f_rnd_int(64);
7096 fhp.ts[tn].maio := f_rnd_int(64);
7097 fhp.ts[tn].ma := { };
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007098
7099 /* Random Mobile Allocation (hopping channels) */
7100 var integer ma_len := 2 + f_rnd_int(9); /* 2..10 channels */
7101 var integer step := 3 + f_rnd_int(4); /* 3..6 stepping */
7102 for (var integer i := 1; i <= ma_len; i := i + 1) {
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007103 fhp.ts[tn].ma := fhp.ts[tn].ma & { i * step };
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007104 }
7105
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007106 fhp.ts[tn].enabled := true;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007107 }
7108
7109 log("f_TC_fh_params_gen(): ", fhp);
7110 return fhp;
7111}
7112
7113/* Make sure that the given Channel Description IE matches the hopping configuration */
7114private function f_TC_fh_params_match_chan_desc(in FHParamsTrx fhp, in ChannelDescription cd)
7115{
7116 var template (present) ChannelDescription tr_cd;
7117 var template (present) MaioHsn tr_maio_hsn;
7118 var uint3_t tn := cd.chan_nr.tn;
7119
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007120 if (fhp.ts[tn].enabled) {
7121 tr_maio_hsn := tr_HsnMaio(fhp.ts[tn].hsn, fhp.ts[tn].maio);
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007122 tr_cd := tr_ChanDescH1(cd.chan_nr, tr_maio_hsn);
7123 } else {
Vadim Yanitskiye7c8c6e2020-09-13 14:33:03 +07007124 tr_cd := tr_ChanDescH0(cd.chan_nr, fhp.arfcn);
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007125 }
7126
7127 if (not match(cd, tr_cd)) {
7128 setverdict(fail, "Channel Description IE does not match: ",
7129 cd, " vs expected ", tr_cd);
7130 }
7131}
7132
7133/* Make sure that the given Mobile Allocation IE matches the hopping configuration */
7134private function f_TC_fh_params_match_ma(in FHParamsTrx fhp, uint3_t tn,
7135 in MobileAllocationLV ma)
7136{
7137 var template MobileAllocationLV tr_ma := f_TC_fh_params_gen_tr_ma(fhp, tn, ma);
7138
7139 if (not match(ma, tr_ma)) {
7140 setverdict(fail, "Mobile Allocation IE does not match (tn := ",
7141 tn, "): ", ma, " vs expected: ", tr_ma);
7142 } else {
7143 setverdict(pass);
7144 }
7145}
7146
7147private function f_TC_fh_params_gen_tr_ma(in FHParamsTrx fhp, uint3_t tn,
7148 in MobileAllocationLV ma)
7149return template MobileAllocationLV {
7150 /* Mobile Allocation IE is expected to be empty if hopping is not enabled */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007151 if (not fhp.ts[tn].enabled) {
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007152 return { len := 0, ma := ''B };
7153 }
7154
7155 var bitstring full_mask := f_pad_bit(''B, 1024, '0'B);
7156 var bitstring slot_mask := f_pad_bit(''B, 1024, '0'B);
7157 var bitstring ma_mask := ''B;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007158
7159 /* Compose the full bit-mask (all channels, up to 1024 entries) */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007160 for (var integer i := 0; i < lengthof(fhp.ts); i := i + 1) {
7161 for (var integer j := 0; j < lengthof(fhp.ts[i].ma); j := j + 1) {
7162 if (full_mask[fhp.ts[i].ma[j]] == '1'B)
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007163 { continue; }
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007164 full_mask[fhp.ts[i].ma[j]] := '1'B;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007165 }
7166 }
7167
Vadim Yanitskiye7c8c6e2020-09-13 14:33:03 +07007168 /* Take ARFCN of the TRX itself into account */
7169 full_mask[fhp.arfcn] := '1'B;
7170
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007171 /* Compose a bit-mask for the given timeslot number */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007172 for (var integer i := 0; i < lengthof(fhp.ts[tn].ma); i := i + 1) {
7173 slot_mask[fhp.ts[tn].ma[i]] := '1'B;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007174 }
7175
7176 /* Finally, compose the Mobile Allocation bit-mask */
Vadim Yanitskiy3e997362020-09-05 21:08:34 +07007177 for (var integer i := 1; i < lengthof(full_mask); i := i + 1) {
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007178 if (full_mask[i] != '1'B)
7179 { continue; }
7180
7181 /* FIXME: ma_mask := ma_mask & slot_mask[i]; // triggers a bug in TITAN */
7182 if (slot_mask[i] == '1'B) {
7183 ma_mask := ma_mask & '1'B;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007184 } else {
7185 ma_mask := ma_mask & '0'B;
7186 }
7187 }
7188
Vadim Yanitskiy3e997362020-09-05 21:08:34 +07007189 /* ARFCN 0 (if present) goes to the last position of the bit-mask */
7190 if (full_mask[0] == '1'B) {
7191 /* FIXME: ma_mask := ma_mask & slot_mask[0]; // triggers a bug in TITAN */
7192 if (slot_mask[0] == '1'B) {
7193 ma_mask := ma_mask & '1'B;
7194 } else {
7195 ma_mask := ma_mask & '0'B;
7196 }
7197 }
7198
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007199 /* Ensure that ma_mask is octet-aligned */
Vadim Yanitskiy2aa02522020-09-06 14:05:23 +07007200 var integer ma_mask_len := (lengthof(ma_mask) + 8 - 1) / 8;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007201 ma_mask := f_pad_bit(ma_mask, ma_mask_len * 8, '0'B);
7202
7203 return { len := ma_mask_len, ma := ma_mask };
7204}
7205
7206/* Configure the hopping parameters in accordance with the given record */
7207private function f_TC_fh_params_set(in FHParamsTrx fhp,
7208 uint8_t bts_nr := 0,
7209 uint8_t trx_nr := 0)
7210runs on test_CT {
7211 /* Enter the configuration node for the given BTS/TRX numbers */
7212 f_vty_enter_cfg_trx(BSCVTY, bts_nr, trx_nr);
7213
Vadim Yanitskiye7c8c6e2020-09-13 14:33:03 +07007214 f_vty_transceive(BSCVTY, "arfcn " & int2str(fhp.arfcn));
7215
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007216 for (var integer tn := 0; tn < lengthof(fhp.ts); tn := tn + 1) {
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007217 f_vty_transceive(BSCVTY, "timeslot " & int2str(tn));
7218
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007219 if (not fhp.ts[tn].enabled) {
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007220 f_vty_transceive(BSCVTY, "hopping enabled 0");
7221 f_vty_transceive(BSCVTY, "exit"); /* go back */
7222 continue;
7223 }
7224
7225 /* Configure HSN / MAIO values */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007226 f_vty_transceive(BSCVTY, "hopping sequence-number " & int2str(fhp.ts[tn].hsn));
7227 f_vty_transceive(BSCVTY, "hopping maio " & int2str(fhp.ts[tn].maio));
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007228
7229 /* Configure the Mobile Allocation (hopping channels) */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007230 for (var integer i := 0; i < lengthof(fhp.ts[tn].ma); i := i + 1) {
7231 f_vty_transceive(BSCVTY, "hopping arfcn add " & int2str(fhp.ts[tn].ma[i]));
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007232 }
7233
7234 f_vty_transceive(BSCVTY, "hopping enabled 1");
7235 f_vty_transceive(BSCVTY, "exit"); /* go back */
7236 }
7237
7238 f_vty_transceive(BSCVTY, "end");
7239}
7240
7241/* Disable frequency hopping on all timeslots */
7242private function f_TC_fh_params_unset(in FHParamsTrx fhp,
7243 uint8_t bts_nr := 0,
Vadim Yanitskiye7c8c6e2020-09-13 14:33:03 +07007244 uint8_t trx_nr := 0,
7245 GsmArfcn arfcn := 871)
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007246runs on test_CT {
7247 /* Enter the configuration node for the given BTS/TRX numbers */
7248 f_vty_enter_cfg_trx(BSCVTY, bts_nr, trx_nr);
7249
Vadim Yanitskiye7c8c6e2020-09-13 14:33:03 +07007250 f_vty_transceive(BSCVTY, "arfcn " & int2str(arfcn));
7251
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007252 for (var integer tn := 0; tn < lengthof(fhp.ts); tn := tn + 1) {
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007253 f_vty_transceive(BSCVTY, "timeslot " & int2str(tn));
7254
7255 /* Delete all ARFCNs from the Mobile Allocation (if any) */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007256 for (var integer i := 0; i < lengthof(fhp.ts[tn].ma); i := i + 1) {
7257 f_vty_transceive(BSCVTY, "hopping arfcn del " & int2str(fhp.ts[tn].ma[i]));
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007258 }
7259
7260 f_vty_transceive(BSCVTY, "hopping enabled 0");
7261 f_vty_transceive(BSCVTY, "exit"); /* go back */
7262 }
7263
7264 f_vty_transceive(BSCVTY, "end");
7265 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
7266}
7267
7268/* Verify presence and correctness of the hopping parameters (HSN, MAIO)
7269 * in the Channel Identification IE of the RSL CHANnel ACTIVation message. */
7270testcase TC_fh_params_chan_activ() runs on test_CT {
7271 var FHParamsTrx fhp := f_TC_fh_params_gen();
7272 var RSL_Message rsl_msg;
7273 var RSL_IE_Body ie;
7274
7275 f_init_vty();
7276
7277 f_TC_fh_params_set(fhp); /* Enable frequency hopping */
7278 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
7279
7280 f_init(1);
7281
7282 /* CS domain: 3 (SDCCH/4+CBCH) + 4 (TCH/F) + 2 (TCH/H) channels available */
7283 for (var integer i := 0; i < 9; i := i + 1) {
7284 f_ipa_tx(0, ts_RSL_CHAN_RQD(f_rnd_ra_cs(), 23));
7285 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
7286
7287 /* Make sure that Channel Identification IE is present */
7288 if (not f_rsl_find_ie(rsl_msg, RSL_IE_CHAN_IDENT, ie)) {
7289 setverdict(fail, "RSL Channel Identification IE is absent");
7290 continue;
7291 }
7292
7293 /* Make sure that hopping parameters (HSN/MAIO) match */
7294 f_TC_fh_params_match_chan_desc(fhp, ie.chan_ident.ch_desc.v);
7295
7296 /* "Mobile Allocation shall be included but empty" - let's check this */
7297 if (ie.chan_ident.ma.v.len != 0) {
7298 setverdict(fail, "Mobile Allocation IE is not empty: ",
7299 ie.chan_ident.ma, ", despite it shall be");
7300 continue;
7301 }
7302 }
7303
7304 /* Disable frequency hopping */
7305 f_TC_fh_params_unset(fhp);
7306
Vadim Yanitskiy21726312020-09-04 01:45:36 +07007307 f_shutdown_helper();
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007308}
7309
7310/* Verify the hopping parameters (HSN, MAIO, MA) in (RR) Immediate Assignment */
7311testcase TC_fh_params_imm_ass() runs on test_CT {
7312 var FHParamsTrx fhp := f_TC_fh_params_gen();
7313 var RSL_Message rsl_msg;
7314 var RSL_IE_Body ie;
7315
7316 f_init_vty();
7317
7318 f_TC_fh_params_set(fhp); /* Enable frequency hopping */
7319 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
7320
7321 f_init(1);
7322
7323 /* CS domain: 3 (SDCCH/4+CBCH) + 4 (TCH/F) + 2 (TCH/H) channels available */
7324 for (var integer i := 0; i < 9; i := i + 1) {
7325 f_ipa_tx(0, ts_RSL_CHAN_RQD(f_rnd_ra_cs(), 23));
7326 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
7327
7328 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(rsl_msg.ies[0].body.chan_nr, 33));
7329 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeC(RSL_MT_IMMEDIATE_ASSIGN_CMD));
7330
7331 /* Make sure that Full Immediate Assign Info IE is present */
7332 if (not f_rsl_find_ie(rsl_msg, RSL_IE_FULL_IMM_ASS_INFO, ie)) {
7333 setverdict(fail, "RSL Full Immediate Assign Info IE is absent");
7334 continue;
7335 }
7336
7337 /* Decode the actual Immediate Assignment message */
7338 var GsmRrMessage rr_msg := dec_GsmRrMessage(ie.full_imm_ass_info.payload);
7339 if (not match(rr_msg.header, t_RrHeader(IMMEDIATE_ASSIGNMENT, ?))) {
7340 setverdict(fail, "Failed to match Immediate Assignment: ", rr_msg);
7341 continue;
7342 }
7343
7344 /* Make sure that hopping parameters (HSN/MAIO) match */
7345 f_TC_fh_params_match_chan_desc(fhp, rr_msg.payload.imm_ass.chan_desc);
7346
7347 /* Make sure that the Mobile Allocation IE matches */
7348 f_TC_fh_params_match_ma(fhp, rr_msg.payload.imm_ass.chan_desc.chan_nr.tn,
7349 rr_msg.payload.imm_ass.mobile_allocation);
7350 }
7351
7352 /* Disable frequency hopping */
7353 f_TC_fh_params_unset(fhp);
Philipp Maier82812002020-08-13 18:48:27 +02007354
Vadim Yanitskiy21726312020-09-04 01:45:36 +07007355 f_shutdown_helper();
Philipp Maier82812002020-08-13 18:48:27 +02007356}
7357
Vadim Yanitskiyaeb54a22020-09-01 06:25:25 +07007358/* Verify the hopping parameters (HSN, MAIO, MA) in (RR) Assignment Command */
7359testcase TC_fh_params_assignment_cmd() runs on test_CT {
7360 var FHParamsTrx fhp := f_TC_fh_params_gen();
7361 var RSL_Message rsl_msg;
7362 var RSL_IE_Body ie;
7363
7364 f_init_vty();
7365
7366 f_TC_fh_params_set(fhp); /* Enable frequency hopping */
7367 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
7368
7369 f_init(1);
7370
7371 /* HACK: work around "Couldn't find Expect for CRCX" */
7372 vc_MGCP.stop;
7373
7374 var template PDU_BSSAP ass_cmd := f_gen_ass_req();
7375 ass_cmd.pdu.bssmap.assignmentRequest.codecList := ts_BSSMAP_IE_CodecList({ts_CodecFR});
7376
7377 /* CS domain (TCH): 4 (TCH/F) + 2 (TCH/H) channels available
7378 * NOTE: only 3 SDCCH/4 channels are available on CCCH+SDCCH4+CBCH */
7379 for (var integer i := 0; i < 3; i := i + 1) {
7380 /* Establish a dedicated channel, so we can trigger (late) TCH assignment */
7381 var DchanTuple dt := f_est_dchan(f_rnd_ra_cs(), 23, f_rnd_octstring(16));
7382
7383 /* Send a BSSMAP Assignment Command, expect CHANnel ACTIVation */
7384 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ass_cmd));
7385 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
7386
7387 /* ACKnowledge CHANnel ACTIVation, expect RSL DATA REQuest */
7388 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(rsl_msg.ies[0].body.chan_nr, 33));
7389 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeR(RSL_MT_DATA_REQ));
7390
7391 /* Make sure that L3 Information IE is present */
7392 if (not f_rsl_find_ie(rsl_msg, RSL_IE_L3_INFO, ie)) {
7393 setverdict(fail, "RSL L3 Information IE is absent");
7394 continue;
7395 }
7396
7397 /* Decode the L3 message and make sure it is (RR) Assignment Command */
7398 var GsmRrL3Message l3_msg := dec_GsmRrL3Message(ie.l3_info.payload);
7399 if (not match(l3_msg.header, t_RrL3Header(ASSIGNMENT_COMMAND))) {
7400 setverdict(fail, "Failed to match Assignment Command: ", l3_msg);
7401 continue;
7402 }
7403
7404 /* Make sure that hopping parameters (HSN/MAIO) match */
7405 var ChannelDescription chan_desc := l3_msg.payload.ass_cmd.chan_desc;
7406 f_TC_fh_params_match_chan_desc(fhp, chan_desc);
7407
7408 /* Make sure that Cell Channel Description IE is present if FH is enabled */
7409 if (chan_desc.h and not ispresent(l3_msg.payload.ass_cmd.cell_chan_desc)) {
Vadim Yanitskiy38d069d2020-09-02 17:18:57 +07007410 setverdict(fail, "FH enabled, but Cell Channel Description IE is absent");
Vadim Yanitskiyaeb54a22020-09-01 06:25:25 +07007411 continue;
7412 }
7413
7414 /* Make sure that the Mobile Allocation IE matches (if present) */
7415 var boolean ma_present := ispresent(l3_msg.payload.ass_cmd.mobile_allocation);
7416 if (chan_desc.h and ma_present) {
7417 f_TC_fh_params_match_ma(fhp, chan_desc.chan_nr.tn,
7418 l3_msg.payload.ass_cmd.mobile_allocation.v);
7419 } else if (chan_desc.h and not ma_present) {
7420 setverdict(fail, "FH enabled, but Mobile Allocation IE is absent");
7421 continue;
7422 } else if (not chan_desc.h and ma_present) {
7423 setverdict(fail, "FH disabled, but Mobile Allocation IE is present");
7424 continue;
7425 }
7426 }
7427
7428 /* Give the IUT some time to release all channels */
7429 f_sleep(3.0);
7430
7431 /* Disable frequency hopping */
7432 f_TC_fh_params_unset(fhp);
7433
Vadim Yanitskiy21726312020-09-04 01:45:36 +07007434 f_shutdown_helper();
Vadim Yanitskiyaeb54a22020-09-01 06:25:25 +07007435}
7436
Vadim Yanitskiy8f5430d2020-09-02 18:51:38 +07007437/* Verify the hopping parameters (HSN, MAIO, MA) in (RR) Handover Command */
7438private function f_TC_fh_params_handover_cmd(in FHParamsTrx fhp)
7439runs on test_CT {
7440 var RSL_Message rsl_msg;
7441 var RSL_IE_Body ie;
7442 var DchanTuple dt;
7443
7444 /* Establish a dedicated channel, so we can trigger handover */
7445 dt := f_est_dchan(f_rnd_ra_cs(), 23, f_rnd_octstring(16));
7446
7447 /* Trigger handover from BTS0 to BTS1 */
7448 f_bts_0_cfg(BSCVTY, { "neighbor bts 1" });
7449 f_vty_handover(BSCVTY, 0, 0, dt.rsl_chan_nr, 1);
7450
7451 /* Expect RSL CHANnel ACTIVation on BTS1/TRX0/TS1 */
7452 rsl_msg := f_exp_ipa_rx(1, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
7453
7454 /* ACKnowledge channel activation and expect (RR) Handover Command */
7455 f_ipa_tx(1, ts_RSL_CHAN_ACT_ACK(rsl_msg.ies[0].body.chan_nr, 33));
7456 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeR(RSL_MT_DATA_REQ));
7457
7458 /* Make sure that L3 Information IE is present */
7459 if (not f_rsl_find_ie(rsl_msg, RSL_IE_L3_INFO, ie)) {
7460 setverdict(fail, "RSL L3 Information IE is absent");
7461 return;
7462 }
7463
7464 /* Decode the L3 message and make sure it is (RR) Handover Command */
7465 var GsmRrL3Message l3_msg := dec_GsmRrL3Message(ie.l3_info.payload);
7466 if (not match(l3_msg.header, t_RrL3Header(HANDOVER_COMMAND))) {
7467 setverdict(fail, "Failed to match Handover Command: ", l3_msg);
7468 return;
7469 }
7470
7471 /* Make sure that we've got SDCCH/8 on TS1 (expected to be hopping) */
7472 var ChannelDescription chan_desc := l3_msg.payload.ho_cmd.chan_desc;
7473 if (not match(chan_desc.chan_nr, t_RslChanNr_SDCCH8(1, ?))) {
7474 setverdict(fail, "Unexpected channel number: ", chan_desc.chan_nr);
7475 return;
7476 }
7477
7478 /* Make sure that hopping parameters (HSN/MAIO) match */
7479 f_TC_fh_params_match_chan_desc(fhp, chan_desc);
7480
7481 /* Make sure that Cell Channel Description IE is present */
7482 if (not ispresent(l3_msg.payload.ho_cmd.cell_chan_desc)) {
7483 setverdict(fail, "FH enabled, but Cell Channel Description IE is absent");
7484 return;
7485 }
7486
7487 /* Make sure that the Mobile Allocation (after time) IE is present and matches */
7488 var boolean ma_present := ispresent(l3_msg.payload.ho_cmd.mobile_allocation);
7489 if (ma_present) {
7490 f_TC_fh_params_match_ma(fhp, chan_desc.chan_nr.tn,
7491 l3_msg.payload.ho_cmd.mobile_allocation.v);
7492 } else {
7493 setverdict(fail, "FH enabled, but Mobile Allocation IE is absent");
7494 return;
7495 }
7496}
7497testcase TC_fh_params_handover_cmd() runs on test_CT {
7498 var FHParamsTrx fhp := f_TC_fh_params_gen();
7499
7500 f_init_vty();
7501
7502 /* (Re)configure TS0 as BCCH and TS1 as SDCCH8 on BTS1/TRX0 */
7503 f_vty_enter_cfg_trx(BSCVTY, bts := 1, trx := 0);
7504
7505 f_vty_transceive(BSCVTY, "timeslot 0");
7506 f_vty_transceive(BSCVTY, "phys_chan_config ccch");
7507 f_vty_transceive(BSCVTY, "exit"); /* go back */
7508
7509 f_vty_transceive(BSCVTY, "timeslot 1");
7510 f_vty_transceive(BSCVTY, "phys_chan_config sdcch8");
7511 f_vty_transceive(BSCVTY, "end"); /* we're done */
7512
7513 f_TC_fh_params_set(fhp, 1); /* Enable frequency hopping on BTS1 */
7514 f_vty_transceive(BSCVTY, "drop bts connection 1 oml");
7515
7516 f_init(2);
7517
7518 f_TC_fh_params_handover_cmd(fhp);
7519
7520 /* Disable frequency hopping on BTS1 */
7521 f_TC_fh_params_unset(fhp, 1);
7522
7523 /* (Re)configure TS0 as CCCH+SDCCH4+CBCH and TS1 as TCH/F */
7524 f_vty_enter_cfg_trx(BSCVTY, bts := 1, trx := 0);
7525
7526 f_vty_transceive(BSCVTY, "timeslot 0");
7527 f_vty_transceive(BSCVTY, "phys_chan_config ccch+sdcch4+cbch");
7528 f_vty_transceive(BSCVTY, "exit"); /* go back */
7529
7530 f_vty_transceive(BSCVTY, "timeslot 1");
7531 f_vty_transceive(BSCVTY, "phys_chan_config tch/f");
7532 f_vty_transceive(BSCVTY, "end"); /* we're done */
7533
7534 f_shutdown_helper();
7535}
7536
Vadim Yanitskiyca974032020-09-01 07:20:39 +07007537/* Verify the hopping parameters in System Information Type 4 */
7538testcase TC_fh_params_si4_cbch() runs on test_CT {
7539 var FHParamsTrx fhp := f_TC_fh_params_gen(tr_tn := 1);
7540 var ASP_RSL_Unitdata rx_rsl_ud;
7541 timer T := 5.0;
7542
7543 f_init_vty();
7544
7545 /* (Re)configure TS0 as BCCH and TS1 as SDCCH8+CBCH */
7546 f_vty_enter_cfg_trx(BSCVTY, trx := 0);
7547
7548 f_vty_transceive(BSCVTY, "timeslot 0");
7549 f_vty_transceive(BSCVTY, "phys_chan_config ccch");
7550 f_vty_transceive(BSCVTY, "exit"); /* go back */
7551
7552 f_vty_transceive(BSCVTY, "timeslot 1");
7553 f_vty_transceive(BSCVTY, "phys_chan_config sdcch8+cbch");
7554 f_vty_transceive(BSCVTY, "end"); /* we're done */
7555
7556 f_TC_fh_params_set(fhp); /* Enable frequency hopping */
7557 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
7558
7559 f_init(1);
7560
7561 T.start;
7562 alt {
7563 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_BCCH_INFO(RSL_SYSTEM_INFO_4))) -> value rx_rsl_ud {
7564 var RSL_IE_Body ie := rx_rsl_ud.rsl.ies[2].body; /* FULL BCCH Information IE */
7565 var SystemInformation si := dec_SystemInformation(ie.other.payload);
7566
7567 /* Make sure that what we decoded is System Information Type 4 */
7568 if (si.header.message_type != SYSTEM_INFORMATION_TYPE_4) {
7569 setverdict(fail, "RSL FULL BCCH Information IE contains: ", si);
7570 repeat;
7571 }
7572
7573 /* Make sure that CBCH Channel Description IE is present */
7574 if (not ispresent(si.payload.si4.cbch_chan_desc)) {
7575 setverdict(fail, "CBCH Channel Description IE is absent");
7576 break;
7577 }
7578
7579 /* Finally, check the hopping parameters (HSN, MAIO) */
7580 var ChannelDescription chan_desc := si.payload.si4.cbch_chan_desc.v;
7581 f_TC_fh_params_match_chan_desc(fhp, chan_desc);
7582
7583 /* 3GPP TS 44.018, section 9.1.36.2 "CBCH Mobile Allocation":
7584 * The CBCH Mobile Allocation IE *shall* be present if FH is enabled. */
7585 if (chan_desc.h and not ispresent(si.payload.si4.cbch_mobile_alloc)) {
7586 setverdict(fail, "FH enabled, but Mobile Allocation IE is absent");
7587 break;
7588 } else if (chan_desc.h and ispresent(si.payload.si4.cbch_mobile_alloc)) {
7589 f_TC_fh_params_match_ma(fhp, chan_desc.chan_nr.tn,
7590 si.payload.si4.cbch_mobile_alloc.v);
7591 }
7592 }
7593 [] IPA_RSL[0].receive { repeat; }
7594 [] T.timeout {
7595 setverdict(fail, "Timeout waiting for RSL BCCH INFOrmation (SI4)");
7596 }
7597 }
7598
7599 /* Disable frequency hopping */
7600 f_TC_fh_params_unset(fhp);
7601
Vadim Yanitskiy8bc46012020-09-06 12:38:01 +07007602 /* (Re)configure TS0 as CCCH+SDCCH4+CBCH and TS1 as TCH/F */
Vadim Yanitskiyca974032020-09-01 07:20:39 +07007603 f_vty_enter_cfg_trx(BSCVTY, trx := 0);
7604
7605 f_vty_transceive(BSCVTY, "timeslot 0");
Vadim Yanitskiy8bc46012020-09-06 12:38:01 +07007606 f_vty_transceive(BSCVTY, "phys_chan_config ccch+sdcch4+cbch");
Vadim Yanitskiyca974032020-09-01 07:20:39 +07007607 f_vty_transceive(BSCVTY, "exit"); /* go back */
7608
7609 f_vty_transceive(BSCVTY, "timeslot 1");
7610 f_vty_transceive(BSCVTY, "phys_chan_config tch/f");
7611 f_vty_transceive(BSCVTY, "end"); /* we're done */
7612
Vadim Yanitskiy21726312020-09-04 01:45:36 +07007613 f_shutdown_helper();
Vadim Yanitskiyca974032020-09-01 07:20:39 +07007614}
7615
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02007616template (value) PDU_BSSAP_LE ts_BSSMAP_LE_BSSLAP(template (value) BSSLAP_PDU bsslap)
7617 := ts_BSSMAP_LE_ConnInfo(BSSMAP_LE_PROT_BSSLAP, data := enc_BSSLAP_PDU(valueof(bsslap)));
7618
7619private function f_match_bsslap(PDU_BSSAP_LE got_bsslap_msg,
7620 template (present) BSSLAP_PDU expect_bsslap)
7621{
7622 var BSSLAP_PDU bsslap := dec_BSSLAP_PDU(got_bsslap_msg.pdu.bssmap.co_info.bsslap_apdu.data);
7623 if (not match(bsslap, expect_bsslap)) {
7624 log("EXPECTING BSSLAP: ", expect_bsslap);
7625 log("GOT BSSLAP: ", bsslap);
7626 setverdict(fail, "BSSLAP is not as expected");
7627 mtc.stop;
7628 }
7629 setverdict(pass);
7630}
7631
7632/* GAD: this is an Ellipsoid point with uncertainty circle, encoded as in 3GPP TS 23.032 §7.3.2. */
7633const octetstring gad_ell_point_unc_circle := '10b0646d0d5f6627'O;
7634
7635private function f_expect_bsslap(template (present) BSSLAP_PDU expect_rx_bsslap) runs on MSC_ConnHdlr {
7636 var PDU_BSSAP_LE rx_bsslap;
7637 BSSAP_LE.receive(tr_BSSMAP_LE_ConnInfo(BSSMAP_LE_PROT_BSSLAP, ?)) -> value(rx_bsslap);
7638 f_match_bsslap(rx_bsslap, expect_rx_bsslap);
7639}
7640
7641/* With an active lchan, start BSSMAP Perform Location Request on A interface, starting BSSMAP-LE Perform Location
7642 * Request on Lb interface. Either with or without the SMLC doing a BSSLAP TA Request. */
7643private function f_lcs_loc_req_for_active_ms(boolean do_ta_request := false) runs on MSC_ConnHdlr {
7644 f_sleep(1.0);
7645
7646 f_establish_fully(omit, omit);
7647 f_bssap_le_register_imsi(g_pars.imsi, omit);
7648
7649 BSSAP.send(valueof(ts_BSSMAP_Perform_Location_Request(ts_BSSMAP_Imsi(g_pars.imsi),
7650 ts_CellId_CGI('262'H, '42'H, 23, 42))));
7651
7652 var PDU_BSSAP_LE plr;
7653 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocReq(BSSMAP_LE_LOC_INFO_CURRENT_GEOGRAPHIC_LOC, ?, ?)) -> value(plr);
7654
7655 if (not do_ta_request) {
7656 /* verify TA Layer 3 in APDU. First the APDU type (BSSLAP), then the BSSLAP data contents. */
7657 var template BSSMAP_LE_IE_APDU expect_apdu := tr_BSSMAP_LE_APDU(BSSMAP_LE_PROT_BSSLAP, ?);
7658 if (not match(plr.pdu.bssmap.perf_loc_req.bsslap_apdu, expect_apdu)) {
7659 log("EXPECTING BSSMAP-LE APDU IE ", expect_apdu);
7660 log("GOT BSSMAP-LE APDU IE ", plr.pdu.bssmap.perf_loc_req.bsslap_apdu);
7661 setverdict(fail, "BSSMAP-LE APDU IE is not as expected");
7662 mtc.stop;
7663 }
7664 var template BSSLAP_PDU expect_ta_layer3 := tr_BSSLAP_TA_Layer3(tr_BSSLAP_IE_TA(0));
7665 var BSSLAP_PDU bsslap := dec_BSSLAP_PDU(plr.pdu.bssmap.perf_loc_req.bsslap_apdu.data);
7666 if (not match(bsslap, expect_ta_layer3)) {
7667 log("EXPECTING BSSLAP TA Layer 3: ", expect_ta_layer3);
7668 log("GOT BSSLAP: ", bsslap);
7669 setverdict(fail, "BSSLAP is not as expected");
7670 mtc.stop;
7671 }
7672 /* OsmoBSC directly sent the TA as BSSLAP APDU in the BSSMAP-LE Perform Location Request to the SMLC. The SMLC
7673 * has no need to request the TA from the BSC and directly responds. */
7674 } else {
7675 /* SMLC wants to ask the TA from the BSC explicitly in a BSSLAP TA Request message */
7676 BSSAP_LE.send(ts_BSSMAP_LE_BSSLAP(ts_BSSLAP_TA_Req));
7677 f_expect_bsslap(tr_BSSLAP_TA_Resp(?, ?));
7678 }
7679
7680 /* SMLC got the TA from the BSC, now responds with geo information data. */
7681 BSSAP_LE.send(ts_BSSMAP_LE_PerfLocResp(gad_ell_point_unc_circle, omit));
7682 BSSAP_LE.receive(BSSAP_LE_Conn_Prim:CONN_PRIM_DISC_IND);
7683 BSSAP.receive(tr_BSSMAP_Perform_Location_Response(tr_BSSMAP_IE_LocationEstimate(gad_ell_point_unc_circle)));
7684
7685 /* The LCS was using an active A-interface conn. It should still remain active after this. */
7686 f_mo_l3_transceive();
7687
7688 f_perform_clear(RSL);
7689
7690 f_sleep(2.0);
7691 setverdict(pass);
7692}
7693
7694/* With an active lchan, start BSSMAP Perform Location Request on A interface, starting BSSMAP-LE Perform Location
7695 * Request on Lb interface. Without the SMLC doing a BSSLAP TA Request. */
7696private function f_tc_lcs_loc_req_for_active_ms(charstring id) runs on MSC_ConnHdlr {
7697 f_lcs_loc_req_for_active_ms(false);
7698}
7699testcase TC_lcs_loc_req_for_active_ms() runs on test_CT {
7700 var MSC_ConnHdlr vc_conn;
7701 var TestHdlrParams pars := f_gen_test_hdlr_pars();
7702
7703 f_init(1, true);
7704 f_sleep(1.0);
7705 vc_conn := f_start_handler(refers(f_tc_lcs_loc_req_for_active_ms), pars);
7706 vc_conn.done;
7707}
7708
7709/* With an active lchan, start BSSMAP Perform Location Request on A interface, starting BSSMAP-LE Perform Location
7710 * Request on Lb interface. With the SMLC doing a BSSLAP TA Request. */
7711private function f_tc_lcs_loc_req_for_active_ms_ta_req(charstring id) runs on MSC_ConnHdlr {
7712 f_lcs_loc_req_for_active_ms(true);
7713}
7714testcase TC_lcs_loc_req_for_active_ms_ta_req() runs on test_CT {
7715 var MSC_ConnHdlr vc_conn;
7716 var TestHdlrParams pars := f_gen_test_hdlr_pars();
7717
7718 f_init(1, true);
7719 f_sleep(1.0);
7720 vc_conn := f_start_handler(refers(f_tc_lcs_loc_req_for_active_ms_ta_req), pars);
7721 vc_conn.done;
7722}
7723
7724/* Clear the A-interface conn only, without doing anything on Abis. Useful for LCS, for cases where there is only an A
7725 * conn without an active lchan. */
7726private function f_clear_A_conn() runs on MSC_ConnHdlr
7727{
7728 var BssmapCause cause := 0;
7729 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
7730 BSSAP.receive(tr_BSSMAP_ClearComplete);
7731 BSSAP.send(RAN_Conn_Prim:MSC_CONN_PRIM_DISC_REQ);
7732
7733 timer no_more_bssap := 5.0;
7734 no_more_bssap.start;
7735 alt {
7736 [] no_more_bssap.timeout { break; }
7737 [] BSSAP.receive(tr_BSSAP_BSSMAP) {
7738 setverdict(fail, "Expected no more BSSAP after Clear Complete");
7739 mtc.stop;
7740 }
7741 }
7742 setverdict(pass);
7743}
7744
7745/* Verify that the A-interface connection is still working, and then clear it, without doing anything on Abis. Useful
7746 * for LCS, for cases where there is only an A conn without an active lchan. */
7747private function f_verify_active_A_conn_and_clear() runs on MSC_ConnHdlr
7748{
7749 f_logp(BSCVTY, "f_verify_active_A_conn_and_clear: test A link, then clear");
7750
7751 /* When an lchan is active, we can send some L3 data from the BTS side and verify that it shows up on the other
7752 * side towards the MSC. When there is no lchan, this is not possible. To probe whether the A-interface
7753 * connection is still up, we need something that echos back on the A-interface. Another LCS request! */
7754 BSSAP.send(valueof(ts_BSSMAP_Perform_Location_Request(ts_BSSMAP_Imsi(g_pars.imsi),
7755 ts_CellId_CGI('262'H, '42'H, 23, 42))));
7756 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocReq(BSSMAP_LE_LOC_INFO_CURRENT_GEOGRAPHIC_LOC, ?, ?));
7757
7758 /* Right, the Perform Location Request showed up on Lb, now we can clear the A conn. */
7759 f_clear_A_conn();
7760 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocAbort(BSSMAP_LE_LCS_CAUSE_REQUEST_ABORTED));
7761 BSSAP_LE.receive(BSSAP_LE_Conn_Prim:CONN_PRIM_DISC_IND);
7762}
7763
7764/* With *no* active lchan, start BSSMAP Perform Location Request on A interface, starting BSSMAP-LE Perform Location
7765 * Request on Lb interface. BSC will Page for the subscriber as soon as we (virtual SMLC) request the TA via BSSLAP.
7766 */
7767private function f_tc_lcs_loc_req_for_idle_ms(charstring id) runs on MSC_ConnHdlr {
7768 f_sleep(1.0);
7769
7770 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
7771 f_bssap_le_register_imsi(g_pars.imsi, omit);
7772
7773 /* Register to receive the Paging Command */
7774 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
7775 g_chan_nr := new_chan_nr;
7776 f_rslem_register(0, g_chan_nr);
7777
7778 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
7779 valueof(ts_BSSMAP_Perform_Location_Request(ts_BSSMAP_Imsi(g_pars.imsi),
7780 ts_CellId_CGI('001'H, '01'H, 1, 0)))));
7781 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
7782
7783 var PDU_BSSAP_LE plr;
7784 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocReq(BSSMAP_LE_LOC_INFO_CURRENT_GEOGRAPHIC_LOC, ?, ?)) -> value(plr);
7785
7786 /* SMLC wants to ask the TA from the BSC explicitly in a BSSLAP TA Request message */
7787 BSSAP_LE.send(ts_BSSMAP_LE_BSSLAP(ts_BSSLAP_TA_Req));
7788
7789 /* OsmoBSC needs to Page */
7790 RSL.receive(tr_RSL_PAGING_CMD(tr_MI_IMSI(g_pars.imsi)));
7791 f_logp(BSCVTY, "got Paging Command");
7792
7793 /* MS requests channel. Since the Paging was for LCS, the Paging Response does not trigger a Complete Layer 3 to
7794 * the MSC, and releases the lchan directly. */
7795 f_perform_compl_l3(RSL, ts_PAG_RESP(valueof(ts_MI_IMSI_LV(g_pars.imsi))), do_clear := false, expect_bssmap_l3 := false);
7796 f_expect_lchan_rel(RSL);
7797
7798 /* From the Paging Response, the TA is now known to the BSC, and it responds to the SMLC. */
7799
7800 f_expect_bsslap(tr_BSSLAP_TA_Resp(?, ?));
7801
7802 /* SMLC got the TA from the BSC, now responds with geo information data. */
7803 BSSAP_LE.send(ts_BSSMAP_LE_PerfLocResp(gad_ell_point_unc_circle, omit));
7804 BSSAP_LE.receive(BSSAP_LE_Conn_Prim:CONN_PRIM_DISC_IND);
7805
7806 BSSAP.receive(tr_BSSMAP_Perform_Location_Response(tr_BSSMAP_IE_LocationEstimate(gad_ell_point_unc_circle)));
7807
7808 /* The lchan is gone, the A-interface conn was created for the LCS only.
7809 * Still it is clearly the MSC's job to decide whether to tear down the conn or not. */
7810 f_verify_active_A_conn_and_clear();
7811
7812 f_sleep(2.0);
7813 setverdict(pass);
7814}
7815testcase TC_lcs_loc_req_for_idle_ms() runs on test_CT {
7816 var MSC_ConnHdlr vc_conn;
7817 var TestHdlrParams pars := f_gen_test_hdlr_pars();
7818
7819 f_init(1, true);
7820 f_sleep(1.0);
7821
7822 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
7823 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
7824
7825 vc_conn := f_start_handler(refers(f_tc_lcs_loc_req_for_idle_ms), pars);
7826 vc_conn.done;
7827}
7828
7829/* With no active lchan, start BSSMAP Perform Location Request on A interface, but omit IMSI; expect failure response.
7830 */
7831private function f_tc_lcs_loc_req_no_subscriber(charstring id) runs on MSC_ConnHdlr {
7832 f_sleep(1.0);
7833
7834 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
7835 f_bssap_le_register_imsi(g_pars.imsi, omit);
7836
7837 /* provoke an abort by omitting both IMSI and IMEI */
7838 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
7839 valueof(ts_BSSMAP_Perform_Location_Request(omit,
7840 ts_CellId_CGI('262'H, '42'H, 23, 42)))));
7841 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
7842
7843 /* BSC tells MSC about failure */
7844 BSSAP.receive(tr_BSSMAP_Perform_Location_Response(
7845 locationEstimate := omit, positioningData := omit,
7846 lCS_Cause := tr_BSSMAP_LcsCause(BSSMAP_LCS_CAUSE_DATA_MISSING_IN_REQ)));
7847
7848 /* There is no lchan. Still the MSC's job to decide whether to tear down the conn or not. */
7849 f_verify_active_A_conn_and_clear();
7850
7851 f_sleep(2.0);
7852 setverdict(pass);
7853}
7854testcase TC_lcs_loc_req_no_subscriber() runs on test_CT {
7855 var MSC_ConnHdlr vc_conn;
7856 var TestHdlrParams pars := f_gen_test_hdlr_pars();
7857
7858 f_init(1, true);
7859 f_sleep(1.0);
7860
7861 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
7862 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
7863
7864 vc_conn := f_start_handler(refers(f_tc_lcs_loc_req_no_subscriber), pars);
7865 vc_conn.done;
7866}
7867
7868/* With an active lchan, start a Perform Location Request on the A-interface, but virtual SMLC does not answer with
7869 * BSSMAP-LE Perform Location Response (before or after sending a BSSLAP TA Request) */
7870private function f_lcs_loc_req_for_active_ms_le_timeout(boolean do_ta) runs on MSC_ConnHdlr {
7871 f_sleep(1.0);
7872
7873 f_establish_fully(omit, omit);
7874 f_bssap_le_register_imsi(g_pars.imsi, omit);
7875
7876 BSSAP.send(valueof(ts_BSSMAP_Perform_Location_Request(ts_BSSMAP_Imsi(g_pars.imsi),
7877 ts_CellId_CGI('262'H, '42'H, 23, 42))));
7878
7879 var PDU_BSSAP_LE plr;
7880 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocReq(BSSMAP_LE_LOC_INFO_CURRENT_GEOGRAPHIC_LOC, ?, ?)) -> value(plr);
7881
7882 if (do_ta) {
7883 /* SMLC wants to ask the TA from the BSC explicitly in a BSSLAP TA Request message */
7884 BSSAP_LE.send(ts_BSSMAP_LE_BSSLAP(ts_BSSLAP_TA_Req));
7885 f_expect_bsslap(tr_BSSLAP_TA_Resp(?, ?));
7886 }
7887
7888 /* SMLC fails to respond, BSC runs into timeout */
7889 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocAbort(BSSMAP_LE_LCS_CAUSE_SYSTEM_FAILURE));
7890 BSSAP_LE.receive(BSSAP_LE_Conn_Prim:CONN_PRIM_DISC_IND);
7891
7892 BSSAP.receive(tr_BSSMAP_Perform_Location_Response(
7893 locationEstimate := omit, positioningData := omit,
7894 lCS_Cause := tr_BSSMAP_LcsCause(BSSMAP_LCS_CAUSE_SYSTEM_FAILURE)));
7895
7896 /* There is no lchan. Still the MSC's job to decide whether to tear down the conn or not. */
7897 f_verify_active_A_conn_and_clear();
7898
7899 f_sleep(2.0);
7900 setverdict(pass);
7901}
7902
7903/* With an active lchan, start a Perform Location Request on the A-interface, but virtual SMLC does not answer with
7904 * BSSMAP-LE Perform Location Response, without sending a BSSLAP TA Request. */
7905private function f_tc_lcs_loc_req_for_active_ms_le_timeout(charstring id) runs on MSC_ConnHdlr {
7906 f_lcs_loc_req_for_active_ms_le_timeout(false);
7907}
7908
7909testcase TC_lcs_loc_req_for_active_ms_le_timeout() runs on test_CT {
7910 var MSC_ConnHdlr vc_conn;
7911 var TestHdlrParams pars := f_gen_test_hdlr_pars();
7912
7913 f_init(1, true);
7914 f_sleep(1.0);
7915 vc_conn := f_start_handler(refers(f_tc_lcs_loc_req_for_active_ms_le_timeout), pars);
7916 vc_conn.done;
7917}
7918
7919/* With an active lchan, start a Perform Location Request on the A-interface, but virtual SMLC does not answer with
7920 * BSSMAP-LE Perform Location Response, after sending a BSSLAP TA Request. */
7921private function f_tc_lcs_loc_req_for_active_ms_le_timeout2(charstring id) runs on MSC_ConnHdlr {
7922 f_lcs_loc_req_for_active_ms_le_timeout(true);
7923}
7924
7925testcase TC_lcs_loc_req_for_active_ms_le_timeout2() runs on test_CT {
7926 var MSC_ConnHdlr vc_conn;
7927 var TestHdlrParams pars := f_gen_test_hdlr_pars();
7928
7929 f_init(1, true);
7930 f_sleep(1.0);
7931 vc_conn := f_start_handler(refers(f_tc_lcs_loc_req_for_active_ms_le_timeout2), pars);
7932 vc_conn.done;
7933}
7934
7935/* With *no* active lchan, start a Perform Location Request, expecting that the MS will be Paged. */
7936private function f_tc_lcs_loc_req_for_idle_ms_no_pag_resp(charstring id) runs on MSC_ConnHdlr {
7937 f_sleep(1.0);
7938
7939 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
7940 f_bssap_le_register_imsi(g_pars.imsi, omit);
7941
7942 /* Register to receive the Paging Command */
7943 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
7944 g_chan_nr := new_chan_nr;
7945 f_rslem_register(0, g_chan_nr);
7946
7947 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
7948 valueof(ts_BSSMAP_Perform_Location_Request(ts_BSSMAP_Imsi(g_pars.imsi),
7949 ts_CellId_CGI('001'H, '01'H, 1, 0)))));
7950 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
7951
7952 var PDU_BSSAP_LE plr;
7953 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocReq(BSSMAP_LE_LOC_INFO_CURRENT_GEOGRAPHIC_LOC, ?, ?)) -> value(plr);
7954
7955 /* SMLC wants to ask the TA from the BSC explicitly in a BSSLAP TA Request message */
7956 BSSAP_LE.send(ts_BSSMAP_LE_BSSLAP(ts_BSSLAP_TA_Req));
7957
7958 /* OsmoBSC needs to Page */
7959 var PDU_BSSAP_LE rx_bsslap;
7960 alt {
7961 [] RSL.receive(tr_RSL_PAGING_CMD(tr_MI_IMSI(g_pars.imsi))) {
7962 f_logp(BSCVTY, "got Paging Command");
7963 repeat;
7964 }
7965 [] BSSAP_LE.receive(tr_BSSMAP_LE_ConnInfo(BSSMAP_LE_PROT_BSSLAP, ?)) -> value(rx_bsslap) {
7966 /* MS does not respond to Paging, TA Req runs into timeout. */
7967 f_match_bsslap(rx_bsslap, tr_BSSLAP_Abort(?));
7968 }
7969 }
7970
7971 /* SMLC responds with failure */
7972 BSSAP_LE.send(ts_BSSMAP_LE_PerfLocResp(omit, BSSMAP_LE_LCS_CAUSE_REQUEST_ABORTED));
7973 BSSAP_LE.receive(BSSAP_LE_Conn_Prim:CONN_PRIM_DISC_IND);
7974
7975 /* BSC tells MSC about failure */
7976 BSSAP.receive(tr_BSSMAP_Perform_Location_Response(
7977 locationEstimate := omit, positioningData := omit,
7978 lCS_Cause := tr_BSSMAP_LcsCause(BSSMAP_LCS_CAUSE_REQUEST_ABORTED)));
7979
7980 /* There is no lchan. Still the MSC's job to decide whether to tear down the conn or not. */
7981 f_verify_active_A_conn_and_clear();
7982
7983 f_sleep(2.0);
7984 setverdict(pass);
7985}
7986testcase TC_lcs_loc_req_for_idle_ms_no_pag_resp() runs on test_CT {
7987 var MSC_ConnHdlr vc_conn;
7988 var TestHdlrParams pars := f_gen_test_hdlr_pars();
7989
7990 f_init(1, true);
7991 f_sleep(1.0);
7992
7993 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
7994 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
7995
7996 vc_conn := f_start_handler(refers(f_tc_lcs_loc_req_for_idle_ms_no_pag_resp), pars);
7997 vc_conn.done;
7998}
7999
8000/* During an ongoing Location Request, the MS sends a CM Service Request. Expect the same A-conn to be re-used / taken
8001 * over. */
8002private function f_tc_cm_service_during_lcs_loc_req(charstring id) runs on MSC_ConnHdlr {
8003 f_sleep(1.0);
8004
8005 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
8006 f_bssap_le_register_imsi(g_pars.imsi, omit);
8007
8008 /* Register to receive the Paging Command */
8009 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
8010 g_chan_nr := new_chan_nr;
8011 f_rslem_register(0, g_chan_nr);
8012
8013 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
8014 valueof(ts_BSSMAP_Perform_Location_Request(ts_BSSMAP_Imsi(g_pars.imsi),
8015 ts_CellId_CGI('001'H, '01'H, 1, 0)))));
8016 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
8017
8018 var PDU_BSSAP_LE plr;
8019 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocReq(BSSMAP_LE_LOC_INFO_CURRENT_GEOGRAPHIC_LOC, ?, ?)) -> value(plr);
8020
8021 /* As the A-interface conn was established for LCS, the MS coincidentally decides to issue a CM Service Request
8022 * and establish Layer 3. It should use the existing A-interface conn. */
8023 f_perform_compl_l3(RSL, valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, valueof(ts_MI_IMSI_LV(g_pars.imsi)))),
8024 do_clear := false, expect_bssmap_l3 := true);
8025
8026 /* SMLC wants to ask the TA from the BSC explicitly in a BSSLAP TA Request message */
8027 BSSAP_LE.send(ts_BSSMAP_LE_BSSLAP(ts_BSSLAP_TA_Req));
8028
8029 /* OsmoBSC already has an lchan, no need to Page, just returns the TA */
8030 f_expect_bsslap(tr_BSSLAP_TA_Resp(?, ?));
8031
8032 /* SMLC got the TA from the BSC, now responds with geo information data. */
8033 BSSAP_LE.send(ts_BSSMAP_LE_PerfLocResp(gad_ell_point_unc_circle, omit));
8034 BSSAP_LE.receive(BSSAP_LE_Conn_Prim:CONN_PRIM_DISC_IND);
8035 BSSAP.receive(tr_BSSMAP_Perform_Location_Response(tr_BSSMAP_IE_LocationEstimate(gad_ell_point_unc_circle)));
8036
8037 /* The lchan should still exist, it was from a CM Service Request. */
8038 f_mo_l3_transceive();
8039
8040 f_perform_clear(RSL);
8041
8042 f_sleep(2.0);
8043 setverdict(pass);
8044}
8045testcase TC_cm_service_during_lcs_loc_req() 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_cm_service_during_lcs_loc_req), pars);
8056 vc_conn.done;
8057}
8058
8059/* During an ongoing Perform Location Request, do a Handover, an expect a BSSLAP Reset message from the BSC to indicate
8060 * the new lchan after handover. */
8061private function f_tc_ho_during_lcs_loc_req(charstring id) 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 /* SMLC ponders the Location Request, in the meantime the BSC decides to handover */
8074 f_bts_0_cfg(BSCVTY, {"neighbor bts 1"});
8075
8076 var HandoverState hs := {
8077 rr_ho_cmpl_seen := false,
8078 handover_done := false,
8079 old_chan_nr := -
8080 };
8081 /* issue hand-over command on VTY */
8082 f_vty_handover(BSCVTY, 0, 0, g_chan_nr, 1);
8083 /* temporarily suspend DChan processing on BTS1 to avoid race with RSLEM_register */
8084 f_rslem_suspend(RSL1_PROC);
8085
8086 /* From the MGW perspective, a handover is is characterized by
8087 * performing one MDCX operation with the MGW. So we expect to see
8088 * one more MDCX during handover. */
8089 g_media.mgcp_conn[0].mdcx_seen_exp := g_media.mgcp_conn[0].crcx_seen_exp + 1;
8090
8091 alt {
8092 [] as_handover(hs);
8093 }
8094
8095 var PDU_BSSAP_LE rx_bsslap;
8096
8097 interleave {
8098 /* Expect the BSC to inform the MSC about the handover */
8099 [] BSSAP.receive(tr_BSSMAP_HandoverPerformed);
8100
8101 /* Expect the BSC to inform the SMLC about the handover */
8102 [] BSSAP_LE.receive(tr_BSSMAP_LE_ConnInfo(BSSMAP_LE_PROT_BSSLAP, ?)) -> value(rx_bsslap) {
8103 f_match_bsslap(rx_bsslap, tr_BSSLAP_Reset(BSSLAP_CAUSE_INTRA_BSS_HO));
8104 }
8105 }
8106
8107 /* SMLC now responds with geo information data. */
8108 BSSAP_LE.send(ts_BSSMAP_LE_PerfLocResp(gad_ell_point_unc_circle, omit));
8109 BSSAP_LE.receive(BSSAP_LE_Conn_Prim:CONN_PRIM_DISC_IND);
8110 BSSAP.receive(tr_BSSMAP_Perform_Location_Response(tr_BSSMAP_IE_LocationEstimate(gad_ell_point_unc_circle)));
8111
8112 /* lchan still active */
8113 f_mo_l3_transceive(RSL1);
8114
8115 /* MSC decides it is done now. */
8116 f_perform_clear(RSL1);
8117
8118 f_sleep(2.0);
8119 setverdict(pass);
8120}
8121testcase TC_ho_during_lcs_loc_req() runs on test_CT {
8122 var MSC_ConnHdlr vc_conn;
8123 var TestHdlrParams pars := f_gen_test_hdlr_pars();
8124
8125 f_init(2, true);
8126 f_sleep(1.0);
8127 vc_conn := f_start_handler(refers(f_tc_ho_during_lcs_loc_req), pars);
8128 vc_conn.done;
8129}
8130
Harald Welte0ea2d5e2018-04-07 21:40:29 +02008131/* Dyn PDCH todo:
8132 * activate OSMO as TCH/F
8133 * activate OSMO as TCH/H
8134 * does the BSC-located PCU socket get the updated INFO?
8135 * what if no PCU is connected at the time?
8136 * is the info correct on delayed PCU (re)connect?
8137 */
Harald Welte94e0c342018-04-07 11:33:23 +02008138
Harald Welte28d943e2017-11-25 15:00:50 +01008139control {
Harald Welte898113b2018-01-31 18:32:21 +01008140 /* CTRL interface testing */
Harald Welte4003d112017-12-09 22:35:39 +01008141 execute( TC_ctrl_msc_connection_status() );
Stefan Sperlingb041b3d2018-01-03 17:14:55 +01008142 execute( TC_ctrl_msc0_connection_status() );
Harald Welte96c94412017-12-09 03:12:45 +01008143 execute( TC_ctrl() );
Neels Hofmeyrf246a922020-05-13 02:27:10 +02008144 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_SCCPlite_SERVER) {
Pau Espin Pedrol5a2d7432019-06-07 19:43:45 +02008145 execute( TC_ctrl_location() );
8146 }
Harald Welte898113b2018-01-31 18:32:21 +01008147
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +02008148 execute( TC_si_default() );
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02008149 execute( TC_si2quater_2_earfcns() );
8150 execute( TC_si2quater_3_earfcns() );
8151 execute( TC_si2quater_4_earfcns() );
8152 execute( TC_si2quater_5_earfcns() );
8153 execute( TC_si2quater_6_earfcns() );
Neels Hofmeyrad132f22020-07-08 02:20:16 +02008154 execute( TC_si2quater_12_earfcns() );
8155 execute( TC_si2quater_23_earfcns() );
8156 execute( TC_si2quater_32_earfcns() );
8157 execute( TC_si2quater_33_earfcns() );
8158 execute( TC_si2quater_42_earfcns() );
8159 execute( TC_si2quater_48_earfcns() );
8160 execute( TC_si2quater_49_earfcns() );
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02008161 execute( TC_si_acc_rotate() );
Alexander Couzens4ad3a352020-09-10 22:29:12 +02008162 execute( TC_si_acc_ramp_rotate() );
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +02008163
Harald Welte898113b2018-01-31 18:32:21 +01008164 /* RSL DCHAN Channel ACtivation / Deactivation */
Harald Welteae026692017-12-09 01:03:01 +01008165 execute( TC_chan_act_noreply() );
Harald Welte4003d112017-12-09 22:35:39 +01008166 execute( TC_chan_act_counter() );
Harald Welteae026692017-12-09 01:03:01 +01008167 execute( TC_chan_act_ack_noest() );
Philipp Maier9c60a622020-07-09 15:08:46 +02008168 execute( TC_chan_act_ack_noest_emerg() );
Philipp Maier606f07d2020-08-12 17:21:58 +02008169 execute( TC_chan_rqd_emerg_deny() );
Harald Welteae026692017-12-09 01:03:01 +01008170 execute( TC_chan_act_ack_est_ind_noreply() );
8171 execute( TC_chan_act_ack_est_ind_refused() );
Harald Welte618ef642017-12-14 14:58:20 +01008172 execute( TC_chan_act_nack() );
Harald Welte799c97b2017-12-14 17:50:30 +01008173 execute( TC_chan_exhaustion() );
Vadim Yanitskiy1ff1fdf2018-11-27 01:32:57 +07008174 execute( TC_chan_deact_silence() );
Harald Welte4003d112017-12-09 22:35:39 +01008175 execute( TC_chan_rel_rll_rel_ind() );
8176 execute( TC_chan_rel_conn_fail() );
8177 execute( TC_chan_rel_hard_clear() );
Harald Welte99787102019-02-04 10:41:36 +01008178 execute( TC_chan_rel_hard_clear_csfb() );
Harald Welted8c36cd2017-12-09 23:05:31 +01008179 execute( TC_chan_rel_hard_rlsd() );
Harald Welte550daf92018-06-11 19:22:13 +02008180 execute( TC_chan_rel_hard_rlsd_ms_dead() );
Harald Welte85804d42017-12-10 14:11:58 +01008181 execute( TC_chan_rel_a_reset() );
Pau Espin Pedrolc675b612020-01-09 19:55:40 +01008182 execute( TC_chan_rel_sccp_tiar_timeout() );
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02008183 execute( TC_chan_rel_rr_cause() );
Harald Welte6f521d82017-12-11 19:52:02 +01008184
Harald Weltecfe2c962017-12-15 12:09:32 +01008185 execute( TC_outbound_connect() );
Harald Welte898113b2018-01-31 18:32:21 +01008186
8187 /* Assignment related */
Harald Welte16a4adf2017-12-14 18:54:01 +01008188 execute( TC_assignment_cic_only() );
Harald Welte235ebf12017-12-15 14:18:16 +01008189 execute( TC_assignment_csd() );
8190 execute( TC_assignment_ctm() );
8191 execute( TC_assignment_sign() );
Pau Espin Pedrol07866632020-09-03 19:10:55 +02008192 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
8193 execute( TC_assignment_aoip_tla_v6() );
8194 }
Harald Welte235ebf12017-12-15 14:18:16 +01008195 execute( TC_assignment_fr_a5_0() );
8196 execute( TC_assignment_fr_a5_1() );
Neels Hofmeyrf246a922020-05-13 02:27:10 +02008197 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
Harald Welte8f67d1d2018-05-25 20:38:42 +02008198 execute( TC_assignment_fr_a5_1_codec_missing() );
8199 }
Harald Welte235ebf12017-12-15 14:18:16 +01008200 execute( TC_assignment_fr_a5_3() );
8201 execute( TC_assignment_fr_a5_4() );
Harald Welte3c86ea02018-05-10 22:28:05 +02008202 execute( TC_ciph_mode_a5_0() );
8203 execute( TC_ciph_mode_a5_1() );
8204 execute( TC_ciph_mode_a5_3() );
Harald Welte16a4adf2017-12-14 18:54:01 +01008205
Harald Welte60aa5762018-03-21 19:33:13 +01008206 execute( TC_assignment_codec_fr() );
8207 execute( TC_assignment_codec_hr() );
8208 execute( TC_assignment_codec_efr() );
8209 execute( TC_assignment_codec_amr_f() );
8210 execute( TC_assignment_codec_amr_h() );
Philipp Maier8a581d22019-03-26 18:32:48 +01008211
Neels Hofmeyrf246a922020-05-13 02:27:10 +02008212 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
Philipp Maier8a581d22019-03-26 18:32:48 +01008213 execute( TC_assignment_codec_amr_f_S1() );
8214 execute( TC_assignment_codec_amr_h_S1() );
8215 execute( TC_assignment_codec_amr_f_S124() );
8216 execute( TC_assignment_codec_amr_h_S124() );
8217 execute( TC_assignment_codec_amr_f_S0() );
8218 execute( TC_assignment_codec_amr_f_S02() );
8219 execute( TC_assignment_codec_amr_f_S024() );
8220 execute( TC_assignment_codec_amr_f_S0247() );
8221 execute( TC_assignment_codec_amr_h_S0() );
8222 execute( TC_assignment_codec_amr_h_S02() );
8223 execute( TC_assignment_codec_amr_h_S024() );
8224 execute( TC_assignment_codec_amr_h_S0247() );
8225 execute( TC_assignment_codec_amr_f_S01234567() );
8226 execute( TC_assignment_codec_amr_f_S0234567() );
8227 execute( TC_assignment_codec_amr_f_zero() );
8228 execute( TC_assignment_codec_amr_f_unsupp() );
8229 execute( TC_assignment_codec_amr_h_S7() );
8230 }
Harald Welte60aa5762018-03-21 19:33:13 +01008231
Philipp Maierac09bfc2019-01-08 13:41:39 +01008232 execute( TC_assignment_codec_fr_exhausted_req_hr() );
8233 execute( TC_assignment_codec_fr_exhausted_req_fr() );
8234 execute( TC_assignment_codec_fr_exhausted_req_fr_hr() );
8235 execute( TC_assignment_codec_fr_exhausted_req_hr_fr() );
8236 execute( TC_assignment_codec_hr_exhausted_req_fr() );
8237 execute( TC_assignment_codec_hr_exhausted_req_hr() );
8238 execute( TC_assignment_codec_hr_exhausted_req_hr_fr() );
8239 execute( TC_assignment_codec_hr_exhausted_req_fr_hr() );
8240 execute( TC_assignment_codec_req_hr_fr() );
8241 execute( TC_assignment_codec_req_fr_hr() );
8242
Pau Espin Pedrol58cf6822019-05-28 18:11:33 +02008243 if (mp_enable_osmux_test) {
8244 execute( TC_assignment_osmux() );
8245 }
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02008246
Harald Welte898113b2018-01-31 18:32:21 +01008247 /* RLL Establish Indication on inactive DCHAN / SAPI */
Harald Welte5cd20ed2017-12-13 21:03:20 +01008248 execute( TC_rll_est_ind_inact_lchan() );
8249 execute( TC_rll_est_ind_inval_sapi1() );
8250 execute( TC_rll_est_ind_inval_sapi3() );
8251 execute( TC_rll_est_ind_inval_sacch() );
8252
Vadim Yanitskiy61f784a2020-10-01 21:12:19 +07008253 /* DLCI / RSL Link ID conversion for MO/MT messages on SAPI0/SAPI3 */
8254 execute( TC_tch_dlci_link_id_sapi() );
8255
Vadim Yanitskiy6ef5dfa2020-08-28 18:04:41 +07008256 /* SAPI N Reject triggered by RLL establishment failures */
8257 execute( TC_rll_rel_ind_sapi_n_reject() );
8258 execute( TC_rll_err_ind_sapi_n_reject() );
8259 execute( TC_rll_timeout_sapi_n_reject() );
8260
Harald Welte898113b2018-01-31 18:32:21 +01008261 /* Paging related tests */
Harald Welte6f521d82017-12-11 19:52:02 +01008262 execute( TC_paging_imsi_nochan() );
8263 execute( TC_paging_tmsi_nochan() );
8264 execute( TC_paging_tmsi_any() );
8265 execute( TC_paging_tmsi_sdcch() );
8266 execute( TC_paging_tmsi_tch_f() );
8267 execute( TC_paging_tmsi_tch_hf() );
8268 execute( TC_paging_imsi_nochan_cgi() );
8269 execute( TC_paging_imsi_nochan_lac_ci() );
8270 execute( TC_paging_imsi_nochan_ci() );
8271 execute( TC_paging_imsi_nochan_lai() );
8272 execute( TC_paging_imsi_nochan_lac() );
8273 execute( TC_paging_imsi_nochan_all() );
Harald Welte751d3eb2018-01-31 15:51:06 +01008274 execute( TC_paging_imsi_nochan_plmn_lac_rnc() );
8275 execute( TC_paging_imsi_nochan_rnc() );
8276 execute( TC_paging_imsi_nochan_lac_rnc() );
8277 execute( TC_paging_imsi_nochan_lacs() );
8278 execute( TC_paging_imsi_nochan_lacs_empty() );
Stefan Sperling049a86e2018-03-20 15:51:00 +01008279 execute( TC_paging_imsi_nochan_cgi_unknown_cid() );
Harald Welte10985002017-12-12 09:29:15 +01008280 execute( TC_paging_imsi_a_reset() );
Harald Weltee65d40e2017-12-13 00:09:06 +01008281 execute( TC_paging_imsi_load() );
Philipp Maier779a7922018-02-16 11:00:37 +01008282 execute( TC_paging_counter() );
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01008283 execute( TC_paging_resp_unsol() );
Harald Welte4e9b9cc2017-12-14 18:31:02 +01008284
8285 execute( TC_rsl_drop_counter() );
Stefan Sperling830dc9d2018-02-12 21:08:28 +01008286 execute( TC_rsl_unknown_unit_id() );
8287
8288 execute( TC_oml_unknown_unit_id() );
Harald Welte898113b2018-01-31 18:32:21 +01008289
8290 execute( TC_classmark() );
Harald Welteeddf0e92020-06-21 19:42:15 +02008291 execute( TC_common_id() );
Harald Welte898113b2018-01-31 18:32:21 +01008292 execute( TC_unsol_ass_fail() );
Harald Welteea99a002018-01-31 20:46:43 +01008293 execute( TC_unsol_ass_compl() );
Harald Weltefbf9b5e2018-01-31 20:41:23 +01008294 execute( TC_unsol_ho_fail() );
Harald Weltee3bd6582018-01-31 22:51:25 +01008295 execute( TC_err_82_short_msg() );
Harald Weltee9e02e42018-01-31 23:36:25 +01008296 execute( TC_err_84_unknown_msg() );
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01008297
Harald Welte261af4b2018-02-12 21:20:39 +01008298 execute( TC_ho_int() );
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01008299
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01008300 execute( TC_ho_out_of_this_bsc() );
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02008301 execute( TC_ho_out_fail_no_msc_response() );
8302 execute( TC_ho_out_fail_rr_ho_failure() );
Neels Hofmeyrd8a602c2019-07-09 19:46:01 +02008303 execute( TC_ho_out_fail_no_result_after_ho_cmd() );
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01008304
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01008305 execute( TC_ho_into_this_bsc() );
Pau Espin Pedrol07866632020-09-03 19:10:55 +02008306 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
8307 execute( TC_ho_into_this_bsc_tla_v6() );
8308 }
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01008309 execute( TC_ho_in_fail_msc_clears() );
8310 execute( TC_ho_in_fail_msc_clears_after_ho_detect() );
8311 execute( TC_ho_in_fail_no_detect() );
8312 execute( TC_ho_in_fail_no_detect2() );
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01008313
Neels Hofmeyr91401012019-07-11 00:42:35 +02008314 execute( TC_ho_neighbor_config_1() );
8315 execute( TC_ho_neighbor_config_2() );
8316 execute( TC_ho_neighbor_config_3() );
8317 execute( TC_ho_neighbor_config_4() );
8318 execute( TC_ho_neighbor_config_5() );
8319 execute( TC_ho_neighbor_config_6() );
8320 execute( TC_ho_neighbor_config_7() );
8321
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01008322 execute( TC_bssap_rlsd_does_not_cause_bssmap_reset() );
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01008323 execute( TC_bssmap_clear_does_not_cause_bssmap_reset() );
Neels Hofmeyrfd445c32018-03-09 15:39:31 +01008324 execute( TC_ms_rel_ind_does_not_cause_bssmap_reset() );
Harald Welte94e0c342018-04-07 11:33:23 +02008325
8326 execute( TC_dyn_pdch_ipa_act_deact() );
8327 execute( TC_dyn_pdch_ipa_act_nack() );
8328 execute( TC_dyn_pdch_osmo_act_deact() );
8329 execute( TC_dyn_pdch_osmo_act_nack() );
Harald Welte99f3ca02018-06-14 13:40:29 +02008330
Stefan Sperling0796a822018-10-05 13:01:39 +02008331 execute( TC_chopped_ipa_ping() );
Stefan Sperlingaa1e60f2018-10-15 16:34:07 +02008332 execute( TC_chopped_ipa_payload() );
Stefan Sperling0796a822018-10-05 13:01:39 +02008333
Pau Espin Pedrol8f773632019-11-05 11:46:53 +01008334 /* Power control related */
8335 execute( TC_assignment_verify_ms_power_params_ie() );
Neels Hofmeyr4f118412020-06-04 15:25:10 +02008336
8337 /* MSC pooling */
8338 /* FIXME: in SCCPlite, indicating how many MSCs should be connected does currently not work. Since
8339 * RESET->RESET-ACK is unconditionally negotiated for all configured MSCs, they always all appear as connected
8340 * to osmo-bsc. The MSC pooling tests however require disconnecting selected MSCs, and hence don't work out as
8341 * intended on SCCPlite. So for now, run these only for SCCP/M3UA. */
8342 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
8343 execute( TC_mscpool_L3Compl_on_1_msc() );
8344 execute( TC_mscpool_L3Complete_by_imsi_round_robin() );
8345 execute( TC_mscpool_LU_by_tmsi_null_nri_0_round_robin() );
8346 execute( TC_mscpool_LU_by_tmsi_null_nri_1_round_robin() );
8347 execute( TC_mscpool_L3Complete_by_tmsi_unassigned_nri_round_robin() );
8348 execute( TC_mscpool_L3Complete_by_tmsi_valid_nri_msc_not_connected_round_robin() );
8349 execute( TC_mscpool_L3Complete_by_tmsi_valid_nri_1() );
8350 execute( TC_mscpool_L3Complete_by_tmsi_valid_nri_2() );
8351 execute( TC_mscpool_LU_by_tmsi_from_other_PLMN() );
8352 execute( TC_mscpool_paging_and_response_imsi() );
8353 execute( TC_mscpool_paging_and_response_tmsi() );
8354 execute( TC_mscpool_no_allow_attach_round_robin() );
8355 execute( TC_mscpool_no_allow_attach_valid_nri() );
8356 }
8357
Harald Welte99f3ca02018-06-14 13:40:29 +02008358 /* at bottom as they might crash OsmoBSC before OS#3182 is fixed */
8359 execute( TC_early_conn_fail() );
8360 execute( TC_late_conn_fail() );
8361
Philipp Maier783681c2020-07-16 16:47:06 +02008362 /* Emergency call handling (deny / allow) */
8363 execute( TC_assignment_emerg_setup_allow() );
8364 execute( TC_assignment_emerg_setup_deny_msc() );
8365 execute( TC_assignment_emerg_setup_deny_bts() );
Philipp Maier82812002020-08-13 18:48:27 +02008366 execute( TC_emerg_premption() );
8367
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008368 /* Frequency hopping parameters handling */
8369 execute( TC_fh_params_chan_activ() );
8370 execute( TC_fh_params_imm_ass() );
Vadim Yanitskiyaeb54a22020-09-01 06:25:25 +07008371 execute( TC_fh_params_assignment_cmd() );
Vadim Yanitskiy8f5430d2020-09-02 18:51:38 +07008372 execute( TC_fh_params_handover_cmd() );
Vadim Yanitskiyca974032020-09-01 07:20:39 +07008373 execute( TC_fh_params_si4_cbch() );
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02008374
8375 if (mp_enable_lcs_tests) {
8376 execute( TC_lcs_loc_req_for_active_ms() );
8377 execute( TC_lcs_loc_req_for_active_ms_ta_req() );
8378 execute( TC_lcs_loc_req_for_idle_ms() );
8379 execute( TC_lcs_loc_req_no_subscriber() );
8380 execute( TC_lcs_loc_req_for_active_ms_le_timeout() );
8381 execute( TC_lcs_loc_req_for_active_ms_le_timeout2() );
8382 execute( TC_lcs_loc_req_for_idle_ms_no_pag_resp() );
8383 execute( TC_cm_service_during_lcs_loc_req() );
8384 execute( TC_ho_during_lcs_loc_req() );
8385 }
Harald Welte28d943e2017-11-25 15:00:50 +01008386}
8387
8388}