blob: 5ab5f8d84231f647b90faf9357abb4d992ef715b [file] [log] [blame]
Pau Espin Pedrol8dd59fb2020-04-29 15:08:16 +02001module PCU_Tests_NS {
Pau Espin Pedrol4536c822019-12-30 13:22:32 +01002
3/* 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
13import from General_Types all;
14import from Osmocom_Types all;
Pau Espin Pedrol8dd59fb2020-04-29 15:08:16 +020015import from PCU_Tests all;
Pau Espin Pedrol0e6ed2e2020-04-29 14:33:13 +020016import from SGSN_Components all;
Pau Espin Pedrol4536c822019-12-30 13:22:32 +010017import from Osmocom_Gb_Types all;
18import from NS_CodecPort all;
19import from NS_Types all;
20import from BSSGP_Types all;
21import from UD_Types all;
22import from NS_CodecPort all;
23import from NS_CodecPort_CtrlFunct all;
24import from NS_Emulation all;
25import from Native_Functions all;
26import from IPL4asp_Types all;
27import from PCUIF_Types all;
28import from PCUIF_CodecPort all;
Alexander Couzens3c268da2020-09-07 04:25:05 +020029import from RAW_NS all;
Pau Espin Pedrol4536c822019-12-30 13:22:32 +010030
Harald Welte23e27492020-10-09 12:15:18 +020031modulepar {
32 /* tolerate CellID absence/presence in BVC-RESET in violation to spec */
33 boolean mp_tolerate_bvc_reset_cellid := false;
34}
35
Pau Espin Pedrol4536c822019-12-30 13:22:32 +010036type component RAW_PCU_CT {
37 /* PCUIF (we emulate the BTS part) */
38 port PCUIF_CODEC_PT PCU;
39 var ConnectionId g_pcu_conn_id := -1;
40}
41
42type component RAW_Test_CT extends RAW_NS_CT, RAW_PCU_CT {
43}
44
Pau Espin Pedrol4536c822019-12-30 13:22:32 +010045function f_init_pcuif() runs on RAW_PCU_CT {
46 var PCUIF_info_ind info_ind;
47 map(self:PCU, system:PCU);
48
49
50 info_ind := valueof(ts_PCUIF_INFO_default);
51
52 /* Connect the Unix Domain Socket */
53 g_pcu_conn_id := f_pcuif_listen(PCU, mp_pcu_sock_path);
54 PCU.receive(UD_connected:?);
55
56 /* Wait for PCU_VERSION and return INFO_IND */
57 PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_TXT_IND(0, PCU_VERSION, ?)));
Harald Welte5339b2e2020-10-04 22:52:56 +020058 /* FIXME: make sure to use parameters from mp_gb_cfg.bvc[0].cell_id in the PCU INFO IND */
Pau Espin Pedrol4536c822019-12-30 13:22:32 +010059 var template PCUIF_Message info_ind_msg := ts_PCUIF_INFO_IND(0, info_ind);
60 PCU.send(t_SD_PCUIF(g_pcu_conn_id, info_ind_msg));
61}
62
63function f_pcuif_tx(template (value) PCUIF_Message msg) runs on RAW_PCU_CT {
64 PCU.send(t_SD_PCUIF(g_pcu_conn_id, msg));
65}
66
Pau Espin Pedrol4536c822019-12-30 13:22:32 +010067/* ensure no matching message is received within 'tout' */
68function f_ensure_no_ns(template PDU_NS ns := ?, integer idx := 0, float tout := 3.0)
69runs on RAW_Test_CT {
70 timer T := tout;
71 T.start;
72 alt {
73 [] NSCP[idx].receive(t_NS_RecvFrom(ns)) {
74 setverdict(fail, "NS-ALIVE from unconfigured (possibly initial) endpoint");
75 }
76 [] T.timeout {
77 setverdict(pass);
78 }
79 }
80}
81
Pau Espin Pedrol4536c822019-12-30 13:22:32 +010082/* test the NS-RESET procedure */
83testcase TC_ns_reset() runs on RAW_Test_CT {
Alexander Couzens2beaa202020-09-11 20:08:41 +020084 f_init_ns_codec(mp_nsconfig);
Pau Espin Pedrol4536c822019-12-30 13:22:32 +010085 f_init_pcuif();
86
87
88 /* Expect inbound NS-RESET procedure */
89 as_rx_ns_reset_ack(oneshot := true);
90 setverdict(pass);
91}
92
93/* ensure NS-RESET are re-transmitted */
94testcase TC_ns_reset_retrans() runs on RAW_Test_CT {
Alexander Couzens2beaa202020-09-11 20:08:41 +020095 f_init_ns_codec(mp_nsconfig);
Pau Espin Pedrol4536c822019-12-30 13:22:32 +010096 f_init_pcuif();
97
98 var integer i;
99 for (i := 0; i < 3; i := i+1) {
100 NSCP[0].receive(t_NS_RecvFrom(tr_NS_RESET(NS_CAUSE_OM_INTERVENTION,
101 g_nsconfig[0].nsvci, g_nsconfig[0].nsei)));
102 }
103
104 /* Expect inbound NS-RESET procedure */
105 as_rx_ns_reset_ack(oneshot := true);
106 setverdict(pass);
107}
108
109/* test the inbound NS-ALIVE procedure after NS-RESET */
110testcase TC_ns_alive() runs on RAW_Test_CT {
Alexander Couzens2beaa202020-09-11 20:08:41 +0200111 f_init_ns_codec(mp_nsconfig);
Pau Espin Pedrol4536c822019-12-30 13:22:32 +0100112 f_init_pcuif();
113
114 /* Expect inbound NS-RESET procedure */
115 as_rx_ns_reset_ack(oneshot := true);
116
Alexander Couzens355ab562020-07-26 22:04:33 +0200117 alt {
Pau Espin Pedrol4536c822019-12-30 13:22:32 +0100118 /* wait for one ALIVE cycle, then ACK any further ALIVE in the background */
Alexander Couzens355ab562020-07-26 22:04:33 +0200119 [] NSCP[0].receive(t_NS_RecvFrom(t_NS_ALIVE)) { setverdict(pass); };
120 [] NSCP[0].receive(t_NS_RecvFrom(t_NS_UNBLOCK)) { repeat; }
121 }
Pau Espin Pedrol4536c822019-12-30 13:22:32 +0100122}
123
124/* Test for NS-RESET after NS-ALIVE timeout */
125testcase TC_ns_alive_timeout_reset() runs on RAW_Test_CT {
Alexander Couzens2beaa202020-09-11 20:08:41 +0200126 f_init_ns_codec(mp_nsconfig, guard_secs := 100.0);
Pau Espin Pedrol4536c822019-12-30 13:22:32 +0100127 f_init_pcuif();
128
129 /* Expect inbound NS-RESET procedure */
130 as_rx_ns_reset_ack(oneshot := true);
131
132 /* wait for at least one NS-ALIVE */
Alexander Couzens355ab562020-07-26 22:04:33 +0200133 alt {
134 [] as_rx_alive_tx_ack(oneshot := true) { };
135 [] NSCP[0].receive(t_NS_RecvFrom(t_NS_UNBLOCK)) { repeat; }
136 }
Pau Espin Pedrol4536c822019-12-30 13:22:32 +0100137
138 /* wait for NS-RESET to re-appear, ignoring any NS-ALIVE until then */
139 alt {
140 [] as_rx_ns_reset_ack(oneshot := true) { setverdict(pass); }
141 [] NSCP[0].receive(t_NS_RecvFrom(t_NS_ALIVE)) { repeat; }
Alexander Couzens355ab562020-07-26 22:04:33 +0200142 [] NSCP[0].receive(t_NS_RecvFrom(t_NS_UNBLOCK)) { repeat; }
Pau Espin Pedrol4536c822019-12-30 13:22:32 +0100143 }
144}
145
146/* test for NS-RESET/NS-ALIVE/NS-UNBLOCK */
147testcase TC_ns_unblock() runs on RAW_Test_CT {
Alexander Couzens2beaa202020-09-11 20:08:41 +0200148 f_init_ns_codec(mp_nsconfig);
Pau Espin Pedrol4536c822019-12-30 13:22:32 +0100149 f_init_pcuif();
150
151 /* Expect inbound NS-RESET procedure */
152 as_rx_ns_reset_ack(oneshot := true);
153
Alexander Couzens355ab562020-07-26 22:04:33 +0200154 /* keep it alive */
Pau Espin Pedrol4536c822019-12-30 13:22:32 +0100155 activate(as_rx_alive_tx_ack());
156
157 as_rx_ns_unblock_ack(oneshot := true);
158 setverdict(pass);
159}
160
161/* test for NS-UNBLOCK re-transmissions */
162testcase TC_ns_unblock_retrans() runs on RAW_Test_CT {
Alexander Couzens2beaa202020-09-11 20:08:41 +0200163 f_init_ns_codec(mp_nsconfig);
Pau Espin Pedrol4536c822019-12-30 13:22:32 +0100164 f_init_pcuif();
165
166 /* Expect inbound NS-RESET procedure */
167 as_rx_ns_reset_ack(oneshot := true);
168
Alexander Couzens355ab562020-07-26 22:04:33 +0200169 /* keep it alive */
Pau Espin Pedrol4536c822019-12-30 13:22:32 +0100170 activate(as_rx_alive_tx_ack());
171
172 /* wait for first NS-UNBLOCK, don't respond */
173 NSCP[0].receive(t_NS_RecvFrom(t_NS_UNBLOCK));
174
175 /* wait for re-transmission of NS-UNBLOCK */
176 as_rx_ns_unblock_ack(oneshot := true);
177 setverdict(pass);
178}
179
180/* full bring-up of the Gb link for NS and BSSGP layer up to BVC-FC */
181testcase TC_ns_full_bringup() runs on RAW_Test_CT {
Alexander Couzens2beaa202020-09-11 20:08:41 +0200182 f_init_ns_codec(mp_nsconfig);
Pau Espin Pedrol4536c822019-12-30 13:22:32 +0100183 f_init_pcuif();
184
185 /* Expect inbound NS-RESET procedure */
186 as_rx_ns_reset_ack(oneshot := true);
187
Alexander Couzens355ab562020-07-26 22:04:33 +0200188 /* keep it alive */
Pau Espin Pedrol4536c822019-12-30 13:22:32 +0100189 activate(as_rx_alive_tx_ack());
190
191 as_rx_ns_unblock_ack(oneshot := true);
192
193 f_outgoing_ns_alive();
194
195 /* Expect BVC-RESET for signaling (0) and ptp BVCI */
Harald Welte23e27492020-10-09 12:15:18 +0200196 if (mp_tolerate_bvc_reset_cellid) {
Harald Welte5339b2e2020-10-04 22:52:56 +0200197 as_rx_bvc_reset_tx_ack(0, mp_gb_cfg.bvc[0].cell_id, oneshot := true);
Harald Welte23e27492020-10-09 12:15:18 +0200198 } else {
199 as_rx_bvc_reset_tx_ack(0, omit, oneshot := true);
200 }
Harald Welte5339b2e2020-10-04 22:52:56 +0200201 as_rx_bvc_reset_tx_ack(mp_gb_cfg.bvc[0].bvci, mp_gb_cfg.bvc[0].cell_id, oneshot := true);
202 as_rx_bvc_unblock_tx_ack(mp_gb_cfg.bvc[0].bvci, oneshot := true);
Pau Espin Pedrol4536c822019-12-30 13:22:32 +0100203
204 /* wait for one FLOW-CONTROL BVC and then ACK any further in the future */
Harald Welte5339b2e2020-10-04 22:52:56 +0200205 as_rx_bvc_fc_tx_ack(mp_gb_cfg.bvc[0].bvci, oneshot := true);
206 activate(as_rx_bvc_fc_tx_ack(mp_gb_cfg.bvc[0].bvci));
Pau Espin Pedrol4536c822019-12-30 13:22:32 +0100207 setverdict(pass);
208}
209
210/* test outbound (SGSN-originated) NS-BLOCK procedure */
211testcase TC_ns_so_block() runs on RAW_Test_CT {
Alexander Couzens2beaa202020-09-11 20:08:41 +0200212 f_init_ns_codec(mp_nsconfig);
Pau Espin Pedrol4536c822019-12-30 13:22:32 +0100213 f_init_pcuif();
214
215 /* Expect inbound NS-RESET procedure */
216 as_rx_ns_reset_ack(oneshot := true);
217
Alexander Couzens355ab562020-07-26 22:04:33 +0200218 /* keep it alive */
Pau Espin Pedrol4536c822019-12-30 13:22:32 +0100219 activate(as_rx_alive_tx_ack());
220
221 as_rx_ns_unblock_ack(oneshot := true);
222
223 f_outgoing_ns_alive();
224
225 f_outgoing_ns_block(NS_CAUSE_EQUIPMENT_FAILURE);
226 setverdict(pass);
227}
228
229
230control {
231 execute( TC_ns_reset() );
232 execute( TC_ns_reset_retrans() );
233 execute( TC_ns_alive() );
234 execute( TC_ns_alive_timeout_reset() );
235 execute( TC_ns_unblock() );
236 execute( TC_ns_unblock_retrans() );
237 execute( TC_ns_full_bringup() );
238 execute( TC_ns_so_block() );
239}
240
241}