blob: 4d2002788f677e9fa616bfe315f472cbfbb315db [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>
Vadim Yanitskiy3e1d3182019-09-11 16:53:45 +020010 * (C) 2019 Vadim Yanitskiy <axilirator@gmail.com>
Harald Welte34b5a952019-05-27 11:54:11 +020011 * All rights reserved.
12 *
13 * Released under the terms of GNU General Public License, Version 2 or
14 * (at your option) any later version.
15 *
16 * SPDX-License-Identifier: GPL-2.0-or-later
17 */
18
Harald Welte9fbcf4b2018-12-07 07:56:52 +010019import from General_Types all;
20import from Osmocom_Types all;
Harald Welte7fd25cf2019-03-21 22:14:02 +010021import from GSM_Types all;
22import from GSM_RR_Types all;
23
Vadim Yanitskiy0eb26622019-09-14 20:35:28 +020024import from RLCMAC_CSN1_Types all;
25import from RLCMAC_Types all;
26
Harald Welte9fbcf4b2018-12-07 07:56:52 +010027import from NS_Types all;
28import from BSSGP_Types all;
29import from Osmocom_Gb_Types all;
30
31import from BSSGP_Emulation all; /* BssgpConfig */
32import from NS_Emulation all; /* NSConfiguration */
33
34import from UD_Types all;
35import from PCUIF_Types all;
36import from PCUIF_CodecPort all;
Vadim Yanitskiyf7d9c0f2019-09-06 00:08:17 +020037import from PCUIF_RAW_Components all;
Harald Welte9fbcf4b2018-12-07 07:56:52 +010038import from IPL4asp_Types all;
39import from NS_CodecPort all;
40import from NS_CodecPort_CtrlFunct all;
41import from Native_Functions all;
42import from PCU_Tests all;
43
44modulepar {
45 charstring mp_pcu_sock_path := PCU_SOCK_DEFAULT;
46}
47
48type component RAW_NS_CT {
49 /* UDP port towards the bottom (IUT) */
Harald Weltebf768242019-02-21 22:19:21 +010050 port NS_CODEC_PT NSCP[4];
51 var ConnectionId g_ns_conn_id[4] := {-1, -1, -1, -1};
52 var NSConfiguration g_nsconfig[4];
Harald Welte9fbcf4b2018-12-07 07:56:52 +010053 timer g_T_guard;
Harald Welteea3c7e92019-03-01 19:34:55 +010054}
Harald Welte9fbcf4b2018-12-07 07:56:52 +010055
Harald Welteea3c7e92019-03-01 19:34:55 +010056type component RAW_PCU_CT {
Harald Welte9fbcf4b2018-12-07 07:56:52 +010057 /* PCUIF (we emulate the BTS part) */
58 port PCUIF_CODEC_PT PCU;
59 var ConnectionId g_pcu_conn_id := -1;
60}
61
Harald Welteea3c7e92019-03-01 19:34:55 +010062type component RAW_Test_CT extends RAW_NS_CT, RAW_PCU_CT {
63}
64
Harald Welte9fbcf4b2018-12-07 07:56:52 +010065private altstep as_Tguard() runs on RAW_NS_CT {
66 [] g_T_guard.timeout {
67 setverdict(fail, "Timeout of T_guard");
68 mtc.stop;
69 }
70}
71
Harald Welteea3c7e92019-03-01 19:34:55 +010072function f_init_pcuif() runs on RAW_PCU_CT {
Harald Welte9fbcf4b2018-12-07 07:56:52 +010073 map(self:PCU, system:PCU);
74
75 /* Connect the Unix Domain Socket */
76 g_pcu_conn_id := f_pcuif_listen(PCU, mp_pcu_sock_path);
77 PCU.receive(UD_connected:?);
78
79 /* Wait for PCU_VERSION and return INFO_IND */
80 PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_TXT_IND(0, PCU_VERSION, ?)));
81 /* FIXME: make sure to use parameters from mp_gb_cfg.cell_id in the PCU INFO IND */
82 var template PCUIF_Message info_ind := ts_PCUIF_INFO_IND(bts_nr := 0,
83 nsei := mp_nsconfig.nsei,
84 nsvci := mp_nsconfig.nsvci,
85 bvci := mp_gb_cfg.bvci,
86 local_port := mp_nsconfig.remote_udp_port,
87 remote_port := mp_nsconfig.local_udp_port,
88 remote_ip := f_inet_haddr(mp_nsconfig.local_ip)
89 );
90 PCU.send(t_SD_PCUIF(g_pcu_conn_id, info_ind));
91}
92
Harald Welte0466d162019-03-21 21:30:21 +010093function f_pcuif_tx(template (value) PCUIF_Message msg) runs on RAW_PCU_CT {
94 PCU.send(t_SD_PCUIF(g_pcu_conn_id, msg));
95}
96
Harald Weltebf768242019-02-21 22:19:21 +010097function f_init_ns_codec(integer idx := 0, float guard_secs := 60.0) runs on RAW_NS_CT {
Harald Welte9fbcf4b2018-12-07 07:56:52 +010098 var Result res;
Harald Weltebf768242019-02-21 22:19:21 +010099
100 if (not g_T_guard.running) {
101 g_T_guard.start(guard_secs);
102 activate(as_Tguard());
103 }
104
105 if (not isbound(g_nsconfig) or not isbound(g_nsconfig[idx])) {
106 /* copy most parts from mp_nsconfig */
107 g_nsconfig[idx] := mp_nsconfig;
108 /* adjust those parts different for each NS-VC */
109 g_nsconfig[idx].nsvci := mp_nsconfig.nsvci + idx;
110 g_nsconfig[idx].local_udp_port := mp_nsconfig.local_udp_port + idx;
111 }
112
113 map(self:NSCP[idx], system:NSCP);
Harald Welte9fbcf4b2018-12-07 07:56:52 +0100114 /* Connect the UDP socket */
Harald Weltebf768242019-02-21 22:19:21 +0100115 log("connecting NSCP[", idx, "] to ", g_nsconfig[idx]);
116 res := f_IPL4_connect(NSCP[idx], g_nsconfig[idx].remote_ip, g_nsconfig[idx].remote_udp_port,
117 g_nsconfig[idx].local_ip, g_nsconfig[idx].local_udp_port, 0, { udp := {}});
Harald Welte9fbcf4b2018-12-07 07:56:52 +0100118 if (not ispresent(res.connId)) {
Harald Weltebf768242019-02-21 22:19:21 +0100119 setverdict(fail, "Could not connect NS UDP socket, check your configuration ", g_nsconfig[idx]);
Harald Welte9fbcf4b2018-12-07 07:56:52 +0100120 mtc.stop;
121 }
Harald Weltebf768242019-02-21 22:19:21 +0100122 g_ns_conn_id[idx] := res.connId;
123
Harald Welte9fbcf4b2018-12-07 07:56:52 +0100124}
125
Harald Weltebf768242019-02-21 22:19:21 +0100126function 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 +0100127 var NS_RecvFrom nrf;
128 log("f_ns_exp() expecting ", exp_rx);
129 alt {
Harald Weltebf768242019-02-21 22:19:21 +0100130 [] NSCP[idx].receive(t_NS_RecvFrom(exp_rx)) -> value nrf { }
131 [] NSCP[idx].receive {
Harald Welte9fbcf4b2018-12-07 07:56:52 +0100132 setverdict(fail, "Received unexpected NS: ", nrf);
133 mtc.stop;
134 }
135 }
136 return nrf.msg;
137}
138
Harald Welte9fbcf4b2018-12-07 07:56:52 +0100139/* perform outbound NS-ALIVE procedure */
Harald Weltebf768242019-02-21 22:19:21 +0100140function f_outgoing_ns_alive(integer idx := 0) runs on RAW_NS_CT {
141 NSCP[idx].send(t_NS_Send(g_ns_conn_id[idx], t_NS_ALIVE));
Harald Welte9fbcf4b2018-12-07 07:56:52 +0100142 alt {
Harald Weltebf768242019-02-21 22:19:21 +0100143 [] NSCP[idx].receive(t_NS_RecvFrom(t_NS_ALIVE_ACK));
144 [] NSCP[idx].receive { repeat; }
Harald Welte9fbcf4b2018-12-07 07:56:52 +0100145 }
146}
147
Harald Welteecd159e2019-03-16 13:36:07 +0100148/* perform outbound NS-ALIVE procedure */
149function f_outgoing_ns_alive_no_ack(integer idx := 0, float tout := 10.0) runs on RAW_NS_CT {
150 timer T := tout;
151 NSCP[idx].send(t_NS_Send(g_ns_conn_id[idx], t_NS_ALIVE));
152 T.start;
153 alt {
154 [] NSCP[idx].receive(t_NS_RecvFrom(t_NS_ALIVE_ACK)) {
155 setverdict(fail, "Received unexpected NS-ALIVE ACK");
156 }
157 [] NSCP[idx].receive { repeat; }
158 [] T.timeout {
159 setverdict(pass);
160 }
161 }
162}
163
164/* ensure no matching message is received within 'tout' */
165function f_ensure_no_ns(template PDU_NS ns := ?, integer idx := 0, float tout := 3.0)
166runs on RAW_Test_CT {
167 timer T := tout;
168 T.start;
169 alt {
170 [] NSCP[idx].receive(t_NS_RecvFrom(ns)) {
171 setverdict(fail, "NS-ALIVE from unconfigured (possibly initial) endpoint");
172 }
173 [] T.timeout {
174 setverdict(pass);
175 }
176 }
177}
178
Harald Welte9fbcf4b2018-12-07 07:56:52 +0100179/* perform outbound NS-BLOCK procedure */
Harald Weltebf768242019-02-21 22:19:21 +0100180function f_outgoing_ns_block(NsCause cause, integer idx := 0) runs on RAW_NS_CT {
181 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 +0100182 alt {
Harald Weltebf768242019-02-21 22:19:21 +0100183 [] NSCP[idx].receive(t_NS_RecvFrom(tr_NS_BLOCK_ACK(g_nsconfig[idx].nsvci)));
184 [] NSCP[idx].receive { repeat; }
Harald Welte9fbcf4b2018-12-07 07:56:52 +0100185 }
186}
187
188/* receive NS-ALIVE and ACK it */
Harald Weltebf768242019-02-21 22:19:21 +0100189altstep as_rx_alive_tx_ack(boolean oneshot := false, integer idx := 0) runs on RAW_NS_CT {
190 [] NSCP[idx].receive(t_NS_RecvFrom(t_NS_ALIVE)) {
191 NSCP[idx].send(t_NS_Send(g_ns_conn_id[idx], t_NS_ALIVE_ACK));
Harald Welte9fbcf4b2018-12-07 07:56:52 +0100192 if (not oneshot) { repeat; }
193 }
194}
195
Harald Welte64d07312019-03-20 09:48:39 +0100196/* Transmit BSSGP RESET for given BVCI and expect ACK */
197function f_tx_bvc_reset_rx_ack(BssgpBvci bvci, integer idx := 0, boolean exp_ack := true)
198runs on RAW_NS_CT {
199 var PDU_BSSGP bssgp_tx := valueof(ts_BVC_RESET(BSSGP_CAUSE_NET_SV_CAP_MOD_GT_ZERO_KBPS, bvci,
200 mp_gb_cfg.cell_id));
201 timer T := 5.0;
202 NSCP[idx].send(t_NS_Send(g_ns_conn_id[idx], ts_NS_UNITDATA(t_SduCtrlB, 0, enc_PDU_BSSGP(bssgp_tx))));
203 T.start;
204 alt {
205 [exp_ack] NSCP[idx].receive(t_NS_RecvFrom(tr_NS_UNITDATA(t_SduCtrlB, 0,
206 decmatch tr_BVC_RESET_ACK(bvci, ?)))) {
207 setverdict(pass);
208 }
209 [exp_ack] T.timeout {
210 setverdict(fail, "No response to BVC-RESET");
211 }
212 [not exp_ack] T.timeout {
213 setverdict(pass);
214 }
215 [] NSCP[idx].receive { repeat; }
216 }
217}
218
Harald Welte9fbcf4b2018-12-07 07:56:52 +0100219/* Receive a BSSGP RESET for given BVCI and ACK it */
Harald Weltebf768242019-02-21 22:19:21 +0100220altstep 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 +0100221 var NS_RecvFrom ns_rf;
222 /* FIXME: nail down received cell_id in match */
Harald Weltebf768242019-02-21 22:19:21 +0100223 [] NSCP[idx].receive(t_NS_RecvFrom(tr_NS_UNITDATA(t_SduCtrlB, 0,
Harald Welte9fbcf4b2018-12-07 07:56:52 +0100224 decmatch tr_BVC_RESET(?, bvci, ?))))
225 -> value ns_rf {
226 var PDU_BSSGP bssgp_rx := dec_PDU_BSSGP(ns_rf.msg.pDU_NS_Unitdata.nS_SDU);
227 var PDU_BSSGP bssgp_tx := valueof(ts_BVC_RESET_ACK(bvci, mp_gb_cfg.cell_id));
Harald Weltebf768242019-02-21 22:19:21 +0100228 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 +0100229 if (not oneshot) { repeat; }
230 }
231}
232
233
234/* Receive a BSSGP UNBLOCK for given BVCI and ACK it */
Harald Weltebf768242019-02-21 22:19:21 +0100235altstep 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 +0100236 var NS_RecvFrom ns_rf;
Harald Weltebf768242019-02-21 22:19:21 +0100237 [] NSCP[idx].receive(t_NS_RecvFrom(tr_NS_UNITDATA(t_SduCtrlB, 0,
Harald Welte9fbcf4b2018-12-07 07:56:52 +0100238 decmatch t_BVC_UNBLOCK(bvci))))
239 -> value ns_rf {
240 var PDU_BSSGP bssgp_rx := dec_PDU_BSSGP(ns_rf.msg.pDU_NS_Unitdata.nS_SDU);
241 var PDU_BSSGP bssgp_tx := valueof(t_BVC_UNBLOCK_ACK(bvci));
Harald Weltebf768242019-02-21 22:19:21 +0100242 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 +0100243 if (not oneshot) { repeat; }
244 }
245}
246
247/* Receive a BSSGP FLOW-CONTROL-BVC and ACK it */
Harald Weltebf768242019-02-21 22:19:21 +0100248altstep 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 +0100249 var NS_RecvFrom ns_rf;
Harald Weltebf768242019-02-21 22:19:21 +0100250 [] NSCP[idx].receive(t_NS_RecvFrom(tr_NS_UNITDATA(t_SduCtrlB, bvci,
Harald Welte9fbcf4b2018-12-07 07:56:52 +0100251 decmatch tr_BVC_FC_BVC)))
252 -> value ns_rf {
253 var PDU_BSSGP bssgp_rx := dec_PDU_BSSGP(ns_rf.msg.pDU_NS_Unitdata.nS_SDU);
254 var OCT1 tag := bssgp_rx.pDU_BSSGP_FLOW_CONTROL_BVC.tag.unstructured_Value;
255 var PDU_BSSGP bssgp_tx := valueof(t_BVC_FC_BVC_ACK(tag));
Harald Weltebf768242019-02-21 22:19:21 +0100256 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 +0100257 if (not oneshot) { repeat; }
258 }
259}
260
261/**********************************************************************************
262 * Classic Gb/IP bring-up test cases using NS-{RESET,BLOCK,UNBLOCK} and no IP-SNS *
263 **********************************************************************************/
264
265/* Receive a NS-RESET and ACK it */
Harald Weltebf768242019-02-21 22:19:21 +0100266private altstep as_rx_ns_reset_ack(boolean oneshot := false, integer idx := 0) runs on RAW_NS_CT {
Harald Welte9fbcf4b2018-12-07 07:56:52 +0100267 var NS_RecvFrom ns_rf;
Harald Weltebf768242019-02-21 22:19:21 +0100268 [] NSCP[idx].receive(t_NS_RecvFrom(tr_NS_RESET(NS_CAUSE_OM_INTERVENTION, g_nsconfig[idx].nsvci,
269 g_nsconfig[idx].nsei))) -> value ns_rf {
270 NSCP[idx].send(t_NS_Send(g_ns_conn_id[idx], ts_NS_RESET_ACK(g_nsconfig[idx].nsvci,
271 g_nsconfig[idx].nsei)));
Harald Welte9fbcf4b2018-12-07 07:56:52 +0100272 if (not oneshot) { repeat; }
273 }
274}
275/* Receive a NS-UNBLOCK and ACK it */
Harald Weltebf768242019-02-21 22:19:21 +0100276private altstep as_rx_ns_unblock_ack(boolean oneshot := false, integer idx := 0) runs on RAW_NS_CT {
Harald Welte9fbcf4b2018-12-07 07:56:52 +0100277 var NS_RecvFrom ns_rf;
Harald Weltebf768242019-02-21 22:19:21 +0100278 [] NSCP[idx].receive(t_NS_RecvFrom(t_NS_UNBLOCK)) -> value ns_rf {
279 NSCP[idx].send(t_NS_Send(g_ns_conn_id[idx], t_NS_UNBLOCK_ACK));
Harald Welte9fbcf4b2018-12-07 07:56:52 +0100280 if (not oneshot) { repeat; }
281 }
282}
283
284/* test the NS-RESET procedure */
Harald Welteea3c7e92019-03-01 19:34:55 +0100285testcase TC_ns_reset() runs on RAW_Test_CT {
Harald Welte9fbcf4b2018-12-07 07:56:52 +0100286 f_init_ns_codec();
287 f_init_pcuif();
288
289
290 /* Expect inbound NS-RESET procedure */
291 as_rx_ns_reset_ack(oneshot := true);
292 setverdict(pass);
293}
294
295/* ensure NS-RESET are re-transmitted */
Harald Welteea3c7e92019-03-01 19:34:55 +0100296testcase TC_ns_reset_retrans() runs on RAW_Test_CT {
Harald Welte9fbcf4b2018-12-07 07:56:52 +0100297 f_init_ns_codec();
298 f_init_pcuif();
299
300 var integer i;
301 for (i := 0; i < 3; i := i+1) {
Harald Weltebf768242019-02-21 22:19:21 +0100302 NSCP[0].receive(t_NS_RecvFrom(tr_NS_RESET(NS_CAUSE_OM_INTERVENTION,
303 g_nsconfig[0].nsvci, g_nsconfig[0].nsei)));
Harald Welte9fbcf4b2018-12-07 07:56:52 +0100304 }
305
306 /* Expect inbound NS-RESET procedure */
307 as_rx_ns_reset_ack(oneshot := true);
308 setverdict(pass);
309}
310
311/* test the inbound NS-ALIVE procedure after NS-RESET */
Harald Welteea3c7e92019-03-01 19:34:55 +0100312testcase TC_ns_alive() runs on RAW_Test_CT {
Harald Welte9fbcf4b2018-12-07 07:56:52 +0100313 f_init_ns_codec();
314 f_init_pcuif();
315
316 /* Expect inbound NS-RESET procedure */
317 as_rx_ns_reset_ack(oneshot := true);
318
319 /* wait for one ALIVE cycle, then ACK any further ALIVE in the background */
320 as_rx_alive_tx_ack(oneshot := true);
321 setverdict(pass);
322}
323
324/* Test for NS-RESET after NS-ALIVE timeout */
Harald Welteea3c7e92019-03-01 19:34:55 +0100325testcase TC_ns_alive_timeout_reset() runs on RAW_Test_CT {
Harald Weltebf768242019-02-21 22:19:21 +0100326 f_init_ns_codec(guard_secs := 100.0);
Harald Welte9fbcf4b2018-12-07 07:56:52 +0100327 f_init_pcuif();
328
329 /* Expect inbound NS-RESET procedure */
330 as_rx_ns_reset_ack(oneshot := true);
331
332 /* wait for at least one NS-ALIVE */
Harald Weltebf768242019-02-21 22:19:21 +0100333 NSCP[0].receive(t_NS_RecvFrom(t_NS_ALIVE));
Harald Welte9fbcf4b2018-12-07 07:56:52 +0100334
335 /* wait for NS-RESET to re-appear, ignoring any NS-ALIVE until then */
336 alt {
337 [] as_rx_ns_reset_ack(oneshot := true) { setverdict(pass); }
Harald Weltebf768242019-02-21 22:19:21 +0100338 [] NSCP[0].receive(t_NS_RecvFrom(t_NS_ALIVE)) { repeat; }
Harald Welte9fbcf4b2018-12-07 07:56:52 +0100339 }
340}
341
342/* test for NS-RESET/NS-ALIVE/NS-UNBLOCK */
Harald Welteea3c7e92019-03-01 19:34:55 +0100343testcase TC_ns_unblock() runs on RAW_Test_CT {
Harald Welte9fbcf4b2018-12-07 07:56:52 +0100344 f_init_ns_codec();
345 f_init_pcuif();
346
347 /* Expect inbound NS-RESET procedure */
348 as_rx_ns_reset_ack(oneshot := true);
349
350 /* wait for one ALIVE cycle, then ACK any further ALIVE in the background */
351 as_rx_alive_tx_ack(oneshot := true);
352 activate(as_rx_alive_tx_ack());
353
354 as_rx_ns_unblock_ack(oneshot := true);
355 setverdict(pass);
356}
357
358/* test for NS-UNBLOCK re-transmissions */
Harald Welteea3c7e92019-03-01 19:34:55 +0100359testcase TC_ns_unblock_retrans() runs on RAW_Test_CT {
Harald Welte9fbcf4b2018-12-07 07:56:52 +0100360 f_init_ns_codec();
361 f_init_pcuif();
362
363 /* Expect inbound NS-RESET procedure */
364 as_rx_ns_reset_ack(oneshot := true);
365
366 /* wait for one ALIVE cycle, then ACK any further ALIVE in the background */
367 as_rx_alive_tx_ack(oneshot := true);
368 activate(as_rx_alive_tx_ack());
369
370 /* wait for first NS-UNBLOCK, don't respond */
Harald Weltebf768242019-02-21 22:19:21 +0100371 NSCP[0].receive(t_NS_RecvFrom(t_NS_UNBLOCK));
Harald Welte9fbcf4b2018-12-07 07:56:52 +0100372
373 /* wait for re-transmission of NS-UNBLOCK */
374 as_rx_ns_unblock_ack(oneshot := true);
375 setverdict(pass);
376}
377
378/* full bring-up of the Gb link for NS and BSSGP layer up to BVC-FC */
Harald Welteea3c7e92019-03-01 19:34:55 +0100379testcase TC_ns_full_bringup() runs on RAW_Test_CT {
Harald Welte9fbcf4b2018-12-07 07:56:52 +0100380 f_init_ns_codec();
381 f_init_pcuif();
382
383 /* Expect inbound NS-RESET procedure */
384 as_rx_ns_reset_ack(oneshot := true);
385
386 /* wait for one ALIVE cycle, then ACK any further ALIVE in the background */
387 as_rx_alive_tx_ack(oneshot := true);
388 activate(as_rx_alive_tx_ack());
389
390 as_rx_ns_unblock_ack(oneshot := true);
391
392 f_outgoing_ns_alive();
393
394 /* Expect BVC-RESET for signaling (0) and ptp BVCI */
395 as_rx_bvc_reset_tx_ack(0, oneshot := true);
396 as_rx_bvc_reset_tx_ack(mp_gb_cfg.bvci, oneshot := true);
397 as_rx_bvc_unblock_tx_ack(mp_gb_cfg.bvci, oneshot := true);
398
399 /* wait for one FLOW-CONTROL BVC and then ACK any further in the future */
400 as_rx_bvc_fc_tx_ack(mp_gb_cfg.bvci, oneshot := true);
401 activate(as_rx_bvc_fc_tx_ack(mp_gb_cfg.bvci));
402 setverdict(pass);
403}
404
405/* test outbound (SGSN-originated) NS-BLOCK procedure */
Harald Welteea3c7e92019-03-01 19:34:55 +0100406testcase TC_ns_so_block() runs on RAW_Test_CT {
Harald Welte9fbcf4b2018-12-07 07:56:52 +0100407 f_init_ns_codec();
408 f_init_pcuif();
409
410 /* Expect inbound NS-RESET procedure */
411 as_rx_ns_reset_ack(oneshot := true);
412
413 /* wait for one ALIVE cycle, then ACK any further ALIVE in the background */
414 as_rx_alive_tx_ack(oneshot := true);
415 activate(as_rx_alive_tx_ack());
416
417 as_rx_ns_unblock_ack(oneshot := true);
418
419 f_outgoing_ns_alive();
420
421 f_outgoing_ns_block(NS_CAUSE_EQUIPMENT_FAILURE);
422 setverdict(pass);
423}
424
Vadim Yanitskiyf7d9c0f2019-09-06 00:08:17 +0200425type component RAW_PCU_Test_CT extends bssgp_CT {
426 /* Connection to the BTS component (one for now) */
427 port RAW_PCU_MSG_PT BTS;
428 /* Connection to the PCUIF component */
429 port RAW_PCU_MSG_PT PCUIF;
430
431 /* Guard timeout */
432 timer g_T_guard := 60.0;
433};
434
435private altstep as_Tguard_RAW() runs on RAW_PCU_Test_CT {
436 [] g_T_guard.timeout {
437 setverdict(fail, "Timeout of T_guard");
438 mtc.stop;
439 }
440}
441
442private function f_init_raw(charstring id)
443runs on RAW_PCU_Test_CT {
444 var PCUIF_info_ind info_ind;
445 var RAW_PCUIF_CT vc_PCUIF;
446 var RAW_PCU_BTS_CT vc_BTS;
447
448 /* Start the guard timer */
449 g_T_guard.start;
450 activate(as_Tguard_RAW());
451
452 /* Init PCU interface component */
453 vc_PCUIF := RAW_PCUIF_CT.create("PCUIF-" & id);
454 connect(vc_PCUIF:MTC, self:PCUIF);
455 map(vc_PCUIF:PCU, system:PCU);
456
457 /* Create one BTS component (we may want more some day) */
458 vc_BTS := RAW_PCU_BTS_CT.create("BTS-" & id);
459 connect(vc_BTS:PCUIF, vc_PCUIF:BTS);
460 connect(vc_BTS:TC, self:BTS);
461
462 /* FIXME: make sure to use parameters from mp_gb_cfg.cell_id in the PCU INFO IND */
463 info_ind := {
464 version := PCU_IF_VERSION,
465 flags := c_PCUIF_Flags_default,
466 trx := valueof(ts_PCUIF_InfoTrxs_def),
467 /* TODO: make this configurable */
468 bsic := 7, mcc := 262, mnc := 42,
469 mnc_3_digits := 0,
470 /* TODO: make this configurable */
471 lac := 13135, rac := 0,
472 nsei := mp_nsconfig.nsei,
473 nse_timer := { 3, 3, 3, 3, 30, 3, 10 },
474 cell_timer := { 3, 3, 3, 3, 3, 10, 3, 10, 3, 10, 3 },
475 cell_id := 20960,
476 repeat_time := 5 * 50,
477 repeat_count := 3,
478 bvci := mp_gb_cfg.bvci,
479 t3142 := 20,
480 t3169 := 5,
481 t3191 := 5,
482 t3193_10ms := 160,
483 t3195 := 5,
484 t3101 := 10,
485 t3103 := 4,
486 t3105 := 8,
487 cv_countdown := 15,
488 dl_tbf_ext := 250 * 10, /* ms */
489 ul_tbf_ext := 250 * 10, /* ms */
490 initial_cs := 2,
491 initial_mcs := 6,
492 nsvci := { mp_nsconfig.nsvci, 0 },
493 local_pprt := { mp_nsconfig.remote_udp_port, 0 },
494 remote_port := { mp_nsconfig.local_udp_port, 0 },
495 remote_ip := { f_inet_haddr(mp_nsconfig.local_ip), '00000000'O }
496 };
497
498 vc_PCUIF.start(f_PCUIF_CT_handler(mp_pcu_sock_path));
499 vc_BTS.start(f_BTS_CT_handler(0, info_ind));
500
501 /* Wait until the BTS is ready (SI13 negotiated) */
502 BTS.receive(tr_RAW_PCU_EV(BTS_EV_SI13_NEGO));
503}
504
Vadim Yanitskiy3e1d3182019-09-11 16:53:45 +0200505/* FIXME: properly encode RA (see TS 24.060, table 11.2.5.2) */
506private function f_establish_tbf(out GsmRrMessage rr_imm_ass, uint8_t bts_nr := 0,
507 uint16_t ra := oct2int('3A'O), uint8_t is_11bit := 0,
508 PCUIF_BurstType burst_type := BURST_TYPE_0,
509 TimingAdvance ta := 0)
510runs on RAW_PCU_Test_CT return boolean {
511 var PCUIF_Message pcu_msg;
512 var GsmRrMessage rr_msg;
513 var uint32_t fn;
514 timer T;
515
516 /* FIXME: ask the BTS component to give us the current TDMA fn */
517 fn := 1337 + ta;
518
519 /* Send RACH.ind */
520 log("Sending RACH.ind on fn=", fn, " with RA=", ra, ", TA=", ta);
521 BTS.send(ts_PCUIF_RACH_IND(bts_nr := bts_nr,
522 ra := ra, is_11bit := is_11bit,
523 burst_type := burst_type,
524 fn := fn, arfcn := 871,
525 qta := ta * 4));
526
527 /* Expect Immediate (TBF) Assignment on TS0/AGCH */
528 T.start(2.0);
529 alt {
530 [] BTS.receive(tr_PCUIF_DATA_REQ(bts_nr := bts_nr, trx_nr := ?, ts_nr := 0,
531 sapi := PCU_IF_SAPI_AGCH, data := ?))
532 -> value pcu_msg {
533 rr_imm_ass := dec_GsmRrMessage(pcu_msg.u.data_req.data);
534 log("Rx Immediate Assignment: ", rr_imm_ass);
535
536 /* Make sure this assignment is for us
537 * TODO: Uplink or Downlink TBF? */
538 if (match(rr_imm_ass, tr_IMM_TBF_ASS(?, ra, fn))) {
539 setverdict(pass);
540 return true;
541 }
542
543 /* Not for us? Wait for more. */
544 repeat;
545 }
546 [] BTS.receive { repeat; }
547 [] T.timeout {
548 setverdict(fail, "Timeout waiting for Immediate Assignment");
549 }
550 }
551
552 return false;
553}
554
Pau Espin Pedrolc3a77322019-10-03 19:40:08 +0200555/* Enqueue DATA.ind (both TDMA frame and block numbers to be patched) */
556private function f_pcuif_tx_data_ind(octetstring data, int16_t lqual_cb := 0)
557runs on RAW_PCU_Test_CT {
558
559 BTS.send(ts_PCUIF_DATA_IND(bts_nr := 0, trx_nr := 0, ts_nr := 7, block_nr := 0,
560 sapi := PCU_IF_SAPI_PDTCH, data := data,
561 fn := 0, arfcn := 871, lqual_cb := lqual_cb));
562 BTS.receive(tr_RAW_PCU_EV(TDMA_EV_PDTCH_BLOCK_SENT));
563}
564
565/* Enqueue RTS.req, expect DATA.req with UL ACK from the PCU */
566private function f_pcuif_rx_data_req(out PCUIF_Message pcu_msg)
567runs on RAW_PCU_Test_CT {
568 BTS.send(ts_PCUIF_RTS_REQ(bts_nr := 0, trx_nr := 0, ts_nr := 7,
569 sapi := PCU_IF_SAPI_PDTCH, fn := 0,
570 arfcn := 871, block_nr := 0));
571 BTS.receive(tr_PCUIF_DATA_REQ(bts_nr := 0, trx_nr := 0, ts_nr := 7,
572 sapi := PCU_IF_SAPI_PDTCH)) -> value pcu_msg;
573}
574
575private function f_tx_rlcmac_ul_block(template (value) RlcmacUlBlock ul_data, int16_t lqual_cb := 0)
576runs on RAW_PCU_Test_CT {
577 var octetstring data;
578 /* Encode the payload of DATA.ind */
579 data := enc_RlcmacUlBlock(valueof(ul_data));
580 data := f_pad_oct(data, 23, '00'O); /* CS-1 */
581
582 /* Enqueue DATA.ind (both TDMA frame and block numbers to be patched) */
583 f_pcuif_tx_data_ind(data, lqual_cb);
584}
585
586private function f_rx_rlcmac_dl_block(out RlcmacDlBlock dl_block)
587runs on RAW_PCU_Test_CT {
588 var PCUIF_Message pcu_msg;
589 f_pcuif_rx_data_req(pcu_msg);
590 dl_block := dec_RlcmacDlBlock(pcu_msg.u.data_req.data);
591}
592
593private function f_rx_rlcmac_dl_block_exp_ack_nack(out RlcmacDlBlock dl_block)
594runs on RAW_PCU_Test_CT {
595 f_rx_rlcmac_dl_block(dl_block);
596 if (not match(dl_block, tr_RLCMAC_ACK_NACK(ul_tfi := ?, tlli := ?))) {
597 setverdict(fail, "Failed to match Packet Uplink ACK / NACK");
598 mtc.stop;
599 }
600}
601
Vadim Yanitskiy740ae762019-09-29 16:13:41 +0700602testcase TC_pcuif_suspend() runs on RAW_PCU_Test_CT {
603 var octetstring ra_id := enc_RoutingAreaIdentification(mp_gb_cfg.cell_id.ra_id);
604 var GprsTlli tlli := 'FFFFFFFF'O;
605 timer T;
606
607 /* Initialize NS/BSSGP side */
608 f_init_bssgp();
609
610 /* Initialize the PCU interface abstraction */
611 f_init_raw(testcasename());
612
613 /* Establish BSSGP connection to the PCU */
614 f_bssgp_establish();
615
616 BTS.send(ts_PCUIF_SUSP_REQ(0, tlli, ra_id, 0));
617
618 T.start(2.0);
619 alt {
620 [] BSSGP_SIG[0].receive(tr_BSSGP_SUSPEND(tlli, mp_gb_cfg.cell_id.ra_id)) {
621 setverdict(pass);
622 }
623 [] T.timeout {
624 setverdict(fail, "Timeout waiting for BSSGP SUSPEND");
625 }
626 }
627}
628
Vadim Yanitskiy3e1d3182019-09-11 16:53:45 +0200629/* Test of correct Timing Advance at the time of TBF establishment
630 * (derived from timing offset of the Access Burst). */
631testcase TC_ta_rach_imm_ass() runs on RAW_PCU_Test_CT {
632 var GsmRrMessage rr_msg;
633 var boolean ok;
634
635 /* Initialize the PCU interface abstraction */
636 f_init_raw(testcasename());
637
638 /* We cannot send too many TBF requests in a short time because
639 * at some point the PCU will fail to allocate a new TBF. */
640 for (var TimingAdvance ta := 0; ta < 64; ta := ta + 16) {
641 /* Establish an Uplink TBF (send RACH.ind with current TA) */
642 ok := f_establish_tbf(rr_msg, bts_nr := 0, ta := ta);
643 if (not ok) {
644 setverdict(fail, "Failed to establish an Uplink TBF");
645 mtc.stop;
646 }
647
648 /* Make sure Timing Advance IE matches out expectations */
649 if (match(rr_msg, tr_IMM_TBF_ASS(dl := false, ta := ta))) {
650 setverdict(pass);
651 }
652 }
653}
654
Vadim Yanitskiy1f72b0a2019-10-01 05:58:45 +0700655/* Verify that the PCU generates valid PTCCH/D messages
656 * while neither Uplink nor Downlink TBF is established. */
657testcase TC_ta_ptcch_idle() runs on RAW_PCU_Test_CT {
658 var PTCCHDownlinkMsg ptcch_msg;
659 var PCUIF_Message pcu_msg;
660 timer T;
661
662 /* Initialize the PCU interface abstraction */
663 f_init_raw(testcasename());
664
665 /* Sent an RTS.req for PTCCH/D */
666 BTS.send(ts_PCUIF_RTS_REQ(bts_nr := 0, trx_nr := 0, ts_nr := 7,
667 sapi := PCU_IF_SAPI_PTCCH, fn := 0,
668 arfcn := 871, block_nr := 0));
669 T.start(5.0);
670 alt {
671 [] BTS.receive(tr_PCUIF_DATA_REQ(bts_nr := 0, trx_nr := 0, ts_nr := 7,
672 sapi := PCU_IF_SAPI_PTCCH)) -> value pcu_msg {
673 log("Rx DATA.req message: ", pcu_msg);
674 setverdict(pass);
675 }
676 [] BTS.receive(PCUIF_Message:?) { repeat; }
677 [] T.timeout {
678 setverdict(fail, "Timeout waiting for a PTCCH/D block");
679 mtc.stop;
680 }
681 }
682
683 ptcch_msg := dec_PTCCHDownlinkMsg(pcu_msg.u.data_req.data);
684 log("Decoded PTCCH/D message: ", ptcch_msg);
685
686 /* Make sure the message is encoded correctly
687 * TODO: do we expect all TA values to be equal '1111111'B? */
688 if (not match(ptcch_msg, tr_PTCCHDownlinkMsg)) {
689 setverdict(fail, "Malformed PTCCH/D message");
690 mtc.stop;
691 }
692}
693
Vadim Yanitskiy02f77d82019-10-04 17:12:35 +0700694/* Test of correct Timing Advance during an active Uplink TBF.
695 *
696 * Unlike the circuit-switched domain, Uplink transmissions on PDCH time-slots
697 * are not continuous and there can be long time gaps between them. This happens
698 * due to a bursty nature of packet data. The actual Timing Advance of a MS may
699 * significantly change between such rare Uplink transmissions, so GPRS introduces
700 * additional mechanisms to control Timing Advance, and thus reduce interference
701 * between neighboring TDMA time-slots.
702 *
703 * At the moment of Uplink TBF establishment, initial Timing Advance is measured
704 * from ToA (Timing of Arrival) of an Access Burst. This is covered by another
705 * test case - TC_ta_rach_imm_ass. In response to that Access Burst the network
706 * sends Immediate Assignment on AGCH, which _may_ contain Timing Advance Index
707 * among with the initial Timing Advance value. And here PTCCH comes to play.
708 *
709 * PTCCH is a unidirectional channel on which the network can instruct a sub-set
710 * of 16 MS (whether TBFs are active or not) to adjust their Timing Advance
711 * continuously. To ensure continuous measurements of the signal propagation
712 * delay, the MSs shall transmit Access Bursts on Uplink (PTCCH/U) on sub-slots
713 * defined by an assigned Timing Advance Index (see 3GPP TS 45.002).
714 *
715 * The purpose of this test case is to verify the assignment of Timing Advance
716 * Index, and the process of Timing Advance notification on PTCCH/D. The MTC
717 * first establishes several Uplink TBFs, but does not transmit any Uplink
718 * blocks on them. During 4 TDMA multi-frame periods the MTC is sending RACH
719 * indications to the PCU, checking the correctness of two received PTCCH/D
720 * messages (period of PTCCH/D is two multi-frames).
721 */
722private altstep as_ta_ptcch(uint8_t bts_nr := 0, integer toa_factor := 0)
723runs on RAW_PCU_Test_CT {
724 var integer counter := 0;
725 var RAW_PCU_Event event;
726
727 /* Send Access Bursts on PTCCH/U for every TA Index */
728 [] BTS.receive(tr_RAW_PCU_EV(TDMA_EV_PTCCH_UL_BURST)) -> value event {
729 log("Sending an Access Burst on PTCCH/U",
730 ", fn=", event.data.tdma_fn,
731 ", ToA=", counter * toa_factor);
732 /* TODO: do we care about RA and burst format? */
733 BTS.send(ts_PCUIF_RACH_IND(bts_nr := bts_nr,
734 ra := oct2int('3A'O),
735 is_11bit := 0,
736 burst_type := BURST_TYPE_0,
737 fn := event.data.tdma_fn,
738 arfcn := 871,
739 qta := counter * toa_factor * 4,
740 sapi := PCU_IF_SAPI_PTCCH));
741 counter := counter + 1;
742 repeat;
743 }
744}
745
746private function f_TC_ta_ptcch_ul_multi_tbf(template PTCCHDownlinkMsg t_ta_msg)
747runs on RAW_PCU_Test_CT {
748 var PTCCHDownlinkMsg ta_msg;
749 var PCUIF_Message pcu_msg;
750 timer T;
751
752 /* First, send an RTS.req for the upcoming PTCCH/D block */
753 BTS.send(ts_PCUIF_RTS_REQ(bts_nr := 0, trx_nr := 0, ts_nr := 7,
754 sapi := PCU_IF_SAPI_PTCCH, fn := 0,
755 arfcn := 871, block_nr := 0));
756 T.start(2.0);
757 alt {
758 /* Keep sending of Access Bursts during two multi-frames (period of PTCCH/D)
759 * with increasing ToA (Timing of Arrival) values: 0, 7, 14, 28, 35... */
760 [] as_ta_ptcch(bts_nr := 0, toa_factor := 7);
761 /* In the end of 2nd multi-frame we should receive a PTCCH/D block */
762 [] BTS.receive(tr_PCUIF_DATA_REQ(bts_nr := 0, trx_nr := 0, ts_nr := 7,
763 sapi := PCU_IF_SAPI_PTCCH)) -> value pcu_msg {
764 ta_msg := dec_PTCCHDownlinkMsg(pcu_msg.u.data_req.data);
765 log("Rx PTCCH/D message: ", ta_msg);
766
767 /* Make sure Timing Advance values match our expectations */
768 if (match(ta_msg, t_ta_msg)) {
769 setverdict(pass);
770 } else {
771 setverdict(fail, "PTCCH/D message does not match: ", t_ta_msg);
772 }
773 }
774 [] BTS.receive { repeat; }
775 [] T.timeout {
776 setverdict(fail, "Timeout waiting for a PTCCH/D block");
777 mtc.stop;
778 }
779 }
780}
781
782testcase TC_ta_ptcch_ul_multi_tbf() runs on RAW_PCU_Test_CT {
783 var template PacketUlAssign t_ul_tbf_ass;
784 var PacketUlAssign ul_tbf_ass[7];
785 var GsmRrMessage rr_msg[7];
786 var boolean ok;
787
788 /* Initialize the PCU interface abstraction */
789 f_init_raw(testcasename());
790
791 /* Enable forwarding of PTCCH/U TDMA events to us */
792 BTS.send(ts_RAW_PCU_CMD(TDMA_CMD_ENABLE_PTCCH_UL_FWD));
793
794 /* Establish 7 Uplink TBFs (USF flag is 3 bits long, '111'B is reserved) */
795 for (var integer i := 0; i < 7; i := i + 1) {
796 ok := f_establish_tbf(rr_msg[i], ta := 0);
797 if (not ok) {
798 setverdict(fail, "Failed to establish an Uplink TBF #", i);
799 mtc.stop;
800 }
801
802 /* Make sure we received an UL TBF Assignment */
803 if (match(rr_msg[i], tr_IMM_TBF_ASS(dl := false, rest := tr_IaRestOctets_ULAss(?)))) {
804 ul_tbf_ass[i] := rr_msg[i].payload.imm_ass.rest_octets.hh.pa.uldl.ass.ul;
805 log("Rx Uplink TBF assignment for #", i, ": ", ul_tbf_ass[i]);
806 } else {
807 setverdict(fail, "Failed to match UL TBF Assignment for #", i);
808 mtc.stop;
809 }
810
811 /* We expect incremental TFI/USF assignment (dynamic allocation) */
812 t_ul_tbf_ass := tr_PacketUlDynAssign(tfi := i, usf := i);
813 if (not match(ul_tbf_ass[i], t_ul_tbf_ass)) {
814 setverdict(fail, "Failed to match Packet Uplink Assignment for #", i);
815 mtc.stop;
816 }
817
818 /* We also expect Timing Advance Index to be a part of the assignment */
819 if (ul_tbf_ass[i].dynamic.ta_index != i) {
820 setverdict(fail, "Failed to match Timing Advance Index for #", i);
821 /* Keep going, the current OsmoPCU does not assign TA Index */
822 }
823 }
824
825 /* Now we have all 7 TBFs established in one-phase access mode,
826 * however we will not be sending any data on them. Instead, we
827 * will be sending RACH.ind on PTCCH/U during 4 multi-frame
828 * periods (TAI 0..8), and then will check two PTCCH/D blocks.
829 *
830 * Why not 4 TBFs at once? Because Uplink is delayed by 3 TDMA
831 * time-slots, so at the moment of scheduling a PTCCH/D block
832 * the PCU has odd number of PTCCH/U Access Bursts received. */
833 f_TC_ta_ptcch_ul_multi_tbf(tr_PTCCHDownlinkMsg(
834 tai0_ta := 7, tai1_ta := 14, tai2_ta := 21,
835 /* Other values are not known (yet) */
836 tai3_ta := ?));
837 f_TC_ta_ptcch_ul_multi_tbf(tr_PTCCHDownlinkMsg(
838 /* Other values are out of our interest */
839 tai0_ta := 7, tai1_ta := 14, tai2_ta := 21,
840 tai3_ta := 28, tai4_ta := 35, tai5_ta := 42,
841 /* Other values are not known (yet) */
842 tai6_ta := ?));
843}
844
Vadim Yanitskiy0eb26622019-09-14 20:35:28 +0200845/* Default link quality adaptation (Coding Scheme) ranges:
846/* CS1: ... 6 dB, CS2: 5 .. 8 dB, CS3: 7 .. 13 db, CS4: 12 ... dB */
847private template integer CS1_lqual_dB_range := (-infinity .. 6);
848private template integer CS2_lqual_dB_range := (5 .. 8);
849private template integer CS3_lqual_dB_range := (7 .. 13);
850private template integer CS4_lqual_dB_range := (12 .. infinity);
851
852testcase TC_cs_lqual_ul_tbf() runs on RAW_PCU_Test_CT {
853 var PacketUlAssign ul_tbf_ass;
854 var RlcmacDlBlock dl_block;
855 var PCUIF_Message pcu_msg;
856 var GsmRrMessage rr_msg;
857 var octetstring data;
858 var boolean ok;
859
860 /* Initialize the PCU interface abstraction */
861 f_init_raw(testcasename());
862
863 /* Establish an Uplink TBF */
864 ok := f_establish_tbf(rr_msg);
865 if (not ok) {
866 setverdict(fail, "Failed to establish an Uplink TBF");
867 mtc.stop;
868 }
869
870 /* Make sure we received an UL TBF Assignment */
Vadim Yanitskiy0eb26622019-09-14 20:35:28 +0200871 if (match(rr_msg, tr_IMM_TBF_ASS(dl := false, rest := tr_IaRestOctets_ULAss(?)))) {
872 ul_tbf_ass := rr_msg.payload.imm_ass.rest_octets.hh.pa.uldl.ass.ul;
873 log("Rx Uplink TBF assignment: ", ul_tbf_ass);
874 setverdict(pass);
875 } else {
876 setverdict(fail, "Failed to match UL TBF Assignment");
877 mtc.stop;
878 }
879
Vadim Yanitskiy6276b6c2019-09-29 19:48:26 +0700880 /* Make sure we have got a TBF with Dynamic Block Allocation */
881 if (ul_tbf_ass.dynamic == omit) {
882 setverdict(fail, "Single Block Allocation is not handled by ", testcasename());
883 mtc.stop;
884 }
885
Vadim Yanitskiy0eb26622019-09-14 20:35:28 +0200886 var template (value) RlcmacUlBlock ul_data := t_RLCMAC_UL_DATA(
887 tfi := ul_tbf_ass.dynamic.tfi_assignment,
888 cv := 15, /* 15 UL blocks to be sent (to be overridden in loop) */
889 bsn := 0, /* TODO: what should be here? */
890 blocks := { /* To be generated in loop */ });
891
892 /* HACK: patch missing TLLI; otherwise OsmoPCU rejects DATA.req */
893 ul_data.data.tlli := '00000001'O;
894
895 /* 16 UL blocks (0 .. 32 dB, step = 2 dB) */
896 for (var integer i := 0; i < 16; i := i + 1) {
897 /* Prepare a new UL block (CV, random payload) */
898 ul_data.data.mac_hdr.countdown := (15 - i);
899 ul_data.data.blocks := { valueof(t_RLCMAC_LLCBLOCK(f_rnd_octstring(10))) };
900
Vadim Yanitskiy0eb26622019-09-14 20:35:28 +0200901 /* Link quality in dB and our CS1-4 expectations */
902 var integer lqual := i * 2;
903
904 /* Enqueue DATA.ind (both TDMA frame and block numbers to be patched) */
905 log("Sending DATA.ind with link quality (dB): ", lqual);
Pau Espin Pedrolc3a77322019-10-03 19:40:08 +0200906 f_tx_rlcmac_ul_block(ul_data, lqual * 10);
Vadim Yanitskiy0eb26622019-09-14 20:35:28 +0200907
908 /* Enqueue RTS.req, expect DATA.req with UL ACK from the PCU */
Pau Espin Pedrolc3a77322019-10-03 19:40:08 +0200909 f_rx_rlcmac_dl_block_exp_ack_nack(dl_block);
Vadim Yanitskiy0eb26622019-09-14 20:35:28 +0200910
911 log("Rx Packet Uplink ACK / NACK with Channel Coding Command: ",
912 dl_block.ctrl.payload.u.ul_ack_nack.gprs.ch_coding_cmd);
913
914 /* Match the received Channel Coding Command */
915 var template ChCodingCommand ch_coding;
916 select (lqual) {
917 case (CS1_lqual_dB_range) { ch_coding := CH_CODING_CS1; }
918 case (CS2_lqual_dB_range) { ch_coding := CH_CODING_CS2; }
919 case (CS3_lqual_dB_range) { ch_coding := CH_CODING_CS3; }
920 case (CS4_lqual_dB_range) { ch_coding := CH_CODING_CS4; }
921 }
922
923 if (not match(dl_block.ctrl.payload.u.ul_ack_nack.gprs.ch_coding_cmd, ch_coding)) {
924 setverdict(fail, "Channel Coding does not match our expectations: ", ch_coding);
925 } else {
926 setverdict(pass);
927 }
928 }
929}
930
Harald Welte9fbcf4b2018-12-07 07:56:52 +0100931
932control {
933 execute( TC_ns_reset() );
934 execute( TC_ns_reset_retrans() );
935 execute( TC_ns_alive() );
936 execute( TC_ns_alive_timeout_reset() );
937 execute( TC_ns_unblock() );
938 execute( TC_ns_unblock_retrans() );
939 execute( TC_ns_full_bringup() );
940 execute( TC_ns_so_block() );
Harald Welte7fd25cf2019-03-21 22:14:02 +0100941
942 execute( TC_pcuif_suspend() );
Vadim Yanitskiy1f72b0a2019-10-01 05:58:45 +0700943 execute( TC_ta_ptcch_idle() );
Vadim Yanitskiy3e1d3182019-09-11 16:53:45 +0200944 execute( TC_ta_rach_imm_ass() );
Vadim Yanitskiy02f77d82019-10-04 17:12:35 +0700945 execute( TC_ta_ptcch_ul_multi_tbf() );
Vadim Yanitskiy0eb26622019-09-14 20:35:28 +0200946 execute( TC_cs_lqual_ul_tbf() );
Harald Welte9fbcf4b2018-12-07 07:56:52 +0100947}
948
949
950
951
952
953
954}