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