blob: 4fca26eff3569fd1b0120771382f994403917d94 [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_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 Couzensc3165722021-01-11 02:51:45 +010030 var NSVCConfiguration nsvc_cfg := g_nsconfig.nsvc[idx];
Alexander Couzens7b1e44f2020-08-25 23:33:17 +020031
Harald Welte90f19742020-11-06 19:34:40 +010032 if (nsvc_cfg.provider.ip.address_family == AF_INET) {
Alexander Couzens7b1e44f2020-08-25 23:33:17 +020033 /* expect one single SNS-SIZE with RESET flag; 4x v4 EP; no v6 EP */
Alexander Couzensc3165722021-01-11 02:51:45 +010034 rx := f_ns_exp(tr_SNS_SIZE(g_nsconfig.nsei, rst_flag := true, max_nsvcs := 8,
Alexander Couzens7b1e44f2020-08-25 23:33:17 +020035 num_v4 := 4, num_v6 := omit), idx);
36 } else {
37 /* expect one single SNS-SIZE with RESET flag; no v4 EP; 4x v6 EP */
Alexander Couzensc3165722021-01-11 02:51:45 +010038 rx := f_ns_exp(tr_SNS_SIZE(g_nsconfig.nsei, rst_flag := true, max_nsvcs := 8,
Alexander Couzens7b1e44f2020-08-25 23:33:17 +020039 num_v4 := omit, num_v6 := 4), idx);
40 }
Alexander Couzensc3165722021-01-11 02:51:45 +010041 NSCP[idx].send(ts_SNS_SIZE_ACK(g_nsconfig.nsei, cause));
Harald Weltec4d7beb2019-02-21 18:21:01 +010042}
43
44/* perform outbound SNS-SIZE procedure */
Harald Weltebf768242019-02-21 22:19:21 +010045function f_outgoing_sns_size(template (omit) NsCause cause := omit, integer idx:= 0)
46runs on RAW_NS_CT {
Harald Welteb63c3a12019-02-22 23:27:12 +010047 log("f_outgoing_sns_size(idx=", idx, ")");
Harald Weltec4d7beb2019-02-21 18:21:01 +010048 var PDU_NS rx;
Alexander Couzensc3165722021-01-11 02:51:45 +010049 var NSVCConfiguration nsvc_cfg := g_nsconfig.nsvc[idx];
Harald Welte90f19742020-11-06 19:34:40 +010050
51 if (nsvc_cfg.provider.ip.address_family == AF_INET) {
Alexander Couzensc3165722021-01-11 02:51:45 +010052 NSCP[idx].send(ts_SNS_SIZE(g_nsconfig.nsei, rst_flag := true, max_nsvcs := 1,
Alexander Couzens7b1e44f2020-08-25 23:33:17 +020053 num_v4 := 1, num_v6 := omit)
Alexander Couzensc3165722021-01-11 02:51:45 +010054 );
Alexander Couzens7b1e44f2020-08-25 23:33:17 +020055 } else {
Alexander Couzensc3165722021-01-11 02:51:45 +010056 NSCP[idx].send(ts_SNS_SIZE(g_nsconfig.nsei, rst_flag := true, max_nsvcs := 1,
Alexander Couzens7b1e44f2020-08-25 23:33:17 +020057 num_v4 := omit, num_v6 := 1)
Alexander Couzensc3165722021-01-11 02:51:45 +010058 );
Alexander Couzens7b1e44f2020-08-25 23:33:17 +020059 }
60 /* expect one single SNS-SIZE with RESET flag; 4x v4 EP; no v6 EP */
Alexander Couzensc3165722021-01-11 02:51:45 +010061 rx := f_ns_exp(tr_SNS_SIZE_ACK(g_nsconfig.nsei, cause), idx);
Harald Weltec4d7beb2019-02-21 18:21:01 +010062}
63
64/* perform inbound SNS-CONFIG procedure */
Harald Weltebf768242019-02-21 22:19:21 +010065function f_incoming_sns_config(template (omit) NsCause cause := omit, integer idx := 0)
66runs on RAW_NS_CT {
Harald Welteb63c3a12019-02-22 23:27:12 +010067 log("f_incoming_sns_config(idx=", idx, ")");
Harald Weltec4d7beb2019-02-21 18:21:01 +010068 var PDU_NS rx;
Alexander Couzensc3165722021-01-11 02:51:45 +010069 var NSVCConfiguration nsvc_cfg := g_nsconfig.nsvc[idx];
Alexander Couzens7b1e44f2020-08-25 23:33:17 +020070
Harald Welte90f19742020-11-06 19:34:40 +010071 if (nsvc_cfg.provider.ip.address_family == AF_INET) {
72 var template IP4_Elements v4_elem := { tr_SNS_IPv4(nsvc_cfg.provider.ip.remote_ip,
73 nsvc_cfg.provider.ip.remote_udp_port) };
Alexander Couzensc3165722021-01-11 02:51:45 +010074 rx := f_ns_exp(tr_SNS_CONFIG(g_nsconfig.nsei, end_flag := true, v4 := v4_elem), idx);
Alexander Couzens7b1e44f2020-08-25 23:33:17 +020075 } else {
Harald Welte90f19742020-11-06 19:34:40 +010076 var template IP6_Elements v6_elem := { tr_SNS_IPv6(nsvc_cfg.provider.ip.remote_ip,
77 nsvc_cfg.provider.ip.remote_udp_port) };
Alexander Couzensc3165722021-01-11 02:51:45 +010078 rx := f_ns_exp(tr_SNS_CONFIG(g_nsconfig.nsei, end_flag := true, v6 := v6_elem), idx);
Alexander Couzens7b1e44f2020-08-25 23:33:17 +020079 }
Alexander Couzensc3165722021-01-11 02:51:45 +010080 NSCP[idx].send(ts_SNS_CONFIG_ACK(g_nsconfig.nsei, cause));
Harald Weltec4d7beb2019-02-21 18:21:01 +010081}
82
83/* perform outbound SNS-CONFIG procedure */
Harald Weltebf768242019-02-21 22:19:21 +010084function f_outgoing_sns_config(template (omit) NsCause cause := omit, integer idx := 0)
85runs on RAW_NS_CT {
Harald Welteb63c3a12019-02-22 23:27:12 +010086 log("f_outgoing_sns_config(idx=", idx, ")");
Harald Weltec4d7beb2019-02-21 18:21:01 +010087 var PDU_NS rx;
Alexander Couzensc3165722021-01-11 02:51:45 +010088 var NSVCConfiguration nsvc_cfg := g_nsconfig.nsvc[idx];
Harald Welte90f19742020-11-06 19:34:40 +010089
90 if (nsvc_cfg.provider.ip.address_family == AF_INET) {
91 var template (omit) IP4_Elements v4 := { ts_SNS_IPv4(nsvc_cfg.provider.ip.local_ip,
92 nsvc_cfg.provider.ip.local_udp_port) }
Alexander Couzensc3165722021-01-11 02:51:45 +010093 NSCP[idx].send(ts_SNS_CONFIG(g_nsconfig.nsei, true, v4));
Alexander Couzens7b1e44f2020-08-25 23:33:17 +020094 } else {
Harald Welte90f19742020-11-06 19:34:40 +010095 var template (omit) IP6_Elements v6 := { ts_SNS_IPv6(nsvc_cfg.provider.ip.local_ip,
96 nsvc_cfg.provider.ip.local_udp_port) }
Alexander Couzensc3165722021-01-11 02:51:45 +010097 NSCP[idx].send(ts_SNS_CONFIG(g_nsconfig.nsei, true, omit, v6));
Alexander Couzens7b1e44f2020-08-25 23:33:17 +020098 }
Alexander Couzensc3165722021-01-11 02:51:45 +010099 rx := f_ns_exp(tr_SNS_CONFIG_ACK(g_nsconfig.nsei, cause), idx);
Harald Weltec4d7beb2019-02-21 18:21:01 +0100100}
101
Harald Weltebf768242019-02-21 22:19:21 +0100102/* perform outbound SNS-CONFIG procedure (separate endpoints: 1 for control, 1 for user */
103function f_outgoing_sns_config_1c1u(template (omit) NsCause cause := omit, integer idx := 0)
104runs on RAW_NS_CT {
Harald Welteb63c3a12019-02-22 23:27:12 +0100105 log("f_outgoing_sns_config_1c1u(idx=", idx, ")");
Harald Weltebf768242019-02-21 22:19:21 +0100106 var PDU_NS rx;
Harald Welte90f19742020-11-06 19:34:40 +0100107
108 if (mp_nsconfig.nsvc[0].provider.ip.address_family == AF_INET) {
Alexander Couzensc3165722021-01-11 02:51:45 +0100109 var template (omit) IP4_Elements v4 := { ts_SNS_IPv4(g_nsconfig.nsvc[0].provider.ip.local_ip,
110 g_nsconfig.nsvc[0].provider.ip.local_udp_port, 1, 0),
111 ts_SNS_IPv4(g_nsconfig.nsvc[1].provider.ip.local_ip,
112 g_nsconfig.nsvc[1].provider.ip.local_udp_port, 0, 1) };
113 NSCP[idx].send(ts_SNS_CONFIG(g_nsconfig.nsei, true, v4));
Alexander Couzens7b1e44f2020-08-25 23:33:17 +0200114 } else {
Alexander Couzensc3165722021-01-11 02:51:45 +0100115 var template (omit) IP6_Elements v6 := { ts_SNS_IPv6(g_nsconfig.nsvc[0].provider.ip.local_ip,
116 g_nsconfig.nsvc[0].provider.ip.local_udp_port, 1, 0),
117 ts_SNS_IPv6(g_nsconfig.nsvc[1].provider.ip.local_ip,
118 g_nsconfig.nsvc[1].provider.ip.local_udp_port, 0, 1) };
119 NSCP[idx].send(ts_SNS_CONFIG(g_nsconfig.nsei, true, omit, v6));
Alexander Couzens7b1e44f2020-08-25 23:33:17 +0200120 }
Alexander Couzensc3165722021-01-11 02:51:45 +0100121 rx := f_ns_exp(tr_SNS_CONFIG_ACK(g_nsconfig.nsei, cause), idx);
Harald Weltebf768242019-02-21 22:19:21 +0100122}
123
Harald Welteecd159e2019-03-16 13:36:07 +0100124/* perform outbound SNS-CONFIG procedure (separate endpoints: 1 for control, 1 for user */
125function f_outgoing_sns_config_1c1u_separate(template (omit) NsCause cause := omit, integer idx := 0)
126runs on RAW_NS_CT {
127 log("f_outgoing_sns_config_1c1u_separate(idx=", idx, ")");
128 var PDU_NS rx;
Harald Welte90f19742020-11-06 19:34:40 +0100129 if (mp_nsconfig.nsvc[0].provider.ip.address_family == AF_INET) {
Alexander Couzensc3165722021-01-11 02:51:45 +0100130 var template (omit) IP4_Elements v4 := { ts_SNS_IPv4(g_nsconfig.nsvc[1].provider.ip.local_ip,
131 g_nsconfig.nsvc[1].provider.ip.local_udp_port, 1, 0),
132 ts_SNS_IPv4(g_nsconfig.nsvc[2].provider.ip.local_ip,
133 g_nsconfig.nsvc[2].provider.ip.local_udp_port, 0, 1) };
134 NSCP[idx].send(ts_SNS_CONFIG(g_nsconfig.nsei, true, v4));
Alexander Couzens7b1e44f2020-08-25 23:33:17 +0200135 } else {
Alexander Couzensc3165722021-01-11 02:51:45 +0100136 var template (omit) IP6_Elements v6 := { ts_SNS_IPv6(g_nsconfig.nsvc[1].provider.ip.local_ip,
137 g_nsconfig.nsvc[1].provider.ip.local_udp_port, 1, 0),
138 ts_SNS_IPv6(g_nsconfig.nsvc[2].provider.ip.local_ip,
139 g_nsconfig.nsvc[2].provider.ip.local_udp_port, 0, 1) };
140 NSCP[idx].send(ts_SNS_CONFIG(g_nsconfig.nsei, true, omit, v6));
Alexander Couzens7b1e44f2020-08-25 23:33:17 +0200141 }
Alexander Couzensc3165722021-01-11 02:51:45 +0100142 rx := f_ns_exp(tr_SNS_CONFIG_ACK(g_nsconfig.nsei, cause), idx);
Harald Welteecd159e2019-03-16 13:36:07 +0100143}
144
Alexander Couzens2a0ac802020-12-09 02:19:29 +0100145function 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 +0100146runs on RAW_NS_CT {
147 log("f_outgoing_sns_add(idx_add=", idx_add, ")");
148 var PDU_NS rx;
Alexander Couzensc3165722021-01-11 02:51:45 +0100149 var NSVCConfiguration nsvc_cfg := g_nsconfig.nsvc[idx_add];
Harald Welte90f19742020-11-06 19:34:40 +0100150 if (nsvc_cfg.provider.ip.address_family == AF_INET) {
151 var template (omit) IP4_Elements v4 := { ts_SNS_IPv4(nsvc_cfg.provider.ip.local_ip,
152 nsvc_cfg.provider.ip.local_udp_port,
Alexander Couzens7b1e44f2020-08-25 23:33:17 +0200153 w_sig, w_user) };
Alexander Couzensc3165722021-01-11 02:51:45 +0100154 NSCP[idx].send(ts_SNS_ADD(g_nsconfig.nsei, 23, v4));
155 rx := f_ns_exp(tr_SNS_ACK(g_nsconfig.nsei, 23, cause, v4));
Alexander Couzens7b1e44f2020-08-25 23:33:17 +0200156 } else {
Harald Welte90f19742020-11-06 19:34:40 +0100157 var template (omit) IP6_Elements v6 := { ts_SNS_IPv6(nsvc_cfg.provider.ip.local_ip,
158 nsvc_cfg.provider.ip.local_udp_port,
Alexander Couzens7b1e44f2020-08-25 23:33:17 +0200159 w_sig, w_user) };
Alexander Couzensc3165722021-01-11 02:51:45 +0100160 NSCP[idx].send(ts_SNS_ADD(g_nsconfig.nsei, 23, omit, v6));
161 rx := f_ns_exp(tr_SNS_ACK(g_nsconfig.nsei, 23, cause, omit, v6));
Alexander Couzens7b1e44f2020-08-25 23:33:17 +0200162 }
Harald Welte630d0e62019-02-22 23:26:40 +0100163}
164
165function f_outgoing_sns_del(integer idx_del, uint8_t w_sig := 1, uint8_t w_user := 1, integer idx := 0)
166runs on RAW_NS_CT {
167 log("f_outgoing_sns_del(idx_del=", idx_del, ")");
168 var PDU_NS rx;
Alexander Couzensc3165722021-01-11 02:51:45 +0100169 var NSVCConfiguration nsvc_cfg := g_nsconfig.nsvc[idx_del];
Harald Welte90f19742020-11-06 19:34:40 +0100170 if (nsvc_cfg.provider.ip.address_family == AF_INET) {
171 var template (omit) IP4_Elements v4 := { ts_SNS_IPv4(nsvc_cfg.provider.ip.local_ip,
172 nsvc_cfg.provider.ip.local_udp_port,
Alexander Couzens7b1e44f2020-08-25 23:33:17 +0200173 w_sig, w_user) };
Alexander Couzensc3165722021-01-11 02:51:45 +0100174 NSCP[idx].send(ts_SNS_DEL(g_nsconfig.nsei, 24, omit, v4));
175 rx := f_ns_exp(tr_SNS_ACK(g_nsconfig.nsei, 24, omit, v4));
Alexander Couzens7b1e44f2020-08-25 23:33:17 +0200176 } else {
Harald Welte90f19742020-11-06 19:34:40 +0100177 var template (omit) IP6_Elements v6 := { ts_SNS_IPv6(nsvc_cfg.provider.ip.local_ip,
178 nsvc_cfg.provider.ip.local_udp_port,
Alexander Couzens7b1e44f2020-08-25 23:33:17 +0200179 w_sig, w_user) };
Alexander Couzensc3165722021-01-11 02:51:45 +0100180 NSCP[idx].send(ts_SNS_DEL(g_nsconfig.nsei, 24, omit, omit, v6));
181 rx := f_ns_exp(tr_SNS_ACK(g_nsconfig.nsei, 24, omit, omit, v6));
Alexander Couzens7b1e44f2020-08-25 23:33:17 +0200182 }
Harald Welte630d0e62019-02-22 23:26:40 +0100183}
184
Harald Welte72099552019-02-23 15:09:22 +0100185function f_outgoing_sns_chg_weight(integer idx_chg, uint8_t w_sig, uint8_t w_user, integer idx := 0)
186runs on RAW_NS_CT {
187 log("f_outgoing_sns_chg_weight(idx_chg=", idx_chg, ")");
188 var PDU_NS rx;
Alexander Couzensc3165722021-01-11 02:51:45 +0100189 var NSVCConfiguration nsvc_cfg := g_nsconfig.nsvc[idx_chg];
Harald Welte90f19742020-11-06 19:34:40 +0100190 if (nsvc_cfg.provider.ip.address_family == AF_INET) {
191 var template (omit) IP4_Elements v4 := { ts_SNS_IPv4(nsvc_cfg.provider.ip.local_ip,
192 nsvc_cfg.provider.ip.local_udp_port,
Alexander Couzens7b1e44f2020-08-25 23:33:17 +0200193 w_sig, w_user) };
Alexander Couzensc3165722021-01-11 02:51:45 +0100194 NSCP[idx].send(ts_SNS_CHG_WEIGHT(g_nsconfig.nsei, 25, v4));
195 rx := f_ns_exp(tr_SNS_ACK(g_nsconfig.nsei, 25, omit, v4));
Alexander Couzens7b1e44f2020-08-25 23:33:17 +0200196 } else {
Harald Welte90f19742020-11-06 19:34:40 +0100197 var template (omit) IP6_Elements v6 := { ts_SNS_IPv6(nsvc_cfg.provider.ip.local_ip,
198 nsvc_cfg.provider.ip.local_udp_port,
Alexander Couzens7b1e44f2020-08-25 23:33:17 +0200199 w_sig, w_user) };
Alexander Couzensc3165722021-01-11 02:51:45 +0100200 NSCP[idx].send(ts_SNS_CHG_WEIGHT(g_nsconfig.nsei, 25, omit, v6));
201 rx := f_ns_exp(tr_SNS_ACK(g_nsconfig.nsei, 25, omit, omit, v6));
Alexander Couzens7b1e44f2020-08-25 23:33:17 +0200202 }
Harald Welte72099552019-02-23 15:09:22 +0100203}
204
205
206
Harald Welte630d0e62019-02-22 23:26:40 +0100207
Harald Weltebf768242019-02-21 22:19:21 +0100208
Harald Weltef7b74072019-02-20 20:48:50 +0100209/* PCU-originated SNS-SIZE: successful case */
Harald Welteea3c7e92019-03-01 19:34:55 +0100210testcase TC_sns_po_size_success() 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();
214 f_sleep(1.0);
215 setverdict(pass);
Alexander Couzensc3165722021-01-11 02:51:45 +0100216 f_clean_ns_codec();
Harald Weltef7b74072019-02-20 20:48:50 +0100217}
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);
Alexander Couzensc3165722021-01-11 02:51:45 +0100228 f_clean_ns_codec();
Harald Weltef7b74072019-02-20 20:48:50 +0100229}
230
231/* PCU-originated SNS-CONFIG: successful case */
Harald Welteea3c7e92019-03-01 19:34:55 +0100232testcase TC_sns_po_config_success() runs on RAW_Test_CT {
Alexander Couzens2beaa202020-09-11 20:08:41 +0200233 f_init_ns_codec(mp_nsconfig);
Harald Weltef7b74072019-02-20 20:48:50 +0100234 f_init_pcuif();
235 f_incoming_sns_size();
236 f_incoming_sns_config();
237 f_sleep(1.0);
238 setverdict(pass);
Alexander Couzensc3165722021-01-11 02:51:45 +0100239 f_clean_ns_codec();
Harald Weltef7b74072019-02-20 20:48:50 +0100240}
241
242/* PCU-originated SNS-CONFIG: successful case */
Harald Welteea3c7e92019-03-01 19:34:55 +0100243testcase TC_sns_po_config_nack() 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(NS_CAUSE_PROTOCOL_ERROR_UNSPEIFIED);
248 /* FIXME: ensure we get re-transmitted SNS-CONFIG attempts */
249 f_sleep(10.0);
250 setverdict(pass);
Alexander Couzensc3165722021-01-11 02:51:45 +0100251 f_clean_ns_codec();
Harald Weltef7b74072019-02-20 20:48:50 +0100252}
253
254
255/* SGSN-originated SNS-SIZE: successful case */
Harald Welteea3c7e92019-03-01 19:34:55 +0100256testcase TC_sns_so_config_success() runs on RAW_Test_CT {
Alexander Couzens2beaa202020-09-11 20:08:41 +0200257 f_init_ns_codec(mp_nsconfig);
Harald Weltef7b74072019-02-20 20:48:50 +0100258 f_init_pcuif();
259 f_incoming_sns_size();
260 f_incoming_sns_config();
261 f_outgoing_sns_config();
262
263 /* wait for one ALIVE cycle, then ACK any further ALIVE in the background */
264 as_rx_alive_tx_ack(oneshot := true);
265 activate(as_rx_alive_tx_ack());
266
267 f_outgoing_ns_alive();
268
269 /* Expect BVC-RESET for signaling (0) and ptp BVCI */
Harald Weltee97e3af2020-10-09 14:56:54 +0200270 as_rx_bvc_reset_tx_ack(0, omit, omit, oneshot := true);
271 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 +0200272 as_rx_bvc_unblock_tx_ack(mp_gb_cfg.bvc[0].bvci, oneshot := true);
Harald Weltef7b74072019-02-20 20:48:50 +0100273
274 /* wait for one FLOW-CONTROL BVC and then ACK any further in the future */
Harald Welte5339b2e2020-10-04 22:52:56 +0200275 as_rx_bvc_fc_tx_ack(mp_gb_cfg.bvc[0].bvci, oneshot := true);
276 activate(as_rx_bvc_fc_tx_ack(mp_gb_cfg.bvc[0].bvci));
Harald Weltef7b74072019-02-20 20:48:50 +0100277 setverdict(pass);
Alexander Couzensc3165722021-01-11 02:51:45 +0100278 f_clean_ns_codec();
Harald Weltef7b74072019-02-20 20:48:50 +0100279}
280
Harald Welte64d07312019-03-20 09:48:39 +0100281private function f_sns_bringup_1c1u(boolean sgsn_originated_reset := false) runs on RAW_Test_CT {
Harald Welte630d0e62019-02-22 23:26:40 +0100282 /* Activate two NS codec ports */
Alexander Couzens2beaa202020-09-11 20:08:41 +0200283 f_init_ns_codec(mp_nsconfig);
284 f_init_ns_codec(mp_nsconfig, 1);
Harald Welte630d0e62019-02-22 23:26:40 +0100285 f_init_pcuif();
286 /* Perform Size + BSS-originated config */
287 f_incoming_sns_size();
288 f_incoming_sns_config();
289 /* perform SGSN-originated config using idx==0 for signalling and idx==1 for user traffic */
290 f_outgoing_sns_config_1c1u();
291
292 /* wait for one ALIVE cycle, then ACK any further ALIVE in the background
293 * for both NS-VCs */
294 as_rx_alive_tx_ack(oneshot := true, idx := 0);
295 activate(as_rx_alive_tx_ack(idx := 0));
296 as_rx_alive_tx_ack(oneshot := true, idx := 1);
297 activate(as_rx_alive_tx_ack(idx := 1));
298
299 /* perform outgoing ALIVE procedure for both NS-VCs */
300 f_outgoing_ns_alive(0);
301 f_outgoing_ns_alive(1);
302
Harald Welte64d07312019-03-20 09:48:39 +0100303 if (sgsn_originated_reset) {
Alexander Couzens195c9e72020-10-26 23:09:16 +0100304 /* Expect BVC-RESET, but ignore it to prevent a race condition of BVC RESETs */
305 var template PDU_NS pdu := tr_NS_UNITDATA(t_SduCtrlB, 0, decmatch tr_BVC_RESET(?, 0, omit));
306 f_ns_exp(pdu);
307 /* SGSN originated BVC-RESET on an uninitialized signalling BVC */
Harald Weltee97e3af2020-10-09 14:56:54 +0200308 f_tx_bvc_reset_rx_ack(0, omit, omit);
Alexander Couzens195c9e72020-10-26 23:09:16 +0100309
310 /* Expect BVC-RESET PTP BVC, but ignore it to prevent a race condition of BVC RESETs */
311 pdu := tr_NS_UNITDATA(t_SduCtrlB, 0, decmatch tr_BVC_RESET(?, mp_gb_cfg.bvc[0].bvci, mp_gb_cfg.bvc[0].cell_id));
312 f_ns_exp(pdu);
313 /* SGSN originated BVC-RESET on an uninitialized PTP BVC */
Harald Weltee97e3af2020-10-09 14:56:54 +0200314 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 +0100315 } else {
Alexander Couzens195c9e72020-10-26 23:09:16 +0100316 /* Expect BVC-RESET for signaling BVCI=0 */
Harald Weltee97e3af2020-10-09 14:56:54 +0200317 as_rx_bvc_reset_tx_ack(0, omit, omit, oneshot := true);
Alexander Couzens195c9e72020-10-26 23:09:16 +0100318 /* Expect BVC-RESET from the PCU on PTP BVC */
Harald Weltee97e3af2020-10-09 14:56:54 +0200319 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 +0100320 }
Harald Welte630d0e62019-02-22 23:26:40 +0100321 /* Expect UNBLOCK for ptp BVCI on signaling NS-VC (idx==0) */
Harald Welte5339b2e2020-10-04 22:52:56 +0200322 as_rx_bvc_unblock_tx_ack(mp_gb_cfg.bvc[0].bvci, oneshot := true);
Harald Welte630d0e62019-02-22 23:26:40 +0100323
324 /* wait for one FLOW-CONTROL BVC and then ACK any further in the future. Flow
325 * control happens on the p-t-p BVCI and hence on index 1 */
Harald Welte5339b2e2020-10-04 22:52:56 +0200326 as_rx_bvc_fc_tx_ack(mp_gb_cfg.bvc[0].bvci, oneshot := true, idx := 1);
327 activate(as_rx_bvc_fc_tx_ack(mp_gb_cfg.bvc[0].bvci, idx := 1));
Harald Welte630d0e62019-02-22 23:26:40 +0100328}
329
330/* Test full IP-SNS bring-up with two NS-VCs, one sig-only and one user-only */
Harald Welteea3c7e92019-03-01 19:34:55 +0100331testcase TC_sns_1c1u() runs on RAW_Test_CT {
Harald Welte630d0e62019-02-22 23:26:40 +0100332 f_sns_bringup_1c1u();
333 setverdict(pass);
Alexander Couzensc3165722021-01-11 02:51:45 +0100334 f_clean_ns_codec();
Harald Welte630d0e62019-02-22 23:26:40 +0100335}
336
Harald Welte64d07312019-03-20 09:48:39 +0100337private function f_sns_bringup_1c1u_separate(boolean sgsn_originated_reset := false) runs on RAW_Test_CT {
Harald Welteecd159e2019-03-16 13:36:07 +0100338 /* Activate two NS codec ports */
Alexander Couzens2beaa202020-09-11 20:08:41 +0200339 f_init_ns_codec(mp_nsconfig);
340 f_init_ns_codec(mp_nsconfig, 1);
341 f_init_ns_codec(mp_nsconfig, 2);
Harald Welteecd159e2019-03-16 13:36:07 +0100342 f_init_pcuif();
343 /* Perform Size + BSS-originated config */
344 f_incoming_sns_size();
345 f_incoming_sns_config();
346 /* perform SGSN-originated config using idx==0 for signalling and idx==1 for user traffic */
347 f_outgoing_sns_config_1c1u_separate();
348
349 /* wait for one ALIVE cycle, then ACK any further ALIVE in the background
350 * for both NS-VCs */
351 as_rx_alive_tx_ack(oneshot := true, idx := 1);
352 activate(as_rx_alive_tx_ack(idx := 1));
353 as_rx_alive_tx_ack(oneshot := true, idx := 2);
354 activate(as_rx_alive_tx_ack(idx := 2));
355 /* ensure there's no NS-ALIVE received on idx==0 */
356 f_ensure_no_ns(t_NS_ALIVE, idx := 0);
357
358 /* perform outgoing ALIVE procedure for both NS-VCs */
359 f_outgoing_ns_alive(1);
360 f_outgoing_ns_alive(2);
361 /* ensure there's no response to NS-ALIVE sent on idx==0 */
362 f_outgoing_ns_alive_no_ack(idx := 0);
363
Harald Welte64d07312019-03-20 09:48:39 +0100364 if (sgsn_originated_reset) {
Alexander Couzens195c9e72020-10-26 23:09:16 +0100365 /* Expect BVC-RESET, but ignore it to prevent a race condition of BVC RESETs */
366 var template PDU_NS pdu := tr_NS_UNITDATA(t_SduCtrlB, 0, decmatch tr_BVC_RESET(?, 0, omit));
367 f_ns_exp(pdu, idx := 1);
368 /* SGSN originated BVC-RESET on an uninitialized sign BVC */
Harald Weltee97e3af2020-10-09 14:56:54 +0200369 f_tx_bvc_reset_rx_ack(0, omit, omit, idx := 1);
Alexander Couzens195c9e72020-10-26 23:09:16 +0100370
371 /* Expect BVC-RESET PTP BVC, but ignore it to prevent a race condition of BVC RESETs */
372 pdu := tr_NS_UNITDATA(t_SduCtrlB, 0, decmatch tr_BVC_RESET(?, mp_gb_cfg.bvc[0].bvci, mp_gb_cfg.bvc[0].cell_id));
373 f_ns_exp(pdu, idx := 1);
Harald Weltee97e3af2020-10-09 14:56:54 +0200374 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 +0100375 } else {
Alexander Couzens195c9e72020-10-26 23:09:16 +0100376 /* Expect BVC-RESET for signaling BVCI=0 */
Harald Weltee97e3af2020-10-09 14:56:54 +0200377 as_rx_bvc_reset_tx_ack(0, omit, omit, oneshot := true, idx := 1);
Alexander Couzens195c9e72020-10-26 23:09:16 +0100378 /* Expect BVC-RESET from the PCU on PTP BVC */
Harald Weltee97e3af2020-10-09 14:56:54 +0200379 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 +0100380 }
Harald Welteecd159e2019-03-16 13:36:07 +0100381 /* Expect UNBLOCK for ptp BVCI on signaling NS-VC (idx==1) */
Harald Welte5339b2e2020-10-04 22:52:56 +0200382 as_rx_bvc_unblock_tx_ack(mp_gb_cfg.bvc[0].bvci, oneshot := true, idx := 1);
Harald Welteecd159e2019-03-16 13:36:07 +0100383
384 /* wait for one FLOW-CONTROL BVC and then ACK any further in the future. Flow
385 * control happens on the p-t-p BVCI and hence on index 1 */
Harald Welte5339b2e2020-10-04 22:52:56 +0200386 as_rx_bvc_fc_tx_ack(mp_gb_cfg.bvc[0].bvci, oneshot := true, idx := 2);
387 activate(as_rx_bvc_fc_tx_ack(mp_gb_cfg.bvc[0].bvci, idx := 2));
Harald Welteecd159e2019-03-16 13:36:07 +0100388}
389
390/* Test full IP-SNS bring-up with two NS-VCs, one sig-only and one user-only - and where
391 * the initial IP/port for the SNS procedure is *not* part of the NS-VCs later */
392testcase TC_sns_1c1u_separate() runs on RAW_Test_CT {
393 f_sns_bringup_1c1u_separate();
394 setverdict(pass);
Alexander Couzensc3165722021-01-11 02:51:45 +0100395 f_clean_ns_codec();
Harald Welteecd159e2019-03-16 13:36:07 +0100396}
397
Harald Welte64d07312019-03-20 09:48:39 +0100398/* Test full IP-SNS bring-up with two NS-VCs, one sig-only and one user-only and use
399 * SGSN-originated BVC-RESET rather than BSS-originated */
400testcase TC_sns_1c1u_so_bvc_reset() runs on RAW_Test_CT {
401 f_sns_bringup_1c1u_separate(sgsn_originated_reset := true);
402 setverdict(pass);
Alexander Couzensc3165722021-01-11 02:51:45 +0100403 f_clean_ns_codec();
Harald Welte64d07312019-03-20 09:48:39 +0100404}
405
406/* Transmit BVC-RESET before NS-ALIVE of PCU was ACKed: expect no response */
407testcase TC_sns_1c1u_so_bvc_reset_too_early() runs on RAW_Test_CT {
408 /* Activate two NS codec ports */
Alexander Couzens2beaa202020-09-11 20:08:41 +0200409 f_init_ns_codec(mp_nsconfig);
410 f_init_ns_codec(mp_nsconfig, 1);
411 f_init_ns_codec(mp_nsconfig, 2);
Harald Welte64d07312019-03-20 09:48:39 +0100412 f_init_pcuif();
413 /* Perform Size + BSS-originated config */
414 f_incoming_sns_size();
415 f_incoming_sns_config();
416 /* perform SGSN-originated config using idx==0 for signalling and idx==1 for user traffic */
417 f_outgoing_sns_config_1c1u_separate();
418
419 /* DON'T ACK ANY INBOUND NS-ALIVE HERE! */
420
421 /* perform outgoing ALIVE procedure for both NS-VCs */
422 f_outgoing_ns_alive(1);
423 f_outgoing_ns_alive(2);
424 /* ensure there's no response to NS-ALIVE sent on idx==0 */
425 f_outgoing_ns_alive_no_ack(idx := 0);
426
427 /* Transmit BVC-RESET and expect no ACK*/
Harald Weltee97e3af2020-10-09 14:56:54 +0200428 f_tx_bvc_reset_rx_ack(0, omit, omit, idx := 1, exp_ack := false);
429 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);
Alexander Couzensc3165722021-01-11 02:51:45 +0100430 f_clean_ns_codec();
Harald Welte64d07312019-03-20 09:48:39 +0100431}
432
Harald Welte630d0e62019-02-22 23:26:40 +0100433/* Test adding new IP endpoints at runtime */
Harald Welteea3c7e92019-03-01 19:34:55 +0100434testcase TC_sns_add() runs on RAW_Test_CT {
Harald Welte630d0e62019-02-22 23:26:40 +0100435 f_sns_bringup_1c1u();
436
Alexander Couzens2373afc2020-12-09 02:19:49 +0100437 /* create another NS codec port on the tester side */
Alexander Couzens2beaa202020-09-11 20:08:41 +0200438 f_init_ns_codec(mp_nsconfig, 2);
Harald Welte630d0e62019-02-22 23:26:40 +0100439
440 f_outgoing_sns_add(idx_add := 2, w_sig := 0, w_user := 1, idx := 0);
441
442 /* wait for one ALIVE cycle, then ACK any further ALIVE in the background */
443 as_rx_alive_tx_ack(oneshot := true, idx := 2);
444 activate(as_rx_alive_tx_ack(idx := 2));
445
446 f_outgoing_ns_alive(2);
Harald Welte630d0e62019-02-22 23:26:40 +0100447 setverdict(pass);
Alexander Couzensc3165722021-01-11 02:51:45 +0100448 f_clean_ns_codec();
Harald Welte630d0e62019-02-22 23:26:40 +0100449}
450
Alexander Couzens2a0ac802020-12-09 02:19:29 +0100451/* Test adding an already present IP endpoint at runtime */
452testcase TC_sns_add_nack() runs on RAW_Test_CT {
453 f_sns_bringup_1c1u();
454
455 f_outgoing_sns_add(idx_add := 0, w_sig := 0, w_user := 1, idx := 0, cause := NS_CAUSE_PROTOCOL_ERROR_UNSPEIFIED);
456 setverdict(pass);
Alexander Couzensc3165722021-01-11 02:51:45 +0100457 f_clean_ns_codec();
Alexander Couzens2a0ac802020-12-09 02:19:29 +0100458}
459
Harald Welte630d0e62019-02-22 23:26:40 +0100460/* Test deleting IP endpoints at runtime */
Harald Welteea3c7e92019-03-01 19:34:55 +0100461testcase TC_sns_del() runs on RAW_Test_CT {
Harald Welte630d0e62019-02-22 23:26:40 +0100462 f_sns_bringup_1c1u();
463
464 f_outgoing_sns_del(idx_del := 1, w_sig := 0, w_user := 1, idx := 0);
465 /* FIXME: ensure we don't receive anything on just-deleted NS-VC anymore */
466 setverdict(pass);
Alexander Couzensc3165722021-01-11 02:51:45 +0100467 f_clean_ns_codec();
Harald Welte630d0e62019-02-22 23:26:40 +0100468}
469
Harald Welte72099552019-02-23 15:09:22 +0100470/* Test changing weights at runtime */
Harald Welteea3c7e92019-03-01 19:34:55 +0100471testcase TC_sns_chg_weight() runs on RAW_Test_CT {
Harald Welte72099552019-02-23 15:09:22 +0100472 f_sns_bringup_1c1u();
473
474 /* change w_user from 1 to 200 */
475 f_outgoing_sns_chg_weight(idx_chg := 1, w_sig := 0, w_user := 200, idx := 0);
476 setverdict(pass);
Alexander Couzensc3165722021-01-11 02:51:45 +0100477 f_clean_ns_codec();
Harald Welte72099552019-02-23 15:09:22 +0100478}
479
Harald Welte16e92f42019-03-02 00:03:44 +0100480import from PCUIF_Types all;
481import from PCUIF_CodecPort all;
482
Harald Welte3b335832019-03-15 22:38:06 +0100483altstep as_pcu_activate() runs on RAW_PCU_CT {
484 var PCUIF_send_data sd;
485 [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_ACT_REQ(?, ?, ?))) -> value sd { repeat; }
486
487}
488
Harald Welte16e92f42019-03-02 00:03:44 +0100489testcase TC_pcuif_rach() runs on RAW_Test_CT {
490 f_sns_bringup_1c1u();
Harald Welte3b335832019-03-15 22:38:06 +0100491 activate(as_pcu_activate());
Harald Welte16e92f42019-03-02 00:03:44 +0100492
Vadim Yanitskiy36558d92019-11-17 02:23:51 +0700493 f_pcuif_tx(ts_PCUIF_RACH_IND(bts_nr:=0, trx_nr:=0, ts_nr:=0, ra:=23,
494 is_11bit:=0, burst_type:=BURST_TYPE_0,
Harald Welte16e92f42019-03-02 00:03:44 +0100495 fn:=42, arfcn:=871, qta:=0));
496 PCU.receive(t_SD_PCUIF(g_pcu_conn_id,
497 tr_PCUIF_DATA_REQ(bts_nr:=0, trx_nr:=0, ts_nr:=0, block_nr:=?, fn:=?,
498 sapi:=PCU_IF_SAPI_AGCH, data:=?)));
499 setverdict(pass);
Alexander Couzensc3165722021-01-11 02:51:45 +0100500 f_clean_ns_codec();
Harald Welte16e92f42019-03-02 00:03:44 +0100501}
502
Harald Welte630d0e62019-02-22 23:26:40 +0100503
504
Harald Weltef7b74072019-02-20 20:48:50 +0100505control {
506 execute( TC_sns_po_size_success() );
507 execute( TC_sns_po_size_nack() );
508 execute( TC_sns_po_config_success() );
509 execute( TC_sns_po_config_nack() );
510 execute( TC_sns_so_config_success() );
Harald Welte630d0e62019-02-22 23:26:40 +0100511 execute( TC_sns_1c1u() );
Harald Welteecd159e2019-03-16 13:36:07 +0100512 execute( TC_sns_1c1u_separate() );
Harald Welte64d07312019-03-20 09:48:39 +0100513 execute( TC_sns_1c1u_so_bvc_reset() );
514 execute( TC_sns_1c1u_so_bvc_reset_too_early() );
Harald Welte630d0e62019-02-22 23:26:40 +0100515 execute( TC_sns_add() );
Alexander Couzens2a0ac802020-12-09 02:19:29 +0100516 execute( TC_sns_add_nack() );
Harald Welte630d0e62019-02-22 23:26:40 +0100517 execute( TC_sns_del() );
Harald Welte72099552019-02-23 15:09:22 +0100518 execute( TC_sns_chg_weight() );
Harald Welte16e92f42019-03-02 00:03:44 +0100519
520 execute( TC_pcuif_rach() );
Harald Weltef7b74072019-02-20 20:48:50 +0100521}
522
523}