Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1 | module BTS_Tests { |
| 2 | |
Harald Welte | 1490695 | 2019-05-27 09:19:49 +0200 | [diff] [blame] | 3 | /* Integration Tests for OsmoBTS |
Harald Welte | 34b5a95 | 2019-05-27 11:54:11 +0200 | [diff] [blame] | 4 | * (C) 2018-2019 by Harald Welte <laforge@gnumonks.org> |
Harald Welte | 1490695 | 2019-05-27 09:19:49 +0200 | [diff] [blame] | 5 | * contributions by Vadim Yanitskiy and sysmocom - s.f.m.c. GmbH |
| 6 | * All rights reserved. |
| 7 | * |
| 8 | * Released under the terms of GNU General Public License, Version 2 or |
| 9 | * (at your option) any later version. |
| 10 | * |
Harald Welte | 34b5a95 | 2019-05-27 11:54:11 +0200 | [diff] [blame] | 11 | * SPDX-License-Identifier: GPL-2.0-or-later |
| 12 | * |
Harald Welte | 1490695 | 2019-05-27 09:19:49 +0200 | [diff] [blame] | 13 | * This test suite tests OsmoBTS by attaching to the external interfaces |
| 14 | * such as Abis RSL, PCU, VTY as well as by attaching to a MS L1 implementation |
| 15 | * using the L1CTL protocol/interface. |
| 16 | * |
| 17 | * You can run the tests with |
| 18 | * a) osmo-bts-trx + trxcon + fake_trx (without any hardware) |
| 19 | * b) any osmo-bts-* + OsmocomBB layer1 + osmocon (with real BTS hardware) |
| 20 | * c) osmo-bts-virtual + virt_phy (without any hardware) |
| 21 | * |
| 22 | * Some of the tests will only run on a subset of those three configurations |
| 23 | * due to limitations in the respective L1. |
| 24 | */ |
| 25 | |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 26 | import from Misc_Helpers all; |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 27 | import from General_Types all; |
| 28 | import from GSM_Types all; |
| 29 | import from GSM_RR_Types all; |
| 30 | import from Osmocom_Types all; |
| 31 | import from GSM_Types all; |
Harald Welte | 82ccef7 | 2018-02-25 16:17:33 +0100 | [diff] [blame] | 32 | import from GSM_SystemInformation all; |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 33 | import from L1CTL_PortType all; |
| 34 | import from L1CTL_Types all; |
| 35 | import from LAPDm_Types all; |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 36 | import from LAPDm_RAW_PT all; |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 37 | import from Osmocom_CTRL_Adapter all; |
Neels Hofmeyr | 6a84b23 | 2018-04-03 19:12:36 +0200 | [diff] [blame] | 38 | import from Osmocom_CTRL_Functions all; |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 39 | |
| 40 | import from RSL_Types all; |
Harald Welte | 7484fc4 | 2018-02-24 14:09:45 +0100 | [diff] [blame] | 41 | import from IPA_Types all; |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 42 | import from IPA_Emulation all; |
Stefan Sperling | 0ec1c26 | 2018-10-15 15:12:52 +0200 | [diff] [blame] | 43 | import from IPA_Testing all; |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 44 | import from RSL_Emulation all; |
| 45 | |
| 46 | import from IPL4asp_Types all; |
| 47 | import from TRXC_Types all; |
| 48 | import from TRXC_CodecPort all; |
| 49 | import from TRXC_CodecPort_CtrlFunct all; |
| 50 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 51 | import from PCUIF_Types all; |
| 52 | import from PCUIF_CodecPort all; |
Harald Welte | a2e0e94 | 2019-05-27 18:12:53 +0200 | [diff] [blame] | 53 | import from UD_Types all; |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 54 | |
Harald Welte | 7484fc4 | 2018-02-24 14:09:45 +0100 | [diff] [blame] | 55 | import from MobileL3_CommonIE_Types all; |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 56 | import from MobileL3_RRM_Types all; |
| 57 | import from MobileL3_Types all; |
| 58 | import from L3_Templates all; |
Harald Welte | eaa9a86 | 2019-05-26 23:01:08 +0200 | [diff] [blame] | 59 | import from L3_Common all; |
| 60 | import from MobileL3_GMM_SM_Types all; |
Harald Welte | 7484fc4 | 2018-02-24 14:09:45 +0100 | [diff] [blame] | 61 | |
Harald Welte | 8da4824 | 2018-02-27 20:41:32 +0100 | [diff] [blame] | 62 | import from Osmocom_VTY_Functions all; |
| 63 | import from TELNETasp_PortType all; |
Harald Welte | 2f2b2b7 | 2019-05-31 22:24:57 +0200 | [diff] [blame] | 64 | import from BTS_Tests_LAPDm all; |
Harald Welte | 8da4824 | 2018-02-27 20:41:32 +0100 | [diff] [blame] | 65 | |
Harald Welte | 505cf9b | 2018-09-15 17:47:23 +0300 | [diff] [blame] | 66 | friend module BTS_Tests_SMSCB; |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 67 | friend module BTS_Tests_virtphy; |
Harald Welte | 2f2b2b7 | 2019-05-31 22:24:57 +0200 | [diff] [blame] | 68 | friend module BTS_Tests_LAPDm; |
Harald Welte | 505cf9b | 2018-09-15 17:47:23 +0300 | [diff] [blame] | 69 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 70 | /* The tests assume a BTS with the following timeslot configuration: |
| 71 | * TS0 : Combined CCCH + SDCCH/4 |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 72 | * TS1 : TCH/F |
| 73 | * TS2 : TCH/F |
| 74 | * TS3 : TCH/F_PDCH (IPA Style) |
| 75 | * TS4 : TCH/F_TCH/H_PDCH (Osmocom Style) |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 76 | * TS5 : TCH/H |
| 77 | * TS6 : SDCCH/8 |
| 78 | * TS7 : PDCH |
| 79 | */ |
| 80 | |
| 81 | modulepar { |
| 82 | charstring mp_rsl_ip := "127.0.0.2"; |
| 83 | integer mp_rsl_port := 3003; |
| 84 | integer mp_trx0_arfcn := 871; |
Vadim Yanitskiy | 44ff214 | 2019-01-12 07:04:58 +0700 | [diff] [blame] | 85 | charstring mp_bts_trxc_ip := "127.0.0.1"; |
| 86 | integer mp_bts_trxc_port := 5701; |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 87 | charstring mp_pcu_socket := PCU_SOCK_DEFAULT; |
Neels Hofmeyr | 6a84b23 | 2018-04-03 19:12:36 +0200 | [diff] [blame] | 88 | charstring mp_ctrl_ip := "127.0.0.1"; |
| 89 | integer mp_ctrl_port := 4238; |
Harald Welte | 07bd2d2 | 2019-05-25 11:03:30 +0200 | [diff] [blame] | 90 | charstring mp_bsc_ctrl_ip := "127.0.0.1"; |
| 91 | integer mp_bsc_ctrl_port := 4249; |
Pau Espin Pedrol | 121724c | 2018-09-28 15:58:12 +0200 | [diff] [blame] | 92 | integer mp_tolerance_rxqual := 1; |
| 93 | integer mp_tolerance_rxlev := 3; |
| 94 | integer mp_tolerance_timing_offset_256syms := 0; |
Pau Espin Pedrol | 752ffd5 | 2018-06-07 13:55:45 +0200 | [diff] [blame] | 95 | integer mp_rxlev_exp := 57; |
Pau Espin Pedrol | e9571aa | 2018-10-22 17:13:07 +0200 | [diff] [blame] | 96 | integer mp_ul_rxlev_exp := 10; |
Pau Espin Pedrol | ed359cb | 2018-09-28 16:08:24 +0200 | [diff] [blame] | 97 | integer mp_ms_power_level_exp := 7; |
Pau Espin Pedrol | 121724c | 2018-09-28 15:58:12 +0200 | [diff] [blame] | 98 | integer mp_ms_actual_ta_exp := 0; |
| 99 | integer mp_timing_offset_256syms_exp := 512; |
Pau Espin Pedrol | 315e471 | 2018-11-01 16:27:07 +0100 | [diff] [blame] | 100 | /* Time to wait for RSL conn from BTS during startup of test */ |
Philipp Maier | 12567e4 | 2019-04-17 14:10:05 +0200 | [diff] [blame] | 101 | float mp_ipa_up_timeout := 15.0; |
Philipp Maier | e63229e | 2019-04-26 12:21:37 +0200 | [diff] [blame] | 102 | float mp_ipa_up_delay := 0.0; |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 103 | /* false for now, as only virtphy supports it, not calypso-l1 nor trxcon */ |
| 104 | boolean mp_l1_supports_gprs := false; |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 105 | } |
| 106 | |
Harald Welte | 629cc6b | 2018-03-11 17:19:05 +0100 | [diff] [blame] | 107 | type record of RslChannelNr ChannelNrs; |
| 108 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 109 | type component test_CT extends CTRL_Adapter_CT { |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 110 | /* IPA Emulation component underneath RSL */ |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 111 | var IPA_Emulation_CT vc_IPA; |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 112 | /* RSL Emulation component (for ConnHdlr tests) */ |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 113 | var RSL_Emulation_CT vc_RSL; |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 114 | /* Direct RSL_CCHAN_PT */ |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 115 | port RSL_CCHAN_PT RSL_CCHAN; |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 116 | |
| 117 | /* L1CTL port (for classic tests) */ |
| 118 | port L1CTL_PT L1CTL; |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 119 | |
Vadim Yanitskiy | f4e997c | 2019-06-04 21:40:33 +0700 | [diff] [blame] | 120 | /* Optional TRXC connection to FakeTRX (BTS side) */ |
Vadim Yanitskiy | 44ff214 | 2019-01-12 07:04:58 +0700 | [diff] [blame] | 121 | port TRXC_CODEC_PT BTS_TRXC; |
| 122 | var integer g_bts_trxc_conn_id; |
Harald Welte | 54a2a2d | 2018-02-26 09:14:05 +0100 | [diff] [blame] | 123 | |
Harald Welte | f50e3ae | 2018-09-10 10:27:56 +0200 | [diff] [blame] | 124 | /* VTY connections to both BTS and BSC */ |
Harald Welte | 8da4824 | 2018-02-27 20:41:32 +0100 | [diff] [blame] | 125 | port TELNETasp_PT BTSVTY; |
Harald Welte | f50e3ae | 2018-09-10 10:27:56 +0200 | [diff] [blame] | 126 | port TELNETasp_PT BSCVTY; |
Harald Welte | 8da4824 | 2018-02-27 20:41:32 +0100 | [diff] [blame] | 127 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 128 | /* PCU Interface of BTS */ |
| 129 | port PCUIF_CODEC_PT PCU; |
| 130 | var integer g_pcu_conn_id; |
| 131 | /* Last PCU INFO IND we received */ |
| 132 | var PCUIF_Message g_pcu_last_info; |
| 133 | |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 134 | /* SI configuration */ |
| 135 | var SystemInformationConfig si_cfg := { |
| 136 | bcch_extended := false, |
| 137 | si1_present := false, |
| 138 | si2bis_present := false, |
| 139 | si2ter_present := false, |
| 140 | si2quater_present := false, |
| 141 | si7_present := false, |
| 142 | si8_present := false, |
| 143 | si9_present := false, |
| 144 | si13_present := false, |
| 145 | si13alt_present := false, |
| 146 | si15_present := false, |
| 147 | si16_present := false, |
| 148 | si17_present := false, |
| 149 | si2n_present := false, |
| 150 | si21_present := false, |
| 151 | si22_present := false |
| 152 | }; |
Harald Welte | 629cc6b | 2018-03-11 17:19:05 +0100 | [diff] [blame] | 153 | |
| 154 | /* all logical channels available on the BTS */ |
| 155 | var ChannelNrs g_AllChannels; |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 156 | var ChannelNrs g_AllChanTypes; |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 157 | } |
| 158 | |
| 159 | /* an individual call / channel */ |
Harald Welte | 2f2b2b7 | 2019-05-31 22:24:57 +0200 | [diff] [blame] | 160 | type component ConnHdlr extends RSL_DchanHdlr, lapdm_test_CT { |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 161 | port L1CTL_PT L1CTL; |
| 162 | |
Vadim Yanitskiy | f4e997c | 2019-06-04 21:40:33 +0700 | [diff] [blame] | 163 | /* Optional TRXC connection to FakeTRX (BTS side) */ |
Vadim Yanitskiy | 44ff214 | 2019-01-12 07:04:58 +0700 | [diff] [blame] | 164 | port TRXC_CODEC_PT BTS_TRXC; |
| 165 | var integer g_bts_trxc_conn_id; |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 166 | |
| 167 | timer g_Tguard; |
| 168 | timer g_Tmeas_exp := 2.0; /* >= 103 SACCH multiframe ~ 500ms */ |
| 169 | |
| 170 | var ConnHdlrPars g_pars; |
| 171 | var uint8_t g_next_meas_res_nr := 0; |
Harald Welte | fa45e9e | 2018-03-10 18:59:03 +0100 | [diff] [blame] | 172 | var boolean g_first_meas_res := true; |
Harald Welte | f26de0b | 2018-04-04 20:28:05 +0200 | [diff] [blame] | 173 | |
| 174 | /* PCU Interface of BTS */ |
| 175 | port PCUIF_CODEC_PT PCU; |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 176 | } |
| 177 | |
| 178 | function f_init_rsl(charstring id) runs on test_CT { |
| 179 | vc_IPA := IPA_Emulation_CT.create(id & "-RSL-IPA"); |
| 180 | vc_RSL := RSL_Emulation_CT.create(id & "-RSL"); |
| 181 | |
| 182 | map(vc_IPA:IPA_PORT, system:IPA_CODEC_PT); |
| 183 | connect(vc_IPA:IPA_RSL_PORT, vc_RSL:IPA_PT); |
| 184 | connect(self:RSL_CCHAN, vc_RSL:CCHAN_PT); |
| 185 | |
| 186 | vc_IPA.start(IPA_Emulation.main_server(mp_rsl_ip, mp_rsl_port)); |
| 187 | vc_RSL.start(RSL_Emulation.main(false)); |
| 188 | } |
| 189 | |
| 190 | type record ConnHdlrPars { |
| 191 | RslChannelNr chan_nr, |
| 192 | RSL_IE_ChannelMode chan_mode, |
| 193 | float t_guard, |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 194 | ConnL1Pars l1_pars, |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 195 | TestSpecUnion spec optional, |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 196 | RSL_IE_EncryptionInfo encr optional, |
| 197 | BtsBand bts0_band optional |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 198 | } |
| 199 | |
| 200 | /* Test-specific parameters */ |
| 201 | type union TestSpecUnion { |
| 202 | RllTestCase rll |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 203 | } |
| 204 | |
Harald Welte | 82ccef7 | 2018-02-25 16:17:33 +0100 | [diff] [blame] | 205 | template (value) RachControlParameters ts_RachCtrl_default := { |
Harald Welte | 0fd1fb0 | 2018-03-10 17:19:50 +0100 | [diff] [blame] | 206 | max_retrans := RACH_MAX_RETRANS_7, |
| 207 | tx_integer := '1001'B, /* 12 slots */ |
Harald Welte | 82ccef7 | 2018-02-25 16:17:33 +0100 | [diff] [blame] | 208 | cell_barr_access := false, |
| 209 | re_not_allowed := true, |
Harald Welte | b9585f8 | 2018-03-10 17:18:47 +0100 | [diff] [blame] | 210 | acc := '0000010000000000'B |
Harald Welte | 82ccef7 | 2018-02-25 16:17:33 +0100 | [diff] [blame] | 211 | }; |
| 212 | |
Harald Welte | f10153f | 2018-02-25 16:34:05 +0100 | [diff] [blame] | 213 | template (value) CellSelectionParameters ts_CellSelPar_default := { |
Harald Welte | 0fd1fb0 | 2018-03-10 17:19:50 +0100 | [diff] [blame] | 214 | cell_resel_hyst_2dB := 2, |
Pau Espin Pedrol | ed359cb | 2018-09-28 16:08:24 +0200 | [diff] [blame] | 215 | ms_txpwr_max_cch := mp_ms_power_level_exp, |
Harald Welte | f10153f | 2018-02-25 16:34:05 +0100 | [diff] [blame] | 216 | acs := '0'B, |
| 217 | neci := true, |
| 218 | rxlev_access_min := 0 |
| 219 | } |
| 220 | |
| 221 | template (value) LocationAreaIdentification ts_LAI_default := { |
| 222 | mcc_mnc := '262F42'H, |
| 223 | lac := 42 |
| 224 | } |
| 225 | |
Harald Welte | 7484fc4 | 2018-02-24 14:09:45 +0100 | [diff] [blame] | 226 | /* Default SYSTEM INFORMATION 3 */ |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 227 | template (value) SystemInformation ts_SI3_default := { |
| 228 | header := ts_RrHeader(SYSTEM_INFORMATION_TYPE_3, 18), |
Harald Welte | 7484fc4 | 2018-02-24 14:09:45 +0100 | [diff] [blame] | 229 | payload := { |
| 230 | si3 := { |
| 231 | cell_id := 23, |
Harald Welte | f10153f | 2018-02-25 16:34:05 +0100 | [diff] [blame] | 232 | lai := ts_LAI_default, |
Harald Welte | 7484fc4 | 2018-02-24 14:09:45 +0100 | [diff] [blame] | 233 | ctrl_chan_desc := { |
| 234 | msc_r99 := true, |
| 235 | att := true, |
| 236 | bs_ag_blks_res := 1, |
| 237 | ccch_conf := CCHAN_DESC_1CCCH_COMBINED, |
Harald Welte | 82ccef7 | 2018-02-25 16:17:33 +0100 | [diff] [blame] | 238 | si22ind := false, |
Harald Welte | 7484fc4 | 2018-02-24 14:09:45 +0100 | [diff] [blame] | 239 | cbq3 := CBQ3_IU_MODE_NOT_SUPPORTED, |
| 240 | spare := '00'B, |
| 241 | bs_pa_mfrms := 0, /* 2 multiframes */ |
| 242 | t3212 := 1 /* 6 minutes */ |
| 243 | }, |
Harald Welte | 82ccef7 | 2018-02-25 16:17:33 +0100 | [diff] [blame] | 244 | cell_options := { |
Harald Welte | 7484fc4 | 2018-02-24 14:09:45 +0100 | [diff] [blame] | 245 | dn_ind := false, |
| 246 | pwrc := false, |
| 247 | dtx := MS_MAY_USE_UL_DTX, |
Harald Welte | 0fd1fb0 | 2018-03-10 17:19:50 +0100 | [diff] [blame] | 248 | radio_link_tout_div4 := (32/4)-1 |
Harald Welte | 7484fc4 | 2018-02-24 14:09:45 +0100 | [diff] [blame] | 249 | }, |
Harald Welte | f10153f | 2018-02-25 16:34:05 +0100 | [diff] [blame] | 250 | cell_sel_par := ts_CellSelPar_default, |
Harald Welte | 82ccef7 | 2018-02-25 16:17:33 +0100 | [diff] [blame] | 251 | rach_control := ts_RachCtrl_default, |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 252 | rest_octets := '2C2B2B2B'O /* GPRS present */ |
Harald Welte | 7484fc4 | 2018-02-24 14:09:45 +0100 | [diff] [blame] | 253 | } |
| 254 | } |
| 255 | } |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 256 | |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 257 | template (value) SystemInformation ts_SI2_default := { |
| 258 | header := ts_RrHeader(SYSTEM_INFORMATION_TYPE_2, 22), |
Harald Welte | f10153f | 2018-02-25 16:34:05 +0100 | [diff] [blame] | 259 | payload := { |
| 260 | si2 := { |
| 261 | bcch_freq_list := '00000000000000000000000000000000'O, |
| 262 | ncc_permitted := '11111111'B, |
| 263 | rach_control := ts_RachCtrl_default |
| 264 | } |
| 265 | } |
| 266 | } |
| 267 | |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 268 | template (value) SystemInformation ts_SI4_default := { |
| 269 | header := ts_RrHeader(SYSTEM_INFORMATION_TYPE_4, 12), /* no CBCH / restoct */ |
Harald Welte | f10153f | 2018-02-25 16:34:05 +0100 | [diff] [blame] | 270 | payload := { |
| 271 | si4 := { |
| 272 | lai := ts_LAI_default, |
| 273 | cell_sel_par := ts_CellSelPar_default, |
| 274 | rach_control := ts_RachCtrl_default, |
| 275 | cbch_chan_desc := omit, |
| 276 | cbch_mobile_alloc := omit, |
| 277 | rest_octets := ''O |
| 278 | } |
| 279 | } |
| 280 | } |
| 281 | |
| 282 | function f_rsl_bcch_fill_raw(RSL_IE_SysinfoType rsl_si_type, octetstring si_enc) |
| 283 | runs on test_CT { |
| 284 | log("Setting ", rsl_si_type, ": ", si_enc); |
| 285 | RSL_CCHAN.send(ts_RSL_UD(ts_RSL_BCCH_INFO(rsl_si_type, si_enc))); |
| 286 | } |
| 287 | |
| 288 | function f_rsl_bcch_fill(RSL_IE_SysinfoType rsl_si_type, template (value) SystemInformation si_dec) |
| 289 | runs on test_CT { |
| 290 | var octetstring si_enc := enc_SystemInformation(valueof(si_dec)); |
| 291 | log("Setting ", rsl_si_type, ": ", si_dec); |
| 292 | f_rsl_bcch_fill_raw(rsl_si_type, si_enc); |
| 293 | } |
| 294 | |
Harald Welte | 505cf9b | 2018-09-15 17:47:23 +0300 | [diff] [blame] | 295 | friend function f_init_vty(charstring id) runs on test_CT { |
Harald Welte | 8da4824 | 2018-02-27 20:41:32 +0100 | [diff] [blame] | 296 | map(self:BTSVTY, system:BTSVTY); |
| 297 | f_vty_set_prompts(BTSVTY); |
| 298 | f_vty_transceive(BTSVTY, "enable"); |
| 299 | } |
| 300 | |
Harald Welte | 505cf9b | 2018-09-15 17:47:23 +0300 | [diff] [blame] | 301 | friend function f_init_vty_bsc() runs on test_CT { |
Harald Welte | f50e3ae | 2018-09-10 10:27:56 +0200 | [diff] [blame] | 302 | map(self:BSCVTY, system:BSCVTY); |
| 303 | f_vty_set_prompts(BSCVTY, "OsmoBSC"); |
| 304 | f_vty_transceive(BSCVTY, "enable"); |
| 305 | } |
| 306 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 307 | /* PCU socket may at any time receive a new INFO.ind */ |
Harald Welte | f26de0b | 2018-04-04 20:28:05 +0200 | [diff] [blame] | 308 | private altstep as_pcu_info_ind(PCUIF_CODEC_PT pt, integer pcu_conn_id, |
| 309 | out PCUIF_Message pcu_last_info) { |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 310 | var PCUIF_send_data sd; |
Harald Welte | f26de0b | 2018-04-04 20:28:05 +0200 | [diff] [blame] | 311 | [] pt.receive(t_SD_PCUIF(pcu_conn_id, tr_PCUIF_INFO_IND(0, ?))) -> value sd { |
| 312 | pcu_last_info := sd.data; |
Harald Welte | d378a25 | 2018-03-13 17:02:14 +0100 | [diff] [blame] | 313 | } |
Harald Welte | f26de0b | 2018-04-04 20:28:05 +0200 | [diff] [blame] | 314 | [] 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] | 315 | 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] | 316 | } |
| 317 | } |
| 318 | |
Harald Welte | f26de0b | 2018-04-04 20:28:05 +0200 | [diff] [blame] | 319 | private function f_init_pcu(PCUIF_CODEC_PT pt, charstring id, |
| 320 | out integer pcu_conn_id, out PCUIF_Message pcu_last_info) { |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 321 | timer T := 2.0; |
| 322 | var PCUIF_send_data sd; |
Harald Welte | 8427162 | 2018-03-10 17:21:03 +0100 | [diff] [blame] | 323 | if (mp_pcu_socket == "") { |
Harald Welte | f26de0b | 2018-04-04 20:28:05 +0200 | [diff] [blame] | 324 | pcu_conn_id := -1; |
Harald Welte | 8427162 | 2018-03-10 17:21:03 +0100 | [diff] [blame] | 325 | return; |
| 326 | } |
Harald Welte | f26de0b | 2018-04-04 20:28:05 +0200 | [diff] [blame] | 327 | pcu_conn_id := f_pcuif_connect(pt, mp_pcu_socket); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 328 | |
| 329 | T.start; |
| 330 | alt { |
Harald Welte | f26de0b | 2018-04-04 20:28:05 +0200 | [diff] [blame] | 331 | [] as_pcu_info_ind(pt, pcu_conn_id, pcu_last_info); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 332 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 333 | 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] | 334 | } |
| 335 | } |
| 336 | } |
| 337 | |
Vadim Yanitskiy | f4e997c | 2019-06-04 21:40:33 +0700 | [diff] [blame] | 338 | private function f_init_trxc(TRXC_CODEC_PT pt, charstring id, |
| 339 | out integer trxc_conn_id) { |
| 340 | var Result res; |
| 341 | |
| 342 | res := TRXC_CodecPort_CtrlFunct.f_IPL4_connect(pt, mp_bts_trxc_ip, mp_bts_trxc_port, |
| 343 | "", -1, -1, { udp := {} }, {}); |
| 344 | if (not ispresent(res.connId)) { |
| 345 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 346 | "Could not connect to the control (TRXC) interface " & |
| 347 | "of FakeTRX, check your configuration"); |
| 348 | } |
| 349 | trxc_conn_id := res.connId; |
| 350 | } |
| 351 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 352 | /* global init function */ |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 353 | function f_init() runs on test_CT { |
| 354 | var charstring id := testcasename(); |
Pau Espin Pedrol | 315e471 | 2018-11-01 16:27:07 +0100 | [diff] [blame] | 355 | timer T := mp_ipa_up_timeout; |
Harald Welte | 629cc6b | 2018-03-11 17:19:05 +0100 | [diff] [blame] | 356 | g_AllChannels := { |
| 357 | /* TS 1..4: TCH/F */ |
| 358 | valueof(ts_RslChanNr_Bm(1)), valueof(ts_RslChanNr_Bm(2)), |
| 359 | valueof(ts_RslChanNr_Bm(3)), valueof(ts_RslChanNr_Bm(4)), |
| 360 | /* TS 5: TCH/H */ |
| 361 | valueof(ts_RslChanNr_Lm(5,0)), valueof(ts_RslChanNr_Lm(5,1)), |
| 362 | /* TS 0: SDCCH/4 */ |
| 363 | valueof(ts_RslChanNr_SDCCH4(0,0)), valueof(ts_RslChanNr_SDCCH4(0,1)), |
| 364 | valueof(ts_RslChanNr_SDCCH4(0,2)), valueof(ts_RslChanNr_SDCCH4(0,3)), |
| 365 | /* TS 6: SDCCH/8 */ |
| 366 | valueof(ts_RslChanNr_SDCCH8(6,0)), valueof(ts_RslChanNr_SDCCH8(6,1)), |
| 367 | valueof(ts_RslChanNr_SDCCH8(6,2)), valueof(ts_RslChanNr_SDCCH8(6,3)), |
| 368 | valueof(ts_RslChanNr_SDCCH8(6,4)), valueof(ts_RslChanNr_SDCCH8(6,5)), |
| 369 | valueof(ts_RslChanNr_SDCCH8(6,6)), valueof(ts_RslChanNr_SDCCH8(6,7)) |
| 370 | }; |
| 371 | |
Pau Espin Pedrol | 3dcf38f | 2018-10-22 14:07:54 +0200 | [diff] [blame] | 372 | /* FIXME: FACCH/H is unreliable with calypso firmware, see OS#3653 */ |
Vadim Yanitskiy | 44ff214 | 2019-01-12 07:04:58 +0700 | [diff] [blame] | 373 | if (mp_bts_trxc_port != -1) { |
Pau Espin Pedrol | 3dcf38f | 2018-10-22 14:07:54 +0200 | [diff] [blame] | 374 | g_AllChanTypes := { |
| 375 | /* TS 1..4: TCH/F */ |
| 376 | valueof(ts_RslChanNr_Bm(1)), |
| 377 | /* TS 5: TCH/H */ |
| 378 | valueof(ts_RslChanNr_Lm(5,1)), |
| 379 | /* TS 0: SDCCH/4 */ |
| 380 | valueof(ts_RslChanNr_SDCCH4(0,2)), |
| 381 | /* TS 6: SDCCH/8 */ |
| 382 | valueof(ts_RslChanNr_SDCCH8(6,4)) |
| 383 | }; |
| 384 | } else { |
| 385 | g_AllChanTypes := { |
| 386 | /* TS 1..4: TCH/F */ |
| 387 | valueof(ts_RslChanNr_Bm(1)), |
| 388 | /* TS 0: SDCCH/4 */ |
| 389 | valueof(ts_RslChanNr_SDCCH4(0,2)), |
| 390 | /* TS 6: SDCCH/8 */ |
| 391 | valueof(ts_RslChanNr_SDCCH8(6,4)) |
| 392 | }; |
| 393 | } |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 394 | f_init_rsl(id); |
Harald Welte | 83f6dbf | 2018-06-03 18:26:50 +0200 | [diff] [blame] | 395 | T.start; |
| 396 | alt { |
| 397 | [] RSL_CCHAN.receive(ASP_IPA_Event:{up_down := ASP_IPA_EVENT_UP}); |
| 398 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 399 | 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] | 400 | } |
| 401 | } |
Harald Welte | 2d14259 | 2018-02-25 13:19:44 +0100 | [diff] [blame] | 402 | f_sleep(0.5); /* workaround for OS#3000 */ |
Harald Welte | 8da4824 | 2018-02-27 20:41:32 +0100 | [diff] [blame] | 403 | f_init_vty(id); |
Neels Hofmeyr | 6a84b23 | 2018-04-03 19:12:36 +0200 | [diff] [blame] | 404 | f_ipa_ctrl_start(mp_ctrl_ip, mp_ctrl_port); |
Harald Welte | 7484fc4 | 2018-02-24 14:09:45 +0100 | [diff] [blame] | 405 | |
| 406 | /* Send SI3 to the BTS, it is needed for various computations */ |
Harald Welte | f10153f | 2018-02-25 16:34:05 +0100 | [diff] [blame] | 407 | f_rsl_bcch_fill(RSL_SYSTEM_INFO_3, ts_SI3_default); |
| 408 | /* SI2 + SI4 are required for SI testing as they are mandatory defaults */ |
| 409 | f_rsl_bcch_fill(RSL_SYSTEM_INFO_2, ts_SI2_default); |
| 410 | f_rsl_bcch_fill(RSL_SYSTEM_INFO_4, ts_SI4_default); |
Harald Welte | 57fe823 | 2018-02-26 17:52:50 +0100 | [diff] [blame] | 411 | |
Harald Welte | f26de0b | 2018-04-04 20:28:05 +0200 | [diff] [blame] | 412 | map(self:PCU, system:PCU); |
| 413 | 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] | 414 | |
Vadim Yanitskiy | 44ff214 | 2019-01-12 07:04:58 +0700 | [diff] [blame] | 415 | if (mp_bts_trxc_port != -1) { |
Harald Welte | 8427162 | 2018-03-10 17:21:03 +0100 | [diff] [blame] | 416 | var TrxcMessage ret; |
Vadim Yanitskiy | f4e997c | 2019-06-04 21:40:33 +0700 | [diff] [blame] | 417 | |
| 418 | /* Init TRXC interface to FakeTRX */ |
| 419 | map(self:BTS_TRXC, system:BTS_TRXC); |
| 420 | f_init_trxc(BTS_TRXC, id, g_bts_trxc_conn_id); |
| 421 | |
Vadim Yanitskiy | 10d7246 | 2019-06-04 22:27:52 +0700 | [diff] [blame] | 422 | /* Start with a default moderate timing offset equalling TA=2, and RSSI=-60 */ |
Vadim Yanitskiy | 44ff214 | 2019-01-12 07:04:58 +0700 | [diff] [blame] | 423 | ret := f_TRXC_transceive(BTS_TRXC, g_bts_trxc_conn_id, valueof(ts_TRXC_FAKE_TIMING(2*256))); |
Vadim Yanitskiy | 10d7246 | 2019-06-04 22:27:52 +0700 | [diff] [blame] | 424 | ret := f_TRXC_transceive(BTS_TRXC, g_bts_trxc_conn_id, valueof(ts_TRXC_FAKE_RSSI(-60))); |
Vadim Yanitskiy | de535e0 | 2019-07-26 16:29:27 +0700 | [diff] [blame] | 425 | /* OsmoBTS may have different AB / NB threshold (see MIN_QUAL_NORM, MIN_QUAL_RACH) */ |
| 426 | ret := f_TRXC_transceive(BTS_TRXC, g_bts_trxc_conn_id, valueof(ts_TRXC_FAKE_CI(60))); |
Harald Welte | 8427162 | 2018-03-10 17:21:03 +0100 | [diff] [blame] | 427 | } |
Philipp Maier | d95f340 | 2019-04-18 17:50:52 +0200 | [diff] [blame] | 428 | |
| 429 | /* Wait some extra time to make sure the BTS emits a stable carrier. |
| 430 | * (this is only relevant when running the tests with a physical BTS.) */ |
| 431 | f_sleep(mp_ipa_up_delay); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 432 | } |
| 433 | |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 434 | /* Attach L1CTL to master test_CT (classic tests, non-handler mode) */ |
| 435 | function f_init_l1ctl() runs on test_CT { |
| 436 | map(self:L1CTL, system:L1CTL); |
| 437 | f_connect_reset(L1CTL); |
| 438 | } |
| 439 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 440 | type function void_fn(charstring id) runs on ConnHdlr; |
| 441 | |
| 442 | /* create a new test component */ |
Vadim Yanitskiy | f4e997c | 2019-06-04 21:40:33 +0700 | [diff] [blame] | 443 | function f_start_handler(void_fn fn, ConnHdlrPars pars, |
| 444 | boolean pcu_comp := false, |
| 445 | boolean trxc_comp := false) |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 446 | runs on test_CT return ConnHdlr { |
| 447 | var charstring id := testcasename(); |
| 448 | var ConnHdlr vc_conn; |
| 449 | |
| 450 | vc_conn := ConnHdlr.create(id); |
| 451 | /* connect to RSL Emulation main component */ |
| 452 | connect(vc_conn:RSL, vc_RSL:CLIENT_PT); |
| 453 | connect(vc_conn:RSL_PROC, vc_RSL:RSL_PROC); |
Vadim Yanitskiy | f4e997c | 2019-06-04 21:40:33 +0700 | [diff] [blame] | 454 | |
| 455 | /* The ConnHdlr component may want to talk to some ports directly, |
| 456 | * so we disconnect it from the test_CT and connect it to the component. |
| 457 | * This obviously only works for one component, i.e. no concurrency. */ |
Harald Welte | f26de0b | 2018-04-04 20:28:05 +0200 | [diff] [blame] | 458 | if (pcu_comp) { |
Harald Welte | f26de0b | 2018-04-04 20:28:05 +0200 | [diff] [blame] | 459 | unmap(self:PCU, system:PCU); |
| 460 | map(vc_conn:PCU, system:PCU); |
| 461 | } |
Vadim Yanitskiy | f4e997c | 2019-06-04 21:40:33 +0700 | [diff] [blame] | 462 | if (trxc_comp) { |
| 463 | unmap(self:BTS_TRXC, system:BTS_TRXC); |
| 464 | map(vc_conn:BTS_TRXC, system:BTS_TRXC); |
| 465 | } |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 466 | |
| 467 | vc_conn.start(f_handler_init(fn, id, pars)); |
| 468 | return vc_conn; |
| 469 | } |
| 470 | |
Harald Welte | 7484fc4 | 2018-02-24 14:09:45 +0100 | [diff] [blame] | 471 | template ASP_RSL_Unitdata ts_RSL_UD(template RSL_Message rsl, IpaStreamId sid := IPAC_PROTO_RSL_TRX0) := { |
| 472 | streamId := sid, |
| 473 | rsl := rsl |
| 474 | } |
| 475 | |
| 476 | template ASP_RSL_Unitdata tr_RSL_UD(template RSL_Message rsl, |
| 477 | template IpaStreamId sid := IPAC_PROTO_RSL_TRX0) := { |
| 478 | streamId := sid, |
| 479 | rsl := rsl |
| 480 | } |
| 481 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 482 | private altstep as_Tguard() runs on ConnHdlr { |
| 483 | [] g_Tguard.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 484 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Tguard timeout"); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 485 | } |
| 486 | } |
| 487 | |
Harald Welte | 990a361 | 2019-05-27 14:02:13 +0200 | [diff] [blame] | 488 | friend function f_l1_tune(L1CTL_PT L1CTL, L1ctlCcchMode ccch_mode := CCCH_MODE_COMBINED) { |
| 489 | f_L1CTL_FBSB(L1CTL, { false, mp_trx0_arfcn }, ccch_mode, mp_rxlev_exp); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 490 | } |
| 491 | |
Vadim Yanitskiy | 2f01fbd | 2019-06-01 01:32:48 +0700 | [diff] [blame] | 492 | private function f_trxc_fake_rssi(TRXC_RSSI rssi) runs on ConnHdlr { |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 493 | var TrxcMessage ret; |
Vadim Yanitskiy | 44ff214 | 2019-01-12 07:04:58 +0700 | [diff] [blame] | 494 | ret := f_TRXC_transceive(BTS_TRXC, g_bts_trxc_conn_id, valueof(ts_TRXC_FAKE_RSSI(rssi))); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 495 | } |
| 496 | |
Vadim Yanitskiy | dc8db92 | 2019-06-04 21:58:15 +0700 | [diff] [blame] | 497 | private function f_trxc_fake_toffs256(int16_t toffs256) runs on ConnHdlr { |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 498 | var TrxcMessage ret; |
Vadim Yanitskiy | 44ff214 | 2019-01-12 07:04:58 +0700 | [diff] [blame] | 499 | ret := f_TRXC_transceive(BTS_TRXC, g_bts_trxc_conn_id, valueof(ts_TRXC_FAKE_TIMING(toffs256))); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 500 | } |
| 501 | |
| 502 | /* first function started in ConnHdlr component */ |
| 503 | private function f_handler_init(void_fn fn, charstring id, ConnHdlrPars pars) |
| 504 | runs on ConnHdlr { |
| 505 | g_pars := pars; |
| 506 | g_chan_nr := pars.chan_nr; |
| 507 | |
| 508 | map(self:L1CTL, system:L1CTL); |
| 509 | f_connect_reset(L1CTL); |
| 510 | |
Harald Welte | d48c0c7 | 2019-06-05 10:01:15 +0200 | [diff] [blame] | 511 | if (mp_bts_trxc_port != -1 and BTS_TRXC.checkstate("Mapped")) { |
Vadim Yanitskiy | f4e997c | 2019-06-04 21:40:33 +0700 | [diff] [blame] | 512 | f_init_trxc(BTS_TRXC, id, g_bts_trxc_conn_id); |
Harald Welte | 8427162 | 2018-03-10 17:21:03 +0100 | [diff] [blame] | 513 | } |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 514 | |
| 515 | g_Tguard.start(pars.t_guard); |
| 516 | activate(as_Tguard()); |
| 517 | |
| 518 | f_rslem_register(0, pars.chan_nr); |
| 519 | |
| 520 | /* call the user-supplied test case function */ |
| 521 | fn.apply(id); |
| 522 | } |
| 523 | |
Harald Welte | b1726c9 | 2018-03-30 11:56:38 +0200 | [diff] [blame] | 524 | function f_rsl_transceive_ret(template RSL_Message tx, template RSL_Message exp_rx, charstring id, |
| 525 | boolean ignore_other := false) |
| 526 | runs on ConnHdlr return RSL_Message { |
| 527 | var RSL_Message rx; |
Harald Welte | 1eba374 | 2018-02-25 12:48:14 +0100 | [diff] [blame] | 528 | timer T := 3.0; |
| 529 | RSL.send(tx); |
| 530 | T.start; |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 531 | alt { |
Harald Welte | b1726c9 | 2018-03-30 11:56:38 +0200 | [diff] [blame] | 532 | [] RSL.receive(exp_rx) -> value rx { |
Harald Welte | 1eba374 | 2018-02-25 12:48:14 +0100 | [diff] [blame] | 533 | T.stop; |
| 534 | setverdict(pass); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 535 | } |
Harald Welte | 1eba374 | 2018-02-25 12:48:14 +0100 | [diff] [blame] | 536 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 537 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout expecting " & id); |
Harald Welte | 1eba374 | 2018-02-25 12:48:14 +0100 | [diff] [blame] | 538 | } |
Harald Welte | 21240e6 | 2018-03-11 21:43:35 +0100 | [diff] [blame] | 539 | [not ignore_other] as_l1_sacch(); |
| 540 | [not ignore_other] as_meas_res(); |
| 541 | [not ignore_other] as_l1_dcch(); |
| 542 | [not ignore_other] RSL.receive { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 543 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected RSL message received"); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 544 | } |
Harald Welte | 21240e6 | 2018-03-11 21:43:35 +0100 | [diff] [blame] | 545 | [ignore_other] RSL.receive { repeat; } |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 546 | } |
Harald Welte | b1726c9 | 2018-03-30 11:56:38 +0200 | [diff] [blame] | 547 | return rx; |
| 548 | } |
| 549 | |
| 550 | function f_rsl_transceive(template RSL_Message tx, template RSL_Message exp_rx, charstring id, |
| 551 | boolean ignore_other := false) |
| 552 | runs on ConnHdlr { |
| 553 | 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] | 554 | } |
| 555 | |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 556 | function f_rsl_chan_act(RSL_IE_ChannelMode mode, boolean encr_enable := false, RSL_IE_List more_ies := {}, |
| 557 | RSL_IE_ActivationType act_type := t_RSL_IE_ActType_IA) runs on ConnHdlr { |
| 558 | var RSL_Message ch_act := valueof(ts_RSL_CHAN_ACT(g_chan_nr, mode, act_type)); |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 559 | if (encr_enable) { |
| 560 | /* append encryption related IEs, if requested */ |
| 561 | var RSL_IE_EncryptionInfo encr_info; |
| 562 | encr_info := valueof(ts_RSL_IE_EncrInfo(g_pars.encr.alg_id, g_pars.encr.key)); |
| 563 | ch_act.ies := ch_act.ies & { valueof(t_RSL_IE(RSL_IE_ENCR_INFO, RSL_IE_Body:{encr_info := |
| 564 | encr_info})) }; |
| 565 | } |
Harald Welte | c8d363c | 2019-05-19 20:36:48 +0200 | [diff] [blame] | 566 | ch_act.ies := ch_act.ies & more_ies; |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 567 | 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] | 568 | } |
| 569 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 570 | function f_rsl_chan_deact() runs on ConnHdlr { |
Harald Welte | 1eba374 | 2018-02-25 12:48:14 +0100 | [diff] [blame] | 571 | 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] | 572 | "RF CHAN REL", true); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 573 | } |
| 574 | |
Harald Welte | 2f2b2b7 | 2019-05-31 22:24:57 +0200 | [diff] [blame] | 575 | friend template ConnHdlrPars t_Pars(template RslChannelNr chan_nr, |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 576 | template RSL_IE_ChannelMode chan_mode, |
| 577 | float t_guard := 20.0) := { |
| 578 | chan_nr := valueof(chan_nr), |
| 579 | chan_mode := valueof(chan_mode), |
| 580 | t_guard := t_guard, |
| 581 | l1_pars := { |
| 582 | dtx_enabled := false, |
Harald Welte | 685d598 | 2018-02-27 20:42:05 +0100 | [diff] [blame] | 583 | toa256_enabled := false, |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 584 | meas_ul := { |
| 585 | full := { |
Pau Espin Pedrol | e9571aa | 2018-10-22 17:13:07 +0200 | [diff] [blame] | 586 | rxlev := mp_ul_rxlev_exp, |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 587 | rxqual := 0 |
| 588 | }, |
| 589 | sub := { |
Pau Espin Pedrol | e9571aa | 2018-10-22 17:13:07 +0200 | [diff] [blame] | 590 | rxlev := mp_ul_rxlev_exp, |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 591 | rxqual := 0 |
| 592 | } |
| 593 | }, |
Pau Espin Pedrol | 121724c | 2018-09-28 15:58:12 +0200 | [diff] [blame] | 594 | timing_offset_256syms := mp_timing_offset_256syms_exp, |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 595 | bs_power_level := 0, |
Pau Espin Pedrol | ed359cb | 2018-09-28 16:08:24 +0200 | [diff] [blame] | 596 | ms_power_level := mp_ms_power_level_exp, |
Pau Espin Pedrol | 121724c | 2018-09-28 15:58:12 +0200 | [diff] [blame] | 597 | ms_actual_ta := mp_ms_actual_ta_exp |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 598 | }, |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 599 | spec := omit, |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 600 | encr := omit, |
| 601 | bts0_band := omit |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 602 | } |
| 603 | |
Harald Welte | 93640c6 | 2018-02-25 16:59:33 +0100 | [diff] [blame] | 604 | /*********************************************************************** |
| 605 | * Channel Activation / Deactivation |
| 606 | ***********************************************************************/ |
| 607 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 608 | /* Stress test: Do 500 channel activations/deactivations in rapid succession */ |
| 609 | function f_TC_chan_act_stress(charstring id) runs on ConnHdlr { |
| 610 | for (var integer i := 0; i < 500; i := i+1) { |
| 611 | f_rsl_chan_act(g_pars.chan_mode); |
| 612 | f_rsl_chan_deact(); |
| 613 | } |
| 614 | setverdict(pass); |
| 615 | } |
| 616 | testcase TC_chan_act_stress() runs on test_CT { |
| 617 | var ConnHdlr vc_conn; |
| 618 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 619 | f_init(); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 620 | vc_conn := f_start_handler(refers(f_TC_chan_act_stress), pars); |
| 621 | vc_conn.done; |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 622 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 623 | } |
| 624 | |
| 625 | /* Test if re-activation of an already active channel fails as expected */ |
| 626 | function f_TC_chan_act_react(charstring id) runs on ConnHdlr { |
| 627 | f_rsl_chan_act(g_pars.chan_mode); |
| 628 | /* attempt to activate the same lchan again -> expect reject */ |
| 629 | RSL.send(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode)); |
| 630 | alt { |
| 631 | [] RSL.receive(tr_RSL_CHAN_ACT_ACK(g_chan_nr)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 632 | 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] | 633 | } |
| 634 | [] RSL.receive(tr_RSL_CHAN_ACT_NACK(g_chan_nr)) { |
| 635 | setverdict(pass); |
| 636 | } |
| 637 | } |
| 638 | f_rsl_chan_deact(); |
| 639 | } |
| 640 | testcase TC_chan_act_react() runs on test_CT { |
| 641 | var ConnHdlr vc_conn; |
| 642 | 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] | 643 | f_init(); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 644 | vc_conn := f_start_handler(refers(f_TC_chan_act_react), pars); |
| 645 | vc_conn.done; |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 646 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 647 | } |
| 648 | |
| 649 | /* Attempt to de-activate a channel that's not active */ |
| 650 | function f_TC_chan_deact_not_active(charstring id) runs on ConnHdlr { |
| 651 | timer T := 3.0; |
| 652 | RSL.send(ts_RSL_RF_CHAN_REL(g_chan_nr)); |
| 653 | T.start; |
| 654 | alt { |
| 655 | [] RSL.receive(tr_RSL_RF_CHAN_REL_ACK(g_chan_nr)) { |
| 656 | setverdict(pass); |
| 657 | } |
| 658 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 659 | 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] | 660 | } |
| 661 | } |
| 662 | } |
| 663 | testcase TC_chan_deact_not_active() runs on test_CT { |
| 664 | 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] | 665 | f_init(); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 666 | var ConnHdlr vc_conn := f_start_handler(refers(f_TC_chan_deact_not_active), pars); |
| 667 | vc_conn.done; |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 668 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 669 | } |
| 670 | |
| 671 | /* attempt to activate channel with wrong RSL Channel Nr IE; expect NACK */ |
| 672 | function f_TC_chan_act_wrong_nr(charstring id) runs on ConnHdlr { |
| 673 | RSL.send(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode)); |
| 674 | alt { |
| 675 | [] RSL.receive(tr_RSL_CHAN_ACT_ACK(g_chan_nr)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 676 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected CHAN ACT ACK"); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 677 | } |
| 678 | [] RSL.receive(tr_RSL_CHAN_ACT_NACK(g_chan_nr)) { |
| 679 | setverdict(pass); |
| 680 | } |
| 681 | } |
| 682 | } |
| 683 | private type record WrongChanNrCase { |
| 684 | RslChannelNr chan_nr, |
| 685 | charstring description |
| 686 | } |
| 687 | private type record of WrongChanNrCase WrongChanNrCases; |
| 688 | private template WrongChanNrCase t_WCN(template RslChannelNr chan_nr, charstring desc) := { |
| 689 | chan_nr := chan_nr, |
| 690 | description := desc |
| 691 | } |
| 692 | |
| 693 | testcase TC_chan_act_wrong_nr() runs on test_CT { |
| 694 | var ConnHdlr vc_conn; |
| 695 | var ConnHdlrPars pars; |
| 696 | |
Harald Welte | 294b0a2 | 2018-03-10 23:26:48 +0100 | [diff] [blame] | 697 | f_init(); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 698 | |
| 699 | var WrongChanNrCases wrong := { |
| 700 | valueof(t_WCN(t_RslChanNr_RACH(0), "RACH is not a dedicated channel")), |
| 701 | valueof(t_WCN(t_RslChanNr_RACH(1), "RACH doesn't exist on timeslot")), |
| 702 | valueof(t_WCN(t_RslChanNr_BCCH(0), "BCCH is not a dedicated channel")), |
| 703 | valueof(t_WCN(t_RslChanNr_PCH_AGCH(0), "PCH/AGCH is not a dedicated channel")), |
| 704 | valueof(t_WCN(t_RslChanNr_Bm(0), "TS0 cannot be TCH/F")), |
| 705 | valueof(t_WCN(t_RslChanNr_Lm(0, 0), "TS0 cannot be TCH/H")), |
| 706 | valueof(t_WCN(t_RslChanNr_Lm(0, 1), "TS0 cannot be TCH/H")), |
| 707 | valueof(t_WCN(t_RslChanNr_PDCH(0), "TS0 cannot be PDCH")), |
| 708 | valueof(t_WCN(t_RslChanNr_SDCCH8(0, 0), "TS0 cannot be SDCCH/8")), |
| 709 | valueof(t_WCN(t_RslChanNr_SDCCH8(0, 7), "TS0 cannot be SDCCH/8")), |
| 710 | valueof(t_WCN(t_RslChanNr_SDCCH4(7, 0), "TS7 cannot be SDCCH/4")), |
| 711 | valueof(t_WCN(t_RslChanNr_SDCCH4(7, 3), "TS7 cannot be SDCCH/4")), |
| 712 | valueof(t_WCN(t_RslChanNr_Lm(1, 0), "TS1 cannot be TCH/H")) |
| 713 | }; |
| 714 | |
| 715 | for (var integer i := 0; i < sizeof(wrong); i := i+1) { |
| 716 | pars := valueof(t_Pars(wrong[i].chan_nr, ts_RSL_ChanMode_SIGN)); |
| 717 | vc_conn := f_start_handler(refers(f_TC_chan_act_wrong_nr), pars); |
| 718 | vc_conn.done; |
| 719 | } |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 720 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 721 | } |
| 722 | |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 723 | /* execute the same callback function on a variety of logical channels */ |
Harald Welte | 2f2b2b7 | 2019-05-31 22:24:57 +0200 | [diff] [blame] | 724 | friend function f_testmatrix_each_chan(ConnHdlrPars pars, void_fn fn) runs on test_CT { |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 725 | var ConnHdlr vc_conn; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 726 | f_init(); |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 727 | |
| 728 | /* test on each of the channels we have */ |
| 729 | for (var integer i := 0; i < sizeof(g_AllChanTypes); i := i+1) { |
| 730 | pars.chan_nr := valueof(g_AllChanTypes[i]); |
| 731 | |
| 732 | log(testcasename(), ": XXX Starting on ", g_AllChanTypes[i]); |
| 733 | vc_conn := f_start_handler(fn, pars); |
| 734 | vc_conn.done; |
| 735 | } |
| 736 | |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 737 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 738 | } |
| 739 | |
Harald Welte | 93640c6 | 2018-02-25 16:59:33 +0100 | [diff] [blame] | 740 | /*********************************************************************** |
Harald Welte | 629cc6b | 2018-03-11 17:19:05 +0100 | [diff] [blame] | 741 | * SACCH handling |
| 742 | ***********************************************************************/ |
| 743 | |
| 744 | private function f_exp_sacch(boolean exp) runs on ConnHdlr { |
| 745 | timer T_sacch := 3.0; |
| 746 | T_sacch.start; |
| 747 | alt { |
| 748 | [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] | 749 | 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] | 750 | } |
| 751 | [not exp] T_sacch.timeout { |
| 752 | setverdict(pass); |
| 753 | } |
| 754 | [exp] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(0))) { |
| 755 | setverdict(pass); |
| 756 | } |
| 757 | [exp] T_sacch.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 758 | 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] | 759 | } |
| 760 | [] L1CTL.receive { repeat; } |
| 761 | [] RSL.receive { repeat; } |
| 762 | } |
| 763 | } |
| 764 | |
| 765 | /* Test if DEACTIVATE SACCH actualy deactivates its transmission (TS 48.058 4.6) */ |
| 766 | private function f_TC_deact_sacch(charstring id) runs on ConnHdlr { |
| 767 | f_l1_tune(L1CTL); |
| 768 | RSL.clear; |
| 769 | |
| 770 | /* activate the logical channel */ |
| 771 | f_est_dchan(); |
| 772 | L1CTL.clear; |
| 773 | |
| 774 | /* check that SACCH actually are received as expected */ |
| 775 | f_exp_sacch(true); |
| 776 | |
| 777 | /* deactivate SACCH on the logical channel */ |
| 778 | RSL.send(ts_RSL_DEACT_SACCH(g_chan_nr)); |
| 779 | f_sleep(1.0); |
| 780 | L1CTL.clear; |
| 781 | |
| 782 | /* check that no SACCH are received anymore */ |
| 783 | f_exp_sacch(false); |
| 784 | |
| 785 | /* release the channel */ |
| 786 | f_rsl_chan_deact(); |
| 787 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 788 | } |
| 789 | testcase TC_deact_sacch() runs on test_CT { |
| 790 | var ConnHdlr vc_conn; |
| 791 | var ConnHdlrPars pars; |
| 792 | f_init(); |
| 793 | for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) { |
| 794 | //for (var integer i := 0; i < 1; i := i+1) { |
| 795 | pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN)); |
| 796 | log(testcasename(), ": Starting for ", g_AllChannels[i]); |
| 797 | vc_conn := f_start_handler(refers(f_TC_deact_sacch), pars); |
| 798 | vc_conn.done; |
| 799 | } |
| 800 | /* TODO: do the above in parallel, rather than sequentially? */ |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 801 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 629cc6b | 2018-03-11 17:19:05 +0100 | [diff] [blame] | 802 | } |
| 803 | |
Harald Welte | 5570066 | 2018-03-12 13:15:43 +0100 | [diff] [blame] | 804 | /* verify that given SACCH payload is present */ |
Harald Welte | ea17b91 | 2018-03-11 22:29:31 +0100 | [diff] [blame] | 805 | private function f_sacch_present(template octetstring l3_exp) runs on ConnHdlr { |
| 806 | var L1ctlDlMessage dl; |
| 807 | /* check that the specified SI5 value is actually sent */ |
| 808 | timer T_sacch := 3.0; |
| 809 | L1CTL.clear; |
| 810 | T_sacch.start; |
| 811 | alt { |
| 812 | [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(0))) -> value dl { |
| 813 | var octetstring l3 := substr(dl.payload.data_ind.payload, 4, 19); |
| 814 | if (match(l3, l3_exp)) { |
| 815 | setverdict(pass); |
| 816 | } else { |
| 817 | repeat; |
| 818 | } |
| 819 | } |
| 820 | [] L1CTL.receive { repeat; } |
| 821 | [] T_sacch.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 822 | 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] | 823 | } |
| 824 | } |
| 825 | } |
| 826 | |
Harald Welte | 5570066 | 2018-03-12 13:15:43 +0100 | [diff] [blame] | 827 | /* verify that given SACCH payload is not present */ |
| 828 | private function f_sacch_missing(template octetstring l3_exp) runs on ConnHdlr { |
| 829 | var L1ctlDlMessage dl; |
| 830 | /* check that the specified SI5 value is actually sent */ |
| 831 | timer T_sacch := 3.0; |
| 832 | L1CTL.clear; |
| 833 | T_sacch.start; |
| 834 | alt { |
| 835 | [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(0))) -> value dl { |
| 836 | var octetstring l3 := substr(dl.payload.data_ind.payload, 4, 19); |
| 837 | if (match(l3, l3_exp)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 838 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Received unexpected SACCH ", dl)); |
Harald Welte | 5570066 | 2018-03-12 13:15:43 +0100 | [diff] [blame] | 839 | } else { |
| 840 | repeat; |
| 841 | } |
| 842 | } |
| 843 | [] L1CTL.receive { repeat; } |
| 844 | [] T_sacch.timeout { |
| 845 | setverdict(pass); |
| 846 | } |
| 847 | } |
| 848 | } |
| 849 | |
Harald Welte | 629cc6b | 2018-03-11 17:19:05 +0100 | [diff] [blame] | 850 | /* Test for default SACCH FILL transmitted in DL SACCH (all channel types) */ |
Harald Welte | ea17b91 | 2018-03-11 22:29:31 +0100 | [diff] [blame] | 851 | private function f_TC_sacch_filling(charstring id) runs on ConnHdlr { |
| 852 | /* Set a known default SACCH filling for SI5 */ |
| 853 | var octetstring si5 := f_rnd_octstring(19); |
| 854 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5)); |
| 855 | |
| 856 | f_l1_tune(L1CTL); |
| 857 | RSL.clear; |
| 858 | |
| 859 | /* activate the logical channel */ |
| 860 | f_est_dchan(); |
| 861 | |
| 862 | /* check that the specified SI5 value is actually sent */ |
| 863 | f_sacch_present(si5); |
| 864 | |
| 865 | /* release the channel */ |
| 866 | RSL.clear; |
| 867 | f_rsl_chan_deact(); |
| 868 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 869 | } |
| 870 | testcase TC_sacch_filling() runs on test_CT { |
| 871 | var ConnHdlr vc_conn; |
| 872 | var ConnHdlrPars pars; |
| 873 | f_init(); |
| 874 | for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) { |
| 875 | pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN)); |
| 876 | log(testcasename(), ": Starting for ", g_AllChannels[i]); |
| 877 | vc_conn := f_start_handler(refers(f_TC_sacch_filling), pars); |
| 878 | vc_conn.done; |
| 879 | } |
| 880 | /* TODO: do the above in parallel, rather than sequentially? */ |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 881 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | ea17b91 | 2018-03-11 22:29:31 +0100 | [diff] [blame] | 882 | } |
| 883 | |
Harald Welte | 629cc6b | 2018-03-11 17:19:05 +0100 | [diff] [blame] | 884 | /* Test for lchan-specific SACCH INFO MODIFY (TS 48.058 4.12) */ |
Harald Welte | ea17b91 | 2018-03-11 22:29:31 +0100 | [diff] [blame] | 885 | private function f_TC_sacch_info_mod(charstring id) runs on ConnHdlr { |
| 886 | /* Set a known default SACCH filling for SI5 */ |
| 887 | var octetstring si5 := f_rnd_octstring(19); |
| 888 | var octetstring si5_diff := f_rnd_octstring(19); |
| 889 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5)); |
| 890 | |
| 891 | f_l1_tune(L1CTL); |
| 892 | RSL.clear; |
| 893 | |
| 894 | log("Activating channel, expecting standard SI5"); |
| 895 | /* activate the logical channel */ |
| 896 | f_est_dchan(); |
| 897 | /* check that the specified SI5 value is actually sent */ |
| 898 | f_sacch_present(si5); |
| 899 | |
| 900 | /* set channel-specific different SI5 */ |
| 901 | log("Setting channel specific SACCH INFO, expecting it"); |
| 902 | RSL.send(ts_RSL_SACCH_INF_MOD(g_chan_nr, RSL_SYSTEM_INFO_5, si5_diff)) |
| 903 | /* check that the specified lchan-specific value is now used */ |
| 904 | f_sacch_present(si5_diff); |
| 905 | |
| 906 | /* deactivate the channel and re-activate it, this should result in default SI5 */ |
| 907 | log("De-activating and re-activating channel, expecting standard SI5"); |
| 908 | f_rsl_chan_deact(); |
| 909 | f_rsl_chan_act(valueof(ts_RSL_ChanMode_SIGN)); |
| 910 | /* Verify that the TRX-wide default SACCH filling is present again */ |
| 911 | f_sacch_present(si5); |
| 912 | |
| 913 | /* release the channel */ |
| 914 | RSL.clear; |
| 915 | f_rsl_chan_deact(); |
| 916 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 917 | } |
| 918 | testcase TC_sacch_info_mod() runs on test_CT { |
| 919 | var ConnHdlr vc_conn; |
| 920 | var ConnHdlrPars pars; |
| 921 | f_init(); |
| 922 | for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) { |
| 923 | pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN)); |
| 924 | log(testcasename(), ": Starting for ", g_AllChannels[i]); |
| 925 | vc_conn := f_start_handler(refers(f_TC_sacch_info_mod), pars); |
| 926 | vc_conn.done; |
| 927 | } |
| 928 | /* TODO: do the above in parallel, rather than sequentially? */ |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 929 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | ea17b91 | 2018-03-11 22:29:31 +0100 | [diff] [blame] | 930 | } |
| 931 | |
Harald Welte | 075d84c | 2018-03-12 13:07:24 +0100 | [diff] [blame] | 932 | /* Test SACCH scheduling of multiple different SI message types */ |
| 933 | private function f_TC_sacch_multi(charstring id) runs on ConnHdlr { |
| 934 | var octetstring si5 := f_rnd_octstring(19); |
| 935 | var octetstring si5bis := f_rnd_octstring(19); |
| 936 | var octetstring si5ter := f_rnd_octstring(19); |
| 937 | var octetstring si6 := f_rnd_octstring(19); |
| 938 | |
| 939 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5)); |
| 940 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5bis, si5bis)); |
| 941 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5ter, si5ter)); |
| 942 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_6, si6)); |
| 943 | |
| 944 | f_l1_tune(L1CTL); |
| 945 | RSL.clear; |
| 946 | |
| 947 | /* activate the logical channel */ |
| 948 | f_est_dchan(); |
| 949 | L1CTL.clear; |
| 950 | |
| 951 | /* check that SACCH actually are received as expected */ |
| 952 | f_sacch_present(si5); |
| 953 | f_sacch_present(si5bis); |
| 954 | f_sacch_present(si5ter); |
| 955 | f_sacch_present(si6); |
| 956 | |
| 957 | /* release the channel */ |
| 958 | f_rsl_chan_deact(); |
| 959 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 960 | } |
| 961 | testcase TC_sacch_multi() runs on test_CT { |
| 962 | var ConnHdlr vc_conn; |
| 963 | var ConnHdlrPars pars; |
| 964 | f_init(); |
| 965 | for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) { |
| 966 | pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN)); |
| 967 | log(testcasename(), ": Starting for ", g_AllChannels[i]); |
| 968 | vc_conn := f_start_handler(refers(f_TC_sacch_multi), pars); |
| 969 | vc_conn.done; |
| 970 | } |
| 971 | /* TODO: do the above in parallel, rather than sequentially? */ |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 972 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 075d84c | 2018-03-12 13:07:24 +0100 | [diff] [blame] | 973 | } |
| 974 | |
Harald Welte | 5570066 | 2018-03-12 13:15:43 +0100 | [diff] [blame] | 975 | /* Test if SACH information is modified as expected */ |
| 976 | private function f_TC_sacch_multi_chg(charstring id) runs on ConnHdlr { |
| 977 | var octetstring si5 := f_rnd_octstring(19); |
| 978 | var octetstring si6 := f_rnd_octstring(19); |
| 979 | |
| 980 | /* First, configure both SI5 and SI6 to be transmitted */ |
| 981 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5)); |
| 982 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_6, si6)); |
| 983 | |
| 984 | f_l1_tune(L1CTL); |
| 985 | RSL.clear; |
| 986 | |
| 987 | /* activate the logical channel */ |
| 988 | f_est_dchan(); |
| 989 | L1CTL.clear; |
| 990 | |
| 991 | /* check that SACCH actually are received as expected */ |
| 992 | f_sacch_present(si5); |
| 993 | f_sacch_present(si6); |
| 994 | |
| 995 | /* disable SI6 */ |
| 996 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_6, ''O)); |
| 997 | |
| 998 | /* check that SI5 is still transmitted */ |
| 999 | f_sacch_present(si5); |
| 1000 | /* check if SI6 is now gone */ |
| 1001 | f_sacch_missing(si6); |
| 1002 | |
| 1003 | /* release the channel */ |
| 1004 | f_rsl_chan_deact(); |
| 1005 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 1006 | } |
| 1007 | testcase TC_sacch_multi_chg() runs on test_CT { |
| 1008 | var ConnHdlr vc_conn; |
| 1009 | var ConnHdlrPars pars; |
| 1010 | f_init(); |
| 1011 | for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) { |
| 1012 | pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN)); |
| 1013 | log(testcasename(), ": Starting for ", g_AllChannels[i]); |
| 1014 | vc_conn := f_start_handler(refers(f_TC_sacch_multi_chg), pars); |
| 1015 | vc_conn.done; |
| 1016 | } |
| 1017 | /* TODO: do the above in parallel, rather than sequentially? */ |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1018 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 5570066 | 2018-03-12 13:15:43 +0100 | [diff] [blame] | 1019 | } |
| 1020 | |
Harald Welte | c8d363c | 2019-05-19 20:36:48 +0200 | [diff] [blame] | 1021 | /* Test for SACCH information present in RSL CHAN ACT (overrides FILLING) */ |
| 1022 | private function f_TC_sacch_chan_act(charstring id) runs on ConnHdlr { |
| 1023 | var octetstring si5 := f_rnd_octstring(19); |
| 1024 | var octetstring si6 := f_rnd_octstring(19); |
| 1025 | var octetstring si5_specific := f_rnd_octstring(19); |
| 1026 | var octetstring si6_specific := f_rnd_octstring(19); |
| 1027 | |
| 1028 | /* First, configure both SI5 and SI6 to be transmitted */ |
| 1029 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5)); |
| 1030 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_6, si6)); |
| 1031 | |
| 1032 | f_l1_tune(L1CTL); |
| 1033 | RSL.clear; |
| 1034 | |
| 1035 | /* activate channel with different SACCH filling */ |
| 1036 | var RSL_SacchInfo sacch_info := valueof(ts_RSL_SacchInfo({ |
| 1037 | ts_RSL_SacchInfoElem(RSL_SYSTEM_INFO_5, si5_specific), |
| 1038 | ts_RSL_SacchInfoElem(RSL_SYSTEM_INFO_6, si6_specific) |
| 1039 | })); |
| 1040 | var RSL_IE_List addl_ies := { valueof(t_RSL_IE(RSL_IE_SACCH_INFO, |
| 1041 | RSL_IE_Body:{sacch_info := sacch_info})) }; |
| 1042 | f_est_dchan(more_ies := addl_ies); |
| 1043 | |
| 1044 | /* check that SACCH actually are received as expected */ |
| 1045 | f_sacch_present(si5_specific); |
| 1046 | f_sacch_present(si6_specific); |
| 1047 | |
| 1048 | /* release the channel */ |
| 1049 | f_rsl_chan_deact(); |
| 1050 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 1051 | } |
| 1052 | testcase TC_sacch_chan_act() runs on test_CT { |
| 1053 | var ConnHdlr vc_conn; |
| 1054 | var ConnHdlrPars pars; |
| 1055 | f_init(); |
| 1056 | |
| 1057 | for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) { |
| 1058 | pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN)); |
| 1059 | log(testcasename(), ": Starting for ", g_AllChannels[i]); |
| 1060 | vc_conn := f_start_handler(refers(f_TC_sacch_chan_act), pars); |
| 1061 | vc_conn.done; |
| 1062 | } |
| 1063 | /* TODO: do the above in parallel, rather than sequentially? */ |
| 1064 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 1065 | } |
| 1066 | |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1067 | /* verify that SACCH DL transmission is started only if MS power IE present |
| 1068 | * see section 4.1.3 of 3GPP TS 48.058 */ |
| 1069 | private function f_TC_sacch_chan_act_ho_async(charstring id) runs on ConnHdlr { |
| 1070 | var octetstring si5 := f_rnd_octstring(19); |
| 1071 | |
| 1072 | f_l1_tune(L1CTL); |
| 1073 | RSL.clear; |
| 1074 | |
| 1075 | /* Step 1: Activate ASYNC HO channel without MS power IE */ |
| 1076 | |
| 1077 | /* Activate channel on BTS side */ |
| 1078 | f_rsl_chan_act(g_pars.chan_mode, act_type := t_RSL_IE_ActType_HO_ASYNC); |
| 1079 | /* don't perform immediate assignment here, as we're testing non-IA case */ |
| 1080 | /* enable dedicated mode */ |
| 1081 | f_L1CTL_DM_EST_REQ(L1CTL, {false, mp_trx0_arfcn }, g_pars.chan_nr, 7); |
| 1082 | |
| 1083 | /* Verify that no DL SACCH is being received */ |
| 1084 | f_sacch_missing(?); |
| 1085 | |
| 1086 | f_rsl_chan_deact(); |
| 1087 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 1088 | |
| 1089 | |
| 1090 | /* Step 2: Activate ASYNC HO channel with MS power IE */ |
| 1091 | |
| 1092 | /* Activate channel on BTS side */ |
| 1093 | var RSL_IE_List addl_ies := { |
| 1094 | valueof(t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ts_RSL_IE_MS_Power(0)})) |
| 1095 | }; |
| 1096 | f_rsl_chan_act(g_pars.chan_mode, more_ies := addl_ies, act_type := t_RSL_IE_ActType_HO_ASYNC); |
| 1097 | /* don't perform immediate assignment here, as we're testing non-IA case */ |
| 1098 | /* enable dedicated mode */ |
| 1099 | f_L1CTL_DM_EST_REQ(L1CTL, {false, mp_trx0_arfcn }, g_pars.chan_nr, 7); |
| 1100 | |
| 1101 | /* Verify that DL SACCH is being received */ |
| 1102 | f_sacch_present(si5); |
| 1103 | |
| 1104 | f_rsl_chan_deact(); |
| 1105 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 1106 | } |
| 1107 | testcase TC_sacch_chan_act_ho_async() runs on test_CT { |
| 1108 | var ConnHdlr vc_conn; |
| 1109 | var ConnHdlrPars pars; |
| 1110 | f_init(); |
| 1111 | |
| 1112 | for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) { |
| 1113 | pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN)); |
| 1114 | log(testcasename(), ": Starting for ", g_AllChannels[i]); |
| 1115 | vc_conn := f_start_handler(refers(f_TC_sacch_chan_act_ho_async), pars); |
| 1116 | vc_conn.done; |
| 1117 | } |
| 1118 | /* TODO: do the above in parallel, rather than sequentially? */ |
| 1119 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 1120 | } |
| 1121 | |
| 1122 | /* verify that SACCH DL transmission is started only if TA + MS power IEs present, |
| 1123 | * see section 4.1.4 of 3GPP TS 48.058 */ |
| 1124 | private function f_TC_sacch_chan_act_ho_sync(charstring id) runs on ConnHdlr { |
| 1125 | var octetstring si5 := f_rnd_octstring(19); |
| 1126 | var RSL_IE_List addl_ies; |
| 1127 | |
| 1128 | f_l1_tune(L1CTL); |
| 1129 | RSL.clear; |
| 1130 | |
| 1131 | /* Step 1: Activate SYNC HO channel without MS power IE */ |
| 1132 | |
| 1133 | /* Activate channel on BTS side */ |
| 1134 | f_rsl_chan_act(g_pars.chan_mode, act_type := t_RSL_IE_ActType_HO_SYNC); |
| 1135 | /* don't perform immediate assignment here, as we're testing non-IA case */ |
| 1136 | /* enable dedicated mode */ |
| 1137 | f_L1CTL_DM_EST_REQ(L1CTL, {false, mp_trx0_arfcn }, g_pars.chan_nr, 7); |
| 1138 | |
| 1139 | /* Verify that no DL SACCH is being received */ |
| 1140 | f_sacch_missing(?); |
| 1141 | |
| 1142 | f_rsl_chan_deact(); |
| 1143 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 1144 | |
| 1145 | |
| 1146 | /* Step 2a: Activate SYNC HO channel with only MS power IE */ |
| 1147 | |
| 1148 | /* Activate channel on BTS side */ |
| 1149 | addl_ies := { |
| 1150 | valueof(t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ts_RSL_IE_MS_Power(0)})) |
| 1151 | }; |
| 1152 | f_rsl_chan_act(g_pars.chan_mode, more_ies := addl_ies, act_type := t_RSL_IE_ActType_HO_SYNC); |
| 1153 | /* don't perform immediate assignment here, as we're testing non-IA case */ |
| 1154 | /* enable dedicated mode */ |
| 1155 | f_L1CTL_DM_EST_REQ(L1CTL, {false, mp_trx0_arfcn }, g_pars.chan_nr, 7); |
| 1156 | |
| 1157 | /* Verify that no DL SACCH is being received */ |
| 1158 | f_sacch_missing(?); |
| 1159 | |
| 1160 | f_rsl_chan_deact(); |
| 1161 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 1162 | |
| 1163 | |
| 1164 | /* Step 2b: Activate SYNC HO channel with TA IE */ |
| 1165 | |
| 1166 | /* Activate channel on BTS side */ |
| 1167 | addl_ies := { |
| 1168 | valueof(t_RSL_IE(RSL_IE_TIMING_ADVANCE, RSL_IE_Body:{timing_adv := 0})) |
| 1169 | }; |
| 1170 | f_rsl_chan_act(g_pars.chan_mode, more_ies := addl_ies, act_type := t_RSL_IE_ActType_HO_SYNC); |
| 1171 | /* don't perform immediate assignment here, as we're testing non-IA case */ |
| 1172 | /* enable dedicated mode */ |
| 1173 | f_L1CTL_DM_EST_REQ(L1CTL, {false, mp_trx0_arfcn }, g_pars.chan_nr, 7); |
| 1174 | |
| 1175 | /* Verify that no DL SACCH is being received */ |
| 1176 | f_sacch_missing(?); |
| 1177 | |
| 1178 | f_rsl_chan_deact(); |
| 1179 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 1180 | |
| 1181 | |
| 1182 | /* Step 3: Activate SYNC HO channel with MS power IE and TA IE */ |
| 1183 | |
| 1184 | /* Activate channel on BTS side */ |
| 1185 | addl_ies := { |
| 1186 | valueof(t_RSL_IE(RSL_IE_TIMING_ADVANCE, RSL_IE_Body:{timing_adv := 0})), |
| 1187 | valueof(t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ts_RSL_IE_MS_Power(0)})) |
| 1188 | }; |
| 1189 | f_rsl_chan_act(g_pars.chan_mode, more_ies := addl_ies, act_type := t_RSL_IE_ActType_HO_SYNC); |
| 1190 | /* don't perform immediate assignment here, as we're testing non-IA case */ |
| 1191 | /* enable dedicated mode */ |
| 1192 | f_L1CTL_DM_EST_REQ(L1CTL, {false, mp_trx0_arfcn }, g_pars.chan_nr, 7); |
| 1193 | |
| 1194 | /* Verify that DL SACCH is being received */ |
| 1195 | f_sacch_present(si5); |
| 1196 | |
| 1197 | f_rsl_chan_deact(); |
| 1198 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 1199 | } |
| 1200 | testcase TC_sacch_chan_act_ho_sync() runs on test_CT { |
| 1201 | var ConnHdlr vc_conn; |
| 1202 | var ConnHdlrPars pars; |
| 1203 | f_init(); |
| 1204 | |
| 1205 | for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) { |
| 1206 | pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN)); |
| 1207 | log(testcasename(), ": Starting for ", g_AllChannels[i]); |
| 1208 | vc_conn := f_start_handler(refers(f_TC_sacch_chan_act_ho_sync), pars); |
| 1209 | vc_conn.done; |
| 1210 | } |
| 1211 | /* TODO: do the above in parallel, rather than sequentially? */ |
| 1212 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 1213 | } |
Harald Welte | 629cc6b | 2018-03-11 17:19:05 +0100 | [diff] [blame] | 1214 | |
| 1215 | |
| 1216 | /*********************************************************************** |
Harald Welte | 93640c6 | 2018-02-25 16:59:33 +0100 | [diff] [blame] | 1217 | * RACH Handling |
| 1218 | ***********************************************************************/ |
| 1219 | |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1220 | /* like L1SAP_IS_PACKET_RACH */ |
| 1221 | private function ra_is_ps(OCT1 ra) return boolean { |
Harald Welte | 56c0580 | 2018-02-28 21:39:35 +0100 | [diff] [blame] | 1222 | 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] | 1223 | return true; |
| 1224 | } |
| 1225 | return false; |
| 1226 | } |
| 1227 | |
| 1228 | /* generate a random RACH for circuit-switched */ |
| 1229 | private function f_rnd_ra_cs() return OCT1 { |
| 1230 | var OCT1 ra; |
| 1231 | do { |
| 1232 | ra := f_rnd_octstring(1); |
| 1233 | } while (ra_is_ps(ra)); |
| 1234 | return ra; |
| 1235 | } |
| 1236 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 1237 | /* generate a random RACH for packet-switched */ |
| 1238 | private function f_rnd_ra_ps() return OCT1 { |
| 1239 | var OCT1 ra; |
| 1240 | do { |
| 1241 | ra := f_rnd_octstring(1); |
| 1242 | } while (not ra_is_ps(ra)); |
| 1243 | return ra; |
| 1244 | } |
| 1245 | |
Vadim Yanitskiy | 51cbc10 | 2019-04-22 06:37:30 +0700 | [diff] [blame] | 1246 | /* generate a random 11-bit RA (packet-switched only) */ |
| 1247 | private function f_rnd_ra11_ps() return BIT11 { |
| 1248 | var integer ra11 := f_rnd_int(bit2int('11111111111'B)); |
| 1249 | return int2bit(ra11, 11); |
| 1250 | } |
| 1251 | |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1252 | /* Send 1000 RACH requests and check their RA+FN on the RSL side */ |
| 1253 | testcase TC_rach_content() runs on test_CT { |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 1254 | f_init(); |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1255 | f_init_l1ctl(); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 1256 | f_l1_tune(L1CTL); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1257 | |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1258 | var GsmFrameNumber fn_last := 0; |
Max | a199a2e | 2019-02-25 16:31:11 +0100 | [diff] [blame] | 1259 | var boolean test_failed := false; |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1260 | for (var integer i := 0; i < 1000; i := i+1) { |
| 1261 | var OCT1 ra := f_rnd_ra_cs(); |
| 1262 | var GsmFrameNumber fn := f_L1CTL_RACH(L1CTL, oct2int(ra)); |
| 1263 | if (fn == fn_last) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1264 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Two RACH in same FN?!?"); |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1265 | } |
| 1266 | fn_last := fn; |
| 1267 | |
| 1268 | timer T := 5.0; |
Harald Welte | 56c0580 | 2018-02-28 21:39:35 +0100 | [diff] [blame] | 1269 | T.start; |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1270 | alt { |
Vadim Yanitskiy | ab448a5 | 2019-05-31 20:24:03 +0700 | [diff] [blame] | 1271 | [] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_CHAN_RQD(ra, fn, t_RslChanNr_RACH(0)))) { |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1272 | T.stop; |
| 1273 | } |
Vadim Yanitskiy | ab448a5 | 2019-05-31 20:24:03 +0700 | [diff] [blame] | 1274 | [] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_CHAN_RQD(?, ?, ?, ?))) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1275 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected CHAN RQD"); |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1276 | } |
| 1277 | [] RSL_CCHAN.receive { repeat; } |
| 1278 | [] T.timeout { |
Max | a199a2e | 2019-02-25 16:31:11 +0100 | [diff] [blame] | 1279 | test_failed := true; |
| 1280 | log("[", i, "] Timeout waiting for CHAN RQD FN=", fn, " RA=", ra); |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1281 | } |
| 1282 | } |
| 1283 | } |
Max | ba06feb | 2019-03-05 10:52:46 +0100 | [diff] [blame] | 1284 | if (test_failed) { |
| 1285 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Some out of 1000 RACH requests timed out")); |
Max | a199a2e | 2019-02-25 16:31:11 +0100 | [diff] [blame] | 1286 | } |
Max | ba06feb | 2019-03-05 10:52:46 +0100 | [diff] [blame] | 1287 | setverdict(pass); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1288 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1289 | } |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1290 | |
| 1291 | /* Send 1000 RACH Requests (flood ~ 89/s) and count if count(Abis) == count(Um) */ |
| 1292 | testcase TC_rach_count() runs on test_CT { |
Harald Welte | 294b0a2 | 2018-03-10 23:26:48 +0100 | [diff] [blame] | 1293 | f_init(); |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1294 | f_init_l1ctl(); |
Harald Welte | 294b0a2 | 2018-03-10 23:26:48 +0100 | [diff] [blame] | 1295 | f_sleep(1.0); |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1296 | f_l1_tune(L1CTL); |
| 1297 | |
| 1298 | var GsmFrameNumber fn_last := 0; |
| 1299 | for (var integer i := 0; i < 1000; i := i+1) { |
| 1300 | var OCT1 ra := f_rnd_ra_cs(); |
| 1301 | var GsmFrameNumber fn := f_L1CTL_RACH(L1CTL, oct2int(ra)); |
| 1302 | if (fn == fn_last) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1303 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Two RACH in same FN?!?"); |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1304 | } |
| 1305 | fn_last := fn; |
| 1306 | } |
| 1307 | var integer rsl_chrqd := 0; |
| 1308 | timer T := 3.0; |
Harald Welte | 56c0580 | 2018-02-28 21:39:35 +0100 | [diff] [blame] | 1309 | T.start; |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1310 | alt { |
| 1311 | [] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_CHAN_RQD(?,?))) { |
| 1312 | rsl_chrqd := rsl_chrqd + 1; |
Harald Welte | c3a3f45 | 2018-02-26 17:37:47 +0100 | [diff] [blame] | 1313 | f_timer_safe_restart(T); |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1314 | repeat; |
| 1315 | } |
| 1316 | [] RSL_CCHAN.receive { repeat; } |
| 1317 | [] T.timeout { } |
| 1318 | } |
| 1319 | if (rsl_chrqd == 1000) { |
| 1320 | setverdict(pass); |
| 1321 | } else { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1322 | 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] | 1323 | } |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1324 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1325 | } |
| 1326 | |
Harald Welte | 3453ab4 | 2019-05-24 21:19:58 +0200 | [diff] [blame] | 1327 | private function f_vty_load_ind_thresh(integer period := 10, integer bts_nr := 0) runs on test_CT { |
| 1328 | var charstring bts_str := "bts " & int2str(bts_nr); |
| 1329 | f_vty_config2(BSCVTY, {"network", bts_str}, "ccch load-indication-threshold " & int2str(period)); |
| 1330 | } |
| 1331 | |
| 1332 | /* empirical value: Number of RACH slots per reporting interval (1s) on combined CCCH */ |
| 1333 | private template integer tr_rach_slots_per_interval := (90 .. 130); |
| 1334 | |
| 1335 | /* Expect 0 RACH load on an idle BTS that has just started up */ |
| 1336 | testcase TC_rach_load_idle_thresh0() runs on test_CT { |
| 1337 | var ASP_RSL_Unitdata rx_ud; |
| 1338 | |
| 1339 | f_init_vty_bsc(); |
| 1340 | /* send load indications even at 0% load */ |
| 1341 | f_vty_load_ind_thresh(0); |
| 1342 | f_vty_transceive(BSCVTY, "drop bts connection 0 oml"); |
| 1343 | f_sleep(2.0); |
| 1344 | |
| 1345 | f_init(); |
| 1346 | |
| 1347 | timer T := 5.0; |
| 1348 | T.start; |
| 1349 | alt { |
| 1350 | [] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_RACH_LOAD_IND(tr_rach_slots_per_interval, 0, 0))) { |
| 1351 | setverdict(pass); |
| 1352 | repeat; |
| 1353 | } |
| 1354 | [] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_RACH_LOAD_IND(?, ?, ?))) -> value rx_ud { |
| 1355 | setverdict(fail, "Unexpected RACH LOAD IND: ", rx_ud); |
| 1356 | repeat; |
| 1357 | } |
| 1358 | [] RSL_CCHAN.receive { |
| 1359 | repeat; |
| 1360 | } |
| 1361 | [] T.timeout { } |
| 1362 | } |
| 1363 | |
| 1364 | f_vty_load_ind_thresh(10); |
| 1365 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 1366 | } |
| 1367 | |
| 1368 | /* Expect no RACH load indications on an idle BTS that has just started up (default threshold 10%) */ |
| 1369 | testcase TC_rach_load_idle_below_thresh() runs on test_CT { |
| 1370 | var ASP_RSL_Unitdata rx_ud; |
| 1371 | |
| 1372 | f_init_vty_bsc(); |
| 1373 | f_init(); |
| 1374 | |
| 1375 | timer T := 5.0; |
| 1376 | T.start; |
| 1377 | alt { |
| 1378 | [] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_RACH_LOAD_IND(?, ?, ?))) -> value rx_ud { |
| 1379 | setverdict(fail, "Unexpected RACH LOAD IND: ", rx_ud); |
| 1380 | repeat; |
| 1381 | } |
| 1382 | [] RSL_CCHAN.receive { |
| 1383 | repeat; |
| 1384 | } |
| 1385 | [] T.timeout { |
| 1386 | setverdict(pass); |
| 1387 | } |
| 1388 | } |
| 1389 | |
| 1390 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 1391 | } |
| 1392 | |
| 1393 | /* Expect 0 RACH load on an idle BTS that has just started up */ |
| 1394 | testcase TC_rach_load_count() runs on test_CT { |
| 1395 | var ASP_RSL_Unitdata rx_ud; |
| 1396 | var integer load_access_count := 0; |
| 1397 | |
| 1398 | f_init_vty_bsc(); |
| 1399 | /* send load indications even at 0% load */ |
| 1400 | f_vty_load_ind_thresh(0); |
| 1401 | f_vty_transceive(BSCVTY, "drop bts connection 0 oml"); |
| 1402 | f_sleep(2.0); |
| 1403 | f_init(); |
| 1404 | |
| 1405 | f_init_l1ctl(); |
| 1406 | f_sleep(1.0); |
| 1407 | f_l1_tune(L1CTL); |
| 1408 | |
| 1409 | var GsmFrameNumber fn_last := 0; |
| 1410 | for (var integer i := 0; i < 1000; i := i+1) { |
| 1411 | var OCT1 ra := f_rnd_ra_cs(); |
| 1412 | var GsmFrameNumber fn := f_L1CTL_RACH(L1CTL, oct2int(ra)); |
| 1413 | if (fn == fn_last) { |
| 1414 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Two RACH in same FN?!?"); |
| 1415 | } |
| 1416 | fn_last := fn; |
| 1417 | } |
| 1418 | |
| 1419 | timer T := 5.0; |
| 1420 | T.start; |
| 1421 | alt { |
| 1422 | [] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_RACH_LOAD_IND(tr_rach_slots_per_interval, ?, ?))) |
| 1423 | -> value rx_ud { |
| 1424 | var RSL_IE_Body ie; |
| 1425 | f_rsl_find_ie(rx_ud.rsl, RSL_IE_RACH_LOAD, ie); |
| 1426 | load_access_count := load_access_count + ie.rach_load.access_count; |
| 1427 | if (ie.rach_load.busy_count < ie.rach_load.access_count) { |
| 1428 | setverdict(fail, "Access count cannot be < Busy count"); |
| 1429 | } |
| 1430 | repeat; |
| 1431 | } |
| 1432 | [] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_RACH_LOAD_IND(?, ?, ?))) -> value rx_ud { |
| 1433 | setverdict(fail, "Unexpected RACH LOAD IND: ", rx_ud); |
| 1434 | repeat; |
| 1435 | } |
| 1436 | [] RSL_CCHAN.receive { |
| 1437 | repeat; |
| 1438 | } |
| 1439 | [] T.timeout { } |
| 1440 | } |
| 1441 | if (load_access_count == 1000) { |
| 1442 | setverdict(pass); |
| 1443 | } else { |
| 1444 | setverdict(fail, "Load reports state ", load_access_count, " RACH, but we sent 1000"); |
| 1445 | } |
| 1446 | |
| 1447 | f_vty_load_ind_thresh(10); |
| 1448 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 1449 | } |
| 1450 | |
Harald Welte | 54a2a2d | 2018-02-26 09:14:05 +0100 | [diff] [blame] | 1451 | 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] | 1452 | var TrxcMessage ret; |
Harald Welte | 54a2a2d | 2018-02-26 09:14:05 +0100 | [diff] [blame] | 1453 | /* tell fake_trx to use a given timing offset for all bursts */ |
Vadim Yanitskiy | 44ff214 | 2019-01-12 07:04:58 +0700 | [diff] [blame] | 1454 | ret := f_TRXC_transceive(BTS_TRXC, g_bts_trxc_conn_id, valueof(ts_TRXC_FAKE_TIMING(toffs256))); |
Harald Welte | 54a2a2d | 2018-02-26 09:14:05 +0100 | [diff] [blame] | 1455 | f_sleep(0.5); |
| 1456 | |
| 1457 | /* Transmit RACH request + wait for confirmation */ |
| 1458 | var OCT1 ra := f_rnd_ra_cs(); |
| 1459 | var GsmFrameNumber fn := f_L1CTL_RACH(L1CTL, oct2int(ra)); |
| 1460 | |
| 1461 | /* Check for expected result */ |
| 1462 | timer T := 1.5; |
| 1463 | T.start; |
| 1464 | alt { |
| 1465 | [expect_pass] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_CHAN_RQD(ra, fn))) { |
| 1466 | setverdict(pass); |
| 1467 | } |
| 1468 | [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] | 1469 | 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] | 1470 | } |
| 1471 | [] RSL_CCHAN.receive { repeat; } |
| 1472 | [not expect_pass] T.timeout { |
| 1473 | setverdict(pass); |
| 1474 | } |
| 1475 | [expect_pass] T.timeout { |
Max | 6e05304 | 2019-03-14 16:34:22 +0100 | [diff] [blame] | 1476 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Timeout waiting for CHAN RQD: FN=", fn, " RA=", ra)); |
Harald Welte | 54a2a2d | 2018-02-26 09:14:05 +0100 | [diff] [blame] | 1477 | } |
| 1478 | } |
| 1479 | } |
| 1480 | |
| 1481 | /* Test if dropping of RACH Based on NM_ATT_MAX_TA works */ |
| 1482 | testcase TC_rach_max_ta() runs on test_CT { |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 1483 | f_init(); |
Harald Welte | 54a2a2d | 2018-02-26 09:14:05 +0100 | [diff] [blame] | 1484 | f_init_l1ctl(); |
| 1485 | f_l1_tune(L1CTL); |
Harald Welte | 54a2a2d | 2018-02-26 09:14:05 +0100 | [diff] [blame] | 1486 | f_sleep(1.0); |
| 1487 | |
| 1488 | /* default max-ta is 63 (full range of GSM timing advance */ |
| 1489 | |
Vadim Yanitskiy | c81d6e4 | 2018-03-05 22:39:01 +0700 | [diff] [blame] | 1490 | /* We allow early arrival up to 2 symbols */ |
| 1491 | f_rach_toffs(-1*256, true); |
| 1492 | f_rach_toffs(-2*256, true); |
Harald Welte | 54a2a2d | 2018-02-26 09:14:05 +0100 | [diff] [blame] | 1493 | f_rach_toffs(-10*256, false); |
| 1494 | |
| 1495 | /* 0 / 32 / 63 bits is legal / permitted */ |
| 1496 | f_rach_toffs(0, true); |
| 1497 | f_rach_toffs(32*256, true); |
| 1498 | f_rach_toffs(63*256, true); |
| 1499 | |
| 1500 | /* more than 63 bits is not legal / permitted */ |
| 1501 | f_rach_toffs(64*256, false); |
| 1502 | f_rach_toffs(127*256, false); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1503 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 54a2a2d | 2018-02-26 09:14:05 +0100 | [diff] [blame] | 1504 | } |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1505 | |
Vadim Yanitskiy | 7c2c10c | 2019-05-31 20:42:01 +0700 | [diff] [blame] | 1506 | function f_TC_ho_rach(charstring id) runs on ConnHdlr { |
| 1507 | var GsmFrameNumber fn; |
| 1508 | var RSL_Message rm; |
| 1509 | |
| 1510 | f_l1_tune(L1CTL); |
| 1511 | RSL.clear; |
| 1512 | |
| 1513 | /* Generate a random Handover Reference */ |
| 1514 | var integer ho_ref := oct2int(f_rnd_octstring(1)); |
| 1515 | |
| 1516 | /* Handover Reference IE (see 3GPP TS 48.058, 9.3.9) */ |
| 1517 | var RSL_IE ho_ref_ie := valueof(t_RSL_IE(RSL_IE_HANDO_REF, |
| 1518 | RSL_IE_Body:{ handover_ref := ho_ref })); |
| 1519 | |
| 1520 | /* Activate a channel on the BTS side (no encryption) */ |
| 1521 | f_rsl_chan_act(g_pars.chan_mode, more_ies := { ho_ref_ie }, |
| 1522 | act_type := t_RSL_IE_ActType_HO_SYNC); |
| 1523 | |
| 1524 | /* Switch the MS side (e.g. trxcon) to a dedicated channel without |
| 1525 | * waiting for Immediate Assignment and sending Access Burst */ |
| 1526 | f_L1CTL_DM_EST_REQ(L1CTL, { false, mp_trx0_arfcn }, g_pars.chan_nr, 7); |
| 1527 | |
| 1528 | /* Send handover Access Burst */ |
| 1529 | fn := f_L1CTL_RACH(L1CTL, ho_ref, chan_nr := g_pars.chan_nr); |
| 1530 | |
| 1531 | /* TODO: test mismatching Handover Reference, and missing IE */ |
| 1532 | |
| 1533 | /* Wait for handover detection */ |
| 1534 | timer T := 3.0; |
| 1535 | T.start; |
| 1536 | alt { |
| 1537 | [] RSL.receive(tr_RSL_HANDO_DET(g_pars.chan_nr)) -> value rm { |
| 1538 | log("Handover RACH has been detected: ", rm); |
| 1539 | setverdict(pass); |
| 1540 | } |
| 1541 | [] RSL.receive(tr_RSL_CHAN_RQD(?, ?, ?, ?)) -> value rm { |
| 1542 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 1543 | log2str("RSL_CHAN_RQD was not expected: ", rm)); |
| 1544 | } |
| 1545 | [] RSL.receive { repeat; } |
| 1546 | [] T.timeout { |
| 1547 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 1548 | log2str("Timeout waiting for handover RACH: FN=", fn, " RA=", ho_ref)); |
| 1549 | } |
| 1550 | } |
| 1551 | |
| 1552 | /* Release the channel */ |
| 1553 | f_rsl_chan_deact(); |
| 1554 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 1555 | } |
| 1556 | |
| 1557 | /* Test handover RACH detection */ |
| 1558 | testcase TC_ho_rach() runs on test_CT { |
| 1559 | var ConnHdlrPars pars; |
| 1560 | var ConnHdlr vc_conn; |
| 1561 | |
| 1562 | f_init(); |
| 1563 | |
| 1564 | for (var integer i := 0; i < sizeof(g_AllChannels); i := i + 1) { |
| 1565 | pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN)); |
| 1566 | log(testcasename(), ": Starting for ", g_AllChannels[i]); |
| 1567 | vc_conn := f_start_handler(refers(f_TC_ho_rach), pars); |
| 1568 | vc_conn.done; |
| 1569 | } |
| 1570 | |
| 1571 | /* TODO: do the above in parallel, rather than sequentially? */ |
| 1572 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 1573 | } |
| 1574 | |
Harald Welte | 93640c6 | 2018-02-25 16:59:33 +0100 | [diff] [blame] | 1575 | /*********************************************************************** |
| 1576 | * Measurement Processing / Reporting |
| 1577 | ***********************************************************************/ |
| 1578 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1579 | template LapdmAddressField ts_LapdmAddr(LapdmSapi sapi, boolean c_r) := { |
| 1580 | spare := '0'B, |
| 1581 | lpd := 0, |
| 1582 | sapi := sapi, |
| 1583 | c_r := c_r, |
| 1584 | ea := true |
| 1585 | } |
| 1586 | |
Harald Welte | d879bd9 | 2018-03-12 15:01:23 +0100 | [diff] [blame] | 1587 | 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] | 1588 | addr := ts_LapdmAddr(sapi, c_r), |
Harald Welte | d879bd9 | 2018-03-12 15:01:23 +0100 | [diff] [blame] | 1589 | ctrl := ts_LapdmCtrlUI(p), |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1590 | len := 0, /* overwritten */ |
| 1591 | m := false, |
| 1592 | el := 1, |
| 1593 | payload := pl |
| 1594 | } |
| 1595 | |
| 1596 | /* handle incoming downlink SACCH and respond with uplink SACCH (meas res) */ |
| 1597 | altstep as_l1_sacch() runs on ConnHdlr { |
| 1598 | var L1ctlDlMessage l1_dl; |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 1599 | [] 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] | 1600 | log("SACCH received: ", l1_dl.payload.data_ind.payload); |
Pau Espin Pedrol | e9571aa | 2018-10-22 17:13:07 +0200 | [diff] [blame] | 1601 | 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] | 1602 | 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] | 1603 | log("LAPDm: ", lb); |
Pau Espin Pedrol | ed359cb | 2018-09-28 16:08:24 +0200 | [diff] [blame] | 1604 | |
Vadim Yanitskiy | 0a8d6da | 2019-05-28 22:18:28 +0700 | [diff] [blame] | 1605 | var template (value) SacchL1Header l1h := ts_SacchL1Header( |
| 1606 | g_pars.l1_pars.ms_power_level, false, |
| 1607 | g_pars.l1_pars.ms_actual_ta); |
| 1608 | |
| 1609 | /* TODO: we can use an extension of TTCN-3 for that, i.e. PADDING('2B'O) */ |
| 1610 | var octetstring l2 := f_pad_oct(enc_LapdmFrameAB(lb), 21, '2B'O); |
| 1611 | |
| 1612 | log("Sending Measurement Report: ", l1h, l2); |
| 1613 | L1CTL.send(ts_L1CTL_DATA_REQ_SACCH(g_chan_nr, ts_RslLinkID_SACCH(0), l1h, l2)); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1614 | repeat; |
| 1615 | } |
| 1616 | } |
| 1617 | |
| 1618 | altstep as_l1_dcch() runs on ConnHdlr { |
| 1619 | var L1ctlDlMessage l1_dl; |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 1620 | [] 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] | 1621 | log("DCCH received: ", l1_dl.payload.data_ind.payload); |
| 1622 | var octetstring pl := '010301'O; |
Vadim Yanitskiy | 31e7c67 | 2018-07-27 02:23:16 +0700 | [diff] [blame] | 1623 | L1CTL.send(ts_L1CTL_DATA_REQ(g_chan_nr, ts_RslLinkID_DCCH(0), |
| 1624 | f_pad_oct(pl, 23, '2B'O))); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1625 | repeat; |
| 1626 | } |
| 1627 | } |
| 1628 | |
| 1629 | type record MeasElem { |
| 1630 | uint6_t rxlev, |
| 1631 | uint3_t rxqual |
| 1632 | } |
| 1633 | |
| 1634 | type record MeasElemFS { |
| 1635 | MeasElem full, |
| 1636 | MeasElem sub |
| 1637 | } |
| 1638 | |
| 1639 | type record ConnL1Pars { |
| 1640 | boolean dtx_enabled, |
Harald Welte | 685d598 | 2018-02-27 20:42:05 +0100 | [diff] [blame] | 1641 | boolean toa256_enabled, |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1642 | MeasElemFS meas_ul, |
| 1643 | int16_t timing_offset_256syms, |
| 1644 | uint5_t bs_power_level, |
| 1645 | uint5_t ms_power_level, |
| 1646 | uint8_t ms_actual_ta |
| 1647 | } |
| 1648 | |
| 1649 | /* Convert tiing offset from 1/256th symbol to RSL Timing Offset */ |
| 1650 | private function toffs256s_to_rsl(int16_t toffs256s) return uint8_t { |
| 1651 | return 63 + (toffs256s/256); |
| 1652 | } |
| 1653 | |
Harald Welte | d568439 | 2018-03-10 18:22:04 +0100 | [diff] [blame] | 1654 | private function f_max(integer a, integer b) return integer { |
| 1655 | if (a > b) { |
| 1656 | return a; |
| 1657 | } else { |
| 1658 | return b; |
| 1659 | } |
| 1660 | } |
| 1661 | |
| 1662 | private function f_min(integer a, integer b) return integer { |
| 1663 | if (a < b) { |
| 1664 | return a; |
| 1665 | } else { |
| 1666 | return b; |
| 1667 | } |
| 1668 | } |
| 1669 | |
| 1670 | /* compute negative tolerance val-tolerance, ensure >= min */ |
| 1671 | private function f_tolerance_neg(integer val, integer min, integer tolerance) return integer { |
| 1672 | val := val - tolerance; |
| 1673 | return f_max(val, min); |
| 1674 | } |
| 1675 | |
| 1676 | /* compute positive tolerance val+tolerance, ensure <= max */ |
| 1677 | private function f_tolerance_pos(integer val, integer max, integer tolerance) return integer { |
| 1678 | val := val + tolerance; |
| 1679 | return f_min(val, max); |
| 1680 | } |
| 1681 | |
| 1682 | /* return a template of (val-tolerance .. val+tolerance) ensuring it is within (min .. max) */ |
| 1683 | private function f_tolerance(integer val, integer min, integer max, integer tolerance) |
| 1684 | return template integer { |
| 1685 | var template integer ret; |
| 1686 | ret := (f_tolerance_neg(val, min, tolerance) .. f_tolerance_pos(val, max, tolerance)); |
| 1687 | return ret; |
| 1688 | } |
| 1689 | |
| 1690 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1691 | /* build a template for matching measurement results against */ |
| 1692 | private function f_build_meas_res_tmpl() runs on ConnHdlr return template RSL_Message { |
| 1693 | var ConnL1Pars l1p := g_pars.l1_pars; |
| 1694 | var template RSL_IE_UplinkMeas ul_meas := { |
| 1695 | len := 3, |
| 1696 | rfu := '0'B, |
| 1697 | dtx_d := l1p.dtx_enabled, |
Harald Welte | d568439 | 2018-03-10 18:22:04 +0100 | [diff] [blame] | 1698 | 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] | 1699 | reserved1 := '00'B, |
Harald Welte | d568439 | 2018-03-10 18:22:04 +0100 | [diff] [blame] | 1700 | 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] | 1701 | reserved2 := '00'B, |
Harald Welte | d568439 | 2018-03-10 18:22:04 +0100 | [diff] [blame] | 1702 | rxq_f_u := f_tolerance(l1p.meas_ul.full.rxqual, 0, 7, mp_tolerance_rxqual), |
| 1703 | 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] | 1704 | supp_meas_info := omit |
| 1705 | }; |
Harald Welte | 685d598 | 2018-02-27 20:42:05 +0100 | [diff] [blame] | 1706 | if (l1p.toa256_enabled) { |
Harald Welte | 15de8ba | 2018-06-29 08:51:42 +0200 | [diff] [blame] | 1707 | ul_meas.len := (3+8); |
| 1708 | ul_meas.supp_meas_info := { |
Pau Espin Pedrol | 121724c | 2018-09-28 15:58:12 +0200 | [diff] [blame] | 1709 | 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] | 1710 | toa256_min := ?, |
| 1711 | toa256_max := ?, |
| 1712 | toa256_std_dev := ? |
| 1713 | } |
Harald Welte | 685d598 | 2018-02-27 20:42:05 +0100 | [diff] [blame] | 1714 | } |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1715 | var template RSL_IE_BS_Power bs_power := { |
| 1716 | reserved := 0, |
| 1717 | epc := false, |
| 1718 | fpc := false, |
| 1719 | power_level := l1p.bs_power_level |
| 1720 | }; |
| 1721 | var template RSL_IE_L1Info l1_info := { |
| 1722 | ms_power_lvl := l1p.ms_power_level, |
| 1723 | fpc := false, |
| 1724 | reserved := 0, |
Pau Espin Pedrol | 121724c | 2018-09-28 15:58:12 +0200 | [diff] [blame] | 1725 | 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] | 1726 | }; |
| 1727 | var uint8_t offs := toffs256s_to_rsl(l1p.timing_offset_256syms); |
Pau Espin Pedrol | 121724c | 2018-09-28 15:58:12 +0200 | [diff] [blame] | 1728 | 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] | 1729 | return tr_RSL_MEAS_RES_OSMO(g_chan_nr, g_next_meas_res_nr, ul_meas, bs_power, l1_info, |
| 1730 | ?, t_toffs); |
| 1731 | } |
| 1732 | |
| 1733 | /* verify we regularly receive measurement reports with incrementing numbers */ |
Vadim Yanitskiy | 41baf00 | 2018-10-04 17:44:50 +0700 | [diff] [blame] | 1734 | altstep as_meas_res(boolean verify_meas := true) runs on ConnHdlr { |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1735 | var RSL_Message rsl; |
Vadim Yanitskiy | 41baf00 | 2018-10-04 17:44:50 +0700 | [diff] [blame] | 1736 | [not verify_meas] RSL.receive(tr_RSL_MEAS_RES(?)) { repeat; } |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1737 | [] RSL.receive(f_build_meas_res_tmpl()) -> value rsl { |
| 1738 | /* increment counter of next to-be-expected meas rep */ |
| 1739 | g_next_meas_res_nr := (g_next_meas_res_nr + 1) mod 256; |
| 1740 | /* Re-start the timer expecting the next MEAS RES */ |
Harald Welte | c3a3f45 | 2018-02-26 17:37:47 +0100 | [diff] [blame] | 1741 | f_timer_safe_restart(g_Tmeas_exp); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1742 | repeat; |
| 1743 | } |
| 1744 | [] 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] | 1745 | /* increment counter of next to-be-expected meas rep */ |
| 1746 | g_next_meas_res_nr := (g_next_meas_res_nr + 1) mod 256; |
| 1747 | if (g_first_meas_res) { |
| 1748 | g_first_meas_res := false; |
| 1749 | repeat; |
| 1750 | } else { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1751 | 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] | 1752 | } |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1753 | } |
| 1754 | [] RSL.receive(tr_RSL_MEAS_RES(?)) -> value rsl { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1755 | 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] | 1756 | } |
Pau Espin Pedrol | 425b62f | 2018-07-06 16:11:43 +0200 | [diff] [blame] | 1757 | [g_Tmeas_exp.running] g_Tmeas_exp.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1758 | 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] | 1759 | } |
| 1760 | } |
| 1761 | |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 1762 | private function f_alg_id_to_l1ctl(RSL_AlgId rsl_alg_id) return uint8_t { |
| 1763 | select (rsl_alg_id) { |
| 1764 | case (RSL_ALG_ID_A5_0) { return 0; } |
| 1765 | case (RSL_ALG_ID_A5_1) { return 1; } |
| 1766 | case (RSL_ALG_ID_A5_2) { return 2; } |
| 1767 | case (RSL_ALG_ID_A5_3) { return 3; } |
| 1768 | case (RSL_ALG_ID_A5_4) { return 4; } |
| 1769 | case (RSL_ALG_ID_A5_5) { return 5; } |
| 1770 | case (RSL_ALG_ID_A5_6) { return 6; } |
| 1771 | case (RSL_ALG_ID_A5_7) { return 7; } |
| 1772 | case else { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1773 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unknwon Algorithm ID"); |
| 1774 | /* Make compiler happy by calling mtc.stop here. It is already |
| 1775 | * called in f_shutdown */ |
Daniel Willmann | 17ddd85 | 2018-07-05 17:33:20 +0200 | [diff] [blame] | 1776 | mtc.stop; |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 1777 | } |
| 1778 | } |
| 1779 | } |
| 1780 | |
| 1781 | private function f_alg_id_to_l3(RSL_AlgId rsl_alg_id) return BIT3 { |
| 1782 | select (rsl_alg_id) { |
| 1783 | case (RSL_ALG_ID_A5_1) { return '000'B; } |
| 1784 | case (RSL_ALG_ID_A5_2) { return '001'B; } |
| 1785 | case (RSL_ALG_ID_A5_3) { return '010'B; } |
| 1786 | case (RSL_ALG_ID_A5_4) { return '011'B; } |
| 1787 | case (RSL_ALG_ID_A5_5) { return '100'B; } |
| 1788 | case (RSL_ALG_ID_A5_6) { return '101'B; } |
| 1789 | case (RSL_ALG_ID_A5_7) { return '110'B; } |
| 1790 | case else { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1791 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unknwon Algorithm ID"); |
| 1792 | /* Make compiler happy by calling mtc.stop here. It is already |
| 1793 | * called in f_shutdown */ |
Daniel Willmann | 17ddd85 | 2018-07-05 17:33:20 +0200 | [diff] [blame] | 1794 | mtc.stop; |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 1795 | } |
| 1796 | } |
| 1797 | } |
| 1798 | |
Pau Espin Pedrol | 6451b04 | 2018-10-24 20:36:16 +0200 | [diff] [blame] | 1799 | /* Send RACH request through l1CTL and wait for ChanReq on RSL BST->BSC */ |
| 1800 | private function f_rach_req_wait_chan_rqd(integer ra) runs on ConnHdlr return GsmFrameNumber { |
| 1801 | var GsmFrameNumber fn; |
| 1802 | timer T := 8.0; |
| 1803 | |
| 1804 | /* advertise to RSL Emulation that we expect to receive confirmation from RACH */ |
| 1805 | RSL.send(ts_RSLDC_ChanRqd_anyFN(int2oct(ra,1))); |
| 1806 | |
| 1807 | f_L1CTL_PARAM(L1CTL, g_pars.l1_pars.ms_actual_ta, g_pars.l1_pars.ms_power_level); |
| 1808 | /* Send the actual RACH */ |
| 1809 | fn := f_L1CTL_RACH(L1CTL, ra); |
| 1810 | |
| 1811 | T.start; |
| 1812 | alt { |
| 1813 | [] RSL.receive(tr_RSL_CHAN_RQD(int2oct(ra,1), fn)) { setverdict(pass, "Received CHAN-RQD from RACH REQ") } |
| 1814 | [] T.timeout { |
| 1815 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Timeout waiting for CHAN-RQD from RACH REQ <", ra, ", ", fn, ">")); |
| 1816 | } |
| 1817 | } |
| 1818 | T.stop |
| 1819 | return fn; |
| 1820 | } |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 1821 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1822 | /* Establish dedicated channel: L1CTL + RSL side */ |
Harald Welte | c8d363c | 2019-05-19 20:36:48 +0200 | [diff] [blame] | 1823 | private function f_est_dchan(boolean encr_enable := false, RSL_IE_List more_ies := {}) runs on ConnHdlr { |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1824 | var GsmFrameNumber fn; |
| 1825 | var ImmediateAssignment imm_ass; |
| 1826 | var integer ra := 23; |
| 1827 | |
Pau Espin Pedrol | 6451b04 | 2018-10-24 20:36:16 +0200 | [diff] [blame] | 1828 | /* Send RACH request and wait for ChanReq */ |
| 1829 | fn := f_rach_req_wait_chan_rqd(ra); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1830 | |
| 1831 | /* Activate channel on BTS side */ |
Harald Welte | c8d363c | 2019-05-19 20:36:48 +0200 | [diff] [blame] | 1832 | f_rsl_chan_act(g_pars.chan_mode, encr_enable, more_ies); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1833 | |
| 1834 | /* Send IMM.ASS via CCHAN */ |
| 1835 | var ChannelDescription ch_desc := { |
| 1836 | chan_nr := g_pars.chan_nr, |
| 1837 | tsc := 7, |
| 1838 | h := false, |
| 1839 | arfcn := mp_trx0_arfcn, |
| 1840 | maio_hsn := omit |
| 1841 | }; |
| 1842 | var MobileAllocation ma := { |
| 1843 | len := 0, |
| 1844 | ma := ''B |
| 1845 | }; |
| 1846 | var GsmRrMessage rr_msg := valueof(ts_IMM_ASS(ra, fn, 0, ch_desc, ma)); |
| 1847 | RSL.send(ts_RSL_IMM_ASSIGN(enc_GsmRrMessage(rr_msg))); |
| 1848 | |
| 1849 | /* receive IMM.ASS on MS side */ |
| 1850 | var ImmediateAssignment ia_um; |
| 1851 | ia_um := f_L1CTL_WAIT_IMM_ASS(L1CTL, ra, fn); |
| 1852 | /* enable dedicated mode */ |
| 1853 | f_L1CTL_DM_EST_REQ_IA(L1CTL, ia_um); |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 1854 | /* enable encryption, if requested */ |
| 1855 | if (encr_enable) { |
| 1856 | var uint8_t alg_id := f_alg_id_to_l1ctl(g_pars.encr.alg_id); |
| 1857 | f_L1CTL_CRYPTO_REQ(L1CTL, g_pars.chan_nr, alg_id, g_pars.encr.key); |
| 1858 | } |
Harald Welte | fa45e9e | 2018-03-10 18:59:03 +0100 | [diff] [blame] | 1859 | |
| 1860 | g_first_meas_res := true; |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1861 | } |
| 1862 | |
| 1863 | /* establish DChan, verify existance + contents of measurement reports */ |
| 1864 | function f_TC_meas_res_periodic(charstring id) runs on ConnHdlr { |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 1865 | f_l1_tune(L1CTL); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1866 | RSL.clear; |
| 1867 | |
Vadim Yanitskiy | 44ff214 | 2019-01-12 07:04:58 +0700 | [diff] [blame] | 1868 | if (mp_bts_trxc_port != -1) { |
Pau Espin Pedrol | e9571aa | 2018-10-22 17:13:07 +0200 | [diff] [blame] | 1869 | f_trxc_fake_rssi(rxlev2dbm(mp_ul_rxlev_exp)); |
Vadim Yanitskiy | dc8db92 | 2019-06-04 21:58:15 +0700 | [diff] [blame] | 1870 | f_trxc_fake_toffs256(g_pars.l1_pars.timing_offset_256syms); |
Pau Espin Pedrol | 121724c | 2018-09-28 15:58:12 +0200 | [diff] [blame] | 1871 | } |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1872 | |
| 1873 | f_est_dchan(); |
| 1874 | |
| 1875 | /* run for a number of seconds, send SACCH + FACCH from MS side and verify |
| 1876 | * RSL measurement reports on Abis side */ |
| 1877 | timer T := 8.0; |
| 1878 | T.start; |
| 1879 | alt { |
| 1880 | [] as_l1_sacch(); |
| 1881 | [] as_meas_res(); |
| 1882 | [] as_l1_dcch(); |
| 1883 | [] L1CTL.receive { repeat; } |
| 1884 | [g_Tmeas_exp.running] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1885 | /* 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] | 1886 | * of any earlier errors, so if we reach this timeout, we're good */ |
| 1887 | setverdict(pass); |
| 1888 | } |
| 1889 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1890 | 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] | 1891 | } |
| 1892 | } |
| 1893 | f_rsl_chan_deact(); |
Harald Welte | 3dc2046 | 2018-03-10 23:03:38 +0100 | [diff] [blame] | 1894 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1895 | } |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 1896 | |
Eric Wild | ae8f262 | 2019-06-18 17:05:11 +0200 | [diff] [blame] | 1897 | function f_check_meas_bs_power_level(integer level) runs on ConnHdlr { |
| 1898 | timer T := 8.0; |
| 1899 | T.start; |
| 1900 | var RSL_Message rsl; |
| 1901 | alt { |
| 1902 | [] as_l1_sacch(); |
| 1903 | [] L1CTL.receive { repeat; } |
| 1904 | [] RSL.receive(tr_RSL_MEAS_RES(g_chan_nr, ?, ?, ?)) -> value rsl { |
| 1905 | if (rsl.ies[3].body.bs_power.power_level == level) { |
| 1906 | setverdict(pass) |
| 1907 | } else { |
| 1908 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Received wrong BS power level in MEAS RES ", rsl)); |
| 1909 | } |
| 1910 | } |
| 1911 | [] T.timeout { |
| 1912 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "No MEAS RES received at all"); |
| 1913 | } |
| 1914 | } |
| 1915 | } |
| 1916 | |
| 1917 | /* see if the rsl meas res contains our expeced bs power level |
| 1918 | bs power set during assignment */ |
| 1919 | function f_TC_rsl_bs_pwr_static_ass(charstring id) runs on ConnHdlr { |
| 1920 | f_l1_tune(L1CTL); |
| 1921 | RSL.clear; |
| 1922 | |
| 1923 | if (mp_bts_trxc_port != -1) { |
| 1924 | f_trxc_fake_rssi(rxlev2dbm(mp_ul_rxlev_exp)); |
| 1925 | f_trxc_fake_toffs256(g_pars.l1_pars.timing_offset_256syms); |
| 1926 | } |
| 1927 | |
| 1928 | var uint5_t pwr_var := 1; |
| 1929 | var template (value) RSL_IE_BS_Power bs_power := ts_RSL_IE_BS_Power(pwr_var); |
| 1930 | var template (value) RSL_IE pwr := t_RSL_IE(RSL_IE_BS_POWER, RSL_IE_Body:{bs_power := bs_power}); |
| 1931 | |
| 1932 | f_est_dchan(more_ies :={valueof(pwr)}); |
| 1933 | |
| 1934 | f_check_meas_bs_power_level(pwr_var); |
| 1935 | |
| 1936 | f_rsl_chan_deact(); |
| 1937 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 1938 | } |
| 1939 | |
| 1940 | /* see if the rsl meas res contains our expeced bs power level |
| 1941 | bs power set after assignment */ |
| 1942 | function f_TC_rsl_bs_pwr_static_power_control(charstring id) runs on ConnHdlr { |
| 1943 | f_l1_tune(L1CTL); |
| 1944 | RSL.clear; |
| 1945 | |
| 1946 | if (mp_bts_trxc_port != -1) { |
| 1947 | f_trxc_fake_rssi(rxlev2dbm(mp_ul_rxlev_exp)); |
| 1948 | f_trxc_fake_toffs256(g_pars.l1_pars.timing_offset_256syms); |
| 1949 | } |
| 1950 | |
| 1951 | var uint5_t pwr_var := 1; |
| 1952 | var template (value) RSL_IE_BS_Power bs_power := ts_RSL_IE_BS_Power(pwr_var); |
| 1953 | |
| 1954 | f_est_dchan(); |
| 1955 | |
| 1956 | RSL.send(ts_RSL_BS_PWR_CTRL(g_chan_nr, bs_power)); |
| 1957 | |
| 1958 | f_check_meas_bs_power_level(pwr_var); |
| 1959 | |
| 1960 | f_rsl_chan_deact(); |
| 1961 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 1962 | } |
| 1963 | |
| 1964 | testcase TC_rsl_bs_pwr_static_ass() runs on test_CT { |
| 1965 | var ConnHdlr vc_conn; |
| 1966 | var ConnHdlrPars pars; |
| 1967 | f_init(); |
| 1968 | for (var integer tn := 1; tn <= 4; tn := tn+1) { |
| 1969 | pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN)); |
| 1970 | vc_conn := f_start_handler(refers(f_TC_rsl_bs_pwr_static_ass), pars, |
| 1971 | pcu_comp := false, trxc_comp := true); |
| 1972 | vc_conn.done; |
| 1973 | } |
| 1974 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 1975 | } |
| 1976 | |
| 1977 | testcase TC_rsl_bs_pwr_static_power_control() runs on test_CT { |
| 1978 | var ConnHdlr vc_conn; |
| 1979 | var ConnHdlrPars pars; |
| 1980 | f_init(); |
| 1981 | for (var integer tn := 1; tn <= 4; tn := tn+1) { |
| 1982 | pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN)); |
| 1983 | vc_conn := f_start_handler(refers(f_TC_rsl_bs_pwr_static_power_control), pars, |
| 1984 | pcu_comp := false, trxc_comp := true); |
| 1985 | vc_conn.done; |
| 1986 | } |
| 1987 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 1988 | } |
| 1989 | |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 1990 | /* target level -100, first rssi -90, ms power 7, expected increase to 7+6 within 6 seconds, |
| 1991 | second rssi -110, ms power 7+6, expected decrease to 7 within 6 seconds, |
| 1992 | These power levels are valid for all bands and require no special handling */ |
| 1993 | function f_TC_rsl_ms_pwr_dyn_ass_updown(charstring id) runs on ConnHdlr { |
| 1994 | var uint5_t pwr_var := 7; |
| 1995 | var L1ctlDlMessage l1_dl; |
| 1996 | |
| 1997 | f_trxc_fake_rssi(rxlev2dbm(10)); |
| 1998 | f_l1_tune(L1CTL); |
| 1999 | RSL.clear; |
| 2000 | |
| 2001 | var RSL_IE_List addl_ies; |
| 2002 | var template (value) RSL_IE_MS_Power_Parameters pp := (ts_RSL_IE_MS_Power_Parameters(''O)); |
| 2003 | |
| 2004 | addl_ies := { |
| 2005 | valueof(t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ts_RSL_IE_MS_Power(pwr_var)})), |
| 2006 | valueof(t_RSL_IE(RSL_IE_MS_POWER_PARAM, RSL_IE_Body:{ms_power_params := pp})) |
| 2007 | }; |
| 2008 | |
| 2009 | /* establish with power parameters */ |
| 2010 | f_est_dchan(more_ies := addl_ies); |
| 2011 | |
| 2012 | /* set a high value to ensure L1 power control level increases */ |
| 2013 | f_trxc_fake_rssi(rxlev2dbm(20)); |
| 2014 | |
| 2015 | timer T2 := 6.0; |
| 2016 | T2.start; |
| 2017 | alt { |
| 2018 | [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl { |
| 2019 | if( not(oct2int(l1_dl.payload.data_ind.payload[0]) > (pwr_var+6))){ |
| 2020 | repeat; |
| 2021 | } |
| 2022 | T2.stop; |
| 2023 | } |
| 2024 | [] L1CTL.receive { repeat; } |
| 2025 | [] T2.timeout { |
| 2026 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2027 | "Power Level in L1 header has not increased sufficiently"); |
| 2028 | } |
| 2029 | } |
| 2030 | |
| 2031 | /* set a low value to ensure L1 power control level decreases */ |
| 2032 | f_trxc_fake_rssi(rxlev2dbm(0)); |
| 2033 | |
| 2034 | timer T4 := 6.0; |
| 2035 | T4.start; |
| 2036 | alt { |
| 2037 | [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl { |
| 2038 | if( not(oct2int(l1_dl.payload.data_ind.payload[0]) <= (pwr_var))){ |
| 2039 | repeat; |
| 2040 | } |
| 2041 | T4.stop; |
| 2042 | setverdict(pass, "Power level in L1 decreased/increased as expected"); |
| 2043 | } |
| 2044 | [] L1CTL.receive { repeat; } |
| 2045 | [] T4.timeout { |
| 2046 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2047 | "Power Level in L1 header has not decreased sufficiently"); |
| 2048 | } |
| 2049 | } |
| 2050 | |
| 2051 | f_rsl_chan_deact(); |
| 2052 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 2053 | |
| 2054 | } |
| 2055 | |
| 2056 | /* check that we do not exceed the max power */ |
| 2057 | function f_TC_rsl_ms_pwr_dyn_max(charstring id) runs on ConnHdlr { |
| 2058 | var uint5_t pwr_var := 7; |
| 2059 | var L1ctlDlMessage l1_dl; |
| 2060 | |
| 2061 | /* set a low value to ensure power increases */ |
| 2062 | f_trxc_fake_rssi(rxlev2dbm(10)); |
| 2063 | f_l1_tune(L1CTL); |
| 2064 | RSL.clear; |
| 2065 | |
| 2066 | var RSL_IE_List addl_ies; |
| 2067 | var template (value) RSL_IE_MS_Power_Parameters pp := (ts_RSL_IE_MS_Power_Parameters(''O)); |
| 2068 | |
| 2069 | addl_ies := { |
| 2070 | valueof(t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ts_RSL_IE_MS_Power(pwr_var)})), |
| 2071 | valueof(t_RSL_IE(RSL_IE_MS_POWER_PARAM, RSL_IE_Body:{ms_power_params := pp})) |
| 2072 | }; |
| 2073 | |
| 2074 | /* establish with power parameters */ |
| 2075 | f_est_dchan(more_ies := addl_ies); |
| 2076 | |
| 2077 | timer T1 := 10.0; |
| 2078 | T1.start; |
| 2079 | alt { |
| 2080 | [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl { repeat; } |
| 2081 | [] L1CTL.receive { repeat; } |
| 2082 | [] T1.timeout { |
| 2083 | if( oct2int(l1_dl.payload.data_ind.payload[0]) != pwr_var){ |
| 2084 | setverdict(fail, "Power level in L1 header should not have changed"); |
| 2085 | } |
| 2086 | } |
| 2087 | } |
| 2088 | |
| 2089 | f_rsl_chan_deact(); |
| 2090 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 2091 | |
| 2092 | } |
| 2093 | |
| 2094 | /* see if we reach the band max power */ |
| 2095 | function f_TC_rsl_ms_pwr_dyn_up(charstring id) runs on ConnHdlr { |
| 2096 | var L1ctlDlMessage l1_dl; |
| 2097 | var uint5_t pwr_var := 15; |
| 2098 | var uint5_t pwr_max_var := f_get_max_power_from_band(); |
| 2099 | |
| 2100 | /* set a low value to ensure power increases */ |
| 2101 | f_trxc_fake_rssi(rxlev2dbm(10)); |
| 2102 | f_l1_tune(L1CTL); |
| 2103 | RSL.clear; |
| 2104 | |
| 2105 | var template (value) RSL_IE_MS_Power ms_power := ts_RSL_IE_MS_Power(pwr_var); |
| 2106 | var template (value) RSL_IE pwr := t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ms_power}); |
| 2107 | |
| 2108 | /* establish with fixed power level */ |
| 2109 | f_est_dchan(more_ies :={valueof(pwr)}); |
| 2110 | |
| 2111 | /* check our initial power level */ |
| 2112 | f_wait_for_l1_power_level(pwr_var); |
| 2113 | |
| 2114 | /* update power param to enable power loop |
| 2115 | 48.058 The maximum power to be used is indicated in the BS and MS Power elements respectively. */ |
| 2116 | RSL.send(ts_RSL_MS_PWR_CTRL_with_pp(g_chan_nr, pwr_max_var)); |
| 2117 | |
| 2118 | /* wait, then check that our power level was reduced */ |
| 2119 | timer T1 := 10.0; |
| 2120 | T1.start; |
| 2121 | alt { |
| 2122 | [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl { repeat; } |
| 2123 | [] L1CTL.receive { repeat; } |
| 2124 | [] T1.timeout { |
| 2125 | var int8_t rcv := oct2int(l1_dl.payload.data_ind.payload[0]); |
| 2126 | if( f_power_level_is_highest_dbm(rcv) ){ |
| 2127 | setverdict(pass, "Power level in L1 header reduced as expected"); |
| 2128 | } else { |
| 2129 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2130 | log2str("Power Level in L1 header did not reach the expected value, e:",pwr_max_var," r:",rcv)); |
| 2131 | } |
| 2132 | } |
| 2133 | } |
| 2134 | |
| 2135 | f_rsl_chan_deact(); |
| 2136 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 2137 | |
| 2138 | } |
| 2139 | |
| 2140 | /* see if we reach the band min power */ |
| 2141 | function f_TC_rsl_ms_pwr_dyn_down(charstring id) runs on ConnHdlr { |
| 2142 | var L1ctlDlMessage l1_dl; |
| 2143 | |
| 2144 | /* set a high value to ensure power decreases */ |
| 2145 | f_trxc_fake_rssi(rxlev2dbm(50)); |
| 2146 | f_l1_tune(L1CTL); |
| 2147 | RSL.clear; |
| 2148 | |
| 2149 | var uint5_t pwr_var := 5; |
| 2150 | var uint5_t pwr_target_val := 15; |
| 2151 | |
| 2152 | var template (value) RSL_IE_MS_Power ms_power := ts_RSL_IE_MS_Power(pwr_var); |
| 2153 | var template (value) RSL_IE pwr := t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ms_power}); |
| 2154 | |
| 2155 | /* establish with fixed power level */ |
| 2156 | f_est_dchan(more_ies :={valueof(pwr)}); |
| 2157 | |
| 2158 | /* check our initial power level */ |
| 2159 | f_wait_for_l1_power_level(pwr_var); |
| 2160 | |
| 2161 | /* update power param to enable power loop |
| 2162 | as per spec the supplied ms power IE should set the max allowed power...*/ |
| 2163 | RSL.send(ts_RSL_MS_PWR_CTRL_with_pp(g_chan_nr, pwr_var)); |
| 2164 | |
| 2165 | /* wait, then check that our power level was increased */ |
| 2166 | timer T1 := 10.0; |
| 2167 | T1.start; |
| 2168 | alt { |
| 2169 | [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl { repeat; } |
| 2170 | [] L1CTL.receive { repeat; } |
| 2171 | [] T1.timeout { |
| 2172 | if( f_power_level_is_lowest_dbm(oct2int(l1_dl.payload.data_ind.payload[0])) ){ |
| 2173 | setverdict(pass, "Power level in L1 header increased to lowest power value"); |
| 2174 | } else { |
| 2175 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2176 | "Power level in L1 header NOT increased to lowest power value"); |
| 2177 | } |
| 2178 | } |
| 2179 | } |
| 2180 | |
| 2181 | f_rsl_chan_deact(); |
| 2182 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 2183 | |
| 2184 | } |
| 2185 | |
Eric Wild | 095024b | 2019-06-17 15:08:57 +0200 | [diff] [blame] | 2186 | /* see if we change the power level without receiving power parameters, which should not happen |
| 2187 | rsl chan act WITHOUT power parameters */ |
Eric Wild | 280ccb8 | 2019-06-17 11:11:52 +0200 | [diff] [blame] | 2188 | function f_TC_rsl_ms_pwr_dyn_active(charstring id) runs on ConnHdlr { |
| 2189 | var L1ctlDlMessage l1_dl; |
| 2190 | |
| 2191 | /* set a high value to ensure power decreases */ |
| 2192 | f_trxc_fake_rssi(rxlev2dbm(50)); |
| 2193 | f_l1_tune(L1CTL); |
| 2194 | RSL.clear; |
| 2195 | |
| 2196 | var uint5_t pwr_var := 5; |
| 2197 | |
| 2198 | var template (value) RSL_IE_MS_Power ms_power := ts_RSL_IE_MS_Power(pwr_var); |
| 2199 | var template (value) RSL_IE pwr := t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ms_power}); |
| 2200 | |
| 2201 | /* establish with fixed power level */ |
| 2202 | f_est_dchan(more_ies :={valueof(pwr)}); |
| 2203 | |
| 2204 | /* check our initial power level */ |
| 2205 | f_wait_for_l1_power_level(pwr_var); |
| 2206 | |
| 2207 | /* wait, then check that our power level did not change */ |
| 2208 | timer T1 := 10.0; |
| 2209 | T1.start; |
| 2210 | alt { |
| 2211 | [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl { |
| 2212 | if ( oct2int(l1_dl.payload.data_ind.payload[0]) != pwr_var) { |
| 2213 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2214 | "BS power control should not be active unless we receive a power parameters IE!"); |
| 2215 | } |
| 2216 | repeat; |
| 2217 | } |
| 2218 | [] L1CTL.receive { repeat; } |
| 2219 | [] T1.timeout { setverdict(pass); } |
| 2220 | } |
| 2221 | |
| 2222 | f_rsl_chan_deact(); |
| 2223 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 2224 | |
| 2225 | } |
| 2226 | |
Eric Wild | 095024b | 2019-06-17 15:08:57 +0200 | [diff] [blame] | 2227 | /* see if we change the power level without receiving power parameters, which should not happen |
| 2228 | ms power control WITHOUT power parameters */ |
| 2229 | function f_TC_rsl_ms_pwr_dyn_active2(charstring id) runs on ConnHdlr { |
| 2230 | var L1ctlDlMessage l1_dl; |
| 2231 | |
| 2232 | /* set a high value to ensure power decreases */ |
| 2233 | f_trxc_fake_rssi(rxlev2dbm(50)); |
| 2234 | f_l1_tune(L1CTL); |
| 2235 | RSL.clear; |
| 2236 | |
| 2237 | var uint5_t pwr_var := 5; |
| 2238 | |
| 2239 | var template (value) RSL_IE_MS_Power ms_power := ts_RSL_IE_MS_Power(pwr_var); |
| 2240 | var template (value) RSL_IE pwr := t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ms_power}); |
| 2241 | |
| 2242 | /* establish with fixed power level */ |
| 2243 | f_est_dchan(more_ies :={valueof(pwr)}); |
| 2244 | |
| 2245 | /* check our initial power level */ |
| 2246 | f_wait_for_l1_power_level(pwr_var); |
| 2247 | |
| 2248 | /* pwr control without power params IE, should NOT activate MS power control*/ |
| 2249 | RSL.send(ts_RSL_MS_PWR_CTRL(g_chan_nr, ms_power)); |
| 2250 | |
| 2251 | /* wait, then check that our power level did not change */ |
| 2252 | timer T1 := 10.0; |
| 2253 | T1.start; |
| 2254 | alt { |
| 2255 | [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl { |
| 2256 | if ( oct2int(l1_dl.payload.data_ind.payload[0]) != pwr_var) { |
| 2257 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2258 | "BS power control should not be active unless we receive a power parameters IE!"); |
| 2259 | } |
| 2260 | repeat; |
| 2261 | } |
| 2262 | [] L1CTL.receive { repeat; } |
| 2263 | [] T1.timeout { setverdict(pass); } |
| 2264 | } |
| 2265 | |
| 2266 | f_rsl_chan_deact(); |
| 2267 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 2268 | |
| 2269 | } |
| 2270 | |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 2271 | function f_wait_for_l1_power_level(integer level) runs on ConnHdlr { |
| 2272 | var L1ctlDlMessage l1_dl; |
| 2273 | timer T0 := 10.0; |
| 2274 | T0.start; |
| 2275 | alt { |
| 2276 | [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl { |
| 2277 | if (not (l1_dl.payload.data_ind.payload[0] == int2oct(level, 1))) { |
| 2278 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2279 | "Power level in L1 header != signaled (RSL) power level."); |
| 2280 | } |
| 2281 | } |
| 2282 | [] L1CTL.receive { repeat; } |
| 2283 | [] T0.timeout { |
| 2284 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2285 | "Timeout waiting for initial power level"); |
| 2286 | } |
| 2287 | } |
| 2288 | T0.stop; |
| 2289 | } |
| 2290 | |
| 2291 | private function f_power_level_is_lowest_dbm(integer level) runs on ConnHdlr return boolean { |
| 2292 | var IntegerRecord min_dbm_level; |
| 2293 | var IntegerRecord max_dbm_level; |
| 2294 | var IntegerRecord x := f_power_from_band(g_pars.bts0_band, min_dbm_level, max_dbm_level); |
| 2295 | |
| 2296 | for (var integer i := 0; i < sizeof(min_dbm_level); i := i+1) { |
| 2297 | if (min_dbm_level[i] == level) { |
| 2298 | return true; |
| 2299 | } |
| 2300 | } |
| 2301 | return false; |
| 2302 | } |
| 2303 | |
| 2304 | private function f_power_level_is_highest_dbm(integer level) runs on ConnHdlr return boolean { |
| 2305 | var IntegerRecord min_dbm_level; |
| 2306 | var IntegerRecord max_dbm_level; |
| 2307 | var IntegerRecord x := f_power_from_band(g_pars.bts0_band, min_dbm_level, max_dbm_level); |
| 2308 | |
| 2309 | for (var integer i := 0; i < sizeof(max_dbm_level); i := i+1) { |
| 2310 | if (max_dbm_level[i] == level) { |
| 2311 | return true; |
| 2312 | } |
| 2313 | } |
| 2314 | return false; |
| 2315 | } |
| 2316 | |
| 2317 | private function f_get_max_power_from_band() runs on ConnHdlr return integer { |
| 2318 | var IntegerRecord min_dbm_level; |
| 2319 | var IntegerRecord max_dbm_level; |
| 2320 | var IntegerRecord x := f_power_from_band(g_pars.bts0_band, min_dbm_level, max_dbm_level); |
| 2321 | return max_dbm_level[0]; |
| 2322 | } |
| 2323 | |
| 2324 | type charstring BtsBand ("GSM450","GSM480","GSM750","GSM810","GSM850","GSM900","DCS1800","PCS1900"); |
| 2325 | template charstring BtsBand_allGSM:= pattern "GSM???"; |
| 2326 | private function f_power_from_band(in BtsBand band, out IntegerRecord min_dbm_level, out IntegerRecord max_dbm_level) return IntegerRecord { |
| 2327 | // 45.005 4.1.1 |
| 2328 | var IntegerRecord gsm_power :={31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, |
| 2329 | 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, |
| 2330 | 2, 1, 0}; |
| 2331 | var IntegerRecord dcs_power :={28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, |
| 2332 | 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 31, 30, 29}; |
| 2333 | var IntegerRecord pcs_power :={15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 31, 30}; |
| 2334 | var IntegerRecord rv; |
| 2335 | |
| 2336 | select(band){ |
| 2337 | case (BtsBand_allGSM){ |
| 2338 | rv := gsm_power; |
| 2339 | min_dbm_level := {31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19} ; |
| 2340 | max_dbm_level := {2, 1, 0}; |
| 2341 | } |
| 2342 | case("DCS1800"){ |
| 2343 | rv := dcs_power; |
| 2344 | min_dbm_level := {28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15}; |
| 2345 | max_dbm_level := {0, 29}; // let's cheat here, assume MS_TXPWR_MAX_CCH might be being broadcast, so maybe no 29,30,31 |
| 2346 | } |
| 2347 | case("PCS1900"){ |
| 2348 | rv := pcs_power; |
| 2349 | min_dbm_level := {15}; |
| 2350 | max_dbm_level := {30}; |
| 2351 | } |
| 2352 | } |
| 2353 | |
| 2354 | return rv; |
| 2355 | } |
| 2356 | |
| 2357 | private function f_vty_get_bts0_band() runs on test_CT return BtsBand { |
| 2358 | return f_vty_transceive_match_regex(BTSVTY, "show bts 0", "BTS 0 is of \w+ type in band (\w+),*", 0); |
| 2359 | } |
| 2360 | |
| 2361 | testcase TC_rsl_ms_pwr_dyn_ass_updown() runs on test_CT { |
| 2362 | var ConnHdlr vc_conn; |
| 2363 | var ConnHdlrPars pars; |
| 2364 | f_init(); |
| 2365 | f_vty_config(BTSVTY, "phy 0", "osmotrx ms-power-loop -100"); |
| 2366 | for (var integer tn := 1; tn <= 1; tn := tn+1) { |
| 2367 | pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN)); |
| 2368 | pars.bts0_band := f_vty_get_bts0_band(); |
| 2369 | vc_conn := f_start_handler(refers(f_TC_rsl_ms_pwr_dyn_ass_updown), pars, trxc_comp := true); |
| 2370 | vc_conn.done; |
| 2371 | } |
| 2372 | f_vty_config(BTSVTY, "phy 0", "no osmotrx ms-power-loop"); |
| 2373 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 2374 | } |
| 2375 | |
| 2376 | testcase TC_rsl_ms_pwr_dyn_up() runs on test_CT { |
| 2377 | var ConnHdlr vc_conn; |
| 2378 | var ConnHdlrPars pars; |
| 2379 | f_init(); |
| 2380 | f_vty_config(BTSVTY, "phy 0", "osmotrx ms-power-loop -10"); |
| 2381 | for (var integer tn := 1; tn <= 1; tn := tn+1) { |
| 2382 | pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN)); |
| 2383 | pars.bts0_band := f_vty_get_bts0_band(); |
| 2384 | vc_conn := f_start_handler(refers(f_TC_rsl_ms_pwr_dyn_up), pars, trxc_comp := true); |
| 2385 | vc_conn.done; |
| 2386 | } |
| 2387 | f_vty_config(BTSVTY, "phy 0", "no osmotrx ms-power-loop"); |
| 2388 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 2389 | } |
| 2390 | |
| 2391 | testcase TC_rsl_ms_pwr_dyn_max() runs on test_CT { |
| 2392 | var ConnHdlr vc_conn; |
| 2393 | var ConnHdlrPars pars; |
| 2394 | f_init(); |
| 2395 | f_vty_config(BTSVTY, "phy 0", "osmotrx ms-power-loop -10"); |
| 2396 | for (var integer tn := 1; tn <= 1; tn := tn+1) { |
| 2397 | pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN)); |
| 2398 | pars.bts0_band := f_vty_get_bts0_band(); |
| 2399 | vc_conn := f_start_handler(refers(f_TC_rsl_ms_pwr_dyn_max), pars, trxc_comp := true); |
| 2400 | vc_conn.done; |
| 2401 | } |
| 2402 | f_vty_config(BTSVTY, "phy 0", "no osmotrx ms-power-loop"); |
| 2403 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 2404 | } |
| 2405 | |
| 2406 | testcase TC_rsl_ms_pwr_dyn_down() runs on test_CT { |
| 2407 | var ConnHdlr vc_conn; |
| 2408 | var ConnHdlrPars pars; |
| 2409 | f_init(); |
| 2410 | f_vty_config(BTSVTY, "phy 0", "osmotrx ms-power-loop -100"); |
| 2411 | for (var integer tn := 1; tn <= 1; tn := tn+1) { |
| 2412 | pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN)); |
| 2413 | pars.bts0_band := f_vty_get_bts0_band(); |
| 2414 | vc_conn := f_start_handler(refers(f_TC_rsl_ms_pwr_dyn_down), pars, trxc_comp := true); |
| 2415 | vc_conn.done; |
| 2416 | } |
| 2417 | f_vty_config(BTSVTY, "phy 0", "no osmotrx ms-power-loop"); |
| 2418 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 2419 | } |
| 2420 | |
Eric Wild | 280ccb8 | 2019-06-17 11:11:52 +0200 | [diff] [blame] | 2421 | testcase TC_rsl_ms_pwr_dyn_active() runs on test_CT { |
| 2422 | var ConnHdlr vc_conn; |
| 2423 | var ConnHdlrPars pars; |
| 2424 | f_init(); |
| 2425 | f_vty_config(BTSVTY, "phy 0", "osmotrx ms-power-loop -100"); |
| 2426 | for (var integer tn := 1; tn <= 1; tn := tn+1) { |
| 2427 | pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN)); |
| 2428 | pars.bts0_band := f_vty_get_bts0_band(); |
| 2429 | vc_conn := f_start_handler(refers(f_TC_rsl_ms_pwr_dyn_active), pars, trxc_comp := true); |
| 2430 | vc_conn.done; |
| 2431 | } |
| 2432 | f_vty_config(BTSVTY, "phy 0", "no osmotrx ms-power-loop"); |
| 2433 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 2434 | } |
| 2435 | |
Eric Wild | 095024b | 2019-06-17 15:08:57 +0200 | [diff] [blame] | 2436 | testcase TC_rsl_ms_pwr_dyn_active2() runs on test_CT { |
| 2437 | var ConnHdlr vc_conn; |
| 2438 | var ConnHdlrPars pars; |
| 2439 | f_init(); |
| 2440 | f_vty_config(BTSVTY, "phy 0", "osmotrx ms-power-loop -100"); |
| 2441 | for (var integer tn := 1; tn <= 1; tn := tn+1) { |
| 2442 | pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN)); |
| 2443 | pars.bts0_band := f_vty_get_bts0_band(); |
| 2444 | vc_conn := f_start_handler(refers(f_TC_rsl_ms_pwr_dyn_active2), pars, trxc_comp := true); |
| 2445 | vc_conn.done; |
| 2446 | } |
| 2447 | f_vty_config(BTSVTY, "phy 0", "no osmotrx ms-power-loop"); |
| 2448 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 2449 | } |
| 2450 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2451 | testcase TC_meas_res_sign_tchf() runs on test_CT { |
| 2452 | var ConnHdlr vc_conn; |
| 2453 | var ConnHdlrPars pars; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 2454 | f_init(); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2455 | for (var integer tn := 1; tn <= 4; tn := tn+1) { |
| 2456 | pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN)); |
Vadim Yanitskiy | f4e997c | 2019-06-04 21:40:33 +0700 | [diff] [blame] | 2457 | vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars, |
| 2458 | pcu_comp := false, trxc_comp := true); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2459 | vc_conn.done; |
| 2460 | } |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 2461 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2462 | } |
| 2463 | testcase TC_meas_res_sign_tchh() runs on test_CT { |
| 2464 | var ConnHdlr vc_conn; |
| 2465 | var ConnHdlrPars pars; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 2466 | f_init(); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2467 | for (var integer ss := 0; ss <= 1; ss := ss+1) { |
| 2468 | pars := valueof(t_Pars(t_RslChanNr_Lm(5, ss), ts_RSL_ChanMode_SIGN)); |
Eric Wild | 5b9ef14 | 2019-07-11 19:28:02 +0200 | [diff] [blame] | 2469 | vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars, |
| 2470 | pcu_comp := false, trxc_comp := true); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2471 | vc_conn.done; |
| 2472 | } |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 2473 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2474 | } |
| 2475 | testcase TC_meas_res_sign_sdcch4() runs on test_CT { |
| 2476 | var ConnHdlr vc_conn; |
| 2477 | var ConnHdlrPars pars; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 2478 | f_init(); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2479 | for (var integer ss := 0; ss <= 3; ss := ss+1) { |
| 2480 | pars := valueof(t_Pars(t_RslChanNr_SDCCH4(0, ss), ts_RSL_ChanMode_SIGN)); |
Eric Wild | 5b9ef14 | 2019-07-11 19:28:02 +0200 | [diff] [blame] | 2481 | vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars, |
| 2482 | pcu_comp := false, trxc_comp := true); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2483 | vc_conn.done; |
| 2484 | } |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 2485 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2486 | } |
| 2487 | testcase TC_meas_res_sign_sdcch8() runs on test_CT { |
| 2488 | var ConnHdlr vc_conn; |
| 2489 | var ConnHdlrPars pars; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 2490 | f_init(); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2491 | for (var integer ss := 0; ss <= 7; ss := ss+1) { |
| 2492 | pars := valueof(t_Pars(t_RslChanNr_SDCCH8(6, ss), ts_RSL_ChanMode_SIGN)); |
Eric Wild | 5b9ef14 | 2019-07-11 19:28:02 +0200 | [diff] [blame] | 2493 | vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars, |
| 2494 | pcu_comp := false, trxc_comp := true); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2495 | vc_conn.done; |
| 2496 | } |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 2497 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2498 | } |
Harald Welte | 685d598 | 2018-02-27 20:42:05 +0100 | [diff] [blame] | 2499 | testcase TC_meas_res_sign_tchh_toa256() runs on test_CT { |
| 2500 | var ConnHdlr vc_conn; |
| 2501 | var ConnHdlrPars pars; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 2502 | f_init(); |
Harald Welte | 685d598 | 2018-02-27 20:42:05 +0100 | [diff] [blame] | 2503 | f_vty_config(BTSVTY, "bts 0", "supp-meas-info toa256"); |
| 2504 | for (var integer ss := 0; ss <= 1; ss := ss+1) { |
| 2505 | pars := valueof(t_Pars(t_RslChanNr_Lm(5, ss), ts_RSL_ChanMode_SIGN)); |
| 2506 | pars.l1_pars.toa256_enabled := true; |
| 2507 | vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars); |
| 2508 | vc_conn.done; |
| 2509 | } |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 2510 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 685d598 | 2018-02-27 20:42:05 +0100 | [diff] [blame] | 2511 | } |
| 2512 | |
Philipp Maier | 4d1e9c9 | 2018-12-20 11:11:56 +0100 | [diff] [blame] | 2513 | /* establish DChan, and send MS POWER CONTROL messages via RSL, verify that |
| 2514 | * the BTS is forwarding those values to the MS via the SACCH L1 header. */ |
| 2515 | function f_tc_rsl_ms_pwr_ctrl(charstring id) runs on ConnHdlr { |
| 2516 | var L1ctlDlMessage l1_dl; |
| 2517 | var RSL_IE_MS_Power ms_power; |
| 2518 | var RSL_Message rsl; |
| 2519 | var uint5_t power_level := 0; |
| 2520 | |
| 2521 | f_l1_tune(L1CTL); |
| 2522 | RSL.clear; |
| 2523 | |
| 2524 | f_est_dchan(); |
| 2525 | |
| 2526 | ms_power.reserved := 0; |
| 2527 | ms_power.fpc_epc := false; |
| 2528 | |
| 2529 | /* Send the first power control command. This will disable any BTS/TRX |
| 2530 | * internal power control and switch the MS (which is not in scope of |
| 2531 | * this test) to a constant power level. We start with a power level |
| 2532 | * of 0 */ |
| 2533 | ms_power.power_level := power_level; |
| 2534 | rsl := valueof(ts_RSL_MS_PWR_CTRL(g_chan_nr, ms_power)); |
| 2535 | RSL.send(rsl); |
| 2536 | |
| 2537 | alt { |
| 2538 | |
| 2539 | /* Pick all SACCH blocks for checking */ |
| 2540 | [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl { |
| 2541 | |
| 2542 | /* The first byte of the L1 header contains the power level. |
| 2543 | * The reserved bits and the fpc bit is set to 0, so we may |
| 2544 | * compare directly. */ |
| 2545 | if (not (l1_dl.payload.data_ind.payload[0] == int2oct(power_level, 1))) { |
| 2546 | setverdict(fail, "Power level in L1 header does not match the signaled (RSL) power level."); |
| 2547 | } |
| 2548 | |
| 2549 | /* Signal a new power level via RSL for the next turn. */ |
| 2550 | if (power_level < 31) { |
| 2551 | power_level := power_level + 1; |
| 2552 | ms_power.power_level := power_level; |
| 2553 | rsl := valueof(ts_RSL_MS_PWR_CTRL(g_chan_nr, ms_power)); |
| 2554 | RSL.send(rsl); |
| 2555 | repeat; |
| 2556 | } |
| 2557 | |
| 2558 | } |
| 2559 | |
| 2560 | /* Ignore all other blocks */ |
| 2561 | [] L1CTL.receive { repeat; } |
| 2562 | |
| 2563 | } |
| 2564 | |
| 2565 | f_rsl_chan_deact(); |
| 2566 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 2567 | |
| 2568 | setverdict(pass); |
| 2569 | } |
| 2570 | |
| 2571 | testcase TC_rsl_ms_pwr_ctrl() runs on test_CT { |
| 2572 | var ConnHdlr vc_conn; |
| 2573 | var ConnHdlrPars pars; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 2574 | f_init(); |
Philipp Maier | 4d1e9c9 | 2018-12-20 11:11:56 +0100 | [diff] [blame] | 2575 | |
| 2576 | for (var integer tn := 1; tn <= 4; tn := tn+1) { |
| 2577 | pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN)); |
| 2578 | vc_conn := f_start_handler(refers(f_tc_rsl_ms_pwr_ctrl), pars); |
| 2579 | vc_conn.done; |
| 2580 | } |
| 2581 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 2582 | } |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2583 | |
Eric Wild | 6833cc9 | 2019-05-23 19:34:44 +0200 | [diff] [blame] | 2584 | /* establish DChan, verify that the BTS sets the TA in the first SACCH L1 header. |
| 2585 | TA for the IMM ASS messages is still controlled by g_pars.l1_pars.ms_actual_ta! */ |
| 2586 | function f_tc_rsl_chan_initial_ta(charstring id) runs on ConnHdlr { |
| 2587 | var L1ctlDlMessage l1_dl; |
| 2588 | var uint5_t ta_to_test := 16; |
| 2589 | |
| 2590 | |
| 2591 | f_l1_tune(L1CTL); |
| 2592 | RSL.clear; |
| 2593 | |
| 2594 | /* tell fake_trx to use a given timing offset for all bursts */ |
Vadim Yanitskiy | dc8db92 | 2019-06-04 21:58:15 +0700 | [diff] [blame] | 2595 | f_trxc_fake_toffs256(ta_to_test*256); |
Eric Wild | 6833cc9 | 2019-05-23 19:34:44 +0200 | [diff] [blame] | 2596 | |
| 2597 | f_est_dchan(more_ies :={valueof(t_RSL_IE(RSL_IE_TIMING_ADVANCE, RSL_IE_Body:{timing_adv := ta_to_test}))} ); |
| 2598 | |
| 2599 | |
| 2600 | alt { |
| 2601 | |
| 2602 | /* Pick all SACCH blocks for checking */ |
| 2603 | [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl { |
| 2604 | |
| 2605 | /* The second byte of the L1 header contains the TA. */ |
| 2606 | if (not (l1_dl.payload.data_ind.payload[1] == int2oct(ta_to_test, 1))) { |
| 2607 | setverdict(fail, "TA in L1 header does not match the signaled (RSL) TA."); |
| 2608 | } |
| 2609 | |
| 2610 | } |
| 2611 | |
| 2612 | /* Ignore all other blocks */ |
| 2613 | [] L1CTL.receive { repeat; } |
| 2614 | |
| 2615 | } |
| 2616 | |
| 2617 | f_rsl_chan_deact(); |
| 2618 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 2619 | |
| 2620 | setverdict(pass); |
| 2621 | } |
| 2622 | |
| 2623 | testcase TC_rsl_chan_initial_ta() runs on test_CT { |
| 2624 | var ConnHdlr vc_conn; |
| 2625 | var ConnHdlrPars pars; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 2626 | f_init(); |
Eric Wild | 6833cc9 | 2019-05-23 19:34:44 +0200 | [diff] [blame] | 2627 | pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
Vadim Yanitskiy | f4e997c | 2019-06-04 21:40:33 +0700 | [diff] [blame] | 2628 | vc_conn := f_start_handler(refers(f_tc_rsl_chan_initial_ta), pars, |
| 2629 | pcu_comp := false, trxc_comp := true); |
Eric Wild | 6833cc9 | 2019-05-23 19:34:44 +0200 | [diff] [blame] | 2630 | vc_conn.done; |
| 2631 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 2632 | } |
| 2633 | |
Eric Wild | e57e1a6 | 2019-05-28 13:30:55 +0200 | [diff] [blame] | 2634 | /* establish DChan, verify that the BTS sets MS power in the first SACCH L1 header. */ |
| 2635 | function f_tc_rsl_chan_initial_ms_pwr(charstring id) runs on ConnHdlr { |
| 2636 | var L1ctlDlMessage l1_dl; |
| 2637 | var uint5_t ms_power_level := 7; |
| 2638 | |
| 2639 | var RSL_IE_MS_Power ms_power; |
| 2640 | ms_power.reserved := 0; |
| 2641 | ms_power.fpc_epc := false; |
| 2642 | ms_power.power_level := ms_power_level; |
| 2643 | |
| 2644 | f_l1_tune(L1CTL); |
| 2645 | RSL.clear; |
| 2646 | |
| 2647 | f_est_dchan(more_ies :={valueof(t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ms_power}))} ); |
| 2648 | |
| 2649 | timer T := 1.0; |
| 2650 | T.start; |
| 2651 | alt { |
| 2652 | /* Pick all SACCH blocks for checking */ |
| 2653 | [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl { |
| 2654 | /* The first byte of the L1 header contains the power level.. */ |
| 2655 | if (not (l1_dl.payload.data_ind.payload[0] == int2oct(ms_power_level, 1))) { |
| 2656 | setverdict(fail, "Power Level in L1 header does not match the signaled (RSL) MS Power Level."); |
| 2657 | } |
| 2658 | } |
| 2659 | /* Ignore all other blocks */ |
| 2660 | [] L1CTL.receive { repeat; } |
| 2661 | [] T.timeout { |
| 2662 | setverdict(fail, "Power Level in L1 header does not match the signaled (RSL) MS Power Level."); |
| 2663 | } |
| 2664 | } |
| 2665 | |
| 2666 | f_rsl_chan_deact(); |
| 2667 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 2668 | setverdict(pass); |
| 2669 | } |
| 2670 | |
| 2671 | testcase TC_rsl_chan_initial_ms_pwr() runs on test_CT { |
| 2672 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 2673 | f_testmatrix_each_chan(pars, refers(f_tc_rsl_chan_initial_ms_pwr)); |
| 2674 | } |
| 2675 | |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 2676 | /* 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] | 2677 | private function f_TC_conn_fail_crit(charstring id) runs on ConnHdlr { |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 2678 | f_l1_tune(L1CTL); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2679 | RSL.clear; |
| 2680 | |
| 2681 | f_est_dchan(); |
| 2682 | f_sleep(2.0); |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 2683 | L1CTL.send(ts_L1CTL_DM_REL_REQ(g_chan_nr)); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2684 | |
| 2685 | timer T := 40.0; |
| 2686 | T.start; |
| 2687 | alt { |
| 2688 | [] RSL.receive(tr_RSL_CONN_FAIL_IND(g_chan_nr, ?)) { |
| 2689 | setverdict(pass) |
| 2690 | } |
| 2691 | [] RSL.receive { repeat }; |
| 2692 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 2693 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "No CONN FAIL IND received"); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2694 | } |
| 2695 | } |
| 2696 | f_rsl_chan_deact(); |
| 2697 | } |
| 2698 | testcase TC_conn_fail_crit() runs on test_CT { |
| 2699 | var ConnHdlr vc_conn; |
| 2700 | var ConnHdlrPars pars; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 2701 | f_init(); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2702 | pars := valueof(t_Pars(t_RslChanNr_SDCCH8(6, 3), ts_RSL_ChanMode_SIGN)); |
| 2703 | pars.t_guard := 60.0; |
| 2704 | vc_conn := f_start_handler(refers(f_TC_conn_fail_crit), pars); |
| 2705 | vc_conn.done; |
| 2706 | } |
| 2707 | |
Harald Welte | 93640c6 | 2018-02-25 16:59:33 +0100 | [diff] [blame] | 2708 | /*********************************************************************** |
| 2709 | * Paging |
| 2710 | ***********************************************************************/ |
| 2711 | |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 2712 | function tmsi_is_dummy(TMSIP_TMSI_V tmsi) return boolean { |
| 2713 | if (tmsi == 'FFFFFFFF'O) { |
| 2714 | return true; |
| 2715 | } else { |
| 2716 | return false; |
| 2717 | } |
| 2718 | } |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2719 | |
Philipp Maier | 82cb0b1 | 2018-08-31 14:41:39 +0200 | [diff] [blame] | 2720 | type record allowedFn { integer frame_nr } |
| 2721 | template allowedFn bs_ag_blks_res_0 := { frame_nr := (6, 12, 16, 22, 26, 32, 36, 42, 46) } |
| 2722 | template allowedFn bs_ag_blks_res_1 := { frame_nr := (12, 16, 22, 26, 32, 36, 42, 46) } |
| 2723 | template allowedFn bs_ag_blks_res_2 := { frame_nr := (16, 22, 26, 32, 36, 42, 46) } |
| 2724 | template allowedFn bs_ag_blks_res_3 := { frame_nr := (22, 26, 32, 36, 42, 46) } |
| 2725 | template allowedFn bs_ag_blks_res_4 := { frame_nr := (26, 32, 36, 42, 46) } |
| 2726 | template allowedFn bs_ag_blks_res_5 := { frame_nr := (32, 36, 42, 46) } |
| 2727 | template allowedFn bs_ag_blks_res_6 := { frame_nr := (36, 42, 46) } |
| 2728 | template allowedFn bs_ag_blks_res_7 := { frame_nr := (42, 46) } |
| 2729 | function check_pch_fn(integer frame_nr, integer bs_ag_blks_res) runs on test_CT |
| 2730 | { |
| 2731 | var integer frame_nr_51; |
| 2732 | frame_nr_51 := frame_nr mod 51 |
| 2733 | |
| 2734 | var allowedFn fn_check; |
| 2735 | fn_check.frame_nr := frame_nr_51; |
| 2736 | |
| 2737 | if (bs_ag_blks_res < 0 or bs_ag_blks_res > 7) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 2738 | 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] | 2739 | return; |
| 2740 | } |
| 2741 | |
| 2742 | if (bs_ag_blks_res == 0 and match(fn_check, bs_ag_blks_res_0)) { |
| 2743 | return; |
| 2744 | } |
| 2745 | if (bs_ag_blks_res == 1 and match(fn_check, bs_ag_blks_res_1)) { |
| 2746 | return; |
| 2747 | } |
| 2748 | if (bs_ag_blks_res == 2 and match(fn_check, bs_ag_blks_res_2)) { |
| 2749 | return; |
| 2750 | } |
| 2751 | if (bs_ag_blks_res == 3 and match(fn_check, bs_ag_blks_res_3)) { |
| 2752 | return; |
| 2753 | } |
| 2754 | if (bs_ag_blks_res == 4 and match(fn_check, bs_ag_blks_res_4)) { |
| 2755 | return; |
| 2756 | } |
| 2757 | if (bs_ag_blks_res == 5 and match(fn_check, bs_ag_blks_res_5)) { |
| 2758 | return; |
| 2759 | } |
| 2760 | if (bs_ag_blks_res == 6 and match(fn_check, bs_ag_blks_res_6)) { |
| 2761 | return; |
| 2762 | } |
| 2763 | if (bs_ag_blks_res == 7 and match(fn_check, bs_ag_blks_res_7)) { |
| 2764 | return; |
| 2765 | } |
| 2766 | |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 2767 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "received paging on AGCH"); |
Philipp Maier | 82cb0b1 | 2018-08-31 14:41:39 +0200 | [diff] [blame] | 2768 | return; |
| 2769 | } |
| 2770 | |
| 2771 | 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] | 2772 | runs on test_CT { |
| 2773 | var L1ctlDlMessage dl; |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 2774 | [] 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] | 2775 | repeat; |
| 2776 | } |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 2777 | [] 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] | 2778 | var octetstring without_plen := |
| 2779 | substr(dl.payload.data_ind.payload, 1, lengthof(dl.payload.data_ind.payload)-1); |
| 2780 | 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] | 2781 | |
| 2782 | check_pch_fn(dl.dl_info.frame_nr, cfg.bs_ag_blks_res); |
| 2783 | |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 2784 | if (match(rr, tr_PAGING_REQ1)) { |
| 2785 | num_paging_rcv_msgs := num_paging_rcv_msgs + 1; |
| 2786 | num_paging_rcv_ids := num_paging_rcv_ids + 1; |
| 2787 | if (isvalue(rr.msgs.rrm.pagingReq_Type1.mobileIdentity2)) { |
| 2788 | num_paging_rcv_ids := num_paging_rcv_ids + 1; |
| 2789 | } |
| 2790 | } else if (match(rr, tr_PAGING_REQ2)) { |
| 2791 | num_paging_rcv_msgs := num_paging_rcv_msgs + 1; |
| 2792 | if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type2.mobileIdentity1)) { |
| 2793 | num_paging_rcv_ids := num_paging_rcv_ids + 1; |
| 2794 | } |
| 2795 | if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type2.mobileIdentity2)) { |
| 2796 | num_paging_rcv_ids := num_paging_rcv_ids + 1; |
| 2797 | } |
| 2798 | if (isvalue(rr.msgs.rrm.pagingReq_Type2.mobileIdentity3)) { |
| 2799 | num_paging_rcv_ids := num_paging_rcv_ids + 1; |
| 2800 | } |
| 2801 | } else if (match(rr, tr_PAGING_REQ3)) { |
| 2802 | num_paging_rcv_msgs := num_paging_rcv_msgs + 1; |
| 2803 | if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type3.mobileIdentity1)) { |
| 2804 | num_paging_rcv_ids := num_paging_rcv_ids + 1; |
| 2805 | } |
| 2806 | if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type3.mobileIdentity2)) { |
| 2807 | num_paging_rcv_ids := num_paging_rcv_ids + 1; |
| 2808 | } |
| 2809 | if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type3.mobileIdentity3)) { |
| 2810 | num_paging_rcv_ids := num_paging_rcv_ids + 1; |
| 2811 | } |
| 2812 | if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type3.mobileIdentity4)) { |
| 2813 | num_paging_rcv_ids := num_paging_rcv_ids + 1; |
| 2814 | } |
| 2815 | } |
| 2816 | repeat; |
| 2817 | } |
| 2818 | } |
| 2819 | |
| 2820 | type record PagingTestCfg { |
| 2821 | boolean combined_ccch, |
| 2822 | integer bs_ag_blks_res, |
| 2823 | float load_factor, |
| 2824 | boolean exp_load_ind, |
| 2825 | boolean exp_overload, |
| 2826 | boolean use_tmsi |
| 2827 | } |
| 2828 | |
| 2829 | type record PagingTestState { |
| 2830 | integer num_paging_sent, |
| 2831 | integer num_paging_rcv_msgs, |
| 2832 | integer num_paging_rcv_ids, |
| 2833 | integer num_overload |
| 2834 | } |
| 2835 | |
| 2836 | /* receive + ignore RSL RF RES IND */ |
| 2837 | altstep as_rsl_res_ind() runs on test_CT { |
| 2838 | [] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_RF_RES_IND)) { |
| 2839 | repeat; |
| 2840 | } |
| 2841 | } |
| 2842 | |
| 2843 | /* Helper function for paging related testing */ |
| 2844 | private function f_TC_paging(PagingTestCfg cfg) runs on test_CT return PagingTestState { |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 2845 | f_init(); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 2846 | f_init_l1ctl(); |
| 2847 | f_l1_tune(L1CTL); |
| 2848 | |
| 2849 | var PagingTestState st := { |
| 2850 | num_paging_sent := 0, |
| 2851 | num_paging_rcv_msgs := 0, |
| 2852 | num_paging_rcv_ids := 0, |
| 2853 | num_overload := 0 |
| 2854 | }; |
| 2855 | |
| 2856 | var float max_pch_blocks_per_sec := f_pch_block_rate_est(cfg.combined_ccch, cfg.bs_ag_blks_res); |
| 2857 | var float max_pch_imsi_per_sec; |
| 2858 | if (cfg.use_tmsi) { |
| 2859 | max_pch_imsi_per_sec := max_pch_blocks_per_sec * 4.0; /* Type 3 */ |
| 2860 | } else { |
| 2861 | max_pch_imsi_per_sec := max_pch_blocks_per_sec * 2.0; /* Type 1 */ |
| 2862 | } |
| 2863 | var float pch_blocks_per_sec := max_pch_imsi_per_sec * cfg.load_factor; |
| 2864 | var float interval := 1.0 / pch_blocks_per_sec; |
Pau Espin Pedrol | 9c3ff4e | 2018-09-26 18:30:16 +0200 | [diff] [blame] | 2865 | var float time_total := 20.0; |
| 2866 | var integer pkt_total := float2int(time_total * pch_blocks_per_sec); |
| 2867 | 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] | 2868 | |
Pau Espin Pedrol | 9c3ff4e | 2018-09-26 18:30:16 +0200 | [diff] [blame] | 2869 | timer T_total := 300.0; /* big value (far bigger than time_total), used to count elapsed time */ |
| 2870 | T_total.start; |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 2871 | |
Pau Espin Pedrol | 9c3ff4e | 2018-09-26 18:30:16 +0200 | [diff] [blame] | 2872 | timer T_itv := 0.0; |
| 2873 | T_itv.start; |
| 2874 | while (st.num_paging_sent < pkt_total) { |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 2875 | alt { |
| 2876 | /* check for presence of CCCH LOAD IND (paging load) */ |
| 2877 | [cfg.exp_overload] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_PAGING_LOAD_IND(0))) { |
| 2878 | st.num_overload := st.num_overload + 1; |
| 2879 | repeat; |
| 2880 | } |
| 2881 | [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] | 2882 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected PCH Overload"); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 2883 | } |
| 2884 | [cfg.exp_load_ind] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_PAGING_LOAD_IND)) { |
| 2885 | log("Rx LOAD_IND"); |
| 2886 | /* FIXME: analyze/verify interval + contents */ |
| 2887 | repeat; |
| 2888 | } |
| 2889 | /* check if paging requests arrive on Um side */ |
Philipp Maier | 82cb0b1 | 2018-08-31 14:41:39 +0200 | [diff] [blame] | 2890 | [] 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] | 2891 | [] L1CTL.receive { repeat; } |
Pau Espin Pedrol | 9c3ff4e | 2018-09-26 18:30:16 +0200 | [diff] [blame] | 2892 | [] T_itv.timeout { |
| 2893 | /* Send paging cmds based on elapsed time */ |
| 2894 | var integer new_sent := f_min(pkt_total, float2int(T_total.read * pch_blocks_per_sec) + 1); |
| 2895 | while (st.num_paging_sent < new_sent) { |
| 2896 | /* build mobile Identity */ |
| 2897 | var MobileL3_CommonIE_Types.MobileIdentityLV mi; |
| 2898 | if (cfg.use_tmsi) { |
| 2899 | mi := valueof(ts_MI_TMSI_LV(f_rnd_octstring(4))); |
| 2900 | } else { |
| 2901 | mi := valueof(ts_MI_IMSI_LV(f_gen_imsi(st.num_paging_sent))); |
| 2902 | } |
| 2903 | var octetstring mi_enc_lv := enc_MobileIdentityLV(mi); |
| 2904 | var octetstring mi_enc := substr(mi_enc_lv, 1, lengthof(mi_enc_lv)-1); |
| 2905 | |
| 2906 | /* Send RSL PAGING COMMAND */ |
| 2907 | RSL_CCHAN.send(ts_RSL_UD(ts_RSL_PAGING_CMD(mi_enc, st.num_paging_sent mod 4))); |
| 2908 | |
| 2909 | st.num_paging_sent := st.num_paging_sent + 1; |
| 2910 | } |
| 2911 | if (st.num_paging_sent < pkt_total) { |
| 2912 | /* Wait for interval to next PAGING COMMAND */ |
| 2913 | var float time_now := T_total.read; |
| 2914 | var float next_sched := int2float(st.num_paging_sent)*interval; |
| 2915 | if (next_sched > time_now) { |
| 2916 | T_itv.start(next_sched - time_now); |
| 2917 | } else { |
| 2918 | T_itv.start(0.0); |
| 2919 | } |
| 2920 | } else { |
| 2921 | /* We are done, no need to keep counting */ |
| 2922 | T_total.stop; |
| 2923 | } |
| 2924 | } |
| 2925 | [] T_total.timeout { } |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 2926 | [] as_rsl_res_ind(); |
| 2927 | } |
| 2928 | } |
| 2929 | |
| 2930 | /* wait for max 18s for paging queue to drain (size: 200, ~ 13 per s -> 15s) */ |
| 2931 | timer T_wait := 18.0; |
| 2932 | T_wait.start; |
| 2933 | alt { |
Philipp Maier | 82cb0b1 | 2018-08-31 14:41:39 +0200 | [diff] [blame] | 2934 | [] 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] | 2935 | [] L1CTL.receive { repeat; } |
| 2936 | /* 65535 == empty paging queue, we can terminate*/ |
| 2937 | [] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_PAGING_LOAD_IND(65535))) { } |
| 2938 | [] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_PAGING_LOAD_IND)) { repeat; } |
| 2939 | [] T_wait.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 2940 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Waiting for empty paging queue"); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 2941 | } |
| 2942 | [] as_rsl_res_ind(); |
| 2943 | } |
| 2944 | |
| 2945 | log("num_paging_sent=", st.num_paging_sent, " rcvd_msgs=", st.num_paging_rcv_msgs, |
| 2946 | " rcvd_ids=", st.num_paging_rcv_ids); |
| 2947 | return st; |
| 2948 | } |
| 2949 | |
| 2950 | /* Create ~ 80% paging load (IMSI only) sustained for about 20s, verifying that |
| 2951 | * - the number of Mobile Identities on Um PCH match the number of pages on RSL |
| 2952 | * - that CCCH LOAD IND (PCH) are being generated |
| 2953 | * - that CCCH LOAD IND (PCH) [no load] is received after paging flood is over */ |
| 2954 | testcase TC_paging_imsi_80percent() runs on test_CT { |
Philipp Maier | d65d056 | 2018-08-30 16:25:47 +0200 | [diff] [blame] | 2955 | var SystemInformation si3 := valueof(ts_SI3_default); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 2956 | var PagingTestCfg cfg := { |
| 2957 | combined_ccch := true, |
Philipp Maier | d65d056 | 2018-08-30 16:25:47 +0200 | [diff] [blame] | 2958 | 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] | 2959 | load_factor := 0.8, |
| 2960 | exp_load_ind := true, |
| 2961 | exp_overload := false, |
| 2962 | use_tmsi := false |
| 2963 | }; |
| 2964 | var PagingTestState st := f_TC_paging(cfg); |
| 2965 | if (st.num_paging_sent != st.num_paging_rcv_ids) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 2966 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Expected ", st.num_paging_sent, " pagings but have ", |
| 2967 | st.num_paging_rcv_ids)); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 2968 | } else { |
| 2969 | setverdict(pass); |
| 2970 | } |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 2971 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 2972 | } |
| 2973 | |
| 2974 | /* Create ~ 80% paging load (TMSI only) sustained for about 20s, verifying that |
| 2975 | * - the number of Mobile Identities on Um PCH match the number of pages on RSL |
| 2976 | * - that CCCH LOAD IND (PCH) are being generated |
| 2977 | * - that CCCH LOAD IND (PCH) [no load] is received after paging flood is over */ |
| 2978 | testcase TC_paging_tmsi_80percent() runs on test_CT { |
Philipp Maier | d65d056 | 2018-08-30 16:25:47 +0200 | [diff] [blame] | 2979 | var SystemInformation si3 := valueof(ts_SI3_default); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 2980 | var PagingTestCfg cfg := { |
| 2981 | combined_ccch := true, |
Philipp Maier | d65d056 | 2018-08-30 16:25:47 +0200 | [diff] [blame] | 2982 | 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] | 2983 | load_factor := 0.8, |
| 2984 | exp_load_ind := true, |
| 2985 | exp_overload := false, |
| 2986 | use_tmsi := true |
| 2987 | }; |
| 2988 | var PagingTestState st := f_TC_paging(cfg); |
| 2989 | if (st.num_paging_sent != st.num_paging_rcv_ids) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 2990 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Expected ", st.num_paging_sent, " pagings but have ", |
| 2991 | st.num_paging_rcv_ids)); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 2992 | } else { |
| 2993 | setverdict(pass); |
| 2994 | } |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 2995 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 2996 | } |
| 2997 | |
| 2998 | /* Create ~ 200% paging load (IMSI only) sustained for about 20s, verifying that |
| 2999 | * - the number of Mobile Identities on Um PCH are ~ 82% of the number of pages on RSL |
| 3000 | * - that CCCH LOAD IND (PCH) are being generated and reach 0 at some point |
| 3001 | * - that CCCH LOAD IND (PCH) [no load] is received after paging flood is over */ |
| 3002 | testcase TC_paging_imsi_200percent() runs on test_CT { |
Philipp Maier | d65d056 | 2018-08-30 16:25:47 +0200 | [diff] [blame] | 3003 | var SystemInformation si3 := valueof(ts_SI3_default); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3004 | var PagingTestCfg cfg := { |
| 3005 | combined_ccch := true, |
Philipp Maier | d65d056 | 2018-08-30 16:25:47 +0200 | [diff] [blame] | 3006 | 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] | 3007 | load_factor := 2.0, |
| 3008 | exp_load_ind := true, |
| 3009 | exp_overload := true, |
| 3010 | use_tmsi := false |
| 3011 | }; |
| 3012 | var PagingTestState st := f_TC_paging(cfg); |
| 3013 | /* We expect about 80-85% to pass, given that we can fill the paging buffer of 200 |
| 3014 | * slots and will fully drain that buffer before returning */ |
Pau Espin Pedrol | 9c3ff4e | 2018-09-26 18:30:16 +0200 | [diff] [blame] | 3015 | 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] | 3016 | if (not match(st.num_paging_rcv_ids, tpl)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3017 | 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] | 3018 | } else { |
| 3019 | setverdict(pass); |
| 3020 | } |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3021 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3022 | } |
| 3023 | |
| 3024 | /* Create ~ 200% paging load (TMSI only) sustained for about 20s, verifying that |
| 3025 | * - the number of Mobile Identities on Um PCH are ~ 82% of the number of pages on RSL |
| 3026 | * - that CCCH LOAD IND (PCH) are being generated and reach 0 at some point |
| 3027 | * - that CCCH LOAD IND (PCH) [no load] is received after paging flood is over */ |
| 3028 | testcase TC_paging_tmsi_200percent() runs on test_CT { |
Philipp Maier | d65d056 | 2018-08-30 16:25:47 +0200 | [diff] [blame] | 3029 | var SystemInformation si3 := valueof(ts_SI3_default); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3030 | var PagingTestCfg cfg := { |
| 3031 | combined_ccch := true, |
Philipp Maier | d65d056 | 2018-08-30 16:25:47 +0200 | [diff] [blame] | 3032 | 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] | 3033 | load_factor := 2.0, |
| 3034 | exp_load_ind := true, |
| 3035 | exp_overload := true, |
| 3036 | use_tmsi := true |
| 3037 | }; |
| 3038 | var PagingTestState st := f_TC_paging(cfg); |
| 3039 | /* We expect about 70% to pass, given that we can fill the paging buffer of 200 |
| 3040 | * slots and will fully drain that buffer before returning */ |
Pau Espin Pedrol | 9c3ff4e | 2018-09-26 18:30:16 +0200 | [diff] [blame] | 3041 | 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] | 3042 | if (not match(st.num_paging_rcv_ids, tpl)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3043 | 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] | 3044 | } else { |
| 3045 | setverdict(pass); |
| 3046 | } |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3047 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3048 | } |
| 3049 | |
| 3050 | |
Harald Welte | 93640c6 | 2018-02-25 16:59:33 +0100 | [diff] [blame] | 3051 | /*********************************************************************** |
| 3052 | * Immediate Assignment / AGCH |
| 3053 | ***********************************************************************/ |
Harald Welte | e8d750e | 2018-06-10 21:41:35 +0200 | [diff] [blame] | 3054 | const MobileAllocation c_MA_null := { |
| 3055 | len := 0, |
| 3056 | ma := ''B |
| 3057 | } |
Harald Welte | 93640c6 | 2018-02-25 16:59:33 +0100 | [diff] [blame] | 3058 | |
Harald Welte | e8d750e | 2018-06-10 21:41:35 +0200 | [diff] [blame] | 3059 | template (value) ChannelDescription ts_ChanDesc(template (value) RslChannelNr chan_nr, uint3_t tsc := 7, |
| 3060 | uint12_t arfcn := 871) := { |
| 3061 | chan_nr := chan_nr, |
| 3062 | tsc := tsc, |
| 3063 | h := false, |
| 3064 | arfcn := arfcn, |
| 3065 | maio_hsn := omit |
| 3066 | } |
| 3067 | |
| 3068 | private function f_fmt_ia_stats(integer num_tx, integer num_rx, integer num_del) return charstring { |
| 3069 | return int2str(num_tx) & " sent, " |
| 3070 | & int2str(num_rx) & " received, " |
| 3071 | & int2str(num_del) & " deleted"; |
| 3072 | } |
| 3073 | |
| 3074 | private function f_TC_imm_ass(integer num_total, float sleep_s, float exp_pass) runs on test_CT { |
| 3075 | var L1ctlDlMessage l1_dl; |
| 3076 | timer T := 10.0; |
| 3077 | var integer num_tx := 0; |
| 3078 | var integer num_rx := 0; |
| 3079 | var integer num_del := 0; |
| 3080 | var charstring res_str; |
| 3081 | var float rx_ratio; |
| 3082 | |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 3083 | f_init(); |
Harald Welte | e8d750e | 2018-06-10 21:41:35 +0200 | [diff] [blame] | 3084 | f_init_l1ctl(); |
| 3085 | f_l1_tune(L1CTL); |
| 3086 | |
| 3087 | for (var integer i := 0; i < num_total; i := i+1) { |
| 3088 | var ChannelDescription ch_desc := valueof(ts_ChanDesc(valueof(t_RslChanNr_SDCCH4(0, 0)))); |
| 3089 | var GsmRrMessage ia := valueof(ts_IMM_ASS(42, i, 5, ch_desc, c_MA_null)); |
| 3090 | var octetstring ia_enc := enc_GsmRrMessage(ia); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3091 | 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] | 3092 | num_tx := num_tx+1; |
| 3093 | f_sleep(sleep_s); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3094 | } |
| 3095 | /* FIXME: check if imm.ass arrive on Um side */ |
Harald Welte | e8d750e | 2018-06-10 21:41:35 +0200 | [diff] [blame] | 3096 | T.start; |
| 3097 | alt { |
| 3098 | [] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_DELETE_IND(?, 0))) { |
| 3099 | num_del := num_del+1; |
| 3100 | repeat; |
| 3101 | } |
| 3102 | [] RSL_CCHAN.receive { |
| 3103 | repeat; |
| 3104 | } |
| 3105 | [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_PCH_AGCH(0), ?)) -> value l1_dl { |
| 3106 | /* somehow dec_SystemInformation will try to decode even non-RR as SI */ |
| 3107 | var GsmRrMessage rr := dec_GsmRrMessage(l1_dl.payload.data_ind.payload); |
| 3108 | if (not match(rr, tr_IMM_ASS(42, ?, 5, ?, ?))) { |
| 3109 | /* FIXME: Why are we seeing paging requests on PCH/AGCH? */ |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3110 | //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] | 3111 | } else { |
| 3112 | num_rx := num_rx+1; |
| 3113 | } |
| 3114 | repeat; |
| 3115 | } |
| 3116 | [] L1CTL.receive { repeat; } |
| 3117 | [] T.timeout { } |
| 3118 | } |
| 3119 | res_str := f_fmt_ia_stats(num_tx, num_rx, num_del); |
| 3120 | log("AGCH test: " & res_str); |
| 3121 | if (num_rx + num_del != num_tx) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3122 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "RX + DEL != TX ?!?: " & res_str); |
Harald Welte | e8d750e | 2018-06-10 21:41:35 +0200 | [diff] [blame] | 3123 | } |
| 3124 | rx_ratio := int2float(num_rx) / int2float(num_tx); |
| 3125 | 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] | 3126 | 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] | 3127 | } else { |
| 3128 | setverdict(pass); |
| 3129 | } |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3130 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3131 | } |
| 3132 | |
Harald Welte | e8d750e | 2018-06-10 21:41:35 +0200 | [diff] [blame] | 3133 | /* send a long burst of 1000 IMM.ASS with 20ms spacing (50 per s); expect 75% of them to be deleted */ |
| 3134 | testcase TC_imm_ass_1000_20ms() runs on test_CT { |
| 3135 | f_TC_imm_ass(1000, 0.02, 0.25); |
| 3136 | } |
| 3137 | |
| 3138 | /* send a short burst of 200 IMM.ASS without any spacing; expect 95% of them to be deleted */ |
| 3139 | testcase TC_imm_ass_200_0ms() runs on test_CT { |
| 3140 | f_TC_imm_ass(200, 0.0, 0.05); |
| 3141 | } |
| 3142 | |
| 3143 | /* send 150 IMM.ASS at rate of 13/s; expect none of them to be deleted */ |
| 3144 | testcase TC_imm_ass_200_76ms() runs on test_CT { |
| 3145 | f_TC_imm_ass(150, 0.076, 1.00); |
| 3146 | } |
| 3147 | |
| 3148 | |
| 3149 | |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 3150 | /*********************************************************************** |
| 3151 | * BCCH |
| 3152 | ***********************************************************************/ |
| 3153 | |
| 3154 | /* tuple of Frame Number + decoded SI */ |
| 3155 | type record SystemInformationFn { |
| 3156 | GsmFrameNumber frame_number, |
| 3157 | SystemInformation si |
| 3158 | } |
| 3159 | |
| 3160 | /* an arbitrary-length vector of decoded SI + gsmtap header */ |
| 3161 | type record of SystemInformationFn SystemInformationVector; |
| 3162 | |
| 3163 | /* an array of SI-vectors indexed by TC value */ |
| 3164 | type SystemInformationVector SystemInformationVectorPerTc[8]; |
| 3165 | |
| 3166 | /* determine if a given SI vector contains given SI type at least once */ |
| 3167 | function f_si_vecslot_contains(SystemInformationVector arr, RrMessageType key, boolean bcch_ext := false) return boolean { |
| 3168 | for (var integer i:= 0; i< sizeof(arr); i := i + 1) { |
| 3169 | var integer fn_mod51 := arr[i].frame_number mod 51; |
| 3170 | if (not bcch_ext and fn_mod51 == 2 or |
| 3171 | bcch_ext and fn_mod51 == 6) { |
| 3172 | if (arr[i].si.header.message_type == key) { |
| 3173 | return true; |
| 3174 | } |
| 3175 | } |
| 3176 | } |
| 3177 | return false; |
| 3178 | } |
| 3179 | |
| 3180 | /* ensure a given TC slot of the SI vector contains given SI type at least once at TC */ |
| 3181 | function f_ensure_si_vec_contains(SystemInformationVectorPerTc arr, integer tc, RrMessageType key, boolean ext_bcch := false) { |
| 3182 | if (not f_si_vecslot_contains(arr[tc], key, ext_bcch)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3183 | 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] | 3184 | } |
| 3185 | } |
| 3186 | |
| 3187 | /* check if a given SI vector contains given SI type at least once on any TC */ |
| 3188 | function f_si_vec_contains(SystemInformationVectorPerTc arr, RrMessageType key) return boolean { |
| 3189 | for (var integer tc:= 0; tc < sizeof(arr); tc := tc + 1) { |
| 3190 | if (f_si_vecslot_contains(arr[tc], key) or |
| 3191 | f_si_vecslot_contains(arr[tc], key, true)) { |
| 3192 | return true; |
| 3193 | } |
| 3194 | } |
| 3195 | return false; |
| 3196 | } |
| 3197 | |
| 3198 | /* determine if a given SI vector contains given SI type at least N of M times */ |
| 3199 | function f_si_vecslot_contains_n_of_m(SystemInformationVector arr, RrMessageType key, boolean bcch_ext := false, integer n := 1, integer m := 4) return boolean { |
| 3200 | var integer count := 0; |
| 3201 | if (sizeof(arr) < m) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3202 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Error: Insufficient SI in array"); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 3203 | } |
| 3204 | for (var integer i:= 0; i < m; i := i + 1) { |
| 3205 | var integer fn_mod51 := arr[i].frame_number mod 51; |
| 3206 | if (not bcch_ext and fn_mod51 == 2 or |
| 3207 | bcch_ext and fn_mod51 == 6) { |
| 3208 | if (arr[i].si.header.message_type == key) { |
| 3209 | count := count + 1; |
| 3210 | } |
| 3211 | } |
| 3212 | } |
| 3213 | if (count >= n) { |
| 3214 | return true; |
| 3215 | } else { |
| 3216 | return false; |
| 3217 | } |
| 3218 | } |
| 3219 | |
| 3220 | /* ensure a given TC slot of the SI vector contains given SI type at least N out of M times at TC */ |
| 3221 | function f_ensure_si_vec_contains_n_of_m(SystemInformationVectorPerTc arr, integer tc, RrMessageType key, boolean ext_bcch := false, integer n, integer m) { |
| 3222 | 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] | 3223 | 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] | 3224 | } |
| 3225 | } |
| 3226 | |
| 3227 | /* determine if a given SI vector contains given SI type at least once */ |
| 3228 | function f_si_vecslot_contains_only(SystemInformationVector arr, RrMessageType key, boolean bcch_ext := false) return boolean { |
| 3229 | for (var integer i:= 0; i< sizeof(arr); i := i + 1) { |
| 3230 | var integer fn_mod51 := arr[i].frame_number mod 51; |
| 3231 | if (not bcch_ext and fn_mod51 == 2 or |
| 3232 | bcch_ext and fn_mod51 == 6) { |
| 3233 | if (arr[i].si.header.message_type != key) { |
| 3234 | return false; |
| 3235 | } |
| 3236 | } |
| 3237 | } |
| 3238 | return true; |
| 3239 | } |
| 3240 | |
| 3241 | /* ensure a given TC slot of the SI vector contains only given SI type */ |
| 3242 | function f_ensure_si_vec_contains_only(SystemInformationVectorPerTc arr, integer tc, RrMessageType key, boolean ext_bcch := false) { |
| 3243 | if (not f_si_vecslot_contains_only(arr[tc], key, ext_bcch)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3244 | 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] | 3245 | } |
| 3246 | } |
| 3247 | |
| 3248 | /* SI configuration of cell, against which we validate actual SI messages */ |
| 3249 | type set SystemInformationConfig { |
| 3250 | boolean bcch_extended, |
| 3251 | boolean si1_present, |
| 3252 | boolean si2bis_present, |
| 3253 | boolean si2ter_present, |
| 3254 | boolean si2quater_present, |
| 3255 | boolean si7_present, |
| 3256 | boolean si8_present, |
| 3257 | boolean si9_present, |
| 3258 | boolean si13_present, |
| 3259 | boolean si13alt_present, |
| 3260 | boolean si15_present, |
| 3261 | boolean si16_present, |
| 3262 | boolean si17_present, |
| 3263 | boolean si2n_present, |
| 3264 | boolean si21_present, |
| 3265 | boolean si22_present |
| 3266 | } |
| 3267 | |
| 3268 | /* validate the SI scheduling according to TS 45.002 version 14.1.0 Release 14, Section 6.3.1.3 */ |
| 3269 | function f_validate_si_scheduling(SystemInformationConfig cfg, SystemInformationVectorPerTc si_per_tc) { |
| 3270 | var integer i; |
| 3271 | for (i := 0; i < sizeof(si_per_tc); i := i + 1) { |
| 3272 | if (sizeof(si_per_tc[i]) == 0) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3273 | 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] | 3274 | } |
| 3275 | } |
| 3276 | if (cfg.si1_present) { |
| 3277 | /* ii) System Information Type 1 needs to be sent if frequency hopping is in use or |
| 3278 | * when the NCH is present in a cell. If the MS finds another message on BCCH Norm |
| 3279 | * when TC = 0, it can assume that System Information Type 1 is not in use. */ |
| 3280 | f_ensure_si_vec_contains(si_per_tc, 0, SYSTEM_INFORMATION_TYPE_1); |
| 3281 | /* make sure *ALL* contain SI1 */ |
| 3282 | f_ensure_si_vec_contains_only(si_per_tc, 0, SYSTEM_INFORMATION_TYPE_1); |
| 3283 | } |
| 3284 | f_ensure_si_vec_contains(si_per_tc, 1, SYSTEM_INFORMATION_TYPE_2); |
| 3285 | /* iii) A SI 2 message will be sent at least every time TC = 1 */ |
| 3286 | f_ensure_si_vec_contains(si_per_tc, 2, SYSTEM_INFORMATION_TYPE_3); |
| 3287 | f_ensure_si_vec_contains(si_per_tc, 6, SYSTEM_INFORMATION_TYPE_3); |
| 3288 | f_ensure_si_vec_contains(si_per_tc, 3, SYSTEM_INFORMATION_TYPE_4); |
| 3289 | f_ensure_si_vec_contains(si_per_tc, 7, SYSTEM_INFORMATION_TYPE_4); |
| 3290 | |
| 3291 | /* iii) System information type 2 bis or 2 ter messages are sent if needed, as determined by the |
| 3292 | * system operator. If only one of them is needed, it is sent when TC = 5. If both are |
| 3293 | * needed, 2bis is sent when TC = 5 and 2ter is sent at least once within any of 4 |
| 3294 | * consecutive occurrences of TC = 4. */ |
| 3295 | if (cfg.si2bis_present and not cfg.si2ter_present) { |
| 3296 | f_ensure_si_vec_contains(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2bis); |
| 3297 | } else if (cfg.si2ter_present and not cfg.si2bis_present) { |
| 3298 | f_ensure_si_vec_contains(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2ter); |
| 3299 | } else if (cfg.si2ter_present and cfg.si2bis_present) { |
| 3300 | f_ensure_si_vec_contains(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2bis); |
| 3301 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_2ter, false, 1, 4); |
| 3302 | } |
| 3303 | |
| 3304 | if (cfg.si7_present or cfg.si8_present) { |
| 3305 | /* vi) Use of System Information type 7 and 8 is not always necessary. It is necessary |
| 3306 | * if System Information type 4 does not contain all information needed for cell |
| 3307 | * selection and reselection. */ |
| 3308 | if (not cfg.bcch_extended) { |
| 3309 | testcase.stop("Error: SI7/SI8 require BCCH Extd."); |
| 3310 | } |
| 3311 | if (cfg.si7_present) { |
| 3312 | f_ensure_si_vec_contains(si_per_tc, 7, SYSTEM_INFORMATION_TYPE_7, true); |
| 3313 | } |
| 3314 | if (cfg.si8_present) { |
| 3315 | f_ensure_si_vec_contains(si_per_tc, 3, SYSTEM_INFORMATION_TYPE_8, true); |
| 3316 | } |
| 3317 | } |
| 3318 | |
| 3319 | if (cfg.si2quater_present) { |
| 3320 | /* iii) System information type 2 quater is sent if needed, as determined by the system |
| 3321 | * operator. If sent on BCCH Norm, it shall be sent when TC = 5 if neither of 2bis |
| 3322 | * and 2ter are used, otherwise it shall be sent at least once within any of 4 |
| 3323 | * consecutive occurrences of TC = 4. If sent on BCCH Ext, it is sent at least once |
| 3324 | * within any of 4 consecutive occurrences of TC = 5. */ |
| 3325 | if (not (cfg.bcch_extended)) { |
| 3326 | if (not (cfg.si2bis_present or cfg.si2ter_present)) { |
| 3327 | f_ensure_si_vec_contains(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2quater); |
| 3328 | } else { |
| 3329 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_2quater, false, 1, 4); |
| 3330 | } |
| 3331 | } else { |
| 3332 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2quater, true, 1, 4); |
| 3333 | } |
| 3334 | } |
| 3335 | if (cfg.si9_present) { |
| 3336 | /* vi) System Information type 9 is sent in those blocks with TC = 4 which are specified |
| 3337 | * in system information type 3 as defined in 3GPP TS 44.018. */ |
| 3338 | f_ensure_si_vec_contains(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_9); // FIXME SI3 |
| 3339 | } |
| 3340 | if (cfg.si13_present) { |
| 3341 | /* vii) System Information type 13 is only related to the GPRS service. System Information |
| 3342 | * Type 13 need only be sent if GPRS support is indicated in one or more of System |
| 3343 | * Information Type 3 or 4 or 7 or 8 messages. These messages also indicate if the |
| 3344 | * message is sent on the BCCH Norm or if the message is transmitted on the BCCH Ext. |
| 3345 | * In the case that the message is sent on the BCCH Norm, it is sent at least once |
| 3346 | * within any of 4 consecutive occurrences of TC=4. */ |
| 3347 | if (not cfg.bcch_extended) { |
| 3348 | log("not-bccch-extended"); |
| 3349 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_13, false, 1, 4); |
| 3350 | } else { |
| 3351 | log("bccch-extended"); |
| 3352 | f_ensure_si_vec_contains(si_per_tc, 0, SYSTEM_INFORMATION_TYPE_13, true); |
| 3353 | } |
| 3354 | if (f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_13alt)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3355 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Cannot have SI13alt and SI13"); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 3356 | } |
| 3357 | } |
| 3358 | if (cfg.si16_present or cfg.si17_present) { |
| 3359 | /* viii) System Information type 16 and 17 are only related to the SoLSA service. They |
| 3360 | * should not be sent in a cell where network sharing is used (see rule xv). */ |
| 3361 | if (cfg.si22_present) { |
| 3362 | testcase.stop("Error: Cannot have SI16/SI17 and SI22!"); |
| 3363 | } |
| 3364 | if (f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_22)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3365 | 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] | 3366 | } |
| 3367 | if (not cfg.bcch_extended) { |
| 3368 | testcase.stop("Error: SI16/SI17 requires BCCH Extd!"); |
| 3369 | } |
| 3370 | if (cfg.si16_present) { |
| 3371 | f_ensure_si_vec_contains(si_per_tc, 6, SYSTEM_INFORMATION_TYPE_16, true); |
| 3372 | } |
| 3373 | if (cfg.si17_present) { |
| 3374 | f_ensure_si_vec_contains(si_per_tc, 2, SYSTEM_INFORMATION_TYPE_17, true); |
| 3375 | } |
| 3376 | } |
| 3377 | |
| 3378 | /* ix) System Information type 18 and 20 are sent in order to transmit non-GSM |
| 3379 | * broadcast information. The frequency with which they are sent is determined by the |
| 3380 | * system operator. System Information type 9 identifies the scheduling of System |
| 3381 | * Information type 18 and 20 messages. */ |
| 3382 | |
| 3383 | /* x) System Information Type 19 is sent if COMPACT neighbours exist. If System |
| 3384 | * Information Type 19 is present, then its scheduling shall be indicated in System |
| 3385 | * Information Type 9. */ |
| 3386 | |
| 3387 | if (cfg.si15_present) { |
| 3388 | /* xi) System Information Type 15 is broadcast if dynamic ARFCN mapping is used in the |
| 3389 | * PLMN. If sent on BCCH Norm, it is sent at least once within any of 4 consecutive |
| 3390 | * occurrences of TC = 4. If sent on BCCH Ext, it is sent at least once within any of |
| 3391 | * 4 consecutive occurrences of TC = 1. */ |
| 3392 | if (not cfg.bcch_extended) { |
| 3393 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_15, false, 1, 4); |
| 3394 | } else { |
| 3395 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 1, SYSTEM_INFORMATION_TYPE_15, true, 1, 4); |
| 3396 | } |
| 3397 | } |
| 3398 | if (cfg.si13alt_present) { |
| 3399 | /* xii) System Information type 13 alt is only related to the GERAN Iu mode. System |
| 3400 | * Information Type 13 alt need only be sent if GERAN Iu mode support is indicated in |
| 3401 | * one or more of System Information Type 3 or 4 or 7 or 8 messages and SI 13 is not |
| 3402 | * broadcast. These messages also indicate if the message is sent on the BCCH Norm or |
| 3403 | * if the message is transmitted on the BCCH Ext. In the case that the message is sent |
| 3404 | * on the BCCH Norm, it is sent at least once within any of 4 consecutive occurrences |
| 3405 | * of TC = 4. */ |
| 3406 | if (cfg.si13_present) { |
| 3407 | testcase.stop("Error: Cannot have SI13alt and SI13"); |
| 3408 | } |
| 3409 | if (f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_13)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3410 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Cannot have SI13alt and SI13"); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 3411 | } |
| 3412 | if (not cfg.bcch_extended) { |
| 3413 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_13alt, false, 1, 4); |
| 3414 | } else { |
| 3415 | f_ensure_si_vec_contains(si_per_tc, 0, SYSTEM_INFORMATION_TYPE_13alt, true); |
| 3416 | } |
| 3417 | } |
| 3418 | if (cfg.si2n_present) { |
| 3419 | /* xiii) System Information Type 2n is optionally sent on BCCH Norm or BCCH Ext if needed, |
| 3420 | * as determined by the system operator. In the case that the message is sent on the |
| 3421 | * BCCH Norm, it is sent at least once within any of 4 consecutive occurrences of TC = |
| 3422 | * 4. If the message is sent on BCCH Ext, it is sent at least once within any of 2 |
| 3423 | * consecutive occurrences of TC = 4. */ |
| 3424 | if (not cfg.bcch_extended) { |
| 3425 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_2n, false, 1, 4); |
| 3426 | } else { |
| 3427 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_2n, true, 2, 4); |
| 3428 | } |
| 3429 | } |
| 3430 | if (cfg.si21_present) { |
| 3431 | /* xiv) System Information Type 21 is optionally sent on BCCH Norm or BCCH Ext, as |
| 3432 | * determined by the system operator. If Extended Access Barring is in use in the cell |
| 3433 | * then this message is sent at least once within any of 4 consecutive occurrences of |
| 3434 | * TC = 4 regardless if it is sent on BCCH Norm or BCCH Ext. If BCCH Ext is used in a |
| 3435 | * cell then this message shall only be sent on BCCH Ext. */ |
| 3436 | if (not cfg.bcch_extended) { |
| 3437 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_21, false, 1, 4); |
| 3438 | } else { |
| 3439 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_21, true, 1, 4); |
| 3440 | 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] | 3441 | 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] | 3442 | } |
| 3443 | } |
| 3444 | } |
| 3445 | if (cfg.si22_present) { |
| 3446 | /* xv) System Information Type 22 is sent if network sharing is in use in the cell. It |
| 3447 | * should not be sent in a cell where SoLSA is used (see rule viii). System |
| 3448 | * Information Type 22 instances shall be sent on BCCH Ext within any occurrence of TC |
| 3449 | * =2 and TC=6. */ |
| 3450 | if (cfg.si16_present or cfg.si17_present) { |
| 3451 | testcase.stop("Error: Cannot have SI16/SI17 and SI22!"); |
| 3452 | } |
| 3453 | if (f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_16) or |
| 3454 | f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_17)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3455 | 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] | 3456 | } |
| 3457 | if (not cfg.bcch_extended) { |
| 3458 | testcase.stop("Error: SI22 requires BCCH Extd!"); |
| 3459 | } else { |
| 3460 | f_ensure_si_vec_contains_only(si_per_tc, 2, SYSTEM_INFORMATION_TYPE_22, true); |
| 3461 | f_ensure_si_vec_contains_only(si_per_tc, 6, SYSTEM_INFORMATION_TYPE_22, true); |
| 3462 | } |
| 3463 | } |
| 3464 | } |
| 3465 | |
| 3466 | /* sample Systme Information for specified duration via L1CTL */ |
| 3467 | function f_l1_sample_si(L1CTL_PT pt, float duration := 8.0) return SystemInformationVectorPerTc { |
| 3468 | timer T := duration; |
| 3469 | var SystemInformationVectorPerTc si_per_tc; |
| 3470 | var L1ctlDlMessage l1_dl; |
| 3471 | |
| 3472 | /* initialize all per-TC vectors empty */ |
| 3473 | for (var integer i:= 0; i < sizeof(si_per_tc); i := i+1) { |
| 3474 | si_per_tc[i] := {}; |
| 3475 | } |
| 3476 | |
| 3477 | /* flush all previous L1 queued msgs */ |
| 3478 | pt.clear; |
| 3479 | |
| 3480 | T.start; |
| 3481 | alt { |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 3482 | [] 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] | 3483 | /* somehow dec_SystemInformation will try to decode even non-RR as SI */ |
| 3484 | if (not (l1_dl.payload.data_ind.payload[1] == '06'O)) { |
| 3485 | log("Ignoring non-RR SI ", l1_dl); |
| 3486 | repeat; |
| 3487 | } |
| 3488 | var SystemInformationFn sig := { |
| 3489 | frame_number := l1_dl.dl_info.frame_nr, |
| 3490 | si := dec_SystemInformation(l1_dl.payload.data_ind.payload) |
| 3491 | } |
| 3492 | var integer tc := f_gsm_compute_tc(sig.frame_number); |
| 3493 | log("SI received at TC=", tc, ": ", sig.si); |
| 3494 | /* append to the per-TC bucket */ |
| 3495 | si_per_tc[tc] := si_per_tc[tc] & { sig }; |
| 3496 | repeat; |
| 3497 | } |
| 3498 | [] pt.receive { repeat; } |
| 3499 | [] T.timeout { } |
| 3500 | } |
| 3501 | |
| 3502 | for (var integer i:= 0; i < sizeof(si_per_tc); i := i+1) { |
| 3503 | log(testcasename(), ": TC=", i, " has #of SI=", sizeof(si_per_tc[i])); |
| 3504 | } |
| 3505 | log("si_per_tc=", si_per_tc); |
| 3506 | return si_per_tc; |
| 3507 | } |
| 3508 | |
| 3509 | /* helper function: Set given SI via RSL + validate scheduling. |
| 3510 | * CALLER MUST MAKE SURE TO CHANGE GLOBAL si_cfg! */ |
| 3511 | function f_TC_si_sched() runs on test_CT { |
| 3512 | var SystemInformationVectorPerTc si_per_tc; |
| 3513 | f_init_l1ctl(); |
| 3514 | f_l1_tune(L1CTL); |
| 3515 | |
| 3516 | /* Sample + Validate Scheduling */ |
| 3517 | si_per_tc := f_l1_sample_si(L1CTL); |
| 3518 | f_validate_si_scheduling(si_cfg, si_per_tc); |
| 3519 | |
| 3520 | setverdict(pass); |
| 3521 | } |
| 3522 | |
| 3523 | testcase TC_si_sched_default() runs on test_CT { |
| 3524 | f_init(); |
Harald Welte | 0cae455 | 2018-03-09 22:20:26 +0100 | [diff] [blame] | 3525 | /* 2+3+4 are mandatory and set in f_init() */ |
| 3526 | f_TC_si_sched(); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3527 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 0cae455 | 2018-03-09 22:20:26 +0100 | [diff] [blame] | 3528 | } |
| 3529 | |
| 3530 | testcase TC_si_sched_1() runs on test_CT { |
| 3531 | f_init(); |
| 3532 | si_cfg.si1_present := true; |
| 3533 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_1, '5506198fb38000000000000000000000000000e504002b'O); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 3534 | f_TC_si_sched(); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3535 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 3536 | } |
| 3537 | |
| 3538 | testcase TC_si_sched_2bis() runs on test_CT { |
| 3539 | f_init(); |
| 3540 | si_cfg.si2bis_present := true; |
| 3541 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2bis, '550602bfe809b3ff00000000000000000000007900002b'O); |
| 3542 | f_TC_si_sched(); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3543 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 3544 | } |
| 3545 | |
| 3546 | testcase TC_si_sched_2ter() runs on test_CT { |
| 3547 | f_init(); |
| 3548 | si_cfg.si2ter_present := true; |
| 3549 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2ter, '010603bf66b0aa0a00000002000000000000002b2b2b2b'O); |
| 3550 | f_TC_si_sched(); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3551 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 3552 | } |
| 3553 | |
| 3554 | testcase TC_si_sched_2ter_2bis() runs on test_CT { |
| 3555 | f_init(); |
| 3556 | si_cfg.si2bis_present := true; |
| 3557 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2bis, '550602bfe809b3ff00000000000000000000007900002b'O); |
| 3558 | si_cfg.si2ter_present := true; |
| 3559 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2ter, '010603bf66b0aa0a00000002000000000000002b2b2b2b'O); |
| 3560 | f_TC_si_sched(); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3561 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 3562 | } |
| 3563 | |
| 3564 | testcase TC_si_sched_2quater() runs on test_CT { |
| 3565 | f_init(); |
| 3566 | si_cfg.si2quater_present := true; |
| 3567 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2quater, '050607a8a0364aa698d72ff424feee0506d5e7fff02043'O); |
| 3568 | f_TC_si_sched(); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3569 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 3570 | } |
| 3571 | |
| 3572 | testcase TC_si_sched_13() runs on test_CT { |
| 3573 | f_init(); |
| 3574 | si_cfg.si13_present := true; |
Harald Welte | 5618c2a | 2018-04-15 16:24:46 +0200 | [diff] [blame] | 3575 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_13, '0106009000185a6fc9e08410ab2b2b2b2b2b2b2b2b2b2b'O); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 3576 | f_TC_si_sched(); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3577 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 3578 | } |
| 3579 | |
| 3580 | testcase TC_si_sched_13_2bis_2ter_2quater() runs on test_CT { |
| 3581 | f_init(); |
| 3582 | si_cfg.si2bis_present := true; |
| 3583 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2bis, '550602bfe809b3ff00000000000000000000007900002b'O); |
| 3584 | si_cfg.si2ter_present := true; |
| 3585 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2ter, '010603bf66b0aa0a00000002000000000000002b2b2b2b'O); |
| 3586 | si_cfg.si2quater_present := true; |
| 3587 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2quater, '050607a8a0364aa698d72ff424feee0506d5e7fff02043'O); |
| 3588 | si_cfg.si13_present := true; |
Harald Welte | 5618c2a | 2018-04-15 16:24:46 +0200 | [diff] [blame] | 3589 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_13, '0106009000185a6fc9e08410ab2b2b2b2b2b2b2b2b2b2b'O); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 3590 | f_TC_si_sched(); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3591 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 3592 | } |
| 3593 | |
| 3594 | |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3595 | testcase TC_bcch_info() runs on test_CT { |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 3596 | f_init(); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3597 | /* FIXME: enable / disable individual BCCH info */ |
| 3598 | //ts_RSL_BCCH_INFO(si_type, info); |
| 3599 | /* expect no ERROR REPORT after either of them * |
| 3600 | /* negative test: ensure ERROR REPORT on unsupported types */ |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3601 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3602 | } |
| 3603 | |
Harald Welte | 93640c6 | 2018-02-25 16:59:33 +0100 | [diff] [blame] | 3604 | /*********************************************************************** |
| 3605 | * Low-Level Protocol Errors / ERROR REPORT |
| 3606 | ***********************************************************************/ |
| 3607 | |
Harald Welte | 01d982c | 2018-02-25 01:31:40 +0100 | [diff] [blame] | 3608 | private function f_exp_err_rep(template RSL_Cause cause) runs on test_CT { |
| 3609 | timer T := 5.0; |
| 3610 | T.start; |
| 3611 | alt { |
| 3612 | [] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_ERROR_REPORT(cause))) { |
| 3613 | setverdict(pass); |
| 3614 | } |
| 3615 | [] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_ERROR_REPORT(?))) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3616 | 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] | 3617 | } |
| 3618 | [] RSL_CCHAN.receive { |
| 3619 | repeat; |
| 3620 | } |
| 3621 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3622 | 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] | 3623 | } |
| 3624 | } |
| 3625 | } |
| 3626 | |
| 3627 | /* Provoke a protocol error (message too short) and match on ERROR REPORT */ |
| 3628 | testcase TC_rsl_protocol_error() runs on test_CT { |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 3629 | f_init(); |
Harald Welte | 01d982c | 2018-02-25 01:31:40 +0100 | [diff] [blame] | 3630 | var RSL_Message rsl := valueof(ts_RSL_BCCH_INFO(RSL_SYSTEM_INFO_1, ''O)); |
| 3631 | rsl.ies := omit; |
| 3632 | RSL_CCHAN.send(ts_RSL_UD(rsl)); |
| 3633 | |
| 3634 | f_exp_err_rep(RSL_ERR_PROTO); |
| 3635 | } |
| 3636 | |
| 3637 | /* Provoke a mandatory IE error and match on ERROR REPORT */ |
| 3638 | testcase TC_rsl_mand_ie_error() runs on test_CT { |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 3639 | f_init(); |
Harald Welte | 01d982c | 2018-02-25 01:31:40 +0100 | [diff] [blame] | 3640 | |
| 3641 | var RSL_Message rsl := valueof(ts_RSL_BCCH_INFO(RSL_SYSTEM_INFO_1, ''O)); |
| 3642 | rsl.ies := { rsl.ies[0] }; |
| 3643 | RSL_CCHAN.send(ts_RSL_UD(rsl)); |
| 3644 | |
| 3645 | f_exp_err_rep(RSL_ERR_MAND_IE_ERROR); |
| 3646 | } |
| 3647 | |
| 3648 | /* Provoke an IE content error and match on ERROR REPORT */ |
| 3649 | testcase TC_rsl_ie_content_error() runs on test_CT { |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 3650 | f_init(); |
Harald Welte | 01d982c | 2018-02-25 01:31:40 +0100 | [diff] [blame] | 3651 | var RSL_Message rsl := valueof(ts_RSL_BCCH_INFO(RSL_SYSTEM_INFO_1, ''O)); |
| 3652 | rsl.ies[1].body.sysinfo_type := RSL_SYSTEM_INFO_5; |
| 3653 | RSL_CCHAN.send(ts_RSL_UD(rsl)); |
| 3654 | |
| 3655 | f_exp_err_rep(RSL_ERR_IE_CONTENT); |
| 3656 | } |
| 3657 | |
Harald Welte | ee25aae | 2019-05-19 14:32:37 +0200 | [diff] [blame] | 3658 | /* attempt to activate channel with wrong RSL Message Discriminator IE */ |
| 3659 | function f_TC_chan_act_wrong_mdisc(charstring id) runs on ConnHdlr { |
| 3660 | var template RSL_Message rsl := ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode); |
| 3661 | rsl.msg_disc := ts_RSL_MsgDisc(RSL_MDISC_RESERVED, false); |
| 3662 | RSL.send(rsl); |
| 3663 | f_rslem_unregister(0, g_chan_nr); |
| 3664 | } |
| 3665 | testcase TC_err_rep_wrong_mdisc() runs on test_CT { |
| 3666 | var ConnHdlr vc_conn; |
| 3667 | var ConnHdlrPars pars := valueof(t_Pars(ts_RslChanNr_SDCCH4(0,0), ts_RSL_ChanMode_SIGN)); |
| 3668 | |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 3669 | f_init(); |
Harald Welte | ee25aae | 2019-05-19 14:32:37 +0200 | [diff] [blame] | 3670 | |
| 3671 | vc_conn := f_start_handler(refers(f_TC_chan_act_wrong_mdisc), pars); |
| 3672 | vc_conn.done; |
| 3673 | f_exp_err_rep(RSL_ERR_MSG_DISCR); |
| 3674 | |
| 3675 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 3676 | } |
| 3677 | |
| 3678 | /* Send messages with wrong message type */ |
| 3679 | function f_TC_wrong_msg_type_dchan(charstring id) runs on ConnHdlr { |
| 3680 | var template (value) RSL_Message rsl_tx; |
| 3681 | rsl_tx := ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode); |
| 3682 | rsl_tx.msg_type := RSL_MT_NOT_CMD; |
| 3683 | RSL.send(rsl_tx); |
| 3684 | f_rslem_unregister(0, g_chan_nr); |
| 3685 | } |
| 3686 | function f_TC_wrong_msg_type_rll(charstring id) runs on ConnHdlr { |
| 3687 | var template (value) RSL_Message rsl_tx; |
| 3688 | /* we first have to activate the dedicated channel */ |
| 3689 | f_rsl_chan_act(g_pars.chan_mode); |
| 3690 | /* ... to then send an invalid RLL message */ |
| 3691 | rsl_tx := ts_RSL_UNITDATA_REQ(g_chan_nr, ts_RslLinkID_DCCH(0), '0102'O); |
| 3692 | rsl_tx.msg_type := RSL_MT_CBCH_LOAD_IND; |
| 3693 | RSL.send(rsl_tx); |
| 3694 | f_rslem_unregister(0, g_chan_nr); |
| 3695 | } |
| 3696 | testcase TC_err_rep_wrong_msg_type() runs on test_CT { |
| 3697 | var ConnHdlr vc_conn; |
| 3698 | var ConnHdlrPars pars := valueof(t_Pars(ts_RslChanNr_SDCCH4(0,0), ts_RSL_ChanMode_SIGN)); |
| 3699 | var template (value) RSL_Message rsl_tx; |
| 3700 | |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 3701 | f_init(); |
Harald Welte | ee25aae | 2019-05-19 14:32:37 +0200 | [diff] [blame] | 3702 | |
| 3703 | /* Common Channel with wrong message type */ |
| 3704 | RSL_CCHAN.clear; |
| 3705 | rsl_tx := valueof(ts_RSL_BCCH_INFO(RSL_SYSTEM_INFO_1, ''O)); |
| 3706 | rsl_tx.msg_type := RSL_MT_LOCATION_INFO; |
| 3707 | RSL_CCHAN.send(ts_RSL_UD(rsl_tx)); |
| 3708 | f_exp_err_rep(RSL_ERR_MSG_TYPE); |
| 3709 | |
| 3710 | /* TRX Management */ |
| 3711 | RSL_CCHAN.clear; |
| 3712 | rsl_tx := ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, ''O); |
| 3713 | rsl_tx.msg_type := RSL_MT_UNIT_DATA_IND; |
| 3714 | RSL_CCHAN.send(ts_RSL_UD(rsl_tx)); |
| 3715 | f_exp_err_rep(RSL_ERR_MSG_TYPE); |
| 3716 | |
| 3717 | /* Dedicated Channel */ |
| 3718 | RSL_CCHAN.clear; |
| 3719 | vc_conn := f_start_handler(refers(f_TC_wrong_msg_type_dchan), pars); |
| 3720 | vc_conn.done; |
| 3721 | f_exp_err_rep(RSL_ERR_MSG_TYPE); |
| 3722 | |
| 3723 | /* RLL */ |
| 3724 | RSL_CCHAN.clear; |
| 3725 | vc_conn := f_start_handler(refers(f_TC_wrong_msg_type_rll), pars); |
| 3726 | vc_conn.done; |
| 3727 | f_exp_err_rep(RSL_ERR_MSG_TYPE); |
| 3728 | } |
| 3729 | |
| 3730 | /* Send messages in wrong sequence (RLL to an inactive lchan) */ |
| 3731 | function f_TC_err_rep_wrong_sequence(charstring id) runs on ConnHdlr { |
| 3732 | RSL.send(ts_RSL_UNITDATA_REQ(g_chan_nr, ts_RslLinkID_DCCH(0), '0102'O)); |
| 3733 | f_rslem_unregister(0, g_chan_nr); |
| 3734 | } |
| 3735 | testcase TC_err_rep_wrong_sequence() runs on test_CT { |
| 3736 | var ConnHdlr vc_conn; |
| 3737 | var ConnHdlrPars pars := valueof(t_Pars(ts_RslChanNr_SDCCH4(0,0), ts_RSL_ChanMode_SIGN)); |
| 3738 | |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 3739 | f_init(); |
Harald Welte | ee25aae | 2019-05-19 14:32:37 +0200 | [diff] [blame] | 3740 | |
| 3741 | RSL_CCHAN.clear; |
| 3742 | vc_conn := f_start_handler(refers(f_TC_err_rep_wrong_sequence), pars); |
| 3743 | vc_conn.done; |
| 3744 | f_exp_err_rep(RSL_ERR_MSG_SEQ); |
| 3745 | } |
| 3746 | |
Harald Welte | 93640c6 | 2018-02-25 16:59:33 +0100 | [diff] [blame] | 3747 | /*********************************************************************** |
| 3748 | * IPA CRCX/MDCX/DLCS media stream handling |
| 3749 | ***********************************************************************/ |
| 3750 | |
Harald Welte | a871a38 | 2018-02-25 02:03:14 +0100 | [diff] [blame] | 3751 | /* Send IPA DLCX to inactive lchan */ |
| 3752 | function f_TC_ipa_dlcx_not_active(charstring id) runs on ConnHdlr { |
Harald Welte | 1eba374 | 2018-02-25 12:48:14 +0100 | [diff] [blame] | 3753 | f_rsl_transceive(ts_RSL_IPA_DLCX(g_chan_nr, 0), tr_RSL_IPA_DLCX_ACK(g_chan_nr, ?, ?), |
| 3754 | "IPA DLCX ACK"); |
Harald Welte | a871a38 | 2018-02-25 02:03:14 +0100 | [diff] [blame] | 3755 | } |
| 3756 | testcase TC_ipa_dlcx_not_active() runs on test_CT { |
| 3757 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 3758 | f_init(); |
Harald Welte | a871a38 | 2018-02-25 02:03:14 +0100 | [diff] [blame] | 3759 | var ConnHdlr vc_conn := f_start_handler(refers(f_TC_ipa_dlcx_not_active), pars); |
| 3760 | vc_conn.done; |
| 3761 | } |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3762 | |
Harald Welte | a3f1df9 | 2018-02-25 12:49:55 +0100 | [diff] [blame] | 3763 | /* Send IPA CRCX twice to inactive lchan */ |
| 3764 | function f_TC_ipa_crcx_twice_not_active(charstring id) runs on ConnHdlr { |
| 3765 | f_rsl_transceive(ts_RSL_IPA_CRCX(g_chan_nr), tr_RSL_IPA_CRCX_ACK(g_chan_nr, ?, ?, ?), |
| 3766 | "IPA CRCX ACK"); |
| 3767 | f_rsl_transceive(ts_RSL_IPA_CRCX(g_chan_nr), tr_RSL_IPA_CRCX_NACK(g_chan_nr, RSL_ERR_RES_UNAVAIL), |
| 3768 | "IPA CRCX NACK"); |
| 3769 | } |
| 3770 | testcase TC_ipa_crcx_twice_not_active() runs on test_CT { |
| 3771 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 3772 | f_init(); |
Harald Welte | a3f1df9 | 2018-02-25 12:49:55 +0100 | [diff] [blame] | 3773 | var ConnHdlr vc_conn := f_start_handler(refers(f_TC_ipa_crcx_twice_not_active), pars); |
| 3774 | vc_conn.done; |
| 3775 | } |
| 3776 | |
| 3777 | /* Regular sequence of CRCX/MDCX/DLCX */ |
| 3778 | function f_TC_ipa_crcx_mdcx_dlcx_not_active(charstring id) runs on ConnHdlr { |
| 3779 | f_rsl_transceive(ts_RSL_IPA_CRCX(g_chan_nr), tr_RSL_IPA_CRCX_ACK(g_chan_nr, ?, ?, ?), |
| 3780 | "IPA CRCX ACK"); |
| 3781 | var uint32_t remote_ip := f_rnd_int(c_UINT32_MAX); |
| 3782 | var uint16_t remote_port := f_rnd_int(c_UINT16_MAX); |
| 3783 | var uint7_t rtp_pt2 := f_rnd_int(127); |
| 3784 | var uint16_t fake_conn_id := 23; /* we're too lazy to read it out from the CRCX ACK above */ |
| 3785 | f_rsl_transceive(ts_RSL_IPA_MDCX(g_chan_nr, fake_conn_id, remote_ip, remote_port, rtp_pt2), |
| 3786 | tr_RSL_IPA_MDCX_ACK(g_chan_nr, ?, ?, ?, rtp_pt2), |
| 3787 | "IPA MDCX ACK"); |
| 3788 | f_rsl_transceive(ts_RSL_IPA_DLCX(g_chan_nr, fake_conn_id), tr_RSL_IPA_DLCX_ACK(g_chan_nr, ?, ?), |
| 3789 | "IPA DLCX ACK"); |
| 3790 | } |
| 3791 | testcase TC_ipa_crcx_mdcx_dlcx_not_active() runs on test_CT { |
| 3792 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 3793 | f_init(); |
Harald Welte | a3f1df9 | 2018-02-25 12:49:55 +0100 | [diff] [blame] | 3794 | var ConnHdlr vc_conn := f_start_handler(refers(f_TC_ipa_crcx_mdcx_dlcx_not_active), pars); |
| 3795 | vc_conn.done; |
| 3796 | } |
| 3797 | |
Harald Welte | 3ae11da | 2018-02-25 13:36:06 +0100 | [diff] [blame] | 3798 | /* Sequence of CRCX, 2x MDCX, DLCX */ |
| 3799 | function f_TC_ipa_crcx_mdcx_mdcx_dlcx_not_active(charstring id) runs on ConnHdlr { |
| 3800 | f_rsl_transceive(ts_RSL_IPA_CRCX(g_chan_nr), tr_RSL_IPA_CRCX_ACK(g_chan_nr, ?, ?, ?), |
| 3801 | "IPA CRCX ACK"); |
| 3802 | var uint32_t remote_ip := f_rnd_int(c_UINT32_MAX); |
| 3803 | var uint16_t remote_port := f_rnd_int(c_UINT16_MAX); |
| 3804 | var uint7_t rtp_pt2 := f_rnd_int(127); |
| 3805 | var uint16_t fake_conn_id := 23; /* we're too lazy to read it out from the CRCX ACK above */ |
| 3806 | f_rsl_transceive(ts_RSL_IPA_MDCX(g_chan_nr, fake_conn_id, remote_ip, remote_port, rtp_pt2), |
| 3807 | tr_RSL_IPA_MDCX_ACK(g_chan_nr, ?, ?, ?, rtp_pt2), |
| 3808 | "IPA MDCX ACK"); |
| 3809 | /* Second MDCX */ |
| 3810 | remote_ip := f_rnd_int(c_UINT32_MAX); |
| 3811 | remote_port := f_rnd_int(c_UINT16_MAX); |
| 3812 | f_rsl_transceive(ts_RSL_IPA_MDCX(g_chan_nr, fake_conn_id, remote_ip, remote_port, rtp_pt2), |
| 3813 | tr_RSL_IPA_MDCX_ACK(g_chan_nr, ?, ?, ?, rtp_pt2), |
| 3814 | "IPA MDCX ACK"); |
| 3815 | f_rsl_transceive(ts_RSL_IPA_DLCX(g_chan_nr, fake_conn_id), tr_RSL_IPA_DLCX_ACK(g_chan_nr, ?, ?), |
| 3816 | "IPA DLCX ACK"); |
| 3817 | } |
| 3818 | testcase TC_ipa_crcx_mdcx_mdcx_dlcx_not_active() runs on test_CT { |
| 3819 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 3820 | f_init(); |
Harald Welte | 3ae11da | 2018-02-25 13:36:06 +0100 | [diff] [blame] | 3821 | var ConnHdlr vc_conn := f_start_handler(refers(f_TC_ipa_crcx_mdcx_mdcx_dlcx_not_active), pars); |
| 3822 | vc_conn.done; |
| 3823 | } |
| 3824 | |
Harald Welte | 9912eb5 | 2018-02-25 13:30:15 +0100 | [diff] [blame] | 3825 | /* IPA CRCX on SDCCH/4 and SDCCH/8 (doesn't make sense) */ |
| 3826 | function f_TC_ipa_crcx_sdcch_not_active(charstring id) runs on ConnHdlr { |
| 3827 | f_rsl_transceive(ts_RSL_IPA_CRCX(g_chan_nr), tr_RSL_IPA_CRCX_NACK(g_chan_nr, ?), |
| 3828 | "IPA CRCX NACK"); |
| 3829 | } |
| 3830 | testcase TC_ipa_crcx_sdcch_not_active() runs on test_CT { |
| 3831 | var ConnHdlrPars pars; |
| 3832 | var ConnHdlr vc_conn; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 3833 | f_init(); |
Harald Welte | 9912eb5 | 2018-02-25 13:30:15 +0100 | [diff] [blame] | 3834 | |
| 3835 | pars := valueof(t_Pars(t_RslChanNr_SDCCH4(0,1), ts_RSL_ChanMode_SIGN)); |
| 3836 | vc_conn := f_start_handler(refers(f_TC_ipa_crcx_sdcch_not_active), pars); |
| 3837 | vc_conn.done; |
| 3838 | |
| 3839 | pars := valueof(t_Pars(t_RslChanNr_SDCCH8(6,5), ts_RSL_ChanMode_SIGN)); |
| 3840 | vc_conn := f_start_handler(refers(f_TC_ipa_crcx_sdcch_not_active), pars); |
| 3841 | vc_conn.done; |
| 3842 | } |
| 3843 | |
Harald Welte | a3f1df9 | 2018-02-25 12:49:55 +0100 | [diff] [blame] | 3844 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 3845 | /*********************************************************************** |
| 3846 | * PCU Socket related tests |
| 3847 | ***********************************************************************/ |
| 3848 | |
Harald Welte | 07bd2d2 | 2019-05-25 11:03:30 +0200 | [diff] [blame] | 3849 | /* Verify no RTS before ACT_REQ; verify RTS after ACT_REQ */ |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 3850 | friend function f_TC_pcu_act_req(uint8_t bts_nr, uint8_t trx_nr, uint8_t ts_nr, boolean exp_success) |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 3851 | runs on test_CT { |
| 3852 | timer T := 3.0; |
| 3853 | |
| 3854 | /* we don't expect any RTS.req before PDCH are active */ |
| 3855 | T.start; |
| 3856 | alt { |
| 3857 | [] 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] | 3858 | 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] | 3859 | } |
| 3860 | [] PCU.receive { repeat; } |
| 3861 | [] T.timeout { } |
| 3862 | } |
| 3863 | |
| 3864 | /* Send PDCH activate request for known PDCH timeslot */ |
| 3865 | PCU.send(t_SD_PCUIF(g_pcu_conn_id, ts_PCUIF_ACT_REQ(bts_nr, trx_nr, ts_nr))); |
| 3866 | |
| 3867 | /* we now expect RTS.req for this timeslot (only) */ |
| 3868 | T.start; |
| 3869 | alt { |
| 3870 | [exp_success] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RTS_REQ(bts_nr, trx_nr, ts_nr))) { |
| 3871 | setverdict(pass); |
| 3872 | } |
| 3873 | [not exp_success] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, |
| 3874 | tr_PCUIF_RTS_REQ(bts_nr, trx_nr, ts_nr))) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3875 | 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] | 3876 | } |
| 3877 | [] 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] | 3878 | 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] | 3879 | } |
| 3880 | [] PCU.receive { repeat; } |
| 3881 | [exp_success] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3882 | 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] | 3883 | } |
| 3884 | [not exp_success] T.timeout { |
| 3885 | setverdict(pass); |
| 3886 | } |
| 3887 | } |
| 3888 | } |
| 3889 | |
Harald Welte | 07bd2d2 | 2019-05-25 11:03:30 +0200 | [diff] [blame] | 3890 | /* verify no more RTS after DEACT_REQ */ |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 3891 | friend function f_TC_pcu_deact_req(uint8_t bts_nr, uint8_t trx_nr, uint8_t ts_nr) |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 3892 | runs on test_CT { |
| 3893 | timer T := 3.0; |
| 3894 | |
| 3895 | /* Send PDCH activate request for known PDCH timeslot */ |
| 3896 | PCU.send(t_SD_PCUIF(g_pcu_conn_id, ts_PCUIF_DEACT_REQ(bts_nr, trx_nr, ts_nr))); |
| 3897 | |
| 3898 | PCU.clear; |
| 3899 | /* we now expect no RTS.req for this timeslot */ |
| 3900 | T.start; |
| 3901 | alt { |
| 3902 | [] 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] | 3903 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Received unexpected PCU RTS.req"); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 3904 | } |
| 3905 | [] PCU.receive { repeat; } |
| 3906 | [] T.timeout { |
| 3907 | setverdict(pass); |
| 3908 | } |
| 3909 | } |
| 3910 | } |
| 3911 | |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 3912 | friend function f_init_pcu_test() runs on test_CT { |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 3913 | f_init(); |
| 3914 | PCU.send(t_SD_PCUIF(g_pcu_conn_id, ts_PCUIF_TXT_IND(0, PCU_VERSION, testcasename()))); |
| 3915 | } |
| 3916 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 3917 | /* PDCH activation via PCU socket; check for presence of RTS.req */ |
| 3918 | testcase TC_pcu_act_req() runs on test_CT { |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 3919 | f_init_pcu_test(); |
| 3920 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 3921 | f_TC_pcu_act_req(0, 0, 7, true); |
| 3922 | } |
| 3923 | |
| 3924 | /* PDCH activation via PCU socket on non-PDCU timeslot */ |
| 3925 | testcase TC_pcu_act_req_wrong_ts() runs on test_CT { |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 3926 | f_init_pcu_test(); |
| 3927 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 3928 | f_TC_pcu_act_req(0, 0, 1, false); |
| 3929 | } |
| 3930 | |
| 3931 | /* PDCH activation via PCU socket on wrong BTS */ |
| 3932 | testcase TC_pcu_act_req_wrong_bts() runs on test_CT { |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 3933 | f_init_pcu_test(); |
| 3934 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 3935 | f_TC_pcu_act_req(23, 0, 7, false); |
| 3936 | } |
| 3937 | |
| 3938 | /* PDCH activation via PCU socket on wrong TRX */ |
| 3939 | testcase TC_pcu_act_req_wrong_trx() runs on test_CT { |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 3940 | f_init_pcu_test(); |
| 3941 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 3942 | f_TC_pcu_act_req(0, 23, 7, false); |
| 3943 | } |
| 3944 | |
| 3945 | /* PDCH deactivation via PCU socket; check for absence of RTS.req */ |
| 3946 | testcase TC_pcu_deact_req() runs on test_CT { |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 3947 | f_init_pcu_test(); |
| 3948 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 3949 | /* Activate PDCH */ |
| 3950 | f_TC_pcu_act_req(0, 0, 7, true); |
| 3951 | f_sleep(1.0); |
| 3952 | /* and De-Activate again */ |
| 3953 | f_TC_pcu_deact_req(0, 0, 7); |
| 3954 | } |
| 3955 | |
| 3956 | /* Attempt to deactivate a PDCH on a non-PDCH timeslot */ |
| 3957 | testcase TC_pcu_deact_req_wrong_ts() runs on test_CT { |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 3958 | f_init_pcu_test(); |
| 3959 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 3960 | f_TC_pcu_deact_req(0, 0, 1); |
| 3961 | } |
| 3962 | |
| 3963 | /* Test the PCU->BTS Version and BTS->PCU SI13 handshake */ |
| 3964 | testcase TC_pcu_ver_si13() runs on test_CT { |
| 3965 | const octetstring si13 := '00010203040506070909'O; |
| 3966 | var PCUIF_send_data sd; |
| 3967 | timer T:= 3.0; |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 3968 | f_init_pcu_test(); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 3969 | |
| 3970 | /* Set SI13 via RSL */ |
| 3971 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_13, si13); |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 3972 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 3973 | T.start; |
| 3974 | alt { |
| 3975 | [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_DATA_IND(0, 0, 0, ?, PCU_IF_SAPI_BCCH))) -> value sd { |
| 3976 | if (substr(sd.data.u.data_ind.data, 0, lengthof(si13)) == si13) { |
| 3977 | setverdict(pass); |
| 3978 | } else { |
| 3979 | repeat; |
| 3980 | } |
| 3981 | } |
| 3982 | [] PCU.receive { repeat; } |
| 3983 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3984 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for SI13"); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 3985 | } |
| 3986 | } |
| 3987 | } |
| 3988 | |
| 3989 | private const octetstring c_PCU_DATA := '000102030405060708090a0b0c0d0e0f10111213141516'O; |
| 3990 | |
| 3991 | /* helper function to send a PCU DATA.req */ |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 3992 | friend function f_pcu_data_req(uint8_t bts_nr, uint8_t trx_nr, uint8_t ts_nr, |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 3993 | uint8_t block_nr, uint32_t fn, PCUIF_Sapi sapi, octetstring data) |
| 3994 | runs on test_CT |
| 3995 | { |
| 3996 | PCU.send(t_SD_PCUIF(g_pcu_conn_id, |
| 3997 | ts_PCUIF_DATA_REQ(bts_nr, trx_nr, ts_nr, block_nr, fn, sapi, data))); |
| 3998 | } |
| 3999 | |
| 4000 | /* helper function to wait for RTS.ind for given SAPI on given BTS/TRX/TS and then send */ |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 4001 | friend function f_pcu_wait_rts_and_data_req(uint8_t bts_nr, uint8_t trx_nr, uint8_t ts_nr, |
| 4002 | PCUIF_Sapi sapi, octetstring data) |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4003 | runs on test_CT |
| 4004 | { |
| 4005 | var PCUIF_send_data sd; |
| 4006 | |
| 4007 | timer T := 3.0; |
| 4008 | T.start; |
| 4009 | alt { |
| 4010 | [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, |
| 4011 | tr_PCUIF_RTS_REQ(bts_nr, trx_nr, ts_nr, sapi))) -> value sd { |
| 4012 | f_pcu_data_req(bts_nr, trx_nr, ts_nr, sd.data.u.rts_req.block_nr, |
| 4013 | sd.data.u.rts_req.fn, sapi, data); |
| 4014 | } |
| 4015 | [] PCU.receive { repeat; } |
| 4016 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4017 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for RTS.ind"); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4018 | } |
| 4019 | } |
| 4020 | } |
| 4021 | |
| 4022 | /* Send DATA.req on invalid BTS */ |
| 4023 | testcase TC_pcu_data_req_wrong_bts() runs on test_CT { |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 4024 | var TfiUsfArr tua := f_TfiUsfArrInit(); |
| 4025 | var octetstring data := '0000'O & f_rnd_octstring(21); |
| 4026 | |
| 4027 | f_virtphy_common(); |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 4028 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4029 | f_TC_pcu_act_req(0, 0, 7, true); |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 4030 | f_TfiUsfArrSet(tua, 7, 0); |
| 4031 | f_L1CTL_TBF_CFG(L1CTL, false, tua); |
| 4032 | f_sleep(1.0); |
| 4033 | |
| 4034 | f_pcu_to_l1(23, 0, 7, PCU_IF_SAPI_PDTCH, data, false, false); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4035 | } |
| 4036 | |
| 4037 | /* Send DATA.req on invalid TRX */ |
| 4038 | testcase TC_pcu_data_req_wrong_trx() runs on test_CT { |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 4039 | var TfiUsfArr tua := f_TfiUsfArrInit(); |
| 4040 | var octetstring data := '0000'O & f_rnd_octstring(21); |
| 4041 | |
| 4042 | f_virtphy_common(); |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 4043 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4044 | f_TC_pcu_act_req(0, 0, 7, true); |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 4045 | f_TfiUsfArrSet(tua, 7, 0); |
| 4046 | f_L1CTL_TBF_CFG(L1CTL, false, tua); |
| 4047 | f_sleep(1.0); |
| 4048 | |
| 4049 | f_pcu_to_l1(0, 100, 7, PCU_IF_SAPI_PDTCH, data, false, false); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4050 | } |
| 4051 | |
| 4052 | /* Send DATA.req on invalid timeslot */ |
| 4053 | testcase TC_pcu_data_req_wrong_ts() runs on test_CT { |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 4054 | var TfiUsfArr tua := f_TfiUsfArrInit(); |
| 4055 | var octetstring data := '0000'O & f_rnd_octstring(21); |
| 4056 | |
| 4057 | f_virtphy_common(); |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 4058 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4059 | f_TC_pcu_act_req(0, 0, 7, true); |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 4060 | f_TfiUsfArrSet(tua, 7, 0); |
| 4061 | f_L1CTL_TBF_CFG(L1CTL, false, tua); |
| 4062 | f_sleep(1.0); |
| 4063 | |
| 4064 | f_pcu_to_l1(0, 0, 70, PCU_IF_SAPI_PDTCH, data, false, false); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4065 | } |
| 4066 | |
| 4067 | /* Send DATA.req on timeslot that hasn't been activated */ |
| 4068 | testcase TC_pcu_data_req_ts_inactive() runs on test_CT { |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 4069 | var TfiUsfArr tua := f_TfiUsfArrInit(); |
| 4070 | var octetstring data := '0000'O & f_rnd_octstring(21); |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 4071 | |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 4072 | f_virtphy_common(); |
| 4073 | |
| 4074 | f_TfiUsfArrSet(tua, 7, 0); |
| 4075 | f_L1CTL_TBF_CFG(L1CTL, false, tua); |
| 4076 | f_sleep(1.0); |
| 4077 | |
| 4078 | f_pcu_to_l1(0, 0, 7, PCU_IF_SAPI_PDTCH, data, false, false); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4079 | } |
| 4080 | |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 4081 | private function f_pcu_to_l1(uint8_t bts_nr, uint8_t trx_nr, uint8_t ts_nr, |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 4082 | PCUIF_Sapi sapi, octetstring data, boolean expect_data := true, |
| 4083 | boolean wait_rts := true) |
| 4084 | runs on test_CT { |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 4085 | timer T := 5.0; |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 4086 | var L1ctlDlMessage rx_dl; |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 4087 | |
| 4088 | PCU.clear; |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 4089 | if (wait_rts) { |
| 4090 | f_pcu_wait_rts_and_data_req(bts_nr, trx_nr, ts_nr, sapi, data); |
| 4091 | } else { |
| 4092 | f_pcu_data_req(bts_nr, trx_nr, ts_nr, 0, 0, sapi, data); |
| 4093 | } |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 4094 | |
| 4095 | T.start; |
| 4096 | alt { |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 4097 | [expect_data] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_PDCH(ts_nr), ?, data)) { |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 4098 | /* FIXME: why is fn of DATA_IND different to fn of RTS / DATA_REQ above? */ |
| 4099 | setverdict(pass); |
| 4100 | } |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 4101 | [not expect_data] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_PDCH(ts_nr), ?, data)) -> value rx_dl { |
| 4102 | setverdict(fail, "Received unexpected ", rx_dl); |
| 4103 | } |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 4104 | [] L1CTL.receive { |
| 4105 | repeat; |
| 4106 | } |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 4107 | [expect_data] T.timeout { |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 4108 | setverdict(fail, "Timeout waiting for ", data); |
| 4109 | } |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 4110 | [not expect_data] T.timeout { |
| 4111 | setverdict(pass); |
| 4112 | } |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 4113 | } |
| 4114 | } |
| 4115 | |
| 4116 | private function f_disable_dynamic_ts() runs on test_CT |
| 4117 | { |
| 4118 | f_init_vty_bsc(); |
| 4119 | /* I'm not quite sure why we need this with osmo-bts-virtual. Somehow it deosn't seem to |
| 4120 | * support dynamic timeslots? But it uses the same scheduler as osmo-bts-trx ?!? */ |
| 4121 | f_vty_config2(BSCVTY, {"network", "bts 0", "trx 0", "timeslot 3"}, "phys_chan_config TCH/F"); |
| 4122 | f_vty_config2(BSCVTY, {"network", "bts 0", "trx 0", "timeslot 4"}, "phys_chan_config TCH/F"); |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 4123 | f_init_pcu_test(); |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 4124 | } |
| 4125 | |
| 4126 | private function f_virtphy_common() runs on test_CT { |
| 4127 | f_disable_dynamic_ts(); |
| 4128 | f_init_l1ctl(); |
| 4129 | f_l1_tune(L1CTL); |
| 4130 | } |
| 4131 | |
| 4132 | testcase TC_pcu_data_req_pdtch() runs on test_CT { |
| 4133 | var TfiUsfArr tua := f_TfiUsfArrInit(); |
| 4134 | var octetstring data := '0000'O & f_rnd_octstring(21); |
| 4135 | |
| 4136 | f_virtphy_common(); |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 4137 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4138 | f_TC_pcu_act_req(0, 0, 7, true); |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 4139 | f_TfiUsfArrSet(tua, 7, 0); |
| 4140 | f_L1CTL_TBF_CFG(L1CTL, false, tua); |
| 4141 | f_sleep(1.0); |
| 4142 | |
| 4143 | f_pcu_to_l1(0, 0, 7, PCU_IF_SAPI_PDTCH, data); //c_PCU_DATA); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4144 | } |
| 4145 | |
| 4146 | testcase TC_pcu_data_req_ptcch() runs on test_CT { |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 4147 | var TfiUsfArr tua := f_TfiUsfArrInit(); |
| 4148 | var octetstring data := '0000'O & f_rnd_octstring(21); |
| 4149 | |
| 4150 | f_virtphy_common(); |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 4151 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4152 | f_TC_pcu_act_req(0, 0, 7, true); |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 4153 | f_TfiUsfArrSet(tua, 7, 0); |
| 4154 | f_L1CTL_TBF_CFG(L1CTL, false, tua); |
| 4155 | f_sleep(1.0); |
| 4156 | |
| 4157 | f_pcu_to_l1(0, 0, 7, PCU_IF_SAPI_PTCCH, data); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4158 | } |
| 4159 | |
| 4160 | /* Send AGCH from PCU; check it appears on Um side */ |
| 4161 | testcase TC_pcu_data_req_agch() runs on test_CT { |
| 4162 | timer T := 3.0; |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 4163 | f_init_pcu_test(); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4164 | f_init_l1ctl(); |
| 4165 | f_l1_tune(L1CTL); |
| 4166 | |
| 4167 | f_TC_pcu_act_req(0, 0, 7, true); |
| 4168 | f_pcu_data_req(0, 0, 7, 0, 0, PCU_IF_SAPI_AGCH, c_PCU_DATA); |
| 4169 | |
| 4170 | T.start; |
| 4171 | alt { |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 4172 | [] 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] | 4173 | setverdict(pass); |
| 4174 | } |
| 4175 | [] L1CTL.receive { repeat; } |
| 4176 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4177 | 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] | 4178 | } |
| 4179 | } |
| 4180 | } |
| 4181 | |
Harald Welte | 928622b | 2019-05-26 13:22:59 +0200 | [diff] [blame] | 4182 | /* Send AGCH from PCU; check it appears on Um side */ |
| 4183 | testcase TC_pcu_data_req_pch() runs on test_CT { |
| 4184 | timer T := 3.0; |
| 4185 | f_init_pcu_test(); |
| 4186 | f_init_l1ctl(); |
| 4187 | f_l1_tune(L1CTL); |
| 4188 | |
| 4189 | f_TC_pcu_act_req(0, 0, 7, true); |
| 4190 | /* three characters prefix: last 3 digits of IMSI as ASCII */ |
| 4191 | f_pcu_data_req(0, 0, 7, 0, 0, PCU_IF_SAPI_PCH, '313233'O & c_PCU_DATA); |
| 4192 | |
| 4193 | T.start; |
| 4194 | alt { |
| 4195 | [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_PCH_AGCH(0), ?, c_PCU_DATA)) { |
| 4196 | setverdict(pass); |
| 4197 | } |
| 4198 | [] L1CTL.receive { repeat; } |
| 4199 | [] T.timeout { |
| 4200 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for PCU-originated PCH block on Um"); |
| 4201 | } |
| 4202 | } |
| 4203 | } |
| 4204 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4205 | /* Send IMM.ASS from PCU for PCH; check it appears on Um side */ |
| 4206 | testcase TC_pcu_data_req_imm_ass_pch() runs on test_CT { |
| 4207 | var octetstring imm_ass := f_rnd_octstring(23); |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 4208 | f_init_pcu_test(); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4209 | f_init_l1ctl(); |
| 4210 | f_l1_tune(L1CTL); |
| 4211 | |
| 4212 | /* append 3 last imsi digits so BTS can compute pagng group */ |
| 4213 | var uint32_t fn := f_PCUIF_tx_imm_ass_pch(PCU, g_pcu_conn_id, imm_ass, '123459987'H); |
| 4214 | |
| 4215 | timer T := 0.5; |
| 4216 | T.start; |
| 4217 | alt { |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 4218 | [] 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] | 4219 | /* TODO: verify paging group */ |
| 4220 | setverdict(pass); |
| 4221 | } |
| 4222 | [] L1CTL.receive { repeat; } |
| 4223 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4224 | 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] | 4225 | } |
| 4226 | } |
| 4227 | } |
| 4228 | |
| 4229 | /* Send RACH from Um side, expect it to show up on PCU socket */ |
| 4230 | testcase TC_pcu_rach_content() runs on test_CT { |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 4231 | f_init_pcu_test(); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4232 | f_init_l1ctl(); |
| 4233 | f_l1_tune(L1CTL); |
| 4234 | |
| 4235 | var GsmFrameNumber fn_last := 0; |
| 4236 | for (var integer i := 0; i < 1000; i := i+1) { |
| 4237 | var OCT1 ra := f_rnd_ra_ps(); |
| 4238 | var GsmFrameNumber fn := f_L1CTL_RACH(L1CTL, oct2int(ra)); |
| 4239 | if (fn == fn_last) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4240 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Two RACH in same FN?!?"); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4241 | } |
| 4242 | fn_last := fn; |
| 4243 | |
| 4244 | timer T := 2.0; |
| 4245 | T.start; |
| 4246 | alt { |
| 4247 | [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RACH_IND(0, oct2int(ra), 0, ?, fn))) { |
| 4248 | T.stop; |
| 4249 | } |
| 4250 | [] 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] | 4251 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected RACH IND"); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4252 | } |
| 4253 | [] PCU.receive { repeat; } |
| 4254 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4255 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for RACH IND"); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4256 | } |
| 4257 | } |
| 4258 | } |
| 4259 | setverdict(pass); |
| 4260 | } |
| 4261 | |
Vadim Yanitskiy | 51cbc10 | 2019-04-22 06:37:30 +0700 | [diff] [blame] | 4262 | /* Send extended (11-bit, TS1 & TS2) RACH bursts from the Um side, |
| 4263 | * expect them to show up on PCU socket (with proper BURST_TYPE_*). */ |
| 4264 | testcase TC_pcu_ext_rach_content() runs on test_CT { |
| 4265 | var template PCUIF_Message pcu_rach_ind; |
| 4266 | var GsmFrameNumber fn_last := 0; |
| 4267 | var L1ctlRachSynchSeq synch_seq; |
| 4268 | var PCUIF_BurstType pcu_bt; |
| 4269 | var GsmFrameNumber fn; |
| 4270 | var BIT11 ra11; |
| 4271 | |
| 4272 | f_init_pcu_test(); |
| 4273 | f_init_l1ctl(); |
| 4274 | f_l1_tune(L1CTL); |
| 4275 | |
| 4276 | for (var integer i := 0; i < 1000; i := i+1) { |
| 4277 | /* We need to test both TS1 & TS2 */ |
| 4278 | if (i rem 2 == 0) { |
| 4279 | synch_seq := RACH_SYNCH_SEQ_TS1; |
| 4280 | pcu_bt := BURST_TYPE_1; |
| 4281 | } else { |
| 4282 | synch_seq := RACH_SYNCH_SEQ_TS2; |
| 4283 | pcu_bt := BURST_TYPE_2; |
| 4284 | } |
| 4285 | |
| 4286 | ra11 := f_rnd_ra11_ps(); |
| 4287 | fn := f_L1CTL_EXT_RACH(L1CTL, bit2int(ra11), synch_seq); |
| 4288 | if (fn == fn_last) { |
| 4289 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 4290 | "Two RACH in same FN?!?"); |
| 4291 | } |
| 4292 | fn_last := fn; |
| 4293 | |
| 4294 | /* Compose the expected message */ |
| 4295 | pcu_rach_ind := tr_PCUIF_RACH_IND( |
| 4296 | bts_nr := 0, |
| 4297 | ra := bit2int(ra11), |
| 4298 | is_11bit := 1, |
| 4299 | burst_type := pcu_bt, |
| 4300 | fn := fn); |
| 4301 | |
| 4302 | timer T := 2.0; |
| 4303 | T.start; |
| 4304 | alt { |
| 4305 | [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, pcu_rach_ind)) { |
| 4306 | T.stop; |
| 4307 | } |
| 4308 | [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RACH_IND)) { |
| 4309 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected RACH IND"); |
| 4310 | } |
| 4311 | [] PCU.receive { repeat; } |
| 4312 | [] T.timeout { |
| 4313 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for RACH IND"); |
| 4314 | } |
| 4315 | } |
| 4316 | } |
| 4317 | setverdict(pass); |
| 4318 | } |
| 4319 | |
Vadim Yanitskiy | a2c68e8 | 2019-07-03 13:07:20 +0700 | [diff] [blame] | 4320 | private function f_TC_pcu_data_ind_lqual_cb(int16_t lqual_cb_exp, int16_t thresh) |
| 4321 | runs on test_CT { |
| 4322 | var template PCUIF_send_data sdt; |
| 4323 | var PCUIF_send_data sd; |
| 4324 | var int16_t lqual_cb; |
| 4325 | timer T := 1.0; |
| 4326 | |
| 4327 | /* PCUIF_DATA.ind is encapsulated into a supplementary record */ |
| 4328 | sdt := t_SD_PCUIF_MSGT(g_pcu_conn_id, PCU_IF_MSG_DATA_IND); |
| 4329 | |
| 4330 | /* Send a random PDTCH frame over Um */ |
| 4331 | L1CTL.send(ts_L1CTL_TRAFFIC_REQ(ts_RslChanNr_PDCH(7), ts_RslLinkID_DCCH(0), |
| 4332 | '0000'O & f_rnd_octstring(21))); |
| 4333 | |
| 4334 | T.start; |
| 4335 | alt { |
| 4336 | /* If expected link quality is above the threshold */ |
| 4337 | [lqual_cb_exp >= thresh] PCU.receive(sdt) -> value sd { |
| 4338 | lqual_cb := sd.data.u.data_ind.lqual_cb; |
| 4339 | log("Rx PCUIF_DATA.ind (lqual_cb=", lqual_cb, ")"); |
| 4340 | |
| 4341 | /* Make sure the actual link quality matches the expected value */ |
| 4342 | if (not match(lqual_cb, lqual_cb_exp)) { |
| 4343 | setverdict(fail, log2str("Link quality ", lqual_cb, " does not match ", |
| 4344 | "expected value ", lqual_cb_exp)); |
| 4345 | } else { |
| 4346 | setverdict(pass); |
| 4347 | } |
| 4348 | } |
| 4349 | /* If expected link quality is below the threshold */ |
| 4350 | [lqual_cb_exp < thresh] PCU.receive(sdt) -> value sd { |
| 4351 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 4352 | log2str("Rx unexpected PCUIF_DATA.ind: ", sd.data)); |
| 4353 | } |
| 4354 | /* Ignore PCUIF_RTS.req and PCUIF_TIME.ind */ |
| 4355 | [] PCU.receive { repeat; } |
| 4356 | [lqual_cb_exp < thresh] T.timeout { |
| 4357 | log("Rx nothing, as expected"); |
| 4358 | setverdict(pass); |
| 4359 | } |
| 4360 | [lqual_cb_exp >= thresh] T.timeout { |
| 4361 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 4362 | "Timeout waiting for PCUIF_DATA.ind"); |
| 4363 | } |
| 4364 | } |
| 4365 | } |
| 4366 | |
| 4367 | /* Verify C/I (Carrier-to-Interference ratio) processing of PDTCH frames */ |
| 4368 | testcase TC_pcu_data_ind_lqual_cb() runs on test_CT { |
| 4369 | f_init_pcu_test(); |
| 4370 | PCU.clear; |
| 4371 | |
| 4372 | f_init_l1ctl(); |
| 4373 | f_l1_tune(L1CTL); |
| 4374 | |
| 4375 | /* Activate a PDCH channel on TS7 */ |
| 4376 | f_TC_pcu_act_req(0, 0, 7, true); |
| 4377 | |
| 4378 | /* Tune trxcon to that PDCH channel on TS7 */ |
| 4379 | f_L1CTL_DM_EST_REQ(L1CTL, { false, mp_trx0_arfcn }, |
| 4380 | valueof(ts_RslChanNr_PDCH(7)), 7); |
| 4381 | |
| 4382 | /* C/I in centiBels, test range: -256 .. +1280, step 128 */ |
| 4383 | for (var int16_t i := -256; i <= 1280; i := i + 128) { |
| 4384 | var TrxcMessage ret; |
| 4385 | |
| 4386 | ret := f_TRXC_transceive(BTS_TRXC, g_bts_trxc_conn_id, |
| 4387 | valueof(ts_TRXC_FAKE_CI(i))); |
| 4388 | |
| 4389 | /* FIXME: OsmoBTS may have different threshold (see MIN_QUAL_NORM) */ |
| 4390 | f_TC_pcu_data_ind_lqual_cb(i, thresh := 0); |
| 4391 | } |
| 4392 | } |
| 4393 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4394 | /* Send PAGING via RSL, expect it to shw up on PCU socket */ |
| 4395 | testcase TC_pcu_paging_from_rsl() runs on test_CT { |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 4396 | f_init_pcu_test(); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4397 | |
| 4398 | for (var integer i := 0; i < 100; i := i+1) { |
| 4399 | var MobileL3_CommonIE_Types.MobileIdentityLV mi; |
| 4400 | timer T := 3.0; |
| 4401 | if (i < 50) { |
| 4402 | mi := valueof(ts_MI_TMSI_LV(f_rnd_octstring(4))); |
| 4403 | } else { |
| 4404 | mi := valueof(ts_MI_IMSI_LV(f_gen_imsi(i))); |
| 4405 | } |
| 4406 | var octetstring mi_enc_lv := enc_MobileIdentityLV(mi); |
| 4407 | var octetstring mi_enc := substr(mi_enc_lv, 1, lengthof(mi_enc_lv)-1); |
| 4408 | var octetstring t_mi_lv := f_pad_oct(mi_enc_lv, 9, '00'O); |
| 4409 | |
| 4410 | /* Send RSL PAGING COMMAND */ |
| 4411 | RSL_CCHAN.send(ts_RSL_UD(ts_RSL_PAGING_CMD(mi_enc, i mod 4))); |
| 4412 | T.start; |
| 4413 | alt { |
| 4414 | [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_PAG_REQ(0, t_mi_lv))) { |
| 4415 | } |
| 4416 | [] 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] | 4417 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected PAGING REQ"); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4418 | } |
| 4419 | [] PCU.receive { repeat; } |
| 4420 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4421 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for PAGING REQ"); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4422 | } |
| 4423 | } |
| 4424 | } |
| 4425 | setverdict(pass); |
| 4426 | } |
| 4427 | |
Harald Welte | d66c9b8 | 2019-05-25 09:03:15 +0200 | [diff] [blame] | 4428 | /* test for periodic TIME_IND; check number of FN expired and number of TIME_IND within frames */ |
| 4429 | testcase TC_pcu_time_ind() runs on test_CT { |
| 4430 | var PCUIF_send_data pcu_sd; |
| 4431 | var integer num_time_ind := 0; |
| 4432 | var integer first_fn, last_fn; |
| 4433 | var float test_duration := 5.0; |
| 4434 | timer T; |
| 4435 | |
| 4436 | f_init_pcu_test(); |
| 4437 | f_TC_pcu_act_req(0, 0, 7, true); |
| 4438 | |
| 4439 | PCU.clear; |
| 4440 | T.start(test_duration); |
| 4441 | alt { |
| 4442 | [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_TIME_IND(0, ?))) -> value pcu_sd { |
| 4443 | num_time_ind := num_time_ind + 1; |
| 4444 | if (not isbound(first_fn)) { |
| 4445 | first_fn := pcu_sd.data.u.time_ind.fn; |
| 4446 | } |
| 4447 | last_fn := pcu_sd.data.u.time_ind.fn; |
| 4448 | repeat; |
| 4449 | } |
| 4450 | [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_TIME_IND(?, ?))) -> value pcu_sd { |
| 4451 | setverdict(fail, "Received unexpected PCUIF_TIME_IND: ", pcu_sd.data); |
| 4452 | repeat; |
| 4453 | } |
| 4454 | [] PCU.receive { |
| 4455 | repeat; |
| 4456 | } |
| 4457 | [] T.timeout {} |
| 4458 | } |
| 4459 | var integer fn_expired := last_fn - first_fn; |
| 4460 | log(fn_expired, " fn expired with ", num_time_ind, " PCU_TIME.ind"); |
| 4461 | |
| 4462 | /* verify the number of frames expired matches our expectation */ |
| 4463 | const float c_GSM_FN_DURATION_MS := 4.61538; |
| 4464 | var float fn_expected := test_duration * 1000.0 / c_GSM_FN_DURATION_MS; |
Harald Welte | c761c54 | 2019-05-28 11:59:57 +0200 | [diff] [blame] | 4465 | var template integer t_fn_expected := f_tolerance(float2int(fn_expected), 1, 100000, 20); |
Harald Welte | d66c9b8 | 2019-05-25 09:03:15 +0200 | [diff] [blame] | 4466 | if (not match(fn_expired, t_fn_expected)) { |
| 4467 | setverdict(fail, "Number of TDMA Frames (", fn_expired, ") not matching ", t_fn_expected); |
| 4468 | } |
| 4469 | |
| 4470 | /* There are three TIME.ind in every fn MOD 13 */ |
| 4471 | var float time_ind_expected := int2float(fn_expired) * 3.0 / 13.0; |
| 4472 | /* Add some tolerance */ |
| 4473 | var template integer t_time_ind_exp := f_tolerance(float2int(time_ind_expected), 1, 100000, 5); |
| 4474 | if (not match(num_time_ind, t_time_ind_exp)) { |
| 4475 | setverdict(fail, "Number of TIME.ind (", num_time_ind, ") not matching ", t_time_ind_exp); |
| 4476 | } |
| 4477 | |
| 4478 | setverdict(pass); |
| 4479 | } |
| 4480 | |
Harald Welte | 4832c86 | 2019-05-25 14:57:18 +0200 | [diff] [blame] | 4481 | /* test for periodic RTS_REQ; check number of FN expired and number of RTS_IND per SAPI */ |
| 4482 | testcase TC_pcu_rts_req() runs on test_CT { |
| 4483 | var PCUIF_send_data pcu_sd; |
| 4484 | var integer first_fn, last_fn; |
| 4485 | var integer num_rts_pdtch := 0; |
| 4486 | var integer num_rts_ptcch := 0; |
| 4487 | var float test_duration := 5.0; |
| 4488 | timer T; |
| 4489 | |
| 4490 | f_init_pcu_test(); |
| 4491 | f_TC_pcu_act_req(0, 0, 7, true); |
| 4492 | |
| 4493 | PCU.clear; |
| 4494 | T.start(test_duration); |
| 4495 | alt { |
| 4496 | [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RTS_REQ(0, 0, 7, PCU_IF_SAPI_PDTCH, ?, ?))) |
| 4497 | -> value pcu_sd { |
| 4498 | num_rts_pdtch := num_rts_pdtch + 1; |
| 4499 | if (not isbound(first_fn)) { |
| 4500 | first_fn := pcu_sd.data.u.rts_req.fn; |
| 4501 | } |
| 4502 | last_fn := pcu_sd.data.u.rts_req.fn; |
| 4503 | repeat; |
| 4504 | } |
| 4505 | [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RTS_REQ(0, 0, 7, PCU_IF_SAPI_PTCCH, ?, ?))) |
| 4506 | -> value pcu_sd { |
| 4507 | num_rts_ptcch := num_rts_ptcch + 1; |
| 4508 | if (not isbound(first_fn)) { |
| 4509 | first_fn := pcu_sd.data.u.rts_req.fn; |
| 4510 | } |
| 4511 | last_fn := pcu_sd.data.u.rts_req.fn; |
| 4512 | repeat; |
| 4513 | } |
| 4514 | [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RTS_REQ)) -> value pcu_sd { |
| 4515 | setverdict(fail, "Received unexpected PCUIF_RTS_REQ: ", pcu_sd.data); |
| 4516 | repeat; |
| 4517 | } |
| 4518 | [] PCU.receive { |
| 4519 | repeat; |
| 4520 | } |
| 4521 | [] T.timeout {} |
| 4522 | } |
| 4523 | var integer fn_expired := last_fn - first_fn; |
| 4524 | log(fn_expired, " fn expired with num_rts_pdtch=", num_rts_pdtch, |
| 4525 | ", num_rts_ptcch=", num_rts_ptcch); |
| 4526 | |
| 4527 | /* verify the number of frames expired matches our expectation */ |
| 4528 | const float c_GSM_FN_DURATION_MS := 4.61538; |
| 4529 | var float fn_expected := test_duration * 1000.0 / c_GSM_FN_DURATION_MS; |
Harald Welte | c761c54 | 2019-05-28 11:59:57 +0200 | [diff] [blame] | 4530 | var template integer t_fn_expected := f_tolerance(float2int(fn_expected), 1, 100000, 20); |
Harald Welte | 4832c86 | 2019-05-25 14:57:18 +0200 | [diff] [blame] | 4531 | if (not match(fn_expired, t_fn_expected)) { |
| 4532 | setverdict(fail, "Number of TDMA Frames (", fn_expired, ") not matching ", t_fn_expected); |
| 4533 | } |
| 4534 | |
| 4535 | /* PTCCH is in pos. 12 + 38 of 52-multiframe, but four slots/bursts required per block */ |
| 4536 | var float ptcch_expected := int2float(fn_expired) / 52.0 * 0.5; |
| 4537 | var template integer t_ptcch_exp := f_tolerance(float2int(ptcch_expected), 1, 100000, 1); |
| 4538 | if (not match(num_rts_ptcch, t_ptcch_exp)) { |
| 4539 | setverdict(fail, "Number of RTS.ind for PTCCH (", num_rts_ptcch, ") not matching ", |
| 4540 | t_ptcch_exp); |
| 4541 | } |
| 4542 | |
| 4543 | /* We have 12 PDTCH blocks every 52-multiframe */ |
| 4544 | var float pdtch_expected := int2float(fn_expired) / 52.0 * 12.0; |
| 4545 | var template integer t_pdtch_exp := f_tolerance(float2int(pdtch_expected), 1, 100000, 2); |
| 4546 | if (not match(num_rts_pdtch, t_pdtch_exp)) { |
| 4547 | setverdict(fail, "Number of RTS.ind for PDTCH (", num_rts_pdtch, ") not matching ", |
| 4548 | t_pdtch_exp); |
| 4549 | } |
| 4550 | |
| 4551 | setverdict(pass); |
| 4552 | } |
| 4553 | |
Harald Welte | 07bd2d2 | 2019-05-25 11:03:30 +0200 | [diff] [blame] | 4554 | /* test for generating Abis side OML ALERT from the PCU */ |
| 4555 | testcase TC_pcu_oml_alert() runs on test_CT { |
| 4556 | var PCUIF_send_data pcu_sd; |
| 4557 | var integer num_time_ind := 0; |
| 4558 | var integer first_fn, last_fn; |
| 4559 | var float test_duration := 5.0; |
| 4560 | timer T; |
| 4561 | |
| 4562 | f_init_pcu_test(); |
| 4563 | f_TC_pcu_act_req(0, 0, 7, true); |
| 4564 | |
| 4565 | /* re-connect CTRL port from BTS to BSC */ |
| 4566 | f_ipa_ctrl_stop(); |
| 4567 | f_ipa_ctrl_start(mp_bsc_ctrl_ip, mp_bsc_ctrl_port); |
| 4568 | |
| 4569 | /* Send that OML Alert */ |
| 4570 | PCU.send(t_SD_PCUIF(g_pcu_conn_id, ts_PCUIF_TXT_IND(0, PCU_OML_ALERT, testcasename()))); |
| 4571 | |
| 4572 | /* This requires https://gerrit.osmocom.org/#/c/osmo-bsc/+/14177 to be merged */ |
| 4573 | f_ctrl_exp_trap(IPA_CTRL, "bts.0.oml_failure_report", ?); |
| 4574 | setverdict(pass); |
| 4575 | } |
| 4576 | |
Harald Welte | eaa9a86 | 2019-05-26 23:01:08 +0200 | [diff] [blame] | 4577 | template (value) PDU_ML3_MS_NW ts_RRM_GprsSuspReq(template (value) OCT4 tlli, |
| 4578 | template (value) RoutingAreaIdentificationV rai, |
| 4579 | template (value) OCT1 cause) := { |
| 4580 | discriminator := '0000'B, /* overwritten */ |
| 4581 | tiOrSkip := { |
| 4582 | skipIndicator := '0000'B |
| 4583 | }, |
| 4584 | msgs := { |
| 4585 | rrm := { |
| 4586 | gPRS_suspensionRequest := { |
| 4587 | messageType := '00110100'B, |
| 4588 | tLLI := tlli, |
| 4589 | routingAreaIdentification := rai, |
| 4590 | suspensionCause := cause, |
| 4591 | service_Support := omit |
| 4592 | } |
| 4593 | } |
| 4594 | } |
| 4595 | } |
| 4596 | |
| 4597 | /* test for forwarding of RR SUSPEND from CS lchan to PCU via PCU socket */ |
| 4598 | private function f_TC_rr_suspend_req(charstring id) runs on ConnHdlr { |
| 4599 | var PCUIF_Message first_info; |
| 4600 | var integer pcu_conn_id := -1; |
| 4601 | var RslLinkId link_id := valueof(ts_RslLinkID_DCCH(0)); |
| 4602 | var RoutingAreaIdentificationV rai := f_RAI('262'H, '42F'H, '2342'O, '55'O); |
| 4603 | var OCT4 tlli := '01020304'O; |
| 4604 | var OCT1 cause := '23'O; |
| 4605 | timer T := 5.0; |
| 4606 | |
| 4607 | f_init_pcu(PCU, id, pcu_conn_id, first_info); |
| 4608 | |
| 4609 | f_l1_tune(L1CTL); |
| 4610 | RSL.clear; |
| 4611 | |
| 4612 | f_est_dchan(); |
| 4613 | L1CTL.clear; |
| 4614 | |
| 4615 | f_est_rll_mo(link_id.sapi, link_id, '23420815'O); |
| 4616 | |
| 4617 | var PDU_ML3_MS_NW susp_req := valueof(ts_RRM_GprsSuspReq(tlli, rai, cause)); |
| 4618 | var octetstring l3 := enc_PDU_ML3_MS_NW(susp_req); |
| 4619 | f_tx_lapdm(ts_LAPDm_I(link_id.sapi, cr_MO_CMD, true, 1, 0, l3), link_id); |
| 4620 | |
| 4621 | /* ConnHdlr has terminated after sending the RR SUSP REQ over a dedicaed channel */ |
| 4622 | T.start; |
| 4623 | alt { |
| 4624 | [] PCU.receive(t_SD_PCUIF(pcu_conn_id, tr_PCUIF_SUSP_REQ(0, tlli, ?, oct2int(cause)))) { |
| 4625 | setverdict(pass); |
| 4626 | } |
| 4627 | [] PCU.receive(t_SD_PCUIF(pcu_conn_id, tr_PCUIF_SUSP_REQ(?, ?, ?, ?))) { |
| 4628 | setverdict(fail, "Received unexpected PCUIF SUSPE REQ: "); |
| 4629 | } |
| 4630 | [] PCU.receive { |
| 4631 | repeat; |
| 4632 | } |
| 4633 | [] T.timeout { |
| 4634 | setverdict(fail, "Timeout waiting for SUSP REQ on PCUIF"); |
| 4635 | } |
| 4636 | } |
Alexander Couzens | a063483 | 2019-06-07 00:28:56 +0200 | [diff] [blame] | 4637 | |
| 4638 | /* release the channel */ |
| 4639 | f_rsl_chan_deact(); |
| 4640 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 4641 | f_rslem_unregister(0, g_chan_nr); |
Harald Welte | eaa9a86 | 2019-05-26 23:01:08 +0200 | [diff] [blame] | 4642 | } |
| 4643 | testcase TC_pcu_rr_suspend() runs on test_CT { |
| 4644 | var ConnHdlrPars pars; |
| 4645 | var ConnHdlr vc_conn; |
| 4646 | |
| 4647 | f_init(); |
| 4648 | |
| 4649 | pars := valueof(t_Pars(t_RslChanNr_SDCCH4(0,3), ts_RSL_ChanMode_SIGN)); |
| 4650 | vc_conn := f_start_handler(refers(f_TC_rr_suspend_req), pars, true); |
| 4651 | vc_conn.done; |
| 4652 | } |
Harald Welte | 07bd2d2 | 2019-05-25 11:03:30 +0200 | [diff] [blame] | 4653 | |
Harald Welte | a2e0e94 | 2019-05-27 18:12:53 +0200 | [diff] [blame] | 4654 | /* Ensure that PCUIF socket can accept only a single connection */ |
| 4655 | testcase TC_pcu_socket_connect_multi() runs on test_CT { |
| 4656 | timer T := 5.0; |
| 4657 | |
| 4658 | /* this (among other things) establishes the first connection to the PCUIF socket */ |
| 4659 | f_init(); |
| 4660 | |
| 4661 | /* try to establish a second connection, expect it to fail */ |
| 4662 | PCU.send(UD_connect:{mp_pcu_socket, -1}); |
| 4663 | T.start; |
| 4664 | alt { |
| 4665 | [] PCU.receive(UD_connect_result:{id := ?, result := { result_code := ERROR, err := ? }}) { |
| 4666 | setverdict(pass); |
| 4667 | } |
| 4668 | [] PCU.receive(UD_connect_result:?) { |
| 4669 | setverdict(fail, "Unexpected unix domain connect result"); |
| 4670 | } |
| 4671 | [] T.timeout { |
| 4672 | setverdict(pass); |
| 4673 | } |
| 4674 | } |
| 4675 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 4676 | } |
| 4677 | |
Harald Welte | c8effb7 | 2019-05-27 18:23:04 +0200 | [diff] [blame] | 4678 | /* Ensure that PCUIF socket can disconnect + reconnect */ |
| 4679 | testcase TC_pcu_socket_reconnect() runs on test_CT { |
| 4680 | /* this (among other things) establishes the first connection to the PCUIF socket */ |
| 4681 | f_init(); |
| 4682 | |
| 4683 | f_sleep(1.0); |
| 4684 | |
| 4685 | f_pcuif_close(PCU, g_pcu_conn_id); |
| 4686 | g_pcu_conn_id := -1; |
| 4687 | |
| 4688 | f_sleep(1.0); |
| 4689 | |
| 4690 | /* re-connect */ |
| 4691 | PCU.clear; |
| 4692 | f_init_pcu(PCU, testcasename(), g_pcu_conn_id, g_pcu_last_info); |
| 4693 | setverdict(pass); |
| 4694 | |
| 4695 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 4696 | } |
| 4697 | |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 4698 | /* Ensure that GPRS capability is not advertised before PCU socket conncet */ |
| 4699 | private function f_get_si3(L1CTL_PT pt) runs on test_CT return SystemInformationType3 { |
| 4700 | var L1ctlDlMessage l1_dl; |
| 4701 | var SystemInformation si; |
| 4702 | timer T := 5.0; |
| 4703 | T.start; |
| 4704 | alt { |
| 4705 | [] pt.receive(tr_L1CTL_DATA_IND(t_RslChanNr_BCCH(0), ?)) -> value l1_dl { |
| 4706 | /* somehow dec_SystemInformation will try to decode even non-RR as SI */ |
| 4707 | if (not (l1_dl.payload.data_ind.payload[1] == '06'O)) { |
| 4708 | log("Ignoring non-RR SI ", l1_dl); |
| 4709 | repeat; |
| 4710 | } |
| 4711 | si := dec_SystemInformation(l1_dl.payload.data_ind.payload) |
| 4712 | if (not ischosen(si.payload.si3)) { |
| 4713 | repeat; |
| 4714 | } |
| 4715 | } |
| 4716 | [] pt.receive { |
| 4717 | repeat; |
| 4718 | } |
| 4719 | [] T.timeout { |
| 4720 | setverdict(fail, "Timeout waiting for SI3"); |
| 4721 | } |
| 4722 | } |
| 4723 | return si.payload.si3; |
| 4724 | } |
| 4725 | |
| 4726 | /* CSN.1 L/H logic: is the bit at the current position using "inverted logic" (true) or not? */ |
| 4727 | private function f_bitpos_is_inv(integer idx) return boolean { |
| 4728 | select (idx mod 8) { |
| 4729 | case ((2, 4, 6, 7)) { return true; } /* 1-bits of 0x2B */ |
| 4730 | case else { return false; } /* 0-bits of 0x2B */ |
| 4731 | } |
| 4732 | } |
| 4733 | /* determine if the bit at position 'idx' in 'str' is a CSN.1 'H' (true) or 'L' (false) */ |
| 4734 | private function f_bit_is_high(bitstring str, integer idx) return boolean { |
| 4735 | var boolean invert := f_bitpos_is_inv(idx); |
| 4736 | if (invert) { |
| 4737 | if (str[idx] == '1'B) { |
| 4738 | return false; |
| 4739 | } else { |
| 4740 | return true; |
| 4741 | } |
| 4742 | } else { |
| 4743 | if (str[idx] == '1'B) { |
| 4744 | return true; |
| 4745 | } else { |
| 4746 | return false; |
| 4747 | } |
| 4748 | } |
| 4749 | } |
| 4750 | /* As the TITAN RAW codec cannot expres the CSN.1 L/H concept yet, we have to do this |
| 4751 | manually. Let's hope https://www.eclipse.org/forums/index.php/t/1099087/ takes off and |
| 4752 | we can replace this piece of code soon ... */ |
| 4753 | private function f_si3_has_gprs_indicator(OCT4 si3_restoctets) return boolean { |
| 4754 | var bitstring bits := oct2bit(si3_restoctets); |
| 4755 | var integer idx := 0; |
| 4756 | |
| 4757 | if (f_bit_is_high(bits, idx)) { |
| 4758 | /* skip Optional selection parameters */ |
| 4759 | idx := idx + 16; |
| 4760 | } else { |
| 4761 | idx := idx + 1; |
| 4762 | } |
| 4763 | |
| 4764 | if (f_bit_is_high(bits, idx)) { |
| 4765 | /* skip Optional power offset */ |
| 4766 | idx := idx + 3; |
| 4767 | } else { |
| 4768 | idx := idx + 1; |
| 4769 | } |
| 4770 | |
| 4771 | /* skip SI2ter Indicator */ |
| 4772 | idx := idx + 1; |
| 4773 | |
| 4774 | /* skip Early CM Sending Control */ |
| 4775 | idx := idx + 1; |
| 4776 | |
| 4777 | /* skip Scheduling if and where */ |
| 4778 | if (f_bit_is_high(bits, idx)) { |
| 4779 | idx := idx + 4; |
| 4780 | } else { |
| 4781 | idx := idx + 1; |
| 4782 | } |
| 4783 | |
| 4784 | return f_bit_is_high(bits, idx); |
| 4785 | } |
| 4786 | |
| 4787 | testcase TC_pcu_socket_noconnect_nosi3gprs() runs on test_CT { |
| 4788 | var SystemInformationType3 si3; |
| 4789 | timer T := 5.0; |
| 4790 | |
| 4791 | /* don't call f_init() as this would connect PCU socket */ |
| 4792 | f_init_rsl(testcasename()); |
| 4793 | T.start; |
| 4794 | alt { |
| 4795 | [] RSL_CCHAN.receive(ASP_IPA_Event:{up_down := ASP_IPA_EVENT_UP}); |
| 4796 | [] T.timeout { |
| 4797 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for ASP_IPA_EVENT_UP"); |
| 4798 | } |
| 4799 | } |
| 4800 | f_rsl_bcch_fill(RSL_SYSTEM_INFO_3, ts_SI3_default); |
| 4801 | |
| 4802 | f_init_l1ctl(); |
| 4803 | f_l1_tune(L1CTL); |
| 4804 | |
| 4805 | f_sleep(2.0); |
| 4806 | L1CTL.clear; |
| 4807 | si3 := f_get_si3(L1CTL); |
| 4808 | if (f_si3_has_gprs_indicator(si3.rest_octets)) { |
| 4809 | setverdict(fail, "SI3 indicates GPRS even before PCU socket connected"); |
| 4810 | } else { |
| 4811 | setverdict(pass); |
| 4812 | } |
| 4813 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 4814 | } |
| 4815 | |
| 4816 | /* Ensure that GPRS capability is advertised after PCU socket connect */ |
| 4817 | testcase TC_pcu_socket_connect_si3gprs() runs on test_CT { |
| 4818 | var SystemInformationType3 si3; |
| 4819 | |
| 4820 | /* this (among other things) establishes the first connection to the PCUIF socket */ |
| 4821 | f_init(); |
| 4822 | f_init_l1ctl(); |
| 4823 | f_l1_tune(L1CTL); |
| 4824 | |
| 4825 | f_sleep(2.0); |
| 4826 | L1CTL.clear; |
| 4827 | si3 := f_get_si3(L1CTL); |
| 4828 | if (not f_si3_has_gprs_indicator(si3.rest_octets)) { |
| 4829 | setverdict(fail, "SI3 indicates no GPRS despite PCU socket connected"); |
| 4830 | } else { |
| 4831 | setverdict(pass); |
| 4832 | } |
| 4833 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 4834 | } |
| 4835 | |
| 4836 | /* Ensure that GPRS capability is no longer advertised after PCU socket disconnect */ |
| 4837 | testcase TC_pcu_socket_disconnect_nosi3gprs() runs on test_CT { |
| 4838 | var SystemInformationType3 si3; |
| 4839 | |
| 4840 | /* this (among other things) establishes the first connection to the PCUIF socket */ |
| 4841 | f_init(); |
| 4842 | f_init_l1ctl(); |
| 4843 | f_l1_tune(L1CTL); |
| 4844 | |
| 4845 | f_pcuif_close(PCU, g_pcu_conn_id); |
| 4846 | g_pcu_conn_id := -1; |
| 4847 | |
| 4848 | f_sleep(1.0); |
| 4849 | |
| 4850 | /* re-connect */ |
| 4851 | PCU.clear; |
| 4852 | f_init_pcu(PCU, testcasename(), g_pcu_conn_id, g_pcu_last_info); |
| 4853 | |
| 4854 | f_sleep(2.0); |
| 4855 | L1CTL.clear; |
| 4856 | si3 := f_get_si3(L1CTL); |
| 4857 | if (f_si3_has_gprs_indicator(si3.rest_octets)) { |
| 4858 | setverdict(fail, "SI3 indicates GPRS after PCU socket disconnected"); |
| 4859 | } else { |
| 4860 | setverdict(pass); |
| 4861 | } |
| 4862 | |
| 4863 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 4864 | } |
| 4865 | |
Oliver Smith | f5239c7 | 2019-08-28 10:01:25 +0200 | [diff] [blame] | 4866 | /* Verify that the cell_id of SI3 (TS 04.08 9.1.35) and other values are passed properly to the PCU socket (OS#3854) */ |
| 4867 | testcase TC_pcu_socket_verify_info_ind() runs on test_CT { |
| 4868 | var SystemInformation si3 := valueof(ts_SI3_default); |
| 4869 | |
| 4870 | f_init(); |
| 4871 | |
| 4872 | /* Verify cell_id */ |
| 4873 | var uint16_t cell_id_si3 := si3.payload.si3.cell_id; |
| 4874 | var uint16_t cell_id_pcu := g_pcu_last_info.u.info_ind.cell_id; |
| 4875 | if (cell_id_si3 != cell_id_pcu) { |
Oliver Smith | e1c00f0 | 2019-09-04 11:35:56 +0200 | [diff] [blame] | 4876 | setverdict(fail, "Expected cell_id '", cell_id_si3, "' and got '", cell_id_pcu, "'. This either means,", |
| 4877 | " that the BTS is sending the wrong cell_id, or that the BTS sent it too early", |
| 4878 | " (OS#4179)"); |
Oliver Smith | f5239c7 | 2019-08-28 10:01:25 +0200 | [diff] [blame] | 4879 | } |
| 4880 | |
| 4881 | /* Verify LAC */ |
| 4882 | var uint16_t lac_si3 := si3.payload.si3.lai.lac; |
| 4883 | var uint16_t lac_pcu := g_pcu_last_info.u.info_ind.lac; |
| 4884 | if (lac_si3 != lac_pcu) { |
| 4885 | setverdict(fail, "Expected LAC ", lac_si3, " got: ", lac_pcu); |
| 4886 | } |
| 4887 | |
| 4888 | setverdict(pass); |
| 4889 | } |
Harald Welte | d66c9b8 | 2019-05-25 09:03:15 +0200 | [diff] [blame] | 4890 | |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 4891 | /*********************************************************************** |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 4892 | * Osmocom Style Dynamic Timeslot Support |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 4893 | ***********************************************************************/ |
| 4894 | |
| 4895 | private function f_dyn_osmo_pdch_act(integer pcu_conn_id, integer bts_nr, integer trx_nr) |
| 4896 | runs on ConnHdlr { |
| 4897 | var PCUIF_send_data sd; |
| 4898 | /* Expect BTS to immediately acknowledge activation as PDCH */ |
| 4899 | PCU.clear; |
| 4900 | f_rsl_chan_act(g_pars.chan_mode); |
| 4901 | /* expect INFO_IND on PCU interface listing TS as PDCH */ |
| 4902 | alt { |
| 4903 | [] PCU.receive(t_SD_PCUIF(pcu_conn_id, tr_PCUIF_INFO_IND(bts_nr, ?))) -> value sd { |
| 4904 | 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] | 4905 | 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] | 4906 | } |
| 4907 | } |
| 4908 | [] PCU.receive { repeat; } |
| 4909 | } |
| 4910 | /* try to activate this PDCH from the PCU point of view */ |
| 4911 | PCU.send(t_SD_PCUIF(pcu_conn_id, ts_PCUIF_ACT_REQ(bts_nr, trx_nr, g_chan_nr.tn))); |
| 4912 | /* FIXME: is there a response? */ |
| 4913 | } |
| 4914 | |
| 4915 | private function f_dyn_osmo_pdch_deact(integer pcu_conn_id, integer bts_nr, integer trx_nr) |
| 4916 | runs on ConnHdlr { |
| 4917 | var PCUIF_send_data sd; |
| 4918 | /* Send RSL CHAN REL (deactivate) */ |
| 4919 | PCU.clear; |
| 4920 | RSL.send(ts_RSL_RF_CHAN_REL(g_chan_nr)); |
| 4921 | /* expect BTS to ask PCU to deactivate the channel */ |
| 4922 | alt { |
| 4923 | [] PCU.receive(t_SD_PCUIF(pcu_conn_id, tr_PCUIF_INFO_IND(bts_nr, ?))) -> value sd { |
| 4924 | 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] | 4925 | 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] | 4926 | } |
| 4927 | } |
| 4928 | [] PCU.receive { repeat; } |
| 4929 | } |
| 4930 | /* Emulate PCU asking BTS to deactivate PDCH */ |
| 4931 | PCU.send(t_SD_PCUIF(pcu_conn_id, ts_PCUIF_DEACT_REQ(bts_nr, trx_nr, g_chan_nr.tn))); |
| 4932 | alt { |
| 4933 | [] RSL.receive(tr_RSL_RF_CHAN_REL_ACK(g_chan_nr)) { |
| 4934 | setverdict(pass); |
| 4935 | } |
| 4936 | [] RSL.receive { repeat; } |
| 4937 | } |
| 4938 | } |
| 4939 | |
| 4940 | /* Activate Osmocom-style dynamic PDCH from BSC side */ |
| 4941 | function f_TC_dyn_osmo_pdch_act_deact(charstring id) runs on ConnHdlr { |
| 4942 | var PCUIF_Message first_info; |
| 4943 | var integer ts_nr := g_chan_nr.tn; |
| 4944 | var integer trx_nr := 0; |
| 4945 | var integer bts_nr := 0; |
| 4946 | var integer pcu_conn_id := -1; |
| 4947 | |
| 4948 | f_init_pcu(PCU, id, pcu_conn_id, first_info); |
| 4949 | |
| 4950 | f_dyn_osmo_pdch_act(pcu_conn_id, bts_nr, trx_nr); |
| 4951 | f_sleep(3.0); |
| 4952 | f_dyn_osmo_pdch_deact(pcu_conn_id, bts_nr, trx_nr); |
| 4953 | setverdict(pass); |
| 4954 | } |
| 4955 | testcase TC_dyn_osmo_pdch_act_deact() runs on test_CT { |
| 4956 | var ConnHdlrPars pars; |
| 4957 | var ConnHdlr vc_conn; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 4958 | f_init(); |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 4959 | |
| 4960 | pars := valueof(t_Pars(t_RslChanNr_PDCH(4), ts_RSL_ChanMode_SIGN)); |
| 4961 | vc_conn := f_start_handler(refers(f_TC_dyn_osmo_pdch_act_deact), pars, true); |
| 4962 | vc_conn.done; |
| 4963 | } |
| 4964 | |
| 4965 | /* send a RF CHAN REL for PDCH on an osmocom dynamci PDCH that's already inactive */ |
| 4966 | function f_TC_dyn_osmo_pdch_unsol_deact(charstring id) runs on ConnHdlr { |
| 4967 | var PCUIF_Message first_info; |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 4968 | var integer pcu_conn_id := -1; |
| 4969 | |
| 4970 | f_init_pcu(PCU, id, pcu_conn_id, first_info); |
| 4971 | |
Neels Hofmeyr | 9c50ca5 | 2018-05-08 20:37:54 +0200 | [diff] [blame] | 4972 | RSL.send(ts_RSL_RF_CHAN_REL(g_chan_nr)); |
| 4973 | /* since the lchan is already released, we don't expect any PCU changes, just a rel ack. */ |
| 4974 | RSL.receive(tr_RSL_RF_CHAN_REL_ACK(g_chan_nr)); |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 4975 | setverdict(pass); |
| 4976 | } |
| 4977 | testcase TC_dyn_osmo_pdch_unsol_deact() runs on test_CT { |
| 4978 | var ConnHdlrPars pars; |
| 4979 | var ConnHdlr vc_conn; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 4980 | f_init(); |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 4981 | |
| 4982 | pars := valueof(t_Pars(t_RslChanNr_PDCH(4), ts_RSL_ChanMode_SIGN)); |
| 4983 | vc_conn := f_start_handler(refers(f_TC_dyn_osmo_pdch_unsol_deact), pars, true); |
| 4984 | vc_conn.done; |
| 4985 | } |
| 4986 | |
| 4987 | /* try to RSL CHAN ACT a PDCH on an osmocom-style PDCH that's already active */ |
| 4988 | function f_TC_dyn_osmo_pdch_double_act(charstring id) runs on ConnHdlr { |
| 4989 | var PCUIF_Message first_info; |
| 4990 | var integer ts_nr := g_chan_nr.tn; |
| 4991 | var integer trx_nr := 0; |
| 4992 | var integer bts_nr := 0; |
| 4993 | var integer pcu_conn_id := -1; |
| 4994 | |
| 4995 | f_init_pcu(PCU, id, pcu_conn_id, first_info); |
| 4996 | |
| 4997 | f_dyn_osmo_pdch_act(pcu_conn_id, bts_nr, trx_nr); |
Neels Hofmeyr | df936a2 | 2018-05-08 22:07:57 +0200 | [diff] [blame] | 4998 | /* Send a second Chan Activ and expect it to be NACKed */ |
| 4999 | f_rsl_transceive(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode), tr_RSL_CHAN_ACT_NACK(g_chan_nr), |
| 5000 | "RSL CHAN ACT NACK"); |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 5001 | setverdict(pass); |
| 5002 | } |
| 5003 | testcase TC_dyn_osmo_pdch_double_act() runs on test_CT { |
| 5004 | var ConnHdlrPars pars; |
| 5005 | var ConnHdlr vc_conn; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 5006 | f_init(); |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 5007 | |
| 5008 | pars := valueof(t_Pars(t_RslChanNr_PDCH(4), ts_RSL_ChanMode_SIGN)); |
| 5009 | vc_conn := f_start_handler(refers(f_TC_dyn_osmo_pdch_double_act), pars, true); |
| 5010 | vc_conn.done; |
| 5011 | } |
| 5012 | |
| 5013 | /* try to RSL CHAN ACT a TCH/F on an osmocom-style PDCH */ |
| 5014 | function f_TC_dyn_osmo_pdch_tchf_act(charstring id) runs on ConnHdlr { |
| 5015 | var PCUIF_Message first_info; |
| 5016 | var integer ts_nr := g_chan_nr.tn; |
| 5017 | var integer trx_nr := 0; |
| 5018 | var integer bts_nr := 0; |
| 5019 | var integer pcu_conn_id := -1; |
| 5020 | var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(g_chan_nr.tn)); |
| 5021 | |
| 5022 | /* register for the TCH/F channel number */ |
| 5023 | f_rslem_register(0, chan_nr); |
| 5024 | |
| 5025 | f_init_pcu(PCU, id, pcu_conn_id, first_info); |
| 5026 | |
| 5027 | f_rsl_transceive(ts_RSL_CHAN_ACT(chan_nr, g_pars.chan_mode), tr_RSL_CHAN_ACT_ACK(chan_nr), |
| 5028 | "RSL CHAN ACT"); |
| 5029 | setverdict(pass); |
| 5030 | } |
| 5031 | testcase TC_dyn_osmo_pdch_tchf_act() runs on test_CT { |
| 5032 | var ConnHdlrPars pars; |
| 5033 | var ConnHdlr vc_conn; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 5034 | f_init(); |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 5035 | |
| 5036 | pars := valueof(t_Pars(t_RslChanNr_PDCH(4), ts_RSL_ChanMode_SIGN)); |
| 5037 | vc_conn := f_start_handler(refers(f_TC_dyn_osmo_pdch_tchf_act), pars, true); |
| 5038 | vc_conn.done; |
| 5039 | } |
| 5040 | |
| 5041 | /* try to RSL CHAN ACT the TCH/H on an osmocom-style PDCH */ |
| 5042 | function f_TC_dyn_osmo_pdch_tchh_act(charstring id) runs on ConnHdlr { |
| 5043 | var PCUIF_Message first_info; |
| 5044 | var integer ts_nr := g_chan_nr.tn; |
| 5045 | var integer trx_nr := 0; |
| 5046 | var integer bts_nr := 0; |
| 5047 | var integer pcu_conn_id := -1; |
| 5048 | var RslChannelNr chan_nr[2] := { valueof(t_RslChanNr_Lm(g_chan_nr.tn, 0)), |
| 5049 | valueof(t_RslChanNr_Lm(g_chan_nr.tn, 1)) }; |
| 5050 | |
| 5051 | /* register for the TCH/H channel numbers */ |
| 5052 | f_rslem_register(0, chan_nr[0]); |
| 5053 | f_rslem_register(0, chan_nr[1]); |
| 5054 | |
| 5055 | f_init_pcu(PCU, id, pcu_conn_id, first_info); |
| 5056 | |
| 5057 | f_rsl_transceive(ts_RSL_CHAN_ACT(chan_nr[1], g_pars.chan_mode), |
| 5058 | tr_RSL_CHAN_ACT_ACK(chan_nr[1]), "RSL CHAN ACT [1]"); |
| 5059 | f_rsl_transceive(ts_RSL_CHAN_ACT(chan_nr[0], g_pars.chan_mode), |
| 5060 | tr_RSL_CHAN_ACT_ACK(chan_nr[0]), "RSL CHAN ACT [0]"); |
| 5061 | setverdict(pass); |
| 5062 | } |
| 5063 | testcase TC_dyn_osmo_pdch_tchh_act() runs on test_CT { |
| 5064 | var ConnHdlrPars pars; |
| 5065 | var ConnHdlr vc_conn; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 5066 | f_init(); |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 5067 | |
| 5068 | pars := valueof(t_Pars(t_RslChanNr_PDCH(4), ts_RSL_ChanMode_SIGN)); |
| 5069 | vc_conn := f_start_handler(refers(f_TC_dyn_osmo_pdch_tchh_act), pars, true); |
| 5070 | vc_conn.done; |
| 5071 | } |
| 5072 | |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 5073 | /*********************************************************************** |
| 5074 | * IPA Style Dynamic Timeslot Support |
| 5075 | ***********************************************************************/ |
| 5076 | |
| 5077 | private function f_dyn_ipa_pdch_act(integer pcu_conn_id, integer bts_nr, integer trx_nr) |
| 5078 | runs on ConnHdlr { |
| 5079 | var PCUIF_send_data sd; |
| 5080 | /* Expect BTS to immediately acknowledge activation as PDCH */ |
| 5081 | PCU.clear; |
| 5082 | RSL.send(ts_RSL_IPA_PDCH_ACT(g_chan_nr)); |
| 5083 | /* expect INFO_IND on PCU interface listing TS as PDCH */ |
Pau Espin Pedrol | 446e07b | 2019-02-18 21:18:36 +0100 | [diff] [blame] | 5084 | timer T_wait := 2.0; |
| 5085 | T_wait.start; |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 5086 | alt { |
| 5087 | [] PCU.receive(t_SD_PCUIF(pcu_conn_id, tr_PCUIF_INFO_IND(bts_nr, ?))) -> value sd { |
| 5088 | if (substr(sd.data.u.info_ind.trx[trx_nr].pdch_mask, g_chan_nr.tn, 1) != '1'B) { |
Pau Espin Pedrol | 446e07b | 2019-02-18 21:18:36 +0100 | [diff] [blame] | 5089 | log("PCUIF_INFO_IND PDCH_MASK not yet '1' after PDCH ACT on TS", g_chan_nr.tn, |
| 5090 | " mask:", sd.data.u.info_ind.trx[trx_nr].pdch_mask); |
| 5091 | repeat; |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 5092 | } |
| 5093 | } |
| 5094 | [] PCU.receive { repeat; } |
Pau Espin Pedrol | 446e07b | 2019-02-18 21:18:36 +0100 | [diff] [blame] | 5095 | [] T_wait.timeout { |
| 5096 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 5097 | log2str("Timeout waiting for PCUIF_INFO_IND PDCH_MASK to be '1' on TS", g_chan_nr.tn)); |
| 5098 | } |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 5099 | } |
| 5100 | /* try to activate this PDCH from the PCU point of view */ |
| 5101 | PCU.send(t_SD_PCUIF(pcu_conn_id, ts_PCUIF_ACT_REQ(bts_nr, trx_nr, g_chan_nr.tn))); |
| 5102 | /* FIXME: is there a response? */ |
| 5103 | |
| 5104 | RSL.receive(tr_RSL_IPA_PDCH_ACT_ACK(g_chan_nr, ?)); |
| 5105 | } |
| 5106 | |
| 5107 | private function f_dyn_ipa_pdch_deact(integer pcu_conn_id, integer bts_nr, integer trx_nr) |
| 5108 | runs on ConnHdlr { |
| 5109 | var PCUIF_send_data sd; |
| 5110 | /* Send RSL CHAN REL (deactivate) */ |
| 5111 | RSL.send(ts_RSL_IPA_PDCH_DEACT(g_chan_nr)); |
| 5112 | PCU.clear; |
| 5113 | /* expect BTS to ask PCU to deactivate the channel */ |
Pau Espin Pedrol | 446e07b | 2019-02-18 21:18:36 +0100 | [diff] [blame] | 5114 | timer T_wait := 2.0; |
| 5115 | T_wait.start; |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 5116 | alt { |
| 5117 | [] PCU.receive(t_SD_PCUIF(pcu_conn_id, tr_PCUIF_INFO_IND(bts_nr, ?))) -> value sd { |
| 5118 | if (substr(sd.data.u.info_ind.trx[trx_nr].pdch_mask, g_chan_nr.tn, 1) != '0'B) { |
Pau Espin Pedrol | 446e07b | 2019-02-18 21:18:36 +0100 | [diff] [blame] | 5119 | log("PCUIF_INFO_IND PDCH_MASK not yet '0' after PDCH DEACT on TS", g_chan_nr.tn, |
| 5120 | " mask:", sd.data.u.info_ind.trx[trx_nr].pdch_mask); |
| 5121 | repeat; |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 5122 | } |
| 5123 | } |
| 5124 | [] PCU.receive { repeat; } |
Pau Espin Pedrol | 446e07b | 2019-02-18 21:18:36 +0100 | [diff] [blame] | 5125 | [] T_wait.timeout { |
| 5126 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 5127 | log2str("Timeout waiting for PCUIF_INFO_IND PDCH_MASK to be '0' on TS", g_chan_nr.tn)); |
| 5128 | } |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 5129 | } |
| 5130 | /* Emulate PCU asking BTS to deactivate PDCH */ |
| 5131 | PCU.send(t_SD_PCUIF(pcu_conn_id, ts_PCUIF_DEACT_REQ(bts_nr, trx_nr, g_chan_nr.tn))); |
| 5132 | alt { |
| 5133 | [] RSL.receive(tr_RSL_IPA_PDCH_DEACT_ACK(g_chan_nr)) { |
| 5134 | setverdict(pass); |
| 5135 | } |
| 5136 | [] RSL.receive { repeat; } |
| 5137 | } |
| 5138 | } |
| 5139 | |
| 5140 | /* Activate and de-activate an IPA-style dynamic TCH/F + PDCH */ |
| 5141 | function f_TC_dyn_ipa_pdch_act_deact(charstring id) runs on ConnHdlr { |
| 5142 | var PCUIF_Message first_info; |
| 5143 | var integer ts_nr := g_chan_nr.tn; |
| 5144 | var integer trx_nr := 0; |
| 5145 | var integer bts_nr := 0; |
| 5146 | var integer pcu_conn_id := -1; |
| 5147 | |
| 5148 | f_init_pcu(PCU, id, pcu_conn_id, first_info); |
| 5149 | |
| 5150 | f_dyn_ipa_pdch_act(pcu_conn_id, bts_nr, trx_nr); |
| 5151 | f_sleep(3.0); |
| 5152 | f_dyn_ipa_pdch_deact(pcu_conn_id, bts_nr, trx_nr); |
| 5153 | |
| 5154 | setverdict(pass); |
| 5155 | |
| 5156 | } |
| 5157 | testcase TC_dyn_ipa_pdch_act_deact() runs on test_CT { |
| 5158 | var ConnHdlrPars pars; |
| 5159 | var ConnHdlr vc_conn; |
| 5160 | f_init(); |
| 5161 | |
| 5162 | pars := valueof(t_Pars(t_RslChanNr_Bm(3), ts_RSL_ChanMode_SIGN)); |
| 5163 | vc_conn := f_start_handler(refers(f_TC_dyn_ipa_pdch_act_deact), pars, true); |
| 5164 | vc_conn.done; |
| 5165 | } |
| 5166 | |
| 5167 | /* try to RSL CHAN ACT a TCH/F on an IPA-style PDCH */ |
| 5168 | function f_TC_dyn_ipa_pdch_tchf_act(charstring id) runs on ConnHdlr { |
| 5169 | var PCUIF_Message first_info; |
| 5170 | var integer ts_nr := g_chan_nr.tn; |
| 5171 | var integer trx_nr := 0; |
| 5172 | var integer bts_nr := 0; |
| 5173 | var integer pcu_conn_id := -1; |
| 5174 | |
| 5175 | f_init_pcu(PCU, id, pcu_conn_id, first_info); |
| 5176 | |
| 5177 | f_rsl_transceive(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode), tr_RSL_CHAN_ACT_ACK(g_chan_nr), |
| 5178 | "RSL CHAN ACT"); |
| 5179 | f_rsl_transceive(ts_RSL_RF_CHAN_REL(g_chan_nr), tr_RSL_RF_CHAN_REL_ACK(g_chan_nr), |
| 5180 | "RF CHAN REL", true); |
| 5181 | setverdict(pass); |
| 5182 | } |
| 5183 | testcase TC_dyn_ipa_pdch_tchf_act() runs on test_CT { |
| 5184 | var ConnHdlrPars pars; |
| 5185 | var ConnHdlr vc_conn; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 5186 | f_init(); |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 5187 | |
| 5188 | pars := valueof(t_Pars(t_RslChanNr_Bm(3), ts_RSL_ChanMode_SIGN)); |
| 5189 | vc_conn := f_start_handler(refers(f_TC_dyn_ipa_pdch_tchf_act), pars, true); |
| 5190 | vc_conn.done; |
| 5191 | } |
| 5192 | |
| 5193 | /* Activate IPA style dyn PDCH as TCH/F and then illegally try to activate it as PDCH, too */ |
| 5194 | function f_TC_dyn_ipa_pdch_tchf_act_pdch_act_nack(charstring id) runs on ConnHdlr { |
| 5195 | var PCUIF_Message first_info; |
| 5196 | var integer ts_nr := g_chan_nr.tn; |
| 5197 | var integer trx_nr := 0; |
| 5198 | var integer bts_nr := 0; |
| 5199 | var integer pcu_conn_id := -1; |
| 5200 | |
| 5201 | f_init_pcu(PCU, id, pcu_conn_id, first_info); |
| 5202 | |
| 5203 | f_rsl_transceive(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode), tr_RSL_CHAN_ACT_ACK(g_chan_nr), |
| 5204 | "RSL CHAN ACT"); |
| 5205 | |
| 5206 | RSL.send(ts_RSL_IPA_PDCH_ACT(g_chan_nr)); |
| 5207 | alt { |
| 5208 | [] RSL.receive(tr_RSL_IPA_PDCH_ACT_NACK(g_chan_nr, ?)); |
| 5209 | [] RSL.receive(tr_RSL_IPA_PDCH_ACT_ACK(g_chan_nr, ?)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 5210 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected PDCH ACT ACK"); |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 5211 | } |
| 5212 | [] RSL.receive { repeat; } |
| 5213 | } |
| 5214 | |
| 5215 | f_rsl_transceive(ts_RSL_RF_CHAN_REL(g_chan_nr), tr_RSL_RF_CHAN_REL_ACK(g_chan_nr), |
| 5216 | "RF CHAN REL", true); |
| 5217 | setverdict(pass); |
| 5218 | } |
| 5219 | testcase TC_dyn_ipa_pdch_tchf_act_pdch_act_nack() runs on test_CT { |
| 5220 | var ConnHdlrPars pars; |
| 5221 | var ConnHdlr vc_conn; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 5222 | f_init(); |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 5223 | |
| 5224 | pars := valueof(t_Pars(t_RslChanNr_Bm(3), ts_RSL_ChanMode_SIGN)); |
| 5225 | vc_conn := f_start_handler(refers(f_TC_dyn_ipa_pdch_tchf_act_pdch_act_nack), pars, true); |
| 5226 | vc_conn.done; |
| 5227 | } |
| 5228 | |
| 5229 | /* try to RSL CHAN ACT a TCH/F on an IPA-style PDCH that's already in PDCH mode; expect NACK */ |
| 5230 | function f_TC_dyn_ipa_pdch_act_tchf_act_nack(charstring id) runs on ConnHdlr { |
| 5231 | var PCUIF_Message first_info; |
| 5232 | var integer ts_nr := g_chan_nr.tn; |
| 5233 | var integer trx_nr := 0; |
| 5234 | var integer bts_nr := 0; |
| 5235 | var integer pcu_conn_id := -1; |
| 5236 | |
| 5237 | /* register for the TCH/F channel number */ |
| 5238 | f_rslem_register(0, g_chan_nr); |
| 5239 | |
| 5240 | f_init_pcu(PCU, id, pcu_conn_id, first_info); |
| 5241 | |
| 5242 | f_dyn_ipa_pdch_act(pcu_conn_id, bts_nr, trx_nr); |
| 5243 | |
| 5244 | f_rsl_transceive(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode), tr_RSL_CHAN_ACT_NACK(g_chan_nr), |
| 5245 | "RSL CHAN ACT"); |
| 5246 | |
| 5247 | f_dyn_ipa_pdch_deact(pcu_conn_id, bts_nr, trx_nr); |
| 5248 | |
| 5249 | setverdict(pass); |
| 5250 | } |
| 5251 | testcase TC_dyn_ipa_pdch_act_tchf_act_nack() runs on test_CT { |
| 5252 | var ConnHdlrPars pars; |
| 5253 | var ConnHdlr vc_conn; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 5254 | f_init(); |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 5255 | |
| 5256 | pars := valueof(t_Pars(t_RslChanNr_Bm(3), ts_RSL_ChanMode_SIGN)); |
| 5257 | vc_conn := f_start_handler(refers(f_TC_dyn_ipa_pdch_act_tchf_act_nack), pars, true); |
| 5258 | vc_conn.done; |
| 5259 | } |
| 5260 | |
| 5261 | |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 5262 | /*********************************************************************** |
| 5263 | * LAPDm / RLL related |
| 5264 | ***********************************************************************/ |
| 5265 | |
| 5266 | private function f_tx_lapdm(template (value) LapdmFrame l, |
| 5267 | template (value) RslLinkId link_id) runs on ConnHdlr { |
| 5268 | var octetstring l2 := enc_LapdmFrame(valueof(l)); |
Vadim Yanitskiy | 0a8d6da | 2019-05-28 22:18:28 +0700 | [diff] [blame] | 5269 | var template (value) SacchL1Header l1h; |
| 5270 | |
| 5271 | /* TODO: we can use an extension of TTCN-3 for padding, i.e. PADDING('2B'O) */ |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 5272 | if (valueof(link_id.c) == SACCH) { |
Vadim Yanitskiy | 0a8d6da | 2019-05-28 22:18:28 +0700 | [diff] [blame] | 5273 | /* Compose dummy L1 header */ |
| 5274 | l1h := ts_SacchL1Header(g_pars.l1_pars.ms_power_level, false, g_pars.l1_pars.ms_actual_ta); |
| 5275 | L1CTL.send(ts_L1CTL_DATA_REQ_SACCH(g_chan_nr, link_id, l1h, f_pad_oct(l2, 21, '2B'O))); |
Pau Espin Pedrol | a0fb42a | 2018-10-10 15:56:39 +0200 | [diff] [blame] | 5276 | } else { |
| 5277 | /* If required, pad L2 frame with constant 0x2b filling */ |
Vadim Yanitskiy | 0a8d6da | 2019-05-28 22:18:28 +0700 | [diff] [blame] | 5278 | L1CTL.send(ts_L1CTL_DATA_REQ(g_chan_nr, link_id, f_pad_oct(l2, 23, '2B'O))); |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 5279 | } |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 5280 | } |
| 5281 | |
| 5282 | type record RllTestCase { |
| 5283 | uint3_t sapi, |
| 5284 | RslLinkId link_id, |
| 5285 | octetstring l3, |
| 5286 | boolean exp |
| 5287 | } |
| 5288 | type record of RllTestCase RllTestCases; |
| 5289 | template RllTestCase t_EITC(uint3_t sapi, RslLinkId id, octetstring l3, boolean exp) := { |
| 5290 | sapi := sapi, |
| 5291 | link_id := id, |
| 5292 | l3 := l3, |
| 5293 | exp := exp |
| 5294 | } |
| 5295 | |
| 5296 | /* execute the same callback function with a set of different parameters (tcs) on a |
| 5297 | * variety of logical channels */ |
| 5298 | private function f_rll_testmatrix(RllTestCases tcs, void_fn fn) runs on test_CT { |
| 5299 | var ConnHdlrPars pars; |
| 5300 | var ConnHdlr vc_conn; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 5301 | f_init(); |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 5302 | |
| 5303 | /* test on each of the channels we have */ |
| 5304 | for (var integer i := 0; i < sizeof(g_AllChanTypes); i := i+1) { |
| 5305 | pars := valueof(t_Pars(g_AllChanTypes[i], ts_RSL_ChanMode_SIGN)); |
| 5306 | |
| 5307 | /* test each of the test cases on the current channel */ |
| 5308 | for (var integer j := 0; j < sizeof(tcs); j := j+1) { |
| 5309 | pars.spec.rll := tcs[j]; |
| 5310 | log(testcasename(), ": XXX Starting ", tcs[j] , " on ", g_AllChanTypes[i]); |
| 5311 | vc_conn := f_start_handler(fn, pars); |
| 5312 | vc_conn.done; |
| 5313 | } |
| 5314 | } |
| 5315 | |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 5316 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 5317 | } |
| 5318 | |
| 5319 | /* test if SABM on Um triggers EST IND (TS 48.058 3.1) */ |
| 5320 | private function f_TC_rll_est_ind(charstring id) runs on ConnHdlr { |
| 5321 | var RllTestCase tc := g_pars.spec.rll; |
| 5322 | timer T := 3.0; |
| 5323 | |
| 5324 | f_l1_tune(L1CTL); |
| 5325 | RSL.clear; |
| 5326 | |
| 5327 | /* activate the logical channel */ |
| 5328 | f_est_dchan(); |
| 5329 | L1CTL.clear; |
| 5330 | |
| 5331 | f_tx_lapdm(ts_LAPDm_SABM(tc.sapi, cr_MO_CMD, true, tc.l3), tc.link_id); |
| 5332 | T.start; |
| 5333 | alt { |
| 5334 | [tc.l3 != ''O] RSL.receive(tr_RSL_EST_IND(g_chan_nr, tc.link_id, tc.l3)) { |
| 5335 | if (tc.exp) { |
| 5336 | setverdict(pass); |
| 5337 | } else { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 5338 | 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] | 5339 | } |
| 5340 | } |
| 5341 | [tc.l3 == ''O] RSL.receive(tr_RSL_EST_IND_NOL3(g_chan_nr, tc.link_id)) { |
| 5342 | if (tc.exp) { |
| 5343 | setverdict(pass); |
| 5344 | } else { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 5345 | 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] | 5346 | } |
| 5347 | } |
Vadim Yanitskiy | 3567787 | 2018-10-04 17:30:21 +0700 | [diff] [blame] | 5348 | /* We also expect to receive the measurements */ |
| 5349 | [] as_meas_res(verify_meas := false); |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 5350 | [tc.exp] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 5351 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for EST IND"); |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 5352 | } |
| 5353 | [not tc.exp] T.timeout { |
| 5354 | setverdict(pass); |
| 5355 | } |
| 5356 | } |
| 5357 | |
| 5358 | f_rsl_chan_deact(); |
| 5359 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 5360 | f_rslem_unregister(0, g_chan_nr); |
| 5361 | } |
| 5362 | testcase TC_rll_est_ind() runs on test_CT { |
| 5363 | var RllTestCases tcs := { |
Harald Welte | 7aacbbf | 2018-05-09 16:56:41 +0200 | [diff] [blame] | 5364 | /* SAPI0 establishment (contention resolution) */ |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 5365 | valueof(t_EITC(0, valueof(ts_RslLinkID_DCCH(0)), '01020304'O, true)), |
Harald Welte | 7aacbbf | 2018-05-09 16:56:41 +0200 | [diff] [blame] | 5366 | /* normal SAPI0 establishment */ |
| 5367 | valueof(t_EITC(0, valueof(ts_RslLinkID_DCCH(0)), ''O, true)), |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 5368 | /* SAPI 3 doesn't support contention resolution */ |
| 5369 | valueof(t_EITC(3, valueof(ts_RslLinkID_DCCH(3)), '01020304'O, false)), |
| 5370 | valueof(t_EITC(3, valueof(ts_RslLinkID_SACCH(3)), '01020304'O, false)), |
| 5371 | /* normal SAPI3 establishment on main DCCH */ |
| 5372 | valueof(t_EITC(3, valueof(ts_RslLinkID_DCCH(3)), ''O, true)), |
| 5373 | /* normal SAPI3 establishment on SACCH */ |
| 5374 | valueof(t_EITC(3, valueof(ts_RslLinkID_SACCH(3)), ''O, true)) |
| 5375 | }; |
| 5376 | f_rll_testmatrix(tcs, refers(f_TC_rll_est_ind)); |
| 5377 | } |
| 5378 | |
| 5379 | /* test if RLL EST REQ trigeres SABM on Um; UA on Um triggers EST CONF (TS 48.058 3.2) */ |
| 5380 | private function f_TC_rll_est_req(charstring id) runs on ConnHdlr { |
| 5381 | var RllTestCase tc := g_pars.spec.rll; |
| 5382 | var L1ctlDlMessage dl; |
| 5383 | timer T := 3.0; |
| 5384 | |
| 5385 | f_l1_tune(L1CTL); |
| 5386 | RSL.clear; |
| 5387 | |
| 5388 | /* activate the logical channel */ |
| 5389 | f_est_dchan(); |
| 5390 | L1CTL.clear; |
| 5391 | |
| 5392 | /* Send a RSL EST REQ for SAPI3 on main DCCH */ |
| 5393 | RSL.send(ts_RSL_EST_REQ(g_chan_nr, tc.link_id)); |
| 5394 | T.start; |
| 5395 | alt { |
| 5396 | [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, ?)) -> value dl { |
| 5397 | var LapdmFrame lapdm; |
| 5398 | var octetstring l2 := dl.payload.data_ind.payload; |
| 5399 | if (dl.dl_info.link_id.c == SACCH) { |
| 5400 | /* remove L1 header */ |
| 5401 | l2 := substr(l2, 2, lengthof(l2)-2); |
| 5402 | } |
| 5403 | lapdm.ab := dec_LapdmFrameAB(l2); |
| 5404 | if (match(lapdm, tr_LAPDm_SABM(tc.sapi, cr_MT_CMD, true, ''O))) { |
| 5405 | setverdict(pass); |
| 5406 | } else { |
| 5407 | repeat; |
| 5408 | } |
| 5409 | } |
| 5410 | [] L1CTL.receive { repeat; } |
| 5411 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 5412 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for SABM"); |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 5413 | } |
| 5414 | } |
| 5415 | |
| 5416 | f_rsl_chan_deact(); |
| 5417 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 5418 | f_rslem_unregister(0, g_chan_nr); |
| 5419 | } |
| 5420 | testcase TC_rll_est_req_DCCH_3() runs on test_CT { |
| 5421 | var RllTestCases tcs := { |
| 5422 | /* normal SAPI3 establishment on main DCCH */ |
| 5423 | valueof(t_EITC(3, valueof(ts_RslLinkID_DCCH(3)), ''O, true))//, |
| 5424 | }; |
| 5425 | f_rll_testmatrix(tcs, refers(f_TC_rll_est_req)); |
| 5426 | } |
| 5427 | testcase TC_rll_est_req_ACCH_3() runs on test_CT { |
| 5428 | var RllTestCases tcs := { |
| 5429 | /* normal SAPI3 establishment on SACCH */ |
| 5430 | valueof(t_EITC(3, valueof(ts_RslLinkID_SACCH(3)), ''O, true)) |
| 5431 | } |
| 5432 | f_rll_testmatrix(tcs, refers(f_TC_rll_est_req)); |
| 5433 | } |
| 5434 | |
| 5435 | /* altstep to receive a LAPDm frame matching the given template */ |
| 5436 | private altstep as_l1_exp_lapdm(template LapdmFrame exp) runs on ConnHdlr { |
| 5437 | var L1ctlDlMessage dl; |
| 5438 | [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, ?)) -> value dl { |
| 5439 | var LapdmFrame lapdm; |
| 5440 | var octetstring l2 := dl.payload.data_ind.payload; |
| 5441 | if (dl.dl_info.link_id.c == SACCH) { |
| 5442 | /* remove L1 header */ |
| 5443 | l2 := substr(l2, 2, lengthof(l2)-2); |
| 5444 | } |
| 5445 | if (ischosen(exp.ab)) { |
| 5446 | lapdm.ab := dec_LapdmFrameAB(l2); |
| 5447 | } else if (ischosen(exp.b4)) { |
| 5448 | lapdm.b4 := dec_LapdmFrameB4(l2); |
| 5449 | } else if (ischosen(exp.bbis)) { |
| 5450 | lapdm.bbis := dec_LapdmFrameBbis(l2); |
| 5451 | } |
| 5452 | log("Rx LAPDm ", lapdm); |
| 5453 | if (match(lapdm, exp)) { |
| 5454 | setverdict(pass); |
| 5455 | } else { |
| 5456 | repeat; |
| 5457 | } |
| 5458 | } |
| 5459 | [] L1CTL.receive { repeat; } |
| 5460 | } |
| 5461 | private function f_l1_exp_lapdm(template LapdmFrame exp, float t := 3.0) runs on ConnHdlr { |
| 5462 | timer T := t; |
| 5463 | T.start; |
| 5464 | alt { |
| 5465 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 5466 | 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] | 5467 | } |
| 5468 | [] as_l1_exp_lapdm(exp); |
| 5469 | } |
| 5470 | } |
| 5471 | |
| 5472 | /* establish one Radio Link Layer via SABM -> UA. Use l3 for contention resolution */ |
| 5473 | private function f_est_rll_mo(uint3_t sapi, RslLinkId link_id, octetstring l3) runs on ConnHdlr { |
| 5474 | /* send SABM from MS -> BTS */ |
| 5475 | f_tx_lapdm(ts_LAPDm_SABM(sapi, cr_MO_CMD, true, l3), link_id); |
| 5476 | /* expect RLL EST IND on Abis */ |
| 5477 | alt { |
| 5478 | [l3 != ''O] RSL.receive(tr_RSL_EST_IND(g_chan_nr, link_id, l3)); |
| 5479 | [l3 == ''O] RSL.receive(tr_RSL_EST_IND_NOL3(g_chan_nr, link_id)); |
| 5480 | [] RSL.receive(tr_RSL_ERROR_IND(g_chan_nr, link_id, ?)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 5481 | 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] | 5482 | } |
| 5483 | [] RSL.receive { repeat; } |
| 5484 | } |
| 5485 | /* expect UA from BTS -> MS */ |
| 5486 | f_l1_exp_lapdm(tr_LAPDm_UA(sapi, cr_MT_RSP, true, l3)); |
| 5487 | } |
| 5488 | |
| 5489 | /* test if DISC on Um triggers RLL REL IND (TS 48.058 3.3) */ |
| 5490 | private function f_TC_rll_rel_ind(charstring id) runs on ConnHdlr { |
| 5491 | var RllTestCase tc := g_pars.spec.rll; |
| 5492 | |
| 5493 | f_l1_tune(L1CTL); |
| 5494 | RSL.clear; |
| 5495 | |
| 5496 | /* activate the logical channel */ |
| 5497 | f_est_dchan(); |
| 5498 | L1CTL.clear; |
| 5499 | |
| 5500 | /* first establish the link-layer */ |
| 5501 | f_est_rll_mo(tc.sapi, tc.link_id, tc.l3); |
| 5502 | |
| 5503 | /* then send the DISC */ |
| 5504 | f_tx_lapdm(ts_LAPDm_DISC(tc.sapi, cr_MO_CMD, true), tc.link_id); |
| 5505 | /* ... and expect the REL IND on the RSL side */ |
| 5506 | alt { |
| 5507 | [] RSL.receive(tr_RSL_REL_IND(g_chan_nr, tc.link_id)) { |
| 5508 | setverdict(pass); |
| 5509 | } |
Vadim Yanitskiy | 3567787 | 2018-10-04 17:30:21 +0700 | [diff] [blame] | 5510 | /* We also expect to receive the measurements */ |
| 5511 | [] as_meas_res(verify_meas := false); |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 5512 | } |
| 5513 | |
| 5514 | /* release the channel */ |
| 5515 | f_rsl_chan_deact(); |
| 5516 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 5517 | f_rslem_unregister(0, g_chan_nr); |
| 5518 | } |
| 5519 | testcase TC_rll_rel_ind_DCCH_0() runs on test_CT { |
| 5520 | var RllTestCases tcs := { |
| 5521 | valueof(t_EITC(0, valueof(ts_RslLinkID_DCCH(0)), '01020304'O, true)) |
| 5522 | }; |
| 5523 | f_rll_testmatrix(tcs, refers(f_TC_rll_rel_ind)); |
| 5524 | } |
| 5525 | |
| 5526 | testcase TC_rll_rel_ind_ACCH_0() runs on test_CT { |
| 5527 | var RllTestCases tcs := { |
| 5528 | valueof(t_EITC(0, valueof(ts_RslLinkID_SACCH(0)), ''O, true)) |
| 5529 | }; |
| 5530 | f_rll_testmatrix(tcs, refers(f_TC_rll_rel_ind)); |
| 5531 | } |
| 5532 | testcase TC_rll_rel_ind_DCCH_3() runs on test_CT { |
| 5533 | var RllTestCases tcs := { |
| 5534 | valueof(t_EITC(3, valueof(ts_RslLinkID_DCCH(3)), ''O, true)) |
| 5535 | }; |
| 5536 | f_rll_testmatrix(tcs, refers(f_TC_rll_rel_ind)); |
| 5537 | } |
| 5538 | testcase TC_rll_rel_ind_ACCH_3() runs on test_CT { |
| 5539 | var RllTestCases tcs := { |
| 5540 | valueof(t_EITC(3, valueof(ts_RslLinkID_SACCH(3)), ''O, true)) |
| 5541 | }; |
| 5542 | f_rll_testmatrix(tcs, refers(f_TC_rll_rel_ind)); |
| 5543 | } |
| 5544 | |
| 5545 | /* test if RLL REL REQ triggers DISC on Um; UA/DM triggers RLL REL CONF (TS 48.058 3.4) */ |
| 5546 | private function f_TC_rll_rel_req(charstring id) runs on ConnHdlr { |
| 5547 | var RllTestCase tc := g_pars.spec.rll; |
| 5548 | f_l1_tune(L1CTL); |
| 5549 | RSL.clear; |
| 5550 | |
| 5551 | /* activate the logical channel */ |
| 5552 | f_est_dchan(); |
| 5553 | L1CTL.clear; |
| 5554 | |
| 5555 | /* first establish the link-layer */ |
| 5556 | f_est_rll_mo(tc.sapi, tc.link_id, tc.l3); |
| 5557 | |
| 5558 | /* then send the REL REQ via RSL */ |
| 5559 | RSL.send(ts_RSL_REL_REQ(g_chan_nr, tc.link_id, RSL_REL_MODE_NORMAL)); |
| 5560 | /* ... and expect the DISC on the Um side */ |
| 5561 | alt { |
Harald Welte | bc6199f | 2018-05-10 19:38:18 +0200 | [diff] [blame] | 5562 | [] 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] | 5563 | /* FIXME: send a UA in resposne to the DISC */ |
| 5564 | } |
| 5565 | } |
| 5566 | |
| 5567 | /* release the channel */ |
| 5568 | f_rsl_chan_deact(); |
| 5569 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 5570 | f_rslem_unregister(0, g_chan_nr); |
| 5571 | } |
| 5572 | testcase TC_rll_rel_req() runs on test_CT { |
| 5573 | var RllTestCases tcs := { |
| 5574 | valueof(t_EITC(0, valueof(ts_RslLinkID_DCCH(0)), '01020304'O, true)), |
| 5575 | valueof(t_EITC(0, valueof(ts_RslLinkID_SACCH(0)), ''O, true)), |
| 5576 | valueof(t_EITC(3, valueof(ts_RslLinkID_DCCH(3)), ''O, true)), |
| 5577 | valueof(t_EITC(3, valueof(ts_RslLinkID_SACCH(3)), ''O, true)) |
| 5578 | }; |
| 5579 | f_rll_testmatrix(tcs, refers(f_TC_rll_rel_req)); |
| 5580 | } |
| 5581 | |
| 5582 | /* test if RLL DATA REQ triggers I-frames on Um (TS 48.058 3.5) */ |
| 5583 | testcase TC_rll_data_req() runs on test_CT { |
| 5584 | } |
| 5585 | |
| 5586 | /* test if I-frames on Um trigger RLL DATA IND (TS 48.058 3.6) */ |
| 5587 | testcase TC_rll_data_ind() runs on test_CT { |
| 5588 | } |
| 5589 | |
| 5590 | /* test if RLL UNIT DATA REQ triggers UI-frame on Um (TS 48.058 3.7) */ |
| 5591 | private function f_TC_rll_ud_req(charstring id) runs on ConnHdlr { |
| 5592 | var RllTestCase tc := g_pars.spec.rll; |
| 5593 | |
| 5594 | f_l1_tune(L1CTL); |
| 5595 | RSL.clear; |
| 5596 | |
| 5597 | f_est_dchan(); |
| 5598 | L1CTL.clear; |
| 5599 | |
| 5600 | /* Send UNITDATA REQ on RSL side */ |
| 5601 | RSL.send(ts_RSL_UNITDATA_REQ(g_chan_nr, tc.link_id, tc.l3)); |
| 5602 | /* Expect it to arrive on the other side */ |
| 5603 | if (tc.link_id.c == SACCH) { |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 5604 | 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] | 5605 | } else { |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 5606 | 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] | 5607 | } |
| 5608 | |
| 5609 | /* release the channel */ |
| 5610 | f_rsl_chan_deact(); |
| 5611 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 5612 | f_rslem_unregister(0, g_chan_nr); |
| 5613 | } |
| 5614 | testcase TC_rll_unit_data_req_DCCH() runs on test_CT { |
| 5615 | var octetstring l3 := f_rnd_octstring(15); |
| 5616 | var RllTestCases tcs := { |
| 5617 | valueof(t_EITC(0, valueof(ts_RslLinkID_DCCH(0)), l3, true)), |
| 5618 | valueof(t_EITC(3, valueof(ts_RslLinkID_DCCH(3)), l3, true)) |
| 5619 | }; |
| 5620 | f_rll_testmatrix(tcs, refers(f_TC_rll_ud_req)); |
| 5621 | } |
| 5622 | testcase TC_rll_unit_data_req_ACCH() runs on test_CT { |
| 5623 | var octetstring l3 := f_rnd_octstring(19); |
| 5624 | var RllTestCases tcs := { |
| 5625 | valueof(t_EITC(0, valueof(ts_RslLinkID_SACCH(0)), l3, true)), |
| 5626 | valueof(t_EITC(3, valueof(ts_RslLinkID_SACCH(3)), l3, true)) |
| 5627 | }; |
| 5628 | f_rll_testmatrix(tcs, refers(f_TC_rll_ud_req)); |
| 5629 | } |
| 5630 | |
| 5631 | /* test if UI-frames on Um trigger RLL UNIT DATA IND (TS 48.058 3.8) */ |
| 5632 | private function f_TC_rll_ud_ind(charstring id) runs on ConnHdlr { |
| 5633 | var RllTestCase tc := g_pars.spec.rll; |
| 5634 | |
| 5635 | f_l1_tune(L1CTL); |
| 5636 | RSL.clear; |
| 5637 | |
| 5638 | f_est_dchan(); |
| 5639 | L1CTL.clear; |
| 5640 | |
| 5641 | /* Send LAPDm UI frame. There is no B4 format in uplink! */ |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 5642 | 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] | 5643 | /* Expdct RLL UNITDATA IND on RSL side */ |
| 5644 | alt { |
| 5645 | [] RSL.receive(tr_RSL_UNITDATA_IND(g_chan_nr, tc.link_id, tc.l3)) { |
| 5646 | setverdict(pass); |
| 5647 | } |
| 5648 | [] RSL.receive { repeat; } |
| 5649 | } |
| 5650 | |
| 5651 | /* release the channel */ |
| 5652 | f_rsl_chan_deact(); |
| 5653 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 5654 | f_rslem_unregister(0, g_chan_nr); |
| 5655 | } |
| 5656 | testcase TC_rll_unit_data_ind_DCCH() runs on test_CT { |
Stefan Sperling | c418191 | 2018-07-25 17:03:08 +0200 | [diff] [blame] | 5657 | var octetstring l3 := f_rnd_octstring(20); |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 5658 | var RllTestCases tcs := { |
| 5659 | valueof(t_EITC(0, valueof(ts_RslLinkID_DCCH(0)), l3, true)), |
| 5660 | valueof(t_EITC(3, valueof(ts_RslLinkID_DCCH(3)), l3, true)) |
| 5661 | }; |
| 5662 | f_rll_testmatrix(tcs, refers(f_TC_rll_ud_ind)); |
| 5663 | } |
| 5664 | testcase TC_rll_unit_data_ind_ACCH() runs on test_CT { |
| 5665 | var octetstring l3 := f_rnd_octstring(18); |
| 5666 | var RllTestCases tcs := { |
| 5667 | valueof(t_EITC(0, valueof(ts_RslLinkID_SACCH(0)), l3, true)), |
| 5668 | valueof(t_EITC(3, valueof(ts_RslLinkID_SACCH(3)), l3, true)) |
| 5669 | }; |
| 5670 | f_rll_testmatrix(tcs, refers(f_TC_rll_ud_ind)); |
| 5671 | } |
| 5672 | |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 5673 | /*********************************************************************** |
| 5674 | * Encryption Related |
| 5675 | ***********************************************************************/ |
| 5676 | |
| 5677 | /* send UNITDATA_REQ from BTS to MS and expect it to arrive */ |
| 5678 | function f_unitdata_mt(RslLinkId link_id, octetstring l3) runs on ConnHdlr { |
| 5679 | RSL.send(ts_RSL_UNITDATA_REQ(g_chan_nr, link_id, l3)); |
| 5680 | if (link_id.c == SACCH) { |
| 5681 | f_l1_exp_lapdm(tr_LAPDm_B4_UI(link_id.sapi, cr_MT_CMD, l3)); |
| 5682 | } else { |
| 5683 | f_l1_exp_lapdm(tr_LAPDm_UI(link_id.sapi, cr_MT_CMD, l3)); |
| 5684 | } |
| 5685 | } |
| 5686 | |
Vadim Yanitskiy | ad131c8 | 2018-10-04 06:18:59 +0700 | [diff] [blame] | 5687 | /* Expect (or not expect) other kinds of messages */ |
| 5688 | private altstep as_rsl_any_ind(boolean exp_any) runs on ConnHdlr { |
| 5689 | [exp_any] RSL.receive { repeat; } |
| 5690 | [not exp_any] RSL.receive { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 5691 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected RSL message!"); |
Vadim Yanitskiy | ad131c8 | 2018-10-04 06:18:59 +0700 | [diff] [blame] | 5692 | } |
| 5693 | } |
| 5694 | |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 5695 | /* 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] | 5696 | private function f_unitdata_mo( |
Vadim Yanitskiy | 98e0315 | 2018-10-03 18:06:06 +0700 | [diff] [blame] | 5697 | RslLinkId link_id, |
| 5698 | octetstring l3, |
| 5699 | boolean exp_sacch := true, /* Should tolerate SACCH messages? */ |
Vadim Yanitskiy | b992050 | 2018-10-03 18:29:51 +0700 | [diff] [blame] | 5700 | boolean exp_any := false /* Should tolerate any other RSL messages? */ |
Vadim Yanitskiy | 98e0315 | 2018-10-03 18:06:06 +0700 | [diff] [blame] | 5701 | ) runs on ConnHdlr { |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 5702 | timer T := 3.0; |
| 5703 | f_tx_lapdm(ts_LAPDm_UI(link_id.sapi, cr_MO_CMD, l3), link_id); |
| 5704 | T.start; |
| 5705 | /* Expect RLL UNITDATA IND on RSL side */ |
| 5706 | alt { |
| 5707 | [] RSL.receive(tr_RSL_UNITDATA_IND(g_chan_nr, link_id, l3)) { |
| 5708 | setverdict(pass); |
| 5709 | } |
Vadim Yanitskiy | e0b91a7 | 2018-10-04 15:44:40 +0700 | [diff] [blame] | 5710 | [exp_sacch] as_meas_res(verify_meas := false); |
Vadim Yanitskiy | ad131c8 | 2018-10-04 06:18:59 +0700 | [diff] [blame] | 5711 | [] as_rsl_any_ind(exp_any); |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 5712 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 5713 | 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] | 5714 | } |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 5715 | } |
| 5716 | } |
| 5717 | |
Vadim Yanitskiy | 4d78a70 | 2018-10-03 03:59:34 +0700 | [diff] [blame] | 5718 | /* Send I-frame from MS and expect it to arrive as RLL DATA IND on Abis */ |
| 5719 | private function f_data_mo( |
| 5720 | RslLinkId link_id, |
| 5721 | boolean p, uint3_t nr, uint3_t ns, |
| 5722 | octetstring l3, |
| 5723 | boolean exp_sacch := true, /* Should tolerate SACCH messages? */ |
Vadim Yanitskiy | b992050 | 2018-10-03 18:29:51 +0700 | [diff] [blame] | 5724 | boolean exp_any := false /* Should tolerate any other RSL messages? */ |
Vadim Yanitskiy | 4d78a70 | 2018-10-03 03:59:34 +0700 | [diff] [blame] | 5725 | ) runs on ConnHdlr { |
| 5726 | timer T := 3.0; |
| 5727 | f_tx_lapdm(ts_LAPDm_I(link_id.sapi, cr_MO_CMD, p, nr, ns, l3), link_id); |
| 5728 | T.start; |
| 5729 | /* Expect RLL DATA IND on RSL side */ |
| 5730 | alt { |
| 5731 | [] RSL.receive(tr_RSL_DATA_IND(g_chan_nr, link_id, l3)) { |
| 5732 | setverdict(pass); |
| 5733 | } |
Vadim Yanitskiy | e0b91a7 | 2018-10-04 15:44:40 +0700 | [diff] [blame] | 5734 | [exp_sacch] as_meas_res(verify_meas := false); |
Vadim Yanitskiy | 4d78a70 | 2018-10-03 03:59:34 +0700 | [diff] [blame] | 5735 | [] as_rsl_any_ind(exp_any); |
| 5736 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 5737 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for DATA_IND"); |
Vadim Yanitskiy | 4d78a70 | 2018-10-03 03:59:34 +0700 | [diff] [blame] | 5738 | } |
| 5739 | } |
| 5740 | } |
| 5741 | |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 5742 | /* Test channel activation with A5/n right from the beginning (like in assignment + hand-over) */ |
| 5743 | function f_TC_chan_act_encr(charstring id) runs on ConnHdlr { |
| 5744 | f_l1_tune(L1CTL); |
| 5745 | f_est_dchan(true); |
| 5746 | |
| 5747 | /* now we actually need to transmit some data both ways to check if the encryption works */ |
| 5748 | var L1ctlDlMessage dl; |
| 5749 | |
Stefan Sperling | 603d98e | 2018-07-25 16:47:28 +0200 | [diff] [blame] | 5750 | var octetstring l3 := f_rnd_octstring(20); |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 5751 | var RslLinkId link_id := valueof(ts_RslLinkID_DCCH(0)); |
| 5752 | |
| 5753 | /* send UNITDATA_REQ from BTS to MS and expect it to arrive */ |
| 5754 | f_unitdata_mt(link_id, l3); |
| 5755 | |
| 5756 | /* Send UI frame from MS and expect it to arrive as RLL UNITDATA IND on Abis */ |
| 5757 | f_unitdata_mo(link_id, l3); |
| 5758 | |
| 5759 | /* release the channel */ |
| 5760 | f_rsl_chan_deact(); |
| 5761 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 5762 | f_rslem_unregister(0, g_chan_nr); |
| 5763 | } |
| 5764 | testcase TC_chan_act_a51() runs on test_CT { |
| 5765 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 5766 | pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_1, f_rnd_octstring(8))); |
| 5767 | f_testmatrix_each_chan(pars, refers(f_TC_chan_act_encr)); |
| 5768 | } |
| 5769 | testcase TC_chan_act_a52() runs on test_CT { |
| 5770 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 5771 | pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_2, f_rnd_octstring(8))); |
| 5772 | f_testmatrix_each_chan(pars, refers(f_TC_chan_act_encr)); |
| 5773 | } |
| 5774 | testcase TC_chan_act_a53() runs on test_CT { |
| 5775 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 5776 | pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_3, f_rnd_octstring(8))); |
| 5777 | f_testmatrix_each_chan(pars, refers(f_TC_chan_act_encr)); |
| 5778 | } |
| 5779 | |
Eric Wild | f1827a7 | 2019-05-28 17:37:35 +0200 | [diff] [blame] | 5780 | /* Test channel activation with A5/n right from the beginning and RSL MODE MODIFY |
| 5781 | which should break the en/decryption on purpose by supplying a new key that is unknown to the MS*/ |
| 5782 | function f_TC_rsl_modify_encr(charstring id) runs on ConnHdlr { |
| 5783 | f_l1_tune(L1CTL); |
| 5784 | f_est_dchan(true); |
| 5785 | |
| 5786 | /* now we actually need to transmit some data both ways to check if the encryption works */ |
| 5787 | var L1ctlDlMessage dl; |
| 5788 | |
| 5789 | var octetstring l3 := f_rnd_octstring(20); |
| 5790 | var RslLinkId link_id := valueof(ts_RslLinkID_DCCH(0)); |
| 5791 | |
| 5792 | /* send UNITDATA_REQ from BTS to MS and expect it to arrive */ |
| 5793 | f_unitdata_mt(link_id, l3); |
| 5794 | |
| 5795 | /* Send UI frame from MS and expect it to arrive as RLL UNITDATA IND on Abis */ |
| 5796 | f_unitdata_mo(link_id, l3); |
| 5797 | |
| 5798 | var RSL_Message rsl; |
| 5799 | rsl := valueof(ts_RSL_MODE_MODIFY_REQ(g_chan_nr, valueof(ts_RSL_ChanMode_SIGN(false)))); |
| 5800 | |
| 5801 | /* modify key to break proper encryption */ |
| 5802 | g_pars.encr.key := f_rnd_octstring(8); |
| 5803 | var RSL_IE ei := valueof(t_RSL_IE(RSL_IE_ENCR_INFO, RSL_IE_Body:{encr_info := g_pars.encr})); |
| 5804 | rsl.ies := rsl.ies & { ei }; |
| 5805 | RSL.send(rsl); |
| 5806 | |
| 5807 | timer T0 := 1.0; |
| 5808 | T0.start; |
| 5809 | /* Expect RSL MODIFY ACK */ |
| 5810 | alt { |
| 5811 | [] RSL.receive(tr_RSL_MODE_MODIFY_ACK(g_chan_nr)) {} |
| 5812 | [] RSL.receive(tr_RSL_MODE_MODIFY_NACK(g_chan_nr, ?)) { |
| 5813 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,"MODE MODIFY NACK"); |
| 5814 | } |
| 5815 | [] T0.timeout { |
| 5816 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for MODE MODIFY (N)ACK"); |
| 5817 | } |
| 5818 | } |
| 5819 | |
| 5820 | var octetstring l3msg := f_rnd_octstring(15); |
| 5821 | timer T1 := 3.0; |
| 5822 | /* Send UI frame from MS, do not expect it to arrive as RLL UNITDATA IND on Abis |
| 5823 | due to broken encryption */ |
| 5824 | f_tx_lapdm(ts_LAPDm_UI(link_id.sapi, cr_MO_CMD, l3msg), link_id); |
| 5825 | T1.start; |
| 5826 | alt { |
| 5827 | [] RSL.receive(tr_RSL_UNITDATA_IND(g_chan_nr, link_id, l3msg)) { |
| 5828 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "BTS shouldn't be able to decrypt after key change") |
| 5829 | } |
| 5830 | [] T1.timeout { |
| 5831 | setverdict(pass); |
| 5832 | } |
| 5833 | } |
| 5834 | |
| 5835 | /* release the channel */ |
| 5836 | f_rsl_chan_deact(); |
| 5837 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 5838 | f_rslem_unregister(0, g_chan_nr); |
| 5839 | } |
| 5840 | testcase TC_rsl_modify_encr() runs on test_CT { |
| 5841 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 5842 | pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_1, f_rnd_octstring(8))); |
| 5843 | f_testmatrix_each_chan(pars, refers(f_TC_rsl_modify_encr)); |
| 5844 | } |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 5845 | |
| 5846 | /* Test unencrypted channel activation followed by explicit ENCR CMD later */ |
| 5847 | function f_TC_encr_cmd(charstring id) runs on ConnHdlr { |
| 5848 | /* L3 payload doesn't matter, as it is passed transparently */ |
| 5849 | var BIT3 l3_alg_id := f_alg_id_to_l3(g_pars.encr.alg_id); |
| 5850 | var octetstring l3 := enc_PDU_ML3_NW_MS(valueof(ts_RRM_CiphModeCmd(l3_alg_id))); |
| 5851 | var RslLinkId link_id := valueof(ts_RslLinkID_DCCH(0)); |
| 5852 | |
| 5853 | f_l1_tune(L1CTL); |
| 5854 | |
| 5855 | /* first establish a dedicated channel in the clear */ |
| 5856 | f_est_dchan(false); |
| 5857 | |
| 5858 | /* Establish ABM */ |
| 5859 | f_est_rll_mo(link_id.sapi, link_id, '23420815'O); |
| 5860 | |
| 5861 | /* then send the RSL ENCR CMD with an actual RR CIPH MOD CMD inside */ |
| 5862 | RSL.send(ts_RSL_ENCR_CMD(g_chan_nr, link_id, g_pars.encr.alg_id, g_pars.encr.key, l3)); |
| 5863 | /* expect the L3 to arrive still unencrypted on the MS side */ |
| 5864 | f_l1_exp_lapdm(tr_LAPDm_I(link_id.sapi, cr_MT_CMD, ?, ?, ?, l3)); |
| 5865 | |
| 5866 | /* configure L1 to apply ciphering */ |
| 5867 | var uint8_t alg_id := f_alg_id_to_l1ctl(g_pars.encr.alg_id); |
| 5868 | f_L1CTL_CRYPTO_REQ(L1CTL, g_pars.chan_nr, alg_id, g_pars.encr.key); |
| 5869 | |
Vadim Yanitskiy | 4d78a70 | 2018-10-03 03:59:34 +0700 | [diff] [blame] | 5870 | /* send first ciphered I-frame in response and expect it on RSL */ |
| 5871 | 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] | 5872 | |
| 5873 | /* now the BTS code should have detected the first properly encrypted uplink I-frame, |
| 5874 | * and hence enable encryption also on the downlink */ |
| 5875 | |
| 5876 | /* expect bi-directional communication work in encrypted mode */ |
| 5877 | f_unitdata_mo(link_id, f_rnd_octstring(15)); |
| 5878 | f_unitdata_mt(link_id, f_rnd_octstring(15)); |
| 5879 | |
| 5880 | /* release the channel */ |
| 5881 | f_rsl_chan_deact(); |
| 5882 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 5883 | f_rslem_unregister(0, g_chan_nr); |
| 5884 | } |
| 5885 | testcase TC_encr_cmd_a51() runs on test_CT { |
| 5886 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 5887 | pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_1, f_rnd_octstring(8))); |
| 5888 | f_testmatrix_each_chan(pars, refers(f_TC_encr_cmd)); |
| 5889 | } |
| 5890 | testcase TC_encr_cmd_a52() runs on test_CT { |
| 5891 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 5892 | pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_2, f_rnd_octstring(8))); |
| 5893 | f_testmatrix_each_chan(pars, refers(f_TC_encr_cmd)); |
| 5894 | } |
| 5895 | testcase TC_encr_cmd_a53() runs on test_CT { |
| 5896 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 5897 | pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_3, f_rnd_octstring(8))); |
| 5898 | f_testmatrix_each_chan(pars, refers(f_TC_encr_cmd)); |
| 5899 | } |
| 5900 | |
| 5901 | private function f_assert_lapdm(octetstring enc, template LapdmFrame exp_match, charstring name := "") { |
| 5902 | var LapdmFrame lf; |
| 5903 | var octetstring reenc; |
| 5904 | |
| 5905 | /* decode the LAPDm frame */ |
| 5906 | if (ischosen(exp_match.ab)) { |
| 5907 | lf.ab := dec_LapdmFrameAB(enc); |
| 5908 | } else { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 5909 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "unsupported frame type"); |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 5910 | } |
| 5911 | |
| 5912 | /* check if decoder result matches expectation */ |
| 5913 | if (not match(lf, exp_match)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 5914 | 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] | 5915 | } else { |
| 5916 | log(name, ": matched"); |
| 5917 | setverdict(pass); |
| 5918 | } |
| 5919 | |
| 5920 | /* test if re-encoded frame equals original input */ |
| 5921 | reenc := enc_LapdmFrame(lf); |
| 5922 | if (enc != reenc) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 5923 | 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] | 5924 | } else { |
| 5925 | setverdict(pass); |
| 5926 | } |
| 5927 | } |
| 5928 | |
| 5929 | testcase TC_lapdm_selftest() runs on test_CT { |
| 5930 | f_assert_lapdm('030301'O, tr_LAPDm_UI(0, true, ''O), "ui_s0_empty"); |
| 5931 | f_assert_lapdm('0F0301'O, tr_LAPDm_UI(3, true, ''O), "ui_s3_empty"); |
| 5932 | f_assert_lapdm('013F01'O, tr_LAPDm_SABM(0, false, true, ''O), "sabm_s0_empty"); |
| 5933 | f_assert_lapdm('013F1123420815'O, tr_LAPDm_SABM(0, false, true, '23420815'O), "sabm_s0_l3"); |
| 5934 | f_assert_lapdm('03E101'O, tr_LAPDm_RR(0, true, false, 7), "rr_s0_7"); |
| 5935 | f_assert_lapdm('03000d063505'O, tr_LAPDm_I(0, true, false, 0, 0, '063505'O), "I/0/0"); |
| 5936 | f_assert_lapdm('03e00d063505'O, tr_LAPDm_I(0, true, false, 7, 0, '063505'O), "I/7/0"); |
| 5937 | } |
| 5938 | |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 5939 | /*********************************************************************** |
| 5940 | * DTX Related (see GSM 05.08, section 8.3) |
| 5941 | ***********************************************************************/ |
| 5942 | |
| 5943 | /* XXX These functions must be kept in sync with g_AllChannels defined on test_CT. */ |
| 5944 | function f_g_chan_is_tchf() runs on ConnHdlr return boolean { |
| 5945 | return (g_chan_nr == valueof(ts_RslChanNr_Bm(1)) or |
| 5946 | g_chan_nr == valueof(ts_RslChanNr_Bm(2)) or |
| 5947 | g_chan_nr == valueof(ts_RslChanNr_Bm(3)) or |
| 5948 | g_chan_nr == valueof(ts_RslChanNr_Bm(4))); |
| 5949 | } |
| 5950 | function f_g_chan_is_tchh() runs on ConnHdlr return boolean { |
| 5951 | return (g_chan_nr == valueof(ts_RslChanNr_Lm(5,0)) or |
| 5952 | g_chan_nr == valueof(ts_RslChanNr_Lm(5,1))); |
| 5953 | } |
| 5954 | function f_g_chan_is_sdcch4() runs on ConnHdlr return boolean { |
| 5955 | return (g_chan_nr == valueof(ts_RslChanNr_SDCCH4(0,0)) or |
| 5956 | g_chan_nr == valueof(ts_RslChanNr_SDCCH4(0,1)) or |
| 5957 | g_chan_nr == valueof(ts_RslChanNr_SDCCH4(0,2)) or |
| 5958 | g_chan_nr == valueof(ts_RslChanNr_SDCCH4(0,3))); |
| 5959 | } |
| 5960 | function f_g_chan_is_sdcch8() runs on ConnHdlr return boolean { |
| 5961 | return (g_chan_nr == valueof(ts_RslChanNr_SDCCH8(6,0)) or |
| 5962 | g_chan_nr == valueof(ts_RslChanNr_SDCCH8(6,1)) or |
| 5963 | g_chan_nr == valueof(ts_RslChanNr_SDCCH8(6,2)) or |
| 5964 | g_chan_nr == valueof(ts_RslChanNr_SDCCH8(6,3)) or |
| 5965 | g_chan_nr == valueof(ts_RslChanNr_SDCCH8(6,4)) or |
| 5966 | g_chan_nr == valueof(ts_RslChanNr_SDCCH8(6,5)) or |
| 5967 | g_chan_nr == valueof(ts_RslChanNr_SDCCH8(6,6)) or |
| 5968 | g_chan_nr == valueof(ts_RslChanNr_SDCCH8(6,7))); |
| 5969 | } |
| 5970 | |
| 5971 | function f_test_l2_fill_frames(boolean dtxd) runs on ConnHdlr { |
| 5972 | var L1ctlDlMessage dl; |
| 5973 | var octetstring l2_fill_frame := '0303012B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B'O; |
| 5974 | var octetstring l2_fill_frame_sacch := substr(l2_fill_frame, 0, lengthof(l2_fill_frame) - 2); |
| 5975 | var GsmFrameNumber first_fn; |
| 5976 | var boolean is_first_frame := true; |
Stefan Sperling | 91d4c9d | 2018-08-09 20:03:08 +0200 | [diff] [blame] | 5977 | var integer nfill_frames_sacch := 0; |
| 5978 | var integer nfill_frames_nonsacch := 0; |
| 5979 | 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] | 5980 | /* Frames numbers (mod 104) for which a fill frame is expected on TCHF if DTX is enabled. */ |
| 5981 | 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] | 5982 | const integer frame_dtx_tchf_mod := 104; |
| 5983 | /* Frame numbers (mod 104) for which a fill frame is expected at the L1SAP level, |
| 5984 | * which operates in terms of blocks rather than frames. */ |
| 5985 | var Integers required_tdma_blocks_dtx_tchf := { 52, 56 }; |
| 5986 | const integer block_dtx_tchf_mod := 26; |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 5987 | timer T := 5.0; |
| 5988 | |
| 5989 | f_l1_tune(L1CTL); |
| 5990 | RSL.clear; |
| 5991 | L1CTL.clear; |
| 5992 | |
| 5993 | /* activate TCHF signalling channel */ |
| 5994 | f_est_dchan(false); |
| 5995 | |
| 5996 | T.start; |
| 5997 | alt { |
| 5998 | [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, ?)) -> value dl { |
| 5999 | var GsmFrameNumber fn := dl.dl_info.frame_nr; |
| 6000 | var octetstring l2 := dl.payload.data_ind.payload; |
| 6001 | |
| 6002 | if (is_first_frame) { |
| 6003 | is_first_frame := false; |
| 6004 | first_fn := dl.dl_info.frame_nr; |
| 6005 | } |
| 6006 | |
| 6007 | if (dl.dl_info.link_id.c == SACCH) { |
| 6008 | l2 := substr(l2, 2, lengthof(l2) - 2); /* remove L1 header */ |
| 6009 | if (not match(l2_fill_frame_sacch, l2)) { |
| 6010 | repeat; |
| 6011 | } |
| 6012 | } else if (not match(l2_fill_frame, l2)) { |
| 6013 | repeat; |
| 6014 | } |
| 6015 | |
| 6016 | if (dtxd) { |
| 6017 | if (not f_g_chan_is_tchf()) { |
| 6018 | T.stop; |
| 6019 | f_rsl_chan_deact(); |
| 6020 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 6021 | 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] | 6022 | } |
Stefan Sperling | 91d4c9d | 2018-08-09 20:03:08 +0200 | [diff] [blame] | 6023 | if (fn > first_fn + frame_dtx_tchf_mod) { |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 6024 | T.stop; |
| 6025 | f_rsl_chan_deact(); |
| 6026 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
Stefan Sperling | 91d4c9d | 2018-08-09 20:03:08 +0200 | [diff] [blame] | 6027 | |
| 6028 | /* With DTX enabled we can expect at least 3 fill frames for every 104 frames. |
| 6029 | * 2 SACCH, 1 TCH/F */ |
| 6030 | expected_fill_frames := 3; |
| 6031 | |
| 6032 | if (nfill_frames_sacch + nfill_frames_nonsacch < expected_fill_frames) { |
| 6033 | log("received only ", nfill_frames_sacch, "+", nfill_frames_nonsacch, |
| 6034 | " (SACCH+other) out of ", expected_fill_frames, " expected fill frames"); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 6035 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Not enough fill frames received"); |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 6036 | } else { |
| 6037 | setverdict(pass); |
| 6038 | } |
Stefan Sperling | 91d4c9d | 2018-08-09 20:03:08 +0200 | [diff] [blame] | 6039 | } else { |
| 6040 | if (dl.dl_info.link_id.c == SACCH) { |
| 6041 | nfill_frames_sacch := nfill_frames_sacch + 1; |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 6042 | repeat; |
| 6043 | } |
Stefan Sperling | 91d4c9d | 2018-08-09 20:03:08 +0200 | [diff] [blame] | 6044 | /* On DTX TCH/F channels, fill frames occur only for specific frame numbers mod 104. |
| 6045 | * Furthermore, the L1SAP layer gives us frame numbers for the start of a block so |
| 6046 | * we should only see the subset of frames numbers which correspond to a block boundary. |
| 6047 | * TCH/F blocks are defined to start at 0,4,8,13,17,21 (modulo 26) */ |
| 6048 | for (var integer i := 0; i < lengthof(required_tdma_blocks_dtx_tchf); i := i + 1) { |
| 6049 | if (fn mod frame_dtx_tchf_mod == required_tdma_blocks_dtx_tchf[i]) { |
| 6050 | nfill_frames_nonsacch := nfill_frames_nonsacch + 1; |
| 6051 | repeat; |
| 6052 | } |
| 6053 | } |
| 6054 | log("Received DTX TCH fill frame with bad frame number: ", fn, |
| 6055 | " (mod ", frame_dtx_tchf_mod, ": ", fn mod frame_dtx_tchf_mod, ")", |
| 6056 | " (mod ", block_dtx_tchf_mod, ": ", fn mod block_dtx_tchf_mod, ")"); |
| 6057 | f_rsl_chan_deact(); |
| 6058 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 6059 | 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] | 6060 | } |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 6061 | } else { |
Stefan Sperling | 91d4c9d | 2018-08-09 20:03:08 +0200 | [diff] [blame] | 6062 | if (dl.dl_info.link_id.c == SACCH) { |
| 6063 | nfill_frames_sacch := nfill_frames_sacch + 1; |
| 6064 | } else { |
| 6065 | nfill_frames_nonsacch := nfill_frames_nonsacch + 1; |
| 6066 | } |
| 6067 | if (fn > first_fn + frame_dtx_tchf_mod) { |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 6068 | T.stop; |
| 6069 | if (f_g_chan_is_tchf()) { |
| 6070 | /* Without DTX we can expect 25 fill frames for every 104 frames. |
| 6071 | * (24 FACCH + 1 SACCH filling) */ |
| 6072 | expected_fill_frames := 25; |
| 6073 | } else if (f_g_chan_is_tchh()) { |
| 6074 | /* We can expect 2 fill frames for every 104 frames. */ |
| 6075 | expected_fill_frames := 2; |
| 6076 | } else if (f_g_chan_is_sdcch4() or f_g_chan_is_sdcch8()) { |
| 6077 | /* We can expect 5 fill frames for every 104 frames. */ |
| 6078 | expected_fill_frames := 5; |
| 6079 | } else { |
| 6080 | f_rsl_chan_deact(); |
| 6081 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 6082 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unknown channel type"); |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 6083 | } |
| 6084 | |
| 6085 | f_rsl_chan_deact(); |
| 6086 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
Stefan Sperling | 91d4c9d | 2018-08-09 20:03:08 +0200 | [diff] [blame] | 6087 | |
| 6088 | if (nfill_frames_sacch + nfill_frames_nonsacch >= expected_fill_frames) { |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 6089 | setverdict(pass); |
| 6090 | } else { |
Stefan Sperling | 91d4c9d | 2018-08-09 20:03:08 +0200 | [diff] [blame] | 6091 | log("received only ", nfill_frames_sacch, "+", nfill_frames_nonsacch, |
| 6092 | " (SACCH+other) out of ", expected_fill_frames, " expected fill frames"); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 6093 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Not enough fill frames received"); |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 6094 | } |
| 6095 | } else { |
| 6096 | repeat; |
| 6097 | } |
| 6098 | } |
| 6099 | } |
| 6100 | [] L1CTL.receive { repeat; } |
| 6101 | [] T.timeout { |
| 6102 | f_rsl_chan_deact(); |
| 6103 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 6104 | 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] | 6105 | } |
| 6106 | } |
| 6107 | } |
| 6108 | |
| 6109 | function f_TC_tch_sign_l2_fill_frame(charstring id) runs on ConnHdlr { |
| 6110 | f_test_l2_fill_frames(false); |
| 6111 | } |
| 6112 | |
| 6113 | function f_TC_tch_sign_l2_fill_frame_dtxd(charstring id) runs on ConnHdlr { |
| 6114 | f_test_l2_fill_frames(true); |
| 6115 | } |
| 6116 | |
| 6117 | function f_tch_sign_l2_fill_frame(boolean dtxd) runs on test_CT { |
| 6118 | var ConnHdlr vc_conn; |
| 6119 | var ConnHdlrPars pars; |
| 6120 | pars.t_guard := 60.0; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 6121 | f_init(); |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 6122 | for (var integer i := 0; i < sizeof(g_AllChannels); i := i + 1) { |
| 6123 | pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN(dtxd))); |
| 6124 | if (dtxd) { |
| 6125 | if (i >= 4) { /* DTX is only allowed on TCH/F */ |
| 6126 | break; |
| 6127 | } |
| 6128 | vc_conn := f_start_handler(refers(f_TC_tch_sign_l2_fill_frame_dtxd), pars); |
| 6129 | } else { |
| 6130 | vc_conn := f_start_handler(refers(f_TC_tch_sign_l2_fill_frame), pars); |
| 6131 | } |
| 6132 | vc_conn.done; |
| 6133 | } |
| 6134 | } |
| 6135 | |
| 6136 | /* Verify that L2 fill frames are sent on TCH in signaling mode if |
| 6137 | * there is nothing to transmit while DTX is disabled on downlink. */ |
| 6138 | testcase TC_tch_sign_l2_fill_frame() runs on test_CT { |
| 6139 | f_tch_sign_l2_fill_frame(false); |
| 6140 | } |
| 6141 | |
| 6142 | /* Verify that particular L2 fill frames are sent on TCH in signaling mode if |
| 6143 | * there is nothing to transmit while DTX is enabled on downlink. */ |
| 6144 | testcase TC_tch_sign_l2_fill_frame_dtxd() runs on test_CT { |
| 6145 | f_tch_sign_l2_fill_frame(true); |
| 6146 | } |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 6147 | |
Stefan Sperling | 0ec1c26 | 2018-10-15 15:12:52 +0200 | [diff] [blame] | 6148 | testcase TC_chopped_ipa_ping() runs on test_CT { |
| 6149 | IPA_Testing.f_run_TC_chopped_ipa_ping(mp_rsl_ip, mp_rsl_port, LISTEN_FOR_CLIENT); |
| 6150 | } |
| 6151 | |
Stefan Sperling | aa1e60f | 2018-10-15 16:34:07 +0200 | [diff] [blame] | 6152 | testcase TC_chopped_ipa_payload() runs on test_CT { |
| 6153 | IPA_Testing.f_run_TC_chopped_ipa_payload(mp_rsl_ip, mp_rsl_port, LISTEN_FOR_CLIENT); |
| 6154 | } |
| 6155 | |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 6156 | /* test generation of RLL ERR IND based on Um errors (TS 48.058 3.9) */ |
| 6157 | /* protocol error as per 44.006 */ |
| 6158 | /* link layer failure (repetition of I-frame N200 times without ACK */ |
| 6159 | /* repetition of SABM or DISC N200 times without ACK */ |
| 6160 | /* receptiom of SABM in multi-frame established state */ |
| 6161 | |
| 6162 | |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 6163 | /* TODO Areas: |
| 6164 | |
| 6165 | * channel activation |
| 6166 | ** with BS_Power / MS_Power, bypassing power control loop |
| 6167 | ** on primary vs. secondary TRX |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 6168 | ** with timing advance from initial activation on |
| 6169 | * mode modify |
| 6170 | ** encryption |
| 6171 | ** multirate |
| 6172 | * check DEACTIVATE SACCH |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 6173 | ** unsupported algorithm |
| 6174 | * handover detection |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 6175 | * BS Power Control |
| 6176 | * Physical Context |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 6177 | * RF resource ind |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 6178 | * error handling |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 6179 | ** IE duplicated? |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 6180 | * PCU interface |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 6181 | ** DATA_IND from BTS->PCU |
| 6182 | ** verification of PCU-originated DATA_REQ arrival on Um/MS side |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 6183 | |
| 6184 | */ |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 6185 | |
| 6186 | control { |
| 6187 | execute( TC_chan_act_stress() ); |
| 6188 | execute( TC_chan_act_react() ); |
| 6189 | execute( TC_chan_deact_not_active() ); |
| 6190 | execute( TC_chan_act_wrong_nr() ); |
Harald Welte | 629cc6b | 2018-03-11 17:19:05 +0100 | [diff] [blame] | 6191 | execute( TC_deact_sacch() ); |
Harald Welte | ea17b91 | 2018-03-11 22:29:31 +0100 | [diff] [blame] | 6192 | execute( TC_sacch_filling() ); |
| 6193 | execute( TC_sacch_info_mod() ); |
Harald Welte | 075d84c | 2018-03-12 13:07:24 +0100 | [diff] [blame] | 6194 | execute( TC_sacch_multi() ); |
Harald Welte | 5570066 | 2018-03-12 13:15:43 +0100 | [diff] [blame] | 6195 | execute( TC_sacch_multi_chg() ); |
Harald Welte | c8d363c | 2019-05-19 20:36:48 +0200 | [diff] [blame] | 6196 | execute( TC_sacch_chan_act() ); |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 6197 | execute( TC_sacch_chan_act_ho_async() ); |
| 6198 | execute( TC_sacch_chan_act_ho_sync() ); |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 6199 | execute( TC_rach_content() ); |
| 6200 | execute( TC_rach_count() ); |
Harald Welte | 54a2a2d | 2018-02-26 09:14:05 +0100 | [diff] [blame] | 6201 | execute( TC_rach_max_ta() ); |
Vadim Yanitskiy | 7c2c10c | 2019-05-31 20:42:01 +0700 | [diff] [blame] | 6202 | execute( TC_ho_rach() ); |
Harald Welte | 3453ab4 | 2019-05-24 21:19:58 +0200 | [diff] [blame] | 6203 | execute( TC_rach_load_idle_thresh0() ); |
| 6204 | execute( TC_rach_load_idle_below_thresh() ); |
| 6205 | execute( TC_rach_load_count() ); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 6206 | execute( TC_meas_res_sign_tchf() ); |
| 6207 | execute( TC_meas_res_sign_tchh() ); |
| 6208 | execute( TC_meas_res_sign_sdcch4() ); |
| 6209 | execute( TC_meas_res_sign_sdcch8() ); |
Harald Welte | 685d598 | 2018-02-27 20:42:05 +0100 | [diff] [blame] | 6210 | execute( TC_meas_res_sign_tchh_toa256() ); |
Eric Wild | ae8f262 | 2019-06-18 17:05:11 +0200 | [diff] [blame] | 6211 | execute( TC_rsl_bs_pwr_static_ass() ); |
| 6212 | execute( TC_rsl_bs_pwr_static_power_control() ); |
Philipp Maier | 4d1e9c9 | 2018-12-20 11:11:56 +0100 | [diff] [blame] | 6213 | execute( TC_rsl_ms_pwr_ctrl() ); |
Eric Wild | 280ccb8 | 2019-06-17 11:11:52 +0200 | [diff] [blame] | 6214 | execute( TC_rsl_ms_pwr_dyn_active() ); |
Eric Wild | 095024b | 2019-06-17 15:08:57 +0200 | [diff] [blame] | 6215 | execute( TC_rsl_ms_pwr_dyn_active2() ); |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 6216 | execute( TC_rsl_ms_pwr_dyn_up() ); |
| 6217 | execute( TC_rsl_ms_pwr_dyn_down() ); |
| 6218 | execute( TC_rsl_ms_pwr_dyn_ass_updown() ); |
| 6219 | execute( TC_rsl_ms_pwr_dyn_max() ); |
Eric Wild | e57e1a6 | 2019-05-28 13:30:55 +0200 | [diff] [blame] | 6220 | execute( TC_rsl_chan_initial_ms_pwr() ); |
Eric Wild | 6833cc9 | 2019-05-23 19:34:44 +0200 | [diff] [blame] | 6221 | execute( TC_rsl_chan_initial_ta() ); |
Eric Wild | f1827a7 | 2019-05-28 17:37:35 +0200 | [diff] [blame] | 6222 | execute( TC_rsl_modify_encr() ); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 6223 | execute( TC_conn_fail_crit() ); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 6224 | execute( TC_paging_imsi_80percent() ); |
| 6225 | execute( TC_paging_tmsi_80percent() ); |
| 6226 | execute( TC_paging_imsi_200percent() ); |
| 6227 | execute( TC_paging_tmsi_200percent() ); |
Harald Welte | 01d982c | 2018-02-25 01:31:40 +0100 | [diff] [blame] | 6228 | execute( TC_rsl_protocol_error() ); |
| 6229 | execute( TC_rsl_mand_ie_error() ); |
| 6230 | execute( TC_rsl_ie_content_error() ); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 6231 | execute( TC_si_sched_default() ); |
Harald Welte | 0cae455 | 2018-03-09 22:20:26 +0100 | [diff] [blame] | 6232 | execute( TC_si_sched_1() ); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 6233 | execute( TC_si_sched_2bis() ); |
| 6234 | execute( TC_si_sched_2ter() ); |
| 6235 | execute( TC_si_sched_2ter_2bis() ); |
| 6236 | execute( TC_si_sched_2quater() ); |
| 6237 | execute( TC_si_sched_13() ); |
| 6238 | execute( TC_si_sched_13_2bis_2ter_2quater() ); |
Harald Welte | a871a38 | 2018-02-25 02:03:14 +0100 | [diff] [blame] | 6239 | execute( TC_ipa_dlcx_not_active() ); |
Harald Welte | a3f1df9 | 2018-02-25 12:49:55 +0100 | [diff] [blame] | 6240 | execute( TC_ipa_crcx_twice_not_active() ); |
| 6241 | execute( TC_ipa_crcx_mdcx_dlcx_not_active() ); |
Harald Welte | 3ae11da | 2018-02-25 13:36:06 +0100 | [diff] [blame] | 6242 | execute( TC_ipa_crcx_mdcx_mdcx_dlcx_not_active() ); |
Harald Welte | 9912eb5 | 2018-02-25 13:30:15 +0100 | [diff] [blame] | 6243 | execute( TC_ipa_crcx_sdcch_not_active() ); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 6244 | |
Pau Espin Pedrol | a14a8af | 2018-11-20 13:12:22 +0100 | [diff] [blame] | 6245 | if (mp_pcu_socket != "") { |
| 6246 | execute( TC_pcu_act_req() ); |
| 6247 | execute( TC_pcu_act_req_wrong_ts() ); |
| 6248 | execute( TC_pcu_act_req_wrong_bts() ); |
| 6249 | execute( TC_pcu_act_req_wrong_trx() ); |
| 6250 | execute( TC_pcu_deact_req() ); |
| 6251 | execute( TC_pcu_deact_req_wrong_ts() ); |
| 6252 | execute( TC_pcu_ver_si13() ); |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 6253 | if (mp_l1_supports_gprs) { |
| 6254 | execute( TC_pcu_data_req_pdtch() ); |
| 6255 | execute( TC_pcu_data_req_ptcch() ); |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 6256 | execute( TC_pcu_data_req_wrong_bts() ); |
| 6257 | execute( TC_pcu_data_req_wrong_trx() ); |
| 6258 | execute( TC_pcu_data_req_wrong_ts() ); |
| 6259 | execute( TC_pcu_data_req_ts_inactive() ); |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 6260 | } |
Pau Espin Pedrol | a14a8af | 2018-11-20 13:12:22 +0100 | [diff] [blame] | 6261 | execute( TC_pcu_data_req_agch() ); |
Harald Welte | 928622b | 2019-05-26 13:22:59 +0200 | [diff] [blame] | 6262 | execute( TC_pcu_data_req_pch() ); |
Pau Espin Pedrol | a14a8af | 2018-11-20 13:12:22 +0100 | [diff] [blame] | 6263 | execute( TC_pcu_data_req_imm_ass_pch() ); |
| 6264 | execute( TC_pcu_rach_content() ); |
Vadim Yanitskiy | 51cbc10 | 2019-04-22 06:37:30 +0700 | [diff] [blame] | 6265 | execute( TC_pcu_ext_rach_content() ); |
Vadim Yanitskiy | a2c68e8 | 2019-07-03 13:07:20 +0700 | [diff] [blame] | 6266 | execute( TC_pcu_data_ind_lqual_cb() ); |
Pau Espin Pedrol | a14a8af | 2018-11-20 13:12:22 +0100 | [diff] [blame] | 6267 | execute( TC_pcu_paging_from_rsl() ); |
Harald Welte | d66c9b8 | 2019-05-25 09:03:15 +0200 | [diff] [blame] | 6268 | execute( TC_pcu_time_ind() ); |
Harald Welte | 4832c86 | 2019-05-25 14:57:18 +0200 | [diff] [blame] | 6269 | execute( TC_pcu_rts_req() ); |
Harald Welte | 07bd2d2 | 2019-05-25 11:03:30 +0200 | [diff] [blame] | 6270 | execute( TC_pcu_oml_alert() ); |
Harald Welte | eaa9a86 | 2019-05-26 23:01:08 +0200 | [diff] [blame] | 6271 | execute( TC_pcu_rr_suspend() ); |
Harald Welte | a2e0e94 | 2019-05-27 18:12:53 +0200 | [diff] [blame] | 6272 | execute( TC_pcu_socket_connect_multi() ); |
Harald Welte | c8effb7 | 2019-05-27 18:23:04 +0200 | [diff] [blame] | 6273 | execute( TC_pcu_socket_reconnect() ); |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 6274 | execute( TC_pcu_socket_noconnect_nosi3gprs() ); |
| 6275 | execute( TC_pcu_socket_connect_si3gprs() ); |
| 6276 | execute( TC_pcu_socket_disconnect_nosi3gprs() ); |
Oliver Smith | f5239c7 | 2019-08-28 10:01:25 +0200 | [diff] [blame] | 6277 | execute( TC_pcu_socket_verify_info_ind() ); |
Pau Espin Pedrol | a14a8af | 2018-11-20 13:12:22 +0100 | [diff] [blame] | 6278 | } else { |
| 6279 | log("PCU socket path not available, skipping PCU tests"); |
| 6280 | } |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 6281 | |
| 6282 | execute( TC_dyn_osmo_pdch_act_deact() ); |
| 6283 | execute( TC_dyn_osmo_pdch_unsol_deact() ); |
| 6284 | execute( TC_dyn_osmo_pdch_double_act() ); |
| 6285 | execute( TC_dyn_osmo_pdch_tchf_act() ); |
| 6286 | execute( TC_dyn_osmo_pdch_tchh_act() ); |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 6287 | execute( TC_dyn_ipa_pdch_act_deact() ); |
| 6288 | execute( TC_dyn_ipa_pdch_tchf_act() ); |
| 6289 | execute( TC_dyn_ipa_pdch_tchf_act_pdch_act_nack() ); |
| 6290 | execute( TC_dyn_ipa_pdch_act_tchf_act_nack() ); |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 6291 | |
| 6292 | execute( TC_rll_est_ind() ); |
| 6293 | execute( TC_rll_est_req_DCCH_3() ); |
| 6294 | execute( TC_rll_est_req_ACCH_3() ); |
| 6295 | execute( TC_rll_rel_ind_DCCH_0() ); |
| 6296 | execute( TC_rll_rel_ind_DCCH_3() ); |
| 6297 | execute( TC_rll_rel_ind_ACCH_0() ); |
| 6298 | execute( TC_rll_rel_ind_ACCH_3() ); |
| 6299 | execute( TC_rll_rel_req() ); |
| 6300 | execute( TC_rll_unit_data_req_DCCH() ); |
| 6301 | execute( TC_rll_unit_data_req_ACCH() ); |
| 6302 | execute( TC_rll_unit_data_ind_DCCH() ); |
| 6303 | execute( TC_rll_unit_data_ind_ACCH() ); |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 6304 | |
| 6305 | execute( TC_chan_act_a51() ); |
| 6306 | execute( TC_chan_act_a52() ); |
| 6307 | execute( TC_chan_act_a53() ); |
| 6308 | execute( TC_encr_cmd_a51() ); |
| 6309 | execute( TC_encr_cmd_a52() ); |
| 6310 | execute( TC_encr_cmd_a53() ); |
| 6311 | |
Harald Welte | ee25aae | 2019-05-19 14:32:37 +0200 | [diff] [blame] | 6312 | execute( TC_err_rep_wrong_mdisc() ); |
| 6313 | execute( TC_err_rep_wrong_msg_type() ); |
| 6314 | execute( TC_err_rep_wrong_sequence() ); |
| 6315 | |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 6316 | execute( TC_lapdm_selftest() ); |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 6317 | |
| 6318 | execute( TC_tch_sign_l2_fill_frame() ); |
| 6319 | execute( TC_tch_sign_l2_fill_frame_dtxd() ); |
Stefan Sperling | 0ec1c26 | 2018-10-15 15:12:52 +0200 | [diff] [blame] | 6320 | |
| 6321 | execute( TC_chopped_ipa_ping() ); |
Stefan Sperling | aa1e60f | 2018-10-15 16:34:07 +0200 | [diff] [blame] | 6322 | execute( TC_chopped_ipa_payload() ); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 6323 | } |
| 6324 | |
| 6325 | |
| 6326 | } |