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