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