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