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