blob: 26d80110cad7e6bc9f46f634d8e93adce16788c1 [file] [log] [blame]
Harald Weltef7b74072019-02-20 20:48:50 +01001module PCU_Tests_RAW_SNS {
2
3import from Osmocom_Types all;
4import from PCU_Tests all;
5import from PCU_Tests_RAW all;
Harald Weltec4d7beb2019-02-21 18:21:01 +01006import from Osmocom_Gb_Types all;
7import from NS_CodecPort all;
8import from NS_Types all;
Harald Weltef7b74072019-02-20 20:48:50 +01009
10/**********************************************************************************
11 * Modern Gb/IP bring-up test cases using IP Sub-Network Service (SNS)
12 **********************************************************************************/
13
Harald Weltec4d7beb2019-02-21 18:21:01 +010014/* perform inbound SNS-SIZE procedure */
Harald Weltebf768242019-02-21 22:19:21 +010015function f_incoming_sns_size(template (omit) NsCause cause := omit, integer idx := 0)
16runs on RAW_NS_CT {
Harald Welteb63c3a12019-02-22 23:27:12 +010017 log("f_incoming_sns_size(idx=", idx, ")");
Harald Weltec4d7beb2019-02-21 18:21:01 +010018 var PDU_NS rx;
19 /* expect one single SNS-SIZE with RESET flag; one remote v4 EP; no v6 EP */
Harald Weltebf768242019-02-21 22:19:21 +010020 rx := f_ns_exp(tr_SNS_SIZE(g_nsconfig[idx].nsei, rst_flag := true, max_nsvcs := 8,
21 num_v4 := 4, num_v6 := omit), idx);
22 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 +010023}
24
25/* perform outbound SNS-SIZE procedure */
Harald Weltebf768242019-02-21 22:19:21 +010026function f_outgoing_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_outgoing_sns_size(idx=", idx, ")");
Harald Weltec4d7beb2019-02-21 18:21:01 +010029 var PDU_NS rx;
Harald Weltebf768242019-02-21 22:19:21 +010030 NSCP[idx].send(t_NS_Send(g_ns_conn_id[idx], ts_SNS_SIZE(g_nsconfig[idx].nsei, rst_flag := true, max_nsvcs := 1,
Harald Weltec4d7beb2019-02-21 18:21:01 +010031 num_v4 := 1, num_v6 := omit)
32 ));
33 /* expect one single SNS-SIZE with RESET flag; one remote v4 EP; no v6 EP */
Harald Weltebf768242019-02-21 22:19:21 +010034 rx := f_ns_exp(tr_SNS_SIZE_ACK(g_nsconfig[idx].nsei, cause), idx);
Harald Weltec4d7beb2019-02-21 18:21:01 +010035}
36
37/* perform inbound SNS-CONFIG procedure */
Harald Weltebf768242019-02-21 22:19:21 +010038function f_incoming_sns_config(template (omit) NsCause cause := omit, integer idx := 0)
39runs on RAW_NS_CT {
Harald Welteb63c3a12019-02-22 23:27:12 +010040 log("f_incoming_sns_config(idx=", idx, ")");
Harald Weltec4d7beb2019-02-21 18:21:01 +010041 var PDU_NS rx;
Harald Weltebf768242019-02-21 22:19:21 +010042 rx := f_ns_exp(tr_SNS_CONFIG(g_nsconfig[idx].nsei, end_flag := true, v4 := ?), idx);
43 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 +010044}
45
46/* perform outbound SNS-CONFIG procedure */
Harald Weltebf768242019-02-21 22:19:21 +010047function f_outgoing_sns_config(template (omit) NsCause cause := omit, integer idx := 0)
48runs on RAW_NS_CT {
Harald Welteb63c3a12019-02-22 23:27:12 +010049 log("f_outgoing_sns_config(idx=", idx, ")");
Harald Weltec4d7beb2019-02-21 18:21:01 +010050 var PDU_NS rx;
Harald Weltebf768242019-02-21 22:19:21 +010051 var template (omit) IP4_Elements v4 := { ts_SNS_IPv4(g_nsconfig[idx].local_ip,
52 g_nsconfig[idx].local_udp_port) }
53 NSCP[idx].send(t_NS_Send(g_ns_conn_id[idx], ts_SNS_CONFIG(g_nsconfig[idx].nsei, true, v4)));
54 rx := f_ns_exp(tr_SNS_CONFIG_ACK(g_nsconfig[idx].nsei, cause), idx);
Harald Weltec4d7beb2019-02-21 18:21:01 +010055}
56
Harald Weltebf768242019-02-21 22:19:21 +010057/* perform outbound SNS-CONFIG procedure (separate endpoints: 1 for control, 1 for user */
58function f_outgoing_sns_config_1c1u(template (omit) NsCause cause := omit, integer idx := 0)
59runs on RAW_NS_CT {
Harald Welteb63c3a12019-02-22 23:27:12 +010060 log("f_outgoing_sns_config_1c1u(idx=", idx, ")");
Harald Weltebf768242019-02-21 22:19:21 +010061 var PDU_NS rx;
62 var template (omit) IP4_Elements v4 := { ts_SNS_IPv4(g_nsconfig[0].local_ip,
63 g_nsconfig[0].local_udp_port, 1, 0),
64 ts_SNS_IPv4(g_nsconfig[1].local_ip,
65 g_nsconfig[1].local_udp_port, 0, 1) };
66 NSCP[idx].send(t_NS_Send(g_ns_conn_id[idx], ts_SNS_CONFIG(g_nsconfig[idx].nsei, true, v4)));
67 rx := f_ns_exp(tr_SNS_CONFIG_ACK(g_nsconfig[idx].nsei, cause), idx);
68}
69
Harald Welte630d0e62019-02-22 23:26:40 +010070function f_outgoing_sns_add(integer idx_add, uint8_t w_sig := 1, uint8_t w_user := 1, integer idx := 0)
71runs on RAW_NS_CT {
72 log("f_outgoing_sns_add(idx_add=", idx_add, ")");
73 var PDU_NS rx;
74 var template (omit) IP4_Elements v4 := { ts_SNS_IPv4(g_nsconfig[idx_add].local_ip,
75 g_nsconfig[idx_add].local_udp_port,
76 w_sig, w_user) };
77 NSCP[idx].send(t_NS_Send(g_ns_conn_id[idx], ts_SNS_ADD(g_nsconfig[idx].nsei, 23, v4)));
78 rx := f_ns_exp(tr_SNS_ACK(g_nsconfig[idx].nsei, 23, omit, v4));
79}
80
81function f_outgoing_sns_del(integer idx_del, uint8_t w_sig := 1, uint8_t w_user := 1, integer idx := 0)
82runs on RAW_NS_CT {
83 log("f_outgoing_sns_del(idx_del=", idx_del, ")");
84 var PDU_NS rx;
85 var template (omit) IP4_Elements v4 := { ts_SNS_IPv4(g_nsconfig[idx_del].local_ip,
86 g_nsconfig[idx_del].local_udp_port,
87 w_sig, w_user) };
88 NSCP[idx].send(t_NS_Send(g_ns_conn_id[idx], ts_SNS_DEL(g_nsconfig[idx].nsei, 24, omit, v4)));
89 rx := f_ns_exp(tr_SNS_ACK(g_nsconfig[idx].nsei, 24, omit, v4));
90}
91
Harald Welte72099552019-02-23 15:09:22 +010092function f_outgoing_sns_chg_weight(integer idx_chg, uint8_t w_sig, uint8_t w_user, integer idx := 0)
93runs on RAW_NS_CT {
94 log("f_outgoing_sns_chg_weight(idx_chg=", idx_chg, ")");
95 var PDU_NS rx;
96 var template (omit) IP4_Elements v4 := { ts_SNS_IPv4(g_nsconfig[idx_chg].local_ip,
97 g_nsconfig[idx_chg].local_udp_port,
98 w_sig, w_user) };
99 NSCP[idx].send(t_NS_Send(g_ns_conn_id[idx], ts_SNS_CHG_WEIGHT(g_nsconfig[idx].nsei, 25, v4)));
100 rx := f_ns_exp(tr_SNS_ACK(g_nsconfig[idx].nsei, 25, omit, v4));
101}
102
103
104
Harald Welte630d0e62019-02-22 23:26:40 +0100105
Harald Weltebf768242019-02-21 22:19:21 +0100106
Harald Weltef7b74072019-02-20 20:48:50 +0100107/* PCU-originated SNS-SIZE: successful case */
Harald Welteea3c7e92019-03-01 19:34:55 +0100108testcase TC_sns_po_size_success() runs on RAW_Test_CT {
Harald Weltef7b74072019-02-20 20:48:50 +0100109 f_init_ns_codec();
110 f_init_pcuif();
111 f_incoming_sns_size();
112 f_sleep(1.0);
113 setverdict(pass);
114}
115
116/* PCU-originated SNS-SIZE: NACK from our side */
Harald Welteea3c7e92019-03-01 19:34:55 +0100117testcase TC_sns_po_size_nack() runs on RAW_Test_CT {
Harald Weltef7b74072019-02-20 20:48:50 +0100118 f_init_ns_codec();
119 f_init_pcuif();
120 f_incoming_sns_size(NS_CAUSE_PROTOCOL_ERROR_UNSPEIFIED);
121 /* FIXME: ensure we don't get a SNS-CONFIG */
122 /* FIXME: ensure we get re-transmitted SNS-SIZE attempts */
123 f_sleep(10.0);
124 setverdict(pass);
125}
126
127/* PCU-originated SNS-CONFIG: successful case */
Harald Welteea3c7e92019-03-01 19:34:55 +0100128testcase TC_sns_po_config_success() runs on RAW_Test_CT {
Harald Weltef7b74072019-02-20 20:48:50 +0100129 f_init_ns_codec();
130 f_init_pcuif();
131 f_incoming_sns_size();
132 f_incoming_sns_config();
133 f_sleep(1.0);
134 setverdict(pass);
135}
136
137/* PCU-originated SNS-CONFIG: successful case */
Harald Welteea3c7e92019-03-01 19:34:55 +0100138testcase TC_sns_po_config_nack() runs on RAW_Test_CT {
Harald Weltef7b74072019-02-20 20:48:50 +0100139 f_init_ns_codec();
140 f_init_pcuif();
141 f_incoming_sns_size();
142 f_incoming_sns_config(NS_CAUSE_PROTOCOL_ERROR_UNSPEIFIED);
143 /* FIXME: ensure we get re-transmitted SNS-CONFIG attempts */
144 f_sleep(10.0);
145 setverdict(pass);
146}
147
148
149/* SGSN-originated SNS-SIZE: successful case */
Harald Welteea3c7e92019-03-01 19:34:55 +0100150testcase TC_sns_so_config_success() runs on RAW_Test_CT {
Harald Weltef7b74072019-02-20 20:48:50 +0100151 f_init_ns_codec();
152 f_init_pcuif();
153 f_incoming_sns_size();
154 f_incoming_sns_config();
155 f_outgoing_sns_config();
156
157 /* wait for one ALIVE cycle, then ACK any further ALIVE in the background */
158 as_rx_alive_tx_ack(oneshot := true);
159 activate(as_rx_alive_tx_ack());
160
161 f_outgoing_ns_alive();
162
163 /* Expect BVC-RESET for signaling (0) and ptp BVCI */
164 as_rx_bvc_reset_tx_ack(0, oneshot := true);
165 as_rx_bvc_reset_tx_ack(mp_gb_cfg.bvci, oneshot := true);
166 as_rx_bvc_unblock_tx_ack(mp_gb_cfg.bvci, oneshot := true);
167
168 /* wait for one FLOW-CONTROL BVC and then ACK any further in the future */
Harald Welte630d0e62019-02-22 23:26:40 +0100169 as_rx_bvc_fc_tx_ack(mp_gb_cfg.bvci, oneshot := true, idx := 1);
170 activate(as_rx_bvc_fc_tx_ack(mp_gb_cfg.bvci, idx := 1));
Harald Weltef7b74072019-02-20 20:48:50 +0100171 setverdict(pass);
172}
173
Harald Welteea3c7e92019-03-01 19:34:55 +0100174private function f_sns_bringup_1c1u() runs on RAW_Test_CT {
Harald Welte630d0e62019-02-22 23:26:40 +0100175 /* Activate two NS codec ports */
176 f_init_ns_codec();
177 f_init_ns_codec(1);
178 f_init_pcuif();
179 /* Perform Size + BSS-originated config */
180 f_incoming_sns_size();
181 f_incoming_sns_config();
182 /* perform SGSN-originated config using idx==0 for signalling and idx==1 for user traffic */
183 f_outgoing_sns_config_1c1u();
184
185 /* wait for one ALIVE cycle, then ACK any further ALIVE in the background
186 * for both NS-VCs */
187 as_rx_alive_tx_ack(oneshot := true, idx := 0);
188 activate(as_rx_alive_tx_ack(idx := 0));
189 as_rx_alive_tx_ack(oneshot := true, idx := 1);
190 activate(as_rx_alive_tx_ack(idx := 1));
191
192 /* perform outgoing ALIVE procedure for both NS-VCs */
193 f_outgoing_ns_alive(0);
194 f_outgoing_ns_alive(1);
195
196 /* Expect BVC-RESET for signaling (0) and ptp BVCI */
197 as_rx_bvc_reset_tx_ack(0, oneshot := true);
198 as_rx_bvc_reset_tx_ack(mp_gb_cfg.bvci, oneshot := true);
199 /* Expect UNBLOCK for ptp BVCI on signaling NS-VC (idx==0) */
200 as_rx_bvc_unblock_tx_ack(mp_gb_cfg.bvci, oneshot := true);
201
202 /* wait for one FLOW-CONTROL BVC and then ACK any further in the future. Flow
203 * control happens on the p-t-p BVCI and hence on index 1 */
204 as_rx_bvc_fc_tx_ack(mp_gb_cfg.bvci, oneshot := true, idx := 1);
205 activate(as_rx_bvc_fc_tx_ack(mp_gb_cfg.bvci, idx := 1));
206}
207
208/* Test full IP-SNS bring-up with two NS-VCs, one sig-only and one user-only */
Harald Welteea3c7e92019-03-01 19:34:55 +0100209testcase TC_sns_1c1u() runs on RAW_Test_CT {
Harald Welte630d0e62019-02-22 23:26:40 +0100210 f_sns_bringup_1c1u();
211 setverdict(pass);
212}
213
214/* Test adding new IP endpoints at runtime */
Harald Welteea3c7e92019-03-01 19:34:55 +0100215testcase TC_sns_add() runs on RAW_Test_CT {
Harald Welte630d0e62019-02-22 23:26:40 +0100216 f_sns_bringup_1c1u();
217
218 /* crate another NS codec port on the tester side */
219 f_init_ns_codec(2);
220
221 f_outgoing_sns_add(idx_add := 2, w_sig := 0, w_user := 1, idx := 0);
222
223 /* wait for one ALIVE cycle, then ACK any further ALIVE in the background */
224 as_rx_alive_tx_ack(oneshot := true, idx := 2);
225 activate(as_rx_alive_tx_ack(idx := 2));
226
227 f_outgoing_ns_alive(2);
228 /* TODO: Should we expect FLOW-CONTROL BVC here too? */
229 setverdict(pass);
230}
231
232/* Test deleting IP endpoints at runtime */
Harald Welteea3c7e92019-03-01 19:34:55 +0100233testcase TC_sns_del() runs on RAW_Test_CT {
Harald Welte630d0e62019-02-22 23:26:40 +0100234 f_sns_bringup_1c1u();
235
236 f_outgoing_sns_del(idx_del := 1, w_sig := 0, w_user := 1, idx := 0);
237 /* FIXME: ensure we don't receive anything on just-deleted NS-VC anymore */
238 setverdict(pass);
239}
240
Harald Welte72099552019-02-23 15:09:22 +0100241/* Test changing weights at runtime */
Harald Welteea3c7e92019-03-01 19:34:55 +0100242testcase TC_sns_chg_weight() runs on RAW_Test_CT {
Harald Welte72099552019-02-23 15:09:22 +0100243 f_sns_bringup_1c1u();
244
245 /* change w_user from 1 to 200 */
246 f_outgoing_sns_chg_weight(idx_chg := 1, w_sig := 0, w_user := 200, idx := 0);
247 setverdict(pass);
248}
249
Harald Welte16e92f42019-03-02 00:03:44 +0100250import from PCUIF_Types all;
251import from PCUIF_CodecPort all;
252
253private function f_pcuif_tx(template (value) PCUIF_Message msg) runs on RAW_PCU_CT {
254 PCU.send(t_SD_PCUIF(g_pcu_conn_id, msg));
255}
256
257testcase TC_pcuif_rach() runs on RAW_Test_CT {
258 f_sns_bringup_1c1u();
259
260 f_pcuif_tx(ts_PCUIF_RACH_IND(bts_nr:=0, ra:=23, is_11bit:=0, burst_type:=BURST_TYPE_0,
261 fn:=42, arfcn:=871, qta:=0));
262 PCU.receive(t_SD_PCUIF(g_pcu_conn_id,
263 tr_PCUIF_DATA_REQ(bts_nr:=0, trx_nr:=0, ts_nr:=0, block_nr:=?, fn:=?,
264 sapi:=PCU_IF_SAPI_AGCH, data:=?)));
265 setverdict(pass);
266}
267
Harald Welte630d0e62019-02-22 23:26:40 +0100268
269
Harald Weltef7b74072019-02-20 20:48:50 +0100270control {
271 execute( TC_sns_po_size_success() );
272 execute( TC_sns_po_size_nack() );
273 execute( TC_sns_po_config_success() );
274 execute( TC_sns_po_config_nack() );
275 execute( TC_sns_so_config_success() );
Harald Welte630d0e62019-02-22 23:26:40 +0100276 execute( TC_sns_1c1u() );
277 execute( TC_sns_add() );
278 execute( TC_sns_del() );
Harald Welte72099552019-02-23 15:09:22 +0100279 execute( TC_sns_chg_weight() );
Harald Welte16e92f42019-03-02 00:03:44 +0100280
281 execute( TC_pcuif_rach() );
Harald Weltef7b74072019-02-20 20:48:50 +0100282}
283
284}