Alexander Couzens | 20cd41e | 2021-01-11 02:56:03 +0100 | [diff] [blame] | 1 | module NS_Tests { |
| 2 | |
| 3 | /* Osmocom NS test suite for NS over framerelay or udp ip.access style in TTCN-3 |
| 4 | * (C) 2021 sysmocom s.f.m.c. GmbH <info@sysmocom.de> |
| 5 | * Author: Alexander Couzens <lynxis@fe80.eu> |
| 6 | * All rights reserved. |
| 7 | * |
| 8 | * Released under the terms of GNU General Public License, Version 2 or |
| 9 | * (at your option) any later version. |
| 10 | * |
| 11 | * SPDX-License-Identifier: GPL-2.0-or-later |
| 12 | */ |
| 13 | |
| 14 | import from General_Types all; |
| 15 | import from Osmocom_Types all; |
| 16 | import from Osmocom_Gb_Types all; |
| 17 | import from NS_Types all; |
| 18 | import from BSSGP_Types all; |
| 19 | import from UD_Types all; |
| 20 | import from NS_Emulation all; |
| 21 | import from Native_Functions all; |
| 22 | import from IPL4asp_Types all; |
| 23 | import from RAW_NS all; |
| 24 | import from Osmocom_VTY_Functions all; |
| 25 | import from TELNETasp_PortType all; |
| 26 | |
| 27 | modulepar { |
| 28 | OsmoNsDialect mp_dialect := NS2_DIALECT_IPACCESS; |
| 29 | NSConfiguration mp_nsconfig := { |
| 30 | nsei := 96, |
| 31 | role_sgsn := false, |
| 32 | handle_sns := false, |
| 33 | nsvc := { |
| 34 | { |
| 35 | provider := { |
| 36 | ip := { |
| 37 | address_family := AF_INET, |
| 38 | local_udp_port := 21000, |
| 39 | local_ip := "127.0.0.1", |
| 40 | remote_udp_port := 23000, |
Alexander Couzens | 87e44cf | 2021-02-03 15:15:27 +0100 | [diff] [blame] | 41 | remote_ip := "127.0.0.1", |
| 42 | data_weight := 2, |
| 43 | signalling_weight := 2 |
Alexander Couzens | 20cd41e | 2021-01-11 02:56:03 +0100 | [diff] [blame] | 44 | } |
| 45 | }, |
| 46 | nsvci := 97 |
Alexander Couzens | 6f17ecc | 2021-05-25 13:43:57 +0200 | [diff] [blame] | 47 | }, |
| 48 | { |
| 49 | provider := { |
| 50 | ip := { |
| 51 | address_family := AF_INET, |
| 52 | local_udp_port := 21000, |
| 53 | local_ip := "127.0.0.1", |
| 54 | remote_udp_port := 23001, |
| 55 | remote_ip := "127.0.0.1", |
| 56 | data_weight := 1, |
| 57 | signalling_weight := 1 |
| 58 | } |
| 59 | }, |
| 60 | nsvci := 98 |
Alexander Couzens | 20cd41e | 2021-01-11 02:56:03 +0100 | [diff] [blame] | 61 | } |
| 62 | } |
| 63 | }; |
| 64 | } |
| 65 | |
| 66 | type component RAW_Test_CT extends RAW_NS_CT { |
| 67 | port TELNETasp_PT NSVTY; |
| 68 | } |
| 69 | |
| 70 | private function f_init_vty() runs on RAW_Test_CT { |
| 71 | map(self:NSVTY, system:NSVTY); |
| 72 | f_vty_set_prompts(NSVTY); |
| 73 | f_vty_transceive(NSVTY, "enable"); |
| 74 | f_vty_transceive(NSVTY, "nsvc nsei " & int2str(mp_nsconfig.nsei) & " force-unconfigured"); |
Alexander Couzens | 6f17ecc | 2021-05-25 13:43:57 +0200 | [diff] [blame] | 75 | f_vty_config2(NSVTY, {"ns", "nse " & int2str(mp_nsconfig.nsei)}, "no ip-sns-bind local2"); |
Alexander Couzens | 7a62502 | 2021-06-06 23:14:58 +0200 | [diff] [blame] | 76 | f_vty_config2(NSVTY, {"ns", "bind udp local"}, "ip-sns signalling-weight 1 data-weight 1"); |
| 77 | f_vty_config2(NSVTY, {"ns", "bind udp local2"}, "ip-sns signalling-weight 1 data-weight 1"); |
Alexander Couzens | 20cd41e | 2021-01-11 02:56:03 +0100 | [diff] [blame] | 78 | } |
| 79 | |
| 80 | /* ensure no matching message is received within 'tout' */ |
| 81 | function f_ensure_no_ns(integer idx := 0, boolean answer_alive := false, float tout := 3.0) |
| 82 | runs on RAW_Test_CT { |
| 83 | var PDU_NS nrf; |
| 84 | |
| 85 | timer T := tout; |
| 86 | var default d := activate(ax_rx_fail_on_any_ns(idx)); |
| 87 | T.start; |
| 88 | alt { |
| 89 | [answer_alive] as_rx_alive_tx_ack(); |
| 90 | [] T.timeout { |
| 91 | setverdict(pass); |
| 92 | } |
| 93 | } |
| 94 | deactivate(d); |
| 95 | } |
| 96 | |
| 97 | function f_fails_except_reset(integer idx := 0, float tout := 15.0) |
| 98 | runs on RAW_Test_CT { |
| 99 | var PDU_NS nrf; |
| 100 | timer T := 15.0; |
| 101 | T.start; |
| 102 | alt { |
| 103 | [] NSCP[idx].receive(tr_NS_RESET(*, *, *)) { |
| 104 | repeat; |
| 105 | } |
| 106 | [] NSCP[idx].receive(PDU_NS: ?) -> value nrf { |
| 107 | setverdict(fail, "Received unexpected NS: ", nrf); |
| 108 | mtc.stop; |
| 109 | } |
| 110 | [] T.timeout { |
| 111 | setverdict(pass); |
| 112 | } |
| 113 | } |
| 114 | } |
| 115 | |
| 116 | testcase TC_tx_reset() runs on RAW_Test_CT { |
| 117 | f_init_vty(); |
| 118 | f_init_ns_codec(mp_nsconfig, guard_secs := 10.0); |
| 119 | |
| 120 | /* do a NS Reset procedure */ |
| 121 | f_outgoing_ns_reset(); |
| 122 | |
| 123 | setverdict(pass); |
| 124 | f_sleep(1.0); |
| 125 | } |
| 126 | |
| 127 | testcase TC_tx_reset_tx_alive() runs on RAW_Test_CT { |
| 128 | f_init_vty(); |
| 129 | f_init_ns_codec(mp_nsconfig, guard_secs := 10.0); |
| 130 | |
| 131 | /* do a NS Reset procedure */ |
| 132 | f_outgoing_ns_reset(); |
| 133 | |
| 134 | /* check outgoing NS procedure */ |
| 135 | f_outgoing_ns_alive(); |
| 136 | |
| 137 | setverdict(pass); |
| 138 | f_sleep(1.0); |
| 139 | } |
| 140 | |
| 141 | testcase TC_tx_reset_rx_alive() runs on RAW_Test_CT { |
| 142 | f_init_vty(); |
| 143 | f_init_ns_codec(mp_nsconfig, guard_secs := 10.0); |
| 144 | |
| 145 | /* do a NS Reset procedure */ |
| 146 | f_outgoing_ns_reset(); |
| 147 | |
| 148 | activate(as_rx_ns_unblock_ack()); |
| 149 | /* check outgoing NS procedure */ |
| 150 | as_rx_alive_tx_ack(oneshot := true); |
| 151 | |
| 152 | setverdict(pass); |
| 153 | f_sleep(1.0); |
| 154 | } |
| 155 | |
| 156 | /* 48.016 7.2 unblock procedure |
| 157 | * |
| 158 | * TTCN -> NS: reset |
| 159 | * TTCN <- NS: reset ack |
| 160 | * TTCN -> NS: unblock |
| 161 | * TTCN <- NS: unblock ack |
| 162 | */ |
| 163 | testcase TC_tx_unblock() runs on RAW_Test_CT { |
| 164 | f_init_vty(); |
| 165 | f_init_ns_codec(mp_nsconfig, guard_secs := 30.0); |
| 166 | |
| 167 | /* do a NS Reset procedure */ |
| 168 | f_outgoing_ns_reset(); |
| 169 | /* send alive acks */ |
| 170 | activate(as_rx_alive_tx_ack()); |
| 171 | |
| 172 | f_outgoing_ns_unblock(); |
| 173 | setverdict(pass); |
| 174 | f_sleep(1.0); |
| 175 | } |
| 176 | |
| 177 | /* 48.016 7.2 tx unblock retries |
| 178 | * |
| 179 | * TTCN -> NS: reset |
| 180 | * TTCN <- NS: reset ack |
| 181 | * TTCN -> NS: unblock |
| 182 | * TTCN <- NS: unblock ack |
| 183 | * TTCN -> NS: unblock |
| 184 | * TTCN <- NS: unblock ack |
| 185 | * TTCN -> NS: unblock |
| 186 | * TTCN <- NS: unblock ack |
| 187 | */ |
| 188 | testcase TC_tx_unblock_retries() runs on RAW_Test_CT { |
| 189 | f_init_vty(); |
| 190 | f_init_ns_codec(mp_nsconfig, guard_secs := 30.0); |
| 191 | |
| 192 | /* do a NS Reset procedure */ |
| 193 | f_outgoing_ns_reset(); |
| 194 | /* send alive acks */ |
| 195 | activate(as_rx_alive_tx_ack()); |
| 196 | |
| 197 | f_outgoing_ns_unblock(); |
| 198 | f_outgoing_ns_unblock(); |
| 199 | f_outgoing_ns_unblock(); |
| 200 | setverdict(pass); |
| 201 | f_sleep(1.0); |
| 202 | } |
| 203 | |
| 204 | /* 48.016 7.2 block procedure |
| 205 | * |
| 206 | * TTCN -> NS: reset |
| 207 | * TTCN <- NS: reset ack |
| 208 | * TTCN -> NS: unblock |
| 209 | * TTCN <- NS: unblock ack |
| 210 | * TTCN -> NS: block |
| 211 | * TTCN <- NS: block ack |
| 212 | */ |
| 213 | testcase TC_tx_block() runs on RAW_Test_CT { |
| 214 | f_init_vty(); |
| 215 | f_init_ns_codec(mp_nsconfig, guard_secs := 30.0); |
| 216 | |
| 217 | /* do a NS Reset procedure */ |
| 218 | f_outgoing_ns_reset(); |
| 219 | activate(as_rx_alive_tx_ack()); |
| 220 | |
| 221 | f_outgoing_ns_unblock(); |
| 222 | f_sleep(1.0); |
| 223 | |
| 224 | f_outgoing_ns_block(NS_CAUSE_EQUIPMENT_FAILURE); |
| 225 | setverdict(pass); |
| 226 | f_sleep(1.0); |
| 227 | } |
| 228 | |
| 229 | /* 48.016 7.2 block procedure by vty |
| 230 | * |
| 231 | * TTCN -> NS: reset |
| 232 | * TTCN <- NS: reset ack |
| 233 | * TTCN -> NS: unblock |
| 234 | * TTCN <- NS: unblock ack |
| 235 | * vty: block nsvc |
| 236 | * TTCN <- NS: block |
| 237 | * TTCN -> NS: block ack |
| 238 | */ |
| 239 | function tx_block_by_vty(float guard_secs := 30.0) runs on RAW_Test_CT { |
| 240 | f_init_vty(); |
| 241 | f_init_ns_codec(mp_nsconfig, guard_secs := guard_secs); |
| 242 | |
| 243 | /* do a NS Reset procedure */ |
| 244 | f_outgoing_ns_reset(); |
| 245 | activate(as_rx_alive_tx_ack()); |
| 246 | |
| 247 | f_outgoing_ns_unblock(); |
| 248 | f_sleep(1.0); |
| 249 | |
| 250 | f_vty_transceive(NSVTY, "nsvc " & int2str(mp_nsconfig.nsvc[0].nsvci) & " block"); |
| 251 | |
| 252 | alt { |
| 253 | [] as_rx_ns_block_ack(oneshot := true, nsvci := mp_nsconfig.nsvc[0].nsvci); |
| 254 | } |
| 255 | setverdict(pass); |
| 256 | } |
| 257 | |
| 258 | testcase TC_tx_block_by_vty() runs on RAW_Test_CT { |
| 259 | tx_block_by_vty(30.0); |
| 260 | f_sleep(1.0); |
| 261 | } |
| 262 | |
| 263 | /* 48.016 7.2 block precedure by vty and reset the NSVC. |
| 264 | * The NSVC should be still blocked after the reset. |
| 265 | */ |
| 266 | testcase TC_tx_block_by_vty_reset() runs on RAW_Test_CT { |
| 267 | timer T := 10.0; |
| 268 | |
| 269 | tx_block_by_vty(60.0); |
| 270 | f_outgoing_ns_reset(); |
| 271 | |
| 272 | var default d := activate(ax_rx_fail_on_any_ns()); |
| 273 | T.start; |
| 274 | alt { |
| 275 | [] as_rx_alive_tx_ack(); |
| 276 | [] T.timeout { setverdict(pass); } |
| 277 | } |
| 278 | deactivate(d); |
| 279 | } |
| 280 | |
| 281 | /* 48.016 7.4.1 ignore unexpected NS_ALIVE ACK */ |
| 282 | testcase TC_no_reset_alive_ack() runs on RAW_Test_CT { |
| 283 | f_init_vty(); |
| 284 | f_init_ns_codec(mp_nsconfig, guard_secs := 30.0); |
| 285 | |
| 286 | NSCP[0].send(t_NS_ALIVE_ACK); |
| 287 | f_fails_except_reset(); |
| 288 | setverdict(pass); |
| 289 | f_sleep(1.0); |
| 290 | } |
| 291 | |
| 292 | /* 48.016 7.3.1 NS_RESET with wrong nsei */ |
| 293 | testcase TC_reset_wrong_nsei() runs on RAW_Test_CT { |
| 294 | f_init_vty(); |
| 295 | f_init_ns_codec(mp_nsconfig, guard_secs := 30.0); |
| 296 | |
| 297 | NSCP[0].send(ts_NS_RESET(NS_CAUSE_EQUIPMENT_FAILURE, g_nsconfig.nsvc[0].nsvci, g_nsconfig.nsei + 20)); |
| 298 | NSCP[0].receive(tr_NS_RESET_ACK(g_nsconfig.nsvc[0].nsvci, g_nsconfig.nsei)); |
| 299 | f_fails_except_reset(); |
| 300 | setverdict(pass); |
| 301 | f_sleep(1.0); |
| 302 | } |
| 303 | |
| 304 | /* 48.016 7.3.1 NS_RESET with wrong nsvci */ |
| 305 | testcase TC_reset_wrong_nsvci() runs on RAW_Test_CT { |
| 306 | f_init_vty(); |
| 307 | f_init_ns_codec(mp_nsconfig, guard_secs := 30.0); |
| 308 | |
| 309 | NSCP[0].send(ts_NS_RESET(NS_CAUSE_EQUIPMENT_FAILURE, g_nsconfig.nsvc[0].nsvci + 20, g_nsconfig.nsei)); |
| 310 | NSCP[0].receive(tr_NS_RESET_ACK(g_nsconfig.nsvc[0].nsvci, g_nsconfig.nsei)); |
| 311 | f_fails_except_reset(); |
| 312 | setverdict(pass); |
| 313 | f_sleep(1.0); |
| 314 | } |
| 315 | |
| 316 | /* 48.016 7.3.1 NS_RESET with wrong nsvci + nsei */ |
| 317 | testcase TC_reset_wrong_nsei_nsvci() runs on RAW_Test_CT { |
| 318 | f_init_vty(); |
| 319 | f_init_ns_codec(mp_nsconfig, guard_secs := 30.0); |
| 320 | |
| 321 | NSCP[0].send(ts_NS_RESET(NS_CAUSE_EQUIPMENT_FAILURE, g_nsconfig.nsvc[0].nsvci + 20, g_nsconfig.nsei + 20)); |
| 322 | NSCP[0].receive(tr_NS_RESET_ACK(g_nsconfig.nsvc[0].nsvci, g_nsconfig.nsei)); |
| 323 | f_fails_except_reset(); |
| 324 | setverdict(pass); |
| 325 | f_sleep(1.0); |
| 326 | } |
| 327 | |
| 328 | /* 48.016 7.3.1 NS_RESET_ACK with wrong nsei */ |
| 329 | testcase TC_reset_ack_wrong_nsei() runs on RAW_Test_CT { |
| 330 | f_init_vty(); |
| 331 | f_init_ns_codec(mp_nsconfig, guard_secs := 30.0); |
| 332 | |
| 333 | NSCP[0].receive(tr_NS_RESET(*, g_nsconfig.nsvc[0].nsvci, g_nsconfig.nsei)); |
| 334 | NSCP[0].send(ts_NS_RESET_ACK(g_nsconfig.nsvc[0].nsvci, g_nsconfig.nsei + 20)); |
| 335 | f_fails_except_reset(); |
| 336 | setverdict(pass); |
| 337 | f_sleep(1.0); |
| 338 | } |
| 339 | |
| 340 | /* 48.016 7.3.1 NS_RESET_ACK with wrong nsvci */ |
| 341 | testcase TC_reset_ack_wrong_nsvci() runs on RAW_Test_CT { |
| 342 | f_init_vty(); |
| 343 | f_init_ns_codec(mp_nsconfig, guard_secs := 30.0); |
| 344 | |
| 345 | NSCP[0].receive(tr_NS_RESET(*, g_nsconfig.nsvc[0].nsvci, g_nsconfig.nsei)); |
| 346 | NSCP[0].send(ts_NS_RESET_ACK(g_nsconfig.nsvc[0].nsvci + 20, g_nsconfig.nsei)); |
| 347 | f_fails_except_reset(); |
| 348 | setverdict(pass); |
| 349 | f_sleep(1.0); |
| 350 | } |
| 351 | |
| 352 | /* 48.016 7.3.1 NS_RESET_ACK with wrong nsvci + nsei */ |
| 353 | testcase TC_reset_ack_wrong_nsei_nsvci() runs on RAW_Test_CT { |
| 354 | f_init_vty(); |
| 355 | f_init_ns_codec(mp_nsconfig, guard_secs := 30.0); |
| 356 | |
| 357 | NSCP[0].receive(tr_NS_RESET(*, g_nsconfig.nsvc[0].nsvci, g_nsconfig.nsei)); |
| 358 | NSCP[0].send(ts_NS_RESET_ACK(g_nsconfig.nsvc[0].nsvci + 20, g_nsconfig.nsei + 20)); |
| 359 | f_fails_except_reset(); |
| 360 | setverdict(pass); |
| 361 | f_sleep(1.0); |
| 362 | } |
| 363 | |
| 364 | /* 48.016 7.3.1 ignore unexpected NS_RESET_ACK after NS_RESET+ALIVE */ |
| 365 | testcase TC_ignore_reset_ack() runs on RAW_Test_CT { |
| 366 | f_init_vty(); |
| 367 | f_init_ns_codec(mp_nsconfig, guard_secs := 30.0); |
| 368 | |
| 369 | /* do a NS Reset procedure */ |
| 370 | f_outgoing_ns_reset(); |
| 371 | |
| 372 | /* unblock and alive */ |
| 373 | alt { |
| 374 | [] as_rx_ns_unblock_ack(oneshot := true); |
| 375 | [] as_rx_alive_tx_ack(); |
| 376 | } |
| 377 | |
| 378 | NSCP[0].send(ts_NS_RESET_ACK(g_nsconfig.nsvc[0].nsvci, g_nsconfig.nsei)); |
| 379 | f_ensure_no_ns(answer_alive := true, tout := 15.0); |
| 380 | setverdict(pass); |
| 381 | f_sleep(1.0); |
| 382 | } |
| 383 | |
| 384 | /* 48.016 7.3 NS_RESET retries */ |
| 385 | testcase TC_reset_retries() runs on RAW_Test_CT { |
| 386 | var integer reset := 0; |
| 387 | |
| 388 | f_init_vty(); |
| 389 | f_init_ns_codec(mp_nsconfig, guard_secs := 30.0); |
| 390 | |
| 391 | alt { |
| 392 | [] NSCP[0].receive(tr_NS_RESET(*, *, *)) { |
| 393 | reset := reset + 1; |
| 394 | if (reset <= 3) { |
| 395 | repeat; |
| 396 | } else { |
| 397 | setverdict(pass); |
| 398 | } |
| 399 | } |
| 400 | } |
| 401 | |
| 402 | f_sleep(1.0); |
| 403 | } |
| 404 | |
| 405 | /* 48.016 behave RESET_ACK got dropped |
| 406 | * TTCN -> NS: reset |
| 407 | * TTCN <- NS: reset ack |
| 408 | * TTCN <- NS: unblock |
| 409 | * TTCN -> NS: reset |
| 410 | * TTCN <- NS: reset ack |
| 411 | * TTCN <- NS: unblock |
| 412 | */ |
| 413 | testcase TC_reset_on_block_reset() runs on RAW_Test_CT { |
| 414 | var integer i := 0; |
| 415 | |
| 416 | f_init_vty(); |
| 417 | f_init_ns_codec(mp_nsconfig, guard_secs := 30.0); |
| 418 | |
| 419 | f_outgoing_ns_reset(); |
| 420 | activate(as_rx_alive_tx_ack()); |
| 421 | |
| 422 | alt { |
| 423 | [] NSCP[0].receive(t_NS_UNBLOCK) { |
| 424 | NSCP[0].send(ts_NS_RESET(NS_CAUSE_EQUIPMENT_FAILURE, g_nsconfig.nsvc[0].nsvci, g_nsconfig.nsei)); |
| 425 | i := i + 1; |
| 426 | if (i < 3) { |
| 427 | repeat; |
| 428 | } else { |
| 429 | setverdict(pass); |
| 430 | } |
| 431 | } |
| 432 | [] NSCP[0].receive(tr_NS_RESET_ACK(g_nsconfig.nsvc[0].nsvci, g_nsconfig.nsei)) { repeat; } |
| 433 | } |
| 434 | |
| 435 | f_sleep(1.0); |
| 436 | } |
| 437 | |
| 438 | /* 48.016 7.4 test procedure for frame relay with a single nsvci */ |
| 439 | function f_alive_retries_single(boolean reset := false) runs on RAW_Test_CT { |
| 440 | f_init_vty(); |
| 441 | f_init_ns_codec(mp_nsconfig, guard_secs := 60.0); |
| 442 | |
| 443 | /* do a NS Reset procedure */ |
| 444 | f_outgoing_ns_reset(); |
| 445 | |
| 446 | alt { |
| 447 | [] as_rx_ns_unblock_ack(oneshot := true); |
| 448 | [] as_rx_alive_tx_ack(); |
| 449 | } |
| 450 | |
| 451 | /* wait for one alive and answer it */ |
| 452 | as_rx_alive_tx_ack(oneshot := true); |
| 453 | NSCP[0].receive(t_NS_ALIVE); |
| 454 | NSCP[0].receive(t_NS_ALIVE); |
| 455 | NSCP[0].receive(t_NS_ALIVE); |
| 456 | NSCP[0].receive(t_NS_ALIVE); |
| 457 | if (reset) { |
| 458 | NSCP[0].receive(tr_NS_RESET(*, g_nsconfig.nsvc[0].nsvci, g_nsconfig.nsei)); |
| 459 | } else { |
| 460 | f_ensure_no_ns(tout := 10.0); |
| 461 | } |
| 462 | |
| 463 | setverdict(pass); |
| 464 | f_sleep(1.0); |
| 465 | } |
| 466 | |
| 467 | testcase TC_alive_retries_single_reset() runs on RAW_Test_CT { |
| 468 | f_alive_retries_single(reset := true); |
| 469 | } |
| 470 | |
| 471 | testcase TC_alive_retries_single_no_resp() runs on RAW_Test_CT { |
| 472 | f_alive_retries_single(reset := false); |
| 473 | } |
| 474 | |
Alexander Couzens | cbee32a | 2021-02-27 20:50:20 +0100 | [diff] [blame] | 475 | /* 48.016 SNS test cases */ |
| 476 | |
| 477 | /* do a succesful SNS configuration */ |
Alexander Couzens | 79606cf | 2021-07-27 14:59:29 +0200 | [diff] [blame^] | 478 | testcase TC_sns_bss_config_success() runs on RAW_Test_CT { |
Alexander Couzens | cbee32a | 2021-02-27 20:50:20 +0100 | [diff] [blame] | 479 | f_init_vty(); |
| 480 | f_init_ns_codec(mp_nsconfig); |
| 481 | f_incoming_sns_size(); |
| 482 | f_incoming_sns_config(); |
| 483 | f_outgoing_sns_config(); |
| 484 | setverdict(pass); |
| 485 | f_clean_ns_codec(); |
| 486 | } |
| 487 | |
Alexander Couzens | d5ac510 | 2021-02-27 20:53:37 +0100 | [diff] [blame] | 488 | testcase TC_sns_bss_change_weight() runs on RAW_Test_CT { |
Alexander Couzens | 60548b1 | 2021-04-14 19:39:26 +0200 | [diff] [blame] | 489 | g_handle_rx_alive := true; |
Alexander Couzens | d5ac510 | 2021-02-27 20:53:37 +0100 | [diff] [blame] | 490 | f_init_vty(); |
| 491 | f_init_ns_codec(mp_nsconfig); |
| 492 | f_incoming_sns_size(); |
| 493 | f_incoming_sns_config(); |
| 494 | f_outgoing_sns_config(); |
| 495 | activate(as_rx_alive_tx_ack()); |
| 496 | f_vty_config2(NSVTY, {"ns", "bind udp local"}, "ip-sns signalling-weight 99 data-weight 99"); |
| 497 | f_incoming_sns_chg_weight(); |
| 498 | setverdict(pass); |
| 499 | f_clean_ns_codec(); |
| 500 | } |
| 501 | |
Alexander Couzens | 6c723fb | 2021-03-01 00:12:00 +0100 | [diff] [blame] | 502 | /* receive 3x SNS_CHG_WEIGHT but never answer on it */ |
| 503 | testcase TC_sns_bss_change_weight_timeout() runs on RAW_Test_CT { |
| 504 | var integer i := 0; |
| 505 | var template PDU_NS rx; |
| 506 | var NSVCConfiguration nsvc_cfg; |
| 507 | |
Alexander Couzens | 60548b1 | 2021-04-14 19:39:26 +0200 | [diff] [blame] | 508 | g_handle_rx_alive := true; |
Alexander Couzens | 6c723fb | 2021-03-01 00:12:00 +0100 | [diff] [blame] | 509 | f_init_vty(); |
| 510 | f_init_ns_codec(mp_nsconfig); |
| 511 | f_incoming_sns_size(); |
| 512 | f_incoming_sns_config(); |
| 513 | f_outgoing_sns_config(); |
| 514 | activate(as_rx_alive_tx_ack()); |
| 515 | f_vty_config2(NSVTY, {"ns", "bind udp local"}, "ip-sns signalling-weight 99 data-weight 99"); |
| 516 | |
| 517 | nsvc_cfg := g_nsconfig.nsvc[0]; |
| 518 | if (nsvc_cfg.provider.ip.address_family == AF_INET) { |
| 519 | var template IP4_Elements v4_elem := { tr_SNS_IPv4(nsvc_cfg.provider.ip.remote_ip, |
| 520 | nsvc_cfg.provider.ip.remote_udp_port) }; |
| 521 | |
| 522 | rx := tr_SNS_CHG_WEIGHT(g_nsconfig.nsei, ?, v4 := v4_elem); |
| 523 | } else { |
| 524 | var template IP6_Elements v6_elem := { tr_SNS_IPv6(nsvc_cfg.provider.ip.remote_ip, |
| 525 | nsvc_cfg.provider.ip.remote_udp_port) }; |
| 526 | rx := tr_SNS_CHG_WEIGHT(g_nsconfig.nsei, ?, v4 := omit, v6 := v6_elem); |
| 527 | } |
| 528 | |
Alexander Couzens | 60548b1 | 2021-04-14 19:39:26 +0200 | [diff] [blame] | 529 | for (i := 0; i < 3; i := i + 1) { |
| 530 | f_ns_exp(rx); |
Alexander Couzens | 6c723fb | 2021-03-01 00:12:00 +0100 | [diff] [blame] | 531 | } |
| 532 | |
Alexander Couzens | a93cc36 | 2021-04-14 19:39:18 +0200 | [diff] [blame] | 533 | if (nsvc_cfg.provider.ip.address_family == AF_INET) { |
| 534 | /* expect one single SNS-SIZE with RESET flag; 4x v4 EP; no v6 EP */ |
| 535 | rx := f_ns_exp(tr_SNS_SIZE(g_nsconfig.nsei, rst_flag := true, max_nsvcs := ?, |
| 536 | num_v4 := ?, num_v6 := omit), 0); |
| 537 | } else { |
| 538 | /* expect one single SNS-SIZE with RESET flag; no v4 EP; 4x v6 EP */ |
| 539 | rx := f_ns_exp(tr_SNS_SIZE(g_nsconfig.nsei, rst_flag := true, max_nsvcs := ?, |
| 540 | num_v4 := omit, num_v6 := ?), 0); |
| 541 | } |
| 542 | |
Alexander Couzens | 6c723fb | 2021-03-01 00:12:00 +0100 | [diff] [blame] | 543 | setverdict(pass); |
| 544 | f_clean_ns_codec(); |
| 545 | } |
| 546 | |
Alexander Couzens | 6f17ecc | 2021-05-25 13:43:57 +0200 | [diff] [blame] | 547 | testcase TC_sns_bss_add() runs on RAW_Test_CT { |
| 548 | g_handle_rx_alive := true; |
| 549 | f_init_vty(); |
| 550 | f_init_ns_codec(mp_nsconfig); |
| 551 | f_init_ns_codec(mp_nsconfig, 1); |
| 552 | f_incoming_sns_size(); |
| 553 | f_incoming_sns_config(); |
| 554 | f_outgoing_sns_config(); |
| 555 | activate(as_rx_alive_tx_ack()); |
| 556 | f_vty_config2(NSVTY, {"ns", "nse " & int2str(g_nsconfig.nsei)}, "ip-sns-bind local2"); |
| 557 | f_incoming_sns_add(idx_add := 1); |
| 558 | as_rx_alive_tx_ack(oneshot := true, idx := 1); |
| 559 | setverdict(pass); |
| 560 | f_clean_ns_codec(); |
| 561 | } |
| 562 | |
| 563 | testcase TC_sns_bss_del() runs on RAW_Test_CT { |
| 564 | g_handle_rx_alive := true; |
| 565 | f_init_vty(); |
| 566 | f_init_ns_codec(mp_nsconfig); |
| 567 | f_init_ns_codec(mp_nsconfig, 1); |
| 568 | f_incoming_sns_size(); |
| 569 | f_incoming_sns_config(); |
| 570 | f_outgoing_sns_config(); |
| 571 | activate(as_rx_alive_tx_ack()); |
| 572 | f_vty_config2(NSVTY, {"ns", "nse " & int2str(g_nsconfig.nsei)}, "ip-sns-bind local2"); |
| 573 | f_incoming_sns_add(idx_add := 1); |
| 574 | as_rx_alive_tx_ack(oneshot := true, idx := 1); |
| 575 | |
| 576 | /* delete the endpoint */ |
| 577 | f_vty_config2(NSVTY, {"ns", "nse " & int2str(g_nsconfig.nsei)}, "no ip-sns-bind local2"); |
| 578 | f_incoming_sns_del(idx_del := 1); |
| 579 | setverdict(pass); |
| 580 | f_clean_ns_codec(); |
| 581 | } |
| 582 | |
Alexander Couzens | e23387a | 2021-06-06 23:15:42 +0200 | [diff] [blame] | 583 | /* 1. do SNS configuration |
| 584 | * 2. add a bind |
| 585 | * 3. receive the SNS_ADD |
| 586 | * 4. before answering the SNS_ADD, change the weight via vty and remove the bind |
| 587 | */ |
| 588 | testcase TC_sns_bss_add_change_del() runs on RAW_Test_CT { |
| 589 | var PDU_NS rx; |
| 590 | var NSVCConfiguration nsvc_cfg; |
| 591 | |
| 592 | g_handle_rx_alive := true; |
| 593 | f_init_vty(); |
| 594 | f_init_ns_codec(mp_nsconfig); |
| 595 | f_init_ns_codec(mp_nsconfig, 1); |
| 596 | f_incoming_sns_size(); |
| 597 | f_incoming_sns_config(); |
| 598 | f_outgoing_sns_config(); |
| 599 | activate(as_rx_alive_tx_ack()); |
| 600 | f_vty_config2(NSVTY, {"ns", "nse " & int2str(g_nsconfig.nsei)}, "ip-sns-bind local2"); |
| 601 | |
| 602 | /* rx SNS ADD */ |
| 603 | nsvc_cfg := g_nsconfig.nsvc[1]; |
| 604 | if (nsvc_cfg.provider.ip.address_family == AF_INET) { |
| 605 | var template (omit) IP4_Elements v4_elem := { ts_SNS_IPv4(nsvc_cfg.provider.ip.remote_ip, |
| 606 | nsvc_cfg.provider.ip.remote_udp_port, |
| 607 | 1, 1) }; |
| 608 | rx := f_ns_exp(tr_SNS_ADD(g_nsconfig.nsei, ?, v4 := v4_elem), 0); |
| 609 | } else { |
| 610 | var template (omit) IP6_Elements v6_elem := { ts_SNS_IPv6(nsvc_cfg.provider.ip.remote_ip, |
| 611 | nsvc_cfg.provider.ip.remote_udp_port, |
| 612 | 1, 1) }; |
| 613 | rx := f_ns_exp(tr_SNS_ADD(g_nsconfig.nsei, ?, omit, v6_elem), 0); |
| 614 | } |
| 615 | |
| 616 | /* delete the endpoint */ |
| 617 | f_vty_config2(NSVTY, {"ns", "bind udp local2"}, "ip-sns signalling-weight 99 data-weight 99"); |
| 618 | f_vty_config2(NSVTY, {"ns", "nse " & int2str(g_nsconfig.nsei)}, "no ip-sns-bind local2"); |
| 619 | |
| 620 | /* accept the SNS_ADD */ |
| 621 | NSCP[0].send(ts_SNS_ACK(g_nsconfig.nsei, rx.pDU_SNS_Add.transactionID)); |
| 622 | |
| 623 | f_incoming_sns_chg_weight(idx_chg := 1); |
| 624 | f_incoming_sns_del(idx_del := 1, w_sig := 99, w_user := 99); |
| 625 | setverdict(pass); |
| 626 | f_clean_ns_codec(); |
| 627 | } |
| 628 | |
Alexander Couzens | 31f8150 | 2021-07-12 18:15:01 +0200 | [diff] [blame] | 629 | /* Ensure the ns2 code doesn't crash when calling force unconfigured while sending SNS SIZE */ |
| 630 | testcase TC_sns_rx_size_force_unconf() runs on RAW_Test_CT { |
| 631 | g_handle_rx_alive := true; |
| 632 | f_init_vty(); |
| 633 | f_init_ns_codec(mp_nsconfig); |
| 634 | f_init_ns_codec(mp_nsconfig, 1); |
| 635 | f_ns_exp(tr_SNS_SIZE(mp_nsconfig.nsei, rst_flag := true, max_nsvcs := ?, |
| 636 | num_v4 := ?, num_v6 := omit)); |
| 637 | f_vty_transceive(NSVTY, "nsvc nsei " & int2str(mp_nsconfig.nsei) & " force-unconfigured"); |
| 638 | f_ns_exp(tr_SNS_SIZE(mp_nsconfig.nsei, rst_flag := true, max_nsvcs := ?, |
| 639 | num_v4 := ?, num_v6 := omit)); |
| 640 | setverdict(pass); |
| 641 | f_clean_ns_codec(); |
| 642 | } |
| 643 | |
Alexander Couzens | 1650b16 | 2021-06-13 04:05:56 +0200 | [diff] [blame] | 644 | /* Test if SNS fails when all signalling NSVCs failes |
| 645 | * 3GPP TS 48.016 ยง 7.4b.1.1 |
| 646 | * 1. do success SNS configuration |
| 647 | * 2. change sig weight of the seconds inactive bind |
| 648 | * 3. add second bind to SNS |
| 649 | * 4. stop reacting to NS_ALIVE on first NSVC (only NSVC with sig weight) |
| 650 | * 5. expect SNS SIZE |
| 651 | */ |
| 652 | testcase TC_sns_bss_all_signalling_nsvcs_failed() runs on RAW_Test_CT { |
| 653 | g_handle_rx_alive := true; |
| 654 | f_init_vty(); |
| 655 | f_init_ns_codec(mp_nsconfig); |
| 656 | f_init_ns_codec(mp_nsconfig, 1); |
| 657 | f_incoming_sns_size(); |
| 658 | f_incoming_sns_config(); |
| 659 | f_outgoing_sns_config(); |
| 660 | var default d := activate(as_rx_alive_tx_ack()); |
| 661 | |
| 662 | f_vty_config2(NSVTY, {"ns", "bind udp local2"}, "ip-sns signalling-weight 0 data-weight 99"); |
| 663 | f_vty_config2(NSVTY, {"ns", "nse " & int2str(g_nsconfig.nsei)}, "ip-sns-bind local2"); |
| 664 | f_incoming_sns_add(idx_add := 1, w_sig := 0, w_user := 99); |
| 665 | as_rx_alive_tx_ack(oneshot := true, idx := 1); |
| 666 | activate(as_rx_alive_tx_ack(idx := 1)); |
| 667 | /* 2x NSVCs up, stop first NSVC */ |
| 668 | deactivate(d); |
| 669 | /* libosmocore will rotate the SNS binds on failure */ |
| 670 | NSCP[0].receive(t_NS_ALIVE); |
| 671 | NSCP[0].receive(t_NS_ALIVE); |
| 672 | NSCP[0].receive(t_NS_ALIVE); |
| 673 | f_incoming_sns_size(idx := 1); |
| 674 | |
| 675 | setverdict(pass); |
| 676 | f_clean_ns_codec(); |
| 677 | } |
| 678 | |
Alexander Couzens | 5eeebaa | 2021-07-12 18:15:42 +0200 | [diff] [blame] | 679 | testcase TC_idle() runs on RAW_Test_CT { |
| 680 | f_init_vty(); |
| 681 | f_init_ns_codec(mp_nsconfig, guard_secs := 30.0); |
| 682 | |
| 683 | /* do a NS Reset procedure */ |
| 684 | f_outgoing_ns_reset(); |
| 685 | activate(as_rx_alive_tx_ack()); |
| 686 | |
| 687 | f_outgoing_ns_unblock(); |
| 688 | f_sleep(30.0); |
| 689 | |
| 690 | setverdict(pass); |
| 691 | f_sleep(1.0); |
| 692 | f_clean_ns_codec(); |
| 693 | } |
| 694 | |
Alexander Couzens | 20cd41e | 2021-01-11 02:56:03 +0100 | [diff] [blame] | 695 | control { |
Alexander Couzens | e48d355 | 2021-02-27 20:01:16 +0100 | [diff] [blame] | 696 | if (mp_dialect == NS2_DIALECT_STATIC_RESETBLOCK or mp_dialect == NS2_DIALECT_IPACCESS) { |
| 697 | execute( TC_tx_reset() ); |
Alexander Couzens | 20cd41e | 2021-01-11 02:56:03 +0100 | [diff] [blame] | 698 | |
Alexander Couzens | e48d355 | 2021-02-27 20:01:16 +0100 | [diff] [blame] | 699 | /* 48.016 7.2 Block procedure */ |
| 700 | execute( TC_tx_block() ); |
| 701 | execute( TC_tx_block_by_vty() ); |
| 702 | execute( TC_tx_block_by_vty_reset() ); |
| 703 | // execute( TC_block_other_nsvc() ); // reset, unblock, sleep(1), block over another nsvci |
| 704 | /* 48.016 7.2 Unblock procedure */ |
| 705 | execute( TC_tx_unblock() ); |
| 706 | execute( TC_tx_unblock_retries() ); |
| 707 | // execute( TC_rx_unblock_tx_unblock() ); // wait for an rx unblock pdu, send an unblock pdu, expect unblock ack pdu |
| 708 | // execute( TC_unblockable() ); // block a NS-VCI via vty, try block procedure |
Alexander Couzens | 20cd41e | 2021-01-11 02:56:03 +0100 | [diff] [blame] | 709 | |
Alexander Couzens | e48d355 | 2021-02-27 20:01:16 +0100 | [diff] [blame] | 710 | /* 48.016 7.2.1 Block Abnormal Condition */ |
| 711 | /* 48.016 7.2.1 Unblock Abnormal Condition */ |
| 712 | /* 48.016 7.3.1 Abnormal Condition */ |
Alexander Couzens | 20cd41e | 2021-01-11 02:56:03 +0100 | [diff] [blame] | 713 | execute( TC_reset_wrong_nsei() ); |
| 714 | execute( TC_reset_wrong_nsvci() ); |
| 715 | execute( TC_reset_wrong_nsei_nsvci() ); |
| 716 | execute( TC_reset_ack_wrong_nsei() ); |
| 717 | execute( TC_reset_ack_wrong_nsvci() ); |
| 718 | execute( TC_reset_ack_wrong_nsei_nsvci() ); |
| 719 | execute( TC_reset_retries() ); |
| 720 | execute( TC_reset_on_block_reset() ); |
Alexander Couzens | e48d355 | 2021-02-27 20:01:16 +0100 | [diff] [blame] | 721 | execute( TC_ignore_reset_ack() ); |
Alexander Couzens | 20cd41e | 2021-01-11 02:56:03 +0100 | [diff] [blame] | 722 | |
Alexander Couzens | e48d355 | 2021-02-27 20:01:16 +0100 | [diff] [blame] | 723 | /* 48.016 7.4 Test procedure on frame relay */ |
| 724 | execute( TC_tx_reset_tx_alive() ); |
| 725 | execute( TC_tx_reset_rx_alive() ); |
Alexander Couzens | 20cd41e | 2021-01-11 02:56:03 +0100 | [diff] [blame] | 726 | |
Alexander Couzens | e48d355 | 2021-02-27 20:01:16 +0100 | [diff] [blame] | 727 | /* 48.016 7.4.1 Abnormal Condition */ |
| 728 | if (mp_dialect == NS2_DIALECT_STATIC_RESETBLOCK) { |
| 729 | // execute( TC_alive_retries_multi() ); // check if alive retries works and block over an alive nsvc |
| 730 | execute( TC_alive_retries_single_reset() ); |
| 731 | } else if (mp_dialect == NS2_DIALECT_IPACCESS) { |
| 732 | execute( TC_alive_retries_single_no_resp() ); |
| 733 | } |
| 734 | |
| 735 | execute( TC_no_reset_alive_ack() ); |
Alexander Couzens | 20cd41e | 2021-01-11 02:56:03 +0100 | [diff] [blame] | 736 | } |
Alexander Couzens | cbee32a | 2021-02-27 20:50:20 +0100 | [diff] [blame] | 737 | |
| 738 | if (mp_dialect == NS2_DIALECT_SNS) { |
Alexander Couzens | 79606cf | 2021-07-27 14:59:29 +0200 | [diff] [blame^] | 739 | /* BSS test cases */ |
| 740 | execute( TC_sns_bss_config_success() ); |
Alexander Couzens | d5ac510 | 2021-02-27 20:53:37 +0100 | [diff] [blame] | 741 | execute( TC_sns_bss_change_weight() ); |
Alexander Couzens | 6c723fb | 2021-03-01 00:12:00 +0100 | [diff] [blame] | 742 | execute( TC_sns_bss_change_weight_timeout() ); |
Alexander Couzens | 6f17ecc | 2021-05-25 13:43:57 +0200 | [diff] [blame] | 743 | execute( TC_sns_bss_add() ); |
| 744 | execute( TC_sns_bss_del() ); |
Alexander Couzens | e23387a | 2021-06-06 23:15:42 +0200 | [diff] [blame] | 745 | execute( TC_sns_bss_add_change_del() ); |
Alexander Couzens | 1650b16 | 2021-06-13 04:05:56 +0200 | [diff] [blame] | 746 | execute( TC_sns_bss_all_signalling_nsvcs_failed() ); |
Alexander Couzens | 31f8150 | 2021-07-12 18:15:01 +0200 | [diff] [blame] | 747 | execute( TC_sns_rx_size_force_unconf() ); |
Alexander Couzens | cbee32a | 2021-02-27 20:50:20 +0100 | [diff] [blame] | 748 | } |
Alexander Couzens | 20cd41e | 2021-01-11 02:56:03 +0100 | [diff] [blame] | 749 | } |
| 750 | |
| 751 | } |