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 | |
Harald Welte | cf20007 | 2021-01-16 15:20:46 +0100 | [diff] [blame^] | 1471 | /* Rejected PS-PAGING on PTP-BVC for BVCI (one cell) */ |
| 1472 | testcase TC_paging_ps_reject_ptp_bvci() runs on test_CT { |
| 1473 | f_init(); |
| 1474 | f_start_handlers(refers(f_TC_paging_ps_reject_ptp_bvci), testcasename(), 16); |
| 1475 | f_cleanup(); |
| 1476 | } |
| 1477 | |
| 1478 | /* Rejected PS-PAGING on PTP-BVC for BVCI (one cell) using IMSI only (no P-TMSI allocated) */ |
| 1479 | private function f_TC_paging_ps_reject_ptp_bvci(charstring id) runs on BSSGP_ConnHdlr |
| 1480 | { |
| 1481 | /* first send the PS-PAGING from SGSN -> PCU */ |
| 1482 | f_send_paging_ps_exp_one_bss(ts_BssgpP4Bvci(pcu_bvc_cfg[0].bvci), 0, false, 0); |
| 1483 | /* then simulate the PS-PAGING-REJECT from the PCU */ |
| 1484 | f_send_paging_ps_rej(use_sig:=false); |
| 1485 | } |
| 1486 | testcase TC_paging_ps_reject_ptp_bvci_imsi() runs on test_CT { |
| 1487 | f_init(); |
| 1488 | f_start_handlers(refers(f_TC_paging_ps_reject_ptp_bvci), testcasename(), 16, have_ptmsi:=false); |
| 1489 | f_cleanup(); |
| 1490 | } |
Harald Welte | b5a04aa | 2021-01-16 13:04:40 +0100 | [diff] [blame] | 1491 | |
Harald Welte | 7462a59 | 2020-11-23 22:07:07 +0100 | [diff] [blame] | 1492 | /* PS-PAGING on PTP-BVC for unknown BVCI */ |
| 1493 | private function f_TC_paging_ps_ptp_bvci_unknown(charstring id) runs on BSSGP_ConnHdlr |
| 1494 | { |
| 1495 | /* as it's sent on the PTP BVC, we expect it to pass even for unknown BVCI */ |
| 1496 | f_send_paging_ps_exp_one_bss(ts_BssgpP4Bvci(33333), 0, false, 0); |
| 1497 | } |
| 1498 | testcase TC_paging_ps_ptp_bvci_unknown() runs on test_CT { |
Harald Welte | 7462a59 | 2020-11-23 22:07:07 +0100 | [diff] [blame] | 1499 | f_init(); |
Harald Welte | 2ecbca8 | 2021-01-16 11:23:09 +0100 | [diff] [blame] | 1500 | 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] | 1501 | f_cleanup(); |
| 1502 | } |
| 1503 | |
Harald Welte | 0e18824 | 2020-11-22 21:46:48 +0100 | [diff] [blame] | 1504 | /* altstep for expecting BSSGP PDU on signaling BVC of given pcu_idx + storing in 'roi' */ |
| 1505 | private altstep as_paging_sig_pcu(integer pcu_idx, template (present) PDU_BSSGP exp_rx, inout ro_integer roi) |
| 1506 | runs on BSSGP_ConnHdlr { |
| 1507 | [] PCU_SIG[pcu_idx].receive(exp_rx) { |
| 1508 | if (ro_integer_contains(roi, pcu_idx)) { |
| 1509 | setverdict(fail, "Received multiple paging on same SIG BVC"); |
| 1510 | } |
| 1511 | roi := roi & { pcu_idx }; |
| 1512 | repeat; |
| 1513 | } |
Harald Welte | 158becf | 2020-12-09 12:32:32 +0100 | [diff] [blame] | 1514 | [] PCU_PTP[pcu_idx].receive(exp_rx) { |
Harald Welte | 0e18824 | 2020-11-22 21:46:48 +0100 | [diff] [blame] | 1515 | setverdict(fail, "Received paging on PTP BVC, expected SIGNALING BVC"); |
| 1516 | } |
| 1517 | [] PCU_SIG[pcu_idx].receive(PDU_BSSGP:{pDU_BSSGP_PAGING_PS:=?}) { |
| 1518 | setverdict(fail, "Different Paging than expected received SIGNALING BVC"); |
| 1519 | } |
Harald Welte | 158becf | 2020-12-09 12:32:32 +0100 | [diff] [blame] | 1520 | [] PCU_PTP[pcu_idx].receive(PDU_BSSGP:{pDU_BSSGP_PAGING_PS:=?}) { |
Harald Welte | 0e18824 | 2020-11-22 21:46:48 +0100 | [diff] [blame] | 1521 | setverdict(fail, "Different Paging than expected received PTP BVC"); |
| 1522 | } |
| 1523 | } |
| 1524 | |
| 1525 | type record of default ro_default; |
| 1526 | |
| 1527 | /* send PS-PAGING on SIG BVC, expect it to arrive on given list of PCU indexes */ |
| 1528 | private function f_send_paging_ps_exp_multi(template (value) Paging_Field4 p4, integer sgsn_idx := 0, |
| 1529 | ro_integer exp_on_pcu_idx) runs on BSSGP_ConnHdlr |
| 1530 | { |
| 1531 | var template (present) PDU_BSSGP exp_rx; |
| 1532 | exp_rx := f_send_paging_ps(p4, 0, true); |
| 1533 | |
| 1534 | /* FIXME: make sure the relevant BVCs/BSS are connected to the ports! */ |
| 1535 | var ro_default defaults := {}; |
| 1536 | for (var integer i := 0; i < lengthof(mp_nsconfig_pcu); i := i+1) { |
| 1537 | var default d := activate(as_paging_sig_pcu(i, exp_rx, g_roi)); |
| 1538 | defaults := defaults & { d }; |
| 1539 | } |
| 1540 | f_sleep(2.0); |
| 1541 | for (var integer i := 0; i < lengthof(defaults); i := i+1) { |
| 1542 | deactivate(defaults[i]); |
| 1543 | } |
| 1544 | log("Paging received on PCU ", g_roi); |
| 1545 | |
| 1546 | for (var integer i := 0; i < lengthof(mp_nsconfig_pcu); i := i+1) { |
| 1547 | var boolean rx_on_i := ro_integer_contains(g_roi, i); |
| 1548 | var boolean exp_on_i := ro_integer_contains(exp_on_pcu_idx, i); |
| 1549 | if (exp_on_i and not rx_on_i) { |
| 1550 | setverdict(fail, "PS-PAGING not received on ", mp_nsconfig_pcu[i].nsei); |
| 1551 | } |
| 1552 | if (not exp_on_i and rx_on_i) { |
| 1553 | setverdict(fail, "PS-PAGING not expected but received on ", mp_nsconfig_pcu[i].nsei); |
| 1554 | } |
| 1555 | } |
| 1556 | setverdict(pass); |
| 1557 | } |
| 1558 | |
Harald Welte | cf20007 | 2021-01-16 15:20:46 +0100 | [diff] [blame^] | 1559 | /* Send PAGING-PS-REJECT on SIG BVC, expect it to arrive on the "right" SGSN */ |
| 1560 | private function f_send_paging_ps_rej(boolean use_sig := true, integer pcu_idx := 0) runs on BSSGP_ConnHdlr |
| 1561 | { |
| 1562 | var template (value) PDU_BSSGP pdu_tx; |
| 1563 | var template (present) PDU_BSSGP exp_rx; |
| 1564 | var PDU_BSSGP pdu_rx; |
| 1565 | timer T := 5.0; |
| 1566 | var template (omit) GsmTmsi tmsi_int := omit; |
| 1567 | |
| 1568 | if (ispresent(g_pars.p_tmsi)) { |
| 1569 | tmsi_int := oct2int(g_pars.p_tmsi); |
| 1570 | } |
| 1571 | |
| 1572 | pdu_tx := ts_BSSGP_PAGING_PS_REJ(g_pars.imsi, 23, 42, tmsi_int); |
| 1573 | exp_rx := tr_BSSGP_PAGING_PS_REJ(g_pars.imsi, 23, 42, tmsi_int); |
| 1574 | |
| 1575 | if (use_sig) { |
| 1576 | PCU_SIG[pcu_idx].send(pdu_tx); |
| 1577 | } else { |
| 1578 | PCU_PTP[pcu_idx].send(pdu_tx); |
| 1579 | } |
| 1580 | T.start; |
| 1581 | alt { |
| 1582 | [use_sig] SGSN_SIG[g_pars.sgsn_idx].receive(exp_rx) -> value pdu_rx { |
| 1583 | setverdict(pass); |
| 1584 | } |
| 1585 | [use_sig] SGSN_SIG[g_pars.sgsn_idx].receive { |
| 1586 | setverdict(fail, "Unexpected PDU on SGSN"); |
| 1587 | } |
| 1588 | [use_sig] any from SGSN_SIG.receive(exp_rx) -> value pdu_rx { |
| 1589 | setverdict(fail, "PAGING-PS-REJECT arrived on wrong SGSN"); |
| 1590 | } |
| 1591 | [not use_sig] SGSN_PTP[g_pars.sgsn_idx].receive(exp_rx) -> value pdu_rx { |
| 1592 | setverdict(pass); |
| 1593 | } |
| 1594 | [not use_sig] SGSN_PTP[g_pars.sgsn_idx].receive { |
| 1595 | setverdict(fail, "Unexpected PDU on SGSN"); |
| 1596 | } |
| 1597 | [not use_sig] any from SGSN_PTP.receive(exp_rx) -> value pdu_rx { |
| 1598 | setverdict(fail, "PAGING-PS-REJECT arrived on wrong SGSN"); |
| 1599 | } |
| 1600 | [] T.timeout { |
| 1601 | setverdict(fail, "Timeout waiting for PAGING-PS-REJECT"); |
| 1602 | } |
| 1603 | } |
| 1604 | } |
| 1605 | |
Harald Welte | 0e18824 | 2020-11-22 21:46:48 +0100 | [diff] [blame] | 1606 | /* PS-PAGING on SIG-BVC for BSS Area */ |
| 1607 | private function f_TC_paging_ps_sig_bss(charstring id) runs on BSSGP_ConnHdlr |
| 1608 | { |
| 1609 | /* we expect the paging to arrive on all three NSE */ |
| 1610 | f_send_paging_ps_exp_multi(ts_BssgpP4BssArea, 0, {0, 1, 2}); |
| 1611 | } |
| 1612 | testcase TC_paging_ps_sig_bss() runs on test_CT { |
Harald Welte | 0e18824 | 2020-11-22 21:46:48 +0100 | [diff] [blame] | 1613 | f_init(); |
Harald Welte | 2ecbca8 | 2021-01-16 11:23:09 +0100 | [diff] [blame] | 1614 | f_start_handlers(refers(f_TC_paging_ps_sig_bss), testcasename(), 13); |
Harald Welte | 0e18824 | 2020-11-22 21:46:48 +0100 | [diff] [blame] | 1615 | f_cleanup(); |
| 1616 | } |
| 1617 | |
| 1618 | /* PS-PAGING on SIG-BVC for Location Area */ |
| 1619 | private function f_TC_paging_ps_sig_lac(charstring id) runs on BSSGP_ConnHdlr |
| 1620 | { |
Daniel Willmann | 2c9300f | 2020-12-01 10:54:08 +0100 | [diff] [blame] | 1621 | /* The first LAC (13135) is shared by all three NSEs */ |
| 1622 | f_send_paging_ps_exp_multi(ts_BssgpP4LAC(pcu_bvc_cfg[0].cell_id.ra_id.lai), 0, {0, 1, 2}); |
| 1623 | /* Reset state */ |
| 1624 | g_roi := {}; |
| 1625 | /* Make LAC (13300) available on pcu index 2 */ |
| 1626 | f_connect_to_pcu_bvc(port_idx := 2, nse_idx := 2, bvc_idx := 1); |
| 1627 | 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] | 1628 | } |
| 1629 | testcase TC_paging_ps_sig_lac() runs on test_CT { |
Harald Welte | 0e18824 | 2020-11-22 21:46:48 +0100 | [diff] [blame] | 1630 | f_init(); |
Harald Welte | 2ecbca8 | 2021-01-16 11:23:09 +0100 | [diff] [blame] | 1631 | f_start_handlers(refers(f_TC_paging_ps_sig_lac), testcasename(), 14); |
Harald Welte | 0e18824 | 2020-11-22 21:46:48 +0100 | [diff] [blame] | 1632 | f_cleanup(); |
| 1633 | } |
| 1634 | |
Harald Welte | 7462a59 | 2020-11-23 22:07:07 +0100 | [diff] [blame] | 1635 | /* PS-PAGING on SIG-BVC for unknown Location Area */ |
| 1636 | private function f_TC_paging_ps_sig_lac_unknown(charstring id) runs on BSSGP_ConnHdlr |
| 1637 | { |
| 1638 | var GSM_Types.LocationAreaIdentification unknown_la := { |
| 1639 | mcc_mnc := '567F99'H, |
| 1640 | lac := 33333 |
| 1641 | }; |
| 1642 | f_send_paging_ps_exp_no_bss(ts_BssgpP4LAC(unknown_la), 0, true); |
| 1643 | } |
| 1644 | testcase TC_paging_ps_sig_lac_unknown() runs on test_CT { |
Harald Welte | 7462a59 | 2020-11-23 22:07:07 +0100 | [diff] [blame] | 1645 | f_init(); |
Harald Welte | 2ecbca8 | 2021-01-16 11:23:09 +0100 | [diff] [blame] | 1646 | 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] | 1647 | f_cleanup(); |
| 1648 | } |
| 1649 | |
Harald Welte | 0e18824 | 2020-11-22 21:46:48 +0100 | [diff] [blame] | 1650 | /* PS-PAGING on SIG-BVC for Routeing Area */ |
| 1651 | private function f_TC_paging_ps_sig_rac(charstring id) runs on BSSGP_ConnHdlr |
| 1652 | { |
Daniel Willmann | 2c9300f | 2020-12-01 10:54:08 +0100 | [diff] [blame] | 1653 | /* Only PCU index 0 has a matching BVC with the RA ID */ |
Harald Welte | 0e18824 | 2020-11-22 21:46:48 +0100 | [diff] [blame] | 1654 | 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] | 1655 | g_roi := {}; |
| 1656 | /* PCU index 1 and 2 have a matching BVC with the RA ID */ |
| 1657 | f_send_paging_ps_exp_multi(ts_BssgpP4RAC(pcu_bvc_cfg[2].cell_id.ra_id), 0, {1, 2}); |
| 1658 | g_roi := {}; |
| 1659 | /* PCU index 2 has two matching BVCs with the RA ID */ |
| 1660 | f_connect_to_pcu_bvc(port_idx := 2, nse_idx := 2, bvc_idx := 1); |
| 1661 | 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] | 1662 | } |
| 1663 | testcase TC_paging_ps_sig_rac() runs on test_CT { |
Harald Welte | 0e18824 | 2020-11-22 21:46:48 +0100 | [diff] [blame] | 1664 | f_init(); |
Harald Welte | 2ecbca8 | 2021-01-16 11:23:09 +0100 | [diff] [blame] | 1665 | f_start_handlers(refers(f_TC_paging_ps_sig_rac), testcasename(), 15); |
Harald Welte | 0e18824 | 2020-11-22 21:46:48 +0100 | [diff] [blame] | 1666 | f_cleanup(); |
| 1667 | } |
| 1668 | |
Harald Welte | 7462a59 | 2020-11-23 22:07:07 +0100 | [diff] [blame] | 1669 | /* PS-PAGING on SIG-BVC for unknown Routeing Area */ |
| 1670 | private function f_TC_paging_ps_sig_rac_unknown(charstring id) runs on BSSGP_ConnHdlr |
| 1671 | { |
| 1672 | var RoutingAreaIdentification unknown_ra := { |
| 1673 | lai := { |
| 1674 | mcc_mnc := '567F99'H, |
| 1675 | lac := 33333 |
| 1676 | }, |
| 1677 | rac := 254 |
| 1678 | }; |
| 1679 | f_send_paging_ps_exp_no_bss(ts_BssgpP4RAC(unknown_ra), 0, true); |
| 1680 | } |
| 1681 | testcase TC_paging_ps_sig_rac_unknown() runs on test_CT { |
Harald Welte | 7462a59 | 2020-11-23 22:07:07 +0100 | [diff] [blame] | 1682 | f_init(); |
Harald Welte | 2ecbca8 | 2021-01-16 11:23:09 +0100 | [diff] [blame] | 1683 | 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] | 1684 | f_cleanup(); |
| 1685 | } |
| 1686 | |
Harald Welte | 0e18824 | 2020-11-22 21:46:48 +0100 | [diff] [blame] | 1687 | /* PS-PAGING on SIG-BVC for BVCI (one cell) */ |
| 1688 | private function f_TC_paging_ps_sig_bvci(charstring id) runs on BSSGP_ConnHdlr |
| 1689 | { |
| 1690 | f_send_paging_ps_exp_multi(ts_BssgpP4Bvci(pcu_bvc_cfg[0].bvci), 0, {0}); |
| 1691 | } |
| 1692 | testcase TC_paging_ps_sig_bvci() runs on test_CT { |
Harald Welte | 0e18824 | 2020-11-22 21:46:48 +0100 | [diff] [blame] | 1693 | f_init(); |
Harald Welte | 2ecbca8 | 2021-01-16 11:23:09 +0100 | [diff] [blame] | 1694 | f_start_handlers(refers(f_TC_paging_ps_sig_bvci), testcasename(), 16); |
Harald Welte | 0e18824 | 2020-11-22 21:46:48 +0100 | [diff] [blame] | 1695 | f_cleanup(); |
| 1696 | } |
| 1697 | |
Harald Welte | b5a04aa | 2021-01-16 13:04:40 +0100 | [diff] [blame] | 1698 | /* PS-PAGING on SIG-BVC for BVCI (one cell) using IMSI only (no P-TMSI allocated) */ |
| 1699 | testcase TC_paging_ps_sig_bvci_imsi() runs on test_CT { |
| 1700 | f_init(); |
| 1701 | f_start_handlers(refers(f_TC_paging_ps_sig_bvci), testcasename(), 16, have_ptmsi:=false); |
| 1702 | f_cleanup(); |
| 1703 | } |
| 1704 | |
Harald Welte | cf20007 | 2021-01-16 15:20:46 +0100 | [diff] [blame^] | 1705 | /* Rejected PS-PAGING on SIG-BVC for BVCI (one cell) */ |
| 1706 | private function f_TC_paging_ps_reject_sig_bvci(charstring id) runs on BSSGP_ConnHdlr |
| 1707 | { |
| 1708 | /* first send the PS-PAGING from SGSN -> PCU */ |
| 1709 | f_send_paging_ps_exp_multi(ts_BssgpP4Bvci(pcu_bvc_cfg[0].bvci), 0, {0}); |
| 1710 | /* then simulate the PS-PAGING-REJECT from the PCU */ |
| 1711 | f_send_paging_ps_rej(use_sig:=true); |
| 1712 | |
| 1713 | } |
| 1714 | testcase TC_paging_ps_reject_sig_bvci() runs on test_CT { |
| 1715 | f_init(); |
| 1716 | f_start_handlers(refers(f_TC_paging_ps_reject_sig_bvci), testcasename(), 16); |
| 1717 | f_cleanup(); |
| 1718 | } |
| 1719 | |
| 1720 | /* Rejected PS-PAGING on SIG-BVC for BVCI (one cell) using IMSI only (no P-TMSI allocated) */ |
| 1721 | testcase TC_paging_ps_reject_sig_bvci_imsi() runs on test_CT { |
| 1722 | f_init(); |
| 1723 | f_start_handlers(refers(f_TC_paging_ps_reject_sig_bvci), testcasename(), 16, have_ptmsi:=false); |
| 1724 | f_cleanup(); |
| 1725 | } |
| 1726 | |
Harald Welte | 7462a59 | 2020-11-23 22:07:07 +0100 | [diff] [blame] | 1727 | /* PS-PAGING on SIG-BVC for unknown BVCI */ |
| 1728 | private function f_TC_paging_ps_sig_bvci_unknown(charstring id) runs on BSSGP_ConnHdlr |
| 1729 | { |
| 1730 | f_send_paging_ps_exp_no_bss(ts_BssgpP4Bvci(33333), 0, true); |
| 1731 | } |
| 1732 | testcase TC_paging_ps_sig_bvci_unknown() runs on test_CT { |
Harald Welte | 7462a59 | 2020-11-23 22:07:07 +0100 | [diff] [blame] | 1733 | f_init(); |
Harald Welte | 2ecbca8 | 2021-01-16 11:23:09 +0100 | [diff] [blame] | 1734 | 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] | 1735 | f_cleanup(); |
| 1736 | } |
| 1737 | |
| 1738 | |
Harald Welte | 0e18824 | 2020-11-22 21:46:48 +0100 | [diff] [blame] | 1739 | |
| 1740 | /*********************************************************************** |
| 1741 | * PAGING CS procedure |
| 1742 | ***********************************************************************/ |
| 1743 | |
| 1744 | private function f_send_paging_cs(template (value) Paging_Field4 p4, integer sgsn_idx := 0, |
| 1745 | boolean use_sig := false) |
| 1746 | runs on BSSGP_ConnHdlr return template (present) PDU_BSSGP { |
| 1747 | var template (value) PDU_BSSGP pdu_tx; |
| 1748 | var template (present) PDU_BSSGP pdu_rx; |
| 1749 | /* we always specify '0' as BVCI in the templates below, as we override it with |
| 1750 | * 'p4' later anyway */ |
| 1751 | pdu_rx := tr_BSSGP_CS_PAGING(0); |
| 1752 | pdu_rx.pDU_BSSGP_PAGING_CS.iMSI := tr_BSSGP_IMSI(g_pars.imsi); |
| 1753 | if (ispresent(g_pars.p_tmsi)) { |
| 1754 | pdu_tx := ts_BSSGP_CS_PAGING_PTMSI(0, g_pars.imsi, oct2int(g_pars.p_tmsi)); |
| 1755 | pdu_rx.pDU_BSSGP_PAGING_CS.tMSI := tr_BSSGP_TMSI(oct2int(g_pars.p_tmsi)); |
| 1756 | } else { |
| 1757 | pdu_tx := ts_BSSGP_CS_PAGING_IMSI(0, g_pars.imsi); |
| 1758 | pdu_rx.pDU_BSSGP_PAGING_CS.tMSI := omit; |
| 1759 | } |
| 1760 | pdu_tx.pDU_BSSGP_PAGING_CS.paging_Field4 := p4; |
| 1761 | pdu_rx.pDU_BSSGP_PAGING_CS.paging_Field4 := p4; |
| 1762 | if (use_sig == false) { |
Harald Welte | 158becf | 2020-12-09 12:32:32 +0100 | [diff] [blame] | 1763 | SGSN_PTP[sgsn_idx].send(pdu_tx); |
Harald Welte | 0e18824 | 2020-11-22 21:46:48 +0100 | [diff] [blame] | 1764 | } else { |
| 1765 | SGSN_SIG[sgsn_idx].send(pdu_tx); |
| 1766 | } |
| 1767 | return pdu_rx; |
| 1768 | } |
| 1769 | |
| 1770 | /* send paging defined by 'p4' on given SGSN-side index (ptp or signaling) and expect one paging to arrive on |
| 1771 | * specified PCU index */ |
| 1772 | private function f_send_paging_cs_exp_one_bss(template (value) Paging_Field4 p4, integer sgsn_idx := 0, |
| 1773 | boolean use_sig := false,integer pcu_idx := 0) |
| 1774 | runs on BSSGP_ConnHdlr { |
| 1775 | var template (present) PDU_BSSGP exp_rx; |
Daniel Willmann | 1a85971 | 2020-12-04 00:59:45 +0100 | [diff] [blame] | 1776 | var boolean test_done := false; |
Harald Welte | 0e18824 | 2020-11-22 21:46:48 +0100 | [diff] [blame] | 1777 | /* doesn't really make sense: Sending to a single BVCI means the message ends up |
| 1778 | * at that BVC (cell) only, and paging all over the BSS area is not possible */ |
| 1779 | exp_rx := f_send_paging_cs(p4, sgsn_idx, use_sig); |
| 1780 | /* Expect paging to propagate to the one BSS addressed by the BVCI only */ |
| 1781 | timer T := 2.0; |
| 1782 | T.start; |
| 1783 | alt { |
Harald Welte | 158becf | 2020-12-09 12:32:32 +0100 | [diff] [blame] | 1784 | [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] | 1785 | setverdict(pass); |
Daniel Willmann | 1a85971 | 2020-12-04 00:59:45 +0100 | [diff] [blame] | 1786 | test_done := true; |
Harald Welte | 0e18824 | 2020-11-22 21:46:48 +0100 | [diff] [blame] | 1787 | repeat; |
| 1788 | } |
| 1789 | [not use_sig] PCU_SIG[pcu_idx].receive(exp_rx) { |
| 1790 | setverdict(fail, "Received paging on SIGNALING BVC, expected PTP BVC"); |
| 1791 | } |
Daniel Willmann | 1a85971 | 2020-12-04 00:59:45 +0100 | [diff] [blame] | 1792 | [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] | 1793 | setverdict(pass); |
Daniel Willmann | 1a85971 | 2020-12-04 00:59:45 +0100 | [diff] [blame] | 1794 | test_done := true; |
Harald Welte | 0e18824 | 2020-11-22 21:46:48 +0100 | [diff] [blame] | 1795 | repeat; |
| 1796 | } |
Harald Welte | 158becf | 2020-12-09 12:32:32 +0100 | [diff] [blame] | 1797 | [use_sig] PCU_PTP[pcu_idx].receive(exp_rx) { |
Harald Welte | 0e18824 | 2020-11-22 21:46:48 +0100 | [diff] [blame] | 1798 | setverdict(fail, "Received paging on PTP BVC, expected SIGNALING BVC"); |
| 1799 | } |
Harald Welte | 158becf | 2020-12-09 12:32:32 +0100 | [diff] [blame] | 1800 | [] any from PCU_PTP.receive(exp_rx) { |
Harald Welte | 0e18824 | 2020-11-22 21:46:48 +0100 | [diff] [blame] | 1801 | setverdict(fail, "Paging received on unexpected BVC"); |
| 1802 | } |
| 1803 | [] any from PCU_SIG.receive(exp_rx) { |
| 1804 | setverdict(fail, "Paging received on unexpected BVC"); |
| 1805 | } |
Harald Welte | 158becf | 2020-12-09 12:32:32 +0100 | [diff] [blame] | 1806 | [] any from PCU_PTP.receive(PDU_BSSGP:{pDU_BSSGP_PAGING_CS:=?}) { |
Harald Welte | 0e18824 | 2020-11-22 21:46:48 +0100 | [diff] [blame] | 1807 | setverdict(fail, "Different Paging than expected received PTP BVC"); |
| 1808 | } |
| 1809 | [] any from PCU_SIG.receive(PDU_BSSGP:{pDU_BSSGP_PAGING_CS:=?}) { |
| 1810 | setverdict(fail, "Different Paging than expected on SIGNALING BVC"); |
| 1811 | } |
Daniel Willmann | 1a85971 | 2020-12-04 00:59:45 +0100 | [diff] [blame] | 1812 | [not test_done] T.timeout { |
| 1813 | setverdict(fail, "Timeout while waiting for paging") |
| 1814 | } |
| 1815 | [test_done] T.timeout; |
Harald Welte | 0e18824 | 2020-11-22 21:46:48 +0100 | [diff] [blame] | 1816 | } |
| 1817 | } |
| 1818 | |
Harald Welte | 7462a59 | 2020-11-23 22:07:07 +0100 | [diff] [blame] | 1819 | /* send a CS-PAGING but don't expect it to show up on any PTP or SIG BVC */ |
| 1820 | private function f_send_paging_cs_exp_no_bss(template (value) Paging_Field4 p4, integer sgsn_idx := 0, |
| 1821 | boolean use_sig := false) |
| 1822 | runs on BSSGP_ConnHdlr { |
| 1823 | var template (present) PDU_BSSGP exp_rx; |
| 1824 | exp_rx := f_send_paging_cs(p4, sgsn_idx, use_sig); |
| 1825 | /* Expect paging to propagate to no BSS */ |
| 1826 | timer T := 2.0; |
| 1827 | T.start; |
| 1828 | alt { |
Harald Welte | 158becf | 2020-12-09 12:32:32 +0100 | [diff] [blame] | 1829 | [] any from PCU_PTP.receive(exp_rx) { |
Harald Welte | 7462a59 | 2020-11-23 22:07:07 +0100 | [diff] [blame] | 1830 | setverdict(fail, "Paging received on unexpected BVC"); |
| 1831 | } |
| 1832 | [] any from PCU_SIG.receive(exp_rx) { |
| 1833 | setverdict(fail, "Paging received on unexpected BVC"); |
| 1834 | } |
Harald Welte | 158becf | 2020-12-09 12:32:32 +0100 | [diff] [blame] | 1835 | [] any from PCU_PTP.receive(PDU_BSSGP:{pDU_BSSGP_PAGING_CS:=?}) { |
Harald Welte | 7462a59 | 2020-11-23 22:07:07 +0100 | [diff] [blame] | 1836 | setverdict(fail, "Different Paging received on PTP BVC"); |
| 1837 | } |
| 1838 | [] any from PCU_SIG.receive(PDU_BSSGP:{pDU_BSSGP_PAGING_CS:=?}) { |
| 1839 | setverdict(fail, "Different Paging received on SIGNALING BVC"); |
| 1840 | } |
| 1841 | [] T.timeout { |
| 1842 | setverdict(pass); |
| 1843 | } |
| 1844 | } |
| 1845 | } |
| 1846 | |
Harald Welte | 0e18824 | 2020-11-22 21:46:48 +0100 | [diff] [blame] | 1847 | private function f_TC_paging_cs_ptp_bss(charstring id) runs on BSSGP_ConnHdlr |
| 1848 | { |
| 1849 | /* doesn't really make sense: Sending to a single BVCI means the message ends up |
| 1850 | * at that BVC (cell) only, and paging all over the BSS area is not possible */ |
| 1851 | f_send_paging_cs_exp_one_bss(ts_BssgpP4BssArea, 0, false, 0); |
| 1852 | } |
| 1853 | testcase TC_paging_cs_ptp_bss() runs on test_CT { |
Harald Welte | 0e18824 | 2020-11-22 21:46:48 +0100 | [diff] [blame] | 1854 | f_init(); |
Harald Welte | 2ecbca8 | 2021-01-16 11:23:09 +0100 | [diff] [blame] | 1855 | f_start_handlers(refers(f_TC_paging_cs_ptp_bss), testcasename(), 17); |
Harald Welte | 0e18824 | 2020-11-22 21:46:48 +0100 | [diff] [blame] | 1856 | f_cleanup(); |
| 1857 | } |
| 1858 | |
| 1859 | /* CS-PAGING on PTP-BVC for Location Area */ |
| 1860 | private function f_TC_paging_cs_ptp_lac(charstring id) runs on BSSGP_ConnHdlr |
| 1861 | { |
| 1862 | var template (present) PDU_BSSGP exp_rx; |
| 1863 | /* doesn't really make sense: Sending to a single BVCI means the message ends up |
| 1864 | * at that BVC (cell) only, and paging all over the BSS area is not possible */ |
| 1865 | f_send_paging_cs_exp_one_bss(ts_BssgpP4LAC(pcu_bvc_cfg[0].cell_id.ra_id.lai), 0, false, 0); |
| 1866 | } |
| 1867 | testcase TC_paging_cs_ptp_lac() runs on test_CT { |
Harald Welte | 0e18824 | 2020-11-22 21:46:48 +0100 | [diff] [blame] | 1868 | f_init(); |
Harald Welte | 2ecbca8 | 2021-01-16 11:23:09 +0100 | [diff] [blame] | 1869 | f_start_handlers(refers(f_TC_paging_cs_ptp_lac), testcasename(), 18); |
Harald Welte | 0e18824 | 2020-11-22 21:46:48 +0100 | [diff] [blame] | 1870 | f_cleanup(); |
| 1871 | } |
| 1872 | |
Harald Welte | 7462a59 | 2020-11-23 22:07:07 +0100 | [diff] [blame] | 1873 | /* CS-PAGING on PTP-BVC for unknown Location Area */ |
| 1874 | private function f_TC_paging_cs_ptp_lac_unknown(charstring id) runs on BSSGP_ConnHdlr |
| 1875 | { |
| 1876 | var GSM_Types.LocationAreaIdentification unknown_la := { |
| 1877 | mcc_mnc := '567F99'H, |
| 1878 | lac := 33333 |
| 1879 | }; |
| 1880 | /* as it's sent on the PTP BVC, we expect it to pass even for unknown LAC */ |
| 1881 | f_send_paging_cs_exp_one_bss(ts_BssgpP4LAC(unknown_la), 0, false, 0); |
| 1882 | } |
| 1883 | testcase TC_paging_cs_ptp_lac_unknown() runs on test_CT { |
Harald Welte | 7462a59 | 2020-11-23 22:07:07 +0100 | [diff] [blame] | 1884 | f_init(); |
Harald Welte | 2ecbca8 | 2021-01-16 11:23:09 +0100 | [diff] [blame] | 1885 | 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] | 1886 | f_cleanup(); |
| 1887 | } |
| 1888 | |
Harald Welte | 0e18824 | 2020-11-22 21:46:48 +0100 | [diff] [blame] | 1889 | /* CS-PAGING on PTP-BVC for Routeing Area */ |
| 1890 | private function f_TC_paging_cs_ptp_rac(charstring id) runs on BSSGP_ConnHdlr |
| 1891 | { |
| 1892 | /* doesn't really make sense: Sending to a single BVCI means the message ends up |
| 1893 | * at that BVC (cell) only, and paging all over the BSS area is not possible */ |
| 1894 | f_send_paging_cs_exp_one_bss(ts_BssgpP4RAC(pcu_bvc_cfg[0].cell_id.ra_id), 0, false, 0); |
| 1895 | } |
| 1896 | testcase TC_paging_cs_ptp_rac() runs on test_CT { |
Harald Welte | 0e18824 | 2020-11-22 21:46:48 +0100 | [diff] [blame] | 1897 | f_init(); |
Harald Welte | 2ecbca8 | 2021-01-16 11:23:09 +0100 | [diff] [blame] | 1898 | f_start_handlers(refers(f_TC_paging_cs_ptp_rac), testcasename(), 19); |
Harald Welte | 0e18824 | 2020-11-22 21:46:48 +0100 | [diff] [blame] | 1899 | f_cleanup(); |
| 1900 | } |
| 1901 | |
Harald Welte | 7462a59 | 2020-11-23 22:07:07 +0100 | [diff] [blame] | 1902 | /* CS-PAGING on PTP-BVC for unknown Routeing Area */ |
| 1903 | private function f_TC_paging_cs_ptp_rac_unknown(charstring id) runs on BSSGP_ConnHdlr |
| 1904 | { |
| 1905 | var RoutingAreaIdentification unknown_ra := { |
| 1906 | lai := { |
| 1907 | mcc_mnc := '567F99'H, |
| 1908 | lac := 33333 |
| 1909 | }, |
| 1910 | rac := 254 |
| 1911 | }; |
| 1912 | /* as it's sent on the PTP BVC, we expect it to pass even for unknown RAC */ |
| 1913 | f_send_paging_cs_exp_one_bss(ts_BssgpP4RAC(unknown_ra), 0, false, 0); |
| 1914 | } |
| 1915 | testcase TC_paging_cs_ptp_rac_unknown() runs on test_CT { |
Harald Welte | 7462a59 | 2020-11-23 22:07:07 +0100 | [diff] [blame] | 1916 | f_init(); |
Harald Welte | 2ecbca8 | 2021-01-16 11:23:09 +0100 | [diff] [blame] | 1917 | 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] | 1918 | f_cleanup(); |
| 1919 | } |
| 1920 | |
Harald Welte | 0e18824 | 2020-11-22 21:46:48 +0100 | [diff] [blame] | 1921 | /* CS-PAGING on PTP-BVC for BVCI (one cell) */ |
| 1922 | private function f_TC_paging_cs_ptp_bvci(charstring id) runs on BSSGP_ConnHdlr |
| 1923 | { |
| 1924 | /* this should be the normal case for MS in READY MM state after a lower layer failure */ |
| 1925 | f_send_paging_cs_exp_one_bss(ts_BssgpP4Bvci(pcu_bvc_cfg[0].bvci), 0, false, 0); |
| 1926 | } |
| 1927 | testcase TC_paging_cs_ptp_bvci() runs on test_CT { |
Harald Welte | 0e18824 | 2020-11-22 21:46:48 +0100 | [diff] [blame] | 1928 | f_init(); |
Harald Welte | 2ecbca8 | 2021-01-16 11:23:09 +0100 | [diff] [blame] | 1929 | f_start_handlers(refers(f_TC_paging_cs_ptp_bvci), testcasename(), 20); |
Harald Welte | 0e18824 | 2020-11-22 21:46:48 +0100 | [diff] [blame] | 1930 | f_cleanup(); |
| 1931 | } |
| 1932 | |
Harald Welte | 7462a59 | 2020-11-23 22:07:07 +0100 | [diff] [blame] | 1933 | /* CS-PAGING on PTP-BVC for unknown BVCI */ |
| 1934 | private function f_TC_paging_cs_ptp_bvci_unknown(charstring id) runs on BSSGP_ConnHdlr |
| 1935 | { |
| 1936 | /* as it's sent on the PTP BVC, we expect it to pass even for unknown BVCI */ |
| 1937 | f_send_paging_cs_exp_one_bss(ts_BssgpP4Bvci(33333), 0, false, 0); |
| 1938 | } |
| 1939 | testcase TC_paging_cs_ptp_bvci_unknown() runs on test_CT { |
Harald Welte | 7462a59 | 2020-11-23 22:07:07 +0100 | [diff] [blame] | 1940 | f_init(); |
Harald Welte | 2ecbca8 | 2021-01-16 11:23:09 +0100 | [diff] [blame] | 1941 | 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] | 1942 | f_cleanup(); |
| 1943 | } |
| 1944 | |
Harald Welte | 0e18824 | 2020-11-22 21:46:48 +0100 | [diff] [blame] | 1945 | /* send CS-PAGING on SIG BVC, expect it to arrive on given list of PCU indexes */ |
| 1946 | private function f_send_paging_cs_exp_multi(template (value) Paging_Field4 p4, integer sgsn_idx := 0, |
| 1947 | ro_integer exp_on_pcu_idx) runs on BSSGP_ConnHdlr |
| 1948 | { |
| 1949 | var template (present) PDU_BSSGP exp_rx; |
| 1950 | exp_rx := f_send_paging_cs(p4, 0, true); |
| 1951 | |
| 1952 | /* FIXME: make sure the relevant BVCs/BSS are connected to the ports! */ |
| 1953 | var ro_default defaults := {}; |
| 1954 | for (var integer i := 0; i < lengthof(mp_nsconfig_pcu); i := i+1) { |
| 1955 | var default d := activate(as_paging_sig_pcu(i, exp_rx, g_roi)); |
| 1956 | defaults := defaults & { d }; |
| 1957 | } |
| 1958 | f_sleep(2.0); |
| 1959 | for (var integer i := 0; i < lengthof(defaults); i := i+1) { |
| 1960 | deactivate(defaults[i]); |
| 1961 | } |
| 1962 | log("Paging received on PCU ", g_roi); |
| 1963 | |
| 1964 | for (var integer i := 0; i < lengthof(mp_nsconfig_pcu); i := i+1) { |
| 1965 | var boolean rx_on_i := ro_integer_contains(g_roi, i); |
| 1966 | var boolean exp_on_i := ro_integer_contains(exp_on_pcu_idx, i); |
| 1967 | if (exp_on_i and not rx_on_i) { |
| 1968 | setverdict(fail, "PS-PAGING not received on ", mp_nsconfig_pcu[i].nsei); |
| 1969 | } |
| 1970 | if (not exp_on_i and rx_on_i) { |
| 1971 | setverdict(fail, "PS-PAGING not expected but received on ", mp_nsconfig_pcu[i].nsei); |
| 1972 | } |
| 1973 | } |
| 1974 | setverdict(pass); |
| 1975 | } |
| 1976 | |
| 1977 | /* CS-PAGING on SIG-BVC for BSS Area */ |
| 1978 | private function f_TC_paging_cs_sig_bss(charstring id) runs on BSSGP_ConnHdlr |
| 1979 | { |
| 1980 | /* we expect the paging to arrive on all three NSE */ |
| 1981 | f_send_paging_cs_exp_multi(ts_BssgpP4BssArea, 0, {0, 1, 2}); |
| 1982 | } |
| 1983 | testcase TC_paging_cs_sig_bss() runs on test_CT { |
Harald Welte | 0e18824 | 2020-11-22 21:46:48 +0100 | [diff] [blame] | 1984 | f_init(); |
Harald Welte | 2ecbca8 | 2021-01-16 11:23:09 +0100 | [diff] [blame] | 1985 | f_start_handlers(refers(f_TC_paging_cs_sig_bss), testcasename(), 13); |
Harald Welte | 0e18824 | 2020-11-22 21:46:48 +0100 | [diff] [blame] | 1986 | f_cleanup(); |
| 1987 | } |
| 1988 | |
| 1989 | /* CS-PAGING on SIG-BVC for Location Area */ |
| 1990 | private function f_TC_paging_cs_sig_lac(charstring id) runs on BSSGP_ConnHdlr |
| 1991 | { |
Daniel Willmann | d4fb73c | 2020-12-07 13:57:17 +0100 | [diff] [blame] | 1992 | /* The first LAC (13135) is shared by all three NSEs */ |
| 1993 | f_send_paging_cs_exp_multi(ts_BssgpP4LAC(pcu_bvc_cfg[0].cell_id.ra_id.lai), 0, {0, 1, 2}); |
| 1994 | /* Reset state */ |
| 1995 | g_roi := {}; |
| 1996 | /* Make LAC (13300) available on pcu index 2 */ |
| 1997 | f_connect_to_pcu_bvc(port_idx := 2, nse_idx := 2, bvc_idx := 1); |
| 1998 | 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] | 1999 | } |
| 2000 | testcase TC_paging_cs_sig_lac() runs on test_CT { |
Harald Welte | 0e18824 | 2020-11-22 21:46:48 +0100 | [diff] [blame] | 2001 | f_init(); |
Harald Welte | 2ecbca8 | 2021-01-16 11:23:09 +0100 | [diff] [blame] | 2002 | f_start_handlers(refers(f_TC_paging_cs_sig_lac), testcasename(), 14); |
Harald Welte | 0e18824 | 2020-11-22 21:46:48 +0100 | [diff] [blame] | 2003 | f_cleanup(); |
| 2004 | } |
| 2005 | |
Harald Welte | 7462a59 | 2020-11-23 22:07:07 +0100 | [diff] [blame] | 2006 | /* CS-PAGING on SIG-BVC for unknown Location Area */ |
| 2007 | private function f_TC_paging_cs_sig_lac_unknown(charstring id) runs on BSSGP_ConnHdlr |
| 2008 | { |
| 2009 | var GSM_Types.LocationAreaIdentification unknown_la := { |
| 2010 | mcc_mnc := '567F99'H, |
| 2011 | lac := 33333 |
| 2012 | }; |
| 2013 | f_send_paging_cs_exp_no_bss(ts_BssgpP4LAC(unknown_la), 0, true); |
| 2014 | } |
| 2015 | testcase TC_paging_cs_sig_lac_unknown() runs on test_CT { |
Harald Welte | 7462a59 | 2020-11-23 22:07:07 +0100 | [diff] [blame] | 2016 | f_init(); |
Harald Welte | 2ecbca8 | 2021-01-16 11:23:09 +0100 | [diff] [blame] | 2017 | 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] | 2018 | f_cleanup(); |
| 2019 | } |
| 2020 | |
Harald Welte | 0e18824 | 2020-11-22 21:46:48 +0100 | [diff] [blame] | 2021 | /* CS-PAGING on SIG-BVC for Routeing Area */ |
| 2022 | private function f_TC_paging_cs_sig_rac(charstring id) runs on BSSGP_ConnHdlr |
| 2023 | { |
Daniel Willmann | d4fb73c | 2020-12-07 13:57:17 +0100 | [diff] [blame] | 2024 | /* Only PCU index 0 has a matching BVC with the RA ID */ |
Harald Welte | 0e18824 | 2020-11-22 21:46:48 +0100 | [diff] [blame] | 2025 | 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] | 2026 | g_roi := {}; |
| 2027 | /* PCU index 1 and 2 have a matching BVC with the RA ID */ |
| 2028 | f_send_paging_cs_exp_multi(ts_BssgpP4RAC(pcu_bvc_cfg[2].cell_id.ra_id), 0, {1, 2}); |
| 2029 | g_roi := {}; |
| 2030 | /* PCU index 2 has two matching BVCs with the RA ID */ |
| 2031 | f_connect_to_pcu_bvc(port_idx := 2, nse_idx := 2, bvc_idx := 1); |
| 2032 | 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] | 2033 | } |
| 2034 | testcase TC_paging_cs_sig_rac() runs on test_CT { |
Harald Welte | 0e18824 | 2020-11-22 21:46:48 +0100 | [diff] [blame] | 2035 | f_init(); |
Harald Welte | 2ecbca8 | 2021-01-16 11:23:09 +0100 | [diff] [blame] | 2036 | f_start_handlers(refers(f_TC_paging_cs_sig_rac), testcasename(), 15); |
Harald Welte | 0e18824 | 2020-11-22 21:46:48 +0100 | [diff] [blame] | 2037 | f_cleanup(); |
| 2038 | } |
| 2039 | |
Harald Welte | 7462a59 | 2020-11-23 22:07:07 +0100 | [diff] [blame] | 2040 | /* CS-PAGING on SIG-BVC for unknown Routeing Area */ |
| 2041 | private function f_TC_paging_cs_sig_rac_unknown(charstring id) runs on BSSGP_ConnHdlr |
| 2042 | { |
| 2043 | var RoutingAreaIdentification unknown_ra := { |
| 2044 | lai := { |
| 2045 | mcc_mnc := '567F99'H, |
| 2046 | lac := 33333 |
| 2047 | }, |
| 2048 | rac := 254 |
| 2049 | }; |
| 2050 | f_send_paging_cs_exp_no_bss(ts_BssgpP4RAC(unknown_ra), 0, true); |
| 2051 | } |
| 2052 | testcase TC_paging_cs_sig_rac_unknown() runs on test_CT { |
Harald Welte | 7462a59 | 2020-11-23 22:07:07 +0100 | [diff] [blame] | 2053 | f_init(); |
Harald Welte | 2ecbca8 | 2021-01-16 11:23:09 +0100 | [diff] [blame] | 2054 | 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] | 2055 | f_cleanup(); |
| 2056 | } |
| 2057 | |
Harald Welte | 0e18824 | 2020-11-22 21:46:48 +0100 | [diff] [blame] | 2058 | /* CS-PAGING on SIG-BVC for BVCI (one cell) */ |
| 2059 | private function f_TC_paging_cs_sig_bvci(charstring id) runs on BSSGP_ConnHdlr |
| 2060 | { |
| 2061 | f_send_paging_cs_exp_multi(ts_BssgpP4Bvci(pcu_bvc_cfg[0].bvci), 0, {0}); |
| 2062 | } |
| 2063 | testcase TC_paging_cs_sig_bvci() runs on test_CT { |
Harald Welte | 0e18824 | 2020-11-22 21:46:48 +0100 | [diff] [blame] | 2064 | f_init(); |
Harald Welte | 2ecbca8 | 2021-01-16 11:23:09 +0100 | [diff] [blame] | 2065 | f_start_handlers(refers(f_TC_paging_cs_sig_bvci), testcasename(), 16); |
Harald Welte | 0e18824 | 2020-11-22 21:46:48 +0100 | [diff] [blame] | 2066 | f_cleanup(); |
| 2067 | } |
| 2068 | |
Harald Welte | 7462a59 | 2020-11-23 22:07:07 +0100 | [diff] [blame] | 2069 | /* CS-PAGING on SIG-BVC for unknown BVCI */ |
| 2070 | private function f_TC_paging_cs_sig_bvci_unknown(charstring id) runs on BSSGP_ConnHdlr |
| 2071 | { |
| 2072 | f_send_paging_cs_exp_no_bss(ts_BssgpP4Bvci(33333), 0, true); |
| 2073 | } |
| 2074 | testcase TC_paging_cs_sig_bvci_unknown() runs on test_CT { |
Harald Welte | 7462a59 | 2020-11-23 22:07:07 +0100 | [diff] [blame] | 2075 | f_init(); |
Harald Welte | 2ecbca8 | 2021-01-16 11:23:09 +0100 | [diff] [blame] | 2076 | 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] | 2077 | f_cleanup(); |
| 2078 | } |
| 2079 | |
Harald Welte | 4f91c3b | 2020-12-09 12:25:51 +0100 | [diff] [blame] | 2080 | /*********************************************************************** |
| 2081 | * FLUSH-LL procedure |
| 2082 | ***********************************************************************/ |
| 2083 | |
Daniel Willmann | 91a8e25b | 2020-11-24 14:50:59 +0100 | [diff] [blame] | 2084 | private function f_TC_flush_ll(charstring id) runs on BSSGP_ConnHdlr { |
| 2085 | var BssgpBvci bvci := g_pars.pcu[0].cfg.bvc[0].bvci; |
| 2086 | var integer i; |
| 2087 | for (i := 0; i < 10; i := i+1) { |
| 2088 | var template (value) PDU_BSSGP pdu_tx := ts_BSSGP_FLUSH_LL(g_pars.tlli, bvci, bvci_new := bvci); |
| 2089 | /* we cannot use pdu_tx as there are some subtle differences in the length field :/ */ |
| 2090 | var template (present) PDU_BSSGP pdu_rx := tr_BSSGP_FLUSH_LL(g_pars.tlli, bvci, bvci_new := bvci); |
| 2091 | |
| 2092 | f_sgsn2pcu(pdu_tx, pdu_rx, use_sig := true); |
| 2093 | |
| 2094 | pdu_tx := ts_BSSGP_FLUSH_LL_ACK(g_pars.tlli, int2oct(0, 1), 23, bvci_new := bvci); |
| 2095 | /* we cannot use pdu_tx as there are some subtle differences in the length field :/ */ |
| 2096 | pdu_rx := tr_BSSGP_FLUSH_LL_ACK(g_pars.tlli, int2oct(0, 1), 23, bvci_new := bvci); |
| 2097 | |
| 2098 | f_pcu2sgsn(pdu_tx, pdu_rx, use_sig := true); |
| 2099 | } |
| 2100 | setverdict(pass); |
| 2101 | } |
| 2102 | testcase TC_flush_ll() runs on test_CT |
| 2103 | { |
Daniel Willmann | 91a8e25b | 2020-11-24 14:50:59 +0100 | [diff] [blame] | 2104 | f_init(); |
Harald Welte | 2ecbca8 | 2021-01-16 11:23:09 +0100 | [diff] [blame] | 2105 | f_start_handlers(refers(f_TC_flush_ll), testcasename(), 6); |
Daniel Willmann | 91a8e25b | 2020-11-24 14:50:59 +0100 | [diff] [blame] | 2106 | /* 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] | 2107 | f_cleanup(); |
| 2108 | } |
Harald Welte | 6dc2ac4 | 2020-11-16 09:16:17 +0100 | [diff] [blame] | 2109 | |
Harald Welte | 4f91c3b | 2020-12-09 12:25:51 +0100 | [diff] [blame] | 2110 | /*********************************************************************** |
| 2111 | * SGSN-INVOKE-TRACE procedure |
| 2112 | ***********************************************************************/ |
| 2113 | |
Harald Welte | f8e5c5d | 2020-11-27 22:37:23 +0100 | [diff] [blame] | 2114 | private altstep as_bssgp_g_pcu_count(integer pcu_idx, template (present) PDU_BSSGP exp_rx, inout ro_integer roi) |
| 2115 | runs on GlobalTest_CT { |
| 2116 | [] G_PCU[pcu_idx].receive(exp_rx) from g_pcu[pcu_idx].vc_BSSGP { |
| 2117 | if (ro_integer_contains(roi, pcu_idx)) { |
| 2118 | setverdict(fail, "Received multiple on same SIG BVC"); |
| 2119 | } |
| 2120 | roi := roi & { pcu_idx }; |
| 2121 | repeat; |
| 2122 | } |
| 2123 | } |
| 2124 | /* send a INVOKE-TRACE from SGSN and expect to receive a copy on each NSE */ |
| 2125 | testcase TC_trace() runs on GlobalTest_CT |
| 2126 | { |
| 2127 | var BSSGP_ConnHdlr vc_conn; |
| 2128 | f_init(); |
| 2129 | f_global_init(); |
| 2130 | |
| 2131 | var template (value) PDU_BSSGP pdu_tx := ts_BSSGP_INVOKE_TRACE('23'O, '4321'O); |
| 2132 | var template (present) PDU_BSSGP exp_rx := ts_BSSGP_INVOKE_TRACE('23'O, '4321'O); |
| 2133 | |
| 2134 | var ro_default defaults := {}; |
| 2135 | for (var integer i := 0; i < lengthof(g_pcu); i := i+1) { |
| 2136 | activate(as_bssgp_g_pcu_count(i, exp_rx, g_roi)); |
| 2137 | } |
| 2138 | G_SGSN[0].send(pdu_tx); |
| 2139 | f_sleep(2.0); |
| 2140 | for (var integer i := 0; i < lengthof(defaults); i := i+1) { |
| 2141 | deactivate(defaults[i]); |
| 2142 | } |
| 2143 | |
| 2144 | for (var integer i := 0; i < lengthof(g_pcu); i := i+1) { |
| 2145 | if (not ro_integer_contains(g_roi, i)) { |
| 2146 | setverdict(fail, "Failed to receive TRACE on PCU index ", i); |
| 2147 | } |
| 2148 | } |
| 2149 | setverdict(pass); |
| 2150 | |
| 2151 | f_cleanup(); |
| 2152 | } |
| 2153 | |
Harald Welte | 4f91c3b | 2020-12-09 12:25:51 +0100 | [diff] [blame] | 2154 | /*********************************************************************** |
| 2155 | * LLC-DISCARDED procedure |
| 2156 | ***********************************************************************/ |
| 2157 | |
Harald Welte | c0351d1 | 2020-11-27 22:49:02 +0100 | [diff] [blame] | 2158 | private function f_TC_llc_discarded(charstring id) runs on BSSGP_ConnHdlr { |
| 2159 | var BssgpBvci bvci := g_pars.pcu[0].cfg.bvc[0].bvci; |
| 2160 | |
| 2161 | var template (value) PDU_BSSGP pdu_tx := ts_BSSGP_LLC_DISCARDED(g_pars.tlli, 23, bvci, 2342); |
| 2162 | /* we cannot use pdu_tx as there are some subtle differences in the length field :/ */ |
| 2163 | var template (present) PDU_BSSGP pdu_rx := tr_BSSGP_LLC_DISCARDED(g_pars.tlli, 23, bvci, 2342); |
| 2164 | |
| 2165 | f_pcu2sgsn(pdu_tx, pdu_rx, use_sig := true); |
| 2166 | |
| 2167 | setverdict(pass); |
| 2168 | } |
| 2169 | /* Send a LLC-DISCARDED from BSS side and expect it to show up on SGSN (SIG BVC) */ |
| 2170 | testcase TC_llc_discarded() runs on test_CT |
| 2171 | { |
Harald Welte | c0351d1 | 2020-11-27 22:49:02 +0100 | [diff] [blame] | 2172 | f_init(); |
Harald Welte | 2ecbca8 | 2021-01-16 11:23:09 +0100 | [diff] [blame] | 2173 | f_start_handlers(refers(f_TC_llc_discarded), testcasename(), 6); |
Harald Welte | c0351d1 | 2020-11-27 22:49:02 +0100 | [diff] [blame] | 2174 | /* 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] | 2175 | f_cleanup(); |
| 2176 | } |
| 2177 | |
Harald Welte | 4f91c3b | 2020-12-09 12:25:51 +0100 | [diff] [blame] | 2178 | /*********************************************************************** |
| 2179 | * OVERLOAD procedure |
| 2180 | ***********************************************************************/ |
| 2181 | |
Harald Welte | f20af41 | 2020-11-28 16:11:11 +0100 | [diff] [blame] | 2182 | /* Send an OVERLOAD from SGSN side and expect it to show up on each PCU (SIG BVC) */ |
| 2183 | testcase TC_overload() runs on GlobalTest_CT |
| 2184 | { |
| 2185 | f_init(); |
| 2186 | f_global_init(); |
| 2187 | |
| 2188 | var template (value) PDU_BSSGP pdu_tx := ts_OVERLOAD('1'B); |
| 2189 | var template (present) PDU_BSSGP exp_rx := tr_OVERLOAD('1'B); |
| 2190 | |
| 2191 | var ro_default defaults := {}; |
| 2192 | for (var integer i := 0; i < lengthof(g_pcu); i := i+1) { |
| 2193 | activate(as_bssgp_g_pcu_count(i, exp_rx, g_roi)); |
| 2194 | } |
| 2195 | G_SGSN[0].send(pdu_tx); |
| 2196 | f_sleep(2.0); |
| 2197 | for (var integer i := 0; i < lengthof(defaults); i := i+1) { |
| 2198 | deactivate(defaults[i]); |
| 2199 | } |
| 2200 | |
| 2201 | for (var integer i := 0; i < lengthof(g_pcu); i := i+1) { |
| 2202 | if (not ro_integer_contains(g_roi, i)) { |
| 2203 | setverdict(fail, "Failed to receive OVERLOAD on PCU index ", i); |
| 2204 | } |
| 2205 | } |
| 2206 | setverdict(pass); |
| 2207 | |
| 2208 | f_cleanup(); |
| 2209 | } |
| 2210 | |
Harald Welte | 4f91c3b | 2020-12-09 12:25:51 +0100 | [diff] [blame] | 2211 | /*********************************************************************** |
| 2212 | * BVC-BLOCK / BVC-UNBLOCK procedure |
| 2213 | ***********************************************************************/ |
| 2214 | |
Harald Welte | 239aa50 | 2020-11-24 23:14:20 +0100 | [diff] [blame] | 2215 | private function f_block_ptp_bvc_from_pcu(integer pcu_idx, integer bvc_idx) runs on test_CT |
| 2216 | { |
| 2217 | var BSSGP_BVC_CT bvc_ct := g_pcu[pcu_idx].vc_BSSGP_BVC[bvc_idx]; |
| 2218 | var BssgpBvcConfig bvc_cfg := g_pcu[pcu_idx].cfg.bvc[bvc_idx]; |
| 2219 | var Nsei nsei_pcu := g_pcu[pcu_idx].cfg.nsei; |
| 2220 | |
| 2221 | SGSN_MGMT.clear; |
| 2222 | PCU_MGMT.clear; |
| 2223 | |
| 2224 | /* block the PTP BVC from the PCU side */ |
| 2225 | PCU_MGMT.send(BssgpBlockRequest:{cause:=BSSGP_CAUSE_OM_INTERVENTION}) to bvc_ct; |
| 2226 | /* expect state on both PCU and SGSN side to change */ |
| 2227 | interleave { |
| 2228 | [] PCU_MGMT.receive(tr_BssgpStsInd(nsei_pcu, bvc_cfg.bvci, BVC_S_BLOCKED)) from bvc_ct; |
| 2229 | [] SGSN_MGMT.receive(tr_BssgpStsInd(*, bvc_cfg.bvci, BVC_S_BLOCKED)); |
| 2230 | } |
| 2231 | setverdict(pass); |
| 2232 | } |
| 2233 | testcase TC_bvc_block_ptp() runs on test_CT |
| 2234 | { |
| 2235 | f_init(); |
| 2236 | f_sleep(1.0); |
| 2237 | f_block_ptp_bvc_from_pcu(0, 0); |
| 2238 | f_cleanup(); |
| 2239 | } |
| 2240 | |
| 2241 | private function f_unblock_ptp_bvc_from_pcu(integer pcu_idx, integer bvc_idx) runs on test_CT |
| 2242 | { |
| 2243 | var BSSGP_BVC_CT bvc_ct := g_pcu[pcu_idx].vc_BSSGP_BVC[bvc_idx]; |
| 2244 | var BssgpBvcConfig bvc_cfg := g_pcu[pcu_idx].cfg.bvc[bvc_idx]; |
| 2245 | var Nsei nsei_pcu := g_pcu[pcu_idx].cfg.nsei; |
| 2246 | |
| 2247 | SGSN_MGMT.clear; |
| 2248 | PCU_MGMT.clear; |
| 2249 | |
| 2250 | /* block the PTP BVC from the PCU side */ |
| 2251 | PCU_MGMT.send(BssgpUnblockRequest:{}) to bvc_ct; |
| 2252 | /* expect state on both PCU and SGSN side to change */ |
| 2253 | interleave { |
| 2254 | [] PCU_MGMT.receive(tr_BssgpStsInd(nsei_pcu, bvc_cfg.bvci, BVC_S_UNBLOCKED)) from bvc_ct; |
| 2255 | [] SGSN_MGMT.receive(tr_BssgpStsInd(*, bvc_cfg.bvci, BVC_S_UNBLOCKED)); |
| 2256 | } |
| 2257 | setverdict(pass); |
| 2258 | } |
| 2259 | testcase TC_bvc_unblock_ptp() runs on test_CT |
| 2260 | { |
| 2261 | f_init(); |
| 2262 | f_sleep(1.0); |
| 2263 | f_block_ptp_bvc_from_pcu(0, 0); |
| 2264 | f_sleep(1.0); |
| 2265 | f_unblock_ptp_bvc_from_pcu(0, 0); |
| 2266 | f_cleanup(); |
| 2267 | } |
| 2268 | |
Harald Welte | 4f91c3b | 2020-12-09 12:25:51 +0100 | [diff] [blame] | 2269 | /*********************************************************************** |
| 2270 | * BVC-RESET procedure |
| 2271 | ***********************************************************************/ |
| 2272 | |
Harald Welte | 60a8ec7 | 2020-11-25 17:12:53 +0100 | [diff] [blame] | 2273 | private altstep as_ignore_status(BSSGP_BVC_MGMT_PT pt) { |
| 2274 | [] pt.receive(BssgpStatusIndication:?) { repeat; } |
| 2275 | } |
| 2276 | private function f_get_sgsn_bvc_ct(integer sgsn_idx, BssgpBvci bvci) runs on test_CT return BSSGP_BVC_CT { |
| 2277 | for (var integer i := 0; i < lengthof(g_sgsn[sgsn_idx].cfg.bvc); i := i+1) { |
| 2278 | if (g_sgsn[sgsn_idx].cfg.bvc[i].bvci == bvci) { |
| 2279 | return g_sgsn[sgsn_idx].vc_BSSGP_BVC[i]; |
| 2280 | } |
| 2281 | } |
| 2282 | return null; |
| 2283 | } |
| 2284 | private function f_reset_ptp_bvc_from_pcu(integer pcu_idx, integer bvc_idx) runs on test_CT |
| 2285 | { |
| 2286 | var BSSGP_BVC_CT pcu_bvc_ct := g_pcu[pcu_idx].vc_BSSGP_BVC[bvc_idx]; |
| 2287 | var BssgpBvcConfig bvc_cfg := g_pcu[pcu_idx].cfg.bvc[bvc_idx]; |
| 2288 | var Nsei nsei_pcu := g_pcu[pcu_idx].cfg.nsei; |
| 2289 | var BSSGP_BVC_CT sgsn_bvc_ct := f_get_sgsn_bvc_ct(0, bvc_cfg.bvci); |
| 2290 | var default d; |
| 2291 | |
| 2292 | SGSN_MGMT.clear; |
| 2293 | PCU_MGMT.clear; |
| 2294 | |
| 2295 | /* block the PTP BVC from the PCU side */ |
| 2296 | PCU_MGMT.send(BssgpResetRequest:{cause:=BSSGP_CAUSE_OM_INTERVENTION}) to pcu_bvc_ct; |
| 2297 | /* expect state on both PCU and SGSN side to change */ |
| 2298 | d := activate(as_ignore_status(SGSN_MGMT)); |
| 2299 | interleave { |
| 2300 | [] PCU_MGMT.receive(tr_BssgpStsInd(nsei_pcu, bvc_cfg.bvci, BVC_S_BLOCKED)) from pcu_bvc_ct; |
| 2301 | [] SGSN_MGMT.receive(BssgpResetIndication:{bvc_cfg.bvci}) from sgsn_bvc_ct; |
| 2302 | } |
| 2303 | deactivate(d); |
| 2304 | setverdict(pass); |
| 2305 | } |
| 2306 | /* Send a BVC-RESET for a PTP BVC from the BSS side: expect it to propagate */ |
| 2307 | testcase TC_bvc_reset_ptp_from_bss() runs on test_CT |
| 2308 | { |
| 2309 | f_init(); |
| 2310 | f_sleep(3.0); |
| 2311 | f_reset_ptp_bvc_from_pcu(0, 0); |
| 2312 | f_cleanup(); |
| 2313 | } |
| 2314 | |
Harald Welte | 16786e9 | 2020-11-27 19:11:56 +0100 | [diff] [blame] | 2315 | private altstep as_count_bvc_block(integer sgsn_idx, BssgpBvci bvci, inout ro_integer roi) |
| 2316 | runs on test_CT { |
| 2317 | var BSSGP_BVC_CT sgsn_bvc_ct := f_get_sgsn_bvc_ct(sgsn_idx, bvci); |
| 2318 | [] SGSN_MGMT.receive(tr_BssgpStsInd(?, bvci, BVC_S_BLOCKED)) from sgsn_bvc_ct { |
| 2319 | roi := roi & { bvci }; |
Harald Welte | b2647f7 | 2020-12-07 14:36:35 +0100 | [diff] [blame] | 2320 | repeat; |
Harald Welte | 16786e9 | 2020-11-27 19:11:56 +0100 | [diff] [blame] | 2321 | } |
| 2322 | } |
| 2323 | /* reset the signaling BVC from one BSS; expect no signaling BVC reset on SGSN; but BVC-BLOCK for PTP */ |
| 2324 | testcase TC_bvc_reset_sig_from_bss() runs on test_CT { |
| 2325 | |
| 2326 | f_init(); |
| 2327 | f_sleep(3.0); |
| 2328 | |
| 2329 | /* Start BVC-RESET procedure for BVCI=0 */ |
| 2330 | PCU_MGMT.send(BssgpResetRequest:{cause:=BSSGP_CAUSE_OM_INTERVENTION}) to g_pcu[0].vc_BSSGP; |
| 2331 | |
| 2332 | /* Activate altsteps: One for each PTP BVC within that PCUs NSE */ |
| 2333 | var ro_default defaults := {}; |
| 2334 | for (var integer i := 0; i < lengthof(g_pcu[0].cfg.bvc); i := i+1) { |
| 2335 | var BssgpBvcConfig bvcc := g_pcu[0].cfg.bvc[i]; |
| 2336 | var default d := activate(as_count_bvc_block(0, bvcc.bvci, g_roi)); |
| 2337 | defaults := defaults & { d }; |
| 2338 | } |
| 2339 | |
| 2340 | timer T := 3.0; |
| 2341 | T.start; |
| 2342 | alt { |
| 2343 | [] SGSN_MGMT.receive(BssgpResetIndication:{0}) { |
| 2344 | setverdict(fail, "BSS-side Reset of BVCI=0 should not propagate"); |
| 2345 | } |
| 2346 | [] T.timeout; |
| 2347 | } |
| 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[0].cfg.bvc); i := i+1) { |
| 2355 | var BssgpBvcConfig bvcc := g_pcu[0].cfg.bvc[i]; |
| 2356 | if (not ro_integer_contains(g_roi, bvcc.bvci)) { |
| 2357 | setverdict(fail, "Missing SGSN-side BVC-BLOCK of BVCI=", bvcc.bvci); |
| 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' */ |
Daniel Willmann | f259021 | 2020-12-04 14:20:50 +0100 | [diff] [blame] | 2363 | setverdict(pass); |
Harald Welte | 16786e9 | 2020-11-27 19:11:56 +0100 | [diff] [blame] | 2364 | f_cleanup(); |
| 2365 | } |
| 2366 | |
Harald Welte | 60a8ec7 | 2020-11-25 17:12:53 +0100 | [diff] [blame] | 2367 | private function f_reset_ptp_bvc_from_sgsn(integer pcu_idx, integer bvc_idx) runs on test_CT |
| 2368 | { |
| 2369 | var BSSGP_BVC_CT pcu_bvc_ct := g_pcu[pcu_idx].vc_BSSGP_BVC[bvc_idx]; |
| 2370 | var BssgpBvcConfig bvc_cfg := g_pcu[pcu_idx].cfg.bvc[bvc_idx]; |
| 2371 | var Nsei nsei_pcu := g_pcu[pcu_idx].cfg.nsei; |
| 2372 | var BSSGP_BVC_CT sgsn_bvc_ct := f_get_sgsn_bvc_ct(0, bvc_cfg.bvci); |
| 2373 | var default d; |
| 2374 | |
| 2375 | SGSN_MGMT.clear; |
| 2376 | PCU_MGMT.clear; |
| 2377 | |
| 2378 | /* block the PTP BVC from the PCU side */ |
| 2379 | SGSN_MGMT.send(BssgpResetRequest:{cause:=BSSGP_CAUSE_OM_INTERVENTION}) to sgsn_bvc_ct; |
| 2380 | /* expect state on both PCU and SGSN side to change */ |
| 2381 | d := activate(as_ignore_status(PCU_MGMT)); |
| 2382 | interleave { |
| 2383 | [] SGSN_MGMT.receive(tr_BssgpStsInd(?, bvc_cfg.bvci, BVC_S_BLOCKED)) from sgsn_bvc_ct; |
| 2384 | [] PCU_MGMT.receive(BssgpResetIndication:{bvc_cfg.bvci}) from pcu_bvc_ct; |
| 2385 | } |
| 2386 | deactivate(d); |
| 2387 | setverdict(pass); |
| 2388 | } |
| 2389 | /* Send a BVC-RESET for a PTP BVC from the SGSN side: expect it to propagate */ |
| 2390 | testcase TC_bvc_reset_ptp_from_sgsn() runs on test_CT |
| 2391 | { |
| 2392 | f_init(); |
| 2393 | f_sleep(3.0); |
| 2394 | f_reset_ptp_bvc_from_sgsn(0, 0); |
| 2395 | f_cleanup(); |
| 2396 | } |
| 2397 | |
Daniel Willmann | ef7015f | 2021-01-08 00:43:56 +0100 | [diff] [blame] | 2398 | private altstep as_ignore_mgmt(BSSGP_BVC_MGMT_PT pt) { |
| 2399 | [] pt.receive {repeat; } |
| 2400 | } |
| 2401 | |
Harald Welte | 16786e9 | 2020-11-27 19:11:56 +0100 | [diff] [blame] | 2402 | private altstep as_count_bvc0_block(integer pcu_idx, Nsei nsei, inout ro_integer roi) |
| 2403 | runs on test_CT { |
| 2404 | var BSSGP_CT pcu_ct := g_pcu[pcu_idx].vc_BSSGP; |
| 2405 | [] PCU_MGMT.receive(BssgpResetIndication:{0}) from pcu_ct { |
| 2406 | roi := roi & { nsei }; |
Daniel Willmann | ef7015f | 2021-01-08 00:43:56 +0100 | [diff] [blame] | 2407 | repeat; |
Harald Welte | 16786e9 | 2020-11-27 19:11:56 +0100 | [diff] [blame] | 2408 | } |
| 2409 | } |
Daniel Willmann | ef7015f | 2021-01-08 00:43:56 +0100 | [diff] [blame] | 2410 | |
Harald Welte | 16786e9 | 2020-11-27 19:11:56 +0100 | [diff] [blame] | 2411 | /* reset the signaling BVC from the SGSN; expect all signaling BVC on all BSS to be reset */ |
| 2412 | testcase TC_bvc_reset_sig_from_sgsn() runs on test_CT { |
| 2413 | |
| 2414 | f_init(); |
| 2415 | f_sleep(3.0); |
| 2416 | |
Daniel Willmann | ef7015f | 2021-01-08 00:43:56 +0100 | [diff] [blame] | 2417 | SGSN_MGMT.clear; |
| 2418 | PCU_MGMT.clear; |
| 2419 | |
Harald Welte | 16786e9 | 2020-11-27 19:11:56 +0100 | [diff] [blame] | 2420 | /* Start BVC-RESET procedure for BVCI=0 */ |
| 2421 | SGSN_MGMT.send(BssgpResetRequest:{cause:=BSSGP_CAUSE_OM_INTERVENTION}) to g_sgsn[0].vc_BSSGP; |
| 2422 | |
Daniel Willmann | ef7015f | 2021-01-08 00:43:56 +0100 | [diff] [blame] | 2423 | /* Defaults match in reverse activation order, this one is a catch-all for Status indications |
| 2424 | * and reset indications sent from other components (like the ptp_bvcs). If we don't drain |
| 2425 | * the port and a different message sits at the front we wait forever and fail the test. |
| 2426 | */ |
| 2427 | var ro_default defaults := { activate(as_ignore_mgmt(PCU_MGMT)) }; |
| 2428 | |
Harald Welte | 16786e9 | 2020-11-27 19:11:56 +0100 | [diff] [blame] | 2429 | /* Activate altsteps: One for each PCU NSE */ |
Harald Welte | 16786e9 | 2020-11-27 19:11:56 +0100 | [diff] [blame] | 2430 | for (var integer i := 0; i < lengthof(g_pcu); i := i+1) { |
| 2431 | var NSConfiguration nscfg := mp_nsconfig_pcu[i]; |
| 2432 | var default d := activate(as_count_bvc0_block(i, nscfg.nsei, g_roi)); |
| 2433 | defaults := defaults & { d }; |
| 2434 | } |
| 2435 | |
| 2436 | f_sleep(3.0); |
| 2437 | |
| 2438 | for (var integer i := 0; i < lengthof(defaults); i := i+1) { |
| 2439 | deactivate(defaults[i]); |
| 2440 | } |
| 2441 | |
| 2442 | /* check if BVC-block was received on all expected BVC */ |
| 2443 | for (var integer i := 0; i < lengthof(g_pcu); i := i+1) { |
| 2444 | var NSConfiguration nscfg := mp_nsconfig_pcu[i]; |
| 2445 | if (not ro_integer_contains(g_roi, nscfg.nsei)) { |
| 2446 | setverdict(fail, "Missing PCU-side BVC-RESET of BVCI=0 on PCU index ", i); |
| 2447 | } |
| 2448 | } |
| 2449 | |
| 2450 | /* check if BVC-block was not received on any unexpected BVC is not required as |
| 2451 | * such a message would basically run into 'no matching clause' */ |
| 2452 | |
| 2453 | f_cleanup(); |
| 2454 | } |
| 2455 | |
Harald Welte | 299aa48 | 2020-12-09 15:10:55 +0100 | [diff] [blame] | 2456 | /*********************************************************************** |
| 2457 | * FLOW-CONTROL-BVC procedure |
| 2458 | ***********************************************************************/ |
| 2459 | |
| 2460 | private altstep as_g_count_sgsn(integer sgsn_idx, inout ro_integer roi, |
| 2461 | template PDU_BSSGP exp_rx, template (omit) PDU_BSSGP tx_reply) |
| 2462 | runs on GlobalTest_CT { |
| 2463 | [] G_SGSN[sgsn_idx].receive(exp_rx) { |
| 2464 | roi := roi & { sgsn_idx }; |
| 2465 | if (ispresent(tx_reply)) { |
| 2466 | G_SGSN[sgsn_idx].send(tx_reply); |
| 2467 | } |
Harald Welte | 5fb0174 | 2021-01-15 21:07:52 +0100 | [diff] [blame] | 2468 | repeat; |
Harald Welte | 299aa48 | 2020-12-09 15:10:55 +0100 | [diff] [blame] | 2469 | } |
| 2470 | } |
| 2471 | /* Send FC-BVC from simulated PCU; expect each SGSN to receive it; expect PCU to receive ACK */ |
| 2472 | testcase TC_fc_bvc() runs on GlobalTest_CT |
| 2473 | { |
| 2474 | f_init(); |
| 2475 | f_global_init_ptp(); |
| 2476 | |
| 2477 | var template (value) PDU_BSSGP pdu_tx := t_BVC_FC_BVC(10240, 2000, 1024, 1000, '01'O); |
| 2478 | /* we cannot use pdu_tx as there are some subtle differences in the length field :/ */ |
| 2479 | var template (present) PDU_BSSGP pdu_rx := tr_BVC_FC_BVC(10240, 2000, 1024, 1000, '01'O); |
| 2480 | var template (omit) PDU_BSSGP ack_tx := |
| 2481 | t_BVC_FC_BVC_ACK(pdu_tx.pDU_BSSGP_FLOW_CONTROL_BVC.tag.unstructured_Value); |
| 2482 | |
| 2483 | /* Send a FC-BVC from BSS to gbproxy, expect an ACK in response */ |
| 2484 | G_PCU[0].send(pdu_tx); |
| 2485 | |
| 2486 | /* Activate altsteps: One for each SGSN-side PTP BVC port */ |
| 2487 | var ro_default defaults := {}; |
| 2488 | for (var integer i := 0; i < lengthof(g_sgsn); i := i+1) { |
| 2489 | var default d := activate(as_g_count_sgsn(i, g_roi, pdu_rx, ack_tx)); |
| 2490 | defaults := defaults & { d }; |
| 2491 | } |
| 2492 | |
| 2493 | f_sleep(3.0); |
| 2494 | |
| 2495 | for (var integer i := 0; i < lengthof(defaults); i := i+1) { |
| 2496 | deactivate(defaults[i]); |
| 2497 | } |
| 2498 | |
| 2499 | /* check if BVC-block was received on all expected BVC */ |
| 2500 | for (var integer i := 0; i < lengthof(g_sgsn); i := i+1) { |
| 2501 | if (not ro_integer_contains(g_roi, i)) { |
| 2502 | setverdict(fail, "Missing BVC-FLOW-CONTROL on SGSN index ", i); |
| 2503 | } |
| 2504 | } |
| 2505 | |
| 2506 | /* Expect ACK on PCU side */ |
| 2507 | G_PCU[0].receive(ack_tx); |
| 2508 | |
| 2509 | setverdict(pass); |
| 2510 | |
| 2511 | f_cleanup(); |
| 2512 | } |
| 2513 | |
Harald Welte | cc3894b | 2020-12-09 16:50:12 +0100 | [diff] [blame] | 2514 | /*********************************************************************** |
| 2515 | * FLOW-CONTROL-MS procedure |
| 2516 | ***********************************************************************/ |
| 2517 | |
| 2518 | private function f_TC_fc_ms(charstring id) runs on BSSGP_ConnHdlr { |
| 2519 | var BssgpBvci bvci := g_pars.pcu[0].cfg.bvc[0].bvci; |
| 2520 | |
| 2521 | var template (value) PDU_BSSGP fc_tx := ts_BVC_FC_MS(g_pars.tlli, 100, 200, '12'O); |
| 2522 | /* we cannot use pdu_tx as there are some subtle differences in the length field :/ */ |
| 2523 | var template (present) PDU_BSSGP fc_rx := tr_BVC_FC_MS(g_pars.tlli, 100, 200, '12'O); |
| 2524 | var template (value) PDU_BSSGP ack_tx := ts_BVC_FC_MS_ACK(g_pars.tlli, '12'O); |
| 2525 | |
| 2526 | f_pcu2sgsn(fc_tx, fc_rx, use_sig := false); |
| 2527 | f_sgsn2pcu(ack_tx, ack_tx, use_sig := false); |
| 2528 | |
| 2529 | setverdict(pass); |
| 2530 | } |
| 2531 | /* Send a FLOW-CONTROL-MS from BSS side and expect it to show up on SGSN (PTP BVC) */ |
| 2532 | testcase TC_fc_ms() runs on test_CT |
| 2533 | { |
Harald Welte | cc3894b | 2020-12-09 16:50:12 +0100 | [diff] [blame] | 2534 | f_init(); |
Harald Welte | 2ecbca8 | 2021-01-16 11:23:09 +0100 | [diff] [blame] | 2535 | f_start_handlers(refers(f_TC_fc_ms), testcasename(), 21); |
Harald Welte | cc3894b | 2020-12-09 16:50:12 +0100 | [diff] [blame] | 2536 | /* 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] | 2537 | f_cleanup(); |
| 2538 | } |
| 2539 | |
| 2540 | |
Harald Welte | 299aa48 | 2020-12-09 15:10:55 +0100 | [diff] [blame] | 2541 | |
Daniel Willmann | 423d8f4 | 2020-09-08 18:58:22 +0200 | [diff] [blame] | 2542 | control { |
| 2543 | execute( TC_BVC_bringup() ); |
Harald Welte | 9268601 | 2020-11-15 21:45:49 +0100 | [diff] [blame] | 2544 | execute( TC_ul_unitdata() ); |
Harald Welte | 78d8db9 | 2020-11-15 23:27:27 +0100 | [diff] [blame] | 2545 | execute( TC_dl_unitdata() ); |
Harald Welte | 6dc2ac4 | 2020-11-16 09:16:17 +0100 | [diff] [blame] | 2546 | execute( TC_ra_capability() ); |
Daniel Willmann | ace3ece | 2020-11-16 19:53:26 +0100 | [diff] [blame] | 2547 | execute( TC_ra_capability_upd() ); |
Daniel Willmann | 165d661 | 2020-11-19 14:27:29 +0100 | [diff] [blame] | 2548 | execute( TC_radio_status() ); |
Daniel Willmann | fa67f49 | 2020-11-19 15:48:05 +0100 | [diff] [blame] | 2549 | execute( TC_suspend() ); |
Daniel Willmann | 087a33d | 2020-11-19 15:58:43 +0100 | [diff] [blame] | 2550 | execute( TC_resume() ); |
Harald Welte | f8e5c5d | 2020-11-27 22:37:23 +0100 | [diff] [blame] | 2551 | execute( TC_trace() ); |
Harald Welte | c0351d1 | 2020-11-27 22:49:02 +0100 | [diff] [blame] | 2552 | execute( TC_llc_discarded() ); |
Harald Welte | f20af41 | 2020-11-28 16:11:11 +0100 | [diff] [blame] | 2553 | execute( TC_overload() ); |
Harald Welte | 239aa50 | 2020-11-24 23:14:20 +0100 | [diff] [blame] | 2554 | execute( TC_bvc_block_ptp() ); |
| 2555 | execute( TC_bvc_unblock_ptp() ); |
Harald Welte | 60a8ec7 | 2020-11-25 17:12:53 +0100 | [diff] [blame] | 2556 | execute( TC_bvc_reset_ptp_from_bss() ); |
Harald Welte | 16786e9 | 2020-11-27 19:11:56 +0100 | [diff] [blame] | 2557 | execute( TC_bvc_reset_sig_from_bss() ); |
Harald Welte | 60a8ec7 | 2020-11-25 17:12:53 +0100 | [diff] [blame] | 2558 | execute( TC_bvc_reset_ptp_from_sgsn() ); |
Harald Welte | 16786e9 | 2020-11-27 19:11:56 +0100 | [diff] [blame] | 2559 | execute( TC_bvc_reset_sig_from_sgsn() ); |
Harald Welte | f6e59b0 | 2020-12-08 08:29:09 +0100 | [diff] [blame] | 2560 | if (mp_enable_bss_load_sharing) { |
Harald Welte | f8ef028 | 2020-11-18 12:16:59 +0100 | [diff] [blame] | 2561 | /* don't enable this by default, as we don't yet have any automatic test setup for FR with 4 NS-VC */ |
| 2562 | execute( TC_load_sharing_dl() ); |
| 2563 | } |
Harald Welte | 0e18824 | 2020-11-22 21:46:48 +0100 | [diff] [blame] | 2564 | |
| 2565 | /* PAGING-PS over PTP BVC */ |
| 2566 | execute( TC_paging_ps_ptp_bss() ); |
| 2567 | execute( TC_paging_ps_ptp_lac() ); |
Harald Welte | 7462a59 | 2020-11-23 22:07:07 +0100 | [diff] [blame] | 2568 | execute( TC_paging_ps_ptp_lac_unknown() ); |
Harald Welte | 0e18824 | 2020-11-22 21:46:48 +0100 | [diff] [blame] | 2569 | execute( TC_paging_ps_ptp_rac() ); |
Harald Welte | 7462a59 | 2020-11-23 22:07:07 +0100 | [diff] [blame] | 2570 | execute( TC_paging_ps_ptp_rac_unknown() ); |
Harald Welte | 0e18824 | 2020-11-22 21:46:48 +0100 | [diff] [blame] | 2571 | execute( TC_paging_ps_ptp_bvci() ); |
Harald Welte | b5a04aa | 2021-01-16 13:04:40 +0100 | [diff] [blame] | 2572 | execute( TC_paging_ps_ptp_bvci_imsi() ); |
Harald Welte | 7462a59 | 2020-11-23 22:07:07 +0100 | [diff] [blame] | 2573 | execute( TC_paging_ps_ptp_bvci_unknown() ); |
Harald Welte | cf20007 | 2021-01-16 15:20:46 +0100 | [diff] [blame^] | 2574 | execute( TC_paging_ps_reject_ptp_bvci() ); |
| 2575 | execute( TC_paging_ps_reject_ptp_bvci_imsi() ); |
Harald Welte | 0e18824 | 2020-11-22 21:46:48 +0100 | [diff] [blame] | 2576 | |
| 2577 | /* PAGING-PS over SIG BVC */ |
| 2578 | execute( TC_paging_ps_sig_bss() ); |
| 2579 | execute( TC_paging_ps_sig_lac() ); |
Harald Welte | 7462a59 | 2020-11-23 22:07:07 +0100 | [diff] [blame] | 2580 | execute( TC_paging_ps_sig_lac_unknown() ); |
Harald Welte | 0e18824 | 2020-11-22 21:46:48 +0100 | [diff] [blame] | 2581 | execute( TC_paging_ps_sig_rac() ); |
Harald Welte | 7462a59 | 2020-11-23 22:07:07 +0100 | [diff] [blame] | 2582 | execute( TC_paging_ps_sig_rac_unknown() ); |
Harald Welte | 0e18824 | 2020-11-22 21:46:48 +0100 | [diff] [blame] | 2583 | execute( TC_paging_ps_sig_bvci() ); |
Harald Welte | b5a04aa | 2021-01-16 13:04:40 +0100 | [diff] [blame] | 2584 | execute( TC_paging_ps_sig_bvci_imsi() ); |
Harald Welte | 7462a59 | 2020-11-23 22:07:07 +0100 | [diff] [blame] | 2585 | execute( TC_paging_ps_sig_bvci_unknown() ); |
Harald Welte | cf20007 | 2021-01-16 15:20:46 +0100 | [diff] [blame^] | 2586 | execute( TC_paging_ps_reject_sig_bvci() ); |
| 2587 | execute( TC_paging_ps_reject_sig_bvci_imsi() ); |
Harald Welte | 0e18824 | 2020-11-22 21:46:48 +0100 | [diff] [blame] | 2588 | |
| 2589 | /* PAGING-CS over PTP BVC */ |
| 2590 | execute( TC_paging_cs_ptp_bss() ); |
| 2591 | execute( TC_paging_cs_ptp_lac() ); |
Harald Welte | 7462a59 | 2020-11-23 22:07:07 +0100 | [diff] [blame] | 2592 | execute( TC_paging_cs_ptp_lac_unknown() ); |
Harald Welte | 0e18824 | 2020-11-22 21:46:48 +0100 | [diff] [blame] | 2593 | execute( TC_paging_cs_ptp_rac() ); |
Harald Welte | 7462a59 | 2020-11-23 22:07:07 +0100 | [diff] [blame] | 2594 | execute( TC_paging_cs_ptp_rac_unknown() ); |
Harald Welte | 0e18824 | 2020-11-22 21:46:48 +0100 | [diff] [blame] | 2595 | execute( TC_paging_cs_ptp_bvci() ); |
Harald Welte | 7462a59 | 2020-11-23 22:07:07 +0100 | [diff] [blame] | 2596 | execute( TC_paging_cs_ptp_bvci_unknown() ); |
Harald Welte | 0e18824 | 2020-11-22 21:46:48 +0100 | [diff] [blame] | 2597 | |
| 2598 | /* PAGING-CS over SIG BVC */ |
| 2599 | execute( TC_paging_cs_sig_bss() ); |
| 2600 | execute( TC_paging_cs_sig_lac() ); |
Harald Welte | 7462a59 | 2020-11-23 22:07:07 +0100 | [diff] [blame] | 2601 | execute( TC_paging_cs_sig_lac_unknown() ); |
Harald Welte | 0e18824 | 2020-11-22 21:46:48 +0100 | [diff] [blame] | 2602 | execute( TC_paging_cs_sig_rac() ); |
Harald Welte | 7462a59 | 2020-11-23 22:07:07 +0100 | [diff] [blame] | 2603 | execute( TC_paging_cs_sig_rac_unknown() ); |
Harald Welte | 0e18824 | 2020-11-22 21:46:48 +0100 | [diff] [blame] | 2604 | execute( TC_paging_cs_sig_bvci() ); |
Harald Welte | 7462a59 | 2020-11-23 22:07:07 +0100 | [diff] [blame] | 2605 | execute( TC_paging_cs_sig_bvci_unknown() ); |
Harald Welte | 0e18824 | 2020-11-22 21:46:48 +0100 | [diff] [blame] | 2606 | |
| 2607 | |
Daniel Willmann | 91a8e25b | 2020-11-24 14:50:59 +0100 | [diff] [blame] | 2608 | execute( TC_flush_ll() ); |
Harald Welte | 299aa48 | 2020-12-09 15:10:55 +0100 | [diff] [blame] | 2609 | execute( TC_fc_bvc() ); |
Harald Welte | cc3894b | 2020-12-09 16:50:12 +0100 | [diff] [blame] | 2610 | execute( TC_fc_ms() ); |
Daniel Willmann | 423d8f4 | 2020-09-08 18:58:22 +0200 | [diff] [blame] | 2611 | } |
| 2612 | |
| 2613 | |
| 2614 | } |