blob: dce1ef3d2a4f0fba1a45512b6ca55663fd7feef1 [file] [log] [blame]
Daniel Willmann423d8f42020-09-08 18:58:22 +02001module GBProxy_Tests {
2
3/* Osmocom GBProxy test suite in TTCN-3
4 * (C) 2020 sysmocom - s.f.m.c. GmbH
5 * All rights reserved.
6 *
7 * Author: Daniel Willmann <dwillmann@sysmocom.de>
8
9 * Released under the terms of GNU General Public License, Version 2 or
10 * (at your option) any later version.
11 *
12 * SPDX-License-Identifier: GPL-2.0-or-later
13 */
14
15import from General_Types all;
16import from Osmocom_Types all;
17import from GSM_Types all;
18import from Native_Functions all;
19import from NS_Types all;
20import from NS_Emulation all;
21import from BSSGP_Types all;
22import from BSSGP_Emulation all;
23import from SCCPasp_Types all;
24import from Osmocom_Gb_Types all;
25
26import from MobileL3_CommonIE_Types all;
27import from MobileL3_GMM_SM_Types all;
28import from MobileL3_Types all;
29import from L3_Templates all;
30import from L3_Common all;
31
32import from TELNETasp_PortType all;
33import from Osmocom_VTY_Functions all;
34
35import from LLC_Types all;
36import from LLC_Templates all;
37
38import from GSM_RR_Types all;
39
Harald Welte6d63f742020-11-15 19:44:04 +010040/* mcc_mnc is 24.008 10.5.5.15 encoded. 262 42 */
41const BcdMccMnc c_mcc_mnc := '262F42'H;
42
Daniel Willmann423d8f42020-09-08 18:58:22 +020043modulepar {
44 /* IP/port on which we run our internal GSUP/HLR emulation */
Harald Welte6d63f742020-11-15 19:44:04 +010045 NSConfigurations mp_nsconfig_sgsn := {
Daniel Willmann423d8f42020-09-08 18:58:22 +020046 {
Daniel Willmann423d8f42020-09-08 18:58:22 +020047 nsei := 101,
48 role_sgsn := true,
Harald Welte90f19742020-11-06 19:34:40 +010049 handle_sns := false,
50 nsvc := {
51 {
52 provider := {
53 ip := {
54 address_family := AF_INET,
55 local_udp_port := 7777,
56 local_ip := "127.0.0.1",
57 remote_udp_port := 23000,
58 remote_ip := "127.0.0.1"
59 }
60 },
61 nsvci := 101
62 }
63 }
Daniel Willmann423d8f42020-09-08 18:58:22 +020064 }
65 };
Harald Welte6d63f742020-11-15 19:44:04 +010066 NSConfigurations mp_nsconfig_pcu := {
Daniel Willmann423d8f42020-09-08 18:58:22 +020067 {
Daniel Willmann423d8f42020-09-08 18:58:22 +020068 nsei := 96,
69 role_sgsn := false,
Harald Welte90f19742020-11-06 19:34:40 +010070 handle_sns := false,
71 nsvc := {
72 {
73 provider := {
74 ip := {
75 address_family := AF_INET,
76 local_udp_port := 21010,
77 local_ip := "127.0.0.1",
78 remote_udp_port := 23000,
79 remote_ip := "127.0.0.1"
80 }
81 },
82 nsvci := 97
83 }
84 }
Daniel Willmann423d8f42020-09-08 18:58:22 +020085 },
86 {
Daniel Willmann423d8f42020-09-08 18:58:22 +020087 nsei := 97,
88 role_sgsn := false,
Harald Welte90f19742020-11-06 19:34:40 +010089 handle_sns := false,
90 nsvc := {
91 {
92 provider := {
93 ip := {
94 address_family := AF_INET,
95 local_udp_port := 21011,
96 local_ip := "127.0.0.1",
97 remote_udp_port := 23000,
98 remote_ip := "127.0.0.1"
99 }
100 },
101 nsvci := 98
102 }
103 }
Daniel Willmann423d8f42020-09-08 18:58:22 +0200104 },
105 {
Daniel Willmann423d8f42020-09-08 18:58:22 +0200106 nsei := 98,
107 role_sgsn := false,
Harald Welte90f19742020-11-06 19:34:40 +0100108 handle_sns := false,
109 nsvc := {
110 {
111 provider := {
112 ip := {
113 address_family := AF_INET,
114 local_udp_port := 21012,
115 local_ip := "127.0.0.1",
116 remote_udp_port := 23000,
117 remote_ip := "127.0.0.1"
118 }
119 },
120 nsvci := 99
121 }
122 }
Daniel Willmann423d8f42020-09-08 18:58:22 +0200123 }
124 };
Harald Welte6d63f742020-11-15 19:44:04 +0100125 BssgpConfigs mp_gbconfigs := {
126 {
127 nsei := 96,
128 sgsn_role := false,
129 bvc := {
130 {
131 bvci := 196,
132 cell_id := {
133 ra_id := {
134 lai := {
135 mcc_mnc := c_mcc_mnc,
136 lac := 13135
137 },
138 rac := 0
139 },
140 cell_id := 20960
141 },
142 depth := BSSGP_DECODE_DEPTH_BSSGP,
143 create_cb := refers(BSSGP_Emulation.DefaultCreateCallback)
144 }
145 }
146 }, {
147 nsei := 97,
148 sgsn_role := false,
149 bvc := {
150 {
151 bvci := 210,
152 cell_id := {
153 ra_id := {
154 lai := {
155 mcc_mnc := c_mcc_mnc,
Harald Welte0e188242020-11-22 21:46:48 +0100156 lac := 13135
Harald Welte6d63f742020-11-15 19:44:04 +0100157 },
Harald Welte0e188242020-11-22 21:46:48 +0100158 rac := 1
Harald Welte6d63f742020-11-15 19:44:04 +0100159 },
160 cell_id := 20961
161 },
162 depth := BSSGP_DECODE_DEPTH_BSSGP,
163 create_cb := refers(BSSGP_Emulation.DefaultCreateCallback)
164 }
165 }
166 }, {
167 nsei := 98,
168 sgsn_role := false,
169 bvc := {
170 {
171 bvci := 220,
172 cell_id := {
173 ra_id := {
174 lai := {
175 mcc_mnc := c_mcc_mnc,
176 lac := 13300
177 },
178 rac := 0
179 },
180 cell_id := 20962
181 },
182 depth := BSSGP_DECODE_DEPTH_BSSGP,
183 create_cb := refers(BSSGP_Emulation.DefaultCreateCallback)
184 }
185 }
186 }
187 }
Daniel Willmann423d8f42020-09-08 18:58:22 +0200188};
189
Daniel Willmann423d8f42020-09-08 18:58:22 +0200190type record GbInstance {
191 NS_CT vc_NS,
192 BSSGP_CT vc_BSSGP,
Harald Welte67dc8c22020-11-17 18:32:29 +0100193 BSSGP_BVC_CTs vc_BSSGP_BVC,
Daniel Willmann423d8f42020-09-08 18:58:22 +0200194 BssgpConfig cfg
195};
Harald Welte67dc8c22020-11-17 18:32:29 +0100196type record of BSSGP_BVC_CT BSSGP_BVC_CTs
Daniel Willmann423d8f42020-09-08 18:58:22 +0200197
198const integer NUM_PCU := 3;
Harald Welte6d63f742020-11-15 19:44:04 +0100199type record of GbInstance GbInstances;
200type record of BssgpConfig BssgpConfigs;
201type record of NSConfiguration NSConfigurations;
202type record of BssgpCellId BssgpCellIds;
Daniel Willmann423d8f42020-09-08 18:58:22 +0200203
204const integer NUM_SGSN := 1;
Daniel Willmann423d8f42020-09-08 18:58:22 +0200205
206type component test_CT {
Harald Welte6d63f742020-11-15 19:44:04 +0100207 var GbInstances g_pcu;
208 var GbInstances g_sgsn;
Daniel Willmann423d8f42020-09-08 18:58:22 +0200209
210 port BSSGP_CT_PROC_PT PROC;
211
Harald Weltefbae83f2020-11-15 23:25:55 +0100212 port BSSGP_BVC_MGMT_PT SGSN_MGMT;
213 port BSSGP_BVC_MGMT_PT PCU_MGMT;
214
Daniel Willmann423d8f42020-09-08 18:58:22 +0200215 port TELNETasp_PT GBPVTY;
216
217 var boolean g_initialized := false;
218 var boolean g_use_echo := false;
219};
220
221type component BSSGP_ConnHdlr {
Harald Welte3dd21b32020-11-17 19:21:00 +0100222 /* array of per-BVC ports on the PCU side */
Daniel Willmann423d8f42020-09-08 18:58:22 +0200223 port BSSGP_PT PCU[NUM_PCU];
224 port BSSGP_PT PCU_SIG[NUM_PCU];
225 port BSSGP_PROC_PT PCU_PROC[NUM_PCU];
Harald Welte3dd21b32020-11-17 19:21:00 +0100226 /* component reference to the component to which we're currently connected */
227 var BSSGP_BVC_CT pcu_ct[NUM_PCU];
Harald Welte0e188242020-11-22 21:46:48 +0100228 /* BSSGP BVC configuration of the component to which we're currently connected */
229 var BssgpBvcConfig pcu_bvc_cfg[NUM_PCU];
Harald Welte3dd21b32020-11-17 19:21:00 +0100230
231 /* array of per-BVC ports on the SGSN side */
Daniel Willmann423d8f42020-09-08 18:58:22 +0200232 port BSSGP_PT SGSN[NUM_SGSN];
233 port BSSGP_PT SGSN_SIG[NUM_SGSN];
234 port BSSGP_PROC_PT SGSN_PROC[NUM_SGSN];
Harald Welte3dd21b32020-11-17 19:21:00 +0100235 /* component reference to the component to which we're currently connected */
236 var BSSGP_BVC_CT sgsn_ct[NUM_PCU];
Daniel Willmann423d8f42020-09-08 18:58:22 +0200237
238 var BSSGP_ConnHdlrPars g_pars;
239 timer g_Tguard;
240 var LLC_Entities llc;
Harald Welte0e188242020-11-22 21:46:48 +0100241
242 var ro_integer g_roi := {};
Daniel Willmann423d8f42020-09-08 18:58:22 +0200243}
244
245type record SGSN_ConnHdlrNetworkPars {
246 boolean expect_ptmsi,
247 boolean expect_auth,
248 boolean expect_ciph
249};
250
251type record BSSGP_ConnHdlrPars {
252 /* IMEI of the simulated ME */
253 hexstring imei,
254 /* IMSI of the simulated MS */
255 hexstring imsi,
256 /* MSISDN of the simulated MS (probably unused) */
257 hexstring msisdn,
258 /* P-TMSI allocated to the simulated MS */
259 OCT4 p_tmsi optional,
260 OCT3 p_tmsi_sig optional,
261 /* TLLI of the simulated MS */
262 OCT4 tlli,
263 OCT4 tlli_old optional,
264 RoutingAreaIdentificationV ra optional,
Harald Welte16357a92020-11-17 18:20:00 +0100265 GbInstances pcu,
Harald Welte3dd21b32020-11-17 19:21:00 +0100266 GbInstances sgsn,
Daniel Willmann423d8f42020-09-08 18:58:22 +0200267 float t_guard
268};
269
270private function f_cellid_to_RAI(in BssgpCellId cell_id) return RoutingAreaIdentificationV {
271 /* mcc_mnc is encoded as of 24.008 10.5.5.15 */
272 var BcdMccMnc mcc_mnc := cell_id.ra_id.lai.mcc_mnc;
273
274 var RoutingAreaIdentificationV ret := {
275 mccDigit1 := mcc_mnc[0],
276 mccDigit2 := mcc_mnc[1],
277 mccDigit3 := mcc_mnc[2],
278 mncDigit3 := mcc_mnc[3],
279 mncDigit1 := mcc_mnc[4],
280 mncDigit2 := mcc_mnc[5],
281 lac := int2oct(cell_id.ra_id.lai.lac, 16),
282 rac := int2oct(cell_id.ra_id.rac, 8)
283 }
284 return ret;
285};
286
287private function f_init_gb_pcu(inout GbInstance gb, charstring id, integer offset) runs on test_CT {
Harald Welteb419d0e2020-11-16 16:45:05 +0100288 var charstring ns_id := id & "-NS(PCU[" & int2str(offset) & "])";
289 var charstring bssgp_id := id & "-BSSGP(PCU[" & int2str(offset) & "])";
290 gb.vc_NS := NS_CT.create(ns_id);
291 gb.vc_BSSGP := BSSGP_CT.create(bssgp_id);
Daniel Willmann423d8f42020-09-08 18:58:22 +0200292 /* connect lower end of BSSGP emulation with NS upper port */
293 connect(gb.vc_BSSGP:BSCP, gb.vc_NS:NS_SP);
294
Harald Welteb419d0e2020-11-16 16:45:05 +0100295 gb.vc_NS.start(NSStart(mp_nsconfig_pcu[offset], ns_id));
296 gb.vc_BSSGP.start(BssgpStart(gb.cfg, bssgp_id));
Daniel Willmann423d8f42020-09-08 18:58:22 +0200297
298 for (var integer i := 0; i < lengthof(gb.cfg.bvc); i := i + 1) {
299 connect(self:PROC, gb.vc_BSSGP:PROC);
300 gb.vc_BSSGP_BVC[i] := f_bssgp_get_bvci_ct(gb.cfg.bvc[i].bvci, PROC);
301 disconnect(self:PROC, gb.vc_BSSGP:PROC);
Harald Weltefbae83f2020-11-15 23:25:55 +0100302 connect(self:PCU_MGMT, gb.vc_BSSGP_BVC[i]:MGMT);
Daniel Willmann423d8f42020-09-08 18:58:22 +0200303 }
304}
305
306private function f_init_gb_sgsn(inout GbInstance gb, charstring id, integer offset) runs on test_CT {
Harald Welteb419d0e2020-11-16 16:45:05 +0100307 var charstring ns_id := id & "-NS(SGSN[" & int2str(offset) & "])";
308 var charstring bssgp_id := id & "-BSSGP(SGSN[" & int2str(offset) & "])";
309 gb.vc_NS := NS_CT.create(ns_id);
310 gb.vc_BSSGP := BSSGP_CT.create(bssgp_id);
Daniel Willmann423d8f42020-09-08 18:58:22 +0200311 /* connect lower end of BSSGP emulation with NS upper port */
312 connect(gb.vc_BSSGP:BSCP, gb.vc_NS:NS_SP);
313
Harald Welteb419d0e2020-11-16 16:45:05 +0100314 gb.vc_NS.start(NSStart(mp_nsconfig_sgsn[offset], ns_id));
315 gb.vc_BSSGP.start(BssgpStart(gb.cfg, bssgp_id));
Daniel Willmann423d8f42020-09-08 18:58:22 +0200316
317 for (var integer i := 0; i < lengthof(gb.cfg.bvc); i := i + 1) {
318 connect(self:PROC, gb.vc_BSSGP:PROC);
319 gb.vc_BSSGP_BVC[i] := f_bssgp_get_bvci_ct(gb.cfg.bvc[i].bvci, PROC);
320 disconnect(self:PROC, gb.vc_BSSGP:PROC);
Harald Weltefbae83f2020-11-15 23:25:55 +0100321 connect(self:SGSN_MGMT, gb.vc_BSSGP_BVC[i]:MGMT);
Daniel Willmann423d8f42020-09-08 18:58:22 +0200322 }
323}
324
325
326private function f_init_vty() runs on test_CT {
327 map(self:GBPVTY, system:GBPVTY);
328 f_vty_set_prompts(GBPVTY);
329 f_vty_transceive(GBPVTY, "enable");
330}
331
Harald Weltefbae83f2020-11-15 23:25:55 +0100332type record of integer ro_integer;
333
334private function ro_integer_contains(ro_integer r, integer x) return boolean {
335 for (var integer j := 0; j < lengthof(r); j := j+1) {
336 if (r[j] == x) {
337 return true;
338 }
339 }
340 return false;
341}
342
Harald Welte6d63f742020-11-15 19:44:04 +0100343function f_init() runs on test_CT {
Harald Weltefbae83f2020-11-15 23:25:55 +0100344 var ro_integer bvci_unblocked := {};
345 var BssgpStatusIndication bsi;
Daniel Willmann423d8f42020-09-08 18:58:22 +0200346 var integer i;
347
348 if (g_initialized == true) {
349 return;
350 }
351 g_initialized := true;
Daniel Willmann423d8f42020-09-08 18:58:22 +0200352
353 g_sgsn[0].cfg := {
Harald Welte6d63f742020-11-15 19:44:04 +0100354 nsei := mp_nsconfig_sgsn[0].nsei,
Daniel Willmann423d8f42020-09-08 18:58:22 +0200355 sgsn_role := true,
Harald Welte6d63f742020-11-15 19:44:04 +0100356 bvc := { }
357 }
358 for (i := 0; i < lengthof(mp_gbconfigs); i := i+1) {
359 g_pcu[i].cfg := mp_gbconfigs[i];
360 /* concatenate all the PCU-side BVCs for the SGSN side */
361 g_sgsn[0].cfg.bvc := g_sgsn[0].cfg.bvc & mp_gbconfigs[i].bvc;
362 }
Daniel Willmann423d8f42020-09-08 18:58:22 +0200363
364 f_init_vty();
Harald Welte6d63f742020-11-15 19:44:04 +0100365 for (i := 0; i < lengthof(mp_nsconfig_sgsn); i := i+1) {
Daniel Willmann443fc572020-11-18 13:26:57 +0100366 f_vty_transceive(GBPVTY, "nsvc nsei " & int2str(g_sgsn[i].cfg.nsei) & " force-unconfigured");
Harald Welteea1ba592020-11-17 18:05:13 +0100367 f_init_gb_sgsn(g_sgsn[i], "GbProxy_Test", i);
Harald Welte6d63f742020-11-15 19:44:04 +0100368 }
Daniel Willmann423d8f42020-09-08 18:58:22 +0200369 f_sleep(4.0);
Harald Welte6d63f742020-11-15 19:44:04 +0100370 for (i := 0; i < lengthof(mp_nsconfig_pcu); i := i+1) {
Harald Welteb419d0e2020-11-16 16:45:05 +0100371 f_init_gb_pcu(g_pcu[i], "GbProxy_Test", i);
Harald Welte6d63f742020-11-15 19:44:04 +0100372 }
Harald Weltefbae83f2020-11-15 23:25:55 +0100373
374 /* wait until all BVC are unblocked on both sides */
Harald Welted2801272020-11-17 19:22:58 +0100375 timer T := 15.0;
Harald Weltefbae83f2020-11-15 23:25:55 +0100376 T.start;
377 alt {
378 [] SGSN_MGMT.receive(BssgpStatusIndication:{*, ?, BVC_S_UNBLOCKED}) -> value bsi {
379 bvci_unblocked := bvci_unblocked & { bsi.bvci };
380 if (lengthof(bvci_unblocked) != lengthof(g_sgsn[0].cfg.bvc)) {
381 repeat;
382 }
383 }
384 [] SGSN_MGMT.receive(BssgpStatusIndication:{*, ?, ?}) {
385 repeat;
386 }
387 [] SGSN_MGMT.receive {
388 setverdict(fail, "Received unexpected message on SGSN_MGMT");
389 mtc.stop;
390 }
391
392 [] PCU_MGMT.receive(BssgpStatusIndication:{*, ?, BVC_S_UNBLOCKED}) -> value bsi {
393 repeat;
394 }
395 [] PCU_MGMT.receive(BssgpStatusIndication:{*, ?, ?}) {
396 repeat;
397 }
398 [] PCU_MGMT.receive(BssgpResetIndication:{0}) {
399 repeat;
400 }
401 [] PCU_MGMT.receive {
402 setverdict(fail, "Received unexpected message on PCU_MGMT");
403 mtc.stop;
404 }
405
406 [] T.timeout {
407 setverdict(fail, "Timeout waiting for unblock of all BVCs");
408 mtc.stop;
409 }
410 }
411
412 /* iterate over list and check all BVCI */
413 for (i := 0; i < lengthof(g_sgsn[0].cfg.bvc); i := i+1) {
414 var BssgpBvci bvci := g_sgsn[0].cfg.bvc[i].bvci;
415 if (not ro_integer_contains(bvci_unblocked, bvci)) {
416 setverdict(fail, "BVCI=", bvci, " was not unblocked during start-up");
417 mtc.stop;
418 }
419 }
Daniel Willmann423d8f42020-09-08 18:58:22 +0200420}
421
422function f_cleanup() runs on test_CT {
423 self.stop;
424}
425
426type function void_fn(charstring id) runs on BSSGP_ConnHdlr;
427
428/* helper function to create, connect and start a BSSGP_ConnHdlr component */
Harald Welte6d63f742020-11-15 19:44:04 +0100429function f_start_handler(void_fn fn, charstring id, GbInstances pcu, GbInstances sgsn, integer imsi_suffix,
Daniel Willmann423d8f42020-09-08 18:58:22 +0200430 float t_guard := 30.0)
431runs on test_CT return BSSGP_ConnHdlr {
432 var BSSGP_ConnHdlr vc_conn;
433
434 var BSSGP_ConnHdlrPars pars := {
435 imei := f_gen_imei(imsi_suffix),
436 imsi := f_gen_imsi(imsi_suffix),
437 msisdn := f_gen_msisdn(imsi_suffix),
438 p_tmsi := omit,
439 p_tmsi_sig := omit,
440 tlli := f_gprs_tlli_random(),
441 tlli_old := omit,
442 ra := omit,
Harald Welte16357a92020-11-17 18:20:00 +0100443 pcu := g_pcu,
Harald Welte3dd21b32020-11-17 19:21:00 +0100444 sgsn := g_sgsn,
Daniel Willmann423d8f42020-09-08 18:58:22 +0200445 t_guard := t_guard
446 };
447
448 vc_conn := BSSGP_ConnHdlr.create(id);
Daniel Willmann423d8f42020-09-08 18:58:22 +0200449
450 vc_conn.start(f_handler_init(fn, id, pars));
451 return vc_conn;
452}
453
Harald Welte3dd21b32020-11-17 19:21:00 +0100454/* Connect the PCU-side per-BVC ports (PCU/PCU_SIG/PCU_PROC) array slot 'port_idx' to specified per-BVC component */
Harald Welte0e188242020-11-22 21:46:48 +0100455private function f_connect_to_pcu_bvc(integer port_idx, integer nse_idx, integer bvc_idx)
456runs on BSSGP_ConnHdlr {
457 var BSSGP_BVC_CT bvc_ct := g_pars.pcu[nse_idx].vc_BSSGP_BVC[bvc_idx]
Harald Welte3dd21b32020-11-17 19:21:00 +0100458 if (PCU[port_idx].checkstate("Connected")) {
459 /* unregister + disconnect from old BVC */
460 f_client_unregister(g_pars.imsi, PCU_PROC[port_idx]);
461 disconnect(self:PCU[port_idx], pcu_ct[port_idx]:BSSGP_SP);
462 disconnect(self:PCU_SIG[port_idx], pcu_ct[port_idx]:BSSGP_SP_SIG);
463 disconnect(self:PCU_PROC[port_idx], pcu_ct[port_idx]:BSSGP_PROC);
464 }
465 /* connect to new BVC and register us */
466 connect(self:PCU[port_idx], bvc_ct:BSSGP_SP);
467 connect(self:PCU_SIG[port_idx], bvc_ct:BSSGP_SP_SIG);
468 connect(self:PCU_PROC[port_idx], bvc_ct:BSSGP_PROC);
469 f_client_register(g_pars.imsi, g_pars.tlli, PCU_PROC[port_idx]);
470 pcu_ct[port_idx] := bvc_ct;
Harald Welte0e188242020-11-22 21:46:48 +0100471 pcu_bvc_cfg[port_idx] := g_pars.pcu[nse_idx].cfg.bvc[bvc_idx];
Harald Welte3dd21b32020-11-17 19:21:00 +0100472}
473
474/* Connect the SGSN-side per-BVC ports (SGSN/SGSN_SIG/SGSN_PROC) array slot 'port_idx' to specified per-BVC component */
475private function f_connect_to_sgsn_bvc(integer port_idx, BSSGP_BVC_CT bvc_ct) runs on BSSGP_ConnHdlr {
476 if (SGSN[port_idx].checkstate("Connected")) {
477 /* unregister + disconnect from old BVC */
478 f_client_unregister(g_pars.imsi, SGSN_PROC[port_idx]);
479 disconnect(self:SGSN[port_idx], sgsn_ct[port_idx]:BSSGP_SP);
480 disconnect(self:SGSN_SIG[port_idx], sgsn_ct[port_idx]:BSSGP_SP_SIG);
481 disconnect(self:SGSN_PROC[port_idx], sgsn_ct[port_idx]:BSSGP_PROC);
482 }
483 /* connect to new BVC and register us */
484 connect(self:SGSN[port_idx], bvc_ct:BSSGP_SP);
485 connect(self:SGSN_SIG[port_idx], bvc_ct:BSSGP_SP_SIG);
486 connect(self:SGSN_PROC[port_idx], bvc_ct:BSSGP_PROC);
487 f_client_register(g_pars.imsi, g_pars.tlli, SGSN_PROC[port_idx]);
488 sgsn_ct[port_idx] := bvc_ct;
489}
490
Daniel Willmann423d8f42020-09-08 18:58:22 +0200491private altstep as_Tguard() runs on BSSGP_ConnHdlr {
492 [] g_Tguard.timeout {
493 setverdict(fail, "Tguard timeout");
494 mtc.stop;
495 }
496}
497
498/* first function called in every ConnHdlr */
499private function f_handler_init(void_fn fn, charstring id, BSSGP_ConnHdlrPars pars)
500runs on BSSGP_ConnHdlr {
Harald Welte1e834f32020-11-15 20:02:59 +0100501 var integer i;
Daniel Willmann423d8f42020-09-08 18:58:22 +0200502 /* do some common stuff like setting up g_pars */
503 g_pars := pars;
504
505 llc := f_llc_create(false);
506
Harald Welte3dd21b32020-11-17 19:21:00 +0100507 /* default connections on PCU side: First BVC of each NSE/PCU */
508 for (i := 0; i < lengthof(g_pars.pcu); i := i+1) {
Harald Welte0e188242020-11-22 21:46:48 +0100509 f_connect_to_pcu_bvc(port_idx := i, nse_idx := i, bvc_idx := 0);
Harald Welte1e834f32020-11-15 20:02:59 +0100510 }
Harald Welte3dd21b32020-11-17 19:21:00 +0100511
512 /* default connections on SGSN side: First BVC of each NSE/SGSN */
513 for (i := 0; i < lengthof(g_pars.sgsn); i := i+1) {
514 f_connect_to_sgsn_bvc(i, g_pars.sgsn[i].vc_BSSGP_BVC[0]);
Harald Welte1e834f32020-11-15 20:02:59 +0100515 }
Daniel Willmann423d8f42020-09-08 18:58:22 +0200516
517 g_Tguard.start(pars.t_guard);
518 activate(as_Tguard());
519
520 /* call the user-supplied test case function */
521 fn.apply(id);
522}
523
Harald Welte1e834f32020-11-15 20:02:59 +0100524private function f_client_register(hexstring imsi, OCT4 tlli, BSSGP_PROC_PT PT)
525runs on BSSGP_ConnHdlr {
526 PT.call(BSSGP_register_client:{imsi, tlli}) {
527 [] PT.getreply(BSSGP_register_client:{imsi, tlli}) {};
528 }
529}
530
531private function f_client_unregister(hexstring imsi, BSSGP_PROC_PT PT)
532runs on BSSGP_ConnHdlr {
533 PT.call(BSSGP_unregister_client:{imsi}) {
534 [] PT.getreply(BSSGP_unregister_client:{imsi}) {};
535 }
536}
537
Harald Welte22ef5d92020-11-16 13:35:14 +0100538/* Send 'tx' on PTP-BVCI from PCU; expect 'rx' on SGSN */
539friend function f_pcu2sgsn(template (value) PDU_BSSGP tx, template (present) PDU_BSSGP exp_rx,
Daniel Willmann4798fd72020-11-24 16:23:29 +0100540 integer pcu_idx := 0, integer sgsn_idx := 0, boolean use_sig := false) runs on BSSGP_ConnHdlr {
Harald Welte22ef5d92020-11-16 13:35:14 +0100541 var PDU_BSSGP rx;
542 timer T := 1.0;
543
Daniel Willmann4798fd72020-11-24 16:23:29 +0100544 if (use_sig) {
545 PCU_SIG[pcu_idx].send(tx);
546 } else {
547 PCU[pcu_idx].send(tx);
548 }
549
Harald Welte22ef5d92020-11-16 13:35:14 +0100550 T.start;
551 alt {
Daniel Willmann4798fd72020-11-24 16:23:29 +0100552 [use_sig] SGSN_SIG[sgsn_idx].receive(exp_rx) {
553 setverdict(pass);
554 }
555 [not use_sig] SGSN[sgsn_idx].receive(exp_rx) {
Harald Welte22ef5d92020-11-16 13:35:14 +0100556 setverdict(pass);
557 }
558 [] SGSN[sgsn_idx].receive(PDU_BSSGP:?) -> value rx {
559 setverdict(fail, "Unexpected BSSGP on SGSN side: ", rx);
560 mtc.stop;
561 }
Daniel Willmann4798fd72020-11-24 16:23:29 +0100562 [] SGSN_SIG[sgsn_idx].receive(PDU_BSSGP:?) -> value rx {
563 setverdict(fail, "Unexpected SIG BSSGP on SGSN side: ", rx);
564 mtc.stop;
565 }
Harald Welte22ef5d92020-11-16 13:35:14 +0100566 [] T.timeout {
567 setverdict(fail, "Timeout waiting for BSSGP on SGSN side: ", rx);
568 mtc.stop;
569 }
570 }
571}
572
573/* Send 'tx' on PTP-BVCI from SGSN; expect 'rx' on PCU */
574friend function f_sgsn2pcu(template (value) PDU_BSSGP tx, template (present) PDU_BSSGP exp_rx,
Daniel Willmann4798fd72020-11-24 16:23:29 +0100575 integer sgsn_idx:= 0, integer pcu_idx := 0, boolean use_sig := false) runs on BSSGP_ConnHdlr {
Harald Welte22ef5d92020-11-16 13:35:14 +0100576 var PDU_BSSGP rx;
577 timer T := 1.0;
578
Daniel Willmann4798fd72020-11-24 16:23:29 +0100579 if (use_sig) {
580 SGSN_SIG[sgsn_idx].send(tx);
581 } else {
582 SGSN[sgsn_idx].send(tx);
583 }
584
Harald Welte22ef5d92020-11-16 13:35:14 +0100585 T.start;
586 alt {
Daniel Willmann4798fd72020-11-24 16:23:29 +0100587 [use_sig] PCU_SIG[pcu_idx].receive(exp_rx) {
588 setverdict(pass);
589 }
590 [not use_sig] PCU[pcu_idx].receive(exp_rx) {
Harald Welte22ef5d92020-11-16 13:35:14 +0100591 setverdict(pass);
592 }
593 [] PCU[pcu_idx].receive(PDU_BSSGP:?) -> value rx {
594 setverdict(fail, "Unexpected BSSGP on PCU side: ", rx);
595 mtc.stop;
596 }
Daniel Willmann4798fd72020-11-24 16:23:29 +0100597 [] PCU_SIG[pcu_idx].receive(PDU_BSSGP:?) -> value rx {
598 setverdict(fail, "Unexpected SIG BSSGP on PCU side: ", rx);
599 mtc.stop;
600 }
Harald Welte22ef5d92020-11-16 13:35:14 +0100601 [] T.timeout {
602 setverdict(fail, "Timeout waiting for BSSGP on PCU side: ", rx);
603 mtc.stop;
604 }
605 }
606}
Harald Welte1e834f32020-11-15 20:02:59 +0100607
Daniel Willmann423d8f42020-09-08 18:58:22 +0200608/* TODO:
609 * Detach without Attach
610 * SM procedures without attach / RAU
611 * ATTACH / RAU
612 ** with / without authentication
613 ** with / without P-TMSI allocation
614 * re-transmissions of LLC frames
615 * PDP Context activation
616 ** with different GGSN config in SGSN VTY
617 ** with different PDP context type (v4/v6/v46)
618 ** timeout from GGSN
619 ** multiple / secondary PDP context
620 */
621
622private function f_TC_BVC_bringup(charstring id) runs on BSSGP_ConnHdlr {
623 f_sleep(5.0);
624 setverdict(pass);
625}
626
627testcase TC_BVC_bringup() runs on test_CT {
628 var BSSGP_ConnHdlr vc_conn;
629 f_init();
630
631 vc_conn := f_start_handler(refers(f_TC_BVC_bringup), testcasename(), g_pcu, g_sgsn, 51);
632 vc_conn.done;
633
634 f_cleanup();
635}
636
637friend function f_bssgp_suspend(integer ran_idx := 0) runs on BSSGP_ConnHdlr return OCT1 {
Harald Welte16357a92020-11-17 18:20:00 +0100638 var BssgpBvcConfig bvcc := g_pars.pcu[ran_idx].cfg.bvc[0];
Daniel Willmann423d8f42020-09-08 18:58:22 +0200639 timer T := 5.0;
640 var PDU_BSSGP rx_pdu;
Harald Welte16357a92020-11-17 18:20:00 +0100641 PCU_SIG[ran_idx].send(ts_BSSGP_SUSPEND(g_pars.tlli, bvcc.cell_id.ra_id));
Daniel Willmann423d8f42020-09-08 18:58:22 +0200642 T.start;
643 alt {
Harald Welte16357a92020-11-17 18:20:00 +0100644 [] PCU_SIG[ran_idx].receive(tr_BSSGP_SUSPEND_ACK(g_pars.tlli, bvcc.cell_id.ra_id, ?)) -> value rx_pdu {
Daniel Willmann423d8f42020-09-08 18:58:22 +0200645 return rx_pdu.pDU_BSSGP_SUSPEND_ACK.suspend_Reference_Number.suspend_Reference_Number_value;
646 }
Harald Welte16357a92020-11-17 18:20:00 +0100647 [] PCU_SIG[ran_idx].receive(tr_BSSGP_SUSPEND_NACK(g_pars.tlli, bvcc.cell_id.ra_id, ?)) -> value rx_pdu {
Daniel Willmann423d8f42020-09-08 18:58:22 +0200648 setverdict(fail, "SUSPEND-NACK in response to SUSPEND for TLLI ", g_pars.tlli);
649 mtc.stop;
650 }
651 [] T.timeout {
652 setverdict(fail, "No SUSPEND-ACK in response to SUSPEND for TLLI ", g_pars.tlli);
653 mtc.stop;
654 }
655 }
656 return '00'O;
657}
658
659friend function f_bssgp_resume(OCT1 susp_ref, integer ran_idx := 0) runs on BSSGP_ConnHdlr {
Harald Welte16357a92020-11-17 18:20:00 +0100660 var BssgpBvcConfig bvcc := g_pars.pcu[ran_idx].cfg.bvc[0];
Daniel Willmann423d8f42020-09-08 18:58:22 +0200661 timer T := 5.0;
Harald Welte16357a92020-11-17 18:20:00 +0100662 PCU_SIG[ran_idx].send(ts_BSSGP_RESUME(g_pars.tlli, bvcc.cell_id.ra_id, susp_ref));
Daniel Willmann423d8f42020-09-08 18:58:22 +0200663 T.start;
664 alt {
Harald Welte16357a92020-11-17 18:20:00 +0100665 [] PCU_SIG[ran_idx].receive(tr_BSSGP_RESUME_ACK(g_pars.tlli, bvcc.cell_id.ra_id));
666 [] PCU_SIG[ran_idx].receive(tr_BSSGP_RESUME_NACK(g_pars.tlli, bvcc.cell_id.ra_id, ?)) {
Daniel Willmann423d8f42020-09-08 18:58:22 +0200667 setverdict(fail, "RESUME-NACK in response to RESUME for TLLI ", g_pars.tlli);
668 mtc.stop;
669 }
670 [] T.timeout {
671 setverdict(fail, "No RESUME-ACK in response to SUSPEND for TLLI ", g_pars.tlli);
672 mtc.stop;
673 }
674 }
675}
676
677
Harald Welte92686012020-11-15 21:45:49 +0100678/* send uplink-unitdata of a variety of different sizes; expect it to show up on SGSN */
679private function f_TC_ul_unitdata(charstring id) runs on BSSGP_ConnHdlr {
Harald Welte16357a92020-11-17 18:20:00 +0100680 var integer ran_idx := 0;
681 var BssgpBvcConfig bvcc := g_pars.pcu[ran_idx].cfg.bvc[0];
Harald Welte92686012020-11-15 21:45:49 +0100682 var integer i;
683
684 for (i := 0; i < 1024; i := i+1) {
685 var octetstring payload := f_rnd_octstring(i);
Harald Welte16357a92020-11-17 18:20:00 +0100686 var template (value) PDU_BSSGP pdu_tx := ts_BSSGP_UL_UD(g_pars.tlli, bvcc.cell_id, payload);
Harald Welte92686012020-11-15 21:45:49 +0100687 /* we cannot use pdu_tx as there are some subtle differences in the length field :/ */
Harald Welte16357a92020-11-17 18:20:00 +0100688 var template (present) PDU_BSSGP pdu_rx := tr_BSSGP_UL_UD(g_pars.tlli, bvcc.cell_id, payload);
Harald Welte92686012020-11-15 21:45:49 +0100689
Harald Welte22ef5d92020-11-16 13:35:14 +0100690 f_pcu2sgsn(pdu_tx, pdu_rx);
Harald Welte92686012020-11-15 21:45:49 +0100691 }
692 setverdict(pass);
693}
694
695testcase TC_ul_unitdata() runs on test_CT
696{
697 var BSSGP_ConnHdlr vc_conn;
698 f_init();
699
700 vc_conn := f_start_handler(refers(f_TC_ul_unitdata), testcasename(), g_pcu, g_sgsn, 1);
701 vc_conn.done;
702 /* TODO: start multiple handlers (UEs) on various cells on same and other NSEs */
703
704 f_cleanup();
705}
706
Harald Welte78d8db92020-11-15 23:27:27 +0100707/* send downlink-unitdata of a variety of different sizes; expect it to show up on PCU */
708private function f_TC_dl_unitdata(charstring id) runs on BSSGP_ConnHdlr {
709 var integer i;
710
711 for (i := 0; i < 1024; i := i+1) {
712 var octetstring payload := f_rnd_octstring(i);
713 var template (value) PDU_BSSGP pdu_tx :=
714 ts_BSSGP_DL_UD(g_pars.tlli, payload, omit, ts_BSSGP_IMSI(g_pars.imsi));
715 /* we cannot use pdu_tx as there are some subtle differences in the length field :/ */
716 var template (present) PDU_BSSGP pdu_rx :=
717 tr_BSSGP_DL_UD(g_pars.tlli, payload, tr_BSSGP_IMSI(g_pars.imsi));
718
Harald Welte22ef5d92020-11-16 13:35:14 +0100719 f_sgsn2pcu(pdu_tx, pdu_rx);
Harald Welte78d8db92020-11-15 23:27:27 +0100720 }
721 setverdict(pass);
722}
723
724testcase TC_dl_unitdata() runs on test_CT
725{
726 var BSSGP_ConnHdlr vc_conn;
727 f_init();
728
729 vc_conn := f_start_handler(refers(f_TC_dl_unitdata), testcasename(), g_pcu, g_sgsn, 2);
730 vc_conn.done;
731 /* TODO: start multiple handlers (UEs) on various cells on same and other NSEs */
732
733 f_cleanup();
734}
Harald Welte92686012020-11-15 21:45:49 +0100735
Harald Welte6dc2ac42020-11-16 09:16:17 +0100736private function f_TC_ra_capability(charstring id) runs on BSSGP_ConnHdlr {
737 var integer i;
738
739 for (i := 0; i < 10; i := i+1) {
740 var template (value) PDU_BSSGP pdu_tx := ts_BSSGP_RA_CAP(g_pars.tlli, { ts_RaCapRec_BSSGP });
741 /* we cannot use pdu_tx as there are some subtle differences in the length field :/ */
742 var template (present) PDU_BSSGP pdu_rx := tr_BSSGP_RA_CAP(g_pars.tlli, { tr_RaCapRec_BSSGP })
743
Harald Welte22ef5d92020-11-16 13:35:14 +0100744 f_sgsn2pcu(pdu_tx, pdu_rx);
Harald Welte6dc2ac42020-11-16 09:16:17 +0100745 }
746 setverdict(pass);
747}
748testcase TC_ra_capability() runs on test_CT
749{
750 var BSSGP_ConnHdlr vc_conn;
751 f_init();
752
753 vc_conn := f_start_handler(refers(f_TC_ra_capability), testcasename(), g_pcu, g_sgsn, 3);
754 vc_conn.done;
755 /* TODO: start multiple handlers (UEs) on various cells on same and other NSEs */
756
757 f_cleanup();
758}
759
Daniel Willmannace3ece2020-11-16 19:53:26 +0100760private function f_TC_ra_capability_upd(charstring id) runs on BSSGP_ConnHdlr {
761 var integer i;
762 var OCT1 tag;
763 for (i := 0; i < 10; i := i+1) {
764 tag := int2oct(23 + i, 1);
765 var template (value) PDU_BSSGP pdu_tx := ts_BSSGP_RA_CAP_UPD(g_pars.tlli, tag);
766 /* we cannot use pdu_tx as there are some subtle differences in the length field :/ */
767 var template (present) PDU_BSSGP pdu_rx := tr_BSSGP_RA_CAP_UPD(g_pars.tlli, tag)
768
769 f_pcu2sgsn(pdu_tx, pdu_rx);
770
771 pdu_tx := ts_BSSGP_RA_CAP_UPD_ACK(g_pars.tlli, tag, '42'O);
772 /* we cannot use pdu_tx as there are some subtle differences in the length field :/ */
773 pdu_rx := tr_BSSGP_RA_CAP_UPD_ACK(g_pars.tlli, tag, '42'O)
774
775 f_sgsn2pcu(pdu_tx, pdu_rx);
776 }
777 setverdict(pass);
778}
779testcase TC_ra_capability_upd() runs on test_CT
780{
781 var BSSGP_ConnHdlr vc_conn;
782 f_init();
783
Daniel Willmann54833f22020-11-19 15:43:52 +0100784 vc_conn := f_start_handler(refers(f_TC_ra_capability_upd), testcasename(), g_pcu, g_sgsn, 4);
Daniel Willmannace3ece2020-11-16 19:53:26 +0100785 vc_conn.done;
786 /* TODO: start multiple handlers (UEs) on various cells on same and other NSEs */
787
788 f_cleanup();
789}
790
Daniel Willmann165d6612020-11-19 14:27:29 +0100791private function f_TC_radio_status(charstring id) runs on BSSGP_ConnHdlr {
792 var integer i;
793 var BssgpRadioCause cause := BSSGP_RADIO_CAUSE_CONTACT_LOST;
794 for (i := 0; i < 10; i := i+1) {
795 var template (value) PDU_BSSGP pdu_tx := ts_BSSGP_RADIO_STATUS(g_pars.tlli, cause);
796 /* we cannot use pdu_tx as there are some subtle differences in the length field :/ */
797 var template (present) PDU_BSSGP pdu_rx := tr_BSSGP_RADIO_STATUS(g_pars.tlli, cause)
798
799 f_pcu2sgsn(pdu_tx, pdu_rx);
800 }
801 setverdict(pass);
802}
803testcase TC_radio_status() runs on test_CT
804{
805 var BSSGP_ConnHdlr vc_conn;
806 f_init();
807
Daniel Willmann54833f22020-11-19 15:43:52 +0100808 vc_conn := f_start_handler(refers(f_TC_radio_status), testcasename(), g_pcu, g_sgsn, 5);
Daniel Willmann165d6612020-11-19 14:27:29 +0100809 vc_conn.done;
810 /* TODO: start multiple handlers (UEs) on various cells on same and other NSEs */
811
812 f_cleanup();
813}
814
Daniel Willmannfa67f492020-11-19 15:48:05 +0100815private function f_TC_suspend(charstring id) runs on BSSGP_ConnHdlr {
816 var integer i;
Daniel Willmann165d6612020-11-19 14:27:29 +0100817
Daniel Willmannfa67f492020-11-19 15:48:05 +0100818 /* TODO: Generate RA ID for each ConnHdlr */
819 var RoutingAreaIdentification ra_id := g_pars.pcu[0].cfg.bvc[0].cell_id.ra_id;
820 for (i := 0; i < 10; i := i+1) {
821
822 var template (value) PDU_BSSGP pdu_tx := ts_BSSGP_SUSPEND(g_pars.tlli, ra_id);
823 /* we cannot use pdu_tx as there are some subtle differences in the length field :/ */
824 var template (present) PDU_BSSGP pdu_rx := tr_BSSGP_SUSPEND(g_pars.tlli, ra_id);
825
826 f_pcu2sgsn(pdu_tx, pdu_rx);
827
828 pdu_tx := ts_BSSGP_SUSPEND_ACK(g_pars.tlli, ra_id, int2oct(i, 1));
829 /* we cannot use pdu_tx as there are some subtle differences in the length field :/ */
830 pdu_rx := tr_BSSGP_SUSPEND_ACK(g_pars.tlli, ra_id, int2oct(i, 1));
831
832 f_sgsn2pcu(pdu_tx, pdu_rx);
833
834 /* These messages are simple passed through so just also test sending NACK */
835 pdu_tx := ts_BSSGP_SUSPEND_NACK(g_pars.tlli, ra_id, BSSGP_CAUSE_UNKNOWN_MS);
836 /* we cannot use pdu_tx as there are some subtle differences in the length field :/ */
837 pdu_rx := tr_BSSGP_SUSPEND_NACK(g_pars.tlli, ra_id, BSSGP_CAUSE_UNKNOWN_MS);
838
839 f_sgsn2pcu(pdu_tx, pdu_rx);
840 }
841 setverdict(pass);
842}
843testcase TC_suspend() runs on test_CT
844{
845 var BSSGP_ConnHdlr vc_conn;
846 f_init();
847
848 vc_conn := f_start_handler(refers(f_TC_suspend), testcasename(), g_pcu, g_sgsn, 6);
849 vc_conn.done;
850 /* TODO: start multiple handlers (UEs) on various cells on same and other NSEs */
851
852 f_cleanup();
853}
Harald Welte6dc2ac42020-11-16 09:16:17 +0100854
Daniel Willmann087a33d2020-11-19 15:58:43 +0100855private function f_TC_resume(charstring id) runs on BSSGP_ConnHdlr {
856 var integer i;
857
858 /* TODO: Generate RA ID for each ConnHdlr */
859 var RoutingAreaIdentification ra_id := g_pars.pcu[0].cfg.bvc[0].cell_id.ra_id;
860 for (i := 0; i < 10; i := i+1) {
861
862 var template (value) PDU_BSSGP pdu_tx := ts_BSSGP_RESUME(g_pars.tlli, ra_id, int2oct(i, 1));
863 /* we cannot use pdu_tx as there are some subtle differences in the length field :/ */
864 var template (present) PDU_BSSGP pdu_rx := tr_BSSGP_RESUME(g_pars.tlli, ra_id, int2oct(i, 1));
865
866 f_pcu2sgsn(pdu_tx, pdu_rx);
867
868 pdu_tx := ts_BSSGP_RESUME_ACK(g_pars.tlli, ra_id);
869 /* we cannot use pdu_tx as there are some subtle differences in the length field :/ */
870 pdu_rx := tr_BSSGP_RESUME_ACK(g_pars.tlli, ra_id);
871
872 f_sgsn2pcu(pdu_tx, pdu_rx);
873
874 /* These messages are simple passed through so just also test sending NACK */
875 pdu_tx := ts_BSSGP_RESUME_NACK(g_pars.tlli, ra_id, BSSGP_CAUSE_UNKNOWN_MS);
876 /* we cannot use pdu_tx as there are some subtle differences in the length field :/ */
877 pdu_rx := tr_BSSGP_RESUME_NACK(g_pars.tlli, ra_id, BSSGP_CAUSE_UNKNOWN_MS);
878
879 f_sgsn2pcu(pdu_tx, pdu_rx);
880 }
881 setverdict(pass);
882}
883testcase TC_resume() runs on test_CT
884{
885 var BSSGP_ConnHdlr vc_conn;
886 f_init();
887
888 vc_conn := f_start_handler(refers(f_TC_resume), testcasename(), g_pcu, g_sgsn, 6);
889 vc_conn.done;
890 /* TODO: start multiple handlers (UEs) on various cells on same and other NSEs */
891
892 f_cleanup();
893}
894
Harald Weltef8ef0282020-11-18 12:16:59 +0100895/* test the load-sharing between multiple NS-VC on the BSS side */
896private function f_TC_dl_ud_unidir(charstring id) runs on BSSGP_ConnHdlr {
897 var integer i;
898
899 for (i := 0; i < 10; i := i+1) {
900 var octetstring payload := f_rnd_octstring(i);
901 var template (value) PDU_BSSGP pdu_tx :=
902 ts_BSSGP_DL_UD(g_pars.tlli, payload, omit, ts_BSSGP_IMSI(g_pars.imsi));
903 SGSN[0].send(pdu_tx);
904 }
905 setverdict(pass);
906}
907testcase TC_load_sharing_dl() runs on test_CT_NS
908{
909 const integer num_ue := 10;
910 var BSSGP_ConnHdlr vc_conn[num_ue];
911 f_init();
912
913 /* all BVC are now fully brought up. We disconnect BSSGP from NS on the BSS
914 * side so we get the raw NsUnitdataIndication and hence observe different
915 * NSVCI */
916 disconnect(g_pcu[0].vc_NS:NS_SP, g_pcu[0].vc_BSSGP:BSCP);
917 connect(g_pcu[0].vc_NS:NS_SP, self:NS);
918
919 /* there may still be some NS-VCs coming up? After all, the BVC-RESET succeeds after the first
920 * of the NS-VC is ALIVE/UNBLOCKED */
921 f_sleep(3.0);
922
923 /* start parallel components generating DL-UNITDATA from the SGSN side */
924 for (var integer i:= 0; i < num_ue; i := i+1) {
925 vc_conn[i] := f_start_handler(refers(f_TC_dl_ud_unidir), testcasename(), g_pcu, g_sgsn, 5+i);
926 }
927
928 /* now start counting all the messages that were queued before */
929 /* TODO: We have a hard-coded assumption of 4 NS-VC in one NSE/NS-VCG here! */
930 var ro_integer rx_count := { 0, 0, 0, 0 };
931 timer T := 2.0;
932 T.start;
933 alt {
934 [] as_NsUdiCount(0, rx_count);
935 [] as_NsUdiCount(1, rx_count);
936 [] as_NsUdiCount(2, rx_count);
937 [] as_NsUdiCount(3, rx_count);
938 [] NS.receive(NsUnitdataIndication:{0,?,?,*,*}) { repeat; } /* signaling BVC */
939 [] NS.receive(NsStatusIndication:?) { repeat; }
940 [] NS.receive {
941 setverdict(fail, "Rx unexpected NS");
942 mtc.stop;
943 }
944 [] T.timeout {
945 }
946 }
947 for (var integer i := 0; i < lengthof(rx_count); i := i+1) {
948 log("Rx on NSVCI ", mp_nsconfig_pcu[0].nsvc[i].nsvci, ": ", rx_count[i]);
949 if (rx_count[i] == 0) {
950 setverdict(fail, "Data not shared over all NSVC");
951 }
952 }
953 setverdict(pass);
954}
955private altstep as_NsUdiCount(integer nsvc_idx, inout ro_integer roi) runs on test_CT_NS {
956 var NsUnitdataIndication udi;
957 var BssgpBvcConfig bvcc := g_pcu[0].cfg.bvc[0];
958 [] NS.receive(NsUnitdataIndication:{bvcc.bvci, g_pcu[0].cfg.nsei, mp_nsconfig_pcu[0].nsvc[nsvc_idx].nsvci, *, *}) -> value udi {
959 roi[nsvc_idx] := roi[nsvc_idx] + 1;
960 repeat;
961 }
962}
963type component test_CT_NS extends test_CT {
964 port NS_PT NS;
965};
966
967
Harald Welte0e188242020-11-22 21:46:48 +0100968/***********************************************************************
969 * PAGING PS procedure
970 ***********************************************************************/
971
972private function f_send_paging_ps(template (value) Paging_Field4 p4, integer sgsn_idx := 0,
973 boolean use_sig := false)
974runs on BSSGP_ConnHdlr return template (present) PDU_BSSGP {
975 var template (value) PDU_BSSGP pdu_tx;
976 var template (present) PDU_BSSGP pdu_rx;
977 /* we always specify '0' as BVCI in the templates below, as we override it with
978 * 'p4' later anyway */
979 pdu_rx := tr_BSSGP_PS_PAGING(0);
980 pdu_rx.pDU_BSSGP_PAGING_PS.iMSI := tr_BSSGP_IMSI(g_pars.imsi);
981 if (ispresent(g_pars.p_tmsi)) {
982 pdu_tx := ts_BSSGP_PS_PAGING_PTMSI(0, g_pars.imsi, oct2int(g_pars.p_tmsi));
983 pdu_rx.pDU_BSSGP_PAGING_PS.pTMSI := tr_BSSGP_TMSI(oct2int(g_pars.p_tmsi));
984 } else {
985 pdu_tx := ts_BSSGP_PS_PAGING_IMSI(0, g_pars.imsi);
986 pdu_rx.pDU_BSSGP_PAGING_PS.pTMSI := omit;
987 }
988 pdu_tx.pDU_BSSGP_PAGING_PS.paging_Field4 := p4;
989 pdu_rx.pDU_BSSGP_PAGING_PS.paging_Field4 := p4;
990 if (use_sig == false) {
991 SGSN[sgsn_idx].send(pdu_tx);
992 } else {
993 SGSN_SIG[sgsn_idx].send(pdu_tx);
994 }
995 return pdu_rx;
996}
997
998/* send paging defined by 'p4' on given SGSN-side index (ptp or signaling) and expect one paging to arrive on
999 * specified PCU index */
1000private function f_send_paging_ps_exp_one_bss(template (value) Paging_Field4 p4, integer sgsn_idx := 0,
1001 boolean use_sig := false,integer pcu_idx := 0)
1002runs on BSSGP_ConnHdlr {
1003 var template (present) PDU_BSSGP exp_rx;
1004 /* doesn't really make sense: Sending to a single BVCI means the message ends up
1005 * at that BVC (cell) only, and paging all over the BSS area is not possible */
1006 exp_rx := f_send_paging_ps(p4, sgsn_idx, use_sig);
1007 /* Expect paging to propagate to the one BSS addressed by the BVCI only */
1008 timer T := 2.0;
1009 T.start;
1010 alt {
1011 [not use_sig] PCU[pcu_idx].receive(exp_rx) {
1012 setverdict(pass);
1013 repeat;
1014 }
1015 [not use_sig] PCU_SIG[pcu_idx].receive(exp_rx) {
1016 setverdict(fail, "Received paging on SIGNALING BVC, expected PTP BVC");
1017 }
1018 [use_sig] PCU_SIG[pcu_idx].receive(exp_rx) {
1019 setverdict(pass);
1020 repeat;
1021 }
1022 [use_sig] PCU[pcu_idx].receive(exp_rx) {
1023 setverdict(fail, "Received paging on PTP BVC, expected SIGNALING BVC");
1024 }
1025 [] any from PCU.receive(exp_rx) {
1026 setverdict(fail, "Paging received on unexpected BVC");
1027 }
1028 [] any from PCU_SIG.receive(exp_rx) {
1029 setverdict(fail, "Paging received on unexpected BVC");
1030 }
1031 [] any from PCU.receive(PDU_BSSGP:{pDU_BSSGP_PAGING_PS:=?}) {
1032 setverdict(fail, "Different Paging than expected received PTP BVC");
1033 }
1034 [] any from PCU_SIG.receive(PDU_BSSGP:{pDU_BSSGP_PAGING_PS:=?}) {
1035 setverdict(fail, "Different Paging than expected on SIGNALING BVC");
1036 }
1037 [] T.timeout;
1038 }
1039}
1040
1041private function f_TC_paging_ps_ptp_bss(charstring id) runs on BSSGP_ConnHdlr
1042{
1043 /* doesn't really make sense: Sending to a single BVCI means the message ends up
1044 * at that BVC (cell) only, and paging all over the BSS area is not possible */
1045 f_send_paging_ps_exp_one_bss(ts_BssgpP4BssArea, 0, false, 0);
1046}
1047testcase TC_paging_ps_ptp_bss() runs on test_CT {
1048 var BSSGP_ConnHdlr vc_conn;
1049 f_init();
1050
1051 vc_conn := f_start_handler(refers(f_TC_paging_ps_ptp_bss), testcasename(), g_pcu, g_sgsn, 9);
1052 vc_conn.done;
1053
1054 f_cleanup();
1055}
1056
1057/* PS-PAGING on PTP-BVC for Location Area */
1058private function f_TC_paging_ps_ptp_lac(charstring id) runs on BSSGP_ConnHdlr
1059{
1060 var template (present) PDU_BSSGP exp_rx;
1061 /* doesn't really make sense: Sending to a single BVCI means the message ends up
1062 * at that BVC (cell) only, and paging all over the BSS area is not possible */
1063 f_send_paging_ps_exp_one_bss(ts_BssgpP4LAC(pcu_bvc_cfg[0].cell_id.ra_id.lai), 0, false, 0);
1064}
1065testcase TC_paging_ps_ptp_lac() runs on test_CT {
1066 var BSSGP_ConnHdlr vc_conn;
1067 f_init();
1068
1069 vc_conn := f_start_handler(refers(f_TC_paging_ps_ptp_lac), testcasename(), g_pcu, g_sgsn, 10);
1070 vc_conn.done;
1071
1072 f_cleanup();
1073}
1074
1075/* PS-PAGING on PTP-BVC for Routeing Area */
1076private function f_TC_paging_ps_ptp_rac(charstring id) runs on BSSGP_ConnHdlr
1077{
1078 /* doesn't really make sense: Sending to a single BVCI means the message ends up
1079 * at that BVC (cell) only, and paging all over the BSS area is not possible */
1080 f_send_paging_ps_exp_one_bss(ts_BssgpP4RAC(pcu_bvc_cfg[0].cell_id.ra_id), 0, false, 0);
1081}
1082testcase TC_paging_ps_ptp_rac() runs on test_CT {
1083 var BSSGP_ConnHdlr vc_conn;
1084 f_init();
1085
1086 vc_conn := f_start_handler(refers(f_TC_paging_ps_ptp_rac), testcasename(), g_pcu, g_sgsn, 11);
1087 vc_conn.done;
1088
1089 f_cleanup();
1090}
1091
1092/* PS-PAGING on PTP-BVC for BVCI (one cell) */
1093private function f_TC_paging_ps_ptp_bvci(charstring id) runs on BSSGP_ConnHdlr
1094{
1095 /* this should be the normal case for MS in READY MM state after a lower layer failure */
1096 f_send_paging_ps_exp_one_bss(ts_BssgpP4Bvci(pcu_bvc_cfg[0].bvci), 0, false, 0);
1097}
1098testcase TC_paging_ps_ptp_bvci() runs on test_CT {
1099 var BSSGP_ConnHdlr vc_conn;
1100 f_init();
1101
1102 vc_conn := f_start_handler(refers(f_TC_paging_ps_ptp_bvci), testcasename(), g_pcu, g_sgsn, 12);
1103 vc_conn.done;
1104
1105 f_cleanup();
1106}
1107
1108/* altstep for expecting BSSGP PDU on signaling BVC of given pcu_idx + storing in 'roi' */
1109private altstep as_paging_sig_pcu(integer pcu_idx, template (present) PDU_BSSGP exp_rx, inout ro_integer roi)
1110runs on BSSGP_ConnHdlr {
1111[] PCU_SIG[pcu_idx].receive(exp_rx) {
1112 if (ro_integer_contains(roi, pcu_idx)) {
1113 setverdict(fail, "Received multiple paging on same SIG BVC");
1114 }
1115 roi := roi & { pcu_idx };
1116 repeat;
1117 }
1118[] PCU[pcu_idx].receive(exp_rx) {
1119 setverdict(fail, "Received paging on PTP BVC, expected SIGNALING BVC");
1120 }
1121[] PCU_SIG[pcu_idx].receive(PDU_BSSGP:{pDU_BSSGP_PAGING_PS:=?}) {
1122 setverdict(fail, "Different Paging than expected received SIGNALING BVC");
1123 }
1124[] PCU[pcu_idx].receive(PDU_BSSGP:{pDU_BSSGP_PAGING_PS:=?}) {
1125 setverdict(fail, "Different Paging than expected received PTP BVC");
1126 }
1127}
1128
1129type record of default ro_default;
1130
1131/* send PS-PAGING on SIG BVC, expect it to arrive on given list of PCU indexes */
1132private function f_send_paging_ps_exp_multi(template (value) Paging_Field4 p4, integer sgsn_idx := 0,
1133 ro_integer exp_on_pcu_idx) runs on BSSGP_ConnHdlr
1134{
1135 var template (present) PDU_BSSGP exp_rx;
1136 exp_rx := f_send_paging_ps(p4, 0, true);
1137
1138 /* FIXME: make sure the relevant BVCs/BSS are connected to the ports! */
1139 var ro_default defaults := {};
1140 for (var integer i := 0; i < lengthof(mp_nsconfig_pcu); i := i+1) {
1141 var default d := activate(as_paging_sig_pcu(i, exp_rx, g_roi));
1142 defaults := defaults & { d };
1143 }
1144 f_sleep(2.0);
1145 for (var integer i := 0; i < lengthof(defaults); i := i+1) {
1146 deactivate(defaults[i]);
1147 }
1148 log("Paging received on PCU ", g_roi);
1149
1150 for (var integer i := 0; i < lengthof(mp_nsconfig_pcu); i := i+1) {
1151 var boolean rx_on_i := ro_integer_contains(g_roi, i);
1152 var boolean exp_on_i := ro_integer_contains(exp_on_pcu_idx, i);
1153 if (exp_on_i and not rx_on_i) {
1154 setverdict(fail, "PS-PAGING not received on ", mp_nsconfig_pcu[i].nsei);
1155 }
1156 if (not exp_on_i and rx_on_i) {
1157 setverdict(fail, "PS-PAGING not expected but received on ", mp_nsconfig_pcu[i].nsei);
1158 }
1159 }
1160 setverdict(pass);
1161}
1162
1163/* PS-PAGING on SIG-BVC for BSS Area */
1164private function f_TC_paging_ps_sig_bss(charstring id) runs on BSSGP_ConnHdlr
1165{
1166 /* we expect the paging to arrive on all three NSE */
1167 f_send_paging_ps_exp_multi(ts_BssgpP4BssArea, 0, {0, 1, 2});
1168}
1169testcase TC_paging_ps_sig_bss() runs on test_CT {
1170 var BSSGP_ConnHdlr vc_conn;
1171 f_init();
1172
1173 vc_conn := f_start_handler(refers(f_TC_paging_ps_sig_bss), testcasename(), g_pcu, g_sgsn, 13);
1174 vc_conn.done;
1175
1176 f_cleanup();
1177}
1178
1179/* PS-PAGING on SIG-BVC for Location Area */
1180private function f_TC_paging_ps_sig_lac(charstring id) runs on BSSGP_ConnHdlr
1181{
1182 /* Both PCU index 0 and 1 have a BVC within the LAC */
1183 f_send_paging_ps_exp_multi(ts_BssgpP4LAC(pcu_bvc_cfg[0].cell_id.ra_id.lai), 0, {0, 1});
1184}
1185testcase TC_paging_ps_sig_lac() runs on test_CT {
1186 var BSSGP_ConnHdlr vc_conn;
1187 f_init();
1188
1189 vc_conn := f_start_handler(refers(f_TC_paging_ps_sig_lac), testcasename(), g_pcu, g_sgsn, 14);
1190 vc_conn.done;
1191
1192 f_cleanup();
1193}
1194
1195/* PS-PAGING on SIG-BVC for Routeing Area */
1196private function f_TC_paging_ps_sig_rac(charstring id) runs on BSSGP_ConnHdlr
1197{
1198 /* Only PCU index 0 has a matching BVC within the LAC */
1199 f_send_paging_ps_exp_multi(ts_BssgpP4RAC(pcu_bvc_cfg[0].cell_id.ra_id), 0, {0});
1200}
1201testcase TC_paging_ps_sig_rac() runs on test_CT {
1202 var BSSGP_ConnHdlr vc_conn;
1203 f_init();
1204
1205 vc_conn := f_start_handler(refers(f_TC_paging_ps_sig_rac), testcasename(), g_pcu, g_sgsn, 15);
1206 vc_conn.done;
1207
1208 f_cleanup();
1209}
1210
1211/* PS-PAGING on SIG-BVC for BVCI (one cell) */
1212private function f_TC_paging_ps_sig_bvci(charstring id) runs on BSSGP_ConnHdlr
1213{
1214 f_send_paging_ps_exp_multi(ts_BssgpP4Bvci(pcu_bvc_cfg[0].bvci), 0, {0});
1215}
1216testcase TC_paging_ps_sig_bvci() runs on test_CT {
1217 var BSSGP_ConnHdlr vc_conn;
1218 f_init();
1219
1220 vc_conn := f_start_handler(refers(f_TC_paging_ps_sig_bvci), testcasename(), g_pcu, g_sgsn, 16);
1221 vc_conn.done;
1222
1223 f_cleanup();
1224}
1225
1226
1227/***********************************************************************
1228 * PAGING CS procedure
1229 ***********************************************************************/
1230
1231private function f_send_paging_cs(template (value) Paging_Field4 p4, integer sgsn_idx := 0,
1232 boolean use_sig := false)
1233runs on BSSGP_ConnHdlr return template (present) PDU_BSSGP {
1234 var template (value) PDU_BSSGP pdu_tx;
1235 var template (present) PDU_BSSGP pdu_rx;
1236 /* we always specify '0' as BVCI in the templates below, as we override it with
1237 * 'p4' later anyway */
1238 pdu_rx := tr_BSSGP_CS_PAGING(0);
1239 pdu_rx.pDU_BSSGP_PAGING_CS.iMSI := tr_BSSGP_IMSI(g_pars.imsi);
1240 if (ispresent(g_pars.p_tmsi)) {
1241 pdu_tx := ts_BSSGP_CS_PAGING_PTMSI(0, g_pars.imsi, oct2int(g_pars.p_tmsi));
1242 pdu_rx.pDU_BSSGP_PAGING_CS.tMSI := tr_BSSGP_TMSI(oct2int(g_pars.p_tmsi));
1243 } else {
1244 pdu_tx := ts_BSSGP_CS_PAGING_IMSI(0, g_pars.imsi);
1245 pdu_rx.pDU_BSSGP_PAGING_CS.tMSI := omit;
1246 }
1247 pdu_tx.pDU_BSSGP_PAGING_CS.paging_Field4 := p4;
1248 pdu_rx.pDU_BSSGP_PAGING_CS.paging_Field4 := p4;
1249 if (use_sig == false) {
1250 SGSN[sgsn_idx].send(pdu_tx);
1251 } else {
1252 SGSN_SIG[sgsn_idx].send(pdu_tx);
1253 }
1254 return pdu_rx;
1255}
1256
1257/* send paging defined by 'p4' on given SGSN-side index (ptp or signaling) and expect one paging to arrive on
1258 * specified PCU index */
1259private function f_send_paging_cs_exp_one_bss(template (value) Paging_Field4 p4, integer sgsn_idx := 0,
1260 boolean use_sig := false,integer pcu_idx := 0)
1261runs on BSSGP_ConnHdlr {
1262 var template (present) PDU_BSSGP exp_rx;
1263 /* doesn't really make sense: Sending to a single BVCI means the message ends up
1264 * at that BVC (cell) only, and paging all over the BSS area is not possible */
1265 exp_rx := f_send_paging_cs(p4, sgsn_idx, use_sig);
1266 /* Expect paging to propagate to the one BSS addressed by the BVCI only */
1267 timer T := 2.0;
1268 T.start;
1269 alt {
1270 [not use_sig] PCU[pcu_idx].receive(exp_rx) {
1271 setverdict(pass);
1272 repeat;
1273 }
1274 [not use_sig] PCU_SIG[pcu_idx].receive(exp_rx) {
1275 setverdict(fail, "Received paging on SIGNALING BVC, expected PTP BVC");
1276 }
1277 [use_sig] PCU_SIG[pcu_idx].receive(exp_rx) {
1278 setverdict(pass);
1279 repeat;
1280 }
1281 [use_sig] PCU[pcu_idx].receive(exp_rx) {
1282 setverdict(fail, "Received paging on PTP BVC, expected SIGNALING BVC");
1283 }
1284 [] any from PCU.receive(exp_rx) {
1285 setverdict(fail, "Paging received on unexpected BVC");
1286 }
1287 [] any from PCU_SIG.receive(exp_rx) {
1288 setverdict(fail, "Paging received on unexpected BVC");
1289 }
1290 [] any from PCU.receive(PDU_BSSGP:{pDU_BSSGP_PAGING_CS:=?}) {
1291 setverdict(fail, "Different Paging than expected received PTP BVC");
1292 }
1293 [] any from PCU_SIG.receive(PDU_BSSGP:{pDU_BSSGP_PAGING_CS:=?}) {
1294 setverdict(fail, "Different Paging than expected on SIGNALING BVC");
1295 }
1296 [] T.timeout;
1297 }
1298}
1299
1300private function f_TC_paging_cs_ptp_bss(charstring id) runs on BSSGP_ConnHdlr
1301{
1302 /* doesn't really make sense: Sending to a single BVCI means the message ends up
1303 * at that BVC (cell) only, and paging all over the BSS area is not possible */
1304 f_send_paging_cs_exp_one_bss(ts_BssgpP4BssArea, 0, false, 0);
1305}
1306testcase TC_paging_cs_ptp_bss() runs on test_CT {
1307 var BSSGP_ConnHdlr vc_conn;
1308 f_init();
1309
1310 vc_conn := f_start_handler(refers(f_TC_paging_cs_ptp_bss), testcasename(), g_pcu, g_sgsn, 17);
1311 vc_conn.done;
1312
1313 f_cleanup();
1314}
1315
1316/* CS-PAGING on PTP-BVC for Location Area */
1317private function f_TC_paging_cs_ptp_lac(charstring id) runs on BSSGP_ConnHdlr
1318{
1319 var template (present) PDU_BSSGP exp_rx;
1320 /* doesn't really make sense: Sending to a single BVCI means the message ends up
1321 * at that BVC (cell) only, and paging all over the BSS area is not possible */
1322 f_send_paging_cs_exp_one_bss(ts_BssgpP4LAC(pcu_bvc_cfg[0].cell_id.ra_id.lai), 0, false, 0);
1323}
1324testcase TC_paging_cs_ptp_lac() runs on test_CT {
1325 var BSSGP_ConnHdlr vc_conn;
1326 f_init();
1327
1328 vc_conn := f_start_handler(refers(f_TC_paging_cs_ptp_lac), testcasename(), g_pcu, g_sgsn, 18);
1329 vc_conn.done;
1330
1331 f_cleanup();
1332}
1333
1334/* CS-PAGING on PTP-BVC for Routeing Area */
1335private function f_TC_paging_cs_ptp_rac(charstring id) runs on BSSGP_ConnHdlr
1336{
1337 /* doesn't really make sense: Sending to a single BVCI means the message ends up
1338 * at that BVC (cell) only, and paging all over the BSS area is not possible */
1339 f_send_paging_cs_exp_one_bss(ts_BssgpP4RAC(pcu_bvc_cfg[0].cell_id.ra_id), 0, false, 0);
1340}
1341testcase TC_paging_cs_ptp_rac() runs on test_CT {
1342 var BSSGP_ConnHdlr vc_conn;
1343 f_init();
1344
1345 vc_conn := f_start_handler(refers(f_TC_paging_cs_ptp_rac), testcasename(), g_pcu, g_sgsn, 19);
1346 vc_conn.done;
1347
1348 f_cleanup();
1349}
1350
1351/* CS-PAGING on PTP-BVC for BVCI (one cell) */
1352private function f_TC_paging_cs_ptp_bvci(charstring id) runs on BSSGP_ConnHdlr
1353{
1354 /* this should be the normal case for MS in READY MM state after a lower layer failure */
1355 f_send_paging_cs_exp_one_bss(ts_BssgpP4Bvci(pcu_bvc_cfg[0].bvci), 0, false, 0);
1356}
1357testcase TC_paging_cs_ptp_bvci() runs on test_CT {
1358 var BSSGP_ConnHdlr vc_conn;
1359 f_init();
1360
1361 vc_conn := f_start_handler(refers(f_TC_paging_cs_ptp_bvci), testcasename(), g_pcu, g_sgsn, 20);
1362 vc_conn.done;
1363
1364 f_cleanup();
1365}
1366
1367/* send CS-PAGING on SIG BVC, expect it to arrive on given list of PCU indexes */
1368private function f_send_paging_cs_exp_multi(template (value) Paging_Field4 p4, integer sgsn_idx := 0,
1369 ro_integer exp_on_pcu_idx) runs on BSSGP_ConnHdlr
1370{
1371 var template (present) PDU_BSSGP exp_rx;
1372 exp_rx := f_send_paging_cs(p4, 0, true);
1373
1374 /* FIXME: make sure the relevant BVCs/BSS are connected to the ports! */
1375 var ro_default defaults := {};
1376 for (var integer i := 0; i < lengthof(mp_nsconfig_pcu); i := i+1) {
1377 var default d := activate(as_paging_sig_pcu(i, exp_rx, g_roi));
1378 defaults := defaults & { d };
1379 }
1380 f_sleep(2.0);
1381 for (var integer i := 0; i < lengthof(defaults); i := i+1) {
1382 deactivate(defaults[i]);
1383 }
1384 log("Paging received on PCU ", g_roi);
1385
1386 for (var integer i := 0; i < lengthof(mp_nsconfig_pcu); i := i+1) {
1387 var boolean rx_on_i := ro_integer_contains(g_roi, i);
1388 var boolean exp_on_i := ro_integer_contains(exp_on_pcu_idx, i);
1389 if (exp_on_i and not rx_on_i) {
1390 setverdict(fail, "PS-PAGING not received on ", mp_nsconfig_pcu[i].nsei);
1391 }
1392 if (not exp_on_i and rx_on_i) {
1393 setverdict(fail, "PS-PAGING not expected but received on ", mp_nsconfig_pcu[i].nsei);
1394 }
1395 }
1396 setverdict(pass);
1397}
1398
1399/* CS-PAGING on SIG-BVC for BSS Area */
1400private function f_TC_paging_cs_sig_bss(charstring id) runs on BSSGP_ConnHdlr
1401{
1402 /* we expect the paging to arrive on all three NSE */
1403 f_send_paging_cs_exp_multi(ts_BssgpP4BssArea, 0, {0, 1, 2});
1404}
1405testcase TC_paging_cs_sig_bss() runs on test_CT {
1406 var BSSGP_ConnHdlr vc_conn;
1407 f_init();
1408
1409 vc_conn := f_start_handler(refers(f_TC_paging_cs_sig_bss), testcasename(), g_pcu, g_sgsn, 13);
1410 vc_conn.done;
1411
1412 f_cleanup();
1413}
1414
1415/* CS-PAGING on SIG-BVC for Location Area */
1416private function f_TC_paging_cs_sig_lac(charstring id) runs on BSSGP_ConnHdlr
1417{
1418 /* Both PCU index 0 and 1 have a BVC within the LAC */
1419 f_send_paging_cs_exp_multi(ts_BssgpP4LAC(pcu_bvc_cfg[0].cell_id.ra_id.lai), 0, {0, 1});
1420}
1421testcase TC_paging_cs_sig_lac() runs on test_CT {
1422 var BSSGP_ConnHdlr vc_conn;
1423 f_init();
1424
1425 vc_conn := f_start_handler(refers(f_TC_paging_cs_sig_lac), testcasename(), g_pcu, g_sgsn, 14);
1426 vc_conn.done;
1427
1428 f_cleanup();
1429}
1430
1431/* CS-PAGING on SIG-BVC for Routeing Area */
1432private function f_TC_paging_cs_sig_rac(charstring id) runs on BSSGP_ConnHdlr
1433{
1434 /* Only PCU index 0 has a matching BVC within the LAC */
1435 f_send_paging_cs_exp_multi(ts_BssgpP4RAC(pcu_bvc_cfg[0].cell_id.ra_id), 0, {0});
1436}
1437testcase TC_paging_cs_sig_rac() runs on test_CT {
1438 var BSSGP_ConnHdlr vc_conn;
1439 f_init();
1440
1441 vc_conn := f_start_handler(refers(f_TC_paging_cs_sig_rac), testcasename(), g_pcu, g_sgsn, 15);
1442 vc_conn.done;
1443
1444 f_cleanup();
1445}
1446
1447/* CS-PAGING on SIG-BVC for BVCI (one cell) */
1448private function f_TC_paging_cs_sig_bvci(charstring id) runs on BSSGP_ConnHdlr
1449{
1450 f_send_paging_cs_exp_multi(ts_BssgpP4Bvci(pcu_bvc_cfg[0].bvci), 0, {0});
1451}
1452testcase TC_paging_cs_sig_bvci() runs on test_CT {
1453 var BSSGP_ConnHdlr vc_conn;
1454 f_init();
1455
1456 vc_conn := f_start_handler(refers(f_TC_paging_cs_sig_bvci), testcasename(), g_pcu, g_sgsn, 16);
1457 vc_conn.done;
1458
1459 f_cleanup();
1460}
1461
Harald Welte6dc2ac42020-11-16 09:16:17 +01001462
Daniel Willmann423d8f42020-09-08 18:58:22 +02001463control {
1464 execute( TC_BVC_bringup() );
Harald Welte92686012020-11-15 21:45:49 +01001465 execute( TC_ul_unitdata() );
Harald Welte78d8db92020-11-15 23:27:27 +01001466 execute( TC_dl_unitdata() );
Harald Welte6dc2ac42020-11-16 09:16:17 +01001467 execute( TC_ra_capability() );
Daniel Willmannace3ece2020-11-16 19:53:26 +01001468 execute( TC_ra_capability_upd() );
Daniel Willmann165d6612020-11-19 14:27:29 +01001469 execute( TC_radio_status() );
Daniel Willmannfa67f492020-11-19 15:48:05 +01001470 execute( TC_suspend() );
Daniel Willmann087a33d2020-11-19 15:58:43 +01001471 execute( TC_resume() );
Harald Weltef8ef0282020-11-18 12:16:59 +01001472 if (false) {
1473 /* don't enable this by default, as we don't yet have any automatic test setup for FR with 4 NS-VC */
1474 execute( TC_load_sharing_dl() );
1475 }
Harald Welte0e188242020-11-22 21:46:48 +01001476
1477 /* PAGING-PS over PTP BVC */
1478 execute( TC_paging_ps_ptp_bss() );
1479 execute( TC_paging_ps_ptp_lac() );
1480 execute( TC_paging_ps_ptp_rac() );
1481 execute( TC_paging_ps_ptp_bvci() );
1482
1483 /* PAGING-PS over SIG BVC */
1484 execute( TC_paging_ps_sig_bss() );
1485 execute( TC_paging_ps_sig_lac() );
1486 execute( TC_paging_ps_sig_rac() );
1487 execute( TC_paging_ps_sig_bvci() );
1488
1489 /* PAGING-CS over PTP BVC */
1490 execute( TC_paging_cs_ptp_bss() );
1491 execute( TC_paging_cs_ptp_lac() );
1492 execute( TC_paging_cs_ptp_rac() );
1493 execute( TC_paging_cs_ptp_bvci() );
1494
1495 /* PAGING-CS over SIG BVC */
1496 execute( TC_paging_cs_sig_bss() );
1497 execute( TC_paging_cs_sig_lac() );
1498 execute( TC_paging_cs_sig_rac() );
1499 execute( TC_paging_cs_sig_bvci() );
1500
1501
Daniel Willmann423d8f42020-09-08 18:58:22 +02001502}
1503
1504
1505}