blob: 8bbb43c03d18acc51a0873856b50c5d35131bf9d [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
27modulepar {
28 OsmoNsDialect mp_dialect := NS2_DIALECT_IPACCESS;
29 NSConfiguration mp_nsconfig := {
30 nsei := 96,
31 role_sgsn := false,
32 handle_sns := false,
33 nsvc := {
34 {
35 provider := {
36 ip := {
37 address_family := AF_INET,
38 local_udp_port := 21000,
39 local_ip := "127.0.0.1",
40 remote_udp_port := 23000,
Alexander Couzens87e44cf2021-02-03 15:15:27 +010041 remote_ip := "127.0.0.1",
42 data_weight := 2,
43 signalling_weight := 2
Alexander Couzens20cd41e2021-01-11 02:56:03 +010044 }
45 },
46 nsvci := 97
Alexander Couzens6f17ecc2021-05-25 13:43:57 +020047 },
48 {
49 provider := {
50 ip := {
51 address_family := AF_INET,
52 local_udp_port := 21000,
53 local_ip := "127.0.0.1",
54 remote_udp_port := 23001,
55 remote_ip := "127.0.0.1",
56 data_weight := 1,
57 signalling_weight := 1
58 }
59 },
60 nsvci := 98
Alexander Couzens20cd41e2021-01-11 02:56:03 +010061 }
62 }
63 };
64}
65
66type component RAW_Test_CT extends RAW_NS_CT {
67 port TELNETasp_PT NSVTY;
68}
69
70private function f_init_vty() runs on RAW_Test_CT {
71 map(self:NSVTY, system:NSVTY);
72 f_vty_set_prompts(NSVTY);
73 f_vty_transceive(NSVTY, "enable");
74 f_vty_transceive(NSVTY, "nsvc nsei " & int2str(mp_nsconfig.nsei) & " force-unconfigured");
Alexander Couzens6f17ecc2021-05-25 13:43:57 +020075 f_vty_config2(NSVTY, {"ns", "nse " & int2str(mp_nsconfig.nsei)}, "no ip-sns-bind local2");
Alexander Couzens7a625022021-06-06 23:14:58 +020076 f_vty_config2(NSVTY, {"ns", "bind udp local"}, "ip-sns signalling-weight 1 data-weight 1");
77 f_vty_config2(NSVTY, {"ns", "bind udp local2"}, "ip-sns signalling-weight 1 data-weight 1");
Alexander Couzens20cd41e2021-01-11 02:56:03 +010078}
79
80/* ensure no matching message is received within 'tout' */
81function f_ensure_no_ns(integer idx := 0, boolean answer_alive := false, float tout := 3.0)
82runs on RAW_Test_CT {
83 var PDU_NS nrf;
84
85 timer T := tout;
86 var default d := activate(ax_rx_fail_on_any_ns(idx));
87 T.start;
88 alt {
89 [answer_alive] as_rx_alive_tx_ack();
90 [] T.timeout {
91 setverdict(pass);
92 }
93 }
94 deactivate(d);
95}
96
97function f_fails_except_reset(integer idx := 0, float tout := 15.0)
98runs on RAW_Test_CT {
99 var PDU_NS nrf;
100 timer T := 15.0;
101 T.start;
102 alt {
103 [] NSCP[idx].receive(tr_NS_RESET(*, *, *)) {
104 repeat;
105 }
106 [] NSCP[idx].receive(PDU_NS: ?) -> value nrf {
107 setverdict(fail, "Received unexpected NS: ", nrf);
108 mtc.stop;
109 }
110 [] T.timeout {
111 setverdict(pass);
112 }
113 }
114}
115
116testcase TC_tx_reset() runs on RAW_Test_CT {
117 f_init_vty();
118 f_init_ns_codec(mp_nsconfig, guard_secs := 10.0);
119
120 /* do a NS Reset procedure */
121 f_outgoing_ns_reset();
122
123 setverdict(pass);
124 f_sleep(1.0);
125}
126
127testcase TC_tx_reset_tx_alive() runs on RAW_Test_CT {
128 f_init_vty();
129 f_init_ns_codec(mp_nsconfig, guard_secs := 10.0);
130
131 /* do a NS Reset procedure */
132 f_outgoing_ns_reset();
133
134 /* check outgoing NS procedure */
135 f_outgoing_ns_alive();
136
137 setverdict(pass);
138 f_sleep(1.0);
139}
140
141testcase TC_tx_reset_rx_alive() runs on RAW_Test_CT {
142 f_init_vty();
143 f_init_ns_codec(mp_nsconfig, guard_secs := 10.0);
144
145 /* do a NS Reset procedure */
146 f_outgoing_ns_reset();
147
148 activate(as_rx_ns_unblock_ack());
149 /* check outgoing NS procedure */
150 as_rx_alive_tx_ack(oneshot := true);
151
152 setverdict(pass);
153 f_sleep(1.0);
154}
155
156/* 48.016 7.2 unblock procedure
157 *
158 * TTCN -> NS: reset
159 * TTCN <- NS: reset ack
160 * TTCN -> NS: unblock
161 * TTCN <- NS: unblock ack
162 */
163testcase TC_tx_unblock() runs on RAW_Test_CT {
164 f_init_vty();
165 f_init_ns_codec(mp_nsconfig, guard_secs := 30.0);
166
167 /* do a NS Reset procedure */
168 f_outgoing_ns_reset();
169 /* send alive acks */
170 activate(as_rx_alive_tx_ack());
171
172 f_outgoing_ns_unblock();
173 setverdict(pass);
174 f_sleep(1.0);
175}
176
177/* 48.016 7.2 tx unblock retries
178 *
179 * TTCN -> NS: reset
180 * TTCN <- NS: reset ack
181 * TTCN -> NS: unblock
182 * TTCN <- NS: unblock ack
183 * TTCN -> NS: unblock
184 * TTCN <- NS: unblock ack
185 * TTCN -> NS: unblock
186 * TTCN <- NS: unblock ack
187 */
188testcase TC_tx_unblock_retries() runs on RAW_Test_CT {
189 f_init_vty();
190 f_init_ns_codec(mp_nsconfig, guard_secs := 30.0);
191
192 /* do a NS Reset procedure */
193 f_outgoing_ns_reset();
194 /* send alive acks */
195 activate(as_rx_alive_tx_ack());
196
197 f_outgoing_ns_unblock();
198 f_outgoing_ns_unblock();
199 f_outgoing_ns_unblock();
200 setverdict(pass);
201 f_sleep(1.0);
202}
203
204/* 48.016 7.2 block procedure
205 *
206 * TTCN -> NS: reset
207 * TTCN <- NS: reset ack
208 * TTCN -> NS: unblock
209 * TTCN <- NS: unblock ack
210 * TTCN -> NS: block
211 * TTCN <- NS: block ack
212 */
213testcase TC_tx_block() runs on RAW_Test_CT {
214 f_init_vty();
215 f_init_ns_codec(mp_nsconfig, guard_secs := 30.0);
216
217 /* do a NS Reset procedure */
218 f_outgoing_ns_reset();
219 activate(as_rx_alive_tx_ack());
220
221 f_outgoing_ns_unblock();
222 f_sleep(1.0);
223
224 f_outgoing_ns_block(NS_CAUSE_EQUIPMENT_FAILURE);
225 setverdict(pass);
226 f_sleep(1.0);
227}
228
229/* 48.016 7.2 block procedure by vty
230 *
231 * TTCN -> NS: reset
232 * TTCN <- NS: reset ack
233 * TTCN -> NS: unblock
234 * TTCN <- NS: unblock ack
235 * vty: block nsvc
236 * TTCN <- NS: block
237 * TTCN -> NS: block ack
238 */
239function tx_block_by_vty(float guard_secs := 30.0) runs on RAW_Test_CT {
240 f_init_vty();
241 f_init_ns_codec(mp_nsconfig, guard_secs := guard_secs);
242
243 /* do a NS Reset procedure */
244 f_outgoing_ns_reset();
245 activate(as_rx_alive_tx_ack());
246
247 f_outgoing_ns_unblock();
248 f_sleep(1.0);
249
250 f_vty_transceive(NSVTY, "nsvc " & int2str(mp_nsconfig.nsvc[0].nsvci) & " block");
251
252 alt {
253 [] as_rx_ns_block_ack(oneshot := true, nsvci := mp_nsconfig.nsvc[0].nsvci);
254 }
255 setverdict(pass);
256}
257
258testcase TC_tx_block_by_vty() runs on RAW_Test_CT {
259 tx_block_by_vty(30.0);
260 f_sleep(1.0);
261}
262
263/* 48.016 7.2 block precedure by vty and reset the NSVC.
264 * The NSVC should be still blocked after the reset.
265 */
266testcase TC_tx_block_by_vty_reset() runs on RAW_Test_CT {
267 timer T := 10.0;
268
269 tx_block_by_vty(60.0);
270 f_outgoing_ns_reset();
271
272 var default d := activate(ax_rx_fail_on_any_ns());
273 T.start;
274 alt {
275 [] as_rx_alive_tx_ack();
276 [] T.timeout { setverdict(pass); }
277 }
278 deactivate(d);
279}
280
281/* 48.016 7.4.1 ignore unexpected NS_ALIVE ACK */
282testcase TC_no_reset_alive_ack() runs on RAW_Test_CT {
283 f_init_vty();
284 f_init_ns_codec(mp_nsconfig, guard_secs := 30.0);
285
286 NSCP[0].send(t_NS_ALIVE_ACK);
287 f_fails_except_reset();
288 setverdict(pass);
289 f_sleep(1.0);
290}
291
292/* 48.016 7.3.1 NS_RESET with wrong nsei */
293testcase TC_reset_wrong_nsei() runs on RAW_Test_CT {
294 f_init_vty();
295 f_init_ns_codec(mp_nsconfig, guard_secs := 30.0);
296
297 NSCP[0].send(ts_NS_RESET(NS_CAUSE_EQUIPMENT_FAILURE, g_nsconfig.nsvc[0].nsvci, g_nsconfig.nsei + 20));
298 NSCP[0].receive(tr_NS_RESET_ACK(g_nsconfig.nsvc[0].nsvci, g_nsconfig.nsei));
299 f_fails_except_reset();
300 setverdict(pass);
301 f_sleep(1.0);
302}
303
304/* 48.016 7.3.1 NS_RESET with wrong nsvci */
305testcase TC_reset_wrong_nsvci() runs on RAW_Test_CT {
306 f_init_vty();
307 f_init_ns_codec(mp_nsconfig, guard_secs := 30.0);
308
309 NSCP[0].send(ts_NS_RESET(NS_CAUSE_EQUIPMENT_FAILURE, g_nsconfig.nsvc[0].nsvci + 20, g_nsconfig.nsei));
310 NSCP[0].receive(tr_NS_RESET_ACK(g_nsconfig.nsvc[0].nsvci, g_nsconfig.nsei));
311 f_fails_except_reset();
312 setverdict(pass);
313 f_sleep(1.0);
314}
315
316/* 48.016 7.3.1 NS_RESET with wrong nsvci + nsei */
317testcase TC_reset_wrong_nsei_nsvci() runs on RAW_Test_CT {
318 f_init_vty();
319 f_init_ns_codec(mp_nsconfig, guard_secs := 30.0);
320
321 NSCP[0].send(ts_NS_RESET(NS_CAUSE_EQUIPMENT_FAILURE, g_nsconfig.nsvc[0].nsvci + 20, g_nsconfig.nsei + 20));
322 NSCP[0].receive(tr_NS_RESET_ACK(g_nsconfig.nsvc[0].nsvci, g_nsconfig.nsei));
323 f_fails_except_reset();
324 setverdict(pass);
325 f_sleep(1.0);
326}
327
328/* 48.016 7.3.1 NS_RESET_ACK with wrong nsei */
329testcase TC_reset_ack_wrong_nsei() runs on RAW_Test_CT {
330 f_init_vty();
331 f_init_ns_codec(mp_nsconfig, guard_secs := 30.0);
332
333 NSCP[0].receive(tr_NS_RESET(*, g_nsconfig.nsvc[0].nsvci, g_nsconfig.nsei));
334 NSCP[0].send(ts_NS_RESET_ACK(g_nsconfig.nsvc[0].nsvci, g_nsconfig.nsei + 20));
335 f_fails_except_reset();
336 setverdict(pass);
337 f_sleep(1.0);
338}
339
340/* 48.016 7.3.1 NS_RESET_ACK with wrong nsvci */
341testcase TC_reset_ack_wrong_nsvci() runs on RAW_Test_CT {
342 f_init_vty();
343 f_init_ns_codec(mp_nsconfig, guard_secs := 30.0);
344
345 NSCP[0].receive(tr_NS_RESET(*, g_nsconfig.nsvc[0].nsvci, g_nsconfig.nsei));
346 NSCP[0].send(ts_NS_RESET_ACK(g_nsconfig.nsvc[0].nsvci + 20, g_nsconfig.nsei));
347 f_fails_except_reset();
348 setverdict(pass);
349 f_sleep(1.0);
350}
351
352/* 48.016 7.3.1 NS_RESET_ACK with wrong nsvci + nsei */
353testcase TC_reset_ack_wrong_nsei_nsvci() runs on RAW_Test_CT {
354 f_init_vty();
355 f_init_ns_codec(mp_nsconfig, guard_secs := 30.0);
356
357 NSCP[0].receive(tr_NS_RESET(*, g_nsconfig.nsvc[0].nsvci, g_nsconfig.nsei));
358 NSCP[0].send(ts_NS_RESET_ACK(g_nsconfig.nsvc[0].nsvci + 20, g_nsconfig.nsei + 20));
359 f_fails_except_reset();
360 setverdict(pass);
361 f_sleep(1.0);
362}
363
364/* 48.016 7.3.1 ignore unexpected NS_RESET_ACK after NS_RESET+ALIVE */
365testcase TC_ignore_reset_ack() runs on RAW_Test_CT {
366 f_init_vty();
367 f_init_ns_codec(mp_nsconfig, guard_secs := 30.0);
368
369 /* do a NS Reset procedure */
370 f_outgoing_ns_reset();
371
372 /* unblock and alive */
373 alt {
374 [] as_rx_ns_unblock_ack(oneshot := true);
375 [] as_rx_alive_tx_ack();
376 }
377
378 NSCP[0].send(ts_NS_RESET_ACK(g_nsconfig.nsvc[0].nsvci, g_nsconfig.nsei));
379 f_ensure_no_ns(answer_alive := true, tout := 15.0);
380 setverdict(pass);
381 f_sleep(1.0);
382}
383
384/* 48.016 7.3 NS_RESET retries */
385testcase TC_reset_retries() runs on RAW_Test_CT {
386 var integer reset := 0;
387
388 f_init_vty();
389 f_init_ns_codec(mp_nsconfig, guard_secs := 30.0);
390
391 alt {
392 [] NSCP[0].receive(tr_NS_RESET(*, *, *)) {
393 reset := reset + 1;
394 if (reset <= 3) {
395 repeat;
396 } else {
397 setverdict(pass);
398 }
399 }
400 }
401
402 f_sleep(1.0);
403}
404
405/* 48.016 behave RESET_ACK got dropped
406 * TTCN -> NS: reset
407 * TTCN <- NS: reset ack
408 * TTCN <- NS: unblock
409 * TTCN -> NS: reset
410 * TTCN <- NS: reset ack
411 * TTCN <- NS: unblock
412 */
413testcase TC_reset_on_block_reset() runs on RAW_Test_CT {
414 var integer i := 0;
415
416 f_init_vty();
417 f_init_ns_codec(mp_nsconfig, guard_secs := 30.0);
418
419 f_outgoing_ns_reset();
420 activate(as_rx_alive_tx_ack());
421
422 alt {
423 [] NSCP[0].receive(t_NS_UNBLOCK) {
424 NSCP[0].send(ts_NS_RESET(NS_CAUSE_EQUIPMENT_FAILURE, g_nsconfig.nsvc[0].nsvci, g_nsconfig.nsei));
425 i := i + 1;
426 if (i < 3) {
427 repeat;
428 } else {
429 setverdict(pass);
430 }
431 }
432 [] NSCP[0].receive(tr_NS_RESET_ACK(g_nsconfig.nsvc[0].nsvci, g_nsconfig.nsei)) { repeat; }
433 }
434
435 f_sleep(1.0);
436}
437
438/* 48.016 7.4 test procedure for frame relay with a single nsvci */
439function f_alive_retries_single(boolean reset := false) runs on RAW_Test_CT {
440 f_init_vty();
441 f_init_ns_codec(mp_nsconfig, guard_secs := 60.0);
442
443 /* do a NS Reset procedure */
444 f_outgoing_ns_reset();
445
446 alt {
447 [] as_rx_ns_unblock_ack(oneshot := true);
448 [] as_rx_alive_tx_ack();
449 }
450
451 /* wait for one alive and answer it */
452 as_rx_alive_tx_ack(oneshot := true);
453 NSCP[0].receive(t_NS_ALIVE);
454 NSCP[0].receive(t_NS_ALIVE);
455 NSCP[0].receive(t_NS_ALIVE);
456 NSCP[0].receive(t_NS_ALIVE);
457 if (reset) {
458 NSCP[0].receive(tr_NS_RESET(*, g_nsconfig.nsvc[0].nsvci, g_nsconfig.nsei));
459 } else {
460 f_ensure_no_ns(tout := 10.0);
461 }
462
463 setverdict(pass);
464 f_sleep(1.0);
465}
466
467testcase TC_alive_retries_single_reset() runs on RAW_Test_CT {
468 f_alive_retries_single(reset := true);
469}
470
471testcase TC_alive_retries_single_no_resp() runs on RAW_Test_CT {
472 f_alive_retries_single(reset := false);
473}
474
Alexander Couzenscbee32a2021-02-27 20:50:20 +0100475/* 48.016 SNS test cases */
476
477/* do a succesful SNS configuration */
478testcase TC_sns_config_success() runs on RAW_Test_CT {
479 f_init_vty();
480 f_init_ns_codec(mp_nsconfig);
481 f_incoming_sns_size();
482 f_incoming_sns_config();
483 f_outgoing_sns_config();
484 setverdict(pass);
485 f_clean_ns_codec();
486}
487
Alexander Couzensd5ac5102021-02-27 20:53:37 +0100488testcase TC_sns_bss_change_weight() runs on RAW_Test_CT {
Alexander Couzens60548b12021-04-14 19:39:26 +0200489 g_handle_rx_alive := true;
Alexander Couzensd5ac5102021-02-27 20:53:37 +0100490 f_init_vty();
491 f_init_ns_codec(mp_nsconfig);
492 f_incoming_sns_size();
493 f_incoming_sns_config();
494 f_outgoing_sns_config();
495 activate(as_rx_alive_tx_ack());
496 f_vty_config2(NSVTY, {"ns", "bind udp local"}, "ip-sns signalling-weight 99 data-weight 99");
497 f_incoming_sns_chg_weight();
498 setverdict(pass);
499 f_clean_ns_codec();
500}
501
Alexander Couzens6c723fb2021-03-01 00:12:00 +0100502/* receive 3x SNS_CHG_WEIGHT but never answer on it */
503testcase TC_sns_bss_change_weight_timeout() runs on RAW_Test_CT {
504 var integer i := 0;
505 var template PDU_NS rx;
506 var NSVCConfiguration nsvc_cfg;
507
Alexander Couzens60548b12021-04-14 19:39:26 +0200508 g_handle_rx_alive := true;
Alexander Couzens6c723fb2021-03-01 00:12:00 +0100509 f_init_vty();
510 f_init_ns_codec(mp_nsconfig);
511 f_incoming_sns_size();
512 f_incoming_sns_config();
513 f_outgoing_sns_config();
514 activate(as_rx_alive_tx_ack());
515 f_vty_config2(NSVTY, {"ns", "bind udp local"}, "ip-sns signalling-weight 99 data-weight 99");
516
517 nsvc_cfg := g_nsconfig.nsvc[0];
518 if (nsvc_cfg.provider.ip.address_family == AF_INET) {
519 var template IP4_Elements v4_elem := { tr_SNS_IPv4(nsvc_cfg.provider.ip.remote_ip,
520 nsvc_cfg.provider.ip.remote_udp_port) };
521
522 rx := tr_SNS_CHG_WEIGHT(g_nsconfig.nsei, ?, v4 := v4_elem);
523 } else {
524 var template IP6_Elements v6_elem := { tr_SNS_IPv6(nsvc_cfg.provider.ip.remote_ip,
525 nsvc_cfg.provider.ip.remote_udp_port) };
526 rx := tr_SNS_CHG_WEIGHT(g_nsconfig.nsei, ?, v4 := omit, v6 := v6_elem);
527 }
528
Alexander Couzens60548b12021-04-14 19:39:26 +0200529 for (i := 0; i < 3; i := i + 1) {
530 f_ns_exp(rx);
Alexander Couzens6c723fb2021-03-01 00:12:00 +0100531 }
532
Alexander Couzensa93cc362021-04-14 19:39:18 +0200533 if (nsvc_cfg.provider.ip.address_family == AF_INET) {
534 /* expect one single SNS-SIZE with RESET flag; 4x v4 EP; no v6 EP */
535 rx := f_ns_exp(tr_SNS_SIZE(g_nsconfig.nsei, rst_flag := true, max_nsvcs := ?,
536 num_v4 := ?, num_v6 := omit), 0);
537 } else {
538 /* expect one single SNS-SIZE with RESET flag; no v4 EP; 4x v6 EP */
539 rx := f_ns_exp(tr_SNS_SIZE(g_nsconfig.nsei, rst_flag := true, max_nsvcs := ?,
540 num_v4 := omit, num_v6 := ?), 0);
541 }
542
Alexander Couzens6c723fb2021-03-01 00:12:00 +0100543 setverdict(pass);
544 f_clean_ns_codec();
545}
546
Alexander Couzens6f17ecc2021-05-25 13:43:57 +0200547testcase TC_sns_bss_add() runs on RAW_Test_CT {
548 g_handle_rx_alive := true;
549 f_init_vty();
550 f_init_ns_codec(mp_nsconfig);
551 f_init_ns_codec(mp_nsconfig, 1);
552 f_incoming_sns_size();
553 f_incoming_sns_config();
554 f_outgoing_sns_config();
555 activate(as_rx_alive_tx_ack());
556 f_vty_config2(NSVTY, {"ns", "nse " & int2str(g_nsconfig.nsei)}, "ip-sns-bind local2");
557 f_incoming_sns_add(idx_add := 1);
558 as_rx_alive_tx_ack(oneshot := true, idx := 1);
559 setverdict(pass);
560 f_clean_ns_codec();
561}
562
563testcase TC_sns_bss_del() runs on RAW_Test_CT {
564 g_handle_rx_alive := true;
565 f_init_vty();
566 f_init_ns_codec(mp_nsconfig);
567 f_init_ns_codec(mp_nsconfig, 1);
568 f_incoming_sns_size();
569 f_incoming_sns_config();
570 f_outgoing_sns_config();
571 activate(as_rx_alive_tx_ack());
572 f_vty_config2(NSVTY, {"ns", "nse " & int2str(g_nsconfig.nsei)}, "ip-sns-bind local2");
573 f_incoming_sns_add(idx_add := 1);
574 as_rx_alive_tx_ack(oneshot := true, idx := 1);
575
576 /* delete the endpoint */
577 f_vty_config2(NSVTY, {"ns", "nse " & int2str(g_nsconfig.nsei)}, "no ip-sns-bind local2");
578 f_incoming_sns_del(idx_del := 1);
579 setverdict(pass);
580 f_clean_ns_codec();
581}
582
Alexander Couzense23387a2021-06-06 23:15:42 +0200583/* 1. do SNS configuration
584 * 2. add a bind
585 * 3. receive the SNS_ADD
586 * 4. before answering the SNS_ADD, change the weight via vty and remove the bind
587 */
588testcase TC_sns_bss_add_change_del() runs on RAW_Test_CT {
589 var PDU_NS rx;
590 var NSVCConfiguration nsvc_cfg;
591
592 g_handle_rx_alive := true;
593 f_init_vty();
594 f_init_ns_codec(mp_nsconfig);
595 f_init_ns_codec(mp_nsconfig, 1);
596 f_incoming_sns_size();
597 f_incoming_sns_config();
598 f_outgoing_sns_config();
599 activate(as_rx_alive_tx_ack());
600 f_vty_config2(NSVTY, {"ns", "nse " & int2str(g_nsconfig.nsei)}, "ip-sns-bind local2");
601
602 /* rx SNS ADD */
603 nsvc_cfg := g_nsconfig.nsvc[1];
604 if (nsvc_cfg.provider.ip.address_family == AF_INET) {
605 var template (omit) IP4_Elements v4_elem := { ts_SNS_IPv4(nsvc_cfg.provider.ip.remote_ip,
606 nsvc_cfg.provider.ip.remote_udp_port,
607 1, 1) };
608 rx := f_ns_exp(tr_SNS_ADD(g_nsconfig.nsei, ?, v4 := v4_elem), 0);
609 } else {
610 var template (omit) IP6_Elements v6_elem := { ts_SNS_IPv6(nsvc_cfg.provider.ip.remote_ip,
611 nsvc_cfg.provider.ip.remote_udp_port,
612 1, 1) };
613 rx := f_ns_exp(tr_SNS_ADD(g_nsconfig.nsei, ?, omit, v6_elem), 0);
614 }
615
616 /* delete the endpoint */
617 f_vty_config2(NSVTY, {"ns", "bind udp local2"}, "ip-sns signalling-weight 99 data-weight 99");
618 f_vty_config2(NSVTY, {"ns", "nse " & int2str(g_nsconfig.nsei)}, "no ip-sns-bind local2");
619
620 /* accept the SNS_ADD */
621 NSCP[0].send(ts_SNS_ACK(g_nsconfig.nsei, rx.pDU_SNS_Add.transactionID));
622
623 f_incoming_sns_chg_weight(idx_chg := 1);
624 f_incoming_sns_del(idx_del := 1, w_sig := 99, w_user := 99);
625 setverdict(pass);
626 f_clean_ns_codec();
627}
628
Alexander Couzens20cd41e2021-01-11 02:56:03 +0100629control {
Alexander Couzense48d3552021-02-27 20:01:16 +0100630 if (mp_dialect == NS2_DIALECT_STATIC_RESETBLOCK or mp_dialect == NS2_DIALECT_IPACCESS) {
631 execute( TC_tx_reset() );
Alexander Couzens20cd41e2021-01-11 02:56:03 +0100632
Alexander Couzense48d3552021-02-27 20:01:16 +0100633 /* 48.016 7.2 Block procedure */
634 execute( TC_tx_block() );
635 execute( TC_tx_block_by_vty() );
636 execute( TC_tx_block_by_vty_reset() );
637 // execute( TC_block_other_nsvc() ); // reset, unblock, sleep(1), block over another nsvci
638 /* 48.016 7.2 Unblock procedure */
639 execute( TC_tx_unblock() );
640 execute( TC_tx_unblock_retries() );
641 // execute( TC_rx_unblock_tx_unblock() ); // wait for an rx unblock pdu, send an unblock pdu, expect unblock ack pdu
642 // execute( TC_unblockable() ); // block a NS-VCI via vty, try block procedure
Alexander Couzens20cd41e2021-01-11 02:56:03 +0100643
Alexander Couzense48d3552021-02-27 20:01:16 +0100644 /* 48.016 7.2.1 Block Abnormal Condition */
645 /* 48.016 7.2.1 Unblock Abnormal Condition */
646 /* 48.016 7.3.1 Abnormal Condition */
Alexander Couzens20cd41e2021-01-11 02:56:03 +0100647 execute( TC_reset_wrong_nsei() );
648 execute( TC_reset_wrong_nsvci() );
649 execute( TC_reset_wrong_nsei_nsvci() );
650 execute( TC_reset_ack_wrong_nsei() );
651 execute( TC_reset_ack_wrong_nsvci() );
652 execute( TC_reset_ack_wrong_nsei_nsvci() );
653 execute( TC_reset_retries() );
654 execute( TC_reset_on_block_reset() );
Alexander Couzense48d3552021-02-27 20:01:16 +0100655 execute( TC_ignore_reset_ack() );
Alexander Couzens20cd41e2021-01-11 02:56:03 +0100656
Alexander Couzense48d3552021-02-27 20:01:16 +0100657 /* 48.016 7.4 Test procedure on frame relay */
658 execute( TC_tx_reset_tx_alive() );
659 execute( TC_tx_reset_rx_alive() );
Alexander Couzens20cd41e2021-01-11 02:56:03 +0100660
Alexander Couzense48d3552021-02-27 20:01:16 +0100661 /* 48.016 7.4.1 Abnormal Condition */
662 if (mp_dialect == NS2_DIALECT_STATIC_RESETBLOCK) {
663 // execute( TC_alive_retries_multi() ); // check if alive retries works and block over an alive nsvc
664 execute( TC_alive_retries_single_reset() );
665 } else if (mp_dialect == NS2_DIALECT_IPACCESS) {
666 execute( TC_alive_retries_single_no_resp() );
667 }
668
669 execute( TC_no_reset_alive_ack() );
Alexander Couzens20cd41e2021-01-11 02:56:03 +0100670 }
Alexander Couzenscbee32a2021-02-27 20:50:20 +0100671
672 if (mp_dialect == NS2_DIALECT_SNS) {
673 execute( TC_sns_config_success() );
Alexander Couzensd5ac5102021-02-27 20:53:37 +0100674 execute( TC_sns_bss_change_weight() );
Alexander Couzens6c723fb2021-03-01 00:12:00 +0100675 execute( TC_sns_bss_change_weight_timeout() );
Alexander Couzens6f17ecc2021-05-25 13:43:57 +0200676 execute( TC_sns_bss_add() );
677 execute( TC_sns_bss_del() );
Alexander Couzense23387a2021-06-06 23:15:42 +0200678 execute( TC_sns_bss_add_change_del() );
Alexander Couzenscbee32a2021-02-27 20:50:20 +0100679 }
Alexander Couzens20cd41e2021-01-11 02:56:03 +0100680}
681
682}