blob: 8944447589286ee9f8cf3705e98353855935a820 [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;
747 timer T := 5.0;
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200748 BSSAP.send(ts_BSSAP_UNITDATA_req(g_bssap[bssap_idx].sccp_addr_peer, g_bssap[bssap_idx].sccp_addr_own,
749 ts_BSSMAP_Reset(0, g_osmux_enabled)));
Harald Weltea4ca4462018-02-09 00:17:14 +0100750 T.start;
751 alt {
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200752 [] BSSAP.receive(tr_BSSAP_UNITDATA_ind(g_bssap[bssap_idx].sccp_addr_own, g_bssap[bssap_idx].sccp_addr_peer,
753 tr_BSSMAP_ResetAck(g_osmux_enabled))) {
Harald Weltea4ca4462018-02-09 00:17:14 +0100754 log("Received RESET-ACK in response to RESET, we're ready to go!");
755 }
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200756 [] BSSAP.receive(tr_BSSAP_UNITDATA_ind(?, ?, tr_BSSMAP_Reset(g_osmux_enabled))) -> value ud_ind {
Harald Weltea4ca4462018-02-09 00:17:14 +0100757 log("Respoding to inbound RESET with RESET-ACK");
758 BSSAP.send(ts_BSSAP_UNITDATA_req(ud_ind.callingAddress, ud_ind.calledAddress,
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200759 ts_BSSMAP_ResetAck(g_osmux_enabled)));
Harald Weltea4ca4462018-02-09 00:17:14 +0100760 repeat;
761 }
762 [] BSSAP.receive { repeat; }
763 [] T.timeout { setverdict(fail, "Waiting for RESET-ACK after sending RESET"); }
764 }
Harald Welte28d943e2017-11-25 15:00:50 +0100765}
766
Harald Welteae026692017-12-09 01:03:01 +0100767type record IPA_Client {
Harald Welte21b46bd2017-12-17 19:46:32 +0100768 /* IPA Emulation component reference */
Harald Welteae026692017-12-09 01:03:01 +0100769 IPA_Emulation_CT vc_IPA,
Harald Welte21b46bd2017-12-17 19:46:32 +0100770 /* Unit-ID and other CCM parameters to use for IPA client emulation */
Harald Welteae026692017-12-09 01:03:01 +0100771 IPA_CCM_Parameters ccm_pars,
Harald Welte21b46bd2017-12-17 19:46:32 +0100772 /* String identifier for this IPA Client */
Harald Welte624f9632017-12-16 19:26:04 +0100773 charstring id,
Harald Welte21b46bd2017-12-17 19:46:32 +0100774 /* Associated RSL Emulation Component (if any). Only used in "Handler mode" */
Harald Welte624f9632017-12-16 19:26:04 +0100775 RSL_Emulation_CT vc_RSL optional
Harald Welte28d943e2017-11-25 15:00:50 +0100776}
777
Harald Welte21b46bd2017-12-17 19:46:32 +0100778/*! Start the IPA/RSL related bits for one IPA_Client.
779 * \param clnt IPA_Client for which to establish
780 * \param bsc_host IP address / hostname of the BSC
781 * \param bsc_port TCP port number of the BSC
782 * \param i number identifying this BTS
783 * \param handler_mode Start an RSL_Emulation_CT component (true) or not (false) */
Harald Welte624f9632017-12-16 19:26:04 +0100784function f_ipa_rsl_start(inout IPA_Client clnt, charstring bsc_host, PortNumber bsc_port, integer i,
785 boolean handler_mode := false)
Harald Welte28d943e2017-11-25 15:00:50 +0100786runs on test_CT {
Harald Welteae026692017-12-09 01:03:01 +0100787 timer T := 10.0;
788
Harald Welte96c94412017-12-09 03:12:45 +0100789 clnt.id := "IPA" & int2str(i) & "-RSL";
Harald Welteae026692017-12-09 01:03:01 +0100790 clnt.vc_IPA := IPA_Emulation_CT.create(clnt.id & "-IPA");
791 clnt.ccm_pars := c_IPA_default_ccm_pars;
792 clnt.ccm_pars.name := "Osmocom TTCN-3 BTS Simulator";
793 clnt.ccm_pars.unit_id := int2str(1234+i) & "/0/0";
Harald Welte624f9632017-12-16 19:26:04 +0100794 if (handler_mode) {
795 clnt.vc_RSL := RSL_Emulation_CT.create(clnt.id & "-RSL");
Harald Welte89ab1912018-02-23 18:56:29 +0100796 connect(clnt.vc_RSL:CCHAN_PT, self:RSL_CCHAN[i]);
Harald Welte624f9632017-12-16 19:26:04 +0100797 }
Harald Welteae026692017-12-09 01:03:01 +0100798
799 map(clnt.vc_IPA:IPA_PORT, system:IPA_CODEC_PT);
Harald Welte624f9632017-12-16 19:26:04 +0100800 if (handler_mode) {
801 connect(clnt.vc_IPA:IPA_RSL_PORT, clnt.vc_RSL:IPA_PT);
802 } else {
803 connect(clnt.vc_IPA:IPA_RSL_PORT, self:IPA_RSL[i]);
804 }
Harald Welteae026692017-12-09 01:03:01 +0100805
Harald Welte5d1a2202017-12-13 19:51:29 +0100806 clnt.vc_IPA.start(IPA_Emulation.main_client(bsc_host, bsc_port, "", 10000+i, clnt.ccm_pars));
Harald Welte624f9632017-12-16 19:26:04 +0100807 if (handler_mode) {
808 clnt.vc_RSL.start(RSL_Emulation.main());
809 return;
810 }
Harald Welteae026692017-12-09 01:03:01 +0100811
812 /* wait for IPA RSL link to connect and send ID ACK */
813 T.start;
814 alt {
Vadim Yanitskiya2afacc2020-05-18 21:16:19 +0700815 [] IPA_RSL[i].receive(tr_ASP_IPA_EV(ASP_IPA_EVENT_ID_ACK)) {
Harald Welteae026692017-12-09 01:03:01 +0100816 T.stop;
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +0700817 IPA_RSL[i].send(ts_ASP_RSL_UD(ts_RSL_PAGING_LOAD_IND(23)));
Harald Welteae026692017-12-09 01:03:01 +0100818 }
Harald Welte60e823a2017-12-10 14:10:59 +0100819 [] IPA_RSL[i].receive(ASP_IPA_Event:?) { repeat }
Harald Welteae026692017-12-09 01:03:01 +0100820 [] IPA_RSL[i].receive { repeat }
821 [] T.timeout {
Harald Welte96c94412017-12-09 03:12:45 +0100822 setverdict(fail, "Timeout RSL waiting for ASP_IPA_EVENT_ID_ACK");
Daniel Willmannafce8662018-07-06 23:11:32 +0200823 mtc.stop;
Harald Welteae026692017-12-09 01:03:01 +0100824 }
825 }
826}
827
Harald Welte12055472018-03-17 20:10:08 +0100828function f_ipa_rsl_stop(inout IPA_Client clnt) runs on test_CT {
829 if (not isbound(clnt) or not isbound(clnt.vc_IPA)) {
830 return;
831 }
832 clnt.vc_IPA.stop;
833 if (isbound(clnt.vc_RSL)) {
834 clnt.vc_RSL.stop;
835 }
836}
837
Harald Welte21b46bd2017-12-17 19:46:32 +0100838/* Wait for the OML connection to be brought up by the external osmo-bts-omldummy */
Harald Weltea5d2ab22017-12-09 14:21:42 +0100839function f_wait_oml(integer bts_nr, charstring status, float secs_max) runs on test_CT {
840 timer T := secs_max;
841 T.start;
842 while (true) {
843 if (f_ctrl_get_bts(IPA_CTRL, bts_nr, "oml-connection-state") == status) {
844 T.stop;
Harald Weltebd868bd2017-12-10 18:28:40 +0100845 /* the 'degraded' state exists from OML connection time, and we have to wait
846 * until all MO's are initialized */
847 T.start(1.0);
848 T.timeout;
Harald Weltea5d2ab22017-12-09 14:21:42 +0100849 return;
850 }
Harald Weltef0d6ac62017-12-17 17:02:21 +0100851 f_sleep(0.1);
Harald Weltea5d2ab22017-12-09 14:21:42 +0100852 if (not T.running) {
Max99253902018-11-16 17:57:39 +0100853 setverdict(fail, "Timeout waiting for BTS" & int2str(bts_nr) & " oml-connection-state ", status);
Daniel Willmannafce8662018-07-06 23:11:32 +0200854 mtc.stop;
Harald Weltea5d2ab22017-12-09 14:21:42 +0100855 }
856 }
857}
858
Harald Welte21b46bd2017-12-17 19:46:32 +0100859/* global altstep for global guard timer; also takes care of responding RESET witH RESET-ACK */
Harald Welteae026692017-12-09 01:03:01 +0100860altstep as_Tguard() runs on test_CT {
Harald Welte60e823a2017-12-10 14:10:59 +0100861 var BSSAP_N_UNITDATA_ind ud_ind;
Neels Hofmeyrcc3f76a2018-03-12 01:43:25 +0100862 [] T_guard.timeout {
863 setverdict(fail, "Timeout of T_guard");
Daniel Willmannafce8662018-07-06 23:11:32 +0200864 mtc.stop;
Neels Hofmeyrcc3f76a2018-03-12 01:43:25 +0100865 }
Harald Welte60e823a2017-12-10 14:10:59 +0100866 /* always respond with RESET ACK to RESET */
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200867 [] BSSAP.receive(tr_BSSAP_UNITDATA_ind(?, ?, tr_BSSMAP_Reset(g_osmux_enabled))) -> value ud_ind {
Harald Welte60e823a2017-12-10 14:10:59 +0100868 BSSAP.send(ts_BSSAP_UNITDATA_req(ud_ind.callingAddress, ud_ind.calledAddress,
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200869 ts_BSSMAP_ResetAck(g_osmux_enabled)));
Harald Welte69c1c262017-12-13 21:02:08 +0100870 repeat;
Harald Welte60e823a2017-12-10 14:10:59 +0100871 }
Harald Welte28d943e2017-11-25 15:00:50 +0100872}
873
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +0100874altstep no_bssmap_reset() runs on test_CT {
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200875 [] BSSAP.receive(tr_BSSAP_UNITDATA_ind(?, ?, tr_BSSMAP_Reset(g_osmux_enabled))) {
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +0100876 setverdict(fail, "unexpected BSSMAP Reset");
Daniel Willmannafce8662018-07-06 23:11:32 +0200877 mtc.stop;
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +0100878 }
879}
880
Daniel Willmann191e0d92018-01-17 12:44:35 +0100881function f_init_mgcp(charstring id) runs on test_CT {
882 id := id & "-MGCP";
883
884 var MGCPOps ops := {
885 create_cb := refers(MGCP_Emulation.ExpectedCreateCallback),
886 unitdata_cb := refers(MGCP_Emulation.DummyUnitdataCallback)
887 };
888 var MGCP_conn_parameters mgcp_pars := {
889 callagent_ip := mp_bsc_ip,
Harald Welte9e4273e2018-01-29 22:01:22 +0100890 callagent_udp_port := -1,
Daniel Willmann191e0d92018-01-17 12:44:35 +0100891 mgw_ip := mp_test_ip,
Pau Espin Pedrol1a026a52019-06-18 17:21:52 +0200892 mgw_udp_port := 2427,
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +0200893 /* Enable it for SCCPlite, since we have 2 MGCP sockets towards MGW (UDP one +
894 the on with MGCP over IPA forwarded from MSC one) */
Neels Hofmeyrf246a922020-05-13 02:27:10 +0200895 multi_conn_mode := (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_SCCPlite_SERVER)
Daniel Willmann191e0d92018-01-17 12:44:35 +0100896 };
897
898 vc_MGCP := MGCP_Emulation_CT.create(id);
899 vc_MGCP.start(MGCP_Emulation.main(ops, mgcp_pars, id));
900}
901
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +0200902/* Enable or disable (current default) Osmux. When enabling, BSSMAP Reset
903 * contains extra IE (OsmuxSupport) and osmo-bsc will handle AssignReq with
904 * OsmuxCID IE.
905 */
906private function f_vty_allow_osmux(boolean allow) runs on test_CT {
907 f_vty_enter_cfg_msc(BSCVTY, 0);
908 if (allow) {
909 f_vty_transceive(BSCVTY, "osmux on");
910 } else {
911 f_vty_transceive(BSCVTY, "osmux off");
912 }
913 f_vty_transceive(BSCVTY, "exit");
914 f_vty_transceive(BSCVTY, "exit");
915 g_osmux_enabled := allow;
916}
917
Max2253c0b2018-11-06 19:28:05 +0100918function f_init_vty(charstring id := "foo") runs on test_CT {
Harald Welte94e0c342018-04-07 11:33:23 +0200919 if (BSCVTY.checkstate("Mapped")) {
920 /* skip initialization if already executed once */
921 return;
922 }
Harald Weltebc03c762018-02-12 18:09:38 +0100923 map(self:BSCVTY, system:BSCVTY);
924 f_vty_set_prompts(BSCVTY);
925 f_vty_transceive(BSCVTY, "enable");
Pau Espin Pedrolc675b612020-01-09 19:55:40 +0100926 f_cs7_inst_0_cfg(BSCVTY, {"sccp-timer ias " & int2str(g_bsc_sccp_timer_ias),
927 "sccp-timer iar " & int2str(g_bsc_sccp_timer_iar)});
Harald Weltebc03c762018-02-12 18:09:38 +0100928}
929
Neels Hofmeyr4f118412020-06-04 15:25:10 +0200930private function f_logp(charstring log_msg) runs on MSC_ConnHdlr
931{
932 // log on TTCN3 log output
933 log(log_msg);
934 // log in stderr log
935 f_vty_transceive(BSCVTY, "logp lglobal notice " & log_msg);
936}
937
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +0200938private function f_sysinfo_seen(integer rsl_idx, RSL_Message rsl) runs on test_CT
939{
940 if (rsl_idx >= lengthof(g_system_information)) {
941 g_system_information[rsl_idx] := SystemInformationConfig_omit
942 }
943 f_sysinfo_dec_raw(g_system_information[rsl_idx], rsl);
944}
945
946altstep as_catch_RSL_sysinfo(integer rsl_idx) runs on test_CT {
947 var ASP_RSL_Unitdata rx_rsl_ud;
948
949 /* For handler_mode := false, receiving the RSL bootstrap messages directly on IPA_RSL */
950 [] IPA_RSL[rsl_idx].receive(tr_ASP_RSL_UD(tr_RSL_NO_BCCH_INFO)) -> value rx_rsl_ud {
951 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
952 repeat;
953 }
954 [] IPA_RSL[rsl_idx].receive(tr_ASP_RSL_UD(tr_RSL_BCCH_INFO)) -> value rx_rsl_ud {
955 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
956 repeat;
957 }
958 [] IPA_RSL[rsl_idx].receive(tr_ASP_RSL_UD(tr_RSL_NO_SACCH_FILL)) -> value rx_rsl_ud {
959 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
960 repeat;
961 }
962 [] IPA_RSL[rsl_idx].receive(tr_ASP_RSL_UD(tr_RSL_SACCH_FILL)) -> value rx_rsl_ud {
963 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
964 repeat;
965 }
966
967 /* For handler_mode := true, receiving the RSL bootstrap messages via RSL_Emulation */
968 [] RSL_CCHAN[rsl_idx].receive(tr_ASP_RSL_UD(tr_RSL_NO_BCCH_INFO)) -> value rx_rsl_ud {
969 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
970 repeat;
971 }
972 [] RSL_CCHAN[rsl_idx].receive(tr_ASP_RSL_UD(tr_RSL_BCCH_INFO)) -> value rx_rsl_ud {
973 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
974 repeat;
975 }
976 [] RSL_CCHAN[rsl_idx].receive(tr_ASP_RSL_UD(tr_RSL_NO_SACCH_FILL)) -> value rx_rsl_ud {
977 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
978 repeat;
979 }
980 [] RSL_CCHAN[rsl_idx].receive(tr_ASP_RSL_UD(tr_RSL_SACCH_FILL)) -> value rx_rsl_ud {
981 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
982 repeat;
983 }
984}
985
Neels Hofmeyra460f1f2020-08-09 20:17:03 +0000986/* TODO: use BooleanList from COMMON/src/General_Types.ttcn */
987private type record of boolean my_BooleanList;
988
989private function f_vty_msc_allow_attach(TELNETasp_PT pt, my_BooleanList allow_attach_list)
990{
Neels Hofmeyr8f576712020-08-12 22:49:53 +0000991 var charstring config := f_vty_transceive_ret(pt, "show running-config");
992
Neels Hofmeyra460f1f2020-08-09 20:17:03 +0000993 for (var integer msc_nr := 0; msc_nr < sizeof(allow_attach_list); msc_nr := msc_nr+1) {
Neels Hofmeyr8f576712020-08-12 22:49:53 +0000994 if (f_strstr(config, "\nmsc " & int2str(msc_nr) & "\n") < 0) {
995 /* There is no 'msc N' for this msc_nr in the running config, so don't create an empty msc by
996 * stepping into that config node. */
997 log("msc ", msc_nr, " is not configured, skipping");
998 continue;
999 }
Neels Hofmeyra460f1f2020-08-09 20:17:03 +00001000 f_vty_enter_cfg_msc(pt, msc_nr);
1001 if (allow_attach_list[msc_nr]) {
1002 /* strict := false: ignore if osmo-bsc does not support this config option (latest build) */
1003 f_vty_transceive(pt, "allow-attach", strict := false);
1004 } else {
1005 f_vty_transceive(pt, "no allow-attach", strict := false);
1006 }
1007 f_vty_transceive(pt, "exit");
1008 f_vty_transceive(pt, "exit");
1009 }
1010}
1011
Harald Welte21b46bd2017-12-17 19:46:32 +01001012/* global initialization function
1013 * \param nr_bts Number of BTSs we should start/bring up
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001014 * \param handler_mode Start an RSL_Emulation_CT component (true) or not (false).
1015 * \param nr_msc Number of virtual MSCs to bring up to connect to osmo-bsc.
1016 */
1017function f_init(integer nr_bts := NUM_BTS, boolean handler_mode := false, boolean allow_osmux := false,
Neels Hofmeyr4fbad7f2020-06-16 00:30:47 +02001018 integer nr_msc := 1, float guard_timeout := 30.0) runs on test_CT {
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001019 var integer bssap_idx;
Harald Welte28d943e2017-11-25 15:00:50 +01001020
Harald Welteae026692017-12-09 01:03:01 +01001021 if (g_initialized) {
1022 return;
Harald Welte28d943e2017-11-25 15:00:50 +01001023 }
Harald Welteae026692017-12-09 01:03:01 +01001024 g_initialized := true;
1025
Neels Hofmeyr4fbad7f2020-06-16 00:30:47 +02001026 T_guard.start(guard_timeout);
Daniel Willmanne68f9272018-11-27 15:15:28 +01001027 activate(as_Tguard());
1028
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02001029 f_init_vty("VirtMSC");
Pau Espin Pedrol58cf6822019-05-28 18:11:33 +02001030 if (mp_enable_osmux_test) {
1031 f_vty_allow_osmux(allow_osmux);
1032 }
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02001033
Neels Hofmeyra460f1f2020-08-09 20:17:03 +00001034 var my_BooleanList allow_attach := { false, false, false };
Daniel Willmannebdecc02020-08-12 15:30:17 +02001035 f_init_statsd("VirtMSC", vc_STATSD, mp_test_ip, mp_bsc_statsd_port);
1036
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001037 for (bssap_idx := 0; bssap_idx < nr_msc; bssap_idx := bssap_idx+1) {
Neels Hofmeyra460f1f2020-08-09 20:17:03 +00001038 allow_attach[bssap_idx] := true;
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001039 /* Call a function of our 'parent component' RAN_Adapter_CT to start the
1040 * MSC-side BSSAP emulation */
1041 if (handler_mode) {
1042 var RanOps ranops := MSC_RanOps;
1043 ranops.use_osmux := g_osmux_enabled;
1044 f_ran_adapter_init(g_bssap[bssap_idx], mp_bssap_cfg[bssap_idx], "VirtMSC", ranops);
1045 connect(self:SCCPLITE_IPA_CTRL, g_bssap[bssap_idx].vc_RAN:CTRL_CLIENT);
1046 f_ran_adapter_start(g_bssap[bssap_idx]);
1047 } else {
1048 f_ran_adapter_init(g_bssap[bssap_idx], mp_bssap_cfg[bssap_idx], "VirtMSC", omit);
1049 connect(self:BSSAP, g_bssap[bssap_idx].vc_SCCP:SCCP_SP_PORT);
1050 f_ran_adapter_start(g_bssap[bssap_idx]);
1051 f_legacy_bssap_reset();
1052 }
Harald Welte67089ee2018-01-17 22:19:03 +01001053 }
Harald Welted5833a82018-05-27 16:52:56 +02001054
Neels Hofmeyra460f1f2020-08-09 20:17:03 +00001055 /* start the test with exactly all enabled MSCs allowed to attach */
1056 f_vty_msc_allow_attach(BSCVTY, allow_attach);
1057
Harald Welteffe55fc2018-01-17 22:39:54 +01001058 f_ipa_ctrl_start(mp_bsc_ip, mp_bsc_ctrl_port);
Harald Welte28d943e2017-11-25 15:00:50 +01001059
Daniel Willmann191e0d92018-01-17 12:44:35 +01001060 f_init_mgcp("VirtMSC");
1061
Neels Hofmeyr0b7365b2020-07-04 00:52:34 +02001062 for (var integer i := 0; i < nr_bts; i := i+1) {
1063 f_init_bts(i, handler_mode);
Harald Welte696ddb62017-12-08 14:01:43 +01001064 }
Neels Hofmeyr0b7365b2020-07-04 00:52:34 +02001065}
Harald Welte696ddb62017-12-08 14:01:43 +01001066
Neels Hofmeyr0b7365b2020-07-04 00:52:34 +02001067function f_init_bts(integer bts_idx := 0, boolean handler_mode := false)
1068runs on test_CT {
1069 /* wait until osmo-bts-omldummy has respawned */
1070 f_wait_oml(bts_idx, "degraded", 5.0);
1071
1072 /* start RSL connection */
1073 f_ipa_rsl_start(bts[bts_idx].rsl, mp_bsc_ip, mp_bsc_rsl_port, bts_idx, handler_mode);
1074 /* wait until BSC tells us "connected" */
1075 f_wait_oml(bts_idx, "connected", 5.0);
Harald Welte28d943e2017-11-25 15:00:50 +01001076}
1077
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +02001078function f_init_bts_and_check_sysinfo(integer bts_idx := 0, boolean handler_mode := false,
1079 template SystemInformationConfig expect_si)
1080runs on test_CT {
1081 var default sysinfo := activate(as_catch_RSL_sysinfo(bts_idx));
1082
1083 f_init_bts(bts_idx, handler_mode);
1084
1085 /* Give some time to (hopefully/most likely) collect all system informations from RSL startup.
1086 * We could stop as soon as all expected SI are received, but then we might miss SI that we don't expect and
1087 * that might be sent afterwards. So rather give a generous timeout and be quite sure to catch all SI.
1088 */
1089 f_sleep(5.0);
1090 log("RSL ", bts_idx, " SYSTEM INFORMATION: ", g_system_information[bts_idx]);
1091
1092 deactivate(sysinfo);
1093
1094 if (match(g_system_information[bts_idx], expect_si)) {
1095 setverdict(pass);
1096 } else {
1097 log("RSL ", bts_idx, ": EXPECTED SI: ", expect_si);
1098 log("RSL ", bts_idx, ": GOT SI: ", g_system_information[bts_idx]);
1099 setverdict(fail, "received SI does not match expectations");
1100 return;
1101 }
1102}
1103
Maxd4e56962018-10-31 19:08:25 +01001104/* expect to receive a RSL message matching a specified template on a given BTS / stream */
Harald Welte65e419a2020-08-21 12:38:33 +02001105function 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 +01001106runs on test_CT return RSL_Message {
1107 var ASP_RSL_Unitdata rx_rsl_ud;
1108 timer T := t_secs;
1109
1110 T.start;
1111 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001112 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(t_rx, sid)) -> value rx_rsl_ud {
Harald Welteae026692017-12-09 01:03:01 +01001113 T.stop;
1114 }
1115 [] IPA_RSL[bts_nr].receive { repeat; }
Harald Welteb2917702017-12-10 15:48:52 +01001116 [] T.timeout {
1117 setverdict(fail, "Timeout expecting ", t_rx);
Daniel Willmannafce8662018-07-06 23:11:32 +02001118 mtc.stop;
Harald Welteb2917702017-12-10 15:48:52 +01001119 }
Harald Welteae026692017-12-09 01:03:01 +01001120 }
1121 return rx_rsl_ud.rsl;
1122}
1123
Harald Welte21b46bd2017-12-17 19:46:32 +01001124/* helper function to transmit RSL on a given BTS/stream */
Harald Welte65e419a2020-08-21 12:38:33 +02001125function 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 +01001126runs on test_CT {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001127 IPA_RSL[bts_nr].send(ts_ASP_RSL_UD(t_tx, sid));
Harald Welteae026692017-12-09 01:03:01 +01001128}
1129
1130
Harald Welte4003d112017-12-09 22:35:39 +01001131/* verify we get a CHAN_ACT after CHAN RQD */
Harald Welteae026692017-12-09 01:03:01 +01001132testcase TC_chan_act_noreply() runs on test_CT {
1133 var BSSAP_N_UNITDATA_ind ud_ind;
Harald Welte930d0a72018-03-22 22:08:40 +01001134 var RSL_Message rsl_unused;
Harald Welte28d943e2017-11-25 15:00:50 +01001135
Harald Welte89d42e82017-12-17 16:42:41 +01001136 f_init(1);
Harald Welte28d943e2017-11-25 15:00:50 +01001137
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001138 IPA_RSL[0].send(ts_ASP_RSL_UD(ts_RSL_CHAN_RQD('23'O, 23)));
Harald Welte930d0a72018-03-22 22:08:40 +01001139 rsl_unused := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
Harald Welteae026692017-12-09 01:03:01 +01001140 setverdict(pass);
Harald Welte28d943e2017-11-25 15:00:50 +01001141}
1142
Harald Welte4003d112017-12-09 22:35:39 +01001143/* verify if the "chreq:total" counter increments as expected */
1144testcase TC_chan_act_counter() runs on test_CT {
1145 var BSSAP_N_UNITDATA_ind ud_ind;
1146 var integer chreq_total;
Harald Welte930d0a72018-03-22 22:08:40 +01001147 var RSL_Message rsl_unused;
Harald Welte4003d112017-12-09 22:35:39 +01001148
Harald Welte89d42e82017-12-17 16:42:41 +01001149 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +01001150
1151 chreq_total := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total");
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001152 IPA_RSL[0].send(ts_ASP_RSL_UD(ts_RSL_CHAN_RQD('23'O, 23)));
Harald Welte930d0a72018-03-22 22:08:40 +01001153 rsl_unused := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
Harald Welte4003d112017-12-09 22:35:39 +01001154 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total", chreq_total+1);
1155
1156 setverdict(pass);
1157}
1158
Harald Welteae026692017-12-09 01:03:01 +01001159/* CHAN RQD -> CHAN ACT -> CHAN ACT ACK -> RF CHAN REL */
Philipp Maier9c60a622020-07-09 15:08:46 +02001160private function f_TC_chan_act_ack_noest(OCT1 ra := '23'O) runs on test_CT {
Harald Welteae026692017-12-09 01:03:01 +01001161 var RSL_Message rx_rsl;
1162
Harald Welteae026692017-12-09 01:03:01 +01001163 /* Send CHAN RQD and wait for allocation; acknowledge it */
Philipp Maier9c60a622020-07-09 15:08:46 +02001164 var RslChannelNr chan_nr := f_chreq_act_ack(ra);
Harald Welteae026692017-12-09 01:03:01 +01001165
1166 /* expect BSC to disable the channel again if there's no RLL EST IND */
1167 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), T3101_MAX);
1168
1169 setverdict(pass);
1170}
1171
Philipp Maier9c60a622020-07-09 15:08:46 +02001172/* Normal variant */
1173testcase TC_chan_act_ack_noest() runs on test_CT {
Philipp Maieraf58db22020-08-12 17:24:40 +02001174 f_init(1);
Philipp Maier9c60a622020-07-09 15:08:46 +02001175 f_TC_chan_act_ack_noest();
1176}
1177
1178/* Emergency call variant */
1179testcase TC_chan_act_ack_noest_emerg() runs on test_CT {
1180 /* See also: 3GPP TS 04.08, Table 9.9, ra=101xxxxx */
Philipp Maieraf58db22020-08-12 17:24:40 +02001181 f_init(1);
1182 f_vty_allow_emerg_bts(true, 0);
Philipp Maier9c60a622020-07-09 15:08:46 +02001183 f_TC_chan_act_ack_noest(ra := 'A5'O);
1184}
1185
Philipp Maier606f07d2020-08-12 17:21:58 +02001186/* Emergency call variant, but emergency calls are not allowed */
1187testcase TC_chan_rqd_emerg_deny() runs on test_CT {
1188 /* See also: 3GPP TS 04.08, Table 9.9, ra=101xxxxx */
1189
1190 var RSL_Message rx_rsl;
1191 var GsmRrMessage rr;
1192
1193 f_init(1);
1194 f_vty_allow_emerg_bts(false, 0);
1195
1196 IPA_RSL[0].clear;
1197 f_ipa_tx(0, ts_RSL_CHAN_RQD('A5'O, 23));
1198
1199 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeC(RSL_MT_IMMEDIATE_ASSIGN_CMD));
1200 rr := dec_GsmRrMessage(rx_rsl.ies[1].body.full_imm_ass_info.payload);
1201 if (rr.header.message_type == IMMEDIATE_ASSIGNMENT_REJECT) {
1202 setverdict(pass);
1203 } else {
1204 setverdict(fail, "immediate assignment not rejected");
1205 }
1206}
1207
Harald Welteae026692017-12-09 01:03:01 +01001208/* Test behavior if MSC never answers to CR */
1209testcase TC_chan_act_ack_est_ind_noreply() runs on test_CT {
Harald Weltef77aef62018-01-28 15:35:42 +01001210 var RslLinkId main_dcch := valueof(ts_RslLinkID_DCCH(0));
1211 var IpaStreamId sid := IPAC_PROTO_RSL_TRX0;
Harald Welteae026692017-12-09 01:03:01 +01001212 var RSL_Message rx_rsl;
Harald Weltef77aef62018-01-28 15:35:42 +01001213 var ASP_RSL_Unitdata rx_rsl_ud;
Harald Welteae026692017-12-09 01:03:01 +01001214
Harald Welte89d42e82017-12-17 16:42:41 +01001215 f_init(1);
Harald Welteae026692017-12-09 01:03:01 +01001216
1217 /* Send CHAN RQD and wait for allocation; acknowledge it */
Harald Welted6939652017-12-13 21:02:46 +01001218 var RslChannelNr chan_nr := f_chreq_act_ack();
Harald Welteae026692017-12-09 01:03:01 +01001219
1220 var octetstring l3 := '00010203040506'O
1221 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
1222
1223 BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3)));
1224
1225 /* expect BSC to disable the channel again if there's no response from MSC */
Harald Weltef77aef62018-01-28 15:35:42 +01001226 /* MS waits 20s (T3210) at LU; 10s (T3230) at CM SERV REQ and 5s (T3220) AT detach */
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001227 f_expect_chan_rel(0, chan_nr, expect_rll_rel_req := false);
Harald Welteae026692017-12-09 01:03:01 +01001228 setverdict(pass);
1229}
1230
1231/* Test behavior if MSC answers with CREF to CR */
1232testcase TC_chan_act_ack_est_ind_refused() runs on test_CT {
1233 var BSSAP_N_CONNECT_ind rx_c_ind;
1234 var RSL_Message rx_rsl;
1235
Harald Welte89d42e82017-12-17 16:42:41 +01001236 f_init(1);
Harald Welteae026692017-12-09 01:03:01 +01001237
1238 /* Send CHAN RQD and wait for allocation; acknowledge it */
Harald Welted6939652017-12-13 21:02:46 +01001239 var RslChannelNr chan_nr := f_chreq_act_ack();
Harald Welteae026692017-12-09 01:03:01 +01001240
1241 var octetstring l3 := '00010203040506'O
1242 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
1243
1244 BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) -> value rx_c_ind;
1245 BSSAP.send(ts_BSSAP_DISC_req(rx_c_ind.connectionId, 0));
1246
1247 /* expect BSC to disable the channel */
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001248 f_expect_chan_rel(0, chan_nr, expect_rll_rel_req := false);
Harald Welteae026692017-12-09 01:03:01 +01001249 setverdict(pass);
1250}
1251
Harald Welte618ef642017-12-14 14:58:20 +01001252/* CHAN RQD -> CHAN ACT -> CHAN ACT NACK -> RF CHAN REL */
1253testcase TC_chan_act_nack() runs on test_CT {
1254 var RSL_Message rx_rsl;
1255 var integer chact_nack;
1256
Harald Welte89d42e82017-12-17 16:42:41 +01001257 f_init(1);
Harald Welte618ef642017-12-14 14:58:20 +01001258
1259 chact_nack := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chan_act:nack");
1260
1261 f_ipa_tx(0, ts_RSL_CHAN_RQD('33'O, 33));
1262 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
1263 var RslChannelNr chan_nr := rx_rsl.ies[0].body.chan_nr;
1264
1265 f_ipa_tx(0, ts_RSL_CHAN_ACT_NACK(chan_nr, RSL_ERR_EQUIPMENT_FAIL));
1266
1267 /* wait for some time to hope the NACK arrives before the CTRL GET below */
1268 f_sleep(0.5);
1269
1270 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chan_act:nack", chact_nack+1);
1271
1272 setverdict(pass);
1273}
1274
Harald Welte799c97b2017-12-14 17:50:30 +01001275/* Test for channel exhaustion due to RACH overload */
1276testcase TC_chan_exhaustion() runs on test_CT {
1277 var ASP_RSL_Unitdata rsl_ud;
1278 var integer i;
1279 var integer chreq_total, chreq_nochan;
1280
Harald Welte89d42e82017-12-17 16:42:41 +01001281 f_init(1);
Harald Welte799c97b2017-12-14 17:50:30 +01001282
1283 chreq_total := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total");
1284 chreq_nochan := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:no_channel");
1285
Pau Espin Pedrolfe200d72018-12-10 12:41:04 +01001286 /* GSM 04.08 Table 9.9a:
1287 * RA = '33'O -> Establishment cause = 0011xxxx (MS dual rate capable and asks for "TCH/H or TCH/F").
1288 * With current setup, expect 4xSDCCH + 4xTCH/F + 1xTCH/H to succeed */
Philipp Maiercb6cc482018-03-26 13:08:00 +02001289 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 +01001290 var RslChannelNr chan_nr := f_chreq_act_ack('33'O, i);
Harald Welte799c97b2017-12-14 17:50:30 +01001291 }
1292
1293 IPA_RSL[0].clear;
1294
Harald Weltedd8cbf32018-01-28 12:07:52 +01001295 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total",
Philipp Maiercb6cc482018-03-26 13:08:00 +02001296 chreq_total + NUM_TCHF_PER_BTS + NUM_TCHH_PER_BTS + NUM_SDCCH_PER_BTS);
Harald Welte799c97b2017-12-14 17:50:30 +01001297
1298 /* now expect additional channel activations to fail */
1299 f_ipa_tx(0, ts_RSL_CHAN_RQD('42'O, 42));
1300
1301 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001302 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV))) {
Harald Welte799c97b2017-12-14 17:50:30 +01001303 setverdict(fail, "Received CHAN ACT ACK without resources?!?");
1304 }
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001305 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_IMM_ASSIGN(?))) -> value rsl_ud {
Harald Welte799c97b2017-12-14 17:50:30 +01001306 var GsmRrMessage rr;
1307 /* match on IMM ASS REJ */
1308 rr := dec_GsmRrMessage(rsl_ud.rsl.ies[1].body.full_imm_ass_info.payload);
1309 if (rr.header.message_type == IMMEDIATE_ASSIGNMENT_REJECT) {
1310 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total",
Philipp Maiercb6cc482018-03-26 13:08:00 +02001311 chreq_total + NUM_TCHF_PER_BTS + NUM_TCHH_PER_BTS + NUM_SDCCH_PER_BTS+1);
Harald Welte799c97b2017-12-14 17:50:30 +01001312 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:no_channel",
1313 chreq_nochan+1);
1314 setverdict(pass);
1315 } else {
1316 repeat;
1317 }
1318 }
1319 [] IPA_RSL[0].receive { repeat; }
1320 }
1321}
1322
Vadim Yanitskiy1ff1fdf2018-11-27 01:32:57 +07001323/* Test channel deactivation due to silence from MS */
1324testcase TC_chan_deact_silence() runs on test_CT {
1325 var RslChannelNr chan_nr;
1326
1327 f_init(1);
1328
1329 /* Request for a dedicated channel */
1330 chan_nr := f_chreq_act_ack('23'O);
1331
1332 /* Wait some time until the channel is released */
1333 f_sleep(2.0);
1334
1335 /* Expect CHANnel RELease */
1336 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001337 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL))) {
Vadim Yanitskiy1ff1fdf2018-11-27 01:32:57 +07001338 log("Received CHANnel RELease");
1339 setverdict(pass);
1340 }
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001341 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_IMM_ASSIGN(?))) {
Vadim Yanitskiy1ff1fdf2018-11-27 01:32:57 +07001342 /* See OS#3709, OsmoBSC should not send Immediate
1343 * Assignment Reject since a dedicated channel was
1344 * already allocated, and Immediate Assignment was
1345 * already sent. */
1346 setverdict(fail, "Unexpected Immediate Assignment!");
1347 }
1348 [] IPA_RSL[0].receive {
1349 setverdict(fail, "Unexpected RSL message!");
1350 }
1351 }
1352}
1353
Harald Weltecfe2c962017-12-15 12:09:32 +01001354/***********************************************************************
1355 * Assignment Testing
1356 ***********************************************************************/
1357
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02001358/* Verify that the BSC refuses any BSSAP connection from the MSC (They are all BSC->MSC direction,
1359 * except for the inter-BSC handover, MT side) */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001360testcase TC_outbound_connect(integer bssap_idx := 0) runs on test_CT {
Harald Welte89d42e82017-12-17 16:42:41 +01001361 f_init(1);
Harald Weltecfe2c962017-12-15 12:09:32 +01001362
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001363 BSSAP.send(ts_BSSAP_CONNECT_req(g_bssap[bssap_idx].sccp_addr_peer, g_bssap[bssap_idx].sccp_addr_own,
1364 2342, ts_BSSMAP_AssignmentReq));
Harald Weltecfe2c962017-12-15 12:09:32 +01001365 BSSAP.receive(tr_BSSAP_DISC_ind(2342, ?, ?));
1366 setverdict(pass);
1367}
1368
Harald Welte16a4adf2017-12-14 18:54:01 +01001369/* Test behavior if MSC answers with CREF to CR */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001370testcase TC_assignment_cic_only(integer bssap_idx := 0) runs on test_CT {
Harald Welte16a4adf2017-12-14 18:54:01 +01001371 var BSSAP_N_CONNECT_ind rx_c_ind;
1372 var RSL_Message rx_rsl;
1373 var DchanTuple dt;
1374
Harald Welte89d42e82017-12-17 16:42:41 +01001375 f_init(1);
Harald Welte16a4adf2017-12-14 18:54:01 +01001376
1377 dt := f_est_dchan('23'O, 23, '00000000'O);
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001378 if (mp_bssap_cfg[bssap_idx].transport == BSSAP_TRANSPORT_AoIP) {
Harald Welte17b27da2018-05-25 20:33:53 +02001379 /* send assignment without AoIP IEs */
1380 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_AssignmentReq(ts_BSSMAP_IE_CIC(0, 1))));
1381 } else {
1382 /* Send assignmetn without CIC in IPA case */
1383 var BSSMAP_IE_AoIP_TransportLayerAddress tla :=
1384 valueof(ts_BSSMAP_IE_AoIP_TLA4('01020304'O, 2342));
1385 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_AssignmentReq(omit, tla)));
1386 }
Harald Welte16a4adf2017-12-14 18:54:01 +01001387 alt {
1388 [] BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_AssignmentComplete)) {
1389 setverdict(fail, "AoIP BSC cannot accept ASSIGNMENT without AoIP Transport IE");
1390 }
Harald Welte235ebf12017-12-15 14:18:16 +01001391 /* TODO: Actually expect GSM0808_CAUSE_REQ_A_IF_TYPE_NOT_SUPP */
Harald Welte16a4adf2017-12-14 18:54:01 +01001392 [] BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_AssignmentFail)) {
1393 setverdict(pass);
1394 }
1395 [] BSSAP.receive { repeat; }
1396 }
1397}
1398
Harald Welteed848512018-05-24 22:27:58 +02001399/* generate an assignment request for either AoIP or SCCPlite */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001400function f_gen_ass_req(boolean osmux_enabled := false, integer bssap_idx := 0) return PDU_BSSAP {
Harald Welteed848512018-05-24 22:27:58 +02001401 var PDU_BSSAP ass_cmd;
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02001402 var BSSMAP_IE_Osmo_OsmuxCID osmux_cid := valueof(ts_OsmuxCID(0));
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001403 if (mp_bssap_cfg[bssap_idx].transport == BSSAP_TRANSPORT_AoIP) {
Harald Welteed848512018-05-24 22:27:58 +02001404 var BSSMAP_IE_AoIP_TransportLayerAddress tla :=
1405 valueof(ts_BSSMAP_IE_AoIP_TLA4('01020304'O, 2342));
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02001406 if (osmux_enabled) {
1407 ass_cmd := valueof(ts_BSSMAP_AssignmentReq(omit, tla, osmux_cid));
1408 } else {
1409 ass_cmd := valueof(ts_BSSMAP_AssignmentReq(omit, tla));
1410 }
Harald Welteed848512018-05-24 22:27:58 +02001411 } else {
1412 var BSSMAP_IE_CircuitIdentityCode cic := valueof(ts_BSSMAP_IE_CIC(0,1));
Pau Espin Pedrol096d73d2019-06-06 12:49:17 +02001413 ass_cmd := valueof(ts_BSSMAP_AssignmentReq(cic, omit));
Harald Welteed848512018-05-24 22:27:58 +02001414 }
1415 return ass_cmd;
1416}
1417
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001418function f_gen_handover_req(integer bssap_idx := 0) return PDU_BSSAP {
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01001419 var PDU_BSSAP ho_req;
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001420 if (mp_bssap_cfg[bssap_idx].transport == BSSAP_TRANSPORT_AoIP) {
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01001421 var BSSMAP_IE_AoIP_TransportLayerAddress tla :=
1422 valueof(ts_BSSMAP_IE_AoIP_TLA4('01020304'O, 2342));
1423 ho_req := valueof(ts_BSSMAP_HandoverRequest(omit, tla));
1424 } else {
1425 var BSSMAP_IE_CircuitIdentityCode cic := valueof(ts_BSSMAP_IE_CIC(0,1));
1426 ho_req := valueof(ts_BSSMAP_HandoverRequest(cic, omit));
1427 }
1428 return ho_req;
1429}
1430
Harald Welteed848512018-05-24 22:27:58 +02001431/* generate an assignment complete template for either AoIP or SCCPlite */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001432function f_gen_exp_compl(boolean expect_osmux := false, integer bssap_idx := 0) return template PDU_BSSAP {
Harald Welteed848512018-05-24 22:27:58 +02001433 var template PDU_BSSAP exp_compl;
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02001434 var BSSMAP_IE_Osmo_OsmuxCID osmux_cid := valueof(ts_OsmuxCID(0));
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001435 if (mp_bssap_cfg[bssap_idx].transport == BSSAP_TRANSPORT_AoIP) {
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02001436 if (expect_osmux) {
1437 exp_compl := tr_BSSMAP_AssignmentComplete(omit, ?, osmux_cid);
1438 } else {
1439 exp_compl := tr_BSSMAP_AssignmentComplete(omit, ?, omit);
1440 }
Harald Welteed848512018-05-24 22:27:58 +02001441 } else {
1442 /* CIC is optional "*" as the MSC allocated it */
Pau Espin Pedrol096d73d2019-06-06 12:49:17 +02001443 exp_compl := tr_BSSMAP_AssignmentComplete(*, omit);
Harald Welteed848512018-05-24 22:27:58 +02001444 }
1445 return exp_compl;
1446}
1447
Harald Welte235ebf12017-12-15 14:18:16 +01001448/* Run everything required up to sending a caller-specified assignment command and expect response */
1449function f_assignment_exp(PDU_BSSAP ass_cmd, template PDU_BSSAP exp, charstring fail_text)
1450runs on test_CT {
1451 var BSSAP_N_CONNECT_ind rx_c_ind;
1452 var RSL_Message rx_rsl;
1453 var DchanTuple dt;
1454
Harald Welte89d42e82017-12-17 16:42:41 +01001455 f_init(1);
Harald Welte235ebf12017-12-15 14:18:16 +01001456
1457 dt := f_est_dchan('23'O, 23, '00000000'O);
1458 /* send assignment without AoIP IEs */
1459 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ass_cmd));
1460 alt {
1461 [] BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_AssignmentComplete)) {
1462 if (ischosen(exp.pdu.bssmap.assignmentComplete)) {
1463 setverdict(pass);
1464 } else {
1465 setverdict(fail, fail_text);
1466 }
1467 }
1468 [] BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_AssignmentFail)) {
1469 if (ischosen(exp.pdu.bssmap.assignmentFailure)) {
1470 setverdict(pass);
1471 } else {
1472 setverdict(fail, fail_text);
1473 }
1474 }
1475 [] BSSAP.receive { repeat; }
1476 }
1477}
1478testcase TC_assignment_csd() runs on test_CT {
1479 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
Harald Welteed848512018-05-24 22:27:58 +02001480 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte235ebf12017-12-15 14:18:16 +01001481 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeCSD);
1482 //exp_fail.pdu.bssmap.assignmentFailure.cause.causeValue := int2bit(enum2int(GSM0808_CAUSE_REQ_CODEC_TYPE_OR_CONFIG_UNAVAIL), 7);
1483 f_assignment_exp(ass_cmd, exp_fail, "BSC accepted Assignment for CSD");
1484}
1485
1486testcase TC_assignment_ctm() runs on test_CT {
1487 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
Harald Welteed848512018-05-24 22:27:58 +02001488 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte235ebf12017-12-15 14:18:16 +01001489 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeCTM);
1490 //exp_fail.pdu.bssmap.assignmentFailure.cause.causeValue := int2bit(enum2int(GSM0808_CAUSE_REQ_CODEC_TYPE_OR_CONFIG_UNAVAIL), 7);
1491 f_assignment_exp(ass_cmd, exp_fail, "BSC accepted Assignment for Speech+CTM");
1492}
1493
Harald Welte4003d112017-12-09 22:35:39 +01001494type record DchanTuple {
1495 integer sccp_conn_id,
1496 RslChannelNr rsl_chan_nr
Harald Weltea5d2ab22017-12-09 14:21:42 +01001497}
1498
Harald Welted6939652017-12-13 21:02:46 +01001499/* Send CHAN RQD and wait for allocation; acknowledge it */
1500private function f_chreq_act_ack(OCT1 ra := '23'O, GsmFrameNumber fn := 23)
1501runs on test_CT return RslChannelNr {
1502 var RSL_Message rx_rsl;
1503 f_ipa_tx(0, ts_RSL_CHAN_RQD(ra, fn));
1504 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
1505 var RslChannelNr chan_nr := rx_rsl.ies[0].body.chan_nr;
1506 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, fn+10));
Daniel Willmannf4ac4ce2018-08-02 14:06:30 +02001507 rx_rsl := f_exp_ipa_rx(0, tr_RSL_IMM_ASSIGN(0));
Harald Welted6939652017-12-13 21:02:46 +01001508 return chan_nr;
1509}
1510
Harald Welte4003d112017-12-09 22:35:39 +01001511/* helper function to establish a dedicated channel via BTS and MSC */
1512function f_est_dchan(OCT1 ra, GsmFrameNumber fn, octetstring l3)
1513runs on test_CT return DchanTuple {
1514 var BSSAP_N_CONNECT_ind rx_c_ind;
Harald Welte4003d112017-12-09 22:35:39 +01001515 var DchanTuple dt;
Harald Weltea5d2ab22017-12-09 14:21:42 +01001516
Harald Welte4003d112017-12-09 22:35:39 +01001517 /* Send CHAN RQD and wait for allocation; acknowledge it */
Harald Welted6939652017-12-13 21:02:46 +01001518 dt.rsl_chan_nr := f_chreq_act_ack(ra, fn);
Harald Welte4003d112017-12-09 22:35:39 +01001519
1520 f_ipa_tx(0, ts_RSL_EST_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
1521
1522 BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) -> value rx_c_ind;
1523 dt.sccp_conn_id := rx_c_ind.connectionId;
1524 BSSAP.send(ts_BSSAP_CONNECT_res(dt.sccp_conn_id));
1525
1526 return dt;
Harald Weltea5d2ab22017-12-09 14:21:42 +01001527}
1528
Harald Welte641fcbe2018-06-14 10:58:35 +02001529/* expect RF CAN REL from BTS, acknowledge it and clear the MSC side */
1530private function f_exp_chan_rel_and_clear(DchanTuple dt, integer bts_nr := 0) runs on test_CT {
1531 var RSL_Message rx_rsl;
1532 /* expect BSC to disable the channel */
1533 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), T3101_MAX);
1534 /* respond with CHAN REL ACK */
1535 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(dt.rsl_chan_nr));
1536
1537 /* expect Clear Complete from BSC */
1538 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete));
1539
1540 /* MSC disconnects as instructed. */
1541 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
1542}
1543
Harald Welte4003d112017-12-09 22:35:39 +01001544/* Test behavior of channel release after unilateral RLL REL IND (DISC from MS) */
1545testcase TC_chan_rel_rll_rel_ind() runs on test_CT {
Neels Hofmeyr27f64362018-03-12 01:44:00 +01001546 var BSSAP_N_DATA_ind rx_di;
Harald Welte4003d112017-12-09 22:35:39 +01001547 var DchanTuple dt;
Harald Welte96c94412017-12-09 03:12:45 +01001548
Harald Welte89d42e82017-12-17 16:42:41 +01001549 f_init(1);
Harald Welte96c94412017-12-09 03:12:45 +01001550
Harald Welte4003d112017-12-09 22:35:39 +01001551 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1552
1553 /* simulate RLL REL IND */
1554 f_ipa_tx(0, ts_RSL_REL_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0))));
1555
Neels Hofmeyr27f64362018-03-12 01:44:00 +01001556 /* expect Clear Request on MSC side */
1557 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearRequest)) -> value rx_di;
1558
1559 /* Instruct BSC to clear channel */
1560 var BssmapCause cause := bit2int(rx_di.userData.pdu.bssmap.clearRequest.cause.causeValue);
1561 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
1562
Harald Welte4003d112017-12-09 22:35:39 +01001563 /* expect BSC to disable the channel */
Harald Welte641fcbe2018-06-14 10:58:35 +02001564 f_exp_chan_rel_and_clear(dt, 0);
Neels Hofmeyr27f64362018-03-12 01:44:00 +01001565
1566 /* wait for SCCP emulation to do its job */
1567 f_sleep(1.0);
Harald Welte4003d112017-12-09 22:35:39 +01001568
1569 setverdict(pass);
1570}
1571
1572/* Test behavior of channel release after CONN FAIL IND from BTS */
1573testcase TC_chan_rel_conn_fail() runs on test_CT {
1574 var BSSAP_N_DATA_ind rx_di;
Harald Welte4003d112017-12-09 22:35:39 +01001575 var DchanTuple dt;
1576
Harald Welte89d42e82017-12-17 16:42:41 +01001577 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +01001578
1579 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1580
1581 /* simulate CONN FAIL IND */
Harald Weltea8ed9062017-12-14 09:46:01 +01001582 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 +01001583 /* TODO: different cause values? */
1584
Harald Welte4003d112017-12-09 22:35:39 +01001585 /* expect Clear Request from BSC */
1586 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearRequest)) -> value rx_di;
1587
1588 /* Instruct BSC to clear channel */
1589 var BssmapCause cause := bit2int(rx_di.userData.pdu.bssmap.clearRequest.cause.causeValue);
1590 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
1591
Harald Welte6ff76ea2018-01-28 13:08:01 +01001592 /* expect BSC to disable the channel */
Harald Welte641fcbe2018-06-14 10:58:35 +02001593 f_exp_chan_rel_and_clear(dt, 0);
Harald Welte4003d112017-12-09 22:35:39 +01001594
1595 /* wait for SCCP emulation to do its job */
1596 f_sleep(1.0);
1597
1598 setverdict(pass);
1599}
1600
Harald Welte99f3ca02018-06-14 13:40:29 +02001601/* Test behavior of early CONN FAIL IND from BTS (before EST IND!) */
1602/* See also https://www.osmocom.org/issues/3182 */
1603testcase TC_early_conn_fail() runs on test_CT {
1604 var RSL_Message rx_rsl;
1605 var DchanTuple dt;
1606
1607 f_init(1);
1608
1609 /* BTS->BSC: Send CHAN RQD and wait for allocation; acknowledge it */
1610 dt.rsl_chan_nr := f_chreq_act_ack(f_rnd_octstring(1), 23);
1611
1612 /* BTS->BSC: simulate CONN FAIL IND */
1613 f_ipa_tx(0, ts_RSL_CONN_FAIL_IND(dt.rsl_chan_nr, RSL_ERR_RADIO_LINK_FAIL));
1614
1615 /* BTS->BSC: Expect RF channel release from BSC on Abis */
1616 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), 10.0);
1617
1618 /* BTS<-BSC: respond with CHAN REL ACK */
1619 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(dt.rsl_chan_nr));
1620
1621 setverdict(pass);
1622}
1623
1624/* Test behavior of late CONN FAIL IND from BTS (ater REL IND!) */
1625/* See also https://www.osmocom.org/issues/3182 */
1626testcase TC_late_conn_fail() runs on test_CT {
1627 var RSL_Message rx_rsl;
1628 var DchanTuple dt;
1629
1630 f_init(1);
1631
1632 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1633
1634 /* BSC<-MSC: Instruct BSC to clear connection */
1635 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(0)));
1636
1637 /* BTS->BSC: expect BSC to deactivate SACCH */
1638 rx_rsl := f_exp_ipa_rx(0, tr_RSL_DEACT_SACCH(dt.rsl_chan_nr));
1639
1640 /* BTS->BSC: simulate a late CONN FAIL IND from BTS */
1641 f_ipa_tx(0, ts_RSL_CONN_FAIL_IND(dt.rsl_chan_nr, RSL_ERR_RADIO_LINK_FAIL));
1642
1643 /* BTS<-BSC: Expect RF channel release from BSC on Abis */
1644 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL), 10.0);
1645 /* BTS->BSC: respond with CHAN REL ACK */
1646 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(dt.rsl_chan_nr));
1647
1648 /* BSC->MSC: expect Clear Complete from BSC */
1649 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete));
1650
1651 /* BSC<-MSC: MSC disconnects as requested. */
1652 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
1653
1654 setverdict(pass);
1655}
1656
Neels Hofmeyrf44ccd12018-11-05 19:15:23 +01001657function f_expect_chan_rel(integer bts_nr, RslChannelNr rsl_chan_nr,
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001658 boolean expect_deact_sacch := true,
1659 boolean expect_rr_chan_rel := true,
1660 boolean expect_rll_rel_req := true,
Harald Welte99787102019-02-04 10:41:36 +01001661 boolean handle_rll_rel := true,
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02001662 boolean is_csfb := false,
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02001663 template CellSelIndValue csfb_expect_cells := omit,
1664 template RR_Cause expect_rr_cause := ?
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001665 ) runs on test_CT {
Harald Welte91d54a52018-01-28 15:35:07 +01001666
1667 var RslLinkId main_dcch := valueof(ts_RslLinkID_DCCH(0));
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001668 var boolean got_deact_sacch := false;
1669 var boolean got_rr_chan_rel := false;
1670 var boolean got_rll_rel_req := false;
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02001671 var ASP_RSL_Unitdata ud;
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02001672 var RSL_IE_Body l3_ie;
1673 var PDU_ML3_NW_MS l3;
1674 var RR_Cause got_cause;
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001675 log("f_expect_chan_rel() expecting: expect_deact_sacch=", expect_deact_sacch, " expect_rr_chan_rel=", expect_rr_chan_rel,
1676 " expect_rll_rel_req=", expect_rll_rel_req);
Harald Welte91d54a52018-01-28 15:35:07 +01001677 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001678 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(tr_RSL_DEACT_SACCH(rsl_chan_nr))) {
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001679 got_deact_sacch := true;
Harald Welte91d54a52018-01-28 15:35:07 +01001680 repeat;
1681 }
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02001682 [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 +01001683 got_rr_chan_rel := true;
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02001684
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02001685 if (f_rsl_find_ie(ud.rsl, RSL_IE_L3_INFO, l3_ie) == false) {
1686 setverdict(fail, "cannot find L3");
1687 mtc.stop;
1688 }
1689 l3 := dec_PDU_ML3_NW_MS(l3_ie.l3_info.payload);
1690
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02001691 if (not istemplatekind(csfb_expect_cells, "omit")) {
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02001692 var CellSelIndValue cells := dec_CellSelIndValue(
1693 l3.msgs.rrm.channelRelease.cellSelectionIndicator.cellSelectionIndicatorValue);
1694
1695 log("GOT RR CHANNEL RELEASE CSFB CELLS: ", cells);
1696 if (match(cells, csfb_expect_cells)) {
1697 setverdict(pass);
1698 } else {
1699 log("EXPECTED CSFB CELLS: ", csfb_expect_cells);
1700 setverdict(fail, "Received CSFB cells list on RR Channel Release does not match expectations");
1701 }
1702 }
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02001703
1704 if (not istemplatekind(expect_rr_cause, "omit")) {
1705 int2enum(oct2int(l3.msgs.rrm.channelRelease.rRCause.valuePart), got_cause);
1706 log("GOT CAUSE CODE: ", l3.msgs.rrm.channelRelease.rRCause.valuePart, " = ", got_cause);
1707 if (match(got_cause, expect_rr_cause)) {
1708 setverdict(pass);
1709 } else {
1710 log("EXPECTED CAUSE CODE: ", expect_rr_cause);
1711 setverdict(fail, "Received RR Channel Release Cause code does not match expectations");
1712 }
1713 }
Harald Welte99787102019-02-04 10:41:36 +01001714 repeat;
1715 }
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02001716 [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 +01001717 got_rr_chan_rel := true;
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02001718
1719 if (not istemplatekind(expect_rr_cause, "omit")) {
1720 if (f_rsl_find_ie(ud.rsl, RSL_IE_L3_INFO, l3_ie) == false) {
1721 setverdict(fail, "cannot find L3");
1722 mtc.stop;
1723 }
1724 l3 := dec_PDU_ML3_NW_MS(l3_ie.l3_info.payload);
1725
1726 int2enum(oct2int(l3.msgs.rrm.channelRelease.rRCause.valuePart), got_cause);
1727 log("GOT CAUSE CODE: ", l3.msgs.rrm.channelRelease.rRCause.valuePart, " = ", got_cause);
1728 if (match(got_cause, expect_rr_cause)) {
1729 setverdict(pass);
1730 } else {
1731 log("EXPECTED CAUSE CODE: ", expect_rr_cause);
1732 setverdict(fail, "Received RR Channel Release Cause code does not match expectations");
1733 }
1734 }
Neels Hofmeyr211169d2018-11-07 00:37:29 +01001735 repeat;
1736 }
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001737 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(tr_RSL_REL_REQ(rsl_chan_nr, ?))) {
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001738 got_rll_rel_req := true;
Harald Welte91d54a52018-01-28 15:35:07 +01001739 /* FIXME: Why are we getting this for LinkID SACCH? */
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001740 if (handle_rll_rel) {
1741 f_ipa_tx(0, ts_RSL_REL_CONF(rsl_chan_nr, main_dcch));
1742 }
Harald Welte91d54a52018-01-28 15:35:07 +01001743 repeat;
1744 }
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001745 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL))) {
Harald Welte91d54a52018-01-28 15:35:07 +01001746 /* respond with CHAN REL ACK */
1747 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(rsl_chan_nr));
1748 }
1749 /* ignore any user data */
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07001750 [] IPA_RSL[bts_nr].receive(tr_ASP_RSL_UD(tr_RSL_MsgTypeR(?))) {
Harald Welte91d54a52018-01-28 15:35:07 +01001751 repeat;
1752 }
1753 }
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001754
1755 log("f_expect_chan_rel() summary: got_deact_sacch=", got_deact_sacch, " got_rr_chan_rel=", got_rr_chan_rel,
1756 " got_rll_rel_req=", got_rll_rel_req);
1757
1758 if (expect_deact_sacch != got_deact_sacch) {
1759 setverdict(fail, "f_expect_chan_rel(): expect_deact_sacch=", expect_deact_sacch, " got_deact_sacch=", got_deact_sacch);
1760 }
1761 if (expect_rr_chan_rel != got_rr_chan_rel) {
1762 setverdict(fail, "f_expect_chan_rel(): expect_rr_chan_rel=", expect_rr_chan_rel, " got_rr_chan_rel=", got_rr_chan_rel);
1763 }
1764 if (expect_rll_rel_req != got_rll_rel_req) {
1765 setverdict(fail, "f_expect_chan_rel(): expect_rll_rel_req=", expect_rll_rel_req, " got_rll_rel_req=", got_rll_rel_req);
1766 }
Harald Welte91d54a52018-01-28 15:35:07 +01001767}
1768
Harald Welte4003d112017-12-09 22:35:39 +01001769/* Test behavior of channel release after hard Clear Command from MSC */
1770testcase TC_chan_rel_hard_clear() runs on test_CT {
1771 var BSSAP_N_DATA_ind rx_di;
Harald Welte4003d112017-12-09 22:35:39 +01001772 var DchanTuple dt;
Harald Welte4003d112017-12-09 22:35:39 +01001773
Harald Welte89d42e82017-12-17 16:42:41 +01001774 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +01001775
1776 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1777
1778 /* Instruct BSC to clear channel */
1779 var BssmapCause cause := 0;
1780 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
1781
1782 /* expect Clear Complete from BSC on A */
1783 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete)) {
1784 /* release the SCCP connection */
1785 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
1786 }
1787
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001788 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
Harald Welte4003d112017-12-09 22:35:39 +01001789 setverdict(pass);
1790}
1791
Harald Welte99787102019-02-04 10:41:36 +01001792/* Test behavior of channel release after Clear Command with CSFB indicator from MSC */
1793testcase TC_chan_rel_hard_clear_csfb() runs on test_CT {
1794 var BSSAP_N_DATA_ind rx_di;
1795 var DchanTuple dt;
1796
1797 f_init(1);
1798
1799 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1800
1801 /* Instruct BSC to clear channel */
1802 var BssmapCause cause := 0;
1803 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommandCSFB(cause)));
1804
1805 /* expect Clear Complete from BSC on A */
1806 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete)) {
1807 /* release the SCCP connection */
1808 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
1809 }
1810
1811 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false, is_csfb := true);
1812 setverdict(pass);
1813}
1814
Harald Welted8c36cd2017-12-09 23:05:31 +01001815/* Test behavior of channel release after hard RLSD from MSC */
1816testcase TC_chan_rel_hard_rlsd() runs on test_CT {
Harald Welted8c36cd2017-12-09 23:05:31 +01001817 var DchanTuple dt;
Harald Welted8c36cd2017-12-09 23:05:31 +01001818
Harald Welte89d42e82017-12-17 16:42:41 +01001819 f_init(1);
Harald Welted8c36cd2017-12-09 23:05:31 +01001820
1821 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1822
1823 /* release the SCCP connection */
1824 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
1825
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001826 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
Harald Welted8c36cd2017-12-09 23:05:31 +01001827 setverdict(pass);
1828}
1829
Harald Welte550daf92018-06-11 19:22:13 +02001830/* Test behavior of channel release after hard RLSD from MSC and MS is not responding to RLL REL REQ */
1831testcase TC_chan_rel_hard_rlsd_ms_dead() runs on test_CT {
1832 var DchanTuple dt;
1833
1834 f_init(1);
1835
1836 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1837
1838 /* release the SCCP connection */
1839 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
1840
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001841 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
Harald Welte550daf92018-06-11 19:22:13 +02001842 setverdict(pass);
1843}
1844
Harald Welte85804d42017-12-10 14:11:58 +01001845/* Test behavior of channel release after BSSMAP RESET from MSC */
1846testcase TC_chan_rel_a_reset() runs on test_CT {
Harald Welte85804d42017-12-10 14:11:58 +01001847 var DchanTuple dt;
Harald Welte85804d42017-12-10 14:11:58 +01001848
Harald Welte89d42e82017-12-17 16:42:41 +01001849 f_init(1);
Harald Welte85804d42017-12-10 14:11:58 +01001850
1851 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1852
1853 /* Clear the queue, it might still contain stuff like IMMEDIATE ASSIGN */
1854 IPA_RSL[0].clear;
1855
1856 /* perform BSSAP RESET, expect RESET ACK and DISC.ind on connection */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001857 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 +01001858 interleave {
Neels Hofmeyrf246a922020-05-13 02:27:10 +02001859 [] 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 +01001860 [] BSSAP.receive(tr_BSSAP_DISC_ind(dt.sccp_conn_id, ?, ?)) { }
1861 }
1862
Neels Hofmeyra5302c82018-11-04 23:09:58 +01001863 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
Harald Welte85804d42017-12-10 14:11:58 +01001864 setverdict(pass);
1865}
1866
Pau Espin Pedrolc675b612020-01-09 19:55:40 +01001867/* Verify T(iar) triggers and releases the channel */
1868testcase TC_chan_rel_sccp_tiar_timeout() runs on test_CT {
1869 var DchanTuple dt;
1870
1871 /* Set T(iar) in BSC low enough that it will trigger before other side
1872 has time to keep alive with a T(ias). Keep recommended ratio of
1873 T(iar) >= T(ias)*2 */
1874 g_bsc_sccp_timer_ias := 2;
1875 g_bsc_sccp_timer_iar := 5;
1876
1877 f_init(1);
1878
1879 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1880 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
1881 setverdict(pass);
1882}
1883
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02001884private function f_tc_chan_rel_rr_cause(myBSSMAP_Cause clear_cmd_cause, template RR_Cause expect_rr_cause)
1885runs on test_CT
1886{
1887 var DchanTuple dt;
1888
1889 dt := f_est_dchan('23'O, 23, '00010203040506'O);
1890 var BssmapCause cause := 0;
1891 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(enum2int(clear_cmd_cause))));
1892 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete)) {
1893 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
1894 }
1895
1896 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false, expect_rr_cause := expect_rr_cause);
1897 setverdict(pass);
1898}
1899
1900/* Test that Clear Command cause codes affect the RR Channel Release cause code */
1901testcase TC_chan_rel_rr_cause() runs on test_CT {
1902 f_init(1);
1903
1904 f_tc_chan_rel_rr_cause(GSM0808_CAUSE_CALL_CONTROL, GSM48_RR_CAUSE_NORMAL);
1905 f_tc_chan_rel_rr_cause(GSM0808_CAUSE_HANDOVER_SUCCESSFUL, GSM48_RR_CAUSE_NORMAL);
1906 f_tc_chan_rel_rr_cause(GSM0808_CAUSE_PREEMPTION, GSM48_RR_CAUSE_PREMPTIVE_REL);
1907 f_tc_chan_rel_rr_cause(GSM0808_CAUSE_RADIO_INTERFACE_MESSAGE_FAILURE, GSM48_RR_CAUSE_PROT_ERROR_UNSPC);
1908 f_tc_chan_rel_rr_cause(GSM0808_CAUSE_RADIO_INTERFACE_FAILURE, GSM48_RR_CAUSE_ABNORMAL_UNSPEC);
1909 f_tc_chan_rel_rr_cause(GSM0808_CAUSE_EQUIPMENT_FAILURE, GSM48_RR_CAUSE_ABNORMAL_UNSPEC);
1910}
1911
Harald Welte5cd20ed2017-12-13 21:03:20 +01001912/* Test behavior if RSL EST IND for non-active channel */
1913testcase TC_rll_est_ind_inact_lchan() runs on test_CT {
1914 timer T := 2.0;
1915
Harald Welte89d42e82017-12-17 16:42:41 +01001916 f_init(1);
Harald Welte5cd20ed2017-12-13 21:03:20 +01001917
1918 var octetstring l3 := '00010203040506'O;
1919 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(6));
1920 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
1921
1922 T.start;
1923 alt {
1924 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) {
1925 setverdict(fail, "MSC received COMPL L3 for non-active lchan");
1926 }
1927 [] BSSAP.receive {}
1928 [] IPA_RSL[0].receive {}
1929 [] T.timeout {}
1930 }
1931
1932 setverdict(pass);
1933}
1934
1935/* Test behavior if RSL EST IND for invalid SAPI */
1936testcase TC_rll_est_ind_inval_sapi1() runs on test_CT {
1937 var RslChannelNr chan_nr;
1938
Harald Welte89d42e82017-12-17 16:42:41 +01001939 f_init(1);
Harald Welte5cd20ed2017-12-13 21:03:20 +01001940
1941 chan_nr := f_chreq_act_ack()
1942
1943 var octetstring l3 := '00010203040506'O;
1944 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(1)), l3));
1945
1946 timer T := 2.0;
1947 T.start;
1948 alt {
1949 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) {
1950 setverdict(fail, "MSC received COMPL L3 for invalid SAPI 1");
1951 }
1952 [] BSSAP.receive { repeat; }
1953 [] IPA_RSL[0].receive { repeat; }
1954 [] T.timeout {}
1955 }
1956
1957 setverdict(pass);
1958}
1959
1960/* Test behavior if RSL EST IND for invalid SAPI */
1961testcase TC_rll_est_ind_inval_sapi3() runs on test_CT {
1962 timer T := 2.0;
1963
Harald Welte89d42e82017-12-17 16:42:41 +01001964 f_init(1);
Harald Welte5cd20ed2017-12-13 21:03:20 +01001965
1966 var RslChannelNr chan_nr := f_chreq_act_ack();
1967
1968 var octetstring l3 := '00010203040506'O;
1969 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_DCCH(3)), l3));
1970
1971 T.start;
1972 alt {
1973 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) {
1974 setverdict(fail, "MSC received COMPL L3 for invalid SAPI 3");
1975 }
1976 [] BSSAP.receive { repeat; }
1977 [] IPA_RSL[0].receive { repeat; }
1978 [] T.timeout {}
1979 }
1980
1981 setverdict(pass);
1982}
1983
1984/* Test behavior if RSL EST IND for invalid SACCH */
1985testcase TC_rll_est_ind_inval_sacch() runs on test_CT {
1986 timer T := 2.0;
1987
Harald Welte89d42e82017-12-17 16:42:41 +01001988 f_init(1);
Harald Welte5cd20ed2017-12-13 21:03:20 +01001989
1990 var RslChannelNr chan_nr := f_chreq_act_ack();
1991
1992 var octetstring l3 := '00010203040506'O;
1993 f_ipa_tx(0, ts_RSL_EST_IND(chan_nr, valueof(ts_RslLinkID_SACCH(0)), l3));
1994
1995 T.start;
1996 alt {
1997 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(l3))) {
1998 setverdict(fail, "MSC received COMPL L3 for invalid Link SACCH");
1999 }
2000 [] BSSAP.receive { repeat; }
2001 [] IPA_RSL[0].receive { repeat; }
2002 [] T.timeout {}
2003 }
2004
2005 setverdict(pass);
2006}
2007
Vadim Yanitskiy6ef5dfa2020-08-28 18:04:41 +07002008private function f_exp_sapi_n_reject(template (present) GsmSapi sapi := ?,
2009 template myBSSMAP_Cause cause := ?,
2010 float T_val := 2.0)
2011runs on test_CT {
2012 var BSSAP_N_DATA_ind rx_di;
2013 timer T;
2014
2015 var template BSSMAP_IE_Cause tr_cause := tr_BSSMAP_IE_Cause(cause);
2016 var template PDU_BSSAP tr_pdu := tr_BSSMAP_SAPInReject(sapi);
2017
2018 T.start(T_val);
2019 alt {
2020 [] BSSAP.receive(tr_BSSAP_DATA_ind(?, tr_pdu)) -> value rx_di {
2021 var BSSMAP_IE_Cause rx_cause := rx_di.userData.pdu.bssmap.sAPInReject.cause;
2022 if (not match(rx_cause, tr_cause)) {
2023 setverdict(fail, "Rx unexpected Cause IE: ",
2024 rx_cause, " vs expected ", tr_cause);
2025 }
2026 setverdict(pass);
2027 }
2028 [] BSSAP.receive(BSSAP_N_DATA_ind:?) -> value rx_di {
2029 setverdict(fail, "Rx unexpected BSSAP PDU: ", rx_di);
2030 }
2031 [] T.timeout {
2032 setverdict(fail, "Timeout waiting for BSSMAP SAPI N Reject");
2033 }
2034 }
2035}
2036
2037/* Check if we get SAPI N Reject on receipt of unexpected RLL RELease INDication */
2038testcase TC_rll_rel_ind_sapi_n_reject() runs on test_CT {
2039 var octetstring rnd_data := f_rnd_octstring(16);
2040 var RSL_Message rx_rsl;
2041 var DchanTuple dt;
2042
2043 f_init(1);
2044
2045 /* MS establishes a SAPI=0 link on DCCH */
2046 dt := f_est_dchan(f_rnd_ra_cs(), 23, rnd_data);
2047
2048 /* MSC sends some data on (not yet established) SAPI=3 link */
2049 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSAP_DTAP(rnd_data, '03'O)));
2050 /* BSC attempts to establish a SAPI=3 link on DCCH */
2051 rx_rsl := f_exp_ipa_rx(0, tr_RSL_EST_REQ(dt.rsl_chan_nr, tr_RslLinkID_DCCH(3)));
2052
2053 /* MS sends unexpected RELease INDication on SAPI=3 */
2054 f_ipa_tx(0, ts_RSL_REL_IND(dt.rsl_chan_nr, ts_RslLinkID_DCCH(3)));
2055 /* We expect to receive BSSMAP SAPI N Reject message from the BSC */
2056 f_exp_sapi_n_reject(3, GSM0808_CAUSE_MS_NOT_EQUIPPED);
2057
2058 /* Clean up the connection */
2059 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
2060 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
2061
2062 setverdict(pass);
2063}
2064
2065/* Check if we get SAPI N Reject on receipt of unexpected RLL ERROR INDication */
2066testcase TC_rll_err_ind_sapi_n_reject() runs on test_CT {
2067 var octetstring rnd_data := f_rnd_octstring(16);
2068 var RSL_Message rx_rsl;
2069 var DchanTuple dt;
2070
2071 f_init(1);
2072
2073 /* MS establishes a SAPI=0 link on DCCH */
2074 dt := f_est_dchan(f_rnd_ra_cs(), 23, rnd_data);
2075
2076 /* MSC sends some data on (not yet established) SAPI=3 link */
2077 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSAP_DTAP(rnd_data, '03'O)));
2078 /* BSC attempts to establish a SAPI=3 link on DCCH */
2079 rx_rsl := f_exp_ipa_rx(0, tr_RSL_EST_REQ(dt.rsl_chan_nr, tr_RslLinkID_DCCH(3)));
2080
2081 /* BTS sends unexpected ERROR INDication on SAPI=3 */
2082 f_ipa_tx(0, ts_RSL_ERROR_IND(dt.rsl_chan_nr, ts_RslLinkID_DCCH(3), ''O));
2083 /* We expect to receive BSSMAP SAPI N Reject message from the BSC */
2084 f_exp_sapi_n_reject(3, GSM0808_CAUSE_BSS_NOT_EQUIPPED);
2085
2086 /* Clean up the connection */
2087 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
2088 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
2089
2090 setverdict(pass);
2091}
2092
2093/* Check if we get SAPI N Reject due to a SAPI=3 link establishment timeout */
2094testcase TC_rll_timeout_sapi_n_reject() runs on test_CT {
2095 var octetstring rnd_data := f_rnd_octstring(16);
2096 var RSL_Message rx_rsl;
2097 var DchanTuple dt;
2098
2099 f_init(1);
2100
2101 /* MS establishes a SAPI=0 link on DCCH */
2102 dt := f_est_dchan(f_rnd_ra_cs(), 23, rnd_data);
2103
2104 /* MSC sends some data on (not yet established) SAPI=3 link */
2105 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSAP_DTAP(rnd_data, '03'O)));
2106 /* BSC attempts to establish a SAPI=3 link on DCCH */
2107 rx_rsl := f_exp_ipa_rx(0, tr_RSL_EST_REQ(dt.rsl_chan_nr, tr_RslLinkID_DCCH(3)));
2108
2109 /* MS does not respond, so the link establishment timeout triggers SAPI N Reject */
2110 f_exp_sapi_n_reject(3, GSM0808_CAUSE_BSS_NOT_EQUIPPED, T_val := 8.0);
2111
2112 /* Clean up the connection */
2113 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
2114 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false);
2115
2116 setverdict(pass);
2117}
2118
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +02002119testcase TC_si_default() runs on test_CT {
2120 f_init(0);
2121 f_init_bts_and_check_sysinfo(0, expect_si := SystemInformationConfig_default);
2122}
Harald Welte4003d112017-12-09 22:35:39 +01002123
Neels Hofmeyr56f24782020-07-09 00:50:49 +02002124/* We're testing SI2quater with lists of EARFCNs. Instead of just incrementing EARFCNs, also pick some from the edges of
2125 * the entire value range. This function provides the same EARFCN numbers for the same earfcn_index */
2126private function f_test_si2quater_earfcn_by_idx(integer earfcn_index) return uint16_t
2127{
2128 select (earfcn_index) {
2129 case (0) {
2130 /* E-ARFCN 111 is already added in the osmo-bsc.cfg */
2131 return 111;
2132 }
2133 case (1) {
2134 return 1;
2135 }
2136 case (2) {
2137 return 0;
2138 }
2139 case (3) {
2140 return 65535;
2141 }
2142 case else {
2143 return 23 * (earfcn_index - 3);
2144 }
2145 }
2146}
2147
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02002148function f_test_si2quater(integer total_earfcns, template SystemInformationConfig expect_si,
2149 template CellSelIndValue expect_cells := omit) runs on test_CT {
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002150
2151 f_init(0);
2152
2153 /* E-ARFCN 111 is already added in the osmo-bsc.cfg, so only add more arfcns if total_earfcns > 1 */
2154 for (var integer i := 1; i < total_earfcns; i := i + 1) {
Neels Hofmeyr56f24782020-07-09 00:50:49 +02002155 f_bts_0_cfg(BSCVTY, {"si2quater neighbor-list add earfcn " & int2str(f_test_si2quater_earfcn_by_idx(i))
2156 & " thresh-hi 20 thresh-lo 10 prio 3 qrxlv 22 meas 3"});
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002157 }
2158
2159 f_init_bts_and_check_sysinfo(0, expect_si := expect_si);
2160
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02002161 f_init(1);
2162
2163 if (not istemplatekind(expect_cells, "omit")) {
2164 /* Also check that RR Channel Release contains these EARFCNs.
2165 * (copied code from TC_chan_rel_hard_clear_csfb) */
2166 var BSSAP_N_DATA_ind rx_di;
2167 var DchanTuple dt;
2168
2169 dt := f_est_dchan('23'O, 23, '00010203040506'O);
2170
2171 /* Instruct BSC to clear channel */
2172 var BssmapCause cause := 0;
2173 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommandCSFB(cause)));
2174
2175 /* expect Clear Complete from BSC on A */
2176 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearComplete)) {
2177 /* release the SCCP connection */
2178 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
2179 }
2180
2181 f_expect_chan_rel(0, dt.rsl_chan_nr, expect_rll_rel_req := false, is_csfb := true,
2182 csfb_expect_cells := expect_cells);
2183 }
2184
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002185 for (var integer i := 1; i < total_earfcns; i := i + 1) {
Neels Hofmeyr56f24782020-07-09 00:50:49 +02002186 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 +02002187 }
2188}
2189
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002190private function f_tr_si2quater_earfcns(integer count) return template SI2quaterRestOctetsList
2191{
2192 var template SI2quaterRestOctetsList si2quater := {};
2193 var integer si2quater_count := (count + 2) / 3;
2194
2195 for (var integer i := 0; i < count; i := i + 1) {
Neels Hofmeyr56f24782020-07-09 00:50:49 +02002196 var integer earfcn := f_test_si2quater_earfcn_by_idx(i);
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002197 var integer index := i / 3;
2198 var integer earfcn_index := i mod 3;
2199 if (index >= lengthof(si2quater)) {
2200 si2quater[index] := tr_SI2quaterRestOctets_EUTRAN(index := index, count := si2quater_count - 1);
2201 }
2202 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);
2203 }
2204
2205 return si2quater;
2206}
2207
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02002208private function f_tr_rr_chan_rel_earfcns(integer count) return template CellSelIndValue
2209{
2210 var template CellSelIndValue_EUTRAN_Descrs cells := {};
2211
2212 for (var integer i := 0; i < count; i := i + 1) {
2213 var integer earfcn := f_test_si2quater_earfcn_by_idx(i);
2214 cells[i] := tr_CellSelIndValue_EUTRAN_Descr(earfcn, meas_bw_presence := '0'B, meas_bw := omit);
2215 }
2216
2217 return tr_CellSelIndValue_EUTRAN(cells);
2218}
2219
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002220private function f_tc_si2quater_n_earfcns(integer n) runs on test_CT
2221{
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002222 var template SystemInformationConfig sic := SystemInformationConfig_default;
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002223 sic.si2quater := f_tr_si2quater_earfcns(n);
Neels Hofmeyr0edf4ac2020-07-10 17:33:24 +02002224 var template CellSelIndValue cells := f_tr_rr_chan_rel_earfcns(n);
2225 f_test_si2quater(n, sic, cells);
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002226}
2227
2228testcase TC_si2quater_2_earfcns() runs on test_CT {
2229 f_tc_si2quater_n_earfcns(2);
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002230}
2231
2232testcase TC_si2quater_3_earfcns() runs on test_CT {
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002233 f_tc_si2quater_n_earfcns(3);
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002234}
2235
2236testcase TC_si2quater_4_earfcns() runs on test_CT {
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002237 f_tc_si2quater_n_earfcns(4);
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002238}
2239
2240testcase TC_si2quater_5_earfcns() runs on test_CT {
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002241 f_tc_si2quater_n_earfcns(5);
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002242}
2243
2244testcase TC_si2quater_6_earfcns() runs on test_CT {
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002245 f_tc_si2quater_n_earfcns(6);
2246}
2247
2248testcase TC_si2quater_12_earfcns() runs on test_CT {
2249 f_tc_si2quater_n_earfcns(12);
2250}
2251
2252testcase TC_si2quater_23_earfcns() runs on test_CT {
2253 f_tc_si2quater_n_earfcns(23);
2254}
2255
2256testcase TC_si2quater_32_earfcns() runs on test_CT {
2257 f_tc_si2quater_n_earfcns(32);
2258}
2259
2260testcase TC_si2quater_33_earfcns() runs on test_CT {
2261 f_tc_si2quater_n_earfcns(33);
2262}
2263
2264testcase TC_si2quater_42_earfcns() runs on test_CT {
2265 f_tc_si2quater_n_earfcns(42);
2266}
2267
2268testcase TC_si2quater_48_earfcns() runs on test_CT {
2269 f_tc_si2quater_n_earfcns(48);
2270}
2271
2272/* verify the VTY error response when adding too many EARFCNs, and showing that osmo-bsc still sends 16 SI2quater with
2273 * 48 EARFCNs. */
2274testcase TC_si2quater_49_earfcns() runs on test_CT {
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002275 var template SystemInformationConfig sic := SystemInformationConfig_default;
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002276 sic.si2quater := f_tr_si2quater_earfcns(48); /* 48, not 49! */
2277 f_init(0);
2278
2279 for (var integer i := 1; i < 48; i := i + 1) {
Neels Hofmeyr56f24782020-07-09 00:50:49 +02002280 f_bts_0_cfg(BSCVTY, {"si2quater neighbor-list add earfcn " & int2str(f_test_si2quater_earfcn_by_idx(i))
2281 & " thresh-hi 20 thresh-lo 10 prio 3 qrxlv 22 meas 3"});
Neels Hofmeyrad132f22020-07-08 02:20:16 +02002282 }
2283
2284 /* The 49th EARFCN no longer fits, expect VTY error */
2285 f_vty_enter_cfg_bts(BSCVTY, 0);
2286 var charstring vty_error;
2287 vty_error := f_vty_transceive_ret(BSCVTY,
2288 "si2quater neighbor-list add earfcn 70 thresh-hi 20 thresh-lo 10 prio 3 qrxlv 22 meas 3")
2289 f_vty_transceive(BSCVTY, "end");
2290
2291 if (f_strstr(vty_error, "Unable to add ARFCN 70") >= 0) {
2292 log("Got expected VTY error: ", vty_error);
2293 setverdict(pass);
2294 } else {
2295 setverdict(fail, "Expected the 49th EUTRAN ARFCN to be rejected by vty config, got: ", vty_error);
2296 }
2297
2298 f_init_bts_and_check_sysinfo(0, expect_si := sic);
2299
2300 for (var integer i := 1; i < 48; i := i + 1) {
Neels Hofmeyr56f24782020-07-09 00:50:49 +02002301 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 +02002302 }
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002303}
2304
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02002305private function f_acc09_count_allowed(AccessControlClass acc) return uint8_t
2306{
2307 var uint8_t count := 0;
2308 for (var integer i := 5; i < 16; i := i + 1) {
2309 if (acc[i] == '0'B) { /* the list marks barred, we count allowed */
2310 count := count + 1;
2311 }
2312 }
2313 return count;
2314}
2315
Pau Espin Pedrolc6136cd2020-07-24 13:20:02 +02002316private function f_recv_next_si1(integer rsl_idx := 0) runs on test_CT return SystemInformationType1
2317{
2318 var ASP_RSL_Unitdata rx_rsl_ud;
2319 var SystemInformationType1 last_si1;
2320
2321 timer T := 30.0;
2322 T.start;
2323 alt {
2324 [] IPA_RSL[rsl_idx].receive(tr_ASP_RSL_UD((tr_RSL_NO_BCCH_INFO,
2325 tr_RSL_BCCH_INFO,
2326 tr_RSL_NO_SACCH_FILL,
2327 tr_RSL_SACCH_FILL))
2328 ) -> value rx_rsl_ud {
2329 f_sysinfo_seen(rsl_idx, rx_rsl_ud.rsl);
2330 if (g_system_information[rsl_idx].si1 == omit) {
2331 repeat;
2332 }
2333 last_si1 := g_system_information[rsl_idx].si1;
2334 g_system_information[rsl_idx].si1 := omit;
2335 T.stop;
2336 }
2337 [] T.timeout { setverdict(fail, "Timeout receiving next SI1"); }
2338 }
2339 return last_si1;
2340}
2341
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02002342/* verify ACC rotate feature */
2343testcase TC_si_acc_rotate() runs on test_CT {
2344 var template SystemInformationConfig sic := SystemInformationConfig_default;
Pau Espin Pedrolc6136cd2020-07-24 13:20:02 +02002345 var SystemInformationType1 last_si1;
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02002346 var AccessControlClass acc;
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02002347 var uint8_t count;
2348 var integer times_allowed[10] := { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
2349
2350 f_init(0, guard_timeout := 60.0);
2351
2352 f_bts_0_cfg(BSCVTY, {"rach access-control-class 5 barred",
2353 "access-control-class-rotate 3",
2354 "access-control-class-rotate-quantum 1"});
2355
2356 /* Init and get first sysinfo */
2357 f_init_bts_and_check_sysinfo(0, expect_si := ?);
2358
Pau Espin Pedrolc6136cd2020-07-24 13:20:02 +02002359 for (var integer i:= 0; i < 20; i := i + 1) {
2360 last_si1 := f_recv_next_si1(0);
2361 acc := last_si1.rach_control.acc;
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02002362 count := f_acc09_count_allowed(acc);
2363 log("RSL: GOT SI1 ACC len=", count, ": ", acc);
2364
2365 if (count != 3) {
2366 log("RSL: EXPECTED SI ACC len=3");
2367 setverdict(fail, "received SI does not match expectations");
2368 break;
2369 }
2370
2371 for (var integer j := 0; j < 10; j := j + 1) {
2372 if (acc[16 - 1 - j] == '0'B) { /* the list marks barred, we count allowed */
2373 times_allowed[j] := times_allowed[j] + 1;
2374 }
2375 }
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02002376 }
2377
2378 for (var integer j := 0; j < 10; j := j + 1) {
2379 log("ACC", j, " allowed ", times_allowed[j], " times" );
2380 if (j != 5 and times_allowed[j] < 3) {
2381 setverdict(fail, "ACC", j, " ERROR: allowed ", times_allowed[j], " < 1 times");
2382 } else if (j == 5 and times_allowed[j] > 0) {
2383 setverdict(fail, "ACC", j, " ERROR: allowed ", times_allowed[j], " > 0 times");
2384 }
2385 }
2386
2387 f_bts_0_cfg(BSCVTY, {"access-control-class-rotate 10",
2388 "rach access-control-class 5 allowed"});
2389}
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02002390
Pau Espin Pedrolc6136cd2020-07-24 13:20:02 +02002391/* verify ACC startup ramp+rotate feature */
2392testcase TC_si_acc_ramp_rotate() runs on test_CT {
2393 var template SystemInformationConfig sic := SystemInformationConfig_default;
2394 var SystemInformationType1 last_si1;
2395 var AccessControlClass acc;
2396 var ASP_RSL_Unitdata rx_rsl_ud;
2397 var uint8_t count;
2398 var uint8_t prev_count;
2399 var integer times_allowed[10] := { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
2400
2401 f_init(0, guard_timeout := 80.0);
2402
2403 f_bts_0_cfg(BSCVTY, {"rach access-control-class 4 barred",
2404 "access-control-class-rotate 0",
2405 "access-control-class-rotate-quantum 1",
2406 "access-control-class-ramping",
2407 "access-control-class-ramping-step-interval 5",
2408 "access-control-class-ramping-step-size 5"});
2409
2410 /* Init and get first sysinfo */
2411 f_init_bts_and_check_sysinfo(0, expect_si := ?);
2412 last_si1 := g_system_information[0].si1;
2413 acc := last_si1.rach_control.acc;
2414 count := f_acc09_count_allowed(acc);
2415 /* Adm subset size was set to 0 above, so wait until all ACC are barred */
2416 while (count > 0) {
2417 last_si1 := f_recv_next_si1(0);
2418 acc := last_si1.rach_control.acc;
2419 count := f_acc09_count_allowed(acc);
2420 log("RSL: wait len()=0: GOT SI1 ACC len=", count, ": ", acc);
2421 }
2422
2423 /* Increase adm subset size, we should see ramping start up */
2424 f_bts_0_cfg(BSCVTY, {"access-control-class-rotate 10"});
2425 prev_count := 0;
2426 while (true) {
2427 last_si1 := f_recv_next_si1(0);
2428 acc := last_si1.rach_control.acc;
2429 count := f_acc09_count_allowed(acc);
2430 log("RSL: GOT SI1 ACC len=", count, ": ", acc);
2431
2432 if (prev_count > count) {
2433 setverdict(fail, "ACC allowed count dropped while expecting grow: ", prev_count, " -> ", count);
2434 break;
2435 }
2436
2437 if (count == 9) {
2438 break; /* Maximum reached (10 - 1 perm barred), done here */
2439 }
2440
2441 prev_count := count;
2442 }
2443
2444 setverdict(pass);
2445
2446 f_bts_0_cfg(BSCVTY, {"access-control-class-rotate 10",
2447 "rach access-control-class 4 allowed",
2448 "no access-control-class-ramping"});
2449}
2450
Harald Welte4003d112017-12-09 22:35:39 +01002451testcase TC_ctrl_msc_connection_status() runs on test_CT {
2452 var charstring ctrl_resp;
2453
Harald Welte89d42e82017-12-17 16:42:41 +01002454 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +01002455
2456 /* See https://osmocom.org/issues/2729 */
2457 f_ctrl_get_exp(IPA_CTRL, "msc_connection_status", "connected");
2458 setverdict(pass);
2459}
2460
Stefan Sperlingb041b3d2018-01-03 17:14:55 +01002461testcase TC_ctrl_msc0_connection_status() runs on test_CT {
2462 var charstring ctrl_resp;
2463
2464 f_init(1);
Stefan Sperlingb041b3d2018-01-03 17:14:55 +01002465
2466 f_ctrl_get_exp(IPA_CTRL, "msc.0.connection_status", "connected");
2467 setverdict(pass);
2468}
2469
Harald Welte4003d112017-12-09 22:35:39 +01002470testcase TC_ctrl() runs on test_CT {
2471 var charstring ctrl_resp;
2472
Harald Welte89d42e82017-12-17 16:42:41 +01002473 f_init(1);
Harald Welte4003d112017-12-09 22:35:39 +01002474
2475 /* all below values must match the osmo-bsc.cfg config file used */
2476
Harald Welte6a129692018-03-17 17:30:14 +01002477 f_ctrl_get_exp(IPA_CTRL, "mcc", "001");
2478 f_ctrl_get_exp(IPA_CTRL, "mnc", "01");
Oliver Smith75aa0202019-08-19 14:17:50 +02002479 f_ctrl_get_exp(IPA_CTRL, "number-of-bts", "4");
Harald Welte4003d112017-12-09 22:35:39 +01002480
2481 var integer bts_nr := 0;
2482 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "location-area-code", "1");
2483 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "cell-identity", "0");
2484 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "oml-connection-state", "connected");
2485 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "gprs-mode", "gprs");
2486 f_ctrl_get_exp_bts(IPA_CTRL, bts_nr, "rf_state", "operational,unlocked,on");
2487 f_ctrl_get_exp_trx(IPA_CTRL, bts_nr, 0, "arfcn", "871");
2488 f_ctrl_get_exp_trx(IPA_CTRL, bts_nr, 0, "max-power-reduction", "20");
2489
2490 var integer uptime := str2int(f_ctrl_get_bts(IPA_CTRL, bts_nr, "oml-uptime"));
2491 f_sleep(2.0);
2492 if (str2int(f_ctrl_get_bts(IPA_CTRL, bts_nr, "oml-uptime")) < uptime+1) {
2493 setverdict(fail, "oml-uptime not incrementing as expected");
2494 }
2495 /* TODO: Disconnect RSL, imply that OML is disconnected and check for uptime zero? */
2496
2497 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bsc", 0, "paging:attempted", 0);
2498
2499 setverdict(pass);
Harald Welte96c94412017-12-09 03:12:45 +01002500}
2501
Pau Espin Pedrol5a2d7432019-06-07 19:43:45 +02002502/* Verify that Upon receival of SET "location", BSC forwards a TRAP
2503 "location-state" over the SCCPlite IPA conn */
2504testcase TC_ctrl_location() runs on test_CT {
2505 var MSC_ConnHdlr vc_conn;
2506 var integer bts_nr := 0;
2507
2508 f_init(1, true);
2509 f_sleep(1.0);
2510
2511 f_ctrl_set_bts(IPA_CTRL, bts_nr, "location", "1234567,fix3d,0.340000,0.560000,0.780000");
2512 f_ctrl_exp_trap(SCCPLITE_IPA_CTRL, "bts." & int2str(bts_nr) & ".location-state",
2513 "1234567,fix3d,0.340000,0.560000,0.780000,operational,unlocked,on,001,01");
2514
2515 f_ctrl_set(SCCPLITE_IPA_CTRL, "rf_locked", "1");
2516 f_sleep(2.0);
2517
2518 f_ctrl_set_bts(IPA_CTRL, bts_nr, "location", "1234888,fix3d,0.350000,0.570000,0.790000");
2519 f_ctrl_exp_trap(SCCPLITE_IPA_CTRL, "bts." & int2str(bts_nr) & ".location-state",
2520 "1234888,fix3d,0.350000,0.570000,0.790000,operational,locked,off,001,01");
2521
2522 /* should match the one from config */
2523 f_ctrl_set(SCCPLITE_IPA_CTRL, "rf_locked", "0");
2524
2525 setverdict(pass);
2526}
2527
Harald Welte6f521d82017-12-11 19:52:02 +01002528
2529/***********************************************************************
2530 * Paging Testing
2531 ***********************************************************************/
2532
2533type record Cell_Identity {
2534 GsmMcc mcc,
2535 GsmMnc mnc,
2536 GsmLac lac,
2537 GsmCellId ci
2538};
Harald Welte24135bd2018-03-17 19:27:53 +01002539private const Cell_Identity cid := { '001'H, '01'H, 1, 0 };
Stefan Sperling049a86e2018-03-20 15:51:00 +01002540private const Cell_Identity unknown_cid := { '678'H, 'f90'H, 1, 0 };
Harald Welte6f521d82017-12-11 19:52:02 +01002541
Harald Welte5d1a2202017-12-13 19:51:29 +01002542type set of integer BtsIdList;
2543
2544private function f_bts_in_list(integer bts_id, BtsIdList bts_ids) return boolean {
2545 for (var integer j := 0; j < sizeof(bts_ids); j := j + 1) {
2546 if (bts_id == bts_ids[j]) {
2547 return true;
2548 }
2549 }
2550 return false;
2551}
Harald Welte6f521d82017-12-11 19:52:02 +01002552
2553/* core paging test helper function; used by most paging test cases */
2554private function f_pageing_helper(hexstring imsi,
2555 template BSSMAP_FIELD_CellIdentificationList cid_list,
Harald Welte5d1a2202017-12-13 19:51:29 +01002556 BtsIdList bts_ids := { 0 },
Harald Welte6f521d82017-12-11 19:52:02 +01002557 template RSL_ChanNeeded rsl_chneed := omit,
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07002558 template (omit) OCT4 tmsi := omit) runs on test_CT
Harald Welte6f521d82017-12-11 19:52:02 +01002559{
2560 var template BSSMAP_IE_ChannelNeeded bssmap_chneed;
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07002561 var template MobileIdentityV mi;
Harald Welte6f521d82017-12-11 19:52:02 +01002562 var RSL_Message rx_rsl;
2563 var integer paging_group := hex2int(imsi[lengthof(imsi)-1]);
Harald Welte5d1a2202017-12-13 19:51:29 +01002564 var integer i;
Harald Welte6f521d82017-12-11 19:52:02 +01002565
2566 f_init();
Harald Welte6f521d82017-12-11 19:52:02 +01002567
2568 /* Clear the queue, it might still contain stuff like BCCH FILLING */
Harald Weltec3068592018-03-17 19:55:31 +01002569 for (i := 0; i < NUM_BTS; i := i + 1) {
2570 IPA_RSL[i].clear;
Harald Welte5d1a2202017-12-13 19:51:29 +01002571 }
Harald Welte6f521d82017-12-11 19:52:02 +01002572
2573 if (isvalue(rsl_chneed)) {
2574 /* The values of 08.08 3.2.2.36 and 08.58 9.3.40 are luckily identical */
2575 bssmap_chneed := ts_BSSMAP_IE_ChanNeeded(int2bit(enum2int(valueof(rsl_chneed)),2));
2576 } else {
2577 bssmap_chneed := omit;
2578 }
2579
Neels Hofmeyrf246a922020-05-13 02:27:10 +02002580 BSSAP.send(ts_BSSAP_UNITDATA_req(g_bssap[0].sccp_addr_peer, g_bssap[0].sccp_addr_own,
2581 ts_BSSMAP_Paging(imsi, cid_list, tmsi, bssmap_chneed)));
Harald Welte6f521d82017-12-11 19:52:02 +01002582
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07002583 if (not istemplatekind(tmsi, "omit")) {
2584 mi := t_MI_TMSI(tmsi);
Harald Welte6f521d82017-12-11 19:52:02 +01002585 } else {
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07002586 mi := tr_MI_IMSI(imsi);
Harald Welte6f521d82017-12-11 19:52:02 +01002587 }
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07002588
Harald Welte5d1a2202017-12-13 19:51:29 +01002589 for (i := 0; i < sizeof(bts_ids); i := i + 1) {
Vadim Yanitskiycc4623d2020-03-28 06:14:06 +07002590 rx_rsl := f_exp_ipa_rx(bts_ids[i], tr_RSL_PAGING_CMD(mi));
Harald Welte5d1a2202017-12-13 19:51:29 +01002591 /* check channel type, paging group */
2592 if (rx_rsl.ies[1].body.paging_group != paging_group) {
2593 setverdict(fail, "Paging for wrong paging group");
2594 }
2595 if (ispresent(rsl_chneed) and
2596 rx_rsl.ies[3].body.chan_needed.chan_needed != valueof(rsl_chneed)) {
2597 setverdict(fail, "RSL Channel Needed != BSSMAP Channel Needed");
2598 }
Harald Welte6f521d82017-12-11 19:52:02 +01002599 }
Harald Welte2fccd982018-01-31 15:48:19 +01002600 f_sleep(2.0);
Harald Welte5d1a2202017-12-13 19:51:29 +01002601 /* do a quick check on all not-included BTSs if they received paging */
2602 for (i := 0; i < NUM_BTS; i := i + 1) {
2603 timer T := 0.1;
2604 if (f_bts_in_list(i, bts_ids)) {
2605 continue;
2606 }
2607 T.start;
2608 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07002609 [] IPA_RSL[i].receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD(mi))) {
Harald Welte5d1a2202017-12-13 19:51:29 +01002610 setverdict(fail, "Paging on BTS ", i, " which is not part of ", bts_ids);
2611 }
2612 [] IPA_RSL[i].receive { repeat; }
2613 [] T.timeout { }
2614 }
Harald Welte6f521d82017-12-11 19:52:02 +01002615 }
2616
2617 setverdict(pass);
2618}
2619
Harald Welte5d1a2202017-12-13 19:51:29 +01002620const BtsIdList c_BtsId_all := { 0, 1, 2 };
Harald Welte751d3eb2018-01-31 15:51:06 +01002621const BtsIdList c_BtsId_none := { };
Harald Welte5d1a2202017-12-13 19:51:29 +01002622const BtsIdList c_BtsId_LAC1 := { 0, 1 };
2623const BtsIdList c_BtsId_LAC2 := { 2 };
2624
Harald Welte6f521d82017-12-11 19:52:02 +01002625/* PAGING by IMSI + TMSI */
2626testcase TC_paging_imsi_nochan() runs on test_CT {
2627 var BSSMAP_FIELD_CellIdentificationList cid_list;
2628 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Philipp Maier8c04b0a2018-02-23 13:48:48 +01002629 f_pageing_helper('001010100000001'H, cid_list, c_BtsId_all, omit, omit);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002630 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002631}
2632
2633/* PAGING by IMSI + TMSI */
2634testcase TC_paging_tmsi_nochan() runs on test_CT {
2635 var BSSMAP_FIELD_CellIdentificationList cid_list;
2636 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01002637 f_pageing_helper('001010100000001'H, cid_list, c_BtsId_all, omit, 'A1B2C301'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002638 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002639}
2640
2641/* Paging with different "channel needed' values */
2642testcase TC_paging_tmsi_any() runs on test_CT {
2643 var BSSMAP_FIELD_CellIdentificationList cid_list;
2644 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01002645 f_pageing_helper('001010100000002'H, cid_list, c_BtsId_all, RSL_CHANNEED_ANY, 'A1B2C302'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002646 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002647}
2648testcase TC_paging_tmsi_sdcch() runs on test_CT {
2649 var BSSMAP_FIELD_CellIdentificationList cid_list;
2650 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01002651 f_pageing_helper('001010100000003'H, cid_list, c_BtsId_all, RSL_CHANNEED_SDCCH, 'A1B2C303'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002652 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002653}
2654testcase TC_paging_tmsi_tch_f() runs on test_CT {
2655 var BSSMAP_FIELD_CellIdentificationList cid_list;
2656 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01002657 f_pageing_helper('001010000000004'H, cid_list, c_BtsId_all, RSL_CHANNEED_TCH_F, 'A1B2C304'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002658 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002659}
2660testcase TC_paging_tmsi_tch_hf() runs on test_CT {
2661 var BSSMAP_FIELD_CellIdentificationList cid_list;
2662 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01002663 f_pageing_helper('001010000000005'H, cid_list, c_BtsId_all, RSL_CHANNEED_TCH_ForH, 'A1B2C305'O);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002664 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002665}
2666
2667/* Paging by CGI */
2668testcase TC_paging_imsi_nochan_cgi() runs on test_CT {
2669 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2670 cid_list := { cIl_CGI := { ts_BSSMAP_CI_CGI(cid.mcc, cid.mnc, cid.lac, cid.ci) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01002671 f_pageing_helper('001010000000006'H, cid_list, { 0 });
Philipp Maier282ca4b2018-02-27 17:17:00 +01002672 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002673}
2674
2675/* Paging by LAC+CI */
2676testcase TC_paging_imsi_nochan_lac_ci() runs on test_CT {
2677 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2678 cid_list := { cIl_LAC_CI := { ts_BSSMAP_CI_LAC_CI(cid.lac, cid.ci) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01002679 f_pageing_helper('001010000000007'H, cid_list, { 0 });
Philipp Maier282ca4b2018-02-27 17:17:00 +01002680 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002681}
2682
2683/* Paging by CI */
2684testcase TC_paging_imsi_nochan_ci() runs on test_CT {
2685 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2686 cid_list := { cIl_CI := { ts_BSSMAP_CI_CI(cid.ci) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01002687 f_pageing_helper('001010000000008'H, cid_list, { 0 });
Philipp Maier282ca4b2018-02-27 17:17:00 +01002688 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002689}
2690
2691/* Paging by LAI */
2692testcase TC_paging_imsi_nochan_lai() runs on test_CT {
2693 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2694 cid_list := { cIl_LAI := { ts_BSSMAP_CI_LAI(cid.mcc, cid.mnc, cid.lac) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01002695 f_pageing_helper('001010000000009'H, cid_list, c_BtsId_LAC1);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002696 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002697}
2698
2699/* Paging by LAC */
2700testcase TC_paging_imsi_nochan_lac() runs on test_CT {
2701 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2702 cid_list := { cIl_LAC := { ts_BSSMAP_CI_LAC(cid.lac) } };
Harald Welte5d1a2202017-12-13 19:51:29 +01002703 f_pageing_helper('001010000000010'H, cid_list, c_BtsId_LAC1);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002704 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002705}
2706
2707/* Paging by "all in BSS" */
2708testcase TC_paging_imsi_nochan_all() runs on test_CT {
2709 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2710 cid_list := { cIl_allInBSS := ''O };
Harald Welte5d1a2202017-12-13 19:51:29 +01002711 f_pageing_helper('001010000000011'H, cid_list, c_BtsId_all);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002712 f_shutdown_helper();
Harald Welte6f521d82017-12-11 19:52:02 +01002713}
2714
Stefan Sperling7b5e1782018-03-20 19:32:43 +01002715/* Paging by PLMN+LAC+RNC; We do not implement this; Verify nothing is paged */
Harald Welte751d3eb2018-01-31 15:51:06 +01002716testcase TC_paging_imsi_nochan_plmn_lac_rnc() runs on test_CT {
2717 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2718 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 +01002719 f_pageing_helper('001010000000012'H, cid_list, c_BtsId_none);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002720 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01002721}
Harald Welte6f521d82017-12-11 19:52:02 +01002722
Stefan Sperling7b5e1782018-03-20 19:32:43 +01002723/* Paging by RNC; We do not implement this; Verify nothing is paged */
Harald Welte751d3eb2018-01-31 15:51:06 +01002724testcase TC_paging_imsi_nochan_rnc() runs on test_CT {
2725 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2726 cid_list := { cIl_RNC := { int2oct(13, 2) } };
Stefan Sperling7b5e1782018-03-20 19:32:43 +01002727 f_pageing_helper('001010000000013'H, cid_list, c_BtsId_none);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002728 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01002729}
2730
Stefan Sperling7b5e1782018-03-20 19:32:43 +01002731/* Paging by LAC+RNC; We do not implement; Verify nothing is paged */
Harald Welte751d3eb2018-01-31 15:51:06 +01002732testcase TC_paging_imsi_nochan_lac_rnc() runs on test_CT {
2733 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2734 cid_list := { cIl_LAC_RNC := { ts_BSSMAP_CI_LAC_RNC(cid.lac, 14) } };
Stefan Sperling7b5e1782018-03-20 19:32:43 +01002735 f_pageing_helper('001010000000014'H, cid_list, c_BtsId_none);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002736 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01002737}
2738
Harald Welte6f521d82017-12-11 19:52:02 +01002739/* Paging on multiple cells (multiple entries in list): Verify all of them page */
Harald Welte751d3eb2018-01-31 15:51:06 +01002740testcase TC_paging_imsi_nochan_lacs() runs on test_CT {
2741 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2742 cid_list := { cIl_LAC := { ts_BSSMAP_CI_LAC(1), ts_BSSMAP_CI_LAC(2) } };
2743 f_pageing_helper('001010000000015'H, cid_list, c_BtsId_all);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002744 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01002745}
2746
2747/* Paging on empty list: Verify none of them page */
2748testcase TC_paging_imsi_nochan_lacs_empty() runs on test_CT {
2749 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2750 cid_list := { cIl_LAC := { } };
2751 f_pageing_helper('001010000000016'H, cid_list, c_BtsId_none);
Philipp Maier282ca4b2018-02-27 17:17:00 +01002752 f_shutdown_helper();
Harald Welte751d3eb2018-01-31 15:51:06 +01002753}
2754
Stefan Sperling049a86e2018-03-20 15:51:00 +01002755/* Paging by CGI with unknown MCC/MNC: Verify nothing is paged. */
2756testcase TC_paging_imsi_nochan_cgi_unknown_cid() runs on test_CT {
2757 var template BSSMAP_FIELD_CellIdentificationList cid_list;
2758 cid_list := { cIl_CGI := { ts_BSSMAP_CI_CGI(unknown_cid.mcc, unknown_cid.mnc, unknown_cid.lac, unknown_cid.ci) } };
2759 f_pageing_helper('001010000000006'H, cid_list, c_BtsId_none);
2760 f_shutdown_helper();
2761}
2762
Harald Welte6f521d82017-12-11 19:52:02 +01002763/* Verify paging retransmission interval + count */
2764/* Verify paging stops after channel establishment */
Harald Welte6f521d82017-12-11 19:52:02 +01002765/* Test behavior under paging overload */
Harald Welteae026692017-12-09 01:03:01 +01002766
Harald Weltee65d40e2017-12-13 00:09:06 +01002767/* Verify PCH load */
2768testcase TC_paging_imsi_load() runs on test_CT {
2769 var BSSMAP_FIELD_CellIdentificationList cid_list;
2770 timer T := 4.0;
Harald Welte2caa1062018-03-17 18:19:05 +01002771 timer T_retrans := 1.0;
Harald Weltee65d40e2017-12-13 00:09:06 +01002772 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01002773 f_pageing_helper('001010123456789'H, cid_list, c_BtsId_all);
Harald Weltee65d40e2017-12-13 00:09:06 +01002774
2775 /* tell BSC there is no paging space anymore */
2776 f_ipa_tx(0, ts_RSL_PAGING_LOAD_IND(0));
Harald Welte3b57ab52018-03-17 18:01:10 +01002777 f_sleep(0.2);
2778 IPA_RSL[0].clear;
Harald Weltee65d40e2017-12-13 00:09:06 +01002779
2780 /* Wait for 4 seconds if any more PAGING CMD are received on RSL. Normally,
2781 * there would be 8 retransmissions during 4 seconds */
2782 T.start;
Harald Welte2caa1062018-03-17 18:19:05 +01002783 T_retrans.start;
Harald Weltee65d40e2017-12-13 00:09:06 +01002784 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07002785 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD(?))) {
Harald Weltee65d40e2017-12-13 00:09:06 +01002786 setverdict(fail, "Received PAGING after LOAD_IND(0)");
Daniel Willmannafce8662018-07-06 23:11:32 +02002787 mtc.stop;
Harald Weltee65d40e2017-12-13 00:09:06 +01002788 }
Harald Welte2caa1062018-03-17 18:19:05 +01002789 [] T_retrans.timeout {
2790 /* re-trnsmit the zero-space LOAD IND to avoid BSC 'auto credit' */
2791 f_ipa_tx(0, ts_RSL_PAGING_LOAD_IND(0));
2792 T_retrans.start;
2793 repeat;
2794 }
Harald Weltee65d40e2017-12-13 00:09:06 +01002795 [] T.timeout {
2796 setverdict(pass);
2797 }
2798 }
Philipp Maier282ca4b2018-02-27 17:17:00 +01002799
2800 f_shutdown_helper();
Harald Weltee65d40e2017-12-13 00:09:06 +01002801}
2802
Harald Welte235ebf12017-12-15 14:18:16 +01002803/* Verify Paging Counter */
Harald Welte1ff69992017-12-14 12:31:17 +01002804testcase TC_paging_counter() runs on test_CT {
2805 var BSSMAP_FIELD_CellIdentificationList cid_list;
2806 timer T := 4.0;
2807 var integer i;
2808 var integer paging_attempted_bsc;
2809 var integer paging_attempted_bts[NUM_BTS];
2810 var integer paging_expired_bts[NUM_BTS];
2811 cid_list := valueof(ts_BSSMAP_CIL_noCell);
2812
2813 f_init();
2814
2815 /* read counters before paging */
2816 paging_attempted_bsc := f_ctrl_get_ratectr_abs(IPA_CTRL, "bsc", 0, "paging:attempted");
2817 for (i := 0; i < NUM_BTS; i := i+1) {
2818 paging_attempted_bts[i] := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", i, "paging:attempted");
2819 paging_expired_bts[i] := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", i, "paging:expired");
2820 }
2821
2822 f_pageing_helper('001230000000001'H, cid_list, c_BtsId_all);
2823
2824 /* expect the attempted pages on BSC and each BTSs to have incremented by one */
2825 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bsc", 0, "paging:attempted", paging_attempted_bsc+1);
2826 for (i := 0; i < NUM_BTS; i := i+1) {
2827 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", i, "paging:attempted",
2828 paging_attempted_bts[i]+1);
2829 }
2830
2831 /* assume that 12s later the paging on all BTSs have expired and hence incremented by 1 */
2832 f_sleep(12.0);
2833 for (i := 0; i < NUM_BTS; i := i+1) {
2834 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", i, "paging:expired",
2835 paging_expired_bts[i]+1);
2836 }
Harald Welte1ff69992017-12-14 12:31:17 +01002837
Philipp Maier282ca4b2018-02-27 17:17:00 +01002838 f_shutdown_helper();
Harald Welte1ff69992017-12-14 12:31:17 +01002839}
2840
2841
Harald Welte10985002017-12-12 09:29:15 +01002842/* Verify paging stops after A-RESET */
2843testcase TC_paging_imsi_a_reset() runs on test_CT {
2844 var BSSMAP_FIELD_CellIdentificationList cid_list;
2845 timer T := 3.0;
2846 cid_list := valueof(ts_BSSMAP_CIL_noCell);
Harald Welte5d1a2202017-12-13 19:51:29 +01002847 f_pageing_helper('001010123456789'H, cid_list, c_BtsId_all);
Harald Welte10985002017-12-12 09:29:15 +01002848
2849 /* Perform a BSSMAP Reset and wait for ACK */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02002850 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 +01002851 alt {
Neels Hofmeyrf246a922020-05-13 02:27:10 +02002852 [] 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 +01002853 [] BSSAP.receive { repeat; }
2854 }
2855
Daniel Willmanncbef3982018-07-30 09:22:40 +02002856 /* Wait to avoid a possible race condition if a paging message is
2857 * received right before the reset ACK. */
2858 f_sleep(0.2);
2859
Harald Welte10985002017-12-12 09:29:15 +01002860 /* Clear the queue, it might still contain stuff like BCCH FILLING */
Philipp Maier1e6b4422018-02-23 14:02:13 +01002861 for (var integer i := 0; i < sizeof(IPA_RSL); i := i+1) {
2862 IPA_RSL[i].clear;
2863 }
Harald Welte10985002017-12-12 09:29:15 +01002864
2865 /* Wait for 3 seconds if any more PAGING CMD are received on RSL */
2866 T.start;
2867 alt {
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07002868 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD(?))) {
Harald Welte10985002017-12-12 09:29:15 +01002869 setverdict(fail, "Received PAGING after A-RESET");
Daniel Willmannafce8662018-07-06 23:11:32 +02002870 mtc.stop;
Harald Welte10985002017-12-12 09:29:15 +01002871 }
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07002872 [] IPA_RSL[1].receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD(?))) {
Harald Welte5d1a2202017-12-13 19:51:29 +01002873 setverdict(fail, "Received PAGING after A-RESET");
Daniel Willmannafce8662018-07-06 23:11:32 +02002874 mtc.stop;
Harald Welte5d1a2202017-12-13 19:51:29 +01002875 }
Vadim Yanitskiy9b4e3562020-05-25 21:40:52 +07002876 [] IPA_RSL[2].receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD(?))) {
Harald Welte5d1a2202017-12-13 19:51:29 +01002877 setverdict(fail, "Received PAGING after A-RESET");
Daniel Willmannafce8662018-07-06 23:11:32 +02002878 mtc.stop;
Harald Welte5d1a2202017-12-13 19:51:29 +01002879 }
Harald Welte10985002017-12-12 09:29:15 +01002880 [] T.timeout {
2881 setverdict(pass);
2882 }
2883 }
Philipp Maier282ca4b2018-02-27 17:17:00 +01002884
2885 f_shutdown_helper();
Harald Welte10985002017-12-12 09:29:15 +01002886}
Harald Welteae026692017-12-09 01:03:01 +01002887
Philipp Maierf45824a2019-08-14 14:44:10 +02002888/* Verify how we handle unsolicited Paging Response. In case of an unsolicit
2889 * paging response we can not know which MSC is in charge, so we will blindly
2890 * pick the first configured MSC. This behavior is required in order to make
2891 * MT-CSFB calls working because in those cases the BSC can not know that the
2892 * MSC has already paged the subscriver via SGs. So any MT-CSFB call will look
2893 * like an unsolicited Paging Response to the MSC.
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01002894 */
2895testcase TC_paging_resp_unsol() runs on test_CT {
2896
2897 f_init(1);
Philipp Maierf45824a2019-08-14 14:44:10 +02002898 timer T := 5.0;
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01002899
2900 var BSSAP_N_CONNECT_ind rx_c_ind;
2901 var DchanTuple dt;
2902 var PDU_ML3_MS_NW l3 := valueof(ts_PAG_RESP(valueof(ts_MI_IMSI_LV('001010008880018'H))));
Philipp Maierf45824a2019-08-14 14:44:10 +02002903 var octetstring rr_pag_resp := enc_PDU_ML3_MS_NW(l3);
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01002904
2905 /* Send CHAN RQD and wait for allocation; acknowledge it */
2906 dt.rsl_chan_nr := f_chreq_act_ack();
2907
2908 /* Send unsolicited Paging response (no matching Paging CMD stored in BSC) */
2909 f_ipa_tx(0, ts_RSL_EST_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0)), enc_PDU_ML3_MS_NW(l3)));
2910
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01002911
Philipp Maierf45824a2019-08-14 14:44:10 +02002912 /* Expevct a CR with a matching Paging response on the A-Interface */
2913 T.start;
2914 alt {
2915 [] BSSAP.receive(tr_BSSAP_CONNECT_ind(?, ?, tr_BSSMAP_ComplL3(rr_pag_resp))) {
2916 setverdict(pass);
2917 }
2918 [] BSSAP.receive {
2919 setverdict(fail, "Received unexpected message on A-Interface!");
2920 }
2921 [] T.timeout {
2922 setverdict(fail, "Received nothing on A-Interface!");
2923 }
2924 }
2925
2926 setverdict(pass);
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01002927}
2928
Harald Welte4e9b9cc2017-12-14 18:31:02 +01002929/* Test RSL link drop causes counter increment */
2930testcase TC_rsl_drop_counter() runs on test_CT {
2931 var integer rsl_fail;
2932
Harald Welte89d42e82017-12-17 16:42:41 +01002933 f_init(1);
Harald Welte4e9b9cc2017-12-14 18:31:02 +01002934
2935 rsl_fail := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "rsl_fail");
2936
2937 bts[0].rsl.vc_IPA.stop;
2938
2939 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "rsl_fail", rsl_fail+1);
2940
2941 setverdict(pass);
2942}
2943
2944/* TODO: Test OML link drop causes counter increment */
2945
Stefan Sperling830dc9d2018-02-12 21:08:28 +01002946/* The body of TC_rsl_unknown_unit_id() and TC_oml_unknown_unit_id() tests. */
2947function f_ipa_unknown_unit_id(integer mp_bsc_ipa_port) runs on test_CT return boolean {
2948 timer T := 10.0;
2949
2950 bts[0].rsl.id := "IPA-0-RSL";
2951 bts[0].rsl.vc_IPA := IPA_Emulation_CT.create(bts[0].rsl.id & "-IPA");
2952 bts[0].rsl.ccm_pars := c_IPA_default_ccm_pars;
2953 bts[0].rsl.ccm_pars.name := "Osmocom TTCN-3 BTS Simulator";
Oliver Smith92c2bdb2019-08-20 15:11:24 +02002954 bts[0].rsl.ccm_pars.unit_id := "99/0/0"; /* value which is unknown at BTS */
Stefan Sperling830dc9d2018-02-12 21:08:28 +01002955
Stefan Sperling830dc9d2018-02-12 21:08:28 +01002956 f_ipa_ctrl_start(mp_bsc_ip, mp_bsc_ctrl_port);
2957
2958 f_init_mgcp("VirtMSC");
2959
2960 /* start RSL/OML connection (XXX re-uses RSL port/protocol definitions for OML) */
2961 map(bts[0].rsl.vc_IPA:IPA_PORT, system:IPA);
2962 connect(bts[0].rsl.vc_IPA:IPA_RSL_PORT, self:IPA_RSL[0]);
2963 bts[0].rsl.vc_IPA.start(IPA_Emulation.main_client(mp_bsc_ip, mp_bsc_ipa_port, "", 10000, bts[0].rsl.ccm_pars));
2964
2965 /* wait for IPA OML link to connect and then disconnect */
2966 T.start;
2967 alt {
Vadim Yanitskiya2afacc2020-05-18 21:16:19 +07002968 [] IPA_RSL[0].receive(tr_ASP_IPA_EV(ASP_IPA_EVENT_DOWN)) {
Stefan Sperling830dc9d2018-02-12 21:08:28 +01002969 T.stop;
2970 return true;
2971 }
2972 [] IPA_RSL[0].receive { repeat }
2973 [] T.timeout {
Daniel Willmannafce8662018-07-06 23:11:32 +02002974 return false;
Stefan Sperling830dc9d2018-02-12 21:08:28 +01002975 }
2976 }
Stefan Sperling830dc9d2018-02-12 21:08:28 +01002977 return false;
2978}
2979
2980/* BSC should close an RSL connection from a BTS with unknown unit ID (OS#2714). */
2981testcase TC_rsl_unknown_unit_id() runs on test_CT {
2982 if (f_ipa_unknown_unit_id(mp_bsc_rsl_port)) {
2983 setverdict(pass);
2984 } else {
2985 setverdict(fail, "Timeout RSL waiting for connection to close");
2986 }
2987}
2988
2989
2990/* BSC should close an RSL connection from a BTS with unknown unit ID (OS#2714). */
2991testcase TC_oml_unknown_unit_id() runs on test_CT {
2992 if (f_ipa_unknown_unit_id(mp_bsc_oml_port)) {
2993 setverdict(pass);
2994 } else {
2995 setverdict(fail, "Timeout OML waiting for connection to close");
2996 }
2997}
2998
2999
Harald Weltec1a2fff2017-12-17 11:06:19 +01003000/***********************************************************************
Harald Welte6811d102019-04-14 22:23:14 +02003001 * "New world" test cases using RSL_Emulation + RAN_Emulation
Harald Weltec1a2fff2017-12-17 11:06:19 +01003002 ***********************************************************************/
3003
Harald Welte6811d102019-04-14 22:23:14 +02003004import from RAN_Emulation all;
Harald Weltec1a2fff2017-12-17 11:06:19 +01003005import from RSL_Emulation all;
3006import from MSC_ConnectionHandler all;
3007
3008type function void_fn(charstring id) runs on MSC_ConnHdlr;
3009
Harald Welte336820c2018-05-31 20:34:52 +02003010/* helper function to create and connect a MSC_ConnHdlr component */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003011private function f_connect_handler(inout MSC_ConnHdlr vc_conn, integer bssap_idx := 0) runs on test_CT {
3012 connect(vc_conn:RAN, g_bssap[bssap_idx].vc_RAN:PROC);
Daniel Willmann191e0d92018-01-17 12:44:35 +01003013 connect(vc_conn:MGCP_PROC, vc_MGCP:MGCP_PROC);
Harald Weltec1a2fff2017-12-17 11:06:19 +01003014 connect(vc_conn:RSL, bts[0].rsl.vc_RSL:CLIENT_PT);
Harald Weltef70df652018-01-29 22:00:23 +01003015 connect(vc_conn:RSL_PROC, bts[0].rsl.vc_RSL:RSL_PROC);
Philipp Maier88f4ae82018-03-01 14:00:58 +01003016 if (isvalue(bts[1])) {
Philipp Maier956a92f2018-02-16 10:58:07 +01003017 connect(vc_conn:RSL1, bts[1].rsl.vc_RSL:CLIENT_PT);
3018 connect(vc_conn:RSL1_PROC, bts[1].rsl.vc_RSL:RSL_PROC);
3019 }
Neels Hofmeyr91401012019-07-11 00:42:35 +02003020 if (isvalue(bts[2])) {
3021 connect(vc_conn:RSL2, bts[2].rsl.vc_RSL:CLIENT_PT);
3022 connect(vc_conn:RSL2_PROC, bts[2].rsl.vc_RSL:RSL_PROC);
3023 }
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003024 connect(vc_conn:BSSAP, g_bssap[bssap_idx].vc_RAN:CLIENT);
Daniel Willmann191e0d92018-01-17 12:44:35 +01003025 connect(vc_conn:MGCP, vc_MGCP:MGCP_CLIENT);
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +02003026 connect(vc_conn:MGCP_MULTI, vc_MGCP:MGCP_CLIENT_MULTI);
Daniel Willmannebdecc02020-08-12 15:30:17 +02003027 connect(vc_conn:STATSD_PROC, vc_STATSD:STATSD_PROC);
Harald Welte336820c2018-05-31 20:34:52 +02003028}
3029
3030function f_start_handler(void_fn fn, template (omit) TestHdlrParams pars := omit)
3031runs on test_CT return MSC_ConnHdlr {
3032 var charstring id := testcasename();
3033 var MSC_ConnHdlr vc_conn;
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003034 var integer bssap_idx := 0;
3035 if (isvalue(pars)) {
3036 bssap_idx := valueof(pars).mscpool.bssap_idx;
3037 }
Harald Welte336820c2018-05-31 20:34:52 +02003038 vc_conn := MSC_ConnHdlr.create(id);
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003039 f_connect_handler(vc_conn, bssap_idx);
Harald Weltea0630032018-03-20 21:09:55 +01003040 vc_conn.start(f_handler_init(fn, id, pars));
Harald Weltec1a2fff2017-12-17 11:06:19 +01003041 return vc_conn;
3042}
3043
Harald Weltea0630032018-03-20 21:09:55 +01003044/* first function inside ConnHdlr component; sets g_pars + starts function */
3045private function f_handler_init(void_fn fn, charstring id, template (omit) TestHdlrParams pars := omit)
3046runs on MSC_ConnHdlr {
3047 if (isvalue(pars)) {
3048 g_pars := valueof(pars);
3049 }
3050 fn.apply(id);
3051}
3052
Harald Welte3c86ea02018-05-10 22:28:05 +02003053/* Establish signalling channel (non-assignment case) followed by cipher mode */
3054private function f_tc_ciph_mode_a5(charstring id) runs on MSC_ConnHdlr {
Harald Welteed848512018-05-24 22:27:58 +02003055 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3056 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte3c86ea02018-05-10 22:28:05 +02003057 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeSIGNAL);
Philipp Maier23000732018-05-18 11:25:37 +02003058 ass_cmd.pdu.bssmap.assignmentRequest.circuitIdentityCode := omit;
3059 ass_cmd.pdu.bssmap.assignmentRequest.aoIPTransportLayer := omit;
3060 exp_compl.pdu.bssmap.assignmentComplete.circuitIdentityCode := omit;
3061 exp_compl.pdu.bssmap.assignmentComplete.aoIPTransportLayer := omit;
Harald Welte3c86ea02018-05-10 22:28:05 +02003062
Philipp Maier23000732018-05-18 11:25:37 +02003063 f_establish_fully(ass_cmd, exp_compl);
Harald Welte3c86ea02018-05-10 22:28:05 +02003064}
3065testcase TC_ciph_mode_a5_0() runs on test_CT {
3066 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02003067 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte3c86ea02018-05-10 22:28:05 +02003068 pars.encr := valueof(t_EncrParams('01'O, f_rnd_octstring(8)));
3069
3070 f_init(1, true);
3071 f_sleep(1.0);
3072 vc_conn := f_start_handler(refers(f_tc_ciph_mode_a5), pars);
3073 vc_conn.done;
3074}
3075testcase TC_ciph_mode_a5_1() runs on test_CT {
3076 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02003077 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte3c86ea02018-05-10 22:28:05 +02003078 pars.encr := valueof(t_EncrParams('02'O, f_rnd_octstring(8)));
3079
3080 f_init(1, true);
3081 f_sleep(1.0);
3082 vc_conn := f_start_handler(refers(f_tc_ciph_mode_a5), pars);
3083 vc_conn.done;
3084}
3085testcase TC_ciph_mode_a5_3() runs on test_CT {
3086 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02003087 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte3c86ea02018-05-10 22:28:05 +02003088 pars.encr := valueof(t_EncrParams('08'O, f_rnd_octstring(8)));
3089
3090 f_init(1, true);
3091 f_sleep(1.0);
3092 vc_conn := f_start_handler(refers(f_tc_ciph_mode_a5), pars);
3093 vc_conn.done;
3094}
3095
3096
3097/* establish initial channel, enable ciphering followed by assignment to ciphered channel */
Harald Welte651fcdc2018-05-10 20:23:16 +02003098private function f_tc_assignment_fr_a5(charstring id) runs on MSC_ConnHdlr {
Harald Welteed848512018-05-24 22:27:58 +02003099 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3100 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Weltec1a2fff2017-12-17 11:06:19 +01003101
Harald Welte552620d2017-12-16 23:21:36 +01003102 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3103 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
Harald Welte73cd2712017-12-17 00:44:52 +01003104
Harald Weltea0630032018-03-20 21:09:55 +01003105 f_establish_fully(ass_cmd, exp_compl);
Harald Welte552620d2017-12-16 23:21:36 +01003106}
Harald Welte552620d2017-12-16 23:21:36 +01003107testcase TC_assignment_fr_a5_0() runs on test_CT {
3108 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02003109 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte651fcdc2018-05-10 20:23:16 +02003110 pars.encr := valueof(t_EncrParams('01'O, f_rnd_octstring(8)));
Harald Welte552620d2017-12-16 23:21:36 +01003111
Harald Welte89d42e82017-12-17 16:42:41 +01003112 f_init(1, true);
Harald Welte552620d2017-12-16 23:21:36 +01003113 f_sleep(1.0);
Harald Welte651fcdc2018-05-10 20:23:16 +02003114 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5), pars);
Harald Welte552620d2017-12-16 23:21:36 +01003115 vc_conn.done;
3116}
Harald Welte552620d2017-12-16 23:21:36 +01003117testcase TC_assignment_fr_a5_1() runs on test_CT {
Harald Weltec1a2fff2017-12-17 11:06:19 +01003118 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02003119 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte651fcdc2018-05-10 20:23:16 +02003120 pars.encr := valueof(t_EncrParams('02'O, f_rnd_octstring(8)));
Harald Weltec1a2fff2017-12-17 11:06:19 +01003121
Harald Welte89d42e82017-12-17 16:42:41 +01003122 f_init(1, true);
Harald Weltec1a2fff2017-12-17 11:06:19 +01003123 f_sleep(1.0);
Harald Welte651fcdc2018-05-10 20:23:16 +02003124 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5), pars);
3125 vc_conn.done;
3126}
3127testcase TC_assignment_fr_a5_3() runs on test_CT {
3128 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02003129 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte651fcdc2018-05-10 20:23:16 +02003130 pars.encr := valueof(t_EncrParams('08'O, f_rnd_octstring(8)));
Harald Weltec1a2fff2017-12-17 11:06:19 +01003131
Harald Welte651fcdc2018-05-10 20:23:16 +02003132 f_init(1, true);
3133 f_sleep(1.0);
3134 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5), pars);
Harald Weltec1a2fff2017-12-17 11:06:19 +01003135 vc_conn.done;
3136}
3137
Harald Welte552620d2017-12-16 23:21:36 +01003138/* Expect ASSIGNMENT FAIL if mandatory IE is missing */
3139private function f_tc_assignment_fr_a5_1_codec_missing(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02003140 g_pars := f_gen_test_hdlr_pars();
Harald Welte552620d2017-12-16 23:21:36 +01003141 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
Harald Welteed848512018-05-24 22:27:58 +02003142 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte552620d2017-12-16 23:21:36 +01003143 const OCT8 kc := '0001020304050607'O;
3144
3145 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02003146 /* Omit: ass_cmd.pdu.bssmap.assignmentRequest.codecList */
3147
Harald Weltea0630032018-03-20 21:09:55 +01003148 f_establish_fully(ass_cmd, exp_fail);
Harald Welte552620d2017-12-16 23:21:36 +01003149}
Harald Welte552620d2017-12-16 23:21:36 +01003150testcase TC_assignment_fr_a5_1_codec_missing() runs on test_CT {
3151 var MSC_ConnHdlr vc_conn;
3152
Harald Welte89d42e82017-12-17 16:42:41 +01003153 f_init(1, true);
Harald Welte552620d2017-12-16 23:21:36 +01003154 f_sleep(1.0);
3155
Harald Welte8863fa12018-05-10 20:15:27 +02003156 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5_1_codec_missing));
Harald Welte552620d2017-12-16 23:21:36 +01003157 vc_conn.done;
3158}
3159
Harald Welte552620d2017-12-16 23:21:36 +01003160private function f_tc_assignment_fr_a5_4(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02003161 g_pars := f_gen_test_hdlr_pars();
Harald Welteed848512018-05-24 22:27:58 +02003162 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3163 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte552620d2017-12-16 23:21:36 +01003164 const OCT8 kc := '0001020304050607'O;
3165 const OCT16 kc128 := kc & kc;
3166
3167 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3168 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
Harald Weltea0630032018-03-20 21:09:55 +01003169 f_establish_fully(ass_cmd, exp_compl);
Harald Welte38b2a102017-12-23 02:42:58 +01003170 f_cipher_mode('10'O, kc, kc128, true);
Harald Welte552620d2017-12-16 23:21:36 +01003171 /* TODO: expect GSM0808_CAUSE_CIPHERING_ALGORITHM_NOT_SUPPORTED cause value */
Harald Welte552620d2017-12-16 23:21:36 +01003172}
Harald Welte552620d2017-12-16 23:21:36 +01003173testcase TC_assignment_fr_a5_4() runs on test_CT {
3174 var MSC_ConnHdlr vc_conn;
3175
Harald Welte89d42e82017-12-17 16:42:41 +01003176 f_init(1, true);
Harald Welte552620d2017-12-16 23:21:36 +01003177 f_sleep(1.0);
3178
Harald Welte8863fa12018-05-10 20:15:27 +02003179 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5_4));
Harald Welte552620d2017-12-16 23:21:36 +01003180 vc_conn.done;
3181}
3182
3183
Harald Welte4532e0a2017-12-23 02:05:44 +01003184private function f_tc_assignment_sign(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02003185 g_pars := f_gen_test_hdlr_pars();
Harald Welte4532e0a2017-12-23 02:05:44 +01003186 var template PDU_BSSAP exp_compl := tr_BSSMAP_AssignmentComplete(omit, omit);
Philipp Maier48604732018-10-09 15:00:37 +02003187 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte4532e0a2017-12-23 02:05:44 +01003188 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelTypeSIGNAL);
Daniel Willmannebdecc02020-08-12 15:30:17 +02003189
3190 f_statsd_reset();
Harald Weltea0630032018-03-20 21:09:55 +01003191 f_establish_fully(ass_cmd, exp_compl);
Daniel Willmannebdecc02020-08-12 15:30:17 +02003192
3193 var StatsDExpects expect := {
3194 { name := "TTCN3.bsc.0.assignment.attempted", mtype := "c", min := 1, max := 1},
3195 { name := "TTCN3.bsc.0.assignment.completed", mtype := "c", min := 1, max := 1}
3196 };
3197 f_statsd_expect(expect);
Harald Welte4532e0a2017-12-23 02:05:44 +01003198}
3199
3200testcase TC_assignment_sign() runs on test_CT {
3201 var MSC_ConnHdlr vc_conn;
3202
3203 f_init(1, true);
3204 f_sleep(1.0);
3205
Harald Welte8863fa12018-05-10 20:15:27 +02003206 vc_conn := f_start_handler(refers(f_tc_assignment_sign));
Harald Welte4532e0a2017-12-23 02:05:44 +01003207 vc_conn.done;
3208}
3209
Harald Welte60aa5762018-03-21 19:33:13 +01003210/***********************************************************************
3211 * Codec (list) testing
3212 ***********************************************************************/
3213
3214/* check if the given rsl_mode is compatible with the a_elem */
3215private function f_match_codec(BSSMAP_FIELD_CodecElement a_elem, RSL_IE_ChannelMode rsl_mode)
3216return boolean {
3217 select (a_elem.codecType) {
3218 case (GSM_FR) {
3219 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM1))) {
3220 return true;
3221 }
3222 }
3223 case (GSM_HR) {
3224 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_H, RSL_CMOD_SP_GSM1))) {
3225 return true;
3226 }
3227 }
3228 case (GSM_EFR) {
3229 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM2))) {
3230 return true;
3231 }
3232 }
3233 case (FR_AMR) {
3234 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM3))) {
3235 return true;
3236 }
3237 }
3238 case (HR_AMR) {
3239 if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_H, RSL_CMOD_SP_GSM3))) {
3240 return true;
3241 }
3242 }
3243 case else { }
3244 }
3245 return false;
3246}
3247
3248/* check if the given rsl_mode is compatible with the a_list */
3249private function f_match_codecs(BSSMAP_IE_SpeechCodecList a_list, RSL_IE_ChannelMode rsl_mode)
3250return boolean {
3251 for (var integer i := 0; i < sizeof(a_list); i := i+1) {
3252 if (f_match_codec(a_list.codecElements[i], rsl_mode)) {
3253 return true;
3254 }
3255 }
3256 return false;
3257}
3258
3259/* determine BSSMAP_IE_ChannelType from *first* element of BSSMAP_FIELD_CodecElement */
Philipp Maier61f6b572018-07-06 14:03:38 +02003260function f_BSSMAP_chtype_from_codec(BSSMAP_FIELD_CodecElement a_elem)
Harald Welte60aa5762018-03-21 19:33:13 +01003261return BSSMAP_IE_ChannelType {
3262 /* FIXME: actually look at all elements of BSSMAP_IE_SpeechCodecList */
3263 var BSSMAP_IE_ChannelType ret := valueof(ts_BSSMAP_IE_ChannelType);
3264 select (a_elem.codecType) {
3265 case (GSM_FR) {
3266 ret.channelRateAndType := ChRate_TCHF;
3267 ret.speechId_DataIndicator := Spdi_TCHF_FR;
3268 }
3269 case (GSM_HR) {
3270 ret.channelRateAndType := ChRate_TCHH;
3271 ret.speechId_DataIndicator := Spdi_TCHH_HR;
3272 }
3273 case (GSM_EFR) {
3274 ret.channelRateAndType := ChRate_TCHF;
3275 ret.speechId_DataIndicator := Spdi_TCHF_EFR;
3276 }
3277 case (FR_AMR) {
3278 ret.channelRateAndType := ChRate_TCHF;
3279 ret.speechId_DataIndicator := Spdi_TCHF_AMR;
3280 }
3281 case (HR_AMR) {
3282 ret.channelRateAndType := ChRate_TCHH;
3283 ret.speechId_DataIndicator := Spdi_TCHH_AMR;
3284 }
3285 case else {
3286 setverdict(fail, "Unsupported codec ", a_elem);
Daniel Willmannafce8662018-07-06 23:11:32 +02003287 mtc.stop;
Harald Welte60aa5762018-03-21 19:33:13 +01003288 }
3289 }
3290 return ret;
3291}
3292
Harald Weltea63b9102018-03-22 20:36:16 +01003293private function f_rsl_chmod_tmpl_from_codec(BSSMAP_FIELD_CodecElement a_elem)
3294return template RSL_IE_Body {
3295 var template RSL_IE_Body mode_ie := {
3296 chan_mode := {
3297 len := ?,
3298 reserved := ?,
3299 dtx_d := ?,
3300 dtx_u := ?,
3301 spd_ind := RSL_SPDI_SPEECH,
3302 ch_rate_type := -,
3303 coding_alg_rate := -
3304 }
3305 }
3306
3307 select (a_elem.codecType) {
3308 case (GSM_FR) {
3309 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_F;
3310 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM1;
3311 }
3312 case (GSM_HR) {
3313 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_H;
3314 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM1;
3315 }
3316 case (GSM_EFR) {
3317 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_F;
3318 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM2;
3319 }
3320 case (FR_AMR) {
3321 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_F;
3322 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM3;
3323 }
3324 case (HR_AMR) {
3325 mode_ie.chan_mode.ch_rate_type := RSL_CHRT_TCH_H;
3326 mode_ie.chan_mode.coding_alg_rate := RSL_CMOD_SP_GSM3;
3327 }
3328 }
3329 return mode_ie;
3330}
3331
Harald Welte60aa5762018-03-21 19:33:13 +01003332type record CodecListTest {
3333 BSSMAP_IE_SpeechCodecList codec_list,
3334 charstring id
3335}
3336type record of CodecListTest CodecListTests
3337
3338private function f_TC_assignment_codec(charstring id) runs on MSC_ConnHdlr {
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02003339 var PDU_BSSAP ass_cmd := f_gen_ass_req(g_pars.use_osmux);
3340 var template PDU_BSSAP exp_compl := f_gen_exp_compl(g_pars.use_osmux);
Harald Welte60aa5762018-03-21 19:33:13 +01003341
3342 /* puzzle together the ASSIGNMENT REQ for given codec[s] */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003343 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
Harald Welte79f3f542018-05-25 20:02:37 +02003344 ass_cmd.pdu.bssmap.assignmentRequest.codecList := g_pars.ass_codec_list;
3345 exp_compl.pdu.bssmap.assignmentComplete.speechCodec.codecElements[0] :=
3346 g_pars.ass_codec_list.codecElements[0];
Philipp Maierd0e64b02019-03-13 14:15:23 +01003347 if (isvalue(g_pars.expect_mr_s0_s7)) {
3348 exp_compl.pdu.bssmap.assignmentComplete.speechCodec.codecElements[0].s0_7 :=
3349 g_pars.expect_mr_s0_s7;
3350 }
Harald Welte79f3f542018-05-25 20:02:37 +02003351 }
Harald Welte60aa5762018-03-21 19:33:13 +01003352 ass_cmd.pdu.bssmap.assignmentRequest.channelType :=
3353 f_BSSMAP_chtype_from_codec(g_pars.ass_codec_list.codecElements[0]);
Harald Welte60aa5762018-03-21 19:33:13 +01003354 log("expecting ASS COMPL like this: ", exp_compl);
3355
3356 f_establish_fully(ass_cmd, exp_compl);
Harald Weltea63b9102018-03-22 20:36:16 +01003357
3358 /* Verify that the RSL-side activation actually matches our expectations */
3359 var RSL_Message rsl := f_rslem_get_last_act(RSL_PROC, 0, g_chan_nr);
3360
3361 var RSL_IE_Body mode_ie;
3362 if (f_rsl_find_ie(rsl, RSL_IE_CHAN_MODE, mode_ie) == false) {
3363 setverdict(fail, "Couldn't find CHAN_MODE IE");
Daniel Willmannafce8662018-07-06 23:11:32 +02003364 mtc.stop;
Harald Weltea63b9102018-03-22 20:36:16 +01003365 }
3366 var template RSL_IE_Body t_mode_ie := f_rsl_chmod_tmpl_from_codec(g_pars.ass_codec_list.codecElements[0]);
3367 if (not match(mode_ie, t_mode_ie)) {
3368 setverdict(fail, "RSL Channel Mode IE doesn't match expectation");
3369 }
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02003370
3371 var RSL_IE_Body mr_conf;
3372 if (g_pars.expect_mr_conf_ie != omit) {
3373 if (f_rsl_find_ie(rsl, RSL_IE_MR_CONFIG, mr_conf) == false) {
3374 setverdict(fail, "Missing MR CONFIG IE in RSL Chan Activ");
Daniel Willmannafce8662018-07-06 23:11:32 +02003375 mtc.stop;
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02003376 }
3377 log("found RSL MR CONFIG IE: ", mr_conf);
3378
3379 if (not match(mr_conf, g_pars.expect_mr_conf_ie)) {
3380 setverdict(fail, "RSL MR CONFIG IE does not match expectation. Expected: ",
3381 g_pars.expect_mr_conf_ie);
3382 }
3383 } else {
3384 if (f_rsl_find_ie(rsl, RSL_IE_MR_CONFIG, mr_conf) == true) {
3385 log("found RSL MR CONFIG IE: ", mr_conf);
3386 setverdict(fail, "Found MR CONFIG IE in RSL Chan Activ, expecting omit");
Daniel Willmannafce8662018-07-06 23:11:32 +02003387 mtc.stop;
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02003388 }
3389 }
Harald Welte60aa5762018-03-21 19:33:13 +01003390}
3391
Philipp Maierd0e64b02019-03-13 14:15:23 +01003392private function f_TC_assignment_codec_fail(charstring id) runs on MSC_ConnHdlr {
3393
3394 var PDU_BSSAP ass_cmd := f_gen_ass_req();
3395 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
3396
3397 /* puzzle together the ASSIGNMENT REQ for given codec[s] */
Neels Hofmeyrf246a922020-05-13 02:27:10 +02003398 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
Philipp Maierd0e64b02019-03-13 14:15:23 +01003399 ass_cmd.pdu.bssmap.assignmentRequest.codecList := g_pars.ass_codec_list;
3400 }
3401 ass_cmd.pdu.bssmap.assignmentRequest.channelType :=
3402 f_BSSMAP_chtype_from_codec(g_pars.ass_codec_list.codecElements[0]);
3403 log("expecting ASS FAIL like this: ", exp_fail);
3404
3405 f_establish_fully(ass_cmd, exp_fail);
3406}
3407
Harald Welte60aa5762018-03-21 19:33:13 +01003408testcase TC_assignment_codec_fr() runs on test_CT {
Philipp Maier48604732018-10-09 15:00:37 +02003409 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte60aa5762018-03-21 19:33:13 +01003410 var MSC_ConnHdlr vc_conn;
3411
3412 f_init(1, true);
3413 f_sleep(1.0);
3414
3415 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
Harald Welte8863fa12018-05-10 20:15:27 +02003416 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01003417 vc_conn.done;
3418}
3419
3420testcase TC_assignment_codec_hr() runs on test_CT {
Philipp Maier48604732018-10-09 15:00:37 +02003421 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte60aa5762018-03-21 19:33:13 +01003422 var MSC_ConnHdlr vc_conn;
3423
3424 f_init(1, true);
3425 f_sleep(1.0);
3426
3427 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR}));
Harald Welte8863fa12018-05-10 20:15:27 +02003428 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01003429 vc_conn.done;
3430}
3431
3432testcase TC_assignment_codec_efr() runs on test_CT {
Philipp Maier48604732018-10-09 15:00:37 +02003433 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte60aa5762018-03-21 19:33:13 +01003434 var MSC_ConnHdlr vc_conn;
3435
3436 f_init(1, true);
3437 f_sleep(1.0);
3438
3439 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecEFR}));
Harald Welte8863fa12018-05-10 20:15:27 +02003440 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01003441 vc_conn.done;
3442}
3443
Philipp Maierd0e64b02019-03-13 14:15:23 +01003444/* Allow 5,90k only (current default config) */
3445private function f_allow_amr_rate_5_90k() runs on test_CT {
3446 f_vty_enter_cfg_msc(BSCVTY, 0);
3447 f_vty_transceive(BSCVTY, "amr-config 12_2k forbidden");
3448 f_vty_transceive(BSCVTY, "amr-config 10_2k forbidden");
3449 f_vty_transceive(BSCVTY, "amr-config 7_95k forbidden");
3450 f_vty_transceive(BSCVTY, "amr-config 7_40k forbidden");
3451 f_vty_transceive(BSCVTY, "amr-config 6_70k forbidden");
3452 f_vty_transceive(BSCVTY, "amr-config 5_90k allowed");
3453 f_vty_transceive(BSCVTY, "amr-config 5_15k forbidden");
3454 f_vty_transceive(BSCVTY, "amr-config 4_75k forbidden");
3455 f_vty_transceive(BSCVTY, "exit");
3456 f_vty_transceive(BSCVTY, "exit");
3457}
3458
3459/* Allow 4,75k, 5,90k, 4,70k and 12,2k, which are the most common rates
3460 * ("Config-NB-Code = 1") */
3461private function f_allow_amr_rate_4_75k_5_90k_7_40k_12_20k() runs on test_CT {
3462 f_vty_enter_cfg_msc(BSCVTY, 0);
3463 f_vty_transceive(BSCVTY, "amr-config 12_2k allowed");
3464 f_vty_transceive(BSCVTY, "amr-config 10_2k forbidden");
3465 f_vty_transceive(BSCVTY, "amr-config 7_95k forbidden");
3466 f_vty_transceive(BSCVTY, "amr-config 7_40k allowed");
3467 f_vty_transceive(BSCVTY, "amr-config 6_70k forbidden");
3468 f_vty_transceive(BSCVTY, "amr-config 5_90k allowed");
3469 f_vty_transceive(BSCVTY, "amr-config 5_15k forbidden");
3470 f_vty_transceive(BSCVTY, "amr-config 4_75k allowed");
3471 f_vty_transceive(BSCVTY, "exit");
3472 f_vty_transceive(BSCVTY, "exit");
3473}
3474
Harald Welte60aa5762018-03-21 19:33:13 +01003475testcase TC_assignment_codec_amr_f() runs on test_CT {
Philipp Maier48604732018-10-09 15:00:37 +02003476 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte60aa5762018-03-21 19:33:13 +01003477 var MSC_ConnHdlr vc_conn;
Philipp Maier7695a0d2018-09-27 17:52:14 +02003478
3479 /* Note: This setups the codec configuration. The parameter payload in
3480 * mr_conf must be consistant with the parameter codecElements in pars
3481 * and also must match the amr-config in osmo-bsc.cfg! */
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02003482 var RSL_IE_Body mr_conf := {
3483 other := {
3484 len := 2,
3485 payload := '2804'O
3486 }
3487 };
Harald Welte60aa5762018-03-21 19:33:13 +01003488
Philipp Maier7695a0d2018-09-27 17:52:14 +02003489 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_F}));
Philipp Maier806f8f12019-03-12 12:13:41 +01003490 pars.ass_codec_list.codecElements[0].s0_7 := '00000100'B; /* 5,90k */
Philipp Maier7695a0d2018-09-27 17:52:14 +02003491 pars.ass_codec_list.codecElements[0].s8_15 := '01010111'B;
3492 pars.expect_mr_conf_ie := mr_conf;
3493
Harald Welte60aa5762018-03-21 19:33:13 +01003494 f_init(1, true);
3495 f_sleep(1.0);
3496
Harald Welte8863fa12018-05-10 20:15:27 +02003497 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01003498 vc_conn.done;
3499}
3500
3501testcase TC_assignment_codec_amr_h() runs on test_CT {
Philipp Maier48604732018-10-09 15:00:37 +02003502 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Harald Welte60aa5762018-03-21 19:33:13 +01003503 var MSC_ConnHdlr vc_conn;
Philipp Maier7695a0d2018-09-27 17:52:14 +02003504
3505 /* See note above */
Neels Hofmeyrbcf62bc2018-07-04 00:24:33 +02003506 var RSL_IE_Body mr_conf := {
3507 other := {
3508 len := 2,
3509 payload := '2804'O
3510 }
3511 };
Harald Welte60aa5762018-03-21 19:33:13 +01003512
Philipp Maier7695a0d2018-09-27 17:52:14 +02003513 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_H}));
Philipp Maier806f8f12019-03-12 12:13:41 +01003514 pars.ass_codec_list.codecElements[0].s0_7 := '00000100'B; /* 5,90k */
Philipp Maier7695a0d2018-09-27 17:52:14 +02003515 pars.ass_codec_list.codecElements[0].s8_15 := '00000111'B;
3516 pars.expect_mr_conf_ie := mr_conf;
3517
Harald Welte60aa5762018-03-21 19:33:13 +01003518 f_init(1, true);
3519 f_sleep(1.0);
3520
Harald Welte8863fa12018-05-10 20:15:27 +02003521 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
Harald Welte60aa5762018-03-21 19:33:13 +01003522 vc_conn.done;
3523}
3524
Philipp Maierd0e64b02019-03-13 14:15:23 +01003525function f_TC_assignment_codec_amr(boolean fr, octetstring mrconf, bitstring s8_s0, bitstring exp_s8_s0)
3526runs on test_CT {
3527
3528 var TestHdlrParams pars := f_gen_test_hdlr_pars();
3529 var MSC_ConnHdlr vc_conn;
3530
3531 /* See note above */
3532 var RSL_IE_Body mr_conf := {
3533 other := {
3534 len := lengthof(mrconf),
3535 payload := mrconf
3536 }
3537 };
3538
3539 if (fr) {
3540 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_F}));
3541 } else {
3542 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_H}));
3543 }
3544 pars.ass_codec_list.codecElements[0].s0_7 := s8_s0;
3545 pars.ass_codec_list.codecElements[0].s8_15 := '00000111'B;
3546 pars.expect_mr_conf_ie := mr_conf;
3547 pars.expect_mr_s0_s7 := exp_s8_s0;
3548
3549 f_init(1, true);
3550 f_allow_amr_rate_4_75k_5_90k_7_40k_12_20k();
3551 f_sleep(1.0);
3552
3553 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
3554 vc_conn.done;
3555 f_allow_amr_rate_5_90k();
3556}
3557
3558function f_TC_assignment_codec_amr_fail(boolean fr, bitstring s8_s0)
3559runs on test_CT {
3560
3561 var TestHdlrParams pars := f_gen_test_hdlr_pars();
3562 var MSC_ConnHdlr vc_conn;
3563
3564 if (fr) {
3565 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_F}));
3566 } else {
3567 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_H}));
3568 }
3569 pars.ass_codec_list.codecElements[0].s0_7 := s8_s0;
3570 pars.ass_codec_list.codecElements[0].s8_15 := '00000111'B;
3571
3572 f_init(1, true);
3573 f_allow_amr_rate_4_75k_5_90k_7_40k_12_20k();
3574 f_sleep(1.0);
3575
3576 vc_conn := f_start_handler(refers(f_TC_assignment_codec_fail), pars);
3577 vc_conn.done;
3578 f_allow_amr_rate_5_90k();
3579}
3580
3581
3582/* Set S1, we expect an AMR multirate configuration IE with all four rates
3583 * set. */
3584testcase TC_assignment_codec_amr_f_S1() runs on test_CT {
3585 f_TC_assignment_codec_amr(true, '289520882208'O, '00000010'B, '00000010'B);
3586}
3587
3588/* Set S1, we expect an AMR multirate configuration IE with the lower three
3589 * rates set. */
3590testcase TC_assignment_codec_amr_h_S1() runs on test_CT {
3591 f_TC_assignment_codec_amr(false, '2815208820'O, '00000010'B, '00000010'B);
3592}
3593
3594/* Set S1 and two other rates, we expect an AMR MULTIRATE CONFIGURATION IE with
3595 * all four rates (and only S1 set in the ASSIGNMENT COMPLETE) */
3596testcase TC_assignment_codec_amr_f_S124() runs on test_CT {
3597 f_TC_assignment_codec_amr(true, '289520882208'O, '00010110'B, '00000010'B);
3598}
3599
3600/* Set S1 and two other rates, we expect an AMR MULTIRATE CONFIGURATION IE with
3601 * all four rates (and only S1 set in the ASSIGNMENT COMPLETE) */
3602testcase TC_assignment_codec_amr_h_S124() runs on test_CT {
3603 f_TC_assignment_codec_amr(false, '2815208820'O, '00010110'B, '00000010'B);
3604}
3605
3606/* The following block of tests selects more and more rates until all four
3607 * possible rates are in the active set (full rate) */
3608testcase TC_assignment_codec_amr_f_S0() runs on test_CT {
3609 f_TC_assignment_codec_amr(true, '2801'O, '00000001'B, '00000001'B);
3610}
3611
3612testcase TC_assignment_codec_amr_f_S02() runs on test_CT {
3613 f_TC_assignment_codec_amr(true, '28052080'O, '00000101'B, '00000101'B);
3614}
3615
3616testcase TC_assignment_codec_amr_f_S024() runs on test_CT {
3617 f_TC_assignment_codec_amr(true, '2815208820'O, '00010101'B, '00010101'B);
3618}
3619
3620testcase TC_assignment_codec_amr_f_S0247() runs on test_CT {
3621 f_TC_assignment_codec_amr(true, '289520882208'O, '10010101'B, '10010101'B);
3622}
3623
3624/* The following block of tests selects more and more rates until all three
3625 * possible rates are in the active set (half rate) */
3626testcase TC_assignment_codec_amr_h_S0() runs on test_CT {
3627 f_TC_assignment_codec_amr(false, '2801'O, '00000001'B, '00000001'B);
3628}
3629
3630testcase TC_assignment_codec_amr_h_S02() runs on test_CT {
3631 f_TC_assignment_codec_amr(false, '28052080'O, '00000101'B, '00000101'B);
3632}
3633
3634testcase TC_assignment_codec_amr_h_S024() runs on test_CT {
3635 f_TC_assignment_codec_amr(false, '2815208820'O, '00010101'B, '00010101'B);
3636}
3637
3638/* The following block tests what happens when the MSC does offer rate
3639 * configurations that are not supported by the BSC. Normally such situations
3640 * should not happen because the MSC gets informed by the BSC in advance via
3641 * the L3 COMPLETE message which rates are applicable. The MSC should not try
3642 * to offer rates that are not applicable anyway. */
3643
3644testcase TC_assignment_codec_amr_h_S0247() runs on test_CT {
3645 /* Try to include 12,2k in into the active set even though the channel
3646 * is half rate only. The BSC is expected to remove the 12,0k */
3647 f_TC_assignment_codec_amr(false, '2815208820'O, '10010101'B, '00010101'B);
3648}
3649
3650testcase TC_assignment_codec_amr_f_S01234567() runs on test_CT {
3651 /* See what happens when all rates are selected at once. Since then
3652 * Also S1 is selected, this setting will be prefered and we should
3653 * get 12.2k, 7,40k, 5,90k, and 4,75k in the active set. */
3654 f_TC_assignment_codec_amr(true, '289520882208'O, '11111111'B, '00000010'B);
3655}
3656
3657testcase TC_assignment_codec_amr_f_S0234567() runs on test_CT {
3658 /* Same as above, but with S1 missing, the MSC is then expected to
3659 * select the currently supported rates, which are also 12.2k, 7,40k,
3660 * 5,90k, and 4,75k, into the active set. */
3661 f_TC_assignment_codec_amr(true, '289520882208'O, '11111101'B, '10010101'B);
3662}
3663
3664testcase TC_assignment_codec_amr_f_zero() runs on test_CT {
3665 /* Try to select no rates at all */
3666 f_TC_assignment_codec_amr_fail(true, '00000000'B);
3667}
3668
3669testcase TC_assignment_codec_amr_f_unsupp() runs on test_CT {
3670 /* Try to select only unsupported rates */
3671 f_TC_assignment_codec_amr_fail(true, '01101000'B);
3672}
3673
3674testcase TC_assignment_codec_amr_h_S7() runs on test_CT {
3675 /* Try to select 12,2k for half rate */
3676 f_TC_assignment_codec_amr_fail(false, '10000000'B);
3677}
3678
Philipp Maierac09bfc2019-01-08 13:41:39 +01003679private function f_disable_all_tch_f() runs on test_CT {
Philipp Maierc704a882019-01-29 15:58:52 +01003680 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 1 sub-slot 0 borken");
3681 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 2 sub-slot 0 borken");
3682 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 3 sub-slot 0 borken");
3683 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 4 sub-slot 0 borken");
Philipp Maierac09bfc2019-01-08 13:41:39 +01003684}
3685
3686private function f_disable_all_tch_h() runs on test_CT {
Philipp Maierc704a882019-01-29 15:58:52 +01003687 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 5 sub-slot 0 borken");
3688 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 5 sub-slot 1 borken");
Philipp Maierac09bfc2019-01-08 13:41:39 +01003689}
3690
3691private function f_enable_all_tch() runs on test_CT {
Philipp Maierc704a882019-01-29 15:58:52 +01003692 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 1 sub-slot 0 unused");
3693 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 2 sub-slot 0 unused");
3694 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 3 sub-slot 0 unused");
3695 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 4 sub-slot 0 unused");
3696 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 5 sub-slot 0 unused");
3697 f_vty_transceive(BSCVTY, "bts 0 trx 0 timeslot 5 sub-slot 1 unused");
Philipp Maierac09bfc2019-01-08 13:41:39 +01003698}
3699
3700/* Allow HR only */
3701private function f_TC_assignment_codec_xr_exhausted_req_hr(charstring id) runs on MSC_ConnHdlr {
3702 g_pars := f_gen_test_hdlr_pars();
3703 var PDU_BSSAP ass_cmd := f_gen_ass_req();
3704 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3705 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3706 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '09'O;
3707 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '05'O;
3708 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR}));
3709 f_establish_fully(ass_cmd, exp_compl);
3710}
3711
3712/* Allow FR only */
3713private function f_TC_assignment_codec_xr_exhausted_req_fr(charstring id) runs on MSC_ConnHdlr {
3714 g_pars := f_gen_test_hdlr_pars();
3715 var PDU_BSSAP ass_cmd := f_gen_ass_req();
3716 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3717 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3718 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '08'O;
3719 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '01'O;
3720 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
3721 f_establish_fully(ass_cmd, exp_compl);
3722}
3723
3724/* Allow HR only (expect assignment failure) */
3725private function f_TC_assignment_codec_xr_exhausted_req_hr_fail(charstring id) runs on MSC_ConnHdlr {
3726 g_pars := f_gen_test_hdlr_pars();
3727 var PDU_BSSAP ass_cmd := f_gen_ass_req();
3728 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
3729 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3730 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '09'O;
3731 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '05'O;
3732 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR}));
3733 f_establish_fully(ass_cmd, exp_fail);
3734}
3735
3736/* Allow FR only (expect assignment failure) */
3737private function f_TC_assignment_codec_xr_exhausted_req_fr_fail(charstring id) runs on MSC_ConnHdlr {
3738 g_pars := f_gen_test_hdlr_pars();
3739 var PDU_BSSAP ass_cmd := f_gen_ass_req();
3740 var template PDU_BSSAP exp_fail := tr_BSSMAP_AssignmentFail;
3741 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3742 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '08'O;
3743 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '01'O;
3744 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
3745 f_establish_fully(ass_cmd, exp_fail);
3746}
3747
3748/* Allow FR and HR, but prefer FR */
3749private function f_TC_assignment_codec_fr_exhausted_req_fr_hr(charstring id) runs on MSC_ConnHdlr {
3750 g_pars := f_gen_test_hdlr_pars();
3751 var PDU_BSSAP ass_cmd := f_gen_ass_req();
3752 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3753 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3754 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0A'O; /* Prefer FR */
3755 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8105'O;
3756 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR, ts_CodecHR}));
3757 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000101'B; /* Expect HR */
3758 f_establish_fully(ass_cmd, exp_compl);
3759}
3760
3761/* Allow FR and HR, but prefer HR */
3762private function f_TC_assignment_codec_fr_exhausted_req_hr_fr(charstring id) runs on MSC_ConnHdlr {
3763 g_pars := f_gen_test_hdlr_pars();
3764 var PDU_BSSAP ass_cmd := f_gen_ass_req();
3765 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3766 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3767 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0B'O; /* Prefer HR */
3768 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8501'O;
3769 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR, ts_CodecFR}));
3770 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000101'B; /* Expect HR */
3771 f_establish_fully(ass_cmd, exp_compl);
3772}
3773
3774/* Allow FR and HR, but prefer FR */
3775private function f_TC_assignment_codec_hr_exhausted_req_fr_hr(charstring id) runs on MSC_ConnHdlr {
3776 g_pars := f_gen_test_hdlr_pars();
3777 var PDU_BSSAP ass_cmd := f_gen_ass_req();
3778 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3779 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3780 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0A'O; /* Prefer FR */
3781 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8105'O;
3782 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR, ts_CodecHR}));
3783 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000001'B; /* Expect FR */
3784 f_establish_fully(ass_cmd, exp_compl);
3785}
3786
3787/* Allow FR and HR, but prefer HR */
3788private function f_TC_assignment_codec_hr_exhausted_req_hr_fr(charstring id) runs on MSC_ConnHdlr {
3789 g_pars := f_gen_test_hdlr_pars();
3790 var PDU_BSSAP ass_cmd := f_gen_ass_req();
3791 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3792 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3793 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0B'O; /* Prefer HR */
3794 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8501'O;
3795 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR, ts_CodecFR}));
3796 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000001'B; /* Expect FR */
3797 f_establish_fully(ass_cmd, exp_compl);
3798}
3799
3800/* Request a HR channel while all FR channels are exhausted, this is expected
3801 * to work without conflicts */
3802testcase TC_assignment_codec_fr_exhausted_req_hr() runs on test_CT {
3803 var MSC_ConnHdlr vc_conn;
3804 f_init(1, true);
3805 f_sleep(1.0);
3806 f_enable_all_tch();
3807 f_disable_all_tch_f();
3808 vc_conn := f_start_handler(refers(f_TC_assignment_codec_xr_exhausted_req_hr));
3809 vc_conn.done;
3810 f_enable_all_tch();
3811 setverdict(pass);
3812}
3813
3814/* Request a FR channel while all FR channels are exhausted, this is expected
3815 * to fail. */
3816testcase TC_assignment_codec_fr_exhausted_req_fr() runs on test_CT {
3817 var MSC_ConnHdlr vc_conn;
3818 f_init(1, true);
3819 f_sleep(1.0);
3820 f_enable_all_tch();
3821 f_disable_all_tch_f();
3822 vc_conn := f_start_handler(refers(f_TC_assignment_codec_xr_exhausted_req_fr_fail));
3823 vc_conn.done;
3824 f_enable_all_tch();
3825 setverdict(pass);
3826}
3827
3828/* Request a FR (prefered) or alternatively a HR channel while all FR channels
3829 * are exhausted, this is expected to be resolved by selecting a HR channel. */
3830testcase TC_assignment_codec_fr_exhausted_req_fr_hr() runs on test_CT {
3831 var MSC_ConnHdlr vc_conn;
3832 f_init(1, true);
3833 f_sleep(1.0);
3834 f_enable_all_tch();
3835 f_disable_all_tch_f();
3836 vc_conn := f_start_handler(refers(f_TC_assignment_codec_fr_exhausted_req_fr_hr));
3837 vc_conn.done;
3838 f_enable_all_tch();
3839 setverdict(pass);
3840}
3841
3842/* Request a HR (prefered) or alternatively a FR channel while all FR channels
3843 * are exhausted, this is expected to work without conflicts. */
3844testcase TC_assignment_codec_fr_exhausted_req_hr_fr() runs on test_CT {
3845 var MSC_ConnHdlr vc_conn;
3846 f_init(1, true);
3847 f_sleep(1.0);
3848 f_enable_all_tch();
3849 f_disable_all_tch_f();
3850 vc_conn := f_start_handler(refers(f_TC_assignment_codec_fr_exhausted_req_hr_fr));
3851 vc_conn.done;
3852 f_enable_all_tch();
3853 setverdict(pass);
3854}
3855
3856/* Request a FR channel while all HR channels are exhausted, this is expected
3857 * to work without conflicts */
3858testcase TC_assignment_codec_hr_exhausted_req_fr() runs on test_CT {
3859 var MSC_ConnHdlr vc_conn;
3860 f_init(1, true);
3861 f_sleep(1.0);
3862 f_enable_all_tch();
3863 f_disable_all_tch_h();
3864 vc_conn := f_start_handler(refers(f_TC_assignment_codec_xr_exhausted_req_fr));
3865 vc_conn.done;
3866 f_enable_all_tch();
3867 setverdict(pass);
3868}
3869
3870/* Request a HR channel while all HR channels are exhausted, this is expected
3871 * to fail. */
3872testcase TC_assignment_codec_hr_exhausted_req_hr() runs on test_CT {
3873 var MSC_ConnHdlr vc_conn;
3874 f_init(1, true);
3875 f_sleep(1.0);
3876 f_enable_all_tch();
3877 f_disable_all_tch_h();
3878 vc_conn := f_start_handler(refers(f_TC_assignment_codec_xr_exhausted_req_hr_fail));
3879 vc_conn.done;
3880 f_enable_all_tch();
3881 setverdict(pass);
3882}
3883
3884/* Request a HR (prefered) or alternatively a FR channel while all HR channels
3885 * are exhausted, this is expected to be resolved by selecting a FR channel. */
3886testcase TC_assignment_codec_hr_exhausted_req_hr_fr() runs on test_CT {
3887 var MSC_ConnHdlr vc_conn;
3888 f_init(1, true);
3889 f_sleep(1.0);
3890 f_enable_all_tch();
3891 f_disable_all_tch_h();
3892 vc_conn := f_start_handler(refers(f_TC_assignment_codec_hr_exhausted_req_hr_fr));
3893 vc_conn.done;
3894 f_enable_all_tch();
3895 setverdict(pass);
3896}
3897
3898/* Request a FR (prefered) or alternatively a HR channel while all HR channels
3899 * are exhausted, this is expected to work without conflicts. */
3900testcase TC_assignment_codec_hr_exhausted_req_fr_hr() runs on test_CT {
3901 var MSC_ConnHdlr vc_conn;
3902 f_init(1, true);
3903 f_sleep(1.0);
3904 f_enable_all_tch();
3905 f_disable_all_tch_h();
3906 vc_conn := f_start_handler(refers(f_TC_assignment_codec_hr_exhausted_req_fr_hr));
3907 vc_conn.done;
3908 f_enable_all_tch();
3909 setverdict(pass);
3910}
3911
3912/* Allow FR and HR, but prefer HR */
3913private function f_TC_assignment_codec_req_hr_fr(charstring id) runs on MSC_ConnHdlr {
3914 g_pars := f_gen_test_hdlr_pars();
3915 var PDU_BSSAP ass_cmd := f_gen_ass_req();
3916 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3917 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3918 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0B'O; /* Prefer HR */
3919 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8501'O;
3920 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR, ts_CodecFR}));
3921 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000101'B; /* Expect HR */
3922 f_establish_fully(ass_cmd, exp_compl);
3923}
3924
3925/* Allow FR and HR, but prefer FR */
3926private function f_TC_assignment_codec_req_fr_hr(charstring id) runs on MSC_ConnHdlr {
3927 g_pars := f_gen_test_hdlr_pars();
3928 var PDU_BSSAP ass_cmd := f_gen_ass_req();
3929 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
3930 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
3931 ass_cmd.pdu.bssmap.assignmentRequest.channelType.channelRateAndType := '0A'O; /* Prefer FR */
3932 ass_cmd.pdu.bssmap.assignmentRequest.channelType.speechId_DataIndicator := '8105'O;
3933 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR, ts_CodecHR}));
3934 exp_compl.pdu.bssmap.assignmentComplete.speechVersion.speechVersionIdentifier := '0000001'B; /* Expect FR */
3935 f_establish_fully(ass_cmd, exp_compl);
3936}
3937
3938/* Request a HR (prefered) or alternatively a FR channel, it is expected that
3939 * HR, which is the prefered type, is selected. */
3940testcase TC_assignment_codec_req_hr_fr() runs on test_CT {
3941 var MSC_ConnHdlr vc_conn;
3942 f_init(1, true);
3943 f_sleep(1.0);
3944 f_enable_all_tch();
3945 vc_conn := f_start_handler(refers(f_TC_assignment_codec_req_hr_fr));
3946 vc_conn.done;
3947 setverdict(pass);
3948}
3949
3950/* Request a FR (prefered) or alternatively a HR channel, it is expected that
3951 * FR, which is the prefered type, is selected. */
3952testcase TC_assignment_codec_req_fr_hr() runs on test_CT {
3953 var MSC_ConnHdlr vc_conn;
3954 f_init(1, true);
3955 f_sleep(1.0);
3956 f_enable_all_tch();
3957 vc_conn := f_start_handler(refers(f_TC_assignment_codec_req_fr_hr));
3958 vc_conn.done;
3959 setverdict(pass);
3960}
3961
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02003962testcase TC_assignment_osmux() runs on test_CT {
3963 var TestHdlrParams pars := f_gen_test_hdlr_pars();
3964 var MSC_ConnHdlr vc_conn;
3965
3966 /* See note above */
3967 var RSL_IE_Body mr_conf := {
3968 other := {
3969 len := 2,
3970 payload := '2804'O
3971 }
3972 };
3973
3974 pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_H}));
3975 pars.ass_codec_list.codecElements[0].s0_7 := '00000100'B; /* 5,90k */
3976 pars.ass_codec_list.codecElements[0].s8_15 := '00000111'B;
3977 pars.expect_mr_conf_ie := mr_conf;
3978 pars.use_osmux := true;
3979
3980 f_init(1, true, true);
3981 f_sleep(1.0);
3982
3983 vc_conn := f_start_handler(refers(f_TC_assignment_codec), pars);
3984 vc_conn.done;
3985}
3986
Neels Hofmeyr92b12b72018-09-18 14:30:23 +02003987/* test the procedure of the MSC requesting a Classmark Update:
3988 * a) BSSMAP Classmark Request should result in RR CLASSMARK ENQUIRY,
3989 * b) L3 RR CLASSMARK CHANGE should result in BSSMAP CLASSMARK UPDATE */
Harald Welte898113b2018-01-31 18:32:21 +01003990private function f_tc_classmark(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02003991 g_pars := f_gen_test_hdlr_pars();
3992
Harald Weltea0630032018-03-20 21:09:55 +01003993 f_create_chan_and_exp();
Harald Welte898113b2018-01-31 18:32:21 +01003994 /* we should now have a COMPL_L3 at the MSC */
3995 BSSAP.receive(tr_BSSMAP_ComplL3);
3996
Neels Hofmeyr92b12b72018-09-18 14:30:23 +02003997 BSSAP.send(ts_BSSMAP_ClassmarkRequest);
3998 RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_CM_ENQUIRY));
3999
Harald Welte898113b2018-01-31 18:32:21 +01004000 f_rsl_send_l3(ts_RRM_CM_CHG(valueof(ts_CM2)));
4001 BSSAP.receive(tr_BSSMAP_ClassmarkUpd(?, omit));
4002 setverdict(pass);
4003}
4004testcase TC_classmark() runs on test_CT {
4005 var MSC_ConnHdlr vc_conn;
4006 f_init(1, true);
4007 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02004008 vc_conn := f_start_handler(refers(f_tc_classmark));
Harald Welte898113b2018-01-31 18:32:21 +01004009 vc_conn.done;
4010}
4011
Harald Welteeddf0e92020-06-21 19:42:15 +02004012/* Send a CommonID from the simulated MSC and verify that the information is used to
4013 * fill BSC-internal data structures (specifically, bsc_subscr associated with subscr_conn) */
4014private function f_tc_common_id(charstring id) runs on MSC_ConnHdlr {
4015 g_pars := f_gen_test_hdlr_pars();
4016 f_MscConnHdlr_init_vty();
4017
4018 f_create_chan_and_exp();
4019 /* we should now have a COMPL_L3 at the MSC */
4020 BSSAP.receive(tr_BSSMAP_ComplL3);
4021
4022 /* Send CommonID */
4023 BSSAP.send(ts_BSSMAP_CommonId(g_pars.imsi));
4024
4025 /* Use VTY to verify that the IMSI of the subscr_conn is set */
4026 var charstring regex := "*(IMSI: " & hex2str(g_pars.imsi) & ")*";
4027 f_vty_transceive_match_regexp_retry(BSCVTY, "show conns", regex, 0, 4, 1.0);
4028
4029 setverdict(pass);
4030}
4031testcase TC_common_id() runs on test_CT {
4032 var MSC_ConnHdlr vc_conn;
4033 f_init(1, true);
4034 f_sleep(1.0);
4035 vc_conn := f_start_handler(refers(f_tc_common_id));
4036 vc_conn.done;
4037}
4038
Harald Weltee3bd6582018-01-31 22:51:25 +01004039private function f_est_single_l3(template PDU_ML3_MS_NW l3) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02004040 g_pars := f_gen_test_hdlr_pars();
Harald Weltea0630032018-03-20 21:09:55 +01004041 f_create_chan_and_exp();
Harald Welte898113b2018-01-31 18:32:21 +01004042 /* we should now have a COMPL_L3 at the MSC */
4043 BSSAP.receive(tr_BSSMAP_ComplL3);
4044
Harald Weltee3bd6582018-01-31 22:51:25 +01004045 /* send the single message we want to send */
4046 f_rsl_send_l3(l3);
4047}
4048
4049private function f_bssap_expect_nothing(float sec := 5.00) runs on MSC_ConnHdlr {
4050 timer T := sec;
4051 var PDU_BSSAP bssap;
Harald Welte898113b2018-01-31 18:32:21 +01004052 T.start;
4053 alt {
Harald Weltee3bd6582018-01-31 22:51:25 +01004054 [] BSSAP.receive(PDU_BSSAP:?) -> value bssap {
4055 setverdict(fail, "Unexpected BSSMAP ", bssap);
Daniel Willmannafce8662018-07-06 23:11:32 +02004056 mtc.stop;
Harald Welte898113b2018-01-31 18:32:21 +01004057 }
4058 [] T.timeout {
4059 setverdict(pass);
4060 }
4061 }
4062}
4063
Harald Weltee3bd6582018-01-31 22:51:25 +01004064/* unsolicited ASSIGNMENT FAIL (without ASSIGN) from MS shouldn't bring BSC down */
4065private function f_tc_unsol_ass_fail(charstring id) runs on MSC_ConnHdlr {
4066 f_est_single_l3(ts_RRM_AssignmentFailure('00'O));
4067 f_bssap_expect_nothing();
4068}
Harald Welte898113b2018-01-31 18:32:21 +01004069testcase TC_unsol_ass_fail() runs on test_CT {
4070 var MSC_ConnHdlr vc_conn;
4071 f_init(1, true);
4072 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02004073 vc_conn := f_start_handler(refers(f_tc_unsol_ass_fail));
Harald Welte898113b2018-01-31 18:32:21 +01004074 vc_conn.done;
4075}
Harald Welte552620d2017-12-16 23:21:36 +01004076
Harald Welteea99a002018-01-31 20:46:43 +01004077
4078/* unsolicited ASSIGNMENT COMPLETE (without ASSIGN) from MS shouldn't bring BSC down */
4079private function f_tc_unsol_ass_compl(charstring id) runs on MSC_ConnHdlr {
Harald Weltee3bd6582018-01-31 22:51:25 +01004080 f_est_single_l3(ts_RRM_AssignmentComplete('00'O));
4081 f_bssap_expect_nothing();
Harald Welteea99a002018-01-31 20:46:43 +01004082}
4083testcase TC_unsol_ass_compl() runs on test_CT {
4084 var MSC_ConnHdlr vc_conn;
4085 f_init(1, true);
4086 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02004087 vc_conn := f_start_handler(refers(f_tc_unsol_ass_compl));
Harald Welteea99a002018-01-31 20:46:43 +01004088 vc_conn.done;
4089}
4090
4091
Harald Weltefbf9b5e2018-01-31 20:41:23 +01004092/* unsolicited HANDOVER FAIL (without ASSIGN) from MS shouldn't bring BSC down */
4093private function f_tc_unsol_ho_fail(charstring id) runs on MSC_ConnHdlr {
Harald Weltee3bd6582018-01-31 22:51:25 +01004094 f_est_single_l3(ts_RRM_HandoverFailure('00'O));
4095 f_bssap_expect_nothing();
Harald Weltefbf9b5e2018-01-31 20:41:23 +01004096}
Harald Weltefbf9b5e2018-01-31 20:41:23 +01004097testcase TC_unsol_ho_fail() runs on test_CT {
4098 var MSC_ConnHdlr vc_conn;
4099 f_init(1, true);
4100 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02004101 vc_conn := f_start_handler(refers(f_tc_unsol_ho_fail));
Harald Weltefbf9b5e2018-01-31 20:41:23 +01004102 vc_conn.done;
4103}
4104
4105
Harald Weltee3bd6582018-01-31 22:51:25 +01004106/* short message from MS should be ignored */
4107private function f_tc_err_82_short_msg(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02004108 g_pars := f_gen_test_hdlr_pars();
Harald Weltea0630032018-03-20 21:09:55 +01004109 f_create_chan_and_exp();
Harald Weltee3bd6582018-01-31 22:51:25 +01004110 /* we should now have a COMPL_L3 at the MSC */
4111 BSSAP.receive(tr_BSSMAP_ComplL3);
4112
4113 /* send short message */
4114 RSL.send(ts_RSL_DATA_IND(g_chan_nr, valueof(ts_RslLinkID_DCCH(0)), ''O));
4115 f_bssap_expect_nothing();
4116}
4117testcase TC_err_82_short_msg() runs on test_CT {
4118 var MSC_ConnHdlr vc_conn;
4119 f_init(1, true);
4120 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02004121 vc_conn := f_start_handler(refers(f_tc_err_82_short_msg));
Harald Weltee3bd6582018-01-31 22:51:25 +01004122 vc_conn.done;
4123}
4124
4125
Harald Weltee9e02e42018-01-31 23:36:25 +01004126/* 24.008 8.4 Unknown message must trigger RR STATUS */
4127private function f_tc_err_84_unknown_msg(charstring id) runs on MSC_ConnHdlr {
4128 f_est_single_l3(ts_RRM_UL_REL('00'O));
4129 timer T := 3.0
4130 alt {
4131 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_STATUS)) {
4132 setverdict(pass);
4133 }
4134 [] BSSAP.receive { setverdict(fail, "unexpected BSSAP"); }
Harald Welte458fd372018-03-21 11:26:23 +01004135 [] T.timeout { setverdict(fail, "Timeout waiting for RR STATUS"); }
Harald Weltee9e02e42018-01-31 23:36:25 +01004136 }
4137}
4138testcase TC_err_84_unknown_msg() runs on test_CT {
4139 var MSC_ConnHdlr vc_conn;
4140 f_init(1, true);
4141 f_sleep(1.0);
Harald Welte8863fa12018-05-10 20:15:27 +02004142 vc_conn := f_start_handler(refers(f_tc_err_84_unknown_msg));
Harald Weltee9e02e42018-01-31 23:36:25 +01004143 vc_conn.done;
4144}
4145
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004146/***********************************************************************
4147 * Handover
4148 ***********************************************************************/
4149
Harald Welte94e0c342018-04-07 11:33:23 +02004150/* execute a "bts <0-255> trx <0-255> timeslot <0-7> " command on given Dchan */
4151private function f_vty_ts_action(charstring suffix, integer bts_nr, integer trx_nr, integer ts_nr)
4152runs on test_CT {
4153 var charstring cmd := "bts "&int2str(bts_nr)&" trx "&int2str(trx_nr)&
4154 " timeslot "&int2str(ts_nr)&" ";
4155 f_vty_transceive(BSCVTY, cmd & suffix);
4156}
4157
Harald Welte261af4b2018-02-12 21:20:39 +01004158/* 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 +07004159private function f_vty_ss_action(TELNETasp_PT pt, charstring suffix,
4160 uint8_t bts_nr, uint8_t trx_nr,
4161 in RslChannelNr chan_nr)
4162{
Harald Welte261af4b2018-02-12 21:20:39 +01004163 /* FIXME: resolve those from component-global state */
4164 var integer ts_nr := chan_nr.tn;
4165 var integer ss_nr;
4166 if (ischosen(chan_nr.u.ch0)) {
4167 ss_nr := 0;
4168 } else if (ischosen(chan_nr.u.lm)) {
4169 ss_nr := chan_nr.u.lm.sub_chan;
4170 } else if (ischosen(chan_nr.u.sdcch4)) {
4171 ss_nr := chan_nr.u.sdcch4.sub_chan;
4172 } else if (ischosen(chan_nr.u.sdcch8)) {
4173 ss_nr := chan_nr.u.sdcch8.sub_chan;
4174 } else {
4175 setverdict(fail, "Invalid ChanNr ", chan_nr);
Daniel Willmannafce8662018-07-06 23:11:32 +02004176 mtc.stop;
Harald Welte261af4b2018-02-12 21:20:39 +01004177 }
4178
4179 var charstring cmd := "bts "&int2str(bts_nr)&" trx "&int2str(trx_nr)&
4180 " timeslot "&int2str(ts_nr)&" sub-slot "&int2str(ss_nr)&" ";
Vadim Yanitskiy00070722020-09-02 17:27:57 +07004181 f_vty_transceive(pt, cmd & suffix);
Harald Welte261af4b2018-02-12 21:20:39 +01004182}
4183
Neels Hofmeyr91401012019-07-11 00:42:35 +02004184/* Even though the VTY command to trigger handover takes a new BTS number as argument, behind the scenes osmo-bsc always
4185 * translates that to a target ARFCN+BSIC first. See bsc_vty.c trigger_ho_or_as(), which puts the selected BTS' neighbor
4186 * ident key (ARFCN + BSIC) in the struct passed on to handover_request(). handover_start() then resolves that to a
4187 * viable actual neighbor cell. So from the internal osmo-bsc perspective, we always request handover to an ARFCN + BSIC
4188 * pair, not really to a specific BTS number. */
Vadim Yanitskiy00070722020-09-02 17:27:57 +07004189private function f_vty_handover(TELNETasp_PT pt, uint8_t bts_nr, uint8_t trx_nr,
4190 in RslChannelNr chan_nr, uint8_t new_bts_nr)
4191{
4192 f_vty_ss_action(pt, "handover " & int2str(new_bts_nr), bts_nr, trx_nr, chan_nr);
Harald Welte261af4b2018-02-12 21:20:39 +01004193}
4194
4195/* intra-BSC hand-over between BTS0 and BTS1 */
4196private function f_tc_ho_int(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02004197 g_pars := f_gen_test_hdlr_pars();
Harald Welteed848512018-05-24 22:27:58 +02004198 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4199 var PDU_BSSAP ass_cmd := f_gen_ass_req();
Harald Welte261af4b2018-02-12 21:20:39 +01004200 const OCT8 kc := '0001020304050607'O;
4201
4202 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4203 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
4204
Harald Weltea0630032018-03-20 21:09:55 +01004205 f_establish_fully(ass_cmd, exp_compl);
Neels Hofmeyr666f0432020-07-04 00:53:07 +02004206 f_bts_0_cfg(BSCVTY, {"neighbor bts 1"});
Harald Welte261af4b2018-02-12 21:20:39 +01004207
4208 var HandoverState hs := {
4209 rr_ho_cmpl_seen := false,
4210 handover_done := false,
4211 old_chan_nr := -
4212 };
4213 /* issue hand-over command on VTY */
Vadim Yanitskiy00070722020-09-02 17:27:57 +07004214 f_vty_handover(BSCVTY, 0, 0, g_chan_nr, 1);
Harald Welte261af4b2018-02-12 21:20:39 +01004215 /* temporarily suspend DChan processing on BTS1 to avoid race with RSLEM_register */
4216 f_rslem_suspend(RSL1_PROC);
Philipp Maier3e2af5d2018-07-11 17:01:05 +02004217
4218 /* From the MGW perspective, a handover is is characterized by
4219 * performing one MDCX operation with the MGW. So we expect to see
4220 * one more MDCX during handover. */
4221 g_media.mgcp_conn[0].mdcx_seen_exp := g_media.mgcp_conn[0].crcx_seen_exp + 1;
4222
Harald Welte261af4b2018-02-12 21:20:39 +01004223 alt {
4224 [] as_handover(hs);
Harald Welte261af4b2018-02-12 21:20:39 +01004225 }
Philipp Maier3e2af5d2018-07-11 17:01:05 +02004226
Philipp Maier4dae0652018-11-12 12:03:26 +01004227 /* Since this is an internal handover we expect the BSC to inform the
4228 * MSC about the event */
4229 BSSAP.receive(tr_BSSMAP_HandoverPerformed);
4230
Philipp Maier3e2af5d2018-07-11 17:01:05 +02004231 /* Check the amount of MGCP transactions is still consistant with the
4232 * test expectation */
4233 f_check_mgcp_expectations()
Neels Hofmeyr861a4c12018-11-07 01:23:17 +01004234 f_sleep(0.5);
Harald Welte261af4b2018-02-12 21:20:39 +01004235}
4236
4237testcase TC_ho_int() runs on test_CT {
4238 var MSC_ConnHdlr vc_conn;
4239 f_init(2, true);
4240 f_sleep(1.0);
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004241
4242 f_ctrs_bsc_and_bts_init();
4243
Harald Welte8863fa12018-05-10 20:15:27 +02004244 vc_conn := f_start_handler(refers(f_tc_ho_int));
Harald Welte261af4b2018-02-12 21:20:39 +01004245 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004246
4247 /* from f_establish_fully() */
4248 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
4249 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
4250 /* from handover */
4251 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
4252 f_ctrs_bsc_and_bts_add(0, "handover:completed");
4253 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
4254 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:completed");
4255 f_ctrs_bsc_and_bts_verify();
Harald Welte261af4b2018-02-12 21:20:39 +01004256}
Harald Weltee9e02e42018-01-31 23:36:25 +01004257
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004258/* Expecting MGCP to DLCX the endpoint's two connections: towards BTS and towards MSC */
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02004259private function f_expect_dlcx_conns() runs on MSC_ConnHdlr {
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004260 var MgcpCommand mgcp;
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +02004261 var template MgcpResponse mgcp_resp;
4262 var MGCP_RecvFrom mrf;
4263 var template MgcpMessage msg_resp;
4264 var template MgcpMessage msg_dlcx := {
4265 command := tr_DLCX()
4266 }
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004267
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +02004268 if (g_pars.aoip) {
4269 MGCP.receive(tr_DLCX()) -> value mgcp {
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004270 log("Got first DLCX: ", mgcp);
4271 MGCP.send(ts_DLCX_ACK2(mgcp.line.trans_id));
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +02004272 };
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004273
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004274 MGCP.receive(tr_DLCX()) -> value mgcp {
4275 log("Got second DLCX: ", mgcp);
4276 MGCP.send(ts_DLCX_ACK2(mgcp.line.trans_id));
4277 };
Pau Espin Pedrolfd02ad42019-06-18 17:45:20 +02004278 } else {
4279 /* For SCCPLite, BSC doesn't handle the MSC-side */
4280 MGCP_MULTI.receive(tr_MGCP_RecvFrom_any(msg_dlcx)) -> value mrf {
4281 log("Got first DLCX: ", mrf.msg.command);
4282 msg_resp := {
4283 response := ts_DLCX_ACK2(mrf.msg.command.line.trans_id)
4284 }
4285 MGCP_MULTI.send(t_MGCP_SendToMrf(mrf, msg_resp));
4286 };
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004287 }
4288
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02004289 BSSAP.receive(tr_BSSMAP_ClearComplete);
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004290}
4291
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004292private function f_tc_ho_out_of_this_bsc(charstring id) runs on MSC_ConnHdlr {
Philipp Maier48604732018-10-09 15:00:37 +02004293 g_pars := f_gen_test_hdlr_pars();
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004294
4295 var PDU_BSSAP ass_req := f_gen_ass_req();
4296 ass_req.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4297 ass_req.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
4298 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4299 f_establish_fully(ass_req, exp_compl);
4300
Neels Hofmeyr666f0432020-07-04 00:53:07 +02004301 f_bts_0_cfg(BSCVTY, {"neighbor lac 99 arfcn 123 bsic any"});
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004302 f_vty_transceive(BSCVTY, "handover any to arfcn 123 bsic any");
4303
4304 BSSAP.receive(tr_BSSMAP_HandoverRequired);
4305
4306 f_sleep(0.5);
4307 /* The MSC negotiates Handover Request and Handover Request Ack with
4308 * the other BSS and comes back with a BSSMAP Handover Command
4309 * containing an RR Handover Command coming from the target BSS... */
4310
4311 var PDU_ML3_NW_MS rr_ho_cmd := valueof(ts_RR_HandoverCommand);
4312 log("Remote cell's RR Handover Command passed through as L3 Info: ", rr_ho_cmd);
4313 var octetstring rr_ho_cmd_enc := enc_PDU_ML3_NW_MS(rr_ho_cmd);
4314 log("Remote cell's RR Handover Command passed through as L3 Info, encoded: ", rr_ho_cmd_enc);
4315 BSSAP.send(ts_BSSMAP_HandoverCommand(rr_ho_cmd_enc));
4316
4317 /* expect the Handover Command to go out on RR */
4318 var RSL_Message rsl_ho_cmd
4319 RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, ?)) -> value rsl_ho_cmd;
4320 log("RSL Data Req went out to first BTS: ", rsl_ho_cmd);
4321 var RSL_IE_Body rsl_ho_cmd_l3;
4322 if (not f_rsl_find_ie(rsl_ho_cmd, RSL_IE_L3_INFO, rsl_ho_cmd_l3)) {
4323 log("RSL message contains no L3 Info IE, expected RR Handover Command");
4324 setverdict(fail);
4325 } else {
4326 log("Found L3 Info: ", rsl_ho_cmd_l3);
4327 if (rsl_ho_cmd_l3.l3_info.payload != rr_ho_cmd_enc) {
4328 log("FAIL: the BSC sent out a different L3 Info, not matching the RR Handover Command the other BSS forwarded.");
4329 setverdict(fail);
4330 } else {
4331 log("Success: the BSC sent out the same RR Handover Command the other BSS forwarded.");
4332 setverdict(pass);
4333 }
4334 }
4335
4336 /* When the other BSS has reported a completed handover, this side is
4337 * torn down. */
4338
4339 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_HANDOVER_SUCCESSFUL;
4340 var BssmapCause cause := enum2int(cause_val);
4341 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
4342
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02004343 f_expect_dlcx_conns();
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004344 setverdict(pass);
4345 f_sleep(1.0);
4346}
4347testcase TC_ho_out_of_this_bsc() runs on test_CT {
4348 var MSC_ConnHdlr vc_conn;
4349
4350 f_init(1, true);
4351 f_sleep(1.0);
4352
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004353 f_ctrs_bsc_and_bts_init();
4354
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004355 vc_conn := f_start_handler(refers(f_tc_ho_out_of_this_bsc));
4356 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004357
4358 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
4359 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
4360 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
4361 f_ctrs_bsc_and_bts_add(0, "handover:completed");
4362 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
4363 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:completed");
4364 f_ctrs_bsc_and_bts_verify();
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004365}
4366
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004367/* BSC asks for inter-BSC HO, but the MSC decides that it won't happen and
4368 * simply never sends a BSSMAP Handover Command. */
4369private function f_tc_ho_out_fail_no_msc_response(charstring id) runs on MSC_ConnHdlr {
Daniel Willmann3b59eb52018-10-29 15:40:55 +01004370 g_pars := f_gen_test_hdlr_pars();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004371
4372 var PDU_BSSAP ass_req := f_gen_ass_req();
4373 ass_req.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4374 ass_req.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
4375 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4376 f_establish_fully(ass_req, exp_compl);
4377
Neels Hofmeyr666f0432020-07-04 00:53:07 +02004378 f_bts_0_cfg(BSCVTY, {"neighbor lac 99 arfcn 123 bsic any"});
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004379 f_vty_transceive(BSCVTY, "handover any to arfcn 123 bsic any");
4380
4381 BSSAP.receive(tr_BSSMAP_HandoverRequired);
4382
4383 /* osmo-bsc should time out 10 seconds after the handover started.
4384 * Let's give it a bit extra. */
4385 f_sleep(15.0);
4386
4387 /* The old lchan and conn should still be active. See that arbitrary L3
4388 * is still going through. */
4389 var octetstring l3 := '0123456789'O;
4390 RSL.send(ts_RSL_DATA_IND(g_chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
4391 var template PDU_BSSAP exp_data := {
4392 discriminator := '1'B,
4393 spare := '0000000'B,
4394 dlci := '00'O,
4395 lengthIndicator := 5,
4396 pdu := {
4397 dtap := l3
4398 }
4399 };
4400 BSSAP.receive(exp_data);
4401 setverdict(pass);
4402 f_sleep(1.0);
4403}
4404testcase TC_ho_out_fail_no_msc_response() runs on test_CT {
4405 var MSC_ConnHdlr vc_conn;
4406
4407 f_init(1, true);
4408 f_sleep(1.0);
4409
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004410 f_ctrs_bsc_and_bts_init();
4411
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004412 vc_conn := f_start_handler(refers(f_tc_ho_out_fail_no_msc_response));
4413 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004414
4415 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
4416 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
4417 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
4418 f_ctrs_bsc_and_bts_add(0, "handover:timeout");
4419 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
4420 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:timeout");
4421 f_ctrs_bsc_and_bts_verify();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004422}
4423
4424/* BSC asks for inter-BSC HO, receives BSSMAP Handover Command, but MS reports
4425 * RR Handover Failure. */
4426private function f_tc_ho_out_fail_rr_ho_failure(charstring id) runs on MSC_ConnHdlr {
Daniel Willmann3b59eb52018-10-29 15:40:55 +01004427 g_pars := f_gen_test_hdlr_pars();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004428
4429 var PDU_BSSAP ass_req := f_gen_ass_req();
4430 ass_req.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4431 ass_req.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
4432 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4433 f_establish_fully(ass_req, exp_compl);
4434
Neels Hofmeyr666f0432020-07-04 00:53:07 +02004435 f_bts_0_cfg(BSCVTY, {"neighbor lac 99 arfcn 123 bsic any"});
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004436 f_vty_transceive(BSCVTY, "handover any to arfcn 123 bsic any");
4437
4438 BSSAP.receive(tr_BSSMAP_HandoverRequired);
4439
4440 f_sleep(0.5);
4441 /* The MSC negotiates Handover Request and Handover Request Ack with
4442 * the other BSS and comes back with a BSSMAP Handover Command
4443 * containing an RR Handover Command coming from the target BSS... */
4444
4445 var PDU_ML3_NW_MS rr_ho_cmd := valueof(ts_RR_HandoverCommand);
4446 log("Remote cell's RR Handover Command passed through as L3 Info: ", rr_ho_cmd);
4447 var octetstring rr_ho_cmd_enc := enc_PDU_ML3_NW_MS(rr_ho_cmd);
4448 log("Remote cell's RR Handover Command passed through as L3 Info, encoded: ", rr_ho_cmd_enc);
4449 BSSAP.send(ts_BSSMAP_HandoverCommand(rr_ho_cmd_enc));
4450
4451 /* expect the Handover Command to go out on RR */
4452 var RSL_Message rsl_ho_cmd
4453 RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, ?)) -> value rsl_ho_cmd;
4454 log("RSL Data Req went out to first BTS: ", rsl_ho_cmd);
4455 var RSL_IE_Body rsl_ho_cmd_l3;
4456 if (not f_rsl_find_ie(rsl_ho_cmd, RSL_IE_L3_INFO, rsl_ho_cmd_l3)) {
4457 log("RSL message contains no L3 Info IE, expected RR Handover Command");
4458 setverdict(fail);
4459 } else {
4460 log("Found L3 Info: ", rsl_ho_cmd_l3);
4461 if (rsl_ho_cmd_l3.l3_info.payload != rr_ho_cmd_enc) {
4462 log("FAIL: the BSC sent out a different L3 Info, not matching the RR Handover Command the other BSS forwarded.");
4463 setverdict(fail);
4464 } else {
4465 log("Success: the BSC sent out the same RR Handover Command the other BSS forwarded.");
4466 setverdict(pass);
4467 }
4468 }
4469
4470 f_sleep(0.2);
4471 f_rsl_send_l3(ts_RRM_HandoverFailure('00'O));
4472
4473 /* Should tell the MSC about the failure */
4474 BSSAP.receive(tr_BSSMAP_HandoverFailure);
4475
4476 f_sleep(1.0);
4477
4478 /* The old lchan and conn should still be active. See that arbitrary L3
4479 * is still going through. */
4480 var octetstring l3 := '0123456789'O;
4481 RSL.send(ts_RSL_DATA_IND(g_chan_nr, valueof(ts_RslLinkID_DCCH(0)), l3));
4482 var template PDU_BSSAP exp_data := {
4483 discriminator := '1'B,
4484 spare := '0000000'B,
4485 dlci := '00'O,
4486 lengthIndicator := 5,
4487 pdu := {
4488 dtap := l3
4489 }
4490 };
4491 BSSAP.receive(exp_data);
4492 setverdict(pass);
4493 f_sleep(1.0);
4494
4495 setverdict(pass);
4496 f_sleep(1.0);
4497}
4498testcase TC_ho_out_fail_rr_ho_failure() runs on test_CT {
4499 var MSC_ConnHdlr vc_conn;
4500
4501 f_init(1, true);
4502 f_sleep(1.0);
4503
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004504 f_ctrs_bsc_and_bts_init();
4505
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004506 vc_conn := f_start_handler(refers(f_tc_ho_out_fail_rr_ho_failure));
4507 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004508
4509 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
4510 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
4511 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
4512 f_ctrs_bsc_and_bts_add(0, "handover:failed");
4513 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
4514 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:failed");
4515 f_ctrs_bsc_and_bts_verify();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004516}
4517
Neels Hofmeyr10f2bfa2019-07-09 19:33:29 +02004518/* BSC asks for inter-BSC-out HO, receives BSSMAP Handover Command, but then no reply is received about HO outcome
4519 * (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 +02004520 * and the lchan is released. */
4521private function f_tc_ho_out_fail_no_result_after_ho_cmd(charstring id) runs on MSC_ConnHdlr {
Daniel Willmann3b59eb52018-10-29 15:40:55 +01004522 g_pars := f_gen_test_hdlr_pars();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004523
4524 var PDU_BSSAP ass_req := f_gen_ass_req();
4525 ass_req.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
4526 ass_req.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
4527 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
4528 f_establish_fully(ass_req, exp_compl);
4529
Neels Hofmeyr666f0432020-07-04 00:53:07 +02004530 f_bts_0_cfg(BSCVTY, {"neighbor lac 99 arfcn 123 bsic any"});
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004531 f_vty_transceive(BSCVTY, "handover any to arfcn 123 bsic any");
4532
4533 BSSAP.receive(tr_BSSMAP_HandoverRequired);
4534
4535 f_sleep(0.5);
4536 /* The MSC negotiates Handover Request and Handover Request Ack with
4537 * the other BSS and comes back with a BSSMAP Handover Command
4538 * containing an RR Handover Command coming from the target BSS... */
4539
4540 var PDU_ML3_NW_MS rr_ho_cmd := valueof(ts_RR_HandoverCommand);
4541 log("Remote cell's RR Handover Command passed through as L3 Info: ", rr_ho_cmd);
4542 var octetstring rr_ho_cmd_enc := enc_PDU_ML3_NW_MS(rr_ho_cmd);
4543 log("Remote cell's RR Handover Command passed through as L3 Info, encoded: ", rr_ho_cmd_enc);
4544 BSSAP.send(ts_BSSMAP_HandoverCommand(rr_ho_cmd_enc));
4545
4546 /* expect the Handover Command to go out on RR */
4547 var RSL_Message rsl_ho_cmd
4548 RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, ?)) -> value rsl_ho_cmd;
4549 log("RSL Data Req went out to first BTS: ", rsl_ho_cmd);
4550 var RSL_IE_Body rsl_ho_cmd_l3;
4551 if (not f_rsl_find_ie(rsl_ho_cmd, RSL_IE_L3_INFO, rsl_ho_cmd_l3)) {
4552 log("RSL message contains no L3 Info IE, expected RR Handover Command");
4553 setverdict(fail);
4554 } else {
4555 log("Found L3 Info: ", rsl_ho_cmd_l3);
4556 if (rsl_ho_cmd_l3.l3_info.payload != rr_ho_cmd_enc) {
4557 log("FAIL: the BSC sent out a different L3 Info, not matching the RR Handover Command the other BSS forwarded.");
4558 setverdict(fail);
4559 } else {
4560 log("Success: the BSC sent out the same RR Handover Command the other BSS forwarded.");
4561 setverdict(pass);
4562 }
4563 }
4564
Neels Hofmeyr10f2bfa2019-07-09 19:33:29 +02004565 /* We get neither success nor failure report from the remote BSS. Eventually T8 times out and we run into 3GPP
4566 * TS 48.008 3.1.5.3.3 "Abnormal Conditions": Clear Request should go to the MSC, and RR should be released
4567 * after Clear Command */
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004568
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02004569 var PDU_BSSAP rx_clear_request;
Neels Hofmeyre1797aa2019-07-09 19:34:04 +02004570 BSSAP.receive(tr_BSSMAP_ClearRequest) -> value rx_clear_request;
4571 log("Got BSSMAP Clear Request");
4572 /* Instruct BSC to clear channel */
4573 var BssmapCause cause := bit2int(rx_clear_request.pdu.bssmap.clearRequest.cause.causeValue);
4574 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
4575
4576 var MgcpCommand mgcp;
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004577 interleave {
Neels Hofmeyr861a4c12018-11-07 01:23:17 +01004578 [] RSL.receive(tr_RSL_DEACT_SACCH(g_chan_nr)) {
4579 log("Got Deact SACCH");
4580 }
Harald Welte924b6ea2019-02-04 01:05:34 +01004581 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_RELEASE)) {
Neels Hofmeyr211169d2018-11-07 00:37:29 +01004582 log("Got RR Release");
4583 }
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004584 [] RSL.receive(tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL)) {
4585 log("Got RF Chan Rel");
4586 RSL.send(ts_RSL_RF_CHAN_REL_ACK(g_chan_nr));
4587 }
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004588 }
4589
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02004590 f_expect_dlcx_conns();
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02004591
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004592 setverdict(pass);
4593 f_sleep(1.0);
4594}
Neels Hofmeyrd8a602c2019-07-09 19:46:01 +02004595testcase TC_ho_out_fail_no_result_after_ho_cmd() runs on test_CT {
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004596 var MSC_ConnHdlr vc_conn;
4597
4598 f_init(1, true);
4599 f_sleep(1.0);
4600
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004601 f_ctrs_bsc_and_bts_init();
4602
Neels Hofmeyrd8a602c2019-07-09 19:46:01 +02004603 vc_conn := f_start_handler(refers(f_tc_ho_out_fail_no_result_after_ho_cmd));
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004604 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004605
4606 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
4607 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
4608 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
4609 f_ctrs_bsc_and_bts_add(0, "handover:timeout");
4610 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
4611 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:timeout");
4612 f_ctrs_bsc_and_bts_verify();
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02004613}
4614
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004615private function f_tc_ho_into_this_bsc(charstring id) runs on MSC_ConnHdlr {
4616 /* Hack: the proper way would be to wait for the BSSMAP Handover Request ACK and extract the
4617 * actual assigned chan_nr from its L3 (RR Handover Command) message. But osmo-bsc starts acting
4618 * on the lchan even before we get a chance to evaluate the BSSMAP Handover Request ACK. So we
4619 * need to assume that osmo-bsc will activate TS 1 and already set up this lchan's RSL emulation
4620 * before we get started. */
4621 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
4622 f_rslem_register(0, new_chan_nr);
4623 g_chan_nr := new_chan_nr;
4624 f_sleep(1.0);
4625
4626 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
4627 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
4628 activate(as_Media());
4629
Neels Hofmeyr90f80962020-06-12 16:16:55 +02004630 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004631 f_gen_handover_req()));
Harald Welte6811d102019-04-14 22:23:14 +02004632 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004633
4634 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
4635
4636 var PDU_BSSAP rx_bssap;
4637 var octetstring ho_command_str;
4638
4639 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
Pau Espin Pedrol76ba5412019-06-10 11:00:33 +02004640
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004641 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
4642 log("Received L3 Info in HO Request Ack: ", ho_command_str);
4643 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
4644 log("L3 Info in HO Request Ack is ", ho_command);
4645
4646 var GsmArfcn arfcn;
4647 var RslChannelNr actual_new_chan_nr;
4648 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
4649 actual_new_chan_nr, arfcn);
4650
4651 if (actual_new_chan_nr != new_chan_nr) {
4652 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
4653 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
4654 setverdict(fail);
4655 return;
4656 }
4657 log("Handover Command chan_nr is", actual_new_chan_nr);
4658
4659 /* Now the MSC forwards the RR Handover Command to the other BSC, which
4660 * tells the MS to handover to the new lchan. Here comes the new MS on
4661 * the new lchan with a Handover RACH: */
4662
4663 /* send handover detect */
4664
4665 RSL.send(ts_RSL_HANDO_DET(new_chan_nr));
4666
4667 BSSAP.receive(tr_BSSMAP_HandoverDetect);
4668
4669 /* send handover complete over the new channel */
4670
4671 var PDU_ML3_MS_NW l3_tx := valueof(ts_RRM_HandoverComplete('00'O));
4672 RSL.send(ts_RSL_EST_IND(new_chan_nr, valueof(ts_RslLinkID_DCCH(0)),
4673 enc_PDU_ML3_MS_NW(l3_tx)));
4674
4675 BSSAP.receive(tr_BSSMAP_HandoverComplete);
4676 setverdict(pass);
4677}
4678testcase TC_ho_into_this_bsc() runs on test_CT {
4679 var MSC_ConnHdlr vc_conn;
Philipp Maier48604732018-10-09 15:00:37 +02004680 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004681
4682 f_init(1, true);
4683 f_sleep(1.0);
4684
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004685 f_ctrs_bsc_and_bts_init();
4686
Neels Hofmeyr90f80962020-06-12 16:16:55 +02004687 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
4688 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004689
4690 vc_conn := f_start_handler(refers(f_tc_ho_into_this_bsc), pars);
4691 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004692
4693 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
4694 f_ctrs_bsc_and_bts_add(0, "handover:completed");
4695 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:attempted");
4696 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:completed");
4697 f_ctrs_bsc_and_bts_verify();
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01004698}
4699
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01004700private function f_tc_ho_in_fail_msc_clears(charstring id) runs on MSC_ConnHdlr {
4701 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
4702 f_rslem_register(0, new_chan_nr);
4703 g_chan_nr := new_chan_nr;
4704 f_sleep(1.0);
4705
4706 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
4707 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
4708 activate(as_Media());
4709
Neels Hofmeyr90f80962020-06-12 16:16:55 +02004710 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01004711 f_gen_handover_req()));
Harald Welte6811d102019-04-14 22:23:14 +02004712 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01004713
4714 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
4715
4716 var PDU_BSSAP rx_bssap;
4717 var octetstring ho_command_str;
4718
4719 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
4720
4721 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
4722 log("Received L3 Info in HO Request Ack: ", ho_command_str);
4723 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
4724 log("L3 Info in HO Request Ack is ", ho_command);
4725
4726 var GsmArfcn arfcn;
4727 var RslChannelNr actual_new_chan_nr;
4728 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
4729 actual_new_chan_nr, arfcn);
4730
4731 if (actual_new_chan_nr != new_chan_nr) {
4732 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
4733 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
4734 setverdict(fail);
4735 return;
4736 }
4737 log("Handover Command chan_nr is", actual_new_chan_nr);
4738
Neels Hofmeyr61ca08d2019-05-06 23:52:22 +02004739 /* For deterministic test results, give some time for the MGW endpoint to be configured */
4740 f_sleep(1.0);
4741
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01004742 /* Now the MSC forwards the RR Handover Command to the other BSC, which
4743 * tells the MS to handover to the new lchan. In this case, the MS
4744 * reports a Handover Failure to the old BSS, which forwards a BSSMAP
4745 * Handover Failure to the MSC. The procedure according to 3GPP TS
4746 * 48.008 3.1.5.3.2 "Handover Failure" is then that the MSC sends a
4747 * BSSMAP Clear Command: */
4748
4749 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_RADIO_INTERFACE_FAILURE_REVERSION;
4750 var BssmapCause cause := enum2int(cause_val);
4751 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
4752
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02004753 f_expect_dlcx_conns();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01004754 setverdict(pass);
4755 f_sleep(1.0);
4756
4757 setverdict(pass);
4758}
4759testcase TC_ho_in_fail_msc_clears() runs on test_CT {
4760 var MSC_ConnHdlr vc_conn;
4761 var TestHdlrParams pars := f_gen_test_hdlr_pars();
4762
4763 f_init(1, true);
4764 f_sleep(1.0);
4765
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004766 f_ctrs_bsc_and_bts_init();
4767
Neels Hofmeyr90f80962020-06-12 16:16:55 +02004768 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
4769 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01004770
4771 vc_conn := f_start_handler(refers(f_tc_ho_in_fail_msc_clears), pars);
4772 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004773
4774 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
4775 f_ctrs_bsc_and_bts_add(0, "handover:stopped");
4776 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:attempted");
4777 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:stopped");
4778 f_ctrs_bsc_and_bts_verify();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01004779}
4780
4781private function f_tc_ho_in_fail_msc_clears_after_ho_detect(charstring id) runs on MSC_ConnHdlr {
4782 /* Hack: the proper way would be to wait for the BSSMAP Handover Request ACK and extract the
4783 * actual assigned chan_nr from its L3 (RR Handover Command) message. But osmo-bsc starts acting
4784 * on the lchan even before we get a chance to evaluate the BSSMAP Handover Request ACK. So we
4785 * need to assume that osmo-bsc will activate TS 1 and already set up this lchan's RSL emulation
4786 * before we get started. */
4787 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
4788 f_rslem_register(0, new_chan_nr);
4789 g_chan_nr := new_chan_nr;
4790 f_sleep(1.0);
4791
4792 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
4793 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
4794 activate(as_Media());
4795
Neels Hofmeyr90f80962020-06-12 16:16:55 +02004796 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01004797 f_gen_handover_req()));
Harald Welte6811d102019-04-14 22:23:14 +02004798 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01004799
4800 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
4801
4802 var PDU_BSSAP rx_bssap;
4803 var octetstring ho_command_str;
4804
4805 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
4806
4807 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
4808 log("Received L3 Info in HO Request Ack: ", ho_command_str);
4809 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
4810 log("L3 Info in HO Request Ack is ", ho_command);
4811
4812 var GsmArfcn arfcn;
4813 var RslChannelNr actual_new_chan_nr;
4814 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
4815 actual_new_chan_nr, arfcn);
4816
4817 if (actual_new_chan_nr != new_chan_nr) {
4818 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
4819 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
4820 setverdict(fail);
4821 return;
4822 }
4823 log("Handover Command chan_nr is", actual_new_chan_nr);
4824
4825 /* Now the MSC forwards the RR Handover Command to the other BSC, which
4826 * tells the MS to handover to the new lchan. Here comes the new MS on
4827 * the new lchan with a Handover RACH: */
4828
4829 /* send handover detect */
4830
4831 RSL.send(ts_RSL_HANDO_DET(new_chan_nr));
4832
4833 BSSAP.receive(tr_BSSMAP_HandoverDetect);
4834
4835 /* The MSC chooses to clear the connection now, maybe we got the
4836 * Handover RACH on the new cell but the MS still signaled Handover
4837 * Failure to the old BSS? */
4838
4839 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_RADIO_INTERFACE_FAILURE_REVERSION;
4840 var BssmapCause cause := enum2int(cause_val);
4841 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
4842
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02004843 f_expect_dlcx_conns();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01004844 setverdict(pass);
4845 f_sleep(1.0);
4846}
4847testcase TC_ho_in_fail_msc_clears_after_ho_detect() runs on test_CT {
4848 var MSC_ConnHdlr vc_conn;
4849 var TestHdlrParams pars := f_gen_test_hdlr_pars();
4850
4851 f_init(1, true);
4852 f_sleep(1.0);
4853
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004854 f_ctrs_bsc_and_bts_init();
4855
Neels Hofmeyr90f80962020-06-12 16:16:55 +02004856 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
4857 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01004858
4859 vc_conn := f_start_handler(refers(f_tc_ho_in_fail_msc_clears_after_ho_detect), pars);
4860 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004861
4862 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
4863 f_ctrs_bsc_and_bts_add(0, "handover:stopped");
4864 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:attempted");
4865 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:stopped");
4866 f_ctrs_bsc_and_bts_verify();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01004867}
4868
4869/* The new BSS's lchan times out before the MSC decides that handover failed. */
4870private function f_tc_ho_in_fail_no_detect(charstring id) runs on MSC_ConnHdlr {
4871 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
4872 f_rslem_register(0, new_chan_nr);
4873 g_chan_nr := new_chan_nr;
4874 f_sleep(1.0);
4875
4876 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
4877 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
4878 activate(as_Media());
4879
Neels Hofmeyr90f80962020-06-12 16:16:55 +02004880 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01004881 f_gen_handover_req()));
Harald Welte6811d102019-04-14 22:23:14 +02004882 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01004883
4884 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
4885
4886 var PDU_BSSAP rx_bssap;
4887 var octetstring ho_command_str;
4888
4889 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
4890
4891 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
4892 log("Received L3 Info in HO Request Ack: ", ho_command_str);
4893 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
4894 log("L3 Info in HO Request Ack is ", ho_command);
4895
4896 var GsmArfcn arfcn;
4897 var RslChannelNr actual_new_chan_nr;
4898 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
4899 actual_new_chan_nr, arfcn);
4900
4901 if (actual_new_chan_nr != new_chan_nr) {
4902 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
4903 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
4904 setverdict(fail);
4905 return;
4906 }
4907 log("Handover Command chan_nr is", actual_new_chan_nr);
4908
4909 /* Now the MSC forwards the RR Handover Command to the other BSC, which
4910 * tells the MS to handover to the new lchan. But the MS never shows up
4911 * on the new lchan. */
4912
4913 BSSAP.receive(tr_BSSMAP_HandoverFailure);
4914
4915 /* Did osmo-bsc also send a Clear Request? */
4916 timer T := 0.5;
4917 T.start;
4918 alt {
4919 [] BSSAP.receive(tr_BSSMAP_ClearRequest);
4920 [] T.timeout { }
4921 }
4922
4923 /* MSC plays along with a Clear Command (no matter whether osmo-bsc
4924 * asked for it, this is a Handover Failure after all). */
4925
4926 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_RADIO_INTERFACE_FAILURE_REVERSION;
4927 var BssmapCause cause := enum2int(cause_val);
4928 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
4929
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02004930 f_expect_dlcx_conns();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01004931 setverdict(pass);
4932 f_sleep(1.0);
4933
4934 setverdict(pass);
4935}
4936testcase TC_ho_in_fail_no_detect() runs on test_CT {
4937 var MSC_ConnHdlr vc_conn;
4938 var TestHdlrParams pars := f_gen_test_hdlr_pars();
4939
4940 f_init(1, true);
4941 f_sleep(1.0);
4942
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004943 f_ctrs_bsc_and_bts_init();
4944
Neels Hofmeyr90f80962020-06-12 16:16:55 +02004945 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
4946 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01004947
4948 vc_conn := f_start_handler(refers(f_tc_ho_in_fail_no_detect), pars);
4949 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00004950
4951 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
4952 f_ctrs_bsc_and_bts_add(0, "handover:error");
4953 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:attempted");
4954 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:error");
4955 f_ctrs_bsc_and_bts_verify();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01004956}
4957
4958/* Same as f_tc_ho_in_fail_no_detect, but MSC fails to send a Clear Command */
4959private function f_tc_ho_in_fail_no_detect2(charstring id) runs on MSC_ConnHdlr {
4960 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(1, RSL_CHAN_NR_Bm_ACCH));
4961 f_rslem_register(0, new_chan_nr);
4962 g_chan_nr := new_chan_nr;
4963 f_sleep(1.0);
4964
4965 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
4966 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
4967 activate(as_Media());
4968
Neels Hofmeyr90f80962020-06-12 16:16:55 +02004969 BSSAP.send(ts_BSSAP_Conn_Req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01004970 f_gen_handover_req()));
Harald Welte6811d102019-04-14 22:23:14 +02004971 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_CONF_IND);
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01004972
4973 /* The RSL Emulation magically accepts the Chan Activ behind the scenes. */
4974
4975 var PDU_BSSAP rx_bssap;
4976 var octetstring ho_command_str;
4977
4978 BSSAP.receive(tr_BSSMAP_HandoverRequestAcknowledge(?)) -> value rx_bssap;
4979
4980 ho_command_str := rx_bssap.pdu.bssmap.handoverRequestAck.layer3Information.layer3info;
4981 log("Received L3 Info in HO Request Ack: ", ho_command_str);
4982 var PDU_ML3_NW_MS ho_command := dec_PDU_ML3_NW_MS(ho_command_str);
4983 log("L3 Info in HO Request Ack is ", ho_command);
4984
4985 var GsmArfcn arfcn;
4986 var RslChannelNr actual_new_chan_nr;
4987 f_ChDesc2RslChanNr(ho_command.msgs.rrm.handoverCommand.channelDescription2,
4988 actual_new_chan_nr, arfcn);
4989
4990 if (actual_new_chan_nr != new_chan_nr) {
4991 log("ERROR: osmo-bsc assigned a different lchan than we assumed above -- this test will fail now.",
4992 " Assumed: ", new_chan_nr, " Assigned: ", actual_new_chan_nr);
4993 setverdict(fail);
4994 return;
4995 }
4996 log("Handover Command chan_nr is", actual_new_chan_nr);
4997
4998 /* Now the MSC forwards the RR Handover Command to the other BSC, which
4999 * tells the MS to handover to the new lchan. But the MS never shows up
5000 * on the new lchan. */
5001
5002 BSSAP.receive(tr_BSSMAP_HandoverFailure);
5003
5004 /* MSC plays dumb and sends no Clear Command */
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005005 var PDU_BSSAP rx_clear_request;
Pau Espin Pedrol1fc30b92019-06-18 13:08:22 +02005006
5007 BSSAP.receive(tr_BSSMAP_ClearRequest) -> value rx_clear_request {
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005008 var BssmapCause cause := bit2int(rx_clear_request.pdu.bssmap.clearRequest.cause.causeValue);
5009 BSSAP.send(ts_BSSMAP_ClearCommand(cause));
5010 };
Pau Espin Pedrol7aa02742019-06-26 16:30:14 +02005011 f_expect_dlcx_conns();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005012 setverdict(pass);
5013 f_sleep(1.0);
5014}
5015testcase TC_ho_in_fail_no_detect2() runs on test_CT {
5016 var MSC_ConnHdlr vc_conn;
5017 var TestHdlrParams pars := f_gen_test_hdlr_pars();
5018
5019 f_init(1, true);
5020 f_sleep(1.0);
5021
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005022 f_ctrs_bsc_and_bts_init();
5023
Neels Hofmeyr90f80962020-06-12 16:16:55 +02005024 pars.sccp_addr_msc := g_bssap[0].sccp_addr_own;
5025 pars.sccp_addr_bsc := g_bssap[0].sccp_addr_peer;
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005026
5027 vc_conn := f_start_handler(refers(f_tc_ho_in_fail_no_detect2), pars);
5028 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005029
5030 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5031 f_ctrs_bsc_and_bts_add(0, "handover:error");
5032 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:attempted");
5033 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_in:error");
5034 f_ctrs_bsc_and_bts_verify();
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01005035}
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01005036
Neels Hofmeyr91401012019-07-11 00:42:35 +02005037type record of charstring Commands;
5038
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005039private function f_bts_0_cfg(TELNETasp_PT pt, Commands cmds := {})
Neels Hofmeyr91401012019-07-11 00:42:35 +02005040{
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005041 f_vty_enter_cfg_bts(pt, 0);
Neels Hofmeyr91401012019-07-11 00:42:35 +02005042 for (var integer i := 0; i < sizeof(cmds); i := i+1) {
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005043 f_vty_transceive(pt, cmds[i]);
Neels Hofmeyr91401012019-07-11 00:42:35 +02005044 }
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005045 f_vty_transceive(pt, "end");
Neels Hofmeyr91401012019-07-11 00:42:35 +02005046}
5047
Pau Espin Pedrolc675b612020-01-09 19:55:40 +01005048private function f_cs7_inst_0_cfg(TELNETasp_PT pt, Commands cmds := {})
5049{
5050 f_vty_enter_cfg_cs7_inst(pt, 0);
5051 for (var integer i := 0; i < sizeof(cmds); i := i+1) {
5052 f_vty_transceive(pt, cmds[i]);
5053 }
5054 f_vty_transceive(pt, "end");
5055}
5056
Neels Hofmeyr91401012019-07-11 00:42:35 +02005057private function f_probe_for_handover(charstring log_label,
5058 charstring log_descr,
5059 charstring handover_vty_cmd,
5060 boolean expect_handover,
5061 boolean is_inter_bsc_handover := false)
5062runs on MSC_ConnHdlr
5063{
Neels Hofmeyrb3fc8982020-05-11 00:16:42 +02005064 /* We're going to thwart any and all handover attempts, just be ready to handle (and ignore) handover target
5065 * lchans to be established on bts 1 or bts 2. */
5066 f_rslem_suspend(RSL1_PROC);
5067 f_rslem_suspend(RSL2_PROC);
5068
Neels Hofmeyr91401012019-07-11 00:42:35 +02005069 var RSL_Message rsl;
5070
5071 var charstring log_msg := " (expecting handover)"
5072 if (not expect_handover) {
5073 log_msg := " (expecting NO handover)";
5074 }
5075 log("f_probe_for_handover starting: " & log_label & ": " & log_descr & log_msg);
5076 f_vty_transceive(BSCVTY, handover_vty_cmd);
5077
Neels Hofmeyr91401012019-07-11 00:42:35 +02005078 timer T := 2.0;
5079 T.start;
5080
5081 alt {
5082 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr)) -> value rsl {
5083 var PDU_ML3_NW_MS l3 := dec_PDU_ML3_NW_MS(rsl.ies[2].body.l3_info.payload);
5084 log("Rx L3 from net: ", l3);
5085 if (ischosen(l3.msgs.rrm.handoverCommand)) {
5086 var RslChannelNr new_chan_nr;
5087 var GsmArfcn arfcn;
5088 f_ChDesc2RslChanNr(l3.msgs.rrm.handoverCommand.channelDescription2,
5089 new_chan_nr, arfcn);
5090 log("Handover to new chan ", new_chan_nr, " on ARFCN ", arfcn);
5091 log(l3.msgs.rrm.handoverCommand);
5092
5093 /* Need to register for new lchan on new BTS -- it's either bts 1 or bts 2. It doesn't really
5094 * matter on which BTS it really is, we're not going to follow through an entire handover
5095 * anyway. */
5096 f_rslem_register(0, new_chan_nr, RSL1_PROC);
5097 f_rslem_resume(RSL1_PROC);
5098 f_rslem_register(0, new_chan_nr, RSL2_PROC);
5099 f_rslem_resume(RSL2_PROC);
5100
5101 if (expect_handover and not is_inter_bsc_handover) {
5102 setverdict(pass);
5103 log("f_probe_for_handover(" & log_label & "): Got RSL Handover Command as expected.");
5104 } else {
5105 setverdict(fail, "f_probe_for_handover(" & log_label & "): Expected none, but got RSL Handover Command. "
5106 & log_label & ": " & log_descr);
5107 }
5108
5109 log("f_probe_for_handover(" & log_label & "): Ending the test: Handover Failure stops the procedure.");
5110 /* osmo-bsc has triggered Handover. That's all we need to know for this test, reply with
5111 * Handover Failure. */
5112 f_rsl_send_l3(ts_RRM_HandoverFailure('00'O));
5113
5114 /* target BTS is told to release lchan again; don't care which BTS nor what messages. */
5115 f_sleep(0.5);
5116 RSL1.clear;
5117 RSL2.clear;
5118 log("f_probe_for_handover(" & log_label & "): done (got RSL Handover Command)");
5119 break;
5120 } else {
5121 repeat;
5122 }
5123 }
5124 [] BSSAP.receive(tr_BSSMAP_HandoverRequired) {
5125 if (expect_handover and is_inter_bsc_handover) {
5126 setverdict(pass);
5127 log("f_probe_for_handover(" & log_label & "): Got BSSMAP Handover Required as expected.");
5128 } else {
5129 setverdict(fail, "f_probe_for_handover(" & log_label & "): Expected none, but got BSSMAP Handover Required. "
5130 & log_label & ": " & log_descr);
5131 }
5132
5133 log("f_probe_for_handover(" & log_label & "): done (got BSSMAP Handover Required)");
5134
5135 /* Note: f_tc_ho_neighbor_config_start() sets T7, the timeout for BSSMAP Handover Required, to
5136 * 1 second. There is no legal way to quickly abort a handover after a BSSMAP Handover Required,
5137 * setting a short timeout and waiting is the only way. */
5138 log("f_probe_for_handover(" & log_label & "): waiting for inter-BSC HO to time out...");
5139 f_sleep(1.5);
5140 log("f_probe_for_handover(" & log_label & "): ...done");
5141
5142 break;
5143 }
5144 [] T.timeout {
5145 if (expect_handover) {
5146 setverdict(fail, "f_probe_for_handover(" & log_label & "): Expected Handover, but got none. "
5147 & log_label & ": " & log_descr);
5148 } else {
5149 setverdict(pass);
5150 log("f_probe_for_handover(" & log_label & "): Got no Handover, as expected.");
5151 }
5152 log("f_probe_for_handover(" & log_label & "): done (got no Handover)");
5153 break;
5154 }
5155 }
5156
5157 f_rslem_resume(RSL1_PROC);
5158 f_rslem_resume(RSL2_PROC);
5159 f_sleep(3.0);
5160 RSL.clear;
5161
5162 log("f_probe_for_handover(" & log_label & "): done clearing");
5163}
5164
5165/* Test the effect of various neighbor configuration scenarios:
5166 *
5167 * To avoid complexity, block off any actual handover operation, and always remain on the lchan at bts 0.
5168 * Reconfigure the neighbors for bts 0, trigger a Handover, and probe whether osmo-bsc does or doesn't start HO.
5169 */
5170private function f_tc_ho_neighbor_config_start() runs on MSC_ConnHdlr {
5171 g_pars := f_gen_test_hdlr_pars();
5172 var template PDU_BSSAP exp_compl := f_gen_exp_compl();
5173 var PDU_BSSAP ass_cmd := f_gen_ass_req();
5174 const OCT8 kc := '0001020304050607'O;
5175
5176 ass_cmd.pdu.bssmap.assignmentRequest.channelType := valueof(ts_BSSMAP_IE_ChannelType);
5177 ass_cmd.pdu.bssmap.assignmentRequest.codecList := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
5178
5179 /* Establish lchan at bts 0 */
5180 f_establish_fully(ass_cmd, exp_compl);
5181
5182 /* Shorten the inter-BSC Handover timeout, to not wait so long for inter-BSC Handovers */
5183 f_vty_enter_cfg_network(BSCVTY);
5184 f_vty_transceive(BSCVTY, "timer T7 1");
5185 f_vty_transceive(BSCVTY, "end");
5186}
5187
5188private function f_tc_ho_neighbor_config_1(charstring id) runs on MSC_ConnHdlr {
5189 f_tc_ho_neighbor_config_start();
5190
5191 /*
5192 * bts 0 ARFCN 871 BSIC 10
5193 * bts 1 ARFCN 871 BSIC 11
5194 * bts 2 ARFCN 871 BSIC 12
5195 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
5196 */
5197
5198 log("f_tc_ho_neighbor_config: 1. No 'neighbor' config");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005199 f_bts_0_cfg(BSCVTY, {"no neighbors"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02005200 f_probe_for_handover("1.a", "HO to bts 1 works, implicitly listed as neighbor (legacy behavior when none are configured)",
5201 "handover any to arfcn 871 bsic 11",
5202 true);
5203
5204 f_probe_for_handover("1.b", "HO to unknown cell does not start",
5205 "handover any to arfcn 13 bsic 39",
5206 false);
5207
5208 f_probe_for_handover("1.c", "HO to 871-12 is ambiguous = error",
5209 "handover any to arfcn 871 bsic 12",
5210 false);
5211
5212 f_probe_for_handover("1.d", "HO to 871-11 still works (verify that this test properly cleans up)",
5213 "handover any to arfcn 871 bsic 11",
5214 true);
5215}
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005216testcase TC_ho_neighbor_config_1() runs on test_CT {
5217 var MSC_ConnHdlr vc_conn;
5218 f_init(3, true, guard_timeout := 60.0);
5219 f_sleep(1.0);
5220 f_ctrs_bsc_and_bts_init();
5221 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_1));
5222 vc_conn.done;
5223
5224 /* f_tc_ho_neighbor_config_start() */
5225 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5226 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5227
5228 /* 1.a */
5229 /* "failed" means a handover was triggered and started (which is all this test aims for) and the test ended the
5230 * handover quickly by sending a Handover Failure message. */
5231 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5232 f_ctrs_bsc_and_bts_add(0, "handover:failed");
5233 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
5234 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:failed");
5235
5236 /* 1.b */
5237 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5238 f_ctrs_bsc_and_bts_add(0, "handover:error");
5239
5240 /* 1.c */
5241 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5242 f_ctrs_bsc_and_bts_add(0, "handover:error");
5243
5244 /* 1.d */
5245 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5246 f_ctrs_bsc_and_bts_add(0, "handover:failed");
5247 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
5248 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:failed");
5249
5250 f_ctrs_bsc_and_bts_verify();
5251}
5252
Neels Hofmeyr91401012019-07-11 00:42:35 +02005253private function f_tc_ho_neighbor_config_2(charstring id) runs on MSC_ConnHdlr {
5254 f_tc_ho_neighbor_config_start();
5255
5256 /*
5257 * bts 0 ARFCN 871 BSIC 10
5258 * bts 1 ARFCN 871 BSIC 11
5259 * bts 2 ARFCN 871 BSIC 12
5260 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
5261 */
5262
5263 log("f_tc_ho_neighbor_config: 2. explicit local neighbor: 'neighbor bts 1'");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005264 f_bts_0_cfg(BSCVTY, {"neighbor bts 1"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02005265 f_sleep(0.5);
5266
5267 f_probe_for_handover("2.a", "HO to bts 1 works, explicitly listed as neighbor",
5268 "handover any to arfcn 871 bsic 11",
5269 true);
5270
5271 f_probe_for_handover("2.b", "HO to bts 2 doesn't work, not listed as neighbor",
5272 "handover any to arfcn 871 bsic 12",
5273 false);
5274}
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005275testcase TC_ho_neighbor_config_2() runs on test_CT {
5276 var MSC_ConnHdlr vc_conn;
5277 f_init(3, true, guard_timeout := 50.0);
5278 f_sleep(1.0);
5279 f_ctrs_bsc_and_bts_init();
5280 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_2));
5281 vc_conn.done;
5282
5283 /* f_tc_ho_neighbor_config_start() */
5284 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5285 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5286
5287 /* 2.a */
5288 /* "failed" means a handover was triggered and started (which is all this test aims for) and the test ended the
5289 * handover quickly by sending a Handover Failure message. */
5290 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5291 f_ctrs_bsc_and_bts_add(0, "handover:failed");
5292 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
5293 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:failed");
5294
5295 /* 2.b */
5296 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5297 f_ctrs_bsc_and_bts_add(0, "handover:error");
5298
5299 f_ctrs_bsc_and_bts_verify();
5300}
5301
Neels Hofmeyr91401012019-07-11 00:42:35 +02005302private function f_tc_ho_neighbor_config_3(charstring id) runs on MSC_ConnHdlr {
5303 f_tc_ho_neighbor_config_start();
5304
5305 /*
5306 * bts 0 ARFCN 871 BSIC 10
5307 * bts 1 ARFCN 871 BSIC 11
5308 * bts 2 ARFCN 871 BSIC 12
5309 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
5310 */
5311
5312 log("f_tc_ho_neighbor_config: 3. explicit local neighbor: 'neighbor bts 2'");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005313 f_bts_0_cfg(BSCVTY, {"no neighbors", "neighbor bts 2"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02005314 f_sleep(0.5);
5315
5316 f_probe_for_handover("3.a", "HO to bts 1 doesn't work, not listed as neighbor",
5317 "handover any to arfcn 871 bsic 11",
5318 false);
5319 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",
5320 "handover any to arfcn 871 bsic 12",
5321 true);
5322}
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005323testcase TC_ho_neighbor_config_3() runs on test_CT {
5324 var MSC_ConnHdlr vc_conn;
5325 f_init(3, true, guard_timeout := 50.0);
5326 f_sleep(1.0);
5327 f_ctrs_bsc_and_bts_init();
5328 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_3));
5329 vc_conn.done;
5330
5331 /* f_tc_ho_neighbor_config_start() */
5332 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5333 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5334
5335 /* 3.a */
5336 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5337 f_ctrs_bsc_and_bts_add(0, "handover:error");
5338
5339 /* 3.b */
5340 /* "failed" means a handover was triggered and started (which is all this test aims for) and the test ended the
5341 * handover quickly by sending a Handover Failure message. */
5342 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5343 f_ctrs_bsc_and_bts_add(0, "handover:failed");
5344 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
5345 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:failed");
5346
5347 f_ctrs_bsc_and_bts_verify();
5348}
5349
Neels Hofmeyr91401012019-07-11 00:42:35 +02005350private function f_tc_ho_neighbor_config_4(charstring id) runs on MSC_ConnHdlr {
5351 f_tc_ho_neighbor_config_start();
5352
5353 /*
5354 * bts 0 ARFCN 871 BSIC 10
5355 * bts 1 ARFCN 871 BSIC 11
5356 * bts 2 ARFCN 871 BSIC 12
5357 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
5358 */
5359
5360 log("f_tc_ho_neighbor_config: 4. explicit remote neighbor: 'neighbor lac 99 arfcn 123 bsic 45'");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005361 f_bts_0_cfg(BSCVTY, {"no neighbors", "neighbor lac 99 arfcn 123 bsic 45"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02005362 f_sleep(0.5);
5363
5364 f_probe_for_handover("4.a", "HO to bts 1 doesn't work, not listed as neighbor",
5365 "handover any to arfcn 871 bsic 11",
5366 false);
5367 f_probe_for_handover("4.b", "HO to bts 2 doesn't work, not listed as neighbor",
5368 "handover any to arfcn 871 bsic 12",
5369 false);
5370 f_probe_for_handover("4.c", "HO to 123-45 triggers inter-BSC HO",
5371 "handover any to arfcn 123 bsic 45",
5372 true, true);
5373}
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005374testcase TC_ho_neighbor_config_4() runs on test_CT {
5375 var MSC_ConnHdlr vc_conn;
5376 f_init(3, true, guard_timeout := 50.0);
5377 f_sleep(1.0);
5378 f_ctrs_bsc_and_bts_init();
5379 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_4));
5380 vc_conn.done;
5381
5382 /* f_tc_ho_neighbor_config_start() */
5383 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5384 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5385
5386 /* 4.a */
5387 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5388 f_ctrs_bsc_and_bts_add(0, "handover:error");
5389
5390 /* 4.b */
5391 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5392 f_ctrs_bsc_and_bts_add(0, "handover:error");
5393
5394 /* 4.c */
5395 /* "timeout" means a handover was triggered and started (which is all this test aims for) and the test ended the
5396 * handover quickly by timing out after the Handover Required message */
5397 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5398 f_ctrs_bsc_and_bts_add(0, "handover:timeout");
5399 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
5400 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:timeout");
5401
5402 f_ctrs_bsc_and_bts_verify();
5403}
5404
Neels Hofmeyr91401012019-07-11 00:42:35 +02005405private function f_tc_ho_neighbor_config_5(charstring id) runs on MSC_ConnHdlr {
5406 f_tc_ho_neighbor_config_start();
5407
5408 /*
5409 * bts 0 ARFCN 871 BSIC 10
5410 * bts 1 ARFCN 871 BSIC 11
5411 * bts 2 ARFCN 871 BSIC 12
5412 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
5413 */
5414
5415 log("f_tc_ho_neighbor_config: 5. explicit remote neighbor re-using ARFCN+BSIC: 'neighbor lac 99 arfcn 871 bsic 12'");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005416 f_bts_0_cfg(BSCVTY, {"no neighbors", "neighbor lac 99 arfcn 871 bsic 12"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02005417 f_sleep(0.5);
5418
5419 f_probe_for_handover("5.a", "HO to 871-12 triggers inter-BSC HO (ignoring local cells with same ARFCN+BSIC)",
5420 "handover any to arfcn 871 bsic 12",
5421 true, true);
5422}
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005423testcase TC_ho_neighbor_config_5() runs on test_CT {
5424 var MSC_ConnHdlr vc_conn;
5425 f_init(3, true);
5426 f_sleep(1.0);
5427 f_ctrs_bsc_and_bts_init();
5428 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_5));
5429 vc_conn.done;
5430
5431 /* f_tc_ho_neighbor_config_start() */
5432 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5433 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5434
5435 /* 5 */
5436 /* "timeout" means a handover was triggered and started (which is all this test aims for) and the test ended the
5437 * handover quickly by timing out after the Handover Required message */
5438 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5439 f_ctrs_bsc_and_bts_add(0, "handover:timeout");
5440 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
5441 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:timeout");
5442
5443 f_ctrs_bsc_and_bts_verify();
5444}
5445
Neels Hofmeyr91401012019-07-11 00:42:35 +02005446private function f_tc_ho_neighbor_config_6(charstring id) runs on MSC_ConnHdlr {
5447 f_tc_ho_neighbor_config_start();
5448
5449 /*
5450 * bts 0 ARFCN 871 BSIC 10
5451 * bts 1 ARFCN 871 BSIC 11
5452 * bts 2 ARFCN 871 BSIC 12
5453 * bts 3 ARFCN 871 BSIC 12 serves as ambiguity for bts 2, re-using the ARFCN+BSIC
5454 */
5455
5456 log("f_tc_ho_neighbor_config: 6. config error: explicit local and remote neighbors with ambiguous ARFCN+BSIC:"
5457 & " 'neighbor bts 2; neighbor lac 99 arfcn 871 bsic 12'");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005458 f_bts_0_cfg(BSCVTY, {"no neighbors", "neighbor bts 2", "neighbor lac 99 arfcn 871 bsic 12"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02005459 f_sleep(0.5);
5460
5461 f_probe_for_handover("6.a", "HO to 871-12 is ambiguous = error",
5462 "handover any to arfcn 871 bsic 12",
5463 false);
5464}
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005465testcase TC_ho_neighbor_config_6() runs on test_CT {
5466 var MSC_ConnHdlr vc_conn;
5467 f_init(3, true);
5468 f_sleep(1.0);
5469 f_ctrs_bsc_and_bts_init();
5470 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_6));
5471 vc_conn.done;
5472
5473 /* f_tc_ho_neighbor_config_start() */
5474 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5475 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5476
5477 /* 6.a */
5478 /* "timeout" means a handover was triggered and started (which is all this test aims for) and the test ended the
5479 * handover quickly by timing out after the Handover Required message */
5480 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5481 f_ctrs_bsc_and_bts_add(0, "handover:error");
5482
5483 f_ctrs_bsc_and_bts_verify();
5484}
5485
Neels Hofmeyr91401012019-07-11 00:42:35 +02005486private function f_tc_ho_neighbor_config_7(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: 7. explicit local and remote neighbors:"
5497 & " 'neighbor bts 2; neighbor lac 99 arfcn 123 bsic 45'");
Neels Hofmeyr666f0432020-07-04 00:53:07 +02005498 f_bts_0_cfg(BSCVTY, {"no neighbors", "neighbor bts 2", "neighbor lac 99 arfcn 123 bsic 45"});
Neels Hofmeyr91401012019-07-11 00:42:35 +02005499 f_sleep(0.5);
5500
5501 f_probe_for_handover("7.a", "HO to 871-12 does HO to bts 2",
5502 "handover any to arfcn 871 bsic 12",
5503 true);
5504 f_probe_for_handover("7.b", "HO to 123-45 triggers inter-BSC HO",
5505 "handover any to arfcn 123 bsic 45",
5506 true, true);
5507}
Neels Hofmeyr91401012019-07-11 00:42:35 +02005508testcase TC_ho_neighbor_config_7() runs on test_CT {
5509 var MSC_ConnHdlr vc_conn;
Neels Hofmeyrf2b88032020-06-16 00:35:04 +02005510 f_init(3, true, guard_timeout := 50.0);
Neels Hofmeyr91401012019-07-11 00:42:35 +02005511 f_sleep(1.0);
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005512 f_ctrs_bsc_and_bts_init();
Neels Hofmeyr91401012019-07-11 00:42:35 +02005513 vc_conn := f_start_handler(refers(f_tc_ho_neighbor_config_7));
5514 vc_conn.done;
Neels Hofmeyr12941bd2020-08-29 03:21:26 +00005515
5516 /* f_tc_ho_neighbor_config_start() */
5517 f_ctrs_bsc_and_bts_add(0, "assignment:attempted");
5518 f_ctrs_bsc_and_bts_add(0, "assignment:completed");
5519
5520 /* 7.a */
5521 /* "failed" means a handover was triggered and started (which is all this test aims for) and the test ended the
5522 * handover quickly by sending a Handover Failure message. */
5523 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5524 f_ctrs_bsc_and_bts_add(0, "handover:failed");
5525 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:attempted");
5526 f_ctrs_bsc_and_bts_add(0, "intra_bsc_ho:failed");
5527
5528 /* 7.b */
5529 /* "timeout" means a handover was triggered and started (which is all this test aims for) and the test ended the
5530 * handover quickly by timing out after the Handover Required message */
5531 f_ctrs_bsc_and_bts_add(0, "handover:attempted");
5532 f_ctrs_bsc_and_bts_add(0, "handover:timeout");
5533 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:attempted");
5534 f_ctrs_bsc_and_bts_add(0, "interbsc_ho_out:timeout");
5535
5536 f_ctrs_bsc_and_bts_verify();
Neels Hofmeyr91401012019-07-11 00:42:35 +02005537}
5538
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01005539/* OS#3041: Open and close N connections in a normal fashion, and expect no
5540 * BSSMAP Reset just because of that. */
5541testcase TC_bssap_rlsd_does_not_cause_bssmap_reset() runs on test_CT {
5542 var default d;
5543 var integer i;
5544 var DchanTuple dt;
5545
5546 f_init();
5547
5548 /* Wait for initial BSSMAP Reset to pass */
5549 f_sleep(4.0);
5550
5551 d := activate(no_bssmap_reset());
5552
5553 /* Setup up a number of connections and RLSD them again from the MSC
5554 * side. In the buggy behavior, the fourth one triggers BSSMAP Reset.
5555 * Let's do it some more times for good measure. */
Harald Weltec3260d92018-06-11 17:48:16 +02005556 for (i := 0; i < 4; i := i+1) {
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01005557 /* Since we're doing a lot of runs, give each one a fresh
5558 * T_guard from the top. */
5559 T_guard.start;
5560
5561 /* Setup a BSSAP connection and clear it right away. This is
5562 * the MSC telling the BSC about a planned release, it's not an
5563 * erratic loss of a connection. */
Harald Weltea1897182018-06-11 13:53:09 +02005564 dt := f_est_dchan(int2oct(i,1), 23+i, '00010203040506'O);
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01005565
5566 /* MSC disconnects (RLSD). */
5567 BSSAP.send(ts_BSSAP_DISC_req(dt.sccp_conn_id, 0));
5568 }
5569
5570 /* In the buggy behavior, a timeout of 2 seconds happens between above
5571 * trigger (logs "SIGTRAN connection down, reconnecting...") and the
5572 * actual BSSMAP Reset. Wait a bit longer just to make sure. */
5573 f_sleep(4.0);
5574
5575 deactivate(d);
5576 f_shutdown_helper();
5577}
Harald Welte552620d2017-12-16 23:21:36 +01005578
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01005579/* OS#3041: Open and close N connections in a normal fashion, and expect no
5580 * BSSMAP Reset just because of that. Invoke the release by a BSSMAP Clear from
5581 * the MSC. */
5582testcase TC_bssmap_clear_does_not_cause_bssmap_reset() runs on test_CT {
5583 var default d;
5584 var integer i;
5585 var DchanTuple dt;
5586 var BSSAP_N_DATA_ind rx_di;
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01005587 var myBSSMAP_Cause cause_val := GSM0808_CAUSE_CALL_CONTROL;
5588 var BssmapCause cause := enum2int(cause_val);
5589
5590 f_init();
5591
5592 /* Wait for initial BSSMAP Reset to pass */
5593 f_sleep(4.0);
5594
5595 d := activate(no_bssmap_reset());
5596
5597 /* Setup up a number of connections and RLSD them again from the MSC
5598 * side. In the buggy behavior, the fourth one triggers BSSMAP Reset.
5599 * Let's do it some more times for good measure. */
5600 for (i := 0; i < 8; i := i+1) {
5601 /* Since we're doing a lot of runs, give each one a fresh
5602 * T_guard from the top. */
5603 T_guard.start;
5604
5605 /* Setup a BSSAP connection and clear it right away. This is
5606 * the MSC telling the BSC about a planned release, it's not an
5607 * erratic loss of a connection. */
Harald Weltea1897182018-06-11 13:53:09 +02005608 dt := f_est_dchan(int2oct(i,1), 23+i, '00010203040506'O);
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01005609
5610 /* Instruct BSC to clear channel */
5611 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
5612
5613 /* expect BSC to disable the channel */
Harald Welte641fcbe2018-06-14 10:58:35 +02005614 f_exp_chan_rel_and_clear(dt, 0);
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01005615 }
5616
5617 /* In the buggy behavior, a timeout of 2 seconds happens between above
5618 * trigger (logs "SIGTRAN connection down, reconnecting...") and the
5619 * actual BSSMAP Reset. Wait a bit longer just to make sure. */
5620 f_sleep(4.0);
5621
5622 deactivate(d);
5623 f_shutdown_helper();
5624}
5625
Neels Hofmeyrfd445c32018-03-09 15:39:31 +01005626/* OS#3041: Open and close N connections in a normal fashion, and expect no
5627 * BSSMAP Reset just because of that. Close connections from the MS side with a
5628 * Release Ind on RSL. */
5629testcase TC_ms_rel_ind_does_not_cause_bssmap_reset() runs on test_CT {
5630 var default d;
5631 var integer i;
5632 var DchanTuple dt;
5633 var BSSAP_N_DATA_ind rx_di;
Neels Hofmeyrfd445c32018-03-09 15:39:31 +01005634 var integer j;
5635
5636 f_init();
5637
5638 /* Wait for initial BSSMAP Reset to pass */
5639 f_sleep(4.0);
5640
5641 d := activate(no_bssmap_reset());
5642
5643 /* Setup up a number of connections and RLSD them again from the MSC
5644 * side. In the buggy behavior, the fourth one triggers BSSMAP Reset.
5645 * Let's do it some more times for good measure. */
5646 for (i := 0; i < 8; i := i+1) {
5647 /* Since we're doing a lot of runs, give each one a fresh
5648 * T_guard from the top. */
5649 T_guard.start;
5650
5651 /* Setup a BSSAP connection and clear it right away. This is
5652 * the MSC telling the BSC about a planned release, it's not an
5653 * erratic loss of a connection. */
5654 dt := f_est_dchan('23'O, 23, '00010203040506'O);
5655
5656 /* simulate RLL REL IND */
5657 f_ipa_tx(0, ts_RSL_REL_IND(dt.rsl_chan_nr, valueof(ts_RslLinkID_DCCH(0))));
5658
5659 /* expect Clear Request on MSC side */
5660 BSSAP.receive(tr_BSSAP_DATA_ind(dt.sccp_conn_id, tr_BSSMAP_ClearRequest)) -> value rx_di;
5661
5662 /* Instruct BSC to clear channel */
5663 var BssmapCause cause := bit2int(rx_di.userData.pdu.bssmap.clearRequest.cause.causeValue);
5664 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ts_BSSMAP_ClearCommand(cause)));
5665
5666 /* expect BSC to disable the channel */
Harald Welte641fcbe2018-06-14 10:58:35 +02005667 f_exp_chan_rel_and_clear(dt, 0);
Neels Hofmeyrfd445c32018-03-09 15:39:31 +01005668 }
5669
5670 /* In the buggy behavior, a timeout of 2 seconds happens between above
5671 * trigger (logs "SIGTRAN connection down, reconnecting...") and the
5672 * actual BSSMAP Reset. Wait a bit longer just to make sure. */
5673 f_sleep(4.0);
5674
5675 deactivate(d);
5676 f_shutdown_helper();
5677}
5678
Harald Welte94e0c342018-04-07 11:33:23 +02005679/***********************************************************************
5680 * IPA style dynamic PDCH
5681 ***********************************************************************/
5682
5683private function f_dyn_ipa_pdch_act(integer bts_nr, integer trx_nr, integer ts_nr,
5684 template (omit) RSL_Cause nack := omit)
5685runs on test_CT {
5686 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(ts_nr));
5687 var RSL_Message rsl_unused;
5688 /* ask BSC via VTY to activate a given IPA style chan as PDCH */
5689 f_vty_ts_action("pdch activate", bts_nr, trx_nr, ts_nr);
5690 /* expect the BSC to issue the related RSL command */
5691 rsl_unused := f_exp_ipa_rx(0, tr_RSL_IPA_PDCH_ACT(chan_nr));
5692 if (istemplatekind(nack, "omit")) {
5693 /* respond with a related acknowledgement */
5694 f_ipa_tx(0, ts_RSL_IPA_PDCH_ACT_ACK(chan_nr, ts_RSL_IE_FrameNumber(2342)));
5695 } else {
5696 f_ipa_tx(0, ts_RSL_IPA_PDCH_ACT_NACK(chan_nr, valueof(nack)));
5697 }
5698}
5699
5700private function f_dyn_ipa_pdch_deact(integer bts_nr, integer trx_nr, integer ts_nr,
5701 template (omit) RSL_Cause nack := omit)
5702runs on test_CT {
5703 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(ts_nr));
5704 var RSL_Message rsl_unused;
5705 /* ask BSC via VTY to activate a given IPA style chan as PDCH */
5706 f_vty_ts_action("pdch deactivate", bts_nr, trx_nr, ts_nr);
5707 /* expect the BSC to issue the related RSL command */
5708 rsl_unused := f_exp_ipa_rx(0, tr_RSL_IPA_PDCH_DEACT(chan_nr));
5709 if (istemplatekind(nack, "omit")) {
5710 /* respond with a related acknowledgement */
5711 f_ipa_tx(0, ts_RSL_IPA_PDCH_DEACT_ACK(chan_nr));
5712 } else {
5713 f_ipa_tx(0, ts_RSL_IPA_PDCH_DEACT_NACK(chan_nr, valueof(nack)));
5714 }
5715}
5716
5717private function f_ts_dyn_mode_get(integer bts_nr, integer trx_nr, integer ts_nr)
5718runs on test_CT return charstring {
5719 var charstring cmd, resp;
5720 cmd := "show timeslot "&int2str(bts_nr)&" "&int2str(trx_nr)&" "&int2str(ts_nr);
Stefan Sperlingcff13562018-11-13 15:24:06 +01005721 return f_vty_transceive_match_regexp_retry(BSCVTY, cmd, "*\((*)\)*", 0, 4, 1.0);
Harald Welte94e0c342018-04-07 11:33:23 +02005722}
5723
5724private function f_ts_dyn_mode_assert(integer bts_nr, integer trx_nr, integer ts_nr,
5725 template charstring exp)
5726runs on test_CT {
5727 var charstring mode := f_ts_dyn_mode_get(bts_nr, trx_nr, ts_nr);
5728 if (not match(mode, exp)) {
5729 setverdict(fail, "Unexpected TS Mode: ", mode);
Daniel Willmannafce8662018-07-06 23:11:32 +02005730 mtc.stop;
Harald Welte94e0c342018-04-07 11:33:23 +02005731 }
5732}
5733
5734private function f_ts_set_chcomb(integer bts_nr, integer trx_nr, integer ts_nr, charstring chcomb)
5735runs on test_CT {
5736 f_vty_enter_cfg_ts(BSCVTY, bts_nr, trx_nr, ts_nr);
5737 f_vty_transceive(BSCVTY, "phys_chan_config " & chcomb);
5738 f_vty_transceive(BSCVTY, "end");
5739}
5740
5741private const charstring TCHF_MODE := "TCH/F mode";
5742private const charstring TCHH_MODE := "TCH/H mode";
5743private const charstring PDCH_MODE := "PDCH mode";
5744private const charstring NONE_MODE := "NONE mode";
5745
5746/* Test IPA PDCH activation / deactivation triggered by VTY */
5747testcase TC_dyn_pdch_ipa_act_deact() runs on test_CT {
5748 var RSL_Message rsl_unused;
5749
5750 /* change Timeslot 6 before f_init() starts RSL */
5751 f_init_vty();
5752 f_ts_set_chcomb(0, 0, 6, "TCH/F_PDCH");
5753 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
5754
5755 f_init(1, false);
5756 f_sleep(1.0);
5757
5758 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(6));
5759
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02005760 log("TCH/F_PDCH pchan starts out in TCH/F mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02005761 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
5762 /* The BSC will activate the dynamic PDCH by default, so confirm that */
5763 rsl_unused := f_exp_ipa_rx(0, tr_RSL_IPA_PDCH_ACT(chan_nr));
5764 f_ipa_tx(0, ts_RSL_IPA_PDCH_ACT_ACK(chan_nr, ts_RSL_IE_FrameNumber(2342)));
5765 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02005766 log("TCH/F_PDCH pchan, PDCH ACT was ACKed, so now in PDCH mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02005767 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, PDCH_MODE);
5768
5769 /* De-activate it via VTY */
5770 f_dyn_ipa_pdch_deact(0, 0, chan_nr.tn);
5771 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02005772 log("TCH/F_PDCH pchan, PDCH DEACT via VTY, so now back in TCH/F mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02005773 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
5774
5775 /* re-activate it via VTY */
5776 f_dyn_ipa_pdch_act(0, 0, chan_nr.tn);
5777 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02005778 log("TCH/F_PDCH pchan, PDCH ACT via VTY, so now in PDCH mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02005779 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, PDCH_MODE);
5780
5781 /* and finally de-activate it again */
5782 f_dyn_ipa_pdch_deact(0, 0, chan_nr.tn);
5783 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02005784 log("TCH/F_PDCH pchan, PDCH DEACT via VTY, so now back in TCH/F mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02005785 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
5786
Neels Hofmeyr887e8f12018-06-27 01:01:55 +02005787 /* clean up config */
5788 f_ts_set_chcomb(0, 0, 6, "PDCH");
5789
Harald Welte94e0c342018-04-07 11:33:23 +02005790 setverdict(pass);
5791}
5792
5793/* Test IPA PDCH activation NACK */
5794testcase TC_dyn_pdch_ipa_act_nack() runs on test_CT {
5795 var RSL_Message rsl_unused;
5796
5797 /* change Timeslot 6 before f_init() starts RSL */
5798 f_init_vty();
5799 f_ts_set_chcomb(0, 0, 6, "TCH/F_PDCH");
5800 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
5801
5802 f_init(1, false);
5803 f_sleep(1.0);
5804
5805 var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(6));
5806
5807 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
5808 /* The BSC will activate the dynamic PDCH by default, so confirm that */
5809 rsl_unused := f_exp_ipa_rx(0, tr_RSL_IPA_PDCH_ACT(chan_nr));
5810 f_ipa_tx(0, ts_RSL_IPA_PDCH_ACT_ACK(chan_nr, ts_RSL_IE_FrameNumber(2342)));
5811 f_sleep(1.0);
5812 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, PDCH_MODE);
5813
5814 /* De-activate it via VTY */
5815 f_dyn_ipa_pdch_deact(0, 0, chan_nr.tn);
5816 f_sleep(1.0);
5817 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
5818
5819 /* re-activate it via VTY, but fail that; check BSC still assumes TCH/F mode */
5820 f_dyn_ipa_pdch_act(0, 0, chan_nr.tn, RSL_ERR_EQUIPMENT_FAIL);
5821 f_sleep(1.0);
5822 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, TCHF_MODE);
5823
Neels Hofmeyr887e8f12018-06-27 01:01:55 +02005824 /* clean up config */
5825 f_ts_set_chcomb(0, 0, 6, "PDCH");
5826
Harald Welte94e0c342018-04-07 11:33:23 +02005827 setverdict(pass);
5828}
5829
5830
5831/***********************************************************************
5832 * Osmocom style dynamic PDCH
5833 ***********************************************************************/
5834
5835private function f_dyn_osmo_pdch_act(integer bts_nr, integer trx_nr, integer ts_nr,
5836 template (omit) RSL_Cause nack := omit)
5837runs on test_CT {
5838 var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(ts_nr));
5839 var RSL_Message rsl_unused;
5840 /* ask BSC via VTY to activate a given IPA style chan as PDCH */
5841 /* FIXME: no VTY command to activate Osmocom PDCH !! */
5842 /* expect the BSC to issue the related RSL command */
5843 rsl_unused := f_exp_ipa_rx(0, tr_RSL_CHAN_ACT(chan_nr, ?));
5844 if (istemplatekind(nack, "omit")) {
5845 /* respond with a related acknowledgement */
5846 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, 2342));
5847 } else {
5848 f_ipa_tx(0, ts_RSL_CHAN_ACT_NACK(chan_nr, valueof(nack)));
5849 }
5850}
5851
5852private function f_dyn_osmo_pdch_deact(integer bts_nr, integer trx_nr, integer ts_nr,
5853 template (omit) RSL_Cause nack := omit)
5854runs on test_CT {
5855 var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(ts_nr));
5856 var RSL_Message rsl_unused;
5857 /* ask BSC via VTY to activate a given IPA style chan as PDCH */
5858 /* FIXME: no VTY command to activate Osmocom PDCH !! */
5859 /* expect the BSC to issue the related RSL command */
5860 rsl_unused := f_exp_ipa_rx(0, tr_RSL_RF_CHAN_REL(chan_nr));
5861 if (istemplatekind(nack, "omit")) {
5862 /* respond with a related acknowledgement */
5863 f_ipa_tx(0, ts_RSL_RF_CHAN_REL_ACK(chan_nr));
5864 } else {
5865 //f_ipa_tx(0, ts_RSL_RF_CHAN_REL_NACK(chan_nr, valueof(nack)));
5866 }
5867}
5868
5869/* Test Osmocom dyn PDCH activation / deactivation triggered by VTY */
5870testcase TC_dyn_pdch_osmo_act_deact() runs on test_CT {
5871 var RSL_Message rsl_unused;
5872
5873 /* change Timeslot 6 before f_init() starts RSL */
5874 f_init_vty();
5875 f_ts_set_chcomb(0, 0, 6, "TCH/F_TCH/H_PDCH");
5876 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
5877
5878 f_init(1, false);
5879 f_sleep(1.0);
5880
5881 var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(6));
5882
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02005883 log("TCH/F_TCH/H_PDCH pchan starts out in disabled mode:");
Harald Welte94e0c342018-04-07 11:33:23 +02005884 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, NONE_MODE);
5885 /* The BSC will activate the dynamic PDCH by default, so confirm that */
5886 rsl_unused := f_exp_ipa_rx(0, tr_RSL_CHAN_ACT_PDCH(chan_nr, ?));
5887
5888 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, 2342));
5889 f_sleep(1.0);
Neels Hofmeyrda4a6952018-06-14 04:02:49 +02005890 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 +02005891 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, PDCH_MODE);
5892
Neels Hofmeyr887e8f12018-06-27 01:01:55 +02005893 /* clean up config */
5894 f_ts_set_chcomb(0, 0, 6, "PDCH");
5895
Harald Welte94e0c342018-04-07 11:33:23 +02005896 setverdict(pass);
5897}
5898
5899/* Test Osmocom dyn PDCH activation NACK behavior */
5900testcase TC_dyn_pdch_osmo_act_nack() runs on test_CT {
5901 var RSL_Message rsl_unused;
5902
5903 /* change Timeslot 6 before f_init() starts RSL */
5904 f_init_vty();
5905 f_ts_set_chcomb(0, 0, 6, "TCH/F_TCH/H_PDCH");
5906 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
5907
5908 f_init(1, false);
5909 f_sleep(1.0);
5910
5911 var RslChannelNr chan_nr := valueof(t_RslChanNr_PDCH(6));
5912
5913 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, NONE_MODE);
5914 /* The BSC will activate the dynamic PDCH by default, so confirm that */
5915 rsl_unused := f_exp_ipa_rx(0, tr_RSL_CHAN_ACT_PDCH(chan_nr, ?));
5916
5917 /* NACK this activation and expect the "show timeslot" mode still to be NONE */
5918 f_ipa_tx(0, ts_RSL_CHAN_ACT_NACK(chan_nr, RSL_ERR_EQUIPMENT_FAIL));
5919 f_sleep(1.0);
5920 f_ts_dyn_mode_assert(0, 0, chan_nr.tn, NONE_MODE);
5921
Neels Hofmeyr887e8f12018-06-27 01:01:55 +02005922 /* clean up config */
5923 f_ts_set_chcomb(0, 0, 6, "PDCH");
5924
Harald Welte94e0c342018-04-07 11:33:23 +02005925 setverdict(pass);
5926}
5927
Stefan Sperling0796a822018-10-05 13:01:39 +02005928testcase TC_chopped_ipa_ping() runs on test_CT {
Stefan Sperling554123f2018-10-09 14:12:30 +02005929 const Integers bsc_ipa_ports := {mp_bsc_rsl_port, mp_bsc_oml_port, mp_bsc_ctrl_port};
Stefan Sperling0796a822018-10-05 13:01:39 +02005930 for (var integer i := 0; i < lengthof(bsc_ipa_ports); i := i + 1) {
5931 IPA_Testing.f_run_TC_chopped_ipa_ping(mp_bsc_ip, bsc_ipa_ports[i], CONNECT_TO_SERVER);
5932 }
5933}
5934
Stefan Sperlingaa1e60f2018-10-15 16:34:07 +02005935testcase TC_chopped_ipa_payload() runs on test_CT {
5936 const Integers bsc_ipa_ports := {mp_bsc_rsl_port, mp_bsc_oml_port
5937 /* TODO: mp_bsc_ctrl_port does not work yet */};
5938 for (var integer i := 0; i < lengthof(bsc_ipa_ports); i := i + 1) {
5939 IPA_Testing.f_run_TC_chopped_ipa_payload(mp_bsc_ip, bsc_ipa_ports[i], CONNECT_TO_SERVER);
5940 }
5941}
5942
Pau Espin Pedrol8f773632019-11-05 11:46:53 +01005943/* Verify the BSC sends the MS Power Parameters IE during CHAN ACT to make sure
5944 the BTS does autonomous MS power control loop */
5945testcase TC_assignment_verify_ms_power_params_ie() runs on test_CT {
5946 var MSC_ConnHdlr vc_conn;
5947 var TestHdlrParams pars := f_gen_test_hdlr_pars();
5948 //pars.encr := valueof(t_EncrParams('01'O, f_rnd_octstring(8)));
5949 pars.exp_ms_power_params := true;
5950
5951 f_init(1, true);
5952 f_sleep(1.0);
5953 vc_conn := f_start_handler(refers(f_tc_assignment_fr_a5), pars);
5954 vc_conn.done;
5955}
Stefan Sperlingaa1e60f2018-10-15 16:34:07 +02005956
Neels Hofmeyr4f118412020-06-04 15:25:10 +02005957/***********************************************************************
5958 * MSC Pooling
5959 ***********************************************************************/
5960
5961function f_tmsi_nri(integer nri_v, octetstring base_tmsi := '42000023'O, integer nri_bitlen := 10) return octetstring
5962{
5963 return int2oct( oct2int(base_tmsi) + bit2int( (int2bit(nri_v, 32) << ( 24 - nri_bitlen)) ),
5964 4);
5965}
5966
5967template MobileIdentityLV ts_MI_TMSI_NRI_LV(integer nri_v, integer nri_bitlen := 10) :=
5968 ts_MI_TMSI_LV(tmsi := f_tmsi_nri(nri_v, nri_bitlen := nri_bitlen));
5969
5970private function f_perform_clear(RSL_DCHAN_PT rsl) runs on MSC_ConnHdlr {
5971 f_logp("MSC instructs BSC to clear channel");
5972 BSSAP.send(ts_BSSMAP_ClearCommand(0));
5973 interleave {
5974 [] rsl.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_RELEASE)) {
5975 f_logp("Got RSL RR Release");
5976 }
5977 [] rsl.receive(tr_RSL_DEACT_SACCH(g_chan_nr)) {
5978 f_logp("Got RSL Deact SACCH");
5979 }
5980 [] BSSAP.receive(tr_BSSMAP_ClearComplete) {
5981 f_logp("Got BSSMAP Clear Complete");
5982 /* Also drop the SCCP connection */
5983 BSSAP.send(RAN_Conn_Prim:MSC_CONN_PRIM_DISC_REQ);
5984 }
5985 [] rsl.receive(tr_RSL_MsgTypeD(RSL_MT_RF_CHAN_REL)) {
5986 f_logp("Got RSL RF Chan Rel, sending Rel Ack");
5987 rsl.send(ts_RSL_RF_CHAN_REL_ACK(g_chan_nr));
5988 }
5989 }
5990}
5991
5992private function f_perform_compl_l3(RSL_DCHAN_PT rsl, template PDU_ML3_MS_NW l3_info, boolean do_clear := true)
5993runs on MSC_ConnHdlr {
5994 timer T := 10.0;
5995 var octetstring l3_enc := enc_PDU_ML3_MS_NW(valueof(l3_info));
5996
5997 f_logp("establish channel, send Complete Layer 3 Info");
5998 f_create_bssmap_exp(l3_enc);
5999
6000 /* RSL_Emulation.f_chan_est() on rsl:
6001 * This is basically code dup with s/RSL/rsl from:
6002 * RSL_Emulation.f_chan_est(g_pars.ra, l3_enc, g_pars.link_id, g_pars.fn);
6003 */
6004 var RSL_Message rx_rsl;
6005 var GsmRrMessage rr;
6006
6007 /* request a channel to be established */
6008 rsl.send(ts_RSLDC_ChanRqd(g_pars.ra, g_pars.fn));
6009 /* expect immediate assignment.
6010 * Code dup with s/RSL/rsl from:
6011 * rx_rsl := f_rx_or_fail(tr_RSL_IMM_ASSIGN);
6012 */
6013 timer Tt := 10.0;
6014
6015 /* request a channel to be established */
6016 Tt.start;
6017 alt {
6018 [] rsl.receive(tr_RSL_IMM_ASSIGN) -> value rx_rsl {
6019 Tt.stop;
6020 }
6021 [] rsl.receive {
6022 setverdict(fail, "Unexpected RSL message on DCHAN");
6023 mtc.stop;
6024 }
6025 [] Tt.timeout {
6026 setverdict(fail, "Timeout waiting for RSL on DCHAN");
6027 mtc.stop;
6028 }
6029 }
6030 rr := dec_GsmRrMessage(rx_rsl.ies[1].body.full_imm_ass_info.payload);
6031 g_chan_nr := rr.payload.imm_ass.chan_desc.chan_nr;
6032 rsl.send(ts_RSL_EST_IND(g_chan_nr, valueof(g_pars.link_id), l3_enc));
6033
6034
6035 f_logp("expect BSSAP Complete Layer 3 Info at MSC");
6036 var template PDU_BSSAP exp_l3_compl;
6037 exp_l3_compl := tr_BSSMAP_ComplL3()
6038 if (g_pars.aoip == false) {
6039 exp_l3_compl.pdu.bssmap.completeLayer3Information.codecList := omit;
6040 } else {
6041 exp_l3_compl.pdu.bssmap.completeLayer3Information.codecList := ?;
6042 }
6043
6044 var PDU_BSSAP bssap;
6045 T.start;
6046 alt {
6047 [] BSSAP.receive(exp_l3_compl) -> value bssap {
6048 f_logp("received expected Complete Layer 3 Info at MSC");
6049 log("rx exp_l3_compl = ", bssap);
6050 }
6051 [] BSSAP.receive(tr_BSSMAP_ComplL3) {
6052 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Received non-matching COMPLETE LAYER 3 INFORMATION");
6053 }
6054 [] T.timeout {
6055 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for COMPLETE LAYER 3 INFORMATION");
6056 }
6057 }
6058
6059 /* start ciphering, if requested */
6060 if (ispresent(g_pars.encr)) {
6061 f_logp("start ciphering");
6062 f_cipher_mode(g_pars.encr.enc_alg, g_pars.encr.enc_key);
6063 }
6064
6065 if (do_clear) {
6066 f_perform_clear(rsl);
6067 }
6068 setverdict(pass);
6069 f_sleep(1.0);
6070}
6071
6072private function f_tc_mscpool_compl_l3(charstring id) runs on MSC_ConnHdlr {
6073 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
6074 if (g_pars.mscpool.rsl_idx == 0) {
6075 f_perform_compl_l3(RSL, g_pars.mscpool.l3_info);
6076 } else if (g_pars.mscpool.rsl_idx == 1) {
6077 f_perform_compl_l3(RSL1, g_pars.mscpool.l3_info);
6078 } else if (g_pars.mscpool.rsl_idx == 2) {
6079 f_perform_compl_l3(RSL2, g_pars.mscpool.l3_info);
6080 }
6081}
6082
6083/* Various Complete Layer 3 by IMSI all end up with the first MSC, because the other MSCs are not connected. */
6084private function f_tc_mscpool_L3Compl_on_1_msc(charstring id) runs on MSC_ConnHdlr {
6085 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
6086 f_perform_compl_l3(RSL, ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_IMSI_LV('001010000000001'H)), '00F110'O) );
6087 f_perform_compl_l3(RSL, ts_CM_SERV_REQ(CM_TYPE_MO_SMS, valueof(ts_MI_IMSI_LV('001010000000002'H))) );
6088 f_perform_compl_l3(RSL, ts_PAG_RESP(valueof(ts_MI_IMSI_LV('001010000000003'H))) );
6089 f_perform_compl_l3(RSL, ts_ML3_MO_MM_IMSI_DET_Ind(valueof(ts_MI_IMSI_LV('001010000000004'H))) );
6090}
6091testcase TC_mscpool_L3Compl_on_1_msc() runs on test_CT {
6092
6093 f_init(1, true);
6094 f_sleep(1.0);
6095 var MSC_ConnHdlr vc_conn;
6096 var TestHdlrParams pars := f_gen_test_hdlr_pars();
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006097
6098 f_ctrs_msc_init();
6099
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006100 vc_conn := f_start_handler(refers(f_tc_mscpool_L3Compl_on_1_msc), pars);
6101 vc_conn.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006102
6103 f_ctrs_msc_expect(0, "mscpool:subscr:new", 4);
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006104}
6105
6106/* Three Layer 3 Complete by IMSI are round-robin'ed across two connected MSCs */
6107/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
6108 * just as well using only RSL. */
6109testcase TC_mscpool_L3Complete_by_imsi_round_robin() runs on test_CT {
6110
6111 f_init(nr_bts := 3, handler_mode := true, nr_msc := 2);
6112 f_sleep(1.0);
6113
6114 /* Control which MSC gets chosen next by the round-robin, otherwise
6115 * would be randomly affected by which other tests ran before this. */
6116 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
6117
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006118 f_ctrs_msc_init();
6119
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006120 var MSC_ConnHdlr vc_conn1;
6121 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
6122 pars1.mscpool.rsl_idx := 0;
6123 pars1.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_IMSI_LV('001010000000001'H)), '00F110'O));
6124 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6125 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006126 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006127
6128 var MSC_ConnHdlr vc_conn2;
6129 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 1);
6130 pars2.mscpool.rsl_idx := 1;
6131 pars2.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, valueof(ts_MI_IMSI_LV('001010000000002'H))));
6132 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6133 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006134 f_ctrs_msc_expect(1, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006135
6136 /* Test round-robin wrap to the first MSC */
6137 var MSC_ConnHdlr vc_conn3;
6138 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 0);
6139 pars3.mscpool.rsl_idx := 2;
6140 pars3.mscpool.l3_info := valueof(ts_PAG_RESP(valueof(ts_MI_IMSI_LV('001010000000003'H))));
6141 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
6142 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006143 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006144}
6145
6146/* Three LU by TMSI are round-robin'ed across two connected MSCs, because they contain the NULL-NRI 0
6147 * (configured in osmo-bsc.cfg). */
6148/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
6149 * just as well using only RSL. */
6150testcase TC_mscpool_LU_by_tmsi_null_nri_0_round_robin() runs on test_CT {
6151
6152 f_init(nr_bts := 3, handler_mode := true, nr_msc := 2);
6153 f_sleep(1.0);
6154
6155 /* Control which MSC gets chosen next by the round-robin, otherwise
6156 * would be randomly affected by which other tests ran before this. */
6157 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
6158
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006159 f_ctrs_msc_init();
6160
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006161 var MSC_ConnHdlr vc_conn1;
6162 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
6163 pars1.mscpool.rsl_idx := 0;
6164 pars1.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(0)), '00F110'O));
6165 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6166 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006167 f_ctrs_msc_expect(0, "mscpool:subscr:reattach");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006168
6169 var MSC_ConnHdlr vc_conn2;
6170 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 1);
6171 pars2.mscpool.rsl_idx := 1;
6172 pars2.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(0)), '00F110'O));
6173 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6174 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006175 f_ctrs_msc_expect(1, "mscpool:subscr:reattach");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006176
6177 /* Test round-robin wrap to the first MSC */
6178 var MSC_ConnHdlr vc_conn3;
6179 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 0);
6180 pars3.mscpool.rsl_idx := 2;
6181 pars3.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(0)), '00F110'O));
6182 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
6183 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006184 f_ctrs_msc_expect(0, "mscpool:subscr:reattach");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006185}
6186
6187/* Three LU by TMSI are round-robin'ed across two connected MSCs, because they contain the NULL-NRI 1
6188 * (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
6189 * NULL-NRI setting is stronger than that. */
6190/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
6191 * just as well using only RSL. */
6192testcase TC_mscpool_LU_by_tmsi_null_nri_1_round_robin() runs on test_CT {
6193
6194 f_init(nr_bts := 3, handler_mode := true, nr_msc := 2);
6195 f_sleep(1.0);
6196
6197 /* Control which MSC gets chosen next by the round-robin, otherwise
6198 * would be randomly affected by which other tests ran before this. */
6199 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
6200
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006201 f_ctrs_msc_init();
6202
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006203 var MSC_ConnHdlr vc_conn1;
6204 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
6205 pars1.mscpool.rsl_idx := 0;
6206 pars1.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(1)), '00F110'O));
6207 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6208 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006209 f_ctrs_msc_expect(0, "mscpool:subscr:reattach");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006210
6211 var MSC_ConnHdlr vc_conn2;
6212 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 1);
6213 pars2.mscpool.rsl_idx := 1;
6214 pars2.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(1)), '00F110'O));
6215 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6216 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006217 f_ctrs_msc_expect(1, "mscpool:subscr:reattach");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006218
6219 /* Test round-robin wrap to the first MSC */
6220 var MSC_ConnHdlr vc_conn3;
6221 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 0);
6222 pars3.mscpool.rsl_idx := 2;
6223 pars3.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(1)), '00F110'O));
6224 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
6225 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006226 f_ctrs_msc_expect(0, "mscpool:subscr:reattach");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006227}
6228
6229/* Three Layer 3 Complete by TMSI are round-robin'ed across two connected MSCs, because they contain an NRI not
6230 * assigned to any MSC (configured in osmo-bsc.cfg). */
6231/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
6232 * just as well using only RSL. */
6233testcase TC_mscpool_L3Complete_by_tmsi_unassigned_nri_round_robin() runs on test_CT {
6234
6235 f_init(nr_bts := 3, handler_mode := true, nr_msc := 2);
6236 f_sleep(1.0);
6237
6238 /* Control which MSC gets chosen next by the round-robin, otherwise
6239 * would be randomly affected by which other tests ran before this. */
6240 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
6241
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006242 f_ctrs_msc_init();
6243
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006244 var MSC_ConnHdlr vc_conn1;
6245 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
6246 pars1.mscpool.rsl_idx := 0;
6247 /* An NRI that is not assigned to any MSC */
6248 pars1.mscpool.l3_info := valueof(ts_ML3_MO_MM_IMSI_DET_Ind(valueof(ts_MI_TMSI_NRI_LV(1023))));
6249 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6250 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006251 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006252
6253 var MSC_ConnHdlr vc_conn2;
6254 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 1);
6255 pars2.mscpool.rsl_idx := 1;
6256 /* An NRI that is not assigned to any MSC */
6257 pars2.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(768)), '00F110'O));
6258 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6259 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006260 f_ctrs_msc_expect(1, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006261
6262 /* Test round-robin wrap to the first MSC */
6263 var MSC_ConnHdlr vc_conn3;
6264 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 0);
6265 pars3.mscpool.rsl_idx := 2;
6266 /* An NRI that is not assigned to any MSC */
6267 pars3.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_SS_ACT, valueof(ts_MI_TMSI_NRI_LV(819))));
6268 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
6269 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006270 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006271}
6272
6273/* Three Layer 3 Complete by TMSI are round-robin'ed across two connected MSCs, because they contain an NRI
6274 * assigned to an MSC that is currently not connected (configured in osmo-bsc.cfg). */
6275/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
6276 * just as well using only RSL. */
6277testcase TC_mscpool_L3Complete_by_tmsi_valid_nri_msc_not_connected_round_robin() runs on test_CT {
6278
6279 f_init(nr_bts := 3, handler_mode := true, nr_msc := 2);
6280 f_sleep(1.0);
6281
6282 /* Control which MSC gets chosen next by the round-robin, otherwise
6283 * would be randomly affected by which other tests ran before this. */
6284 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
6285
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006286 f_ctrs_msc_init();
6287
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006288 var MSC_ConnHdlr vc_conn1;
6289 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
6290 pars1.mscpool.rsl_idx := 0;
6291 /* An NRI that is assigned to an unconnected MSC */
6292 pars1.mscpool.l3_info := valueof(ts_PAG_RESP(valueof(ts_MI_TMSI_NRI_LV(512))));
6293 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6294 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006295 f_ctrs_msc_add(2, "mscpool:subscr:attach_lost");
6296 f_ctrs_msc_add(0, "mscpool:subscr:new");
6297 f_ctrs_msc_verify();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006298
6299 var MSC_ConnHdlr vc_conn2;
6300 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 1);
6301 pars2.mscpool.rsl_idx := 1;
6302 /* An NRI that is assigned to an unconnected MSC */
6303 pars2.mscpool.l3_info := valueof(ts_ML3_MO_MM_IMSI_DET_Ind(valueof(ts_MI_TMSI_NRI_LV(767))));
6304 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6305 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006306 f_ctrs_msc_add(2, "mscpool:subscr:attach_lost");
6307 f_ctrs_msc_add(1, "mscpool:subscr:new");
6308 f_ctrs_msc_verify();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006309
6310 /* Test round-robin wrap to the first MSC */
6311 var MSC_ConnHdlr vc_conn3;
6312 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 0);
6313 pars3.mscpool.rsl_idx := 2;
6314 /* An NRI that is assigned to an unconnected MSC */
6315 pars3.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(750)), '00F110'O));
6316 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
6317 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006318 f_ctrs_msc_add(2, "mscpool:subscr:attach_lost");
6319 f_ctrs_msc_add(0, "mscpool:subscr:new");
6320 f_ctrs_msc_verify();
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006321}
6322
6323/* Three Layer 3 Complete by TMSI with valid NRI for the second MSC are all directed to the second MSC (configured in
6324 * osmo-bsc.cfg). */
6325/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
6326 * just as well using only RSL. */
6327testcase TC_mscpool_L3Complete_by_tmsi_valid_nri_1() runs on test_CT {
6328
6329 f_init(nr_bts := 3, handler_mode := true, nr_msc := 2);
6330 f_sleep(1.0);
6331
6332 /* All TMSIs in this test point at the second MSC, set the round robin to point at the first MSC to make sure
6333 * this is not using round-robin. */
6334 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
6335
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006336 f_ctrs_msc_init();
6337
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006338 var MSC_ConnHdlr vc_conn1;
6339 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 1);
6340 pars1.mscpool.rsl_idx := 0;
6341 /* An NRI of the second MSC's range (256-511) */
6342 pars1.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_SMS, valueof(ts_MI_TMSI_NRI_LV(256))));
6343 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6344 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006345 f_ctrs_msc_expect(1, "mscpool:subscr:known");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006346
6347 var MSC_ConnHdlr vc_conn2;
6348 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 1);
6349 pars2.mscpool.rsl_idx := 1;
6350 /* An NRI of the second MSC's range (256-511) */
6351 pars2.mscpool.l3_info := valueof(ts_PAG_RESP(valueof(ts_MI_TMSI_NRI_LV(260))));
6352 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6353 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006354 f_ctrs_msc_expect(1, "mscpool:subscr:known");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006355
6356 var MSC_ConnHdlr vc_conn3;
6357 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 1);
6358 pars3.mscpool.rsl_idx := 2;
6359 /* An NRI of the second MSC's range (256-511) */
6360 pars3.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(511)), '00F110'O));
6361 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
6362 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006363 f_ctrs_msc_expect(1, "mscpool:subscr:known");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006364}
6365
6366/* Layer 3 Complete by TMSI with valid NRI for the third MSC are directed to the third MSC (configured in osmo-bsc.cfg),
6367 * while a round-robin remains unaffected by that. */
6368/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
6369 * just as well using only RSL. */
6370testcase TC_mscpool_L3Complete_by_tmsi_valid_nri_2() runs on test_CT {
6371
6372 f_init(nr_bts := 3, handler_mode := true, nr_msc := 3);
6373 f_sleep(1.0);
6374
6375 /* All TMSIs in this test point at the third MSC, set the round robin to point at the second MSC to make sure
6376 * this is not using round-robin. */
6377 f_vty_transceive(BSCVTY, "mscpool roundrobin next 1");
6378
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006379 f_ctrs_msc_init();
6380
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006381 var MSC_ConnHdlr vc_conn1;
6382 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 2);
6383 pars1.mscpool.rsl_idx := 0;
6384 /* An NRI of the third MSC's range (512-767) */
6385 pars1.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_SMS, valueof(ts_MI_TMSI_NRI_LV(512))));
6386 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6387 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006388 f_ctrs_msc_expect(2, "mscpool:subscr:known");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006389
6390 var MSC_ConnHdlr vc_conn2;
6391 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 2);
6392 pars2.mscpool.rsl_idx := 1;
6393 /* An NRI of the third MSC's range (512-767) */
6394 pars2.mscpool.l3_info := valueof(ts_PAG_RESP(valueof(ts_MI_TMSI_NRI_LV(678))));
6395 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6396 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006397 f_ctrs_msc_expect(2, "mscpool:subscr:known");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006398
6399 /* The above forwardings to third MSC have not affected the round robin, which still points at the second MSC */
6400 var MSC_ConnHdlr vc_conn3;
6401 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 1);
6402 pars3.mscpool.rsl_idx := 2;
6403 pars3.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_IMSI_LV('001010000000013'H)), '00F110'O));
6404 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
6405 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006406 f_ctrs_msc_expect(1, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006407}
6408
6409/* LU with a TMSI but indicating a different PLMN in its previous LAI: ignore the NRI. */
6410/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
6411 * just as well using only RSL. */
6412testcase TC_mscpool_LU_by_tmsi_from_other_PLMN() runs on test_CT {
6413
6414 f_init(nr_bts := 3, handler_mode := true, nr_msc := 3);
6415 f_sleep(1.0);
6416
6417 /* The TMSIs in this test points at the second MSC, but since it is from a different PLMN, round-robin is used
6418 * instead, and hits msc 0. */
6419 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
6420
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006421 f_ctrs_msc_init();
6422
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006423 /* An NRI of the second MSC's range (256-511), but a PLMN that doesn't match with osmo-bsc.cfg */
6424 var MSC_ConnHdlr vc_conn1;
6425 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
6426 pars1.mscpool.rsl_idx := 0;
6427 pars1.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(260)), '99F999'O));
6428 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6429 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006430 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006431
6432 /* An NRI of the third MSC's range (512-767) and a matching PLMN gets directed by NRI. */
6433 var MSC_ConnHdlr vc_conn2;
6434 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 2);
6435 pars2.mscpool.rsl_idx := 1;
6436 pars2.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_TMSI_NRI_LV(555)), '00F110'O));
6437 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6438 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006439 f_ctrs_msc_expect(2, "mscpool:subscr:known");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006440}
6441
6442/* Make sure that whichever MSC paged a subscriber will also get the Paging Response. Page by IMSI, which would be
6443 * round-robined to another MSC, to make sure the Paging->Response relation is stronger than the NRI->MSC mapping. */
6444private function f_tc_mscpool_paging_imsi(charstring id) runs on MSC_ConnHdlr {
6445 var template BSSMAP_FIELD_CellIdentificationList cid_list := { cIl_CI := { ts_BSSMAP_CI_CI(0) } };
6446 //cid_list := { cIl_allInBSS := ''O };
6447 var RSL_ChanNeeded rsl_chneed := RSL_CHANNEED_SDCCH;
6448 var template BSSMAP_IE_ChannelNeeded bssmap_chneed := ts_BSSMAP_IE_ChanNeeded(int2bit(enum2int(valueof(rsl_chneed)),2));
6449 var BSSAP_N_UNITDATA_req paging;
6450 var hexstring imsi := '001010000000123'H;
6451
6452 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
6453
Neels Hofmeyr90f80962020-06-12 16:16:55 +02006454 paging := valueof(ts_BSSAP_UNITDATA_req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006455 valueof(ts_BSSMAP_Paging(imsi, cid_list, omit, bssmap_chneed))));
6456 BSSAP.send(paging);
6457
6458 /* Register any RSL conn so that the Paging Command gets received here. With the current RSL_Emulation's main()
6459 * handling of '[bts_role] IPA_PT.receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD()))' it doesn't matter at all which
6460 * channel number is picked here. */
6461 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(0, RSL_CHAN_NR_INVALID));
6462 f_rslem_register(0, new_chan_nr);
6463 RSL.receive(tr_RSL_PAGING_CMD(tr_MI_IMSI(imsi)));
6464 f_rslem_unregister(0, new_chan_nr);
6465
6466 /* Despite the round robin pointing at the second MSC ('roundrobin next 1'), the earlier Paging for the same IMSI
6467 * causes this Paging Response to go to the first MSC (bssap_idx := 0). */
6468 f_perform_compl_l3(RSL, ts_PAG_RESP(valueof(ts_MI_IMSI_LV(imsi))) );
6469 setverdict(pass);
6470 f_sleep(1.0);
6471}
6472testcase TC_mscpool_paging_and_response_imsi() runs on test_CT {
6473 f_init(nr_bts := 1, handler_mode := true, nr_msc := 3);
6474 f_sleep(1.0);
6475
6476 /* Testing a Paging on the first MSC to get a Paging Response back to the first MSC. Set round robin to the
6477 * second MSC to make sure we're getting the Paging logic, not a coincidental round robin match. */
6478 f_vty_transceive(BSCVTY, "mscpool roundrobin next 1");
6479
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006480 f_ctrs_msc_init();
6481
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006482 var MSC_ConnHdlr vc_conn1;
6483 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
6484 pars1.mscpool.rsl_idx := 0;
Neels Hofmeyr90f80962020-06-12 16:16:55 +02006485 pars1.sccp_addr_bsc := g_bssap[pars1.mscpool.bssap_idx].sccp_addr_peer;
6486 pars1.sccp_addr_msc := g_bssap[pars1.mscpool.bssap_idx].sccp_addr_own;
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006487 vc_conn1 := f_start_handler(refers(f_tc_mscpool_paging_imsi), pars1);
6488 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006489 f_ctrs_msc_expect(0, "mscpool:subscr:paged");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006490}
6491
6492/* Make sure that whichever MSC paged a subscriber will also get the Paging Response. Page by TMSI with an NRI value
6493 * that matches a different MSC, to make sure the Paging->Response relation is stronger than the NRI->MSC mapping. */
6494private function f_tc_mscpool_paging_tmsi(charstring id) runs on MSC_ConnHdlr {
6495 var template BSSMAP_FIELD_CellIdentificationList cid_list := { cIl_CI := { ts_BSSMAP_CI_CI(0) } };
6496 //cid_list := { cIl_allInBSS := ''O };
6497 var RSL_ChanNeeded rsl_chneed := RSL_CHANNEED_SDCCH;
6498 var template BSSMAP_IE_ChannelNeeded bssmap_chneed := ts_BSSMAP_IE_ChanNeeded(int2bit(enum2int(valueof(rsl_chneed)),2));
6499 var integer nri_v := 300; /* <-- second MSC's NRI */
6500 var octetstring tmsi := f_tmsi_nri(nri_v);
6501 var BSSAP_N_UNITDATA_req paging;
6502
6503 f_MscConnHdlr_init(g_pars.media_nr, "127.0.0.2", "127.0.0.3", FR_AMR);
6504
Neels Hofmeyr90f80962020-06-12 16:16:55 +02006505 paging := valueof(ts_BSSAP_UNITDATA_req(g_pars.sccp_addr_bsc, g_pars.sccp_addr_msc,
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006506 valueof(ts_BSSMAP_Paging('001010000000011'H, cid_list, tmsi, bssmap_chneed))));
6507 BSSAP.send(paging);
6508
6509 /* Register any RSL conn so that the Paging Command gets received here. With the current RSL_Emulation's main()
6510 * handling of '[bts_role] IPA_PT.receive(tr_ASP_RSL_UD(tr_RSL_PAGING_CMD()))' it doesn't matter at all which
6511 * channel number is picked here. */
6512 var RslChannelNr new_chan_nr := valueof(t_RslChanNr0(0, RSL_CHAN_NR_INVALID));
6513 f_rslem_register(0, new_chan_nr);
6514 RSL.receive(tr_RSL_PAGING_CMD(t_MI_TMSI(tmsi)));
6515 f_rslem_unregister(0, new_chan_nr);
6516
6517 /* Despite the NRI matching the second MSC (NRI from 'msc 1' in osmo-bsc.cfg) and round robin pointing at the
6518 * third MSC ('roundrobin next 2'), the earlier Paging for the same TMSI causes this Paging Response to go to
6519 * the first MSC (bssap_idx := 0). */
6520 f_perform_compl_l3(RSL, ts_PAG_RESP(valueof(ts_MI_TMSI_NRI_LV(nri_v))) );
6521 setverdict(pass);
6522 f_sleep(1.0);
6523}
6524testcase TC_mscpool_paging_and_response_tmsi() runs on test_CT {
6525 f_init(nr_bts := 1, handler_mode := true, nr_msc := 3);
6526 f_sleep(1.0);
6527
6528 /* Testing a Paging on the first MSC to get a Paging Response back to the first MSC. Set round robin to the
6529 * third MSC to make sure we're getting the Paging logic, not a coincidental round robin match. */
6530 f_vty_transceive(BSCVTY, "mscpool roundrobin next 2");
6531
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006532 f_ctrs_msc_init();
6533
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006534 var MSC_ConnHdlr vc_conn1;
6535 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
6536 pars1.mscpool.rsl_idx := 0;
Neels Hofmeyr90f80962020-06-12 16:16:55 +02006537 pars1.sccp_addr_bsc := g_bssap[pars1.mscpool.bssap_idx].sccp_addr_peer;
6538 pars1.sccp_addr_msc := g_bssap[pars1.mscpool.bssap_idx].sccp_addr_own;
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006539 vc_conn1 := f_start_handler(refers(f_tc_mscpool_paging_tmsi), pars1);
6540 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006541 f_ctrs_msc_expect(0, "mscpool:subscr:paged");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006542}
6543
6544/* For round-robin, skip an MSC that has 'no allow-attach' set. */
6545/* FIXME: each run is using a separate RSLem: RSL, RSL1, RSL2. It should work
6546 * just as well using only RSL. */
6547testcase TC_mscpool_no_allow_attach_round_robin() runs on test_CT {
6548
6549 f_init(nr_bts := 3, handler_mode := true, nr_msc := 3);
6550 f_sleep(1.0);
Neels Hofmeyra460f1f2020-08-09 20:17:03 +00006551 /* Mark the second MSC as offloading, round-robin should skip this MSC now. */
6552 f_vty_msc_allow_attach(BSCVTY, {true, false, true});
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006553
6554 /* Control which MSC gets chosen next by the round-robin, otherwise
6555 * would be randomly affected by which other tests ran before this. */
6556 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
6557
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006558 f_ctrs_msc_init();
6559
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006560 var MSC_ConnHdlr vc_conn1;
6561 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 0);
6562 pars1.mscpool.rsl_idx := 0;
6563 pars1.mscpool.l3_info := valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(ts_MI_IMSI_LV('001010000000001'H)), '00F110'O));
6564 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6565 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006566 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006567
6568 var MSC_ConnHdlr vc_conn2;
6569 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 2);
6570 pars2.mscpool.rsl_idx := 1;
6571 pars2.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, valueof(ts_MI_IMSI_LV('001010000000002'H))));
6572 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6573 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006574 f_ctrs_msc_expect(2, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006575
6576 var MSC_ConnHdlr vc_conn3;
6577 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 0);
6578 pars3.mscpool.rsl_idx := 2;
6579 pars3.mscpool.l3_info := valueof(ts_PAG_RESP(valueof(ts_MI_IMSI_LV('001010000000003'H))));
6580 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
6581 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006582 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006583}
6584
6585/* An MSC that has 'no allow-attach' set should still serve subscribers that are already attached according to their
6586 * TMSI NRI. */
6587testcase TC_mscpool_no_allow_attach_valid_nri() runs on test_CT {
6588
6589 f_init(nr_bts := 3, handler_mode := true, nr_msc := 3);
6590 f_sleep(1.0);
6591
Neels Hofmeyra460f1f2020-08-09 20:17:03 +00006592 /* Mark the second MSC as offloading, round-robin should skip this MSC now. */
6593 f_vty_msc_allow_attach(BSCVTY, {true, false, true});
6594
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006595 /* Control which MSC gets chosen next by the round-robin, otherwise
6596 * would be randomly affected by which other tests ran before this. */
6597 f_vty_transceive(BSCVTY, "mscpool roundrobin next 0");
6598
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006599 f_ctrs_msc_init();
6600
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006601 /* Round robin points at msc 0, but the valid NRI directs to msc 1, even though msc 1 has 'no allow-attach'. */
6602 var MSC_ConnHdlr vc_conn1;
6603 var TestHdlrParams pars1 := f_gen_test_hdlr_pars(bssap_idx := 1);
6604 pars1.mscpool.rsl_idx := 0;
6605 /* An NRI of the second MSC's range (256-511) */
6606 pars1.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, valueof(ts_MI_TMSI_NRI_LV(260))));
6607 vc_conn1 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars1);
6608 vc_conn1.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006609 f_ctrs_msc_expect(1, "mscpool:subscr:known");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006610
6611 var MSC_ConnHdlr vc_conn2;
6612 var TestHdlrParams pars2 := f_gen_test_hdlr_pars(bssap_idx := 0);
6613 pars2.mscpool.rsl_idx := 1;
6614 pars2.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, valueof(ts_MI_IMSI_LV('001010000000002'H))));
6615 vc_conn2 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars2);
6616 vc_conn2.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006617 f_ctrs_msc_expect(0, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006618
6619 var MSC_ConnHdlr vc_conn3;
6620 var TestHdlrParams pars3 := f_gen_test_hdlr_pars(bssap_idx := 2);
6621 pars3.mscpool.rsl_idx := 2;
6622 pars3.mscpool.l3_info := valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, valueof(ts_MI_IMSI_LV('001010000000003'H))));
6623 vc_conn3 := f_start_handler(refers(f_tc_mscpool_compl_l3), pars3);
6624 vc_conn3.done;
Neels Hofmeyr22c3f792020-06-17 02:49:28 +02006625 f_ctrs_msc_expect(2, "mscpool:subscr:new");
Neels Hofmeyr4f118412020-06-04 15:25:10 +02006626}
6627
Philipp Maier783681c2020-07-16 16:47:06 +02006628/* Allow/Deny emergency calls globally via VTY */
6629private function f_vty_allow_emerg_msc(boolean allow) runs on test_CT {
6630 f_vty_enter_cfg_msc(BSCVTY, 0);
6631 if (allow) {
6632 f_vty_transceive(BSCVTY, "allow-emergency allow");
6633 } else {
6634 f_vty_transceive(BSCVTY, "allow-emergency deny");
6635 }
6636 f_vty_transceive(BSCVTY, "exit");
6637 f_vty_transceive(BSCVTY, "exit");
6638}
6639
6640/* Allow/Deny emergency calls per BTS via VTY */
6641private function f_vty_allow_emerg_bts(boolean allow, integer bts_nr) runs on test_CT {
6642 f_vty_enter_cfg_bts(BSCVTY, bts_nr);
6643 if (allow) {
6644 f_vty_transceive(BSCVTY, "rach emergency call allowed 1");
6645 } else {
6646 f_vty_transceive(BSCVTY, "rach emergency call allowed 0");
6647 }
6648 f_vty_transceive(BSCVTY, "exit");
6649 f_vty_transceive(BSCVTY, "exit");
6650}
6651
6652/* Begin assignmet procedure and send an EMERGENCY SETUP (RR) */
6653private function f_assignment_emerg_setup() runs on MSC_ConnHdlr {
6654 var PDU_ML3_MS_NW emerg_setup;
6655 var octetstring emerg_setup_enc;
6656 var RSL_Message emerg_setup_data_ind;
6657
6658 f_establish_fully(omit, omit);
6659
6660 emerg_setup := valueof(ts_ML3_MO_CC_EMERG_SETUP(1, valueof(ts_Bcap_voice)));
6661 emerg_setup_enc := enc_PDU_ML3_MS_NW(emerg_setup);
6662 emerg_setup_data_ind := valueof(ts_RSL_DATA_IND(g_chan_nr, valueof(ts_RslLinkID_DCCH(0)), emerg_setup_enc));
6663
6664 RSL.send(emerg_setup_data_ind);
6665}
6666
6667/* Test if the EMERGENCY SETUP gets passed on to the MSC via A when EMERGENCY
6668 * CALLS are permitted by the BSC config. */
6669private function f_TC_assignment_emerg_setup_allow(charstring id) runs on MSC_ConnHdlr {
6670 var PDU_BSSAP emerg_setup_data_ind_bssap;
6671 var PDU_ML3_MS_NW emerg_setup;
6672 timer T := 3.0;
6673
6674 f_assignment_emerg_setup()
6675
6676 T.start;
6677 alt {
6678 [] BSSAP.receive(tr_BSSAP_DTAP) -> value emerg_setup_data_ind_bssap {
6679 emerg_setup := dec_PDU_ML3_MS_NW(emerg_setup_data_ind_bssap.pdu.dtap);
6680 if (not isbound(emerg_setup.msgs.cc.emergencySetup)) {
6681 setverdict(fail, "no emergency setup");
6682 }
6683 }
6684 [] BSSAP.receive {
6685 setverdict(fail, "unexpected BSSAP message!");
6686 }
6687 [] T.timeout {
6688 setverdict(fail, "timout waiting for EMERGENCY SETUP!");
6689 }
6690 }
6691
6692 setverdict(pass);
6693}
6694
6695/* Test if the EMERGENCY SETUP gets blocked by the BSC if EMERGENCY CALLS are
6696 * forbidden by the BSC config. */
6697private function f_TC_assignment_emerg_setup_deny(charstring id) runs on MSC_ConnHdlr {
6698 var PDU_BSSAP emerg_setup_data_ind_bssap;
6699 timer T := 3.0;
6700
6701 f_assignment_emerg_setup()
6702
6703 T.start;
6704 alt {
6705 [] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr, ?, decmatch tr_RRM_RR_RELEASE)) {
6706 setverdict(pass);
6707 }
6708 [] RSL.receive {
6709 setverdict(fail, "unexpected RSL message!");
6710 }
6711 [] T.timeout {
6712 setverdict(fail, "timout waiting for RR CHANNEL RELEASE!");
6713 }
6714 }
6715}
6716
6717/* EMERGENCY CALL situation #1, allowed globally and by BTS */
6718testcase TC_assignment_emerg_setup_allow() runs on test_CT {
6719 var TestHdlrParams pars := f_gen_test_hdlr_pars();
6720 var MSC_ConnHdlr vc_conn;
6721
6722 f_init(1, true);
6723 f_sleep(1.0);
6724
6725 f_vty_allow_emerg_msc(true);
6726 f_vty_allow_emerg_bts(true, 0);
6727 vc_conn := f_start_handler(refers(f_TC_assignment_emerg_setup_allow), pars);
6728 vc_conn.done;
6729}
6730
6731/* EMERGENCY CALL situation #2, forbidden globally but allowed by BTS */
6732testcase TC_assignment_emerg_setup_deny_msc() runs on test_CT {
6733 var TestHdlrParams pars := f_gen_test_hdlr_pars();
6734 var MSC_ConnHdlr vc_conn;
6735
6736 f_init(1, true);
6737 f_sleep(1.0);
6738
6739 f_vty_allow_emerg_msc(false);
6740 f_vty_allow_emerg_bts(true, 0);
6741 vc_conn := f_start_handler(refers(f_TC_assignment_emerg_setup_deny), pars);
6742 vc_conn.done;
6743}
6744
6745/* EMERGENCY CALL situation #3, allowed globally but forbidden by BTS */
6746testcase TC_assignment_emerg_setup_deny_bts() runs on test_CT {
6747 var TestHdlrParams pars := f_gen_test_hdlr_pars();
6748 var MSC_ConnHdlr vc_conn;
6749
6750 /* Note: This simulates a spec violation by the MS, correct MS
6751 * implementations would not try to establish an emergency call because
6752 * the system information tells in advance that emergency calls are
6753 * not forbidden */
6754
6755 f_init(1, true);
6756 f_sleep(1.0);
6757
6758 f_vty_allow_emerg_msc(true);
6759 f_vty_allow_emerg_bts(false, 0);
6760 vc_conn := f_start_handler(refers(f_TC_assignment_emerg_setup_deny), pars);
6761 vc_conn.done;
6762}
6763
Philipp Maier82812002020-08-13 18:48:27 +02006764/* Test what happens when an emergency call arrives while all TCH channels are
6765 * busy, the BSC is expected to terminate one call in favor of the incoming
6766 * emergency call */
6767testcase TC_emerg_premption() runs on test_CT {
6768 var ASP_RSL_Unitdata rsl_ud;
6769 var integer i;
6770 var integer chreq_total, chreq_nochan;
6771 var RSL_Message rx_rsl;
6772 var RslChannelNr chan_nr;
6773
6774 f_init(1);
6775 f_sleep(1.0);
6776
6777 f_vty_allow_emerg_msc(true);
6778 f_vty_allow_emerg_bts(true, 0);
6779
6780 /* Fill up all channels on the BTS */
6781 chreq_total := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total");
6782 chreq_nochan := f_ctrl_get_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:no_channel");
6783 for (i := 0; i < NUM_TCHF_PER_BTS + NUM_TCHH_PER_BTS + NUM_SDCCH_PER_BTS; i := i+1) {
6784 chan_nr := f_chreq_act_ack('33'O, i);
6785 }
6786 IPA_RSL[0].clear;
6787 f_ctrl_get_exp_ratectr_abs(IPA_CTRL, "bts", 0, "chreq:total",
6788 chreq_total + NUM_TCHF_PER_BTS + NUM_TCHH_PER_BTS + NUM_SDCCH_PER_BTS);
6789
6790 /* Send Channel request for emegergency call */
6791 f_ipa_tx(0, ts_RSL_CHAN_RQD('A5'O, 23));
6792
6793 /* Expect the BSC to release one (the first) TCH/F on the BTS */
6794 chan_nr := valueof(t_RslChanNr_Bm(1));
6795 f_expect_chan_rel(0, chan_nr, expect_rr_chan_rel := false, expect_rll_rel_req := false);
6796
6797 /* Expect the BSC to send activate/assign the a channel for the emergency call */
6798 rx_rsl := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
6799 chan_nr := rx_rsl.ies[0].body.chan_nr;
6800 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(chan_nr, 33));
6801 rx_rsl := f_exp_ipa_rx(0, tr_RSL_IMM_ASSIGN(0));
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07006802}
6803
6804/* Hopping parameters per a timeslot */
6805private type record length(0..64) of integer ArfcnList;
6806private type record FHParamsTs {
6807 boolean enabled,
6808 uint6_t hsn,
6809 uint6_t maio,
6810 ArfcnList ma
6811};
6812
6813/* Hopping parameters per a transceiver */
6814private type record length(8) of FHParamsTs FHParamsTrx;
6815
6816/* Randomly generate the hopping parameters for the given timeslot numbers */
6817private function f_TC_fh_params_gen(template integer tr_tn := (1, 3, 5))
6818runs on test_CT return FHParamsTrx {
6819 var FHParamsTrx fhp;
6820
6821 for (var integer tn := 0; tn < 8; tn := tn + 1) {
6822 if (not match(tn, tr_tn)) {
6823 fhp[tn].enabled := false;
6824 fhp[tn].ma := { };
6825 continue;
6826 }
6827
6828 /* Random HSN / MAIO values: 0..63 */
6829 fhp[tn].hsn := f_rnd_int(64);
6830 fhp[tn].maio := f_rnd_int(64);
6831 fhp[tn].ma := { };
6832
6833 /* Random Mobile Allocation (hopping channels) */
6834 var integer ma_len := 2 + f_rnd_int(9); /* 2..10 channels */
6835 var integer step := 3 + f_rnd_int(4); /* 3..6 stepping */
6836 for (var integer i := 1; i <= ma_len; i := i + 1) {
6837 fhp[tn].ma := fhp[tn].ma & { i * step };
6838 }
6839
6840 fhp[tn].enabled := true;
6841 }
6842
6843 log("f_TC_fh_params_gen(): ", fhp);
6844 return fhp;
6845}
6846
6847/* Make sure that the given Channel Description IE matches the hopping configuration */
6848private function f_TC_fh_params_match_chan_desc(in FHParamsTrx fhp, in ChannelDescription cd)
6849{
6850 var template (present) ChannelDescription tr_cd;
6851 var template (present) MaioHsn tr_maio_hsn;
6852 var uint3_t tn := cd.chan_nr.tn;
6853
6854 if (fhp[tn].enabled) {
6855 tr_maio_hsn := tr_HsnMaio(fhp[tn].hsn, fhp[tn].maio);
6856 tr_cd := tr_ChanDescH1(cd.chan_nr, tr_maio_hsn);
6857 } else {
6858 tr_cd := tr_ChanDescH0(cd.chan_nr);
6859 }
6860
6861 if (not match(cd, tr_cd)) {
6862 setverdict(fail, "Channel Description IE does not match: ",
6863 cd, " vs expected ", tr_cd);
6864 }
6865}
6866
6867/* Make sure that the given Mobile Allocation IE matches the hopping configuration */
6868private function f_TC_fh_params_match_ma(in FHParamsTrx fhp, uint3_t tn,
6869 in MobileAllocationLV ma)
6870{
6871 var template MobileAllocationLV tr_ma := f_TC_fh_params_gen_tr_ma(fhp, tn, ma);
6872
6873 if (not match(ma, tr_ma)) {
6874 setverdict(fail, "Mobile Allocation IE does not match (tn := ",
6875 tn, "): ", ma, " vs expected: ", tr_ma);
6876 } else {
6877 setverdict(pass);
6878 }
6879}
6880
6881private function f_TC_fh_params_gen_tr_ma(in FHParamsTrx fhp, uint3_t tn,
6882 in MobileAllocationLV ma)
6883return template MobileAllocationLV {
6884 /* Mobile Allocation IE is expected to be empty if hopping is not enabled */
6885 if (not fhp[tn].enabled) {
6886 return { len := 0, ma := ''B };
6887 }
6888
6889 var bitstring full_mask := f_pad_bit(''B, 1024, '0'B);
6890 var bitstring slot_mask := f_pad_bit(''B, 1024, '0'B);
6891 var bitstring ma_mask := ''B;
6892 var integer ma_mask_len := 0;
6893
6894 /* Compose the full bit-mask (all channels, up to 1024 entries) */
6895 for (var integer i := 0; i < lengthof(fhp); i := i + 1) {
6896 for (var integer j := 0; j < lengthof(fhp[i].ma); j := j + 1) {
6897 if (full_mask[fhp[i].ma[j]] == '1'B)
6898 { continue; }
6899 full_mask[fhp[i].ma[j]] := '1'B;
6900 }
6901 }
6902
6903 /* Compose a bit-mask for the given timeslot number */
6904 for (var integer i := 0; i < lengthof(fhp[tn].ma); i := i + 1) {
6905 slot_mask[fhp[tn].ma[i]] := '1'B;
6906 }
6907
6908 /* Finally, compose the Mobile Allocation bit-mask */
6909 for (var integer i := 0; i < lengthof(full_mask); i := i + 1) {
6910 if (full_mask[i] != '1'B)
6911 { continue; }
6912
6913 /* FIXME: ma_mask := ma_mask & slot_mask[i]; // triggers a bug in TITAN */
6914 if (slot_mask[i] == '1'B) {
6915 ma_mask := ma_mask & '1'B;
6916 ma_mask_len := lengthof(ma_mask);
6917 } else {
6918 ma_mask := ma_mask & '0'B;
6919 }
6920 }
6921
6922 /* Ensure that ma_mask is octet-aligned */
Vadim Yanitskiy93a2fda2020-09-02 19:01:30 +07006923 ma_mask := substr(ma_mask, 0, ma_mask_len);
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07006924 ma_mask_len := (ma_mask_len + 8 - 1) / 8;
6925 ma_mask := f_pad_bit(ma_mask, ma_mask_len * 8, '0'B);
6926
6927 return { len := ma_mask_len, ma := ma_mask };
6928}
6929
6930/* Configure the hopping parameters in accordance with the given record */
6931private function f_TC_fh_params_set(in FHParamsTrx fhp,
6932 uint8_t bts_nr := 0,
6933 uint8_t trx_nr := 0)
6934runs on test_CT {
6935 /* Enter the configuration node for the given BTS/TRX numbers */
6936 f_vty_enter_cfg_trx(BSCVTY, bts_nr, trx_nr);
6937
6938 for (var integer tn := 0; tn < lengthof(fhp); tn := tn + 1) {
6939 f_vty_transceive(BSCVTY, "timeslot " & int2str(tn));
6940
6941 if (not fhp[tn].enabled) {
6942 f_vty_transceive(BSCVTY, "hopping enabled 0");
6943 f_vty_transceive(BSCVTY, "exit"); /* go back */
6944 continue;
6945 }
6946
6947 /* Configure HSN / MAIO values */
6948 f_vty_transceive(BSCVTY, "hopping sequence-number " & int2str(fhp[tn].hsn));
6949 f_vty_transceive(BSCVTY, "hopping maio " & int2str(fhp[tn].maio));
6950
6951 /* Configure the Mobile Allocation (hopping channels) */
6952 for (var integer i := 0; i < lengthof(fhp[tn].ma); i := i + 1) {
6953 f_vty_transceive(BSCVTY, "hopping arfcn add " & int2str(fhp[tn].ma[i]));
6954 }
6955
6956 f_vty_transceive(BSCVTY, "hopping enabled 1");
6957 f_vty_transceive(BSCVTY, "exit"); /* go back */
6958 }
6959
6960 f_vty_transceive(BSCVTY, "end");
6961}
6962
6963/* Disable frequency hopping on all timeslots */
6964private function f_TC_fh_params_unset(in FHParamsTrx fhp,
6965 uint8_t bts_nr := 0,
6966 uint8_t trx_nr := 0)
6967runs on test_CT {
6968 /* Enter the configuration node for the given BTS/TRX numbers */
6969 f_vty_enter_cfg_trx(BSCVTY, bts_nr, trx_nr);
6970
6971 for (var integer tn := 0; tn < lengthof(fhp); tn := tn + 1) {
6972 f_vty_transceive(BSCVTY, "timeslot " & int2str(tn));
6973
6974 /* Delete all ARFCNs from the Mobile Allocation (if any) */
6975 for (var integer i := 0; i < lengthof(fhp[tn].ma); i := i + 1) {
6976 f_vty_transceive(BSCVTY, "hopping arfcn del " & int2str(fhp[tn].ma[i]));
6977 }
6978
6979 f_vty_transceive(BSCVTY, "hopping enabled 0");
6980 f_vty_transceive(BSCVTY, "exit"); /* go back */
6981 }
6982
6983 f_vty_transceive(BSCVTY, "end");
6984 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
6985}
6986
6987/* Verify presence and correctness of the hopping parameters (HSN, MAIO)
6988 * in the Channel Identification IE of the RSL CHANnel ACTIVation message. */
6989testcase TC_fh_params_chan_activ() runs on test_CT {
6990 var FHParamsTrx fhp := f_TC_fh_params_gen();
6991 var RSL_Message rsl_msg;
6992 var RSL_IE_Body ie;
6993
6994 f_init_vty();
6995
6996 f_TC_fh_params_set(fhp); /* Enable frequency hopping */
6997 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
6998
6999 f_init(1);
7000
7001 /* CS domain: 3 (SDCCH/4+CBCH) + 4 (TCH/F) + 2 (TCH/H) channels available */
7002 for (var integer i := 0; i < 9; i := i + 1) {
7003 f_ipa_tx(0, ts_RSL_CHAN_RQD(f_rnd_ra_cs(), 23));
7004 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
7005
7006 /* Make sure that Channel Identification IE is present */
7007 if (not f_rsl_find_ie(rsl_msg, RSL_IE_CHAN_IDENT, ie)) {
7008 setverdict(fail, "RSL Channel Identification IE is absent");
7009 continue;
7010 }
7011
7012 /* Make sure that hopping parameters (HSN/MAIO) match */
7013 f_TC_fh_params_match_chan_desc(fhp, ie.chan_ident.ch_desc.v);
7014
7015 /* "Mobile Allocation shall be included but empty" - let's check this */
7016 if (ie.chan_ident.ma.v.len != 0) {
7017 setverdict(fail, "Mobile Allocation IE is not empty: ",
7018 ie.chan_ident.ma, ", despite it shall be");
7019 continue;
7020 }
7021 }
7022
7023 /* Disable frequency hopping */
7024 f_TC_fh_params_unset(fhp);
7025
7026 setverdict(pass);
7027}
7028
7029/* Verify the hopping parameters (HSN, MAIO, MA) in (RR) Immediate Assignment */
7030testcase TC_fh_params_imm_ass() runs on test_CT {
7031 var FHParamsTrx fhp := f_TC_fh_params_gen();
7032 var RSL_Message rsl_msg;
7033 var RSL_IE_Body ie;
7034
7035 f_init_vty();
7036
7037 f_TC_fh_params_set(fhp); /* Enable frequency hopping */
7038 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
7039
7040 f_init(1);
7041
7042 /* CS domain: 3 (SDCCH/4+CBCH) + 4 (TCH/F) + 2 (TCH/H) channels available */
7043 for (var integer i := 0; i < 9; i := i + 1) {
7044 f_ipa_tx(0, ts_RSL_CHAN_RQD(f_rnd_ra_cs(), 23));
7045 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
7046
7047 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(rsl_msg.ies[0].body.chan_nr, 33));
7048 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeC(RSL_MT_IMMEDIATE_ASSIGN_CMD));
7049
7050 /* Make sure that Full Immediate Assign Info IE is present */
7051 if (not f_rsl_find_ie(rsl_msg, RSL_IE_FULL_IMM_ASS_INFO, ie)) {
7052 setverdict(fail, "RSL Full Immediate Assign Info IE is absent");
7053 continue;
7054 }
7055
7056 /* Decode the actual Immediate Assignment message */
7057 var GsmRrMessage rr_msg := dec_GsmRrMessage(ie.full_imm_ass_info.payload);
7058 if (not match(rr_msg.header, t_RrHeader(IMMEDIATE_ASSIGNMENT, ?))) {
7059 setverdict(fail, "Failed to match Immediate Assignment: ", rr_msg);
7060 continue;
7061 }
7062
7063 /* Make sure that hopping parameters (HSN/MAIO) match */
7064 f_TC_fh_params_match_chan_desc(fhp, rr_msg.payload.imm_ass.chan_desc);
7065
7066 /* Make sure that the Mobile Allocation IE matches */
7067 f_TC_fh_params_match_ma(fhp, rr_msg.payload.imm_ass.chan_desc.chan_nr.tn,
7068 rr_msg.payload.imm_ass.mobile_allocation);
7069 }
7070
7071 /* Disable frequency hopping */
7072 f_TC_fh_params_unset(fhp);
Philipp Maier82812002020-08-13 18:48:27 +02007073
7074 setverdict(pass);
7075}
7076
Vadim Yanitskiyaeb54a22020-09-01 06:25:25 +07007077/* Verify the hopping parameters (HSN, MAIO, MA) in (RR) Assignment Command */
7078testcase TC_fh_params_assignment_cmd() runs on test_CT {
7079 var FHParamsTrx fhp := f_TC_fh_params_gen();
7080 var RSL_Message rsl_msg;
7081 var RSL_IE_Body ie;
7082
7083 f_init_vty();
7084
7085 f_TC_fh_params_set(fhp); /* Enable frequency hopping */
7086 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
7087
7088 f_init(1);
7089
7090 /* HACK: work around "Couldn't find Expect for CRCX" */
7091 vc_MGCP.stop;
7092
7093 var template PDU_BSSAP ass_cmd := f_gen_ass_req();
7094 ass_cmd.pdu.bssmap.assignmentRequest.codecList := ts_BSSMAP_IE_CodecList({ts_CodecFR});
7095
7096 /* CS domain (TCH): 4 (TCH/F) + 2 (TCH/H) channels available
7097 * NOTE: only 3 SDCCH/4 channels are available on CCCH+SDCCH4+CBCH */
7098 for (var integer i := 0; i < 3; i := i + 1) {
7099 /* Establish a dedicated channel, so we can trigger (late) TCH assignment */
7100 var DchanTuple dt := f_est_dchan(f_rnd_ra_cs(), 23, f_rnd_octstring(16));
7101
7102 /* Send a BSSMAP Assignment Command, expect CHANnel ACTIVation */
7103 BSSAP.send(ts_BSSAP_DATA_req(dt.sccp_conn_id, ass_cmd));
7104 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeD(RSL_MT_CHAN_ACTIV));
7105
7106 /* ACKnowledge CHANnel ACTIVation, expect RSL DATA REQuest */
7107 f_ipa_tx(0, ts_RSL_CHAN_ACT_ACK(rsl_msg.ies[0].body.chan_nr, 33));
7108 rsl_msg := f_exp_ipa_rx(0, tr_RSL_MsgTypeR(RSL_MT_DATA_REQ));
7109
7110 /* Make sure that L3 Information IE is present */
7111 if (not f_rsl_find_ie(rsl_msg, RSL_IE_L3_INFO, ie)) {
7112 setverdict(fail, "RSL L3 Information IE is absent");
7113 continue;
7114 }
7115
7116 /* Decode the L3 message and make sure it is (RR) Assignment Command */
7117 var GsmRrL3Message l3_msg := dec_GsmRrL3Message(ie.l3_info.payload);
7118 if (not match(l3_msg.header, t_RrL3Header(ASSIGNMENT_COMMAND))) {
7119 setverdict(fail, "Failed to match Assignment Command: ", l3_msg);
7120 continue;
7121 }
7122
7123 /* Make sure that hopping parameters (HSN/MAIO) match */
7124 var ChannelDescription chan_desc := l3_msg.payload.ass_cmd.chan_desc;
7125 f_TC_fh_params_match_chan_desc(fhp, chan_desc);
7126
7127 /* Make sure that Cell Channel Description IE is present if FH is enabled */
7128 if (chan_desc.h and not ispresent(l3_msg.payload.ass_cmd.cell_chan_desc)) {
Vadim Yanitskiy38d069d2020-09-02 17:18:57 +07007129 setverdict(fail, "FH enabled, but Cell Channel Description IE is absent");
Vadim Yanitskiyaeb54a22020-09-01 06:25:25 +07007130 continue;
7131 }
7132
7133 /* Make sure that the Mobile Allocation IE matches (if present) */
7134 var boolean ma_present := ispresent(l3_msg.payload.ass_cmd.mobile_allocation);
7135 if (chan_desc.h and ma_present) {
7136 f_TC_fh_params_match_ma(fhp, chan_desc.chan_nr.tn,
7137 l3_msg.payload.ass_cmd.mobile_allocation.v);
7138 } else if (chan_desc.h and not ma_present) {
7139 setverdict(fail, "FH enabled, but Mobile Allocation IE is absent");
7140 continue;
7141 } else if (not chan_desc.h and ma_present) {
7142 setverdict(fail, "FH disabled, but Mobile Allocation IE is present");
7143 continue;
7144 }
7145 }
7146
7147 /* Give the IUT some time to release all channels */
7148 f_sleep(3.0);
7149
7150 /* Disable frequency hopping */
7151 f_TC_fh_params_unset(fhp);
7152
7153 setverdict(pass);
7154}
7155
Vadim Yanitskiyca974032020-09-01 07:20:39 +07007156/* Verify the hopping parameters in System Information Type 4 */
7157testcase TC_fh_params_si4_cbch() runs on test_CT {
7158 var FHParamsTrx fhp := f_TC_fh_params_gen(tr_tn := 1);
7159 var ASP_RSL_Unitdata rx_rsl_ud;
7160 timer T := 5.0;
7161
7162 f_init_vty();
7163
7164 /* (Re)configure TS0 as BCCH and TS1 as SDCCH8+CBCH */
7165 f_vty_enter_cfg_trx(BSCVTY, trx := 0);
7166
7167 f_vty_transceive(BSCVTY, "timeslot 0");
7168 f_vty_transceive(BSCVTY, "phys_chan_config ccch");
7169 f_vty_transceive(BSCVTY, "exit"); /* go back */
7170
7171 f_vty_transceive(BSCVTY, "timeslot 1");
7172 f_vty_transceive(BSCVTY, "phys_chan_config sdcch8+cbch");
7173 f_vty_transceive(BSCVTY, "end"); /* we're done */
7174
7175 f_TC_fh_params_set(fhp); /* Enable frequency hopping */
7176 f_vty_transceive(BSCVTY, "drop bts connection 0 oml");
7177
7178 f_init(1);
7179
7180 T.start;
7181 alt {
7182 [] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr_RSL_BCCH_INFO(RSL_SYSTEM_INFO_4))) -> value rx_rsl_ud {
7183 var RSL_IE_Body ie := rx_rsl_ud.rsl.ies[2].body; /* FULL BCCH Information IE */
7184 var SystemInformation si := dec_SystemInformation(ie.other.payload);
7185
7186 /* Make sure that what we decoded is System Information Type 4 */
7187 if (si.header.message_type != SYSTEM_INFORMATION_TYPE_4) {
7188 setverdict(fail, "RSL FULL BCCH Information IE contains: ", si);
7189 repeat;
7190 }
7191
7192 /* Make sure that CBCH Channel Description IE is present */
7193 if (not ispresent(si.payload.si4.cbch_chan_desc)) {
7194 setverdict(fail, "CBCH Channel Description IE is absent");
7195 break;
7196 }
7197
7198 /* Finally, check the hopping parameters (HSN, MAIO) */
7199 var ChannelDescription chan_desc := si.payload.si4.cbch_chan_desc.v;
7200 f_TC_fh_params_match_chan_desc(fhp, chan_desc);
7201
7202 /* 3GPP TS 44.018, section 9.1.36.2 "CBCH Mobile Allocation":
7203 * The CBCH Mobile Allocation IE *shall* be present if FH is enabled. */
7204 if (chan_desc.h and not ispresent(si.payload.si4.cbch_mobile_alloc)) {
7205 setverdict(fail, "FH enabled, but Mobile Allocation IE is absent");
7206 break;
7207 } else if (chan_desc.h and ispresent(si.payload.si4.cbch_mobile_alloc)) {
7208 f_TC_fh_params_match_ma(fhp, chan_desc.chan_nr.tn,
7209 si.payload.si4.cbch_mobile_alloc.v);
7210 }
7211 }
7212 [] IPA_RSL[0].receive { repeat; }
7213 [] T.timeout {
7214 setverdict(fail, "Timeout waiting for RSL BCCH INFOrmation (SI4)");
7215 }
7216 }
7217
7218 /* Disable frequency hopping */
7219 f_TC_fh_params_unset(fhp);
7220
Vadim Yanitskiy8bc46012020-09-06 12:38:01 +07007221 /* (Re)configure TS0 as CCCH+SDCCH4+CBCH and TS1 as TCH/F */
Vadim Yanitskiyca974032020-09-01 07:20:39 +07007222 f_vty_enter_cfg_trx(BSCVTY, trx := 0);
7223
7224 f_vty_transceive(BSCVTY, "timeslot 0");
Vadim Yanitskiy8bc46012020-09-06 12:38:01 +07007225 f_vty_transceive(BSCVTY, "phys_chan_config ccch+sdcch4+cbch");
Vadim Yanitskiyca974032020-09-01 07:20:39 +07007226 f_vty_transceive(BSCVTY, "exit"); /* go back */
7227
7228 f_vty_transceive(BSCVTY, "timeslot 1");
7229 f_vty_transceive(BSCVTY, "phys_chan_config tch/f");
7230 f_vty_transceive(BSCVTY, "end"); /* we're done */
7231
7232 setverdict(pass);
7233}
7234
Harald Welte0ea2d5e2018-04-07 21:40:29 +02007235/* Dyn PDCH todo:
7236 * activate OSMO as TCH/F
7237 * activate OSMO as TCH/H
7238 * does the BSC-located PCU socket get the updated INFO?
7239 * what if no PCU is connected at the time?
7240 * is the info correct on delayed PCU (re)connect?
7241 */
Harald Welte94e0c342018-04-07 11:33:23 +02007242
Harald Welte28d943e2017-11-25 15:00:50 +01007243control {
Harald Welte898113b2018-01-31 18:32:21 +01007244 /* CTRL interface testing */
Harald Welte4003d112017-12-09 22:35:39 +01007245 execute( TC_ctrl_msc_connection_status() );
Stefan Sperlingb041b3d2018-01-03 17:14:55 +01007246 execute( TC_ctrl_msc0_connection_status() );
Harald Welte96c94412017-12-09 03:12:45 +01007247 execute( TC_ctrl() );
Neels Hofmeyrf246a922020-05-13 02:27:10 +02007248 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_SCCPlite_SERVER) {
Pau Espin Pedrol5a2d7432019-06-07 19:43:45 +02007249 execute( TC_ctrl_location() );
7250 }
Harald Welte898113b2018-01-31 18:32:21 +01007251
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +02007252 execute( TC_si_default() );
Neels Hofmeyr66aeba42020-07-06 02:21:21 +02007253 execute( TC_si2quater_2_earfcns() );
7254 execute( TC_si2quater_3_earfcns() );
7255 execute( TC_si2quater_4_earfcns() );
7256 execute( TC_si2quater_5_earfcns() );
7257 execute( TC_si2quater_6_earfcns() );
Neels Hofmeyrad132f22020-07-08 02:20:16 +02007258 execute( TC_si2quater_12_earfcns() );
7259 execute( TC_si2quater_23_earfcns() );
7260 execute( TC_si2quater_32_earfcns() );
7261 execute( TC_si2quater_33_earfcns() );
7262 execute( TC_si2quater_42_earfcns() );
7263 execute( TC_si2quater_48_earfcns() );
7264 execute( TC_si2quater_49_earfcns() );
Pau Espin Pedrol85a84432020-07-20 18:45:03 +02007265 execute( TC_si_acc_rotate() );
Pau Espin Pedrolc6136cd2020-07-24 13:20:02 +02007266 execute (TC_si_acc_ramp_rotate() );
Neels Hofmeyr5e686dc2020-06-30 01:26:53 +02007267
Harald Welte898113b2018-01-31 18:32:21 +01007268 /* RSL DCHAN Channel ACtivation / Deactivation */
Harald Welteae026692017-12-09 01:03:01 +01007269 execute( TC_chan_act_noreply() );
Harald Welte4003d112017-12-09 22:35:39 +01007270 execute( TC_chan_act_counter() );
Harald Welteae026692017-12-09 01:03:01 +01007271 execute( TC_chan_act_ack_noest() );
Philipp Maier9c60a622020-07-09 15:08:46 +02007272 execute( TC_chan_act_ack_noest_emerg() );
Philipp Maier606f07d2020-08-12 17:21:58 +02007273 execute( TC_chan_rqd_emerg_deny() );
Harald Welteae026692017-12-09 01:03:01 +01007274 execute( TC_chan_act_ack_est_ind_noreply() );
7275 execute( TC_chan_act_ack_est_ind_refused() );
Harald Welte618ef642017-12-14 14:58:20 +01007276 execute( TC_chan_act_nack() );
Harald Welte799c97b2017-12-14 17:50:30 +01007277 execute( TC_chan_exhaustion() );
Vadim Yanitskiy1ff1fdf2018-11-27 01:32:57 +07007278 execute( TC_chan_deact_silence() );
Harald Welte4003d112017-12-09 22:35:39 +01007279 execute( TC_chan_rel_rll_rel_ind() );
7280 execute( TC_chan_rel_conn_fail() );
7281 execute( TC_chan_rel_hard_clear() );
Harald Welte99787102019-02-04 10:41:36 +01007282 execute( TC_chan_rel_hard_clear_csfb() );
Harald Welted8c36cd2017-12-09 23:05:31 +01007283 execute( TC_chan_rel_hard_rlsd() );
Harald Welte550daf92018-06-11 19:22:13 +02007284 execute( TC_chan_rel_hard_rlsd_ms_dead() );
Harald Welte85804d42017-12-10 14:11:58 +01007285 execute( TC_chan_rel_a_reset() );
Pau Espin Pedrolc675b612020-01-09 19:55:40 +01007286 execute( TC_chan_rel_sccp_tiar_timeout() );
Neels Hofmeyr95a5edc2020-07-11 02:57:04 +02007287 execute( TC_chan_rel_rr_cause() );
Harald Welte6f521d82017-12-11 19:52:02 +01007288
Harald Weltecfe2c962017-12-15 12:09:32 +01007289 execute( TC_outbound_connect() );
Harald Welte898113b2018-01-31 18:32:21 +01007290
7291 /* Assignment related */
Harald Welte16a4adf2017-12-14 18:54:01 +01007292 execute( TC_assignment_cic_only() );
Harald Welte235ebf12017-12-15 14:18:16 +01007293 execute( TC_assignment_csd() );
7294 execute( TC_assignment_ctm() );
7295 execute( TC_assignment_sign() );
7296 execute( TC_assignment_fr_a5_0() );
7297 execute( TC_assignment_fr_a5_1() );
Neels Hofmeyrf246a922020-05-13 02:27:10 +02007298 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
Harald Welte8f67d1d2018-05-25 20:38:42 +02007299 execute( TC_assignment_fr_a5_1_codec_missing() );
7300 }
Harald Welte235ebf12017-12-15 14:18:16 +01007301 execute( TC_assignment_fr_a5_3() );
7302 execute( TC_assignment_fr_a5_4() );
Harald Welte3c86ea02018-05-10 22:28:05 +02007303 execute( TC_ciph_mode_a5_0() );
7304 execute( TC_ciph_mode_a5_1() );
7305 execute( TC_ciph_mode_a5_3() );
Harald Welte16a4adf2017-12-14 18:54:01 +01007306
Harald Welte60aa5762018-03-21 19:33:13 +01007307 execute( TC_assignment_codec_fr() );
7308 execute( TC_assignment_codec_hr() );
7309 execute( TC_assignment_codec_efr() );
7310 execute( TC_assignment_codec_amr_f() );
7311 execute( TC_assignment_codec_amr_h() );
Philipp Maier8a581d22019-03-26 18:32:48 +01007312
Neels Hofmeyrf246a922020-05-13 02:27:10 +02007313 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
Philipp Maier8a581d22019-03-26 18:32:48 +01007314 execute( TC_assignment_codec_amr_f_S1() );
7315 execute( TC_assignment_codec_amr_h_S1() );
7316 execute( TC_assignment_codec_amr_f_S124() );
7317 execute( TC_assignment_codec_amr_h_S124() );
7318 execute( TC_assignment_codec_amr_f_S0() );
7319 execute( TC_assignment_codec_amr_f_S02() );
7320 execute( TC_assignment_codec_amr_f_S024() );
7321 execute( TC_assignment_codec_amr_f_S0247() );
7322 execute( TC_assignment_codec_amr_h_S0() );
7323 execute( TC_assignment_codec_amr_h_S02() );
7324 execute( TC_assignment_codec_amr_h_S024() );
7325 execute( TC_assignment_codec_amr_h_S0247() );
7326 execute( TC_assignment_codec_amr_f_S01234567() );
7327 execute( TC_assignment_codec_amr_f_S0234567() );
7328 execute( TC_assignment_codec_amr_f_zero() );
7329 execute( TC_assignment_codec_amr_f_unsupp() );
7330 execute( TC_assignment_codec_amr_h_S7() );
7331 }
Harald Welte60aa5762018-03-21 19:33:13 +01007332
Philipp Maierac09bfc2019-01-08 13:41:39 +01007333 execute( TC_assignment_codec_fr_exhausted_req_hr() );
7334 execute( TC_assignment_codec_fr_exhausted_req_fr() );
7335 execute( TC_assignment_codec_fr_exhausted_req_fr_hr() );
7336 execute( TC_assignment_codec_fr_exhausted_req_hr_fr() );
7337 execute( TC_assignment_codec_hr_exhausted_req_fr() );
7338 execute( TC_assignment_codec_hr_exhausted_req_hr() );
7339 execute( TC_assignment_codec_hr_exhausted_req_hr_fr() );
7340 execute( TC_assignment_codec_hr_exhausted_req_fr_hr() );
7341 execute( TC_assignment_codec_req_hr_fr() );
7342 execute( TC_assignment_codec_req_fr_hr() );
7343
Pau Espin Pedrol58cf6822019-05-28 18:11:33 +02007344 if (mp_enable_osmux_test) {
7345 execute( TC_assignment_osmux() );
7346 }
Pau Espin Pedrolc6a53db2019-05-20 19:31:47 +02007347
Harald Welte898113b2018-01-31 18:32:21 +01007348 /* RLL Establish Indication on inactive DCHAN / SAPI */
Harald Welte5cd20ed2017-12-13 21:03:20 +01007349 execute( TC_rll_est_ind_inact_lchan() );
7350 execute( TC_rll_est_ind_inval_sapi1() );
7351 execute( TC_rll_est_ind_inval_sapi3() );
7352 execute( TC_rll_est_ind_inval_sacch() );
7353
Vadim Yanitskiy6ef5dfa2020-08-28 18:04:41 +07007354 /* SAPI N Reject triggered by RLL establishment failures */
7355 execute( TC_rll_rel_ind_sapi_n_reject() );
7356 execute( TC_rll_err_ind_sapi_n_reject() );
7357 execute( TC_rll_timeout_sapi_n_reject() );
7358
Harald Welte898113b2018-01-31 18:32:21 +01007359 /* Paging related tests */
Harald Welte6f521d82017-12-11 19:52:02 +01007360 execute( TC_paging_imsi_nochan() );
7361 execute( TC_paging_tmsi_nochan() );
7362 execute( TC_paging_tmsi_any() );
7363 execute( TC_paging_tmsi_sdcch() );
7364 execute( TC_paging_tmsi_tch_f() );
7365 execute( TC_paging_tmsi_tch_hf() );
7366 execute( TC_paging_imsi_nochan_cgi() );
7367 execute( TC_paging_imsi_nochan_lac_ci() );
7368 execute( TC_paging_imsi_nochan_ci() );
7369 execute( TC_paging_imsi_nochan_lai() );
7370 execute( TC_paging_imsi_nochan_lac() );
7371 execute( TC_paging_imsi_nochan_all() );
Harald Welte751d3eb2018-01-31 15:51:06 +01007372 execute( TC_paging_imsi_nochan_plmn_lac_rnc() );
7373 execute( TC_paging_imsi_nochan_rnc() );
7374 execute( TC_paging_imsi_nochan_lac_rnc() );
7375 execute( TC_paging_imsi_nochan_lacs() );
7376 execute( TC_paging_imsi_nochan_lacs_empty() );
Stefan Sperling049a86e2018-03-20 15:51:00 +01007377 execute( TC_paging_imsi_nochan_cgi_unknown_cid() );
Harald Welte10985002017-12-12 09:29:15 +01007378 execute( TC_paging_imsi_a_reset() );
Harald Weltee65d40e2017-12-13 00:09:06 +01007379 execute( TC_paging_imsi_load() );
Philipp Maier779a7922018-02-16 11:00:37 +01007380 execute( TC_paging_counter() );
Pau Espin Pedrol3466cc52018-11-05 12:41:05 +01007381 execute( TC_paging_resp_unsol() );
Harald Welte4e9b9cc2017-12-14 18:31:02 +01007382
7383 execute( TC_rsl_drop_counter() );
Stefan Sperling830dc9d2018-02-12 21:08:28 +01007384 execute( TC_rsl_unknown_unit_id() );
7385
7386 execute( TC_oml_unknown_unit_id() );
Harald Welte898113b2018-01-31 18:32:21 +01007387
7388 execute( TC_classmark() );
Harald Welteeddf0e92020-06-21 19:42:15 +02007389 execute( TC_common_id() );
Harald Welte898113b2018-01-31 18:32:21 +01007390 execute( TC_unsol_ass_fail() );
Harald Welteea99a002018-01-31 20:46:43 +01007391 execute( TC_unsol_ass_compl() );
Harald Weltefbf9b5e2018-01-31 20:41:23 +01007392 execute( TC_unsol_ho_fail() );
Harald Weltee3bd6582018-01-31 22:51:25 +01007393 execute( TC_err_82_short_msg() );
Harald Weltee9e02e42018-01-31 23:36:25 +01007394 execute( TC_err_84_unknown_msg() );
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01007395
Harald Welte261af4b2018-02-12 21:20:39 +01007396 execute( TC_ho_int() );
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01007397
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01007398 execute( TC_ho_out_of_this_bsc() );
Neels Hofmeyr61ebb8b2018-10-09 18:28:06 +02007399 execute( TC_ho_out_fail_no_msc_response() );
7400 execute( TC_ho_out_fail_rr_ho_failure() );
Neels Hofmeyrd8a602c2019-07-09 19:46:01 +02007401 execute( TC_ho_out_fail_no_result_after_ho_cmd() );
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01007402
Neels Hofmeyrbd0ef932018-03-19 14:58:46 +01007403 execute( TC_ho_into_this_bsc() );
Neels Hofmeyr20bc3e22018-11-09 01:40:16 +01007404 execute( TC_ho_in_fail_msc_clears() );
7405 execute( TC_ho_in_fail_msc_clears_after_ho_detect() );
7406 execute( TC_ho_in_fail_no_detect() );
7407 execute( TC_ho_in_fail_no_detect2() );
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01007408
Neels Hofmeyr91401012019-07-11 00:42:35 +02007409 execute( TC_ho_neighbor_config_1() );
7410 execute( TC_ho_neighbor_config_2() );
7411 execute( TC_ho_neighbor_config_3() );
7412 execute( TC_ho_neighbor_config_4() );
7413 execute( TC_ho_neighbor_config_5() );
7414 execute( TC_ho_neighbor_config_6() );
7415 execute( TC_ho_neighbor_config_7() );
7416
Neels Hofmeyrcdc2d762018-03-12 01:48:11 +01007417 execute( TC_bssap_rlsd_does_not_cause_bssmap_reset() );
Neels Hofmeyr4ff93282018-03-12 04:25:35 +01007418 execute( TC_bssmap_clear_does_not_cause_bssmap_reset() );
Neels Hofmeyrfd445c32018-03-09 15:39:31 +01007419 execute( TC_ms_rel_ind_does_not_cause_bssmap_reset() );
Harald Welte94e0c342018-04-07 11:33:23 +02007420
7421 execute( TC_dyn_pdch_ipa_act_deact() );
7422 execute( TC_dyn_pdch_ipa_act_nack() );
7423 execute( TC_dyn_pdch_osmo_act_deact() );
7424 execute( TC_dyn_pdch_osmo_act_nack() );
Harald Welte99f3ca02018-06-14 13:40:29 +02007425
Stefan Sperling0796a822018-10-05 13:01:39 +02007426 execute( TC_chopped_ipa_ping() );
Stefan Sperlingaa1e60f2018-10-15 16:34:07 +02007427 execute( TC_chopped_ipa_payload() );
Stefan Sperling0796a822018-10-05 13:01:39 +02007428
Pau Espin Pedrol8f773632019-11-05 11:46:53 +01007429 /* Power control related */
7430 execute( TC_assignment_verify_ms_power_params_ie() );
Neels Hofmeyr4f118412020-06-04 15:25:10 +02007431
7432 /* MSC pooling */
7433 /* FIXME: in SCCPlite, indicating how many MSCs should be connected does currently not work. Since
7434 * RESET->RESET-ACK is unconditionally negotiated for all configured MSCs, they always all appear as connected
7435 * to osmo-bsc. The MSC pooling tests however require disconnecting selected MSCs, and hence don't work out as
7436 * intended on SCCPlite. So for now, run these only for SCCP/M3UA. */
7437 if (mp_bssap_cfg[0].transport == BSSAP_TRANSPORT_AoIP) {
7438 execute( TC_mscpool_L3Compl_on_1_msc() );
7439 execute( TC_mscpool_L3Complete_by_imsi_round_robin() );
7440 execute( TC_mscpool_LU_by_tmsi_null_nri_0_round_robin() );
7441 execute( TC_mscpool_LU_by_tmsi_null_nri_1_round_robin() );
7442 execute( TC_mscpool_L3Complete_by_tmsi_unassigned_nri_round_robin() );
7443 execute( TC_mscpool_L3Complete_by_tmsi_valid_nri_msc_not_connected_round_robin() );
7444 execute( TC_mscpool_L3Complete_by_tmsi_valid_nri_1() );
7445 execute( TC_mscpool_L3Complete_by_tmsi_valid_nri_2() );
7446 execute( TC_mscpool_LU_by_tmsi_from_other_PLMN() );
7447 execute( TC_mscpool_paging_and_response_imsi() );
7448 execute( TC_mscpool_paging_and_response_tmsi() );
7449 execute( TC_mscpool_no_allow_attach_round_robin() );
7450 execute( TC_mscpool_no_allow_attach_valid_nri() );
7451 }
7452
Harald Welte99f3ca02018-06-14 13:40:29 +02007453 /* at bottom as they might crash OsmoBSC before OS#3182 is fixed */
7454 execute( TC_early_conn_fail() );
7455 execute( TC_late_conn_fail() );
7456
Philipp Maier783681c2020-07-16 16:47:06 +02007457 /* Emergency call handling (deny / allow) */
7458 execute( TC_assignment_emerg_setup_allow() );
7459 execute( TC_assignment_emerg_setup_deny_msc() );
7460 execute( TC_assignment_emerg_setup_deny_bts() );
Philipp Maier82812002020-08-13 18:48:27 +02007461 execute( TC_emerg_premption() );
7462
Vadim Yanitskiy16bbde92020-08-28 05:30:45 +07007463 /* Frequency hopping parameters handling */
7464 execute( TC_fh_params_chan_activ() );
7465 execute( TC_fh_params_imm_ass() );
Vadim Yanitskiyaeb54a22020-09-01 06:25:25 +07007466 execute( TC_fh_params_assignment_cmd() );
Vadim Yanitskiyca974032020-09-01 07:20:39 +07007467 execute( TC_fh_params_si4_cbch() );
Harald Welte28d943e2017-11-25 15:00:50 +01007468}
7469
7470}