Harald Welte | 56db5fd | 2017-07-14 18:25:59 +0200 | [diff] [blame] | 1 | module Test { |
Harald Welte | af54941 | 2017-07-15 21:33:21 +0200 | [diff] [blame] | 2 | import from GSM_Types all; |
Harald Welte | f0a4997 | 2017-07-16 03:55:20 +0200 | [diff] [blame] | 3 | import from Osmocom_Types all; |
Harald Welte | 56db5fd | 2017-07-14 18:25:59 +0200 | [diff] [blame] | 4 | import from GSM_SystemInformation all; |
Harald Welte | f976492 | 2017-08-20 22:47:44 +0200 | [diff] [blame] | 5 | import from GSM_RR_Types all; |
Harald Welte | b622a3d | 2017-07-14 22:26:33 +0200 | [diff] [blame] | 6 | import from GSMTAP_Types all; |
| 7 | import from GSMTAP_PortType all; |
| 8 | import from IPL4_GSMTAP_CtrlFunct all; |
Harald Welte | 9a907b3 | 2017-07-15 10:34:27 +0200 | [diff] [blame] | 9 | import from TELNETasp_PortType all; |
Harald Welte | 8542cef | 2017-07-19 20:06:26 +0200 | [diff] [blame] | 10 | import from Osmocom_VTY_Functions all; |
Harald Welte | 56db5fd | 2017-07-14 18:25:59 +0200 | [diff] [blame] | 11 | |
| 12 | const octetstring si1 := '5506198fb38000000000000000000000000000e504002b'O; |
| 13 | const octetstring si2 := '59061a00000000000000000000000000000000ffe50400'O; |
| 14 | const octetstring si3 := '49061b000062f22404d2490301275d40e50400392b2b2b'O; |
| 15 | const octetstring si4 := '31061c62f22404d25d40e504002b2b2b2b2b2b2b2b2b2b'O; |
Harald Welte | bdc5dbd | 2017-07-16 00:00:43 +0200 | [diff] [blame] | 16 | const octetstring c_si2bis := '550602bfe809b3ff00000000000000000000007900002b'O; |
| 17 | const octetstring c_si2ter := '010603bf66b0aa0a00000002000000000000002b2b2b2b'O; |
| 18 | const octetstring c_si2quater := '050607a8a0364aa698d72ff424feee0506d5e7fff02043'O; |
Harald Welte | 56db5fd | 2017-07-14 18:25:59 +0200 | [diff] [blame] | 19 | |
| 20 | type component dummy_CT { |
Harald Welte | b622a3d | 2017-07-14 22:26:33 +0200 | [diff] [blame] | 21 | port GSMTAP_PT GSMTAP; |
Harald Welte | 9a907b3 | 2017-07-15 10:34:27 +0200 | [diff] [blame] | 22 | port TELNETasp_PT BSCVTY; |
Harald Welte | bdc5dbd | 2017-07-16 00:00:43 +0200 | [diff] [blame] | 23 | var boolean initialized := false; |
| 24 | var SystemInformationConfig si_cfg := { |
| 25 | bcch_extended := false, |
| 26 | si1_present := true, |
| 27 | si2bis_present := false, |
| 28 | si2ter_present := false, |
| 29 | si2quater_present := false, |
| 30 | si7_present := false, |
| 31 | si8_present := false, |
| 32 | si9_present := false, |
| 33 | si13_present := false, |
| 34 | si13alt_present := false, |
| 35 | si15_present := false, |
| 36 | si16_present := false, |
| 37 | si17_present := false, |
| 38 | si2n_present := false, |
| 39 | si21_present := false, |
| 40 | si22_present := false |
| 41 | }; |
Harald Welte | 56db5fd | 2017-07-14 18:25:59 +0200 | [diff] [blame] | 42 | }; |
| 43 | |
| 44 | testcase TC_si1() runs on dummy_CT { |
Harald Welte | 56db5fd | 2017-07-14 18:25:59 +0200 | [diff] [blame] | 45 | log("SI: ", dec_SystemInformation(si1)); |
| 46 | log("SI: ", dec_SystemInformation(si2)); |
| 47 | log("SI: ", dec_SystemInformation(si3)); |
| 48 | log("SI: ", dec_SystemInformation(si4)); |
Harald Welte | bdc5dbd | 2017-07-16 00:00:43 +0200 | [diff] [blame] | 49 | setverdict(pass); |
Harald Welte | 56db5fd | 2017-07-14 18:25:59 +0200 | [diff] [blame] | 50 | } |
| 51 | |
Harald Welte | b622a3d | 2017-07-14 22:26:33 +0200 | [diff] [blame] | 52 | template GsmtapHeader t_GsmtapHeader := { |
| 53 | version := GSMTAP_VERSION, |
| 54 | hdr_len := 4, |
| 55 | msg_type := ?, |
| 56 | timeslot := ?, |
| 57 | arfcn := ?, |
| 58 | signal_dbm := ?, |
| 59 | snr_db := ?, |
| 60 | frame_number := ?, |
| 61 | sub_type := ?, |
| 62 | antenna_nr := ?, |
| 63 | sub_slot := ?, |
| 64 | res := ? |
| 65 | } |
| 66 | |
| 67 | template GsmtapHeader t_GsmtapHeaderUm(template GsmtapChannel ch) modifies t_GsmtapHeader := { |
| 68 | msg_type := GSMTAP_TYPE_UM, |
| 69 | sub_type := ch |
| 70 | } |
| 71 | |
Harald Welte | b622a3d | 2017-07-14 22:26:33 +0200 | [diff] [blame] | 72 | template GsmtapMessage t_bcch := { |
| 73 | header := t_GsmtapHeaderUm(GSMTAP_CHANNEL_BCCH), |
| 74 | payload := ? |
| 75 | } |
| 76 | |
| 77 | template GSMTAP_RecvFrom t_recvfrom(template GsmtapChannel ch) := { |
| 78 | connId := ?, |
| 79 | remName := ?, |
| 80 | remPort := ?, |
| 81 | locName := ?, |
| 82 | locPort := GSMTAP_PORT, |
| 83 | proto := {udp:={}}, |
| 84 | userData := ?, |
| 85 | msg := { header := t_GsmtapHeaderUm(ch), payload := ?} |
| 86 | } |
| 87 | |
Harald Welte | af54941 | 2017-07-15 21:33:21 +0200 | [diff] [blame] | 88 | /* tuple of gsmtap header + decoded SI */ |
| 89 | type record SystemInformationGsmtap { |
| 90 | GsmtapHeader gsmtap, |
| 91 | SystemInformation si |
| 92 | } |
| 93 | |
| 94 | /* an arbitrary-length vector of decoded SI + gsmtap header */ |
| 95 | type record of SystemInformationGsmtap SystemInformationVector; |
| 96 | |
| 97 | /* an array of SI-vectors indexed by TC value */ |
| 98 | type SystemInformationVector SystemInformationVectorPerTc[8]; |
| 99 | |
| 100 | type record of integer IntegerRecord; |
| 101 | |
Harald Welte | f0a4997 | 2017-07-16 03:55:20 +0200 | [diff] [blame] | 102 | function int2bool(integer int) return boolean { |
| 103 | if (int != 0) { |
| 104 | return true; |
| 105 | } else { |
| 106 | return false; |
| 107 | } |
| 108 | } |
| 109 | |
Harald Welte | af54941 | 2017-07-15 21:33:21 +0200 | [diff] [blame] | 110 | function f_array_contains(IntegerRecord arr, integer key) return boolean { |
| 111 | for (var integer i:= 0; i< sizeof(arr); i := i + 1) { |
| 112 | if (arr[i] == key) { |
| 113 | return true; |
| 114 | } |
| 115 | } |
| 116 | return false; |
| 117 | } |
| 118 | |
| 119 | |
| 120 | /* compute TC as per 45.002 6.3.1.3 */ |
| 121 | function f_gsm_compute_tc(integer fn) return integer { |
| 122 | return (fn / 51) mod 8; |
| 123 | } |
| 124 | |
| 125 | /* determine if a given SI vector contains given SI type at least once */ |
| 126 | function f_si_vecslot_contains(SystemInformationVector arr, RrMessageType key, boolean bcch_ext := false) return boolean { |
| 127 | for (var integer i:= 0; i< sizeof(arr); i := i + 1) { |
| 128 | var integer fn_mod51 := arr[i].gsmtap.frame_number mod 51; |
| 129 | if (not bcch_ext and fn_mod51 == 2 or |
| 130 | bcch_ext and fn_mod51 == 6) { |
| 131 | if (arr[i].si.header.message_type == key) { |
| 132 | return true; |
| 133 | } |
| 134 | } |
| 135 | } |
| 136 | return false; |
| 137 | } |
| 138 | |
Harald Welte | 3927677 | 2017-07-16 01:07:42 +0200 | [diff] [blame] | 139 | /* ensure a given TC slot of the SI vector contains given SI type at least once at TC */ |
| 140 | function f_ensure_si_vec_contains(SystemInformationVectorPerTc arr, integer tc, RrMessageType key, boolean ext_bcch := false) { |
| 141 | if (not f_si_vecslot_contains(arr[tc], key, ext_bcch)) { |
| 142 | log("Fail: No ", key, " in TC=", tc, "!"); |
| 143 | setverdict(fail); |
| 144 | } |
| 145 | } |
| 146 | |
Harald Welte | af54941 | 2017-07-15 21:33:21 +0200 | [diff] [blame] | 147 | /* check if a given SI vector contains given SI type at least once on any TC */ |
| 148 | function f_si_vec_contains(SystemInformationVectorPerTc arr, RrMessageType key) return boolean { |
| 149 | for (var integer tc:= 0; tc < sizeof(arr); tc := tc + 1) { |
| 150 | if (f_si_vecslot_contains(arr[tc], key) or |
| 151 | f_si_vecslot_contains(arr[tc], key, true)) { |
| 152 | return true; |
| 153 | } |
| 154 | } |
| 155 | return false; |
| 156 | } |
| 157 | |
Harald Welte | 3927677 | 2017-07-16 01:07:42 +0200 | [diff] [blame] | 158 | /* determine if a given SI vector contains given SI type at least N of M times */ |
| 159 | function f_si_vecslot_contains_n_of_m(SystemInformationVector arr, RrMessageType key, boolean bcch_ext := false, integer n := 1, integer m := 4) return boolean { |
| 160 | var integer count := 0; |
| 161 | if (sizeof(arr) < m) { |
Harald Welte | 75f761f | 2017-07-16 03:05:31 +0200 | [diff] [blame] | 162 | testcase.stop("Error: Insufficient SI in array"); |
Harald Welte | 3927677 | 2017-07-16 01:07:42 +0200 | [diff] [blame] | 163 | } |
| 164 | for (var integer i:= 0; i < m; i := i + 1) { |
| 165 | var integer fn_mod51 := arr[i].gsmtap.frame_number mod 51; |
| 166 | if (not bcch_ext and fn_mod51 == 2 or |
| 167 | bcch_ext and fn_mod51 == 6) { |
| 168 | if (arr[i].si.header.message_type == key) { |
| 169 | count := count + 1; |
| 170 | } |
| 171 | } |
| 172 | } |
| 173 | if (count >= n) { |
| 174 | return true; |
| 175 | } else { |
| 176 | return false; |
| 177 | } |
| 178 | } |
| 179 | |
| 180 | /* ensure a given TC slot of the SI vector contains given SI type at least N out of M times at TC */ |
| 181 | function f_ensure_si_vec_contains_n_of_m(SystemInformationVectorPerTc arr, integer tc, RrMessageType key, boolean ext_bcch := false, integer n, integer m) { |
| 182 | if (not f_si_vecslot_contains_n_of_m(arr[tc], key, ext_bcch, n, m)) { |
| 183 | log("Fail: Not ", n, "/", m, " of ", key, " in TC=", tc, "!"); |
| 184 | setverdict(fail); |
| 185 | } |
| 186 | } |
| 187 | |
| 188 | /* determine if a given SI vector contains given SI type at least once */ |
| 189 | function f_si_vecslot_contains_only(SystemInformationVector arr, RrMessageType key, boolean bcch_ext := false) return boolean { |
| 190 | for (var integer i:= 0; i< sizeof(arr); i := i + 1) { |
| 191 | var integer fn_mod51 := arr[i].gsmtap.frame_number mod 51; |
| 192 | if (not bcch_ext and fn_mod51 == 2 or |
| 193 | bcch_ext and fn_mod51 == 6) { |
| 194 | if (arr[i].si.header.message_type != key) { |
| 195 | return false; |
| 196 | } |
| 197 | } |
| 198 | } |
| 199 | return true; |
| 200 | } |
| 201 | |
| 202 | /* ensure a given TC slot of the SI vector contains only given SI type */ |
| 203 | function f_ensure_si_vec_contains_only(SystemInformationVectorPerTc arr, integer tc, RrMessageType key, boolean ext_bcch := false) { |
| 204 | if (not f_si_vecslot_contains_only(arr[tc], key, ext_bcch)) { |
| 205 | log("Fail: Not all ", key, " in TC=", tc, "!"); |
Harald Welte | af54941 | 2017-07-15 21:33:21 +0200 | [diff] [blame] | 206 | setverdict(fail); |
| 207 | } |
| 208 | } |
| 209 | |
| 210 | /* SI configuration of cell, against which we validate actual SI messages */ |
| 211 | type set SystemInformationConfig { |
| 212 | boolean bcch_extended, |
| 213 | boolean si1_present, |
| 214 | boolean si2bis_present, |
| 215 | boolean si2ter_present, |
| 216 | boolean si2quater_present, |
| 217 | boolean si7_present, |
| 218 | boolean si8_present, |
| 219 | boolean si9_present, |
| 220 | boolean si13_present, |
| 221 | boolean si13alt_present, |
| 222 | boolean si15_present, |
| 223 | boolean si16_present, |
| 224 | boolean si17_present, |
| 225 | boolean si2n_present, |
| 226 | boolean si21_present, |
| 227 | boolean si22_present |
| 228 | } |
| 229 | |
| 230 | /* validate the SI scheduling according to TS 45.002 version 14.1.0 Release 14, Section 6.3.1.3 */ |
| 231 | function f_validate_si_scheduling(SystemInformationConfig cfg, SystemInformationVectorPerTc si_per_tc) { |
| 232 | var integer i; |
| 233 | for (i := 0; i < sizeof(si_per_tc); i := i + 1) { |
| 234 | if (sizeof(si_per_tc[i]) == 0) { |
| 235 | setverdict(fail, "No SI messages for TC=0!"); |
| 236 | } |
| 237 | } |
| 238 | if (cfg.si1_present) { |
| 239 | /* ii) System Information Type 1 needs to be sent if frequency hopping is in use or |
| 240 | * when the NCH is present in a cell. If the MS finds another message on BCCH Norm |
| 241 | * when TC = 0, it can assume that System Information Type 1 is not in use. */ |
| 242 | f_ensure_si_vec_contains(si_per_tc, 0, SYSTEM_INFORMATION_TYPE_1); |
Harald Welte | 3927677 | 2017-07-16 01:07:42 +0200 | [diff] [blame] | 243 | /* make sure *ALL* contain SI1 */ |
| 244 | f_ensure_si_vec_contains_only(si_per_tc, 0, SYSTEM_INFORMATION_TYPE_1); |
Harald Welte | af54941 | 2017-07-15 21:33:21 +0200 | [diff] [blame] | 245 | } |
| 246 | f_ensure_si_vec_contains(si_per_tc, 1, SYSTEM_INFORMATION_TYPE_2); |
| 247 | /* iii) A SI 2 message will be sent at least every time TC = 1 */ |
| 248 | f_ensure_si_vec_contains(si_per_tc, 2, SYSTEM_INFORMATION_TYPE_3); |
| 249 | f_ensure_si_vec_contains(si_per_tc, 6, SYSTEM_INFORMATION_TYPE_3); |
| 250 | f_ensure_si_vec_contains(si_per_tc, 3, SYSTEM_INFORMATION_TYPE_4); |
| 251 | f_ensure_si_vec_contains(si_per_tc, 7, SYSTEM_INFORMATION_TYPE_4); |
| 252 | |
| 253 | /* iii) System information type 2 bis or 2 ter messages are sent if needed, as determined by the |
| 254 | * system operator. If only one of them is needed, it is sent when TC = 5. If both are |
| 255 | * needed, 2bis is sent when TC = 5 and 2ter is sent at least once within any of 4 |
| 256 | * consecutive occurrences of TC = 4. */ |
| 257 | if (cfg.si2bis_present and not cfg.si2ter_present) { |
| 258 | f_ensure_si_vec_contains(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2bis); |
| 259 | } else if (cfg.si2ter_present and not cfg.si2bis_present) { |
| 260 | f_ensure_si_vec_contains(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2ter); |
| 261 | } else if (cfg.si2ter_present and cfg.si2bis_present) { |
| 262 | f_ensure_si_vec_contains(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2bis); |
Harald Welte | 3927677 | 2017-07-16 01:07:42 +0200 | [diff] [blame] | 263 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_2ter, false, 1, 4); |
Harald Welte | af54941 | 2017-07-15 21:33:21 +0200 | [diff] [blame] | 264 | } |
| 265 | |
| 266 | if (cfg.si7_present or cfg.si8_present) { |
| 267 | /* vi) Use of System Information type 7 and 8 is not always necessary. It is necessary |
| 268 | * if System Information type 4 does not contain all information needed for cell |
| 269 | * selection and reselection. */ |
| 270 | if (not cfg.bcch_extended) { |
Harald Welte | 75f761f | 2017-07-16 03:05:31 +0200 | [diff] [blame] | 271 | testcase.stop("Error: SI7/SI8 require BCCH Extd."); |
Harald Welte | af54941 | 2017-07-15 21:33:21 +0200 | [diff] [blame] | 272 | } |
| 273 | if (cfg.si7_present) { |
| 274 | f_ensure_si_vec_contains(si_per_tc, 7, SYSTEM_INFORMATION_TYPE_7, true); |
| 275 | } |
| 276 | if (cfg.si8_present) { |
| 277 | f_ensure_si_vec_contains(si_per_tc, 3, SYSTEM_INFORMATION_TYPE_8, true); |
| 278 | } |
| 279 | } |
| 280 | |
| 281 | if (cfg.si2quater_present) { |
| 282 | /* iii) System information type 2 quater is sent if needed, as determined by the system |
| 283 | * operator. If sent on BCCH Norm, it shall be sent when TC = 5 if neither of 2bis |
| 284 | * and 2ter are used, otherwise it shall be sent at least once within any of 4 |
| 285 | * consecutive occurrences of TC = 4. If sent on BCCH Ext, it is sent at least once |
| 286 | * within any of 4 consecutive occurrences of TC = 5. */ |
| 287 | if (not (cfg.bcch_extended)) { |
| 288 | if (not (cfg.si2bis_present or cfg.si2ter_present)) { |
| 289 | f_ensure_si_vec_contains(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2quater); |
| 290 | } else { |
Harald Welte | 3927677 | 2017-07-16 01:07:42 +0200 | [diff] [blame] | 291 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_2quater, false, 1, 4); |
Harald Welte | af54941 | 2017-07-15 21:33:21 +0200 | [diff] [blame] | 292 | } |
| 293 | } else { |
Harald Welte | 3927677 | 2017-07-16 01:07:42 +0200 | [diff] [blame] | 294 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2quater, true, 1, 4); |
Harald Welte | af54941 | 2017-07-15 21:33:21 +0200 | [diff] [blame] | 295 | } |
| 296 | } |
| 297 | if (cfg.si9_present) { |
| 298 | /* vi) System Information type 9 is sent in those blocks with TC = 4 which are specified |
| 299 | * in system information type 3 as defined in 3GPP TS 44.018. */ |
| 300 | f_ensure_si_vec_contains(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_9); // FIXME SI3 |
| 301 | } |
| 302 | if (cfg.si13_present) { |
| 303 | /* vii) System Information type 13 is only related to the GPRS service. System Information |
| 304 | * Type 13 need only be sent if GPRS support is indicated in one or more of System |
| 305 | * Information Type 3 or 4 or 7 or 8 messages. These messages also indicate if the |
| 306 | * message is sent on the BCCH Norm or if the message is transmitted on the BCCH Ext. |
| 307 | * In the case that the message is sent on the BCCH Norm, it is sent at least once |
| 308 | * within any of 4 consecutive occurrences of TC=4. */ |
| 309 | if (not cfg.bcch_extended) { |
Harald Welte | 3927677 | 2017-07-16 01:07:42 +0200 | [diff] [blame] | 310 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_13, false, 1, 4); |
Harald Welte | af54941 | 2017-07-15 21:33:21 +0200 | [diff] [blame] | 311 | } else { |
| 312 | f_ensure_si_vec_contains(si_per_tc, 0, SYSTEM_INFORMATION_TYPE_13, true); |
| 313 | } |
| 314 | if (f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_13alt)) { |
| 315 | setverdict(fail, "Cannot have SI13alt and SI13"); |
| 316 | } |
| 317 | } |
| 318 | if (cfg.si16_present or cfg.si17_present) { |
| 319 | /* viii) System Information type 16 and 17 are only related to the SoLSA service. They |
| 320 | * should not be sent in a cell where network sharing is used (see rule xv). */ |
| 321 | if (cfg.si22_present) { |
Harald Welte | 75f761f | 2017-07-16 03:05:31 +0200 | [diff] [blame] | 322 | testcase.stop("Error: Cannot have SI16/SI17 and SI22!"); |
Harald Welte | af54941 | 2017-07-15 21:33:21 +0200 | [diff] [blame] | 323 | } |
| 324 | if (f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_22)) { |
| 325 | setverdict(fail, "Cannot have SI16/SI17 and SI22!"); |
| 326 | } |
| 327 | if (not cfg.bcch_extended) { |
Harald Welte | 75f761f | 2017-07-16 03:05:31 +0200 | [diff] [blame] | 328 | testcase.stop("Error: SI16/SI17 requires BCCH Extd!"); |
Harald Welte | af54941 | 2017-07-15 21:33:21 +0200 | [diff] [blame] | 329 | } |
| 330 | if (cfg.si16_present) { |
| 331 | f_ensure_si_vec_contains(si_per_tc, 6, SYSTEM_INFORMATION_TYPE_16, true); |
| 332 | } |
| 333 | if (cfg.si17_present) { |
| 334 | f_ensure_si_vec_contains(si_per_tc, 2, SYSTEM_INFORMATION_TYPE_17, true); |
| 335 | } |
| 336 | } |
| 337 | |
| 338 | /* ix) System Information type 18 and 20 are sent in order to transmit non-GSM |
| 339 | * broadcast information. The frequency with which they are sent is determined by the |
| 340 | * system operator. System Information type 9 identifies the scheduling of System |
| 341 | * Information type 18 and 20 messages. */ |
| 342 | |
| 343 | /* x) System Information Type 19 is sent if COMPACT neighbours exist. If System |
| 344 | * Information Type 19 is present, then its scheduling shall be indicated in System |
| 345 | * Information Type 9. */ |
| 346 | |
| 347 | if (cfg.si15_present) { |
| 348 | /* xi) System Information Type 15 is broadcast if dynamic ARFCN mapping is used in the |
| 349 | * PLMN. If sent on BCCH Norm, it is sent at least once within any of 4 consecutive |
| 350 | * occurrences of TC = 4. If sent on BCCH Ext, it is sent at least once within any of |
| 351 | * 4 consecutive occurrences of TC = 1. */ |
| 352 | if (not cfg.bcch_extended) { |
Harald Welte | 3927677 | 2017-07-16 01:07:42 +0200 | [diff] [blame] | 353 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_15, false, 1, 4); |
Harald Welte | af54941 | 2017-07-15 21:33:21 +0200 | [diff] [blame] | 354 | } else { |
Harald Welte | 3927677 | 2017-07-16 01:07:42 +0200 | [diff] [blame] | 355 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 1, SYSTEM_INFORMATION_TYPE_15, true, 1, 4); |
Harald Welte | af54941 | 2017-07-15 21:33:21 +0200 | [diff] [blame] | 356 | } |
| 357 | } |
| 358 | if (cfg.si13alt_present) { |
| 359 | /* xii) System Information type 13 alt is only related to the GERAN Iu mode. System |
| 360 | * Information Type 13 alt need only be sent if GERAN Iu mode support is indicated in |
| 361 | * one or more of System Information Type 3 or 4 or 7 or 8 messages and SI 13 is not |
| 362 | * broadcast. These messages also indicate if the message is sent on the BCCH Norm or |
| 363 | * if the message is transmitted on the BCCH Ext. In the case that the message is sent |
| 364 | * on the BCCH Norm, it is sent at least once within any of 4 consecutive occurrences |
| 365 | * of TC = 4. */ |
| 366 | if (cfg.si13_present) { |
Harald Welte | 75f761f | 2017-07-16 03:05:31 +0200 | [diff] [blame] | 367 | testcase.stop("Error: Cannot have SI13alt and SI13"); |
Harald Welte | af54941 | 2017-07-15 21:33:21 +0200 | [diff] [blame] | 368 | } |
| 369 | if (f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_13)) { |
| 370 | setverdict(fail, "Cannot have SI13alt and SI13"); |
| 371 | } |
| 372 | if (not cfg.bcch_extended) { |
Harald Welte | 3927677 | 2017-07-16 01:07:42 +0200 | [diff] [blame] | 373 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_13alt, false, 1, 4); |
Harald Welte | af54941 | 2017-07-15 21:33:21 +0200 | [diff] [blame] | 374 | } else { |
| 375 | f_ensure_si_vec_contains(si_per_tc, 0, SYSTEM_INFORMATION_TYPE_13alt, true); |
| 376 | } |
| 377 | } |
| 378 | if (cfg.si2n_present) { |
| 379 | /* xiii) System Information Type 2n is optionally sent on BCCH Norm or BCCH Ext if needed, |
| 380 | * as determined by the system operator. In the case that the message is sent on the |
| 381 | * BCCH Norm, it is sent at least once within any of 4 consecutive occurrences of TC = |
| 382 | * 4. If the message is sent on BCCH Ext, it is sent at least once within any of 2 |
| 383 | * consecutive occurrences of TC = 4. */ |
| 384 | if (not cfg.bcch_extended) { |
Harald Welte | 3927677 | 2017-07-16 01:07:42 +0200 | [diff] [blame] | 385 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_2n, false, 1, 4); |
Harald Welte | af54941 | 2017-07-15 21:33:21 +0200 | [diff] [blame] | 386 | } else { |
Harald Welte | 3927677 | 2017-07-16 01:07:42 +0200 | [diff] [blame] | 387 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_2n, true, 2, 4); |
Harald Welte | af54941 | 2017-07-15 21:33:21 +0200 | [diff] [blame] | 388 | } |
| 389 | } |
| 390 | if (cfg.si21_present) { |
| 391 | /* xiv) System Information Type 21 is optionally sent on BCCH Norm or BCCH Ext, as |
| 392 | * determined by the system operator. If Extended Access Barring is in use in the cell |
| 393 | * then this message is sent at least once within any of 4 consecutive occurrences of |
| 394 | * TC = 4 regardless if it is sent on BCCH Norm or BCCH Ext. If BCCH Ext is used in a |
| 395 | * cell then this message shall only be sent on BCCH Ext. */ |
| 396 | if (not cfg.bcch_extended) { |
Harald Welte | 3927677 | 2017-07-16 01:07:42 +0200 | [diff] [blame] | 397 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_21, false, 1, 4); |
Harald Welte | af54941 | 2017-07-15 21:33:21 +0200 | [diff] [blame] | 398 | } else { |
Harald Welte | 3927677 | 2017-07-16 01:07:42 +0200 | [diff] [blame] | 399 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_21, true, 1, 4); |
Harald Welte | af54941 | 2017-07-15 21:33:21 +0200 | [diff] [blame] | 400 | if (f_si_vecslot_contains(si_per_tc[4], SYSTEM_INFORMATION_TYPE_21)) { |
| 401 | setverdict(fail, "Cannot have SI21 on BCCH Norm if BCCH Extd enabled!"); |
| 402 | } |
| 403 | } |
| 404 | } |
| 405 | if (cfg.si22_present) { |
| 406 | /* xv) System Information Type 22 is sent if network sharing is in use in the cell. It |
| 407 | * should not be sent in a cell where SoLSA is used (see rule viii). System |
| 408 | * Information Type 22 instances shall be sent on BCCH Ext within any occurrence of TC |
| 409 | * =2 and TC=6. */ |
| 410 | if (cfg.si16_present or cfg.si17_present) { |
Harald Welte | 75f761f | 2017-07-16 03:05:31 +0200 | [diff] [blame] | 411 | testcase.stop("Error: Cannot have SI16/SI17 and SI22!"); |
Harald Welte | af54941 | 2017-07-15 21:33:21 +0200 | [diff] [blame] | 412 | } |
| 413 | if (f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_16) or |
| 414 | f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_17)) { |
| 415 | setverdict(fail, "Cannot have SI16/SI17 and SI22!"); |
| 416 | } |
| 417 | if (not cfg.bcch_extended) { |
Harald Welte | 75f761f | 2017-07-16 03:05:31 +0200 | [diff] [blame] | 418 | testcase.stop("Error: SI22 requires BCCH Extd!"); |
Harald Welte | 3927677 | 2017-07-16 01:07:42 +0200 | [diff] [blame] | 419 | } else { |
| 420 | f_ensure_si_vec_contains_only(si_per_tc, 2, SYSTEM_INFORMATION_TYPE_22, true); |
| 421 | f_ensure_si_vec_contains_only(si_per_tc, 6, SYSTEM_INFORMATION_TYPE_22, true); |
Harald Welte | af54941 | 2017-07-15 21:33:21 +0200 | [diff] [blame] | 422 | } |
| 423 | } |
| 424 | } |
| 425 | |
| 426 | |
Harald Welte | 3927677 | 2017-07-16 01:07:42 +0200 | [diff] [blame] | 427 | function f_gsmtap_sample_si(GSMTAP_PT pt, float duration := 8.0) return SystemInformationVectorPerTc { |
Harald Welte | af54941 | 2017-07-15 21:33:21 +0200 | [diff] [blame] | 428 | timer T := duration; |
| 429 | var SystemInformationVectorPerTc si_per_tc; |
| 430 | var GSMTAP_RecvFrom rf; |
| 431 | |
| 432 | /* initialize all per-TC vectors empty */ |
| 433 | for (var integer i := 0; i < sizeof(si_per_tc); i := i + 1) { |
| 434 | si_per_tc[i] := {}; |
| 435 | } |
| 436 | |
Harald Welte | bdc5dbd | 2017-07-16 00:00:43 +0200 | [diff] [blame] | 437 | /* flush all previous/buffered elements */ |
| 438 | pt.clear |
| 439 | |
Harald Welte | af54941 | 2017-07-15 21:33:21 +0200 | [diff] [blame] | 440 | T.start; |
| 441 | alt { |
| 442 | [] pt.receive(t_recvfrom(GSMTAP_CHANNEL_BCCH)) -> value rf { |
| 443 | var SystemInformation si := dec_SystemInformation(rf.msg.payload); |
| 444 | var SystemInformationGsmtap sig := { rf.msg.header, si }; |
| 445 | var integer tc := f_gsm_compute_tc(rf.msg.header.frame_number); |
| 446 | log("SI received at TC=", tc, ": ", si); |
| 447 | /* append to the per-TC bucket */ |
| 448 | si_per_tc[tc] := si_per_tc[tc] & { sig }; |
| 449 | repeat; |
| 450 | } |
| 451 | [] pt.receive { repeat; }; |
| 452 | [] T.timeout { }; |
| 453 | } |
Harald Welte | 3927677 | 2017-07-16 01:07:42 +0200 | [diff] [blame] | 454 | for (var integer i := 0; i < sizeof(si_per_tc); i := i + 1) { |
| 455 | log(testcasename(), ": TC=", i, " has #of SI=", sizeof(si_per_tc[i])); |
| 456 | } |
Harald Welte | af54941 | 2017-07-15 21:33:21 +0200 | [diff] [blame] | 457 | return si_per_tc; |
| 458 | } |
| 459 | |
Harald Welte | f0a4997 | 2017-07-16 03:55:20 +0200 | [diff] [blame] | 460 | function f_gsmtap_get_si(GSMTAP_PT pt, RrMessageType msg_type) return SystemInformation { |
| 461 | timer T := 10.0; |
| 462 | var GSMTAP_RecvFrom rf; |
| 463 | var SystemInformation si; |
| 464 | |
| 465 | /* flush all previous/buffered elements */ |
| 466 | pt.clear |
| 467 | |
| 468 | T.start; |
| 469 | alt { |
| 470 | [] pt.receive(t_recvfrom(GSMTAP_CHANNEL_BCCH)) -> value rf { |
| 471 | si := dec_SystemInformation(rf.msg.payload); |
| 472 | if (si.header.message_type == msg_type) { |
| 473 | return si; |
| 474 | } |
| 475 | repeat; |
| 476 | } |
| 477 | [] pt.receive { repeat; }; |
| 478 | [] T.timeout { testcase.stop("Error waiting for SI on GSMTAP"); }; |
| 479 | } |
| 480 | return si; |
| 481 | } |
| 482 | |
| 483 | function f_gsmtap_match_si(GSMTAP_PT pt, RrMessageType msg_type, template SystemInformation t) { |
| 484 | var SystemInformation si := f_gsmtap_get_si(pt, msg_type); |
| 485 | if (not match(si, t)) { |
| 486 | setverdict(fail, "SI ", si, " doesn't match ", t); |
| 487 | } else { |
| 488 | setverdict(pass); |
| 489 | } |
| 490 | } |
| 491 | |
Harald Welte | bdc5dbd | 2017-07-16 00:00:43 +0200 | [diff] [blame] | 492 | function f_init() runs on dummy_CT { |
| 493 | if (initialized) { |
| 494 | return; |
| 495 | } |
| 496 | /* GSMTAP initialization */ |
Harald Welte | b622a3d | 2017-07-14 22:26:33 +0200 | [diff] [blame] | 497 | map(self:GSMTAP, system:GSMTAP); |
| 498 | IPL4_GSMTAP_CtrlFunct.f_IPL4_listen(GSMTAP, "0.0.0.0", GSMTAP_PORT, {udp := {}}); |
| 499 | |
Harald Welte | bdc5dbd | 2017-07-16 00:00:43 +0200 | [diff] [blame] | 500 | /* VTY initialization */ |
| 501 | map(self:BSCVTY, system:BSCVTY); |
| 502 | f_vty_set_prompts(BSCVTY) |
Harald Welte | fd512cb | 2017-07-16 01:34:15 +0200 | [diff] [blame] | 503 | f_vty_transceive(BSCVTY, "enable"); |
Harald Welte | bdc5dbd | 2017-07-16 00:00:43 +0200 | [diff] [blame] | 504 | |
| 505 | initialized := true; |
| 506 | } |
| 507 | |
| 508 | testcase TC_si_default() runs on dummy_CT { |
| 509 | var SystemInformationVectorPerTc si_per_tc; |
| 510 | |
| 511 | f_init(); |
| 512 | |
Harald Welte | af54941 | 2017-07-15 21:33:21 +0200 | [diff] [blame] | 513 | si_per_tc := f_gsmtap_sample_si(GSMTAP); |
Harald Welte | af54941 | 2017-07-15 21:33:21 +0200 | [diff] [blame] | 514 | f_validate_si_scheduling(si_cfg, si_per_tc); |
Harald Welte | bdc5dbd | 2017-07-16 00:00:43 +0200 | [diff] [blame] | 515 | |
Harald Welte | af54941 | 2017-07-15 21:33:21 +0200 | [diff] [blame] | 516 | setverdict(pass); |
Harald Welte | b622a3d | 2017-07-14 22:26:33 +0200 | [diff] [blame] | 517 | } |
| 518 | |
Harald Welte | bdc5dbd | 2017-07-16 00:00:43 +0200 | [diff] [blame] | 519 | testcase TC_si_sched_2bis() runs on dummy_CT { |
| 520 | var SystemInformationVectorPerTc si_per_tc; |
| 521 | f_init(); |
| 522 | |
| 523 | /* Enable SI2bis + validate scheduling */ |
Harald Welte | bdc5dbd | 2017-07-16 00:00:43 +0200 | [diff] [blame] | 524 | si_cfg.si2bis_present := true; |
Harald Welte | fe1052d | 2017-07-16 01:24:01 +0200 | [diff] [blame] | 525 | f_si_cfg_to_vty(); |
Harald Welte | bdc5dbd | 2017-07-16 00:00:43 +0200 | [diff] [blame] | 526 | si_per_tc := f_gsmtap_sample_si(GSMTAP); |
| 527 | f_validate_si_scheduling(si_cfg, si_per_tc); |
| 528 | |
| 529 | /* cleanup */ |
Harald Welte | bdc5dbd | 2017-07-16 00:00:43 +0200 | [diff] [blame] | 530 | si_cfg.si2bis_present := false; |
Harald Welte | fe1052d | 2017-07-16 01:24:01 +0200 | [diff] [blame] | 531 | f_si_cfg_to_vty(); |
Harald Welte | bdc5dbd | 2017-07-16 00:00:43 +0200 | [diff] [blame] | 532 | |
| 533 | setverdict(pass); |
| 534 | } |
| 535 | |
| 536 | testcase TC_si_sched_2ter() runs on dummy_CT { |
| 537 | var SystemInformationVectorPerTc si_per_tc; |
| 538 | f_init(); |
| 539 | |
| 540 | /* Enable SI2ter + validate scheduling */ |
Harald Welte | bdc5dbd | 2017-07-16 00:00:43 +0200 | [diff] [blame] | 541 | si_cfg.si2ter_present := true; |
Harald Welte | fe1052d | 2017-07-16 01:24:01 +0200 | [diff] [blame] | 542 | f_si_cfg_to_vty(); |
Harald Welte | bdc5dbd | 2017-07-16 00:00:43 +0200 | [diff] [blame] | 543 | si_per_tc := f_gsmtap_sample_si(GSMTAP); |
| 544 | f_validate_si_scheduling(si_cfg, si_per_tc); |
| 545 | |
| 546 | /* cleanup */ |
Harald Welte | bdc5dbd | 2017-07-16 00:00:43 +0200 | [diff] [blame] | 547 | si_cfg.si2ter_present := false; |
Harald Welte | fe1052d | 2017-07-16 01:24:01 +0200 | [diff] [blame] | 548 | f_si_cfg_to_vty(); |
Harald Welte | bdc5dbd | 2017-07-16 00:00:43 +0200 | [diff] [blame] | 549 | |
| 550 | setverdict(pass); |
| 551 | } |
| 552 | |
| 553 | testcase TC_si_sched_2ter_2bis() runs on dummy_CT { |
| 554 | var SystemInformationVectorPerTc si_per_tc; |
| 555 | f_init(); |
| 556 | |
| 557 | /* Enable SI2bis + SI2ter + validate scheduling */ |
Harald Welte | bdc5dbd | 2017-07-16 00:00:43 +0200 | [diff] [blame] | 558 | si_cfg.si2bis_present := true; |
| 559 | si_cfg.si2ter_present := true; |
Harald Welte | fe1052d | 2017-07-16 01:24:01 +0200 | [diff] [blame] | 560 | f_si_cfg_to_vty(); |
Harald Welte | bdc5dbd | 2017-07-16 00:00:43 +0200 | [diff] [blame] | 561 | si_per_tc := f_gsmtap_sample_si(GSMTAP); |
| 562 | f_validate_si_scheduling(si_cfg, si_per_tc); |
| 563 | |
| 564 | /* cleanup */ |
Harald Welte | bdc5dbd | 2017-07-16 00:00:43 +0200 | [diff] [blame] | 565 | si_cfg.si2bis_present := false; |
| 566 | si_cfg.si2ter_present := false; |
Harald Welte | fe1052d | 2017-07-16 01:24:01 +0200 | [diff] [blame] | 567 | f_si_cfg_to_vty(); |
Harald Welte | bdc5dbd | 2017-07-16 00:00:43 +0200 | [diff] [blame] | 568 | |
| 569 | setverdict(pass); |
| 570 | } |
| 571 | |
| 572 | testcase TC_si_sched_2quater() runs on dummy_CT { |
| 573 | var SystemInformationVectorPerTc si_per_tc; |
| 574 | f_init(); |
| 575 | |
| 576 | /* Enable SI2quater + validate scheduling */ |
Harald Welte | bdc5dbd | 2017-07-16 00:00:43 +0200 | [diff] [blame] | 577 | si_cfg.si2quater_present := true; |
Harald Welte | fe1052d | 2017-07-16 01:24:01 +0200 | [diff] [blame] | 578 | f_si_cfg_to_vty(); |
Harald Welte | bdc5dbd | 2017-07-16 00:00:43 +0200 | [diff] [blame] | 579 | |
| 580 | /* cleanup */ |
Harald Welte | bdc5dbd | 2017-07-16 00:00:43 +0200 | [diff] [blame] | 581 | si_cfg.si2quater_present := false; |
Harald Welte | fe1052d | 2017-07-16 01:24:01 +0200 | [diff] [blame] | 582 | f_si_cfg_to_vty(); |
Harald Welte | bdc5dbd | 2017-07-16 00:00:43 +0200 | [diff] [blame] | 583 | |
| 584 | setverdict(pass); |
| 585 | } |
| 586 | |
| 587 | testcase TC_si_sched_13() runs on dummy_CT { |
| 588 | var SystemInformationVectorPerTc si_per_tc; |
| 589 | f_init(); |
| 590 | |
| 591 | /* Enable SI2ter + validate scheduling */ |
Harald Welte | bdc5dbd | 2017-07-16 00:00:43 +0200 | [diff] [blame] | 592 | si_cfg.si13_present := true; |
Harald Welte | fe1052d | 2017-07-16 01:24:01 +0200 | [diff] [blame] | 593 | f_si_cfg_to_vty(); |
Harald Welte | bdc5dbd | 2017-07-16 00:00:43 +0200 | [diff] [blame] | 594 | si_per_tc := f_gsmtap_sample_si(GSMTAP); |
| 595 | f_validate_si_scheduling(si_cfg, si_per_tc); |
| 596 | |
| 597 | /* cleanup */ |
Harald Welte | bdc5dbd | 2017-07-16 00:00:43 +0200 | [diff] [blame] | 598 | si_cfg.si13_present := false; |
Harald Welte | fe1052d | 2017-07-16 01:24:01 +0200 | [diff] [blame] | 599 | f_si_cfg_to_vty(); |
Harald Welte | bdc5dbd | 2017-07-16 00:00:43 +0200 | [diff] [blame] | 600 | |
| 601 | setverdict(pass); |
| 602 | } |
Harald Welte | 9a907b3 | 2017-07-15 10:34:27 +0200 | [diff] [blame] | 603 | |
Harald Welte | fe1052d | 2017-07-16 01:24:01 +0200 | [diff] [blame] | 604 | testcase TC_si_sched_13_2bis_2ter_2quater() runs on dummy_CT { |
| 605 | var SystemInformationVectorPerTc si_per_tc; |
| 606 | f_init(); |
| 607 | |
| 608 | si_cfg.si2bis_present := true; |
| 609 | si_cfg.si2ter_present := true; |
| 610 | si_cfg.si2quater_present := true; |
| 611 | si_cfg.si13_present := true; |
| 612 | f_si_cfg_to_vty(); |
| 613 | si_per_tc := f_gsmtap_sample_si(GSMTAP); |
| 614 | f_validate_si_scheduling(si_cfg, si_per_tc); |
| 615 | |
| 616 | /* cleanup */ |
| 617 | si_cfg.si2bis_present := false; |
| 618 | si_cfg.si2ter_present := false; |
| 619 | si_cfg.si2quater_present := false; |
| 620 | si_cfg.si13_present := false; |
| 621 | f_si_cfg_to_vty(); |
| 622 | |
| 623 | setverdict(pass); |
| 624 | } |
| 625 | |
| 626 | function f_si_cfg_to_vty() runs on dummy_CT { |
| 627 | if (si_cfg.si2bis_present) { |
| 628 | f_vty_si_static(BSCVTY, 0, "2bis", c_si2bis); |
| 629 | } else { |
| 630 | f_vty_si_computed(BSCVTY, 0, "2bis"); |
| 631 | } |
| 632 | if (si_cfg.si2ter_present) { |
| 633 | f_vty_si_static(BSCVTY, 0, "2ter", c_si2ter); |
| 634 | } else { |
| 635 | f_vty_si_computed(BSCVTY, 0, "2ter"); |
| 636 | } |
| 637 | if (si_cfg.si13_present) { |
| 638 | f_vty_gprs_mode(BSCVTY, 0, "gprs"); |
| 639 | } else { |
| 640 | f_vty_gprs_mode(BSCVTY, 0, "none"); |
| 641 | } |
| 642 | if (si_cfg.si2quater_present) { |
| 643 | f_vty_si2q_add_uarfcn(BSCVTY, 0, 23, 42); |
| 644 | } else { |
| 645 | f_vty_si2q_del_uarfcn(BSCVTY, 0, 23, 42); |
| 646 | } |
| 647 | /* for debugging */ |
| 648 | f_vty_transceive(BSCVTY, "write terminal"); |
| 649 | /* actually commit the changes from BSC -> BTS */ |
| 650 | f_vty_si_resend(BSCVTY, 0); |
| 651 | } |
Harald Welte | 9a907b3 | 2017-07-15 10:34:27 +0200 | [diff] [blame] | 652 | |
Harald Welte | bdc5dbd | 2017-07-16 00:00:43 +0200 | [diff] [blame] | 653 | function f_vty_si_static(TELNETasp_PT pt, BtsNr bts, charstring si, octetstring bytes) { |
| 654 | f_vty_enter_cfg_bts(pt, bts); |
| 655 | f_vty_transceive(pt, "system-information " & si & " mode static"); |
| 656 | f_vty_transceive(pt, "system-information " & si & " static " & hex2str(oct2hex(bytes))); |
| 657 | f_vty_transceive(pt, "end"); |
| 658 | } |
| 659 | |
| 660 | function f_vty_si_computed(TELNETasp_PT pt, BtsNr bts, charstring si) { |
| 661 | f_vty_enter_cfg_bts(pt, bts); |
| 662 | f_vty_transceive(pt, "system-information " & si & " mode computed"); |
| 663 | f_vty_transceive(pt, "end"); |
| 664 | } |
| 665 | |
| 666 | function f_vty_si_resend(TELNETasp_PT pt, BtsNr bts := 0) { |
| 667 | f_vty_transceive(pt, "bts " & int2str(bts) & " resend-system-information"); |
Harald Welte | c17c88e | 2017-07-16 00:39:59 +0200 | [diff] [blame] | 668 | /* wait for 1s until changes propagate */ |
| 669 | timer T := 1.0; |
Harald Welte | bdc5dbd | 2017-07-16 00:00:43 +0200 | [diff] [blame] | 670 | T.start; |
| 671 | T.timeout; |
| 672 | } |
| 673 | |
| 674 | function f_vty_gprs_mode(TELNETasp_PT pt, integer bts, BtsGprsMode mode) { |
| 675 | f_vty_enter_cfg_bts(pt, bts); |
| 676 | f_vty_transceive(pt, "gprs mode " & mode); |
| 677 | f_vty_transceive(pt, "end"); |
| 678 | } |
| 679 | |
| 680 | function f_vty_si2q_add_uarfcn(TELNETasp_PT pt, BtsNr bts, UmtsArfcn uarfcn, UmtsScramblingCode sc, integer diversity := 0) { |
| 681 | f_vty_enter_cfg_bts(pt, bts); |
| 682 | f_vty_transceive(pt, "si2quater neighbor-list add uarfcn " & int2str(uarfcn) & " " & int2str(sc) & " " & int2str(diversity)); |
| 683 | f_vty_transceive(pt, "end"); |
| 684 | } |
| 685 | |
| 686 | function f_vty_si2q_del_uarfcn(TELNETasp_PT pt, BtsNr bts, UmtsArfcn uarfcn, UmtsScramblingCode sc) { |
| 687 | f_vty_enter_cfg_bts(pt, bts); |
| 688 | f_vty_transceive(pt, "si2quater neighbor-list del uarfcn " & int2str(uarfcn) & " " & int2str(sc)); |
| 689 | f_vty_transceive(pt, "end"); |
| 690 | } |
| 691 | |
| 692 | testcase TC_telnet() runs on dummy_CT { |
| 693 | f_init(); |
Harald Welte | fd512cb | 2017-07-16 01:34:15 +0200 | [diff] [blame] | 694 | f_vty_enter_config(BSCVTY); |
Harald Welte | 9a907b3 | 2017-07-15 10:34:27 +0200 | [diff] [blame] | 695 | f_vty_transceive(BSCVTY, "show network") |
Harald Welte | 9a907b3 | 2017-07-15 10:34:27 +0200 | [diff] [blame] | 696 | f_vty_transceive(BSCVTY, "network") |
| 697 | f_vty_transceive(BSCVTY, "bts 0") |
Harald Welte | bdc5dbd | 2017-07-16 00:00:43 +0200 | [diff] [blame] | 698 | f_vty_transceive(BSCVTY, "end") |
| 699 | setverdict(pass); |
Harald Welte | 9a907b3 | 2017-07-15 10:34:27 +0200 | [diff] [blame] | 700 | } |
| 701 | |
Harald Welte | f0a4997 | 2017-07-16 03:55:20 +0200 | [diff] [blame] | 702 | template SystemInformation t_SI_SI3 := { |
Harald Welte | d2e342f | 2017-07-16 07:34:13 +0200 | [diff] [blame] | 703 | header := t_RrHeader(SYSTEM_INFORMATION_TYPE_3, ?), |
Harald Welte | f0a4997 | 2017-07-16 03:55:20 +0200 | [diff] [blame] | 704 | payload := { si3 := t_SI3 } |
| 705 | } |
| 706 | |
| 707 | testcase TC_cellid() runs on dummy_CT { |
| 708 | var CellIdentity cid := float2int(rnd() * 65535.0); |
| 709 | var template SystemInformation t := t_SI_SI3; |
| 710 | t.payload.si3.cell_id := cid; |
| 711 | |
| 712 | f_init(); |
| 713 | f_vty_enter_cfg_bts(BSCVTY, 0); |
| 714 | f_vty_transceive(BSCVTY, "cell_identity " & int2str(cid)); |
| 715 | f_vty_transceive(BSCVTY, "end") |
| 716 | f_vty_si_resend(BSCVTY, 0); |
| 717 | |
| 718 | f_gsmtap_match_si(GSMTAP, SYSTEM_INFORMATION_TYPE_3, t); |
| 719 | } |
| 720 | |
| 721 | testcase TC_lac() runs on dummy_CT { |
| 722 | var uint16_t lac := float2int(rnd() * 65535.0); |
| 723 | |
| 724 | var template SystemInformation t := t_SI_SI3; |
| 725 | t.payload.si3.lai.lac := lac; |
| 726 | |
| 727 | f_init(); |
| 728 | f_vty_enter_cfg_bts(BSCVTY, 0); |
| 729 | f_vty_transceive(BSCVTY, "location_area_code " & int2str(lac)); |
| 730 | f_vty_transceive(BSCVTY, "end") |
| 731 | f_vty_si_resend(BSCVTY, 0); |
| 732 | |
| 733 | f_gsmtap_match_si(GSMTAP, SYSTEM_INFORMATION_TYPE_3, t); |
| 734 | } |
| 735 | |
| 736 | testcase TC_rach_tx_int() runs on dummy_CT { |
| 737 | var uint16_t rach_tx_int := float2int(rnd() * 15.0); |
| 738 | |
| 739 | var template SystemInformation t := t_SI_SI3; |
| 740 | t.payload.si3.rach_control.tx_integer := int2bit(rach_tx_int, 4); |
| 741 | |
| 742 | f_init(); |
| 743 | f_vty_enter_cfg_bts(BSCVTY, 0); |
| 744 | f_vty_transceive(BSCVTY, "rach tx integer " & int2str(rach_tx_int)); |
| 745 | f_vty_transceive(BSCVTY, "end") |
| 746 | f_vty_si_resend(BSCVTY, 0); |
| 747 | |
| 748 | f_gsmtap_match_si(GSMTAP, SYSTEM_INFORMATION_TYPE_3, t); |
| 749 | } |
| 750 | |
| 751 | testcase TC_rach_max_tx() runs on dummy_CT { |
| 752 | var uint16_t r := float2int(rnd() * 3.0); |
| 753 | const integer max_tx_map[4] := { 1, 2, 4, 7 }; |
| 754 | var template SystemInformation t := t_SI_SI3; |
| 755 | t.payload.si3.rach_control.max_retrans := int2bit(r, 2); |
| 756 | |
| 757 | f_init(); |
| 758 | f_vty_enter_cfg_bts(BSCVTY, 0); |
| 759 | f_vty_transceive(BSCVTY, "rach max transmission " & int2str(max_tx_map[r])); |
| 760 | f_vty_transceive(BSCVTY, "end") |
| 761 | f_vty_si_resend(BSCVTY, 0); |
| 762 | |
| 763 | f_gsmtap_match_si(GSMTAP, SYSTEM_INFORMATION_TYPE_3, t); |
| 764 | } |
| 765 | |
| 766 | testcase TC_dtx_ul() runs on dummy_CT { |
| 767 | var integer i := float2int(rnd() * 2.0); |
| 768 | var template SystemInformation t := t_SI_SI3; |
| 769 | t.payload.si3.cell_options.dtx := int2bit(i, 2); |
| 770 | |
| 771 | f_init(); |
| 772 | f_vty_enter_cfg_bts(BSCVTY, 0); |
| 773 | if (i == 0) { |
| 774 | f_vty_transceive(BSCVTY, "dtx uplink"); |
| 775 | } else if (i == 1) { |
| 776 | f_vty_transceive(BSCVTY, "dtx uplink force"); |
| 777 | } else { |
| 778 | f_vty_transceive(BSCVTY, "no dtx uplink"); |
| 779 | } |
| 780 | |
| 781 | f_gsmtap_match_si(GSMTAP, SYSTEM_INFORMATION_TYPE_3, t); |
| 782 | } |
| 783 | |
| 784 | testcase TC_attach() runs on dummy_CT { |
| 785 | var integer i := float2int(rnd()); |
| 786 | var template SystemInformation t := t_SI_SI3; |
| 787 | t.payload.si3.ctrl_chan_desc.att := int2bool(i); |
| 788 | |
| 789 | f_init(); |
| 790 | f_vty_enter_cfg_bts(BSCVTY, 0); |
| 791 | f_vty_transceive(BSCVTY, "channel-descrption attach " & int2str(i)); |
| 792 | f_vty_transceive(BSCVTY, "end") |
| 793 | f_vty_si_resend(BSCVTY, 0); |
| 794 | |
| 795 | f_gsmtap_match_si(GSMTAP, SYSTEM_INFORMATION_TYPE_3, t); |
| 796 | } |
| 797 | |
| 798 | testcase TC_bs_pa_mfrms() runs on dummy_CT { |
| 799 | var integer i := 2 + float2int(rnd() * 7.0); |
| 800 | var template SystemInformation t := t_SI_SI3; |
| 801 | t.payload.si3.ctrl_chan_desc.bs_pa_mfrms := i - 2; |
| 802 | |
| 803 | f_init(); |
| 804 | f_vty_enter_cfg_bts(BSCVTY, 0); |
| 805 | f_vty_transceive(BSCVTY, "channel-descrption bs-pa-mfrms " & int2str(i)); |
| 806 | f_vty_transceive(BSCVTY, "end") |
| 807 | f_vty_si_resend(BSCVTY, 0); |
| 808 | |
| 809 | f_gsmtap_match_si(GSMTAP, SYSTEM_INFORMATION_TYPE_3, t); |
| 810 | } |
| 811 | |
| 812 | testcase TC_bs_ag_blks_res() runs on dummy_CT { |
| 813 | var integer i := float2int(rnd() * 7.0); |
| 814 | var template SystemInformation t := t_SI_SI3; |
| 815 | t.payload.si3.ctrl_chan_desc.bs_ag_blks_res := i; |
| 816 | |
| 817 | f_init(); |
| 818 | f_vty_enter_cfg_bts(BSCVTY, 0); |
| 819 | f_vty_transceive(BSCVTY, "channel-descrption bs-ag-blks-res " & int2str(i)); |
| 820 | f_vty_transceive(BSCVTY, "end") |
| 821 | f_vty_si_resend(BSCVTY, 0); |
| 822 | |
| 823 | f_gsmtap_match_si(GSMTAP, SYSTEM_INFORMATION_TYPE_3, t); |
| 824 | } |
| 825 | |
| 826 | testcase TC_radio_link_timeout() runs on dummy_CT { |
| 827 | var integer i := float2int(rnd() * 15.0); |
| 828 | var template SystemInformation t := t_SI_SI3; |
| 829 | t.payload.si3.cell_options.radio_link_timeout := int2bit(i, 4); |
| 830 | |
| 831 | f_init(); |
| 832 | f_vty_enter_cfg_bts(BSCVTY, 0); |
| 833 | f_vty_transceive(BSCVTY, "radio-link-timeout " & int2str(4 + i*4)); |
| 834 | f_vty_transceive(BSCVTY, "end") |
| 835 | f_vty_si_resend(BSCVTY, 0); |
| 836 | |
| 837 | f_gsmtap_match_si(GSMTAP, SYSTEM_INFORMATION_TYPE_3, t); |
| 838 | } |
| 839 | |
| 840 | testcase TC_cell_resel_hyst() runs on dummy_CT { |
| 841 | var integer i := float2int(rnd() * 7.0); |
| 842 | var template SystemInformation t := t_SI_SI3; |
| 843 | t.payload.si3.cell_sel_par.cell_resel_hyst := i; |
| 844 | |
| 845 | f_init(); |
| 846 | f_vty_enter_cfg_bts(BSCVTY, 0); |
| 847 | f_vty_transceive(BSCVTY, "cell reselection hysteresis " & int2str(i*2)); |
| 848 | f_vty_transceive(BSCVTY, "end") |
| 849 | f_vty_si_resend(BSCVTY, 0); |
| 850 | |
| 851 | f_gsmtap_match_si(GSMTAP, SYSTEM_INFORMATION_TYPE_3, t); |
| 852 | } |
| 853 | |
| 854 | testcase TC_rxlev_acc_min() runs on dummy_CT { |
| 855 | var integer i := float2int(rnd() * 63.0); |
| 856 | var template SystemInformation t := t_SI_SI3; |
| 857 | t.payload.si3.cell_sel_par.rxlev_access_min := i; |
| 858 | |
| 859 | f_init(); |
| 860 | f_vty_enter_cfg_bts(BSCVTY, 0); |
| 861 | f_vty_transceive(BSCVTY, "rxlev access min " & int2str(i)); |
| 862 | f_vty_transceive(BSCVTY, "end") |
| 863 | f_vty_si_resend(BSCVTY, 0); |
| 864 | |
| 865 | f_gsmtap_match_si(GSMTAP, SYSTEM_INFORMATION_TYPE_3, t); |
| 866 | } |
| 867 | |
| 868 | testcase TC_neci() runs on dummy_CT { |
| 869 | var integer i := float2int(rnd() * 1.0); |
| 870 | var template SystemInformation t := t_SI_SI3; |
| 871 | t.payload.si3.cell_sel_par.neci := int2bool(i); |
| 872 | |
| 873 | f_init(); |
| 874 | f_vty_enter_cfg_network(BSCVTY); |
| 875 | f_vty_transceive(BSCVTY, "neci " & int2str(i)); |
| 876 | f_vty_transceive(BSCVTY, "end") |
| 877 | f_vty_si_resend(BSCVTY, 0); |
| 878 | |
| 879 | f_gsmtap_match_si(GSMTAP, SYSTEM_INFORMATION_TYPE_3, t); |
| 880 | } |
| 881 | |
| 882 | testcase TC_emerg_allowed() runs on dummy_CT { |
| 883 | var integer i := float2int(rnd()); |
| 884 | var template SystemInformation t := t_SI_SI3; |
| 885 | if (i == 1) { |
| 886 | t.payload.si3.rach_control.ac := '?????0??????????'B; |
| 887 | } else { |
| 888 | t.payload.si3.rach_control.ac := '?????1??????????'B; |
| 889 | } |
| 890 | |
| 891 | f_init(); |
| 892 | f_vty_enter_cfg_bts(BSCVTY, 0); |
| 893 | f_vty_transceive(BSCVTY, "rach emergency call allowed " & int2str(i)); |
| 894 | f_vty_transceive(BSCVTY, "end") |
| 895 | f_vty_si_resend(BSCVTY, 0); |
| 896 | |
| 897 | f_gsmtap_match_si(GSMTAP, SYSTEM_INFORMATION_TYPE_3, t); |
| 898 | } |
| 899 | |
| 900 | /* TODO: |
| 901 | * * don't only validate SI3 but check all other SI with same IE? |
| 902 | * * parse + validate rest octets somehow |
| 903 | * * validate contents/encoding of neighbor channel lists |
| 904 | * * validate si2quater sub-mux scheduling |
| 905 | */ |
| 906 | |
| 907 | |
Harald Welte | 56db5fd | 2017-07-14 18:25:59 +0200 | [diff] [blame] | 908 | control { |
| 909 | execute(TC_si1()); |
Harald Welte | 9a907b3 | 2017-07-15 10:34:27 +0200 | [diff] [blame] | 910 | execute(TC_telnet()); |
Harald Welte | bdc5dbd | 2017-07-16 00:00:43 +0200 | [diff] [blame] | 911 | execute(TC_si_default()); |
| 912 | execute(TC_si_sched_2bis()); |
| 913 | execute(TC_si_sched_2ter()); |
| 914 | execute(TC_si_sched_2ter_2bis()); |
| 915 | execute(TC_si_sched_2quater()); |
| 916 | execute(TC_si_sched_13()); |
Harald Welte | fe1052d | 2017-07-16 01:24:01 +0200 | [diff] [blame] | 917 | execute(TC_si_sched_13_2bis_2ter_2quater()); |
Harald Welte | f0a4997 | 2017-07-16 03:55:20 +0200 | [diff] [blame] | 918 | execute(TC_neci()); |
| 919 | execute(TC_cell_resel_hyst()); |
| 920 | execute(TC_rxlev_acc_min()); |
| 921 | execute(TC_cellid()); |
| 922 | execute(TC_lac()); |
| 923 | execute(TC_rach_tx_int()); |
| 924 | execute(TC_rach_max_tx()); |
| 925 | execute(TC_attach()); |
| 926 | execute(TC_dtx_ul()); |
| 927 | execute(TC_emerg_allowed()); |
| 928 | execute(TC_bs_pa_mfrms()); |
| 929 | execute(TC_bs_ag_blks_res()); |
| 930 | execute(TC_radio_link_timeout()); |
Harald Welte | 56db5fd | 2017-07-14 18:25:59 +0200 | [diff] [blame] | 931 | } |
| 932 | } |