blob: 4c450287c975405c351d8893f6cb782951fd0f05 [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));
Harald Welteae026692017-12-09 01:03:01 +01001151 setverdict(pass);
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
1167 setverdict(pass);
1168}
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
1180 setverdict(pass);
1181}
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);
Harald Welteae026692017-12-09 01:03:01 +01001239 setverdict(pass);
1240}
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);
Harald Welteae026692017-12-09 01:03:01 +01001260 setverdict(pass);
1261}
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
1283 setverdict(pass);
1284}
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 }
1332}
1333
Vadim Yanitskiy1ff1fdf2018-11-27 01:32:57 +07001334/* Test channel deactivation due to silence from MS */
1335testcase TC_chan_deact_silence() runs on test_CT {
1336 var RslChannelNr chan_nr;
1337
1338 f_init(1);
1339
1340 /* Request for a dedicated channel */
1341 chan_nr := f_chreq_act_ack('23'O);
1342
1343 /* Wait some time until the channel is released */
1344 f_sleep(2.0);
1345
1346 /* Expect CHANnel RELease */
1347 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001348 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL))) {
Vadim Yanitskiy1ff1fdf2018-11-27 01:32:57 +07001349 log("Received CHANnel RELease");
1350 setverdict(pass);
1351 }
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001352 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_IMM_ASSIGN(?))) {
Vadim Yanitskiy1ff1fdf2018-11-27 01:32:57 +07001353 /* See OS#3709, OsmoBSC should not send Immediate
1354 * Assignment Reject since a dedicated channel was
1355 * already allocated, and Immediate Assignment was
1356 * already sent. */
1357 setverdict(fail, "Unexpected Immediate Assignment!");
1358 }
1359 [] IPA_RSL[0].receive {
1360 setverdict(fail, "Unexpected RSL message!");
1361 }
1362 }
1363}
1364
Harald Weltecfe2c962017-12-15 12:09:32 +01001365/***********************************************************************
1366 * Assignment Testing
1367 ***********************************************************************/
1368
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02001369/* Verify that the BSC refuses any BSSAP connection from the MSC (They are all BSC->MSC direction,
1370 * except for the inter-BSC handover, MT side) */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001371testcase TC_outbound_connect(integer bssap_idx := 0) runs on test_CT {
Harald Welte89d42e82017-12-17 16:42:41 +01001372 f_init(1);
Harald Weltecfe2c962017-12-15 12:09:32 +01001373
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001374 BSSAP.send(ts_BSSAP_CONNECT_req(g_bssap[bssap_idx].sccp_addr_peer, g_bssap[bssap_idx].sccp_addr_own,
1375 2342, ts_BSSMAP_AssignmentReq));
Harald Weltecfe2c962017-12-15 12:09:32 +01001376 BSSAP.receive(tr_BSSAP_DISC_ind(2342, ?, ?));
1377 setverdict(pass);
1378}
1379
Harald Welte16a4adf2017-12-14 18:54:01 +01001380/* Test behavior if MSC answers with CREF to CR */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001381testcase TC_assignment_cic_only(integer bssap_idx := 0) runs on test_CT {
Harald Welte16a4adf2017-12-14 18:54:01 +01001382 var BSSAP_N_CONNECT_ind rx_c_ind;
1383 var RSL_Message rx_rsl;
1384 var DchanTuple dt;
1385
Harald Welte89d42e82017-12-17 16:42:41 +01001386 f_init(1);
Harald Welte16a4adf2017-12-14 18:54:01 +01001387
1388 dt := f_est_dchan('23'O, 23, '00000000'O);
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001389 if (mp_bssap_cfg[bssap_idx].transport == BSSAP_TRANSPORT_AoIP) {
Harald Welte17b27da2018-05-25 20:33:53 +02001390 /* send assignment without AoIP IEs */
1391 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_AssignmentReq(ts_BSSMAP_IE_CIC(0, 1))));
1392 } else {
1393 /* Send assignmetn without CIC in IPA case */
1394 var BSSMAP_IE_AoIP_TransportLayerAddress tla :=
1395 valueof(ts_BSSMAP_IE_AoIP_TLA4('01020304'O, 2342));
1396 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_AssignmentReq(omit, tla)));
1397 }
Harald Welte16a4adf2017-12-14 18:54:01 +01001398 alt {
1399 [] BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_AssignmentComplete)) {
1400 setverdict(fail, "AoIP BSC cannot accept ASSIGNMENT without AoIP Transport IE");
1401 }
Harald Welte235ebf12017-12-15 14:18:16 +01001402 /* TODO: Actually expect GSM0808_CAUSE_REQ_A_IF_TYPE_NOT_SUPP */
Harald Welte16a4adf2017-12-14 18:54:01 +01001403 [] BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_AssignmentFail)) {
1404 setverdict(pass);
1405 }
1406 [] BSSAP.receive { repeat; }
1407 }
1408}
1409
Harald Welteed848512018-05-24 22:27:58 +02001410/* generate an assignment request for either AoIP or SCCPlite */
Pau Espin Pedrol07866632020-09-03 19:10:55 +02001411function 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 +02001412 var PDU_BSSAP ass_cmd;
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02001413 var BSSMAP_IE_Osmo_OsmuxCID osmux_cid := valueof(ts_OsmuxCID(0));
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001414 if (mp_bssap_cfg[bssap_idx].transport == BSSAP_TRANSPORT_AoIP) {
Harald Welteed848512018-05-24 22:27:58 +02001415 var BSSMAP_IE_AoIP_TransportLayerAddress tla :=
Pau Espin Pedrol07866632020-09-03 19:10:55 +02001416 valueof(f_ts_BSSMAP_IE_AoIP_TLA(aoip_tla, 2342));
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02001417 if (osmux_enabled) {
1418 ass_cmd := valueof(ts_BSSMAP_AssignmentReq(omit, tla, osmux_cid));
1419 } else {
1420 ass_cmd := valueof(ts_BSSMAP_AssignmentReq(omit, tla));
1421 }
Harald Welteed848512018-05-24 22:27:58 +02001422 } else {
1423 var BSSMAP_IE_CircuitIdentityCode cic := valueof(ts_BSSMAP_IE_CIC(0,1));
Pau Espin Pedrol096d73d2019-06-06 12:49:17 +02001424 ass_cmd := valueof(ts_BSSMAP_AssignmentReq(cic, omit));
Harald Welteed848512018-05-24 22:27:58 +02001425 }
1426 return ass_cmd;
1427}
1428
Pau Espin Pedrol07866632020-09-03 19:10:55 +02001429function 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 +01001430 var PDU_BSSAP ho_req;
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001431 if (mp_bssap_cfg[bssap_idx].transport == BSSAP_TRANSPORT_AoIP) {
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01001432 var BSSMAP_IE_AoIP_TransportLayerAddress tla :=
Pau Espin Pedrol07866632020-09-03 19:10:55 +02001433 valueof(f_ts_BSSMAP_IE_AoIP_TLA(aoip_tla, 2342));
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01001434 ho_req := valueof(ts_BSSMAP_HandoverRequest(omit, tla));
1435 } else {
1436 var BSSMAP_IE_CircuitIdentityCode cic := valueof(ts_BSSMAP_IE_CIC(0,1));
1437 ho_req := valueof(ts_BSSMAP_HandoverRequest(cic, omit));
1438 }
1439 return ho_req;
1440}
1441
Harald Welteed848512018-05-24 22:27:58 +02001442/* generate an assignment complete template for either AoIP or SCCPlite */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001443function f_gen_exp_compl(boolean expect_osmux := false, integer bssap_idx := 0) return template PDU_BSSAP {
Harald Welteed848512018-05-24 22:27:58 +02001444 var template PDU_BSSAP exp_compl;
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02001445 var BSSMAP_IE_Osmo_OsmuxCID osmux_cid := valueof(ts_OsmuxCID(0));
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001446 if (mp_bssap_cfg[bssap_idx].transport == BSSAP_TRANSPORT_AoIP) {
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02001447 if (expect_osmux) {
1448 exp_compl := tr_BSSMAP_AssignmentComplete(omit, ?, osmux_cid);
1449 } else {
1450 exp_compl := tr_BSSMAP_AssignmentComplete(omit, ?, omit);
1451 }
Harald Welteed848512018-05-24 22:27:58 +02001452 } else {
1453 /* CIC is optional "*" as the MSC allocated it */
Pau Espin Pedrol096d73d2019-06-06 12:49:17 +02001454 exp_compl := tr_BSSMAP_AssignmentComplete(*, omit);
Harald Welteed848512018-05-24 22:27:58 +02001455 }
1456 return exp_compl;
1457}
1458
Harald Welte235ebf12017-12-15 14:18:16 +01001459/* Run everything required up to sending a caller-specified assignment command and expect response */
1460function f_assignment_exp(PDU_BSSAP ass_cmd, template PDU_BSSAP exp, charstring fail_text)
1461runs on test_CT {
1462 var BSSAP_N_CONNECT_ind rx_c_ind;
1463 var RSL_Message rx_rsl;
1464 var DchanTuple dt;
1465
Harald Welte89d42e82017-12-17 16:42:41 +01001466 f_init(1);
Harald Welte235ebf12017-12-15 14:18:16 +01001467
1468 dt := f_est_dchan('23'O, 23, '00000000'O);
1469 /* send assignment without AoIP IEs */
1470 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ass_cmd));
1471 alt {
1472 [] BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_AssignmentComplete)) {
1473 if (ischosen(exp.pdu.bssmap.assignmentComplete)) {
1474 setverdict(pass);
1475 } else {
1476 setverdict(fail, fail_text);
1477 }
1478 }
1479 [] BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_AssignmentFail)) {
1480 if (ischosen(exp.pdu.bssmap.assignmentFailure)) {
1481 setverdict(pass);
1482 } else {
1483 setverdict(fail, fail_text);
1484 }
1485 }
1486 [] BSSAP.receive { repeat; }
1487 }
1488}
1489testcase TC_assignment_csd() runs on test_CT {
1490 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
Harald Welteed848512018-05-24 22:27:58 +02001491 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte235ebf12017-12-15 14:18:16 +01001492 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeCSD);
1493 //exp_fail.pdu.bssmap.assignmentFailure.cause.causeValue := int2bit(enum2int(GSM0808_CAUSE_REQ_CODEC_TYPE_OR_CONFIG_UNAVAIL), 7);
1494 f_assignment_exp(ass_cmd, exp_fail, "BSC accepted Assignment for CSD");
1495}
1496
1497testcase TC_assignment_ctm() runs on test_CT {
1498 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
Harald Welteed848512018-05-24 22:27:58 +02001499 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte235ebf12017-12-15 14:18:16 +01001500 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeCTM);
1501 //exp_fail.pdu.bssmap.assignmentFailure.cause.causeValue := int2bit(enum2int(GSM0808_CAUSE_REQ_CODEC_TYPE_OR_CONFIG_UNAVAIL), 7);
1502 f_assignment_exp(ass_cmd, exp_fail, "BSC accepted Assignment for Speech+CTM");
1503}
1504
Harald Welte4003d112017-12-09 22:35:39 +01001505type record DchanTuple {
1506 integer sccp_conn_id,
1507 RslChannelNr rsl_chan_nr
Harald Weltea5d2ab22017-12-09 14:21:42 +01001508}
1509
Harald Welted6939652017-12-13 21:02:46 +01001510/* Send CHAN RQD and wait for allocation; acknowledge it */
1511private function f_chreq_act_ack(OCT1 ra := '23'O, GsmFrameNumber fn := 23)
1512runs on test_CT return RslChannelNr {
1513 var RSL_Message rx_rsl;
1514 f_ipa_tx(0, ts_RSL_CHAN_RQD(ra, fn));
1515 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
1516 var RslChannelNr chan_nr := rx_rsl.ies[0].body.chan_nr;
1517 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, fn+10));
Daniel Willmannf4ac4ce2018-08-02 14:06:30 +02001518 rx_rsl := f_exp_ipa_rx(0, tr_RSL_IMM_ASSIGN(0));
Harald Welted6939652017-12-13 21:02:46 +01001519 return chan_nr;
1520}
1521
Harald Welte4003d112017-12-09 22:35:39 +01001522/* helper function to establish a dedicated channel via BTS and MSC */
1523function f_est_dchan(OCT1 ra, GsmFrameNumber fn, octetstring l3)
1524runs on test_CT return DchanTuple {
1525 var BSSAP_N_CONNECT_ind rx_c_ind;
Harald Welte4003d112017-12-09 22:35:39 +01001526 var DchanTuple dt;
Harald Weltea5d2ab22017-12-09 14:21:42 +01001527
Harald Welte4003d112017-12-09 22:35:39 +01001528 /* Send CHAN RQD and wait for allocation; acknowledge it */
Harald Welted6939652017-12-13 21:02:46 +01001529 dt.rsl_chan_nr := f_chreq_act_ack(ra, fn);
Harald Welte4003d112017-12-09 22:35:39 +01001530
1531 f_ipa_tx(0, ts_RSL_EST_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
1532
1533 BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) -> value rx_c_ind;
1534 dt.sccp_conn_id := rx_c_ind.connectionId;
1535 BSSAP.send(ts_BSSAP_CONNECT_res(dt.sccp_conn_id));
1536
1537 return dt;
Harald Weltea5d2ab22017-12-09 14:21:42 +01001538}
1539
Harald Welte641fcbe2018-06-14 10:58:35 +02001540/* expect RF CAN REL from BTS, acknowledge it and clear the MSC side */
1541private function f_exp_chan_rel_and_clear(DchanTuple dt, integer bts_nr := 0) runs on test_CT {
1542 var RSL_Message rx_rsl;
1543 /* expect BSC to disable the channel */
1544 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), T3101_MAX);
1545 /* respond with CHAN REL ACK */
1546 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(dt.rsl_chan_nr));
1547
1548 /* expect Clear Complete from BSC */
1549 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete));
1550
1551 /* MSC disconnects as instructed. */
1552 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
1553}
1554
Harald Welte4003d112017-12-09 22:35:39 +01001555/* Test behavior of channel release after unilateral RLL REL IND (DISC from MS) */
1556testcase TC_chan_rel_rll_rel_ind() runs on test_CT {
Neels Hofmeyr27f64362018-03-12 01:44:00 +01001557 var BSSAP_N_DATA_ind rx_di;
Harald Welte4003d112017-12-09 22:35:39 +01001558 var DchanTuple dt;
Harald Welte96c94412017-12-09 03:12:45 +01001559
Harald Welte89d42e82017-12-17 16:42:41 +01001560 f_init(1);
Harald Welte96c94412017-12-09 03:12:45 +01001561
Harald Welte4003d112017-12-09 22:35:39 +01001562 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1563
1564 /* simulate RLL REL IND */
1565 f_ipa_tx(0, ts_RSL_REL_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0))));
1566
Neels Hofmeyr27f64362018-03-12 01:44:00 +01001567 /* expect Clear Request on MSC side */
1568 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearRequest)) -> value rx_di;
1569
1570 /* Instruct BSC to clear channel */
1571 var BssmapCause cause := bit2int(rx_di.userData.pdu.bssmap.clearRequest.cause.causeValue);
1572 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
1573
Harald Welte4003d112017-12-09 22:35:39 +01001574 /* expect BSC to disable the channel */
Harald Welte641fcbe2018-06-14 10:58:35 +02001575 f_exp_chan_rel_and_clear(dt, 0);
Neels Hofmeyr27f64362018-03-12 01:44:00 +01001576
1577 /* wait for SCCP emulation to do its job */
1578 f_sleep(1.0);
Harald Welte4003d112017-12-09 22:35:39 +01001579
1580 setverdict(pass);
1581}
1582
1583/* Test behavior of channel release after CONN FAIL IND from BTS */
1584testcase TC_chan_rel_conn_fail() runs on test_CT {
1585 var BSSAP_N_DATA_ind rx_di;
Harald Welte4003d112017-12-09 22:35:39 +01001586 var DchanTuple dt;
1587
Harald Welte89d42e82017-12-17 16:42:41 +01001588 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +01001589
1590 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1591
1592 /* simulate CONN FAIL IND */
Harald Weltea8ed9062017-12-14 09:46:01 +01001593 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 +01001594 /* TODO: different cause values? */
1595
Harald Welte4003d112017-12-09 22:35:39 +01001596 /* expect Clear Request from BSC */
1597 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearRequest)) -> value rx_di;
1598
1599 /* Instruct BSC to clear channel */
1600 var BssmapCause cause := bit2int(rx_di.userData.pdu.bssmap.clearRequest.cause.causeValue);
1601 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
1602
Harald Welte6ff76ea2018-01-28 13:08:01 +01001603 /* expect BSC to disable the channel */
Harald Welte641fcbe2018-06-14 10:58:35 +02001604 f_exp_chan_rel_and_clear(dt, 0);
Harald Welte4003d112017-12-09 22:35:39 +01001605
1606 /* wait for SCCP emulation to do its job */
1607 f_sleep(1.0);
1608
1609 setverdict(pass);
1610}
1611
Harald Welte99f3ca02018-06-14 13:40:29 +02001612/* Test behavior of early CONN FAIL IND from BTS (before EST IND!) */
1613/* See also https://www.osmocom.org/issues/3182 */
1614testcase TC_early_conn_fail() runs on test_CT {
1615 var RSL_Message rx_rsl;
1616 var DchanTuple dt;
1617
1618 f_init(1);
1619
1620 /* BTS->BSC: Send CHAN RQD and wait for allocation; acknowledge it */
1621 dt.rsl_chan_nr := f_chreq_act_ack(f_rnd_octstring(1), 23);
1622
1623 /* BTS->BSC: simulate CONN FAIL IND */
1624 f_ipa_tx(0, ts_RSL_CONN_FAIL_IND(dt.rsl_chan_nr, RSL_ERR_RADIO_LINK_FAIL));
1625
1626 /* BTS->BSC: Expect RF channel release from BSC on Abis */
1627 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), 10.0);
1628
1629 /* BTS<-BSC: respond with CHAN REL ACK */
1630 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(dt.rsl_chan_nr));
1631
1632 setverdict(pass);
1633}
1634
1635/* Test behavior of late CONN FAIL IND from BTS (ater REL IND!) */
1636/* See also https://www.osmocom.org/issues/3182 */
1637testcase TC_late_conn_fail() runs on test_CT {
1638 var RSL_Message rx_rsl;
1639 var DchanTuple dt;
1640
1641 f_init(1);
1642
1643 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1644
1645 /* BSC<-MSC: Instruct BSC to clear connection */
1646 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(0)));
1647
1648 /* BTS->BSC: expect BSC to deactivate SACCH */
1649 rx_rsl := f_exp_ipa_rx(0, tr_RSL_DEACT_SACCH(dt.rsl_chan_nr));
1650
1651 /* BTS->BSC: simulate a late CONN FAIL IND from BTS */
1652 f_ipa_tx(0, ts_RSL_CONN_FAIL_IND(dt.rsl_chan_nr, RSL_ERR_RADIO_LINK_FAIL));
1653
1654 /* BTS<-BSC: Expect RF channel release from BSC on Abis */
1655 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), 10.0);
1656 /* BTS->BSC: respond with CHAN REL ACK */
1657 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(dt.rsl_chan_nr));
1658
1659 /* BSC->MSC: expect Clear Complete from BSC */
1660 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete));
1661
1662 /* BSC<-MSC: MSC disconnects as requested. */
1663 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
1664
1665 setverdict(pass);
1666}
1667
Neels Hofmeyrf44ccd12018-11-05 19:15:23 +01001668function f_expect_chan_rel(integer bts_nr, RslChannelNr rsl_chan_nr,
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001669 boolean expect_deact_sacch := true,
1670 boolean expect_rr_chan_rel := true,
1671 boolean expect_rll_rel_req := true,
Harald Welte99787102019-02-04 10:41:36 +01001672 boolean handle_rll_rel := true,
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02001673 boolean is_csfb := false,
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02001674 template CellSelIndValue csfb_expect_cells := omit,
1675 template RR_Cause expect_rr_cause := ?
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001676 ) runs on test_CT {
Harald Welte91d54a52018-01-28 15:35:07 +01001677
1678 var RslLinkId main_dcch := valueof(ts_RslLinkID_DCCH(0));
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001679 var boolean got_deact_sacch := false;
1680 var boolean got_rr_chan_rel := false;
1681 var boolean got_rll_rel_req := false;
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02001682 var ASP_RSL_Unitdata ud;
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02001683 var RSL_IE_Body l3_ie;
1684 var PDU_ML3_NW_MS l3;
1685 var RR_Cause got_cause;
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001686 log("f_expect_chan_rel() expecting: expect_deact_sacch=", expect_deact_sacch, " expect_rr_chan_rel=", expect_rr_chan_rel,
1687 " expect_rll_rel_req=", expect_rll_rel_req);
Harald Welte91d54a52018-01-28 15:35:07 +01001688 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001689 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(tr_RSL_DEACT_SACCH(rsl_chan_nr))) {
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001690 got_deact_sacch := true;
Harald Welte91d54a52018-01-28 15:35:07 +01001691 repeat;
1692 }
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02001693 [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 +01001694 got_rr_chan_rel := true;
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02001695
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02001696 if (f_rsl_find_ie(ud.rsl, RSL_IE_L3_INFO, l3_ie) == false) {
1697 setverdict(fail, "cannot find L3");
1698 mtc.stop;
1699 }
1700 l3 := dec_PDU_ML3_NW_MS(l3_ie.l3_info.payload);
1701
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02001702 if (not istemplatekind(csfb_expect_cells, "omit")) {
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02001703 var CellSelIndValue cells := dec_CellSelIndValue(
1704 l3.msgs.rrm.channelRelease.cellSelectionIndicator.cellSelectionIndicatorValue);
1705
1706 log("GOT RR CHANNEL RELEASE CSFB CELLS: ", cells);
1707 if (match(cells, csfb_expect_cells)) {
1708 setverdict(pass);
1709 } else {
1710 log("EXPECTED CSFB CELLS: ", csfb_expect_cells);
1711 setverdict(fail, "Received CSFB cells list on RR Channel Release does not match expectations");
1712 }
1713 }
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02001714
1715 if (not istemplatekind(expect_rr_cause, "omit")) {
1716 int2enum(oct2int(l3.msgs.rrm.channelRelease.rRCause.valuePart), got_cause);
1717 log("GOT CAUSE CODE: ", l3.msgs.rrm.channelRelease.rRCause.valuePart, " = ", got_cause);
1718 if (match(got_cause, expect_rr_cause)) {
1719 setverdict(pass);
1720 } else {
1721 log("EXPECTED CAUSE CODE: ", expect_rr_cause);
1722 setverdict(fail, "Received RR Channel Release Cause code does not match expectations");
1723 }
1724 }
Harald Welte99787102019-02-04 10:41:36 +01001725 repeat;
1726 }
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02001727 [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 +01001728 got_rr_chan_rel := true;
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02001729
1730 if (not istemplatekind(expect_rr_cause, "omit")) {
1731 if (f_rsl_find_ie(ud.rsl, RSL_IE_L3_INFO, l3_ie) == false) {
1732 setverdict(fail, "cannot find L3");
1733 mtc.stop;
1734 }
1735 l3 := dec_PDU_ML3_NW_MS(l3_ie.l3_info.payload);
1736
1737 int2enum(oct2int(l3.msgs.rrm.channelRelease.rRCause.valuePart), got_cause);
1738 log("GOT CAUSE CODE: ", l3.msgs.rrm.channelRelease.rRCause.valuePart, " = ", got_cause);
1739 if (match(got_cause, expect_rr_cause)) {
1740 setverdict(pass);
1741 } else {
1742 log("EXPECTED CAUSE CODE: ", expect_rr_cause);
1743 setverdict(fail, "Received RR Channel Release Cause code does not match expectations");
1744 }
1745 }
Neels Hofmeyr211169d2018-11-07 00:37:29 +01001746 repeat;
1747 }
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001748 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(tr_RSL_REL_REQ(rsl_chan_nr, ?))) {
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001749 got_rll_rel_req := true;
Harald Welte91d54a52018-01-28 15:35:07 +01001750 /* FIXME: Why are we getting this for LinkID SACCH? */
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001751 if (handle_rll_rel) {
1752 f_ipa_tx(0, ts_RSL_REL_CONF(rsl_chan_nr, main_dcch));
1753 }
Harald Welte91d54a52018-01-28 15:35:07 +01001754 repeat;
1755 }
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001756 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL))) {
Harald Welte91d54a52018-01-28 15:35:07 +01001757 /* respond with CHAN REL ACK */
1758 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(rsl_chan_nr));
1759 }
1760 /* ignore any user data */
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001761 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(tr_RSL_MsgTypeR(?))) {
Harald Welte91d54a52018-01-28 15:35:07 +01001762 repeat;
1763 }
1764 }
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001765
1766 log("f_expect_chan_rel() summary: got_deact_sacch=", got_deact_sacch, " got_rr_chan_rel=", got_rr_chan_rel,
1767 " got_rll_rel_req=", got_rll_rel_req);
1768
1769 if (expect_deact_sacch != got_deact_sacch) {
1770 setverdict(fail, "f_expect_chan_rel(): expect_deact_sacch=", expect_deact_sacch, " got_deact_sacch=", got_deact_sacch);
1771 }
1772 if (expect_rr_chan_rel != got_rr_chan_rel) {
1773 setverdict(fail, "f_expect_chan_rel(): expect_rr_chan_rel=", expect_rr_chan_rel, " got_rr_chan_rel=", got_rr_chan_rel);
1774 }
1775 if (expect_rll_rel_req != got_rll_rel_req) {
1776 setverdict(fail, "f_expect_chan_rel(): expect_rll_rel_req=", expect_rll_rel_req, " got_rll_rel_req=", got_rll_rel_req);
1777 }
Harald Welte91d54a52018-01-28 15:35:07 +01001778}
1779
Harald Welte4003d112017-12-09 22:35:39 +01001780/* Test behavior of channel release after hard Clear Command from MSC */
1781testcase TC_chan_rel_hard_clear() runs on test_CT {
1782 var BSSAP_N_DATA_ind rx_di;
Harald Welte4003d112017-12-09 22:35:39 +01001783 var DchanTuple dt;
Harald Welte4003d112017-12-09 22:35:39 +01001784
Harald Welte89d42e82017-12-17 16:42:41 +01001785 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +01001786
1787 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1788
1789 /* Instruct BSC to clear channel */
1790 var BssmapCause cause := 0;
1791 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
1792
1793 /* expect Clear Complete from BSC on A */
1794 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete)) {
1795 /* release the SCCP connection */
1796 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
1797 }
1798
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001799 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
Harald Welte4003d112017-12-09 22:35:39 +01001800 setverdict(pass);
1801}
1802
Harald Welte99787102019-02-04 10:41:36 +01001803/* Test behavior of channel release after Clear Command with CSFB indicator from MSC */
1804testcase TC_chan_rel_hard_clear_csfb() runs on test_CT {
1805 var BSSAP_N_DATA_ind rx_di;
1806 var DchanTuple dt;
1807
1808 f_init(1);
1809
1810 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1811
1812 /* Instruct BSC to clear channel */
1813 var BssmapCause cause := 0;
1814 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommandCSFB(cause)));
1815
1816 /* expect Clear Complete from BSC on A */
1817 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete)) {
1818 /* release the SCCP connection */
1819 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
1820 }
1821
1822 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false, is_csfb := true);
1823 setverdict(pass);
1824}
1825
Harald Welted8c36cd2017-12-09 23:05:31 +01001826/* Test behavior of channel release after hard RLSD from MSC */
1827testcase TC_chan_rel_hard_rlsd() runs on test_CT {
Harald Welted8c36cd2017-12-09 23:05:31 +01001828 var DchanTuple dt;
Harald Welted8c36cd2017-12-09 23:05:31 +01001829
Harald Welte89d42e82017-12-17 16:42:41 +01001830 f_init(1);
Harald Welted8c36cd2017-12-09 23:05:31 +01001831
1832 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1833
1834 /* release the SCCP connection */
1835 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
1836
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001837 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
Harald Welted8c36cd2017-12-09 23:05:31 +01001838 setverdict(pass);
1839}
1840
Harald Welte550daf92018-06-11 19:22:13 +02001841/* Test behavior of channel release after hard RLSD from MSC and MS is not responding to RLL REL REQ */
1842testcase TC_chan_rel_hard_rlsd_ms_dead() runs on test_CT {
1843 var DchanTuple dt;
1844
1845 f_init(1);
1846
1847 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1848
1849 /* release the SCCP connection */
1850 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
1851
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001852 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
Harald Welte550daf92018-06-11 19:22:13 +02001853 setverdict(pass);
1854}
1855
Harald Welte85804d42017-12-10 14:11:58 +01001856/* Test behavior of channel release after BSSMAP RESET from MSC */
1857testcase TC_chan_rel_a_reset() runs on test_CT {
Harald Welte85804d42017-12-10 14:11:58 +01001858 var DchanTuple dt;
Harald Welte85804d42017-12-10 14:11:58 +01001859
Harald Welte89d42e82017-12-17 16:42:41 +01001860 f_init(1);
Harald Welte85804d42017-12-10 14:11:58 +01001861
1862 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1863
1864 /* Clear the queue, it might still contain stuff like IMMEDIATE ASSIGN */
1865 IPA_RSL[0].clear;
1866
1867 /* perform BSSAP RESET, expect RESET ACK and DISC.ind on connection */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001868 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 +01001869 interleave {
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001870 [] 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 +01001871 [] BSSAP.receive(tr_BSSAP_DISC_ind(dt.sccp_conn_id, ?, ?)) { }
1872 }
1873
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001874 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
Harald Welte85804d42017-12-10 14:11:58 +01001875 setverdict(pass);
1876}
1877
Pau Espin Pedrolc675b612020-01-09 19:55:40 +01001878/* Verify T(iar) triggers and releases the channel */
1879testcase TC_chan_rel_sccp_tiar_timeout() runs on test_CT {
1880 var DchanTuple dt;
1881
1882 /* Set T(iar) in BSC low enough that it will trigger before other side
1883 has time to keep alive with a T(ias). Keep recommended ratio of
1884 T(iar) >= T(ias)*2 */
1885 g_bsc_sccp_timer_ias := 2;
1886 g_bsc_sccp_timer_iar := 5;
1887
1888 f_init(1);
1889
1890 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1891 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
1892 setverdict(pass);
1893}
1894
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02001895private function f_tc_chan_rel_rr_cause(myBSSMAP_Cause clear_cmd_cause, template RR_Cause expect_rr_cause)
1896runs on test_CT
1897{
1898 var DchanTuple dt;
1899
1900 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1901 var BssmapCause cause := 0;
1902 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(enum2int(clear_cmd_cause))));
1903 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete)) {
1904 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
1905 }
1906
1907 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false, expect_rr_cause := expect_rr_cause);
1908 setverdict(pass);
1909}
1910
1911/* Test that Clear Command cause codes affect the RR Channel Release cause code */
1912testcase TC_chan_rel_rr_cause() runs on test_CT {
1913 f_init(1);
1914
1915 f_tc_chan_rel_rr_cause(GSM0808_CAUSE_CALL_CONTROL, GSM48_RR_CAUSE_NORMAL);
1916 f_tc_chan_rel_rr_cause(GSM0808_CAUSE_HANDOVER_SUCCESSFUL, GSM48_RR_CAUSE_NORMAL);
1917 f_tc_chan_rel_rr_cause(GSM0808_CAUSE_PREEMPTION, GSM48_RR_CAUSE_PREMPTIVE_REL);
1918 f_tc_chan_rel_rr_cause(GSM0808_CAUSE_RADIO_INTERFACE_MESSAGE_FAILURE, GSM48_RR_CAUSE_PROT_ERROR_UNSPC);
1919 f_tc_chan_rel_rr_cause(GSM0808_CAUSE_RADIO_INTERFACE_FAILURE, GSM48_RR_CAUSE_ABNORMAL_UNSPEC);
1920 f_tc_chan_rel_rr_cause(GSM0808_CAUSE_EQUIPMENT_FAILURE, GSM48_RR_CAUSE_ABNORMAL_UNSPEC);
1921}
1922
Harald Welte5cd20ed2017-12-13 21:03:20 +01001923/* Test behavior if RSL EST IND for non-active channel */
1924testcase TC_rll_est_ind_inact_lchan() runs on test_CT {
1925 timer T := 2.0;
1926
Harald Welte89d42e82017-12-17 16:42:41 +01001927 f_init(1);
Harald Welte5cd20ed2017-12-13 21:03:20 +01001928
1929 var octetstring l3 := '00010203040506'O;
1930 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(6));
1931 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
1932
1933 T.start;
1934 alt {
1935 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) {
1936 setverdict(fail, "MSC received COMPL L3 for non-active lchan");
1937 }
1938 [] BSSAP.receive {}
1939 [] IPA_RSL[0].receive {}
1940 [] T.timeout {}
1941 }
1942
1943 setverdict(pass);
1944}
1945
1946/* Test behavior if RSL EST IND for invalid SAPI */
1947testcase TC_rll_est_ind_inval_sapi1() runs on test_CT {
1948 var RslChannelNr chan_nr;
1949
Harald Welte89d42e82017-12-17 16:42:41 +01001950 f_init(1);
Harald Welte5cd20ed2017-12-13 21:03:20 +01001951
1952 chan_nr := f_chreq_act_ack()
1953
1954 var octetstring l3 := '00010203040506'O;
1955 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(1)), l3));
1956
1957 timer T := 2.0;
1958 T.start;
1959 alt {
1960 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) {
1961 setverdict(fail, "MSC received COMPL L3 for invalid SAPI 1");
1962 }
1963 [] BSSAP.receive { repeat; }
1964 [] IPA_RSL[0].receive { repeat; }
1965 [] T.timeout {}
1966 }
1967
1968 setverdict(pass);
1969}
1970
1971/* Test behavior if RSL EST IND for invalid SAPI */
1972testcase TC_rll_est_ind_inval_sapi3() runs on test_CT {
1973 timer T := 2.0;
1974
Harald Welte89d42e82017-12-17 16:42:41 +01001975 f_init(1);
Harald Welte5cd20ed2017-12-13 21:03:20 +01001976
1977 var RslChannelNr chan_nr := f_chreq_act_ack();
1978
1979 var octetstring l3 := '00010203040506'O;
1980 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(3)), l3));
1981
1982 T.start;
1983 alt {
1984 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) {
1985 setverdict(fail, "MSC received COMPL L3 for invalid SAPI 3");
1986 }
1987 [] BSSAP.receive { repeat; }
1988 [] IPA_RSL[0].receive { repeat; }
1989 [] T.timeout {}
1990 }
1991
1992 setverdict(pass);
1993}
1994
1995/* Test behavior if RSL EST IND for invalid SACCH */
1996testcase TC_rll_est_ind_inval_sacch() runs on test_CT {
1997 timer T := 2.0;
1998
Harald Welte89d42e82017-12-17 16:42:41 +01001999 f_init(1);
Harald Welte5cd20ed2017-12-13 21:03:20 +01002000
2001 var RslChannelNr chan_nr := f_chreq_act_ack();
2002
2003 var octetstring l3 := '00010203040506'O;
2004 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_SACCH(0)), l3));
2005
2006 T.start;
2007 alt {
2008 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) {
2009 setverdict(fail, "MSC received COMPL L3 for invalid Link SACCH");
2010 }
2011 [] BSSAP.receive { repeat; }
2012 [] IPA_RSL[0].receive { repeat; }
2013 [] T.timeout {}
2014 }
2015
2016 setverdict(pass);
2017}
2018
Vadim Yanitskiy6ef5dfa2020-08-28 18:04:41 +07002019private function f_exp_sapi_n_reject(template (present) GsmSapi sapi := ?,
2020 template myBSSMAP_Cause cause := ?,
2021 float T_val := 2.0)
2022runs on test_CT {
2023 var BSSAP_N_DATA_ind rx_di;
2024 timer T;
2025
2026 var template BSSMAP_IE_Cause tr_cause := tr_BSSMAP_IE_Cause(cause);
2027 var template PDU_BSSAP tr_pdu := tr_BSSMAP_SAPInReject(sapi);
2028
2029 T.start(T_val);
2030 alt {
2031 [] BSSAP.receive(tr_BSSAP_DATA_ind(?, tr_pdu)) -> value rx_di {
2032 var BSSMAP_IE_Cause rx_cause := rx_di.userData.pdu.bssmap.sAPInReject.cause;
2033 if (not match(rx_cause, tr_cause)) {
2034 setverdict(fail, "Rx unexpected Cause IE: ",
2035 rx_cause, " vs expected ", tr_cause);
2036 }
2037 setverdict(pass);
2038 }
2039 [] BSSAP.receive(BSSAP_N_DATA_ind:?) -> value rx_di {
2040 setverdict(fail, "Rx unexpected BSSAP PDU: ", rx_di);
2041 }
2042 [] T.timeout {
2043 setverdict(fail, "Timeout waiting for BSSMAP SAPI N Reject");
2044 }
2045 }
2046}
2047
2048/* Check if we get SAPI N Reject on receipt of unexpected RLL RELease INDication */
2049testcase TC_rll_rel_ind_sapi_n_reject() runs on test_CT {
2050 var octetstring rnd_data := f_rnd_octstring(16);
2051 var RSL_Message rx_rsl;
2052 var DchanTuple dt;
2053
2054 f_init(1);
2055
2056 /* MS establishes a SAPI=0 link on DCCH */
2057 dt := f_est_dchan(f_rnd_ra_cs(), 23, rnd_data);
2058
2059 /* MSC sends some data on (not yet established) SAPI=3 link */
2060 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSAP_DTAP(rnd_data, '03'O)));
2061 /* BSC attempts to establish a SAPI=3 link on DCCH */
2062 rx_rsl := f_exp_ipa_rx(0, tr_RSL_EST_REQ(dt.rsl_chan_nr, tr_RslLinkID_DCCH(3)));
2063
2064 /* MS sends unexpected RELease INDication on SAPI=3 */
2065 f_ipa_tx(0, ts_RSL_REL_IND(dt.rsl_chan_nr, ts_RslLinkID_DCCH(3)));
2066 /* We expect to receive BSSMAP SAPI N Reject message from the BSC */
2067 f_exp_sapi_n_reject(3, GSM0808_CAUSE_MS_NOT_EQUIPPED);
2068
2069 /* Clean up the connection */
2070 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
2071 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
2072
2073 setverdict(pass);
2074}
2075
2076/* Check if we get SAPI N Reject on receipt of unexpected RLL ERROR INDication */
2077testcase TC_rll_err_ind_sapi_n_reject() runs on test_CT {
2078 var octetstring rnd_data := f_rnd_octstring(16);
2079 var RSL_Message rx_rsl;
2080 var DchanTuple dt;
2081
2082 f_init(1);
2083
2084 /* MS establishes a SAPI=0 link on DCCH */
2085 dt := f_est_dchan(f_rnd_ra_cs(), 23, rnd_data);
2086
2087 /* MSC sends some data on (not yet established) SAPI=3 link */
2088 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSAP_DTAP(rnd_data, '03'O)));
2089 /* BSC attempts to establish a SAPI=3 link on DCCH */
2090 rx_rsl := f_exp_ipa_rx(0, tr_RSL_EST_REQ(dt.rsl_chan_nr, tr_RslLinkID_DCCH(3)));
2091
2092 /* BTS sends unexpected ERROR INDication on SAPI=3 */
2093 f_ipa_tx(0, ts_RSL_ERROR_IND(dt.rsl_chan_nr, ts_RslLinkID_DCCH(3), ''O));
2094 /* We expect to receive BSSMAP SAPI N Reject message from the BSC */
2095 f_exp_sapi_n_reject(3, GSM0808_CAUSE_BSS_NOT_EQUIPPED);
2096
2097 /* Clean up the connection */
2098 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
2099 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
2100
2101 setverdict(pass);
2102}
2103
2104/* Check if we get SAPI N Reject due to a SAPI=3 link establishment timeout */
2105testcase TC_rll_timeout_sapi_n_reject() runs on test_CT {
2106 var octetstring rnd_data := f_rnd_octstring(16);
2107 var RSL_Message rx_rsl;
2108 var DchanTuple dt;
2109
2110 f_init(1);
2111
2112 /* MS establishes a SAPI=0 link on DCCH */
2113 dt := f_est_dchan(f_rnd_ra_cs(), 23, rnd_data);
2114
2115 /* MSC sends some data on (not yet established) SAPI=3 link */
2116 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSAP_DTAP(rnd_data, '03'O)));
2117 /* BSC attempts to establish a SAPI=3 link on DCCH */
2118 rx_rsl := f_exp_ipa_rx(0, tr_RSL_EST_REQ(dt.rsl_chan_nr, tr_RslLinkID_DCCH(3)));
2119
2120 /* MS does not respond, so the link establishment timeout triggers SAPI N Reject */
2121 f_exp_sapi_n_reject(3, GSM0808_CAUSE_BSS_NOT_EQUIPPED, T_val := 8.0);
2122
2123 /* Clean up the connection */
2124 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
2125 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
2126
2127 setverdict(pass);
2128}
2129
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +02002130testcase TC_si_default() runs on test_CT {
2131 f_init(0);
2132 f_init_bts_and_check_sysinfo(0, expect_si := SystemInformationConfig_default);
2133}
Harald Welte4003d112017-12-09 22:35:39 +01002134
Neels Hofmeyr56f24782020-07-09 00:50:49 +02002135/* We're testing SI2quater with lists of EARFCNs. Instead of just incrementing EARFCNs, also pick some from the edges of
2136 * the entire value range. This function provides the same EARFCN numbers for the same earfcn_index */
2137private function f_test_si2quater_earfcn_by_idx(integer earfcn_index) return uint16_t
2138{
2139 select (earfcn_index) {
2140 case (0) {
2141 /* E-ARFCN 111 is already added in the osmo-bsc.cfg */
2142 return 111;
2143 }
2144 case (1) {
2145 return 1;
2146 }
2147 case (2) {
2148 return 0;
2149 }
2150 case (3) {
2151 return 65535;
2152 }
2153 case else {
2154 return 23 * (earfcn_index - 3);
2155 }
2156 }
2157}
2158
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02002159function f_test_si2quater(integer total_earfcns, template SystemInformationConfig expect_si,
2160 template CellSelIndValue expect_cells := omit) runs on test_CT {
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002161
2162 f_init(0);
2163
2164 /* E-ARFCN 111 is already added in the osmo-bsc.cfg, so only add more arfcns if total_earfcns > 1 */
2165 for (var integer i := 1; i < total_earfcns; i := i + 1) {
Neels Hofmeyr56f24782020-07-09 00:50:49 +02002166 f_bts_0_cfg(BSCVTY, {"si2quater neighbor-list add earfcn " & int2str(f_test_si2quater_earfcn_by_idx(i))
2167 & " thresh-hi 20 thresh-lo 10 prio 3 qrxlv 22 meas 3"});
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002168 }
2169
2170 f_init_bts_and_check_sysinfo(0, expect_si := expect_si);
2171
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02002172 f_init(1);
2173
2174 if (not istemplatekind(expect_cells, "omit")) {
2175 /* Also check that RR Channel Release contains these EARFCNs.
2176 * (copied code from TC_chan_rel_hard_clear_csfb) */
2177 var BSSAP_N_DATA_ind rx_di;
2178 var DchanTuple dt;
2179
2180 dt := f_est_dchan('23'O, 23, '00010203040506'O);
2181
2182 /* Instruct BSC to clear channel */
2183 var BssmapCause cause := 0;
2184 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommandCSFB(cause)));
2185
2186 /* expect Clear Complete from BSC on A */
2187 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete)) {
2188 /* release the SCCP connection */
2189 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
2190 }
2191
2192 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false, is_csfb := true,
2193 csfb_expect_cells := expect_cells);
2194 }
2195
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002196 for (var integer i := 1; i < total_earfcns; i := i + 1) {
Neels Hofmeyr56f24782020-07-09 00:50:49 +02002197 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 +02002198 }
2199}
2200
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002201private function f_tr_si2quater_earfcns(integer count) return template SI2quaterRestOctetsList
2202{
2203 var template SI2quaterRestOctetsList si2quater := {};
2204 var integer si2quater_count := (count + 2) / 3;
2205
2206 for (var integer i := 0; i < count; i := i + 1) {
Neels Hofmeyr56f24782020-07-09 00:50:49 +02002207 var integer earfcn := f_test_si2quater_earfcn_by_idx(i);
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002208 var integer index := i / 3;
2209 var integer earfcn_index := i mod 3;
2210 if (index >= lengthof(si2quater)) {
2211 si2quater[index] := tr_SI2quaterRestOctets_EUTRAN(index := index, count := si2quater_count - 1);
2212 }
2213 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);
2214 }
2215
2216 return si2quater;
2217}
2218
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02002219private function f_tr_rr_chan_rel_earfcns(integer count) return template CellSelIndValue
2220{
2221 var template CellSelIndValue_EUTRAN_Descrs cells := {};
2222
2223 for (var integer i := 0; i < count; i := i + 1) {
2224 var integer earfcn := f_test_si2quater_earfcn_by_idx(i);
2225 cells[i] := tr_CellSelIndValue_EUTRAN_Descr(earfcn, meas_bw_presence := '0'B, meas_bw := omit);
2226 }
2227
2228 return tr_CellSelIndValue_EUTRAN(cells);
2229}
2230
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002231private function f_tc_si2quater_n_earfcns(integer n) runs on test_CT
2232{
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002233 var template SystemInformationConfig sic := SystemInformationConfig_default;
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002234 sic.si2quater := f_tr_si2quater_earfcns(n);
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02002235 var template CellSelIndValue cells := f_tr_rr_chan_rel_earfcns(n);
2236 f_test_si2quater(n, sic, cells);
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002237}
2238
2239testcase TC_si2quater_2_earfcns() runs on test_CT {
2240 f_tc_si2quater_n_earfcns(2);
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002241}
2242
2243testcase TC_si2quater_3_earfcns() runs on test_CT {
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002244 f_tc_si2quater_n_earfcns(3);
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002245}
2246
2247testcase TC_si2quater_4_earfcns() runs on test_CT {
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002248 f_tc_si2quater_n_earfcns(4);
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002249}
2250
2251testcase TC_si2quater_5_earfcns() runs on test_CT {
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002252 f_tc_si2quater_n_earfcns(5);
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002253}
2254
2255testcase TC_si2quater_6_earfcns() runs on test_CT {
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002256 f_tc_si2quater_n_earfcns(6);
2257}
2258
2259testcase TC_si2quater_12_earfcns() runs on test_CT {
2260 f_tc_si2quater_n_earfcns(12);
2261}
2262
2263testcase TC_si2quater_23_earfcns() runs on test_CT {
2264 f_tc_si2quater_n_earfcns(23);
2265}
2266
2267testcase TC_si2quater_32_earfcns() runs on test_CT {
2268 f_tc_si2quater_n_earfcns(32);
2269}
2270
2271testcase TC_si2quater_33_earfcns() runs on test_CT {
2272 f_tc_si2quater_n_earfcns(33);
2273}
2274
2275testcase TC_si2quater_42_earfcns() runs on test_CT {
2276 f_tc_si2quater_n_earfcns(42);
2277}
2278
2279testcase TC_si2quater_48_earfcns() runs on test_CT {
2280 f_tc_si2quater_n_earfcns(48);
2281}
2282
2283/* verify the VTY error response when adding too many EARFCNs, and showing that osmo-bsc still sends 16 SI2quater with
2284 * 48 EARFCNs. */
2285testcase TC_si2quater_49_earfcns() runs on test_CT {
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002286 var template SystemInformationConfig sic := SystemInformationConfig_default;
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002287 sic.si2quater := f_tr_si2quater_earfcns(48); /* 48, not 49! */
2288 f_init(0);
2289
2290 for (var integer i := 1; i < 48; i := i + 1) {
Neels Hofmeyr56f24782020-07-09 00:50:49 +02002291 f_bts_0_cfg(BSCVTY, {"si2quater neighbor-list add earfcn " & int2str(f_test_si2quater_earfcn_by_idx(i))
2292 & " thresh-hi 20 thresh-lo 10 prio 3 qrxlv 22 meas 3"});
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002293 }
2294
2295 /* The 49th EARFCN no longer fits, expect VTY error */
2296 f_vty_enter_cfg_bts(BSCVTY, 0);
2297 var charstring vty_error;
2298 vty_error := f_vty_transceive_ret(BSCVTY,
2299 "si2quater neighbor-list add earfcn 70 thresh-hi 20 thresh-lo 10 prio 3 qrxlv 22 meas 3")
2300 f_vty_transceive(BSCVTY, "end");
2301
2302 if (f_strstr(vty_error, "Unable to add ARFCN 70") >= 0) {
2303 log("Got expected VTY error: ", vty_error);
2304 setverdict(pass);
2305 } else {
2306 setverdict(fail, "Expected the 49th EUTRAN ARFCN to be rejected by vty config, got: ", vty_error);
2307 }
2308
2309 f_init_bts_and_check_sysinfo(0, expect_si := sic);
2310
2311 for (var integer i := 1; i < 48; i := i + 1) {
Neels Hofmeyr56f24782020-07-09 00:50:49 +02002312 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 +02002313 }
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002314}
2315
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02002316private function f_acc09_count_allowed(AccessControlClass acc) return uint8_t
2317{
2318 var uint8_t count := 0;
2319 for (var integer i := 5; i < 16; i := i + 1) {
2320 if (acc[i] == '0'B) { /* the list marks barred, we count allowed */
2321 count := count + 1;
2322 }
2323 }
2324 return count;
2325}
2326
Pau Espin Pedrolc6136cd2020-07-24 13:20:02 +02002327private function f_recv_next_si1(integer rsl_idx := 0) runs on test_CT return SystemInformationType1
2328{
2329 var ASP_RSL_Unitdata rx_rsl_ud;
2330 var SystemInformationType1 last_si1;
2331
2332 timer T := 30.0;
2333 T.start;
2334 alt {
2335 [] IPA_RSL[rsl_idx].receive(tr_ASP_RSL_UD((tr_RSL_NO_BCCH_INFO,
2336 tr_RSL_BCCH_INFO,
2337 tr_RSL_NO_SACCH_FILL,
2338 tr_RSL_SACCH_FILL))
2339 ) -> value rx_rsl_ud {
2340 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
2341 if (g_system_information[rsl_idx].si1 == omit) {
2342 repeat;
2343 }
2344 last_si1 := g_system_information[rsl_idx].si1;
2345 g_system_information[rsl_idx].si1 := omit;
2346 T.stop;
2347 }
2348 [] T.timeout { setverdict(fail, "Timeout receiving next SI1"); }
2349 }
2350 return last_si1;
2351}
2352
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02002353/* verify ACC rotate feature */
2354testcase TC_si_acc_rotate() runs on test_CT {
2355 var template SystemInformationConfig sic := SystemInformationConfig_default;
Pau Espin Pedrolc6136cd2020-07-24 13:20:02 +02002356 var SystemInformationType1 last_si1;
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02002357 var AccessControlClass acc;
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02002358 var uint8_t count;
2359 var integer times_allowed[10] := { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
2360
2361 f_init(0, guard_timeout := 60.0);
2362
2363 f_bts_0_cfg(BSCVTY, {"rach access-control-class 5 barred",
2364 "access-control-class-rotate 3",
2365 "access-control-class-rotate-quantum 1"});
2366
2367 /* Init and get first sysinfo */
2368 f_init_bts_and_check_sysinfo(0, expect_si := ?);
2369
Pau Espin Pedrolc6136cd2020-07-24 13:20:02 +02002370 for (var integer i:= 0; i < 20; i := i + 1) {
2371 last_si1 := f_recv_next_si1(0);
2372 acc := last_si1.rach_control.acc;
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02002373 count := f_acc09_count_allowed(acc);
2374 log("RSL: GOT SI1 ACC len=", count, ": ", acc);
2375
2376 if (count != 3) {
2377 log("RSL: EXPECTED SI ACC len=3");
2378 setverdict(fail, "received SI does not match expectations");
2379 break;
2380 }
2381
2382 for (var integer j := 0; j < 10; j := j + 1) {
2383 if (acc[16 - 1 - j] == '0'B) { /* the list marks barred, we count allowed */
2384 times_allowed[j] := times_allowed[j] + 1;
2385 }
2386 }
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02002387 }
2388
2389 for (var integer j := 0; j < 10; j := j + 1) {
2390 log("ACC", j, " allowed ", times_allowed[j], " times" );
2391 if (j != 5 and times_allowed[j] < 3) {
2392 setverdict(fail, "ACC", j, " ERROR: allowed ", times_allowed[j], " < 1 times");
2393 } else if (j == 5 and times_allowed[j] > 0) {
2394 setverdict(fail, "ACC", j, " ERROR: allowed ", times_allowed[j], " > 0 times");
2395 }
2396 }
2397
2398 f_bts_0_cfg(BSCVTY, {"access-control-class-rotate 10",
2399 "rach access-control-class 5 allowed"});
2400}
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002401
Pau Espin Pedrolc6136cd2020-07-24 13:20:02 +02002402/* verify ACC startup ramp+rotate feature */
2403testcase TC_si_acc_ramp_rotate() runs on test_CT {
2404 var template SystemInformationConfig sic := SystemInformationConfig_default;
2405 var SystemInformationType1 last_si1;
2406 var AccessControlClass acc;
2407 var ASP_RSL_Unitdata rx_rsl_ud;
2408 var uint8_t count;
2409 var uint8_t prev_count;
2410 var integer times_allowed[10] := { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
2411
2412 f_init(0, guard_timeout := 80.0);
2413
2414 f_bts_0_cfg(BSCVTY, {"rach access-control-class 4 barred",
2415 "access-control-class-rotate 0",
2416 "access-control-class-rotate-quantum 1",
2417 "access-control-class-ramping",
2418 "access-control-class-ramping-step-interval 5",
2419 "access-control-class-ramping-step-size 5"});
2420
2421 /* Init and get first sysinfo */
2422 f_init_bts_and_check_sysinfo(0, expect_si := ?);
2423 last_si1 := g_system_information[0].si1;
2424 acc := last_si1.rach_control.acc;
2425 count := f_acc09_count_allowed(acc);
2426 /* Adm subset size was set to 0 above, so wait until all ACC are barred */
2427 while (count > 0) {
2428 last_si1 := f_recv_next_si1(0);
2429 acc := last_si1.rach_control.acc;
2430 count := f_acc09_count_allowed(acc);
2431 log("RSL: wait len()=0: GOT SI1 ACC len=", count, ": ", acc);
2432 }
2433
2434 /* Increase adm subset size, we should see ramping start up */
2435 f_bts_0_cfg(BSCVTY, {"access-control-class-rotate 10"});
2436 prev_count := 0;
2437 while (true) {
2438 last_si1 := f_recv_next_si1(0);
2439 acc := last_si1.rach_control.acc;
2440 count := f_acc09_count_allowed(acc);
2441 log("RSL: GOT SI1 ACC len=", count, ": ", acc);
2442
2443 if (prev_count > count) {
2444 setverdict(fail, "ACC allowed count dropped while expecting grow: ", prev_count, " -> ", count);
2445 break;
2446 }
2447
2448 if (count == 9) {
2449 break; /* Maximum reached (10 - 1 perm barred), done here */
2450 }
2451
2452 prev_count := count;
2453 }
2454
2455 setverdict(pass);
2456
2457 f_bts_0_cfg(BSCVTY, {"access-control-class-rotate 10",
2458 "rach access-control-class 4 allowed",
2459 "no access-control-class-ramping"});
2460}
2461
Harald Welte4003d112017-12-09 22:35:39 +01002462testcase TC_ctrl_msc_connection_status() runs on test_CT {
2463 var charstring ctrl_resp;
2464
Harald Welte89d42e82017-12-17 16:42:41 +01002465 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +01002466
2467 /* See https://osmocom.org/issues/2729 */
2468 f_ctrl_get_exp(IPA_CTRL, "msc_connection_status", "connected");
2469 setverdict(pass);
2470}
2471
Stefan Sperlingb041b3d2018-01-03 17:14:55 +01002472testcase TC_ctrl_msc0_connection_status() runs on test_CT {
2473 var charstring ctrl_resp;
2474
2475 f_init(1);
Stefan Sperlingb041b3d2018-01-03 17:14:55 +01002476
2477 f_ctrl_get_exp(IPA_CTRL, "msc.0.connection_status", "connected");
2478 setverdict(pass);
2479}
2480
Harald Welte4003d112017-12-09 22:35:39 +01002481testcase TC_ctrl() runs on test_CT {
2482 var charstring ctrl_resp;
2483
Harald Welte89d42e82017-12-17 16:42:41 +01002484 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +01002485
2486 /* all below values must match the osmo-bsc.cfg config file used */
2487
Harald Welte6a129692018-03-17 17:30:14 +01002488 f_ctrl_get_exp(IPA_CTRL, "mcc", "001");
2489 f_ctrl_get_exp(IPA_CTRL, "mnc", "01");
Oliver Smith75aa0202019-08-19 14:17:50 +02002490 f_ctrl_get_exp(IPA_CTRL, "number-of-bts", "4");
Harald Welte4003d112017-12-09 22:35:39 +01002491
2492 var integer bts_nr := 0;
2493 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "location-area-code", "1");
2494 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "cell-identity", "0");
2495 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "oml-connection-state", "connected");
2496 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "gprs-mode", "gprs");
2497 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "rf_state", "operational,unlocked,on");
2498 f_ctrl_get_exp_trx(IPA_CTRL, bts_nr, 0, "arfcn", "871");
2499 f_ctrl_get_exp_trx(IPA_CTRL, bts_nr, 0, "max-power-reduction", "20");
2500
2501 var integer uptime := str2int(f_ctrl_get_bts(IPA_CTRL, bts_nr, "oml-uptime"));
2502 f_sleep(2.0);
2503 if (str2int(f_ctrl_get_bts(IPA_CTRL, bts_nr, "oml-uptime")) < uptime+1) {
2504 setverdict(fail, "oml-uptime not incrementing as expected");
2505 }
2506 /* TODO: Disconnect RSL, imply that OML is disconnected and check for uptime zero? */
2507
2508 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bsc", 0, "paging:attempted", 0);
2509
2510 setverdict(pass);
Harald Welte96c94412017-12-09 03:12:45 +01002511}
2512
Pau Espin Pedrol5a2d7432019-06-07 19:43:45 +02002513/* Verify that Upon receival of SET "location", BSC forwards a TRAP
2514 "location-state" over the SCCPlite IPA conn */
2515testcase TC_ctrl_location() runs on test_CT {
2516 var MSC_ConnHdlr vc_conn;
2517 var integer bts_nr := 0;
2518
2519 f_init(1, true);
2520 f_sleep(1.0);
2521
2522 f_ctrl_set_bts(IPA_CTRL, bts_nr, "location", "1234567,fix3d,0.340000,0.560000,0.780000");
2523 f_ctrl_exp_trap(SCCPLITE_IPA_CTRL, "bts." & int2str(bts_nr) & ".location-state",
2524 "1234567,fix3d,0.340000,0.560000,0.780000,operational,unlocked,on,001,01");
2525
2526 f_ctrl_set(SCCPLITE_IPA_CTRL, "rf_locked", "1");
2527 f_sleep(2.0);
2528
2529 f_ctrl_set_bts(IPA_CTRL, bts_nr, "location", "1234888,fix3d,0.350000,0.570000,0.790000");
2530 f_ctrl_exp_trap(SCCPLITE_IPA_CTRL, "bts." & int2str(bts_nr) & ".location-state",
2531 "1234888,fix3d,0.350000,0.570000,0.790000,operational,locked,off,001,01");
2532
2533 /* should match the one from config */
2534 f_ctrl_set(SCCPLITE_IPA_CTRL, "rf_locked", "0");
2535
2536 setverdict(pass);
2537}
2538
Harald Welte6f521d82017-12-11 19:52:02 +01002539
2540/***********************************************************************
2541 * Paging Testing
2542 ***********************************************************************/
2543
2544type record Cell_Identity {
2545 GsmMcc mcc,
2546 GsmMnc mnc,
2547 GsmLac lac,
2548 GsmCellId ci
2549};
Harald Welte24135bd2018-03-17 19:27:53 +01002550private const Cell_Identity cid := { '001'H, '01'H, 1, 0 };
Stefan Sperling049a86e2018-03-20 15:51:00 +01002551private const Cell_Identity unknown_cid := { '678'H, 'f90'H, 1, 0 };
Harald Welte6f521d82017-12-11 19:52:02 +01002552
Harald Welte5d1a2202017-12-13 19:51:29 +01002553type set of integer BtsIdList;
2554
2555private function f_bts_in_list(integer bts_id, BtsIdList bts_ids) return boolean {
2556 for (var integer j := 0; j < sizeof(bts_ids); j := j + 1) {
2557 if (bts_id == bts_ids[j]) {
2558 return true;
2559 }
2560 }
2561 return false;
2562}
Harald Welte6f521d82017-12-11 19:52:02 +01002563
2564/* core paging test helper function; used by most paging test cases */
2565private function f_pageing_helper(hexstring imsi,
2566 template BSSMAP_FIELD_CellIdentificationList cid_list,
Harald Welte5d1a2202017-12-13 19:51:29 +01002567 BtsIdList bts_ids := { 0 },
Harald Welte6f521d82017-12-11 19:52:02 +01002568 template RSL_ChanNeeded rsl_chneed := omit,
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07002569 template (omit) OCT4 tmsi := omit) runs on test_CT
Harald Welte6f521d82017-12-11 19:52:02 +01002570{
2571 var template BSSMAP_IE_ChannelNeeded bssmap_chneed;
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07002572 var template MobileIdentityV mi;
Harald Welte6f521d82017-12-11 19:52:02 +01002573 var RSL_Message rx_rsl;
2574 var integer paging_group := hex2int(imsi[lengthof(imsi)-1]);
Harald Welte5d1a2202017-12-13 19:51:29 +01002575 var integer i;
Harald Welte6f521d82017-12-11 19:52:02 +01002576
2577 f_init();
Harald Welte6f521d82017-12-11 19:52:02 +01002578
2579 /* Clear the queue, it might still contain stuff like BCCH FILLING */
Harald Weltec3068592018-03-17 19:55:31 +01002580 for (i := 0; i < NUM_BTS; i := i + 1) {
2581 IPA_RSL[i].clear;
Harald Welte5d1a2202017-12-13 19:51:29 +01002582 }
Harald Welte6f521d82017-12-11 19:52:02 +01002583
2584 if (isvalue(rsl_chneed)) {
2585 /* The values of 08.08 3.2.2.36 and 08.58 9.3.40 are luckily identical */
2586 bssmap_chneed := ts_BSSMAP_IE_ChanNeeded(int2bit(enum2int(valueof(rsl_chneed)),2));
2587 } else {
2588 bssmap_chneed := omit;
2589 }
2590
Neels Hofmeyrf246a922020-05-13 02:27:10 +02002591 BSSAP.send(ts_BSSAP_UNITDATA_req(g_bssap[0].sccp_addr_peer, g_bssap[0].sccp_addr_own,
2592 ts_BSSMAP_Paging(imsi, cid_list, tmsi, bssmap_chneed)));
Harald Welte6f521d82017-12-11 19:52:02 +01002593
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07002594 if (not istemplatekind(tmsi, "omit")) {
2595 mi := t_MI_TMSI(tmsi);
Harald Welte6f521d82017-12-11 19:52:02 +01002596 } else {
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07002597 mi := tr_MI_IMSI(imsi);
Harald Welte6f521d82017-12-11 19:52:02 +01002598 }
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07002599
Harald Welte5d1a2202017-12-13 19:51:29 +01002600 for (i := 0; i < sizeof(bts_ids); i := i + 1) {
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07002601 rx_rsl := f_exp_ipa_rx(bts_ids[i], tr_RSL_PAGING_CMD(mi));
Harald Welte5d1a2202017-12-13 19:51:29 +01002602 /* check channel type, paging group */
2603 if (rx_rsl.ies[1].body.paging_group != paging_group) {
2604 setverdict(fail, "Paging for wrong paging group");
2605 }
2606 if (ispresent(rsl_chneed) and
2607 rx_rsl.ies[3].body.chan_needed.chan_needed != valueof(rsl_chneed)) {
2608 setverdict(fail, "RSL Channel Needed != BSSMAP Channel Needed");
2609 }
Harald Welte6f521d82017-12-11 19:52:02 +01002610 }
Harald Welte2fccd982018-01-31 15:48:19 +01002611 f_sleep(2.0);
Harald Welte5d1a2202017-12-13 19:51:29 +01002612 /* do a quick check on all not-included BTSs if they received paging */
2613 for (i := 0; i < NUM_BTS; i := i + 1) {
2614 timer T := 0.1;
2615 if (f_bts_in_list(i, bts_ids)) {
2616 continue;
2617 }
2618 T.start;
2619 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07002620 [] IPA_RSL[i].receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD(mi))) {
Harald Welte5d1a2202017-12-13 19:51:29 +01002621 setverdict(fail, "Paging on BTS ", i, " which is not part of ", bts_ids);
2622 }
2623 [] IPA_RSL[i].receive { repeat; }
2624 [] T.timeout { }
2625 }
Harald Welte6f521d82017-12-11 19:52:02 +01002626 }
2627
2628 setverdict(pass);
2629}
2630
Harald Welte5d1a2202017-12-13 19:51:29 +01002631const BtsIdList c_BtsId_all := { 0, 1, 2 };
Harald Welte751d3eb2018-01-31 15:51:06 +01002632const BtsIdList c_BtsId_none := { };
Harald Welte5d1a2202017-12-13 19:51:29 +01002633const BtsIdList c_BtsId_LAC1 := { 0, 1 };
2634const BtsIdList c_BtsId_LAC2 := { 2 };
2635
Harald Welte6f521d82017-12-11 19:52:02 +01002636/* PAGING by IMSI + TMSI */
2637testcase TC_paging_imsi_nochan() runs on test_CT {
2638 var BSSMAP_FIELD_CellIdentificationList cid_list;
2639 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Philipp Maier8c04b0a2018-02-23 13:48:48 +01002640 f_pageing_helper('001010100000001'H, cid_list, c_BtsId_all, omit, omit);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002641 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002642}
2643
2644/* PAGING by IMSI + TMSI */
2645testcase TC_paging_tmsi_nochan() runs on test_CT {
2646 var BSSMAP_FIELD_CellIdentificationList cid_list;
2647 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01002648 f_pageing_helper('001010100000001'H, cid_list, c_BtsId_all, omit, 'A1B2C301'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002649 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002650}
2651
2652/* Paging with different "channel needed' values */
2653testcase TC_paging_tmsi_any() runs on test_CT {
2654 var BSSMAP_FIELD_CellIdentificationList cid_list;
2655 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01002656 f_pageing_helper('001010100000002'H, cid_list, c_BtsId_all, RSL_CHANNEED_ANY, 'A1B2C302'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002657 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002658}
2659testcase TC_paging_tmsi_sdcch() runs on test_CT {
2660 var BSSMAP_FIELD_CellIdentificationList cid_list;
2661 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01002662 f_pageing_helper('001010100000003'H, cid_list, c_BtsId_all, RSL_CHANNEED_SDCCH, 'A1B2C303'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002663 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002664}
2665testcase TC_paging_tmsi_tch_f() runs on test_CT {
2666 var BSSMAP_FIELD_CellIdentificationList cid_list;
2667 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01002668 f_pageing_helper('001010000000004'H, cid_list, c_BtsId_all, RSL_CHANNEED_TCH_F, 'A1B2C304'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002669 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002670}
2671testcase TC_paging_tmsi_tch_hf() runs on test_CT {
2672 var BSSMAP_FIELD_CellIdentificationList cid_list;
2673 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01002674 f_pageing_helper('001010000000005'H, cid_list, c_BtsId_all, RSL_CHANNEED_TCH_ForH, 'A1B2C305'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002675 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002676}
2677
2678/* Paging by CGI */
2679testcase TC_paging_imsi_nochan_cgi() runs on test_CT {
2680 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2681 cid_list := { cIl_CGI := { ts_BSSMAP_CI_CGI(cid.mcc, cid.mnc, cid.lac, cid.ci) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01002682 f_pageing_helper('001010000000006'H, cid_list, { 0 });
Philipp Maier282ca4b2018-02-27 17:17:00 +01002683 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002684}
2685
2686/* Paging by LAC+CI */
2687testcase TC_paging_imsi_nochan_lac_ci() runs on test_CT {
2688 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2689 cid_list := { cIl_LAC_CI := { ts_BSSMAP_CI_LAC_CI(cid.lac, cid.ci) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01002690 f_pageing_helper('001010000000007'H, cid_list, { 0 });
Philipp Maier282ca4b2018-02-27 17:17:00 +01002691 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002692}
2693
2694/* Paging by CI */
2695testcase TC_paging_imsi_nochan_ci() runs on test_CT {
2696 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2697 cid_list := { cIl_CI := { ts_BSSMAP_CI_CI(cid.ci) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01002698 f_pageing_helper('001010000000008'H, cid_list, { 0 });
Philipp Maier282ca4b2018-02-27 17:17:00 +01002699 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002700}
2701
2702/* Paging by LAI */
2703testcase TC_paging_imsi_nochan_lai() runs on test_CT {
2704 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2705 cid_list := { cIl_LAI := { ts_BSSMAP_CI_LAI(cid.mcc, cid.mnc, cid.lac) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01002706 f_pageing_helper('001010000000009'H, cid_list, c_BtsId_LAC1);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002707 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002708}
2709
2710/* Paging by LAC */
2711testcase TC_paging_imsi_nochan_lac() runs on test_CT {
2712 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2713 cid_list := { cIl_LAC := { ts_BSSMAP_CI_LAC(cid.lac) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01002714 f_pageing_helper('001010000000010'H, cid_list, c_BtsId_LAC1);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002715 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002716}
2717
2718/* Paging by "all in BSS" */
2719testcase TC_paging_imsi_nochan_all() runs on test_CT {
2720 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2721 cid_list := { cIl_allInBSS := ''O };
Harald Welte5d1a2202017-12-13 19:51:29 +01002722 f_pageing_helper('001010000000011'H, cid_list, c_BtsId_all);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002723 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002724}
2725
Stefan Sperling7b5e1782018-03-20 19:32:43 +01002726/* Paging by PLMN+LAC+RNC; We do not implement this; Verify nothing is paged */
Harald Welte751d3eb2018-01-31 15:51:06 +01002727testcase TC_paging_imsi_nochan_plmn_lac_rnc() runs on test_CT {
2728 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2729 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 +01002730 f_pageing_helper('001010000000012'H, cid_list, c_BtsId_none);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002731 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01002732}
Harald Welte6f521d82017-12-11 19:52:02 +01002733
Stefan Sperling7b5e1782018-03-20 19:32:43 +01002734/* Paging by RNC; We do not implement this; Verify nothing is paged */
Harald Welte751d3eb2018-01-31 15:51:06 +01002735testcase TC_paging_imsi_nochan_rnc() runs on test_CT {
2736 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2737 cid_list := { cIl_RNC := { int2oct(13, 2) } };
Stefan Sperling7b5e1782018-03-20 19:32:43 +01002738 f_pageing_helper('001010000000013'H, cid_list, c_BtsId_none);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002739 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01002740}
2741
Stefan Sperling7b5e1782018-03-20 19:32:43 +01002742/* Paging by LAC+RNC; We do not implement; Verify nothing is paged */
Harald Welte751d3eb2018-01-31 15:51:06 +01002743testcase TC_paging_imsi_nochan_lac_rnc() runs on test_CT {
2744 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2745 cid_list := { cIl_LAC_RNC := { ts_BSSMAP_CI_LAC_RNC(cid.lac, 14) } };
Stefan Sperling7b5e1782018-03-20 19:32:43 +01002746 f_pageing_helper('001010000000014'H, cid_list, c_BtsId_none);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002747 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01002748}
2749
Harald Welte6f521d82017-12-11 19:52:02 +01002750/* Paging on multiple cells (multiple entries in list): Verify all of them page */
Harald Welte751d3eb2018-01-31 15:51:06 +01002751testcase TC_paging_imsi_nochan_lacs() runs on test_CT {
2752 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2753 cid_list := { cIl_LAC := { ts_BSSMAP_CI_LAC(1), ts_BSSMAP_CI_LAC(2) } };
2754 f_pageing_helper('001010000000015'H, cid_list, c_BtsId_all);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002755 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01002756}
2757
2758/* Paging on empty list: Verify none of them page */
2759testcase TC_paging_imsi_nochan_lacs_empty() runs on test_CT {
2760 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2761 cid_list := { cIl_LAC := { } };
2762 f_pageing_helper('001010000000016'H, cid_list, c_BtsId_none);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002763 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01002764}
2765
Stefan Sperling049a86e2018-03-20 15:51:00 +01002766/* Paging by CGI with unknown MCC/MNC: Verify nothing is paged. */
2767testcase TC_paging_imsi_nochan_cgi_unknown_cid() runs on test_CT {
2768 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2769 cid_list := { cIl_CGI := { ts_BSSMAP_CI_CGI(unknown_cid.mcc, unknown_cid.mnc, unknown_cid.lac, unknown_cid.ci) } };
2770 f_pageing_helper('001010000000006'H, cid_list, c_BtsId_none);
2771 f_shutdown_helper();
2772}
2773
Harald Welte6f521d82017-12-11 19:52:02 +01002774/* Verify paging retransmission interval + count */
2775/* Verify paging stops after channel establishment */
Harald Welte6f521d82017-12-11 19:52:02 +01002776/* Test behavior under paging overload */
Harald Welteae026692017-12-09 01:03:01 +01002777
Harald Weltee65d40e2017-12-13 00:09:06 +01002778/* Verify PCH load */
2779testcase TC_paging_imsi_load() runs on test_CT {
2780 var BSSMAP_FIELD_CellIdentificationList cid_list;
2781 timer T := 4.0;
Harald Welte2caa1062018-03-17 18:19:05 +01002782 timer T_retrans := 1.0;
Harald Weltee65d40e2017-12-13 00:09:06 +01002783 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01002784 f_pageing_helper('001010123456789'H, cid_list, c_BtsId_all);
Harald Weltee65d40e2017-12-13 00:09:06 +01002785
2786 /* tell BSC there is no paging space anymore */
2787 f_ipa_tx(0, ts_RSL_PAGING_LOAD_IND(0));
Harald Welte3b57ab52018-03-17 18:01:10 +01002788 f_sleep(0.2);
2789 IPA_RSL[0].clear;
Harald Weltee65d40e2017-12-13 00:09:06 +01002790
2791 /* Wait for 4 seconds if any more PAGING CMD are received on RSL. Normally,
2792 * there would be 8 retransmissions during 4 seconds */
2793 T.start;
Harald Welte2caa1062018-03-17 18:19:05 +01002794 T_retrans.start;
Harald Weltee65d40e2017-12-13 00:09:06 +01002795 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07002796 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD(?))) {
Harald Weltee65d40e2017-12-13 00:09:06 +01002797 setverdict(fail, "Received PAGING after LOAD_IND(0)");
Daniel Willmannafce8662018-07-06 23:11:32 +02002798 mtc.stop;
Harald Weltee65d40e2017-12-13 00:09:06 +01002799 }
Harald Welte2caa1062018-03-17 18:19:05 +01002800 [] T_retrans.timeout {
2801 /* re-trnsmit the zero-space LOAD IND to avoid BSC 'auto credit' */
2802 f_ipa_tx(0, ts_RSL_PAGING_LOAD_IND(0));
2803 T_retrans.start;
2804 repeat;
2805 }
Harald Weltee65d40e2017-12-13 00:09:06 +01002806 [] T.timeout {
2807 setverdict(pass);
2808 }
2809 }
Philipp Maier282ca4b2018-02-27 17:17:00 +01002810
2811 f_shutdown_helper();
Harald Weltee65d40e2017-12-13 00:09:06 +01002812}
2813
Harald Welte235ebf12017-12-15 14:18:16 +01002814/* Verify Paging Counter */
Harald Welte1ff69992017-12-14 12:31:17 +01002815testcase TC_paging_counter() runs on test_CT {
2816 var BSSMAP_FIELD_CellIdentificationList cid_list;
2817 timer T := 4.0;
2818 var integer i;
2819 var integer paging_attempted_bsc;
2820 var integer paging_attempted_bts[NUM_BTS];
2821 var integer paging_expired_bts[NUM_BTS];
2822 cid_list := valueof(ts_BSSMAP_CIL_noCell);
2823
2824 f_init();
2825
2826 /* read counters before paging */
2827 paging_attempted_bsc := f_ctrl_get_ratectr_abs(IPA_CTRL, "bsc", 0, "paging:attempted");
2828 for (i := 0; i < NUM_BTS; i := i+1) {
2829 paging_attempted_bts[i] := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", i, "paging:attempted");
2830 paging_expired_bts[i] := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", i, "paging:expired");
2831 }
2832
2833 f_pageing_helper('001230000000001'H, cid_list, c_BtsId_all);
2834
2835 /* expect the attempted pages on BSC and each BTSs to have incremented by one */
2836 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bsc", 0, "paging:attempted", paging_attempted_bsc+1);
2837 for (i := 0; i < NUM_BTS; i := i+1) {
2838 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", i, "paging:attempted",
2839 paging_attempted_bts[i]+1);
2840 }
2841
2842 /* assume that 12s later the paging on all BTSs have expired and hence incremented by 1 */
2843 f_sleep(12.0);
2844 for (i := 0; i < NUM_BTS; i := i+1) {
2845 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", i, "paging:expired",
2846 paging_expired_bts[i]+1);
2847 }
Harald Welte1ff69992017-12-14 12:31:17 +01002848
Philipp Maier282ca4b2018-02-27 17:17:00 +01002849 f_shutdown_helper();
Harald Welte1ff69992017-12-14 12:31:17 +01002850}
2851
2852
Harald Welte10985002017-12-12 09:29:15 +01002853/* Verify paging stops after A-RESET */
2854testcase TC_paging_imsi_a_reset() runs on test_CT {
2855 var BSSMAP_FIELD_CellIdentificationList cid_list;
2856 timer T := 3.0;
2857 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01002858 f_pageing_helper('001010123456789'H, cid_list, c_BtsId_all);
Harald Welte10985002017-12-12 09:29:15 +01002859
2860 /* Perform a BSSMAP Reset and wait for ACK */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02002861 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 +01002862 alt {
Neels Hofmeyrf246a922020-05-13 02:27:10 +02002863 [] 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 +01002864 [] BSSAP.receive { repeat; }
2865 }
2866
Daniel Willmanncbef3982018-07-30 09:22:40 +02002867 /* Wait to avoid a possible race condition if a paging message is
2868 * received right before the reset ACK. */
2869 f_sleep(0.2);
2870
Harald Welte10985002017-12-12 09:29:15 +01002871 /* Clear the queue, it might still contain stuff like BCCH FILLING */
Philipp Maier1e6b4422018-02-23 14:02:13 +01002872 for (var integer i := 0; i < sizeof(IPA_RSL); i := i+1) {
2873 IPA_RSL[i].clear;
2874 }
Harald Welte10985002017-12-12 09:29:15 +01002875
2876 /* Wait for 3 seconds if any more PAGING CMD are received on RSL */
2877 T.start;
2878 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07002879 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD(?))) {
Harald Welte10985002017-12-12 09:29:15 +01002880 setverdict(fail, "Received PAGING after A-RESET");
Daniel Willmannafce8662018-07-06 23:11:32 +02002881 mtc.stop;
Harald Welte10985002017-12-12 09:29:15 +01002882 }
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07002883 [] IPA_RSL[1].receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD(?))) {
Harald Welte5d1a2202017-12-13 19:51:29 +01002884 setverdict(fail, "Received PAGING after A-RESET");
Daniel Willmannafce8662018-07-06 23:11:32 +02002885 mtc.stop;
Harald Welte5d1a2202017-12-13 19:51:29 +01002886 }
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07002887 [] IPA_RSL[2].receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD(?))) {
Harald Welte5d1a2202017-12-13 19:51:29 +01002888 setverdict(fail, "Received PAGING after A-RESET");
Daniel Willmannafce8662018-07-06 23:11:32 +02002889 mtc.stop;
Harald Welte5d1a2202017-12-13 19:51:29 +01002890 }
Harald Welte10985002017-12-12 09:29:15 +01002891 [] T.timeout {
2892 setverdict(pass);
2893 }
2894 }
Philipp Maier282ca4b2018-02-27 17:17:00 +01002895
2896 f_shutdown_helper();
Harald Welte10985002017-12-12 09:29:15 +01002897}
Harald Welteae026692017-12-09 01:03:01 +01002898
Philipp Maierf45824a2019-08-14 14:44:10 +02002899/* Verify how we handle unsolicited Paging Response. In case of an unsolicit
2900 * paging response we can not know which MSC is in charge, so we will blindly
2901 * pick the first configured MSC. This behavior is required in order to make
2902 * MT-CSFB calls working because in those cases the BSC can not know that the
2903 * MSC has already paged the subscriver via SGs. So any MT-CSFB call will look
2904 * like an unsolicited Paging Response to the MSC.
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01002905 */
2906testcase TC_paging_resp_unsol() runs on test_CT {
2907
2908 f_init(1);
Philipp Maierf45824a2019-08-14 14:44:10 +02002909 timer T := 5.0;
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01002910
2911 var BSSAP_N_CONNECT_ind rx_c_ind;
2912 var DchanTuple dt;
2913 var PDU_ML3_MS_NW l3 := valueof(ts_PAG_RESP(valueof(ts_MI_IMSI_LV('001010008880018'H))));
Philipp Maierf45824a2019-08-14 14:44:10 +02002914 var octetstring rr_pag_resp := enc_PDU_ML3_MS_NW(l3);
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01002915
2916 /* Send CHAN RQD and wait for allocation; acknowledge it */
2917 dt.rsl_chan_nr := f_chreq_act_ack();
2918
2919 /* Send unsolicited Paging response (no matching Paging CMD stored in BSC) */
2920 f_ipa_tx(0, ts_RSL_EST_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0)), enc_PDU_ML3_MS_NW(l3)));
2921
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01002922
Philipp Maierf45824a2019-08-14 14:44:10 +02002923 /* Expevct a CR with a matching Paging response on the A-Interface */
2924 T.start;
2925 alt {
2926 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(rr_pag_resp))) {
2927 setverdict(pass);
2928 }
2929 [] BSSAP.receive {
2930 setverdict(fail, "Received unexpected message on A-Interface!");
2931 }
2932 [] T.timeout {
2933 setverdict(fail, "Received nothing on A-Interface!");
2934 }
2935 }
2936
2937 setverdict(pass);
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01002938}
2939
Harald Welte4e9b9cc2017-12-14 18:31:02 +01002940/* Test RSL link drop causes counter increment */
2941testcase TC_rsl_drop_counter() runs on test_CT {
2942 var integer rsl_fail;
2943
Harald Welte89d42e82017-12-17 16:42:41 +01002944 f_init(1);
Harald Welte4e9b9cc2017-12-14 18:31:02 +01002945
2946 rsl_fail := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "rsl_fail");
2947
2948 bts[0].rsl.vc_IPA.stop;
2949
2950 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "rsl_fail", rsl_fail+1);
2951
2952 setverdict(pass);
2953}
2954
2955/* TODO: Test OML link drop causes counter increment */
2956
Stefan Sperling830dc9d2018-02-12 21:08:28 +01002957/* The body of TC_rsl_unknown_unit_id() and TC_oml_unknown_unit_id() tests. */
2958function f_ipa_unknown_unit_id(integer mp_bsc_ipa_port) runs on test_CT return boolean {
2959 timer T := 10.0;
2960
2961 bts[0].rsl.id := "IPA-0-RSL";
2962 bts[0].rsl.vc_IPA := IPA_Emulation_CT.create(bts[0].rsl.id & "-IPA");
2963 bts[0].rsl.ccm_pars := c_IPA_default_ccm_pars;
2964 bts[0].rsl.ccm_pars.name := "Osmocom TTCN-3 BTS Simulator";
Oliver Smith92c2bdb2019-08-20 15:11:24 +02002965 bts[0].rsl.ccm_pars.unit_id := "99/0/0"; /* value which is unknown at BTS */
Stefan Sperling830dc9d2018-02-12 21:08:28 +01002966
Stefan Sperling830dc9d2018-02-12 21:08:28 +01002967 f_ipa_ctrl_start(mp_bsc_ip, mp_bsc_ctrl_port);
2968
2969 f_init_mgcp("VirtMSC");
2970
2971 /* start RSL/OML connection (XXX re-uses RSL port/protocol definitions for OML) */
2972 map(bts[0].rsl.vc_IPA:IPA_PORT, system:IPA);
2973 connect(bts[0].rsl.vc_IPA:IPA_RSL_PORT, self:IPA_RSL[0]);
2974 bts[0].rsl.vc_IPA.start(IPA_Emulation.main_client(mp_bsc_ip, mp_bsc_ipa_port, "", 10000, bts[0].rsl.ccm_pars));
2975
2976 /* wait for IPA OML link to connect and then disconnect */
2977 T.start;
2978 alt {
Vadim Yanitskiya2afacc2020-05-18 21:16:19 +07002979 [] IPA_RSL[0].receive(tr_ASP_IPA_EV(ASP_IPA_EVENT_DOWN)) {
Stefan Sperling830dc9d2018-02-12 21:08:28 +01002980 T.stop;
2981 return true;
2982 }
2983 [] IPA_RSL[0].receive { repeat }
2984 [] T.timeout {
Daniel Willmannafce8662018-07-06 23:11:32 +02002985 return false;
Stefan Sperling830dc9d2018-02-12 21:08:28 +01002986 }
2987 }
Stefan Sperling830dc9d2018-02-12 21:08:28 +01002988 return false;
2989}
2990
2991/* BSC should close an RSL connection from a BTS with unknown unit ID (OS#2714). */
2992testcase TC_rsl_unknown_unit_id() runs on test_CT {
2993 if (f_ipa_unknown_unit_id(mp_bsc_rsl_port)) {
2994 setverdict(pass);
2995 } else {
2996 setverdict(fail, "Timeout RSL waiting for connection to close");
2997 }
2998}
2999
3000
3001/* BSC should close an RSL connection from a BTS with unknown unit ID (OS#2714). */
3002testcase TC_oml_unknown_unit_id() runs on test_CT {
3003 if (f_ipa_unknown_unit_id(mp_bsc_oml_port)) {
3004 setverdict(pass);
3005 } else {
3006 setverdict(fail, "Timeout OML waiting for connection to close");
3007 }
3008}
3009
3010
Harald Weltec1a2fff2017-12-17 11:06:19 +01003011/***********************************************************************
Harald Welte6811d102019-04-14 22:23:14 +02003012 * "New world" test cases using RSL_Emulation + RAN_Emulation
Harald Weltec1a2fff2017-12-17 11:06:19 +01003013 ***********************************************************************/
3014
Harald Welte6811d102019-04-14 22:23:14 +02003015import from RAN_Emulation all;
Harald Weltec1a2fff2017-12-17 11:06:19 +01003016import from RSL_Emulation all;
3017import from MSC_ConnectionHandler all;
3018
3019type function void_fn(charstring id) runs on MSC_ConnHdlr;
3020
Harald Welte336820c2018-05-31 20:34:52 +02003021/* helper function to create and connect a MSC_ConnHdlr component */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003022private function f_connect_handler(inout MSC_ConnHdlr vc_conn, integer bssap_idx := 0) runs on test_CT {
3023 connect(vc_conn:RAN, g_bssap[bssap_idx].vc_RAN:PROC);
Daniel Willmann191e0d92018-01-17 12:44:35 +01003024 connect(vc_conn:MGCP_PROC, vc_MGCP:MGCP_PROC);
Harald Weltec1a2fff2017-12-17 11:06:19 +01003025 connect(vc_conn:RSL, bts[0].rsl.vc_RSL:CLIENT_PT);
Harald Weltef70df652018-01-29 22:00:23 +01003026 connect(vc_conn:RSL_PROC, bts[0].rsl.vc_RSL:RSL_PROC);
Philipp Maier88f4ae82018-03-01 14:00:58 +01003027 if (isvalue(bts[1])) {
Philipp Maier956a92f2018-02-16 10:58:07 +01003028 connect(vc_conn:RSL1, bts[1].rsl.vc_RSL:CLIENT_PT);
3029 connect(vc_conn:RSL1_PROC, bts[1].rsl.vc_RSL:RSL_PROC);
3030 }
Neels Hofmeyr91401012019-07-11 00:42:35 +02003031 if (isvalue(bts[2])) {
3032 connect(vc_conn:RSL2, bts[2].rsl.vc_RSL:CLIENT_PT);
3033 connect(vc_conn:RSL2_PROC, bts[2].rsl.vc_RSL:RSL_PROC);
3034 }
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003035 connect(vc_conn:BSSAP, g_bssap[bssap_idx].vc_RAN:CLIENT);
Daniel Willmann191e0d92018-01-17 12:44:35 +01003036 connect(vc_conn:MGCP, vc_MGCP:MGCP_CLIENT);
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +02003037 connect(vc_conn:MGCP_MULTI, vc_MGCP:MGCP_CLIENT_MULTI);
Daniel Willmannebdecc02020-08-12 15:30:17 +02003038 connect(vc_conn:STATSD_PROC, vc_STATSD:STATSD_PROC);
Harald Welte336820c2018-05-31 20:34:52 +02003039}
3040
3041function f_start_handler(void_fn fn, template (omit) TestHdlrParams pars := omit)
3042runs on test_CT return MSC_ConnHdlr {
3043 var charstring id := testcasename();
3044 var MSC_ConnHdlr vc_conn;
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003045 var integer bssap_idx := 0;
3046 if (isvalue(pars)) {
3047 bssap_idx := valueof(pars).mscpool.bssap_idx;
3048 }
Harald Welte336820c2018-05-31 20:34:52 +02003049 vc_conn := MSC_ConnHdlr.create(id);
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003050 f_connect_handler(vc_conn, bssap_idx);
Harald Weltea0630032018-03-20 21:09:55 +01003051 vc_conn.start(f_handler_init(fn, id, pars));
Harald Weltec1a2fff2017-12-17 11:06:19 +01003052 return vc_conn;
3053}
3054
Harald Weltea0630032018-03-20 21:09:55 +01003055/* first function inside ConnHdlr component; sets g_pars + starts function */
3056private function f_handler_init(void_fn fn, charstring id, template (omit) TestHdlrParams pars := omit)
3057runs on MSC_ConnHdlr {
3058 if (isvalue(pars)) {
3059 g_pars := valueof(pars);
3060 }
3061 fn.apply(id);
3062}
3063
Harald Welte3c86ea02018-05-10 22:28:05 +02003064/* Establish signalling channel (non-assignment case) followed by cipher mode */
3065private function f_tc_ciph_mode_a5(charstring id) runs on MSC_ConnHdlr {
Harald Welteed848512018-05-24 22:27:58 +02003066 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3067 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte3c86ea02018-05-10 22:28:05 +02003068 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeSIGNAL);
Philipp Maier23000732018-05-18 11:25:37 +02003069 ass_cmd.pdu.bssmap.assignmentRequest.circuitIdentityCode := omit;
3070 ass_cmd.pdu.bssmap.assignmentRequest.aoIPTransportLayer := omit;
3071 exp_compl.pdu.bssmap.assignmentComplete.circuitIdentityCode := omit;
3072 exp_compl.pdu.bssmap.assignmentComplete.aoIPTransportLayer := omit;
Harald Welte3c86ea02018-05-10 22:28:05 +02003073
Philipp Maier23000732018-05-18 11:25:37 +02003074 f_establish_fully(ass_cmd, exp_compl);
Harald Welte3c86ea02018-05-10 22:28:05 +02003075}
3076testcase TC_ciph_mode_a5_0() runs on test_CT {
3077 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02003078 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte3c86ea02018-05-10 22:28:05 +02003079 pars.encr := valueof(t_EncrParams('01'O, f_rnd_octstring(8)));
3080
3081 f_init(1, true);
3082 f_sleep(1.0);
3083 vc_conn := f_start_handler(refers(f_tc_ciph_mode_a5), pars);
3084 vc_conn.done;
3085}
3086testcase TC_ciph_mode_a5_1() runs on test_CT {
3087 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02003088 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte3c86ea02018-05-10 22:28:05 +02003089 pars.encr := valueof(t_EncrParams('02'O, f_rnd_octstring(8)));
3090
3091 f_init(1, true);
3092 f_sleep(1.0);
3093 vc_conn := f_start_handler(refers(f_tc_ciph_mode_a5), pars);
3094 vc_conn.done;
3095}
3096testcase TC_ciph_mode_a5_3() runs on test_CT {
3097 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02003098 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte3c86ea02018-05-10 22:28:05 +02003099 pars.encr := valueof(t_EncrParams('08'O, f_rnd_octstring(8)));
3100
3101 f_init(1, true);
3102 f_sleep(1.0);
3103 vc_conn := f_start_handler(refers(f_tc_ciph_mode_a5), pars);
3104 vc_conn.done;
3105}
3106
Pau Espin Pedrol07866632020-09-03 19:10:55 +02003107/* establish initial channel, enable ciphering followed by assignment to ciphered channel */
3108private function f_tc_assignment_aoip_tla_v6(charstring id) runs on MSC_ConnHdlr {
3109 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3110 var PDU_BSSAP ass_cmd := f_gen_ass_req(aoip_tla := "::3");
3111 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3112 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
3113
3114 f_establish_fully(ass_cmd, exp_compl);
3115}
3116testcase TC_assignment_aoip_tla_v6() runs on test_CT {
3117 var MSC_ConnHdlr vc_conn;
3118 var TestHdlrParams pars := f_gen_test_hdlr_pars();
3119
3120 f_init(1, true);
3121 f_sleep(1.0);
3122 vc_conn := f_start_handler(refers(f_tc_assignment_aoip_tla_v6), pars);
3123 vc_conn.done;
3124}
3125
Harald Welte3c86ea02018-05-10 22:28:05 +02003126
3127/* establish initial channel, enable ciphering followed by assignment to ciphered channel */
Harald Welte651fcdc2018-05-10 20:23:16 +02003128private function f_tc_assignment_fr_a5(charstring id) runs on MSC_ConnHdlr {
Harald Welteed848512018-05-24 22:27:58 +02003129 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3130 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Weltec1a2fff2017-12-17 11:06:19 +01003131
Harald Welte552620d2017-12-16 23:21:36 +01003132 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3133 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
Harald Welte73cd2712017-12-17 00:44:52 +01003134
Harald Weltea0630032018-03-20 21:09:55 +01003135 f_establish_fully(ass_cmd, exp_compl);
Harald Welte552620d2017-12-16 23:21:36 +01003136}
Harald Welte552620d2017-12-16 23:21:36 +01003137testcase TC_assignment_fr_a5_0() runs on test_CT {
3138 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02003139 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte651fcdc2018-05-10 20:23:16 +02003140 pars.encr := valueof(t_EncrParams('01'O, f_rnd_octstring(8)));
Harald Welte552620d2017-12-16 23:21:36 +01003141
Harald Welte89d42e82017-12-17 16:42:41 +01003142 f_init(1, true);
Harald Welte552620d2017-12-16 23:21:36 +01003143 f_sleep(1.0);
Harald Welte651fcdc2018-05-10 20:23:16 +02003144 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5), pars);
Harald Welte552620d2017-12-16 23:21:36 +01003145 vc_conn.done;
3146}
Harald Welte552620d2017-12-16 23:21:36 +01003147testcase TC_assignment_fr_a5_1() runs on test_CT {
Harald Weltec1a2fff2017-12-17 11:06:19 +01003148 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02003149 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte651fcdc2018-05-10 20:23:16 +02003150 pars.encr := valueof(t_EncrParams('02'O, f_rnd_octstring(8)));
Harald Weltec1a2fff2017-12-17 11:06:19 +01003151
Harald Welte89d42e82017-12-17 16:42:41 +01003152 f_init(1, true);
Harald Weltec1a2fff2017-12-17 11:06:19 +01003153 f_sleep(1.0);
Harald Welte651fcdc2018-05-10 20:23:16 +02003154 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5), pars);
3155 vc_conn.done;
3156}
3157testcase TC_assignment_fr_a5_3() runs on test_CT {
3158 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02003159 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte651fcdc2018-05-10 20:23:16 +02003160 pars.encr := valueof(t_EncrParams('08'O, f_rnd_octstring(8)));
Harald Weltec1a2fff2017-12-17 11:06:19 +01003161
Harald Welte651fcdc2018-05-10 20:23:16 +02003162 f_init(1, true);
3163 f_sleep(1.0);
3164 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5), pars);
Harald Weltec1a2fff2017-12-17 11:06:19 +01003165 vc_conn.done;
3166}
3167
Harald Welte552620d2017-12-16 23:21:36 +01003168/* Expect ASSIGNMENT FAIL if mandatory IE is missing */
3169private function f_tc_assignment_fr_a5_1_codec_missing(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02003170 g_pars := f_gen_test_hdlr_pars();
Harald Welte552620d2017-12-16 23:21:36 +01003171 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
Harald Welteed848512018-05-24 22:27:58 +02003172 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte552620d2017-12-16 23:21:36 +01003173 const OCT8 kc := '0001020304050607'O;
3174
3175 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02003176 /* Omit: ass_cmd.pdu.bssmap.assignmentRequest.codecList */
3177
Harald Weltea0630032018-03-20 21:09:55 +01003178 f_establish_fully(ass_cmd, exp_fail);
Harald Welte552620d2017-12-16 23:21:36 +01003179}
Harald Welte552620d2017-12-16 23:21:36 +01003180testcase TC_assignment_fr_a5_1_codec_missing() runs on test_CT {
3181 var MSC_ConnHdlr vc_conn;
3182
Harald Welte89d42e82017-12-17 16:42:41 +01003183 f_init(1, true);
Harald Welte552620d2017-12-16 23:21:36 +01003184 f_sleep(1.0);
3185
Harald Welte8863fa12018-05-10 20:15:27 +02003186 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5_1_codec_missing));
Harald Welte552620d2017-12-16 23:21:36 +01003187 vc_conn.done;
3188}
3189
Harald Welte552620d2017-12-16 23:21:36 +01003190private function f_tc_assignment_fr_a5_4(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02003191 g_pars := f_gen_test_hdlr_pars();
Harald Welteed848512018-05-24 22:27:58 +02003192 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3193 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte552620d2017-12-16 23:21:36 +01003194 const OCT8 kc := '0001020304050607'O;
3195 const OCT16 kc128 := kc & kc;
3196
3197 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3198 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
Harald Weltea0630032018-03-20 21:09:55 +01003199 f_establish_fully(ass_cmd, exp_compl);
Harald Welte38b2a102017-12-23 02:42:58 +01003200 f_cipher_mode('10'O, kc, kc128, true);
Harald Welte552620d2017-12-16 23:21:36 +01003201 /* TODO: expect GSM0808_CAUSE_CIPHERING_ALGORITHM_NOT_SUPPORTED cause value */
Harald Welte552620d2017-12-16 23:21:36 +01003202}
Harald Welte552620d2017-12-16 23:21:36 +01003203testcase TC_assignment_fr_a5_4() runs on test_CT {
3204 var MSC_ConnHdlr vc_conn;
3205
Harald Welte89d42e82017-12-17 16:42:41 +01003206 f_init(1, true);
Harald Welte552620d2017-12-16 23:21:36 +01003207 f_sleep(1.0);
3208
Harald Welte8863fa12018-05-10 20:15:27 +02003209 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5_4));
Harald Welte552620d2017-12-16 23:21:36 +01003210 vc_conn.done;
3211}
3212
3213
Harald Welte4532e0a2017-12-23 02:05:44 +01003214private function f_tc_assignment_sign(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02003215 g_pars := f_gen_test_hdlr_pars();
Harald Welte4532e0a2017-12-23 02:05:44 +01003216 var template PDU_BSSAP exp_compl := tr_BSSMAP_AssignmentComplete(omit, omit);
Philipp Maier48604732018-10-09 15:00:37 +02003217 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte4532e0a2017-12-23 02:05:44 +01003218 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeSIGNAL);
Daniel Willmannebdecc02020-08-12 15:30:17 +02003219
3220 f_statsd_reset();
Harald Weltea0630032018-03-20 21:09:55 +01003221 f_establish_fully(ass_cmd, exp_compl);
Daniel Willmannebdecc02020-08-12 15:30:17 +02003222
3223 var StatsDExpects expect := {
3224 { name := "TTCN3.bsc.0.assignment.attempted", mtype := "c", min := 1, max := 1},
3225 { name := "TTCN3.bsc.0.assignment.completed", mtype := "c", min := 1, max := 1}
3226 };
3227 f_statsd_expect(expect);
Harald Welte4532e0a2017-12-23 02:05:44 +01003228}
3229
3230testcase TC_assignment_sign() runs on test_CT {
3231 var MSC_ConnHdlr vc_conn;
3232
3233 f_init(1, true);
3234 f_sleep(1.0);
3235
Harald Welte8863fa12018-05-10 20:15:27 +02003236 vc_conn := f_start_handler(refers(f_tc_assignment_sign));
Harald Welte4532e0a2017-12-23 02:05:44 +01003237 vc_conn.done;
3238}
3239
Harald Welte60aa5762018-03-21 19:33:13 +01003240/***********************************************************************
3241 * Codec (list) testing
3242 ***********************************************************************/
3243
3244/* check if the given rsl_mode is compatible with the a_elem */
3245private function f_match_codec(BSSMAP_FIELD_CodecElement a_elem, RSL_IE_ChannelMode rsl_mode)
3246return boolean {
3247 select (a_elem.codecType) {
3248 case (GSM_FR) {
3249 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM1))) {
3250 return true;
3251 }
3252 }
3253 case (GSM_HR) {
3254 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_H, RSL_CMOD_SP_GSM1))) {
3255 return true;
3256 }
3257 }
3258 case (GSM_EFR) {
3259 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM2))) {
3260 return true;
3261 }
3262 }
3263 case (FR_AMR) {
3264 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM3))) {
3265 return true;
3266 }
3267 }
3268 case (HR_AMR) {
3269 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_H, RSL_CMOD_SP_GSM3))) {
3270 return true;
3271 }
3272 }
3273 case else { }
3274 }
3275 return false;
3276}
3277
3278/* check if the given rsl_mode is compatible with the a_list */
3279private function f_match_codecs(BSSMAP_IE_SpeechCodecList a_list, RSL_IE_ChannelMode rsl_mode)
3280return boolean {
3281 for (var integer i := 0; i < sizeof(a_list); i := i+1) {
3282 if (f_match_codec(a_list.codecElements[i], rsl_mode)) {
3283 return true;
3284 }
3285 }
3286 return false;
3287}
3288
3289/* determine BSSMAP_IE_ChannelType from *first* element of BSSMAP_FIELD_CodecElement */
Philipp Maier61f6b572018-07-06 14:03:38 +02003290function f_BSSMAP_chtype_from_codec(BSSMAP_FIELD_CodecElement a_elem)
Harald Welte60aa5762018-03-21 19:33:13 +01003291return BSSMAP_IE_ChannelType {
3292 /* FIXME: actually look at all elements of BSSMAP_IE_SpeechCodecList */
3293 var BSSMAP_IE_ChannelType ret := valueof(ts_BSSMAP_IE_ChannelType);
3294 select (a_elem.codecType) {
3295 case (GSM_FR) {
3296 ret.channelRateAndType := ChRate_TCHF;
3297 ret.speechId_DataIndicator := Spdi_TCHF_FR;
3298 }
3299 case (GSM_HR) {
3300 ret.channelRateAndType := ChRate_TCHH;
3301 ret.speechId_DataIndicator := Spdi_TCHH_HR;
3302 }
3303 case (GSM_EFR) {
3304 ret.channelRateAndType := ChRate_TCHF;
3305 ret.speechId_DataIndicator := Spdi_TCHF_EFR;
3306 }
3307 case (FR_AMR) {
3308 ret.channelRateAndType := ChRate_TCHF;
3309 ret.speechId_DataIndicator := Spdi_TCHF_AMR;
3310 }
3311 case (HR_AMR) {
3312 ret.channelRateAndType := ChRate_TCHH;
3313 ret.speechId_DataIndicator := Spdi_TCHH_AMR;
3314 }
3315 case else {
3316 setverdict(fail, "Unsupported codec ", a_elem);
Daniel Willmannafce8662018-07-06 23:11:32 +02003317 mtc.stop;
Harald Welte60aa5762018-03-21 19:33:13 +01003318 }
3319 }
3320 return ret;
3321}
3322
Harald Weltea63b9102018-03-22 20:36:16 +01003323private function f_rsl_chmod_tmpl_from_codec(BSSMAP_FIELD_CodecElement a_elem)
3324return template RSL_IE_Body {
3325 var template RSL_IE_Body mode_ie := {
3326 chan_mode := {
3327 len := ?,
3328 reserved := ?,
3329 dtx_d := ?,
3330 dtx_u := ?,
3331 spd_ind := RSL_SPDI_SPEECH,
3332 ch_rate_type := -,
3333 coding_alg_rate := -
3334 }
3335 }
3336
3337 select (a_elem.codecType) {
3338 case (GSM_FR) {
3339 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_F;
3340 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM1;
3341 }
3342 case (GSM_HR) {
3343 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_H;
3344 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM1;
3345 }
3346 case (GSM_EFR) {
3347 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_F;
3348 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM2;
3349 }
3350 case (FR_AMR) {
3351 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_F;
3352 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM3;
3353 }
3354 case (HR_AMR) {
3355 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_H;
3356 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM3;
3357 }
3358 }
3359 return mode_ie;
3360}
3361
Harald Welte60aa5762018-03-21 19:33:13 +01003362type record CodecListTest {
3363 BSSMAP_IE_SpeechCodecList codec_list,
3364 charstring id
3365}
3366type record of CodecListTest CodecListTests
3367
3368private function f_TC_assignment_codec(charstring id) runs on MSC_ConnHdlr {
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02003369 var PDU_BSSAP ass_cmd := f_gen_ass_req(g_pars.use_osmux);
3370 var template PDU_BSSAP exp_compl := f_gen_exp_compl(g_pars.use_osmux);
Harald Welte60aa5762018-03-21 19:33:13 +01003371
3372 /* puzzle together the ASSIGNMENT REQ for given codec[s] */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003373 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
Harald Welte79f3f542018-05-25 20:02:37 +02003374 ass_cmd.pdu.bssmap.assignmentRequest.codecList := g_pars.ass_codec_list;
3375 exp_compl.pdu.bssmap.assignmentComplete.speechCodec.codecElements[0] :=
3376 g_pars.ass_codec_list.codecElements[0];
Philipp Maierd0e64b02019-03-13 14:15:23 +01003377 if (isvalue(g_pars.expect_mr_s0_s7)) {
3378 exp_compl.pdu.bssmap.assignmentComplete.speechCodec.codecElements[0].s0_7 :=
3379 g_pars.expect_mr_s0_s7;
3380 }
Harald Welte79f3f542018-05-25 20:02:37 +02003381 }
Harald Welte60aa5762018-03-21 19:33:13 +01003382 ass_cmd.pdu.bssmap.assignmentRequest.channelType :=
3383 f_BSSMAP_chtype_from_codec(g_pars.ass_codec_list.codecElements[0]);
Harald Welte60aa5762018-03-21 19:33:13 +01003384 log("expecting ASS COMPL like this: ", exp_compl);
3385
3386 f_establish_fully(ass_cmd, exp_compl);
Harald Weltea63b9102018-03-22 20:36:16 +01003387
3388 /* Verify that the RSL-side activation actually matches our expectations */
3389 var RSL_Message rsl := f_rslem_get_last_act(RSL_PROC, 0, g_chan_nr);
3390
3391 var RSL_IE_Body mode_ie;
3392 if (f_rsl_find_ie(rsl, RSL_IE_CHAN_MODE, mode_ie) == false) {
3393 setverdict(fail, "Couldn't find CHAN_MODE IE");
Daniel Willmannafce8662018-07-06 23:11:32 +02003394 mtc.stop;
Harald Weltea63b9102018-03-22 20:36:16 +01003395 }
3396 var template RSL_IE_Body t_mode_ie := f_rsl_chmod_tmpl_from_codec(g_pars.ass_codec_list.codecElements[0]);
3397 if (not match(mode_ie, t_mode_ie)) {
3398 setverdict(fail, "RSL Channel Mode IE doesn't match expectation");
3399 }
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02003400
3401 var RSL_IE_Body mr_conf;
3402 if (g_pars.expect_mr_conf_ie != omit) {
3403 if (f_rsl_find_ie(rsl, RSL_IE_MR_CONFIG, mr_conf) == false) {
3404 setverdict(fail, "Missing MR CONFIG IE in RSL Chan Activ");
Daniel Willmannafce8662018-07-06 23:11:32 +02003405 mtc.stop;
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02003406 }
3407 log("found RSL MR CONFIG IE: ", mr_conf);
3408
3409 if (not match(mr_conf, g_pars.expect_mr_conf_ie)) {
3410 setverdict(fail, "RSL MR CONFIG IE does not match expectation. Expected: ",
3411 g_pars.expect_mr_conf_ie);
3412 }
3413 } else {
3414 if (f_rsl_find_ie(rsl, RSL_IE_MR_CONFIG, mr_conf) == true) {
3415 log("found RSL MR CONFIG IE: ", mr_conf);
3416 setverdict(fail, "Found MR CONFIG IE in RSL Chan Activ, expecting omit");
Daniel Willmannafce8662018-07-06 23:11:32 +02003417 mtc.stop;
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02003418 }
3419 }
Harald Welte60aa5762018-03-21 19:33:13 +01003420}
3421
Philipp Maierd0e64b02019-03-13 14:15:23 +01003422private function f_TC_assignment_codec_fail(charstring id) runs on MSC_ConnHdlr {
3423
3424 var PDU_BSSAP ass_cmd := f_gen_ass_req();
3425 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
3426
3427 /* puzzle together the ASSIGNMENT REQ for given codec[s] */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003428 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
Philipp Maierd0e64b02019-03-13 14:15:23 +01003429 ass_cmd.pdu.bssmap.assignmentRequest.codecList := g_pars.ass_codec_list;
3430 }
3431 ass_cmd.pdu.bssmap.assignmentRequest.channelType :=
3432 f_BSSMAP_chtype_from_codec(g_pars.ass_codec_list.codecElements[0]);
3433 log("expecting ASS FAIL like this: ", exp_fail);
3434
3435 f_establish_fully(ass_cmd, exp_fail);
3436}
3437
Harald Welte60aa5762018-03-21 19:33:13 +01003438testcase TC_assignment_codec_fr() runs on test_CT {
Philipp Maier48604732018-10-09 15:00:37 +02003439 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte60aa5762018-03-21 19:33:13 +01003440 var MSC_ConnHdlr vc_conn;
3441
3442 f_init(1, true);
3443 f_sleep(1.0);
3444
3445 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
Harald Welte8863fa12018-05-10 20:15:27 +02003446 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01003447 vc_conn.done;
3448}
3449
3450testcase TC_assignment_codec_hr() runs on test_CT {
Philipp Maier48604732018-10-09 15:00:37 +02003451 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte60aa5762018-03-21 19:33:13 +01003452 var MSC_ConnHdlr vc_conn;
3453
3454 f_init(1, true);
3455 f_sleep(1.0);
3456
3457 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR}));
Harald Welte8863fa12018-05-10 20:15:27 +02003458 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01003459 vc_conn.done;
3460}
3461
3462testcase TC_assignment_codec_efr() runs on test_CT {
Philipp Maier48604732018-10-09 15:00:37 +02003463 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte60aa5762018-03-21 19:33:13 +01003464 var MSC_ConnHdlr vc_conn;
3465
3466 f_init(1, true);
3467 f_sleep(1.0);
3468
3469 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecEFR}));
Harald Welte8863fa12018-05-10 20:15:27 +02003470 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01003471 vc_conn.done;
3472}
3473
Philipp Maierd0e64b02019-03-13 14:15:23 +01003474/* Allow 5,90k only (current default config) */
3475private function f_allow_amr_rate_5_90k() runs on test_CT {
3476 f_vty_enter_cfg_msc(BSCVTY, 0);
3477 f_vty_transceive(BSCVTY, "amr-config 12_2k forbidden");
3478 f_vty_transceive(BSCVTY, "amr-config 10_2k forbidden");
3479 f_vty_transceive(BSCVTY, "amr-config 7_95k forbidden");
3480 f_vty_transceive(BSCVTY, "amr-config 7_40k forbidden");
3481 f_vty_transceive(BSCVTY, "amr-config 6_70k forbidden");
3482 f_vty_transceive(BSCVTY, "amr-config 5_90k allowed");
3483 f_vty_transceive(BSCVTY, "amr-config 5_15k forbidden");
3484 f_vty_transceive(BSCVTY, "amr-config 4_75k forbidden");
3485 f_vty_transceive(BSCVTY, "exit");
3486 f_vty_transceive(BSCVTY, "exit");
3487}
3488
3489/* Allow 4,75k, 5,90k, 4,70k and 12,2k, which are the most common rates
3490 * ("Config-NB-Code = 1") */
3491private function f_allow_amr_rate_4_75k_5_90k_7_40k_12_20k() runs on test_CT {
3492 f_vty_enter_cfg_msc(BSCVTY, 0);
3493 f_vty_transceive(BSCVTY, "amr-config 12_2k allowed");
3494 f_vty_transceive(BSCVTY, "amr-config 10_2k forbidden");
3495 f_vty_transceive(BSCVTY, "amr-config 7_95k forbidden");
3496 f_vty_transceive(BSCVTY, "amr-config 7_40k allowed");
3497 f_vty_transceive(BSCVTY, "amr-config 6_70k forbidden");
3498 f_vty_transceive(BSCVTY, "amr-config 5_90k allowed");
3499 f_vty_transceive(BSCVTY, "amr-config 5_15k forbidden");
3500 f_vty_transceive(BSCVTY, "amr-config 4_75k allowed");
3501 f_vty_transceive(BSCVTY, "exit");
3502 f_vty_transceive(BSCVTY, "exit");
3503}
3504
Harald Welte60aa5762018-03-21 19:33:13 +01003505testcase TC_assignment_codec_amr_f() runs on test_CT {
Philipp Maier48604732018-10-09 15:00:37 +02003506 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte60aa5762018-03-21 19:33:13 +01003507 var MSC_ConnHdlr vc_conn;
Philipp Maier7695a0d2018-09-27 17:52:14 +02003508
3509 /* Note: This setups the codec configuration. The parameter payload in
3510 * mr_conf must be consistant with the parameter codecElements in pars
3511 * and also must match the amr-config in osmo-bsc.cfg! */
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02003512 var RSL_IE_Body mr_conf := {
3513 other := {
3514 len := 2,
3515 payload := '2804'O
3516 }
3517 };
Harald Welte60aa5762018-03-21 19:33:13 +01003518
Philipp Maier7695a0d2018-09-27 17:52:14 +02003519 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_F}));
Philipp Maier806f8f12019-03-12 12:13:41 +01003520 pars.ass_codec_list.codecElements[0].s0_7 := '00000100'B; /* 5,90k */
Philipp Maier7695a0d2018-09-27 17:52:14 +02003521 pars.ass_codec_list.codecElements[0].s8_15 := '01010111'B;
3522 pars.expect_mr_conf_ie := mr_conf;
3523
Harald Welte60aa5762018-03-21 19:33:13 +01003524 f_init(1, true);
3525 f_sleep(1.0);
3526
Harald Welte8863fa12018-05-10 20:15:27 +02003527 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01003528 vc_conn.done;
3529}
3530
3531testcase TC_assignment_codec_amr_h() runs on test_CT {
Philipp Maier48604732018-10-09 15:00:37 +02003532 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte60aa5762018-03-21 19:33:13 +01003533 var MSC_ConnHdlr vc_conn;
Philipp Maier7695a0d2018-09-27 17:52:14 +02003534
3535 /* See note above */
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02003536 var RSL_IE_Body mr_conf := {
3537 other := {
3538 len := 2,
3539 payload := '2804'O
3540 }
3541 };
Harald Welte60aa5762018-03-21 19:33:13 +01003542
Philipp Maier7695a0d2018-09-27 17:52:14 +02003543 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_H}));
Philipp Maier806f8f12019-03-12 12:13:41 +01003544 pars.ass_codec_list.codecElements[0].s0_7 := '00000100'B; /* 5,90k */
Philipp Maier7695a0d2018-09-27 17:52:14 +02003545 pars.ass_codec_list.codecElements[0].s8_15 := '00000111'B;
3546 pars.expect_mr_conf_ie := mr_conf;
3547
Harald Welte60aa5762018-03-21 19:33:13 +01003548 f_init(1, true);
3549 f_sleep(1.0);
3550
Harald Welte8863fa12018-05-10 20:15:27 +02003551 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01003552 vc_conn.done;
3553}
3554
Philipp Maierd0e64b02019-03-13 14:15:23 +01003555function f_TC_assignment_codec_amr(boolean fr, octetstring mrconf, bitstring s8_s0, bitstring exp_s8_s0)
3556runs on test_CT {
3557
3558 var TestHdlrParams pars := f_gen_test_hdlr_pars();
3559 var MSC_ConnHdlr vc_conn;
3560
3561 /* See note above */
3562 var RSL_IE_Body mr_conf := {
3563 other := {
3564 len := lengthof(mrconf),
3565 payload := mrconf
3566 }
3567 };
3568
3569 if (fr) {
3570 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_F}));
3571 } else {
3572 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_H}));
3573 }
3574 pars.ass_codec_list.codecElements[0].s0_7 := s8_s0;
3575 pars.ass_codec_list.codecElements[0].s8_15 := '00000111'B;
3576 pars.expect_mr_conf_ie := mr_conf;
3577 pars.expect_mr_s0_s7 := exp_s8_s0;
3578
3579 f_init(1, true);
3580 f_allow_amr_rate_4_75k_5_90k_7_40k_12_20k();
3581 f_sleep(1.0);
3582
3583 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
3584 vc_conn.done;
3585 f_allow_amr_rate_5_90k();
3586}
3587
3588function f_TC_assignment_codec_amr_fail(boolean fr, bitstring s8_s0)
3589runs on test_CT {
3590
3591 var TestHdlrParams pars := f_gen_test_hdlr_pars();
3592 var MSC_ConnHdlr vc_conn;
3593
3594 if (fr) {
3595 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_F}));
3596 } else {
3597 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_H}));
3598 }
3599 pars.ass_codec_list.codecElements[0].s0_7 := s8_s0;
3600 pars.ass_codec_list.codecElements[0].s8_15 := '00000111'B;
3601
3602 f_init(1, true);
3603 f_allow_amr_rate_4_75k_5_90k_7_40k_12_20k();
3604 f_sleep(1.0);
3605
3606 vc_conn := f_start_handler(refers(f_TC_assignment_codec_fail), pars);
3607 vc_conn.done;
3608 f_allow_amr_rate_5_90k();
3609}
3610
3611
3612/* Set S1, we expect an AMR multirate configuration IE with all four rates
3613 * set. */
3614testcase TC_assignment_codec_amr_f_S1() runs on test_CT {
3615 f_TC_assignment_codec_amr(true, '289520882208'O, '00000010'B, '00000010'B);
3616}
3617
3618/* Set S1, we expect an AMR multirate configuration IE with the lower three
3619 * rates set. */
3620testcase TC_assignment_codec_amr_h_S1() runs on test_CT {
3621 f_TC_assignment_codec_amr(false, '2815208820'O, '00000010'B, '00000010'B);
3622}
3623
3624/* Set S1 and two other rates, we expect an AMR MULTIRATE CONFIGURATION IE with
3625 * all four rates (and only S1 set in the ASSIGNMENT COMPLETE) */
3626testcase TC_assignment_codec_amr_f_S124() runs on test_CT {
3627 f_TC_assignment_codec_amr(true, '289520882208'O, '00010110'B, '00000010'B);
3628}
3629
3630/* Set S1 and two other rates, we expect an AMR MULTIRATE CONFIGURATION IE with
3631 * all four rates (and only S1 set in the ASSIGNMENT COMPLETE) */
3632testcase TC_assignment_codec_amr_h_S124() runs on test_CT {
3633 f_TC_assignment_codec_amr(false, '2815208820'O, '00010110'B, '00000010'B);
3634}
3635
3636/* The following block of tests selects more and more rates until all four
3637 * possible rates are in the active set (full rate) */
3638testcase TC_assignment_codec_amr_f_S0() runs on test_CT {
3639 f_TC_assignment_codec_amr(true, '2801'O, '00000001'B, '00000001'B);
3640}
3641
3642testcase TC_assignment_codec_amr_f_S02() runs on test_CT {
3643 f_TC_assignment_codec_amr(true, '28052080'O, '00000101'B, '00000101'B);
3644}
3645
3646testcase TC_assignment_codec_amr_f_S024() runs on test_CT {
3647 f_TC_assignment_codec_amr(true, '2815208820'O, '00010101'B, '00010101'B);
3648}
3649
3650testcase TC_assignment_codec_amr_f_S0247() runs on test_CT {
3651 f_TC_assignment_codec_amr(true, '289520882208'O, '10010101'B, '10010101'B);
3652}
3653
3654/* The following block of tests selects more and more rates until all three
3655 * possible rates are in the active set (half rate) */
3656testcase TC_assignment_codec_amr_h_S0() runs on test_CT {
3657 f_TC_assignment_codec_amr(false, '2801'O, '00000001'B, '00000001'B);
3658}
3659
3660testcase TC_assignment_codec_amr_h_S02() runs on test_CT {
3661 f_TC_assignment_codec_amr(false, '28052080'O, '00000101'B, '00000101'B);
3662}
3663
3664testcase TC_assignment_codec_amr_h_S024() runs on test_CT {
3665 f_TC_assignment_codec_amr(false, '2815208820'O, '00010101'B, '00010101'B);
3666}
3667
3668/* The following block tests what happens when the MSC does offer rate
3669 * configurations that are not supported by the BSC. Normally such situations
3670 * should not happen because the MSC gets informed by the BSC in advance via
3671 * the L3 COMPLETE message which rates are applicable. The MSC should not try
3672 * to offer rates that are not applicable anyway. */
3673
3674testcase TC_assignment_codec_amr_h_S0247() runs on test_CT {
3675 /* Try to include 12,2k in into the active set even though the channel
3676 * is half rate only. The BSC is expected to remove the 12,0k */
3677 f_TC_assignment_codec_amr(false, '2815208820'O, '10010101'B, '00010101'B);
3678}
3679
3680testcase TC_assignment_codec_amr_f_S01234567() runs on test_CT {
3681 /* See what happens when all rates are selected at once. Since then
3682 * Also S1 is selected, this setting will be prefered and we should
3683 * get 12.2k, 7,40k, 5,90k, and 4,75k in the active set. */
3684 f_TC_assignment_codec_amr(true, '289520882208'O, '11111111'B, '00000010'B);
3685}
3686
3687testcase TC_assignment_codec_amr_f_S0234567() runs on test_CT {
3688 /* Same as above, but with S1 missing, the MSC is then expected to
3689 * select the currently supported rates, which are also 12.2k, 7,40k,
3690 * 5,90k, and 4,75k, into the active set. */
3691 f_TC_assignment_codec_amr(true, '289520882208'O, '11111101'B, '10010101'B);
3692}
3693
3694testcase TC_assignment_codec_amr_f_zero() runs on test_CT {
3695 /* Try to select no rates at all */
3696 f_TC_assignment_codec_amr_fail(true, '00000000'B);
3697}
3698
3699testcase TC_assignment_codec_amr_f_unsupp() runs on test_CT {
3700 /* Try to select only unsupported rates */
3701 f_TC_assignment_codec_amr_fail(true, '01101000'B);
3702}
3703
3704testcase TC_assignment_codec_amr_h_S7() runs on test_CT {
3705 /* Try to select 12,2k for half rate */
3706 f_TC_assignment_codec_amr_fail(false, '10000000'B);
3707}
3708
Philipp Maierac09bfc2019-01-08 13:41:39 +01003709private function f_disable_all_tch_f() runs on test_CT {
Philipp Maierc704a882019-01-29 15:58:52 +01003710 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 1 sub-slot 0 borken");
3711 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 2 sub-slot 0 borken");
3712 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 3 sub-slot 0 borken");
3713 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 4 sub-slot 0 borken");
Philipp Maierac09bfc2019-01-08 13:41:39 +01003714}
3715
3716private function f_disable_all_tch_h() runs on test_CT {
Philipp Maierc704a882019-01-29 15:58:52 +01003717 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 5 sub-slot 0 borken");
3718 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 5 sub-slot 1 borken");
Philipp Maierac09bfc2019-01-08 13:41:39 +01003719}
3720
3721private function f_enable_all_tch() runs on test_CT {
Philipp Maierc704a882019-01-29 15:58:52 +01003722 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 1 sub-slot 0 unused");
3723 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 2 sub-slot 0 unused");
3724 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 3 sub-slot 0 unused");
3725 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 4 sub-slot 0 unused");
3726 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 5 sub-slot 0 unused");
3727 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 5 sub-slot 1 unused");
Philipp Maierac09bfc2019-01-08 13:41:39 +01003728}
3729
3730/* Allow HR only */
3731private function f_TC_assignment_codec_xr_exhausted_req_hr(charstring id) runs on MSC_ConnHdlr {
3732 g_pars := f_gen_test_hdlr_pars();
3733 var PDU_BSSAP ass_cmd := f_gen_ass_req();
3734 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3735 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3736 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '09'O;
3737 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '05'O;
3738 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR}));
3739 f_establish_fully(ass_cmd, exp_compl);
3740}
3741
3742/* Allow FR only */
3743private function f_TC_assignment_codec_xr_exhausted_req_fr(charstring id) runs on MSC_ConnHdlr {
3744 g_pars := f_gen_test_hdlr_pars();
3745 var PDU_BSSAP ass_cmd := f_gen_ass_req();
3746 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3747 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3748 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '08'O;
3749 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '01'O;
3750 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
3751 f_establish_fully(ass_cmd, exp_compl);
3752}
3753
3754/* Allow HR only (expect assignment failure) */
3755private function f_TC_assignment_codec_xr_exhausted_req_hr_fail(charstring id) runs on MSC_ConnHdlr {
3756 g_pars := f_gen_test_hdlr_pars();
3757 var PDU_BSSAP ass_cmd := f_gen_ass_req();
3758 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
3759 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3760 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '09'O;
3761 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '05'O;
3762 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR}));
3763 f_establish_fully(ass_cmd, exp_fail);
3764}
3765
3766/* Allow FR only (expect assignment failure) */
3767private function f_TC_assignment_codec_xr_exhausted_req_fr_fail(charstring id) runs on MSC_ConnHdlr {
3768 g_pars := f_gen_test_hdlr_pars();
3769 var PDU_BSSAP ass_cmd := f_gen_ass_req();
3770 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
3771 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3772 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '08'O;
3773 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '01'O;
3774 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
3775 f_establish_fully(ass_cmd, exp_fail);
3776}
3777
3778/* Allow FR and HR, but prefer FR */
3779private function f_TC_assignment_codec_fr_exhausted_req_fr_hr(charstring id) runs on MSC_ConnHdlr {
3780 g_pars := f_gen_test_hdlr_pars();
3781 var PDU_BSSAP ass_cmd := f_gen_ass_req();
3782 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3783 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3784 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0A'O; /* Prefer FR */
3785 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8105'O;
3786 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR, ts_CodecHR}));
3787 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000101'B; /* Expect HR */
3788 f_establish_fully(ass_cmd, exp_compl);
3789}
3790
3791/* Allow FR and HR, but prefer HR */
3792private function f_TC_assignment_codec_fr_exhausted_req_hr_fr(charstring id) runs on MSC_ConnHdlr {
3793 g_pars := f_gen_test_hdlr_pars();
3794 var PDU_BSSAP ass_cmd := f_gen_ass_req();
3795 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3796 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3797 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0B'O; /* Prefer HR */
3798 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8501'O;
3799 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR, ts_CodecFR}));
3800 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000101'B; /* Expect HR */
3801 f_establish_fully(ass_cmd, exp_compl);
3802}
3803
3804/* Allow FR and HR, but prefer FR */
3805private function f_TC_assignment_codec_hr_exhausted_req_fr_hr(charstring id) runs on MSC_ConnHdlr {
3806 g_pars := f_gen_test_hdlr_pars();
3807 var PDU_BSSAP ass_cmd := f_gen_ass_req();
3808 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3809 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3810 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0A'O; /* Prefer FR */
3811 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8105'O;
3812 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR, ts_CodecHR}));
3813 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000001'B; /* Expect FR */
3814 f_establish_fully(ass_cmd, exp_compl);
3815}
3816
3817/* Allow FR and HR, but prefer HR */
3818private function f_TC_assignment_codec_hr_exhausted_req_hr_fr(charstring id) runs on MSC_ConnHdlr {
3819 g_pars := f_gen_test_hdlr_pars();
3820 var PDU_BSSAP ass_cmd := f_gen_ass_req();
3821 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3822 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3823 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0B'O; /* Prefer HR */
3824 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8501'O;
3825 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR, ts_CodecFR}));
3826 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000001'B; /* Expect FR */
3827 f_establish_fully(ass_cmd, exp_compl);
3828}
3829
3830/* Request a HR channel while all FR channels are exhausted, this is expected
3831 * to work without conflicts */
3832testcase TC_assignment_codec_fr_exhausted_req_hr() runs on test_CT {
3833 var MSC_ConnHdlr vc_conn;
3834 f_init(1, true);
3835 f_sleep(1.0);
3836 f_enable_all_tch();
3837 f_disable_all_tch_f();
3838 vc_conn := f_start_handler(refers(f_TC_assignment_codec_xr_exhausted_req_hr));
3839 vc_conn.done;
3840 f_enable_all_tch();
3841 setverdict(pass);
3842}
3843
3844/* Request a FR channel while all FR channels are exhausted, this is expected
3845 * to fail. */
3846testcase TC_assignment_codec_fr_exhausted_req_fr() runs on test_CT {
3847 var MSC_ConnHdlr vc_conn;
3848 f_init(1, true);
3849 f_sleep(1.0);
3850 f_enable_all_tch();
3851 f_disable_all_tch_f();
3852 vc_conn := f_start_handler(refers(f_TC_assignment_codec_xr_exhausted_req_fr_fail));
3853 vc_conn.done;
3854 f_enable_all_tch();
3855 setverdict(pass);
3856}
3857
3858/* Request a FR (prefered) or alternatively a HR channel while all FR channels
3859 * are exhausted, this is expected to be resolved by selecting a HR channel. */
3860testcase TC_assignment_codec_fr_exhausted_req_fr_hr() runs on test_CT {
3861 var MSC_ConnHdlr vc_conn;
3862 f_init(1, true);
3863 f_sleep(1.0);
3864 f_enable_all_tch();
3865 f_disable_all_tch_f();
3866 vc_conn := f_start_handler(refers(f_TC_assignment_codec_fr_exhausted_req_fr_hr));
3867 vc_conn.done;
3868 f_enable_all_tch();
3869 setverdict(pass);
3870}
3871
3872/* Request a HR (prefered) or alternatively a FR channel while all FR channels
3873 * are exhausted, this is expected to work without conflicts. */
3874testcase TC_assignment_codec_fr_exhausted_req_hr_fr() runs on test_CT {
3875 var MSC_ConnHdlr vc_conn;
3876 f_init(1, true);
3877 f_sleep(1.0);
3878 f_enable_all_tch();
3879 f_disable_all_tch_f();
3880 vc_conn := f_start_handler(refers(f_TC_assignment_codec_fr_exhausted_req_hr_fr));
3881 vc_conn.done;
3882 f_enable_all_tch();
3883 setverdict(pass);
3884}
3885
3886/* Request a FR channel while all HR channels are exhausted, this is expected
3887 * to work without conflicts */
3888testcase TC_assignment_codec_hr_exhausted_req_fr() runs on test_CT {
3889 var MSC_ConnHdlr vc_conn;
3890 f_init(1, true);
3891 f_sleep(1.0);
3892 f_enable_all_tch();
3893 f_disable_all_tch_h();
3894 vc_conn := f_start_handler(refers(f_TC_assignment_codec_xr_exhausted_req_fr));
3895 vc_conn.done;
3896 f_enable_all_tch();
3897 setverdict(pass);
3898}
3899
3900/* Request a HR channel while all HR channels are exhausted, this is expected
3901 * to fail. */
3902testcase TC_assignment_codec_hr_exhausted_req_hr() runs on test_CT {
3903 var MSC_ConnHdlr vc_conn;
3904 f_init(1, true);
3905 f_sleep(1.0);
3906 f_enable_all_tch();
3907 f_disable_all_tch_h();
3908 vc_conn := f_start_handler(refers(f_TC_assignment_codec_xr_exhausted_req_hr_fail));
3909 vc_conn.done;
3910 f_enable_all_tch();
3911 setverdict(pass);
3912}
3913
3914/* Request a HR (prefered) or alternatively a FR channel while all HR channels
3915 * are exhausted, this is expected to be resolved by selecting a FR channel. */
3916testcase TC_assignment_codec_hr_exhausted_req_hr_fr() runs on test_CT {
3917 var MSC_ConnHdlr vc_conn;
3918 f_init(1, true);
3919 f_sleep(1.0);
3920 f_enable_all_tch();
3921 f_disable_all_tch_h();
3922 vc_conn := f_start_handler(refers(f_TC_assignment_codec_hr_exhausted_req_hr_fr));
3923 vc_conn.done;
3924 f_enable_all_tch();
3925 setverdict(pass);
3926}
3927
3928/* Request a FR (prefered) or alternatively a HR channel while all HR channels
3929 * are exhausted, this is expected to work without conflicts. */
3930testcase TC_assignment_codec_hr_exhausted_req_fr_hr() runs on test_CT {
3931 var MSC_ConnHdlr vc_conn;
3932 f_init(1, true);
3933 f_sleep(1.0);
3934 f_enable_all_tch();
3935 f_disable_all_tch_h();
3936 vc_conn := f_start_handler(refers(f_TC_assignment_codec_hr_exhausted_req_fr_hr));
3937 vc_conn.done;
3938 f_enable_all_tch();
3939 setverdict(pass);
3940}
3941
3942/* Allow FR and HR, but prefer HR */
3943private function f_TC_assignment_codec_req_hr_fr(charstring id) runs on MSC_ConnHdlr {
3944 g_pars := f_gen_test_hdlr_pars();
3945 var PDU_BSSAP ass_cmd := f_gen_ass_req();
3946 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3947 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3948 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0B'O; /* Prefer HR */
3949 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8501'O;
3950 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR, ts_CodecFR}));
3951 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000101'B; /* Expect HR */
3952 f_establish_fully(ass_cmd, exp_compl);
3953}
3954
3955/* Allow FR and HR, but prefer FR */
3956private function f_TC_assignment_codec_req_fr_hr(charstring id) runs on MSC_ConnHdlr {
3957 g_pars := f_gen_test_hdlr_pars();
3958 var PDU_BSSAP ass_cmd := f_gen_ass_req();
3959 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3960 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3961 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0A'O; /* Prefer FR */
3962 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8105'O;
3963 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR, ts_CodecHR}));
3964 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000001'B; /* Expect FR */
3965 f_establish_fully(ass_cmd, exp_compl);
3966}
3967
3968/* Request a HR (prefered) or alternatively a FR channel, it is expected that
3969 * HR, which is the prefered type, is selected. */
3970testcase TC_assignment_codec_req_hr_fr() runs on test_CT {
3971 var MSC_ConnHdlr vc_conn;
3972 f_init(1, true);
3973 f_sleep(1.0);
3974 f_enable_all_tch();
3975 vc_conn := f_start_handler(refers(f_TC_assignment_codec_req_hr_fr));
3976 vc_conn.done;
3977 setverdict(pass);
3978}
3979
3980/* Request a FR (prefered) or alternatively a HR channel, it is expected that
3981 * FR, which is the prefered type, is selected. */
3982testcase TC_assignment_codec_req_fr_hr() runs on test_CT {
3983 var MSC_ConnHdlr vc_conn;
3984 f_init(1, true);
3985 f_sleep(1.0);
3986 f_enable_all_tch();
3987 vc_conn := f_start_handler(refers(f_TC_assignment_codec_req_fr_hr));
3988 vc_conn.done;
3989 setverdict(pass);
3990}
3991
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02003992testcase TC_assignment_osmux() runs on test_CT {
3993 var TestHdlrParams pars := f_gen_test_hdlr_pars();
3994 var MSC_ConnHdlr vc_conn;
3995
3996 /* See note above */
3997 var RSL_IE_Body mr_conf := {
3998 other := {
3999 len := 2,
4000 payload := '2804'O
4001 }
4002 };
4003
4004 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_H}));
4005 pars.ass_codec_list.codecElements[0].s0_7 := '00000100'B; /* 5,90k */
4006 pars.ass_codec_list.codecElements[0].s8_15 := '00000111'B;
4007 pars.expect_mr_conf_ie := mr_conf;
4008 pars.use_osmux := true;
4009
4010 f_init(1, true, true);
4011 f_sleep(1.0);
4012
4013 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
4014 vc_conn.done;
4015}
4016
Neels Hofmeyr92b12b72018-09-18 14:30:23 +02004017/* test the procedure of the MSC requesting a Classmark Update:
4018 * a) BSSMAP Classmark Request should result in RR CLASSMARK ENQUIRY,
4019 * b) L3 RR CLASSMARK CHANGE should result in BSSMAP CLASSMARK UPDATE */
Harald Welte898113b2018-01-31 18:32:21 +01004020private function f_tc_classmark(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02004021 g_pars := f_gen_test_hdlr_pars();
4022
Harald Weltea0630032018-03-20 21:09:55 +01004023 f_create_chan_and_exp();
Harald Welte898113b2018-01-31 18:32:21 +01004024 /* we should now have a COMPL_L3 at the MSC */
4025 BSSAP.receive(tr_BSSMAP_ComplL3);
4026
Neels Hofmeyr92b12b72018-09-18 14:30:23 +02004027 BSSAP.send(ts_BSSMAP_ClassmarkRequest);
4028 RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_CM_ENQUIRY));
4029
Harald Welte898113b2018-01-31 18:32:21 +01004030 f_rsl_send_l3(ts_RRM_CM_CHG(valueof(ts_CM2)));
4031 BSSAP.receive(tr_BSSMAP_ClassmarkUpd(?, omit));
4032 setverdict(pass);
4033}
4034testcase TC_classmark() runs on test_CT {
4035 var MSC_ConnHdlr vc_conn;
4036 f_init(1, true);
4037 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02004038 vc_conn := f_start_handler(refers(f_tc_classmark));
Harald Welte898113b2018-01-31 18:32:21 +01004039 vc_conn.done;
4040}
4041
Harald Welteeddf0e92020-06-21 19:42:15 +02004042/* Send a CommonID from the simulated MSC and verify that the information is used to
4043 * fill BSC-internal data structures (specifically, bsc_subscr associated with subscr_conn) */
4044private function f_tc_common_id(charstring id) runs on MSC_ConnHdlr {
4045 g_pars := f_gen_test_hdlr_pars();
4046 f_MscConnHdlr_init_vty();
4047
4048 f_create_chan_and_exp();
4049 /* we should now have a COMPL_L3 at the MSC */
4050 BSSAP.receive(tr_BSSMAP_ComplL3);
4051
4052 /* Send CommonID */
4053 BSSAP.send(ts_BSSMAP_CommonId(g_pars.imsi));
4054
4055 /* Use VTY to verify that the IMSI of the subscr_conn is set */
4056 var charstring regex := "*(IMSI: " & hex2str(g_pars.imsi) & ")*";
4057 f_vty_transceive_match_regexp_retry(BSCVTY, "show conns", regex, 0, 4, 1.0);
4058
4059 setverdict(pass);
4060}
4061testcase TC_common_id() runs on test_CT {
4062 var MSC_ConnHdlr vc_conn;
4063 f_init(1, true);
4064 f_sleep(1.0);
4065 vc_conn := f_start_handler(refers(f_tc_common_id));
4066 vc_conn.done;
4067}
4068
Harald Weltee3bd6582018-01-31 22:51:25 +01004069private function f_est_single_l3(template PDU_ML3_MS_NW l3) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02004070 g_pars := f_gen_test_hdlr_pars();
Harald Weltea0630032018-03-20 21:09:55 +01004071 f_create_chan_and_exp();
Harald Welte898113b2018-01-31 18:32:21 +01004072 /* we should now have a COMPL_L3 at the MSC */
4073 BSSAP.receive(tr_BSSMAP_ComplL3);
4074
Harald Weltee3bd6582018-01-31 22:51:25 +01004075 /* send the single message we want to send */
4076 f_rsl_send_l3(l3);
4077}
4078
4079private function f_bssap_expect_nothing(float sec := 5.00) runs on MSC_ConnHdlr {
4080 timer T := sec;
4081 var PDU_BSSAP bssap;
Harald Welte898113b2018-01-31 18:32:21 +01004082 T.start;
4083 alt {
Harald Weltee3bd6582018-01-31 22:51:25 +01004084 [] BSSAP.receive(PDU_BSSAP:?) -> value bssap {
4085 setverdict(fail, "Unexpected BSSMAP ", bssap);
Daniel Willmannafce8662018-07-06 23:11:32 +02004086 mtc.stop;
Harald Welte898113b2018-01-31 18:32:21 +01004087 }
4088 [] T.timeout {
4089 setverdict(pass);
4090 }
4091 }
4092}
4093
Harald Weltee3bd6582018-01-31 22:51:25 +01004094/* unsolicited ASSIGNMENT FAIL (without ASSIGN) from MS shouldn't bring BSC down */
4095private function f_tc_unsol_ass_fail(charstring id) runs on MSC_ConnHdlr {
4096 f_est_single_l3(ts_RRM_AssignmentFailure('00'O));
4097 f_bssap_expect_nothing();
4098}
Harald Welte898113b2018-01-31 18:32:21 +01004099testcase TC_unsol_ass_fail() runs on test_CT {
4100 var MSC_ConnHdlr vc_conn;
4101 f_init(1, true);
4102 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02004103 vc_conn := f_start_handler(refers(f_tc_unsol_ass_fail));
Harald Welte898113b2018-01-31 18:32:21 +01004104 vc_conn.done;
4105}
Harald Welte552620d2017-12-16 23:21:36 +01004106
Harald Welteea99a002018-01-31 20:46:43 +01004107
4108/* unsolicited ASSIGNMENT COMPLETE (without ASSIGN) from MS shouldn't bring BSC down */
4109private function f_tc_unsol_ass_compl(charstring id) runs on MSC_ConnHdlr {
Harald Weltee3bd6582018-01-31 22:51:25 +01004110 f_est_single_l3(ts_RRM_AssignmentComplete('00'O));
4111 f_bssap_expect_nothing();
Harald Welteea99a002018-01-31 20:46:43 +01004112}
4113testcase TC_unsol_ass_compl() runs on test_CT {
4114 var MSC_ConnHdlr vc_conn;
4115 f_init(1, true);
4116 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02004117 vc_conn := f_start_handler(refers(f_tc_unsol_ass_compl));
Harald Welteea99a002018-01-31 20:46:43 +01004118 vc_conn.done;
4119}
4120
4121
Harald Weltefbf9b5e2018-01-31 20:41:23 +01004122/* unsolicited HANDOVER FAIL (without ASSIGN) from MS shouldn't bring BSC down */
4123private function f_tc_unsol_ho_fail(charstring id) runs on MSC_ConnHdlr {
Harald Weltee3bd6582018-01-31 22:51:25 +01004124 f_est_single_l3(ts_RRM_HandoverFailure('00'O));
4125 f_bssap_expect_nothing();
Harald Weltefbf9b5e2018-01-31 20:41:23 +01004126}
Harald Weltefbf9b5e2018-01-31 20:41:23 +01004127testcase TC_unsol_ho_fail() runs on test_CT {
4128 var MSC_ConnHdlr vc_conn;
4129 f_init(1, true);
4130 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02004131 vc_conn := f_start_handler(refers(f_tc_unsol_ho_fail));
Harald Weltefbf9b5e2018-01-31 20:41:23 +01004132 vc_conn.done;
4133}
4134
4135
Harald Weltee3bd6582018-01-31 22:51:25 +01004136/* short message from MS should be ignored */
4137private function f_tc_err_82_short_msg(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02004138 g_pars := f_gen_test_hdlr_pars();
Harald Weltea0630032018-03-20 21:09:55 +01004139 f_create_chan_and_exp();
Harald Weltee3bd6582018-01-31 22:51:25 +01004140 /* we should now have a COMPL_L3 at the MSC */
4141 BSSAP.receive(tr_BSSMAP_ComplL3);
4142
4143 /* send short message */
4144 RSL.send(ts_RSL_DATA_IND(g_chan_nr, valueof(ts_RslLinkID_DCCH(0)), ''O));
4145 f_bssap_expect_nothing();
4146}
4147testcase TC_err_82_short_msg() runs on test_CT {
4148 var MSC_ConnHdlr vc_conn;
4149 f_init(1, true);
4150 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02004151 vc_conn := f_start_handler(refers(f_tc_err_82_short_msg));
Harald Weltee3bd6582018-01-31 22:51:25 +01004152 vc_conn.done;
4153}
4154
4155
Harald Weltee9e02e42018-01-31 23:36:25 +01004156/* 24.008 8.4 Unknown message must trigger RR STATUS */
4157private function f_tc_err_84_unknown_msg(charstring id) runs on MSC_ConnHdlr {
4158 f_est_single_l3(ts_RRM_UL_REL('00'O));
4159 timer T := 3.0
4160 alt {
4161 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_STATUS)) {
4162 setverdict(pass);
4163 }
4164 [] BSSAP.receive { setverdict(fail, "unexpected BSSAP"); }
Harald Welte458fd372018-03-21 11:26:23 +01004165 [] T.timeout { setverdict(fail, "Timeout waiting for RR STATUS"); }
Harald Weltee9e02e42018-01-31 23:36:25 +01004166 }
4167}
4168testcase TC_err_84_unknown_msg() runs on test_CT {
4169 var MSC_ConnHdlr vc_conn;
4170 f_init(1, true);
4171 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02004172 vc_conn := f_start_handler(refers(f_tc_err_84_unknown_msg));
Harald Weltee9e02e42018-01-31 23:36:25 +01004173 vc_conn.done;
4174}
4175
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004176/***********************************************************************
4177 * Handover
4178 ***********************************************************************/
4179
Harald Welte94e0c342018-04-07 11:33:23 +02004180/* execute a "bts <0-255> trx <0-255> timeslot <0-7> " command on given Dchan */
4181private function f_vty_ts_action(charstring suffix, integer bts_nr, integer trx_nr, integer ts_nr)
4182runs on test_CT {
4183 var charstring cmd := "bts "&int2str(bts_nr)&" trx "&int2str(trx_nr)&
4184 " timeslot "&int2str(ts_nr)&" ";
4185 f_vty_transceive(BSCVTY, cmd & suffix);
4186}
4187
Harald Welte261af4b2018-02-12 21:20:39 +01004188/* 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 +07004189private function f_vty_ss_action(TELNETasp_PT pt, charstring suffix,
4190 uint8_t bts_nr, uint8_t trx_nr,
4191 in RslChannelNr chan_nr)
4192{
Harald Welte261af4b2018-02-12 21:20:39 +01004193 /* FIXME: resolve those from component-global state */
4194 var integer ts_nr := chan_nr.tn;
4195 var integer ss_nr;
4196 if (ischosen(chan_nr.u.ch0)) {
4197 ss_nr := 0;
4198 } else if (ischosen(chan_nr.u.lm)) {
4199 ss_nr := chan_nr.u.lm.sub_chan;
4200 } else if (ischosen(chan_nr.u.sdcch4)) {
4201 ss_nr := chan_nr.u.sdcch4.sub_chan;
4202 } else if (ischosen(chan_nr.u.sdcch8)) {
4203 ss_nr := chan_nr.u.sdcch8.sub_chan;
4204 } else {
4205 setverdict(fail, "Invalid ChanNr ", chan_nr);
Daniel Willmannafce8662018-07-06 23:11:32 +02004206 mtc.stop;
Harald Welte261af4b2018-02-12 21:20:39 +01004207 }
4208
4209 var charstring cmd := "bts "&int2str(bts_nr)&" trx "&int2str(trx_nr)&
4210 " timeslot "&int2str(ts_nr)&" sub-slot "&int2str(ss_nr)&" ";
Vadim Yanitskiy00070722020-09-02 17:27:57 +07004211 f_vty_transceive(pt, cmd & suffix);
Harald Welte261af4b2018-02-12 21:20:39 +01004212}
4213
Neels Hofmeyr91401012019-07-11 00:42:35 +02004214/* Even though the VTY command to trigger handover takes a new BTS number as argument, behind the scenes osmo-bsc always
4215 * translates that to a target ARFCN+BSIC first. See bsc_vty.c trigger_ho_or_as(), which puts the selected BTS' neighbor
4216 * ident key (ARFCN + BSIC) in the struct passed on to handover_request(). handover_start() then resolves that to a
4217 * viable actual neighbor cell. So from the internal osmo-bsc perspective, we always request handover to an ARFCN + BSIC
4218 * pair, not really to a specific BTS number. */
Vadim Yanitskiy00070722020-09-02 17:27:57 +07004219private function f_vty_handover(TELNETasp_PT pt, uint8_t bts_nr, uint8_t trx_nr,
4220 in RslChannelNr chan_nr, uint8_t new_bts_nr)
4221{
4222 f_vty_ss_action(pt, "handover " & int2str(new_bts_nr), bts_nr, trx_nr, chan_nr);
Harald Welte261af4b2018-02-12 21:20:39 +01004223}
4224
4225/* intra-BSC hand-over between BTS0 and BTS1 */
4226private function f_tc_ho_int(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02004227 g_pars := f_gen_test_hdlr_pars();
Harald Welteed848512018-05-24 22:27:58 +02004228 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4229 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte261af4b2018-02-12 21:20:39 +01004230 const OCT8 kc := '0001020304050607'O;
4231
4232 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4233 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
4234
Harald Weltea0630032018-03-20 21:09:55 +01004235 f_establish_fully(ass_cmd, exp_compl);
Neels Hofmeyr666f0432020-07-04 00:53:07 +02004236 f_bts_0_cfg(BSCVTY, {"neighbor bts 1"});
Harald Welte261af4b2018-02-12 21:20:39 +01004237
4238 var HandoverState hs := {
4239 rr_ho_cmpl_seen := false,
4240 handover_done := false,
4241 old_chan_nr := -
4242 };
4243 /* issue hand-over command on VTY */
Vadim Yanitskiy00070722020-09-02 17:27:57 +07004244 f_vty_handover(BSCVTY, 0, 0, g_chan_nr, 1);
Harald Welte261af4b2018-02-12 21:20:39 +01004245 /* temporarily suspend DChan processing on BTS1 to avoid race with RSLEM_register */
4246 f_rslem_suspend(RSL1_PROC);
Philipp Maier3e2af5d2018-07-11 17:01:05 +02004247
4248 /* From the MGW perspective, a handover is is characterized by
4249 * performing one MDCX operation with the MGW. So we expect to see
4250 * one more MDCX during handover. */
4251 g_media.mgcp_conn[0].mdcx_seen_exp := g_media.mgcp_conn[0].crcx_seen_exp + 1;
4252
Harald Welte261af4b2018-02-12 21:20:39 +01004253 alt {
4254 [] as_handover(hs);
Harald Welte261af4b2018-02-12 21:20:39 +01004255 }
Philipp Maier3e2af5d2018-07-11 17:01:05 +02004256
Philipp Maier4dae0652018-11-12 12:03:26 +01004257 /* Since this is an internal handover we expect the BSC to inform the
4258 * MSC about the event */
4259 BSSAP.receive(tr_BSSMAP_HandoverPerformed);
4260
Philipp Maier3e2af5d2018-07-11 17:01:05 +02004261 /* Check the amount of MGCP transactions is still consistant with the
4262 * test expectation */
4263 f_check_mgcp_expectations()
Neels Hofmeyr861a4c12018-11-07 01:23:17 +01004264 f_sleep(0.5);
Harald Welte261af4b2018-02-12 21:20:39 +01004265}
4266
4267testcase TC_ho_int() runs on test_CT {
4268 var MSC_ConnHdlr vc_conn;
4269 f_init(2, true);
4270 f_sleep(1.0);
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004271
4272 f_ctrs_bsc_and_bts_init();
4273
Harald Welte8863fa12018-05-10 20:15:27 +02004274 vc_conn := f_start_handler(refers(f_tc_ho_int));
Harald Welte261af4b2018-02-12 21:20:39 +01004275 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004276
4277 /* from f_establish_fully() */
4278 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
4279 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
4280 /* from handover */
4281 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
4282 f_ctrs_bsc_and_bts_add(0, "handover:completed");
4283 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
4284 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:completed");
4285 f_ctrs_bsc_and_bts_verify();
Harald Welte261af4b2018-02-12 21:20:39 +01004286}
Harald Weltee9e02e42018-01-31 23:36:25 +01004287
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004288/* Expecting MGCP to DLCX the endpoint's two connections: towards BTS and towards MSC */
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02004289private function f_expect_dlcx_conns() runs on MSC_ConnHdlr {
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004290 var MgcpCommand mgcp;
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +02004291 var template MgcpResponse mgcp_resp;
4292 var MGCP_RecvFrom mrf;
4293 var template MgcpMessage msg_resp;
4294 var template MgcpMessage msg_dlcx := {
4295 command := tr_DLCX()
4296 }
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004297
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +02004298 if (g_pars.aoip) {
4299 MGCP.receive(tr_DLCX()) -> value mgcp {
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004300 log("Got first DLCX: ", mgcp);
4301 MGCP.send(ts_DLCX_ACK2(mgcp.line.trans_id));
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +02004302 };
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004303
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004304 MGCP.receive(tr_DLCX()) -> value mgcp {
4305 log("Got second DLCX: ", mgcp);
4306 MGCP.send(ts_DLCX_ACK2(mgcp.line.trans_id));
4307 };
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +02004308 } else {
4309 /* For SCCPLite, BSC doesn't handle the MSC-side */
4310 MGCP_MULTI.receive(tr_MGCP_RecvFrom_any(msg_dlcx)) -> value mrf {
4311 log("Got first DLCX: ", mrf.msg.command);
4312 msg_resp := {
4313 response := ts_DLCX_ACK2(mrf.msg.command.line.trans_id)
4314 }
4315 MGCP_MULTI.send(t_MGCP_SendToMrf(mrf, msg_resp));
4316 };
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004317 }
4318
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02004319 BSSAP.receive(tr_BSSMAP_ClearComplete);
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004320}
4321
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004322private function f_tc_ho_out_of_this_bsc(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02004323 g_pars := f_gen_test_hdlr_pars();
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004324
4325 var PDU_BSSAP ass_req := f_gen_ass_req();
4326 ass_req.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4327 ass_req.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
4328 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4329 f_establish_fully(ass_req, exp_compl);
4330
Neels Hofmeyr666f0432020-07-04 00:53:07 +02004331 f_bts_0_cfg(BSCVTY, {"neighbor lac 99 arfcn 123 bsic any"});
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004332 f_vty_transceive(BSCVTY, "handover any to arfcn 123 bsic any");
4333
4334 BSSAP.receive(tr_BSSMAP_HandoverRequired);
4335
4336 f_sleep(0.5);
4337 /* The MSC negotiates Handover Request and Handover Request Ack with
4338 * the other BSS and comes back with a BSSMAP Handover Command
4339 * containing an RR Handover Command coming from the target BSS... */
4340
4341 var PDU_ML3_NW_MS rr_ho_cmd := valueof(ts_RR_HandoverCommand);
4342 log("Remote cell's RR Handover Command passed through as L3 Info: ", rr_ho_cmd);
4343 var octetstring rr_ho_cmd_enc := enc_PDU_ML3_NW_MS(rr_ho_cmd);
4344 log("Remote cell's RR Handover Command passed through as L3 Info, encoded: ", rr_ho_cmd_enc);
4345 BSSAP.send(ts_BSSMAP_HandoverCommand(rr_ho_cmd_enc));
4346
4347 /* expect the Handover Command to go out on RR */
4348 var RSL_Message rsl_ho_cmd
4349 RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, ?)) -> value rsl_ho_cmd;
4350 log("RSL Data Req went out to first BTS: ", rsl_ho_cmd);
4351 var RSL_IE_Body rsl_ho_cmd_l3;
4352 if (not f_rsl_find_ie(rsl_ho_cmd, RSL_IE_L3_INFO, rsl_ho_cmd_l3)) {
4353 log("RSL message contains no L3 Info IE, expected RR Handover Command");
4354 setverdict(fail);
4355 } else {
4356 log("Found L3 Info: ", rsl_ho_cmd_l3);
4357 if (rsl_ho_cmd_l3.l3_info.payload != rr_ho_cmd_enc) {
4358 log("FAIL: the BSC sent out a different L3 Info, not matching the RR Handover Command the other BSS forwarded.");
4359 setverdict(fail);
4360 } else {
4361 log("Success: the BSC sent out the same RR Handover Command the other BSS forwarded.");
4362 setverdict(pass);
4363 }
4364 }
4365
4366 /* When the other BSS has reported a completed handover, this side is
4367 * torn down. */
4368
4369 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_HANDOVER_SUCCESSFUL;
4370 var BssmapCause cause := enum2int(cause_val);
4371 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
4372
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02004373 f_expect_dlcx_conns();
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004374 setverdict(pass);
4375 f_sleep(1.0);
4376}
4377testcase TC_ho_out_of_this_bsc() runs on test_CT {
4378 var MSC_ConnHdlr vc_conn;
4379
4380 f_init(1, true);
4381 f_sleep(1.0);
4382
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004383 f_ctrs_bsc_and_bts_init();
4384
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004385 vc_conn := f_start_handler(refers(f_tc_ho_out_of_this_bsc));
4386 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004387
4388 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
4389 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
4390 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
4391 f_ctrs_bsc_and_bts_add(0, "handover:completed");
4392 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
4393 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:completed");
4394 f_ctrs_bsc_and_bts_verify();
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004395}
4396
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004397/* BSC asks for inter-BSC HO, but the MSC decides that it won't happen and
4398 * simply never sends a BSSMAP Handover Command. */
4399private function f_tc_ho_out_fail_no_msc_response(charstring id) runs on MSC_ConnHdlr {
Daniel Willmann3b59eb52018-10-29 15:40:55 +01004400 g_pars := f_gen_test_hdlr_pars();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004401
4402 var PDU_BSSAP ass_req := f_gen_ass_req();
4403 ass_req.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4404 ass_req.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
4405 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4406 f_establish_fully(ass_req, exp_compl);
4407
Neels Hofmeyr666f0432020-07-04 00:53:07 +02004408 f_bts_0_cfg(BSCVTY, {"neighbor lac 99 arfcn 123 bsic any"});
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004409 f_vty_transceive(BSCVTY, "handover any to arfcn 123 bsic any");
4410
4411 BSSAP.receive(tr_BSSMAP_HandoverRequired);
4412
4413 /* osmo-bsc should time out 10 seconds after the handover started.
4414 * Let's give it a bit extra. */
4415 f_sleep(15.0);
4416
4417 /* The old lchan and conn should still be active. See that arbitrary L3
4418 * is still going through. */
4419 var octetstring l3 := '0123456789'O;
4420 RSL.send(ts_RSL_DATA_IND(g_chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
4421 var template PDU_BSSAP exp_data := {
4422 discriminator := '1'B,
4423 spare := '0000000'B,
4424 dlci := '00'O,
4425 lengthIndicator := 5,
4426 pdu := {
4427 dtap := l3
4428 }
4429 };
4430 BSSAP.receive(exp_data);
4431 setverdict(pass);
4432 f_sleep(1.0);
4433}
4434testcase TC_ho_out_fail_no_msc_response() runs on test_CT {
4435 var MSC_ConnHdlr vc_conn;
4436
4437 f_init(1, true);
4438 f_sleep(1.0);
4439
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004440 f_ctrs_bsc_and_bts_init();
4441
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004442 vc_conn := f_start_handler(refers(f_tc_ho_out_fail_no_msc_response));
4443 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004444
4445 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
4446 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
4447 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
4448 f_ctrs_bsc_and_bts_add(0, "handover:timeout");
4449 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
4450 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:timeout");
4451 f_ctrs_bsc_and_bts_verify();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004452}
4453
4454/* BSC asks for inter-BSC HO, receives BSSMAP Handover Command, but MS reports
4455 * RR Handover Failure. */
4456private function f_tc_ho_out_fail_rr_ho_failure(charstring id) runs on MSC_ConnHdlr {
Daniel Willmann3b59eb52018-10-29 15:40:55 +01004457 g_pars := f_gen_test_hdlr_pars();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004458
4459 var PDU_BSSAP ass_req := f_gen_ass_req();
4460 ass_req.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4461 ass_req.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
4462 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4463 f_establish_fully(ass_req, exp_compl);
4464
Neels Hofmeyr666f0432020-07-04 00:53:07 +02004465 f_bts_0_cfg(BSCVTY, {"neighbor lac 99 arfcn 123 bsic any"});
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004466 f_vty_transceive(BSCVTY, "handover any to arfcn 123 bsic any");
4467
4468 BSSAP.receive(tr_BSSMAP_HandoverRequired);
4469
4470 f_sleep(0.5);
4471 /* The MSC negotiates Handover Request and Handover Request Ack with
4472 * the other BSS and comes back with a BSSMAP Handover Command
4473 * containing an RR Handover Command coming from the target BSS... */
4474
4475 var PDU_ML3_NW_MS rr_ho_cmd := valueof(ts_RR_HandoverCommand);
4476 log("Remote cell's RR Handover Command passed through as L3 Info: ", rr_ho_cmd);
4477 var octetstring rr_ho_cmd_enc := enc_PDU_ML3_NW_MS(rr_ho_cmd);
4478 log("Remote cell's RR Handover Command passed through as L3 Info, encoded: ", rr_ho_cmd_enc);
4479 BSSAP.send(ts_BSSMAP_HandoverCommand(rr_ho_cmd_enc));
4480
4481 /* expect the Handover Command to go out on RR */
4482 var RSL_Message rsl_ho_cmd
4483 RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, ?)) -> value rsl_ho_cmd;
4484 log("RSL Data Req went out to first BTS: ", rsl_ho_cmd);
4485 var RSL_IE_Body rsl_ho_cmd_l3;
4486 if (not f_rsl_find_ie(rsl_ho_cmd, RSL_IE_L3_INFO, rsl_ho_cmd_l3)) {
4487 log("RSL message contains no L3 Info IE, expected RR Handover Command");
4488 setverdict(fail);
4489 } else {
4490 log("Found L3 Info: ", rsl_ho_cmd_l3);
4491 if (rsl_ho_cmd_l3.l3_info.payload != rr_ho_cmd_enc) {
4492 log("FAIL: the BSC sent out a different L3 Info, not matching the RR Handover Command the other BSS forwarded.");
4493 setverdict(fail);
4494 } else {
4495 log("Success: the BSC sent out the same RR Handover Command the other BSS forwarded.");
4496 setverdict(pass);
4497 }
4498 }
4499
4500 f_sleep(0.2);
4501 f_rsl_send_l3(ts_RRM_HandoverFailure('00'O));
4502
4503 /* Should tell the MSC about the failure */
4504 BSSAP.receive(tr_BSSMAP_HandoverFailure);
4505
4506 f_sleep(1.0);
4507
4508 /* The old lchan and conn should still be active. See that arbitrary L3
4509 * is still going through. */
4510 var octetstring l3 := '0123456789'O;
4511 RSL.send(ts_RSL_DATA_IND(g_chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
4512 var template PDU_BSSAP exp_data := {
4513 discriminator := '1'B,
4514 spare := '0000000'B,
4515 dlci := '00'O,
4516 lengthIndicator := 5,
4517 pdu := {
4518 dtap := l3
4519 }
4520 };
4521 BSSAP.receive(exp_data);
4522 setverdict(pass);
4523 f_sleep(1.0);
4524
4525 setverdict(pass);
4526 f_sleep(1.0);
4527}
4528testcase TC_ho_out_fail_rr_ho_failure() runs on test_CT {
4529 var MSC_ConnHdlr vc_conn;
4530
4531 f_init(1, true);
4532 f_sleep(1.0);
4533
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004534 f_ctrs_bsc_and_bts_init();
4535
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004536 vc_conn := f_start_handler(refers(f_tc_ho_out_fail_rr_ho_failure));
4537 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004538
4539 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
4540 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
4541 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
4542 f_ctrs_bsc_and_bts_add(0, "handover:failed");
4543 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
4544 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:failed");
4545 f_ctrs_bsc_and_bts_verify();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004546}
4547
Neels Hofmeyr10f2bfa2019-07-09 19:33:29 +02004548/* BSC asks for inter-BSC-out HO, receives BSSMAP Handover Command, but then no reply is received about HO outcome
4549 * (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 +02004550 * and the lchan is released. */
4551private function f_tc_ho_out_fail_no_result_after_ho_cmd(charstring id) runs on MSC_ConnHdlr {
Daniel Willmann3b59eb52018-10-29 15:40:55 +01004552 g_pars := f_gen_test_hdlr_pars();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004553
4554 var PDU_BSSAP ass_req := f_gen_ass_req();
4555 ass_req.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4556 ass_req.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
4557 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4558 f_establish_fully(ass_req, exp_compl);
4559
Neels Hofmeyr666f0432020-07-04 00:53:07 +02004560 f_bts_0_cfg(BSCVTY, {"neighbor lac 99 arfcn 123 bsic any"});
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004561 f_vty_transceive(BSCVTY, "handover any to arfcn 123 bsic any");
4562
4563 BSSAP.receive(tr_BSSMAP_HandoverRequired);
4564
4565 f_sleep(0.5);
4566 /* The MSC negotiates Handover Request and Handover Request Ack with
4567 * the other BSS and comes back with a BSSMAP Handover Command
4568 * containing an RR Handover Command coming from the target BSS... */
4569
4570 var PDU_ML3_NW_MS rr_ho_cmd := valueof(ts_RR_HandoverCommand);
4571 log("Remote cell's RR Handover Command passed through as L3 Info: ", rr_ho_cmd);
4572 var octetstring rr_ho_cmd_enc := enc_PDU_ML3_NW_MS(rr_ho_cmd);
4573 log("Remote cell's RR Handover Command passed through as L3 Info, encoded: ", rr_ho_cmd_enc);
4574 BSSAP.send(ts_BSSMAP_HandoverCommand(rr_ho_cmd_enc));
4575
4576 /* expect the Handover Command to go out on RR */
4577 var RSL_Message rsl_ho_cmd
4578 RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, ?)) -> value rsl_ho_cmd;
4579 log("RSL Data Req went out to first BTS: ", rsl_ho_cmd);
4580 var RSL_IE_Body rsl_ho_cmd_l3;
4581 if (not f_rsl_find_ie(rsl_ho_cmd, RSL_IE_L3_INFO, rsl_ho_cmd_l3)) {
4582 log("RSL message contains no L3 Info IE, expected RR Handover Command");
4583 setverdict(fail);
4584 } else {
4585 log("Found L3 Info: ", rsl_ho_cmd_l3);
4586 if (rsl_ho_cmd_l3.l3_info.payload != rr_ho_cmd_enc) {
4587 log("FAIL: the BSC sent out a different L3 Info, not matching the RR Handover Command the other BSS forwarded.");
4588 setverdict(fail);
4589 } else {
4590 log("Success: the BSC sent out the same RR Handover Command the other BSS forwarded.");
4591 setverdict(pass);
4592 }
4593 }
4594
Neels Hofmeyr10f2bfa2019-07-09 19:33:29 +02004595 /* We get neither success nor failure report from the remote BSS. Eventually T8 times out and we run into 3GPP
4596 * TS 48.008 3.1.5.3.3 "Abnormal Conditions": Clear Request should go to the MSC, and RR should be released
4597 * after Clear Command */
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004598
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02004599 var PDU_BSSAP rx_clear_request;
Neels Hofmeyre1797aa2019-07-09 19:34:04 +02004600 BSSAP.receive(tr_BSSMAP_ClearRequest) -> value rx_clear_request;
4601 log("Got BSSMAP Clear Request");
4602 /* Instruct BSC to clear channel */
4603 var BssmapCause cause := bit2int(rx_clear_request.pdu.bssmap.clearRequest.cause.causeValue);
4604 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
4605
4606 var MgcpCommand mgcp;
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004607 interleave {
Neels Hofmeyr861a4c12018-11-07 01:23:17 +01004608 [] RSL.receive(tr_RSL_DEACT_SACCH(g_chan_nr)) {
4609 log("Got Deact SACCH");
4610 }
Harald Welte924b6ea2019-02-04 01:05:34 +01004611 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_RELEASE)) {
Neels Hofmeyr211169d2018-11-07 00:37:29 +01004612 log("Got RR Release");
4613 }
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004614 [] RSL.receive(tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL)) {
4615 log("Got RF Chan Rel");
4616 RSL.send(ts_RSL_RF_CHAN_REL_ACK(g_chan_nr));
4617 }
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004618 }
4619
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02004620 f_expect_dlcx_conns();
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004621
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004622 setverdict(pass);
4623 f_sleep(1.0);
4624}
Neels Hofmeyrd8a602c2019-07-09 19:46:01 +02004625testcase TC_ho_out_fail_no_result_after_ho_cmd() runs on test_CT {
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004626 var MSC_ConnHdlr vc_conn;
4627
4628 f_init(1, true);
4629 f_sleep(1.0);
4630
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004631 f_ctrs_bsc_and_bts_init();
4632
Neels Hofmeyrd8a602c2019-07-09 19:46:01 +02004633 vc_conn := f_start_handler(refers(f_tc_ho_out_fail_no_result_after_ho_cmd));
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004634 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004635
4636 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
4637 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
4638 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
4639 f_ctrs_bsc_and_bts_add(0, "handover:timeout");
4640 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
4641 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:timeout");
4642 f_ctrs_bsc_and_bts_verify();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004643}
4644
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004645private function f_tc_ho_into_this_bsc(charstring id) runs on MSC_ConnHdlr {
4646 /* Hack: the proper way would be to wait for the BSSMAP Handover Request ACK and extract the
4647 * actual assigned chan_nr from its L3 (RR Handover Command) message. But osmo-bsc starts acting
4648 * on the lchan even before we get a chance to evaluate the BSSMAP Handover Request ACK. So we
4649 * need to assume that osmo-bsc will activate TS 1 and already set up this lchan's RSL emulation
4650 * before we get started. */
4651 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
4652 f_rslem_register(0, new_chan_nr);
4653 g_chan_nr := new_chan_nr;
4654 f_sleep(1.0);
4655
4656 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
4657 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
4658 activate(as_Media());
4659
Neels Hofmeyr90f80962020-06-12 16:16:55 +02004660 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Pau Espin Pedrol07866632020-09-03 19:10:55 +02004661 f_gen_handover_req(aoip_tla := g_pars.host_aoip_tla)));
Harald Welte6811d102019-04-14 22:23:14 +02004662 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004663
4664 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
4665
4666 var PDU_BSSAP rx_bssap;
4667 var octetstring ho_command_str;
4668
4669 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
Pau Espin Pedrol76ba5412019-06-10 11:00:33 +02004670
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004671 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
4672 log("Received L3 Info in HO Request Ack: ", ho_command_str);
4673 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
4674 log("L3 Info in HO Request Ack is ", ho_command);
4675
4676 var GsmArfcn arfcn;
4677 var RslChannelNr actual_new_chan_nr;
4678 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
4679 actual_new_chan_nr, arfcn);
4680
4681 if (actual_new_chan_nr != new_chan_nr) {
4682 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
4683 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
4684 setverdict(fail);
4685 return;
4686 }
4687 log("Handover Command chan_nr is", actual_new_chan_nr);
4688
4689 /* Now the MSC forwards the RR Handover Command to the other BSC, which
4690 * tells the MS to handover to the new lchan. Here comes the new MS on
4691 * the new lchan with a Handover RACH: */
4692
4693 /* send handover detect */
4694
4695 RSL.send(ts_RSL_HANDO_DET(new_chan_nr));
4696
4697 BSSAP.receive(tr_BSSMAP_HandoverDetect);
4698
4699 /* send handover complete over the new channel */
4700
4701 var PDU_ML3_MS_NW l3_tx := valueof(ts_RRM_HandoverComplete('00'O));
4702 RSL.send(ts_RSL_EST_IND(new_chan_nr, valueof(ts_RslLinkID_DCCH(0)),
4703 enc_PDU_ML3_MS_NW(l3_tx)));
4704
4705 BSSAP.receive(tr_BSSMAP_HandoverComplete);
4706 setverdict(pass);
4707}
Pau Espin Pedrol07866632020-09-03 19:10:55 +02004708function f_tc_ho_into_this_bsc_main(TestHdlrParams pars) runs on test_CT {
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004709 var MSC_ConnHdlr vc_conn;
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004710
4711 f_init(1, true);
4712 f_sleep(1.0);
4713
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004714 f_ctrs_bsc_and_bts_init();
4715
Neels Hofmeyr90f80962020-06-12 16:16:55 +02004716 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
4717 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004718
4719 vc_conn := f_start_handler(refers(f_tc_ho_into_this_bsc), pars);
4720 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004721
4722 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
4723 f_ctrs_bsc_and_bts_add(0, "handover:completed");
4724 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:attempted");
4725 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:completed");
4726 f_ctrs_bsc_and_bts_verify();
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004727}
4728
Pau Espin Pedrol07866632020-09-03 19:10:55 +02004729testcase TC_ho_into_this_bsc() runs on test_CT {
4730 var TestHdlrParams pars := f_gen_test_hdlr_pars();
4731 f_tc_ho_into_this_bsc_main(pars);
4732}
4733
4734testcase TC_ho_into_this_bsc_tla_v6() runs on test_CT {
4735 var TestHdlrParams pars := f_gen_test_hdlr_pars();
4736 pars.host_aoip_tla := "::6";
4737 f_tc_ho_into_this_bsc_main(pars);
4738}
4739
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01004740private function f_tc_ho_in_fail_msc_clears(charstring id) runs on MSC_ConnHdlr {
4741 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
4742 f_rslem_register(0, new_chan_nr);
4743 g_chan_nr := new_chan_nr;
4744 f_sleep(1.0);
4745
4746 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
4747 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
4748 activate(as_Media());
4749
Neels Hofmeyr90f80962020-06-12 16:16:55 +02004750 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01004751 f_gen_handover_req()));
Harald Welte6811d102019-04-14 22:23:14 +02004752 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01004753
4754 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
4755
4756 var PDU_BSSAP rx_bssap;
4757 var octetstring ho_command_str;
4758
4759 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
4760
4761 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
4762 log("Received L3 Info in HO Request Ack: ", ho_command_str);
4763 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
4764 log("L3 Info in HO Request Ack is ", ho_command);
4765
4766 var GsmArfcn arfcn;
4767 var RslChannelNr actual_new_chan_nr;
4768 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
4769 actual_new_chan_nr, arfcn);
4770
4771 if (actual_new_chan_nr != new_chan_nr) {
4772 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
4773 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
4774 setverdict(fail);
4775 return;
4776 }
4777 log("Handover Command chan_nr is", actual_new_chan_nr);
4778
Neels Hofmeyr61ca08d2019-05-06 23:52:22 +02004779 /* For deterministic test results, give some time for the MGW endpoint to be configured */
4780 f_sleep(1.0);
4781
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01004782 /* Now the MSC forwards the RR Handover Command to the other BSC, which
4783 * tells the MS to handover to the new lchan. In this case, the MS
4784 * reports a Handover Failure to the old BSS, which forwards a BSSMAP
4785 * Handover Failure to the MSC. The procedure according to 3GPP TS
4786 * 48.008 3.1.5.3.2 "Handover Failure" is then that the MSC sends a
4787 * BSSMAP Clear Command: */
4788
4789 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_RADIO_INTERFACE_FAILURE_REVERSION;
4790 var BssmapCause cause := enum2int(cause_val);
4791 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
4792
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02004793 f_expect_dlcx_conns();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01004794 setverdict(pass);
4795 f_sleep(1.0);
4796
4797 setverdict(pass);
4798}
4799testcase TC_ho_in_fail_msc_clears() runs on test_CT {
4800 var MSC_ConnHdlr vc_conn;
4801 var TestHdlrParams pars := f_gen_test_hdlr_pars();
4802
4803 f_init(1, true);
4804 f_sleep(1.0);
4805
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004806 f_ctrs_bsc_and_bts_init();
4807
Neels Hofmeyr90f80962020-06-12 16:16:55 +02004808 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
4809 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01004810
4811 vc_conn := f_start_handler(refers(f_tc_ho_in_fail_msc_clears), pars);
4812 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004813
4814 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
4815 f_ctrs_bsc_and_bts_add(0, "handover:stopped");
4816 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:attempted");
4817 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:stopped");
4818 f_ctrs_bsc_and_bts_verify();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01004819}
4820
4821private function f_tc_ho_in_fail_msc_clears_after_ho_detect(charstring id) runs on MSC_ConnHdlr {
4822 /* Hack: the proper way would be to wait for the BSSMAP Handover Request ACK and extract the
4823 * actual assigned chan_nr from its L3 (RR Handover Command) message. But osmo-bsc starts acting
4824 * on the lchan even before we get a chance to evaluate the BSSMAP Handover Request ACK. So we
4825 * need to assume that osmo-bsc will activate TS 1 and already set up this lchan's RSL emulation
4826 * before we get started. */
4827 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
4828 f_rslem_register(0, new_chan_nr);
4829 g_chan_nr := new_chan_nr;
4830 f_sleep(1.0);
4831
4832 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
4833 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
4834 activate(as_Media());
4835
Neels Hofmeyr90f80962020-06-12 16:16:55 +02004836 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01004837 f_gen_handover_req()));
Harald Welte6811d102019-04-14 22:23:14 +02004838 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01004839
4840 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
4841
4842 var PDU_BSSAP rx_bssap;
4843 var octetstring ho_command_str;
4844
4845 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
4846
4847 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
4848 log("Received L3 Info in HO Request Ack: ", ho_command_str);
4849 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
4850 log("L3 Info in HO Request Ack is ", ho_command);
4851
4852 var GsmArfcn arfcn;
4853 var RslChannelNr actual_new_chan_nr;
4854 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
4855 actual_new_chan_nr, arfcn);
4856
4857 if (actual_new_chan_nr != new_chan_nr) {
4858 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
4859 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
4860 setverdict(fail);
4861 return;
4862 }
4863 log("Handover Command chan_nr is", actual_new_chan_nr);
4864
4865 /* Now the MSC forwards the RR Handover Command to the other BSC, which
4866 * tells the MS to handover to the new lchan. Here comes the new MS on
4867 * the new lchan with a Handover RACH: */
4868
4869 /* send handover detect */
4870
4871 RSL.send(ts_RSL_HANDO_DET(new_chan_nr));
4872
4873 BSSAP.receive(tr_BSSMAP_HandoverDetect);
4874
4875 /* The MSC chooses to clear the connection now, maybe we got the
4876 * Handover RACH on the new cell but the MS still signaled Handover
4877 * Failure to the old BSS? */
4878
4879 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_RADIO_INTERFACE_FAILURE_REVERSION;
4880 var BssmapCause cause := enum2int(cause_val);
4881 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
4882
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02004883 f_expect_dlcx_conns();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01004884 setverdict(pass);
4885 f_sleep(1.0);
4886}
4887testcase TC_ho_in_fail_msc_clears_after_ho_detect() runs on test_CT {
4888 var MSC_ConnHdlr vc_conn;
4889 var TestHdlrParams pars := f_gen_test_hdlr_pars();
4890
4891 f_init(1, true);
4892 f_sleep(1.0);
4893
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004894 f_ctrs_bsc_and_bts_init();
4895
Neels Hofmeyr90f80962020-06-12 16:16:55 +02004896 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
4897 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01004898
4899 vc_conn := f_start_handler(refers(f_tc_ho_in_fail_msc_clears_after_ho_detect), pars);
4900 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004901
4902 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
4903 f_ctrs_bsc_and_bts_add(0, "handover:stopped");
4904 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:attempted");
4905 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:stopped");
4906 f_ctrs_bsc_and_bts_verify();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01004907}
4908
4909/* The new BSS's lchan times out before the MSC decides that handover failed. */
4910private function f_tc_ho_in_fail_no_detect(charstring id) runs on MSC_ConnHdlr {
4911 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
4912 f_rslem_register(0, new_chan_nr);
4913 g_chan_nr := new_chan_nr;
4914 f_sleep(1.0);
4915
4916 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
4917 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
4918 activate(as_Media());
4919
Neels Hofmeyr90f80962020-06-12 16:16:55 +02004920 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01004921 f_gen_handover_req()));
Harald Welte6811d102019-04-14 22:23:14 +02004922 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01004923
4924 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
4925
4926 var PDU_BSSAP rx_bssap;
4927 var octetstring ho_command_str;
4928
4929 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
4930
4931 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
4932 log("Received L3 Info in HO Request Ack: ", ho_command_str);
4933 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
4934 log("L3 Info in HO Request Ack is ", ho_command);
4935
4936 var GsmArfcn arfcn;
4937 var RslChannelNr actual_new_chan_nr;
4938 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
4939 actual_new_chan_nr, arfcn);
4940
4941 if (actual_new_chan_nr != new_chan_nr) {
4942 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
4943 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
4944 setverdict(fail);
4945 return;
4946 }
4947 log("Handover Command chan_nr is", actual_new_chan_nr);
4948
4949 /* Now the MSC forwards the RR Handover Command to the other BSC, which
4950 * tells the MS to handover to the new lchan. But the MS never shows up
4951 * on the new lchan. */
4952
4953 BSSAP.receive(tr_BSSMAP_HandoverFailure);
4954
4955 /* Did osmo-bsc also send a Clear Request? */
4956 timer T := 0.5;
4957 T.start;
4958 alt {
4959 [] BSSAP.receive(tr_BSSMAP_ClearRequest);
4960 [] T.timeout { }
4961 }
4962
4963 /* MSC plays along with a Clear Command (no matter whether osmo-bsc
4964 * asked for it, this is a Handover Failure after all). */
4965
4966 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_RADIO_INTERFACE_FAILURE_REVERSION;
4967 var BssmapCause cause := enum2int(cause_val);
4968 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
4969
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02004970 f_expect_dlcx_conns();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01004971 setverdict(pass);
4972 f_sleep(1.0);
4973
4974 setverdict(pass);
4975}
4976testcase TC_ho_in_fail_no_detect() runs on test_CT {
4977 var MSC_ConnHdlr vc_conn;
4978 var TestHdlrParams pars := f_gen_test_hdlr_pars();
4979
4980 f_init(1, true);
4981 f_sleep(1.0);
4982
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004983 f_ctrs_bsc_and_bts_init();
4984
Neels Hofmeyr90f80962020-06-12 16:16:55 +02004985 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
4986 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01004987
4988 vc_conn := f_start_handler(refers(f_tc_ho_in_fail_no_detect), pars);
4989 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004990
4991 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
4992 f_ctrs_bsc_and_bts_add(0, "handover:error");
4993 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:attempted");
4994 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:error");
4995 f_ctrs_bsc_and_bts_verify();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01004996}
4997
4998/* Same as f_tc_ho_in_fail_no_detect, but MSC fails to send a Clear Command */
4999private function f_tc_ho_in_fail_no_detect2(charstring id) runs on MSC_ConnHdlr {
5000 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
5001 f_rslem_register(0, new_chan_nr);
5002 g_chan_nr := new_chan_nr;
5003 f_sleep(1.0);
5004
5005 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
5006 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
5007 activate(as_Media());
5008
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005009 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005010 f_gen_handover_req()));
Harald Welte6811d102019-04-14 22:23:14 +02005011 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005012
5013 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
5014
5015 var PDU_BSSAP rx_bssap;
5016 var octetstring ho_command_str;
5017
5018 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
5019
5020 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
5021 log("Received L3 Info in HO Request Ack: ", ho_command_str);
5022 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
5023 log("L3 Info in HO Request Ack is ", ho_command);
5024
5025 var GsmArfcn arfcn;
5026 var RslChannelNr actual_new_chan_nr;
5027 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
5028 actual_new_chan_nr, arfcn);
5029
5030 if (actual_new_chan_nr != new_chan_nr) {
5031 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
5032 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
5033 setverdict(fail);
5034 return;
5035 }
5036 log("Handover Command chan_nr is", actual_new_chan_nr);
5037
5038 /* Now the MSC forwards the RR Handover Command to the other BSC, which
5039 * tells the MS to handover to the new lchan. But the MS never shows up
5040 * on the new lchan. */
5041
5042 BSSAP.receive(tr_BSSMAP_HandoverFailure);
5043
5044 /* MSC plays dumb and sends no Clear Command */
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005045 var PDU_BSSAP rx_clear_request;
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02005046
5047 BSSAP.receive(tr_BSSMAP_ClearRequest) -> value rx_clear_request {
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005048 var BssmapCause cause := bit2int(rx_clear_request.pdu.bssmap.clearRequest.cause.causeValue);
5049 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
5050 };
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02005051 f_expect_dlcx_conns();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005052 setverdict(pass);
5053 f_sleep(1.0);
5054}
5055testcase TC_ho_in_fail_no_detect2() runs on test_CT {
5056 var MSC_ConnHdlr vc_conn;
5057 var TestHdlrParams pars := f_gen_test_hdlr_pars();
5058
5059 f_init(1, true);
5060 f_sleep(1.0);
5061
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005062 f_ctrs_bsc_and_bts_init();
5063
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005064 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
5065 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005066
5067 vc_conn := f_start_handler(refers(f_tc_ho_in_fail_no_detect2), pars);
5068 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005069
5070 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5071 f_ctrs_bsc_and_bts_add(0, "handover:error");
5072 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:attempted");
5073 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:error");
5074 f_ctrs_bsc_and_bts_verify();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005075}
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005076
Neels Hofmeyr91401012019-07-11 00:42:35 +02005077type record of charstring Commands;
5078
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005079private function f_bts_0_cfg(TELNETasp_PT pt, Commands cmds := {})
Neels Hofmeyr91401012019-07-11 00:42:35 +02005080{
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005081 f_vty_enter_cfg_bts(pt, 0);
Neels Hofmeyr91401012019-07-11 00:42:35 +02005082 for (var integer i := 0; i < sizeof(cmds); i := i+1) {
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005083 f_vty_transceive(pt, cmds[i]);
Neels Hofmeyr91401012019-07-11 00:42:35 +02005084 }
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005085 f_vty_transceive(pt, "end");
Neels Hofmeyr91401012019-07-11 00:42:35 +02005086}
5087
Pau Espin Pedrolc675b612020-01-09 19:55:40 +01005088private function f_cs7_inst_0_cfg(TELNETasp_PT pt, Commands cmds := {})
5089{
5090 f_vty_enter_cfg_cs7_inst(pt, 0);
5091 for (var integer i := 0; i < sizeof(cmds); i := i+1) {
5092 f_vty_transceive(pt, cmds[i]);
5093 }
5094 f_vty_transceive(pt, "end");
5095}
5096
Neels Hofmeyr91401012019-07-11 00:42:35 +02005097private function f_probe_for_handover(charstring log_label,
5098 charstring log_descr,
5099 charstring handover_vty_cmd,
5100 boolean expect_handover,
5101 boolean is_inter_bsc_handover := false)
5102runs on MSC_ConnHdlr
5103{
Neels Hofmeyrb3fc8982020-05-11 00:16:42 +02005104 /* We're going to thwart any and all handover attempts, just be ready to handle (and ignore) handover target
5105 * lchans to be established on bts 1 or bts 2. */
5106 f_rslem_suspend(RSL1_PROC);
5107 f_rslem_suspend(RSL2_PROC);
5108
Neels Hofmeyr91401012019-07-11 00:42:35 +02005109 var RSL_Message rsl;
5110
5111 var charstring log_msg := " (expecting handover)"
5112 if (not expect_handover) {
5113 log_msg := " (expecting NO handover)";
5114 }
5115 log("f_probe_for_handover starting: " & log_label & ": " & log_descr & log_msg);
5116 f_vty_transceive(BSCVTY, handover_vty_cmd);
5117
Neels Hofmeyr91401012019-07-11 00:42:35 +02005118 timer T := 2.0;
5119 T.start;
5120
5121 alt {
5122 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr)) -> value rsl {
5123 var PDU_ML3_NW_MS l3 := dec_PDU_ML3_NW_MS(rsl.ies[2].body.l3_info.payload);
5124 log("Rx L3 from net: ", l3);
5125 if (ischosen(l3.msgs.rrm.handoverCommand)) {
5126 var RslChannelNr new_chan_nr;
5127 var GsmArfcn arfcn;
5128 f_ChDesc2RslChanNr(l3.msgs.rrm.handoverCommand.channelDescription2,
5129 new_chan_nr, arfcn);
5130 log("Handover to new chan ", new_chan_nr, " on ARFCN ", arfcn);
5131 log(l3.msgs.rrm.handoverCommand);
5132
5133 /* Need to register for new lchan on new BTS -- it's either bts 1 or bts 2. It doesn't really
5134 * matter on which BTS it really is, we're not going to follow through an entire handover
5135 * anyway. */
5136 f_rslem_register(0, new_chan_nr, RSL1_PROC);
5137 f_rslem_resume(RSL1_PROC);
5138 f_rslem_register(0, new_chan_nr, RSL2_PROC);
5139 f_rslem_resume(RSL2_PROC);
5140
5141 if (expect_handover and not is_inter_bsc_handover) {
5142 setverdict(pass);
5143 log("f_probe_for_handover(" & log_label & "): Got RSL Handover Command as expected.");
5144 } else {
5145 setverdict(fail, "f_probe_for_handover(" & log_label & "): Expected none, but got RSL Handover Command. "
5146 & log_label & ": " & log_descr);
5147 }
5148
5149 log("f_probe_for_handover(" & log_label & "): Ending the test: Handover Failure stops the procedure.");
5150 /* osmo-bsc has triggered Handover. That's all we need to know for this test, reply with
5151 * Handover Failure. */
5152 f_rsl_send_l3(ts_RRM_HandoverFailure('00'O));
5153
5154 /* target BTS is told to release lchan again; don't care which BTS nor what messages. */
5155 f_sleep(0.5);
5156 RSL1.clear;
5157 RSL2.clear;
5158 log("f_probe_for_handover(" & log_label & "): done (got RSL Handover Command)");
5159 break;
5160 } else {
5161 repeat;
5162 }
5163 }
5164 [] BSSAP.receive(tr_BSSMAP_HandoverRequired) {
5165 if (expect_handover and is_inter_bsc_handover) {
5166 setverdict(pass);
5167 log("f_probe_for_handover(" & log_label & "): Got BSSMAP Handover Required as expected.");
5168 } else {
5169 setverdict(fail, "f_probe_for_handover(" & log_label & "): Expected none, but got BSSMAP Handover Required. "
5170 & log_label & ": " & log_descr);
5171 }
5172
5173 log("f_probe_for_handover(" & log_label & "): done (got BSSMAP Handover Required)");
5174
5175 /* Note: f_tc_ho_neighbor_config_start() sets T7, the timeout for BSSMAP Handover Required, to
5176 * 1 second. There is no legal way to quickly abort a handover after a BSSMAP Handover Required,
5177 * setting a short timeout and waiting is the only way. */
5178 log("f_probe_for_handover(" & log_label & "): waiting for inter-BSC HO to time out...");
5179 f_sleep(1.5);
5180 log("f_probe_for_handover(" & log_label & "): ...done");
5181
5182 break;
5183 }
5184 [] T.timeout {
5185 if (expect_handover) {
5186 setverdict(fail, "f_probe_for_handover(" & log_label & "): Expected Handover, but got none. "
5187 & log_label & ": " & log_descr);
5188 } else {
5189 setverdict(pass);
5190 log("f_probe_for_handover(" & log_label & "): Got no Handover, as expected.");
5191 }
5192 log("f_probe_for_handover(" & log_label & "): done (got no Handover)");
5193 break;
5194 }
5195 }
5196
5197 f_rslem_resume(RSL1_PROC);
5198 f_rslem_resume(RSL2_PROC);
5199 f_sleep(3.0);
5200 RSL.clear;
5201
5202 log("f_probe_for_handover(" & log_label & "): done clearing");
5203}
5204
5205/* Test the effect of various neighbor configuration scenarios:
5206 *
5207 * To avoid complexity, block off any actual handover operation, and always remain on the lchan at bts 0.
5208 * Reconfigure the neighbors for bts 0, trigger a Handover, and probe whether osmo-bsc does or doesn't start HO.
5209 */
5210private function f_tc_ho_neighbor_config_start() runs on MSC_ConnHdlr {
5211 g_pars := f_gen_test_hdlr_pars();
5212 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
5213 var PDU_BSSAP ass_cmd := f_gen_ass_req();
5214 const OCT8 kc := '0001020304050607'O;
5215
5216 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
5217 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
5218
5219 /* Establish lchan at bts 0 */
5220 f_establish_fully(ass_cmd, exp_compl);
5221
5222 /* Shorten the inter-BSC Handover timeout, to not wait so long for inter-BSC Handovers */
5223 f_vty_enter_cfg_network(BSCVTY);
5224 f_vty_transceive(BSCVTY, "timer T7 1");
5225 f_vty_transceive(BSCVTY, "end");
5226}
5227
5228private function f_tc_ho_neighbor_config_1(charstring id) runs on MSC_ConnHdlr {
5229 f_tc_ho_neighbor_config_start();
5230
5231 /*
5232 * bts 0 ARFCN 871 BSIC 10
5233 * bts 1 ARFCN 871 BSIC 11
5234 * bts 2 ARFCN 871 BSIC 12
5235 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
5236 */
5237
5238 log("f_tc_ho_neighbor_config: 1. No 'neighbor' config");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005239 f_bts_0_cfg(BSCVTY, {"no neighbors"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02005240 f_probe_for_handover("1.a", "HO to bts 1 works, implicitly listed as neighbor (legacy behavior when none are configured)",
5241 "handover any to arfcn 871 bsic 11",
5242 true);
5243
5244 f_probe_for_handover("1.b", "HO to unknown cell does not start",
5245 "handover any to arfcn 13 bsic 39",
5246 false);
5247
5248 f_probe_for_handover("1.c", "HO to 871-12 is ambiguous = error",
5249 "handover any to arfcn 871 bsic 12",
5250 false);
5251
5252 f_probe_for_handover("1.d", "HO to 871-11 still works (verify that this test properly cleans up)",
5253 "handover any to arfcn 871 bsic 11",
5254 true);
5255}
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005256testcase TC_ho_neighbor_config_1() runs on test_CT {
5257 var MSC_ConnHdlr vc_conn;
5258 f_init(3, true, guard_timeout := 60.0);
5259 f_sleep(1.0);
5260 f_ctrs_bsc_and_bts_init();
5261 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_1));
5262 vc_conn.done;
5263
5264 /* f_tc_ho_neighbor_config_start() */
5265 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5266 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5267
5268 /* 1.a */
5269 /* "failed" means a handover was triggered and started (which is all this test aims for) and the test ended the
5270 * handover quickly by sending a Handover Failure message. */
5271 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5272 f_ctrs_bsc_and_bts_add(0, "handover:failed");
5273 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
5274 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:failed");
5275
5276 /* 1.b */
5277 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5278 f_ctrs_bsc_and_bts_add(0, "handover:error");
5279
5280 /* 1.c */
5281 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5282 f_ctrs_bsc_and_bts_add(0, "handover:error");
5283
5284 /* 1.d */
5285 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5286 f_ctrs_bsc_and_bts_add(0, "handover:failed");
5287 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
5288 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:failed");
5289
5290 f_ctrs_bsc_and_bts_verify();
5291}
5292
Neels Hofmeyr91401012019-07-11 00:42:35 +02005293private function f_tc_ho_neighbor_config_2(charstring id) runs on MSC_ConnHdlr {
5294 f_tc_ho_neighbor_config_start();
5295
5296 /*
5297 * bts 0 ARFCN 871 BSIC 10
5298 * bts 1 ARFCN 871 BSIC 11
5299 * bts 2 ARFCN 871 BSIC 12
5300 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
5301 */
5302
5303 log("f_tc_ho_neighbor_config: 2. explicit local neighbor: 'neighbor bts 1'");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005304 f_bts_0_cfg(BSCVTY, {"neighbor bts 1"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02005305 f_sleep(0.5);
5306
5307 f_probe_for_handover("2.a", "HO to bts 1 works, explicitly listed as neighbor",
5308 "handover any to arfcn 871 bsic 11",
5309 true);
5310
5311 f_probe_for_handover("2.b", "HO to bts 2 doesn't work, not listed as neighbor",
5312 "handover any to arfcn 871 bsic 12",
5313 false);
5314}
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005315testcase TC_ho_neighbor_config_2() runs on test_CT {
5316 var MSC_ConnHdlr vc_conn;
5317 f_init(3, true, guard_timeout := 50.0);
5318 f_sleep(1.0);
5319 f_ctrs_bsc_and_bts_init();
5320 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_2));
5321 vc_conn.done;
5322
5323 /* f_tc_ho_neighbor_config_start() */
5324 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5325 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5326
5327 /* 2.a */
5328 /* "failed" means a handover was triggered and started (which is all this test aims for) and the test ended the
5329 * handover quickly by sending a Handover Failure message. */
5330 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5331 f_ctrs_bsc_and_bts_add(0, "handover:failed");
5332 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
5333 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:failed");
5334
5335 /* 2.b */
5336 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5337 f_ctrs_bsc_and_bts_add(0, "handover:error");
5338
5339 f_ctrs_bsc_and_bts_verify();
5340}
5341
Neels Hofmeyr91401012019-07-11 00:42:35 +02005342private function f_tc_ho_neighbor_config_3(charstring id) runs on MSC_ConnHdlr {
5343 f_tc_ho_neighbor_config_start();
5344
5345 /*
5346 * bts 0 ARFCN 871 BSIC 10
5347 * bts 1 ARFCN 871 BSIC 11
5348 * bts 2 ARFCN 871 BSIC 12
5349 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
5350 */
5351
5352 log("f_tc_ho_neighbor_config: 3. explicit local neighbor: 'neighbor bts 2'");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005353 f_bts_0_cfg(BSCVTY, {"no neighbors", "neighbor bts 2"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02005354 f_sleep(0.5);
5355
5356 f_probe_for_handover("3.a", "HO to bts 1 doesn't work, not listed as neighbor",
5357 "handover any to arfcn 871 bsic 11",
5358 false);
5359 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",
5360 "handover any to arfcn 871 bsic 12",
5361 true);
5362}
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005363testcase TC_ho_neighbor_config_3() runs on test_CT {
5364 var MSC_ConnHdlr vc_conn;
5365 f_init(3, true, guard_timeout := 50.0);
5366 f_sleep(1.0);
5367 f_ctrs_bsc_and_bts_init();
5368 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_3));
5369 vc_conn.done;
5370
5371 /* f_tc_ho_neighbor_config_start() */
5372 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5373 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5374
5375 /* 3.a */
5376 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5377 f_ctrs_bsc_and_bts_add(0, "handover:error");
5378
5379 /* 3.b */
5380 /* "failed" means a handover was triggered and started (which is all this test aims for) and the test ended the
5381 * handover quickly by sending a Handover Failure message. */
5382 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5383 f_ctrs_bsc_and_bts_add(0, "handover:failed");
5384 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
5385 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:failed");
5386
5387 f_ctrs_bsc_and_bts_verify();
5388}
5389
Neels Hofmeyr91401012019-07-11 00:42:35 +02005390private function f_tc_ho_neighbor_config_4(charstring id) runs on MSC_ConnHdlr {
5391 f_tc_ho_neighbor_config_start();
5392
5393 /*
5394 * bts 0 ARFCN 871 BSIC 10
5395 * bts 1 ARFCN 871 BSIC 11
5396 * bts 2 ARFCN 871 BSIC 12
5397 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
5398 */
5399
5400 log("f_tc_ho_neighbor_config: 4. explicit remote neighbor: 'neighbor lac 99 arfcn 123 bsic 45'");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005401 f_bts_0_cfg(BSCVTY, {"no neighbors", "neighbor lac 99 arfcn 123 bsic 45"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02005402 f_sleep(0.5);
5403
5404 f_probe_for_handover("4.a", "HO to bts 1 doesn't work, not listed as neighbor",
5405 "handover any to arfcn 871 bsic 11",
5406 false);
5407 f_probe_for_handover("4.b", "HO to bts 2 doesn't work, not listed as neighbor",
5408 "handover any to arfcn 871 bsic 12",
5409 false);
5410 f_probe_for_handover("4.c", "HO to 123-45 triggers inter-BSC HO",
5411 "handover any to arfcn 123 bsic 45",
5412 true, true);
5413}
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005414testcase TC_ho_neighbor_config_4() runs on test_CT {
5415 var MSC_ConnHdlr vc_conn;
5416 f_init(3, true, guard_timeout := 50.0);
5417 f_sleep(1.0);
5418 f_ctrs_bsc_and_bts_init();
5419 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_4));
5420 vc_conn.done;
5421
5422 /* f_tc_ho_neighbor_config_start() */
5423 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5424 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5425
5426 /* 4.a */
5427 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5428 f_ctrs_bsc_and_bts_add(0, "handover:error");
5429
5430 /* 4.b */
5431 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5432 f_ctrs_bsc_and_bts_add(0, "handover:error");
5433
5434 /* 4.c */
5435 /* "timeout" means a handover was triggered and started (which is all this test aims for) and the test ended the
5436 * handover quickly by timing out after the Handover Required message */
5437 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5438 f_ctrs_bsc_and_bts_add(0, "handover:timeout");
5439 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
5440 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:timeout");
5441
5442 f_ctrs_bsc_and_bts_verify();
5443}
5444
Neels Hofmeyr91401012019-07-11 00:42:35 +02005445private function f_tc_ho_neighbor_config_5(charstring id) runs on MSC_ConnHdlr {
5446 f_tc_ho_neighbor_config_start();
5447
5448 /*
5449 * bts 0 ARFCN 871 BSIC 10
5450 * bts 1 ARFCN 871 BSIC 11
5451 * bts 2 ARFCN 871 BSIC 12
5452 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
5453 */
5454
5455 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 +02005456 f_bts_0_cfg(BSCVTY, {"no neighbors", "neighbor lac 99 arfcn 871 bsic 12"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02005457 f_sleep(0.5);
5458
5459 f_probe_for_handover("5.a", "HO to 871-12 triggers inter-BSC HO (ignoring local cells with same ARFCN+BSIC)",
5460 "handover any to arfcn 871 bsic 12",
5461 true, true);
5462}
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005463testcase TC_ho_neighbor_config_5() runs on test_CT {
5464 var MSC_ConnHdlr vc_conn;
5465 f_init(3, true);
5466 f_sleep(1.0);
5467 f_ctrs_bsc_and_bts_init();
5468 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_5));
5469 vc_conn.done;
5470
5471 /* f_tc_ho_neighbor_config_start() */
5472 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5473 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5474
5475 /* 5 */
5476 /* "timeout" means a handover was triggered and started (which is all this test aims for) and the test ended the
5477 * handover quickly by timing out after the Handover Required message */
5478 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5479 f_ctrs_bsc_and_bts_add(0, "handover:timeout");
5480 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
5481 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:timeout");
5482
5483 f_ctrs_bsc_and_bts_verify();
5484}
5485
Neels Hofmeyr91401012019-07-11 00:42:35 +02005486private function f_tc_ho_neighbor_config_6(charstring id) runs on MSC_ConnHdlr {
5487 f_tc_ho_neighbor_config_start();
5488
5489 /*
5490 * bts 0 ARFCN 871 BSIC 10
5491 * bts 1 ARFCN 871 BSIC 11
5492 * bts 2 ARFCN 871 BSIC 12
5493 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
5494 */
5495
5496 log("f_tc_ho_neighbor_config: 6. config error: explicit local and remote neighbors with ambiguous ARFCN+BSIC:"
5497 & " 'neighbor bts 2; neighbor lac 99 arfcn 871 bsic 12'");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005498 f_bts_0_cfg(BSCVTY, {"no neighbors", "neighbor bts 2", "neighbor lac 99 arfcn 871 bsic 12"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02005499 f_sleep(0.5);
5500
5501 f_probe_for_handover("6.a", "HO to 871-12 is ambiguous = error",
5502 "handover any to arfcn 871 bsic 12",
5503 false);
5504}
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005505testcase TC_ho_neighbor_config_6() runs on test_CT {
5506 var MSC_ConnHdlr vc_conn;
5507 f_init(3, true);
5508 f_sleep(1.0);
5509 f_ctrs_bsc_and_bts_init();
5510 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_6));
5511 vc_conn.done;
5512
5513 /* f_tc_ho_neighbor_config_start() */
5514 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5515 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5516
5517 /* 6.a */
5518 /* "timeout" means a handover was triggered and started (which is all this test aims for) and the test ended the
5519 * handover quickly by timing out after the Handover Required message */
5520 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5521 f_ctrs_bsc_and_bts_add(0, "handover:error");
5522
5523 f_ctrs_bsc_and_bts_verify();
5524}
5525
Neels Hofmeyr91401012019-07-11 00:42:35 +02005526private function f_tc_ho_neighbor_config_7(charstring id) runs on MSC_ConnHdlr {
5527 f_tc_ho_neighbor_config_start();
5528
5529 /*
5530 * bts 0 ARFCN 871 BSIC 10
5531 * bts 1 ARFCN 871 BSIC 11
5532 * bts 2 ARFCN 871 BSIC 12
5533 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
5534 */
5535
5536 log("f_tc_ho_neighbor_config: 7. explicit local and remote neighbors:"
5537 & " 'neighbor bts 2; neighbor lac 99 arfcn 123 bsic 45'");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005538 f_bts_0_cfg(BSCVTY, {"no neighbors", "neighbor bts 2", "neighbor lac 99 arfcn 123 bsic 45"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02005539 f_sleep(0.5);
5540
5541 f_probe_for_handover("7.a", "HO to 871-12 does HO to bts 2",
5542 "handover any to arfcn 871 bsic 12",
5543 true);
5544 f_probe_for_handover("7.b", "HO to 123-45 triggers inter-BSC HO",
5545 "handover any to arfcn 123 bsic 45",
5546 true, true);
5547}
Neels Hofmeyr91401012019-07-11 00:42:35 +02005548testcase TC_ho_neighbor_config_7() runs on test_CT {
5549 var MSC_ConnHdlr vc_conn;
Neels Hofmeyrf2b88032020-06-16 00:35:04 +02005550 f_init(3, true, guard_timeout := 50.0);
Neels Hofmeyr91401012019-07-11 00:42:35 +02005551 f_sleep(1.0);
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005552 f_ctrs_bsc_and_bts_init();
Neels Hofmeyr91401012019-07-11 00:42:35 +02005553 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_7));
5554 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005555
5556 /* f_tc_ho_neighbor_config_start() */
5557 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5558 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5559
5560 /* 7.a */
5561 /* "failed" means a handover was triggered and started (which is all this test aims for) and the test ended the
5562 * handover quickly by sending a Handover Failure message. */
5563 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5564 f_ctrs_bsc_and_bts_add(0, "handover:failed");
5565 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
5566 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:failed");
5567
5568 /* 7.b */
5569 /* "timeout" means a handover was triggered and started (which is all this test aims for) and the test ended the
5570 * handover quickly by timing out after the Handover Required message */
5571 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5572 f_ctrs_bsc_and_bts_add(0, "handover:timeout");
5573 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
5574 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:timeout");
5575
5576 f_ctrs_bsc_and_bts_verify();
Neels Hofmeyr91401012019-07-11 00:42:35 +02005577}
5578
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01005579/* OS#3041: Open and close N connections in a normal fashion, and expect no
5580 * BSSMAP Reset just because of that. */
5581testcase TC_bssap_rlsd_does_not_cause_bssmap_reset() runs on test_CT {
5582 var default d;
5583 var integer i;
5584 var DchanTuple dt;
5585
5586 f_init();
5587
5588 /* Wait for initial BSSMAP Reset to pass */
5589 f_sleep(4.0);
5590
5591 d := activate(no_bssmap_reset());
5592
5593 /* Setup up a number of connections and RLSD them again from the MSC
5594 * side. In the buggy behavior, the fourth one triggers BSSMAP Reset.
5595 * Let's do it some more times for good measure. */
Harald Weltec3260d92018-06-11 17:48:16 +02005596 for (i := 0; i < 4; i := i+1) {
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01005597 /* Since we're doing a lot of runs, give each one a fresh
5598 * T_guard from the top. */
5599 T_guard.start;
5600
5601 /* Setup a BSSAP connection and clear it right away. This is
5602 * the MSC telling the BSC about a planned release, it's not an
5603 * erratic loss of a connection. */
Harald Weltea1897182018-06-11 13:53:09 +02005604 dt := f_est_dchan(int2oct(i,1), 23+i, '00010203040506'O);
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01005605
5606 /* MSC disconnects (RLSD). */
5607 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
5608 }
5609
5610 /* In the buggy behavior, a timeout of 2 seconds happens between above
5611 * trigger (logs "SIGTRAN connection down, reconnecting...") and the
5612 * actual BSSMAP Reset. Wait a bit longer just to make sure. */
5613 f_sleep(4.0);
5614
5615 deactivate(d);
5616 f_shutdown_helper();
5617}
Harald Welte552620d2017-12-16 23:21:36 +01005618
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01005619/* OS#3041: Open and close N connections in a normal fashion, and expect no
5620 * BSSMAP Reset just because of that. Invoke the release by a BSSMAP Clear from
5621 * the MSC. */
5622testcase TC_bssmap_clear_does_not_cause_bssmap_reset() runs on test_CT {
5623 var default d;
5624 var integer i;
5625 var DchanTuple dt;
5626 var BSSAP_N_DATA_ind rx_di;
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01005627 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_CALL_CONTROL;
5628 var BssmapCause cause := enum2int(cause_val);
5629
5630 f_init();
5631
5632 /* Wait for initial BSSMAP Reset to pass */
5633 f_sleep(4.0);
5634
5635 d := activate(no_bssmap_reset());
5636
5637 /* Setup up a number of connections and RLSD them again from the MSC
5638 * side. In the buggy behavior, the fourth one triggers BSSMAP Reset.
5639 * Let's do it some more times for good measure. */
5640 for (i := 0; i < 8; i := i+1) {
5641 /* Since we're doing a lot of runs, give each one a fresh
5642 * T_guard from the top. */
5643 T_guard.start;
5644
5645 /* Setup a BSSAP connection and clear it right away. This is
5646 * the MSC telling the BSC about a planned release, it's not an
5647 * erratic loss of a connection. */
Harald Weltea1897182018-06-11 13:53:09 +02005648 dt := f_est_dchan(int2oct(i,1), 23+i, '00010203040506'O);
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01005649
5650 /* Instruct BSC to clear channel */
5651 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
5652
5653 /* expect BSC to disable the channel */
Harald Welte641fcbe2018-06-14 10:58:35 +02005654 f_exp_chan_rel_and_clear(dt, 0);
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01005655 }
5656
5657 /* In the buggy behavior, a timeout of 2 seconds happens between above
5658 * trigger (logs "SIGTRAN connection down, reconnecting...") and the
5659 * actual BSSMAP Reset. Wait a bit longer just to make sure. */
5660 f_sleep(4.0);
5661
5662 deactivate(d);
5663 f_shutdown_helper();
5664}
5665
Neels Hofmeyrfd445c32018-03-09 15:39:31 +01005666/* OS#3041: Open and close N connections in a normal fashion, and expect no
5667 * BSSMAP Reset just because of that. Close connections from the MS side with a
5668 * Release Ind on RSL. */
5669testcase TC_ms_rel_ind_does_not_cause_bssmap_reset() runs on test_CT {
5670 var default d;
5671 var integer i;
5672 var DchanTuple dt;
5673 var BSSAP_N_DATA_ind rx_di;
Neels Hofmeyrfd445c32018-03-09 15:39:31 +01005674 var integer j;
5675
5676 f_init();
5677
5678 /* Wait for initial BSSMAP Reset to pass */
5679 f_sleep(4.0);
5680
5681 d := activate(no_bssmap_reset());
5682
5683 /* Setup up a number of connections and RLSD them again from the MSC
5684 * side. In the buggy behavior, the fourth one triggers BSSMAP Reset.
5685 * Let's do it some more times for good measure. */
5686 for (i := 0; i < 8; i := i+1) {
5687 /* Since we're doing a lot of runs, give each one a fresh
5688 * T_guard from the top. */
5689 T_guard.start;
5690
5691 /* Setup a BSSAP connection and clear it right away. This is
5692 * the MSC telling the BSC about a planned release, it's not an
5693 * erratic loss of a connection. */
5694 dt := f_est_dchan('23'O, 23, '00010203040506'O);
5695
5696 /* simulate RLL REL IND */
5697 f_ipa_tx(0, ts_RSL_REL_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0))));
5698
5699 /* expect Clear Request on MSC side */
5700 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearRequest)) -> value rx_di;
5701
5702 /* Instruct BSC to clear channel */
5703 var BssmapCause cause := bit2int(rx_di.userData.pdu.bssmap.clearRequest.cause.causeValue);
5704 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
5705
5706 /* expect BSC to disable the channel */
Harald Welte641fcbe2018-06-14 10:58:35 +02005707 f_exp_chan_rel_and_clear(dt, 0);
Neels Hofmeyrfd445c32018-03-09 15:39:31 +01005708 }
5709
5710 /* In the buggy behavior, a timeout of 2 seconds happens between above
5711 * trigger (logs "SIGTRAN connection down, reconnecting...") and the
5712 * actual BSSMAP Reset. Wait a bit longer just to make sure. */
5713 f_sleep(4.0);
5714
5715 deactivate(d);
5716 f_shutdown_helper();
5717}
5718
Harald Welte94e0c342018-04-07 11:33:23 +02005719/***********************************************************************
5720 * IPA style dynamic PDCH
5721 ***********************************************************************/
5722
5723private function f_dyn_ipa_pdch_act(integer bts_nr, integer trx_nr, integer ts_nr,
5724 template (omit) RSL_Cause nack := omit)
5725runs on test_CT {
5726 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(ts_nr));
5727 var RSL_Message rsl_unused;
5728 /* ask BSC via VTY to activate a given IPA style chan as PDCH */
5729 f_vty_ts_action("pdch activate", bts_nr, trx_nr, ts_nr);
5730 /* expect the BSC to issue the related RSL command */
5731 rsl_unused := f_exp_ipa_rx(0, tr_RSL_IPA_PDCH_ACT(chan_nr));
5732 if (istemplatekind(nack, "omit")) {
5733 /* respond with a related acknowledgement */
5734 f_ipa_tx(0, ts_RSL_IPA_PDCH_ACT_ACK(chan_nr, ts_RSL_IE_FrameNumber(2342)));
5735 } else {
5736 f_ipa_tx(0, ts_RSL_IPA_PDCH_ACT_NACK(chan_nr, valueof(nack)));
5737 }
5738}
5739
5740private function f_dyn_ipa_pdch_deact(integer bts_nr, integer trx_nr, integer ts_nr,
5741 template (omit) RSL_Cause nack := omit)
5742runs on test_CT {
5743 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(ts_nr));
5744 var RSL_Message rsl_unused;
5745 /* ask BSC via VTY to activate a given IPA style chan as PDCH */
5746 f_vty_ts_action("pdch deactivate", bts_nr, trx_nr, ts_nr);
5747 /* expect the BSC to issue the related RSL command */
5748 rsl_unused := f_exp_ipa_rx(0, tr_RSL_IPA_PDCH_DEACT(chan_nr));
5749 if (istemplatekind(nack, "omit")) {
5750 /* respond with a related acknowledgement */
5751 f_ipa_tx(0, ts_RSL_IPA_PDCH_DEACT_ACK(chan_nr));
5752 } else {
5753 f_ipa_tx(0, ts_RSL_IPA_PDCH_DEACT_NACK(chan_nr, valueof(nack)));
5754 }
5755}
5756
5757private function f_ts_dyn_mode_get(integer bts_nr, integer trx_nr, integer ts_nr)
5758runs on test_CT return charstring {
5759 var charstring cmd, resp;
5760 cmd := "show timeslot "&int2str(bts_nr)&" "&int2str(trx_nr)&" "&int2str(ts_nr);
Stefan Sperlingcff13562018-11-13 15:24:06 +01005761 return f_vty_transceive_match_regexp_retry(BSCVTY, cmd, "*\((*)\)*", 0, 4, 1.0);
Harald Welte94e0c342018-04-07 11:33:23 +02005762}
5763
5764private function f_ts_dyn_mode_assert(integer bts_nr, integer trx_nr, integer ts_nr,
5765 template charstring exp)
5766runs on test_CT {
5767 var charstring mode := f_ts_dyn_mode_get(bts_nr, trx_nr, ts_nr);
5768 if (not match(mode, exp)) {
5769 setverdict(fail, "Unexpected TS Mode: ", mode);
Daniel Willmannafce8662018-07-06 23:11:32 +02005770 mtc.stop;
Harald Welte94e0c342018-04-07 11:33:23 +02005771 }
5772}
5773
5774private function f_ts_set_chcomb(integer bts_nr, integer trx_nr, integer ts_nr, charstring chcomb)
5775runs on test_CT {
5776 f_vty_enter_cfg_ts(BSCVTY, bts_nr, trx_nr, ts_nr);
5777 f_vty_transceive(BSCVTY, "phys_chan_config " & chcomb);
5778 f_vty_transceive(BSCVTY, "end");
5779}
5780
5781private const charstring TCHF_MODE := "TCH/F mode";
5782private const charstring TCHH_MODE := "TCH/H mode";
5783private const charstring PDCH_MODE := "PDCH mode";
5784private const charstring NONE_MODE := "NONE mode";
5785
5786/* Test IPA PDCH activation / deactivation triggered by VTY */
5787testcase TC_dyn_pdch_ipa_act_deact() runs on test_CT {
5788 var RSL_Message rsl_unused;
5789
5790 /* change Timeslot 6 before f_init() starts RSL */
5791 f_init_vty();
5792 f_ts_set_chcomb(0, 0, 6, "TCH/F_PDCH");
5793 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
5794
5795 f_init(1, false);
5796 f_sleep(1.0);
5797
5798 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(6));
5799
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02005800 log("TCH/F_PDCH pchan starts out in TCH/F mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02005801 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
5802 /* The BSC will activate the dynamic PDCH by default, so confirm that */
5803 rsl_unused := f_exp_ipa_rx(0, tr_RSL_IPA_PDCH_ACT(chan_nr));
5804 f_ipa_tx(0, ts_RSL_IPA_PDCH_ACT_ACK(chan_nr, ts_RSL_IE_FrameNumber(2342)));
5805 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02005806 log("TCH/F_PDCH pchan, PDCH ACT was ACKed, so now in PDCH mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02005807 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, PDCH_MODE);
5808
5809 /* De-activate it via VTY */
5810 f_dyn_ipa_pdch_deact(0, 0, chan_nr.tn);
5811 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02005812 log("TCH/F_PDCH pchan, PDCH DEACT via VTY, so now back in TCH/F mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02005813 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
5814
5815 /* re-activate it via VTY */
5816 f_dyn_ipa_pdch_act(0, 0, chan_nr.tn);
5817 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02005818 log("TCH/F_PDCH pchan, PDCH ACT via VTY, so now in PDCH mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02005819 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, PDCH_MODE);
5820
5821 /* and finally de-activate it again */
5822 f_dyn_ipa_pdch_deact(0, 0, chan_nr.tn);
5823 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02005824 log("TCH/F_PDCH pchan, PDCH DEACT via VTY, so now back in TCH/F mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02005825 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
5826
Neels Hofmeyr887e8f12018-06-27 01:01:55 +02005827 /* clean up config */
5828 f_ts_set_chcomb(0, 0, 6, "PDCH");
5829
Harald Welte94e0c342018-04-07 11:33:23 +02005830 setverdict(pass);
5831}
5832
5833/* Test IPA PDCH activation NACK */
5834testcase TC_dyn_pdch_ipa_act_nack() runs on test_CT {
5835 var RSL_Message rsl_unused;
5836
5837 /* change Timeslot 6 before f_init() starts RSL */
5838 f_init_vty();
5839 f_ts_set_chcomb(0, 0, 6, "TCH/F_PDCH");
5840 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
5841
5842 f_init(1, false);
5843 f_sleep(1.0);
5844
5845 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(6));
5846
5847 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
5848 /* The BSC will activate the dynamic PDCH by default, so confirm that */
5849 rsl_unused := f_exp_ipa_rx(0, tr_RSL_IPA_PDCH_ACT(chan_nr));
5850 f_ipa_tx(0, ts_RSL_IPA_PDCH_ACT_ACK(chan_nr, ts_RSL_IE_FrameNumber(2342)));
5851 f_sleep(1.0);
5852 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, PDCH_MODE);
5853
5854 /* De-activate it via VTY */
5855 f_dyn_ipa_pdch_deact(0, 0, chan_nr.tn);
5856 f_sleep(1.0);
5857 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
5858
5859 /* re-activate it via VTY, but fail that; check BSC still assumes TCH/F mode */
5860 f_dyn_ipa_pdch_act(0, 0, chan_nr.tn, RSL_ERR_EQUIPMENT_FAIL);
5861 f_sleep(1.0);
5862 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
5863
Neels Hofmeyr887e8f12018-06-27 01:01:55 +02005864 /* clean up config */
5865 f_ts_set_chcomb(0, 0, 6, "PDCH");
5866
Harald Welte94e0c342018-04-07 11:33:23 +02005867 setverdict(pass);
5868}
5869
5870
5871/***********************************************************************
5872 * Osmocom style dynamic PDCH
5873 ***********************************************************************/
5874
5875private function f_dyn_osmo_pdch_act(integer bts_nr, integer trx_nr, integer ts_nr,
5876 template (omit) RSL_Cause nack := omit)
5877runs on test_CT {
5878 var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(ts_nr));
5879 var RSL_Message rsl_unused;
5880 /* ask BSC via VTY to activate a given IPA style chan as PDCH */
5881 /* FIXME: no VTY command to activate Osmocom PDCH !! */
5882 /* expect the BSC to issue the related RSL command */
5883 rsl_unused := f_exp_ipa_rx(0, tr_RSL_CHAN_ACT(chan_nr, ?));
5884 if (istemplatekind(nack, "omit")) {
5885 /* respond with a related acknowledgement */
5886 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, 2342));
5887 } else {
5888 f_ipa_tx(0, ts_RSL_CHAN_ACT_NACK(chan_nr, valueof(nack)));
5889 }
5890}
5891
5892private function f_dyn_osmo_pdch_deact(integer bts_nr, integer trx_nr, integer ts_nr,
5893 template (omit) RSL_Cause nack := omit)
5894runs on test_CT {
5895 var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(ts_nr));
5896 var RSL_Message rsl_unused;
5897 /* ask BSC via VTY to activate a given IPA style chan as PDCH */
5898 /* FIXME: no VTY command to activate Osmocom PDCH !! */
5899 /* expect the BSC to issue the related RSL command */
5900 rsl_unused := f_exp_ipa_rx(0, tr_RSL_RF_CHAN_REL(chan_nr));
5901 if (istemplatekind(nack, "omit")) {
5902 /* respond with a related acknowledgement */
5903 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(chan_nr));
5904 } else {
5905 //f_ipa_tx(0, ts_RSL_RF_CHAN_REL_NACK(chan_nr, valueof(nack)));
5906 }
5907}
5908
5909/* Test Osmocom dyn PDCH activation / deactivation triggered by VTY */
5910testcase TC_dyn_pdch_osmo_act_deact() runs on test_CT {
5911 var RSL_Message rsl_unused;
5912
5913 /* change Timeslot 6 before f_init() starts RSL */
5914 f_init_vty();
5915 f_ts_set_chcomb(0, 0, 6, "TCH/F_TCH/H_PDCH");
5916 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
5917
5918 f_init(1, false);
5919 f_sleep(1.0);
5920
5921 var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(6));
5922
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02005923 log("TCH/F_TCH/H_PDCH pchan starts out in disabled mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02005924 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, NONE_MODE);
5925 /* The BSC will activate the dynamic PDCH by default, so confirm that */
5926 rsl_unused := f_exp_ipa_rx(0, tr_RSL_CHAN_ACT_PDCH(chan_nr, ?));
5927
5928 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, 2342));
5929 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02005930 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 +02005931 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, PDCH_MODE);
5932
Neels Hofmeyr887e8f12018-06-27 01:01:55 +02005933 /* clean up config */
5934 f_ts_set_chcomb(0, 0, 6, "PDCH");
5935
Harald Welte94e0c342018-04-07 11:33:23 +02005936 setverdict(pass);
5937}
5938
5939/* Test Osmocom dyn PDCH activation NACK behavior */
5940testcase TC_dyn_pdch_osmo_act_nack() runs on test_CT {
5941 var RSL_Message rsl_unused;
5942
5943 /* change Timeslot 6 before f_init() starts RSL */
5944 f_init_vty();
5945 f_ts_set_chcomb(0, 0, 6, "TCH/F_TCH/H_PDCH");
5946 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
5947
5948 f_init(1, false);
5949 f_sleep(1.0);
5950
5951 var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(6));
5952
5953 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, NONE_MODE);
5954 /* The BSC will activate the dynamic PDCH by default, so confirm that */
5955 rsl_unused := f_exp_ipa_rx(0, tr_RSL_CHAN_ACT_PDCH(chan_nr, ?));
5956
5957 /* NACK this activation and expect the "show timeslot" mode still to be NONE */
5958 f_ipa_tx(0, ts_RSL_CHAN_ACT_NACK(chan_nr, RSL_ERR_EQUIPMENT_FAIL));
5959 f_sleep(1.0);
5960 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, NONE_MODE);
5961
Neels Hofmeyr887e8f12018-06-27 01:01:55 +02005962 /* clean up config */
5963 f_ts_set_chcomb(0, 0, 6, "PDCH");
5964
Harald Welte94e0c342018-04-07 11:33:23 +02005965 setverdict(pass);
5966}
5967
Stefan Sperling0796a822018-10-05 13:01:39 +02005968testcase TC_chopped_ipa_ping() runs on test_CT {
Stefan Sperling554123f2018-10-09 14:12:30 +02005969 const Integers bsc_ipa_ports := {mp_bsc_rsl_port, mp_bsc_oml_port, mp_bsc_ctrl_port};
Stefan Sperling0796a822018-10-05 13:01:39 +02005970 for (var integer i := 0; i < lengthof(bsc_ipa_ports); i := i + 1) {
5971 IPA_Testing.f_run_TC_chopped_ipa_ping(mp_bsc_ip, bsc_ipa_ports[i], CONNECT_TO_SERVER);
5972 }
5973}
5974
Stefan Sperlingaa1e60f2018-10-15 16:34:07 +02005975testcase TC_chopped_ipa_payload() runs on test_CT {
5976 const Integers bsc_ipa_ports := {mp_bsc_rsl_port, mp_bsc_oml_port
5977 /* TODO: mp_bsc_ctrl_port does not work yet */};
5978 for (var integer i := 0; i < lengthof(bsc_ipa_ports); i := i + 1) {
5979 IPA_Testing.f_run_TC_chopped_ipa_payload(mp_bsc_ip, bsc_ipa_ports[i], CONNECT_TO_SERVER);
5980 }
5981}
5982
Pau Espin Pedrol8f773632019-11-05 11:46:53 +01005983/* Verify the BSC sends the MS Power Parameters IE during CHAN ACT to make sure
5984 the BTS does autonomous MS power control loop */
5985testcase TC_assignment_verify_ms_power_params_ie() runs on test_CT {
5986 var MSC_ConnHdlr vc_conn;
5987 var TestHdlrParams pars := f_gen_test_hdlr_pars();
5988 //pars.encr := valueof(t_EncrParams('01'O, f_rnd_octstring(8)));
5989 pars.exp_ms_power_params := true;
5990
5991 f_init(1, true);
5992 f_sleep(1.0);
5993 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5), pars);
5994 vc_conn.done;
5995}
Stefan Sperlingaa1e60f2018-10-15 16:34:07 +02005996
Neels Hofmeyr4f118412020-06-04 15:25:10 +02005997/***********************************************************************
5998 * MSC Pooling
5999 ***********************************************************************/
6000
6001function f_tmsi_nri(integer nri_v, octetstring base_tmsi := '42000023'O, integer nri_bitlen := 10) return octetstring
6002{
6003 return int2oct( oct2int(base_tmsi) + bit2int( (int2bit(nri_v, 32) << ( 24 - nri_bitlen)) ),
6004 4);
6005}
6006
6007template MobileIdentityLV ts_MI_TMSI_NRI_LV(integer nri_v, integer nri_bitlen := 10) :=
6008 ts_MI_TMSI_LV(tmsi := f_tmsi_nri(nri_v, nri_bitlen := nri_bitlen));
6009
6010private function f_perform_clear(RSL_DCHAN_PT rsl) runs on MSC_ConnHdlr {
6011 f_logp("MSC instructs BSC to clear channel");
6012 BSSAP.send(ts_BSSMAP_ClearCommand(0));
6013 interleave {
6014 [] rsl.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_RELEASE)) {
6015 f_logp("Got RSL RR Release");
6016 }
6017 [] rsl.receive(tr_RSL_DEACT_SACCH(g_chan_nr)) {
6018 f_logp("Got RSL Deact SACCH");
6019 }
6020 [] BSSAP.receive(tr_BSSMAP_ClearComplete) {
6021 f_logp("Got BSSMAP Clear Complete");
6022 /* Also drop the SCCP connection */
6023 BSSAP.send(RAN_Conn_Prim:MSC_CONN_PRIM_DISC_REQ);
6024 }
6025 [] rsl.receive(tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL)) {
6026 f_logp("Got RSL RF Chan Rel, sending Rel Ack");
6027 rsl.send(ts_RSL_RF_CHAN_REL_ACK(g_chan_nr));
6028 }
6029 }
6030}
6031
6032private function f_perform_compl_l3(RSL_DCHAN_PT rsl, template PDU_ML3_MS_NW l3_info, boolean do_clear := true)
6033runs on MSC_ConnHdlr {
6034 timer T := 10.0;
6035 var octetstring l3_enc := enc_PDU_ML3_MS_NW(valueof(l3_info));
6036
6037 f_logp("establish channel, send Complete Layer 3 Info");
6038 f_create_bssmap_exp(l3_enc);
6039
6040 /* RSL_Emulation.f_chan_est() on rsl:
6041 * This is basically code dup with s/RSL/rsl from:
6042 * RSL_Emulation.f_chan_est(g_pars.ra, l3_enc, g_pars.link_id, g_pars.fn);
6043 */
6044 var RSL_Message rx_rsl;
6045 var GsmRrMessage rr;
6046
6047 /* request a channel to be established */
6048 rsl.send(ts_RSLDC_ChanRqd(g_pars.ra, g_pars.fn));
6049 /* expect immediate assignment.
6050 * Code dup with s/RSL/rsl from:
6051 * rx_rsl := f_rx_or_fail(tr_RSL_IMM_ASSIGN);
6052 */
6053 timer Tt := 10.0;
6054
6055 /* request a channel to be established */
6056 Tt.start;
6057 alt {
6058 [] rsl.receive(tr_RSL_IMM_ASSIGN) -> value rx_rsl {
6059 Tt.stop;
6060 }
6061 [] rsl.receive {
6062 setverdict(fail, "Unexpected RSL message on DCHAN");
6063 mtc.stop;
6064 }
6065 [] Tt.timeout {
6066 setverdict(fail, "Timeout waiting for RSL on DCHAN");
6067 mtc.stop;
6068 }
6069 }
6070 rr := dec_GsmRrMessage(rx_rsl.ies[1].body.full_imm_ass_info.payload);
6071 g_chan_nr := rr.payload.imm_ass.chan_desc.chan_nr;
6072 rsl.send(ts_RSL_EST_IND(g_chan_nr, valueof(g_pars.link_id), l3_enc));
6073
6074
6075 f_logp("expect BSSAP Complete Layer 3 Info at MSC");
6076 var template PDU_BSSAP exp_l3_compl;
6077 exp_l3_compl := tr_BSSMAP_ComplL3()
6078 if (g_pars.aoip == false) {
6079 exp_l3_compl.pdu.bssmap.completeLayer3Information.codecList := omit;
6080 } else {
6081 exp_l3_compl.pdu.bssmap.completeLayer3Information.codecList := ?;
6082 }
6083
6084 var PDU_BSSAP bssap;
6085 T.start;
6086 alt {
6087 [] BSSAP.receive(exp_l3_compl) -> value bssap {
6088 f_logp("received expected Complete Layer 3 Info at MSC");
6089 log("rx exp_l3_compl = ", bssap);
6090 }
6091 [] BSSAP.receive(tr_BSSMAP_ComplL3) {
6092 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Received non-matching COMPLETE LAYER 3 INFORMATION");
6093 }
6094 [] T.timeout {
6095 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for COMPLETE LAYER 3 INFORMATION");
6096 }
6097 }
6098
6099 /* start ciphering, if requested */
6100 if (ispresent(g_pars.encr)) {
6101 f_logp("start ciphering");
6102 f_cipher_mode(g_pars.encr.enc_alg, g_pars.encr.enc_key);
6103 }
6104
6105 if (do_clear) {
6106 f_perform_clear(rsl);
6107 }
6108 setverdict(pass);
6109 f_sleep(1.0);
6110}
6111
6112private function f_tc_mscpool_compl_l3(charstring id) runs on MSC_ConnHdlr {
6113 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
6114 if (g_pars.mscpool.rsl_idx == 0) {
6115 f_perform_compl_l3(RSL, g_pars.mscpool.l3_info);
6116 } else if (g_pars.mscpool.rsl_idx == 1) {
6117 f_perform_compl_l3(RSL1, g_pars.mscpool.l3_info);
6118 } else if (g_pars.mscpool.rsl_idx == 2) {
6119 f_perform_compl_l3(RSL2, g_pars.mscpool.l3_info);
6120 }
6121}
6122
6123/* Various Complete Layer 3 by IMSI all end up with the first MSC, because the other MSCs are not connected. */
6124private function f_tc_mscpool_L3Compl_on_1_msc(charstring id) runs on MSC_ConnHdlr {
6125 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
6126 f_perform_compl_l3(RSL, ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_IMSI_LV('001010000000001'H)), '00F110'O) );
6127 f_perform_compl_l3(RSL, ts_CM_SERV_REQ(CM_TYPE_MO_SMS, valueof(ts_MI_IMSI_LV('001010000000002'H))) );
6128 f_perform_compl_l3(RSL, ts_PAG_RESP(valueof(ts_MI_IMSI_LV('001010000000003'H))) );
6129 f_perform_compl_l3(RSL, ts_ML3_MO_MM_IMSI_DET_Ind(valueof(ts_MI_IMSI_LV('001010000000004'H))) );
6130}
6131testcase TC_mscpool_L3Compl_on_1_msc() runs on test_CT {
6132
6133 f_init(1, true);
6134 f_sleep(1.0);
6135 var MSC_ConnHdlr vc_conn;
6136 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006137
6138 f_ctrs_msc_init();
6139
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006140 vc_conn := f_start_handler(refers(f_tc_mscpool_L3Compl_on_1_msc), pars);
6141 vc_conn.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006142
6143 f_ctrs_msc_expect(0, "mscpool:subscr:new", 4);
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006144}
6145
6146/* Three Layer 3 Complete by IMSI are round-robin'ed across two connected MSCs */
6147/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
6148 * just as well using only RSL. */
6149testcase TC_mscpool_L3Complete_by_imsi_round_robin() runs on test_CT {
6150
6151 f_init(nr_bts := 3, handler_mode := true, nr_msc := 2);
6152 f_sleep(1.0);
6153
6154 /* Control which MSC gets chosen next by the round-robin, otherwise
6155 * would be randomly affected by which other tests ran before this. */
6156 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
6157
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006158 f_ctrs_msc_init();
6159
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006160 var MSC_ConnHdlr vc_conn1;
6161 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
6162 pars1.mscpool.rsl_idx := 0;
6163 pars1.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_IMSI_LV('001010000000001'H)), '00F110'O));
6164 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6165 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006166 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006167
6168 var MSC_ConnHdlr vc_conn2;
6169 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 1);
6170 pars2.mscpool.rsl_idx := 1;
6171 pars2.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, valueof(ts_MI_IMSI_LV('001010000000002'H))));
6172 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6173 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006174 f_ctrs_msc_expect(1, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006175
6176 /* Test round-robin wrap to the first MSC */
6177 var MSC_ConnHdlr vc_conn3;
6178 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 0);
6179 pars3.mscpool.rsl_idx := 2;
6180 pars3.mscpool.l3_info := valueof(ts_PAG_RESP(valueof(ts_MI_IMSI_LV('001010000000003'H))));
6181 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
6182 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006183 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006184}
6185
6186/* Three LU by TMSI are round-robin'ed across two connected MSCs, because they contain the NULL-NRI 0
6187 * (configured in osmo-bsc.cfg). */
6188/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
6189 * just as well using only RSL. */
6190testcase TC_mscpool_LU_by_tmsi_null_nri_0_round_robin() runs on test_CT {
6191
6192 f_init(nr_bts := 3, handler_mode := true, nr_msc := 2);
6193 f_sleep(1.0);
6194
6195 /* Control which MSC gets chosen next by the round-robin, otherwise
6196 * would be randomly affected by which other tests ran before this. */
6197 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
6198
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006199 f_ctrs_msc_init();
6200
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006201 var MSC_ConnHdlr vc_conn1;
6202 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
6203 pars1.mscpool.rsl_idx := 0;
6204 pars1.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(0)), '00F110'O));
6205 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6206 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006207 f_ctrs_msc_expect(0, "mscpool:subscr:reattach");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006208
6209 var MSC_ConnHdlr vc_conn2;
6210 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 1);
6211 pars2.mscpool.rsl_idx := 1;
6212 pars2.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(0)), '00F110'O));
6213 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6214 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006215 f_ctrs_msc_expect(1, "mscpool:subscr:reattach");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006216
6217 /* Test round-robin wrap to the first MSC */
6218 var MSC_ConnHdlr vc_conn3;
6219 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 0);
6220 pars3.mscpool.rsl_idx := 2;
6221 pars3.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(0)), '00F110'O));
6222 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
6223 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006224 f_ctrs_msc_expect(0, "mscpool:subscr:reattach");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006225}
6226
6227/* Three LU by TMSI are round-robin'ed across two connected MSCs, because they contain the NULL-NRI 1
6228 * (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
6229 * NULL-NRI setting is stronger than that. */
6230/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
6231 * just as well using only RSL. */
6232testcase TC_mscpool_LU_by_tmsi_null_nri_1_round_robin() runs on test_CT {
6233
6234 f_init(nr_bts := 3, handler_mode := true, nr_msc := 2);
6235 f_sleep(1.0);
6236
6237 /* Control which MSC gets chosen next by the round-robin, otherwise
6238 * would be randomly affected by which other tests ran before this. */
6239 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
6240
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006241 f_ctrs_msc_init();
6242
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006243 var MSC_ConnHdlr vc_conn1;
6244 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
6245 pars1.mscpool.rsl_idx := 0;
6246 pars1.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(1)), '00F110'O));
6247 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6248 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006249 f_ctrs_msc_expect(0, "mscpool:subscr:reattach");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006250
6251 var MSC_ConnHdlr vc_conn2;
6252 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 1);
6253 pars2.mscpool.rsl_idx := 1;
6254 pars2.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(1)), '00F110'O));
6255 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6256 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006257 f_ctrs_msc_expect(1, "mscpool:subscr:reattach");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006258
6259 /* Test round-robin wrap to the first MSC */
6260 var MSC_ConnHdlr vc_conn3;
6261 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 0);
6262 pars3.mscpool.rsl_idx := 2;
6263 pars3.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(1)), '00F110'O));
6264 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
6265 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006266 f_ctrs_msc_expect(0, "mscpool:subscr:reattach");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006267}
6268
6269/* Three Layer 3 Complete by TMSI are round-robin'ed across two connected MSCs, because they contain an NRI not
6270 * assigned to any MSC (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_L3Complete_by_tmsi_unassigned_nri_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 /* An NRI that is not assigned to any MSC */
6288 pars1.mscpool.l3_info := valueof(ts_ML3_MO_MM_IMSI_DET_Ind(valueof(ts_MI_TMSI_NRI_LV(1023))));
6289 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6290 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006291 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006292
6293 var MSC_ConnHdlr vc_conn2;
6294 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 1);
6295 pars2.mscpool.rsl_idx := 1;
6296 /* An NRI that is not assigned to any MSC */
6297 pars2.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(768)), '00F110'O));
6298 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6299 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006300 f_ctrs_msc_expect(1, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006301
6302 /* Test round-robin wrap to the first MSC */
6303 var MSC_ConnHdlr vc_conn3;
6304 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 0);
6305 pars3.mscpool.rsl_idx := 2;
6306 /* An NRI that is not assigned to any MSC */
6307 pars3.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_SS_ACT, valueof(ts_MI_TMSI_NRI_LV(819))));
6308 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
6309 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006310 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006311}
6312
6313/* Three Layer 3 Complete by TMSI are round-robin'ed across two connected MSCs, because they contain an NRI
6314 * assigned to an MSC that is currently not connected (configured in osmo-bsc.cfg). */
6315/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
6316 * just as well using only RSL. */
6317testcase TC_mscpool_L3Complete_by_tmsi_valid_nri_msc_not_connected_round_robin() runs on test_CT {
6318
6319 f_init(nr_bts := 3, handler_mode := true, nr_msc := 2);
6320 f_sleep(1.0);
6321
6322 /* Control which MSC gets chosen next by the round-robin, otherwise
6323 * would be randomly affected by which other tests ran before this. */
6324 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
6325
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006326 f_ctrs_msc_init();
6327
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006328 var MSC_ConnHdlr vc_conn1;
6329 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
6330 pars1.mscpool.rsl_idx := 0;
6331 /* An NRI that is assigned to an unconnected MSC */
6332 pars1.mscpool.l3_info := valueof(ts_PAG_RESP(valueof(ts_MI_TMSI_NRI_LV(512))));
6333 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6334 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006335 f_ctrs_msc_add(2, "mscpool:subscr:attach_lost");
6336 f_ctrs_msc_add(0, "mscpool:subscr:new");
6337 f_ctrs_msc_verify();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006338
6339 var MSC_ConnHdlr vc_conn2;
6340 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 1);
6341 pars2.mscpool.rsl_idx := 1;
6342 /* An NRI that is assigned to an unconnected MSC */
6343 pars2.mscpool.l3_info := valueof(ts_ML3_MO_MM_IMSI_DET_Ind(valueof(ts_MI_TMSI_NRI_LV(767))));
6344 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6345 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006346 f_ctrs_msc_add(2, "mscpool:subscr:attach_lost");
6347 f_ctrs_msc_add(1, "mscpool:subscr:new");
6348 f_ctrs_msc_verify();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006349
6350 /* Test round-robin wrap to the first MSC */
6351 var MSC_ConnHdlr vc_conn3;
6352 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 0);
6353 pars3.mscpool.rsl_idx := 2;
6354 /* An NRI that is assigned to an unconnected MSC */
6355 pars3.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(750)), '00F110'O));
6356 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
6357 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006358 f_ctrs_msc_add(2, "mscpool:subscr:attach_lost");
6359 f_ctrs_msc_add(0, "mscpool:subscr:new");
6360 f_ctrs_msc_verify();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006361}
6362
6363/* Three Layer 3 Complete by TMSI with valid NRI for the second MSC are all directed to the second MSC (configured in
6364 * osmo-bsc.cfg). */
6365/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
6366 * just as well using only RSL. */
6367testcase TC_mscpool_L3Complete_by_tmsi_valid_nri_1() runs on test_CT {
6368
6369 f_init(nr_bts := 3, handler_mode := true, nr_msc := 2);
6370 f_sleep(1.0);
6371
6372 /* All TMSIs in this test point at the second MSC, set the round robin to point at the first MSC to make sure
6373 * this is not using round-robin. */
6374 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
6375
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006376 f_ctrs_msc_init();
6377
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006378 var MSC_ConnHdlr vc_conn1;
6379 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 1);
6380 pars1.mscpool.rsl_idx := 0;
6381 /* An NRI of the second MSC's range (256-511) */
6382 pars1.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_SMS, valueof(ts_MI_TMSI_NRI_LV(256))));
6383 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6384 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006385 f_ctrs_msc_expect(1, "mscpool:subscr:known");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006386
6387 var MSC_ConnHdlr vc_conn2;
6388 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 1);
6389 pars2.mscpool.rsl_idx := 1;
6390 /* An NRI of the second MSC's range (256-511) */
6391 pars2.mscpool.l3_info := valueof(ts_PAG_RESP(valueof(ts_MI_TMSI_NRI_LV(260))));
6392 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6393 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006394 f_ctrs_msc_expect(1, "mscpool:subscr:known");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006395
6396 var MSC_ConnHdlr vc_conn3;
6397 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 1);
6398 pars3.mscpool.rsl_idx := 2;
6399 /* An NRI of the second MSC's range (256-511) */
6400 pars3.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(511)), '00F110'O));
6401 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
6402 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006403 f_ctrs_msc_expect(1, "mscpool:subscr:known");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006404}
6405
6406/* Layer 3 Complete by TMSI with valid NRI for the third MSC are directed to the third MSC (configured in osmo-bsc.cfg),
6407 * while a round-robin remains unaffected by that. */
6408/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
6409 * just as well using only RSL. */
6410testcase TC_mscpool_L3Complete_by_tmsi_valid_nri_2() runs on test_CT {
6411
6412 f_init(nr_bts := 3, handler_mode := true, nr_msc := 3);
6413 f_sleep(1.0);
6414
6415 /* All TMSIs in this test point at the third MSC, set the round robin to point at the second MSC to make sure
6416 * this is not using round-robin. */
6417 f_vty_transceive(BSCVTY, "mscpool roundrobin next 1");
6418
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006419 f_ctrs_msc_init();
6420
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006421 var MSC_ConnHdlr vc_conn1;
6422 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 2);
6423 pars1.mscpool.rsl_idx := 0;
6424 /* An NRI of the third MSC's range (512-767) */
6425 pars1.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_SMS, valueof(ts_MI_TMSI_NRI_LV(512))));
6426 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6427 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006428 f_ctrs_msc_expect(2, "mscpool:subscr:known");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006429
6430 var MSC_ConnHdlr vc_conn2;
6431 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 2);
6432 pars2.mscpool.rsl_idx := 1;
6433 /* An NRI of the third MSC's range (512-767) */
6434 pars2.mscpool.l3_info := valueof(ts_PAG_RESP(valueof(ts_MI_TMSI_NRI_LV(678))));
6435 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6436 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006437 f_ctrs_msc_expect(2, "mscpool:subscr:known");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006438
6439 /* The above forwardings to third MSC have not affected the round robin, which still points at the second MSC */
6440 var MSC_ConnHdlr vc_conn3;
6441 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 1);
6442 pars3.mscpool.rsl_idx := 2;
6443 pars3.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_IMSI_LV('001010000000013'H)), '00F110'O));
6444 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
6445 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006446 f_ctrs_msc_expect(1, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006447}
6448
6449/* LU with a TMSI but indicating a different PLMN in its previous LAI: ignore the NRI. */
6450/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
6451 * just as well using only RSL. */
6452testcase TC_mscpool_LU_by_tmsi_from_other_PLMN() runs on test_CT {
6453
6454 f_init(nr_bts := 3, handler_mode := true, nr_msc := 3);
6455 f_sleep(1.0);
6456
6457 /* The TMSIs in this test points at the second MSC, but since it is from a different PLMN, round-robin is used
6458 * instead, and hits msc 0. */
6459 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
6460
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006461 f_ctrs_msc_init();
6462
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006463 /* An NRI of the second MSC's range (256-511), but a PLMN that doesn't match with osmo-bsc.cfg */
6464 var MSC_ConnHdlr vc_conn1;
6465 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
6466 pars1.mscpool.rsl_idx := 0;
6467 pars1.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(260)), '99F999'O));
6468 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6469 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006470 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006471
6472 /* An NRI of the third MSC's range (512-767) and a matching PLMN gets directed by NRI. */
6473 var MSC_ConnHdlr vc_conn2;
6474 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 2);
6475 pars2.mscpool.rsl_idx := 1;
6476 pars2.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(555)), '00F110'O));
6477 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6478 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006479 f_ctrs_msc_expect(2, "mscpool:subscr:known");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006480}
6481
6482/* Make sure that whichever MSC paged a subscriber will also get the Paging Response. Page by IMSI, which would be
6483 * round-robined to another MSC, to make sure the Paging->Response relation is stronger than the NRI->MSC mapping. */
6484private function f_tc_mscpool_paging_imsi(charstring id) runs on MSC_ConnHdlr {
6485 var template BSSMAP_FIELD_CellIdentificationList cid_list := { cIl_CI := { ts_BSSMAP_CI_CI(0) } };
6486 //cid_list := { cIl_allInBSS := ''O };
6487 var RSL_ChanNeeded rsl_chneed := RSL_CHANNEED_SDCCH;
6488 var template BSSMAP_IE_ChannelNeeded bssmap_chneed := ts_BSSMAP_IE_ChanNeeded(int2bit(enum2int(valueof(rsl_chneed)),2));
6489 var BSSAP_N_UNITDATA_req paging;
6490 var hexstring imsi := '001010000000123'H;
6491
6492 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
6493
Neels Hofmeyr90f80962020-06-12 16:16:55 +02006494 paging := valueof(ts_BSSAP_UNITDATA_req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006495 valueof(ts_BSSMAP_Paging(imsi, cid_list, omit, bssmap_chneed))));
6496 BSSAP.send(paging);
6497
6498 /* Register any RSL conn so that the Paging Command gets received here. With the current RSL_Emulation's main()
6499 * handling of '[bts_role] IPA_PT.receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD()))' it doesn't matter at all which
6500 * channel number is picked here. */
6501 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(0, RSL_CHAN_NR_INVALID));
6502 f_rslem_register(0, new_chan_nr);
6503 RSL.receive(tr_RSL_PAGING_CMD(tr_MI_IMSI(imsi)));
6504 f_rslem_unregister(0, new_chan_nr);
6505
6506 /* Despite the round robin pointing at the second MSC ('roundrobin next 1'), the earlier Paging for the same IMSI
6507 * causes this Paging Response to go to the first MSC (bssap_idx := 0). */
6508 f_perform_compl_l3(RSL, ts_PAG_RESP(valueof(ts_MI_IMSI_LV(imsi))) );
6509 setverdict(pass);
6510 f_sleep(1.0);
6511}
6512testcase TC_mscpool_paging_and_response_imsi() runs on test_CT {
6513 f_init(nr_bts := 1, handler_mode := true, nr_msc := 3);
6514 f_sleep(1.0);
6515
6516 /* Testing a Paging on the first MSC to get a Paging Response back to the first MSC. Set round robin to the
6517 * second MSC to make sure we're getting the Paging logic, not a coincidental round robin match. */
6518 f_vty_transceive(BSCVTY, "mscpool roundrobin next 1");
6519
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006520 f_ctrs_msc_init();
6521
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006522 var MSC_ConnHdlr vc_conn1;
6523 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
6524 pars1.mscpool.rsl_idx := 0;
Neels Hofmeyr90f80962020-06-12 16:16:55 +02006525 pars1.sccp_addr_bsc := g_bssap[pars1.mscpool.bssap_idx].sccp_addr_peer;
6526 pars1.sccp_addr_msc := g_bssap[pars1.mscpool.bssap_idx].sccp_addr_own;
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006527 vc_conn1 := f_start_handler(refers(f_tc_mscpool_paging_imsi), pars1);
6528 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006529 f_ctrs_msc_expect(0, "mscpool:subscr:paged");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006530}
6531
6532/* Make sure that whichever MSC paged a subscriber will also get the Paging Response. Page by TMSI with an NRI value
6533 * that matches a different MSC, to make sure the Paging->Response relation is stronger than the NRI->MSC mapping. */
6534private function f_tc_mscpool_paging_tmsi(charstring id) runs on MSC_ConnHdlr {
6535 var template BSSMAP_FIELD_CellIdentificationList cid_list := { cIl_CI := { ts_BSSMAP_CI_CI(0) } };
6536 //cid_list := { cIl_allInBSS := ''O };
6537 var RSL_ChanNeeded rsl_chneed := RSL_CHANNEED_SDCCH;
6538 var template BSSMAP_IE_ChannelNeeded bssmap_chneed := ts_BSSMAP_IE_ChanNeeded(int2bit(enum2int(valueof(rsl_chneed)),2));
6539 var integer nri_v := 300; /* <-- second MSC's NRI */
6540 var octetstring tmsi := f_tmsi_nri(nri_v);
6541 var BSSAP_N_UNITDATA_req paging;
6542
6543 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
6544
Neels Hofmeyr90f80962020-06-12 16:16:55 +02006545 paging := valueof(ts_BSSAP_UNITDATA_req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006546 valueof(ts_BSSMAP_Paging('001010000000011'H, cid_list, tmsi, bssmap_chneed))));
6547 BSSAP.send(paging);
6548
6549 /* Register any RSL conn so that the Paging Command gets received here. With the current RSL_Emulation's main()
6550 * handling of '[bts_role] IPA_PT.receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD()))' it doesn't matter at all which
6551 * channel number is picked here. */
6552 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(0, RSL_CHAN_NR_INVALID));
6553 f_rslem_register(0, new_chan_nr);
6554 RSL.receive(tr_RSL_PAGING_CMD(t_MI_TMSI(tmsi)));
6555 f_rslem_unregister(0, new_chan_nr);
6556
6557 /* Despite the NRI matching the second MSC (NRI from 'msc 1' in osmo-bsc.cfg) and round robin pointing at the
6558 * third MSC ('roundrobin next 2'), the earlier Paging for the same TMSI causes this Paging Response to go to
6559 * the first MSC (bssap_idx := 0). */
6560 f_perform_compl_l3(RSL, ts_PAG_RESP(valueof(ts_MI_TMSI_NRI_LV(nri_v))) );
6561 setverdict(pass);
6562 f_sleep(1.0);
6563}
6564testcase TC_mscpool_paging_and_response_tmsi() runs on test_CT {
6565 f_init(nr_bts := 1, handler_mode := true, nr_msc := 3);
6566 f_sleep(1.0);
6567
6568 /* Testing a Paging on the first MSC to get a Paging Response back to the first MSC. Set round robin to the
6569 * third MSC to make sure we're getting the Paging logic, not a coincidental round robin match. */
6570 f_vty_transceive(BSCVTY, "mscpool roundrobin next 2");
6571
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006572 f_ctrs_msc_init();
6573
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006574 var MSC_ConnHdlr vc_conn1;
6575 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
6576 pars1.mscpool.rsl_idx := 0;
Neels Hofmeyr90f80962020-06-12 16:16:55 +02006577 pars1.sccp_addr_bsc := g_bssap[pars1.mscpool.bssap_idx].sccp_addr_peer;
6578 pars1.sccp_addr_msc := g_bssap[pars1.mscpool.bssap_idx].sccp_addr_own;
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006579 vc_conn1 := f_start_handler(refers(f_tc_mscpool_paging_tmsi), pars1);
6580 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006581 f_ctrs_msc_expect(0, "mscpool:subscr:paged");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006582}
6583
6584/* For round-robin, skip an MSC that has 'no allow-attach' set. */
6585/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
6586 * just as well using only RSL. */
6587testcase TC_mscpool_no_allow_attach_round_robin() runs on test_CT {
6588
6589 f_init(nr_bts := 3, handler_mode := true, nr_msc := 3);
6590 f_sleep(1.0);
Neels Hofmeyra460f1f2020-08-09 20:17:03 +00006591 /* Mark the second MSC as offloading, round-robin should skip this MSC now. */
6592 f_vty_msc_allow_attach(BSCVTY, {true, false, true});
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006593
6594 /* Control which MSC gets chosen next by the round-robin, otherwise
6595 * would be randomly affected by which other tests ran before this. */
6596 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
6597
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006598 f_ctrs_msc_init();
6599
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006600 var MSC_ConnHdlr vc_conn1;
6601 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
6602 pars1.mscpool.rsl_idx := 0;
6603 pars1.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_IMSI_LV('001010000000001'H)), '00F110'O));
6604 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6605 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006606 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006607
6608 var MSC_ConnHdlr vc_conn2;
6609 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 2);
6610 pars2.mscpool.rsl_idx := 1;
6611 pars2.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, valueof(ts_MI_IMSI_LV('001010000000002'H))));
6612 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6613 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006614 f_ctrs_msc_expect(2, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006615
6616 var MSC_ConnHdlr vc_conn3;
6617 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 0);
6618 pars3.mscpool.rsl_idx := 2;
6619 pars3.mscpool.l3_info := valueof(ts_PAG_RESP(valueof(ts_MI_IMSI_LV('001010000000003'H))));
6620 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
6621 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006622 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006623}
6624
6625/* An MSC that has 'no allow-attach' set should still serve subscribers that are already attached according to their
6626 * TMSI NRI. */
6627testcase TC_mscpool_no_allow_attach_valid_nri() runs on test_CT {
6628
6629 f_init(nr_bts := 3, handler_mode := true, nr_msc := 3);
6630 f_sleep(1.0);
6631
Neels Hofmeyra460f1f2020-08-09 20:17:03 +00006632 /* Mark the second MSC as offloading, round-robin should skip this MSC now. */
6633 f_vty_msc_allow_attach(BSCVTY, {true, false, true});
6634
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006635 /* Control which MSC gets chosen next by the round-robin, otherwise
6636 * would be randomly affected by which other tests ran before this. */
6637 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
6638
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006639 f_ctrs_msc_init();
6640
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006641 /* Round robin points at msc 0, but the valid NRI directs to msc 1, even though msc 1 has 'no allow-attach'. */
6642 var MSC_ConnHdlr vc_conn1;
6643 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 1);
6644 pars1.mscpool.rsl_idx := 0;
6645 /* An NRI of the second MSC's range (256-511) */
6646 pars1.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, valueof(ts_MI_TMSI_NRI_LV(260))));
6647 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6648 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006649 f_ctrs_msc_expect(1, "mscpool:subscr:known");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006650
6651 var MSC_ConnHdlr vc_conn2;
6652 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 0);
6653 pars2.mscpool.rsl_idx := 1;
6654 pars2.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, valueof(ts_MI_IMSI_LV('001010000000002'H))));
6655 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6656 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006657 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006658
6659 var MSC_ConnHdlr vc_conn3;
6660 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 2);
6661 pars3.mscpool.rsl_idx := 2;
6662 pars3.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, valueof(ts_MI_IMSI_LV('001010000000003'H))));
6663 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
6664 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006665 f_ctrs_msc_expect(2, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006666}
6667
Philipp Maier783681c2020-07-16 16:47:06 +02006668/* Allow/Deny emergency calls globally via VTY */
6669private function f_vty_allow_emerg_msc(boolean allow) runs on test_CT {
6670 f_vty_enter_cfg_msc(BSCVTY, 0);
6671 if (allow) {
6672 f_vty_transceive(BSCVTY, "allow-emergency allow");
6673 } else {
6674 f_vty_transceive(BSCVTY, "allow-emergency deny");
6675 }
6676 f_vty_transceive(BSCVTY, "exit");
6677 f_vty_transceive(BSCVTY, "exit");
6678}
6679
6680/* Allow/Deny emergency calls per BTS via VTY */
6681private function f_vty_allow_emerg_bts(boolean allow, integer bts_nr) runs on test_CT {
6682 f_vty_enter_cfg_bts(BSCVTY, bts_nr);
6683 if (allow) {
6684 f_vty_transceive(BSCVTY, "rach emergency call allowed 1");
6685 } else {
6686 f_vty_transceive(BSCVTY, "rach emergency call allowed 0");
6687 }
6688 f_vty_transceive(BSCVTY, "exit");
6689 f_vty_transceive(BSCVTY, "exit");
6690}
6691
6692/* Begin assignmet procedure and send an EMERGENCY SETUP (RR) */
6693private function f_assignment_emerg_setup() runs on MSC_ConnHdlr {
6694 var PDU_ML3_MS_NW emerg_setup;
6695 var octetstring emerg_setup_enc;
6696 var RSL_Message emerg_setup_data_ind;
6697
6698 f_establish_fully(omit, omit);
6699
6700 emerg_setup := valueof(ts_ML3_MO_CC_EMERG_SETUP(1, valueof(ts_Bcap_voice)));
6701 emerg_setup_enc := enc_PDU_ML3_MS_NW(emerg_setup);
6702 emerg_setup_data_ind := valueof(ts_RSL_DATA_IND(g_chan_nr, valueof(ts_RslLinkID_DCCH(0)), emerg_setup_enc));
6703
6704 RSL.send(emerg_setup_data_ind);
6705}
6706
6707/* Test if the EMERGENCY SETUP gets passed on to the MSC via A when EMERGENCY
6708 * CALLS are permitted by the BSC config. */
6709private function f_TC_assignment_emerg_setup_allow(charstring id) runs on MSC_ConnHdlr {
6710 var PDU_BSSAP emerg_setup_data_ind_bssap;
6711 var PDU_ML3_MS_NW emerg_setup;
6712 timer T := 3.0;
6713
6714 f_assignment_emerg_setup()
6715
6716 T.start;
6717 alt {
6718 [] BSSAP.receive(tr_BSSAP_DTAP) -> value emerg_setup_data_ind_bssap {
6719 emerg_setup := dec_PDU_ML3_MS_NW(emerg_setup_data_ind_bssap.pdu.dtap);
6720 if (not isbound(emerg_setup.msgs.cc.emergencySetup)) {
6721 setverdict(fail, "no emergency setup");
6722 }
6723 }
6724 [] BSSAP.receive {
6725 setverdict(fail, "unexpected BSSAP message!");
6726 }
6727 [] T.timeout {
6728 setverdict(fail, "timout waiting for EMERGENCY SETUP!");
6729 }
6730 }
6731
6732 setverdict(pass);
6733}
6734
6735/* Test if the EMERGENCY SETUP gets blocked by the BSC if EMERGENCY CALLS are
6736 * forbidden by the BSC config. */
6737private function f_TC_assignment_emerg_setup_deny(charstring id) runs on MSC_ConnHdlr {
6738 var PDU_BSSAP emerg_setup_data_ind_bssap;
6739 timer T := 3.0;
6740
6741 f_assignment_emerg_setup()
6742
6743 T.start;
6744 alt {
6745 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_RELEASE)) {
6746 setverdict(pass);
6747 }
6748 [] RSL.receive {
6749 setverdict(fail, "unexpected RSL message!");
6750 }
6751 [] T.timeout {
6752 setverdict(fail, "timout waiting for RR CHANNEL RELEASE!");
6753 }
6754 }
6755}
6756
6757/* EMERGENCY CALL situation #1, allowed globally and by BTS */
6758testcase TC_assignment_emerg_setup_allow() runs on test_CT {
6759 var TestHdlrParams pars := f_gen_test_hdlr_pars();
6760 var MSC_ConnHdlr vc_conn;
6761
6762 f_init(1, true);
6763 f_sleep(1.0);
6764
6765 f_vty_allow_emerg_msc(true);
6766 f_vty_allow_emerg_bts(true, 0);
6767 vc_conn := f_start_handler(refers(f_TC_assignment_emerg_setup_allow), pars);
6768 vc_conn.done;
6769}
6770
6771/* EMERGENCY CALL situation #2, forbidden globally but allowed by BTS */
6772testcase TC_assignment_emerg_setup_deny_msc() runs on test_CT {
6773 var TestHdlrParams pars := f_gen_test_hdlr_pars();
6774 var MSC_ConnHdlr vc_conn;
6775
6776 f_init(1, true);
6777 f_sleep(1.0);
6778
6779 f_vty_allow_emerg_msc(false);
6780 f_vty_allow_emerg_bts(true, 0);
6781 vc_conn := f_start_handler(refers(f_TC_assignment_emerg_setup_deny), pars);
6782 vc_conn.done;
6783}
6784
6785/* EMERGENCY CALL situation #3, allowed globally but forbidden by BTS */
6786testcase TC_assignment_emerg_setup_deny_bts() runs on test_CT {
6787 var TestHdlrParams pars := f_gen_test_hdlr_pars();
6788 var MSC_ConnHdlr vc_conn;
6789
6790 /* Note: This simulates a spec violation by the MS, correct MS
6791 * implementations would not try to establish an emergency call because
6792 * the system information tells in advance that emergency calls are
6793 * not forbidden */
6794
6795 f_init(1, true);
6796 f_sleep(1.0);
6797
6798 f_vty_allow_emerg_msc(true);
6799 f_vty_allow_emerg_bts(false, 0);
6800 vc_conn := f_start_handler(refers(f_TC_assignment_emerg_setup_deny), pars);
6801 vc_conn.done;
6802}
6803
Philipp Maier82812002020-08-13 18:48:27 +02006804/* Test what happens when an emergency call arrives while all TCH channels are
6805 * busy, the BSC is expected to terminate one call in favor of the incoming
6806 * emergency call */
6807testcase TC_emerg_premption() runs on test_CT {
6808 var ASP_RSL_Unitdata rsl_ud;
6809 var integer i;
6810 var integer chreq_total, chreq_nochan;
6811 var RSL_Message rx_rsl;
6812 var RslChannelNr chan_nr;
6813
6814 f_init(1);
6815 f_sleep(1.0);
6816
6817 f_vty_allow_emerg_msc(true);
6818 f_vty_allow_emerg_bts(true, 0);
6819
6820 /* Fill up all channels on the BTS */
6821 chreq_total := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total");
6822 chreq_nochan := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:no_channel");
6823 for (i := 0; i < NUM_TCHF_PER_BTS + NUM_TCHH_PER_BTS + NUM_SDCCH_PER_BTS; i := i+1) {
6824 chan_nr := f_chreq_act_ack('33'O, i);
6825 }
6826 IPA_RSL[0].clear;
6827 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total",
6828 chreq_total + NUM_TCHF_PER_BTS + NUM_TCHH_PER_BTS + NUM_SDCCH_PER_BTS);
6829
6830 /* Send Channel request for emegergency call */
6831 f_ipa_tx(0, ts_RSL_CHAN_RQD('A5'O, 23));
6832
6833 /* Expect the BSC to release one (the first) TCH/F on the BTS */
6834 chan_nr := valueof(t_RslChanNr_Bm(1));
6835 f_expect_chan_rel(0, chan_nr, expect_rr_chan_rel := false, expect_rll_rel_req := false);
6836
6837 /* Expect the BSC to send activate/assign the a channel for the emergency call */
6838 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
6839 chan_nr := rx_rsl.ies[0].body.chan_nr;
6840 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, 33));
6841 rx_rsl := f_exp_ipa_rx(0, tr_RSL_IMM_ASSIGN(0));
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07006842}
6843
6844/* Hopping parameters per a timeslot */
6845private type record length(0..64) of integer ArfcnList;
6846private type record FHParamsTs {
6847 boolean enabled,
6848 uint6_t hsn,
6849 uint6_t maio,
6850 ArfcnList ma
6851};
6852
6853/* Hopping parameters per a transceiver */
6854private type record length(8) of FHParamsTs FHParamsTrx;
6855
6856/* Randomly generate the hopping parameters for the given timeslot numbers */
6857private function f_TC_fh_params_gen(template integer tr_tn := (1, 3, 5))
6858runs on test_CT return FHParamsTrx {
6859 var FHParamsTrx fhp;
6860
6861 for (var integer tn := 0; tn < 8; tn := tn + 1) {
6862 if (not match(tn, tr_tn)) {
6863 fhp[tn].enabled := false;
6864 fhp[tn].ma := { };
6865 continue;
6866 }
6867
6868 /* Random HSN / MAIO values: 0..63 */
6869 fhp[tn].hsn := f_rnd_int(64);
6870 fhp[tn].maio := f_rnd_int(64);
6871 fhp[tn].ma := { };
6872
6873 /* Random Mobile Allocation (hopping channels) */
6874 var integer ma_len := 2 + f_rnd_int(9); /* 2..10 channels */
6875 var integer step := 3 + f_rnd_int(4); /* 3..6 stepping */
6876 for (var integer i := 1; i <= ma_len; i := i + 1) {
6877 fhp[tn].ma := fhp[tn].ma & { i * step };
6878 }
6879
6880 fhp[tn].enabled := true;
6881 }
6882
6883 log("f_TC_fh_params_gen(): ", fhp);
6884 return fhp;
6885}
6886
6887/* Make sure that the given Channel Description IE matches the hopping configuration */
6888private function f_TC_fh_params_match_chan_desc(in FHParamsTrx fhp, in ChannelDescription cd)
6889{
6890 var template (present) ChannelDescription tr_cd;
6891 var template (present) MaioHsn tr_maio_hsn;
6892 var uint3_t tn := cd.chan_nr.tn;
6893
6894 if (fhp[tn].enabled) {
6895 tr_maio_hsn := tr_HsnMaio(fhp[tn].hsn, fhp[tn].maio);
6896 tr_cd := tr_ChanDescH1(cd.chan_nr, tr_maio_hsn);
6897 } else {
6898 tr_cd := tr_ChanDescH0(cd.chan_nr);
6899 }
6900
6901 if (not match(cd, tr_cd)) {
6902 setverdict(fail, "Channel Description IE does not match: ",
6903 cd, " vs expected ", tr_cd);
6904 }
6905}
6906
6907/* Make sure that the given Mobile Allocation IE matches the hopping configuration */
6908private function f_TC_fh_params_match_ma(in FHParamsTrx fhp, uint3_t tn,
6909 in MobileAllocationLV ma)
6910{
6911 var template MobileAllocationLV tr_ma := f_TC_fh_params_gen_tr_ma(fhp, tn, ma);
6912
6913 if (not match(ma, tr_ma)) {
6914 setverdict(fail, "Mobile Allocation IE does not match (tn := ",
6915 tn, "): ", ma, " vs expected: ", tr_ma);
6916 } else {
6917 setverdict(pass);
6918 }
6919}
6920
6921private function f_TC_fh_params_gen_tr_ma(in FHParamsTrx fhp, uint3_t tn,
6922 in MobileAllocationLV ma)
6923return template MobileAllocationLV {
6924 /* Mobile Allocation IE is expected to be empty if hopping is not enabled */
6925 if (not fhp[tn].enabled) {
6926 return { len := 0, ma := ''B };
6927 }
6928
6929 var bitstring full_mask := f_pad_bit(''B, 1024, '0'B);
6930 var bitstring slot_mask := f_pad_bit(''B, 1024, '0'B);
6931 var bitstring ma_mask := ''B;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07006932
6933 /* Compose the full bit-mask (all channels, up to 1024 entries) */
6934 for (var integer i := 0; i < lengthof(fhp); i := i + 1) {
6935 for (var integer j := 0; j < lengthof(fhp[i].ma); j := j + 1) {
6936 if (full_mask[fhp[i].ma[j]] == '1'B)
6937 { continue; }
6938 full_mask[fhp[i].ma[j]] := '1'B;
6939 }
6940 }
6941
6942 /* Compose a bit-mask for the given timeslot number */
6943 for (var integer i := 0; i < lengthof(fhp[tn].ma); i := i + 1) {
6944 slot_mask[fhp[tn].ma[i]] := '1'B;
6945 }
6946
6947 /* Finally, compose the Mobile Allocation bit-mask */
6948 for (var integer i := 0; i < lengthof(full_mask); i := i + 1) {
6949 if (full_mask[i] != '1'B)
6950 { continue; }
6951
6952 /* FIXME: ma_mask := ma_mask & slot_mask[i]; // triggers a bug in TITAN */
6953 if (slot_mask[i] == '1'B) {
6954 ma_mask := ma_mask & '1'B;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07006955 } else {
6956 ma_mask := ma_mask & '0'B;
6957 }
6958 }
6959
6960 /* Ensure that ma_mask is octet-aligned */
Vadim Yanitskiy2aa02522020-09-06 14:05:23 +07006961 var integer ma_mask_len := (lengthof(ma_mask) + 8 - 1) / 8;
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07006962 ma_mask := f_pad_bit(ma_mask, ma_mask_len * 8, '0'B);
6963
6964 return { len := ma_mask_len, ma := ma_mask };
6965}
6966
6967/* Configure the hopping parameters in accordance with the given record */
6968private function f_TC_fh_params_set(in FHParamsTrx fhp,
6969 uint8_t bts_nr := 0,
6970 uint8_t trx_nr := 0)
6971runs on test_CT {
6972 /* Enter the configuration node for the given BTS/TRX numbers */
6973 f_vty_enter_cfg_trx(BSCVTY, bts_nr, trx_nr);
6974
6975 for (var integer tn := 0; tn < lengthof(fhp); tn := tn + 1) {
6976 f_vty_transceive(BSCVTY, "timeslot " & int2str(tn));
6977
6978 if (not fhp[tn].enabled) {
6979 f_vty_transceive(BSCVTY, "hopping enabled 0");
6980 f_vty_transceive(BSCVTY, "exit"); /* go back */
6981 continue;
6982 }
6983
6984 /* Configure HSN / MAIO values */
6985 f_vty_transceive(BSCVTY, "hopping sequence-number " & int2str(fhp[tn].hsn));
6986 f_vty_transceive(BSCVTY, "hopping maio " & int2str(fhp[tn].maio));
6987
6988 /* Configure the Mobile Allocation (hopping channels) */
6989 for (var integer i := 0; i < lengthof(fhp[tn].ma); i := i + 1) {
6990 f_vty_transceive(BSCVTY, "hopping arfcn add " & int2str(fhp[tn].ma[i]));
6991 }
6992
6993 f_vty_transceive(BSCVTY, "hopping enabled 1");
6994 f_vty_transceive(BSCVTY, "exit"); /* go back */
6995 }
6996
6997 f_vty_transceive(BSCVTY, "end");
6998}
6999
7000/* Disable frequency hopping on all timeslots */
7001private function f_TC_fh_params_unset(in FHParamsTrx fhp,
7002 uint8_t bts_nr := 0,
7003 uint8_t trx_nr := 0)
7004runs on test_CT {
7005 /* Enter the configuration node for the given BTS/TRX numbers */
7006 f_vty_enter_cfg_trx(BSCVTY, bts_nr, trx_nr);
7007
7008 for (var integer tn := 0; tn < lengthof(fhp); tn := tn + 1) {
7009 f_vty_transceive(BSCVTY, "timeslot " & int2str(tn));
7010
7011 /* Delete all ARFCNs from the Mobile Allocation (if any) */
7012 for (var integer i := 0; i < lengthof(fhp[tn].ma); i := i + 1) {
7013 f_vty_transceive(BSCVTY, "hopping arfcn del " & int2str(fhp[tn].ma[i]));
7014 }
7015
7016 f_vty_transceive(BSCVTY, "hopping enabled 0");
7017 f_vty_transceive(BSCVTY, "exit"); /* go back */
7018 }
7019
7020 f_vty_transceive(BSCVTY, "end");
7021 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
7022}
7023
7024/* Verify presence and correctness of the hopping parameters (HSN, MAIO)
7025 * in the Channel Identification IE of the RSL CHANnel ACTIVation message. */
7026testcase TC_fh_params_chan_activ() runs on test_CT {
7027 var FHParamsTrx fhp := f_TC_fh_params_gen();
7028 var RSL_Message rsl_msg;
7029 var RSL_IE_Body ie;
7030
7031 f_init_vty();
7032
7033 f_TC_fh_params_set(fhp); /* Enable frequency hopping */
7034 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
7035
7036 f_init(1);
7037
7038 /* CS domain: 3 (SDCCH/4+CBCH) + 4 (TCH/F) + 2 (TCH/H) channels available */
7039 for (var integer i := 0; i < 9; i := i + 1) {
7040 f_ipa_tx(0, ts_RSL_CHAN_RQD(f_rnd_ra_cs(), 23));
7041 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
7042
7043 /* Make sure that Channel Identification IE is present */
7044 if (not f_rsl_find_ie(rsl_msg, RSL_IE_CHAN_IDENT, ie)) {
7045 setverdict(fail, "RSL Channel Identification IE is absent");
7046 continue;
7047 }
7048
7049 /* Make sure that hopping parameters (HSN/MAIO) match */
7050 f_TC_fh_params_match_chan_desc(fhp, ie.chan_ident.ch_desc.v);
7051
7052 /* "Mobile Allocation shall be included but empty" - let's check this */
7053 if (ie.chan_ident.ma.v.len != 0) {
7054 setverdict(fail, "Mobile Allocation IE is not empty: ",
7055 ie.chan_ident.ma, ", despite it shall be");
7056 continue;
7057 }
7058 }
7059
7060 /* Disable frequency hopping */
7061 f_TC_fh_params_unset(fhp);
7062
Vadim Yanitskiy21726312020-09-04 01:45:36 +07007063 f_shutdown_helper();
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007064}
7065
7066/* Verify the hopping parameters (HSN, MAIO, MA) in (RR) Immediate Assignment */
7067testcase TC_fh_params_imm_ass() runs on test_CT {
7068 var FHParamsTrx fhp := f_TC_fh_params_gen();
7069 var RSL_Message rsl_msg;
7070 var RSL_IE_Body ie;
7071
7072 f_init_vty();
7073
7074 f_TC_fh_params_set(fhp); /* Enable frequency hopping */
7075 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
7076
7077 f_init(1);
7078
7079 /* CS domain: 3 (SDCCH/4+CBCH) + 4 (TCH/F) + 2 (TCH/H) channels available */
7080 for (var integer i := 0; i < 9; i := i + 1) {
7081 f_ipa_tx(0, ts_RSL_CHAN_RQD(f_rnd_ra_cs(), 23));
7082 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
7083
7084 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(rsl_msg.ies[0].body.chan_nr, 33));
7085 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeC(RSL_MT_IMMEDIATE_ASSIGN_CMD));
7086
7087 /* Make sure that Full Immediate Assign Info IE is present */
7088 if (not f_rsl_find_ie(rsl_msg, RSL_IE_FULL_IMM_ASS_INFO, ie)) {
7089 setverdict(fail, "RSL Full Immediate Assign Info IE is absent");
7090 continue;
7091 }
7092
7093 /* Decode the actual Immediate Assignment message */
7094 var GsmRrMessage rr_msg := dec_GsmRrMessage(ie.full_imm_ass_info.payload);
7095 if (not match(rr_msg.header, t_RrHeader(IMMEDIATE_ASSIGNMENT, ?))) {
7096 setverdict(fail, "Failed to match Immediate Assignment: ", rr_msg);
7097 continue;
7098 }
7099
7100 /* Make sure that hopping parameters (HSN/MAIO) match */
7101 f_TC_fh_params_match_chan_desc(fhp, rr_msg.payload.imm_ass.chan_desc);
7102
7103 /* Make sure that the Mobile Allocation IE matches */
7104 f_TC_fh_params_match_ma(fhp, rr_msg.payload.imm_ass.chan_desc.chan_nr.tn,
7105 rr_msg.payload.imm_ass.mobile_allocation);
7106 }
7107
7108 /* Disable frequency hopping */
7109 f_TC_fh_params_unset(fhp);
Philipp Maier82812002020-08-13 18:48:27 +02007110
Vadim Yanitskiy21726312020-09-04 01:45:36 +07007111 f_shutdown_helper();
Philipp Maier82812002020-08-13 18:48:27 +02007112}
7113
Vadim Yanitskiyaeb54a22020-09-01 06:25:25 +07007114/* Verify the hopping parameters (HSN, MAIO, MA) in (RR) Assignment Command */
7115testcase TC_fh_params_assignment_cmd() runs on test_CT {
7116 var FHParamsTrx fhp := f_TC_fh_params_gen();
7117 var RSL_Message rsl_msg;
7118 var RSL_IE_Body ie;
7119
7120 f_init_vty();
7121
7122 f_TC_fh_params_set(fhp); /* Enable frequency hopping */
7123 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
7124
7125 f_init(1);
7126
7127 /* HACK: work around "Couldn't find Expect for CRCX" */
7128 vc_MGCP.stop;
7129
7130 var template PDU_BSSAP ass_cmd := f_gen_ass_req();
7131 ass_cmd.pdu.bssmap.assignmentRequest.codecList := ts_BSSMAP_IE_CodecList({ts_CodecFR});
7132
7133 /* CS domain (TCH): 4 (TCH/F) + 2 (TCH/H) channels available
7134 * NOTE: only 3 SDCCH/4 channels are available on CCCH+SDCCH4+CBCH */
7135 for (var integer i := 0; i < 3; i := i + 1) {
7136 /* Establish a dedicated channel, so we can trigger (late) TCH assignment */
7137 var DchanTuple dt := f_est_dchan(f_rnd_ra_cs(), 23, f_rnd_octstring(16));
7138
7139 /* Send a BSSMAP Assignment Command, expect CHANnel ACTIVation */
7140 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ass_cmd));
7141 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
7142
7143 /* ACKnowledge CHANnel ACTIVation, expect RSL DATA REQuest */
7144 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(rsl_msg.ies[0].body.chan_nr, 33));
7145 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeR(RSL_MT_DATA_REQ));
7146
7147 /* Make sure that L3 Information IE is present */
7148 if (not f_rsl_find_ie(rsl_msg, RSL_IE_L3_INFO, ie)) {
7149 setverdict(fail, "RSL L3 Information IE is absent");
7150 continue;
7151 }
7152
7153 /* Decode the L3 message and make sure it is (RR) Assignment Command */
7154 var GsmRrL3Message l3_msg := dec_GsmRrL3Message(ie.l3_info.payload);
7155 if (not match(l3_msg.header, t_RrL3Header(ASSIGNMENT_COMMAND))) {
7156 setverdict(fail, "Failed to match Assignment Command: ", l3_msg);
7157 continue;
7158 }
7159
7160 /* Make sure that hopping parameters (HSN/MAIO) match */
7161 var ChannelDescription chan_desc := l3_msg.payload.ass_cmd.chan_desc;
7162 f_TC_fh_params_match_chan_desc(fhp, chan_desc);
7163
7164 /* Make sure that Cell Channel Description IE is present if FH is enabled */
7165 if (chan_desc.h and not ispresent(l3_msg.payload.ass_cmd.cell_chan_desc)) {
Vadim Yanitskiy38d069d2020-09-02 17:18:57 +07007166 setverdict(fail, "FH enabled, but Cell Channel Description IE is absent");
Vadim Yanitskiyaeb54a22020-09-01 06:25:25 +07007167 continue;
7168 }
7169
7170 /* Make sure that the Mobile Allocation IE matches (if present) */
7171 var boolean ma_present := ispresent(l3_msg.payload.ass_cmd.mobile_allocation);
7172 if (chan_desc.h and ma_present) {
7173 f_TC_fh_params_match_ma(fhp, chan_desc.chan_nr.tn,
7174 l3_msg.payload.ass_cmd.mobile_allocation.v);
7175 } else if (chan_desc.h and not ma_present) {
7176 setverdict(fail, "FH enabled, but Mobile Allocation IE is absent");
7177 continue;
7178 } else if (not chan_desc.h and ma_present) {
7179 setverdict(fail, "FH disabled, but Mobile Allocation IE is present");
7180 continue;
7181 }
7182 }
7183
7184 /* Give the IUT some time to release all channels */
7185 f_sleep(3.0);
7186
7187 /* Disable frequency hopping */
7188 f_TC_fh_params_unset(fhp);
7189
Vadim Yanitskiy21726312020-09-04 01:45:36 +07007190 f_shutdown_helper();
Vadim Yanitskiyaeb54a22020-09-01 06:25:25 +07007191}
7192
Vadim Yanitskiy8f5430d2020-09-02 18:51:38 +07007193/* Verify the hopping parameters (HSN, MAIO, MA) in (RR) Handover Command */
7194private function f_TC_fh_params_handover_cmd(in FHParamsTrx fhp)
7195runs on test_CT {
7196 var RSL_Message rsl_msg;
7197 var RSL_IE_Body ie;
7198 var DchanTuple dt;
7199
7200 /* Establish a dedicated channel, so we can trigger handover */
7201 dt := f_est_dchan(f_rnd_ra_cs(), 23, f_rnd_octstring(16));
7202
7203 /* Trigger handover from BTS0 to BTS1 */
7204 f_bts_0_cfg(BSCVTY, { "neighbor bts 1" });
7205 f_vty_handover(BSCVTY, 0, 0, dt.rsl_chan_nr, 1);
7206
7207 /* Expect RSL CHANnel ACTIVation on BTS1/TRX0/TS1 */
7208 rsl_msg := f_exp_ipa_rx(1, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
7209
7210 /* ACKnowledge channel activation and expect (RR) Handover Command */
7211 f_ipa_tx(1, ts_RSL_CHAN_ACT_ACK(rsl_msg.ies[0].body.chan_nr, 33));
7212 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeR(RSL_MT_DATA_REQ));
7213
7214 /* Make sure that L3 Information IE is present */
7215 if (not f_rsl_find_ie(rsl_msg, RSL_IE_L3_INFO, ie)) {
7216 setverdict(fail, "RSL L3 Information IE is absent");
7217 return;
7218 }
7219
7220 /* Decode the L3 message and make sure it is (RR) Handover Command */
7221 var GsmRrL3Message l3_msg := dec_GsmRrL3Message(ie.l3_info.payload);
7222 if (not match(l3_msg.header, t_RrL3Header(HANDOVER_COMMAND))) {
7223 setverdict(fail, "Failed to match Handover Command: ", l3_msg);
7224 return;
7225 }
7226
7227 /* Make sure that we've got SDCCH/8 on TS1 (expected to be hopping) */
7228 var ChannelDescription chan_desc := l3_msg.payload.ho_cmd.chan_desc;
7229 if (not match(chan_desc.chan_nr, t_RslChanNr_SDCCH8(1, ?))) {
7230 setverdict(fail, "Unexpected channel number: ", chan_desc.chan_nr);
7231 return;
7232 }
7233
7234 /* Make sure that hopping parameters (HSN/MAIO) match */
7235 f_TC_fh_params_match_chan_desc(fhp, chan_desc);
7236
7237 /* Make sure that Cell Channel Description IE is present */
7238 if (not ispresent(l3_msg.payload.ho_cmd.cell_chan_desc)) {
7239 setverdict(fail, "FH enabled, but Cell Channel Description IE is absent");
7240 return;
7241 }
7242
7243 /* Make sure that the Mobile Allocation (after time) IE is present and matches */
7244 var boolean ma_present := ispresent(l3_msg.payload.ho_cmd.mobile_allocation);
7245 if (ma_present) {
7246 f_TC_fh_params_match_ma(fhp, chan_desc.chan_nr.tn,
7247 l3_msg.payload.ho_cmd.mobile_allocation.v);
7248 } else {
7249 setverdict(fail, "FH enabled, but Mobile Allocation IE is absent");
7250 return;
7251 }
7252}
7253testcase TC_fh_params_handover_cmd() runs on test_CT {
7254 var FHParamsTrx fhp := f_TC_fh_params_gen();
7255
7256 f_init_vty();
7257
7258 /* (Re)configure TS0 as BCCH and TS1 as SDCCH8 on BTS1/TRX0 */
7259 f_vty_enter_cfg_trx(BSCVTY, bts := 1, trx := 0);
7260
7261 f_vty_transceive(BSCVTY, "timeslot 0");
7262 f_vty_transceive(BSCVTY, "phys_chan_config ccch");
7263 f_vty_transceive(BSCVTY, "exit"); /* go back */
7264
7265 f_vty_transceive(BSCVTY, "timeslot 1");
7266 f_vty_transceive(BSCVTY, "phys_chan_config sdcch8");
7267 f_vty_transceive(BSCVTY, "end"); /* we're done */
7268
7269 f_TC_fh_params_set(fhp, 1); /* Enable frequency hopping on BTS1 */
7270 f_vty_transceive(BSCVTY, "drop bts connection 1 oml");
7271
7272 f_init(2);
7273
7274 f_TC_fh_params_handover_cmd(fhp);
7275
7276 /* Disable frequency hopping on BTS1 */
7277 f_TC_fh_params_unset(fhp, 1);
7278
7279 /* (Re)configure TS0 as CCCH+SDCCH4+CBCH and TS1 as TCH/F */
7280 f_vty_enter_cfg_trx(BSCVTY, bts := 1, trx := 0);
7281
7282 f_vty_transceive(BSCVTY, "timeslot 0");
7283 f_vty_transceive(BSCVTY, "phys_chan_config ccch+sdcch4+cbch");
7284 f_vty_transceive(BSCVTY, "exit"); /* go back */
7285
7286 f_vty_transceive(BSCVTY, "timeslot 1");
7287 f_vty_transceive(BSCVTY, "phys_chan_config tch/f");
7288 f_vty_transceive(BSCVTY, "end"); /* we're done */
7289
7290 f_shutdown_helper();
7291}
7292
Vadim Yanitskiyca974032020-09-01 07:20:39 +07007293/* Verify the hopping parameters in System Information Type 4 */
7294testcase TC_fh_params_si4_cbch() runs on test_CT {
7295 var FHParamsTrx fhp := f_TC_fh_params_gen(tr_tn := 1);
7296 var ASP_RSL_Unitdata rx_rsl_ud;
7297 timer T := 5.0;
7298
7299 f_init_vty();
7300
7301 /* (Re)configure TS0 as BCCH and TS1 as SDCCH8+CBCH */
7302 f_vty_enter_cfg_trx(BSCVTY, trx := 0);
7303
7304 f_vty_transceive(BSCVTY, "timeslot 0");
7305 f_vty_transceive(BSCVTY, "phys_chan_config ccch");
7306 f_vty_transceive(BSCVTY, "exit"); /* go back */
7307
7308 f_vty_transceive(BSCVTY, "timeslot 1");
7309 f_vty_transceive(BSCVTY, "phys_chan_config sdcch8+cbch");
7310 f_vty_transceive(BSCVTY, "end"); /* we're done */
7311
7312 f_TC_fh_params_set(fhp); /* Enable frequency hopping */
7313 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
7314
7315 f_init(1);
7316
7317 T.start;
7318 alt {
7319 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_BCCH_INFO(RSL_SYSTEM_INFO_4))) -> value rx_rsl_ud {
7320 var RSL_IE_Body ie := rx_rsl_ud.rsl.ies[2].body; /* FULL BCCH Information IE */
7321 var SystemInformation si := dec_SystemInformation(ie.other.payload);
7322
7323 /* Make sure that what we decoded is System Information Type 4 */
7324 if (si.header.message_type != SYSTEM_INFORMATION_TYPE_4) {
7325 setverdict(fail, "RSL FULL BCCH Information IE contains: ", si);
7326 repeat;
7327 }
7328
7329 /* Make sure that CBCH Channel Description IE is present */
7330 if (not ispresent(si.payload.si4.cbch_chan_desc)) {
7331 setverdict(fail, "CBCH Channel Description IE is absent");
7332 break;
7333 }
7334
7335 /* Finally, check the hopping parameters (HSN, MAIO) */
7336 var ChannelDescription chan_desc := si.payload.si4.cbch_chan_desc.v;
7337 f_TC_fh_params_match_chan_desc(fhp, chan_desc);
7338
7339 /* 3GPP TS 44.018, section 9.1.36.2 "CBCH Mobile Allocation":
7340 * The CBCH Mobile Allocation IE *shall* be present if FH is enabled. */
7341 if (chan_desc.h and not ispresent(si.payload.si4.cbch_mobile_alloc)) {
7342 setverdict(fail, "FH enabled, but Mobile Allocation IE is absent");
7343 break;
7344 } else if (chan_desc.h and ispresent(si.payload.si4.cbch_mobile_alloc)) {
7345 f_TC_fh_params_match_ma(fhp, chan_desc.chan_nr.tn,
7346 si.payload.si4.cbch_mobile_alloc.v);
7347 }
7348 }
7349 [] IPA_RSL[0].receive { repeat; }
7350 [] T.timeout {
7351 setverdict(fail, "Timeout waiting for RSL BCCH INFOrmation (SI4)");
7352 }
7353 }
7354
7355 /* Disable frequency hopping */
7356 f_TC_fh_params_unset(fhp);
7357
Vadim Yanitskiy8bc46012020-09-06 12:38:01 +07007358 /* (Re)configure TS0 as CCCH+SDCCH4+CBCH and TS1 as TCH/F */
Vadim Yanitskiyca974032020-09-01 07:20:39 +07007359 f_vty_enter_cfg_trx(BSCVTY, trx := 0);
7360
7361 f_vty_transceive(BSCVTY, "timeslot 0");
Vadim Yanitskiy8bc46012020-09-06 12:38:01 +07007362 f_vty_transceive(BSCVTY, "phys_chan_config ccch+sdcch4+cbch");
Vadim Yanitskiyca974032020-09-01 07:20:39 +07007363 f_vty_transceive(BSCVTY, "exit"); /* go back */
7364
7365 f_vty_transceive(BSCVTY, "timeslot 1");
7366 f_vty_transceive(BSCVTY, "phys_chan_config tch/f");
7367 f_vty_transceive(BSCVTY, "end"); /* we're done */
7368
Vadim Yanitskiy21726312020-09-04 01:45:36 +07007369 f_shutdown_helper();
Vadim Yanitskiyca974032020-09-01 07:20:39 +07007370}
7371
Harald Welte0ea2d5e2018-04-07 21:40:29 +02007372/* Dyn PDCH todo:
7373 * activate OSMO as TCH/F
7374 * activate OSMO as TCH/H
7375 * does the BSC-located PCU socket get the updated INFO?
7376 * what if no PCU is connected at the time?
7377 * is the info correct on delayed PCU (re)connect?
7378 */
Harald Welte94e0c342018-04-07 11:33:23 +02007379
Harald Welte28d943e2017-11-25 15:00:50 +01007380control {
Harald Welte898113b2018-01-31 18:32:21 +01007381 /* CTRL interface testing */
Harald Welte4003d112017-12-09 22:35:39 +01007382 execute( TC_ctrl_msc_connection_status() );
Stefan Sperlingb041b3d2018-01-03 17:14:55 +01007383 execute( TC_ctrl_msc0_connection_status() );
Harald Welte96c94412017-12-09 03:12:45 +01007384 execute( TC_ctrl() );
Neels Hofmeyrf246a922020-05-13 02:27:10 +02007385 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_SCCPlite_SERVER) {
Pau Espin Pedrol5a2d7432019-06-07 19:43:45 +02007386 execute( TC_ctrl_location() );
7387 }
Harald Welte898113b2018-01-31 18:32:21 +01007388
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +02007389 execute( TC_si_default() );
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02007390 execute( TC_si2quater_2_earfcns() );
7391 execute( TC_si2quater_3_earfcns() );
7392 execute( TC_si2quater_4_earfcns() );
7393 execute( TC_si2quater_5_earfcns() );
7394 execute( TC_si2quater_6_earfcns() );
Neels Hofmeyrad132f22020-07-08 02:20:16 +02007395 execute( TC_si2quater_12_earfcns() );
7396 execute( TC_si2quater_23_earfcns() );
7397 execute( TC_si2quater_32_earfcns() );
7398 execute( TC_si2quater_33_earfcns() );
7399 execute( TC_si2quater_42_earfcns() );
7400 execute( TC_si2quater_48_earfcns() );
7401 execute( TC_si2quater_49_earfcns() );
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02007402 execute( TC_si_acc_rotate() );
Pau Espin Pedrolc6136cd2020-07-24 13:20:02 +02007403 execute (TC_si_acc_ramp_rotate() );
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +02007404
Harald Welte898113b2018-01-31 18:32:21 +01007405 /* RSL DCHAN Channel ACtivation / Deactivation */
Harald Welteae026692017-12-09 01:03:01 +01007406 execute( TC_chan_act_noreply() );
Harald Welte4003d112017-12-09 22:35:39 +01007407 execute( TC_chan_act_counter() );
Harald Welteae026692017-12-09 01:03:01 +01007408 execute( TC_chan_act_ack_noest() );
Philipp Maier9c60a622020-07-09 15:08:46 +02007409 execute( TC_chan_act_ack_noest_emerg() );
Philipp Maier606f07d2020-08-12 17:21:58 +02007410 execute( TC_chan_rqd_emerg_deny() );
Harald Welteae026692017-12-09 01:03:01 +01007411 execute( TC_chan_act_ack_est_ind_noreply() );
7412 execute( TC_chan_act_ack_est_ind_refused() );
Harald Welte618ef642017-12-14 14:58:20 +01007413 execute( TC_chan_act_nack() );
Harald Welte799c97b2017-12-14 17:50:30 +01007414 execute( TC_chan_exhaustion() );
Vadim Yanitskiy1ff1fdf2018-11-27 01:32:57 +07007415 execute( TC_chan_deact_silence() );
Harald Welte4003d112017-12-09 22:35:39 +01007416 execute( TC_chan_rel_rll_rel_ind() );
7417 execute( TC_chan_rel_conn_fail() );
7418 execute( TC_chan_rel_hard_clear() );
Harald Welte99787102019-02-04 10:41:36 +01007419 execute( TC_chan_rel_hard_clear_csfb() );
Harald Welted8c36cd2017-12-09 23:05:31 +01007420 execute( TC_chan_rel_hard_rlsd() );
Harald Welte550daf92018-06-11 19:22:13 +02007421 execute( TC_chan_rel_hard_rlsd_ms_dead() );
Harald Welte85804d42017-12-10 14:11:58 +01007422 execute( TC_chan_rel_a_reset() );
Pau Espin Pedrolc675b612020-01-09 19:55:40 +01007423 execute( TC_chan_rel_sccp_tiar_timeout() );
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02007424 execute( TC_chan_rel_rr_cause() );
Harald Welte6f521d82017-12-11 19:52:02 +01007425
Harald Weltecfe2c962017-12-15 12:09:32 +01007426 execute( TC_outbound_connect() );
Harald Welte898113b2018-01-31 18:32:21 +01007427
7428 /* Assignment related */
Harald Welte16a4adf2017-12-14 18:54:01 +01007429 execute( TC_assignment_cic_only() );
Harald Welte235ebf12017-12-15 14:18:16 +01007430 execute( TC_assignment_csd() );
7431 execute( TC_assignment_ctm() );
7432 execute( TC_assignment_sign() );
Pau Espin Pedrol07866632020-09-03 19:10:55 +02007433 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
7434 execute( TC_assignment_aoip_tla_v6() );
7435 }
Harald Welte235ebf12017-12-15 14:18:16 +01007436 execute( TC_assignment_fr_a5_0() );
7437 execute( TC_assignment_fr_a5_1() );
Neels Hofmeyrf246a922020-05-13 02:27:10 +02007438 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
Harald Welte8f67d1d2018-05-25 20:38:42 +02007439 execute( TC_assignment_fr_a5_1_codec_missing() );
7440 }
Harald Welte235ebf12017-12-15 14:18:16 +01007441 execute( TC_assignment_fr_a5_3() );
7442 execute( TC_assignment_fr_a5_4() );
Harald Welte3c86ea02018-05-10 22:28:05 +02007443 execute( TC_ciph_mode_a5_0() );
7444 execute( TC_ciph_mode_a5_1() );
7445 execute( TC_ciph_mode_a5_3() );
Harald Welte16a4adf2017-12-14 18:54:01 +01007446
Harald Welte60aa5762018-03-21 19:33:13 +01007447 execute( TC_assignment_codec_fr() );
7448 execute( TC_assignment_codec_hr() );
7449 execute( TC_assignment_codec_efr() );
7450 execute( TC_assignment_codec_amr_f() );
7451 execute( TC_assignment_codec_amr_h() );
Philipp Maier8a581d22019-03-26 18:32:48 +01007452
Neels Hofmeyrf246a922020-05-13 02:27:10 +02007453 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
Philipp Maier8a581d22019-03-26 18:32:48 +01007454 execute( TC_assignment_codec_amr_f_S1() );
7455 execute( TC_assignment_codec_amr_h_S1() );
7456 execute( TC_assignment_codec_amr_f_S124() );
7457 execute( TC_assignment_codec_amr_h_S124() );
7458 execute( TC_assignment_codec_amr_f_S0() );
7459 execute( TC_assignment_codec_amr_f_S02() );
7460 execute( TC_assignment_codec_amr_f_S024() );
7461 execute( TC_assignment_codec_amr_f_S0247() );
7462 execute( TC_assignment_codec_amr_h_S0() );
7463 execute( TC_assignment_codec_amr_h_S02() );
7464 execute( TC_assignment_codec_amr_h_S024() );
7465 execute( TC_assignment_codec_amr_h_S0247() );
7466 execute( TC_assignment_codec_amr_f_S01234567() );
7467 execute( TC_assignment_codec_amr_f_S0234567() );
7468 execute( TC_assignment_codec_amr_f_zero() );
7469 execute( TC_assignment_codec_amr_f_unsupp() );
7470 execute( TC_assignment_codec_amr_h_S7() );
7471 }
Harald Welte60aa5762018-03-21 19:33:13 +01007472
Philipp Maierac09bfc2019-01-08 13:41:39 +01007473 execute( TC_assignment_codec_fr_exhausted_req_hr() );
7474 execute( TC_assignment_codec_fr_exhausted_req_fr() );
7475 execute( TC_assignment_codec_fr_exhausted_req_fr_hr() );
7476 execute( TC_assignment_codec_fr_exhausted_req_hr_fr() );
7477 execute( TC_assignment_codec_hr_exhausted_req_fr() );
7478 execute( TC_assignment_codec_hr_exhausted_req_hr() );
7479 execute( TC_assignment_codec_hr_exhausted_req_hr_fr() );
7480 execute( TC_assignment_codec_hr_exhausted_req_fr_hr() );
7481 execute( TC_assignment_codec_req_hr_fr() );
7482 execute( TC_assignment_codec_req_fr_hr() );
7483
Pau Espin Pedrol58cf6822019-05-28 18:11:33 +02007484 if (mp_enable_osmux_test) {
7485 execute( TC_assignment_osmux() );
7486 }
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02007487
Harald Welte898113b2018-01-31 18:32:21 +01007488 /* RLL Establish Indication on inactive DCHAN / SAPI */
Harald Welte5cd20ed2017-12-13 21:03:20 +01007489 execute( TC_rll_est_ind_inact_lchan() );
7490 execute( TC_rll_est_ind_inval_sapi1() );
7491 execute( TC_rll_est_ind_inval_sapi3() );
7492 execute( TC_rll_est_ind_inval_sacch() );
7493
Vadim Yanitskiy6ef5dfa2020-08-28 18:04:41 +07007494 /* SAPI N Reject triggered by RLL establishment failures */
7495 execute( TC_rll_rel_ind_sapi_n_reject() );
7496 execute( TC_rll_err_ind_sapi_n_reject() );
7497 execute( TC_rll_timeout_sapi_n_reject() );
7498
Harald Welte898113b2018-01-31 18:32:21 +01007499 /* Paging related tests */
Harald Welte6f521d82017-12-11 19:52:02 +01007500 execute( TC_paging_imsi_nochan() );
7501 execute( TC_paging_tmsi_nochan() );
7502 execute( TC_paging_tmsi_any() );
7503 execute( TC_paging_tmsi_sdcch() );
7504 execute( TC_paging_tmsi_tch_f() );
7505 execute( TC_paging_tmsi_tch_hf() );
7506 execute( TC_paging_imsi_nochan_cgi() );
7507 execute( TC_paging_imsi_nochan_lac_ci() );
7508 execute( TC_paging_imsi_nochan_ci() );
7509 execute( TC_paging_imsi_nochan_lai() );
7510 execute( TC_paging_imsi_nochan_lac() );
7511 execute( TC_paging_imsi_nochan_all() );
Harald Welte751d3eb2018-01-31 15:51:06 +01007512 execute( TC_paging_imsi_nochan_plmn_lac_rnc() );
7513 execute( TC_paging_imsi_nochan_rnc() );
7514 execute( TC_paging_imsi_nochan_lac_rnc() );
7515 execute( TC_paging_imsi_nochan_lacs() );
7516 execute( TC_paging_imsi_nochan_lacs_empty() );
Stefan Sperling049a86e2018-03-20 15:51:00 +01007517 execute( TC_paging_imsi_nochan_cgi_unknown_cid() );
Harald Welte10985002017-12-12 09:29:15 +01007518 execute( TC_paging_imsi_a_reset() );
Harald Weltee65d40e2017-12-13 00:09:06 +01007519 execute( TC_paging_imsi_load() );
Philipp Maier779a7922018-02-16 11:00:37 +01007520 execute( TC_paging_counter() );
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01007521 execute( TC_paging_resp_unsol() );
Harald Welte4e9b9cc2017-12-14 18:31:02 +01007522
7523 execute( TC_rsl_drop_counter() );
Stefan Sperling830dc9d2018-02-12 21:08:28 +01007524 execute( TC_rsl_unknown_unit_id() );
7525
7526 execute( TC_oml_unknown_unit_id() );
Harald Welte898113b2018-01-31 18:32:21 +01007527
7528 execute( TC_classmark() );
Harald Welteeddf0e92020-06-21 19:42:15 +02007529 execute( TC_common_id() );
Harald Welte898113b2018-01-31 18:32:21 +01007530 execute( TC_unsol_ass_fail() );
Harald Welteea99a002018-01-31 20:46:43 +01007531 execute( TC_unsol_ass_compl() );
Harald Weltefbf9b5e2018-01-31 20:41:23 +01007532 execute( TC_unsol_ho_fail() );
Harald Weltee3bd6582018-01-31 22:51:25 +01007533 execute( TC_err_82_short_msg() );
Harald Weltee9e02e42018-01-31 23:36:25 +01007534 execute( TC_err_84_unknown_msg() );
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01007535
Harald Welte261af4b2018-02-12 21:20:39 +01007536 execute( TC_ho_int() );
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01007537
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01007538 execute( TC_ho_out_of_this_bsc() );
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02007539 execute( TC_ho_out_fail_no_msc_response() );
7540 execute( TC_ho_out_fail_rr_ho_failure() );
Neels Hofmeyrd8a602c2019-07-09 19:46:01 +02007541 execute( TC_ho_out_fail_no_result_after_ho_cmd() );
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01007542
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01007543 execute( TC_ho_into_this_bsc() );
Pau Espin Pedrol07866632020-09-03 19:10:55 +02007544 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
7545 execute( TC_ho_into_this_bsc_tla_v6() );
7546 }
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01007547 execute( TC_ho_in_fail_msc_clears() );
7548 execute( TC_ho_in_fail_msc_clears_after_ho_detect() );
7549 execute( TC_ho_in_fail_no_detect() );
7550 execute( TC_ho_in_fail_no_detect2() );
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01007551
Neels Hofmeyr91401012019-07-11 00:42:35 +02007552 execute( TC_ho_neighbor_config_1() );
7553 execute( TC_ho_neighbor_config_2() );
7554 execute( TC_ho_neighbor_config_3() );
7555 execute( TC_ho_neighbor_config_4() );
7556 execute( TC_ho_neighbor_config_5() );
7557 execute( TC_ho_neighbor_config_6() );
7558 execute( TC_ho_neighbor_config_7() );
7559
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01007560 execute( TC_bssap_rlsd_does_not_cause_bssmap_reset() );
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01007561 execute( TC_bssmap_clear_does_not_cause_bssmap_reset() );
Neels Hofmeyrfd445c32018-03-09 15:39:31 +01007562 execute( TC_ms_rel_ind_does_not_cause_bssmap_reset() );
Harald Welte94e0c342018-04-07 11:33:23 +02007563
7564 execute( TC_dyn_pdch_ipa_act_deact() );
7565 execute( TC_dyn_pdch_ipa_act_nack() );
7566 execute( TC_dyn_pdch_osmo_act_deact() );
7567 execute( TC_dyn_pdch_osmo_act_nack() );
Harald Welte99f3ca02018-06-14 13:40:29 +02007568
Stefan Sperling0796a822018-10-05 13:01:39 +02007569 execute( TC_chopped_ipa_ping() );
Stefan Sperlingaa1e60f2018-10-15 16:34:07 +02007570 execute( TC_chopped_ipa_payload() );
Stefan Sperling0796a822018-10-05 13:01:39 +02007571
Pau Espin Pedrol8f773632019-11-05 11:46:53 +01007572 /* Power control related */
7573 execute( TC_assignment_verify_ms_power_params_ie() );
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007574
7575 /* MSC pooling */
7576 /* FIXME: in SCCPlite, indicating how many MSCs should be connected does currently not work. Since
7577 * RESET->RESET-ACK is unconditionally negotiated for all configured MSCs, they always all appear as connected
7578 * to osmo-bsc. The MSC pooling tests however require disconnecting selected MSCs, and hence don't work out as
7579 * intended on SCCPlite. So for now, run these only for SCCP/M3UA. */
7580 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
7581 execute( TC_mscpool_L3Compl_on_1_msc() );
7582 execute( TC_mscpool_L3Complete_by_imsi_round_robin() );
7583 execute( TC_mscpool_LU_by_tmsi_null_nri_0_round_robin() );
7584 execute( TC_mscpool_LU_by_tmsi_null_nri_1_round_robin() );
7585 execute( TC_mscpool_L3Complete_by_tmsi_unassigned_nri_round_robin() );
7586 execute( TC_mscpool_L3Complete_by_tmsi_valid_nri_msc_not_connected_round_robin() );
7587 execute( TC_mscpool_L3Complete_by_tmsi_valid_nri_1() );
7588 execute( TC_mscpool_L3Complete_by_tmsi_valid_nri_2() );
7589 execute( TC_mscpool_LU_by_tmsi_from_other_PLMN() );
7590 execute( TC_mscpool_paging_and_response_imsi() );
7591 execute( TC_mscpool_paging_and_response_tmsi() );
7592 execute( TC_mscpool_no_allow_attach_round_robin() );
7593 execute( TC_mscpool_no_allow_attach_valid_nri() );
7594 }
7595
Harald Welte99f3ca02018-06-14 13:40:29 +02007596 /* at bottom as they might crash OsmoBSC before OS#3182 is fixed */
7597 execute( TC_early_conn_fail() );
7598 execute( TC_late_conn_fail() );
7599
Philipp Maier783681c2020-07-16 16:47:06 +02007600 /* Emergency call handling (deny / allow) */
7601 execute( TC_assignment_emerg_setup_allow() );
7602 execute( TC_assignment_emerg_setup_deny_msc() );
7603 execute( TC_assignment_emerg_setup_deny_bts() );
Philipp Maier82812002020-08-13 18:48:27 +02007604 execute( TC_emerg_premption() );
7605
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007606 /* Frequency hopping parameters handling */
7607 execute( TC_fh_params_chan_activ() );
7608 execute( TC_fh_params_imm_ass() );
Vadim Yanitskiyaeb54a22020-09-01 06:25:25 +07007609 execute( TC_fh_params_assignment_cmd() );
Vadim Yanitskiy8f5430d2020-09-02 18:51:38 +07007610 execute( TC_fh_params_handover_cmd() );
Vadim Yanitskiyca974032020-09-01 07:20:39 +07007611 execute( TC_fh_params_si4_cbch() );
Harald Welte28d943e2017-11-25 15:00:50 +01007612}
7613
7614}