blob: 105d3972c2be61e7cdf193ec66713c61b7f7d316 [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
Alexander Couzens94d3d102021-09-06 00:20:42 +0200165/* 48.016 7.2.1 transmit a UNIT DATA over a BLOCKED NSVC when ttcn3 blocked it
166 *
167 * TTCN -> NS: reset
168 * TTCN <- NS: reset ack
169 * TTCN -> NS: unblock
170 * TTCN <- NS: unblock ack
171 * TTCN -> NS: block
172 * TTCN <- NS: block ack
173 * TTCN -> NS: unitdata
174 * TTCN <- NS: status (cause blocked)
175 */
176testcase TC_tx_block_unitdata_over_blocked() runs on RAW_Test_CT {
177 f_tx_block();
178 f_sleep(1.0);
179
180 NSCP[0].send(ts_NS_UNITDATA(t_SduCtrlB, 42, '0011234242230101'O));
181 f_ns_exp(tr_NS_STATUS(NS_CAUSE_NSVC_BLOCKED));
182
183 setverdict(pass);
184 f_sleep(1.0);
185 f_clean_ns_codec();
186}
187
188/* 48.016 7.2.1 transmit a UNIT DATA over a BLOCKED NSVC when ns2 blocked it
189 *
190 * TTCN -> NS: reset
191 * TTCN <- NS: reset ack
192 * TTCN -> NS: unblock
193 * TTCN <- NS: unblock ack
194 * TTCN <- NS: block
195 * TTCN -> NS: block ack
196 * TTCN -> NS: unitdata
197 * TTCN <- NS: status (cause blocked)
198 */
199testcase TC_rx_block_unitdata_over_blocked() runs on RAW_Test_CT {
200 tx_block_by_vty();
201 f_sleep(1.0);
202
203 NSCP[0].send(ts_NS_UNITDATA(t_SduCtrlB, 42, '0011234242230101'O));
204 f_ns_exp(tr_NS_STATUS(NS_CAUSE_NSVC_BLOCKED));
205
206 setverdict(pass);
207 f_sleep(1.0);
208 f_clean_ns_codec();
209}
210
Alexander Couzens20cd41e2021-01-11 02:56:03 +0100211/* 48.016 7.2 unblock procedure
212 *
213 * TTCN -> NS: reset
214 * TTCN <- NS: reset ack
215 * TTCN -> NS: unblock
216 * TTCN <- NS: unblock ack
217 */
218testcase TC_tx_unblock() runs on RAW_Test_CT {
219 f_init_vty();
220 f_init_ns_codec(mp_nsconfig, guard_secs := 30.0);
221
222 /* do a NS Reset procedure */
223 f_outgoing_ns_reset();
224 /* send alive acks */
225 activate(as_rx_alive_tx_ack());
226
227 f_outgoing_ns_unblock();
228 setverdict(pass);
229 f_sleep(1.0);
230}
231
232/* 48.016 7.2 tx unblock retries
233 *
234 * TTCN -> NS: reset
235 * TTCN <- NS: reset ack
236 * TTCN -> NS: unblock
237 * TTCN <- NS: unblock ack
238 * TTCN -> NS: unblock
239 * TTCN <- NS: unblock ack
240 * TTCN -> NS: unblock
241 * TTCN <- NS: unblock ack
242 */
243testcase TC_tx_unblock_retries() runs on RAW_Test_CT {
244 f_init_vty();
245 f_init_ns_codec(mp_nsconfig, guard_secs := 30.0);
246
247 /* do a NS Reset procedure */
248 f_outgoing_ns_reset();
249 /* send alive acks */
250 activate(as_rx_alive_tx_ack());
251
252 f_outgoing_ns_unblock();
253 f_outgoing_ns_unblock();
254 f_outgoing_ns_unblock();
255 setverdict(pass);
256 f_sleep(1.0);
257}
258
259/* 48.016 7.2 block procedure
260 *
261 * TTCN -> NS: reset
262 * TTCN <- NS: reset ack
263 * TTCN -> NS: unblock
264 * TTCN <- NS: unblock ack
265 * TTCN -> NS: block
266 * TTCN <- NS: block ack
267 */
Alexander Couzens94d3d102021-09-06 00:20:42 +0200268function f_tx_block(float guard_secs := 30.0) runs on RAW_Test_CT {
Alexander Couzens20cd41e2021-01-11 02:56:03 +0100269 f_init_vty();
Alexander Couzens94d3d102021-09-06 00:20:42 +0200270 f_init_ns_codec(mp_nsconfig, guard_secs := guard_secs);
Alexander Couzens20cd41e2021-01-11 02:56:03 +0100271
272 /* do a NS Reset procedure */
273 f_outgoing_ns_reset();
274 activate(as_rx_alive_tx_ack());
275
276 f_outgoing_ns_unblock();
277 f_sleep(1.0);
278
279 f_outgoing_ns_block(NS_CAUSE_EQUIPMENT_FAILURE);
280 setverdict(pass);
281 f_sleep(1.0);
282}
283
Alexander Couzens94d3d102021-09-06 00:20:42 +0200284testcase TC_tx_block() runs on RAW_Test_CT {
285 f_tx_block()
286 f_clean_ns_codec();
287}
288
Alexander Couzens20cd41e2021-01-11 02:56:03 +0100289/* 48.016 7.2 block procedure by vty
290 *
291 * TTCN -> NS: reset
292 * TTCN <- NS: reset ack
293 * TTCN -> NS: unblock
294 * TTCN <- NS: unblock ack
295 * vty: block nsvc
296 * TTCN <- NS: block
297 * TTCN -> NS: block ack
298 */
299function tx_block_by_vty(float guard_secs := 30.0) runs on RAW_Test_CT {
300 f_init_vty();
301 f_init_ns_codec(mp_nsconfig, guard_secs := guard_secs);
302
303 /* do a NS Reset procedure */
304 f_outgoing_ns_reset();
305 activate(as_rx_alive_tx_ack());
306
307 f_outgoing_ns_unblock();
308 f_sleep(1.0);
309
310 f_vty_transceive(NSVTY, "nsvc " & int2str(mp_nsconfig.nsvc[0].nsvci) & " block");
311
312 alt {
313 [] as_rx_ns_block_ack(oneshot := true, nsvci := mp_nsconfig.nsvc[0].nsvci);
314 }
315 setverdict(pass);
316}
317
318testcase TC_tx_block_by_vty() runs on RAW_Test_CT {
319 tx_block_by_vty(30.0);
320 f_sleep(1.0);
321}
322
323/* 48.016 7.2 block precedure by vty and reset the NSVC.
324 * The NSVC should be still blocked after the reset.
325 */
326testcase TC_tx_block_by_vty_reset() runs on RAW_Test_CT {
327 timer T := 10.0;
328
329 tx_block_by_vty(60.0);
330 f_outgoing_ns_reset();
331
332 var default d := activate(ax_rx_fail_on_any_ns());
333 T.start;
334 alt {
335 [] as_rx_alive_tx_ack();
336 [] T.timeout { setverdict(pass); }
337 }
338 deactivate(d);
339}
340
341/* 48.016 7.4.1 ignore unexpected NS_ALIVE ACK */
342testcase TC_no_reset_alive_ack() runs on RAW_Test_CT {
343 f_init_vty();
344 f_init_ns_codec(mp_nsconfig, guard_secs := 30.0);
345
346 NSCP[0].send(t_NS_ALIVE_ACK);
347 f_fails_except_reset();
348 setverdict(pass);
349 f_sleep(1.0);
350}
351
352/* 48.016 7.3.1 NS_RESET with wrong nsei */
353testcase TC_reset_wrong_nsei() runs on RAW_Test_CT {
354 f_init_vty();
355 f_init_ns_codec(mp_nsconfig, guard_secs := 30.0);
356
357 NSCP[0].send(ts_NS_RESET(NS_CAUSE_EQUIPMENT_FAILURE, g_nsconfig.nsvc[0].nsvci, g_nsconfig.nsei + 20));
358 NSCP[0].receive(tr_NS_RESET_ACK(g_nsconfig.nsvc[0].nsvci, g_nsconfig.nsei));
359 f_fails_except_reset();
360 setverdict(pass);
361 f_sleep(1.0);
362}
363
364/* 48.016 7.3.1 NS_RESET with wrong nsvci */
365testcase TC_reset_wrong_nsvci() runs on RAW_Test_CT {
366 f_init_vty();
367 f_init_ns_codec(mp_nsconfig, guard_secs := 30.0);
368
369 NSCP[0].send(ts_NS_RESET(NS_CAUSE_EQUIPMENT_FAILURE, g_nsconfig.nsvc[0].nsvci + 20, g_nsconfig.nsei));
370 NSCP[0].receive(tr_NS_RESET_ACK(g_nsconfig.nsvc[0].nsvci, g_nsconfig.nsei));
371 f_fails_except_reset();
372 setverdict(pass);
373 f_sleep(1.0);
374}
375
376/* 48.016 7.3.1 NS_RESET with wrong nsvci + nsei */
377testcase TC_reset_wrong_nsei_nsvci() runs on RAW_Test_CT {
378 f_init_vty();
379 f_init_ns_codec(mp_nsconfig, guard_secs := 30.0);
380
381 NSCP[0].send(ts_NS_RESET(NS_CAUSE_EQUIPMENT_FAILURE, g_nsconfig.nsvc[0].nsvci + 20, g_nsconfig.nsei + 20));
382 NSCP[0].receive(tr_NS_RESET_ACK(g_nsconfig.nsvc[0].nsvci, g_nsconfig.nsei));
383 f_fails_except_reset();
384 setverdict(pass);
385 f_sleep(1.0);
386}
387
388/* 48.016 7.3.1 NS_RESET_ACK with wrong nsei */
389testcase TC_reset_ack_wrong_nsei() runs on RAW_Test_CT {
390 f_init_vty();
391 f_init_ns_codec(mp_nsconfig, guard_secs := 30.0);
392
393 NSCP[0].receive(tr_NS_RESET(*, g_nsconfig.nsvc[0].nsvci, g_nsconfig.nsei));
394 NSCP[0].send(ts_NS_RESET_ACK(g_nsconfig.nsvc[0].nsvci, g_nsconfig.nsei + 20));
395 f_fails_except_reset();
396 setverdict(pass);
397 f_sleep(1.0);
398}
399
400/* 48.016 7.3.1 NS_RESET_ACK with wrong nsvci */
401testcase TC_reset_ack_wrong_nsvci() runs on RAW_Test_CT {
402 f_init_vty();
403 f_init_ns_codec(mp_nsconfig, guard_secs := 30.0);
404
405 NSCP[0].receive(tr_NS_RESET(*, g_nsconfig.nsvc[0].nsvci, g_nsconfig.nsei));
406 NSCP[0].send(ts_NS_RESET_ACK(g_nsconfig.nsvc[0].nsvci + 20, g_nsconfig.nsei));
407 f_fails_except_reset();
408 setverdict(pass);
409 f_sleep(1.0);
410}
411
412/* 48.016 7.3.1 NS_RESET_ACK with wrong nsvci + nsei */
413testcase TC_reset_ack_wrong_nsei_nsvci() runs on RAW_Test_CT {
414 f_init_vty();
415 f_init_ns_codec(mp_nsconfig, guard_secs := 30.0);
416
417 NSCP[0].receive(tr_NS_RESET(*, g_nsconfig.nsvc[0].nsvci, g_nsconfig.nsei));
418 NSCP[0].send(ts_NS_RESET_ACK(g_nsconfig.nsvc[0].nsvci + 20, g_nsconfig.nsei + 20));
419 f_fails_except_reset();
420 setverdict(pass);
421 f_sleep(1.0);
422}
423
424/* 48.016 7.3.1 ignore unexpected NS_RESET_ACK after NS_RESET+ALIVE */
425testcase TC_ignore_reset_ack() runs on RAW_Test_CT {
426 f_init_vty();
427 f_init_ns_codec(mp_nsconfig, guard_secs := 30.0);
428
429 /* do a NS Reset procedure */
430 f_outgoing_ns_reset();
431
432 /* unblock and alive */
433 alt {
434 [] as_rx_ns_unblock_ack(oneshot := true);
435 [] as_rx_alive_tx_ack();
436 }
437
438 NSCP[0].send(ts_NS_RESET_ACK(g_nsconfig.nsvc[0].nsvci, g_nsconfig.nsei));
439 f_ensure_no_ns(answer_alive := true, tout := 15.0);
440 setverdict(pass);
441 f_sleep(1.0);
442}
443
444/* 48.016 7.3 NS_RESET retries */
445testcase TC_reset_retries() runs on RAW_Test_CT {
446 var integer reset := 0;
447
448 f_init_vty();
449 f_init_ns_codec(mp_nsconfig, guard_secs := 30.0);
450
451 alt {
452 [] NSCP[0].receive(tr_NS_RESET(*, *, *)) {
453 reset := reset + 1;
454 if (reset <= 3) {
455 repeat;
456 } else {
457 setverdict(pass);
458 }
459 }
460 }
461
462 f_sleep(1.0);
463}
464
465/* 48.016 behave RESET_ACK got dropped
466 * TTCN -> NS: reset
467 * TTCN <- NS: reset ack
468 * TTCN <- NS: unblock
469 * TTCN -> NS: reset
470 * TTCN <- NS: reset ack
471 * TTCN <- NS: unblock
472 */
473testcase TC_reset_on_block_reset() runs on RAW_Test_CT {
474 var integer i := 0;
475
476 f_init_vty();
477 f_init_ns_codec(mp_nsconfig, guard_secs := 30.0);
478
479 f_outgoing_ns_reset();
480 activate(as_rx_alive_tx_ack());
481
482 alt {
483 [] NSCP[0].receive(t_NS_UNBLOCK) {
484 NSCP[0].send(ts_NS_RESET(NS_CAUSE_EQUIPMENT_FAILURE, g_nsconfig.nsvc[0].nsvci, g_nsconfig.nsei));
485 i := i + 1;
486 if (i < 3) {
487 repeat;
488 } else {
489 setverdict(pass);
490 }
491 }
492 [] NSCP[0].receive(tr_NS_RESET_ACK(g_nsconfig.nsvc[0].nsvci, g_nsconfig.nsei)) { repeat; }
493 }
494
495 f_sleep(1.0);
496}
497
498/* 48.016 7.4 test procedure for frame relay with a single nsvci */
499function f_alive_retries_single(boolean reset := false) runs on RAW_Test_CT {
500 f_init_vty();
501 f_init_ns_codec(mp_nsconfig, guard_secs := 60.0);
502
503 /* do a NS Reset procedure */
504 f_outgoing_ns_reset();
505
506 alt {
507 [] as_rx_ns_unblock_ack(oneshot := true);
508 [] as_rx_alive_tx_ack();
509 }
510
511 /* wait for one alive and answer it */
512 as_rx_alive_tx_ack(oneshot := true);
513 NSCP[0].receive(t_NS_ALIVE);
514 NSCP[0].receive(t_NS_ALIVE);
515 NSCP[0].receive(t_NS_ALIVE);
516 NSCP[0].receive(t_NS_ALIVE);
517 if (reset) {
518 NSCP[0].receive(tr_NS_RESET(*, g_nsconfig.nsvc[0].nsvci, g_nsconfig.nsei));
519 } else {
520 f_ensure_no_ns(tout := 10.0);
521 }
522
523 setverdict(pass);
524 f_sleep(1.0);
525}
526
527testcase TC_alive_retries_single_reset() runs on RAW_Test_CT {
528 f_alive_retries_single(reset := true);
529}
530
531testcase TC_alive_retries_single_no_resp() runs on RAW_Test_CT {
532 f_alive_retries_single(reset := false);
533}
534
Alexander Couzenscbee32a2021-02-27 20:50:20 +0100535/* 48.016 SNS test cases */
536
537/* do a succesful SNS configuration */
Alexander Couzens79606cf2021-07-27 14:59:29 +0200538testcase TC_sns_bss_config_success() runs on RAW_Test_CT {
Alexander Couzenscbee32a2021-02-27 20:50:20 +0100539 f_init_vty();
540 f_init_ns_codec(mp_nsconfig);
541 f_incoming_sns_size();
542 f_incoming_sns_config();
543 f_outgoing_sns_config();
544 setverdict(pass);
545 f_clean_ns_codec();
546}
547
Alexander Couzensd5ac5102021-02-27 20:53:37 +0100548testcase TC_sns_bss_change_weight() runs on RAW_Test_CT {
Alexander Couzens60548b12021-04-14 19:39:26 +0200549 g_handle_rx_alive := true;
Alexander Couzensd5ac5102021-02-27 20:53:37 +0100550 f_init_vty();
551 f_init_ns_codec(mp_nsconfig);
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", "bind udp local"}, "ip-sns signalling-weight 99 data-weight 99");
557 f_incoming_sns_chg_weight();
558 setverdict(pass);
559 f_clean_ns_codec();
560}
561
Alexander Couzens6c723fb2021-03-01 00:12:00 +0100562/* receive 3x SNS_CHG_WEIGHT but never answer on it */
563testcase TC_sns_bss_change_weight_timeout() runs on RAW_Test_CT {
564 var integer i := 0;
565 var template PDU_NS rx;
566 var NSVCConfiguration nsvc_cfg;
567
Alexander Couzens60548b12021-04-14 19:39:26 +0200568 g_handle_rx_alive := true;
Alexander Couzens6c723fb2021-03-01 00:12:00 +0100569 f_init_vty();
570 f_init_ns_codec(mp_nsconfig);
571 f_incoming_sns_size();
572 f_incoming_sns_config();
573 f_outgoing_sns_config();
574 activate(as_rx_alive_tx_ack());
575 f_vty_config2(NSVTY, {"ns", "bind udp local"}, "ip-sns signalling-weight 99 data-weight 99");
576
577 nsvc_cfg := g_nsconfig.nsvc[0];
578 if (nsvc_cfg.provider.ip.address_family == AF_INET) {
579 var template IP4_Elements v4_elem := { tr_SNS_IPv4(nsvc_cfg.provider.ip.remote_ip,
580 nsvc_cfg.provider.ip.remote_udp_port) };
581
582 rx := tr_SNS_CHG_WEIGHT(g_nsconfig.nsei, ?, v4 := v4_elem);
583 } else {
584 var template IP6_Elements v6_elem := { tr_SNS_IPv6(nsvc_cfg.provider.ip.remote_ip,
585 nsvc_cfg.provider.ip.remote_udp_port) };
586 rx := tr_SNS_CHG_WEIGHT(g_nsconfig.nsei, ?, v4 := omit, v6 := v6_elem);
587 }
588
Alexander Couzens60548b12021-04-14 19:39:26 +0200589 for (i := 0; i < 3; i := i + 1) {
590 f_ns_exp(rx);
Alexander Couzens6c723fb2021-03-01 00:12:00 +0100591 }
592
Alexander Couzensa93cc362021-04-14 19:39:18 +0200593 if (nsvc_cfg.provider.ip.address_family == AF_INET) {
594 /* expect one single SNS-SIZE with RESET flag; 4x v4 EP; no v6 EP */
595 rx := f_ns_exp(tr_SNS_SIZE(g_nsconfig.nsei, rst_flag := true, max_nsvcs := ?,
596 num_v4 := ?, num_v6 := omit), 0);
597 } else {
598 /* expect one single SNS-SIZE with RESET flag; no v4 EP; 4x v6 EP */
599 rx := f_ns_exp(tr_SNS_SIZE(g_nsconfig.nsei, rst_flag := true, max_nsvcs := ?,
600 num_v4 := omit, num_v6 := ?), 0);
601 }
602
Alexander Couzens6c723fb2021-03-01 00:12:00 +0100603 setverdict(pass);
604 f_clean_ns_codec();
605}
606
Alexander Couzens6f17ecc2021-05-25 13:43:57 +0200607testcase TC_sns_bss_add() runs on RAW_Test_CT {
608 g_handle_rx_alive := true;
609 f_init_vty();
610 f_init_ns_codec(mp_nsconfig);
611 f_init_ns_codec(mp_nsconfig, 1);
612 f_incoming_sns_size();
613 f_incoming_sns_config();
614 f_outgoing_sns_config();
615 activate(as_rx_alive_tx_ack());
616 f_vty_config2(NSVTY, {"ns", "nse " & int2str(g_nsconfig.nsei)}, "ip-sns-bind local2");
617 f_incoming_sns_add(idx_add := 1);
618 as_rx_alive_tx_ack(oneshot := true, idx := 1);
619 setverdict(pass);
620 f_clean_ns_codec();
621}
622
623testcase TC_sns_bss_del() runs on RAW_Test_CT {
624 g_handle_rx_alive := true;
625 f_init_vty();
626 f_init_ns_codec(mp_nsconfig);
627 f_init_ns_codec(mp_nsconfig, 1);
628 f_incoming_sns_size();
629 f_incoming_sns_config();
630 f_outgoing_sns_config();
631 activate(as_rx_alive_tx_ack());
632 f_vty_config2(NSVTY, {"ns", "nse " & int2str(g_nsconfig.nsei)}, "ip-sns-bind local2");
633 f_incoming_sns_add(idx_add := 1);
634 as_rx_alive_tx_ack(oneshot := true, idx := 1);
635
636 /* delete the endpoint */
637 f_vty_config2(NSVTY, {"ns", "nse " & int2str(g_nsconfig.nsei)}, "no ip-sns-bind local2");
638 f_incoming_sns_del(idx_del := 1);
639 setverdict(pass);
640 f_clean_ns_codec();
641}
642
Alexander Couzense23387a2021-06-06 23:15:42 +0200643/* 1. do SNS configuration
644 * 2. add a bind
645 * 3. receive the SNS_ADD
646 * 4. before answering the SNS_ADD, change the weight via vty and remove the bind
647 */
648testcase TC_sns_bss_add_change_del() runs on RAW_Test_CT {
649 var PDU_NS rx;
650 var NSVCConfiguration nsvc_cfg;
651
652 g_handle_rx_alive := true;
653 f_init_vty();
654 f_init_ns_codec(mp_nsconfig);
655 f_init_ns_codec(mp_nsconfig, 1);
656 f_incoming_sns_size();
657 f_incoming_sns_config();
658 f_outgoing_sns_config();
659 activate(as_rx_alive_tx_ack());
660 f_vty_config2(NSVTY, {"ns", "nse " & int2str(g_nsconfig.nsei)}, "ip-sns-bind local2");
661
662 /* rx SNS ADD */
663 nsvc_cfg := g_nsconfig.nsvc[1];
664 if (nsvc_cfg.provider.ip.address_family == AF_INET) {
665 var template (omit) IP4_Elements v4_elem := { ts_SNS_IPv4(nsvc_cfg.provider.ip.remote_ip,
666 nsvc_cfg.provider.ip.remote_udp_port,
667 1, 1) };
668 rx := f_ns_exp(tr_SNS_ADD(g_nsconfig.nsei, ?, v4 := v4_elem), 0);
669 } else {
670 var template (omit) IP6_Elements v6_elem := { ts_SNS_IPv6(nsvc_cfg.provider.ip.remote_ip,
671 nsvc_cfg.provider.ip.remote_udp_port,
672 1, 1) };
673 rx := f_ns_exp(tr_SNS_ADD(g_nsconfig.nsei, ?, omit, v6_elem), 0);
674 }
675
676 /* delete the endpoint */
677 f_vty_config2(NSVTY, {"ns", "bind udp local2"}, "ip-sns signalling-weight 99 data-weight 99");
678 f_vty_config2(NSVTY, {"ns", "nse " & int2str(g_nsconfig.nsei)}, "no ip-sns-bind local2");
679
680 /* accept the SNS_ADD */
681 NSCP[0].send(ts_SNS_ACK(g_nsconfig.nsei, rx.pDU_SNS_Add.transactionID));
682
683 f_incoming_sns_chg_weight(idx_chg := 1);
684 f_incoming_sns_del(idx_del := 1, w_sig := 99, w_user := 99);
685 setverdict(pass);
686 f_clean_ns_codec();
687}
688
Alexander Couzens31f81502021-07-12 18:15:01 +0200689/* Ensure the ns2 code doesn't crash when calling force unconfigured while sending SNS SIZE */
690testcase TC_sns_rx_size_force_unconf() runs on RAW_Test_CT {
691 g_handle_rx_alive := true;
692 f_init_vty();
693 f_init_ns_codec(mp_nsconfig);
694 f_init_ns_codec(mp_nsconfig, 1);
695 f_ns_exp(tr_SNS_SIZE(mp_nsconfig.nsei, rst_flag := true, max_nsvcs := ?,
696 num_v4 := ?, num_v6 := omit));
697 f_vty_transceive(NSVTY, "nsvc nsei " & int2str(mp_nsconfig.nsei) & " force-unconfigured");
698 f_ns_exp(tr_SNS_SIZE(mp_nsconfig.nsei, rst_flag := true, max_nsvcs := ?,
699 num_v4 := ?, num_v6 := omit));
700 setverdict(pass);
701 f_clean_ns_codec();
702}
703
Alexander Couzens1650b162021-06-13 04:05:56 +0200704/* Test if SNS fails when all signalling NSVCs failes
705 * 3GPP TS 48.016 § 7.4b.1.1
706 * 1. do success SNS configuration
707 * 2. change sig weight of the seconds inactive bind
708 * 3. add second bind to SNS
709 * 4. stop reacting to NS_ALIVE on first NSVC (only NSVC with sig weight)
710 * 5. expect SNS SIZE
Alexander Couzens8122ed22021-08-06 22:01:20 +0200711 *
712 * Broken: the test case tests the wrong side. The signalling
713 * and data weight are valid for the other side. The correct
714 * test case needs to add a second bind on the ttcn3 side.
Alexander Couzens1650b162021-06-13 04:05:56 +0200715 */
716testcase TC_sns_bss_all_signalling_nsvcs_failed() runs on RAW_Test_CT {
717 g_handle_rx_alive := true;
718 f_init_vty();
719 f_init_ns_codec(mp_nsconfig);
720 f_init_ns_codec(mp_nsconfig, 1);
721 f_incoming_sns_size();
722 f_incoming_sns_config();
723 f_outgoing_sns_config();
724 var default d := activate(as_rx_alive_tx_ack());
725
726 f_vty_config2(NSVTY, {"ns", "bind udp local2"}, "ip-sns signalling-weight 0 data-weight 99");
727 f_vty_config2(NSVTY, {"ns", "nse " & int2str(g_nsconfig.nsei)}, "ip-sns-bind local2");
728 f_incoming_sns_add(idx_add := 1, w_sig := 0, w_user := 99);
729 as_rx_alive_tx_ack(oneshot := true, idx := 1);
730 activate(as_rx_alive_tx_ack(idx := 1));
731 /* 2x NSVCs up, stop first NSVC */
732 deactivate(d);
733 /* libosmocore will rotate the SNS binds on failure */
734 NSCP[0].receive(t_NS_ALIVE);
735 NSCP[0].receive(t_NS_ALIVE);
736 NSCP[0].receive(t_NS_ALIVE);
737 f_incoming_sns_size(idx := 1);
738
739 setverdict(pass);
740 f_clean_ns_codec();
741}
742
Alexander Couzensfdfe6382021-09-03 23:17:35 +0200743/* Test if SNS fails when removing a bind which has the last valid connection
744 *
745 * ns2 has 2 binds, ttcn3 1 bind.
746 *
747 * nsvcs:
748 * ns2 ttcn3
749 * 1*-----------*1
750 * /
751 * 2*-broken--/
752 *
753 * remove the 1st ns2 bind.
754 */
755testcase TC_sns_bss_remove_bind_fail_sns() runs on RAW_Test_CT {
756 g_handle_rx_alive := true;
757 f_init_vty();
758 f_init_ns_codec(mp_nsconfig);
759 f_init_ns_codec(mp_nsconfig, 1);
760 f_incoming_sns_size();
761 f_incoming_sns_config();
762 f_outgoing_sns_config();
763 var default d := activate(as_rx_alive_tx_ack());
764
765 f_vty_config2(NSVTY, {"ns", "bind udp local2"}, "ip-sns signalling-weight 1 data-weight 1");
766 f_vty_config2(NSVTY, {"ns", "nse " & int2str(g_nsconfig.nsei)}, "ip-sns-bind local2");
767 f_incoming_sns_add(idx_add := 1, w_sig := 1, w_user := 1);
768 /* 2nd bind won't have a valid connection to the ttcn3 */
769 NSCP[1].receive(t_NS_ALIVE);
770 NSCP[1].receive(t_NS_ALIVE);
771 NSCP[1].receive(t_NS_ALIVE);
772 NSCP[1].receive(t_NS_ALIVE);
773 NSCP[1].receive(t_NS_ALIVE);
774 f_sleep(1.0);
775 f_vty_config2(NSVTY, {"ns", "nse " & int2str(g_nsconfig.nsei)}, "no ip-sns-bind local");
776 setverdict(pass);
777 f_clean_ns_codec();
778}
779
Alexander Couzens5eeebaa2021-07-12 18:15:42 +0200780testcase TC_idle() runs on RAW_Test_CT {
781 f_init_vty();
782 f_init_ns_codec(mp_nsconfig, guard_secs := 30.0);
783
784 /* do a NS Reset procedure */
785 f_outgoing_ns_reset();
786 activate(as_rx_alive_tx_ack());
787
788 f_outgoing_ns_unblock();
789 f_sleep(30.0);
790
791 setverdict(pass);
792 f_sleep(1.0);
793 f_clean_ns_codec();
794}
795
Alexander Couzens358c74c2021-08-06 18:01:06 +0200796testcase TC_sns_sgsn_config_success() runs on RAW_Test_CT {
797 f_init_vty();
798 f_init_ns_codec(mp_nsconfig);
799 f_outgoing_sns_size();
800 f_outgoing_sns_config();
801 f_incoming_sns_config();
802 setverdict(pass);
803 f_clean_ns_codec();
804}
805
Alexander Couzens717bb212021-09-04 01:23:42 +0200806/* Ensure a SNS SIZE ACK is transmitted from the correct port */
807testcase TC_sns_sgsn_size_correct_port() runs on RAW_Test_CT {
808 f_init_vty();
809 f_init_ns_codec(mp_nsconfig);
810 f_init_ns_codec(mp_nsconfig, 1);
811 f_outgoing_sns_size(max_nsvcs := 10);
812 f_outgoing_sns_config();
813 f_incoming_sns_config();
814 NSCP[0].receive(t_NS_ALIVE);
815 f_outgoing_sns_size(max_nsvcs := 10, idx := 1);
816 setverdict(pass);
817 f_clean_ns_codec();
818}
819
Alexander Couzens6b51a3c2021-08-06 18:23:49 +0200820testcase TC_sns_sgsn_add() runs on RAW_Test_CT {
821 g_handle_rx_alive := true;
822 f_init_vty();
823 f_init_ns_codec(mp_nsconfig);
824 f_init_ns_codec(mp_nsconfig, 1);
825 f_outgoing_sns_size(max_nsvcs := 4, num_ip := 4);
826 f_outgoing_sns_config();
827 f_incoming_sns_config();
828 activate(as_rx_alive_tx_ack());
829
830 f_vty_config2(NSVTY, {"ns", "nse " & int2str(g_nsconfig.nsei)}, "ip-sns-bind local2");
831 f_incoming_sns_add(idx_add := 1);
832 as_rx_alive_tx_ack(oneshot := true, idx := 1);
833
834 setverdict(pass);
835 f_clean_ns_codec();
836}
837
Alexander Couzens8a682d62021-08-06 22:24:47 +0200838testcase TC_sns_sgsn_del() runs on RAW_Test_CT {
839 g_handle_rx_alive := true;
840 f_init_vty();
841 f_init_ns_codec(mp_nsconfig);
842 f_init_ns_codec(mp_nsconfig, 1);
843 f_outgoing_sns_size(max_nsvcs := 4, num_ip := 4);
844 f_outgoing_sns_config();
845 f_incoming_sns_config();
846 activate(as_rx_alive_tx_ack());
847
848 f_vty_config2(NSVTY, {"ns", "nse " & int2str(g_nsconfig.nsei)}, "ip-sns-bind local2");
849 f_incoming_sns_add(idx_add := 1);
850 as_rx_alive_tx_ack(oneshot := true, idx := 1);
851
852 /* delete the endpoint */
853 f_vty_config2(NSVTY, {"ns", "nse " & int2str(g_nsconfig.nsei)}, "no ip-sns-bind local2");
854 f_incoming_sns_del(idx_del := 1);
855
856 setverdict(pass);
857 f_clean_ns_codec();
858}
Alexander Couzens6b51a3c2021-08-06 18:23:49 +0200859
Alexander Couzens3921fb52021-08-12 04:04:20 +0200860/* 1. do SNS configuration
861 * 2. add a bind
862 * 3. receive the SNS_ADD
863 * 4. before answering the SNS_ADD, change the weight via vty and remove the bind
864 */
865testcase TC_sns_sgsn_add_change_del() runs on RAW_Test_CT {
866 var PDU_NS rx;
867 var NSVCConfiguration nsvc_cfg;
868
869 g_handle_rx_alive := true;
870 f_init_vty();
871 f_init_ns_codec(mp_nsconfig);
872 f_init_ns_codec(mp_nsconfig, 1);
873 f_outgoing_sns_size(max_nsvcs := 4, num_ip := 4);
874 f_outgoing_sns_config();
875 f_incoming_sns_config();
876 activate(as_rx_alive_tx_ack());
877 f_vty_config2(NSVTY, {"ns", "nse " & int2str(g_nsconfig.nsei)}, "ip-sns-bind local2");
878
879 /* rx SNS ADD */
880 nsvc_cfg := g_nsconfig.nsvc[1];
881 if (nsvc_cfg.provider.ip.address_family == AF_INET) {
882 var template (omit) IP4_Elements v4_elem := { ts_SNS_IPv4(nsvc_cfg.provider.ip.remote_ip,
883 nsvc_cfg.provider.ip.remote_udp_port,
884 1, 1) };
885 rx := f_ns_exp(tr_SNS_ADD(g_nsconfig.nsei, ?, v4 := v4_elem), 0);
886 } else {
887 var template (omit) IP6_Elements v6_elem := { ts_SNS_IPv6(nsvc_cfg.provider.ip.remote_ip,
888 nsvc_cfg.provider.ip.remote_udp_port,
889 1, 1) };
890 rx := f_ns_exp(tr_SNS_ADD(g_nsconfig.nsei, ?, omit, v6_elem), 0);
891 }
892
893 /* delete the endpoint */
894 f_vty_config2(NSVTY, {"ns", "bind udp local2"}, "ip-sns signalling-weight 99 data-weight 99");
895 f_vty_config2(NSVTY, {"ns", "nse " & int2str(g_nsconfig.nsei)}, "no ip-sns-bind local2");
896
897 /* accept the SNS_ADD */
898 NSCP[0].send(ts_SNS_ACK(g_nsconfig.nsei, rx.pDU_SNS_Add.transactionID));
899
900 f_incoming_sns_chg_weight(idx_chg := 1);
901 f_incoming_sns_del(idx_del := 1, w_sig := 99, w_user := 99);
902 setverdict(pass);
903 f_clean_ns_codec();
904}
905
Alexander Couzens20cd41e2021-01-11 02:56:03 +0100906control {
Alexander Couzense48d3552021-02-27 20:01:16 +0100907 if (mp_dialect == NS2_DIALECT_STATIC_RESETBLOCK or mp_dialect == NS2_DIALECT_IPACCESS) {
908 execute( TC_tx_reset() );
Alexander Couzens20cd41e2021-01-11 02:56:03 +0100909
Alexander Couzense48d3552021-02-27 20:01:16 +0100910 /* 48.016 7.2 Block procedure */
911 execute( TC_tx_block() );
912 execute( TC_tx_block_by_vty() );
913 execute( TC_tx_block_by_vty_reset() );
Alexander Couzens94d3d102021-09-06 00:20:42 +0200914 execute( TC_tx_block_unitdata_over_blocked() );
915 execute( TC_rx_block_unitdata_over_blocked() );
Alexander Couzense48d3552021-02-27 20:01:16 +0100916 // execute( TC_block_other_nsvc() ); // reset, unblock, sleep(1), block over another nsvci
917 /* 48.016 7.2 Unblock procedure */
918 execute( TC_tx_unblock() );
919 execute( TC_tx_unblock_retries() );
920 // execute( TC_rx_unblock_tx_unblock() ); // wait for an rx unblock pdu, send an unblock pdu, expect unblock ack pdu
921 // execute( TC_unblockable() ); // block a NS-VCI via vty, try block procedure
Alexander Couzens20cd41e2021-01-11 02:56:03 +0100922
Alexander Couzense48d3552021-02-27 20:01:16 +0100923 /* 48.016 7.2.1 Block Abnormal Condition */
924 /* 48.016 7.2.1 Unblock Abnormal Condition */
925 /* 48.016 7.3.1 Abnormal Condition */
Alexander Couzens20cd41e2021-01-11 02:56:03 +0100926 execute( TC_reset_wrong_nsei() );
927 execute( TC_reset_wrong_nsvci() );
928 execute( TC_reset_wrong_nsei_nsvci() );
929 execute( TC_reset_ack_wrong_nsei() );
930 execute( TC_reset_ack_wrong_nsvci() );
931 execute( TC_reset_ack_wrong_nsei_nsvci() );
932 execute( TC_reset_retries() );
933 execute( TC_reset_on_block_reset() );
Alexander Couzense48d3552021-02-27 20:01:16 +0100934 execute( TC_ignore_reset_ack() );
Alexander Couzens20cd41e2021-01-11 02:56:03 +0100935
Alexander Couzense48d3552021-02-27 20:01:16 +0100936 /* 48.016 7.4 Test procedure on frame relay */
937 execute( TC_tx_reset_tx_alive() );
938 execute( TC_tx_reset_rx_alive() );
Alexander Couzens20cd41e2021-01-11 02:56:03 +0100939
Alexander Couzense48d3552021-02-27 20:01:16 +0100940 /* 48.016 7.4.1 Abnormal Condition */
941 if (mp_dialect == NS2_DIALECT_STATIC_RESETBLOCK) {
942 // execute( TC_alive_retries_multi() ); // check if alive retries works and block over an alive nsvc
943 execute( TC_alive_retries_single_reset() );
944 } else if (mp_dialect == NS2_DIALECT_IPACCESS) {
945 execute( TC_alive_retries_single_no_resp() );
946 }
947
948 execute( TC_no_reset_alive_ack() );
Alexander Couzens20cd41e2021-01-11 02:56:03 +0100949 }
Alexander Couzenscbee32a2021-02-27 20:50:20 +0100950
951 if (mp_dialect == NS2_DIALECT_SNS) {
Alexander Couzensde3dfaa2021-08-06 17:59:54 +0200952 if (mp_sns_role == SNS_ROLE_BSS) {
953 /* BSS test cases */
954 execute( TC_sns_bss_config_success() );
955 execute( TC_sns_bss_change_weight() );
956 execute( TC_sns_bss_change_weight_timeout() );
957 execute( TC_sns_bss_add() );
958 execute( TC_sns_bss_del() );
959 execute( TC_sns_bss_add_change_del() );
Alexander Couzens8122ed22021-08-06 22:01:20 +0200960 /* execute( TC_sns_bss_all_signalling_nsvcs_failed() ); */
Alexander Couzensde3dfaa2021-08-06 17:59:54 +0200961 execute( TC_sns_rx_size_force_unconf() );
Alexander Couzensfdfe6382021-09-03 23:17:35 +0200962 execute( TC_sns_bss_remove_bind_fail_sns() );
Alexander Couzensde3dfaa2021-08-06 17:59:54 +0200963 }
Alexander Couzens358c74c2021-08-06 18:01:06 +0200964
965 if (mp_sns_role == SNS_ROLE_SGSN) {
966 execute( TC_sns_sgsn_config_success() );
Alexander Couzens6b51a3c2021-08-06 18:23:49 +0200967 execute( TC_sns_sgsn_add() );
Alexander Couzens8a682d62021-08-06 22:24:47 +0200968 execute( TC_sns_sgsn_del() );
Alexander Couzens3921fb52021-08-12 04:04:20 +0200969 execute( TC_sns_sgsn_add_change_del() );
Alexander Couzens717bb212021-09-04 01:23:42 +0200970 execute( TC_sns_sgsn_size_correct_port() );
Alexander Couzens358c74c2021-08-06 18:01:06 +0200971 }
Alexander Couzenscbee32a2021-02-27 20:50:20 +0100972 }
Alexander Couzens20cd41e2021-01-11 02:56:03 +0100973}
974
975}