blob: 7f670d20f48adcd0d361cd99d0f0ea7e71f29270 [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 Welteae026692017-12-09 01:03:01 +010031import from BSSAP_CodecPort all;
32import from BSSMAP_Templates all;
Harald Welte28d943e2017-11-25 15:00:50 +010033import from IPA_Emulation all;
Stefan Sperling830dc9d2018-02-12 21:08:28 +010034import from IPA_CodecPort all;
Harald Welteae026692017-12-09 01:03:01 +010035import from IPA_Types all;
Stefan Sperling0796a822018-10-05 13:01:39 +020036import from IPA_Testing all;
Harald Welteae026692017-12-09 01:03:01 +010037import from RSL_Types all;
Harald Welte624f9632017-12-16 19:26:04 +010038import from RSL_Emulation all;
Daniel Willmann191e0d92018-01-17 12:44:35 +010039import from MGCP_Emulation all;
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +010040import from MGCP_Templates all;
41import from MGCP_Types all;
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +020042import from MGCP_CodecPort all;
Harald Welte28d943e2017-11-25 15:00:50 +010043
Harald Welte96c94412017-12-09 03:12:45 +010044import from Osmocom_CTRL_Functions all;
Harald Weltea5d2ab22017-12-09 14:21:42 +010045import from Osmocom_CTRL_Types all;
Harald Welteffe55fc2018-01-17 22:39:54 +010046import from Osmocom_CTRL_Adapter all;
Harald Welte96c94412017-12-09 03:12:45 +010047
Daniel Willmannebdecc02020-08-12 15:30:17 +020048import from StatsD_Types all;
49import from StatsD_CodecPort all;
50import from StatsD_CodecPort_CtrlFunct all;
51import from StatsD_Checker all;
52
Harald Weltebc03c762018-02-12 18:09:38 +010053import from Osmocom_VTY_Functions all;
54import from TELNETasp_PortType all;
55
Harald Welte6f521d82017-12-11 19:52:02 +010056import from MobileL3_CommonIE_Types all;
Harald Weltee3bd6582018-01-31 22:51:25 +010057import from MobileL3_Types all;
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +010058import from MobileL3_RRM_Types all;
Harald Welte6f521d82017-12-11 19:52:02 +010059import from L3_Templates all;
60import from GSM_RR_Types all;
61
Stefan Sperlingc307e682018-06-14 15:15:46 +020062import from SCCP_Templates all;
Neels Hofmeyr4ff93282018-03-12 04:25:35 +010063import from BSSMAP_Templates all;
64
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +010065import from SCCPasp_Types all;
66
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +020067import from GSM_SystemInformation all;
68import from GSM_RestOctets all;
Neels Hofmeyrad132f22020-07-08 02:20:16 +020069import from TCCConversion_Functions all;
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +020070
Harald Welte5d1a2202017-12-13 19:51:29 +010071const integer NUM_BTS := 3;
Neels Hofmeyrf246a922020-05-13 02:27:10 +020072const integer NUM_MSC := 3;
Harald Welteae026692017-12-09 01:03:01 +010073const float T3101_MAX := 12.0;
Harald Welte28d943e2017-11-25 15:00:50 +010074
Harald Welte799c97b2017-12-14 17:50:30 +010075/* make sure to sync this with the osmo-bts.cfg you're using */
Philipp Maiercb6cc482018-03-26 13:08:00 +020076const integer NUM_TCHH_PER_BTS := 2;
77const integer NUM_TCHF_PER_BTS := 4;
Neels Hofmeyr74083c22020-07-29 00:43:01 +020078const integer NUM_SDCCH_PER_BTS := 3;
Harald Welte799c97b2017-12-14 17:50:30 +010079
Harald Welte4003d112017-12-09 22:35:39 +010080
Harald Welte21b46bd2017-12-17 19:46:32 +010081/* per-BTS state which we keep */
Harald Welte96c94412017-12-09 03:12:45 +010082type record BTS_State {
Harald Welte21b46bd2017-12-17 19:46:32 +010083 /* component reference to the IPA_Client component used for RSL */
Harald Weltea5d2ab22017-12-09 14:21:42 +010084 IPA_Client rsl
Harald Welte96c94412017-12-09 03:12:45 +010085}
86
Neels Hofmeyr22c3f792020-06-17 02:49:28 +020087/* Default list of counters for an 'msc' entity. */
88const CounterNameVals counternames_msc_mscpool := {
89 { "mscpool:subscr:new", 0 },
90 { "mscpool:subscr:known", 0 },
91 { "mscpool:subscr:reattach", 0 },
92 { "mscpool:subscr:attach_lost", 0 },
93 { "mscpool:subscr:paged", 0 }
94};
95
Neels Hofmeyr12941bd2020-08-29 03:21:26 +000096/* Default list of counters for 'bsc' and 'bts' entities. */
97const CounterNameVals counternames_bsc_bts_handover := {
98 { "assignment:attempted", 0 },
99 { "assignment:completed", 0 },
100 { "assignment:stopped", 0 },
101 { "assignment:no_channel", 0 },
102 { "assignment:timeout", 0 },
103 { "assignment:failed", 0 },
104 { "assignment:error", 0 },
105
106 { "handover:attempted", 0 },
107 { "handover:completed", 0 },
108 { "handover:stopped", 0 },
109 { "handover:no_channel", 0 },
110 { "handover:timeout", 0 },
111 { "handover:failed", 0 },
112 { "handover:error", 0 },
113
114 { "intra_cell_ho:attempted", 0 },
115 { "intra_cell_ho:completed", 0 },
116 { "intra_cell_ho:stopped", 0 },
117 { "intra_cell_ho:no_channel", 0 },
118 { "intra_cell_ho:timeout", 0 },
119 { "intra_cell_ho:failed", 0 },
120 { "intra_cell_ho:error", 0 },
121
122 { "intra_bsc_ho:attempted", 0 },
123 { "intra_bsc_ho:completed", 0 },
124 { "intra_bsc_ho:stopped", 0 },
125 { "intra_bsc_ho:no_channel", 0 },
126 { "intra_bsc_ho:timeout", 0 },
127 { "intra_bsc_ho:failed", 0 },
128 { "intra_bsc_ho:error", 0 },
129
130 { "interbsc_ho_out:attempted", 0 },
131 { "interbsc_ho_out:completed", 0 },
132 { "interbsc_ho_out:stopped", 0 },
133 { "interbsc_ho_out:timeout", 0 },
134 { "interbsc_ho_out:failed", 0 },
135 { "interbsc_ho_out:error", 0 },
136
137 { "interbsc_ho_in:attempted", 0 },
138 { "interbsc_ho_in:completed", 0 },
139 { "interbsc_ho_in:stopped", 0 },
140 { "interbsc_ho_in:no_channel", 0 },
141 { "interbsc_ho_in:timeout", 0 },
142 { "interbsc_ho_in:failed", 0 },
143 { "interbsc_ho_in:error", 0 }
144};
145
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +0200146/* Set of all System Information received during one RSL port's startup.
147 * Note that some System Information may be sent on RSL, but lacking actual SI data, to indicate that the BTS should not
148 * broadcast that SI type. That will be reflected as 'omit' here.
149 */
150type record SystemInformationConfig {
151 SystemInformationType1 si1 optional,
152 SystemInformationType2 si2 optional,
153 SystemInformationType2bis si2bis optional,
154 SystemInformationType2ter si2ter optional,
Neels Hofmeyrad132f22020-07-08 02:20:16 +0200155 SI2quaterRestOctetsList si2quater optional,
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +0200156 SystemInformationType3 si3 optional,
157 SystemInformationType4 si4 optional,
158 /* TODO: replace with proper decoding of SI13, implement SI13 in GSM_SystemInformation.ttcn */
159 octetstring si13 optional,
160 SystemInformationType5 si5 optional,
161 SystemInformationType5bis si5bis optional,
162 SystemInformationType5ter si5ter optional,
163 SystemInformationType6 si6 optional
164};
165
166const SystemInformationConfig SystemInformationConfig_omit := {
167 si1 := omit,
168 si2 := omit,
169 si2bis := omit,
170 si2ter := omit,
171 si2quater := omit,
172 si3 := omit,
173 si4 := omit,
174 si13 := omit,
175 si5 := omit,
176 si5bis := omit,
177 si5ter := omit,
178 si6 := omit
179};
180
181/* tr_EUTRAN_CellDesc with defaults used in BSC_Tests.ttcn */
182template EUTRAN_CellDesc tr_EUTRAN_CellDesc_default(template (present) uint16_t e_arfcn := ?,
183 template uint3_t meas_bw := 3)
184:= tr_EUTRAN_CellDesc(e_arfcn := e_arfcn,
185 meas_bw_presence := '1'B,
186 meas_bw := meas_bw);
187
188/* tr_EUTRAN_NeighbourCells with defaults used in BSC_Tests.ttcn */
Harald Welte65e419a2020-08-21 12:38:33 +0200189template EUTRAN_NeighbourCells tr_EUTRAN_NeighbourCells_default(template (present) EUTRAN_CellDescs cell_desc_list := { tr_EUTRAN_CellDesc_default },
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +0200190 template uint3_t prio := 3,
191 template (present) uint5_t thresh_high := 20,
192 template uint5_t thresh_low := 10,
193 template uint5_t qrxlevmin := 22)
194:= tr_EUTRAN_NeighbourCells(
195 cell_desc_list := cell_desc_list,
196 prio_presence := '1'B,
197 prio := prio,
198 thresh_high := thresh_high,
199 thresh_low_presence := '1'B,
200 thresh_low := thresh_low,
201 qrxlevmin_presence := '1'B,
202 qrxlevmin := qrxlevmin);
203
204template SystemInformationConfig SystemInformationConfig_default := {
205 si1 := {
206 cell_chan_desc := '8FB38000000000000000000000000000'O,
207 rach_control := {
208 max_retrans := RACH_MAX_RETRANS_7,
209 tx_integer := '1001'B,
210 cell_barr_access := false,
211 re_not_allowed := true,
212 acc := '0000010000000000'B
213 },
214 rest_octets := ?
215 },
216 si2 := {
217 bcch_freq_list := '00000000000000000000000000000000'O,
218 ncc_permitted := '11111111'B,
219 rach_control := {
220 max_retrans := RACH_MAX_RETRANS_7,
221 tx_integer := '1001'B,
222 cell_barr_access := false,
223 re_not_allowed := true,
224 acc := '0000010000000000'B
225 }
226 },
227 si2bis := omit,
228 si2ter := {
229 extd_bcch_freq_list := '8E320000000000000000000000000800'O,
230 rest_octets := ?
231 },
232 si2quater := {
233 tr_SI2quaterRestOctets_EUTRAN( repeated_neigh_cells := { tr_EUTRAN_NeighbourCells_default } )
234 },
235 si3 := {
236 cell_id := 0,
237 lai := {
238 mcc_mnc := '001F01'H,
239 lac := 1
240 },
241 ctrl_chan_desc := {
242 msc_r99 := true,
243 att := true,
244 bs_ag_blks_res := 1,
245 ccch_conf := CCHAN_DESC_1CCCH_COMBINED,
246 si22ind := false,
247 cbq3 := CBQ3_IU_MODE_NOT_SUPPORTED,
248 spare := '00'B,
249 bs_pa_mfrms := 3,
250 t3212 := 30
251 },
252 cell_options := {
253 dn_ind := false,
254 pwrc := false,
255 dtx := MS_SHALL_USE_UL_DTX,
256 radio_link_tout_div4 := 7
257 },
258 cell_sel_par := {
259 cell_resel_hyst_2dB := 2,
260 ms_txpwr_max_cch := 7,
261 acs := '0'B,
262 neci := true,
263 rxlev_access_min := 0
264 },
265 rach_control := {
266 max_retrans := RACH_MAX_RETRANS_7,
267 tx_integer := '1001'B,
268 cell_barr_access := false,
269 re_not_allowed := true,
270 acc := '0000010000000000'B
271 },
272 rest_octets := {
273 sel_params := {
274 presence := '0'B,
275 params := omit
276 },
277 pwr_offset := {
278 presence := '0'B,
279 offset := omit
280 },
281 si_2ter_ind := '1'B,
282 early_cm_ind := '0'B,
283 sched_where := {
284 presence := '0'B,
285 where := omit
286 },
287 gprs_ind := {
288 presence := '1'B,
289 ind := {
290 ra_colour := 0,
291 si13_pos := '0'B
292 }
293 },
294 umts_early_cm_ind := '1'B,
295 si2_quater_ind := {
296 presence := '1'B,
297 ind := '0'B
298 },
299 iu_mode_ind := omit,
300 si21_ind := {
301 presence := '0'B,
302 pos := omit
303 }
304 }
305 },
306 si4 := {
307 lai := {
308 mcc_mnc := '001F01'H,
309 lac := 1
310 },
311 cell_sel_par := {
312 cell_resel_hyst_2dB := 2,
313 ms_txpwr_max_cch := 7,
314 acs := '0'B,
315 neci := true,
316 rxlev_access_min := 0
317 },
318 rach_control := {
319 max_retrans := RACH_MAX_RETRANS_7,
320 tx_integer := '1001'B,
321 cell_barr_access := false,
322 re_not_allowed := true,
323 acc := '0000010000000000'B
324 },
Neels Hofmeyr74083c22020-07-29 00:43:01 +0200325 cbch_chan_desc := {
326 iei := '64'O,
327 v := {
328 chan_nr := {
329 u := {
330 sdcch4 := {
331 tag := '001'B,
332 sub_chan := 2
333 }
334 },
335 tn := 0
336 },
337 tsc := 2,
338 h := false,
339 arfcn := 871,
340 maio_hsn := omit
341 }
342 },
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +0200343 cbch_mobile_alloc := omit,
344 rest_octets := {
345 sel_params := {
346 presence := '0'B,
347 params := omit
348 },
349 pwr_offset := {
350 presence := '0'B,
351 offset := omit
352 },
353 gprs_ind := {
354 presence := '1'B,
355 ind := {
356 ra_colour := 0,
357 si13_pos := '0'B
358 }
359 },
360 s_presence := '0'B,
361 s := omit
362 }
363 },
364 si13 := '9000185A6FC9E08410AB2B2B2B2B2B2B2B2B2B2B'O,
365 si5 := {
366 bcch_freq_list := '10000000000000000000000000000000'O
367 },
368 si5bis := omit,
369 si5ter := {
370 extd_bcch_freq_list := '9E050020000000000000000000000000'O
371 },
372 si6 := {
373 cell_id := 0,
374 lai := {
375 mcc_mnc := '001F01'H,
376 lac := 1
377 },
378 cell_options := {
379 dtx_ext := '1'B,
380 pwrc := false,
381 dtx := '01'B,
382 radio_link_timeout := '0111'B
383 },
384 ncc_permitted := '11111111'B,
385 rest_octets := ?
386 }
387 };
388
389
390/* List of all the System Information received on all RSL ports */
391type record of SystemInformationConfig SystemInformationConfig_list;
392
393function f_sysinfo_dec_raw(inout SystemInformationConfig si, RSL_Message rsl)
394{
395 var RSL_IE_Body sysinfo_type_ie;
396 var RSL_IE_SysinfoType si_type;
397 var octetstring data;
398
399 if (f_rsl_find_ie(rsl, RSL_IE_SYSINFO_TYPE, sysinfo_type_ie) == false) {
400 setverdict(fail, "Cannot find RSL_IE_SYSINFO_TYPE");
401 mtc.stop;
402 }
403 si_type := sysinfo_type_ie.sysinfo_type;
404
405 if (rsl.msg_type == RSL_MT_BCCH_INFO) {
406 var RSL_IE_Body bcch_ie;
407 if (f_rsl_find_ie(rsl, RSL_IE_FULL_BCCH_INFO, bcch_ie)) {
408 data := bcch_ie.other.payload;
409 }
410 } else if (rsl.msg_type == RSL_MT_SACCH_FILL) {
411 var RSL_IE_Body l3_ie;
412 if (f_rsl_find_ie(rsl, RSL_IE_L3_INFO, l3_ie)) {
413 data := l3_ie.l3_info.payload;
414 }
415 } else {
416 setverdict(fail, "Don't understand this System Information message");
417 mtc.stop;
418 }
419
420 var boolean handled := false;
421
422 if (rsl.msg_type == RSL_MT_BCCH_INFO) {
423 handled := true;
424
425 if (si_type == RSL_SYSTEM_INFO_1) {
426 if (not isbound(data)) {
427 si.si1 := omit;
428 } else {
429 si.si1 := dec_SystemInformation(data).payload.si1;
430 }
431 } else if (si_type == RSL_SYSTEM_INFO_2) {
432 if (not isbound(data)) {
433 si.si2 := omit;
434 } else {
435 si.si2 := dec_SystemInformation(data).payload.si2;
436 }
437 } else if (si_type == RSL_SYSTEM_INFO_2bis) {
438 if (not isbound(data)) {
439 si.si2bis := omit;
440 } else {
441 si.si2bis := dec_SystemInformation(data).payload.si2bis;
442 }
443 } else if (si_type == RSL_SYSTEM_INFO_2ter) {
444 if (not isbound(data)) {
445 si.si2ter := omit;
446 } else {
447 si.si2ter := dec_SystemInformation(data).payload.si2ter;
448 }
449 } else if (si_type == RSL_SYSTEM_INFO_2quater) {
450 if (not isbound(data)) {
451 si.si2quater := {};
452 } else {
453 var SystemInformationType2quater decoded := dec_SystemInformation(data).payload.si2quater;
454 /* this is a *record* of SI2quaterRestOctets! (multiplexed) */
455 si.si2quater[decoded.rest_octets.si2quater_index] := decoded.rest_octets;
456 }
457 } else if (si_type == RSL_SYSTEM_INFO_3) {
458 if (not isbound(data)) {
459 si.si3 := omit;
460 } else {
461 si.si3 := dec_SystemInformation(data).payload.si3;
462 }
463 } else if (si_type == RSL_SYSTEM_INFO_4) {
464 if (not isbound(data)) {
465 si.si4 := omit;
466 } else {
467 si.si4 := dec_SystemInformation(data).payload.si4;
468 }
469 } else if (si_type == RSL_SYSTEM_INFO_13) {
470 if (not isbound(data)) {
471 si.si13 := omit;
472 } else {
473 si.si13 := dec_SystemInformation(data).payload.other;
474 }
475 } else {
476 handled := false;
477 }
478 } else if (rsl.msg_type == RSL_MT_SACCH_FILL) {
479 handled := true;
480
481 if (si_type == RSL_SYSTEM_INFO_5) {
482 if (not isbound(data)) {
483 si.si5 := omit;
484 } else {
485 si.si5 := dec_SystemInformation(data).payload.si5;
486 }
487 } else if (si_type == RSL_SYSTEM_INFO_5bis) {
488 if (not isbound(data)) {
489 si.si5bis := omit;
490 } else {
491 si.si5bis := dec_SystemInformation(data).payload.si5bis;
492 }
493 } else if (si_type == RSL_SYSTEM_INFO_5ter) {
494 if (not isbound(data)) {
495 si.si5ter := omit;
496 } else {
497 si.si5ter := dec_SystemInformation(data).payload.si5ter;
498 }
499 } else if (si_type == RSL_SYSTEM_INFO_6) {
500 if (not isbound(data)) {
501 si.si6 := omit;
502 } else {
503 si.si6 := dec_SystemInformation(data).payload.si6;
504 }
505 } else {
506 handled := false;
507 }
508 }
509
510 if (not handled) {
511 setverdict(fail, "Unexpected SI type in ", rsl.msg_type, " message: ", si_type);
512 }
513}
514
Harald Weltea4ca4462018-02-09 00:17:14 +0100515type component test_CT extends CTRL_Adapter_CT {
Harald Welte21b46bd2017-12-17 19:46:32 +0100516 /* Array of per-BTS state */
Harald Welte96c94412017-12-09 03:12:45 +0100517 var BTS_State bts[NUM_BTS];
Harald Welte89ab1912018-02-23 18:56:29 +0100518 /* RSL common Channel Port (for RSL_Emulation) */
519 port RSL_CCHAN_PT RSL_CCHAN[NUM_BTS];
Harald Welte21b46bd2017-12-17 19:46:32 +0100520 /* array of per-BTS RSL test ports */
Harald Welteae026692017-12-09 01:03:01 +0100521 port IPA_RSL_PT IPA_RSL[NUM_BTS];
Stefan Sperling830dc9d2018-02-12 21:08:28 +0100522 port IPA_CODEC_PT IPA; /* Required for compilation of TC_rsl_unknown_unit_id() */
Pau Espin Pedrol5a2d7432019-06-07 19:43:45 +0200523 /* CTRL muxed over IPA in SCCPlite conn BSC<->MSC (or BSC-NAT) */
524 port IPA_CTRL_PT SCCPLITE_IPA_CTRL;
Harald Weltea5d2ab22017-12-09 14:21:42 +0100525
Daniel Willmann191e0d92018-01-17 12:44:35 +0100526 var MGCP_Emulation_CT vc_MGCP;
Harald Weltebc03c762018-02-12 18:09:38 +0100527 port TELNETasp_PT BSCVTY;
Daniel Willmann191e0d92018-01-17 12:44:35 +0100528
Daniel Willmannebdecc02020-08-12 15:30:17 +0200529 /* StatsD */
530 var StatsD_Checker_CT vc_STATSD;
531
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200532 var RAN_Adapter g_bssap[NUM_MSC];
Harald Weltea4ca4462018-02-09 00:17:14 +0100533 /* for old legacy-tests only */
534 port BSSAP_CODEC_PT BSSAP;
535
Harald Welte21b46bd2017-12-17 19:46:32 +0100536 /* are we initialized yet */
Harald Welte28d943e2017-11-25 15:00:50 +0100537 var boolean g_initialized := false;
Harald Welte21b46bd2017-12-17 19:46:32 +0100538
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200539 /* Osmux is enabled through VTY */
540 var boolean g_osmux_enabled := false;
541
Pau Espin Pedrolc675b612020-01-09 19:55:40 +0100542 /*Configure T(tias) over VTY, seconds */
543 var integer g_bsc_sccp_timer_ias := 7 * 60;
544 /*Configure T(tiar) over VTY, seconds */
545 var integer g_bsc_sccp_timer_iar := 15 * 60;
546
Neels Hofmeyr4fbad7f2020-06-16 00:30:47 +0200547 /* global test case guard timer (actual timeout value is set in f_init()) */
Harald Welteae026692017-12-09 01:03:01 +0100548 timer T_guard := 30.0;
549
Neels Hofmeyr22c3f792020-06-17 02:49:28 +0200550 var CounterNameValsList g_ctr_msc;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +0000551 var CounterNameValsList g_ctr_bsc;
552 var CounterNameValsList g_ctr_bts;
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +0200553
554 /* System Information bytes as received during RSL startup, for each RSL[idx]. */
555 var SystemInformationConfig_list g_system_information := {};
Harald Welte28d943e2017-11-25 15:00:50 +0100556}
557
558modulepar {
Harald Welte21b46bd2017-12-17 19:46:32 +0100559 /* IP address at which the BSC can be reached */
Harald Welte696ddb62017-12-08 14:01:43 +0100560 charstring mp_bsc_ip := "127.0.0.1";
Stefan Sperling830dc9d2018-02-12 21:08:28 +0100561 /* port number to which to establish the IPA OML connections */
562 integer mp_bsc_oml_port := 3002;
Harald Welte21b46bd2017-12-17 19:46:32 +0100563 /* port number to which to establish the IPA RSL connections */
Harald Welte696ddb62017-12-08 14:01:43 +0100564 integer mp_bsc_rsl_port := 3003;
Harald Welte21b46bd2017-12-17 19:46:32 +0100565 /* port number to which to establish the IPA CTRL connection */
Harald Welte96c94412017-12-09 03:12:45 +0100566 integer mp_bsc_ctrl_port := 4249;
Daniel Willmannebdecc02020-08-12 15:30:17 +0200567 /* port number to which to listen for STATSD metrics */
568 integer mp_bsc_statsd_port := 8125;
Daniel Willmann191e0d92018-01-17 12:44:35 +0100569 /* IP address at which the test binds */
570 charstring mp_test_ip := "127.0.0.1";
Harald Weltea4ca4462018-02-09 00:17:14 +0100571
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200572 RAN_Configurations mp_bssap_cfg := {
573 {
574 transport := BSSAP_TRANSPORT_AoIP,
575 sccp_service_type := "mtp3_itu",
576 sctp_addr := { 23905, "127.0.0.1", 2905, "127.0.0.1" },
577 own_pc := 185, /* 0.23.1 first MSC emulation */
578 own_ssn := 254,
579 peer_pc := 187, /* 0.23.3 osmo-bsc */
580 peer_ssn := 254,
581 sio := '83'O,
Harald Weltecb0cc432020-06-21 19:42:31 +0200582 rctx := 1
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200583 },
584 {
585 transport := BSSAP_TRANSPORT_AoIP,
586 sccp_service_type := "mtp3_itu",
587 sctp_addr := { 23906, "127.0.0.1", 2905, "127.0.0.1" },
588 own_pc := 2, /* 0.0.2 second MSC emulation */
589 own_ssn := 254,
590 peer_pc := 187, /* 0.23.3 osmo-bsc */
591 peer_ssn := 254,
592 sio := '83'O,
593 rctx := 2
594 },
595 {
596 transport := BSSAP_TRANSPORT_AoIP,
597 sccp_service_type := "mtp3_itu",
598 sctp_addr := { 23907, "127.0.0.1", 2905, "127.0.0.1" },
599 own_pc := 3, /* 0.0.3 third MSC emulation */
600 own_ssn := 254,
601 peer_pc := 187, /* 0.23.3 osmo-bsc */
602 peer_ssn := 254,
603 sio := '83'O,
604 rctx := 3
605 }
Harald Weltea4ca4462018-02-09 00:17:14 +0100606 };
Pau Espin Pedrol58cf6822019-05-28 18:11:33 +0200607
608 /* Whether to enable osmux tests. Can be dropped completely and enable
609 unconditionally once new version of osmo-bsc is released (current
610 version: 1.4.1) */
611 boolean mp_enable_osmux_test := true;
Pau Espin Pedrol8f30ccd2019-11-01 17:30:57 +0100612 /* Value set in osmo-bsc.cfg "ms max power" */
613 uint8_t mp_exp_ms_power_level := 7;
Harald Weltea4ca4462018-02-09 00:17:14 +0100614}
615
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200616private function f_gen_test_hdlr_pars(integer bssap_idx := 0) return TestHdlrParams {
Philipp Maier48604732018-10-09 15:00:37 +0200617
618 var TestHdlrParams pars := valueof(t_def_TestHdlrPars);
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200619 if (mp_bssap_cfg[bssap_idx].transport == BSSAP_TRANSPORT_AoIP) {
Philipp Maier48604732018-10-09 15:00:37 +0200620 pars.aoip := true;
621 } else {
622 pars.aoip := false;
623 }
Pau Espin Pedrol8f30ccd2019-11-01 17:30:57 +0100624 pars.exp_ms_power_level := mp_exp_ms_power_level;
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200625 pars.mscpool.bssap_idx := bssap_idx;
Philipp Maier48604732018-10-09 15:00:37 +0200626
627 return pars;
628}
629
Neels Hofmeyr22c3f792020-06-17 02:49:28 +0200630/* Convenience functions for rate counters using g_ctr_msc. */
631
632private function f_ctrs_msc_init(integer mscs_count := NUM_MSC, CounterNameVals counternames := counternames_msc_mscpool) runs on test_CT {
633 g_ctr_msc := f_counter_name_vals_get_n(IPA_CTRL, "msc", mscs_count, counternames);
634 log("initial msc rate counters: ", g_ctr_msc);
635}
636
637private function f_ctrs_msc_add(integer msc_nr, charstring countername, integer val := 1) runs on test_CT {
Neels Hofmeyr9656e922020-06-30 01:27:01 +0200638 f_counter_name_vals_list_add(g_ctr_msc, msc_nr, countername, val);
Neels Hofmeyr22c3f792020-06-17 02:49:28 +0200639}
640
641/* f_ctrs_msc_init();
642 * f_do_thing(on_msc := 0);
643 * f_do_thing(on_msc := 0);
644 * f_do_other(on_msc := 1);
645 * f_ctrs_msc_add(0, "thing", 2);
646 * f_ctrs_msc_add(1, "other");
647 * f_ctrs_msc_verify();
648 */
649private function f_ctrs_msc_verify() runs on test_CT {
650 log("verifying msc rate counters: ", g_ctr_msc);
651 f_counter_name_vals_expect_n(IPA_CTRL, "msc", g_ctr_msc);
652}
653
654/* convenience: f_ctrs_msc_add() and f_ctrs_msc_verify() in one call.
655 * f_ctrs_msc_init();
656 * f_do_thing(on_msc := 0);
657 * f_do_thing(on_msc := 0);
658 * f_do_thing(on_msc := 0);
659 * f_ctrs_msc_expect(0, "thing", 3);
660 */
661private function f_ctrs_msc_expect(integer msc_nr, charstring countername, integer val := 1) runs on test_CT {
662 f_ctrs_msc_add(msc_nr, countername, val);
663 f_ctrs_msc_verify();
664}
665
Neels Hofmeyr12941bd2020-08-29 03:21:26 +0000666/* Convenience functions for rate counters using g_ctr_bts, always also including g_ctr_bsc. */
667
668private function f_ctrs_bsc_and_bts_init(integer bts_count := NUM_BTS, CounterNameVals counternames := counternames_bsc_bts_handover) runs on test_CT {
669 g_ctr_bts := f_counter_name_vals_get_n(IPA_CTRL, "bts", bts_count, counternames);
670 log("initial bts rate counters: ", g_ctr_bts);
671 f_ctrs_bsc_init(counternames);
672}
673
674private function f_ctrs_bsc_and_bts_add(integer bts_nr, charstring countername, integer val := 1) runs on test_CT {
675 f_counter_name_vals_list_add(g_ctr_bts, bts_nr, countername, val);
676 f_ctrs_bsc_add(countername, val);
677}
678
679/* f_ctrs_bsc_and_bts_init();
680 * f_do_thing(on_bts := 0);
681 * f_do_thing(on_bts := 0);
682 * f_do_other(on_bts := 1);
683 * f_ctrs_bsc_and_bts_add(0, "thing", 2);
684 * f_ctrs_bsc_and_bts_add(1, "other");
685 * f_ctrs_bsc_and_bts_verify();
686 */
687private function f_ctrs_bsc_and_bts_verify() runs on test_CT {
688 f_counter_name_vals_expect_n(IPA_CTRL, "bts", g_ctr_bts);
689 f_ctrs_bsc_verify();
690}
691
692/* convenience: f_ctrs_bsc_and_bts_add() and f_ctrs_bsc_and_bts_verify() in one call.
693 * f_ctrs_bsc_and_bts_init();
694 * f_do_thing(on_bts := 0);
695 * f_do_thing(on_bts := 0);
696 * f_do_thing(on_bts := 0);
697 * f_ctrs_bsc_and_bts_expect(0, "thing", 3);
698 */
699private function f_ctrs_bsc_and_bts_expect(integer bts_nr, charstring countername, integer val := 1) runs on test_CT {
700 f_ctrs_bsc_and_bts_add(bts_nr, countername, val);
701 f_ctrs_bsc_and_bts_verify();
702}
703
704
705/* Convenience functions for rate counters using g_ctr_bsc. */
706
707private function f_ctrs_bsc_init(CounterNameVals counternames := counternames_bsc_bts_handover) runs on test_CT {
708 g_ctr_bsc := f_counter_name_vals_get_n(IPA_CTRL, "bsc", 1, counternames);
709 log("initial bsc rate counters: ", g_ctr_bsc);
710}
711
712private function f_ctrs_bsc_add(charstring countername, integer val := 1) runs on test_CT {
713 f_counter_name_vals_list_add(g_ctr_bsc, 0, countername, val);
714}
715
716/* f_ctrs_bsc_init();
717 * f_do_thing();
718 * f_do_thing();
719 * f_do_other();
720 * f_ctrs_bsc_add("thing", 2);
721 * f_ctrs_bsc_add("other");
722 * f_ctrs_bsc_verify();
723 */
724private function f_ctrs_bsc_verify() runs on test_CT {
725 f_counter_name_vals_expect_n(IPA_CTRL, "bsc", g_ctr_bsc);
726}
727
728/* convenience: f_ctrs_bsc_add() and f_ctrs_bsc_verify() in one call.
729 * f_ctrs_bsc_init();
730 * f_do_thing();
731 * f_ctrs_bsc_expect("thing", 1);
732 */
733private function f_ctrs_bsc_expect(charstring countername, integer val := 1) runs on test_CT {
734 f_ctrs_bsc_add(countername, val);
735 f_ctrs_bsc_verify();
736}
737
Neels Hofmeyr22c3f792020-06-17 02:49:28 +0200738
Philipp Maier282ca4b2018-02-27 17:17:00 +0100739private function f_shutdown_helper() runs on test_CT {
Daniel Willmann637ef6c2018-07-25 10:49:09 +0200740 all component.stop;
Philipp Maier282ca4b2018-02-27 17:17:00 +0100741 setverdict(pass);
Daniel Willmannafce8662018-07-06 23:11:32 +0200742 mtc.stop;
Philipp Maier282ca4b2018-02-27 17:17:00 +0100743}
744
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200745private function f_legacy_bssap_reset(integer bssap_idx := 0) runs on test_CT {
Harald Weltea4ca4462018-02-09 00:17:14 +0100746 var BSSAP_N_UNITDATA_ind ud_ind;
Pau Espin Pedrol24c05992020-09-01 12:54:12 +0200747 var boolean reset_received := false;
Harald Weltea4ca4462018-02-09 00:17:14 +0100748 timer T := 5.0;
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200749 BSSAP.send(ts_BSSAP_UNITDATA_req(g_bssap[bssap_idx].sccp_addr_peer, g_bssap[bssap_idx].sccp_addr_own,
750 ts_BSSMAP_Reset(0, g_osmux_enabled)));
Harald Weltea4ca4462018-02-09 00:17:14 +0100751 T.start;
752 alt {
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200753 [] BSSAP.receive(tr_BSSAP_UNITDATA_ind(g_bssap[bssap_idx].sccp_addr_own, g_bssap[bssap_idx].sccp_addr_peer,
754 tr_BSSMAP_ResetAck(g_osmux_enabled))) {
Harald Weltea4ca4462018-02-09 00:17:14 +0100755 log("Received RESET-ACK in response to RESET, we're ready to go!");
756 }
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200757 [] BSSAP.receive(tr_BSSAP_UNITDATA_ind(?, ?, tr_BSSMAP_Reset(g_osmux_enabled))) -> value ud_ind {
Harald Weltea4ca4462018-02-09 00:17:14 +0100758 log("Respoding to inbound RESET with RESET-ACK");
759 BSSAP.send(ts_BSSAP_UNITDATA_req(ud_ind.callingAddress, ud_ind.calledAddress,
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200760 ts_BSSMAP_ResetAck(g_osmux_enabled)));
Pau Espin Pedrol24c05992020-09-01 12:54:12 +0200761 reset_received := true;
Harald Weltea4ca4462018-02-09 00:17:14 +0100762 repeat;
763 }
764 [] BSSAP.receive { repeat; }
Pau Espin Pedrol24c05992020-09-01 12:54:12 +0200765 [] T.timeout {
766 log("Timeout waiting for RESET-ACK after sending RESET");
767 /* If we received a RESET after ours was sent, it
768 may be a race condition where the other peer beacame
769 available after we sent it, but we are in a desired
770 state anyway, so go forward. */
771 if (not reset_received) {
772 setverdict(fail);
773 }
774 }
Harald Weltea4ca4462018-02-09 00:17:14 +0100775 }
Harald Welte28d943e2017-11-25 15:00:50 +0100776}
777
Harald Welteae026692017-12-09 01:03:01 +0100778type record IPA_Client {
Harald Welte21b46bd2017-12-17 19:46:32 +0100779 /* IPA Emulation component reference */
Harald Welteae026692017-12-09 01:03:01 +0100780 IPA_Emulation_CT vc_IPA,
Harald Welte21b46bd2017-12-17 19:46:32 +0100781 /* Unit-ID and other CCM parameters to use for IPA client emulation */
Harald Welteae026692017-12-09 01:03:01 +0100782 IPA_CCM_Parameters ccm_pars,
Harald Welte21b46bd2017-12-17 19:46:32 +0100783 /* String identifier for this IPA Client */
Harald Welte624f9632017-12-16 19:26:04 +0100784 charstring id,
Harald Welte21b46bd2017-12-17 19:46:32 +0100785 /* Associated RSL Emulation Component (if any). Only used in "Handler mode" */
Harald Welte624f9632017-12-16 19:26:04 +0100786 RSL_Emulation_CT vc_RSL optional
Harald Welte28d943e2017-11-25 15:00:50 +0100787}
788
Harald Welte21b46bd2017-12-17 19:46:32 +0100789/*! Start the IPA/RSL related bits for one IPA_Client.
790 * \param clnt IPA_Client for which to establish
791 * \param bsc_host IP address / hostname of the BSC
792 * \param bsc_port TCP port number of the BSC
793 * \param i number identifying this BTS
794 * \param handler_mode Start an RSL_Emulation_CT component (true) or not (false) */
Harald Welte624f9632017-12-16 19:26:04 +0100795function f_ipa_rsl_start(inout IPA_Client clnt, charstring bsc_host, PortNumber bsc_port, integer i,
796 boolean handler_mode := false)
Harald Welte28d943e2017-11-25 15:00:50 +0100797runs on test_CT {
Harald Welteae026692017-12-09 01:03:01 +0100798 timer T := 10.0;
799
Harald Welte96c94412017-12-09 03:12:45 +0100800 clnt.id := "IPA" & int2str(i) & "-RSL";
Harald Welteae026692017-12-09 01:03:01 +0100801 clnt.vc_IPA := IPA_Emulation_CT.create(clnt.id & "-IPA");
802 clnt.ccm_pars := c_IPA_default_ccm_pars;
803 clnt.ccm_pars.name := "Osmocom TTCN-3 BTS Simulator";
804 clnt.ccm_pars.unit_id := int2str(1234+i) & "/0/0";
Harald Welte624f9632017-12-16 19:26:04 +0100805 if (handler_mode) {
806 clnt.vc_RSL := RSL_Emulation_CT.create(clnt.id & "-RSL");
Harald Welte89ab1912018-02-23 18:56:29 +0100807 connect(clnt.vc_RSL:CCHAN_PT, self:RSL_CCHAN[i]);
Harald Welte624f9632017-12-16 19:26:04 +0100808 }
Harald Welteae026692017-12-09 01:03:01 +0100809
810 map(clnt.vc_IPA:IPA_PORT, system:IPA_CODEC_PT);
Harald Welte624f9632017-12-16 19:26:04 +0100811 if (handler_mode) {
812 connect(clnt.vc_IPA:IPA_RSL_PORT, clnt.vc_RSL:IPA_PT);
813 } else {
814 connect(clnt.vc_IPA:IPA_RSL_PORT, self:IPA_RSL[i]);
815 }
Harald Welteae026692017-12-09 01:03:01 +0100816
Harald Welte5d1a2202017-12-13 19:51:29 +0100817 clnt.vc_IPA.start(IPA_Emulation.main_client(bsc_host, bsc_port, "", 10000+i, clnt.ccm_pars));
Harald Welte624f9632017-12-16 19:26:04 +0100818 if (handler_mode) {
819 clnt.vc_RSL.start(RSL_Emulation.main());
820 return;
821 }
Harald Welteae026692017-12-09 01:03:01 +0100822
823 /* wait for IPA RSL link to connect and send ID ACK */
824 T.start;
825 alt {
Vadim Yanitskiya2afacc2020-05-18 21:16:19 +0700826 [] IPA_RSL[i].receive(tr_ASP_IPA_EV(ASP_IPA_EVENT_ID_ACK)) {
Harald Welteae026692017-12-09 01:03:01 +0100827 T.stop;
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +0700828 IPA_RSL[i].send(ts_ASP_RSL_UD(ts_RSL_PAGING_LOAD_IND(23)));
Harald Welteae026692017-12-09 01:03:01 +0100829 }
Harald Welte60e823a2017-12-10 14:10:59 +0100830 [] IPA_RSL[i].receive(ASP_IPA_Event:?) { repeat }
Harald Welteae026692017-12-09 01:03:01 +0100831 [] IPA_RSL[i].receive { repeat }
832 [] T.timeout {
Harald Welte96c94412017-12-09 03:12:45 +0100833 setverdict(fail, "Timeout RSL waiting for ASP_IPA_EVENT_ID_ACK");
Daniel Willmannafce8662018-07-06 23:11:32 +0200834 mtc.stop;
Harald Welteae026692017-12-09 01:03:01 +0100835 }
836 }
837}
838
Harald Welte12055472018-03-17 20:10:08 +0100839function f_ipa_rsl_stop(inout IPA_Client clnt) runs on test_CT {
840 if (not isbound(clnt) or not isbound(clnt.vc_IPA)) {
841 return;
842 }
843 clnt.vc_IPA.stop;
844 if (isbound(clnt.vc_RSL)) {
845 clnt.vc_RSL.stop;
846 }
847}
848
Harald Welte21b46bd2017-12-17 19:46:32 +0100849/* Wait for the OML connection to be brought up by the external osmo-bts-omldummy */
Harald Weltea5d2ab22017-12-09 14:21:42 +0100850function f_wait_oml(integer bts_nr, charstring status, float secs_max) runs on test_CT {
851 timer T := secs_max;
852 T.start;
853 while (true) {
854 if (f_ctrl_get_bts(IPA_CTRL, bts_nr, "oml-connection-state") == status) {
855 T.stop;
Harald Weltebd868bd2017-12-10 18:28:40 +0100856 /* the 'degraded' state exists from OML connection time, and we have to wait
857 * until all MO's are initialized */
858 T.start(1.0);
859 T.timeout;
Harald Weltea5d2ab22017-12-09 14:21:42 +0100860 return;
861 }
Harald Weltef0d6ac62017-12-17 17:02:21 +0100862 f_sleep(0.1);
Harald Weltea5d2ab22017-12-09 14:21:42 +0100863 if (not T.running) {
Max99253902018-11-16 17:57:39 +0100864 setverdict(fail, "Timeout waiting for BTS" & int2str(bts_nr) & " oml-connection-state ", status);
Daniel Willmannafce8662018-07-06 23:11:32 +0200865 mtc.stop;
Harald Weltea5d2ab22017-12-09 14:21:42 +0100866 }
867 }
868}
869
Harald Welte21b46bd2017-12-17 19:46:32 +0100870/* global altstep for global guard timer; also takes care of responding RESET witH RESET-ACK */
Harald Welteae026692017-12-09 01:03:01 +0100871altstep as_Tguard() runs on test_CT {
Harald Welte60e823a2017-12-10 14:10:59 +0100872 var BSSAP_N_UNITDATA_ind ud_ind;
Neels Hofmeyrcc3f76a2018-03-12 01:43:25 +0100873 [] T_guard.timeout {
874 setverdict(fail, "Timeout of T_guard");
Daniel Willmannafce8662018-07-06 23:11:32 +0200875 mtc.stop;
Neels Hofmeyrcc3f76a2018-03-12 01:43:25 +0100876 }
Harald Welte60e823a2017-12-10 14:10:59 +0100877 /* always respond with RESET ACK to RESET */
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200878 [] BSSAP.receive(tr_BSSAP_UNITDATA_ind(?, ?, tr_BSSMAP_Reset(g_osmux_enabled))) -> value ud_ind {
Harald Welte60e823a2017-12-10 14:10:59 +0100879 BSSAP.send(ts_BSSAP_UNITDATA_req(ud_ind.callingAddress, ud_ind.calledAddress,
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200880 ts_BSSMAP_ResetAck(g_osmux_enabled)));
Harald Welte69c1c262017-12-13 21:02:08 +0100881 repeat;
Harald Welte60e823a2017-12-10 14:10:59 +0100882 }
Harald Welte28d943e2017-11-25 15:00:50 +0100883}
884
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +0100885altstep no_bssmap_reset() runs on test_CT {
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200886 [] BSSAP.receive(tr_BSSAP_UNITDATA_ind(?, ?, tr_BSSMAP_Reset(g_osmux_enabled))) {
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +0100887 setverdict(fail, "unexpected BSSMAP Reset");
Daniel Willmannafce8662018-07-06 23:11:32 +0200888 mtc.stop;
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +0100889 }
890}
891
Daniel Willmann191e0d92018-01-17 12:44:35 +0100892function f_init_mgcp(charstring id) runs on test_CT {
893 id := id & "-MGCP";
894
895 var MGCPOps ops := {
896 create_cb := refers(MGCP_Emulation.ExpectedCreateCallback),
897 unitdata_cb := refers(MGCP_Emulation.DummyUnitdataCallback)
898 };
899 var MGCP_conn_parameters mgcp_pars := {
900 callagent_ip := mp_bsc_ip,
Harald Welte9e4273e2018-01-29 22:01:22 +0100901 callagent_udp_port := -1,
Daniel Willmann191e0d92018-01-17 12:44:35 +0100902 mgw_ip := mp_test_ip,
Pau Espin Pedrol1a026a52019-06-18 17:21:52 +0200903 mgw_udp_port := 2427,
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +0200904 /* Enable it for SCCPlite, since we have 2 MGCP sockets towards MGW (UDP one +
905 the on with MGCP over IPA forwarded from MSC one) */
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200906 multi_conn_mode := (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_SCCPlite_SERVER)
Daniel Willmann191e0d92018-01-17 12:44:35 +0100907 };
908
909 vc_MGCP := MGCP_Emulation_CT.create(id);
910 vc_MGCP.start(MGCP_Emulation.main(ops, mgcp_pars, id));
911}
912
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200913/* Enable or disable (current default) Osmux. When enabling, BSSMAP Reset
914 * contains extra IE (OsmuxSupport) and osmo-bsc will handle AssignReq with
915 * OsmuxCID IE.
916 */
917private function f_vty_allow_osmux(boolean allow) runs on test_CT {
918 f_vty_enter_cfg_msc(BSCVTY, 0);
919 if (allow) {
920 f_vty_transceive(BSCVTY, "osmux on");
921 } else {
922 f_vty_transceive(BSCVTY, "osmux off");
923 }
924 f_vty_transceive(BSCVTY, "exit");
925 f_vty_transceive(BSCVTY, "exit");
926 g_osmux_enabled := allow;
927}
928
Max2253c0b2018-11-06 19:28:05 +0100929function f_init_vty(charstring id := "foo") runs on test_CT {
Harald Welte94e0c342018-04-07 11:33:23 +0200930 if (BSCVTY.checkstate("Mapped")) {
931 /* skip initialization if already executed once */
932 return;
933 }
Harald Weltebc03c762018-02-12 18:09:38 +0100934 map(self:BSCVTY, system:BSCVTY);
935 f_vty_set_prompts(BSCVTY);
936 f_vty_transceive(BSCVTY, "enable");
Pau Espin Pedrolc675b612020-01-09 19:55:40 +0100937 f_cs7_inst_0_cfg(BSCVTY, {"sccp-timer ias " & int2str(g_bsc_sccp_timer_ias),
938 "sccp-timer iar " & int2str(g_bsc_sccp_timer_iar)});
Harald Weltebc03c762018-02-12 18:09:38 +0100939}
940
Neels Hofmeyr4f118412020-06-04 15:25:10 +0200941private function f_logp(charstring log_msg) runs on MSC_ConnHdlr
942{
943 // log on TTCN3 log output
944 log(log_msg);
945 // log in stderr log
946 f_vty_transceive(BSCVTY, "logp lglobal notice " & log_msg);
947}
948
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +0200949private function f_sysinfo_seen(integer rsl_idx, RSL_Message rsl) runs on test_CT
950{
951 if (rsl_idx >= lengthof(g_system_information)) {
952 g_system_information[rsl_idx] := SystemInformationConfig_omit
953 }
954 f_sysinfo_dec_raw(g_system_information[rsl_idx], rsl);
955}
956
957altstep as_catch_RSL_sysinfo(integer rsl_idx) runs on test_CT {
958 var ASP_RSL_Unitdata rx_rsl_ud;
959
960 /* For handler_mode := false, receiving the RSL bootstrap messages directly on IPA_RSL */
961 [] IPA_RSL[rsl_idx].receive(tr_ASP_RSL_UD(tr_RSL_NO_BCCH_INFO)) -> value rx_rsl_ud {
962 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
963 repeat;
964 }
965 [] IPA_RSL[rsl_idx].receive(tr_ASP_RSL_UD(tr_RSL_BCCH_INFO)) -> value rx_rsl_ud {
966 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
967 repeat;
968 }
969 [] IPA_RSL[rsl_idx].receive(tr_ASP_RSL_UD(tr_RSL_NO_SACCH_FILL)) -> value rx_rsl_ud {
970 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
971 repeat;
972 }
973 [] IPA_RSL[rsl_idx].receive(tr_ASP_RSL_UD(tr_RSL_SACCH_FILL)) -> value rx_rsl_ud {
974 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
975 repeat;
976 }
977
978 /* For handler_mode := true, receiving the RSL bootstrap messages via RSL_Emulation */
979 [] RSL_CCHAN[rsl_idx].receive(tr_ASP_RSL_UD(tr_RSL_NO_BCCH_INFO)) -> value rx_rsl_ud {
980 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
981 repeat;
982 }
983 [] RSL_CCHAN[rsl_idx].receive(tr_ASP_RSL_UD(tr_RSL_BCCH_INFO)) -> value rx_rsl_ud {
984 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
985 repeat;
986 }
987 [] RSL_CCHAN[rsl_idx].receive(tr_ASP_RSL_UD(tr_RSL_NO_SACCH_FILL)) -> value rx_rsl_ud {
988 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
989 repeat;
990 }
991 [] RSL_CCHAN[rsl_idx].receive(tr_ASP_RSL_UD(tr_RSL_SACCH_FILL)) -> value rx_rsl_ud {
992 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
993 repeat;
994 }
995}
996
Neels Hofmeyra460f1f2020-08-09 20:17:03 +0000997/* TODO: use BooleanList from COMMON/src/General_Types.ttcn */
998private type record of boolean my_BooleanList;
999
1000private function f_vty_msc_allow_attach(TELNETasp_PT pt, my_BooleanList allow_attach_list)
1001{
Neels Hofmeyr8f576712020-08-12 22:49:53 +00001002 var charstring config := f_vty_transceive_ret(pt, "show running-config");
1003
Neels Hofmeyra460f1f2020-08-09 20:17:03 +00001004 for (var integer msc_nr := 0; msc_nr < sizeof(allow_attach_list); msc_nr := msc_nr+1) {
Neels Hofmeyr8f576712020-08-12 22:49:53 +00001005 if (f_strstr(config, "\nmsc " & int2str(msc_nr) & "\n") < 0) {
1006 /* There is no 'msc N' for this msc_nr in the running config, so don't create an empty msc by
1007 * stepping into that config node. */
1008 log("msc ", msc_nr, " is not configured, skipping");
1009 continue;
1010 }
Neels Hofmeyra460f1f2020-08-09 20:17:03 +00001011 f_vty_enter_cfg_msc(pt, msc_nr);
1012 if (allow_attach_list[msc_nr]) {
1013 /* strict := false: ignore if osmo-bsc does not support this config option (latest build) */
1014 f_vty_transceive(pt, "allow-attach", strict := false);
1015 } else {
1016 f_vty_transceive(pt, "no allow-attach", strict := false);
1017 }
1018 f_vty_transceive(pt, "exit");
1019 f_vty_transceive(pt, "exit");
1020 }
1021}
1022
Harald Welte21b46bd2017-12-17 19:46:32 +01001023/* global initialization function
1024 * \param nr_bts Number of BTSs we should start/bring up
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001025 * \param handler_mode Start an RSL_Emulation_CT component (true) or not (false).
1026 * \param nr_msc Number of virtual MSCs to bring up to connect to osmo-bsc.
1027 */
1028function f_init(integer nr_bts := NUM_BTS, boolean handler_mode := false, boolean allow_osmux := false,
Neels Hofmeyr4fbad7f2020-06-16 00:30:47 +02001029 integer nr_msc := 1, float guard_timeout := 30.0) runs on test_CT {
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001030 var integer bssap_idx;
Harald Welte28d943e2017-11-25 15:00:50 +01001031
Harald Welteae026692017-12-09 01:03:01 +01001032 if (g_initialized) {
1033 return;
Harald Welte28d943e2017-11-25 15:00:50 +01001034 }
Harald Welteae026692017-12-09 01:03:01 +01001035 g_initialized := true;
1036
Neels Hofmeyr4fbad7f2020-06-16 00:30:47 +02001037 T_guard.start(guard_timeout);
Daniel Willmanne68f9272018-11-27 15:15:28 +01001038 activate(as_Tguard());
1039
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02001040 f_init_vty("VirtMSC");
Pau Espin Pedrol58cf6822019-05-28 18:11:33 +02001041 if (mp_enable_osmux_test) {
1042 f_vty_allow_osmux(allow_osmux);
1043 }
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02001044
Neels Hofmeyra460f1f2020-08-09 20:17:03 +00001045 var my_BooleanList allow_attach := { false, false, false };
Daniel Willmannebdecc02020-08-12 15:30:17 +02001046 f_init_statsd("VirtMSC", vc_STATSD, mp_test_ip, mp_bsc_statsd_port);
1047
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001048 for (bssap_idx := 0; bssap_idx < nr_msc; bssap_idx := bssap_idx+1) {
Neels Hofmeyra460f1f2020-08-09 20:17:03 +00001049 allow_attach[bssap_idx] := true;
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001050 /* Call a function of our 'parent component' RAN_Adapter_CT to start the
1051 * MSC-side BSSAP emulation */
1052 if (handler_mode) {
1053 var RanOps ranops := MSC_RanOps;
1054 ranops.use_osmux := g_osmux_enabled;
1055 f_ran_adapter_init(g_bssap[bssap_idx], mp_bssap_cfg[bssap_idx], "VirtMSC", ranops);
1056 connect(self:SCCPLITE_IPA_CTRL, g_bssap[bssap_idx].vc_RAN:CTRL_CLIENT);
1057 f_ran_adapter_start(g_bssap[bssap_idx]);
1058 } else {
1059 f_ran_adapter_init(g_bssap[bssap_idx], mp_bssap_cfg[bssap_idx], "VirtMSC", omit);
1060 connect(self:BSSAP, g_bssap[bssap_idx].vc_SCCP:SCCP_SP_PORT);
1061 f_ran_adapter_start(g_bssap[bssap_idx]);
1062 f_legacy_bssap_reset();
1063 }
Harald Welte67089ee2018-01-17 22:19:03 +01001064 }
Harald Welted5833a82018-05-27 16:52:56 +02001065
Neels Hofmeyra460f1f2020-08-09 20:17:03 +00001066 /* start the test with exactly all enabled MSCs allowed to attach */
1067 f_vty_msc_allow_attach(BSCVTY, allow_attach);
1068
Harald Welteffe55fc2018-01-17 22:39:54 +01001069 f_ipa_ctrl_start(mp_bsc_ip, mp_bsc_ctrl_port);
Harald Welte28d943e2017-11-25 15:00:50 +01001070
Daniel Willmann191e0d92018-01-17 12:44:35 +01001071 f_init_mgcp("VirtMSC");
1072
Neels Hofmeyr0b7365b2020-07-04 00:52:34 +02001073 for (var integer i := 0; i < nr_bts; i := i+1) {
1074 f_init_bts(i, handler_mode);
Harald Welte696ddb62017-12-08 14:01:43 +01001075 }
Neels Hofmeyr0b7365b2020-07-04 00:52:34 +02001076}
Harald Welte696ddb62017-12-08 14:01:43 +01001077
Neels Hofmeyr0b7365b2020-07-04 00:52:34 +02001078function f_init_bts(integer bts_idx := 0, boolean handler_mode := false)
1079runs on test_CT {
1080 /* wait until osmo-bts-omldummy has respawned */
1081 f_wait_oml(bts_idx, "degraded", 5.0);
1082
1083 /* start RSL connection */
1084 f_ipa_rsl_start(bts[bts_idx].rsl, mp_bsc_ip, mp_bsc_rsl_port, bts_idx, handler_mode);
1085 /* wait until BSC tells us "connected" */
1086 f_wait_oml(bts_idx, "connected", 5.0);
Harald Welte28d943e2017-11-25 15:00:50 +01001087}
1088
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +02001089function f_init_bts_and_check_sysinfo(integer bts_idx := 0, boolean handler_mode := false,
1090 template SystemInformationConfig expect_si)
1091runs on test_CT {
1092 var default sysinfo := activate(as_catch_RSL_sysinfo(bts_idx));
1093
1094 f_init_bts(bts_idx, handler_mode);
1095
1096 /* Give some time to (hopefully/most likely) collect all system informations from RSL startup.
1097 * We could stop as soon as all expected SI are received, but then we might miss SI that we don't expect and
1098 * that might be sent afterwards. So rather give a generous timeout and be quite sure to catch all SI.
1099 */
1100 f_sleep(5.0);
1101 log("RSL ", bts_idx, " SYSTEM INFORMATION: ", g_system_information[bts_idx]);
1102
1103 deactivate(sysinfo);
1104
1105 if (match(g_system_information[bts_idx], expect_si)) {
1106 setverdict(pass);
1107 } else {
1108 log("RSL ", bts_idx, ": EXPECTED SI: ", expect_si);
1109 log("RSL ", bts_idx, ": GOT SI: ", g_system_information[bts_idx]);
1110 setverdict(fail, "received SI does not match expectations");
1111 return;
1112 }
1113}
1114
Maxd4e56962018-10-31 19:08:25 +01001115/* expect to receive a RSL message matching a specified template on a given BTS / stream */
Harald Welte65e419a2020-08-21 12:38:33 +02001116function 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 +01001117runs on test_CT return RSL_Message {
1118 var ASP_RSL_Unitdata rx_rsl_ud;
1119 timer T := t_secs;
1120
1121 T.start;
1122 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001123 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(t_rx, sid)) -> value rx_rsl_ud {
Harald Welteae026692017-12-09 01:03:01 +01001124 T.stop;
1125 }
1126 [] IPA_RSL[bts_nr].receive { repeat; }
Harald Welteb2917702017-12-10 15:48:52 +01001127 [] T.timeout {
1128 setverdict(fail, "Timeout expecting ", t_rx);
Daniel Willmannafce8662018-07-06 23:11:32 +02001129 mtc.stop;
Harald Welteb2917702017-12-10 15:48:52 +01001130 }
Harald Welteae026692017-12-09 01:03:01 +01001131 }
1132 return rx_rsl_ud.rsl;
1133}
1134
Harald Welte21b46bd2017-12-17 19:46:32 +01001135/* helper function to transmit RSL on a given BTS/stream */
Harald Welte65e419a2020-08-21 12:38:33 +02001136function 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 +01001137runs on test_CT {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001138 IPA_RSL[bts_nr].send(ts_ASP_RSL_UD(t_tx, sid));
Harald Welteae026692017-12-09 01:03:01 +01001139}
1140
1141
Harald Welte4003d112017-12-09 22:35:39 +01001142/* verify we get a CHAN_ACT after CHAN RQD */
Harald Welteae026692017-12-09 01:03:01 +01001143testcase TC_chan_act_noreply() runs on test_CT {
1144 var BSSAP_N_UNITDATA_ind ud_ind;
Harald Welte930d0a72018-03-22 22:08:40 +01001145 var RSL_Message rsl_unused;
Harald Welte28d943e2017-11-25 15:00:50 +01001146
Harald Welte89d42e82017-12-17 16:42:41 +01001147 f_init(1);
Harald Welte28d943e2017-11-25 15:00:50 +01001148
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001149 IPA_RSL[0].send(ts_ASP_RSL_UD(ts_RSL_CHAN_RQD('23'O, 23)));
Harald Welte930d0a72018-03-22 22:08:40 +01001150 rsl_unused := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001151 f_shutdown_helper();
Harald Welte28d943e2017-11-25 15:00:50 +01001152}
1153
Harald Welte4003d112017-12-09 22:35:39 +01001154/* verify if the "chreq:total" counter increments as expected */
1155testcase TC_chan_act_counter() runs on test_CT {
1156 var BSSAP_N_UNITDATA_ind ud_ind;
1157 var integer chreq_total;
Harald Welte930d0a72018-03-22 22:08:40 +01001158 var RSL_Message rsl_unused;
Harald Welte4003d112017-12-09 22:35:39 +01001159
Harald Welte89d42e82017-12-17 16:42:41 +01001160 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +01001161
1162 chreq_total := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total");
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001163 IPA_RSL[0].send(ts_ASP_RSL_UD(ts_RSL_CHAN_RQD('23'O, 23)));
Harald Welte930d0a72018-03-22 22:08:40 +01001164 rsl_unused := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
Harald Welte4003d112017-12-09 22:35:39 +01001165 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total", chreq_total+1);
1166
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001167 f_shutdown_helper();
Harald Welte4003d112017-12-09 22:35:39 +01001168}
1169
Harald Welteae026692017-12-09 01:03:01 +01001170/* CHAN RQD -> CHAN ACT -> CHAN ACT ACK -> RF CHAN REL */
Philipp Maier9c60a622020-07-09 15:08:46 +02001171private function f_TC_chan_act_ack_noest(OCT1 ra := '23'O) runs on test_CT {
Harald Welteae026692017-12-09 01:03:01 +01001172 var RSL_Message rx_rsl;
1173
Harald Welteae026692017-12-09 01:03:01 +01001174 /* Send CHAN RQD and wait for allocation; acknowledge it */
Philipp Maier9c60a622020-07-09 15:08:46 +02001175 var RslChannelNr chan_nr := f_chreq_act_ack(ra);
Harald Welteae026692017-12-09 01:03:01 +01001176
1177 /* expect BSC to disable the channel again if there's no RLL EST IND */
1178 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), T3101_MAX);
1179
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001180 f_shutdown_helper();
Harald Welteae026692017-12-09 01:03:01 +01001181}
1182
Philipp Maier9c60a622020-07-09 15:08:46 +02001183/* Normal variant */
1184testcase TC_chan_act_ack_noest() runs on test_CT {
Philipp Maieraf58db22020-08-12 17:24:40 +02001185 f_init(1);
Philipp Maier9c60a622020-07-09 15:08:46 +02001186 f_TC_chan_act_ack_noest();
1187}
1188
1189/* Emergency call variant */
1190testcase TC_chan_act_ack_noest_emerg() runs on test_CT {
1191 /* See also: 3GPP TS 04.08, Table 9.9, ra=101xxxxx */
Philipp Maieraf58db22020-08-12 17:24:40 +02001192 f_init(1);
1193 f_vty_allow_emerg_bts(true, 0);
Philipp Maier9c60a622020-07-09 15:08:46 +02001194 f_TC_chan_act_ack_noest(ra := 'A5'O);
1195}
1196
Philipp Maier606f07d2020-08-12 17:21:58 +02001197/* Emergency call variant, but emergency calls are not allowed */
1198testcase TC_chan_rqd_emerg_deny() runs on test_CT {
1199 /* See also: 3GPP TS 04.08, Table 9.9, ra=101xxxxx */
1200
1201 var RSL_Message rx_rsl;
1202 var GsmRrMessage rr;
1203
1204 f_init(1);
1205 f_vty_allow_emerg_bts(false, 0);
1206
1207 IPA_RSL[0].clear;
1208 f_ipa_tx(0, ts_RSL_CHAN_RQD('A5'O, 23));
1209
1210 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeC(RSL_MT_IMMEDIATE_ASSIGN_CMD));
1211 rr := dec_GsmRrMessage(rx_rsl.ies[1].body.full_imm_ass_info.payload);
1212 if (rr.header.message_type == IMMEDIATE_ASSIGNMENT_REJECT) {
1213 setverdict(pass);
1214 } else {
1215 setverdict(fail, "immediate assignment not rejected");
1216 }
1217}
1218
Harald Welteae026692017-12-09 01:03:01 +01001219/* Test behavior if MSC never answers to CR */
1220testcase TC_chan_act_ack_est_ind_noreply() runs on test_CT {
Harald Weltef77aef62018-01-28 15:35:42 +01001221 var RslLinkId main_dcch := valueof(ts_RslLinkID_DCCH(0));
1222 var IpaStreamId sid := IPAC_PROTO_RSL_TRX0;
Harald Welteae026692017-12-09 01:03:01 +01001223 var RSL_Message rx_rsl;
Harald Weltef77aef62018-01-28 15:35:42 +01001224 var ASP_RSL_Unitdata rx_rsl_ud;
Harald Welteae026692017-12-09 01:03:01 +01001225
Harald Welte89d42e82017-12-17 16:42:41 +01001226 f_init(1);
Harald Welteae026692017-12-09 01:03:01 +01001227
1228 /* Send CHAN RQD and wait for allocation; acknowledge it */
Harald Welted6939652017-12-13 21:02:46 +01001229 var RslChannelNr chan_nr := f_chreq_act_ack();
Harald Welteae026692017-12-09 01:03:01 +01001230
1231 var octetstring l3 := '00010203040506'O
1232 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
1233
1234 BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3)));
1235
1236 /* expect BSC to disable the channel again if there's no response from MSC */
Harald Weltef77aef62018-01-28 15:35:42 +01001237 /* MS waits 20s (T3210) at LU; 10s (T3230) at CM SERV REQ and 5s (T3220) AT detach */
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001238 f_expect_chan_rel(0, chan_nr, expect_rll_rel_req := false);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001239 f_shutdown_helper();
Harald Welteae026692017-12-09 01:03:01 +01001240}
1241
1242/* Test behavior if MSC answers with CREF to CR */
1243testcase TC_chan_act_ack_est_ind_refused() runs on test_CT {
1244 var BSSAP_N_CONNECT_ind rx_c_ind;
1245 var RSL_Message rx_rsl;
1246
Harald Welte89d42e82017-12-17 16:42:41 +01001247 f_init(1);
Harald Welteae026692017-12-09 01:03:01 +01001248
1249 /* Send CHAN RQD and wait for allocation; acknowledge it */
Harald Welted6939652017-12-13 21:02:46 +01001250 var RslChannelNr chan_nr := f_chreq_act_ack();
Harald Welteae026692017-12-09 01:03:01 +01001251
1252 var octetstring l3 := '00010203040506'O
1253 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
1254
1255 BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) -> value rx_c_ind;
1256 BSSAP.send(ts_BSSAP_DISC_req(rx_c_ind.connectionId, 0));
1257
1258 /* expect BSC to disable the channel */
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001259 f_expect_chan_rel(0, chan_nr, expect_rll_rel_req := false);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001260 f_shutdown_helper();
Harald Welteae026692017-12-09 01:03:01 +01001261}
1262
Harald Welte618ef642017-12-14 14:58:20 +01001263/* CHAN RQD -> CHAN ACT -> CHAN ACT NACK -> RF CHAN REL */
1264testcase TC_chan_act_nack() runs on test_CT {
1265 var RSL_Message rx_rsl;
1266 var integer chact_nack;
1267
Harald Welte89d42e82017-12-17 16:42:41 +01001268 f_init(1);
Harald Welte618ef642017-12-14 14:58:20 +01001269
1270 chact_nack := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chan_act:nack");
1271
1272 f_ipa_tx(0, ts_RSL_CHAN_RQD('33'O, 33));
1273 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
1274 var RslChannelNr chan_nr := rx_rsl.ies[0].body.chan_nr;
1275
1276 f_ipa_tx(0, ts_RSL_CHAN_ACT_NACK(chan_nr, RSL_ERR_EQUIPMENT_FAIL));
1277
1278 /* wait for some time to hope the NACK arrives before the CTRL GET below */
1279 f_sleep(0.5);
1280
1281 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chan_act:nack", chact_nack+1);
1282
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001283 f_shutdown_helper();
Harald Welte618ef642017-12-14 14:58:20 +01001284}
1285
Harald Welte799c97b2017-12-14 17:50:30 +01001286/* Test for channel exhaustion due to RACH overload */
1287testcase TC_chan_exhaustion() runs on test_CT {
1288 var ASP_RSL_Unitdata rsl_ud;
1289 var integer i;
1290 var integer chreq_total, chreq_nochan;
1291
Harald Welte89d42e82017-12-17 16:42:41 +01001292 f_init(1);
Harald Welte799c97b2017-12-14 17:50:30 +01001293
1294 chreq_total := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total");
1295 chreq_nochan := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:no_channel");
1296
Pau Espin Pedrolfe200d72018-12-10 12:41:04 +01001297 /* GSM 04.08 Table 9.9a:
1298 * RA = '33'O -> Establishment cause = 0011xxxx (MS dual rate capable and asks for "TCH/H or TCH/F").
1299 * With current setup, expect 4xSDCCH + 4xTCH/F + 1xTCH/H to succeed */
Philipp Maiercb6cc482018-03-26 13:08:00 +02001300 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 +01001301 var RslChannelNr chan_nr := f_chreq_act_ack('33'O, i);
Harald Welte799c97b2017-12-14 17:50:30 +01001302 }
1303
1304 IPA_RSL[0].clear;
1305
Harald Weltedd8cbf32018-01-28 12:07:52 +01001306 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total",
Philipp Maiercb6cc482018-03-26 13:08:00 +02001307 chreq_total + NUM_TCHF_PER_BTS + NUM_TCHH_PER_BTS + NUM_SDCCH_PER_BTS);
Harald Welte799c97b2017-12-14 17:50:30 +01001308
1309 /* now expect additional channel activations to fail */
1310 f_ipa_tx(0, ts_RSL_CHAN_RQD('42'O, 42));
1311
1312 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001313 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV))) {
Harald Welte799c97b2017-12-14 17:50:30 +01001314 setverdict(fail, "Received CHAN ACT ACK without resources?!?");
1315 }
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001316 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_IMM_ASSIGN(?))) -> value rsl_ud {
Harald Welte799c97b2017-12-14 17:50:30 +01001317 var GsmRrMessage rr;
1318 /* match on IMM ASS REJ */
1319 rr := dec_GsmRrMessage(rsl_ud.rsl.ies[1].body.full_imm_ass_info.payload);
1320 if (rr.header.message_type == IMMEDIATE_ASSIGNMENT_REJECT) {
1321 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total",
Philipp Maiercb6cc482018-03-26 13:08:00 +02001322 chreq_total + NUM_TCHF_PER_BTS + NUM_TCHH_PER_BTS + NUM_SDCCH_PER_BTS+1);
Harald Welte799c97b2017-12-14 17:50:30 +01001323 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:no_channel",
1324 chreq_nochan+1);
1325 setverdict(pass);
1326 } else {
1327 repeat;
1328 }
1329 }
1330 [] IPA_RSL[0].receive { repeat; }
1331 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001332 f_shutdown_helper();
Harald Welte799c97b2017-12-14 17:50:30 +01001333}
1334
Vadim Yanitskiy1ff1fdf2018-11-27 01:32:57 +07001335/* Test channel deactivation due to silence from MS */
1336testcase TC_chan_deact_silence() runs on test_CT {
1337 var RslChannelNr chan_nr;
1338
1339 f_init(1);
1340
1341 /* Request for a dedicated channel */
1342 chan_nr := f_chreq_act_ack('23'O);
1343
1344 /* Wait some time until the channel is released */
1345 f_sleep(2.0);
1346
1347 /* Expect CHANnel RELease */
1348 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001349 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL))) {
Vadim Yanitskiy1ff1fdf2018-11-27 01:32:57 +07001350 log("Received CHANnel RELease");
1351 setverdict(pass);
1352 }
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001353 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_IMM_ASSIGN(?))) {
Vadim Yanitskiy1ff1fdf2018-11-27 01:32:57 +07001354 /* See OS#3709, OsmoBSC should not send Immediate
1355 * Assignment Reject since a dedicated channel was
1356 * already allocated, and Immediate Assignment was
1357 * already sent. */
1358 setverdict(fail, "Unexpected Immediate Assignment!");
1359 }
1360 [] IPA_RSL[0].receive {
1361 setverdict(fail, "Unexpected RSL message!");
1362 }
1363 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001364 f_shutdown_helper();
Vadim Yanitskiy1ff1fdf2018-11-27 01:32:57 +07001365}
1366
Harald Weltecfe2c962017-12-15 12:09:32 +01001367/***********************************************************************
1368 * Assignment Testing
1369 ***********************************************************************/
1370
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02001371/* Verify that the BSC refuses any BSSAP connection from the MSC (They are all BSC->MSC direction,
1372 * except for the inter-BSC handover, MT side) */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001373testcase TC_outbound_connect(integer bssap_idx := 0) runs on test_CT {
Harald Welte89d42e82017-12-17 16:42:41 +01001374 f_init(1);
Harald Weltecfe2c962017-12-15 12:09:32 +01001375
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001376 BSSAP.send(ts_BSSAP_CONNECT_req(g_bssap[bssap_idx].sccp_addr_peer, g_bssap[bssap_idx].sccp_addr_own,
1377 2342, ts_BSSMAP_AssignmentReq));
Harald Weltecfe2c962017-12-15 12:09:32 +01001378 BSSAP.receive(tr_BSSAP_DISC_ind(2342, ?, ?));
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001379 f_shutdown_helper();
Harald Weltecfe2c962017-12-15 12:09:32 +01001380}
1381
Harald Welte16a4adf2017-12-14 18:54:01 +01001382/* Test behavior if MSC answers with CREF to CR */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001383testcase TC_assignment_cic_only(integer bssap_idx := 0) runs on test_CT {
Harald Welte16a4adf2017-12-14 18:54:01 +01001384 var BSSAP_N_CONNECT_ind rx_c_ind;
1385 var RSL_Message rx_rsl;
1386 var DchanTuple dt;
1387
Harald Welte89d42e82017-12-17 16:42:41 +01001388 f_init(1);
Harald Welte16a4adf2017-12-14 18:54:01 +01001389
1390 dt := f_est_dchan('23'O, 23, '00000000'O);
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001391 if (mp_bssap_cfg[bssap_idx].transport == BSSAP_TRANSPORT_AoIP) {
Harald Welte17b27da2018-05-25 20:33:53 +02001392 /* send assignment without AoIP IEs */
1393 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_AssignmentReq(ts_BSSMAP_IE_CIC(0, 1))));
1394 } else {
1395 /* Send assignmetn without CIC in IPA case */
1396 var BSSMAP_IE_AoIP_TransportLayerAddress tla :=
1397 valueof(ts_BSSMAP_IE_AoIP_TLA4('01020304'O, 2342));
1398 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_AssignmentReq(omit, tla)));
1399 }
Harald Welte16a4adf2017-12-14 18:54:01 +01001400 alt {
1401 [] BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_AssignmentComplete)) {
1402 setverdict(fail, "AoIP BSC cannot accept ASSIGNMENT without AoIP Transport IE");
1403 }
Harald Welte235ebf12017-12-15 14:18:16 +01001404 /* TODO: Actually expect GSM0808_CAUSE_REQ_A_IF_TYPE_NOT_SUPP */
Harald Welte16a4adf2017-12-14 18:54:01 +01001405 [] BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_AssignmentFail)) {
1406 setverdict(pass);
1407 }
1408 [] BSSAP.receive { repeat; }
1409 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001410 f_shutdown_helper();
Harald Welte16a4adf2017-12-14 18:54:01 +01001411}
1412
Harald Welteed848512018-05-24 22:27:58 +02001413/* generate an assignment request for either AoIP or SCCPlite */
Pau Espin Pedrol07866632020-09-03 19:10:55 +02001414function 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 +02001415 var PDU_BSSAP ass_cmd;
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02001416 var BSSMAP_IE_Osmo_OsmuxCID osmux_cid := valueof(ts_OsmuxCID(0));
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001417 if (mp_bssap_cfg[bssap_idx].transport == BSSAP_TRANSPORT_AoIP) {
Harald Welteed848512018-05-24 22:27:58 +02001418 var BSSMAP_IE_AoIP_TransportLayerAddress tla :=
Pau Espin Pedrol07866632020-09-03 19:10:55 +02001419 valueof(f_ts_BSSMAP_IE_AoIP_TLA(aoip_tla, 2342));
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02001420 if (osmux_enabled) {
1421 ass_cmd := valueof(ts_BSSMAP_AssignmentReq(omit, tla, osmux_cid));
1422 } else {
1423 ass_cmd := valueof(ts_BSSMAP_AssignmentReq(omit, tla));
1424 }
Harald Welteed848512018-05-24 22:27:58 +02001425 } else {
1426 var BSSMAP_IE_CircuitIdentityCode cic := valueof(ts_BSSMAP_IE_CIC(0,1));
Pau Espin Pedrol096d73d2019-06-06 12:49:17 +02001427 ass_cmd := valueof(ts_BSSMAP_AssignmentReq(cic, omit));
Harald Welteed848512018-05-24 22:27:58 +02001428 }
1429 return ass_cmd;
1430}
1431
Pau Espin Pedrol07866632020-09-03 19:10:55 +02001432function 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 +01001433 var PDU_BSSAP ho_req;
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001434 if (mp_bssap_cfg[bssap_idx].transport == BSSAP_TRANSPORT_AoIP) {
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01001435 var BSSMAP_IE_AoIP_TransportLayerAddress tla :=
Pau Espin Pedrol07866632020-09-03 19:10:55 +02001436 valueof(f_ts_BSSMAP_IE_AoIP_TLA(aoip_tla, 2342));
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01001437 ho_req := valueof(ts_BSSMAP_HandoverRequest(omit, tla));
1438 } else {
1439 var BSSMAP_IE_CircuitIdentityCode cic := valueof(ts_BSSMAP_IE_CIC(0,1));
1440 ho_req := valueof(ts_BSSMAP_HandoverRequest(cic, omit));
1441 }
1442 return ho_req;
1443}
1444
Harald Welteed848512018-05-24 22:27:58 +02001445/* generate an assignment complete template for either AoIP or SCCPlite */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001446function f_gen_exp_compl(boolean expect_osmux := false, integer bssap_idx := 0) return template PDU_BSSAP {
Harald Welteed848512018-05-24 22:27:58 +02001447 var template PDU_BSSAP exp_compl;
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) {
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02001450 if (expect_osmux) {
1451 exp_compl := tr_BSSMAP_AssignmentComplete(omit, ?, osmux_cid);
1452 } else {
1453 exp_compl := tr_BSSMAP_AssignmentComplete(omit, ?, omit);
1454 }
Harald Welteed848512018-05-24 22:27:58 +02001455 } else {
1456 /* CIC is optional "*" as the MSC allocated it */
Pau Espin Pedrol096d73d2019-06-06 12:49:17 +02001457 exp_compl := tr_BSSMAP_AssignmentComplete(*, omit);
Harald Welteed848512018-05-24 22:27:58 +02001458 }
1459 return exp_compl;
1460}
1461
Harald Welte235ebf12017-12-15 14:18:16 +01001462/* Run everything required up to sending a caller-specified assignment command and expect response */
1463function f_assignment_exp(PDU_BSSAP ass_cmd, template PDU_BSSAP exp, charstring fail_text)
1464runs on test_CT {
1465 var BSSAP_N_CONNECT_ind rx_c_ind;
1466 var RSL_Message rx_rsl;
1467 var DchanTuple dt;
1468
Harald Welte89d42e82017-12-17 16:42:41 +01001469 f_init(1);
Harald Welte235ebf12017-12-15 14:18:16 +01001470
1471 dt := f_est_dchan('23'O, 23, '00000000'O);
1472 /* send assignment without AoIP IEs */
1473 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ass_cmd));
1474 alt {
1475 [] BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_AssignmentComplete)) {
1476 if (ischosen(exp.pdu.bssmap.assignmentComplete)) {
1477 setverdict(pass);
1478 } else {
1479 setverdict(fail, fail_text);
1480 }
1481 }
1482 [] BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_AssignmentFail)) {
1483 if (ischosen(exp.pdu.bssmap.assignmentFailure)) {
1484 setverdict(pass);
1485 } else {
1486 setverdict(fail, fail_text);
1487 }
1488 }
1489 [] BSSAP.receive { repeat; }
1490 }
1491}
1492testcase TC_assignment_csd() runs on test_CT {
1493 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
Harald Welteed848512018-05-24 22:27:58 +02001494 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte235ebf12017-12-15 14:18:16 +01001495 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeCSD);
1496 //exp_fail.pdu.bssmap.assignmentFailure.cause.causeValue := int2bit(enum2int(GSM0808_CAUSE_REQ_CODEC_TYPE_OR_CONFIG_UNAVAIL), 7);
1497 f_assignment_exp(ass_cmd, exp_fail, "BSC accepted Assignment for CSD");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001498 f_shutdown_helper();
Harald Welte235ebf12017-12-15 14:18:16 +01001499}
1500
1501testcase TC_assignment_ctm() runs on test_CT {
1502 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
Harald Welteed848512018-05-24 22:27:58 +02001503 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte235ebf12017-12-15 14:18:16 +01001504 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeCTM);
1505 //exp_fail.pdu.bssmap.assignmentFailure.cause.causeValue := int2bit(enum2int(GSM0808_CAUSE_REQ_CODEC_TYPE_OR_CONFIG_UNAVAIL), 7);
1506 f_assignment_exp(ass_cmd, exp_fail, "BSC accepted Assignment for Speech+CTM");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001507 f_shutdown_helper();
Harald Welte235ebf12017-12-15 14:18:16 +01001508}
1509
Harald Welte4003d112017-12-09 22:35:39 +01001510type record DchanTuple {
1511 integer sccp_conn_id,
1512 RslChannelNr rsl_chan_nr
Harald Weltea5d2ab22017-12-09 14:21:42 +01001513}
1514
Harald Welted6939652017-12-13 21:02:46 +01001515/* Send CHAN RQD and wait for allocation; acknowledge it */
1516private function f_chreq_act_ack(OCT1 ra := '23'O, GsmFrameNumber fn := 23)
1517runs on test_CT return RslChannelNr {
1518 var RSL_Message rx_rsl;
1519 f_ipa_tx(0, ts_RSL_CHAN_RQD(ra, fn));
1520 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
1521 var RslChannelNr chan_nr := rx_rsl.ies[0].body.chan_nr;
1522 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, fn+10));
Daniel Willmannf4ac4ce2018-08-02 14:06:30 +02001523 rx_rsl := f_exp_ipa_rx(0, tr_RSL_IMM_ASSIGN(0));
Harald Welted6939652017-12-13 21:02:46 +01001524 return chan_nr;
1525}
1526
Harald Welte4003d112017-12-09 22:35:39 +01001527/* helper function to establish a dedicated channel via BTS and MSC */
1528function f_est_dchan(OCT1 ra, GsmFrameNumber fn, octetstring l3)
1529runs on test_CT return DchanTuple {
1530 var BSSAP_N_CONNECT_ind rx_c_ind;
Harald Welte4003d112017-12-09 22:35:39 +01001531 var DchanTuple dt;
Harald Weltea5d2ab22017-12-09 14:21:42 +01001532
Harald Welte4003d112017-12-09 22:35:39 +01001533 /* Send CHAN RQD and wait for allocation; acknowledge it */
Harald Welted6939652017-12-13 21:02:46 +01001534 dt.rsl_chan_nr := f_chreq_act_ack(ra, fn);
Harald Welte4003d112017-12-09 22:35:39 +01001535
1536 f_ipa_tx(0, ts_RSL_EST_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
1537
1538 BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) -> value rx_c_ind;
1539 dt.sccp_conn_id := rx_c_ind.connectionId;
1540 BSSAP.send(ts_BSSAP_CONNECT_res(dt.sccp_conn_id));
1541
1542 return dt;
Harald Weltea5d2ab22017-12-09 14:21:42 +01001543}
1544
Harald Welte641fcbe2018-06-14 10:58:35 +02001545/* expect RF CAN REL from BTS, acknowledge it and clear the MSC side */
1546private function f_exp_chan_rel_and_clear(DchanTuple dt, integer bts_nr := 0) runs on test_CT {
1547 var RSL_Message rx_rsl;
1548 /* expect BSC to disable the channel */
1549 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), T3101_MAX);
1550 /* respond with CHAN REL ACK */
1551 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(dt.rsl_chan_nr));
1552
1553 /* expect Clear Complete from BSC */
1554 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete));
1555
1556 /* MSC disconnects as instructed. */
1557 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
1558}
1559
Harald Welte4003d112017-12-09 22:35:39 +01001560/* Test behavior of channel release after unilateral RLL REL IND (DISC from MS) */
1561testcase TC_chan_rel_rll_rel_ind() runs on test_CT {
Neels Hofmeyr27f64362018-03-12 01:44:00 +01001562 var BSSAP_N_DATA_ind rx_di;
Harald Welte4003d112017-12-09 22:35:39 +01001563 var DchanTuple dt;
Harald Welte96c94412017-12-09 03:12:45 +01001564
Harald Welte89d42e82017-12-17 16:42:41 +01001565 f_init(1);
Harald Welte96c94412017-12-09 03:12:45 +01001566
Harald Welte4003d112017-12-09 22:35:39 +01001567 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1568
1569 /* simulate RLL REL IND */
1570 f_ipa_tx(0, ts_RSL_REL_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0))));
1571
Neels Hofmeyr27f64362018-03-12 01:44:00 +01001572 /* expect Clear Request on MSC side */
1573 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearRequest)) -> value rx_di;
1574
1575 /* Instruct BSC to clear channel */
1576 var BssmapCause cause := bit2int(rx_di.userData.pdu.bssmap.clearRequest.cause.causeValue);
1577 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
1578
Harald Welte4003d112017-12-09 22:35:39 +01001579 /* expect BSC to disable the channel */
Harald Welte641fcbe2018-06-14 10:58:35 +02001580 f_exp_chan_rel_and_clear(dt, 0);
Neels Hofmeyr27f64362018-03-12 01:44:00 +01001581
1582 /* wait for SCCP emulation to do its job */
1583 f_sleep(1.0);
Harald Welte4003d112017-12-09 22:35:39 +01001584
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001585 f_shutdown_helper();
Harald Welte4003d112017-12-09 22:35:39 +01001586}
1587
1588/* Test behavior of channel release after CONN FAIL IND from BTS */
1589testcase TC_chan_rel_conn_fail() runs on test_CT {
1590 var BSSAP_N_DATA_ind rx_di;
Harald Welte4003d112017-12-09 22:35:39 +01001591 var DchanTuple dt;
1592
Harald Welte89d42e82017-12-17 16:42:41 +01001593 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +01001594
1595 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1596
1597 /* simulate CONN FAIL IND */
Harald Weltea8ed9062017-12-14 09:46:01 +01001598 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 +01001599 /* TODO: different cause values? */
1600
Harald Welte4003d112017-12-09 22:35:39 +01001601 /* expect Clear Request from BSC */
1602 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearRequest)) -> value rx_di;
1603
1604 /* Instruct BSC to clear channel */
1605 var BssmapCause cause := bit2int(rx_di.userData.pdu.bssmap.clearRequest.cause.causeValue);
1606 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
1607
Harald Welte6ff76ea2018-01-28 13:08:01 +01001608 /* expect BSC to disable the channel */
Harald Welte641fcbe2018-06-14 10:58:35 +02001609 f_exp_chan_rel_and_clear(dt, 0);
Harald Welte4003d112017-12-09 22:35:39 +01001610
1611 /* wait for SCCP emulation to do its job */
1612 f_sleep(1.0);
1613
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001614 f_shutdown_helper();
Harald Welte4003d112017-12-09 22:35:39 +01001615}
1616
Harald Welte99f3ca02018-06-14 13:40:29 +02001617/* Test behavior of early CONN FAIL IND from BTS (before EST IND!) */
1618/* See also https://www.osmocom.org/issues/3182 */
1619testcase TC_early_conn_fail() runs on test_CT {
1620 var RSL_Message rx_rsl;
1621 var DchanTuple dt;
1622
1623 f_init(1);
1624
1625 /* BTS->BSC: Send CHAN RQD and wait for allocation; acknowledge it */
1626 dt.rsl_chan_nr := f_chreq_act_ack(f_rnd_octstring(1), 23);
1627
1628 /* BTS->BSC: simulate CONN FAIL IND */
1629 f_ipa_tx(0, ts_RSL_CONN_FAIL_IND(dt.rsl_chan_nr, RSL_ERR_RADIO_LINK_FAIL));
1630
1631 /* BTS->BSC: Expect RF channel release from BSC on Abis */
1632 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), 10.0);
1633
1634 /* BTS<-BSC: respond with CHAN REL ACK */
1635 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(dt.rsl_chan_nr));
1636
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001637 f_shutdown_helper();
Harald Welte99f3ca02018-06-14 13:40:29 +02001638}
1639
1640/* Test behavior of late CONN FAIL IND from BTS (ater REL IND!) */
1641/* See also https://www.osmocom.org/issues/3182 */
1642testcase TC_late_conn_fail() runs on test_CT {
1643 var RSL_Message rx_rsl;
1644 var DchanTuple dt;
1645
1646 f_init(1);
1647
1648 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1649
1650 /* BSC<-MSC: Instruct BSC to clear connection */
1651 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(0)));
1652
1653 /* BTS->BSC: expect BSC to deactivate SACCH */
1654 rx_rsl := f_exp_ipa_rx(0, tr_RSL_DEACT_SACCH(dt.rsl_chan_nr));
1655
1656 /* BTS->BSC: simulate a late CONN FAIL IND from BTS */
1657 f_ipa_tx(0, ts_RSL_CONN_FAIL_IND(dt.rsl_chan_nr, RSL_ERR_RADIO_LINK_FAIL));
1658
1659 /* BTS<-BSC: Expect RF channel release from BSC on Abis */
1660 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), 10.0);
1661 /* BTS->BSC: respond with CHAN REL ACK */
1662 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(dt.rsl_chan_nr));
1663
1664 /* BSC->MSC: expect Clear Complete from BSC */
1665 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete));
1666
1667 /* BSC<-MSC: MSC disconnects as requested. */
1668 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
1669
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001670 f_shutdown_helper();
Harald Welte99f3ca02018-06-14 13:40:29 +02001671}
1672
Neels Hofmeyrf44ccd12018-11-05 19:15:23 +01001673function f_expect_chan_rel(integer bts_nr, RslChannelNr rsl_chan_nr,
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001674 boolean expect_deact_sacch := true,
1675 boolean expect_rr_chan_rel := true,
1676 boolean expect_rll_rel_req := true,
Harald Welte99787102019-02-04 10:41:36 +01001677 boolean handle_rll_rel := true,
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02001678 boolean is_csfb := false,
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02001679 template CellSelIndValue csfb_expect_cells := omit,
1680 template RR_Cause expect_rr_cause := ?
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001681 ) runs on test_CT {
Harald Welte91d54a52018-01-28 15:35:07 +01001682
1683 var RslLinkId main_dcch := valueof(ts_RslLinkID_DCCH(0));
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001684 var boolean got_deact_sacch := false;
1685 var boolean got_rr_chan_rel := false;
1686 var boolean got_rll_rel_req := false;
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02001687 var ASP_RSL_Unitdata ud;
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02001688 var RSL_IE_Body l3_ie;
1689 var PDU_ML3_NW_MS l3;
1690 var RR_Cause got_cause;
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001691 log("f_expect_chan_rel() expecting: expect_deact_sacch=", expect_deact_sacch, " expect_rr_chan_rel=", expect_rr_chan_rel,
1692 " expect_rll_rel_req=", expect_rll_rel_req);
Harald Welte91d54a52018-01-28 15:35:07 +01001693 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001694 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(tr_RSL_DEACT_SACCH(rsl_chan_nr))) {
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001695 got_deact_sacch := true;
Harald Welte91d54a52018-01-28 15:35:07 +01001696 repeat;
1697 }
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02001698 [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 +01001699 got_rr_chan_rel := true;
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02001700
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02001701 if (f_rsl_find_ie(ud.rsl, RSL_IE_L3_INFO, l3_ie) == false) {
1702 setverdict(fail, "cannot find L3");
1703 mtc.stop;
1704 }
1705 l3 := dec_PDU_ML3_NW_MS(l3_ie.l3_info.payload);
1706
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02001707 if (not istemplatekind(csfb_expect_cells, "omit")) {
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02001708 var CellSelIndValue cells := dec_CellSelIndValue(
1709 l3.msgs.rrm.channelRelease.cellSelectionIndicator.cellSelectionIndicatorValue);
1710
1711 log("GOT RR CHANNEL RELEASE CSFB CELLS: ", cells);
1712 if (match(cells, csfb_expect_cells)) {
1713 setverdict(pass);
1714 } else {
1715 log("EXPECTED CSFB CELLS: ", csfb_expect_cells);
1716 setverdict(fail, "Received CSFB cells list on RR Channel Release does not match expectations");
1717 }
1718 }
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02001719
1720 if (not istemplatekind(expect_rr_cause, "omit")) {
1721 int2enum(oct2int(l3.msgs.rrm.channelRelease.rRCause.valuePart), got_cause);
1722 log("GOT CAUSE CODE: ", l3.msgs.rrm.channelRelease.rRCause.valuePart, " = ", got_cause);
1723 if (match(got_cause, expect_rr_cause)) {
1724 setverdict(pass);
1725 } else {
1726 log("EXPECTED CAUSE CODE: ", expect_rr_cause);
1727 setverdict(fail, "Received RR Channel Release Cause code does not match expectations");
1728 }
1729 }
Harald Welte99787102019-02-04 10:41:36 +01001730 repeat;
1731 }
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02001732 [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 +01001733 got_rr_chan_rel := true;
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02001734
1735 if (not istemplatekind(expect_rr_cause, "omit")) {
1736 if (f_rsl_find_ie(ud.rsl, RSL_IE_L3_INFO, l3_ie) == false) {
1737 setverdict(fail, "cannot find L3");
1738 mtc.stop;
1739 }
1740 l3 := dec_PDU_ML3_NW_MS(l3_ie.l3_info.payload);
1741
1742 int2enum(oct2int(l3.msgs.rrm.channelRelease.rRCause.valuePart), got_cause);
1743 log("GOT CAUSE CODE: ", l3.msgs.rrm.channelRelease.rRCause.valuePart, " = ", got_cause);
1744 if (match(got_cause, expect_rr_cause)) {
1745 setverdict(pass);
1746 } else {
1747 log("EXPECTED CAUSE CODE: ", expect_rr_cause);
1748 setverdict(fail, "Received RR Channel Release Cause code does not match expectations");
1749 }
1750 }
Neels Hofmeyr211169d2018-11-07 00:37:29 +01001751 repeat;
1752 }
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001753 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(tr_RSL_REL_REQ(rsl_chan_nr, ?))) {
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001754 got_rll_rel_req := true;
Harald Welte91d54a52018-01-28 15:35:07 +01001755 /* FIXME: Why are we getting this for LinkID SACCH? */
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001756 if (handle_rll_rel) {
1757 f_ipa_tx(0, ts_RSL_REL_CONF(rsl_chan_nr, main_dcch));
1758 }
Harald Welte91d54a52018-01-28 15:35:07 +01001759 repeat;
1760 }
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001761 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL))) {
Harald Welte91d54a52018-01-28 15:35:07 +01001762 /* respond with CHAN REL ACK */
1763 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(rsl_chan_nr));
1764 }
1765 /* ignore any user data */
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001766 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(tr_RSL_MsgTypeR(?))) {
Harald Welte91d54a52018-01-28 15:35:07 +01001767 repeat;
1768 }
1769 }
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001770
1771 log("f_expect_chan_rel() summary: got_deact_sacch=", got_deact_sacch, " got_rr_chan_rel=", got_rr_chan_rel,
1772 " got_rll_rel_req=", got_rll_rel_req);
1773
1774 if (expect_deact_sacch != got_deact_sacch) {
1775 setverdict(fail, "f_expect_chan_rel(): expect_deact_sacch=", expect_deact_sacch, " got_deact_sacch=", got_deact_sacch);
1776 }
1777 if (expect_rr_chan_rel != got_rr_chan_rel) {
1778 setverdict(fail, "f_expect_chan_rel(): expect_rr_chan_rel=", expect_rr_chan_rel, " got_rr_chan_rel=", got_rr_chan_rel);
1779 }
1780 if (expect_rll_rel_req != got_rll_rel_req) {
1781 setverdict(fail, "f_expect_chan_rel(): expect_rll_rel_req=", expect_rll_rel_req, " got_rll_rel_req=", got_rll_rel_req);
1782 }
Harald Welte91d54a52018-01-28 15:35:07 +01001783}
1784
Harald Welte4003d112017-12-09 22:35:39 +01001785/* Test behavior of channel release after hard Clear Command from MSC */
1786testcase TC_chan_rel_hard_clear() runs on test_CT {
1787 var BSSAP_N_DATA_ind rx_di;
Harald Welte4003d112017-12-09 22:35:39 +01001788 var DchanTuple dt;
Harald Welte4003d112017-12-09 22:35:39 +01001789
Harald Welte89d42e82017-12-17 16:42:41 +01001790 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +01001791
1792 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1793
1794 /* Instruct BSC to clear channel */
1795 var BssmapCause cause := 0;
1796 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
1797
1798 /* expect Clear Complete from BSC on A */
1799 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete)) {
1800 /* release the SCCP connection */
1801 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
1802 }
1803
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001804 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001805 f_shutdown_helper();
Harald Welte4003d112017-12-09 22:35:39 +01001806}
1807
Harald Welte99787102019-02-04 10:41:36 +01001808/* Test behavior of channel release after Clear Command with CSFB indicator from MSC */
1809testcase TC_chan_rel_hard_clear_csfb() runs on test_CT {
1810 var BSSAP_N_DATA_ind rx_di;
1811 var DchanTuple dt;
1812
1813 f_init(1);
1814
1815 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1816
1817 /* Instruct BSC to clear channel */
1818 var BssmapCause cause := 0;
1819 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommandCSFB(cause)));
1820
1821 /* expect Clear Complete from BSC on A */
1822 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete)) {
1823 /* release the SCCP connection */
1824 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
1825 }
1826
1827 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 +02001828 f_shutdown_helper();
Harald Welte99787102019-02-04 10:41:36 +01001829}
1830
Harald Welted8c36cd2017-12-09 23:05:31 +01001831/* Test behavior of channel release after hard RLSD from MSC */
1832testcase TC_chan_rel_hard_rlsd() runs on test_CT {
Harald Welted8c36cd2017-12-09 23:05:31 +01001833 var DchanTuple dt;
Harald Welted8c36cd2017-12-09 23:05:31 +01001834
Harald Welte89d42e82017-12-17 16:42:41 +01001835 f_init(1);
Harald Welted8c36cd2017-12-09 23:05:31 +01001836
1837 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1838
1839 /* release the SCCP connection */
1840 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
1841
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001842 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001843 f_shutdown_helper();
Harald Welted8c36cd2017-12-09 23:05:31 +01001844}
1845
Harald Welte550daf92018-06-11 19:22:13 +02001846/* Test behavior of channel release after hard RLSD from MSC and MS is not responding to RLL REL REQ */
1847testcase TC_chan_rel_hard_rlsd_ms_dead() runs on test_CT {
1848 var DchanTuple dt;
1849
1850 f_init(1);
1851
1852 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1853
1854 /* release the SCCP connection */
1855 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
1856
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001857 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001858 f_shutdown_helper();
Harald Welte550daf92018-06-11 19:22:13 +02001859}
1860
Harald Welte85804d42017-12-10 14:11:58 +01001861/* Test behavior of channel release after BSSMAP RESET from MSC */
1862testcase TC_chan_rel_a_reset() runs on test_CT {
Harald Welte85804d42017-12-10 14:11:58 +01001863 var DchanTuple dt;
Harald Welte85804d42017-12-10 14:11:58 +01001864
Harald Welte89d42e82017-12-17 16:42:41 +01001865 f_init(1);
Harald Welte85804d42017-12-10 14:11:58 +01001866
1867 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1868
1869 /* Clear the queue, it might still contain stuff like IMMEDIATE ASSIGN */
1870 IPA_RSL[0].clear;
1871
1872 /* perform BSSAP RESET, expect RESET ACK and DISC.ind on connection */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001873 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 +01001874 interleave {
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001875 [] 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 +01001876 [] BSSAP.receive(tr_BSSAP_DISC_ind(dt.sccp_conn_id, ?, ?)) { }
1877 }
1878
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001879 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001880 f_shutdown_helper();
Harald Welte85804d42017-12-10 14:11:58 +01001881}
1882
Pau Espin Pedrolc675b612020-01-09 19:55:40 +01001883/* Verify T(iar) triggers and releases the channel */
1884testcase TC_chan_rel_sccp_tiar_timeout() runs on test_CT {
1885 var DchanTuple dt;
1886
1887 /* Set T(iar) in BSC low enough that it will trigger before other side
1888 has time to keep alive with a T(ias). Keep recommended ratio of
1889 T(iar) >= T(ias)*2 */
1890 g_bsc_sccp_timer_ias := 2;
1891 g_bsc_sccp_timer_iar := 5;
1892
1893 f_init(1);
1894
1895 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1896 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001897 f_shutdown_helper();
Pau Espin Pedrolc675b612020-01-09 19:55:40 +01001898}
1899
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02001900private function f_tc_chan_rel_rr_cause(myBSSMAP_Cause clear_cmd_cause, template RR_Cause expect_rr_cause)
1901runs on test_CT
1902{
1903 var DchanTuple dt;
1904
1905 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1906 var BssmapCause cause := 0;
1907 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(enum2int(clear_cmd_cause))));
1908 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete)) {
1909 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
1910 }
1911
1912 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 +02001913 f_shutdown_helper();
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02001914}
1915
1916/* Test that Clear Command cause codes affect the RR Channel Release cause code */
1917testcase TC_chan_rel_rr_cause() runs on test_CT {
1918 f_init(1);
1919
1920 f_tc_chan_rel_rr_cause(GSM0808_CAUSE_CALL_CONTROL, GSM48_RR_CAUSE_NORMAL);
1921 f_tc_chan_rel_rr_cause(GSM0808_CAUSE_HANDOVER_SUCCESSFUL, GSM48_RR_CAUSE_NORMAL);
1922 f_tc_chan_rel_rr_cause(GSM0808_CAUSE_PREEMPTION, GSM48_RR_CAUSE_PREMPTIVE_REL);
1923 f_tc_chan_rel_rr_cause(GSM0808_CAUSE_RADIO_INTERFACE_MESSAGE_FAILURE, GSM48_RR_CAUSE_PROT_ERROR_UNSPC);
1924 f_tc_chan_rel_rr_cause(GSM0808_CAUSE_RADIO_INTERFACE_FAILURE, GSM48_RR_CAUSE_ABNORMAL_UNSPEC);
1925 f_tc_chan_rel_rr_cause(GSM0808_CAUSE_EQUIPMENT_FAILURE, GSM48_RR_CAUSE_ABNORMAL_UNSPEC);
1926}
1927
Harald Welte5cd20ed2017-12-13 21:03:20 +01001928/* Test behavior if RSL EST IND for non-active channel */
1929testcase TC_rll_est_ind_inact_lchan() runs on test_CT {
1930 timer T := 2.0;
1931
Harald Welte89d42e82017-12-17 16:42:41 +01001932 f_init(1);
Harald Welte5cd20ed2017-12-13 21:03:20 +01001933
1934 var octetstring l3 := '00010203040506'O;
1935 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(6));
1936 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
1937
1938 T.start;
1939 alt {
1940 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) {
1941 setverdict(fail, "MSC received COMPL L3 for non-active lchan");
1942 }
1943 [] BSSAP.receive {}
1944 [] IPA_RSL[0].receive {}
1945 [] T.timeout {}
1946 }
1947
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001948 f_shutdown_helper();
Harald Welte5cd20ed2017-12-13 21:03:20 +01001949}
1950
1951/* Test behavior if RSL EST IND for invalid SAPI */
1952testcase TC_rll_est_ind_inval_sapi1() runs on test_CT {
1953 var RslChannelNr chan_nr;
1954
Harald Welte89d42e82017-12-17 16:42:41 +01001955 f_init(1);
Harald Welte5cd20ed2017-12-13 21:03:20 +01001956
1957 chan_nr := f_chreq_act_ack()
1958
1959 var octetstring l3 := '00010203040506'O;
1960 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(1)), l3));
1961
1962 timer T := 2.0;
1963 T.start;
1964 alt {
1965 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) {
1966 setverdict(fail, "MSC received COMPL L3 for invalid SAPI 1");
1967 }
1968 [] BSSAP.receive { repeat; }
1969 [] IPA_RSL[0].receive { repeat; }
1970 [] T.timeout {}
1971 }
1972
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001973 f_shutdown_helper();
Harald Welte5cd20ed2017-12-13 21:03:20 +01001974}
1975
1976/* Test behavior if RSL EST IND for invalid SAPI */
1977testcase TC_rll_est_ind_inval_sapi3() runs on test_CT {
1978 timer T := 2.0;
1979
Harald Welte89d42e82017-12-17 16:42:41 +01001980 f_init(1);
Harald Welte5cd20ed2017-12-13 21:03:20 +01001981
1982 var RslChannelNr chan_nr := f_chreq_act_ack();
1983
1984 var octetstring l3 := '00010203040506'O;
1985 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(3)), l3));
1986
1987 T.start;
1988 alt {
1989 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) {
1990 setverdict(fail, "MSC received COMPL L3 for invalid SAPI 3");
1991 }
1992 [] BSSAP.receive { repeat; }
1993 [] IPA_RSL[0].receive { repeat; }
1994 [] T.timeout {}
1995 }
1996
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02001997 f_shutdown_helper();
Harald Welte5cd20ed2017-12-13 21:03:20 +01001998}
1999
2000/* Test behavior if RSL EST IND for invalid SACCH */
2001testcase TC_rll_est_ind_inval_sacch() runs on test_CT {
2002 timer T := 2.0;
2003
Harald Welte89d42e82017-12-17 16:42:41 +01002004 f_init(1);
Harald Welte5cd20ed2017-12-13 21:03:20 +01002005
2006 var RslChannelNr chan_nr := f_chreq_act_ack();
2007
2008 var octetstring l3 := '00010203040506'O;
2009 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_SACCH(0)), l3));
2010
2011 T.start;
2012 alt {
2013 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) {
2014 setverdict(fail, "MSC received COMPL L3 for invalid Link SACCH");
2015 }
2016 [] BSSAP.receive { repeat; }
2017 [] IPA_RSL[0].receive { repeat; }
2018 [] T.timeout {}
2019 }
2020
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002021 f_shutdown_helper();
Harald Welte5cd20ed2017-12-13 21:03:20 +01002022}
2023
Vadim Yanitskiy6ef5dfa2020-08-28 18:04:41 +07002024private function f_exp_sapi_n_reject(template (present) GsmSapi sapi := ?,
2025 template myBSSMAP_Cause cause := ?,
2026 float T_val := 2.0)
2027runs on test_CT {
2028 var BSSAP_N_DATA_ind rx_di;
2029 timer T;
2030
2031 var template BSSMAP_IE_Cause tr_cause := tr_BSSMAP_IE_Cause(cause);
2032 var template PDU_BSSAP tr_pdu := tr_BSSMAP_SAPInReject(sapi);
2033
2034 T.start(T_val);
2035 alt {
2036 [] BSSAP.receive(tr_BSSAP_DATA_ind(?, tr_pdu)) -> value rx_di {
2037 var BSSMAP_IE_Cause rx_cause := rx_di.userData.pdu.bssmap.sAPInReject.cause;
2038 if (not match(rx_cause, tr_cause)) {
2039 setverdict(fail, "Rx unexpected Cause IE: ",
2040 rx_cause, " vs expected ", tr_cause);
2041 }
2042 setverdict(pass);
2043 }
2044 [] BSSAP.receive(BSSAP_N_DATA_ind:?) -> value rx_di {
2045 setverdict(fail, "Rx unexpected BSSAP PDU: ", rx_di);
2046 }
2047 [] T.timeout {
2048 setverdict(fail, "Timeout waiting for BSSMAP SAPI N Reject");
2049 }
2050 }
2051}
2052
2053/* Check if we get SAPI N Reject on receipt of unexpected RLL RELease INDication */
2054testcase TC_rll_rel_ind_sapi_n_reject() runs on test_CT {
2055 var octetstring rnd_data := f_rnd_octstring(16);
2056 var RSL_Message rx_rsl;
2057 var DchanTuple dt;
2058
2059 f_init(1);
2060
2061 /* MS establishes a SAPI=0 link on DCCH */
2062 dt := f_est_dchan(f_rnd_ra_cs(), 23, rnd_data);
2063
2064 /* MSC sends some data on (not yet established) SAPI=3 link */
2065 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSAP_DTAP(rnd_data, '03'O)));
2066 /* BSC attempts to establish a SAPI=3 link on DCCH */
2067 rx_rsl := f_exp_ipa_rx(0, tr_RSL_EST_REQ(dt.rsl_chan_nr, tr_RslLinkID_DCCH(3)));
2068
2069 /* MS sends unexpected RELease INDication on SAPI=3 */
2070 f_ipa_tx(0, ts_RSL_REL_IND(dt.rsl_chan_nr, ts_RslLinkID_DCCH(3)));
2071 /* We expect to receive BSSMAP SAPI N Reject message from the BSC */
2072 f_exp_sapi_n_reject(3, GSM0808_CAUSE_MS_NOT_EQUIPPED);
2073
2074 /* Clean up the connection */
2075 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
2076 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
2077
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002078 f_shutdown_helper();
Vadim Yanitskiy6ef5dfa2020-08-28 18:04:41 +07002079}
2080
2081/* Check if we get SAPI N Reject on receipt of unexpected RLL ERROR INDication */
2082testcase TC_rll_err_ind_sapi_n_reject() runs on test_CT {
2083 var octetstring rnd_data := f_rnd_octstring(16);
2084 var RSL_Message rx_rsl;
2085 var DchanTuple dt;
2086
2087 f_init(1);
2088
2089 /* MS establishes a SAPI=0 link on DCCH */
2090 dt := f_est_dchan(f_rnd_ra_cs(), 23, rnd_data);
2091
2092 /* MSC sends some data on (not yet established) SAPI=3 link */
2093 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSAP_DTAP(rnd_data, '03'O)));
2094 /* BSC attempts to establish a SAPI=3 link on DCCH */
2095 rx_rsl := f_exp_ipa_rx(0, tr_RSL_EST_REQ(dt.rsl_chan_nr, tr_RslLinkID_DCCH(3)));
2096
2097 /* BTS sends unexpected ERROR INDication on SAPI=3 */
2098 f_ipa_tx(0, ts_RSL_ERROR_IND(dt.rsl_chan_nr, ts_RslLinkID_DCCH(3), ''O));
2099 /* We expect to receive BSSMAP SAPI N Reject message from the BSC */
2100 f_exp_sapi_n_reject(3, GSM0808_CAUSE_BSS_NOT_EQUIPPED);
2101
2102 /* Clean up the connection */
2103 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
2104 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
2105
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002106 f_shutdown_helper();
Vadim Yanitskiy6ef5dfa2020-08-28 18:04:41 +07002107}
2108
2109/* Check if we get SAPI N Reject due to a SAPI=3 link establishment timeout */
2110testcase TC_rll_timeout_sapi_n_reject() runs on test_CT {
2111 var octetstring rnd_data := f_rnd_octstring(16);
2112 var RSL_Message rx_rsl;
2113 var DchanTuple dt;
2114
2115 f_init(1);
2116
2117 /* MS establishes a SAPI=0 link on DCCH */
2118 dt := f_est_dchan(f_rnd_ra_cs(), 23, rnd_data);
2119
2120 /* MSC sends some data on (not yet established) SAPI=3 link */
2121 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSAP_DTAP(rnd_data, '03'O)));
2122 /* BSC attempts to establish a SAPI=3 link on DCCH */
2123 rx_rsl := f_exp_ipa_rx(0, tr_RSL_EST_REQ(dt.rsl_chan_nr, tr_RslLinkID_DCCH(3)));
2124
2125 /* MS does not respond, so the link establishment timeout triggers SAPI N Reject */
2126 f_exp_sapi_n_reject(3, GSM0808_CAUSE_BSS_NOT_EQUIPPED, T_val := 8.0);
2127
2128 /* Clean up the connection */
2129 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
2130 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
2131
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002132 f_shutdown_helper();
Vadim Yanitskiy6ef5dfa2020-08-28 18:04:41 +07002133}
2134
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +02002135testcase TC_si_default() runs on test_CT {
2136 f_init(0);
2137 f_init_bts_and_check_sysinfo(0, expect_si := SystemInformationConfig_default);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002138 f_shutdown_helper();
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +02002139}
Harald Welte4003d112017-12-09 22:35:39 +01002140
Neels Hofmeyr56f24782020-07-09 00:50:49 +02002141/* We're testing SI2quater with lists of EARFCNs. Instead of just incrementing EARFCNs, also pick some from the edges of
2142 * the entire value range. This function provides the same EARFCN numbers for the same earfcn_index */
2143private function f_test_si2quater_earfcn_by_idx(integer earfcn_index) return uint16_t
2144{
2145 select (earfcn_index) {
2146 case (0) {
2147 /* E-ARFCN 111 is already added in the osmo-bsc.cfg */
2148 return 111;
2149 }
2150 case (1) {
2151 return 1;
2152 }
2153 case (2) {
2154 return 0;
2155 }
2156 case (3) {
2157 return 65535;
2158 }
2159 case else {
2160 return 23 * (earfcn_index - 3);
2161 }
2162 }
2163}
2164
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02002165function f_test_si2quater(integer total_earfcns, template SystemInformationConfig expect_si,
2166 template CellSelIndValue expect_cells := omit) runs on test_CT {
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002167
2168 f_init(0);
2169
2170 /* E-ARFCN 111 is already added in the osmo-bsc.cfg, so only add more arfcns if total_earfcns > 1 */
2171 for (var integer i := 1; i < total_earfcns; i := i + 1) {
Neels Hofmeyr56f24782020-07-09 00:50:49 +02002172 f_bts_0_cfg(BSCVTY, {"si2quater neighbor-list add earfcn " & int2str(f_test_si2quater_earfcn_by_idx(i))
2173 & " thresh-hi 20 thresh-lo 10 prio 3 qrxlv 22 meas 3"});
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002174 }
2175
2176 f_init_bts_and_check_sysinfo(0, expect_si := expect_si);
2177
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02002178 f_init(1);
2179
2180 if (not istemplatekind(expect_cells, "omit")) {
2181 /* Also check that RR Channel Release contains these EARFCNs.
2182 * (copied code from TC_chan_rel_hard_clear_csfb) */
2183 var BSSAP_N_DATA_ind rx_di;
2184 var DchanTuple dt;
2185
2186 dt := f_est_dchan('23'O, 23, '00010203040506'O);
2187
2188 /* Instruct BSC to clear channel */
2189 var BssmapCause cause := 0;
2190 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommandCSFB(cause)));
2191
2192 /* expect Clear Complete from BSC on A */
2193 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete)) {
2194 /* release the SCCP connection */
2195 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
2196 }
2197
2198 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false, is_csfb := true,
2199 csfb_expect_cells := expect_cells);
2200 }
2201
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002202 for (var integer i := 1; i < total_earfcns; i := i + 1) {
Neels Hofmeyr56f24782020-07-09 00:50:49 +02002203 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 +02002204 }
2205}
2206
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002207private function f_tr_si2quater_earfcns(integer count) return template SI2quaterRestOctetsList
2208{
2209 var template SI2quaterRestOctetsList si2quater := {};
2210 var integer si2quater_count := (count + 2) / 3;
2211
2212 for (var integer i := 0; i < count; i := i + 1) {
Neels Hofmeyr56f24782020-07-09 00:50:49 +02002213 var integer earfcn := f_test_si2quater_earfcn_by_idx(i);
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002214 var integer index := i / 3;
2215 var integer earfcn_index := i mod 3;
2216 if (index >= lengthof(si2quater)) {
2217 si2quater[index] := tr_SI2quaterRestOctets_EUTRAN(index := index, count := si2quater_count - 1);
2218 }
2219 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);
2220 }
2221
2222 return si2quater;
2223}
2224
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02002225private function f_tr_rr_chan_rel_earfcns(integer count) return template CellSelIndValue
2226{
2227 var template CellSelIndValue_EUTRAN_Descrs cells := {};
2228
Alexander Couzensf74b5cb2020-09-10 22:28:40 +02002229 /* the lte neighbors must match the config & vty to pass this test */
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02002230 for (var integer i := 0; i < count; i := i + 1) {
2231 var integer earfcn := f_test_si2quater_earfcn_by_idx(i);
Alexander Couzensf74b5cb2020-09-10 22:28:40 +02002232 cells[i] := tr_CellSelIndValue_EUTRAN_Descr(earfcn, '1'B, 3);
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02002233 }
2234
2235 return tr_CellSelIndValue_EUTRAN(cells);
2236}
2237
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002238private function f_tc_si2quater_n_earfcns(integer n) runs on test_CT
2239{
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002240 var template SystemInformationConfig sic := SystemInformationConfig_default;
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002241 sic.si2quater := f_tr_si2quater_earfcns(n);
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02002242 var template CellSelIndValue cells := f_tr_rr_chan_rel_earfcns(n);
2243 f_test_si2quater(n, sic, cells);
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002244}
2245
2246testcase TC_si2quater_2_earfcns() runs on test_CT {
2247 f_tc_si2quater_n_earfcns(2);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002248 f_shutdown_helper();
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002249}
2250
2251testcase TC_si2quater_3_earfcns() runs on test_CT {
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002252 f_tc_si2quater_n_earfcns(3);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002253 f_shutdown_helper();
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002254}
2255
2256testcase TC_si2quater_4_earfcns() runs on test_CT {
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002257 f_tc_si2quater_n_earfcns(4);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002258 f_shutdown_helper();
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002259}
2260
2261testcase TC_si2quater_5_earfcns() runs on test_CT {
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002262 f_tc_si2quater_n_earfcns(5);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002263 f_shutdown_helper();
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002264}
2265
2266testcase TC_si2quater_6_earfcns() runs on test_CT {
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002267 f_tc_si2quater_n_earfcns(6);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002268 f_shutdown_helper();
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002269}
2270
2271testcase TC_si2quater_12_earfcns() runs on test_CT {
2272 f_tc_si2quater_n_earfcns(12);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002273 f_shutdown_helper();
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002274}
2275
2276testcase TC_si2quater_23_earfcns() runs on test_CT {
2277 f_tc_si2quater_n_earfcns(23);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002278 f_shutdown_helper();
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002279}
2280
2281testcase TC_si2quater_32_earfcns() runs on test_CT {
2282 f_tc_si2quater_n_earfcns(32);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002283 f_shutdown_helper();
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002284}
2285
2286testcase TC_si2quater_33_earfcns() runs on test_CT {
2287 f_tc_si2quater_n_earfcns(33);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002288 f_shutdown_helper();
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002289}
2290
2291testcase TC_si2quater_42_earfcns() runs on test_CT {
2292 f_tc_si2quater_n_earfcns(42);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002293 f_shutdown_helper();
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002294}
2295
2296testcase TC_si2quater_48_earfcns() runs on test_CT {
2297 f_tc_si2quater_n_earfcns(48);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002298 f_shutdown_helper();
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002299}
2300
2301/* verify the VTY error response when adding too many EARFCNs, and showing that osmo-bsc still sends 16 SI2quater with
2302 * 48 EARFCNs. */
2303testcase TC_si2quater_49_earfcns() runs on test_CT {
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002304 var template SystemInformationConfig sic := SystemInformationConfig_default;
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002305 sic.si2quater := f_tr_si2quater_earfcns(48); /* 48, not 49! */
2306 f_init(0);
2307
2308 for (var integer i := 1; i < 48; i := i + 1) {
Neels Hofmeyr56f24782020-07-09 00:50:49 +02002309 f_bts_0_cfg(BSCVTY, {"si2quater neighbor-list add earfcn " & int2str(f_test_si2quater_earfcn_by_idx(i))
2310 & " thresh-hi 20 thresh-lo 10 prio 3 qrxlv 22 meas 3"});
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002311 }
2312
2313 /* The 49th EARFCN no longer fits, expect VTY error */
2314 f_vty_enter_cfg_bts(BSCVTY, 0);
2315 var charstring vty_error;
2316 vty_error := f_vty_transceive_ret(BSCVTY,
2317 "si2quater neighbor-list add earfcn 70 thresh-hi 20 thresh-lo 10 prio 3 qrxlv 22 meas 3")
2318 f_vty_transceive(BSCVTY, "end");
2319
2320 if (f_strstr(vty_error, "Unable to add ARFCN 70") >= 0) {
2321 log("Got expected VTY error: ", vty_error);
2322 setverdict(pass);
2323 } else {
2324 setverdict(fail, "Expected the 49th EUTRAN ARFCN to be rejected by vty config, got: ", vty_error);
2325 }
2326
2327 f_init_bts_and_check_sysinfo(0, expect_si := sic);
2328
2329 for (var integer i := 1; i < 48; i := i + 1) {
Neels Hofmeyr56f24782020-07-09 00:50:49 +02002330 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 +02002331 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002332 f_shutdown_helper();
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002333}
2334
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02002335private function f_acc09_count_allowed(AccessControlClass acc) return uint8_t
2336{
2337 var uint8_t count := 0;
2338 for (var integer i := 5; i < 16; i := i + 1) {
2339 if (acc[i] == '0'B) { /* the list marks barred, we count allowed */
2340 count := count + 1;
2341 }
2342 }
2343 return count;
2344}
2345
Pau Espin Pedrolc6136cd2020-07-24 13:20:02 +02002346private function f_recv_next_si1(integer rsl_idx := 0) runs on test_CT return SystemInformationType1
2347{
2348 var ASP_RSL_Unitdata rx_rsl_ud;
2349 var SystemInformationType1 last_si1;
2350
2351 timer T := 30.0;
2352 T.start;
2353 alt {
2354 [] IPA_RSL[rsl_idx].receive(tr_ASP_RSL_UD((tr_RSL_NO_BCCH_INFO,
2355 tr_RSL_BCCH_INFO,
2356 tr_RSL_NO_SACCH_FILL,
2357 tr_RSL_SACCH_FILL))
2358 ) -> value rx_rsl_ud {
2359 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
2360 if (g_system_information[rsl_idx].si1 == omit) {
2361 repeat;
2362 }
2363 last_si1 := g_system_information[rsl_idx].si1;
2364 g_system_information[rsl_idx].si1 := omit;
2365 T.stop;
2366 }
2367 [] T.timeout { setverdict(fail, "Timeout receiving next SI1"); }
2368 }
2369 return last_si1;
2370}
2371
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02002372/* verify ACC rotate feature */
2373testcase TC_si_acc_rotate() runs on test_CT {
2374 var template SystemInformationConfig sic := SystemInformationConfig_default;
Pau Espin Pedrolc6136cd2020-07-24 13:20:02 +02002375 var SystemInformationType1 last_si1;
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02002376 var AccessControlClass acc;
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02002377 var uint8_t count;
2378 var integer times_allowed[10] := { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
2379
2380 f_init(0, guard_timeout := 60.0);
2381
2382 f_bts_0_cfg(BSCVTY, {"rach access-control-class 5 barred",
2383 "access-control-class-rotate 3",
2384 "access-control-class-rotate-quantum 1"});
2385
2386 /* Init and get first sysinfo */
2387 f_init_bts_and_check_sysinfo(0, expect_si := ?);
2388
Pau Espin Pedrolc6136cd2020-07-24 13:20:02 +02002389 for (var integer i:= 0; i < 20; i := i + 1) {
2390 last_si1 := f_recv_next_si1(0);
2391 acc := last_si1.rach_control.acc;
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02002392 count := f_acc09_count_allowed(acc);
2393 log("RSL: GOT SI1 ACC len=", count, ": ", acc);
2394
2395 if (count != 3) {
2396 log("RSL: EXPECTED SI ACC len=3");
2397 setverdict(fail, "received SI does not match expectations");
2398 break;
2399 }
2400
2401 for (var integer j := 0; j < 10; j := j + 1) {
2402 if (acc[16 - 1 - j] == '0'B) { /* the list marks barred, we count allowed */
2403 times_allowed[j] := times_allowed[j] + 1;
2404 }
2405 }
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02002406 }
2407
2408 for (var integer j := 0; j < 10; j := j + 1) {
2409 log("ACC", j, " allowed ", times_allowed[j], " times" );
2410 if (j != 5 and times_allowed[j] < 3) {
2411 setverdict(fail, "ACC", j, " ERROR: allowed ", times_allowed[j], " < 1 times");
2412 } else if (j == 5 and times_allowed[j] > 0) {
2413 setverdict(fail, "ACC", j, " ERROR: allowed ", times_allowed[j], " > 0 times");
2414 }
2415 }
2416
2417 f_bts_0_cfg(BSCVTY, {"access-control-class-rotate 10",
2418 "rach access-control-class 5 allowed"});
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002419 f_shutdown_helper();
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02002420}
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002421
Pau Espin Pedrolc6136cd2020-07-24 13:20:02 +02002422/* verify ACC startup ramp+rotate feature */
2423testcase TC_si_acc_ramp_rotate() runs on test_CT {
2424 var template SystemInformationConfig sic := SystemInformationConfig_default;
2425 var SystemInformationType1 last_si1;
2426 var AccessControlClass acc;
2427 var ASP_RSL_Unitdata rx_rsl_ud;
2428 var uint8_t count;
2429 var uint8_t prev_count;
2430 var integer times_allowed[10] := { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
2431
2432 f_init(0, guard_timeout := 80.0);
2433
2434 f_bts_0_cfg(BSCVTY, {"rach access-control-class 4 barred",
2435 "access-control-class-rotate 0",
2436 "access-control-class-rotate-quantum 1",
2437 "access-control-class-ramping",
2438 "access-control-class-ramping-step-interval 5",
2439 "access-control-class-ramping-step-size 5"});
2440
2441 /* Init and get first sysinfo */
2442 f_init_bts_and_check_sysinfo(0, expect_si := ?);
2443 last_si1 := g_system_information[0].si1;
2444 acc := last_si1.rach_control.acc;
2445 count := f_acc09_count_allowed(acc);
2446 /* Adm subset size was set to 0 above, so wait until all ACC are barred */
2447 while (count > 0) {
2448 last_si1 := f_recv_next_si1(0);
2449 acc := last_si1.rach_control.acc;
2450 count := f_acc09_count_allowed(acc);
2451 log("RSL: wait len()=0: GOT SI1 ACC len=", count, ": ", acc);
2452 }
2453
2454 /* Increase adm subset size, we should see ramping start up */
2455 f_bts_0_cfg(BSCVTY, {"access-control-class-rotate 10"});
2456 prev_count := 0;
2457 while (true) {
2458 last_si1 := f_recv_next_si1(0);
2459 acc := last_si1.rach_control.acc;
2460 count := f_acc09_count_allowed(acc);
2461 log("RSL: GOT SI1 ACC len=", count, ": ", acc);
2462
2463 if (prev_count > count) {
2464 setverdict(fail, "ACC allowed count dropped while expecting grow: ", prev_count, " -> ", count);
2465 break;
2466 }
2467
2468 if (count == 9) {
2469 break; /* Maximum reached (10 - 1 perm barred), done here */
2470 }
2471
2472 prev_count := count;
2473 }
2474
2475 setverdict(pass);
2476
2477 f_bts_0_cfg(BSCVTY, {"access-control-class-rotate 10",
2478 "rach access-control-class 4 allowed",
2479 "no access-control-class-ramping"});
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002480 f_shutdown_helper();
Pau Espin Pedrolc6136cd2020-07-24 13:20:02 +02002481}
2482
Harald Welte4003d112017-12-09 22:35:39 +01002483testcase TC_ctrl_msc_connection_status() runs on test_CT {
2484 var charstring ctrl_resp;
2485
Harald Welte89d42e82017-12-17 16:42:41 +01002486 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +01002487
2488 /* See https://osmocom.org/issues/2729 */
2489 f_ctrl_get_exp(IPA_CTRL, "msc_connection_status", "connected");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002490 f_shutdown_helper();
Harald Welte4003d112017-12-09 22:35:39 +01002491}
2492
Stefan Sperlingb041b3d2018-01-03 17:14:55 +01002493testcase TC_ctrl_msc0_connection_status() runs on test_CT {
2494 var charstring ctrl_resp;
2495
2496 f_init(1);
Stefan Sperlingb041b3d2018-01-03 17:14:55 +01002497
2498 f_ctrl_get_exp(IPA_CTRL, "msc.0.connection_status", "connected");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002499 f_shutdown_helper();
Stefan Sperlingb041b3d2018-01-03 17:14:55 +01002500}
2501
Harald Welte4003d112017-12-09 22:35:39 +01002502testcase TC_ctrl() runs on test_CT {
2503 var charstring ctrl_resp;
2504
Harald Welte89d42e82017-12-17 16:42:41 +01002505 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +01002506
2507 /* all below values must match the osmo-bsc.cfg config file used */
2508
Harald Welte6a129692018-03-17 17:30:14 +01002509 f_ctrl_get_exp(IPA_CTRL, "mcc", "001");
2510 f_ctrl_get_exp(IPA_CTRL, "mnc", "01");
Oliver Smith75aa0202019-08-19 14:17:50 +02002511 f_ctrl_get_exp(IPA_CTRL, "number-of-bts", "4");
Harald Welte4003d112017-12-09 22:35:39 +01002512
2513 var integer bts_nr := 0;
2514 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "location-area-code", "1");
2515 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "cell-identity", "0");
2516 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "oml-connection-state", "connected");
2517 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "gprs-mode", "gprs");
2518 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "rf_state", "operational,unlocked,on");
2519 f_ctrl_get_exp_trx(IPA_CTRL, bts_nr, 0, "arfcn", "871");
2520 f_ctrl_get_exp_trx(IPA_CTRL, bts_nr, 0, "max-power-reduction", "20");
2521
2522 var integer uptime := str2int(f_ctrl_get_bts(IPA_CTRL, bts_nr, "oml-uptime"));
2523 f_sleep(2.0);
2524 if (str2int(f_ctrl_get_bts(IPA_CTRL, bts_nr, "oml-uptime")) < uptime+1) {
2525 setverdict(fail, "oml-uptime not incrementing as expected");
2526 }
2527 /* TODO: Disconnect RSL, imply that OML is disconnected and check for uptime zero? */
2528
2529 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bsc", 0, "paging:attempted", 0);
2530
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002531 f_shutdown_helper();
Harald Welte96c94412017-12-09 03:12:45 +01002532}
2533
Pau Espin Pedrol5a2d7432019-06-07 19:43:45 +02002534/* Verify that Upon receival of SET "location", BSC forwards a TRAP
2535 "location-state" over the SCCPlite IPA conn */
2536testcase TC_ctrl_location() runs on test_CT {
2537 var MSC_ConnHdlr vc_conn;
2538 var integer bts_nr := 0;
2539
2540 f_init(1, true);
2541 f_sleep(1.0);
2542
2543 f_ctrl_set_bts(IPA_CTRL, bts_nr, "location", "1234567,fix3d,0.340000,0.560000,0.780000");
2544 f_ctrl_exp_trap(SCCPLITE_IPA_CTRL, "bts." & int2str(bts_nr) & ".location-state",
2545 "1234567,fix3d,0.340000,0.560000,0.780000,operational,unlocked,on,001,01");
2546
2547 f_ctrl_set(SCCPLITE_IPA_CTRL, "rf_locked", "1");
2548 f_sleep(2.0);
2549
2550 f_ctrl_set_bts(IPA_CTRL, bts_nr, "location", "1234888,fix3d,0.350000,0.570000,0.790000");
2551 f_ctrl_exp_trap(SCCPLITE_IPA_CTRL, "bts." & int2str(bts_nr) & ".location-state",
2552 "1234888,fix3d,0.350000,0.570000,0.790000,operational,locked,off,001,01");
2553
2554 /* should match the one from config */
2555 f_ctrl_set(SCCPLITE_IPA_CTRL, "rf_locked", "0");
2556
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002557 f_shutdown_helper();
Pau Espin Pedrol5a2d7432019-06-07 19:43:45 +02002558}
2559
Harald Welte6f521d82017-12-11 19:52:02 +01002560
2561/***********************************************************************
2562 * Paging Testing
2563 ***********************************************************************/
2564
2565type record Cell_Identity {
2566 GsmMcc mcc,
2567 GsmMnc mnc,
2568 GsmLac lac,
2569 GsmCellId ci
2570};
Harald Welte24135bd2018-03-17 19:27:53 +01002571private const Cell_Identity cid := { '001'H, '01'H, 1, 0 };
Stefan Sperling049a86e2018-03-20 15:51:00 +01002572private const Cell_Identity unknown_cid := { '678'H, 'f90'H, 1, 0 };
Harald Welte6f521d82017-12-11 19:52:02 +01002573
Harald Welte5d1a2202017-12-13 19:51:29 +01002574type set of integer BtsIdList;
2575
2576private function f_bts_in_list(integer bts_id, BtsIdList bts_ids) return boolean {
2577 for (var integer j := 0; j < sizeof(bts_ids); j := j + 1) {
2578 if (bts_id == bts_ids[j]) {
2579 return true;
2580 }
2581 }
2582 return false;
2583}
Harald Welte6f521d82017-12-11 19:52:02 +01002584
2585/* core paging test helper function; used by most paging test cases */
2586private function f_pageing_helper(hexstring imsi,
2587 template BSSMAP_FIELD_CellIdentificationList cid_list,
Harald Welte5d1a2202017-12-13 19:51:29 +01002588 BtsIdList bts_ids := { 0 },
Harald Welte6f521d82017-12-11 19:52:02 +01002589 template RSL_ChanNeeded rsl_chneed := omit,
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07002590 template (omit) OCT4 tmsi := omit) runs on test_CT
Harald Welte6f521d82017-12-11 19:52:02 +01002591{
2592 var template BSSMAP_IE_ChannelNeeded bssmap_chneed;
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07002593 var template MobileIdentityV mi;
Harald Welte6f521d82017-12-11 19:52:02 +01002594 var RSL_Message rx_rsl;
2595 var integer paging_group := hex2int(imsi[lengthof(imsi)-1]);
Harald Welte5d1a2202017-12-13 19:51:29 +01002596 var integer i;
Harald Welte6f521d82017-12-11 19:52:02 +01002597
2598 f_init();
Harald Welte6f521d82017-12-11 19:52:02 +01002599
2600 /* Clear the queue, it might still contain stuff like BCCH FILLING */
Harald Weltec3068592018-03-17 19:55:31 +01002601 for (i := 0; i < NUM_BTS; i := i + 1) {
2602 IPA_RSL[i].clear;
Harald Welte5d1a2202017-12-13 19:51:29 +01002603 }
Harald Welte6f521d82017-12-11 19:52:02 +01002604
2605 if (isvalue(rsl_chneed)) {
2606 /* The values of 08.08 3.2.2.36 and 08.58 9.3.40 are luckily identical */
2607 bssmap_chneed := ts_BSSMAP_IE_ChanNeeded(int2bit(enum2int(valueof(rsl_chneed)),2));
2608 } else {
2609 bssmap_chneed := omit;
2610 }
2611
Neels Hofmeyrf246a922020-05-13 02:27:10 +02002612 BSSAP.send(ts_BSSAP_UNITDATA_req(g_bssap[0].sccp_addr_peer, g_bssap[0].sccp_addr_own,
2613 ts_BSSMAP_Paging(imsi, cid_list, tmsi, bssmap_chneed)));
Harald Welte6f521d82017-12-11 19:52:02 +01002614
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07002615 if (not istemplatekind(tmsi, "omit")) {
2616 mi := t_MI_TMSI(tmsi);
Harald Welte6f521d82017-12-11 19:52:02 +01002617 } else {
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07002618 mi := tr_MI_IMSI(imsi);
Harald Welte6f521d82017-12-11 19:52:02 +01002619 }
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07002620
Harald Welte5d1a2202017-12-13 19:51:29 +01002621 for (i := 0; i < sizeof(bts_ids); i := i + 1) {
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07002622 rx_rsl := f_exp_ipa_rx(bts_ids[i], tr_RSL_PAGING_CMD(mi));
Harald Welte5d1a2202017-12-13 19:51:29 +01002623 /* check channel type, paging group */
2624 if (rx_rsl.ies[1].body.paging_group != paging_group) {
2625 setverdict(fail, "Paging for wrong paging group");
2626 }
2627 if (ispresent(rsl_chneed) and
2628 rx_rsl.ies[3].body.chan_needed.chan_needed != valueof(rsl_chneed)) {
2629 setverdict(fail, "RSL Channel Needed != BSSMAP Channel Needed");
2630 }
Harald Welte6f521d82017-12-11 19:52:02 +01002631 }
Harald Welte2fccd982018-01-31 15:48:19 +01002632 f_sleep(2.0);
Harald Welte5d1a2202017-12-13 19:51:29 +01002633 /* do a quick check on all not-included BTSs if they received paging */
2634 for (i := 0; i < NUM_BTS; i := i + 1) {
2635 timer T := 0.1;
2636 if (f_bts_in_list(i, bts_ids)) {
2637 continue;
2638 }
2639 T.start;
2640 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07002641 [] IPA_RSL[i].receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD(mi))) {
Harald Welte5d1a2202017-12-13 19:51:29 +01002642 setverdict(fail, "Paging on BTS ", i, " which is not part of ", bts_ids);
2643 }
2644 [] IPA_RSL[i].receive { repeat; }
2645 [] T.timeout { }
2646 }
Harald Welte6f521d82017-12-11 19:52:02 +01002647 }
2648
2649 setverdict(pass);
2650}
2651
Harald Welte5d1a2202017-12-13 19:51:29 +01002652const BtsIdList c_BtsId_all := { 0, 1, 2 };
Harald Welte751d3eb2018-01-31 15:51:06 +01002653const BtsIdList c_BtsId_none := { };
Harald Welte5d1a2202017-12-13 19:51:29 +01002654const BtsIdList c_BtsId_LAC1 := { 0, 1 };
2655const BtsIdList c_BtsId_LAC2 := { 2 };
2656
Harald Welte6f521d82017-12-11 19:52:02 +01002657/* PAGING by IMSI + TMSI */
2658testcase TC_paging_imsi_nochan() runs on test_CT {
2659 var BSSMAP_FIELD_CellIdentificationList cid_list;
2660 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Philipp Maier8c04b0a2018-02-23 13:48:48 +01002661 f_pageing_helper('001010100000001'H, cid_list, c_BtsId_all, omit, omit);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002662 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002663}
2664
2665/* PAGING by IMSI + TMSI */
2666testcase TC_paging_tmsi_nochan() runs on test_CT {
2667 var BSSMAP_FIELD_CellIdentificationList cid_list;
2668 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01002669 f_pageing_helper('001010100000001'H, cid_list, c_BtsId_all, omit, 'A1B2C301'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002670 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002671}
2672
2673/* Paging with different "channel needed' values */
2674testcase TC_paging_tmsi_any() runs on test_CT {
2675 var BSSMAP_FIELD_CellIdentificationList cid_list;
2676 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01002677 f_pageing_helper('001010100000002'H, cid_list, c_BtsId_all, RSL_CHANNEED_ANY, 'A1B2C302'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002678 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002679}
2680testcase TC_paging_tmsi_sdcch() runs on test_CT {
2681 var BSSMAP_FIELD_CellIdentificationList cid_list;
2682 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01002683 f_pageing_helper('001010100000003'H, cid_list, c_BtsId_all, RSL_CHANNEED_SDCCH, 'A1B2C303'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002684 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002685}
2686testcase TC_paging_tmsi_tch_f() runs on test_CT {
2687 var BSSMAP_FIELD_CellIdentificationList cid_list;
2688 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01002689 f_pageing_helper('001010000000004'H, cid_list, c_BtsId_all, RSL_CHANNEED_TCH_F, 'A1B2C304'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002690 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002691}
2692testcase TC_paging_tmsi_tch_hf() runs on test_CT {
2693 var BSSMAP_FIELD_CellIdentificationList cid_list;
2694 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01002695 f_pageing_helper('001010000000005'H, cid_list, c_BtsId_all, RSL_CHANNEED_TCH_ForH, 'A1B2C305'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002696 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002697}
2698
2699/* Paging by CGI */
2700testcase TC_paging_imsi_nochan_cgi() runs on test_CT {
2701 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2702 cid_list := { cIl_CGI := { ts_BSSMAP_CI_CGI(cid.mcc, cid.mnc, cid.lac, cid.ci) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01002703 f_pageing_helper('001010000000006'H, cid_list, { 0 });
Philipp Maier282ca4b2018-02-27 17:17:00 +01002704 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002705}
2706
2707/* Paging by LAC+CI */
2708testcase TC_paging_imsi_nochan_lac_ci() runs on test_CT {
2709 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2710 cid_list := { cIl_LAC_CI := { ts_BSSMAP_CI_LAC_CI(cid.lac, cid.ci) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01002711 f_pageing_helper('001010000000007'H, cid_list, { 0 });
Philipp Maier282ca4b2018-02-27 17:17:00 +01002712 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002713}
2714
2715/* Paging by CI */
2716testcase TC_paging_imsi_nochan_ci() runs on test_CT {
2717 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2718 cid_list := { cIl_CI := { ts_BSSMAP_CI_CI(cid.ci) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01002719 f_pageing_helper('001010000000008'H, cid_list, { 0 });
Philipp Maier282ca4b2018-02-27 17:17:00 +01002720 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002721}
2722
2723/* Paging by LAI */
2724testcase TC_paging_imsi_nochan_lai() runs on test_CT {
2725 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2726 cid_list := { cIl_LAI := { ts_BSSMAP_CI_LAI(cid.mcc, cid.mnc, cid.lac) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01002727 f_pageing_helper('001010000000009'H, cid_list, c_BtsId_LAC1);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002728 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002729}
2730
2731/* Paging by LAC */
2732testcase TC_paging_imsi_nochan_lac() runs on test_CT {
2733 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2734 cid_list := { cIl_LAC := { ts_BSSMAP_CI_LAC(cid.lac) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01002735 f_pageing_helper('001010000000010'H, cid_list, c_BtsId_LAC1);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002736 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002737}
2738
2739/* Paging by "all in BSS" */
2740testcase TC_paging_imsi_nochan_all() runs on test_CT {
2741 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2742 cid_list := { cIl_allInBSS := ''O };
Harald Welte5d1a2202017-12-13 19:51:29 +01002743 f_pageing_helper('001010000000011'H, cid_list, c_BtsId_all);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002744 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002745}
2746
Stefan Sperling7b5e1782018-03-20 19:32:43 +01002747/* Paging by PLMN+LAC+RNC; We do not implement this; Verify nothing is paged */
Harald Welte751d3eb2018-01-31 15:51:06 +01002748testcase TC_paging_imsi_nochan_plmn_lac_rnc() runs on test_CT {
2749 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2750 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 +01002751 f_pageing_helper('001010000000012'H, cid_list, c_BtsId_none);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002752 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01002753}
Harald Welte6f521d82017-12-11 19:52:02 +01002754
Stefan Sperling7b5e1782018-03-20 19:32:43 +01002755/* Paging by RNC; We do not implement this; Verify nothing is paged */
Harald Welte751d3eb2018-01-31 15:51:06 +01002756testcase TC_paging_imsi_nochan_rnc() runs on test_CT {
2757 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2758 cid_list := { cIl_RNC := { int2oct(13, 2) } };
Stefan Sperling7b5e1782018-03-20 19:32:43 +01002759 f_pageing_helper('001010000000013'H, cid_list, c_BtsId_none);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002760 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01002761}
2762
Stefan Sperling7b5e1782018-03-20 19:32:43 +01002763/* Paging by LAC+RNC; We do not implement; Verify nothing is paged */
Harald Welte751d3eb2018-01-31 15:51:06 +01002764testcase TC_paging_imsi_nochan_lac_rnc() runs on test_CT {
2765 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2766 cid_list := { cIl_LAC_RNC := { ts_BSSMAP_CI_LAC_RNC(cid.lac, 14) } };
Stefan Sperling7b5e1782018-03-20 19:32:43 +01002767 f_pageing_helper('001010000000014'H, cid_list, c_BtsId_none);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002768 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01002769}
2770
Harald Welte6f521d82017-12-11 19:52:02 +01002771/* Paging on multiple cells (multiple entries in list): Verify all of them page */
Harald Welte751d3eb2018-01-31 15:51:06 +01002772testcase TC_paging_imsi_nochan_lacs() runs on test_CT {
2773 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2774 cid_list := { cIl_LAC := { ts_BSSMAP_CI_LAC(1), ts_BSSMAP_CI_LAC(2) } };
2775 f_pageing_helper('001010000000015'H, cid_list, c_BtsId_all);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002776 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01002777}
2778
2779/* Paging on empty list: Verify none of them page */
2780testcase TC_paging_imsi_nochan_lacs_empty() runs on test_CT {
2781 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2782 cid_list := { cIl_LAC := { } };
2783 f_pageing_helper('001010000000016'H, cid_list, c_BtsId_none);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002784 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01002785}
2786
Stefan Sperling049a86e2018-03-20 15:51:00 +01002787/* Paging by CGI with unknown MCC/MNC: Verify nothing is paged. */
2788testcase TC_paging_imsi_nochan_cgi_unknown_cid() runs on test_CT {
2789 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2790 cid_list := { cIl_CGI := { ts_BSSMAP_CI_CGI(unknown_cid.mcc, unknown_cid.mnc, unknown_cid.lac, unknown_cid.ci) } };
2791 f_pageing_helper('001010000000006'H, cid_list, c_BtsId_none);
2792 f_shutdown_helper();
2793}
2794
Harald Welte6f521d82017-12-11 19:52:02 +01002795/* Verify paging retransmission interval + count */
2796/* Verify paging stops after channel establishment */
Harald Welte6f521d82017-12-11 19:52:02 +01002797/* Test behavior under paging overload */
Harald Welteae026692017-12-09 01:03:01 +01002798
Harald Weltee65d40e2017-12-13 00:09:06 +01002799/* Verify PCH load */
2800testcase TC_paging_imsi_load() runs on test_CT {
2801 var BSSMAP_FIELD_CellIdentificationList cid_list;
2802 timer T := 4.0;
Harald Welte2caa1062018-03-17 18:19:05 +01002803 timer T_retrans := 1.0;
Harald Weltee65d40e2017-12-13 00:09:06 +01002804 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01002805 f_pageing_helper('001010123456789'H, cid_list, c_BtsId_all);
Harald Weltee65d40e2017-12-13 00:09:06 +01002806
2807 /* tell BSC there is no paging space anymore */
2808 f_ipa_tx(0, ts_RSL_PAGING_LOAD_IND(0));
Harald Welte3b57ab52018-03-17 18:01:10 +01002809 f_sleep(0.2);
2810 IPA_RSL[0].clear;
Harald Weltee65d40e2017-12-13 00:09:06 +01002811
2812 /* Wait for 4 seconds if any more PAGING CMD are received on RSL. Normally,
2813 * there would be 8 retransmissions during 4 seconds */
2814 T.start;
Harald Welte2caa1062018-03-17 18:19:05 +01002815 T_retrans.start;
Harald Weltee65d40e2017-12-13 00:09:06 +01002816 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07002817 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD(?))) {
Harald Weltee65d40e2017-12-13 00:09:06 +01002818 setverdict(fail, "Received PAGING after LOAD_IND(0)");
Daniel Willmannafce8662018-07-06 23:11:32 +02002819 mtc.stop;
Harald Weltee65d40e2017-12-13 00:09:06 +01002820 }
Harald Welte2caa1062018-03-17 18:19:05 +01002821 [] T_retrans.timeout {
2822 /* re-trnsmit the zero-space LOAD IND to avoid BSC 'auto credit' */
2823 f_ipa_tx(0, ts_RSL_PAGING_LOAD_IND(0));
2824 T_retrans.start;
2825 repeat;
2826 }
Harald Weltee65d40e2017-12-13 00:09:06 +01002827 [] T.timeout {
2828 setverdict(pass);
2829 }
2830 }
Philipp Maier282ca4b2018-02-27 17:17:00 +01002831
2832 f_shutdown_helper();
Harald Weltee65d40e2017-12-13 00:09:06 +01002833}
2834
Harald Welte235ebf12017-12-15 14:18:16 +01002835/* Verify Paging Counter */
Harald Welte1ff69992017-12-14 12:31:17 +01002836testcase TC_paging_counter() runs on test_CT {
2837 var BSSMAP_FIELD_CellIdentificationList cid_list;
2838 timer T := 4.0;
2839 var integer i;
2840 var integer paging_attempted_bsc;
2841 var integer paging_attempted_bts[NUM_BTS];
2842 var integer paging_expired_bts[NUM_BTS];
2843 cid_list := valueof(ts_BSSMAP_CIL_noCell);
2844
2845 f_init();
2846
2847 /* read counters before paging */
2848 paging_attempted_bsc := f_ctrl_get_ratectr_abs(IPA_CTRL, "bsc", 0, "paging:attempted");
2849 for (i := 0; i < NUM_BTS; i := i+1) {
2850 paging_attempted_bts[i] := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", i, "paging:attempted");
2851 paging_expired_bts[i] := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", i, "paging:expired");
2852 }
2853
2854 f_pageing_helper('001230000000001'H, cid_list, c_BtsId_all);
2855
2856 /* expect the attempted pages on BSC and each BTSs to have incremented by one */
2857 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bsc", 0, "paging:attempted", paging_attempted_bsc+1);
2858 for (i := 0; i < NUM_BTS; i := i+1) {
2859 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", i, "paging:attempted",
2860 paging_attempted_bts[i]+1);
2861 }
2862
2863 /* assume that 12s later the paging on all BTSs have expired and hence incremented by 1 */
2864 f_sleep(12.0);
2865 for (i := 0; i < NUM_BTS; i := i+1) {
2866 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", i, "paging:expired",
2867 paging_expired_bts[i]+1);
2868 }
Harald Welte1ff69992017-12-14 12:31:17 +01002869
Philipp Maier282ca4b2018-02-27 17:17:00 +01002870 f_shutdown_helper();
Harald Welte1ff69992017-12-14 12:31:17 +01002871}
2872
2873
Harald Welte10985002017-12-12 09:29:15 +01002874/* Verify paging stops after A-RESET */
2875testcase TC_paging_imsi_a_reset() runs on test_CT {
2876 var BSSMAP_FIELD_CellIdentificationList cid_list;
2877 timer T := 3.0;
2878 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01002879 f_pageing_helper('001010123456789'H, cid_list, c_BtsId_all);
Harald Welte10985002017-12-12 09:29:15 +01002880
2881 /* Perform a BSSMAP Reset and wait for ACK */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02002882 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 +01002883 alt {
Neels Hofmeyrf246a922020-05-13 02:27:10 +02002884 [] 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 +01002885 [] BSSAP.receive { repeat; }
2886 }
2887
Daniel Willmanncbef3982018-07-30 09:22:40 +02002888 /* Wait to avoid a possible race condition if a paging message is
2889 * received right before the reset ACK. */
2890 f_sleep(0.2);
2891
Harald Welte10985002017-12-12 09:29:15 +01002892 /* Clear the queue, it might still contain stuff like BCCH FILLING */
Philipp Maier1e6b4422018-02-23 14:02:13 +01002893 for (var integer i := 0; i < sizeof(IPA_RSL); i := i+1) {
2894 IPA_RSL[i].clear;
2895 }
Harald Welte10985002017-12-12 09:29:15 +01002896
2897 /* Wait for 3 seconds if any more PAGING CMD are received on RSL */
2898 T.start;
2899 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07002900 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD(?))) {
Harald Welte10985002017-12-12 09:29:15 +01002901 setverdict(fail, "Received PAGING after A-RESET");
Daniel Willmannafce8662018-07-06 23:11:32 +02002902 mtc.stop;
Harald Welte10985002017-12-12 09:29:15 +01002903 }
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07002904 [] IPA_RSL[1].receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD(?))) {
Harald Welte5d1a2202017-12-13 19:51:29 +01002905 setverdict(fail, "Received PAGING after A-RESET");
Daniel Willmannafce8662018-07-06 23:11:32 +02002906 mtc.stop;
Harald Welte5d1a2202017-12-13 19:51:29 +01002907 }
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07002908 [] IPA_RSL[2].receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD(?))) {
Harald Welte5d1a2202017-12-13 19:51:29 +01002909 setverdict(fail, "Received PAGING after A-RESET");
Daniel Willmannafce8662018-07-06 23:11:32 +02002910 mtc.stop;
Harald Welte5d1a2202017-12-13 19:51:29 +01002911 }
Harald Welte10985002017-12-12 09:29:15 +01002912 [] T.timeout {
2913 setverdict(pass);
2914 }
2915 }
Philipp Maier282ca4b2018-02-27 17:17:00 +01002916
2917 f_shutdown_helper();
Harald Welte10985002017-12-12 09:29:15 +01002918}
Harald Welteae026692017-12-09 01:03:01 +01002919
Philipp Maierf45824a2019-08-14 14:44:10 +02002920/* Verify how we handle unsolicited Paging Response. In case of an unsolicit
2921 * paging response we can not know which MSC is in charge, so we will blindly
2922 * pick the first configured MSC. This behavior is required in order to make
2923 * MT-CSFB calls working because in those cases the BSC can not know that the
2924 * MSC has already paged the subscriver via SGs. So any MT-CSFB call will look
2925 * like an unsolicited Paging Response to the MSC.
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01002926 */
2927testcase TC_paging_resp_unsol() runs on test_CT {
2928
2929 f_init(1);
Philipp Maierf45824a2019-08-14 14:44:10 +02002930 timer T := 5.0;
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01002931
2932 var BSSAP_N_CONNECT_ind rx_c_ind;
2933 var DchanTuple dt;
2934 var PDU_ML3_MS_NW l3 := valueof(ts_PAG_RESP(valueof(ts_MI_IMSI_LV('001010008880018'H))));
Philipp Maierf45824a2019-08-14 14:44:10 +02002935 var octetstring rr_pag_resp := enc_PDU_ML3_MS_NW(l3);
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01002936
2937 /* Send CHAN RQD and wait for allocation; acknowledge it */
2938 dt.rsl_chan_nr := f_chreq_act_ack();
2939
2940 /* Send unsolicited Paging response (no matching Paging CMD stored in BSC) */
2941 f_ipa_tx(0, ts_RSL_EST_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0)), enc_PDU_ML3_MS_NW(l3)));
2942
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01002943
Philipp Maierf45824a2019-08-14 14:44:10 +02002944 /* Expevct a CR with a matching Paging response on the A-Interface */
2945 T.start;
2946 alt {
2947 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(rr_pag_resp))) {
2948 setverdict(pass);
2949 }
2950 [] BSSAP.receive {
2951 setverdict(fail, "Received unexpected message on A-Interface!");
2952 }
2953 [] T.timeout {
2954 setverdict(fail, "Received nothing on A-Interface!");
2955 }
2956 }
2957
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002958 f_shutdown_helper();
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01002959}
2960
Harald Welte4e9b9cc2017-12-14 18:31:02 +01002961/* Test RSL link drop causes counter increment */
2962testcase TC_rsl_drop_counter() runs on test_CT {
2963 var integer rsl_fail;
2964
Harald Welte89d42e82017-12-17 16:42:41 +01002965 f_init(1);
Harald Welte4e9b9cc2017-12-14 18:31:02 +01002966
2967 rsl_fail := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "rsl_fail");
2968
2969 bts[0].rsl.vc_IPA.stop;
2970
2971 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "rsl_fail", rsl_fail+1);
2972
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02002973 f_shutdown_helper();
Harald Welte4e9b9cc2017-12-14 18:31:02 +01002974}
2975
2976/* TODO: Test OML link drop causes counter increment */
2977
Stefan Sperling830dc9d2018-02-12 21:08:28 +01002978/* The body of TC_rsl_unknown_unit_id() and TC_oml_unknown_unit_id() tests. */
2979function f_ipa_unknown_unit_id(integer mp_bsc_ipa_port) runs on test_CT return boolean {
2980 timer T := 10.0;
2981
2982 bts[0].rsl.id := "IPA-0-RSL";
2983 bts[0].rsl.vc_IPA := IPA_Emulation_CT.create(bts[0].rsl.id & "-IPA");
2984 bts[0].rsl.ccm_pars := c_IPA_default_ccm_pars;
2985 bts[0].rsl.ccm_pars.name := "Osmocom TTCN-3 BTS Simulator";
Oliver Smith92c2bdb2019-08-20 15:11:24 +02002986 bts[0].rsl.ccm_pars.unit_id := "99/0/0"; /* value which is unknown at BTS */
Stefan Sperling830dc9d2018-02-12 21:08:28 +01002987
Stefan Sperling830dc9d2018-02-12 21:08:28 +01002988 f_ipa_ctrl_start(mp_bsc_ip, mp_bsc_ctrl_port);
2989
2990 f_init_mgcp("VirtMSC");
2991
2992 /* start RSL/OML connection (XXX re-uses RSL port/protocol definitions for OML) */
2993 map(bts[0].rsl.vc_IPA:IPA_PORT, system:IPA);
2994 connect(bts[0].rsl.vc_IPA:IPA_RSL_PORT, self:IPA_RSL[0]);
2995 bts[0].rsl.vc_IPA.start(IPA_Emulation.main_client(mp_bsc_ip, mp_bsc_ipa_port, "", 10000, bts[0].rsl.ccm_pars));
2996
2997 /* wait for IPA OML link to connect and then disconnect */
2998 T.start;
2999 alt {
Vadim Yanitskiya2afacc2020-05-18 21:16:19 +07003000 [] IPA_RSL[0].receive(tr_ASP_IPA_EV(ASP_IPA_EVENT_DOWN)) {
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003001 T.stop;
3002 return true;
3003 }
3004 [] IPA_RSL[0].receive { repeat }
3005 [] T.timeout {
Daniel Willmannafce8662018-07-06 23:11:32 +02003006 return false;
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003007 }
3008 }
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003009 return false;
3010}
3011
3012/* BSC should close an RSL connection from a BTS with unknown unit ID (OS#2714). */
3013testcase TC_rsl_unknown_unit_id() runs on test_CT {
3014 if (f_ipa_unknown_unit_id(mp_bsc_rsl_port)) {
3015 setverdict(pass);
3016 } else {
3017 setverdict(fail, "Timeout RSL waiting for connection to close");
3018 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003019 f_shutdown_helper();
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003020}
3021
3022
3023/* BSC should close an RSL connection from a BTS with unknown unit ID (OS#2714). */
3024testcase TC_oml_unknown_unit_id() runs on test_CT {
3025 if (f_ipa_unknown_unit_id(mp_bsc_oml_port)) {
3026 setverdict(pass);
3027 } else {
3028 setverdict(fail, "Timeout OML waiting for connection to close");
3029 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003030 f_shutdown_helper();
Stefan Sperling830dc9d2018-02-12 21:08:28 +01003031}
3032
3033
Harald Weltec1a2fff2017-12-17 11:06:19 +01003034/***********************************************************************
Harald Welte6811d102019-04-14 22:23:14 +02003035 * "New world" test cases using RSL_Emulation + RAN_Emulation
Harald Weltec1a2fff2017-12-17 11:06:19 +01003036 ***********************************************************************/
3037
Harald Welte6811d102019-04-14 22:23:14 +02003038import from RAN_Emulation all;
Harald Weltec1a2fff2017-12-17 11:06:19 +01003039import from RSL_Emulation all;
3040import from MSC_ConnectionHandler all;
3041
3042type function void_fn(charstring id) runs on MSC_ConnHdlr;
3043
Harald Welte336820c2018-05-31 20:34:52 +02003044/* helper function to create and connect a MSC_ConnHdlr component */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003045private function f_connect_handler(inout MSC_ConnHdlr vc_conn, integer bssap_idx := 0) runs on test_CT {
3046 connect(vc_conn:RAN, g_bssap[bssap_idx].vc_RAN:PROC);
Daniel Willmann191e0d92018-01-17 12:44:35 +01003047 connect(vc_conn:MGCP_PROC, vc_MGCP:MGCP_PROC);
Harald Weltec1a2fff2017-12-17 11:06:19 +01003048 connect(vc_conn:RSL, bts[0].rsl.vc_RSL:CLIENT_PT);
Harald Weltef70df652018-01-29 22:00:23 +01003049 connect(vc_conn:RSL_PROC, bts[0].rsl.vc_RSL:RSL_PROC);
Philipp Maier88f4ae82018-03-01 14:00:58 +01003050 if (isvalue(bts[1])) {
Philipp Maier956a92f2018-02-16 10:58:07 +01003051 connect(vc_conn:RSL1, bts[1].rsl.vc_RSL:CLIENT_PT);
3052 connect(vc_conn:RSL1_PROC, bts[1].rsl.vc_RSL:RSL_PROC);
3053 }
Neels Hofmeyr91401012019-07-11 00:42:35 +02003054 if (isvalue(bts[2])) {
3055 connect(vc_conn:RSL2, bts[2].rsl.vc_RSL:CLIENT_PT);
3056 connect(vc_conn:RSL2_PROC, bts[2].rsl.vc_RSL:RSL_PROC);
3057 }
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003058 connect(vc_conn:BSSAP, g_bssap[bssap_idx].vc_RAN:CLIENT);
Daniel Willmann191e0d92018-01-17 12:44:35 +01003059 connect(vc_conn:MGCP, vc_MGCP:MGCP_CLIENT);
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +02003060 connect(vc_conn:MGCP_MULTI, vc_MGCP:MGCP_CLIENT_MULTI);
Daniel Willmannebdecc02020-08-12 15:30:17 +02003061 connect(vc_conn:STATSD_PROC, vc_STATSD:STATSD_PROC);
Harald Welte336820c2018-05-31 20:34:52 +02003062}
3063
3064function f_start_handler(void_fn fn, template (omit) TestHdlrParams pars := omit)
3065runs on test_CT return MSC_ConnHdlr {
3066 var charstring id := testcasename();
3067 var MSC_ConnHdlr vc_conn;
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003068 var integer bssap_idx := 0;
3069 if (isvalue(pars)) {
3070 bssap_idx := valueof(pars).mscpool.bssap_idx;
3071 }
Harald Welte336820c2018-05-31 20:34:52 +02003072 vc_conn := MSC_ConnHdlr.create(id);
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003073 f_connect_handler(vc_conn, bssap_idx);
Harald Weltea0630032018-03-20 21:09:55 +01003074 vc_conn.start(f_handler_init(fn, id, pars));
Harald Weltec1a2fff2017-12-17 11:06:19 +01003075 return vc_conn;
3076}
3077
Harald Weltea0630032018-03-20 21:09:55 +01003078/* first function inside ConnHdlr component; sets g_pars + starts function */
3079private function f_handler_init(void_fn fn, charstring id, template (omit) TestHdlrParams pars := omit)
3080runs on MSC_ConnHdlr {
3081 if (isvalue(pars)) {
3082 g_pars := valueof(pars);
3083 }
3084 fn.apply(id);
3085}
3086
Harald Welte3c86ea02018-05-10 22:28:05 +02003087/* Establish signalling channel (non-assignment case) followed by cipher mode */
3088private function f_tc_ciph_mode_a5(charstring id) runs on MSC_ConnHdlr {
Harald Welteed848512018-05-24 22:27:58 +02003089 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3090 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte3c86ea02018-05-10 22:28:05 +02003091 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeSIGNAL);
Philipp Maier23000732018-05-18 11:25:37 +02003092 ass_cmd.pdu.bssmap.assignmentRequest.circuitIdentityCode := omit;
3093 ass_cmd.pdu.bssmap.assignmentRequest.aoIPTransportLayer := omit;
3094 exp_compl.pdu.bssmap.assignmentComplete.circuitIdentityCode := omit;
3095 exp_compl.pdu.bssmap.assignmentComplete.aoIPTransportLayer := omit;
Harald Welte3c86ea02018-05-10 22:28:05 +02003096
Philipp Maier23000732018-05-18 11:25:37 +02003097 f_establish_fully(ass_cmd, exp_compl);
Harald Welte3c86ea02018-05-10 22:28:05 +02003098}
3099testcase TC_ciph_mode_a5_0() runs on test_CT {
3100 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02003101 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte3c86ea02018-05-10 22:28:05 +02003102 pars.encr := valueof(t_EncrParams('01'O, f_rnd_octstring(8)));
3103
3104 f_init(1, true);
3105 f_sleep(1.0);
3106 vc_conn := f_start_handler(refers(f_tc_ciph_mode_a5), pars);
3107 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003108 f_shutdown_helper();
Harald Welte3c86ea02018-05-10 22:28:05 +02003109}
3110testcase TC_ciph_mode_a5_1() runs on test_CT {
3111 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02003112 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte3c86ea02018-05-10 22:28:05 +02003113 pars.encr := valueof(t_EncrParams('02'O, f_rnd_octstring(8)));
3114
3115 f_init(1, true);
3116 f_sleep(1.0);
3117 vc_conn := f_start_handler(refers(f_tc_ciph_mode_a5), pars);
3118 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003119 f_shutdown_helper();
Harald Welte3c86ea02018-05-10 22:28:05 +02003120}
3121testcase TC_ciph_mode_a5_3() runs on test_CT {
3122 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02003123 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte3c86ea02018-05-10 22:28:05 +02003124 pars.encr := valueof(t_EncrParams('08'O, f_rnd_octstring(8)));
3125
3126 f_init(1, true);
3127 f_sleep(1.0);
3128 vc_conn := f_start_handler(refers(f_tc_ciph_mode_a5), pars);
3129 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003130 f_shutdown_helper();
Harald Welte3c86ea02018-05-10 22:28:05 +02003131}
3132
Pau Espin Pedrol07866632020-09-03 19:10:55 +02003133/* establish initial channel, enable ciphering followed by assignment to ciphered channel */
3134private function f_tc_assignment_aoip_tla_v6(charstring id) runs on MSC_ConnHdlr {
3135 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3136 var PDU_BSSAP ass_cmd := f_gen_ass_req(aoip_tla := "::3");
3137 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3138 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
3139
3140 f_establish_fully(ass_cmd, exp_compl);
3141}
3142testcase TC_assignment_aoip_tla_v6() runs on test_CT {
3143 var MSC_ConnHdlr vc_conn;
3144 var TestHdlrParams pars := f_gen_test_hdlr_pars();
3145
3146 f_init(1, true);
3147 f_sleep(1.0);
3148 vc_conn := f_start_handler(refers(f_tc_assignment_aoip_tla_v6), pars);
3149 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003150 f_shutdown_helper();
Pau Espin Pedrol07866632020-09-03 19:10:55 +02003151}
3152
Harald Welte3c86ea02018-05-10 22:28:05 +02003153
3154/* establish initial channel, enable ciphering followed by assignment to ciphered channel */
Harald Welte651fcdc2018-05-10 20:23:16 +02003155private function f_tc_assignment_fr_a5(charstring id) runs on MSC_ConnHdlr {
Harald Welteed848512018-05-24 22:27:58 +02003156 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3157 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Weltec1a2fff2017-12-17 11:06:19 +01003158
Harald Welte552620d2017-12-16 23:21:36 +01003159 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3160 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
Harald Welte73cd2712017-12-17 00:44:52 +01003161
Harald Weltea0630032018-03-20 21:09:55 +01003162 f_establish_fully(ass_cmd, exp_compl);
Harald Welte552620d2017-12-16 23:21:36 +01003163}
Harald Welte552620d2017-12-16 23:21:36 +01003164testcase TC_assignment_fr_a5_0() runs on test_CT {
3165 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02003166 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte651fcdc2018-05-10 20:23:16 +02003167 pars.encr := valueof(t_EncrParams('01'O, f_rnd_octstring(8)));
Harald Welte552620d2017-12-16 23:21:36 +01003168
Harald Welte89d42e82017-12-17 16:42:41 +01003169 f_init(1, true);
Harald Welte552620d2017-12-16 23:21:36 +01003170 f_sleep(1.0);
Harald Welte651fcdc2018-05-10 20:23:16 +02003171 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5), pars);
Harald Welte552620d2017-12-16 23:21:36 +01003172 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003173 f_shutdown_helper();
Harald Welte552620d2017-12-16 23:21:36 +01003174}
Harald Welte552620d2017-12-16 23:21:36 +01003175testcase TC_assignment_fr_a5_1() runs on test_CT {
Harald Weltec1a2fff2017-12-17 11:06:19 +01003176 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02003177 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte651fcdc2018-05-10 20:23:16 +02003178 pars.encr := valueof(t_EncrParams('02'O, f_rnd_octstring(8)));
Harald Weltec1a2fff2017-12-17 11:06:19 +01003179
Harald Welte89d42e82017-12-17 16:42:41 +01003180 f_init(1, true);
Harald Weltec1a2fff2017-12-17 11:06:19 +01003181 f_sleep(1.0);
Harald Welte651fcdc2018-05-10 20:23:16 +02003182 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5), pars);
3183 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003184 f_shutdown_helper();
Harald Welte651fcdc2018-05-10 20:23:16 +02003185}
3186testcase TC_assignment_fr_a5_3() runs on test_CT {
3187 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02003188 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte651fcdc2018-05-10 20:23:16 +02003189 pars.encr := valueof(t_EncrParams('08'O, f_rnd_octstring(8)));
Harald Weltec1a2fff2017-12-17 11:06:19 +01003190
Harald Welte651fcdc2018-05-10 20:23:16 +02003191 f_init(1, true);
3192 f_sleep(1.0);
3193 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5), pars);
Harald Weltec1a2fff2017-12-17 11:06:19 +01003194 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003195 f_shutdown_helper();
Harald Weltec1a2fff2017-12-17 11:06:19 +01003196}
3197
Harald Welte552620d2017-12-16 23:21:36 +01003198/* Expect ASSIGNMENT FAIL if mandatory IE is missing */
3199private function f_tc_assignment_fr_a5_1_codec_missing(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02003200 g_pars := f_gen_test_hdlr_pars();
Harald Welte552620d2017-12-16 23:21:36 +01003201 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
Harald Welteed848512018-05-24 22:27:58 +02003202 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte552620d2017-12-16 23:21:36 +01003203 const OCT8 kc := '0001020304050607'O;
3204
3205 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02003206 /* Omit: ass_cmd.pdu.bssmap.assignmentRequest.codecList */
3207
Harald Weltea0630032018-03-20 21:09:55 +01003208 f_establish_fully(ass_cmd, exp_fail);
Harald Welte552620d2017-12-16 23:21:36 +01003209}
Harald Welte552620d2017-12-16 23:21:36 +01003210testcase TC_assignment_fr_a5_1_codec_missing() runs on test_CT {
3211 var MSC_ConnHdlr vc_conn;
3212
Harald Welte89d42e82017-12-17 16:42:41 +01003213 f_init(1, true);
Harald Welte552620d2017-12-16 23:21:36 +01003214 f_sleep(1.0);
3215
Harald Welte8863fa12018-05-10 20:15:27 +02003216 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5_1_codec_missing));
Harald Welte552620d2017-12-16 23:21:36 +01003217 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003218 f_shutdown_helper();
Harald Welte552620d2017-12-16 23:21:36 +01003219}
3220
Harald Welte552620d2017-12-16 23:21:36 +01003221private function f_tc_assignment_fr_a5_4(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02003222 g_pars := f_gen_test_hdlr_pars();
Harald Welteed848512018-05-24 22:27:58 +02003223 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3224 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte552620d2017-12-16 23:21:36 +01003225 const OCT8 kc := '0001020304050607'O;
3226 const OCT16 kc128 := kc & kc;
3227
3228 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3229 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
Harald Weltea0630032018-03-20 21:09:55 +01003230 f_establish_fully(ass_cmd, exp_compl);
Harald Welte38b2a102017-12-23 02:42:58 +01003231 f_cipher_mode('10'O, kc, kc128, true);
Harald Welte552620d2017-12-16 23:21:36 +01003232 /* TODO: expect GSM0808_CAUSE_CIPHERING_ALGORITHM_NOT_SUPPORTED cause value */
Harald Welte552620d2017-12-16 23:21:36 +01003233}
Harald Welte552620d2017-12-16 23:21:36 +01003234testcase TC_assignment_fr_a5_4() runs on test_CT {
3235 var MSC_ConnHdlr vc_conn;
3236
Harald Welte89d42e82017-12-17 16:42:41 +01003237 f_init(1, true);
Harald Welte552620d2017-12-16 23:21:36 +01003238 f_sleep(1.0);
3239
Harald Welte8863fa12018-05-10 20:15:27 +02003240 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5_4));
Harald Welte552620d2017-12-16 23:21:36 +01003241 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003242 f_shutdown_helper();
Harald Welte552620d2017-12-16 23:21:36 +01003243}
3244
3245
Harald Welte4532e0a2017-12-23 02:05:44 +01003246private function f_tc_assignment_sign(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02003247 g_pars := f_gen_test_hdlr_pars();
Harald Welte4532e0a2017-12-23 02:05:44 +01003248 var template PDU_BSSAP exp_compl := tr_BSSMAP_AssignmentComplete(omit, omit);
Philipp Maier48604732018-10-09 15:00:37 +02003249 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte4532e0a2017-12-23 02:05:44 +01003250 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeSIGNAL);
Daniel Willmannebdecc02020-08-12 15:30:17 +02003251
3252 f_statsd_reset();
Harald Weltea0630032018-03-20 21:09:55 +01003253 f_establish_fully(ass_cmd, exp_compl);
Daniel Willmannebdecc02020-08-12 15:30:17 +02003254
3255 var StatsDExpects expect := {
Daniel Willmannc5398f72020-09-21 10:41:35 +02003256 { name := "TTCN3.bts.0.chreq.total", mtype := "c", min := 1, max := 1},
3257 { name := "TTCN3.bts.0.chreq.successful", mtype := "c", min := 1, max := 1},
Daniel Willmannebdecc02020-08-12 15:30:17 +02003258 { name := "TTCN3.bsc.0.assignment.attempted", mtype := "c", min := 1, max := 1},
3259 { name := "TTCN3.bsc.0.assignment.completed", mtype := "c", min := 1, max := 1}
3260 };
3261 f_statsd_expect(expect);
Harald Welte4532e0a2017-12-23 02:05:44 +01003262}
3263
3264testcase TC_assignment_sign() runs on test_CT {
3265 var MSC_ConnHdlr vc_conn;
3266
3267 f_init(1, true);
3268 f_sleep(1.0);
3269
Harald Welte8863fa12018-05-10 20:15:27 +02003270 vc_conn := f_start_handler(refers(f_tc_assignment_sign));
Harald Welte4532e0a2017-12-23 02:05:44 +01003271 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003272 f_shutdown_helper();
Harald Welte4532e0a2017-12-23 02:05:44 +01003273}
3274
Harald Welte60aa5762018-03-21 19:33:13 +01003275/***********************************************************************
3276 * Codec (list) testing
3277 ***********************************************************************/
3278
3279/* check if the given rsl_mode is compatible with the a_elem */
3280private function f_match_codec(BSSMAP_FIELD_CodecElement a_elem, RSL_IE_ChannelMode rsl_mode)
3281return boolean {
3282 select (a_elem.codecType) {
3283 case (GSM_FR) {
3284 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM1))) {
3285 return true;
3286 }
3287 }
3288 case (GSM_HR) {
3289 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_H, RSL_CMOD_SP_GSM1))) {
3290 return true;
3291 }
3292 }
3293 case (GSM_EFR) {
3294 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM2))) {
3295 return true;
3296 }
3297 }
3298 case (FR_AMR) {
3299 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM3))) {
3300 return true;
3301 }
3302 }
3303 case (HR_AMR) {
3304 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_H, RSL_CMOD_SP_GSM3))) {
3305 return true;
3306 }
3307 }
3308 case else { }
3309 }
3310 return false;
3311}
3312
3313/* check if the given rsl_mode is compatible with the a_list */
3314private function f_match_codecs(BSSMAP_IE_SpeechCodecList a_list, RSL_IE_ChannelMode rsl_mode)
3315return boolean {
3316 for (var integer i := 0; i < sizeof(a_list); i := i+1) {
3317 if (f_match_codec(a_list.codecElements[i], rsl_mode)) {
3318 return true;
3319 }
3320 }
3321 return false;
3322}
3323
3324/* determine BSSMAP_IE_ChannelType from *first* element of BSSMAP_FIELD_CodecElement */
Philipp Maier61f6b572018-07-06 14:03:38 +02003325function f_BSSMAP_chtype_from_codec(BSSMAP_FIELD_CodecElement a_elem)
Harald Welte60aa5762018-03-21 19:33:13 +01003326return BSSMAP_IE_ChannelType {
3327 /* FIXME: actually look at all elements of BSSMAP_IE_SpeechCodecList */
3328 var BSSMAP_IE_ChannelType ret := valueof(ts_BSSMAP_IE_ChannelType);
3329 select (a_elem.codecType) {
3330 case (GSM_FR) {
3331 ret.channelRateAndType := ChRate_TCHF;
3332 ret.speechId_DataIndicator := Spdi_TCHF_FR;
3333 }
3334 case (GSM_HR) {
3335 ret.channelRateAndType := ChRate_TCHH;
3336 ret.speechId_DataIndicator := Spdi_TCHH_HR;
3337 }
3338 case (GSM_EFR) {
3339 ret.channelRateAndType := ChRate_TCHF;
3340 ret.speechId_DataIndicator := Spdi_TCHF_EFR;
3341 }
3342 case (FR_AMR) {
3343 ret.channelRateAndType := ChRate_TCHF;
3344 ret.speechId_DataIndicator := Spdi_TCHF_AMR;
3345 }
3346 case (HR_AMR) {
3347 ret.channelRateAndType := ChRate_TCHH;
3348 ret.speechId_DataIndicator := Spdi_TCHH_AMR;
3349 }
3350 case else {
3351 setverdict(fail, "Unsupported codec ", a_elem);
Daniel Willmannafce8662018-07-06 23:11:32 +02003352 mtc.stop;
Harald Welte60aa5762018-03-21 19:33:13 +01003353 }
3354 }
3355 return ret;
3356}
3357
Harald Weltea63b9102018-03-22 20:36:16 +01003358private function f_rsl_chmod_tmpl_from_codec(BSSMAP_FIELD_CodecElement a_elem)
3359return template RSL_IE_Body {
3360 var template RSL_IE_Body mode_ie := {
3361 chan_mode := {
3362 len := ?,
3363 reserved := ?,
3364 dtx_d := ?,
3365 dtx_u := ?,
3366 spd_ind := RSL_SPDI_SPEECH,
3367 ch_rate_type := -,
3368 coding_alg_rate := -
3369 }
3370 }
3371
3372 select (a_elem.codecType) {
3373 case (GSM_FR) {
3374 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_F;
3375 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM1;
3376 }
3377 case (GSM_HR) {
3378 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_H;
3379 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM1;
3380 }
3381 case (GSM_EFR) {
3382 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_F;
3383 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM2;
3384 }
3385 case (FR_AMR) {
3386 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_F;
3387 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM3;
3388 }
3389 case (HR_AMR) {
3390 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_H;
3391 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM3;
3392 }
3393 }
3394 return mode_ie;
3395}
3396
Harald Welte60aa5762018-03-21 19:33:13 +01003397type record CodecListTest {
3398 BSSMAP_IE_SpeechCodecList codec_list,
3399 charstring id
3400}
3401type record of CodecListTest CodecListTests
3402
3403private function f_TC_assignment_codec(charstring id) runs on MSC_ConnHdlr {
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02003404 var PDU_BSSAP ass_cmd := f_gen_ass_req(g_pars.use_osmux);
3405 var template PDU_BSSAP exp_compl := f_gen_exp_compl(g_pars.use_osmux);
Harald Welte60aa5762018-03-21 19:33:13 +01003406
3407 /* puzzle together the ASSIGNMENT REQ for given codec[s] */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003408 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
Harald Welte79f3f542018-05-25 20:02:37 +02003409 ass_cmd.pdu.bssmap.assignmentRequest.codecList := g_pars.ass_codec_list;
3410 exp_compl.pdu.bssmap.assignmentComplete.speechCodec.codecElements[0] :=
3411 g_pars.ass_codec_list.codecElements[0];
Philipp Maierd0e64b02019-03-13 14:15:23 +01003412 if (isvalue(g_pars.expect_mr_s0_s7)) {
3413 exp_compl.pdu.bssmap.assignmentComplete.speechCodec.codecElements[0].s0_7 :=
3414 g_pars.expect_mr_s0_s7;
3415 }
Harald Welte79f3f542018-05-25 20:02:37 +02003416 }
Harald Welte60aa5762018-03-21 19:33:13 +01003417 ass_cmd.pdu.bssmap.assignmentRequest.channelType :=
3418 f_BSSMAP_chtype_from_codec(g_pars.ass_codec_list.codecElements[0]);
Harald Welte60aa5762018-03-21 19:33:13 +01003419 log("expecting ASS COMPL like this: ", exp_compl);
3420
3421 f_establish_fully(ass_cmd, exp_compl);
Harald Weltea63b9102018-03-22 20:36:16 +01003422
3423 /* Verify that the RSL-side activation actually matches our expectations */
3424 var RSL_Message rsl := f_rslem_get_last_act(RSL_PROC, 0, g_chan_nr);
3425
3426 var RSL_IE_Body mode_ie;
3427 if (f_rsl_find_ie(rsl, RSL_IE_CHAN_MODE, mode_ie) == false) {
3428 setverdict(fail, "Couldn't find CHAN_MODE IE");
Daniel Willmannafce8662018-07-06 23:11:32 +02003429 mtc.stop;
Harald Weltea63b9102018-03-22 20:36:16 +01003430 }
3431 var template RSL_IE_Body t_mode_ie := f_rsl_chmod_tmpl_from_codec(g_pars.ass_codec_list.codecElements[0]);
3432 if (not match(mode_ie, t_mode_ie)) {
3433 setverdict(fail, "RSL Channel Mode IE doesn't match expectation");
3434 }
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02003435
3436 var RSL_IE_Body mr_conf;
3437 if (g_pars.expect_mr_conf_ie != omit) {
3438 if (f_rsl_find_ie(rsl, RSL_IE_MR_CONFIG, mr_conf) == false) {
3439 setverdict(fail, "Missing MR CONFIG IE in RSL Chan Activ");
Daniel Willmannafce8662018-07-06 23:11:32 +02003440 mtc.stop;
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02003441 }
3442 log("found RSL MR CONFIG IE: ", mr_conf);
3443
3444 if (not match(mr_conf, g_pars.expect_mr_conf_ie)) {
3445 setverdict(fail, "RSL MR CONFIG IE does not match expectation. Expected: ",
3446 g_pars.expect_mr_conf_ie);
3447 }
3448 } else {
3449 if (f_rsl_find_ie(rsl, RSL_IE_MR_CONFIG, mr_conf) == true) {
3450 log("found RSL MR CONFIG IE: ", mr_conf);
3451 setverdict(fail, "Found MR CONFIG IE in RSL Chan Activ, expecting omit");
Daniel Willmannafce8662018-07-06 23:11:32 +02003452 mtc.stop;
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02003453 }
3454 }
Harald Welte60aa5762018-03-21 19:33:13 +01003455}
3456
Philipp Maierd0e64b02019-03-13 14:15:23 +01003457private function f_TC_assignment_codec_fail(charstring id) runs on MSC_ConnHdlr {
3458
3459 var PDU_BSSAP ass_cmd := f_gen_ass_req();
3460 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
3461
3462 /* puzzle together the ASSIGNMENT REQ for given codec[s] */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003463 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
Philipp Maierd0e64b02019-03-13 14:15:23 +01003464 ass_cmd.pdu.bssmap.assignmentRequest.codecList := g_pars.ass_codec_list;
3465 }
3466 ass_cmd.pdu.bssmap.assignmentRequest.channelType :=
3467 f_BSSMAP_chtype_from_codec(g_pars.ass_codec_list.codecElements[0]);
3468 log("expecting ASS FAIL like this: ", exp_fail);
3469
3470 f_establish_fully(ass_cmd, exp_fail);
3471}
3472
Harald Welte60aa5762018-03-21 19:33:13 +01003473testcase TC_assignment_codec_fr() runs on test_CT {
Philipp Maier48604732018-10-09 15:00:37 +02003474 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte60aa5762018-03-21 19:33:13 +01003475 var MSC_ConnHdlr vc_conn;
3476
3477 f_init(1, true);
3478 f_sleep(1.0);
3479
3480 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
Harald Welte8863fa12018-05-10 20:15:27 +02003481 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01003482 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003483 f_shutdown_helper();
Harald Welte60aa5762018-03-21 19:33:13 +01003484}
3485
3486testcase TC_assignment_codec_hr() runs on test_CT {
Philipp Maier48604732018-10-09 15:00:37 +02003487 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte60aa5762018-03-21 19:33:13 +01003488 var MSC_ConnHdlr vc_conn;
3489
3490 f_init(1, true);
3491 f_sleep(1.0);
3492
3493 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR}));
Harald Welte8863fa12018-05-10 20:15:27 +02003494 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01003495 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003496 f_shutdown_helper();
Harald Welte60aa5762018-03-21 19:33:13 +01003497}
3498
3499testcase TC_assignment_codec_efr() runs on test_CT {
Philipp Maier48604732018-10-09 15:00:37 +02003500 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte60aa5762018-03-21 19:33:13 +01003501 var MSC_ConnHdlr vc_conn;
3502
3503 f_init(1, true);
3504 f_sleep(1.0);
3505
3506 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecEFR}));
Harald Welte8863fa12018-05-10 20:15:27 +02003507 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01003508 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003509 f_shutdown_helper();
Harald Welte60aa5762018-03-21 19:33:13 +01003510}
3511
Philipp Maierd0e64b02019-03-13 14:15:23 +01003512/* Allow 5,90k only (current default config) */
3513private function f_allow_amr_rate_5_90k() runs on test_CT {
3514 f_vty_enter_cfg_msc(BSCVTY, 0);
3515 f_vty_transceive(BSCVTY, "amr-config 12_2k forbidden");
3516 f_vty_transceive(BSCVTY, "amr-config 10_2k forbidden");
3517 f_vty_transceive(BSCVTY, "amr-config 7_95k forbidden");
3518 f_vty_transceive(BSCVTY, "amr-config 7_40k forbidden");
3519 f_vty_transceive(BSCVTY, "amr-config 6_70k forbidden");
3520 f_vty_transceive(BSCVTY, "amr-config 5_90k allowed");
3521 f_vty_transceive(BSCVTY, "amr-config 5_15k forbidden");
3522 f_vty_transceive(BSCVTY, "amr-config 4_75k forbidden");
3523 f_vty_transceive(BSCVTY, "exit");
3524 f_vty_transceive(BSCVTY, "exit");
3525}
3526
3527/* Allow 4,75k, 5,90k, 4,70k and 12,2k, which are the most common rates
3528 * ("Config-NB-Code = 1") */
3529private function f_allow_amr_rate_4_75k_5_90k_7_40k_12_20k() runs on test_CT {
3530 f_vty_enter_cfg_msc(BSCVTY, 0);
3531 f_vty_transceive(BSCVTY, "amr-config 12_2k allowed");
3532 f_vty_transceive(BSCVTY, "amr-config 10_2k forbidden");
3533 f_vty_transceive(BSCVTY, "amr-config 7_95k forbidden");
3534 f_vty_transceive(BSCVTY, "amr-config 7_40k allowed");
3535 f_vty_transceive(BSCVTY, "amr-config 6_70k forbidden");
3536 f_vty_transceive(BSCVTY, "amr-config 5_90k allowed");
3537 f_vty_transceive(BSCVTY, "amr-config 5_15k forbidden");
3538 f_vty_transceive(BSCVTY, "amr-config 4_75k allowed");
3539 f_vty_transceive(BSCVTY, "exit");
3540 f_vty_transceive(BSCVTY, "exit");
3541}
3542
Harald Welte60aa5762018-03-21 19:33:13 +01003543testcase TC_assignment_codec_amr_f() runs on test_CT {
Philipp Maier48604732018-10-09 15:00:37 +02003544 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte60aa5762018-03-21 19:33:13 +01003545 var MSC_ConnHdlr vc_conn;
Philipp Maier7695a0d2018-09-27 17:52:14 +02003546
3547 /* Note: This setups the codec configuration. The parameter payload in
3548 * mr_conf must be consistant with the parameter codecElements in pars
3549 * and also must match the amr-config in osmo-bsc.cfg! */
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02003550 var RSL_IE_Body mr_conf := {
3551 other := {
3552 len := 2,
3553 payload := '2804'O
3554 }
3555 };
Harald Welte60aa5762018-03-21 19:33:13 +01003556
Philipp Maier7695a0d2018-09-27 17:52:14 +02003557 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_F}));
Philipp Maier806f8f12019-03-12 12:13:41 +01003558 pars.ass_codec_list.codecElements[0].s0_7 := '00000100'B; /* 5,90k */
Philipp Maier7695a0d2018-09-27 17:52:14 +02003559 pars.ass_codec_list.codecElements[0].s8_15 := '01010111'B;
3560 pars.expect_mr_conf_ie := mr_conf;
3561
Harald Welte60aa5762018-03-21 19:33:13 +01003562 f_init(1, true);
3563 f_sleep(1.0);
3564
Harald Welte8863fa12018-05-10 20:15:27 +02003565 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01003566 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003567 f_shutdown_helper();
Harald Welte60aa5762018-03-21 19:33:13 +01003568}
3569
3570testcase TC_assignment_codec_amr_h() runs on test_CT {
Philipp Maier48604732018-10-09 15:00:37 +02003571 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte60aa5762018-03-21 19:33:13 +01003572 var MSC_ConnHdlr vc_conn;
Philipp Maier7695a0d2018-09-27 17:52:14 +02003573
3574 /* See note above */
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02003575 var RSL_IE_Body mr_conf := {
3576 other := {
3577 len := 2,
3578 payload := '2804'O
3579 }
3580 };
Harald Welte60aa5762018-03-21 19:33:13 +01003581
Philipp Maier7695a0d2018-09-27 17:52:14 +02003582 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_H}));
Philipp Maier806f8f12019-03-12 12:13:41 +01003583 pars.ass_codec_list.codecElements[0].s0_7 := '00000100'B; /* 5,90k */
Philipp Maier7695a0d2018-09-27 17:52:14 +02003584 pars.ass_codec_list.codecElements[0].s8_15 := '00000111'B;
3585 pars.expect_mr_conf_ie := mr_conf;
3586
Harald Welte60aa5762018-03-21 19:33:13 +01003587 f_init(1, true);
3588 f_sleep(1.0);
3589
Harald Welte8863fa12018-05-10 20:15:27 +02003590 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01003591 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003592 f_shutdown_helper();
Harald Welte60aa5762018-03-21 19:33:13 +01003593}
3594
Philipp Maierd0e64b02019-03-13 14:15:23 +01003595function f_TC_assignment_codec_amr(boolean fr, octetstring mrconf, bitstring s8_s0, bitstring exp_s8_s0)
3596runs on test_CT {
3597
3598 var TestHdlrParams pars := f_gen_test_hdlr_pars();
3599 var MSC_ConnHdlr vc_conn;
3600
3601 /* See note above */
3602 var RSL_IE_Body mr_conf := {
3603 other := {
3604 len := lengthof(mrconf),
3605 payload := mrconf
3606 }
3607 };
3608
3609 if (fr) {
3610 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_F}));
3611 } else {
3612 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_H}));
3613 }
3614 pars.ass_codec_list.codecElements[0].s0_7 := s8_s0;
3615 pars.ass_codec_list.codecElements[0].s8_15 := '00000111'B;
3616 pars.expect_mr_conf_ie := mr_conf;
3617 pars.expect_mr_s0_s7 := exp_s8_s0;
3618
3619 f_init(1, true);
3620 f_allow_amr_rate_4_75k_5_90k_7_40k_12_20k();
3621 f_sleep(1.0);
3622
3623 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
3624 vc_conn.done;
3625 f_allow_amr_rate_5_90k();
3626}
3627
3628function f_TC_assignment_codec_amr_fail(boolean fr, bitstring s8_s0)
3629runs on test_CT {
3630
3631 var TestHdlrParams pars := f_gen_test_hdlr_pars();
3632 var MSC_ConnHdlr vc_conn;
3633
3634 if (fr) {
3635 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_F}));
3636 } else {
3637 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_H}));
3638 }
3639 pars.ass_codec_list.codecElements[0].s0_7 := s8_s0;
3640 pars.ass_codec_list.codecElements[0].s8_15 := '00000111'B;
3641
3642 f_init(1, true);
3643 f_allow_amr_rate_4_75k_5_90k_7_40k_12_20k();
3644 f_sleep(1.0);
3645
3646 vc_conn := f_start_handler(refers(f_TC_assignment_codec_fail), pars);
3647 vc_conn.done;
3648 f_allow_amr_rate_5_90k();
3649}
3650
3651
3652/* Set S1, we expect an AMR multirate configuration IE with all four rates
3653 * set. */
3654testcase TC_assignment_codec_amr_f_S1() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003655 f_TC_assignment_codec_amr(true, '289520882208'O, '00000010'B, '00000010'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003656 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003657}
3658
3659/* Set S1, we expect an AMR multirate configuration IE with the lower three
3660 * rates set. */
3661testcase TC_assignment_codec_amr_h_S1() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003662 f_TC_assignment_codec_amr(false, '2815208820'O, '00000010'B, '00000010'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003663 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003664}
3665
3666/* Set S1 and two other rates, we expect an AMR MULTIRATE CONFIGURATION IE with
3667 * all four rates (and only S1 set in the ASSIGNMENT COMPLETE) */
3668testcase TC_assignment_codec_amr_f_S124() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003669 f_TC_assignment_codec_amr(true, '289520882208'O, '00010110'B, '00000010'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003670 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003671}
3672
3673/* Set S1 and two other rates, we expect an AMR MULTIRATE CONFIGURATION IE with
3674 * all four rates (and only S1 set in the ASSIGNMENT COMPLETE) */
3675testcase TC_assignment_codec_amr_h_S124() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003676 f_TC_assignment_codec_amr(false, '2815208820'O, '00010110'B, '00000010'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003677 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003678}
3679
3680/* The following block of tests selects more and more rates until all four
3681 * possible rates are in the active set (full rate) */
3682testcase TC_assignment_codec_amr_f_S0() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003683 f_TC_assignment_codec_amr(true, '2801'O, '00000001'B, '00000001'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003684 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003685}
3686
3687testcase TC_assignment_codec_amr_f_S02() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003688 f_TC_assignment_codec_amr(true, '28052080'O, '00000101'B, '00000101'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003689 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003690}
3691
3692testcase TC_assignment_codec_amr_f_S024() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003693 f_TC_assignment_codec_amr(true, '2815208820'O, '00010101'B, '00010101'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003694 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003695}
3696
3697testcase TC_assignment_codec_amr_f_S0247() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003698 f_TC_assignment_codec_amr(true, '289520882208'O, '10010101'B, '10010101'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003699 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003700}
3701
3702/* The following block of tests selects more and more rates until all three
3703 * possible rates are in the active set (half rate) */
3704testcase TC_assignment_codec_amr_h_S0() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003705 f_TC_assignment_codec_amr(false, '2801'O, '00000001'B, '00000001'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003706 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003707}
3708
3709testcase TC_assignment_codec_amr_h_S02() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003710 f_TC_assignment_codec_amr(false, '28052080'O, '00000101'B, '00000101'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003711 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003712}
3713
3714testcase TC_assignment_codec_amr_h_S024() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003715 f_TC_assignment_codec_amr(false, '2815208820'O, '00010101'B, '00010101'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003716 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003717}
3718
3719/* The following block tests what happens when the MSC does offer rate
3720 * configurations that are not supported by the BSC. Normally such situations
3721 * should not happen because the MSC gets informed by the BSC in advance via
3722 * the L3 COMPLETE message which rates are applicable. The MSC should not try
3723 * to offer rates that are not applicable anyway. */
3724
3725testcase TC_assignment_codec_amr_h_S0247() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003726 /* Try to include 12,2k in into the active set even though the channel
3727 * is half rate only. The BSC is expected to remove the 12,0k */
3728 f_TC_assignment_codec_amr(false, '2815208820'O, '10010101'B, '00010101'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003729 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003730}
3731
3732testcase TC_assignment_codec_amr_f_S01234567() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003733 /* See what happens when all rates are selected at once. Since then
3734 * Also S1 is selected, this setting will be prefered and we should
3735 * get 12.2k, 7,40k, 5,90k, and 4,75k in the active set. */
3736 f_TC_assignment_codec_amr(true, '289520882208'O, '11111111'B, '00000010'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003737 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003738}
3739
3740testcase TC_assignment_codec_amr_f_S0234567() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003741 /* Same as above, but with S1 missing, the MSC is then expected to
3742 * select the currently supported rates, which are also 12.2k, 7,40k,
3743 * 5,90k, and 4,75k, into the active set. */
3744 f_TC_assignment_codec_amr(true, '289520882208'O, '11111101'B, '10010101'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003745 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003746}
3747
3748testcase TC_assignment_codec_amr_f_zero() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003749 /* Try to select no rates at all */
3750 f_TC_assignment_codec_amr_fail(true, '00000000'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003751 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003752}
3753
3754testcase TC_assignment_codec_amr_f_unsupp() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003755 /* Try to select only unsupported rates */
3756 f_TC_assignment_codec_amr_fail(true, '01101000'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003757 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003758}
3759
3760testcase TC_assignment_codec_amr_h_S7() runs on test_CT {
Pau Espin Pedrol00f40e82020-09-23 14:16:04 +02003761 /* Try to select 12,2k for half rate */
3762 f_TC_assignment_codec_amr_fail(false, '10000000'B);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003763 f_shutdown_helper();
Philipp Maierd0e64b02019-03-13 14:15:23 +01003764}
3765
Philipp Maierac09bfc2019-01-08 13:41:39 +01003766private function f_disable_all_tch_f() runs on test_CT {
Philipp Maierc704a882019-01-29 15:58:52 +01003767 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 1 sub-slot 0 borken");
3768 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 2 sub-slot 0 borken");
3769 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 3 sub-slot 0 borken");
3770 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 4 sub-slot 0 borken");
Philipp Maierac09bfc2019-01-08 13:41:39 +01003771}
3772
3773private function f_disable_all_tch_h() runs on test_CT {
Philipp Maierc704a882019-01-29 15:58:52 +01003774 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 5 sub-slot 0 borken");
3775 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 5 sub-slot 1 borken");
Philipp Maierac09bfc2019-01-08 13:41:39 +01003776}
3777
3778private function f_enable_all_tch() runs on test_CT {
Philipp Maierc704a882019-01-29 15:58:52 +01003779 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 1 sub-slot 0 unused");
3780 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 2 sub-slot 0 unused");
3781 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 3 sub-slot 0 unused");
3782 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 4 sub-slot 0 unused");
3783 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 5 sub-slot 0 unused");
3784 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 5 sub-slot 1 unused");
Philipp Maierac09bfc2019-01-08 13:41:39 +01003785}
3786
3787/* Allow HR only */
3788private function f_TC_assignment_codec_xr_exhausted_req_hr(charstring id) runs on MSC_ConnHdlr {
3789 g_pars := f_gen_test_hdlr_pars();
3790 var PDU_BSSAP ass_cmd := f_gen_ass_req();
3791 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3792 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3793 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '09'O;
3794 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '05'O;
3795 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR}));
3796 f_establish_fully(ass_cmd, exp_compl);
3797}
3798
3799/* Allow FR only */
3800private function f_TC_assignment_codec_xr_exhausted_req_fr(charstring id) runs on MSC_ConnHdlr {
3801 g_pars := f_gen_test_hdlr_pars();
3802 var PDU_BSSAP ass_cmd := f_gen_ass_req();
3803 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3804 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3805 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '08'O;
3806 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '01'O;
3807 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
3808 f_establish_fully(ass_cmd, exp_compl);
3809}
3810
3811/* Allow HR only (expect assignment failure) */
3812private function f_TC_assignment_codec_xr_exhausted_req_hr_fail(charstring id) runs on MSC_ConnHdlr {
3813 g_pars := f_gen_test_hdlr_pars();
3814 var PDU_BSSAP ass_cmd := f_gen_ass_req();
3815 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
3816 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3817 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '09'O;
3818 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '05'O;
3819 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR}));
3820 f_establish_fully(ass_cmd, exp_fail);
3821}
3822
3823/* Allow FR only (expect assignment failure) */
3824private function f_TC_assignment_codec_xr_exhausted_req_fr_fail(charstring id) runs on MSC_ConnHdlr {
3825 g_pars := f_gen_test_hdlr_pars();
3826 var PDU_BSSAP ass_cmd := f_gen_ass_req();
3827 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
3828 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3829 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '08'O;
3830 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '01'O;
3831 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
3832 f_establish_fully(ass_cmd, exp_fail);
3833}
3834
3835/* Allow FR and HR, but prefer FR */
3836private function f_TC_assignment_codec_fr_exhausted_req_fr_hr(charstring id) runs on MSC_ConnHdlr {
3837 g_pars := f_gen_test_hdlr_pars();
3838 var PDU_BSSAP ass_cmd := f_gen_ass_req();
3839 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3840 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3841 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0A'O; /* Prefer FR */
3842 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8105'O;
3843 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR, ts_CodecHR}));
3844 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000101'B; /* Expect HR */
3845 f_establish_fully(ass_cmd, exp_compl);
3846}
3847
3848/* Allow FR and HR, but prefer HR */
3849private function f_TC_assignment_codec_fr_exhausted_req_hr_fr(charstring id) runs on MSC_ConnHdlr {
3850 g_pars := f_gen_test_hdlr_pars();
3851 var PDU_BSSAP ass_cmd := f_gen_ass_req();
3852 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3853 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3854 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0B'O; /* Prefer HR */
3855 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8501'O;
3856 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR, ts_CodecFR}));
3857 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000101'B; /* Expect HR */
3858 f_establish_fully(ass_cmd, exp_compl);
3859}
3860
3861/* Allow FR and HR, but prefer FR */
3862private function f_TC_assignment_codec_hr_exhausted_req_fr_hr(charstring id) runs on MSC_ConnHdlr {
3863 g_pars := f_gen_test_hdlr_pars();
3864 var PDU_BSSAP ass_cmd := f_gen_ass_req();
3865 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3866 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3867 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0A'O; /* Prefer FR */
3868 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8105'O;
3869 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR, ts_CodecHR}));
3870 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000001'B; /* Expect FR */
3871 f_establish_fully(ass_cmd, exp_compl);
3872}
3873
3874/* Allow FR and HR, but prefer HR */
3875private function f_TC_assignment_codec_hr_exhausted_req_hr_fr(charstring id) runs on MSC_ConnHdlr {
3876 g_pars := f_gen_test_hdlr_pars();
3877 var PDU_BSSAP ass_cmd := f_gen_ass_req();
3878 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3879 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3880 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0B'O; /* Prefer HR */
3881 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8501'O;
3882 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR, ts_CodecFR}));
3883 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000001'B; /* Expect FR */
3884 f_establish_fully(ass_cmd, exp_compl);
3885}
3886
3887/* Request a HR channel while all FR channels are exhausted, this is expected
3888 * to work without conflicts */
3889testcase TC_assignment_codec_fr_exhausted_req_hr() runs on test_CT {
3890 var MSC_ConnHdlr vc_conn;
3891 f_init(1, true);
3892 f_sleep(1.0);
3893 f_enable_all_tch();
3894 f_disable_all_tch_f();
3895 vc_conn := f_start_handler(refers(f_TC_assignment_codec_xr_exhausted_req_hr));
3896 vc_conn.done;
3897 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003898 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01003899}
3900
3901/* Request a FR channel while all FR channels are exhausted, this is expected
3902 * to fail. */
3903testcase TC_assignment_codec_fr_exhausted_req_fr() runs on test_CT {
3904 var MSC_ConnHdlr vc_conn;
3905 f_init(1, true);
3906 f_sleep(1.0);
3907 f_enable_all_tch();
3908 f_disable_all_tch_f();
3909 vc_conn := f_start_handler(refers(f_TC_assignment_codec_xr_exhausted_req_fr_fail));
3910 vc_conn.done;
3911 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003912 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01003913}
3914
3915/* Request a FR (prefered) or alternatively a HR channel while all FR channels
3916 * are exhausted, this is expected to be resolved by selecting a HR channel. */
3917testcase TC_assignment_codec_fr_exhausted_req_fr_hr() runs on test_CT {
3918 var MSC_ConnHdlr vc_conn;
3919 f_init(1, true);
3920 f_sleep(1.0);
3921 f_enable_all_tch();
3922 f_disable_all_tch_f();
3923 vc_conn := f_start_handler(refers(f_TC_assignment_codec_fr_exhausted_req_fr_hr));
3924 vc_conn.done;
3925 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003926 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01003927}
3928
3929/* Request a HR (prefered) or alternatively a FR channel while all FR channels
3930 * are exhausted, this is expected to work without conflicts. */
3931testcase TC_assignment_codec_fr_exhausted_req_hr_fr() runs on test_CT {
3932 var MSC_ConnHdlr vc_conn;
3933 f_init(1, true);
3934 f_sleep(1.0);
3935 f_enable_all_tch();
3936 f_disable_all_tch_f();
3937 vc_conn := f_start_handler(refers(f_TC_assignment_codec_fr_exhausted_req_hr_fr));
3938 vc_conn.done;
3939 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003940 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01003941}
3942
3943/* Request a FR channel while all HR channels are exhausted, this is expected
3944 * to work without conflicts */
3945testcase TC_assignment_codec_hr_exhausted_req_fr() runs on test_CT {
3946 var MSC_ConnHdlr vc_conn;
3947 f_init(1, true);
3948 f_sleep(1.0);
3949 f_enable_all_tch();
3950 f_disable_all_tch_h();
3951 vc_conn := f_start_handler(refers(f_TC_assignment_codec_xr_exhausted_req_fr));
3952 vc_conn.done;
3953 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003954 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01003955}
3956
3957/* Request a HR channel while all HR channels are exhausted, this is expected
3958 * to fail. */
3959testcase TC_assignment_codec_hr_exhausted_req_hr() runs on test_CT {
3960 var MSC_ConnHdlr vc_conn;
3961 f_init(1, true);
3962 f_sleep(1.0);
3963 f_enable_all_tch();
3964 f_disable_all_tch_h();
3965 vc_conn := f_start_handler(refers(f_TC_assignment_codec_xr_exhausted_req_hr_fail));
3966 vc_conn.done;
3967 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003968 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01003969}
3970
3971/* Request a HR (prefered) or alternatively a FR channel while all HR channels
3972 * are exhausted, this is expected to be resolved by selecting a FR channel. */
3973testcase TC_assignment_codec_hr_exhausted_req_hr_fr() runs on test_CT {
3974 var MSC_ConnHdlr vc_conn;
3975 f_init(1, true);
3976 f_sleep(1.0);
3977 f_enable_all_tch();
3978 f_disable_all_tch_h();
3979 vc_conn := f_start_handler(refers(f_TC_assignment_codec_hr_exhausted_req_hr_fr));
3980 vc_conn.done;
3981 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003982 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01003983}
3984
3985/* Request a FR (prefered) or alternatively a HR channel while all HR channels
3986 * are exhausted, this is expected to work without conflicts. */
3987testcase TC_assignment_codec_hr_exhausted_req_fr_hr() runs on test_CT {
3988 var MSC_ConnHdlr vc_conn;
3989 f_init(1, true);
3990 f_sleep(1.0);
3991 f_enable_all_tch();
3992 f_disable_all_tch_h();
3993 vc_conn := f_start_handler(refers(f_TC_assignment_codec_hr_exhausted_req_fr_hr));
3994 vc_conn.done;
3995 f_enable_all_tch();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02003996 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01003997}
3998
3999/* Allow FR and HR, but prefer HR */
4000private function f_TC_assignment_codec_req_hr_fr(charstring id) runs on MSC_ConnHdlr {
4001 g_pars := f_gen_test_hdlr_pars();
4002 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4003 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4004 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4005 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0B'O; /* Prefer HR */
4006 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8501'O;
4007 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR, ts_CodecFR}));
4008 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000101'B; /* Expect HR */
4009 f_establish_fully(ass_cmd, exp_compl);
4010}
4011
4012/* Allow FR and HR, but prefer FR */
4013private function f_TC_assignment_codec_req_fr_hr(charstring id) runs on MSC_ConnHdlr {
4014 g_pars := f_gen_test_hdlr_pars();
4015 var PDU_BSSAP ass_cmd := f_gen_ass_req();
4016 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4017 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4018 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0A'O; /* Prefer FR */
4019 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8105'O;
4020 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR, ts_CodecHR}));
4021 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000001'B; /* Expect FR */
4022 f_establish_fully(ass_cmd, exp_compl);
4023}
4024
4025/* Request a HR (prefered) or alternatively a FR channel, it is expected that
4026 * HR, which is the prefered type, is selected. */
4027testcase TC_assignment_codec_req_hr_fr() runs on test_CT {
4028 var MSC_ConnHdlr vc_conn;
4029 f_init(1, true);
4030 f_sleep(1.0);
4031 f_enable_all_tch();
4032 vc_conn := f_start_handler(refers(f_TC_assignment_codec_req_hr_fr));
4033 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004034 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004035}
4036
4037/* Request a FR (prefered) or alternatively a HR channel, it is expected that
4038 * FR, which is the prefered type, is selected. */
4039testcase TC_assignment_codec_req_fr_hr() runs on test_CT {
4040 var MSC_ConnHdlr vc_conn;
4041 f_init(1, true);
4042 f_sleep(1.0);
4043 f_enable_all_tch();
4044 vc_conn := f_start_handler(refers(f_TC_assignment_codec_req_fr_hr));
4045 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004046 f_shutdown_helper();
Philipp Maierac09bfc2019-01-08 13:41:39 +01004047}
4048
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02004049testcase TC_assignment_osmux() runs on test_CT {
4050 var TestHdlrParams pars := f_gen_test_hdlr_pars();
4051 var MSC_ConnHdlr vc_conn;
4052
4053 /* See note above */
4054 var RSL_IE_Body mr_conf := {
4055 other := {
4056 len := 2,
4057 payload := '2804'O
4058 }
4059 };
4060
4061 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_H}));
4062 pars.ass_codec_list.codecElements[0].s0_7 := '00000100'B; /* 5,90k */
4063 pars.ass_codec_list.codecElements[0].s8_15 := '00000111'B;
4064 pars.expect_mr_conf_ie := mr_conf;
4065 pars.use_osmux := true;
4066
4067 f_init(1, true, true);
4068 f_sleep(1.0);
4069
4070 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
4071 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004072 f_shutdown_helper();
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02004073}
4074
Neels Hofmeyr92b12b72018-09-18 14:30:23 +02004075/* test the procedure of the MSC requesting a Classmark Update:
4076 * a) BSSMAP Classmark Request should result in RR CLASSMARK ENQUIRY,
4077 * b) L3 RR CLASSMARK CHANGE should result in BSSMAP CLASSMARK UPDATE */
Harald Welte898113b2018-01-31 18:32:21 +01004078private function f_tc_classmark(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02004079 g_pars := f_gen_test_hdlr_pars();
4080
Harald Weltea0630032018-03-20 21:09:55 +01004081 f_create_chan_and_exp();
Harald Welte898113b2018-01-31 18:32:21 +01004082 /* we should now have a COMPL_L3 at the MSC */
4083 BSSAP.receive(tr_BSSMAP_ComplL3);
4084
Neels Hofmeyr92b12b72018-09-18 14:30:23 +02004085 BSSAP.send(ts_BSSMAP_ClassmarkRequest);
4086 RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_CM_ENQUIRY));
4087
Harald Welte898113b2018-01-31 18:32:21 +01004088 f_rsl_send_l3(ts_RRM_CM_CHG(valueof(ts_CM2)));
4089 BSSAP.receive(tr_BSSMAP_ClassmarkUpd(?, omit));
4090 setverdict(pass);
4091}
4092testcase TC_classmark() runs on test_CT {
4093 var MSC_ConnHdlr vc_conn;
4094 f_init(1, true);
4095 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02004096 vc_conn := f_start_handler(refers(f_tc_classmark));
Harald Welte898113b2018-01-31 18:32:21 +01004097 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004098 f_shutdown_helper();
Harald Welte898113b2018-01-31 18:32:21 +01004099}
4100
Harald Welteeddf0e92020-06-21 19:42:15 +02004101/* Send a CommonID from the simulated MSC and verify that the information is used to
4102 * fill BSC-internal data structures (specifically, bsc_subscr associated with subscr_conn) */
4103private function f_tc_common_id(charstring id) runs on MSC_ConnHdlr {
4104 g_pars := f_gen_test_hdlr_pars();
4105 f_MscConnHdlr_init_vty();
4106
4107 f_create_chan_and_exp();
4108 /* we should now have a COMPL_L3 at the MSC */
4109 BSSAP.receive(tr_BSSMAP_ComplL3);
4110
4111 /* Send CommonID */
4112 BSSAP.send(ts_BSSMAP_CommonId(g_pars.imsi));
4113
4114 /* Use VTY to verify that the IMSI of the subscr_conn is set */
4115 var charstring regex := "*(IMSI: " & hex2str(g_pars.imsi) & ")*";
4116 f_vty_transceive_match_regexp_retry(BSCVTY, "show conns", regex, 0, 4, 1.0);
4117
4118 setverdict(pass);
4119}
4120testcase TC_common_id() runs on test_CT {
4121 var MSC_ConnHdlr vc_conn;
4122 f_init(1, true);
4123 f_sleep(1.0);
4124 vc_conn := f_start_handler(refers(f_tc_common_id));
4125 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004126 f_shutdown_helper();
Harald Welteeddf0e92020-06-21 19:42:15 +02004127}
4128
Harald Weltee3bd6582018-01-31 22:51:25 +01004129private function f_est_single_l3(template PDU_ML3_MS_NW l3) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02004130 g_pars := f_gen_test_hdlr_pars();
Harald Weltea0630032018-03-20 21:09:55 +01004131 f_create_chan_and_exp();
Harald Welte898113b2018-01-31 18:32:21 +01004132 /* we should now have a COMPL_L3 at the MSC */
4133 BSSAP.receive(tr_BSSMAP_ComplL3);
4134
Harald Weltee3bd6582018-01-31 22:51:25 +01004135 /* send the single message we want to send */
4136 f_rsl_send_l3(l3);
4137}
4138
4139private function f_bssap_expect_nothing(float sec := 5.00) runs on MSC_ConnHdlr {
4140 timer T := sec;
4141 var PDU_BSSAP bssap;
Harald Welte898113b2018-01-31 18:32:21 +01004142 T.start;
4143 alt {
Harald Weltee3bd6582018-01-31 22:51:25 +01004144 [] BSSAP.receive(PDU_BSSAP:?) -> value bssap {
4145 setverdict(fail, "Unexpected BSSMAP ", bssap);
Daniel Willmannafce8662018-07-06 23:11:32 +02004146 mtc.stop;
Harald Welte898113b2018-01-31 18:32:21 +01004147 }
4148 [] T.timeout {
4149 setverdict(pass);
4150 }
4151 }
4152}
4153
Harald Weltee3bd6582018-01-31 22:51:25 +01004154/* unsolicited ASSIGNMENT FAIL (without ASSIGN) from MS shouldn't bring BSC down */
4155private function f_tc_unsol_ass_fail(charstring id) runs on MSC_ConnHdlr {
4156 f_est_single_l3(ts_RRM_AssignmentFailure('00'O));
4157 f_bssap_expect_nothing();
4158}
Harald Welte898113b2018-01-31 18:32:21 +01004159testcase TC_unsol_ass_fail() runs on test_CT {
4160 var MSC_ConnHdlr vc_conn;
4161 f_init(1, true);
4162 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02004163 vc_conn := f_start_handler(refers(f_tc_unsol_ass_fail));
Harald Welte898113b2018-01-31 18:32:21 +01004164 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004165 f_shutdown_helper();
Harald Welte898113b2018-01-31 18:32:21 +01004166}
Harald Welte552620d2017-12-16 23:21:36 +01004167
Harald Welteea99a002018-01-31 20:46:43 +01004168
4169/* unsolicited ASSIGNMENT COMPLETE (without ASSIGN) from MS shouldn't bring BSC down */
4170private function f_tc_unsol_ass_compl(charstring id) runs on MSC_ConnHdlr {
Harald Weltee3bd6582018-01-31 22:51:25 +01004171 f_est_single_l3(ts_RRM_AssignmentComplete('00'O));
4172 f_bssap_expect_nothing();
Harald Welteea99a002018-01-31 20:46:43 +01004173}
4174testcase TC_unsol_ass_compl() runs on test_CT {
4175 var MSC_ConnHdlr vc_conn;
4176 f_init(1, true);
4177 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02004178 vc_conn := f_start_handler(refers(f_tc_unsol_ass_compl));
Harald Welteea99a002018-01-31 20:46:43 +01004179 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004180 f_shutdown_helper();
Harald Welteea99a002018-01-31 20:46:43 +01004181}
4182
4183
Harald Weltefbf9b5e2018-01-31 20:41:23 +01004184/* unsolicited HANDOVER FAIL (without ASSIGN) from MS shouldn't bring BSC down */
4185private function f_tc_unsol_ho_fail(charstring id) runs on MSC_ConnHdlr {
Harald Weltee3bd6582018-01-31 22:51:25 +01004186 f_est_single_l3(ts_RRM_HandoverFailure('00'O));
4187 f_bssap_expect_nothing();
Harald Weltefbf9b5e2018-01-31 20:41:23 +01004188}
Harald Weltefbf9b5e2018-01-31 20:41:23 +01004189testcase TC_unsol_ho_fail() runs on test_CT {
4190 var MSC_ConnHdlr vc_conn;
4191 f_init(1, true);
4192 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02004193 vc_conn := f_start_handler(refers(f_tc_unsol_ho_fail));
Harald Weltefbf9b5e2018-01-31 20:41:23 +01004194 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004195 f_shutdown_helper();
Harald Weltefbf9b5e2018-01-31 20:41:23 +01004196}
4197
4198
Harald Weltee3bd6582018-01-31 22:51:25 +01004199/* short message from MS should be ignored */
4200private function f_tc_err_82_short_msg(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02004201 g_pars := f_gen_test_hdlr_pars();
Harald Weltea0630032018-03-20 21:09:55 +01004202 f_create_chan_and_exp();
Harald Weltee3bd6582018-01-31 22:51:25 +01004203 /* we should now have a COMPL_L3 at the MSC */
4204 BSSAP.receive(tr_BSSMAP_ComplL3);
4205
4206 /* send short message */
4207 RSL.send(ts_RSL_DATA_IND(g_chan_nr, valueof(ts_RslLinkID_DCCH(0)), ''O));
4208 f_bssap_expect_nothing();
4209}
4210testcase TC_err_82_short_msg() runs on test_CT {
4211 var MSC_ConnHdlr vc_conn;
4212 f_init(1, true);
4213 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02004214 vc_conn := f_start_handler(refers(f_tc_err_82_short_msg));
Harald Weltee3bd6582018-01-31 22:51:25 +01004215 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004216 f_shutdown_helper();
Harald Weltee3bd6582018-01-31 22:51:25 +01004217}
4218
4219
Harald Weltee9e02e42018-01-31 23:36:25 +01004220/* 24.008 8.4 Unknown message must trigger RR STATUS */
4221private function f_tc_err_84_unknown_msg(charstring id) runs on MSC_ConnHdlr {
4222 f_est_single_l3(ts_RRM_UL_REL('00'O));
4223 timer T := 3.0
4224 alt {
4225 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_STATUS)) {
4226 setverdict(pass);
4227 }
4228 [] BSSAP.receive { setverdict(fail, "unexpected BSSAP"); }
Harald Welte458fd372018-03-21 11:26:23 +01004229 [] T.timeout { setverdict(fail, "Timeout waiting for RR STATUS"); }
Harald Weltee9e02e42018-01-31 23:36:25 +01004230 }
4231}
4232testcase TC_err_84_unknown_msg() runs on test_CT {
4233 var MSC_ConnHdlr vc_conn;
4234 f_init(1, true);
4235 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02004236 vc_conn := f_start_handler(refers(f_tc_err_84_unknown_msg));
Harald Weltee9e02e42018-01-31 23:36:25 +01004237 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004238 f_shutdown_helper();
Harald Weltee9e02e42018-01-31 23:36:25 +01004239}
4240
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004241/***********************************************************************
4242 * Handover
4243 ***********************************************************************/
4244
Harald Welte94e0c342018-04-07 11:33:23 +02004245/* execute a "bts <0-255> trx <0-255> timeslot <0-7> " command on given Dchan */
4246private function f_vty_ts_action(charstring suffix, integer bts_nr, integer trx_nr, integer ts_nr)
4247runs on test_CT {
4248 var charstring cmd := "bts "&int2str(bts_nr)&" trx "&int2str(trx_nr)&
4249 " timeslot "&int2str(ts_nr)&" ";
4250 f_vty_transceive(BSCVTY, cmd & suffix);
4251}
4252
Harald Welte261af4b2018-02-12 21:20:39 +01004253/* 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 +07004254private function f_vty_ss_action(TELNETasp_PT pt, charstring suffix,
4255 uint8_t bts_nr, uint8_t trx_nr,
4256 in RslChannelNr chan_nr)
4257{
Harald Welte261af4b2018-02-12 21:20:39 +01004258 /* FIXME: resolve those from component-global state */
4259 var integer ts_nr := chan_nr.tn;
4260 var integer ss_nr;
4261 if (ischosen(chan_nr.u.ch0)) {
4262 ss_nr := 0;
4263 } else if (ischosen(chan_nr.u.lm)) {
4264 ss_nr := chan_nr.u.lm.sub_chan;
4265 } else if (ischosen(chan_nr.u.sdcch4)) {
4266 ss_nr := chan_nr.u.sdcch4.sub_chan;
4267 } else if (ischosen(chan_nr.u.sdcch8)) {
4268 ss_nr := chan_nr.u.sdcch8.sub_chan;
4269 } else {
4270 setverdict(fail, "Invalid ChanNr ", chan_nr);
Daniel Willmannafce8662018-07-06 23:11:32 +02004271 mtc.stop;
Harald Welte261af4b2018-02-12 21:20:39 +01004272 }
4273
4274 var charstring cmd := "bts "&int2str(bts_nr)&" trx "&int2str(trx_nr)&
4275 " timeslot "&int2str(ts_nr)&" sub-slot "&int2str(ss_nr)&" ";
Vadim Yanitskiy00070722020-09-02 17:27:57 +07004276 f_vty_transceive(pt, cmd & suffix);
Harald Welte261af4b2018-02-12 21:20:39 +01004277}
4278
Neels Hofmeyr91401012019-07-11 00:42:35 +02004279/* Even though the VTY command to trigger handover takes a new BTS number as argument, behind the scenes osmo-bsc always
4280 * translates that to a target ARFCN+BSIC first. See bsc_vty.c trigger_ho_or_as(), which puts the selected BTS' neighbor
4281 * ident key (ARFCN + BSIC) in the struct passed on to handover_request(). handover_start() then resolves that to a
4282 * viable actual neighbor cell. So from the internal osmo-bsc perspective, we always request handover to an ARFCN + BSIC
4283 * pair, not really to a specific BTS number. */
Vadim Yanitskiy00070722020-09-02 17:27:57 +07004284private function f_vty_handover(TELNETasp_PT pt, uint8_t bts_nr, uint8_t trx_nr,
4285 in RslChannelNr chan_nr, uint8_t new_bts_nr)
4286{
4287 f_vty_ss_action(pt, "handover " & int2str(new_bts_nr), bts_nr, trx_nr, chan_nr);
Harald Welte261af4b2018-02-12 21:20:39 +01004288}
4289
4290/* intra-BSC hand-over between BTS0 and BTS1 */
4291private function f_tc_ho_int(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02004292 g_pars := f_gen_test_hdlr_pars();
Harald Welteed848512018-05-24 22:27:58 +02004293 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4294 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte261af4b2018-02-12 21:20:39 +01004295 const OCT8 kc := '0001020304050607'O;
4296
4297 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4298 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
4299
Harald Weltea0630032018-03-20 21:09:55 +01004300 f_establish_fully(ass_cmd, exp_compl);
Neels Hofmeyr666f0432020-07-04 00:53:07 +02004301 f_bts_0_cfg(BSCVTY, {"neighbor bts 1"});
Harald Welte261af4b2018-02-12 21:20:39 +01004302
4303 var HandoverState hs := {
4304 rr_ho_cmpl_seen := false,
4305 handover_done := false,
4306 old_chan_nr := -
4307 };
4308 /* issue hand-over command on VTY */
Vadim Yanitskiy00070722020-09-02 17:27:57 +07004309 f_vty_handover(BSCVTY, 0, 0, g_chan_nr, 1);
Harald Welte261af4b2018-02-12 21:20:39 +01004310 /* temporarily suspend DChan processing on BTS1 to avoid race with RSLEM_register */
4311 f_rslem_suspend(RSL1_PROC);
Philipp Maier3e2af5d2018-07-11 17:01:05 +02004312
4313 /* From the MGW perspective, a handover is is characterized by
4314 * performing one MDCX operation with the MGW. So we expect to see
4315 * one more MDCX during handover. */
4316 g_media.mgcp_conn[0].mdcx_seen_exp := g_media.mgcp_conn[0].crcx_seen_exp + 1;
4317
Harald Welte261af4b2018-02-12 21:20:39 +01004318 alt {
4319 [] as_handover(hs);
Harald Welte261af4b2018-02-12 21:20:39 +01004320 }
Philipp Maier3e2af5d2018-07-11 17:01:05 +02004321
Philipp Maier4dae0652018-11-12 12:03:26 +01004322 /* Since this is an internal handover we expect the BSC to inform the
4323 * MSC about the event */
4324 BSSAP.receive(tr_BSSMAP_HandoverPerformed);
4325
Philipp Maier3e2af5d2018-07-11 17:01:05 +02004326 /* Check the amount of MGCP transactions is still consistant with the
4327 * test expectation */
4328 f_check_mgcp_expectations()
Neels Hofmeyr861a4c12018-11-07 01:23:17 +01004329 f_sleep(0.5);
Harald Welte261af4b2018-02-12 21:20:39 +01004330}
4331
4332testcase TC_ho_int() runs on test_CT {
4333 var MSC_ConnHdlr vc_conn;
4334 f_init(2, true);
4335 f_sleep(1.0);
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004336
4337 f_ctrs_bsc_and_bts_init();
4338
Harald Welte8863fa12018-05-10 20:15:27 +02004339 vc_conn := f_start_handler(refers(f_tc_ho_int));
Harald Welte261af4b2018-02-12 21:20:39 +01004340 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004341
4342 /* from f_establish_fully() */
4343 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
4344 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
4345 /* from handover */
4346 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
4347 f_ctrs_bsc_and_bts_add(0, "handover:completed");
4348 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
4349 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:completed");
4350 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004351 f_shutdown_helper();
Harald Welte261af4b2018-02-12 21:20:39 +01004352}
Harald Weltee9e02e42018-01-31 23:36:25 +01004353
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004354/* Expecting MGCP to DLCX the endpoint's two connections: towards BTS and towards MSC */
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02004355private function f_expect_dlcx_conns() runs on MSC_ConnHdlr {
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004356 var MgcpCommand mgcp;
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +02004357 var template MgcpResponse mgcp_resp;
4358 var MGCP_RecvFrom mrf;
4359 var template MgcpMessage msg_resp;
4360 var template MgcpMessage msg_dlcx := {
4361 command := tr_DLCX()
4362 }
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004363
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +02004364 if (g_pars.aoip) {
4365 MGCP.receive(tr_DLCX()) -> value mgcp {
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004366 log("Got first DLCX: ", mgcp);
4367 MGCP.send(ts_DLCX_ACK2(mgcp.line.trans_id));
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +02004368 };
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004369
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004370 MGCP.receive(tr_DLCX()) -> value mgcp {
4371 log("Got second DLCX: ", mgcp);
4372 MGCP.send(ts_DLCX_ACK2(mgcp.line.trans_id));
4373 };
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +02004374 } else {
4375 /* For SCCPLite, BSC doesn't handle the MSC-side */
4376 MGCP_MULTI.receive(tr_MGCP_RecvFrom_any(msg_dlcx)) -> value mrf {
4377 log("Got first DLCX: ", mrf.msg.command);
4378 msg_resp := {
4379 response := ts_DLCX_ACK2(mrf.msg.command.line.trans_id)
4380 }
4381 MGCP_MULTI.send(t_MGCP_SendToMrf(mrf, msg_resp));
4382 };
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004383 }
4384
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02004385 BSSAP.receive(tr_BSSMAP_ClearComplete);
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004386}
4387
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004388private function f_tc_ho_out_of_this_bsc(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02004389 g_pars := f_gen_test_hdlr_pars();
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004390
4391 var PDU_BSSAP ass_req := f_gen_ass_req();
4392 ass_req.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4393 ass_req.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
4394 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4395 f_establish_fully(ass_req, exp_compl);
4396
Neels Hofmeyr666f0432020-07-04 00:53:07 +02004397 f_bts_0_cfg(BSCVTY, {"neighbor lac 99 arfcn 123 bsic any"});
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004398 f_vty_transceive(BSCVTY, "handover any to arfcn 123 bsic any");
4399
4400 BSSAP.receive(tr_BSSMAP_HandoverRequired);
4401
4402 f_sleep(0.5);
4403 /* The MSC negotiates Handover Request and Handover Request Ack with
4404 * the other BSS and comes back with a BSSMAP Handover Command
4405 * containing an RR Handover Command coming from the target BSS... */
4406
4407 var PDU_ML3_NW_MS rr_ho_cmd := valueof(ts_RR_HandoverCommand);
4408 log("Remote cell's RR Handover Command passed through as L3 Info: ", rr_ho_cmd);
4409 var octetstring rr_ho_cmd_enc := enc_PDU_ML3_NW_MS(rr_ho_cmd);
4410 log("Remote cell's RR Handover Command passed through as L3 Info, encoded: ", rr_ho_cmd_enc);
4411 BSSAP.send(ts_BSSMAP_HandoverCommand(rr_ho_cmd_enc));
4412
4413 /* expect the Handover Command to go out on RR */
4414 var RSL_Message rsl_ho_cmd
4415 RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, ?)) -> value rsl_ho_cmd;
4416 log("RSL Data Req went out to first BTS: ", rsl_ho_cmd);
4417 var RSL_IE_Body rsl_ho_cmd_l3;
4418 if (not f_rsl_find_ie(rsl_ho_cmd, RSL_IE_L3_INFO, rsl_ho_cmd_l3)) {
4419 log("RSL message contains no L3 Info IE, expected RR Handover Command");
4420 setverdict(fail);
4421 } else {
4422 log("Found L3 Info: ", rsl_ho_cmd_l3);
4423 if (rsl_ho_cmd_l3.l3_info.payload != rr_ho_cmd_enc) {
4424 log("FAIL: the BSC sent out a different L3 Info, not matching the RR Handover Command the other BSS forwarded.");
4425 setverdict(fail);
4426 } else {
4427 log("Success: the BSC sent out the same RR Handover Command the other BSS forwarded.");
4428 setverdict(pass);
4429 }
4430 }
4431
4432 /* When the other BSS has reported a completed handover, this side is
4433 * torn down. */
4434
4435 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_HANDOVER_SUCCESSFUL;
4436 var BssmapCause cause := enum2int(cause_val);
4437 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
4438
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02004439 f_expect_dlcx_conns();
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004440 setverdict(pass);
4441 f_sleep(1.0);
4442}
4443testcase TC_ho_out_of_this_bsc() runs on test_CT {
4444 var MSC_ConnHdlr vc_conn;
4445
4446 f_init(1, true);
4447 f_sleep(1.0);
4448
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004449 f_ctrs_bsc_and_bts_init();
4450
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004451 vc_conn := f_start_handler(refers(f_tc_ho_out_of_this_bsc));
4452 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004453
4454 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
4455 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
4456 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
4457 f_ctrs_bsc_and_bts_add(0, "handover:completed");
4458 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
4459 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:completed");
4460 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004461 f_shutdown_helper();
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004462}
4463
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004464/* BSC asks for inter-BSC HO, but the MSC decides that it won't happen and
4465 * simply never sends a BSSMAP Handover Command. */
4466private function f_tc_ho_out_fail_no_msc_response(charstring id) runs on MSC_ConnHdlr {
Daniel Willmann3b59eb52018-10-29 15:40:55 +01004467 g_pars := f_gen_test_hdlr_pars();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004468
4469 var PDU_BSSAP ass_req := f_gen_ass_req();
4470 ass_req.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4471 ass_req.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
4472 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4473 f_establish_fully(ass_req, exp_compl);
4474
Neels Hofmeyr666f0432020-07-04 00:53:07 +02004475 f_bts_0_cfg(BSCVTY, {"neighbor lac 99 arfcn 123 bsic any"});
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004476 f_vty_transceive(BSCVTY, "handover any to arfcn 123 bsic any");
4477
4478 BSSAP.receive(tr_BSSMAP_HandoverRequired);
4479
4480 /* osmo-bsc should time out 10 seconds after the handover started.
4481 * Let's give it a bit extra. */
4482 f_sleep(15.0);
4483
4484 /* The old lchan and conn should still be active. See that arbitrary L3
4485 * is still going through. */
4486 var octetstring l3 := '0123456789'O;
4487 RSL.send(ts_RSL_DATA_IND(g_chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
4488 var template PDU_BSSAP exp_data := {
4489 discriminator := '1'B,
4490 spare := '0000000'B,
4491 dlci := '00'O,
4492 lengthIndicator := 5,
4493 pdu := {
4494 dtap := l3
4495 }
4496 };
4497 BSSAP.receive(exp_data);
4498 setverdict(pass);
4499 f_sleep(1.0);
4500}
4501testcase TC_ho_out_fail_no_msc_response() runs on test_CT {
4502 var MSC_ConnHdlr vc_conn;
4503
4504 f_init(1, true);
4505 f_sleep(1.0);
4506
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004507 f_ctrs_bsc_and_bts_init();
4508
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004509 vc_conn := f_start_handler(refers(f_tc_ho_out_fail_no_msc_response));
4510 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004511
4512 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
4513 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
4514 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
4515 f_ctrs_bsc_and_bts_add(0, "handover:timeout");
4516 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
4517 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:timeout");
4518 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004519 f_shutdown_helper();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004520}
4521
4522/* BSC asks for inter-BSC HO, receives BSSMAP Handover Command, but MS reports
4523 * RR Handover Failure. */
4524private function f_tc_ho_out_fail_rr_ho_failure(charstring id) runs on MSC_ConnHdlr {
Daniel Willmann3b59eb52018-10-29 15:40:55 +01004525 g_pars := f_gen_test_hdlr_pars();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004526
4527 var PDU_BSSAP ass_req := f_gen_ass_req();
4528 ass_req.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4529 ass_req.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
4530 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4531 f_establish_fully(ass_req, exp_compl);
4532
Neels Hofmeyr666f0432020-07-04 00:53:07 +02004533 f_bts_0_cfg(BSCVTY, {"neighbor lac 99 arfcn 123 bsic any"});
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004534 f_vty_transceive(BSCVTY, "handover any to arfcn 123 bsic any");
4535
4536 BSSAP.receive(tr_BSSMAP_HandoverRequired);
4537
4538 f_sleep(0.5);
4539 /* The MSC negotiates Handover Request and Handover Request Ack with
4540 * the other BSS and comes back with a BSSMAP Handover Command
4541 * containing an RR Handover Command coming from the target BSS... */
4542
4543 var PDU_ML3_NW_MS rr_ho_cmd := valueof(ts_RR_HandoverCommand);
4544 log("Remote cell's RR Handover Command passed through as L3 Info: ", rr_ho_cmd);
4545 var octetstring rr_ho_cmd_enc := enc_PDU_ML3_NW_MS(rr_ho_cmd);
4546 log("Remote cell's RR Handover Command passed through as L3 Info, encoded: ", rr_ho_cmd_enc);
4547 BSSAP.send(ts_BSSMAP_HandoverCommand(rr_ho_cmd_enc));
4548
4549 /* expect the Handover Command to go out on RR */
4550 var RSL_Message rsl_ho_cmd
4551 RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, ?)) -> value rsl_ho_cmd;
4552 log("RSL Data Req went out to first BTS: ", rsl_ho_cmd);
4553 var RSL_IE_Body rsl_ho_cmd_l3;
4554 if (not f_rsl_find_ie(rsl_ho_cmd, RSL_IE_L3_INFO, rsl_ho_cmd_l3)) {
4555 log("RSL message contains no L3 Info IE, expected RR Handover Command");
4556 setverdict(fail);
4557 } else {
4558 log("Found L3 Info: ", rsl_ho_cmd_l3);
4559 if (rsl_ho_cmd_l3.l3_info.payload != rr_ho_cmd_enc) {
4560 log("FAIL: the BSC sent out a different L3 Info, not matching the RR Handover Command the other BSS forwarded.");
4561 setverdict(fail);
4562 } else {
4563 log("Success: the BSC sent out the same RR Handover Command the other BSS forwarded.");
4564 setverdict(pass);
4565 }
4566 }
4567
4568 f_sleep(0.2);
4569 f_rsl_send_l3(ts_RRM_HandoverFailure('00'O));
4570
4571 /* Should tell the MSC about the failure */
4572 BSSAP.receive(tr_BSSMAP_HandoverFailure);
4573
4574 f_sleep(1.0);
4575
4576 /* The old lchan and conn should still be active. See that arbitrary L3
4577 * is still going through. */
4578 var octetstring l3 := '0123456789'O;
4579 RSL.send(ts_RSL_DATA_IND(g_chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
4580 var template PDU_BSSAP exp_data := {
4581 discriminator := '1'B,
4582 spare := '0000000'B,
4583 dlci := '00'O,
4584 lengthIndicator := 5,
4585 pdu := {
4586 dtap := l3
4587 }
4588 };
4589 BSSAP.receive(exp_data);
4590 setverdict(pass);
4591 f_sleep(1.0);
4592
4593 setverdict(pass);
4594 f_sleep(1.0);
4595}
4596testcase TC_ho_out_fail_rr_ho_failure() runs on test_CT {
4597 var MSC_ConnHdlr vc_conn;
4598
4599 f_init(1, true);
4600 f_sleep(1.0);
4601
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004602 f_ctrs_bsc_and_bts_init();
4603
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004604 vc_conn := f_start_handler(refers(f_tc_ho_out_fail_rr_ho_failure));
4605 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004606
4607 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
4608 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
4609 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
4610 f_ctrs_bsc_and_bts_add(0, "handover:failed");
4611 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
4612 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:failed");
4613 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004614 f_shutdown_helper();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004615}
4616
Neels Hofmeyr10f2bfa2019-07-09 19:33:29 +02004617/* BSC asks for inter-BSC-out HO, receives BSSMAP Handover Command, but then no reply is received about HO outcome
4618 * (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 +02004619 * and the lchan is released. */
4620private function f_tc_ho_out_fail_no_result_after_ho_cmd(charstring id) runs on MSC_ConnHdlr {
Daniel Willmann3b59eb52018-10-29 15:40:55 +01004621 g_pars := f_gen_test_hdlr_pars();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004622
4623 var PDU_BSSAP ass_req := f_gen_ass_req();
4624 ass_req.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4625 ass_req.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
4626 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4627 f_establish_fully(ass_req, exp_compl);
4628
Neels Hofmeyr666f0432020-07-04 00:53:07 +02004629 f_bts_0_cfg(BSCVTY, {"neighbor lac 99 arfcn 123 bsic any"});
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004630 f_vty_transceive(BSCVTY, "handover any to arfcn 123 bsic any");
4631
4632 BSSAP.receive(tr_BSSMAP_HandoverRequired);
4633
4634 f_sleep(0.5);
4635 /* The MSC negotiates Handover Request and Handover Request Ack with
4636 * the other BSS and comes back with a BSSMAP Handover Command
4637 * containing an RR Handover Command coming from the target BSS... */
4638
4639 var PDU_ML3_NW_MS rr_ho_cmd := valueof(ts_RR_HandoverCommand);
4640 log("Remote cell's RR Handover Command passed through as L3 Info: ", rr_ho_cmd);
4641 var octetstring rr_ho_cmd_enc := enc_PDU_ML3_NW_MS(rr_ho_cmd);
4642 log("Remote cell's RR Handover Command passed through as L3 Info, encoded: ", rr_ho_cmd_enc);
4643 BSSAP.send(ts_BSSMAP_HandoverCommand(rr_ho_cmd_enc));
4644
4645 /* expect the Handover Command to go out on RR */
4646 var RSL_Message rsl_ho_cmd
4647 RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, ?)) -> value rsl_ho_cmd;
4648 log("RSL Data Req went out to first BTS: ", rsl_ho_cmd);
4649 var RSL_IE_Body rsl_ho_cmd_l3;
4650 if (not f_rsl_find_ie(rsl_ho_cmd, RSL_IE_L3_INFO, rsl_ho_cmd_l3)) {
4651 log("RSL message contains no L3 Info IE, expected RR Handover Command");
4652 setverdict(fail);
4653 } else {
4654 log("Found L3 Info: ", rsl_ho_cmd_l3);
4655 if (rsl_ho_cmd_l3.l3_info.payload != rr_ho_cmd_enc) {
4656 log("FAIL: the BSC sent out a different L3 Info, not matching the RR Handover Command the other BSS forwarded.");
4657 setverdict(fail);
4658 } else {
4659 log("Success: the BSC sent out the same RR Handover Command the other BSS forwarded.");
4660 setverdict(pass);
4661 }
4662 }
4663
Neels Hofmeyr10f2bfa2019-07-09 19:33:29 +02004664 /* We get neither success nor failure report from the remote BSS. Eventually T8 times out and we run into 3GPP
4665 * TS 48.008 3.1.5.3.3 "Abnormal Conditions": Clear Request should go to the MSC, and RR should be released
4666 * after Clear Command */
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004667
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02004668 var PDU_BSSAP rx_clear_request;
Neels Hofmeyre1797aa2019-07-09 19:34:04 +02004669 BSSAP.receive(tr_BSSMAP_ClearRequest) -> value rx_clear_request;
4670 log("Got BSSMAP Clear Request");
4671 /* Instruct BSC to clear channel */
4672 var BssmapCause cause := bit2int(rx_clear_request.pdu.bssmap.clearRequest.cause.causeValue);
4673 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
4674
4675 var MgcpCommand mgcp;
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004676 interleave {
Neels Hofmeyr861a4c12018-11-07 01:23:17 +01004677 [] RSL.receive(tr_RSL_DEACT_SACCH(g_chan_nr)) {
4678 log("Got Deact SACCH");
4679 }
Harald Welte924b6ea2019-02-04 01:05:34 +01004680 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_RELEASE)) {
Neels Hofmeyr211169d2018-11-07 00:37:29 +01004681 log("Got RR Release");
4682 }
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004683 [] RSL.receive(tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL)) {
4684 log("Got RF Chan Rel");
4685 RSL.send(ts_RSL_RF_CHAN_REL_ACK(g_chan_nr));
4686 }
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004687 }
4688
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02004689 f_expect_dlcx_conns();
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004690
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004691 setverdict(pass);
4692 f_sleep(1.0);
4693}
Neels Hofmeyrd8a602c2019-07-09 19:46:01 +02004694testcase TC_ho_out_fail_no_result_after_ho_cmd() runs on test_CT {
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004695 var MSC_ConnHdlr vc_conn;
4696
4697 f_init(1, true);
4698 f_sleep(1.0);
4699
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004700 f_ctrs_bsc_and_bts_init();
4701
Neels Hofmeyrd8a602c2019-07-09 19:46:01 +02004702 vc_conn := f_start_handler(refers(f_tc_ho_out_fail_no_result_after_ho_cmd));
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004703 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004704
4705 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
4706 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
4707 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
4708 f_ctrs_bsc_and_bts_add(0, "handover:timeout");
4709 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
4710 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:timeout");
4711 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004712 f_shutdown_helper();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004713}
4714
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004715private function f_tc_ho_into_this_bsc(charstring id) runs on MSC_ConnHdlr {
4716 /* Hack: the proper way would be to wait for the BSSMAP Handover Request ACK and extract the
4717 * actual assigned chan_nr from its L3 (RR Handover Command) message. But osmo-bsc starts acting
4718 * on the lchan even before we get a chance to evaluate the BSSMAP Handover Request ACK. So we
4719 * need to assume that osmo-bsc will activate TS 1 and already set up this lchan's RSL emulation
4720 * before we get started. */
4721 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
4722 f_rslem_register(0, new_chan_nr);
4723 g_chan_nr := new_chan_nr;
4724 f_sleep(1.0);
4725
4726 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
4727 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
4728 activate(as_Media());
4729
Neels Hofmeyr90f80962020-06-12 16:16:55 +02004730 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Pau Espin Pedrol07866632020-09-03 19:10:55 +02004731 f_gen_handover_req(aoip_tla := g_pars.host_aoip_tla)));
Harald Welte6811d102019-04-14 22:23:14 +02004732 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004733
4734 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
4735
4736 var PDU_BSSAP rx_bssap;
4737 var octetstring ho_command_str;
4738
4739 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
Pau Espin Pedrol76ba5412019-06-10 11:00:33 +02004740
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004741 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
4742 log("Received L3 Info in HO Request Ack: ", ho_command_str);
4743 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
4744 log("L3 Info in HO Request Ack is ", ho_command);
4745
4746 var GsmArfcn arfcn;
4747 var RslChannelNr actual_new_chan_nr;
4748 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
4749 actual_new_chan_nr, arfcn);
4750
4751 if (actual_new_chan_nr != new_chan_nr) {
4752 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
4753 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
4754 setverdict(fail);
4755 return;
4756 }
4757 log("Handover Command chan_nr is", actual_new_chan_nr);
4758
4759 /* Now the MSC forwards the RR Handover Command to the other BSC, which
4760 * tells the MS to handover to the new lchan. Here comes the new MS on
4761 * the new lchan with a Handover RACH: */
4762
4763 /* send handover detect */
4764
4765 RSL.send(ts_RSL_HANDO_DET(new_chan_nr));
4766
4767 BSSAP.receive(tr_BSSMAP_HandoverDetect);
4768
4769 /* send handover complete over the new channel */
4770
4771 var PDU_ML3_MS_NW l3_tx := valueof(ts_RRM_HandoverComplete('00'O));
4772 RSL.send(ts_RSL_EST_IND(new_chan_nr, valueof(ts_RslLinkID_DCCH(0)),
4773 enc_PDU_ML3_MS_NW(l3_tx)));
4774
4775 BSSAP.receive(tr_BSSMAP_HandoverComplete);
4776 setverdict(pass);
4777}
Pau Espin Pedrol07866632020-09-03 19:10:55 +02004778function f_tc_ho_into_this_bsc_main(TestHdlrParams pars) runs on test_CT {
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004779 var MSC_ConnHdlr vc_conn;
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004780
4781 f_init(1, true);
4782 f_sleep(1.0);
4783
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004784 f_ctrs_bsc_and_bts_init();
4785
Neels Hofmeyr90f80962020-06-12 16:16:55 +02004786 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
4787 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004788
4789 vc_conn := f_start_handler(refers(f_tc_ho_into_this_bsc), pars);
4790 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004791
4792 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
4793 f_ctrs_bsc_and_bts_add(0, "handover:completed");
4794 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:attempted");
4795 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:completed");
4796 f_ctrs_bsc_and_bts_verify();
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004797}
4798
Pau Espin Pedrol07866632020-09-03 19:10:55 +02004799testcase TC_ho_into_this_bsc() runs on test_CT {
4800 var TestHdlrParams pars := f_gen_test_hdlr_pars();
4801 f_tc_ho_into_this_bsc_main(pars);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004802 f_shutdown_helper();
Pau Espin Pedrol07866632020-09-03 19:10:55 +02004803}
4804
4805testcase TC_ho_into_this_bsc_tla_v6() runs on test_CT {
4806 var TestHdlrParams pars := f_gen_test_hdlr_pars();
4807 pars.host_aoip_tla := "::6";
4808 f_tc_ho_into_this_bsc_main(pars);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004809 f_shutdown_helper();
Pau Espin Pedrol07866632020-09-03 19:10:55 +02004810}
4811
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01004812private function f_tc_ho_in_fail_msc_clears(charstring id) runs on MSC_ConnHdlr {
4813 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
4814 f_rslem_register(0, new_chan_nr);
4815 g_chan_nr := new_chan_nr;
4816 f_sleep(1.0);
4817
4818 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
4819 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
4820 activate(as_Media());
4821
Neels Hofmeyr90f80962020-06-12 16:16:55 +02004822 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01004823 f_gen_handover_req()));
Harald Welte6811d102019-04-14 22:23:14 +02004824 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01004825
4826 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
4827
4828 var PDU_BSSAP rx_bssap;
4829 var octetstring ho_command_str;
4830
4831 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
4832
4833 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
4834 log("Received L3 Info in HO Request Ack: ", ho_command_str);
4835 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
4836 log("L3 Info in HO Request Ack is ", ho_command);
4837
4838 var GsmArfcn arfcn;
4839 var RslChannelNr actual_new_chan_nr;
4840 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
4841 actual_new_chan_nr, arfcn);
4842
4843 if (actual_new_chan_nr != new_chan_nr) {
4844 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
4845 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
4846 setverdict(fail);
4847 return;
4848 }
4849 log("Handover Command chan_nr is", actual_new_chan_nr);
4850
Neels Hofmeyr61ca08d2019-05-06 23:52:22 +02004851 /* For deterministic test results, give some time for the MGW endpoint to be configured */
4852 f_sleep(1.0);
4853
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01004854 /* Now the MSC forwards the RR Handover Command to the other BSC, which
4855 * tells the MS to handover to the new lchan. In this case, the MS
4856 * reports a Handover Failure to the old BSS, which forwards a BSSMAP
4857 * Handover Failure to the MSC. The procedure according to 3GPP TS
4858 * 48.008 3.1.5.3.2 "Handover Failure" is then that the MSC sends a
4859 * BSSMAP Clear Command: */
4860
4861 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_RADIO_INTERFACE_FAILURE_REVERSION;
4862 var BssmapCause cause := enum2int(cause_val);
4863 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
4864
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02004865 f_expect_dlcx_conns();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01004866 setverdict(pass);
4867 f_sleep(1.0);
4868
4869 setverdict(pass);
4870}
4871testcase TC_ho_in_fail_msc_clears() runs on test_CT {
4872 var MSC_ConnHdlr vc_conn;
4873 var TestHdlrParams pars := f_gen_test_hdlr_pars();
4874
4875 f_init(1, true);
4876 f_sleep(1.0);
4877
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004878 f_ctrs_bsc_and_bts_init();
4879
Neels Hofmeyr90f80962020-06-12 16:16:55 +02004880 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
4881 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01004882
4883 vc_conn := f_start_handler(refers(f_tc_ho_in_fail_msc_clears), pars);
4884 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004885
4886 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
4887 f_ctrs_bsc_and_bts_add(0, "handover:stopped");
4888 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:attempted");
4889 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:stopped");
4890 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004891 f_shutdown_helper();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01004892}
4893
4894private function f_tc_ho_in_fail_msc_clears_after_ho_detect(charstring id) runs on MSC_ConnHdlr {
4895 /* Hack: the proper way would be to wait for the BSSMAP Handover Request ACK and extract the
4896 * actual assigned chan_nr from its L3 (RR Handover Command) message. But osmo-bsc starts acting
4897 * on the lchan even before we get a chance to evaluate the BSSMAP Handover Request ACK. So we
4898 * need to assume that osmo-bsc will activate TS 1 and already set up this lchan's RSL emulation
4899 * before we get started. */
4900 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
4901 f_rslem_register(0, new_chan_nr);
4902 g_chan_nr := new_chan_nr;
4903 f_sleep(1.0);
4904
4905 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
4906 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
4907 activate(as_Media());
4908
Neels Hofmeyr90f80962020-06-12 16:16:55 +02004909 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01004910 f_gen_handover_req()));
Harald Welte6811d102019-04-14 22:23:14 +02004911 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01004912
4913 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
4914
4915 var PDU_BSSAP rx_bssap;
4916 var octetstring ho_command_str;
4917
4918 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
4919
4920 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
4921 log("Received L3 Info in HO Request Ack: ", ho_command_str);
4922 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
4923 log("L3 Info in HO Request Ack is ", ho_command);
4924
4925 var GsmArfcn arfcn;
4926 var RslChannelNr actual_new_chan_nr;
4927 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
4928 actual_new_chan_nr, arfcn);
4929
4930 if (actual_new_chan_nr != new_chan_nr) {
4931 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
4932 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
4933 setverdict(fail);
4934 return;
4935 }
4936 log("Handover Command chan_nr is", actual_new_chan_nr);
4937
4938 /* Now the MSC forwards the RR Handover Command to the other BSC, which
4939 * tells the MS to handover to the new lchan. Here comes the new MS on
4940 * the new lchan with a Handover RACH: */
4941
4942 /* send handover detect */
4943
4944 RSL.send(ts_RSL_HANDO_DET(new_chan_nr));
4945
4946 BSSAP.receive(tr_BSSMAP_HandoverDetect);
4947
4948 /* The MSC chooses to clear the connection now, maybe we got the
4949 * Handover RACH on the new cell but the MS still signaled Handover
4950 * Failure to the old BSS? */
4951
4952 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_RADIO_INTERFACE_FAILURE_REVERSION;
4953 var BssmapCause cause := enum2int(cause_val);
4954 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
4955
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02004956 f_expect_dlcx_conns();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01004957 f_sleep(1.0);
4958}
4959testcase TC_ho_in_fail_msc_clears_after_ho_detect() runs on test_CT {
4960 var MSC_ConnHdlr vc_conn;
4961 var TestHdlrParams pars := f_gen_test_hdlr_pars();
4962
4963 f_init(1, true);
4964 f_sleep(1.0);
4965
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004966 f_ctrs_bsc_and_bts_init();
4967
Neels Hofmeyr90f80962020-06-12 16:16:55 +02004968 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
4969 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01004970
4971 vc_conn := f_start_handler(refers(f_tc_ho_in_fail_msc_clears_after_ho_detect), pars);
4972 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004973
4974 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
4975 f_ctrs_bsc_and_bts_add(0, "handover:stopped");
4976 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:attempted");
4977 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:stopped");
4978 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02004979 f_shutdown_helper();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01004980}
4981
4982/* The new BSS's lchan times out before the MSC decides that handover failed. */
4983private function f_tc_ho_in_fail_no_detect(charstring id) runs on MSC_ConnHdlr {
4984 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
4985 f_rslem_register(0, new_chan_nr);
4986 g_chan_nr := new_chan_nr;
4987 f_sleep(1.0);
4988
4989 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
4990 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
4991 activate(as_Media());
4992
Neels Hofmeyr90f80962020-06-12 16:16:55 +02004993 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01004994 f_gen_handover_req()));
Harald Welte6811d102019-04-14 22:23:14 +02004995 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01004996
4997 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
4998
4999 var PDU_BSSAP rx_bssap;
5000 var octetstring ho_command_str;
5001
5002 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
5003
5004 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
5005 log("Received L3 Info in HO Request Ack: ", ho_command_str);
5006 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
5007 log("L3 Info in HO Request Ack is ", ho_command);
5008
5009 var GsmArfcn arfcn;
5010 var RslChannelNr actual_new_chan_nr;
5011 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
5012 actual_new_chan_nr, arfcn);
5013
5014 if (actual_new_chan_nr != new_chan_nr) {
5015 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
5016 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
5017 setverdict(fail);
5018 return;
5019 }
5020 log("Handover Command chan_nr is", actual_new_chan_nr);
5021
5022 /* Now the MSC forwards the RR Handover Command to the other BSC, which
5023 * tells the MS to handover to the new lchan. But the MS never shows up
5024 * on the new lchan. */
5025
5026 BSSAP.receive(tr_BSSMAP_HandoverFailure);
5027
5028 /* Did osmo-bsc also send a Clear Request? */
5029 timer T := 0.5;
5030 T.start;
5031 alt {
5032 [] BSSAP.receive(tr_BSSMAP_ClearRequest);
5033 [] T.timeout { }
5034 }
5035
5036 /* MSC plays along with a Clear Command (no matter whether osmo-bsc
5037 * asked for it, this is a Handover Failure after all). */
5038
5039 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_RADIO_INTERFACE_FAILURE_REVERSION;
5040 var BssmapCause cause := enum2int(cause_val);
5041 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
5042
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02005043 f_expect_dlcx_conns();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005044 f_sleep(1.0);
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005045}
5046testcase TC_ho_in_fail_no_detect() runs on test_CT {
5047 var MSC_ConnHdlr vc_conn;
5048 var TestHdlrParams pars := f_gen_test_hdlr_pars();
5049
5050 f_init(1, true);
5051 f_sleep(1.0);
5052
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005053 f_ctrs_bsc_and_bts_init();
5054
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005055 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
5056 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005057
5058 vc_conn := f_start_handler(refers(f_tc_ho_in_fail_no_detect), pars);
5059 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005060
5061 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5062 f_ctrs_bsc_and_bts_add(0, "handover:error");
5063 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:attempted");
5064 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:error");
5065 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005066 f_shutdown_helper();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005067}
5068
5069/* Same as f_tc_ho_in_fail_no_detect, but MSC fails to send a Clear Command */
5070private function f_tc_ho_in_fail_no_detect2(charstring id) runs on MSC_ConnHdlr {
5071 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
5072 f_rslem_register(0, new_chan_nr);
5073 g_chan_nr := new_chan_nr;
5074 f_sleep(1.0);
5075
5076 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
5077 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
5078 activate(as_Media());
5079
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005080 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005081 f_gen_handover_req()));
Harald Welte6811d102019-04-14 22:23:14 +02005082 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005083
5084 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
5085
5086 var PDU_BSSAP rx_bssap;
5087 var octetstring ho_command_str;
5088
5089 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
5090
5091 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
5092 log("Received L3 Info in HO Request Ack: ", ho_command_str);
5093 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
5094 log("L3 Info in HO Request Ack is ", ho_command);
5095
5096 var GsmArfcn arfcn;
5097 var RslChannelNr actual_new_chan_nr;
5098 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
5099 actual_new_chan_nr, arfcn);
5100
5101 if (actual_new_chan_nr != new_chan_nr) {
5102 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
5103 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
5104 setverdict(fail);
5105 return;
5106 }
5107 log("Handover Command chan_nr is", actual_new_chan_nr);
5108
5109 /* Now the MSC forwards the RR Handover Command to the other BSC, which
5110 * tells the MS to handover to the new lchan. But the MS never shows up
5111 * on the new lchan. */
5112
5113 BSSAP.receive(tr_BSSMAP_HandoverFailure);
5114
5115 /* MSC plays dumb and sends no Clear Command */
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005116 var PDU_BSSAP rx_clear_request;
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02005117
5118 BSSAP.receive(tr_BSSMAP_ClearRequest) -> value rx_clear_request {
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005119 var BssmapCause cause := bit2int(rx_clear_request.pdu.bssmap.clearRequest.cause.causeValue);
5120 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
5121 };
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02005122 f_expect_dlcx_conns();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005123 f_sleep(1.0);
5124}
5125testcase TC_ho_in_fail_no_detect2() runs on test_CT {
5126 var MSC_ConnHdlr vc_conn;
5127 var TestHdlrParams pars := f_gen_test_hdlr_pars();
5128
5129 f_init(1, true);
5130 f_sleep(1.0);
5131
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005132 f_ctrs_bsc_and_bts_init();
5133
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005134 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
5135 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005136
5137 vc_conn := f_start_handler(refers(f_tc_ho_in_fail_no_detect2), pars);
5138 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005139
5140 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5141 f_ctrs_bsc_and_bts_add(0, "handover:error");
5142 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:attempted");
5143 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:error");
5144 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005145 f_shutdown_helper();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005146}
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005147
Neels Hofmeyr91401012019-07-11 00:42:35 +02005148type record of charstring Commands;
5149
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005150private function f_bts_0_cfg(TELNETasp_PT pt, Commands cmds := {})
Neels Hofmeyr91401012019-07-11 00:42:35 +02005151{
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005152 f_vty_enter_cfg_bts(pt, 0);
Neels Hofmeyr91401012019-07-11 00:42:35 +02005153 for (var integer i := 0; i < sizeof(cmds); i := i+1) {
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005154 f_vty_transceive(pt, cmds[i]);
Neels Hofmeyr91401012019-07-11 00:42:35 +02005155 }
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005156 f_vty_transceive(pt, "end");
Neels Hofmeyr91401012019-07-11 00:42:35 +02005157}
5158
Pau Espin Pedrolc675b612020-01-09 19:55:40 +01005159private function f_cs7_inst_0_cfg(TELNETasp_PT pt, Commands cmds := {})
5160{
5161 f_vty_enter_cfg_cs7_inst(pt, 0);
5162 for (var integer i := 0; i < sizeof(cmds); i := i+1) {
5163 f_vty_transceive(pt, cmds[i]);
5164 }
5165 f_vty_transceive(pt, "end");
5166}
5167
Neels Hofmeyr91401012019-07-11 00:42:35 +02005168private function f_probe_for_handover(charstring log_label,
5169 charstring log_descr,
5170 charstring handover_vty_cmd,
5171 boolean expect_handover,
5172 boolean is_inter_bsc_handover := false)
5173runs on MSC_ConnHdlr
5174{
Neels Hofmeyrb3fc8982020-05-11 00:16:42 +02005175 /* We're going to thwart any and all handover attempts, just be ready to handle (and ignore) handover target
5176 * lchans to be established on bts 1 or bts 2. */
5177 f_rslem_suspend(RSL1_PROC);
5178 f_rslem_suspend(RSL2_PROC);
5179
Neels Hofmeyr91401012019-07-11 00:42:35 +02005180 var RSL_Message rsl;
5181
5182 var charstring log_msg := " (expecting handover)"
5183 if (not expect_handover) {
5184 log_msg := " (expecting NO handover)";
5185 }
5186 log("f_probe_for_handover starting: " & log_label & ": " & log_descr & log_msg);
5187 f_vty_transceive(BSCVTY, handover_vty_cmd);
5188
Neels Hofmeyr91401012019-07-11 00:42:35 +02005189 timer T := 2.0;
5190 T.start;
5191
5192 alt {
5193 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr)) -> value rsl {
5194 var PDU_ML3_NW_MS l3 := dec_PDU_ML3_NW_MS(rsl.ies[2].body.l3_info.payload);
5195 log("Rx L3 from net: ", l3);
5196 if (ischosen(l3.msgs.rrm.handoverCommand)) {
5197 var RslChannelNr new_chan_nr;
5198 var GsmArfcn arfcn;
5199 f_ChDesc2RslChanNr(l3.msgs.rrm.handoverCommand.channelDescription2,
5200 new_chan_nr, arfcn);
5201 log("Handover to new chan ", new_chan_nr, " on ARFCN ", arfcn);
5202 log(l3.msgs.rrm.handoverCommand);
5203
5204 /* Need to register for new lchan on new BTS -- it's either bts 1 or bts 2. It doesn't really
5205 * matter on which BTS it really is, we're not going to follow through an entire handover
5206 * anyway. */
5207 f_rslem_register(0, new_chan_nr, RSL1_PROC);
5208 f_rslem_resume(RSL1_PROC);
5209 f_rslem_register(0, new_chan_nr, RSL2_PROC);
5210 f_rslem_resume(RSL2_PROC);
5211
5212 if (expect_handover and not is_inter_bsc_handover) {
5213 setverdict(pass);
5214 log("f_probe_for_handover(" & log_label & "): Got RSL Handover Command as expected.");
5215 } else {
5216 setverdict(fail, "f_probe_for_handover(" & log_label & "): Expected none, but got RSL Handover Command. "
5217 & log_label & ": " & log_descr);
5218 }
5219
5220 log("f_probe_for_handover(" & log_label & "): Ending the test: Handover Failure stops the procedure.");
5221 /* osmo-bsc has triggered Handover. That's all we need to know for this test, reply with
5222 * Handover Failure. */
5223 f_rsl_send_l3(ts_RRM_HandoverFailure('00'O));
5224
5225 /* target BTS is told to release lchan again; don't care which BTS nor what messages. */
5226 f_sleep(0.5);
5227 RSL1.clear;
5228 RSL2.clear;
5229 log("f_probe_for_handover(" & log_label & "): done (got RSL Handover Command)");
5230 break;
5231 } else {
5232 repeat;
5233 }
5234 }
5235 [] BSSAP.receive(tr_BSSMAP_HandoverRequired) {
5236 if (expect_handover and is_inter_bsc_handover) {
5237 setverdict(pass);
5238 log("f_probe_for_handover(" & log_label & "): Got BSSMAP Handover Required as expected.");
5239 } else {
5240 setverdict(fail, "f_probe_for_handover(" & log_label & "): Expected none, but got BSSMAP Handover Required. "
5241 & log_label & ": " & log_descr);
5242 }
5243
5244 log("f_probe_for_handover(" & log_label & "): done (got BSSMAP Handover Required)");
5245
5246 /* Note: f_tc_ho_neighbor_config_start() sets T7, the timeout for BSSMAP Handover Required, to
5247 * 1 second. There is no legal way to quickly abort a handover after a BSSMAP Handover Required,
5248 * setting a short timeout and waiting is the only way. */
5249 log("f_probe_for_handover(" & log_label & "): waiting for inter-BSC HO to time out...");
5250 f_sleep(1.5);
5251 log("f_probe_for_handover(" & log_label & "): ...done");
5252
5253 break;
5254 }
5255 [] T.timeout {
5256 if (expect_handover) {
5257 setverdict(fail, "f_probe_for_handover(" & log_label & "): Expected Handover, but got none. "
5258 & log_label & ": " & log_descr);
5259 } else {
5260 setverdict(pass);
5261 log("f_probe_for_handover(" & log_label & "): Got no Handover, as expected.");
5262 }
5263 log("f_probe_for_handover(" & log_label & "): done (got no Handover)");
5264 break;
5265 }
5266 }
5267
5268 f_rslem_resume(RSL1_PROC);
5269 f_rslem_resume(RSL2_PROC);
5270 f_sleep(3.0);
5271 RSL.clear;
5272
5273 log("f_probe_for_handover(" & log_label & "): done clearing");
5274}
5275
5276/* Test the effect of various neighbor configuration scenarios:
5277 *
5278 * To avoid complexity, block off any actual handover operation, and always remain on the lchan at bts 0.
5279 * Reconfigure the neighbors for bts 0, trigger a Handover, and probe whether osmo-bsc does or doesn't start HO.
5280 */
5281private function f_tc_ho_neighbor_config_start() runs on MSC_ConnHdlr {
5282 g_pars := f_gen_test_hdlr_pars();
5283 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
5284 var PDU_BSSAP ass_cmd := f_gen_ass_req();
5285 const OCT8 kc := '0001020304050607'O;
5286
5287 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
5288 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
5289
5290 /* Establish lchan at bts 0 */
5291 f_establish_fully(ass_cmd, exp_compl);
5292
5293 /* Shorten the inter-BSC Handover timeout, to not wait so long for inter-BSC Handovers */
5294 f_vty_enter_cfg_network(BSCVTY);
5295 f_vty_transceive(BSCVTY, "timer T7 1");
5296 f_vty_transceive(BSCVTY, "end");
5297}
5298
5299private function f_tc_ho_neighbor_config_1(charstring id) runs on MSC_ConnHdlr {
5300 f_tc_ho_neighbor_config_start();
5301
5302 /*
5303 * bts 0 ARFCN 871 BSIC 10
5304 * bts 1 ARFCN 871 BSIC 11
5305 * bts 2 ARFCN 871 BSIC 12
5306 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
5307 */
5308
5309 log("f_tc_ho_neighbor_config: 1. No 'neighbor' config");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005310 f_bts_0_cfg(BSCVTY, {"no neighbors"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02005311 f_probe_for_handover("1.a", "HO to bts 1 works, implicitly listed as neighbor (legacy behavior when none are configured)",
5312 "handover any to arfcn 871 bsic 11",
5313 true);
5314
5315 f_probe_for_handover("1.b", "HO to unknown cell does not start",
5316 "handover any to arfcn 13 bsic 39",
5317 false);
5318
5319 f_probe_for_handover("1.c", "HO to 871-12 is ambiguous = error",
5320 "handover any to arfcn 871 bsic 12",
5321 false);
5322
5323 f_probe_for_handover("1.d", "HO to 871-11 still works (verify that this test properly cleans up)",
5324 "handover any to arfcn 871 bsic 11",
5325 true);
5326}
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005327testcase TC_ho_neighbor_config_1() runs on test_CT {
5328 var MSC_ConnHdlr vc_conn;
5329 f_init(3, true, guard_timeout := 60.0);
5330 f_sleep(1.0);
5331 f_ctrs_bsc_and_bts_init();
5332 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_1));
5333 vc_conn.done;
5334
5335 /* f_tc_ho_neighbor_config_start() */
5336 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5337 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5338
5339 /* 1.a */
5340 /* "failed" means a handover was triggered and started (which is all this test aims for) and the test ended the
5341 * handover quickly by sending a Handover Failure message. */
5342 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5343 f_ctrs_bsc_and_bts_add(0, "handover:failed");
5344 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
5345 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:failed");
5346
5347 /* 1.b */
5348 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5349 f_ctrs_bsc_and_bts_add(0, "handover:error");
5350
5351 /* 1.c */
5352 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5353 f_ctrs_bsc_and_bts_add(0, "handover:error");
5354
5355 /* 1.d */
5356 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5357 f_ctrs_bsc_and_bts_add(0, "handover:failed");
5358 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
5359 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:failed");
5360
5361 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005362 f_shutdown_helper();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005363}
5364
Neels Hofmeyr91401012019-07-11 00:42:35 +02005365private function f_tc_ho_neighbor_config_2(charstring id) runs on MSC_ConnHdlr {
5366 f_tc_ho_neighbor_config_start();
5367
5368 /*
5369 * bts 0 ARFCN 871 BSIC 10
5370 * bts 1 ARFCN 871 BSIC 11
5371 * bts 2 ARFCN 871 BSIC 12
5372 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
5373 */
5374
5375 log("f_tc_ho_neighbor_config: 2. explicit local neighbor: 'neighbor bts 1'");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005376 f_bts_0_cfg(BSCVTY, {"neighbor bts 1"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02005377 f_sleep(0.5);
5378
5379 f_probe_for_handover("2.a", "HO to bts 1 works, explicitly listed as neighbor",
5380 "handover any to arfcn 871 bsic 11",
5381 true);
5382
5383 f_probe_for_handover("2.b", "HO to bts 2 doesn't work, not listed as neighbor",
5384 "handover any to arfcn 871 bsic 12",
5385 false);
5386}
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005387testcase TC_ho_neighbor_config_2() runs on test_CT {
5388 var MSC_ConnHdlr vc_conn;
5389 f_init(3, true, guard_timeout := 50.0);
5390 f_sleep(1.0);
5391 f_ctrs_bsc_and_bts_init();
5392 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_2));
5393 vc_conn.done;
5394
5395 /* f_tc_ho_neighbor_config_start() */
5396 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5397 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5398
5399 /* 2.a */
5400 /* "failed" means a handover was triggered and started (which is all this test aims for) and the test ended the
5401 * handover quickly by sending a Handover Failure message. */
5402 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5403 f_ctrs_bsc_and_bts_add(0, "handover:failed");
5404 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
5405 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:failed");
5406
5407 /* 2.b */
5408 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5409 f_ctrs_bsc_and_bts_add(0, "handover:error");
5410
5411 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005412 f_shutdown_helper();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005413}
5414
Neels Hofmeyr91401012019-07-11 00:42:35 +02005415private function f_tc_ho_neighbor_config_3(charstring id) runs on MSC_ConnHdlr {
5416 f_tc_ho_neighbor_config_start();
5417
5418 /*
5419 * bts 0 ARFCN 871 BSIC 10
5420 * bts 1 ARFCN 871 BSIC 11
5421 * bts 2 ARFCN 871 BSIC 12
5422 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
5423 */
5424
5425 log("f_tc_ho_neighbor_config: 3. explicit local neighbor: 'neighbor bts 2'");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005426 f_bts_0_cfg(BSCVTY, {"no neighbors", "neighbor bts 2"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02005427 f_sleep(0.5);
5428
5429 f_probe_for_handover("3.a", "HO to bts 1 doesn't work, not listed as neighbor",
5430 "handover any to arfcn 871 bsic 11",
5431 false);
5432 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",
5433 "handover any to arfcn 871 bsic 12",
5434 true);
5435}
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005436testcase TC_ho_neighbor_config_3() runs on test_CT {
5437 var MSC_ConnHdlr vc_conn;
5438 f_init(3, true, guard_timeout := 50.0);
5439 f_sleep(1.0);
5440 f_ctrs_bsc_and_bts_init();
5441 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_3));
5442 vc_conn.done;
5443
5444 /* f_tc_ho_neighbor_config_start() */
5445 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5446 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5447
5448 /* 3.a */
5449 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5450 f_ctrs_bsc_and_bts_add(0, "handover:error");
5451
5452 /* 3.b */
5453 /* "failed" means a handover was triggered and started (which is all this test aims for) and the test ended the
5454 * handover quickly by sending a Handover Failure message. */
5455 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5456 f_ctrs_bsc_and_bts_add(0, "handover:failed");
5457 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
5458 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:failed");
5459
5460 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005461 f_shutdown_helper();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005462}
5463
Neels Hofmeyr91401012019-07-11 00:42:35 +02005464private function f_tc_ho_neighbor_config_4(charstring id) runs on MSC_ConnHdlr {
5465 f_tc_ho_neighbor_config_start();
5466
5467 /*
5468 * bts 0 ARFCN 871 BSIC 10
5469 * bts 1 ARFCN 871 BSIC 11
5470 * bts 2 ARFCN 871 BSIC 12
5471 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
5472 */
5473
5474 log("f_tc_ho_neighbor_config: 4. explicit remote neighbor: 'neighbor lac 99 arfcn 123 bsic 45'");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005475 f_bts_0_cfg(BSCVTY, {"no neighbors", "neighbor lac 99 arfcn 123 bsic 45"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02005476 f_sleep(0.5);
5477
5478 f_probe_for_handover("4.a", "HO to bts 1 doesn't work, not listed as neighbor",
5479 "handover any to arfcn 871 bsic 11",
5480 false);
5481 f_probe_for_handover("4.b", "HO to bts 2 doesn't work, not listed as neighbor",
5482 "handover any to arfcn 871 bsic 12",
5483 false);
5484 f_probe_for_handover("4.c", "HO to 123-45 triggers inter-BSC HO",
5485 "handover any to arfcn 123 bsic 45",
5486 true, true);
5487}
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005488testcase TC_ho_neighbor_config_4() runs on test_CT {
5489 var MSC_ConnHdlr vc_conn;
5490 f_init(3, true, guard_timeout := 50.0);
5491 f_sleep(1.0);
5492 f_ctrs_bsc_and_bts_init();
5493 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_4));
5494 vc_conn.done;
5495
5496 /* f_tc_ho_neighbor_config_start() */
5497 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5498 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5499
5500 /* 4.a */
5501 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5502 f_ctrs_bsc_and_bts_add(0, "handover:error");
5503
5504 /* 4.b */
5505 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5506 f_ctrs_bsc_and_bts_add(0, "handover:error");
5507
5508 /* 4.c */
5509 /* "timeout" means a handover was triggered and started (which is all this test aims for) and the test ended the
5510 * handover quickly by timing out after the Handover Required message */
5511 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5512 f_ctrs_bsc_and_bts_add(0, "handover:timeout");
5513 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
5514 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:timeout");
5515
5516 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005517 f_shutdown_helper();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005518}
5519
Neels Hofmeyr91401012019-07-11 00:42:35 +02005520private function f_tc_ho_neighbor_config_5(charstring id) runs on MSC_ConnHdlr {
5521 f_tc_ho_neighbor_config_start();
5522
5523 /*
5524 * bts 0 ARFCN 871 BSIC 10
5525 * bts 1 ARFCN 871 BSIC 11
5526 * bts 2 ARFCN 871 BSIC 12
5527 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
5528 */
5529
5530 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 +02005531 f_bts_0_cfg(BSCVTY, {"no neighbors", "neighbor lac 99 arfcn 871 bsic 12"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02005532 f_sleep(0.5);
5533
5534 f_probe_for_handover("5.a", "HO to 871-12 triggers inter-BSC HO (ignoring local cells with same ARFCN+BSIC)",
5535 "handover any to arfcn 871 bsic 12",
5536 true, true);
5537}
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005538testcase TC_ho_neighbor_config_5() runs on test_CT {
5539 var MSC_ConnHdlr vc_conn;
5540 f_init(3, true);
5541 f_sleep(1.0);
5542 f_ctrs_bsc_and_bts_init();
5543 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_5));
5544 vc_conn.done;
5545
5546 /* f_tc_ho_neighbor_config_start() */
5547 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5548 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5549
5550 /* 5 */
5551 /* "timeout" means a handover was triggered and started (which is all this test aims for) and the test ended the
5552 * handover quickly by timing out after the Handover Required message */
5553 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5554 f_ctrs_bsc_and_bts_add(0, "handover:timeout");
5555 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
5556 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:timeout");
5557
5558 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005559 f_shutdown_helper();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005560}
5561
Neels Hofmeyr91401012019-07-11 00:42:35 +02005562private function f_tc_ho_neighbor_config_6(charstring id) runs on MSC_ConnHdlr {
5563 f_tc_ho_neighbor_config_start();
5564
5565 /*
5566 * bts 0 ARFCN 871 BSIC 10
5567 * bts 1 ARFCN 871 BSIC 11
5568 * bts 2 ARFCN 871 BSIC 12
5569 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
5570 */
5571
5572 log("f_tc_ho_neighbor_config: 6. config error: explicit local and remote neighbors with ambiguous ARFCN+BSIC:"
5573 & " 'neighbor bts 2; neighbor lac 99 arfcn 871 bsic 12'");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005574 f_bts_0_cfg(BSCVTY, {"no neighbors", "neighbor bts 2", "neighbor lac 99 arfcn 871 bsic 12"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02005575 f_sleep(0.5);
5576
5577 f_probe_for_handover("6.a", "HO to 871-12 is ambiguous = error",
5578 "handover any to arfcn 871 bsic 12",
5579 false);
5580}
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005581testcase TC_ho_neighbor_config_6() runs on test_CT {
5582 var MSC_ConnHdlr vc_conn;
5583 f_init(3, true);
5584 f_sleep(1.0);
5585 f_ctrs_bsc_and_bts_init();
5586 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_6));
5587 vc_conn.done;
5588
5589 /* f_tc_ho_neighbor_config_start() */
5590 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5591 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5592
5593 /* 6.a */
5594 /* "timeout" means a handover was triggered and started (which is all this test aims for) and the test ended the
5595 * handover quickly by timing out after the Handover Required message */
5596 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5597 f_ctrs_bsc_and_bts_add(0, "handover:error");
5598
5599 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005600 f_shutdown_helper();
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005601}
5602
Neels Hofmeyr91401012019-07-11 00:42:35 +02005603private function f_tc_ho_neighbor_config_7(charstring id) runs on MSC_ConnHdlr {
5604 f_tc_ho_neighbor_config_start();
5605
5606 /*
5607 * bts 0 ARFCN 871 BSIC 10
5608 * bts 1 ARFCN 871 BSIC 11
5609 * bts 2 ARFCN 871 BSIC 12
5610 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
5611 */
5612
5613 log("f_tc_ho_neighbor_config: 7. explicit local and remote neighbors:"
5614 & " 'neighbor bts 2; neighbor lac 99 arfcn 123 bsic 45'");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005615 f_bts_0_cfg(BSCVTY, {"no neighbors", "neighbor bts 2", "neighbor lac 99 arfcn 123 bsic 45"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02005616 f_sleep(0.5);
5617
5618 f_probe_for_handover("7.a", "HO to 871-12 does HO to bts 2",
5619 "handover any to arfcn 871 bsic 12",
5620 true);
5621 f_probe_for_handover("7.b", "HO to 123-45 triggers inter-BSC HO",
5622 "handover any to arfcn 123 bsic 45",
5623 true, true);
5624}
Neels Hofmeyr91401012019-07-11 00:42:35 +02005625testcase TC_ho_neighbor_config_7() runs on test_CT {
5626 var MSC_ConnHdlr vc_conn;
Neels Hofmeyrf2b88032020-06-16 00:35:04 +02005627 f_init(3, true, guard_timeout := 50.0);
Neels Hofmeyr91401012019-07-11 00:42:35 +02005628 f_sleep(1.0);
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005629 f_ctrs_bsc_and_bts_init();
Neels Hofmeyr91401012019-07-11 00:42:35 +02005630 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_7));
5631 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005632
5633 /* f_tc_ho_neighbor_config_start() */
5634 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5635 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5636
5637 /* 7.a */
5638 /* "failed" means a handover was triggered and started (which is all this test aims for) and the test ended the
5639 * handover quickly by sending a Handover Failure message. */
5640 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5641 f_ctrs_bsc_and_bts_add(0, "handover:failed");
5642 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
5643 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:failed");
5644
5645 /* 7.b */
5646 /* "timeout" means a handover was triggered and started (which is all this test aims for) and the test ended the
5647 * handover quickly by timing out after the Handover Required message */
5648 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5649 f_ctrs_bsc_and_bts_add(0, "handover:timeout");
5650 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
5651 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:timeout");
5652
5653 f_ctrs_bsc_and_bts_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005654 f_shutdown_helper();
Neels Hofmeyr91401012019-07-11 00:42:35 +02005655}
5656
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01005657/* OS#3041: Open and close N connections in a normal fashion, and expect no
5658 * BSSMAP Reset just because of that. */
5659testcase TC_bssap_rlsd_does_not_cause_bssmap_reset() runs on test_CT {
5660 var default d;
5661 var integer i;
5662 var DchanTuple dt;
5663
5664 f_init();
5665
5666 /* Wait for initial BSSMAP Reset to pass */
5667 f_sleep(4.0);
5668
5669 d := activate(no_bssmap_reset());
5670
5671 /* Setup up a number of connections and RLSD them again from the MSC
5672 * side. In the buggy behavior, the fourth one triggers BSSMAP Reset.
5673 * Let's do it some more times for good measure. */
Harald Weltec3260d92018-06-11 17:48:16 +02005674 for (i := 0; i < 4; i := i+1) {
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01005675 /* Since we're doing a lot of runs, give each one a fresh
5676 * T_guard from the top. */
5677 T_guard.start;
5678
5679 /* Setup a BSSAP connection and clear it right away. This is
5680 * the MSC telling the BSC about a planned release, it's not an
5681 * erratic loss of a connection. */
Harald Weltea1897182018-06-11 13:53:09 +02005682 dt := f_est_dchan(int2oct(i,1), 23+i, '00010203040506'O);
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01005683
5684 /* MSC disconnects (RLSD). */
5685 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
5686 }
5687
5688 /* In the buggy behavior, a timeout of 2 seconds happens between above
5689 * trigger (logs "SIGTRAN connection down, reconnecting...") and the
5690 * actual BSSMAP Reset. Wait a bit longer just to make sure. */
5691 f_sleep(4.0);
5692
5693 deactivate(d);
5694 f_shutdown_helper();
5695}
Harald Welte552620d2017-12-16 23:21:36 +01005696
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01005697/* OS#3041: Open and close N connections in a normal fashion, and expect no
5698 * BSSMAP Reset just because of that. Invoke the release by a BSSMAP Clear from
5699 * the MSC. */
5700testcase TC_bssmap_clear_does_not_cause_bssmap_reset() runs on test_CT {
5701 var default d;
5702 var integer i;
5703 var DchanTuple dt;
5704 var BSSAP_N_DATA_ind rx_di;
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01005705 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_CALL_CONTROL;
5706 var BssmapCause cause := enum2int(cause_val);
5707
5708 f_init();
5709
5710 /* Wait for initial BSSMAP Reset to pass */
5711 f_sleep(4.0);
5712
5713 d := activate(no_bssmap_reset());
5714
5715 /* Setup up a number of connections and RLSD them again from the MSC
5716 * side. In the buggy behavior, the fourth one triggers BSSMAP Reset.
5717 * Let's do it some more times for good measure. */
5718 for (i := 0; i < 8; i := i+1) {
5719 /* Since we're doing a lot of runs, give each one a fresh
5720 * T_guard from the top. */
5721 T_guard.start;
5722
5723 /* Setup a BSSAP connection and clear it right away. This is
5724 * the MSC telling the BSC about a planned release, it's not an
5725 * erratic loss of a connection. */
Harald Weltea1897182018-06-11 13:53:09 +02005726 dt := f_est_dchan(int2oct(i,1), 23+i, '00010203040506'O);
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01005727
5728 /* Instruct BSC to clear channel */
5729 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
5730
5731 /* expect BSC to disable the channel */
Harald Welte641fcbe2018-06-14 10:58:35 +02005732 f_exp_chan_rel_and_clear(dt, 0);
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01005733 }
5734
5735 /* In the buggy behavior, a timeout of 2 seconds happens between above
5736 * trigger (logs "SIGTRAN connection down, reconnecting...") and the
5737 * actual BSSMAP Reset. Wait a bit longer just to make sure. */
5738 f_sleep(4.0);
5739
5740 deactivate(d);
5741 f_shutdown_helper();
5742}
5743
Neels Hofmeyrfd445c32018-03-09 15:39:31 +01005744/* OS#3041: Open and close N connections in a normal fashion, and expect no
5745 * BSSMAP Reset just because of that. Close connections from the MS side with a
5746 * Release Ind on RSL. */
5747testcase TC_ms_rel_ind_does_not_cause_bssmap_reset() runs on test_CT {
5748 var default d;
5749 var integer i;
5750 var DchanTuple dt;
5751 var BSSAP_N_DATA_ind rx_di;
Neels Hofmeyrfd445c32018-03-09 15:39:31 +01005752 var integer j;
5753
5754 f_init();
5755
5756 /* Wait for initial BSSMAP Reset to pass */
5757 f_sleep(4.0);
5758
5759 d := activate(no_bssmap_reset());
5760
5761 /* Setup up a number of connections and RLSD them again from the MSC
5762 * side. In the buggy behavior, the fourth one triggers BSSMAP Reset.
5763 * Let's do it some more times for good measure. */
5764 for (i := 0; i < 8; i := i+1) {
5765 /* Since we're doing a lot of runs, give each one a fresh
5766 * T_guard from the top. */
5767 T_guard.start;
5768
5769 /* Setup a BSSAP connection and clear it right away. This is
5770 * the MSC telling the BSC about a planned release, it's not an
5771 * erratic loss of a connection. */
5772 dt := f_est_dchan('23'O, 23, '00010203040506'O);
5773
5774 /* simulate RLL REL IND */
5775 f_ipa_tx(0, ts_RSL_REL_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0))));
5776
5777 /* expect Clear Request on MSC side */
5778 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearRequest)) -> value rx_di;
5779
5780 /* Instruct BSC to clear channel */
5781 var BssmapCause cause := bit2int(rx_di.userData.pdu.bssmap.clearRequest.cause.causeValue);
5782 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
5783
5784 /* expect BSC to disable the channel */
Harald Welte641fcbe2018-06-14 10:58:35 +02005785 f_exp_chan_rel_and_clear(dt, 0);
Neels Hofmeyrfd445c32018-03-09 15:39:31 +01005786 }
5787
5788 /* In the buggy behavior, a timeout of 2 seconds happens between above
5789 * trigger (logs "SIGTRAN connection down, reconnecting...") and the
5790 * actual BSSMAP Reset. Wait a bit longer just to make sure. */
5791 f_sleep(4.0);
5792
5793 deactivate(d);
5794 f_shutdown_helper();
5795}
5796
Harald Welte94e0c342018-04-07 11:33:23 +02005797/***********************************************************************
5798 * IPA style dynamic PDCH
5799 ***********************************************************************/
5800
5801private function f_dyn_ipa_pdch_act(integer bts_nr, integer trx_nr, integer ts_nr,
5802 template (omit) RSL_Cause nack := omit)
5803runs on test_CT {
5804 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(ts_nr));
5805 var RSL_Message rsl_unused;
5806 /* ask BSC via VTY to activate a given IPA style chan as PDCH */
5807 f_vty_ts_action("pdch activate", bts_nr, trx_nr, ts_nr);
5808 /* expect the BSC to issue the related RSL command */
5809 rsl_unused := f_exp_ipa_rx(0, tr_RSL_IPA_PDCH_ACT(chan_nr));
5810 if (istemplatekind(nack, "omit")) {
5811 /* respond with a related acknowledgement */
5812 f_ipa_tx(0, ts_RSL_IPA_PDCH_ACT_ACK(chan_nr, ts_RSL_IE_FrameNumber(2342)));
5813 } else {
5814 f_ipa_tx(0, ts_RSL_IPA_PDCH_ACT_NACK(chan_nr, valueof(nack)));
5815 }
5816}
5817
5818private function f_dyn_ipa_pdch_deact(integer bts_nr, integer trx_nr, integer ts_nr,
5819 template (omit) RSL_Cause nack := omit)
5820runs on test_CT {
5821 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(ts_nr));
5822 var RSL_Message rsl_unused;
5823 /* ask BSC via VTY to activate a given IPA style chan as PDCH */
5824 f_vty_ts_action("pdch deactivate", bts_nr, trx_nr, ts_nr);
5825 /* expect the BSC to issue the related RSL command */
5826 rsl_unused := f_exp_ipa_rx(0, tr_RSL_IPA_PDCH_DEACT(chan_nr));
5827 if (istemplatekind(nack, "omit")) {
5828 /* respond with a related acknowledgement */
5829 f_ipa_tx(0, ts_RSL_IPA_PDCH_DEACT_ACK(chan_nr));
5830 } else {
5831 f_ipa_tx(0, ts_RSL_IPA_PDCH_DEACT_NACK(chan_nr, valueof(nack)));
5832 }
5833}
5834
5835private function f_ts_dyn_mode_get(integer bts_nr, integer trx_nr, integer ts_nr)
5836runs on test_CT return charstring {
5837 var charstring cmd, resp;
5838 cmd := "show timeslot "&int2str(bts_nr)&" "&int2str(trx_nr)&" "&int2str(ts_nr);
Stefan Sperlingcff13562018-11-13 15:24:06 +01005839 return f_vty_transceive_match_regexp_retry(BSCVTY, cmd, "*\((*)\)*", 0, 4, 1.0);
Harald Welte94e0c342018-04-07 11:33:23 +02005840}
5841
5842private function f_ts_dyn_mode_assert(integer bts_nr, integer trx_nr, integer ts_nr,
5843 template charstring exp)
5844runs on test_CT {
5845 var charstring mode := f_ts_dyn_mode_get(bts_nr, trx_nr, ts_nr);
5846 if (not match(mode, exp)) {
5847 setverdict(fail, "Unexpected TS Mode: ", mode);
Daniel Willmannafce8662018-07-06 23:11:32 +02005848 mtc.stop;
Harald Welte94e0c342018-04-07 11:33:23 +02005849 }
5850}
5851
5852private function f_ts_set_chcomb(integer bts_nr, integer trx_nr, integer ts_nr, charstring chcomb)
5853runs on test_CT {
5854 f_vty_enter_cfg_ts(BSCVTY, bts_nr, trx_nr, ts_nr);
5855 f_vty_transceive(BSCVTY, "phys_chan_config " & chcomb);
5856 f_vty_transceive(BSCVTY, "end");
5857}
5858
5859private const charstring TCHF_MODE := "TCH/F mode";
5860private const charstring TCHH_MODE := "TCH/H mode";
5861private const charstring PDCH_MODE := "PDCH mode";
5862private const charstring NONE_MODE := "NONE mode";
5863
5864/* Test IPA PDCH activation / deactivation triggered by VTY */
5865testcase TC_dyn_pdch_ipa_act_deact() runs on test_CT {
5866 var RSL_Message rsl_unused;
5867
5868 /* change Timeslot 6 before f_init() starts RSL */
5869 f_init_vty();
5870 f_ts_set_chcomb(0, 0, 6, "TCH/F_PDCH");
5871 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
5872
5873 f_init(1, false);
5874 f_sleep(1.0);
5875
5876 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(6));
5877
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02005878 log("TCH/F_PDCH pchan starts out in TCH/F mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02005879 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
5880 /* The BSC will activate the dynamic PDCH by default, so confirm that */
5881 rsl_unused := f_exp_ipa_rx(0, tr_RSL_IPA_PDCH_ACT(chan_nr));
5882 f_ipa_tx(0, ts_RSL_IPA_PDCH_ACT_ACK(chan_nr, ts_RSL_IE_FrameNumber(2342)));
5883 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02005884 log("TCH/F_PDCH pchan, PDCH ACT was ACKed, so now in PDCH mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02005885 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, PDCH_MODE);
5886
5887 /* De-activate it via VTY */
5888 f_dyn_ipa_pdch_deact(0, 0, chan_nr.tn);
5889 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02005890 log("TCH/F_PDCH pchan, PDCH DEACT via VTY, so now back in TCH/F mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02005891 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
5892
5893 /* re-activate it via VTY */
5894 f_dyn_ipa_pdch_act(0, 0, chan_nr.tn);
5895 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02005896 log("TCH/F_PDCH pchan, PDCH ACT via VTY, so now in PDCH mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02005897 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, PDCH_MODE);
5898
5899 /* and finally de-activate it again */
5900 f_dyn_ipa_pdch_deact(0, 0, chan_nr.tn);
5901 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02005902 log("TCH/F_PDCH pchan, PDCH DEACT via VTY, so now back in TCH/F mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02005903 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
5904
Neels Hofmeyr887e8f12018-06-27 01:01:55 +02005905 /* clean up config */
5906 f_ts_set_chcomb(0, 0, 6, "PDCH");
5907
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005908 f_shutdown_helper();
Harald Welte94e0c342018-04-07 11:33:23 +02005909}
5910
5911/* Test IPA PDCH activation NACK */
5912testcase TC_dyn_pdch_ipa_act_nack() runs on test_CT {
5913 var RSL_Message rsl_unused;
5914
5915 /* change Timeslot 6 before f_init() starts RSL */
5916 f_init_vty();
5917 f_ts_set_chcomb(0, 0, 6, "TCH/F_PDCH");
5918 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
5919
5920 f_init(1, false);
5921 f_sleep(1.0);
5922
5923 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(6));
5924
5925 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
5926 /* The BSC will activate the dynamic PDCH by default, so confirm that */
5927 rsl_unused := f_exp_ipa_rx(0, tr_RSL_IPA_PDCH_ACT(chan_nr));
5928 f_ipa_tx(0, ts_RSL_IPA_PDCH_ACT_ACK(chan_nr, ts_RSL_IE_FrameNumber(2342)));
5929 f_sleep(1.0);
5930 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, PDCH_MODE);
5931
5932 /* De-activate it via VTY */
5933 f_dyn_ipa_pdch_deact(0, 0, chan_nr.tn);
5934 f_sleep(1.0);
5935 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
5936
5937 /* re-activate it via VTY, but fail that; check BSC still assumes TCH/F mode */
5938 f_dyn_ipa_pdch_act(0, 0, chan_nr.tn, RSL_ERR_EQUIPMENT_FAIL);
5939 f_sleep(1.0);
5940 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
5941
Neels Hofmeyr887e8f12018-06-27 01:01:55 +02005942 /* clean up config */
5943 f_ts_set_chcomb(0, 0, 6, "PDCH");
5944
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02005945 f_shutdown_helper();
Harald Welte94e0c342018-04-07 11:33:23 +02005946}
5947
5948
5949/***********************************************************************
5950 * Osmocom style dynamic PDCH
5951 ***********************************************************************/
5952
5953private function f_dyn_osmo_pdch_act(integer bts_nr, integer trx_nr, integer ts_nr,
5954 template (omit) RSL_Cause nack := omit)
5955runs on test_CT {
5956 var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(ts_nr));
5957 var RSL_Message rsl_unused;
5958 /* ask BSC via VTY to activate a given IPA style chan as PDCH */
5959 /* FIXME: no VTY command to activate Osmocom PDCH !! */
5960 /* expect the BSC to issue the related RSL command */
5961 rsl_unused := f_exp_ipa_rx(0, tr_RSL_CHAN_ACT(chan_nr, ?));
5962 if (istemplatekind(nack, "omit")) {
5963 /* respond with a related acknowledgement */
5964 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, 2342));
5965 } else {
5966 f_ipa_tx(0, ts_RSL_CHAN_ACT_NACK(chan_nr, valueof(nack)));
5967 }
5968}
5969
5970private function f_dyn_osmo_pdch_deact(integer bts_nr, integer trx_nr, integer ts_nr,
5971 template (omit) RSL_Cause nack := omit)
5972runs on test_CT {
5973 var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(ts_nr));
5974 var RSL_Message rsl_unused;
5975 /* ask BSC via VTY to activate a given IPA style chan as PDCH */
5976 /* FIXME: no VTY command to activate Osmocom PDCH !! */
5977 /* expect the BSC to issue the related RSL command */
5978 rsl_unused := f_exp_ipa_rx(0, tr_RSL_RF_CHAN_REL(chan_nr));
5979 if (istemplatekind(nack, "omit")) {
5980 /* respond with a related acknowledgement */
5981 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(chan_nr));
5982 } else {
5983 //f_ipa_tx(0, ts_RSL_RF_CHAN_REL_NACK(chan_nr, valueof(nack)));
5984 }
5985}
5986
5987/* Test Osmocom dyn PDCH activation / deactivation triggered by VTY */
5988testcase TC_dyn_pdch_osmo_act_deact() runs on test_CT {
5989 var RSL_Message rsl_unused;
5990
5991 /* change Timeslot 6 before f_init() starts RSL */
5992 f_init_vty();
5993 f_ts_set_chcomb(0, 0, 6, "TCH/F_TCH/H_PDCH");
5994 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
5995
5996 f_init(1, false);
5997 f_sleep(1.0);
5998
5999 var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(6));
6000
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02006001 log("TCH/F_TCH/H_PDCH pchan starts out in disabled mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02006002 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, NONE_MODE);
6003 /* The BSC will activate the dynamic PDCH by default, so confirm that */
6004 rsl_unused := f_exp_ipa_rx(0, tr_RSL_CHAN_ACT_PDCH(chan_nr, ?));
6005
6006 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, 2342));
6007 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02006008 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 +02006009 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, PDCH_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 Osmocom dyn PDCH activation NACK behavior */
6018testcase TC_dyn_pdch_osmo_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_TCH/H_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_PDCH(6));
6030
6031 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, NONE_MODE);
6032 /* The BSC will activate the dynamic PDCH by default, so confirm that */
6033 rsl_unused := f_exp_ipa_rx(0, tr_RSL_CHAN_ACT_PDCH(chan_nr, ?));
6034
6035 /* NACK this activation and expect the "show timeslot" mode still to be NONE */
6036 f_ipa_tx(0, ts_RSL_CHAN_ACT_NACK(chan_nr, RSL_ERR_EQUIPMENT_FAIL));
6037 f_sleep(1.0);
6038 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, NONE_MODE);
6039
Neels Hofmeyr887e8f12018-06-27 01:01:55 +02006040 /* clean up config */
6041 f_ts_set_chcomb(0, 0, 6, "PDCH");
6042
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006043 f_shutdown_helper();
Harald Welte94e0c342018-04-07 11:33:23 +02006044}
6045
Stefan Sperling0796a822018-10-05 13:01:39 +02006046testcase TC_chopped_ipa_ping() runs on test_CT {
Stefan Sperling554123f2018-10-09 14:12:30 +02006047 const Integers bsc_ipa_ports := {mp_bsc_rsl_port, mp_bsc_oml_port, mp_bsc_ctrl_port};
Stefan Sperling0796a822018-10-05 13:01:39 +02006048 for (var integer i := 0; i < lengthof(bsc_ipa_ports); i := i + 1) {
6049 IPA_Testing.f_run_TC_chopped_ipa_ping(mp_bsc_ip, bsc_ipa_ports[i], CONNECT_TO_SERVER);
6050 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006051 f_shutdown_helper();
Stefan Sperling0796a822018-10-05 13:01:39 +02006052}
6053
Stefan Sperlingaa1e60f2018-10-15 16:34:07 +02006054testcase TC_chopped_ipa_payload() runs on test_CT {
6055 const Integers bsc_ipa_ports := {mp_bsc_rsl_port, mp_bsc_oml_port
6056 /* TODO: mp_bsc_ctrl_port does not work yet */};
6057 for (var integer i := 0; i < lengthof(bsc_ipa_ports); i := i + 1) {
6058 IPA_Testing.f_run_TC_chopped_ipa_payload(mp_bsc_ip, bsc_ipa_ports[i], CONNECT_TO_SERVER);
6059 }
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006060 f_shutdown_helper();
Stefan Sperlingaa1e60f2018-10-15 16:34:07 +02006061}
6062
Pau Espin Pedrol8f773632019-11-05 11:46:53 +01006063/* Verify the BSC sends the MS Power Parameters IE during CHAN ACT to make sure
6064 the BTS does autonomous MS power control loop */
6065testcase TC_assignment_verify_ms_power_params_ie() runs on test_CT {
6066 var MSC_ConnHdlr vc_conn;
6067 var TestHdlrParams pars := f_gen_test_hdlr_pars();
6068 //pars.encr := valueof(t_EncrParams('01'O, f_rnd_octstring(8)));
6069 pars.exp_ms_power_params := true;
6070
6071 f_init(1, true);
6072 f_sleep(1.0);
6073 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5), pars);
6074 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006075 f_shutdown_helper();
Pau Espin Pedrol8f773632019-11-05 11:46:53 +01006076}
Stefan Sperlingaa1e60f2018-10-15 16:34:07 +02006077
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006078/***********************************************************************
6079 * MSC Pooling
6080 ***********************************************************************/
6081
6082function f_tmsi_nri(integer nri_v, octetstring base_tmsi := '42000023'O, integer nri_bitlen := 10) return octetstring
6083{
6084 return int2oct( oct2int(base_tmsi) + bit2int( (int2bit(nri_v, 32) << ( 24 - nri_bitlen)) ),
6085 4);
6086}
6087
6088template MobileIdentityLV ts_MI_TMSI_NRI_LV(integer nri_v, integer nri_bitlen := 10) :=
6089 ts_MI_TMSI_LV(tmsi := f_tmsi_nri(nri_v, nri_bitlen := nri_bitlen));
6090
6091private function f_perform_clear(RSL_DCHAN_PT rsl) runs on MSC_ConnHdlr {
6092 f_logp("MSC instructs BSC to clear channel");
6093 BSSAP.send(ts_BSSMAP_ClearCommand(0));
6094 interleave {
6095 [] rsl.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_RELEASE)) {
6096 f_logp("Got RSL RR Release");
6097 }
6098 [] rsl.receive(tr_RSL_DEACT_SACCH(g_chan_nr)) {
6099 f_logp("Got RSL Deact SACCH");
6100 }
6101 [] BSSAP.receive(tr_BSSMAP_ClearComplete) {
6102 f_logp("Got BSSMAP Clear Complete");
6103 /* Also drop the SCCP connection */
6104 BSSAP.send(RAN_Conn_Prim:MSC_CONN_PRIM_DISC_REQ);
6105 }
6106 [] rsl.receive(tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL)) {
6107 f_logp("Got RSL RF Chan Rel, sending Rel Ack");
6108 rsl.send(ts_RSL_RF_CHAN_REL_ACK(g_chan_nr));
6109 }
6110 }
6111}
6112
6113private function f_perform_compl_l3(RSL_DCHAN_PT rsl, template PDU_ML3_MS_NW l3_info, boolean do_clear := true)
6114runs on MSC_ConnHdlr {
6115 timer T := 10.0;
6116 var octetstring l3_enc := enc_PDU_ML3_MS_NW(valueof(l3_info));
6117
6118 f_logp("establish channel, send Complete Layer 3 Info");
6119 f_create_bssmap_exp(l3_enc);
6120
6121 /* RSL_Emulation.f_chan_est() on rsl:
6122 * This is basically code dup with s/RSL/rsl from:
6123 * RSL_Emulation.f_chan_est(g_pars.ra, l3_enc, g_pars.link_id, g_pars.fn);
6124 */
6125 var RSL_Message rx_rsl;
6126 var GsmRrMessage rr;
6127
6128 /* request a channel to be established */
6129 rsl.send(ts_RSLDC_ChanRqd(g_pars.ra, g_pars.fn));
6130 /* expect immediate assignment.
6131 * Code dup with s/RSL/rsl from:
6132 * rx_rsl := f_rx_or_fail(tr_RSL_IMM_ASSIGN);
6133 */
6134 timer Tt := 10.0;
6135
6136 /* request a channel to be established */
6137 Tt.start;
6138 alt {
6139 [] rsl.receive(tr_RSL_IMM_ASSIGN) -> value rx_rsl {
6140 Tt.stop;
6141 }
6142 [] rsl.receive {
6143 setverdict(fail, "Unexpected RSL message on DCHAN");
6144 mtc.stop;
6145 }
6146 [] Tt.timeout {
6147 setverdict(fail, "Timeout waiting for RSL on DCHAN");
6148 mtc.stop;
6149 }
6150 }
6151 rr := dec_GsmRrMessage(rx_rsl.ies[1].body.full_imm_ass_info.payload);
6152 g_chan_nr := rr.payload.imm_ass.chan_desc.chan_nr;
6153 rsl.send(ts_RSL_EST_IND(g_chan_nr, valueof(g_pars.link_id), l3_enc));
6154
6155
6156 f_logp("expect BSSAP Complete Layer 3 Info at MSC");
6157 var template PDU_BSSAP exp_l3_compl;
6158 exp_l3_compl := tr_BSSMAP_ComplL3()
6159 if (g_pars.aoip == false) {
6160 exp_l3_compl.pdu.bssmap.completeLayer3Information.codecList := omit;
6161 } else {
6162 exp_l3_compl.pdu.bssmap.completeLayer3Information.codecList := ?;
6163 }
6164
6165 var PDU_BSSAP bssap;
6166 T.start;
6167 alt {
6168 [] BSSAP.receive(exp_l3_compl) -> value bssap {
6169 f_logp("received expected Complete Layer 3 Info at MSC");
6170 log("rx exp_l3_compl = ", bssap);
6171 }
6172 [] BSSAP.receive(tr_BSSMAP_ComplL3) {
6173 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Received non-matching COMPLETE LAYER 3 INFORMATION");
6174 }
6175 [] T.timeout {
6176 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for COMPLETE LAYER 3 INFORMATION");
6177 }
6178 }
6179
6180 /* start ciphering, if requested */
6181 if (ispresent(g_pars.encr)) {
6182 f_logp("start ciphering");
6183 f_cipher_mode(g_pars.encr.enc_alg, g_pars.encr.enc_key);
6184 }
6185
6186 if (do_clear) {
6187 f_perform_clear(rsl);
6188 }
6189 setverdict(pass);
6190 f_sleep(1.0);
6191}
6192
6193private function f_tc_mscpool_compl_l3(charstring id) runs on MSC_ConnHdlr {
6194 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
6195 if (g_pars.mscpool.rsl_idx == 0) {
6196 f_perform_compl_l3(RSL, g_pars.mscpool.l3_info);
6197 } else if (g_pars.mscpool.rsl_idx == 1) {
6198 f_perform_compl_l3(RSL1, g_pars.mscpool.l3_info);
6199 } else if (g_pars.mscpool.rsl_idx == 2) {
6200 f_perform_compl_l3(RSL2, g_pars.mscpool.l3_info);
6201 }
6202}
6203
6204/* Various Complete Layer 3 by IMSI all end up with the first MSC, because the other MSCs are not connected. */
6205private function f_tc_mscpool_L3Compl_on_1_msc(charstring id) runs on MSC_ConnHdlr {
6206 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
6207 f_perform_compl_l3(RSL, ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_IMSI_LV('001010000000001'H)), '00F110'O) );
6208 f_perform_compl_l3(RSL, ts_CM_SERV_REQ(CM_TYPE_MO_SMS, valueof(ts_MI_IMSI_LV('001010000000002'H))) );
6209 f_perform_compl_l3(RSL, ts_PAG_RESP(valueof(ts_MI_IMSI_LV('001010000000003'H))) );
6210 f_perform_compl_l3(RSL, ts_ML3_MO_MM_IMSI_DET_Ind(valueof(ts_MI_IMSI_LV('001010000000004'H))) );
6211}
6212testcase TC_mscpool_L3Compl_on_1_msc() runs on test_CT {
6213
6214 f_init(1, true);
6215 f_sleep(1.0);
6216 var MSC_ConnHdlr vc_conn;
6217 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006218
6219 f_ctrs_msc_init();
6220
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006221 vc_conn := f_start_handler(refers(f_tc_mscpool_L3Compl_on_1_msc), pars);
6222 vc_conn.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006223
6224 f_ctrs_msc_expect(0, "mscpool:subscr:new", 4);
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006225 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006226}
6227
6228/* Three Layer 3 Complete by IMSI are round-robin'ed across two connected MSCs */
6229/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
6230 * just as well using only RSL. */
6231testcase TC_mscpool_L3Complete_by_imsi_round_robin() runs on test_CT {
6232
6233 f_init(nr_bts := 3, handler_mode := true, nr_msc := 2);
6234 f_sleep(1.0);
6235
6236 /* Control which MSC gets chosen next by the round-robin, otherwise
6237 * would be randomly affected by which other tests ran before this. */
6238 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
6239
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006240 f_ctrs_msc_init();
6241
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006242 var MSC_ConnHdlr vc_conn1;
6243 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
6244 pars1.mscpool.rsl_idx := 0;
6245 pars1.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_IMSI_LV('001010000000001'H)), '00F110'O));
6246 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6247 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006248 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006249
6250 var MSC_ConnHdlr vc_conn2;
6251 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 1);
6252 pars2.mscpool.rsl_idx := 1;
6253 pars2.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, valueof(ts_MI_IMSI_LV('001010000000002'H))));
6254 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6255 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006256 f_ctrs_msc_expect(1, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006257
6258 /* Test round-robin wrap to the first MSC */
6259 var MSC_ConnHdlr vc_conn3;
6260 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 0);
6261 pars3.mscpool.rsl_idx := 2;
6262 pars3.mscpool.l3_info := valueof(ts_PAG_RESP(valueof(ts_MI_IMSI_LV('001010000000003'H))));
6263 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
6264 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006265 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006266 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006267}
6268
6269/* Three LU by TMSI are round-robin'ed across two connected MSCs, because they contain the NULL-NRI 0
6270 * (configured in osmo-bsc.cfg). */
6271/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
6272 * just as well using only RSL. */
6273testcase TC_mscpool_LU_by_tmsi_null_nri_0_round_robin() runs on test_CT {
6274
6275 f_init(nr_bts := 3, handler_mode := true, nr_msc := 2);
6276 f_sleep(1.0);
6277
6278 /* Control which MSC gets chosen next by the round-robin, otherwise
6279 * would be randomly affected by which other tests ran before this. */
6280 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
6281
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006282 f_ctrs_msc_init();
6283
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006284 var MSC_ConnHdlr vc_conn1;
6285 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
6286 pars1.mscpool.rsl_idx := 0;
6287 pars1.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(0)), '00F110'O));
6288 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6289 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006290 f_ctrs_msc_expect(0, "mscpool:subscr:reattach");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006291
6292 var MSC_ConnHdlr vc_conn2;
6293 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 1);
6294 pars2.mscpool.rsl_idx := 1;
6295 pars2.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(0)), '00F110'O));
6296 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6297 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006298 f_ctrs_msc_expect(1, "mscpool:subscr:reattach");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006299
6300 /* Test round-robin wrap to the first MSC */
6301 var MSC_ConnHdlr vc_conn3;
6302 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 0);
6303 pars3.mscpool.rsl_idx := 2;
6304 pars3.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(0)), '00F110'O));
6305 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
6306 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006307 f_ctrs_msc_expect(0, "mscpool:subscr:reattach");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006308 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006309}
6310
6311/* Three LU by TMSI are round-robin'ed across two connected MSCs, because they contain the NULL-NRI 1
6312 * (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
6313 * NULL-NRI setting is stronger than that. */
6314/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
6315 * just as well using only RSL. */
6316testcase TC_mscpool_LU_by_tmsi_null_nri_1_round_robin() runs on test_CT {
6317
6318 f_init(nr_bts := 3, handler_mode := true, nr_msc := 2);
6319 f_sleep(1.0);
6320
6321 /* Control which MSC gets chosen next by the round-robin, otherwise
6322 * would be randomly affected by which other tests ran before this. */
6323 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
6324
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006325 f_ctrs_msc_init();
6326
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006327 var MSC_ConnHdlr vc_conn1;
6328 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
6329 pars1.mscpool.rsl_idx := 0;
6330 pars1.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(1)), '00F110'O));
6331 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6332 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006333 f_ctrs_msc_expect(0, "mscpool:subscr:reattach");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006334
6335 var MSC_ConnHdlr vc_conn2;
6336 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 1);
6337 pars2.mscpool.rsl_idx := 1;
6338 pars2.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(1)), '00F110'O));
6339 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6340 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006341 f_ctrs_msc_expect(1, "mscpool:subscr:reattach");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006342
6343 /* Test round-robin wrap to the first MSC */
6344 var MSC_ConnHdlr vc_conn3;
6345 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 0);
6346 pars3.mscpool.rsl_idx := 2;
6347 pars3.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(1)), '00F110'O));
6348 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
6349 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006350 f_ctrs_msc_expect(0, "mscpool:subscr:reattach");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006351 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006352}
6353
6354/* Three Layer 3 Complete by TMSI are round-robin'ed across two connected MSCs, because they contain an NRI not
6355 * assigned to any MSC (configured in osmo-bsc.cfg). */
6356/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
6357 * just as well using only RSL. */
6358testcase TC_mscpool_L3Complete_by_tmsi_unassigned_nri_round_robin() runs on test_CT {
6359
6360 f_init(nr_bts := 3, handler_mode := true, nr_msc := 2);
6361 f_sleep(1.0);
6362
6363 /* Control which MSC gets chosen next by the round-robin, otherwise
6364 * would be randomly affected by which other tests ran before this. */
6365 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
6366
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006367 f_ctrs_msc_init();
6368
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006369 var MSC_ConnHdlr vc_conn1;
6370 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
6371 pars1.mscpool.rsl_idx := 0;
6372 /* An NRI that is not assigned to any MSC */
6373 pars1.mscpool.l3_info := valueof(ts_ML3_MO_MM_IMSI_DET_Ind(valueof(ts_MI_TMSI_NRI_LV(1023))));
6374 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6375 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006376 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006377
6378 var MSC_ConnHdlr vc_conn2;
6379 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 1);
6380 pars2.mscpool.rsl_idx := 1;
6381 /* An NRI that is not assigned to any MSC */
6382 pars2.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(768)), '00F110'O));
6383 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6384 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006385 f_ctrs_msc_expect(1, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006386
6387 /* Test round-robin wrap to the first MSC */
6388 var MSC_ConnHdlr vc_conn3;
6389 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 0);
6390 pars3.mscpool.rsl_idx := 2;
6391 /* An NRI that is not assigned to any MSC */
6392 pars3.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_SS_ACT, valueof(ts_MI_TMSI_NRI_LV(819))));
6393 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
6394 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006395 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006396 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006397}
6398
6399/* Three Layer 3 Complete by TMSI are round-robin'ed across two connected MSCs, because they contain an NRI
6400 * assigned to an MSC that is currently not connected (configured in osmo-bsc.cfg). */
6401/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
6402 * just as well using only RSL. */
6403testcase TC_mscpool_L3Complete_by_tmsi_valid_nri_msc_not_connected_round_robin() runs on test_CT {
6404
6405 f_init(nr_bts := 3, handler_mode := true, nr_msc := 2);
6406 f_sleep(1.0);
6407
6408 /* Control which MSC gets chosen next by the round-robin, otherwise
6409 * would be randomly affected by which other tests ran before this. */
6410 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
6411
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006412 f_ctrs_msc_init();
6413
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006414 var MSC_ConnHdlr vc_conn1;
6415 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
6416 pars1.mscpool.rsl_idx := 0;
6417 /* An NRI that is assigned to an unconnected MSC */
6418 pars1.mscpool.l3_info := valueof(ts_PAG_RESP(valueof(ts_MI_TMSI_NRI_LV(512))));
6419 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6420 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006421 f_ctrs_msc_add(2, "mscpool:subscr:attach_lost");
6422 f_ctrs_msc_add(0, "mscpool:subscr:new");
6423 f_ctrs_msc_verify();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006424
6425 var MSC_ConnHdlr vc_conn2;
6426 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 1);
6427 pars2.mscpool.rsl_idx := 1;
6428 /* An NRI that is assigned to an unconnected MSC */
6429 pars2.mscpool.l3_info := valueof(ts_ML3_MO_MM_IMSI_DET_Ind(valueof(ts_MI_TMSI_NRI_LV(767))));
6430 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6431 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006432 f_ctrs_msc_add(2, "mscpool:subscr:attach_lost");
6433 f_ctrs_msc_add(1, "mscpool:subscr:new");
6434 f_ctrs_msc_verify();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006435
6436 /* Test round-robin wrap to the first MSC */
6437 var MSC_ConnHdlr vc_conn3;
6438 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 0);
6439 pars3.mscpool.rsl_idx := 2;
6440 /* An NRI that is assigned to an unconnected MSC */
6441 pars3.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(750)), '00F110'O));
6442 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
6443 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006444 f_ctrs_msc_add(2, "mscpool:subscr:attach_lost");
6445 f_ctrs_msc_add(0, "mscpool:subscr:new");
6446 f_ctrs_msc_verify();
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006447 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006448}
6449
6450/* Three Layer 3 Complete by TMSI with valid NRI for the second MSC are all directed to the second MSC (configured in
6451 * osmo-bsc.cfg). */
6452/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
6453 * just as well using only RSL. */
6454testcase TC_mscpool_L3Complete_by_tmsi_valid_nri_1() runs on test_CT {
6455
6456 f_init(nr_bts := 3, handler_mode := true, nr_msc := 2);
6457 f_sleep(1.0);
6458
6459 /* All TMSIs in this test point at the second MSC, set the round robin to point at the first MSC to make sure
6460 * this is not using round-robin. */
6461 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
6462
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006463 f_ctrs_msc_init();
6464
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006465 var MSC_ConnHdlr vc_conn1;
6466 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 1);
6467 pars1.mscpool.rsl_idx := 0;
6468 /* An NRI of the second MSC's range (256-511) */
6469 pars1.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_SMS, valueof(ts_MI_TMSI_NRI_LV(256))));
6470 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6471 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006472 f_ctrs_msc_expect(1, "mscpool:subscr:known");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006473
6474 var MSC_ConnHdlr vc_conn2;
6475 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 1);
6476 pars2.mscpool.rsl_idx := 1;
6477 /* An NRI of the second MSC's range (256-511) */
6478 pars2.mscpool.l3_info := valueof(ts_PAG_RESP(valueof(ts_MI_TMSI_NRI_LV(260))));
6479 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6480 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006481 f_ctrs_msc_expect(1, "mscpool:subscr:known");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006482
6483 var MSC_ConnHdlr vc_conn3;
6484 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 1);
6485 pars3.mscpool.rsl_idx := 2;
6486 /* An NRI of the second MSC's range (256-511) */
6487 pars3.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(511)), '00F110'O));
6488 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
6489 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006490 f_ctrs_msc_expect(1, "mscpool:subscr:known");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006491 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006492}
6493
6494/* Layer 3 Complete by TMSI with valid NRI for the third MSC are directed to the third MSC (configured in osmo-bsc.cfg),
6495 * while a round-robin remains unaffected by that. */
6496/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
6497 * just as well using only RSL. */
6498testcase TC_mscpool_L3Complete_by_tmsi_valid_nri_2() runs on test_CT {
6499
6500 f_init(nr_bts := 3, handler_mode := true, nr_msc := 3);
6501 f_sleep(1.0);
6502
6503 /* All TMSIs in this test point at the third MSC, set the round robin to point at the second MSC to make sure
6504 * this is not using round-robin. */
6505 f_vty_transceive(BSCVTY, "mscpool roundrobin next 1");
6506
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006507 f_ctrs_msc_init();
6508
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006509 var MSC_ConnHdlr vc_conn1;
6510 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 2);
6511 pars1.mscpool.rsl_idx := 0;
6512 /* An NRI of the third MSC's range (512-767) */
6513 pars1.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_SMS, valueof(ts_MI_TMSI_NRI_LV(512))));
6514 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6515 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006516 f_ctrs_msc_expect(2, "mscpool:subscr:known");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006517
6518 var MSC_ConnHdlr vc_conn2;
6519 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 2);
6520 pars2.mscpool.rsl_idx := 1;
6521 /* An NRI of the third MSC's range (512-767) */
6522 pars2.mscpool.l3_info := valueof(ts_PAG_RESP(valueof(ts_MI_TMSI_NRI_LV(678))));
6523 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6524 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006525 f_ctrs_msc_expect(2, "mscpool:subscr:known");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006526
6527 /* The above forwardings to third MSC have not affected the round robin, which still points at the second MSC */
6528 var MSC_ConnHdlr vc_conn3;
6529 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 1);
6530 pars3.mscpool.rsl_idx := 2;
6531 pars3.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_IMSI_LV('001010000000013'H)), '00F110'O));
6532 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
6533 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006534 f_ctrs_msc_expect(1, "mscpool:subscr:new");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006535 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006536}
6537
6538/* LU with a TMSI but indicating a different PLMN in its previous LAI: ignore the NRI. */
6539/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
6540 * just as well using only RSL. */
6541testcase TC_mscpool_LU_by_tmsi_from_other_PLMN() runs on test_CT {
6542
6543 f_init(nr_bts := 3, handler_mode := true, nr_msc := 3);
6544 f_sleep(1.0);
6545
6546 /* The TMSIs in this test points at the second MSC, but since it is from a different PLMN, round-robin is used
6547 * instead, and hits msc 0. */
6548 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
6549
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006550 f_ctrs_msc_init();
6551
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006552 /* An NRI of the second MSC's range (256-511), but a PLMN that doesn't match with osmo-bsc.cfg */
6553 var MSC_ConnHdlr vc_conn1;
6554 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
6555 pars1.mscpool.rsl_idx := 0;
6556 pars1.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(260)), '99F999'O));
6557 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6558 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006559 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006560
6561 /* An NRI of the third MSC's range (512-767) and a matching PLMN gets directed by NRI. */
6562 var MSC_ConnHdlr vc_conn2;
6563 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 2);
6564 pars2.mscpool.rsl_idx := 1;
6565 pars2.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(555)), '00F110'O));
6566 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6567 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006568 f_ctrs_msc_expect(2, "mscpool:subscr:known");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006569 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006570}
6571
6572/* Make sure that whichever MSC paged a subscriber will also get the Paging Response. Page by IMSI, which would be
6573 * round-robined to another MSC, to make sure the Paging->Response relation is stronger than the NRI->MSC mapping. */
6574private function f_tc_mscpool_paging_imsi(charstring id) runs on MSC_ConnHdlr {
6575 var template BSSMAP_FIELD_CellIdentificationList cid_list := { cIl_CI := { ts_BSSMAP_CI_CI(0) } };
6576 //cid_list := { cIl_allInBSS := ''O };
6577 var RSL_ChanNeeded rsl_chneed := RSL_CHANNEED_SDCCH;
6578 var template BSSMAP_IE_ChannelNeeded bssmap_chneed := ts_BSSMAP_IE_ChanNeeded(int2bit(enum2int(valueof(rsl_chneed)),2));
6579 var BSSAP_N_UNITDATA_req paging;
6580 var hexstring imsi := '001010000000123'H;
6581
6582 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
6583
Neels Hofmeyr90f80962020-06-12 16:16:55 +02006584 paging := valueof(ts_BSSAP_UNITDATA_req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006585 valueof(ts_BSSMAP_Paging(imsi, cid_list, omit, bssmap_chneed))));
6586 BSSAP.send(paging);
6587
6588 /* Register any RSL conn so that the Paging Command gets received here. With the current RSL_Emulation's main()
6589 * handling of '[bts_role] IPA_PT.receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD()))' it doesn't matter at all which
6590 * channel number is picked here. */
6591 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(0, RSL_CHAN_NR_INVALID));
6592 f_rslem_register(0, new_chan_nr);
6593 RSL.receive(tr_RSL_PAGING_CMD(tr_MI_IMSI(imsi)));
6594 f_rslem_unregister(0, new_chan_nr);
6595
6596 /* Despite the round robin pointing at the second MSC ('roundrobin next 1'), the earlier Paging for the same IMSI
6597 * causes this Paging Response to go to the first MSC (bssap_idx := 0). */
6598 f_perform_compl_l3(RSL, ts_PAG_RESP(valueof(ts_MI_IMSI_LV(imsi))) );
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006599 f_sleep(1.0);
6600}
6601testcase TC_mscpool_paging_and_response_imsi() runs on test_CT {
6602 f_init(nr_bts := 1, handler_mode := true, nr_msc := 3);
6603 f_sleep(1.0);
6604
6605 /* Testing a Paging on the first MSC to get a Paging Response back to the first MSC. Set round robin to the
6606 * second MSC to make sure we're getting the Paging logic, not a coincidental round robin match. */
6607 f_vty_transceive(BSCVTY, "mscpool roundrobin next 1");
6608
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006609 f_ctrs_msc_init();
6610
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006611 var MSC_ConnHdlr vc_conn1;
6612 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
6613 pars1.mscpool.rsl_idx := 0;
Neels Hofmeyr90f80962020-06-12 16:16:55 +02006614 pars1.sccp_addr_bsc := g_bssap[pars1.mscpool.bssap_idx].sccp_addr_peer;
6615 pars1.sccp_addr_msc := g_bssap[pars1.mscpool.bssap_idx].sccp_addr_own;
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006616 vc_conn1 := f_start_handler(refers(f_tc_mscpool_paging_imsi), pars1);
6617 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006618 f_ctrs_msc_expect(0, "mscpool:subscr:paged");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006619 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006620}
6621
6622/* Make sure that whichever MSC paged a subscriber will also get the Paging Response. Page by TMSI with an NRI value
6623 * that matches a different MSC, to make sure the Paging->Response relation is stronger than the NRI->MSC mapping. */
6624private function f_tc_mscpool_paging_tmsi(charstring id) runs on MSC_ConnHdlr {
6625 var template BSSMAP_FIELD_CellIdentificationList cid_list := { cIl_CI := { ts_BSSMAP_CI_CI(0) } };
6626 //cid_list := { cIl_allInBSS := ''O };
6627 var RSL_ChanNeeded rsl_chneed := RSL_CHANNEED_SDCCH;
6628 var template BSSMAP_IE_ChannelNeeded bssmap_chneed := ts_BSSMAP_IE_ChanNeeded(int2bit(enum2int(valueof(rsl_chneed)),2));
6629 var integer nri_v := 300; /* <-- second MSC's NRI */
6630 var octetstring tmsi := f_tmsi_nri(nri_v);
6631 var BSSAP_N_UNITDATA_req paging;
6632
6633 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
6634
Neels Hofmeyr90f80962020-06-12 16:16:55 +02006635 paging := valueof(ts_BSSAP_UNITDATA_req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006636 valueof(ts_BSSMAP_Paging('001010000000011'H, cid_list, tmsi, bssmap_chneed))));
6637 BSSAP.send(paging);
6638
6639 /* Register any RSL conn so that the Paging Command gets received here. With the current RSL_Emulation's main()
6640 * handling of '[bts_role] IPA_PT.receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD()))' it doesn't matter at all which
6641 * channel number is picked here. */
6642 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(0, RSL_CHAN_NR_INVALID));
6643 f_rslem_register(0, new_chan_nr);
6644 RSL.receive(tr_RSL_PAGING_CMD(t_MI_TMSI(tmsi)));
6645 f_rslem_unregister(0, new_chan_nr);
6646
6647 /* Despite the NRI matching the second MSC (NRI from 'msc 1' in osmo-bsc.cfg) and round robin pointing at the
6648 * third MSC ('roundrobin next 2'), the earlier Paging for the same TMSI causes this Paging Response to go to
6649 * the first MSC (bssap_idx := 0). */
6650 f_perform_compl_l3(RSL, ts_PAG_RESP(valueof(ts_MI_TMSI_NRI_LV(nri_v))) );
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006651 f_sleep(1.0);
6652}
6653testcase TC_mscpool_paging_and_response_tmsi() runs on test_CT {
6654 f_init(nr_bts := 1, handler_mode := true, nr_msc := 3);
6655 f_sleep(1.0);
6656
6657 /* Testing a Paging on the first MSC to get a Paging Response back to the first MSC. Set round robin to the
6658 * third MSC to make sure we're getting the Paging logic, not a coincidental round robin match. */
6659 f_vty_transceive(BSCVTY, "mscpool roundrobin next 2");
6660
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006661 f_ctrs_msc_init();
6662
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006663 var MSC_ConnHdlr vc_conn1;
6664 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
6665 pars1.mscpool.rsl_idx := 0;
Neels Hofmeyr90f80962020-06-12 16:16:55 +02006666 pars1.sccp_addr_bsc := g_bssap[pars1.mscpool.bssap_idx].sccp_addr_peer;
6667 pars1.sccp_addr_msc := g_bssap[pars1.mscpool.bssap_idx].sccp_addr_own;
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006668 vc_conn1 := f_start_handler(refers(f_tc_mscpool_paging_tmsi), pars1);
6669 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006670 f_ctrs_msc_expect(0, "mscpool:subscr:paged");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006671 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006672}
6673
6674/* For round-robin, skip an MSC that has 'no allow-attach' set. */
6675/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
6676 * just as well using only RSL. */
6677testcase TC_mscpool_no_allow_attach_round_robin() runs on test_CT {
6678
6679 f_init(nr_bts := 3, handler_mode := true, nr_msc := 3);
6680 f_sleep(1.0);
Neels Hofmeyra460f1f2020-08-09 20:17:03 +00006681 /* Mark the second MSC as offloading, round-robin should skip this MSC now. */
6682 f_vty_msc_allow_attach(BSCVTY, {true, false, true});
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006683
6684 /* Control which MSC gets chosen next by the round-robin, otherwise
6685 * would be randomly affected by which other tests ran before this. */
6686 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
6687
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006688 f_ctrs_msc_init();
6689
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006690 var MSC_ConnHdlr vc_conn1;
6691 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
6692 pars1.mscpool.rsl_idx := 0;
6693 pars1.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_IMSI_LV('001010000000001'H)), '00F110'O));
6694 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6695 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006696 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006697
6698 var MSC_ConnHdlr vc_conn2;
6699 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 2);
6700 pars2.mscpool.rsl_idx := 1;
6701 pars2.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, valueof(ts_MI_IMSI_LV('001010000000002'H))));
6702 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6703 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006704 f_ctrs_msc_expect(2, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006705
6706 var MSC_ConnHdlr vc_conn3;
6707 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 0);
6708 pars3.mscpool.rsl_idx := 2;
6709 pars3.mscpool.l3_info := valueof(ts_PAG_RESP(valueof(ts_MI_IMSI_LV('001010000000003'H))));
6710 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
6711 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006712 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006713 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006714}
6715
6716/* An MSC that has 'no allow-attach' set should still serve subscribers that are already attached according to their
6717 * TMSI NRI. */
6718testcase TC_mscpool_no_allow_attach_valid_nri() runs on test_CT {
6719
6720 f_init(nr_bts := 3, handler_mode := true, nr_msc := 3);
6721 f_sleep(1.0);
6722
Neels Hofmeyra460f1f2020-08-09 20:17:03 +00006723 /* Mark the second MSC as offloading, round-robin should skip this MSC now. */
6724 f_vty_msc_allow_attach(BSCVTY, {true, false, true});
6725
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006726 /* Control which MSC gets chosen next by the round-robin, otherwise
6727 * would be randomly affected by which other tests ran before this. */
6728 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
6729
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006730 f_ctrs_msc_init();
6731
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006732 /* Round robin points at msc 0, but the valid NRI directs to msc 1, even though msc 1 has 'no allow-attach'. */
6733 var MSC_ConnHdlr vc_conn1;
6734 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 1);
6735 pars1.mscpool.rsl_idx := 0;
6736 /* An NRI of the second MSC's range (256-511) */
6737 pars1.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, valueof(ts_MI_TMSI_NRI_LV(260))));
6738 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6739 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006740 f_ctrs_msc_expect(1, "mscpool:subscr:known");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006741
6742 var MSC_ConnHdlr vc_conn2;
6743 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 0);
6744 pars2.mscpool.rsl_idx := 1;
6745 pars2.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, valueof(ts_MI_IMSI_LV('001010000000002'H))));
6746 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6747 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006748 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006749
6750 var MSC_ConnHdlr vc_conn3;
6751 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 2);
6752 pars3.mscpool.rsl_idx := 2;
6753 pars3.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, valueof(ts_MI_IMSI_LV('001010000000003'H))));
6754 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
6755 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006756 f_ctrs_msc_expect(2, "mscpool:subscr:new");
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006757 f_shutdown_helper();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006758}
6759
Philipp Maier783681c2020-07-16 16:47:06 +02006760/* Allow/Deny emergency calls globally via VTY */
6761private function f_vty_allow_emerg_msc(boolean allow) runs on test_CT {
6762 f_vty_enter_cfg_msc(BSCVTY, 0);
6763 if (allow) {
6764 f_vty_transceive(BSCVTY, "allow-emergency allow");
6765 } else {
6766 f_vty_transceive(BSCVTY, "allow-emergency deny");
6767 }
6768 f_vty_transceive(BSCVTY, "exit");
6769 f_vty_transceive(BSCVTY, "exit");
6770}
6771
6772/* Allow/Deny emergency calls per BTS via VTY */
6773private function f_vty_allow_emerg_bts(boolean allow, integer bts_nr) runs on test_CT {
6774 f_vty_enter_cfg_bts(BSCVTY, bts_nr);
6775 if (allow) {
6776 f_vty_transceive(BSCVTY, "rach emergency call allowed 1");
6777 } else {
6778 f_vty_transceive(BSCVTY, "rach emergency call allowed 0");
6779 }
6780 f_vty_transceive(BSCVTY, "exit");
6781 f_vty_transceive(BSCVTY, "exit");
6782}
6783
6784/* Begin assignmet procedure and send an EMERGENCY SETUP (RR) */
6785private function f_assignment_emerg_setup() runs on MSC_ConnHdlr {
6786 var PDU_ML3_MS_NW emerg_setup;
6787 var octetstring emerg_setup_enc;
6788 var RSL_Message emerg_setup_data_ind;
6789
6790 f_establish_fully(omit, omit);
6791
6792 emerg_setup := valueof(ts_ML3_MO_CC_EMERG_SETUP(1, valueof(ts_Bcap_voice)));
6793 emerg_setup_enc := enc_PDU_ML3_MS_NW(emerg_setup);
6794 emerg_setup_data_ind := valueof(ts_RSL_DATA_IND(g_chan_nr, valueof(ts_RslLinkID_DCCH(0)), emerg_setup_enc));
6795
6796 RSL.send(emerg_setup_data_ind);
6797}
6798
6799/* Test if the EMERGENCY SETUP gets passed on to the MSC via A when EMERGENCY
6800 * CALLS are permitted by the BSC config. */
6801private function f_TC_assignment_emerg_setup_allow(charstring id) runs on MSC_ConnHdlr {
6802 var PDU_BSSAP emerg_setup_data_ind_bssap;
6803 var PDU_ML3_MS_NW emerg_setup;
6804 timer T := 3.0;
6805
6806 f_assignment_emerg_setup()
6807
6808 T.start;
6809 alt {
6810 [] BSSAP.receive(tr_BSSAP_DTAP) -> value emerg_setup_data_ind_bssap {
6811 emerg_setup := dec_PDU_ML3_MS_NW(emerg_setup_data_ind_bssap.pdu.dtap);
6812 if (not isbound(emerg_setup.msgs.cc.emergencySetup)) {
6813 setverdict(fail, "no emergency setup");
6814 }
6815 }
6816 [] BSSAP.receive {
6817 setverdict(fail, "unexpected BSSAP message!");
6818 }
6819 [] T.timeout {
6820 setverdict(fail, "timout waiting for EMERGENCY SETUP!");
6821 }
6822 }
6823
6824 setverdict(pass);
6825}
6826
6827/* Test if the EMERGENCY SETUP gets blocked by the BSC if EMERGENCY CALLS are
6828 * forbidden by the BSC config. */
6829private function f_TC_assignment_emerg_setup_deny(charstring id) runs on MSC_ConnHdlr {
6830 var PDU_BSSAP emerg_setup_data_ind_bssap;
6831 timer T := 3.0;
6832
6833 f_assignment_emerg_setup()
6834
6835 T.start;
6836 alt {
6837 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_RELEASE)) {
6838 setverdict(pass);
6839 }
6840 [] RSL.receive {
6841 setverdict(fail, "unexpected RSL message!");
6842 }
6843 [] T.timeout {
6844 setverdict(fail, "timout waiting for RR CHANNEL RELEASE!");
6845 }
6846 }
6847}
6848
6849/* EMERGENCY CALL situation #1, allowed globally and by BTS */
6850testcase TC_assignment_emerg_setup_allow() runs on test_CT {
6851 var TestHdlrParams pars := f_gen_test_hdlr_pars();
6852 var MSC_ConnHdlr vc_conn;
6853
6854 f_init(1, true);
6855 f_sleep(1.0);
6856
6857 f_vty_allow_emerg_msc(true);
6858 f_vty_allow_emerg_bts(true, 0);
6859 vc_conn := f_start_handler(refers(f_TC_assignment_emerg_setup_allow), pars);
6860 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006861 f_shutdown_helper();
Philipp Maier783681c2020-07-16 16:47:06 +02006862}
6863
6864/* EMERGENCY CALL situation #2, forbidden globally but allowed by BTS */
6865testcase TC_assignment_emerg_setup_deny_msc() runs on test_CT {
6866 var TestHdlrParams pars := f_gen_test_hdlr_pars();
6867 var MSC_ConnHdlr vc_conn;
6868
6869 f_init(1, true);
6870 f_sleep(1.0);
6871
6872 f_vty_allow_emerg_msc(false);
6873 f_vty_allow_emerg_bts(true, 0);
6874 vc_conn := f_start_handler(refers(f_TC_assignment_emerg_setup_deny), pars);
6875 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006876 f_shutdown_helper();
Philipp Maier783681c2020-07-16 16:47:06 +02006877}
6878
6879/* EMERGENCY CALL situation #3, allowed globally but forbidden by BTS */
6880testcase TC_assignment_emerg_setup_deny_bts() runs on test_CT {
6881 var TestHdlrParams pars := f_gen_test_hdlr_pars();
6882 var MSC_ConnHdlr vc_conn;
6883
6884 /* Note: This simulates a spec violation by the MS, correct MS
6885 * implementations would not try to establish an emergency call because
6886 * the system information tells in advance that emergency calls are
6887 * not forbidden */
6888
6889 f_init(1, true);
6890 f_sleep(1.0);
6891
6892 f_vty_allow_emerg_msc(true);
6893 f_vty_allow_emerg_bts(false, 0);
6894 vc_conn := f_start_handler(refers(f_TC_assignment_emerg_setup_deny), pars);
6895 vc_conn.done;
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006896 f_shutdown_helper();
Philipp Maier783681c2020-07-16 16:47:06 +02006897}
6898
Philipp Maier82812002020-08-13 18:48:27 +02006899/* Test what happens when an emergency call arrives while all TCH channels are
6900 * busy, the BSC is expected to terminate one call in favor of the incoming
6901 * emergency call */
6902testcase TC_emerg_premption() runs on test_CT {
6903 var ASP_RSL_Unitdata rsl_ud;
6904 var integer i;
6905 var integer chreq_total, chreq_nochan;
6906 var RSL_Message rx_rsl;
6907 var RslChannelNr chan_nr;
6908
6909 f_init(1);
6910 f_sleep(1.0);
6911
6912 f_vty_allow_emerg_msc(true);
6913 f_vty_allow_emerg_bts(true, 0);
6914
6915 /* Fill up all channels on the BTS */
6916 chreq_total := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total");
6917 chreq_nochan := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:no_channel");
6918 for (i := 0; i < NUM_TCHF_PER_BTS + NUM_TCHH_PER_BTS + NUM_SDCCH_PER_BTS; i := i+1) {
6919 chan_nr := f_chreq_act_ack('33'O, i);
6920 }
6921 IPA_RSL[0].clear;
6922 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total",
6923 chreq_total + NUM_TCHF_PER_BTS + NUM_TCHH_PER_BTS + NUM_SDCCH_PER_BTS);
6924
6925 /* Send Channel request for emegergency call */
6926 f_ipa_tx(0, ts_RSL_CHAN_RQD('A5'O, 23));
6927
6928 /* Expect the BSC to release one (the first) TCH/F on the BTS */
6929 chan_nr := valueof(t_RslChanNr_Bm(1));
6930 f_expect_chan_rel(0, chan_nr, expect_rr_chan_rel := false, expect_rll_rel_req := false);
6931
6932 /* Expect the BSC to send activate/assign the a channel for the emergency call */
6933 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
6934 chan_nr := rx_rsl.ies[0].body.chan_nr;
6935 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, 33));
6936 rx_rsl := f_exp_ipa_rx(0, tr_RSL_IMM_ASSIGN(0));
Philipp Maier104f4c02020-09-11 18:12:18 +02006937
Pau Espin Pedrol6ed083c2020-09-23 14:16:58 +02006938 f_shutdown_helper();
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07006939}
6940
6941/* Hopping parameters per a timeslot */
Vadim Yanitskiybc6654a2020-09-13 01:27:40 +07006942private type record length(0..64) of GsmArfcn ArfcnList;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07006943private type record FHParamsTs {
6944 boolean enabled,
6945 uint6_t hsn,
6946 uint6_t maio,
6947 ArfcnList ma
6948};
6949
6950/* Hopping parameters per a transceiver */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07006951private type record FHParamsTrx {
6952 GsmArfcn arfcn,
6953 FHParamsTs ts[8]
6954};
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07006955
6956/* Randomly generate the hopping parameters for the given timeslot numbers */
6957private function f_TC_fh_params_gen(template integer tr_tn := (1, 3, 5))
6958runs on test_CT return FHParamsTrx {
6959 var FHParamsTrx fhp;
6960
Vadim Yanitskiy3e997362020-09-05 21:08:34 +07006961 /* Generate a random ARFCN, including ARFCN 0 */
6962 fhp.arfcn := f_rnd_int(3);
Vadim Yanitskiye7c8c6e2020-09-13 14:33:03 +07006963
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07006964 for (var integer tn := 0; tn < 8; tn := tn + 1) {
6965 if (not match(tn, tr_tn)) {
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07006966 fhp.ts[tn].enabled := false;
6967 fhp.ts[tn].ma := { };
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07006968 continue;
6969 }
6970
6971 /* Random HSN / MAIO values: 0..63 */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07006972 fhp.ts[tn].hsn := f_rnd_int(64);
6973 fhp.ts[tn].maio := f_rnd_int(64);
6974 fhp.ts[tn].ma := { };
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07006975
6976 /* Random Mobile Allocation (hopping channels) */
6977 var integer ma_len := 2 + f_rnd_int(9); /* 2..10 channels */
6978 var integer step := 3 + f_rnd_int(4); /* 3..6 stepping */
6979 for (var integer i := 1; i <= ma_len; i := i + 1) {
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07006980 fhp.ts[tn].ma := fhp.ts[tn].ma & { i * step };
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07006981 }
6982
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07006983 fhp.ts[tn].enabled := true;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07006984 }
6985
6986 log("f_TC_fh_params_gen(): ", fhp);
6987 return fhp;
6988}
6989
6990/* Make sure that the given Channel Description IE matches the hopping configuration */
6991private function f_TC_fh_params_match_chan_desc(in FHParamsTrx fhp, in ChannelDescription cd)
6992{
6993 var template (present) ChannelDescription tr_cd;
6994 var template (present) MaioHsn tr_maio_hsn;
6995 var uint3_t tn := cd.chan_nr.tn;
6996
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07006997 if (fhp.ts[tn].enabled) {
6998 tr_maio_hsn := tr_HsnMaio(fhp.ts[tn].hsn, fhp.ts[tn].maio);
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07006999 tr_cd := tr_ChanDescH1(cd.chan_nr, tr_maio_hsn);
7000 } else {
Vadim Yanitskiye7c8c6e2020-09-13 14:33:03 +07007001 tr_cd := tr_ChanDescH0(cd.chan_nr, fhp.arfcn);
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007002 }
7003
7004 if (not match(cd, tr_cd)) {
7005 setverdict(fail, "Channel Description IE does not match: ",
7006 cd, " vs expected ", tr_cd);
7007 }
7008}
7009
7010/* Make sure that the given Mobile Allocation IE matches the hopping configuration */
7011private function f_TC_fh_params_match_ma(in FHParamsTrx fhp, uint3_t tn,
7012 in MobileAllocationLV ma)
7013{
7014 var template MobileAllocationLV tr_ma := f_TC_fh_params_gen_tr_ma(fhp, tn, ma);
7015
7016 if (not match(ma, tr_ma)) {
7017 setverdict(fail, "Mobile Allocation IE does not match (tn := ",
7018 tn, "): ", ma, " vs expected: ", tr_ma);
7019 } else {
7020 setverdict(pass);
7021 }
7022}
7023
7024private function f_TC_fh_params_gen_tr_ma(in FHParamsTrx fhp, uint3_t tn,
7025 in MobileAllocationLV ma)
7026return template MobileAllocationLV {
7027 /* Mobile Allocation IE is expected to be empty if hopping is not enabled */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007028 if (not fhp.ts[tn].enabled) {
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007029 return { len := 0, ma := ''B };
7030 }
7031
7032 var bitstring full_mask := f_pad_bit(''B, 1024, '0'B);
7033 var bitstring slot_mask := f_pad_bit(''B, 1024, '0'B);
7034 var bitstring ma_mask := ''B;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007035
7036 /* Compose the full bit-mask (all channels, up to 1024 entries) */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007037 for (var integer i := 0; i < lengthof(fhp.ts); i := i + 1) {
7038 for (var integer j := 0; j < lengthof(fhp.ts[i].ma); j := j + 1) {
7039 if (full_mask[fhp.ts[i].ma[j]] == '1'B)
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007040 { continue; }
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007041 full_mask[fhp.ts[i].ma[j]] := '1'B;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007042 }
7043 }
7044
Vadim Yanitskiye7c8c6e2020-09-13 14:33:03 +07007045 /* Take ARFCN of the TRX itself into account */
7046 full_mask[fhp.arfcn] := '1'B;
7047
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007048 /* Compose a bit-mask for the given timeslot number */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007049 for (var integer i := 0; i < lengthof(fhp.ts[tn].ma); i := i + 1) {
7050 slot_mask[fhp.ts[tn].ma[i]] := '1'B;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007051 }
7052
7053 /* Finally, compose the Mobile Allocation bit-mask */
Vadim Yanitskiy3e997362020-09-05 21:08:34 +07007054 for (var integer i := 1; i < lengthof(full_mask); i := i + 1) {
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007055 if (full_mask[i] != '1'B)
7056 { continue; }
7057
7058 /* FIXME: ma_mask := ma_mask & slot_mask[i]; // triggers a bug in TITAN */
7059 if (slot_mask[i] == '1'B) {
7060 ma_mask := ma_mask & '1'B;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007061 } else {
7062 ma_mask := ma_mask & '0'B;
7063 }
7064 }
7065
Vadim Yanitskiy3e997362020-09-05 21:08:34 +07007066 /* ARFCN 0 (if present) goes to the last position of the bit-mask */
7067 if (full_mask[0] == '1'B) {
7068 /* FIXME: ma_mask := ma_mask & slot_mask[0]; // triggers a bug in TITAN */
7069 if (slot_mask[0] == '1'B) {
7070 ma_mask := ma_mask & '1'B;
7071 } else {
7072 ma_mask := ma_mask & '0'B;
7073 }
7074 }
7075
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007076 /* Ensure that ma_mask is octet-aligned */
Vadim Yanitskiy2aa02522020-09-06 14:05:23 +07007077 var integer ma_mask_len := (lengthof(ma_mask) + 8 - 1) / 8;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007078 ma_mask := f_pad_bit(ma_mask, ma_mask_len * 8, '0'B);
7079
7080 return { len := ma_mask_len, ma := ma_mask };
7081}
7082
7083/* Configure the hopping parameters in accordance with the given record */
7084private function f_TC_fh_params_set(in FHParamsTrx fhp,
7085 uint8_t bts_nr := 0,
7086 uint8_t trx_nr := 0)
7087runs on test_CT {
7088 /* Enter the configuration node for the given BTS/TRX numbers */
7089 f_vty_enter_cfg_trx(BSCVTY, bts_nr, trx_nr);
7090
Vadim Yanitskiye7c8c6e2020-09-13 14:33:03 +07007091 f_vty_transceive(BSCVTY, "arfcn " & int2str(fhp.arfcn));
7092
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007093 for (var integer tn := 0; tn < lengthof(fhp.ts); tn := tn + 1) {
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007094 f_vty_transceive(BSCVTY, "timeslot " & int2str(tn));
7095
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007096 if (not fhp.ts[tn].enabled) {
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007097 f_vty_transceive(BSCVTY, "hopping enabled 0");
7098 f_vty_transceive(BSCVTY, "exit"); /* go back */
7099 continue;
7100 }
7101
7102 /* Configure HSN / MAIO values */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007103 f_vty_transceive(BSCVTY, "hopping sequence-number " & int2str(fhp.ts[tn].hsn));
7104 f_vty_transceive(BSCVTY, "hopping maio " & int2str(fhp.ts[tn].maio));
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007105
7106 /* Configure the Mobile Allocation (hopping channels) */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007107 for (var integer i := 0; i < lengthof(fhp.ts[tn].ma); i := i + 1) {
7108 f_vty_transceive(BSCVTY, "hopping arfcn add " & int2str(fhp.ts[tn].ma[i]));
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007109 }
7110
7111 f_vty_transceive(BSCVTY, "hopping enabled 1");
7112 f_vty_transceive(BSCVTY, "exit"); /* go back */
7113 }
7114
7115 f_vty_transceive(BSCVTY, "end");
7116}
7117
7118/* Disable frequency hopping on all timeslots */
7119private function f_TC_fh_params_unset(in FHParamsTrx fhp,
7120 uint8_t bts_nr := 0,
Vadim Yanitskiye7c8c6e2020-09-13 14:33:03 +07007121 uint8_t trx_nr := 0,
7122 GsmArfcn arfcn := 871)
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007123runs on test_CT {
7124 /* Enter the configuration node for the given BTS/TRX numbers */
7125 f_vty_enter_cfg_trx(BSCVTY, bts_nr, trx_nr);
7126
Vadim Yanitskiye7c8c6e2020-09-13 14:33:03 +07007127 f_vty_transceive(BSCVTY, "arfcn " & int2str(arfcn));
7128
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007129 for (var integer tn := 0; tn < lengthof(fhp.ts); tn := tn + 1) {
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007130 f_vty_transceive(BSCVTY, "timeslot " & int2str(tn));
7131
7132 /* Delete all ARFCNs from the Mobile Allocation (if any) */
Vadim Yanitskiy1b996612020-09-13 13:22:34 +07007133 for (var integer i := 0; i < lengthof(fhp.ts[tn].ma); i := i + 1) {
7134 f_vty_transceive(BSCVTY, "hopping arfcn del " & int2str(fhp.ts[tn].ma[i]));
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007135 }
7136
7137 f_vty_transceive(BSCVTY, "hopping enabled 0");
7138 f_vty_transceive(BSCVTY, "exit"); /* go back */
7139 }
7140
7141 f_vty_transceive(BSCVTY, "end");
7142 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
7143}
7144
7145/* Verify presence and correctness of the hopping parameters (HSN, MAIO)
7146 * in the Channel Identification IE of the RSL CHANnel ACTIVation message. */
7147testcase TC_fh_params_chan_activ() runs on test_CT {
7148 var FHParamsTrx fhp := f_TC_fh_params_gen();
7149 var RSL_Message rsl_msg;
7150 var RSL_IE_Body ie;
7151
7152 f_init_vty();
7153
7154 f_TC_fh_params_set(fhp); /* Enable frequency hopping */
7155 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
7156
7157 f_init(1);
7158
7159 /* CS domain: 3 (SDCCH/4+CBCH) + 4 (TCH/F) + 2 (TCH/H) channels available */
7160 for (var integer i := 0; i < 9; i := i + 1) {
7161 f_ipa_tx(0, ts_RSL_CHAN_RQD(f_rnd_ra_cs(), 23));
7162 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
7163
7164 /* Make sure that Channel Identification IE is present */
7165 if (not f_rsl_find_ie(rsl_msg, RSL_IE_CHAN_IDENT, ie)) {
7166 setverdict(fail, "RSL Channel Identification IE is absent");
7167 continue;
7168 }
7169
7170 /* Make sure that hopping parameters (HSN/MAIO) match */
7171 f_TC_fh_params_match_chan_desc(fhp, ie.chan_ident.ch_desc.v);
7172
7173 /* "Mobile Allocation shall be included but empty" - let's check this */
7174 if (ie.chan_ident.ma.v.len != 0) {
7175 setverdict(fail, "Mobile Allocation IE is not empty: ",
7176 ie.chan_ident.ma, ", despite it shall be");
7177 continue;
7178 }
7179 }
7180
7181 /* Disable frequency hopping */
7182 f_TC_fh_params_unset(fhp);
7183
Vadim Yanitskiy21726312020-09-04 01:45:36 +07007184 f_shutdown_helper();
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007185}
7186
7187/* Verify the hopping parameters (HSN, MAIO, MA) in (RR) Immediate Assignment */
7188testcase TC_fh_params_imm_ass() runs on test_CT {
7189 var FHParamsTrx fhp := f_TC_fh_params_gen();
7190 var RSL_Message rsl_msg;
7191 var RSL_IE_Body ie;
7192
7193 f_init_vty();
7194
7195 f_TC_fh_params_set(fhp); /* Enable frequency hopping */
7196 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
7197
7198 f_init(1);
7199
7200 /* CS domain: 3 (SDCCH/4+CBCH) + 4 (TCH/F) + 2 (TCH/H) channels available */
7201 for (var integer i := 0; i < 9; i := i + 1) {
7202 f_ipa_tx(0, ts_RSL_CHAN_RQD(f_rnd_ra_cs(), 23));
7203 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
7204
7205 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(rsl_msg.ies[0].body.chan_nr, 33));
7206 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeC(RSL_MT_IMMEDIATE_ASSIGN_CMD));
7207
7208 /* Make sure that Full Immediate Assign Info IE is present */
7209 if (not f_rsl_find_ie(rsl_msg, RSL_IE_FULL_IMM_ASS_INFO, ie)) {
7210 setverdict(fail, "RSL Full Immediate Assign Info IE is absent");
7211 continue;
7212 }
7213
7214 /* Decode the actual Immediate Assignment message */
7215 var GsmRrMessage rr_msg := dec_GsmRrMessage(ie.full_imm_ass_info.payload);
7216 if (not match(rr_msg.header, t_RrHeader(IMMEDIATE_ASSIGNMENT, ?))) {
7217 setverdict(fail, "Failed to match Immediate Assignment: ", rr_msg);
7218 continue;
7219 }
7220
7221 /* Make sure that hopping parameters (HSN/MAIO) match */
7222 f_TC_fh_params_match_chan_desc(fhp, rr_msg.payload.imm_ass.chan_desc);
7223
7224 /* Make sure that the Mobile Allocation IE matches */
7225 f_TC_fh_params_match_ma(fhp, rr_msg.payload.imm_ass.chan_desc.chan_nr.tn,
7226 rr_msg.payload.imm_ass.mobile_allocation);
7227 }
7228
7229 /* Disable frequency hopping */
7230 f_TC_fh_params_unset(fhp);
Philipp Maier82812002020-08-13 18:48:27 +02007231
Vadim Yanitskiy21726312020-09-04 01:45:36 +07007232 f_shutdown_helper();
Philipp Maier82812002020-08-13 18:48:27 +02007233}
7234
Vadim Yanitskiyaeb54a22020-09-01 06:25:25 +07007235/* Verify the hopping parameters (HSN, MAIO, MA) in (RR) Assignment Command */
7236testcase TC_fh_params_assignment_cmd() runs on test_CT {
7237 var FHParamsTrx fhp := f_TC_fh_params_gen();
7238 var RSL_Message rsl_msg;
7239 var RSL_IE_Body ie;
7240
7241 f_init_vty();
7242
7243 f_TC_fh_params_set(fhp); /* Enable frequency hopping */
7244 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
7245
7246 f_init(1);
7247
7248 /* HACK: work around "Couldn't find Expect for CRCX" */
7249 vc_MGCP.stop;
7250
7251 var template PDU_BSSAP ass_cmd := f_gen_ass_req();
7252 ass_cmd.pdu.bssmap.assignmentRequest.codecList := ts_BSSMAP_IE_CodecList({ts_CodecFR});
7253
7254 /* CS domain (TCH): 4 (TCH/F) + 2 (TCH/H) channels available
7255 * NOTE: only 3 SDCCH/4 channels are available on CCCH+SDCCH4+CBCH */
7256 for (var integer i := 0; i < 3; i := i + 1) {
7257 /* Establish a dedicated channel, so we can trigger (late) TCH assignment */
7258 var DchanTuple dt := f_est_dchan(f_rnd_ra_cs(), 23, f_rnd_octstring(16));
7259
7260 /* Send a BSSMAP Assignment Command, expect CHANnel ACTIVation */
7261 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ass_cmd));
7262 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
7263
7264 /* ACKnowledge CHANnel ACTIVation, expect RSL DATA REQuest */
7265 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(rsl_msg.ies[0].body.chan_nr, 33));
7266 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeR(RSL_MT_DATA_REQ));
7267
7268 /* Make sure that L3 Information IE is present */
7269 if (not f_rsl_find_ie(rsl_msg, RSL_IE_L3_INFO, ie)) {
7270 setverdict(fail, "RSL L3 Information IE is absent");
7271 continue;
7272 }
7273
7274 /* Decode the L3 message and make sure it is (RR) Assignment Command */
7275 var GsmRrL3Message l3_msg := dec_GsmRrL3Message(ie.l3_info.payload);
7276 if (not match(l3_msg.header, t_RrL3Header(ASSIGNMENT_COMMAND))) {
7277 setverdict(fail, "Failed to match Assignment Command: ", l3_msg);
7278 continue;
7279 }
7280
7281 /* Make sure that hopping parameters (HSN/MAIO) match */
7282 var ChannelDescription chan_desc := l3_msg.payload.ass_cmd.chan_desc;
7283 f_TC_fh_params_match_chan_desc(fhp, chan_desc);
7284
7285 /* Make sure that Cell Channel Description IE is present if FH is enabled */
7286 if (chan_desc.h and not ispresent(l3_msg.payload.ass_cmd.cell_chan_desc)) {
Vadim Yanitskiy38d069d2020-09-02 17:18:57 +07007287 setverdict(fail, "FH enabled, but Cell Channel Description IE is absent");
Vadim Yanitskiyaeb54a22020-09-01 06:25:25 +07007288 continue;
7289 }
7290
7291 /* Make sure that the Mobile Allocation IE matches (if present) */
7292 var boolean ma_present := ispresent(l3_msg.payload.ass_cmd.mobile_allocation);
7293 if (chan_desc.h and ma_present) {
7294 f_TC_fh_params_match_ma(fhp, chan_desc.chan_nr.tn,
7295 l3_msg.payload.ass_cmd.mobile_allocation.v);
7296 } else if (chan_desc.h and not ma_present) {
7297 setverdict(fail, "FH enabled, but Mobile Allocation IE is absent");
7298 continue;
7299 } else if (not chan_desc.h and ma_present) {
7300 setverdict(fail, "FH disabled, but Mobile Allocation IE is present");
7301 continue;
7302 }
7303 }
7304
7305 /* Give the IUT some time to release all channels */
7306 f_sleep(3.0);
7307
7308 /* Disable frequency hopping */
7309 f_TC_fh_params_unset(fhp);
7310
Vadim Yanitskiy21726312020-09-04 01:45:36 +07007311 f_shutdown_helper();
Vadim Yanitskiyaeb54a22020-09-01 06:25:25 +07007312}
7313
Vadim Yanitskiy8f5430d2020-09-02 18:51:38 +07007314/* Verify the hopping parameters (HSN, MAIO, MA) in (RR) Handover Command */
7315private function f_TC_fh_params_handover_cmd(in FHParamsTrx fhp)
7316runs on test_CT {
7317 var RSL_Message rsl_msg;
7318 var RSL_IE_Body ie;
7319 var DchanTuple dt;
7320
7321 /* Establish a dedicated channel, so we can trigger handover */
7322 dt := f_est_dchan(f_rnd_ra_cs(), 23, f_rnd_octstring(16));
7323
7324 /* Trigger handover from BTS0 to BTS1 */
7325 f_bts_0_cfg(BSCVTY, { "neighbor bts 1" });
7326 f_vty_handover(BSCVTY, 0, 0, dt.rsl_chan_nr, 1);
7327
7328 /* Expect RSL CHANnel ACTIVation on BTS1/TRX0/TS1 */
7329 rsl_msg := f_exp_ipa_rx(1, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
7330
7331 /* ACKnowledge channel activation and expect (RR) Handover Command */
7332 f_ipa_tx(1, ts_RSL_CHAN_ACT_ACK(rsl_msg.ies[0].body.chan_nr, 33));
7333 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeR(RSL_MT_DATA_REQ));
7334
7335 /* Make sure that L3 Information IE is present */
7336 if (not f_rsl_find_ie(rsl_msg, RSL_IE_L3_INFO, ie)) {
7337 setverdict(fail, "RSL L3 Information IE is absent");
7338 return;
7339 }
7340
7341 /* Decode the L3 message and make sure it is (RR) Handover Command */
7342 var GsmRrL3Message l3_msg := dec_GsmRrL3Message(ie.l3_info.payload);
7343 if (not match(l3_msg.header, t_RrL3Header(HANDOVER_COMMAND))) {
7344 setverdict(fail, "Failed to match Handover Command: ", l3_msg);
7345 return;
7346 }
7347
7348 /* Make sure that we've got SDCCH/8 on TS1 (expected to be hopping) */
7349 var ChannelDescription chan_desc := l3_msg.payload.ho_cmd.chan_desc;
7350 if (not match(chan_desc.chan_nr, t_RslChanNr_SDCCH8(1, ?))) {
7351 setverdict(fail, "Unexpected channel number: ", chan_desc.chan_nr);
7352 return;
7353 }
7354
7355 /* Make sure that hopping parameters (HSN/MAIO) match */
7356 f_TC_fh_params_match_chan_desc(fhp, chan_desc);
7357
7358 /* Make sure that Cell Channel Description IE is present */
7359 if (not ispresent(l3_msg.payload.ho_cmd.cell_chan_desc)) {
7360 setverdict(fail, "FH enabled, but Cell Channel Description IE is absent");
7361 return;
7362 }
7363
7364 /* Make sure that the Mobile Allocation (after time) IE is present and matches */
7365 var boolean ma_present := ispresent(l3_msg.payload.ho_cmd.mobile_allocation);
7366 if (ma_present) {
7367 f_TC_fh_params_match_ma(fhp, chan_desc.chan_nr.tn,
7368 l3_msg.payload.ho_cmd.mobile_allocation.v);
7369 } else {
7370 setverdict(fail, "FH enabled, but Mobile Allocation IE is absent");
7371 return;
7372 }
7373}
7374testcase TC_fh_params_handover_cmd() runs on test_CT {
7375 var FHParamsTrx fhp := f_TC_fh_params_gen();
7376
7377 f_init_vty();
7378
7379 /* (Re)configure TS0 as BCCH and TS1 as SDCCH8 on BTS1/TRX0 */
7380 f_vty_enter_cfg_trx(BSCVTY, bts := 1, trx := 0);
7381
7382 f_vty_transceive(BSCVTY, "timeslot 0");
7383 f_vty_transceive(BSCVTY, "phys_chan_config ccch");
7384 f_vty_transceive(BSCVTY, "exit"); /* go back */
7385
7386 f_vty_transceive(BSCVTY, "timeslot 1");
7387 f_vty_transceive(BSCVTY, "phys_chan_config sdcch8");
7388 f_vty_transceive(BSCVTY, "end"); /* we're done */
7389
7390 f_TC_fh_params_set(fhp, 1); /* Enable frequency hopping on BTS1 */
7391 f_vty_transceive(BSCVTY, "drop bts connection 1 oml");
7392
7393 f_init(2);
7394
7395 f_TC_fh_params_handover_cmd(fhp);
7396
7397 /* Disable frequency hopping on BTS1 */
7398 f_TC_fh_params_unset(fhp, 1);
7399
7400 /* (Re)configure TS0 as CCCH+SDCCH4+CBCH and TS1 as TCH/F */
7401 f_vty_enter_cfg_trx(BSCVTY, bts := 1, trx := 0);
7402
7403 f_vty_transceive(BSCVTY, "timeslot 0");
7404 f_vty_transceive(BSCVTY, "phys_chan_config ccch+sdcch4+cbch");
7405 f_vty_transceive(BSCVTY, "exit"); /* go back */
7406
7407 f_vty_transceive(BSCVTY, "timeslot 1");
7408 f_vty_transceive(BSCVTY, "phys_chan_config tch/f");
7409 f_vty_transceive(BSCVTY, "end"); /* we're done */
7410
7411 f_shutdown_helper();
7412}
7413
Vadim Yanitskiyca974032020-09-01 07:20:39 +07007414/* Verify the hopping parameters in System Information Type 4 */
7415testcase TC_fh_params_si4_cbch() runs on test_CT {
7416 var FHParamsTrx fhp := f_TC_fh_params_gen(tr_tn := 1);
7417 var ASP_RSL_Unitdata rx_rsl_ud;
7418 timer T := 5.0;
7419
7420 f_init_vty();
7421
7422 /* (Re)configure TS0 as BCCH and TS1 as SDCCH8+CBCH */
7423 f_vty_enter_cfg_trx(BSCVTY, trx := 0);
7424
7425 f_vty_transceive(BSCVTY, "timeslot 0");
7426 f_vty_transceive(BSCVTY, "phys_chan_config ccch");
7427 f_vty_transceive(BSCVTY, "exit"); /* go back */
7428
7429 f_vty_transceive(BSCVTY, "timeslot 1");
7430 f_vty_transceive(BSCVTY, "phys_chan_config sdcch8+cbch");
7431 f_vty_transceive(BSCVTY, "end"); /* we're done */
7432
7433 f_TC_fh_params_set(fhp); /* Enable frequency hopping */
7434 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
7435
7436 f_init(1);
7437
7438 T.start;
7439 alt {
7440 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_BCCH_INFO(RSL_SYSTEM_INFO_4))) -> value rx_rsl_ud {
7441 var RSL_IE_Body ie := rx_rsl_ud.rsl.ies[2].body; /* FULL BCCH Information IE */
7442 var SystemInformation si := dec_SystemInformation(ie.other.payload);
7443
7444 /* Make sure that what we decoded is System Information Type 4 */
7445 if (si.header.message_type != SYSTEM_INFORMATION_TYPE_4) {
7446 setverdict(fail, "RSL FULL BCCH Information IE contains: ", si);
7447 repeat;
7448 }
7449
7450 /* Make sure that CBCH Channel Description IE is present */
7451 if (not ispresent(si.payload.si4.cbch_chan_desc)) {
7452 setverdict(fail, "CBCH Channel Description IE is absent");
7453 break;
7454 }
7455
7456 /* Finally, check the hopping parameters (HSN, MAIO) */
7457 var ChannelDescription chan_desc := si.payload.si4.cbch_chan_desc.v;
7458 f_TC_fh_params_match_chan_desc(fhp, chan_desc);
7459
7460 /* 3GPP TS 44.018, section 9.1.36.2 "CBCH Mobile Allocation":
7461 * The CBCH Mobile Allocation IE *shall* be present if FH is enabled. */
7462 if (chan_desc.h and not ispresent(si.payload.si4.cbch_mobile_alloc)) {
7463 setverdict(fail, "FH enabled, but Mobile Allocation IE is absent");
7464 break;
7465 } else if (chan_desc.h and ispresent(si.payload.si4.cbch_mobile_alloc)) {
7466 f_TC_fh_params_match_ma(fhp, chan_desc.chan_nr.tn,
7467 si.payload.si4.cbch_mobile_alloc.v);
7468 }
7469 }
7470 [] IPA_RSL[0].receive { repeat; }
7471 [] T.timeout {
7472 setverdict(fail, "Timeout waiting for RSL BCCH INFOrmation (SI4)");
7473 }
7474 }
7475
7476 /* Disable frequency hopping */
7477 f_TC_fh_params_unset(fhp);
7478
Vadim Yanitskiy8bc46012020-09-06 12:38:01 +07007479 /* (Re)configure TS0 as CCCH+SDCCH4+CBCH and TS1 as TCH/F */
Vadim Yanitskiyca974032020-09-01 07:20:39 +07007480 f_vty_enter_cfg_trx(BSCVTY, trx := 0);
7481
7482 f_vty_transceive(BSCVTY, "timeslot 0");
Vadim Yanitskiy8bc46012020-09-06 12:38:01 +07007483 f_vty_transceive(BSCVTY, "phys_chan_config ccch+sdcch4+cbch");
Vadim Yanitskiyca974032020-09-01 07:20:39 +07007484 f_vty_transceive(BSCVTY, "exit"); /* go back */
7485
7486 f_vty_transceive(BSCVTY, "timeslot 1");
7487 f_vty_transceive(BSCVTY, "phys_chan_config tch/f");
7488 f_vty_transceive(BSCVTY, "end"); /* we're done */
7489
Vadim Yanitskiy21726312020-09-04 01:45:36 +07007490 f_shutdown_helper();
Vadim Yanitskiyca974032020-09-01 07:20:39 +07007491}
7492
Harald Welte0ea2d5e2018-04-07 21:40:29 +02007493/* Dyn PDCH todo:
7494 * activate OSMO as TCH/F
7495 * activate OSMO as TCH/H
7496 * does the BSC-located PCU socket get the updated INFO?
7497 * what if no PCU is connected at the time?
7498 * is the info correct on delayed PCU (re)connect?
7499 */
Harald Welte94e0c342018-04-07 11:33:23 +02007500
Harald Welte28d943e2017-11-25 15:00:50 +01007501control {
Harald Welte898113b2018-01-31 18:32:21 +01007502 /* CTRL interface testing */
Harald Welte4003d112017-12-09 22:35:39 +01007503 execute( TC_ctrl_msc_connection_status() );
Stefan Sperlingb041b3d2018-01-03 17:14:55 +01007504 execute( TC_ctrl_msc0_connection_status() );
Harald Welte96c94412017-12-09 03:12:45 +01007505 execute( TC_ctrl() );
Neels Hofmeyrf246a922020-05-13 02:27:10 +02007506 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_SCCPlite_SERVER) {
Pau Espin Pedrol5a2d7432019-06-07 19:43:45 +02007507 execute( TC_ctrl_location() );
7508 }
Harald Welte898113b2018-01-31 18:32:21 +01007509
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +02007510 execute( TC_si_default() );
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02007511 execute( TC_si2quater_2_earfcns() );
7512 execute( TC_si2quater_3_earfcns() );
7513 execute( TC_si2quater_4_earfcns() );
7514 execute( TC_si2quater_5_earfcns() );
7515 execute( TC_si2quater_6_earfcns() );
Neels Hofmeyrad132f22020-07-08 02:20:16 +02007516 execute( TC_si2quater_12_earfcns() );
7517 execute( TC_si2quater_23_earfcns() );
7518 execute( TC_si2quater_32_earfcns() );
7519 execute( TC_si2quater_33_earfcns() );
7520 execute( TC_si2quater_42_earfcns() );
7521 execute( TC_si2quater_48_earfcns() );
7522 execute( TC_si2quater_49_earfcns() );
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02007523 execute( TC_si_acc_rotate() );
Alexander Couzens4ad3a352020-09-10 22:29:12 +02007524 execute( TC_si_acc_ramp_rotate() );
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +02007525
Harald Welte898113b2018-01-31 18:32:21 +01007526 /* RSL DCHAN Channel ACtivation / Deactivation */
Harald Welteae026692017-12-09 01:03:01 +01007527 execute( TC_chan_act_noreply() );
Harald Welte4003d112017-12-09 22:35:39 +01007528 execute( TC_chan_act_counter() );
Harald Welteae026692017-12-09 01:03:01 +01007529 execute( TC_chan_act_ack_noest() );
Philipp Maier9c60a622020-07-09 15:08:46 +02007530 execute( TC_chan_act_ack_noest_emerg() );
Philipp Maier606f07d2020-08-12 17:21:58 +02007531 execute( TC_chan_rqd_emerg_deny() );
Harald Welteae026692017-12-09 01:03:01 +01007532 execute( TC_chan_act_ack_est_ind_noreply() );
7533 execute( TC_chan_act_ack_est_ind_refused() );
Harald Welte618ef642017-12-14 14:58:20 +01007534 execute( TC_chan_act_nack() );
Harald Welte799c97b2017-12-14 17:50:30 +01007535 execute( TC_chan_exhaustion() );
Vadim Yanitskiy1ff1fdf2018-11-27 01:32:57 +07007536 execute( TC_chan_deact_silence() );
Harald Welte4003d112017-12-09 22:35:39 +01007537 execute( TC_chan_rel_rll_rel_ind() );
7538 execute( TC_chan_rel_conn_fail() );
7539 execute( TC_chan_rel_hard_clear() );
Harald Welte99787102019-02-04 10:41:36 +01007540 execute( TC_chan_rel_hard_clear_csfb() );
Harald Welted8c36cd2017-12-09 23:05:31 +01007541 execute( TC_chan_rel_hard_rlsd() );
Harald Welte550daf92018-06-11 19:22:13 +02007542 execute( TC_chan_rel_hard_rlsd_ms_dead() );
Harald Welte85804d42017-12-10 14:11:58 +01007543 execute( TC_chan_rel_a_reset() );
Pau Espin Pedrolc675b612020-01-09 19:55:40 +01007544 execute( TC_chan_rel_sccp_tiar_timeout() );
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02007545 execute( TC_chan_rel_rr_cause() );
Harald Welte6f521d82017-12-11 19:52:02 +01007546
Harald Weltecfe2c962017-12-15 12:09:32 +01007547 execute( TC_outbound_connect() );
Harald Welte898113b2018-01-31 18:32:21 +01007548
7549 /* Assignment related */
Harald Welte16a4adf2017-12-14 18:54:01 +01007550 execute( TC_assignment_cic_only() );
Harald Welte235ebf12017-12-15 14:18:16 +01007551 execute( TC_assignment_csd() );
7552 execute( TC_assignment_ctm() );
7553 execute( TC_assignment_sign() );
Pau Espin Pedrol07866632020-09-03 19:10:55 +02007554 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
7555 execute( TC_assignment_aoip_tla_v6() );
7556 }
Harald Welte235ebf12017-12-15 14:18:16 +01007557 execute( TC_assignment_fr_a5_0() );
7558 execute( TC_assignment_fr_a5_1() );
Neels Hofmeyrf246a922020-05-13 02:27:10 +02007559 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
Harald Welte8f67d1d2018-05-25 20:38:42 +02007560 execute( TC_assignment_fr_a5_1_codec_missing() );
7561 }
Harald Welte235ebf12017-12-15 14:18:16 +01007562 execute( TC_assignment_fr_a5_3() );
7563 execute( TC_assignment_fr_a5_4() );
Harald Welte3c86ea02018-05-10 22:28:05 +02007564 execute( TC_ciph_mode_a5_0() );
7565 execute( TC_ciph_mode_a5_1() );
7566 execute( TC_ciph_mode_a5_3() );
Harald Welte16a4adf2017-12-14 18:54:01 +01007567
Harald Welte60aa5762018-03-21 19:33:13 +01007568 execute( TC_assignment_codec_fr() );
7569 execute( TC_assignment_codec_hr() );
7570 execute( TC_assignment_codec_efr() );
7571 execute( TC_assignment_codec_amr_f() );
7572 execute( TC_assignment_codec_amr_h() );
Philipp Maier8a581d22019-03-26 18:32:48 +01007573
Neels Hofmeyrf246a922020-05-13 02:27:10 +02007574 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
Philipp Maier8a581d22019-03-26 18:32:48 +01007575 execute( TC_assignment_codec_amr_f_S1() );
7576 execute( TC_assignment_codec_amr_h_S1() );
7577 execute( TC_assignment_codec_amr_f_S124() );
7578 execute( TC_assignment_codec_amr_h_S124() );
7579 execute( TC_assignment_codec_amr_f_S0() );
7580 execute( TC_assignment_codec_amr_f_S02() );
7581 execute( TC_assignment_codec_amr_f_S024() );
7582 execute( TC_assignment_codec_amr_f_S0247() );
7583 execute( TC_assignment_codec_amr_h_S0() );
7584 execute( TC_assignment_codec_amr_h_S02() );
7585 execute( TC_assignment_codec_amr_h_S024() );
7586 execute( TC_assignment_codec_amr_h_S0247() );
7587 execute( TC_assignment_codec_amr_f_S01234567() );
7588 execute( TC_assignment_codec_amr_f_S0234567() );
7589 execute( TC_assignment_codec_amr_f_zero() );
7590 execute( TC_assignment_codec_amr_f_unsupp() );
7591 execute( TC_assignment_codec_amr_h_S7() );
7592 }
Harald Welte60aa5762018-03-21 19:33:13 +01007593
Philipp Maierac09bfc2019-01-08 13:41:39 +01007594 execute( TC_assignment_codec_fr_exhausted_req_hr() );
7595 execute( TC_assignment_codec_fr_exhausted_req_fr() );
7596 execute( TC_assignment_codec_fr_exhausted_req_fr_hr() );
7597 execute( TC_assignment_codec_fr_exhausted_req_hr_fr() );
7598 execute( TC_assignment_codec_hr_exhausted_req_fr() );
7599 execute( TC_assignment_codec_hr_exhausted_req_hr() );
7600 execute( TC_assignment_codec_hr_exhausted_req_hr_fr() );
7601 execute( TC_assignment_codec_hr_exhausted_req_fr_hr() );
7602 execute( TC_assignment_codec_req_hr_fr() );
7603 execute( TC_assignment_codec_req_fr_hr() );
7604
Pau Espin Pedrol58cf6822019-05-28 18:11:33 +02007605 if (mp_enable_osmux_test) {
7606 execute( TC_assignment_osmux() );
7607 }
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02007608
Harald Welte898113b2018-01-31 18:32:21 +01007609 /* RLL Establish Indication on inactive DCHAN / SAPI */
Harald Welte5cd20ed2017-12-13 21:03:20 +01007610 execute( TC_rll_est_ind_inact_lchan() );
7611 execute( TC_rll_est_ind_inval_sapi1() );
7612 execute( TC_rll_est_ind_inval_sapi3() );
7613 execute( TC_rll_est_ind_inval_sacch() );
7614
Vadim Yanitskiy6ef5dfa2020-08-28 18:04:41 +07007615 /* SAPI N Reject triggered by RLL establishment failures */
7616 execute( TC_rll_rel_ind_sapi_n_reject() );
7617 execute( TC_rll_err_ind_sapi_n_reject() );
7618 execute( TC_rll_timeout_sapi_n_reject() );
7619
Harald Welte898113b2018-01-31 18:32:21 +01007620 /* Paging related tests */
Harald Welte6f521d82017-12-11 19:52:02 +01007621 execute( TC_paging_imsi_nochan() );
7622 execute( TC_paging_tmsi_nochan() );
7623 execute( TC_paging_tmsi_any() );
7624 execute( TC_paging_tmsi_sdcch() );
7625 execute( TC_paging_tmsi_tch_f() );
7626 execute( TC_paging_tmsi_tch_hf() );
7627 execute( TC_paging_imsi_nochan_cgi() );
7628 execute( TC_paging_imsi_nochan_lac_ci() );
7629 execute( TC_paging_imsi_nochan_ci() );
7630 execute( TC_paging_imsi_nochan_lai() );
7631 execute( TC_paging_imsi_nochan_lac() );
7632 execute( TC_paging_imsi_nochan_all() );
Harald Welte751d3eb2018-01-31 15:51:06 +01007633 execute( TC_paging_imsi_nochan_plmn_lac_rnc() );
7634 execute( TC_paging_imsi_nochan_rnc() );
7635 execute( TC_paging_imsi_nochan_lac_rnc() );
7636 execute( TC_paging_imsi_nochan_lacs() );
7637 execute( TC_paging_imsi_nochan_lacs_empty() );
Stefan Sperling049a86e2018-03-20 15:51:00 +01007638 execute( TC_paging_imsi_nochan_cgi_unknown_cid() );
Harald Welte10985002017-12-12 09:29:15 +01007639 execute( TC_paging_imsi_a_reset() );
Harald Weltee65d40e2017-12-13 00:09:06 +01007640 execute( TC_paging_imsi_load() );
Philipp Maier779a7922018-02-16 11:00:37 +01007641 execute( TC_paging_counter() );
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01007642 execute( TC_paging_resp_unsol() );
Harald Welte4e9b9cc2017-12-14 18:31:02 +01007643
7644 execute( TC_rsl_drop_counter() );
Stefan Sperling830dc9d2018-02-12 21:08:28 +01007645 execute( TC_rsl_unknown_unit_id() );
7646
7647 execute( TC_oml_unknown_unit_id() );
Harald Welte898113b2018-01-31 18:32:21 +01007648
7649 execute( TC_classmark() );
Harald Welteeddf0e92020-06-21 19:42:15 +02007650 execute( TC_common_id() );
Harald Welte898113b2018-01-31 18:32:21 +01007651 execute( TC_unsol_ass_fail() );
Harald Welteea99a002018-01-31 20:46:43 +01007652 execute( TC_unsol_ass_compl() );
Harald Weltefbf9b5e2018-01-31 20:41:23 +01007653 execute( TC_unsol_ho_fail() );
Harald Weltee3bd6582018-01-31 22:51:25 +01007654 execute( TC_err_82_short_msg() );
Harald Weltee9e02e42018-01-31 23:36:25 +01007655 execute( TC_err_84_unknown_msg() );
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01007656
Harald Welte261af4b2018-02-12 21:20:39 +01007657 execute( TC_ho_int() );
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01007658
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01007659 execute( TC_ho_out_of_this_bsc() );
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02007660 execute( TC_ho_out_fail_no_msc_response() );
7661 execute( TC_ho_out_fail_rr_ho_failure() );
Neels Hofmeyrd8a602c2019-07-09 19:46:01 +02007662 execute( TC_ho_out_fail_no_result_after_ho_cmd() );
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01007663
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01007664 execute( TC_ho_into_this_bsc() );
Pau Espin Pedrol07866632020-09-03 19:10:55 +02007665 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
7666 execute( TC_ho_into_this_bsc_tla_v6() );
7667 }
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01007668 execute( TC_ho_in_fail_msc_clears() );
7669 execute( TC_ho_in_fail_msc_clears_after_ho_detect() );
7670 execute( TC_ho_in_fail_no_detect() );
7671 execute( TC_ho_in_fail_no_detect2() );
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01007672
Neels Hofmeyr91401012019-07-11 00:42:35 +02007673 execute( TC_ho_neighbor_config_1() );
7674 execute( TC_ho_neighbor_config_2() );
7675 execute( TC_ho_neighbor_config_3() );
7676 execute( TC_ho_neighbor_config_4() );
7677 execute( TC_ho_neighbor_config_5() );
7678 execute( TC_ho_neighbor_config_6() );
7679 execute( TC_ho_neighbor_config_7() );
7680
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01007681 execute( TC_bssap_rlsd_does_not_cause_bssmap_reset() );
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01007682 execute( TC_bssmap_clear_does_not_cause_bssmap_reset() );
Neels Hofmeyrfd445c32018-03-09 15:39:31 +01007683 execute( TC_ms_rel_ind_does_not_cause_bssmap_reset() );
Harald Welte94e0c342018-04-07 11:33:23 +02007684
7685 execute( TC_dyn_pdch_ipa_act_deact() );
7686 execute( TC_dyn_pdch_ipa_act_nack() );
7687 execute( TC_dyn_pdch_osmo_act_deact() );
7688 execute( TC_dyn_pdch_osmo_act_nack() );
Harald Welte99f3ca02018-06-14 13:40:29 +02007689
Stefan Sperling0796a822018-10-05 13:01:39 +02007690 execute( TC_chopped_ipa_ping() );
Stefan Sperlingaa1e60f2018-10-15 16:34:07 +02007691 execute( TC_chopped_ipa_payload() );
Stefan Sperling0796a822018-10-05 13:01:39 +02007692
Pau Espin Pedrol8f773632019-11-05 11:46:53 +01007693 /* Power control related */
7694 execute( TC_assignment_verify_ms_power_params_ie() );
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007695
7696 /* MSC pooling */
7697 /* FIXME: in SCCPlite, indicating how many MSCs should be connected does currently not work. Since
7698 * RESET->RESET-ACK is unconditionally negotiated for all configured MSCs, they always all appear as connected
7699 * to osmo-bsc. The MSC pooling tests however require disconnecting selected MSCs, and hence don't work out as
7700 * intended on SCCPlite. So for now, run these only for SCCP/M3UA. */
7701 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
7702 execute( TC_mscpool_L3Compl_on_1_msc() );
7703 execute( TC_mscpool_L3Complete_by_imsi_round_robin() );
7704 execute( TC_mscpool_LU_by_tmsi_null_nri_0_round_robin() );
7705 execute( TC_mscpool_LU_by_tmsi_null_nri_1_round_robin() );
7706 execute( TC_mscpool_L3Complete_by_tmsi_unassigned_nri_round_robin() );
7707 execute( TC_mscpool_L3Complete_by_tmsi_valid_nri_msc_not_connected_round_robin() );
7708 execute( TC_mscpool_L3Complete_by_tmsi_valid_nri_1() );
7709 execute( TC_mscpool_L3Complete_by_tmsi_valid_nri_2() );
7710 execute( TC_mscpool_LU_by_tmsi_from_other_PLMN() );
7711 execute( TC_mscpool_paging_and_response_imsi() );
7712 execute( TC_mscpool_paging_and_response_tmsi() );
7713 execute( TC_mscpool_no_allow_attach_round_robin() );
7714 execute( TC_mscpool_no_allow_attach_valid_nri() );
7715 }
7716
Harald Welte99f3ca02018-06-14 13:40:29 +02007717 /* at bottom as they might crash OsmoBSC before OS#3182 is fixed */
7718 execute( TC_early_conn_fail() );
7719 execute( TC_late_conn_fail() );
7720
Philipp Maier783681c2020-07-16 16:47:06 +02007721 /* Emergency call handling (deny / allow) */
7722 execute( TC_assignment_emerg_setup_allow() );
7723 execute( TC_assignment_emerg_setup_deny_msc() );
7724 execute( TC_assignment_emerg_setup_deny_bts() );
Philipp Maier82812002020-08-13 18:48:27 +02007725 execute( TC_emerg_premption() );
7726
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007727 /* Frequency hopping parameters handling */
7728 execute( TC_fh_params_chan_activ() );
7729 execute( TC_fh_params_imm_ass() );
Vadim Yanitskiyaeb54a22020-09-01 06:25:25 +07007730 execute( TC_fh_params_assignment_cmd() );
Vadim Yanitskiy8f5430d2020-09-02 18:51:38 +07007731 execute( TC_fh_params_handover_cmd() );
Vadim Yanitskiyca974032020-09-01 07:20:39 +07007732 execute( TC_fh_params_si4_cbch() );
Harald Welte28d943e2017-11-25 15:00:50 +01007733}
7734
7735}