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