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