blob: ea787611b350342e99e07b67dae5ac424c579865 [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) {
Alexander Couzens195c9e72020-10-26 23:09:16 +0100300 /* Expect BVC-RESET, but ignore it to prevent a race condition of BVC RESETs */
301 var template PDU_NS pdu := tr_NS_UNITDATA(t_SduCtrlB, 0, decmatch tr_BVC_RESET(?, 0, omit));
302 f_ns_exp(pdu);
303 /* SGSN originated BVC-RESET on an uninitialized signalling BVC */
Harald Weltee97e3af2020-10-09 14:56:54 +0200304 f_tx_bvc_reset_rx_ack(0, omit, omit);
Alexander Couzens195c9e72020-10-26 23:09:16 +0100305
306 /* Expect BVC-RESET PTP BVC, but ignore it to prevent a race condition of BVC RESETs */
307 pdu := tr_NS_UNITDATA(t_SduCtrlB, 0, decmatch tr_BVC_RESET(?, mp_gb_cfg.bvc[0].bvci, mp_gb_cfg.bvc[0].cell_id));
308 f_ns_exp(pdu);
309 /* SGSN originated BVC-RESET on an uninitialized PTP BVC */
Harald Weltee97e3af2020-10-09 14:56:54 +0200310 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 +0100311 } else {
Alexander Couzens195c9e72020-10-26 23:09:16 +0100312 /* Expect BVC-RESET for signaling BVCI=0 */
Harald Weltee97e3af2020-10-09 14:56:54 +0200313 as_rx_bvc_reset_tx_ack(0, omit, omit, oneshot := true);
Alexander Couzens195c9e72020-10-26 23:09:16 +0100314 /* Expect BVC-RESET from the PCU on PTP BVC */
Harald Weltee97e3af2020-10-09 14:56:54 +0200315 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 +0100316 }
Harald Welte630d0e62019-02-22 23:26:40 +0100317 /* Expect UNBLOCK for ptp BVCI on signaling NS-VC (idx==0) */
Harald Welte5339b2e2020-10-04 22:52:56 +0200318 as_rx_bvc_unblock_tx_ack(mp_gb_cfg.bvc[0].bvci, oneshot := true);
Harald Welte630d0e62019-02-22 23:26:40 +0100319
320 /* wait for one FLOW-CONTROL BVC and then ACK any further in the future. Flow
321 * control happens on the p-t-p BVCI and hence on index 1 */
Harald Welte5339b2e2020-10-04 22:52:56 +0200322 as_rx_bvc_fc_tx_ack(mp_gb_cfg.bvc[0].bvci, oneshot := true, idx := 1);
323 activate(as_rx_bvc_fc_tx_ack(mp_gb_cfg.bvc[0].bvci, idx := 1));
Harald Welte630d0e62019-02-22 23:26:40 +0100324}
325
326/* Test full IP-SNS bring-up with two NS-VCs, one sig-only and one user-only */
Harald Welteea3c7e92019-03-01 19:34:55 +0100327testcase TC_sns_1c1u() runs on RAW_Test_CT {
Harald Welte630d0e62019-02-22 23:26:40 +0100328 f_sns_bringup_1c1u();
329 setverdict(pass);
330}
331
Harald Welte64d07312019-03-20 09:48:39 +0100332private function f_sns_bringup_1c1u_separate(boolean sgsn_originated_reset := false) runs on RAW_Test_CT {
Harald Welteecd159e2019-03-16 13:36:07 +0100333 /* Activate two NS codec ports */
Alexander Couzens2beaa202020-09-11 20:08:41 +0200334 f_init_ns_codec(mp_nsconfig);
335 f_init_ns_codec(mp_nsconfig, 1);
336 f_init_ns_codec(mp_nsconfig, 2);
Harald Welteecd159e2019-03-16 13:36:07 +0100337 f_init_pcuif();
338 /* Perform Size + BSS-originated config */
339 f_incoming_sns_size();
340 f_incoming_sns_config();
341 /* perform SGSN-originated config using idx==0 for signalling and idx==1 for user traffic */
342 f_outgoing_sns_config_1c1u_separate();
343
344 /* wait for one ALIVE cycle, then ACK any further ALIVE in the background
345 * for both NS-VCs */
346 as_rx_alive_tx_ack(oneshot := true, idx := 1);
347 activate(as_rx_alive_tx_ack(idx := 1));
348 as_rx_alive_tx_ack(oneshot := true, idx := 2);
349 activate(as_rx_alive_tx_ack(idx := 2));
350 /* ensure there's no NS-ALIVE received on idx==0 */
351 f_ensure_no_ns(t_NS_ALIVE, idx := 0);
352
353 /* perform outgoing ALIVE procedure for both NS-VCs */
354 f_outgoing_ns_alive(1);
355 f_outgoing_ns_alive(2);
356 /* ensure there's no response to NS-ALIVE sent on idx==0 */
357 f_outgoing_ns_alive_no_ack(idx := 0);
358
Harald Welte64d07312019-03-20 09:48:39 +0100359 if (sgsn_originated_reset) {
Alexander Couzens195c9e72020-10-26 23:09:16 +0100360 /* Expect BVC-RESET, but ignore it to prevent a race condition of BVC RESETs */
361 var template PDU_NS pdu := tr_NS_UNITDATA(t_SduCtrlB, 0, decmatch tr_BVC_RESET(?, 0, omit));
362 f_ns_exp(pdu, idx := 1);
363 /* SGSN originated BVC-RESET on an uninitialized sign BVC */
Harald Weltee97e3af2020-10-09 14:56:54 +0200364 f_tx_bvc_reset_rx_ack(0, omit, omit, idx := 1);
Alexander Couzens195c9e72020-10-26 23:09:16 +0100365
366 /* Expect BVC-RESET PTP BVC, but ignore it to prevent a race condition of BVC RESETs */
367 pdu := tr_NS_UNITDATA(t_SduCtrlB, 0, decmatch tr_BVC_RESET(?, mp_gb_cfg.bvc[0].bvci, mp_gb_cfg.bvc[0].cell_id));
368 f_ns_exp(pdu, idx := 1);
Harald Weltee97e3af2020-10-09 14:56:54 +0200369 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 +0100370 } else {
Alexander Couzens195c9e72020-10-26 23:09:16 +0100371 /* Expect BVC-RESET for signaling BVCI=0 */
Harald Weltee97e3af2020-10-09 14:56:54 +0200372 as_rx_bvc_reset_tx_ack(0, omit, omit, oneshot := true, idx := 1);
Alexander Couzens195c9e72020-10-26 23:09:16 +0100373 /* Expect BVC-RESET from the PCU on PTP BVC */
Harald Weltee97e3af2020-10-09 14:56:54 +0200374 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 +0100375 }
Harald Welteecd159e2019-03-16 13:36:07 +0100376 /* Expect UNBLOCK for ptp BVCI on signaling NS-VC (idx==1) */
Harald Welte5339b2e2020-10-04 22:52:56 +0200377 as_rx_bvc_unblock_tx_ack(mp_gb_cfg.bvc[0].bvci, oneshot := true, idx := 1);
Harald Welteecd159e2019-03-16 13:36:07 +0100378
379 /* wait for one FLOW-CONTROL BVC and then ACK any further in the future. Flow
380 * control happens on the p-t-p BVCI and hence on index 1 */
Harald Welte5339b2e2020-10-04 22:52:56 +0200381 as_rx_bvc_fc_tx_ack(mp_gb_cfg.bvc[0].bvci, oneshot := true, idx := 2);
382 activate(as_rx_bvc_fc_tx_ack(mp_gb_cfg.bvc[0].bvci, idx := 2));
Harald Welteecd159e2019-03-16 13:36:07 +0100383}
384
385/* Test full IP-SNS bring-up with two NS-VCs, one sig-only and one user-only - and where
386 * the initial IP/port for the SNS procedure is *not* part of the NS-VCs later */
387testcase TC_sns_1c1u_separate() runs on RAW_Test_CT {
388 f_sns_bringup_1c1u_separate();
389 setverdict(pass);
390}
391
Harald Welte64d07312019-03-20 09:48:39 +0100392/* Test full IP-SNS bring-up with two NS-VCs, one sig-only and one user-only and use
393 * SGSN-originated BVC-RESET rather than BSS-originated */
394testcase TC_sns_1c1u_so_bvc_reset() runs on RAW_Test_CT {
395 f_sns_bringup_1c1u_separate(sgsn_originated_reset := true);
396 setverdict(pass);
397}
398
399/* Transmit BVC-RESET before NS-ALIVE of PCU was ACKed: expect no response */
400testcase TC_sns_1c1u_so_bvc_reset_too_early() runs on RAW_Test_CT {
401 /* Activate two NS codec ports */
Alexander Couzens2beaa202020-09-11 20:08:41 +0200402 f_init_ns_codec(mp_nsconfig);
403 f_init_ns_codec(mp_nsconfig, 1);
404 f_init_ns_codec(mp_nsconfig, 2);
Harald Welte64d07312019-03-20 09:48:39 +0100405 f_init_pcuif();
406 /* Perform Size + BSS-originated config */
407 f_incoming_sns_size();
408 f_incoming_sns_config();
409 /* perform SGSN-originated config using idx==0 for signalling and idx==1 for user traffic */
410 f_outgoing_sns_config_1c1u_separate();
411
412 /* DON'T ACK ANY INBOUND NS-ALIVE HERE! */
413
414 /* perform outgoing ALIVE procedure for both NS-VCs */
415 f_outgoing_ns_alive(1);
416 f_outgoing_ns_alive(2);
417 /* ensure there's no response to NS-ALIVE sent on idx==0 */
418 f_outgoing_ns_alive_no_ack(idx := 0);
419
420 /* Transmit BVC-RESET and expect no ACK*/
Harald Weltee97e3af2020-10-09 14:56:54 +0200421 f_tx_bvc_reset_rx_ack(0, omit, omit, idx := 1, exp_ack := false);
422 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 +0100423}
424
Harald Welte630d0e62019-02-22 23:26:40 +0100425/* Test adding new IP endpoints at runtime */
Harald Welteea3c7e92019-03-01 19:34:55 +0100426testcase TC_sns_add() runs on RAW_Test_CT {
Harald Welte630d0e62019-02-22 23:26:40 +0100427 f_sns_bringup_1c1u();
428
Alexander Couzens2373afc2020-12-09 02:19:49 +0100429 /* create another NS codec port on the tester side */
Alexander Couzens2beaa202020-09-11 20:08:41 +0200430 f_init_ns_codec(mp_nsconfig, 2);
Harald Welte630d0e62019-02-22 23:26:40 +0100431
432 f_outgoing_sns_add(idx_add := 2, w_sig := 0, w_user := 1, idx := 0);
433
434 /* wait for one ALIVE cycle, then ACK any further ALIVE in the background */
435 as_rx_alive_tx_ack(oneshot := true, idx := 2);
436 activate(as_rx_alive_tx_ack(idx := 2));
437
438 f_outgoing_ns_alive(2);
Harald Welte630d0e62019-02-22 23:26:40 +0100439 setverdict(pass);
440}
441
Alexander Couzens2a0ac802020-12-09 02:19:29 +0100442/* Test adding an already present IP endpoint at runtime */
443testcase TC_sns_add_nack() runs on RAW_Test_CT {
444 f_sns_bringup_1c1u();
445
446 f_outgoing_sns_add(idx_add := 0, w_sig := 0, w_user := 1, idx := 0, cause := NS_CAUSE_PROTOCOL_ERROR_UNSPEIFIED);
447 setverdict(pass);
448}
449
Harald Welte630d0e62019-02-22 23:26:40 +0100450/* Test deleting IP endpoints at runtime */
Harald Welteea3c7e92019-03-01 19:34:55 +0100451testcase TC_sns_del() runs on RAW_Test_CT {
Harald Welte630d0e62019-02-22 23:26:40 +0100452 f_sns_bringup_1c1u();
453
454 f_outgoing_sns_del(idx_del := 1, w_sig := 0, w_user := 1, idx := 0);
455 /* FIXME: ensure we don't receive anything on just-deleted NS-VC anymore */
456 setverdict(pass);
457}
458
Harald Welte72099552019-02-23 15:09:22 +0100459/* Test changing weights at runtime */
Harald Welteea3c7e92019-03-01 19:34:55 +0100460testcase TC_sns_chg_weight() runs on RAW_Test_CT {
Harald Welte72099552019-02-23 15:09:22 +0100461 f_sns_bringup_1c1u();
462
463 /* change w_user from 1 to 200 */
464 f_outgoing_sns_chg_weight(idx_chg := 1, w_sig := 0, w_user := 200, idx := 0);
465 setverdict(pass);
466}
467
Harald Welte16e92f42019-03-02 00:03:44 +0100468import from PCUIF_Types all;
469import from PCUIF_CodecPort all;
470
Harald Welte3b335832019-03-15 22:38:06 +0100471altstep as_pcu_activate() runs on RAW_PCU_CT {
472 var PCUIF_send_data sd;
473 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_ACT_REQ(?, ?, ?))) -> value sd { repeat; }
474
475}
476
Harald Welte16e92f42019-03-02 00:03:44 +0100477testcase TC_pcuif_rach() runs on RAW_Test_CT {
478 f_sns_bringup_1c1u();
Harald Welte3b335832019-03-15 22:38:06 +0100479 activate(as_pcu_activate());
Harald Welte16e92f42019-03-02 00:03:44 +0100480
Vadim Yanitskiy36558d92019-11-17 02:23:51 +0700481 f_pcuif_tx(ts_PCUIF_RACH_IND(bts_nr:=0, trx_nr:=0, ts_nr:=0, ra:=23,
482 is_11bit:=0, burst_type:=BURST_TYPE_0,
Harald Welte16e92f42019-03-02 00:03:44 +0100483 fn:=42, arfcn:=871, qta:=0));
484 PCU.receive(t_SD_PCUIF(g_pcu_conn_id,
485 tr_PCUIF_DATA_REQ(bts_nr:=0, trx_nr:=0, ts_nr:=0, block_nr:=?, fn:=?,
486 sapi:=PCU_IF_SAPI_AGCH, data:=?)));
487 setverdict(pass);
488}
489
Harald Welte630d0e62019-02-22 23:26:40 +0100490
491
Harald Weltef7b74072019-02-20 20:48:50 +0100492control {
493 execute( TC_sns_po_size_success() );
494 execute( TC_sns_po_size_nack() );
495 execute( TC_sns_po_config_success() );
496 execute( TC_sns_po_config_nack() );
497 execute( TC_sns_so_config_success() );
Harald Welte630d0e62019-02-22 23:26:40 +0100498 execute( TC_sns_1c1u() );
Harald Welteecd159e2019-03-16 13:36:07 +0100499 execute( TC_sns_1c1u_separate() );
Harald Welte64d07312019-03-20 09:48:39 +0100500 execute( TC_sns_1c1u_so_bvc_reset() );
501 execute( TC_sns_1c1u_so_bvc_reset_too_early() );
Harald Welte630d0e62019-02-22 23:26:40 +0100502 execute( TC_sns_add() );
Alexander Couzens2a0ac802020-12-09 02:19:29 +0100503 execute( TC_sns_add_nack() );
Harald Welte630d0e62019-02-22 23:26:40 +0100504 execute( TC_sns_del() );
Harald Welte72099552019-02-23 15:09:22 +0100505 execute( TC_sns_chg_weight() );
Harald Welte16e92f42019-03-02 00:03:44 +0100506
507 execute( TC_pcuif_rach() );
Harald Weltef7b74072019-02-20 20:48:50 +0100508}
509
510}