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; |
Neels Hofmeyr | 6a84b23 | 2018-04-03 19:12:36 +0200 | [diff] [blame] | 14 | import from Osmocom_CTRL_Functions all; |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 15 | |
| 16 | import from RSL_Types all; |
Harald Welte | 7484fc4 | 2018-02-24 14:09:45 +0100 | [diff] [blame] | 17 | import from IPA_Types all; |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 18 | import from IPA_Emulation all; |
| 19 | import from RSL_Emulation all; |
| 20 | |
| 21 | import from IPL4asp_Types all; |
| 22 | import from TRXC_Types all; |
| 23 | import from TRXC_CodecPort all; |
| 24 | import from TRXC_CodecPort_CtrlFunct all; |
| 25 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 26 | import from PCUIF_Types all; |
| 27 | import from PCUIF_CodecPort all; |
| 28 | |
Harald Welte | 7484fc4 | 2018-02-24 14:09:45 +0100 | [diff] [blame] | 29 | import from MobileL3_CommonIE_Types all; |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 30 | import from MobileL3_RRM_Types all; |
| 31 | import from MobileL3_Types all; |
| 32 | import from L3_Templates all; |
Harald Welte | 7484fc4 | 2018-02-24 14:09:45 +0100 | [diff] [blame] | 33 | |
Harald Welte | 8da4824 | 2018-02-27 20:41:32 +0100 | [diff] [blame] | 34 | import from Osmocom_VTY_Functions all; |
| 35 | import from TELNETasp_PortType all; |
| 36 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 37 | /* The tests assume a BTS with the following timeslot configuration: |
| 38 | * TS0 : Combined CCCH + SDCCH/4 |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 39 | * TS1 : TCH/F |
| 40 | * TS2 : TCH/F |
| 41 | * TS3 : TCH/F_PDCH (IPA Style) |
| 42 | * TS4 : TCH/F_TCH/H_PDCH (Osmocom Style) |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 43 | * TS5 : TCH/H |
| 44 | * TS6 : SDCCH/8 |
| 45 | * TS7 : PDCH |
| 46 | */ |
| 47 | |
| 48 | modulepar { |
| 49 | charstring mp_rsl_ip := "127.0.0.2"; |
| 50 | integer mp_rsl_port := 3003; |
| 51 | integer mp_trx0_arfcn := 871; |
Harald Welte | a4d8f35 | 2018-03-01 15:47:20 +0100 | [diff] [blame] | 52 | charstring mp_bb_trxc_ip := "127.0.0.1"; |
Harald Welte | ef3e1c9 | 2018-02-28 23:40:14 +0100 | [diff] [blame] | 53 | integer mp_bb_trxc_port := 6701; |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 54 | charstring mp_pcu_socket := PCU_SOCK_DEFAULT; |
Harald Welte | d568439 | 2018-03-10 18:22:04 +0100 | [diff] [blame] | 55 | integer mp_tolerance_rxqual := 1; |
| 56 | integer mp_tolerance_rxlev := 3; |
Neels Hofmeyr | 6a84b23 | 2018-04-03 19:12:36 +0200 | [diff] [blame] | 57 | charstring mp_ctrl_ip := "127.0.0.1"; |
| 58 | integer mp_ctrl_port := 4238; |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 59 | } |
| 60 | |
Harald Welte | 629cc6b | 2018-03-11 17:19:05 +0100 | [diff] [blame] | 61 | type record of RslChannelNr ChannelNrs; |
| 62 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 63 | type component test_CT extends CTRL_Adapter_CT { |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 64 | /* IPA Emulation component underneath RSL */ |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 65 | var IPA_Emulation_CT vc_IPA; |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 66 | /* RSL Emulation component (for ConnHdlr tests) */ |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 67 | var RSL_Emulation_CT vc_RSL; |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 68 | /* Direct RSL_CCHAN_PT */ |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 69 | port RSL_CCHAN_PT RSL_CCHAN; |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 70 | |
| 71 | /* L1CTL port (for classic tests) */ |
| 72 | port L1CTL_PT L1CTL; |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 73 | |
Harald Welte | 54a2a2d | 2018-02-26 09:14:05 +0100 | [diff] [blame] | 74 | /* TRXC port (for classic tests) */ |
| 75 | port TRXC_CODEC_PT BB_TRXC; |
| 76 | var integer g_bb_trxc_conn_id; |
| 77 | |
Harald Welte | 8da4824 | 2018-02-27 20:41:32 +0100 | [diff] [blame] | 78 | port TELNETasp_PT BTSVTY; |
| 79 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 80 | /* PCU Interface of BTS */ |
| 81 | port PCUIF_CODEC_PT PCU; |
| 82 | var integer g_pcu_conn_id; |
| 83 | /* Last PCU INFO IND we received */ |
| 84 | var PCUIF_Message g_pcu_last_info; |
| 85 | |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 86 | /* SI configuration */ |
| 87 | var SystemInformationConfig si_cfg := { |
| 88 | bcch_extended := false, |
| 89 | si1_present := false, |
| 90 | si2bis_present := false, |
| 91 | si2ter_present := false, |
| 92 | si2quater_present := false, |
| 93 | si7_present := false, |
| 94 | si8_present := false, |
| 95 | si9_present := false, |
| 96 | si13_present := false, |
| 97 | si13alt_present := false, |
| 98 | si15_present := false, |
| 99 | si16_present := false, |
| 100 | si17_present := false, |
| 101 | si2n_present := false, |
| 102 | si21_present := false, |
| 103 | si22_present := false |
| 104 | }; |
Harald Welte | 629cc6b | 2018-03-11 17:19:05 +0100 | [diff] [blame] | 105 | |
| 106 | /* all logical channels available on the BTS */ |
| 107 | var ChannelNrs g_AllChannels; |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 108 | var ChannelNrs g_AllChanTypes; |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 109 | } |
| 110 | |
| 111 | /* an individual call / channel */ |
| 112 | type component ConnHdlr extends RSL_DchanHdlr { |
| 113 | port L1CTL_PT L1CTL; |
| 114 | |
| 115 | port TRXC_CODEC_PT BB_TRXC; |
| 116 | var integer g_bb_trxc_conn_id; |
| 117 | |
| 118 | timer g_Tguard; |
| 119 | timer g_Tmeas_exp := 2.0; /* >= 103 SACCH multiframe ~ 500ms */ |
| 120 | |
| 121 | var ConnHdlrPars g_pars; |
| 122 | var uint8_t g_next_meas_res_nr := 0; |
Harald Welte | fa45e9e | 2018-03-10 18:59:03 +0100 | [diff] [blame] | 123 | var boolean g_first_meas_res := true; |
Harald Welte | f26de0b | 2018-04-04 20:28:05 +0200 | [diff] [blame] | 124 | |
| 125 | /* PCU Interface of BTS */ |
| 126 | port PCUIF_CODEC_PT PCU; |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 127 | } |
| 128 | |
| 129 | function f_init_rsl(charstring id) runs on test_CT { |
| 130 | vc_IPA := IPA_Emulation_CT.create(id & "-RSL-IPA"); |
| 131 | vc_RSL := RSL_Emulation_CT.create(id & "-RSL"); |
| 132 | |
| 133 | map(vc_IPA:IPA_PORT, system:IPA_CODEC_PT); |
| 134 | connect(vc_IPA:IPA_RSL_PORT, vc_RSL:IPA_PT); |
| 135 | connect(self:RSL_CCHAN, vc_RSL:CCHAN_PT); |
| 136 | |
| 137 | vc_IPA.start(IPA_Emulation.main_server(mp_rsl_ip, mp_rsl_port)); |
| 138 | vc_RSL.start(RSL_Emulation.main(false)); |
| 139 | } |
| 140 | |
| 141 | type record ConnHdlrPars { |
| 142 | RslChannelNr chan_nr, |
| 143 | RSL_IE_ChannelMode chan_mode, |
| 144 | float t_guard, |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 145 | ConnL1Pars l1_pars, |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 146 | TestSpecUnion spec optional, |
| 147 | RSL_IE_EncryptionInfo encr optional |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 148 | } |
| 149 | |
| 150 | /* Test-specific parameters */ |
| 151 | type union TestSpecUnion { |
| 152 | RllTestCase rll |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 153 | } |
| 154 | |
Harald Welte | 82ccef7 | 2018-02-25 16:17:33 +0100 | [diff] [blame] | 155 | template (value) RachControlParameters ts_RachCtrl_default := { |
Harald Welte | 0fd1fb0 | 2018-03-10 17:19:50 +0100 | [diff] [blame] | 156 | max_retrans := RACH_MAX_RETRANS_7, |
| 157 | tx_integer := '1001'B, /* 12 slots */ |
Harald Welte | 82ccef7 | 2018-02-25 16:17:33 +0100 | [diff] [blame] | 158 | cell_barr_access := false, |
| 159 | re_not_allowed := true, |
Harald Welte | b9585f8 | 2018-03-10 17:18:47 +0100 | [diff] [blame] | 160 | acc := '0000010000000000'B |
Harald Welte | 82ccef7 | 2018-02-25 16:17:33 +0100 | [diff] [blame] | 161 | }; |
| 162 | |
Harald Welte | f10153f | 2018-02-25 16:34:05 +0100 | [diff] [blame] | 163 | template (value) CellSelectionParameters ts_CellSelPar_default := { |
Harald Welte | 0fd1fb0 | 2018-03-10 17:19:50 +0100 | [diff] [blame] | 164 | cell_resel_hyst_2dB := 2, |
| 165 | ms_txpwr_max_cch := 7, |
Harald Welte | f10153f | 2018-02-25 16:34:05 +0100 | [diff] [blame] | 166 | acs := '0'B, |
| 167 | neci := true, |
| 168 | rxlev_access_min := 0 |
| 169 | } |
| 170 | |
| 171 | template (value) LocationAreaIdentification ts_LAI_default := { |
| 172 | mcc_mnc := '262F42'H, |
| 173 | lac := 42 |
| 174 | } |
| 175 | |
Harald Welte | 7484fc4 | 2018-02-24 14:09:45 +0100 | [diff] [blame] | 176 | /* Default SYSTEM INFORMATION 3 */ |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 177 | template (value) SystemInformation ts_SI3_default := { |
| 178 | header := ts_RrHeader(SYSTEM_INFORMATION_TYPE_3, 18), |
Harald Welte | 7484fc4 | 2018-02-24 14:09:45 +0100 | [diff] [blame] | 179 | payload := { |
| 180 | si3 := { |
| 181 | cell_id := 23, |
Harald Welte | f10153f | 2018-02-25 16:34:05 +0100 | [diff] [blame] | 182 | lai := ts_LAI_default, |
Harald Welte | 7484fc4 | 2018-02-24 14:09:45 +0100 | [diff] [blame] | 183 | ctrl_chan_desc := { |
| 184 | msc_r99 := true, |
| 185 | att := true, |
| 186 | bs_ag_blks_res := 1, |
| 187 | ccch_conf := CCHAN_DESC_1CCCH_COMBINED, |
Harald Welte | 82ccef7 | 2018-02-25 16:17:33 +0100 | [diff] [blame] | 188 | si22ind := false, |
Harald Welte | 7484fc4 | 2018-02-24 14:09:45 +0100 | [diff] [blame] | 189 | cbq3 := CBQ3_IU_MODE_NOT_SUPPORTED, |
| 190 | spare := '00'B, |
| 191 | bs_pa_mfrms := 0, /* 2 multiframes */ |
| 192 | t3212 := 1 /* 6 minutes */ |
| 193 | }, |
Harald Welte | 82ccef7 | 2018-02-25 16:17:33 +0100 | [diff] [blame] | 194 | cell_options := { |
Harald Welte | 7484fc4 | 2018-02-24 14:09:45 +0100 | [diff] [blame] | 195 | dn_ind := false, |
| 196 | pwrc := false, |
| 197 | dtx := MS_MAY_USE_UL_DTX, |
Harald Welte | 0fd1fb0 | 2018-03-10 17:19:50 +0100 | [diff] [blame] | 198 | radio_link_tout_div4 := (32/4)-1 |
Harald Welte | 7484fc4 | 2018-02-24 14:09:45 +0100 | [diff] [blame] | 199 | }, |
Harald Welte | f10153f | 2018-02-25 16:34:05 +0100 | [diff] [blame] | 200 | cell_sel_par := ts_CellSelPar_default, |
Harald Welte | 82ccef7 | 2018-02-25 16:17:33 +0100 | [diff] [blame] | 201 | rach_control := ts_RachCtrl_default, |
Harald Welte | 3778acc | 2018-03-09 19:32:31 +0100 | [diff] [blame] | 202 | rest_octets := '2B2B2B2B'O |
Harald Welte | 7484fc4 | 2018-02-24 14:09:45 +0100 | [diff] [blame] | 203 | } |
| 204 | } |
| 205 | } |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 206 | |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 207 | template (value) SystemInformation ts_SI2_default := { |
| 208 | header := ts_RrHeader(SYSTEM_INFORMATION_TYPE_2, 22), |
Harald Welte | f10153f | 2018-02-25 16:34:05 +0100 | [diff] [blame] | 209 | payload := { |
| 210 | si2 := { |
| 211 | bcch_freq_list := '00000000000000000000000000000000'O, |
| 212 | ncc_permitted := '11111111'B, |
| 213 | rach_control := ts_RachCtrl_default |
| 214 | } |
| 215 | } |
| 216 | } |
| 217 | |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 218 | template (value) SystemInformation ts_SI4_default := { |
| 219 | header := ts_RrHeader(SYSTEM_INFORMATION_TYPE_4, 12), /* no CBCH / restoct */ |
Harald Welte | f10153f | 2018-02-25 16:34:05 +0100 | [diff] [blame] | 220 | payload := { |
| 221 | si4 := { |
| 222 | lai := ts_LAI_default, |
| 223 | cell_sel_par := ts_CellSelPar_default, |
| 224 | rach_control := ts_RachCtrl_default, |
| 225 | cbch_chan_desc := omit, |
| 226 | cbch_mobile_alloc := omit, |
| 227 | rest_octets := ''O |
| 228 | } |
| 229 | } |
| 230 | } |
| 231 | |
| 232 | function f_rsl_bcch_fill_raw(RSL_IE_SysinfoType rsl_si_type, octetstring si_enc) |
| 233 | runs on test_CT { |
| 234 | log("Setting ", rsl_si_type, ": ", si_enc); |
| 235 | RSL_CCHAN.send(ts_RSL_UD(ts_RSL_BCCH_INFO(rsl_si_type, si_enc))); |
| 236 | } |
| 237 | |
| 238 | function f_rsl_bcch_fill(RSL_IE_SysinfoType rsl_si_type, template (value) SystemInformation si_dec) |
| 239 | runs on test_CT { |
| 240 | var octetstring si_enc := enc_SystemInformation(valueof(si_dec)); |
| 241 | log("Setting ", rsl_si_type, ": ", si_dec); |
| 242 | f_rsl_bcch_fill_raw(rsl_si_type, si_enc); |
| 243 | } |
| 244 | |
Harald Welte | 8da4824 | 2018-02-27 20:41:32 +0100 | [diff] [blame] | 245 | private function f_init_vty(charstring id) runs on test_CT { |
| 246 | map(self:BTSVTY, system:BTSVTY); |
| 247 | f_vty_set_prompts(BTSVTY); |
| 248 | f_vty_transceive(BTSVTY, "enable"); |
| 249 | } |
| 250 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 251 | /* PCU socket may at any time receive a new INFO.ind */ |
Harald Welte | f26de0b | 2018-04-04 20:28:05 +0200 | [diff] [blame] | 252 | private altstep as_pcu_info_ind(PCUIF_CODEC_PT pt, integer pcu_conn_id, |
| 253 | out PCUIF_Message pcu_last_info) { |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 254 | var PCUIF_send_data sd; |
Harald Welte | f26de0b | 2018-04-04 20:28:05 +0200 | [diff] [blame] | 255 | [] pt.receive(t_SD_PCUIF(pcu_conn_id, tr_PCUIF_INFO_IND(0, ?))) -> value sd { |
| 256 | pcu_last_info := sd.data; |
Harald Welte | d378a25 | 2018-03-13 17:02:14 +0100 | [diff] [blame] | 257 | } |
Harald Welte | f26de0b | 2018-04-04 20:28:05 +0200 | [diff] [blame] | 258 | [] pt.receive(t_SD_PCUIF(pcu_conn_id, tr_PCUIF_INFO_IND(?, ?, ?))) -> value sd { |
Harald Welte | d378a25 | 2018-03-13 17:02:14 +0100 | [diff] [blame] | 259 | setverdict(fail, "Invalid PCU Version/BTS Number received"); |
| 260 | self.stop; |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 261 | } |
| 262 | } |
| 263 | |
Harald Welte | f26de0b | 2018-04-04 20:28:05 +0200 | [diff] [blame] | 264 | private function f_init_pcu(PCUIF_CODEC_PT pt, charstring id, |
| 265 | out integer pcu_conn_id, out PCUIF_Message pcu_last_info) { |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 266 | timer T := 2.0; |
| 267 | var PCUIF_send_data sd; |
Harald Welte | 8427162 | 2018-03-10 17:21:03 +0100 | [diff] [blame] | 268 | if (mp_pcu_socket == "") { |
Harald Welte | f26de0b | 2018-04-04 20:28:05 +0200 | [diff] [blame] | 269 | pcu_conn_id := -1; |
Harald Welte | 8427162 | 2018-03-10 17:21:03 +0100 | [diff] [blame] | 270 | return; |
| 271 | } |
Harald Welte | f26de0b | 2018-04-04 20:28:05 +0200 | [diff] [blame] | 272 | pcu_conn_id := f_pcuif_connect(pt, mp_pcu_socket); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 273 | |
| 274 | T.start; |
| 275 | alt { |
Harald Welte | f26de0b | 2018-04-04 20:28:05 +0200 | [diff] [blame] | 276 | [] as_pcu_info_ind(pt, pcu_conn_id, pcu_last_info); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 277 | [] T.timeout { |
| 278 | setverdict(fail, "Timeout waiting for PCU INFO_IND"); |
| 279 | self.stop; |
| 280 | } |
| 281 | } |
| 282 | } |
| 283 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 284 | /* global init function */ |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 285 | function f_init(charstring id := "BTS-Test") runs on test_CT { |
Harald Welte | 629cc6b | 2018-03-11 17:19:05 +0100 | [diff] [blame] | 286 | g_AllChannels := { |
| 287 | /* TS 1..4: TCH/F */ |
| 288 | valueof(ts_RslChanNr_Bm(1)), valueof(ts_RslChanNr_Bm(2)), |
| 289 | valueof(ts_RslChanNr_Bm(3)), valueof(ts_RslChanNr_Bm(4)), |
| 290 | /* TS 5: TCH/H */ |
| 291 | valueof(ts_RslChanNr_Lm(5,0)), valueof(ts_RslChanNr_Lm(5,1)), |
| 292 | /* TS 0: SDCCH/4 */ |
| 293 | valueof(ts_RslChanNr_SDCCH4(0,0)), valueof(ts_RslChanNr_SDCCH4(0,1)), |
| 294 | valueof(ts_RslChanNr_SDCCH4(0,2)), valueof(ts_RslChanNr_SDCCH4(0,3)), |
| 295 | /* TS 6: SDCCH/8 */ |
| 296 | valueof(ts_RslChanNr_SDCCH8(6,0)), valueof(ts_RslChanNr_SDCCH8(6,1)), |
| 297 | valueof(ts_RslChanNr_SDCCH8(6,2)), valueof(ts_RslChanNr_SDCCH8(6,3)), |
| 298 | valueof(ts_RslChanNr_SDCCH8(6,4)), valueof(ts_RslChanNr_SDCCH8(6,5)), |
| 299 | valueof(ts_RslChanNr_SDCCH8(6,6)), valueof(ts_RslChanNr_SDCCH8(6,7)) |
| 300 | }; |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 301 | g_AllChanTypes := { |
| 302 | /* TS 1..4: TCH/F */ |
| 303 | //valueof(ts_RslChanNr_Bm(1)), |
| 304 | /* TS 5: TCH/H */ |
| 305 | //valueof(ts_RslChanNr_Lm(5,1)), |
| 306 | /* TS 0: SDCCH/4 */ |
| 307 | valueof(ts_RslChanNr_SDCCH4(0,2)), |
| 308 | /* TS 6: SDCCH/8 */ |
| 309 | valueof(ts_RslChanNr_SDCCH8(6,4)) |
| 310 | }; |
Harald Welte | 629cc6b | 2018-03-11 17:19:05 +0100 | [diff] [blame] | 311 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 312 | f_init_rsl(id); |
| 313 | RSL_CCHAN.receive(ASP_IPA_Event:{up_down := ASP_IPA_EVENT_UP}); |
Harald Welte | 2d14259 | 2018-02-25 13:19:44 +0100 | [diff] [blame] | 314 | f_sleep(0.5); /* workaround for OS#3000 */ |
Harald Welte | 8da4824 | 2018-02-27 20:41:32 +0100 | [diff] [blame] | 315 | f_init_vty(id); |
Neels Hofmeyr | 6a84b23 | 2018-04-03 19:12:36 +0200 | [diff] [blame] | 316 | f_ipa_ctrl_start(mp_ctrl_ip, mp_ctrl_port); |
Harald Welte | 7484fc4 | 2018-02-24 14:09:45 +0100 | [diff] [blame] | 317 | |
| 318 | /* Send SI3 to the BTS, it is needed for various computations */ |
Harald Welte | f10153f | 2018-02-25 16:34:05 +0100 | [diff] [blame] | 319 | f_rsl_bcch_fill(RSL_SYSTEM_INFO_3, ts_SI3_default); |
| 320 | /* SI2 + SI4 are required for SI testing as they are mandatory defaults */ |
| 321 | f_rsl_bcch_fill(RSL_SYSTEM_INFO_2, ts_SI2_default); |
| 322 | f_rsl_bcch_fill(RSL_SYSTEM_INFO_4, ts_SI4_default); |
Harald Welte | 57fe823 | 2018-02-26 17:52:50 +0100 | [diff] [blame] | 323 | |
Harald Welte | f26de0b | 2018-04-04 20:28:05 +0200 | [diff] [blame] | 324 | map(self:PCU, system:PCU); |
| 325 | f_init_pcu(PCU, id, g_pcu_conn_id, g_pcu_last_info); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 326 | |
Harald Welte | 8427162 | 2018-03-10 17:21:03 +0100 | [diff] [blame] | 327 | if (mp_bb_trxc_port != -1) { |
| 328 | var TrxcMessage ret; |
| 329 | /* start with a default moderate timing offset equalling TA=2 */ |
| 330 | f_main_trxc_connect(); |
| 331 | ret := f_TRXC_transceive(BB_TRXC, g_bb_trxc_conn_id, valueof(ts_TRXC_FAKE_TIMING(2*256))); |
| 332 | } |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 333 | } |
| 334 | |
Harald Welte | 294b0a2 | 2018-03-10 23:26:48 +0100 | [diff] [blame] | 335 | function f_shutdown() runs on test_CT { |
| 336 | /* shut down all "externally interfaced" components first to avoid unclean shutdown */ |
| 337 | vc_IPA.stop; |
| 338 | vc_RSL.stop; |
Neels Hofmeyr | 6a84b23 | 2018-04-03 19:12:36 +0200 | [diff] [blame] | 339 | f_ipa_ctrl_stop(); |
Harald Welte | 294b0a2 | 2018-03-10 23:26:48 +0100 | [diff] [blame] | 340 | } |
| 341 | |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 342 | /* Attach L1CTL to master test_CT (classic tests, non-handler mode) */ |
| 343 | function f_init_l1ctl() runs on test_CT { |
| 344 | map(self:L1CTL, system:L1CTL); |
| 345 | f_connect_reset(L1CTL); |
| 346 | } |
| 347 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 348 | type function void_fn(charstring id) runs on ConnHdlr; |
| 349 | |
| 350 | /* create a new test component */ |
Harald Welte | f26de0b | 2018-04-04 20:28:05 +0200 | [diff] [blame] | 351 | function f_start_handler(void_fn fn, ConnHdlrPars pars, boolean pcu_comp := false) |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 352 | runs on test_CT return ConnHdlr { |
| 353 | var charstring id := testcasename(); |
| 354 | var ConnHdlr vc_conn; |
| 355 | |
| 356 | vc_conn := ConnHdlr.create(id); |
| 357 | /* connect to RSL Emulation main component */ |
| 358 | connect(vc_conn:RSL, vc_RSL:CLIENT_PT); |
| 359 | connect(vc_conn:RSL_PROC, vc_RSL:RSL_PROC); |
Harald Welte | f26de0b | 2018-04-04 20:28:05 +0200 | [diff] [blame] | 360 | if (pcu_comp) { |
| 361 | /* the ConnHdlr component wants to talk directly to the PCU, so disconnect |
| 362 | * it from the test_CT and connect it to the component. This obviously only |
| 363 | * works for one component, i.e. no concurrency */ |
| 364 | unmap(self:PCU, system:PCU); |
| 365 | map(vc_conn:PCU, system:PCU); |
| 366 | } |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 367 | |
| 368 | vc_conn.start(f_handler_init(fn, id, pars)); |
| 369 | return vc_conn; |
| 370 | } |
| 371 | |
Harald Welte | 7484fc4 | 2018-02-24 14:09:45 +0100 | [diff] [blame] | 372 | template ASP_RSL_Unitdata ts_RSL_UD(template RSL_Message rsl, IpaStreamId sid := IPAC_PROTO_RSL_TRX0) := { |
| 373 | streamId := sid, |
| 374 | rsl := rsl |
| 375 | } |
| 376 | |
| 377 | template ASP_RSL_Unitdata tr_RSL_UD(template RSL_Message rsl, |
| 378 | template IpaStreamId sid := IPAC_PROTO_RSL_TRX0) := { |
| 379 | streamId := sid, |
| 380 | rsl := rsl |
| 381 | } |
| 382 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 383 | private altstep as_Tguard() runs on ConnHdlr { |
| 384 | [] g_Tguard.timeout { |
| 385 | setverdict(fail, "Tguard timeout"); |
| 386 | self.stop; |
| 387 | } |
| 388 | } |
| 389 | |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 390 | private function f_l1_tune(L1CTL_PT L1CTL) { |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 391 | f_L1CTL_FBSB(L1CTL, { false, mp_trx0_arfcn }, CCCH_MODE_COMBINED); |
| 392 | } |
| 393 | |
| 394 | private function f_trxc_connect() runs on ConnHdlr { |
| 395 | map(self:BB_TRXC, system:BB_TRXC); |
| 396 | var Result res; |
Harald Welte | a4d8f35 | 2018-03-01 15:47:20 +0100 | [diff] [blame] | 397 | res := TRXC_CodecPort_CtrlFunct.f_IPL4_connect(BB_TRXC, mp_bb_trxc_ip, mp_bb_trxc_port, |
| 398 | "", -1, -1, {udp:={}}, {}); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 399 | g_bb_trxc_conn_id := res.connId; |
| 400 | } |
| 401 | |
| 402 | private function f_trxc_fake_rssi(uint8_t rssi) runs on ConnHdlr { |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 403 | var TrxcMessage ret; |
| 404 | 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] | 405 | } |
| 406 | |
| 407 | private function f_trx_fake_toffs256(int16_t toffs256) runs on ConnHdlr { |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 408 | var TrxcMessage ret; |
| 409 | 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] | 410 | } |
| 411 | |
| 412 | /* first function started in ConnHdlr component */ |
| 413 | private function f_handler_init(void_fn fn, charstring id, ConnHdlrPars pars) |
| 414 | runs on ConnHdlr { |
| 415 | g_pars := pars; |
| 416 | g_chan_nr := pars.chan_nr; |
| 417 | |
| 418 | map(self:L1CTL, system:L1CTL); |
| 419 | f_connect_reset(L1CTL); |
| 420 | |
Harald Welte | 8427162 | 2018-03-10 17:21:03 +0100 | [diff] [blame] | 421 | if (mp_bb_trxc_port != -1) { |
| 422 | f_trxc_connect(); |
| 423 | } |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 424 | |
| 425 | g_Tguard.start(pars.t_guard); |
| 426 | activate(as_Tguard()); |
| 427 | |
| 428 | f_rslem_register(0, pars.chan_nr); |
| 429 | |
| 430 | /* call the user-supplied test case function */ |
| 431 | fn.apply(id); |
| 432 | } |
| 433 | |
Harald Welte | b1726c9 | 2018-03-30 11:56:38 +0200 | [diff] [blame] | 434 | function f_rsl_transceive_ret(template RSL_Message tx, template RSL_Message exp_rx, charstring id, |
| 435 | boolean ignore_other := false) |
| 436 | runs on ConnHdlr return RSL_Message { |
| 437 | var RSL_Message rx; |
Harald Welte | 1eba374 | 2018-02-25 12:48:14 +0100 | [diff] [blame] | 438 | timer T := 3.0; |
| 439 | RSL.send(tx); |
| 440 | T.start; |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 441 | alt { |
Harald Welte | b1726c9 | 2018-03-30 11:56:38 +0200 | [diff] [blame] | 442 | [] RSL.receive(exp_rx) -> value rx { |
Harald Welte | 1eba374 | 2018-02-25 12:48:14 +0100 | [diff] [blame] | 443 | T.stop; |
| 444 | setverdict(pass); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 445 | } |
Harald Welte | 1eba374 | 2018-02-25 12:48:14 +0100 | [diff] [blame] | 446 | [] T.timeout { |
| 447 | setverdict(fail, "Timeout expecting " & id); |
| 448 | self.stop; |
| 449 | } |
Harald Welte | 21240e6 | 2018-03-11 21:43:35 +0100 | [diff] [blame] | 450 | [not ignore_other] as_l1_sacch(); |
| 451 | [not ignore_other] as_meas_res(); |
| 452 | [not ignore_other] as_l1_dcch(); |
| 453 | [not ignore_other] RSL.receive { |
Harald Welte | 1eba374 | 2018-02-25 12:48:14 +0100 | [diff] [blame] | 454 | setverdict(fail, "Unexpected RSL message received"); |
Harald Welte | b1726c9 | 2018-03-30 11:56:38 +0200 | [diff] [blame] | 455 | self.stop; |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 456 | } |
Harald Welte | 21240e6 | 2018-03-11 21:43:35 +0100 | [diff] [blame] | 457 | [ignore_other] RSL.receive { repeat; } |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 458 | } |
Harald Welte | b1726c9 | 2018-03-30 11:56:38 +0200 | [diff] [blame] | 459 | return rx; |
| 460 | } |
| 461 | |
| 462 | function f_rsl_transceive(template RSL_Message tx, template RSL_Message exp_rx, charstring id, |
| 463 | boolean ignore_other := false) |
| 464 | runs on ConnHdlr { |
| 465 | var RSL_Message rx := f_rsl_transceive_ret(tx, exp_rx, id, ignore_other); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 466 | } |
| 467 | |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 468 | function f_rsl_chan_act(RSL_IE_ChannelMode mode, boolean encr_enable := false) |
| 469 | runs on ConnHdlr { |
| 470 | var RSL_Message ch_act := valueof(ts_RSL_CHAN_ACT(g_chan_nr, mode)); |
| 471 | if (encr_enable) { |
| 472 | /* append encryption related IEs, if requested */ |
| 473 | var RSL_IE_EncryptionInfo encr_info; |
| 474 | encr_info := valueof(ts_RSL_IE_EncrInfo(g_pars.encr.alg_id, g_pars.encr.key)); |
| 475 | ch_act.ies := ch_act.ies & { valueof(t_RSL_IE(RSL_IE_ENCR_INFO, RSL_IE_Body:{encr_info := |
| 476 | encr_info})) }; |
| 477 | } |
| 478 | f_rsl_transceive(ch_act, tr_RSL_CHAN_ACT_ACK(g_chan_nr), "RSL CHAN ACT"); |
Harald Welte | 1eba374 | 2018-02-25 12:48:14 +0100 | [diff] [blame] | 479 | } |
| 480 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 481 | function f_rsl_chan_deact() runs on ConnHdlr { |
Harald Welte | 1eba374 | 2018-02-25 12:48:14 +0100 | [diff] [blame] | 482 | f_rsl_transceive(ts_RSL_RF_CHAN_REL(g_chan_nr), tr_RSL_RF_CHAN_REL_ACK(g_chan_nr), |
Harald Welte | 21240e6 | 2018-03-11 21:43:35 +0100 | [diff] [blame] | 483 | "RF CHAN REL", true); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 484 | } |
| 485 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 486 | private template ConnHdlrPars t_Pars(template RslChannelNr chan_nr, |
| 487 | template RSL_IE_ChannelMode chan_mode, |
| 488 | float t_guard := 20.0) := { |
| 489 | chan_nr := valueof(chan_nr), |
| 490 | chan_mode := valueof(chan_mode), |
| 491 | t_guard := t_guard, |
| 492 | l1_pars := { |
| 493 | dtx_enabled := false, |
Harald Welte | 685d598 | 2018-02-27 20:42:05 +0100 | [diff] [blame] | 494 | toa256_enabled := false, |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 495 | meas_ul := { |
| 496 | full := { |
| 497 | rxlev := dbm2rxlev(-53), |
| 498 | rxqual := 0 |
| 499 | }, |
| 500 | sub := { |
| 501 | rxlev := dbm2rxlev(-53), |
| 502 | rxqual := 0 |
| 503 | } |
| 504 | }, |
| 505 | timing_offset_256syms := 0, |
| 506 | bs_power_level := 0, |
| 507 | ms_power_level := 0, |
| 508 | ms_actual_ta := 0 |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 509 | }, |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 510 | spec := omit, |
| 511 | encr := omit |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 512 | } |
| 513 | |
Harald Welte | 93640c6 | 2018-02-25 16:59:33 +0100 | [diff] [blame] | 514 | /*********************************************************************** |
| 515 | * Channel Activation / Deactivation |
| 516 | ***********************************************************************/ |
| 517 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 518 | /* Stress test: Do 500 channel activations/deactivations in rapid succession */ |
| 519 | function f_TC_chan_act_stress(charstring id) runs on ConnHdlr { |
| 520 | for (var integer i := 0; i < 500; i := i+1) { |
| 521 | f_rsl_chan_act(g_pars.chan_mode); |
| 522 | f_rsl_chan_deact(); |
| 523 | } |
| 524 | setverdict(pass); |
| 525 | } |
| 526 | testcase TC_chan_act_stress() runs on test_CT { |
| 527 | var ConnHdlr vc_conn; |
| 528 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 529 | f_init(testcasename()); |
| 530 | vc_conn := f_start_handler(refers(f_TC_chan_act_stress), pars); |
| 531 | vc_conn.done; |
Harald Welte | 294b0a2 | 2018-03-10 23:26:48 +0100 | [diff] [blame] | 532 | f_shutdown(); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 533 | } |
| 534 | |
| 535 | /* Test if re-activation of an already active channel fails as expected */ |
| 536 | function f_TC_chan_act_react(charstring id) runs on ConnHdlr { |
| 537 | f_rsl_chan_act(g_pars.chan_mode); |
| 538 | /* attempt to activate the same lchan again -> expect reject */ |
| 539 | RSL.send(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode)); |
| 540 | alt { |
| 541 | [] RSL.receive(tr_RSL_CHAN_ACT_ACK(g_chan_nr)) { |
| 542 | setverdict(fail, "Unexpected CHAN ACT ACK on double activation"); |
| 543 | } |
| 544 | [] RSL.receive(tr_RSL_CHAN_ACT_NACK(g_chan_nr)) { |
| 545 | setverdict(pass); |
| 546 | } |
| 547 | } |
| 548 | f_rsl_chan_deact(); |
| 549 | } |
| 550 | testcase TC_chan_act_react() runs on test_CT { |
| 551 | var ConnHdlr vc_conn; |
| 552 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
Harald Welte | 294b0a2 | 2018-03-10 23:26:48 +0100 | [diff] [blame] | 553 | f_init(); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 554 | vc_conn := f_start_handler(refers(f_TC_chan_act_react), pars); |
| 555 | vc_conn.done; |
Harald Welte | 294b0a2 | 2018-03-10 23:26:48 +0100 | [diff] [blame] | 556 | f_shutdown(); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 557 | } |
| 558 | |
| 559 | /* Attempt to de-activate a channel that's not active */ |
| 560 | function f_TC_chan_deact_not_active(charstring id) runs on ConnHdlr { |
| 561 | timer T := 3.0; |
| 562 | RSL.send(ts_RSL_RF_CHAN_REL(g_chan_nr)); |
| 563 | T.start; |
| 564 | alt { |
| 565 | [] RSL.receive(tr_RSL_RF_CHAN_REL_ACK(g_chan_nr)) { |
| 566 | setverdict(pass); |
| 567 | } |
| 568 | [] T.timeout { |
| 569 | setverdict(fail, "Timeout expecting RF_CHAN_REL_ACK"); |
| 570 | } |
| 571 | } |
| 572 | } |
| 573 | testcase TC_chan_deact_not_active() runs on test_CT { |
| 574 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
Harald Welte | 294b0a2 | 2018-03-10 23:26:48 +0100 | [diff] [blame] | 575 | f_init(); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 576 | var ConnHdlr vc_conn := f_start_handler(refers(f_TC_chan_deact_not_active), pars); |
| 577 | vc_conn.done; |
Harald Welte | 294b0a2 | 2018-03-10 23:26:48 +0100 | [diff] [blame] | 578 | f_shutdown(); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 579 | } |
| 580 | |
| 581 | /* attempt to activate channel with wrong RSL Channel Nr IE; expect NACK */ |
| 582 | function f_TC_chan_act_wrong_nr(charstring id) runs on ConnHdlr { |
| 583 | RSL.send(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode)); |
| 584 | alt { |
| 585 | [] RSL.receive(tr_RSL_CHAN_ACT_ACK(g_chan_nr)) { |
| 586 | setverdict(fail, "Unexpected CHAN ACT ACK"); |
| 587 | } |
| 588 | [] RSL.receive(tr_RSL_CHAN_ACT_NACK(g_chan_nr)) { |
| 589 | setverdict(pass); |
| 590 | } |
| 591 | } |
| 592 | } |
| 593 | private type record WrongChanNrCase { |
| 594 | RslChannelNr chan_nr, |
| 595 | charstring description |
| 596 | } |
| 597 | private type record of WrongChanNrCase WrongChanNrCases; |
| 598 | private template WrongChanNrCase t_WCN(template RslChannelNr chan_nr, charstring desc) := { |
| 599 | chan_nr := chan_nr, |
| 600 | description := desc |
| 601 | } |
| 602 | |
| 603 | testcase TC_chan_act_wrong_nr() runs on test_CT { |
| 604 | var ConnHdlr vc_conn; |
| 605 | var ConnHdlrPars pars; |
| 606 | |
Harald Welte | 294b0a2 | 2018-03-10 23:26:48 +0100 | [diff] [blame] | 607 | f_init(); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 608 | |
| 609 | var WrongChanNrCases wrong := { |
| 610 | valueof(t_WCN(t_RslChanNr_RACH(0), "RACH is not a dedicated channel")), |
| 611 | valueof(t_WCN(t_RslChanNr_RACH(1), "RACH doesn't exist on timeslot")), |
| 612 | valueof(t_WCN(t_RslChanNr_BCCH(0), "BCCH is not a dedicated channel")), |
| 613 | valueof(t_WCN(t_RslChanNr_PCH_AGCH(0), "PCH/AGCH is not a dedicated channel")), |
| 614 | valueof(t_WCN(t_RslChanNr_Bm(0), "TS0 cannot be TCH/F")), |
| 615 | valueof(t_WCN(t_RslChanNr_Lm(0, 0), "TS0 cannot be TCH/H")), |
| 616 | valueof(t_WCN(t_RslChanNr_Lm(0, 1), "TS0 cannot be TCH/H")), |
| 617 | valueof(t_WCN(t_RslChanNr_PDCH(0), "TS0 cannot be PDCH")), |
| 618 | valueof(t_WCN(t_RslChanNr_SDCCH8(0, 0), "TS0 cannot be SDCCH/8")), |
| 619 | valueof(t_WCN(t_RslChanNr_SDCCH8(0, 7), "TS0 cannot be SDCCH/8")), |
| 620 | valueof(t_WCN(t_RslChanNr_SDCCH4(7, 0), "TS7 cannot be SDCCH/4")), |
| 621 | valueof(t_WCN(t_RslChanNr_SDCCH4(7, 3), "TS7 cannot be SDCCH/4")), |
| 622 | valueof(t_WCN(t_RslChanNr_Lm(1, 0), "TS1 cannot be TCH/H")) |
| 623 | }; |
| 624 | |
| 625 | for (var integer i := 0; i < sizeof(wrong); i := i+1) { |
| 626 | pars := valueof(t_Pars(wrong[i].chan_nr, ts_RSL_ChanMode_SIGN)); |
| 627 | vc_conn := f_start_handler(refers(f_TC_chan_act_wrong_nr), pars); |
| 628 | vc_conn.done; |
| 629 | } |
Harald Welte | 294b0a2 | 2018-03-10 23:26:48 +0100 | [diff] [blame] | 630 | f_shutdown(); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 631 | } |
| 632 | |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 633 | /* execute the same callback function on a variety of logical channels */ |
| 634 | private function f_testmatrix_each_chan(ConnHdlrPars pars, void_fn fn) runs on test_CT { |
| 635 | var ConnHdlr vc_conn; |
| 636 | f_init(testcasename()); |
| 637 | |
| 638 | /* test on each of the channels we have */ |
| 639 | for (var integer i := 0; i < sizeof(g_AllChanTypes); i := i+1) { |
| 640 | pars.chan_nr := valueof(g_AllChanTypes[i]); |
| 641 | |
| 642 | log(testcasename(), ": XXX Starting on ", g_AllChanTypes[i]); |
| 643 | vc_conn := f_start_handler(fn, pars); |
| 644 | vc_conn.done; |
| 645 | } |
| 646 | |
| 647 | f_shutdown(); |
| 648 | } |
| 649 | |
Harald Welte | 93640c6 | 2018-02-25 16:59:33 +0100 | [diff] [blame] | 650 | /*********************************************************************** |
Harald Welte | 629cc6b | 2018-03-11 17:19:05 +0100 | [diff] [blame] | 651 | * SACCH handling |
| 652 | ***********************************************************************/ |
| 653 | |
| 654 | private function f_exp_sacch(boolean exp) runs on ConnHdlr { |
| 655 | timer T_sacch := 3.0; |
| 656 | T_sacch.start; |
| 657 | alt { |
| 658 | [not exp] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(0))) { |
| 659 | setverdict(fail, "Received SACCH when not expecting it"); |
| 660 | } |
| 661 | [not exp] T_sacch.timeout { |
| 662 | setverdict(pass); |
| 663 | } |
| 664 | [exp] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(0))) { |
| 665 | setverdict(pass); |
| 666 | } |
| 667 | [exp] T_sacch.timeout { |
| 668 | setverdict(fail, "Timeout waiting for SACCH on ", g_chan_nr); |
| 669 | } |
| 670 | [] L1CTL.receive { repeat; } |
| 671 | [] RSL.receive { repeat; } |
| 672 | } |
| 673 | } |
| 674 | |
| 675 | /* Test if DEACTIVATE SACCH actualy deactivates its transmission (TS 48.058 4.6) */ |
| 676 | private function f_TC_deact_sacch(charstring id) runs on ConnHdlr { |
| 677 | f_l1_tune(L1CTL); |
| 678 | RSL.clear; |
| 679 | |
| 680 | /* activate the logical channel */ |
| 681 | f_est_dchan(); |
| 682 | L1CTL.clear; |
| 683 | |
| 684 | /* check that SACCH actually are received as expected */ |
| 685 | f_exp_sacch(true); |
| 686 | |
| 687 | /* deactivate SACCH on the logical channel */ |
| 688 | RSL.send(ts_RSL_DEACT_SACCH(g_chan_nr)); |
| 689 | f_sleep(1.0); |
| 690 | L1CTL.clear; |
| 691 | |
| 692 | /* check that no SACCH are received anymore */ |
| 693 | f_exp_sacch(false); |
| 694 | |
| 695 | /* release the channel */ |
| 696 | f_rsl_chan_deact(); |
| 697 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 698 | } |
| 699 | testcase TC_deact_sacch() runs on test_CT { |
| 700 | var ConnHdlr vc_conn; |
| 701 | var ConnHdlrPars pars; |
| 702 | f_init(); |
| 703 | for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) { |
| 704 | //for (var integer i := 0; i < 1; i := i+1) { |
| 705 | pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN)); |
| 706 | log(testcasename(), ": Starting for ", g_AllChannels[i]); |
| 707 | vc_conn := f_start_handler(refers(f_TC_deact_sacch), pars); |
| 708 | vc_conn.done; |
| 709 | } |
| 710 | /* TODO: do the above in parallel, rather than sequentially? */ |
| 711 | f_shutdown(); |
| 712 | } |
| 713 | |
Harald Welte | 5570066 | 2018-03-12 13:15:43 +0100 | [diff] [blame] | 714 | /* verify that given SACCH payload is present */ |
Harald Welte | ea17b91 | 2018-03-11 22:29:31 +0100 | [diff] [blame] | 715 | private function f_sacch_present(template octetstring l3_exp) runs on ConnHdlr { |
| 716 | var L1ctlDlMessage dl; |
| 717 | /* check that the specified SI5 value is actually sent */ |
| 718 | timer T_sacch := 3.0; |
| 719 | L1CTL.clear; |
| 720 | T_sacch.start; |
| 721 | alt { |
| 722 | [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(0))) -> value dl { |
| 723 | var octetstring l3 := substr(dl.payload.data_ind.payload, 4, 19); |
| 724 | if (match(l3, l3_exp)) { |
| 725 | setverdict(pass); |
| 726 | } else { |
| 727 | repeat; |
| 728 | } |
| 729 | } |
| 730 | [] L1CTL.receive { repeat; } |
| 731 | [] T_sacch.timeout { |
| 732 | setverdict(fail, "Timeout waiting for SACCH ", l3_exp); |
| 733 | self.stop; |
| 734 | } |
| 735 | } |
| 736 | } |
| 737 | |
Harald Welte | 5570066 | 2018-03-12 13:15:43 +0100 | [diff] [blame] | 738 | /* verify that given SACCH payload is not present */ |
| 739 | private function f_sacch_missing(template octetstring l3_exp) runs on ConnHdlr { |
| 740 | var L1ctlDlMessage dl; |
| 741 | /* check that the specified SI5 value is actually sent */ |
| 742 | timer T_sacch := 3.0; |
| 743 | L1CTL.clear; |
| 744 | T_sacch.start; |
| 745 | alt { |
| 746 | [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(0))) -> value dl { |
| 747 | var octetstring l3 := substr(dl.payload.data_ind.payload, 4, 19); |
| 748 | if (match(l3, l3_exp)) { |
| 749 | setverdict(fail, "Received unexpected SACCH ", dl); |
| 750 | self.stop; |
| 751 | } else { |
| 752 | repeat; |
| 753 | } |
| 754 | } |
| 755 | [] L1CTL.receive { repeat; } |
| 756 | [] T_sacch.timeout { |
| 757 | setverdict(pass); |
| 758 | } |
| 759 | } |
| 760 | } |
| 761 | |
Harald Welte | 629cc6b | 2018-03-11 17:19:05 +0100 | [diff] [blame] | 762 | /* Test for default SACCH FILL transmitted in DL SACCH (all channel types) */ |
Harald Welte | ea17b91 | 2018-03-11 22:29:31 +0100 | [diff] [blame] | 763 | private function f_TC_sacch_filling(charstring id) runs on ConnHdlr { |
| 764 | /* Set a known default SACCH filling for SI5 */ |
| 765 | var octetstring si5 := f_rnd_octstring(19); |
| 766 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5)); |
| 767 | |
| 768 | f_l1_tune(L1CTL); |
| 769 | RSL.clear; |
| 770 | |
| 771 | /* activate the logical channel */ |
| 772 | f_est_dchan(); |
| 773 | |
| 774 | /* check that the specified SI5 value is actually sent */ |
| 775 | f_sacch_present(si5); |
| 776 | |
| 777 | /* release the channel */ |
| 778 | RSL.clear; |
| 779 | f_rsl_chan_deact(); |
| 780 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 781 | } |
| 782 | testcase TC_sacch_filling() runs on test_CT { |
| 783 | var ConnHdlr vc_conn; |
| 784 | var ConnHdlrPars pars; |
| 785 | f_init(); |
| 786 | for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) { |
| 787 | pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN)); |
| 788 | log(testcasename(), ": Starting for ", g_AllChannels[i]); |
| 789 | vc_conn := f_start_handler(refers(f_TC_sacch_filling), pars); |
| 790 | vc_conn.done; |
| 791 | } |
| 792 | /* TODO: do the above in parallel, rather than sequentially? */ |
| 793 | f_shutdown(); |
| 794 | } |
| 795 | |
Harald Welte | 629cc6b | 2018-03-11 17:19:05 +0100 | [diff] [blame] | 796 | /* Test for lchan-specific SACCH INFO MODIFY (TS 48.058 4.12) */ |
Harald Welte | ea17b91 | 2018-03-11 22:29:31 +0100 | [diff] [blame] | 797 | private function f_TC_sacch_info_mod(charstring id) runs on ConnHdlr { |
| 798 | /* Set a known default SACCH filling for SI5 */ |
| 799 | var octetstring si5 := f_rnd_octstring(19); |
| 800 | var octetstring si5_diff := f_rnd_octstring(19); |
| 801 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5)); |
| 802 | |
| 803 | f_l1_tune(L1CTL); |
| 804 | RSL.clear; |
| 805 | |
| 806 | log("Activating channel, expecting standard SI5"); |
| 807 | /* activate the logical channel */ |
| 808 | f_est_dchan(); |
| 809 | /* check that the specified SI5 value is actually sent */ |
| 810 | f_sacch_present(si5); |
| 811 | |
| 812 | /* set channel-specific different SI5 */ |
| 813 | log("Setting channel specific SACCH INFO, expecting it"); |
| 814 | RSL.send(ts_RSL_SACCH_INF_MOD(g_chan_nr, RSL_SYSTEM_INFO_5, si5_diff)) |
| 815 | /* check that the specified lchan-specific value is now used */ |
| 816 | f_sacch_present(si5_diff); |
| 817 | |
| 818 | /* deactivate the channel and re-activate it, this should result in default SI5 */ |
| 819 | log("De-activating and re-activating channel, expecting standard SI5"); |
| 820 | f_rsl_chan_deact(); |
| 821 | f_rsl_chan_act(valueof(ts_RSL_ChanMode_SIGN)); |
| 822 | /* Verify that the TRX-wide default SACCH filling is present again */ |
| 823 | f_sacch_present(si5); |
| 824 | |
| 825 | /* release the channel */ |
| 826 | RSL.clear; |
| 827 | f_rsl_chan_deact(); |
| 828 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 829 | } |
| 830 | testcase TC_sacch_info_mod() runs on test_CT { |
| 831 | var ConnHdlr vc_conn; |
| 832 | var ConnHdlrPars pars; |
| 833 | f_init(); |
| 834 | for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) { |
| 835 | pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN)); |
| 836 | log(testcasename(), ": Starting for ", g_AllChannels[i]); |
| 837 | vc_conn := f_start_handler(refers(f_TC_sacch_info_mod), pars); |
| 838 | vc_conn.done; |
| 839 | } |
| 840 | /* TODO: do the above in parallel, rather than sequentially? */ |
| 841 | f_shutdown(); |
| 842 | } |
| 843 | |
Harald Welte | 075d84c | 2018-03-12 13:07:24 +0100 | [diff] [blame] | 844 | /* Test SACCH scheduling of multiple different SI message types */ |
| 845 | private function f_TC_sacch_multi(charstring id) runs on ConnHdlr { |
| 846 | var octetstring si5 := f_rnd_octstring(19); |
| 847 | var octetstring si5bis := f_rnd_octstring(19); |
| 848 | var octetstring si5ter := f_rnd_octstring(19); |
| 849 | var octetstring si6 := f_rnd_octstring(19); |
| 850 | |
| 851 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5)); |
| 852 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5bis, si5bis)); |
| 853 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5ter, si5ter)); |
| 854 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_6, si6)); |
| 855 | |
| 856 | f_l1_tune(L1CTL); |
| 857 | RSL.clear; |
| 858 | |
| 859 | /* activate the logical channel */ |
| 860 | f_est_dchan(); |
| 861 | L1CTL.clear; |
| 862 | |
| 863 | /* check that SACCH actually are received as expected */ |
| 864 | f_sacch_present(si5); |
| 865 | f_sacch_present(si5bis); |
| 866 | f_sacch_present(si5ter); |
| 867 | f_sacch_present(si6); |
| 868 | |
| 869 | /* release the channel */ |
| 870 | f_rsl_chan_deact(); |
| 871 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 872 | } |
| 873 | testcase TC_sacch_multi() runs on test_CT { |
| 874 | var ConnHdlr vc_conn; |
| 875 | var ConnHdlrPars pars; |
| 876 | f_init(); |
| 877 | for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) { |
| 878 | pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN)); |
| 879 | log(testcasename(), ": Starting for ", g_AllChannels[i]); |
| 880 | vc_conn := f_start_handler(refers(f_TC_sacch_multi), pars); |
| 881 | vc_conn.done; |
| 882 | } |
| 883 | /* TODO: do the above in parallel, rather than sequentially? */ |
| 884 | f_shutdown(); |
| 885 | } |
| 886 | |
Harald Welte | 5570066 | 2018-03-12 13:15:43 +0100 | [diff] [blame] | 887 | /* Test if SACH information is modified as expected */ |
| 888 | private function f_TC_sacch_multi_chg(charstring id) runs on ConnHdlr { |
| 889 | var octetstring si5 := f_rnd_octstring(19); |
| 890 | var octetstring si6 := f_rnd_octstring(19); |
| 891 | |
| 892 | /* First, configure both SI5 and SI6 to be transmitted */ |
| 893 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5)); |
| 894 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_6, si6)); |
| 895 | |
| 896 | f_l1_tune(L1CTL); |
| 897 | RSL.clear; |
| 898 | |
| 899 | /* activate the logical channel */ |
| 900 | f_est_dchan(); |
| 901 | L1CTL.clear; |
| 902 | |
| 903 | /* check that SACCH actually are received as expected */ |
| 904 | f_sacch_present(si5); |
| 905 | f_sacch_present(si6); |
| 906 | |
| 907 | /* disable SI6 */ |
| 908 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_6, ''O)); |
| 909 | |
| 910 | /* check that SI5 is still transmitted */ |
| 911 | f_sacch_present(si5); |
| 912 | /* check if SI6 is now gone */ |
| 913 | f_sacch_missing(si6); |
| 914 | |
| 915 | /* release the channel */ |
| 916 | f_rsl_chan_deact(); |
| 917 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 918 | } |
| 919 | testcase TC_sacch_multi_chg() runs on test_CT { |
| 920 | var ConnHdlr vc_conn; |
| 921 | var ConnHdlrPars pars; |
| 922 | f_init(); |
| 923 | for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) { |
| 924 | pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN)); |
| 925 | log(testcasename(), ": Starting for ", g_AllChannels[i]); |
| 926 | vc_conn := f_start_handler(refers(f_TC_sacch_multi_chg), pars); |
| 927 | vc_conn.done; |
| 928 | } |
| 929 | /* TODO: do the above in parallel, rather than sequentially? */ |
| 930 | f_shutdown(); |
| 931 | } |
| 932 | |
Harald Welte | 075d84c | 2018-03-12 13:07:24 +0100 | [diff] [blame] | 933 | /* TODO: Test for SACCH information present in RSL CHAN ACT (overrides FILLING) */ |
| 934 | /* TODO: Test for SACCH transmission rules in the context of special CHAN ACT (HO) */ |
Harald Welte | 629cc6b | 2018-03-11 17:19:05 +0100 | [diff] [blame] | 935 | |
| 936 | |
| 937 | /*********************************************************************** |
Harald Welte | 93640c6 | 2018-02-25 16:59:33 +0100 | [diff] [blame] | 938 | * RACH Handling |
| 939 | ***********************************************************************/ |
| 940 | |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 941 | /* like L1SAP_IS_PACKET_RACH */ |
| 942 | private function ra_is_ps(OCT1 ra) return boolean { |
Harald Welte | 56c0580 | 2018-02-28 21:39:35 +0100 | [diff] [blame] | 943 | 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] | 944 | return true; |
| 945 | } |
| 946 | return false; |
| 947 | } |
| 948 | |
| 949 | /* generate a random RACH for circuit-switched */ |
| 950 | private function f_rnd_ra_cs() return OCT1 { |
| 951 | var OCT1 ra; |
| 952 | do { |
| 953 | ra := f_rnd_octstring(1); |
| 954 | } while (ra_is_ps(ra)); |
| 955 | return ra; |
| 956 | } |
| 957 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 958 | /* generate a random RACH for packet-switched */ |
| 959 | private function f_rnd_ra_ps() return OCT1 { |
| 960 | var OCT1 ra; |
| 961 | do { |
| 962 | ra := f_rnd_octstring(1); |
| 963 | } while (not ra_is_ps(ra)); |
| 964 | return ra; |
| 965 | } |
| 966 | |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 967 | /* Send 1000 RACH requests and check their RA+FN on the RSL side */ |
| 968 | testcase TC_rach_content() runs on test_CT { |
| 969 | f_init(testcasename()); |
| 970 | f_init_l1ctl(); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 971 | f_l1_tune(L1CTL); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 972 | |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 973 | var GsmFrameNumber fn_last := 0; |
| 974 | for (var integer i := 0; i < 1000; i := i+1) { |
| 975 | var OCT1 ra := f_rnd_ra_cs(); |
| 976 | var GsmFrameNumber fn := f_L1CTL_RACH(L1CTL, oct2int(ra)); |
| 977 | if (fn == fn_last) { |
| 978 | setverdict(fail, "Two RACH in same FN?!?"); |
| 979 | self.stop; |
| 980 | } |
| 981 | fn_last := fn; |
| 982 | |
| 983 | timer T := 5.0; |
Harald Welte | 56c0580 | 2018-02-28 21:39:35 +0100 | [diff] [blame] | 984 | T.start; |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 985 | alt { |
| 986 | [] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_CHAN_RQD(ra, fn, ?))) { |
| 987 | T.stop; |
| 988 | } |
| 989 | [] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_CHAN_RQD(?, ?, ?))) { |
| 990 | setverdict(fail, "Unexpected CHAN RQD"); |
| 991 | self.stop; |
| 992 | } |
| 993 | [] RSL_CCHAN.receive { repeat; } |
| 994 | [] T.timeout { |
| 995 | setverdict(fail, "Timeout waiting for CHAN RQD"); |
| 996 | self.stop; |
| 997 | } |
| 998 | } |
| 999 | } |
| 1000 | setverdict(pass); |
Harald Welte | 294b0a2 | 2018-03-10 23:26:48 +0100 | [diff] [blame] | 1001 | f_shutdown(); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1002 | } |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1003 | |
| 1004 | /* Send 1000 RACH Requests (flood ~ 89/s) and count if count(Abis) == count(Um) */ |
| 1005 | testcase TC_rach_count() runs on test_CT { |
Harald Welte | 294b0a2 | 2018-03-10 23:26:48 +0100 | [diff] [blame] | 1006 | f_init(); |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1007 | f_init_l1ctl(); |
Harald Welte | 294b0a2 | 2018-03-10 23:26:48 +0100 | [diff] [blame] | 1008 | f_sleep(1.0); |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1009 | f_l1_tune(L1CTL); |
| 1010 | |
| 1011 | var GsmFrameNumber fn_last := 0; |
| 1012 | for (var integer i := 0; i < 1000; i := i+1) { |
| 1013 | var OCT1 ra := f_rnd_ra_cs(); |
| 1014 | var GsmFrameNumber fn := f_L1CTL_RACH(L1CTL, oct2int(ra)); |
| 1015 | if (fn == fn_last) { |
| 1016 | setverdict(fail, "Two RACH in same FN?!?"); |
| 1017 | self.stop; |
| 1018 | } |
| 1019 | fn_last := fn; |
| 1020 | } |
| 1021 | var integer rsl_chrqd := 0; |
| 1022 | timer T := 3.0; |
Harald Welte | 56c0580 | 2018-02-28 21:39:35 +0100 | [diff] [blame] | 1023 | T.start; |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1024 | alt { |
| 1025 | [] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_CHAN_RQD(?,?))) { |
| 1026 | rsl_chrqd := rsl_chrqd + 1; |
Harald Welte | c3a3f45 | 2018-02-26 17:37:47 +0100 | [diff] [blame] | 1027 | f_timer_safe_restart(T); |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1028 | repeat; |
| 1029 | } |
| 1030 | [] RSL_CCHAN.receive { repeat; } |
| 1031 | [] T.timeout { } |
| 1032 | } |
| 1033 | if (rsl_chrqd == 1000) { |
| 1034 | setverdict(pass); |
| 1035 | } else { |
| 1036 | setverdict(fail, "Received only ", rsl_chrqd, " out of 1000 RACH"); |
| 1037 | } |
Harald Welte | 294b0a2 | 2018-03-10 23:26:48 +0100 | [diff] [blame] | 1038 | f_shutdown(); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1039 | } |
| 1040 | |
Harald Welte | 54a2a2d | 2018-02-26 09:14:05 +0100 | [diff] [blame] | 1041 | private function f_main_trxc_connect() runs on test_CT { |
| 1042 | map(self:BB_TRXC, system:BB_TRXC); |
| 1043 | var Result res; |
Harald Welte | d3a88a6 | 2018-03-01 16:04:52 +0100 | [diff] [blame] | 1044 | res := TRXC_CodecPort_CtrlFunct.f_IPL4_connect(BB_TRXC, mp_bb_trxc_ip, mp_bb_trxc_port, |
| 1045 | "", -1, -1, {udp:={}}, {}); |
Harald Welte | 54a2a2d | 2018-02-26 09:14:05 +0100 | [diff] [blame] | 1046 | g_bb_trxc_conn_id := res.connId; |
| 1047 | } |
| 1048 | |
| 1049 | 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] | 1050 | var TrxcMessage ret; |
Harald Welte | 54a2a2d | 2018-02-26 09:14:05 +0100 | [diff] [blame] | 1051 | /* tell fake_trx to use a given timing offset for all bursts */ |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 1052 | 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] | 1053 | f_sleep(0.5); |
| 1054 | |
| 1055 | /* Transmit RACH request + wait for confirmation */ |
| 1056 | var OCT1 ra := f_rnd_ra_cs(); |
| 1057 | var GsmFrameNumber fn := f_L1CTL_RACH(L1CTL, oct2int(ra)); |
| 1058 | |
| 1059 | /* Check for expected result */ |
| 1060 | timer T := 1.5; |
| 1061 | T.start; |
| 1062 | alt { |
| 1063 | [expect_pass] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_CHAN_RQD(ra, fn))) { |
| 1064 | setverdict(pass); |
| 1065 | } |
| 1066 | [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] | 1067 | setverdict(fail, "RACH passed but was expected to be dropped: ", toffs256); |
Harald Welte | 54a2a2d | 2018-02-26 09:14:05 +0100 | [diff] [blame] | 1068 | } |
| 1069 | [] RSL_CCHAN.receive { repeat; } |
| 1070 | [not expect_pass] T.timeout { |
| 1071 | setverdict(pass); |
| 1072 | } |
| 1073 | [expect_pass] T.timeout { |
| 1074 | setverdict(fail, "Timeout waiting for CHAN RQD"); |
| 1075 | } |
| 1076 | } |
| 1077 | } |
| 1078 | |
| 1079 | /* Test if dropping of RACH Based on NM_ATT_MAX_TA works */ |
| 1080 | testcase TC_rach_max_ta() runs on test_CT { |
| 1081 | f_init(testcasename()); |
| 1082 | f_init_l1ctl(); |
| 1083 | f_l1_tune(L1CTL); |
Harald Welte | 54a2a2d | 2018-02-26 09:14:05 +0100 | [diff] [blame] | 1084 | f_sleep(1.0); |
| 1085 | |
| 1086 | /* default max-ta is 63 (full range of GSM timing advance */ |
| 1087 | |
Vadim Yanitskiy | c81d6e4 | 2018-03-05 22:39:01 +0700 | [diff] [blame] | 1088 | /* We allow early arrival up to 2 symbols */ |
| 1089 | f_rach_toffs(-1*256, true); |
| 1090 | f_rach_toffs(-2*256, true); |
Harald Welte | 54a2a2d | 2018-02-26 09:14:05 +0100 | [diff] [blame] | 1091 | f_rach_toffs(-10*256, false); |
| 1092 | |
| 1093 | /* 0 / 32 / 63 bits is legal / permitted */ |
| 1094 | f_rach_toffs(0, true); |
| 1095 | f_rach_toffs(32*256, true); |
| 1096 | f_rach_toffs(63*256, true); |
| 1097 | |
| 1098 | /* more than 63 bits is not legal / permitted */ |
| 1099 | f_rach_toffs(64*256, false); |
| 1100 | f_rach_toffs(127*256, false); |
Harald Welte | 294b0a2 | 2018-03-10 23:26:48 +0100 | [diff] [blame] | 1101 | f_shutdown(); |
Harald Welte | 54a2a2d | 2018-02-26 09:14:05 +0100 | [diff] [blame] | 1102 | } |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1103 | |
Harald Welte | 93640c6 | 2018-02-25 16:59:33 +0100 | [diff] [blame] | 1104 | /*********************************************************************** |
| 1105 | * Measurement Processing / Reporting |
| 1106 | ***********************************************************************/ |
| 1107 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1108 | template LapdmAddressField ts_LapdmAddr(LapdmSapi sapi, boolean c_r) := { |
| 1109 | spare := '0'B, |
| 1110 | lpd := 0, |
| 1111 | sapi := sapi, |
| 1112 | c_r := c_r, |
| 1113 | ea := true |
| 1114 | } |
| 1115 | |
Harald Welte | d879bd9 | 2018-03-12 15:01:23 +0100 | [diff] [blame] | 1116 | template LapdmFrameAB ts_LAPDm_AB(LapdmSapi sapi, boolean c_r, boolean p, octetstring pl) := { |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1117 | addr := ts_LapdmAddr(sapi, c_r), |
Harald Welte | d879bd9 | 2018-03-12 15:01:23 +0100 | [diff] [blame] | 1118 | ctrl := ts_LapdmCtrlUI(p), |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1119 | len := 0, /* overwritten */ |
| 1120 | m := false, |
| 1121 | el := 1, |
| 1122 | payload := pl |
| 1123 | } |
| 1124 | |
| 1125 | /* handle incoming downlink SACCH and respond with uplink SACCH (meas res) */ |
| 1126 | altstep as_l1_sacch() runs on ConnHdlr { |
| 1127 | var L1ctlDlMessage l1_dl; |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 1128 | [] 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] | 1129 | log("SACCH received: ", l1_dl.payload.data_ind.payload); |
| 1130 | var GsmRrL3Message meas_rep := valueof(ts_MEAS_REP(true, 23, 23, 0, 0, omit)); |
Harald Welte | d879bd9 | 2018-03-12 15:01:23 +0100 | [diff] [blame] | 1131 | var LapdmFrameAB lb := valueof(ts_LAPDm_AB(0, false, false, enc_GsmRrL3Message(meas_rep))); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1132 | log("LAPDm: ", lb); |
Harald Welte | d879bd9 | 2018-03-12 15:01:23 +0100 | [diff] [blame] | 1133 | var octetstring pl := '0000'O & enc_LapdmFrameAB(lb); |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 1134 | 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] | 1135 | repeat; |
| 1136 | } |
| 1137 | } |
| 1138 | |
| 1139 | altstep as_l1_dcch() runs on ConnHdlr { |
| 1140 | var L1ctlDlMessage l1_dl; |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 1141 | [] 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] | 1142 | log("DCCH received: ", l1_dl.payload.data_ind.payload); |
| 1143 | var octetstring pl := '010301'O; |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 1144 | 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] | 1145 | repeat; |
| 1146 | } |
| 1147 | } |
| 1148 | |
| 1149 | type record MeasElem { |
| 1150 | uint6_t rxlev, |
| 1151 | uint3_t rxqual |
| 1152 | } |
| 1153 | |
| 1154 | type record MeasElemFS { |
| 1155 | MeasElem full, |
| 1156 | MeasElem sub |
| 1157 | } |
| 1158 | |
| 1159 | type record ConnL1Pars { |
| 1160 | boolean dtx_enabled, |
Harald Welte | 685d598 | 2018-02-27 20:42:05 +0100 | [diff] [blame] | 1161 | boolean toa256_enabled, |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1162 | MeasElemFS meas_ul, |
| 1163 | int16_t timing_offset_256syms, |
| 1164 | uint5_t bs_power_level, |
| 1165 | uint5_t ms_power_level, |
| 1166 | uint8_t ms_actual_ta |
| 1167 | } |
| 1168 | |
| 1169 | /* Convert tiing offset from 1/256th symbol to RSL Timing Offset */ |
| 1170 | private function toffs256s_to_rsl(int16_t toffs256s) return uint8_t { |
| 1171 | return 63 + (toffs256s/256); |
| 1172 | } |
| 1173 | |
Harald Welte | d568439 | 2018-03-10 18:22:04 +0100 | [diff] [blame] | 1174 | private function f_max(integer a, integer b) return integer { |
| 1175 | if (a > b) { |
| 1176 | return a; |
| 1177 | } else { |
| 1178 | return b; |
| 1179 | } |
| 1180 | } |
| 1181 | |
| 1182 | private function f_min(integer a, integer b) return integer { |
| 1183 | if (a < b) { |
| 1184 | return a; |
| 1185 | } else { |
| 1186 | return b; |
| 1187 | } |
| 1188 | } |
| 1189 | |
| 1190 | /* compute negative tolerance val-tolerance, ensure >= min */ |
| 1191 | private function f_tolerance_neg(integer val, integer min, integer tolerance) return integer { |
| 1192 | val := val - tolerance; |
| 1193 | return f_max(val, min); |
| 1194 | } |
| 1195 | |
| 1196 | /* compute positive tolerance val+tolerance, ensure <= max */ |
| 1197 | private function f_tolerance_pos(integer val, integer max, integer tolerance) return integer { |
| 1198 | val := val + tolerance; |
| 1199 | return f_min(val, max); |
| 1200 | } |
| 1201 | |
| 1202 | /* return a template of (val-tolerance .. val+tolerance) ensuring it is within (min .. max) */ |
| 1203 | private function f_tolerance(integer val, integer min, integer max, integer tolerance) |
| 1204 | return template integer { |
| 1205 | var template integer ret; |
| 1206 | ret := (f_tolerance_neg(val, min, tolerance) .. f_tolerance_pos(val, max, tolerance)); |
| 1207 | return ret; |
| 1208 | } |
| 1209 | |
| 1210 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1211 | /* build a template for matching measurement results against */ |
| 1212 | private function f_build_meas_res_tmpl() runs on ConnHdlr return template RSL_Message { |
| 1213 | var ConnL1Pars l1p := g_pars.l1_pars; |
| 1214 | var template RSL_IE_UplinkMeas ul_meas := { |
| 1215 | len := 3, |
| 1216 | rfu := '0'B, |
| 1217 | dtx_d := l1p.dtx_enabled, |
Harald Welte | d568439 | 2018-03-10 18:22:04 +0100 | [diff] [blame] | 1218 | 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] | 1219 | reserved1 := '00'B, |
Harald Welte | d568439 | 2018-03-10 18:22:04 +0100 | [diff] [blame] | 1220 | 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] | 1221 | reserved2 := '00'B, |
Harald Welte | d568439 | 2018-03-10 18:22:04 +0100 | [diff] [blame] | 1222 | rxq_f_u := f_tolerance(l1p.meas_ul.full.rxqual, 0, 7, mp_tolerance_rxqual), |
| 1223 | 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] | 1224 | supp_meas_info := omit |
| 1225 | }; |
Harald Welte | 685d598 | 2018-02-27 20:42:05 +0100 | [diff] [blame] | 1226 | if (l1p.toa256_enabled) { |
| 1227 | ul_meas.len := 5; |
| 1228 | ul_meas.supp_meas_info := int2oct(l1p.timing_offset_256syms, 2); |
| 1229 | } |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1230 | /* HACK HACK HACK FIXME HACK HACK HACK see https://osmocom.org/issues/2988 */ |
| 1231 | ul_meas.rxlev_f_u := ?; |
| 1232 | ul_meas.rxlev_s_u := ?; |
| 1233 | ul_meas.rxq_f_u := ?; |
| 1234 | ul_meas.rxq_s_u := ?; |
| 1235 | var template RSL_IE_BS_Power bs_power := { |
| 1236 | reserved := 0, |
| 1237 | epc := false, |
| 1238 | fpc := false, |
| 1239 | power_level := l1p.bs_power_level |
| 1240 | }; |
| 1241 | var template RSL_IE_L1Info l1_info := { |
| 1242 | ms_power_lvl := l1p.ms_power_level, |
| 1243 | fpc := false, |
| 1244 | reserved := 0, |
| 1245 | actual_ta := l1p.ms_actual_ta |
| 1246 | }; |
| 1247 | var uint8_t offs := toffs256s_to_rsl(l1p.timing_offset_256syms); |
| 1248 | var template uint8_t t_toffs := (offs-1 .. offs+1); /* some tolerance */ |
| 1249 | return tr_RSL_MEAS_RES_OSMO(g_chan_nr, g_next_meas_res_nr, ul_meas, bs_power, l1_info, |
| 1250 | ?, t_toffs); |
| 1251 | } |
| 1252 | |
| 1253 | /* verify we regularly receive measurement reports with incrementing numbers */ |
| 1254 | altstep as_meas_res() runs on ConnHdlr { |
| 1255 | var RSL_Message rsl; |
| 1256 | [] RSL.receive(f_build_meas_res_tmpl()) -> value rsl { |
| 1257 | /* increment counter of next to-be-expected meas rep */ |
| 1258 | g_next_meas_res_nr := (g_next_meas_res_nr + 1) mod 256; |
| 1259 | /* Re-start the timer expecting the next MEAS RES */ |
Harald Welte | c3a3f45 | 2018-02-26 17:37:47 +0100 | [diff] [blame] | 1260 | f_timer_safe_restart(g_Tmeas_exp); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1261 | repeat; |
| 1262 | } |
| 1263 | [] 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] | 1264 | /* increment counter of next to-be-expected meas rep */ |
| 1265 | g_next_meas_res_nr := (g_next_meas_res_nr + 1) mod 256; |
| 1266 | if (g_first_meas_res) { |
| 1267 | g_first_meas_res := false; |
| 1268 | repeat; |
| 1269 | } else { |
| 1270 | setverdict(fail, "Received unspecific MEAS RES ", rsl); |
| 1271 | self.stop; |
| 1272 | } |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1273 | } |
| 1274 | [] RSL.receive(tr_RSL_MEAS_RES(?)) -> value rsl { |
| 1275 | setverdict(fail, "Received unexpected MEAS RES ", rsl); |
| 1276 | self.stop; |
| 1277 | } |
| 1278 | [] g_Tmeas_exp.timeout { |
| 1279 | setverdict(fail, "Didn't receive expected measurement result") |
| 1280 | self.stop; |
| 1281 | } |
| 1282 | } |
| 1283 | |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 1284 | private function f_alg_id_to_l1ctl(RSL_AlgId rsl_alg_id) return uint8_t { |
| 1285 | select (rsl_alg_id) { |
| 1286 | case (RSL_ALG_ID_A5_0) { return 0; } |
| 1287 | case (RSL_ALG_ID_A5_1) { return 1; } |
| 1288 | case (RSL_ALG_ID_A5_2) { return 2; } |
| 1289 | case (RSL_ALG_ID_A5_3) { return 3; } |
| 1290 | case (RSL_ALG_ID_A5_4) { return 4; } |
| 1291 | case (RSL_ALG_ID_A5_5) { return 5; } |
| 1292 | case (RSL_ALG_ID_A5_6) { return 6; } |
| 1293 | case (RSL_ALG_ID_A5_7) { return 7; } |
| 1294 | case else { |
| 1295 | setverdict(fail, "Unknwon Algorithm ID"); |
| 1296 | self.stop; |
| 1297 | } |
| 1298 | } |
| 1299 | } |
| 1300 | |
| 1301 | private function f_alg_id_to_l3(RSL_AlgId rsl_alg_id) return BIT3 { |
| 1302 | select (rsl_alg_id) { |
| 1303 | case (RSL_ALG_ID_A5_1) { return '000'B; } |
| 1304 | case (RSL_ALG_ID_A5_2) { return '001'B; } |
| 1305 | case (RSL_ALG_ID_A5_3) { return '010'B; } |
| 1306 | case (RSL_ALG_ID_A5_4) { return '011'B; } |
| 1307 | case (RSL_ALG_ID_A5_5) { return '100'B; } |
| 1308 | case (RSL_ALG_ID_A5_6) { return '101'B; } |
| 1309 | case (RSL_ALG_ID_A5_7) { return '110'B; } |
| 1310 | case else { |
| 1311 | setverdict(fail, "Unknwon Algorithm ID"); |
| 1312 | self.stop; |
| 1313 | } |
| 1314 | } |
| 1315 | } |
| 1316 | |
| 1317 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1318 | /* Establish dedicated channel: L1CTL + RSL side */ |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 1319 | private function f_est_dchan(boolean encr_enable := false) runs on ConnHdlr { |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1320 | var GsmFrameNumber fn; |
| 1321 | var ImmediateAssignment imm_ass; |
| 1322 | var integer ra := 23; |
| 1323 | |
| 1324 | fn := f_L1CTL_RACH(L1CTL, ra); |
| 1325 | /* This arrives on CCHAN, so we cannot test for receiving CHAN RQDhere */ |
| 1326 | //RSL.receive(tr_RSL_CHAN_RQD(int2oct(23,1))); |
| 1327 | |
| 1328 | /* Activate channel on BTS side */ |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 1329 | f_rsl_chan_act(g_pars.chan_mode, encr_enable); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1330 | |
| 1331 | /* Send IMM.ASS via CCHAN */ |
| 1332 | var ChannelDescription ch_desc := { |
| 1333 | chan_nr := g_pars.chan_nr, |
| 1334 | tsc := 7, |
| 1335 | h := false, |
| 1336 | arfcn := mp_trx0_arfcn, |
| 1337 | maio_hsn := omit |
| 1338 | }; |
| 1339 | var MobileAllocation ma := { |
| 1340 | len := 0, |
| 1341 | ma := ''B |
| 1342 | }; |
| 1343 | var GsmRrMessage rr_msg := valueof(ts_IMM_ASS(ra, fn, 0, ch_desc, ma)); |
| 1344 | RSL.send(ts_RSL_IMM_ASSIGN(enc_GsmRrMessage(rr_msg))); |
| 1345 | |
| 1346 | /* receive IMM.ASS on MS side */ |
| 1347 | var ImmediateAssignment ia_um; |
| 1348 | ia_um := f_L1CTL_WAIT_IMM_ASS(L1CTL, ra, fn); |
| 1349 | /* enable dedicated mode */ |
| 1350 | f_L1CTL_DM_EST_REQ_IA(L1CTL, ia_um); |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 1351 | /* enable encryption, if requested */ |
| 1352 | if (encr_enable) { |
| 1353 | var uint8_t alg_id := f_alg_id_to_l1ctl(g_pars.encr.alg_id); |
| 1354 | f_L1CTL_CRYPTO_REQ(L1CTL, g_pars.chan_nr, alg_id, g_pars.encr.key); |
| 1355 | } |
Harald Welte | fa45e9e | 2018-03-10 18:59:03 +0100 | [diff] [blame] | 1356 | |
| 1357 | g_first_meas_res := true; |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1358 | } |
| 1359 | |
| 1360 | /* establish DChan, verify existance + contents of measurement reports */ |
| 1361 | function f_TC_meas_res_periodic(charstring id) runs on ConnHdlr { |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 1362 | f_l1_tune(L1CTL); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1363 | RSL.clear; |
| 1364 | |
Harald Welte | 5398d5e | 2018-03-10 19:00:24 +0100 | [diff] [blame] | 1365 | if (mp_bb_trxc_port != -1) { |
| 1366 | g_pars.l1_pars.meas_ul.full.rxlev := dbm2rxlev(-100); |
| 1367 | f_trxc_fake_rssi(100); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1368 | |
Harald Welte | 5398d5e | 2018-03-10 19:00:24 +0100 | [diff] [blame] | 1369 | g_pars.l1_pars.timing_offset_256syms := 512; /* 2 symbols */ |
| 1370 | f_trx_fake_toffs256(g_pars.l1_pars.timing_offset_256syms); |
| 1371 | } else { |
| 1372 | g_pars.l1_pars.timing_offset_256syms := 0; /* FIXME */ |
| 1373 | g_pars.l1_pars.meas_ul.full.rxlev := dbm2rxlev(-55); /* FIXME */ |
| 1374 | } |
| 1375 | 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] | 1376 | |
| 1377 | f_est_dchan(); |
| 1378 | |
| 1379 | /* run for a number of seconds, send SACCH + FACCH from MS side and verify |
| 1380 | * RSL measurement reports on Abis side */ |
| 1381 | timer T := 8.0; |
| 1382 | T.start; |
| 1383 | alt { |
| 1384 | [] as_l1_sacch(); |
| 1385 | [] as_meas_res(); |
| 1386 | [] as_l1_dcch(); |
| 1387 | [] L1CTL.receive { repeat; } |
| 1388 | [g_Tmeas_exp.running] T.timeout { |
| 1389 | /* as_meas_res() would have done setverdict(fail) / self.stop in case |
| 1390 | * of any earlier errors, so if we reach this timeout, we're good */ |
| 1391 | setverdict(pass); |
| 1392 | } |
| 1393 | [] T.timeout { |
| 1394 | setverdict(fail, "No MEAS RES received at all"); |
| 1395 | } |
| 1396 | } |
| 1397 | f_rsl_chan_deact(); |
Harald Welte | 3dc2046 | 2018-03-10 23:03:38 +0100 | [diff] [blame] | 1398 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1399 | } |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 1400 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1401 | testcase TC_meas_res_sign_tchf() runs on test_CT { |
| 1402 | var ConnHdlr vc_conn; |
| 1403 | var ConnHdlrPars pars; |
| 1404 | f_init(testcasename()); |
| 1405 | for (var integer tn := 1; tn <= 4; tn := tn+1) { |
| 1406 | pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN)); |
| 1407 | vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars); |
| 1408 | vc_conn.done; |
| 1409 | } |
Harald Welte | 294b0a2 | 2018-03-10 23:26:48 +0100 | [diff] [blame] | 1410 | f_shutdown(); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1411 | } |
| 1412 | testcase TC_meas_res_sign_tchh() runs on test_CT { |
| 1413 | var ConnHdlr vc_conn; |
| 1414 | var ConnHdlrPars pars; |
| 1415 | f_init(testcasename()); |
| 1416 | for (var integer ss := 0; ss <= 1; ss := ss+1) { |
| 1417 | pars := valueof(t_Pars(t_RslChanNr_Lm(5, ss), ts_RSL_ChanMode_SIGN)); |
| 1418 | vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars); |
| 1419 | vc_conn.done; |
| 1420 | } |
Harald Welte | 294b0a2 | 2018-03-10 23:26:48 +0100 | [diff] [blame] | 1421 | f_shutdown(); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1422 | } |
| 1423 | testcase TC_meas_res_sign_sdcch4() runs on test_CT { |
| 1424 | var ConnHdlr vc_conn; |
| 1425 | var ConnHdlrPars pars; |
| 1426 | f_init(testcasename()); |
| 1427 | for (var integer ss := 0; ss <= 3; ss := ss+1) { |
| 1428 | pars := valueof(t_Pars(t_RslChanNr_SDCCH4(0, ss), ts_RSL_ChanMode_SIGN)); |
| 1429 | vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars); |
| 1430 | vc_conn.done; |
| 1431 | } |
Harald Welte | 294b0a2 | 2018-03-10 23:26:48 +0100 | [diff] [blame] | 1432 | f_shutdown(); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1433 | } |
| 1434 | testcase TC_meas_res_sign_sdcch8() runs on test_CT { |
| 1435 | var ConnHdlr vc_conn; |
| 1436 | var ConnHdlrPars pars; |
| 1437 | f_init(testcasename()); |
| 1438 | for (var integer ss := 0; ss <= 7; ss := ss+1) { |
| 1439 | pars := valueof(t_Pars(t_RslChanNr_SDCCH8(6, ss), ts_RSL_ChanMode_SIGN)); |
| 1440 | vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars); |
| 1441 | vc_conn.done; |
| 1442 | } |
Harald Welte | 294b0a2 | 2018-03-10 23:26:48 +0100 | [diff] [blame] | 1443 | f_shutdown(); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1444 | } |
Harald Welte | 685d598 | 2018-02-27 20:42:05 +0100 | [diff] [blame] | 1445 | testcase TC_meas_res_sign_tchh_toa256() runs on test_CT { |
| 1446 | var ConnHdlr vc_conn; |
| 1447 | var ConnHdlrPars pars; |
| 1448 | f_init(testcasename()); |
| 1449 | f_vty_config(BTSVTY, "bts 0", "supp-meas-info toa256"); |
| 1450 | for (var integer ss := 0; ss <= 1; ss := ss+1) { |
| 1451 | pars := valueof(t_Pars(t_RslChanNr_Lm(5, ss), ts_RSL_ChanMode_SIGN)); |
| 1452 | pars.l1_pars.toa256_enabled := true; |
| 1453 | vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars); |
| 1454 | vc_conn.done; |
| 1455 | } |
Harald Welte | 294b0a2 | 2018-03-10 23:26:48 +0100 | [diff] [blame] | 1456 | f_shutdown(); |
Harald Welte | 685d598 | 2018-02-27 20:42:05 +0100 | [diff] [blame] | 1457 | } |
| 1458 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1459 | |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 1460 | /* Test if a channel without valid uplink bursts generates RSL CONN FAIL IND (TS 48.058 4.10) */ |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1461 | private function f_TC_conn_fail_crit(charstring id) runs on ConnHdlr { |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 1462 | f_l1_tune(L1CTL); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1463 | RSL.clear; |
| 1464 | |
| 1465 | f_est_dchan(); |
| 1466 | f_sleep(2.0); |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 1467 | L1CTL.send(ts_L1CTL_DM_REL_REQ(g_chan_nr)); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1468 | |
| 1469 | timer T := 40.0; |
| 1470 | T.start; |
| 1471 | alt { |
| 1472 | [] RSL.receive(tr_RSL_CONN_FAIL_IND(g_chan_nr, ?)) { |
| 1473 | setverdict(pass) |
| 1474 | } |
| 1475 | [] RSL.receive { repeat }; |
| 1476 | [] T.timeout { |
| 1477 | setverdict(fail, "No CONN FAIL IND received"); |
| 1478 | } |
| 1479 | } |
| 1480 | f_rsl_chan_deact(); |
| 1481 | } |
| 1482 | testcase TC_conn_fail_crit() runs on test_CT { |
| 1483 | var ConnHdlr vc_conn; |
| 1484 | var ConnHdlrPars pars; |
| 1485 | f_init(testcasename()); |
| 1486 | pars := valueof(t_Pars(t_RslChanNr_SDCCH8(6, 3), ts_RSL_ChanMode_SIGN)); |
| 1487 | pars.t_guard := 60.0; |
| 1488 | vc_conn := f_start_handler(refers(f_TC_conn_fail_crit), pars); |
| 1489 | vc_conn.done; |
| 1490 | } |
| 1491 | |
Harald Welte | 93640c6 | 2018-02-25 16:59:33 +0100 | [diff] [blame] | 1492 | /*********************************************************************** |
| 1493 | * Paging |
| 1494 | ***********************************************************************/ |
| 1495 | |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 1496 | function tmsi_is_dummy(TMSIP_TMSI_V tmsi) return boolean { |
| 1497 | if (tmsi == 'FFFFFFFF'O) { |
| 1498 | return true; |
| 1499 | } else { |
| 1500 | return false; |
| 1501 | } |
| 1502 | } |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1503 | |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 1504 | altstep as_l1_count_paging(inout integer num_paging_rcv_msgs, inout integer num_paging_rcv_ids) |
| 1505 | runs on test_CT { |
| 1506 | var L1ctlDlMessage dl; |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 1507 | [] 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] | 1508 | repeat; |
| 1509 | } |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 1510 | [] 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] | 1511 | var octetstring without_plen := |
| 1512 | substr(dl.payload.data_ind.payload, 1, lengthof(dl.payload.data_ind.payload)-1); |
| 1513 | var PDU_ML3_NW_MS rr := dec_PDU_ML3_NW_MS(without_plen); |
| 1514 | if (match(rr, tr_PAGING_REQ1)) { |
| 1515 | num_paging_rcv_msgs := num_paging_rcv_msgs + 1; |
| 1516 | num_paging_rcv_ids := num_paging_rcv_ids + 1; |
| 1517 | if (isvalue(rr.msgs.rrm.pagingReq_Type1.mobileIdentity2)) { |
| 1518 | num_paging_rcv_ids := num_paging_rcv_ids + 1; |
| 1519 | } |
| 1520 | } else if (match(rr, tr_PAGING_REQ2)) { |
| 1521 | num_paging_rcv_msgs := num_paging_rcv_msgs + 1; |
| 1522 | if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type2.mobileIdentity1)) { |
| 1523 | num_paging_rcv_ids := num_paging_rcv_ids + 1; |
| 1524 | } |
| 1525 | if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type2.mobileIdentity2)) { |
| 1526 | num_paging_rcv_ids := num_paging_rcv_ids + 1; |
| 1527 | } |
| 1528 | if (isvalue(rr.msgs.rrm.pagingReq_Type2.mobileIdentity3)) { |
| 1529 | num_paging_rcv_ids := num_paging_rcv_ids + 1; |
| 1530 | } |
| 1531 | } else if (match(rr, tr_PAGING_REQ3)) { |
| 1532 | num_paging_rcv_msgs := num_paging_rcv_msgs + 1; |
| 1533 | if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type3.mobileIdentity1)) { |
| 1534 | num_paging_rcv_ids := num_paging_rcv_ids + 1; |
| 1535 | } |
| 1536 | if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type3.mobileIdentity2)) { |
| 1537 | num_paging_rcv_ids := num_paging_rcv_ids + 1; |
| 1538 | } |
| 1539 | if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type3.mobileIdentity3)) { |
| 1540 | num_paging_rcv_ids := num_paging_rcv_ids + 1; |
| 1541 | } |
| 1542 | if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type3.mobileIdentity4)) { |
| 1543 | num_paging_rcv_ids := num_paging_rcv_ids + 1; |
| 1544 | } |
| 1545 | } |
| 1546 | repeat; |
| 1547 | } |
| 1548 | } |
| 1549 | |
| 1550 | type record PagingTestCfg { |
| 1551 | boolean combined_ccch, |
| 1552 | integer bs_ag_blks_res, |
| 1553 | float load_factor, |
| 1554 | boolean exp_load_ind, |
| 1555 | boolean exp_overload, |
| 1556 | boolean use_tmsi |
| 1557 | } |
| 1558 | |
| 1559 | type record PagingTestState { |
| 1560 | integer num_paging_sent, |
| 1561 | integer num_paging_rcv_msgs, |
| 1562 | integer num_paging_rcv_ids, |
| 1563 | integer num_overload |
| 1564 | } |
| 1565 | |
| 1566 | /* receive + ignore RSL RF RES IND */ |
| 1567 | altstep as_rsl_res_ind() runs on test_CT { |
| 1568 | [] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_RF_RES_IND)) { |
| 1569 | repeat; |
| 1570 | } |
| 1571 | } |
| 1572 | |
| 1573 | /* Helper function for paging related testing */ |
| 1574 | private function f_TC_paging(PagingTestCfg cfg) runs on test_CT return PagingTestState { |
| 1575 | f_init(testcasename()); |
| 1576 | f_init_l1ctl(); |
| 1577 | f_l1_tune(L1CTL); |
| 1578 | |
| 1579 | var PagingTestState st := { |
| 1580 | num_paging_sent := 0, |
| 1581 | num_paging_rcv_msgs := 0, |
| 1582 | num_paging_rcv_ids := 0, |
| 1583 | num_overload := 0 |
| 1584 | }; |
| 1585 | |
| 1586 | var float max_pch_blocks_per_sec := f_pch_block_rate_est(cfg.combined_ccch, cfg.bs_ag_blks_res); |
| 1587 | var float max_pch_imsi_per_sec; |
| 1588 | if (cfg.use_tmsi) { |
| 1589 | max_pch_imsi_per_sec := max_pch_blocks_per_sec * 4.0; /* Type 3 */ |
| 1590 | } else { |
| 1591 | max_pch_imsi_per_sec := max_pch_blocks_per_sec * 2.0; /* Type 1 */ |
| 1592 | } |
| 1593 | var float pch_blocks_per_sec := max_pch_imsi_per_sec * cfg.load_factor; |
| 1594 | var float interval := 1.0 / pch_blocks_per_sec; |
| 1595 | log("pch_blocks_per_sec=", pch_blocks_per_sec, " interval=", interval); |
| 1596 | |
| 1597 | for (var integer i := 0; i < float2int(20.0/interval); i := i+1) { |
| 1598 | /* build mobile Identity */ |
| 1599 | var MobileL3_CommonIE_Types.MobileIdentityLV mi; |
| 1600 | if (cfg.use_tmsi) { |
| 1601 | mi := valueof(ts_MI_TMSI_LV(f_rnd_octstring(4))); |
| 1602 | } else { |
| 1603 | mi := valueof(ts_MI_IMSI_LV(f_gen_imsi(i))); |
| 1604 | } |
| 1605 | var octetstring mi_enc_lv := enc_MobileIdentityLV(mi); |
| 1606 | var octetstring mi_enc := substr(mi_enc_lv, 1, lengthof(mi_enc_lv)-1); |
| 1607 | |
| 1608 | /* Send RSL PAGING COMMAND */ |
| 1609 | RSL_CCHAN.send(ts_RSL_UD(ts_RSL_PAGING_CMD(mi_enc, i mod 4))); |
| 1610 | st.num_paging_sent := st.num_paging_sent + 1; |
| 1611 | |
| 1612 | /* Wait for interval to next PAGING COMMAND */ |
| 1613 | timer T_itv := interval; |
| 1614 | T_itv.start; |
| 1615 | alt { |
| 1616 | /* check for presence of CCCH LOAD IND (paging load) */ |
| 1617 | [cfg.exp_overload] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_PAGING_LOAD_IND(0))) { |
| 1618 | st.num_overload := st.num_overload + 1; |
| 1619 | repeat; |
| 1620 | } |
| 1621 | [not cfg.exp_overload] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_PAGING_LOAD_IND(0))) { |
| 1622 | setverdict(fail, "Unexpected PCH Overload"); |
| 1623 | } |
| 1624 | [cfg.exp_load_ind] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_PAGING_LOAD_IND)) { |
| 1625 | log("Rx LOAD_IND"); |
| 1626 | /* FIXME: analyze/verify interval + contents */ |
| 1627 | repeat; |
| 1628 | } |
| 1629 | /* check if paging requests arrive on Um side */ |
| 1630 | [] as_l1_count_paging(st.num_paging_rcv_msgs, st.num_paging_rcv_ids); |
| 1631 | [] L1CTL.receive { repeat; } |
| 1632 | [] T_itv.timeout { } |
| 1633 | [] as_rsl_res_ind(); |
| 1634 | } |
| 1635 | } |
| 1636 | |
| 1637 | /* wait for max 18s for paging queue to drain (size: 200, ~ 13 per s -> 15s) */ |
| 1638 | timer T_wait := 18.0; |
| 1639 | T_wait.start; |
| 1640 | alt { |
| 1641 | [] as_l1_count_paging(st.num_paging_rcv_msgs, st.num_paging_rcv_ids); |
| 1642 | [] L1CTL.receive { repeat; } |
| 1643 | /* 65535 == empty paging queue, we can terminate*/ |
| 1644 | [] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_PAGING_LOAD_IND(65535))) { } |
| 1645 | [] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_PAGING_LOAD_IND)) { repeat; } |
| 1646 | [] T_wait.timeout { |
| 1647 | setverdict(fail, "Waiting for empty paging queue"); |
| 1648 | } |
| 1649 | [] as_rsl_res_ind(); |
| 1650 | } |
| 1651 | |
Harald Welte | 294b0a2 | 2018-03-10 23:26:48 +0100 | [diff] [blame] | 1652 | f_shutdown(); |
| 1653 | |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 1654 | log("num_paging_sent=", st.num_paging_sent, " rcvd_msgs=", st.num_paging_rcv_msgs, |
| 1655 | " rcvd_ids=", st.num_paging_rcv_ids); |
| 1656 | return st; |
| 1657 | } |
| 1658 | |
| 1659 | /* Create ~ 80% paging load (IMSI only) sustained for about 20s, verifying that |
| 1660 | * - the number of Mobile Identities on Um PCH match the number of pages on RSL |
| 1661 | * - that CCCH LOAD IND (PCH) are being generated |
| 1662 | * - that CCCH LOAD IND (PCH) [no load] is received after paging flood is over */ |
| 1663 | testcase TC_paging_imsi_80percent() runs on test_CT { |
| 1664 | var PagingTestCfg cfg := { |
| 1665 | combined_ccch := true, |
| 1666 | bs_ag_blks_res := 1, |
| 1667 | load_factor := 0.8, |
| 1668 | exp_load_ind := true, |
| 1669 | exp_overload := false, |
| 1670 | use_tmsi := false |
| 1671 | }; |
| 1672 | var PagingTestState st := f_TC_paging(cfg); |
| 1673 | if (st.num_paging_sent != st.num_paging_rcv_ids) { |
| 1674 | setverdict(fail, "Expected ", st.num_paging_sent, " pagings but have ", |
| 1675 | st.num_paging_rcv_ids); |
| 1676 | } else { |
| 1677 | setverdict(pass); |
| 1678 | } |
| 1679 | } |
| 1680 | |
| 1681 | /* Create ~ 80% paging load (TMSI only) sustained for about 20s, verifying that |
| 1682 | * - the number of Mobile Identities on Um PCH match the number of pages on RSL |
| 1683 | * - that CCCH LOAD IND (PCH) are being generated |
| 1684 | * - that CCCH LOAD IND (PCH) [no load] is received after paging flood is over */ |
| 1685 | testcase TC_paging_tmsi_80percent() runs on test_CT { |
| 1686 | var PagingTestCfg cfg := { |
| 1687 | combined_ccch := true, |
| 1688 | bs_ag_blks_res := 1, |
| 1689 | load_factor := 0.8, |
| 1690 | exp_load_ind := true, |
| 1691 | exp_overload := false, |
| 1692 | use_tmsi := true |
| 1693 | }; |
| 1694 | var PagingTestState st := f_TC_paging(cfg); |
| 1695 | if (st.num_paging_sent != st.num_paging_rcv_ids) { |
| 1696 | setverdict(fail, "Expected ", st.num_paging_sent, " pagings but have ", |
| 1697 | st.num_paging_rcv_ids); |
| 1698 | } else { |
| 1699 | setverdict(pass); |
| 1700 | } |
| 1701 | } |
| 1702 | |
| 1703 | /* Create ~ 200% paging load (IMSI only) sustained for about 20s, verifying that |
| 1704 | * - the number of Mobile Identities on Um PCH are ~ 82% of the number of pages on RSL |
| 1705 | * - that CCCH LOAD IND (PCH) are being generated and reach 0 at some point |
| 1706 | * - that CCCH LOAD IND (PCH) [no load] is received after paging flood is over */ |
| 1707 | testcase TC_paging_imsi_200percent() runs on test_CT { |
| 1708 | var PagingTestCfg cfg := { |
| 1709 | combined_ccch := true, |
| 1710 | bs_ag_blks_res := 1, |
| 1711 | load_factor := 2.0, |
| 1712 | exp_load_ind := true, |
| 1713 | exp_overload := true, |
| 1714 | use_tmsi := false |
| 1715 | }; |
| 1716 | var PagingTestState st := f_TC_paging(cfg); |
| 1717 | /* We expect about 80-85% to pass, given that we can fill the paging buffer of 200 |
| 1718 | * slots and will fully drain that buffer before returning */ |
| 1719 | var template integer tpl := (st.num_paging_sent*80/100 .. st.num_paging_sent *85/100); |
| 1720 | if (not match(st.num_paging_rcv_ids, tpl)) { |
| 1721 | setverdict(fail, "Expected ", tpl, " pagings but have ", st.num_paging_rcv_ids); |
| 1722 | } else { |
| 1723 | setverdict(pass); |
| 1724 | } |
| 1725 | } |
| 1726 | |
| 1727 | /* Create ~ 200% paging load (TMSI only) sustained for about 20s, verifying that |
| 1728 | * - the number of Mobile Identities on Um PCH are ~ 82% of the number of pages on RSL |
| 1729 | * - that CCCH LOAD IND (PCH) are being generated and reach 0 at some point |
| 1730 | * - that CCCH LOAD IND (PCH) [no load] is received after paging flood is over */ |
| 1731 | testcase TC_paging_tmsi_200percent() runs on test_CT { |
| 1732 | var PagingTestCfg cfg := { |
| 1733 | combined_ccch := true, |
| 1734 | bs_ag_blks_res := 1, |
| 1735 | load_factor := 2.0, |
| 1736 | exp_load_ind := true, |
| 1737 | exp_overload := true, |
| 1738 | use_tmsi := true |
| 1739 | }; |
| 1740 | var PagingTestState st := f_TC_paging(cfg); |
| 1741 | /* We expect about 70% to pass, given that we can fill the paging buffer of 200 |
| 1742 | * slots and will fully drain that buffer before returning */ |
Harald Welte | 0803cde | 2018-04-15 21:36:54 +0200 | [diff] [blame] | 1743 | var template integer tpl := (st.num_paging_sent*66/100 .. st.num_paging_sent *72/100); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 1744 | if (not match(st.num_paging_rcv_ids, tpl)) { |
| 1745 | setverdict(fail, "Expected ", tpl, " pagings but have ", st.num_paging_rcv_ids); |
| 1746 | } else { |
| 1747 | setverdict(pass); |
| 1748 | } |
| 1749 | } |
| 1750 | |
| 1751 | |
Harald Welte | 93640c6 | 2018-02-25 16:59:33 +0100 | [diff] [blame] | 1752 | /*********************************************************************** |
| 1753 | * Immediate Assignment / AGCH |
| 1754 | ***********************************************************************/ |
| 1755 | |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 1756 | testcase TC_imm_ass() runs on test_CT { |
| 1757 | f_init(testcasename()); |
| 1758 | for (var integer i := 0; i < 1000; i := i+1) { |
| 1759 | var octetstring ia_enc := f_rnd_octstring(8); |
| 1760 | RSL_CCHAN.send(ts_RSL_UD(ts_RSL_IMM_ASSIGN(ia_enc, 0))); |
| 1761 | f_sleep(0.02); |
| 1762 | } |
| 1763 | /* FIXME: check if imm.ass arrive on Um side */ |
| 1764 | /* FIXME: check for DELETE INDICATION */ |
| 1765 | f_sleep(100.0); |
Harald Welte | 294b0a2 | 2018-03-10 23:26:48 +0100 | [diff] [blame] | 1766 | f_shutdown(); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 1767 | } |
| 1768 | |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 1769 | /*********************************************************************** |
| 1770 | * BCCH |
| 1771 | ***********************************************************************/ |
| 1772 | |
| 1773 | /* tuple of Frame Number + decoded SI */ |
| 1774 | type record SystemInformationFn { |
| 1775 | GsmFrameNumber frame_number, |
| 1776 | SystemInformation si |
| 1777 | } |
| 1778 | |
| 1779 | /* an arbitrary-length vector of decoded SI + gsmtap header */ |
| 1780 | type record of SystemInformationFn SystemInformationVector; |
| 1781 | |
| 1782 | /* an array of SI-vectors indexed by TC value */ |
| 1783 | type SystemInformationVector SystemInformationVectorPerTc[8]; |
| 1784 | |
| 1785 | /* determine if a given SI vector contains given SI type at least once */ |
| 1786 | function f_si_vecslot_contains(SystemInformationVector arr, RrMessageType key, boolean bcch_ext := false) return boolean { |
| 1787 | for (var integer i:= 0; i< sizeof(arr); i := i + 1) { |
| 1788 | var integer fn_mod51 := arr[i].frame_number mod 51; |
| 1789 | if (not bcch_ext and fn_mod51 == 2 or |
| 1790 | bcch_ext and fn_mod51 == 6) { |
| 1791 | if (arr[i].si.header.message_type == key) { |
| 1792 | return true; |
| 1793 | } |
| 1794 | } |
| 1795 | } |
| 1796 | return false; |
| 1797 | } |
| 1798 | |
| 1799 | /* ensure a given TC slot of the SI vector contains given SI type at least once at TC */ |
| 1800 | function f_ensure_si_vec_contains(SystemInformationVectorPerTc arr, integer tc, RrMessageType key, boolean ext_bcch := false) { |
| 1801 | if (not f_si_vecslot_contains(arr[tc], key, ext_bcch)) { |
| 1802 | setverdict(fail, "No ", key, " in TC=", tc, "!"); |
| 1803 | } |
| 1804 | } |
| 1805 | |
| 1806 | /* check if a given SI vector contains given SI type at least once on any TC */ |
| 1807 | function f_si_vec_contains(SystemInformationVectorPerTc arr, RrMessageType key) return boolean { |
| 1808 | for (var integer tc:= 0; tc < sizeof(arr); tc := tc + 1) { |
| 1809 | if (f_si_vecslot_contains(arr[tc], key) or |
| 1810 | f_si_vecslot_contains(arr[tc], key, true)) { |
| 1811 | return true; |
| 1812 | } |
| 1813 | } |
| 1814 | return false; |
| 1815 | } |
| 1816 | |
| 1817 | /* determine if a given SI vector contains given SI type at least N of M times */ |
| 1818 | function f_si_vecslot_contains_n_of_m(SystemInformationVector arr, RrMessageType key, boolean bcch_ext := false, integer n := 1, integer m := 4) return boolean { |
| 1819 | var integer count := 0; |
| 1820 | if (sizeof(arr) < m) { |
| 1821 | setverdict(fail, "Error: Insufficient SI in array"); |
| 1822 | self.stop; |
| 1823 | } |
| 1824 | for (var integer i:= 0; i < m; i := i + 1) { |
| 1825 | var integer fn_mod51 := arr[i].frame_number mod 51; |
| 1826 | if (not bcch_ext and fn_mod51 == 2 or |
| 1827 | bcch_ext and fn_mod51 == 6) { |
| 1828 | if (arr[i].si.header.message_type == key) { |
| 1829 | count := count + 1; |
| 1830 | } |
| 1831 | } |
| 1832 | } |
| 1833 | if (count >= n) { |
| 1834 | return true; |
| 1835 | } else { |
| 1836 | return false; |
| 1837 | } |
| 1838 | } |
| 1839 | |
| 1840 | /* ensure a given TC slot of the SI vector contains given SI type at least N out of M times at TC */ |
| 1841 | function f_ensure_si_vec_contains_n_of_m(SystemInformationVectorPerTc arr, integer tc, RrMessageType key, boolean ext_bcch := false, integer n, integer m) { |
| 1842 | if (not f_si_vecslot_contains_n_of_m(arr[tc], key, ext_bcch, n, m)) { |
| 1843 | setverdict(fail, "Not ", n, "/", m, " of ", key, " in TC=", tc, "!"); |
| 1844 | } |
| 1845 | } |
| 1846 | |
| 1847 | /* determine if a given SI vector contains given SI type at least once */ |
| 1848 | function f_si_vecslot_contains_only(SystemInformationVector arr, RrMessageType key, boolean bcch_ext := false) return boolean { |
| 1849 | for (var integer i:= 0; i< sizeof(arr); i := i + 1) { |
| 1850 | var integer fn_mod51 := arr[i].frame_number mod 51; |
| 1851 | if (not bcch_ext and fn_mod51 == 2 or |
| 1852 | bcch_ext and fn_mod51 == 6) { |
| 1853 | if (arr[i].si.header.message_type != key) { |
| 1854 | return false; |
| 1855 | } |
| 1856 | } |
| 1857 | } |
| 1858 | return true; |
| 1859 | } |
| 1860 | |
| 1861 | /* ensure a given TC slot of the SI vector contains only given SI type */ |
| 1862 | function f_ensure_si_vec_contains_only(SystemInformationVectorPerTc arr, integer tc, RrMessageType key, boolean ext_bcch := false) { |
| 1863 | if (not f_si_vecslot_contains_only(arr[tc], key, ext_bcch)) { |
| 1864 | setverdict(fail, "Not all ", key, " in TC=", tc, "!"); |
| 1865 | } |
| 1866 | } |
| 1867 | |
| 1868 | /* SI configuration of cell, against which we validate actual SI messages */ |
| 1869 | type set SystemInformationConfig { |
| 1870 | boolean bcch_extended, |
| 1871 | boolean si1_present, |
| 1872 | boolean si2bis_present, |
| 1873 | boolean si2ter_present, |
| 1874 | boolean si2quater_present, |
| 1875 | boolean si7_present, |
| 1876 | boolean si8_present, |
| 1877 | boolean si9_present, |
| 1878 | boolean si13_present, |
| 1879 | boolean si13alt_present, |
| 1880 | boolean si15_present, |
| 1881 | boolean si16_present, |
| 1882 | boolean si17_present, |
| 1883 | boolean si2n_present, |
| 1884 | boolean si21_present, |
| 1885 | boolean si22_present |
| 1886 | } |
| 1887 | |
| 1888 | /* validate the SI scheduling according to TS 45.002 version 14.1.0 Release 14, Section 6.3.1.3 */ |
| 1889 | function f_validate_si_scheduling(SystemInformationConfig cfg, SystemInformationVectorPerTc si_per_tc) { |
| 1890 | var integer i; |
| 1891 | for (i := 0; i < sizeof(si_per_tc); i := i + 1) { |
| 1892 | if (sizeof(si_per_tc[i]) == 0) { |
Harald Welte | 544565a | 2018-03-02 10:34:08 +0100 | [diff] [blame] | 1893 | setverdict(fail, "No SI messages for TC=", i); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 1894 | } |
| 1895 | } |
| 1896 | if (cfg.si1_present) { |
| 1897 | /* ii) System Information Type 1 needs to be sent if frequency hopping is in use or |
| 1898 | * when the NCH is present in a cell. If the MS finds another message on BCCH Norm |
| 1899 | * when TC = 0, it can assume that System Information Type 1 is not in use. */ |
| 1900 | f_ensure_si_vec_contains(si_per_tc, 0, SYSTEM_INFORMATION_TYPE_1); |
| 1901 | /* make sure *ALL* contain SI1 */ |
| 1902 | f_ensure_si_vec_contains_only(si_per_tc, 0, SYSTEM_INFORMATION_TYPE_1); |
| 1903 | } |
| 1904 | f_ensure_si_vec_contains(si_per_tc, 1, SYSTEM_INFORMATION_TYPE_2); |
| 1905 | /* iii) A SI 2 message will be sent at least every time TC = 1 */ |
| 1906 | f_ensure_si_vec_contains(si_per_tc, 2, SYSTEM_INFORMATION_TYPE_3); |
| 1907 | f_ensure_si_vec_contains(si_per_tc, 6, SYSTEM_INFORMATION_TYPE_3); |
| 1908 | f_ensure_si_vec_contains(si_per_tc, 3, SYSTEM_INFORMATION_TYPE_4); |
| 1909 | f_ensure_si_vec_contains(si_per_tc, 7, SYSTEM_INFORMATION_TYPE_4); |
| 1910 | |
| 1911 | /* iii) System information type 2 bis or 2 ter messages are sent if needed, as determined by the |
| 1912 | * system operator. If only one of them is needed, it is sent when TC = 5. If both are |
| 1913 | * needed, 2bis is sent when TC = 5 and 2ter is sent at least once within any of 4 |
| 1914 | * consecutive occurrences of TC = 4. */ |
| 1915 | if (cfg.si2bis_present and not cfg.si2ter_present) { |
| 1916 | f_ensure_si_vec_contains(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2bis); |
| 1917 | } else if (cfg.si2ter_present and not cfg.si2bis_present) { |
| 1918 | f_ensure_si_vec_contains(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2ter); |
| 1919 | } else if (cfg.si2ter_present and cfg.si2bis_present) { |
| 1920 | f_ensure_si_vec_contains(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2bis); |
| 1921 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_2ter, false, 1, 4); |
| 1922 | } |
| 1923 | |
| 1924 | if (cfg.si7_present or cfg.si8_present) { |
| 1925 | /* vi) Use of System Information type 7 and 8 is not always necessary. It is necessary |
| 1926 | * if System Information type 4 does not contain all information needed for cell |
| 1927 | * selection and reselection. */ |
| 1928 | if (not cfg.bcch_extended) { |
| 1929 | testcase.stop("Error: SI7/SI8 require BCCH Extd."); |
| 1930 | } |
| 1931 | if (cfg.si7_present) { |
| 1932 | f_ensure_si_vec_contains(si_per_tc, 7, SYSTEM_INFORMATION_TYPE_7, true); |
| 1933 | } |
| 1934 | if (cfg.si8_present) { |
| 1935 | f_ensure_si_vec_contains(si_per_tc, 3, SYSTEM_INFORMATION_TYPE_8, true); |
| 1936 | } |
| 1937 | } |
| 1938 | |
| 1939 | if (cfg.si2quater_present) { |
| 1940 | /* iii) System information type 2 quater is sent if needed, as determined by the system |
| 1941 | * operator. If sent on BCCH Norm, it shall be sent when TC = 5 if neither of 2bis |
| 1942 | * and 2ter are used, otherwise it shall be sent at least once within any of 4 |
| 1943 | * consecutive occurrences of TC = 4. If sent on BCCH Ext, it is sent at least once |
| 1944 | * within any of 4 consecutive occurrences of TC = 5. */ |
| 1945 | if (not (cfg.bcch_extended)) { |
| 1946 | if (not (cfg.si2bis_present or cfg.si2ter_present)) { |
| 1947 | f_ensure_si_vec_contains(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2quater); |
| 1948 | } else { |
| 1949 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_2quater, false, 1, 4); |
| 1950 | } |
| 1951 | } else { |
| 1952 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2quater, true, 1, 4); |
| 1953 | } |
| 1954 | } |
| 1955 | if (cfg.si9_present) { |
| 1956 | /* vi) System Information type 9 is sent in those blocks with TC = 4 which are specified |
| 1957 | * in system information type 3 as defined in 3GPP TS 44.018. */ |
| 1958 | f_ensure_si_vec_contains(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_9); // FIXME SI3 |
| 1959 | } |
| 1960 | if (cfg.si13_present) { |
| 1961 | /* vii) System Information type 13 is only related to the GPRS service. System Information |
| 1962 | * Type 13 need only be sent if GPRS support is indicated in one or more of System |
| 1963 | * Information Type 3 or 4 or 7 or 8 messages. These messages also indicate if the |
| 1964 | * message is sent on the BCCH Norm or if the message is transmitted on the BCCH Ext. |
| 1965 | * In the case that the message is sent on the BCCH Norm, it is sent at least once |
| 1966 | * within any of 4 consecutive occurrences of TC=4. */ |
| 1967 | if (not cfg.bcch_extended) { |
| 1968 | log("not-bccch-extended"); |
| 1969 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_13, false, 1, 4); |
| 1970 | } else { |
| 1971 | log("bccch-extended"); |
| 1972 | f_ensure_si_vec_contains(si_per_tc, 0, SYSTEM_INFORMATION_TYPE_13, true); |
| 1973 | } |
| 1974 | if (f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_13alt)) { |
| 1975 | setverdict(fail, "Cannot have SI13alt and SI13"); |
| 1976 | } |
| 1977 | } |
| 1978 | if (cfg.si16_present or cfg.si17_present) { |
| 1979 | /* viii) System Information type 16 and 17 are only related to the SoLSA service. They |
| 1980 | * should not be sent in a cell where network sharing is used (see rule xv). */ |
| 1981 | if (cfg.si22_present) { |
| 1982 | testcase.stop("Error: Cannot have SI16/SI17 and SI22!"); |
| 1983 | } |
| 1984 | if (f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_22)) { |
| 1985 | setverdict(fail, "Cannot have SI16/SI17 and SI22!"); |
| 1986 | } |
| 1987 | if (not cfg.bcch_extended) { |
| 1988 | testcase.stop("Error: SI16/SI17 requires BCCH Extd!"); |
| 1989 | } |
| 1990 | if (cfg.si16_present) { |
| 1991 | f_ensure_si_vec_contains(si_per_tc, 6, SYSTEM_INFORMATION_TYPE_16, true); |
| 1992 | } |
| 1993 | if (cfg.si17_present) { |
| 1994 | f_ensure_si_vec_contains(si_per_tc, 2, SYSTEM_INFORMATION_TYPE_17, true); |
| 1995 | } |
| 1996 | } |
| 1997 | |
| 1998 | /* ix) System Information type 18 and 20 are sent in order to transmit non-GSM |
| 1999 | * broadcast information. The frequency with which they are sent is determined by the |
| 2000 | * system operator. System Information type 9 identifies the scheduling of System |
| 2001 | * Information type 18 and 20 messages. */ |
| 2002 | |
| 2003 | /* x) System Information Type 19 is sent if COMPACT neighbours exist. If System |
| 2004 | * Information Type 19 is present, then its scheduling shall be indicated in System |
| 2005 | * Information Type 9. */ |
| 2006 | |
| 2007 | if (cfg.si15_present) { |
| 2008 | /* xi) System Information Type 15 is broadcast if dynamic ARFCN mapping is used in the |
| 2009 | * PLMN. If sent on BCCH Norm, it is sent at least once within any of 4 consecutive |
| 2010 | * occurrences of TC = 4. If sent on BCCH Ext, it is sent at least once within any of |
| 2011 | * 4 consecutive occurrences of TC = 1. */ |
| 2012 | if (not cfg.bcch_extended) { |
| 2013 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_15, false, 1, 4); |
| 2014 | } else { |
| 2015 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 1, SYSTEM_INFORMATION_TYPE_15, true, 1, 4); |
| 2016 | } |
| 2017 | } |
| 2018 | if (cfg.si13alt_present) { |
| 2019 | /* xii) System Information type 13 alt is only related to the GERAN Iu mode. System |
| 2020 | * Information Type 13 alt need only be sent if GERAN Iu mode support is indicated in |
| 2021 | * one or more of System Information Type 3 or 4 or 7 or 8 messages and SI 13 is not |
| 2022 | * broadcast. These messages also indicate if the message is sent on the BCCH Norm or |
| 2023 | * if the message is transmitted on the BCCH Ext. In the case that the message is sent |
| 2024 | * on the BCCH Norm, it is sent at least once within any of 4 consecutive occurrences |
| 2025 | * of TC = 4. */ |
| 2026 | if (cfg.si13_present) { |
| 2027 | testcase.stop("Error: Cannot have SI13alt and SI13"); |
| 2028 | } |
| 2029 | if (f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_13)) { |
| 2030 | setverdict(fail, "Cannot have SI13alt and SI13"); |
| 2031 | } |
| 2032 | if (not cfg.bcch_extended) { |
| 2033 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_13alt, false, 1, 4); |
| 2034 | } else { |
| 2035 | f_ensure_si_vec_contains(si_per_tc, 0, SYSTEM_INFORMATION_TYPE_13alt, true); |
| 2036 | } |
| 2037 | } |
| 2038 | if (cfg.si2n_present) { |
| 2039 | /* xiii) System Information Type 2n is optionally sent on BCCH Norm or BCCH Ext if needed, |
| 2040 | * as determined by the system operator. In the case that the message is sent on the |
| 2041 | * BCCH Norm, it is sent at least once within any of 4 consecutive occurrences of TC = |
| 2042 | * 4. If the message is sent on BCCH Ext, it is sent at least once within any of 2 |
| 2043 | * consecutive occurrences of TC = 4. */ |
| 2044 | if (not cfg.bcch_extended) { |
| 2045 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_2n, false, 1, 4); |
| 2046 | } else { |
| 2047 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_2n, true, 2, 4); |
| 2048 | } |
| 2049 | } |
| 2050 | if (cfg.si21_present) { |
| 2051 | /* xiv) System Information Type 21 is optionally sent on BCCH Norm or BCCH Ext, as |
| 2052 | * determined by the system operator. If Extended Access Barring is in use in the cell |
| 2053 | * then this message is sent at least once within any of 4 consecutive occurrences of |
| 2054 | * TC = 4 regardless if it is sent on BCCH Norm or BCCH Ext. If BCCH Ext is used in a |
| 2055 | * cell then this message shall only be sent on BCCH Ext. */ |
| 2056 | if (not cfg.bcch_extended) { |
| 2057 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_21, false, 1, 4); |
| 2058 | } else { |
| 2059 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_21, true, 1, 4); |
| 2060 | if (f_si_vecslot_contains(si_per_tc[4], SYSTEM_INFORMATION_TYPE_21)) { |
| 2061 | setverdict(fail, "Cannot have SI21 on BCCH Norm if BCCH Extd enabled!"); |
| 2062 | } |
| 2063 | } |
| 2064 | } |
| 2065 | if (cfg.si22_present) { |
| 2066 | /* xv) System Information Type 22 is sent if network sharing is in use in the cell. It |
| 2067 | * should not be sent in a cell where SoLSA is used (see rule viii). System |
| 2068 | * Information Type 22 instances shall be sent on BCCH Ext within any occurrence of TC |
| 2069 | * =2 and TC=6. */ |
| 2070 | if (cfg.si16_present or cfg.si17_present) { |
| 2071 | testcase.stop("Error: Cannot have SI16/SI17 and SI22!"); |
| 2072 | } |
| 2073 | if (f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_16) or |
| 2074 | f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_17)) { |
| 2075 | setverdict(fail, "Cannot have SI16/SI17 and SI22!"); |
| 2076 | } |
| 2077 | if (not cfg.bcch_extended) { |
| 2078 | testcase.stop("Error: SI22 requires BCCH Extd!"); |
| 2079 | } else { |
| 2080 | f_ensure_si_vec_contains_only(si_per_tc, 2, SYSTEM_INFORMATION_TYPE_22, true); |
| 2081 | f_ensure_si_vec_contains_only(si_per_tc, 6, SYSTEM_INFORMATION_TYPE_22, true); |
| 2082 | } |
| 2083 | } |
| 2084 | } |
| 2085 | |
| 2086 | /* sample Systme Information for specified duration via L1CTL */ |
| 2087 | function f_l1_sample_si(L1CTL_PT pt, float duration := 8.0) return SystemInformationVectorPerTc { |
| 2088 | timer T := duration; |
| 2089 | var SystemInformationVectorPerTc si_per_tc; |
| 2090 | var L1ctlDlMessage l1_dl; |
| 2091 | |
| 2092 | /* initialize all per-TC vectors empty */ |
| 2093 | for (var integer i:= 0; i < sizeof(si_per_tc); i := i+1) { |
| 2094 | si_per_tc[i] := {}; |
| 2095 | } |
| 2096 | |
| 2097 | /* flush all previous L1 queued msgs */ |
| 2098 | pt.clear; |
| 2099 | |
| 2100 | T.start; |
| 2101 | alt { |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 2102 | [] 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] | 2103 | /* somehow dec_SystemInformation will try to decode even non-RR as SI */ |
| 2104 | if (not (l1_dl.payload.data_ind.payload[1] == '06'O)) { |
| 2105 | log("Ignoring non-RR SI ", l1_dl); |
| 2106 | repeat; |
| 2107 | } |
| 2108 | var SystemInformationFn sig := { |
| 2109 | frame_number := l1_dl.dl_info.frame_nr, |
| 2110 | si := dec_SystemInformation(l1_dl.payload.data_ind.payload) |
| 2111 | } |
| 2112 | var integer tc := f_gsm_compute_tc(sig.frame_number); |
| 2113 | log("SI received at TC=", tc, ": ", sig.si); |
| 2114 | /* append to the per-TC bucket */ |
| 2115 | si_per_tc[tc] := si_per_tc[tc] & { sig }; |
| 2116 | repeat; |
| 2117 | } |
| 2118 | [] pt.receive { repeat; } |
| 2119 | [] T.timeout { } |
| 2120 | } |
| 2121 | |
| 2122 | for (var integer i:= 0; i < sizeof(si_per_tc); i := i+1) { |
| 2123 | log(testcasename(), ": TC=", i, " has #of SI=", sizeof(si_per_tc[i])); |
| 2124 | } |
| 2125 | log("si_per_tc=", si_per_tc); |
| 2126 | return si_per_tc; |
| 2127 | } |
| 2128 | |
| 2129 | /* helper function: Set given SI via RSL + validate scheduling. |
| 2130 | * CALLER MUST MAKE SURE TO CHANGE GLOBAL si_cfg! */ |
| 2131 | function f_TC_si_sched() runs on test_CT { |
| 2132 | var SystemInformationVectorPerTc si_per_tc; |
| 2133 | f_init_l1ctl(); |
| 2134 | f_l1_tune(L1CTL); |
| 2135 | |
| 2136 | /* Sample + Validate Scheduling */ |
| 2137 | si_per_tc := f_l1_sample_si(L1CTL); |
| 2138 | f_validate_si_scheduling(si_cfg, si_per_tc); |
| 2139 | |
| 2140 | setverdict(pass); |
| 2141 | } |
| 2142 | |
| 2143 | testcase TC_si_sched_default() runs on test_CT { |
| 2144 | f_init(); |
Harald Welte | 0cae455 | 2018-03-09 22:20:26 +0100 | [diff] [blame] | 2145 | /* 2+3+4 are mandatory and set in f_init() */ |
| 2146 | f_TC_si_sched(); |
Harald Welte | 294b0a2 | 2018-03-10 23:26:48 +0100 | [diff] [blame] | 2147 | f_shutdown(); |
Harald Welte | 0cae455 | 2018-03-09 22:20:26 +0100 | [diff] [blame] | 2148 | } |
| 2149 | |
| 2150 | testcase TC_si_sched_1() runs on test_CT { |
| 2151 | f_init(); |
| 2152 | si_cfg.si1_present := true; |
| 2153 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_1, '5506198fb38000000000000000000000000000e504002b'O); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 2154 | f_TC_si_sched(); |
Harald Welte | 294b0a2 | 2018-03-10 23:26:48 +0100 | [diff] [blame] | 2155 | f_shutdown(); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 2156 | } |
| 2157 | |
| 2158 | testcase TC_si_sched_2bis() runs on test_CT { |
| 2159 | f_init(); |
| 2160 | si_cfg.si2bis_present := true; |
| 2161 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2bis, '550602bfe809b3ff00000000000000000000007900002b'O); |
| 2162 | f_TC_si_sched(); |
Harald Welte | 294b0a2 | 2018-03-10 23:26:48 +0100 | [diff] [blame] | 2163 | f_shutdown(); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 2164 | } |
| 2165 | |
| 2166 | testcase TC_si_sched_2ter() runs on test_CT { |
| 2167 | f_init(); |
| 2168 | si_cfg.si2ter_present := true; |
| 2169 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2ter, '010603bf66b0aa0a00000002000000000000002b2b2b2b'O); |
| 2170 | f_TC_si_sched(); |
Harald Welte | 294b0a2 | 2018-03-10 23:26:48 +0100 | [diff] [blame] | 2171 | f_shutdown(); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 2172 | } |
| 2173 | |
| 2174 | testcase TC_si_sched_2ter_2bis() runs on test_CT { |
| 2175 | f_init(); |
| 2176 | si_cfg.si2bis_present := true; |
| 2177 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2bis, '550602bfe809b3ff00000000000000000000007900002b'O); |
| 2178 | si_cfg.si2ter_present := true; |
| 2179 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2ter, '010603bf66b0aa0a00000002000000000000002b2b2b2b'O); |
| 2180 | f_TC_si_sched(); |
Harald Welte | 294b0a2 | 2018-03-10 23:26:48 +0100 | [diff] [blame] | 2181 | f_shutdown(); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 2182 | } |
| 2183 | |
| 2184 | testcase TC_si_sched_2quater() runs on test_CT { |
| 2185 | f_init(); |
| 2186 | si_cfg.si2quater_present := true; |
| 2187 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2quater, '050607a8a0364aa698d72ff424feee0506d5e7fff02043'O); |
| 2188 | f_TC_si_sched(); |
Harald Welte | 294b0a2 | 2018-03-10 23:26:48 +0100 | [diff] [blame] | 2189 | f_shutdown(); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 2190 | } |
| 2191 | |
| 2192 | testcase TC_si_sched_13() runs on test_CT { |
| 2193 | f_init(); |
| 2194 | si_cfg.si13_present := true; |
Harald Welte | 5618c2a | 2018-04-15 16:24:46 +0200 | [diff] [blame] | 2195 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_13, '0106009000185a6fc9e08410ab2b2b2b2b2b2b2b2b2b2b'O); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 2196 | f_TC_si_sched(); |
Harald Welte | 294b0a2 | 2018-03-10 23:26:48 +0100 | [diff] [blame] | 2197 | f_shutdown(); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 2198 | } |
| 2199 | |
| 2200 | testcase TC_si_sched_13_2bis_2ter_2quater() runs on test_CT { |
| 2201 | f_init(); |
| 2202 | si_cfg.si2bis_present := true; |
| 2203 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2bis, '550602bfe809b3ff00000000000000000000007900002b'O); |
| 2204 | si_cfg.si2ter_present := true; |
| 2205 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2ter, '010603bf66b0aa0a00000002000000000000002b2b2b2b'O); |
| 2206 | si_cfg.si2quater_present := true; |
| 2207 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2quater, '050607a8a0364aa698d72ff424feee0506d5e7fff02043'O); |
| 2208 | si_cfg.si13_present := true; |
Harald Welte | 5618c2a | 2018-04-15 16:24:46 +0200 | [diff] [blame] | 2209 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_13, '0106009000185a6fc9e08410ab2b2b2b2b2b2b2b2b2b2b'O); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 2210 | f_TC_si_sched(); |
Harald Welte | 294b0a2 | 2018-03-10 23:26:48 +0100 | [diff] [blame] | 2211 | f_shutdown(); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 2212 | } |
| 2213 | |
| 2214 | |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 2215 | testcase TC_bcch_info() runs on test_CT { |
| 2216 | f_init(testcasename()); |
| 2217 | /* FIXME: enable / disable individual BCCH info */ |
| 2218 | //ts_RSL_BCCH_INFO(si_type, info); |
| 2219 | /* expect no ERROR REPORT after either of them * |
| 2220 | /* negative test: ensure ERROR REPORT on unsupported types */ |
Harald Welte | 294b0a2 | 2018-03-10 23:26:48 +0100 | [diff] [blame] | 2221 | f_shutdown(); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 2222 | } |
| 2223 | |
Harald Welte | 93640c6 | 2018-02-25 16:59:33 +0100 | [diff] [blame] | 2224 | /*********************************************************************** |
| 2225 | * Low-Level Protocol Errors / ERROR REPORT |
| 2226 | ***********************************************************************/ |
| 2227 | |
Harald Welte | 01d982c | 2018-02-25 01:31:40 +0100 | [diff] [blame] | 2228 | private function f_exp_err_rep(template RSL_Cause cause) runs on test_CT { |
| 2229 | timer T := 5.0; |
| 2230 | T.start; |
| 2231 | alt { |
| 2232 | [] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_ERROR_REPORT(cause))) { |
| 2233 | setverdict(pass); |
| 2234 | } |
| 2235 | [] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_ERROR_REPORT(?))) { |
| 2236 | setverdict(fail, "Wrong cause in RSL ERR REP"); |
| 2237 | } |
| 2238 | [] RSL_CCHAN.receive { |
| 2239 | repeat; |
| 2240 | } |
| 2241 | [] T.timeout { |
| 2242 | setverdict(fail, "Timeout waiting for RSL ERR REP"); |
| 2243 | } |
| 2244 | } |
| 2245 | } |
| 2246 | |
| 2247 | /* Provoke a protocol error (message too short) and match on ERROR REPORT */ |
| 2248 | testcase TC_rsl_protocol_error() runs on test_CT { |
| 2249 | f_init(testcasename()); |
| 2250 | var RSL_Message rsl := valueof(ts_RSL_BCCH_INFO(RSL_SYSTEM_INFO_1, ''O)); |
| 2251 | rsl.ies := omit; |
| 2252 | RSL_CCHAN.send(ts_RSL_UD(rsl)); |
| 2253 | |
| 2254 | f_exp_err_rep(RSL_ERR_PROTO); |
| 2255 | } |
| 2256 | |
| 2257 | /* Provoke a mandatory IE error and match on ERROR REPORT */ |
| 2258 | testcase TC_rsl_mand_ie_error() runs on test_CT { |
| 2259 | f_init(testcasename()); |
| 2260 | |
| 2261 | var RSL_Message rsl := valueof(ts_RSL_BCCH_INFO(RSL_SYSTEM_INFO_1, ''O)); |
| 2262 | rsl.ies := { rsl.ies[0] }; |
| 2263 | RSL_CCHAN.send(ts_RSL_UD(rsl)); |
| 2264 | |
| 2265 | f_exp_err_rep(RSL_ERR_MAND_IE_ERROR); |
| 2266 | } |
| 2267 | |
| 2268 | /* Provoke an IE content error and match on ERROR REPORT */ |
| 2269 | testcase TC_rsl_ie_content_error() runs on test_CT { |
| 2270 | f_init(testcasename()); |
| 2271 | var RSL_Message rsl := valueof(ts_RSL_BCCH_INFO(RSL_SYSTEM_INFO_1, ''O)); |
| 2272 | rsl.ies[1].body.sysinfo_type := RSL_SYSTEM_INFO_5; |
| 2273 | RSL_CCHAN.send(ts_RSL_UD(rsl)); |
| 2274 | |
| 2275 | f_exp_err_rep(RSL_ERR_IE_CONTENT); |
| 2276 | } |
| 2277 | |
Harald Welte | 93640c6 | 2018-02-25 16:59:33 +0100 | [diff] [blame] | 2278 | /*********************************************************************** |
| 2279 | * IPA CRCX/MDCX/DLCS media stream handling |
| 2280 | ***********************************************************************/ |
| 2281 | |
Harald Welte | a871a38 | 2018-02-25 02:03:14 +0100 | [diff] [blame] | 2282 | /* Send IPA DLCX to inactive lchan */ |
| 2283 | function f_TC_ipa_dlcx_not_active(charstring id) runs on ConnHdlr { |
Harald Welte | 1eba374 | 2018-02-25 12:48:14 +0100 | [diff] [blame] | 2284 | f_rsl_transceive(ts_RSL_IPA_DLCX(g_chan_nr, 0), tr_RSL_IPA_DLCX_ACK(g_chan_nr, ?, ?), |
| 2285 | "IPA DLCX ACK"); |
Harald Welte | a871a38 | 2018-02-25 02:03:14 +0100 | [diff] [blame] | 2286 | } |
| 2287 | testcase TC_ipa_dlcx_not_active() runs on test_CT { |
| 2288 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 2289 | f_init(testcasename()); |
| 2290 | var ConnHdlr vc_conn := f_start_handler(refers(f_TC_ipa_dlcx_not_active), pars); |
| 2291 | vc_conn.done; |
| 2292 | } |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 2293 | |
Harald Welte | a3f1df9 | 2018-02-25 12:49:55 +0100 | [diff] [blame] | 2294 | /* Send IPA CRCX twice to inactive lchan */ |
| 2295 | function f_TC_ipa_crcx_twice_not_active(charstring id) runs on ConnHdlr { |
| 2296 | f_rsl_transceive(ts_RSL_IPA_CRCX(g_chan_nr), tr_RSL_IPA_CRCX_ACK(g_chan_nr, ?, ?, ?), |
| 2297 | "IPA CRCX ACK"); |
| 2298 | f_rsl_transceive(ts_RSL_IPA_CRCX(g_chan_nr), tr_RSL_IPA_CRCX_NACK(g_chan_nr, RSL_ERR_RES_UNAVAIL), |
| 2299 | "IPA CRCX NACK"); |
| 2300 | } |
| 2301 | testcase TC_ipa_crcx_twice_not_active() runs on test_CT { |
| 2302 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 2303 | f_init(testcasename()); |
| 2304 | var ConnHdlr vc_conn := f_start_handler(refers(f_TC_ipa_crcx_twice_not_active), pars); |
| 2305 | vc_conn.done; |
| 2306 | } |
| 2307 | |
| 2308 | /* Regular sequence of CRCX/MDCX/DLCX */ |
| 2309 | function f_TC_ipa_crcx_mdcx_dlcx_not_active(charstring id) runs on ConnHdlr { |
| 2310 | f_rsl_transceive(ts_RSL_IPA_CRCX(g_chan_nr), tr_RSL_IPA_CRCX_ACK(g_chan_nr, ?, ?, ?), |
| 2311 | "IPA CRCX ACK"); |
| 2312 | var uint32_t remote_ip := f_rnd_int(c_UINT32_MAX); |
| 2313 | var uint16_t remote_port := f_rnd_int(c_UINT16_MAX); |
| 2314 | var uint7_t rtp_pt2 := f_rnd_int(127); |
| 2315 | var uint16_t fake_conn_id := 23; /* we're too lazy to read it out from the CRCX ACK above */ |
| 2316 | f_rsl_transceive(ts_RSL_IPA_MDCX(g_chan_nr, fake_conn_id, remote_ip, remote_port, rtp_pt2), |
| 2317 | tr_RSL_IPA_MDCX_ACK(g_chan_nr, ?, ?, ?, rtp_pt2), |
| 2318 | "IPA MDCX ACK"); |
| 2319 | f_rsl_transceive(ts_RSL_IPA_DLCX(g_chan_nr, fake_conn_id), tr_RSL_IPA_DLCX_ACK(g_chan_nr, ?, ?), |
| 2320 | "IPA DLCX ACK"); |
| 2321 | } |
| 2322 | testcase TC_ipa_crcx_mdcx_dlcx_not_active() runs on test_CT { |
| 2323 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 2324 | f_init(testcasename()); |
| 2325 | var ConnHdlr vc_conn := f_start_handler(refers(f_TC_ipa_crcx_mdcx_dlcx_not_active), pars); |
| 2326 | vc_conn.done; |
| 2327 | } |
| 2328 | |
Harald Welte | 3ae11da | 2018-02-25 13:36:06 +0100 | [diff] [blame] | 2329 | /* Sequence of CRCX, 2x MDCX, DLCX */ |
| 2330 | function f_TC_ipa_crcx_mdcx_mdcx_dlcx_not_active(charstring id) runs on ConnHdlr { |
| 2331 | f_rsl_transceive(ts_RSL_IPA_CRCX(g_chan_nr), tr_RSL_IPA_CRCX_ACK(g_chan_nr, ?, ?, ?), |
| 2332 | "IPA CRCX ACK"); |
| 2333 | var uint32_t remote_ip := f_rnd_int(c_UINT32_MAX); |
| 2334 | var uint16_t remote_port := f_rnd_int(c_UINT16_MAX); |
| 2335 | var uint7_t rtp_pt2 := f_rnd_int(127); |
| 2336 | var uint16_t fake_conn_id := 23; /* we're too lazy to read it out from the CRCX ACK above */ |
| 2337 | f_rsl_transceive(ts_RSL_IPA_MDCX(g_chan_nr, fake_conn_id, remote_ip, remote_port, rtp_pt2), |
| 2338 | tr_RSL_IPA_MDCX_ACK(g_chan_nr, ?, ?, ?, rtp_pt2), |
| 2339 | "IPA MDCX ACK"); |
| 2340 | /* Second MDCX */ |
| 2341 | remote_ip := f_rnd_int(c_UINT32_MAX); |
| 2342 | remote_port := f_rnd_int(c_UINT16_MAX); |
| 2343 | f_rsl_transceive(ts_RSL_IPA_MDCX(g_chan_nr, fake_conn_id, remote_ip, remote_port, rtp_pt2), |
| 2344 | tr_RSL_IPA_MDCX_ACK(g_chan_nr, ?, ?, ?, rtp_pt2), |
| 2345 | "IPA MDCX ACK"); |
| 2346 | f_rsl_transceive(ts_RSL_IPA_DLCX(g_chan_nr, fake_conn_id), tr_RSL_IPA_DLCX_ACK(g_chan_nr, ?, ?), |
| 2347 | "IPA DLCX ACK"); |
| 2348 | } |
| 2349 | testcase TC_ipa_crcx_mdcx_mdcx_dlcx_not_active() runs on test_CT { |
| 2350 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 2351 | f_init(testcasename()); |
| 2352 | var ConnHdlr vc_conn := f_start_handler(refers(f_TC_ipa_crcx_mdcx_mdcx_dlcx_not_active), pars); |
| 2353 | vc_conn.done; |
| 2354 | } |
| 2355 | |
Harald Welte | 9912eb5 | 2018-02-25 13:30:15 +0100 | [diff] [blame] | 2356 | /* IPA CRCX on SDCCH/4 and SDCCH/8 (doesn't make sense) */ |
| 2357 | function f_TC_ipa_crcx_sdcch_not_active(charstring id) runs on ConnHdlr { |
| 2358 | f_rsl_transceive(ts_RSL_IPA_CRCX(g_chan_nr), tr_RSL_IPA_CRCX_NACK(g_chan_nr, ?), |
| 2359 | "IPA CRCX NACK"); |
| 2360 | } |
| 2361 | testcase TC_ipa_crcx_sdcch_not_active() runs on test_CT { |
| 2362 | var ConnHdlrPars pars; |
| 2363 | var ConnHdlr vc_conn; |
| 2364 | f_init(testcasename()); |
| 2365 | |
| 2366 | pars := valueof(t_Pars(t_RslChanNr_SDCCH4(0,1), ts_RSL_ChanMode_SIGN)); |
| 2367 | vc_conn := f_start_handler(refers(f_TC_ipa_crcx_sdcch_not_active), pars); |
| 2368 | vc_conn.done; |
| 2369 | |
| 2370 | pars := valueof(t_Pars(t_RslChanNr_SDCCH8(6,5), ts_RSL_ChanMode_SIGN)); |
| 2371 | vc_conn := f_start_handler(refers(f_TC_ipa_crcx_sdcch_not_active), pars); |
| 2372 | vc_conn.done; |
| 2373 | } |
| 2374 | |
Harald Welte | a3f1df9 | 2018-02-25 12:49:55 +0100 | [diff] [blame] | 2375 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 2376 | /*********************************************************************** |
| 2377 | * PCU Socket related tests |
| 2378 | ***********************************************************************/ |
| 2379 | |
| 2380 | private function f_TC_pcu_act_req(uint8_t bts_nr, uint8_t trx_nr, uint8_t ts_nr, boolean exp_success) |
| 2381 | runs on test_CT { |
| 2382 | timer T := 3.0; |
| 2383 | |
| 2384 | /* we don't expect any RTS.req before PDCH are active */ |
| 2385 | T.start; |
| 2386 | alt { |
| 2387 | [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RTS_REQ(bts_nr))) { |
| 2388 | setverdict(fail, "PCU RTS.req before PDCH active?"); |
| 2389 | self.stop; |
| 2390 | } |
| 2391 | [] PCU.receive { repeat; } |
| 2392 | [] T.timeout { } |
| 2393 | } |
| 2394 | |
| 2395 | /* Send PDCH activate request for known PDCH timeslot */ |
| 2396 | PCU.send(t_SD_PCUIF(g_pcu_conn_id, ts_PCUIF_ACT_REQ(bts_nr, trx_nr, ts_nr))); |
| 2397 | |
| 2398 | /* we now expect RTS.req for this timeslot (only) */ |
| 2399 | T.start; |
| 2400 | alt { |
| 2401 | [exp_success] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RTS_REQ(bts_nr, trx_nr, ts_nr))) { |
| 2402 | setverdict(pass); |
| 2403 | } |
| 2404 | [not exp_success] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, |
| 2405 | tr_PCUIF_RTS_REQ(bts_nr, trx_nr, ts_nr))) { |
| 2406 | setverdict(fail, "Unexpected RTS.req for supposedly failing activation"); |
| 2407 | self.stop; |
| 2408 | } |
| 2409 | [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RTS_REQ)) { |
| 2410 | setverdict(fail, "RTS.req for wrong TRX/TS"); |
| 2411 | self.stop; |
| 2412 | } |
| 2413 | [] PCU.receive { repeat; } |
| 2414 | [exp_success] T.timeout { |
| 2415 | setverdict(fail, "Timeout waiting for PCU RTS.req"); |
| 2416 | } |
| 2417 | [not exp_success] T.timeout { |
| 2418 | setverdict(pass); |
| 2419 | } |
| 2420 | } |
| 2421 | } |
| 2422 | |
| 2423 | private function f_TC_pcu_deact_req(uint8_t bts_nr, uint8_t trx_nr, uint8_t ts_nr) |
| 2424 | runs on test_CT { |
| 2425 | timer T := 3.0; |
| 2426 | |
| 2427 | /* Send PDCH activate request for known PDCH timeslot */ |
| 2428 | PCU.send(t_SD_PCUIF(g_pcu_conn_id, ts_PCUIF_DEACT_REQ(bts_nr, trx_nr, ts_nr))); |
| 2429 | |
| 2430 | PCU.clear; |
| 2431 | /* we now expect no RTS.req for this timeslot */ |
| 2432 | T.start; |
| 2433 | alt { |
| 2434 | [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RTS_REQ(bts_nr, trx_nr, ts_nr))) { |
| 2435 | setverdict(fail, "Received unexpected PCU RTS.req"); |
| 2436 | self.stop; |
| 2437 | } |
| 2438 | [] PCU.receive { repeat; } |
| 2439 | [] T.timeout { |
| 2440 | setverdict(pass); |
| 2441 | } |
| 2442 | } |
| 2443 | } |
| 2444 | |
| 2445 | /* PDCH activation via PCU socket; check for presence of RTS.req */ |
| 2446 | testcase TC_pcu_act_req() runs on test_CT { |
| 2447 | f_init(); |
| 2448 | f_TC_pcu_act_req(0, 0, 7, true); |
| 2449 | } |
| 2450 | |
| 2451 | /* PDCH activation via PCU socket on non-PDCU timeslot */ |
| 2452 | testcase TC_pcu_act_req_wrong_ts() runs on test_CT { |
| 2453 | f_init(); |
| 2454 | f_TC_pcu_act_req(0, 0, 1, false); |
| 2455 | } |
| 2456 | |
| 2457 | /* PDCH activation via PCU socket on wrong BTS */ |
| 2458 | testcase TC_pcu_act_req_wrong_bts() runs on test_CT { |
| 2459 | f_init(); |
| 2460 | f_TC_pcu_act_req(23, 0, 7, false); |
| 2461 | } |
| 2462 | |
| 2463 | /* PDCH activation via PCU socket on wrong TRX */ |
| 2464 | testcase TC_pcu_act_req_wrong_trx() runs on test_CT { |
| 2465 | f_init(); |
| 2466 | f_TC_pcu_act_req(0, 23, 7, false); |
| 2467 | } |
| 2468 | |
| 2469 | /* PDCH deactivation via PCU socket; check for absence of RTS.req */ |
| 2470 | testcase TC_pcu_deact_req() runs on test_CT { |
| 2471 | f_init(); |
| 2472 | /* Activate PDCH */ |
| 2473 | f_TC_pcu_act_req(0, 0, 7, true); |
| 2474 | f_sleep(1.0); |
| 2475 | /* and De-Activate again */ |
| 2476 | f_TC_pcu_deact_req(0, 0, 7); |
| 2477 | } |
| 2478 | |
| 2479 | /* Attempt to deactivate a PDCH on a non-PDCH timeslot */ |
| 2480 | testcase TC_pcu_deact_req_wrong_ts() runs on test_CT { |
| 2481 | f_init(); |
| 2482 | f_TC_pcu_deact_req(0, 0, 1); |
| 2483 | } |
| 2484 | |
| 2485 | /* Test the PCU->BTS Version and BTS->PCU SI13 handshake */ |
| 2486 | testcase TC_pcu_ver_si13() runs on test_CT { |
| 2487 | const octetstring si13 := '00010203040506070909'O; |
| 2488 | var PCUIF_send_data sd; |
| 2489 | timer T:= 3.0; |
| 2490 | f_init(); |
| 2491 | |
| 2492 | /* Set SI13 via RSL */ |
| 2493 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_13, si13); |
| 2494 | PCU.send(t_SD_PCUIF(g_pcu_conn_id, ts_PCUIF_TXT_IND(0, PCU_VERSION, "BTS_Test v23"))); |
| 2495 | T.start; |
| 2496 | alt { |
| 2497 | [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_DATA_IND(0, 0, 0, ?, PCU_IF_SAPI_BCCH))) -> value sd { |
| 2498 | if (substr(sd.data.u.data_ind.data, 0, lengthof(si13)) == si13) { |
| 2499 | setverdict(pass); |
| 2500 | } else { |
| 2501 | repeat; |
| 2502 | } |
| 2503 | } |
| 2504 | [] PCU.receive { repeat; } |
| 2505 | [] T.timeout { |
| 2506 | setverdict(fail, "Timeout waiting for SI13"); |
| 2507 | self.stop; |
| 2508 | } |
| 2509 | } |
| 2510 | } |
| 2511 | |
| 2512 | private const octetstring c_PCU_DATA := '000102030405060708090a0b0c0d0e0f10111213141516'O; |
| 2513 | |
| 2514 | /* helper function to send a PCU DATA.req */ |
| 2515 | private function f_pcu_data_req(uint8_t bts_nr, uint8_t trx_nr, uint8_t ts_nr, |
| 2516 | uint8_t block_nr, uint32_t fn, PCUIF_Sapi sapi, octetstring data) |
| 2517 | runs on test_CT |
| 2518 | { |
| 2519 | PCU.send(t_SD_PCUIF(g_pcu_conn_id, |
| 2520 | ts_PCUIF_DATA_REQ(bts_nr, trx_nr, ts_nr, block_nr, fn, sapi, data))); |
| 2521 | } |
| 2522 | |
| 2523 | /* helper function to wait for RTS.ind for given SAPI on given BTS/TRX/TS and then send */ |
| 2524 | private function f_pcu_wait_rts_and_data_req(uint8_t bts_nr, uint8_t trx_nr, uint8_t ts_nr, |
| 2525 | PCUIF_Sapi sapi, octetstring data) |
| 2526 | runs on test_CT |
| 2527 | { |
| 2528 | var PCUIF_send_data sd; |
| 2529 | |
| 2530 | timer T := 3.0; |
| 2531 | T.start; |
| 2532 | alt { |
| 2533 | [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, |
| 2534 | tr_PCUIF_RTS_REQ(bts_nr, trx_nr, ts_nr, sapi))) -> value sd { |
| 2535 | f_pcu_data_req(bts_nr, trx_nr, ts_nr, sd.data.u.rts_req.block_nr, |
| 2536 | sd.data.u.rts_req.fn, sapi, data); |
| 2537 | } |
| 2538 | [] PCU.receive { repeat; } |
| 2539 | [] T.timeout { |
| 2540 | setverdict(fail, "Timeout waiting for RTS.ind"); |
| 2541 | } |
| 2542 | } |
| 2543 | } |
| 2544 | |
| 2545 | /* Send DATA.req on invalid BTS */ |
| 2546 | testcase TC_pcu_data_req_wrong_bts() runs on test_CT { |
| 2547 | f_init(); |
| 2548 | f_TC_pcu_act_req(0, 0, 7, true); |
| 2549 | f_pcu_data_req(23, 0, 7, 0, 0, PCU_IF_SAPI_PDTCH, c_PCU_DATA); |
| 2550 | /* FIXME: how to check this wasn't actually sent and didn't crash BTS? */ |
| 2551 | f_sleep(10.0); |
| 2552 | } |
| 2553 | |
| 2554 | /* Send DATA.req on invalid TRX */ |
| 2555 | testcase TC_pcu_data_req_wrong_trx() runs on test_CT { |
| 2556 | f_init(); |
| 2557 | f_TC_pcu_act_req(0, 0, 7, true); |
| 2558 | f_pcu_data_req(0, 100, 7, 0, 0, PCU_IF_SAPI_PDTCH, c_PCU_DATA); |
| 2559 | /* FIXME: how to check this wasn't actually sent and didn't crash BTS? */ |
| 2560 | f_sleep(10.0); |
| 2561 | } |
| 2562 | |
| 2563 | /* Send DATA.req on invalid timeslot */ |
| 2564 | testcase TC_pcu_data_req_wrong_ts() runs on test_CT { |
| 2565 | f_init(); |
| 2566 | f_TC_pcu_act_req(0, 0, 7, true); |
| 2567 | f_pcu_data_req(0, 0, 70, 0, 0, PCU_IF_SAPI_PDTCH, c_PCU_DATA); |
| 2568 | /* FIXME: how to check this wasn't actually sent and didn't crash BTS? */ |
| 2569 | f_sleep(10.0); |
| 2570 | } |
| 2571 | |
| 2572 | /* Send DATA.req on timeslot that hasn't been activated */ |
| 2573 | testcase TC_pcu_data_req_ts_inactive() runs on test_CT { |
| 2574 | f_init(); |
| 2575 | f_pcu_data_req(0, 0, 7, 0, 0, PCU_IF_SAPI_PDTCH, c_PCU_DATA); |
| 2576 | /* FIXME: how to check this wasn't actually sent and didn't crash BTS? */ |
| 2577 | f_sleep(2.0); |
| 2578 | } |
| 2579 | |
| 2580 | testcase TC_pcu_data_req_pdtch() runs on test_CT { |
| 2581 | f_init(); |
| 2582 | f_TC_pcu_act_req(0, 0, 7, true); |
| 2583 | f_pcu_wait_rts_and_data_req(0, 0, 7, PCU_IF_SAPI_PDTCH, c_PCU_DATA); |
| 2584 | /* FIXME: how to check this was actually sent */ |
| 2585 | f_sleep(2.0); |
| 2586 | } |
| 2587 | |
| 2588 | testcase TC_pcu_data_req_ptcch() runs on test_CT { |
| 2589 | f_init(); |
| 2590 | f_TC_pcu_act_req(0, 0, 7, true); |
| 2591 | f_pcu_wait_rts_and_data_req(0, 0, 7, PCU_IF_SAPI_PTCCH, c_PCU_DATA); |
| 2592 | /* FIXME: how to check this was actually sent */ |
| 2593 | f_sleep(2.0); |
| 2594 | } |
| 2595 | |
| 2596 | /* Send AGCH from PCU; check it appears on Um side */ |
| 2597 | testcase TC_pcu_data_req_agch() runs on test_CT { |
| 2598 | timer T := 3.0; |
| 2599 | f_init(); |
| 2600 | f_init_l1ctl(); |
| 2601 | f_l1_tune(L1CTL); |
| 2602 | |
| 2603 | f_TC_pcu_act_req(0, 0, 7, true); |
| 2604 | f_pcu_data_req(0, 0, 7, 0, 0, PCU_IF_SAPI_AGCH, c_PCU_DATA); |
| 2605 | |
| 2606 | T.start; |
| 2607 | alt { |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 2608 | [] 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] | 2609 | setverdict(pass); |
| 2610 | } |
| 2611 | [] L1CTL.receive { repeat; } |
| 2612 | [] T.timeout { |
| 2613 | setverdict(fail, "Timeout waiting for PCU-originated AGCH block on Um"); |
| 2614 | } |
| 2615 | } |
| 2616 | } |
| 2617 | |
| 2618 | /* Send IMM.ASS from PCU for PCH; check it appears on Um side */ |
| 2619 | testcase TC_pcu_data_req_imm_ass_pch() runs on test_CT { |
| 2620 | var octetstring imm_ass := f_rnd_octstring(23); |
| 2621 | f_init(); |
| 2622 | f_init_l1ctl(); |
| 2623 | f_l1_tune(L1CTL); |
| 2624 | |
| 2625 | /* append 3 last imsi digits so BTS can compute pagng group */ |
| 2626 | var uint32_t fn := f_PCUIF_tx_imm_ass_pch(PCU, g_pcu_conn_id, imm_ass, '123459987'H); |
| 2627 | |
| 2628 | timer T := 0.5; |
| 2629 | T.start; |
| 2630 | alt { |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 2631 | [] 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] | 2632 | /* TODO: verify paging group */ |
| 2633 | setverdict(pass); |
| 2634 | } |
| 2635 | [] L1CTL.receive { repeat; } |
| 2636 | [] T.timeout { |
| 2637 | setverdict(fail, "Timeout waiting for PCU-originated AGCH block on Um"); |
| 2638 | } |
| 2639 | } |
| 2640 | } |
| 2641 | |
| 2642 | /* Send RACH from Um side, expect it to show up on PCU socket */ |
| 2643 | testcase TC_pcu_rach_content() runs on test_CT { |
| 2644 | f_init(); |
| 2645 | f_init_l1ctl(); |
| 2646 | f_l1_tune(L1CTL); |
| 2647 | |
| 2648 | var GsmFrameNumber fn_last := 0; |
| 2649 | for (var integer i := 0; i < 1000; i := i+1) { |
| 2650 | var OCT1 ra := f_rnd_ra_ps(); |
| 2651 | var GsmFrameNumber fn := f_L1CTL_RACH(L1CTL, oct2int(ra)); |
| 2652 | if (fn == fn_last) { |
| 2653 | setverdict(fail, "Two RACH in same FN?!?"); |
| 2654 | self.stop; |
| 2655 | } |
| 2656 | fn_last := fn; |
| 2657 | |
| 2658 | timer T := 2.0; |
| 2659 | T.start; |
| 2660 | alt { |
| 2661 | [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RACH_IND(0, oct2int(ra), 0, ?, fn))) { |
| 2662 | T.stop; |
| 2663 | } |
| 2664 | [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RACH_IND)) { |
| 2665 | setverdict(fail, "Unexpected RACH IND"); |
| 2666 | self.stop; |
| 2667 | } |
| 2668 | [] PCU.receive { repeat; } |
| 2669 | [] T.timeout { |
| 2670 | setverdict(fail, "Timeout waiting for RACH IND"); |
| 2671 | self.stop; |
| 2672 | } |
| 2673 | } |
| 2674 | } |
| 2675 | setverdict(pass); |
| 2676 | } |
| 2677 | |
| 2678 | private function f_pad_oct(octetstring str, integer len, OCT1 pad) return octetstring { |
| 2679 | var integer strlen := lengthof(str); |
| 2680 | for (var integer i := 0; i < len-strlen; i := i+1) { |
| 2681 | str := str & pad; |
| 2682 | } |
| 2683 | return str; |
| 2684 | } |
| 2685 | |
| 2686 | /* Send PAGING via RSL, expect it to shw up on PCU socket */ |
| 2687 | testcase TC_pcu_paging_from_rsl() runs on test_CT { |
| 2688 | f_init(); |
| 2689 | |
| 2690 | for (var integer i := 0; i < 100; i := i+1) { |
| 2691 | var MobileL3_CommonIE_Types.MobileIdentityLV mi; |
| 2692 | timer T := 3.0; |
| 2693 | if (i < 50) { |
| 2694 | mi := valueof(ts_MI_TMSI_LV(f_rnd_octstring(4))); |
| 2695 | } else { |
| 2696 | mi := valueof(ts_MI_IMSI_LV(f_gen_imsi(i))); |
| 2697 | } |
| 2698 | var octetstring mi_enc_lv := enc_MobileIdentityLV(mi); |
| 2699 | var octetstring mi_enc := substr(mi_enc_lv, 1, lengthof(mi_enc_lv)-1); |
| 2700 | var octetstring t_mi_lv := f_pad_oct(mi_enc_lv, 9, '00'O); |
| 2701 | |
| 2702 | /* Send RSL PAGING COMMAND */ |
| 2703 | RSL_CCHAN.send(ts_RSL_UD(ts_RSL_PAGING_CMD(mi_enc, i mod 4))); |
| 2704 | T.start; |
| 2705 | alt { |
| 2706 | [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_PAG_REQ(0, t_mi_lv))) { |
| 2707 | } |
| 2708 | [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_PAG_REQ)) { |
| 2709 | setverdict(fail, "Unexpected PAGING REQ"); |
| 2710 | self.stop; |
| 2711 | } |
| 2712 | [] PCU.receive { repeat; } |
| 2713 | [] T.timeout { |
| 2714 | setverdict(fail, "Timeout waiting for PAGING REQ"); |
| 2715 | self.stop; |
| 2716 | } |
| 2717 | } |
| 2718 | } |
| 2719 | setverdict(pass); |
| 2720 | } |
| 2721 | |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 2722 | /*********************************************************************** |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 2723 | * Osmocom Style Dynamic Timeslot Support |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 2724 | ***********************************************************************/ |
| 2725 | |
| 2726 | private function f_dyn_osmo_pdch_act(integer pcu_conn_id, integer bts_nr, integer trx_nr) |
| 2727 | runs on ConnHdlr { |
| 2728 | var PCUIF_send_data sd; |
| 2729 | /* Expect BTS to immediately acknowledge activation as PDCH */ |
| 2730 | PCU.clear; |
| 2731 | f_rsl_chan_act(g_pars.chan_mode); |
| 2732 | /* expect INFO_IND on PCU interface listing TS as PDCH */ |
| 2733 | alt { |
| 2734 | [] PCU.receive(t_SD_PCUIF(pcu_conn_id, tr_PCUIF_INFO_IND(bts_nr, ?))) -> value sd { |
| 2735 | if (substr(sd.data.u.info_ind.trx[trx_nr].pdch_mask, g_chan_nr.tn, 1) != '1'B) { |
| 2736 | setverdict(fail, "PCUIF_INFO_IND PDCH_MASK not '1' after PDCH ACT"); |
| 2737 | self.stop; |
| 2738 | } |
| 2739 | } |
| 2740 | [] PCU.receive { repeat; } |
| 2741 | } |
| 2742 | /* try to activate this PDCH from the PCU point of view */ |
| 2743 | PCU.send(t_SD_PCUIF(pcu_conn_id, ts_PCUIF_ACT_REQ(bts_nr, trx_nr, g_chan_nr.tn))); |
| 2744 | /* FIXME: is there a response? */ |
| 2745 | } |
| 2746 | |
| 2747 | private function f_dyn_osmo_pdch_deact(integer pcu_conn_id, integer bts_nr, integer trx_nr) |
| 2748 | runs on ConnHdlr { |
| 2749 | var PCUIF_send_data sd; |
| 2750 | /* Send RSL CHAN REL (deactivate) */ |
| 2751 | PCU.clear; |
| 2752 | RSL.send(ts_RSL_RF_CHAN_REL(g_chan_nr)); |
| 2753 | /* expect BTS to ask PCU to deactivate the channel */ |
| 2754 | alt { |
| 2755 | [] PCU.receive(t_SD_PCUIF(pcu_conn_id, tr_PCUIF_INFO_IND(bts_nr, ?))) -> value sd { |
| 2756 | if (substr(sd.data.u.info_ind.trx[trx_nr].pdch_mask, g_chan_nr.tn, 1) != '0'B) { |
| 2757 | setverdict(fail, "PCUIF_INFO_IND PDCH_MASK not '0' after PDCH DEACT"); |
| 2758 | self.stop; |
| 2759 | } |
| 2760 | } |
| 2761 | [] PCU.receive { repeat; } |
| 2762 | } |
| 2763 | /* Emulate PCU asking BTS to deactivate PDCH */ |
| 2764 | PCU.send(t_SD_PCUIF(pcu_conn_id, ts_PCUIF_DEACT_REQ(bts_nr, trx_nr, g_chan_nr.tn))); |
| 2765 | alt { |
| 2766 | [] RSL.receive(tr_RSL_RF_CHAN_REL_ACK(g_chan_nr)) { |
| 2767 | setverdict(pass); |
| 2768 | } |
| 2769 | [] RSL.receive { repeat; } |
| 2770 | } |
| 2771 | } |
| 2772 | |
| 2773 | /* Activate Osmocom-style dynamic PDCH from BSC side */ |
| 2774 | function f_TC_dyn_osmo_pdch_act_deact(charstring id) runs on ConnHdlr { |
| 2775 | var PCUIF_Message first_info; |
| 2776 | var integer ts_nr := g_chan_nr.tn; |
| 2777 | var integer trx_nr := 0; |
| 2778 | var integer bts_nr := 0; |
| 2779 | var integer pcu_conn_id := -1; |
| 2780 | |
| 2781 | f_init_pcu(PCU, id, pcu_conn_id, first_info); |
| 2782 | |
| 2783 | f_dyn_osmo_pdch_act(pcu_conn_id, bts_nr, trx_nr); |
| 2784 | f_sleep(3.0); |
| 2785 | f_dyn_osmo_pdch_deact(pcu_conn_id, bts_nr, trx_nr); |
| 2786 | setverdict(pass); |
| 2787 | } |
| 2788 | testcase TC_dyn_osmo_pdch_act_deact() runs on test_CT { |
| 2789 | var ConnHdlrPars pars; |
| 2790 | var ConnHdlr vc_conn; |
| 2791 | f_init(testcasename()); |
| 2792 | |
| 2793 | pars := valueof(t_Pars(t_RslChanNr_PDCH(4), ts_RSL_ChanMode_SIGN)); |
| 2794 | vc_conn := f_start_handler(refers(f_TC_dyn_osmo_pdch_act_deact), pars, true); |
| 2795 | vc_conn.done; |
| 2796 | } |
| 2797 | |
| 2798 | /* send a RF CHAN REL for PDCH on an osmocom dynamci PDCH that's already inactive */ |
| 2799 | function f_TC_dyn_osmo_pdch_unsol_deact(charstring id) runs on ConnHdlr { |
| 2800 | var PCUIF_Message first_info; |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 2801 | var integer pcu_conn_id := -1; |
| 2802 | |
| 2803 | f_init_pcu(PCU, id, pcu_conn_id, first_info); |
| 2804 | |
Neels Hofmeyr | 9c50ca5 | 2018-05-08 20:37:54 +0200 | [diff] [blame] | 2805 | RSL.send(ts_RSL_RF_CHAN_REL(g_chan_nr)); |
| 2806 | /* since the lchan is already released, we don't expect any PCU changes, just a rel ack. */ |
| 2807 | RSL.receive(tr_RSL_RF_CHAN_REL_ACK(g_chan_nr)); |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 2808 | setverdict(pass); |
| 2809 | } |
| 2810 | testcase TC_dyn_osmo_pdch_unsol_deact() runs on test_CT { |
| 2811 | var ConnHdlrPars pars; |
| 2812 | var ConnHdlr vc_conn; |
| 2813 | f_init(testcasename()); |
| 2814 | |
| 2815 | pars := valueof(t_Pars(t_RslChanNr_PDCH(4), ts_RSL_ChanMode_SIGN)); |
| 2816 | vc_conn := f_start_handler(refers(f_TC_dyn_osmo_pdch_unsol_deact), pars, true); |
| 2817 | vc_conn.done; |
| 2818 | } |
| 2819 | |
| 2820 | /* try to RSL CHAN ACT a PDCH on an osmocom-style PDCH that's already active */ |
| 2821 | function f_TC_dyn_osmo_pdch_double_act(charstring id) runs on ConnHdlr { |
| 2822 | var PCUIF_Message first_info; |
| 2823 | var integer ts_nr := g_chan_nr.tn; |
| 2824 | var integer trx_nr := 0; |
| 2825 | var integer bts_nr := 0; |
| 2826 | var integer pcu_conn_id := -1; |
| 2827 | |
| 2828 | f_init_pcu(PCU, id, pcu_conn_id, first_info); |
| 2829 | |
| 2830 | f_dyn_osmo_pdch_act(pcu_conn_id, bts_nr, trx_nr); |
Neels Hofmeyr | df936a2 | 2018-05-08 22:07:57 +0200 | [diff] [blame] | 2831 | /* Send a second Chan Activ and expect it to be NACKed */ |
| 2832 | f_rsl_transceive(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode), tr_RSL_CHAN_ACT_NACK(g_chan_nr), |
| 2833 | "RSL CHAN ACT NACK"); |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 2834 | setverdict(pass); |
| 2835 | } |
| 2836 | testcase TC_dyn_osmo_pdch_double_act() runs on test_CT { |
| 2837 | var ConnHdlrPars pars; |
| 2838 | var ConnHdlr vc_conn; |
| 2839 | f_init(testcasename()); |
| 2840 | |
| 2841 | pars := valueof(t_Pars(t_RslChanNr_PDCH(4), ts_RSL_ChanMode_SIGN)); |
| 2842 | vc_conn := f_start_handler(refers(f_TC_dyn_osmo_pdch_double_act), pars, true); |
| 2843 | vc_conn.done; |
| 2844 | } |
| 2845 | |
| 2846 | /* try to RSL CHAN ACT a TCH/F on an osmocom-style PDCH */ |
| 2847 | function f_TC_dyn_osmo_pdch_tchf_act(charstring id) runs on ConnHdlr { |
| 2848 | var PCUIF_Message first_info; |
| 2849 | var integer ts_nr := g_chan_nr.tn; |
| 2850 | var integer trx_nr := 0; |
| 2851 | var integer bts_nr := 0; |
| 2852 | var integer pcu_conn_id := -1; |
| 2853 | var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(g_chan_nr.tn)); |
| 2854 | |
| 2855 | /* register for the TCH/F channel number */ |
| 2856 | f_rslem_register(0, chan_nr); |
| 2857 | |
| 2858 | f_init_pcu(PCU, id, pcu_conn_id, first_info); |
| 2859 | |
| 2860 | f_rsl_transceive(ts_RSL_CHAN_ACT(chan_nr, g_pars.chan_mode), tr_RSL_CHAN_ACT_ACK(chan_nr), |
| 2861 | "RSL CHAN ACT"); |
| 2862 | setverdict(pass); |
| 2863 | } |
| 2864 | testcase TC_dyn_osmo_pdch_tchf_act() runs on test_CT { |
| 2865 | var ConnHdlrPars pars; |
| 2866 | var ConnHdlr vc_conn; |
| 2867 | f_init(testcasename()); |
| 2868 | |
| 2869 | pars := valueof(t_Pars(t_RslChanNr_PDCH(4), ts_RSL_ChanMode_SIGN)); |
| 2870 | vc_conn := f_start_handler(refers(f_TC_dyn_osmo_pdch_tchf_act), pars, true); |
| 2871 | vc_conn.done; |
| 2872 | } |
| 2873 | |
| 2874 | /* try to RSL CHAN ACT the TCH/H on an osmocom-style PDCH */ |
| 2875 | function f_TC_dyn_osmo_pdch_tchh_act(charstring id) runs on ConnHdlr { |
| 2876 | var PCUIF_Message first_info; |
| 2877 | var integer ts_nr := g_chan_nr.tn; |
| 2878 | var integer trx_nr := 0; |
| 2879 | var integer bts_nr := 0; |
| 2880 | var integer pcu_conn_id := -1; |
| 2881 | var RslChannelNr chan_nr[2] := { valueof(t_RslChanNr_Lm(g_chan_nr.tn, 0)), |
| 2882 | valueof(t_RslChanNr_Lm(g_chan_nr.tn, 1)) }; |
| 2883 | |
| 2884 | /* register for the TCH/H channel numbers */ |
| 2885 | f_rslem_register(0, chan_nr[0]); |
| 2886 | f_rslem_register(0, chan_nr[1]); |
| 2887 | |
| 2888 | f_init_pcu(PCU, id, pcu_conn_id, first_info); |
| 2889 | |
| 2890 | f_rsl_transceive(ts_RSL_CHAN_ACT(chan_nr[1], g_pars.chan_mode), |
| 2891 | tr_RSL_CHAN_ACT_ACK(chan_nr[1]), "RSL CHAN ACT [1]"); |
| 2892 | f_rsl_transceive(ts_RSL_CHAN_ACT(chan_nr[0], g_pars.chan_mode), |
| 2893 | tr_RSL_CHAN_ACT_ACK(chan_nr[0]), "RSL CHAN ACT [0]"); |
| 2894 | setverdict(pass); |
| 2895 | } |
| 2896 | testcase TC_dyn_osmo_pdch_tchh_act() runs on test_CT { |
| 2897 | var ConnHdlrPars pars; |
| 2898 | var ConnHdlr vc_conn; |
| 2899 | f_init(testcasename()); |
| 2900 | |
| 2901 | pars := valueof(t_Pars(t_RslChanNr_PDCH(4), ts_RSL_ChanMode_SIGN)); |
| 2902 | vc_conn := f_start_handler(refers(f_TC_dyn_osmo_pdch_tchh_act), pars, true); |
| 2903 | vc_conn.done; |
| 2904 | } |
| 2905 | |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 2906 | /*********************************************************************** |
| 2907 | * IPA Style Dynamic Timeslot Support |
| 2908 | ***********************************************************************/ |
| 2909 | |
| 2910 | private function f_dyn_ipa_pdch_act(integer pcu_conn_id, integer bts_nr, integer trx_nr) |
| 2911 | runs on ConnHdlr { |
| 2912 | var PCUIF_send_data sd; |
| 2913 | /* Expect BTS to immediately acknowledge activation as PDCH */ |
| 2914 | PCU.clear; |
| 2915 | RSL.send(ts_RSL_IPA_PDCH_ACT(g_chan_nr)); |
| 2916 | /* expect INFO_IND on PCU interface listing TS as PDCH */ |
| 2917 | alt { |
| 2918 | [] PCU.receive(t_SD_PCUIF(pcu_conn_id, tr_PCUIF_INFO_IND(bts_nr, ?))) -> value sd { |
| 2919 | if (substr(sd.data.u.info_ind.trx[trx_nr].pdch_mask, g_chan_nr.tn, 1) != '1'B) { |
| 2920 | setverdict(fail, "PCUIF_INFO_IND PDCH_MASK not '1' after PDCH ACT"); |
| 2921 | self.stop; |
| 2922 | } |
| 2923 | } |
| 2924 | [] PCU.receive { repeat; } |
| 2925 | } |
| 2926 | /* try to activate this PDCH from the PCU point of view */ |
| 2927 | PCU.send(t_SD_PCUIF(pcu_conn_id, ts_PCUIF_ACT_REQ(bts_nr, trx_nr, g_chan_nr.tn))); |
| 2928 | /* FIXME: is there a response? */ |
| 2929 | |
| 2930 | RSL.receive(tr_RSL_IPA_PDCH_ACT_ACK(g_chan_nr, ?)); |
| 2931 | } |
| 2932 | |
| 2933 | private function f_dyn_ipa_pdch_deact(integer pcu_conn_id, integer bts_nr, integer trx_nr) |
| 2934 | runs on ConnHdlr { |
| 2935 | var PCUIF_send_data sd; |
| 2936 | /* Send RSL CHAN REL (deactivate) */ |
| 2937 | RSL.send(ts_RSL_IPA_PDCH_DEACT(g_chan_nr)); |
| 2938 | PCU.clear; |
| 2939 | /* expect BTS to ask PCU to deactivate the channel */ |
| 2940 | alt { |
| 2941 | [] PCU.receive(t_SD_PCUIF(pcu_conn_id, tr_PCUIF_INFO_IND(bts_nr, ?))) -> value sd { |
| 2942 | if (substr(sd.data.u.info_ind.trx[trx_nr].pdch_mask, g_chan_nr.tn, 1) != '0'B) { |
| 2943 | setverdict(fail, "PCUIF_INFO_IND PDCH_MASK not '0' after PDCH DEACT"); |
| 2944 | self.stop; |
| 2945 | } |
| 2946 | } |
| 2947 | [] PCU.receive { repeat; } |
| 2948 | } |
| 2949 | /* Emulate PCU asking BTS to deactivate PDCH */ |
| 2950 | PCU.send(t_SD_PCUIF(pcu_conn_id, ts_PCUIF_DEACT_REQ(bts_nr, trx_nr, g_chan_nr.tn))); |
| 2951 | alt { |
| 2952 | [] RSL.receive(tr_RSL_IPA_PDCH_DEACT_ACK(g_chan_nr)) { |
| 2953 | setverdict(pass); |
| 2954 | } |
| 2955 | [] RSL.receive { repeat; } |
| 2956 | } |
| 2957 | } |
| 2958 | |
| 2959 | /* Activate and de-activate an IPA-style dynamic TCH/F + PDCH */ |
| 2960 | function f_TC_dyn_ipa_pdch_act_deact(charstring id) runs on ConnHdlr { |
| 2961 | var PCUIF_Message first_info; |
| 2962 | var integer ts_nr := g_chan_nr.tn; |
| 2963 | var integer trx_nr := 0; |
| 2964 | var integer bts_nr := 0; |
| 2965 | var integer pcu_conn_id := -1; |
| 2966 | |
| 2967 | f_init_pcu(PCU, id, pcu_conn_id, first_info); |
| 2968 | |
| 2969 | f_dyn_ipa_pdch_act(pcu_conn_id, bts_nr, trx_nr); |
| 2970 | f_sleep(3.0); |
| 2971 | f_dyn_ipa_pdch_deact(pcu_conn_id, bts_nr, trx_nr); |
| 2972 | |
| 2973 | setverdict(pass); |
| 2974 | |
| 2975 | } |
| 2976 | testcase TC_dyn_ipa_pdch_act_deact() runs on test_CT { |
| 2977 | var ConnHdlrPars pars; |
| 2978 | var ConnHdlr vc_conn; |
| 2979 | f_init(); |
| 2980 | |
| 2981 | pars := valueof(t_Pars(t_RslChanNr_Bm(3), ts_RSL_ChanMode_SIGN)); |
| 2982 | vc_conn := f_start_handler(refers(f_TC_dyn_ipa_pdch_act_deact), pars, true); |
| 2983 | vc_conn.done; |
| 2984 | } |
| 2985 | |
| 2986 | /* try to RSL CHAN ACT a TCH/F on an IPA-style PDCH */ |
| 2987 | function f_TC_dyn_ipa_pdch_tchf_act(charstring id) runs on ConnHdlr { |
| 2988 | var PCUIF_Message first_info; |
| 2989 | var integer ts_nr := g_chan_nr.tn; |
| 2990 | var integer trx_nr := 0; |
| 2991 | var integer bts_nr := 0; |
| 2992 | var integer pcu_conn_id := -1; |
| 2993 | |
| 2994 | f_init_pcu(PCU, id, pcu_conn_id, first_info); |
| 2995 | |
| 2996 | f_rsl_transceive(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode), tr_RSL_CHAN_ACT_ACK(g_chan_nr), |
| 2997 | "RSL CHAN ACT"); |
| 2998 | f_rsl_transceive(ts_RSL_RF_CHAN_REL(g_chan_nr), tr_RSL_RF_CHAN_REL_ACK(g_chan_nr), |
| 2999 | "RF CHAN REL", true); |
| 3000 | setverdict(pass); |
| 3001 | } |
| 3002 | testcase TC_dyn_ipa_pdch_tchf_act() runs on test_CT { |
| 3003 | var ConnHdlrPars pars; |
| 3004 | var ConnHdlr vc_conn; |
| 3005 | f_init(testcasename()); |
| 3006 | |
| 3007 | pars := valueof(t_Pars(t_RslChanNr_Bm(3), ts_RSL_ChanMode_SIGN)); |
| 3008 | vc_conn := f_start_handler(refers(f_TC_dyn_ipa_pdch_tchf_act), pars, true); |
| 3009 | vc_conn.done; |
| 3010 | } |
| 3011 | |
| 3012 | /* Activate IPA style dyn PDCH as TCH/F and then illegally try to activate it as PDCH, too */ |
| 3013 | function f_TC_dyn_ipa_pdch_tchf_act_pdch_act_nack(charstring id) runs on ConnHdlr { |
| 3014 | var PCUIF_Message first_info; |
| 3015 | var integer ts_nr := g_chan_nr.tn; |
| 3016 | var integer trx_nr := 0; |
| 3017 | var integer bts_nr := 0; |
| 3018 | var integer pcu_conn_id := -1; |
| 3019 | |
| 3020 | f_init_pcu(PCU, id, pcu_conn_id, first_info); |
| 3021 | |
| 3022 | f_rsl_transceive(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode), tr_RSL_CHAN_ACT_ACK(g_chan_nr), |
| 3023 | "RSL CHAN ACT"); |
| 3024 | |
| 3025 | RSL.send(ts_RSL_IPA_PDCH_ACT(g_chan_nr)); |
| 3026 | alt { |
| 3027 | [] RSL.receive(tr_RSL_IPA_PDCH_ACT_NACK(g_chan_nr, ?)); |
| 3028 | [] RSL.receive(tr_RSL_IPA_PDCH_ACT_ACK(g_chan_nr, ?)) { |
| 3029 | setverdict(fail, "Unexpected PDCH ACT ACK"); |
| 3030 | self.stop; |
| 3031 | } |
| 3032 | [] RSL.receive { repeat; } |
| 3033 | } |
| 3034 | |
| 3035 | f_rsl_transceive(ts_RSL_RF_CHAN_REL(g_chan_nr), tr_RSL_RF_CHAN_REL_ACK(g_chan_nr), |
| 3036 | "RF CHAN REL", true); |
| 3037 | setverdict(pass); |
| 3038 | } |
| 3039 | testcase TC_dyn_ipa_pdch_tchf_act_pdch_act_nack() runs on test_CT { |
| 3040 | var ConnHdlrPars pars; |
| 3041 | var ConnHdlr vc_conn; |
| 3042 | f_init(testcasename()); |
| 3043 | |
| 3044 | pars := valueof(t_Pars(t_RslChanNr_Bm(3), ts_RSL_ChanMode_SIGN)); |
| 3045 | vc_conn := f_start_handler(refers(f_TC_dyn_ipa_pdch_tchf_act_pdch_act_nack), pars, true); |
| 3046 | vc_conn.done; |
| 3047 | } |
| 3048 | |
| 3049 | /* try to RSL CHAN ACT a TCH/F on an IPA-style PDCH that's already in PDCH mode; expect NACK */ |
| 3050 | function f_TC_dyn_ipa_pdch_act_tchf_act_nack(charstring id) runs on ConnHdlr { |
| 3051 | var PCUIF_Message first_info; |
| 3052 | var integer ts_nr := g_chan_nr.tn; |
| 3053 | var integer trx_nr := 0; |
| 3054 | var integer bts_nr := 0; |
| 3055 | var integer pcu_conn_id := -1; |
| 3056 | |
| 3057 | /* register for the TCH/F channel number */ |
| 3058 | f_rslem_register(0, g_chan_nr); |
| 3059 | |
| 3060 | f_init_pcu(PCU, id, pcu_conn_id, first_info); |
| 3061 | |
| 3062 | f_dyn_ipa_pdch_act(pcu_conn_id, bts_nr, trx_nr); |
| 3063 | |
| 3064 | f_rsl_transceive(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode), tr_RSL_CHAN_ACT_NACK(g_chan_nr), |
| 3065 | "RSL CHAN ACT"); |
| 3066 | |
| 3067 | f_dyn_ipa_pdch_deact(pcu_conn_id, bts_nr, trx_nr); |
| 3068 | |
| 3069 | setverdict(pass); |
| 3070 | } |
| 3071 | testcase TC_dyn_ipa_pdch_act_tchf_act_nack() runs on test_CT { |
| 3072 | var ConnHdlrPars pars; |
| 3073 | var ConnHdlr vc_conn; |
| 3074 | f_init(testcasename()); |
| 3075 | |
| 3076 | pars := valueof(t_Pars(t_RslChanNr_Bm(3), ts_RSL_ChanMode_SIGN)); |
| 3077 | vc_conn := f_start_handler(refers(f_TC_dyn_ipa_pdch_act_tchf_act_nack), pars, true); |
| 3078 | vc_conn.done; |
| 3079 | } |
| 3080 | |
| 3081 | |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 3082 | /*********************************************************************** |
| 3083 | * LAPDm / RLL related |
| 3084 | ***********************************************************************/ |
| 3085 | |
| 3086 | private function f_tx_lapdm(template (value) LapdmFrame l, |
| 3087 | template (value) RslLinkId link_id) runs on ConnHdlr { |
| 3088 | var octetstring l2 := enc_LapdmFrame(valueof(l)); |
| 3089 | if (valueof(link_id.c) == SACCH) { |
| 3090 | /* prepend dummy L1 header */ |
| 3091 | l2 := '0000'O & l2; |
| 3092 | } |
| 3093 | log("encoding ", l, " to ", l2); |
| 3094 | L1CTL.send(ts_L1CTL_DATA_REQ(g_chan_nr, link_id, l2)); |
| 3095 | } |
| 3096 | |
| 3097 | type record RllTestCase { |
| 3098 | uint3_t sapi, |
| 3099 | RslLinkId link_id, |
| 3100 | octetstring l3, |
| 3101 | boolean exp |
| 3102 | } |
| 3103 | type record of RllTestCase RllTestCases; |
| 3104 | template RllTestCase t_EITC(uint3_t sapi, RslLinkId id, octetstring l3, boolean exp) := { |
| 3105 | sapi := sapi, |
| 3106 | link_id := id, |
| 3107 | l3 := l3, |
| 3108 | exp := exp |
| 3109 | } |
| 3110 | |
| 3111 | /* execute the same callback function with a set of different parameters (tcs) on a |
| 3112 | * variety of logical channels */ |
| 3113 | private function f_rll_testmatrix(RllTestCases tcs, void_fn fn) runs on test_CT { |
| 3114 | var ConnHdlrPars pars; |
| 3115 | var ConnHdlr vc_conn; |
| 3116 | f_init(testcasename()); |
| 3117 | |
| 3118 | /* test on each of the channels we have */ |
| 3119 | for (var integer i := 0; i < sizeof(g_AllChanTypes); i := i+1) { |
| 3120 | pars := valueof(t_Pars(g_AllChanTypes[i], ts_RSL_ChanMode_SIGN)); |
| 3121 | |
| 3122 | /* test each of the test cases on the current channel */ |
| 3123 | for (var integer j := 0; j < sizeof(tcs); j := j+1) { |
| 3124 | pars.spec.rll := tcs[j]; |
| 3125 | log(testcasename(), ": XXX Starting ", tcs[j] , " on ", g_AllChanTypes[i]); |
| 3126 | vc_conn := f_start_handler(fn, pars); |
| 3127 | vc_conn.done; |
| 3128 | } |
| 3129 | } |
| 3130 | |
| 3131 | f_shutdown(); |
| 3132 | } |
| 3133 | |
| 3134 | /* test if SABM on Um triggers EST IND (TS 48.058 3.1) */ |
| 3135 | private function f_TC_rll_est_ind(charstring id) runs on ConnHdlr { |
| 3136 | var RllTestCase tc := g_pars.spec.rll; |
| 3137 | timer T := 3.0; |
| 3138 | |
| 3139 | f_l1_tune(L1CTL); |
| 3140 | RSL.clear; |
| 3141 | |
| 3142 | /* activate the logical channel */ |
| 3143 | f_est_dchan(); |
| 3144 | L1CTL.clear; |
| 3145 | |
| 3146 | f_tx_lapdm(ts_LAPDm_SABM(tc.sapi, cr_MO_CMD, true, tc.l3), tc.link_id); |
| 3147 | T.start; |
| 3148 | alt { |
| 3149 | [tc.l3 != ''O] RSL.receive(tr_RSL_EST_IND(g_chan_nr, tc.link_id, tc.l3)) { |
| 3150 | if (tc.exp) { |
| 3151 | setverdict(pass); |
| 3152 | } else { |
| 3153 | setverdict(fail, "Unexpected EST IND with L3 in ", tc); |
| 3154 | } |
| 3155 | } |
| 3156 | [tc.l3 == ''O] RSL.receive(tr_RSL_EST_IND_NOL3(g_chan_nr, tc.link_id)) { |
| 3157 | if (tc.exp) { |
| 3158 | setverdict(pass); |
| 3159 | } else { |
| 3160 | setverdict(fail, "Unexpected EST IND without L3 in ", tc); |
| 3161 | } |
| 3162 | } |
| 3163 | [tc.exp] T.timeout { |
| 3164 | setverdict(fail, "Timeout waiting for EST IND"); |
| 3165 | } |
| 3166 | [not tc.exp] T.timeout { |
| 3167 | setverdict(pass); |
| 3168 | } |
| 3169 | } |
| 3170 | |
| 3171 | f_rsl_chan_deact(); |
| 3172 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 3173 | f_rslem_unregister(0, g_chan_nr); |
| 3174 | } |
| 3175 | testcase TC_rll_est_ind() runs on test_CT { |
| 3176 | var RllTestCases tcs := { |
Harald Welte | 7aacbbf | 2018-05-09 16:56:41 +0200 | [diff] [blame] | 3177 | /* SAPI0 establishment (contention resolution) */ |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 3178 | valueof(t_EITC(0, valueof(ts_RslLinkID_DCCH(0)), '01020304'O, true)), |
Harald Welte | 7aacbbf | 2018-05-09 16:56:41 +0200 | [diff] [blame] | 3179 | /* normal SAPI0 establishment */ |
| 3180 | valueof(t_EITC(0, valueof(ts_RslLinkID_DCCH(0)), ''O, true)), |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 3181 | /* SAPI 3 doesn't support contention resolution */ |
| 3182 | valueof(t_EITC(3, valueof(ts_RslLinkID_DCCH(3)), '01020304'O, false)), |
| 3183 | valueof(t_EITC(3, valueof(ts_RslLinkID_SACCH(3)), '01020304'O, false)), |
| 3184 | /* normal SAPI3 establishment on main DCCH */ |
| 3185 | valueof(t_EITC(3, valueof(ts_RslLinkID_DCCH(3)), ''O, true)), |
| 3186 | /* normal SAPI3 establishment on SACCH */ |
| 3187 | valueof(t_EITC(3, valueof(ts_RslLinkID_SACCH(3)), ''O, true)) |
| 3188 | }; |
| 3189 | f_rll_testmatrix(tcs, refers(f_TC_rll_est_ind)); |
| 3190 | } |
| 3191 | |
| 3192 | /* test if RLL EST REQ trigeres SABM on Um; UA on Um triggers EST CONF (TS 48.058 3.2) */ |
| 3193 | private function f_TC_rll_est_req(charstring id) runs on ConnHdlr { |
| 3194 | var RllTestCase tc := g_pars.spec.rll; |
| 3195 | var L1ctlDlMessage dl; |
| 3196 | timer T := 3.0; |
| 3197 | |
| 3198 | f_l1_tune(L1CTL); |
| 3199 | RSL.clear; |
| 3200 | |
| 3201 | /* activate the logical channel */ |
| 3202 | f_est_dchan(); |
| 3203 | L1CTL.clear; |
| 3204 | |
| 3205 | /* Send a RSL EST REQ for SAPI3 on main DCCH */ |
| 3206 | RSL.send(ts_RSL_EST_REQ(g_chan_nr, tc.link_id)); |
| 3207 | T.start; |
| 3208 | alt { |
| 3209 | [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, ?)) -> value dl { |
| 3210 | var LapdmFrame lapdm; |
| 3211 | var octetstring l2 := dl.payload.data_ind.payload; |
| 3212 | if (dl.dl_info.link_id.c == SACCH) { |
| 3213 | /* remove L1 header */ |
| 3214 | l2 := substr(l2, 2, lengthof(l2)-2); |
| 3215 | } |
| 3216 | lapdm.ab := dec_LapdmFrameAB(l2); |
| 3217 | if (match(lapdm, tr_LAPDm_SABM(tc.sapi, cr_MT_CMD, true, ''O))) { |
| 3218 | setverdict(pass); |
| 3219 | } else { |
| 3220 | repeat; |
| 3221 | } |
| 3222 | } |
| 3223 | [] L1CTL.receive { repeat; } |
| 3224 | [] T.timeout { |
| 3225 | setverdict(fail, "Timeout waiting for SABM"); |
| 3226 | self.stop; |
| 3227 | } |
| 3228 | } |
| 3229 | |
| 3230 | f_rsl_chan_deact(); |
| 3231 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 3232 | f_rslem_unregister(0, g_chan_nr); |
| 3233 | } |
| 3234 | testcase TC_rll_est_req_DCCH_3() runs on test_CT { |
| 3235 | var RllTestCases tcs := { |
| 3236 | /* normal SAPI3 establishment on main DCCH */ |
| 3237 | valueof(t_EITC(3, valueof(ts_RslLinkID_DCCH(3)), ''O, true))//, |
| 3238 | }; |
| 3239 | f_rll_testmatrix(tcs, refers(f_TC_rll_est_req)); |
| 3240 | } |
| 3241 | testcase TC_rll_est_req_ACCH_3() runs on test_CT { |
| 3242 | var RllTestCases tcs := { |
| 3243 | /* normal SAPI3 establishment on SACCH */ |
| 3244 | valueof(t_EITC(3, valueof(ts_RslLinkID_SACCH(3)), ''O, true)) |
| 3245 | } |
| 3246 | f_rll_testmatrix(tcs, refers(f_TC_rll_est_req)); |
| 3247 | } |
| 3248 | |
| 3249 | /* altstep to receive a LAPDm frame matching the given template */ |
| 3250 | private altstep as_l1_exp_lapdm(template LapdmFrame exp) runs on ConnHdlr { |
| 3251 | var L1ctlDlMessage dl; |
| 3252 | [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, ?)) -> value dl { |
| 3253 | var LapdmFrame lapdm; |
| 3254 | var octetstring l2 := dl.payload.data_ind.payload; |
| 3255 | if (dl.dl_info.link_id.c == SACCH) { |
| 3256 | /* remove L1 header */ |
| 3257 | l2 := substr(l2, 2, lengthof(l2)-2); |
| 3258 | } |
| 3259 | if (ischosen(exp.ab)) { |
| 3260 | lapdm.ab := dec_LapdmFrameAB(l2); |
| 3261 | } else if (ischosen(exp.b4)) { |
| 3262 | lapdm.b4 := dec_LapdmFrameB4(l2); |
| 3263 | } else if (ischosen(exp.bbis)) { |
| 3264 | lapdm.bbis := dec_LapdmFrameBbis(l2); |
| 3265 | } |
| 3266 | log("Rx LAPDm ", lapdm); |
| 3267 | if (match(lapdm, exp)) { |
| 3268 | setverdict(pass); |
| 3269 | } else { |
| 3270 | repeat; |
| 3271 | } |
| 3272 | } |
| 3273 | [] L1CTL.receive { repeat; } |
| 3274 | } |
| 3275 | private function f_l1_exp_lapdm(template LapdmFrame exp, float t := 3.0) runs on ConnHdlr { |
| 3276 | timer T := t; |
| 3277 | T.start; |
| 3278 | alt { |
| 3279 | [] T.timeout { |
| 3280 | setverdict(fail, "Timeout waiting for LAPDm ", exp); |
| 3281 | self.stop; |
| 3282 | } |
| 3283 | [] as_l1_exp_lapdm(exp); |
| 3284 | } |
| 3285 | } |
| 3286 | |
| 3287 | /* establish one Radio Link Layer via SABM -> UA. Use l3 for contention resolution */ |
| 3288 | private function f_est_rll_mo(uint3_t sapi, RslLinkId link_id, octetstring l3) runs on ConnHdlr { |
| 3289 | /* send SABM from MS -> BTS */ |
| 3290 | f_tx_lapdm(ts_LAPDm_SABM(sapi, cr_MO_CMD, true, l3), link_id); |
| 3291 | /* expect RLL EST IND on Abis */ |
| 3292 | alt { |
| 3293 | [l3 != ''O] RSL.receive(tr_RSL_EST_IND(g_chan_nr, link_id, l3)); |
| 3294 | [l3 == ''O] RSL.receive(tr_RSL_EST_IND_NOL3(g_chan_nr, link_id)); |
| 3295 | [] RSL.receive(tr_RSL_ERROR_IND(g_chan_nr, link_id, ?)) { |
| 3296 | setverdict(fail, "Failing due to RSL_ERROR_IND"); |
| 3297 | self.stop; |
| 3298 | } |
| 3299 | [] RSL.receive { repeat; } |
| 3300 | } |
| 3301 | /* expect UA from BTS -> MS */ |
| 3302 | f_l1_exp_lapdm(tr_LAPDm_UA(sapi, cr_MT_RSP, true, l3)); |
| 3303 | } |
| 3304 | |
| 3305 | /* test if DISC on Um triggers RLL REL IND (TS 48.058 3.3) */ |
| 3306 | private function f_TC_rll_rel_ind(charstring id) runs on ConnHdlr { |
| 3307 | var RllTestCase tc := g_pars.spec.rll; |
| 3308 | |
| 3309 | f_l1_tune(L1CTL); |
| 3310 | RSL.clear; |
| 3311 | |
| 3312 | /* activate the logical channel */ |
| 3313 | f_est_dchan(); |
| 3314 | L1CTL.clear; |
| 3315 | |
| 3316 | /* first establish the link-layer */ |
| 3317 | f_est_rll_mo(tc.sapi, tc.link_id, tc.l3); |
| 3318 | |
| 3319 | /* then send the DISC */ |
| 3320 | f_tx_lapdm(ts_LAPDm_DISC(tc.sapi, cr_MO_CMD, true), tc.link_id); |
| 3321 | /* ... and expect the REL IND on the RSL side */ |
| 3322 | alt { |
| 3323 | [] RSL.receive(tr_RSL_REL_IND(g_chan_nr, tc.link_id)) { |
| 3324 | setverdict(pass); |
| 3325 | } |
| 3326 | } |
| 3327 | |
| 3328 | /* release the channel */ |
| 3329 | f_rsl_chan_deact(); |
| 3330 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 3331 | f_rslem_unregister(0, g_chan_nr); |
| 3332 | } |
| 3333 | testcase TC_rll_rel_ind_DCCH_0() runs on test_CT { |
| 3334 | var RllTestCases tcs := { |
| 3335 | valueof(t_EITC(0, valueof(ts_RslLinkID_DCCH(0)), '01020304'O, true)) |
| 3336 | }; |
| 3337 | f_rll_testmatrix(tcs, refers(f_TC_rll_rel_ind)); |
| 3338 | } |
| 3339 | |
| 3340 | testcase TC_rll_rel_ind_ACCH_0() runs on test_CT { |
| 3341 | var RllTestCases tcs := { |
| 3342 | valueof(t_EITC(0, valueof(ts_RslLinkID_SACCH(0)), ''O, true)) |
| 3343 | }; |
| 3344 | f_rll_testmatrix(tcs, refers(f_TC_rll_rel_ind)); |
| 3345 | } |
| 3346 | testcase TC_rll_rel_ind_DCCH_3() runs on test_CT { |
| 3347 | var RllTestCases tcs := { |
| 3348 | valueof(t_EITC(3, valueof(ts_RslLinkID_DCCH(3)), ''O, true)) |
| 3349 | }; |
| 3350 | f_rll_testmatrix(tcs, refers(f_TC_rll_rel_ind)); |
| 3351 | } |
| 3352 | testcase TC_rll_rel_ind_ACCH_3() runs on test_CT { |
| 3353 | var RllTestCases tcs := { |
| 3354 | valueof(t_EITC(3, valueof(ts_RslLinkID_SACCH(3)), ''O, true)) |
| 3355 | }; |
| 3356 | f_rll_testmatrix(tcs, refers(f_TC_rll_rel_ind)); |
| 3357 | } |
| 3358 | |
| 3359 | /* test if RLL REL REQ triggers DISC on Um; UA/DM triggers RLL REL CONF (TS 48.058 3.4) */ |
| 3360 | private function f_TC_rll_rel_req(charstring id) runs on ConnHdlr { |
| 3361 | var RllTestCase tc := g_pars.spec.rll; |
| 3362 | f_l1_tune(L1CTL); |
| 3363 | RSL.clear; |
| 3364 | |
| 3365 | /* activate the logical channel */ |
| 3366 | f_est_dchan(); |
| 3367 | L1CTL.clear; |
| 3368 | |
| 3369 | /* first establish the link-layer */ |
| 3370 | f_est_rll_mo(tc.sapi, tc.link_id, tc.l3); |
| 3371 | |
| 3372 | /* then send the REL REQ via RSL */ |
| 3373 | RSL.send(ts_RSL_REL_REQ(g_chan_nr, tc.link_id, RSL_REL_MODE_NORMAL)); |
| 3374 | /* ... and expect the DISC on the Um side */ |
| 3375 | alt { |
Harald Welte | bc6199f | 2018-05-10 19:38:18 +0200 | [diff] [blame] | 3376 | [] as_l1_exp_lapdm(tr_LAPDm_DISC(tc.sapi, cr_MT_CMD, true)) { |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 3377 | /* FIXME: send a UA in resposne to the DISC */ |
| 3378 | } |
| 3379 | } |
| 3380 | |
| 3381 | /* release the channel */ |
| 3382 | f_rsl_chan_deact(); |
| 3383 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 3384 | f_rslem_unregister(0, g_chan_nr); |
| 3385 | } |
| 3386 | testcase TC_rll_rel_req() runs on test_CT { |
| 3387 | var RllTestCases tcs := { |
| 3388 | valueof(t_EITC(0, valueof(ts_RslLinkID_DCCH(0)), '01020304'O, true)), |
| 3389 | valueof(t_EITC(0, valueof(ts_RslLinkID_SACCH(0)), ''O, true)), |
| 3390 | valueof(t_EITC(3, valueof(ts_RslLinkID_DCCH(3)), ''O, true)), |
| 3391 | valueof(t_EITC(3, valueof(ts_RslLinkID_SACCH(3)), ''O, true)) |
| 3392 | }; |
| 3393 | f_rll_testmatrix(tcs, refers(f_TC_rll_rel_req)); |
| 3394 | } |
| 3395 | |
| 3396 | /* test if RLL DATA REQ triggers I-frames on Um (TS 48.058 3.5) */ |
| 3397 | testcase TC_rll_data_req() runs on test_CT { |
| 3398 | } |
| 3399 | |
| 3400 | /* test if I-frames on Um trigger RLL DATA IND (TS 48.058 3.6) */ |
| 3401 | testcase TC_rll_data_ind() runs on test_CT { |
| 3402 | } |
| 3403 | |
| 3404 | /* test if RLL UNIT DATA REQ triggers UI-frame on Um (TS 48.058 3.7) */ |
| 3405 | private function f_TC_rll_ud_req(charstring id) runs on ConnHdlr { |
| 3406 | var RllTestCase tc := g_pars.spec.rll; |
| 3407 | |
| 3408 | f_l1_tune(L1CTL); |
| 3409 | RSL.clear; |
| 3410 | |
| 3411 | f_est_dchan(); |
| 3412 | L1CTL.clear; |
| 3413 | |
| 3414 | /* Send UNITDATA REQ on RSL side */ |
| 3415 | RSL.send(ts_RSL_UNITDATA_REQ(g_chan_nr, tc.link_id, tc.l3)); |
| 3416 | /* Expect it to arrive on the other side */ |
| 3417 | if (tc.link_id.c == SACCH) { |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 3418 | f_l1_exp_lapdm(tr_LAPDm_B4_UI(tc.sapi, cr_MT_CMD, tc.l3)); |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 3419 | } else { |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 3420 | f_l1_exp_lapdm(tr_LAPDm_UI(tc.sapi, cr_MT_CMD, tc.l3)); |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 3421 | } |
| 3422 | |
| 3423 | /* release the channel */ |
| 3424 | f_rsl_chan_deact(); |
| 3425 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 3426 | f_rslem_unregister(0, g_chan_nr); |
| 3427 | } |
| 3428 | testcase TC_rll_unit_data_req_DCCH() runs on test_CT { |
| 3429 | var octetstring l3 := f_rnd_octstring(15); |
| 3430 | var RllTestCases tcs := { |
| 3431 | valueof(t_EITC(0, valueof(ts_RslLinkID_DCCH(0)), l3, true)), |
| 3432 | valueof(t_EITC(3, valueof(ts_RslLinkID_DCCH(3)), l3, true)) |
| 3433 | }; |
| 3434 | f_rll_testmatrix(tcs, refers(f_TC_rll_ud_req)); |
| 3435 | } |
| 3436 | testcase TC_rll_unit_data_req_ACCH() runs on test_CT { |
| 3437 | var octetstring l3 := f_rnd_octstring(19); |
| 3438 | var RllTestCases tcs := { |
| 3439 | valueof(t_EITC(0, valueof(ts_RslLinkID_SACCH(0)), l3, true)), |
| 3440 | valueof(t_EITC(3, valueof(ts_RslLinkID_SACCH(3)), l3, true)) |
| 3441 | }; |
| 3442 | f_rll_testmatrix(tcs, refers(f_TC_rll_ud_req)); |
| 3443 | } |
| 3444 | |
| 3445 | /* test if UI-frames on Um trigger RLL UNIT DATA IND (TS 48.058 3.8) */ |
| 3446 | private function f_TC_rll_ud_ind(charstring id) runs on ConnHdlr { |
| 3447 | var RllTestCase tc := g_pars.spec.rll; |
| 3448 | |
| 3449 | f_l1_tune(L1CTL); |
| 3450 | RSL.clear; |
| 3451 | |
| 3452 | f_est_dchan(); |
| 3453 | L1CTL.clear; |
| 3454 | |
| 3455 | /* Send LAPDm UI frame. There is no B4 format in uplink! */ |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 3456 | f_tx_lapdm(ts_LAPDm_UI(tc.sapi, cr_MO_CMD, tc.l3), tc.link_id); |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 3457 | /* Expdct RLL UNITDATA IND on RSL side */ |
| 3458 | alt { |
| 3459 | [] RSL.receive(tr_RSL_UNITDATA_IND(g_chan_nr, tc.link_id, tc.l3)) { |
| 3460 | setverdict(pass); |
| 3461 | } |
| 3462 | [] RSL.receive { repeat; } |
| 3463 | } |
| 3464 | |
| 3465 | /* release the channel */ |
| 3466 | f_rsl_chan_deact(); |
| 3467 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 3468 | f_rslem_unregister(0, g_chan_nr); |
| 3469 | } |
| 3470 | testcase TC_rll_unit_data_ind_DCCH() runs on test_CT { |
| 3471 | var octetstring l3 := f_rnd_octstring(15); |
| 3472 | var RllTestCases tcs := { |
| 3473 | valueof(t_EITC(0, valueof(ts_RslLinkID_DCCH(0)), l3, true)), |
| 3474 | valueof(t_EITC(3, valueof(ts_RslLinkID_DCCH(3)), l3, true)) |
| 3475 | }; |
| 3476 | f_rll_testmatrix(tcs, refers(f_TC_rll_ud_ind)); |
| 3477 | } |
| 3478 | testcase TC_rll_unit_data_ind_ACCH() runs on test_CT { |
| 3479 | var octetstring l3 := f_rnd_octstring(18); |
| 3480 | var RllTestCases tcs := { |
| 3481 | valueof(t_EITC(0, valueof(ts_RslLinkID_SACCH(0)), l3, true)), |
| 3482 | valueof(t_EITC(3, valueof(ts_RslLinkID_SACCH(3)), l3, true)) |
| 3483 | }; |
| 3484 | f_rll_testmatrix(tcs, refers(f_TC_rll_ud_ind)); |
| 3485 | } |
| 3486 | |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 3487 | /*********************************************************************** |
| 3488 | * Encryption Related |
| 3489 | ***********************************************************************/ |
| 3490 | |
| 3491 | /* send UNITDATA_REQ from BTS to MS and expect it to arrive */ |
| 3492 | function f_unitdata_mt(RslLinkId link_id, octetstring l3) runs on ConnHdlr { |
| 3493 | RSL.send(ts_RSL_UNITDATA_REQ(g_chan_nr, link_id, l3)); |
| 3494 | if (link_id.c == SACCH) { |
| 3495 | f_l1_exp_lapdm(tr_LAPDm_B4_UI(link_id.sapi, cr_MT_CMD, l3)); |
| 3496 | } else { |
| 3497 | f_l1_exp_lapdm(tr_LAPDm_UI(link_id.sapi, cr_MT_CMD, l3)); |
| 3498 | } |
| 3499 | } |
| 3500 | |
| 3501 | /* Send UI frame from MS and expect it to arrive as RLL UNITDATA IND on Abis */ |
| 3502 | function f_unitdata_mo(RslLinkId link_id, octetstring l3) runs on ConnHdlr { |
| 3503 | timer T := 3.0; |
| 3504 | f_tx_lapdm(ts_LAPDm_UI(link_id.sapi, cr_MO_CMD, l3), link_id); |
| 3505 | T.start; |
| 3506 | /* Expect RLL UNITDATA IND on RSL side */ |
| 3507 | alt { |
| 3508 | [] RSL.receive(tr_RSL_UNITDATA_IND(g_chan_nr, link_id, l3)) { |
| 3509 | setverdict(pass); |
| 3510 | } |
| 3511 | [] T.timeout { |
| 3512 | setverdict(fail, "Timeout waiting for UNIT_DATA_IND"); |
| 3513 | } |
| 3514 | [] RSL.receive { repeat; } |
| 3515 | } |
| 3516 | } |
| 3517 | |
| 3518 | /* Test channel activation with A5/n right from the beginning (like in assignment + hand-over) */ |
| 3519 | function f_TC_chan_act_encr(charstring id) runs on ConnHdlr { |
| 3520 | f_l1_tune(L1CTL); |
| 3521 | f_est_dchan(true); |
| 3522 | |
| 3523 | /* now we actually need to transmit some data both ways to check if the encryption works */ |
| 3524 | var L1ctlDlMessage dl; |
| 3525 | |
| 3526 | var octetstring l3 := f_rnd_octstring(16); |
| 3527 | var RslLinkId link_id := valueof(ts_RslLinkID_DCCH(0)); |
| 3528 | |
| 3529 | /* send UNITDATA_REQ from BTS to MS and expect it to arrive */ |
| 3530 | f_unitdata_mt(link_id, l3); |
| 3531 | |
| 3532 | /* Send UI frame from MS and expect it to arrive as RLL UNITDATA IND on Abis */ |
| 3533 | f_unitdata_mo(link_id, l3); |
| 3534 | |
| 3535 | /* release the channel */ |
| 3536 | f_rsl_chan_deact(); |
| 3537 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 3538 | f_rslem_unregister(0, g_chan_nr); |
| 3539 | } |
| 3540 | testcase TC_chan_act_a51() runs on test_CT { |
| 3541 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 3542 | pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_1, f_rnd_octstring(8))); |
| 3543 | f_testmatrix_each_chan(pars, refers(f_TC_chan_act_encr)); |
| 3544 | } |
| 3545 | testcase TC_chan_act_a52() runs on test_CT { |
| 3546 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 3547 | pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_2, f_rnd_octstring(8))); |
| 3548 | f_testmatrix_each_chan(pars, refers(f_TC_chan_act_encr)); |
| 3549 | } |
| 3550 | testcase TC_chan_act_a53() runs on test_CT { |
| 3551 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 3552 | pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_3, f_rnd_octstring(8))); |
| 3553 | f_testmatrix_each_chan(pars, refers(f_TC_chan_act_encr)); |
| 3554 | } |
| 3555 | |
| 3556 | |
| 3557 | /* Test unencrypted channel activation followed by explicit ENCR CMD later */ |
| 3558 | function f_TC_encr_cmd(charstring id) runs on ConnHdlr { |
| 3559 | /* L3 payload doesn't matter, as it is passed transparently */ |
| 3560 | var BIT3 l3_alg_id := f_alg_id_to_l3(g_pars.encr.alg_id); |
| 3561 | var octetstring l3 := enc_PDU_ML3_NW_MS(valueof(ts_RRM_CiphModeCmd(l3_alg_id))); |
| 3562 | var RslLinkId link_id := valueof(ts_RslLinkID_DCCH(0)); |
| 3563 | |
| 3564 | f_l1_tune(L1CTL); |
| 3565 | |
| 3566 | /* first establish a dedicated channel in the clear */ |
| 3567 | f_est_dchan(false); |
| 3568 | |
| 3569 | /* Establish ABM */ |
| 3570 | f_est_rll_mo(link_id.sapi, link_id, '23420815'O); |
| 3571 | |
| 3572 | /* then send the RSL ENCR CMD with an actual RR CIPH MOD CMD inside */ |
| 3573 | RSL.send(ts_RSL_ENCR_CMD(g_chan_nr, link_id, g_pars.encr.alg_id, g_pars.encr.key, l3)); |
| 3574 | /* expect the L3 to arrive still unencrypted on the MS side */ |
| 3575 | f_l1_exp_lapdm(tr_LAPDm_I(link_id.sapi, cr_MT_CMD, ?, ?, ?, l3)); |
| 3576 | |
| 3577 | /* configure L1 to apply ciphering */ |
| 3578 | var uint8_t alg_id := f_alg_id_to_l1ctl(g_pars.encr.alg_id); |
| 3579 | f_L1CTL_CRYPTO_REQ(L1CTL, g_pars.chan_nr, alg_id, g_pars.encr.key); |
| 3580 | |
| 3581 | /* send first ciphered I-frame in response */ |
| 3582 | l3 := '0a0b0c0d'O; |
| 3583 | f_tx_lapdm(ts_LAPDm_I(link_id.sapi, cr_MO_CMD, true, 1, 0, l3), link_id); |
| 3584 | RSL.receive(tr_RSL_DATA_IND(g_chan_nr, link_id, l3)); |
| 3585 | |
| 3586 | /* now the BTS code should have detected the first properly encrypted uplink I-frame, |
| 3587 | * and hence enable encryption also on the downlink */ |
| 3588 | |
| 3589 | /* expect bi-directional communication work in encrypted mode */ |
| 3590 | f_unitdata_mo(link_id, f_rnd_octstring(15)); |
| 3591 | f_unitdata_mt(link_id, f_rnd_octstring(15)); |
| 3592 | |
| 3593 | /* release the channel */ |
| 3594 | f_rsl_chan_deact(); |
| 3595 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 3596 | f_rslem_unregister(0, g_chan_nr); |
| 3597 | } |
| 3598 | testcase TC_encr_cmd_a51() runs on test_CT { |
| 3599 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 3600 | pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_1, f_rnd_octstring(8))); |
| 3601 | f_testmatrix_each_chan(pars, refers(f_TC_encr_cmd)); |
| 3602 | } |
| 3603 | testcase TC_encr_cmd_a52() runs on test_CT { |
| 3604 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 3605 | pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_2, f_rnd_octstring(8))); |
| 3606 | f_testmatrix_each_chan(pars, refers(f_TC_encr_cmd)); |
| 3607 | } |
| 3608 | testcase TC_encr_cmd_a53() runs on test_CT { |
| 3609 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 3610 | pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_3, f_rnd_octstring(8))); |
| 3611 | f_testmatrix_each_chan(pars, refers(f_TC_encr_cmd)); |
| 3612 | } |
| 3613 | |
| 3614 | private function f_assert_lapdm(octetstring enc, template LapdmFrame exp_match, charstring name := "") { |
| 3615 | var LapdmFrame lf; |
| 3616 | var octetstring reenc; |
| 3617 | |
| 3618 | /* decode the LAPDm frame */ |
| 3619 | if (ischosen(exp_match.ab)) { |
| 3620 | lf.ab := dec_LapdmFrameAB(enc); |
| 3621 | } else { |
| 3622 | setverdict(fail, "unsupported frame type"); |
| 3623 | self.stop; |
| 3624 | } |
| 3625 | |
| 3626 | /* check if decoder result matches expectation */ |
| 3627 | if (not match(lf, exp_match)) { |
| 3628 | setverdict(fail, name, ": decoded LAPDm doesn't match"); |
| 3629 | } else { |
| 3630 | log(name, ": matched"); |
| 3631 | setverdict(pass); |
| 3632 | } |
| 3633 | |
| 3634 | /* test if re-encoded frame equals original input */ |
| 3635 | reenc := enc_LapdmFrame(lf); |
| 3636 | if (enc != reenc) { |
| 3637 | setverdict(fail, name, ": re-encoded LAPDm frame doesn't match"); |
| 3638 | } else { |
| 3639 | setverdict(pass); |
| 3640 | } |
| 3641 | } |
| 3642 | |
| 3643 | testcase TC_lapdm_selftest() runs on test_CT { |
| 3644 | f_assert_lapdm('030301'O, tr_LAPDm_UI(0, true, ''O), "ui_s0_empty"); |
| 3645 | f_assert_lapdm('0F0301'O, tr_LAPDm_UI(3, true, ''O), "ui_s3_empty"); |
| 3646 | f_assert_lapdm('013F01'O, tr_LAPDm_SABM(0, false, true, ''O), "sabm_s0_empty"); |
| 3647 | f_assert_lapdm('013F1123420815'O, tr_LAPDm_SABM(0, false, true, '23420815'O), "sabm_s0_l3"); |
| 3648 | f_assert_lapdm('03E101'O, tr_LAPDm_RR(0, true, false, 7), "rr_s0_7"); |
| 3649 | f_assert_lapdm('03000d063505'O, tr_LAPDm_I(0, true, false, 0, 0, '063505'O), "I/0/0"); |
| 3650 | f_assert_lapdm('03e00d063505'O, tr_LAPDm_I(0, true, false, 7, 0, '063505'O), "I/7/0"); |
| 3651 | } |
| 3652 | |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 3653 | |
| 3654 | /* test generation of RLL ERR IND based on Um errors (TS 48.058 3.9) */ |
| 3655 | /* protocol error as per 44.006 */ |
| 3656 | /* link layer failure (repetition of I-frame N200 times without ACK */ |
| 3657 | /* repetition of SABM or DISC N200 times without ACK */ |
| 3658 | /* receptiom of SABM in multi-frame established state */ |
| 3659 | |
| 3660 | |
| 3661 | |
| 3662 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 3663 | |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3664 | /* TODO Areas: |
| 3665 | |
| 3666 | * channel activation |
| 3667 | ** with BS_Power / MS_Power, bypassing power control loop |
| 3668 | ** on primary vs. secondary TRX |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3669 | ** with timing advance from initial activation on |
| 3670 | * mode modify |
| 3671 | ** encryption |
| 3672 | ** multirate |
| 3673 | * check DEACTIVATE SACCH |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3674 | ** unsupported algorithm |
| 3675 | * handover detection |
| 3676 | * MS Power Control |
| 3677 | * BS Power Control |
| 3678 | * Physical Context |
| 3679 | * SACCH info modify |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3680 | * CCCH Load Indication for PCH and RACH |
| 3681 | * Delete Indication on AGCH overflow |
| 3682 | * SMS Broadcast Req / Cmd / CBCH LOad Ind |
| 3683 | * RF resource ind |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3684 | * error handling |
| 3685 | * discriminator error |
| 3686 | ** type error |
| 3687 | ** sequence error |
| 3688 | ** IE duplicated? |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 3689 | * PCU interface |
| 3690 | ** TIME_IND from BTS->PCU |
| 3691 | ** DATA_IND from BTS->PCU |
| 3692 | ** verification of PCU-originated DATA_REQ arrival on Um/MS side |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3693 | |
| 3694 | */ |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3695 | |
| 3696 | control { |
| 3697 | execute( TC_chan_act_stress() ); |
| 3698 | execute( TC_chan_act_react() ); |
| 3699 | execute( TC_chan_deact_not_active() ); |
| 3700 | execute( TC_chan_act_wrong_nr() ); |
Harald Welte | 629cc6b | 2018-03-11 17:19:05 +0100 | [diff] [blame] | 3701 | execute( TC_deact_sacch() ); |
Harald Welte | ea17b91 | 2018-03-11 22:29:31 +0100 | [diff] [blame] | 3702 | execute( TC_sacch_filling() ); |
| 3703 | execute( TC_sacch_info_mod() ); |
Harald Welte | 075d84c | 2018-03-12 13:07:24 +0100 | [diff] [blame] | 3704 | execute( TC_sacch_multi() ); |
Harald Welte | 5570066 | 2018-03-12 13:15:43 +0100 | [diff] [blame] | 3705 | execute( TC_sacch_multi_chg() ); |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 3706 | execute( TC_rach_content() ); |
| 3707 | execute( TC_rach_count() ); |
Harald Welte | 54a2a2d | 2018-02-26 09:14:05 +0100 | [diff] [blame] | 3708 | execute( TC_rach_max_ta() ); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3709 | execute( TC_meas_res_sign_tchf() ); |
| 3710 | execute( TC_meas_res_sign_tchh() ); |
| 3711 | execute( TC_meas_res_sign_sdcch4() ); |
| 3712 | execute( TC_meas_res_sign_sdcch8() ); |
Harald Welte | 685d598 | 2018-02-27 20:42:05 +0100 | [diff] [blame] | 3713 | execute( TC_meas_res_sign_tchh_toa256() ); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3714 | execute( TC_conn_fail_crit() ); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3715 | execute( TC_paging_imsi_80percent() ); |
| 3716 | execute( TC_paging_tmsi_80percent() ); |
| 3717 | execute( TC_paging_imsi_200percent() ); |
| 3718 | execute( TC_paging_tmsi_200percent() ); |
Harald Welte | 01d982c | 2018-02-25 01:31:40 +0100 | [diff] [blame] | 3719 | execute( TC_rsl_protocol_error() ); |
| 3720 | execute( TC_rsl_mand_ie_error() ); |
| 3721 | execute( TC_rsl_ie_content_error() ); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 3722 | execute( TC_si_sched_default() ); |
Harald Welte | 0cae455 | 2018-03-09 22:20:26 +0100 | [diff] [blame] | 3723 | execute( TC_si_sched_1() ); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 3724 | execute( TC_si_sched_2bis() ); |
| 3725 | execute( TC_si_sched_2ter() ); |
| 3726 | execute( TC_si_sched_2ter_2bis() ); |
| 3727 | execute( TC_si_sched_2quater() ); |
| 3728 | execute( TC_si_sched_13() ); |
| 3729 | execute( TC_si_sched_13_2bis_2ter_2quater() ); |
Harald Welte | a871a38 | 2018-02-25 02:03:14 +0100 | [diff] [blame] | 3730 | execute( TC_ipa_dlcx_not_active() ); |
Harald Welte | a3f1df9 | 2018-02-25 12:49:55 +0100 | [diff] [blame] | 3731 | execute( TC_ipa_crcx_twice_not_active() ); |
| 3732 | execute( TC_ipa_crcx_mdcx_dlcx_not_active() ); |
Harald Welte | 3ae11da | 2018-02-25 13:36:06 +0100 | [diff] [blame] | 3733 | execute( TC_ipa_crcx_mdcx_mdcx_dlcx_not_active() ); |
Harald Welte | 9912eb5 | 2018-02-25 13:30:15 +0100 | [diff] [blame] | 3734 | execute( TC_ipa_crcx_sdcch_not_active() ); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 3735 | |
| 3736 | execute( TC_pcu_act_req() ); |
| 3737 | execute( TC_pcu_act_req_wrong_ts() ); |
| 3738 | execute( TC_pcu_act_req_wrong_bts() ); |
| 3739 | execute( TC_pcu_act_req_wrong_trx() ); |
| 3740 | execute( TC_pcu_deact_req() ); |
| 3741 | execute( TC_pcu_deact_req_wrong_ts() ); |
| 3742 | execute( TC_pcu_ver_si13() ); |
| 3743 | execute( TC_pcu_data_req_wrong_bts() ); |
| 3744 | execute( TC_pcu_data_req_wrong_trx() ); |
| 3745 | execute( TC_pcu_data_req_wrong_ts() ); |
| 3746 | execute( TC_pcu_data_req_ts_inactive() ); |
| 3747 | execute( TC_pcu_data_req_pdtch() ); |
| 3748 | execute( TC_pcu_data_req_ptcch() ); |
| 3749 | execute( TC_pcu_data_req_agch() ); |
| 3750 | execute( TC_pcu_data_req_imm_ass_pch() ); |
| 3751 | execute( TC_pcu_rach_content() ); |
| 3752 | execute( TC_pcu_paging_from_rsl() ); |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 3753 | |
| 3754 | execute( TC_dyn_osmo_pdch_act_deact() ); |
| 3755 | execute( TC_dyn_osmo_pdch_unsol_deact() ); |
| 3756 | execute( TC_dyn_osmo_pdch_double_act() ); |
| 3757 | execute( TC_dyn_osmo_pdch_tchf_act() ); |
| 3758 | execute( TC_dyn_osmo_pdch_tchh_act() ); |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 3759 | execute( TC_dyn_ipa_pdch_act_deact() ); |
| 3760 | execute( TC_dyn_ipa_pdch_tchf_act() ); |
| 3761 | execute( TC_dyn_ipa_pdch_tchf_act_pdch_act_nack() ); |
| 3762 | execute( TC_dyn_ipa_pdch_act_tchf_act_nack() ); |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 3763 | |
| 3764 | execute( TC_rll_est_ind() ); |
| 3765 | execute( TC_rll_est_req_DCCH_3() ); |
| 3766 | execute( TC_rll_est_req_ACCH_3() ); |
| 3767 | execute( TC_rll_rel_ind_DCCH_0() ); |
| 3768 | execute( TC_rll_rel_ind_DCCH_3() ); |
| 3769 | execute( TC_rll_rel_ind_ACCH_0() ); |
| 3770 | execute( TC_rll_rel_ind_ACCH_3() ); |
| 3771 | execute( TC_rll_rel_req() ); |
| 3772 | execute( TC_rll_unit_data_req_DCCH() ); |
| 3773 | execute( TC_rll_unit_data_req_ACCH() ); |
| 3774 | execute( TC_rll_unit_data_ind_DCCH() ); |
| 3775 | execute( TC_rll_unit_data_ind_ACCH() ); |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 3776 | |
| 3777 | execute( TC_chan_act_a51() ); |
| 3778 | execute( TC_chan_act_a52() ); |
| 3779 | execute( TC_chan_act_a53() ); |
| 3780 | execute( TC_encr_cmd_a51() ); |
| 3781 | execute( TC_encr_cmd_a52() ); |
| 3782 | execute( TC_encr_cmd_a53() ); |
| 3783 | |
| 3784 | execute( TC_lapdm_selftest() ); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 3785 | } |
| 3786 | |
| 3787 | |
| 3788 | } |