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