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