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