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