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