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