blob: 9a5faa73b6b1f3d75bc0018517148bb7c79aec8c [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))) {
Neels Hofmeyr4f5d7be2020-10-16 16:28:16 +0200777 log("BSSMAP: Received RESET-ACK in response to RESET, we're ready to go!");
Harald Weltea4ca4462018-02-09 00:17:14 +0100778 }
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200779 [] BSSAP.receive(tr_BSSAP_UNITDATA_ind(?, ?, tr_BSSMAP_Reset(g_osmux_enabled))) -> value ud_ind {
Neels Hofmeyr4f5d7be2020-10-16 16:28:16 +0200780 log("BSSMAP: Respoding to inbound RESET with RESET-ACK");
Harald Weltea4ca4462018-02-09 00:17:14 +0100781 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 {
Neels Hofmeyr4f5d7be2020-10-16 16:28:16 +0200788 log("BSSMAP: Timeout waiting for RESET-ACK after sending RESET");
Pau Espin Pedrol24c05992020-09-01 12:54:12 +0200789 /* 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);
Neels Hofmeyr1708d1b2020-10-10 16:56:48 +02003167 /* Emit a marker to appear in the SUT's own logging output */
3168 f_logp(BSCVTY, testcasename() & "() start");
Harald Weltea0630032018-03-20 21:09:55 +01003169 vc_conn.start(f_handler_init(fn, id, pars));
Harald Weltec1a2fff2017-12-17 11:06:19 +01003170 return vc_conn;
3171}
3172
Harald Weltea0630032018-03-20 21:09:55 +01003173/* first function inside ConnHdlr component; sets g_pars + starts function */
3174private function f_handler_init(void_fn fn, charstring id, template (omit) TestHdlrParams pars := omit)
3175runs on MSC_ConnHdlr {
3176 if (isvalue(pars)) {
3177 g_pars := valueof(pars);
3178 }
3179 fn.apply(id);
3180}
3181
Harald Welte3c86ea02018-05-10 22:28:05 +02003182/* Establish signalling channel (non-assignment case) followed by cipher mode */
3183private function f_tc_ciph_mode_a5(charstring id) runs on MSC_ConnHdlr {
Harald Welteed848512018-05-24 22:27:58 +02003184 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3185 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte3c86ea02018-05-10 22:28:05 +02003186 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeSIGNAL);
Philipp Maier23000732018-05-18 11:25:37 +02003187 ass_cmd.pdu.bssmap.assignmentRequest.circuitIdentityCode := omit;
3188 ass_cmd.pdu.bssmap.assignmentRequest.aoIPTransportLayer := omit;
3189 exp_compl.pdu.bssmap.assignmentComplete.circuitIdentityCode := omit;
3190 exp_compl.pdu.bssmap.assignmentComplete.aoIPTransportLayer := omit;
Harald Welte3c86ea02018-05-10 22:28:05 +02003191
Philipp Maier23000732018-05-18 11:25:37 +02003192 f_establish_fully(ass_cmd, exp_compl);
Harald Welte3c86ea02018-05-10 22:28:05 +02003193}
3194testcase TC_ciph_mode_a5_0() runs on test_CT {
3195 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02003196 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte3c86ea02018-05-10 22:28:05 +02003197 pars.encr := valueof(t_EncrParams('01'O, f_rnd_octstring(8)));
3198
3199 f_init(1, true);
3200 f_sleep(1.0);
3201 vc_conn := f_start_handler(refers(f_tc_ciph_mode_a5), pars);
3202 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003203 f_shutdown_helper();
Harald Welte3c86ea02018-05-10 22:28:05 +02003204}
3205testcase TC_ciph_mode_a5_1() runs on test_CT {
3206 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02003207 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte3c86ea02018-05-10 22:28:05 +02003208 pars.encr := valueof(t_EncrParams('02'O, f_rnd_octstring(8)));
3209
3210 f_init(1, true);
3211 f_sleep(1.0);
3212 vc_conn := f_start_handler(refers(f_tc_ciph_mode_a5), pars);
3213 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003214 f_shutdown_helper();
Harald Welte3c86ea02018-05-10 22:28:05 +02003215}
3216testcase TC_ciph_mode_a5_3() runs on test_CT {
3217 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02003218 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte3c86ea02018-05-10 22:28:05 +02003219 pars.encr := valueof(t_EncrParams('08'O, f_rnd_octstring(8)));
3220
3221 f_init(1, true);
3222 f_sleep(1.0);
3223 vc_conn := f_start_handler(refers(f_tc_ciph_mode_a5), pars);
3224 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003225 f_shutdown_helper();
Harald Welte3c86ea02018-05-10 22:28:05 +02003226}
3227
Pau Espin Pedrol07866632020-09-03 19:10:55 +02003228/* establish initial channel, enable ciphering followed by assignment to ciphered channel */
3229private function f_tc_assignment_aoip_tla_v6(charstring id) runs on MSC_ConnHdlr {
3230 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3231 var PDU_BSSAP ass_cmd := f_gen_ass_req(aoip_tla := "::3");
3232 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3233 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
3234
3235 f_establish_fully(ass_cmd, exp_compl);
3236}
3237testcase TC_assignment_aoip_tla_v6() runs on test_CT {
3238 var MSC_ConnHdlr vc_conn;
3239 var TestHdlrParams pars := f_gen_test_hdlr_pars();
3240
3241 f_init(1, true);
3242 f_sleep(1.0);
3243 vc_conn := f_start_handler(refers(f_tc_assignment_aoip_tla_v6), pars);
3244 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003245 f_shutdown_helper();
Pau Espin Pedrol07866632020-09-03 19:10:55 +02003246}
3247
Harald Welte3c86ea02018-05-10 22:28:05 +02003248
3249/* establish initial channel, enable ciphering followed by assignment to ciphered channel */
Harald Welte651fcdc2018-05-10 20:23:16 +02003250private function f_tc_assignment_fr_a5(charstring id) runs on MSC_ConnHdlr {
Harald Welteed848512018-05-24 22:27:58 +02003251 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3252 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Weltec1a2fff2017-12-17 11:06:19 +01003253
Harald Welte552620d2017-12-16 23:21:36 +01003254 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3255 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
Harald Welte73cd2712017-12-17 00:44:52 +01003256
Harald Weltea0630032018-03-20 21:09:55 +01003257 f_establish_fully(ass_cmd, exp_compl);
Harald Welte552620d2017-12-16 23:21:36 +01003258}
Harald Welte552620d2017-12-16 23:21:36 +01003259testcase TC_assignment_fr_a5_0() runs on test_CT {
3260 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02003261 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte651fcdc2018-05-10 20:23:16 +02003262 pars.encr := valueof(t_EncrParams('01'O, f_rnd_octstring(8)));
Harald Welte552620d2017-12-16 23:21:36 +01003263
Harald Welte89d42e82017-12-17 16:42:41 +01003264 f_init(1, true);
Harald Welte552620d2017-12-16 23:21:36 +01003265 f_sleep(1.0);
Harald Welte651fcdc2018-05-10 20:23:16 +02003266 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5), pars);
Harald Welte552620d2017-12-16 23:21:36 +01003267 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003268 f_shutdown_helper();
Harald Welte552620d2017-12-16 23:21:36 +01003269}
Harald Welte552620d2017-12-16 23:21:36 +01003270testcase TC_assignment_fr_a5_1() runs on test_CT {
Harald Weltec1a2fff2017-12-17 11:06:19 +01003271 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02003272 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte651fcdc2018-05-10 20:23:16 +02003273 pars.encr := valueof(t_EncrParams('02'O, f_rnd_octstring(8)));
Harald Weltec1a2fff2017-12-17 11:06:19 +01003274
Harald Welte89d42e82017-12-17 16:42:41 +01003275 f_init(1, true);
Harald Weltec1a2fff2017-12-17 11:06:19 +01003276 f_sleep(1.0);
Harald Welte651fcdc2018-05-10 20:23:16 +02003277 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5), pars);
3278 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003279 f_shutdown_helper();
Harald Welte651fcdc2018-05-10 20:23:16 +02003280}
3281testcase TC_assignment_fr_a5_3() runs on test_CT {
3282 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02003283 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte651fcdc2018-05-10 20:23:16 +02003284 pars.encr := valueof(t_EncrParams('08'O, f_rnd_octstring(8)));
Harald Weltec1a2fff2017-12-17 11:06:19 +01003285
Harald Welte651fcdc2018-05-10 20:23:16 +02003286 f_init(1, true);
3287 f_sleep(1.0);
3288 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5), pars);
Harald Weltec1a2fff2017-12-17 11:06:19 +01003289 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003290 f_shutdown_helper();
Harald Weltec1a2fff2017-12-17 11:06:19 +01003291}
3292
Harald Welte552620d2017-12-16 23:21:36 +01003293/* Expect ASSIGNMENT FAIL if mandatory IE is missing */
3294private function f_tc_assignment_fr_a5_1_codec_missing(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02003295 g_pars := f_gen_test_hdlr_pars();
Harald Welte552620d2017-12-16 23:21:36 +01003296 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
Harald Welteed848512018-05-24 22:27:58 +02003297 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte552620d2017-12-16 23:21:36 +01003298 const OCT8 kc := '0001020304050607'O;
3299
3300 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02003301 /* Omit: ass_cmd.pdu.bssmap.assignmentRequest.codecList */
3302
Harald Weltea0630032018-03-20 21:09:55 +01003303 f_establish_fully(ass_cmd, exp_fail);
Harald Welte552620d2017-12-16 23:21:36 +01003304}
Harald Welte552620d2017-12-16 23:21:36 +01003305testcase TC_assignment_fr_a5_1_codec_missing() runs on test_CT {
3306 var MSC_ConnHdlr vc_conn;
3307
Harald Welte89d42e82017-12-17 16:42:41 +01003308 f_init(1, true);
Harald Welte552620d2017-12-16 23:21:36 +01003309 f_sleep(1.0);
3310
Harald Welte8863fa12018-05-10 20:15:27 +02003311 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5_1_codec_missing));
Harald Welte552620d2017-12-16 23:21:36 +01003312 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003313 f_shutdown_helper();
Harald Welte552620d2017-12-16 23:21:36 +01003314}
3315
Harald Welte552620d2017-12-16 23:21:36 +01003316private function f_tc_assignment_fr_a5_4(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02003317 g_pars := f_gen_test_hdlr_pars();
Harald Welteed848512018-05-24 22:27:58 +02003318 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3319 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte552620d2017-12-16 23:21:36 +01003320 const OCT8 kc := '0001020304050607'O;
3321 const OCT16 kc128 := kc & kc;
3322
3323 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3324 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
Harald Weltea0630032018-03-20 21:09:55 +01003325 f_establish_fully(ass_cmd, exp_compl);
Harald Welte38b2a102017-12-23 02:42:58 +01003326 f_cipher_mode('10'O, kc, kc128, true);
Harald Welte552620d2017-12-16 23:21:36 +01003327 /* TODO: expect GSM0808_CAUSE_CIPHERING_ALGORITHM_NOT_SUPPORTED cause value */
Harald Welte552620d2017-12-16 23:21:36 +01003328}
Harald Welte552620d2017-12-16 23:21:36 +01003329testcase TC_assignment_fr_a5_4() runs on test_CT {
3330 var MSC_ConnHdlr vc_conn;
3331
Harald Welte89d42e82017-12-17 16:42:41 +01003332 f_init(1, true);
Harald Welte552620d2017-12-16 23:21:36 +01003333 f_sleep(1.0);
3334
Harald Welte8863fa12018-05-10 20:15:27 +02003335 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5_4));
Harald Welte552620d2017-12-16 23:21:36 +01003336 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003337 f_shutdown_helper();
Harald Welte552620d2017-12-16 23:21:36 +01003338}
3339
3340
Harald Welte4532e0a2017-12-23 02:05:44 +01003341private function f_tc_assignment_sign(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02003342 g_pars := f_gen_test_hdlr_pars();
Harald Welte4532e0a2017-12-23 02:05:44 +01003343 var template PDU_BSSAP exp_compl := tr_BSSMAP_AssignmentComplete(omit, omit);
Philipp Maier48604732018-10-09 15:00:37 +02003344 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte4532e0a2017-12-23 02:05:44 +01003345 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeSIGNAL);
Daniel Willmannebdecc02020-08-12 15:30:17 +02003346
3347 f_statsd_reset();
Harald Weltea0630032018-03-20 21:09:55 +01003348 f_establish_fully(ass_cmd, exp_compl);
Daniel Willmannebdecc02020-08-12 15:30:17 +02003349
3350 var StatsDExpects expect := {
Daniel Willmannc5398f72020-09-21 10:41:35 +02003351 { name := "TTCN3.bts.0.chreq.total", mtype := "c", min := 1, max := 1},
3352 { name := "TTCN3.bts.0.chreq.successful", mtype := "c", min := 1, max := 1},
Daniel Willmannebdecc02020-08-12 15:30:17 +02003353 { name := "TTCN3.bsc.0.assignment.attempted", mtype := "c", min := 1, max := 1},
3354 { name := "TTCN3.bsc.0.assignment.completed", mtype := "c", min := 1, max := 1}
3355 };
3356 f_statsd_expect(expect);
Harald Welte4532e0a2017-12-23 02:05:44 +01003357}
3358
3359testcase TC_assignment_sign() runs on test_CT {
3360 var MSC_ConnHdlr vc_conn;
3361
3362 f_init(1, true);
3363 f_sleep(1.0);
3364
Harald Welte8863fa12018-05-10 20:15:27 +02003365 vc_conn := f_start_handler(refers(f_tc_assignment_sign));
Harald Welte4532e0a2017-12-23 02:05:44 +01003366 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003367 f_shutdown_helper();
Harald Welte4532e0a2017-12-23 02:05:44 +01003368}
3369
Harald Welte60aa5762018-03-21 19:33:13 +01003370/***********************************************************************
3371 * Codec (list) testing
3372 ***********************************************************************/
3373
3374/* check if the given rsl_mode is compatible with the a_elem */
3375private function f_match_codec(BSSMAP_FIELD_CodecElement a_elem, RSL_IE_ChannelMode rsl_mode)
3376return boolean {
3377 select (a_elem.codecType) {
3378 case (GSM_FR) {
3379 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM1))) {
3380 return true;
3381 }
3382 }
3383 case (GSM_HR) {
3384 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_H, RSL_CMOD_SP_GSM1))) {
3385 return true;
3386 }
3387 }
3388 case (GSM_EFR) {
3389 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM2))) {
3390 return true;
3391 }
3392 }
3393 case (FR_AMR) {
3394 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM3))) {
3395 return true;
3396 }
3397 }
3398 case (HR_AMR) {
3399 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_H, RSL_CMOD_SP_GSM3))) {
3400 return true;
3401 }
3402 }
3403 case else { }
3404 }
3405 return false;
3406}
3407
3408/* check if the given rsl_mode is compatible with the a_list */
3409private function f_match_codecs(BSSMAP_IE_SpeechCodecList a_list, RSL_IE_ChannelMode rsl_mode)
3410return boolean {
3411 for (var integer i := 0; i < sizeof(a_list); i := i+1) {
3412 if (f_match_codec(a_list.codecElements[i], rsl_mode)) {
3413 return true;
3414 }
3415 }
3416 return false;
3417}
3418
3419/* determine BSSMAP_IE_ChannelType from *first* element of BSSMAP_FIELD_CodecElement */
Philipp Maier61f6b572018-07-06 14:03:38 +02003420function f_BSSMAP_chtype_from_codec(BSSMAP_FIELD_CodecElement a_elem)
Harald Welte60aa5762018-03-21 19:33:13 +01003421return BSSMAP_IE_ChannelType {
3422 /* FIXME: actually look at all elements of BSSMAP_IE_SpeechCodecList */
3423 var BSSMAP_IE_ChannelType ret := valueof(ts_BSSMAP_IE_ChannelType);
3424 select (a_elem.codecType) {
3425 case (GSM_FR) {
3426 ret.channelRateAndType := ChRate_TCHF;
3427 ret.speechId_DataIndicator := Spdi_TCHF_FR;
3428 }
3429 case (GSM_HR) {
3430 ret.channelRateAndType := ChRate_TCHH;
3431 ret.speechId_DataIndicator := Spdi_TCHH_HR;
3432 }
3433 case (GSM_EFR) {
3434 ret.channelRateAndType := ChRate_TCHF;
3435 ret.speechId_DataIndicator := Spdi_TCHF_EFR;
3436 }
3437 case (FR_AMR) {
3438 ret.channelRateAndType := ChRate_TCHF;
3439 ret.speechId_DataIndicator := Spdi_TCHF_AMR;
3440 }
3441 case (HR_AMR) {
3442 ret.channelRateAndType := ChRate_TCHH;
3443 ret.speechId_DataIndicator := Spdi_TCHH_AMR;
3444 }
3445 case else {
3446 setverdict(fail, "Unsupported codec ", a_elem);
Daniel Willmannafce8662018-07-06 23:11:32 +02003447 mtc.stop;
Harald Welte60aa5762018-03-21 19:33:13 +01003448 }
3449 }
3450 return ret;
3451}
3452
Harald Weltea63b9102018-03-22 20:36:16 +01003453private function f_rsl_chmod_tmpl_from_codec(BSSMAP_FIELD_CodecElement a_elem)
3454return template RSL_IE_Body {
3455 var template RSL_IE_Body mode_ie := {
3456 chan_mode := {
3457 len := ?,
3458 reserved := ?,
3459 dtx_d := ?,
3460 dtx_u := ?,
3461 spd_ind := RSL_SPDI_SPEECH,
3462 ch_rate_type := -,
3463 coding_alg_rate := -
3464 }
3465 }
3466
3467 select (a_elem.codecType) {
3468 case (GSM_FR) {
3469 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_F;
3470 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM1;
3471 }
3472 case (GSM_HR) {
3473 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_H;
3474 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM1;
3475 }
3476 case (GSM_EFR) {
3477 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_F;
3478 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM2;
3479 }
3480 case (FR_AMR) {
3481 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_F;
3482 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM3;
3483 }
3484 case (HR_AMR) {
3485 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_H;
3486 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM3;
3487 }
3488 }
3489 return mode_ie;
3490}
3491
Harald Welte60aa5762018-03-21 19:33:13 +01003492type record CodecListTest {
3493 BSSMAP_IE_SpeechCodecList codec_list,
3494 charstring id
3495}
3496type record of CodecListTest CodecListTests
3497
3498private function f_TC_assignment_codec(charstring id) runs on MSC_ConnHdlr {
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02003499 var PDU_BSSAP ass_cmd := f_gen_ass_req(g_pars.use_osmux);
3500 var template PDU_BSSAP exp_compl := f_gen_exp_compl(g_pars.use_osmux);
Harald Welte60aa5762018-03-21 19:33:13 +01003501
3502 /* puzzle together the ASSIGNMENT REQ for given codec[s] */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003503 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
Harald Welte79f3f542018-05-25 20:02:37 +02003504 ass_cmd.pdu.bssmap.assignmentRequest.codecList := g_pars.ass_codec_list;
3505 exp_compl.pdu.bssmap.assignmentComplete.speechCodec.codecElements[0] :=
3506 g_pars.ass_codec_list.codecElements[0];
Philipp Maierd0e64b02019-03-13 14:15:23 +01003507 if (isvalue(g_pars.expect_mr_s0_s7)) {
3508 exp_compl.pdu.bssmap.assignmentComplete.speechCodec.codecElements[0].s0_7 :=
3509 g_pars.expect_mr_s0_s7;
3510 }
Harald Welte79f3f542018-05-25 20:02:37 +02003511 }
Harald Welte60aa5762018-03-21 19:33:13 +01003512 ass_cmd.pdu.bssmap.assignmentRequest.channelType :=
3513 f_BSSMAP_chtype_from_codec(g_pars.ass_codec_list.codecElements[0]);
Harald Welte60aa5762018-03-21 19:33:13 +01003514 log("expecting ASS COMPL like this: ", exp_compl);
3515
3516 f_establish_fully(ass_cmd, exp_compl);
Harald Weltea63b9102018-03-22 20:36:16 +01003517
3518 /* Verify that the RSL-side activation actually matches our expectations */
3519 var RSL_Message rsl := f_rslem_get_last_act(RSL_PROC, 0, g_chan_nr);
3520
3521 var RSL_IE_Body mode_ie;
3522 if (f_rsl_find_ie(rsl, RSL_IE_CHAN_MODE, mode_ie) == false) {
3523 setverdict(fail, "Couldn't find CHAN_MODE IE");
Daniel Willmannafce8662018-07-06 23:11:32 +02003524 mtc.stop;
Harald Weltea63b9102018-03-22 20:36:16 +01003525 }
3526 var template RSL_IE_Body t_mode_ie := f_rsl_chmod_tmpl_from_codec(g_pars.ass_codec_list.codecElements[0]);
3527 if (not match(mode_ie, t_mode_ie)) {
3528 setverdict(fail, "RSL Channel Mode IE doesn't match expectation");
3529 }
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02003530
3531 var RSL_IE_Body mr_conf;
3532 if (g_pars.expect_mr_conf_ie != omit) {
3533 if (f_rsl_find_ie(rsl, RSL_IE_MR_CONFIG, mr_conf) == false) {
3534 setverdict(fail, "Missing MR CONFIG IE in RSL Chan Activ");
Daniel Willmannafce8662018-07-06 23:11:32 +02003535 mtc.stop;
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02003536 }
3537 log("found RSL MR CONFIG IE: ", mr_conf);
3538
3539 if (not match(mr_conf, g_pars.expect_mr_conf_ie)) {
3540 setverdict(fail, "RSL MR CONFIG IE does not match expectation. Expected: ",
3541 g_pars.expect_mr_conf_ie);
3542 }
3543 } else {
3544 if (f_rsl_find_ie(rsl, RSL_IE_MR_CONFIG, mr_conf) == true) {
3545 log("found RSL MR CONFIG IE: ", mr_conf);
3546 setverdict(fail, "Found MR CONFIG IE in RSL Chan Activ, expecting omit");
Daniel Willmannafce8662018-07-06 23:11:32 +02003547 mtc.stop;
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02003548 }
3549 }
Harald Welte60aa5762018-03-21 19:33:13 +01003550}
3551
Philipp Maierd0e64b02019-03-13 14:15:23 +01003552private function f_TC_assignment_codec_fail(charstring id) runs on MSC_ConnHdlr {
3553
3554 var PDU_BSSAP ass_cmd := f_gen_ass_req();
3555 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
3556
3557 /* puzzle together the ASSIGNMENT REQ for given codec[s] */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003558 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
Philipp Maierd0e64b02019-03-13 14:15:23 +01003559 ass_cmd.pdu.bssmap.assignmentRequest.codecList := g_pars.ass_codec_list;
3560 }
3561 ass_cmd.pdu.bssmap.assignmentRequest.channelType :=
3562 f_BSSMAP_chtype_from_codec(g_pars.ass_codec_list.codecElements[0]);
3563 log("expecting ASS FAIL like this: ", exp_fail);
3564
3565 f_establish_fully(ass_cmd, exp_fail);
3566}
3567
Harald Welte60aa5762018-03-21 19:33:13 +01003568testcase TC_assignment_codec_fr() runs on test_CT {
Philipp Maier48604732018-10-09 15:00:37 +02003569 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte60aa5762018-03-21 19:33:13 +01003570 var MSC_ConnHdlr vc_conn;
3571
3572 f_init(1, true);
3573 f_sleep(1.0);
3574
3575 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
Harald Welte8863fa12018-05-10 20:15:27 +02003576 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01003577 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003578 f_shutdown_helper();
Harald Welte60aa5762018-03-21 19:33:13 +01003579}
3580
3581testcase TC_assignment_codec_hr() runs on test_CT {
Philipp Maier48604732018-10-09 15:00:37 +02003582 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte60aa5762018-03-21 19:33:13 +01003583 var MSC_ConnHdlr vc_conn;
3584
3585 f_init(1, true);
3586 f_sleep(1.0);
3587
3588 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR}));
Harald Welte8863fa12018-05-10 20:15:27 +02003589 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01003590 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003591 f_shutdown_helper();
Harald Welte60aa5762018-03-21 19:33:13 +01003592}
3593
3594testcase TC_assignment_codec_efr() runs on test_CT {
Philipp Maier48604732018-10-09 15:00:37 +02003595 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte60aa5762018-03-21 19:33:13 +01003596 var MSC_ConnHdlr vc_conn;
3597
3598 f_init(1, true);
3599 f_sleep(1.0);
3600
3601 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecEFR}));
Harald Welte8863fa12018-05-10 20:15:27 +02003602 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01003603 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003604 f_shutdown_helper();
Harald Welte60aa5762018-03-21 19:33:13 +01003605}
3606
Philipp Maierd0e64b02019-03-13 14:15:23 +01003607/* Allow 5,90k only (current default config) */
3608private function f_allow_amr_rate_5_90k() runs on test_CT {
3609 f_vty_enter_cfg_msc(BSCVTY, 0);
3610 f_vty_transceive(BSCVTY, "amr-config 12_2k forbidden");
3611 f_vty_transceive(BSCVTY, "amr-config 10_2k forbidden");
3612 f_vty_transceive(BSCVTY, "amr-config 7_95k forbidden");
3613 f_vty_transceive(BSCVTY, "amr-config 7_40k forbidden");
3614 f_vty_transceive(BSCVTY, "amr-config 6_70k forbidden");
3615 f_vty_transceive(BSCVTY, "amr-config 5_90k allowed");
3616 f_vty_transceive(BSCVTY, "amr-config 5_15k forbidden");
3617 f_vty_transceive(BSCVTY, "amr-config 4_75k forbidden");
3618 f_vty_transceive(BSCVTY, "exit");
3619 f_vty_transceive(BSCVTY, "exit");
3620}
3621
3622/* Allow 4,75k, 5,90k, 4,70k and 12,2k, which are the most common rates
3623 * ("Config-NB-Code = 1") */
3624private function f_allow_amr_rate_4_75k_5_90k_7_40k_12_20k() runs on test_CT {
3625 f_vty_enter_cfg_msc(BSCVTY, 0);
3626 f_vty_transceive(BSCVTY, "amr-config 12_2k allowed");
3627 f_vty_transceive(BSCVTY, "amr-config 10_2k forbidden");
3628 f_vty_transceive(BSCVTY, "amr-config 7_95k forbidden");
3629 f_vty_transceive(BSCVTY, "amr-config 7_40k allowed");
3630 f_vty_transceive(BSCVTY, "amr-config 6_70k forbidden");
3631 f_vty_transceive(BSCVTY, "amr-config 5_90k allowed");
3632 f_vty_transceive(BSCVTY, "amr-config 5_15k forbidden");
3633 f_vty_transceive(BSCVTY, "amr-config 4_75k allowed");
3634 f_vty_transceive(BSCVTY, "exit");
3635 f_vty_transceive(BSCVTY, "exit");
3636}
3637
Harald Welte60aa5762018-03-21 19:33:13 +01003638testcase TC_assignment_codec_amr_f() runs on test_CT {
Philipp Maier48604732018-10-09 15:00:37 +02003639 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte60aa5762018-03-21 19:33:13 +01003640 var MSC_ConnHdlr vc_conn;
Philipp Maier7695a0d2018-09-27 17:52:14 +02003641
3642 /* Note: This setups the codec configuration. The parameter payload in
3643 * mr_conf must be consistant with the parameter codecElements in pars
3644 * and also must match the amr-config in osmo-bsc.cfg! */
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02003645 var RSL_IE_Body mr_conf := {
3646 other := {
3647 len := 2,
3648 payload := '2804'O
3649 }
3650 };
Harald Welte60aa5762018-03-21 19:33:13 +01003651
Philipp Maier7695a0d2018-09-27 17:52:14 +02003652 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_F}));
Philipp Maier806f8f12019-03-12 12:13:41 +01003653 pars.ass_codec_list.codecElements[0].s0_7 := '00000100'B; /* 5,90k */
Philipp Maier7695a0d2018-09-27 17:52:14 +02003654 pars.ass_codec_list.codecElements[0].s8_15 := '01010111'B;
3655 pars.expect_mr_conf_ie := mr_conf;
3656
Harald Welte60aa5762018-03-21 19:33:13 +01003657 f_init(1, true);
3658 f_sleep(1.0);
3659
Harald Welte8863fa12018-05-10 20:15:27 +02003660 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01003661 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003662 f_shutdown_helper();
Harald Welte60aa5762018-03-21 19:33:13 +01003663}
3664
3665testcase TC_assignment_codec_amr_h() runs on test_CT {
Philipp Maier48604732018-10-09 15:00:37 +02003666 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte60aa5762018-03-21 19:33:13 +01003667 var MSC_ConnHdlr vc_conn;
Philipp Maier7695a0d2018-09-27 17:52:14 +02003668
3669 /* See note above */
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02003670 var RSL_IE_Body mr_conf := {
3671 other := {
3672 len := 2,
3673 payload := '2804'O
3674 }
3675 };
Harald Welte60aa5762018-03-21 19:33:13 +01003676
Philipp Maier7695a0d2018-09-27 17:52:14 +02003677 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_H}));
Philipp Maier806f8f12019-03-12 12:13:41 +01003678 pars.ass_codec_list.codecElements[0].s0_7 := '00000100'B; /* 5,90k */
Philipp Maier7695a0d2018-09-27 17:52:14 +02003679 pars.ass_codec_list.codecElements[0].s8_15 := '00000111'B;
3680 pars.expect_mr_conf_ie := mr_conf;
3681
Harald Welte60aa5762018-03-21 19:33:13 +01003682 f_init(1, true);
3683 f_sleep(1.0);
3684
Harald Welte8863fa12018-05-10 20:15:27 +02003685 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01003686 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003687 f_shutdown_helper();
Harald Welte60aa5762018-03-21 19:33:13 +01003688}
3689
Philipp Maierd0e64b02019-03-13 14:15:23 +01003690function f_TC_assignment_codec_amr(boolean fr, octetstring mrconf, bitstring s8_s0, bitstring exp_s8_s0)
3691runs on test_CT {
3692
3693 var TestHdlrParams pars := f_gen_test_hdlr_pars();
3694 var MSC_ConnHdlr vc_conn;
3695
3696 /* See note above */
3697 var RSL_IE_Body mr_conf := {
3698 other := {
3699 len := lengthof(mrconf),
3700 payload := mrconf
3701 }
3702 };
3703
3704 if (fr) {
3705 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_F}));
3706 } else {
3707 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_H}));
3708 }
3709 pars.ass_codec_list.codecElements[0].s0_7 := s8_s0;
3710 pars.ass_codec_list.codecElements[0].s8_15 := '00000111'B;
3711 pars.expect_mr_conf_ie := mr_conf;
3712 pars.expect_mr_s0_s7 := exp_s8_s0;
3713
3714 f_init(1, true);
3715 f_allow_amr_rate_4_75k_5_90k_7_40k_12_20k();
3716 f_sleep(1.0);
3717
3718 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
3719 vc_conn.done;
3720 f_allow_amr_rate_5_90k();
3721}
3722
3723function f_TC_assignment_codec_amr_fail(boolean fr, bitstring s8_s0)
3724runs on test_CT {
3725
3726 var TestHdlrParams pars := f_gen_test_hdlr_pars();
3727 var MSC_ConnHdlr vc_conn;
3728
3729 if (fr) {
3730 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_F}));
3731 } else {
3732 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_H}));
3733 }
3734 pars.ass_codec_list.codecElements[0].s0_7 := s8_s0;
3735 pars.ass_codec_list.codecElements[0].s8_15 := '00000111'B;
3736
3737 f_init(1, true);
3738 f_allow_amr_rate_4_75k_5_90k_7_40k_12_20k();
3739 f_sleep(1.0);
3740
3741 vc_conn := f_start_handler(refers(f_TC_assignment_codec_fail), pars);
3742 vc_conn.done;
3743 f_allow_amr_rate_5_90k();
3744}
3745
3746
3747/* Set S1, we expect an AMR multirate configuration IE with all four rates
3748 * set. */
3749testcase TC_assignment_codec_amr_f_S1() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003750 f_TC_assignment_codec_amr(true, '289520882208'O, '00000010'B, '00000010'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003751 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003752}
3753
3754/* Set S1, we expect an AMR multirate configuration IE with the lower three
3755 * rates set. */
3756testcase TC_assignment_codec_amr_h_S1() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003757 f_TC_assignment_codec_amr(false, '2815208820'O, '00000010'B, '00000010'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003758 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003759}
3760
3761/* Set S1 and two other rates, we expect an AMR MULTIRATE CONFIGURATION IE with
3762 * all four rates (and only S1 set in the ASSIGNMENT COMPLETE) */
3763testcase TC_assignment_codec_amr_f_S124() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003764 f_TC_assignment_codec_amr(true, '289520882208'O, '00010110'B, '00000010'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003765 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003766}
3767
3768/* Set S1 and two other rates, we expect an AMR MULTIRATE CONFIGURATION IE with
3769 * all four rates (and only S1 set in the ASSIGNMENT COMPLETE) */
3770testcase TC_assignment_codec_amr_h_S124() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003771 f_TC_assignment_codec_amr(false, '2815208820'O, '00010110'B, '00000010'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003772 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003773}
3774
3775/* The following block of tests selects more and more rates until all four
3776 * possible rates are in the active set (full rate) */
3777testcase TC_assignment_codec_amr_f_S0() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003778 f_TC_assignment_codec_amr(true, '2801'O, '00000001'B, '00000001'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003779 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003780}
3781
3782testcase TC_assignment_codec_amr_f_S02() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003783 f_TC_assignment_codec_amr(true, '28052080'O, '00000101'B, '00000101'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003784 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003785}
3786
3787testcase TC_assignment_codec_amr_f_S024() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003788 f_TC_assignment_codec_amr(true, '2815208820'O, '00010101'B, '00010101'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003789 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003790}
3791
3792testcase TC_assignment_codec_amr_f_S0247() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003793 f_TC_assignment_codec_amr(true, '289520882208'O, '10010101'B, '10010101'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003794 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003795}
3796
3797/* The following block of tests selects more and more rates until all three
3798 * possible rates are in the active set (half rate) */
3799testcase TC_assignment_codec_amr_h_S0() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003800 f_TC_assignment_codec_amr(false, '2801'O, '00000001'B, '00000001'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003801 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003802}
3803
3804testcase TC_assignment_codec_amr_h_S02() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003805 f_TC_assignment_codec_amr(false, '28052080'O, '00000101'B, '00000101'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003806 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003807}
3808
3809testcase TC_assignment_codec_amr_h_S024() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003810 f_TC_assignment_codec_amr(false, '2815208820'O, '00010101'B, '00010101'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003811 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003812}
3813
3814/* The following block tests what happens when the MSC does offer rate
3815 * configurations that are not supported by the BSC. Normally such situations
3816 * should not happen because the MSC gets informed by the BSC in advance via
3817 * the L3 COMPLETE message which rates are applicable. The MSC should not try
3818 * to offer rates that are not applicable anyway. */
3819
3820testcase TC_assignment_codec_amr_h_S0247() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003821 /* Try to include 12,2k in into the active set even though the channel
3822 * is half rate only. The BSC is expected to remove the 12,0k */
3823 f_TC_assignment_codec_amr(false, '2815208820'O, '10010101'B, '00010101'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003824 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003825}
3826
3827testcase TC_assignment_codec_amr_f_S01234567() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003828 /* See what happens when all rates are selected at once. Since then
3829 * Also S1 is selected, this setting will be prefered and we should
3830 * get 12.2k, 7,40k, 5,90k, and 4,75k in the active set. */
3831 f_TC_assignment_codec_amr(true, '289520882208'O, '11111111'B, '00000010'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003832 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003833}
3834
3835testcase TC_assignment_codec_amr_f_S0234567() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003836 /* Same as above, but with S1 missing, the MSC is then expected to
3837 * select the currently supported rates, which are also 12.2k, 7,40k,
3838 * 5,90k, and 4,75k, into the active set. */
3839 f_TC_assignment_codec_amr(true, '289520882208'O, '11111101'B, '10010101'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003840 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003841}
3842
3843testcase TC_assignment_codec_amr_f_zero() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003844 /* Try to select no rates at all */
3845 f_TC_assignment_codec_amr_fail(true, '00000000'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003846 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003847}
3848
3849testcase TC_assignment_codec_amr_f_unsupp() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003850 /* Try to select only unsupported rates */
3851 f_TC_assignment_codec_amr_fail(true, '01101000'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003852 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003853}
3854
3855testcase TC_assignment_codec_amr_h_S7() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003856 /* Try to select 12,2k for half rate */
3857 f_TC_assignment_codec_amr_fail(false, '10000000'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003858 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003859}
3860
Philipp Maierac09bfc2019-01-08 13:41:39 +01003861private function f_disable_all_tch_f() runs on test_CT {
Philipp Maierc704a882019-01-29 15:58:52 +01003862 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 1 sub-slot 0 borken");
3863 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 2 sub-slot 0 borken");
3864 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 3 sub-slot 0 borken");
3865 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 4 sub-slot 0 borken");
Philipp Maierac09bfc2019-01-08 13:41:39 +01003866}
3867
3868private function f_disable_all_tch_h() runs on test_CT {
Philipp Maierc704a882019-01-29 15:58:52 +01003869 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 5 sub-slot 0 borken");
3870 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 5 sub-slot 1 borken");
Philipp Maierac09bfc2019-01-08 13:41:39 +01003871}
3872
3873private function f_enable_all_tch() runs on test_CT {
Philipp Maierc704a882019-01-29 15:58:52 +01003874 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 1 sub-slot 0 unused");
3875 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 2 sub-slot 0 unused");
3876 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 3 sub-slot 0 unused");
3877 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 4 sub-slot 0 unused");
3878 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 5 sub-slot 0 unused");
3879 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 5 sub-slot 1 unused");
Philipp Maierac09bfc2019-01-08 13:41:39 +01003880}
3881
3882/* Allow HR only */
3883private function f_TC_assignment_codec_xr_exhausted_req_hr(charstring id) runs on MSC_ConnHdlr {
3884 g_pars := f_gen_test_hdlr_pars();
3885 var PDU_BSSAP ass_cmd := f_gen_ass_req();
3886 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3887 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3888 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '09'O;
3889 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '05'O;
3890 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR}));
3891 f_establish_fully(ass_cmd, exp_compl);
3892}
3893
3894/* Allow FR only */
3895private function f_TC_assignment_codec_xr_exhausted_req_fr(charstring id) runs on MSC_ConnHdlr {
3896 g_pars := f_gen_test_hdlr_pars();
3897 var PDU_BSSAP ass_cmd := f_gen_ass_req();
3898 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3899 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3900 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '08'O;
3901 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '01'O;
3902 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
3903 f_establish_fully(ass_cmd, exp_compl);
3904}
3905
3906/* Allow HR only (expect assignment failure) */
3907private function f_TC_assignment_codec_xr_exhausted_req_hr_fail(charstring id) runs on MSC_ConnHdlr {
3908 g_pars := f_gen_test_hdlr_pars();
3909 var PDU_BSSAP ass_cmd := f_gen_ass_req();
3910 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
3911 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3912 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '09'O;
3913 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '05'O;
3914 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR}));
3915 f_establish_fully(ass_cmd, exp_fail);
3916}
3917
3918/* Allow FR only (expect assignment failure) */
3919private function f_TC_assignment_codec_xr_exhausted_req_fr_fail(charstring id) runs on MSC_ConnHdlr {
3920 g_pars := f_gen_test_hdlr_pars();
3921 var PDU_BSSAP ass_cmd := f_gen_ass_req();
3922 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
3923 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3924 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '08'O;
3925 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '01'O;
3926 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
3927 f_establish_fully(ass_cmd, exp_fail);
3928}
3929
3930/* Allow FR and HR, but prefer FR */
3931private function f_TC_assignment_codec_fr_exhausted_req_fr_hr(charstring id) runs on MSC_ConnHdlr {
3932 g_pars := f_gen_test_hdlr_pars();
3933 var PDU_BSSAP ass_cmd := f_gen_ass_req();
3934 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3935 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3936 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0A'O; /* Prefer FR */
3937 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8105'O;
3938 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR, ts_CodecHR}));
3939 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000101'B; /* Expect HR */
3940 f_establish_fully(ass_cmd, exp_compl);
3941}
3942
3943/* Allow FR and HR, but prefer HR */
3944private function f_TC_assignment_codec_fr_exhausted_req_hr_fr(charstring id) runs on MSC_ConnHdlr {
3945 g_pars := f_gen_test_hdlr_pars();
3946 var PDU_BSSAP ass_cmd := f_gen_ass_req();
3947 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3948 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3949 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0B'O; /* Prefer HR */
3950 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8501'O;
3951 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR, ts_CodecFR}));
3952 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000101'B; /* Expect HR */
3953 f_establish_fully(ass_cmd, exp_compl);
3954}
3955
3956/* Allow FR and HR, but prefer FR */
3957private function f_TC_assignment_codec_hr_exhausted_req_fr_hr(charstring id) runs on MSC_ConnHdlr {
3958 g_pars := f_gen_test_hdlr_pars();
3959 var PDU_BSSAP ass_cmd := f_gen_ass_req();
3960 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3961 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3962 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0A'O; /* Prefer FR */
3963 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8105'O;
3964 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR, ts_CodecHR}));
3965 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000001'B; /* Expect FR */
3966 f_establish_fully(ass_cmd, exp_compl);
3967}
3968
3969/* Allow FR and HR, but prefer HR */
3970private function f_TC_assignment_codec_hr_exhausted_req_hr_fr(charstring id) runs on MSC_ConnHdlr {
3971 g_pars := f_gen_test_hdlr_pars();
3972 var PDU_BSSAP ass_cmd := f_gen_ass_req();
3973 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3974 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3975 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0B'O; /* Prefer HR */
3976 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8501'O;
3977 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR, ts_CodecFR}));
3978 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000001'B; /* Expect FR */
3979 f_establish_fully(ass_cmd, exp_compl);
3980}
3981
3982/* Request a HR channel while all FR channels are exhausted, this is expected
3983 * to work without conflicts */
3984testcase TC_assignment_codec_fr_exhausted_req_hr() runs on test_CT {
3985 var MSC_ConnHdlr vc_conn;
3986 f_init(1, true);
3987 f_sleep(1.0);
3988 f_enable_all_tch();
3989 f_disable_all_tch_f();
3990 vc_conn := f_start_handler(refers(f_TC_assignment_codec_xr_exhausted_req_hr));
3991 vc_conn.done;
3992 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003993 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01003994}
3995
3996/* Request a FR channel while all FR channels are exhausted, this is expected
3997 * to fail. */
3998testcase TC_assignment_codec_fr_exhausted_req_fr() runs on test_CT {
3999 var MSC_ConnHdlr vc_conn;
4000 f_init(1, true);
4001 f_sleep(1.0);
4002 f_enable_all_tch();
4003 f_disable_all_tch_f();
4004 vc_conn := f_start_handler(refers(f_TC_assignment_codec_xr_exhausted_req_fr_fail));
4005 vc_conn.done;
4006 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004007 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004008}
4009
4010/* Request a FR (prefered) or alternatively a HR channel while all FR channels
4011 * are exhausted, this is expected to be resolved by selecting a HR channel. */
4012testcase TC_assignment_codec_fr_exhausted_req_fr_hr() runs on test_CT {
4013 var MSC_ConnHdlr vc_conn;
4014 f_init(1, true);
4015 f_sleep(1.0);
4016 f_enable_all_tch();
4017 f_disable_all_tch_f();
4018 vc_conn := f_start_handler(refers(f_TC_assignment_codec_fr_exhausted_req_fr_hr));
4019 vc_conn.done;
4020 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004021 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004022}
4023
4024/* Request a HR (prefered) or alternatively a FR channel while all FR channels
4025 * are exhausted, this is expected to work without conflicts. */
4026testcase TC_assignment_codec_fr_exhausted_req_hr_fr() runs on test_CT {
4027 var MSC_ConnHdlr vc_conn;
4028 f_init(1, true);
4029 f_sleep(1.0);
4030 f_enable_all_tch();
4031 f_disable_all_tch_f();
4032 vc_conn := f_start_handler(refers(f_TC_assignment_codec_fr_exhausted_req_hr_fr));
4033 vc_conn.done;
4034 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004035 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004036}
4037
4038/* Request a FR channel while all HR channels are exhausted, this is expected
4039 * to work without conflicts */
4040testcase TC_assignment_codec_hr_exhausted_req_fr() runs on test_CT {
4041 var MSC_ConnHdlr vc_conn;
4042 f_init(1, true);
4043 f_sleep(1.0);
4044 f_enable_all_tch();
4045 f_disable_all_tch_h();
4046 vc_conn := f_start_handler(refers(f_TC_assignment_codec_xr_exhausted_req_fr));
4047 vc_conn.done;
4048 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004049 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004050}
4051
4052/* Request a HR channel while all HR channels are exhausted, this is expected
4053 * to fail. */
4054testcase TC_assignment_codec_hr_exhausted_req_hr() runs on test_CT {
4055 var MSC_ConnHdlr vc_conn;
4056 f_init(1, true);
4057 f_sleep(1.0);
4058 f_enable_all_tch();
4059 f_disable_all_tch_h();
4060 vc_conn := f_start_handler(refers(f_TC_assignment_codec_xr_exhausted_req_hr_fail));
4061 vc_conn.done;
4062 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004063 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004064}
4065
4066/* Request a HR (prefered) or alternatively a FR channel while all HR channels
4067 * are exhausted, this is expected to be resolved by selecting a FR channel. */
4068testcase TC_assignment_codec_hr_exhausted_req_hr_fr() runs on test_CT {
4069 var MSC_ConnHdlr vc_conn;
4070 f_init(1, true);
4071 f_sleep(1.0);
4072 f_enable_all_tch();
4073 f_disable_all_tch_h();
4074 vc_conn := f_start_handler(refers(f_TC_assignment_codec_hr_exhausted_req_hr_fr));
4075 vc_conn.done;
4076 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004077 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004078}
4079
4080/* Request a FR (prefered) or alternatively a HR channel while all HR channels
4081 * are exhausted, this is expected to work without conflicts. */
4082testcase TC_assignment_codec_hr_exhausted_req_fr_hr() runs on test_CT {
4083 var MSC_ConnHdlr vc_conn;
4084 f_init(1, true);
4085 f_sleep(1.0);
4086 f_enable_all_tch();
4087 f_disable_all_tch_h();
4088 vc_conn := f_start_handler(refers(f_TC_assignment_codec_hr_exhausted_req_fr_hr));
4089 vc_conn.done;
4090 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004091 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004092}
4093
4094/* Allow FR and HR, but prefer HR */
4095private function f_TC_assignment_codec_req_hr_fr(charstring id) runs on MSC_ConnHdlr {
4096 g_pars := f_gen_test_hdlr_pars();
4097 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4098 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4099 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4100 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0B'O; /* Prefer HR */
4101 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8501'O;
4102 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR, ts_CodecFR}));
4103 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000101'B; /* Expect HR */
4104 f_establish_fully(ass_cmd, exp_compl);
4105}
4106
4107/* Allow FR and HR, but prefer FR */
4108private function f_TC_assignment_codec_req_fr_hr(charstring id) runs on MSC_ConnHdlr {
4109 g_pars := f_gen_test_hdlr_pars();
4110 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4111 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4112 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4113 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0A'O; /* Prefer FR */
4114 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8105'O;
4115 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR, ts_CodecHR}));
4116 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000001'B; /* Expect FR */
4117 f_establish_fully(ass_cmd, exp_compl);
4118}
4119
4120/* Request a HR (prefered) or alternatively a FR channel, it is expected that
4121 * HR, which is the prefered type, is selected. */
4122testcase TC_assignment_codec_req_hr_fr() runs on test_CT {
4123 var MSC_ConnHdlr vc_conn;
4124 f_init(1, true);
4125 f_sleep(1.0);
4126 f_enable_all_tch();
4127 vc_conn := f_start_handler(refers(f_TC_assignment_codec_req_hr_fr));
4128 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004129 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004130}
4131
4132/* Request a FR (prefered) or alternatively a HR channel, it is expected that
4133 * FR, which is the prefered type, is selected. */
4134testcase TC_assignment_codec_req_fr_hr() runs on test_CT {
4135 var MSC_ConnHdlr vc_conn;
4136 f_init(1, true);
4137 f_sleep(1.0);
4138 f_enable_all_tch();
4139 vc_conn := f_start_handler(refers(f_TC_assignment_codec_req_fr_hr));
4140 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004141 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004142}
4143
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02004144testcase TC_assignment_osmux() runs on test_CT {
4145 var TestHdlrParams pars := f_gen_test_hdlr_pars();
4146 var MSC_ConnHdlr vc_conn;
4147
4148 /* See note above */
4149 var RSL_IE_Body mr_conf := {
4150 other := {
4151 len := 2,
4152 payload := '2804'O
4153 }
4154 };
4155
4156 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_H}));
4157 pars.ass_codec_list.codecElements[0].s0_7 := '00000100'B; /* 5,90k */
4158 pars.ass_codec_list.codecElements[0].s8_15 := '00000111'B;
4159 pars.expect_mr_conf_ie := mr_conf;
4160 pars.use_osmux := true;
4161
4162 f_init(1, true, true);
4163 f_sleep(1.0);
4164
4165 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
4166 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004167 f_shutdown_helper();
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02004168}
4169
Neels Hofmeyr92b12b72018-09-18 14:30:23 +02004170/* test the procedure of the MSC requesting a Classmark Update:
4171 * a) BSSMAP Classmark Request should result in RR CLASSMARK ENQUIRY,
4172 * b) L3 RR CLASSMARK CHANGE should result in BSSMAP CLASSMARK UPDATE */
Harald Welte898113b2018-01-31 18:32:21 +01004173private function f_tc_classmark(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02004174 g_pars := f_gen_test_hdlr_pars();
4175
Harald Weltea0630032018-03-20 21:09:55 +01004176 f_create_chan_and_exp();
Harald Welte898113b2018-01-31 18:32:21 +01004177 /* we should now have a COMPL_L3 at the MSC */
4178 BSSAP.receive(tr_BSSMAP_ComplL3);
4179
Neels Hofmeyr92b12b72018-09-18 14:30:23 +02004180 BSSAP.send(ts_BSSMAP_ClassmarkRequest);
4181 RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_CM_ENQUIRY));
4182
Harald Welte898113b2018-01-31 18:32:21 +01004183 f_rsl_send_l3(ts_RRM_CM_CHG(valueof(ts_CM2)));
4184 BSSAP.receive(tr_BSSMAP_ClassmarkUpd(?, omit));
4185 setverdict(pass);
4186}
4187testcase TC_classmark() runs on test_CT {
4188 var MSC_ConnHdlr vc_conn;
4189 f_init(1, true);
4190 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02004191 vc_conn := f_start_handler(refers(f_tc_classmark));
Harald Welte898113b2018-01-31 18:32:21 +01004192 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004193 f_shutdown_helper();
Harald Welte898113b2018-01-31 18:32:21 +01004194}
4195
Harald Welteeddf0e92020-06-21 19:42:15 +02004196/* Send a CommonID from the simulated MSC and verify that the information is used to
4197 * fill BSC-internal data structures (specifically, bsc_subscr associated with subscr_conn) */
4198private function f_tc_common_id(charstring id) runs on MSC_ConnHdlr {
4199 g_pars := f_gen_test_hdlr_pars();
4200 f_MscConnHdlr_init_vty();
4201
4202 f_create_chan_and_exp();
4203 /* we should now have a COMPL_L3 at the MSC */
4204 BSSAP.receive(tr_BSSMAP_ComplL3);
4205
4206 /* Send CommonID */
4207 BSSAP.send(ts_BSSMAP_CommonId(g_pars.imsi));
4208
4209 /* Use VTY to verify that the IMSI of the subscr_conn is set */
4210 var charstring regex := "*(IMSI: " & hex2str(g_pars.imsi) & ")*";
4211 f_vty_transceive_match_regexp_retry(BSCVTY, "show conns", regex, 0, 4, 1.0);
4212
4213 setverdict(pass);
4214}
4215testcase TC_common_id() runs on test_CT {
4216 var MSC_ConnHdlr vc_conn;
4217 f_init(1, true);
4218 f_sleep(1.0);
4219 vc_conn := f_start_handler(refers(f_tc_common_id));
4220 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004221 f_shutdown_helper();
Harald Welteeddf0e92020-06-21 19:42:15 +02004222}
4223
Harald Weltee3bd6582018-01-31 22:51:25 +01004224private function f_est_single_l3(template PDU_ML3_MS_NW l3) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02004225 g_pars := f_gen_test_hdlr_pars();
Harald Weltea0630032018-03-20 21:09:55 +01004226 f_create_chan_and_exp();
Harald Welte898113b2018-01-31 18:32:21 +01004227 /* we should now have a COMPL_L3 at the MSC */
4228 BSSAP.receive(tr_BSSMAP_ComplL3);
4229
Harald Weltee3bd6582018-01-31 22:51:25 +01004230 /* send the single message we want to send */
4231 f_rsl_send_l3(l3);
4232}
4233
4234private function f_bssap_expect_nothing(float sec := 5.00) runs on MSC_ConnHdlr {
4235 timer T := sec;
4236 var PDU_BSSAP bssap;
Harald Welte898113b2018-01-31 18:32:21 +01004237 T.start;
4238 alt {
Harald Weltee3bd6582018-01-31 22:51:25 +01004239 [] BSSAP.receive(PDU_BSSAP:?) -> value bssap {
4240 setverdict(fail, "Unexpected BSSMAP ", bssap);
Daniel Willmannafce8662018-07-06 23:11:32 +02004241 mtc.stop;
Harald Welte898113b2018-01-31 18:32:21 +01004242 }
4243 [] T.timeout {
4244 setverdict(pass);
4245 }
4246 }
4247}
4248
Harald Weltee3bd6582018-01-31 22:51:25 +01004249/* unsolicited ASSIGNMENT FAIL (without ASSIGN) from MS shouldn't bring BSC down */
4250private function f_tc_unsol_ass_fail(charstring id) runs on MSC_ConnHdlr {
4251 f_est_single_l3(ts_RRM_AssignmentFailure('00'O));
4252 f_bssap_expect_nothing();
4253}
Harald Welte898113b2018-01-31 18:32:21 +01004254testcase TC_unsol_ass_fail() runs on test_CT {
4255 var MSC_ConnHdlr vc_conn;
4256 f_init(1, true);
4257 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02004258 vc_conn := f_start_handler(refers(f_tc_unsol_ass_fail));
Harald Welte898113b2018-01-31 18:32:21 +01004259 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004260 f_shutdown_helper();
Harald Welte898113b2018-01-31 18:32:21 +01004261}
Harald Welte552620d2017-12-16 23:21:36 +01004262
Harald Welteea99a002018-01-31 20:46:43 +01004263
4264/* unsolicited ASSIGNMENT COMPLETE (without ASSIGN) from MS shouldn't bring BSC down */
4265private function f_tc_unsol_ass_compl(charstring id) runs on MSC_ConnHdlr {
Harald Weltee3bd6582018-01-31 22:51:25 +01004266 f_est_single_l3(ts_RRM_AssignmentComplete('00'O));
4267 f_bssap_expect_nothing();
Harald Welteea99a002018-01-31 20:46:43 +01004268}
4269testcase TC_unsol_ass_compl() runs on test_CT {
4270 var MSC_ConnHdlr vc_conn;
4271 f_init(1, true);
4272 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02004273 vc_conn := f_start_handler(refers(f_tc_unsol_ass_compl));
Harald Welteea99a002018-01-31 20:46:43 +01004274 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004275 f_shutdown_helper();
Harald Welteea99a002018-01-31 20:46:43 +01004276}
4277
4278
Harald Weltefbf9b5e2018-01-31 20:41:23 +01004279/* unsolicited HANDOVER FAIL (without ASSIGN) from MS shouldn't bring BSC down */
4280private function f_tc_unsol_ho_fail(charstring id) runs on MSC_ConnHdlr {
Harald Weltee3bd6582018-01-31 22:51:25 +01004281 f_est_single_l3(ts_RRM_HandoverFailure('00'O));
4282 f_bssap_expect_nothing();
Harald Weltefbf9b5e2018-01-31 20:41:23 +01004283}
Harald Weltefbf9b5e2018-01-31 20:41:23 +01004284testcase TC_unsol_ho_fail() runs on test_CT {
4285 var MSC_ConnHdlr vc_conn;
4286 f_init(1, true);
4287 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02004288 vc_conn := f_start_handler(refers(f_tc_unsol_ho_fail));
Harald Weltefbf9b5e2018-01-31 20:41:23 +01004289 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004290 f_shutdown_helper();
Harald Weltefbf9b5e2018-01-31 20:41:23 +01004291}
4292
4293
Harald Weltee3bd6582018-01-31 22:51:25 +01004294/* short message from MS should be ignored */
4295private function f_tc_err_82_short_msg(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02004296 g_pars := f_gen_test_hdlr_pars();
Harald Weltea0630032018-03-20 21:09:55 +01004297 f_create_chan_and_exp();
Harald Weltee3bd6582018-01-31 22:51:25 +01004298 /* we should now have a COMPL_L3 at the MSC */
4299 BSSAP.receive(tr_BSSMAP_ComplL3);
4300
4301 /* send short message */
4302 RSL.send(ts_RSL_DATA_IND(g_chan_nr, valueof(ts_RslLinkID_DCCH(0)), ''O));
4303 f_bssap_expect_nothing();
4304}
4305testcase TC_err_82_short_msg() runs on test_CT {
4306 var MSC_ConnHdlr vc_conn;
4307 f_init(1, true);
4308 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02004309 vc_conn := f_start_handler(refers(f_tc_err_82_short_msg));
Harald Weltee3bd6582018-01-31 22:51:25 +01004310 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004311 f_shutdown_helper();
Harald Weltee3bd6582018-01-31 22:51:25 +01004312}
4313
4314
Harald Weltee9e02e42018-01-31 23:36:25 +01004315/* 24.008 8.4 Unknown message must trigger RR STATUS */
4316private function f_tc_err_84_unknown_msg(charstring id) runs on MSC_ConnHdlr {
4317 f_est_single_l3(ts_RRM_UL_REL('00'O));
4318 timer T := 3.0
4319 alt {
4320 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_STATUS)) {
4321 setverdict(pass);
4322 }
4323 [] BSSAP.receive { setverdict(fail, "unexpected BSSAP"); }
Harald Welte458fd372018-03-21 11:26:23 +01004324 [] T.timeout { setverdict(fail, "Timeout waiting for RR STATUS"); }
Harald Weltee9e02e42018-01-31 23:36:25 +01004325 }
4326}
4327testcase TC_err_84_unknown_msg() runs on test_CT {
4328 var MSC_ConnHdlr vc_conn;
4329 f_init(1, true);
4330 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02004331 vc_conn := f_start_handler(refers(f_tc_err_84_unknown_msg));
Harald Weltee9e02e42018-01-31 23:36:25 +01004332 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004333 f_shutdown_helper();
Harald Weltee9e02e42018-01-31 23:36:25 +01004334}
4335
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004336/***********************************************************************
4337 * Handover
4338 ***********************************************************************/
4339
Harald Welte94e0c342018-04-07 11:33:23 +02004340/* execute a "bts <0-255> trx <0-255> timeslot <0-7> " command on given Dchan */
4341private function f_vty_ts_action(charstring suffix, integer bts_nr, integer trx_nr, integer ts_nr)
4342runs on test_CT {
4343 var charstring cmd := "bts "&int2str(bts_nr)&" trx "&int2str(trx_nr)&
4344 " timeslot "&int2str(ts_nr)&" ";
4345 f_vty_transceive(BSCVTY, cmd & suffix);
4346}
4347
Harald Welte261af4b2018-02-12 21:20:39 +01004348/* 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 +07004349private function f_vty_ss_action(TELNETasp_PT pt, charstring suffix,
4350 uint8_t bts_nr, uint8_t trx_nr,
4351 in RslChannelNr chan_nr)
4352{
Harald Welte261af4b2018-02-12 21:20:39 +01004353 /* FIXME: resolve those from component-global state */
4354 var integer ts_nr := chan_nr.tn;
4355 var integer ss_nr;
4356 if (ischosen(chan_nr.u.ch0)) {
4357 ss_nr := 0;
4358 } else if (ischosen(chan_nr.u.lm)) {
4359 ss_nr := chan_nr.u.lm.sub_chan;
4360 } else if (ischosen(chan_nr.u.sdcch4)) {
4361 ss_nr := chan_nr.u.sdcch4.sub_chan;
4362 } else if (ischosen(chan_nr.u.sdcch8)) {
4363 ss_nr := chan_nr.u.sdcch8.sub_chan;
4364 } else {
4365 setverdict(fail, "Invalid ChanNr ", chan_nr);
Daniel Willmannafce8662018-07-06 23:11:32 +02004366 mtc.stop;
Harald Welte261af4b2018-02-12 21:20:39 +01004367 }
4368
4369 var charstring cmd := "bts "&int2str(bts_nr)&" trx "&int2str(trx_nr)&
4370 " timeslot "&int2str(ts_nr)&" sub-slot "&int2str(ss_nr)&" ";
Vadim Yanitskiy00070722020-09-02 17:27:57 +07004371 f_vty_transceive(pt, cmd & suffix);
Harald Welte261af4b2018-02-12 21:20:39 +01004372}
4373
Neels Hofmeyr91401012019-07-11 00:42:35 +02004374/* Even though the VTY command to trigger handover takes a new BTS number as argument, behind the scenes osmo-bsc always
4375 * translates that to a target ARFCN+BSIC first. See bsc_vty.c trigger_ho_or_as(), which puts the selected BTS' neighbor
4376 * ident key (ARFCN + BSIC) in the struct passed on to handover_request(). handover_start() then resolves that to a
4377 * viable actual neighbor cell. So from the internal osmo-bsc perspective, we always request handover to an ARFCN + BSIC
4378 * pair, not really to a specific BTS number. */
Vadim Yanitskiy00070722020-09-02 17:27:57 +07004379private function f_vty_handover(TELNETasp_PT pt, uint8_t bts_nr, uint8_t trx_nr,
4380 in RslChannelNr chan_nr, uint8_t new_bts_nr)
4381{
4382 f_vty_ss_action(pt, "handover " & int2str(new_bts_nr), bts_nr, trx_nr, chan_nr);
Harald Welte261af4b2018-02-12 21:20:39 +01004383}
4384
4385/* intra-BSC hand-over between BTS0 and BTS1 */
4386private function f_tc_ho_int(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02004387 g_pars := f_gen_test_hdlr_pars();
Harald Welteed848512018-05-24 22:27:58 +02004388 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4389 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte261af4b2018-02-12 21:20:39 +01004390 const OCT8 kc := '0001020304050607'O;
4391
4392 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4393 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
4394
Harald Weltea0630032018-03-20 21:09:55 +01004395 f_establish_fully(ass_cmd, exp_compl);
Neels Hofmeyr666f0432020-07-04 00:53:07 +02004396 f_bts_0_cfg(BSCVTY, {"neighbor bts 1"});
Harald Welte261af4b2018-02-12 21:20:39 +01004397
4398 var HandoverState hs := {
4399 rr_ho_cmpl_seen := false,
4400 handover_done := false,
4401 old_chan_nr := -
4402 };
4403 /* issue hand-over command on VTY */
Vadim Yanitskiy00070722020-09-02 17:27:57 +07004404 f_vty_handover(BSCVTY, 0, 0, g_chan_nr, 1);
Harald Welte261af4b2018-02-12 21:20:39 +01004405 /* temporarily suspend DChan processing on BTS1 to avoid race with RSLEM_register */
4406 f_rslem_suspend(RSL1_PROC);
Philipp Maier3e2af5d2018-07-11 17:01:05 +02004407
4408 /* From the MGW perspective, a handover is is characterized by
4409 * performing one MDCX operation with the MGW. So we expect to see
4410 * one more MDCX during handover. */
4411 g_media.mgcp_conn[0].mdcx_seen_exp := g_media.mgcp_conn[0].crcx_seen_exp + 1;
4412
Harald Welte261af4b2018-02-12 21:20:39 +01004413 alt {
4414 [] as_handover(hs);
Harald Welte261af4b2018-02-12 21:20:39 +01004415 }
Philipp Maier3e2af5d2018-07-11 17:01:05 +02004416
Philipp Maier4dae0652018-11-12 12:03:26 +01004417 /* Since this is an internal handover we expect the BSC to inform the
4418 * MSC about the event */
4419 BSSAP.receive(tr_BSSMAP_HandoverPerformed);
4420
Philipp Maier3e2af5d2018-07-11 17:01:05 +02004421 /* Check the amount of MGCP transactions is still consistant with the
4422 * test expectation */
4423 f_check_mgcp_expectations()
Neels Hofmeyr861a4c12018-11-07 01:23:17 +01004424 f_sleep(0.5);
Harald Welte261af4b2018-02-12 21:20:39 +01004425}
4426
4427testcase TC_ho_int() runs on test_CT {
4428 var MSC_ConnHdlr vc_conn;
4429 f_init(2, true);
4430 f_sleep(1.0);
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004431
4432 f_ctrs_bsc_and_bts_init();
4433
Harald Welte8863fa12018-05-10 20:15:27 +02004434 vc_conn := f_start_handler(refers(f_tc_ho_int));
Harald Welte261af4b2018-02-12 21:20:39 +01004435 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004436
4437 /* from f_establish_fully() */
4438 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
4439 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
4440 /* from handover */
4441 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
4442 f_ctrs_bsc_and_bts_add(0, "handover:completed");
4443 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
4444 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:completed");
4445 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004446 f_shutdown_helper();
Harald Welte261af4b2018-02-12 21:20:39 +01004447}
Harald Weltee9e02e42018-01-31 23:36:25 +01004448
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004449/* Expecting MGCP to DLCX the endpoint's two connections: towards BTS and towards MSC */
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02004450private function f_expect_dlcx_conns() runs on MSC_ConnHdlr {
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004451 var MgcpCommand mgcp;
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +02004452 var template MgcpResponse mgcp_resp;
4453 var MGCP_RecvFrom mrf;
4454 var template MgcpMessage msg_resp;
4455 var template MgcpMessage msg_dlcx := {
4456 command := tr_DLCX()
4457 }
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004458
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +02004459 if (g_pars.aoip) {
4460 MGCP.receive(tr_DLCX()) -> value mgcp {
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004461 log("Got first DLCX: ", mgcp);
4462 MGCP.send(ts_DLCX_ACK2(mgcp.line.trans_id));
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +02004463 };
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004464
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004465 MGCP.receive(tr_DLCX()) -> value mgcp {
4466 log("Got second DLCX: ", mgcp);
4467 MGCP.send(ts_DLCX_ACK2(mgcp.line.trans_id));
4468 };
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +02004469 } else {
4470 /* For SCCPLite, BSC doesn't handle the MSC-side */
4471 MGCP_MULTI.receive(tr_MGCP_RecvFrom_any(msg_dlcx)) -> value mrf {
4472 log("Got first DLCX: ", mrf.msg.command);
4473 msg_resp := {
4474 response := ts_DLCX_ACK2(mrf.msg.command.line.trans_id)
4475 }
4476 MGCP_MULTI.send(t_MGCP_SendToMrf(mrf, msg_resp));
4477 };
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004478 }
4479
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02004480 BSSAP.receive(tr_BSSMAP_ClearComplete);
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004481}
4482
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004483private function f_tc_ho_out_of_this_bsc(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02004484 g_pars := f_gen_test_hdlr_pars();
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004485
4486 var PDU_BSSAP ass_req := f_gen_ass_req();
4487 ass_req.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4488 ass_req.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
4489 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4490 f_establish_fully(ass_req, exp_compl);
4491
Neels Hofmeyr666f0432020-07-04 00:53:07 +02004492 f_bts_0_cfg(BSCVTY, {"neighbor lac 99 arfcn 123 bsic any"});
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004493 f_vty_transceive(BSCVTY, "handover any to arfcn 123 bsic any");
4494
4495 BSSAP.receive(tr_BSSMAP_HandoverRequired);
4496
4497 f_sleep(0.5);
4498 /* The MSC negotiates Handover Request and Handover Request Ack with
4499 * the other BSS and comes back with a BSSMAP Handover Command
4500 * containing an RR Handover Command coming from the target BSS... */
4501
4502 var PDU_ML3_NW_MS rr_ho_cmd := valueof(ts_RR_HandoverCommand);
4503 log("Remote cell's RR Handover Command passed through as L3 Info: ", rr_ho_cmd);
4504 var octetstring rr_ho_cmd_enc := enc_PDU_ML3_NW_MS(rr_ho_cmd);
4505 log("Remote cell's RR Handover Command passed through as L3 Info, encoded: ", rr_ho_cmd_enc);
4506 BSSAP.send(ts_BSSMAP_HandoverCommand(rr_ho_cmd_enc));
4507
4508 /* expect the Handover Command to go out on RR */
4509 var RSL_Message rsl_ho_cmd
4510 RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, ?)) -> value rsl_ho_cmd;
4511 log("RSL Data Req went out to first BTS: ", rsl_ho_cmd);
4512 var RSL_IE_Body rsl_ho_cmd_l3;
4513 if (not f_rsl_find_ie(rsl_ho_cmd, RSL_IE_L3_INFO, rsl_ho_cmd_l3)) {
4514 log("RSL message contains no L3 Info IE, expected RR Handover Command");
4515 setverdict(fail);
4516 } else {
4517 log("Found L3 Info: ", rsl_ho_cmd_l3);
4518 if (rsl_ho_cmd_l3.l3_info.payload != rr_ho_cmd_enc) {
4519 log("FAIL: the BSC sent out a different L3 Info, not matching the RR Handover Command the other BSS forwarded.");
4520 setverdict(fail);
4521 } else {
4522 log("Success: the BSC sent out the same RR Handover Command the other BSS forwarded.");
4523 setverdict(pass);
4524 }
4525 }
4526
4527 /* When the other BSS has reported a completed handover, this side is
4528 * torn down. */
4529
4530 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_HANDOVER_SUCCESSFUL;
4531 var BssmapCause cause := enum2int(cause_val);
4532 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
4533
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02004534 f_expect_dlcx_conns();
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004535 setverdict(pass);
4536 f_sleep(1.0);
4537}
4538testcase TC_ho_out_of_this_bsc() runs on test_CT {
4539 var MSC_ConnHdlr vc_conn;
4540
4541 f_init(1, true);
4542 f_sleep(1.0);
4543
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004544 f_ctrs_bsc_and_bts_init();
4545
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004546 vc_conn := f_start_handler(refers(f_tc_ho_out_of_this_bsc));
4547 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004548
4549 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
4550 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
4551 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
4552 f_ctrs_bsc_and_bts_add(0, "handover:completed");
4553 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
4554 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:completed");
4555 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004556 f_shutdown_helper();
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004557}
4558
Neels Hofmeyr0aa719b2020-10-12 18:43:09 +00004559private function f_mo_l3_transceive(RSL_DCHAN_PT rsl := RSL,
4560 template (value) RslLinkId link_id := ts_RslLinkID_DCCH(0),
Vadim Yanitskiy2ef6a2f2020-10-08 23:17:32 +07004561 template (present) OCT1 dlci := ?,
Vadim Yanitskiyb93aa432020-10-01 14:23:11 +07004562 octetstring l3 := '0123456789'O)
4563runs on MSC_ConnHdlr {
Neels Hofmeyr43654812020-09-25 01:35:35 +02004564 /* The old lchan and conn should still be active. See that arbitrary L3
4565 * is still going through. */
Neels Hofmeyr0aa719b2020-10-12 18:43:09 +00004566 rsl.send(ts_RSL_DATA_IND(g_chan_nr, link_id, l3));
Neels Hofmeyr43654812020-09-25 01:35:35 +02004567 var template PDU_BSSAP exp_data := {
4568 discriminator := '1'B,
4569 spare := '0000000'B,
Vadim Yanitskiyb93aa432020-10-01 14:23:11 +07004570 dlci := dlci,
4571 lengthIndicator := lengthof(l3),
Neels Hofmeyr43654812020-09-25 01:35:35 +02004572 pdu := {
4573 dtap := l3
4574 }
4575 };
4576 BSSAP.receive(exp_data);
4577 setverdict(pass);
4578}
4579
Neels Hofmeyr0aa719b2020-10-12 18:43:09 +00004580private function f_mt_l3_transceive(RSL_DCHAN_PT rsl := RSL,
4581 template (present) RslLinkId link_id := tr_RslLinkID_DCCH(0),
Vadim Yanitskiy0033a3b2020-10-01 22:21:16 +07004582 template (value) OCT1 dlci := '00'O,
4583 octetstring l3 := '0123456789'O)
4584runs on MSC_ConnHdlr {
4585 BSSAP.send(PDU_BSSAP:{
4586 discriminator := '1'B,
4587 spare := '0000000'B,
4588 dlci := dlci,
4589 lengthIndicator := lengthof(l3),
4590 pdu := {
4591 dtap := l3
4592 }
4593 });
Neels Hofmeyr0aa719b2020-10-12 18:43:09 +00004594 rsl.receive(tr_RSL_DATA_REQ(g_chan_nr, link_id, l3));
Vadim Yanitskiy0033a3b2020-10-01 22:21:16 +07004595 setverdict(pass);
4596}
4597
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004598/* BSC asks for inter-BSC HO, but the MSC decides that it won't happen and
4599 * simply never sends a BSSMAP Handover Command. */
4600private function f_tc_ho_out_fail_no_msc_response(charstring id) runs on MSC_ConnHdlr {
Daniel Willmann3b59eb52018-10-29 15:40:55 +01004601 g_pars := f_gen_test_hdlr_pars();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004602
4603 var PDU_BSSAP ass_req := f_gen_ass_req();
4604 ass_req.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4605 ass_req.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
4606 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4607 f_establish_fully(ass_req, exp_compl);
4608
Neels Hofmeyr666f0432020-07-04 00:53:07 +02004609 f_bts_0_cfg(BSCVTY, {"neighbor lac 99 arfcn 123 bsic any"});
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004610 f_vty_transceive(BSCVTY, "handover any to arfcn 123 bsic any");
4611
4612 BSSAP.receive(tr_BSSMAP_HandoverRequired);
4613
4614 /* osmo-bsc should time out 10 seconds after the handover started.
4615 * Let's give it a bit extra. */
4616 f_sleep(15.0);
4617
Vadim Yanitskiy74ae5eb2020-10-01 22:13:29 +07004618 f_mo_l3_transceive();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004619 f_sleep(1.0);
4620}
4621testcase TC_ho_out_fail_no_msc_response() runs on test_CT {
4622 var MSC_ConnHdlr vc_conn;
4623
4624 f_init(1, true);
4625 f_sleep(1.0);
4626
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004627 f_ctrs_bsc_and_bts_init();
4628
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004629 vc_conn := f_start_handler(refers(f_tc_ho_out_fail_no_msc_response));
4630 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004631
4632 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
4633 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
4634 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
4635 f_ctrs_bsc_and_bts_add(0, "handover:timeout");
4636 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
4637 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:timeout");
4638 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004639 f_shutdown_helper();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004640}
4641
4642/* BSC asks for inter-BSC HO, receives BSSMAP Handover Command, but MS reports
4643 * RR Handover Failure. */
4644private function f_tc_ho_out_fail_rr_ho_failure(charstring id) runs on MSC_ConnHdlr {
Daniel Willmann3b59eb52018-10-29 15:40:55 +01004645 g_pars := f_gen_test_hdlr_pars();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004646
4647 var PDU_BSSAP ass_req := f_gen_ass_req();
4648 ass_req.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4649 ass_req.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
4650 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4651 f_establish_fully(ass_req, exp_compl);
4652
Neels Hofmeyr666f0432020-07-04 00:53:07 +02004653 f_bts_0_cfg(BSCVTY, {"neighbor lac 99 arfcn 123 bsic any"});
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004654 f_vty_transceive(BSCVTY, "handover any to arfcn 123 bsic any");
4655
4656 BSSAP.receive(tr_BSSMAP_HandoverRequired);
4657
4658 f_sleep(0.5);
4659 /* The MSC negotiates Handover Request and Handover Request Ack with
4660 * the other BSS and comes back with a BSSMAP Handover Command
4661 * containing an RR Handover Command coming from the target BSS... */
4662
4663 var PDU_ML3_NW_MS rr_ho_cmd := valueof(ts_RR_HandoverCommand);
4664 log("Remote cell's RR Handover Command passed through as L3 Info: ", rr_ho_cmd);
4665 var octetstring rr_ho_cmd_enc := enc_PDU_ML3_NW_MS(rr_ho_cmd);
4666 log("Remote cell's RR Handover Command passed through as L3 Info, encoded: ", rr_ho_cmd_enc);
4667 BSSAP.send(ts_BSSMAP_HandoverCommand(rr_ho_cmd_enc));
4668
4669 /* expect the Handover Command to go out on RR */
4670 var RSL_Message rsl_ho_cmd
4671 RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, ?)) -> value rsl_ho_cmd;
4672 log("RSL Data Req went out to first BTS: ", rsl_ho_cmd);
4673 var RSL_IE_Body rsl_ho_cmd_l3;
4674 if (not f_rsl_find_ie(rsl_ho_cmd, RSL_IE_L3_INFO, rsl_ho_cmd_l3)) {
4675 log("RSL message contains no L3 Info IE, expected RR Handover Command");
4676 setverdict(fail);
4677 } else {
4678 log("Found L3 Info: ", rsl_ho_cmd_l3);
4679 if (rsl_ho_cmd_l3.l3_info.payload != rr_ho_cmd_enc) {
4680 log("FAIL: the BSC sent out a different L3 Info, not matching the RR Handover Command the other BSS forwarded.");
4681 setverdict(fail);
4682 } else {
4683 log("Success: the BSC sent out the same RR Handover Command the other BSS forwarded.");
4684 setverdict(pass);
4685 }
4686 }
4687
4688 f_sleep(0.2);
4689 f_rsl_send_l3(ts_RRM_HandoverFailure('00'O));
4690
4691 /* Should tell the MSC about the failure */
4692 BSSAP.receive(tr_BSSMAP_HandoverFailure);
4693
4694 f_sleep(1.0);
4695
Vadim Yanitskiy74ae5eb2020-10-01 22:13:29 +07004696 f_mo_l3_transceive();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004697 f_sleep(1.0);
4698
4699 setverdict(pass);
4700 f_sleep(1.0);
4701}
4702testcase TC_ho_out_fail_rr_ho_failure() runs on test_CT {
4703 var MSC_ConnHdlr vc_conn;
4704
4705 f_init(1, true);
4706 f_sleep(1.0);
4707
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004708 f_ctrs_bsc_and_bts_init();
4709
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004710 vc_conn := f_start_handler(refers(f_tc_ho_out_fail_rr_ho_failure));
4711 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004712
4713 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
4714 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
4715 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
4716 f_ctrs_bsc_and_bts_add(0, "handover:failed");
4717 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
4718 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:failed");
4719 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004720 f_shutdown_helper();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004721}
4722
Neels Hofmeyr10f2bfa2019-07-09 19:33:29 +02004723/* BSC asks for inter-BSC-out HO, receives BSSMAP Handover Command, but then no reply is received about HO outcome
4724 * (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 +02004725 * and the lchan is released. */
4726private function f_tc_ho_out_fail_no_result_after_ho_cmd(charstring id) runs on MSC_ConnHdlr {
Daniel Willmann3b59eb52018-10-29 15:40:55 +01004727 g_pars := f_gen_test_hdlr_pars();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004728
4729 var PDU_BSSAP ass_req := f_gen_ass_req();
4730 ass_req.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4731 ass_req.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
4732 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4733 f_establish_fully(ass_req, exp_compl);
4734
Neels Hofmeyr666f0432020-07-04 00:53:07 +02004735 f_bts_0_cfg(BSCVTY, {"neighbor lac 99 arfcn 123 bsic any"});
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004736 f_vty_transceive(BSCVTY, "handover any to arfcn 123 bsic any");
4737
4738 BSSAP.receive(tr_BSSMAP_HandoverRequired);
4739
4740 f_sleep(0.5);
4741 /* The MSC negotiates Handover Request and Handover Request Ack with
4742 * the other BSS and comes back with a BSSMAP Handover Command
4743 * containing an RR Handover Command coming from the target BSS... */
4744
4745 var PDU_ML3_NW_MS rr_ho_cmd := valueof(ts_RR_HandoverCommand);
4746 log("Remote cell's RR Handover Command passed through as L3 Info: ", rr_ho_cmd);
4747 var octetstring rr_ho_cmd_enc := enc_PDU_ML3_NW_MS(rr_ho_cmd);
4748 log("Remote cell's RR Handover Command passed through as L3 Info, encoded: ", rr_ho_cmd_enc);
4749 BSSAP.send(ts_BSSMAP_HandoverCommand(rr_ho_cmd_enc));
4750
4751 /* expect the Handover Command to go out on RR */
4752 var RSL_Message rsl_ho_cmd
4753 RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, ?)) -> value rsl_ho_cmd;
4754 log("RSL Data Req went out to first BTS: ", rsl_ho_cmd);
4755 var RSL_IE_Body rsl_ho_cmd_l3;
4756 if (not f_rsl_find_ie(rsl_ho_cmd, RSL_IE_L3_INFO, rsl_ho_cmd_l3)) {
4757 log("RSL message contains no L3 Info IE, expected RR Handover Command");
4758 setverdict(fail);
4759 } else {
4760 log("Found L3 Info: ", rsl_ho_cmd_l3);
4761 if (rsl_ho_cmd_l3.l3_info.payload != rr_ho_cmd_enc) {
4762 log("FAIL: the BSC sent out a different L3 Info, not matching the RR Handover Command the other BSS forwarded.");
4763 setverdict(fail);
4764 } else {
4765 log("Success: the BSC sent out the same RR Handover Command the other BSS forwarded.");
4766 setverdict(pass);
4767 }
4768 }
4769
Neels Hofmeyr10f2bfa2019-07-09 19:33:29 +02004770 /* We get neither success nor failure report from the remote BSS. Eventually T8 times out and we run into 3GPP
4771 * TS 48.008 3.1.5.3.3 "Abnormal Conditions": Clear Request should go to the MSC, and RR should be released
4772 * after Clear Command */
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004773
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02004774 var PDU_BSSAP rx_clear_request;
Neels Hofmeyre1797aa2019-07-09 19:34:04 +02004775 BSSAP.receive(tr_BSSMAP_ClearRequest) -> value rx_clear_request;
4776 log("Got BSSMAP Clear Request");
4777 /* Instruct BSC to clear channel */
4778 var BssmapCause cause := bit2int(rx_clear_request.pdu.bssmap.clearRequest.cause.causeValue);
4779 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
4780
4781 var MgcpCommand mgcp;
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004782 interleave {
Neels Hofmeyr861a4c12018-11-07 01:23:17 +01004783 [] RSL.receive(tr_RSL_DEACT_SACCH(g_chan_nr)) {
4784 log("Got Deact SACCH");
4785 }
Harald Welte924b6ea2019-02-04 01:05:34 +01004786 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_RELEASE)) {
Neels Hofmeyr211169d2018-11-07 00:37:29 +01004787 log("Got RR Release");
4788 }
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004789 [] RSL.receive(tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL)) {
4790 log("Got RF Chan Rel");
4791 RSL.send(ts_RSL_RF_CHAN_REL_ACK(g_chan_nr));
4792 }
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004793 }
4794
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02004795 f_expect_dlcx_conns();
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004796
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004797 setverdict(pass);
4798 f_sleep(1.0);
4799}
Neels Hofmeyrd8a602c2019-07-09 19:46:01 +02004800testcase TC_ho_out_fail_no_result_after_ho_cmd() runs on test_CT {
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004801 var MSC_ConnHdlr vc_conn;
4802
4803 f_init(1, true);
4804 f_sleep(1.0);
4805
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004806 f_ctrs_bsc_and_bts_init();
4807
Neels Hofmeyrd8a602c2019-07-09 19:46:01 +02004808 vc_conn := f_start_handler(refers(f_tc_ho_out_fail_no_result_after_ho_cmd));
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004809 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004810
4811 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
4812 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
4813 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
4814 f_ctrs_bsc_and_bts_add(0, "handover:timeout");
4815 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
4816 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:timeout");
4817 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004818 f_shutdown_helper();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004819}
4820
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004821private function f_tc_ho_into_this_bsc(charstring id) runs on MSC_ConnHdlr {
4822 /* Hack: the proper way would be to wait for the BSSMAP Handover Request ACK and extract the
4823 * actual assigned chan_nr from its L3 (RR Handover Command) message. But osmo-bsc starts acting
4824 * on the lchan even before we get a chance to evaluate the BSSMAP Handover Request ACK. So we
4825 * need to assume that osmo-bsc will activate TS 1 and already set up this lchan's RSL emulation
4826 * before we get started. */
4827 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
4828 f_rslem_register(0, new_chan_nr);
4829 g_chan_nr := new_chan_nr;
4830 f_sleep(1.0);
4831
4832 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
4833 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
4834 activate(as_Media());
4835
Neels Hofmeyr90f80962020-06-12 16:16:55 +02004836 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Pau Espin Pedrol07866632020-09-03 19:10:55 +02004837 f_gen_handover_req(aoip_tla := g_pars.host_aoip_tla)));
Harald Welte6811d102019-04-14 22:23:14 +02004838 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004839
4840 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
4841
4842 var PDU_BSSAP rx_bssap;
4843 var octetstring ho_command_str;
4844
4845 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
Pau Espin Pedrol76ba5412019-06-10 11:00:33 +02004846
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004847 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
4848 log("Received L3 Info in HO Request Ack: ", ho_command_str);
4849 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
4850 log("L3 Info in HO Request Ack is ", ho_command);
4851
4852 var GsmArfcn arfcn;
4853 var RslChannelNr actual_new_chan_nr;
4854 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
4855 actual_new_chan_nr, arfcn);
4856
4857 if (actual_new_chan_nr != new_chan_nr) {
4858 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
4859 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
4860 setverdict(fail);
4861 return;
4862 }
4863 log("Handover Command chan_nr is", actual_new_chan_nr);
4864
4865 /* Now the MSC forwards the RR Handover Command to the other BSC, which
4866 * tells the MS to handover to the new lchan. Here comes the new MS on
4867 * the new lchan with a Handover RACH: */
4868
4869 /* send handover detect */
4870
4871 RSL.send(ts_RSL_HANDO_DET(new_chan_nr));
4872
4873 BSSAP.receive(tr_BSSMAP_HandoverDetect);
4874
4875 /* send handover complete over the new channel */
4876
4877 var PDU_ML3_MS_NW l3_tx := valueof(ts_RRM_HandoverComplete('00'O));
4878 RSL.send(ts_RSL_EST_IND(new_chan_nr, valueof(ts_RslLinkID_DCCH(0)),
4879 enc_PDU_ML3_MS_NW(l3_tx)));
4880
4881 BSSAP.receive(tr_BSSMAP_HandoverComplete);
4882 setverdict(pass);
4883}
Pau Espin Pedrol07866632020-09-03 19:10:55 +02004884function f_tc_ho_into_this_bsc_main(TestHdlrParams pars) runs on test_CT {
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004885 var MSC_ConnHdlr vc_conn;
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004886
4887 f_init(1, true);
4888 f_sleep(1.0);
4889
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004890 f_ctrs_bsc_and_bts_init();
4891
Neels Hofmeyr90f80962020-06-12 16:16:55 +02004892 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
4893 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004894
4895 vc_conn := f_start_handler(refers(f_tc_ho_into_this_bsc), pars);
4896 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004897
4898 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
4899 f_ctrs_bsc_and_bts_add(0, "handover:completed");
4900 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:attempted");
4901 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:completed");
4902 f_ctrs_bsc_and_bts_verify();
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004903}
4904
Pau Espin Pedrol07866632020-09-03 19:10:55 +02004905testcase TC_ho_into_this_bsc() runs on test_CT {
4906 var TestHdlrParams pars := f_gen_test_hdlr_pars();
4907 f_tc_ho_into_this_bsc_main(pars);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004908 f_shutdown_helper();
Pau Espin Pedrol07866632020-09-03 19:10:55 +02004909}
4910
4911testcase TC_ho_into_this_bsc_tla_v6() runs on test_CT {
4912 var TestHdlrParams pars := f_gen_test_hdlr_pars();
4913 pars.host_aoip_tla := "::6";
4914 f_tc_ho_into_this_bsc_main(pars);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004915 f_shutdown_helper();
Pau Espin Pedrol07866632020-09-03 19:10:55 +02004916}
4917
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01004918private function f_tc_ho_in_fail_msc_clears(charstring id) runs on MSC_ConnHdlr {
4919 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
4920 f_rslem_register(0, new_chan_nr);
4921 g_chan_nr := new_chan_nr;
4922 f_sleep(1.0);
4923
4924 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
4925 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
4926 activate(as_Media());
4927
Neels Hofmeyr90f80962020-06-12 16:16:55 +02004928 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01004929 f_gen_handover_req()));
Harald Welte6811d102019-04-14 22:23:14 +02004930 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01004931
4932 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
4933
4934 var PDU_BSSAP rx_bssap;
4935 var octetstring ho_command_str;
4936
4937 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
4938
4939 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
4940 log("Received L3 Info in HO Request Ack: ", ho_command_str);
4941 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
4942 log("L3 Info in HO Request Ack is ", ho_command);
4943
4944 var GsmArfcn arfcn;
4945 var RslChannelNr actual_new_chan_nr;
4946 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
4947 actual_new_chan_nr, arfcn);
4948
4949 if (actual_new_chan_nr != new_chan_nr) {
4950 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
4951 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
4952 setverdict(fail);
4953 return;
4954 }
4955 log("Handover Command chan_nr is", actual_new_chan_nr);
4956
Neels Hofmeyr61ca08d2019-05-06 23:52:22 +02004957 /* For deterministic test results, give some time for the MGW endpoint to be configured */
4958 f_sleep(1.0);
4959
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01004960 /* Now the MSC forwards the RR Handover Command to the other BSC, which
4961 * tells the MS to handover to the new lchan. In this case, the MS
4962 * reports a Handover Failure to the old BSS, which forwards a BSSMAP
4963 * Handover Failure to the MSC. The procedure according to 3GPP TS
4964 * 48.008 3.1.5.3.2 "Handover Failure" is then that the MSC sends a
4965 * BSSMAP Clear Command: */
4966
4967 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_RADIO_INTERFACE_FAILURE_REVERSION;
4968 var BssmapCause cause := enum2int(cause_val);
4969 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
4970
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02004971 f_expect_dlcx_conns();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01004972 setverdict(pass);
4973 f_sleep(1.0);
4974
4975 setverdict(pass);
4976}
4977testcase TC_ho_in_fail_msc_clears() runs on test_CT {
4978 var MSC_ConnHdlr vc_conn;
4979 var TestHdlrParams pars := f_gen_test_hdlr_pars();
4980
4981 f_init(1, true);
4982 f_sleep(1.0);
4983
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004984 f_ctrs_bsc_and_bts_init();
4985
Neels Hofmeyr90f80962020-06-12 16:16:55 +02004986 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
4987 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01004988
4989 vc_conn := f_start_handler(refers(f_tc_ho_in_fail_msc_clears), pars);
4990 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004991
4992 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
4993 f_ctrs_bsc_and_bts_add(0, "handover:stopped");
4994 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:attempted");
4995 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:stopped");
4996 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004997 f_shutdown_helper();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01004998}
4999
5000private function f_tc_ho_in_fail_msc_clears_after_ho_detect(charstring id) runs on MSC_ConnHdlr {
5001 /* Hack: the proper way would be to wait for the BSSMAP Handover Request ACK and extract the
5002 * actual assigned chan_nr from its L3 (RR Handover Command) message. But osmo-bsc starts acting
5003 * on the lchan even before we get a chance to evaluate the BSSMAP Handover Request ACK. So we
5004 * need to assume that osmo-bsc will activate TS 1 and already set up this lchan's RSL emulation
5005 * before we get started. */
5006 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
5007 f_rslem_register(0, new_chan_nr);
5008 g_chan_nr := new_chan_nr;
5009 f_sleep(1.0);
5010
5011 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
5012 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
5013 activate(as_Media());
5014
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005015 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005016 f_gen_handover_req()));
Harald Welte6811d102019-04-14 22:23:14 +02005017 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005018
5019 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
5020
5021 var PDU_BSSAP rx_bssap;
5022 var octetstring ho_command_str;
5023
5024 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
5025
5026 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
5027 log("Received L3 Info in HO Request Ack: ", ho_command_str);
5028 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
5029 log("L3 Info in HO Request Ack is ", ho_command);
5030
5031 var GsmArfcn arfcn;
5032 var RslChannelNr actual_new_chan_nr;
5033 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
5034 actual_new_chan_nr, arfcn);
5035
5036 if (actual_new_chan_nr != new_chan_nr) {
5037 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
5038 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
5039 setverdict(fail);
5040 return;
5041 }
5042 log("Handover Command chan_nr is", actual_new_chan_nr);
5043
5044 /* Now the MSC forwards the RR Handover Command to the other BSC, which
5045 * tells the MS to handover to the new lchan. Here comes the new MS on
5046 * the new lchan with a Handover RACH: */
5047
5048 /* send handover detect */
5049
5050 RSL.send(ts_RSL_HANDO_DET(new_chan_nr));
5051
5052 BSSAP.receive(tr_BSSMAP_HandoverDetect);
5053
5054 /* The MSC chooses to clear the connection now, maybe we got the
5055 * Handover RACH on the new cell but the MS still signaled Handover
5056 * Failure to the old BSS? */
5057
5058 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_RADIO_INTERFACE_FAILURE_REVERSION;
5059 var BssmapCause cause := enum2int(cause_val);
5060 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
5061
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02005062 f_expect_dlcx_conns();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005063 f_sleep(1.0);
5064}
5065testcase TC_ho_in_fail_msc_clears_after_ho_detect() runs on test_CT {
5066 var MSC_ConnHdlr vc_conn;
5067 var TestHdlrParams pars := f_gen_test_hdlr_pars();
5068
5069 f_init(1, true);
5070 f_sleep(1.0);
5071
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005072 f_ctrs_bsc_and_bts_init();
5073
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005074 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
5075 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005076
5077 vc_conn := f_start_handler(refers(f_tc_ho_in_fail_msc_clears_after_ho_detect), pars);
5078 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005079
5080 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5081 f_ctrs_bsc_and_bts_add(0, "handover:stopped");
5082 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:attempted");
5083 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:stopped");
5084 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005085 f_shutdown_helper();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005086}
5087
5088/* The new BSS's lchan times out before the MSC decides that handover failed. */
5089private function f_tc_ho_in_fail_no_detect(charstring id) runs on MSC_ConnHdlr {
5090 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
5091 f_rslem_register(0, new_chan_nr);
5092 g_chan_nr := new_chan_nr;
5093 f_sleep(1.0);
5094
5095 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
5096 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
5097 activate(as_Media());
5098
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005099 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005100 f_gen_handover_req()));
Harald Welte6811d102019-04-14 22:23:14 +02005101 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005102
5103 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
5104
5105 var PDU_BSSAP rx_bssap;
5106 var octetstring ho_command_str;
5107
5108 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
5109
5110 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
5111 log("Received L3 Info in HO Request Ack: ", ho_command_str);
5112 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
5113 log("L3 Info in HO Request Ack is ", ho_command);
5114
5115 var GsmArfcn arfcn;
5116 var RslChannelNr actual_new_chan_nr;
5117 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
5118 actual_new_chan_nr, arfcn);
5119
5120 if (actual_new_chan_nr != new_chan_nr) {
5121 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
5122 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
5123 setverdict(fail);
5124 return;
5125 }
5126 log("Handover Command chan_nr is", actual_new_chan_nr);
5127
5128 /* Now the MSC forwards the RR Handover Command to the other BSC, which
5129 * tells the MS to handover to the new lchan. But the MS never shows up
5130 * on the new lchan. */
5131
5132 BSSAP.receive(tr_BSSMAP_HandoverFailure);
5133
5134 /* Did osmo-bsc also send a Clear Request? */
5135 timer T := 0.5;
5136 T.start;
5137 alt {
5138 [] BSSAP.receive(tr_BSSMAP_ClearRequest);
5139 [] T.timeout { }
5140 }
5141
5142 /* MSC plays along with a Clear Command (no matter whether osmo-bsc
5143 * asked for it, this is a Handover Failure after all). */
5144
5145 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_RADIO_INTERFACE_FAILURE_REVERSION;
5146 var BssmapCause cause := enum2int(cause_val);
5147 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
5148
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02005149 f_expect_dlcx_conns();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005150 f_sleep(1.0);
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005151}
5152testcase TC_ho_in_fail_no_detect() runs on test_CT {
5153 var MSC_ConnHdlr vc_conn;
5154 var TestHdlrParams pars := f_gen_test_hdlr_pars();
5155
5156 f_init(1, true);
5157 f_sleep(1.0);
5158
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005159 f_ctrs_bsc_and_bts_init();
5160
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005161 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
5162 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005163
5164 vc_conn := f_start_handler(refers(f_tc_ho_in_fail_no_detect), pars);
5165 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005166
5167 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5168 f_ctrs_bsc_and_bts_add(0, "handover:error");
5169 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:attempted");
5170 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:error");
5171 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005172 f_shutdown_helper();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005173}
5174
5175/* Same as f_tc_ho_in_fail_no_detect, but MSC fails to send a Clear Command */
5176private function f_tc_ho_in_fail_no_detect2(charstring id) runs on MSC_ConnHdlr {
5177 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
5178 f_rslem_register(0, new_chan_nr);
5179 g_chan_nr := new_chan_nr;
5180 f_sleep(1.0);
5181
5182 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
5183 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
5184 activate(as_Media());
5185
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005186 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005187 f_gen_handover_req()));
Harald Welte6811d102019-04-14 22:23:14 +02005188 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005189
5190 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
5191
5192 var PDU_BSSAP rx_bssap;
5193 var octetstring ho_command_str;
5194
5195 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
5196
5197 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
5198 log("Received L3 Info in HO Request Ack: ", ho_command_str);
5199 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
5200 log("L3 Info in HO Request Ack is ", ho_command);
5201
5202 var GsmArfcn arfcn;
5203 var RslChannelNr actual_new_chan_nr;
5204 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
5205 actual_new_chan_nr, arfcn);
5206
5207 if (actual_new_chan_nr != new_chan_nr) {
5208 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
5209 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
5210 setverdict(fail);
5211 return;
5212 }
5213 log("Handover Command chan_nr is", actual_new_chan_nr);
5214
5215 /* Now the MSC forwards the RR Handover Command to the other BSC, which
5216 * tells the MS to handover to the new lchan. But the MS never shows up
5217 * on the new lchan. */
5218
5219 BSSAP.receive(tr_BSSMAP_HandoverFailure);
5220
5221 /* MSC plays dumb and sends no Clear Command */
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005222 var PDU_BSSAP rx_clear_request;
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02005223
5224 BSSAP.receive(tr_BSSMAP_ClearRequest) -> value rx_clear_request {
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005225 var BssmapCause cause := bit2int(rx_clear_request.pdu.bssmap.clearRequest.cause.causeValue);
5226 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
5227 };
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02005228 f_expect_dlcx_conns();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005229 f_sleep(1.0);
5230}
5231testcase TC_ho_in_fail_no_detect2() runs on test_CT {
5232 var MSC_ConnHdlr vc_conn;
5233 var TestHdlrParams pars := f_gen_test_hdlr_pars();
5234
5235 f_init(1, true);
5236 f_sleep(1.0);
5237
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005238 f_ctrs_bsc_and_bts_init();
5239
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005240 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
5241 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005242
5243 vc_conn := f_start_handler(refers(f_tc_ho_in_fail_no_detect2), pars);
5244 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005245
5246 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5247 f_ctrs_bsc_and_bts_add(0, "handover:error");
5248 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:attempted");
5249 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:error");
5250 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005251 f_shutdown_helper();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005252}
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005253
Neels Hofmeyr91401012019-07-11 00:42:35 +02005254type record of charstring Commands;
5255
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005256private function f_bts_0_cfg(TELNETasp_PT pt, Commands cmds := {})
Neels Hofmeyr91401012019-07-11 00:42:35 +02005257{
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005258 f_vty_enter_cfg_bts(pt, 0);
Neels Hofmeyr91401012019-07-11 00:42:35 +02005259 for (var integer i := 0; i < sizeof(cmds); i := i+1) {
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005260 f_vty_transceive(pt, cmds[i]);
Neels Hofmeyr91401012019-07-11 00:42:35 +02005261 }
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005262 f_vty_transceive(pt, "end");
Neels Hofmeyr91401012019-07-11 00:42:35 +02005263}
5264
Pau Espin Pedrolc675b612020-01-09 19:55:40 +01005265private function f_cs7_inst_0_cfg(TELNETasp_PT pt, Commands cmds := {})
5266{
5267 f_vty_enter_cfg_cs7_inst(pt, 0);
5268 for (var integer i := 0; i < sizeof(cmds); i := i+1) {
5269 f_vty_transceive(pt, cmds[i]);
5270 }
5271 f_vty_transceive(pt, "end");
5272}
5273
Neels Hofmeyr91401012019-07-11 00:42:35 +02005274private function f_probe_for_handover(charstring log_label,
5275 charstring log_descr,
5276 charstring handover_vty_cmd,
5277 boolean expect_handover,
5278 boolean is_inter_bsc_handover := false)
5279runs on MSC_ConnHdlr
5280{
Neels Hofmeyrb3fc8982020-05-11 00:16:42 +02005281 /* We're going to thwart any and all handover attempts, just be ready to handle (and ignore) handover target
5282 * lchans to be established on bts 1 or bts 2. */
5283 f_rslem_suspend(RSL1_PROC);
5284 f_rslem_suspend(RSL2_PROC);
5285
Neels Hofmeyr91401012019-07-11 00:42:35 +02005286 var RSL_Message rsl;
5287
5288 var charstring log_msg := " (expecting handover)"
5289 if (not expect_handover) {
5290 log_msg := " (expecting NO handover)";
5291 }
5292 log("f_probe_for_handover starting: " & log_label & ": " & log_descr & log_msg);
5293 f_vty_transceive(BSCVTY, handover_vty_cmd);
5294
Neels Hofmeyr91401012019-07-11 00:42:35 +02005295 timer T := 2.0;
5296 T.start;
5297
5298 alt {
5299 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr)) -> value rsl {
5300 var PDU_ML3_NW_MS l3 := dec_PDU_ML3_NW_MS(rsl.ies[2].body.l3_info.payload);
5301 log("Rx L3 from net: ", l3);
5302 if (ischosen(l3.msgs.rrm.handoverCommand)) {
5303 var RslChannelNr new_chan_nr;
5304 var GsmArfcn arfcn;
5305 f_ChDesc2RslChanNr(l3.msgs.rrm.handoverCommand.channelDescription2,
5306 new_chan_nr, arfcn);
5307 log("Handover to new chan ", new_chan_nr, " on ARFCN ", arfcn);
5308 log(l3.msgs.rrm.handoverCommand);
5309
5310 /* Need to register for new lchan on new BTS -- it's either bts 1 or bts 2. It doesn't really
5311 * matter on which BTS it really is, we're not going to follow through an entire handover
5312 * anyway. */
5313 f_rslem_register(0, new_chan_nr, RSL1_PROC);
5314 f_rslem_resume(RSL1_PROC);
5315 f_rslem_register(0, new_chan_nr, RSL2_PROC);
5316 f_rslem_resume(RSL2_PROC);
5317
5318 if (expect_handover and not is_inter_bsc_handover) {
5319 setverdict(pass);
5320 log("f_probe_for_handover(" & log_label & "): Got RSL Handover Command as expected.");
5321 } else {
5322 setverdict(fail, "f_probe_for_handover(" & log_label & "): Expected none, but got RSL Handover Command. "
5323 & log_label & ": " & log_descr);
5324 }
5325
5326 log("f_probe_for_handover(" & log_label & "): Ending the test: Handover Failure stops the procedure.");
5327 /* osmo-bsc has triggered Handover. That's all we need to know for this test, reply with
5328 * Handover Failure. */
5329 f_rsl_send_l3(ts_RRM_HandoverFailure('00'O));
5330
5331 /* target BTS is told to release lchan again; don't care which BTS nor what messages. */
5332 f_sleep(0.5);
5333 RSL1.clear;
5334 RSL2.clear;
5335 log("f_probe_for_handover(" & log_label & "): done (got RSL Handover Command)");
5336 break;
5337 } else {
5338 repeat;
5339 }
5340 }
5341 [] BSSAP.receive(tr_BSSMAP_HandoverRequired) {
5342 if (expect_handover and is_inter_bsc_handover) {
5343 setverdict(pass);
5344 log("f_probe_for_handover(" & log_label & "): Got BSSMAP Handover Required as expected.");
5345 } else {
5346 setverdict(fail, "f_probe_for_handover(" & log_label & "): Expected none, but got BSSMAP Handover Required. "
5347 & log_label & ": " & log_descr);
5348 }
5349
5350 log("f_probe_for_handover(" & log_label & "): done (got BSSMAP Handover Required)");
5351
5352 /* Note: f_tc_ho_neighbor_config_start() sets T7, the timeout for BSSMAP Handover Required, to
5353 * 1 second. There is no legal way to quickly abort a handover after a BSSMAP Handover Required,
5354 * setting a short timeout and waiting is the only way. */
5355 log("f_probe_for_handover(" & log_label & "): waiting for inter-BSC HO to time out...");
5356 f_sleep(1.5);
5357 log("f_probe_for_handover(" & log_label & "): ...done");
5358
5359 break;
5360 }
5361 [] T.timeout {
5362 if (expect_handover) {
5363 setverdict(fail, "f_probe_for_handover(" & log_label & "): Expected Handover, but got none. "
5364 & log_label & ": " & log_descr);
5365 } else {
5366 setverdict(pass);
5367 log("f_probe_for_handover(" & log_label & "): Got no Handover, as expected.");
5368 }
5369 log("f_probe_for_handover(" & log_label & "): done (got no Handover)");
5370 break;
5371 }
5372 }
5373
5374 f_rslem_resume(RSL1_PROC);
5375 f_rslem_resume(RSL2_PROC);
5376 f_sleep(3.0);
5377 RSL.clear;
5378
5379 log("f_probe_for_handover(" & log_label & "): done clearing");
5380}
5381
5382/* Test the effect of various neighbor configuration scenarios:
5383 *
5384 * To avoid complexity, block off any actual handover operation, and always remain on the lchan at bts 0.
5385 * Reconfigure the neighbors for bts 0, trigger a Handover, and probe whether osmo-bsc does or doesn't start HO.
5386 */
5387private function f_tc_ho_neighbor_config_start() runs on MSC_ConnHdlr {
5388 g_pars := f_gen_test_hdlr_pars();
5389 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
5390 var PDU_BSSAP ass_cmd := f_gen_ass_req();
5391 const OCT8 kc := '0001020304050607'O;
5392
5393 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
5394 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
5395
5396 /* Establish lchan at bts 0 */
5397 f_establish_fully(ass_cmd, exp_compl);
5398
5399 /* Shorten the inter-BSC Handover timeout, to not wait so long for inter-BSC Handovers */
5400 f_vty_enter_cfg_network(BSCVTY);
5401 f_vty_transceive(BSCVTY, "timer T7 1");
5402 f_vty_transceive(BSCVTY, "end");
5403}
5404
5405private function f_tc_ho_neighbor_config_1(charstring id) runs on MSC_ConnHdlr {
5406 f_tc_ho_neighbor_config_start();
5407
5408 /*
5409 * bts 0 ARFCN 871 BSIC 10
5410 * bts 1 ARFCN 871 BSIC 11
5411 * bts 2 ARFCN 871 BSIC 12
5412 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
5413 */
5414
5415 log("f_tc_ho_neighbor_config: 1. No 'neighbor' config");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005416 f_bts_0_cfg(BSCVTY, {"no neighbors"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02005417 f_probe_for_handover("1.a", "HO to bts 1 works, implicitly listed as neighbor (legacy behavior when none are configured)",
5418 "handover any to arfcn 871 bsic 11",
5419 true);
5420
5421 f_probe_for_handover("1.b", "HO to unknown cell does not start",
5422 "handover any to arfcn 13 bsic 39",
5423 false);
5424
5425 f_probe_for_handover("1.c", "HO to 871-12 is ambiguous = error",
5426 "handover any to arfcn 871 bsic 12",
5427 false);
5428
5429 f_probe_for_handover("1.d", "HO to 871-11 still works (verify that this test properly cleans up)",
5430 "handover any to arfcn 871 bsic 11",
5431 true);
5432}
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005433testcase TC_ho_neighbor_config_1() runs on test_CT {
5434 var MSC_ConnHdlr vc_conn;
5435 f_init(3, true, guard_timeout := 60.0);
5436 f_sleep(1.0);
5437 f_ctrs_bsc_and_bts_init();
5438 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_1));
5439 vc_conn.done;
5440
5441 /* f_tc_ho_neighbor_config_start() */
5442 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5443 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5444
5445 /* 1.a */
5446 /* "failed" means a handover was triggered and started (which is all this test aims for) and the test ended the
5447 * handover quickly by sending a Handover Failure message. */
5448 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5449 f_ctrs_bsc_and_bts_add(0, "handover:failed");
5450 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
5451 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:failed");
5452
5453 /* 1.b */
5454 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5455 f_ctrs_bsc_and_bts_add(0, "handover:error");
5456
5457 /* 1.c */
5458 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5459 f_ctrs_bsc_and_bts_add(0, "handover:error");
5460
5461 /* 1.d */
5462 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5463 f_ctrs_bsc_and_bts_add(0, "handover:failed");
5464 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
5465 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:failed");
5466
5467 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005468 f_shutdown_helper();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005469}
5470
Neels Hofmeyr91401012019-07-11 00:42:35 +02005471private function f_tc_ho_neighbor_config_2(charstring id) runs on MSC_ConnHdlr {
5472 f_tc_ho_neighbor_config_start();
5473
5474 /*
5475 * bts 0 ARFCN 871 BSIC 10
5476 * bts 1 ARFCN 871 BSIC 11
5477 * bts 2 ARFCN 871 BSIC 12
5478 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
5479 */
5480
5481 log("f_tc_ho_neighbor_config: 2. explicit local neighbor: 'neighbor bts 1'");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005482 f_bts_0_cfg(BSCVTY, {"neighbor bts 1"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02005483 f_sleep(0.5);
5484
5485 f_probe_for_handover("2.a", "HO to bts 1 works, explicitly listed as neighbor",
5486 "handover any to arfcn 871 bsic 11",
5487 true);
5488
5489 f_probe_for_handover("2.b", "HO to bts 2 doesn't work, not listed as neighbor",
5490 "handover any to arfcn 871 bsic 12",
5491 false);
5492}
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005493testcase TC_ho_neighbor_config_2() runs on test_CT {
5494 var MSC_ConnHdlr vc_conn;
5495 f_init(3, true, guard_timeout := 50.0);
5496 f_sleep(1.0);
5497 f_ctrs_bsc_and_bts_init();
5498 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_2));
5499 vc_conn.done;
5500
5501 /* f_tc_ho_neighbor_config_start() */
5502 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5503 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5504
5505 /* 2.a */
5506 /* "failed" means a handover was triggered and started (which is all this test aims for) and the test ended the
5507 * handover quickly by sending a Handover Failure message. */
5508 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5509 f_ctrs_bsc_and_bts_add(0, "handover:failed");
5510 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
5511 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:failed");
5512
5513 /* 2.b */
5514 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5515 f_ctrs_bsc_and_bts_add(0, "handover:error");
5516
5517 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005518 f_shutdown_helper();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005519}
5520
Neels Hofmeyr91401012019-07-11 00:42:35 +02005521private function f_tc_ho_neighbor_config_3(charstring id) runs on MSC_ConnHdlr {
5522 f_tc_ho_neighbor_config_start();
5523
5524 /*
5525 * bts 0 ARFCN 871 BSIC 10
5526 * bts 1 ARFCN 871 BSIC 11
5527 * bts 2 ARFCN 871 BSIC 12
5528 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
5529 */
5530
5531 log("f_tc_ho_neighbor_config: 3. explicit local neighbor: 'neighbor bts 2'");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005532 f_bts_0_cfg(BSCVTY, {"no neighbors", "neighbor bts 2"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02005533 f_sleep(0.5);
5534
5535 f_probe_for_handover("3.a", "HO to bts 1 doesn't work, not listed as neighbor",
5536 "handover any to arfcn 871 bsic 11",
5537 false);
5538 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",
5539 "handover any to arfcn 871 bsic 12",
5540 true);
5541}
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005542testcase TC_ho_neighbor_config_3() runs on test_CT {
5543 var MSC_ConnHdlr vc_conn;
5544 f_init(3, true, guard_timeout := 50.0);
5545 f_sleep(1.0);
5546 f_ctrs_bsc_and_bts_init();
5547 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_3));
5548 vc_conn.done;
5549
5550 /* f_tc_ho_neighbor_config_start() */
5551 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5552 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5553
5554 /* 3.a */
5555 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5556 f_ctrs_bsc_and_bts_add(0, "handover:error");
5557
5558 /* 3.b */
5559 /* "failed" means a handover was triggered and started (which is all this test aims for) and the test ended the
5560 * handover quickly by sending a Handover Failure message. */
5561 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5562 f_ctrs_bsc_and_bts_add(0, "handover:failed");
5563 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
5564 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:failed");
5565
5566 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005567 f_shutdown_helper();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005568}
5569
Neels Hofmeyr91401012019-07-11 00:42:35 +02005570private function f_tc_ho_neighbor_config_4(charstring id) runs on MSC_ConnHdlr {
5571 f_tc_ho_neighbor_config_start();
5572
5573 /*
5574 * bts 0 ARFCN 871 BSIC 10
5575 * bts 1 ARFCN 871 BSIC 11
5576 * bts 2 ARFCN 871 BSIC 12
5577 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
5578 */
5579
5580 log("f_tc_ho_neighbor_config: 4. explicit remote neighbor: 'neighbor lac 99 arfcn 123 bsic 45'");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005581 f_bts_0_cfg(BSCVTY, {"no neighbors", "neighbor lac 99 arfcn 123 bsic 45"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02005582 f_sleep(0.5);
5583
5584 f_probe_for_handover("4.a", "HO to bts 1 doesn't work, not listed as neighbor",
5585 "handover any to arfcn 871 bsic 11",
5586 false);
5587 f_probe_for_handover("4.b", "HO to bts 2 doesn't work, not listed as neighbor",
5588 "handover any to arfcn 871 bsic 12",
5589 false);
5590 f_probe_for_handover("4.c", "HO to 123-45 triggers inter-BSC HO",
5591 "handover any to arfcn 123 bsic 45",
5592 true, true);
5593}
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005594testcase TC_ho_neighbor_config_4() runs on test_CT {
5595 var MSC_ConnHdlr vc_conn;
5596 f_init(3, true, guard_timeout := 50.0);
5597 f_sleep(1.0);
5598 f_ctrs_bsc_and_bts_init();
5599 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_4));
5600 vc_conn.done;
5601
5602 /* f_tc_ho_neighbor_config_start() */
5603 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5604 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5605
5606 /* 4.a */
5607 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5608 f_ctrs_bsc_and_bts_add(0, "handover:error");
5609
5610 /* 4.b */
5611 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5612 f_ctrs_bsc_and_bts_add(0, "handover:error");
5613
5614 /* 4.c */
5615 /* "timeout" means a handover was triggered and started (which is all this test aims for) and the test ended the
5616 * handover quickly by timing out after the Handover Required message */
5617 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5618 f_ctrs_bsc_and_bts_add(0, "handover:timeout");
5619 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
5620 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:timeout");
5621
5622 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005623 f_shutdown_helper();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005624}
5625
Neels Hofmeyr91401012019-07-11 00:42:35 +02005626private function f_tc_ho_neighbor_config_5(charstring id) runs on MSC_ConnHdlr {
5627 f_tc_ho_neighbor_config_start();
5628
5629 /*
5630 * bts 0 ARFCN 871 BSIC 10
5631 * bts 1 ARFCN 871 BSIC 11
5632 * bts 2 ARFCN 871 BSIC 12
5633 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
5634 */
5635
5636 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 +02005637 f_bts_0_cfg(BSCVTY, {"no neighbors", "neighbor lac 99 arfcn 871 bsic 12"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02005638 f_sleep(0.5);
5639
5640 f_probe_for_handover("5.a", "HO to 871-12 triggers inter-BSC HO (ignoring local cells with same ARFCN+BSIC)",
5641 "handover any to arfcn 871 bsic 12",
5642 true, true);
5643}
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005644testcase TC_ho_neighbor_config_5() runs on test_CT {
5645 var MSC_ConnHdlr vc_conn;
5646 f_init(3, true);
5647 f_sleep(1.0);
5648 f_ctrs_bsc_and_bts_init();
5649 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_5));
5650 vc_conn.done;
5651
5652 /* f_tc_ho_neighbor_config_start() */
5653 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5654 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5655
5656 /* 5 */
5657 /* "timeout" means a handover was triggered and started (which is all this test aims for) and the test ended the
5658 * handover quickly by timing out after the Handover Required message */
5659 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5660 f_ctrs_bsc_and_bts_add(0, "handover:timeout");
5661 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
5662 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:timeout");
5663
5664 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005665 f_shutdown_helper();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005666}
5667
Neels Hofmeyr91401012019-07-11 00:42:35 +02005668private function f_tc_ho_neighbor_config_6(charstring id) runs on MSC_ConnHdlr {
5669 f_tc_ho_neighbor_config_start();
5670
5671 /*
5672 * bts 0 ARFCN 871 BSIC 10
5673 * bts 1 ARFCN 871 BSIC 11
5674 * bts 2 ARFCN 871 BSIC 12
5675 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
5676 */
5677
5678 log("f_tc_ho_neighbor_config: 6. config error: explicit local and remote neighbors with ambiguous ARFCN+BSIC:"
5679 & " 'neighbor bts 2; neighbor lac 99 arfcn 871 bsic 12'");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005680 f_bts_0_cfg(BSCVTY, {"no neighbors", "neighbor bts 2", "neighbor lac 99 arfcn 871 bsic 12"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02005681 f_sleep(0.5);
5682
5683 f_probe_for_handover("6.a", "HO to 871-12 is ambiguous = error",
5684 "handover any to arfcn 871 bsic 12",
5685 false);
5686}
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005687testcase TC_ho_neighbor_config_6() runs on test_CT {
5688 var MSC_ConnHdlr vc_conn;
5689 f_init(3, true);
5690 f_sleep(1.0);
5691 f_ctrs_bsc_and_bts_init();
5692 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_6));
5693 vc_conn.done;
5694
5695 /* f_tc_ho_neighbor_config_start() */
5696 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5697 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5698
5699 /* 6.a */
5700 /* "timeout" means a handover was triggered and started (which is all this test aims for) and the test ended the
5701 * handover quickly by timing out after the Handover Required message */
5702 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5703 f_ctrs_bsc_and_bts_add(0, "handover:error");
5704
5705 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005706 f_shutdown_helper();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005707}
5708
Neels Hofmeyr91401012019-07-11 00:42:35 +02005709private function f_tc_ho_neighbor_config_7(charstring id) runs on MSC_ConnHdlr {
5710 f_tc_ho_neighbor_config_start();
5711
5712 /*
5713 * bts 0 ARFCN 871 BSIC 10
5714 * bts 1 ARFCN 871 BSIC 11
5715 * bts 2 ARFCN 871 BSIC 12
5716 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
5717 */
5718
5719 log("f_tc_ho_neighbor_config: 7. explicit local and remote neighbors:"
5720 & " 'neighbor bts 2; neighbor lac 99 arfcn 123 bsic 45'");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005721 f_bts_0_cfg(BSCVTY, {"no neighbors", "neighbor bts 2", "neighbor lac 99 arfcn 123 bsic 45"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02005722 f_sleep(0.5);
5723
5724 f_probe_for_handover("7.a", "HO to 871-12 does HO to bts 2",
5725 "handover any to arfcn 871 bsic 12",
5726 true);
5727 f_probe_for_handover("7.b", "HO to 123-45 triggers inter-BSC HO",
5728 "handover any to arfcn 123 bsic 45",
5729 true, true);
5730}
Neels Hofmeyr91401012019-07-11 00:42:35 +02005731testcase TC_ho_neighbor_config_7() runs on test_CT {
5732 var MSC_ConnHdlr vc_conn;
Neels Hofmeyrf2b88032020-06-16 00:35:04 +02005733 f_init(3, true, guard_timeout := 50.0);
Neels Hofmeyr91401012019-07-11 00:42:35 +02005734 f_sleep(1.0);
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005735 f_ctrs_bsc_and_bts_init();
Neels Hofmeyr91401012019-07-11 00:42:35 +02005736 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_7));
5737 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005738
5739 /* f_tc_ho_neighbor_config_start() */
5740 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5741 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5742
5743 /* 7.a */
5744 /* "failed" means a handover was triggered and started (which is all this test aims for) and the test ended the
5745 * handover quickly by sending a Handover Failure message. */
5746 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5747 f_ctrs_bsc_and_bts_add(0, "handover:failed");
5748 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
5749 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:failed");
5750
5751 /* 7.b */
5752 /* "timeout" means a handover was triggered and started (which is all this test aims for) and the test ended the
5753 * handover quickly by timing out after the Handover Required message */
5754 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5755 f_ctrs_bsc_and_bts_add(0, "handover:timeout");
5756 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
5757 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:timeout");
5758
5759 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005760 f_shutdown_helper();
Neels Hofmeyr91401012019-07-11 00:42:35 +02005761}
5762
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01005763/* OS#3041: Open and close N connections in a normal fashion, and expect no
5764 * BSSMAP Reset just because of that. */
5765testcase TC_bssap_rlsd_does_not_cause_bssmap_reset() runs on test_CT {
5766 var default d;
5767 var integer i;
5768 var DchanTuple dt;
5769
5770 f_init();
5771
5772 /* Wait for initial BSSMAP Reset to pass */
5773 f_sleep(4.0);
5774
5775 d := activate(no_bssmap_reset());
5776
5777 /* Setup up a number of connections and RLSD them again from the MSC
5778 * side. In the buggy behavior, the fourth one triggers BSSMAP Reset.
5779 * Let's do it some more times for good measure. */
Harald Weltec3260d92018-06-11 17:48:16 +02005780 for (i := 0; i < 4; i := i+1) {
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01005781 /* Since we're doing a lot of runs, give each one a fresh
5782 * T_guard from the top. */
5783 T_guard.start;
5784
5785 /* Setup a BSSAP connection and clear it right away. This is
5786 * the MSC telling the BSC about a planned release, it's not an
5787 * erratic loss of a connection. */
Harald Weltea1897182018-06-11 13:53:09 +02005788 dt := f_est_dchan(int2oct(i,1), 23+i, '00010203040506'O);
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01005789
5790 /* MSC disconnects (RLSD). */
5791 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
5792 }
5793
5794 /* In the buggy behavior, a timeout of 2 seconds happens between above
5795 * trigger (logs "SIGTRAN connection down, reconnecting...") and the
5796 * actual BSSMAP Reset. Wait a bit longer just to make sure. */
5797 f_sleep(4.0);
5798
5799 deactivate(d);
5800 f_shutdown_helper();
5801}
Harald Welte552620d2017-12-16 23:21:36 +01005802
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01005803/* OS#3041: Open and close N connections in a normal fashion, and expect no
5804 * BSSMAP Reset just because of that. Invoke the release by a BSSMAP Clear from
5805 * the MSC. */
5806testcase TC_bssmap_clear_does_not_cause_bssmap_reset() runs on test_CT {
5807 var default d;
5808 var integer i;
5809 var DchanTuple dt;
5810 var BSSAP_N_DATA_ind rx_di;
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01005811 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_CALL_CONTROL;
5812 var BssmapCause cause := enum2int(cause_val);
5813
5814 f_init();
5815
5816 /* Wait for initial BSSMAP Reset to pass */
5817 f_sleep(4.0);
5818
5819 d := activate(no_bssmap_reset());
5820
5821 /* Setup up a number of connections and RLSD them again from the MSC
5822 * side. In the buggy behavior, the fourth one triggers BSSMAP Reset.
5823 * Let's do it some more times for good measure. */
5824 for (i := 0; i < 8; i := i+1) {
5825 /* Since we're doing a lot of runs, give each one a fresh
5826 * T_guard from the top. */
5827 T_guard.start;
5828
5829 /* Setup a BSSAP connection and clear it right away. This is
5830 * the MSC telling the BSC about a planned release, it's not an
5831 * erratic loss of a connection. */
Harald Weltea1897182018-06-11 13:53:09 +02005832 dt := f_est_dchan(int2oct(i,1), 23+i, '00010203040506'O);
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01005833
5834 /* Instruct BSC to clear channel */
5835 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
5836
5837 /* expect BSC to disable the channel */
Harald Welte641fcbe2018-06-14 10:58:35 +02005838 f_exp_chan_rel_and_clear(dt, 0);
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01005839 }
5840
5841 /* In the buggy behavior, a timeout of 2 seconds happens between above
5842 * trigger (logs "SIGTRAN connection down, reconnecting...") and the
5843 * actual BSSMAP Reset. Wait a bit longer just to make sure. */
5844 f_sleep(4.0);
5845
5846 deactivate(d);
5847 f_shutdown_helper();
5848}
5849
Neels Hofmeyrfd445c32018-03-09 15:39:31 +01005850/* OS#3041: Open and close N connections in a normal fashion, and expect no
5851 * BSSMAP Reset just because of that. Close connections from the MS side with a
5852 * Release Ind on RSL. */
5853testcase TC_ms_rel_ind_does_not_cause_bssmap_reset() runs on test_CT {
5854 var default d;
5855 var integer i;
5856 var DchanTuple dt;
5857 var BSSAP_N_DATA_ind rx_di;
Neels Hofmeyrfd445c32018-03-09 15:39:31 +01005858 var integer j;
5859
5860 f_init();
5861
5862 /* Wait for initial BSSMAP Reset to pass */
5863 f_sleep(4.0);
5864
5865 d := activate(no_bssmap_reset());
5866
5867 /* Setup up a number of connections and RLSD them again from the MSC
5868 * side. In the buggy behavior, the fourth one triggers BSSMAP Reset.
5869 * Let's do it some more times for good measure. */
5870 for (i := 0; i < 8; i := i+1) {
5871 /* Since we're doing a lot of runs, give each one a fresh
5872 * T_guard from the top. */
5873 T_guard.start;
5874
5875 /* Setup a BSSAP connection and clear it right away. This is
5876 * the MSC telling the BSC about a planned release, it's not an
5877 * erratic loss of a connection. */
5878 dt := f_est_dchan('23'O, 23, '00010203040506'O);
5879
5880 /* simulate RLL REL IND */
5881 f_ipa_tx(0, ts_RSL_REL_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0))));
5882
5883 /* expect Clear Request on MSC side */
5884 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearRequest)) -> value rx_di;
5885
5886 /* Instruct BSC to clear channel */
5887 var BssmapCause cause := bit2int(rx_di.userData.pdu.bssmap.clearRequest.cause.causeValue);
5888 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
5889
5890 /* expect BSC to disable the channel */
Harald Welte641fcbe2018-06-14 10:58:35 +02005891 f_exp_chan_rel_and_clear(dt, 0);
Neels Hofmeyrfd445c32018-03-09 15:39:31 +01005892 }
5893
5894 /* In the buggy behavior, a timeout of 2 seconds happens between above
5895 * trigger (logs "SIGTRAN connection down, reconnecting...") and the
5896 * actual BSSMAP Reset. Wait a bit longer just to make sure. */
5897 f_sleep(4.0);
5898
5899 deactivate(d);
5900 f_shutdown_helper();
5901}
5902
Harald Welte94e0c342018-04-07 11:33:23 +02005903/***********************************************************************
5904 * IPA style dynamic PDCH
5905 ***********************************************************************/
5906
5907private function f_dyn_ipa_pdch_act(integer bts_nr, integer trx_nr, integer ts_nr,
5908 template (omit) RSL_Cause nack := omit)
5909runs on test_CT {
5910 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(ts_nr));
5911 var RSL_Message rsl_unused;
5912 /* ask BSC via VTY to activate a given IPA style chan as PDCH */
5913 f_vty_ts_action("pdch activate", bts_nr, trx_nr, ts_nr);
5914 /* expect the BSC to issue the related RSL command */
5915 rsl_unused := f_exp_ipa_rx(0, tr_RSL_IPA_PDCH_ACT(chan_nr));
5916 if (istemplatekind(nack, "omit")) {
5917 /* respond with a related acknowledgement */
5918 f_ipa_tx(0, ts_RSL_IPA_PDCH_ACT_ACK(chan_nr, ts_RSL_IE_FrameNumber(2342)));
5919 } else {
5920 f_ipa_tx(0, ts_RSL_IPA_PDCH_ACT_NACK(chan_nr, valueof(nack)));
5921 }
5922}
5923
5924private function f_dyn_ipa_pdch_deact(integer bts_nr, integer trx_nr, integer ts_nr,
5925 template (omit) RSL_Cause nack := omit)
5926runs on test_CT {
5927 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(ts_nr));
5928 var RSL_Message rsl_unused;
5929 /* ask BSC via VTY to activate a given IPA style chan as PDCH */
5930 f_vty_ts_action("pdch deactivate", bts_nr, trx_nr, ts_nr);
5931 /* expect the BSC to issue the related RSL command */
5932 rsl_unused := f_exp_ipa_rx(0, tr_RSL_IPA_PDCH_DEACT(chan_nr));
5933 if (istemplatekind(nack, "omit")) {
5934 /* respond with a related acknowledgement */
5935 f_ipa_tx(0, ts_RSL_IPA_PDCH_DEACT_ACK(chan_nr));
5936 } else {
5937 f_ipa_tx(0, ts_RSL_IPA_PDCH_DEACT_NACK(chan_nr, valueof(nack)));
5938 }
5939}
5940
5941private function f_ts_dyn_mode_get(integer bts_nr, integer trx_nr, integer ts_nr)
5942runs on test_CT return charstring {
5943 var charstring cmd, resp;
5944 cmd := "show timeslot "&int2str(bts_nr)&" "&int2str(trx_nr)&" "&int2str(ts_nr);
Stefan Sperlingcff13562018-11-13 15:24:06 +01005945 return f_vty_transceive_match_regexp_retry(BSCVTY, cmd, "*\((*)\)*", 0, 4, 1.0);
Harald Welte94e0c342018-04-07 11:33:23 +02005946}
5947
5948private function f_ts_dyn_mode_assert(integer bts_nr, integer trx_nr, integer ts_nr,
5949 template charstring exp)
5950runs on test_CT {
5951 var charstring mode := f_ts_dyn_mode_get(bts_nr, trx_nr, ts_nr);
5952 if (not match(mode, exp)) {
5953 setverdict(fail, "Unexpected TS Mode: ", mode);
Daniel Willmannafce8662018-07-06 23:11:32 +02005954 mtc.stop;
Harald Welte94e0c342018-04-07 11:33:23 +02005955 }
5956}
5957
5958private function f_ts_set_chcomb(integer bts_nr, integer trx_nr, integer ts_nr, charstring chcomb)
5959runs on test_CT {
5960 f_vty_enter_cfg_ts(BSCVTY, bts_nr, trx_nr, ts_nr);
5961 f_vty_transceive(BSCVTY, "phys_chan_config " & chcomb);
5962 f_vty_transceive(BSCVTY, "end");
5963}
5964
5965private const charstring TCHF_MODE := "TCH/F mode";
5966private const charstring TCHH_MODE := "TCH/H mode";
5967private const charstring PDCH_MODE := "PDCH mode";
5968private const charstring NONE_MODE := "NONE mode";
5969
5970/* Test IPA PDCH activation / deactivation triggered by VTY */
5971testcase TC_dyn_pdch_ipa_act_deact() runs on test_CT {
5972 var RSL_Message rsl_unused;
5973
5974 /* change Timeslot 6 before f_init() starts RSL */
5975 f_init_vty();
5976 f_ts_set_chcomb(0, 0, 6, "TCH/F_PDCH");
5977 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
5978
5979 f_init(1, false);
5980 f_sleep(1.0);
5981
5982 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(6));
5983
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02005984 log("TCH/F_PDCH pchan starts out in TCH/F mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02005985 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
5986 /* The BSC will activate the dynamic PDCH by default, so confirm that */
5987 rsl_unused := f_exp_ipa_rx(0, tr_RSL_IPA_PDCH_ACT(chan_nr));
5988 f_ipa_tx(0, ts_RSL_IPA_PDCH_ACT_ACK(chan_nr, ts_RSL_IE_FrameNumber(2342)));
5989 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02005990 log("TCH/F_PDCH pchan, PDCH ACT was ACKed, so now in PDCH mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02005991 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, PDCH_MODE);
5992
5993 /* De-activate it via VTY */
5994 f_dyn_ipa_pdch_deact(0, 0, chan_nr.tn);
5995 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02005996 log("TCH/F_PDCH pchan, PDCH DEACT via VTY, so now back in TCH/F mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02005997 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
5998
5999 /* re-activate it via VTY */
6000 f_dyn_ipa_pdch_act(0, 0, chan_nr.tn);
6001 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02006002 log("TCH/F_PDCH pchan, PDCH ACT via VTY, so now in PDCH mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02006003 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, PDCH_MODE);
6004
6005 /* and finally de-activate it again */
6006 f_dyn_ipa_pdch_deact(0, 0, chan_nr.tn);
6007 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02006008 log("TCH/F_PDCH pchan, PDCH DEACT via VTY, so now back in TCH/F mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02006009 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
6010
Neels Hofmeyr887e8f12018-06-27 01:01:55 +02006011 /* clean up config */
6012 f_ts_set_chcomb(0, 0, 6, "PDCH");
6013
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006014 f_shutdown_helper();
Harald Welte94e0c342018-04-07 11:33:23 +02006015}
6016
6017/* Test IPA PDCH activation NACK */
6018testcase TC_dyn_pdch_ipa_act_nack() runs on test_CT {
6019 var RSL_Message rsl_unused;
6020
6021 /* change Timeslot 6 before f_init() starts RSL */
6022 f_init_vty();
6023 f_ts_set_chcomb(0, 0, 6, "TCH/F_PDCH");
6024 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
6025
6026 f_init(1, false);
6027 f_sleep(1.0);
6028
6029 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(6));
6030
6031 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
6032 /* The BSC will activate the dynamic PDCH by default, so confirm that */
6033 rsl_unused := f_exp_ipa_rx(0, tr_RSL_IPA_PDCH_ACT(chan_nr));
6034 f_ipa_tx(0, ts_RSL_IPA_PDCH_ACT_ACK(chan_nr, ts_RSL_IE_FrameNumber(2342)));
6035 f_sleep(1.0);
6036 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, PDCH_MODE);
6037
6038 /* De-activate it via VTY */
6039 f_dyn_ipa_pdch_deact(0, 0, chan_nr.tn);
6040 f_sleep(1.0);
6041 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
6042
6043 /* re-activate it via VTY, but fail that; check BSC still assumes TCH/F mode */
6044 f_dyn_ipa_pdch_act(0, 0, chan_nr.tn, RSL_ERR_EQUIPMENT_FAIL);
6045 f_sleep(1.0);
6046 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
6047
Neels Hofmeyr887e8f12018-06-27 01:01:55 +02006048 /* clean up config */
6049 f_ts_set_chcomb(0, 0, 6, "PDCH");
6050
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006051 f_shutdown_helper();
Harald Welte94e0c342018-04-07 11:33:23 +02006052}
6053
6054
6055/***********************************************************************
6056 * Osmocom style dynamic PDCH
6057 ***********************************************************************/
6058
6059private function f_dyn_osmo_pdch_act(integer bts_nr, integer trx_nr, integer ts_nr,
6060 template (omit) RSL_Cause nack := omit)
6061runs on test_CT {
6062 var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(ts_nr));
6063 var RSL_Message rsl_unused;
6064 /* ask BSC via VTY to activate a given IPA style chan as PDCH */
6065 /* FIXME: no VTY command to activate Osmocom PDCH !! */
6066 /* expect the BSC to issue the related RSL command */
6067 rsl_unused := f_exp_ipa_rx(0, tr_RSL_CHAN_ACT(chan_nr, ?));
6068 if (istemplatekind(nack, "omit")) {
6069 /* respond with a related acknowledgement */
6070 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, 2342));
6071 } else {
6072 f_ipa_tx(0, ts_RSL_CHAN_ACT_NACK(chan_nr, valueof(nack)));
6073 }
6074}
6075
6076private function f_dyn_osmo_pdch_deact(integer bts_nr, integer trx_nr, integer ts_nr,
6077 template (omit) RSL_Cause nack := omit)
6078runs on test_CT {
6079 var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(ts_nr));
6080 var RSL_Message rsl_unused;
6081 /* ask BSC via VTY to activate a given IPA style chan as PDCH */
6082 /* FIXME: no VTY command to activate Osmocom PDCH !! */
6083 /* expect the BSC to issue the related RSL command */
6084 rsl_unused := f_exp_ipa_rx(0, tr_RSL_RF_CHAN_REL(chan_nr));
6085 if (istemplatekind(nack, "omit")) {
6086 /* respond with a related acknowledgement */
6087 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(chan_nr));
6088 } else {
6089 //f_ipa_tx(0, ts_RSL_RF_CHAN_REL_NACK(chan_nr, valueof(nack)));
6090 }
6091}
6092
6093/* Test Osmocom dyn PDCH activation / deactivation triggered by VTY */
6094testcase TC_dyn_pdch_osmo_act_deact() runs on test_CT {
6095 var RSL_Message rsl_unused;
6096
6097 /* change Timeslot 6 before f_init() starts RSL */
6098 f_init_vty();
6099 f_ts_set_chcomb(0, 0, 6, "TCH/F_TCH/H_PDCH");
6100 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
6101
6102 f_init(1, false);
6103 f_sleep(1.0);
6104
6105 var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(6));
6106
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02006107 log("TCH/F_TCH/H_PDCH pchan starts out in disabled mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02006108 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, NONE_MODE);
6109 /* The BSC will activate the dynamic PDCH by default, so confirm that */
6110 rsl_unused := f_exp_ipa_rx(0, tr_RSL_CHAN_ACT_PDCH(chan_nr, ?));
6111
6112 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, 2342));
6113 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02006114 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 +02006115 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, PDCH_MODE);
6116
Neels Hofmeyr887e8f12018-06-27 01:01:55 +02006117 /* clean up config */
6118 f_ts_set_chcomb(0, 0, 6, "PDCH");
6119
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006120 f_shutdown_helper();
Harald Welte94e0c342018-04-07 11:33:23 +02006121}
6122
6123/* Test Osmocom dyn PDCH activation NACK behavior */
6124testcase TC_dyn_pdch_osmo_act_nack() runs on test_CT {
6125 var RSL_Message rsl_unused;
6126
6127 /* change Timeslot 6 before f_init() starts RSL */
6128 f_init_vty();
6129 f_ts_set_chcomb(0, 0, 6, "TCH/F_TCH/H_PDCH");
6130 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
6131
6132 f_init(1, false);
6133 f_sleep(1.0);
6134
6135 var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(6));
6136
6137 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, NONE_MODE);
6138 /* The BSC will activate the dynamic PDCH by default, so confirm that */
6139 rsl_unused := f_exp_ipa_rx(0, tr_RSL_CHAN_ACT_PDCH(chan_nr, ?));
6140
6141 /* NACK this activation and expect the "show timeslot" mode still to be NONE */
6142 f_ipa_tx(0, ts_RSL_CHAN_ACT_NACK(chan_nr, RSL_ERR_EQUIPMENT_FAIL));
6143 f_sleep(1.0);
6144 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, NONE_MODE);
6145
Neels Hofmeyr887e8f12018-06-27 01:01:55 +02006146 /* clean up config */
6147 f_ts_set_chcomb(0, 0, 6, "PDCH");
6148
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006149 f_shutdown_helper();
Harald Welte94e0c342018-04-07 11:33:23 +02006150}
6151
Stefan Sperling0796a822018-10-05 13:01:39 +02006152testcase TC_chopped_ipa_ping() runs on test_CT {
Stefan Sperling554123f2018-10-09 14:12:30 +02006153 const Integers bsc_ipa_ports := {mp_bsc_rsl_port, mp_bsc_oml_port, mp_bsc_ctrl_port};
Stefan Sperling0796a822018-10-05 13:01:39 +02006154 for (var integer i := 0; i < lengthof(bsc_ipa_ports); i := i + 1) {
6155 IPA_Testing.f_run_TC_chopped_ipa_ping(mp_bsc_ip, bsc_ipa_ports[i], CONNECT_TO_SERVER);
6156 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006157 f_shutdown_helper();
Stefan Sperling0796a822018-10-05 13:01:39 +02006158}
6159
Stefan Sperlingaa1e60f2018-10-15 16:34:07 +02006160testcase TC_chopped_ipa_payload() runs on test_CT {
6161 const Integers bsc_ipa_ports := {mp_bsc_rsl_port, mp_bsc_oml_port
6162 /* TODO: mp_bsc_ctrl_port does not work yet */};
6163 for (var integer i := 0; i < lengthof(bsc_ipa_ports); i := i + 1) {
6164 IPA_Testing.f_run_TC_chopped_ipa_payload(mp_bsc_ip, bsc_ipa_ports[i], CONNECT_TO_SERVER);
6165 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006166 f_shutdown_helper();
Stefan Sperlingaa1e60f2018-10-15 16:34:07 +02006167}
6168
Pau Espin Pedrol8f773632019-11-05 11:46:53 +01006169/* Verify the BSC sends the MS Power Parameters IE during CHAN ACT to make sure
6170 the BTS does autonomous MS power control loop */
6171testcase TC_assignment_verify_ms_power_params_ie() runs on test_CT {
6172 var MSC_ConnHdlr vc_conn;
6173 var TestHdlrParams pars := f_gen_test_hdlr_pars();
6174 //pars.encr := valueof(t_EncrParams('01'O, f_rnd_octstring(8)));
6175 pars.exp_ms_power_params := true;
6176
6177 f_init(1, true);
6178 f_sleep(1.0);
6179 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5), pars);
6180 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006181 f_shutdown_helper();
Pau Espin Pedrol8f773632019-11-05 11:46:53 +01006182}
Stefan Sperlingaa1e60f2018-10-15 16:34:07 +02006183
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006184/***********************************************************************
6185 * MSC Pooling
6186 ***********************************************************************/
6187
6188function f_tmsi_nri(integer nri_v, octetstring base_tmsi := '42000023'O, integer nri_bitlen := 10) return octetstring
6189{
6190 return int2oct( oct2int(base_tmsi) + bit2int( (int2bit(nri_v, 32) << ( 24 - nri_bitlen)) ),
6191 4);
6192}
6193
6194template MobileIdentityLV ts_MI_TMSI_NRI_LV(integer nri_v, integer nri_bitlen := 10) :=
6195 ts_MI_TMSI_LV(tmsi := f_tmsi_nri(nri_v, nri_bitlen := nri_bitlen));
6196
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02006197private function f_expect_lchan_rel(RSL_DCHAN_PT rsl) runs on MSC_ConnHdlr {
6198 interleave {
6199 [] rsl.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_RELEASE)) {
6200 f_logp(BSCVTY, "Got RSL RR Release");
6201 }
6202 [] rsl.receive(tr_RSL_DEACT_SACCH(g_chan_nr)) {
6203 f_logp(BSCVTY, "Got RSL Deact SACCH");
6204 }
6205 [] rsl.receive(tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL)) {
6206 f_logp(BSCVTY, "Got RSL RF Chan Rel, sending Rel Ack");
6207 rsl.send(ts_RSL_RF_CHAN_REL_ACK(g_chan_nr));
6208 break;
6209 }
6210 }
6211}
6212
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006213private function f_perform_clear(RSL_DCHAN_PT rsl) runs on MSC_ConnHdlr {
Neels Hofmeyr767548a2020-08-09 20:26:07 +00006214 f_logp(BSCVTY, "MSC instructs BSC to clear channel");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006215 BSSAP.send(ts_BSSMAP_ClearCommand(0));
6216 interleave {
6217 [] rsl.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_RELEASE)) {
Neels Hofmeyr767548a2020-08-09 20:26:07 +00006218 f_logp(BSCVTY, "Got RSL RR Release");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006219 }
6220 [] rsl.receive(tr_RSL_DEACT_SACCH(g_chan_nr)) {
Neels Hofmeyr767548a2020-08-09 20:26:07 +00006221 f_logp(BSCVTY, "Got RSL Deact SACCH");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006222 }
6223 [] BSSAP.receive(tr_BSSMAP_ClearComplete) {
Neels Hofmeyr767548a2020-08-09 20:26:07 +00006224 f_logp(BSCVTY, "Got BSSMAP Clear Complete");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006225 /* Also drop the SCCP connection */
6226 BSSAP.send(RAN_Conn_Prim:MSC_CONN_PRIM_DISC_REQ);
6227 }
6228 [] rsl.receive(tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL)) {
Neels Hofmeyr767548a2020-08-09 20:26:07 +00006229 f_logp(BSCVTY, "Got RSL RF Chan Rel, sending Rel Ack");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006230 rsl.send(ts_RSL_RF_CHAN_REL_ACK(g_chan_nr));
6231 }
6232 }
6233}
6234
Neels Hofmeyr66e15092020-10-12 18:44:41 +00006235private 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 +02006236runs on MSC_ConnHdlr {
6237 timer T := 10.0;
6238 var octetstring l3_enc := enc_PDU_ML3_MS_NW(valueof(l3_info));
6239
Neels Hofmeyr767548a2020-08-09 20:26:07 +00006240 f_logp(BSCVTY, "establish channel, send Complete Layer 3 Info");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006241 f_create_bssmap_exp(l3_enc);
6242
6243 /* RSL_Emulation.f_chan_est() on rsl:
6244 * This is basically code dup with s/RSL/rsl from:
6245 * RSL_Emulation.f_chan_est(g_pars.ra, l3_enc, g_pars.link_id, g_pars.fn);
6246 */
6247 var RSL_Message rx_rsl;
6248 var GsmRrMessage rr;
6249
6250 /* request a channel to be established */
6251 rsl.send(ts_RSLDC_ChanRqd(g_pars.ra, g_pars.fn));
6252 /* expect immediate assignment.
6253 * Code dup with s/RSL/rsl from:
6254 * rx_rsl := f_rx_or_fail(tr_RSL_IMM_ASSIGN);
6255 */
6256 timer Tt := 10.0;
6257
6258 /* request a channel to be established */
6259 Tt.start;
6260 alt {
6261 [] rsl.receive(tr_RSL_IMM_ASSIGN) -> value rx_rsl {
6262 Tt.stop;
6263 }
6264 [] rsl.receive {
6265 setverdict(fail, "Unexpected RSL message on DCHAN");
6266 mtc.stop;
6267 }
6268 [] Tt.timeout {
6269 setverdict(fail, "Timeout waiting for RSL on DCHAN");
6270 mtc.stop;
6271 }
6272 }
6273 rr := dec_GsmRrMessage(rx_rsl.ies[1].body.full_imm_ass_info.payload);
6274 g_chan_nr := rr.payload.imm_ass.chan_desc.chan_nr;
6275 rsl.send(ts_RSL_EST_IND(g_chan_nr, valueof(g_pars.link_id), l3_enc));
6276
6277
Neels Hofmeyr66e15092020-10-12 18:44:41 +00006278 if (expect_bssmap_l3) {
6279 f_logp(BSCVTY, "expect BSSAP Complete Layer 3 Info at MSC");
6280 var template PDU_BSSAP exp_l3_compl;
6281 exp_l3_compl := tr_BSSMAP_ComplL3()
6282 if (g_pars.aoip == false) {
6283 exp_l3_compl.pdu.bssmap.completeLayer3Information.codecList := omit;
6284 } else {
6285 exp_l3_compl.pdu.bssmap.completeLayer3Information.codecList := ?;
6286 }
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006287
Neels Hofmeyr66e15092020-10-12 18:44:41 +00006288 var PDU_BSSAP bssap;
6289 T.start;
6290 alt {
6291 [] BSSAP.receive(exp_l3_compl) -> value bssap {
6292 f_logp(BSCVTY, "received expected Complete Layer 3 Info at MSC");
6293 log("rx exp_l3_compl = ", bssap);
6294 }
6295 [] BSSAP.receive(tr_BSSMAP_ComplL3) {
6296 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Received non-matching COMPLETE LAYER 3 INFORMATION");
6297 }
6298 [] T.timeout {
6299 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for COMPLETE LAYER 3 INFORMATION");
6300 }
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006301 }
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006302
Neels Hofmeyr66e15092020-10-12 18:44:41 +00006303 /* start ciphering, if requested */
6304 if (ispresent(g_pars.encr)) {
6305 f_logp(BSCVTY, "start ciphering");
6306 f_cipher_mode(g_pars.encr.enc_alg, g_pars.encr.enc_key);
6307 }
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006308 }
6309
6310 if (do_clear) {
6311 f_perform_clear(rsl);
6312 }
6313 setverdict(pass);
6314 f_sleep(1.0);
6315}
6316
6317private function f_tc_mscpool_compl_l3(charstring id) runs on MSC_ConnHdlr {
6318 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
6319 if (g_pars.mscpool.rsl_idx == 0) {
6320 f_perform_compl_l3(RSL, g_pars.mscpool.l3_info);
6321 } else if (g_pars.mscpool.rsl_idx == 1) {
6322 f_perform_compl_l3(RSL1, g_pars.mscpool.l3_info);
6323 } else if (g_pars.mscpool.rsl_idx == 2) {
6324 f_perform_compl_l3(RSL2, g_pars.mscpool.l3_info);
6325 }
6326}
6327
6328/* Various Complete Layer 3 by IMSI all end up with the first MSC, because the other MSCs are not connected. */
6329private function f_tc_mscpool_L3Compl_on_1_msc(charstring id) runs on MSC_ConnHdlr {
6330 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
6331 f_perform_compl_l3(RSL, ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_IMSI_LV('001010000000001'H)), '00F110'O) );
6332 f_perform_compl_l3(RSL, ts_CM_SERV_REQ(CM_TYPE_MO_SMS, valueof(ts_MI_IMSI_LV('001010000000002'H))) );
6333 f_perform_compl_l3(RSL, ts_PAG_RESP(valueof(ts_MI_IMSI_LV('001010000000003'H))) );
6334 f_perform_compl_l3(RSL, ts_ML3_MO_MM_IMSI_DET_Ind(valueof(ts_MI_IMSI_LV('001010000000004'H))) );
6335}
6336testcase TC_mscpool_L3Compl_on_1_msc() runs on test_CT {
6337
6338 f_init(1, true);
6339 f_sleep(1.0);
6340 var MSC_ConnHdlr vc_conn;
6341 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006342
6343 f_ctrs_msc_init();
6344
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006345 vc_conn := f_start_handler(refers(f_tc_mscpool_L3Compl_on_1_msc), pars);
6346 vc_conn.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006347
6348 f_ctrs_msc_expect(0, "mscpool:subscr:new", 4);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006349 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006350}
6351
6352/* Three Layer 3 Complete by IMSI are round-robin'ed across two connected MSCs */
6353/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
6354 * just as well using only RSL. */
6355testcase TC_mscpool_L3Complete_by_imsi_round_robin() runs on test_CT {
6356
6357 f_init(nr_bts := 3, handler_mode := true, nr_msc := 2);
6358 f_sleep(1.0);
6359
6360 /* Control which MSC gets chosen next by the round-robin, otherwise
6361 * would be randomly affected by which other tests ran before this. */
6362 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
6363
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006364 f_ctrs_msc_init();
6365
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006366 var MSC_ConnHdlr vc_conn1;
6367 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
6368 pars1.mscpool.rsl_idx := 0;
6369 pars1.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_IMSI_LV('001010000000001'H)), '00F110'O));
6370 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6371 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006372 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006373
6374 var MSC_ConnHdlr vc_conn2;
6375 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 1);
6376 pars2.mscpool.rsl_idx := 1;
6377 pars2.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, valueof(ts_MI_IMSI_LV('001010000000002'H))));
6378 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6379 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006380 f_ctrs_msc_expect(1, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006381
6382 /* Test round-robin wrap to the first MSC */
6383 var MSC_ConnHdlr vc_conn3;
6384 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 0);
6385 pars3.mscpool.rsl_idx := 2;
6386 pars3.mscpool.l3_info := valueof(ts_PAG_RESP(valueof(ts_MI_IMSI_LV('001010000000003'H))));
6387 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
6388 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006389 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006390 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006391}
6392
6393/* Three LU by TMSI are round-robin'ed across two connected MSCs, because they contain the NULL-NRI 0
6394 * (configured in osmo-bsc.cfg). */
6395/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
6396 * just as well using only RSL. */
6397testcase TC_mscpool_LU_by_tmsi_null_nri_0_round_robin() runs on test_CT {
6398
6399 f_init(nr_bts := 3, handler_mode := true, nr_msc := 2);
6400 f_sleep(1.0);
6401
6402 /* Control which MSC gets chosen next by the round-robin, otherwise
6403 * would be randomly affected by which other tests ran before this. */
6404 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
6405
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006406 f_ctrs_msc_init();
6407
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006408 var MSC_ConnHdlr vc_conn1;
6409 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
6410 pars1.mscpool.rsl_idx := 0;
6411 pars1.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(0)), '00F110'O));
6412 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6413 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006414 f_ctrs_msc_expect(0, "mscpool:subscr:reattach");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006415
6416 var MSC_ConnHdlr vc_conn2;
6417 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 1);
6418 pars2.mscpool.rsl_idx := 1;
6419 pars2.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(0)), '00F110'O));
6420 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6421 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006422 f_ctrs_msc_expect(1, "mscpool:subscr:reattach");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006423
6424 /* Test round-robin wrap to the first MSC */
6425 var MSC_ConnHdlr vc_conn3;
6426 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 0);
6427 pars3.mscpool.rsl_idx := 2;
6428 pars3.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(0)), '00F110'O));
6429 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
6430 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006431 f_ctrs_msc_expect(0, "mscpool:subscr:reattach");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006432 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006433}
6434
6435/* Three LU by TMSI are round-robin'ed across two connected MSCs, because they contain the NULL-NRI 1
6436 * (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
6437 * NULL-NRI setting is stronger than that. */
6438/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
6439 * just as well using only RSL. */
6440testcase TC_mscpool_LU_by_tmsi_null_nri_1_round_robin() runs on test_CT {
6441
6442 f_init(nr_bts := 3, handler_mode := true, nr_msc := 2);
6443 f_sleep(1.0);
6444
6445 /* Control which MSC gets chosen next by the round-robin, otherwise
6446 * would be randomly affected by which other tests ran before this. */
6447 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
6448
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006449 f_ctrs_msc_init();
6450
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006451 var MSC_ConnHdlr vc_conn1;
6452 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
6453 pars1.mscpool.rsl_idx := 0;
6454 pars1.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(1)), '00F110'O));
6455 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6456 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006457 f_ctrs_msc_expect(0, "mscpool:subscr:reattach");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006458
6459 var MSC_ConnHdlr vc_conn2;
6460 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 1);
6461 pars2.mscpool.rsl_idx := 1;
6462 pars2.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(1)), '00F110'O));
6463 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6464 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006465 f_ctrs_msc_expect(1, "mscpool:subscr:reattach");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006466
6467 /* Test round-robin wrap to the first MSC */
6468 var MSC_ConnHdlr vc_conn3;
6469 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 0);
6470 pars3.mscpool.rsl_idx := 2;
6471 pars3.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(1)), '00F110'O));
6472 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
6473 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006474 f_ctrs_msc_expect(0, "mscpool:subscr:reattach");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006475 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006476}
6477
6478/* Three Layer 3 Complete by TMSI are round-robin'ed across two connected MSCs, because they contain an NRI not
6479 * assigned to any MSC (configured in osmo-bsc.cfg). */
6480/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
6481 * just as well using only RSL. */
6482testcase TC_mscpool_L3Complete_by_tmsi_unassigned_nri_round_robin() runs on test_CT {
6483
6484 f_init(nr_bts := 3, handler_mode := true, nr_msc := 2);
6485 f_sleep(1.0);
6486
6487 /* Control which MSC gets chosen next by the round-robin, otherwise
6488 * would be randomly affected by which other tests ran before this. */
6489 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
6490
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006491 f_ctrs_msc_init();
6492
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006493 var MSC_ConnHdlr vc_conn1;
6494 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
6495 pars1.mscpool.rsl_idx := 0;
6496 /* An NRI that is not assigned to any MSC */
6497 pars1.mscpool.l3_info := valueof(ts_ML3_MO_MM_IMSI_DET_Ind(valueof(ts_MI_TMSI_NRI_LV(1023))));
6498 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6499 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006500 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006501
6502 var MSC_ConnHdlr vc_conn2;
6503 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 1);
6504 pars2.mscpool.rsl_idx := 1;
6505 /* An NRI that is not assigned to any MSC */
6506 pars2.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(768)), '00F110'O));
6507 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6508 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006509 f_ctrs_msc_expect(1, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006510
6511 /* Test round-robin wrap to the first MSC */
6512 var MSC_ConnHdlr vc_conn3;
6513 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 0);
6514 pars3.mscpool.rsl_idx := 2;
6515 /* An NRI that is not assigned to any MSC */
6516 pars3.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_SS_ACT, valueof(ts_MI_TMSI_NRI_LV(819))));
6517 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
6518 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006519 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006520 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006521}
6522
6523/* Three Layer 3 Complete by TMSI are round-robin'ed across two connected MSCs, because they contain an NRI
6524 * assigned to an MSC that is currently not connected (configured in osmo-bsc.cfg). */
6525/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
6526 * just as well using only RSL. */
6527testcase TC_mscpool_L3Complete_by_tmsi_valid_nri_msc_not_connected_round_robin() runs on test_CT {
6528
6529 f_init(nr_bts := 3, handler_mode := true, nr_msc := 2);
6530 f_sleep(1.0);
6531
6532 /* Control which MSC gets chosen next by the round-robin, otherwise
6533 * would be randomly affected by which other tests ran before this. */
6534 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
6535
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006536 f_ctrs_msc_init();
6537
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006538 var MSC_ConnHdlr vc_conn1;
6539 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
6540 pars1.mscpool.rsl_idx := 0;
6541 /* An NRI that is assigned to an unconnected MSC */
6542 pars1.mscpool.l3_info := valueof(ts_PAG_RESP(valueof(ts_MI_TMSI_NRI_LV(512))));
6543 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6544 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006545 f_ctrs_msc_add(2, "mscpool:subscr:attach_lost");
6546 f_ctrs_msc_add(0, "mscpool:subscr:new");
6547 f_ctrs_msc_verify();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006548
6549 var MSC_ConnHdlr vc_conn2;
6550 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 1);
6551 pars2.mscpool.rsl_idx := 1;
6552 /* An NRI that is assigned to an unconnected MSC */
6553 pars2.mscpool.l3_info := valueof(ts_ML3_MO_MM_IMSI_DET_Ind(valueof(ts_MI_TMSI_NRI_LV(767))));
6554 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6555 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006556 f_ctrs_msc_add(2, "mscpool:subscr:attach_lost");
6557 f_ctrs_msc_add(1, "mscpool:subscr:new");
6558 f_ctrs_msc_verify();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006559
6560 /* Test round-robin wrap to the first MSC */
6561 var MSC_ConnHdlr vc_conn3;
6562 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 0);
6563 pars3.mscpool.rsl_idx := 2;
6564 /* An NRI that is assigned to an unconnected MSC */
6565 pars3.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(750)), '00F110'O));
6566 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
6567 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006568 f_ctrs_msc_add(2, "mscpool:subscr:attach_lost");
6569 f_ctrs_msc_add(0, "mscpool:subscr:new");
6570 f_ctrs_msc_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006571 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006572}
6573
6574/* Three Layer 3 Complete by TMSI with valid NRI for the second MSC are all directed to the second MSC (configured in
6575 * osmo-bsc.cfg). */
6576/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
6577 * just as well using only RSL. */
6578testcase TC_mscpool_L3Complete_by_tmsi_valid_nri_1() runs on test_CT {
6579
6580 f_init(nr_bts := 3, handler_mode := true, nr_msc := 2);
6581 f_sleep(1.0);
6582
6583 /* All TMSIs in this test point at the second MSC, set the round robin to point at the first MSC to make sure
6584 * this is not using round-robin. */
6585 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
6586
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006587 f_ctrs_msc_init();
6588
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006589 var MSC_ConnHdlr vc_conn1;
6590 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 1);
6591 pars1.mscpool.rsl_idx := 0;
6592 /* An NRI of the second MSC's range (256-511) */
6593 pars1.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_SMS, valueof(ts_MI_TMSI_NRI_LV(256))));
6594 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6595 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006596 f_ctrs_msc_expect(1, "mscpool:subscr:known");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006597
6598 var MSC_ConnHdlr vc_conn2;
6599 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 1);
6600 pars2.mscpool.rsl_idx := 1;
6601 /* An NRI of the second MSC's range (256-511) */
6602 pars2.mscpool.l3_info := valueof(ts_PAG_RESP(valueof(ts_MI_TMSI_NRI_LV(260))));
6603 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6604 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006605 f_ctrs_msc_expect(1, "mscpool:subscr:known");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006606
6607 var MSC_ConnHdlr vc_conn3;
6608 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 1);
6609 pars3.mscpool.rsl_idx := 2;
6610 /* An NRI of the second MSC's range (256-511) */
6611 pars3.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(511)), '00F110'O));
6612 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
6613 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006614 f_ctrs_msc_expect(1, "mscpool:subscr:known");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006615 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006616}
6617
6618/* Layer 3 Complete by TMSI with valid NRI for the third MSC are directed to the third MSC (configured in osmo-bsc.cfg),
6619 * while a round-robin remains unaffected by that. */
6620/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
6621 * just as well using only RSL. */
6622testcase TC_mscpool_L3Complete_by_tmsi_valid_nri_2() runs on test_CT {
6623
6624 f_init(nr_bts := 3, handler_mode := true, nr_msc := 3);
6625 f_sleep(1.0);
6626
6627 /* All TMSIs in this test point at the third MSC, set the round robin to point at the second MSC to make sure
6628 * this is not using round-robin. */
6629 f_vty_transceive(BSCVTY, "mscpool roundrobin next 1");
6630
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006631 f_ctrs_msc_init();
6632
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006633 var MSC_ConnHdlr vc_conn1;
6634 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 2);
6635 pars1.mscpool.rsl_idx := 0;
6636 /* An NRI of the third MSC's range (512-767) */
6637 pars1.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_SMS, valueof(ts_MI_TMSI_NRI_LV(512))));
6638 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6639 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006640 f_ctrs_msc_expect(2, "mscpool:subscr:known");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006641
6642 var MSC_ConnHdlr vc_conn2;
6643 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 2);
6644 pars2.mscpool.rsl_idx := 1;
6645 /* An NRI of the third MSC's range (512-767) */
6646 pars2.mscpool.l3_info := valueof(ts_PAG_RESP(valueof(ts_MI_TMSI_NRI_LV(678))));
6647 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6648 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006649 f_ctrs_msc_expect(2, "mscpool:subscr:known");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006650
6651 /* The above forwardings to third MSC have not affected the round robin, which still points at the second MSC */
6652 var MSC_ConnHdlr vc_conn3;
6653 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 1);
6654 pars3.mscpool.rsl_idx := 2;
6655 pars3.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_IMSI_LV('001010000000013'H)), '00F110'O));
6656 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
6657 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006658 f_ctrs_msc_expect(1, "mscpool:subscr:new");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006659 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006660}
6661
6662/* LU with a TMSI but indicating a different PLMN in its previous LAI: ignore the NRI. */
6663/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
6664 * just as well using only RSL. */
6665testcase TC_mscpool_LU_by_tmsi_from_other_PLMN() runs on test_CT {
6666
6667 f_init(nr_bts := 3, handler_mode := true, nr_msc := 3);
6668 f_sleep(1.0);
6669
6670 /* The TMSIs in this test points at the second MSC, but since it is from a different PLMN, round-robin is used
6671 * instead, and hits msc 0. */
6672 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
6673
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006674 f_ctrs_msc_init();
6675
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006676 /* An NRI of the second MSC's range (256-511), but a PLMN that doesn't match with osmo-bsc.cfg */
6677 var MSC_ConnHdlr vc_conn1;
6678 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
6679 pars1.mscpool.rsl_idx := 0;
6680 pars1.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(260)), '99F999'O));
6681 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6682 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006683 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006684
6685 /* An NRI of the third MSC's range (512-767) and a matching PLMN gets directed by NRI. */
6686 var MSC_ConnHdlr vc_conn2;
6687 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 2);
6688 pars2.mscpool.rsl_idx := 1;
6689 pars2.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(555)), '00F110'O));
6690 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6691 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006692 f_ctrs_msc_expect(2, "mscpool:subscr:known");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006693 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006694}
6695
6696/* Make sure that whichever MSC paged a subscriber will also get the Paging Response. Page by IMSI, which would be
6697 * round-robined to another MSC, to make sure the Paging->Response relation is stronger than the NRI->MSC mapping. */
6698private function f_tc_mscpool_paging_imsi(charstring id) runs on MSC_ConnHdlr {
6699 var template BSSMAP_FIELD_CellIdentificationList cid_list := { cIl_CI := { ts_BSSMAP_CI_CI(0) } };
6700 //cid_list := { cIl_allInBSS := ''O };
6701 var RSL_ChanNeeded rsl_chneed := RSL_CHANNEED_SDCCH;
6702 var template BSSMAP_IE_ChannelNeeded bssmap_chneed := ts_BSSMAP_IE_ChanNeeded(int2bit(enum2int(valueof(rsl_chneed)),2));
6703 var BSSAP_N_UNITDATA_req paging;
6704 var hexstring imsi := '001010000000123'H;
6705
6706 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
6707
Neels Hofmeyr90f80962020-06-12 16:16:55 +02006708 paging := valueof(ts_BSSAP_UNITDATA_req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006709 valueof(ts_BSSMAP_Paging(imsi, cid_list, omit, bssmap_chneed))));
6710 BSSAP.send(paging);
6711
6712 /* Register any RSL conn so that the Paging Command gets received here. With the current RSL_Emulation's main()
6713 * handling of '[bts_role] IPA_PT.receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD()))' it doesn't matter at all which
6714 * channel number is picked here. */
6715 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(0, RSL_CHAN_NR_INVALID));
6716 f_rslem_register(0, new_chan_nr);
6717 RSL.receive(tr_RSL_PAGING_CMD(tr_MI_IMSI(imsi)));
6718 f_rslem_unregister(0, new_chan_nr);
6719
6720 /* Despite the round robin pointing at the second MSC ('roundrobin next 1'), the earlier Paging for the same IMSI
6721 * causes this Paging Response to go to the first MSC (bssap_idx := 0). */
6722 f_perform_compl_l3(RSL, ts_PAG_RESP(valueof(ts_MI_IMSI_LV(imsi))) );
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006723 f_sleep(1.0);
6724}
6725testcase TC_mscpool_paging_and_response_imsi() runs on test_CT {
6726 f_init(nr_bts := 1, handler_mode := true, nr_msc := 3);
6727 f_sleep(1.0);
6728
6729 /* Testing a Paging on the first MSC to get a Paging Response back to the first MSC. Set round robin to the
6730 * second MSC to make sure we're getting the Paging logic, not a coincidental round robin match. */
6731 f_vty_transceive(BSCVTY, "mscpool roundrobin next 1");
6732
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006733 f_ctrs_msc_init();
6734
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006735 var MSC_ConnHdlr vc_conn1;
6736 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
6737 pars1.mscpool.rsl_idx := 0;
Neels Hofmeyr90f80962020-06-12 16:16:55 +02006738 pars1.sccp_addr_bsc := g_bssap[pars1.mscpool.bssap_idx].sccp_addr_peer;
6739 pars1.sccp_addr_msc := g_bssap[pars1.mscpool.bssap_idx].sccp_addr_own;
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006740 vc_conn1 := f_start_handler(refers(f_tc_mscpool_paging_imsi), pars1);
6741 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006742 f_ctrs_msc_expect(0, "mscpool:subscr:paged");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006743 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006744}
6745
6746/* Make sure that whichever MSC paged a subscriber will also get the Paging Response. Page by TMSI with an NRI value
6747 * that matches a different MSC, to make sure the Paging->Response relation is stronger than the NRI->MSC mapping. */
6748private function f_tc_mscpool_paging_tmsi(charstring id) runs on MSC_ConnHdlr {
6749 var template BSSMAP_FIELD_CellIdentificationList cid_list := { cIl_CI := { ts_BSSMAP_CI_CI(0) } };
6750 //cid_list := { cIl_allInBSS := ''O };
6751 var RSL_ChanNeeded rsl_chneed := RSL_CHANNEED_SDCCH;
6752 var template BSSMAP_IE_ChannelNeeded bssmap_chneed := ts_BSSMAP_IE_ChanNeeded(int2bit(enum2int(valueof(rsl_chneed)),2));
6753 var integer nri_v := 300; /* <-- second MSC's NRI */
6754 var octetstring tmsi := f_tmsi_nri(nri_v);
6755 var BSSAP_N_UNITDATA_req paging;
6756
6757 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
6758
Neels Hofmeyr90f80962020-06-12 16:16:55 +02006759 paging := valueof(ts_BSSAP_UNITDATA_req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006760 valueof(ts_BSSMAP_Paging('001010000000011'H, cid_list, tmsi, bssmap_chneed))));
6761 BSSAP.send(paging);
6762
6763 /* Register any RSL conn so that the Paging Command gets received here. With the current RSL_Emulation's main()
6764 * handling of '[bts_role] IPA_PT.receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD()))' it doesn't matter at all which
6765 * channel number is picked here. */
6766 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(0, RSL_CHAN_NR_INVALID));
6767 f_rslem_register(0, new_chan_nr);
6768 RSL.receive(tr_RSL_PAGING_CMD(t_MI_TMSI(tmsi)));
6769 f_rslem_unregister(0, new_chan_nr);
6770
6771 /* Despite the NRI matching the second MSC (NRI from 'msc 1' in osmo-bsc.cfg) and round robin pointing at the
6772 * third MSC ('roundrobin next 2'), the earlier Paging for the same TMSI causes this Paging Response to go to
6773 * the first MSC (bssap_idx := 0). */
6774 f_perform_compl_l3(RSL, ts_PAG_RESP(valueof(ts_MI_TMSI_NRI_LV(nri_v))) );
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006775 f_sleep(1.0);
6776}
6777testcase TC_mscpool_paging_and_response_tmsi() runs on test_CT {
6778 f_init(nr_bts := 1, handler_mode := true, nr_msc := 3);
6779 f_sleep(1.0);
6780
6781 /* Testing a Paging on the first MSC to get a Paging Response back to the first MSC. Set round robin to the
6782 * third MSC to make sure we're getting the Paging logic, not a coincidental round robin match. */
6783 f_vty_transceive(BSCVTY, "mscpool roundrobin next 2");
6784
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006785 f_ctrs_msc_init();
6786
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006787 var MSC_ConnHdlr vc_conn1;
6788 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
6789 pars1.mscpool.rsl_idx := 0;
Neels Hofmeyr90f80962020-06-12 16:16:55 +02006790 pars1.sccp_addr_bsc := g_bssap[pars1.mscpool.bssap_idx].sccp_addr_peer;
6791 pars1.sccp_addr_msc := g_bssap[pars1.mscpool.bssap_idx].sccp_addr_own;
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006792 vc_conn1 := f_start_handler(refers(f_tc_mscpool_paging_tmsi), pars1);
6793 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006794 f_ctrs_msc_expect(0, "mscpool:subscr:paged");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006795 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006796}
6797
6798/* For round-robin, skip an MSC that has 'no allow-attach' set. */
6799/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
6800 * just as well using only RSL. */
6801testcase TC_mscpool_no_allow_attach_round_robin() runs on test_CT {
6802
6803 f_init(nr_bts := 3, handler_mode := true, nr_msc := 3);
6804 f_sleep(1.0);
Neels Hofmeyra460f1f2020-08-09 20:17:03 +00006805 /* Mark the second MSC as offloading, round-robin should skip this MSC now. */
6806 f_vty_msc_allow_attach(BSCVTY, {true, false, true});
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006807
6808 /* Control which MSC gets chosen next by the round-robin, otherwise
6809 * would be randomly affected by which other tests ran before this. */
6810 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
6811
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006812 f_ctrs_msc_init();
6813
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006814 var MSC_ConnHdlr vc_conn1;
6815 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
6816 pars1.mscpool.rsl_idx := 0;
6817 pars1.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_IMSI_LV('001010000000001'H)), '00F110'O));
6818 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6819 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006820 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006821
6822 var MSC_ConnHdlr vc_conn2;
6823 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 2);
6824 pars2.mscpool.rsl_idx := 1;
6825 pars2.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, valueof(ts_MI_IMSI_LV('001010000000002'H))));
6826 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6827 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006828 f_ctrs_msc_expect(2, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006829
6830 var MSC_ConnHdlr vc_conn3;
6831 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 0);
6832 pars3.mscpool.rsl_idx := 2;
6833 pars3.mscpool.l3_info := valueof(ts_PAG_RESP(valueof(ts_MI_IMSI_LV('001010000000003'H))));
6834 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
6835 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006836 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006837 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006838}
6839
6840/* An MSC that has 'no allow-attach' set should still serve subscribers that are already attached according to their
6841 * TMSI NRI. */
6842testcase TC_mscpool_no_allow_attach_valid_nri() runs on test_CT {
6843
6844 f_init(nr_bts := 3, handler_mode := true, nr_msc := 3);
6845 f_sleep(1.0);
6846
Neels Hofmeyra460f1f2020-08-09 20:17:03 +00006847 /* Mark the second MSC as offloading, round-robin should skip this MSC now. */
6848 f_vty_msc_allow_attach(BSCVTY, {true, false, true});
6849
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006850 /* Control which MSC gets chosen next by the round-robin, otherwise
6851 * would be randomly affected by which other tests ran before this. */
6852 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
6853
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006854 f_ctrs_msc_init();
6855
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006856 /* Round robin points at msc 0, but the valid NRI directs to msc 1, even though msc 1 has 'no allow-attach'. */
6857 var MSC_ConnHdlr vc_conn1;
6858 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 1);
6859 pars1.mscpool.rsl_idx := 0;
6860 /* An NRI of the second MSC's range (256-511) */
6861 pars1.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, valueof(ts_MI_TMSI_NRI_LV(260))));
6862 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6863 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006864 f_ctrs_msc_expect(1, "mscpool:subscr:known");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006865
6866 var MSC_ConnHdlr vc_conn2;
6867 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 0);
6868 pars2.mscpool.rsl_idx := 1;
6869 pars2.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, valueof(ts_MI_IMSI_LV('001010000000002'H))));
6870 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6871 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006872 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006873
6874 var MSC_ConnHdlr vc_conn3;
6875 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 2);
6876 pars3.mscpool.rsl_idx := 2;
6877 pars3.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, valueof(ts_MI_IMSI_LV('001010000000003'H))));
6878 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
6879 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006880 f_ctrs_msc_expect(2, "mscpool:subscr:new");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006881 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006882}
6883
Philipp Maier783681c2020-07-16 16:47:06 +02006884/* Allow/Deny emergency calls globally via VTY */
6885private function f_vty_allow_emerg_msc(boolean allow) runs on test_CT {
6886 f_vty_enter_cfg_msc(BSCVTY, 0);
6887 if (allow) {
6888 f_vty_transceive(BSCVTY, "allow-emergency allow");
6889 } else {
6890 f_vty_transceive(BSCVTY, "allow-emergency deny");
6891 }
6892 f_vty_transceive(BSCVTY, "exit");
6893 f_vty_transceive(BSCVTY, "exit");
6894}
6895
6896/* Allow/Deny emergency calls per BTS via VTY */
6897private function f_vty_allow_emerg_bts(boolean allow, integer bts_nr) runs on test_CT {
6898 f_vty_enter_cfg_bts(BSCVTY, bts_nr);
6899 if (allow) {
6900 f_vty_transceive(BSCVTY, "rach emergency call allowed 1");
6901 } else {
6902 f_vty_transceive(BSCVTY, "rach emergency call allowed 0");
6903 }
6904 f_vty_transceive(BSCVTY, "exit");
6905 f_vty_transceive(BSCVTY, "exit");
Neels Hofmeyrb6ed80c2020-10-12 22:52:39 +00006906 f_vty_transceive(BSCVTY, "exit");
Philipp Maier783681c2020-07-16 16:47:06 +02006907}
6908
6909/* Begin assignmet procedure and send an EMERGENCY SETUP (RR) */
6910private function f_assignment_emerg_setup() runs on MSC_ConnHdlr {
6911 var PDU_ML3_MS_NW emerg_setup;
6912 var octetstring emerg_setup_enc;
6913 var RSL_Message emerg_setup_data_ind;
6914
6915 f_establish_fully(omit, omit);
6916
6917 emerg_setup := valueof(ts_ML3_MO_CC_EMERG_SETUP(1, valueof(ts_Bcap_voice)));
6918 emerg_setup_enc := enc_PDU_ML3_MS_NW(emerg_setup);
6919 emerg_setup_data_ind := valueof(ts_RSL_DATA_IND(g_chan_nr, valueof(ts_RslLinkID_DCCH(0)), emerg_setup_enc));
6920
6921 RSL.send(emerg_setup_data_ind);
6922}
6923
6924/* Test if the EMERGENCY SETUP gets passed on to the MSC via A when EMERGENCY
6925 * CALLS are permitted by the BSC config. */
6926private function f_TC_assignment_emerg_setup_allow(charstring id) runs on MSC_ConnHdlr {
6927 var PDU_BSSAP emerg_setup_data_ind_bssap;
6928 var PDU_ML3_MS_NW emerg_setup;
6929 timer T := 3.0;
6930
6931 f_assignment_emerg_setup()
6932
6933 T.start;
6934 alt {
6935 [] BSSAP.receive(tr_BSSAP_DTAP) -> value emerg_setup_data_ind_bssap {
6936 emerg_setup := dec_PDU_ML3_MS_NW(emerg_setup_data_ind_bssap.pdu.dtap);
6937 if (not isbound(emerg_setup.msgs.cc.emergencySetup)) {
6938 setverdict(fail, "no emergency setup");
6939 }
6940 }
6941 [] BSSAP.receive {
6942 setverdict(fail, "unexpected BSSAP message!");
6943 }
6944 [] T.timeout {
6945 setverdict(fail, "timout waiting for EMERGENCY SETUP!");
6946 }
6947 }
6948
6949 setverdict(pass);
6950}
6951
6952/* Test if the EMERGENCY SETUP gets blocked by the BSC if EMERGENCY CALLS are
6953 * forbidden by the BSC config. */
6954private function f_TC_assignment_emerg_setup_deny(charstring id) runs on MSC_ConnHdlr {
6955 var PDU_BSSAP emerg_setup_data_ind_bssap;
6956 timer T := 3.0;
6957
6958 f_assignment_emerg_setup()
6959
6960 T.start;
6961 alt {
6962 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_RELEASE)) {
6963 setverdict(pass);
6964 }
6965 [] RSL.receive {
6966 setverdict(fail, "unexpected RSL message!");
6967 }
6968 [] T.timeout {
6969 setverdict(fail, "timout waiting for RR CHANNEL RELEASE!");
6970 }
6971 }
6972}
6973
6974/* EMERGENCY CALL situation #1, allowed globally and by BTS */
6975testcase TC_assignment_emerg_setup_allow() runs on test_CT {
6976 var TestHdlrParams pars := f_gen_test_hdlr_pars();
6977 var MSC_ConnHdlr vc_conn;
6978
6979 f_init(1, true);
6980 f_sleep(1.0);
6981
6982 f_vty_allow_emerg_msc(true);
6983 f_vty_allow_emerg_bts(true, 0);
6984 vc_conn := f_start_handler(refers(f_TC_assignment_emerg_setup_allow), pars);
6985 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006986 f_shutdown_helper();
Philipp Maier783681c2020-07-16 16:47:06 +02006987}
6988
6989/* EMERGENCY CALL situation #2, forbidden globally but allowed by BTS */
6990testcase TC_assignment_emerg_setup_deny_msc() runs on test_CT {
6991 var TestHdlrParams pars := f_gen_test_hdlr_pars();
6992 var MSC_ConnHdlr vc_conn;
6993
6994 f_init(1, true);
6995 f_sleep(1.0);
6996
6997 f_vty_allow_emerg_msc(false);
6998 f_vty_allow_emerg_bts(true, 0);
6999 vc_conn := f_start_handler(refers(f_TC_assignment_emerg_setup_deny), pars);
7000 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007001 f_shutdown_helper();
Philipp Maier783681c2020-07-16 16:47:06 +02007002}
7003
7004/* EMERGENCY CALL situation #3, allowed globally but forbidden by BTS */
7005testcase TC_assignment_emerg_setup_deny_bts() runs on test_CT {
7006 var TestHdlrParams pars := f_gen_test_hdlr_pars();
7007 var MSC_ConnHdlr vc_conn;
7008
7009 /* Note: This simulates a spec violation by the MS, correct MS
7010 * implementations would not try to establish an emergency call because
7011 * the system information tells in advance that emergency calls are
7012 * not forbidden */
7013
7014 f_init(1, true);
7015 f_sleep(1.0);
7016
7017 f_vty_allow_emerg_msc(true);
7018 f_vty_allow_emerg_bts(false, 0);
7019 vc_conn := f_start_handler(refers(f_TC_assignment_emerg_setup_deny), pars);
7020 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007021 f_shutdown_helper();
Philipp Maier783681c2020-07-16 16:47:06 +02007022}
7023
Philipp Maier82812002020-08-13 18:48:27 +02007024/* Test what happens when an emergency call arrives while all TCH channels are
7025 * busy, the BSC is expected to terminate one call in favor of the incoming
7026 * emergency call */
7027testcase TC_emerg_premption() runs on test_CT {
7028 var ASP_RSL_Unitdata rsl_ud;
7029 var integer i;
7030 var integer chreq_total, chreq_nochan;
7031 var RSL_Message rx_rsl;
7032 var RslChannelNr chan_nr;
7033
7034 f_init(1);
7035 f_sleep(1.0);
7036
7037 f_vty_allow_emerg_msc(true);
7038 f_vty_allow_emerg_bts(true, 0);
7039
7040 /* Fill up all channels on the BTS */
7041 chreq_total := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total");
7042 chreq_nochan := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:no_channel");
7043 for (i := 0; i < NUM_TCHF_PER_BTS + NUM_TCHH_PER_BTS + NUM_SDCCH_PER_BTS; i := i+1) {
7044 chan_nr := f_chreq_act_ack('33'O, i);
7045 }
7046 IPA_RSL[0].clear;
7047 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total",
7048 chreq_total + NUM_TCHF_PER_BTS + NUM_TCHH_PER_BTS + NUM_SDCCH_PER_BTS);
7049
7050 /* Send Channel request for emegergency call */
7051 f_ipa_tx(0, ts_RSL_CHAN_RQD('A5'O, 23));
7052
7053 /* Expect the BSC to release one (the first) TCH/F on the BTS */
7054 chan_nr := valueof(t_RslChanNr_Bm(1));
7055 f_expect_chan_rel(0, chan_nr, expect_rr_chan_rel := false, expect_rll_rel_req := false);
7056
7057 /* Expect the BSC to send activate/assign the a channel for the emergency call */
7058 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
7059 chan_nr := rx_rsl.ies[0].body.chan_nr;
7060 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, 33));
7061 rx_rsl := f_exp_ipa_rx(0, tr_RSL_IMM_ASSIGN(0));
Philipp Maier104f4c02020-09-11 18:12:18 +02007062
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02007063 f_shutdown_helper();
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007064}
7065
7066/* Hopping parameters per a timeslot */
Vadim Yanitskiybc6654a2020-09-13 01:27:40 +07007067private type record length(0..64) of GsmArfcn ArfcnList;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007068private type record FHParamsTs {
7069 boolean enabled,
7070 uint6_t hsn,
7071 uint6_t maio,
7072 ArfcnList ma
7073};
7074
7075/* Hopping parameters per a transceiver */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007076private type record FHParamsTrx {
7077 GsmArfcn arfcn,
7078 FHParamsTs ts[8]
7079};
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007080
7081/* Randomly generate the hopping parameters for the given timeslot numbers */
7082private function f_TC_fh_params_gen(template integer tr_tn := (1, 3, 5))
7083runs on test_CT return FHParamsTrx {
7084 var FHParamsTrx fhp;
7085
Vadim Yanitskiy3e997362020-09-05 21:08:34 +07007086 /* Generate a random ARFCN, including ARFCN 0 */
7087 fhp.arfcn := f_rnd_int(3);
Vadim Yanitskiye7c8c6e2020-09-13 14:33:03 +07007088
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007089 for (var integer tn := 0; tn < 8; tn := tn + 1) {
7090 if (not match(tn, tr_tn)) {
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007091 fhp.ts[tn].enabled := false;
7092 fhp.ts[tn].ma := { };
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007093 continue;
7094 }
7095
7096 /* Random HSN / MAIO values: 0..63 */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007097 fhp.ts[tn].hsn := f_rnd_int(64);
7098 fhp.ts[tn].maio := f_rnd_int(64);
7099 fhp.ts[tn].ma := { };
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007100
7101 /* Random Mobile Allocation (hopping channels) */
7102 var integer ma_len := 2 + f_rnd_int(9); /* 2..10 channels */
7103 var integer step := 3 + f_rnd_int(4); /* 3..6 stepping */
7104 for (var integer i := 1; i <= ma_len; i := i + 1) {
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007105 fhp.ts[tn].ma := fhp.ts[tn].ma & { i * step };
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007106 }
7107
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007108 fhp.ts[tn].enabled := true;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007109 }
7110
7111 log("f_TC_fh_params_gen(): ", fhp);
7112 return fhp;
7113}
7114
7115/* Make sure that the given Channel Description IE matches the hopping configuration */
7116private function f_TC_fh_params_match_chan_desc(in FHParamsTrx fhp, in ChannelDescription cd)
7117{
7118 var template (present) ChannelDescription tr_cd;
7119 var template (present) MaioHsn tr_maio_hsn;
7120 var uint3_t tn := cd.chan_nr.tn;
7121
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007122 if (fhp.ts[tn].enabled) {
7123 tr_maio_hsn := tr_HsnMaio(fhp.ts[tn].hsn, fhp.ts[tn].maio);
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007124 tr_cd := tr_ChanDescH1(cd.chan_nr, tr_maio_hsn);
7125 } else {
Vadim Yanitskiye7c8c6e2020-09-13 14:33:03 +07007126 tr_cd := tr_ChanDescH0(cd.chan_nr, fhp.arfcn);
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007127 }
7128
7129 if (not match(cd, tr_cd)) {
7130 setverdict(fail, "Channel Description IE does not match: ",
7131 cd, " vs expected ", tr_cd);
7132 }
7133}
7134
7135/* Make sure that the given Mobile Allocation IE matches the hopping configuration */
7136private function f_TC_fh_params_match_ma(in FHParamsTrx fhp, uint3_t tn,
7137 in MobileAllocationLV ma)
7138{
7139 var template MobileAllocationLV tr_ma := f_TC_fh_params_gen_tr_ma(fhp, tn, ma);
7140
7141 if (not match(ma, tr_ma)) {
7142 setverdict(fail, "Mobile Allocation IE does not match (tn := ",
7143 tn, "): ", ma, " vs expected: ", tr_ma);
7144 } else {
7145 setverdict(pass);
7146 }
7147}
7148
7149private function f_TC_fh_params_gen_tr_ma(in FHParamsTrx fhp, uint3_t tn,
7150 in MobileAllocationLV ma)
7151return template MobileAllocationLV {
7152 /* Mobile Allocation IE is expected to be empty if hopping is not enabled */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007153 if (not fhp.ts[tn].enabled) {
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007154 return { len := 0, ma := ''B };
7155 }
7156
7157 var bitstring full_mask := f_pad_bit(''B, 1024, '0'B);
7158 var bitstring slot_mask := f_pad_bit(''B, 1024, '0'B);
7159 var bitstring ma_mask := ''B;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007160
7161 /* Compose the full bit-mask (all channels, up to 1024 entries) */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007162 for (var integer i := 0; i < lengthof(fhp.ts); i := i + 1) {
7163 for (var integer j := 0; j < lengthof(fhp.ts[i].ma); j := j + 1) {
7164 if (full_mask[fhp.ts[i].ma[j]] == '1'B)
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007165 { continue; }
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007166 full_mask[fhp.ts[i].ma[j]] := '1'B;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007167 }
7168 }
7169
Vadim Yanitskiye7c8c6e2020-09-13 14:33:03 +07007170 /* Take ARFCN of the TRX itself into account */
7171 full_mask[fhp.arfcn] := '1'B;
7172
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007173 /* Compose a bit-mask for the given timeslot number */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007174 for (var integer i := 0; i < lengthof(fhp.ts[tn].ma); i := i + 1) {
7175 slot_mask[fhp.ts[tn].ma[i]] := '1'B;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007176 }
7177
7178 /* Finally, compose the Mobile Allocation bit-mask */
Vadim Yanitskiy3e997362020-09-05 21:08:34 +07007179 for (var integer i := 1; i < lengthof(full_mask); i := i + 1) {
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007180 if (full_mask[i] != '1'B)
7181 { continue; }
7182
7183 /* FIXME: ma_mask := ma_mask & slot_mask[i]; // triggers a bug in TITAN */
7184 if (slot_mask[i] == '1'B) {
7185 ma_mask := ma_mask & '1'B;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007186 } else {
7187 ma_mask := ma_mask & '0'B;
7188 }
7189 }
7190
Vadim Yanitskiy3e997362020-09-05 21:08:34 +07007191 /* ARFCN 0 (if present) goes to the last position of the bit-mask */
7192 if (full_mask[0] == '1'B) {
7193 /* FIXME: ma_mask := ma_mask & slot_mask[0]; // triggers a bug in TITAN */
7194 if (slot_mask[0] == '1'B) {
7195 ma_mask := ma_mask & '1'B;
7196 } else {
7197 ma_mask := ma_mask & '0'B;
7198 }
7199 }
7200
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007201 /* Ensure that ma_mask is octet-aligned */
Vadim Yanitskiy2aa02522020-09-06 14:05:23 +07007202 var integer ma_mask_len := (lengthof(ma_mask) + 8 - 1) / 8;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007203 ma_mask := f_pad_bit(ma_mask, ma_mask_len * 8, '0'B);
7204
7205 return { len := ma_mask_len, ma := ma_mask };
7206}
7207
7208/* Configure the hopping parameters in accordance with the given record */
7209private function f_TC_fh_params_set(in FHParamsTrx fhp,
7210 uint8_t bts_nr := 0,
7211 uint8_t trx_nr := 0)
7212runs on test_CT {
7213 /* Enter the configuration node for the given BTS/TRX numbers */
7214 f_vty_enter_cfg_trx(BSCVTY, bts_nr, trx_nr);
7215
Vadim Yanitskiye7c8c6e2020-09-13 14:33:03 +07007216 f_vty_transceive(BSCVTY, "arfcn " & int2str(fhp.arfcn));
7217
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007218 for (var integer tn := 0; tn < lengthof(fhp.ts); tn := tn + 1) {
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007219 f_vty_transceive(BSCVTY, "timeslot " & int2str(tn));
7220
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007221 if (not fhp.ts[tn].enabled) {
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007222 f_vty_transceive(BSCVTY, "hopping enabled 0");
7223 f_vty_transceive(BSCVTY, "exit"); /* go back */
7224 continue;
7225 }
7226
7227 /* Configure HSN / MAIO values */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007228 f_vty_transceive(BSCVTY, "hopping sequence-number " & int2str(fhp.ts[tn].hsn));
7229 f_vty_transceive(BSCVTY, "hopping maio " & int2str(fhp.ts[tn].maio));
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007230
7231 /* Configure the Mobile Allocation (hopping channels) */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007232 for (var integer i := 0; i < lengthof(fhp.ts[tn].ma); i := i + 1) {
7233 f_vty_transceive(BSCVTY, "hopping arfcn add " & int2str(fhp.ts[tn].ma[i]));
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007234 }
7235
7236 f_vty_transceive(BSCVTY, "hopping enabled 1");
7237 f_vty_transceive(BSCVTY, "exit"); /* go back */
7238 }
7239
7240 f_vty_transceive(BSCVTY, "end");
7241}
7242
7243/* Disable frequency hopping on all timeslots */
7244private function f_TC_fh_params_unset(in FHParamsTrx fhp,
7245 uint8_t bts_nr := 0,
Vadim Yanitskiye7c8c6e2020-09-13 14:33:03 +07007246 uint8_t trx_nr := 0,
7247 GsmArfcn arfcn := 871)
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007248runs on test_CT {
7249 /* Enter the configuration node for the given BTS/TRX numbers */
7250 f_vty_enter_cfg_trx(BSCVTY, bts_nr, trx_nr);
7251
Vadim Yanitskiye7c8c6e2020-09-13 14:33:03 +07007252 f_vty_transceive(BSCVTY, "arfcn " & int2str(arfcn));
7253
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007254 for (var integer tn := 0; tn < lengthof(fhp.ts); tn := tn + 1) {
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007255 f_vty_transceive(BSCVTY, "timeslot " & int2str(tn));
7256
7257 /* Delete all ARFCNs from the Mobile Allocation (if any) */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007258 for (var integer i := 0; i < lengthof(fhp.ts[tn].ma); i := i + 1) {
7259 f_vty_transceive(BSCVTY, "hopping arfcn del " & int2str(fhp.ts[tn].ma[i]));
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007260 }
7261
7262 f_vty_transceive(BSCVTY, "hopping enabled 0");
7263 f_vty_transceive(BSCVTY, "exit"); /* go back */
7264 }
7265
7266 f_vty_transceive(BSCVTY, "end");
7267 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
7268}
7269
7270/* Verify presence and correctness of the hopping parameters (HSN, MAIO)
7271 * in the Channel Identification IE of the RSL CHANnel ACTIVation message. */
7272testcase TC_fh_params_chan_activ() runs on test_CT {
7273 var FHParamsTrx fhp := f_TC_fh_params_gen();
7274 var RSL_Message rsl_msg;
7275 var RSL_IE_Body ie;
7276
7277 f_init_vty();
7278
7279 f_TC_fh_params_set(fhp); /* Enable frequency hopping */
7280 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
7281
7282 f_init(1);
7283
7284 /* CS domain: 3 (SDCCH/4+CBCH) + 4 (TCH/F) + 2 (TCH/H) channels available */
7285 for (var integer i := 0; i < 9; i := i + 1) {
7286 f_ipa_tx(0, ts_RSL_CHAN_RQD(f_rnd_ra_cs(), 23));
7287 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
7288
7289 /* Make sure that Channel Identification IE is present */
7290 if (not f_rsl_find_ie(rsl_msg, RSL_IE_CHAN_IDENT, ie)) {
7291 setverdict(fail, "RSL Channel Identification IE is absent");
7292 continue;
7293 }
7294
7295 /* Make sure that hopping parameters (HSN/MAIO) match */
7296 f_TC_fh_params_match_chan_desc(fhp, ie.chan_ident.ch_desc.v);
7297
7298 /* "Mobile Allocation shall be included but empty" - let's check this */
7299 if (ie.chan_ident.ma.v.len != 0) {
7300 setverdict(fail, "Mobile Allocation IE is not empty: ",
7301 ie.chan_ident.ma, ", despite it shall be");
7302 continue;
7303 }
7304 }
7305
7306 /* Disable frequency hopping */
7307 f_TC_fh_params_unset(fhp);
7308
Vadim Yanitskiy21726312020-09-04 01:45:36 +07007309 f_shutdown_helper();
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007310}
7311
7312/* Verify the hopping parameters (HSN, MAIO, MA) in (RR) Immediate Assignment */
7313testcase TC_fh_params_imm_ass() runs on test_CT {
7314 var FHParamsTrx fhp := f_TC_fh_params_gen();
7315 var RSL_Message rsl_msg;
7316 var RSL_IE_Body ie;
7317
7318 f_init_vty();
7319
7320 f_TC_fh_params_set(fhp); /* Enable frequency hopping */
7321 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
7322
7323 f_init(1);
7324
7325 /* CS domain: 3 (SDCCH/4+CBCH) + 4 (TCH/F) + 2 (TCH/H) channels available */
7326 for (var integer i := 0; i < 9; i := i + 1) {
7327 f_ipa_tx(0, ts_RSL_CHAN_RQD(f_rnd_ra_cs(), 23));
7328 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
7329
7330 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(rsl_msg.ies[0].body.chan_nr, 33));
7331 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeC(RSL_MT_IMMEDIATE_ASSIGN_CMD));
7332
7333 /* Make sure that Full Immediate Assign Info IE is present */
7334 if (not f_rsl_find_ie(rsl_msg, RSL_IE_FULL_IMM_ASS_INFO, ie)) {
7335 setverdict(fail, "RSL Full Immediate Assign Info IE is absent");
7336 continue;
7337 }
7338
7339 /* Decode the actual Immediate Assignment message */
7340 var GsmRrMessage rr_msg := dec_GsmRrMessage(ie.full_imm_ass_info.payload);
7341 if (not match(rr_msg.header, t_RrHeader(IMMEDIATE_ASSIGNMENT, ?))) {
7342 setverdict(fail, "Failed to match Immediate Assignment: ", rr_msg);
7343 continue;
7344 }
7345
7346 /* Make sure that hopping parameters (HSN/MAIO) match */
7347 f_TC_fh_params_match_chan_desc(fhp, rr_msg.payload.imm_ass.chan_desc);
7348
7349 /* Make sure that the Mobile Allocation IE matches */
7350 f_TC_fh_params_match_ma(fhp, rr_msg.payload.imm_ass.chan_desc.chan_nr.tn,
7351 rr_msg.payload.imm_ass.mobile_allocation);
7352 }
7353
7354 /* Disable frequency hopping */
7355 f_TC_fh_params_unset(fhp);
Philipp Maier82812002020-08-13 18:48:27 +02007356
Vadim Yanitskiy21726312020-09-04 01:45:36 +07007357 f_shutdown_helper();
Philipp Maier82812002020-08-13 18:48:27 +02007358}
7359
Vadim Yanitskiyaeb54a22020-09-01 06:25:25 +07007360/* Verify the hopping parameters (HSN, MAIO, MA) in (RR) Assignment Command */
7361testcase TC_fh_params_assignment_cmd() runs on test_CT {
7362 var FHParamsTrx fhp := f_TC_fh_params_gen();
7363 var RSL_Message rsl_msg;
7364 var RSL_IE_Body ie;
7365
7366 f_init_vty();
7367
7368 f_TC_fh_params_set(fhp); /* Enable frequency hopping */
7369 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
7370
7371 f_init(1);
7372
7373 /* HACK: work around "Couldn't find Expect for CRCX" */
7374 vc_MGCP.stop;
7375
7376 var template PDU_BSSAP ass_cmd := f_gen_ass_req();
7377 ass_cmd.pdu.bssmap.assignmentRequest.codecList := ts_BSSMAP_IE_CodecList({ts_CodecFR});
7378
7379 /* CS domain (TCH): 4 (TCH/F) + 2 (TCH/H) channels available
7380 * NOTE: only 3 SDCCH/4 channels are available on CCCH+SDCCH4+CBCH */
7381 for (var integer i := 0; i < 3; i := i + 1) {
7382 /* Establish a dedicated channel, so we can trigger (late) TCH assignment */
7383 var DchanTuple dt := f_est_dchan(f_rnd_ra_cs(), 23, f_rnd_octstring(16));
7384
7385 /* Send a BSSMAP Assignment Command, expect CHANnel ACTIVation */
7386 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ass_cmd));
7387 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
7388
7389 /* ACKnowledge CHANnel ACTIVation, expect RSL DATA REQuest */
7390 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(rsl_msg.ies[0].body.chan_nr, 33));
7391 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeR(RSL_MT_DATA_REQ));
7392
7393 /* Make sure that L3 Information IE is present */
7394 if (not f_rsl_find_ie(rsl_msg, RSL_IE_L3_INFO, ie)) {
7395 setverdict(fail, "RSL L3 Information IE is absent");
7396 continue;
7397 }
7398
7399 /* Decode the L3 message and make sure it is (RR) Assignment Command */
7400 var GsmRrL3Message l3_msg := dec_GsmRrL3Message(ie.l3_info.payload);
7401 if (not match(l3_msg.header, t_RrL3Header(ASSIGNMENT_COMMAND))) {
7402 setverdict(fail, "Failed to match Assignment Command: ", l3_msg);
7403 continue;
7404 }
7405
7406 /* Make sure that hopping parameters (HSN/MAIO) match */
7407 var ChannelDescription chan_desc := l3_msg.payload.ass_cmd.chan_desc;
7408 f_TC_fh_params_match_chan_desc(fhp, chan_desc);
7409
7410 /* Make sure that Cell Channel Description IE is present if FH is enabled */
7411 if (chan_desc.h and not ispresent(l3_msg.payload.ass_cmd.cell_chan_desc)) {
Vadim Yanitskiy38d069d2020-09-02 17:18:57 +07007412 setverdict(fail, "FH enabled, but Cell Channel Description IE is absent");
Vadim Yanitskiyaeb54a22020-09-01 06:25:25 +07007413 continue;
7414 }
7415
7416 /* Make sure that the Mobile Allocation IE matches (if present) */
7417 var boolean ma_present := ispresent(l3_msg.payload.ass_cmd.mobile_allocation);
7418 if (chan_desc.h and ma_present) {
7419 f_TC_fh_params_match_ma(fhp, chan_desc.chan_nr.tn,
7420 l3_msg.payload.ass_cmd.mobile_allocation.v);
7421 } else if (chan_desc.h and not ma_present) {
7422 setverdict(fail, "FH enabled, but Mobile Allocation IE is absent");
7423 continue;
7424 } else if (not chan_desc.h and ma_present) {
7425 setverdict(fail, "FH disabled, but Mobile Allocation IE is present");
7426 continue;
7427 }
7428 }
7429
7430 /* Give the IUT some time to release all channels */
7431 f_sleep(3.0);
7432
7433 /* Disable frequency hopping */
7434 f_TC_fh_params_unset(fhp);
7435
Vadim Yanitskiy21726312020-09-04 01:45:36 +07007436 f_shutdown_helper();
Vadim Yanitskiyaeb54a22020-09-01 06:25:25 +07007437}
7438
Vadim Yanitskiy8f5430d2020-09-02 18:51:38 +07007439/* Verify the hopping parameters (HSN, MAIO, MA) in (RR) Handover Command */
7440private function f_TC_fh_params_handover_cmd(in FHParamsTrx fhp)
7441runs on test_CT {
7442 var RSL_Message rsl_msg;
7443 var RSL_IE_Body ie;
7444 var DchanTuple dt;
7445
7446 /* Establish a dedicated channel, so we can trigger handover */
7447 dt := f_est_dchan(f_rnd_ra_cs(), 23, f_rnd_octstring(16));
7448
7449 /* Trigger handover from BTS0 to BTS1 */
7450 f_bts_0_cfg(BSCVTY, { "neighbor bts 1" });
7451 f_vty_handover(BSCVTY, 0, 0, dt.rsl_chan_nr, 1);
7452
7453 /* Expect RSL CHANnel ACTIVation on BTS1/TRX0/TS1 */
7454 rsl_msg := f_exp_ipa_rx(1, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
7455
7456 /* ACKnowledge channel activation and expect (RR) Handover Command */
7457 f_ipa_tx(1, ts_RSL_CHAN_ACT_ACK(rsl_msg.ies[0].body.chan_nr, 33));
7458 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeR(RSL_MT_DATA_REQ));
7459
7460 /* Make sure that L3 Information IE is present */
7461 if (not f_rsl_find_ie(rsl_msg, RSL_IE_L3_INFO, ie)) {
7462 setverdict(fail, "RSL L3 Information IE is absent");
7463 return;
7464 }
7465
7466 /* Decode the L3 message and make sure it is (RR) Handover Command */
7467 var GsmRrL3Message l3_msg := dec_GsmRrL3Message(ie.l3_info.payload);
7468 if (not match(l3_msg.header, t_RrL3Header(HANDOVER_COMMAND))) {
7469 setverdict(fail, "Failed to match Handover Command: ", l3_msg);
7470 return;
7471 }
7472
7473 /* Make sure that we've got SDCCH/8 on TS1 (expected to be hopping) */
7474 var ChannelDescription chan_desc := l3_msg.payload.ho_cmd.chan_desc;
7475 if (not match(chan_desc.chan_nr, t_RslChanNr_SDCCH8(1, ?))) {
7476 setverdict(fail, "Unexpected channel number: ", chan_desc.chan_nr);
7477 return;
7478 }
7479
7480 /* Make sure that hopping parameters (HSN/MAIO) match */
7481 f_TC_fh_params_match_chan_desc(fhp, chan_desc);
7482
7483 /* Make sure that Cell Channel Description IE is present */
7484 if (not ispresent(l3_msg.payload.ho_cmd.cell_chan_desc)) {
7485 setverdict(fail, "FH enabled, but Cell Channel Description IE is absent");
7486 return;
7487 }
7488
7489 /* Make sure that the Mobile Allocation (after time) IE is present and matches */
7490 var boolean ma_present := ispresent(l3_msg.payload.ho_cmd.mobile_allocation);
7491 if (ma_present) {
7492 f_TC_fh_params_match_ma(fhp, chan_desc.chan_nr.tn,
7493 l3_msg.payload.ho_cmd.mobile_allocation.v);
7494 } else {
7495 setverdict(fail, "FH enabled, but Mobile Allocation IE is absent");
7496 return;
7497 }
7498}
7499testcase TC_fh_params_handover_cmd() runs on test_CT {
7500 var FHParamsTrx fhp := f_TC_fh_params_gen();
7501
7502 f_init_vty();
7503
7504 /* (Re)configure TS0 as BCCH and TS1 as SDCCH8 on BTS1/TRX0 */
7505 f_vty_enter_cfg_trx(BSCVTY, bts := 1, trx := 0);
7506
7507 f_vty_transceive(BSCVTY, "timeslot 0");
7508 f_vty_transceive(BSCVTY, "phys_chan_config ccch");
7509 f_vty_transceive(BSCVTY, "exit"); /* go back */
7510
7511 f_vty_transceive(BSCVTY, "timeslot 1");
7512 f_vty_transceive(BSCVTY, "phys_chan_config sdcch8");
7513 f_vty_transceive(BSCVTY, "end"); /* we're done */
7514
7515 f_TC_fh_params_set(fhp, 1); /* Enable frequency hopping on BTS1 */
7516 f_vty_transceive(BSCVTY, "drop bts connection 1 oml");
7517
7518 f_init(2);
7519
7520 f_TC_fh_params_handover_cmd(fhp);
7521
7522 /* Disable frequency hopping on BTS1 */
7523 f_TC_fh_params_unset(fhp, 1);
7524
7525 /* (Re)configure TS0 as CCCH+SDCCH4+CBCH and TS1 as TCH/F */
7526 f_vty_enter_cfg_trx(BSCVTY, bts := 1, trx := 0);
7527
7528 f_vty_transceive(BSCVTY, "timeslot 0");
7529 f_vty_transceive(BSCVTY, "phys_chan_config ccch+sdcch4+cbch");
7530 f_vty_transceive(BSCVTY, "exit"); /* go back */
7531
7532 f_vty_transceive(BSCVTY, "timeslot 1");
7533 f_vty_transceive(BSCVTY, "phys_chan_config tch/f");
7534 f_vty_transceive(BSCVTY, "end"); /* we're done */
7535
7536 f_shutdown_helper();
7537}
7538
Vadim Yanitskiyca974032020-09-01 07:20:39 +07007539/* Verify the hopping parameters in System Information Type 4 */
7540testcase TC_fh_params_si4_cbch() runs on test_CT {
7541 var FHParamsTrx fhp := f_TC_fh_params_gen(tr_tn := 1);
7542 var ASP_RSL_Unitdata rx_rsl_ud;
7543 timer T := 5.0;
7544
7545 f_init_vty();
7546
7547 /* (Re)configure TS0 as BCCH and TS1 as SDCCH8+CBCH */
7548 f_vty_enter_cfg_trx(BSCVTY, trx := 0);
7549
7550 f_vty_transceive(BSCVTY, "timeslot 0");
7551 f_vty_transceive(BSCVTY, "phys_chan_config ccch");
7552 f_vty_transceive(BSCVTY, "exit"); /* go back */
7553
7554 f_vty_transceive(BSCVTY, "timeslot 1");
7555 f_vty_transceive(BSCVTY, "phys_chan_config sdcch8+cbch");
7556 f_vty_transceive(BSCVTY, "end"); /* we're done */
7557
7558 f_TC_fh_params_set(fhp); /* Enable frequency hopping */
7559 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
7560
7561 f_init(1);
7562
7563 T.start;
7564 alt {
7565 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_BCCH_INFO(RSL_SYSTEM_INFO_4))) -> value rx_rsl_ud {
7566 var RSL_IE_Body ie := rx_rsl_ud.rsl.ies[2].body; /* FULL BCCH Information IE */
7567 var SystemInformation si := dec_SystemInformation(ie.other.payload);
7568
7569 /* Make sure that what we decoded is System Information Type 4 */
7570 if (si.header.message_type != SYSTEM_INFORMATION_TYPE_4) {
7571 setverdict(fail, "RSL FULL BCCH Information IE contains: ", si);
7572 repeat;
7573 }
7574
7575 /* Make sure that CBCH Channel Description IE is present */
7576 if (not ispresent(si.payload.si4.cbch_chan_desc)) {
7577 setverdict(fail, "CBCH Channel Description IE is absent");
7578 break;
7579 }
7580
7581 /* Finally, check the hopping parameters (HSN, MAIO) */
7582 var ChannelDescription chan_desc := si.payload.si4.cbch_chan_desc.v;
7583 f_TC_fh_params_match_chan_desc(fhp, chan_desc);
7584
7585 /* 3GPP TS 44.018, section 9.1.36.2 "CBCH Mobile Allocation":
7586 * The CBCH Mobile Allocation IE *shall* be present if FH is enabled. */
7587 if (chan_desc.h and not ispresent(si.payload.si4.cbch_mobile_alloc)) {
7588 setverdict(fail, "FH enabled, but Mobile Allocation IE is absent");
7589 break;
7590 } else if (chan_desc.h and ispresent(si.payload.si4.cbch_mobile_alloc)) {
7591 f_TC_fh_params_match_ma(fhp, chan_desc.chan_nr.tn,
7592 si.payload.si4.cbch_mobile_alloc.v);
7593 }
7594 }
7595 [] IPA_RSL[0].receive { repeat; }
7596 [] T.timeout {
7597 setverdict(fail, "Timeout waiting for RSL BCCH INFOrmation (SI4)");
7598 }
7599 }
7600
7601 /* Disable frequency hopping */
7602 f_TC_fh_params_unset(fhp);
7603
Vadim Yanitskiy8bc46012020-09-06 12:38:01 +07007604 /* (Re)configure TS0 as CCCH+SDCCH4+CBCH and TS1 as TCH/F */
Vadim Yanitskiyca974032020-09-01 07:20:39 +07007605 f_vty_enter_cfg_trx(BSCVTY, trx := 0);
7606
7607 f_vty_transceive(BSCVTY, "timeslot 0");
Vadim Yanitskiy8bc46012020-09-06 12:38:01 +07007608 f_vty_transceive(BSCVTY, "phys_chan_config ccch+sdcch4+cbch");
Vadim Yanitskiyca974032020-09-01 07:20:39 +07007609 f_vty_transceive(BSCVTY, "exit"); /* go back */
7610
7611 f_vty_transceive(BSCVTY, "timeslot 1");
7612 f_vty_transceive(BSCVTY, "phys_chan_config tch/f");
7613 f_vty_transceive(BSCVTY, "end"); /* we're done */
7614
Vadim Yanitskiy21726312020-09-04 01:45:36 +07007615 f_shutdown_helper();
Vadim Yanitskiyca974032020-09-01 07:20:39 +07007616}
7617
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02007618template (value) PDU_BSSAP_LE ts_BSSMAP_LE_BSSLAP(template (value) BSSLAP_PDU bsslap)
7619 := ts_BSSMAP_LE_ConnInfo(BSSMAP_LE_PROT_BSSLAP, data := enc_BSSLAP_PDU(valueof(bsslap)));
7620
7621private function f_match_bsslap(PDU_BSSAP_LE got_bsslap_msg,
7622 template (present) BSSLAP_PDU expect_bsslap)
7623{
7624 var BSSLAP_PDU bsslap := dec_BSSLAP_PDU(got_bsslap_msg.pdu.bssmap.co_info.bsslap_apdu.data);
7625 if (not match(bsslap, expect_bsslap)) {
7626 log("EXPECTING BSSLAP: ", expect_bsslap);
7627 log("GOT BSSLAP: ", bsslap);
7628 setverdict(fail, "BSSLAP is not as expected");
7629 mtc.stop;
7630 }
7631 setverdict(pass);
7632}
7633
7634/* GAD: this is an Ellipsoid point with uncertainty circle, encoded as in 3GPP TS 23.032 §7.3.2. */
7635const octetstring gad_ell_point_unc_circle := '10b0646d0d5f6627'O;
7636
7637private function f_expect_bsslap(template (present) BSSLAP_PDU expect_rx_bsslap) runs on MSC_ConnHdlr {
7638 var PDU_BSSAP_LE rx_bsslap;
7639 BSSAP_LE.receive(tr_BSSMAP_LE_ConnInfo(BSSMAP_LE_PROT_BSSLAP, ?)) -> value(rx_bsslap);
7640 f_match_bsslap(rx_bsslap, expect_rx_bsslap);
7641}
7642
7643/* With an active lchan, start BSSMAP Perform Location Request on A interface, starting BSSMAP-LE Perform Location
7644 * Request on Lb interface. Either with or without the SMLC doing a BSSLAP TA Request. */
7645private function f_lcs_loc_req_for_active_ms(boolean do_ta_request := false) runs on MSC_ConnHdlr {
7646 f_sleep(1.0);
7647
7648 f_establish_fully(omit, omit);
7649 f_bssap_le_register_imsi(g_pars.imsi, omit);
7650
7651 BSSAP.send(valueof(ts_BSSMAP_Perform_Location_Request(ts_BSSMAP_Imsi(g_pars.imsi),
7652 ts_CellId_CGI('262'H, '42'H, 23, 42))));
7653
7654 var PDU_BSSAP_LE plr;
7655 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocReq(BSSMAP_LE_LOC_INFO_CURRENT_GEOGRAPHIC_LOC, ?, ?)) -> value(plr);
7656
7657 if (not do_ta_request) {
7658 /* verify TA Layer 3 in APDU. First the APDU type (BSSLAP), then the BSSLAP data contents. */
7659 var template BSSMAP_LE_IE_APDU expect_apdu := tr_BSSMAP_LE_APDU(BSSMAP_LE_PROT_BSSLAP, ?);
7660 if (not match(plr.pdu.bssmap.perf_loc_req.bsslap_apdu, expect_apdu)) {
7661 log("EXPECTING BSSMAP-LE APDU IE ", expect_apdu);
7662 log("GOT BSSMAP-LE APDU IE ", plr.pdu.bssmap.perf_loc_req.bsslap_apdu);
7663 setverdict(fail, "BSSMAP-LE APDU IE is not as expected");
7664 mtc.stop;
7665 }
7666 var template BSSLAP_PDU expect_ta_layer3 := tr_BSSLAP_TA_Layer3(tr_BSSLAP_IE_TA(0));
7667 var BSSLAP_PDU bsslap := dec_BSSLAP_PDU(plr.pdu.bssmap.perf_loc_req.bsslap_apdu.data);
7668 if (not match(bsslap, expect_ta_layer3)) {
7669 log("EXPECTING BSSLAP TA Layer 3: ", expect_ta_layer3);
7670 log("GOT BSSLAP: ", bsslap);
7671 setverdict(fail, "BSSLAP is not as expected");
7672 mtc.stop;
7673 }
7674 /* OsmoBSC directly sent the TA as BSSLAP APDU in the BSSMAP-LE Perform Location Request to the SMLC. The SMLC
7675 * has no need to request the TA from the BSC and directly responds. */
7676 } else {
7677 /* SMLC wants to ask the TA from the BSC explicitly in a BSSLAP TA Request message */
7678 BSSAP_LE.send(ts_BSSMAP_LE_BSSLAP(ts_BSSLAP_TA_Req));
7679 f_expect_bsslap(tr_BSSLAP_TA_Resp(?, ?));
7680 }
7681
7682 /* SMLC got the TA from the BSC, now responds with geo information data. */
7683 BSSAP_LE.send(ts_BSSMAP_LE_PerfLocResp(gad_ell_point_unc_circle, omit));
7684 BSSAP_LE.receive(BSSAP_LE_Conn_Prim:CONN_PRIM_DISC_IND);
7685 BSSAP.receive(tr_BSSMAP_Perform_Location_Response(tr_BSSMAP_IE_LocationEstimate(gad_ell_point_unc_circle)));
7686
7687 /* The LCS was using an active A-interface conn. It should still remain active after this. */
7688 f_mo_l3_transceive();
7689
7690 f_perform_clear(RSL);
7691
7692 f_sleep(2.0);
7693 setverdict(pass);
7694}
7695
7696/* With an active lchan, start BSSMAP Perform Location Request on A interface, starting BSSMAP-LE Perform Location
7697 * Request on Lb interface. Without the SMLC doing a BSSLAP TA Request. */
7698private function f_tc_lcs_loc_req_for_active_ms(charstring id) runs on MSC_ConnHdlr {
7699 f_lcs_loc_req_for_active_ms(false);
7700}
7701testcase TC_lcs_loc_req_for_active_ms() runs on test_CT {
7702 var MSC_ConnHdlr vc_conn;
7703 var TestHdlrParams pars := f_gen_test_hdlr_pars();
7704
7705 f_init(1, true);
7706 f_sleep(1.0);
7707 vc_conn := f_start_handler(refers(f_tc_lcs_loc_req_for_active_ms), pars);
7708 vc_conn.done;
7709}
7710
7711/* With an active lchan, start BSSMAP Perform Location Request on A interface, starting BSSMAP-LE Perform Location
7712 * Request on Lb interface. With the SMLC doing a BSSLAP TA Request. */
7713private function f_tc_lcs_loc_req_for_active_ms_ta_req(charstring id) runs on MSC_ConnHdlr {
7714 f_lcs_loc_req_for_active_ms(true);
7715}
7716testcase TC_lcs_loc_req_for_active_ms_ta_req() runs on test_CT {
7717 var MSC_ConnHdlr vc_conn;
7718 var TestHdlrParams pars := f_gen_test_hdlr_pars();
7719
7720 f_init(1, true);
7721 f_sleep(1.0);
7722 vc_conn := f_start_handler(refers(f_tc_lcs_loc_req_for_active_ms_ta_req), pars);
7723 vc_conn.done;
7724}
7725
7726/* Clear the A-interface conn only, without doing anything on Abis. Useful for LCS, for cases where there is only an A
7727 * conn without an active lchan. */
7728private function f_clear_A_conn() runs on MSC_ConnHdlr
7729{
7730 var BssmapCause cause := 0;
7731 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
7732 BSSAP.receive(tr_BSSMAP_ClearComplete);
7733 BSSAP.send(RAN_Conn_Prim:MSC_CONN_PRIM_DISC_REQ);
7734
7735 timer no_more_bssap := 5.0;
7736 no_more_bssap.start;
7737 alt {
7738 [] no_more_bssap.timeout { break; }
7739 [] BSSAP.receive(tr_BSSAP_BSSMAP) {
7740 setverdict(fail, "Expected no more BSSAP after Clear Complete");
7741 mtc.stop;
7742 }
7743 }
7744 setverdict(pass);
7745}
7746
7747/* Verify that the A-interface connection is still working, and then clear it, without doing anything on Abis. Useful
7748 * for LCS, for cases where there is only an A conn without an active lchan. */
7749private function f_verify_active_A_conn_and_clear() runs on MSC_ConnHdlr
7750{
7751 f_logp(BSCVTY, "f_verify_active_A_conn_and_clear: test A link, then clear");
7752
7753 /* When an lchan is active, we can send some L3 data from the BTS side and verify that it shows up on the other
7754 * side towards the MSC. When there is no lchan, this is not possible. To probe whether the A-interface
7755 * connection is still up, we need something that echos back on the A-interface. Another LCS request! */
7756 BSSAP.send(valueof(ts_BSSMAP_Perform_Location_Request(ts_BSSMAP_Imsi(g_pars.imsi),
7757 ts_CellId_CGI('262'H, '42'H, 23, 42))));
7758 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocReq(BSSMAP_LE_LOC_INFO_CURRENT_GEOGRAPHIC_LOC, ?, ?));
7759
7760 /* Right, the Perform Location Request showed up on Lb, now we can clear the A conn. */
7761 f_clear_A_conn();
7762 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocAbort(BSSMAP_LE_LCS_CAUSE_REQUEST_ABORTED));
7763 BSSAP_LE.receive(BSSAP_LE_Conn_Prim:CONN_PRIM_DISC_IND);
7764}
7765
7766/* With *no* active lchan, start BSSMAP Perform Location Request on A interface, starting BSSMAP-LE Perform Location
7767 * Request on Lb interface. BSC will Page for the subscriber as soon as we (virtual SMLC) request the TA via BSSLAP.
7768 */
7769private function f_tc_lcs_loc_req_for_idle_ms(charstring id) runs on MSC_ConnHdlr {
7770 f_sleep(1.0);
7771
7772 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
7773 f_bssap_le_register_imsi(g_pars.imsi, omit);
7774
7775 /* Register to receive the Paging Command */
7776 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
7777 g_chan_nr := new_chan_nr;
7778 f_rslem_register(0, g_chan_nr);
7779
7780 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
7781 valueof(ts_BSSMAP_Perform_Location_Request(ts_BSSMAP_Imsi(g_pars.imsi),
7782 ts_CellId_CGI('001'H, '01'H, 1, 0)))));
7783 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
7784
7785 var PDU_BSSAP_LE plr;
7786 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocReq(BSSMAP_LE_LOC_INFO_CURRENT_GEOGRAPHIC_LOC, ?, ?)) -> value(plr);
7787
7788 /* SMLC wants to ask the TA from the BSC explicitly in a BSSLAP TA Request message */
7789 BSSAP_LE.send(ts_BSSMAP_LE_BSSLAP(ts_BSSLAP_TA_Req));
7790
7791 /* OsmoBSC needs to Page */
7792 RSL.receive(tr_RSL_PAGING_CMD(tr_MI_IMSI(g_pars.imsi)));
7793 f_logp(BSCVTY, "got Paging Command");
7794
7795 /* MS requests channel. Since the Paging was for LCS, the Paging Response does not trigger a Complete Layer 3 to
7796 * the MSC, and releases the lchan directly. */
7797 f_perform_compl_l3(RSL, ts_PAG_RESP(valueof(ts_MI_IMSI_LV(g_pars.imsi))), do_clear := false, expect_bssmap_l3 := false);
7798 f_expect_lchan_rel(RSL);
7799
7800 /* From the Paging Response, the TA is now known to the BSC, and it responds to the SMLC. */
7801
7802 f_expect_bsslap(tr_BSSLAP_TA_Resp(?, ?));
7803
7804 /* SMLC got the TA from the BSC, now responds with geo information data. */
7805 BSSAP_LE.send(ts_BSSMAP_LE_PerfLocResp(gad_ell_point_unc_circle, omit));
7806 BSSAP_LE.receive(BSSAP_LE_Conn_Prim:CONN_PRIM_DISC_IND);
7807
7808 BSSAP.receive(tr_BSSMAP_Perform_Location_Response(tr_BSSMAP_IE_LocationEstimate(gad_ell_point_unc_circle)));
7809
7810 /* The lchan is gone, the A-interface conn was created for the LCS only.
7811 * Still it is clearly the MSC's job to decide whether to tear down the conn or not. */
7812 f_verify_active_A_conn_and_clear();
7813
7814 f_sleep(2.0);
7815 setverdict(pass);
7816}
7817testcase TC_lcs_loc_req_for_idle_ms() runs on test_CT {
7818 var MSC_ConnHdlr vc_conn;
7819 var TestHdlrParams pars := f_gen_test_hdlr_pars();
7820
7821 f_init(1, true);
7822 f_sleep(1.0);
7823
7824 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
7825 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
7826
7827 vc_conn := f_start_handler(refers(f_tc_lcs_loc_req_for_idle_ms), pars);
7828 vc_conn.done;
7829}
7830
7831/* With no active lchan, start BSSMAP Perform Location Request on A interface, but omit IMSI; expect failure response.
7832 */
7833private function f_tc_lcs_loc_req_no_subscriber(charstring id) runs on MSC_ConnHdlr {
7834 f_sleep(1.0);
7835
7836 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
7837 f_bssap_le_register_imsi(g_pars.imsi, omit);
7838
7839 /* provoke an abort by omitting both IMSI and IMEI */
7840 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
7841 valueof(ts_BSSMAP_Perform_Location_Request(omit,
7842 ts_CellId_CGI('262'H, '42'H, 23, 42)))));
7843 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
7844
7845 /* BSC tells MSC about failure */
7846 BSSAP.receive(tr_BSSMAP_Perform_Location_Response(
7847 locationEstimate := omit, positioningData := omit,
7848 lCS_Cause := tr_BSSMAP_LcsCause(BSSMAP_LCS_CAUSE_DATA_MISSING_IN_REQ)));
7849
7850 /* There is no lchan. Still the MSC's job to decide whether to tear down the conn or not. */
7851 f_verify_active_A_conn_and_clear();
7852
7853 f_sleep(2.0);
7854 setverdict(pass);
7855}
7856testcase TC_lcs_loc_req_no_subscriber() runs on test_CT {
7857 var MSC_ConnHdlr vc_conn;
7858 var TestHdlrParams pars := f_gen_test_hdlr_pars();
7859
7860 f_init(1, true);
7861 f_sleep(1.0);
7862
7863 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
7864 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
7865
7866 vc_conn := f_start_handler(refers(f_tc_lcs_loc_req_no_subscriber), pars);
7867 vc_conn.done;
7868}
7869
7870/* With an active lchan, start a Perform Location Request on the A-interface, but virtual SMLC does not answer with
7871 * BSSMAP-LE Perform Location Response (before or after sending a BSSLAP TA Request) */
7872private function f_lcs_loc_req_for_active_ms_le_timeout(boolean do_ta) runs on MSC_ConnHdlr {
7873 f_sleep(1.0);
7874
7875 f_establish_fully(omit, omit);
7876 f_bssap_le_register_imsi(g_pars.imsi, omit);
7877
7878 BSSAP.send(valueof(ts_BSSMAP_Perform_Location_Request(ts_BSSMAP_Imsi(g_pars.imsi),
7879 ts_CellId_CGI('262'H, '42'H, 23, 42))));
7880
7881 var PDU_BSSAP_LE plr;
7882 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocReq(BSSMAP_LE_LOC_INFO_CURRENT_GEOGRAPHIC_LOC, ?, ?)) -> value(plr);
7883
7884 if (do_ta) {
7885 /* SMLC wants to ask the TA from the BSC explicitly in a BSSLAP TA Request message */
7886 BSSAP_LE.send(ts_BSSMAP_LE_BSSLAP(ts_BSSLAP_TA_Req));
7887 f_expect_bsslap(tr_BSSLAP_TA_Resp(?, ?));
7888 }
7889
7890 /* SMLC fails to respond, BSC runs into timeout */
7891 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocAbort(BSSMAP_LE_LCS_CAUSE_SYSTEM_FAILURE));
7892 BSSAP_LE.receive(BSSAP_LE_Conn_Prim:CONN_PRIM_DISC_IND);
7893
7894 BSSAP.receive(tr_BSSMAP_Perform_Location_Response(
7895 locationEstimate := omit, positioningData := omit,
7896 lCS_Cause := tr_BSSMAP_LcsCause(BSSMAP_LCS_CAUSE_SYSTEM_FAILURE)));
7897
7898 /* There is no lchan. Still the MSC's job to decide whether to tear down the conn or not. */
7899 f_verify_active_A_conn_and_clear();
7900
7901 f_sleep(2.0);
7902 setverdict(pass);
7903}
7904
7905/* With an active lchan, start a Perform Location Request on the A-interface, but virtual SMLC does not answer with
7906 * BSSMAP-LE Perform Location Response, without sending a BSSLAP TA Request. */
7907private function f_tc_lcs_loc_req_for_active_ms_le_timeout(charstring id) runs on MSC_ConnHdlr {
7908 f_lcs_loc_req_for_active_ms_le_timeout(false);
7909}
7910
7911testcase TC_lcs_loc_req_for_active_ms_le_timeout() runs on test_CT {
7912 var MSC_ConnHdlr vc_conn;
7913 var TestHdlrParams pars := f_gen_test_hdlr_pars();
7914
7915 f_init(1, true);
7916 f_sleep(1.0);
7917 vc_conn := f_start_handler(refers(f_tc_lcs_loc_req_for_active_ms_le_timeout), pars);
7918 vc_conn.done;
7919}
7920
7921/* With an active lchan, start a Perform Location Request on the A-interface, but virtual SMLC does not answer with
7922 * BSSMAP-LE Perform Location Response, after sending a BSSLAP TA Request. */
7923private function f_tc_lcs_loc_req_for_active_ms_le_timeout2(charstring id) runs on MSC_ConnHdlr {
7924 f_lcs_loc_req_for_active_ms_le_timeout(true);
7925}
7926
7927testcase TC_lcs_loc_req_for_active_ms_le_timeout2() runs on test_CT {
7928 var MSC_ConnHdlr vc_conn;
7929 var TestHdlrParams pars := f_gen_test_hdlr_pars();
7930
7931 f_init(1, true);
7932 f_sleep(1.0);
7933 vc_conn := f_start_handler(refers(f_tc_lcs_loc_req_for_active_ms_le_timeout2), pars);
7934 vc_conn.done;
7935}
7936
7937/* With *no* active lchan, start a Perform Location Request, expecting that the MS will be Paged. */
7938private function f_tc_lcs_loc_req_for_idle_ms_no_pag_resp(charstring id) runs on MSC_ConnHdlr {
7939 f_sleep(1.0);
7940
7941 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
7942 f_bssap_le_register_imsi(g_pars.imsi, omit);
7943
7944 /* Register to receive the Paging Command */
7945 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
7946 g_chan_nr := new_chan_nr;
7947 f_rslem_register(0, g_chan_nr);
7948
7949 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
7950 valueof(ts_BSSMAP_Perform_Location_Request(ts_BSSMAP_Imsi(g_pars.imsi),
7951 ts_CellId_CGI('001'H, '01'H, 1, 0)))));
7952 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
7953
7954 var PDU_BSSAP_LE plr;
7955 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocReq(BSSMAP_LE_LOC_INFO_CURRENT_GEOGRAPHIC_LOC, ?, ?)) -> value(plr);
7956
7957 /* SMLC wants to ask the TA from the BSC explicitly in a BSSLAP TA Request message */
7958 BSSAP_LE.send(ts_BSSMAP_LE_BSSLAP(ts_BSSLAP_TA_Req));
7959
7960 /* OsmoBSC needs to Page */
7961 var PDU_BSSAP_LE rx_bsslap;
7962 alt {
7963 [] RSL.receive(tr_RSL_PAGING_CMD(tr_MI_IMSI(g_pars.imsi))) {
7964 f_logp(BSCVTY, "got Paging Command");
7965 repeat;
7966 }
7967 [] BSSAP_LE.receive(tr_BSSMAP_LE_ConnInfo(BSSMAP_LE_PROT_BSSLAP, ?)) -> value(rx_bsslap) {
7968 /* MS does not respond to Paging, TA Req runs into timeout. */
7969 f_match_bsslap(rx_bsslap, tr_BSSLAP_Abort(?));
7970 }
7971 }
7972
7973 /* SMLC responds with failure */
7974 BSSAP_LE.send(ts_BSSMAP_LE_PerfLocResp(omit, BSSMAP_LE_LCS_CAUSE_REQUEST_ABORTED));
7975 BSSAP_LE.receive(BSSAP_LE_Conn_Prim:CONN_PRIM_DISC_IND);
7976
7977 /* BSC tells MSC about failure */
7978 BSSAP.receive(tr_BSSMAP_Perform_Location_Response(
7979 locationEstimate := omit, positioningData := omit,
7980 lCS_Cause := tr_BSSMAP_LcsCause(BSSMAP_LCS_CAUSE_REQUEST_ABORTED)));
7981
7982 /* There is no lchan. Still the MSC's job to decide whether to tear down the conn or not. */
7983 f_verify_active_A_conn_and_clear();
7984
7985 f_sleep(2.0);
7986 setverdict(pass);
7987}
7988testcase TC_lcs_loc_req_for_idle_ms_no_pag_resp() runs on test_CT {
7989 var MSC_ConnHdlr vc_conn;
7990 var TestHdlrParams pars := f_gen_test_hdlr_pars();
7991
7992 f_init(1, true);
7993 f_sleep(1.0);
7994
7995 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
7996 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
7997
7998 vc_conn := f_start_handler(refers(f_tc_lcs_loc_req_for_idle_ms_no_pag_resp), pars);
7999 vc_conn.done;
8000}
8001
8002/* During an ongoing Location Request, the MS sends a CM Service Request. Expect the same A-conn to be re-used / taken
8003 * over. */
8004private function f_tc_cm_service_during_lcs_loc_req(charstring id) runs on MSC_ConnHdlr {
8005 f_sleep(1.0);
8006
8007 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
8008 f_bssap_le_register_imsi(g_pars.imsi, omit);
8009
8010 /* Register to receive the Paging Command */
8011 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
8012 g_chan_nr := new_chan_nr;
8013 f_rslem_register(0, g_chan_nr);
8014
8015 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
8016 valueof(ts_BSSMAP_Perform_Location_Request(ts_BSSMAP_Imsi(g_pars.imsi),
8017 ts_CellId_CGI('001'H, '01'H, 1, 0)))));
8018 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
8019
8020 var PDU_BSSAP_LE plr;
8021 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocReq(BSSMAP_LE_LOC_INFO_CURRENT_GEOGRAPHIC_LOC, ?, ?)) -> value(plr);
8022
8023 /* As the A-interface conn was established for LCS, the MS coincidentally decides to issue a CM Service Request
8024 * and establish Layer 3. It should use the existing A-interface conn. */
8025 f_perform_compl_l3(RSL, valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, valueof(ts_MI_IMSI_LV(g_pars.imsi)))),
8026 do_clear := false, expect_bssmap_l3 := true);
8027
8028 /* SMLC wants to ask the TA from the BSC explicitly in a BSSLAP TA Request message */
8029 BSSAP_LE.send(ts_BSSMAP_LE_BSSLAP(ts_BSSLAP_TA_Req));
8030
8031 /* OsmoBSC already has an lchan, no need to Page, just returns the TA */
8032 f_expect_bsslap(tr_BSSLAP_TA_Resp(?, ?));
8033
8034 /* SMLC got the TA from the BSC, now responds with geo information data. */
8035 BSSAP_LE.send(ts_BSSMAP_LE_PerfLocResp(gad_ell_point_unc_circle, omit));
8036 BSSAP_LE.receive(BSSAP_LE_Conn_Prim:CONN_PRIM_DISC_IND);
8037 BSSAP.receive(tr_BSSMAP_Perform_Location_Response(tr_BSSMAP_IE_LocationEstimate(gad_ell_point_unc_circle)));
8038
8039 /* The lchan should still exist, it was from a CM Service Request. */
8040 f_mo_l3_transceive();
8041
8042 f_perform_clear(RSL);
8043
8044 f_sleep(2.0);
8045 setverdict(pass);
8046}
8047testcase TC_cm_service_during_lcs_loc_req() runs on test_CT {
8048 var MSC_ConnHdlr vc_conn;
8049 var TestHdlrParams pars := f_gen_test_hdlr_pars();
8050
8051 f_init(1, true);
8052 f_sleep(1.0);
8053
8054 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
8055 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
8056
8057 vc_conn := f_start_handler(refers(f_tc_cm_service_during_lcs_loc_req), pars);
8058 vc_conn.done;
8059}
8060
8061/* During an ongoing Perform Location Request, do a Handover, an expect a BSSLAP Reset message from the BSC to indicate
8062 * the new lchan after handover. */
8063private function f_tc_ho_during_lcs_loc_req(charstring id) runs on MSC_ConnHdlr {
8064 f_sleep(1.0);
8065
8066 f_establish_fully(omit, omit);
8067 f_bssap_le_register_imsi(g_pars.imsi, omit);
8068
8069 BSSAP.send(valueof(ts_BSSMAP_Perform_Location_Request(ts_BSSMAP_Imsi(g_pars.imsi),
8070 ts_CellId_CGI('262'H, '42'H, 23, 42))));
8071
8072 var PDU_BSSAP_LE plr;
8073 BSSAP_LE.receive(tr_BSSMAP_LE_PerfLocReq(BSSMAP_LE_LOC_INFO_CURRENT_GEOGRAPHIC_LOC, ?, ?)) -> value(plr);
8074
8075 /* SMLC ponders the Location Request, in the meantime the BSC decides to handover */
8076 f_bts_0_cfg(BSCVTY, {"neighbor bts 1"});
8077
8078 var HandoverState hs := {
8079 rr_ho_cmpl_seen := false,
8080 handover_done := false,
8081 old_chan_nr := -
8082 };
8083 /* issue hand-over command on VTY */
8084 f_vty_handover(BSCVTY, 0, 0, g_chan_nr, 1);
8085 /* temporarily suspend DChan processing on BTS1 to avoid race with RSLEM_register */
8086 f_rslem_suspend(RSL1_PROC);
8087
8088 /* From the MGW perspective, a handover is is characterized by
8089 * performing one MDCX operation with the MGW. So we expect to see
8090 * one more MDCX during handover. */
8091 g_media.mgcp_conn[0].mdcx_seen_exp := g_media.mgcp_conn[0].crcx_seen_exp + 1;
8092
8093 alt {
8094 [] as_handover(hs);
8095 }
8096
8097 var PDU_BSSAP_LE rx_bsslap;
8098
8099 interleave {
8100 /* Expect the BSC to inform the MSC about the handover */
8101 [] BSSAP.receive(tr_BSSMAP_HandoverPerformed);
8102
8103 /* Expect the BSC to inform the SMLC about the handover */
8104 [] BSSAP_LE.receive(tr_BSSMAP_LE_ConnInfo(BSSMAP_LE_PROT_BSSLAP, ?)) -> value(rx_bsslap) {
8105 f_match_bsslap(rx_bsslap, tr_BSSLAP_Reset(BSSLAP_CAUSE_INTRA_BSS_HO));
8106 }
8107 }
8108
8109 /* SMLC now responds with geo information data. */
8110 BSSAP_LE.send(ts_BSSMAP_LE_PerfLocResp(gad_ell_point_unc_circle, omit));
8111 BSSAP_LE.receive(BSSAP_LE_Conn_Prim:CONN_PRIM_DISC_IND);
8112 BSSAP.receive(tr_BSSMAP_Perform_Location_Response(tr_BSSMAP_IE_LocationEstimate(gad_ell_point_unc_circle)));
8113
8114 /* lchan still active */
8115 f_mo_l3_transceive(RSL1);
8116
8117 /* MSC decides it is done now. */
8118 f_perform_clear(RSL1);
8119
8120 f_sleep(2.0);
8121 setverdict(pass);
8122}
8123testcase TC_ho_during_lcs_loc_req() runs on test_CT {
8124 var MSC_ConnHdlr vc_conn;
8125 var TestHdlrParams pars := f_gen_test_hdlr_pars();
8126
8127 f_init(2, true);
8128 f_sleep(1.0);
8129 vc_conn := f_start_handler(refers(f_tc_ho_during_lcs_loc_req), pars);
8130 vc_conn.done;
8131}
8132
Harald Welte0ea2d5e2018-04-07 21:40:29 +02008133/* Dyn PDCH todo:
8134 * activate OSMO as TCH/F
8135 * activate OSMO as TCH/H
8136 * does the BSC-located PCU socket get the updated INFO?
8137 * what if no PCU is connected at the time?
8138 * is the info correct on delayed PCU (re)connect?
8139 */
Harald Welte94e0c342018-04-07 11:33:23 +02008140
Harald Welte28d943e2017-11-25 15:00:50 +01008141control {
Harald Welte898113b2018-01-31 18:32:21 +01008142 /* CTRL interface testing */
Harald Welte4003d112017-12-09 22:35:39 +01008143 execute( TC_ctrl_msc_connection_status() );
Stefan Sperlingb041b3d2018-01-03 17:14:55 +01008144 execute( TC_ctrl_msc0_connection_status() );
Harald Welte96c94412017-12-09 03:12:45 +01008145 execute( TC_ctrl() );
Neels Hofmeyrf246a922020-05-13 02:27:10 +02008146 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_SCCPlite_SERVER) {
Pau Espin Pedrol5a2d7432019-06-07 19:43:45 +02008147 execute( TC_ctrl_location() );
8148 }
Harald Welte898113b2018-01-31 18:32:21 +01008149
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +02008150 execute( TC_si_default() );
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02008151 execute( TC_si2quater_2_earfcns() );
8152 execute( TC_si2quater_3_earfcns() );
8153 execute( TC_si2quater_4_earfcns() );
8154 execute( TC_si2quater_5_earfcns() );
8155 execute( TC_si2quater_6_earfcns() );
Neels Hofmeyrad132f22020-07-08 02:20:16 +02008156 execute( TC_si2quater_12_earfcns() );
8157 execute( TC_si2quater_23_earfcns() );
8158 execute( TC_si2quater_32_earfcns() );
8159 execute( TC_si2quater_33_earfcns() );
8160 execute( TC_si2quater_42_earfcns() );
8161 execute( TC_si2quater_48_earfcns() );
8162 execute( TC_si2quater_49_earfcns() );
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02008163 execute( TC_si_acc_rotate() );
Alexander Couzens4ad3a352020-09-10 22:29:12 +02008164 execute( TC_si_acc_ramp_rotate() );
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +02008165
Harald Welte898113b2018-01-31 18:32:21 +01008166 /* RSL DCHAN Channel ACtivation / Deactivation */
Harald Welteae026692017-12-09 01:03:01 +01008167 execute( TC_chan_act_noreply() );
Harald Welte4003d112017-12-09 22:35:39 +01008168 execute( TC_chan_act_counter() );
Harald Welteae026692017-12-09 01:03:01 +01008169 execute( TC_chan_act_ack_noest() );
Philipp Maier9c60a622020-07-09 15:08:46 +02008170 execute( TC_chan_act_ack_noest_emerg() );
Philipp Maier606f07d2020-08-12 17:21:58 +02008171 execute( TC_chan_rqd_emerg_deny() );
Harald Welteae026692017-12-09 01:03:01 +01008172 execute( TC_chan_act_ack_est_ind_noreply() );
8173 execute( TC_chan_act_ack_est_ind_refused() );
Harald Welte618ef642017-12-14 14:58:20 +01008174 execute( TC_chan_act_nack() );
Harald Welte799c97b2017-12-14 17:50:30 +01008175 execute( TC_chan_exhaustion() );
Vadim Yanitskiy1ff1fdf2018-11-27 01:32:57 +07008176 execute( TC_chan_deact_silence() );
Harald Welte4003d112017-12-09 22:35:39 +01008177 execute( TC_chan_rel_rll_rel_ind() );
8178 execute( TC_chan_rel_conn_fail() );
8179 execute( TC_chan_rel_hard_clear() );
Harald Welte99787102019-02-04 10:41:36 +01008180 execute( TC_chan_rel_hard_clear_csfb() );
Harald Welted8c36cd2017-12-09 23:05:31 +01008181 execute( TC_chan_rel_hard_rlsd() );
Harald Welte550daf92018-06-11 19:22:13 +02008182 execute( TC_chan_rel_hard_rlsd_ms_dead() );
Harald Welte85804d42017-12-10 14:11:58 +01008183 execute( TC_chan_rel_a_reset() );
Pau Espin Pedrolc675b612020-01-09 19:55:40 +01008184 execute( TC_chan_rel_sccp_tiar_timeout() );
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02008185 execute( TC_chan_rel_rr_cause() );
Harald Welte6f521d82017-12-11 19:52:02 +01008186
Harald Weltecfe2c962017-12-15 12:09:32 +01008187 execute( TC_outbound_connect() );
Harald Welte898113b2018-01-31 18:32:21 +01008188
8189 /* Assignment related */
Harald Welte16a4adf2017-12-14 18:54:01 +01008190 execute( TC_assignment_cic_only() );
Harald Welte235ebf12017-12-15 14:18:16 +01008191 execute( TC_assignment_csd() );
8192 execute( TC_assignment_ctm() );
8193 execute( TC_assignment_sign() );
Pau Espin Pedrol07866632020-09-03 19:10:55 +02008194 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
8195 execute( TC_assignment_aoip_tla_v6() );
8196 }
Harald Welte235ebf12017-12-15 14:18:16 +01008197 execute( TC_assignment_fr_a5_0() );
8198 execute( TC_assignment_fr_a5_1() );
Neels Hofmeyrf246a922020-05-13 02:27:10 +02008199 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
Harald Welte8f67d1d2018-05-25 20:38:42 +02008200 execute( TC_assignment_fr_a5_1_codec_missing() );
8201 }
Harald Welte235ebf12017-12-15 14:18:16 +01008202 execute( TC_assignment_fr_a5_3() );
8203 execute( TC_assignment_fr_a5_4() );
Harald Welte3c86ea02018-05-10 22:28:05 +02008204 execute( TC_ciph_mode_a5_0() );
8205 execute( TC_ciph_mode_a5_1() );
8206 execute( TC_ciph_mode_a5_3() );
Harald Welte16a4adf2017-12-14 18:54:01 +01008207
Harald Welte60aa5762018-03-21 19:33:13 +01008208 execute( TC_assignment_codec_fr() );
8209 execute( TC_assignment_codec_hr() );
8210 execute( TC_assignment_codec_efr() );
8211 execute( TC_assignment_codec_amr_f() );
8212 execute( TC_assignment_codec_amr_h() );
Philipp Maier8a581d22019-03-26 18:32:48 +01008213
Neels Hofmeyrf246a922020-05-13 02:27:10 +02008214 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
Philipp Maier8a581d22019-03-26 18:32:48 +01008215 execute( TC_assignment_codec_amr_f_S1() );
8216 execute( TC_assignment_codec_amr_h_S1() );
8217 execute( TC_assignment_codec_amr_f_S124() );
8218 execute( TC_assignment_codec_amr_h_S124() );
8219 execute( TC_assignment_codec_amr_f_S0() );
8220 execute( TC_assignment_codec_amr_f_S02() );
8221 execute( TC_assignment_codec_amr_f_S024() );
8222 execute( TC_assignment_codec_amr_f_S0247() );
8223 execute( TC_assignment_codec_amr_h_S0() );
8224 execute( TC_assignment_codec_amr_h_S02() );
8225 execute( TC_assignment_codec_amr_h_S024() );
8226 execute( TC_assignment_codec_amr_h_S0247() );
8227 execute( TC_assignment_codec_amr_f_S01234567() );
8228 execute( TC_assignment_codec_amr_f_S0234567() );
8229 execute( TC_assignment_codec_amr_f_zero() );
8230 execute( TC_assignment_codec_amr_f_unsupp() );
8231 execute( TC_assignment_codec_amr_h_S7() );
8232 }
Harald Welte60aa5762018-03-21 19:33:13 +01008233
Philipp Maierac09bfc2019-01-08 13:41:39 +01008234 execute( TC_assignment_codec_fr_exhausted_req_hr() );
8235 execute( TC_assignment_codec_fr_exhausted_req_fr() );
8236 execute( TC_assignment_codec_fr_exhausted_req_fr_hr() );
8237 execute( TC_assignment_codec_fr_exhausted_req_hr_fr() );
8238 execute( TC_assignment_codec_hr_exhausted_req_fr() );
8239 execute( TC_assignment_codec_hr_exhausted_req_hr() );
8240 execute( TC_assignment_codec_hr_exhausted_req_hr_fr() );
8241 execute( TC_assignment_codec_hr_exhausted_req_fr_hr() );
8242 execute( TC_assignment_codec_req_hr_fr() );
8243 execute( TC_assignment_codec_req_fr_hr() );
8244
Pau Espin Pedrol58cf6822019-05-28 18:11:33 +02008245 if (mp_enable_osmux_test) {
8246 execute( TC_assignment_osmux() );
8247 }
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02008248
Harald Welte898113b2018-01-31 18:32:21 +01008249 /* RLL Establish Indication on inactive DCHAN / SAPI */
Harald Welte5cd20ed2017-12-13 21:03:20 +01008250 execute( TC_rll_est_ind_inact_lchan() );
8251 execute( TC_rll_est_ind_inval_sapi1() );
8252 execute( TC_rll_est_ind_inval_sapi3() );
8253 execute( TC_rll_est_ind_inval_sacch() );
8254
Vadim Yanitskiy61f784a2020-10-01 21:12:19 +07008255 /* DLCI / RSL Link ID conversion for MO/MT messages on SAPI0/SAPI3 */
8256 execute( TC_tch_dlci_link_id_sapi() );
8257
Vadim Yanitskiy6ef5dfa2020-08-28 18:04:41 +07008258 /* SAPI N Reject triggered by RLL establishment failures */
8259 execute( TC_rll_rel_ind_sapi_n_reject() );
8260 execute( TC_rll_err_ind_sapi_n_reject() );
8261 execute( TC_rll_timeout_sapi_n_reject() );
8262
Harald Welte898113b2018-01-31 18:32:21 +01008263 /* Paging related tests */
Harald Welte6f521d82017-12-11 19:52:02 +01008264 execute( TC_paging_imsi_nochan() );
8265 execute( TC_paging_tmsi_nochan() );
8266 execute( TC_paging_tmsi_any() );
8267 execute( TC_paging_tmsi_sdcch() );
8268 execute( TC_paging_tmsi_tch_f() );
8269 execute( TC_paging_tmsi_tch_hf() );
8270 execute( TC_paging_imsi_nochan_cgi() );
8271 execute( TC_paging_imsi_nochan_lac_ci() );
8272 execute( TC_paging_imsi_nochan_ci() );
8273 execute( TC_paging_imsi_nochan_lai() );
8274 execute( TC_paging_imsi_nochan_lac() );
8275 execute( TC_paging_imsi_nochan_all() );
Harald Welte751d3eb2018-01-31 15:51:06 +01008276 execute( TC_paging_imsi_nochan_plmn_lac_rnc() );
8277 execute( TC_paging_imsi_nochan_rnc() );
8278 execute( TC_paging_imsi_nochan_lac_rnc() );
8279 execute( TC_paging_imsi_nochan_lacs() );
8280 execute( TC_paging_imsi_nochan_lacs_empty() );
Stefan Sperling049a86e2018-03-20 15:51:00 +01008281 execute( TC_paging_imsi_nochan_cgi_unknown_cid() );
Harald Welte10985002017-12-12 09:29:15 +01008282 execute( TC_paging_imsi_a_reset() );
Harald Weltee65d40e2017-12-13 00:09:06 +01008283 execute( TC_paging_imsi_load() );
Philipp Maier779a7922018-02-16 11:00:37 +01008284 execute( TC_paging_counter() );
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01008285 execute( TC_paging_resp_unsol() );
Harald Welte4e9b9cc2017-12-14 18:31:02 +01008286
8287 execute( TC_rsl_drop_counter() );
Stefan Sperling830dc9d2018-02-12 21:08:28 +01008288 execute( TC_rsl_unknown_unit_id() );
8289
8290 execute( TC_oml_unknown_unit_id() );
Harald Welte898113b2018-01-31 18:32:21 +01008291
8292 execute( TC_classmark() );
Harald Welteeddf0e92020-06-21 19:42:15 +02008293 execute( TC_common_id() );
Harald Welte898113b2018-01-31 18:32:21 +01008294 execute( TC_unsol_ass_fail() );
Harald Welteea99a002018-01-31 20:46:43 +01008295 execute( TC_unsol_ass_compl() );
Harald Weltefbf9b5e2018-01-31 20:41:23 +01008296 execute( TC_unsol_ho_fail() );
Harald Weltee3bd6582018-01-31 22:51:25 +01008297 execute( TC_err_82_short_msg() );
Harald Weltee9e02e42018-01-31 23:36:25 +01008298 execute( TC_err_84_unknown_msg() );
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01008299
Harald Welte261af4b2018-02-12 21:20:39 +01008300 execute( TC_ho_int() );
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01008301
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01008302 execute( TC_ho_out_of_this_bsc() );
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02008303 execute( TC_ho_out_fail_no_msc_response() );
8304 execute( TC_ho_out_fail_rr_ho_failure() );
Neels Hofmeyrd8a602c2019-07-09 19:46:01 +02008305 execute( TC_ho_out_fail_no_result_after_ho_cmd() );
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01008306
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01008307 execute( TC_ho_into_this_bsc() );
Pau Espin Pedrol07866632020-09-03 19:10:55 +02008308 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
8309 execute( TC_ho_into_this_bsc_tla_v6() );
8310 }
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01008311 execute( TC_ho_in_fail_msc_clears() );
8312 execute( TC_ho_in_fail_msc_clears_after_ho_detect() );
8313 execute( TC_ho_in_fail_no_detect() );
8314 execute( TC_ho_in_fail_no_detect2() );
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01008315
Neels Hofmeyr91401012019-07-11 00:42:35 +02008316 execute( TC_ho_neighbor_config_1() );
8317 execute( TC_ho_neighbor_config_2() );
8318 execute( TC_ho_neighbor_config_3() );
8319 execute( TC_ho_neighbor_config_4() );
8320 execute( TC_ho_neighbor_config_5() );
8321 execute( TC_ho_neighbor_config_6() );
8322 execute( TC_ho_neighbor_config_7() );
8323
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01008324 execute( TC_bssap_rlsd_does_not_cause_bssmap_reset() );
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01008325 execute( TC_bssmap_clear_does_not_cause_bssmap_reset() );
Neels Hofmeyrfd445c32018-03-09 15:39:31 +01008326 execute( TC_ms_rel_ind_does_not_cause_bssmap_reset() );
Harald Welte94e0c342018-04-07 11:33:23 +02008327
8328 execute( TC_dyn_pdch_ipa_act_deact() );
8329 execute( TC_dyn_pdch_ipa_act_nack() );
8330 execute( TC_dyn_pdch_osmo_act_deact() );
8331 execute( TC_dyn_pdch_osmo_act_nack() );
Harald Welte99f3ca02018-06-14 13:40:29 +02008332
Stefan Sperling0796a822018-10-05 13:01:39 +02008333 execute( TC_chopped_ipa_ping() );
Stefan Sperlingaa1e60f2018-10-15 16:34:07 +02008334 execute( TC_chopped_ipa_payload() );
Stefan Sperling0796a822018-10-05 13:01:39 +02008335
Pau Espin Pedrol8f773632019-11-05 11:46:53 +01008336 /* Power control related */
8337 execute( TC_assignment_verify_ms_power_params_ie() );
Neels Hofmeyr4f118412020-06-04 15:25:10 +02008338
8339 /* MSC pooling */
8340 /* FIXME: in SCCPlite, indicating how many MSCs should be connected does currently not work. Since
8341 * RESET->RESET-ACK is unconditionally negotiated for all configured MSCs, they always all appear as connected
8342 * to osmo-bsc. The MSC pooling tests however require disconnecting selected MSCs, and hence don't work out as
8343 * intended on SCCPlite. So for now, run these only for SCCP/M3UA. */
8344 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
8345 execute( TC_mscpool_L3Compl_on_1_msc() );
8346 execute( TC_mscpool_L3Complete_by_imsi_round_robin() );
8347 execute( TC_mscpool_LU_by_tmsi_null_nri_0_round_robin() );
8348 execute( TC_mscpool_LU_by_tmsi_null_nri_1_round_robin() );
8349 execute( TC_mscpool_L3Complete_by_tmsi_unassigned_nri_round_robin() );
8350 execute( TC_mscpool_L3Complete_by_tmsi_valid_nri_msc_not_connected_round_robin() );
8351 execute( TC_mscpool_L3Complete_by_tmsi_valid_nri_1() );
8352 execute( TC_mscpool_L3Complete_by_tmsi_valid_nri_2() );
8353 execute( TC_mscpool_LU_by_tmsi_from_other_PLMN() );
8354 execute( TC_mscpool_paging_and_response_imsi() );
8355 execute( TC_mscpool_paging_and_response_tmsi() );
8356 execute( TC_mscpool_no_allow_attach_round_robin() );
8357 execute( TC_mscpool_no_allow_attach_valid_nri() );
8358 }
8359
Harald Welte99f3ca02018-06-14 13:40:29 +02008360 /* at bottom as they might crash OsmoBSC before OS#3182 is fixed */
8361 execute( TC_early_conn_fail() );
8362 execute( TC_late_conn_fail() );
8363
Philipp Maier783681c2020-07-16 16:47:06 +02008364 /* Emergency call handling (deny / allow) */
8365 execute( TC_assignment_emerg_setup_allow() );
8366 execute( TC_assignment_emerg_setup_deny_msc() );
8367 execute( TC_assignment_emerg_setup_deny_bts() );
Philipp Maier82812002020-08-13 18:48:27 +02008368 execute( TC_emerg_premption() );
8369
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07008370 /* Frequency hopping parameters handling */
8371 execute( TC_fh_params_chan_activ() );
8372 execute( TC_fh_params_imm_ass() );
Vadim Yanitskiyaeb54a22020-09-01 06:25:25 +07008373 execute( TC_fh_params_assignment_cmd() );
Vadim Yanitskiy8f5430d2020-09-02 18:51:38 +07008374 execute( TC_fh_params_handover_cmd() );
Vadim Yanitskiyca974032020-09-01 07:20:39 +07008375 execute( TC_fh_params_si4_cbch() );
Neels Hofmeyr2b910dc2020-10-01 06:36:04 +02008376
8377 if (mp_enable_lcs_tests) {
8378 execute( TC_lcs_loc_req_for_active_ms() );
8379 execute( TC_lcs_loc_req_for_active_ms_ta_req() );
8380 execute( TC_lcs_loc_req_for_idle_ms() );
8381 execute( TC_lcs_loc_req_no_subscriber() );
8382 execute( TC_lcs_loc_req_for_active_ms_le_timeout() );
8383 execute( TC_lcs_loc_req_for_active_ms_le_timeout2() );
8384 execute( TC_lcs_loc_req_for_idle_ms_no_pag_resp() );
8385 execute( TC_cm_service_during_lcs_loc_req() );
8386 execute( TC_ho_during_lcs_loc_req() );
8387 }
Harald Welte28d943e2017-11-25 15:00:50 +01008388}
8389
8390}