blob: 41a4059f4291092d7c646b2da0165b30b3766b9a [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
92
Harald Weltebf768242019-02-21 22:19:21 +010093
Harald Weltef7b74072019-02-20 20:48:50 +010094/* PCU-originated SNS-SIZE: successful case */
95testcase TC_sns_po_size_success() runs on RAW_NS_CT {
96 f_init_ns_codec();
97 f_init_pcuif();
98 f_incoming_sns_size();
99 f_sleep(1.0);
100 setverdict(pass);
101}
102
103/* PCU-originated SNS-SIZE: NACK from our side */
104testcase TC_sns_po_size_nack() runs on RAW_NS_CT {
105 f_init_ns_codec();
106 f_init_pcuif();
107 f_incoming_sns_size(NS_CAUSE_PROTOCOL_ERROR_UNSPEIFIED);
108 /* FIXME: ensure we don't get a SNS-CONFIG */
109 /* FIXME: ensure we get re-transmitted SNS-SIZE attempts */
110 f_sleep(10.0);
111 setverdict(pass);
112}
113
114/* PCU-originated SNS-CONFIG: successful case */
115testcase TC_sns_po_config_success() runs on RAW_NS_CT {
116 f_init_ns_codec();
117 f_init_pcuif();
118 f_incoming_sns_size();
119 f_incoming_sns_config();
120 f_sleep(1.0);
121 setverdict(pass);
122}
123
124/* PCU-originated SNS-CONFIG: successful case */
125testcase TC_sns_po_config_nack() runs on RAW_NS_CT {
126 f_init_ns_codec();
127 f_init_pcuif();
128 f_incoming_sns_size();
129 f_incoming_sns_config(NS_CAUSE_PROTOCOL_ERROR_UNSPEIFIED);
130 /* FIXME: ensure we get re-transmitted SNS-CONFIG attempts */
131 f_sleep(10.0);
132 setverdict(pass);
133}
134
135
136/* SGSN-originated SNS-SIZE: successful case */
137testcase TC_sns_so_config_success() runs on RAW_NS_CT {
138 f_init_ns_codec();
139 f_init_pcuif();
140 f_incoming_sns_size();
141 f_incoming_sns_config();
142 f_outgoing_sns_config();
143
144 /* wait for one ALIVE cycle, then ACK any further ALIVE in the background */
145 as_rx_alive_tx_ack(oneshot := true);
146 activate(as_rx_alive_tx_ack());
147
148 f_outgoing_ns_alive();
149
150 /* Expect BVC-RESET for signaling (0) and ptp BVCI */
151 as_rx_bvc_reset_tx_ack(0, oneshot := true);
152 as_rx_bvc_reset_tx_ack(mp_gb_cfg.bvci, oneshot := true);
153 as_rx_bvc_unblock_tx_ack(mp_gb_cfg.bvci, oneshot := true);
154
155 /* wait for one FLOW-CONTROL BVC and then ACK any further in the future */
Harald Welte630d0e62019-02-22 23:26:40 +0100156 as_rx_bvc_fc_tx_ack(mp_gb_cfg.bvci, oneshot := true, idx := 1);
157 activate(as_rx_bvc_fc_tx_ack(mp_gb_cfg.bvci, idx := 1));
Harald Weltef7b74072019-02-20 20:48:50 +0100158 setverdict(pass);
159}
160
Harald Welte630d0e62019-02-22 23:26:40 +0100161private function f_sns_bringup_1c1u() runs on RAW_NS_CT {
162 /* Activate two NS codec ports */
163 f_init_ns_codec();
164 f_init_ns_codec(1);
165 f_init_pcuif();
166 /* Perform Size + BSS-originated config */
167 f_incoming_sns_size();
168 f_incoming_sns_config();
169 /* perform SGSN-originated config using idx==0 for signalling and idx==1 for user traffic */
170 f_outgoing_sns_config_1c1u();
171
172 /* wait for one ALIVE cycle, then ACK any further ALIVE in the background
173 * for both NS-VCs */
174 as_rx_alive_tx_ack(oneshot := true, idx := 0);
175 activate(as_rx_alive_tx_ack(idx := 0));
176 as_rx_alive_tx_ack(oneshot := true, idx := 1);
177 activate(as_rx_alive_tx_ack(idx := 1));
178
179 /* perform outgoing ALIVE procedure for both NS-VCs */
180 f_outgoing_ns_alive(0);
181 f_outgoing_ns_alive(1);
182
183 /* Expect BVC-RESET for signaling (0) and ptp BVCI */
184 as_rx_bvc_reset_tx_ack(0, oneshot := true);
185 as_rx_bvc_reset_tx_ack(mp_gb_cfg.bvci, oneshot := true);
186 /* Expect UNBLOCK for ptp BVCI on signaling NS-VC (idx==0) */
187 as_rx_bvc_unblock_tx_ack(mp_gb_cfg.bvci, oneshot := true);
188
189 /* wait for one FLOW-CONTROL BVC and then ACK any further in the future. Flow
190 * control happens on the p-t-p BVCI and hence on index 1 */
191 as_rx_bvc_fc_tx_ack(mp_gb_cfg.bvci, oneshot := true, idx := 1);
192 activate(as_rx_bvc_fc_tx_ack(mp_gb_cfg.bvci, idx := 1));
193}
194
195/* Test full IP-SNS bring-up with two NS-VCs, one sig-only and one user-only */
196testcase TC_sns_1c1u() runs on RAW_NS_CT {
197 f_sns_bringup_1c1u();
198 setverdict(pass);
199}
200
201/* Test adding new IP endpoints at runtime */
202testcase TC_sns_add() runs on RAW_NS_CT {
203 f_sns_bringup_1c1u();
204
205 /* crate another NS codec port on the tester side */
206 f_init_ns_codec(2);
207
208 f_outgoing_sns_add(idx_add := 2, w_sig := 0, w_user := 1, idx := 0);
209
210 /* wait for one ALIVE cycle, then ACK any further ALIVE in the background */
211 as_rx_alive_tx_ack(oneshot := true, idx := 2);
212 activate(as_rx_alive_tx_ack(idx := 2));
213
214 f_outgoing_ns_alive(2);
215 /* TODO: Should we expect FLOW-CONTROL BVC here too? */
216 setverdict(pass);
217}
218
219/* Test deleting IP endpoints at runtime */
220testcase TC_sns_del() runs on RAW_NS_CT {
221 f_sns_bringup_1c1u();
222
223 f_outgoing_sns_del(idx_del := 1, w_sig := 0, w_user := 1, idx := 0);
224 /* FIXME: ensure we don't receive anything on just-deleted NS-VC anymore */
225 setverdict(pass);
226}
227
228
229
Harald Weltef7b74072019-02-20 20:48:50 +0100230control {
231 execute( TC_sns_po_size_success() );
232 execute( TC_sns_po_size_nack() );
233 execute( TC_sns_po_config_success() );
234 execute( TC_sns_po_config_nack() );
235 execute( TC_sns_so_config_success() );
Harald Welte630d0e62019-02-22 23:26:40 +0100236 execute( TC_sns_1c1u() );
237 execute( TC_sns_add() );
238 execute( TC_sns_del() );
Harald Weltef7b74072019-02-20 20:48:50 +0100239}
240
241}