blob: 9cf37b51969f50ab86e97787012c05b7b55f0e33 [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;
Pau Espin Pedrol4536c822019-12-30 13:22:32 +010018import from NS_Types all;
19import from BSSGP_Types all;
20import from UD_Types all;
Pau Espin Pedrol4536c822019-12-30 13:22:32 +010021import from NS_Emulation all;
22import from Native_Functions all;
23import from IPL4asp_Types all;
24import from PCUIF_Types all;
25import from PCUIF_CodecPort all;
Alexander Couzens3c268da2020-09-07 04:25:05 +020026import from RAW_NS all;
Pau Espin Pedrol4536c822019-12-30 13:22:32 +010027
Harald Welte23e27492020-10-09 12:15:18 +020028modulepar {
29 /* tolerate CellID absence/presence in BVC-RESET in violation to spec */
30 boolean mp_tolerate_bvc_reset_cellid := false;
31}
32
Pau Espin Pedrol4536c822019-12-30 13:22:32 +010033type component RAW_PCU_CT {
34 /* PCUIF (we emulate the BTS part) */
35 port PCUIF_CODEC_PT PCU;
36 var ConnectionId g_pcu_conn_id := -1;
37}
38
39type component RAW_Test_CT extends RAW_NS_CT, RAW_PCU_CT {
40}
41
Pau Espin Pedrol4536c822019-12-30 13:22:32 +010042function f_init_pcuif() runs on RAW_PCU_CT {
43 var PCUIF_info_ind info_ind;
44 map(self:PCU, system:PCU);
45
46
47 info_ind := valueof(ts_PCUIF_INFO_default);
48
49 /* Connect the Unix Domain Socket */
50 g_pcu_conn_id := f_pcuif_listen(PCU, mp_pcu_sock_path);
51 PCU.receive(UD_connected:?);
52
53 /* Wait for PCU_VERSION and return INFO_IND */
54 PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_TXT_IND(0, PCU_VERSION, ?)));
Harald Welte5339b2e2020-10-04 22:52:56 +020055 /* 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 +010056 var template PCUIF_Message info_ind_msg := ts_PCUIF_INFO_IND(0, info_ind);
57 PCU.send(t_SD_PCUIF(g_pcu_conn_id, info_ind_msg));
58}
59
60function f_pcuif_tx(template (value) PCUIF_Message msg) runs on RAW_PCU_CT {
61 PCU.send(t_SD_PCUIF(g_pcu_conn_id, msg));
62}
63
Pau Espin Pedrol4536c822019-12-30 13:22:32 +010064/* ensure no matching message is received within 'tout' */
65function f_ensure_no_ns(template PDU_NS ns := ?, integer idx := 0, float tout := 3.0)
66runs on RAW_Test_CT {
67 timer T := tout;
68 T.start;
69 alt {
Alexander Couzensc3165722021-01-11 02:51:45 +010070 [] NSCP[idx].receive(ns) {
Pau Espin Pedrol4536c822019-12-30 13:22:32 +010071 setverdict(fail, "NS-ALIVE from unconfigured (possibly initial) endpoint");
72 }
73 [] T.timeout {
74 setverdict(pass);
75 }
76 }
77}
78
Pau Espin Pedrol4536c822019-12-30 13:22:32 +010079/* test the NS-RESET procedure */
80testcase TC_ns_reset() runs on RAW_Test_CT {
Alexander Couzens2beaa202020-09-11 20:08:41 +020081 f_init_ns_codec(mp_nsconfig);
Pau Espin Pedrol4536c822019-12-30 13:22:32 +010082 f_init_pcuif();
83
84
85 /* Expect inbound NS-RESET procedure */
86 as_rx_ns_reset_ack(oneshot := true);
87 setverdict(pass);
Alexander Couzensc3165722021-01-11 02:51:45 +010088 f_clean_ns_codec();
Pau Espin Pedrol4536c822019-12-30 13:22:32 +010089}
90
91/* ensure NS-RESET are re-transmitted */
92testcase TC_ns_reset_retrans() runs on RAW_Test_CT {
Alexander Couzens2beaa202020-09-11 20:08:41 +020093 f_init_ns_codec(mp_nsconfig);
Pau Espin Pedrol4536c822019-12-30 13:22:32 +010094 f_init_pcuif();
95
96 var integer i;
97 for (i := 0; i < 3; i := i+1) {
Alexander Couzensc3165722021-01-11 02:51:45 +010098 NSCP[0].receive(tr_NS_RESET(NS_CAUSE_OM_INTERVENTION,
99 g_nsconfig.nsvc[0].nsvci, g_nsconfig.nsei));
Pau Espin Pedrol4536c822019-12-30 13:22:32 +0100100 }
101
102 /* Expect inbound NS-RESET procedure */
103 as_rx_ns_reset_ack(oneshot := true);
104 setverdict(pass);
Alexander Couzensc3165722021-01-11 02:51:45 +0100105 f_clean_ns_codec();
Pau Espin Pedrol4536c822019-12-30 13:22:32 +0100106}
107
108/* test the inbound NS-ALIVE procedure after NS-RESET */
109testcase TC_ns_alive() runs on RAW_Test_CT {
Alexander Couzens2beaa202020-09-11 20:08:41 +0200110 f_init_ns_codec(mp_nsconfig);
Pau Espin Pedrol4536c822019-12-30 13:22:32 +0100111 f_init_pcuif();
112
113 /* Expect inbound NS-RESET procedure */
114 as_rx_ns_reset_ack(oneshot := true);
115
Alexander Couzens355ab562020-07-26 22:04:33 +0200116 alt {
Pau Espin Pedrol4536c822019-12-30 13:22:32 +0100117 /* wait for one ALIVE cycle, then ACK any further ALIVE in the background */
Alexander Couzensc3165722021-01-11 02:51:45 +0100118 [] NSCP[0].receive(t_NS_ALIVE) { setverdict(pass); };
119 [] NSCP[0].receive(t_NS_UNBLOCK) { repeat; }
Alexander Couzens355ab562020-07-26 22:04:33 +0200120 }
Alexander Couzensc3165722021-01-11 02:51:45 +0100121 f_clean_ns_codec();
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) { };
Alexander Couzensc3165722021-01-11 02:51:45 +0100135 [] NSCP[0].receive(t_NS_UNBLOCK) { repeat; }
Alexander Couzens355ab562020-07-26 22:04:33 +0200136 }
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); }
Alexander Couzensc3165722021-01-11 02:51:45 +0100141 [] NSCP[0].receive(t_NS_ALIVE) { repeat; }
142 [] NSCP[0].receive(t_NS_UNBLOCK) { repeat; }
Pau Espin Pedrol4536c822019-12-30 13:22:32 +0100143 }
Alexander Couzensc3165722021-01-11 02:51:45 +0100144
145 f_clean_ns_codec();
Pau Espin Pedrol4536c822019-12-30 13:22:32 +0100146}
147
148/* test for NS-RESET/NS-ALIVE/NS-UNBLOCK */
149testcase TC_ns_unblock() runs on RAW_Test_CT {
Alexander Couzens2beaa202020-09-11 20:08:41 +0200150 f_init_ns_codec(mp_nsconfig);
Pau Espin Pedrol4536c822019-12-30 13:22:32 +0100151 f_init_pcuif();
152
153 /* Expect inbound NS-RESET procedure */
154 as_rx_ns_reset_ack(oneshot := true);
155
Alexander Couzens355ab562020-07-26 22:04:33 +0200156 /* keep it alive */
Pau Espin Pedrol4536c822019-12-30 13:22:32 +0100157 activate(as_rx_alive_tx_ack());
158
159 as_rx_ns_unblock_ack(oneshot := true);
160 setverdict(pass);
Alexander Couzensc3165722021-01-11 02:51:45 +0100161 f_clean_ns_codec();
Pau Espin Pedrol4536c822019-12-30 13:22:32 +0100162}
163
164/* test for NS-UNBLOCK re-transmissions */
165testcase TC_ns_unblock_retrans() runs on RAW_Test_CT {
Alexander Couzens2beaa202020-09-11 20:08:41 +0200166 f_init_ns_codec(mp_nsconfig);
Pau Espin Pedrol4536c822019-12-30 13:22:32 +0100167 f_init_pcuif();
168
169 /* Expect inbound NS-RESET procedure */
170 as_rx_ns_reset_ack(oneshot := true);
171
Alexander Couzens355ab562020-07-26 22:04:33 +0200172 /* keep it alive */
Pau Espin Pedrol4536c822019-12-30 13:22:32 +0100173 activate(as_rx_alive_tx_ack());
174
175 /* wait for first NS-UNBLOCK, don't respond */
Alexander Couzensc3165722021-01-11 02:51:45 +0100176 NSCP[0].receive(t_NS_UNBLOCK);
Pau Espin Pedrol4536c822019-12-30 13:22:32 +0100177
178 /* wait for re-transmission of NS-UNBLOCK */
179 as_rx_ns_unblock_ack(oneshot := true);
180 setverdict(pass);
Alexander Couzensc3165722021-01-11 02:51:45 +0100181 f_clean_ns_codec();
Pau Espin Pedrol4536c822019-12-30 13:22:32 +0100182}
183
184/* full bring-up of the Gb link for NS and BSSGP layer up to BVC-FC */
185testcase TC_ns_full_bringup() runs on RAW_Test_CT {
Alexander Couzens2beaa202020-09-11 20:08:41 +0200186 f_init_ns_codec(mp_nsconfig);
Pau Espin Pedrol4536c822019-12-30 13:22:32 +0100187 f_init_pcuif();
188
189 /* Expect inbound NS-RESET procedure */
190 as_rx_ns_reset_ack(oneshot := true);
191
Alexander Couzens355ab562020-07-26 22:04:33 +0200192 /* keep it alive */
Pau Espin Pedrol4536c822019-12-30 13:22:32 +0100193 activate(as_rx_alive_tx_ack());
194
195 as_rx_ns_unblock_ack(oneshot := true);
196
197 f_outgoing_ns_alive();
198
199 /* Expect BVC-RESET for signaling (0) and ptp BVCI */
Harald Welte23e27492020-10-09 12:15:18 +0200200 if (mp_tolerate_bvc_reset_cellid) {
Harald Weltee97e3af2020-10-09 14:56:54 +0200201 as_rx_bvc_reset_tx_ack(0, mp_gb_cfg.bvc[0].cell_id, omit, oneshot := true);
Harald Welte23e27492020-10-09 12:15:18 +0200202 } else {
Harald Weltee97e3af2020-10-09 14:56:54 +0200203 as_rx_bvc_reset_tx_ack(0, omit, omit, oneshot := true);
Harald Welte23e27492020-10-09 12:15:18 +0200204 }
Harald Weltee97e3af2020-10-09 14:56:54 +0200205 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 +0200206 as_rx_bvc_unblock_tx_ack(mp_gb_cfg.bvc[0].bvci, oneshot := true);
Pau Espin Pedrol4536c822019-12-30 13:22:32 +0100207
208 /* wait for one FLOW-CONTROL BVC and then ACK any further in the future */
Harald Welte5339b2e2020-10-04 22:52:56 +0200209 as_rx_bvc_fc_tx_ack(mp_gb_cfg.bvc[0].bvci, oneshot := true);
210 activate(as_rx_bvc_fc_tx_ack(mp_gb_cfg.bvc[0].bvci));
Pau Espin Pedrol4536c822019-12-30 13:22:32 +0100211 setverdict(pass);
Alexander Couzensc3165722021-01-11 02:51:45 +0100212 f_clean_ns_codec();
Pau Espin Pedrol4536c822019-12-30 13:22:32 +0100213}
214
215/* test outbound (SGSN-originated) NS-BLOCK procedure */
216testcase TC_ns_so_block() runs on RAW_Test_CT {
Alexander Couzens2beaa202020-09-11 20:08:41 +0200217 f_init_ns_codec(mp_nsconfig);
Pau Espin Pedrol4536c822019-12-30 13:22:32 +0100218 f_init_pcuif();
219
220 /* Expect inbound NS-RESET procedure */
221 as_rx_ns_reset_ack(oneshot := true);
222
Alexander Couzens355ab562020-07-26 22:04:33 +0200223 /* keep it alive */
Pau Espin Pedrol4536c822019-12-30 13:22:32 +0100224 activate(as_rx_alive_tx_ack());
225
226 as_rx_ns_unblock_ack(oneshot := true);
227
228 f_outgoing_ns_alive();
229
230 f_outgoing_ns_block(NS_CAUSE_EQUIPMENT_FAILURE);
231 setverdict(pass);
Alexander Couzensc3165722021-01-11 02:51:45 +0100232 f_clean_ns_codec();
Pau Espin Pedrol4536c822019-12-30 13:22:32 +0100233}
234
235
236control {
237 execute( TC_ns_reset() );
238 execute( TC_ns_reset_retrans() );
239 execute( TC_ns_alive() );
240 execute( TC_ns_alive_timeout_reset() );
241 execute( TC_ns_unblock() );
242 execute( TC_ns_unblock_retrans() );
243 execute( TC_ns_full_bringup() );
244 execute( TC_ns_so_block() );
245}
246
247}