blob: 8553684bc33702f1adf81cca193bc82b4a2f0456 [file] [log] [blame]
Alexander Couzens20cd41e2021-01-11 02:56:03 +01001module 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
14import from General_Types all;
15import from Osmocom_Types all;
16import from Osmocom_Gb_Types all;
17import from NS_Types all;
18import from BSSGP_Types all;
19import from UD_Types all;
20import from NS_Emulation all;
21import from Native_Functions all;
22import from IPL4asp_Types all;
23import from RAW_NS all;
24import from Osmocom_VTY_Functions all;
25import from TELNETasp_PortType all;
26
Alexander Couzensde3dfaa2021-08-06 17:59:54 +020027type enumerated SnsRole {
28 SNS_ROLE_BSS ('00'H),
29 SNS_ROLE_SGSN ('01'H)
30};
31
Alexander Couzens20cd41e2021-01-11 02:56:03 +010032modulepar {
Alexander Couzensde3dfaa2021-08-06 17:59:54 +020033 SnsRole mp_sns_role := SNS_ROLE_BSS;
Alexander Couzens20cd41e2021-01-11 02:56:03 +010034 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 Couzens87e44cf2021-02-03 15:15:27 +010047 remote_ip := "127.0.0.1",
48 data_weight := 2,
49 signalling_weight := 2
Alexander Couzens20cd41e2021-01-11 02:56:03 +010050 }
51 },
52 nsvci := 97
Alexander Couzens6f17ecc2021-05-25 13:43:57 +020053 },
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 Couzens20cd41e2021-01-11 02:56:03 +010067 }
68 }
69 };
70}
71
72type component RAW_Test_CT extends RAW_NS_CT {
73 port TELNETasp_PT NSVTY;
74}
75
76private 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 Couzensbdef8102021-09-03 23:18:27 +020081 if (mp_dialect == NS2_DIALECT_SNS) {
82 f_vty_config2(NSVTY, {"ns", "nse " & int2str(mp_nsconfig.nsei)}, "ip-sns-bind local");
83 f_vty_config2(NSVTY, {"ns", "nse " & int2str(mp_nsconfig.nsei)}, "no ip-sns-bind local2");
84 f_vty_config2(NSVTY, {"ns", "bind udp local"}, "ip-sns signalling-weight 1 data-weight 1");
85 f_vty_config2(NSVTY, {"ns", "bind udp local2"}, "ip-sns signalling-weight 1 data-weight 1");
86 }
Alexander Couzens20cd41e2021-01-11 02:56:03 +010087}
88
89/* ensure no matching message is received within 'tout' */
90function f_ensure_no_ns(integer idx := 0, boolean answer_alive := false, float tout := 3.0)
91runs on RAW_Test_CT {
92 var PDU_NS nrf;
93
94 timer T := tout;
95 var default d := activate(ax_rx_fail_on_any_ns(idx));
96 T.start;
97 alt {
98 [answer_alive] as_rx_alive_tx_ack();
99 [] T.timeout {
100 setverdict(pass);
101 }
102 }
103 deactivate(d);
104}
105
106function f_fails_except_reset(integer idx := 0, float tout := 15.0)
107runs on RAW_Test_CT {
108 var PDU_NS nrf;
109 timer T := 15.0;
110 T.start;
111 alt {
112 [] NSCP[idx].receive(tr_NS_RESET(*, *, *)) {
113 repeat;
114 }
115 [] NSCP[idx].receive(PDU_NS: ?) -> value nrf {
116 setverdict(fail, "Received unexpected NS: ", nrf);
117 mtc.stop;
118 }
119 [] T.timeout {
120 setverdict(pass);
121 }
122 }
123}
124
125testcase TC_tx_reset() runs on RAW_Test_CT {
126 f_init_vty();
127 f_init_ns_codec(mp_nsconfig, guard_secs := 10.0);
128
129 /* do a NS Reset procedure */
130 f_outgoing_ns_reset();
131
132 setverdict(pass);
133 f_sleep(1.0);
134}
135
136testcase TC_tx_reset_tx_alive() runs on RAW_Test_CT {
137 f_init_vty();
138 f_init_ns_codec(mp_nsconfig, guard_secs := 10.0);
139
140 /* do a NS Reset procedure */
141 f_outgoing_ns_reset();
142
143 /* check outgoing NS procedure */
144 f_outgoing_ns_alive();
145
146 setverdict(pass);
147 f_sleep(1.0);
148}
149
150testcase TC_tx_reset_rx_alive() runs on RAW_Test_CT {
151 f_init_vty();
152 f_init_ns_codec(mp_nsconfig, guard_secs := 10.0);
153
154 /* do a NS Reset procedure */
155 f_outgoing_ns_reset();
156
157 activate(as_rx_ns_unblock_ack());
158 /* check outgoing NS procedure */
159 as_rx_alive_tx_ack(oneshot := true);
160
161 setverdict(pass);
162 f_sleep(1.0);
163}
164
165/* 48.016 7.2 unblock procedure
166 *
167 * TTCN -> NS: reset
168 * TTCN <- NS: reset ack
169 * TTCN -> NS: unblock
170 * TTCN <- NS: unblock ack
171 */
172testcase TC_tx_unblock() runs on RAW_Test_CT {
173 f_init_vty();
174 f_init_ns_codec(mp_nsconfig, guard_secs := 30.0);
175
176 /* do a NS Reset procedure */
177 f_outgoing_ns_reset();
178 /* send alive acks */
179 activate(as_rx_alive_tx_ack());
180
181 f_outgoing_ns_unblock();
182 setverdict(pass);
183 f_sleep(1.0);
184}
185
186/* 48.016 7.2 tx unblock retries
187 *
188 * TTCN -> NS: reset
189 * TTCN <- NS: reset ack
190 * TTCN -> NS: unblock
191 * TTCN <- NS: unblock ack
192 * TTCN -> NS: unblock
193 * TTCN <- NS: unblock ack
194 * TTCN -> NS: unblock
195 * TTCN <- NS: unblock ack
196 */
197testcase TC_tx_unblock_retries() runs on RAW_Test_CT {
198 f_init_vty();
199 f_init_ns_codec(mp_nsconfig, guard_secs := 30.0);
200
201 /* do a NS Reset procedure */
202 f_outgoing_ns_reset();
203 /* send alive acks */
204 activate(as_rx_alive_tx_ack());
205
206 f_outgoing_ns_unblock();
207 f_outgoing_ns_unblock();
208 f_outgoing_ns_unblock();
209 setverdict(pass);
210 f_sleep(1.0);
211}
212
213/* 48.016 7.2 block procedure
214 *
215 * TTCN -> NS: reset
216 * TTCN <- NS: reset ack
217 * TTCN -> NS: unblock
218 * TTCN <- NS: unblock ack
219 * TTCN -> NS: block
220 * TTCN <- NS: block ack
221 */
222testcase TC_tx_block() runs on RAW_Test_CT {
223 f_init_vty();
224 f_init_ns_codec(mp_nsconfig, guard_secs := 30.0);
225
226 /* do a NS Reset procedure */
227 f_outgoing_ns_reset();
228 activate(as_rx_alive_tx_ack());
229
230 f_outgoing_ns_unblock();
231 f_sleep(1.0);
232
233 f_outgoing_ns_block(NS_CAUSE_EQUIPMENT_FAILURE);
234 setverdict(pass);
235 f_sleep(1.0);
236}
237
238/* 48.016 7.2 block procedure by vty
239 *
240 * TTCN -> NS: reset
241 * TTCN <- NS: reset ack
242 * TTCN -> NS: unblock
243 * TTCN <- NS: unblock ack
244 * vty: block nsvc
245 * TTCN <- NS: block
246 * TTCN -> NS: block ack
247 */
248function tx_block_by_vty(float guard_secs := 30.0) runs on RAW_Test_CT {
249 f_init_vty();
250 f_init_ns_codec(mp_nsconfig, guard_secs := guard_secs);
251
252 /* do a NS Reset procedure */
253 f_outgoing_ns_reset();
254 activate(as_rx_alive_tx_ack());
255
256 f_outgoing_ns_unblock();
257 f_sleep(1.0);
258
259 f_vty_transceive(NSVTY, "nsvc " & int2str(mp_nsconfig.nsvc[0].nsvci) & " block");
260
261 alt {
262 [] as_rx_ns_block_ack(oneshot := true, nsvci := mp_nsconfig.nsvc[0].nsvci);
263 }
264 setverdict(pass);
265}
266
267testcase TC_tx_block_by_vty() runs on RAW_Test_CT {
268 tx_block_by_vty(30.0);
269 f_sleep(1.0);
270}
271
272/* 48.016 7.2 block precedure by vty and reset the NSVC.
273 * The NSVC should be still blocked after the reset.
274 */
275testcase TC_tx_block_by_vty_reset() runs on RAW_Test_CT {
276 timer T := 10.0;
277
278 tx_block_by_vty(60.0);
279 f_outgoing_ns_reset();
280
281 var default d := activate(ax_rx_fail_on_any_ns());
282 T.start;
283 alt {
284 [] as_rx_alive_tx_ack();
285 [] T.timeout { setverdict(pass); }
286 }
287 deactivate(d);
288}
289
290/* 48.016 7.4.1 ignore unexpected NS_ALIVE ACK */
291testcase TC_no_reset_alive_ack() runs on RAW_Test_CT {
292 f_init_vty();
293 f_init_ns_codec(mp_nsconfig, guard_secs := 30.0);
294
295 NSCP[0].send(t_NS_ALIVE_ACK);
296 f_fails_except_reset();
297 setverdict(pass);
298 f_sleep(1.0);
299}
300
301/* 48.016 7.3.1 NS_RESET with wrong nsei */
302testcase TC_reset_wrong_nsei() runs on RAW_Test_CT {
303 f_init_vty();
304 f_init_ns_codec(mp_nsconfig, guard_secs := 30.0);
305
306 NSCP[0].send(ts_NS_RESET(NS_CAUSE_EQUIPMENT_FAILURE, g_nsconfig.nsvc[0].nsvci, g_nsconfig.nsei + 20));
307 NSCP[0].receive(tr_NS_RESET_ACK(g_nsconfig.nsvc[0].nsvci, g_nsconfig.nsei));
308 f_fails_except_reset();
309 setverdict(pass);
310 f_sleep(1.0);
311}
312
313/* 48.016 7.3.1 NS_RESET with wrong nsvci */
314testcase TC_reset_wrong_nsvci() runs on RAW_Test_CT {
315 f_init_vty();
316 f_init_ns_codec(mp_nsconfig, guard_secs := 30.0);
317
318 NSCP[0].send(ts_NS_RESET(NS_CAUSE_EQUIPMENT_FAILURE, g_nsconfig.nsvc[0].nsvci + 20, g_nsconfig.nsei));
319 NSCP[0].receive(tr_NS_RESET_ACK(g_nsconfig.nsvc[0].nsvci, g_nsconfig.nsei));
320 f_fails_except_reset();
321 setverdict(pass);
322 f_sleep(1.0);
323}
324
325/* 48.016 7.3.1 NS_RESET with wrong nsvci + nsei */
326testcase TC_reset_wrong_nsei_nsvci() runs on RAW_Test_CT {
327 f_init_vty();
328 f_init_ns_codec(mp_nsconfig, guard_secs := 30.0);
329
330 NSCP[0].send(ts_NS_RESET(NS_CAUSE_EQUIPMENT_FAILURE, g_nsconfig.nsvc[0].nsvci + 20, g_nsconfig.nsei + 20));
331 NSCP[0].receive(tr_NS_RESET_ACK(g_nsconfig.nsvc[0].nsvci, g_nsconfig.nsei));
332 f_fails_except_reset();
333 setverdict(pass);
334 f_sleep(1.0);
335}
336
337/* 48.016 7.3.1 NS_RESET_ACK with wrong nsei */
338testcase TC_reset_ack_wrong_nsei() runs on RAW_Test_CT {
339 f_init_vty();
340 f_init_ns_codec(mp_nsconfig, guard_secs := 30.0);
341
342 NSCP[0].receive(tr_NS_RESET(*, g_nsconfig.nsvc[0].nsvci, g_nsconfig.nsei));
343 NSCP[0].send(ts_NS_RESET_ACK(g_nsconfig.nsvc[0].nsvci, g_nsconfig.nsei + 20));
344 f_fails_except_reset();
345 setverdict(pass);
346 f_sleep(1.0);
347}
348
349/* 48.016 7.3.1 NS_RESET_ACK with wrong nsvci */
350testcase TC_reset_ack_wrong_nsvci() runs on RAW_Test_CT {
351 f_init_vty();
352 f_init_ns_codec(mp_nsconfig, guard_secs := 30.0);
353
354 NSCP[0].receive(tr_NS_RESET(*, g_nsconfig.nsvc[0].nsvci, g_nsconfig.nsei));
355 NSCP[0].send(ts_NS_RESET_ACK(g_nsconfig.nsvc[0].nsvci + 20, g_nsconfig.nsei));
356 f_fails_except_reset();
357 setverdict(pass);
358 f_sleep(1.0);
359}
360
361/* 48.016 7.3.1 NS_RESET_ACK with wrong nsvci + nsei */
362testcase TC_reset_ack_wrong_nsei_nsvci() runs on RAW_Test_CT {
363 f_init_vty();
364 f_init_ns_codec(mp_nsconfig, guard_secs := 30.0);
365
366 NSCP[0].receive(tr_NS_RESET(*, g_nsconfig.nsvc[0].nsvci, g_nsconfig.nsei));
367 NSCP[0].send(ts_NS_RESET_ACK(g_nsconfig.nsvc[0].nsvci + 20, g_nsconfig.nsei + 20));
368 f_fails_except_reset();
369 setverdict(pass);
370 f_sleep(1.0);
371}
372
373/* 48.016 7.3.1 ignore unexpected NS_RESET_ACK after NS_RESET+ALIVE */
374testcase TC_ignore_reset_ack() runs on RAW_Test_CT {
375 f_init_vty();
376 f_init_ns_codec(mp_nsconfig, guard_secs := 30.0);
377
378 /* do a NS Reset procedure */
379 f_outgoing_ns_reset();
380
381 /* unblock and alive */
382 alt {
383 [] as_rx_ns_unblock_ack(oneshot := true);
384 [] as_rx_alive_tx_ack();
385 }
386
387 NSCP[0].send(ts_NS_RESET_ACK(g_nsconfig.nsvc[0].nsvci, g_nsconfig.nsei));
388 f_ensure_no_ns(answer_alive := true, tout := 15.0);
389 setverdict(pass);
390 f_sleep(1.0);
391}
392
393/* 48.016 7.3 NS_RESET retries */
394testcase TC_reset_retries() runs on RAW_Test_CT {
395 var integer reset := 0;
396
397 f_init_vty();
398 f_init_ns_codec(mp_nsconfig, guard_secs := 30.0);
399
400 alt {
401 [] NSCP[0].receive(tr_NS_RESET(*, *, *)) {
402 reset := reset + 1;
403 if (reset <= 3) {
404 repeat;
405 } else {
406 setverdict(pass);
407 }
408 }
409 }
410
411 f_sleep(1.0);
412}
413
414/* 48.016 behave RESET_ACK got dropped
415 * TTCN -> NS: reset
416 * TTCN <- NS: reset ack
417 * TTCN <- NS: unblock
418 * TTCN -> NS: reset
419 * TTCN <- NS: reset ack
420 * TTCN <- NS: unblock
421 */
422testcase TC_reset_on_block_reset() runs on RAW_Test_CT {
423 var integer i := 0;
424
425 f_init_vty();
426 f_init_ns_codec(mp_nsconfig, guard_secs := 30.0);
427
428 f_outgoing_ns_reset();
429 activate(as_rx_alive_tx_ack());
430
431 alt {
432 [] NSCP[0].receive(t_NS_UNBLOCK) {
433 NSCP[0].send(ts_NS_RESET(NS_CAUSE_EQUIPMENT_FAILURE, g_nsconfig.nsvc[0].nsvci, g_nsconfig.nsei));
434 i := i + 1;
435 if (i < 3) {
436 repeat;
437 } else {
438 setverdict(pass);
439 }
440 }
441 [] NSCP[0].receive(tr_NS_RESET_ACK(g_nsconfig.nsvc[0].nsvci, g_nsconfig.nsei)) { repeat; }
442 }
443
444 f_sleep(1.0);
445}
446
447/* 48.016 7.4 test procedure for frame relay with a single nsvci */
448function f_alive_retries_single(boolean reset := false) runs on RAW_Test_CT {
449 f_init_vty();
450 f_init_ns_codec(mp_nsconfig, guard_secs := 60.0);
451
452 /* do a NS Reset procedure */
453 f_outgoing_ns_reset();
454
455 alt {
456 [] as_rx_ns_unblock_ack(oneshot := true);
457 [] as_rx_alive_tx_ack();
458 }
459
460 /* wait for one alive and answer it */
461 as_rx_alive_tx_ack(oneshot := true);
462 NSCP[0].receive(t_NS_ALIVE);
463 NSCP[0].receive(t_NS_ALIVE);
464 NSCP[0].receive(t_NS_ALIVE);
465 NSCP[0].receive(t_NS_ALIVE);
466 if (reset) {
467 NSCP[0].receive(tr_NS_RESET(*, g_nsconfig.nsvc[0].nsvci, g_nsconfig.nsei));
468 } else {
469 f_ensure_no_ns(tout := 10.0);
470 }
471
472 setverdict(pass);
473 f_sleep(1.0);
474}
475
476testcase TC_alive_retries_single_reset() runs on RAW_Test_CT {
477 f_alive_retries_single(reset := true);
478}
479
480testcase TC_alive_retries_single_no_resp() runs on RAW_Test_CT {
481 f_alive_retries_single(reset := false);
482}
483
Alexander Couzenscbee32a2021-02-27 20:50:20 +0100484/* 48.016 SNS test cases */
485
486/* do a succesful SNS configuration */
Alexander Couzens79606cf2021-07-27 14:59:29 +0200487testcase TC_sns_bss_config_success() runs on RAW_Test_CT {
Alexander Couzenscbee32a2021-02-27 20:50:20 +0100488 f_init_vty();
489 f_init_ns_codec(mp_nsconfig);
490 f_incoming_sns_size();
491 f_incoming_sns_config();
492 f_outgoing_sns_config();
493 setverdict(pass);
494 f_clean_ns_codec();
495}
496
Alexander Couzensd5ac5102021-02-27 20:53:37 +0100497testcase TC_sns_bss_change_weight() runs on RAW_Test_CT {
Alexander Couzens60548b12021-04-14 19:39:26 +0200498 g_handle_rx_alive := true;
Alexander Couzensd5ac5102021-02-27 20:53:37 +0100499 f_init_vty();
500 f_init_ns_codec(mp_nsconfig);
501 f_incoming_sns_size();
502 f_incoming_sns_config();
503 f_outgoing_sns_config();
504 activate(as_rx_alive_tx_ack());
505 f_vty_config2(NSVTY, {"ns", "bind udp local"}, "ip-sns signalling-weight 99 data-weight 99");
506 f_incoming_sns_chg_weight();
507 setverdict(pass);
508 f_clean_ns_codec();
509}
510
Alexander Couzens6c723fb2021-03-01 00:12:00 +0100511/* receive 3x SNS_CHG_WEIGHT but never answer on it */
512testcase TC_sns_bss_change_weight_timeout() runs on RAW_Test_CT {
513 var integer i := 0;
514 var template PDU_NS rx;
515 var NSVCConfiguration nsvc_cfg;
516
Alexander Couzens60548b12021-04-14 19:39:26 +0200517 g_handle_rx_alive := true;
Alexander Couzens6c723fb2021-03-01 00:12:00 +0100518 f_init_vty();
519 f_init_ns_codec(mp_nsconfig);
520 f_incoming_sns_size();
521 f_incoming_sns_config();
522 f_outgoing_sns_config();
523 activate(as_rx_alive_tx_ack());
524 f_vty_config2(NSVTY, {"ns", "bind udp local"}, "ip-sns signalling-weight 99 data-weight 99");
525
526 nsvc_cfg := g_nsconfig.nsvc[0];
527 if (nsvc_cfg.provider.ip.address_family == AF_INET) {
528 var template IP4_Elements v4_elem := { tr_SNS_IPv4(nsvc_cfg.provider.ip.remote_ip,
529 nsvc_cfg.provider.ip.remote_udp_port) };
530
531 rx := tr_SNS_CHG_WEIGHT(g_nsconfig.nsei, ?, v4 := v4_elem);
532 } else {
533 var template IP6_Elements v6_elem := { tr_SNS_IPv6(nsvc_cfg.provider.ip.remote_ip,
534 nsvc_cfg.provider.ip.remote_udp_port) };
535 rx := tr_SNS_CHG_WEIGHT(g_nsconfig.nsei, ?, v4 := omit, v6 := v6_elem);
536 }
537
Alexander Couzens60548b12021-04-14 19:39:26 +0200538 for (i := 0; i < 3; i := i + 1) {
539 f_ns_exp(rx);
Alexander Couzens6c723fb2021-03-01 00:12:00 +0100540 }
541
Alexander Couzensa93cc362021-04-14 19:39:18 +0200542 if (nsvc_cfg.provider.ip.address_family == AF_INET) {
543 /* expect one single SNS-SIZE with RESET flag; 4x v4 EP; no v6 EP */
544 rx := f_ns_exp(tr_SNS_SIZE(g_nsconfig.nsei, rst_flag := true, max_nsvcs := ?,
545 num_v4 := ?, num_v6 := omit), 0);
546 } else {
547 /* expect one single SNS-SIZE with RESET flag; no v4 EP; 4x v6 EP */
548 rx := f_ns_exp(tr_SNS_SIZE(g_nsconfig.nsei, rst_flag := true, max_nsvcs := ?,
549 num_v4 := omit, num_v6 := ?), 0);
550 }
551
Alexander Couzens6c723fb2021-03-01 00:12:00 +0100552 setverdict(pass);
553 f_clean_ns_codec();
554}
555
Alexander Couzens6f17ecc2021-05-25 13:43:57 +0200556testcase TC_sns_bss_add() runs on RAW_Test_CT {
557 g_handle_rx_alive := true;
558 f_init_vty();
559 f_init_ns_codec(mp_nsconfig);
560 f_init_ns_codec(mp_nsconfig, 1);
561 f_incoming_sns_size();
562 f_incoming_sns_config();
563 f_outgoing_sns_config();
564 activate(as_rx_alive_tx_ack());
565 f_vty_config2(NSVTY, {"ns", "nse " & int2str(g_nsconfig.nsei)}, "ip-sns-bind local2");
566 f_incoming_sns_add(idx_add := 1);
567 as_rx_alive_tx_ack(oneshot := true, idx := 1);
568 setverdict(pass);
569 f_clean_ns_codec();
570}
571
572testcase TC_sns_bss_del() runs on RAW_Test_CT {
573 g_handle_rx_alive := true;
574 f_init_vty();
575 f_init_ns_codec(mp_nsconfig);
576 f_init_ns_codec(mp_nsconfig, 1);
577 f_incoming_sns_size();
578 f_incoming_sns_config();
579 f_outgoing_sns_config();
580 activate(as_rx_alive_tx_ack());
581 f_vty_config2(NSVTY, {"ns", "nse " & int2str(g_nsconfig.nsei)}, "ip-sns-bind local2");
582 f_incoming_sns_add(idx_add := 1);
583 as_rx_alive_tx_ack(oneshot := true, idx := 1);
584
585 /* delete the endpoint */
586 f_vty_config2(NSVTY, {"ns", "nse " & int2str(g_nsconfig.nsei)}, "no ip-sns-bind local2");
587 f_incoming_sns_del(idx_del := 1);
588 setverdict(pass);
589 f_clean_ns_codec();
590}
591
Alexander Couzense23387a2021-06-06 23:15:42 +0200592/* 1. do SNS configuration
593 * 2. add a bind
594 * 3. receive the SNS_ADD
595 * 4. before answering the SNS_ADD, change the weight via vty and remove the bind
596 */
597testcase TC_sns_bss_add_change_del() runs on RAW_Test_CT {
598 var PDU_NS rx;
599 var NSVCConfiguration nsvc_cfg;
600
601 g_handle_rx_alive := true;
602 f_init_vty();
603 f_init_ns_codec(mp_nsconfig);
604 f_init_ns_codec(mp_nsconfig, 1);
605 f_incoming_sns_size();
606 f_incoming_sns_config();
607 f_outgoing_sns_config();
608 activate(as_rx_alive_tx_ack());
609 f_vty_config2(NSVTY, {"ns", "nse " & int2str(g_nsconfig.nsei)}, "ip-sns-bind local2");
610
611 /* rx SNS ADD */
612 nsvc_cfg := g_nsconfig.nsvc[1];
613 if (nsvc_cfg.provider.ip.address_family == AF_INET) {
614 var template (omit) IP4_Elements v4_elem := { ts_SNS_IPv4(nsvc_cfg.provider.ip.remote_ip,
615 nsvc_cfg.provider.ip.remote_udp_port,
616 1, 1) };
617 rx := f_ns_exp(tr_SNS_ADD(g_nsconfig.nsei, ?, v4 := v4_elem), 0);
618 } else {
619 var template (omit) IP6_Elements v6_elem := { ts_SNS_IPv6(nsvc_cfg.provider.ip.remote_ip,
620 nsvc_cfg.provider.ip.remote_udp_port,
621 1, 1) };
622 rx := f_ns_exp(tr_SNS_ADD(g_nsconfig.nsei, ?, omit, v6_elem), 0);
623 }
624
625 /* delete the endpoint */
626 f_vty_config2(NSVTY, {"ns", "bind udp local2"}, "ip-sns signalling-weight 99 data-weight 99");
627 f_vty_config2(NSVTY, {"ns", "nse " & int2str(g_nsconfig.nsei)}, "no ip-sns-bind local2");
628
629 /* accept the SNS_ADD */
630 NSCP[0].send(ts_SNS_ACK(g_nsconfig.nsei, rx.pDU_SNS_Add.transactionID));
631
632 f_incoming_sns_chg_weight(idx_chg := 1);
633 f_incoming_sns_del(idx_del := 1, w_sig := 99, w_user := 99);
634 setverdict(pass);
635 f_clean_ns_codec();
636}
637
Alexander Couzens31f81502021-07-12 18:15:01 +0200638/* Ensure the ns2 code doesn't crash when calling force unconfigured while sending SNS SIZE */
639testcase TC_sns_rx_size_force_unconf() runs on RAW_Test_CT {
640 g_handle_rx_alive := true;
641 f_init_vty();
642 f_init_ns_codec(mp_nsconfig);
643 f_init_ns_codec(mp_nsconfig, 1);
644 f_ns_exp(tr_SNS_SIZE(mp_nsconfig.nsei, rst_flag := true, max_nsvcs := ?,
645 num_v4 := ?, num_v6 := omit));
646 f_vty_transceive(NSVTY, "nsvc nsei " & int2str(mp_nsconfig.nsei) & " force-unconfigured");
647 f_ns_exp(tr_SNS_SIZE(mp_nsconfig.nsei, rst_flag := true, max_nsvcs := ?,
648 num_v4 := ?, num_v6 := omit));
649 setverdict(pass);
650 f_clean_ns_codec();
651}
652
Alexander Couzens1650b162021-06-13 04:05:56 +0200653/* Test if SNS fails when all signalling NSVCs failes
654 * 3GPP TS 48.016 § 7.4b.1.1
655 * 1. do success SNS configuration
656 * 2. change sig weight of the seconds inactive bind
657 * 3. add second bind to SNS
658 * 4. stop reacting to NS_ALIVE on first NSVC (only NSVC with sig weight)
659 * 5. expect SNS SIZE
Alexander Couzens8122ed22021-08-06 22:01:20 +0200660 *
661 * Broken: the test case tests the wrong side. The signalling
662 * and data weight are valid for the other side. The correct
663 * test case needs to add a second bind on the ttcn3 side.
Alexander Couzens1650b162021-06-13 04:05:56 +0200664 */
665testcase TC_sns_bss_all_signalling_nsvcs_failed() runs on RAW_Test_CT {
666 g_handle_rx_alive := true;
667 f_init_vty();
668 f_init_ns_codec(mp_nsconfig);
669 f_init_ns_codec(mp_nsconfig, 1);
670 f_incoming_sns_size();
671 f_incoming_sns_config();
672 f_outgoing_sns_config();
673 var default d := activate(as_rx_alive_tx_ack());
674
675 f_vty_config2(NSVTY, {"ns", "bind udp local2"}, "ip-sns signalling-weight 0 data-weight 99");
676 f_vty_config2(NSVTY, {"ns", "nse " & int2str(g_nsconfig.nsei)}, "ip-sns-bind local2");
677 f_incoming_sns_add(idx_add := 1, w_sig := 0, w_user := 99);
678 as_rx_alive_tx_ack(oneshot := true, idx := 1);
679 activate(as_rx_alive_tx_ack(idx := 1));
680 /* 2x NSVCs up, stop first NSVC */
681 deactivate(d);
682 /* libosmocore will rotate the SNS binds on failure */
683 NSCP[0].receive(t_NS_ALIVE);
684 NSCP[0].receive(t_NS_ALIVE);
685 NSCP[0].receive(t_NS_ALIVE);
686 f_incoming_sns_size(idx := 1);
687
688 setverdict(pass);
689 f_clean_ns_codec();
690}
691
Alexander Couzensfdfe6382021-09-03 23:17:35 +0200692/* Test if SNS fails when removing a bind which has the last valid connection
693 *
694 * ns2 has 2 binds, ttcn3 1 bind.
695 *
696 * nsvcs:
697 * ns2 ttcn3
698 * 1*-----------*1
699 * /
700 * 2*-broken--/
701 *
702 * remove the 1st ns2 bind.
703 */
704testcase TC_sns_bss_remove_bind_fail_sns() runs on RAW_Test_CT {
705 g_handle_rx_alive := true;
706 f_init_vty();
707 f_init_ns_codec(mp_nsconfig);
708 f_init_ns_codec(mp_nsconfig, 1);
709 f_incoming_sns_size();
710 f_incoming_sns_config();
711 f_outgoing_sns_config();
712 var default d := activate(as_rx_alive_tx_ack());
713
714 f_vty_config2(NSVTY, {"ns", "bind udp local2"}, "ip-sns signalling-weight 1 data-weight 1");
715 f_vty_config2(NSVTY, {"ns", "nse " & int2str(g_nsconfig.nsei)}, "ip-sns-bind local2");
716 f_incoming_sns_add(idx_add := 1, w_sig := 1, w_user := 1);
717 /* 2nd bind won't have a valid connection to the ttcn3 */
718 NSCP[1].receive(t_NS_ALIVE);
719 NSCP[1].receive(t_NS_ALIVE);
720 NSCP[1].receive(t_NS_ALIVE);
721 NSCP[1].receive(t_NS_ALIVE);
722 NSCP[1].receive(t_NS_ALIVE);
723 f_sleep(1.0);
724 f_vty_config2(NSVTY, {"ns", "nse " & int2str(g_nsconfig.nsei)}, "no ip-sns-bind local");
725 setverdict(pass);
726 f_clean_ns_codec();
727}
728
Alexander Couzens5eeebaa2021-07-12 18:15:42 +0200729testcase TC_idle() runs on RAW_Test_CT {
730 f_init_vty();
731 f_init_ns_codec(mp_nsconfig, guard_secs := 30.0);
732
733 /* do a NS Reset procedure */
734 f_outgoing_ns_reset();
735 activate(as_rx_alive_tx_ack());
736
737 f_outgoing_ns_unblock();
738 f_sleep(30.0);
739
740 setverdict(pass);
741 f_sleep(1.0);
742 f_clean_ns_codec();
743}
744
Alexander Couzens358c74c2021-08-06 18:01:06 +0200745testcase TC_sns_sgsn_config_success() runs on RAW_Test_CT {
746 f_init_vty();
747 f_init_ns_codec(mp_nsconfig);
748 f_outgoing_sns_size();
749 f_outgoing_sns_config();
750 f_incoming_sns_config();
751 setverdict(pass);
752 f_clean_ns_codec();
753}
754
Alexander Couzens717bb212021-09-04 01:23:42 +0200755/* Ensure a SNS SIZE ACK is transmitted from the correct port */
756testcase TC_sns_sgsn_size_correct_port() runs on RAW_Test_CT {
757 f_init_vty();
758 f_init_ns_codec(mp_nsconfig);
759 f_init_ns_codec(mp_nsconfig, 1);
760 f_outgoing_sns_size(max_nsvcs := 10);
761 f_outgoing_sns_config();
762 f_incoming_sns_config();
763 NSCP[0].receive(t_NS_ALIVE);
764 f_outgoing_sns_size(max_nsvcs := 10, idx := 1);
765 setverdict(pass);
766 f_clean_ns_codec();
767}
768
Alexander Couzens6b51a3c2021-08-06 18:23:49 +0200769testcase TC_sns_sgsn_add() runs on RAW_Test_CT {
770 g_handle_rx_alive := true;
771 f_init_vty();
772 f_init_ns_codec(mp_nsconfig);
773 f_init_ns_codec(mp_nsconfig, 1);
774 f_outgoing_sns_size(max_nsvcs := 4, num_ip := 4);
775 f_outgoing_sns_config();
776 f_incoming_sns_config();
777 activate(as_rx_alive_tx_ack());
778
779 f_vty_config2(NSVTY, {"ns", "nse " & int2str(g_nsconfig.nsei)}, "ip-sns-bind local2");
780 f_incoming_sns_add(idx_add := 1);
781 as_rx_alive_tx_ack(oneshot := true, idx := 1);
782
783 setverdict(pass);
784 f_clean_ns_codec();
785}
786
Alexander Couzens8a682d62021-08-06 22:24:47 +0200787testcase TC_sns_sgsn_del() runs on RAW_Test_CT {
788 g_handle_rx_alive := true;
789 f_init_vty();
790 f_init_ns_codec(mp_nsconfig);
791 f_init_ns_codec(mp_nsconfig, 1);
792 f_outgoing_sns_size(max_nsvcs := 4, num_ip := 4);
793 f_outgoing_sns_config();
794 f_incoming_sns_config();
795 activate(as_rx_alive_tx_ack());
796
797 f_vty_config2(NSVTY, {"ns", "nse " & int2str(g_nsconfig.nsei)}, "ip-sns-bind local2");
798 f_incoming_sns_add(idx_add := 1);
799 as_rx_alive_tx_ack(oneshot := true, idx := 1);
800
801 /* delete the endpoint */
802 f_vty_config2(NSVTY, {"ns", "nse " & int2str(g_nsconfig.nsei)}, "no ip-sns-bind local2");
803 f_incoming_sns_del(idx_del := 1);
804
805 setverdict(pass);
806 f_clean_ns_codec();
807}
Alexander Couzens6b51a3c2021-08-06 18:23:49 +0200808
Alexander Couzens3921fb52021-08-12 04:04:20 +0200809/* 1. do SNS configuration
810 * 2. add a bind
811 * 3. receive the SNS_ADD
812 * 4. before answering the SNS_ADD, change the weight via vty and remove the bind
813 */
814testcase TC_sns_sgsn_add_change_del() runs on RAW_Test_CT {
815 var PDU_NS rx;
816 var NSVCConfiguration nsvc_cfg;
817
818 g_handle_rx_alive := true;
819 f_init_vty();
820 f_init_ns_codec(mp_nsconfig);
821 f_init_ns_codec(mp_nsconfig, 1);
822 f_outgoing_sns_size(max_nsvcs := 4, num_ip := 4);
823 f_outgoing_sns_config();
824 f_incoming_sns_config();
825 activate(as_rx_alive_tx_ack());
826 f_vty_config2(NSVTY, {"ns", "nse " & int2str(g_nsconfig.nsei)}, "ip-sns-bind local2");
827
828 /* rx SNS ADD */
829 nsvc_cfg := g_nsconfig.nsvc[1];
830 if (nsvc_cfg.provider.ip.address_family == AF_INET) {
831 var template (omit) IP4_Elements v4_elem := { ts_SNS_IPv4(nsvc_cfg.provider.ip.remote_ip,
832 nsvc_cfg.provider.ip.remote_udp_port,
833 1, 1) };
834 rx := f_ns_exp(tr_SNS_ADD(g_nsconfig.nsei, ?, v4 := v4_elem), 0);
835 } else {
836 var template (omit) IP6_Elements v6_elem := { ts_SNS_IPv6(nsvc_cfg.provider.ip.remote_ip,
837 nsvc_cfg.provider.ip.remote_udp_port,
838 1, 1) };
839 rx := f_ns_exp(tr_SNS_ADD(g_nsconfig.nsei, ?, omit, v6_elem), 0);
840 }
841
842 /* delete the endpoint */
843 f_vty_config2(NSVTY, {"ns", "bind udp local2"}, "ip-sns signalling-weight 99 data-weight 99");
844 f_vty_config2(NSVTY, {"ns", "nse " & int2str(g_nsconfig.nsei)}, "no ip-sns-bind local2");
845
846 /* accept the SNS_ADD */
847 NSCP[0].send(ts_SNS_ACK(g_nsconfig.nsei, rx.pDU_SNS_Add.transactionID));
848
849 f_incoming_sns_chg_weight(idx_chg := 1);
850 f_incoming_sns_del(idx_del := 1, w_sig := 99, w_user := 99);
851 setverdict(pass);
852 f_clean_ns_codec();
853}
854
Alexander Couzens20cd41e2021-01-11 02:56:03 +0100855control {
Alexander Couzense48d3552021-02-27 20:01:16 +0100856 if (mp_dialect == NS2_DIALECT_STATIC_RESETBLOCK or mp_dialect == NS2_DIALECT_IPACCESS) {
857 execute( TC_tx_reset() );
Alexander Couzens20cd41e2021-01-11 02:56:03 +0100858
Alexander Couzense48d3552021-02-27 20:01:16 +0100859 /* 48.016 7.2 Block procedure */
860 execute( TC_tx_block() );
861 execute( TC_tx_block_by_vty() );
862 execute( TC_tx_block_by_vty_reset() );
863 // execute( TC_block_other_nsvc() ); // reset, unblock, sleep(1), block over another nsvci
864 /* 48.016 7.2 Unblock procedure */
865 execute( TC_tx_unblock() );
866 execute( TC_tx_unblock_retries() );
867 // execute( TC_rx_unblock_tx_unblock() ); // wait for an rx unblock pdu, send an unblock pdu, expect unblock ack pdu
868 // execute( TC_unblockable() ); // block a NS-VCI via vty, try block procedure
Alexander Couzens20cd41e2021-01-11 02:56:03 +0100869
Alexander Couzense48d3552021-02-27 20:01:16 +0100870 /* 48.016 7.2.1 Block Abnormal Condition */
871 /* 48.016 7.2.1 Unblock Abnormal Condition */
872 /* 48.016 7.3.1 Abnormal Condition */
Alexander Couzens20cd41e2021-01-11 02:56:03 +0100873 execute( TC_reset_wrong_nsei() );
874 execute( TC_reset_wrong_nsvci() );
875 execute( TC_reset_wrong_nsei_nsvci() );
876 execute( TC_reset_ack_wrong_nsei() );
877 execute( TC_reset_ack_wrong_nsvci() );
878 execute( TC_reset_ack_wrong_nsei_nsvci() );
879 execute( TC_reset_retries() );
880 execute( TC_reset_on_block_reset() );
Alexander Couzense48d3552021-02-27 20:01:16 +0100881 execute( TC_ignore_reset_ack() );
Alexander Couzens20cd41e2021-01-11 02:56:03 +0100882
Alexander Couzense48d3552021-02-27 20:01:16 +0100883 /* 48.016 7.4 Test procedure on frame relay */
884 execute( TC_tx_reset_tx_alive() );
885 execute( TC_tx_reset_rx_alive() );
Alexander Couzens20cd41e2021-01-11 02:56:03 +0100886
Alexander Couzense48d3552021-02-27 20:01:16 +0100887 /* 48.016 7.4.1 Abnormal Condition */
888 if (mp_dialect == NS2_DIALECT_STATIC_RESETBLOCK) {
889 // execute( TC_alive_retries_multi() ); // check if alive retries works and block over an alive nsvc
890 execute( TC_alive_retries_single_reset() );
891 } else if (mp_dialect == NS2_DIALECT_IPACCESS) {
892 execute( TC_alive_retries_single_no_resp() );
893 }
894
895 execute( TC_no_reset_alive_ack() );
Alexander Couzens20cd41e2021-01-11 02:56:03 +0100896 }
Alexander Couzenscbee32a2021-02-27 20:50:20 +0100897
898 if (mp_dialect == NS2_DIALECT_SNS) {
Alexander Couzensde3dfaa2021-08-06 17:59:54 +0200899 if (mp_sns_role == SNS_ROLE_BSS) {
900 /* BSS test cases */
901 execute( TC_sns_bss_config_success() );
902 execute( TC_sns_bss_change_weight() );
903 execute( TC_sns_bss_change_weight_timeout() );
904 execute( TC_sns_bss_add() );
905 execute( TC_sns_bss_del() );
906 execute( TC_sns_bss_add_change_del() );
Alexander Couzens8122ed22021-08-06 22:01:20 +0200907 /* execute( TC_sns_bss_all_signalling_nsvcs_failed() ); */
Alexander Couzensde3dfaa2021-08-06 17:59:54 +0200908 execute( TC_sns_rx_size_force_unconf() );
Alexander Couzensfdfe6382021-09-03 23:17:35 +0200909 execute( TC_sns_bss_remove_bind_fail_sns() );
Alexander Couzensde3dfaa2021-08-06 17:59:54 +0200910 }
Alexander Couzens358c74c2021-08-06 18:01:06 +0200911
912 if (mp_sns_role == SNS_ROLE_SGSN) {
913 execute( TC_sns_sgsn_config_success() );
Alexander Couzens6b51a3c2021-08-06 18:23:49 +0200914 execute( TC_sns_sgsn_add() );
Alexander Couzens8a682d62021-08-06 22:24:47 +0200915 execute( TC_sns_sgsn_del() );
Alexander Couzens3921fb52021-08-12 04:04:20 +0200916 execute( TC_sns_sgsn_add_change_del() );
Alexander Couzens717bb212021-09-04 01:23:42 +0200917 execute( TC_sns_sgsn_size_correct_port() );
Alexander Couzens358c74c2021-08-06 18:01:06 +0200918 }
Alexander Couzenscbee32a2021-02-27 20:50:20 +0100919 }
Alexander Couzens20cd41e2021-01-11 02:56:03 +0100920}
921
922}