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