Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1 | module BTS_Tests { |
| 2 | |
| 3 | import from General_Types all; |
| 4 | import from GSM_Types all; |
| 5 | import from GSM_RR_Types all; |
| 6 | import from Osmocom_Types all; |
| 7 | import from GSM_Types all; |
| 8 | import from GSM_RR_Types all; |
Harald Welte | 82ccef7 | 2018-02-25 16:17:33 +0100 | [diff] [blame] | 9 | import from GSM_SystemInformation all; |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 10 | import from L1CTL_PortType all; |
| 11 | import from L1CTL_Types all; |
| 12 | import from LAPDm_Types all; |
| 13 | import from Osmocom_CTRL_Adapter all; |
| 14 | |
| 15 | import from RSL_Types all; |
Harald Welte | 7484fc4 | 2018-02-24 14:09:45 +0100 | [diff] [blame] | 16 | import from IPA_Types all; |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 17 | import from IPA_Emulation all; |
| 18 | import from RSL_Emulation all; |
| 19 | |
| 20 | import from IPL4asp_Types all; |
| 21 | import from TRXC_Types all; |
| 22 | import from TRXC_CodecPort all; |
| 23 | import from TRXC_CodecPort_CtrlFunct all; |
| 24 | |
Harald Welte | 7484fc4 | 2018-02-24 14:09:45 +0100 | [diff] [blame] | 25 | import from MobileL3_CommonIE_Types all; |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 26 | import from MobileL3_RRM_Types all; |
| 27 | import from MobileL3_Types all; |
| 28 | import from L3_Templates all; |
Harald Welte | 7484fc4 | 2018-02-24 14:09:45 +0100 | [diff] [blame] | 29 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 30 | /* The tests assume a BTS with the following timeslot configuration: |
| 31 | * TS0 : Combined CCCH + SDCCH/4 |
| 32 | * TS1 .. TS 4: TCH/F |
| 33 | * TS5 : TCH/H |
| 34 | * TS6 : SDCCH/8 |
| 35 | * TS7 : PDCH |
| 36 | */ |
| 37 | |
| 38 | modulepar { |
| 39 | charstring mp_rsl_ip := "127.0.0.2"; |
| 40 | integer mp_rsl_port := 3003; |
| 41 | integer mp_trx0_arfcn := 871; |
| 42 | integer mp_bb_trxc_port := 5704; |
| 43 | } |
| 44 | |
| 45 | type component test_CT extends CTRL_Adapter_CT { |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 46 | /* IPA Emulation component underneath RSL */ |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 47 | var IPA_Emulation_CT vc_IPA; |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 48 | /* RSL Emulation component (for ConnHdlr tests) */ |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 49 | var RSL_Emulation_CT vc_RSL; |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 50 | /* Direct RSL_CCHAN_PT */ |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 51 | port RSL_CCHAN_PT RSL_CCHAN; |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 52 | |
| 53 | /* L1CTL port (for classic tests) */ |
| 54 | port L1CTL_PT L1CTL; |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 55 | |
Harald Welte | 54a2a2d | 2018-02-26 09:14:05 +0100 | [diff] [blame] | 56 | /* TRXC port (for classic tests) */ |
| 57 | port TRXC_CODEC_PT BB_TRXC; |
| 58 | var integer g_bb_trxc_conn_id; |
| 59 | |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 60 | /* SI configuration */ |
| 61 | var SystemInformationConfig si_cfg := { |
| 62 | bcch_extended := false, |
| 63 | si1_present := false, |
| 64 | si2bis_present := false, |
| 65 | si2ter_present := false, |
| 66 | si2quater_present := false, |
| 67 | si7_present := false, |
| 68 | si8_present := false, |
| 69 | si9_present := false, |
| 70 | si13_present := false, |
| 71 | si13alt_present := false, |
| 72 | si15_present := false, |
| 73 | si16_present := false, |
| 74 | si17_present := false, |
| 75 | si2n_present := false, |
| 76 | si21_present := false, |
| 77 | si22_present := false |
| 78 | }; |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 79 | } |
| 80 | |
| 81 | /* an individual call / channel */ |
| 82 | type component ConnHdlr extends RSL_DchanHdlr { |
| 83 | port L1CTL_PT L1CTL; |
| 84 | |
| 85 | port TRXC_CODEC_PT BB_TRXC; |
| 86 | var integer g_bb_trxc_conn_id; |
| 87 | |
| 88 | timer g_Tguard; |
| 89 | timer g_Tmeas_exp := 2.0; /* >= 103 SACCH multiframe ~ 500ms */ |
| 90 | |
| 91 | var ConnHdlrPars g_pars; |
| 92 | var uint8_t g_next_meas_res_nr := 0; |
| 93 | } |
| 94 | |
| 95 | function f_init_rsl(charstring id) runs on test_CT { |
| 96 | vc_IPA := IPA_Emulation_CT.create(id & "-RSL-IPA"); |
| 97 | vc_RSL := RSL_Emulation_CT.create(id & "-RSL"); |
| 98 | |
| 99 | map(vc_IPA:IPA_PORT, system:IPA_CODEC_PT); |
| 100 | connect(vc_IPA:IPA_RSL_PORT, vc_RSL:IPA_PT); |
| 101 | connect(self:RSL_CCHAN, vc_RSL:CCHAN_PT); |
| 102 | |
| 103 | vc_IPA.start(IPA_Emulation.main_server(mp_rsl_ip, mp_rsl_port)); |
| 104 | vc_RSL.start(RSL_Emulation.main(false)); |
| 105 | } |
| 106 | |
| 107 | type record ConnHdlrPars { |
| 108 | RslChannelNr chan_nr, |
| 109 | RSL_IE_ChannelMode chan_mode, |
| 110 | float t_guard, |
| 111 | ConnL1Pars l1_pars |
| 112 | } |
| 113 | |
Harald Welte | 82ccef7 | 2018-02-25 16:17:33 +0100 | [diff] [blame] | 114 | template (value) RachControlParameters ts_RachCtrl_default := { |
| 115 | max_retrans := RACH_MAX_RETRANS_1, |
| 116 | tx_integer := '0000'B, /* 3 slots */ |
| 117 | cell_barr_access := false, |
| 118 | re_not_allowed := true, |
| 119 | acc := '1111111111111111'B |
| 120 | }; |
| 121 | |
Harald Welte | f10153f | 2018-02-25 16:34:05 +0100 | [diff] [blame] | 122 | template (value) CellSelectionParameters ts_CellSelPar_default := { |
| 123 | cell_resel_hyst_2dB := 0, |
| 124 | ms_txpwr_max_cch := 0, |
| 125 | acs := '0'B, |
| 126 | neci := true, |
| 127 | rxlev_access_min := 0 |
| 128 | } |
| 129 | |
| 130 | template (value) LocationAreaIdentification ts_LAI_default := { |
| 131 | mcc_mnc := '262F42'H, |
| 132 | lac := 42 |
| 133 | } |
| 134 | |
Harald Welte | 7484fc4 | 2018-02-24 14:09:45 +0100 | [diff] [blame] | 135 | /* Default SYSTEM INFORMATION 3 */ |
Harald Welte | 82ccef7 | 2018-02-25 16:17:33 +0100 | [diff] [blame] | 136 | template (value) SystemInformation ts_SI3_default := { |
Harald Welte | 7484fc4 | 2018-02-24 14:09:45 +0100 | [diff] [blame] | 137 | header := t_RrHeader(SYSTEM_INFORMATION_TYPE_3, 0), |
| 138 | payload := { |
| 139 | si3 := { |
| 140 | cell_id := 23, |
Harald Welte | f10153f | 2018-02-25 16:34:05 +0100 | [diff] [blame] | 141 | lai := ts_LAI_default, |
Harald Welte | 7484fc4 | 2018-02-24 14:09:45 +0100 | [diff] [blame] | 142 | ctrl_chan_desc := { |
| 143 | msc_r99 := true, |
| 144 | att := true, |
| 145 | bs_ag_blks_res := 1, |
| 146 | ccch_conf := CCHAN_DESC_1CCCH_COMBINED, |
Harald Welte | 82ccef7 | 2018-02-25 16:17:33 +0100 | [diff] [blame] | 147 | si22ind := false, |
Harald Welte | 7484fc4 | 2018-02-24 14:09:45 +0100 | [diff] [blame] | 148 | cbq3 := CBQ3_IU_MODE_NOT_SUPPORTED, |
| 149 | spare := '00'B, |
| 150 | bs_pa_mfrms := 0, /* 2 multiframes */ |
| 151 | t3212 := 1 /* 6 minutes */ |
| 152 | }, |
Harald Welte | 82ccef7 | 2018-02-25 16:17:33 +0100 | [diff] [blame] | 153 | cell_options := { |
Harald Welte | 7484fc4 | 2018-02-24 14:09:45 +0100 | [diff] [blame] | 154 | dn_ind := false, |
| 155 | pwrc := false, |
| 156 | dtx := MS_MAY_USE_UL_DTX, |
| 157 | radio_link_tout_div4 := 4/4 |
| 158 | }, |
Harald Welte | f10153f | 2018-02-25 16:34:05 +0100 | [diff] [blame] | 159 | cell_sel_par := ts_CellSelPar_default, |
Harald Welte | 82ccef7 | 2018-02-25 16:17:33 +0100 | [diff] [blame] | 160 | rach_control := ts_RachCtrl_default, |
Harald Welte | 7484fc4 | 2018-02-24 14:09:45 +0100 | [diff] [blame] | 161 | rest_octets := ''O |
| 162 | } |
| 163 | } |
| 164 | } |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 165 | |
Harald Welte | f10153f | 2018-02-25 16:34:05 +0100 | [diff] [blame] | 166 | template (value) SystemInformation ts_SI2_default := { |
| 167 | header := t_RrHeader(SYSTEM_INFORMATION_TYPE_2, 0), |
| 168 | payload := { |
| 169 | si2 := { |
| 170 | bcch_freq_list := '00000000000000000000000000000000'O, |
| 171 | ncc_permitted := '11111111'B, |
| 172 | rach_control := ts_RachCtrl_default |
| 173 | } |
| 174 | } |
| 175 | } |
| 176 | |
| 177 | template (value) SystemInformation ts_SI4_default := { |
| 178 | header := t_RrHeader(SYSTEM_INFORMATION_TYPE_4, 0), |
| 179 | payload := { |
| 180 | si4 := { |
| 181 | lai := ts_LAI_default, |
| 182 | cell_sel_par := ts_CellSelPar_default, |
| 183 | rach_control := ts_RachCtrl_default, |
| 184 | cbch_chan_desc := omit, |
| 185 | cbch_mobile_alloc := omit, |
| 186 | rest_octets := ''O |
| 187 | } |
| 188 | } |
| 189 | } |
| 190 | |
| 191 | function f_rsl_bcch_fill_raw(RSL_IE_SysinfoType rsl_si_type, octetstring si_enc) |
| 192 | runs on test_CT { |
| 193 | log("Setting ", rsl_si_type, ": ", si_enc); |
| 194 | RSL_CCHAN.send(ts_RSL_UD(ts_RSL_BCCH_INFO(rsl_si_type, si_enc))); |
| 195 | } |
| 196 | |
| 197 | function f_rsl_bcch_fill(RSL_IE_SysinfoType rsl_si_type, template (value) SystemInformation si_dec) |
| 198 | runs on test_CT { |
| 199 | var octetstring si_enc := enc_SystemInformation(valueof(si_dec)); |
| 200 | log("Setting ", rsl_si_type, ": ", si_dec); |
| 201 | f_rsl_bcch_fill_raw(rsl_si_type, si_enc); |
| 202 | } |
| 203 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 204 | /* global init function */ |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 205 | function f_init(charstring id := "BTS-Test") runs on test_CT { |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 206 | f_init_rsl(id); |
| 207 | RSL_CCHAN.receive(ASP_IPA_Event:{up_down := ASP_IPA_EVENT_UP}); |
Harald Welte | 2d14259 | 2018-02-25 13:19:44 +0100 | [diff] [blame] | 208 | f_sleep(0.5); /* workaround for OS#3000 */ |
Harald Welte | 7484fc4 | 2018-02-24 14:09:45 +0100 | [diff] [blame] | 209 | |
| 210 | /* Send SI3 to the BTS, it is needed for various computations */ |
Harald Welte | f10153f | 2018-02-25 16:34:05 +0100 | [diff] [blame] | 211 | f_rsl_bcch_fill(RSL_SYSTEM_INFO_3, ts_SI3_default); |
| 212 | /* SI2 + SI4 are required for SI testing as they are mandatory defaults */ |
| 213 | f_rsl_bcch_fill(RSL_SYSTEM_INFO_2, ts_SI2_default); |
| 214 | f_rsl_bcch_fill(RSL_SYSTEM_INFO_4, ts_SI4_default); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 215 | } |
| 216 | |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 217 | /* Attach L1CTL to master test_CT (classic tests, non-handler mode) */ |
| 218 | function f_init_l1ctl() runs on test_CT { |
| 219 | map(self:L1CTL, system:L1CTL); |
| 220 | f_connect_reset(L1CTL); |
| 221 | } |
| 222 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 223 | type function void_fn(charstring id) runs on ConnHdlr; |
| 224 | |
| 225 | /* create a new test component */ |
| 226 | function f_start_handler(void_fn fn, ConnHdlrPars pars) |
| 227 | runs on test_CT return ConnHdlr { |
| 228 | var charstring id := testcasename(); |
| 229 | var ConnHdlr vc_conn; |
| 230 | |
| 231 | vc_conn := ConnHdlr.create(id); |
| 232 | /* connect to RSL Emulation main component */ |
| 233 | connect(vc_conn:RSL, vc_RSL:CLIENT_PT); |
| 234 | connect(vc_conn:RSL_PROC, vc_RSL:RSL_PROC); |
| 235 | |
| 236 | vc_conn.start(f_handler_init(fn, id, pars)); |
| 237 | return vc_conn; |
| 238 | } |
| 239 | |
Harald Welte | 7484fc4 | 2018-02-24 14:09:45 +0100 | [diff] [blame] | 240 | template ASP_RSL_Unitdata ts_RSL_UD(template RSL_Message rsl, IpaStreamId sid := IPAC_PROTO_RSL_TRX0) := { |
| 241 | streamId := sid, |
| 242 | rsl := rsl |
| 243 | } |
| 244 | |
| 245 | template ASP_RSL_Unitdata tr_RSL_UD(template RSL_Message rsl, |
| 246 | template IpaStreamId sid := IPAC_PROTO_RSL_TRX0) := { |
| 247 | streamId := sid, |
| 248 | rsl := rsl |
| 249 | } |
| 250 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 251 | private altstep as_Tguard() runs on ConnHdlr { |
| 252 | [] g_Tguard.timeout { |
| 253 | setverdict(fail, "Tguard timeout"); |
| 254 | self.stop; |
| 255 | } |
| 256 | } |
| 257 | |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 258 | private function f_l1_tune(L1CTL_PT L1CTL) { |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 259 | f_L1CTL_FBSB(L1CTL, { false, mp_trx0_arfcn }, CCCH_MODE_COMBINED); |
| 260 | } |
| 261 | |
| 262 | private function f_trxc_connect() runs on ConnHdlr { |
| 263 | map(self:BB_TRXC, system:BB_TRXC); |
| 264 | var Result res; |
| 265 | res := TRXC_CodecPort_CtrlFunct.f_IPL4_connect(BB_TRXC, "127.0.0.1", mp_bb_trxc_port, |
| 266 | "127.0.0.1", 0, -1, {udp:={}}, {}); |
| 267 | g_bb_trxc_conn_id := res.connId; |
| 268 | } |
| 269 | |
| 270 | private function f_trxc_fake_rssi(uint8_t rssi) runs on ConnHdlr { |
| 271 | BB_TRXC.send(ts_TRXC_Send(g_bb_trxc_conn_id, ts_TRXC_FAKE_RSSI(rssi))); |
| 272 | } |
| 273 | |
| 274 | private function f_trx_fake_toffs256(int16_t toffs256) runs on ConnHdlr { |
| 275 | BB_TRXC.send(ts_TRXC_Send(g_bb_trxc_conn_id, ts_TRXC_FAKE_TIMING(toffs256))); |
| 276 | } |
| 277 | |
| 278 | /* first function started in ConnHdlr component */ |
| 279 | private function f_handler_init(void_fn fn, charstring id, ConnHdlrPars pars) |
| 280 | runs on ConnHdlr { |
| 281 | g_pars := pars; |
| 282 | g_chan_nr := pars.chan_nr; |
| 283 | |
| 284 | map(self:L1CTL, system:L1CTL); |
| 285 | f_connect_reset(L1CTL); |
| 286 | |
| 287 | f_trxc_connect(); |
| 288 | |
| 289 | g_Tguard.start(pars.t_guard); |
| 290 | activate(as_Tguard()); |
| 291 | |
| 292 | f_rslem_register(0, pars.chan_nr); |
| 293 | |
| 294 | /* call the user-supplied test case function */ |
| 295 | fn.apply(id); |
| 296 | } |
| 297 | |
Harald Welte | 1eba374 | 2018-02-25 12:48:14 +0100 | [diff] [blame] | 298 | function f_rsl_transceive(template RSL_Message tx, template RSL_Message exp_rx, charstring id) |
| 299 | runs on ConnHdlr { |
| 300 | timer T := 3.0; |
| 301 | RSL.send(tx); |
| 302 | T.start; |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 303 | alt { |
Harald Welte | 1eba374 | 2018-02-25 12:48:14 +0100 | [diff] [blame] | 304 | [] RSL.receive(exp_rx) { |
| 305 | T.stop; |
| 306 | setverdict(pass); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 307 | } |
Harald Welte | 1eba374 | 2018-02-25 12:48:14 +0100 | [diff] [blame] | 308 | [] T.timeout { |
| 309 | setverdict(fail, "Timeout expecting " & id); |
| 310 | self.stop; |
| 311 | } |
| 312 | [] RSL.receive { |
| 313 | setverdict(fail, "Unexpected RSL message received"); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 314 | } |
| 315 | } |
| 316 | } |
| 317 | |
Harald Welte | 1eba374 | 2018-02-25 12:48:14 +0100 | [diff] [blame] | 318 | function f_rsl_chan_act(RSL_IE_ChannelMode mode) runs on ConnHdlr { |
| 319 | f_rsl_transceive(ts_RSL_CHAN_ACT(g_chan_nr, mode), tr_RSL_CHAN_ACT_ACK(g_chan_nr), |
| 320 | "RSL CHAN ACT"); |
| 321 | } |
| 322 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 323 | function f_rsl_chan_deact() runs on ConnHdlr { |
Harald Welte | 1eba374 | 2018-02-25 12:48:14 +0100 | [diff] [blame] | 324 | f_rsl_transceive(ts_RSL_RF_CHAN_REL(g_chan_nr), tr_RSL_RF_CHAN_REL_ACK(g_chan_nr), |
| 325 | "RF CHAN REL"); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 326 | } |
| 327 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 328 | private template ConnHdlrPars t_Pars(template RslChannelNr chan_nr, |
| 329 | template RSL_IE_ChannelMode chan_mode, |
| 330 | float t_guard := 20.0) := { |
| 331 | chan_nr := valueof(chan_nr), |
| 332 | chan_mode := valueof(chan_mode), |
| 333 | t_guard := t_guard, |
| 334 | l1_pars := { |
| 335 | dtx_enabled := false, |
| 336 | meas_ul := { |
| 337 | full := { |
| 338 | rxlev := dbm2rxlev(-53), |
| 339 | rxqual := 0 |
| 340 | }, |
| 341 | sub := { |
| 342 | rxlev := dbm2rxlev(-53), |
| 343 | rxqual := 0 |
| 344 | } |
| 345 | }, |
| 346 | timing_offset_256syms := 0, |
| 347 | bs_power_level := 0, |
| 348 | ms_power_level := 0, |
| 349 | ms_actual_ta := 0 |
| 350 | } |
| 351 | } |
| 352 | |
Harald Welte | 93640c6 | 2018-02-25 16:59:33 +0100 | [diff] [blame] | 353 | /*********************************************************************** |
| 354 | * Channel Activation / Deactivation |
| 355 | ***********************************************************************/ |
| 356 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 357 | /* Stress test: Do 500 channel activations/deactivations in rapid succession */ |
| 358 | function f_TC_chan_act_stress(charstring id) runs on ConnHdlr { |
| 359 | for (var integer i := 0; i < 500; i := i+1) { |
| 360 | f_rsl_chan_act(g_pars.chan_mode); |
| 361 | f_rsl_chan_deact(); |
| 362 | } |
| 363 | setverdict(pass); |
| 364 | } |
| 365 | testcase TC_chan_act_stress() runs on test_CT { |
| 366 | var ConnHdlr vc_conn; |
| 367 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 368 | f_init(testcasename()); |
| 369 | vc_conn := f_start_handler(refers(f_TC_chan_act_stress), pars); |
| 370 | vc_conn.done; |
| 371 | } |
| 372 | |
| 373 | /* Test if re-activation of an already active channel fails as expected */ |
| 374 | function f_TC_chan_act_react(charstring id) runs on ConnHdlr { |
| 375 | f_rsl_chan_act(g_pars.chan_mode); |
| 376 | /* attempt to activate the same lchan again -> expect reject */ |
| 377 | RSL.send(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode)); |
| 378 | alt { |
| 379 | [] RSL.receive(tr_RSL_CHAN_ACT_ACK(g_chan_nr)) { |
| 380 | setverdict(fail, "Unexpected CHAN ACT ACK on double activation"); |
| 381 | } |
| 382 | [] RSL.receive(tr_RSL_CHAN_ACT_NACK(g_chan_nr)) { |
| 383 | setverdict(pass); |
| 384 | } |
| 385 | } |
| 386 | f_rsl_chan_deact(); |
| 387 | } |
| 388 | testcase TC_chan_act_react() runs on test_CT { |
| 389 | var ConnHdlr vc_conn; |
| 390 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 391 | f_init(testcasename()); |
| 392 | vc_conn := f_start_handler(refers(f_TC_chan_act_react), pars); |
| 393 | vc_conn.done; |
| 394 | } |
| 395 | |
| 396 | /* Attempt to de-activate a channel that's not active */ |
| 397 | function f_TC_chan_deact_not_active(charstring id) runs on ConnHdlr { |
| 398 | timer T := 3.0; |
| 399 | RSL.send(ts_RSL_RF_CHAN_REL(g_chan_nr)); |
| 400 | T.start; |
| 401 | alt { |
| 402 | [] RSL.receive(tr_RSL_RF_CHAN_REL_ACK(g_chan_nr)) { |
| 403 | setverdict(pass); |
| 404 | } |
| 405 | [] T.timeout { |
| 406 | setverdict(fail, "Timeout expecting RF_CHAN_REL_ACK"); |
| 407 | } |
| 408 | } |
| 409 | } |
| 410 | testcase TC_chan_deact_not_active() runs on test_CT { |
| 411 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 412 | f_init(testcasename()); |
| 413 | var ConnHdlr vc_conn := f_start_handler(refers(f_TC_chan_deact_not_active), pars); |
| 414 | vc_conn.done; |
| 415 | } |
| 416 | |
| 417 | /* attempt to activate channel with wrong RSL Channel Nr IE; expect NACK */ |
| 418 | function f_TC_chan_act_wrong_nr(charstring id) runs on ConnHdlr { |
| 419 | RSL.send(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode)); |
| 420 | alt { |
| 421 | [] RSL.receive(tr_RSL_CHAN_ACT_ACK(g_chan_nr)) { |
| 422 | setverdict(fail, "Unexpected CHAN ACT ACK"); |
| 423 | } |
| 424 | [] RSL.receive(tr_RSL_CHAN_ACT_NACK(g_chan_nr)) { |
| 425 | setverdict(pass); |
| 426 | } |
| 427 | } |
| 428 | } |
| 429 | private type record WrongChanNrCase { |
| 430 | RslChannelNr chan_nr, |
| 431 | charstring description |
| 432 | } |
| 433 | private type record of WrongChanNrCase WrongChanNrCases; |
| 434 | private template WrongChanNrCase t_WCN(template RslChannelNr chan_nr, charstring desc) := { |
| 435 | chan_nr := chan_nr, |
| 436 | description := desc |
| 437 | } |
| 438 | |
| 439 | testcase TC_chan_act_wrong_nr() runs on test_CT { |
| 440 | var ConnHdlr vc_conn; |
| 441 | var ConnHdlrPars pars; |
| 442 | |
| 443 | f_init(testcasename()); |
| 444 | |
| 445 | var WrongChanNrCases wrong := { |
| 446 | valueof(t_WCN(t_RslChanNr_RACH(0), "RACH is not a dedicated channel")), |
| 447 | valueof(t_WCN(t_RslChanNr_RACH(1), "RACH doesn't exist on timeslot")), |
| 448 | valueof(t_WCN(t_RslChanNr_BCCH(0), "BCCH is not a dedicated channel")), |
| 449 | valueof(t_WCN(t_RslChanNr_PCH_AGCH(0), "PCH/AGCH is not a dedicated channel")), |
| 450 | valueof(t_WCN(t_RslChanNr_Bm(0), "TS0 cannot be TCH/F")), |
| 451 | valueof(t_WCN(t_RslChanNr_Lm(0, 0), "TS0 cannot be TCH/H")), |
| 452 | valueof(t_WCN(t_RslChanNr_Lm(0, 1), "TS0 cannot be TCH/H")), |
| 453 | valueof(t_WCN(t_RslChanNr_PDCH(0), "TS0 cannot be PDCH")), |
| 454 | valueof(t_WCN(t_RslChanNr_SDCCH8(0, 0), "TS0 cannot be SDCCH/8")), |
| 455 | valueof(t_WCN(t_RslChanNr_SDCCH8(0, 7), "TS0 cannot be SDCCH/8")), |
| 456 | valueof(t_WCN(t_RslChanNr_SDCCH4(7, 0), "TS7 cannot be SDCCH/4")), |
| 457 | valueof(t_WCN(t_RslChanNr_SDCCH4(7, 3), "TS7 cannot be SDCCH/4")), |
| 458 | valueof(t_WCN(t_RslChanNr_Lm(1, 0), "TS1 cannot be TCH/H")) |
| 459 | }; |
| 460 | |
| 461 | for (var integer i := 0; i < sizeof(wrong); i := i+1) { |
| 462 | pars := valueof(t_Pars(wrong[i].chan_nr, ts_RSL_ChanMode_SIGN)); |
| 463 | vc_conn := f_start_handler(refers(f_TC_chan_act_wrong_nr), pars); |
| 464 | vc_conn.done; |
| 465 | } |
| 466 | } |
| 467 | |
Harald Welte | 93640c6 | 2018-02-25 16:59:33 +0100 | [diff] [blame] | 468 | /*********************************************************************** |
| 469 | * RACH Handling |
| 470 | ***********************************************************************/ |
| 471 | |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 472 | /* like L1SAP_IS_PACKET_RACH */ |
| 473 | private function ra_is_ps(OCT1 ra) return boolean { |
| 474 | if (ra and4b 'F0'O == '70'O) { |
| 475 | return true; |
| 476 | } else if (ra and4b '0F'O == '0F'O) { |
| 477 | return true; |
| 478 | } |
| 479 | return false; |
| 480 | } |
| 481 | |
| 482 | /* generate a random RACH for circuit-switched */ |
| 483 | private function f_rnd_ra_cs() return OCT1 { |
| 484 | var OCT1 ra; |
| 485 | do { |
| 486 | ra := f_rnd_octstring(1); |
| 487 | } while (ra_is_ps(ra)); |
| 488 | return ra; |
| 489 | } |
| 490 | |
| 491 | /* Send 1000 RACH requests and check their RA+FN on the RSL side */ |
| 492 | testcase TC_rach_content() runs on test_CT { |
| 493 | f_init(testcasename()); |
| 494 | f_init_l1ctl(); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 495 | f_l1_tune(L1CTL); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 496 | |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 497 | var GsmFrameNumber fn_last := 0; |
| 498 | for (var integer i := 0; i < 1000; i := i+1) { |
| 499 | var OCT1 ra := f_rnd_ra_cs(); |
| 500 | var GsmFrameNumber fn := f_L1CTL_RACH(L1CTL, oct2int(ra)); |
| 501 | if (fn == fn_last) { |
| 502 | setverdict(fail, "Two RACH in same FN?!?"); |
| 503 | self.stop; |
| 504 | } |
| 505 | fn_last := fn; |
| 506 | |
| 507 | timer T := 5.0; |
| 508 | alt { |
| 509 | [] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_CHAN_RQD(ra, fn, ?))) { |
| 510 | T.stop; |
| 511 | } |
| 512 | [] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_CHAN_RQD(?, ?, ?))) { |
| 513 | setverdict(fail, "Unexpected CHAN RQD"); |
| 514 | self.stop; |
| 515 | } |
| 516 | [] RSL_CCHAN.receive { repeat; } |
| 517 | [] T.timeout { |
| 518 | setverdict(fail, "Timeout waiting for CHAN RQD"); |
| 519 | self.stop; |
| 520 | } |
| 521 | } |
| 522 | } |
| 523 | setverdict(pass); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 524 | } |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 525 | |
| 526 | /* Send 1000 RACH Requests (flood ~ 89/s) and count if count(Abis) == count(Um) */ |
| 527 | testcase TC_rach_count() runs on test_CT { |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 528 | f_init(testcasename()); |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 529 | f_init_l1ctl(); |
| 530 | f_l1_tune(L1CTL); |
| 531 | |
| 532 | var GsmFrameNumber fn_last := 0; |
| 533 | for (var integer i := 0; i < 1000; i := i+1) { |
| 534 | var OCT1 ra := f_rnd_ra_cs(); |
| 535 | var GsmFrameNumber fn := f_L1CTL_RACH(L1CTL, oct2int(ra)); |
| 536 | if (fn == fn_last) { |
| 537 | setverdict(fail, "Two RACH in same FN?!?"); |
| 538 | self.stop; |
| 539 | } |
| 540 | fn_last := fn; |
| 541 | } |
| 542 | var integer rsl_chrqd := 0; |
| 543 | timer T := 3.0; |
| 544 | alt { |
| 545 | [] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_CHAN_RQD(?,?))) { |
| 546 | rsl_chrqd := rsl_chrqd + 1; |
Harald Welte | c3a3f45 | 2018-02-26 17:37:47 +0100 | [diff] [blame^] | 547 | f_timer_safe_restart(T); |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 548 | repeat; |
| 549 | } |
| 550 | [] RSL_CCHAN.receive { repeat; } |
| 551 | [] T.timeout { } |
| 552 | } |
| 553 | if (rsl_chrqd == 1000) { |
| 554 | setverdict(pass); |
| 555 | } else { |
| 556 | setverdict(fail, "Received only ", rsl_chrqd, " out of 1000 RACH"); |
| 557 | } |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 558 | } |
| 559 | |
Harald Welte | 54a2a2d | 2018-02-26 09:14:05 +0100 | [diff] [blame] | 560 | private function f_main_trxc_connect() runs on test_CT { |
| 561 | map(self:BB_TRXC, system:BB_TRXC); |
| 562 | var Result res; |
| 563 | res := TRXC_CodecPort_CtrlFunct.f_IPL4_connect(BB_TRXC, "127.0.0.1", mp_bb_trxc_port, |
| 564 | "127.0.0.1", 0, -1, {udp:={}}, {}); |
| 565 | g_bb_trxc_conn_id := res.connId; |
| 566 | } |
| 567 | |
| 568 | private function f_rach_toffs(int16_t toffs256, boolean expect_pass) runs on test_CT { |
| 569 | /* tell fake_trx to use a given timing offset for all bursts */ |
| 570 | BB_TRXC.send(ts_TRXC_Send(g_bb_trxc_conn_id, ts_TRXC_FAKE_TIMING(toffs256))); |
| 571 | f_sleep(0.5); |
| 572 | |
| 573 | /* Transmit RACH request + wait for confirmation */ |
| 574 | var OCT1 ra := f_rnd_ra_cs(); |
| 575 | var GsmFrameNumber fn := f_L1CTL_RACH(L1CTL, oct2int(ra)); |
| 576 | |
| 577 | /* Check for expected result */ |
| 578 | timer T := 1.5; |
| 579 | T.start; |
| 580 | alt { |
| 581 | [expect_pass] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_CHAN_RQD(ra, fn))) { |
| 582 | setverdict(pass); |
| 583 | } |
| 584 | [not expect_pass] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_CHAN_RQD(ra, fn))) { |
| 585 | setverdict(fail, "RACH passed but was expected to be dropped"); |
| 586 | } |
| 587 | [] RSL_CCHAN.receive { repeat; } |
| 588 | [not expect_pass] T.timeout { |
| 589 | setverdict(pass); |
| 590 | } |
| 591 | [expect_pass] T.timeout { |
| 592 | setverdict(fail, "Timeout waiting for CHAN RQD"); |
| 593 | } |
| 594 | } |
| 595 | } |
| 596 | |
| 597 | /* Test if dropping of RACH Based on NM_ATT_MAX_TA works */ |
| 598 | testcase TC_rach_max_ta() runs on test_CT { |
| 599 | f_init(testcasename()); |
| 600 | f_init_l1ctl(); |
| 601 | f_l1_tune(L1CTL); |
| 602 | f_main_trxc_connect(); |
| 603 | f_sleep(1.0); |
| 604 | |
| 605 | /* default max-ta is 63 (full range of GSM timing advance */ |
| 606 | |
| 607 | /* negative TA must not happen */ |
| 608 | f_rach_toffs(-10*256, false); |
| 609 | |
| 610 | /* 0 / 32 / 63 bits is legal / permitted */ |
| 611 | f_rach_toffs(0, true); |
| 612 | f_rach_toffs(32*256, true); |
| 613 | f_rach_toffs(63*256, true); |
| 614 | |
| 615 | /* more than 63 bits is not legal / permitted */ |
| 616 | f_rach_toffs(64*256, false); |
| 617 | f_rach_toffs(127*256, false); |
| 618 | } |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 619 | |
Harald Welte | 93640c6 | 2018-02-25 16:59:33 +0100 | [diff] [blame] | 620 | /*********************************************************************** |
| 621 | * Measurement Processing / Reporting |
| 622 | ***********************************************************************/ |
| 623 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 624 | template LapdmAddressField ts_LapdmAddr(LapdmSapi sapi, boolean c_r) := { |
| 625 | spare := '0'B, |
| 626 | lpd := 0, |
| 627 | sapi := sapi, |
| 628 | c_r := c_r, |
| 629 | ea := true |
| 630 | } |
| 631 | |
| 632 | template LapdmFrameB ts_LAPDm_B(LapdmSapi sapi, boolean c_r, boolean p, octetstring pl) := { |
| 633 | addr := ts_LapdmAddr(sapi, c_r), |
| 634 | ctrl := t_LapdmCtrlUI(p), |
| 635 | len := 0, /* overwritten */ |
| 636 | m := false, |
| 637 | el := 1, |
| 638 | payload := pl |
| 639 | } |
| 640 | |
| 641 | /* handle incoming downlink SACCH and respond with uplink SACCH (meas res) */ |
| 642 | altstep as_l1_sacch() runs on ConnHdlr { |
| 643 | var L1ctlDlMessage l1_dl; |
| 644 | [] L1CTL.receive(t_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl { |
| 645 | log("SACCH received: ", l1_dl.payload.data_ind.payload); |
| 646 | var GsmRrL3Message meas_rep := valueof(ts_MEAS_REP(true, 23, 23, 0, 0, omit)); |
| 647 | var LapdmFrameB lb := valueof(ts_LAPDm_B(0, false, false, enc_GsmRrL3Message(meas_rep))); |
| 648 | log("LAPDm: ", lb); |
| 649 | var octetstring pl := '0000'O & enc_LapdmFrameB(lb); |
| 650 | L1CTL.send(t_L1CTL_DATA_REQ(g_chan_nr, ts_RslLinkID_SACCH(0), pl)); |
| 651 | repeat; |
| 652 | } |
| 653 | } |
| 654 | |
| 655 | altstep as_l1_dcch() runs on ConnHdlr { |
| 656 | var L1ctlDlMessage l1_dl; |
| 657 | [] L1CTL.receive(t_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_DCCH(?))) -> value l1_dl { |
| 658 | log("DCCH received: ", l1_dl.payload.data_ind.payload); |
| 659 | var octetstring pl := '010301'O; |
| 660 | L1CTL.send(t_L1CTL_DATA_REQ(g_chan_nr, ts_RslLinkID_DCCH(0), pl)); |
| 661 | repeat; |
| 662 | } |
| 663 | } |
| 664 | |
| 665 | type record MeasElem { |
| 666 | uint6_t rxlev, |
| 667 | uint3_t rxqual |
| 668 | } |
| 669 | |
| 670 | type record MeasElemFS { |
| 671 | MeasElem full, |
| 672 | MeasElem sub |
| 673 | } |
| 674 | |
| 675 | type record ConnL1Pars { |
| 676 | boolean dtx_enabled, |
| 677 | MeasElemFS meas_ul, |
| 678 | int16_t timing_offset_256syms, |
| 679 | uint5_t bs_power_level, |
| 680 | uint5_t ms_power_level, |
| 681 | uint8_t ms_actual_ta |
| 682 | } |
| 683 | |
| 684 | /* Convert tiing offset from 1/256th symbol to RSL Timing Offset */ |
| 685 | private function toffs256s_to_rsl(int16_t toffs256s) return uint8_t { |
| 686 | return 63 + (toffs256s/256); |
| 687 | } |
| 688 | |
| 689 | /* build a template for matching measurement results against */ |
| 690 | private function f_build_meas_res_tmpl() runs on ConnHdlr return template RSL_Message { |
| 691 | var ConnL1Pars l1p := g_pars.l1_pars; |
| 692 | var template RSL_IE_UplinkMeas ul_meas := { |
| 693 | len := 3, |
| 694 | rfu := '0'B, |
| 695 | dtx_d := l1p.dtx_enabled, |
| 696 | rxlev_f_u := l1p.meas_ul.full.rxlev, |
| 697 | reserved1 := '00'B, |
| 698 | rxlev_s_u := l1p.meas_ul.sub.rxlev, |
| 699 | reserved2 := '00'B, |
| 700 | rxq_f_u := l1p.meas_ul.full.rxqual, |
| 701 | rxq_s_u := l1p.meas_ul.sub.rxqual, |
| 702 | supp_meas_info := omit |
| 703 | }; |
| 704 | /* HACK HACK HACK FIXME HACK HACK HACK see https://osmocom.org/issues/2988 */ |
| 705 | ul_meas.rxlev_f_u := ?; |
| 706 | ul_meas.rxlev_s_u := ?; |
| 707 | ul_meas.rxq_f_u := ?; |
| 708 | ul_meas.rxq_s_u := ?; |
| 709 | var template RSL_IE_BS_Power bs_power := { |
| 710 | reserved := 0, |
| 711 | epc := false, |
| 712 | fpc := false, |
| 713 | power_level := l1p.bs_power_level |
| 714 | }; |
| 715 | var template RSL_IE_L1Info l1_info := { |
| 716 | ms_power_lvl := l1p.ms_power_level, |
| 717 | fpc := false, |
| 718 | reserved := 0, |
| 719 | actual_ta := l1p.ms_actual_ta |
| 720 | }; |
| 721 | var uint8_t offs := toffs256s_to_rsl(l1p.timing_offset_256syms); |
| 722 | var template uint8_t t_toffs := (offs-1 .. offs+1); /* some tolerance */ |
| 723 | return tr_RSL_MEAS_RES_OSMO(g_chan_nr, g_next_meas_res_nr, ul_meas, bs_power, l1_info, |
| 724 | ?, t_toffs); |
| 725 | } |
| 726 | |
| 727 | /* verify we regularly receive measurement reports with incrementing numbers */ |
| 728 | altstep as_meas_res() runs on ConnHdlr { |
| 729 | var RSL_Message rsl; |
| 730 | [] RSL.receive(f_build_meas_res_tmpl()) -> value rsl { |
| 731 | /* increment counter of next to-be-expected meas rep */ |
| 732 | g_next_meas_res_nr := (g_next_meas_res_nr + 1) mod 256; |
| 733 | /* Re-start the timer expecting the next MEAS RES */ |
Harald Welte | c3a3f45 | 2018-02-26 17:37:47 +0100 | [diff] [blame^] | 734 | f_timer_safe_restart(g_Tmeas_exp); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 735 | repeat; |
| 736 | } |
| 737 | [] RSL.receive(tr_RSL_MEAS_RES(g_chan_nr, g_next_meas_res_nr)) -> value rsl { |
| 738 | setverdict(fail, "Received unspecific MEAS RES ", rsl); |
| 739 | self.stop; |
| 740 | } |
| 741 | [] RSL.receive(tr_RSL_MEAS_RES(?)) -> value rsl { |
| 742 | setverdict(fail, "Received unexpected MEAS RES ", rsl); |
| 743 | self.stop; |
| 744 | } |
| 745 | [] g_Tmeas_exp.timeout { |
| 746 | setverdict(fail, "Didn't receive expected measurement result") |
| 747 | self.stop; |
| 748 | } |
| 749 | } |
| 750 | |
| 751 | /* Establish dedicated channel: L1CTL + RSL side */ |
| 752 | private function f_est_dchan() runs on ConnHdlr { |
| 753 | var GsmFrameNumber fn; |
| 754 | var ImmediateAssignment imm_ass; |
| 755 | var integer ra := 23; |
| 756 | |
| 757 | fn := f_L1CTL_RACH(L1CTL, ra); |
| 758 | /* This arrives on CCHAN, so we cannot test for receiving CHAN RQDhere */ |
| 759 | //RSL.receive(tr_RSL_CHAN_RQD(int2oct(23,1))); |
| 760 | |
| 761 | /* Activate channel on BTS side */ |
| 762 | f_rsl_chan_act(g_pars.chan_mode); |
| 763 | |
| 764 | /* Send IMM.ASS via CCHAN */ |
| 765 | var ChannelDescription ch_desc := { |
| 766 | chan_nr := g_pars.chan_nr, |
| 767 | tsc := 7, |
| 768 | h := false, |
| 769 | arfcn := mp_trx0_arfcn, |
| 770 | maio_hsn := omit |
| 771 | }; |
| 772 | var MobileAllocation ma := { |
| 773 | len := 0, |
| 774 | ma := ''B |
| 775 | }; |
| 776 | var GsmRrMessage rr_msg := valueof(ts_IMM_ASS(ra, fn, 0, ch_desc, ma)); |
| 777 | RSL.send(ts_RSL_IMM_ASSIGN(enc_GsmRrMessage(rr_msg))); |
| 778 | |
| 779 | /* receive IMM.ASS on MS side */ |
| 780 | var ImmediateAssignment ia_um; |
| 781 | ia_um := f_L1CTL_WAIT_IMM_ASS(L1CTL, ra, fn); |
| 782 | /* enable dedicated mode */ |
| 783 | f_L1CTL_DM_EST_REQ_IA(L1CTL, ia_um); |
| 784 | } |
| 785 | |
| 786 | /* establish DChan, verify existance + contents of measurement reports */ |
| 787 | function f_TC_meas_res_periodic(charstring id) runs on ConnHdlr { |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 788 | f_l1_tune(L1CTL); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 789 | RSL.clear; |
| 790 | |
| 791 | g_pars.l1_pars.meas_ul.full.rxlev := dbm2rxlev(-100); |
| 792 | g_pars.l1_pars.meas_ul.sub.rxlev := g_pars.l1_pars.meas_ul.full.rxlev; |
| 793 | f_trxc_fake_rssi(100); |
| 794 | |
| 795 | g_pars.l1_pars.timing_offset_256syms := 512; /* 2 symbols */ |
| 796 | f_trx_fake_toffs256(g_pars.l1_pars.timing_offset_256syms); |
| 797 | |
| 798 | f_est_dchan(); |
| 799 | |
| 800 | /* run for a number of seconds, send SACCH + FACCH from MS side and verify |
| 801 | * RSL measurement reports on Abis side */ |
| 802 | timer T := 8.0; |
| 803 | T.start; |
| 804 | alt { |
| 805 | [] as_l1_sacch(); |
| 806 | [] as_meas_res(); |
| 807 | [] as_l1_dcch(); |
| 808 | [] L1CTL.receive { repeat; } |
| 809 | [g_Tmeas_exp.running] T.timeout { |
| 810 | /* as_meas_res() would have done setverdict(fail) / self.stop in case |
| 811 | * of any earlier errors, so if we reach this timeout, we're good */ |
| 812 | setverdict(pass); |
| 813 | } |
| 814 | [] T.timeout { |
| 815 | setverdict(fail, "No MEAS RES received at all"); |
| 816 | } |
| 817 | } |
| 818 | f_rsl_chan_deact(); |
| 819 | } |
| 820 | testcase TC_meas_res_sign_tchf() runs on test_CT { |
| 821 | var ConnHdlr vc_conn; |
| 822 | var ConnHdlrPars pars; |
| 823 | f_init(testcasename()); |
| 824 | for (var integer tn := 1; tn <= 4; tn := tn+1) { |
| 825 | pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN)); |
| 826 | vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars); |
| 827 | vc_conn.done; |
| 828 | } |
| 829 | } |
| 830 | testcase TC_meas_res_sign_tchh() runs on test_CT { |
| 831 | var ConnHdlr vc_conn; |
| 832 | var ConnHdlrPars pars; |
| 833 | f_init(testcasename()); |
| 834 | for (var integer ss := 0; ss <= 1; ss := ss+1) { |
| 835 | pars := valueof(t_Pars(t_RslChanNr_Lm(5, ss), ts_RSL_ChanMode_SIGN)); |
| 836 | vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars); |
| 837 | vc_conn.done; |
| 838 | } |
| 839 | } |
| 840 | testcase TC_meas_res_sign_sdcch4() runs on test_CT { |
| 841 | var ConnHdlr vc_conn; |
| 842 | var ConnHdlrPars pars; |
| 843 | f_init(testcasename()); |
| 844 | for (var integer ss := 0; ss <= 3; ss := ss+1) { |
| 845 | pars := valueof(t_Pars(t_RslChanNr_SDCCH4(0, ss), ts_RSL_ChanMode_SIGN)); |
| 846 | vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars); |
| 847 | vc_conn.done; |
| 848 | } |
| 849 | } |
| 850 | testcase TC_meas_res_sign_sdcch8() runs on test_CT { |
| 851 | var ConnHdlr vc_conn; |
| 852 | var ConnHdlrPars pars; |
| 853 | f_init(testcasename()); |
| 854 | for (var integer ss := 0; ss <= 7; ss := ss+1) { |
| 855 | pars := valueof(t_Pars(t_RslChanNr_SDCCH8(6, ss), ts_RSL_ChanMode_SIGN)); |
| 856 | vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars); |
| 857 | vc_conn.done; |
| 858 | } |
| 859 | } |
| 860 | |
| 861 | /* Test if a channel without valid uplink bursts generates RSL CONN FAIL IND */ |
| 862 | private function f_TC_conn_fail_crit(charstring id) runs on ConnHdlr { |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 863 | f_l1_tune(L1CTL); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 864 | RSL.clear; |
| 865 | |
| 866 | f_est_dchan(); |
| 867 | f_sleep(2.0); |
| 868 | L1CTL.send(t_L1CTL_DM_REL_REQ(g_chan_nr)); |
| 869 | |
| 870 | timer T := 40.0; |
| 871 | T.start; |
| 872 | alt { |
| 873 | [] RSL.receive(tr_RSL_CONN_FAIL_IND(g_chan_nr, ?)) { |
| 874 | setverdict(pass) |
| 875 | } |
| 876 | [] RSL.receive { repeat }; |
| 877 | [] T.timeout { |
| 878 | setverdict(fail, "No CONN FAIL IND received"); |
| 879 | } |
| 880 | } |
| 881 | f_rsl_chan_deact(); |
| 882 | } |
| 883 | testcase TC_conn_fail_crit() runs on test_CT { |
| 884 | var ConnHdlr vc_conn; |
| 885 | var ConnHdlrPars pars; |
| 886 | f_init(testcasename()); |
| 887 | pars := valueof(t_Pars(t_RslChanNr_SDCCH8(6, 3), ts_RSL_ChanMode_SIGN)); |
| 888 | pars.t_guard := 60.0; |
| 889 | vc_conn := f_start_handler(refers(f_TC_conn_fail_crit), pars); |
| 890 | vc_conn.done; |
| 891 | } |
| 892 | |
Harald Welte | 93640c6 | 2018-02-25 16:59:33 +0100 | [diff] [blame] | 893 | /*********************************************************************** |
| 894 | * Paging |
| 895 | ***********************************************************************/ |
| 896 | |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 897 | function tmsi_is_dummy(TMSIP_TMSI_V tmsi) return boolean { |
| 898 | if (tmsi == 'FFFFFFFF'O) { |
| 899 | return true; |
| 900 | } else { |
| 901 | return false; |
| 902 | } |
| 903 | } |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 904 | |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 905 | altstep as_l1_count_paging(inout integer num_paging_rcv_msgs, inout integer num_paging_rcv_ids) |
| 906 | runs on test_CT { |
| 907 | var L1ctlDlMessage dl; |
| 908 | [] L1CTL.receive(t_L1CTL_DATA_IND(t_RslChanNr_PCH_AGCH(0), ?, c_DummyUI)) { |
| 909 | repeat; |
| 910 | } |
| 911 | [] L1CTL.receive(t_L1CTL_DATA_IND(t_RslChanNr_PCH_AGCH(0))) -> value dl { |
| 912 | var octetstring without_plen := |
| 913 | substr(dl.payload.data_ind.payload, 1, lengthof(dl.payload.data_ind.payload)-1); |
| 914 | var PDU_ML3_NW_MS rr := dec_PDU_ML3_NW_MS(without_plen); |
| 915 | if (match(rr, tr_PAGING_REQ1)) { |
| 916 | num_paging_rcv_msgs := num_paging_rcv_msgs + 1; |
| 917 | num_paging_rcv_ids := num_paging_rcv_ids + 1; |
| 918 | if (isvalue(rr.msgs.rrm.pagingReq_Type1.mobileIdentity2)) { |
| 919 | num_paging_rcv_ids := num_paging_rcv_ids + 1; |
| 920 | } |
| 921 | } else if (match(rr, tr_PAGING_REQ2)) { |
| 922 | num_paging_rcv_msgs := num_paging_rcv_msgs + 1; |
| 923 | if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type2.mobileIdentity1)) { |
| 924 | num_paging_rcv_ids := num_paging_rcv_ids + 1; |
| 925 | } |
| 926 | if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type2.mobileIdentity2)) { |
| 927 | num_paging_rcv_ids := num_paging_rcv_ids + 1; |
| 928 | } |
| 929 | if (isvalue(rr.msgs.rrm.pagingReq_Type2.mobileIdentity3)) { |
| 930 | num_paging_rcv_ids := num_paging_rcv_ids + 1; |
| 931 | } |
| 932 | } else if (match(rr, tr_PAGING_REQ3)) { |
| 933 | num_paging_rcv_msgs := num_paging_rcv_msgs + 1; |
| 934 | if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type3.mobileIdentity1)) { |
| 935 | num_paging_rcv_ids := num_paging_rcv_ids + 1; |
| 936 | } |
| 937 | if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type3.mobileIdentity2)) { |
| 938 | num_paging_rcv_ids := num_paging_rcv_ids + 1; |
| 939 | } |
| 940 | if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type3.mobileIdentity3)) { |
| 941 | num_paging_rcv_ids := num_paging_rcv_ids + 1; |
| 942 | } |
| 943 | if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type3.mobileIdentity4)) { |
| 944 | num_paging_rcv_ids := num_paging_rcv_ids + 1; |
| 945 | } |
| 946 | } |
| 947 | repeat; |
| 948 | } |
| 949 | } |
| 950 | |
| 951 | type record PagingTestCfg { |
| 952 | boolean combined_ccch, |
| 953 | integer bs_ag_blks_res, |
| 954 | float load_factor, |
| 955 | boolean exp_load_ind, |
| 956 | boolean exp_overload, |
| 957 | boolean use_tmsi |
| 958 | } |
| 959 | |
| 960 | type record PagingTestState { |
| 961 | integer num_paging_sent, |
| 962 | integer num_paging_rcv_msgs, |
| 963 | integer num_paging_rcv_ids, |
| 964 | integer num_overload |
| 965 | } |
| 966 | |
| 967 | /* receive + ignore RSL RF RES IND */ |
| 968 | altstep as_rsl_res_ind() runs on test_CT { |
| 969 | [] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_RF_RES_IND)) { |
| 970 | repeat; |
| 971 | } |
| 972 | } |
| 973 | |
| 974 | /* Helper function for paging related testing */ |
| 975 | private function f_TC_paging(PagingTestCfg cfg) runs on test_CT return PagingTestState { |
| 976 | f_init(testcasename()); |
| 977 | f_init_l1ctl(); |
| 978 | f_l1_tune(L1CTL); |
| 979 | |
| 980 | var PagingTestState st := { |
| 981 | num_paging_sent := 0, |
| 982 | num_paging_rcv_msgs := 0, |
| 983 | num_paging_rcv_ids := 0, |
| 984 | num_overload := 0 |
| 985 | }; |
| 986 | |
| 987 | var float max_pch_blocks_per_sec := f_pch_block_rate_est(cfg.combined_ccch, cfg.bs_ag_blks_res); |
| 988 | var float max_pch_imsi_per_sec; |
| 989 | if (cfg.use_tmsi) { |
| 990 | max_pch_imsi_per_sec := max_pch_blocks_per_sec * 4.0; /* Type 3 */ |
| 991 | } else { |
| 992 | max_pch_imsi_per_sec := max_pch_blocks_per_sec * 2.0; /* Type 1 */ |
| 993 | } |
| 994 | var float pch_blocks_per_sec := max_pch_imsi_per_sec * cfg.load_factor; |
| 995 | var float interval := 1.0 / pch_blocks_per_sec; |
| 996 | log("pch_blocks_per_sec=", pch_blocks_per_sec, " interval=", interval); |
| 997 | |
| 998 | for (var integer i := 0; i < float2int(20.0/interval); i := i+1) { |
| 999 | /* build mobile Identity */ |
| 1000 | var MobileL3_CommonIE_Types.MobileIdentityLV mi; |
| 1001 | if (cfg.use_tmsi) { |
| 1002 | mi := valueof(ts_MI_TMSI_LV(f_rnd_octstring(4))); |
| 1003 | } else { |
| 1004 | mi := valueof(ts_MI_IMSI_LV(f_gen_imsi(i))); |
| 1005 | } |
| 1006 | var octetstring mi_enc_lv := enc_MobileIdentityLV(mi); |
| 1007 | var octetstring mi_enc := substr(mi_enc_lv, 1, lengthof(mi_enc_lv)-1); |
| 1008 | |
| 1009 | /* Send RSL PAGING COMMAND */ |
| 1010 | RSL_CCHAN.send(ts_RSL_UD(ts_RSL_PAGING_CMD(mi_enc, i mod 4))); |
| 1011 | st.num_paging_sent := st.num_paging_sent + 1; |
| 1012 | |
| 1013 | /* Wait for interval to next PAGING COMMAND */ |
| 1014 | timer T_itv := interval; |
| 1015 | T_itv.start; |
| 1016 | alt { |
| 1017 | /* check for presence of CCCH LOAD IND (paging load) */ |
| 1018 | [cfg.exp_overload] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_PAGING_LOAD_IND(0))) { |
| 1019 | st.num_overload := st.num_overload + 1; |
| 1020 | repeat; |
| 1021 | } |
| 1022 | [not cfg.exp_overload] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_PAGING_LOAD_IND(0))) { |
| 1023 | setverdict(fail, "Unexpected PCH Overload"); |
| 1024 | } |
| 1025 | [cfg.exp_load_ind] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_PAGING_LOAD_IND)) { |
| 1026 | log("Rx LOAD_IND"); |
| 1027 | /* FIXME: analyze/verify interval + contents */ |
| 1028 | repeat; |
| 1029 | } |
| 1030 | /* check if paging requests arrive on Um side */ |
| 1031 | [] as_l1_count_paging(st.num_paging_rcv_msgs, st.num_paging_rcv_ids); |
| 1032 | [] L1CTL.receive { repeat; } |
| 1033 | [] T_itv.timeout { } |
| 1034 | [] as_rsl_res_ind(); |
| 1035 | } |
| 1036 | } |
| 1037 | |
| 1038 | /* wait for max 18s for paging queue to drain (size: 200, ~ 13 per s -> 15s) */ |
| 1039 | timer T_wait := 18.0; |
| 1040 | T_wait.start; |
| 1041 | alt { |
| 1042 | [] as_l1_count_paging(st.num_paging_rcv_msgs, st.num_paging_rcv_ids); |
| 1043 | [] L1CTL.receive { repeat; } |
| 1044 | /* 65535 == empty paging queue, we can terminate*/ |
| 1045 | [] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_PAGING_LOAD_IND(65535))) { } |
| 1046 | [] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_PAGING_LOAD_IND)) { repeat; } |
| 1047 | [] T_wait.timeout { |
| 1048 | setverdict(fail, "Waiting for empty paging queue"); |
| 1049 | } |
| 1050 | [] as_rsl_res_ind(); |
| 1051 | } |
| 1052 | |
| 1053 | log("num_paging_sent=", st.num_paging_sent, " rcvd_msgs=", st.num_paging_rcv_msgs, |
| 1054 | " rcvd_ids=", st.num_paging_rcv_ids); |
| 1055 | return st; |
| 1056 | } |
| 1057 | |
| 1058 | /* Create ~ 80% paging load (IMSI only) sustained for about 20s, verifying that |
| 1059 | * - the number of Mobile Identities on Um PCH match the number of pages on RSL |
| 1060 | * - that CCCH LOAD IND (PCH) are being generated |
| 1061 | * - that CCCH LOAD IND (PCH) [no load] is received after paging flood is over */ |
| 1062 | testcase TC_paging_imsi_80percent() runs on test_CT { |
| 1063 | var PagingTestCfg cfg := { |
| 1064 | combined_ccch := true, |
| 1065 | bs_ag_blks_res := 1, |
| 1066 | load_factor := 0.8, |
| 1067 | exp_load_ind := true, |
| 1068 | exp_overload := false, |
| 1069 | use_tmsi := false |
| 1070 | }; |
| 1071 | var PagingTestState st := f_TC_paging(cfg); |
| 1072 | if (st.num_paging_sent != st.num_paging_rcv_ids) { |
| 1073 | setverdict(fail, "Expected ", st.num_paging_sent, " pagings but have ", |
| 1074 | st.num_paging_rcv_ids); |
| 1075 | } else { |
| 1076 | setverdict(pass); |
| 1077 | } |
| 1078 | } |
| 1079 | |
| 1080 | /* Create ~ 80% paging load (TMSI only) sustained for about 20s, verifying that |
| 1081 | * - the number of Mobile Identities on Um PCH match the number of pages on RSL |
| 1082 | * - that CCCH LOAD IND (PCH) are being generated |
| 1083 | * - that CCCH LOAD IND (PCH) [no load] is received after paging flood is over */ |
| 1084 | testcase TC_paging_tmsi_80percent() runs on test_CT { |
| 1085 | var PagingTestCfg cfg := { |
| 1086 | combined_ccch := true, |
| 1087 | bs_ag_blks_res := 1, |
| 1088 | load_factor := 0.8, |
| 1089 | exp_load_ind := true, |
| 1090 | exp_overload := false, |
| 1091 | use_tmsi := true |
| 1092 | }; |
| 1093 | var PagingTestState st := f_TC_paging(cfg); |
| 1094 | if (st.num_paging_sent != st.num_paging_rcv_ids) { |
| 1095 | setverdict(fail, "Expected ", st.num_paging_sent, " pagings but have ", |
| 1096 | st.num_paging_rcv_ids); |
| 1097 | } else { |
| 1098 | setverdict(pass); |
| 1099 | } |
| 1100 | } |
| 1101 | |
| 1102 | /* Create ~ 200% paging load (IMSI only) sustained for about 20s, verifying that |
| 1103 | * - the number of Mobile Identities on Um PCH are ~ 82% of the number of pages on RSL |
| 1104 | * - that CCCH LOAD IND (PCH) are being generated and reach 0 at some point |
| 1105 | * - that CCCH LOAD IND (PCH) [no load] is received after paging flood is over */ |
| 1106 | testcase TC_paging_imsi_200percent() runs on test_CT { |
| 1107 | var PagingTestCfg cfg := { |
| 1108 | combined_ccch := true, |
| 1109 | bs_ag_blks_res := 1, |
| 1110 | load_factor := 2.0, |
| 1111 | exp_load_ind := true, |
| 1112 | exp_overload := true, |
| 1113 | use_tmsi := false |
| 1114 | }; |
| 1115 | var PagingTestState st := f_TC_paging(cfg); |
| 1116 | /* We expect about 80-85% to pass, given that we can fill the paging buffer of 200 |
| 1117 | * slots and will fully drain that buffer before returning */ |
| 1118 | var template integer tpl := (st.num_paging_sent*80/100 .. st.num_paging_sent *85/100); |
| 1119 | if (not match(st.num_paging_rcv_ids, tpl)) { |
| 1120 | setverdict(fail, "Expected ", tpl, " pagings but have ", st.num_paging_rcv_ids); |
| 1121 | } else { |
| 1122 | setverdict(pass); |
| 1123 | } |
| 1124 | } |
| 1125 | |
| 1126 | /* Create ~ 200% paging load (TMSI only) sustained for about 20s, verifying that |
| 1127 | * - the number of Mobile Identities on Um PCH are ~ 82% of the number of pages on RSL |
| 1128 | * - that CCCH LOAD IND (PCH) are being generated and reach 0 at some point |
| 1129 | * - that CCCH LOAD IND (PCH) [no load] is received after paging flood is over */ |
| 1130 | testcase TC_paging_tmsi_200percent() runs on test_CT { |
| 1131 | var PagingTestCfg cfg := { |
| 1132 | combined_ccch := true, |
| 1133 | bs_ag_blks_res := 1, |
| 1134 | load_factor := 2.0, |
| 1135 | exp_load_ind := true, |
| 1136 | exp_overload := true, |
| 1137 | use_tmsi := true |
| 1138 | }; |
| 1139 | var PagingTestState st := f_TC_paging(cfg); |
| 1140 | /* We expect about 70% to pass, given that we can fill the paging buffer of 200 |
| 1141 | * slots and will fully drain that buffer before returning */ |
| 1142 | var template integer tpl := (st.num_paging_sent*68/100 .. st.num_paging_sent *72/100); |
| 1143 | if (not match(st.num_paging_rcv_ids, tpl)) { |
| 1144 | setverdict(fail, "Expected ", tpl, " pagings but have ", st.num_paging_rcv_ids); |
| 1145 | } else { |
| 1146 | setverdict(pass); |
| 1147 | } |
| 1148 | } |
| 1149 | |
| 1150 | |
Harald Welte | 93640c6 | 2018-02-25 16:59:33 +0100 | [diff] [blame] | 1151 | /*********************************************************************** |
| 1152 | * Immediate Assignment / AGCH |
| 1153 | ***********************************************************************/ |
| 1154 | |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 1155 | testcase TC_imm_ass() runs on test_CT { |
| 1156 | f_init(testcasename()); |
| 1157 | for (var integer i := 0; i < 1000; i := i+1) { |
| 1158 | var octetstring ia_enc := f_rnd_octstring(8); |
| 1159 | RSL_CCHAN.send(ts_RSL_UD(ts_RSL_IMM_ASSIGN(ia_enc, 0))); |
| 1160 | f_sleep(0.02); |
| 1161 | } |
| 1162 | /* FIXME: check if imm.ass arrive on Um side */ |
| 1163 | /* FIXME: check for DELETE INDICATION */ |
| 1164 | f_sleep(100.0); |
| 1165 | } |
| 1166 | |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 1167 | /*********************************************************************** |
| 1168 | * BCCH |
| 1169 | ***********************************************************************/ |
| 1170 | |
| 1171 | /* tuple of Frame Number + decoded SI */ |
| 1172 | type record SystemInformationFn { |
| 1173 | GsmFrameNumber frame_number, |
| 1174 | SystemInformation si |
| 1175 | } |
| 1176 | |
| 1177 | /* an arbitrary-length vector of decoded SI + gsmtap header */ |
| 1178 | type record of SystemInformationFn SystemInformationVector; |
| 1179 | |
| 1180 | /* an array of SI-vectors indexed by TC value */ |
| 1181 | type SystemInformationVector SystemInformationVectorPerTc[8]; |
| 1182 | |
| 1183 | /* determine if a given SI vector contains given SI type at least once */ |
| 1184 | function f_si_vecslot_contains(SystemInformationVector arr, RrMessageType key, boolean bcch_ext := false) return boolean { |
| 1185 | for (var integer i:= 0; i< sizeof(arr); i := i + 1) { |
| 1186 | var integer fn_mod51 := arr[i].frame_number mod 51; |
| 1187 | if (not bcch_ext and fn_mod51 == 2 or |
| 1188 | bcch_ext and fn_mod51 == 6) { |
| 1189 | if (arr[i].si.header.message_type == key) { |
| 1190 | return true; |
| 1191 | } |
| 1192 | } |
| 1193 | } |
| 1194 | return false; |
| 1195 | } |
| 1196 | |
| 1197 | /* ensure a given TC slot of the SI vector contains given SI type at least once at TC */ |
| 1198 | function f_ensure_si_vec_contains(SystemInformationVectorPerTc arr, integer tc, RrMessageType key, boolean ext_bcch := false) { |
| 1199 | if (not f_si_vecslot_contains(arr[tc], key, ext_bcch)) { |
| 1200 | setverdict(fail, "No ", key, " in TC=", tc, "!"); |
| 1201 | } |
| 1202 | } |
| 1203 | |
| 1204 | /* check if a given SI vector contains given SI type at least once on any TC */ |
| 1205 | function f_si_vec_contains(SystemInformationVectorPerTc arr, RrMessageType key) return boolean { |
| 1206 | for (var integer tc:= 0; tc < sizeof(arr); tc := tc + 1) { |
| 1207 | if (f_si_vecslot_contains(arr[tc], key) or |
| 1208 | f_si_vecslot_contains(arr[tc], key, true)) { |
| 1209 | return true; |
| 1210 | } |
| 1211 | } |
| 1212 | return false; |
| 1213 | } |
| 1214 | |
| 1215 | /* determine if a given SI vector contains given SI type at least N of M times */ |
| 1216 | function f_si_vecslot_contains_n_of_m(SystemInformationVector arr, RrMessageType key, boolean bcch_ext := false, integer n := 1, integer m := 4) return boolean { |
| 1217 | var integer count := 0; |
| 1218 | if (sizeof(arr) < m) { |
| 1219 | setverdict(fail, "Error: Insufficient SI in array"); |
| 1220 | self.stop; |
| 1221 | } |
| 1222 | for (var integer i:= 0; i < m; i := i + 1) { |
| 1223 | var integer fn_mod51 := arr[i].frame_number mod 51; |
| 1224 | if (not bcch_ext and fn_mod51 == 2 or |
| 1225 | bcch_ext and fn_mod51 == 6) { |
| 1226 | if (arr[i].si.header.message_type == key) { |
| 1227 | count := count + 1; |
| 1228 | } |
| 1229 | } |
| 1230 | } |
| 1231 | if (count >= n) { |
| 1232 | return true; |
| 1233 | } else { |
| 1234 | return false; |
| 1235 | } |
| 1236 | } |
| 1237 | |
| 1238 | /* ensure a given TC slot of the SI vector contains given SI type at least N out of M times at TC */ |
| 1239 | function f_ensure_si_vec_contains_n_of_m(SystemInformationVectorPerTc arr, integer tc, RrMessageType key, boolean ext_bcch := false, integer n, integer m) { |
| 1240 | if (not f_si_vecslot_contains_n_of_m(arr[tc], key, ext_bcch, n, m)) { |
| 1241 | setverdict(fail, "Not ", n, "/", m, " of ", key, " in TC=", tc, "!"); |
| 1242 | } |
| 1243 | } |
| 1244 | |
| 1245 | /* determine if a given SI vector contains given SI type at least once */ |
| 1246 | function f_si_vecslot_contains_only(SystemInformationVector arr, RrMessageType key, boolean bcch_ext := false) return boolean { |
| 1247 | for (var integer i:= 0; i< sizeof(arr); i := i + 1) { |
| 1248 | var integer fn_mod51 := arr[i].frame_number mod 51; |
| 1249 | if (not bcch_ext and fn_mod51 == 2 or |
| 1250 | bcch_ext and fn_mod51 == 6) { |
| 1251 | if (arr[i].si.header.message_type != key) { |
| 1252 | return false; |
| 1253 | } |
| 1254 | } |
| 1255 | } |
| 1256 | return true; |
| 1257 | } |
| 1258 | |
| 1259 | /* ensure a given TC slot of the SI vector contains only given SI type */ |
| 1260 | function f_ensure_si_vec_contains_only(SystemInformationVectorPerTc arr, integer tc, RrMessageType key, boolean ext_bcch := false) { |
| 1261 | if (not f_si_vecslot_contains_only(arr[tc], key, ext_bcch)) { |
| 1262 | setverdict(fail, "Not all ", key, " in TC=", tc, "!"); |
| 1263 | } |
| 1264 | } |
| 1265 | |
| 1266 | /* SI configuration of cell, against which we validate actual SI messages */ |
| 1267 | type set SystemInformationConfig { |
| 1268 | boolean bcch_extended, |
| 1269 | boolean si1_present, |
| 1270 | boolean si2bis_present, |
| 1271 | boolean si2ter_present, |
| 1272 | boolean si2quater_present, |
| 1273 | boolean si7_present, |
| 1274 | boolean si8_present, |
| 1275 | boolean si9_present, |
| 1276 | boolean si13_present, |
| 1277 | boolean si13alt_present, |
| 1278 | boolean si15_present, |
| 1279 | boolean si16_present, |
| 1280 | boolean si17_present, |
| 1281 | boolean si2n_present, |
| 1282 | boolean si21_present, |
| 1283 | boolean si22_present |
| 1284 | } |
| 1285 | |
| 1286 | /* validate the SI scheduling according to TS 45.002 version 14.1.0 Release 14, Section 6.3.1.3 */ |
| 1287 | function f_validate_si_scheduling(SystemInformationConfig cfg, SystemInformationVectorPerTc si_per_tc) { |
| 1288 | var integer i; |
| 1289 | for (i := 0; i < sizeof(si_per_tc); i := i + 1) { |
| 1290 | if (sizeof(si_per_tc[i]) == 0) { |
| 1291 | setverdict(fail, "No SI messages for TC=0!"); |
| 1292 | } |
| 1293 | } |
| 1294 | if (cfg.si1_present) { |
| 1295 | /* ii) System Information Type 1 needs to be sent if frequency hopping is in use or |
| 1296 | * when the NCH is present in a cell. If the MS finds another message on BCCH Norm |
| 1297 | * when TC = 0, it can assume that System Information Type 1 is not in use. */ |
| 1298 | f_ensure_si_vec_contains(si_per_tc, 0, SYSTEM_INFORMATION_TYPE_1); |
| 1299 | /* make sure *ALL* contain SI1 */ |
| 1300 | f_ensure_si_vec_contains_only(si_per_tc, 0, SYSTEM_INFORMATION_TYPE_1); |
| 1301 | } |
| 1302 | f_ensure_si_vec_contains(si_per_tc, 1, SYSTEM_INFORMATION_TYPE_2); |
| 1303 | /* iii) A SI 2 message will be sent at least every time TC = 1 */ |
| 1304 | f_ensure_si_vec_contains(si_per_tc, 2, SYSTEM_INFORMATION_TYPE_3); |
| 1305 | f_ensure_si_vec_contains(si_per_tc, 6, SYSTEM_INFORMATION_TYPE_3); |
| 1306 | f_ensure_si_vec_contains(si_per_tc, 3, SYSTEM_INFORMATION_TYPE_4); |
| 1307 | f_ensure_si_vec_contains(si_per_tc, 7, SYSTEM_INFORMATION_TYPE_4); |
| 1308 | |
| 1309 | /* iii) System information type 2 bis or 2 ter messages are sent if needed, as determined by the |
| 1310 | * system operator. If only one of them is needed, it is sent when TC = 5. If both are |
| 1311 | * needed, 2bis is sent when TC = 5 and 2ter is sent at least once within any of 4 |
| 1312 | * consecutive occurrences of TC = 4. */ |
| 1313 | if (cfg.si2bis_present and not cfg.si2ter_present) { |
| 1314 | f_ensure_si_vec_contains(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2bis); |
| 1315 | } else if (cfg.si2ter_present and not cfg.si2bis_present) { |
| 1316 | f_ensure_si_vec_contains(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2ter); |
| 1317 | } else if (cfg.si2ter_present and cfg.si2bis_present) { |
| 1318 | f_ensure_si_vec_contains(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2bis); |
| 1319 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_2ter, false, 1, 4); |
| 1320 | } |
| 1321 | |
| 1322 | if (cfg.si7_present or cfg.si8_present) { |
| 1323 | /* vi) Use of System Information type 7 and 8 is not always necessary. It is necessary |
| 1324 | * if System Information type 4 does not contain all information needed for cell |
| 1325 | * selection and reselection. */ |
| 1326 | if (not cfg.bcch_extended) { |
| 1327 | testcase.stop("Error: SI7/SI8 require BCCH Extd."); |
| 1328 | } |
| 1329 | if (cfg.si7_present) { |
| 1330 | f_ensure_si_vec_contains(si_per_tc, 7, SYSTEM_INFORMATION_TYPE_7, true); |
| 1331 | } |
| 1332 | if (cfg.si8_present) { |
| 1333 | f_ensure_si_vec_contains(si_per_tc, 3, SYSTEM_INFORMATION_TYPE_8, true); |
| 1334 | } |
| 1335 | } |
| 1336 | |
| 1337 | if (cfg.si2quater_present) { |
| 1338 | /* iii) System information type 2 quater is sent if needed, as determined by the system |
| 1339 | * operator. If sent on BCCH Norm, it shall be sent when TC = 5 if neither of 2bis |
| 1340 | * and 2ter are used, otherwise it shall be sent at least once within any of 4 |
| 1341 | * consecutive occurrences of TC = 4. If sent on BCCH Ext, it is sent at least once |
| 1342 | * within any of 4 consecutive occurrences of TC = 5. */ |
| 1343 | if (not (cfg.bcch_extended)) { |
| 1344 | if (not (cfg.si2bis_present or cfg.si2ter_present)) { |
| 1345 | f_ensure_si_vec_contains(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2quater); |
| 1346 | } else { |
| 1347 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_2quater, false, 1, 4); |
| 1348 | } |
| 1349 | } else { |
| 1350 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2quater, true, 1, 4); |
| 1351 | } |
| 1352 | } |
| 1353 | if (cfg.si9_present) { |
| 1354 | /* vi) System Information type 9 is sent in those blocks with TC = 4 which are specified |
| 1355 | * in system information type 3 as defined in 3GPP TS 44.018. */ |
| 1356 | f_ensure_si_vec_contains(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_9); // FIXME SI3 |
| 1357 | } |
| 1358 | if (cfg.si13_present) { |
| 1359 | /* vii) System Information type 13 is only related to the GPRS service. System Information |
| 1360 | * Type 13 need only be sent if GPRS support is indicated in one or more of System |
| 1361 | * Information Type 3 or 4 or 7 or 8 messages. These messages also indicate if the |
| 1362 | * message is sent on the BCCH Norm or if the message is transmitted on the BCCH Ext. |
| 1363 | * In the case that the message is sent on the BCCH Norm, it is sent at least once |
| 1364 | * within any of 4 consecutive occurrences of TC=4. */ |
| 1365 | if (not cfg.bcch_extended) { |
| 1366 | log("not-bccch-extended"); |
| 1367 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_13, false, 1, 4); |
| 1368 | } else { |
| 1369 | log("bccch-extended"); |
| 1370 | f_ensure_si_vec_contains(si_per_tc, 0, SYSTEM_INFORMATION_TYPE_13, true); |
| 1371 | } |
| 1372 | if (f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_13alt)) { |
| 1373 | setverdict(fail, "Cannot have SI13alt and SI13"); |
| 1374 | } |
| 1375 | } |
| 1376 | if (cfg.si16_present or cfg.si17_present) { |
| 1377 | /* viii) System Information type 16 and 17 are only related to the SoLSA service. They |
| 1378 | * should not be sent in a cell where network sharing is used (see rule xv). */ |
| 1379 | if (cfg.si22_present) { |
| 1380 | testcase.stop("Error: Cannot have SI16/SI17 and SI22!"); |
| 1381 | } |
| 1382 | if (f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_22)) { |
| 1383 | setverdict(fail, "Cannot have SI16/SI17 and SI22!"); |
| 1384 | } |
| 1385 | if (not cfg.bcch_extended) { |
| 1386 | testcase.stop("Error: SI16/SI17 requires BCCH Extd!"); |
| 1387 | } |
| 1388 | if (cfg.si16_present) { |
| 1389 | f_ensure_si_vec_contains(si_per_tc, 6, SYSTEM_INFORMATION_TYPE_16, true); |
| 1390 | } |
| 1391 | if (cfg.si17_present) { |
| 1392 | f_ensure_si_vec_contains(si_per_tc, 2, SYSTEM_INFORMATION_TYPE_17, true); |
| 1393 | } |
| 1394 | } |
| 1395 | |
| 1396 | /* ix) System Information type 18 and 20 are sent in order to transmit non-GSM |
| 1397 | * broadcast information. The frequency with which they are sent is determined by the |
| 1398 | * system operator. System Information type 9 identifies the scheduling of System |
| 1399 | * Information type 18 and 20 messages. */ |
| 1400 | |
| 1401 | /* x) System Information Type 19 is sent if COMPACT neighbours exist. If System |
| 1402 | * Information Type 19 is present, then its scheduling shall be indicated in System |
| 1403 | * Information Type 9. */ |
| 1404 | |
| 1405 | if (cfg.si15_present) { |
| 1406 | /* xi) System Information Type 15 is broadcast if dynamic ARFCN mapping is used in the |
| 1407 | * PLMN. If sent on BCCH Norm, it is sent at least once within any of 4 consecutive |
| 1408 | * occurrences of TC = 4. If sent on BCCH Ext, it is sent at least once within any of |
| 1409 | * 4 consecutive occurrences of TC = 1. */ |
| 1410 | if (not cfg.bcch_extended) { |
| 1411 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_15, false, 1, 4); |
| 1412 | } else { |
| 1413 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 1, SYSTEM_INFORMATION_TYPE_15, true, 1, 4); |
| 1414 | } |
| 1415 | } |
| 1416 | if (cfg.si13alt_present) { |
| 1417 | /* xii) System Information type 13 alt is only related to the GERAN Iu mode. System |
| 1418 | * Information Type 13 alt need only be sent if GERAN Iu mode support is indicated in |
| 1419 | * one or more of System Information Type 3 or 4 or 7 or 8 messages and SI 13 is not |
| 1420 | * broadcast. These messages also indicate if the message is sent on the BCCH Norm or |
| 1421 | * if the message is transmitted on the BCCH Ext. In the case that the message is sent |
| 1422 | * on the BCCH Norm, it is sent at least once within any of 4 consecutive occurrences |
| 1423 | * of TC = 4. */ |
| 1424 | if (cfg.si13_present) { |
| 1425 | testcase.stop("Error: Cannot have SI13alt and SI13"); |
| 1426 | } |
| 1427 | if (f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_13)) { |
| 1428 | setverdict(fail, "Cannot have SI13alt and SI13"); |
| 1429 | } |
| 1430 | if (not cfg.bcch_extended) { |
| 1431 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_13alt, false, 1, 4); |
| 1432 | } else { |
| 1433 | f_ensure_si_vec_contains(si_per_tc, 0, SYSTEM_INFORMATION_TYPE_13alt, true); |
| 1434 | } |
| 1435 | } |
| 1436 | if (cfg.si2n_present) { |
| 1437 | /* xiii) System Information Type 2n is optionally sent on BCCH Norm or BCCH Ext if needed, |
| 1438 | * as determined by the system operator. In the case that the message is sent on the |
| 1439 | * BCCH Norm, it is sent at least once within any of 4 consecutive occurrences of TC = |
| 1440 | * 4. If the message is sent on BCCH Ext, it is sent at least once within any of 2 |
| 1441 | * consecutive occurrences of TC = 4. */ |
| 1442 | if (not cfg.bcch_extended) { |
| 1443 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_2n, false, 1, 4); |
| 1444 | } else { |
| 1445 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_2n, true, 2, 4); |
| 1446 | } |
| 1447 | } |
| 1448 | if (cfg.si21_present) { |
| 1449 | /* xiv) System Information Type 21 is optionally sent on BCCH Norm or BCCH Ext, as |
| 1450 | * determined by the system operator. If Extended Access Barring is in use in the cell |
| 1451 | * then this message is sent at least once within any of 4 consecutive occurrences of |
| 1452 | * TC = 4 regardless if it is sent on BCCH Norm or BCCH Ext. If BCCH Ext is used in a |
| 1453 | * cell then this message shall only be sent on BCCH Ext. */ |
| 1454 | if (not cfg.bcch_extended) { |
| 1455 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_21, false, 1, 4); |
| 1456 | } else { |
| 1457 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_21, true, 1, 4); |
| 1458 | if (f_si_vecslot_contains(si_per_tc[4], SYSTEM_INFORMATION_TYPE_21)) { |
| 1459 | setverdict(fail, "Cannot have SI21 on BCCH Norm if BCCH Extd enabled!"); |
| 1460 | } |
| 1461 | } |
| 1462 | } |
| 1463 | if (cfg.si22_present) { |
| 1464 | /* xv) System Information Type 22 is sent if network sharing is in use in the cell. It |
| 1465 | * should not be sent in a cell where SoLSA is used (see rule viii). System |
| 1466 | * Information Type 22 instances shall be sent on BCCH Ext within any occurrence of TC |
| 1467 | * =2 and TC=6. */ |
| 1468 | if (cfg.si16_present or cfg.si17_present) { |
| 1469 | testcase.stop("Error: Cannot have SI16/SI17 and SI22!"); |
| 1470 | } |
| 1471 | if (f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_16) or |
| 1472 | f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_17)) { |
| 1473 | setverdict(fail, "Cannot have SI16/SI17 and SI22!"); |
| 1474 | } |
| 1475 | if (not cfg.bcch_extended) { |
| 1476 | testcase.stop("Error: SI22 requires BCCH Extd!"); |
| 1477 | } else { |
| 1478 | f_ensure_si_vec_contains_only(si_per_tc, 2, SYSTEM_INFORMATION_TYPE_22, true); |
| 1479 | f_ensure_si_vec_contains_only(si_per_tc, 6, SYSTEM_INFORMATION_TYPE_22, true); |
| 1480 | } |
| 1481 | } |
| 1482 | } |
| 1483 | |
| 1484 | /* sample Systme Information for specified duration via L1CTL */ |
| 1485 | function f_l1_sample_si(L1CTL_PT pt, float duration := 8.0) return SystemInformationVectorPerTc { |
| 1486 | timer T := duration; |
| 1487 | var SystemInformationVectorPerTc si_per_tc; |
| 1488 | var L1ctlDlMessage l1_dl; |
| 1489 | |
| 1490 | /* initialize all per-TC vectors empty */ |
| 1491 | for (var integer i:= 0; i < sizeof(si_per_tc); i := i+1) { |
| 1492 | si_per_tc[i] := {}; |
| 1493 | } |
| 1494 | |
| 1495 | /* flush all previous L1 queued msgs */ |
| 1496 | pt.clear; |
| 1497 | |
| 1498 | T.start; |
| 1499 | alt { |
| 1500 | [] pt.receive(t_L1CTL_DATA_IND(t_RslChanNr_BCCH(0), ?)) -> value l1_dl { |
| 1501 | /* somehow dec_SystemInformation will try to decode even non-RR as SI */ |
| 1502 | if (not (l1_dl.payload.data_ind.payload[1] == '06'O)) { |
| 1503 | log("Ignoring non-RR SI ", l1_dl); |
| 1504 | repeat; |
| 1505 | } |
| 1506 | var SystemInformationFn sig := { |
| 1507 | frame_number := l1_dl.dl_info.frame_nr, |
| 1508 | si := dec_SystemInformation(l1_dl.payload.data_ind.payload) |
| 1509 | } |
| 1510 | var integer tc := f_gsm_compute_tc(sig.frame_number); |
| 1511 | log("SI received at TC=", tc, ": ", sig.si); |
| 1512 | /* append to the per-TC bucket */ |
| 1513 | si_per_tc[tc] := si_per_tc[tc] & { sig }; |
| 1514 | repeat; |
| 1515 | } |
| 1516 | [] pt.receive { repeat; } |
| 1517 | [] T.timeout { } |
| 1518 | } |
| 1519 | |
| 1520 | for (var integer i:= 0; i < sizeof(si_per_tc); i := i+1) { |
| 1521 | log(testcasename(), ": TC=", i, " has #of SI=", sizeof(si_per_tc[i])); |
| 1522 | } |
| 1523 | log("si_per_tc=", si_per_tc); |
| 1524 | return si_per_tc; |
| 1525 | } |
| 1526 | |
| 1527 | /* helper function: Set given SI via RSL + validate scheduling. |
| 1528 | * CALLER MUST MAKE SURE TO CHANGE GLOBAL si_cfg! */ |
| 1529 | function f_TC_si_sched() runs on test_CT { |
| 1530 | var SystemInformationVectorPerTc si_per_tc; |
| 1531 | f_init_l1ctl(); |
| 1532 | f_l1_tune(L1CTL); |
| 1533 | |
| 1534 | /* Sample + Validate Scheduling */ |
| 1535 | si_per_tc := f_l1_sample_si(L1CTL); |
| 1536 | f_validate_si_scheduling(si_cfg, si_per_tc); |
| 1537 | |
| 1538 | setverdict(pass); |
| 1539 | } |
| 1540 | |
| 1541 | testcase TC_si_sched_default() runs on test_CT { |
| 1542 | f_init(); |
| 1543 | f_rsl_bcch_fill(RSL_SYSTEM_INFO_2, ts_SI2_default); |
| 1544 | f_rsl_bcch_fill(RSL_SYSTEM_INFO_4, ts_SI4_default); |
| 1545 | f_TC_si_sched(); |
| 1546 | } |
| 1547 | |
| 1548 | testcase TC_si_sched_2bis() runs on test_CT { |
| 1549 | f_init(); |
| 1550 | si_cfg.si2bis_present := true; |
| 1551 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2bis, '550602bfe809b3ff00000000000000000000007900002b'O); |
| 1552 | f_TC_si_sched(); |
| 1553 | } |
| 1554 | |
| 1555 | testcase TC_si_sched_2ter() runs on test_CT { |
| 1556 | f_init(); |
| 1557 | si_cfg.si2ter_present := true; |
| 1558 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2ter, '010603bf66b0aa0a00000002000000000000002b2b2b2b'O); |
| 1559 | f_TC_si_sched(); |
| 1560 | } |
| 1561 | |
| 1562 | testcase TC_si_sched_2ter_2bis() runs on test_CT { |
| 1563 | f_init(); |
| 1564 | si_cfg.si2bis_present := true; |
| 1565 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2bis, '550602bfe809b3ff00000000000000000000007900002b'O); |
| 1566 | si_cfg.si2ter_present := true; |
| 1567 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2ter, '010603bf66b0aa0a00000002000000000000002b2b2b2b'O); |
| 1568 | f_TC_si_sched(); |
| 1569 | } |
| 1570 | |
| 1571 | testcase TC_si_sched_2quater() runs on test_CT { |
| 1572 | f_init(); |
| 1573 | si_cfg.si2quater_present := true; |
| 1574 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2quater, '050607a8a0364aa698d72ff424feee0506d5e7fff02043'O); |
| 1575 | f_TC_si_sched(); |
| 1576 | } |
| 1577 | |
| 1578 | testcase TC_si_sched_13() runs on test_CT { |
| 1579 | f_init(); |
| 1580 | si_cfg.si13_present := true; |
| 1581 | //f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_13, fixme); |
| 1582 | f_TC_si_sched(); |
| 1583 | } |
| 1584 | |
| 1585 | testcase TC_si_sched_13_2bis_2ter_2quater() runs on test_CT { |
| 1586 | f_init(); |
| 1587 | si_cfg.si2bis_present := true; |
| 1588 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2bis, '550602bfe809b3ff00000000000000000000007900002b'O); |
| 1589 | si_cfg.si2ter_present := true; |
| 1590 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2ter, '010603bf66b0aa0a00000002000000000000002b2b2b2b'O); |
| 1591 | si_cfg.si2quater_present := true; |
| 1592 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2quater, '050607a8a0364aa698d72ff424feee0506d5e7fff02043'O); |
| 1593 | si_cfg.si13_present := true; |
| 1594 | //f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_13, fixme); |
| 1595 | f_TC_si_sched(); |
| 1596 | } |
| 1597 | |
| 1598 | |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 1599 | testcase TC_bcch_info() runs on test_CT { |
| 1600 | f_init(testcasename()); |
| 1601 | /* FIXME: enable / disable individual BCCH info */ |
| 1602 | //ts_RSL_BCCH_INFO(si_type, info); |
| 1603 | /* expect no ERROR REPORT after either of them * |
| 1604 | /* negative test: ensure ERROR REPORT on unsupported types */ |
| 1605 | } |
| 1606 | |
Harald Welte | 93640c6 | 2018-02-25 16:59:33 +0100 | [diff] [blame] | 1607 | /*********************************************************************** |
| 1608 | * Low-Level Protocol Errors / ERROR REPORT |
| 1609 | ***********************************************************************/ |
| 1610 | |
Harald Welte | 01d982c | 2018-02-25 01:31:40 +0100 | [diff] [blame] | 1611 | private function f_exp_err_rep(template RSL_Cause cause) runs on test_CT { |
| 1612 | timer T := 5.0; |
| 1613 | T.start; |
| 1614 | alt { |
| 1615 | [] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_ERROR_REPORT(cause))) { |
| 1616 | setverdict(pass); |
| 1617 | } |
| 1618 | [] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_ERROR_REPORT(?))) { |
| 1619 | setverdict(fail, "Wrong cause in RSL ERR REP"); |
| 1620 | } |
| 1621 | [] RSL_CCHAN.receive { |
| 1622 | repeat; |
| 1623 | } |
| 1624 | [] T.timeout { |
| 1625 | setverdict(fail, "Timeout waiting for RSL ERR REP"); |
| 1626 | } |
| 1627 | } |
| 1628 | } |
| 1629 | |
| 1630 | /* Provoke a protocol error (message too short) and match on ERROR REPORT */ |
| 1631 | testcase TC_rsl_protocol_error() runs on test_CT { |
| 1632 | f_init(testcasename()); |
| 1633 | var RSL_Message rsl := valueof(ts_RSL_BCCH_INFO(RSL_SYSTEM_INFO_1, ''O)); |
| 1634 | rsl.ies := omit; |
| 1635 | RSL_CCHAN.send(ts_RSL_UD(rsl)); |
| 1636 | |
| 1637 | f_exp_err_rep(RSL_ERR_PROTO); |
| 1638 | } |
| 1639 | |
| 1640 | /* Provoke a mandatory IE error and match on ERROR REPORT */ |
| 1641 | testcase TC_rsl_mand_ie_error() runs on test_CT { |
| 1642 | f_init(testcasename()); |
| 1643 | |
| 1644 | var RSL_Message rsl := valueof(ts_RSL_BCCH_INFO(RSL_SYSTEM_INFO_1, ''O)); |
| 1645 | rsl.ies := { rsl.ies[0] }; |
| 1646 | RSL_CCHAN.send(ts_RSL_UD(rsl)); |
| 1647 | |
| 1648 | f_exp_err_rep(RSL_ERR_MAND_IE_ERROR); |
| 1649 | } |
| 1650 | |
| 1651 | /* Provoke an IE content error and match on ERROR REPORT */ |
| 1652 | testcase TC_rsl_ie_content_error() runs on test_CT { |
| 1653 | f_init(testcasename()); |
| 1654 | var RSL_Message rsl := valueof(ts_RSL_BCCH_INFO(RSL_SYSTEM_INFO_1, ''O)); |
| 1655 | rsl.ies[1].body.sysinfo_type := RSL_SYSTEM_INFO_5; |
| 1656 | RSL_CCHAN.send(ts_RSL_UD(rsl)); |
| 1657 | |
| 1658 | f_exp_err_rep(RSL_ERR_IE_CONTENT); |
| 1659 | } |
| 1660 | |
Harald Welte | 93640c6 | 2018-02-25 16:59:33 +0100 | [diff] [blame] | 1661 | /*********************************************************************** |
| 1662 | * IPA CRCX/MDCX/DLCS media stream handling |
| 1663 | ***********************************************************************/ |
| 1664 | |
Harald Welte | a871a38 | 2018-02-25 02:03:14 +0100 | [diff] [blame] | 1665 | /* Send IPA DLCX to inactive lchan */ |
| 1666 | function f_TC_ipa_dlcx_not_active(charstring id) runs on ConnHdlr { |
Harald Welte | 1eba374 | 2018-02-25 12:48:14 +0100 | [diff] [blame] | 1667 | f_rsl_transceive(ts_RSL_IPA_DLCX(g_chan_nr, 0), tr_RSL_IPA_DLCX_ACK(g_chan_nr, ?, ?), |
| 1668 | "IPA DLCX ACK"); |
Harald Welte | a871a38 | 2018-02-25 02:03:14 +0100 | [diff] [blame] | 1669 | } |
| 1670 | testcase TC_ipa_dlcx_not_active() runs on test_CT { |
| 1671 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 1672 | f_init(testcasename()); |
| 1673 | var ConnHdlr vc_conn := f_start_handler(refers(f_TC_ipa_dlcx_not_active), pars); |
| 1674 | vc_conn.done; |
| 1675 | } |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 1676 | |
Harald Welte | a3f1df9 | 2018-02-25 12:49:55 +0100 | [diff] [blame] | 1677 | /* Send IPA CRCX twice to inactive lchan */ |
| 1678 | function f_TC_ipa_crcx_twice_not_active(charstring id) runs on ConnHdlr { |
| 1679 | f_rsl_transceive(ts_RSL_IPA_CRCX(g_chan_nr), tr_RSL_IPA_CRCX_ACK(g_chan_nr, ?, ?, ?), |
| 1680 | "IPA CRCX ACK"); |
| 1681 | f_rsl_transceive(ts_RSL_IPA_CRCX(g_chan_nr), tr_RSL_IPA_CRCX_NACK(g_chan_nr, RSL_ERR_RES_UNAVAIL), |
| 1682 | "IPA CRCX NACK"); |
| 1683 | } |
| 1684 | testcase TC_ipa_crcx_twice_not_active() runs on test_CT { |
| 1685 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 1686 | f_init(testcasename()); |
| 1687 | var ConnHdlr vc_conn := f_start_handler(refers(f_TC_ipa_crcx_twice_not_active), pars); |
| 1688 | vc_conn.done; |
| 1689 | } |
| 1690 | |
| 1691 | /* Regular sequence of CRCX/MDCX/DLCX */ |
| 1692 | function f_TC_ipa_crcx_mdcx_dlcx_not_active(charstring id) runs on ConnHdlr { |
| 1693 | f_rsl_transceive(ts_RSL_IPA_CRCX(g_chan_nr), tr_RSL_IPA_CRCX_ACK(g_chan_nr, ?, ?, ?), |
| 1694 | "IPA CRCX ACK"); |
| 1695 | var uint32_t remote_ip := f_rnd_int(c_UINT32_MAX); |
| 1696 | var uint16_t remote_port := f_rnd_int(c_UINT16_MAX); |
| 1697 | var uint7_t rtp_pt2 := f_rnd_int(127); |
| 1698 | var uint16_t fake_conn_id := 23; /* we're too lazy to read it out from the CRCX ACK above */ |
| 1699 | f_rsl_transceive(ts_RSL_IPA_MDCX(g_chan_nr, fake_conn_id, remote_ip, remote_port, rtp_pt2), |
| 1700 | tr_RSL_IPA_MDCX_ACK(g_chan_nr, ?, ?, ?, rtp_pt2), |
| 1701 | "IPA MDCX ACK"); |
| 1702 | f_rsl_transceive(ts_RSL_IPA_DLCX(g_chan_nr, fake_conn_id), tr_RSL_IPA_DLCX_ACK(g_chan_nr, ?, ?), |
| 1703 | "IPA DLCX ACK"); |
| 1704 | } |
| 1705 | testcase TC_ipa_crcx_mdcx_dlcx_not_active() runs on test_CT { |
| 1706 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 1707 | f_init(testcasename()); |
| 1708 | var ConnHdlr vc_conn := f_start_handler(refers(f_TC_ipa_crcx_mdcx_dlcx_not_active), pars); |
| 1709 | vc_conn.done; |
| 1710 | } |
| 1711 | |
Harald Welte | 3ae11da | 2018-02-25 13:36:06 +0100 | [diff] [blame] | 1712 | /* Sequence of CRCX, 2x MDCX, DLCX */ |
| 1713 | function f_TC_ipa_crcx_mdcx_mdcx_dlcx_not_active(charstring id) runs on ConnHdlr { |
| 1714 | f_rsl_transceive(ts_RSL_IPA_CRCX(g_chan_nr), tr_RSL_IPA_CRCX_ACK(g_chan_nr, ?, ?, ?), |
| 1715 | "IPA CRCX ACK"); |
| 1716 | var uint32_t remote_ip := f_rnd_int(c_UINT32_MAX); |
| 1717 | var uint16_t remote_port := f_rnd_int(c_UINT16_MAX); |
| 1718 | var uint7_t rtp_pt2 := f_rnd_int(127); |
| 1719 | var uint16_t fake_conn_id := 23; /* we're too lazy to read it out from the CRCX ACK above */ |
| 1720 | f_rsl_transceive(ts_RSL_IPA_MDCX(g_chan_nr, fake_conn_id, remote_ip, remote_port, rtp_pt2), |
| 1721 | tr_RSL_IPA_MDCX_ACK(g_chan_nr, ?, ?, ?, rtp_pt2), |
| 1722 | "IPA MDCX ACK"); |
| 1723 | /* Second MDCX */ |
| 1724 | remote_ip := f_rnd_int(c_UINT32_MAX); |
| 1725 | remote_port := f_rnd_int(c_UINT16_MAX); |
| 1726 | f_rsl_transceive(ts_RSL_IPA_MDCX(g_chan_nr, fake_conn_id, remote_ip, remote_port, rtp_pt2), |
| 1727 | tr_RSL_IPA_MDCX_ACK(g_chan_nr, ?, ?, ?, rtp_pt2), |
| 1728 | "IPA MDCX ACK"); |
| 1729 | f_rsl_transceive(ts_RSL_IPA_DLCX(g_chan_nr, fake_conn_id), tr_RSL_IPA_DLCX_ACK(g_chan_nr, ?, ?), |
| 1730 | "IPA DLCX ACK"); |
| 1731 | } |
| 1732 | testcase TC_ipa_crcx_mdcx_mdcx_dlcx_not_active() runs on test_CT { |
| 1733 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 1734 | f_init(testcasename()); |
| 1735 | var ConnHdlr vc_conn := f_start_handler(refers(f_TC_ipa_crcx_mdcx_mdcx_dlcx_not_active), pars); |
| 1736 | vc_conn.done; |
| 1737 | } |
| 1738 | |
Harald Welte | 9912eb5 | 2018-02-25 13:30:15 +0100 | [diff] [blame] | 1739 | /* IPA CRCX on SDCCH/4 and SDCCH/8 (doesn't make sense) */ |
| 1740 | function f_TC_ipa_crcx_sdcch_not_active(charstring id) runs on ConnHdlr { |
| 1741 | f_rsl_transceive(ts_RSL_IPA_CRCX(g_chan_nr), tr_RSL_IPA_CRCX_NACK(g_chan_nr, ?), |
| 1742 | "IPA CRCX NACK"); |
| 1743 | } |
| 1744 | testcase TC_ipa_crcx_sdcch_not_active() runs on test_CT { |
| 1745 | var ConnHdlrPars pars; |
| 1746 | var ConnHdlr vc_conn; |
| 1747 | f_init(testcasename()); |
| 1748 | |
| 1749 | pars := valueof(t_Pars(t_RslChanNr_SDCCH4(0,1), ts_RSL_ChanMode_SIGN)); |
| 1750 | vc_conn := f_start_handler(refers(f_TC_ipa_crcx_sdcch_not_active), pars); |
| 1751 | vc_conn.done; |
| 1752 | |
| 1753 | pars := valueof(t_Pars(t_RslChanNr_SDCCH8(6,5), ts_RSL_ChanMode_SIGN)); |
| 1754 | vc_conn := f_start_handler(refers(f_TC_ipa_crcx_sdcch_not_active), pars); |
| 1755 | vc_conn.done; |
| 1756 | } |
| 1757 | |
Harald Welte | a3f1df9 | 2018-02-25 12:49:55 +0100 | [diff] [blame] | 1758 | |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 1759 | /* TODO Areas: |
| 1760 | |
| 1761 | * channel activation |
| 1762 | ** with BS_Power / MS_Power, bypassing power control loop |
| 1763 | ** on primary vs. secondary TRX |
| 1764 | ** with encryption from initial activation on |
| 1765 | ** with timing advance from initial activation on |
| 1766 | * mode modify |
| 1767 | ** encryption |
| 1768 | ** multirate |
| 1769 | * check DEACTIVATE SACCH |
| 1770 | * encryption command / intricate logic about tx-only/tx+rx/... |
| 1771 | ** unsupported algorithm |
| 1772 | * handover detection |
| 1773 | * MS Power Control |
| 1774 | * BS Power Control |
| 1775 | * Physical Context |
| 1776 | * SACCH info modify |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 1777 | * CCCH Load Indication for PCH and RACH |
| 1778 | * Delete Indication on AGCH overflow |
| 1779 | * SMS Broadcast Req / Cmd / CBCH LOad Ind |
| 1780 | * RF resource ind |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 1781 | * error handling |
| 1782 | * discriminator error |
| 1783 | ** type error |
| 1784 | ** sequence error |
| 1785 | ** IE duplicated? |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 1786 | |
| 1787 | */ |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1788 | |
| 1789 | control { |
| 1790 | execute( TC_chan_act_stress() ); |
| 1791 | execute( TC_chan_act_react() ); |
| 1792 | execute( TC_chan_deact_not_active() ); |
| 1793 | execute( TC_chan_act_wrong_nr() ); |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1794 | execute( TC_rach_content() ); |
| 1795 | execute( TC_rach_count() ); |
Harald Welte | 54a2a2d | 2018-02-26 09:14:05 +0100 | [diff] [blame] | 1796 | execute( TC_rach_max_ta() ); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1797 | execute( TC_meas_res_sign_tchf() ); |
| 1798 | execute( TC_meas_res_sign_tchh() ); |
| 1799 | execute( TC_meas_res_sign_sdcch4() ); |
| 1800 | execute( TC_meas_res_sign_sdcch8() ); |
| 1801 | execute( TC_conn_fail_crit() ); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 1802 | execute( TC_paging_imsi_80percent() ); |
| 1803 | execute( TC_paging_tmsi_80percent() ); |
| 1804 | execute( TC_paging_imsi_200percent() ); |
| 1805 | execute( TC_paging_tmsi_200percent() ); |
Harald Welte | 01d982c | 2018-02-25 01:31:40 +0100 | [diff] [blame] | 1806 | execute( TC_rsl_protocol_error() ); |
| 1807 | execute( TC_rsl_mand_ie_error() ); |
| 1808 | execute( TC_rsl_ie_content_error() ); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 1809 | execute( TC_si_sched_default() ); |
| 1810 | execute( TC_si_sched_2bis() ); |
| 1811 | execute( TC_si_sched_2ter() ); |
| 1812 | execute( TC_si_sched_2ter_2bis() ); |
| 1813 | execute( TC_si_sched_2quater() ); |
| 1814 | execute( TC_si_sched_13() ); |
| 1815 | execute( TC_si_sched_13_2bis_2ter_2quater() ); |
Harald Welte | a871a38 | 2018-02-25 02:03:14 +0100 | [diff] [blame] | 1816 | execute( TC_ipa_dlcx_not_active() ); |
Harald Welte | a3f1df9 | 2018-02-25 12:49:55 +0100 | [diff] [blame] | 1817 | execute( TC_ipa_crcx_twice_not_active() ); |
| 1818 | execute( TC_ipa_crcx_mdcx_dlcx_not_active() ); |
Harald Welte | 3ae11da | 2018-02-25 13:36:06 +0100 | [diff] [blame] | 1819 | execute( TC_ipa_crcx_mdcx_mdcx_dlcx_not_active() ); |
Harald Welte | 9912eb5 | 2018-02-25 13:30:15 +0100 | [diff] [blame] | 1820 | execute( TC_ipa_crcx_sdcch_not_active() ); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1821 | } |
| 1822 | |
| 1823 | |
| 1824 | } |