blob: 86b83c2e0456180d5d8311e73da289db42b08436 [file] [log] [blame]
Pau Espin Pedrol8dd59fb2020-04-29 15:08:16 +02001module PCU_Tests_SNS {
Harald Weltef7b74072019-02-20 20:48:50 +01002
Harald Welte34b5a952019-05-27 11:54:11 +02003/* 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
Harald Weltef7b74072019-02-20 20:48:50 +010013import from Osmocom_Types all;
Pau Espin Pedrol8dd59fb2020-04-29 15:08:16 +020014import from PCU_Tests_NS all;
Pau Espin Pedrol0e6ed2e2020-04-29 14:33:13 +020015import from SGSN_Components all;
Harald Weltec4d7beb2019-02-21 18:21:01 +010016import from Osmocom_Gb_Types all;
17import from NS_CodecPort all;
18import from NS_Types all;
Alexander Couzens3c268da2020-09-07 04:25:05 +020019import from RAW_NS all;
Harald Weltef7b74072019-02-20 20:48:50 +010020
21/**********************************************************************************
22 * Modern Gb/IP bring-up test cases using IP Sub-Network Service (SNS)
23 **********************************************************************************/
24
Harald Weltec4d7beb2019-02-21 18:21:01 +010025/* perform inbound SNS-SIZE procedure */
Harald Weltebf768242019-02-21 22:19:21 +010026function f_incoming_sns_size(template (omit) NsCause cause := omit, integer idx := 0)
27runs on RAW_NS_CT {
Harald Welteb63c3a12019-02-22 23:27:12 +010028 log("f_incoming_sns_size(idx=", idx, ")");
Harald Weltec4d7beb2019-02-21 18:21:01 +010029 var PDU_NS rx;
Alexander Couzens7b1e44f2020-08-25 23:33:17 +020030
31 if (mp_nsconfig.provider.ip.address_family == AF_INET) {
32 /* expect one single SNS-SIZE with RESET flag; 4x v4 EP; no v6 EP */
33 rx := f_ns_exp(tr_SNS_SIZE(g_nsconfig[idx].nsei, rst_flag := true, max_nsvcs := 8,
34 num_v4 := 4, num_v6 := omit), idx);
35 } else {
36 /* expect one single SNS-SIZE with RESET flag; no v4 EP; 4x v6 EP */
37 rx := f_ns_exp(tr_SNS_SIZE(g_nsconfig[idx].nsei, rst_flag := true, max_nsvcs := 8,
38 num_v4 := omit, num_v6 := 4), idx);
39 }
Harald Weltebf768242019-02-21 22:19:21 +010040 NSCP[idx].send(t_NS_Send(g_ns_conn_id[idx], ts_SNS_SIZE_ACK(g_nsconfig[idx].nsei, cause)));
Harald Weltec4d7beb2019-02-21 18:21:01 +010041}
42
43/* perform outbound SNS-SIZE procedure */
Harald Weltebf768242019-02-21 22:19:21 +010044function f_outgoing_sns_size(template (omit) NsCause cause := omit, integer idx:= 0)
45runs on RAW_NS_CT {
Harald Welteb63c3a12019-02-22 23:27:12 +010046 log("f_outgoing_sns_size(idx=", idx, ")");
Harald Weltec4d7beb2019-02-21 18:21:01 +010047 var PDU_NS rx;
Alexander Couzens7b1e44f2020-08-25 23:33:17 +020048 if (mp_nsconfig.provider.ip.address_family == AF_INET) {
49 NSCP[idx].send(t_NS_Send(g_ns_conn_id[idx], ts_SNS_SIZE(g_nsconfig[idx].nsei, rst_flag := true, max_nsvcs := 1,
50 num_v4 := 1, num_v6 := omit)
51 ));
52 } else {
53 NSCP[idx].send(t_NS_Send(g_ns_conn_id[idx], ts_SNS_SIZE(g_nsconfig[idx].nsei, rst_flag := true, max_nsvcs := 1,
54 num_v4 := omit, num_v6 := 1)
55 ));
56 }
57 /* expect one single SNS-SIZE with RESET flag; 4x v4 EP; no v6 EP */
Harald Weltebf768242019-02-21 22:19:21 +010058 rx := f_ns_exp(tr_SNS_SIZE_ACK(g_nsconfig[idx].nsei, cause), idx);
Harald Weltec4d7beb2019-02-21 18:21:01 +010059}
60
61/* perform inbound SNS-CONFIG procedure */
Harald Weltebf768242019-02-21 22:19:21 +010062function f_incoming_sns_config(template (omit) NsCause cause := omit, integer idx := 0)
63runs on RAW_NS_CT {
Harald Welteb63c3a12019-02-22 23:27:12 +010064 log("f_incoming_sns_config(idx=", idx, ")");
Harald Weltec4d7beb2019-02-21 18:21:01 +010065 var PDU_NS rx;
Alexander Couzens7b1e44f2020-08-25 23:33:17 +020066
67 if (mp_nsconfig.provider.ip.address_family == AF_INET) {
68 var template IP4_Elements v4_elem := { tr_SNS_IPv4(mp_nsconfig.provider.ip.remote_ip,
69 mp_nsconfig.provider.ip.remote_udp_port) };
70 rx := f_ns_exp(tr_SNS_CONFIG(g_nsconfig[idx].nsei, end_flag := true, v4 := v4_elem), idx);
71 } else {
72 var template IP6_Elements v6_elem := { tr_SNS_IPv6(mp_nsconfig.provider.ip.remote_ip,
73 mp_nsconfig.provider.ip.remote_udp_port) };
74 rx := f_ns_exp(tr_SNS_CONFIG(g_nsconfig[idx].nsei, end_flag := true, v6 := v6_elem), idx);
75 }
76
Harald Weltebf768242019-02-21 22:19:21 +010077 NSCP[idx].send(t_NS_Send(g_ns_conn_id[idx], ts_SNS_CONFIG_ACK(g_nsconfig[idx].nsei, cause)));
Harald Weltec4d7beb2019-02-21 18:21:01 +010078}
79
80/* perform outbound SNS-CONFIG procedure */
Harald Weltebf768242019-02-21 22:19:21 +010081function f_outgoing_sns_config(template (omit) NsCause cause := omit, integer idx := 0)
82runs on RAW_NS_CT {
Harald Welteb63c3a12019-02-22 23:27:12 +010083 log("f_outgoing_sns_config(idx=", idx, ")");
Harald Weltec4d7beb2019-02-21 18:21:01 +010084 var PDU_NS rx;
Alexander Couzens7b1e44f2020-08-25 23:33:17 +020085 if (mp_nsconfig.provider.ip.address_family == AF_INET) {
86 var template (omit) IP4_Elements v4 := { ts_SNS_IPv4(g_nsconfig[idx].provider.ip.local_ip,
87 g_nsconfig[idx].provider.ip.local_udp_port) }
88 NSCP[idx].send(t_NS_Send(g_ns_conn_id[idx], ts_SNS_CONFIG(g_nsconfig[idx].nsei, true, v4)));
89 } else {
90 var template (omit) IP6_Elements v6 := { ts_SNS_IPv6(g_nsconfig[idx].provider.ip.local_ip,
91 g_nsconfig[idx].provider.ip.local_udp_port) }
92 NSCP[idx].send(t_NS_Send(g_ns_conn_id[idx], ts_SNS_CONFIG(g_nsconfig[idx].nsei, true, omit, v6)));
93 }
Harald Weltebf768242019-02-21 22:19:21 +010094 rx := f_ns_exp(tr_SNS_CONFIG_ACK(g_nsconfig[idx].nsei, cause), idx);
Harald Weltec4d7beb2019-02-21 18:21:01 +010095}
96
Harald Weltebf768242019-02-21 22:19:21 +010097/* perform outbound SNS-CONFIG procedure (separate endpoints: 1 for control, 1 for user */
98function f_outgoing_sns_config_1c1u(template (omit) NsCause cause := omit, integer idx := 0)
99runs on RAW_NS_CT {
Harald Welteb63c3a12019-02-22 23:27:12 +0100100 log("f_outgoing_sns_config_1c1u(idx=", idx, ")");
Harald Weltebf768242019-02-21 22:19:21 +0100101 var PDU_NS rx;
Alexander Couzens7b1e44f2020-08-25 23:33:17 +0200102 if (mp_nsconfig.provider.ip.address_family == AF_INET) {
103 var template (omit) IP4_Elements v4 := { ts_SNS_IPv4(g_nsconfig[0].provider.ip.local_ip,
104 g_nsconfig[0].provider.ip.local_udp_port, 1, 0),
105 ts_SNS_IPv4(g_nsconfig[1].provider.ip.local_ip,
106 g_nsconfig[1].provider.ip.local_udp_port, 0, 1) };
107 NSCP[idx].send(t_NS_Send(g_ns_conn_id[idx], ts_SNS_CONFIG(g_nsconfig[idx].nsei, true, v4)));
108 } else {
109 var template (omit) IP6_Elements v6 := { ts_SNS_IPv6(g_nsconfig[0].provider.ip.local_ip,
110 g_nsconfig[0].provider.ip.local_udp_port, 1, 0),
111 ts_SNS_IPv6(g_nsconfig[1].provider.ip.local_ip,
112 g_nsconfig[1].provider.ip.local_udp_port, 0, 1) };
113 NSCP[idx].send(t_NS_Send(g_ns_conn_id[idx], ts_SNS_CONFIG(g_nsconfig[idx].nsei, true, omit, v6)));
114 }
Harald Weltebf768242019-02-21 22:19:21 +0100115 rx := f_ns_exp(tr_SNS_CONFIG_ACK(g_nsconfig[idx].nsei, cause), idx);
116}
117
Harald Welteecd159e2019-03-16 13:36:07 +0100118/* perform outbound SNS-CONFIG procedure (separate endpoints: 1 for control, 1 for user */
119function f_outgoing_sns_config_1c1u_separate(template (omit) NsCause cause := omit, integer idx := 0)
120runs on RAW_NS_CT {
121 log("f_outgoing_sns_config_1c1u_separate(idx=", idx, ")");
122 var PDU_NS rx;
Alexander Couzens7b1e44f2020-08-25 23:33:17 +0200123 if (mp_nsconfig.provider.ip.address_family == AF_INET) {
124 var template (omit) IP4_Elements v4 := { ts_SNS_IPv4(g_nsconfig[1].provider.ip.local_ip,
125 g_nsconfig[1].provider.ip.local_udp_port, 1, 0),
126 ts_SNS_IPv4(g_nsconfig[2].provider.ip.local_ip,
127 g_nsconfig[2].provider.ip.local_udp_port, 0, 1) };
128 NSCP[idx].send(t_NS_Send(g_ns_conn_id[idx], ts_SNS_CONFIG(g_nsconfig[idx].nsei, true, v4)));
129 } else {
130 var template (omit) IP6_Elements v6 := { ts_SNS_IPv6(g_nsconfig[1].provider.ip.local_ip,
131 g_nsconfig[1].provider.ip.local_udp_port, 1, 0),
132 ts_SNS_IPv6(g_nsconfig[2].provider.ip.local_ip,
133 g_nsconfig[2].provider.ip.local_udp_port, 0, 1) };
134 NSCP[idx].send(t_NS_Send(g_ns_conn_id[idx], ts_SNS_CONFIG(g_nsconfig[idx].nsei, true, omit, v6)));
135 }
Harald Welteecd159e2019-03-16 13:36:07 +0100136 rx := f_ns_exp(tr_SNS_CONFIG_ACK(g_nsconfig[idx].nsei, cause), idx);
137}
138
Harald Welte630d0e62019-02-22 23:26:40 +0100139function f_outgoing_sns_add(integer idx_add, uint8_t w_sig := 1, uint8_t w_user := 1, integer idx := 0)
140runs on RAW_NS_CT {
141 log("f_outgoing_sns_add(idx_add=", idx_add, ")");
142 var PDU_NS rx;
Alexander Couzens7b1e44f2020-08-25 23:33:17 +0200143 if (mp_nsconfig.provider.ip.address_family == AF_INET) {
144 var template (omit) IP4_Elements v4 := { ts_SNS_IPv4(g_nsconfig[idx_add].provider.ip.local_ip,
145 g_nsconfig[idx_add].provider.ip.local_udp_port,
146 w_sig, w_user) };
147 NSCP[idx].send(t_NS_Send(g_ns_conn_id[idx], ts_SNS_ADD(g_nsconfig[idx].nsei, 23, v4)));
148 rx := f_ns_exp(tr_SNS_ACK(g_nsconfig[idx].nsei, 23, omit, v4));
149 } else {
150 var template (omit) IP6_Elements v6 := { ts_SNS_IPv6(g_nsconfig[idx_add].provider.ip.local_ip,
151 g_nsconfig[idx_add].provider.ip.local_udp_port,
152 w_sig, w_user) };
153 NSCP[idx].send(t_NS_Send(g_ns_conn_id[idx], ts_SNS_ADD(g_nsconfig[idx].nsei, 23, omit, v6)));
154 rx := f_ns_exp(tr_SNS_ACK(g_nsconfig[idx].nsei, 23, omit, omit, v6));
155 }
Harald Welte630d0e62019-02-22 23:26:40 +0100156}
157
158function f_outgoing_sns_del(integer idx_del, uint8_t w_sig := 1, uint8_t w_user := 1, integer idx := 0)
159runs on RAW_NS_CT {
160 log("f_outgoing_sns_del(idx_del=", idx_del, ")");
161 var PDU_NS rx;
Alexander Couzens7b1e44f2020-08-25 23:33:17 +0200162 if (mp_nsconfig.provider.ip.address_family == AF_INET) {
163 var template (omit) IP4_Elements v4 := { ts_SNS_IPv4(g_nsconfig[idx_del].provider.ip.local_ip,
164 g_nsconfig[idx_del].provider.ip.local_udp_port,
165 w_sig, w_user) };
166 NSCP[idx].send(t_NS_Send(g_ns_conn_id[idx], ts_SNS_DEL(g_nsconfig[idx].nsei, 24, omit, v4)));
167 rx := f_ns_exp(tr_SNS_ACK(g_nsconfig[idx].nsei, 24, omit, v4));
168 } else {
169 var template (omit) IP6_Elements v6 := { ts_SNS_IPv6(g_nsconfig[idx_del].provider.ip.local_ip,
170 g_nsconfig[idx_del].provider.ip.local_udp_port,
171 w_sig, w_user) };
172 NSCP[idx].send(t_NS_Send(g_ns_conn_id[idx], ts_SNS_DEL(g_nsconfig[idx].nsei, 24, omit, omit, v6)));
173 rx := f_ns_exp(tr_SNS_ACK(g_nsconfig[idx].nsei, 24, omit, omit, v6));
174 }
Harald Welte630d0e62019-02-22 23:26:40 +0100175}
176
Harald Welte72099552019-02-23 15:09:22 +0100177function f_outgoing_sns_chg_weight(integer idx_chg, uint8_t w_sig, uint8_t w_user, integer idx := 0)
178runs on RAW_NS_CT {
179 log("f_outgoing_sns_chg_weight(idx_chg=", idx_chg, ")");
180 var PDU_NS rx;
Alexander Couzens7b1e44f2020-08-25 23:33:17 +0200181 if (mp_nsconfig.provider.ip.address_family == AF_INET) {
182 var template (omit) IP4_Elements v4 := { ts_SNS_IPv4(g_nsconfig[idx_chg].provider.ip.local_ip,
183 g_nsconfig[idx_chg].provider.ip.local_udp_port,
184 w_sig, w_user) };
185 NSCP[idx].send(t_NS_Send(g_ns_conn_id[idx], ts_SNS_CHG_WEIGHT(g_nsconfig[idx].nsei, 25, v4)));
186 rx := f_ns_exp(tr_SNS_ACK(g_nsconfig[idx].nsei, 25, omit, v4));
187 } else {
188 var template (omit) IP6_Elements v6 := { ts_SNS_IPv6(g_nsconfig[idx_chg].provider.ip.local_ip,
189 g_nsconfig[idx_chg].provider.ip.local_udp_port,
190 w_sig, w_user) };
191 NSCP[idx].send(t_NS_Send(g_ns_conn_id[idx], ts_SNS_CHG_WEIGHT(g_nsconfig[idx].nsei, 25, omit, v6)));
192 rx := f_ns_exp(tr_SNS_ACK(g_nsconfig[idx].nsei, 25, omit, omit, v6));
193 }
Harald Welte72099552019-02-23 15:09:22 +0100194}
195
196
197
Harald Welte630d0e62019-02-22 23:26:40 +0100198
Harald Weltebf768242019-02-21 22:19:21 +0100199
Harald Weltef7b74072019-02-20 20:48:50 +0100200/* PCU-originated SNS-SIZE: successful case */
Harald Welteea3c7e92019-03-01 19:34:55 +0100201testcase TC_sns_po_size_success() runs on RAW_Test_CT {
Alexander Couzens2beaa202020-09-11 20:08:41 +0200202 f_init_ns_codec(mp_nsconfig);
Harald Weltef7b74072019-02-20 20:48:50 +0100203 f_init_pcuif();
204 f_incoming_sns_size();
205 f_sleep(1.0);
206 setverdict(pass);
207}
208
209/* PCU-originated SNS-SIZE: NACK from our side */
Harald Welteea3c7e92019-03-01 19:34:55 +0100210testcase TC_sns_po_size_nack() runs on RAW_Test_CT {
Alexander Couzens2beaa202020-09-11 20:08:41 +0200211 f_init_ns_codec(mp_nsconfig);
Harald Weltef7b74072019-02-20 20:48:50 +0100212 f_init_pcuif();
213 f_incoming_sns_size(NS_CAUSE_PROTOCOL_ERROR_UNSPEIFIED);
214 /* FIXME: ensure we don't get a SNS-CONFIG */
215 /* FIXME: ensure we get re-transmitted SNS-SIZE attempts */
216 f_sleep(10.0);
217 setverdict(pass);
218}
219
220/* PCU-originated SNS-CONFIG: successful case */
Harald Welteea3c7e92019-03-01 19:34:55 +0100221testcase TC_sns_po_config_success() runs on RAW_Test_CT {
Alexander Couzens2beaa202020-09-11 20:08:41 +0200222 f_init_ns_codec(mp_nsconfig);
Harald Weltef7b74072019-02-20 20:48:50 +0100223 f_init_pcuif();
224 f_incoming_sns_size();
225 f_incoming_sns_config();
226 f_sleep(1.0);
227 setverdict(pass);
228}
229
230/* PCU-originated SNS-CONFIG: successful case */
Harald Welteea3c7e92019-03-01 19:34:55 +0100231testcase TC_sns_po_config_nack() runs on RAW_Test_CT {
Alexander Couzens2beaa202020-09-11 20:08:41 +0200232 f_init_ns_codec(mp_nsconfig);
Harald Weltef7b74072019-02-20 20:48:50 +0100233 f_init_pcuif();
234 f_incoming_sns_size();
235 f_incoming_sns_config(NS_CAUSE_PROTOCOL_ERROR_UNSPEIFIED);
236 /* FIXME: ensure we get re-transmitted SNS-CONFIG attempts */
237 f_sleep(10.0);
238 setverdict(pass);
239}
240
241
242/* SGSN-originated SNS-SIZE: successful case */
Harald Welteea3c7e92019-03-01 19:34:55 +0100243testcase TC_sns_so_config_success() runs on RAW_Test_CT {
Alexander Couzens2beaa202020-09-11 20:08:41 +0200244 f_init_ns_codec(mp_nsconfig);
Harald Weltef7b74072019-02-20 20:48:50 +0100245 f_init_pcuif();
246 f_incoming_sns_size();
247 f_incoming_sns_config();
248 f_outgoing_sns_config();
249
250 /* wait for one ALIVE cycle, then ACK any further ALIVE in the background */
251 as_rx_alive_tx_ack(oneshot := true);
252 activate(as_rx_alive_tx_ack());
253
254 f_outgoing_ns_alive();
255
256 /* Expect BVC-RESET for signaling (0) and ptp BVCI */
Harald Weltee97e3af2020-10-09 14:56:54 +0200257 as_rx_bvc_reset_tx_ack(0, omit, omit, oneshot := true);
258 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 +0200259 as_rx_bvc_unblock_tx_ack(mp_gb_cfg.bvc[0].bvci, oneshot := true);
Harald Weltef7b74072019-02-20 20:48:50 +0100260
261 /* wait for one FLOW-CONTROL BVC and then ACK any further in the future */
Harald Welte5339b2e2020-10-04 22:52:56 +0200262 as_rx_bvc_fc_tx_ack(mp_gb_cfg.bvc[0].bvci, oneshot := true);
263 activate(as_rx_bvc_fc_tx_ack(mp_gb_cfg.bvc[0].bvci));
Harald Weltef7b74072019-02-20 20:48:50 +0100264 setverdict(pass);
265}
266
Harald Welte64d07312019-03-20 09:48:39 +0100267private function f_sns_bringup_1c1u(boolean sgsn_originated_reset := false) runs on RAW_Test_CT {
Harald Welte630d0e62019-02-22 23:26:40 +0100268 /* Activate two NS codec ports */
Alexander Couzens2beaa202020-09-11 20:08:41 +0200269 f_init_ns_codec(mp_nsconfig);
270 f_init_ns_codec(mp_nsconfig, 1);
Harald Welte630d0e62019-02-22 23:26:40 +0100271 f_init_pcuif();
272 /* Perform Size + BSS-originated config */
273 f_incoming_sns_size();
274 f_incoming_sns_config();
275 /* perform SGSN-originated config using idx==0 for signalling and idx==1 for user traffic */
276 f_outgoing_sns_config_1c1u();
277
278 /* wait for one ALIVE cycle, then ACK any further ALIVE in the background
279 * for both NS-VCs */
280 as_rx_alive_tx_ack(oneshot := true, idx := 0);
281 activate(as_rx_alive_tx_ack(idx := 0));
282 as_rx_alive_tx_ack(oneshot := true, idx := 1);
283 activate(as_rx_alive_tx_ack(idx := 1));
284
285 /* perform outgoing ALIVE procedure for both NS-VCs */
286 f_outgoing_ns_alive(0);
287 f_outgoing_ns_alive(1);
288
Harald Welte64d07312019-03-20 09:48:39 +0100289 if (sgsn_originated_reset) {
Harald Weltee97e3af2020-10-09 14:56:54 +0200290 f_tx_bvc_reset_rx_ack(0, omit, omit);
291 f_tx_bvc_reset_rx_ack(mp_gb_cfg.bvc[0].bvci, omit, mp_gb_cfg.bvc[0].cell_id);
Harald Welte64d07312019-03-20 09:48:39 +0100292 } else {
293 /* Expect BVC-RESET for signaling (0) and ptp BVCI */
Harald Weltee97e3af2020-10-09 14:56:54 +0200294 as_rx_bvc_reset_tx_ack(0, omit, omit, oneshot := true);
295 as_rx_bvc_reset_tx_ack(mp_gb_cfg.bvc[0].bvci, mp_gb_cfg.bvc[0].cell_id, omit, oneshot := true);
Harald Welte64d07312019-03-20 09:48:39 +0100296 }
Harald Welte630d0e62019-02-22 23:26:40 +0100297 /* Expect UNBLOCK for ptp BVCI on signaling NS-VC (idx==0) */
Harald Welte5339b2e2020-10-04 22:52:56 +0200298 as_rx_bvc_unblock_tx_ack(mp_gb_cfg.bvc[0].bvci, oneshot := true);
Harald Welte630d0e62019-02-22 23:26:40 +0100299
300 /* wait for one FLOW-CONTROL BVC and then ACK any further in the future. Flow
301 * control happens on the p-t-p BVCI and hence on index 1 */
Harald Welte5339b2e2020-10-04 22:52:56 +0200302 as_rx_bvc_fc_tx_ack(mp_gb_cfg.bvc[0].bvci, oneshot := true, idx := 1);
303 activate(as_rx_bvc_fc_tx_ack(mp_gb_cfg.bvc[0].bvci, idx := 1));
Harald Welte630d0e62019-02-22 23:26:40 +0100304}
305
306/* Test full IP-SNS bring-up with two NS-VCs, one sig-only and one user-only */
Harald Welteea3c7e92019-03-01 19:34:55 +0100307testcase TC_sns_1c1u() runs on RAW_Test_CT {
Harald Welte630d0e62019-02-22 23:26:40 +0100308 f_sns_bringup_1c1u();
309 setverdict(pass);
310}
311
Harald Welte64d07312019-03-20 09:48:39 +0100312private function f_sns_bringup_1c1u_separate(boolean sgsn_originated_reset := false) runs on RAW_Test_CT {
Harald Welteecd159e2019-03-16 13:36:07 +0100313 /* Activate two NS codec ports */
Alexander Couzens2beaa202020-09-11 20:08:41 +0200314 f_init_ns_codec(mp_nsconfig);
315 f_init_ns_codec(mp_nsconfig, 1);
316 f_init_ns_codec(mp_nsconfig, 2);
Harald Welteecd159e2019-03-16 13:36:07 +0100317 f_init_pcuif();
318 /* Perform Size + BSS-originated config */
319 f_incoming_sns_size();
320 f_incoming_sns_config();
321 /* perform SGSN-originated config using idx==0 for signalling and idx==1 for user traffic */
322 f_outgoing_sns_config_1c1u_separate();
323
324 /* wait for one ALIVE cycle, then ACK any further ALIVE in the background
325 * for both NS-VCs */
326 as_rx_alive_tx_ack(oneshot := true, idx := 1);
327 activate(as_rx_alive_tx_ack(idx := 1));
328 as_rx_alive_tx_ack(oneshot := true, idx := 2);
329 activate(as_rx_alive_tx_ack(idx := 2));
330 /* ensure there's no NS-ALIVE received on idx==0 */
331 f_ensure_no_ns(t_NS_ALIVE, idx := 0);
332
333 /* perform outgoing ALIVE procedure for both NS-VCs */
334 f_outgoing_ns_alive(1);
335 f_outgoing_ns_alive(2);
336 /* ensure there's no response to NS-ALIVE sent on idx==0 */
337 f_outgoing_ns_alive_no_ack(idx := 0);
338
Harald Welte64d07312019-03-20 09:48:39 +0100339 if (sgsn_originated_reset) {
Harald Weltee97e3af2020-10-09 14:56:54 +0200340 f_tx_bvc_reset_rx_ack(0, omit, omit, idx := 1);
341 f_tx_bvc_reset_rx_ack(mp_gb_cfg.bvc[0].bvci, omit, mp_gb_cfg.bvc[0].cell_id, idx := 1);
Harald Welte64d07312019-03-20 09:48:39 +0100342 } else {
343 /* Expect BVC-RESET for signaling BVCI=0 and ptp BVCI */
Harald Weltee97e3af2020-10-09 14:56:54 +0200344 as_rx_bvc_reset_tx_ack(0, omit, omit, oneshot := true, idx := 1);
345 as_rx_bvc_reset_tx_ack(mp_gb_cfg.bvc[0].bvci, mp_gb_cfg.bvc[0].cell_id, omit, oneshot := true, idx := 1);
Harald Welte64d07312019-03-20 09:48:39 +0100346 }
Harald Welteecd159e2019-03-16 13:36:07 +0100347 /* Expect UNBLOCK for ptp BVCI on signaling NS-VC (idx==1) */
Harald Welte5339b2e2020-10-04 22:52:56 +0200348 as_rx_bvc_unblock_tx_ack(mp_gb_cfg.bvc[0].bvci, oneshot := true, idx := 1);
Harald Welteecd159e2019-03-16 13:36:07 +0100349
350 /* wait for one FLOW-CONTROL BVC and then ACK any further in the future. Flow
351 * control happens on the p-t-p BVCI and hence on index 1 */
Harald Welte5339b2e2020-10-04 22:52:56 +0200352 as_rx_bvc_fc_tx_ack(mp_gb_cfg.bvc[0].bvci, oneshot := true, idx := 2);
353 activate(as_rx_bvc_fc_tx_ack(mp_gb_cfg.bvc[0].bvci, idx := 2));
Harald Welteecd159e2019-03-16 13:36:07 +0100354}
355
356/* Test full IP-SNS bring-up with two NS-VCs, one sig-only and one user-only - and where
357 * the initial IP/port for the SNS procedure is *not* part of the NS-VCs later */
358testcase TC_sns_1c1u_separate() runs on RAW_Test_CT {
359 f_sns_bringup_1c1u_separate();
360 setverdict(pass);
361}
362
Harald Welte64d07312019-03-20 09:48:39 +0100363/* Test full IP-SNS bring-up with two NS-VCs, one sig-only and one user-only and use
364 * SGSN-originated BVC-RESET rather than BSS-originated */
365testcase TC_sns_1c1u_so_bvc_reset() runs on RAW_Test_CT {
366 f_sns_bringup_1c1u_separate(sgsn_originated_reset := true);
367 setverdict(pass);
368}
369
370/* Transmit BVC-RESET before NS-ALIVE of PCU was ACKed: expect no response */
371testcase TC_sns_1c1u_so_bvc_reset_too_early() runs on RAW_Test_CT {
372 /* Activate two NS codec ports */
Alexander Couzens2beaa202020-09-11 20:08:41 +0200373 f_init_ns_codec(mp_nsconfig);
374 f_init_ns_codec(mp_nsconfig, 1);
375 f_init_ns_codec(mp_nsconfig, 2);
Harald Welte64d07312019-03-20 09:48:39 +0100376 f_init_pcuif();
377 /* Perform Size + BSS-originated config */
378 f_incoming_sns_size();
379 f_incoming_sns_config();
380 /* perform SGSN-originated config using idx==0 for signalling and idx==1 for user traffic */
381 f_outgoing_sns_config_1c1u_separate();
382
383 /* DON'T ACK ANY INBOUND NS-ALIVE HERE! */
384
385 /* perform outgoing ALIVE procedure for both NS-VCs */
386 f_outgoing_ns_alive(1);
387 f_outgoing_ns_alive(2);
388 /* ensure there's no response to NS-ALIVE sent on idx==0 */
389 f_outgoing_ns_alive_no_ack(idx := 0);
390
391 /* Transmit BVC-RESET and expect no ACK*/
Harald Weltee97e3af2020-10-09 14:56:54 +0200392 f_tx_bvc_reset_rx_ack(0, omit, omit, idx := 1, exp_ack := false);
393 f_tx_bvc_reset_rx_ack(mp_gb_cfg.bvc[0].bvci, omit, mp_gb_cfg.bvc[0].cell_id, idx := 1, exp_ack := false);
Harald Welte64d07312019-03-20 09:48:39 +0100394}
395
Harald Welte630d0e62019-02-22 23:26:40 +0100396/* Test adding new IP endpoints at runtime */
Harald Welteea3c7e92019-03-01 19:34:55 +0100397testcase TC_sns_add() runs on RAW_Test_CT {
Harald Welte630d0e62019-02-22 23:26:40 +0100398 f_sns_bringup_1c1u();
399
400 /* crate another NS codec port on the tester side */
Alexander Couzens2beaa202020-09-11 20:08:41 +0200401 f_init_ns_codec(mp_nsconfig, 2);
Harald Welte630d0e62019-02-22 23:26:40 +0100402
403 f_outgoing_sns_add(idx_add := 2, w_sig := 0, w_user := 1, idx := 0);
404
405 /* wait for one ALIVE cycle, then ACK any further ALIVE in the background */
406 as_rx_alive_tx_ack(oneshot := true, idx := 2);
407 activate(as_rx_alive_tx_ack(idx := 2));
408
409 f_outgoing_ns_alive(2);
410 /* TODO: Should we expect FLOW-CONTROL BVC here too? */
411 setverdict(pass);
412}
413
414/* Test deleting IP endpoints at runtime */
Harald Welteea3c7e92019-03-01 19:34:55 +0100415testcase TC_sns_del() runs on RAW_Test_CT {
Harald Welte630d0e62019-02-22 23:26:40 +0100416 f_sns_bringup_1c1u();
417
418 f_outgoing_sns_del(idx_del := 1, w_sig := 0, w_user := 1, idx := 0);
419 /* FIXME: ensure we don't receive anything on just-deleted NS-VC anymore */
420 setverdict(pass);
421}
422
Harald Welte72099552019-02-23 15:09:22 +0100423/* Test changing weights at runtime */
Harald Welteea3c7e92019-03-01 19:34:55 +0100424testcase TC_sns_chg_weight() runs on RAW_Test_CT {
Harald Welte72099552019-02-23 15:09:22 +0100425 f_sns_bringup_1c1u();
426
427 /* change w_user from 1 to 200 */
428 f_outgoing_sns_chg_weight(idx_chg := 1, w_sig := 0, w_user := 200, idx := 0);
429 setverdict(pass);
430}
431
Harald Welte16e92f42019-03-02 00:03:44 +0100432import from PCUIF_Types all;
433import from PCUIF_CodecPort all;
434
Harald Welte3b335832019-03-15 22:38:06 +0100435altstep as_pcu_activate() runs on RAW_PCU_CT {
436 var PCUIF_send_data sd;
437 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_ACT_REQ(?, ?, ?))) -> value sd { repeat; }
438
439}
440
Harald Welte16e92f42019-03-02 00:03:44 +0100441testcase TC_pcuif_rach() runs on RAW_Test_CT {
442 f_sns_bringup_1c1u();
Harald Welte3b335832019-03-15 22:38:06 +0100443 activate(as_pcu_activate());
Harald Welte16e92f42019-03-02 00:03:44 +0100444
Vadim Yanitskiy36558d92019-11-17 02:23:51 +0700445 f_pcuif_tx(ts_PCUIF_RACH_IND(bts_nr:=0, trx_nr:=0, ts_nr:=0, ra:=23,
446 is_11bit:=0, burst_type:=BURST_TYPE_0,
Harald Welte16e92f42019-03-02 00:03:44 +0100447 fn:=42, arfcn:=871, qta:=0));
448 PCU.receive(t_SD_PCUIF(g_pcu_conn_id,
449 tr_PCUIF_DATA_REQ(bts_nr:=0, trx_nr:=0, ts_nr:=0, block_nr:=?, fn:=?,
450 sapi:=PCU_IF_SAPI_AGCH, data:=?)));
451 setverdict(pass);
452}
453
Harald Welte630d0e62019-02-22 23:26:40 +0100454
455
Harald Weltef7b74072019-02-20 20:48:50 +0100456control {
457 execute( TC_sns_po_size_success() );
458 execute( TC_sns_po_size_nack() );
459 execute( TC_sns_po_config_success() );
460 execute( TC_sns_po_config_nack() );
461 execute( TC_sns_so_config_success() );
Harald Welte630d0e62019-02-22 23:26:40 +0100462 execute( TC_sns_1c1u() );
Harald Welteecd159e2019-03-16 13:36:07 +0100463 execute( TC_sns_1c1u_separate() );
Harald Welte64d07312019-03-20 09:48:39 +0100464 execute( TC_sns_1c1u_so_bvc_reset() );
465 execute( TC_sns_1c1u_so_bvc_reset_too_early() );
Harald Welte630d0e62019-02-22 23:26:40 +0100466 execute( TC_sns_add() );
467 execute( TC_sns_del() );
Harald Welte72099552019-02-23 15:09:22 +0100468 execute( TC_sns_chg_weight() );
Harald Welte16e92f42019-03-02 00:03:44 +0100469
470 execute( TC_pcuif_rach() );
Harald Weltef7b74072019-02-20 20:48:50 +0100471}
472
473}