blob: 8424df323bd151183b2028f2ff5a801d7f8f955e [file] [log] [blame]
Harald Welte9fbcf4b2018-12-07 07:56:52 +01001module PCU_Tests_RAW {
2
3/* "RAW" PCU tests: Talk directly to the PCU socket of OsmoPCU on the one hand side (emulating
4 the BTS/BSC side PCU socket server) and the Gb interface on the other hand side. No NS/BSSGP
5 Emulation is used; rather, we simply use the NS_CodecPort to implement both standard and non-
6 standard procedures on the NS and BSSGP level. The goal of these tests is to test exactly
7 those NS and BSSGP implementations on the BSS (PCU) side. */
8
Harald Welte34b5a952019-05-27 11:54:11 +02009/* (C) 2018-2019 Harald Welte <laforge@gnumonks.org>
10 * All rights reserved.
11 *
12 * Released under the terms of GNU General Public License, Version 2 or
13 * (at your option) any later version.
14 *
15 * SPDX-License-Identifier: GPL-2.0-or-later
16 */
17
Harald Welte9fbcf4b2018-12-07 07:56:52 +010018import from General_Types all;
19import from Osmocom_Types all;
Harald Welte7fd25cf2019-03-21 22:14:02 +010020import from GSM_Types all;
21import from GSM_RR_Types all;
22
Harald Welte9fbcf4b2018-12-07 07:56:52 +010023import from NS_Types all;
24import from BSSGP_Types all;
25import from Osmocom_Gb_Types all;
26
27import from BSSGP_Emulation all; /* BssgpConfig */
28import from NS_Emulation all; /* NSConfiguration */
29
30import from UD_Types all;
31import from PCUIF_Types all;
32import from PCUIF_CodecPort all;
Vadim Yanitskiyf7d9c0f2019-09-06 00:08:17 +020033import from PCUIF_RAW_Components all;
Harald Welte9fbcf4b2018-12-07 07:56:52 +010034import from IPL4asp_Types all;
35import from NS_CodecPort all;
36import from NS_CodecPort_CtrlFunct all;
37import from Native_Functions all;
38import from PCU_Tests all;
39
40modulepar {
41 charstring mp_pcu_sock_path := PCU_SOCK_DEFAULT;
42}
43
44type component RAW_NS_CT {
45 /* UDP port towards the bottom (IUT) */
Harald Weltebf768242019-02-21 22:19:21 +010046 port NS_CODEC_PT NSCP[4];
47 var ConnectionId g_ns_conn_id[4] := {-1, -1, -1, -1};
48 var NSConfiguration g_nsconfig[4];
Harald Welte9fbcf4b2018-12-07 07:56:52 +010049 timer g_T_guard;
Harald Welteea3c7e92019-03-01 19:34:55 +010050}
Harald Welte9fbcf4b2018-12-07 07:56:52 +010051
Harald Welteea3c7e92019-03-01 19:34:55 +010052type component RAW_PCU_CT {
Harald Welte9fbcf4b2018-12-07 07:56:52 +010053 /* PCUIF (we emulate the BTS part) */
54 port PCUIF_CODEC_PT PCU;
55 var ConnectionId g_pcu_conn_id := -1;
56}
57
Harald Welteea3c7e92019-03-01 19:34:55 +010058type component RAW_Test_CT extends RAW_NS_CT, RAW_PCU_CT {
59}
60
Harald Welte9fbcf4b2018-12-07 07:56:52 +010061private altstep as_Tguard() runs on RAW_NS_CT {
62 [] g_T_guard.timeout {
63 setverdict(fail, "Timeout of T_guard");
64 mtc.stop;
65 }
66}
67
Harald Welteea3c7e92019-03-01 19:34:55 +010068function f_init_pcuif() runs on RAW_PCU_CT {
Harald Welte9fbcf4b2018-12-07 07:56:52 +010069 map(self:PCU, system:PCU);
70
71 /* Connect the Unix Domain Socket */
72 g_pcu_conn_id := f_pcuif_listen(PCU, mp_pcu_sock_path);
73 PCU.receive(UD_connected:?);
74
75 /* Wait for PCU_VERSION and return INFO_IND */
76 PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_TXT_IND(0, PCU_VERSION, ?)));
77 /* FIXME: make sure to use parameters from mp_gb_cfg.cell_id in the PCU INFO IND */
78 var template PCUIF_Message info_ind := ts_PCUIF_INFO_IND(bts_nr := 0,
79 nsei := mp_nsconfig.nsei,
80 nsvci := mp_nsconfig.nsvci,
81 bvci := mp_gb_cfg.bvci,
82 local_port := mp_nsconfig.remote_udp_port,
83 remote_port := mp_nsconfig.local_udp_port,
84 remote_ip := f_inet_haddr(mp_nsconfig.local_ip)
85 );
86 PCU.send(t_SD_PCUIF(g_pcu_conn_id, info_ind));
87}
88
Harald Welte0466d162019-03-21 21:30:21 +010089function f_pcuif_tx(template (value) PCUIF_Message msg) runs on RAW_PCU_CT {
90 PCU.send(t_SD_PCUIF(g_pcu_conn_id, msg));
91}
92
Harald Weltebf768242019-02-21 22:19:21 +010093function f_init_ns_codec(integer idx := 0, float guard_secs := 60.0) runs on RAW_NS_CT {
Harald Welte9fbcf4b2018-12-07 07:56:52 +010094 var Result res;
Harald Weltebf768242019-02-21 22:19:21 +010095
96 if (not g_T_guard.running) {
97 g_T_guard.start(guard_secs);
98 activate(as_Tguard());
99 }
100
101 if (not isbound(g_nsconfig) or not isbound(g_nsconfig[idx])) {
102 /* copy most parts from mp_nsconfig */
103 g_nsconfig[idx] := mp_nsconfig;
104 /* adjust those parts different for each NS-VC */
105 g_nsconfig[idx].nsvci := mp_nsconfig.nsvci + idx;
106 g_nsconfig[idx].local_udp_port := mp_nsconfig.local_udp_port + idx;
107 }
108
109 map(self:NSCP[idx], system:NSCP);
Harald Welte9fbcf4b2018-12-07 07:56:52 +0100110 /* Connect the UDP socket */
Harald Weltebf768242019-02-21 22:19:21 +0100111 log("connecting NSCP[", idx, "] to ", g_nsconfig[idx]);
112 res := f_IPL4_connect(NSCP[idx], g_nsconfig[idx].remote_ip, g_nsconfig[idx].remote_udp_port,
113 g_nsconfig[idx].local_ip, g_nsconfig[idx].local_udp_port, 0, { udp := {}});
Harald Welte9fbcf4b2018-12-07 07:56:52 +0100114 if (not ispresent(res.connId)) {
Harald Weltebf768242019-02-21 22:19:21 +0100115 setverdict(fail, "Could not connect NS UDP socket, check your configuration ", g_nsconfig[idx]);
Harald Welte9fbcf4b2018-12-07 07:56:52 +0100116 mtc.stop;
117 }
Harald Weltebf768242019-02-21 22:19:21 +0100118 g_ns_conn_id[idx] := res.connId;
119
Harald Welte9fbcf4b2018-12-07 07:56:52 +0100120}
121
Harald Weltebf768242019-02-21 22:19:21 +0100122function f_ns_exp(template PDU_NS exp_rx, integer idx := 0) runs on RAW_NS_CT return PDU_NS {
Harald Welte9fbcf4b2018-12-07 07:56:52 +0100123 var NS_RecvFrom nrf;
124 log("f_ns_exp() expecting ", exp_rx);
125 alt {
Harald Weltebf768242019-02-21 22:19:21 +0100126 [] NSCP[idx].receive(t_NS_RecvFrom(exp_rx)) -> value nrf { }
127 [] NSCP[idx].receive {
Harald Welte9fbcf4b2018-12-07 07:56:52 +0100128 setverdict(fail, "Received unexpected NS: ", nrf);
129 mtc.stop;
130 }
131 }
132 return nrf.msg;
133}
134
Harald Welte9fbcf4b2018-12-07 07:56:52 +0100135/* perform outbound NS-ALIVE procedure */
Harald Weltebf768242019-02-21 22:19:21 +0100136function f_outgoing_ns_alive(integer idx := 0) runs on RAW_NS_CT {
137 NSCP[idx].send(t_NS_Send(g_ns_conn_id[idx], t_NS_ALIVE));
Harald Welte9fbcf4b2018-12-07 07:56:52 +0100138 alt {
Harald Weltebf768242019-02-21 22:19:21 +0100139 [] NSCP[idx].receive(t_NS_RecvFrom(t_NS_ALIVE_ACK));
140 [] NSCP[idx].receive { repeat; }
Harald Welte9fbcf4b2018-12-07 07:56:52 +0100141 }
142}
143
Harald Welteecd159e2019-03-16 13:36:07 +0100144/* perform outbound NS-ALIVE procedure */
145function f_outgoing_ns_alive_no_ack(integer idx := 0, float tout := 10.0) runs on RAW_NS_CT {
146 timer T := tout;
147 NSCP[idx].send(t_NS_Send(g_ns_conn_id[idx], t_NS_ALIVE));
148 T.start;
149 alt {
150 [] NSCP[idx].receive(t_NS_RecvFrom(t_NS_ALIVE_ACK)) {
151 setverdict(fail, "Received unexpected NS-ALIVE ACK");
152 }
153 [] NSCP[idx].receive { repeat; }
154 [] T.timeout {
155 setverdict(pass);
156 }
157 }
158}
159
160/* ensure no matching message is received within 'tout' */
161function f_ensure_no_ns(template PDU_NS ns := ?, integer idx := 0, float tout := 3.0)
162runs on RAW_Test_CT {
163 timer T := tout;
164 T.start;
165 alt {
166 [] NSCP[idx].receive(t_NS_RecvFrom(ns)) {
167 setverdict(fail, "NS-ALIVE from unconfigured (possibly initial) endpoint");
168 }
169 [] T.timeout {
170 setverdict(pass);
171 }
172 }
173}
174
Harald Welte9fbcf4b2018-12-07 07:56:52 +0100175/* perform outbound NS-BLOCK procedure */
Harald Weltebf768242019-02-21 22:19:21 +0100176function f_outgoing_ns_block(NsCause cause, integer idx := 0) runs on RAW_NS_CT {
177 NSCP[idx].send(t_NS_Send(g_ns_conn_id[idx], ts_NS_BLOCK(cause, g_nsconfig[idx].nsvci)));
Harald Welte9fbcf4b2018-12-07 07:56:52 +0100178 alt {
Harald Weltebf768242019-02-21 22:19:21 +0100179 [] NSCP[idx].receive(t_NS_RecvFrom(tr_NS_BLOCK_ACK(g_nsconfig[idx].nsvci)));
180 [] NSCP[idx].receive { repeat; }
Harald Welte9fbcf4b2018-12-07 07:56:52 +0100181 }
182}
183
184/* receive NS-ALIVE and ACK it */
Harald Weltebf768242019-02-21 22:19:21 +0100185altstep as_rx_alive_tx_ack(boolean oneshot := false, integer idx := 0) runs on RAW_NS_CT {
186 [] NSCP[idx].receive(t_NS_RecvFrom(t_NS_ALIVE)) {
187 NSCP[idx].send(t_NS_Send(g_ns_conn_id[idx], t_NS_ALIVE_ACK));
Harald Welte9fbcf4b2018-12-07 07:56:52 +0100188 if (not oneshot) { repeat; }
189 }
190}
191
Harald Welte64d07312019-03-20 09:48:39 +0100192/* Transmit BSSGP RESET for given BVCI and expect ACK */
193function f_tx_bvc_reset_rx_ack(BssgpBvci bvci, integer idx := 0, boolean exp_ack := true)
194runs on RAW_NS_CT {
195 var PDU_BSSGP bssgp_tx := valueof(ts_BVC_RESET(BSSGP_CAUSE_NET_SV_CAP_MOD_GT_ZERO_KBPS, bvci,
196 mp_gb_cfg.cell_id));
197 timer T := 5.0;
198 NSCP[idx].send(t_NS_Send(g_ns_conn_id[idx], ts_NS_UNITDATA(t_SduCtrlB, 0, enc_PDU_BSSGP(bssgp_tx))));
199 T.start;
200 alt {
201 [exp_ack] NSCP[idx].receive(t_NS_RecvFrom(tr_NS_UNITDATA(t_SduCtrlB, 0,
202 decmatch tr_BVC_RESET_ACK(bvci, ?)))) {
203 setverdict(pass);
204 }
205 [exp_ack] T.timeout {
206 setverdict(fail, "No response to BVC-RESET");
207 }
208 [not exp_ack] T.timeout {
209 setverdict(pass);
210 }
211 [] NSCP[idx].receive { repeat; }
212 }
213}
214
Harald Welte9fbcf4b2018-12-07 07:56:52 +0100215/* Receive a BSSGP RESET for given BVCI and ACK it */
Harald Weltebf768242019-02-21 22:19:21 +0100216altstep as_rx_bvc_reset_tx_ack(BssgpBvci bvci, boolean oneshot := false, integer idx := 0) runs on RAW_NS_CT {
Harald Welte9fbcf4b2018-12-07 07:56:52 +0100217 var NS_RecvFrom ns_rf;
218 /* FIXME: nail down received cell_id in match */
Harald Weltebf768242019-02-21 22:19:21 +0100219 [] NSCP[idx].receive(t_NS_RecvFrom(tr_NS_UNITDATA(t_SduCtrlB, 0,
Harald Welte9fbcf4b2018-12-07 07:56:52 +0100220 decmatch tr_BVC_RESET(?, bvci, ?))))
221 -> value ns_rf {
222 var PDU_BSSGP bssgp_rx := dec_PDU_BSSGP(ns_rf.msg.pDU_NS_Unitdata.nS_SDU);
223 var PDU_BSSGP bssgp_tx := valueof(ts_BVC_RESET_ACK(bvci, mp_gb_cfg.cell_id));
Harald Weltebf768242019-02-21 22:19:21 +0100224 NSCP[idx].send(t_NS_Send(g_ns_conn_id[idx], ts_NS_UNITDATA(t_SduCtrlB, 0, enc_PDU_BSSGP(bssgp_tx))));
Harald Welte9fbcf4b2018-12-07 07:56:52 +0100225 if (not oneshot) { repeat; }
226 }
227}
228
229
230/* Receive a BSSGP UNBLOCK for given BVCI and ACK it */
Harald Weltebf768242019-02-21 22:19:21 +0100231altstep as_rx_bvc_unblock_tx_ack(BssgpBvci bvci, boolean oneshot := false, integer idx := 0) runs on RAW_NS_CT {
Harald Welte9fbcf4b2018-12-07 07:56:52 +0100232 var NS_RecvFrom ns_rf;
Harald Weltebf768242019-02-21 22:19:21 +0100233 [] NSCP[idx].receive(t_NS_RecvFrom(tr_NS_UNITDATA(t_SduCtrlB, 0,
Harald Welte9fbcf4b2018-12-07 07:56:52 +0100234 decmatch t_BVC_UNBLOCK(bvci))))
235 -> value ns_rf {
236 var PDU_BSSGP bssgp_rx := dec_PDU_BSSGP(ns_rf.msg.pDU_NS_Unitdata.nS_SDU);
237 var PDU_BSSGP bssgp_tx := valueof(t_BVC_UNBLOCK_ACK(bvci));
Harald Weltebf768242019-02-21 22:19:21 +0100238 NSCP[idx].send(t_NS_Send(g_ns_conn_id[idx], ts_NS_UNITDATA(t_SduCtrlB, 0, enc_PDU_BSSGP(bssgp_tx))));
Harald Welte9fbcf4b2018-12-07 07:56:52 +0100239 if (not oneshot) { repeat; }
240 }
241}
242
243/* Receive a BSSGP FLOW-CONTROL-BVC and ACK it */
Harald Weltebf768242019-02-21 22:19:21 +0100244altstep as_rx_bvc_fc_tx_ack(BssgpBvci bvci, boolean oneshot := false, integer idx := 0) runs on RAW_NS_CT {
Harald Welte9fbcf4b2018-12-07 07:56:52 +0100245 var NS_RecvFrom ns_rf;
Harald Weltebf768242019-02-21 22:19:21 +0100246 [] NSCP[idx].receive(t_NS_RecvFrom(tr_NS_UNITDATA(t_SduCtrlB, bvci,
Harald Welte9fbcf4b2018-12-07 07:56:52 +0100247 decmatch tr_BVC_FC_BVC)))
248 -> value ns_rf {
249 var PDU_BSSGP bssgp_rx := dec_PDU_BSSGP(ns_rf.msg.pDU_NS_Unitdata.nS_SDU);
250 var OCT1 tag := bssgp_rx.pDU_BSSGP_FLOW_CONTROL_BVC.tag.unstructured_Value;
251 var PDU_BSSGP bssgp_tx := valueof(t_BVC_FC_BVC_ACK(tag));
Harald Weltebf768242019-02-21 22:19:21 +0100252 NSCP[idx].send(t_NS_Send(g_ns_conn_id[idx], ts_NS_UNITDATA(t_SduCtrlB, bvci, enc_PDU_BSSGP(bssgp_tx))));
Harald Welte9fbcf4b2018-12-07 07:56:52 +0100253 if (not oneshot) { repeat; }
254 }
255}
256
257/**********************************************************************************
258 * Classic Gb/IP bring-up test cases using NS-{RESET,BLOCK,UNBLOCK} and no IP-SNS *
259 **********************************************************************************/
260
261/* Receive a NS-RESET and ACK it */
Harald Weltebf768242019-02-21 22:19:21 +0100262private altstep as_rx_ns_reset_ack(boolean oneshot := false, integer idx := 0) runs on RAW_NS_CT {
Harald Welte9fbcf4b2018-12-07 07:56:52 +0100263 var NS_RecvFrom ns_rf;
Harald Weltebf768242019-02-21 22:19:21 +0100264 [] NSCP[idx].receive(t_NS_RecvFrom(tr_NS_RESET(NS_CAUSE_OM_INTERVENTION, g_nsconfig[idx].nsvci,
265 g_nsconfig[idx].nsei))) -> value ns_rf {
266 NSCP[idx].send(t_NS_Send(g_ns_conn_id[idx], ts_NS_RESET_ACK(g_nsconfig[idx].nsvci,
267 g_nsconfig[idx].nsei)));
Harald Welte9fbcf4b2018-12-07 07:56:52 +0100268 if (not oneshot) { repeat; }
269 }
270}
271/* Receive a NS-UNBLOCK and ACK it */
Harald Weltebf768242019-02-21 22:19:21 +0100272private altstep as_rx_ns_unblock_ack(boolean oneshot := false, integer idx := 0) runs on RAW_NS_CT {
Harald Welte9fbcf4b2018-12-07 07:56:52 +0100273 var NS_RecvFrom ns_rf;
Harald Weltebf768242019-02-21 22:19:21 +0100274 [] NSCP[idx].receive(t_NS_RecvFrom(t_NS_UNBLOCK)) -> value ns_rf {
275 NSCP[idx].send(t_NS_Send(g_ns_conn_id[idx], t_NS_UNBLOCK_ACK));
Harald Welte9fbcf4b2018-12-07 07:56:52 +0100276 if (not oneshot) { repeat; }
277 }
278}
279
280/* test the NS-RESET procedure */
Harald Welteea3c7e92019-03-01 19:34:55 +0100281testcase TC_ns_reset() runs on RAW_Test_CT {
Harald Welte9fbcf4b2018-12-07 07:56:52 +0100282 f_init_ns_codec();
283 f_init_pcuif();
284
285
286 /* Expect inbound NS-RESET procedure */
287 as_rx_ns_reset_ack(oneshot := true);
288 setverdict(pass);
289}
290
291/* ensure NS-RESET are re-transmitted */
Harald Welteea3c7e92019-03-01 19:34:55 +0100292testcase TC_ns_reset_retrans() runs on RAW_Test_CT {
Harald Welte9fbcf4b2018-12-07 07:56:52 +0100293 f_init_ns_codec();
294 f_init_pcuif();
295
296 var integer i;
297 for (i := 0; i < 3; i := i+1) {
Harald Weltebf768242019-02-21 22:19:21 +0100298 NSCP[0].receive(t_NS_RecvFrom(tr_NS_RESET(NS_CAUSE_OM_INTERVENTION,
299 g_nsconfig[0].nsvci, g_nsconfig[0].nsei)));
Harald Welte9fbcf4b2018-12-07 07:56:52 +0100300 }
301
302 /* Expect inbound NS-RESET procedure */
303 as_rx_ns_reset_ack(oneshot := true);
304 setverdict(pass);
305}
306
307/* test the inbound NS-ALIVE procedure after NS-RESET */
Harald Welteea3c7e92019-03-01 19:34:55 +0100308testcase TC_ns_alive() runs on RAW_Test_CT {
Harald Welte9fbcf4b2018-12-07 07:56:52 +0100309 f_init_ns_codec();
310 f_init_pcuif();
311
312 /* Expect inbound NS-RESET procedure */
313 as_rx_ns_reset_ack(oneshot := true);
314
315 /* wait for one ALIVE cycle, then ACK any further ALIVE in the background */
316 as_rx_alive_tx_ack(oneshot := true);
317 setverdict(pass);
318}
319
320/* Test for NS-RESET after NS-ALIVE timeout */
Harald Welteea3c7e92019-03-01 19:34:55 +0100321testcase TC_ns_alive_timeout_reset() runs on RAW_Test_CT {
Harald Weltebf768242019-02-21 22:19:21 +0100322 f_init_ns_codec(guard_secs := 100.0);
Harald Welte9fbcf4b2018-12-07 07:56:52 +0100323 f_init_pcuif();
324
325 /* Expect inbound NS-RESET procedure */
326 as_rx_ns_reset_ack(oneshot := true);
327
328 /* wait for at least one NS-ALIVE */
Harald Weltebf768242019-02-21 22:19:21 +0100329 NSCP[0].receive(t_NS_RecvFrom(t_NS_ALIVE));
Harald Welte9fbcf4b2018-12-07 07:56:52 +0100330
331 /* wait for NS-RESET to re-appear, ignoring any NS-ALIVE until then */
332 alt {
333 [] as_rx_ns_reset_ack(oneshot := true) { setverdict(pass); }
Harald Weltebf768242019-02-21 22:19:21 +0100334 [] NSCP[0].receive(t_NS_RecvFrom(t_NS_ALIVE)) { repeat; }
Harald Welte9fbcf4b2018-12-07 07:56:52 +0100335 }
336}
337
338/* test for NS-RESET/NS-ALIVE/NS-UNBLOCK */
Harald Welteea3c7e92019-03-01 19:34:55 +0100339testcase TC_ns_unblock() runs on RAW_Test_CT {
Harald Welte9fbcf4b2018-12-07 07:56:52 +0100340 f_init_ns_codec();
341 f_init_pcuif();
342
343 /* Expect inbound NS-RESET procedure */
344 as_rx_ns_reset_ack(oneshot := true);
345
346 /* wait for one ALIVE cycle, then ACK any further ALIVE in the background */
347 as_rx_alive_tx_ack(oneshot := true);
348 activate(as_rx_alive_tx_ack());
349
350 as_rx_ns_unblock_ack(oneshot := true);
351 setverdict(pass);
352}
353
354/* test for NS-UNBLOCK re-transmissions */
Harald Welteea3c7e92019-03-01 19:34:55 +0100355testcase TC_ns_unblock_retrans() runs on RAW_Test_CT {
Harald Welte9fbcf4b2018-12-07 07:56:52 +0100356 f_init_ns_codec();
357 f_init_pcuif();
358
359 /* Expect inbound NS-RESET procedure */
360 as_rx_ns_reset_ack(oneshot := true);
361
362 /* wait for one ALIVE cycle, then ACK any further ALIVE in the background */
363 as_rx_alive_tx_ack(oneshot := true);
364 activate(as_rx_alive_tx_ack());
365
366 /* wait for first NS-UNBLOCK, don't respond */
Harald Weltebf768242019-02-21 22:19:21 +0100367 NSCP[0].receive(t_NS_RecvFrom(t_NS_UNBLOCK));
Harald Welte9fbcf4b2018-12-07 07:56:52 +0100368
369 /* wait for re-transmission of NS-UNBLOCK */
370 as_rx_ns_unblock_ack(oneshot := true);
371 setverdict(pass);
372}
373
374/* full bring-up of the Gb link for NS and BSSGP layer up to BVC-FC */
Harald Welteea3c7e92019-03-01 19:34:55 +0100375testcase TC_ns_full_bringup() runs on RAW_Test_CT {
Harald Welte9fbcf4b2018-12-07 07:56:52 +0100376 f_init_ns_codec();
377 f_init_pcuif();
378
379 /* Expect inbound NS-RESET procedure */
380 as_rx_ns_reset_ack(oneshot := true);
381
382 /* wait for one ALIVE cycle, then ACK any further ALIVE in the background */
383 as_rx_alive_tx_ack(oneshot := true);
384 activate(as_rx_alive_tx_ack());
385
386 as_rx_ns_unblock_ack(oneshot := true);
387
388 f_outgoing_ns_alive();
389
390 /* Expect BVC-RESET for signaling (0) and ptp BVCI */
391 as_rx_bvc_reset_tx_ack(0, oneshot := true);
392 as_rx_bvc_reset_tx_ack(mp_gb_cfg.bvci, oneshot := true);
393 as_rx_bvc_unblock_tx_ack(mp_gb_cfg.bvci, oneshot := true);
394
395 /* wait for one FLOW-CONTROL BVC and then ACK any further in the future */
396 as_rx_bvc_fc_tx_ack(mp_gb_cfg.bvci, oneshot := true);
397 activate(as_rx_bvc_fc_tx_ack(mp_gb_cfg.bvci));
398 setverdict(pass);
399}
400
401/* test outbound (SGSN-originated) NS-BLOCK procedure */
Harald Welteea3c7e92019-03-01 19:34:55 +0100402testcase TC_ns_so_block() runs on RAW_Test_CT {
Harald Welte9fbcf4b2018-12-07 07:56:52 +0100403 f_init_ns_codec();
404 f_init_pcuif();
405
406 /* Expect inbound NS-RESET procedure */
407 as_rx_ns_reset_ack(oneshot := true);
408
409 /* wait for one ALIVE cycle, then ACK any further ALIVE in the background */
410 as_rx_alive_tx_ack(oneshot := true);
411 activate(as_rx_alive_tx_ack());
412
413 as_rx_ns_unblock_ack(oneshot := true);
414
415 f_outgoing_ns_alive();
416
417 f_outgoing_ns_block(NS_CAUSE_EQUIPMENT_FAILURE);
418 setverdict(pass);
419}
420
Harald Welte7fd25cf2019-03-21 22:14:02 +0100421/* Test component with PCUIF + BSSGP/NS Emulation (no L1CTL) */
422type component bssgp_pcuif_CT extends bssgp_CT, RAW_PCU_CT {
423}
424
425testcase TC_pcuif_suspend() runs on bssgp_pcuif_CT {
426 var OCT6 ra_id := enc_RoutingAreaIdentification(mp_gb_cfg.cell_id.ra_id);
427 var GprsTlli tlli := 'FFFFFFFF'O;
428
429 /* Initialize PCU interface side */
430 f_init_pcuif();
431
432 /* Initialize NS/BSSGP side */
433 f_init_bssgp();
434
435 f_sleep(1.0);
436 f_pcuif_tx(ts_PCUIF_SUSP_REQ(0, tlli, ra_id, 0));
Harald Welte955aa942019-05-03 01:29:29 +0200437 BSSGP_SIG[0].receive(tr_BSSGP_SUSPEND(tlli, mp_gb_cfg.cell_id.ra_id));
Harald Welte7fd25cf2019-03-21 22:14:02 +0100438
439 setverdict(pass);
440}
441
Vadim Yanitskiyf7d9c0f2019-09-06 00:08:17 +0200442type component RAW_PCU_Test_CT extends bssgp_CT {
443 /* Connection to the BTS component (one for now) */
444 port RAW_PCU_MSG_PT BTS;
445 /* Connection to the PCUIF component */
446 port RAW_PCU_MSG_PT PCUIF;
447
448 /* Guard timeout */
449 timer g_T_guard := 60.0;
450};
451
452private altstep as_Tguard_RAW() runs on RAW_PCU_Test_CT {
453 [] g_T_guard.timeout {
454 setverdict(fail, "Timeout of T_guard");
455 mtc.stop;
456 }
457}
458
459private function f_init_raw(charstring id)
460runs on RAW_PCU_Test_CT {
461 var PCUIF_info_ind info_ind;
462 var RAW_PCUIF_CT vc_PCUIF;
463 var RAW_PCU_BTS_CT vc_BTS;
464
465 /* Start the guard timer */
466 g_T_guard.start;
467 activate(as_Tguard_RAW());
468
469 /* Init PCU interface component */
470 vc_PCUIF := RAW_PCUIF_CT.create("PCUIF-" & id);
471 connect(vc_PCUIF:MTC, self:PCUIF);
472 map(vc_PCUIF:PCU, system:PCU);
473
474 /* Create one BTS component (we may want more some day) */
475 vc_BTS := RAW_PCU_BTS_CT.create("BTS-" & id);
476 connect(vc_BTS:PCUIF, vc_PCUIF:BTS);
477 connect(vc_BTS:TC, self:BTS);
478
479 /* FIXME: make sure to use parameters from mp_gb_cfg.cell_id in the PCU INFO IND */
480 info_ind := {
481 version := PCU_IF_VERSION,
482 flags := c_PCUIF_Flags_default,
483 trx := valueof(ts_PCUIF_InfoTrxs_def),
484 /* TODO: make this configurable */
485 bsic := 7, mcc := 262, mnc := 42,
486 mnc_3_digits := 0,
487 /* TODO: make this configurable */
488 lac := 13135, rac := 0,
489 nsei := mp_nsconfig.nsei,
490 nse_timer := { 3, 3, 3, 3, 30, 3, 10 },
491 cell_timer := { 3, 3, 3, 3, 3, 10, 3, 10, 3, 10, 3 },
492 cell_id := 20960,
493 repeat_time := 5 * 50,
494 repeat_count := 3,
495 bvci := mp_gb_cfg.bvci,
496 t3142 := 20,
497 t3169 := 5,
498 t3191 := 5,
499 t3193_10ms := 160,
500 t3195 := 5,
501 t3101 := 10,
502 t3103 := 4,
503 t3105 := 8,
504 cv_countdown := 15,
505 dl_tbf_ext := 250 * 10, /* ms */
506 ul_tbf_ext := 250 * 10, /* ms */
507 initial_cs := 2,
508 initial_mcs := 6,
509 nsvci := { mp_nsconfig.nsvci, 0 },
510 local_pprt := { mp_nsconfig.remote_udp_port, 0 },
511 remote_port := { mp_nsconfig.local_udp_port, 0 },
512 remote_ip := { f_inet_haddr(mp_nsconfig.local_ip), '00000000'O }
513 };
514
515 vc_PCUIF.start(f_PCUIF_CT_handler(mp_pcu_sock_path));
516 vc_BTS.start(f_BTS_CT_handler(0, info_ind));
517
518 /* Wait until the BTS is ready (SI13 negotiated) */
519 BTS.receive(tr_RAW_PCU_EV(BTS_EV_SI13_NEGO));
520}
521
Harald Welte9fbcf4b2018-12-07 07:56:52 +0100522
523control {
524 execute( TC_ns_reset() );
525 execute( TC_ns_reset_retrans() );
526 execute( TC_ns_alive() );
527 execute( TC_ns_alive_timeout_reset() );
528 execute( TC_ns_unblock() );
529 execute( TC_ns_unblock_retrans() );
530 execute( TC_ns_full_bringup() );
531 execute( TC_ns_so_block() );
Harald Welte7fd25cf2019-03-21 22:14:02 +0100532
533 execute( TC_pcuif_suspend() );
Harald Welte9fbcf4b2018-12-07 07:56:52 +0100534}
535
536
537
538
539
540
541}