blob: d4073d19496c77a1a79be2711a69a39d7a32243d [file] [log] [blame]
Daniel Willmann19b8d902022-01-05 09:12:34 +01001module HNBGW_Tests {
2
3/* Integration Tests for OsmoHNBGW
4 * (C) 2021 by sysmocom - s.f.m.c. GmbH <info@sysmocom.de>
5 * 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 *
10 * SPDX-License-Identifier: GPL-2.0-or-later
11 *
12 * This test suite tests OsmoHNBGW while emulating the hNodeB as well as MSC, SGSN, MGW
13 * See README for more details.
14 */
15
16import from Misc_Helpers all;
17import from General_Types all;
18import from GSM_Types all;
19import from Osmocom_Types all;
20import from IPL4asp_Types all;
Neels Hofmeyr1e311462023-01-11 01:19:12 +010021import from Native_Functions all;
Daniel Willmann19b8d902022-01-05 09:12:34 +010022
23import from Osmocom_CTRL_Functions all;
24import from Osmocom_CTRL_Types all;
25import from Osmocom_CTRL_Adapter all;
26
27import from StatsD_Types all;
28import from StatsD_CodecPort all;
29import from StatsD_CodecPort_CtrlFunct all;
30import from StatsD_Checker all;
31
32import from Osmocom_VTY_Functions all;
33import from TELNETasp_PortType all;
34
35import from HNBAP_Templates all;
36import from HNBAP_PDU_Descriptions all;
37
38import from RUA_IEs all;
39import from RUA_Templates all;
40import from RUA_Emulation all;
41
42import from Iuh_Emulation all;
43
44import from RANAP_Types all;
45import from RANAP_PDU_Descriptions all;
46import from RANAP_PDU_Contents all;
47import from RANAP_IEs all;
48import from RANAP_Templates all;
Neels Hofmeyrb1bf16d2023-06-27 02:10:04 +020049import from RANAP_CodecPort all;
Daniel Willmann19b8d902022-01-05 09:12:34 +010050
51import from RAN_Adapter all;
Daniel Willmann19b8d902022-01-05 09:12:34 +010052import from RAN_Emulation all;
53
54import from MGCP_Emulation all;
55import from MGCP_Types all;
56import from MGCP_Templates all;
57import from MGCP_CodecPort all;
58import from SDP_Types all;
59
Neels Hofmeyra56e8fd2022-05-08 01:16:55 +020060import from PFCP_Types all;
61import from PFCP_Emulation all;
62import from PFCP_Templates all;
63import from PFCP_CodecPort all;
64
Neels Hofmeyr75d905b2023-04-27 00:30:25 +020065import from TCCConversion_Functions all;
Neels Hofmeyr7a48df12023-04-20 20:43:43 +020066import from MobileL3_Types all;
Neels Hofmeyr7d0e6802023-04-20 20:43:55 +020067import from MobileL3_CommonIE_Types all;
68import from MobileL3_GMM_SM_Types all;
Neels Hofmeyr7a48df12023-04-20 20:43:43 +020069import from L3_Templates all;
Neels Hofmeyr7d0e6802023-04-20 20:43:55 +020070import from L3_Common all;
Neels Hofmeyr7a48df12023-04-20 20:43:43 +020071
Neels Hofmeyrb1bf16d2023-06-27 02:10:04 +020072import from SCCPasp_Types all;
73
Neels Hofmeyr7a48df12023-04-20 20:43:43 +020074const integer NUM_MSC := 4;
75const integer NUM_SGSN := 4;
76
77const integer FIRST_MSC_IDX := 0;
78const integer FIRST_SGSN_IDX := NUM_MSC;
Neels Hofmeyr75d905b2023-04-27 00:30:25 +020079
Daniel Willmann19b8d902022-01-05 09:12:34 +010080modulepar {
81 /* IP address at which the HNodeB can be reached */
82 charstring mp_hnodeb_ip := "127.0.0.1";
83 integer mp_hnodeb_port := -1;
84
85 /* IP address at which the test binds */
86 charstring mp_hnbgw_ip := "127.0.0.1";
87 integer mp_hnbgw_iuh_port := 29169;
Neels Hofmeyrffcb8892023-06-27 01:09:57 +020088 integer mp_hnbgw_ctrl_port := 4262;
Daniel Willmann19b8d902022-01-05 09:12:34 +010089
90 charstring mp_mgw_ip := "127.0.0.1";
91 integer mp_mgw_port := 2427;
92
Neels Hofmeyr7a48df12023-04-20 20:43:43 +020093 RAN_Configurations mp_cn_cfg := {
94 /* MSCs (NUM_MSC entries) */
95 {
96 transport := RANAP_TRANSPORT_IuCS,
97 sccp_service_type := "mtp3_itu",
98 sctp_addr := { 23905, "127.0.0.1", 2905, "127.0.0.1" },
99 own_pc := 188, /* 0.23.4 first MSC emulation */
100 own_ssn := 142,
101 peer_pc := 189, /* 0.23.5 osmo-hnbgw */
102 peer_ssn := 142,
103 sio := '83'O,
104 rctx := 1
105 },
106 {
107 transport := RANAP_TRANSPORT_IuCS,
108 sccp_service_type := "mtp3_itu",
109 sctp_addr := { 23907, "127.0.0.1", 2905, "127.0.0.1" },
110 own_pc := 2, /* 0.0.2 second MSC emulation */
111 own_ssn := 142,
112 peer_pc := 189, /* 0.23.5 osmo-hnbgw */
113 peer_ssn := 142,
114 sio := '83'O,
115 rctx := 3
116 },
117 {
118 transport := RANAP_TRANSPORT_IuCS,
119 sccp_service_type := "mtp3_itu",
120 sctp_addr := { 23909, "127.0.0.1", 2905, "127.0.0.1" },
121 own_pc := 3, /* 0.0.3 third MSC emulation */
122 own_ssn := 142,
123 peer_pc := 189, /* 0.23.5 osmo-hnbgw */
124 peer_ssn := 142,
125 sio := '83'O,
126 rctx := 5
127 },
128 {
129 transport := RANAP_TRANSPORT_IuCS,
130 sccp_service_type := "mtp3_itu",
131 sctp_addr := { 23911, "127.0.0.1", 2905, "127.0.0.1" },
132 own_pc := 4, /* 0.0.4 fourth MSC emulation */
133 own_ssn := 142,
134 peer_pc := 189, /* 0.23.5 osmo-hnbgw */
135 peer_ssn := 142,
136 sio := '83'O,
137 rctx := 7
138 },
139
140 /* SGSNs (NUM_SGSN entries) */
141 {
142 transport := RANAP_TRANSPORT_IuCS,
143 sccp_service_type := "mtp3_itu",
144 sctp_addr := { /* local */ 23906, "127.0.0.1", /* remote */ 2905, "127.0.0.1" },
145 own_pc := 185, /* 0.23.1 first SGSN emulation */
146 own_ssn := 142,
147 peer_pc := 189, /* 2237, 1.23.5 osmo-hnbgw */
148 peer_ssn := 142,
149 sio := '83'O,
150 rctx := 2
151 },
152 {
153 transport := RANAP_TRANSPORT_IuCS,
154 sccp_service_type := "mtp3_itu",
155 sctp_addr := { /* local */ 23908, "127.0.0.1", /* remote */ 2905, "127.0.0.1" },
156 own_pc := 10, /* 0.1.2 second SGSN emulation */
157 own_ssn := 142,
158 peer_pc := 189, /* 2237, 1.23.5 osmo-hnbgw */
159 peer_ssn := 142,
160 sio := '83'O,
161 rctx := 4
162 },
163 {
164 transport := RANAP_TRANSPORT_IuCS,
165 sccp_service_type := "mtp3_itu",
166 sctp_addr := { /* local */ 23910, "127.0.0.1", /* remote */ 2905, "127.0.0.1" },
167 own_pc := 11, /* 0.1.3 third SGSN emulation */
168 own_ssn := 142,
169 peer_pc := 189, /* 2237, 1.23.5 osmo-hnbgw */
170 peer_ssn := 142,
171 sio := '83'O,
172 rctx := 6
173 },
174 {
175 transport := RANAP_TRANSPORT_IuCS,
176 sccp_service_type := "mtp3_itu",
177 sctp_addr := { /* local */ 23912, "127.0.0.1", /* remote */ 2905, "127.0.0.1" },
178 own_pc := 12, /* 0.1.4 fourth SGSN emulation */
179 own_ssn := 142,
180 peer_pc := 189, /* 2237, 1.23.5 osmo-hnbgw */
181 peer_ssn := 142,
182 sio := '83'O,
183 rctx := 8
184 }
Daniel Willmann19b8d902022-01-05 09:12:34 +0100185 };
Neels Hofmeyra56e8fd2022-05-08 01:16:55 +0200186
Neels Hofmeyrbacb74f2022-08-29 16:24:12 +0200187 boolean mp_enable_pfcp_tests := false;
188
Neels Hofmeyra56e8fd2022-05-08 01:16:55 +0200189 /* IP address at which we listen for PFCP to emulate a UPF in ttcn3 */
190 charstring mp_pfcp_ip_local := "127.0.0.1";
191
192 /* IP address from which the SUT (osmo-hnbgw) sends PFCP requests, and to which the ttcn3 UPF emulation sends
193 * PFCP responses. */
194 charstring mp_pfcp_ip_remote := "127.0.0.2";
Pau Espin Pedrol6c87ad92023-07-18 11:24:25 +0200195
196 boolean mp_validate_talloc_asn1 := true;
Pau Espin Pedrolee4ce862023-11-02 12:23:25 +0100197
198 /* The X31 timer configured at osmo-hnbgw (seconds). This provided an idea on
199 * minimum time the test must wait to consider this timer triggered */
200 integer mp_hnbgw_timer_x31 := 5;
Daniel Willmann19b8d902022-01-05 09:12:34 +0100201}
202
203function MSC_UnitdataCallback(RANAP_PDU ranap) runs on RAN_Emulation_CT return template RANAP_PDU {
204 // TODO: Actually implement unitdata handling
Neels Hofmeyrcf6dc492023-06-27 00:51:08 +0200205 return omit;
Daniel Willmann19b8d902022-01-05 09:12:34 +0100206}
207
208const RanOps MSC_RanOps := {
209 ranap_create_cb := refers(RAN_Emulation.RanapExpectedCreateCallback),
210 ranap_unitdata_cb := refers(MSC_UnitdataCallback),
211 ps_domain := false,
212 decode_dtap := false,
213 role_ms := false,
214 protocol := RAN_PROTOCOL_RANAP,
215 transport := RANAP_TRANSPORT_IuCS,
216 use_osmux := false,
Eric Wild6e511ce2022-04-02 21:35:56 +0200217 bssap_reset_retries := 1,
Daniel Willmann19b8d902022-01-05 09:12:34 +0100218 sccp_addr_local := omit,
219 sccp_addr_peer := omit
220}
221
Pau Espin Pedrol264679f2023-11-29 15:52:00 +0100222type record MgwResponse {
Daniel Willmann19b8d902022-01-05 09:12:34 +0100223 integer resp,
224 HostName mgw_rtp_ip,
Pau Espin Pedrol0c35a632023-11-29 16:00:35 +0100225 /* if set, used after first received MDCX: */
226 HostName mgw_rtp_ip_mdcx optional,
Daniel Willmann19b8d902022-01-05 09:12:34 +0100227 PortNumber mgw_rtp_port,
228 MgcpConnectionId mgcp_connection_id
229}
230type record MgcpParameters {
231 integer got_crcx_count,
232 integer got_dlcx_count,
233 MgcpCallId mgcp_call_id optional,
234 MgcpEndpoint mgcp_ep,
Pau Espin Pedrol264679f2023-11-29 15:52:00 +0100235 MgwResponse mgw_conn_ran,
236 MgwResponse mgw_conn_cn,
Daniel Willmann19b8d902022-01-05 09:12:34 +0100237 uint7_t rtp_payload_type,
238 charstring rtp_sdp_format,
239 HostName hnb_rtp_ip,
240 PortNumber hnb_rtp_port,
241 HostName cn_rtp_ip,
242 PortNumber cn_rtp_port,
243 boolean use_osmux,
244 integer got_osmux_count
245}
246
247template (value) MgcpParameters t_MgcpParams := {
248 got_crcx_count := 0,
249 got_dlcx_count := 0,
250 mgcp_call_id := omit,
251 mgcp_ep := "rtpbridge/1@mgw",
Pau Espin Pedrolb85ac2f2023-11-29 15:48:57 +0100252 mgw_conn_ran := {
Daniel Willmann19b8d902022-01-05 09:12:34 +0100253 resp := 1,
254 mgw_rtp_ip := "127.1.2.1",
Pau Espin Pedrol0c35a632023-11-29 16:00:35 +0100255 mgw_rtp_ip_mdcx := omit,
Daniel Willmann19b8d902022-01-05 09:12:34 +0100256 mgw_rtp_port := 10000,
257 mgcp_connection_id := '11111'H
258 },
Pau Espin Pedrolb85ac2f2023-11-29 15:48:57 +0100259 mgw_conn_cn := {
Daniel Willmann19b8d902022-01-05 09:12:34 +0100260 resp := 1,
261 mgw_rtp_ip := "127.1.2.2",
Pau Espin Pedrol0c35a632023-11-29 16:00:35 +0100262 mgw_rtp_ip_mdcx := omit,
Daniel Willmann19b8d902022-01-05 09:12:34 +0100263 mgw_rtp_port := 20000,
264 mgcp_connection_id := '22222'H
265 },
Philipp Maier6c5ba0752023-07-04 16:53:40 +0200266 rtp_payload_type := 112,
267 rtp_sdp_format := "VND.3GPP.IUFP",
Daniel Willmann19b8d902022-01-05 09:12:34 +0100268 hnb_rtp_ip := "127.1.1.1",
269 hnb_rtp_port := 10001,
270 cn_rtp_ip := "127.1.3.1",
271 cn_rtp_port := 20001,
272 use_osmux := false,
273 got_osmux_count := 0
274}
275
276type record TestHdlrParams {
277 integer hnb_idx,
Neels Hofmeyr7a48df12023-04-20 20:43:43 +0200278 /* cn_idx indicates which CN link from g_cn[] to connect to the test component.
279 * See also f_cn_idx(). */
280 integer cn_idx,
Daniel Willmann19b8d902022-01-05 09:12:34 +0100281 hexstring imsi,
282 boolean ps_domain,
283 MgcpParameters mgcp_pars optional,
Neels Hofmeyrf0b9ed12022-06-07 17:46:32 +0200284 HnbConfig hnb optional,
Neels Hofmeyrf2c95022023-04-19 01:24:39 +0200285 boolean expect_separate_sccp_cr,
286 integer tx_sccp_cr_data_len,
Neels Hofmeyr7d0e6802023-04-20 20:43:55 +0200287 charstring pfcp_local_addr,
Neels Hofmeyrb1bf16d2023-06-27 02:10:04 +0200288 octetstring nas_pdu optional,
289 /* local and remote SCCP addresses, used in TC_mscpool_paging_* */
290 SCCP_PAR_Address sccp_addr_msc optional,
291 SCCP_PAR_Address sccp_addr_hnbgw optional
Daniel Willmann19b8d902022-01-05 09:12:34 +0100292}
293
294/* We extend:
295 * RUA_ConnHdlr (for the Iuh side, emulating the HNB)
296 * RAN_ConnHdlr (for the Iu side, emulating the MSC)
297 * MGCP_ConnHdlr (for the MGCP side, emulating the MGW)
298 */
Neels Hofmeyra56e8fd2022-05-08 01:16:55 +0200299type component ConnHdlr extends RAN_ConnHdlr, MGCP_ConnHdlr, RUA_ConnHdlr, PFCP_ConnHdlr {
Daniel Willmann19b8d902022-01-05 09:12:34 +0100300 var integer g_sccp_conn_id;
301 var TestHdlrParams g_pars;
302 timer g_Tguard;
Neels Hofmeyr72a8d622023-01-26 13:47:01 +0100303
304 port TELNETasp_PT HNBGWVTY;
Daniel Willmann19b8d902022-01-05 09:12:34 +0100305}
306
307
308const MGCPOps MSC_MGCPOps := {
309 create_cb := refers(MGCP_Emulation.ExpectedCreateCallback),
310 unitdata_cb := refers(MGCP_Emulation.DummyUnitdataCallback)
311}
312
313function f_create_ranap_exp(octetstring l3_enc) runs on ConnHdlr {
314 BSSAP_PROC.call(RAN_register:{l3_enc, self}) {
315 [] BSSAP_PROC.getreply(RAN_register:{?, ?}) {};
316 }
317}
318
319
Daniel Willmannc79679a2022-08-23 17:48:39 +0200320const integer NUM_HNB := 2;
Daniel Willmann19b8d902022-01-05 09:12:34 +0100321
Daniel Willmann19b8d902022-01-05 09:12:34 +0100322type record HnbConfig {
323 LocationAreaIdentification lai,
324 integer sac
325}
326
327type component test_CT extends CTRL_Adapter_CT {
328 var boolean g_initialized := false;
329
330 /********************* Iu side */
Neels Hofmeyr7a48df12023-04-20 20:43:43 +0200331 var RAN_Adapter g_cn[NUM_MSC + NUM_SGSN];
Daniel Willmann19b8d902022-01-05 09:12:34 +0100332
333 /********************* Iuh side */
334 var HnbConfig g_hnb_cfg[NUM_HNB];
335 var Iuh_Emulation_CT vc_Iuh[NUM_HNB];
336 var RUA_Emulation_CT vc_RUA[NUM_HNB];
337 port HNBAP_PT HNBAP[NUM_HNB];
Pau Espin Pedrol83a49612022-09-12 21:11:05 +0200338 /* Number of HNBs to be used/started by the test */
339 var integer g_num_hnbs := NUM_HNB;
Daniel Willmann19b8d902022-01-05 09:12:34 +0100340
341 var MGCP_Emulation_CT vc_MGCP;
342 port TELNETasp_PT HNBGWVTY;
343 /* global test case guard timer (actual timeout value is set in f_init()) */
344 timer T_guard := 30.0;
Neels Hofmeyr7d0e6802023-04-20 20:43:55 +0200345
346 /* The cnlink type 'msc' or 'sgsn', to be used in CTRL commands to obtain counters */
347 var charstring g_ctr_cn_node_name;
348 /* Counter state */
349 var CounterNameValsList g_ctr_cn;
Daniel Willmann19b8d902022-01-05 09:12:34 +0100350}
351
352/* global altstep for global guard timer; */
353altstep as_Tguard() runs on test_CT {
354 [] T_guard.timeout {
355 setverdict(fail, "Timeout of T_guard");
356 mtc.stop;
357 }
358}
359
Daniel Willmann19b8d902022-01-05 09:12:34 +0100360function f_init_vty(charstring id := "foo") runs on test_CT {
361 if (HNBGWVTY.checkstate("Mapped")) {
362 /* skip initialization if already executed once */
363 return;
364 }
365 map(self:HNBGWVTY, system:HNBGWVTY);
366 f_vty_set_prompts(HNBGWVTY);
367 f_vty_transceive(HNBGWVTY, "enable");
368}
369
370function f_init_mgcp(charstring id) runs on test_CT {
371 id := id & "-MGCP";
372 var MGCPOps ops := {
373 create_cb := refers(MGCP_Emulation.ExpectedCreateCallback),
374 unitdata_cb := refers(MGCP_Emulation.DummyUnitdataCallback)
375 }
376 var MGCP_conn_parameters pars := {
377 callagent_ip := mp_hnbgw_ip,
378 callagent_udp_port := -1,
379 mgw_ip := mp_mgw_ip,
380 mgw_udp_port := mp_mgw_port,
381 multi_conn_mode := false
382 }
383
384 vc_MGCP := MGCP_Emulation_CT.create(id);
385 map(vc_MGCP:MGCP, system:MGCP_CODEC_PT);
386 vc_MGCP.start(MGCP_Emulation.main(ops, pars, id));
387}
388
Neels Hofmeyra56e8fd2022-05-08 01:16:55 +0200389function f_init_pfcp(charstring id) runs on ConnHdlr {
390 id := id & "-PFCP";
391
392 var PFCP_Emulation_Cfg pfcp_cfg := {
393 pfcp_bind_ip := mp_pfcp_ip_local,
394 pfcp_bind_port := PFCP_PORT,
395 pfcp_remote_ip := mp_pfcp_ip_remote,
396 pfcp_remote_port := PFCP_PORT,
397 role := UPF
398 };
399
400 vc_PFCP := PFCP_Emulation_CT.create(id) alive;
401 connect(self:PFCP, vc_PFCP:CLIENT);
402 connect(self:PFCP_PROC, vc_PFCP:CLIENT_PROC);
403 vc_PFCP.start(PFCP_Emulation.main(pfcp_cfg));
404}
405
Daniel Willmann19b8d902022-01-05 09:12:34 +0100406function f_init_hnodeb(charstring id, integer hnb_idx, RuaOps rua_ops) runs on test_CT {
407 id := id & "-Iuh" & int2str(hnb_idx);
408
409 /* Iuh lower layer (RUA/HNBAP demux) */
410 var Iuh_conn_parameters iuh_pars;
411 iuh_pars.remote_ip := mp_hnbgw_ip;
412 iuh_pars.remote_sctp_port := mp_hnbgw_iuh_port;
413 iuh_pars.local_ip := mp_hnodeb_ip;
414 iuh_pars.local_sctp_port := mp_hnodeb_port + hnb_idx;
415 vc_Iuh[hnb_idx] := Iuh_Emulation_CT.create(id);
416 connect(self:HNBAP[hnb_idx], vc_Iuh[hnb_idx]:HNBAP);
417
418 vc_RUA[hnb_idx] := RUA_Emulation_CT.create(id & "-RUA");
419 connect(vc_RUA[hnb_idx]:RUA, vc_Iuh[hnb_idx]:RUA);
420
421 /* Start Iuh side components */
422 vc_Iuh[hnb_idx].start(Iuh_Emulation.main(iuh_pars, id));
423 vc_RUA[hnb_idx].start(RUA_Emulation.main(rua_ops, id & "-RUA"));
424}
425
Neels Hofmeyr3d5a0da2023-06-27 00:57:46 +0200426private type record of boolean BooleanList;
427
428private function f_vty_cnlink_allow_attach(TELNETasp_PT pt, boolean ps_domain, BooleanList allow_attach_list)
429{
430 var charstring config := f_vty_transceive_ret(pt, "show running-config");
431
432 var charstring msc_sgsn;
433 if (ps_domain) {
434 msc_sgsn := "sgsn";
435 } else {
436 msc_sgsn := "msc";
437 }
438
439 f_vty_enter_config(pt);
440 for (var integer cn_nr := 0; cn_nr < sizeof(allow_attach_list); cn_nr := cn_nr+1) {
441 if (f_strstr(config, "\n" & msc_sgsn & " " & int2str(cn_nr) & "\n") < 0) {
442 /* There is no 'msc N' for this cn_nr in the running config, so don't create an empty cn by
443 * stepping into that config node. */
444 log(msc_sgsn, cn_nr, " is not configured, skipping");
445 continue;
446 }
447 f_vty_transceive(pt, msc_sgsn & " " & int2str(cn_nr));
448
449 if (allow_attach_list[cn_nr]) {
450 /* strict := false: ignore if osmo-hnbgw does not support this config option (latest build) */
451 f_vty_transceive(pt, "allow-attach", strict := false);
452 } else {
453 f_vty_transceive(pt, "no allow-attach", strict := false);
454 }
455 f_vty_transceive(pt, "exit");
456 }
457 f_vty_transceive(pt, "exit");
458}
459
460/* Start RAN adapter for CN link N.
461 * e.g. link for 'msc 0' = (ps_domain := false, cn_nr := 0)
462 * link for 'sgsn 3' = (ps_domain := true, cn_nr := 3)
463 */
464private function f_cn_nr_init(boolean ps_domain, integer cn_nr) runs on test_CT {
465 var RanOps ranops := MSC_RanOps;
466 ranops.ps_domain := ps_domain;
467 var integer cn_idx := f_cn_idx(ps_domain, cn_nr);
468 var charstring msc_sgsn := "msc";
469 if (ps_domain) {
470 msc_sgsn := "sgsn";
471 }
472 f_ran_adapter_init(g_cn[cn_idx], mp_cn_cfg[cn_idx], "HNBGW_Test." & msc_sgsn & int2str(cn_nr), ranops);
473 f_ran_adapter_start(g_cn[cn_idx]);
474}
475
476private function f_cn_idx_disconnect(integer cn_idx) runs on test_CT {
477 f_ran_adapter_cleanup(g_cn[cn_idx]);
478}
479
Daniel Willmann19b8d902022-01-05 09:12:34 +0100480/* global initialization function */
Neels Hofmeyr333ea392023-06-27 00:58:05 +0200481function f_init(charstring id := "HNBGW", float guard_timeout := 30.0, integer nr_msc := 1, integer nr_sgsn := 1,
482 boolean start_hnb := true) runs on test_CT {
Daniel Willmann19b8d902022-01-05 09:12:34 +0100483
Daniel Willmann19b8d902022-01-05 09:12:34 +0100484 T_guard.start(guard_timeout);
485 activate(as_Tguard());
486
487 /* RUA/RANAP emulation on top of lower-layer Iuh */
488 var RuaOps rua_ops := {
489 create_cb := refers(IuhRanapCreateCallback),
490 unitdata_cb := refers(IuhRanapUnitdataCallback)
491 };
Pau Espin Pedrol83a49612022-09-12 21:11:05 +0200492 for (var integer i := 0; i < g_num_hnbs; i := i+1) {
Daniel Willmannc79679a2022-08-23 17:48:39 +0200493 g_hnb_cfg[i] := {
494 lai := {
Neels Hofmeyr497216f2023-06-27 00:59:26 +0200495 mcc_mnc := '00F110'H,
Daniel Willmannc79679a2022-08-23 17:48:39 +0200496 lac := 2342 + i
497 },
498 sac := 55
499 };
Daniel Willmann19b8d902022-01-05 09:12:34 +0100500 f_init_hnodeb(testcasename(), i, rua_ops);
501 }
502
Neels Hofmeyr3d5a0da2023-06-27 00:57:46 +0200503 f_init_vty("VirtHNBGW");
Neels Hofmeyrffcb8892023-06-27 01:09:57 +0200504 f_ipa_ctrl_start_client(mp_hnbgw_ip, mp_hnbgw_ctrl_port);
505
Daniel Willmann19b8d902022-01-05 09:12:34 +0100506 /* MSC emulation */
Neels Hofmeyr3d5a0da2023-06-27 00:57:46 +0200507
508 /* Make sure each MSC's internal state is "DISCONNECTED" at first */
509 for (var integer i := 0; i < NUM_MSC; i := i + 1) {
510 f_vty_transceive(HNBGWVTY, "msc " & int2str(i) & " ranap reset", strict := false);
511 }
512
513 var BooleanList allow_attach := { false, false, false, false };
Neels Hofmeyr7a48df12023-04-20 20:43:43 +0200514 for (var integer i := 0; i < nr_msc; i := i + 1) {
515 var integer cn_idx := FIRST_MSC_IDX + i;
Neels Hofmeyr3d5a0da2023-06-27 00:57:46 +0200516 allow_attach[i] := true;
517 f_cn_nr_init(ps_domain := false, cn_nr := i);
Neels Hofmeyr7a48df12023-04-20 20:43:43 +0200518 }
Neels Hofmeyr3d5a0da2023-06-27 00:57:46 +0200519 /* start the test with exactly all enabled MSCs allowed to attach */
520 f_vty_cnlink_allow_attach(HNBGWVTY, false, allow_attach);
Daniel Willmann19b8d902022-01-05 09:12:34 +0100521
522 /* SGSN emulation */
Neels Hofmeyr3d5a0da2023-06-27 00:57:46 +0200523
524 /* Make sure each SGSN's internal state is "DISCONNECTED" at first */
525 for (var integer i := 0; i < NUM_SGSN; i := i + 1) {
526 f_vty_transceive(HNBGWVTY, "sgsn " & int2str(i) & " ranap reset", strict := false);
Neels Hofmeyr7a48df12023-04-20 20:43:43 +0200527 }
Daniel Willmann19b8d902022-01-05 09:12:34 +0100528
Neels Hofmeyr3d5a0da2023-06-27 00:57:46 +0200529 allow_attach := { false, false, false, false };
530 for (var integer i := 0; i < nr_sgsn; i := i + 1) {
531 var integer cn_idx := FIRST_SGSN_IDX + i;
532 allow_attach[i] := true;
533 f_cn_nr_init(ps_domain := true, cn_nr := i);
534 }
535 f_vty_cnlink_allow_attach(HNBGWVTY, true, allow_attach);
536
Daniel Willmann19b8d902022-01-05 09:12:34 +0100537 f_init_mgcp(id);
Neels Hofmeyr333ea392023-06-27 00:58:05 +0200538
539 if (start_hnb) {
540 f_start_hnbs();
541 }
Neels Hofmeyr467eb7e2023-08-10 03:38:07 +0200542
543 /* Sometimes, the RUA InitialUE-Message from a test happens too quickly, before the RANAP RESET from
544 * RAN_Emulation is through, after above f_cn_nr_init(). In the pcap it seems to be a matter of 50 ms. Give some
545 * grace. */
546 f_sleep(1.0);
Daniel Willmann19b8d902022-01-05 09:12:34 +0100547}
548
549friend function f_shutdown_helper() runs on test_CT {
Pau Espin Pedrol6c87ad92023-07-18 11:24:25 +0200550 if (mp_validate_talloc_asn1) {
551 f_verify_talloc_bytes(HNBGWVTY, {"asn1_context"}, 1);
552 }
Neels Hofmeyr75d905b2023-04-27 00:30:25 +0200553
Daniel Willmann19b8d902022-01-05 09:12:34 +0100554 all component.stop;
555 setverdict(pass);
556 mtc.stop;
557}
558
559/* helper function to start all of the simulated hNodeBs */
560function f_start_hnbs() runs on test_CT {
Pau Espin Pedrol83a49612022-09-12 21:11:05 +0200561 for (var integer i:= 0; i < g_num_hnbs; i := i+1) {
Daniel Willmannc79679a2022-08-23 17:48:39 +0200562 f_hnbap_register(i, i);
Daniel Willmann19b8d902022-01-05 09:12:34 +0100563 }
564}
565
566/***********************************************************************
567 * code running in test_CT, preparing start of per-UE ConnHdlr
568 ***********************************************************************/
569
570/* inbound RUA connection establishment on Iuh side */
571function IuhRanapCreateCallback(ContextId context_id, RUA_IEs.CN_DomainIndicator domain, charstring id)
572runs on RUA_Emulation_CT return RUA_ConnHdlr {
573 log("CreateCallback");
574 return null;
575}
576
577/* inbound RUA connectionless data on Iuh side */
578function IuhRanapUnitdataCallback(RANAP_PDU ranap)
579runs on RUA_Emulation_CT return template RANAP_PDU {
580 log("UnitdataCallback");
581 return omit;
582}
583
584private function f_start_handler_create(TestHdlrParams pars) runs on test_CT return ConnHdlr {
585 var ConnHdlr vc_conn;
586 var charstring id := testcasename() & int2str(pars.hnb_idx);
587
588 vc_conn := ConnHdlr.create(id);
589
590 /* Iuh RUA part */
591 connect(vc_conn:RUA, vc_RUA[pars.hnb_idx]:CLIENT);
592
Neels Hofmeyr7a48df12023-04-20 20:43:43 +0200593 /* MSC or SGSN */
594 connect(vc_conn:BSSAP, g_cn[pars.cn_idx].vc_RAN:CLIENT);
595 connect(vc_conn:BSSAP_PROC, g_cn[pars.cn_idx].vc_RAN:PROC);
596
Daniel Willmann19b8d902022-01-05 09:12:34 +0100597 /* MGCP part */
598 connect(vc_conn:MGCP, vc_MGCP:MGCP_CLIENT);
599 connect(vc_conn:MGCP_PROC, vc_MGCP:MGCP_PROC);
600
601 return vc_conn;
602}
603
604private function f_start_handler_run(ConnHdlr vc_conn, void_fn fn, TestHdlrParams pars) runs on test_CT {
605 var charstring id := testcasename(); // & int2str(pars.ran_idx);
606 /* We cannot use vc_conn.start(f_init_handler(fn, id, pars)); as we cannot have
607 * a stand-alone 'derefers()' call, see https://www.eclipse.org/forums/index.php/t/1091364/ */
608 pars.hnb := g_hnb_cfg[pars.hnb_idx];
609 pars.mgcp_pars := valueof(t_MgcpParams);
610 vc_conn.start(derefers(fn)(id, pars));
611}
612
613function f_start_handler_with_pars(void_fn fn, template (value) TestHdlrParams pars)
614runs on test_CT return ConnHdlr {
615 var ConnHdlr vc_conn;
616 vc_conn := f_start_handler_create(valueof(pars));
617 f_start_handler_run(vc_conn, fn, valueof(pars));
618 return vc_conn;
619}
620
621/***********************************************************************
622 * code running inside per-UE ConnHdlr
623 ***********************************************************************/
624
625type function void_fn(charstring id, TestHdlrParams pars) runs on ConnHdlr;
626
627function f_init_handler(TestHdlrParams pars, float t_guard := 20.0) runs on ConnHdlr {
628 /* make parameters available via component variable */
629 g_pars := pars;
Neels Hofmeyra56e8fd2022-05-08 01:16:55 +0200630
631 f_init_pfcp(testcasename());
632
Daniel Willmann19b8d902022-01-05 09:12:34 +0100633 /* start guard timer and activate it as default */
634 g_Tguard.start(t_guard);
635 activate(as_Tguard_ConnHdlr());
636
Neels Hofmeyr72a8d622023-01-26 13:47:01 +0100637 map(self:HNBGWVTY, system:HNBGWVTY);
638 f_vty_set_prompts(HNBGWVTY);
639 f_vty_transceive(HNBGWVTY, "enable");
640
Daniel Willmann19b8d902022-01-05 09:12:34 +0100641 /* TODO: CTRL? */
Neels Hofmeyr59517222023-06-23 04:46:59 +0200642
643 f_sleep(1.0);
Daniel Willmann19b8d902022-01-05 09:12:34 +0100644}
645
646/* global altstep for global guard timer; */
647private altstep as_Tguard_ConnHdlr() runs on ConnHdlr {
648 [] g_Tguard.timeout {
649 setverdict(fail, "Timeout of T_guard");
650 mtc.stop;
651 }
652}
653
Neels Hofmeyrdc416c92023-03-09 02:47:50 +0100654private function f_bssap_expect(template (present) RANAP_PDU exp_rx) runs on ConnHdlr return RANAP_PDU
655{
656 var RANAP_PDU rx;
657 timer T := 5.0;
658 T.start;
659 alt {
660 [] BSSAP.receive(exp_rx) -> value rx {
661 setverdict(pass);
662 }
663 [] BSSAP.receive(RANAP_PDU:?) {
664 setverdict(fail, "Got an unexpected RANAP message on BSSAP port, was waiting for ", exp_rx);
665 mtc.stop;
666 }
667 [] T.timeout {
668 setverdict(fail, "Timeout waiting for RANAP on BSSAP port: ", exp_rx);
669 mtc.stop;
670 }
671 }
672 T.stop;
673 return rx;
674}
675
Daniel Willmann19b8d902022-01-05 09:12:34 +0100676/* send RANAP on Iuh and expect it to show up on Iu */
677function f_iuh2iu(template (present) RANAP_PDU tx, template RANAP_PDU exp_rx := omit)
678runs on ConnHdlr return RANAP_PDU {
679 var RANAP_PDU rx;
680 timer T := 5.0;
681
682 if (istemplatekind(exp_rx, "omit")) {
683 exp_rx := tx;
684 }
685
686 RUA.send(tx);
Daniel Willmann19b8d902022-01-05 09:12:34 +0100687
Neels Hofmeyrdc416c92023-03-09 02:47:50 +0100688 return f_bssap_expect(exp_rx);
Daniel Willmann19b8d902022-01-05 09:12:34 +0100689}
690
691/* send RANAP on Iu and expect it to show up on Iuh */
692function f_iu2iuh(template (present) RANAP_PDU tx, template RANAP_PDU exp_rx := omit)
693runs on ConnHdlr return RANAP_PDU {
Daniel Willmann19b8d902022-01-05 09:12:34 +0100694 if (istemplatekind(exp_rx, "omit")) {
695 exp_rx := tx;
696 }
697
698 BSSAP.send(tx);
Daniel Willmann19b8d902022-01-05 09:12:34 +0100699
Neels Hofmeyr735b6562023-03-09 02:51:28 +0100700 return f_rua_expect(exp_rx)
701}
702
703/* expect to receive a specific RUA message on Iuh */
704private function f_rua_expect(template (present) RANAP_PDU exp_rx) runs on ConnHdlr return RANAP_PDU
705{
706 var RANAP_PDU rx;
707 timer T := 5.0;
708 T.start;
Daniel Willmann19b8d902022-01-05 09:12:34 +0100709 alt {
710 [] RUA.receive(exp_rx) -> value rx {
711 setverdict(pass);
712 }
Neels Hofmeyr735b6562023-03-09 02:51:28 +0100713 [] RUA.receive(RANAP_PDU:?) {
714 setverdict(fail, "Got an unexpected RUA message, was waiting for ", exp_rx);
715 mtc.stop;
716 }
Daniel Willmann19b8d902022-01-05 09:12:34 +0100717 [] T.timeout {
718 setverdict(fail, "Timeout waiting for Iuh ", exp_rx);
Neels Hofmeyr735b6562023-03-09 02:51:28 +0100719 mtc.stop;
Daniel Willmann19b8d902022-01-05 09:12:34 +0100720 }
721 }
Neels Hofmeyr735b6562023-03-09 02:51:28 +0100722 T.stop;
Daniel Willmann19b8d902022-01-05 09:12:34 +0100723 return rx;
724}
725
726/* send RANAP on Iuh and expect it to show up on Iu */
727function f_iuh2iu_connect(template (present) RANAP_PDU tx, template RANAP_PDU exp_rx := omit)
728runs on ConnHdlr return RANAP_PDU {
729 var RANAP_PDU rx;
730 timer T := 5.0;
731
732 if (istemplatekind(exp_rx, "omit")) {
733 exp_rx := tx;
734 }
735
736 /* create an expect on the Iu side for the random NAS portion */
Neels Hofmeyrf2c95022023-04-19 01:24:39 +0200737 if (g_pars.expect_separate_sccp_cr) {
Neels Hofmeyrf0b9ed12022-06-07 17:46:32 +0200738 f_ran_register_sccp_cr_without_payload();
739 } else {
740 var template (omit) octetstring nas := f_ranap_extract_l3(valueof(tx));
741 f_ran_register_exp(valueof(nas));
742 }
Daniel Willmann19b8d902022-01-05 09:12:34 +0100743
744 /* send it via Iuh (creating a RUA connection) */
745 RUA.send(RUA_Conn_Req:{g_pars.ps_domain, tx});
746
Neels Hofmeyrf2c95022023-04-19 01:24:39 +0200747 if (g_pars.expect_separate_sccp_cr) {
Neels Hofmeyrf0b9ed12022-06-07 17:46:32 +0200748 /* Acknowledge the empty SCCP CR. RAN_Emulation does the confirmation, no need to respond. */
749 BSSAP.receive(tr_RANAP_Conn_Req());
750 }
751
Daniel Willmann19b8d902022-01-05 09:12:34 +0100752 /* expect to receive it on the Iu side */
Neels Hofmeyrdc416c92023-03-09 02:47:50 +0100753 return f_bssap_expect(exp_rx);
Daniel Willmann19b8d902022-01-05 09:12:34 +0100754}
755
Neels Hofmeyr99b7d402023-02-20 14:26:31 +0100756/* 3GPP TS 48.006 9.2 Connection release:
757 *
758 * The MSC sends a SCCP released message. This message shall not contain
759 * any user data field.
760 *
761 * So what we expect normally is:
762 *
763 * HNBGW MSC
764 * RUA --id-Disconnect-------> | ---Data-Form-1(!)---> | Iu-ReleaseComplete
765 * | <--Released---------- | (no data)
766 *
767 * This function tests osmo-hnbgw behavior if the CN fails to send a RLSD:
768 * after some timeout, osmo-hnbgw should send a RLSD to the CN.
769 */
Daniel Willmann19b8d902022-01-05 09:12:34 +0100770function f_iuh2iu_disconnect(template (present) RANAP_PDU tx, RUA_IEs.Cause cause,
771 template RANAP_PDU exp_rx := omit)
772runs on ConnHdlr return RANAP_PDU {
773 var RANAP_PDU rx
Pau Espin Pedrolee4ce862023-11-02 12:23:25 +0100774 timer T := int2float(mp_hnbgw_timer_x31) + 1.0;
Daniel Willmann19b8d902022-01-05 09:12:34 +0100775
776 if (istemplatekind(exp_rx, "omit")) {
777 exp_rx := tx;
778 }
779
780 /* send it via Iuh (creating a RUA connection) */
781 RUA.send(RUA_Disc_Req:{tx, cause});
782
783 /* expect to receive it on the Iu side */
Neels Hofmeyrdc416c92023-03-09 02:47:50 +0100784 rx := f_bssap_expect(exp_rx);
Daniel Willmann19b8d902022-01-05 09:12:34 +0100785
786 /* expect disconnect on the Iu side */
Neels Hofmeyrdc416c92023-03-09 02:47:50 +0100787 T.start;
Daniel Willmann19b8d902022-01-05 09:12:34 +0100788 alt {
789 [] BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_DISC_IND) {
790 setverdict(pass);
791 }
792 [] T.timeout {
793 setverdict(fail, "Timeout waiting for Iu disconnect");
794 return rx;
795 }
796
797 }
798 return rx;
799}
800
Neels Hofmeyrf2c95022023-04-19 01:24:39 +0200801private function f_build_initial_ue_with_nas(TestHdlrParams pars, octetstring nas)
802 return RANAP_PDU {
Daniel Willmann19b8d902022-01-05 09:12:34 +0100803 var LAI lai := {
804 pLMNidentity := hex2oct(pars.hnb.lai.mcc_mnc),
805 lAC := int2oct(pars.hnb.lai.lac, 2),
806 iE_Extensions := omit
807 };
808 var SAI sai := {
809 pLMNidentity := lai.pLMNidentity,
810 lAC := lai.lAC,
811 sAC := int2oct(pars.hnb.sac, 2),
812 iE_Extensions := omit
813 }
Daniel Willmann19b8d902022-01-05 09:12:34 +0100814 var IuSignallingConnectionIdentifier sigc_id := int2bit(f_rnd_int(1000), 24);
815 var GlobalRNC_ID grnc_id := {
816 pLMNidentity := lai.pLMNidentity,
817 rNC_ID := 2342
818 }
Neels Hofmeyrf2c95022023-04-19 01:24:39 +0200819 var template RANAP_PDU ret;
Daniel Willmann19b8d902022-01-05 09:12:34 +0100820 if (pars.ps_domain) {
821 var RAC rac := '00'O;
Neels Hofmeyrf2c95022023-04-19 01:24:39 +0200822 ret := ts_RANAP_initialUE_PS(lai, rac, sai, nas, sigc_id, grnc_id);
Daniel Willmann19b8d902022-01-05 09:12:34 +0100823 } else {
Neels Hofmeyrf2c95022023-04-19 01:24:39 +0200824 ret := ts_RANAP_initialUE_CS(lai, sai, nas, sigc_id, grnc_id);
Daniel Willmann19b8d902022-01-05 09:12:34 +0100825 }
Neels Hofmeyrf2c95022023-04-19 01:24:39 +0200826 return valueof(ret);
827}
828
829/* build a RANAP InitialUE based on the TestHdlrParams */
830friend function f_build_initial_ue(TestHdlrParams pars) return RANAP_PDU {
831
832 var octetstring nas;
833
834 if (pars.tx_sccp_cr_data_len == 0) {
835 nas := f_rnd_octstring(10);
836 } else {
837 /* The test asks for an exact number of Optional Data bytes. */
838
839 /* First see what size the RANAP part of the payload data is,
840 * to adjust the NAS PDU size to the size requested by the test (pars.tx_sccp_cr_data_len). */
841 var RANAP_PDU initial_ue := f_build_initial_ue_with_nas(pars, '00'O);
842
843 var octetstring ranap_plus_one_byte_nas := enc_RANAP_PDU(initial_ue);
844 var integer ranap_length := lengthof(ranap_plus_one_byte_nas) - 1;
845
846 log("ranap_plus_one_byte_nas = ", lengthof(ranap_plus_one_byte_nas), " bytes, ", initial_ue, " = ",
847 ranap_plus_one_byte_nas);
848 log("ranap_length = ", ranap_length);
849
850 /* SCCP CR has a payload length limit of 130 bytes. To trigger this limit, the RANAP + NAS PDU has to be
851 * > 130 bytes. It doesn't need to be 131 bytes in the NAS PDU alone, but let's just make it definitely
852 * large enough. To test for this limit, pars.tx_sccp_cr_data_len asks for a specific amount of data len. */
853 nas := f_rnd_octstring(pars.tx_sccp_cr_data_len - ranap_length);
854 }
855
856 var RANAP_PDU ret := f_build_initial_ue_with_nas(pars, nas);
857
858 if (pars.tx_sccp_cr_data_len != 0) {
859 for (var integer attempts := 0; attempts < 2; attempts := attempts + 1) {
860 var octetstring check_len := enc_RANAP_PDU(ret);
861 log("final RANAP PDU length = ", lengthof(check_len));
862 if (lengthof(check_len) == pars.tx_sccp_cr_data_len) {
863 return ret;
864 }
865 nas := f_rnd_octstring(lengthof(nas) + (pars.tx_sccp_cr_data_len - lengthof(check_len)));
866 log("that was off, changed NAS length to ", lengthof(nas), " and trying again");
867 ret := f_build_initial_ue_with_nas(pars, nas);
868 }
869 setverdict(fail, "Ended up with wrong Optional Data length");
870 mtc.stop;
871 }
872 return ret;
Daniel Willmann19b8d902022-01-05 09:12:34 +0100873}
874
875/* build a RANAP RAB AssignmentResponse based on the TestHdlrParams */
876friend function f_build_rab_ass_resp(TestHdlrParams pars) return RANAP_PDU {
877 var template RAB_SetupOrModifiedList rab_sml;
878
879 rab_sml := ts_RAB_SMdL(t_RAB_id(23), f_ts_RAB_TLA("192.168.1.23"), t_RAB_binding_port(1234));
880
881 return valueof(ts_RANAP_RabAssResp(rab_sml));
882}
883
884
885/***********************************************************************
886 * HNBAP Testing
887 ***********************************************************************/
888
889
Daniel Willmannc79679a2022-08-23 17:48:39 +0200890function f_hnbap_register(integer hnb_idx := 0, integer cell_id := 0, boolean expect_reject := false) runs on test_CT
Daniel Willmann19b8d902022-01-05 09:12:34 +0100891{
892 timer T := 2.0;
893
Neels Hofmeyrfffe79b2023-06-27 01:16:15 +0200894 HNBAP[hnb_idx].send(ts_HNBAP_HNBRegisterRequest(char2oct("TTCN3-HNB-" & int2str(hnb_idx)),
Daniel Willmann19b8d902022-01-05 09:12:34 +0100895 '00F110'O,
Daniel Willmannc79679a2022-08-23 17:48:39 +0200896 int2bit(1 + cell_id, 28),
Daniel Willmann19b8d902022-01-05 09:12:34 +0100897 int2oct(2, 2),
898 int2oct(3, 1),
899 int2oct(4, 2)));
900
901 T.start;
902 alt {
903 [] HNBAP[hnb_idx].receive(tr_HNBAP_HNBRegisterAccept(?)) {
Daniel Willmannc79679a2022-08-23 17:48:39 +0200904 if (expect_reject) {
905 setverdict(fail, "Rx HNB Register Accept while expecting reject");
906 } else {
907 setverdict(pass);
908 }
909 }
910 [] HNBAP[hnb_idx].receive(tr_HNBAP_HNBRegisterReject(?)) {
911 if (expect_reject) {
912 setverdict(pass);
913 } else {
914 setverdict(fail, "Rx HNB Register Reject while expecting accept");
915 }
Daniel Willmann19b8d902022-01-05 09:12:34 +0100916 }
917 [] HNBAP[hnb_idx].receive(IUHEM_Event:?) {
918 repeat;
919 }
920 [] T.timeout {
Daniel Willmannc79679a2022-08-23 17:48:39 +0200921 setverdict(fail, "Timeout waiting for HNB Register response");
Daniel Willmann19b8d902022-01-05 09:12:34 +0100922 }
923 }
924}
925
926testcase TC_hnb_register() runs on test_CT {
Pau Espin Pedrol83a49612022-09-12 21:11:05 +0200927 g_num_hnbs := 1;
Neels Hofmeyr333ea392023-06-27 00:58:05 +0200928 f_init(start_hnb := false);
Daniel Willmann19b8d902022-01-05 09:12:34 +0100929 f_hnbap_register(0);
930 f_shutdown_helper();
931}
932
Pau Espin Pedrolacf4f222022-09-27 14:33:40 +0200933/* Try to register the same HNB from 2 different concurrent connections. Second
934 * one should be rejected. */
Daniel Willmannc79679a2022-08-23 17:48:39 +0200935testcase TC_hnb_register_duplicate() runs on test_CT {
Pau Espin Pedrol83a49612022-09-12 21:11:05 +0200936 g_num_hnbs := 2;
Neels Hofmeyr333ea392023-06-27 00:58:05 +0200937 f_init(start_hnb := false);
Daniel Willmannc79679a2022-08-23 17:48:39 +0200938 f_hnbap_register(0);
939 f_hnbap_register(1, 0, expect_reject := true);
940 f_verify_talloc_count(HNBGWVTY, {"struct hnb_context"}, expect_count := 1);
941 f_shutdown_helper();
942}
943
Pau Espin Pedrolacf4f222022-09-27 14:33:40 +0200944/* Try to register the same HNB in the same connection already established, aka
945 * duplicate HNB Register Request. It should be accepted and new configuration
946 * applied. TS 25.469 8.2.4 */
947testcase TC_hnb_register_duplicate_reuse_sctp_assoc() runs on test_CT {
948 g_num_hnbs := 1;
Neels Hofmeyr333ea392023-06-27 00:58:05 +0200949 f_init(start_hnb := false);
Pau Espin Pedrolacf4f222022-09-27 14:33:40 +0200950 f_hnbap_register(0);
951 f_hnbap_register(0);
952 f_verify_talloc_count(HNBGWVTY, {"struct hnb_context"}, expect_count := 1);
953 f_shutdown_helper();
954}
955
Pau Espin Pedrolf0b9fa02022-09-12 13:31:07 +0200956/* Drop HNBAP conn (HNBAP DEREG) and reconnect it (HNBAP REG) using same SCTP association.
957 * Related: OS#5676, SYS#6113 */
958testcase TC_hnb_reregister_reuse_sctp_assoc() runs on test_CT {
959 g_num_hnbs := 1;
Neels Hofmeyr333ea392023-06-27 00:58:05 +0200960 f_init(start_hnb := false);
Pau Espin Pedrolf0b9fa02022-09-12 13:31:07 +0200961 f_hnbap_register(0);
962 HNBAP[0].send(ts_HNBAP_HNBDe_Register(ts_HnbapCause(unspecified)));
963 f_hnbap_register(0);
964 f_verify_talloc_count(HNBGWVTY, {"struct hnb_context"}, expect_count := 1);
965 f_shutdown_helper();
966}
967
Daniel Willmann19b8d902022-01-05 09:12:34 +0100968/***********************************************************************
969 * RUA / RANAP Testing
970 ***********************************************************************/
971
Neels Hofmeyr7a48df12023-04-20 20:43:43 +0200972/* Translate from {msc,sgsn}x{0..n} to the proper index to use in g_cn[].
973 * g_cn[] stores CN links, MSCs and SGSNs in the same array.
974 * For example, for 'sgsn 23', use g_cn[ f_cn_idx(ps_domain := true, cn_nr := 23) ].
975 *
976 * Note the naming:
977 * cn_nr is the number used in the cfg file, as in 'msc 0'.
978 * cn_idx is the array index in g_cn[].
979 */
980private function f_cn_idx(boolean ps_domain, integer cn_nr := 0) return integer
981{
982 if (ps_domain) {
983 return FIRST_SGSN_IDX + cn_nr;
984 }
985 return FIRST_MSC_IDX + cn_nr;
986}
987
Daniel Willmann19b8d902022-01-05 09:12:34 +0100988private template (value) TestHdlrParams
Neels Hofmeyrf0b9ed12022-06-07 17:46:32 +0200989t_pars(integer imsi_suffix, boolean ps_domain := false, integer hnb_idx := 0,
Neels Hofmeyr7a48df12023-04-20 20:43:43 +0200990 boolean expect_separate_sccp_cr := false, integer tx_sccp_cr_data_len := 0,
991 integer cn_nr := 0) := {
Daniel Willmann19b8d902022-01-05 09:12:34 +0100992 hnb_idx := hnb_idx,
Neels Hofmeyr7a48df12023-04-20 20:43:43 +0200993 cn_idx := f_cn_idx(ps_domain, cn_nr),
Daniel Willmann19b8d902022-01-05 09:12:34 +0100994 imsi := f_gen_imsi(imsi_suffix),
995 ps_domain := ps_domain,
Neels Hofmeyrf0b9ed12022-06-07 17:46:32 +0200996 hnb := omit, /* filled in later */
Neels Hofmeyrf2c95022023-04-19 01:24:39 +0200997 expect_separate_sccp_cr := expect_separate_sccp_cr,
998 tx_sccp_cr_data_len := tx_sccp_cr_data_len,
Neels Hofmeyr7d0e6802023-04-20 20:43:55 +0200999 pfcp_local_addr := mp_pfcp_ip_local,
Neels Hofmeyrb1bf16d2023-06-27 02:10:04 +02001000 nas_pdu := omit,
1001 sccp_addr_msc := omit,
1002 sccp_addr_hnbgw := omit
Daniel Willmann19b8d902022-01-05 09:12:34 +01001003}
1004
1005/* Create an Iuh connection; send InitialUE; expect it to appear on new SCCP conenction */
1006friend function f_tc_initial_ue(charstring id, TestHdlrParams pars) runs on ConnHdlr {
1007 f_init_handler(pars);
1008 var RANAP_PDU tx := f_build_initial_ue(g_pars);
1009 f_iuh2iu_connect(tx);
1010}
1011testcase TC_ranap_cs_initial_ue() runs on test_CT {
1012 var ConnHdlr vc_conn;
1013
Pau Espin Pedrol83a49612022-09-12 21:11:05 +02001014 g_num_hnbs := 1;
Daniel Willmann19b8d902022-01-05 09:12:34 +01001015 f_init();
Daniel Willmann19b8d902022-01-05 09:12:34 +01001016
1017 vc_conn := f_start_handler_with_pars(refers(f_tc_initial_ue), t_pars(1));
1018 vc_conn.done;
Neels Hofmeyr3a9140e2023-06-23 04:50:39 +02001019
1020 f_shutdown_helper();
Daniel Willmann19b8d902022-01-05 09:12:34 +01001021}
1022testcase TC_ranap_ps_initial_ue() runs on test_CT {
1023 var ConnHdlr vc_conn;
1024
Pau Espin Pedrol83a49612022-09-12 21:11:05 +02001025 g_num_hnbs := 1;
Daniel Willmann19b8d902022-01-05 09:12:34 +01001026 f_init();
Daniel Willmann19b8d902022-01-05 09:12:34 +01001027
1028 vc_conn := f_start_handler_with_pars(refers(f_tc_initial_ue), t_pars(2, true));
1029 vc_conn.done;
Neels Hofmeyr3a9140e2023-06-23 04:50:39 +02001030
1031 f_shutdown_helper();
Daniel Willmann19b8d902022-01-05 09:12:34 +01001032}
1033
Neels Hofmeyrf2c95022023-04-19 01:24:39 +02001034private function f_vty_set_sccp_max_optional_data(TELNETasp_PT pt, integer val := -1)
Neels Hofmeyrf0b9ed12022-06-07 17:46:32 +02001035{
Neels Hofmeyrf2c95022023-04-19 01:24:39 +02001036 var charstring valstr;
1037 if (val < 0) {
1038 valstr := "standard";
1039 } else {
1040 valstr := int2str(val);
1041 }
Neels Hofmeyrf0b9ed12022-06-07 17:46:32 +02001042 f_vty_enter_config(pt);
Neels Hofmeyrf2c95022023-04-19 01:24:39 +02001043 f_vty_transceive(pt, "cs7 instance 0");
1044 f_vty_transceive(pt, "sccp max-optional-data " & valstr);
Neels Hofmeyrf0b9ed12022-06-07 17:46:32 +02001045 f_vty_transceive(pt, "end");
1046}
1047
1048testcase TC_ranap_cs_initial_ue_empty_cr() runs on test_CT {
1049 var ConnHdlr vc_conn;
1050
Pau Espin Pedrol83a49612022-09-12 21:11:05 +02001051 g_num_hnbs := 1;
Neels Hofmeyrf0b9ed12022-06-07 17:46:32 +02001052 f_init();
Neels Hofmeyrf0b9ed12022-06-07 17:46:32 +02001053
Neels Hofmeyrf2c95022023-04-19 01:24:39 +02001054 f_vty_set_sccp_max_optional_data(HNBGWVTY, 0);
Neels Hofmeyrf0b9ed12022-06-07 17:46:32 +02001055
Neels Hofmeyrf2c95022023-04-19 01:24:39 +02001056 vc_conn := f_start_handler_with_pars(refers(f_tc_initial_ue), t_pars(1, expect_separate_sccp_cr := true));
Neels Hofmeyrf0b9ed12022-06-07 17:46:32 +02001057 vc_conn.done;
1058
1059 /* reset */
Neels Hofmeyrf2c95022023-04-19 01:24:39 +02001060 f_vty_set_sccp_max_optional_data(HNBGWVTY);
Neels Hofmeyr3a9140e2023-06-23 04:50:39 +02001061
1062 f_shutdown_helper();
Neels Hofmeyrf0b9ed12022-06-07 17:46:32 +02001063}
1064testcase TC_ranap_ps_initial_ue_empty_cr() runs on test_CT {
1065 var ConnHdlr vc_conn;
1066
Pau Espin Pedrol83a49612022-09-12 21:11:05 +02001067 g_num_hnbs := 1;
Neels Hofmeyrf0b9ed12022-06-07 17:46:32 +02001068 f_init();
Neels Hofmeyrf0b9ed12022-06-07 17:46:32 +02001069
Neels Hofmeyrf2c95022023-04-19 01:24:39 +02001070 f_vty_set_sccp_max_optional_data(HNBGWVTY, 0);
Neels Hofmeyrf0b9ed12022-06-07 17:46:32 +02001071
Neels Hofmeyrf2c95022023-04-19 01:24:39 +02001072 vc_conn := f_start_handler_with_pars(refers(f_tc_initial_ue), t_pars(2, true, expect_separate_sccp_cr := true));
Neels Hofmeyrf0b9ed12022-06-07 17:46:32 +02001073 vc_conn.done;
1074
1075 /* reset */
Neels Hofmeyrf2c95022023-04-19 01:24:39 +02001076 f_vty_set_sccp_max_optional_data(HNBGWVTY);
Neels Hofmeyr3a9140e2023-06-23 04:50:39 +02001077
1078 f_shutdown_helper();
Neels Hofmeyrf2c95022023-04-19 01:24:39 +02001079}
1080
1081type record Testdata_CR_Limit {
1082 integer data_len,
1083 integer max_optional_data,
1084 boolean expect_separate_sccp_cr
1085};
1086type record of Testdata_CR_Limit Testdata_CR_Limits;
1087
1088testcase TC_sccp_cr_limit() runs on test_CT {
1089 g_num_hnbs := 1;
1090 f_init();
Neels Hofmeyrf2c95022023-04-19 01:24:39 +02001091
1092 const Testdata_CR_Limits tests := {
1093 { data_len := 130, max_optional_data := -1, expect_separate_sccp_cr := false },
1094 { data_len := 131, max_optional_data := -1, expect_separate_sccp_cr := true },
1095
1096 { data_len := 100, max_optional_data := 100, expect_separate_sccp_cr := false },
1097 { data_len := 101, max_optional_data := 100, expect_separate_sccp_cr := true },
1098
1099 { data_len := 200, max_optional_data := 200, expect_separate_sccp_cr := false },
1100 { data_len := 201, max_optional_data := 200, expect_separate_sccp_cr := true }
1101 };
1102
1103 var integer csps;
1104 for (csps := 0; csps < 2; csps := csps + 1) {
1105 var boolean ps_domain := (csps > 0);
1106
1107 var integer i;
1108 for (i := 0; i < lengthof(tests); i := i + 1) {
1109 var Testdata_CR_Limit t := tests[i];
1110 f_logp(HNBGWVTY,
1111 "TEST PART TC_sccp_cr_limit ps_domain=" & f_bool2str(ps_domain)
1112 & " data_len=" & int2str(t.data_len)
1113 & " max_optional_data=" & int2str(t.max_optional_data)
1114 & " expect_separate_sccp_cr=" & f_bool2str(t.expect_separate_sccp_cr)
1115 );
1116
1117 f_vty_set_sccp_max_optional_data(HNBGWVTY, t.max_optional_data);
1118 var ConnHdlr vc_conn;
1119 vc_conn := f_start_handler_with_pars(refers(f_tc_initial_ue),
1120 t_pars(100 + i,
1121 ps_domain := ps_domain,
1122 expect_separate_sccp_cr := t.expect_separate_sccp_cr,
1123 tx_sccp_cr_data_len := t.data_len));
1124 vc_conn.done;
1125 }
1126 }
1127
1128 /* reset */
1129 f_vty_set_sccp_max_optional_data(HNBGWVTY);
Neels Hofmeyr3a9140e2023-06-23 04:50:39 +02001130
1131 f_shutdown_helper();
Neels Hofmeyrf0b9ed12022-06-07 17:46:32 +02001132}
1133
Daniel Willmann19b8d902022-01-05 09:12:34 +01001134/* Reply to a received CRCX with an OK (or the reply configured in cpars), using the given parameters.
1135 * Return true when an OK reply was sent, false otherwise.
1136 * Count occurrence of Osmux, include Osmux parameters in the reply if necessary. */
1137function f_handle_crcx(inout MgcpParameters pars, MgcpCommand mgcp_cmd) return template MgcpResponse {
Pau Espin Pedrol264679f2023-11-29 15:52:00 +01001138 var MgwResponse conn := pars.mgw_conn_ran;
Daniel Willmann19b8d902022-01-05 09:12:34 +01001139 if (pars.got_crcx_count > 0) {
Pau Espin Pedrolb85ac2f2023-11-29 15:48:57 +01001140 conn := pars.mgw_conn_cn;
Daniel Willmann19b8d902022-01-05 09:12:34 +01001141 }
1142 pars.got_crcx_count := pars.got_crcx_count + 1;
1143
1144 var MgcpMessage mgcp_msg := {
1145 command := mgcp_cmd
1146 }
1147 var template MgcpResponse mgcp_resp;
1148 var MgcpOsmuxCID osmux_cid;
1149 var MgcpCallId call_id := f_MgcpCmd_extract_call_id(mgcp_cmd);
1150 if (ispresent(pars.mgcp_call_id)) {
1151 if (pars.mgcp_call_id != call_id) {
1152 setverdict(fail, "CRCX contained unexpected call id. Expected:", pars.mgcp_call_id, " got:", call_id);
1153 mtc.stop;
1154 }
1155 } else {
1156 pars.mgcp_call_id := call_id;
1157 }
1158
1159 /* When the endpoint contains a wildcard we keep the endpoint
1160 * identifier we have set up in pars. Otherwise we use the
1161 * endpoint name that the call agent has supplied */
1162 if (match(mgcp_cmd.line.ep, t_MGCP_EP_wildcard) == false) {
1163 pars.mgcp_ep := mgcp_cmd.line.ep;
1164 }
1165
1166 if (conn.resp == -1) {
1167 /* Reply with rror */
1168 var MgcpResponse mgcp_rsp := {
1169 line := {
1170 code := "542",
1171 trans_id := mgcp_cmd.line.trans_id,
1172 string := "FORCED_FAIL"
1173 },
1174 sdp := omit
1175
1176 }
1177 var MgcpParameter mgcp_rsp_param := {
1178 code := "Z",
1179 val := pars.mgcp_ep
1180 };
1181 mgcp_rsp.params[0] := mgcp_rsp_param;
1182 return mgcp_rsp;
1183 }
1184
1185 if (conn.resp == 0) {
1186 /* Do not reply at all */
1187 return omit;
1188 }
1189
1190 if (conn.resp != 1) {
1191 setverdict(fail, "Unexpected value for pars.mgw_conn_*.resp, expect -1, 0 or 1");
1192 mtc.stop;
1193 }
1194
1195 var SDP_Message sdp := valueof(ts_SDP(conn.mgw_rtp_ip, conn.mgw_rtp_ip,
1196 hex2str(pars.mgcp_call_id), "42",
1197 conn.mgw_rtp_port,
1198 { int2str(pars.rtp_payload_type) },
1199 { valueof(ts_SDP_rtpmap(pars.rtp_payload_type,
1200 pars.rtp_sdp_format)),
1201 valueof(ts_SDP_ptime(20)) }));
1202
1203 if (f_mgcp_contains_par(mgcp_msg, "X-OSMUX")) {
1204 if (not pars.use_osmux) {
1205 setverdict(fail, "MSC sent X-Osmux parameter in MGCP, but not expecting any Osmux");
1206 mtc.stop;
1207 }
1208 pars.got_osmux_count := pars.got_osmux_count + 1;
1209 /* we expect MSC to use wildcard here, i.e. osmux_cid == -1 */
1210 osmux_cid := f_MgcpCmd_extract_osmux_cid(mgcp_cmd);
1211 log("f_handle_crcx(): got Osmux CID: ", osmux_cid);
1212 if (osmux_cid != -1) {
1213 setverdict(fail, "MSC using unexpected CID " & int2str(osmux_cid) & " != -1");
1214 mtc.stop;
1215 }
1216
1217 osmux_cid := 0;
1218 mgcp_resp := ts_CRCX_ACK_osmux(mgcp_cmd.line.trans_id, conn.mgcp_connection_id, osmux_cid, sdp);
1219 } else {
1220 mgcp_resp := ts_CRCX_ACK(mgcp_cmd.line.trans_id, conn.mgcp_connection_id, sdp);
1221 }
1222
1223 f_mgcp_par_append(mgcp_resp.params, ts_MgcpParSpecEP(pars.mgcp_ep));
1224
1225 return mgcp_resp;
1226}
1227
Daniel Willmann3e15b7b2022-02-21 17:07:02 +01001228friend function f_create_rab(inout MgcpParameters pars) runs on ConnHdlr {
1229 f_rab_ass_req(pars);
1230 f_rab_ass_resp(pars);
1231}
1232
1233friend function f_rab_ass_req(inout MgcpParameters pars) runs on ConnHdlr {
Daniel Willmann19b8d902022-01-05 09:12:34 +01001234 var MgcpCommand mgcp_cmd;
1235 var RANAP_PDU tx;
1236 var template RAB_SetupOrModifyList rab_sml;
Daniel Willmann19b8d902022-01-05 09:12:34 +01001237 timer T := 5.0;
1238
1239 /* Send RAB Assignment Request */
1240 rab_sml := ts_RAB_SML(t_RAB_id(23), f_ts_RAB_TLA(pars.cn_rtp_ip), t_RAB_binding_port(pars.cn_rtp_port));
1241 tx := valueof(ts_RANAP_RabAssReq(rab_sml));
1242 BSSAP.send(tx);
1243 T.start;
1244
1245 /* Handle MGCP CRCX */
1246 alt {
1247 [] MGCP.receive(tr_CRCX) -> value mgcp_cmd {
1248 log("CRCX1", mgcp_cmd);
1249 var template MgcpResponse mgcp_rsp := f_handle_crcx(pars, mgcp_cmd);
1250 MGCP.send(valueof(mgcp_rsp));
1251 }
1252 [] T.timeout {
1253 setverdict(fail, "Timeout waiting for MGCP");
1254 }
1255 }
Neels Hofmeyr735b6562023-03-09 02:51:28 +01001256 T.stop;
Daniel Willmann19b8d902022-01-05 09:12:34 +01001257
1258 /* Expect RAB Assignment Request with IP/port from CRCX ACK via Iuh */
Pau Espin Pedrolb85ac2f2023-11-29 15:48:57 +01001259 rab_sml := ts_RAB_SML(t_RAB_id(23), f_ts_RAB_TLA(pars.mgw_conn_ran.mgw_rtp_ip), t_RAB_binding_port(pars.mgw_conn_ran.mgw_rtp_port));
Daniel Willmann19b8d902022-01-05 09:12:34 +01001260 tx := valueof(ts_RANAP_RabAssReq(rab_sml));
1261
Neels Hofmeyr735b6562023-03-09 02:51:28 +01001262 f_rua_expect(tx);
Daniel Willmann3e15b7b2022-02-21 17:07:02 +01001263}
1264
1265friend function f_rab_ass_resp(inout MgcpParameters pars) runs on ConnHdlr {
1266 var MgcpCommand mgcp_cmd;
1267 var RANAP_PDU tx;
1268 var template RAB_SetupOrModifiedList rab_smdl;
Daniel Willmann19b8d902022-01-05 09:12:34 +01001269
1270 /* Send back RAB Assignment Response via Iuh */
1271 rab_smdl := ts_RAB_SMdL(t_RAB_id(23), f_ts_RAB_TLA(pars.hnb_rtp_ip), t_RAB_binding_port(pars.hnb_rtp_port));
1272 tx := valueof(ts_RANAP_RabAssResp(rab_smdl));
1273 RUA.send(tx);
Daniel Willmann19b8d902022-01-05 09:12:34 +01001274
1275 interleave {
1276 /* Expect MDCX with IP/port from RAB Assignment Response */
1277 [] MGCP.receive(tr_MDCX(tr_SDP(pars.hnb_rtp_ip, pars.hnb_rtp_port))) -> value mgcp_cmd {
Pau Espin Pedrol0c35a632023-11-29 16:00:35 +01001278 var HostName mgw_rtp_ip;
Daniel Willmann19b8d902022-01-05 09:12:34 +01001279 log("MDCX1", mgcp_cmd);
Pau Espin Pedrol0c35a632023-11-29 16:00:35 +01001280 if (ispresent(pars.mgw_conn_ran.mgw_rtp_ip_mdcx)) {
1281 mgw_rtp_ip := pars.mgw_conn_ran.mgw_rtp_ip_mdcx;
1282 } else {
1283 mgw_rtp_ip := pars.mgw_conn_ran.mgw_rtp_ip;
1284 }
1285
Daniel Willmann19b8d902022-01-05 09:12:34 +01001286 /* Verify SDP of MDCX */
Pau Espin Pedrol0c35a632023-11-29 16:00:35 +01001287 var SDP_Message sdp := valueof(ts_SDP(mgw_rtp_ip, mgw_rtp_ip, hex2str(pars.mgcp_call_id), "42", pars.mgw_conn_ran.mgw_rtp_port,
Daniel Willmann19b8d902022-01-05 09:12:34 +01001288 { int2str(pars.rtp_payload_type) }, { valueof(ts_SDP_rtpmap(pars.rtp_payload_type, pars.rtp_sdp_format)), valueof(ts_SDP_ptime(20)) } ));
Pau Espin Pedrolb85ac2f2023-11-29 15:48:57 +01001289 var template MgcpResponse mgcp_rsp := ts_MDCX_ACK(mgcp_cmd.line.trans_id, pars.mgw_conn_ran.mgcp_connection_id, sdp);
Daniel Willmann19b8d902022-01-05 09:12:34 +01001290 MGCP.send(valueof(mgcp_rsp));
1291 }
1292 /* Handle CRCX for second leg of endpoint, answer with IP/port */
1293 [] MGCP.receive(tr_CRCX(pars.mgcp_ep, tr_SDP(pars.cn_rtp_ip, pars.cn_rtp_port))) -> value mgcp_cmd {
1294 log("CRCX2", mgcp_cmd);
1295 /* Verify SDP of CRCX */
1296 var template MgcpResponse mgcp_rsp := f_handle_crcx(pars, mgcp_cmd);
1297 MGCP.send(valueof(mgcp_rsp));
1298 }
1299 }
1300
1301 /* Expect RAB Assignment Response with IP/port from second CRCX ACK */
Pau Espin Pedrolb85ac2f2023-11-29 15:48:57 +01001302 rab_smdl := ts_RAB_SMdL(t_RAB_id(23), f_ts_RAB_TLA(pars.mgw_conn_cn.mgw_rtp_ip), t_RAB_binding_port(pars.mgw_conn_cn.mgw_rtp_port));
Daniel Willmann19b8d902022-01-05 09:12:34 +01001303 tx := valueof(ts_RANAP_RabAssResp(rab_smdl));
1304
Neels Hofmeyrdc416c92023-03-09 02:47:50 +01001305 f_bssap_expect(tx);
Daniel Willmann19b8d902022-01-05 09:12:34 +01001306}
1307
1308private altstep as_mgcp_dlcx(inout TestHdlrParams pars) runs on ConnHdlr {
1309 var MgcpCommand mgcp_cmd;
1310
1311 [] MGCP.receive(tr_DLCX(pars.mgcp_pars.mgcp_ep)) -> value mgcp_cmd {
1312 log("DLCX", mgcp_cmd);
1313 MGCP.send(ts_DLCX_ACK2(mgcp_cmd.line.trans_id));
1314 pars.mgcp_pars.got_dlcx_count := pars.mgcp_pars.got_dlcx_count + 1;
Daniel Willmann3e15b7b2022-02-21 17:07:02 +01001315 if (pars.mgcp_pars.got_dlcx_count != pars.mgcp_pars.got_crcx_count) {
Daniel Willmann19b8d902022-01-05 09:12:34 +01001316 repeat;
1317 }
1318 setverdict(pass);
1319 }
1320}
1321
1322friend function f_tc_rab_assignment(charstring id, TestHdlrParams pars) runs on ConnHdlr {
1323 var MgcpCommand mgcp_cmd;
1324 var RANAP_PDU tx;
1325 timer T := 5.0;
1326
1327 f_init_handler(pars);
1328 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
1329
1330 tx := f_build_initial_ue(g_pars);
1331 f_iuh2iu_connect(tx);
1332
1333 f_create_rab(pars.mgcp_pars);
1334
1335 /* Send Iu Release */
1336 tx := valueof(ts_RANAP_IuReleaseCommand(ts_RanapCause_om_intervention));
1337 f_iu2iuh(tx);
1338
1339 T.start;
1340 alt {
1341 [] as_mgcp_dlcx(pars) {}
1342 [] T.timeout {
1343 setverdict(fail, "Timeout waiting for DLCX");
1344 }
1345 }
1346
1347 tx := valueof(ts_RANAP_IuReleaseComplete());
1348 f_iuh2iu(tx);
1349}
1350
1351testcase TC_rab_assignment() runs on test_CT {
1352 var ConnHdlr vc_conn;
Pau Espin Pedrol83a49612022-09-12 21:11:05 +02001353 g_num_hnbs := 1;
Daniel Willmann19b8d902022-01-05 09:12:34 +01001354 f_init();
Daniel Willmann19b8d902022-01-05 09:12:34 +01001355
1356 vc_conn := f_start_handler_with_pars(refers(f_tc_rab_assignment), t_pars(3));
1357 vc_conn.done;
Neels Hofmeyr3a9140e2023-06-23 04:50:39 +02001358
1359 f_shutdown_helper();
Daniel Willmann19b8d902022-01-05 09:12:34 +01001360}
1361
Daniel Willmann3e15b7b2022-02-21 17:07:02 +01001362friend function f_tc_rab_assign_fail(charstring id, TestHdlrParams pars) runs on ConnHdlr {
1363 var MgcpCommand mgcp_cmd;
1364 var RANAP_PDU tx;
1365 timer T := 5.0;
1366
1367 f_init_handler(pars);
1368 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
1369
1370 tx := f_build_initial_ue(g_pars);
1371 f_iuh2iu_connect(tx);
1372
1373 f_rab_ass_req(pars.mgcp_pars);
1374
1375 /* Send RAB failed list in response */
1376 tx := valueof(ts_RANAP_RabAssResp(rab_fl := ts_RAB_FL(t_RAB_id(23), ts_RanapCause_om_intervention)));
1377 f_iuh2iu(tx);
1378
1379 T.start;
1380 alt {
1381 [] as_mgcp_dlcx(pars) {}
1382 [] T.timeout {
1383 setverdict(fail, "Timeout waiting for DLCX");
1384 }
1385 }
1386}
1387
1388testcase TC_rab_assign_fail() runs on test_CT {
1389 var ConnHdlr vc_conn;
Pau Espin Pedrol83a49612022-09-12 21:11:05 +02001390 g_num_hnbs := 1;
Daniel Willmann3e15b7b2022-02-21 17:07:02 +01001391 f_init();
Daniel Willmann3e15b7b2022-02-21 17:07:02 +01001392
1393 vc_conn := f_start_handler_with_pars(refers(f_tc_rab_assign_fail), t_pars(4));
1394 vc_conn.done;
Neels Hofmeyr3a9140e2023-06-23 04:50:39 +02001395
1396 f_shutdown_helper();
Daniel Willmann3e15b7b2022-02-21 17:07:02 +01001397}
1398
Daniel Willmann19b8d902022-01-05 09:12:34 +01001399friend function f_tc_rab_release(charstring id, TestHdlrParams pars) runs on ConnHdlr {
1400 var MgcpCommand mgcp_cmd;
1401 var RANAP_PDU tx;
1402 timer T := 15.0;
1403
1404 f_init_handler(pars);
1405 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
1406
1407 tx := f_build_initial_ue(g_pars);
1408 f_iuh2iu_connect(tx);
1409
1410 f_create_rab(pars.mgcp_pars);
1411
1412 /* Send RAB Release */
Daniel Willmann9e789be2022-02-22 13:30:51 +01001413 tx := valueof(ts_RANAP_RabAssReq(rab_rl := ts_RAB_RL(t_RAB_id(23), ts_RanapCause_om_intervention)));
Daniel Willmann19b8d902022-01-05 09:12:34 +01001414 BSSAP.send(tx);
1415
1416 T.start;
1417
1418 alt {
1419 [] as_mgcp_dlcx(pars) {}
1420 [] T.timeout {
1421 setverdict(fail, "Timeout waiting for DLCX");
1422 }
1423 }
Neels Hofmeyr735b6562023-03-09 02:51:28 +01001424 T.stop;
Daniel Willmann19b8d902022-01-05 09:12:34 +01001425
Neels Hofmeyr735b6562023-03-09 02:51:28 +01001426 f_rua_expect(tx);
Daniel Willmann19b8d902022-01-05 09:12:34 +01001427}
1428
1429testcase TC_rab_release() runs on test_CT {
1430 var ConnHdlr vc_conn;
Pau Espin Pedrol83a49612022-09-12 21:11:05 +02001431 g_num_hnbs := 1;
Daniel Willmann19b8d902022-01-05 09:12:34 +01001432 f_init();
Daniel Willmann19b8d902022-01-05 09:12:34 +01001433
1434 vc_conn := f_start_handler_with_pars(refers(f_tc_rab_release), t_pars(5));
1435 vc_conn.done;
Neels Hofmeyr3a9140e2023-06-23 04:50:39 +02001436
1437 f_shutdown_helper();
Daniel Willmann19b8d902022-01-05 09:12:34 +01001438}
1439
Daniel Willmann37c877f2022-02-22 16:47:06 +01001440friend function f_tc_rab_assign_mgcp_to(charstring id, TestHdlrParams pars) runs on ConnHdlr {
1441 var MgcpCommand mgcp_cmd;
1442 var RANAP_PDU tx;
1443 var template RAB_SetupOrModifyList rab_sml;
1444 timer T := 15.0;
1445
1446 T.start;
1447 f_init_handler(pars);
1448 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
1449
1450 tx := f_build_initial_ue(g_pars);
1451 f_iuh2iu_connect(tx);
1452
1453
1454 /* Send RAB Assignment Request */
1455 rab_sml := ts_RAB_SML(t_RAB_id(23), f_ts_RAB_TLA(pars.mgcp_pars.cn_rtp_ip), t_RAB_binding_port(pars.mgcp_pars.cn_rtp_port));
1456 tx := valueof(ts_RANAP_RabAssReq(rab_sml));
1457 BSSAP.send(tx);
1458
1459 /* Ignore MGCP CRCX */
1460 alt {
1461 [] MGCP.receive(tr_CRCX) -> value mgcp_cmd {
1462 log("Ignoreing CRCX1", mgcp_cmd);
1463 repeat;
1464 }
1465 [] BSSAP.receive(tr_RANAP_IuReleaseRequest(?)) { }
1466 [] T.timeout {
1467 setverdict(fail, "Timeout waiting for IuRelease");
1468 }
1469 }
1470
1471 /* Send Iu Release */
1472 tx := valueof(ts_RANAP_IuReleaseCommand(ts_RanapCause_om_intervention));
1473 f_iu2iuh(tx);
1474
1475 tx := valueof(ts_RANAP_IuReleaseComplete());
1476 f_iuh2iu(tx);
1477}
1478
1479testcase TC_rab_assign_mgcp_to() runs on test_CT {
1480 var ConnHdlr vc_conn;
Pau Espin Pedrol83a49612022-09-12 21:11:05 +02001481 g_num_hnbs := 1;
Daniel Willmann37c877f2022-02-22 16:47:06 +01001482 f_init();
Daniel Willmann37c877f2022-02-22 16:47:06 +01001483
1484 vc_conn := f_start_handler_with_pars(refers(f_tc_rab_assign_mgcp_to), t_pars(6));
1485 vc_conn.done;
Neels Hofmeyr3a9140e2023-06-23 04:50:39 +02001486
1487 f_shutdown_helper();
Daniel Willmann37c877f2022-02-22 16:47:06 +01001488}
1489
Daniel Willmann19b8d902022-01-05 09:12:34 +01001490/* Create an Iuh connection; send InitialUE; transceive data both directions */
1491friend function f_tc_ranap_bidir(charstring id, TestHdlrParams pars) runs on ConnHdlr {
1492 f_init_handler(pars);
1493
1494 /* HNB -> MSC: InitialUE */
1495 f_iuh2iu_connect(f_build_initial_ue(g_pars));
1496
1497 /* MSC <- HNB: DirectTransfer */
1498 f_iu2iuh(ts_RANAP_DirectTransfer(f_rnd_octstring(10)));
1499 /* MSC -> HNB: DirectTransfer */
1500 f_iuh2iu(ts_RANAP_DirectTransfer(f_rnd_octstring(10)));
1501
1502 /* HNB <- MSC: CommonID */
1503 f_iu2iuh(ts_RANAP_CommonId(hex2oct(pars.imsi)));
1504}
1505testcase TC_ranap_cs_bidir() runs on test_CT {
1506 var ConnHdlr vc_conn;
Pau Espin Pedrol83a49612022-09-12 21:11:05 +02001507 g_num_hnbs := 1;
Daniel Willmann19b8d902022-01-05 09:12:34 +01001508 f_init();
Daniel Willmann19b8d902022-01-05 09:12:34 +01001509
1510 vc_conn := f_start_handler_with_pars(refers(f_tc_ranap_bidir), t_pars(3));
1511 vc_conn.done;
Neels Hofmeyr3a9140e2023-06-23 04:50:39 +02001512
1513 f_shutdown_helper();
Daniel Willmann19b8d902022-01-05 09:12:34 +01001514}
1515testcase TC_ranap_ps_bidir() runs on test_CT {
1516 var ConnHdlr vc_conn;
Pau Espin Pedrol83a49612022-09-12 21:11:05 +02001517 g_num_hnbs := 1;
Daniel Willmann19b8d902022-01-05 09:12:34 +01001518 f_init();
Daniel Willmann19b8d902022-01-05 09:12:34 +01001519
1520 vc_conn := f_start_handler_with_pars(refers(f_tc_ranap_bidir), t_pars(4, true));
1521 vc_conn.done;
Neels Hofmeyr3a9140e2023-06-23 04:50:39 +02001522
1523 f_shutdown_helper();
Daniel Willmann19b8d902022-01-05 09:12:34 +01001524}
1525
1526
1527private function f_tc_ranap_mo_disconnect(charstring id, TestHdlrParams pars) runs on ConnHdlr {
1528 f_init_handler(pars);
1529
1530 /* HNB -> MSC: InitialUE */
1531 f_iuh2iu_connect(f_build_initial_ue(g_pars));
1532
1533 /* MSC <- HNB: DirectTransfer */
1534 f_iu2iuh(ts_RANAP_DirectTransfer(f_rnd_octstring(10)));
1535 /* MSC -> HNB: DirectTransfer */
1536 f_iuh2iu(ts_RANAP_DirectTransfer(f_rnd_octstring(10)));
1537
1538 /* MSC <- HNB: RUA disconnect */
1539 f_iuh2iu_disconnect(ts_RANAP_IuReleaseComplete, RUA_IEs.Cause:{misc:=processing_overload});
1540}
1541testcase TC_ranap_cs_mo_disconnect() runs on test_CT {
1542 var ConnHdlr vc_conn;
Pau Espin Pedrol83a49612022-09-12 21:11:05 +02001543 g_num_hnbs := 1;
Daniel Willmann19b8d902022-01-05 09:12:34 +01001544 f_init();
Daniel Willmann19b8d902022-01-05 09:12:34 +01001545
1546 vc_conn := f_start_handler_with_pars(refers(f_tc_ranap_mo_disconnect), t_pars(5));
1547 vc_conn.done;
Neels Hofmeyr3a9140e2023-06-23 04:50:39 +02001548
1549 f_shutdown_helper();
Daniel Willmann19b8d902022-01-05 09:12:34 +01001550}
1551testcase TC_ranap_ps_mo_disconnect() runs on test_CT {
1552 var ConnHdlr vc_conn;
Pau Espin Pedrol83a49612022-09-12 21:11:05 +02001553 g_num_hnbs := 1;
Daniel Willmann19b8d902022-01-05 09:12:34 +01001554 f_init();
Daniel Willmann19b8d902022-01-05 09:12:34 +01001555
1556 vc_conn := f_start_handler_with_pars(refers(f_tc_ranap_mo_disconnect), t_pars(6));
1557 vc_conn.done;
Neels Hofmeyr3a9140e2023-06-23 04:50:39 +02001558
1559 f_shutdown_helper();
Daniel Willmann19b8d902022-01-05 09:12:34 +01001560}
1561
Neels Hofmeyra56e8fd2022-05-08 01:16:55 +02001562type record FTeid {
1563 HostName addr,
1564 OCT4 teid
1565}
1566
1567type record FTeids {
1568 FTeid local,
1569 FTeid remote
1570}
Daniel Willmann19b8d902022-01-05 09:12:34 +01001571
1572
Neels Hofmeyra56e8fd2022-05-08 01:16:55 +02001573/* 'local' and 'remote' refer to the GTP information from the UPF's point of view:
1574 * HNB UPF CN
1575 * access.remote <---> access.local | core.local <---> core.remote
1576 */
1577type record GtpParameters {
1578 FTeids core,
1579 FTeids access
1580}
1581
1582/* HNB UPF CN
1583 * access.remote <---> access.local | core.local <---> core.remote
1584 * 127.0.0.4 127.0.0.3 127.0.0.2 127.0.0.1
1585 * 0x44004400 0x30303030 0x22002200 0x10101010
1586 */
1587template GtpParameters t_GtpParameters := {
1588 core := {
1589 local := {
1590 addr := "127.0.0.2",
1591 teid := '22002200'O
1592 },
1593 remote := {
1594 addr := "127.0.0.1",
1595 teid := '10101010'O
1596 }
1597 },
1598 access := {
1599 local := {
1600 addr := "127.0.0.3",
1601 teid := '30303030'O
1602 },
1603 remote := {
1604 addr := "127.0.0.4",
1605 teid := '44004400'O
1606 }
1607 }
1608}
1609
Neels Hofmeyr65499282023-04-25 02:31:51 +02001610private function f_pfcp_expect(template (present) PDU_PFCP exp_rx, float wait_time := 5.0) runs on ConnHdlr return PDU_PFCP
Neels Hofmeyr6bbfe052023-03-09 02:51:46 +01001611{
1612 var PDU_PFCP rx;
Neels Hofmeyr65499282023-04-25 02:31:51 +02001613 timer T := wait_time;
Neels Hofmeyr6bbfe052023-03-09 02:51:46 +01001614 T.start;
1615 alt {
1616 [] PFCP.receive(exp_rx) -> value rx {
1617 setverdict(pass);
1618 }
1619 [] PFCP.receive(PDU_PFCP:?) {
1620 setverdict(fail, "Got an unexpected PFCP message, was waiting for ", exp_rx);
1621 mtc.stop;
1622 }
1623 [] T.timeout {
1624 setverdict(fail, "Timeout waiting for PFCP ", exp_rx);
1625 mtc.stop;
1626 }
1627 }
1628 T.stop;
1629 return rx;
1630}
1631
Neels Hofmeyrbacb74f2022-08-29 16:24:12 +02001632friend function f_tc_ps_rab_assignment_with_pfcp(charstring id, TestHdlrParams pars) runs on ConnHdlr {
Neels Hofmeyra56e8fd2022-05-08 01:16:55 +02001633 var RANAP_PDU tx;
1634 var RANAP_PDU rx;
Neels Hofmeyra56e8fd2022-05-08 01:16:55 +02001635
1636 f_init_handler(pars);
1637
1638 f_pfcp_register();
1639
1640 var PDU_PFCP m;
1641 var Node_ID upf_node_id := valueof(ts_PFCP_Node_ID_fqdn("\07osmocom\03org"));
1642
Neels Hofmeyr65499282023-04-25 02:31:51 +02001643 m := f_pfcp_expect(tr_PFCP_Assoc_Setup_Req(), wait_time := 15.0);
Neels Hofmeyra56e8fd2022-05-08 01:16:55 +02001644 PFCP.send(ts_PFCP_Assoc_Setup_Resp(m.sequence_number, upf_node_id,
1645 ts_PFCP_Cause(REQUEST_ACCEPTED), 1234));
1646
1647 tx := f_build_initial_ue(g_pars);
1648 f_iuh2iu_connect(tx);
1649
1650 var GtpParameters gtp_pars := valueof(t_GtpParameters);
1651 var template RAB_SetupOrModifyList rab_sml;
1652
1653 /* Send RAB Assignment Request */
1654 rab_sml := ts_RAB_SML_ps(t_RAB_id(23), f_ts_RAB_TLA(gtp_pars.core.remote.addr), gtp_pars.core.remote.teid);
1655 tx := valueof(ts_RANAP_RabAssReq(rab_sml));
1656 BSSAP.send(tx);
1657
1658 /* Expect PFCP Session Establishment Request. */
Neels Hofmeyr6bbfe052023-03-09 02:51:46 +01001659 m := f_pfcp_expect(tr_PFCP_Session_Est_Req());
Neels Hofmeyra56e8fd2022-05-08 01:16:55 +02001660 var F_SEID hnbgw_f_seid := m.message_body.pfcp_session_establishment_request.CP_F_SEID;
1661 var PFCP_Session_Establishment_Request serq := m.message_body.pfcp_session_establishment_request;
1662
1663 /* Acting as UPF, invent a new PFCP SEID to send to HNBGW. Respond to the Session Establishment.
1664 * The PFCP response must have the same sequence_number as the request. */
Neels Hofmeyr1e311462023-01-11 01:19:12 +01001665 var F_SEID up_f_seid := valueof(ts_PFCP_F_SEID_ipv4(f_inet_addr("127.0.0.1"), '1111111111111111'O));
Neels Hofmeyra56e8fd2022-05-08 01:16:55 +02001666 var template PDU_PFCP r := ts_PFCP_Session_Est_Resp(m.sequence_number, upf_node_id, hnbgw_f_seid.seid);
1667 r.message_body.pfcp_session_establishment_response := {
1668 offending_ie := omit,
1669 UP_F_SEID := up_f_seid,
1670 created_PDR_list := {
1671 ts_PFCP_Created_PDR(pdr_id := serq.create_PDR_list[0].grouped_ie.pdr_id,
1672 local_F_TEID := ts_PFCP_F_TEID_ipv4(gtp_pars.core.local.teid,
Neels Hofmeyr1e311462023-01-11 01:19:12 +01001673 f_inet_addr(gtp_pars.core.local.addr))),
Neels Hofmeyra56e8fd2022-05-08 01:16:55 +02001674 ts_PFCP_Created_PDR(pdr_id := serq.create_PDR_list[1].grouped_ie.pdr_id,
1675 local_F_TEID := ts_PFCP_F_TEID_ipv4(gtp_pars.access.local.teid,
Neels Hofmeyr1e311462023-01-11 01:19:12 +01001676 f_inet_addr(gtp_pars.access.local.addr)))
Neels Hofmeyra56e8fd2022-05-08 01:16:55 +02001677 },
1678 load_control_information := omit,
1679 overload_control_information := omit,
1680 node_list := omit,
1681 failed_rule_id := omit,
1682 created_traffic_endpoint_list := omit
1683 };
1684 PFCP.send(r);
1685
1686 /* Expect on Iuh: RAB Assignment Request with IP/port from PFCP Session Est Resp */
1687 rab_sml := ts_RAB_SML_ps(t_RAB_id(23), f_ts_RAB_TLA(gtp_pars.access.local.addr),
1688 gtp_pars.access.local.teid);
1689 rx := valueof(ts_RANAP_RabAssReq(rab_sml));
Neels Hofmeyr735b6562023-03-09 02:51:28 +01001690 f_rua_expect(rx);
Neels Hofmeyra56e8fd2022-05-08 01:16:55 +02001691
1692 /* Send back RAB Assignment Response via Iuh */
1693 var template RAB_SetupOrModifiedList rab_smdl;
1694 rab_smdl := ts_RAB_SMdL_ps(t_RAB_id(23), f_ts_RAB_TLA(gtp_pars.access.remote.addr),
1695 gtp_pars.access.remote.teid);
1696 tx := valueof(ts_RANAP_RabAssResp(rab_smdl));
1697 RUA.send(tx);
Neels Hofmeyra56e8fd2022-05-08 01:16:55 +02001698
Neels Hofmeyr6bbfe052023-03-09 02:51:46 +01001699 m := f_pfcp_expect(tr_PFCP_Session_Mod_Req(up_f_seid.seid));
Neels Hofmeyra56e8fd2022-05-08 01:16:55 +02001700 r := ts_PFCP_Session_Mod_Resp(m.sequence_number, hnbgw_f_seid.seid);
1701 PFCP.send(r);
1702
1703 rab_smdl := ts_RAB_SMdL_ps(t_RAB_id(23), f_ts_RAB_TLA(gtp_pars.core.local.addr), gtp_pars.core.local.teid);
Neels Hofmeyrdc416c92023-03-09 02:47:50 +01001704 f_bssap_expect(tr_RANAP_RabAssResp(rab_smdl));
Neels Hofmeyra56e8fd2022-05-08 01:16:55 +02001705
1706 f_sleep(2.0);
1707 tx := valueof(ts_RANAP_IuReleaseCommand(ts_RanapCause_om_intervention));
1708 f_iu2iuh(tx);
1709
1710 tx := valueof(ts_RANAP_IuReleaseComplete());
1711 f_iuh2iu(tx);
1712
Neels Hofmeyr6bbfe052023-03-09 02:51:46 +01001713 m := f_pfcp_expect(tr_PFCP_Session_Del_Req(up_f_seid.seid));
Neels Hofmeyra56e8fd2022-05-08 01:16:55 +02001714 PFCP.send(ts_PFCP_Session_Del_Resp(m.sequence_number, hnbgw_f_seid.seid));
1715
1716 f_sleep(2.0);
1717}
1718
Neels Hofmeyrbacb74f2022-08-29 16:24:12 +02001719testcase TC_ps_rab_assignment_with_pfcp() runs on test_CT {
Neels Hofmeyra56e8fd2022-05-08 01:16:55 +02001720 var ConnHdlr vc_conn;
Pau Espin Pedrol83a49612022-09-12 21:11:05 +02001721 g_num_hnbs := 1;
Neels Hofmeyra56e8fd2022-05-08 01:16:55 +02001722 f_init();
Neels Hofmeyra56e8fd2022-05-08 01:16:55 +02001723 f_sleep(1.0);
1724
Neels Hofmeyrbacb74f2022-08-29 16:24:12 +02001725 vc_conn := f_start_handler_with_pars(refers(f_tc_ps_rab_assignment_with_pfcp), t_pars(7, ps_domain := true));
1726 vc_conn.done;
Neels Hofmeyr3a9140e2023-06-23 04:50:39 +02001727
1728 f_shutdown_helper();
Neels Hofmeyrbacb74f2022-08-29 16:24:12 +02001729}
1730
1731altstep as_disallow_pfcp() runs on ConnHdlr {
1732 [] PFCP.receive(PDU_PFCP:?) {
1733 setverdict(fail, "Received PFCP message, but no PFCP communication expected");
1734 mtc.stop;
1735 }
1736}
1737
1738friend function f_tc_ps_rab_assignment_without_pfcp(charstring id, TestHdlrParams pars) runs on ConnHdlr {
1739 var RANAP_PDU tx;
1740 var RANAP_PDU rx;
1741 timer T := 5.0;
1742
1743 f_init_handler(pars);
1744
1745 f_pfcp_register();
1746 activate(as_disallow_pfcp());
1747
1748 tx := f_build_initial_ue(g_pars);
1749 f_iuh2iu_connect(tx);
1750
1751 var GtpParameters gtp_pars := valueof(t_GtpParameters);
1752 var template RAB_SetupOrModifyList rab_sml;
1753
1754 /* Send RAB Assignment Request */
1755 rab_sml := ts_RAB_SML_ps(t_RAB_id(23), f_ts_RAB_TLA(gtp_pars.core.remote.addr), gtp_pars.core.remote.teid);
1756 tx := valueof(ts_RANAP_RabAssReq(rab_sml));
1757 BSSAP.send(tx);
1758
1759 /* Expect on Iuh: unmodified RAB Assignment Request */
1760 rx := valueof(ts_RANAP_RabAssReq(rab_sml));
Neels Hofmeyr735b6562023-03-09 02:51:28 +01001761 f_rua_expect(rx);
Neels Hofmeyrbacb74f2022-08-29 16:24:12 +02001762
1763 /* Send back RAB Assignment Response via Iuh */
1764 var template RAB_SetupOrModifiedList rab_smdl;
1765 rab_smdl := ts_RAB_SMdL_ps(t_RAB_id(23), f_ts_RAB_TLA(gtp_pars.access.remote.addr),
1766 gtp_pars.access.remote.teid);
1767 tx := valueof(ts_RANAP_RabAssResp(rab_smdl));
1768 RUA.send(tx);
1769
1770 /* Expect on IuPS: unmodified RAB Assignment Response */
Neels Hofmeyrdc416c92023-03-09 02:47:50 +01001771 f_bssap_expect(tr_RANAP_RabAssResp(rab_smdl));
Neels Hofmeyrbacb74f2022-08-29 16:24:12 +02001772
1773 f_sleep(2.0);
1774 tx := valueof(ts_RANAP_IuReleaseCommand(ts_RanapCause_om_intervention));
1775 f_iu2iuh(tx);
1776
1777 tx := valueof(ts_RANAP_IuReleaseComplete());
1778 f_iuh2iu(tx);
1779
1780 f_sleep(2.0);
1781}
1782
1783testcase TC_ps_rab_assignment_without_pfcp() runs on test_CT {
1784 var ConnHdlr vc_conn;
1785 f_init();
Neels Hofmeyrbacb74f2022-08-29 16:24:12 +02001786 f_sleep(1.0);
1787
1788 vc_conn := f_start_handler_with_pars(refers(f_tc_ps_rab_assignment_without_pfcp), t_pars(7, ps_domain := true));
Neels Hofmeyra56e8fd2022-05-08 01:16:55 +02001789 vc_conn.done;
Neels Hofmeyr3a9140e2023-06-23 04:50:39 +02001790
1791 f_shutdown_helper();
Neels Hofmeyra56e8fd2022-05-08 01:16:55 +02001792}
Daniel Willmann19b8d902022-01-05 09:12:34 +01001793
Neels Hofmeyr7d0e6802023-04-20 20:43:55 +02001794/* Default list of counters for a 'cn' entity to test the cnpool feature. */
1795const CounterNameVals counternames_cnpool := {
1796 { "cnpool:subscr:new", 0 },
1797 { "cnpool:subscr:known", 0 },
1798 { "cnpool:subscr:reattach", 0 },
1799 { "cnpool:subscr:attach_lost", 0 },
1800 { "cnpool:subscr:paged", 0 }
1801};
1802private function f_ctrs_cn_init(boolean ps_domain, integer cn_count := 0,
1803 CounterNameVals counternames := counternames_cnpool) runs on test_CT {
1804 if (ps_domain) {
1805 g_ctr_cn_node_name := "sgsn";
1806 if (cn_count == 0) {
1807 cn_count := NUM_SGSN;
1808 }
1809 } else {
1810 g_ctr_cn_node_name := "msc";
1811 if (cn_count == 0) {
1812 cn_count := NUM_MSC;
1813 }
1814 }
1815 g_ctr_cn := f_counter_name_vals_get_n(IPA_CTRL, g_ctr_cn_node_name, cn_count, counternames);
1816 log("initial " & g_ctr_cn_node_name & " rate counters: ", g_ctr_cn);
1817}
1818
1819/* f_ctrs_cn_init();
1820 * f_do_thing(on_cn := 0);
1821 * f_do_thing(on_cn := 0);
1822 * f_do_other(on_cn := 1);
1823 * f_ctrs_cn_add(0, "thing", 2);
1824 * f_ctrs_cn_add(1, "other");
1825 * f_ctrs_cn_verify();
1826 */
1827private function f_ctrs_cn_verify() runs on test_CT {
1828 log("verifying", g_ctr_cn_node_name, " rate counters: ", g_ctr_cn);
1829 f_counter_name_vals_expect_n(IPA_CTRL, g_ctr_cn_node_name, g_ctr_cn);
1830}
1831
1832/* convenience: f_ctrs_cn_add() and f_ctrs_cn_verify() in one call.
1833 * f_ctrs_cn_init();
1834 * f_do_thing(on_cn := 0);
1835 * f_do_thing(on_cn := 0);
1836 * f_do_thing(on_cn := 0);
1837 * f_ctrs_cn_expect(0, "thing", 3);
1838 */
1839private function f_ctrs_cn_expect(integer cn_nr, charstring countername, integer val := 1) runs on test_CT {
1840 f_ctrs_cn_add(cn_nr, countername, val);
1841 f_ctrs_cn_verify();
1842}
1843
1844private function f_ctrs_cn_add(integer cn_nr, charstring countername, integer val := 1) runs on test_CT {
1845 f_counter_name_vals_list_add(g_ctr_cn, cn_nr, countername, val);
1846}
1847
1848private function f_perform_compl_l3(octetstring nas, boolean do_clear := true, boolean expect_iu_l3 := true)
1849runs on ConnHdlr {
1850 timer T := 10.0;
1851
1852 /* create an expect on the Iu side for the random NAS portion */
1853 if (g_pars.expect_separate_sccp_cr) {
1854 f_ran_register_sccp_cr_without_payload();
1855 } else {
1856 f_ran_register_exp(nas);
1857 }
1858
1859 /* send Connect via Iuh (creating a RUA connection) */
1860 var RANAP_PDU tx := f_build_initial_ue_with_nas(g_pars, nas);
1861 RUA.send(RUA_Conn_Req:{g_pars.ps_domain, tx});
1862
1863 if (expect_iu_l3) {
1864 /* Expect same message to arrive at CN */
1865 f_bssap_expect(tx);
1866 }
1867}
1868
1869private function f_tc_cnpool_compl_l3(charstring id, TestHdlrParams pars) runs on ConnHdlr {
1870 f_init_handler(pars);
1871 f_perform_compl_l3(g_pars.nas_pdu);
1872}
1873
1874private function f_TC_cnpool_compl_l3(boolean ps_domain, octetstring nas_pdu, integer cn_nr,
1875 template (omit) charstring inc_countername := omit) runs on test_CT {
1876 var ConnHdlr vc_conn;
1877 var template (value) TestHdlrParams pars := t_pars(0, ps_domain := ps_domain, cn_nr := cn_nr);
1878 pars.nas_pdu := nas_pdu;
1879 log("XXX ", pars);
1880 vc_conn := f_start_handler_with_pars(refers(f_tc_cnpool_compl_l3), pars);
1881 vc_conn.done;
1882
1883 if (not istemplatekind(inc_countername, "omit")) {
1884 f_ctrs_cn_expect(cn_nr, valueof(inc_countername));
1885 }
1886}
1887
1888function f_TC_cnpool_compl_l3_list(boolean ps_domain, ro_octetstring compl3, Osmocom_Types.ro_integer cn_nrs,
1889 charstring inc_countername) runs on test_CT {
1890 var integer n := lengthof(compl3);
1891 if (n < lengthof(cn_nrs)) {
1892 n := lengthof(cn_nrs);
1893 }
1894 for (var integer i := 0; i < n; i := i + 1) {
1895 var integer cn_nr := cn_nrs[i mod lengthof(cn_nrs)];
1896 f_TC_cnpool_compl_l3(ps_domain, compl3[i mod lengthof(compl3)], cn_nr, inc_countername);
1897 }
1898}
1899
1900type enumerated Compl3Type {
1901 /* CS */
1902 LU,
1903 CMSERV,
1904 PAGRESP,
1905 IMSIDETACH,
1906
1907 /* PS */
1908 ATTACHREQ,
1909 RAUREQ,
1910 DETREQ
1911};
1912
1913private function f_gen_one_compl_l3(Compl3Type compl3type, template (value) MobileIdentityLV mi,
1914 integer ps_nri := -1
1915 ) return octetstring
1916{
1917 /* CS */
1918 if (compl3type == LU) {
1919 return enc_PDU_ML3_MS_NW(valueof(ts_LU_REQ(LU_Type_IMSI_Attach, valueof(mi), '00F110'O)));
1920 }
1921 if (compl3type == CMSERV) {
1922 return enc_PDU_ML3_MS_NW(valueof(ts_CM_SERV_REQ(CM_TYPE_MO_CALL, valueof(mi))));
1923 }
1924 if (compl3type == PAGRESP) {
1925 return enc_PDU_ML3_MS_NW(valueof(ts_PAG_RESP(valueof(mi))));
1926 }
1927 if (compl3type == IMSIDETACH) {
1928 return enc_PDU_ML3_MS_NW(valueof(ts_ML3_MO_MM_IMSI_DET_Ind(valueof(mi))));
1929 }
1930
1931 /* PS */
1932 var template (omit) NetworkResourceIdentifierContainerTLV nri := omit;
1933 if (ps_nri >= 0) {
1934 nri := valueof(ts_GMM_NRI(ps_nri));
1935 }
1936
1937 if (compl3type == ATTACHREQ) {
1938 return enc_PDU_L3_MS_SGSN(valueof(ts_GMM_ATTACH_REQ(valueof(mi), f_RAI('001'H, '01'H, '2a2a'O, '17'O),
1939 nri := nri)));
1940 }
1941 if (compl3type == RAUREQ) {
1942 return enc_PDU_L3_MS_SGSN(valueof(ts_GMM_RAU_REQ(valueof(mi), GPRS_UPD_T_PERIODIC,
1943 f_RAI('001'H, '01'H, '2a2a'O, '17'O),
1944 nri := nri)));
1945 }
1946 if (compl3type == DETREQ) {
1947 return enc_PDU_L3_MS_SGSN(valueof(ts_GMM_DET_REQ_MO_mi(c_GMM_DTT_MO_GPRS, power_off := false,
1948 p_tmsi := valueof(ts_MI_TLV(mi.mobileIdentityV)))));
1949 }
1950
1951 setverdict(fail, "unknown complete layer 3 type");
1952 mtc.stop;
1953}
1954
1955type record of Compl3Type ro_Compl3Type;
1956type record of MobileIdentityLV ro_MobileIdentityLV;
1957type record of octetstring ro_octetstring;
1958
1959/* Generate a list of n Complete Layer 3 NAS PDUs,
1960 * rotating through the message kinds listed in 'types' and the mobile identities in mis.
1961 */
1962private function f_gen_compl_l3(ro_Compl3Type types, ro_MobileIdentityLV mis, integer n) return ro_octetstring
1963{
1964 var ro_octetstring res := {};
1965 for (var integer i := 0; i < n; i := i + 1) {
1966 var integer ti := i mod lengthof(types);
1967 var integer mi := i mod lengthof(mis);
1968 res[i] := f_gen_one_compl_l3(types[ti], mis[mi]);
1969 }
1970 return res;
1971}
1972
1973private function f_gen_mi_imsi(integer n) return MobileIdentityLV
1974{
1975 return valueof(ts_MI_IMSI_LV(f_gen_imsi(n)));
1976}
1977
1978private function f_gen_mi_imsis(integer n) return ro_MobileIdentityLV
1979{
1980 var ro_MobileIdentityLV mis := {};
1981 for (var integer i := 0; i < n; i := i + 1) {
1982 mis[i] := f_gen_mi_imsi(n);
1983 }
1984 return mis;
1985}
1986
1987function f_vty_set_roundrobin_next(TELNETasp_PT VTY, boolean ps_domain, integer cn_nr)
1988{
1989 var charstring msc_sgsn;
1990 if (ps_domain) {
1991 msc_sgsn := "sgsn";
1992 } else {
1993 msc_sgsn := "msc";
1994 }
1995 f_vty_transceive(VTY, "cnpool roundrobin next " & msc_sgsn & " " & int2str(cn_nr));
1996}
1997
1998private function f_gen_compl3_by_domain(boolean ps_domain, integer n, template (omit) ro_MobileIdentityLV mis := omit) return ro_octetstring{
1999 var ro_Compl3Type types;
2000 if (ps_domain) {
2001 types := { ATTACHREQ, RAUREQ, DETREQ };
2002 } else {
2003 types := { LU, CMSERV, PAGRESP, IMSIDETACH };
2004 }
2005 if (istemplatekind(mis, "omit")) {
2006 mis := f_gen_mi_imsis(n);
2007 }
2008 return f_gen_compl_l3(types, valueof(mis), n);
2009}
2010
2011/* Various Complete Layer 3 by IMSI all end up with the first MSC, because the other MSCs are not connected. */
2012testcase TC_mscpool_L3Compl_on_1_cnlink() runs on test_CT {
2013 f_TC_cnpool_L3Compl_on_1_cnlink(ps_domain := false);
2014}
2015testcase TC_sgsnpool_L3Compl_on_1_cnlink() runs on test_CT {
2016 f_TC_cnpool_L3Compl_on_1_cnlink(ps_domain := true);
2017}
2018function f_TC_cnpool_L3Compl_on_1_cnlink(boolean ps_domain) runs on test_CT {
2019
2020 f_init();
2021
2022 f_ctrs_cn_init(ps_domain := ps_domain);
2023
2024 var ro_octetstring compl3 := f_gen_compl3_by_domain(ps_domain, 4);
2025 f_TC_cnpool_compl_l3_list(ps_domain, compl3, {0, 0, 0, 0}, "cnpool:subscr:new");
2026
2027 f_shutdown_helper();
2028}
2029
2030/* Three Layer 3 Complete by IMSI are round-robin'ed across two connected MSCs */
2031testcase TC_mscpool_L3Complete_by_imsi_round_robin() runs on test_CT {
2032 f_TC_cnpool_L3Complete_by_imsi_round_robin(ps_domain := false);
2033}
2034testcase TC_sgsnpool_L3Complete_no_nri_round_robin() runs on test_CT {
2035 f_TC_cnpool_L3Complete_by_imsi_round_robin(ps_domain := true);
2036}
2037function f_TC_cnpool_L3Complete_by_imsi_round_robin(boolean ps_domain) runs on test_CT {
2038
2039 f_init(nr_msc := 2, nr_sgsn := 2);
2040 f_sleep(1.0);
2041
2042 /* Control which MSC gets chosen next by the round-robin, otherwise
2043 * would be randomly affected by which other tests ran before this. */
2044 f_vty_set_roundrobin_next(HNBGWVTY, ps_domain, 0);
2045
2046 f_ctrs_cn_init(ps_domain := ps_domain);
2047
2048 var ro_octetstring compl3 := f_gen_compl3_by_domain(ps_domain, 3);
2049
2050 f_TC_cnpool_compl_l3_list(ps_domain, compl3,
2051 /* Third Complete Layer 3 wraps back to msc 0 */
2052 cn_nrs := {0, 1, 0},
2053 inc_countername := "cnpool:subscr:new");
2054
2055 f_shutdown_helper();
2056}
2057
2058/* Three LU by TMSI are round-robin'ed across two connected MSCs, because they contain a NULL-NRI (0, 1)
2059 * (configured in osmo-hnbgw.cfg). */
2060testcase TC_mscpool_LU_by_tmsi_null_nri_0_round_robin() runs on test_CT {
2061 f_TC_cnpool_LU_by_tmsi_null_nri_N_round_robin(ps_domain := false, nri_val := 0);
2062}
2063/* For NRI == 1, one of the MSC also has the NULL-NRI as part of its owned NRIs, but the NULL-NRI setting is stronger
2064 * than that. */
2065testcase TC_mscpool_LU_by_tmsi_null_nri_1_round_robin() runs on test_CT {
2066 f_TC_cnpool_LU_by_tmsi_null_nri_N_round_robin(ps_domain := false, nri_val := 1);
2067}
2068function f_TC_cnpool_LU_by_tmsi_null_nri_N_round_robin(boolean ps_domain, integer nri_val) runs on test_CT {
2069
2070 f_init(nr_msc := 2, nr_sgsn := 2);
2071 f_sleep(1.0);
2072
2073 /* Control which MSC gets chosen next by the round-robin, otherwise
2074 * would be randomly affected by which other tests ran before this. */
2075 f_vty_set_roundrobin_next(HNBGWVTY, ps_domain, 0);
2076
2077 f_ctrs_cn_init(ps_domain := ps_domain);
2078
2079 var ro_MobileIdentityLV mis := { valueof(ts_MI_TMSI_NRI_LV(nri_val)) };
2080 var ro_octetstring compl3;
2081 if (ps_domain) {
2082 compl3 := {
2083 f_gen_one_compl_l3(ATTACHREQ, mis[0], nri_val)
2084 };
2085 } else {
2086 compl3 := f_gen_compl_l3({LU}, mis, 1);
2087 }
2088
2089 f_TC_cnpool_compl_l3_list(ps_domain, compl3,
2090 /* The third Complete Layer 3 wraps back to msc 0 */
2091 {0, 1, 0},
2092 "cnpool:subscr:reattach");
2093 f_shutdown_helper();
2094}
2095
2096/* Three Layer 3 Complete by TMSI are round-robin'ed across two connected MSCs, because they contain an NRI not
2097 * assigned to any MSC (configured in osmo-hnbgw.cfg). */
2098testcase TC_mscpool_L3Complete_by_tmsi_unassigned_nri_round_robin() runs on test_CT {
2099 f_TC_cnpool_L3Complete_by_tmsi_unassigned_nri_round_robin(ps_domain := false);
2100}
2101function f_TC_cnpool_L3Complete_by_tmsi_unassigned_nri_round_robin(boolean ps_domain) runs on test_CT {
2102
2103 f_init(nr_msc := 2, nr_sgsn := 2);
2104 f_sleep(1.0);
2105
2106 /* Control which MSC gets chosen next by the round-robin, otherwise
2107 * would be randomly affected by which other tests ran before this. */
2108 f_vty_set_roundrobin_next(HNBGWVTY, ps_domain, 0);
2109
2110 f_ctrs_cn_init(ps_domain := ps_domain);
2111
2112 /* 3 NRIs that are not assigned to any MSC */
2113 var ro_MobileIdentityLV mis := {
2114 valueof(ts_MI_TMSI_NRI_LV(1000)),
2115 valueof(ts_MI_TMSI_NRI_LV(768)),
2116 valueof(ts_MI_TMSI_NRI_LV(819))
2117 };
2118
2119 var ro_octetstring compl3 := f_gen_compl3_by_domain(ps_domain, 3, mis);
2120 f_TC_cnpool_compl_l3_list(ps_domain, compl3, { 0, 1, 0 }, "cnpool:subscr:new");
2121
2122 f_shutdown_helper();
2123}
2124
2125/* Three Layer 3 Complete by TMSI are round-robin'ed across two connected MSCs, because they contain an NRI
2126 * assigned to a CN link that is currently not connected (configured in osmo-hnbgw.cfg). */
2127testcase TC_mscpool_L3Complete_by_tmsi_valid_nri_msc_not_connected_round_robin() runs on test_CT {
2128 f_TC_cnpool_L3Complete_by_tmsi_valid_nri_msc_not_connected_round_robin(ps_domain := false);
2129}
2130function f_TC_cnpool_L3Complete_by_tmsi_valid_nri_msc_not_connected_round_robin(boolean ps_domain) runs on test_CT {
2131
2132 f_init(nr_msc := 2, nr_sgsn := 2);
2133 f_sleep(1.0);
2134
2135 /* Control which MSC gets chosen next by the round-robin, otherwise
2136 * would be randomly affected by which other tests ran before this. */
2137 f_vty_set_roundrobin_next(HNBGWVTY, ps_domain, 0);
2138
2139 f_ctrs_cn_init(ps_domain := ps_domain);
2140
2141 /* 3 NRIs that are assigned to an unconnected MSC */
2142 var ro_MobileIdentityLV mis := {
2143 valueof(ts_MI_TMSI_NRI_LV(512)),
2144 valueof(ts_MI_TMSI_NRI_LV(767)),
2145 valueof(ts_MI_TMSI_NRI_LV(750))
2146 };
2147
2148 var ro_octetstring compl3 := f_gen_compl3_by_domain(ps_domain, 3, mis);
2149
2150 f_TC_cnpool_compl_l3(ps_domain, compl3[0], cn_nr := 0);
2151 f_ctrs_cn_add(2, "cnpool:subscr:attach_lost");
2152 f_ctrs_cn_add(0, "cnpool:subscr:new");
2153 f_ctrs_cn_verify();
2154
2155 f_TC_cnpool_compl_l3(ps_domain, compl3[1], cn_nr := 1);
2156 f_ctrs_cn_add(2, "cnpool:subscr:attach_lost");
2157 f_ctrs_cn_add(1, "cnpool:subscr:new");
2158 f_ctrs_cn_verify();
2159
2160 f_TC_cnpool_compl_l3(ps_domain, compl3[2], cn_nr := 0);
2161 f_ctrs_cn_add(2, "cnpool:subscr:attach_lost");
2162 f_ctrs_cn_add(0, "cnpool:subscr:new");
2163 f_ctrs_cn_verify();
2164
2165 f_shutdown_helper();
2166}
2167
2168/* Three Layer 3 Complete by TMSI with valid NRI for the second MSC are all directed to the second MSC (configured in
2169 * osmo-hnbgw.cfg). */
2170testcase TC_mscpool_L3Complete_by_tmsi_valid_nri_1() runs on test_CT {
2171 f_TC_cnpool_L3Complete_valid_nri_1(ps_domain := false);
2172}
2173testcase TC_sgsnpool_L3Complete_valid_nri_1() runs on test_CT {
2174 f_TC_cnpool_L3Complete_valid_nri_1(ps_domain := true);
2175}
2176function f_TC_cnpool_L3Complete_valid_nri_1(boolean ps_domain) runs on test_CT {
2177
2178 f_init(nr_msc := 2, nr_sgsn := 2);
2179 f_sleep(1.0);
2180
2181 /* All TMSIs in this test point at the second MSC, set the round robin to point at the first MSC to make sure
2182 * this is not using round-robin. */
2183 f_vty_set_roundrobin_next(HNBGWVTY, ps_domain, 0);
2184
2185 f_ctrs_cn_init(ps_domain := ps_domain);
2186
2187 var ro_octetstring compl3;
2188
2189 /* 3 NRIs of the second MSC's range (256-511) */
2190 var ro_MobileIdentityLV mis := {
2191 valueof(ts_MI_TMSI_NRI_LV(256)),
2192 valueof(ts_MI_TMSI_NRI_LV(260)),
2193 valueof(ts_MI_TMSI_NRI_LV(511))
2194 };
2195 if (ps_domain) {
2196 compl3 := {
2197 f_gen_one_compl_l3(RAUREQ, mis[0], 256),
2198 f_gen_one_compl_l3(RAUREQ, mis[1], 260),
2199 f_gen_one_compl_l3(RAUREQ, mis[2], 511)
2200 };
2201 } else {
2202 compl3 := f_gen_compl3_by_domain(ps_domain, 3, mis);
2203 }
2204
2205 f_TC_cnpool_compl_l3_list(ps_domain, compl3, {1, 1, 1}, "cnpool:subscr:known");
2206
2207 f_shutdown_helper();
2208}
2209
2210/* Layer 3 Complete by TMSI with valid NRI for the third MSC are directed to the third MSC (configured in osmo-hnbgw.cfg),
2211 * while a round-robin remains unaffected by that. */
2212testcase TC_mscpool_L3Complete_by_tmsi_valid_nri_2() runs on test_CT {
2213 f_TC_cnpool_L3Complete_valid_nri_2(ps_domain := false);
2214}
2215testcase TC_sgsnpool_L3Complete_valid_nri_2() runs on test_CT {
2216 f_TC_cnpool_L3Complete_valid_nri_2(ps_domain := true);
2217}
2218function f_TC_cnpool_L3Complete_valid_nri_2(boolean ps_domain) runs on test_CT {
2219
2220 f_init(nr_msc := 3, nr_sgsn := 3);
2221 f_sleep(1.0);
2222
2223 /* All TMSIs in this test point at the third MSC, set the round robin to point at the second MSC to make sure
2224 * this is not using round-robin. */
2225 f_vty_set_roundrobin_next(HNBGWVTY, ps_domain, 1);
2226
2227 f_ctrs_cn_init(ps_domain := ps_domain);
2228
2229 var ro_octetstring compl3;
2230
2231 /* 2 NRIs of the third MSC's range (512-767) */
2232 var ro_MobileIdentityLV mis := {
2233 valueof(ts_MI_TMSI_NRI_LV(512)),
2234 valueof(ts_MI_TMSI_NRI_LV(678))
2235 };
2236 if (ps_domain) {
2237 compl3 := {
2238 f_gen_one_compl_l3(ATTACHREQ, mis[0], 512),
2239 f_gen_one_compl_l3(ATTACHREQ, mis[1], 678)
2240 };
2241 } else {
2242 compl3 := f_gen_compl3_by_domain(ps_domain, 2, mis);
2243 }
2244
2245 f_TC_cnpool_compl_l3_list(ps_domain, compl3, {2, 2}, "cnpool:subscr:known");
2246
2247 /* The above forwardings to third MSC have not affected the round robin, which still points at the second MSC */
2248 f_TC_cnpool_compl_l3_list(ps_domain, f_gen_compl3_by_domain(ps_domain, 1), {1}, "cnpool:subscr:new");
2249
2250 f_shutdown_helper();
2251}
2252
2253/* LU with a TMSI but indicating a different PLMN in its previous LAI: ignore the NRI. */
2254testcase TC_mscpool_LU_by_tmsi_from_other_PLMN() runs on test_CT {
2255 f_TC_cnpool_nri_from_other_PLMN(ps_domain := false);
2256}
2257testcase TC_sgsnpool_nri_from_other_PLMN() runs on test_CT {
2258 f_TC_cnpool_nri_from_other_PLMN(ps_domain := true);
2259}
2260function f_TC_cnpool_nri_from_other_PLMN(boolean ps_domain) runs on test_CT {
2261
2262 f_init(nr_msc := 3, nr_sgsn := 3);
2263 f_sleep(1.0);
2264
2265 /* The TMSIs in this test points at the second MSC, but since it is from a different PLMN, round-robin is used
2266 * instead, and hits msc 0. */
2267 f_vty_set_roundrobin_next(HNBGWVTY, ps_domain, 0);
2268
2269 f_ctrs_cn_init(ps_domain := ps_domain);
2270
2271 var ro_octetstring compl3;
2272
2273 var ro_MobileIdentityLV mis := {
2274 valueof(ts_MI_TMSI_NRI_LV(260)),
2275 valueof(ts_MI_TMSI_NRI_LV(555))
2276 };
2277 if (ps_domain) {
2278 compl3 := {
2279 /* An NRI of the second MSC's range (256-511), but a PLMN that doesn't match with osmo-hnbgw.cfg */
2280 enc_PDU_L3_MS_SGSN(valueof(ts_GMM_ATTACH_REQ(mis[0], f_RAI('999'H, '99'H, '2a2a'O,
2281 '17'O),
2282 nri := ts_GMM_NRI(260)
2283 ))),
2284 /* An NRI of the third MSC's range (512-767) and a matching PLMN gets directed by NRI. */
2285 f_gen_one_compl_l3(ATTACHREQ, mis[1], 555)
2286 }
2287 } else {
2288 compl3 := {
2289 /* An NRI of the second MSC's range (256-511), but a PLMN that doesn't match with osmo-hnbgw.cfg */
2290 enc_PDU_ML3_MS_NW(valueof(ts_LU_REQ(LU_Type_IMSI_Attach, mis[0], '99F999'O))),
2291 /* An NRI of the third MSC's range (512-767) and a matching PLMN gets directed by NRI. */
2292 enc_PDU_ML3_MS_NW(valueof(ts_LU_REQ(LU_Type_IMSI_Attach, mis[1], '00F110'O)))
2293 };
2294 }
2295
2296 /* Foreign NRI: roundrobin */
2297 f_TC_cnpool_compl_l3(ps_domain, compl3[0], cn_nr := 0, inc_countername := "cnpool:subscr:new");
2298
2299 /* Local NRI: matching msc */
2300 f_TC_cnpool_compl_l3(ps_domain, compl3[1], cn_nr := 2, inc_countername := "cnpool:subscr:known");
2301
2302 f_shutdown_helper();
2303}
2304
Neels Hofmeyrb1bf16d2023-06-27 02:10:04 +02002305/* Make sure that whichever MSC paged a subscriber will also get the Paging Response. Page by IMSI, which would be
2306 * round-robined to another MSC, to make sure the Paging->Response relation is stronger than the NRI->MSC mapping. */
2307friend function f_tc_mscpool_paging_imsi(charstring id, TestHdlrParams pars) runs on ConnHdlr {
2308 f_init_handler(pars);
2309
2310 var hexstring imsi := '001010000000123'H;
2311 var RANAP_IEs.CN_DomainIndicator domain_ind;
2312 if (pars.ps_domain) {
2313 domain_ind := ps_domain;
2314 } else {
2315 domain_ind := cs_domain;
2316 }
2317 var template (value) RANAP_PDU paging := ts_RANAP_Paging(domain_ind, imsi_hex2oct(imsi));
2318 BSSAP.send(ts_RANAP_UNITDATA_req(pars.sccp_addr_hnbgw, pars.sccp_addr_msc, paging));
2319 /* TODO: Expect RUA ConnectionlessTransfer Paging (on all HNB).
2320 * We could verify the Paging sent from osmo-hnbgw to RUA with some effort,
2321 * but, this test does not care whether the Paging was forwarded to RUA or not, only that osmo-hnbgw *received*
2322 * the Paging. In the CN pool decisions, osmo-hnbgw should match up Paging Response to an earlier Paging.
2323 */
2324
2325 f_sleep(1.0);
2326
2327 /* Despite the round robin pointing at the second MSC ('roundrobin next msc 1'), the earlier Paging for the same IMSI
2328 * causes this Paging Response to go to the first MSC ('msc 0'). */
2329 f_perform_compl_l3(f_gen_one_compl_l3(PAGRESP, ts_MI_IMSI_LV(imsi)));
2330 f_sleep(1.0);
2331}
2332
2333testcase TC_mscpool_paging_imsi() runs on test_CT {
2334 f_init(nr_msc := 3);
2335 f_sleep(1.0);
2336
2337 var boolean ps_domain := false;
2338
2339 /* Testing a Paging on the first MSC to get a Paging Response back to the first MSC. Set round robin to the
2340 * second MSC to make sure we're getting the Paging logic, not a coincidental round robin match. */
2341 f_vty_set_roundrobin_next(HNBGWVTY, ps_domain, 0);
2342
2343 f_ctrs_cn_init(ps_domain := ps_domain);
2344
2345 var ConnHdlr vc_conn1;
2346 var template (value) TestHdlrParams pars1 := t_pars(0, ps_domain := ps_domain, cn_nr := 0);
2347 pars1.sccp_addr_hnbgw := g_cn[valueof(pars1.cn_idx)].sccp_addr_peer;
2348 pars1.sccp_addr_msc := g_cn[valueof(pars1.cn_idx)].sccp_addr_own;
2349 vc_conn1 := f_start_handler_with_pars(refers(f_tc_mscpool_paging_imsi), pars1);
2350 vc_conn1.done;
2351 f_ctrs_cn_expect(0, "cnpool:subscr:paged");
2352 f_shutdown_helper();
2353}
2354
2355/* Make sure that whichever MSC paged a subscriber will also get the Paging Response. Page by TMSI with an NRI value
2356 * that matches a different MSC, to make sure the Paging->Response relation is stronger than the NRI->MSC mapping. */
2357friend function f_tc_mscpool_paging_tmsi(charstring id, TestHdlrParams pars) runs on ConnHdlr {
2358 f_init_handler(pars);
2359
2360 var hexstring imsi := '001010000000124'H;
2361 var integer nri_v := 300; /* <-- second MSC's NRI */
2362 var octetstring tmsi := f_gen_tmsi(suffix := 0, nri_v := nri_v);
2363
2364 var RANAP_IEs.CN_DomainIndicator domain_ind;
2365 if (pars.ps_domain) {
2366 domain_ind := ps_domain;
2367 } else {
2368 domain_ind := cs_domain;
2369 }
2370 var template (value) RANAP_PDU paging := ts_RANAP_Paging_temp_id(domain_ind, imsi_hex2oct(imsi),
2371 ts_RANAP_TemporaryUE_ID_TMSI(tmsi));
2372 BSSAP.send(ts_RANAP_UNITDATA_req(pars.sccp_addr_hnbgw, pars.sccp_addr_msc, paging));
2373 /* TODO: Expect RUA ConnectionlessTransfer Paging (on all HNB).
2374 * We could verify the Paging sent from osmo-hnbgw to RUA with some effort,
2375 * but, this test does not care whether the Paging was forwarded to RUA or not, only that osmo-hnbgw *received*
2376 * the Paging. In the CN pool decisions, osmo-hnbgw should match up Paging Response to an earlier Paging.
2377 */
2378
2379 f_sleep(1.0);
2380
2381 /* Despite the round robin pointing at the third MSC ('roundrobin next msc 2'), the earlier Paging for the same
2382 * TMSI causes this Paging Response to go to the first MSC ('msc 0'). */
2383 f_perform_compl_l3(f_gen_one_compl_l3(PAGRESP, ts_MI_TMSI_NRI_LV(nri_v)));
2384 f_sleep(1.0);
2385}
2386testcase TC_mscpool_paging_tmsi() runs on test_CT {
2387 f_init(nr_msc := 3);
2388 f_sleep(1.0);
2389
2390 var boolean ps_domain := false;
2391
2392 /* Testing a Paging on the first MSC to get a Paging Response back to the first MSC. Set round robin to the
2393 * third MSC to make sure we're getting the Paging logic, not a coincidental round robin match. */
2394 f_vty_set_roundrobin_next(HNBGWVTY, ps_domain, 0);
2395
2396 f_ctrs_cn_init(ps_domain := ps_domain);
2397
2398 var ConnHdlr vc_conn1;
2399 var template (value) TestHdlrParams pars1 := t_pars(0, ps_domain := ps_domain, cn_nr := 0);
2400 pars1.sccp_addr_hnbgw := g_cn[valueof(pars1.cn_idx)].sccp_addr_peer;
2401 pars1.sccp_addr_msc := g_cn[valueof(pars1.cn_idx)].sccp_addr_own;
2402 vc_conn1 := f_start_handler_with_pars(refers(f_tc_mscpool_paging_tmsi), pars1);
2403 vc_conn1.done;
2404 f_ctrs_cn_expect(0, "cnpool:subscr:paged");
2405 f_shutdown_helper();
2406}
2407
Neels Hofmeyr7d0e6802023-04-20 20:43:55 +02002408/* For round-robin, skip a CN link that has 'no allow-attach' set. */
2409testcase TC_mscpool_no_allow_attach_round_robin() runs on test_CT {
2410
2411 f_init(nr_msc := 3);
2412 f_sleep(1.0);
2413
2414 var boolean ps_domain := false;
2415
2416 /* Mark the second MSC as offloading, round-robin should skip this MSC now. */
2417 f_vty_cnlink_allow_attach(HNBGWVTY, ps_domain, {true, false, true});
2418
2419 /* Control which MSC gets chosen next by the round-robin, otherwise
2420 * would be randomly affected by which other tests ran before this. */
2421 f_vty_set_roundrobin_next(HNBGWVTY, ps_domain, 0);
2422
2423 f_ctrs_cn_init(ps_domain := ps_domain);
2424
2425 f_TC_cnpool_compl_l3_list(ps_domain, f_gen_compl3_by_domain(ps_domain, 3),
2426 /* msc 1 is skipped */
2427 {0, 2, 0},
2428 "cnpool:subscr:new");
2429
2430 f_shutdown_helper();
2431}
2432
2433/* An MSC that has 'no allow-attach' set should still serve subscribers that are already attached according to their
2434 * TMSI NRI. */
2435testcase TC_mscpool_no_allow_attach_valid_nri() runs on test_CT {
2436
2437 f_init(nr_msc := 3);
2438 f_sleep(1.0);
2439
2440 var boolean ps_domain := false;
2441
2442 /* Mark the second MSC as offloading, round-robin should skip this MSC now. */
2443 f_vty_cnlink_allow_attach(HNBGWVTY, ps_domain, {true, false, true});
2444
2445 /* Control which MSC gets chosen next by the round-robin, otherwise
2446 * would be randomly affected by which other tests ran before this. */
2447 f_vty_set_roundrobin_next(HNBGWVTY, ps_domain, 0);
2448
2449 f_ctrs_cn_init(ps_domain := ps_domain);
2450
2451 var ro_MobileIdentityLV mis := {
2452 valueof(ts_MI_TMSI_NRI_LV(260)),
2453 valueof(ts_MI_IMSI_LV('001010000000002'H)),
2454 valueof(ts_MI_IMSI_LV('001010000000003'H))
2455 };
2456
2457 var ro_octetstring compl3 := f_gen_compl3_by_domain(ps_domain, 3, mis);
2458
2459 /* Round robin points at msc 0, but the valid NRI directs to msc 1, even though msc 1 has 'no allow-attach'. */
2460 f_TC_cnpool_compl_l3(ps_domain, compl3[0], cn_nr := 1, inc_countername := "cnpool:subscr:known");
2461
2462 /* Normal round robin skips msc 1, because it has 'no allow-attach' */
2463 f_TC_cnpool_compl_l3(ps_domain, compl3[1], cn_nr := 0, inc_countername := "cnpool:subscr:new");
2464 f_TC_cnpool_compl_l3(ps_domain, compl3[2], cn_nr := 2, inc_countername := "cnpool:subscr:new");
2465
2466 f_shutdown_helper();
2467}
2468
2469/* When a peer point-code gets an SCCP N-PCSTATE saying it is unreachable, immediately mark the CN link as unusable. */
2470testcase TC_mscpool_sccp_n_pcstate_detaches_cnlink() runs on test_CT {
2471 f_TC_cnpool_sccp_n_pcstate_detaches_cnlink(ps_domain := false);
2472}
2473testcase TC_sgsnpool_sccp_n_pcstate_detaches_cnlink() runs on test_CT {
2474 f_TC_cnpool_sccp_n_pcstate_detaches_cnlink(ps_domain := true);
2475}
2476function f_TC_cnpool_sccp_n_pcstate_detaches_cnlink(boolean ps_domain) runs on test_CT
2477{
2478
2479 f_init(nr_msc := 2, nr_sgsn := 2);
2480 f_sleep(1.0);
2481
2482 /* Control which MSC gets chosen next by the round-robin, otherwise
2483 * would be randomly affected by which other tests ran before this. */
2484 f_vty_set_roundrobin_next(HNBGWVTY, ps_domain, 0);
2485
2486 f_ctrs_cn_init(ps_domain := ps_domain);
2487
2488 var ro_octetstring compl3 := f_gen_compl3_by_domain(ps_domain, 3);
2489
2490 f_TC_cnpool_compl_l3(ps_domain, compl3[0], cn_nr := 0, inc_countername := "cnpool:subscr:new");
2491 f_TC_cnpool_compl_l3(ps_domain, compl3[1], cn_nr := 1, inc_countername := "cnpool:subscr:new");
2492
2493 f_logp(HNBGWVTY, "disconnecting msc0");
2494 f_cn_idx_disconnect(f_cn_idx(ps_domain, 0));
2495
2496 /* Now round-robin would wrap to the first MSC, but since the first MSC is disconnected, it wraps around to the
2497 * second. */
2498 f_TC_cnpool_compl_l3(ps_domain, compl3[2], cn_nr := 1, inc_countername := "cnpool:subscr:new");
2499
2500 f_shutdown_helper();
2501}
2502
2503/* When a CN link point-code gets an SCCP N-PCSTATE saying it is now reachable, immediately trigger RESET and bring up the
2504 * MSC. */
2505testcase TC_mscpool_sccp_n_pcstate_attaches_cnlink() runs on test_CT {
2506 f_TC_cnpool_sccp_n_pcstate_attaches_cnlink(ps_domain := false);
2507}
2508testcase TC_sgsnpool_sccp_n_pcstate_attaches_cnlink() runs on test_CT {
2509 f_TC_cnpool_sccp_n_pcstate_attaches_cnlink(ps_domain := true);
2510}
2511function f_TC_cnpool_sccp_n_pcstate_attaches_cnlink(boolean ps_domain) runs on test_CT
2512{
2513 f_init(nr_msc := 1, nr_sgsn := 1);
2514 f_sleep(1.0);
2515
2516 /* Control which MSC gets chosen next by the round-robin, otherwise
2517 * would be randomly affected by which other tests ran before this. */
2518 f_vty_set_roundrobin_next(HNBGWVTY, ps_domain, 0);
2519
2520 var ro_octetstring compl3 := f_gen_compl3_by_domain(ps_domain, 3);
2521
2522 f_ctrs_cn_init(ps_domain := ps_domain);
2523
2524 /* There is only one MSC, round robin stays on msc0 */
2525 f_TC_cnpool_compl_l3(ps_domain := ps_domain, nas_pdu := compl3[0], cn_nr := 0, inc_countername := "cnpool:subscr:new");
2526 f_TC_cnpool_compl_l3(ps_domain := ps_domain, nas_pdu := compl3[1], cn_nr := 0, inc_countername := "cnpool:subscr:new");
2527
2528 f_logp(HNBGWVTY, "connecting cnlink 1");
2529 f_cn_nr_init(ps_domain, 1);
2530 f_vty_cnlink_allow_attach(HNBGWVTY, ps_domain, { true, true });
2531 f_sleep(1.0);
2532
2533 /* This time round-robin wraps to the second MSC, because it is now online. */
2534 f_TC_cnpool_compl_l3(ps_domain := ps_domain, nas_pdu := compl3[2], cn_nr := 1, inc_countername := "cnpool:subscr:new");
2535
2536 f_shutdown_helper();
2537}
2538
Neels Hofmeyrd019cc02023-06-02 16:31:23 +02002539private function f_vty_add_sccp_addr(TELNETasp_PT pt, charstring addr_name, charstring pc, integer cs7_nr := 0)
2540{
2541 f_vty_enter_config(pt);
2542 f_vty_transceive(pt, "cs7 instance 0");
2543 f_vty_transceive(pt, "sccp-address " & addr_name);
2544 f_vty_transceive(pt, "point-code " & pc);
2545 f_vty_transceive(pt, "end");
2546}
2547
2548private function f_vty_set_cnlink_addr(TELNETasp_PT pt, charstring cnlink_and_nr, charstring addr_name)
2549{
2550 f_vty_enter_config(pt);
2551 f_vty_transceive(pt, cnlink_and_nr);
2552 f_vty_transceive(pt, "remote-addr " & addr_name);
2553 f_vty_transceive(pt, "end");
2554}
2555
2556private function f_vty_apply_sccp(TELNETasp_PT pt)
2557{
2558 f_vty_enter_config(pt);
2559 f_vty_transceive(pt, "apply sccp");
2560 f_vty_transceive(pt, "end");
2561}
2562
2563template (present) RUA_Disc_Req tr_RUA_Disc_Req := {
2564 ranap := ?,
2565 cause := ?
2566};
2567
2568/* With a cnlink up, change the SCCP address, and verify that it restarts upon vty 'apply sccp' */
2569private function f_tc_apply_sccp(charstring id, TestHdlrParams pars) runs on ConnHdlr
2570{
2571 f_init_handler(pars);
2572 f_perform_compl_l3(f_gen_compl3_by_domain(pars.ps_domain, 1)[0]);
2573
2574 f_sleep(1.0);
2575 f_logp(HNBGWVTY, "Changing SCCP address, don't apply yet");
2576
2577 f_vty_add_sccp_addr(HNBGWVTY, "msc-foo", "0.42.4");
2578 f_vty_set_cnlink_addr(HNBGWVTY, "msc 0", "msc-foo");
2579
2580 /* No effect yet, link still open both ways */
2581 f_sleep(1.0);
2582 f_iuh2iu(ts_RANAP_DirectTransfer(f_rnd_octstring(10)));
2583 f_iu2iuh(ts_RANAP_DirectTransfer(f_rnd_octstring(10)));
2584
2585 f_logp(HNBGWVTY, "Apply SCCP address changes");
2586 f_vty_apply_sccp(HNBGWVTY);
2587
2588 /* We modified the SCCP configuration, expect disconnect of UE that was active on the aborted link. */
2589 RUA.receive(RUA_Disc_Ind:?);
2590 BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_DISC_IND);
2591
2592 /* Would be nice to test reconnection on the other point-code, too. That would require another cnlink in
2593 * osmo-stp.cfg and module parameters... */
2594
2595 f_sleep(1.0);
2596}
2597testcase TC_apply_sccp() runs on test_CT
2598{
2599 f_init();
2600 f_sleep(1.0);
2601
2602 var ConnHdlr vc_conn;
2603 var template (value) TestHdlrParams pars := t_pars(0);
2604 vc_conn := f_start_handler_with_pars(refers(f_tc_apply_sccp), pars);
2605 vc_conn.done;
2606
2607 f_shutdown_helper();
2608}
2609
Neels Hofmeyrc3c01d32023-11-07 02:19:00 +01002610/* In the field, we encountered a "normal" RAB Assignment that concludes successfully, followed by another RAB
2611 * Assignment that has different SDU subflow parameters, and does not contain RTP information. At the time of writing,
2612 * it seems that the second RAB Assignment causes a crash. Play through this scenario. */
2613friend function f_tc_second_rab_assignment(charstring id, TestHdlrParams pars) runs on ConnHdlr {
2614 var MgcpCommand mgcp_cmd;
2615 var RANAP_PDU tx;
2616 timer T := 5.0;
2617
2618 f_init_handler(pars);
2619 f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit});
2620
2621 tx := f_build_initial_ue(g_pars);
2622 f_iuh2iu_connect(tx);
2623
2624 f_create_rab(pars.mgcp_pars);
2625
2626 /* Now send a second RAB Assignment with different subflows and omitting transportLayerInformation. (Assuming
2627 * the first RAB Assignment's transportLayerInformation remains in use unchanged.) */
2628 var template RAB_SetupOrModifyList rab_sml;
2629 rab_sml := ts_RAB_SML2(t_RAB_id(23),
2630 ts_RabParams,
2631 user_plane_info := omit,
2632 transport_layer_info := omit);
2633 tx := valueof(ts_RANAP_RabAssReq(rab_sml));
2634 BSSAP.send(tx);
2635 T.start;
2636
2637 /* Expect this secondary RAB Assignment to go through unchanged. */
2638 f_rua_expect(tx);
2639
2640 /* I'm guessing that the RAB Assignment Response also omits transportLayerInformation, so far not known because
2641 * osmo-hnbgw crashed before we could receive the response. */
2642
2643 /* Send back RAB Assignment Response via Iuh */
2644 var template RAB_SetupOrModifiedList rab_smdl;
2645 rab_smdl := ts_RAB_SMdL_no_tla(t_RAB_id(23));
2646 tx := valueof(ts_RANAP_RabAssResp(rab_smdl));
2647 RUA.send(tx);
2648 f_bssap_expect(tx);
2649
2650 /* Send Iu Release */
2651 tx := valueof(ts_RANAP_IuReleaseCommand(ts_RanapCause_om_intervention));
2652 f_iu2iuh(tx);
2653
2654 T.start;
2655 alt {
2656 [] as_mgcp_dlcx(pars) {}
2657 [] T.timeout {
2658 setverdict(fail, "Timeout waiting for DLCX");
2659 }
2660 }
2661
2662 tx := valueof(ts_RANAP_IuReleaseComplete());
2663 f_iuh2iu(tx);
2664}
2665
2666testcase TC_second_rab_assignment() runs on test_CT {
2667 var ConnHdlr vc_conn;
2668 g_num_hnbs := 1;
2669 f_init();
2670
2671 vc_conn := f_start_handler_with_pars(refers(f_tc_second_rab_assignment), t_pars(3));
2672 vc_conn.done;
2673
2674 f_shutdown_helper();
2675}
2676
Daniel Willmann19b8d902022-01-05 09:12:34 +01002677control {
2678 execute(TC_hnb_register());
Daniel Willmannc79679a2022-08-23 17:48:39 +02002679 execute(TC_hnb_register_duplicate());
Pau Espin Pedrolacf4f222022-09-27 14:33:40 +02002680 execute(TC_hnb_register_duplicate_reuse_sctp_assoc());
Daniel Willmann19b8d902022-01-05 09:12:34 +01002681 execute(TC_ranap_cs_initial_ue());
2682 execute(TC_ranap_ps_initial_ue());
Neels Hofmeyrf0b9ed12022-06-07 17:46:32 +02002683 execute(TC_ranap_cs_initial_ue_empty_cr());
2684 execute(TC_ranap_ps_initial_ue_empty_cr());
Daniel Willmann19b8d902022-01-05 09:12:34 +01002685 execute(TC_ranap_cs_bidir());
2686 execute(TC_ranap_ps_bidir());
2687 execute(TC_rab_assignment());
2688 execute(TC_rab_release());
Daniel Willmann3e15b7b2022-02-21 17:07:02 +01002689 execute(TC_rab_assign_fail());
Daniel Willmann37c877f2022-02-22 16:47:06 +01002690 execute(TC_rab_assign_mgcp_to());
Daniel Willmann19b8d902022-01-05 09:12:34 +01002691 execute(TC_ranap_cs_mo_disconnect());
2692 execute(TC_ranap_ps_mo_disconnect());
Neels Hofmeyrbacb74f2022-08-29 16:24:12 +02002693
2694 if (mp_enable_pfcp_tests) {
2695 execute(TC_ps_rab_assignment_with_pfcp());
2696 } else {
2697 execute(TC_ps_rab_assignment_without_pfcp());
2698 }
Pau Espin Pedrolf0b9fa02022-09-12 13:31:07 +02002699
Neels Hofmeyr7d0e6802023-04-20 20:43:55 +02002700 execute( TC_mscpool_L3Compl_on_1_cnlink() );
2701 execute( TC_mscpool_L3Complete_by_imsi_round_robin() );
2702 execute( TC_mscpool_LU_by_tmsi_null_nri_0_round_robin() );
2703 execute( TC_mscpool_LU_by_tmsi_null_nri_1_round_robin() );
2704 execute( TC_mscpool_L3Complete_by_tmsi_unassigned_nri_round_robin() );
2705 execute( TC_mscpool_L3Complete_by_tmsi_valid_nri_msc_not_connected_round_robin() );
2706 execute( TC_mscpool_L3Complete_by_tmsi_valid_nri_1() );
2707 execute( TC_mscpool_L3Complete_by_tmsi_valid_nri_2() );
2708 execute( TC_mscpool_LU_by_tmsi_from_other_PLMN() );
Neels Hofmeyrb1bf16d2023-06-27 02:10:04 +02002709 execute( TC_mscpool_paging_imsi() );
2710 execute( TC_mscpool_paging_tmsi() );
Neels Hofmeyr7d0e6802023-04-20 20:43:55 +02002711 execute( TC_mscpool_no_allow_attach_round_robin() );
2712 execute( TC_mscpool_no_allow_attach_valid_nri() );
2713 execute( TC_mscpool_sccp_n_pcstate_detaches_cnlink() );
2714 execute( TC_mscpool_sccp_n_pcstate_attaches_cnlink() );
2715
2716 execute( TC_sgsnpool_L3Compl_on_1_cnlink() );
2717 execute( TC_sgsnpool_L3Complete_no_nri_round_robin() );
2718 execute( TC_sgsnpool_L3Complete_valid_nri_1() );
2719 execute( TC_sgsnpool_L3Complete_valid_nri_2() );
2720 execute( TC_sgsnpool_nri_from_other_PLMN() );
2721 execute( TC_sgsnpool_sccp_n_pcstate_detaches_cnlink() );
2722 execute( TC_sgsnpool_sccp_n_pcstate_attaches_cnlink() );
2723
Oliver Smithaa919b42023-11-14 11:30:55 +01002724 /* Run only on nightly since it makes osmo-hnbgw <= 1.5.0 crash: OS#6253 */
2725 if (f_osmo_repo_is("nightly")) {
2726 execute(TC_second_rab_assignment());
2727 }
Neels Hofmeyrc3c01d32023-11-07 02:19:00 +01002728
Pau Espin Pedrolf0b9fa02022-09-12 13:31:07 +02002729 /* Run at the end since it makes osmo-hnbgw <= 1.3.0 crash: OS#5676 */
2730 execute(TC_hnb_reregister_reuse_sctp_assoc());
Neels Hofmeyrd019cc02023-06-02 16:31:23 +02002731
2732 /* Run at the end since it messes with the SCCP config */
2733 execute( TC_apply_sccp() );
Daniel Willmann19b8d902022-01-05 09:12:34 +01002734}
2735
2736}