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