Daniel Willmann | 423d8f4 | 2020-09-08 18:58:22 +0200 | [diff] [blame] | 1 | module 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 | |
| 15 | import from General_Types all; |
| 16 | import from Osmocom_Types all; |
| 17 | import from GSM_Types all; |
| 18 | import from Native_Functions all; |
| 19 | import from NS_Types all; |
| 20 | import from NS_Emulation all; |
| 21 | import from BSSGP_Types all; |
| 22 | import from BSSGP_Emulation all; |
| 23 | import from SCCPasp_Types all; |
| 24 | import from Osmocom_Gb_Types all; |
| 25 | |
| 26 | import from MobileL3_CommonIE_Types all; |
| 27 | import from MobileL3_GMM_SM_Types all; |
| 28 | import from MobileL3_Types all; |
| 29 | import from L3_Templates all; |
| 30 | import from L3_Common all; |
| 31 | |
| 32 | import from TELNETasp_PortType all; |
| 33 | import from Osmocom_VTY_Functions all; |
| 34 | |
| 35 | import from LLC_Types all; |
| 36 | import from LLC_Templates all; |
| 37 | |
| 38 | import from GSM_RR_Types all; |
| 39 | |
Harald Welte | 6d63f74 | 2020-11-15 19:44:04 +0100 | [diff] [blame] | 40 | /* mcc_mnc is 24.008 10.5.5.15 encoded. 262 42 */ |
| 41 | const BcdMccMnc c_mcc_mnc := '262F42'H; |
| 42 | |
Harald Welte | 0d5fceb | 2020-11-29 16:04:07 +0100 | [diff] [blame] | 43 | /* 48.016 section 6.1.4.2: The default maximum information field size of 1600 octets shall be supported on the Gb interface */ |
| 44 | const integer max_fr_info_size := 1600; |
| 45 | |
Daniel Willmann | 423d8f4 | 2020-09-08 18:58:22 +0200 | [diff] [blame] | 46 | modulepar { |
Daniel Willmann | 2c9300f | 2020-12-01 10:54:08 +0100 | [diff] [blame] | 47 | /* SGSN NS configuration */ |
Harald Welte | 6d63f74 | 2020-11-15 19:44:04 +0100 | [diff] [blame] | 48 | NSConfigurations mp_nsconfig_sgsn := { |
Daniel Willmann | 423d8f4 | 2020-09-08 18:58:22 +0200 | [diff] [blame] | 49 | { |
Daniel Willmann | 423d8f4 | 2020-09-08 18:58:22 +0200 | [diff] [blame] | 50 | nsei := 101, |
| 51 | role_sgsn := true, |
Harald Welte | 90f1974 | 2020-11-06 19:34:40 +0100 | [diff] [blame] | 52 | handle_sns := false, |
| 53 | nsvc := { |
| 54 | { |
| 55 | provider := { |
| 56 | ip := { |
| 57 | address_family := AF_INET, |
| 58 | local_udp_port := 7777, |
| 59 | local_ip := "127.0.0.1", |
| 60 | remote_udp_port := 23000, |
| 61 | remote_ip := "127.0.0.1" |
| 62 | } |
| 63 | }, |
| 64 | nsvci := 101 |
| 65 | } |
| 66 | } |
Daniel Willmann | 423d8f4 | 2020-09-08 18:58:22 +0200 | [diff] [blame] | 67 | } |
| 68 | }; |
Daniel Willmann | 2c9300f | 2020-12-01 10:54:08 +0100 | [diff] [blame] | 69 | /* BSS NSEI start at 2000 + x |
| 70 | * NSVCI start from value of NSEI + 100 |
| 71 | * UDP port is NSVCI * 10 */ |
Harald Welte | 6d63f74 | 2020-11-15 19:44:04 +0100 | [diff] [blame] | 72 | NSConfigurations mp_nsconfig_pcu := { |
Daniel Willmann | 423d8f4 | 2020-09-08 18:58:22 +0200 | [diff] [blame] | 73 | { |
Daniel Willmann | 2c9300f | 2020-12-01 10:54:08 +0100 | [diff] [blame] | 74 | nsei := 2001, |
Daniel Willmann | 423d8f4 | 2020-09-08 18:58:22 +0200 | [diff] [blame] | 75 | role_sgsn := false, |
Harald Welte | 90f1974 | 2020-11-06 19:34:40 +0100 | [diff] [blame] | 76 | handle_sns := false, |
| 77 | nsvc := { |
| 78 | { |
| 79 | provider := { |
| 80 | ip := { |
| 81 | address_family := AF_INET, |
| 82 | local_udp_port := 21010, |
| 83 | local_ip := "127.0.0.1", |
| 84 | remote_udp_port := 23000, |
| 85 | remote_ip := "127.0.0.1" |
| 86 | } |
| 87 | }, |
Daniel Willmann | 2c9300f | 2020-12-01 10:54:08 +0100 | [diff] [blame] | 88 | nsvci := 2101 |
Harald Welte | 90f1974 | 2020-11-06 19:34:40 +0100 | [diff] [blame] | 89 | } |
| 90 | } |
Daniel Willmann | 423d8f4 | 2020-09-08 18:58:22 +0200 | [diff] [blame] | 91 | }, |
| 92 | { |
Daniel Willmann | 2c9300f | 2020-12-01 10:54:08 +0100 | [diff] [blame] | 93 | nsei := 2002, |
Daniel Willmann | 423d8f4 | 2020-09-08 18:58:22 +0200 | [diff] [blame] | 94 | role_sgsn := false, |
Harald Welte | 90f1974 | 2020-11-06 19:34:40 +0100 | [diff] [blame] | 95 | handle_sns := false, |
| 96 | nsvc := { |
| 97 | { |
| 98 | provider := { |
| 99 | ip := { |
| 100 | address_family := AF_INET, |
Daniel Willmann | 2c9300f | 2020-12-01 10:54:08 +0100 | [diff] [blame] | 101 | local_udp_port := 21020, |
Harald Welte | 90f1974 | 2020-11-06 19:34:40 +0100 | [diff] [blame] | 102 | local_ip := "127.0.0.1", |
| 103 | remote_udp_port := 23000, |
| 104 | remote_ip := "127.0.0.1" |
| 105 | } |
| 106 | }, |
Daniel Willmann | 2c9300f | 2020-12-01 10:54:08 +0100 | [diff] [blame] | 107 | nsvci := 2102 |
Harald Welte | 90f1974 | 2020-11-06 19:34:40 +0100 | [diff] [blame] | 108 | } |
| 109 | } |
Daniel Willmann | 423d8f4 | 2020-09-08 18:58:22 +0200 | [diff] [blame] | 110 | }, |
| 111 | { |
Daniel Willmann | 2c9300f | 2020-12-01 10:54:08 +0100 | [diff] [blame] | 112 | nsei := 2003, |
Daniel Willmann | 423d8f4 | 2020-09-08 18:58:22 +0200 | [diff] [blame] | 113 | role_sgsn := false, |
Harald Welte | 90f1974 | 2020-11-06 19:34:40 +0100 | [diff] [blame] | 114 | handle_sns := false, |
| 115 | nsvc := { |
| 116 | { |
| 117 | provider := { |
| 118 | ip := { |
| 119 | address_family := AF_INET, |
Daniel Willmann | 2c9300f | 2020-12-01 10:54:08 +0100 | [diff] [blame] | 120 | local_udp_port := 21030, |
Harald Welte | 90f1974 | 2020-11-06 19:34:40 +0100 | [diff] [blame] | 121 | local_ip := "127.0.0.1", |
| 122 | remote_udp_port := 23000, |
| 123 | remote_ip := "127.0.0.1" |
| 124 | } |
| 125 | }, |
Daniel Willmann | 2c9300f | 2020-12-01 10:54:08 +0100 | [diff] [blame] | 126 | nsvci := 2103 |
Harald Welte | 90f1974 | 2020-11-06 19:34:40 +0100 | [diff] [blame] | 127 | } |
| 128 | } |
Daniel Willmann | 423d8f4 | 2020-09-08 18:58:22 +0200 | [diff] [blame] | 129 | } |
| 130 | }; |
Daniel Willmann | 2c9300f | 2020-12-01 10:54:08 +0100 | [diff] [blame] | 131 | /* BVCI are NSEI*10 + x |
| 132 | * The first NSE only has one BVC, the second one 2 and so on |
| 133 | * The Cell ID is BVCI + 10000 |
| 134 | * LAC/RAC are configured in such a way that: |
| 135 | * LAC 13135 is present once in NSE(2001), twice in NSE(2002) and once in NSE(2003) |
| 136 | * LAC 13300 is present twice in NSE(2003) |
| 137 | * RAI 13135-1 is present in NSE(2002) and NSE(2003) |
| 138 | * RAI 13300-0 is present twice in NSE(2003) |
| 139 | */ |
Harald Welte | 6d63f74 | 2020-11-15 19:44:04 +0100 | [diff] [blame] | 140 | BssgpConfigs mp_gbconfigs := { |
| 141 | { |
Daniel Willmann | 2c9300f | 2020-12-01 10:54:08 +0100 | [diff] [blame] | 142 | nsei := 2001, |
Harald Welte | 6d63f74 | 2020-11-15 19:44:04 +0100 | [diff] [blame] | 143 | sgsn_role := false, |
| 144 | bvc := { |
| 145 | { |
Daniel Willmann | 2c9300f | 2020-12-01 10:54:08 +0100 | [diff] [blame] | 146 | bvci := 20011, |
Harald Welte | 6d63f74 | 2020-11-15 19:44:04 +0100 | [diff] [blame] | 147 | cell_id := { |
| 148 | ra_id := { |
| 149 | lai := { |
| 150 | mcc_mnc := c_mcc_mnc, |
| 151 | lac := 13135 |
| 152 | }, |
| 153 | rac := 0 |
| 154 | }, |
Daniel Willmann | 2c9300f | 2020-12-01 10:54:08 +0100 | [diff] [blame] | 155 | cell_id := 30011 |
Harald Welte | 6d63f74 | 2020-11-15 19:44:04 +0100 | [diff] [blame] | 156 | }, |
| 157 | depth := BSSGP_DECODE_DEPTH_BSSGP, |
| 158 | create_cb := refers(BSSGP_Emulation.DefaultCreateCallback) |
| 159 | } |
| 160 | } |
| 161 | }, { |
Daniel Willmann | 2c9300f | 2020-12-01 10:54:08 +0100 | [diff] [blame] | 162 | nsei := 2002, |
Harald Welte | 6d63f74 | 2020-11-15 19:44:04 +0100 | [diff] [blame] | 163 | sgsn_role := false, |
| 164 | bvc := { |
| 165 | { |
Daniel Willmann | 2c9300f | 2020-12-01 10:54:08 +0100 | [diff] [blame] | 166 | bvci := 20021, |
Harald Welte | 6d63f74 | 2020-11-15 19:44:04 +0100 | [diff] [blame] | 167 | cell_id := { |
| 168 | ra_id := { |
| 169 | lai := { |
| 170 | mcc_mnc := c_mcc_mnc, |
Harald Welte | 0e18824 | 2020-11-22 21:46:48 +0100 | [diff] [blame] | 171 | lac := 13135 |
Harald Welte | 6d63f74 | 2020-11-15 19:44:04 +0100 | [diff] [blame] | 172 | }, |
Harald Welte | 0e18824 | 2020-11-22 21:46:48 +0100 | [diff] [blame] | 173 | rac := 1 |
Harald Welte | 6d63f74 | 2020-11-15 19:44:04 +0100 | [diff] [blame] | 174 | }, |
Daniel Willmann | 2c9300f | 2020-12-01 10:54:08 +0100 | [diff] [blame] | 175 | cell_id := 30021 |
| 176 | }, |
| 177 | depth := BSSGP_DECODE_DEPTH_BSSGP, |
| 178 | create_cb := refers(BSSGP_Emulation.DefaultCreateCallback) |
| 179 | }, |
| 180 | { |
| 181 | bvci := 20022, |
| 182 | cell_id := { |
| 183 | ra_id := { |
| 184 | lai := { |
| 185 | mcc_mnc := c_mcc_mnc, |
| 186 | lac := 13135 |
| 187 | }, |
| 188 | rac := 2 |
| 189 | }, |
| 190 | cell_id := 30022 |
Harald Welte | 6d63f74 | 2020-11-15 19:44:04 +0100 | [diff] [blame] | 191 | }, |
| 192 | depth := BSSGP_DECODE_DEPTH_BSSGP, |
| 193 | create_cb := refers(BSSGP_Emulation.DefaultCreateCallback) |
| 194 | } |
| 195 | } |
| 196 | }, { |
Daniel Willmann | 2c9300f | 2020-12-01 10:54:08 +0100 | [diff] [blame] | 197 | nsei := 2003, |
Harald Welte | 6d63f74 | 2020-11-15 19:44:04 +0100 | [diff] [blame] | 198 | sgsn_role := false, |
| 199 | bvc := { |
| 200 | { |
Daniel Willmann | 2c9300f | 2020-12-01 10:54:08 +0100 | [diff] [blame] | 201 | bvci := 20031, |
| 202 | cell_id := { |
| 203 | ra_id := { |
| 204 | lai := { |
| 205 | mcc_mnc := c_mcc_mnc, |
| 206 | lac := 13135 |
| 207 | }, |
| 208 | rac := 1 |
| 209 | }, |
| 210 | cell_id := 30031 |
| 211 | }, |
| 212 | depth := BSSGP_DECODE_DEPTH_BSSGP, |
| 213 | create_cb := refers(BSSGP_Emulation.DefaultCreateCallback) |
| 214 | }, |
| 215 | { |
| 216 | bvci := 20032, |
Harald Welte | 6d63f74 | 2020-11-15 19:44:04 +0100 | [diff] [blame] | 217 | cell_id := { |
| 218 | ra_id := { |
| 219 | lai := { |
| 220 | mcc_mnc := c_mcc_mnc, |
| 221 | lac := 13300 |
| 222 | }, |
| 223 | rac := 0 |
| 224 | }, |
Daniel Willmann | 2c9300f | 2020-12-01 10:54:08 +0100 | [diff] [blame] | 225 | cell_id := 30032 |
| 226 | }, |
| 227 | depth := BSSGP_DECODE_DEPTH_BSSGP, |
| 228 | create_cb := refers(BSSGP_Emulation.DefaultCreateCallback) |
| 229 | }, |
| 230 | { |
| 231 | bvci := 20033, |
| 232 | cell_id := { |
| 233 | ra_id := { |
| 234 | lai := { |
| 235 | mcc_mnc := c_mcc_mnc, |
| 236 | lac := 13300 |
| 237 | }, |
| 238 | rac := 0 |
| 239 | }, |
| 240 | cell_id := 30033 |
Harald Welte | 6d63f74 | 2020-11-15 19:44:04 +0100 | [diff] [blame] | 241 | }, |
| 242 | depth := BSSGP_DECODE_DEPTH_BSSGP, |
| 243 | create_cb := refers(BSSGP_Emulation.DefaultCreateCallback) |
| 244 | } |
| 245 | } |
| 246 | } |
| 247 | } |
Daniel Willmann | 423d8f4 | 2020-09-08 18:58:22 +0200 | [diff] [blame] | 248 | }; |
| 249 | |
Daniel Willmann | 423d8f4 | 2020-09-08 18:58:22 +0200 | [diff] [blame] | 250 | type record GbInstance { |
| 251 | NS_CT vc_NS, |
| 252 | BSSGP_CT vc_BSSGP, |
Harald Welte | 67dc8c2 | 2020-11-17 18:32:29 +0100 | [diff] [blame] | 253 | BSSGP_BVC_CTs vc_BSSGP_BVC, |
Daniel Willmann | 423d8f4 | 2020-09-08 18:58:22 +0200 | [diff] [blame] | 254 | BssgpConfig cfg |
| 255 | }; |
Harald Welte | 67dc8c2 | 2020-11-17 18:32:29 +0100 | [diff] [blame] | 256 | type record of BSSGP_BVC_CT BSSGP_BVC_CTs |
Daniel Willmann | 423d8f4 | 2020-09-08 18:58:22 +0200 | [diff] [blame] | 257 | |
| 258 | const integer NUM_PCU := 3; |
Harald Welte | 6d63f74 | 2020-11-15 19:44:04 +0100 | [diff] [blame] | 259 | type record of GbInstance GbInstances; |
| 260 | type record of BssgpConfig BssgpConfigs; |
| 261 | type record of NSConfiguration NSConfigurations; |
| 262 | type record of BssgpCellId BssgpCellIds; |
Daniel Willmann | 423d8f4 | 2020-09-08 18:58:22 +0200 | [diff] [blame] | 263 | |
| 264 | const integer NUM_SGSN := 1; |
Daniel Willmann | 423d8f4 | 2020-09-08 18:58:22 +0200 | [diff] [blame] | 265 | |
| 266 | type component test_CT { |
Harald Welte | 6d63f74 | 2020-11-15 19:44:04 +0100 | [diff] [blame] | 267 | var GbInstances g_pcu; |
| 268 | var GbInstances g_sgsn; |
Daniel Willmann | 423d8f4 | 2020-09-08 18:58:22 +0200 | [diff] [blame] | 269 | |
| 270 | port BSSGP_CT_PROC_PT PROC; |
| 271 | |
Harald Welte | fbae83f | 2020-11-15 23:25:55 +0100 | [diff] [blame] | 272 | port BSSGP_BVC_MGMT_PT SGSN_MGMT; |
| 273 | port BSSGP_BVC_MGMT_PT PCU_MGMT; |
| 274 | |
Daniel Willmann | 423d8f4 | 2020-09-08 18:58:22 +0200 | [diff] [blame] | 275 | port TELNETasp_PT GBPVTY; |
| 276 | |
| 277 | var boolean g_initialized := false; |
| 278 | var boolean g_use_echo := false; |
Harald Welte | 16786e9 | 2020-11-27 19:11:56 +0100 | [diff] [blame] | 279 | |
| 280 | var ro_integer g_roi := {}; |
Daniel Willmann | 423d8f4 | 2020-09-08 18:58:22 +0200 | [diff] [blame] | 281 | }; |
| 282 | |
| 283 | type component BSSGP_ConnHdlr { |
Harald Welte | 3dd21b3 | 2020-11-17 19:21:00 +0100 | [diff] [blame] | 284 | /* array of per-BVC ports on the PCU side */ |
Daniel Willmann | 423d8f4 | 2020-09-08 18:58:22 +0200 | [diff] [blame] | 285 | port BSSGP_PT PCU[NUM_PCU]; |
| 286 | port BSSGP_PT PCU_SIG[NUM_PCU]; |
| 287 | port BSSGP_PROC_PT PCU_PROC[NUM_PCU]; |
Harald Welte | 3dd21b3 | 2020-11-17 19:21:00 +0100 | [diff] [blame] | 288 | /* component reference to the component to which we're currently connected */ |
| 289 | var BSSGP_BVC_CT pcu_ct[NUM_PCU]; |
Harald Welte | 0e18824 | 2020-11-22 21:46:48 +0100 | [diff] [blame] | 290 | /* BSSGP BVC configuration of the component to which we're currently connected */ |
| 291 | var BssgpBvcConfig pcu_bvc_cfg[NUM_PCU]; |
Harald Welte | 3dd21b3 | 2020-11-17 19:21:00 +0100 | [diff] [blame] | 292 | |
| 293 | /* array of per-BVC ports on the SGSN side */ |
Daniel Willmann | 423d8f4 | 2020-09-08 18:58:22 +0200 | [diff] [blame] | 294 | port BSSGP_PT SGSN[NUM_SGSN]; |
| 295 | port BSSGP_PT SGSN_SIG[NUM_SGSN]; |
| 296 | port BSSGP_PROC_PT SGSN_PROC[NUM_SGSN]; |
Harald Welte | 3dd21b3 | 2020-11-17 19:21:00 +0100 | [diff] [blame] | 297 | /* component reference to the component to which we're currently connected */ |
| 298 | var BSSGP_BVC_CT sgsn_ct[NUM_PCU]; |
Daniel Willmann | 423d8f4 | 2020-09-08 18:58:22 +0200 | [diff] [blame] | 299 | |
| 300 | var BSSGP_ConnHdlrPars g_pars; |
| 301 | timer g_Tguard; |
| 302 | var LLC_Entities llc; |
Harald Welte | 0e18824 | 2020-11-22 21:46:48 +0100 | [diff] [blame] | 303 | |
| 304 | var ro_integer g_roi := {}; |
Daniel Willmann | 423d8f4 | 2020-09-08 18:58:22 +0200 | [diff] [blame] | 305 | } |
| 306 | |
| 307 | type record SGSN_ConnHdlrNetworkPars { |
| 308 | boolean expect_ptmsi, |
| 309 | boolean expect_auth, |
| 310 | boolean expect_ciph |
| 311 | }; |
| 312 | |
| 313 | type record BSSGP_ConnHdlrPars { |
| 314 | /* IMEI of the simulated ME */ |
| 315 | hexstring imei, |
| 316 | /* IMSI of the simulated MS */ |
| 317 | hexstring imsi, |
| 318 | /* MSISDN of the simulated MS (probably unused) */ |
| 319 | hexstring msisdn, |
| 320 | /* P-TMSI allocated to the simulated MS */ |
| 321 | OCT4 p_tmsi optional, |
| 322 | OCT3 p_tmsi_sig optional, |
| 323 | /* TLLI of the simulated MS */ |
| 324 | OCT4 tlli, |
| 325 | OCT4 tlli_old optional, |
| 326 | RoutingAreaIdentificationV ra optional, |
Harald Welte | 16357a9 | 2020-11-17 18:20:00 +0100 | [diff] [blame] | 327 | GbInstances pcu, |
Harald Welte | 3dd21b3 | 2020-11-17 19:21:00 +0100 | [diff] [blame] | 328 | GbInstances sgsn, |
Daniel Willmann | 423d8f4 | 2020-09-08 18:58:22 +0200 | [diff] [blame] | 329 | float t_guard |
| 330 | }; |
| 331 | |
| 332 | private function f_cellid_to_RAI(in BssgpCellId cell_id) return RoutingAreaIdentificationV { |
| 333 | /* mcc_mnc is encoded as of 24.008 10.5.5.15 */ |
| 334 | var BcdMccMnc mcc_mnc := cell_id.ra_id.lai.mcc_mnc; |
| 335 | |
| 336 | var RoutingAreaIdentificationV ret := { |
| 337 | mccDigit1 := mcc_mnc[0], |
| 338 | mccDigit2 := mcc_mnc[1], |
| 339 | mccDigit3 := mcc_mnc[2], |
| 340 | mncDigit3 := mcc_mnc[3], |
| 341 | mncDigit1 := mcc_mnc[4], |
| 342 | mncDigit2 := mcc_mnc[5], |
| 343 | lac := int2oct(cell_id.ra_id.lai.lac, 16), |
| 344 | rac := int2oct(cell_id.ra_id.rac, 8) |
| 345 | } |
| 346 | return ret; |
| 347 | }; |
| 348 | |
Harald Welte | 9533943 | 2020-12-02 18:50:52 +0100 | [diff] [blame] | 349 | private function f_fix_create_cb(inout BssgpConfig cfg) |
| 350 | { |
| 351 | for (var integer i := 0; i < lengthof(cfg.bvc); i := i + 1) { |
| 352 | if (not isbound(cfg.bvc[i].create_cb)) { |
| 353 | cfg.bvc[i].create_cb := refers(BSSGP_Emulation.DefaultCreateCallback) |
| 354 | } |
| 355 | } |
| 356 | } |
| 357 | |
Daniel Willmann | 423d8f4 | 2020-09-08 18:58:22 +0200 | [diff] [blame] | 358 | private function f_init_gb_pcu(inout GbInstance gb, charstring id, integer offset) runs on test_CT { |
Harald Welte | b419d0e | 2020-11-16 16:45:05 +0100 | [diff] [blame] | 359 | var charstring ns_id := id & "-NS(PCU[" & int2str(offset) & "])"; |
| 360 | var charstring bssgp_id := id & "-BSSGP(PCU[" & int2str(offset) & "])"; |
| 361 | gb.vc_NS := NS_CT.create(ns_id); |
| 362 | gb.vc_BSSGP := BSSGP_CT.create(bssgp_id); |
Daniel Willmann | 423d8f4 | 2020-09-08 18:58:22 +0200 | [diff] [blame] | 363 | /* connect lower end of BSSGP emulation with NS upper port */ |
| 364 | connect(gb.vc_BSSGP:BSCP, gb.vc_NS:NS_SP); |
| 365 | |
Harald Welte | b419d0e | 2020-11-16 16:45:05 +0100 | [diff] [blame] | 366 | gb.vc_NS.start(NSStart(mp_nsconfig_pcu[offset], ns_id)); |
| 367 | gb.vc_BSSGP.start(BssgpStart(gb.cfg, bssgp_id)); |
Daniel Willmann | 423d8f4 | 2020-09-08 18:58:22 +0200 | [diff] [blame] | 368 | |
| 369 | for (var integer i := 0; i < lengthof(gb.cfg.bvc); i := i + 1) { |
| 370 | connect(self:PROC, gb.vc_BSSGP:PROC); |
| 371 | gb.vc_BSSGP_BVC[i] := f_bssgp_get_bvci_ct(gb.cfg.bvc[i].bvci, PROC); |
| 372 | disconnect(self:PROC, gb.vc_BSSGP:PROC); |
Harald Welte | fbae83f | 2020-11-15 23:25:55 +0100 | [diff] [blame] | 373 | connect(self:PCU_MGMT, gb.vc_BSSGP_BVC[i]:MGMT); |
Daniel Willmann | 423d8f4 | 2020-09-08 18:58:22 +0200 | [diff] [blame] | 374 | } |
Harald Welte | 16786e9 | 2020-11-27 19:11:56 +0100 | [diff] [blame] | 375 | connect(self:PCU_MGMT, gb.vc_BSSGP:MGMT); |
Daniel Willmann | 423d8f4 | 2020-09-08 18:58:22 +0200 | [diff] [blame] | 376 | } |
| 377 | |
| 378 | private function f_init_gb_sgsn(inout GbInstance gb, charstring id, integer offset) runs on test_CT { |
Harald Welte | b419d0e | 2020-11-16 16:45:05 +0100 | [diff] [blame] | 379 | var charstring ns_id := id & "-NS(SGSN[" & int2str(offset) & "])"; |
| 380 | var charstring bssgp_id := id & "-BSSGP(SGSN[" & int2str(offset) & "])"; |
| 381 | gb.vc_NS := NS_CT.create(ns_id); |
| 382 | gb.vc_BSSGP := BSSGP_CT.create(bssgp_id); |
Daniel Willmann | 423d8f4 | 2020-09-08 18:58:22 +0200 | [diff] [blame] | 383 | /* connect lower end of BSSGP emulation with NS upper port */ |
| 384 | connect(gb.vc_BSSGP:BSCP, gb.vc_NS:NS_SP); |
| 385 | |
Harald Welte | b419d0e | 2020-11-16 16:45:05 +0100 | [diff] [blame] | 386 | gb.vc_NS.start(NSStart(mp_nsconfig_sgsn[offset], ns_id)); |
| 387 | gb.vc_BSSGP.start(BssgpStart(gb.cfg, bssgp_id)); |
Daniel Willmann | 423d8f4 | 2020-09-08 18:58:22 +0200 | [diff] [blame] | 388 | |
| 389 | for (var integer i := 0; i < lengthof(gb.cfg.bvc); i := i + 1) { |
| 390 | connect(self:PROC, gb.vc_BSSGP:PROC); |
| 391 | gb.vc_BSSGP_BVC[i] := f_bssgp_get_bvci_ct(gb.cfg.bvc[i].bvci, PROC); |
| 392 | disconnect(self:PROC, gb.vc_BSSGP:PROC); |
Harald Welte | fbae83f | 2020-11-15 23:25:55 +0100 | [diff] [blame] | 393 | connect(self:SGSN_MGMT, gb.vc_BSSGP_BVC[i]:MGMT); |
Daniel Willmann | 423d8f4 | 2020-09-08 18:58:22 +0200 | [diff] [blame] | 394 | } |
Harald Welte | 16786e9 | 2020-11-27 19:11:56 +0100 | [diff] [blame] | 395 | connect(self:SGSN_MGMT, gb.vc_BSSGP:MGMT); |
Daniel Willmann | 423d8f4 | 2020-09-08 18:58:22 +0200 | [diff] [blame] | 396 | } |
| 397 | |
| 398 | |
| 399 | private function f_init_vty() runs on test_CT { |
| 400 | map(self:GBPVTY, system:GBPVTY); |
| 401 | f_vty_set_prompts(GBPVTY); |
| 402 | f_vty_transceive(GBPVTY, "enable"); |
| 403 | } |
| 404 | |
Harald Welte | fbae83f | 2020-11-15 23:25:55 +0100 | [diff] [blame] | 405 | type record of integer ro_integer; |
| 406 | |
| 407 | private function ro_integer_contains(ro_integer r, integer x) return boolean { |
| 408 | for (var integer j := 0; j < lengthof(r); j := j+1) { |
| 409 | if (r[j] == x) { |
| 410 | return true; |
| 411 | } |
| 412 | } |
| 413 | return false; |
| 414 | } |
| 415 | |
Harald Welte | 6d63f74 | 2020-11-15 19:44:04 +0100 | [diff] [blame] | 416 | function f_init() runs on test_CT { |
Harald Welte | fbae83f | 2020-11-15 23:25:55 +0100 | [diff] [blame] | 417 | var ro_integer bvci_unblocked := {}; |
| 418 | var BssgpStatusIndication bsi; |
Daniel Willmann | 423d8f4 | 2020-09-08 18:58:22 +0200 | [diff] [blame] | 419 | var integer i; |
| 420 | |
| 421 | if (g_initialized == true) { |
| 422 | return; |
| 423 | } |
| 424 | g_initialized := true; |
Daniel Willmann | 423d8f4 | 2020-09-08 18:58:22 +0200 | [diff] [blame] | 425 | |
| 426 | g_sgsn[0].cfg := { |
Harald Welte | 6d63f74 | 2020-11-15 19:44:04 +0100 | [diff] [blame] | 427 | nsei := mp_nsconfig_sgsn[0].nsei, |
Daniel Willmann | 423d8f4 | 2020-09-08 18:58:22 +0200 | [diff] [blame] | 428 | sgsn_role := true, |
Harald Welte | 6d63f74 | 2020-11-15 19:44:04 +0100 | [diff] [blame] | 429 | bvc := { } |
| 430 | } |
| 431 | for (i := 0; i < lengthof(mp_gbconfigs); i := i+1) { |
| 432 | g_pcu[i].cfg := mp_gbconfigs[i]; |
Harald Welte | 9533943 | 2020-12-02 18:50:52 +0100 | [diff] [blame] | 433 | /* make sure all have a proper crate_cb, which cannot be specified in config file */ |
| 434 | f_fix_create_cb(g_pcu[i].cfg); |
Harald Welte | 6d63f74 | 2020-11-15 19:44:04 +0100 | [diff] [blame] | 435 | /* concatenate all the PCU-side BVCs for the SGSN side */ |
Harald Welte | 9533943 | 2020-12-02 18:50:52 +0100 | [diff] [blame] | 436 | g_sgsn[0].cfg.bvc := g_sgsn[0].cfg.bvc & g_pcu[i].cfg.bvc; |
Harald Welte | 6d63f74 | 2020-11-15 19:44:04 +0100 | [diff] [blame] | 437 | } |
Daniel Willmann | 423d8f4 | 2020-09-08 18:58:22 +0200 | [diff] [blame] | 438 | |
| 439 | f_init_vty(); |
Harald Welte | 6d63f74 | 2020-11-15 19:44:04 +0100 | [diff] [blame] | 440 | for (i := 0; i < lengthof(mp_nsconfig_sgsn); i := i+1) { |
Daniel Willmann | 443fc57 | 2020-11-18 13:26:57 +0100 | [diff] [blame] | 441 | f_vty_transceive(GBPVTY, "nsvc nsei " & int2str(g_sgsn[i].cfg.nsei) & " force-unconfigured"); |
Daniel Willmann | ad93c05 | 2020-12-04 14:14:38 +0100 | [diff] [blame] | 442 | } |
| 443 | for (i := 0; i < lengthof(mp_nsconfig_pcu); i := i+1) { |
| 444 | f_vty_transceive(GBPVTY, "nsvc nsei " & int2str(g_pcu[i].cfg.nsei) & " force-unconfigured"); |
| 445 | f_vty_transceive(GBPVTY, "delete-gbproxy-peer " & int2str(g_pcu[i].cfg.nsei) & " only-bvc"); |
| 446 | } |
| 447 | |
| 448 | for (i := 0; i < lengthof(mp_nsconfig_sgsn); i := i+1) { |
Harald Welte | ea1ba59 | 2020-11-17 18:05:13 +0100 | [diff] [blame] | 449 | f_init_gb_sgsn(g_sgsn[i], "GbProxy_Test", i); |
Harald Welte | 6d63f74 | 2020-11-15 19:44:04 +0100 | [diff] [blame] | 450 | } |
Daniel Willmann | 423d8f4 | 2020-09-08 18:58:22 +0200 | [diff] [blame] | 451 | f_sleep(4.0); |
Harald Welte | 6d63f74 | 2020-11-15 19:44:04 +0100 | [diff] [blame] | 452 | for (i := 0; i < lengthof(mp_nsconfig_pcu); i := i+1) { |
Harald Welte | b419d0e | 2020-11-16 16:45:05 +0100 | [diff] [blame] | 453 | f_init_gb_pcu(g_pcu[i], "GbProxy_Test", i); |
Harald Welte | 6d63f74 | 2020-11-15 19:44:04 +0100 | [diff] [blame] | 454 | } |
Harald Welte | fbae83f | 2020-11-15 23:25:55 +0100 | [diff] [blame] | 455 | |
| 456 | /* wait until all BVC are unblocked on both sides */ |
Harald Welte | d280127 | 2020-11-17 19:22:58 +0100 | [diff] [blame] | 457 | timer T := 15.0; |
Harald Welte | fbae83f | 2020-11-15 23:25:55 +0100 | [diff] [blame] | 458 | T.start; |
| 459 | alt { |
| 460 | [] SGSN_MGMT.receive(BssgpStatusIndication:{*, ?, BVC_S_UNBLOCKED}) -> value bsi { |
| 461 | bvci_unblocked := bvci_unblocked & { bsi.bvci }; |
| 462 | if (lengthof(bvci_unblocked) != lengthof(g_sgsn[0].cfg.bvc)) { |
| 463 | repeat; |
| 464 | } |
| 465 | } |
| 466 | [] SGSN_MGMT.receive(BssgpStatusIndication:{*, ?, ?}) { |
| 467 | repeat; |
| 468 | } |
Harald Welte | 3c90515 | 2020-11-26 20:56:09 +0100 | [diff] [blame] | 469 | [] SGSN_MGMT.receive(BssgpResetIndication:?) { |
| 470 | repeat; |
| 471 | } |
Harald Welte | fbae83f | 2020-11-15 23:25:55 +0100 | [diff] [blame] | 472 | [] SGSN_MGMT.receive { |
| 473 | setverdict(fail, "Received unexpected message on SGSN_MGMT"); |
| 474 | mtc.stop; |
| 475 | } |
| 476 | |
| 477 | [] PCU_MGMT.receive(BssgpStatusIndication:{*, ?, BVC_S_UNBLOCKED}) -> value bsi { |
| 478 | repeat; |
| 479 | } |
| 480 | [] PCU_MGMT.receive(BssgpStatusIndication:{*, ?, ?}) { |
| 481 | repeat; |
| 482 | } |
| 483 | [] PCU_MGMT.receive(BssgpResetIndication:{0}) { |
| 484 | repeat; |
| 485 | } |
| 486 | [] PCU_MGMT.receive { |
| 487 | setverdict(fail, "Received unexpected message on PCU_MGMT"); |
| 488 | mtc.stop; |
| 489 | } |
| 490 | |
| 491 | [] T.timeout { |
| 492 | setverdict(fail, "Timeout waiting for unblock of all BVCs"); |
| 493 | mtc.stop; |
| 494 | } |
| 495 | } |
| 496 | |
| 497 | /* iterate over list and check all BVCI */ |
| 498 | for (i := 0; i < lengthof(g_sgsn[0].cfg.bvc); i := i+1) { |
| 499 | var BssgpBvci bvci := g_sgsn[0].cfg.bvc[i].bvci; |
| 500 | if (not ro_integer_contains(bvci_unblocked, bvci)) { |
| 501 | setverdict(fail, "BVCI=", bvci, " was not unblocked during start-up"); |
| 502 | mtc.stop; |
| 503 | } |
| 504 | } |
Daniel Willmann | 423d8f4 | 2020-09-08 18:58:22 +0200 | [diff] [blame] | 505 | } |
| 506 | |
| 507 | function f_cleanup() runs on test_CT { |
| 508 | self.stop; |
| 509 | } |
| 510 | |
| 511 | type function void_fn(charstring id) runs on BSSGP_ConnHdlr; |
| 512 | |
| 513 | /* helper function to create, connect and start a BSSGP_ConnHdlr component */ |
Harald Welte | 6d63f74 | 2020-11-15 19:44:04 +0100 | [diff] [blame] | 514 | function f_start_handler(void_fn fn, charstring id, GbInstances pcu, GbInstances sgsn, integer imsi_suffix, |
Daniel Willmann | 423d8f4 | 2020-09-08 18:58:22 +0200 | [diff] [blame] | 515 | float t_guard := 30.0) |
| 516 | runs on test_CT return BSSGP_ConnHdlr { |
| 517 | var BSSGP_ConnHdlr vc_conn; |
| 518 | |
| 519 | var BSSGP_ConnHdlrPars pars := { |
| 520 | imei := f_gen_imei(imsi_suffix), |
| 521 | imsi := f_gen_imsi(imsi_suffix), |
| 522 | msisdn := f_gen_msisdn(imsi_suffix), |
| 523 | p_tmsi := omit, |
| 524 | p_tmsi_sig := omit, |
| 525 | tlli := f_gprs_tlli_random(), |
| 526 | tlli_old := omit, |
| 527 | ra := omit, |
Harald Welte | 16357a9 | 2020-11-17 18:20:00 +0100 | [diff] [blame] | 528 | pcu := g_pcu, |
Harald Welte | 3dd21b3 | 2020-11-17 19:21:00 +0100 | [diff] [blame] | 529 | sgsn := g_sgsn, |
Daniel Willmann | 423d8f4 | 2020-09-08 18:58:22 +0200 | [diff] [blame] | 530 | t_guard := t_guard |
| 531 | }; |
| 532 | |
| 533 | vc_conn := BSSGP_ConnHdlr.create(id); |
Daniel Willmann | 423d8f4 | 2020-09-08 18:58:22 +0200 | [diff] [blame] | 534 | |
| 535 | vc_conn.start(f_handler_init(fn, id, pars)); |
| 536 | return vc_conn; |
| 537 | } |
| 538 | |
Harald Welte | 3dd21b3 | 2020-11-17 19:21:00 +0100 | [diff] [blame] | 539 | /* Connect the PCU-side per-BVC ports (PCU/PCU_SIG/PCU_PROC) array slot 'port_idx' to specified per-BVC component */ |
Harald Welte | 0e18824 | 2020-11-22 21:46:48 +0100 | [diff] [blame] | 540 | private function f_connect_to_pcu_bvc(integer port_idx, integer nse_idx, integer bvc_idx) |
| 541 | runs on BSSGP_ConnHdlr { |
| 542 | var BSSGP_BVC_CT bvc_ct := g_pars.pcu[nse_idx].vc_BSSGP_BVC[bvc_idx] |
Harald Welte | 3dd21b3 | 2020-11-17 19:21:00 +0100 | [diff] [blame] | 543 | if (PCU[port_idx].checkstate("Connected")) { |
| 544 | /* unregister + disconnect from old BVC */ |
| 545 | f_client_unregister(g_pars.imsi, PCU_PROC[port_idx]); |
| 546 | disconnect(self:PCU[port_idx], pcu_ct[port_idx]:BSSGP_SP); |
| 547 | disconnect(self:PCU_SIG[port_idx], pcu_ct[port_idx]:BSSGP_SP_SIG); |
| 548 | disconnect(self:PCU_PROC[port_idx], pcu_ct[port_idx]:BSSGP_PROC); |
| 549 | } |
| 550 | /* connect to new BVC and register us */ |
| 551 | connect(self:PCU[port_idx], bvc_ct:BSSGP_SP); |
| 552 | connect(self:PCU_SIG[port_idx], bvc_ct:BSSGP_SP_SIG); |
| 553 | connect(self:PCU_PROC[port_idx], bvc_ct:BSSGP_PROC); |
| 554 | f_client_register(g_pars.imsi, g_pars.tlli, PCU_PROC[port_idx]); |
| 555 | pcu_ct[port_idx] := bvc_ct; |
Harald Welte | 0e18824 | 2020-11-22 21:46:48 +0100 | [diff] [blame] | 556 | pcu_bvc_cfg[port_idx] := g_pars.pcu[nse_idx].cfg.bvc[bvc_idx]; |
Harald Welte | 3dd21b3 | 2020-11-17 19:21:00 +0100 | [diff] [blame] | 557 | } |
| 558 | |
| 559 | /* Connect the SGSN-side per-BVC ports (SGSN/SGSN_SIG/SGSN_PROC) array slot 'port_idx' to specified per-BVC component */ |
| 560 | private function f_connect_to_sgsn_bvc(integer port_idx, BSSGP_BVC_CT bvc_ct) runs on BSSGP_ConnHdlr { |
| 561 | if (SGSN[port_idx].checkstate("Connected")) { |
| 562 | /* unregister + disconnect from old BVC */ |
| 563 | f_client_unregister(g_pars.imsi, SGSN_PROC[port_idx]); |
| 564 | disconnect(self:SGSN[port_idx], sgsn_ct[port_idx]:BSSGP_SP); |
| 565 | disconnect(self:SGSN_SIG[port_idx], sgsn_ct[port_idx]:BSSGP_SP_SIG); |
| 566 | disconnect(self:SGSN_PROC[port_idx], sgsn_ct[port_idx]:BSSGP_PROC); |
| 567 | } |
| 568 | /* connect to new BVC and register us */ |
| 569 | connect(self:SGSN[port_idx], bvc_ct:BSSGP_SP); |
| 570 | connect(self:SGSN_SIG[port_idx], bvc_ct:BSSGP_SP_SIG); |
| 571 | connect(self:SGSN_PROC[port_idx], bvc_ct:BSSGP_PROC); |
| 572 | f_client_register(g_pars.imsi, g_pars.tlli, SGSN_PROC[port_idx]); |
| 573 | sgsn_ct[port_idx] := bvc_ct; |
| 574 | } |
| 575 | |
Daniel Willmann | 423d8f4 | 2020-09-08 18:58:22 +0200 | [diff] [blame] | 576 | private altstep as_Tguard() runs on BSSGP_ConnHdlr { |
| 577 | [] g_Tguard.timeout { |
| 578 | setverdict(fail, "Tguard timeout"); |
| 579 | mtc.stop; |
| 580 | } |
| 581 | } |
| 582 | |
| 583 | /* first function called in every ConnHdlr */ |
| 584 | private function f_handler_init(void_fn fn, charstring id, BSSGP_ConnHdlrPars pars) |
| 585 | runs on BSSGP_ConnHdlr { |
Harald Welte | 1e834f3 | 2020-11-15 20:02:59 +0100 | [diff] [blame] | 586 | var integer i; |
Daniel Willmann | 423d8f4 | 2020-09-08 18:58:22 +0200 | [diff] [blame] | 587 | /* do some common stuff like setting up g_pars */ |
| 588 | g_pars := pars; |
| 589 | |
| 590 | llc := f_llc_create(false); |
| 591 | |
Harald Welte | 3dd21b3 | 2020-11-17 19:21:00 +0100 | [diff] [blame] | 592 | /* default connections on PCU side: First BVC of each NSE/PCU */ |
| 593 | for (i := 0; i < lengthof(g_pars.pcu); i := i+1) { |
Harald Welte | 0e18824 | 2020-11-22 21:46:48 +0100 | [diff] [blame] | 594 | f_connect_to_pcu_bvc(port_idx := i, nse_idx := i, bvc_idx := 0); |
Harald Welte | 1e834f3 | 2020-11-15 20:02:59 +0100 | [diff] [blame] | 595 | } |
Harald Welte | 3dd21b3 | 2020-11-17 19:21:00 +0100 | [diff] [blame] | 596 | |
| 597 | /* default connections on SGSN side: First BVC of each NSE/SGSN */ |
| 598 | for (i := 0; i < lengthof(g_pars.sgsn); i := i+1) { |
| 599 | f_connect_to_sgsn_bvc(i, g_pars.sgsn[i].vc_BSSGP_BVC[0]); |
Harald Welte | 1e834f3 | 2020-11-15 20:02:59 +0100 | [diff] [blame] | 600 | } |
Daniel Willmann | 423d8f4 | 2020-09-08 18:58:22 +0200 | [diff] [blame] | 601 | |
| 602 | g_Tguard.start(pars.t_guard); |
| 603 | activate(as_Tguard()); |
| 604 | |
| 605 | /* call the user-supplied test case function */ |
| 606 | fn.apply(id); |
| 607 | } |
| 608 | |
Harald Welte | 1e834f3 | 2020-11-15 20:02:59 +0100 | [diff] [blame] | 609 | private function f_client_register(hexstring imsi, OCT4 tlli, BSSGP_PROC_PT PT) |
| 610 | runs on BSSGP_ConnHdlr { |
| 611 | PT.call(BSSGP_register_client:{imsi, tlli}) { |
| 612 | [] PT.getreply(BSSGP_register_client:{imsi, tlli}) {}; |
| 613 | } |
| 614 | } |
| 615 | |
| 616 | private function f_client_unregister(hexstring imsi, BSSGP_PROC_PT PT) |
| 617 | runs on BSSGP_ConnHdlr { |
| 618 | PT.call(BSSGP_unregister_client:{imsi}) { |
| 619 | [] PT.getreply(BSSGP_unregister_client:{imsi}) {}; |
| 620 | } |
| 621 | } |
| 622 | |
Harald Welte | 22ef5d9 | 2020-11-16 13:35:14 +0100 | [diff] [blame] | 623 | /* Send 'tx' on PTP-BVCI from PCU; expect 'rx' on SGSN */ |
| 624 | friend function f_pcu2sgsn(template (value) PDU_BSSGP tx, template (present) PDU_BSSGP exp_rx, |
Daniel Willmann | 4798fd7 | 2020-11-24 16:23:29 +0100 | [diff] [blame] | 625 | integer pcu_idx := 0, integer sgsn_idx := 0, boolean use_sig := false) runs on BSSGP_ConnHdlr { |
Harald Welte | 22ef5d9 | 2020-11-16 13:35:14 +0100 | [diff] [blame] | 626 | var PDU_BSSGP rx; |
| 627 | timer T := 1.0; |
| 628 | |
Daniel Willmann | 4798fd7 | 2020-11-24 16:23:29 +0100 | [diff] [blame] | 629 | if (use_sig) { |
| 630 | PCU_SIG[pcu_idx].send(tx); |
| 631 | } else { |
| 632 | PCU[pcu_idx].send(tx); |
| 633 | } |
| 634 | |
Harald Welte | 22ef5d9 | 2020-11-16 13:35:14 +0100 | [diff] [blame] | 635 | T.start; |
| 636 | alt { |
Daniel Willmann | 4798fd7 | 2020-11-24 16:23:29 +0100 | [diff] [blame] | 637 | [use_sig] SGSN_SIG[sgsn_idx].receive(exp_rx) { |
| 638 | setverdict(pass); |
| 639 | } |
| 640 | [not use_sig] SGSN[sgsn_idx].receive(exp_rx) { |
Harald Welte | 22ef5d9 | 2020-11-16 13:35:14 +0100 | [diff] [blame] | 641 | setverdict(pass); |
| 642 | } |
| 643 | [] SGSN[sgsn_idx].receive(PDU_BSSGP:?) -> value rx { |
| 644 | setverdict(fail, "Unexpected BSSGP on SGSN side: ", rx); |
| 645 | mtc.stop; |
| 646 | } |
Daniel Willmann | 4798fd7 | 2020-11-24 16:23:29 +0100 | [diff] [blame] | 647 | [] SGSN_SIG[sgsn_idx].receive(PDU_BSSGP:?) -> value rx { |
| 648 | setverdict(fail, "Unexpected SIG BSSGP on SGSN side: ", rx); |
| 649 | mtc.stop; |
| 650 | } |
Harald Welte | 22ef5d9 | 2020-11-16 13:35:14 +0100 | [diff] [blame] | 651 | [] T.timeout { |
Harald Welte | 8b32641 | 2020-11-29 16:05:38 +0100 | [diff] [blame] | 652 | setverdict(fail, "Timeout waiting for BSSGP on SGSN side: ", exp_rx); |
Harald Welte | 22ef5d9 | 2020-11-16 13:35:14 +0100 | [diff] [blame] | 653 | mtc.stop; |
| 654 | } |
| 655 | } |
| 656 | } |
| 657 | |
| 658 | /* Send 'tx' on PTP-BVCI from SGSN; expect 'rx' on PCU */ |
| 659 | friend function f_sgsn2pcu(template (value) PDU_BSSGP tx, template (present) PDU_BSSGP exp_rx, |
Daniel Willmann | 4798fd7 | 2020-11-24 16:23:29 +0100 | [diff] [blame] | 660 | integer sgsn_idx:= 0, integer pcu_idx := 0, boolean use_sig := false) runs on BSSGP_ConnHdlr { |
Harald Welte | 22ef5d9 | 2020-11-16 13:35:14 +0100 | [diff] [blame] | 661 | var PDU_BSSGP rx; |
| 662 | timer T := 1.0; |
| 663 | |
Daniel Willmann | 4798fd7 | 2020-11-24 16:23:29 +0100 | [diff] [blame] | 664 | if (use_sig) { |
| 665 | SGSN_SIG[sgsn_idx].send(tx); |
| 666 | } else { |
| 667 | SGSN[sgsn_idx].send(tx); |
| 668 | } |
| 669 | |
Harald Welte | 22ef5d9 | 2020-11-16 13:35:14 +0100 | [diff] [blame] | 670 | T.start; |
| 671 | alt { |
Daniel Willmann | 4798fd7 | 2020-11-24 16:23:29 +0100 | [diff] [blame] | 672 | [use_sig] PCU_SIG[pcu_idx].receive(exp_rx) { |
| 673 | setverdict(pass); |
| 674 | } |
| 675 | [not use_sig] PCU[pcu_idx].receive(exp_rx) { |
Harald Welte | 22ef5d9 | 2020-11-16 13:35:14 +0100 | [diff] [blame] | 676 | setverdict(pass); |
| 677 | } |
| 678 | [] PCU[pcu_idx].receive(PDU_BSSGP:?) -> value rx { |
| 679 | setverdict(fail, "Unexpected BSSGP on PCU side: ", rx); |
| 680 | mtc.stop; |
| 681 | } |
Daniel Willmann | 4798fd7 | 2020-11-24 16:23:29 +0100 | [diff] [blame] | 682 | [] PCU_SIG[pcu_idx].receive(PDU_BSSGP:?) -> value rx { |
| 683 | setverdict(fail, "Unexpected SIG BSSGP on PCU side: ", rx); |
| 684 | mtc.stop; |
| 685 | } |
Harald Welte | 22ef5d9 | 2020-11-16 13:35:14 +0100 | [diff] [blame] | 686 | [] T.timeout { |
Harald Welte | 8b32641 | 2020-11-29 16:05:38 +0100 | [diff] [blame] | 687 | setverdict(fail, "Timeout waiting for BSSGP on PCU side: ", exp_rx); |
Harald Welte | 22ef5d9 | 2020-11-16 13:35:14 +0100 | [diff] [blame] | 688 | mtc.stop; |
| 689 | } |
| 690 | } |
| 691 | } |
Harald Welte | 1e834f3 | 2020-11-15 20:02:59 +0100 | [diff] [blame] | 692 | |
Harald Welte | 3807ed1 | 2020-11-24 19:05:22 +0100 | [diff] [blame] | 693 | /*********************************************************************** |
| 694 | * GlobaLTest_CT: Using the per-NSE GLOBAL ports on PCU + SGSN side |
| 695 | ***********************************************************************/ |
| 696 | |
| 697 | type component GlobalTest_CT extends test_CT { |
| 698 | port BSSGP_PT G_PCU[NUM_PCU]; |
| 699 | port BSSGP_PT G_SGSN[NUM_SGSN]; |
| 700 | }; |
| 701 | |
| 702 | private function f_global_init() runs on GlobalTest_CT { |
| 703 | var integer i; |
| 704 | for (i := 0; i < lengthof(g_sgsn); i := i+1) { |
| 705 | connect(self:G_SGSN[i], g_sgsn[i].vc_BSSGP:GLOBAL); |
| 706 | } |
| 707 | for (i := 0; i < lengthof(g_pcu); i := i+1) { |
| 708 | connect(self:G_PCU[i], g_pcu[i].vc_BSSGP:GLOBAL); |
| 709 | } |
| 710 | } |
| 711 | |
| 712 | /* Send 'tx' on PTP-BVCI from PCU; expect 'rx' on SGSN */ |
| 713 | friend function f_global_pcu2sgsn(template (value) PDU_BSSGP tx, template (present) PDU_BSSGP exp_rx, |
| 714 | integer pcu_idx := 0, integer sgsn_idx := 0) runs on GlobalTest_CT { |
| 715 | var PDU_BSSGP rx; |
| 716 | timer T := 1.0; |
| 717 | |
| 718 | G_PCU[pcu_idx].send(tx); |
| 719 | T.start; |
| 720 | alt { |
| 721 | [] G_SGSN[sgsn_idx].receive(exp_rx) { |
| 722 | setverdict(pass); |
| 723 | } |
| 724 | [] G_SGSN[sgsn_idx].receive(PDU_BSSGP:?) -> value rx { |
| 725 | setverdict(fail, "Unexpected BSSGP on SGSN side: ", rx); |
| 726 | mtc.stop; |
| 727 | } |
| 728 | [] T.timeout { |
| 729 | setverdict(fail, "Timeout waiting for BSSGP on SGSN side: ", rx); |
| 730 | mtc.stop; |
| 731 | } |
| 732 | } |
| 733 | } |
| 734 | |
| 735 | /* Send 'tx' on PTP-BVCI from SGSN; expect 'rx' on PCU */ |
| 736 | friend function f_global_sgsn2pcu(template (value) PDU_BSSGP tx, template (present) PDU_BSSGP exp_rx, |
| 737 | integer sgsn_idx := 0, integer pcu_idx := 0) runs on GlobalTest_CT { |
| 738 | var PDU_BSSGP rx; |
| 739 | timer T := 1.0; |
| 740 | |
| 741 | G_SGSN[sgsn_idx].send(tx); |
| 742 | T.start; |
| 743 | alt { |
| 744 | [] G_PCU[pcu_idx].receive(exp_rx) { |
| 745 | setverdict(pass); |
| 746 | } |
| 747 | [] G_PCU[pcu_idx].receive(PDU_BSSGP:?) -> value rx { |
| 748 | setverdict(fail, "Unexpected BSSGP on PCU side: ", rx); |
| 749 | mtc.stop; |
| 750 | } |
| 751 | [] T.timeout { |
| 752 | setverdict(fail, "Timeout waiting for BSSGP on PCU side: ", rx); |
| 753 | mtc.stop; |
| 754 | } |
| 755 | } |
| 756 | } |
| 757 | |
| 758 | |
Daniel Willmann | 423d8f4 | 2020-09-08 18:58:22 +0200 | [diff] [blame] | 759 | /* TODO: |
| 760 | * Detach without Attach |
| 761 | * SM procedures without attach / RAU |
| 762 | * ATTACH / RAU |
| 763 | ** with / without authentication |
| 764 | ** with / without P-TMSI allocation |
| 765 | * re-transmissions of LLC frames |
| 766 | * PDP Context activation |
| 767 | ** with different GGSN config in SGSN VTY |
| 768 | ** with different PDP context type (v4/v6/v46) |
| 769 | ** timeout from GGSN |
| 770 | ** multiple / secondary PDP context |
| 771 | */ |
| 772 | |
| 773 | private function f_TC_BVC_bringup(charstring id) runs on BSSGP_ConnHdlr { |
| 774 | f_sleep(5.0); |
| 775 | setverdict(pass); |
| 776 | } |
| 777 | |
| 778 | testcase TC_BVC_bringup() runs on test_CT { |
| 779 | var BSSGP_ConnHdlr vc_conn; |
| 780 | f_init(); |
| 781 | |
| 782 | vc_conn := f_start_handler(refers(f_TC_BVC_bringup), testcasename(), g_pcu, g_sgsn, 51); |
| 783 | vc_conn.done; |
| 784 | |
| 785 | f_cleanup(); |
| 786 | } |
| 787 | |
| 788 | friend function f_bssgp_suspend(integer ran_idx := 0) runs on BSSGP_ConnHdlr return OCT1 { |
Harald Welte | 16357a9 | 2020-11-17 18:20:00 +0100 | [diff] [blame] | 789 | var BssgpBvcConfig bvcc := g_pars.pcu[ran_idx].cfg.bvc[0]; |
Daniel Willmann | 423d8f4 | 2020-09-08 18:58:22 +0200 | [diff] [blame] | 790 | timer T := 5.0; |
| 791 | var PDU_BSSGP rx_pdu; |
Harald Welte | 16357a9 | 2020-11-17 18:20:00 +0100 | [diff] [blame] | 792 | PCU_SIG[ran_idx].send(ts_BSSGP_SUSPEND(g_pars.tlli, bvcc.cell_id.ra_id)); |
Daniel Willmann | 423d8f4 | 2020-09-08 18:58:22 +0200 | [diff] [blame] | 793 | T.start; |
| 794 | alt { |
Harald Welte | 16357a9 | 2020-11-17 18:20:00 +0100 | [diff] [blame] | 795 | [] PCU_SIG[ran_idx].receive(tr_BSSGP_SUSPEND_ACK(g_pars.tlli, bvcc.cell_id.ra_id, ?)) -> value rx_pdu { |
Daniel Willmann | 423d8f4 | 2020-09-08 18:58:22 +0200 | [diff] [blame] | 796 | return rx_pdu.pDU_BSSGP_SUSPEND_ACK.suspend_Reference_Number.suspend_Reference_Number_value; |
| 797 | } |
Harald Welte | 16357a9 | 2020-11-17 18:20:00 +0100 | [diff] [blame] | 798 | [] PCU_SIG[ran_idx].receive(tr_BSSGP_SUSPEND_NACK(g_pars.tlli, bvcc.cell_id.ra_id, ?)) -> value rx_pdu { |
Daniel Willmann | 423d8f4 | 2020-09-08 18:58:22 +0200 | [diff] [blame] | 799 | setverdict(fail, "SUSPEND-NACK in response to SUSPEND for TLLI ", g_pars.tlli); |
| 800 | mtc.stop; |
| 801 | } |
| 802 | [] T.timeout { |
| 803 | setverdict(fail, "No SUSPEND-ACK in response to SUSPEND for TLLI ", g_pars.tlli); |
| 804 | mtc.stop; |
| 805 | } |
| 806 | } |
| 807 | return '00'O; |
| 808 | } |
| 809 | |
| 810 | friend function f_bssgp_resume(OCT1 susp_ref, integer ran_idx := 0) runs on BSSGP_ConnHdlr { |
Harald Welte | 16357a9 | 2020-11-17 18:20:00 +0100 | [diff] [blame] | 811 | var BssgpBvcConfig bvcc := g_pars.pcu[ran_idx].cfg.bvc[0]; |
Daniel Willmann | 423d8f4 | 2020-09-08 18:58:22 +0200 | [diff] [blame] | 812 | timer T := 5.0; |
Harald Welte | 16357a9 | 2020-11-17 18:20:00 +0100 | [diff] [blame] | 813 | PCU_SIG[ran_idx].send(ts_BSSGP_RESUME(g_pars.tlli, bvcc.cell_id.ra_id, susp_ref)); |
Daniel Willmann | 423d8f4 | 2020-09-08 18:58:22 +0200 | [diff] [blame] | 814 | T.start; |
| 815 | alt { |
Harald Welte | 16357a9 | 2020-11-17 18:20:00 +0100 | [diff] [blame] | 816 | [] PCU_SIG[ran_idx].receive(tr_BSSGP_RESUME_ACK(g_pars.tlli, bvcc.cell_id.ra_id)); |
| 817 | [] PCU_SIG[ran_idx].receive(tr_BSSGP_RESUME_NACK(g_pars.tlli, bvcc.cell_id.ra_id, ?)) { |
Daniel Willmann | 423d8f4 | 2020-09-08 18:58:22 +0200 | [diff] [blame] | 818 | setverdict(fail, "RESUME-NACK in response to RESUME for TLLI ", g_pars.tlli); |
| 819 | mtc.stop; |
| 820 | } |
| 821 | [] T.timeout { |
| 822 | setverdict(fail, "No RESUME-ACK in response to SUSPEND for TLLI ", g_pars.tlli); |
| 823 | mtc.stop; |
| 824 | } |
| 825 | } |
| 826 | } |
| 827 | |
| 828 | |
Harald Welte | 9268601 | 2020-11-15 21:45:49 +0100 | [diff] [blame] | 829 | /* send uplink-unitdata of a variety of different sizes; expect it to show up on SGSN */ |
| 830 | private function f_TC_ul_unitdata(charstring id) runs on BSSGP_ConnHdlr { |
Harald Welte | 16357a9 | 2020-11-17 18:20:00 +0100 | [diff] [blame] | 831 | var integer ran_idx := 0; |
| 832 | var BssgpBvcConfig bvcc := g_pars.pcu[ran_idx].cfg.bvc[0]; |
Harald Welte | 9268601 | 2020-11-15 21:45:49 +0100 | [diff] [blame] | 833 | var integer i; |
| 834 | |
Harald Welte | 0d5fceb | 2020-11-29 16:04:07 +0100 | [diff] [blame] | 835 | for (i := 0; i < max_fr_info_size-4; i := i+4) { |
Harald Welte | 9268601 | 2020-11-15 21:45:49 +0100 | [diff] [blame] | 836 | var octetstring payload := f_rnd_octstring(i); |
Harald Welte | 16357a9 | 2020-11-17 18:20:00 +0100 | [diff] [blame] | 837 | var template (value) PDU_BSSGP pdu_tx := ts_BSSGP_UL_UD(g_pars.tlli, bvcc.cell_id, payload); |
Harald Welte | 9268601 | 2020-11-15 21:45:49 +0100 | [diff] [blame] | 838 | /* we cannot use pdu_tx as there are some subtle differences in the length field :/ */ |
Harald Welte | 16357a9 | 2020-11-17 18:20:00 +0100 | [diff] [blame] | 839 | var template (present) PDU_BSSGP pdu_rx := tr_BSSGP_UL_UD(g_pars.tlli, bvcc.cell_id, payload); |
Harald Welte | 9268601 | 2020-11-15 21:45:49 +0100 | [diff] [blame] | 840 | |
Harald Welte | 0d5fceb | 2020-11-29 16:04:07 +0100 | [diff] [blame] | 841 | log("UL-UNITDATA(payload_size=", i); |
Harald Welte | 22ef5d9 | 2020-11-16 13:35:14 +0100 | [diff] [blame] | 842 | f_pcu2sgsn(pdu_tx, pdu_rx); |
Harald Welte | 9268601 | 2020-11-15 21:45:49 +0100 | [diff] [blame] | 843 | } |
| 844 | setverdict(pass); |
| 845 | } |
| 846 | |
| 847 | testcase TC_ul_unitdata() runs on test_CT |
| 848 | { |
| 849 | var BSSGP_ConnHdlr vc_conn; |
| 850 | f_init(); |
| 851 | |
| 852 | vc_conn := f_start_handler(refers(f_TC_ul_unitdata), testcasename(), g_pcu, g_sgsn, 1); |
| 853 | vc_conn.done; |
| 854 | /* TODO: start multiple handlers (UEs) on various cells on same and other NSEs */ |
| 855 | |
| 856 | f_cleanup(); |
| 857 | } |
| 858 | |
Harald Welte | 78d8db9 | 2020-11-15 23:27:27 +0100 | [diff] [blame] | 859 | /* send downlink-unitdata of a variety of different sizes; expect it to show up on PCU */ |
| 860 | private function f_TC_dl_unitdata(charstring id) runs on BSSGP_ConnHdlr { |
| 861 | var integer i; |
| 862 | |
Harald Welte | 0d5fceb | 2020-11-29 16:04:07 +0100 | [diff] [blame] | 863 | for (i := 0; i < max_fr_info_size-4; i := i+4) { |
Harald Welte | 78d8db9 | 2020-11-15 23:27:27 +0100 | [diff] [blame] | 864 | var octetstring payload := f_rnd_octstring(i); |
| 865 | var template (value) PDU_BSSGP pdu_tx := |
| 866 | ts_BSSGP_DL_UD(g_pars.tlli, payload, omit, ts_BSSGP_IMSI(g_pars.imsi)); |
| 867 | /* we cannot use pdu_tx as there are some subtle differences in the length field :/ */ |
| 868 | var template (present) PDU_BSSGP pdu_rx := |
| 869 | tr_BSSGP_DL_UD(g_pars.tlli, payload, tr_BSSGP_IMSI(g_pars.imsi)); |
| 870 | |
Harald Welte | 0d5fceb | 2020-11-29 16:04:07 +0100 | [diff] [blame] | 871 | log("DL-UNITDATA(payload_size=", i); |
Harald Welte | 22ef5d9 | 2020-11-16 13:35:14 +0100 | [diff] [blame] | 872 | f_sgsn2pcu(pdu_tx, pdu_rx); |
Harald Welte | 78d8db9 | 2020-11-15 23:27:27 +0100 | [diff] [blame] | 873 | } |
| 874 | setverdict(pass); |
| 875 | } |
| 876 | |
| 877 | testcase TC_dl_unitdata() runs on test_CT |
| 878 | { |
| 879 | var BSSGP_ConnHdlr vc_conn; |
| 880 | f_init(); |
| 881 | |
| 882 | vc_conn := f_start_handler(refers(f_TC_dl_unitdata), testcasename(), g_pcu, g_sgsn, 2); |
| 883 | vc_conn.done; |
| 884 | /* TODO: start multiple handlers (UEs) on various cells on same and other NSEs */ |
| 885 | |
| 886 | f_cleanup(); |
| 887 | } |
Harald Welte | 9268601 | 2020-11-15 21:45:49 +0100 | [diff] [blame] | 888 | |
Harald Welte | 6dc2ac4 | 2020-11-16 09:16:17 +0100 | [diff] [blame] | 889 | private function f_TC_ra_capability(charstring id) runs on BSSGP_ConnHdlr { |
| 890 | var integer i; |
| 891 | |
| 892 | for (i := 0; i < 10; i := i+1) { |
| 893 | var template (value) PDU_BSSGP pdu_tx := ts_BSSGP_RA_CAP(g_pars.tlli, { ts_RaCapRec_BSSGP }); |
| 894 | /* we cannot use pdu_tx as there are some subtle differences in the length field :/ */ |
| 895 | var template (present) PDU_BSSGP pdu_rx := tr_BSSGP_RA_CAP(g_pars.tlli, { tr_RaCapRec_BSSGP }) |
| 896 | |
Harald Welte | 22ef5d9 | 2020-11-16 13:35:14 +0100 | [diff] [blame] | 897 | f_sgsn2pcu(pdu_tx, pdu_rx); |
Harald Welte | 6dc2ac4 | 2020-11-16 09:16:17 +0100 | [diff] [blame] | 898 | } |
| 899 | setverdict(pass); |
| 900 | } |
| 901 | testcase TC_ra_capability() runs on test_CT |
| 902 | { |
| 903 | var BSSGP_ConnHdlr vc_conn; |
| 904 | f_init(); |
| 905 | |
| 906 | vc_conn := f_start_handler(refers(f_TC_ra_capability), testcasename(), g_pcu, g_sgsn, 3); |
| 907 | vc_conn.done; |
| 908 | /* TODO: start multiple handlers (UEs) on various cells on same and other NSEs */ |
| 909 | |
| 910 | f_cleanup(); |
| 911 | } |
| 912 | |
Daniel Willmann | ace3ece | 2020-11-16 19:53:26 +0100 | [diff] [blame] | 913 | private function f_TC_ra_capability_upd(charstring id) runs on BSSGP_ConnHdlr { |
| 914 | var integer i; |
| 915 | var OCT1 tag; |
| 916 | for (i := 0; i < 10; i := i+1) { |
| 917 | tag := int2oct(23 + i, 1); |
| 918 | var template (value) PDU_BSSGP pdu_tx := ts_BSSGP_RA_CAP_UPD(g_pars.tlli, tag); |
| 919 | /* we cannot use pdu_tx as there are some subtle differences in the length field :/ */ |
| 920 | var template (present) PDU_BSSGP pdu_rx := tr_BSSGP_RA_CAP_UPD(g_pars.tlli, tag) |
| 921 | |
| 922 | f_pcu2sgsn(pdu_tx, pdu_rx); |
| 923 | |
| 924 | pdu_tx := ts_BSSGP_RA_CAP_UPD_ACK(g_pars.tlli, tag, '42'O); |
| 925 | /* we cannot use pdu_tx as there are some subtle differences in the length field :/ */ |
| 926 | pdu_rx := tr_BSSGP_RA_CAP_UPD_ACK(g_pars.tlli, tag, '42'O) |
| 927 | |
| 928 | f_sgsn2pcu(pdu_tx, pdu_rx); |
| 929 | } |
| 930 | setverdict(pass); |
| 931 | } |
| 932 | testcase TC_ra_capability_upd() runs on test_CT |
| 933 | { |
| 934 | var BSSGP_ConnHdlr vc_conn; |
| 935 | f_init(); |
| 936 | |
Daniel Willmann | 54833f2 | 2020-11-19 15:43:52 +0100 | [diff] [blame] | 937 | vc_conn := f_start_handler(refers(f_TC_ra_capability_upd), testcasename(), g_pcu, g_sgsn, 4); |
Daniel Willmann | ace3ece | 2020-11-16 19:53:26 +0100 | [diff] [blame] | 938 | vc_conn.done; |
| 939 | /* TODO: start multiple handlers (UEs) on various cells on same and other NSEs */ |
| 940 | |
| 941 | f_cleanup(); |
| 942 | } |
| 943 | |
Daniel Willmann | 165d661 | 2020-11-19 14:27:29 +0100 | [diff] [blame] | 944 | private function f_TC_radio_status(charstring id) runs on BSSGP_ConnHdlr { |
| 945 | var integer i; |
| 946 | var BssgpRadioCause cause := BSSGP_RADIO_CAUSE_CONTACT_LOST; |
| 947 | for (i := 0; i < 10; i := i+1) { |
| 948 | var template (value) PDU_BSSGP pdu_tx := ts_BSSGP_RADIO_STATUS(g_pars.tlli, cause); |
| 949 | /* we cannot use pdu_tx as there are some subtle differences in the length field :/ */ |
| 950 | var template (present) PDU_BSSGP pdu_rx := tr_BSSGP_RADIO_STATUS(g_pars.tlli, cause) |
| 951 | |
| 952 | f_pcu2sgsn(pdu_tx, pdu_rx); |
| 953 | } |
| 954 | setverdict(pass); |
| 955 | } |
| 956 | testcase TC_radio_status() runs on test_CT |
| 957 | { |
| 958 | var BSSGP_ConnHdlr vc_conn; |
| 959 | f_init(); |
| 960 | |
Daniel Willmann | 54833f2 | 2020-11-19 15:43:52 +0100 | [diff] [blame] | 961 | vc_conn := f_start_handler(refers(f_TC_radio_status), testcasename(), g_pcu, g_sgsn, 5); |
Daniel Willmann | 165d661 | 2020-11-19 14:27:29 +0100 | [diff] [blame] | 962 | vc_conn.done; |
| 963 | /* TODO: start multiple handlers (UEs) on various cells on same and other NSEs */ |
| 964 | |
| 965 | f_cleanup(); |
| 966 | } |
| 967 | |
Harald Welte | 3807ed1 | 2020-11-24 19:05:22 +0100 | [diff] [blame] | 968 | private function f_TC_suspend() runs on GlobalTest_CT { |
Daniel Willmann | fa67f49 | 2020-11-19 15:48:05 +0100 | [diff] [blame] | 969 | var integer i; |
Daniel Willmann | 165d661 | 2020-11-19 14:27:29 +0100 | [diff] [blame] | 970 | |
Daniel Willmann | fa67f49 | 2020-11-19 15:48:05 +0100 | [diff] [blame] | 971 | /* TODO: Generate RA ID for each ConnHdlr */ |
Harald Welte | 3807ed1 | 2020-11-24 19:05:22 +0100 | [diff] [blame] | 972 | var RoutingAreaIdentification ra_id := g_pcu[0].cfg.bvc[0].cell_id.ra_id; |
Daniel Willmann | fa67f49 | 2020-11-19 15:48:05 +0100 | [diff] [blame] | 973 | for (i := 0; i < 10; i := i+1) { |
Harald Welte | 3807ed1 | 2020-11-24 19:05:22 +0100 | [diff] [blame] | 974 | var OCT4 tlli := f_gprs_tlli_random(); |
| 975 | var template (value) PDU_BSSGP pdu_tx := ts_BSSGP_SUSPEND(tlli, ra_id); |
Daniel Willmann | fa67f49 | 2020-11-19 15:48:05 +0100 | [diff] [blame] | 976 | /* we cannot use pdu_tx as there are some subtle differences in the length field :/ */ |
Harald Welte | 3807ed1 | 2020-11-24 19:05:22 +0100 | [diff] [blame] | 977 | var template (present) PDU_BSSGP pdu_rx := tr_BSSGP_SUSPEND(tlli, ra_id); |
Daniel Willmann | fa67f49 | 2020-11-19 15:48:05 +0100 | [diff] [blame] | 978 | |
Harald Welte | 3807ed1 | 2020-11-24 19:05:22 +0100 | [diff] [blame] | 979 | f_global_pcu2sgsn(pdu_tx, pdu_rx); |
Daniel Willmann | fa67f49 | 2020-11-19 15:48:05 +0100 | [diff] [blame] | 980 | |
Harald Welte | 3807ed1 | 2020-11-24 19:05:22 +0100 | [diff] [blame] | 981 | pdu_tx := ts_BSSGP_SUSPEND_ACK(tlli, ra_id, int2oct(i, 1)); |
Daniel Willmann | fa67f49 | 2020-11-19 15:48:05 +0100 | [diff] [blame] | 982 | /* we cannot use pdu_tx as there are some subtle differences in the length field :/ */ |
Harald Welte | 3807ed1 | 2020-11-24 19:05:22 +0100 | [diff] [blame] | 983 | pdu_rx := tr_BSSGP_SUSPEND_ACK(tlli, ra_id, int2oct(i, 1)); |
Daniel Willmann | fa67f49 | 2020-11-19 15:48:05 +0100 | [diff] [blame] | 984 | |
Harald Welte | 3807ed1 | 2020-11-24 19:05:22 +0100 | [diff] [blame] | 985 | f_global_sgsn2pcu(pdu_tx, pdu_rx); |
Daniel Willmann | fa67f49 | 2020-11-19 15:48:05 +0100 | [diff] [blame] | 986 | |
| 987 | /* These messages are simple passed through so just also test sending NACK */ |
Harald Welte | 3807ed1 | 2020-11-24 19:05:22 +0100 | [diff] [blame] | 988 | pdu_tx := ts_BSSGP_SUSPEND_NACK(tlli, ra_id, BSSGP_CAUSE_UNKNOWN_MS); |
Daniel Willmann | fa67f49 | 2020-11-19 15:48:05 +0100 | [diff] [blame] | 989 | /* we cannot use pdu_tx as there are some subtle differences in the length field :/ */ |
Harald Welte | 3807ed1 | 2020-11-24 19:05:22 +0100 | [diff] [blame] | 990 | pdu_rx := tr_BSSGP_SUSPEND_NACK(tlli, ra_id, BSSGP_CAUSE_UNKNOWN_MS); |
Daniel Willmann | fa67f49 | 2020-11-19 15:48:05 +0100 | [diff] [blame] | 991 | |
Harald Welte | 3807ed1 | 2020-11-24 19:05:22 +0100 | [diff] [blame] | 992 | f_global_sgsn2pcu(pdu_tx, pdu_rx); |
Daniel Willmann | fa67f49 | 2020-11-19 15:48:05 +0100 | [diff] [blame] | 993 | } |
| 994 | setverdict(pass); |
| 995 | } |
Harald Welte | 3807ed1 | 2020-11-24 19:05:22 +0100 | [diff] [blame] | 996 | testcase TC_suspend() runs on GlobalTest_CT |
Daniel Willmann | fa67f49 | 2020-11-19 15:48:05 +0100 | [diff] [blame] | 997 | { |
Daniel Willmann | fa67f49 | 2020-11-19 15:48:05 +0100 | [diff] [blame] | 998 | f_init(); |
Harald Welte | 3807ed1 | 2020-11-24 19:05:22 +0100 | [diff] [blame] | 999 | f_global_init(); |
| 1000 | f_TC_suspend(); |
Daniel Willmann | fa67f49 | 2020-11-19 15:48:05 +0100 | [diff] [blame] | 1001 | f_cleanup(); |
| 1002 | } |
Harald Welte | 6dc2ac4 | 2020-11-16 09:16:17 +0100 | [diff] [blame] | 1003 | |
Harald Welte | 3807ed1 | 2020-11-24 19:05:22 +0100 | [diff] [blame] | 1004 | private function f_TC_resume() runs on GlobalTest_CT { |
Daniel Willmann | 087a33d | 2020-11-19 15:58:43 +0100 | [diff] [blame] | 1005 | var integer i; |
| 1006 | |
| 1007 | /* TODO: Generate RA ID for each ConnHdlr */ |
Harald Welte | 3807ed1 | 2020-11-24 19:05:22 +0100 | [diff] [blame] | 1008 | var RoutingAreaIdentification ra_id := g_pcu[0].cfg.bvc[0].cell_id.ra_id; |
Daniel Willmann | 087a33d | 2020-11-19 15:58:43 +0100 | [diff] [blame] | 1009 | for (i := 0; i < 10; i := i+1) { |
Harald Welte | 3807ed1 | 2020-11-24 19:05:22 +0100 | [diff] [blame] | 1010 | var OCT4 tlli := f_gprs_tlli_random(); |
| 1011 | var template (value) PDU_BSSGP pdu_tx := ts_BSSGP_RESUME(tlli, ra_id, int2oct(i, 1)); |
Daniel Willmann | 087a33d | 2020-11-19 15:58:43 +0100 | [diff] [blame] | 1012 | /* we cannot use pdu_tx as there are some subtle differences in the length field :/ */ |
Harald Welte | 3807ed1 | 2020-11-24 19:05:22 +0100 | [diff] [blame] | 1013 | var template (present) PDU_BSSGP pdu_rx := tr_BSSGP_RESUME(tlli, ra_id, int2oct(i, 1)); |
Daniel Willmann | 087a33d | 2020-11-19 15:58:43 +0100 | [diff] [blame] | 1014 | |
Harald Welte | 3807ed1 | 2020-11-24 19:05:22 +0100 | [diff] [blame] | 1015 | f_global_pcu2sgsn(pdu_tx, pdu_rx); |
Daniel Willmann | 087a33d | 2020-11-19 15:58:43 +0100 | [diff] [blame] | 1016 | |
Harald Welte | 3807ed1 | 2020-11-24 19:05:22 +0100 | [diff] [blame] | 1017 | pdu_tx := ts_BSSGP_RESUME_ACK(tlli, ra_id); |
Daniel Willmann | 087a33d | 2020-11-19 15:58:43 +0100 | [diff] [blame] | 1018 | /* we cannot use pdu_tx as there are some subtle differences in the length field :/ */ |
Harald Welte | 3807ed1 | 2020-11-24 19:05:22 +0100 | [diff] [blame] | 1019 | pdu_rx := tr_BSSGP_RESUME_ACK(tlli, ra_id); |
Daniel Willmann | 087a33d | 2020-11-19 15:58:43 +0100 | [diff] [blame] | 1020 | |
Harald Welte | 3807ed1 | 2020-11-24 19:05:22 +0100 | [diff] [blame] | 1021 | f_global_sgsn2pcu(pdu_tx, pdu_rx); |
Daniel Willmann | 087a33d | 2020-11-19 15:58:43 +0100 | [diff] [blame] | 1022 | |
| 1023 | /* These messages are simple passed through so just also test sending NACK */ |
Harald Welte | 3807ed1 | 2020-11-24 19:05:22 +0100 | [diff] [blame] | 1024 | pdu_tx := ts_BSSGP_RESUME_NACK(tlli, ra_id, BSSGP_CAUSE_UNKNOWN_MS); |
Daniel Willmann | 087a33d | 2020-11-19 15:58:43 +0100 | [diff] [blame] | 1025 | /* we cannot use pdu_tx as there are some subtle differences in the length field :/ */ |
Harald Welte | 3807ed1 | 2020-11-24 19:05:22 +0100 | [diff] [blame] | 1026 | pdu_rx := tr_BSSGP_RESUME_NACK(tlli, ra_id, BSSGP_CAUSE_UNKNOWN_MS); |
Daniel Willmann | 087a33d | 2020-11-19 15:58:43 +0100 | [diff] [blame] | 1027 | |
Harald Welte | 3807ed1 | 2020-11-24 19:05:22 +0100 | [diff] [blame] | 1028 | f_global_sgsn2pcu(pdu_tx, pdu_rx); |
Daniel Willmann | 087a33d | 2020-11-19 15:58:43 +0100 | [diff] [blame] | 1029 | } |
| 1030 | setverdict(pass); |
| 1031 | } |
Harald Welte | 3807ed1 | 2020-11-24 19:05:22 +0100 | [diff] [blame] | 1032 | testcase TC_resume() runs on GlobalTest_CT |
Daniel Willmann | 087a33d | 2020-11-19 15:58:43 +0100 | [diff] [blame] | 1033 | { |
Daniel Willmann | 087a33d | 2020-11-19 15:58:43 +0100 | [diff] [blame] | 1034 | f_init(); |
Harald Welte | 3807ed1 | 2020-11-24 19:05:22 +0100 | [diff] [blame] | 1035 | f_global_init(); |
| 1036 | f_TC_resume(); |
Daniel Willmann | 087a33d | 2020-11-19 15:58:43 +0100 | [diff] [blame] | 1037 | f_cleanup(); |
| 1038 | } |
| 1039 | |
Harald Welte | f8ef028 | 2020-11-18 12:16:59 +0100 | [diff] [blame] | 1040 | /* test the load-sharing between multiple NS-VC on the BSS side */ |
| 1041 | private function f_TC_dl_ud_unidir(charstring id) runs on BSSGP_ConnHdlr { |
| 1042 | var integer i; |
| 1043 | |
| 1044 | for (i := 0; i < 10; i := i+1) { |
| 1045 | var octetstring payload := f_rnd_octstring(i); |
| 1046 | var template (value) PDU_BSSGP pdu_tx := |
| 1047 | ts_BSSGP_DL_UD(g_pars.tlli, payload, omit, ts_BSSGP_IMSI(g_pars.imsi)); |
| 1048 | SGSN[0].send(pdu_tx); |
| 1049 | } |
| 1050 | setverdict(pass); |
| 1051 | } |
| 1052 | testcase TC_load_sharing_dl() runs on test_CT_NS |
| 1053 | { |
| 1054 | const integer num_ue := 10; |
| 1055 | var BSSGP_ConnHdlr vc_conn[num_ue]; |
| 1056 | f_init(); |
| 1057 | |
| 1058 | /* all BVC are now fully brought up. We disconnect BSSGP from NS on the BSS |
| 1059 | * side so we get the raw NsUnitdataIndication and hence observe different |
| 1060 | * NSVCI */ |
| 1061 | disconnect(g_pcu[0].vc_NS:NS_SP, g_pcu[0].vc_BSSGP:BSCP); |
| 1062 | connect(g_pcu[0].vc_NS:NS_SP, self:NS); |
| 1063 | |
| 1064 | /* there may still be some NS-VCs coming up? After all, the BVC-RESET succeeds after the first |
| 1065 | * of the NS-VC is ALIVE/UNBLOCKED */ |
| 1066 | f_sleep(3.0); |
| 1067 | |
| 1068 | /* start parallel components generating DL-UNITDATA from the SGSN side */ |
| 1069 | for (var integer i:= 0; i < num_ue; i := i+1) { |
| 1070 | vc_conn[i] := f_start_handler(refers(f_TC_dl_ud_unidir), testcasename(), g_pcu, g_sgsn, 5+i); |
| 1071 | } |
| 1072 | |
| 1073 | /* now start counting all the messages that were queued before */ |
| 1074 | /* TODO: We have a hard-coded assumption of 4 NS-VC in one NSE/NS-VCG here! */ |
| 1075 | var ro_integer rx_count := { 0, 0, 0, 0 }; |
| 1076 | timer T := 2.0; |
| 1077 | T.start; |
| 1078 | alt { |
| 1079 | [] as_NsUdiCount(0, rx_count); |
| 1080 | [] as_NsUdiCount(1, rx_count); |
| 1081 | [] as_NsUdiCount(2, rx_count); |
| 1082 | [] as_NsUdiCount(3, rx_count); |
| 1083 | [] NS.receive(NsUnitdataIndication:{0,?,?,*,*}) { repeat; } /* signaling BVC */ |
| 1084 | [] NS.receive(NsStatusIndication:?) { repeat; } |
| 1085 | [] NS.receive { |
| 1086 | setverdict(fail, "Rx unexpected NS"); |
| 1087 | mtc.stop; |
| 1088 | } |
| 1089 | [] T.timeout { |
| 1090 | } |
| 1091 | } |
| 1092 | for (var integer i := 0; i < lengthof(rx_count); i := i+1) { |
| 1093 | log("Rx on NSVCI ", mp_nsconfig_pcu[0].nsvc[i].nsvci, ": ", rx_count[i]); |
| 1094 | if (rx_count[i] == 0) { |
| 1095 | setverdict(fail, "Data not shared over all NSVC"); |
| 1096 | } |
| 1097 | } |
| 1098 | setverdict(pass); |
| 1099 | } |
| 1100 | private altstep as_NsUdiCount(integer nsvc_idx, inout ro_integer roi) runs on test_CT_NS { |
| 1101 | var NsUnitdataIndication udi; |
| 1102 | var BssgpBvcConfig bvcc := g_pcu[0].cfg.bvc[0]; |
| 1103 | [] NS.receive(NsUnitdataIndication:{bvcc.bvci, g_pcu[0].cfg.nsei, mp_nsconfig_pcu[0].nsvc[nsvc_idx].nsvci, *, *}) -> value udi { |
| 1104 | roi[nsvc_idx] := roi[nsvc_idx] + 1; |
| 1105 | repeat; |
| 1106 | } |
| 1107 | } |
| 1108 | type component test_CT_NS extends test_CT { |
| 1109 | port NS_PT NS; |
| 1110 | }; |
| 1111 | |
| 1112 | |
Harald Welte | 0e18824 | 2020-11-22 21:46:48 +0100 | [diff] [blame] | 1113 | /*********************************************************************** |
| 1114 | * PAGING PS procedure |
| 1115 | ***********************************************************************/ |
| 1116 | |
| 1117 | private function f_send_paging_ps(template (value) Paging_Field4 p4, integer sgsn_idx := 0, |
| 1118 | boolean use_sig := false) |
| 1119 | runs on BSSGP_ConnHdlr return template (present) PDU_BSSGP { |
| 1120 | var template (value) PDU_BSSGP pdu_tx; |
| 1121 | var template (present) PDU_BSSGP pdu_rx; |
| 1122 | /* we always specify '0' as BVCI in the templates below, as we override it with |
| 1123 | * 'p4' later anyway */ |
| 1124 | pdu_rx := tr_BSSGP_PS_PAGING(0); |
| 1125 | pdu_rx.pDU_BSSGP_PAGING_PS.iMSI := tr_BSSGP_IMSI(g_pars.imsi); |
| 1126 | if (ispresent(g_pars.p_tmsi)) { |
| 1127 | pdu_tx := ts_BSSGP_PS_PAGING_PTMSI(0, g_pars.imsi, oct2int(g_pars.p_tmsi)); |
| 1128 | pdu_rx.pDU_BSSGP_PAGING_PS.pTMSI := tr_BSSGP_TMSI(oct2int(g_pars.p_tmsi)); |
| 1129 | } else { |
| 1130 | pdu_tx := ts_BSSGP_PS_PAGING_IMSI(0, g_pars.imsi); |
| 1131 | pdu_rx.pDU_BSSGP_PAGING_PS.pTMSI := omit; |
| 1132 | } |
| 1133 | pdu_tx.pDU_BSSGP_PAGING_PS.paging_Field4 := p4; |
| 1134 | pdu_rx.pDU_BSSGP_PAGING_PS.paging_Field4 := p4; |
| 1135 | if (use_sig == false) { |
| 1136 | SGSN[sgsn_idx].send(pdu_tx); |
| 1137 | } else { |
| 1138 | SGSN_SIG[sgsn_idx].send(pdu_tx); |
| 1139 | } |
| 1140 | return pdu_rx; |
| 1141 | } |
| 1142 | |
| 1143 | /* send paging defined by 'p4' on given SGSN-side index (ptp or signaling) and expect one paging to arrive on |
| 1144 | * specified PCU index */ |
| 1145 | private function f_send_paging_ps_exp_one_bss(template (value) Paging_Field4 p4, integer sgsn_idx := 0, |
| 1146 | boolean use_sig := false,integer pcu_idx := 0) |
| 1147 | runs on BSSGP_ConnHdlr { |
| 1148 | var template (present) PDU_BSSGP exp_rx; |
| 1149 | /* doesn't really make sense: Sending to a single BVCI means the message ends up |
| 1150 | * at that BVC (cell) only, and paging all over the BSS area is not possible */ |
| 1151 | exp_rx := f_send_paging_ps(p4, sgsn_idx, use_sig); |
| 1152 | /* Expect paging to propagate to the one BSS addressed by the BVCI only */ |
| 1153 | timer T := 2.0; |
| 1154 | T.start; |
| 1155 | alt { |
| 1156 | [not use_sig] PCU[pcu_idx].receive(exp_rx) { |
| 1157 | setverdict(pass); |
| 1158 | repeat; |
| 1159 | } |
| 1160 | [not use_sig] PCU_SIG[pcu_idx].receive(exp_rx) { |
| 1161 | setverdict(fail, "Received paging on SIGNALING BVC, expected PTP BVC"); |
| 1162 | } |
| 1163 | [use_sig] PCU_SIG[pcu_idx].receive(exp_rx) { |
| 1164 | setverdict(pass); |
| 1165 | repeat; |
| 1166 | } |
| 1167 | [use_sig] PCU[pcu_idx].receive(exp_rx) { |
| 1168 | setverdict(fail, "Received paging on PTP BVC, expected SIGNALING BVC"); |
| 1169 | } |
| 1170 | [] any from PCU.receive(exp_rx) { |
| 1171 | setverdict(fail, "Paging received on unexpected BVC"); |
| 1172 | } |
| 1173 | [] any from PCU_SIG.receive(exp_rx) { |
| 1174 | setverdict(fail, "Paging received on unexpected BVC"); |
| 1175 | } |
| 1176 | [] any from PCU.receive(PDU_BSSGP:{pDU_BSSGP_PAGING_PS:=?}) { |
| 1177 | setverdict(fail, "Different Paging than expected received PTP BVC"); |
| 1178 | } |
| 1179 | [] any from PCU_SIG.receive(PDU_BSSGP:{pDU_BSSGP_PAGING_PS:=?}) { |
| 1180 | setverdict(fail, "Different Paging than expected on SIGNALING BVC"); |
| 1181 | } |
| 1182 | [] T.timeout; |
| 1183 | } |
| 1184 | } |
| 1185 | |
Harald Welte | 7462a59 | 2020-11-23 22:07:07 +0100 | [diff] [blame] | 1186 | /* send a PS-PAGING but don't expect it to show up on any PTP or SIG BVC */ |
| 1187 | private function f_send_paging_ps_exp_no_bss(template (value) Paging_Field4 p4, integer sgsn_idx := 0, |
| 1188 | boolean use_sig := false) |
| 1189 | runs on BSSGP_ConnHdlr { |
| 1190 | var template (present) PDU_BSSGP exp_rx; |
| 1191 | exp_rx := f_send_paging_ps(p4, sgsn_idx, use_sig); |
| 1192 | /* Expect paging to propagate to no BSS */ |
| 1193 | timer T := 2.0; |
| 1194 | T.start; |
| 1195 | alt { |
| 1196 | [] any from PCU.receive(exp_rx) { |
| 1197 | setverdict(fail, "Paging received on unexpected BVC"); |
| 1198 | } |
| 1199 | [] any from PCU_SIG.receive(exp_rx) { |
| 1200 | setverdict(fail, "Paging received on unexpected BVC"); |
| 1201 | } |
| 1202 | [] any from PCU.receive(PDU_BSSGP:{pDU_BSSGP_PAGING_PS:=?}) { |
| 1203 | setverdict(fail, "Different Paging received on PTP BVC"); |
| 1204 | } |
| 1205 | [] any from PCU_SIG.receive(PDU_BSSGP:{pDU_BSSGP_PAGING_PS:=?}) { |
| 1206 | setverdict(fail, "Different Paging received on SIGNALING BVC"); |
| 1207 | } |
| 1208 | [] T.timeout { |
| 1209 | setverdict(pass); |
| 1210 | } |
| 1211 | } |
| 1212 | } |
| 1213 | |
Harald Welte | 0e18824 | 2020-11-22 21:46:48 +0100 | [diff] [blame] | 1214 | private function f_TC_paging_ps_ptp_bss(charstring id) runs on BSSGP_ConnHdlr |
| 1215 | { |
| 1216 | /* doesn't really make sense: Sending to a single BVCI means the message ends up |
| 1217 | * at that BVC (cell) only, and paging all over the BSS area is not possible */ |
| 1218 | f_send_paging_ps_exp_one_bss(ts_BssgpP4BssArea, 0, false, 0); |
| 1219 | } |
| 1220 | testcase TC_paging_ps_ptp_bss() runs on test_CT { |
| 1221 | var BSSGP_ConnHdlr vc_conn; |
| 1222 | f_init(); |
| 1223 | |
| 1224 | vc_conn := f_start_handler(refers(f_TC_paging_ps_ptp_bss), testcasename(), g_pcu, g_sgsn, 9); |
| 1225 | vc_conn.done; |
| 1226 | |
| 1227 | f_cleanup(); |
| 1228 | } |
| 1229 | |
| 1230 | /* PS-PAGING on PTP-BVC for Location Area */ |
| 1231 | private function f_TC_paging_ps_ptp_lac(charstring id) runs on BSSGP_ConnHdlr |
| 1232 | { |
| 1233 | var template (present) PDU_BSSGP exp_rx; |
| 1234 | /* doesn't really make sense: Sending to a single BVCI means the message ends up |
| 1235 | * at that BVC (cell) only, and paging all over the BSS area is not possible */ |
| 1236 | f_send_paging_ps_exp_one_bss(ts_BssgpP4LAC(pcu_bvc_cfg[0].cell_id.ra_id.lai), 0, false, 0); |
| 1237 | } |
| 1238 | testcase TC_paging_ps_ptp_lac() runs on test_CT { |
| 1239 | var BSSGP_ConnHdlr vc_conn; |
| 1240 | f_init(); |
| 1241 | |
| 1242 | vc_conn := f_start_handler(refers(f_TC_paging_ps_ptp_lac), testcasename(), g_pcu, g_sgsn, 10); |
| 1243 | vc_conn.done; |
| 1244 | |
| 1245 | f_cleanup(); |
| 1246 | } |
| 1247 | |
Harald Welte | 7462a59 | 2020-11-23 22:07:07 +0100 | [diff] [blame] | 1248 | /* PS-PAGING on PTP-BVC for unknown Location Area */ |
| 1249 | private function f_TC_paging_ps_ptp_lac_unknown(charstring id) runs on BSSGP_ConnHdlr |
| 1250 | { |
| 1251 | var GSM_Types.LocationAreaIdentification unknown_la := { |
| 1252 | mcc_mnc := '567F99'H, |
| 1253 | lac := 33333 |
| 1254 | }; |
| 1255 | /* as it's sent on the PTP BVC, we expect it to pass even for unknown LAC */ |
| 1256 | f_send_paging_ps_exp_one_bss(ts_BssgpP4LAC(unknown_la), 0, false, 0); |
| 1257 | } |
| 1258 | testcase TC_paging_ps_ptp_lac_unknown() runs on test_CT { |
| 1259 | var BSSGP_ConnHdlr vc_conn; |
| 1260 | f_init(); |
| 1261 | |
| 1262 | vc_conn := f_start_handler(refers(f_TC_paging_ps_ptp_lac_unknown), testcasename(), g_pcu, g_sgsn, 11); |
| 1263 | vc_conn.done; |
| 1264 | |
| 1265 | f_cleanup(); |
| 1266 | } |
| 1267 | |
Harald Welte | 0e18824 | 2020-11-22 21:46:48 +0100 | [diff] [blame] | 1268 | /* PS-PAGING on PTP-BVC for Routeing Area */ |
| 1269 | private function f_TC_paging_ps_ptp_rac(charstring id) runs on BSSGP_ConnHdlr |
| 1270 | { |
| 1271 | /* doesn't really make sense: Sending to a single BVCI means the message ends up |
| 1272 | * at that BVC (cell) only, and paging all over the BSS area is not possible */ |
| 1273 | f_send_paging_ps_exp_one_bss(ts_BssgpP4RAC(pcu_bvc_cfg[0].cell_id.ra_id), 0, false, 0); |
| 1274 | } |
| 1275 | testcase TC_paging_ps_ptp_rac() runs on test_CT { |
| 1276 | var BSSGP_ConnHdlr vc_conn; |
| 1277 | f_init(); |
| 1278 | |
| 1279 | vc_conn := f_start_handler(refers(f_TC_paging_ps_ptp_rac), testcasename(), g_pcu, g_sgsn, 11); |
| 1280 | vc_conn.done; |
| 1281 | |
| 1282 | f_cleanup(); |
| 1283 | } |
| 1284 | |
Harald Welte | 7462a59 | 2020-11-23 22:07:07 +0100 | [diff] [blame] | 1285 | /* PS-PAGING on PTP-BVC for unknown Routeing Area */ |
| 1286 | private function f_TC_paging_ps_ptp_rac_unknown(charstring id) runs on BSSGP_ConnHdlr |
| 1287 | { |
| 1288 | var RoutingAreaIdentification unknown_ra := { |
| 1289 | lai := { |
| 1290 | mcc_mnc := '567F99'H, |
| 1291 | lac := 33333 |
| 1292 | }, |
| 1293 | rac := 254 |
| 1294 | }; |
| 1295 | /* as it's sent on the PTP BVC, we expect it to pass even for unknown RAC */ |
| 1296 | f_send_paging_ps_exp_one_bss(ts_BssgpP4RAC(unknown_ra), 0, false, 0); |
| 1297 | } |
| 1298 | testcase TC_paging_ps_ptp_rac_unknown() runs on test_CT { |
| 1299 | var BSSGP_ConnHdlr vc_conn; |
| 1300 | f_init(); |
| 1301 | |
| 1302 | vc_conn := f_start_handler(refers(f_TC_paging_ps_ptp_rac_unknown), testcasename(), g_pcu, g_sgsn, 11); |
| 1303 | vc_conn.done; |
| 1304 | |
| 1305 | f_cleanup(); |
| 1306 | } |
| 1307 | |
Harald Welte | 0e18824 | 2020-11-22 21:46:48 +0100 | [diff] [blame] | 1308 | /* PS-PAGING on PTP-BVC for BVCI (one cell) */ |
| 1309 | private function f_TC_paging_ps_ptp_bvci(charstring id) runs on BSSGP_ConnHdlr |
| 1310 | { |
| 1311 | /* this should be the normal case for MS in READY MM state after a lower layer failure */ |
| 1312 | f_send_paging_ps_exp_one_bss(ts_BssgpP4Bvci(pcu_bvc_cfg[0].bvci), 0, false, 0); |
| 1313 | } |
| 1314 | testcase TC_paging_ps_ptp_bvci() runs on test_CT { |
| 1315 | var BSSGP_ConnHdlr vc_conn; |
| 1316 | f_init(); |
| 1317 | |
| 1318 | vc_conn := f_start_handler(refers(f_TC_paging_ps_ptp_bvci), testcasename(), g_pcu, g_sgsn, 12); |
| 1319 | vc_conn.done; |
| 1320 | |
| 1321 | f_cleanup(); |
| 1322 | } |
| 1323 | |
Harald Welte | 7462a59 | 2020-11-23 22:07:07 +0100 | [diff] [blame] | 1324 | /* PS-PAGING on PTP-BVC for unknown BVCI */ |
| 1325 | private function f_TC_paging_ps_ptp_bvci_unknown(charstring id) runs on BSSGP_ConnHdlr |
| 1326 | { |
| 1327 | /* as it's sent on the PTP BVC, we expect it to pass even for unknown BVCI */ |
| 1328 | f_send_paging_ps_exp_one_bss(ts_BssgpP4Bvci(33333), 0, false, 0); |
| 1329 | } |
| 1330 | testcase TC_paging_ps_ptp_bvci_unknown() runs on test_CT { |
| 1331 | var BSSGP_ConnHdlr vc_conn; |
| 1332 | f_init(); |
| 1333 | |
| 1334 | vc_conn := f_start_handler(refers(f_TC_paging_ps_ptp_bvci_unknown), testcasename(), g_pcu, g_sgsn, 11); |
| 1335 | vc_conn.done; |
| 1336 | |
| 1337 | f_cleanup(); |
| 1338 | } |
| 1339 | |
Harald Welte | 0e18824 | 2020-11-22 21:46:48 +0100 | [diff] [blame] | 1340 | /* altstep for expecting BSSGP PDU on signaling BVC of given pcu_idx + storing in 'roi' */ |
| 1341 | private altstep as_paging_sig_pcu(integer pcu_idx, template (present) PDU_BSSGP exp_rx, inout ro_integer roi) |
| 1342 | runs on BSSGP_ConnHdlr { |
| 1343 | [] PCU_SIG[pcu_idx].receive(exp_rx) { |
| 1344 | if (ro_integer_contains(roi, pcu_idx)) { |
| 1345 | setverdict(fail, "Received multiple paging on same SIG BVC"); |
| 1346 | } |
| 1347 | roi := roi & { pcu_idx }; |
| 1348 | repeat; |
| 1349 | } |
| 1350 | [] PCU[pcu_idx].receive(exp_rx) { |
| 1351 | setverdict(fail, "Received paging on PTP BVC, expected SIGNALING BVC"); |
| 1352 | } |
| 1353 | [] PCU_SIG[pcu_idx].receive(PDU_BSSGP:{pDU_BSSGP_PAGING_PS:=?}) { |
| 1354 | setverdict(fail, "Different Paging than expected received SIGNALING BVC"); |
| 1355 | } |
| 1356 | [] PCU[pcu_idx].receive(PDU_BSSGP:{pDU_BSSGP_PAGING_PS:=?}) { |
| 1357 | setverdict(fail, "Different Paging than expected received PTP BVC"); |
| 1358 | } |
| 1359 | } |
| 1360 | |
| 1361 | type record of default ro_default; |
| 1362 | |
| 1363 | /* send PS-PAGING on SIG BVC, expect it to arrive on given list of PCU indexes */ |
| 1364 | private function f_send_paging_ps_exp_multi(template (value) Paging_Field4 p4, integer sgsn_idx := 0, |
| 1365 | ro_integer exp_on_pcu_idx) runs on BSSGP_ConnHdlr |
| 1366 | { |
| 1367 | var template (present) PDU_BSSGP exp_rx; |
| 1368 | exp_rx := f_send_paging_ps(p4, 0, true); |
| 1369 | |
| 1370 | /* FIXME: make sure the relevant BVCs/BSS are connected to the ports! */ |
| 1371 | var ro_default defaults := {}; |
| 1372 | for (var integer i := 0; i < lengthof(mp_nsconfig_pcu); i := i+1) { |
| 1373 | var default d := activate(as_paging_sig_pcu(i, exp_rx, g_roi)); |
| 1374 | defaults := defaults & { d }; |
| 1375 | } |
| 1376 | f_sleep(2.0); |
| 1377 | for (var integer i := 0; i < lengthof(defaults); i := i+1) { |
| 1378 | deactivate(defaults[i]); |
| 1379 | } |
| 1380 | log("Paging received on PCU ", g_roi); |
| 1381 | |
| 1382 | for (var integer i := 0; i < lengthof(mp_nsconfig_pcu); i := i+1) { |
| 1383 | var boolean rx_on_i := ro_integer_contains(g_roi, i); |
| 1384 | var boolean exp_on_i := ro_integer_contains(exp_on_pcu_idx, i); |
| 1385 | if (exp_on_i and not rx_on_i) { |
| 1386 | setverdict(fail, "PS-PAGING not received on ", mp_nsconfig_pcu[i].nsei); |
| 1387 | } |
| 1388 | if (not exp_on_i and rx_on_i) { |
| 1389 | setverdict(fail, "PS-PAGING not expected but received on ", mp_nsconfig_pcu[i].nsei); |
| 1390 | } |
| 1391 | } |
| 1392 | setverdict(pass); |
| 1393 | } |
| 1394 | |
| 1395 | /* PS-PAGING on SIG-BVC for BSS Area */ |
| 1396 | private function f_TC_paging_ps_sig_bss(charstring id) runs on BSSGP_ConnHdlr |
| 1397 | { |
| 1398 | /* we expect the paging to arrive on all three NSE */ |
| 1399 | f_send_paging_ps_exp_multi(ts_BssgpP4BssArea, 0, {0, 1, 2}); |
| 1400 | } |
| 1401 | testcase TC_paging_ps_sig_bss() runs on test_CT { |
| 1402 | var BSSGP_ConnHdlr vc_conn; |
| 1403 | f_init(); |
| 1404 | |
| 1405 | vc_conn := f_start_handler(refers(f_TC_paging_ps_sig_bss), testcasename(), g_pcu, g_sgsn, 13); |
| 1406 | vc_conn.done; |
| 1407 | |
| 1408 | f_cleanup(); |
| 1409 | } |
| 1410 | |
| 1411 | /* PS-PAGING on SIG-BVC for Location Area */ |
| 1412 | private function f_TC_paging_ps_sig_lac(charstring id) runs on BSSGP_ConnHdlr |
| 1413 | { |
Daniel Willmann | 2c9300f | 2020-12-01 10:54:08 +0100 | [diff] [blame] | 1414 | /* The first LAC (13135) is shared by all three NSEs */ |
| 1415 | f_send_paging_ps_exp_multi(ts_BssgpP4LAC(pcu_bvc_cfg[0].cell_id.ra_id.lai), 0, {0, 1, 2}); |
| 1416 | /* Reset state */ |
| 1417 | g_roi := {}; |
| 1418 | /* Make LAC (13300) available on pcu index 2 */ |
| 1419 | f_connect_to_pcu_bvc(port_idx := 2, nse_idx := 2, bvc_idx := 1); |
| 1420 | f_send_paging_ps_exp_multi(ts_BssgpP4LAC(pcu_bvc_cfg[2].cell_id.ra_id.lai), 0, {2}); |
Harald Welte | 0e18824 | 2020-11-22 21:46:48 +0100 | [diff] [blame] | 1421 | } |
| 1422 | testcase TC_paging_ps_sig_lac() runs on test_CT { |
| 1423 | var BSSGP_ConnHdlr vc_conn; |
| 1424 | f_init(); |
| 1425 | |
| 1426 | vc_conn := f_start_handler(refers(f_TC_paging_ps_sig_lac), testcasename(), g_pcu, g_sgsn, 14); |
| 1427 | vc_conn.done; |
| 1428 | |
| 1429 | f_cleanup(); |
| 1430 | } |
| 1431 | |
Harald Welte | 7462a59 | 2020-11-23 22:07:07 +0100 | [diff] [blame] | 1432 | /* PS-PAGING on SIG-BVC for unknown Location Area */ |
| 1433 | private function f_TC_paging_ps_sig_lac_unknown(charstring id) runs on BSSGP_ConnHdlr |
| 1434 | { |
| 1435 | var GSM_Types.LocationAreaIdentification unknown_la := { |
| 1436 | mcc_mnc := '567F99'H, |
| 1437 | lac := 33333 |
| 1438 | }; |
| 1439 | f_send_paging_ps_exp_no_bss(ts_BssgpP4LAC(unknown_la), 0, true); |
| 1440 | } |
| 1441 | testcase TC_paging_ps_sig_lac_unknown() runs on test_CT { |
| 1442 | var BSSGP_ConnHdlr vc_conn; |
| 1443 | f_init(); |
| 1444 | |
| 1445 | vc_conn := f_start_handler(refers(f_TC_paging_ps_sig_lac_unknown), testcasename(), g_pcu, g_sgsn, 11); |
| 1446 | vc_conn.done; |
| 1447 | |
| 1448 | f_cleanup(); |
| 1449 | } |
| 1450 | |
Harald Welte | 0e18824 | 2020-11-22 21:46:48 +0100 | [diff] [blame] | 1451 | /* PS-PAGING on SIG-BVC for Routeing Area */ |
| 1452 | private function f_TC_paging_ps_sig_rac(charstring id) runs on BSSGP_ConnHdlr |
| 1453 | { |
Daniel Willmann | 2c9300f | 2020-12-01 10:54:08 +0100 | [diff] [blame] | 1454 | /* Only PCU index 0 has a matching BVC with the RA ID */ |
Harald Welte | 0e18824 | 2020-11-22 21:46:48 +0100 | [diff] [blame] | 1455 | f_send_paging_ps_exp_multi(ts_BssgpP4RAC(pcu_bvc_cfg[0].cell_id.ra_id), 0, {0}); |
Daniel Willmann | 2c9300f | 2020-12-01 10:54:08 +0100 | [diff] [blame] | 1456 | g_roi := {}; |
| 1457 | /* PCU index 1 and 2 have a matching BVC with the RA ID */ |
| 1458 | f_send_paging_ps_exp_multi(ts_BssgpP4RAC(pcu_bvc_cfg[2].cell_id.ra_id), 0, {1, 2}); |
| 1459 | g_roi := {}; |
| 1460 | /* PCU index 2 has two matching BVCs with the RA ID */ |
| 1461 | f_connect_to_pcu_bvc(port_idx := 2, nse_idx := 2, bvc_idx := 1); |
| 1462 | f_send_paging_ps_exp_multi(ts_BssgpP4RAC(pcu_bvc_cfg[2].cell_id.ra_id), 0, {2}); |
Harald Welte | 0e18824 | 2020-11-22 21:46:48 +0100 | [diff] [blame] | 1463 | } |
| 1464 | testcase TC_paging_ps_sig_rac() runs on test_CT { |
| 1465 | var BSSGP_ConnHdlr vc_conn; |
| 1466 | f_init(); |
| 1467 | |
| 1468 | vc_conn := f_start_handler(refers(f_TC_paging_ps_sig_rac), testcasename(), g_pcu, g_sgsn, 15); |
| 1469 | vc_conn.done; |
| 1470 | |
| 1471 | f_cleanup(); |
| 1472 | } |
| 1473 | |
Harald Welte | 7462a59 | 2020-11-23 22:07:07 +0100 | [diff] [blame] | 1474 | /* PS-PAGING on SIG-BVC for unknown Routeing Area */ |
| 1475 | private function f_TC_paging_ps_sig_rac_unknown(charstring id) runs on BSSGP_ConnHdlr |
| 1476 | { |
| 1477 | var RoutingAreaIdentification unknown_ra := { |
| 1478 | lai := { |
| 1479 | mcc_mnc := '567F99'H, |
| 1480 | lac := 33333 |
| 1481 | }, |
| 1482 | rac := 254 |
| 1483 | }; |
| 1484 | f_send_paging_ps_exp_no_bss(ts_BssgpP4RAC(unknown_ra), 0, true); |
| 1485 | } |
| 1486 | testcase TC_paging_ps_sig_rac_unknown() runs on test_CT { |
| 1487 | var BSSGP_ConnHdlr vc_conn; |
| 1488 | f_init(); |
| 1489 | |
| 1490 | vc_conn := f_start_handler(refers(f_TC_paging_ps_sig_rac_unknown), testcasename(), g_pcu, g_sgsn, 11); |
| 1491 | vc_conn.done; |
| 1492 | |
| 1493 | f_cleanup(); |
| 1494 | } |
| 1495 | |
Harald Welte | 0e18824 | 2020-11-22 21:46:48 +0100 | [diff] [blame] | 1496 | /* PS-PAGING on SIG-BVC for BVCI (one cell) */ |
| 1497 | private function f_TC_paging_ps_sig_bvci(charstring id) runs on BSSGP_ConnHdlr |
| 1498 | { |
| 1499 | f_send_paging_ps_exp_multi(ts_BssgpP4Bvci(pcu_bvc_cfg[0].bvci), 0, {0}); |
| 1500 | } |
| 1501 | testcase TC_paging_ps_sig_bvci() runs on test_CT { |
| 1502 | var BSSGP_ConnHdlr vc_conn; |
| 1503 | f_init(); |
| 1504 | |
| 1505 | vc_conn := f_start_handler(refers(f_TC_paging_ps_sig_bvci), testcasename(), g_pcu, g_sgsn, 16); |
| 1506 | vc_conn.done; |
| 1507 | |
| 1508 | f_cleanup(); |
| 1509 | } |
| 1510 | |
Harald Welte | 7462a59 | 2020-11-23 22:07:07 +0100 | [diff] [blame] | 1511 | /* PS-PAGING on SIG-BVC for unknown BVCI */ |
| 1512 | private function f_TC_paging_ps_sig_bvci_unknown(charstring id) runs on BSSGP_ConnHdlr |
| 1513 | { |
| 1514 | f_send_paging_ps_exp_no_bss(ts_BssgpP4Bvci(33333), 0, true); |
| 1515 | } |
| 1516 | testcase TC_paging_ps_sig_bvci_unknown() runs on test_CT { |
| 1517 | var BSSGP_ConnHdlr vc_conn; |
| 1518 | f_init(); |
| 1519 | |
| 1520 | vc_conn := f_start_handler(refers(f_TC_paging_ps_sig_bvci_unknown), testcasename(), g_pcu, g_sgsn, 11); |
| 1521 | vc_conn.done; |
| 1522 | |
| 1523 | f_cleanup(); |
| 1524 | } |
| 1525 | |
| 1526 | |
Harald Welte | 0e18824 | 2020-11-22 21:46:48 +0100 | [diff] [blame] | 1527 | |
| 1528 | /*********************************************************************** |
| 1529 | * PAGING CS procedure |
| 1530 | ***********************************************************************/ |
| 1531 | |
| 1532 | private function f_send_paging_cs(template (value) Paging_Field4 p4, integer sgsn_idx := 0, |
| 1533 | boolean use_sig := false) |
| 1534 | runs on BSSGP_ConnHdlr return template (present) PDU_BSSGP { |
| 1535 | var template (value) PDU_BSSGP pdu_tx; |
| 1536 | var template (present) PDU_BSSGP pdu_rx; |
| 1537 | /* we always specify '0' as BVCI in the templates below, as we override it with |
| 1538 | * 'p4' later anyway */ |
| 1539 | pdu_rx := tr_BSSGP_CS_PAGING(0); |
| 1540 | pdu_rx.pDU_BSSGP_PAGING_CS.iMSI := tr_BSSGP_IMSI(g_pars.imsi); |
| 1541 | if (ispresent(g_pars.p_tmsi)) { |
| 1542 | pdu_tx := ts_BSSGP_CS_PAGING_PTMSI(0, g_pars.imsi, oct2int(g_pars.p_tmsi)); |
| 1543 | pdu_rx.pDU_BSSGP_PAGING_CS.tMSI := tr_BSSGP_TMSI(oct2int(g_pars.p_tmsi)); |
| 1544 | } else { |
| 1545 | pdu_tx := ts_BSSGP_CS_PAGING_IMSI(0, g_pars.imsi); |
| 1546 | pdu_rx.pDU_BSSGP_PAGING_CS.tMSI := omit; |
| 1547 | } |
| 1548 | pdu_tx.pDU_BSSGP_PAGING_CS.paging_Field4 := p4; |
| 1549 | pdu_rx.pDU_BSSGP_PAGING_CS.paging_Field4 := p4; |
| 1550 | if (use_sig == false) { |
| 1551 | SGSN[sgsn_idx].send(pdu_tx); |
| 1552 | } else { |
| 1553 | SGSN_SIG[sgsn_idx].send(pdu_tx); |
| 1554 | } |
| 1555 | return pdu_rx; |
| 1556 | } |
| 1557 | |
| 1558 | /* send paging defined by 'p4' on given SGSN-side index (ptp or signaling) and expect one paging to arrive on |
| 1559 | * specified PCU index */ |
| 1560 | private function f_send_paging_cs_exp_one_bss(template (value) Paging_Field4 p4, integer sgsn_idx := 0, |
| 1561 | boolean use_sig := false,integer pcu_idx := 0) |
| 1562 | runs on BSSGP_ConnHdlr { |
| 1563 | var template (present) PDU_BSSGP exp_rx; |
| 1564 | /* doesn't really make sense: Sending to a single BVCI means the message ends up |
| 1565 | * at that BVC (cell) only, and paging all over the BSS area is not possible */ |
| 1566 | exp_rx := f_send_paging_cs(p4, sgsn_idx, use_sig); |
| 1567 | /* Expect paging to propagate to the one BSS addressed by the BVCI only */ |
| 1568 | timer T := 2.0; |
| 1569 | T.start; |
| 1570 | alt { |
| 1571 | [not use_sig] PCU[pcu_idx].receive(exp_rx) { |
| 1572 | setverdict(pass); |
| 1573 | repeat; |
| 1574 | } |
| 1575 | [not use_sig] PCU_SIG[pcu_idx].receive(exp_rx) { |
| 1576 | setverdict(fail, "Received paging on SIGNALING BVC, expected PTP BVC"); |
| 1577 | } |
| 1578 | [use_sig] PCU_SIG[pcu_idx].receive(exp_rx) { |
| 1579 | setverdict(pass); |
| 1580 | repeat; |
| 1581 | } |
| 1582 | [use_sig] PCU[pcu_idx].receive(exp_rx) { |
| 1583 | setverdict(fail, "Received paging on PTP BVC, expected SIGNALING BVC"); |
| 1584 | } |
| 1585 | [] any from PCU.receive(exp_rx) { |
| 1586 | setverdict(fail, "Paging received on unexpected BVC"); |
| 1587 | } |
| 1588 | [] any from PCU_SIG.receive(exp_rx) { |
| 1589 | setverdict(fail, "Paging received on unexpected BVC"); |
| 1590 | } |
| 1591 | [] any from PCU.receive(PDU_BSSGP:{pDU_BSSGP_PAGING_CS:=?}) { |
| 1592 | setverdict(fail, "Different Paging than expected received PTP BVC"); |
| 1593 | } |
| 1594 | [] any from PCU_SIG.receive(PDU_BSSGP:{pDU_BSSGP_PAGING_CS:=?}) { |
| 1595 | setverdict(fail, "Different Paging than expected on SIGNALING BVC"); |
| 1596 | } |
| 1597 | [] T.timeout; |
| 1598 | } |
| 1599 | } |
| 1600 | |
Harald Welte | 7462a59 | 2020-11-23 22:07:07 +0100 | [diff] [blame] | 1601 | /* send a CS-PAGING but don't expect it to show up on any PTP or SIG BVC */ |
| 1602 | private function f_send_paging_cs_exp_no_bss(template (value) Paging_Field4 p4, integer sgsn_idx := 0, |
| 1603 | boolean use_sig := false) |
| 1604 | runs on BSSGP_ConnHdlr { |
| 1605 | var template (present) PDU_BSSGP exp_rx; |
| 1606 | exp_rx := f_send_paging_cs(p4, sgsn_idx, use_sig); |
| 1607 | /* Expect paging to propagate to no BSS */ |
| 1608 | timer T := 2.0; |
| 1609 | T.start; |
| 1610 | alt { |
| 1611 | [] any from PCU.receive(exp_rx) { |
| 1612 | setverdict(fail, "Paging received on unexpected BVC"); |
| 1613 | } |
| 1614 | [] any from PCU_SIG.receive(exp_rx) { |
| 1615 | setverdict(fail, "Paging received on unexpected BVC"); |
| 1616 | } |
| 1617 | [] any from PCU.receive(PDU_BSSGP:{pDU_BSSGP_PAGING_CS:=?}) { |
| 1618 | setverdict(fail, "Different Paging received on PTP BVC"); |
| 1619 | } |
| 1620 | [] any from PCU_SIG.receive(PDU_BSSGP:{pDU_BSSGP_PAGING_CS:=?}) { |
| 1621 | setverdict(fail, "Different Paging received on SIGNALING BVC"); |
| 1622 | } |
| 1623 | [] T.timeout { |
| 1624 | setverdict(pass); |
| 1625 | } |
| 1626 | } |
| 1627 | } |
| 1628 | |
Harald Welte | 0e18824 | 2020-11-22 21:46:48 +0100 | [diff] [blame] | 1629 | private function f_TC_paging_cs_ptp_bss(charstring id) runs on BSSGP_ConnHdlr |
| 1630 | { |
| 1631 | /* doesn't really make sense: Sending to a single BVCI means the message ends up |
| 1632 | * at that BVC (cell) only, and paging all over the BSS area is not possible */ |
| 1633 | f_send_paging_cs_exp_one_bss(ts_BssgpP4BssArea, 0, false, 0); |
| 1634 | } |
| 1635 | testcase TC_paging_cs_ptp_bss() runs on test_CT { |
| 1636 | var BSSGP_ConnHdlr vc_conn; |
| 1637 | f_init(); |
| 1638 | |
| 1639 | vc_conn := f_start_handler(refers(f_TC_paging_cs_ptp_bss), testcasename(), g_pcu, g_sgsn, 17); |
| 1640 | vc_conn.done; |
| 1641 | |
| 1642 | f_cleanup(); |
| 1643 | } |
| 1644 | |
| 1645 | /* CS-PAGING on PTP-BVC for Location Area */ |
| 1646 | private function f_TC_paging_cs_ptp_lac(charstring id) runs on BSSGP_ConnHdlr |
| 1647 | { |
| 1648 | var template (present) PDU_BSSGP exp_rx; |
| 1649 | /* doesn't really make sense: Sending to a single BVCI means the message ends up |
| 1650 | * at that BVC (cell) only, and paging all over the BSS area is not possible */ |
| 1651 | f_send_paging_cs_exp_one_bss(ts_BssgpP4LAC(pcu_bvc_cfg[0].cell_id.ra_id.lai), 0, false, 0); |
| 1652 | } |
| 1653 | testcase TC_paging_cs_ptp_lac() runs on test_CT { |
| 1654 | var BSSGP_ConnHdlr vc_conn; |
| 1655 | f_init(); |
| 1656 | |
| 1657 | vc_conn := f_start_handler(refers(f_TC_paging_cs_ptp_lac), testcasename(), g_pcu, g_sgsn, 18); |
| 1658 | vc_conn.done; |
| 1659 | |
| 1660 | f_cleanup(); |
| 1661 | } |
| 1662 | |
Harald Welte | 7462a59 | 2020-11-23 22:07:07 +0100 | [diff] [blame] | 1663 | /* CS-PAGING on PTP-BVC for unknown Location Area */ |
| 1664 | private function f_TC_paging_cs_ptp_lac_unknown(charstring id) runs on BSSGP_ConnHdlr |
| 1665 | { |
| 1666 | var GSM_Types.LocationAreaIdentification unknown_la := { |
| 1667 | mcc_mnc := '567F99'H, |
| 1668 | lac := 33333 |
| 1669 | }; |
| 1670 | /* as it's sent on the PTP BVC, we expect it to pass even for unknown LAC */ |
| 1671 | f_send_paging_cs_exp_one_bss(ts_BssgpP4LAC(unknown_la), 0, false, 0); |
| 1672 | } |
| 1673 | testcase TC_paging_cs_ptp_lac_unknown() runs on test_CT { |
| 1674 | var BSSGP_ConnHdlr vc_conn; |
| 1675 | f_init(); |
| 1676 | |
| 1677 | vc_conn := f_start_handler(refers(f_TC_paging_cs_ptp_lac_unknown), testcasename(), g_pcu, g_sgsn, 11); |
| 1678 | vc_conn.done; |
| 1679 | |
| 1680 | f_cleanup(); |
| 1681 | } |
| 1682 | |
Harald Welte | 0e18824 | 2020-11-22 21:46:48 +0100 | [diff] [blame] | 1683 | /* CS-PAGING on PTP-BVC for Routeing Area */ |
| 1684 | private function f_TC_paging_cs_ptp_rac(charstring id) runs on BSSGP_ConnHdlr |
| 1685 | { |
| 1686 | /* doesn't really make sense: Sending to a single BVCI means the message ends up |
| 1687 | * at that BVC (cell) only, and paging all over the BSS area is not possible */ |
| 1688 | f_send_paging_cs_exp_one_bss(ts_BssgpP4RAC(pcu_bvc_cfg[0].cell_id.ra_id), 0, false, 0); |
| 1689 | } |
| 1690 | testcase TC_paging_cs_ptp_rac() runs on test_CT { |
| 1691 | var BSSGP_ConnHdlr vc_conn; |
| 1692 | f_init(); |
| 1693 | |
| 1694 | vc_conn := f_start_handler(refers(f_TC_paging_cs_ptp_rac), testcasename(), g_pcu, g_sgsn, 19); |
| 1695 | vc_conn.done; |
| 1696 | |
| 1697 | f_cleanup(); |
| 1698 | } |
| 1699 | |
Harald Welte | 7462a59 | 2020-11-23 22:07:07 +0100 | [diff] [blame] | 1700 | /* CS-PAGING on PTP-BVC for unknown Routeing Area */ |
| 1701 | private function f_TC_paging_cs_ptp_rac_unknown(charstring id) runs on BSSGP_ConnHdlr |
| 1702 | { |
| 1703 | var RoutingAreaIdentification unknown_ra := { |
| 1704 | lai := { |
| 1705 | mcc_mnc := '567F99'H, |
| 1706 | lac := 33333 |
| 1707 | }, |
| 1708 | rac := 254 |
| 1709 | }; |
| 1710 | /* as it's sent on the PTP BVC, we expect it to pass even for unknown RAC */ |
| 1711 | f_send_paging_cs_exp_one_bss(ts_BssgpP4RAC(unknown_ra), 0, false, 0); |
| 1712 | } |
| 1713 | testcase TC_paging_cs_ptp_rac_unknown() runs on test_CT { |
| 1714 | var BSSGP_ConnHdlr vc_conn; |
| 1715 | f_init(); |
| 1716 | |
| 1717 | vc_conn := f_start_handler(refers(f_TC_paging_cs_ptp_rac_unknown), testcasename(), g_pcu, g_sgsn, 11); |
| 1718 | vc_conn.done; |
| 1719 | |
| 1720 | f_cleanup(); |
| 1721 | } |
| 1722 | |
Harald Welte | 0e18824 | 2020-11-22 21:46:48 +0100 | [diff] [blame] | 1723 | /* CS-PAGING on PTP-BVC for BVCI (one cell) */ |
| 1724 | private function f_TC_paging_cs_ptp_bvci(charstring id) runs on BSSGP_ConnHdlr |
| 1725 | { |
| 1726 | /* this should be the normal case for MS in READY MM state after a lower layer failure */ |
| 1727 | f_send_paging_cs_exp_one_bss(ts_BssgpP4Bvci(pcu_bvc_cfg[0].bvci), 0, false, 0); |
| 1728 | } |
| 1729 | testcase TC_paging_cs_ptp_bvci() runs on test_CT { |
| 1730 | var BSSGP_ConnHdlr vc_conn; |
| 1731 | f_init(); |
| 1732 | |
| 1733 | vc_conn := f_start_handler(refers(f_TC_paging_cs_ptp_bvci), testcasename(), g_pcu, g_sgsn, 20); |
| 1734 | vc_conn.done; |
| 1735 | |
| 1736 | f_cleanup(); |
| 1737 | } |
| 1738 | |
Harald Welte | 7462a59 | 2020-11-23 22:07:07 +0100 | [diff] [blame] | 1739 | /* CS-PAGING on PTP-BVC for unknown BVCI */ |
| 1740 | private function f_TC_paging_cs_ptp_bvci_unknown(charstring id) runs on BSSGP_ConnHdlr |
| 1741 | { |
| 1742 | /* as it's sent on the PTP BVC, we expect it to pass even for unknown BVCI */ |
| 1743 | f_send_paging_cs_exp_one_bss(ts_BssgpP4Bvci(33333), 0, false, 0); |
| 1744 | } |
| 1745 | testcase TC_paging_cs_ptp_bvci_unknown() runs on test_CT { |
| 1746 | var BSSGP_ConnHdlr vc_conn; |
| 1747 | f_init(); |
| 1748 | |
| 1749 | vc_conn := f_start_handler(refers(f_TC_paging_cs_ptp_bvci_unknown), testcasename(), g_pcu, g_sgsn, 11); |
| 1750 | vc_conn.done; |
| 1751 | |
| 1752 | f_cleanup(); |
| 1753 | } |
| 1754 | |
Harald Welte | 0e18824 | 2020-11-22 21:46:48 +0100 | [diff] [blame] | 1755 | /* send CS-PAGING on SIG BVC, expect it to arrive on given list of PCU indexes */ |
| 1756 | private function f_send_paging_cs_exp_multi(template (value) Paging_Field4 p4, integer sgsn_idx := 0, |
| 1757 | ro_integer exp_on_pcu_idx) runs on BSSGP_ConnHdlr |
| 1758 | { |
| 1759 | var template (present) PDU_BSSGP exp_rx; |
| 1760 | exp_rx := f_send_paging_cs(p4, 0, true); |
| 1761 | |
| 1762 | /* FIXME: make sure the relevant BVCs/BSS are connected to the ports! */ |
| 1763 | var ro_default defaults := {}; |
| 1764 | for (var integer i := 0; i < lengthof(mp_nsconfig_pcu); i := i+1) { |
| 1765 | var default d := activate(as_paging_sig_pcu(i, exp_rx, g_roi)); |
| 1766 | defaults := defaults & { d }; |
| 1767 | } |
| 1768 | f_sleep(2.0); |
| 1769 | for (var integer i := 0; i < lengthof(defaults); i := i+1) { |
| 1770 | deactivate(defaults[i]); |
| 1771 | } |
| 1772 | log("Paging received on PCU ", g_roi); |
| 1773 | |
| 1774 | for (var integer i := 0; i < lengthof(mp_nsconfig_pcu); i := i+1) { |
| 1775 | var boolean rx_on_i := ro_integer_contains(g_roi, i); |
| 1776 | var boolean exp_on_i := ro_integer_contains(exp_on_pcu_idx, i); |
| 1777 | if (exp_on_i and not rx_on_i) { |
| 1778 | setverdict(fail, "PS-PAGING not received on ", mp_nsconfig_pcu[i].nsei); |
| 1779 | } |
| 1780 | if (not exp_on_i and rx_on_i) { |
| 1781 | setverdict(fail, "PS-PAGING not expected but received on ", mp_nsconfig_pcu[i].nsei); |
| 1782 | } |
| 1783 | } |
| 1784 | setverdict(pass); |
| 1785 | } |
| 1786 | |
| 1787 | /* CS-PAGING on SIG-BVC for BSS Area */ |
| 1788 | private function f_TC_paging_cs_sig_bss(charstring id) runs on BSSGP_ConnHdlr |
| 1789 | { |
| 1790 | /* we expect the paging to arrive on all three NSE */ |
| 1791 | f_send_paging_cs_exp_multi(ts_BssgpP4BssArea, 0, {0, 1, 2}); |
| 1792 | } |
| 1793 | testcase TC_paging_cs_sig_bss() runs on test_CT { |
| 1794 | var BSSGP_ConnHdlr vc_conn; |
| 1795 | f_init(); |
| 1796 | |
| 1797 | vc_conn := f_start_handler(refers(f_TC_paging_cs_sig_bss), testcasename(), g_pcu, g_sgsn, 13); |
| 1798 | vc_conn.done; |
| 1799 | |
| 1800 | f_cleanup(); |
| 1801 | } |
| 1802 | |
| 1803 | /* CS-PAGING on SIG-BVC for Location Area */ |
| 1804 | private function f_TC_paging_cs_sig_lac(charstring id) runs on BSSGP_ConnHdlr |
| 1805 | { |
| 1806 | /* Both PCU index 0 and 1 have a BVC within the LAC */ |
| 1807 | f_send_paging_cs_exp_multi(ts_BssgpP4LAC(pcu_bvc_cfg[0].cell_id.ra_id.lai), 0, {0, 1}); |
| 1808 | } |
| 1809 | testcase TC_paging_cs_sig_lac() runs on test_CT { |
| 1810 | var BSSGP_ConnHdlr vc_conn; |
| 1811 | f_init(); |
| 1812 | |
| 1813 | vc_conn := f_start_handler(refers(f_TC_paging_cs_sig_lac), testcasename(), g_pcu, g_sgsn, 14); |
| 1814 | vc_conn.done; |
| 1815 | |
| 1816 | f_cleanup(); |
| 1817 | } |
| 1818 | |
Harald Welte | 7462a59 | 2020-11-23 22:07:07 +0100 | [diff] [blame] | 1819 | /* CS-PAGING on SIG-BVC for unknown Location Area */ |
| 1820 | private function f_TC_paging_cs_sig_lac_unknown(charstring id) runs on BSSGP_ConnHdlr |
| 1821 | { |
| 1822 | var GSM_Types.LocationAreaIdentification unknown_la := { |
| 1823 | mcc_mnc := '567F99'H, |
| 1824 | lac := 33333 |
| 1825 | }; |
| 1826 | f_send_paging_cs_exp_no_bss(ts_BssgpP4LAC(unknown_la), 0, true); |
| 1827 | } |
| 1828 | testcase TC_paging_cs_sig_lac_unknown() runs on test_CT { |
| 1829 | var BSSGP_ConnHdlr vc_conn; |
| 1830 | f_init(); |
| 1831 | |
| 1832 | vc_conn := f_start_handler(refers(f_TC_paging_cs_sig_lac_unknown), testcasename(), g_pcu, g_sgsn, 11); |
| 1833 | vc_conn.done; |
| 1834 | |
| 1835 | f_cleanup(); |
| 1836 | } |
| 1837 | |
Harald Welte | 0e18824 | 2020-11-22 21:46:48 +0100 | [diff] [blame] | 1838 | /* CS-PAGING on SIG-BVC for Routeing Area */ |
| 1839 | private function f_TC_paging_cs_sig_rac(charstring id) runs on BSSGP_ConnHdlr |
| 1840 | { |
| 1841 | /* Only PCU index 0 has a matching BVC within the LAC */ |
| 1842 | f_send_paging_cs_exp_multi(ts_BssgpP4RAC(pcu_bvc_cfg[0].cell_id.ra_id), 0, {0}); |
| 1843 | } |
| 1844 | testcase TC_paging_cs_sig_rac() runs on test_CT { |
| 1845 | var BSSGP_ConnHdlr vc_conn; |
| 1846 | f_init(); |
| 1847 | |
| 1848 | vc_conn := f_start_handler(refers(f_TC_paging_cs_sig_rac), testcasename(), g_pcu, g_sgsn, 15); |
| 1849 | vc_conn.done; |
| 1850 | |
| 1851 | f_cleanup(); |
| 1852 | } |
| 1853 | |
Harald Welte | 7462a59 | 2020-11-23 22:07:07 +0100 | [diff] [blame] | 1854 | /* CS-PAGING on SIG-BVC for unknown Routeing Area */ |
| 1855 | private function f_TC_paging_cs_sig_rac_unknown(charstring id) runs on BSSGP_ConnHdlr |
| 1856 | { |
| 1857 | var RoutingAreaIdentification unknown_ra := { |
| 1858 | lai := { |
| 1859 | mcc_mnc := '567F99'H, |
| 1860 | lac := 33333 |
| 1861 | }, |
| 1862 | rac := 254 |
| 1863 | }; |
| 1864 | f_send_paging_cs_exp_no_bss(ts_BssgpP4RAC(unknown_ra), 0, true); |
| 1865 | } |
| 1866 | testcase TC_paging_cs_sig_rac_unknown() runs on test_CT { |
| 1867 | var BSSGP_ConnHdlr vc_conn; |
| 1868 | f_init(); |
| 1869 | |
| 1870 | vc_conn := f_start_handler(refers(f_TC_paging_cs_sig_rac_unknown), testcasename(), g_pcu, g_sgsn, 11); |
| 1871 | vc_conn.done; |
| 1872 | |
| 1873 | f_cleanup(); |
| 1874 | } |
| 1875 | |
Harald Welte | 0e18824 | 2020-11-22 21:46:48 +0100 | [diff] [blame] | 1876 | /* CS-PAGING on SIG-BVC for BVCI (one cell) */ |
| 1877 | private function f_TC_paging_cs_sig_bvci(charstring id) runs on BSSGP_ConnHdlr |
| 1878 | { |
| 1879 | f_send_paging_cs_exp_multi(ts_BssgpP4Bvci(pcu_bvc_cfg[0].bvci), 0, {0}); |
| 1880 | } |
| 1881 | testcase TC_paging_cs_sig_bvci() runs on test_CT { |
| 1882 | var BSSGP_ConnHdlr vc_conn; |
| 1883 | f_init(); |
| 1884 | |
| 1885 | vc_conn := f_start_handler(refers(f_TC_paging_cs_sig_bvci), testcasename(), g_pcu, g_sgsn, 16); |
| 1886 | vc_conn.done; |
| 1887 | |
| 1888 | f_cleanup(); |
| 1889 | } |
| 1890 | |
Harald Welte | 7462a59 | 2020-11-23 22:07:07 +0100 | [diff] [blame] | 1891 | /* CS-PAGING on SIG-BVC for unknown BVCI */ |
| 1892 | private function f_TC_paging_cs_sig_bvci_unknown(charstring id) runs on BSSGP_ConnHdlr |
| 1893 | { |
| 1894 | f_send_paging_cs_exp_no_bss(ts_BssgpP4Bvci(33333), 0, true); |
| 1895 | } |
| 1896 | testcase TC_paging_cs_sig_bvci_unknown() runs on test_CT { |
| 1897 | var BSSGP_ConnHdlr vc_conn; |
| 1898 | f_init(); |
| 1899 | |
| 1900 | vc_conn := f_start_handler(refers(f_TC_paging_cs_sig_bvci_unknown), testcasename(), g_pcu, g_sgsn, 11); |
| 1901 | vc_conn.done; |
| 1902 | |
| 1903 | f_cleanup(); |
| 1904 | } |
| 1905 | |
Daniel Willmann | 91a8e25b | 2020-11-24 14:50:59 +0100 | [diff] [blame] | 1906 | private function f_TC_flush_ll(charstring id) runs on BSSGP_ConnHdlr { |
| 1907 | var BssgpBvci bvci := g_pars.pcu[0].cfg.bvc[0].bvci; |
| 1908 | var integer i; |
| 1909 | for (i := 0; i < 10; i := i+1) { |
| 1910 | var template (value) PDU_BSSGP pdu_tx := ts_BSSGP_FLUSH_LL(g_pars.tlli, bvci, bvci_new := bvci); |
| 1911 | /* we cannot use pdu_tx as there are some subtle differences in the length field :/ */ |
| 1912 | var template (present) PDU_BSSGP pdu_rx := tr_BSSGP_FLUSH_LL(g_pars.tlli, bvci, bvci_new := bvci); |
| 1913 | |
| 1914 | f_sgsn2pcu(pdu_tx, pdu_rx, use_sig := true); |
| 1915 | |
| 1916 | pdu_tx := ts_BSSGP_FLUSH_LL_ACK(g_pars.tlli, int2oct(0, 1), 23, bvci_new := bvci); |
| 1917 | /* we cannot use pdu_tx as there are some subtle differences in the length field :/ */ |
| 1918 | pdu_rx := tr_BSSGP_FLUSH_LL_ACK(g_pars.tlli, int2oct(0, 1), 23, bvci_new := bvci); |
| 1919 | |
| 1920 | f_pcu2sgsn(pdu_tx, pdu_rx, use_sig := true); |
| 1921 | } |
| 1922 | setverdict(pass); |
| 1923 | } |
| 1924 | testcase TC_flush_ll() runs on test_CT |
| 1925 | { |
| 1926 | var BSSGP_ConnHdlr vc_conn; |
| 1927 | f_init(); |
| 1928 | |
| 1929 | vc_conn := f_start_handler(refers(f_TC_flush_ll), testcasename(), g_pcu, g_sgsn, 6); |
| 1930 | vc_conn.done; |
| 1931 | /* TODO: start multiple handlers (UEs) on various cells on same and other NSEs */ |
| 1932 | |
| 1933 | f_cleanup(); |
| 1934 | } |
Harald Welte | 6dc2ac4 | 2020-11-16 09:16:17 +0100 | [diff] [blame] | 1935 | |
Harald Welte | f8e5c5d | 2020-11-27 22:37:23 +0100 | [diff] [blame] | 1936 | private altstep as_bssgp_g_pcu_count(integer pcu_idx, template (present) PDU_BSSGP exp_rx, inout ro_integer roi) |
| 1937 | runs on GlobalTest_CT { |
| 1938 | [] G_PCU[pcu_idx].receive(exp_rx) from g_pcu[pcu_idx].vc_BSSGP { |
| 1939 | if (ro_integer_contains(roi, pcu_idx)) { |
| 1940 | setverdict(fail, "Received multiple on same SIG BVC"); |
| 1941 | } |
| 1942 | roi := roi & { pcu_idx }; |
| 1943 | repeat; |
| 1944 | } |
| 1945 | } |
| 1946 | /* send a INVOKE-TRACE from SGSN and expect to receive a copy on each NSE */ |
| 1947 | testcase TC_trace() runs on GlobalTest_CT |
| 1948 | { |
| 1949 | var BSSGP_ConnHdlr vc_conn; |
| 1950 | f_init(); |
| 1951 | f_global_init(); |
| 1952 | |
| 1953 | var template (value) PDU_BSSGP pdu_tx := ts_BSSGP_INVOKE_TRACE('23'O, '4321'O); |
| 1954 | var template (present) PDU_BSSGP exp_rx := ts_BSSGP_INVOKE_TRACE('23'O, '4321'O); |
| 1955 | |
| 1956 | var ro_default defaults := {}; |
| 1957 | for (var integer i := 0; i < lengthof(g_pcu); i := i+1) { |
| 1958 | activate(as_bssgp_g_pcu_count(i, exp_rx, g_roi)); |
| 1959 | } |
| 1960 | G_SGSN[0].send(pdu_tx); |
| 1961 | f_sleep(2.0); |
| 1962 | for (var integer i := 0; i < lengthof(defaults); i := i+1) { |
| 1963 | deactivate(defaults[i]); |
| 1964 | } |
| 1965 | |
| 1966 | for (var integer i := 0; i < lengthof(g_pcu); i := i+1) { |
| 1967 | if (not ro_integer_contains(g_roi, i)) { |
| 1968 | setverdict(fail, "Failed to receive TRACE on PCU index ", i); |
| 1969 | } |
| 1970 | } |
| 1971 | setverdict(pass); |
| 1972 | |
| 1973 | f_cleanup(); |
| 1974 | } |
| 1975 | |
Harald Welte | c0351d1 | 2020-11-27 22:49:02 +0100 | [diff] [blame] | 1976 | private function f_TC_llc_discarded(charstring id) runs on BSSGP_ConnHdlr { |
| 1977 | var BssgpBvci bvci := g_pars.pcu[0].cfg.bvc[0].bvci; |
| 1978 | |
| 1979 | var template (value) PDU_BSSGP pdu_tx := ts_BSSGP_LLC_DISCARDED(g_pars.tlli, 23, bvci, 2342); |
| 1980 | /* we cannot use pdu_tx as there are some subtle differences in the length field :/ */ |
| 1981 | var template (present) PDU_BSSGP pdu_rx := tr_BSSGP_LLC_DISCARDED(g_pars.tlli, 23, bvci, 2342); |
| 1982 | |
| 1983 | f_pcu2sgsn(pdu_tx, pdu_rx, use_sig := true); |
| 1984 | |
| 1985 | setverdict(pass); |
| 1986 | } |
| 1987 | /* Send a LLC-DISCARDED from BSS side and expect it to show up on SGSN (SIG BVC) */ |
| 1988 | testcase TC_llc_discarded() runs on test_CT |
| 1989 | { |
| 1990 | var BSSGP_ConnHdlr vc_conn; |
| 1991 | f_init(); |
| 1992 | |
| 1993 | vc_conn := f_start_handler(refers(f_TC_llc_discarded), testcasename(), g_pcu, g_sgsn, 6); |
| 1994 | vc_conn.done; |
| 1995 | /* TODO: start multiple handlers (UEs) on various cells on same and other NSEs */ |
| 1996 | |
| 1997 | f_cleanup(); |
| 1998 | } |
| 1999 | |
Harald Welte | f20af41 | 2020-11-28 16:11:11 +0100 | [diff] [blame] | 2000 | /* Send an OVERLOAD from SGSN side and expect it to show up on each PCU (SIG BVC) */ |
| 2001 | testcase TC_overload() runs on GlobalTest_CT |
| 2002 | { |
| 2003 | f_init(); |
| 2004 | f_global_init(); |
| 2005 | |
| 2006 | var template (value) PDU_BSSGP pdu_tx := ts_OVERLOAD('1'B); |
| 2007 | var template (present) PDU_BSSGP exp_rx := tr_OVERLOAD('1'B); |
| 2008 | |
| 2009 | var ro_default defaults := {}; |
| 2010 | for (var integer i := 0; i < lengthof(g_pcu); i := i+1) { |
| 2011 | activate(as_bssgp_g_pcu_count(i, exp_rx, g_roi)); |
| 2012 | } |
| 2013 | G_SGSN[0].send(pdu_tx); |
| 2014 | f_sleep(2.0); |
| 2015 | for (var integer i := 0; i < lengthof(defaults); i := i+1) { |
| 2016 | deactivate(defaults[i]); |
| 2017 | } |
| 2018 | |
| 2019 | for (var integer i := 0; i < lengthof(g_pcu); i := i+1) { |
| 2020 | if (not ro_integer_contains(g_roi, i)) { |
| 2021 | setverdict(fail, "Failed to receive OVERLOAD on PCU index ", i); |
| 2022 | } |
| 2023 | } |
| 2024 | setverdict(pass); |
| 2025 | |
| 2026 | f_cleanup(); |
| 2027 | } |
| 2028 | |
Harald Welte | 239aa50 | 2020-11-24 23:14:20 +0100 | [diff] [blame] | 2029 | private function f_block_ptp_bvc_from_pcu(integer pcu_idx, integer bvc_idx) runs on test_CT |
| 2030 | { |
| 2031 | var BSSGP_BVC_CT bvc_ct := g_pcu[pcu_idx].vc_BSSGP_BVC[bvc_idx]; |
| 2032 | var BssgpBvcConfig bvc_cfg := g_pcu[pcu_idx].cfg.bvc[bvc_idx]; |
| 2033 | var Nsei nsei_pcu := g_pcu[pcu_idx].cfg.nsei; |
| 2034 | |
| 2035 | SGSN_MGMT.clear; |
| 2036 | PCU_MGMT.clear; |
| 2037 | |
| 2038 | /* block the PTP BVC from the PCU side */ |
| 2039 | PCU_MGMT.send(BssgpBlockRequest:{cause:=BSSGP_CAUSE_OM_INTERVENTION}) to bvc_ct; |
| 2040 | /* expect state on both PCU and SGSN side to change */ |
| 2041 | interleave { |
| 2042 | [] PCU_MGMT.receive(tr_BssgpStsInd(nsei_pcu, bvc_cfg.bvci, BVC_S_BLOCKED)) from bvc_ct; |
| 2043 | [] SGSN_MGMT.receive(tr_BssgpStsInd(*, bvc_cfg.bvci, BVC_S_BLOCKED)); |
| 2044 | } |
| 2045 | setverdict(pass); |
| 2046 | } |
| 2047 | testcase TC_bvc_block_ptp() runs on test_CT |
| 2048 | { |
| 2049 | f_init(); |
| 2050 | f_sleep(1.0); |
| 2051 | f_block_ptp_bvc_from_pcu(0, 0); |
| 2052 | f_cleanup(); |
| 2053 | } |
| 2054 | |
| 2055 | private function f_unblock_ptp_bvc_from_pcu(integer pcu_idx, integer bvc_idx) runs on test_CT |
| 2056 | { |
| 2057 | var BSSGP_BVC_CT bvc_ct := g_pcu[pcu_idx].vc_BSSGP_BVC[bvc_idx]; |
| 2058 | var BssgpBvcConfig bvc_cfg := g_pcu[pcu_idx].cfg.bvc[bvc_idx]; |
| 2059 | var Nsei nsei_pcu := g_pcu[pcu_idx].cfg.nsei; |
| 2060 | |
| 2061 | SGSN_MGMT.clear; |
| 2062 | PCU_MGMT.clear; |
| 2063 | |
| 2064 | /* block the PTP BVC from the PCU side */ |
| 2065 | PCU_MGMT.send(BssgpUnblockRequest:{}) to bvc_ct; |
| 2066 | /* expect state on both PCU and SGSN side to change */ |
| 2067 | interleave { |
| 2068 | [] PCU_MGMT.receive(tr_BssgpStsInd(nsei_pcu, bvc_cfg.bvci, BVC_S_UNBLOCKED)) from bvc_ct; |
| 2069 | [] SGSN_MGMT.receive(tr_BssgpStsInd(*, bvc_cfg.bvci, BVC_S_UNBLOCKED)); |
| 2070 | } |
| 2071 | setverdict(pass); |
| 2072 | } |
| 2073 | testcase TC_bvc_unblock_ptp() runs on test_CT |
| 2074 | { |
| 2075 | f_init(); |
| 2076 | f_sleep(1.0); |
| 2077 | f_block_ptp_bvc_from_pcu(0, 0); |
| 2078 | f_sleep(1.0); |
| 2079 | f_unblock_ptp_bvc_from_pcu(0, 0); |
| 2080 | f_cleanup(); |
| 2081 | } |
| 2082 | |
Harald Welte | 60a8ec7 | 2020-11-25 17:12:53 +0100 | [diff] [blame] | 2083 | private altstep as_ignore_status(BSSGP_BVC_MGMT_PT pt) { |
| 2084 | [] pt.receive(BssgpStatusIndication:?) { repeat; } |
| 2085 | } |
| 2086 | private function f_get_sgsn_bvc_ct(integer sgsn_idx, BssgpBvci bvci) runs on test_CT return BSSGP_BVC_CT { |
| 2087 | for (var integer i := 0; i < lengthof(g_sgsn[sgsn_idx].cfg.bvc); i := i+1) { |
| 2088 | if (g_sgsn[sgsn_idx].cfg.bvc[i].bvci == bvci) { |
| 2089 | return g_sgsn[sgsn_idx].vc_BSSGP_BVC[i]; |
| 2090 | } |
| 2091 | } |
| 2092 | return null; |
| 2093 | } |
| 2094 | private function f_reset_ptp_bvc_from_pcu(integer pcu_idx, integer bvc_idx) runs on test_CT |
| 2095 | { |
| 2096 | var BSSGP_BVC_CT pcu_bvc_ct := g_pcu[pcu_idx].vc_BSSGP_BVC[bvc_idx]; |
| 2097 | var BssgpBvcConfig bvc_cfg := g_pcu[pcu_idx].cfg.bvc[bvc_idx]; |
| 2098 | var Nsei nsei_pcu := g_pcu[pcu_idx].cfg.nsei; |
| 2099 | var BSSGP_BVC_CT sgsn_bvc_ct := f_get_sgsn_bvc_ct(0, bvc_cfg.bvci); |
| 2100 | var default d; |
| 2101 | |
| 2102 | SGSN_MGMT.clear; |
| 2103 | PCU_MGMT.clear; |
| 2104 | |
| 2105 | /* block the PTP BVC from the PCU side */ |
| 2106 | PCU_MGMT.send(BssgpResetRequest:{cause:=BSSGP_CAUSE_OM_INTERVENTION}) to pcu_bvc_ct; |
| 2107 | /* expect state on both PCU and SGSN side to change */ |
| 2108 | d := activate(as_ignore_status(SGSN_MGMT)); |
| 2109 | interleave { |
| 2110 | [] PCU_MGMT.receive(tr_BssgpStsInd(nsei_pcu, bvc_cfg.bvci, BVC_S_BLOCKED)) from pcu_bvc_ct; |
| 2111 | [] SGSN_MGMT.receive(BssgpResetIndication:{bvc_cfg.bvci}) from sgsn_bvc_ct; |
| 2112 | } |
| 2113 | deactivate(d); |
| 2114 | setverdict(pass); |
| 2115 | } |
| 2116 | /* Send a BVC-RESET for a PTP BVC from the BSS side: expect it to propagate */ |
| 2117 | testcase TC_bvc_reset_ptp_from_bss() runs on test_CT |
| 2118 | { |
| 2119 | f_init(); |
| 2120 | f_sleep(3.0); |
| 2121 | f_reset_ptp_bvc_from_pcu(0, 0); |
| 2122 | f_cleanup(); |
| 2123 | } |
| 2124 | |
Harald Welte | 16786e9 | 2020-11-27 19:11:56 +0100 | [diff] [blame] | 2125 | private altstep as_count_bvc_block(integer sgsn_idx, BssgpBvci bvci, inout ro_integer roi) |
| 2126 | runs on test_CT { |
| 2127 | var BSSGP_BVC_CT sgsn_bvc_ct := f_get_sgsn_bvc_ct(sgsn_idx, bvci); |
| 2128 | [] SGSN_MGMT.receive(tr_BssgpStsInd(?, bvci, BVC_S_BLOCKED)) from sgsn_bvc_ct { |
| 2129 | roi := roi & { bvci }; |
| 2130 | } |
| 2131 | } |
| 2132 | /* reset the signaling BVC from one BSS; expect no signaling BVC reset on SGSN; but BVC-BLOCK for PTP */ |
| 2133 | testcase TC_bvc_reset_sig_from_bss() runs on test_CT { |
| 2134 | |
| 2135 | f_init(); |
| 2136 | f_sleep(3.0); |
| 2137 | |
| 2138 | /* Start BVC-RESET procedure for BVCI=0 */ |
| 2139 | PCU_MGMT.send(BssgpResetRequest:{cause:=BSSGP_CAUSE_OM_INTERVENTION}) to g_pcu[0].vc_BSSGP; |
| 2140 | |
| 2141 | /* Activate altsteps: One for each PTP BVC within that PCUs NSE */ |
| 2142 | var ro_default defaults := {}; |
| 2143 | for (var integer i := 0; i < lengthof(g_pcu[0].cfg.bvc); i := i+1) { |
| 2144 | var BssgpBvcConfig bvcc := g_pcu[0].cfg.bvc[i]; |
| 2145 | var default d := activate(as_count_bvc_block(0, bvcc.bvci, g_roi)); |
| 2146 | defaults := defaults & { d }; |
| 2147 | } |
| 2148 | |
| 2149 | timer T := 3.0; |
| 2150 | T.start; |
| 2151 | alt { |
| 2152 | [] SGSN_MGMT.receive(BssgpResetIndication:{0}) { |
| 2153 | setverdict(fail, "BSS-side Reset of BVCI=0 should not propagate"); |
| 2154 | } |
| 2155 | [] T.timeout; |
| 2156 | } |
| 2157 | |
| 2158 | for (var integer i := 0; i < lengthof(defaults); i := i+1) { |
| 2159 | deactivate(defaults[i]); |
| 2160 | } |
| 2161 | |
| 2162 | /* check if BVC-block was received on all expected BVC */ |
| 2163 | for (var integer i := 0; i < lengthof(g_pcu[0].cfg.bvc); i := i+1) { |
| 2164 | var BssgpBvcConfig bvcc := g_pcu[0].cfg.bvc[i]; |
| 2165 | if (not ro_integer_contains(g_roi, bvcc.bvci)) { |
| 2166 | setverdict(fail, "Missing SGSN-side BVC-BLOCK of BVCI=", bvcc.bvci); |
| 2167 | } |
| 2168 | } |
| 2169 | |
| 2170 | /* check if BVC-block was not received on any unexpected BVC is not required as |
| 2171 | * such a message would basically run into 'no matching clause' */ |
Daniel Willmann | f259021 | 2020-12-04 14:20:50 +0100 | [diff] [blame] | 2172 | setverdict(pass); |
Harald Welte | 16786e9 | 2020-11-27 19:11:56 +0100 | [diff] [blame] | 2173 | f_cleanup(); |
| 2174 | } |
| 2175 | |
Harald Welte | 60a8ec7 | 2020-11-25 17:12:53 +0100 | [diff] [blame] | 2176 | private function f_reset_ptp_bvc_from_sgsn(integer pcu_idx, integer bvc_idx) runs on test_CT |
| 2177 | { |
| 2178 | var BSSGP_BVC_CT pcu_bvc_ct := g_pcu[pcu_idx].vc_BSSGP_BVC[bvc_idx]; |
| 2179 | var BssgpBvcConfig bvc_cfg := g_pcu[pcu_idx].cfg.bvc[bvc_idx]; |
| 2180 | var Nsei nsei_pcu := g_pcu[pcu_idx].cfg.nsei; |
| 2181 | var BSSGP_BVC_CT sgsn_bvc_ct := f_get_sgsn_bvc_ct(0, bvc_cfg.bvci); |
| 2182 | var default d; |
| 2183 | |
| 2184 | SGSN_MGMT.clear; |
| 2185 | PCU_MGMT.clear; |
| 2186 | |
| 2187 | /* block the PTP BVC from the PCU side */ |
| 2188 | SGSN_MGMT.send(BssgpResetRequest:{cause:=BSSGP_CAUSE_OM_INTERVENTION}) to sgsn_bvc_ct; |
| 2189 | /* expect state on both PCU and SGSN side to change */ |
| 2190 | d := activate(as_ignore_status(PCU_MGMT)); |
| 2191 | interleave { |
| 2192 | [] SGSN_MGMT.receive(tr_BssgpStsInd(?, bvc_cfg.bvci, BVC_S_BLOCKED)) from sgsn_bvc_ct; |
| 2193 | [] PCU_MGMT.receive(BssgpResetIndication:{bvc_cfg.bvci}) from pcu_bvc_ct; |
| 2194 | } |
| 2195 | deactivate(d); |
| 2196 | setverdict(pass); |
| 2197 | } |
| 2198 | /* Send a BVC-RESET for a PTP BVC from the SGSN side: expect it to propagate */ |
| 2199 | testcase TC_bvc_reset_ptp_from_sgsn() runs on test_CT |
| 2200 | { |
| 2201 | f_init(); |
| 2202 | f_sleep(3.0); |
| 2203 | f_reset_ptp_bvc_from_sgsn(0, 0); |
| 2204 | f_cleanup(); |
| 2205 | } |
| 2206 | |
Harald Welte | 16786e9 | 2020-11-27 19:11:56 +0100 | [diff] [blame] | 2207 | private altstep as_count_bvc0_block(integer pcu_idx, Nsei nsei, inout ro_integer roi) |
| 2208 | runs on test_CT { |
| 2209 | var BSSGP_CT pcu_ct := g_pcu[pcu_idx].vc_BSSGP; |
| 2210 | [] PCU_MGMT.receive(BssgpResetIndication:{0}) from pcu_ct { |
| 2211 | roi := roi & { nsei }; |
| 2212 | } |
| 2213 | } |
| 2214 | /* reset the signaling BVC from the SGSN; expect all signaling BVC on all BSS to be reset */ |
| 2215 | testcase TC_bvc_reset_sig_from_sgsn() runs on test_CT { |
| 2216 | |
| 2217 | f_init(); |
| 2218 | f_sleep(3.0); |
| 2219 | |
| 2220 | /* Start BVC-RESET procedure for BVCI=0 */ |
| 2221 | SGSN_MGMT.send(BssgpResetRequest:{cause:=BSSGP_CAUSE_OM_INTERVENTION}) to g_sgsn[0].vc_BSSGP; |
| 2222 | |
| 2223 | /* Activate altsteps: One for each PCU NSE */ |
| 2224 | var ro_default defaults := {}; |
| 2225 | for (var integer i := 0; i < lengthof(g_pcu); i := i+1) { |
| 2226 | var NSConfiguration nscfg := mp_nsconfig_pcu[i]; |
| 2227 | var default d := activate(as_count_bvc0_block(i, nscfg.nsei, g_roi)); |
| 2228 | defaults := defaults & { d }; |
| 2229 | } |
| 2230 | |
| 2231 | f_sleep(3.0); |
| 2232 | |
| 2233 | for (var integer i := 0; i < lengthof(defaults); i := i+1) { |
| 2234 | deactivate(defaults[i]); |
| 2235 | } |
| 2236 | |
| 2237 | /* check if BVC-block was received on all expected BVC */ |
| 2238 | for (var integer i := 0; i < lengthof(g_pcu); i := i+1) { |
| 2239 | var NSConfiguration nscfg := mp_nsconfig_pcu[i]; |
| 2240 | if (not ro_integer_contains(g_roi, nscfg.nsei)) { |
| 2241 | setverdict(fail, "Missing PCU-side BVC-RESET of BVCI=0 on PCU index ", i); |
| 2242 | } |
| 2243 | } |
| 2244 | |
| 2245 | /* check if BVC-block was not received on any unexpected BVC is not required as |
| 2246 | * such a message would basically run into 'no matching clause' */ |
| 2247 | |
| 2248 | f_cleanup(); |
| 2249 | } |
| 2250 | |
Daniel Willmann | 423d8f4 | 2020-09-08 18:58:22 +0200 | [diff] [blame] | 2251 | control { |
| 2252 | execute( TC_BVC_bringup() ); |
Harald Welte | 9268601 | 2020-11-15 21:45:49 +0100 | [diff] [blame] | 2253 | execute( TC_ul_unitdata() ); |
Harald Welte | 78d8db9 | 2020-11-15 23:27:27 +0100 | [diff] [blame] | 2254 | execute( TC_dl_unitdata() ); |
Harald Welte | 6dc2ac4 | 2020-11-16 09:16:17 +0100 | [diff] [blame] | 2255 | execute( TC_ra_capability() ); |
Daniel Willmann | ace3ece | 2020-11-16 19:53:26 +0100 | [diff] [blame] | 2256 | execute( TC_ra_capability_upd() ); |
Daniel Willmann | 165d661 | 2020-11-19 14:27:29 +0100 | [diff] [blame] | 2257 | execute( TC_radio_status() ); |
Daniel Willmann | fa67f49 | 2020-11-19 15:48:05 +0100 | [diff] [blame] | 2258 | execute( TC_suspend() ); |
Daniel Willmann | 087a33d | 2020-11-19 15:58:43 +0100 | [diff] [blame] | 2259 | execute( TC_resume() ); |
Harald Welte | f8e5c5d | 2020-11-27 22:37:23 +0100 | [diff] [blame] | 2260 | execute( TC_trace() ); |
Harald Welte | c0351d1 | 2020-11-27 22:49:02 +0100 | [diff] [blame] | 2261 | execute( TC_llc_discarded() ); |
Harald Welte | f20af41 | 2020-11-28 16:11:11 +0100 | [diff] [blame] | 2262 | execute( TC_overload() ); |
Harald Welte | 239aa50 | 2020-11-24 23:14:20 +0100 | [diff] [blame] | 2263 | execute( TC_bvc_block_ptp() ); |
| 2264 | execute( TC_bvc_unblock_ptp() ); |
Harald Welte | 60a8ec7 | 2020-11-25 17:12:53 +0100 | [diff] [blame] | 2265 | execute( TC_bvc_reset_ptp_from_bss() ); |
Harald Welte | 16786e9 | 2020-11-27 19:11:56 +0100 | [diff] [blame] | 2266 | execute( TC_bvc_reset_sig_from_bss() ); |
Harald Welte | 60a8ec7 | 2020-11-25 17:12:53 +0100 | [diff] [blame] | 2267 | execute( TC_bvc_reset_ptp_from_sgsn() ); |
Harald Welte | 16786e9 | 2020-11-27 19:11:56 +0100 | [diff] [blame] | 2268 | execute( TC_bvc_reset_sig_from_sgsn() ); |
Harald Welte | f8ef028 | 2020-11-18 12:16:59 +0100 | [diff] [blame] | 2269 | if (false) { |
| 2270 | /* don't enable this by default, as we don't yet have any automatic test setup for FR with 4 NS-VC */ |
| 2271 | execute( TC_load_sharing_dl() ); |
| 2272 | } |
Harald Welte | 0e18824 | 2020-11-22 21:46:48 +0100 | [diff] [blame] | 2273 | |
| 2274 | /* PAGING-PS over PTP BVC */ |
| 2275 | execute( TC_paging_ps_ptp_bss() ); |
| 2276 | execute( TC_paging_ps_ptp_lac() ); |
Harald Welte | 7462a59 | 2020-11-23 22:07:07 +0100 | [diff] [blame] | 2277 | execute( TC_paging_ps_ptp_lac_unknown() ); |
Harald Welte | 0e18824 | 2020-11-22 21:46:48 +0100 | [diff] [blame] | 2278 | execute( TC_paging_ps_ptp_rac() ); |
Harald Welte | 7462a59 | 2020-11-23 22:07:07 +0100 | [diff] [blame] | 2279 | execute( TC_paging_ps_ptp_rac_unknown() ); |
Harald Welte | 0e18824 | 2020-11-22 21:46:48 +0100 | [diff] [blame] | 2280 | execute( TC_paging_ps_ptp_bvci() ); |
Harald Welte | 7462a59 | 2020-11-23 22:07:07 +0100 | [diff] [blame] | 2281 | execute( TC_paging_ps_ptp_bvci_unknown() ); |
Harald Welte | 0e18824 | 2020-11-22 21:46:48 +0100 | [diff] [blame] | 2282 | |
| 2283 | /* PAGING-PS over SIG BVC */ |
| 2284 | execute( TC_paging_ps_sig_bss() ); |
| 2285 | execute( TC_paging_ps_sig_lac() ); |
Harald Welte | 7462a59 | 2020-11-23 22:07:07 +0100 | [diff] [blame] | 2286 | execute( TC_paging_ps_sig_lac_unknown() ); |
Harald Welte | 0e18824 | 2020-11-22 21:46:48 +0100 | [diff] [blame] | 2287 | execute( TC_paging_ps_sig_rac() ); |
Harald Welte | 7462a59 | 2020-11-23 22:07:07 +0100 | [diff] [blame] | 2288 | execute( TC_paging_ps_sig_rac_unknown() ); |
Harald Welte | 0e18824 | 2020-11-22 21:46:48 +0100 | [diff] [blame] | 2289 | execute( TC_paging_ps_sig_bvci() ); |
Harald Welte | 7462a59 | 2020-11-23 22:07:07 +0100 | [diff] [blame] | 2290 | execute( TC_paging_ps_sig_bvci_unknown() ); |
Harald Welte | 0e18824 | 2020-11-22 21:46:48 +0100 | [diff] [blame] | 2291 | |
| 2292 | /* PAGING-CS over PTP BVC */ |
| 2293 | execute( TC_paging_cs_ptp_bss() ); |
| 2294 | execute( TC_paging_cs_ptp_lac() ); |
Harald Welte | 7462a59 | 2020-11-23 22:07:07 +0100 | [diff] [blame] | 2295 | execute( TC_paging_cs_ptp_lac_unknown() ); |
Harald Welte | 0e18824 | 2020-11-22 21:46:48 +0100 | [diff] [blame] | 2296 | execute( TC_paging_cs_ptp_rac() ); |
Harald Welte | 7462a59 | 2020-11-23 22:07:07 +0100 | [diff] [blame] | 2297 | execute( TC_paging_cs_ptp_rac_unknown() ); |
Harald Welte | 0e18824 | 2020-11-22 21:46:48 +0100 | [diff] [blame] | 2298 | execute( TC_paging_cs_ptp_bvci() ); |
Harald Welte | 7462a59 | 2020-11-23 22:07:07 +0100 | [diff] [blame] | 2299 | execute( TC_paging_cs_ptp_bvci_unknown() ); |
Harald Welte | 0e18824 | 2020-11-22 21:46:48 +0100 | [diff] [blame] | 2300 | |
| 2301 | /* PAGING-CS over SIG BVC */ |
| 2302 | execute( TC_paging_cs_sig_bss() ); |
| 2303 | execute( TC_paging_cs_sig_lac() ); |
Harald Welte | 7462a59 | 2020-11-23 22:07:07 +0100 | [diff] [blame] | 2304 | execute( TC_paging_cs_sig_lac_unknown() ); |
Harald Welte | 0e18824 | 2020-11-22 21:46:48 +0100 | [diff] [blame] | 2305 | execute( TC_paging_cs_sig_rac() ); |
Harald Welte | 7462a59 | 2020-11-23 22:07:07 +0100 | [diff] [blame] | 2306 | execute( TC_paging_cs_sig_rac_unknown() ); |
Harald Welte | 0e18824 | 2020-11-22 21:46:48 +0100 | [diff] [blame] | 2307 | execute( TC_paging_cs_sig_bvci() ); |
Harald Welte | 7462a59 | 2020-11-23 22:07:07 +0100 | [diff] [blame] | 2308 | execute( TC_paging_cs_sig_bvci_unknown() ); |
Harald Welte | 0e18824 | 2020-11-22 21:46:48 +0100 | [diff] [blame] | 2309 | |
| 2310 | |
Daniel Willmann | 91a8e25b | 2020-11-24 14:50:59 +0100 | [diff] [blame] | 2311 | execute( TC_flush_ll() ); |
Daniel Willmann | 423d8f4 | 2020-09-08 18:58:22 +0200 | [diff] [blame] | 2312 | } |
| 2313 | |
| 2314 | |
| 2315 | } |