blob: eea8d3f5f8ef0f40316c8cc3e9be11fe13490a5c [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;
Alexander Couzens80942542021-04-06 15:53:10 +020015import from Osmocom_VTY_Functions all;
16import from TELNETasp_PortType all;
Pau Espin Pedrol8dd59fb2020-04-29 15:08:16 +020017import from PCU_Tests all;
Pau Espin Pedrol0e6ed2e2020-04-29 14:33:13 +020018import from SGSN_Components all;
Pau Espin Pedrol4536c822019-12-30 13:22:32 +010019import from Osmocom_Gb_Types all;
Pau Espin Pedrol4536c822019-12-30 13:22:32 +010020import from NS_Types all;
21import from BSSGP_Types all;
22import from UD_Types all;
Pau Espin Pedrol4536c822019-12-30 13:22:32 +010023import from NS_Emulation all;
24import from Native_Functions all;
25import from IPL4asp_Types all;
26import from PCUIF_Types all;
27import from PCUIF_CodecPort all;
Alexander Couzens3c268da2020-09-07 04:25:05 +020028import from RAW_NS all;
Pau Espin Pedrol4536c822019-12-30 13:22:32 +010029
30type component RAW_PCU_CT {
31 /* PCUIF (we emulate the BTS part) */
32 port PCUIF_CODEC_PT PCU;
33 var ConnectionId g_pcu_conn_id := -1;
Alexander Couzens80942542021-04-06 15:53:10 +020034 /* VTY connection to the PCU */
35 port TELNETasp_PT PCUVTY;
Pau Espin Pedrol4536c822019-12-30 13:22:32 +010036}
37
38type component RAW_Test_CT extends RAW_NS_CT, RAW_PCU_CT {
39}
40
Alexander Couzens80942542021-04-06 15:53:10 +020041function f_init_vty(charstring id) runs on RAW_PCU_CT {
42 map(self:PCUVTY, system:PCUVTY);
43 f_vty_set_prompts(PCUVTY);
44 f_vty_transceive(PCUVTY, "enable");
45}
46
Pau Espin Pedrol4536c822019-12-30 13:22:32 +010047function f_init_pcuif() runs on RAW_PCU_CT {
48 var PCUIF_info_ind info_ind;
49 map(self:PCU, system:PCU);
50
51
52 info_ind := valueof(ts_PCUIF_INFO_default);
53
54 /* Connect the Unix Domain Socket */
55 g_pcu_conn_id := f_pcuif_listen(PCU, mp_pcu_sock_path);
56 PCU.receive(UD_connected:?);
57
58 /* Wait for PCU_VERSION and return INFO_IND */
59 PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_TXT_IND(0, PCU_VERSION, ?)));
Harald Welte5339b2e2020-10-04 22:52:56 +020060 /* 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 +010061 var template PCUIF_Message info_ind_msg := ts_PCUIF_INFO_IND(0, info_ind);
62 PCU.send(t_SD_PCUIF(g_pcu_conn_id, info_ind_msg));
63}
64
65function f_pcuif_tx(template (value) PCUIF_Message msg) runs on RAW_PCU_CT {
66 PCU.send(t_SD_PCUIF(g_pcu_conn_id, msg));
67}
68
Pau Espin Pedrol4536c822019-12-30 13:22:32 +010069/* ensure no matching message is received within 'tout' */
70function f_ensure_no_ns(template PDU_NS ns := ?, integer idx := 0, float tout := 3.0)
71runs on RAW_Test_CT {
72 timer T := tout;
73 T.start;
74 alt {
Alexander Couzensc3165722021-01-11 02:51:45 +010075 [] NSCP[idx].receive(ns) {
Pau Espin Pedrol4536c822019-12-30 13:22:32 +010076 setverdict(fail, "NS-ALIVE from unconfigured (possibly initial) endpoint");
77 }
78 [] T.timeout {
79 setverdict(pass);
80 }
81 }
82}
83
Pau Espin Pedrol4536c822019-12-30 13:22:32 +010084/* test the NS-RESET procedure */
85testcase TC_ns_reset() runs on RAW_Test_CT {
Alexander Couzens2beaa202020-09-11 20:08:41 +020086 f_init_ns_codec(mp_nsconfig);
Pau Espin Pedrol4536c822019-12-30 13:22:32 +010087 f_init_pcuif();
88
89
90 /* Expect inbound NS-RESET procedure */
91 as_rx_ns_reset_ack(oneshot := true);
92 setverdict(pass);
Alexander Couzensc3165722021-01-11 02:51:45 +010093 f_clean_ns_codec();
Pau Espin Pedrol4536c822019-12-30 13:22:32 +010094}
95
96/* ensure NS-RESET are re-transmitted */
97testcase TC_ns_reset_retrans() runs on RAW_Test_CT {
Alexander Couzens2beaa202020-09-11 20:08:41 +020098 f_init_ns_codec(mp_nsconfig);
Pau Espin Pedrol4536c822019-12-30 13:22:32 +010099 f_init_pcuif();
100
101 var integer i;
102 for (i := 0; i < 3; i := i+1) {
Alexander Couzensc3165722021-01-11 02:51:45 +0100103 NSCP[0].receive(tr_NS_RESET(NS_CAUSE_OM_INTERVENTION,
104 g_nsconfig.nsvc[0].nsvci, g_nsconfig.nsei));
Pau Espin Pedrol4536c822019-12-30 13:22:32 +0100105 }
106
107 /* Expect inbound NS-RESET procedure */
108 as_rx_ns_reset_ack(oneshot := true);
109 setverdict(pass);
Alexander Couzensc3165722021-01-11 02:51:45 +0100110 f_clean_ns_codec();
Pau Espin Pedrol4536c822019-12-30 13:22:32 +0100111}
112
113/* test the inbound NS-ALIVE procedure after NS-RESET */
114testcase TC_ns_alive() runs on RAW_Test_CT {
Alexander Couzens2beaa202020-09-11 20:08:41 +0200115 f_init_ns_codec(mp_nsconfig);
Pau Espin Pedrol4536c822019-12-30 13:22:32 +0100116 f_init_pcuif();
117
118 /* Expect inbound NS-RESET procedure */
119 as_rx_ns_reset_ack(oneshot := true);
120
Alexander Couzens355ab562020-07-26 22:04:33 +0200121 alt {
Pau Espin Pedrol4536c822019-12-30 13:22:32 +0100122 /* wait for one ALIVE cycle, then ACK any further ALIVE in the background */
Alexander Couzensc3165722021-01-11 02:51:45 +0100123 [] NSCP[0].receive(t_NS_ALIVE) { setverdict(pass); };
124 [] NSCP[0].receive(t_NS_UNBLOCK) { repeat; }
Alexander Couzens355ab562020-07-26 22:04:33 +0200125 }
Alexander Couzensc3165722021-01-11 02:51:45 +0100126 f_clean_ns_codec();
Pau Espin Pedrol4536c822019-12-30 13:22:32 +0100127}
128
129/* Test for NS-RESET after NS-ALIVE timeout */
130testcase TC_ns_alive_timeout_reset() runs on RAW_Test_CT {
Alexander Couzens2beaa202020-09-11 20:08:41 +0200131 f_init_ns_codec(mp_nsconfig, guard_secs := 100.0);
Pau Espin Pedrol4536c822019-12-30 13:22:32 +0100132 f_init_pcuif();
133
134 /* Expect inbound NS-RESET procedure */
135 as_rx_ns_reset_ack(oneshot := true);
136
137 /* wait for at least one NS-ALIVE */
Alexander Couzens355ab562020-07-26 22:04:33 +0200138 alt {
139 [] as_rx_alive_tx_ack(oneshot := true) { };
Alexander Couzensc3165722021-01-11 02:51:45 +0100140 [] NSCP[0].receive(t_NS_UNBLOCK) { repeat; }
Alexander Couzens355ab562020-07-26 22:04:33 +0200141 }
Pau Espin Pedrol4536c822019-12-30 13:22:32 +0100142
143 /* wait for NS-RESET to re-appear, ignoring any NS-ALIVE until then */
144 alt {
145 [] as_rx_ns_reset_ack(oneshot := true) { setverdict(pass); }
Alexander Couzensc3165722021-01-11 02:51:45 +0100146 [] NSCP[0].receive(t_NS_ALIVE) { repeat; }
147 [] NSCP[0].receive(t_NS_UNBLOCK) { repeat; }
Pau Espin Pedrol4536c822019-12-30 13:22:32 +0100148 }
Alexander Couzensc3165722021-01-11 02:51:45 +0100149
150 f_clean_ns_codec();
Pau Espin Pedrol4536c822019-12-30 13:22:32 +0100151}
152
153/* test for NS-RESET/NS-ALIVE/NS-UNBLOCK */
154testcase TC_ns_unblock() runs on RAW_Test_CT {
Alexander Couzens2beaa202020-09-11 20:08:41 +0200155 f_init_ns_codec(mp_nsconfig);
Pau Espin Pedrol4536c822019-12-30 13:22:32 +0100156 f_init_pcuif();
157
158 /* Expect inbound NS-RESET procedure */
159 as_rx_ns_reset_ack(oneshot := true);
160
Alexander Couzens355ab562020-07-26 22:04:33 +0200161 /* keep it alive */
Pau Espin Pedrol4536c822019-12-30 13:22:32 +0100162 activate(as_rx_alive_tx_ack());
163
164 as_rx_ns_unblock_ack(oneshot := true);
165 setverdict(pass);
Alexander Couzensc3165722021-01-11 02:51:45 +0100166 f_clean_ns_codec();
Pau Espin Pedrol4536c822019-12-30 13:22:32 +0100167}
168
169/* test for NS-UNBLOCK re-transmissions */
170testcase TC_ns_unblock_retrans() runs on RAW_Test_CT {
Alexander Couzens2beaa202020-09-11 20:08:41 +0200171 f_init_ns_codec(mp_nsconfig);
Pau Espin Pedrol4536c822019-12-30 13:22:32 +0100172 f_init_pcuif();
173
174 /* Expect inbound NS-RESET procedure */
175 as_rx_ns_reset_ack(oneshot := true);
176
Alexander Couzens355ab562020-07-26 22:04:33 +0200177 /* keep it alive */
Pau Espin Pedrol4536c822019-12-30 13:22:32 +0100178 activate(as_rx_alive_tx_ack());
179
180 /* wait for first NS-UNBLOCK, don't respond */
Alexander Couzensc3165722021-01-11 02:51:45 +0100181 NSCP[0].receive(t_NS_UNBLOCK);
Pau Espin Pedrol4536c822019-12-30 13:22:32 +0100182
183 /* wait for re-transmission of NS-UNBLOCK */
184 as_rx_ns_unblock_ack(oneshot := true);
185 setverdict(pass);
Alexander Couzensc3165722021-01-11 02:51:45 +0100186 f_clean_ns_codec();
Pau Espin Pedrol4536c822019-12-30 13:22:32 +0100187}
188
189/* full bring-up of the Gb link for NS and BSSGP layer up to BVC-FC */
190testcase TC_ns_full_bringup() runs on RAW_Test_CT {
Alexander Couzens2beaa202020-09-11 20:08:41 +0200191 f_init_ns_codec(mp_nsconfig);
Pau Espin Pedrol4536c822019-12-30 13:22:32 +0100192 f_init_pcuif();
193
194 /* Expect inbound NS-RESET procedure */
195 as_rx_ns_reset_ack(oneshot := true);
196
Alexander Couzens355ab562020-07-26 22:04:33 +0200197 /* keep it alive */
Pau Espin Pedrol4536c822019-12-30 13:22:32 +0100198 activate(as_rx_alive_tx_ack());
199
200 as_rx_ns_unblock_ack(oneshot := true);
201
202 f_outgoing_ns_alive();
203
204 /* Expect BVC-RESET for signaling (0) and ptp BVCI */
Pau Espin Pedroleef46072021-02-26 13:39:43 +0100205 as_rx_bvc_reset_tx_ack(0, omit, omit, oneshot := true);
Harald Weltee97e3af2020-10-09 14:56:54 +0200206 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 +0200207 as_rx_bvc_unblock_tx_ack(mp_gb_cfg.bvc[0].bvci, oneshot := true);
Pau Espin Pedrol4536c822019-12-30 13:22:32 +0100208
209 /* wait for one FLOW-CONTROL BVC and then ACK any further in the future */
Harald Welte5339b2e2020-10-04 22:52:56 +0200210 as_rx_bvc_fc_tx_ack(mp_gb_cfg.bvc[0].bvci, oneshot := true);
211 activate(as_rx_bvc_fc_tx_ack(mp_gb_cfg.bvc[0].bvci));
Pau Espin Pedrol4536c822019-12-30 13:22:32 +0100212 setverdict(pass);
Alexander Couzensc3165722021-01-11 02:51:45 +0100213 f_clean_ns_codec();
Pau Espin Pedrol4536c822019-12-30 13:22:32 +0100214}
215
216/* test outbound (SGSN-originated) NS-BLOCK procedure */
217testcase TC_ns_so_block() runs on RAW_Test_CT {
Alexander Couzens2beaa202020-09-11 20:08:41 +0200218 f_init_ns_codec(mp_nsconfig);
Pau Espin Pedrol4536c822019-12-30 13:22:32 +0100219 f_init_pcuif();
220
221 /* Expect inbound NS-RESET procedure */
222 as_rx_ns_reset_ack(oneshot := true);
223
Alexander Couzens355ab562020-07-26 22:04:33 +0200224 /* keep it alive */
Pau Espin Pedrol4536c822019-12-30 13:22:32 +0100225 activate(as_rx_alive_tx_ack());
226
227 as_rx_ns_unblock_ack(oneshot := true);
228
229 f_outgoing_ns_alive();
230
231 f_outgoing_ns_block(NS_CAUSE_EQUIPMENT_FAILURE);
232 setverdict(pass);
Alexander Couzensc3165722021-01-11 02:51:45 +0100233 f_clean_ns_codec();
Pau Espin Pedrol4536c822019-12-30 13:22:32 +0100234}
235
236
237control {
238 execute( TC_ns_reset() );
239 execute( TC_ns_reset_retrans() );
240 execute( TC_ns_alive() );
241 execute( TC_ns_alive_timeout_reset() );
242 execute( TC_ns_unblock() );
243 execute( TC_ns_unblock_retrans() );
244 execute( TC_ns_full_bringup() );
245 execute( TC_ns_so_block() );
246}
247
248}