Daniel Willmann | 19b8d90 | 2022-01-05 09:12:34 +0100 | [diff] [blame] | 1 | module 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 | |
| 16 | import from Misc_Helpers all; |
| 17 | import from General_Types all; |
| 18 | import from GSM_Types all; |
| 19 | import from Osmocom_Types all; |
| 20 | import from IPL4asp_Types all; |
| 21 | |
| 22 | import from Osmocom_CTRL_Functions all; |
| 23 | import from Osmocom_CTRL_Types all; |
| 24 | import from Osmocom_CTRL_Adapter all; |
| 25 | |
| 26 | import from StatsD_Types all; |
| 27 | import from StatsD_CodecPort all; |
| 28 | import from StatsD_CodecPort_CtrlFunct all; |
| 29 | import from StatsD_Checker all; |
| 30 | |
| 31 | import from Osmocom_VTY_Functions all; |
| 32 | import from TELNETasp_PortType all; |
| 33 | |
| 34 | import from HNBAP_Templates all; |
| 35 | import from HNBAP_PDU_Descriptions all; |
| 36 | |
| 37 | import from RUA_IEs all; |
| 38 | import from RUA_Templates all; |
| 39 | import from RUA_Emulation all; |
| 40 | |
| 41 | import from Iuh_Emulation all; |
| 42 | |
| 43 | import from RANAP_Types all; |
| 44 | import from RANAP_PDU_Descriptions all; |
| 45 | import from RANAP_PDU_Contents all; |
| 46 | import from RANAP_IEs all; |
| 47 | import from RANAP_Templates all; |
| 48 | |
| 49 | import from RAN_Adapter all; |
| 50 | |
| 51 | import from RAN_Adapter all; |
| 52 | import from RAN_Emulation all; |
| 53 | |
| 54 | import from MGCP_Emulation all; |
| 55 | import from MGCP_Types all; |
| 56 | import from MGCP_Templates all; |
| 57 | import from MGCP_CodecPort all; |
| 58 | import from SDP_Types all; |
| 59 | |
| 60 | modulepar { |
| 61 | /* IP address at which the HNodeB can be reached */ |
| 62 | charstring mp_hnodeb_ip := "127.0.0.1"; |
| 63 | integer mp_hnodeb_port := -1; |
| 64 | |
| 65 | /* IP address at which the test binds */ |
| 66 | charstring mp_hnbgw_ip := "127.0.0.1"; |
| 67 | integer mp_hnbgw_iuh_port := 29169; |
| 68 | |
| 69 | charstring mp_mgw_ip := "127.0.0.1"; |
| 70 | integer mp_mgw_port := 2427; |
| 71 | |
| 72 | RAN_Configuration mp_msc_cfg := { |
| 73 | transport := RANAP_TRANSPORT_IuCS, |
| 74 | sccp_service_type := "mtp3_itu", |
| 75 | sctp_addr := { 23905, "127.0.0.1", 2905, "127.0.0.1" }, |
| 76 | own_pc := 188, /* 0.23.4 first MSC emulation */ |
| 77 | own_ssn := 142, |
| 78 | peer_pc := 189, /* 0.23.5 osmo-hnbgw */ |
| 79 | peer_ssn := 142, |
| 80 | sio := '83'O, |
| 81 | rctx := 1 |
| 82 | }; |
| 83 | RAN_Configuration mp_sgsn_cfg := { |
| 84 | transport := RANAP_TRANSPORT_IuCS, |
| 85 | sccp_service_type := "mtp3_itu", |
| 86 | sctp_addr := { 23906, "127.0.0.1", 2905, "127.0.0.1" }, |
| 87 | own_pc := 185, /* 0.23.1 first SGSN emulation */ |
| 88 | own_ssn := 142, |
| 89 | peer_pc := 189, /* 0.23.5 osmo-hnbgw */ |
| 90 | peer_ssn := 142, |
| 91 | sio := '83'O, |
| 92 | rctx := 2 |
| 93 | }; |
| 94 | } |
| 95 | |
| 96 | function MSC_UnitdataCallback(RANAP_PDU ranap) runs on RAN_Emulation_CT return template RANAP_PDU { |
| 97 | // TODO: Actually implement unitdata handling |
| 98 | return ts_RANAP_Reset(ts_RanapCause_om_intervention, cs_domain); |
| 99 | } |
| 100 | |
| 101 | const RanOps MSC_RanOps := { |
| 102 | ranap_create_cb := refers(RAN_Emulation.RanapExpectedCreateCallback), |
| 103 | ranap_unitdata_cb := refers(MSC_UnitdataCallback), |
| 104 | ps_domain := false, |
| 105 | decode_dtap := false, |
| 106 | role_ms := false, |
| 107 | protocol := RAN_PROTOCOL_RANAP, |
| 108 | transport := RANAP_TRANSPORT_IuCS, |
| 109 | use_osmux := false, |
Eric Wild | 6e511ce | 2022-04-02 21:35:56 +0200 | [diff] [blame] | 110 | bssap_reset_retries := 1, |
Daniel Willmann | 19b8d90 | 2022-01-05 09:12:34 +0100 | [diff] [blame] | 111 | sccp_addr_local := omit, |
| 112 | sccp_addr_peer := omit |
| 113 | } |
| 114 | |
| 115 | type record CrcxResponse { |
| 116 | integer resp, |
| 117 | HostName mgw_rtp_ip, |
| 118 | PortNumber mgw_rtp_port, |
| 119 | MgcpConnectionId mgcp_connection_id |
| 120 | } |
| 121 | type record MgcpParameters { |
| 122 | integer got_crcx_count, |
| 123 | integer got_dlcx_count, |
| 124 | MgcpCallId mgcp_call_id optional, |
| 125 | MgcpEndpoint mgcp_ep, |
| 126 | CrcxResponse mgw_conn_1, |
| 127 | CrcxResponse mgw_conn_2, |
| 128 | uint7_t rtp_payload_type, |
| 129 | charstring rtp_sdp_format, |
| 130 | HostName hnb_rtp_ip, |
| 131 | PortNumber hnb_rtp_port, |
| 132 | HostName cn_rtp_ip, |
| 133 | PortNumber cn_rtp_port, |
| 134 | boolean use_osmux, |
| 135 | integer got_osmux_count |
| 136 | } |
| 137 | |
| 138 | template (value) MgcpParameters t_MgcpParams := { |
| 139 | got_crcx_count := 0, |
| 140 | got_dlcx_count := 0, |
| 141 | mgcp_call_id := omit, |
| 142 | mgcp_ep := "rtpbridge/1@mgw", |
| 143 | mgw_conn_1 := { |
| 144 | resp := 1, |
| 145 | mgw_rtp_ip := "127.1.2.1", |
| 146 | mgw_rtp_port := 10000, |
| 147 | mgcp_connection_id := '11111'H |
| 148 | }, |
| 149 | mgw_conn_2 := { |
| 150 | resp := 1, |
| 151 | mgw_rtp_ip := "127.1.2.2", |
| 152 | mgw_rtp_port := 20000, |
| 153 | mgcp_connection_id := '22222'H |
| 154 | }, |
| 155 | rtp_payload_type := 23, |
| 156 | rtp_sdp_format := "FOO", |
| 157 | hnb_rtp_ip := "127.1.1.1", |
| 158 | hnb_rtp_port := 10001, |
| 159 | cn_rtp_ip := "127.1.3.1", |
| 160 | cn_rtp_port := 20001, |
| 161 | use_osmux := false, |
| 162 | got_osmux_count := 0 |
| 163 | } |
| 164 | |
| 165 | type record TestHdlrParams { |
| 166 | integer hnb_idx, |
| 167 | hexstring imsi, |
| 168 | boolean ps_domain, |
| 169 | MgcpParameters mgcp_pars optional, |
Neels Hofmeyr | f0b9ed1 | 2022-06-07 17:46:32 +0200 | [diff] [blame] | 170 | HnbConfig hnb optional, |
| 171 | boolean separate_sccp_cr |
Daniel Willmann | 19b8d90 | 2022-01-05 09:12:34 +0100 | [diff] [blame] | 172 | } |
| 173 | |
| 174 | /* We extend: |
| 175 | * RUA_ConnHdlr (for the Iuh side, emulating the HNB) |
| 176 | * RAN_ConnHdlr (for the Iu side, emulating the MSC) |
| 177 | * MGCP_ConnHdlr (for the MGCP side, emulating the MGW) |
| 178 | */ |
| 179 | type component ConnHdlr extends RAN_ConnHdlr, MGCP_ConnHdlr, RUA_ConnHdlr { |
| 180 | var integer g_sccp_conn_id; |
| 181 | var TestHdlrParams g_pars; |
| 182 | timer g_Tguard; |
| 183 | } |
| 184 | |
| 185 | |
| 186 | const MGCPOps MSC_MGCPOps := { |
| 187 | create_cb := refers(MGCP_Emulation.ExpectedCreateCallback), |
| 188 | unitdata_cb := refers(MGCP_Emulation.DummyUnitdataCallback) |
| 189 | } |
| 190 | |
| 191 | function f_create_ranap_exp(octetstring l3_enc) runs on ConnHdlr { |
| 192 | BSSAP_PROC.call(RAN_register:{l3_enc, self}) { |
| 193 | [] BSSAP_PROC.getreply(RAN_register:{?, ?}) {}; |
| 194 | } |
| 195 | } |
| 196 | |
| 197 | |
| 198 | const integer NUM_HNB := 1; |
| 199 | |
Daniel Willmann | 19b8d90 | 2022-01-05 09:12:34 +0100 | [diff] [blame] | 200 | type record HnbConfig { |
| 201 | LocationAreaIdentification lai, |
| 202 | integer sac |
| 203 | } |
| 204 | |
| 205 | type component test_CT extends CTRL_Adapter_CT { |
| 206 | var boolean g_initialized := false; |
| 207 | |
| 208 | /********************* Iu side */ |
| 209 | var RAN_Adapter g_msc; |
| 210 | var RAN_Adapter g_sgsn; |
| 211 | /* SGSN IuPS missing */ |
| 212 | |
| 213 | /********************* Iuh side */ |
| 214 | var HnbConfig g_hnb_cfg[NUM_HNB]; |
| 215 | var Iuh_Emulation_CT vc_Iuh[NUM_HNB]; |
| 216 | var RUA_Emulation_CT vc_RUA[NUM_HNB]; |
| 217 | port HNBAP_PT HNBAP[NUM_HNB]; |
| 218 | |
| 219 | var MGCP_Emulation_CT vc_MGCP; |
| 220 | port TELNETasp_PT HNBGWVTY; |
| 221 | /* global test case guard timer (actual timeout value is set in f_init()) */ |
| 222 | timer T_guard := 30.0; |
| 223 | } |
| 224 | |
| 225 | /* global altstep for global guard timer; */ |
| 226 | altstep as_Tguard() runs on test_CT { |
| 227 | [] T_guard.timeout { |
| 228 | setverdict(fail, "Timeout of T_guard"); |
| 229 | mtc.stop; |
| 230 | } |
| 231 | } |
| 232 | |
| 233 | friend function f_logp(TELNETasp_PT pt, charstring log_msg) |
| 234 | { |
| 235 | // log on TTCN3 log output |
| 236 | log(log_msg); |
| 237 | // log in stderr log |
| 238 | f_vty_transceive(pt, "logp lglobal notice TTCN3 f_logp(): " & log_msg); |
| 239 | } |
| 240 | |
| 241 | function f_init_vty(charstring id := "foo") runs on test_CT { |
| 242 | if (HNBGWVTY.checkstate("Mapped")) { |
| 243 | /* skip initialization if already executed once */ |
| 244 | return; |
| 245 | } |
| 246 | map(self:HNBGWVTY, system:HNBGWVTY); |
| 247 | f_vty_set_prompts(HNBGWVTY); |
| 248 | f_vty_transceive(HNBGWVTY, "enable"); |
| 249 | } |
| 250 | |
| 251 | function f_init_mgcp(charstring id) runs on test_CT { |
| 252 | id := id & "-MGCP"; |
| 253 | var MGCPOps ops := { |
| 254 | create_cb := refers(MGCP_Emulation.ExpectedCreateCallback), |
| 255 | unitdata_cb := refers(MGCP_Emulation.DummyUnitdataCallback) |
| 256 | } |
| 257 | var MGCP_conn_parameters pars := { |
| 258 | callagent_ip := mp_hnbgw_ip, |
| 259 | callagent_udp_port := -1, |
| 260 | mgw_ip := mp_mgw_ip, |
| 261 | mgw_udp_port := mp_mgw_port, |
| 262 | multi_conn_mode := false |
| 263 | } |
| 264 | |
| 265 | vc_MGCP := MGCP_Emulation_CT.create(id); |
| 266 | map(vc_MGCP:MGCP, system:MGCP_CODEC_PT); |
| 267 | vc_MGCP.start(MGCP_Emulation.main(ops, pars, id)); |
| 268 | } |
| 269 | |
| 270 | function f_init_hnodeb(charstring id, integer hnb_idx, RuaOps rua_ops) runs on test_CT { |
| 271 | id := id & "-Iuh" & int2str(hnb_idx); |
| 272 | |
| 273 | /* Iuh lower layer (RUA/HNBAP demux) */ |
| 274 | var Iuh_conn_parameters iuh_pars; |
| 275 | iuh_pars.remote_ip := mp_hnbgw_ip; |
| 276 | iuh_pars.remote_sctp_port := mp_hnbgw_iuh_port; |
| 277 | iuh_pars.local_ip := mp_hnodeb_ip; |
| 278 | iuh_pars.local_sctp_port := mp_hnodeb_port + hnb_idx; |
| 279 | vc_Iuh[hnb_idx] := Iuh_Emulation_CT.create(id); |
| 280 | connect(self:HNBAP[hnb_idx], vc_Iuh[hnb_idx]:HNBAP); |
| 281 | |
| 282 | vc_RUA[hnb_idx] := RUA_Emulation_CT.create(id & "-RUA"); |
| 283 | connect(vc_RUA[hnb_idx]:RUA, vc_Iuh[hnb_idx]:RUA); |
| 284 | |
| 285 | /* Start Iuh side components */ |
| 286 | vc_Iuh[hnb_idx].start(Iuh_Emulation.main(iuh_pars, id)); |
| 287 | vc_RUA[hnb_idx].start(RUA_Emulation.main(rua_ops, id & "-RUA")); |
| 288 | } |
| 289 | |
| 290 | /* global initialization function */ |
| 291 | function f_init(charstring id := "HBGW", float guard_timeout := 30.0) runs on test_CT { |
| 292 | |
| 293 | g_hnb_cfg[0] := { |
| 294 | lai := { |
| 295 | mcc_mnc := '00101'H, |
| 296 | lac := 2342 |
| 297 | }, |
| 298 | sac := 55 |
| 299 | } |
| 300 | T_guard.start(guard_timeout); |
| 301 | activate(as_Tguard()); |
| 302 | |
| 303 | /* RUA/RANAP emulation on top of lower-layer Iuh */ |
| 304 | var RuaOps rua_ops := { |
| 305 | create_cb := refers(IuhRanapCreateCallback), |
| 306 | unitdata_cb := refers(IuhRanapUnitdataCallback) |
| 307 | }; |
| 308 | for (var integer i := 0; i < NUM_HNB; i := i+1) { |
| 309 | f_init_hnodeb(testcasename(), i, rua_ops); |
| 310 | } |
| 311 | |
| 312 | /* MSC emulation */ |
| 313 | var RanOps ranops := { |
| 314 | ranap_create_cb := refers(RAN_Emulation.RanapExpectedCreateCallback), |
| 315 | ranap_unitdata_cb := omit, |
| 316 | ps_domain := false, |
| 317 | decode_dtap := false, |
| 318 | role_ms := false, |
| 319 | protocol := RAN_PROTOCOL_RANAP, |
| 320 | transport := RANAP_TRANSPORT_IuCS, |
| 321 | use_osmux := false, |
Eric Wild | 6e511ce | 2022-04-02 21:35:56 +0200 | [diff] [blame] | 322 | bssap_reset_retries := 1, |
Daniel Willmann | 19b8d90 | 2022-01-05 09:12:34 +0100 | [diff] [blame] | 323 | sccp_addr_local := omit, |
| 324 | sccp_addr_peer := omit |
| 325 | }; |
| 326 | f_ran_adapter_init(g_msc, mp_msc_cfg, "HNBGW_Test", ranops); |
| 327 | f_ran_adapter_start(g_msc); |
| 328 | |
| 329 | /* SGSN emulation */ |
| 330 | ranops.ps_domain := true; |
| 331 | f_ran_adapter_init(g_sgsn, mp_sgsn_cfg, "HNBGW_Test", ranops); |
| 332 | f_ran_adapter_start(g_sgsn); |
| 333 | |
| 334 | f_init_mgcp(id); |
| 335 | f_init_vty("VirtHNBGW"); |
| 336 | } |
| 337 | |
| 338 | friend function f_shutdown_helper() runs on test_CT { |
| 339 | all component.stop; |
| 340 | setverdict(pass); |
| 341 | mtc.stop; |
| 342 | } |
| 343 | |
| 344 | /* helper function to start all of the simulated hNodeBs */ |
| 345 | function f_start_hnbs() runs on test_CT { |
| 346 | for (var integer i:= 0; i < NUM_HNB; i := i+1) { |
| 347 | f_hnbap_register(i); |
| 348 | } |
| 349 | } |
| 350 | |
| 351 | /*********************************************************************** |
| 352 | * code running in test_CT, preparing start of per-UE ConnHdlr |
| 353 | ***********************************************************************/ |
| 354 | |
| 355 | /* inbound RUA connection establishment on Iuh side */ |
| 356 | function IuhRanapCreateCallback(ContextId context_id, RUA_IEs.CN_DomainIndicator domain, charstring id) |
| 357 | runs on RUA_Emulation_CT return RUA_ConnHdlr { |
| 358 | log("CreateCallback"); |
| 359 | return null; |
| 360 | } |
| 361 | |
| 362 | /* inbound RUA connectionless data on Iuh side */ |
| 363 | function IuhRanapUnitdataCallback(RANAP_PDU ranap) |
| 364 | runs on RUA_Emulation_CT return template RANAP_PDU { |
| 365 | log("UnitdataCallback"); |
| 366 | return omit; |
| 367 | } |
| 368 | |
| 369 | private function f_start_handler_create(TestHdlrParams pars) runs on test_CT return ConnHdlr { |
| 370 | var ConnHdlr vc_conn; |
| 371 | var charstring id := testcasename() & int2str(pars.hnb_idx); |
| 372 | |
| 373 | vc_conn := ConnHdlr.create(id); |
| 374 | |
| 375 | /* Iuh RUA part */ |
| 376 | connect(vc_conn:RUA, vc_RUA[pars.hnb_idx]:CLIENT); |
| 377 | |
| 378 | if (pars.ps_domain) { |
| 379 | /* SGSN side */ |
| 380 | connect(vc_conn:BSSAP, g_sgsn.vc_RAN:CLIENT); |
| 381 | connect(vc_conn:BSSAP_PROC, g_sgsn.vc_RAN:PROC); |
| 382 | } else { |
| 383 | /* MSC side */ |
| 384 | connect(vc_conn:BSSAP, g_msc.vc_RAN:CLIENT); |
| 385 | connect(vc_conn:BSSAP_PROC, g_msc.vc_RAN:PROC); |
| 386 | } |
| 387 | /* MGCP part */ |
| 388 | connect(vc_conn:MGCP, vc_MGCP:MGCP_CLIENT); |
| 389 | connect(vc_conn:MGCP_PROC, vc_MGCP:MGCP_PROC); |
| 390 | |
| 391 | return vc_conn; |
| 392 | } |
| 393 | |
| 394 | private function f_start_handler_run(ConnHdlr vc_conn, void_fn fn, TestHdlrParams pars) runs on test_CT { |
| 395 | var charstring id := testcasename(); // & int2str(pars.ran_idx); |
| 396 | /* We cannot use vc_conn.start(f_init_handler(fn, id, pars)); as we cannot have |
| 397 | * a stand-alone 'derefers()' call, see https://www.eclipse.org/forums/index.php/t/1091364/ */ |
| 398 | pars.hnb := g_hnb_cfg[pars.hnb_idx]; |
| 399 | pars.mgcp_pars := valueof(t_MgcpParams); |
| 400 | vc_conn.start(derefers(fn)(id, pars)); |
| 401 | } |
| 402 | |
| 403 | function f_start_handler_with_pars(void_fn fn, template (value) TestHdlrParams pars) |
| 404 | runs on test_CT return ConnHdlr { |
| 405 | var ConnHdlr vc_conn; |
| 406 | vc_conn := f_start_handler_create(valueof(pars)); |
| 407 | f_start_handler_run(vc_conn, fn, valueof(pars)); |
| 408 | return vc_conn; |
| 409 | } |
| 410 | |
| 411 | /*********************************************************************** |
| 412 | * code running inside per-UE ConnHdlr |
| 413 | ***********************************************************************/ |
| 414 | |
| 415 | type function void_fn(charstring id, TestHdlrParams pars) runs on ConnHdlr; |
| 416 | |
| 417 | function f_init_handler(TestHdlrParams pars, float t_guard := 20.0) runs on ConnHdlr { |
| 418 | /* make parameters available via component variable */ |
| 419 | g_pars := pars; |
| 420 | /* start guard timer and activate it as default */ |
| 421 | g_Tguard.start(t_guard); |
| 422 | activate(as_Tguard_ConnHdlr()); |
| 423 | |
| 424 | /* TODO: CTRL? */ |
| 425 | /* TODO: VTY? */ |
| 426 | } |
| 427 | |
| 428 | /* global altstep for global guard timer; */ |
| 429 | private altstep as_Tguard_ConnHdlr() runs on ConnHdlr { |
| 430 | [] g_Tguard.timeout { |
| 431 | setverdict(fail, "Timeout of T_guard"); |
| 432 | mtc.stop; |
| 433 | } |
| 434 | } |
| 435 | |
| 436 | /* send RANAP on Iuh and expect it to show up on Iu */ |
| 437 | function f_iuh2iu(template (present) RANAP_PDU tx, template RANAP_PDU exp_rx := omit) |
| 438 | runs on ConnHdlr return RANAP_PDU { |
| 439 | var RANAP_PDU rx; |
| 440 | timer T := 5.0; |
| 441 | |
| 442 | if (istemplatekind(exp_rx, "omit")) { |
| 443 | exp_rx := tx; |
| 444 | } |
| 445 | |
| 446 | RUA.send(tx); |
| 447 | T.start; |
| 448 | |
| 449 | alt { |
| 450 | [] BSSAP.receive(exp_rx) -> value rx { |
| 451 | setverdict(pass); |
| 452 | } |
| 453 | [] T.timeout { |
| 454 | setverdict(fail, "Timeout waiting for Iu ", exp_rx); |
| 455 | } |
| 456 | } |
| 457 | return rx; |
| 458 | } |
| 459 | |
| 460 | /* send RANAP on Iu and expect it to show up on Iuh */ |
| 461 | function f_iu2iuh(template (present) RANAP_PDU tx, template RANAP_PDU exp_rx := omit) |
| 462 | runs on ConnHdlr return RANAP_PDU { |
| 463 | var RANAP_PDU rx; |
| 464 | timer T := 5.0; |
| 465 | |
| 466 | if (istemplatekind(exp_rx, "omit")) { |
| 467 | exp_rx := tx; |
| 468 | } |
| 469 | |
| 470 | BSSAP.send(tx); |
| 471 | T.start; |
| 472 | |
| 473 | alt { |
| 474 | [] RUA.receive(exp_rx) -> value rx { |
| 475 | setverdict(pass); |
| 476 | } |
| 477 | [] T.timeout { |
| 478 | setverdict(fail, "Timeout waiting for Iuh ", exp_rx); |
| 479 | } |
| 480 | } |
| 481 | return rx; |
| 482 | } |
| 483 | |
| 484 | /* send RANAP on Iuh and expect it to show up on Iu */ |
| 485 | function f_iuh2iu_connect(template (present) RANAP_PDU tx, template RANAP_PDU exp_rx := omit) |
| 486 | runs on ConnHdlr return RANAP_PDU { |
| 487 | var RANAP_PDU rx; |
| 488 | timer T := 5.0; |
| 489 | |
| 490 | if (istemplatekind(exp_rx, "omit")) { |
| 491 | exp_rx := tx; |
| 492 | } |
| 493 | |
| 494 | /* create an expect on the Iu side for the random NAS portion */ |
Neels Hofmeyr | f0b9ed1 | 2022-06-07 17:46:32 +0200 | [diff] [blame] | 495 | if (g_pars.separate_sccp_cr) { |
| 496 | f_ran_register_sccp_cr_without_payload(); |
| 497 | } else { |
| 498 | var template (omit) octetstring nas := f_ranap_extract_l3(valueof(tx)); |
| 499 | f_ran_register_exp(valueof(nas)); |
| 500 | } |
Daniel Willmann | 19b8d90 | 2022-01-05 09:12:34 +0100 | [diff] [blame] | 501 | |
| 502 | /* send it via Iuh (creating a RUA connection) */ |
| 503 | RUA.send(RUA_Conn_Req:{g_pars.ps_domain, tx}); |
| 504 | |
Neels Hofmeyr | f0b9ed1 | 2022-06-07 17:46:32 +0200 | [diff] [blame] | 505 | if (g_pars.separate_sccp_cr) { |
| 506 | /* Acknowledge the empty SCCP CR. RAN_Emulation does the confirmation, no need to respond. */ |
| 507 | BSSAP.receive(tr_RANAP_Conn_Req()); |
| 508 | } |
| 509 | |
Daniel Willmann | 19b8d90 | 2022-01-05 09:12:34 +0100 | [diff] [blame] | 510 | /* expect to receive it on the Iu side */ |
| 511 | T.start; |
| 512 | alt { |
| 513 | [] BSSAP.receive(exp_rx) -> value rx { |
| 514 | setverdict(pass); |
| 515 | } |
| 516 | [] T.timeout { |
| 517 | setverdict(fail, "Timeout waiting for Iu ", exp_rx); |
| 518 | } |
| 519 | } |
| 520 | return rx; |
| 521 | } |
| 522 | |
| 523 | function f_iuh2iu_disconnect(template (present) RANAP_PDU tx, RUA_IEs.Cause cause, |
| 524 | template RANAP_PDU exp_rx := omit) |
| 525 | runs on ConnHdlr return RANAP_PDU { |
| 526 | var RANAP_PDU rx |
| 527 | timer T := 5.0; |
| 528 | |
| 529 | if (istemplatekind(exp_rx, "omit")) { |
| 530 | exp_rx := tx; |
| 531 | } |
| 532 | |
| 533 | /* send it via Iuh (creating a RUA connection) */ |
| 534 | RUA.send(RUA_Disc_Req:{tx, cause}); |
| 535 | |
| 536 | /* expect to receive it on the Iu side */ |
| 537 | T.start; |
| 538 | alt { |
| 539 | [] BSSAP.receive(exp_rx) -> value rx { |
| 540 | } |
| 541 | [] T.timeout { |
| 542 | setverdict(fail, "Timeout waiting for Iu ", exp_rx); |
| 543 | return rx; |
| 544 | } |
| 545 | } |
| 546 | |
| 547 | /* expect disconnect on the Iu side */ |
| 548 | alt { |
| 549 | [] BSSAP.receive(RAN_Conn_Prim:MSC_CONN_PRIM_DISC_IND) { |
| 550 | setverdict(pass); |
| 551 | } |
| 552 | [] T.timeout { |
| 553 | setverdict(fail, "Timeout waiting for Iu disconnect"); |
| 554 | return rx; |
| 555 | } |
| 556 | |
| 557 | } |
| 558 | return rx; |
| 559 | } |
| 560 | |
| 561 | /* build a RANAP InitialUE based on the TestHdlrParams */ |
| 562 | friend function f_build_initial_ue(TestHdlrParams pars) return RANAP_PDU { |
| 563 | var LAI lai := { |
| 564 | pLMNidentity := hex2oct(pars.hnb.lai.mcc_mnc), |
| 565 | lAC := int2oct(pars.hnb.lai.lac, 2), |
| 566 | iE_Extensions := omit |
| 567 | }; |
| 568 | var SAI sai := { |
| 569 | pLMNidentity := lai.pLMNidentity, |
| 570 | lAC := lai.lAC, |
| 571 | sAC := int2oct(pars.hnb.sac, 2), |
| 572 | iE_Extensions := omit |
| 573 | } |
| 574 | var octetstring nas := f_rnd_octstring(10); |
| 575 | var IuSignallingConnectionIdentifier sigc_id := int2bit(f_rnd_int(1000), 24); |
| 576 | var GlobalRNC_ID grnc_id := { |
| 577 | pLMNidentity := lai.pLMNidentity, |
| 578 | rNC_ID := 2342 |
| 579 | } |
| 580 | |
| 581 | if (pars.ps_domain) { |
| 582 | var RAC rac := '00'O; |
| 583 | return valueof(ts_RANAP_initialUE_PS(lai, rac, sai, nas, sigc_id, grnc_id)); |
| 584 | } else { |
| 585 | return valueof(ts_RANAP_initialUE_CS(lai, sai, nas, sigc_id, grnc_id)); |
| 586 | } |
| 587 | } |
| 588 | |
| 589 | /* build a RANAP RAB AssignmentResponse based on the TestHdlrParams */ |
| 590 | friend function f_build_rab_ass_resp(TestHdlrParams pars) return RANAP_PDU { |
| 591 | var template RAB_SetupOrModifiedList rab_sml; |
| 592 | |
| 593 | rab_sml := ts_RAB_SMdL(t_RAB_id(23), f_ts_RAB_TLA("192.168.1.23"), t_RAB_binding_port(1234)); |
| 594 | |
| 595 | return valueof(ts_RANAP_RabAssResp(rab_sml)); |
| 596 | } |
| 597 | |
| 598 | |
| 599 | /*********************************************************************** |
| 600 | * HNBAP Testing |
| 601 | ***********************************************************************/ |
| 602 | |
| 603 | |
| 604 | function f_hnbap_register(integer hnb_idx := 0) runs on test_CT |
| 605 | { |
| 606 | timer T := 2.0; |
| 607 | |
| 608 | HNBAP[hnb_idx].send(tr_HNBAP_HNBRegisterRequest(char2oct("TTCN3 HNodeB"), |
| 609 | '00F110'O, |
| 610 | int2bit(1 + hnb_idx, 28), |
| 611 | int2oct(2, 2), |
| 612 | int2oct(3, 1), |
| 613 | int2oct(4, 2))); |
| 614 | |
| 615 | T.start; |
| 616 | alt { |
| 617 | [] HNBAP[hnb_idx].receive(tr_HNBAP_HNBRegisterAccept(?)) { |
| 618 | setverdict(pass); |
| 619 | } |
| 620 | [] HNBAP[hnb_idx].receive(IUHEM_Event:?) { |
| 621 | repeat; |
| 622 | } |
| 623 | [] T.timeout { |
| 624 | setverdict(fail, "Timeout waiting for HNB Register Accept"); |
| 625 | } |
| 626 | } |
| 627 | } |
| 628 | |
| 629 | testcase TC_hnb_register() runs on test_CT { |
| 630 | f_init(); |
| 631 | f_hnbap_register(0); |
| 632 | f_shutdown_helper(); |
| 633 | } |
| 634 | |
| 635 | /*********************************************************************** |
| 636 | * RUA / RANAP Testing |
| 637 | ***********************************************************************/ |
| 638 | |
| 639 | private template (value) TestHdlrParams |
Neels Hofmeyr | f0b9ed1 | 2022-06-07 17:46:32 +0200 | [diff] [blame] | 640 | t_pars(integer imsi_suffix, boolean ps_domain := false, integer hnb_idx := 0, |
| 641 | boolean separate_sccp_cr := false) := { |
Daniel Willmann | 19b8d90 | 2022-01-05 09:12:34 +0100 | [diff] [blame] | 642 | hnb_idx := hnb_idx, |
| 643 | imsi := f_gen_imsi(imsi_suffix), |
| 644 | ps_domain := ps_domain, |
Neels Hofmeyr | f0b9ed1 | 2022-06-07 17:46:32 +0200 | [diff] [blame] | 645 | hnb := omit, /* filled in later */ |
| 646 | separate_sccp_cr := separate_sccp_cr |
Daniel Willmann | 19b8d90 | 2022-01-05 09:12:34 +0100 | [diff] [blame] | 647 | } |
| 648 | |
| 649 | /* Create an Iuh connection; send InitialUE; expect it to appear on new SCCP conenction */ |
| 650 | friend function f_tc_initial_ue(charstring id, TestHdlrParams pars) runs on ConnHdlr { |
| 651 | f_init_handler(pars); |
| 652 | var RANAP_PDU tx := f_build_initial_ue(g_pars); |
| 653 | f_iuh2iu_connect(tx); |
| 654 | } |
| 655 | testcase TC_ranap_cs_initial_ue() runs on test_CT { |
| 656 | var ConnHdlr vc_conn; |
| 657 | |
| 658 | f_init(); |
| 659 | f_start_hnbs(); |
| 660 | |
| 661 | vc_conn := f_start_handler_with_pars(refers(f_tc_initial_ue), t_pars(1)); |
| 662 | vc_conn.done; |
| 663 | } |
| 664 | testcase TC_ranap_ps_initial_ue() runs on test_CT { |
| 665 | var ConnHdlr vc_conn; |
| 666 | |
| 667 | f_init(); |
| 668 | f_start_hnbs(); |
| 669 | |
| 670 | vc_conn := f_start_handler_with_pars(refers(f_tc_initial_ue), t_pars(2, true)); |
| 671 | vc_conn.done; |
| 672 | } |
| 673 | |
Neels Hofmeyr | f0b9ed1 | 2022-06-07 17:46:32 +0200 | [diff] [blame] | 674 | private function f_vty_set_sccp_cr_max_payload_len(TELNETasp_PT pt, integer val := 999999) |
| 675 | { |
| 676 | f_vty_enter_config(pt); |
| 677 | f_vty_transceive(pt, "hnbgw"); |
| 678 | f_vty_transceive(pt, "sccp cr max-payload-len " & int2str(val)); |
| 679 | f_vty_transceive(pt, "end"); |
| 680 | } |
| 681 | |
| 682 | testcase TC_ranap_cs_initial_ue_empty_cr() runs on test_CT { |
| 683 | var ConnHdlr vc_conn; |
| 684 | |
| 685 | f_init(); |
| 686 | f_start_hnbs(); |
| 687 | |
| 688 | f_vty_set_sccp_cr_max_payload_len(HNBGWVTY, 0); |
| 689 | |
| 690 | vc_conn := f_start_handler_with_pars(refers(f_tc_initial_ue), t_pars(1, separate_sccp_cr := true)); |
| 691 | vc_conn.done; |
| 692 | |
| 693 | /* reset */ |
| 694 | f_vty_set_sccp_cr_max_payload_len(HNBGWVTY); |
| 695 | } |
| 696 | testcase TC_ranap_ps_initial_ue_empty_cr() runs on test_CT { |
| 697 | var ConnHdlr vc_conn; |
| 698 | |
| 699 | f_init(); |
| 700 | f_start_hnbs(); |
| 701 | |
| 702 | f_vty_set_sccp_cr_max_payload_len(HNBGWVTY, 0); |
| 703 | |
| 704 | vc_conn := f_start_handler_with_pars(refers(f_tc_initial_ue), t_pars(2, true, separate_sccp_cr := true)); |
| 705 | vc_conn.done; |
| 706 | |
| 707 | /* reset */ |
| 708 | f_vty_set_sccp_cr_max_payload_len(HNBGWVTY); |
| 709 | } |
| 710 | |
Daniel Willmann | 19b8d90 | 2022-01-05 09:12:34 +0100 | [diff] [blame] | 711 | /* Reply to a received CRCX with an OK (or the reply configured in cpars), using the given parameters. |
| 712 | * Return true when an OK reply was sent, false otherwise. |
| 713 | * Count occurrence of Osmux, include Osmux parameters in the reply if necessary. */ |
| 714 | function f_handle_crcx(inout MgcpParameters pars, MgcpCommand mgcp_cmd) return template MgcpResponse { |
| 715 | var CrcxResponse conn := pars.mgw_conn_1; |
| 716 | if (pars.got_crcx_count > 0) { |
| 717 | conn := pars.mgw_conn_2; |
| 718 | } |
| 719 | pars.got_crcx_count := pars.got_crcx_count + 1; |
| 720 | |
| 721 | var MgcpMessage mgcp_msg := { |
| 722 | command := mgcp_cmd |
| 723 | } |
| 724 | var template MgcpResponse mgcp_resp; |
| 725 | var MgcpOsmuxCID osmux_cid; |
| 726 | var MgcpCallId call_id := f_MgcpCmd_extract_call_id(mgcp_cmd); |
| 727 | if (ispresent(pars.mgcp_call_id)) { |
| 728 | if (pars.mgcp_call_id != call_id) { |
| 729 | setverdict(fail, "CRCX contained unexpected call id. Expected:", pars.mgcp_call_id, " got:", call_id); |
| 730 | mtc.stop; |
| 731 | } |
| 732 | } else { |
| 733 | pars.mgcp_call_id := call_id; |
| 734 | } |
| 735 | |
| 736 | /* When the endpoint contains a wildcard we keep the endpoint |
| 737 | * identifier we have set up in pars. Otherwise we use the |
| 738 | * endpoint name that the call agent has supplied */ |
| 739 | if (match(mgcp_cmd.line.ep, t_MGCP_EP_wildcard) == false) { |
| 740 | pars.mgcp_ep := mgcp_cmd.line.ep; |
| 741 | } |
| 742 | |
| 743 | if (conn.resp == -1) { |
| 744 | /* Reply with rror */ |
| 745 | var MgcpResponse mgcp_rsp := { |
| 746 | line := { |
| 747 | code := "542", |
| 748 | trans_id := mgcp_cmd.line.trans_id, |
| 749 | string := "FORCED_FAIL" |
| 750 | }, |
| 751 | sdp := omit |
| 752 | |
| 753 | } |
| 754 | var MgcpParameter mgcp_rsp_param := { |
| 755 | code := "Z", |
| 756 | val := pars.mgcp_ep |
| 757 | }; |
| 758 | mgcp_rsp.params[0] := mgcp_rsp_param; |
| 759 | return mgcp_rsp; |
| 760 | } |
| 761 | |
| 762 | if (conn.resp == 0) { |
| 763 | /* Do not reply at all */ |
| 764 | return omit; |
| 765 | } |
| 766 | |
| 767 | if (conn.resp != 1) { |
| 768 | setverdict(fail, "Unexpected value for pars.mgw_conn_*.resp, expect -1, 0 or 1"); |
| 769 | mtc.stop; |
| 770 | } |
| 771 | |
| 772 | var SDP_Message sdp := valueof(ts_SDP(conn.mgw_rtp_ip, conn.mgw_rtp_ip, |
| 773 | hex2str(pars.mgcp_call_id), "42", |
| 774 | conn.mgw_rtp_port, |
| 775 | { int2str(pars.rtp_payload_type) }, |
| 776 | { valueof(ts_SDP_rtpmap(pars.rtp_payload_type, |
| 777 | pars.rtp_sdp_format)), |
| 778 | valueof(ts_SDP_ptime(20)) })); |
| 779 | |
| 780 | if (f_mgcp_contains_par(mgcp_msg, "X-OSMUX")) { |
| 781 | if (not pars.use_osmux) { |
| 782 | setverdict(fail, "MSC sent X-Osmux parameter in MGCP, but not expecting any Osmux"); |
| 783 | mtc.stop; |
| 784 | } |
| 785 | pars.got_osmux_count := pars.got_osmux_count + 1; |
| 786 | /* we expect MSC to use wildcard here, i.e. osmux_cid == -1 */ |
| 787 | osmux_cid := f_MgcpCmd_extract_osmux_cid(mgcp_cmd); |
| 788 | log("f_handle_crcx(): got Osmux CID: ", osmux_cid); |
| 789 | if (osmux_cid != -1) { |
| 790 | setverdict(fail, "MSC using unexpected CID " & int2str(osmux_cid) & " != -1"); |
| 791 | mtc.stop; |
| 792 | } |
| 793 | |
| 794 | osmux_cid := 0; |
| 795 | mgcp_resp := ts_CRCX_ACK_osmux(mgcp_cmd.line.trans_id, conn.mgcp_connection_id, osmux_cid, sdp); |
| 796 | } else { |
| 797 | mgcp_resp := ts_CRCX_ACK(mgcp_cmd.line.trans_id, conn.mgcp_connection_id, sdp); |
| 798 | } |
| 799 | |
| 800 | f_mgcp_par_append(mgcp_resp.params, ts_MgcpParSpecEP(pars.mgcp_ep)); |
| 801 | |
| 802 | return mgcp_resp; |
| 803 | } |
| 804 | |
Daniel Willmann | 3e15b7b | 2022-02-21 17:07:02 +0100 | [diff] [blame] | 805 | friend function f_create_rab(inout MgcpParameters pars) runs on ConnHdlr { |
| 806 | f_rab_ass_req(pars); |
| 807 | f_rab_ass_resp(pars); |
| 808 | } |
| 809 | |
| 810 | friend function f_rab_ass_req(inout MgcpParameters pars) runs on ConnHdlr { |
Daniel Willmann | 19b8d90 | 2022-01-05 09:12:34 +0100 | [diff] [blame] | 811 | var MgcpCommand mgcp_cmd; |
| 812 | var RANAP_PDU tx; |
| 813 | var template RAB_SetupOrModifyList rab_sml; |
Daniel Willmann | 19b8d90 | 2022-01-05 09:12:34 +0100 | [diff] [blame] | 814 | timer T := 5.0; |
| 815 | |
| 816 | /* Send RAB Assignment Request */ |
| 817 | 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)); |
| 818 | tx := valueof(ts_RANAP_RabAssReq(rab_sml)); |
| 819 | BSSAP.send(tx); |
| 820 | T.start; |
| 821 | |
| 822 | /* Handle MGCP CRCX */ |
| 823 | alt { |
| 824 | [] MGCP.receive(tr_CRCX) -> value mgcp_cmd { |
| 825 | log("CRCX1", mgcp_cmd); |
| 826 | var template MgcpResponse mgcp_rsp := f_handle_crcx(pars, mgcp_cmd); |
| 827 | MGCP.send(valueof(mgcp_rsp)); |
| 828 | } |
| 829 | [] T.timeout { |
| 830 | setverdict(fail, "Timeout waiting for MGCP"); |
| 831 | } |
| 832 | } |
| 833 | |
| 834 | /* Expect RAB Assignment Request with IP/port from CRCX ACK via Iuh */ |
| 835 | rab_sml := ts_RAB_SML(t_RAB_id(23), f_ts_RAB_TLA(pars.mgw_conn_1.mgw_rtp_ip), t_RAB_binding_port(pars.mgw_conn_1.mgw_rtp_port)); |
| 836 | tx := valueof(ts_RANAP_RabAssReq(rab_sml)); |
| 837 | |
| 838 | alt { |
| 839 | [] RUA.receive(tx) { |
| 840 | setverdict(pass); |
| 841 | } |
| 842 | [] T.timeout { |
| 843 | setverdict(fail, "Timeout waiting for Iuh ", tx); |
| 844 | } |
| 845 | } |
Daniel Willmann | 3e15b7b | 2022-02-21 17:07:02 +0100 | [diff] [blame] | 846 | } |
| 847 | |
| 848 | friend function f_rab_ass_resp(inout MgcpParameters pars) runs on ConnHdlr { |
| 849 | var MgcpCommand mgcp_cmd; |
| 850 | var RANAP_PDU tx; |
| 851 | var template RAB_SetupOrModifiedList rab_smdl; |
| 852 | timer T := 5.0; |
Daniel Willmann | 19b8d90 | 2022-01-05 09:12:34 +0100 | [diff] [blame] | 853 | |
| 854 | /* Send back RAB Assignment Response via Iuh */ |
| 855 | 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)); |
| 856 | tx := valueof(ts_RANAP_RabAssResp(rab_smdl)); |
| 857 | RUA.send(tx); |
| 858 | T.start; |
| 859 | |
| 860 | interleave { |
| 861 | /* Expect MDCX with IP/port from RAB Assignment Response */ |
| 862 | [] MGCP.receive(tr_MDCX(tr_SDP(pars.hnb_rtp_ip, pars.hnb_rtp_port))) -> value mgcp_cmd { |
| 863 | log("MDCX1", mgcp_cmd); |
| 864 | /* Verify SDP of MDCX */ |
| 865 | var SDP_Message sdp := valueof(ts_SDP(pars.mgw_conn_1.mgw_rtp_ip, pars.mgw_conn_1.mgw_rtp_ip, hex2str(pars.mgcp_call_id), "42", pars.mgw_conn_1.mgw_rtp_port, |
| 866 | { int2str(pars.rtp_payload_type) }, { valueof(ts_SDP_rtpmap(pars.rtp_payload_type, pars.rtp_sdp_format)), valueof(ts_SDP_ptime(20)) } )); |
| 867 | var template MgcpResponse mgcp_rsp := ts_MDCX_ACK(mgcp_cmd.line.trans_id, pars.mgw_conn_1.mgcp_connection_id, sdp); |
| 868 | MGCP.send(valueof(mgcp_rsp)); |
| 869 | } |
| 870 | /* Handle CRCX for second leg of endpoint, answer with IP/port */ |
| 871 | [] MGCP.receive(tr_CRCX(pars.mgcp_ep, tr_SDP(pars.cn_rtp_ip, pars.cn_rtp_port))) -> value mgcp_cmd { |
| 872 | log("CRCX2", mgcp_cmd); |
| 873 | /* Verify SDP of CRCX */ |
| 874 | var template MgcpResponse mgcp_rsp := f_handle_crcx(pars, mgcp_cmd); |
| 875 | MGCP.send(valueof(mgcp_rsp)); |
| 876 | } |
| 877 | } |
| 878 | |
| 879 | /* Expect RAB Assignment Response with IP/port from second CRCX ACK */ |
| 880 | rab_smdl := ts_RAB_SMdL(t_RAB_id(23), f_ts_RAB_TLA(pars.mgw_conn_2.mgw_rtp_ip), t_RAB_binding_port(pars.mgw_conn_2.mgw_rtp_port)); |
| 881 | tx := valueof(ts_RANAP_RabAssResp(rab_smdl)); |
| 882 | |
| 883 | alt { |
| 884 | [] BSSAP.receive(tx) { |
| 885 | setverdict(pass); |
| 886 | } |
| 887 | [] T.timeout { |
| 888 | setverdict(fail, "Timeout waiting for Iuh ", tx); |
| 889 | } |
| 890 | } |
| 891 | } |
| 892 | |
| 893 | private altstep as_mgcp_dlcx(inout TestHdlrParams pars) runs on ConnHdlr { |
| 894 | var MgcpCommand mgcp_cmd; |
| 895 | |
| 896 | [] MGCP.receive(tr_DLCX(pars.mgcp_pars.mgcp_ep)) -> value mgcp_cmd { |
| 897 | log("DLCX", mgcp_cmd); |
| 898 | MGCP.send(ts_DLCX_ACK2(mgcp_cmd.line.trans_id)); |
| 899 | pars.mgcp_pars.got_dlcx_count := pars.mgcp_pars.got_dlcx_count + 1; |
Daniel Willmann | 3e15b7b | 2022-02-21 17:07:02 +0100 | [diff] [blame] | 900 | if (pars.mgcp_pars.got_dlcx_count != pars.mgcp_pars.got_crcx_count) { |
Daniel Willmann | 19b8d90 | 2022-01-05 09:12:34 +0100 | [diff] [blame] | 901 | repeat; |
| 902 | } |
| 903 | setverdict(pass); |
| 904 | } |
| 905 | } |
| 906 | |
| 907 | friend function f_tc_rab_assignment(charstring id, TestHdlrParams pars) runs on ConnHdlr { |
| 908 | var MgcpCommand mgcp_cmd; |
| 909 | var RANAP_PDU tx; |
| 910 | timer T := 5.0; |
| 911 | |
| 912 | f_init_handler(pars); |
| 913 | f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit}); |
| 914 | |
| 915 | tx := f_build_initial_ue(g_pars); |
| 916 | f_iuh2iu_connect(tx); |
| 917 | |
| 918 | f_create_rab(pars.mgcp_pars); |
| 919 | |
| 920 | /* Send Iu Release */ |
| 921 | tx := valueof(ts_RANAP_IuReleaseCommand(ts_RanapCause_om_intervention)); |
| 922 | f_iu2iuh(tx); |
| 923 | |
| 924 | T.start; |
| 925 | alt { |
| 926 | [] as_mgcp_dlcx(pars) {} |
| 927 | [] T.timeout { |
| 928 | setverdict(fail, "Timeout waiting for DLCX"); |
| 929 | } |
| 930 | } |
| 931 | |
| 932 | tx := valueof(ts_RANAP_IuReleaseComplete()); |
| 933 | f_iuh2iu(tx); |
| 934 | } |
| 935 | |
| 936 | testcase TC_rab_assignment() runs on test_CT { |
| 937 | var ConnHdlr vc_conn; |
| 938 | f_init(); |
| 939 | f_start_hnbs(); |
| 940 | |
| 941 | vc_conn := f_start_handler_with_pars(refers(f_tc_rab_assignment), t_pars(3)); |
| 942 | vc_conn.done; |
| 943 | } |
| 944 | |
Daniel Willmann | 3e15b7b | 2022-02-21 17:07:02 +0100 | [diff] [blame] | 945 | friend function f_tc_rab_assign_fail(charstring id, TestHdlrParams pars) runs on ConnHdlr { |
| 946 | var MgcpCommand mgcp_cmd; |
| 947 | var RANAP_PDU tx; |
| 948 | timer T := 5.0; |
| 949 | |
| 950 | f_init_handler(pars); |
| 951 | f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit}); |
| 952 | |
| 953 | tx := f_build_initial_ue(g_pars); |
| 954 | f_iuh2iu_connect(tx); |
| 955 | |
| 956 | f_rab_ass_req(pars.mgcp_pars); |
| 957 | |
| 958 | /* Send RAB failed list in response */ |
| 959 | tx := valueof(ts_RANAP_RabAssResp(rab_fl := ts_RAB_FL(t_RAB_id(23), ts_RanapCause_om_intervention))); |
| 960 | f_iuh2iu(tx); |
| 961 | |
| 962 | T.start; |
| 963 | alt { |
| 964 | [] as_mgcp_dlcx(pars) {} |
| 965 | [] T.timeout { |
| 966 | setverdict(fail, "Timeout waiting for DLCX"); |
| 967 | } |
| 968 | } |
| 969 | } |
| 970 | |
| 971 | testcase TC_rab_assign_fail() runs on test_CT { |
| 972 | var ConnHdlr vc_conn; |
| 973 | f_init(); |
| 974 | f_start_hnbs(); |
| 975 | |
| 976 | vc_conn := f_start_handler_with_pars(refers(f_tc_rab_assign_fail), t_pars(4)); |
| 977 | vc_conn.done; |
| 978 | } |
| 979 | |
Daniel Willmann | 19b8d90 | 2022-01-05 09:12:34 +0100 | [diff] [blame] | 980 | friend function f_tc_rab_release(charstring id, TestHdlrParams pars) runs on ConnHdlr { |
| 981 | var MgcpCommand mgcp_cmd; |
| 982 | var RANAP_PDU tx; |
| 983 | timer T := 15.0; |
| 984 | |
| 985 | f_init_handler(pars); |
| 986 | f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit}); |
| 987 | |
| 988 | tx := f_build_initial_ue(g_pars); |
| 989 | f_iuh2iu_connect(tx); |
| 990 | |
| 991 | f_create_rab(pars.mgcp_pars); |
| 992 | |
| 993 | /* Send RAB Release */ |
Daniel Willmann | 9e789be | 2022-02-22 13:30:51 +0100 | [diff] [blame] | 994 | tx := valueof(ts_RANAP_RabAssReq(rab_rl := ts_RAB_RL(t_RAB_id(23), ts_RanapCause_om_intervention))); |
Daniel Willmann | 19b8d90 | 2022-01-05 09:12:34 +0100 | [diff] [blame] | 995 | BSSAP.send(tx); |
| 996 | |
| 997 | T.start; |
| 998 | |
| 999 | alt { |
| 1000 | [] as_mgcp_dlcx(pars) {} |
| 1001 | [] T.timeout { |
| 1002 | setverdict(fail, "Timeout waiting for DLCX"); |
| 1003 | } |
| 1004 | } |
| 1005 | |
| 1006 | alt { |
| 1007 | [] RUA.receive(tx) { |
| 1008 | setverdict(pass); |
| 1009 | } |
| 1010 | [] T.timeout { |
| 1011 | setverdict(fail, "Timeout waiting for Iuh ", tx); |
| 1012 | } |
| 1013 | } |
| 1014 | |
| 1015 | } |
| 1016 | |
| 1017 | testcase TC_rab_release() runs on test_CT { |
| 1018 | var ConnHdlr vc_conn; |
| 1019 | f_init(); |
| 1020 | f_start_hnbs(); |
| 1021 | |
| 1022 | vc_conn := f_start_handler_with_pars(refers(f_tc_rab_release), t_pars(5)); |
| 1023 | vc_conn.done; |
| 1024 | } |
| 1025 | |
Daniel Willmann | 37c877f | 2022-02-22 16:47:06 +0100 | [diff] [blame] | 1026 | friend function f_tc_rab_assign_mgcp_to(charstring id, TestHdlrParams pars) runs on ConnHdlr { |
| 1027 | var MgcpCommand mgcp_cmd; |
| 1028 | var RANAP_PDU tx; |
| 1029 | var template RAB_SetupOrModifyList rab_sml; |
| 1030 | timer T := 15.0; |
| 1031 | |
| 1032 | T.start; |
| 1033 | f_init_handler(pars); |
| 1034 | f_create_mgcp_expect(ExpectCriteria:{omit,omit,omit}); |
| 1035 | |
| 1036 | tx := f_build_initial_ue(g_pars); |
| 1037 | f_iuh2iu_connect(tx); |
| 1038 | |
| 1039 | |
| 1040 | /* Send RAB Assignment Request */ |
| 1041 | 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)); |
| 1042 | tx := valueof(ts_RANAP_RabAssReq(rab_sml)); |
| 1043 | BSSAP.send(tx); |
| 1044 | |
| 1045 | /* Ignore MGCP CRCX */ |
| 1046 | alt { |
| 1047 | [] MGCP.receive(tr_CRCX) -> value mgcp_cmd { |
| 1048 | log("Ignoreing CRCX1", mgcp_cmd); |
| 1049 | repeat; |
| 1050 | } |
| 1051 | [] BSSAP.receive(tr_RANAP_IuReleaseRequest(?)) { } |
| 1052 | [] T.timeout { |
| 1053 | setverdict(fail, "Timeout waiting for IuRelease"); |
| 1054 | } |
| 1055 | } |
| 1056 | |
| 1057 | /* Send Iu Release */ |
| 1058 | tx := valueof(ts_RANAP_IuReleaseCommand(ts_RanapCause_om_intervention)); |
| 1059 | f_iu2iuh(tx); |
| 1060 | |
| 1061 | tx := valueof(ts_RANAP_IuReleaseComplete()); |
| 1062 | f_iuh2iu(tx); |
| 1063 | } |
| 1064 | |
| 1065 | testcase TC_rab_assign_mgcp_to() runs on test_CT { |
| 1066 | var ConnHdlr vc_conn; |
| 1067 | f_init(); |
| 1068 | f_start_hnbs(); |
| 1069 | |
| 1070 | vc_conn := f_start_handler_with_pars(refers(f_tc_rab_assign_mgcp_to), t_pars(6)); |
| 1071 | vc_conn.done; |
| 1072 | } |
| 1073 | |
Daniel Willmann | 19b8d90 | 2022-01-05 09:12:34 +0100 | [diff] [blame] | 1074 | /* Create an Iuh connection; send InitialUE; transceive data both directions */ |
| 1075 | friend function f_tc_ranap_bidir(charstring id, TestHdlrParams pars) runs on ConnHdlr { |
| 1076 | f_init_handler(pars); |
| 1077 | |
| 1078 | /* HNB -> MSC: InitialUE */ |
| 1079 | f_iuh2iu_connect(f_build_initial_ue(g_pars)); |
| 1080 | |
| 1081 | /* MSC <- HNB: DirectTransfer */ |
| 1082 | f_iu2iuh(ts_RANAP_DirectTransfer(f_rnd_octstring(10))); |
| 1083 | /* MSC -> HNB: DirectTransfer */ |
| 1084 | f_iuh2iu(ts_RANAP_DirectTransfer(f_rnd_octstring(10))); |
| 1085 | |
| 1086 | /* HNB <- MSC: CommonID */ |
| 1087 | f_iu2iuh(ts_RANAP_CommonId(hex2oct(pars.imsi))); |
| 1088 | } |
| 1089 | testcase TC_ranap_cs_bidir() runs on test_CT { |
| 1090 | var ConnHdlr vc_conn; |
| 1091 | |
| 1092 | f_init(); |
| 1093 | f_start_hnbs(); |
| 1094 | |
| 1095 | vc_conn := f_start_handler_with_pars(refers(f_tc_ranap_bidir), t_pars(3)); |
| 1096 | vc_conn.done; |
| 1097 | } |
| 1098 | testcase TC_ranap_ps_bidir() runs on test_CT { |
| 1099 | var ConnHdlr vc_conn; |
| 1100 | |
| 1101 | f_init(); |
| 1102 | f_start_hnbs(); |
| 1103 | |
| 1104 | vc_conn := f_start_handler_with_pars(refers(f_tc_ranap_bidir), t_pars(4, true)); |
| 1105 | vc_conn.done; |
| 1106 | } |
| 1107 | |
| 1108 | |
| 1109 | private function f_tc_ranap_mo_disconnect(charstring id, TestHdlrParams pars) runs on ConnHdlr { |
| 1110 | f_init_handler(pars); |
| 1111 | |
| 1112 | /* HNB -> MSC: InitialUE */ |
| 1113 | f_iuh2iu_connect(f_build_initial_ue(g_pars)); |
| 1114 | |
| 1115 | /* MSC <- HNB: DirectTransfer */ |
| 1116 | f_iu2iuh(ts_RANAP_DirectTransfer(f_rnd_octstring(10))); |
| 1117 | /* MSC -> HNB: DirectTransfer */ |
| 1118 | f_iuh2iu(ts_RANAP_DirectTransfer(f_rnd_octstring(10))); |
| 1119 | |
| 1120 | /* MSC <- HNB: RUA disconnect */ |
| 1121 | f_iuh2iu_disconnect(ts_RANAP_IuReleaseComplete, RUA_IEs.Cause:{misc:=processing_overload}); |
| 1122 | } |
| 1123 | testcase TC_ranap_cs_mo_disconnect() runs on test_CT { |
| 1124 | var ConnHdlr vc_conn; |
| 1125 | |
| 1126 | f_init(); |
| 1127 | f_start_hnbs(); |
| 1128 | |
| 1129 | vc_conn := f_start_handler_with_pars(refers(f_tc_ranap_mo_disconnect), t_pars(5)); |
| 1130 | vc_conn.done; |
| 1131 | } |
| 1132 | testcase TC_ranap_ps_mo_disconnect() runs on test_CT { |
| 1133 | var ConnHdlr vc_conn; |
| 1134 | |
| 1135 | f_init(); |
| 1136 | f_start_hnbs(); |
| 1137 | |
| 1138 | vc_conn := f_start_handler_with_pars(refers(f_tc_ranap_mo_disconnect), t_pars(6)); |
| 1139 | vc_conn.done; |
| 1140 | } |
| 1141 | |
| 1142 | |
| 1143 | |
| 1144 | |
| 1145 | control { |
| 1146 | execute(TC_hnb_register()); |
| 1147 | execute(TC_ranap_cs_initial_ue()); |
| 1148 | execute(TC_ranap_ps_initial_ue()); |
Neels Hofmeyr | f0b9ed1 | 2022-06-07 17:46:32 +0200 | [diff] [blame] | 1149 | execute(TC_ranap_cs_initial_ue_empty_cr()); |
| 1150 | execute(TC_ranap_ps_initial_ue_empty_cr()); |
Daniel Willmann | 19b8d90 | 2022-01-05 09:12:34 +0100 | [diff] [blame] | 1151 | execute(TC_ranap_cs_bidir()); |
| 1152 | execute(TC_ranap_ps_bidir()); |
| 1153 | execute(TC_rab_assignment()); |
| 1154 | execute(TC_rab_release()); |
Daniel Willmann | 3e15b7b | 2022-02-21 17:07:02 +0100 | [diff] [blame] | 1155 | execute(TC_rab_assign_fail()); |
Daniel Willmann | 37c877f | 2022-02-22 16:47:06 +0100 | [diff] [blame] | 1156 | execute(TC_rab_assign_mgcp_to()); |
Daniel Willmann | 19b8d90 | 2022-01-05 09:12:34 +0100 | [diff] [blame] | 1157 | execute(TC_ranap_cs_mo_disconnect()); |
| 1158 | execute(TC_ranap_ps_mo_disconnect()); |
| 1159 | } |
| 1160 | |
| 1161 | } |