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