blob: 937e30e30a5e9fc6cdc33a3787e4e0c7113dd5e8 [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;
Harald Welte90f19742020-11-06 19:34:40 +010017import from NS_Emulation all;
Harald Weltec4d7beb2019-02-21 18:21:01 +010018import from NS_CodecPort all;
19import from NS_Types all;
Alexander Couzens3c268da2020-09-07 04:25:05 +020020import from RAW_NS all;
Harald Weltef7b74072019-02-20 20:48:50 +010021
22/**********************************************************************************
23 * Modern Gb/IP bring-up test cases using IP Sub-Network Service (SNS)
24 **********************************************************************************/
25
Harald Weltec4d7beb2019-02-21 18:21:01 +010026/* perform inbound SNS-SIZE procedure */
Harald Weltebf768242019-02-21 22:19:21 +010027function f_incoming_sns_size(template (omit) NsCause cause := omit, integer idx := 0)
28runs on RAW_NS_CT {
Harald Welteb63c3a12019-02-22 23:27:12 +010029 log("f_incoming_sns_size(idx=", idx, ")");
Harald Weltec4d7beb2019-02-21 18:21:01 +010030 var PDU_NS rx;
Harald Welte90f19742020-11-06 19:34:40 +010031 var NSVCConfiguration nsvc_cfg := g_nsconfig[idx].nsvc[0];
Alexander Couzens7b1e44f2020-08-25 23:33:17 +020032
Harald Welte90f19742020-11-06 19:34:40 +010033 if (nsvc_cfg.provider.ip.address_family == AF_INET) {
Alexander Couzens7b1e44f2020-08-25 23:33:17 +020034 /* expect one single SNS-SIZE with RESET flag; 4x v4 EP; no v6 EP */
35 rx := f_ns_exp(tr_SNS_SIZE(g_nsconfig[idx].nsei, rst_flag := true, max_nsvcs := 8,
36 num_v4 := 4, num_v6 := omit), idx);
37 } else {
38 /* expect one single SNS-SIZE with RESET flag; no v4 EP; 4x v6 EP */
39 rx := f_ns_exp(tr_SNS_SIZE(g_nsconfig[idx].nsei, rst_flag := true, max_nsvcs := 8,
40 num_v4 := omit, num_v6 := 4), idx);
41 }
Harald Weltebf768242019-02-21 22:19:21 +010042 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 +010043}
44
45/* perform outbound SNS-SIZE procedure */
Harald Weltebf768242019-02-21 22:19:21 +010046function f_outgoing_sns_size(template (omit) NsCause cause := omit, integer idx:= 0)
47runs on RAW_NS_CT {
Harald Welteb63c3a12019-02-22 23:27:12 +010048 log("f_outgoing_sns_size(idx=", idx, ")");
Harald Weltec4d7beb2019-02-21 18:21:01 +010049 var PDU_NS rx;
Harald Welte90f19742020-11-06 19:34:40 +010050 var NSVCConfiguration nsvc_cfg := g_nsconfig[idx].nsvc[0];
51
52 if (nsvc_cfg.provider.ip.address_family == AF_INET) {
Alexander Couzens7b1e44f2020-08-25 23:33:17 +020053 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 := 1, num_v6 := omit)
55 ));
56 } else {
57 NSCP[idx].send(t_NS_Send(g_ns_conn_id[idx], ts_SNS_SIZE(g_nsconfig[idx].nsei, rst_flag := true, max_nsvcs := 1,
58 num_v4 := omit, num_v6 := 1)
59 ));
60 }
61 /* expect one single SNS-SIZE with RESET flag; 4x v4 EP; no v6 EP */
Harald Weltebf768242019-02-21 22:19:21 +010062 rx := f_ns_exp(tr_SNS_SIZE_ACK(g_nsconfig[idx].nsei, cause), idx);
Harald Weltec4d7beb2019-02-21 18:21:01 +010063}
64
65/* perform inbound SNS-CONFIG procedure */
Harald Weltebf768242019-02-21 22:19:21 +010066function f_incoming_sns_config(template (omit) NsCause cause := omit, integer idx := 0)
67runs on RAW_NS_CT {
Harald Welteb63c3a12019-02-22 23:27:12 +010068 log("f_incoming_sns_config(idx=", idx, ")");
Harald Weltec4d7beb2019-02-21 18:21:01 +010069 var PDU_NS rx;
Harald Welte90f19742020-11-06 19:34:40 +010070 var NSVCConfiguration nsvc_cfg := g_nsconfig[idx].nsvc[0];
Alexander Couzens7b1e44f2020-08-25 23:33:17 +020071
Harald Welte90f19742020-11-06 19:34:40 +010072 if (nsvc_cfg.provider.ip.address_family == AF_INET) {
73 var template IP4_Elements v4_elem := { tr_SNS_IPv4(nsvc_cfg.provider.ip.remote_ip,
74 nsvc_cfg.provider.ip.remote_udp_port) };
Alexander Couzens7b1e44f2020-08-25 23:33:17 +020075 rx := f_ns_exp(tr_SNS_CONFIG(g_nsconfig[idx].nsei, end_flag := true, v4 := v4_elem), idx);
76 } else {
Harald Welte90f19742020-11-06 19:34:40 +010077 var template IP6_Elements v6_elem := { tr_SNS_IPv6(nsvc_cfg.provider.ip.remote_ip,
78 nsvc_cfg.provider.ip.remote_udp_port) };
Alexander Couzens7b1e44f2020-08-25 23:33:17 +020079 rx := f_ns_exp(tr_SNS_CONFIG(g_nsconfig[idx].nsei, end_flag := true, v6 := v6_elem), idx);
80 }
Harald Weltebf768242019-02-21 22:19:21 +010081 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 +010082}
83
84/* perform outbound SNS-CONFIG procedure */
Harald Weltebf768242019-02-21 22:19:21 +010085function f_outgoing_sns_config(template (omit) NsCause cause := omit, integer idx := 0)
86runs on RAW_NS_CT {
Harald Welteb63c3a12019-02-22 23:27:12 +010087 log("f_outgoing_sns_config(idx=", idx, ")");
Harald Weltec4d7beb2019-02-21 18:21:01 +010088 var PDU_NS rx;
Harald Welte90f19742020-11-06 19:34:40 +010089 var NSVCConfiguration nsvc_cfg := g_nsconfig[idx].nsvc[0];
90
91 if (nsvc_cfg.provider.ip.address_family == AF_INET) {
92 var template (omit) IP4_Elements v4 := { ts_SNS_IPv4(nsvc_cfg.provider.ip.local_ip,
93 nsvc_cfg.provider.ip.local_udp_port) }
Alexander Couzens7b1e44f2020-08-25 23:33:17 +020094 NSCP[idx].send(t_NS_Send(g_ns_conn_id[idx], ts_SNS_CONFIG(g_nsconfig[idx].nsei, true, v4)));
95 } else {
Harald Welte90f19742020-11-06 19:34:40 +010096 var template (omit) IP6_Elements v6 := { ts_SNS_IPv6(nsvc_cfg.provider.ip.local_ip,
97 nsvc_cfg.provider.ip.local_udp_port) }
Alexander Couzens7b1e44f2020-08-25 23:33:17 +020098 NSCP[idx].send(t_NS_Send(g_ns_conn_id[idx], ts_SNS_CONFIG(g_nsconfig[idx].nsei, true, omit, v6)));
99 }
Harald Weltebf768242019-02-21 22:19:21 +0100100 rx := f_ns_exp(tr_SNS_CONFIG_ACK(g_nsconfig[idx].nsei, cause), idx);
Harald Weltec4d7beb2019-02-21 18:21:01 +0100101}
102
Harald Weltebf768242019-02-21 22:19:21 +0100103/* perform outbound SNS-CONFIG procedure (separate endpoints: 1 for control, 1 for user */
104function f_outgoing_sns_config_1c1u(template (omit) NsCause cause := omit, integer idx := 0)
105runs on RAW_NS_CT {
Harald Welteb63c3a12019-02-22 23:27:12 +0100106 log("f_outgoing_sns_config_1c1u(idx=", idx, ")");
Harald Weltebf768242019-02-21 22:19:21 +0100107 var PDU_NS rx;
Harald Welte90f19742020-11-06 19:34:40 +0100108
109 if (mp_nsconfig.nsvc[0].provider.ip.address_family == AF_INET) {
110 var template (omit) IP4_Elements v4 := { ts_SNS_IPv4(g_nsconfig[0].nsvc[0].provider.ip.local_ip,
111 g_nsconfig[0].nsvc[0].provider.ip.local_udp_port, 1, 0),
112 ts_SNS_IPv4(g_nsconfig[1].nsvc[0].provider.ip.local_ip,
113 g_nsconfig[1].nsvc[0].provider.ip.local_udp_port, 0, 1) };
Alexander Couzens7b1e44f2020-08-25 23:33:17 +0200114 NSCP[idx].send(t_NS_Send(g_ns_conn_id[idx], ts_SNS_CONFIG(g_nsconfig[idx].nsei, true, v4)));
115 } else {
Harald Welte90f19742020-11-06 19:34:40 +0100116 var template (omit) IP6_Elements v6 := { ts_SNS_IPv6(g_nsconfig[0].nsvc[0].provider.ip.local_ip,
117 g_nsconfig[0].nsvc[0].provider.ip.local_udp_port, 1, 0),
118 ts_SNS_IPv6(g_nsconfig[1].nsvc[0].provider.ip.local_ip,
119 g_nsconfig[1].nsvc[0].provider.ip.local_udp_port, 0, 1) };
Alexander Couzens7b1e44f2020-08-25 23:33:17 +0200120 NSCP[idx].send(t_NS_Send(g_ns_conn_id[idx], ts_SNS_CONFIG(g_nsconfig[idx].nsei, true, omit, v6)));
121 }
Harald Weltebf768242019-02-21 22:19:21 +0100122 rx := f_ns_exp(tr_SNS_CONFIG_ACK(g_nsconfig[idx].nsei, cause), idx);
123}
124
Harald Welteecd159e2019-03-16 13:36:07 +0100125/* perform outbound SNS-CONFIG procedure (separate endpoints: 1 for control, 1 for user */
126function f_outgoing_sns_config_1c1u_separate(template (omit) NsCause cause := omit, integer idx := 0)
127runs on RAW_NS_CT {
128 log("f_outgoing_sns_config_1c1u_separate(idx=", idx, ")");
129 var PDU_NS rx;
Harald Welte90f19742020-11-06 19:34:40 +0100130 if (mp_nsconfig.nsvc[0].provider.ip.address_family == AF_INET) {
131 var template (omit) IP4_Elements v4 := { ts_SNS_IPv4(g_nsconfig[1].nsvc[0].provider.ip.local_ip,
132 g_nsconfig[1].nsvc[0].provider.ip.local_udp_port, 1, 0),
133 ts_SNS_IPv4(g_nsconfig[2].nsvc[0].provider.ip.local_ip,
134 g_nsconfig[2].nsvc[0].provider.ip.local_udp_port, 0, 1) };
Alexander Couzens7b1e44f2020-08-25 23:33:17 +0200135 NSCP[idx].send(t_NS_Send(g_ns_conn_id[idx], ts_SNS_CONFIG(g_nsconfig[idx].nsei, true, v4)));
136 } else {
Harald Welte90f19742020-11-06 19:34:40 +0100137 var template (omit) IP6_Elements v6 := { ts_SNS_IPv6(g_nsconfig[1].nsvc[0].provider.ip.local_ip,
138 g_nsconfig[1].nsvc[0].provider.ip.local_udp_port, 1, 0),
139 ts_SNS_IPv6(g_nsconfig[2].nsvc[0].provider.ip.local_ip,
140 g_nsconfig[2].nsvc[0].provider.ip.local_udp_port, 0, 1) };
Alexander Couzens7b1e44f2020-08-25 23:33:17 +0200141 NSCP[idx].send(t_NS_Send(g_ns_conn_id[idx], ts_SNS_CONFIG(g_nsconfig[idx].nsei, true, omit, v6)));
142 }
Harald Welteecd159e2019-03-16 13:36:07 +0100143 rx := f_ns_exp(tr_SNS_CONFIG_ACK(g_nsconfig[idx].nsei, cause), idx);
144}
145
Alexander Couzens2a0ac802020-12-09 02:19:29 +0100146function f_outgoing_sns_add(integer idx_add, uint8_t w_sig := 1, uint8_t w_user := 1, integer idx := 0, template (omit) NsCause cause := omit)
Harald Welte630d0e62019-02-22 23:26:40 +0100147runs on RAW_NS_CT {
148 log("f_outgoing_sns_add(idx_add=", idx_add, ")");
149 var PDU_NS rx;
Alexander Couzensa8fb6212020-12-09 02:05:02 +0100150 var NSVCConfiguration nsvc_cfg := g_nsconfig[idx_add].nsvc[0];
Harald Welte90f19742020-11-06 19:34:40 +0100151 if (nsvc_cfg.provider.ip.address_family == AF_INET) {
152 var template (omit) IP4_Elements v4 := { ts_SNS_IPv4(nsvc_cfg.provider.ip.local_ip,
153 nsvc_cfg.provider.ip.local_udp_port,
Alexander Couzens7b1e44f2020-08-25 23:33:17 +0200154 w_sig, w_user) };
155 NSCP[idx].send(t_NS_Send(g_ns_conn_id[idx], ts_SNS_ADD(g_nsconfig[idx].nsei, 23, v4)));
Alexander Couzens2a0ac802020-12-09 02:19:29 +0100156 rx := f_ns_exp(tr_SNS_ACK(g_nsconfig[idx].nsei, 23, cause, v4));
Alexander Couzens7b1e44f2020-08-25 23:33:17 +0200157 } else {
Harald Welte90f19742020-11-06 19:34:40 +0100158 var template (omit) IP6_Elements v6 := { ts_SNS_IPv6(nsvc_cfg.provider.ip.local_ip,
159 nsvc_cfg.provider.ip.local_udp_port,
Alexander Couzens7b1e44f2020-08-25 23:33:17 +0200160 w_sig, w_user) };
161 NSCP[idx].send(t_NS_Send(g_ns_conn_id[idx], ts_SNS_ADD(g_nsconfig[idx].nsei, 23, omit, v6)));
Alexander Couzens2a0ac802020-12-09 02:19:29 +0100162 rx := f_ns_exp(tr_SNS_ACK(g_nsconfig[idx].nsei, 23, cause, omit, v6));
Alexander Couzens7b1e44f2020-08-25 23:33:17 +0200163 }
Harald Welte630d0e62019-02-22 23:26:40 +0100164}
165
166function f_outgoing_sns_del(integer idx_del, uint8_t w_sig := 1, uint8_t w_user := 1, integer idx := 0)
167runs on RAW_NS_CT {
168 log("f_outgoing_sns_del(idx_del=", idx_del, ")");
169 var PDU_NS rx;
Harald Welte90f19742020-11-06 19:34:40 +0100170 var NSVCConfiguration nsvc_cfg := g_nsconfig[idx_del].nsvc[0];
171 if (nsvc_cfg.provider.ip.address_family == AF_INET) {
172 var template (omit) IP4_Elements v4 := { ts_SNS_IPv4(nsvc_cfg.provider.ip.local_ip,
173 nsvc_cfg.provider.ip.local_udp_port,
Alexander Couzens7b1e44f2020-08-25 23:33:17 +0200174 w_sig, w_user) };
175 NSCP[idx].send(t_NS_Send(g_ns_conn_id[idx], ts_SNS_DEL(g_nsconfig[idx].nsei, 24, omit, v4)));
176 rx := f_ns_exp(tr_SNS_ACK(g_nsconfig[idx].nsei, 24, omit, v4));
177 } else {
Harald Welte90f19742020-11-06 19:34:40 +0100178 var template (omit) IP6_Elements v6 := { ts_SNS_IPv6(nsvc_cfg.provider.ip.local_ip,
179 nsvc_cfg.provider.ip.local_udp_port,
Alexander Couzens7b1e44f2020-08-25 23:33:17 +0200180 w_sig, w_user) };
181 NSCP[idx].send(t_NS_Send(g_ns_conn_id[idx], ts_SNS_DEL(g_nsconfig[idx].nsei, 24, omit, omit, v6)));
182 rx := f_ns_exp(tr_SNS_ACK(g_nsconfig[idx].nsei, 24, omit, omit, v6));
183 }
Harald Welte630d0e62019-02-22 23:26:40 +0100184}
185
Harald Welte72099552019-02-23 15:09:22 +0100186function f_outgoing_sns_chg_weight(integer idx_chg, uint8_t w_sig, uint8_t w_user, integer idx := 0)
187runs on RAW_NS_CT {
188 log("f_outgoing_sns_chg_weight(idx_chg=", idx_chg, ")");
189 var PDU_NS rx;
Harald Welte90f19742020-11-06 19:34:40 +0100190 var NSVCConfiguration nsvc_cfg := g_nsconfig[idx_chg].nsvc[0];
191 if (nsvc_cfg.provider.ip.address_family == AF_INET) {
192 var template (omit) IP4_Elements v4 := { ts_SNS_IPv4(nsvc_cfg.provider.ip.local_ip,
193 nsvc_cfg.provider.ip.local_udp_port,
Alexander Couzens7b1e44f2020-08-25 23:33:17 +0200194 w_sig, w_user) };
195 NSCP[idx].send(t_NS_Send(g_ns_conn_id[idx], ts_SNS_CHG_WEIGHT(g_nsconfig[idx].nsei, 25, v4)));
196 rx := f_ns_exp(tr_SNS_ACK(g_nsconfig[idx].nsei, 25, omit, v4));
197 } else {
Harald Welte90f19742020-11-06 19:34:40 +0100198 var template (omit) IP6_Elements v6 := { ts_SNS_IPv6(nsvc_cfg.provider.ip.local_ip,
199 nsvc_cfg.provider.ip.local_udp_port,
Alexander Couzens7b1e44f2020-08-25 23:33:17 +0200200 w_sig, w_user) };
201 NSCP[idx].send(t_NS_Send(g_ns_conn_id[idx], ts_SNS_CHG_WEIGHT(g_nsconfig[idx].nsei, 25, omit, v6)));
202 rx := f_ns_exp(tr_SNS_ACK(g_nsconfig[idx].nsei, 25, omit, omit, v6));
203 }
Harald Welte72099552019-02-23 15:09:22 +0100204}
205
206
207
Harald Welte630d0e62019-02-22 23:26:40 +0100208
Harald Weltebf768242019-02-21 22:19:21 +0100209
Harald Weltef7b74072019-02-20 20:48:50 +0100210/* PCU-originated SNS-SIZE: successful case */
Harald Welteea3c7e92019-03-01 19:34:55 +0100211testcase TC_sns_po_size_success() runs on RAW_Test_CT {
Alexander Couzens2beaa202020-09-11 20:08:41 +0200212 f_init_ns_codec(mp_nsconfig);
Harald Weltef7b74072019-02-20 20:48:50 +0100213 f_init_pcuif();
214 f_incoming_sns_size();
215 f_sleep(1.0);
216 setverdict(pass);
217}
218
219/* PCU-originated SNS-SIZE: NACK from our side */
Harald Welteea3c7e92019-03-01 19:34:55 +0100220testcase TC_sns_po_size_nack() runs on RAW_Test_CT {
Alexander Couzens2beaa202020-09-11 20:08:41 +0200221 f_init_ns_codec(mp_nsconfig);
Harald Weltef7b74072019-02-20 20:48:50 +0100222 f_init_pcuif();
223 f_incoming_sns_size(NS_CAUSE_PROTOCOL_ERROR_UNSPEIFIED);
224 /* FIXME: ensure we don't get a SNS-CONFIG */
225 /* FIXME: ensure we get re-transmitted SNS-SIZE attempts */
226 f_sleep(10.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_success() 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();
236 f_sleep(1.0);
237 setverdict(pass);
238}
239
240/* PCU-originated SNS-CONFIG: successful case */
Harald Welteea3c7e92019-03-01 19:34:55 +0100241testcase TC_sns_po_config_nack() runs on RAW_Test_CT {
Alexander Couzens2beaa202020-09-11 20:08:41 +0200242 f_init_ns_codec(mp_nsconfig);
Harald Weltef7b74072019-02-20 20:48:50 +0100243 f_init_pcuif();
244 f_incoming_sns_size();
245 f_incoming_sns_config(NS_CAUSE_PROTOCOL_ERROR_UNSPEIFIED);
246 /* FIXME: ensure we get re-transmitted SNS-CONFIG attempts */
247 f_sleep(10.0);
248 setverdict(pass);
249}
250
251
252/* SGSN-originated SNS-SIZE: successful case */
Harald Welteea3c7e92019-03-01 19:34:55 +0100253testcase TC_sns_so_config_success() runs on RAW_Test_CT {
Alexander Couzens2beaa202020-09-11 20:08:41 +0200254 f_init_ns_codec(mp_nsconfig);
Harald Weltef7b74072019-02-20 20:48:50 +0100255 f_init_pcuif();
256 f_incoming_sns_size();
257 f_incoming_sns_config();
258 f_outgoing_sns_config();
259
260 /* wait for one ALIVE cycle, then ACK any further ALIVE in the background */
261 as_rx_alive_tx_ack(oneshot := true);
262 activate(as_rx_alive_tx_ack());
263
264 f_outgoing_ns_alive();
265
266 /* Expect BVC-RESET for signaling (0) and ptp BVCI */
Harald Weltee97e3af2020-10-09 14:56:54 +0200267 as_rx_bvc_reset_tx_ack(0, omit, omit, oneshot := true);
268 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 +0200269 as_rx_bvc_unblock_tx_ack(mp_gb_cfg.bvc[0].bvci, oneshot := true);
Harald Weltef7b74072019-02-20 20:48:50 +0100270
271 /* wait for one FLOW-CONTROL BVC and then ACK any further in the future */
Harald Welte5339b2e2020-10-04 22:52:56 +0200272 as_rx_bvc_fc_tx_ack(mp_gb_cfg.bvc[0].bvci, oneshot := true);
273 activate(as_rx_bvc_fc_tx_ack(mp_gb_cfg.bvc[0].bvci));
Harald Weltef7b74072019-02-20 20:48:50 +0100274 setverdict(pass);
275}
276
Harald Welte64d07312019-03-20 09:48:39 +0100277private function f_sns_bringup_1c1u(boolean sgsn_originated_reset := false) runs on RAW_Test_CT {
Harald Welte630d0e62019-02-22 23:26:40 +0100278 /* Activate two NS codec ports */
Alexander Couzens2beaa202020-09-11 20:08:41 +0200279 f_init_ns_codec(mp_nsconfig);
280 f_init_ns_codec(mp_nsconfig, 1);
Harald Welte630d0e62019-02-22 23:26:40 +0100281 f_init_pcuif();
282 /* Perform Size + BSS-originated config */
283 f_incoming_sns_size();
284 f_incoming_sns_config();
285 /* perform SGSN-originated config using idx==0 for signalling and idx==1 for user traffic */
286 f_outgoing_sns_config_1c1u();
287
288 /* wait for one ALIVE cycle, then ACK any further ALIVE in the background
289 * for both NS-VCs */
290 as_rx_alive_tx_ack(oneshot := true, idx := 0);
291 activate(as_rx_alive_tx_ack(idx := 0));
292 as_rx_alive_tx_ack(oneshot := true, idx := 1);
293 activate(as_rx_alive_tx_ack(idx := 1));
294
295 /* perform outgoing ALIVE procedure for both NS-VCs */
296 f_outgoing_ns_alive(0);
297 f_outgoing_ns_alive(1);
298
Harald Welte64d07312019-03-20 09:48:39 +0100299 if (sgsn_originated_reset) {
Harald Weltee97e3af2020-10-09 14:56:54 +0200300 f_tx_bvc_reset_rx_ack(0, omit, omit);
301 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 +0100302 } else {
303 /* Expect BVC-RESET for signaling (0) and ptp BVCI */
Harald Weltee97e3af2020-10-09 14:56:54 +0200304 as_rx_bvc_reset_tx_ack(0, omit, omit, oneshot := true);
305 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 +0100306 }
Harald Welte630d0e62019-02-22 23:26:40 +0100307 /* Expect UNBLOCK for ptp BVCI on signaling NS-VC (idx==0) */
Harald Welte5339b2e2020-10-04 22:52:56 +0200308 as_rx_bvc_unblock_tx_ack(mp_gb_cfg.bvc[0].bvci, oneshot := true);
Harald Welte630d0e62019-02-22 23:26:40 +0100309
310 /* wait for one FLOW-CONTROL BVC and then ACK any further in the future. Flow
311 * control happens on the p-t-p BVCI and hence on index 1 */
Harald Welte5339b2e2020-10-04 22:52:56 +0200312 as_rx_bvc_fc_tx_ack(mp_gb_cfg.bvc[0].bvci, oneshot := true, idx := 1);
313 activate(as_rx_bvc_fc_tx_ack(mp_gb_cfg.bvc[0].bvci, idx := 1));
Harald Welte630d0e62019-02-22 23:26:40 +0100314}
315
316/* Test full IP-SNS bring-up with two NS-VCs, one sig-only and one user-only */
Harald Welteea3c7e92019-03-01 19:34:55 +0100317testcase TC_sns_1c1u() runs on RAW_Test_CT {
Harald Welte630d0e62019-02-22 23:26:40 +0100318 f_sns_bringup_1c1u();
319 setverdict(pass);
320}
321
Harald Welte64d07312019-03-20 09:48:39 +0100322private function f_sns_bringup_1c1u_separate(boolean sgsn_originated_reset := false) runs on RAW_Test_CT {
Harald Welteecd159e2019-03-16 13:36:07 +0100323 /* Activate two NS codec ports */
Alexander Couzens2beaa202020-09-11 20:08:41 +0200324 f_init_ns_codec(mp_nsconfig);
325 f_init_ns_codec(mp_nsconfig, 1);
326 f_init_ns_codec(mp_nsconfig, 2);
Harald Welteecd159e2019-03-16 13:36:07 +0100327 f_init_pcuif();
328 /* Perform Size + BSS-originated config */
329 f_incoming_sns_size();
330 f_incoming_sns_config();
331 /* perform SGSN-originated config using idx==0 for signalling and idx==1 for user traffic */
332 f_outgoing_sns_config_1c1u_separate();
333
334 /* wait for one ALIVE cycle, then ACK any further ALIVE in the background
335 * for both NS-VCs */
336 as_rx_alive_tx_ack(oneshot := true, idx := 1);
337 activate(as_rx_alive_tx_ack(idx := 1));
338 as_rx_alive_tx_ack(oneshot := true, idx := 2);
339 activate(as_rx_alive_tx_ack(idx := 2));
340 /* ensure there's no NS-ALIVE received on idx==0 */
341 f_ensure_no_ns(t_NS_ALIVE, idx := 0);
342
343 /* perform outgoing ALIVE procedure for both NS-VCs */
344 f_outgoing_ns_alive(1);
345 f_outgoing_ns_alive(2);
346 /* ensure there's no response to NS-ALIVE sent on idx==0 */
347 f_outgoing_ns_alive_no_ack(idx := 0);
348
Harald Welte64d07312019-03-20 09:48:39 +0100349 if (sgsn_originated_reset) {
Harald Weltee97e3af2020-10-09 14:56:54 +0200350 f_tx_bvc_reset_rx_ack(0, omit, omit, idx := 1);
351 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 +0100352 } else {
353 /* Expect BVC-RESET for signaling BVCI=0 and ptp BVCI */
Harald Weltee97e3af2020-10-09 14:56:54 +0200354 as_rx_bvc_reset_tx_ack(0, omit, omit, oneshot := true, idx := 1);
355 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 +0100356 }
Harald Welteecd159e2019-03-16 13:36:07 +0100357 /* Expect UNBLOCK for ptp BVCI on signaling NS-VC (idx==1) */
Harald Welte5339b2e2020-10-04 22:52:56 +0200358 as_rx_bvc_unblock_tx_ack(mp_gb_cfg.bvc[0].bvci, oneshot := true, idx := 1);
Harald Welteecd159e2019-03-16 13:36:07 +0100359
360 /* wait for one FLOW-CONTROL BVC and then ACK any further in the future. Flow
361 * control happens on the p-t-p BVCI and hence on index 1 */
Harald Welte5339b2e2020-10-04 22:52:56 +0200362 as_rx_bvc_fc_tx_ack(mp_gb_cfg.bvc[0].bvci, oneshot := true, idx := 2);
363 activate(as_rx_bvc_fc_tx_ack(mp_gb_cfg.bvc[0].bvci, idx := 2));
Harald Welteecd159e2019-03-16 13:36:07 +0100364}
365
366/* Test full IP-SNS bring-up with two NS-VCs, one sig-only and one user-only - and where
367 * the initial IP/port for the SNS procedure is *not* part of the NS-VCs later */
368testcase TC_sns_1c1u_separate() runs on RAW_Test_CT {
369 f_sns_bringup_1c1u_separate();
370 setverdict(pass);
371}
372
Harald Welte64d07312019-03-20 09:48:39 +0100373/* Test full IP-SNS bring-up with two NS-VCs, one sig-only and one user-only and use
374 * SGSN-originated BVC-RESET rather than BSS-originated */
375testcase TC_sns_1c1u_so_bvc_reset() runs on RAW_Test_CT {
376 f_sns_bringup_1c1u_separate(sgsn_originated_reset := true);
377 setverdict(pass);
378}
379
380/* Transmit BVC-RESET before NS-ALIVE of PCU was ACKed: expect no response */
381testcase TC_sns_1c1u_so_bvc_reset_too_early() runs on RAW_Test_CT {
382 /* Activate two NS codec ports */
Alexander Couzens2beaa202020-09-11 20:08:41 +0200383 f_init_ns_codec(mp_nsconfig);
384 f_init_ns_codec(mp_nsconfig, 1);
385 f_init_ns_codec(mp_nsconfig, 2);
Harald Welte64d07312019-03-20 09:48:39 +0100386 f_init_pcuif();
387 /* Perform Size + BSS-originated config */
388 f_incoming_sns_size();
389 f_incoming_sns_config();
390 /* perform SGSN-originated config using idx==0 for signalling and idx==1 for user traffic */
391 f_outgoing_sns_config_1c1u_separate();
392
393 /* DON'T ACK ANY INBOUND NS-ALIVE HERE! */
394
395 /* perform outgoing ALIVE procedure for both NS-VCs */
396 f_outgoing_ns_alive(1);
397 f_outgoing_ns_alive(2);
398 /* ensure there's no response to NS-ALIVE sent on idx==0 */
399 f_outgoing_ns_alive_no_ack(idx := 0);
400
401 /* Transmit BVC-RESET and expect no ACK*/
Harald Weltee97e3af2020-10-09 14:56:54 +0200402 f_tx_bvc_reset_rx_ack(0, omit, omit, idx := 1, exp_ack := false);
403 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 +0100404}
405
Harald Welte630d0e62019-02-22 23:26:40 +0100406/* Test adding new IP endpoints at runtime */
Harald Welteea3c7e92019-03-01 19:34:55 +0100407testcase TC_sns_add() runs on RAW_Test_CT {
Harald Welte630d0e62019-02-22 23:26:40 +0100408 f_sns_bringup_1c1u();
409
410 /* crate another NS codec port on the tester side */
Alexander Couzens2beaa202020-09-11 20:08:41 +0200411 f_init_ns_codec(mp_nsconfig, 2);
Harald Welte630d0e62019-02-22 23:26:40 +0100412
413 f_outgoing_sns_add(idx_add := 2, w_sig := 0, w_user := 1, idx := 0);
414
415 /* wait for one ALIVE cycle, then ACK any further ALIVE in the background */
416 as_rx_alive_tx_ack(oneshot := true, idx := 2);
417 activate(as_rx_alive_tx_ack(idx := 2));
418
419 f_outgoing_ns_alive(2);
Harald Welte630d0e62019-02-22 23:26:40 +0100420 setverdict(pass);
421}
422
Alexander Couzens2a0ac802020-12-09 02:19:29 +0100423/* Test adding an already present IP endpoint at runtime */
424testcase TC_sns_add_nack() runs on RAW_Test_CT {
425 f_sns_bringup_1c1u();
426
427 f_outgoing_sns_add(idx_add := 0, w_sig := 0, w_user := 1, idx := 0, cause := NS_CAUSE_PROTOCOL_ERROR_UNSPEIFIED);
428 setverdict(pass);
429}
430
Harald Welte630d0e62019-02-22 23:26:40 +0100431/* Test deleting IP endpoints at runtime */
Harald Welteea3c7e92019-03-01 19:34:55 +0100432testcase TC_sns_del() runs on RAW_Test_CT {
Harald Welte630d0e62019-02-22 23:26:40 +0100433 f_sns_bringup_1c1u();
434
435 f_outgoing_sns_del(idx_del := 1, w_sig := 0, w_user := 1, idx := 0);
436 /* FIXME: ensure we don't receive anything on just-deleted NS-VC anymore */
437 setverdict(pass);
438}
439
Harald Welte72099552019-02-23 15:09:22 +0100440/* Test changing weights at runtime */
Harald Welteea3c7e92019-03-01 19:34:55 +0100441testcase TC_sns_chg_weight() runs on RAW_Test_CT {
Harald Welte72099552019-02-23 15:09:22 +0100442 f_sns_bringup_1c1u();
443
444 /* change w_user from 1 to 200 */
445 f_outgoing_sns_chg_weight(idx_chg := 1, w_sig := 0, w_user := 200, idx := 0);
446 setverdict(pass);
447}
448
Harald Welte16e92f42019-03-02 00:03:44 +0100449import from PCUIF_Types all;
450import from PCUIF_CodecPort all;
451
Harald Welte3b335832019-03-15 22:38:06 +0100452altstep as_pcu_activate() runs on RAW_PCU_CT {
453 var PCUIF_send_data sd;
454 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_ACT_REQ(?, ?, ?))) -> value sd { repeat; }
455
456}
457
Harald Welte16e92f42019-03-02 00:03:44 +0100458testcase TC_pcuif_rach() runs on RAW_Test_CT {
459 f_sns_bringup_1c1u();
Harald Welte3b335832019-03-15 22:38:06 +0100460 activate(as_pcu_activate());
Harald Welte16e92f42019-03-02 00:03:44 +0100461
Vadim Yanitskiy36558d92019-11-17 02:23:51 +0700462 f_pcuif_tx(ts_PCUIF_RACH_IND(bts_nr:=0, trx_nr:=0, ts_nr:=0, ra:=23,
463 is_11bit:=0, burst_type:=BURST_TYPE_0,
Harald Welte16e92f42019-03-02 00:03:44 +0100464 fn:=42, arfcn:=871, qta:=0));
465 PCU.receive(t_SD_PCUIF(g_pcu_conn_id,
466 tr_PCUIF_DATA_REQ(bts_nr:=0, trx_nr:=0, ts_nr:=0, block_nr:=?, fn:=?,
467 sapi:=PCU_IF_SAPI_AGCH, data:=?)));
468 setverdict(pass);
469}
470
Harald Welte630d0e62019-02-22 23:26:40 +0100471
472
Harald Weltef7b74072019-02-20 20:48:50 +0100473control {
474 execute( TC_sns_po_size_success() );
475 execute( TC_sns_po_size_nack() );
476 execute( TC_sns_po_config_success() );
477 execute( TC_sns_po_config_nack() );
478 execute( TC_sns_so_config_success() );
Harald Welte630d0e62019-02-22 23:26:40 +0100479 execute( TC_sns_1c1u() );
Harald Welteecd159e2019-03-16 13:36:07 +0100480 execute( TC_sns_1c1u_separate() );
Harald Welte64d07312019-03-20 09:48:39 +0100481 execute( TC_sns_1c1u_so_bvc_reset() );
482 execute( TC_sns_1c1u_so_bvc_reset_too_early() );
Harald Welte630d0e62019-02-22 23:26:40 +0100483 execute( TC_sns_add() );
Alexander Couzens2a0ac802020-12-09 02:19:29 +0100484 execute( TC_sns_add_nack() );
Harald Welte630d0e62019-02-22 23:26:40 +0100485 execute( TC_sns_del() );
Harald Welte72099552019-02-23 15:09:22 +0100486 execute( TC_sns_chg_weight() );
Harald Welte16e92f42019-03-02 00:03:44 +0100487
488 execute( TC_pcuif_rach() );
Harald Weltef7b74072019-02-20 20:48:50 +0100489}
490
491}