blob: e2bad4f9daa58b4f424331e5cdb73776032bf6cf [file] [log] [blame]
Pau Espin Pedrol8dd59fb2020-04-29 15:08:16 +02001module PCU_Tests_NS {
Pau Espin Pedrol4536c822019-12-30 13:22:32 +01002
3/* Osmocom PCU test suite for IP Sub-Network-Service (SNS) in TTCN-3
4 * (C) 2018-2019 Harald Welte <laforge@gnumonks.org>
5 * All rights reserved.
6 *
7 * Released under the terms of GNU General Public License, Version 2 or
8 * (at your option) any later version.
9 *
10 * SPDX-License-Identifier: GPL-2.0-or-later
11 */
12
13import from General_Types all;
14import from Osmocom_Types all;
Pau Espin Pedrol8dd59fb2020-04-29 15:08:16 +020015import from PCU_Tests all;
Pau Espin Pedrol0e6ed2e2020-04-29 14:33:13 +020016import from SGSN_Components all;
Pau Espin Pedrol4536c822019-12-30 13:22:32 +010017import from Osmocom_Gb_Types all;
Pau Espin Pedrol4536c822019-12-30 13:22:32 +010018import from NS_Types all;
19import from BSSGP_Types all;
20import from UD_Types all;
Pau Espin Pedrol4536c822019-12-30 13:22:32 +010021import from NS_Emulation all;
22import from Native_Functions all;
23import from IPL4asp_Types all;
24import from PCUIF_Types all;
25import from PCUIF_CodecPort all;
Alexander Couzens3c268da2020-09-07 04:25:05 +020026import from RAW_NS all;
Pau Espin Pedrol4536c822019-12-30 13:22:32 +010027
28type component RAW_PCU_CT {
29 /* PCUIF (we emulate the BTS part) */
30 port PCUIF_CODEC_PT PCU;
31 var ConnectionId g_pcu_conn_id := -1;
32}
33
34type component RAW_Test_CT extends RAW_NS_CT, RAW_PCU_CT {
35}
36
Pau Espin Pedrol4536c822019-12-30 13:22:32 +010037function f_init_pcuif() runs on RAW_PCU_CT {
38 var PCUIF_info_ind info_ind;
39 map(self:PCU, system:PCU);
40
41
42 info_ind := valueof(ts_PCUIF_INFO_default);
43
44 /* Connect the Unix Domain Socket */
45 g_pcu_conn_id := f_pcuif_listen(PCU, mp_pcu_sock_path);
46 PCU.receive(UD_connected:?);
47
48 /* Wait for PCU_VERSION and return INFO_IND */
49 PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_TXT_IND(0, PCU_VERSION, ?)));
Harald Welte5339b2e2020-10-04 22:52:56 +020050 /* FIXME: make sure to use parameters from mp_gb_cfg.bvc[0].cell_id in the PCU INFO IND */
Pau Espin Pedrol4536c822019-12-30 13:22:32 +010051 var template PCUIF_Message info_ind_msg := ts_PCUIF_INFO_IND(0, info_ind);
52 PCU.send(t_SD_PCUIF(g_pcu_conn_id, info_ind_msg));
53}
54
55function f_pcuif_tx(template (value) PCUIF_Message msg) runs on RAW_PCU_CT {
56 PCU.send(t_SD_PCUIF(g_pcu_conn_id, msg));
57}
58
Pau Espin Pedrol4536c822019-12-30 13:22:32 +010059/* ensure no matching message is received within 'tout' */
60function f_ensure_no_ns(template PDU_NS ns := ?, integer idx := 0, float tout := 3.0)
61runs on RAW_Test_CT {
62 timer T := tout;
63 T.start;
64 alt {
Alexander Couzensc3165722021-01-11 02:51:45 +010065 [] NSCP[idx].receive(ns) {
Pau Espin Pedrol4536c822019-12-30 13:22:32 +010066 setverdict(fail, "NS-ALIVE from unconfigured (possibly initial) endpoint");
67 }
68 [] T.timeout {
69 setverdict(pass);
70 }
71 }
72}
73
Pau Espin Pedrol4536c822019-12-30 13:22:32 +010074/* test the NS-RESET procedure */
75testcase TC_ns_reset() runs on RAW_Test_CT {
Alexander Couzens2beaa202020-09-11 20:08:41 +020076 f_init_ns_codec(mp_nsconfig);
Pau Espin Pedrol4536c822019-12-30 13:22:32 +010077 f_init_pcuif();
78
79
80 /* Expect inbound NS-RESET procedure */
81 as_rx_ns_reset_ack(oneshot := true);
82 setverdict(pass);
Alexander Couzensc3165722021-01-11 02:51:45 +010083 f_clean_ns_codec();
Pau Espin Pedrol4536c822019-12-30 13:22:32 +010084}
85
86/* ensure NS-RESET are re-transmitted */
87testcase TC_ns_reset_retrans() runs on RAW_Test_CT {
Alexander Couzens2beaa202020-09-11 20:08:41 +020088 f_init_ns_codec(mp_nsconfig);
Pau Espin Pedrol4536c822019-12-30 13:22:32 +010089 f_init_pcuif();
90
91 var integer i;
92 for (i := 0; i < 3; i := i+1) {
Alexander Couzensc3165722021-01-11 02:51:45 +010093 NSCP[0].receive(tr_NS_RESET(NS_CAUSE_OM_INTERVENTION,
94 g_nsconfig.nsvc[0].nsvci, g_nsconfig.nsei));
Pau Espin Pedrol4536c822019-12-30 13:22:32 +010095 }
96
97 /* Expect inbound NS-RESET procedure */
98 as_rx_ns_reset_ack(oneshot := true);
99 setverdict(pass);
Alexander Couzensc3165722021-01-11 02:51:45 +0100100 f_clean_ns_codec();
Pau Espin Pedrol4536c822019-12-30 13:22:32 +0100101}
102
103/* test the inbound NS-ALIVE procedure after NS-RESET */
104testcase TC_ns_alive() runs on RAW_Test_CT {
Alexander Couzens2beaa202020-09-11 20:08:41 +0200105 f_init_ns_codec(mp_nsconfig);
Pau Espin Pedrol4536c822019-12-30 13:22:32 +0100106 f_init_pcuif();
107
108 /* Expect inbound NS-RESET procedure */
109 as_rx_ns_reset_ack(oneshot := true);
110
Alexander Couzens355ab562020-07-26 22:04:33 +0200111 alt {
Pau Espin Pedrol4536c822019-12-30 13:22:32 +0100112 /* wait for one ALIVE cycle, then ACK any further ALIVE in the background */
Alexander Couzensc3165722021-01-11 02:51:45 +0100113 [] NSCP[0].receive(t_NS_ALIVE) { setverdict(pass); };
114 [] NSCP[0].receive(t_NS_UNBLOCK) { repeat; }
Alexander Couzens355ab562020-07-26 22:04:33 +0200115 }
Alexander Couzensc3165722021-01-11 02:51:45 +0100116 f_clean_ns_codec();
Pau Espin Pedrol4536c822019-12-30 13:22:32 +0100117}
118
119/* Test for NS-RESET after NS-ALIVE timeout */
120testcase TC_ns_alive_timeout_reset() runs on RAW_Test_CT {
Alexander Couzens2beaa202020-09-11 20:08:41 +0200121 f_init_ns_codec(mp_nsconfig, guard_secs := 100.0);
Pau Espin Pedrol4536c822019-12-30 13:22:32 +0100122 f_init_pcuif();
123
124 /* Expect inbound NS-RESET procedure */
125 as_rx_ns_reset_ack(oneshot := true);
126
127 /* wait for at least one NS-ALIVE */
Alexander Couzens355ab562020-07-26 22:04:33 +0200128 alt {
129 [] as_rx_alive_tx_ack(oneshot := true) { };
Alexander Couzensc3165722021-01-11 02:51:45 +0100130 [] NSCP[0].receive(t_NS_UNBLOCK) { repeat; }
Alexander Couzens355ab562020-07-26 22:04:33 +0200131 }
Pau Espin Pedrol4536c822019-12-30 13:22:32 +0100132
133 /* wait for NS-RESET to re-appear, ignoring any NS-ALIVE until then */
134 alt {
135 [] as_rx_ns_reset_ack(oneshot := true) { setverdict(pass); }
Alexander Couzensc3165722021-01-11 02:51:45 +0100136 [] NSCP[0].receive(t_NS_ALIVE) { repeat; }
137 [] NSCP[0].receive(t_NS_UNBLOCK) { repeat; }
Pau Espin Pedrol4536c822019-12-30 13:22:32 +0100138 }
Alexander Couzensc3165722021-01-11 02:51:45 +0100139
140 f_clean_ns_codec();
Pau Espin Pedrol4536c822019-12-30 13:22:32 +0100141}
142
143/* test for NS-RESET/NS-ALIVE/NS-UNBLOCK */
144testcase TC_ns_unblock() runs on RAW_Test_CT {
Alexander Couzens2beaa202020-09-11 20:08:41 +0200145 f_init_ns_codec(mp_nsconfig);
Pau Espin Pedrol4536c822019-12-30 13:22:32 +0100146 f_init_pcuif();
147
148 /* Expect inbound NS-RESET procedure */
149 as_rx_ns_reset_ack(oneshot := true);
150
Alexander Couzens355ab562020-07-26 22:04:33 +0200151 /* keep it alive */
Pau Espin Pedrol4536c822019-12-30 13:22:32 +0100152 activate(as_rx_alive_tx_ack());
153
154 as_rx_ns_unblock_ack(oneshot := true);
155 setverdict(pass);
Alexander Couzensc3165722021-01-11 02:51:45 +0100156 f_clean_ns_codec();
Pau Espin Pedrol4536c822019-12-30 13:22:32 +0100157}
158
159/* test for NS-UNBLOCK re-transmissions */
160testcase TC_ns_unblock_retrans() runs on RAW_Test_CT {
Alexander Couzens2beaa202020-09-11 20:08:41 +0200161 f_init_ns_codec(mp_nsconfig);
Pau Espin Pedrol4536c822019-12-30 13:22:32 +0100162 f_init_pcuif();
163
164 /* Expect inbound NS-RESET procedure */
165 as_rx_ns_reset_ack(oneshot := true);
166
Alexander Couzens355ab562020-07-26 22:04:33 +0200167 /* keep it alive */
Pau Espin Pedrol4536c822019-12-30 13:22:32 +0100168 activate(as_rx_alive_tx_ack());
169
170 /* wait for first NS-UNBLOCK, don't respond */
Alexander Couzensc3165722021-01-11 02:51:45 +0100171 NSCP[0].receive(t_NS_UNBLOCK);
Pau Espin Pedrol4536c822019-12-30 13:22:32 +0100172
173 /* wait for re-transmission of NS-UNBLOCK */
174 as_rx_ns_unblock_ack(oneshot := true);
175 setverdict(pass);
Alexander Couzensc3165722021-01-11 02:51:45 +0100176 f_clean_ns_codec();
Pau Espin Pedrol4536c822019-12-30 13:22:32 +0100177}
178
179/* full bring-up of the Gb link for NS and BSSGP layer up to BVC-FC */
180testcase TC_ns_full_bringup() runs on RAW_Test_CT {
Alexander Couzens2beaa202020-09-11 20:08:41 +0200181 f_init_ns_codec(mp_nsconfig);
Pau Espin Pedrol4536c822019-12-30 13:22:32 +0100182 f_init_pcuif();
183
184 /* Expect inbound NS-RESET procedure */
185 as_rx_ns_reset_ack(oneshot := true);
186
Alexander Couzens355ab562020-07-26 22:04:33 +0200187 /* keep it alive */
Pau Espin Pedrol4536c822019-12-30 13:22:32 +0100188 activate(as_rx_alive_tx_ack());
189
190 as_rx_ns_unblock_ack(oneshot := true);
191
192 f_outgoing_ns_alive();
193
194 /* Expect BVC-RESET for signaling (0) and ptp BVCI */
Pau Espin Pedroleef46072021-02-26 13:39:43 +0100195 as_rx_bvc_reset_tx_ack(0, omit, omit, oneshot := true);
Harald Weltee97e3af2020-10-09 14:56:54 +0200196 as_rx_bvc_reset_tx_ack(mp_gb_cfg.bvc[0].bvci, mp_gb_cfg.bvc[0].cell_id, omit, oneshot := true);
Harald Welte5339b2e2020-10-04 22:52:56 +0200197 as_rx_bvc_unblock_tx_ack(mp_gb_cfg.bvc[0].bvci, oneshot := true);
Pau Espin Pedrol4536c822019-12-30 13:22:32 +0100198
199 /* wait for one FLOW-CONTROL BVC and then ACK any further in the future */
Harald Welte5339b2e2020-10-04 22:52:56 +0200200 as_rx_bvc_fc_tx_ack(mp_gb_cfg.bvc[0].bvci, oneshot := true);
201 activate(as_rx_bvc_fc_tx_ack(mp_gb_cfg.bvc[0].bvci));
Pau Espin Pedrol4536c822019-12-30 13:22:32 +0100202 setverdict(pass);
Alexander Couzensc3165722021-01-11 02:51:45 +0100203 f_clean_ns_codec();
Pau Espin Pedrol4536c822019-12-30 13:22:32 +0100204}
205
206/* test outbound (SGSN-originated) NS-BLOCK procedure */
207testcase TC_ns_so_block() runs on RAW_Test_CT {
Alexander Couzens2beaa202020-09-11 20:08:41 +0200208 f_init_ns_codec(mp_nsconfig);
Pau Espin Pedrol4536c822019-12-30 13:22:32 +0100209 f_init_pcuif();
210
211 /* Expect inbound NS-RESET procedure */
212 as_rx_ns_reset_ack(oneshot := true);
213
Alexander Couzens355ab562020-07-26 22:04:33 +0200214 /* keep it alive */
Pau Espin Pedrol4536c822019-12-30 13:22:32 +0100215 activate(as_rx_alive_tx_ack());
216
217 as_rx_ns_unblock_ack(oneshot := true);
218
219 f_outgoing_ns_alive();
220
221 f_outgoing_ns_block(NS_CAUSE_EQUIPMENT_FAILURE);
222 setverdict(pass);
Alexander Couzensc3165722021-01-11 02:51:45 +0100223 f_clean_ns_codec();
Pau Espin Pedrol4536c822019-12-30 13:22:32 +0100224}
225
226
227control {
228 execute( TC_ns_reset() );
229 execute( TC_ns_reset_retrans() );
230 execute( TC_ns_alive() );
231 execute( TC_ns_alive_timeout_reset() );
232 execute( TC_ns_unblock() );
233 execute( TC_ns_unblock_retrans() );
234 execute( TC_ns_full_bringup() );
235 execute( TC_ns_so_block() );
236}
237
238}