Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1 | module BTS_Tests { |
| 2 | |
Harald Welte | 1490695 | 2019-05-27 09:19:49 +0200 | [diff] [blame] | 3 | /* Integration Tests for OsmoBTS |
Harald Welte | 34b5a95 | 2019-05-27 11:54:11 +0200 | [diff] [blame] | 4 | * (C) 2018-2019 by Harald Welte <laforge@gnumonks.org> |
Harald Welte | 1490695 | 2019-05-27 09:19:49 +0200 | [diff] [blame] | 5 | * contributions by Vadim Yanitskiy and sysmocom - s.f.m.c. GmbH |
| 6 | * All rights reserved. |
| 7 | * |
| 8 | * Released under the terms of GNU General Public License, Version 2 or |
| 9 | * (at your option) any later version. |
| 10 | * |
Harald Welte | 34b5a95 | 2019-05-27 11:54:11 +0200 | [diff] [blame] | 11 | * SPDX-License-Identifier: GPL-2.0-or-later |
| 12 | * |
Harald Welte | 1490695 | 2019-05-27 09:19:49 +0200 | [diff] [blame] | 13 | * This test suite tests OsmoBTS by attaching to the external interfaces |
| 14 | * such as Abis RSL, PCU, VTY as well as by attaching to a MS L1 implementation |
| 15 | * using the L1CTL protocol/interface. |
| 16 | * |
| 17 | * You can run the tests with |
| 18 | * a) osmo-bts-trx + trxcon + fake_trx (without any hardware) |
| 19 | * b) any osmo-bts-* + OsmocomBB layer1 + osmocon (with real BTS hardware) |
| 20 | * c) osmo-bts-virtual + virt_phy (without any hardware) |
| 21 | * |
| 22 | * Some of the tests will only run on a subset of those three configurations |
| 23 | * due to limitations in the respective L1. |
| 24 | */ |
| 25 | |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 26 | import from Misc_Helpers all; |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 27 | import from General_Types all; |
| 28 | import from GSM_Types all; |
| 29 | import from GSM_RR_Types all; |
| 30 | import from Osmocom_Types all; |
| 31 | import from GSM_Types all; |
Vadim Yanitskiy | 5d2cf44 | 2020-05-02 16:49:17 +0700 | [diff] [blame] | 32 | import from GSM_RestOctets all; |
Harald Welte | 82ccef7 | 2018-02-25 16:17:33 +0100 | [diff] [blame] | 33 | import from GSM_SystemInformation all; |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 34 | import from L1CTL_PortType all; |
| 35 | import from L1CTL_Types all; |
| 36 | import from LAPDm_Types all; |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 37 | import from LAPDm_RAW_PT all; |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 38 | import from Osmocom_CTRL_Adapter all; |
Neels Hofmeyr | 6a84b23 | 2018-04-03 19:12:36 +0200 | [diff] [blame] | 39 | import from Osmocom_CTRL_Functions all; |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 40 | |
| 41 | import from RSL_Types all; |
Harald Welte | 7484fc4 | 2018-02-24 14:09:45 +0100 | [diff] [blame] | 42 | import from IPA_Types all; |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 43 | import from IPA_Emulation all; |
Stefan Sperling | 0ec1c26 | 2018-10-15 15:12:52 +0200 | [diff] [blame] | 44 | import from IPA_Testing all; |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 45 | import from RSL_Emulation all; |
| 46 | |
| 47 | import from IPL4asp_Types all; |
| 48 | import from TRXC_Types all; |
| 49 | import from TRXC_CodecPort all; |
| 50 | import from TRXC_CodecPort_CtrlFunct all; |
| 51 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 52 | import from PCUIF_Types all; |
| 53 | import from PCUIF_CodecPort all; |
Harald Welte | a2e0e94 | 2019-05-27 18:12:53 +0200 | [diff] [blame] | 54 | import from UD_Types all; |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 55 | |
Harald Welte | 7484fc4 | 2018-02-24 14:09:45 +0100 | [diff] [blame] | 56 | import from MobileL3_CommonIE_Types all; |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 57 | import from MobileL3_RRM_Types all; |
| 58 | import from MobileL3_Types all; |
| 59 | import from L3_Templates all; |
Harald Welte | eaa9a86 | 2019-05-26 23:01:08 +0200 | [diff] [blame] | 60 | import from L3_Common all; |
| 61 | import from MobileL3_GMM_SM_Types all; |
Harald Welte | 7484fc4 | 2018-02-24 14:09:45 +0100 | [diff] [blame] | 62 | |
Harald Welte | 8da4824 | 2018-02-27 20:41:32 +0100 | [diff] [blame] | 63 | import from Osmocom_VTY_Functions all; |
| 64 | import from TELNETasp_PortType all; |
Harald Welte | 2f2b2b7 | 2019-05-31 22:24:57 +0200 | [diff] [blame] | 65 | import from BTS_Tests_LAPDm all; |
Harald Welte | 8da4824 | 2018-02-27 20:41:32 +0100 | [diff] [blame] | 66 | |
Harald Welte | 505cf9b | 2018-09-15 17:47:23 +0300 | [diff] [blame] | 67 | friend module BTS_Tests_SMSCB; |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 68 | friend module BTS_Tests_virtphy; |
Harald Welte | 2f2b2b7 | 2019-05-31 22:24:57 +0200 | [diff] [blame] | 69 | friend module BTS_Tests_LAPDm; |
Pau Espin Pedrol | 5a012ee | 2020-02-06 19:33:22 +0100 | [diff] [blame] | 70 | friend module BTS_Tests_perf; |
Harald Welte | 505cf9b | 2018-09-15 17:47:23 +0300 | [diff] [blame] | 71 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 72 | /* The tests assume a BTS with the following timeslot configuration: |
| 73 | * TS0 : Combined CCCH + SDCCH/4 |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 74 | * TS1 : TCH/F |
| 75 | * TS2 : TCH/F |
| 76 | * TS3 : TCH/F_PDCH (IPA Style) |
| 77 | * TS4 : TCH/F_TCH/H_PDCH (Osmocom Style) |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 78 | * TS5 : TCH/H |
| 79 | * TS6 : SDCCH/8 |
| 80 | * TS7 : PDCH |
| 81 | */ |
| 82 | |
| 83 | modulepar { |
| 84 | charstring mp_rsl_ip := "127.0.0.2"; |
| 85 | integer mp_rsl_port := 3003; |
| 86 | integer mp_trx0_arfcn := 871; |
Vadim Yanitskiy | 44ff214 | 2019-01-12 07:04:58 +0700 | [diff] [blame] | 87 | charstring mp_bts_trxc_ip := "127.0.0.1"; |
| 88 | integer mp_bts_trxc_port := 5701; |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 89 | charstring mp_pcu_socket := PCU_SOCK_DEFAULT; |
Neels Hofmeyr | 6a84b23 | 2018-04-03 19:12:36 +0200 | [diff] [blame] | 90 | charstring mp_ctrl_ip := "127.0.0.1"; |
| 91 | integer mp_ctrl_port := 4238; |
Harald Welte | 07bd2d2 | 2019-05-25 11:03:30 +0200 | [diff] [blame] | 92 | charstring mp_bsc_ctrl_ip := "127.0.0.1"; |
| 93 | integer mp_bsc_ctrl_port := 4249; |
Pau Espin Pedrol | 121724c | 2018-09-28 15:58:12 +0200 | [diff] [blame] | 94 | integer mp_tolerance_rxqual := 1; |
| 95 | integer mp_tolerance_rxlev := 3; |
| 96 | integer mp_tolerance_timing_offset_256syms := 0; |
Pau Espin Pedrol | 752ffd5 | 2018-06-07 13:55:45 +0200 | [diff] [blame] | 97 | integer mp_rxlev_exp := 57; |
Pau Espin Pedrol | e9571aa | 2018-10-22 17:13:07 +0200 | [diff] [blame] | 98 | integer mp_ul_rxlev_exp := 10; |
Pau Espin Pedrol | ed359cb | 2018-09-28 16:08:24 +0200 | [diff] [blame] | 99 | integer mp_ms_power_level_exp := 7; |
Pau Espin Pedrol | 121724c | 2018-09-28 15:58:12 +0200 | [diff] [blame] | 100 | integer mp_ms_actual_ta_exp := 0; |
| 101 | integer mp_timing_offset_256syms_exp := 512; |
Pau Espin Pedrol | 315e471 | 2018-11-01 16:27:07 +0100 | [diff] [blame] | 102 | /* Time to wait for RSL conn from BTS during startup of test */ |
Philipp Maier | 12567e4 | 2019-04-17 14:10:05 +0200 | [diff] [blame] | 103 | float mp_ipa_up_timeout := 15.0; |
Philipp Maier | e63229e | 2019-04-26 12:21:37 +0200 | [diff] [blame] | 104 | float mp_ipa_up_delay := 0.0; |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 105 | /* false for now, as only virtphy supports it, not calypso-l1 nor trxcon */ |
| 106 | boolean mp_l1_supports_gprs := false; |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 107 | } |
| 108 | |
Harald Welte | 629cc6b | 2018-03-11 17:19:05 +0100 | [diff] [blame] | 109 | type record of RslChannelNr ChannelNrs; |
| 110 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 111 | type component test_CT extends CTRL_Adapter_CT { |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 112 | /* IPA Emulation component underneath RSL */ |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 113 | var IPA_Emulation_CT vc_IPA; |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 114 | /* RSL Emulation component (for ConnHdlr tests) */ |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 115 | var RSL_Emulation_CT vc_RSL; |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 116 | /* Direct RSL_CCHAN_PT */ |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 117 | port RSL_CCHAN_PT RSL_CCHAN; |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 118 | |
| 119 | /* L1CTL port (for classic tests) */ |
| 120 | port L1CTL_PT L1CTL; |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 121 | |
Vadim Yanitskiy | f4e997c | 2019-06-04 21:40:33 +0700 | [diff] [blame] | 122 | /* Optional TRXC connection to FakeTRX (BTS side) */ |
Vadim Yanitskiy | 44ff214 | 2019-01-12 07:04:58 +0700 | [diff] [blame] | 123 | port TRXC_CODEC_PT BTS_TRXC; |
| 124 | var integer g_bts_trxc_conn_id; |
Harald Welte | 54a2a2d | 2018-02-26 09:14:05 +0100 | [diff] [blame] | 125 | |
Harald Welte | f50e3ae | 2018-09-10 10:27:56 +0200 | [diff] [blame] | 126 | /* VTY connections to both BTS and BSC */ |
Harald Welte | 8da4824 | 2018-02-27 20:41:32 +0100 | [diff] [blame] | 127 | port TELNETasp_PT BTSVTY; |
Harald Welte | f50e3ae | 2018-09-10 10:27:56 +0200 | [diff] [blame] | 128 | port TELNETasp_PT BSCVTY; |
Harald Welte | 8da4824 | 2018-02-27 20:41:32 +0100 | [diff] [blame] | 129 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 130 | /* PCU Interface of BTS */ |
| 131 | port PCUIF_CODEC_PT PCU; |
| 132 | var integer g_pcu_conn_id; |
| 133 | /* Last PCU INFO IND we received */ |
| 134 | var PCUIF_Message g_pcu_last_info; |
| 135 | |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 136 | /* SI configuration */ |
| 137 | var SystemInformationConfig si_cfg := { |
| 138 | bcch_extended := false, |
| 139 | si1_present := false, |
| 140 | si2bis_present := false, |
| 141 | si2ter_present := false, |
| 142 | si2quater_present := false, |
| 143 | si7_present := false, |
| 144 | si8_present := false, |
| 145 | si9_present := false, |
| 146 | si13_present := false, |
| 147 | si13alt_present := false, |
| 148 | si15_present := false, |
| 149 | si16_present := false, |
| 150 | si17_present := false, |
| 151 | si2n_present := false, |
| 152 | si21_present := false, |
| 153 | si22_present := false |
| 154 | }; |
Harald Welte | 629cc6b | 2018-03-11 17:19:05 +0100 | [diff] [blame] | 155 | |
| 156 | /* all logical channels available on the BTS */ |
| 157 | var ChannelNrs g_AllChannels; |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 158 | var ChannelNrs g_AllChanTypes; |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 159 | } |
| 160 | |
| 161 | /* an individual call / channel */ |
Harald Welte | 2f2b2b7 | 2019-05-31 22:24:57 +0200 | [diff] [blame] | 162 | type component ConnHdlr extends RSL_DchanHdlr, lapdm_test_CT { |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 163 | port L1CTL_PT L1CTL; |
| 164 | |
Vadim Yanitskiy | f4e997c | 2019-06-04 21:40:33 +0700 | [diff] [blame] | 165 | /* Optional TRXC connection to FakeTRX (BTS side) */ |
Vadim Yanitskiy | 44ff214 | 2019-01-12 07:04:58 +0700 | [diff] [blame] | 166 | port TRXC_CODEC_PT BTS_TRXC; |
| 167 | var integer g_bts_trxc_conn_id; |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 168 | |
| 169 | timer g_Tguard; |
| 170 | timer g_Tmeas_exp := 2.0; /* >= 103 SACCH multiframe ~ 500ms */ |
| 171 | |
| 172 | var ConnHdlrPars g_pars; |
| 173 | var uint8_t g_next_meas_res_nr := 0; |
Harald Welte | fa45e9e | 2018-03-10 18:59:03 +0100 | [diff] [blame] | 174 | var boolean g_first_meas_res := true; |
Harald Welte | f26de0b | 2018-04-04 20:28:05 +0200 | [diff] [blame] | 175 | |
| 176 | /* PCU Interface of BTS */ |
| 177 | port PCUIF_CODEC_PT PCU; |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 178 | } |
| 179 | |
| 180 | function f_init_rsl(charstring id) runs on test_CT { |
Vadim Yanitskiy | c9c9e29 | 2020-05-18 23:31:40 +0700 | [diff] [blame] | 181 | timer T := mp_ipa_up_timeout; |
| 182 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 183 | vc_IPA := IPA_Emulation_CT.create(id & "-RSL-IPA"); |
| 184 | vc_RSL := RSL_Emulation_CT.create(id & "-RSL"); |
| 185 | |
| 186 | map(vc_IPA:IPA_PORT, system:IPA_CODEC_PT); |
| 187 | connect(vc_IPA:IPA_RSL_PORT, vc_RSL:IPA_PT); |
| 188 | connect(self:RSL_CCHAN, vc_RSL:CCHAN_PT); |
| 189 | |
| 190 | vc_IPA.start(IPA_Emulation.main_server(mp_rsl_ip, mp_rsl_port)); |
| 191 | vc_RSL.start(RSL_Emulation.main(false)); |
Vadim Yanitskiy | c9c9e29 | 2020-05-18 23:31:40 +0700 | [diff] [blame] | 192 | |
| 193 | T.start; |
| 194 | alt { |
Vadim Yanitskiy | 6de2fcb | 2020-05-25 19:40:45 +0700 | [diff] [blame] | 195 | /* TODO: handle connection events from multiple transceivers */ |
| 196 | [] RSL_CCHAN.receive(tr_RSLEm_EV(RSLEM_EV_TRX_UP)); |
Vadim Yanitskiy | c9c9e29 | 2020-05-18 23:31:40 +0700 | [diff] [blame] | 197 | [] T.timeout { |
| 198 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for ASP_IPA_EVENT_UP"); |
| 199 | } |
| 200 | } |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 201 | } |
| 202 | |
| 203 | type record ConnHdlrPars { |
| 204 | RslChannelNr chan_nr, |
| 205 | RSL_IE_ChannelMode chan_mode, |
| 206 | float t_guard, |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 207 | ConnL1Pars l1_pars, |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 208 | TestSpecUnion spec optional, |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 209 | RSL_IE_EncryptionInfo encr optional, |
| 210 | BtsBand bts0_band optional |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 211 | } |
| 212 | |
| 213 | /* Test-specific parameters */ |
| 214 | type union TestSpecUnion { |
| 215 | RllTestCase rll |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 216 | } |
| 217 | |
Harald Welte | 82ccef7 | 2018-02-25 16:17:33 +0100 | [diff] [blame] | 218 | template (value) RachControlParameters ts_RachCtrl_default := { |
Harald Welte | 0fd1fb0 | 2018-03-10 17:19:50 +0100 | [diff] [blame] | 219 | max_retrans := RACH_MAX_RETRANS_7, |
| 220 | tx_integer := '1001'B, /* 12 slots */ |
Harald Welte | 82ccef7 | 2018-02-25 16:17:33 +0100 | [diff] [blame] | 221 | cell_barr_access := false, |
| 222 | re_not_allowed := true, |
Harald Welte | b9585f8 | 2018-03-10 17:18:47 +0100 | [diff] [blame] | 223 | acc := '0000010000000000'B |
Harald Welte | 82ccef7 | 2018-02-25 16:17:33 +0100 | [diff] [blame] | 224 | }; |
| 225 | |
Harald Welte | f10153f | 2018-02-25 16:34:05 +0100 | [diff] [blame] | 226 | template (value) CellSelectionParameters ts_CellSelPar_default := { |
Harald Welte | 0fd1fb0 | 2018-03-10 17:19:50 +0100 | [diff] [blame] | 227 | cell_resel_hyst_2dB := 2, |
Pau Espin Pedrol | ed359cb | 2018-09-28 16:08:24 +0200 | [diff] [blame] | 228 | ms_txpwr_max_cch := mp_ms_power_level_exp, |
Harald Welte | f10153f | 2018-02-25 16:34:05 +0100 | [diff] [blame] | 229 | acs := '0'B, |
| 230 | neci := true, |
| 231 | rxlev_access_min := 0 |
| 232 | } |
| 233 | |
| 234 | template (value) LocationAreaIdentification ts_LAI_default := { |
| 235 | mcc_mnc := '262F42'H, |
| 236 | lac := 42 |
| 237 | } |
| 238 | |
Vadim Yanitskiy | 12cf3d9 | 2020-05-05 00:19:50 +0700 | [diff] [blame] | 239 | private template (value) GPRSIndicator ts_GPRSIndicator_def := { |
| 240 | ra_colour := 0, |
| 241 | si13_pos := '0'B |
| 242 | } |
| 243 | |
| 244 | private template (value) SI3RestOctets ts_SI3RestOctets_def |
| 245 | modifies ts_SI3RestOctets := { |
| 246 | gprs_ind := { |
| 247 | presence := CSN1_H, |
| 248 | ind := ts_GPRSIndicator_def |
| 249 | } |
| 250 | } |
| 251 | |
| 252 | private template (value) SI4RestOctets ts_SI4RestOctets_def |
| 253 | modifies ts_SI4RestOctets := { |
| 254 | gprs_ind := { |
Vadim Yanitskiy | ab5363f | 2020-05-05 00:30:22 +0700 | [diff] [blame] | 255 | presence := CSN1_H, |
| 256 | ind := ts_GPRSIndicator_def |
Vadim Yanitskiy | 12cf3d9 | 2020-05-05 00:19:50 +0700 | [diff] [blame] | 257 | } |
| 258 | } |
| 259 | |
Harald Welte | 7484fc4 | 2018-02-24 14:09:45 +0100 | [diff] [blame] | 260 | /* Default SYSTEM INFORMATION 3 */ |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 261 | template (value) SystemInformation ts_SI3_default := { |
| 262 | header := ts_RrHeader(SYSTEM_INFORMATION_TYPE_3, 18), |
Harald Welte | 7484fc4 | 2018-02-24 14:09:45 +0100 | [diff] [blame] | 263 | payload := { |
| 264 | si3 := { |
| 265 | cell_id := 23, |
Harald Welte | f10153f | 2018-02-25 16:34:05 +0100 | [diff] [blame] | 266 | lai := ts_LAI_default, |
Harald Welte | 7484fc4 | 2018-02-24 14:09:45 +0100 | [diff] [blame] | 267 | ctrl_chan_desc := { |
| 268 | msc_r99 := true, |
| 269 | att := true, |
| 270 | bs_ag_blks_res := 1, |
| 271 | ccch_conf := CCHAN_DESC_1CCCH_COMBINED, |
Harald Welte | 82ccef7 | 2018-02-25 16:17:33 +0100 | [diff] [blame] | 272 | si22ind := false, |
Harald Welte | 7484fc4 | 2018-02-24 14:09:45 +0100 | [diff] [blame] | 273 | cbq3 := CBQ3_IU_MODE_NOT_SUPPORTED, |
| 274 | spare := '00'B, |
| 275 | bs_pa_mfrms := 0, /* 2 multiframes */ |
| 276 | t3212 := 1 /* 6 minutes */ |
| 277 | }, |
Harald Welte | 82ccef7 | 2018-02-25 16:17:33 +0100 | [diff] [blame] | 278 | cell_options := { |
Harald Welte | 7484fc4 | 2018-02-24 14:09:45 +0100 | [diff] [blame] | 279 | dn_ind := false, |
| 280 | pwrc := false, |
| 281 | dtx := MS_MAY_USE_UL_DTX, |
Harald Welte | 0fd1fb0 | 2018-03-10 17:19:50 +0100 | [diff] [blame] | 282 | radio_link_tout_div4 := (32/4)-1 |
Harald Welte | 7484fc4 | 2018-02-24 14:09:45 +0100 | [diff] [blame] | 283 | }, |
Harald Welte | f10153f | 2018-02-25 16:34:05 +0100 | [diff] [blame] | 284 | cell_sel_par := ts_CellSelPar_default, |
Harald Welte | 82ccef7 | 2018-02-25 16:17:33 +0100 | [diff] [blame] | 285 | rach_control := ts_RachCtrl_default, |
Vadim Yanitskiy | 12cf3d9 | 2020-05-05 00:19:50 +0700 | [diff] [blame] | 286 | rest_octets := enc_SI3RestOctets(valueof(ts_SI3RestOctets_def)) |
Harald Welte | 7484fc4 | 2018-02-24 14:09:45 +0100 | [diff] [blame] | 287 | } |
| 288 | } |
| 289 | } |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 290 | |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 291 | template (value) SystemInformation ts_SI2_default := { |
| 292 | header := ts_RrHeader(SYSTEM_INFORMATION_TYPE_2, 22), |
Harald Welte | f10153f | 2018-02-25 16:34:05 +0100 | [diff] [blame] | 293 | payload := { |
| 294 | si2 := { |
| 295 | bcch_freq_list := '00000000000000000000000000000000'O, |
| 296 | ncc_permitted := '11111111'B, |
| 297 | rach_control := ts_RachCtrl_default |
| 298 | } |
| 299 | } |
| 300 | } |
| 301 | |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 302 | template (value) SystemInformation ts_SI4_default := { |
| 303 | header := ts_RrHeader(SYSTEM_INFORMATION_TYPE_4, 12), /* no CBCH / restoct */ |
Harald Welte | f10153f | 2018-02-25 16:34:05 +0100 | [diff] [blame] | 304 | payload := { |
| 305 | si4 := { |
| 306 | lai := ts_LAI_default, |
| 307 | cell_sel_par := ts_CellSelPar_default, |
| 308 | rach_control := ts_RachCtrl_default, |
| 309 | cbch_chan_desc := omit, |
| 310 | cbch_mobile_alloc := omit, |
Vadim Yanitskiy | 12cf3d9 | 2020-05-05 00:19:50 +0700 | [diff] [blame] | 311 | rest_octets := enc_SI4RestOctets(valueof(ts_SI4RestOctets_def)) |
Harald Welte | f10153f | 2018-02-25 16:34:05 +0100 | [diff] [blame] | 312 | } |
| 313 | } |
| 314 | } |
| 315 | |
| 316 | function f_rsl_bcch_fill_raw(RSL_IE_SysinfoType rsl_si_type, octetstring si_enc) |
| 317 | runs on test_CT { |
| 318 | log("Setting ", rsl_si_type, ": ", si_enc); |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 319 | RSL_CCHAN.send(ts_ASP_RSL_UD(ts_RSL_BCCH_INFO(rsl_si_type, si_enc))); |
Harald Welte | f10153f | 2018-02-25 16:34:05 +0100 | [diff] [blame] | 320 | } |
| 321 | |
| 322 | function f_rsl_bcch_fill(RSL_IE_SysinfoType rsl_si_type, template (value) SystemInformation si_dec) |
| 323 | runs on test_CT { |
| 324 | var octetstring si_enc := enc_SystemInformation(valueof(si_dec)); |
| 325 | log("Setting ", rsl_si_type, ": ", si_dec); |
| 326 | f_rsl_bcch_fill_raw(rsl_si_type, si_enc); |
| 327 | } |
| 328 | |
Harald Welte | 505cf9b | 2018-09-15 17:47:23 +0300 | [diff] [blame] | 329 | friend function f_init_vty(charstring id) runs on test_CT { |
Harald Welte | 8da4824 | 2018-02-27 20:41:32 +0100 | [diff] [blame] | 330 | map(self:BTSVTY, system:BTSVTY); |
| 331 | f_vty_set_prompts(BTSVTY); |
| 332 | f_vty_transceive(BTSVTY, "enable"); |
| 333 | } |
| 334 | |
Harald Welte | 505cf9b | 2018-09-15 17:47:23 +0300 | [diff] [blame] | 335 | friend function f_init_vty_bsc() runs on test_CT { |
Harald Welte | f50e3ae | 2018-09-10 10:27:56 +0200 | [diff] [blame] | 336 | map(self:BSCVTY, system:BSCVTY); |
| 337 | f_vty_set_prompts(BSCVTY, "OsmoBSC"); |
| 338 | f_vty_transceive(BSCVTY, "enable"); |
| 339 | } |
| 340 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 341 | /* PCU socket may at any time receive a new INFO.ind */ |
Harald Welte | f26de0b | 2018-04-04 20:28:05 +0200 | [diff] [blame] | 342 | private altstep as_pcu_info_ind(PCUIF_CODEC_PT pt, integer pcu_conn_id, |
| 343 | out PCUIF_Message pcu_last_info) { |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 344 | var PCUIF_send_data sd; |
Harald Welte | f26de0b | 2018-04-04 20:28:05 +0200 | [diff] [blame] | 345 | [] pt.receive(t_SD_PCUIF(pcu_conn_id, tr_PCUIF_INFO_IND(0, ?))) -> value sd { |
| 346 | pcu_last_info := sd.data; |
Harald Welte | d378a25 | 2018-03-13 17:02:14 +0100 | [diff] [blame] | 347 | } |
Harald Welte | f26de0b | 2018-04-04 20:28:05 +0200 | [diff] [blame] | 348 | [] 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] | 349 | 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] | 350 | } |
| 351 | } |
| 352 | |
Harald Welte | f26de0b | 2018-04-04 20:28:05 +0200 | [diff] [blame] | 353 | private function f_init_pcu(PCUIF_CODEC_PT pt, charstring id, |
| 354 | out integer pcu_conn_id, out PCUIF_Message pcu_last_info) { |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 355 | timer T := 2.0; |
| 356 | var PCUIF_send_data sd; |
Harald Welte | 8427162 | 2018-03-10 17:21:03 +0100 | [diff] [blame] | 357 | if (mp_pcu_socket == "") { |
Harald Welte | f26de0b | 2018-04-04 20:28:05 +0200 | [diff] [blame] | 358 | pcu_conn_id := -1; |
Harald Welte | 8427162 | 2018-03-10 17:21:03 +0100 | [diff] [blame] | 359 | return; |
| 360 | } |
Harald Welte | f26de0b | 2018-04-04 20:28:05 +0200 | [diff] [blame] | 361 | pcu_conn_id := f_pcuif_connect(pt, mp_pcu_socket); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 362 | |
| 363 | T.start; |
| 364 | alt { |
Harald Welte | f26de0b | 2018-04-04 20:28:05 +0200 | [diff] [blame] | 365 | [] as_pcu_info_ind(pt, pcu_conn_id, pcu_last_info); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 366 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 367 | 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] | 368 | } |
| 369 | } |
| 370 | } |
| 371 | |
Vadim Yanitskiy | f4e997c | 2019-06-04 21:40:33 +0700 | [diff] [blame] | 372 | private function f_init_trxc(TRXC_CODEC_PT pt, charstring id, |
| 373 | out integer trxc_conn_id) { |
| 374 | var Result res; |
| 375 | |
| 376 | res := TRXC_CodecPort_CtrlFunct.f_IPL4_connect(pt, mp_bts_trxc_ip, mp_bts_trxc_port, |
| 377 | "", -1, -1, { udp := {} }, {}); |
| 378 | if (not ispresent(res.connId)) { |
| 379 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 380 | "Could not connect to the control (TRXC) interface " & |
| 381 | "of FakeTRX, check your configuration"); |
| 382 | } |
| 383 | trxc_conn_id := res.connId; |
| 384 | } |
| 385 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 386 | /* global init function */ |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 387 | function f_init() runs on test_CT { |
| 388 | var charstring id := testcasename(); |
Harald Welte | 629cc6b | 2018-03-11 17:19:05 +0100 | [diff] [blame] | 389 | g_AllChannels := { |
| 390 | /* TS 1..4: TCH/F */ |
| 391 | valueof(ts_RslChanNr_Bm(1)), valueof(ts_RslChanNr_Bm(2)), |
| 392 | valueof(ts_RslChanNr_Bm(3)), valueof(ts_RslChanNr_Bm(4)), |
| 393 | /* TS 5: TCH/H */ |
| 394 | valueof(ts_RslChanNr_Lm(5,0)), valueof(ts_RslChanNr_Lm(5,1)), |
| 395 | /* TS 0: SDCCH/4 */ |
| 396 | valueof(ts_RslChanNr_SDCCH4(0,0)), valueof(ts_RslChanNr_SDCCH4(0,1)), |
| 397 | valueof(ts_RslChanNr_SDCCH4(0,2)), valueof(ts_RslChanNr_SDCCH4(0,3)), |
| 398 | /* TS 6: SDCCH/8 */ |
| 399 | valueof(ts_RslChanNr_SDCCH8(6,0)), valueof(ts_RslChanNr_SDCCH8(6,1)), |
| 400 | valueof(ts_RslChanNr_SDCCH8(6,2)), valueof(ts_RslChanNr_SDCCH8(6,3)), |
| 401 | valueof(ts_RslChanNr_SDCCH8(6,4)), valueof(ts_RslChanNr_SDCCH8(6,5)), |
| 402 | valueof(ts_RslChanNr_SDCCH8(6,6)), valueof(ts_RslChanNr_SDCCH8(6,7)) |
| 403 | }; |
| 404 | |
Pau Espin Pedrol | 3dcf38f | 2018-10-22 14:07:54 +0200 | [diff] [blame] | 405 | /* FIXME: FACCH/H is unreliable with calypso firmware, see OS#3653 */ |
Vadim Yanitskiy | 44ff214 | 2019-01-12 07:04:58 +0700 | [diff] [blame] | 406 | if (mp_bts_trxc_port != -1) { |
Pau Espin Pedrol | 3dcf38f | 2018-10-22 14:07:54 +0200 | [diff] [blame] | 407 | g_AllChanTypes := { |
| 408 | /* TS 1..4: TCH/F */ |
| 409 | valueof(ts_RslChanNr_Bm(1)), |
| 410 | /* TS 5: TCH/H */ |
| 411 | valueof(ts_RslChanNr_Lm(5,1)), |
| 412 | /* TS 0: SDCCH/4 */ |
| 413 | valueof(ts_RslChanNr_SDCCH4(0,2)), |
| 414 | /* TS 6: SDCCH/8 */ |
| 415 | valueof(ts_RslChanNr_SDCCH8(6,4)) |
| 416 | }; |
| 417 | } else { |
| 418 | g_AllChanTypes := { |
| 419 | /* TS 1..4: TCH/F */ |
| 420 | valueof(ts_RslChanNr_Bm(1)), |
| 421 | /* TS 0: SDCCH/4 */ |
| 422 | valueof(ts_RslChanNr_SDCCH4(0,2)), |
| 423 | /* TS 6: SDCCH/8 */ |
| 424 | valueof(ts_RslChanNr_SDCCH8(6,4)) |
| 425 | }; |
| 426 | } |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 427 | f_init_rsl(id); |
Harald Welte | 2d14259 | 2018-02-25 13:19:44 +0100 | [diff] [blame] | 428 | f_sleep(0.5); /* workaround for OS#3000 */ |
Harald Welte | 8da4824 | 2018-02-27 20:41:32 +0100 | [diff] [blame] | 429 | f_init_vty(id); |
Neels Hofmeyr | 6a84b23 | 2018-04-03 19:12:36 +0200 | [diff] [blame] | 430 | f_ipa_ctrl_start(mp_ctrl_ip, mp_ctrl_port); |
Harald Welte | 7484fc4 | 2018-02-24 14:09:45 +0100 | [diff] [blame] | 431 | |
| 432 | /* Send SI3 to the BTS, it is needed for various computations */ |
Harald Welte | f10153f | 2018-02-25 16:34:05 +0100 | [diff] [blame] | 433 | f_rsl_bcch_fill(RSL_SYSTEM_INFO_3, ts_SI3_default); |
| 434 | /* SI2 + SI4 are required for SI testing as they are mandatory defaults */ |
| 435 | f_rsl_bcch_fill(RSL_SYSTEM_INFO_2, ts_SI2_default); |
| 436 | f_rsl_bcch_fill(RSL_SYSTEM_INFO_4, ts_SI4_default); |
Harald Welte | 57fe823 | 2018-02-26 17:52:50 +0100 | [diff] [blame] | 437 | |
Harald Welte | f26de0b | 2018-04-04 20:28:05 +0200 | [diff] [blame] | 438 | map(self:PCU, system:PCU); |
| 439 | 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] | 440 | |
Vadim Yanitskiy | 44ff214 | 2019-01-12 07:04:58 +0700 | [diff] [blame] | 441 | if (mp_bts_trxc_port != -1) { |
Harald Welte | 8427162 | 2018-03-10 17:21:03 +0100 | [diff] [blame] | 442 | var TrxcMessage ret; |
Vadim Yanitskiy | f4e997c | 2019-06-04 21:40:33 +0700 | [diff] [blame] | 443 | |
| 444 | /* Init TRXC interface to FakeTRX */ |
| 445 | map(self:BTS_TRXC, system:BTS_TRXC); |
| 446 | f_init_trxc(BTS_TRXC, id, g_bts_trxc_conn_id); |
| 447 | |
Vadim Yanitskiy | 10d7246 | 2019-06-04 22:27:52 +0700 | [diff] [blame] | 448 | /* 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] | 449 | 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] | 450 | 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] | 451 | /* OsmoBTS may have different AB / NB threshold (see MIN_QUAL_NORM, MIN_QUAL_RACH) */ |
| 452 | 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] | 453 | } |
Philipp Maier | d95f340 | 2019-04-18 17:50:52 +0200 | [diff] [blame] | 454 | |
| 455 | /* Wait some extra time to make sure the BTS emits a stable carrier. |
| 456 | * (this is only relevant when running the tests with a physical BTS.) */ |
| 457 | f_sleep(mp_ipa_up_delay); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 458 | } |
| 459 | |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 460 | /* Attach L1CTL to master test_CT (classic tests, non-handler mode) */ |
| 461 | function f_init_l1ctl() runs on test_CT { |
| 462 | map(self:L1CTL, system:L1CTL); |
| 463 | f_connect_reset(L1CTL); |
| 464 | } |
| 465 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 466 | type function void_fn(charstring id) runs on ConnHdlr; |
| 467 | |
| 468 | /* create a new test component */ |
Vadim Yanitskiy | f4e997c | 2019-06-04 21:40:33 +0700 | [diff] [blame] | 469 | function f_start_handler(void_fn fn, ConnHdlrPars pars, |
| 470 | boolean pcu_comp := false, |
| 471 | boolean trxc_comp := false) |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 472 | runs on test_CT return ConnHdlr { |
| 473 | var charstring id := testcasename(); |
| 474 | var ConnHdlr vc_conn; |
| 475 | |
| 476 | vc_conn := ConnHdlr.create(id); |
| 477 | /* connect to RSL Emulation main component */ |
| 478 | connect(vc_conn:RSL, vc_RSL:CLIENT_PT); |
| 479 | connect(vc_conn:RSL_PROC, vc_RSL:RSL_PROC); |
Vadim Yanitskiy | f4e997c | 2019-06-04 21:40:33 +0700 | [diff] [blame] | 480 | |
| 481 | /* The ConnHdlr component may want to talk to some ports directly, |
| 482 | * so we disconnect it from the test_CT and connect it to the component. |
| 483 | * This obviously only works for one component, i.e. no concurrency. */ |
Harald Welte | f26de0b | 2018-04-04 20:28:05 +0200 | [diff] [blame] | 484 | if (pcu_comp) { |
Harald Welte | f26de0b | 2018-04-04 20:28:05 +0200 | [diff] [blame] | 485 | unmap(self:PCU, system:PCU); |
| 486 | map(vc_conn:PCU, system:PCU); |
| 487 | } |
Vadim Yanitskiy | f4e997c | 2019-06-04 21:40:33 +0700 | [diff] [blame] | 488 | if (trxc_comp) { |
| 489 | unmap(self:BTS_TRXC, system:BTS_TRXC); |
| 490 | map(vc_conn:BTS_TRXC, system:BTS_TRXC); |
| 491 | } |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 492 | |
| 493 | vc_conn.start(f_handler_init(fn, id, pars)); |
| 494 | return vc_conn; |
| 495 | } |
| 496 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 497 | private altstep as_Tguard() runs on ConnHdlr { |
| 498 | [] g_Tguard.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 499 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Tguard timeout"); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 500 | } |
| 501 | } |
| 502 | |
Harald Welte | 990a361 | 2019-05-27 14:02:13 +0200 | [diff] [blame] | 503 | friend function f_l1_tune(L1CTL_PT L1CTL, L1ctlCcchMode ccch_mode := CCCH_MODE_COMBINED) { |
| 504 | 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] | 505 | } |
| 506 | |
Vadim Yanitskiy | 2f01fbd | 2019-06-01 01:32:48 +0700 | [diff] [blame] | 507 | private function f_trxc_fake_rssi(TRXC_RSSI rssi) runs on ConnHdlr { |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 508 | var TrxcMessage ret; |
Vadim Yanitskiy | 44ff214 | 2019-01-12 07:04:58 +0700 | [diff] [blame] | 509 | 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] | 510 | } |
| 511 | |
Vadim Yanitskiy | dc8db92 | 2019-06-04 21:58:15 +0700 | [diff] [blame] | 512 | private function f_trxc_fake_toffs256(int16_t toffs256) runs on ConnHdlr { |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 513 | var TrxcMessage ret; |
Vadim Yanitskiy | 44ff214 | 2019-01-12 07:04:58 +0700 | [diff] [blame] | 514 | 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] | 515 | } |
| 516 | |
| 517 | /* first function started in ConnHdlr component */ |
| 518 | private function f_handler_init(void_fn fn, charstring id, ConnHdlrPars pars) |
| 519 | runs on ConnHdlr { |
| 520 | g_pars := pars; |
| 521 | g_chan_nr := pars.chan_nr; |
| 522 | |
| 523 | map(self:L1CTL, system:L1CTL); |
| 524 | f_connect_reset(L1CTL); |
| 525 | |
Harald Welte | d48c0c7 | 2019-06-05 10:01:15 +0200 | [diff] [blame] | 526 | if (mp_bts_trxc_port != -1 and BTS_TRXC.checkstate("Mapped")) { |
Vadim Yanitskiy | f4e997c | 2019-06-04 21:40:33 +0700 | [diff] [blame] | 527 | f_init_trxc(BTS_TRXC, id, g_bts_trxc_conn_id); |
Harald Welte | 8427162 | 2018-03-10 17:21:03 +0100 | [diff] [blame] | 528 | } |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 529 | |
| 530 | g_Tguard.start(pars.t_guard); |
| 531 | activate(as_Tguard()); |
| 532 | |
| 533 | f_rslem_register(0, pars.chan_nr); |
| 534 | |
| 535 | /* call the user-supplied test case function */ |
| 536 | fn.apply(id); |
| 537 | } |
| 538 | |
Harald Welte | b1726c9 | 2018-03-30 11:56:38 +0200 | [diff] [blame] | 539 | function f_rsl_transceive_ret(template RSL_Message tx, template RSL_Message exp_rx, charstring id, |
| 540 | boolean ignore_other := false) |
| 541 | runs on ConnHdlr return RSL_Message { |
| 542 | var RSL_Message rx; |
Harald Welte | 1eba374 | 2018-02-25 12:48:14 +0100 | [diff] [blame] | 543 | timer T := 3.0; |
| 544 | RSL.send(tx); |
| 545 | T.start; |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 546 | alt { |
Harald Welte | b1726c9 | 2018-03-30 11:56:38 +0200 | [diff] [blame] | 547 | [] RSL.receive(exp_rx) -> value rx { |
Harald Welte | 1eba374 | 2018-02-25 12:48:14 +0100 | [diff] [blame] | 548 | T.stop; |
| 549 | setverdict(pass); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 550 | } |
Harald Welte | 1eba374 | 2018-02-25 12:48:14 +0100 | [diff] [blame] | 551 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 552 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout expecting " & id); |
Harald Welte | 1eba374 | 2018-02-25 12:48:14 +0100 | [diff] [blame] | 553 | } |
Harald Welte | 21240e6 | 2018-03-11 21:43:35 +0100 | [diff] [blame] | 554 | [not ignore_other] as_l1_sacch(); |
| 555 | [not ignore_other] as_meas_res(); |
| 556 | [not ignore_other] as_l1_dcch(); |
| 557 | [not ignore_other] RSL.receive { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 558 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected RSL message received"); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 559 | } |
Harald Welte | 21240e6 | 2018-03-11 21:43:35 +0100 | [diff] [blame] | 560 | [ignore_other] RSL.receive { repeat; } |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 561 | } |
Harald Welte | b1726c9 | 2018-03-30 11:56:38 +0200 | [diff] [blame] | 562 | return rx; |
| 563 | } |
| 564 | |
| 565 | function f_rsl_transceive(template RSL_Message tx, template RSL_Message exp_rx, charstring id, |
| 566 | boolean ignore_other := false) |
| 567 | runs on ConnHdlr { |
| 568 | 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] | 569 | } |
| 570 | |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 571 | function f_rsl_chan_act(RSL_IE_ChannelMode mode, boolean encr_enable := false, RSL_IE_List more_ies := {}, |
| 572 | RSL_IE_ActivationType act_type := t_RSL_IE_ActType_IA) runs on ConnHdlr { |
| 573 | 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] | 574 | if (encr_enable) { |
| 575 | /* append encryption related IEs, if requested */ |
| 576 | var RSL_IE_EncryptionInfo encr_info; |
| 577 | encr_info := valueof(ts_RSL_IE_EncrInfo(g_pars.encr.alg_id, g_pars.encr.key)); |
| 578 | ch_act.ies := ch_act.ies & { valueof(t_RSL_IE(RSL_IE_ENCR_INFO, RSL_IE_Body:{encr_info := |
| 579 | encr_info})) }; |
| 580 | } |
Harald Welte | c8d363c | 2019-05-19 20:36:48 +0200 | [diff] [blame] | 581 | ch_act.ies := ch_act.ies & more_ies; |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 582 | 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] | 583 | } |
| 584 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 585 | function f_rsl_chan_deact() runs on ConnHdlr { |
Harald Welte | 1eba374 | 2018-02-25 12:48:14 +0100 | [diff] [blame] | 586 | 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] | 587 | "RF CHAN REL", true); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 588 | } |
| 589 | |
Harald Welte | 2f2b2b7 | 2019-05-31 22:24:57 +0200 | [diff] [blame] | 590 | friend template ConnHdlrPars t_Pars(template RslChannelNr chan_nr, |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 591 | template RSL_IE_ChannelMode chan_mode, |
| 592 | float t_guard := 20.0) := { |
| 593 | chan_nr := valueof(chan_nr), |
| 594 | chan_mode := valueof(chan_mode), |
| 595 | t_guard := t_guard, |
| 596 | l1_pars := { |
| 597 | dtx_enabled := false, |
Harald Welte | 685d598 | 2018-02-27 20:42:05 +0100 | [diff] [blame] | 598 | toa256_enabled := false, |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 599 | meas_ul := { |
| 600 | full := { |
Pau Espin Pedrol | e9571aa | 2018-10-22 17:13:07 +0200 | [diff] [blame] | 601 | rxlev := mp_ul_rxlev_exp, |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 602 | rxqual := 0 |
| 603 | }, |
| 604 | sub := { |
Pau Espin Pedrol | e9571aa | 2018-10-22 17:13:07 +0200 | [diff] [blame] | 605 | rxlev := mp_ul_rxlev_exp, |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 606 | rxqual := 0 |
| 607 | } |
| 608 | }, |
Pau Espin Pedrol | 121724c | 2018-09-28 15:58:12 +0200 | [diff] [blame] | 609 | timing_offset_256syms := mp_timing_offset_256syms_exp, |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 610 | bs_power_level := 0, |
Pau Espin Pedrol | ed359cb | 2018-09-28 16:08:24 +0200 | [diff] [blame] | 611 | ms_power_level := mp_ms_power_level_exp, |
Pau Espin Pedrol | 121724c | 2018-09-28 15:58:12 +0200 | [diff] [blame] | 612 | ms_actual_ta := mp_ms_actual_ta_exp |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 613 | }, |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 614 | spec := omit, |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 615 | encr := omit, |
| 616 | bts0_band := omit |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 617 | } |
| 618 | |
Harald Welte | 93640c6 | 2018-02-25 16:59:33 +0100 | [diff] [blame] | 619 | /*********************************************************************** |
| 620 | * Channel Activation / Deactivation |
| 621 | ***********************************************************************/ |
| 622 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 623 | /* Stress test: Do 500 channel activations/deactivations in rapid succession */ |
| 624 | function f_TC_chan_act_stress(charstring id) runs on ConnHdlr { |
| 625 | for (var integer i := 0; i < 500; i := i+1) { |
| 626 | f_rsl_chan_act(g_pars.chan_mode); |
| 627 | f_rsl_chan_deact(); |
| 628 | } |
| 629 | setverdict(pass); |
| 630 | } |
| 631 | testcase TC_chan_act_stress() runs on test_CT { |
| 632 | var ConnHdlr vc_conn; |
| 633 | 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] | 634 | f_init(); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 635 | vc_conn := f_start_handler(refers(f_TC_chan_act_stress), pars); |
| 636 | vc_conn.done; |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 637 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 638 | } |
| 639 | |
| 640 | /* Test if re-activation of an already active channel fails as expected */ |
| 641 | function f_TC_chan_act_react(charstring id) runs on ConnHdlr { |
| 642 | f_rsl_chan_act(g_pars.chan_mode); |
| 643 | /* attempt to activate the same lchan again -> expect reject */ |
| 644 | RSL.send(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode)); |
| 645 | alt { |
| 646 | [] RSL.receive(tr_RSL_CHAN_ACT_ACK(g_chan_nr)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 647 | 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] | 648 | } |
| 649 | [] RSL.receive(tr_RSL_CHAN_ACT_NACK(g_chan_nr)) { |
| 650 | setverdict(pass); |
| 651 | } |
| 652 | } |
| 653 | f_rsl_chan_deact(); |
| 654 | } |
| 655 | testcase TC_chan_act_react() runs on test_CT { |
| 656 | var ConnHdlr vc_conn; |
| 657 | 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] | 658 | f_init(); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 659 | vc_conn := f_start_handler(refers(f_TC_chan_act_react), pars); |
| 660 | vc_conn.done; |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 661 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 662 | } |
| 663 | |
| 664 | /* Attempt to de-activate a channel that's not active */ |
| 665 | function f_TC_chan_deact_not_active(charstring id) runs on ConnHdlr { |
| 666 | timer T := 3.0; |
| 667 | RSL.send(ts_RSL_RF_CHAN_REL(g_chan_nr)); |
| 668 | T.start; |
| 669 | alt { |
| 670 | [] RSL.receive(tr_RSL_RF_CHAN_REL_ACK(g_chan_nr)) { |
| 671 | setverdict(pass); |
| 672 | } |
| 673 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 674 | 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] | 675 | } |
| 676 | } |
| 677 | } |
| 678 | testcase TC_chan_deact_not_active() runs on test_CT { |
| 679 | 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] | 680 | f_init(); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 681 | var ConnHdlr vc_conn := f_start_handler(refers(f_TC_chan_deact_not_active), pars); |
| 682 | vc_conn.done; |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 683 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 684 | } |
| 685 | |
| 686 | /* attempt to activate channel with wrong RSL Channel Nr IE; expect NACK */ |
| 687 | function f_TC_chan_act_wrong_nr(charstring id) runs on ConnHdlr { |
| 688 | RSL.send(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode)); |
| 689 | alt { |
| 690 | [] RSL.receive(tr_RSL_CHAN_ACT_ACK(g_chan_nr)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 691 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected CHAN ACT ACK"); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 692 | } |
| 693 | [] RSL.receive(tr_RSL_CHAN_ACT_NACK(g_chan_nr)) { |
| 694 | setverdict(pass); |
| 695 | } |
| 696 | } |
| 697 | } |
| 698 | private type record WrongChanNrCase { |
| 699 | RslChannelNr chan_nr, |
| 700 | charstring description |
| 701 | } |
| 702 | private type record of WrongChanNrCase WrongChanNrCases; |
| 703 | private template WrongChanNrCase t_WCN(template RslChannelNr chan_nr, charstring desc) := { |
| 704 | chan_nr := chan_nr, |
| 705 | description := desc |
| 706 | } |
| 707 | |
| 708 | testcase TC_chan_act_wrong_nr() runs on test_CT { |
| 709 | var ConnHdlr vc_conn; |
| 710 | var ConnHdlrPars pars; |
| 711 | |
Harald Welte | 294b0a2 | 2018-03-10 23:26:48 +0100 | [diff] [blame] | 712 | f_init(); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 713 | |
| 714 | var WrongChanNrCases wrong := { |
| 715 | valueof(t_WCN(t_RslChanNr_RACH(0), "RACH is not a dedicated channel")), |
| 716 | valueof(t_WCN(t_RslChanNr_RACH(1), "RACH doesn't exist on timeslot")), |
| 717 | valueof(t_WCN(t_RslChanNr_BCCH(0), "BCCH is not a dedicated channel")), |
| 718 | valueof(t_WCN(t_RslChanNr_PCH_AGCH(0), "PCH/AGCH is not a dedicated channel")), |
| 719 | valueof(t_WCN(t_RslChanNr_Bm(0), "TS0 cannot be TCH/F")), |
| 720 | valueof(t_WCN(t_RslChanNr_Lm(0, 0), "TS0 cannot be TCH/H")), |
| 721 | valueof(t_WCN(t_RslChanNr_Lm(0, 1), "TS0 cannot be TCH/H")), |
| 722 | valueof(t_WCN(t_RslChanNr_PDCH(0), "TS0 cannot be PDCH")), |
| 723 | valueof(t_WCN(t_RslChanNr_SDCCH8(0, 0), "TS0 cannot be SDCCH/8")), |
| 724 | valueof(t_WCN(t_RslChanNr_SDCCH8(0, 7), "TS0 cannot be SDCCH/8")), |
| 725 | valueof(t_WCN(t_RslChanNr_SDCCH4(7, 0), "TS7 cannot be SDCCH/4")), |
| 726 | valueof(t_WCN(t_RslChanNr_SDCCH4(7, 3), "TS7 cannot be SDCCH/4")), |
| 727 | valueof(t_WCN(t_RslChanNr_Lm(1, 0), "TS1 cannot be TCH/H")) |
| 728 | }; |
| 729 | |
| 730 | for (var integer i := 0; i < sizeof(wrong); i := i+1) { |
| 731 | pars := valueof(t_Pars(wrong[i].chan_nr, ts_RSL_ChanMode_SIGN)); |
| 732 | vc_conn := f_start_handler(refers(f_TC_chan_act_wrong_nr), pars); |
| 733 | vc_conn.done; |
| 734 | } |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 735 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 736 | } |
| 737 | |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 738 | /* execute the same callback function on a variety of logical channels */ |
Harald Welte | 2f2b2b7 | 2019-05-31 22:24:57 +0200 | [diff] [blame] | 739 | 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] | 740 | var ConnHdlr vc_conn; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 741 | f_init(); |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 742 | |
| 743 | /* test on each of the channels we have */ |
| 744 | for (var integer i := 0; i < sizeof(g_AllChanTypes); i := i+1) { |
| 745 | pars.chan_nr := valueof(g_AllChanTypes[i]); |
| 746 | |
| 747 | log(testcasename(), ": XXX Starting on ", g_AllChanTypes[i]); |
| 748 | vc_conn := f_start_handler(fn, pars); |
| 749 | vc_conn.done; |
| 750 | } |
| 751 | |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 752 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 753 | } |
| 754 | |
Harald Welte | 93640c6 | 2018-02-25 16:59:33 +0100 | [diff] [blame] | 755 | /*********************************************************************** |
Harald Welte | 629cc6b | 2018-03-11 17:19:05 +0100 | [diff] [blame] | 756 | * SACCH handling |
| 757 | ***********************************************************************/ |
| 758 | |
| 759 | private function f_exp_sacch(boolean exp) runs on ConnHdlr { |
| 760 | timer T_sacch := 3.0; |
| 761 | T_sacch.start; |
| 762 | alt { |
| 763 | [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] | 764 | 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] | 765 | } |
| 766 | [not exp] T_sacch.timeout { |
| 767 | setverdict(pass); |
| 768 | } |
| 769 | [exp] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(0))) { |
| 770 | setverdict(pass); |
| 771 | } |
| 772 | [exp] T_sacch.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 773 | 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] | 774 | } |
| 775 | [] L1CTL.receive { repeat; } |
| 776 | [] RSL.receive { repeat; } |
| 777 | } |
| 778 | } |
| 779 | |
| 780 | /* Test if DEACTIVATE SACCH actualy deactivates its transmission (TS 48.058 4.6) */ |
| 781 | private function f_TC_deact_sacch(charstring id) runs on ConnHdlr { |
| 782 | f_l1_tune(L1CTL); |
| 783 | RSL.clear; |
| 784 | |
| 785 | /* activate the logical channel */ |
| 786 | f_est_dchan(); |
| 787 | L1CTL.clear; |
| 788 | |
| 789 | /* check that SACCH actually are received as expected */ |
| 790 | f_exp_sacch(true); |
| 791 | |
| 792 | /* deactivate SACCH on the logical channel */ |
| 793 | RSL.send(ts_RSL_DEACT_SACCH(g_chan_nr)); |
| 794 | f_sleep(1.0); |
| 795 | L1CTL.clear; |
| 796 | |
| 797 | /* check that no SACCH are received anymore */ |
| 798 | f_exp_sacch(false); |
| 799 | |
| 800 | /* release the channel */ |
| 801 | f_rsl_chan_deact(); |
| 802 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 803 | } |
| 804 | testcase TC_deact_sacch() runs on test_CT { |
| 805 | var ConnHdlr vc_conn; |
| 806 | var ConnHdlrPars pars; |
| 807 | f_init(); |
| 808 | for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) { |
| 809 | //for (var integer i := 0; i < 1; i := i+1) { |
| 810 | pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN)); |
| 811 | log(testcasename(), ": Starting for ", g_AllChannels[i]); |
| 812 | vc_conn := f_start_handler(refers(f_TC_deact_sacch), pars); |
| 813 | vc_conn.done; |
| 814 | } |
| 815 | /* TODO: do the above in parallel, rather than sequentially? */ |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 816 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 629cc6b | 2018-03-11 17:19:05 +0100 | [diff] [blame] | 817 | } |
| 818 | |
Harald Welte | 5570066 | 2018-03-12 13:15:43 +0100 | [diff] [blame] | 819 | /* verify that given SACCH payload is present */ |
Harald Welte | ea17b91 | 2018-03-11 22:29:31 +0100 | [diff] [blame] | 820 | private function f_sacch_present(template octetstring l3_exp) runs on ConnHdlr { |
| 821 | var L1ctlDlMessage dl; |
| 822 | /* check that the specified SI5 value is actually sent */ |
| 823 | timer T_sacch := 3.0; |
| 824 | L1CTL.clear; |
| 825 | T_sacch.start; |
| 826 | alt { |
| 827 | [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(0))) -> value dl { |
| 828 | var octetstring l3 := substr(dl.payload.data_ind.payload, 4, 19); |
| 829 | if (match(l3, l3_exp)) { |
| 830 | setverdict(pass); |
| 831 | } else { |
| 832 | repeat; |
| 833 | } |
| 834 | } |
| 835 | [] L1CTL.receive { repeat; } |
| 836 | [] T_sacch.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 837 | 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] | 838 | } |
| 839 | } |
| 840 | } |
| 841 | |
Harald Welte | 5570066 | 2018-03-12 13:15:43 +0100 | [diff] [blame] | 842 | /* verify that given SACCH payload is not present */ |
| 843 | private function f_sacch_missing(template octetstring l3_exp) runs on ConnHdlr { |
| 844 | var L1ctlDlMessage dl; |
| 845 | /* check that the specified SI5 value is actually sent */ |
| 846 | timer T_sacch := 3.0; |
| 847 | L1CTL.clear; |
| 848 | T_sacch.start; |
| 849 | alt { |
| 850 | [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(0))) -> value dl { |
| 851 | var octetstring l3 := substr(dl.payload.data_ind.payload, 4, 19); |
| 852 | if (match(l3, l3_exp)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 853 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Received unexpected SACCH ", dl)); |
Harald Welte | 5570066 | 2018-03-12 13:15:43 +0100 | [diff] [blame] | 854 | } else { |
| 855 | repeat; |
| 856 | } |
| 857 | } |
| 858 | [] L1CTL.receive { repeat; } |
| 859 | [] T_sacch.timeout { |
| 860 | setverdict(pass); |
| 861 | } |
| 862 | } |
| 863 | } |
| 864 | |
Harald Welte | 629cc6b | 2018-03-11 17:19:05 +0100 | [diff] [blame] | 865 | /* Test for default SACCH FILL transmitted in DL SACCH (all channel types) */ |
Harald Welte | ea17b91 | 2018-03-11 22:29:31 +0100 | [diff] [blame] | 866 | private function f_TC_sacch_filling(charstring id) runs on ConnHdlr { |
| 867 | /* Set a known default SACCH filling for SI5 */ |
| 868 | var octetstring si5 := f_rnd_octstring(19); |
| 869 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5)); |
| 870 | |
| 871 | f_l1_tune(L1CTL); |
| 872 | RSL.clear; |
| 873 | |
| 874 | /* activate the logical channel */ |
| 875 | f_est_dchan(); |
| 876 | |
| 877 | /* check that the specified SI5 value is actually sent */ |
| 878 | f_sacch_present(si5); |
| 879 | |
| 880 | /* release the channel */ |
| 881 | RSL.clear; |
| 882 | f_rsl_chan_deact(); |
| 883 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 884 | } |
| 885 | testcase TC_sacch_filling() runs on test_CT { |
| 886 | var ConnHdlr vc_conn; |
| 887 | var ConnHdlrPars pars; |
| 888 | f_init(); |
| 889 | for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) { |
| 890 | pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN)); |
| 891 | log(testcasename(), ": Starting for ", g_AllChannels[i]); |
| 892 | vc_conn := f_start_handler(refers(f_TC_sacch_filling), pars); |
| 893 | vc_conn.done; |
| 894 | } |
| 895 | /* TODO: do the above in parallel, rather than sequentially? */ |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 896 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | ea17b91 | 2018-03-11 22:29:31 +0100 | [diff] [blame] | 897 | } |
| 898 | |
Harald Welte | 629cc6b | 2018-03-11 17:19:05 +0100 | [diff] [blame] | 899 | /* Test for lchan-specific SACCH INFO MODIFY (TS 48.058 4.12) */ |
Harald Welte | ea17b91 | 2018-03-11 22:29:31 +0100 | [diff] [blame] | 900 | private function f_TC_sacch_info_mod(charstring id) runs on ConnHdlr { |
| 901 | /* Set a known default SACCH filling for SI5 */ |
| 902 | var octetstring si5 := f_rnd_octstring(19); |
| 903 | var octetstring si5_diff := f_rnd_octstring(19); |
| 904 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5)); |
| 905 | |
| 906 | f_l1_tune(L1CTL); |
| 907 | RSL.clear; |
| 908 | |
| 909 | log("Activating channel, expecting standard SI5"); |
| 910 | /* activate the logical channel */ |
| 911 | f_est_dchan(); |
| 912 | /* check that the specified SI5 value is actually sent */ |
| 913 | f_sacch_present(si5); |
| 914 | |
| 915 | /* set channel-specific different SI5 */ |
| 916 | log("Setting channel specific SACCH INFO, expecting it"); |
| 917 | RSL.send(ts_RSL_SACCH_INF_MOD(g_chan_nr, RSL_SYSTEM_INFO_5, si5_diff)) |
| 918 | /* check that the specified lchan-specific value is now used */ |
| 919 | f_sacch_present(si5_diff); |
| 920 | |
| 921 | /* deactivate the channel and re-activate it, this should result in default SI5 */ |
| 922 | log("De-activating and re-activating channel, expecting standard SI5"); |
| 923 | f_rsl_chan_deact(); |
| 924 | f_rsl_chan_act(valueof(ts_RSL_ChanMode_SIGN)); |
| 925 | /* Verify that the TRX-wide default SACCH filling is present again */ |
| 926 | f_sacch_present(si5); |
| 927 | |
| 928 | /* release the channel */ |
| 929 | RSL.clear; |
| 930 | f_rsl_chan_deact(); |
| 931 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 932 | } |
| 933 | testcase TC_sacch_info_mod() runs on test_CT { |
| 934 | var ConnHdlr vc_conn; |
| 935 | var ConnHdlrPars pars; |
| 936 | f_init(); |
| 937 | for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) { |
| 938 | pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN)); |
| 939 | log(testcasename(), ": Starting for ", g_AllChannels[i]); |
| 940 | vc_conn := f_start_handler(refers(f_TC_sacch_info_mod), pars); |
| 941 | vc_conn.done; |
| 942 | } |
| 943 | /* TODO: do the above in parallel, rather than sequentially? */ |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 944 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | ea17b91 | 2018-03-11 22:29:31 +0100 | [diff] [blame] | 945 | } |
| 946 | |
Harald Welte | 075d84c | 2018-03-12 13:07:24 +0100 | [diff] [blame] | 947 | /* Test SACCH scheduling of multiple different SI message types */ |
| 948 | private function f_TC_sacch_multi(charstring id) runs on ConnHdlr { |
| 949 | var octetstring si5 := f_rnd_octstring(19); |
| 950 | var octetstring si5bis := f_rnd_octstring(19); |
| 951 | var octetstring si5ter := f_rnd_octstring(19); |
| 952 | var octetstring si6 := f_rnd_octstring(19); |
| 953 | |
| 954 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5)); |
| 955 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5bis, si5bis)); |
| 956 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5ter, si5ter)); |
| 957 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_6, si6)); |
| 958 | |
| 959 | f_l1_tune(L1CTL); |
| 960 | RSL.clear; |
| 961 | |
| 962 | /* activate the logical channel */ |
| 963 | f_est_dchan(); |
| 964 | L1CTL.clear; |
| 965 | |
| 966 | /* check that SACCH actually are received as expected */ |
| 967 | f_sacch_present(si5); |
| 968 | f_sacch_present(si5bis); |
| 969 | f_sacch_present(si5ter); |
| 970 | f_sacch_present(si6); |
| 971 | |
| 972 | /* release the channel */ |
| 973 | f_rsl_chan_deact(); |
| 974 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 975 | } |
| 976 | testcase TC_sacch_multi() runs on test_CT { |
| 977 | var ConnHdlr vc_conn; |
| 978 | var ConnHdlrPars pars; |
| 979 | f_init(); |
| 980 | for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) { |
| 981 | pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN)); |
| 982 | log(testcasename(), ": Starting for ", g_AllChannels[i]); |
| 983 | vc_conn := f_start_handler(refers(f_TC_sacch_multi), pars); |
| 984 | vc_conn.done; |
| 985 | } |
| 986 | /* TODO: do the above in parallel, rather than sequentially? */ |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 987 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 075d84c | 2018-03-12 13:07:24 +0100 | [diff] [blame] | 988 | } |
| 989 | |
Harald Welte | 5570066 | 2018-03-12 13:15:43 +0100 | [diff] [blame] | 990 | /* Test if SACH information is modified as expected */ |
| 991 | private function f_TC_sacch_multi_chg(charstring id) runs on ConnHdlr { |
| 992 | var octetstring si5 := f_rnd_octstring(19); |
| 993 | var octetstring si6 := f_rnd_octstring(19); |
| 994 | |
| 995 | /* First, configure both SI5 and SI6 to be transmitted */ |
| 996 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5)); |
| 997 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_6, si6)); |
| 998 | |
| 999 | f_l1_tune(L1CTL); |
| 1000 | RSL.clear; |
| 1001 | |
| 1002 | /* activate the logical channel */ |
| 1003 | f_est_dchan(); |
| 1004 | L1CTL.clear; |
| 1005 | |
| 1006 | /* check that SACCH actually are received as expected */ |
| 1007 | f_sacch_present(si5); |
| 1008 | f_sacch_present(si6); |
| 1009 | |
| 1010 | /* disable SI6 */ |
| 1011 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_6, ''O)); |
| 1012 | |
| 1013 | /* check that SI5 is still transmitted */ |
| 1014 | f_sacch_present(si5); |
| 1015 | /* check if SI6 is now gone */ |
| 1016 | f_sacch_missing(si6); |
| 1017 | |
| 1018 | /* release the channel */ |
| 1019 | f_rsl_chan_deact(); |
| 1020 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 1021 | } |
| 1022 | testcase TC_sacch_multi_chg() runs on test_CT { |
| 1023 | var ConnHdlr vc_conn; |
| 1024 | var ConnHdlrPars pars; |
| 1025 | f_init(); |
| 1026 | for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) { |
| 1027 | pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN)); |
| 1028 | log(testcasename(), ": Starting for ", g_AllChannels[i]); |
| 1029 | vc_conn := f_start_handler(refers(f_TC_sacch_multi_chg), pars); |
| 1030 | vc_conn.done; |
| 1031 | } |
| 1032 | /* TODO: do the above in parallel, rather than sequentially? */ |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1033 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 5570066 | 2018-03-12 13:15:43 +0100 | [diff] [blame] | 1034 | } |
| 1035 | |
Harald Welte | c8d363c | 2019-05-19 20:36:48 +0200 | [diff] [blame] | 1036 | /* Test for SACCH information present in RSL CHAN ACT (overrides FILLING) */ |
| 1037 | private function f_TC_sacch_chan_act(charstring id) runs on ConnHdlr { |
| 1038 | var octetstring si5 := f_rnd_octstring(19); |
| 1039 | var octetstring si6 := f_rnd_octstring(19); |
| 1040 | var octetstring si5_specific := f_rnd_octstring(19); |
| 1041 | var octetstring si6_specific := f_rnd_octstring(19); |
| 1042 | |
| 1043 | /* First, configure both SI5 and SI6 to be transmitted */ |
| 1044 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, si5)); |
| 1045 | RSL.send(ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_6, si6)); |
| 1046 | |
| 1047 | f_l1_tune(L1CTL); |
| 1048 | RSL.clear; |
| 1049 | |
| 1050 | /* activate channel with different SACCH filling */ |
| 1051 | var RSL_SacchInfo sacch_info := valueof(ts_RSL_SacchInfo({ |
| 1052 | ts_RSL_SacchInfoElem(RSL_SYSTEM_INFO_5, si5_specific), |
| 1053 | ts_RSL_SacchInfoElem(RSL_SYSTEM_INFO_6, si6_specific) |
| 1054 | })); |
| 1055 | var RSL_IE_List addl_ies := { valueof(t_RSL_IE(RSL_IE_SACCH_INFO, |
| 1056 | RSL_IE_Body:{sacch_info := sacch_info})) }; |
| 1057 | f_est_dchan(more_ies := addl_ies); |
| 1058 | |
| 1059 | /* check that SACCH actually are received as expected */ |
| 1060 | f_sacch_present(si5_specific); |
| 1061 | f_sacch_present(si6_specific); |
| 1062 | |
| 1063 | /* release the channel */ |
| 1064 | f_rsl_chan_deact(); |
| 1065 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 1066 | } |
| 1067 | testcase TC_sacch_chan_act() runs on test_CT { |
| 1068 | var ConnHdlr vc_conn; |
| 1069 | var ConnHdlrPars pars; |
| 1070 | f_init(); |
| 1071 | |
| 1072 | for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) { |
| 1073 | pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN)); |
| 1074 | log(testcasename(), ": Starting for ", g_AllChannels[i]); |
| 1075 | vc_conn := f_start_handler(refers(f_TC_sacch_chan_act), pars); |
| 1076 | vc_conn.done; |
| 1077 | } |
| 1078 | /* TODO: do the above in parallel, rather than sequentially? */ |
| 1079 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 1080 | } |
| 1081 | |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 1082 | /* verify that SACCH DL transmission is started only if MS power IE present |
| 1083 | * see section 4.1.3 of 3GPP TS 48.058 */ |
| 1084 | private function f_TC_sacch_chan_act_ho_async(charstring id) runs on ConnHdlr { |
| 1085 | var octetstring si5 := f_rnd_octstring(19); |
| 1086 | |
| 1087 | f_l1_tune(L1CTL); |
| 1088 | RSL.clear; |
| 1089 | |
| 1090 | /* Step 1: Activate ASYNC HO channel without MS power IE */ |
| 1091 | |
| 1092 | /* Activate channel on BTS side */ |
| 1093 | f_rsl_chan_act(g_pars.chan_mode, act_type := t_RSL_IE_ActType_HO_ASYNC); |
| 1094 | /* don't perform immediate assignment here, as we're testing non-IA case */ |
| 1095 | /* enable dedicated mode */ |
| 1096 | f_L1CTL_DM_EST_REQ(L1CTL, {false, mp_trx0_arfcn }, g_pars.chan_nr, 7); |
| 1097 | |
| 1098 | /* Verify that no DL SACCH is being received */ |
| 1099 | f_sacch_missing(?); |
| 1100 | |
| 1101 | f_rsl_chan_deact(); |
| 1102 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 1103 | |
| 1104 | |
| 1105 | /* Step 2: Activate ASYNC HO channel with MS power IE */ |
| 1106 | |
| 1107 | /* Activate channel on BTS side */ |
| 1108 | var RSL_IE_List addl_ies := { |
| 1109 | valueof(t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ts_RSL_IE_MS_Power(0)})) |
| 1110 | }; |
| 1111 | f_rsl_chan_act(g_pars.chan_mode, more_ies := addl_ies, act_type := t_RSL_IE_ActType_HO_ASYNC); |
| 1112 | /* don't perform immediate assignment here, as we're testing non-IA case */ |
| 1113 | /* enable dedicated mode */ |
| 1114 | f_L1CTL_DM_EST_REQ(L1CTL, {false, mp_trx0_arfcn }, g_pars.chan_nr, 7); |
| 1115 | |
| 1116 | /* Verify that DL SACCH is being received */ |
| 1117 | f_sacch_present(si5); |
| 1118 | |
| 1119 | f_rsl_chan_deact(); |
| 1120 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 1121 | } |
| 1122 | testcase TC_sacch_chan_act_ho_async() runs on test_CT { |
| 1123 | var ConnHdlr vc_conn; |
| 1124 | var ConnHdlrPars pars; |
| 1125 | f_init(); |
| 1126 | |
| 1127 | for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) { |
| 1128 | pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN)); |
| 1129 | log(testcasename(), ": Starting for ", g_AllChannels[i]); |
| 1130 | vc_conn := f_start_handler(refers(f_TC_sacch_chan_act_ho_async), pars); |
| 1131 | vc_conn.done; |
| 1132 | } |
| 1133 | /* TODO: do the above in parallel, rather than sequentially? */ |
| 1134 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 1135 | } |
| 1136 | |
| 1137 | /* verify that SACCH DL transmission is started only if TA + MS power IEs present, |
| 1138 | * see section 4.1.4 of 3GPP TS 48.058 */ |
| 1139 | private function f_TC_sacch_chan_act_ho_sync(charstring id) runs on ConnHdlr { |
| 1140 | var octetstring si5 := f_rnd_octstring(19); |
| 1141 | var RSL_IE_List addl_ies; |
| 1142 | |
| 1143 | f_l1_tune(L1CTL); |
| 1144 | RSL.clear; |
| 1145 | |
| 1146 | /* Step 1: Activate SYNC HO channel without MS power IE */ |
| 1147 | |
| 1148 | /* Activate channel on BTS side */ |
| 1149 | f_rsl_chan_act(g_pars.chan_mode, act_type := t_RSL_IE_ActType_HO_SYNC); |
| 1150 | /* don't perform immediate assignment here, as we're testing non-IA case */ |
| 1151 | /* enable dedicated mode */ |
| 1152 | f_L1CTL_DM_EST_REQ(L1CTL, {false, mp_trx0_arfcn }, g_pars.chan_nr, 7); |
| 1153 | |
| 1154 | /* Verify that no DL SACCH is being received */ |
| 1155 | f_sacch_missing(?); |
| 1156 | |
| 1157 | f_rsl_chan_deact(); |
| 1158 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 1159 | |
| 1160 | |
| 1161 | /* Step 2a: Activate SYNC HO channel with only MS power IE */ |
| 1162 | |
| 1163 | /* Activate channel on BTS side */ |
| 1164 | addl_ies := { |
| 1165 | valueof(t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ts_RSL_IE_MS_Power(0)})) |
| 1166 | }; |
| 1167 | f_rsl_chan_act(g_pars.chan_mode, more_ies := addl_ies, act_type := t_RSL_IE_ActType_HO_SYNC); |
| 1168 | /* don't perform immediate assignment here, as we're testing non-IA case */ |
| 1169 | /* enable dedicated mode */ |
| 1170 | f_L1CTL_DM_EST_REQ(L1CTL, {false, mp_trx0_arfcn }, g_pars.chan_nr, 7); |
| 1171 | |
| 1172 | /* Verify that no DL SACCH is being received */ |
| 1173 | f_sacch_missing(?); |
| 1174 | |
| 1175 | f_rsl_chan_deact(); |
| 1176 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 1177 | |
| 1178 | |
| 1179 | /* Step 2b: Activate SYNC HO channel with TA IE */ |
| 1180 | |
| 1181 | /* Activate channel on BTS side */ |
| 1182 | addl_ies := { |
| 1183 | valueof(t_RSL_IE(RSL_IE_TIMING_ADVANCE, RSL_IE_Body:{timing_adv := 0})) |
| 1184 | }; |
| 1185 | f_rsl_chan_act(g_pars.chan_mode, more_ies := addl_ies, act_type := t_RSL_IE_ActType_HO_SYNC); |
| 1186 | /* don't perform immediate assignment here, as we're testing non-IA case */ |
| 1187 | /* enable dedicated mode */ |
| 1188 | f_L1CTL_DM_EST_REQ(L1CTL, {false, mp_trx0_arfcn }, g_pars.chan_nr, 7); |
| 1189 | |
| 1190 | /* Verify that no DL SACCH is being received */ |
| 1191 | f_sacch_missing(?); |
| 1192 | |
| 1193 | f_rsl_chan_deact(); |
| 1194 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 1195 | |
| 1196 | |
| 1197 | /* Step 3: Activate SYNC HO channel with MS power IE and TA IE */ |
| 1198 | |
| 1199 | /* Activate channel on BTS side */ |
| 1200 | addl_ies := { |
| 1201 | valueof(t_RSL_IE(RSL_IE_TIMING_ADVANCE, RSL_IE_Body:{timing_adv := 0})), |
| 1202 | valueof(t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ts_RSL_IE_MS_Power(0)})) |
| 1203 | }; |
| 1204 | f_rsl_chan_act(g_pars.chan_mode, more_ies := addl_ies, act_type := t_RSL_IE_ActType_HO_SYNC); |
| 1205 | /* don't perform immediate assignment here, as we're testing non-IA case */ |
| 1206 | /* enable dedicated mode */ |
| 1207 | f_L1CTL_DM_EST_REQ(L1CTL, {false, mp_trx0_arfcn }, g_pars.chan_nr, 7); |
| 1208 | |
| 1209 | /* Verify that DL SACCH is being received */ |
| 1210 | f_sacch_present(si5); |
| 1211 | |
| 1212 | f_rsl_chan_deact(); |
| 1213 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 1214 | } |
| 1215 | testcase TC_sacch_chan_act_ho_sync() runs on test_CT { |
| 1216 | var ConnHdlr vc_conn; |
| 1217 | var ConnHdlrPars pars; |
| 1218 | f_init(); |
| 1219 | |
| 1220 | for (var integer i := 0; i < sizeof(g_AllChannels); i := i+1) { |
| 1221 | pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN)); |
| 1222 | log(testcasename(), ": Starting for ", g_AllChannels[i]); |
| 1223 | vc_conn := f_start_handler(refers(f_TC_sacch_chan_act_ho_sync), pars); |
| 1224 | vc_conn.done; |
| 1225 | } |
| 1226 | /* TODO: do the above in parallel, rather than sequentially? */ |
| 1227 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 1228 | } |
Harald Welte | 629cc6b | 2018-03-11 17:19:05 +0100 | [diff] [blame] | 1229 | |
| 1230 | |
| 1231 | /*********************************************************************** |
Harald Welte | 93640c6 | 2018-02-25 16:59:33 +0100 | [diff] [blame] | 1232 | * RACH Handling |
| 1233 | ***********************************************************************/ |
| 1234 | |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1235 | /* like L1SAP_IS_PACKET_RACH */ |
| 1236 | private function ra_is_ps(OCT1 ra) return boolean { |
Harald Welte | 56c0580 | 2018-02-28 21:39:35 +0100 | [diff] [blame] | 1237 | 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] | 1238 | return true; |
| 1239 | } |
| 1240 | return false; |
| 1241 | } |
| 1242 | |
| 1243 | /* generate a random RACH for circuit-switched */ |
| 1244 | private function f_rnd_ra_cs() return OCT1 { |
| 1245 | var OCT1 ra; |
| 1246 | do { |
| 1247 | ra := f_rnd_octstring(1); |
| 1248 | } while (ra_is_ps(ra)); |
| 1249 | return ra; |
| 1250 | } |
| 1251 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 1252 | /* generate a random RACH for packet-switched */ |
| 1253 | private function f_rnd_ra_ps() return OCT1 { |
| 1254 | var OCT1 ra; |
| 1255 | do { |
| 1256 | ra := f_rnd_octstring(1); |
| 1257 | } while (not ra_is_ps(ra)); |
| 1258 | return ra; |
| 1259 | } |
| 1260 | |
Vadim Yanitskiy | 51cbc10 | 2019-04-22 06:37:30 +0700 | [diff] [blame] | 1261 | /* generate a random 11-bit RA (packet-switched only) */ |
| 1262 | private function f_rnd_ra11_ps() return BIT11 { |
| 1263 | var integer ra11 := f_rnd_int(bit2int('11111111111'B)); |
| 1264 | return int2bit(ra11, 11); |
| 1265 | } |
| 1266 | |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1267 | /* Send 1000 RACH requests and check their RA+FN on the RSL side */ |
| 1268 | testcase TC_rach_content() runs on test_CT { |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 1269 | f_init(); |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1270 | f_init_l1ctl(); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 1271 | f_l1_tune(L1CTL); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1272 | |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1273 | var GsmFrameNumber fn_last := 0; |
Max | a199a2e | 2019-02-25 16:31:11 +0100 | [diff] [blame] | 1274 | var boolean test_failed := false; |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1275 | for (var integer i := 0; i < 1000; i := i+1) { |
| 1276 | var OCT1 ra := f_rnd_ra_cs(); |
| 1277 | var GsmFrameNumber fn := f_L1CTL_RACH(L1CTL, oct2int(ra)); |
| 1278 | if (fn == fn_last) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1279 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Two RACH in same FN?!?"); |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1280 | } |
| 1281 | fn_last := fn; |
| 1282 | |
| 1283 | timer T := 5.0; |
Harald Welte | 56c0580 | 2018-02-28 21:39:35 +0100 | [diff] [blame] | 1284 | T.start; |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1285 | alt { |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 1286 | [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_CHAN_RQD(ra, fn, t_RslChanNr_RACH(0)))) { |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1287 | T.stop; |
| 1288 | } |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 1289 | [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_CHAN_RQD(?, ?, ?, ?))) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1290 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected CHAN RQD"); |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1291 | } |
| 1292 | [] RSL_CCHAN.receive { repeat; } |
| 1293 | [] T.timeout { |
Max | a199a2e | 2019-02-25 16:31:11 +0100 | [diff] [blame] | 1294 | test_failed := true; |
| 1295 | log("[", i, "] Timeout waiting for CHAN RQD FN=", fn, " RA=", ra); |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1296 | } |
| 1297 | } |
| 1298 | } |
Max | ba06feb | 2019-03-05 10:52:46 +0100 | [diff] [blame] | 1299 | if (test_failed) { |
| 1300 | 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] | 1301 | } |
Max | ba06feb | 2019-03-05 10:52:46 +0100 | [diff] [blame] | 1302 | setverdict(pass); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1303 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1304 | } |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1305 | |
| 1306 | /* Send 1000 RACH Requests (flood ~ 89/s) and count if count(Abis) == count(Um) */ |
| 1307 | testcase TC_rach_count() runs on test_CT { |
Harald Welte | 294b0a2 | 2018-03-10 23:26:48 +0100 | [diff] [blame] | 1308 | f_init(); |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1309 | f_init_l1ctl(); |
Harald Welte | 294b0a2 | 2018-03-10 23:26:48 +0100 | [diff] [blame] | 1310 | f_sleep(1.0); |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1311 | f_l1_tune(L1CTL); |
| 1312 | |
| 1313 | var GsmFrameNumber fn_last := 0; |
| 1314 | for (var integer i := 0; i < 1000; i := i+1) { |
| 1315 | var OCT1 ra := f_rnd_ra_cs(); |
| 1316 | var GsmFrameNumber fn := f_L1CTL_RACH(L1CTL, oct2int(ra)); |
| 1317 | if (fn == fn_last) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1318 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Two RACH in same FN?!?"); |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1319 | } |
| 1320 | fn_last := fn; |
| 1321 | } |
| 1322 | var integer rsl_chrqd := 0; |
| 1323 | timer T := 3.0; |
Harald Welte | 56c0580 | 2018-02-28 21:39:35 +0100 | [diff] [blame] | 1324 | T.start; |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1325 | alt { |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 1326 | [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_CHAN_RQD(?,?))) { |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1327 | rsl_chrqd := rsl_chrqd + 1; |
Harald Welte | c3a3f45 | 2018-02-26 17:37:47 +0100 | [diff] [blame] | 1328 | f_timer_safe_restart(T); |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1329 | repeat; |
| 1330 | } |
| 1331 | [] RSL_CCHAN.receive { repeat; } |
| 1332 | [] T.timeout { } |
| 1333 | } |
| 1334 | if (rsl_chrqd == 1000) { |
| 1335 | setverdict(pass); |
| 1336 | } else { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1337 | 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] | 1338 | } |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1339 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1340 | } |
| 1341 | |
Harald Welte | 3453ab4 | 2019-05-24 21:19:58 +0200 | [diff] [blame] | 1342 | private function f_vty_load_ind_thresh(integer period := 10, integer bts_nr := 0) runs on test_CT { |
| 1343 | var charstring bts_str := "bts " & int2str(bts_nr); |
| 1344 | f_vty_config2(BSCVTY, {"network", bts_str}, "ccch load-indication-threshold " & int2str(period)); |
| 1345 | } |
| 1346 | |
| 1347 | /* empirical value: Number of RACH slots per reporting interval (1s) on combined CCCH */ |
| 1348 | private template integer tr_rach_slots_per_interval := (90 .. 130); |
| 1349 | |
| 1350 | /* Expect 0 RACH load on an idle BTS that has just started up */ |
| 1351 | testcase TC_rach_load_idle_thresh0() runs on test_CT { |
| 1352 | var ASP_RSL_Unitdata rx_ud; |
| 1353 | |
| 1354 | f_init_vty_bsc(); |
| 1355 | /* send load indications even at 0% load */ |
| 1356 | f_vty_load_ind_thresh(0); |
| 1357 | f_vty_transceive(BSCVTY, "drop bts connection 0 oml"); |
| 1358 | f_sleep(2.0); |
| 1359 | |
| 1360 | f_init(); |
| 1361 | |
| 1362 | timer T := 5.0; |
| 1363 | T.start; |
| 1364 | alt { |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 1365 | [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_RACH_LOAD_IND(tr_rach_slots_per_interval, 0, 0))) { |
Harald Welte | 3453ab4 | 2019-05-24 21:19:58 +0200 | [diff] [blame] | 1366 | setverdict(pass); |
| 1367 | repeat; |
| 1368 | } |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 1369 | [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_RACH_LOAD_IND(?, ?, ?))) -> value rx_ud { |
Harald Welte | 3453ab4 | 2019-05-24 21:19:58 +0200 | [diff] [blame] | 1370 | setverdict(fail, "Unexpected RACH LOAD IND: ", rx_ud); |
| 1371 | repeat; |
| 1372 | } |
| 1373 | [] RSL_CCHAN.receive { |
| 1374 | repeat; |
| 1375 | } |
| 1376 | [] T.timeout { } |
| 1377 | } |
| 1378 | |
| 1379 | f_vty_load_ind_thresh(10); |
| 1380 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 1381 | } |
| 1382 | |
| 1383 | /* Expect no RACH load indications on an idle BTS that has just started up (default threshold 10%) */ |
| 1384 | testcase TC_rach_load_idle_below_thresh() runs on test_CT { |
| 1385 | var ASP_RSL_Unitdata rx_ud; |
| 1386 | |
| 1387 | f_init_vty_bsc(); |
| 1388 | f_init(); |
| 1389 | |
| 1390 | timer T := 5.0; |
| 1391 | T.start; |
| 1392 | alt { |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 1393 | [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_RACH_LOAD_IND(?, ?, ?))) -> value rx_ud { |
Harald Welte | 3453ab4 | 2019-05-24 21:19:58 +0200 | [diff] [blame] | 1394 | setverdict(fail, "Unexpected RACH LOAD IND: ", rx_ud); |
| 1395 | repeat; |
| 1396 | } |
| 1397 | [] RSL_CCHAN.receive { |
| 1398 | repeat; |
| 1399 | } |
| 1400 | [] T.timeout { |
| 1401 | setverdict(pass); |
| 1402 | } |
| 1403 | } |
| 1404 | |
| 1405 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 1406 | } |
| 1407 | |
| 1408 | /* Expect 0 RACH load on an idle BTS that has just started up */ |
| 1409 | testcase TC_rach_load_count() runs on test_CT { |
| 1410 | var ASP_RSL_Unitdata rx_ud; |
| 1411 | var integer load_access_count := 0; |
| 1412 | |
| 1413 | f_init_vty_bsc(); |
| 1414 | /* send load indications even at 0% load */ |
| 1415 | f_vty_load_ind_thresh(0); |
| 1416 | f_vty_transceive(BSCVTY, "drop bts connection 0 oml"); |
| 1417 | f_sleep(2.0); |
| 1418 | f_init(); |
| 1419 | |
| 1420 | f_init_l1ctl(); |
| 1421 | f_sleep(1.0); |
| 1422 | f_l1_tune(L1CTL); |
| 1423 | |
| 1424 | var GsmFrameNumber fn_last := 0; |
| 1425 | for (var integer i := 0; i < 1000; i := i+1) { |
| 1426 | var OCT1 ra := f_rnd_ra_cs(); |
| 1427 | var GsmFrameNumber fn := f_L1CTL_RACH(L1CTL, oct2int(ra)); |
| 1428 | if (fn == fn_last) { |
| 1429 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Two RACH in same FN?!?"); |
| 1430 | } |
| 1431 | fn_last := fn; |
| 1432 | } |
| 1433 | |
| 1434 | timer T := 5.0; |
| 1435 | T.start; |
| 1436 | alt { |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 1437 | [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_RACH_LOAD_IND(tr_rach_slots_per_interval, ?, ?))) |
Harald Welte | 3453ab4 | 2019-05-24 21:19:58 +0200 | [diff] [blame] | 1438 | -> value rx_ud { |
| 1439 | var RSL_IE_Body ie; |
| 1440 | f_rsl_find_ie(rx_ud.rsl, RSL_IE_RACH_LOAD, ie); |
| 1441 | load_access_count := load_access_count + ie.rach_load.access_count; |
| 1442 | if (ie.rach_load.busy_count < ie.rach_load.access_count) { |
| 1443 | setverdict(fail, "Access count cannot be < Busy count"); |
| 1444 | } |
| 1445 | repeat; |
| 1446 | } |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 1447 | [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_RACH_LOAD_IND(?, ?, ?))) -> value rx_ud { |
Harald Welte | 3453ab4 | 2019-05-24 21:19:58 +0200 | [diff] [blame] | 1448 | setverdict(fail, "Unexpected RACH LOAD IND: ", rx_ud); |
| 1449 | repeat; |
| 1450 | } |
| 1451 | [] RSL_CCHAN.receive { |
| 1452 | repeat; |
| 1453 | } |
| 1454 | [] T.timeout { } |
| 1455 | } |
| 1456 | if (load_access_count == 1000) { |
| 1457 | setverdict(pass); |
| 1458 | } else { |
| 1459 | setverdict(fail, "Load reports state ", load_access_count, " RACH, but we sent 1000"); |
| 1460 | } |
| 1461 | |
| 1462 | f_vty_load_ind_thresh(10); |
| 1463 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 1464 | } |
| 1465 | |
Harald Welte | 54a2a2d | 2018-02-26 09:14:05 +0100 | [diff] [blame] | 1466 | 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] | 1467 | var TrxcMessage ret; |
Harald Welte | 54a2a2d | 2018-02-26 09:14:05 +0100 | [diff] [blame] | 1468 | /* tell fake_trx to use a given timing offset for all bursts */ |
Vadim Yanitskiy | 44ff214 | 2019-01-12 07:04:58 +0700 | [diff] [blame] | 1469 | 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] | 1470 | f_sleep(0.5); |
| 1471 | |
| 1472 | /* Transmit RACH request + wait for confirmation */ |
| 1473 | var OCT1 ra := f_rnd_ra_cs(); |
| 1474 | var GsmFrameNumber fn := f_L1CTL_RACH(L1CTL, oct2int(ra)); |
| 1475 | |
| 1476 | /* Check for expected result */ |
| 1477 | timer T := 1.5; |
| 1478 | T.start; |
| 1479 | alt { |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 1480 | [expect_pass] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_CHAN_RQD(ra, fn))) { |
Harald Welte | 54a2a2d | 2018-02-26 09:14:05 +0100 | [diff] [blame] | 1481 | setverdict(pass); |
| 1482 | } |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 1483 | [not expect_pass] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_CHAN_RQD(ra, fn))) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1484 | 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] | 1485 | } |
| 1486 | [] RSL_CCHAN.receive { repeat; } |
| 1487 | [not expect_pass] T.timeout { |
| 1488 | setverdict(pass); |
| 1489 | } |
| 1490 | [expect_pass] T.timeout { |
Max | 6e05304 | 2019-03-14 16:34:22 +0100 | [diff] [blame] | 1491 | 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] | 1492 | } |
| 1493 | } |
| 1494 | } |
| 1495 | |
| 1496 | /* Test if dropping of RACH Based on NM_ATT_MAX_TA works */ |
| 1497 | testcase TC_rach_max_ta() runs on test_CT { |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 1498 | f_init(); |
Harald Welte | 54a2a2d | 2018-02-26 09:14:05 +0100 | [diff] [blame] | 1499 | f_init_l1ctl(); |
| 1500 | f_l1_tune(L1CTL); |
Harald Welte | 54a2a2d | 2018-02-26 09:14:05 +0100 | [diff] [blame] | 1501 | f_sleep(1.0); |
| 1502 | |
| 1503 | /* default max-ta is 63 (full range of GSM timing advance */ |
| 1504 | |
Vadim Yanitskiy | c81d6e4 | 2018-03-05 22:39:01 +0700 | [diff] [blame] | 1505 | /* We allow early arrival up to 2 symbols */ |
| 1506 | f_rach_toffs(-1*256, true); |
| 1507 | f_rach_toffs(-2*256, true); |
Harald Welte | 54a2a2d | 2018-02-26 09:14:05 +0100 | [diff] [blame] | 1508 | f_rach_toffs(-10*256, false); |
| 1509 | |
| 1510 | /* 0 / 32 / 63 bits is legal / permitted */ |
| 1511 | f_rach_toffs(0, true); |
| 1512 | f_rach_toffs(32*256, true); |
| 1513 | f_rach_toffs(63*256, true); |
| 1514 | |
| 1515 | /* more than 63 bits is not legal / permitted */ |
| 1516 | f_rach_toffs(64*256, false); |
| 1517 | f_rach_toffs(127*256, false); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1518 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 54a2a2d | 2018-02-26 09:14:05 +0100 | [diff] [blame] | 1519 | } |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 1520 | |
Vadim Yanitskiy | 7c2c10c | 2019-05-31 20:42:01 +0700 | [diff] [blame] | 1521 | function f_TC_ho_rach(charstring id) runs on ConnHdlr { |
| 1522 | var GsmFrameNumber fn; |
| 1523 | var RSL_Message rm; |
| 1524 | |
| 1525 | f_l1_tune(L1CTL); |
| 1526 | RSL.clear; |
| 1527 | |
| 1528 | /* Generate a random Handover Reference */ |
| 1529 | var integer ho_ref := oct2int(f_rnd_octstring(1)); |
| 1530 | |
| 1531 | /* Handover Reference IE (see 3GPP TS 48.058, 9.3.9) */ |
| 1532 | var RSL_IE ho_ref_ie := valueof(t_RSL_IE(RSL_IE_HANDO_REF, |
| 1533 | RSL_IE_Body:{ handover_ref := ho_ref })); |
| 1534 | |
| 1535 | /* Activate a channel on the BTS side (no encryption) */ |
| 1536 | f_rsl_chan_act(g_pars.chan_mode, more_ies := { ho_ref_ie }, |
| 1537 | act_type := t_RSL_IE_ActType_HO_SYNC); |
| 1538 | |
| 1539 | /* Switch the MS side (e.g. trxcon) to a dedicated channel without |
| 1540 | * waiting for Immediate Assignment and sending Access Burst */ |
| 1541 | f_L1CTL_DM_EST_REQ(L1CTL, { false, mp_trx0_arfcn }, g_pars.chan_nr, 7); |
| 1542 | |
| 1543 | /* Send handover Access Burst */ |
| 1544 | fn := f_L1CTL_RACH(L1CTL, ho_ref, chan_nr := g_pars.chan_nr); |
| 1545 | |
| 1546 | /* TODO: test mismatching Handover Reference, and missing IE */ |
| 1547 | |
| 1548 | /* Wait for handover detection */ |
| 1549 | timer T := 3.0; |
| 1550 | T.start; |
| 1551 | alt { |
| 1552 | [] RSL.receive(tr_RSL_HANDO_DET(g_pars.chan_nr)) -> value rm { |
| 1553 | log("Handover RACH has been detected: ", rm); |
| 1554 | setverdict(pass); |
| 1555 | } |
| 1556 | [] RSL.receive(tr_RSL_CHAN_RQD(?, ?, ?, ?)) -> value rm { |
| 1557 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 1558 | log2str("RSL_CHAN_RQD was not expected: ", rm)); |
| 1559 | } |
| 1560 | [] RSL.receive { repeat; } |
| 1561 | [] T.timeout { |
| 1562 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 1563 | log2str("Timeout waiting for handover RACH: FN=", fn, " RA=", ho_ref)); |
| 1564 | } |
| 1565 | } |
| 1566 | |
| 1567 | /* Release the channel */ |
| 1568 | f_rsl_chan_deact(); |
| 1569 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 1570 | } |
| 1571 | |
| 1572 | /* Test handover RACH detection */ |
| 1573 | testcase TC_ho_rach() runs on test_CT { |
| 1574 | var ConnHdlrPars pars; |
| 1575 | var ConnHdlr vc_conn; |
| 1576 | |
| 1577 | f_init(); |
| 1578 | |
| 1579 | for (var integer i := 0; i < sizeof(g_AllChannels); i := i + 1) { |
| 1580 | pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN)); |
| 1581 | log(testcasename(), ": Starting for ", g_AllChannels[i]); |
| 1582 | vc_conn := f_start_handler(refers(f_TC_ho_rach), pars); |
| 1583 | vc_conn.done; |
| 1584 | } |
| 1585 | |
| 1586 | /* TODO: do the above in parallel, rather than sequentially? */ |
| 1587 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 1588 | } |
| 1589 | |
Harald Welte | 93640c6 | 2018-02-25 16:59:33 +0100 | [diff] [blame] | 1590 | /*********************************************************************** |
| 1591 | * Measurement Processing / Reporting |
| 1592 | ***********************************************************************/ |
| 1593 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1594 | template LapdmAddressField ts_LapdmAddr(LapdmSapi sapi, boolean c_r) := { |
| 1595 | spare := '0'B, |
| 1596 | lpd := 0, |
| 1597 | sapi := sapi, |
| 1598 | c_r := c_r, |
| 1599 | ea := true |
| 1600 | } |
| 1601 | |
Harald Welte | d879bd9 | 2018-03-12 15:01:23 +0100 | [diff] [blame] | 1602 | 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] | 1603 | addr := ts_LapdmAddr(sapi, c_r), |
Harald Welte | d879bd9 | 2018-03-12 15:01:23 +0100 | [diff] [blame] | 1604 | ctrl := ts_LapdmCtrlUI(p), |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1605 | len := 0, /* overwritten */ |
| 1606 | m := false, |
| 1607 | el := 1, |
| 1608 | payload := pl |
| 1609 | } |
| 1610 | |
| 1611 | /* handle incoming downlink SACCH and respond with uplink SACCH (meas res) */ |
| 1612 | altstep as_l1_sacch() runs on ConnHdlr { |
| 1613 | var L1ctlDlMessage l1_dl; |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 1614 | [] 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] | 1615 | log("SACCH received: ", l1_dl.payload.data_ind.payload); |
Pau Espin Pedrol | e9571aa | 2018-10-22 17:13:07 +0200 | [diff] [blame] | 1616 | 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] | 1617 | 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] | 1618 | log("LAPDm: ", lb); |
Pau Espin Pedrol | ed359cb | 2018-09-28 16:08:24 +0200 | [diff] [blame] | 1619 | |
Vadim Yanitskiy | 0a8d6da | 2019-05-28 22:18:28 +0700 | [diff] [blame] | 1620 | var template (value) SacchL1Header l1h := ts_SacchL1Header( |
| 1621 | g_pars.l1_pars.ms_power_level, false, |
| 1622 | g_pars.l1_pars.ms_actual_ta); |
| 1623 | |
| 1624 | /* TODO: we can use an extension of TTCN-3 for that, i.e. PADDING('2B'O) */ |
| 1625 | var octetstring l2 := f_pad_oct(enc_LapdmFrameAB(lb), 21, '2B'O); |
| 1626 | |
| 1627 | log("Sending Measurement Report: ", l1h, l2); |
| 1628 | 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] | 1629 | repeat; |
| 1630 | } |
| 1631 | } |
| 1632 | |
| 1633 | altstep as_l1_dcch() runs on ConnHdlr { |
| 1634 | var L1ctlDlMessage l1_dl; |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 1635 | [] 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] | 1636 | log("DCCH received: ", l1_dl.payload.data_ind.payload); |
| 1637 | var octetstring pl := '010301'O; |
Vadim Yanitskiy | 31e7c67 | 2018-07-27 02:23:16 +0700 | [diff] [blame] | 1638 | L1CTL.send(ts_L1CTL_DATA_REQ(g_chan_nr, ts_RslLinkID_DCCH(0), |
| 1639 | f_pad_oct(pl, 23, '2B'O))); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1640 | repeat; |
| 1641 | } |
| 1642 | } |
| 1643 | |
| 1644 | type record MeasElem { |
| 1645 | uint6_t rxlev, |
| 1646 | uint3_t rxqual |
| 1647 | } |
| 1648 | |
| 1649 | type record MeasElemFS { |
| 1650 | MeasElem full, |
| 1651 | MeasElem sub |
| 1652 | } |
| 1653 | |
| 1654 | type record ConnL1Pars { |
| 1655 | boolean dtx_enabled, |
Harald Welte | 685d598 | 2018-02-27 20:42:05 +0100 | [diff] [blame] | 1656 | boolean toa256_enabled, |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1657 | MeasElemFS meas_ul, |
| 1658 | int16_t timing_offset_256syms, |
| 1659 | uint5_t bs_power_level, |
| 1660 | uint5_t ms_power_level, |
| 1661 | uint8_t ms_actual_ta |
| 1662 | } |
| 1663 | |
| 1664 | /* Convert tiing offset from 1/256th symbol to RSL Timing Offset */ |
| 1665 | private function toffs256s_to_rsl(int16_t toffs256s) return uint8_t { |
| 1666 | return 63 + (toffs256s/256); |
| 1667 | } |
| 1668 | |
Harald Welte | d568439 | 2018-03-10 18:22:04 +0100 | [diff] [blame] | 1669 | private function f_max(integer a, integer b) return integer { |
| 1670 | if (a > b) { |
| 1671 | return a; |
| 1672 | } else { |
| 1673 | return b; |
| 1674 | } |
| 1675 | } |
| 1676 | |
| 1677 | private function f_min(integer a, integer b) return integer { |
| 1678 | if (a < b) { |
| 1679 | return a; |
| 1680 | } else { |
| 1681 | return b; |
| 1682 | } |
| 1683 | } |
| 1684 | |
| 1685 | /* compute negative tolerance val-tolerance, ensure >= min */ |
| 1686 | private function f_tolerance_neg(integer val, integer min, integer tolerance) return integer { |
| 1687 | val := val - tolerance; |
| 1688 | return f_max(val, min); |
| 1689 | } |
| 1690 | |
| 1691 | /* compute positive tolerance val+tolerance, ensure <= max */ |
| 1692 | private function f_tolerance_pos(integer val, integer max, integer tolerance) return integer { |
| 1693 | val := val + tolerance; |
| 1694 | return f_min(val, max); |
| 1695 | } |
| 1696 | |
| 1697 | /* return a template of (val-tolerance .. val+tolerance) ensuring it is within (min .. max) */ |
| 1698 | private function f_tolerance(integer val, integer min, integer max, integer tolerance) |
| 1699 | return template integer { |
| 1700 | var template integer ret; |
| 1701 | ret := (f_tolerance_neg(val, min, tolerance) .. f_tolerance_pos(val, max, tolerance)); |
| 1702 | return ret; |
| 1703 | } |
| 1704 | |
| 1705 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1706 | /* build a template for matching measurement results against */ |
| 1707 | private function f_build_meas_res_tmpl() runs on ConnHdlr return template RSL_Message { |
| 1708 | var ConnL1Pars l1p := g_pars.l1_pars; |
| 1709 | var template RSL_IE_UplinkMeas ul_meas := { |
| 1710 | len := 3, |
| 1711 | rfu := '0'B, |
| 1712 | dtx_d := l1p.dtx_enabled, |
Harald Welte | d568439 | 2018-03-10 18:22:04 +0100 | [diff] [blame] | 1713 | 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] | 1714 | reserved1 := '00'B, |
Harald Welte | d568439 | 2018-03-10 18:22:04 +0100 | [diff] [blame] | 1715 | 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] | 1716 | reserved2 := '00'B, |
Harald Welte | d568439 | 2018-03-10 18:22:04 +0100 | [diff] [blame] | 1717 | rxq_f_u := f_tolerance(l1p.meas_ul.full.rxqual, 0, 7, mp_tolerance_rxqual), |
| 1718 | 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] | 1719 | supp_meas_info := omit |
| 1720 | }; |
Harald Welte | 685d598 | 2018-02-27 20:42:05 +0100 | [diff] [blame] | 1721 | if (l1p.toa256_enabled) { |
Harald Welte | 15de8ba | 2018-06-29 08:51:42 +0200 | [diff] [blame] | 1722 | ul_meas.len := (3+8); |
| 1723 | ul_meas.supp_meas_info := { |
Pau Espin Pedrol | 121724c | 2018-09-28 15:58:12 +0200 | [diff] [blame] | 1724 | 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] | 1725 | toa256_min := ?, |
| 1726 | toa256_max := ?, |
| 1727 | toa256_std_dev := ? |
| 1728 | } |
Harald Welte | 685d598 | 2018-02-27 20:42:05 +0100 | [diff] [blame] | 1729 | } |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1730 | var template RSL_IE_BS_Power bs_power := { |
| 1731 | reserved := 0, |
| 1732 | epc := false, |
| 1733 | fpc := false, |
| 1734 | power_level := l1p.bs_power_level |
| 1735 | }; |
| 1736 | var template RSL_IE_L1Info l1_info := { |
| 1737 | ms_power_lvl := l1p.ms_power_level, |
| 1738 | fpc := false, |
| 1739 | reserved := 0, |
Pau Espin Pedrol | 121724c | 2018-09-28 15:58:12 +0200 | [diff] [blame] | 1740 | 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] | 1741 | }; |
| 1742 | var uint8_t offs := toffs256s_to_rsl(l1p.timing_offset_256syms); |
Pau Espin Pedrol | 121724c | 2018-09-28 15:58:12 +0200 | [diff] [blame] | 1743 | 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] | 1744 | return tr_RSL_MEAS_RES_OSMO(g_chan_nr, g_next_meas_res_nr, ul_meas, bs_power, l1_info, |
| 1745 | ?, t_toffs); |
| 1746 | } |
| 1747 | |
Philipp Maier | dd841d3 | 2019-12-17 14:44:54 +0100 | [diff] [blame] | 1748 | /* build a template for matching measurement results that do not contain any |
| 1749 | * MS related measurement (l1_info, l3_info and ms timing offset). */ |
| 1750 | private function f_build_meas_res_tmpl_empty() runs on ConnHdlr return template RSL_Message { |
| 1751 | var ConnL1Pars l1p := g_pars.l1_pars; |
| 1752 | var template RSL_IE_UplinkMeas ul_meas := { |
| 1753 | len := 3, |
| 1754 | rfu := '0'B, |
| 1755 | dtx_d := l1p.dtx_enabled, |
| 1756 | rxlev_f_u := ?, |
| 1757 | reserved1 := '00'B, |
| 1758 | rxlev_s_u := ?, |
| 1759 | reserved2 := '00'B, |
| 1760 | rxq_f_u := ?, |
| 1761 | rxq_s_u := ?, |
| 1762 | supp_meas_info := omit |
| 1763 | }; |
| 1764 | if (l1p.toa256_enabled) { |
| 1765 | ul_meas.len := (3+8); |
| 1766 | ul_meas.supp_meas_info := { |
| 1767 | toa256_mean := f_tolerance(l1p.timing_offset_256syms, -63*256, 192*256, mp_tolerance_timing_offset_256syms), |
| 1768 | toa256_min := ?, |
| 1769 | toa256_max := ?, |
| 1770 | toa256_std_dev := ? |
| 1771 | } |
| 1772 | } |
| 1773 | var template RSL_IE_BS_Power bs_power := { |
| 1774 | reserved := 0, |
| 1775 | epc := false, |
| 1776 | fpc := false, |
| 1777 | power_level := l1p.bs_power_level |
| 1778 | }; |
| 1779 | |
| 1780 | return tr_RSL_MEAS_RES_EMPTY(g_chan_nr, g_next_meas_res_nr, ul_meas, bs_power); |
| 1781 | } |
| 1782 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1783 | /* verify we regularly receive measurement reports with incrementing numbers */ |
Vadim Yanitskiy | 41baf00 | 2018-10-04 17:44:50 +0700 | [diff] [blame] | 1784 | altstep as_meas_res(boolean verify_meas := true) runs on ConnHdlr { |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1785 | var RSL_Message rsl; |
Philipp Maier | dd841d3 | 2019-12-17 14:44:54 +0100 | [diff] [blame] | 1786 | var boolean chan_est := false; |
| 1787 | |
Vadim Yanitskiy | 41baf00 | 2018-10-04 17:44:50 +0700 | [diff] [blame] | 1788 | [not verify_meas] RSL.receive(tr_RSL_MEAS_RES(?)) { repeat; } |
Philipp Maier | dd841d3 | 2019-12-17 14:44:54 +0100 | [diff] [blame] | 1789 | |
| 1790 | /* Receive osmocom specific measurement reports. This is the normal |
| 1791 | * case. Here we verify that the measurement reports we sent are |
| 1792 | * comming back as we expect them. */ |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1793 | [] RSL.receive(f_build_meas_res_tmpl()) -> value rsl { |
| 1794 | /* increment counter of next to-be-expected meas rep */ |
| 1795 | g_next_meas_res_nr := (g_next_meas_res_nr + 1) mod 256; |
| 1796 | /* Re-start the timer expecting the next MEAS RES */ |
Harald Welte | c3a3f45 | 2018-02-26 17:37:47 +0100 | [diff] [blame] | 1797 | f_timer_safe_restart(g_Tmeas_exp); |
Philipp Maier | dd841d3 | 2019-12-17 14:44:54 +0100 | [diff] [blame] | 1798 | |
| 1799 | /* The following two cases may only happen in the beginning |
| 1800 | * of the channel establishment phase. Once we have received |
| 1801 | * the "our" measurement report the first time, the channel |
| 1802 | * is established and empty or hardcoded TRXCON reports must |
| 1803 | * not occur anymore. */ |
| 1804 | chan_est := true; |
| 1805 | |
| 1806 | repeat; |
| 1807 | } |
| 1808 | |
| 1809 | /* When the BTS has established the channel, the MS might need slightly |
| 1810 | * more time to establish the channel and actually start sending. The |
| 1811 | * result is then a measurement report that just lacks the measurement |
| 1812 | * information of the MS. This is normal and we tolerate this behavior. */ |
| 1813 | [chan_est == false] RSL.receive(f_build_meas_res_tmpl_empty()) -> value rsl { |
| 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 | /* Re-start the timer expecting the next MEAS RES */ |
| 1817 | f_timer_safe_restart(g_Tmeas_exp); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1818 | repeat; |
| 1819 | } |
Philipp Maier | dd841d3 | 2019-12-17 14:44:54 +0100 | [diff] [blame] | 1820 | |
| 1821 | /* Due to the TDMA nature of GSM, TRXCON implements a way to emit dummy |
| 1822 | * measurements if the TTCN3 side does not supply measurement input in |
| 1823 | * time. In those cases TRXCON will either use a cached measurement |
| 1824 | * report or a hardcoded one. If TRXCON picks the hardcoded measurement |
| 1825 | * report the templates above will not match. We tolerate this |
| 1826 | * behavior, but only once. */ |
| 1827 | [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] | 1828 | /* increment counter of next to-be-expected meas rep */ |
| 1829 | g_next_meas_res_nr := (g_next_meas_res_nr + 1) mod 256; |
| 1830 | if (g_first_meas_res) { |
| 1831 | g_first_meas_res := false; |
| 1832 | repeat; |
| 1833 | } else { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1834 | 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] | 1835 | } |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1836 | } |
| 1837 | [] RSL.receive(tr_RSL_MEAS_RES(?)) -> value rsl { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1838 | 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] | 1839 | } |
Pau Espin Pedrol | 425b62f | 2018-07-06 16:11:43 +0200 | [diff] [blame] | 1840 | [g_Tmeas_exp.running] g_Tmeas_exp.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1841 | 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] | 1842 | } |
| 1843 | } |
| 1844 | |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 1845 | private function f_alg_id_to_l1ctl(RSL_AlgId rsl_alg_id) return uint8_t { |
| 1846 | select (rsl_alg_id) { |
| 1847 | case (RSL_ALG_ID_A5_0) { return 0; } |
| 1848 | case (RSL_ALG_ID_A5_1) { return 1; } |
| 1849 | case (RSL_ALG_ID_A5_2) { return 2; } |
| 1850 | case (RSL_ALG_ID_A5_3) { return 3; } |
| 1851 | case (RSL_ALG_ID_A5_4) { return 4; } |
| 1852 | case (RSL_ALG_ID_A5_5) { return 5; } |
| 1853 | case (RSL_ALG_ID_A5_6) { return 6; } |
| 1854 | case (RSL_ALG_ID_A5_7) { return 7; } |
| 1855 | case else { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1856 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unknwon Algorithm ID"); |
| 1857 | /* Make compiler happy by calling mtc.stop here. It is already |
| 1858 | * called in f_shutdown */ |
Daniel Willmann | 17ddd85 | 2018-07-05 17:33:20 +0200 | [diff] [blame] | 1859 | mtc.stop; |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 1860 | } |
| 1861 | } |
| 1862 | } |
| 1863 | |
| 1864 | private function f_alg_id_to_l3(RSL_AlgId rsl_alg_id) return BIT3 { |
| 1865 | select (rsl_alg_id) { |
| 1866 | case (RSL_ALG_ID_A5_1) { return '000'B; } |
| 1867 | case (RSL_ALG_ID_A5_2) { return '001'B; } |
| 1868 | case (RSL_ALG_ID_A5_3) { return '010'B; } |
| 1869 | case (RSL_ALG_ID_A5_4) { return '011'B; } |
| 1870 | case (RSL_ALG_ID_A5_5) { return '100'B; } |
| 1871 | case (RSL_ALG_ID_A5_6) { return '101'B; } |
| 1872 | case (RSL_ALG_ID_A5_7) { return '110'B; } |
| 1873 | case else { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1874 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unknwon Algorithm ID"); |
| 1875 | /* Make compiler happy by calling mtc.stop here. It is already |
| 1876 | * called in f_shutdown */ |
Daniel Willmann | 17ddd85 | 2018-07-05 17:33:20 +0200 | [diff] [blame] | 1877 | mtc.stop; |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 1878 | } |
| 1879 | } |
| 1880 | } |
| 1881 | |
Pau Espin Pedrol | 6451b04 | 2018-10-24 20:36:16 +0200 | [diff] [blame] | 1882 | /* Send RACH request through l1CTL and wait for ChanReq on RSL BST->BSC */ |
| 1883 | private function f_rach_req_wait_chan_rqd(integer ra) runs on ConnHdlr return GsmFrameNumber { |
| 1884 | var GsmFrameNumber fn; |
| 1885 | timer T := 8.0; |
| 1886 | |
| 1887 | /* advertise to RSL Emulation that we expect to receive confirmation from RACH */ |
| 1888 | RSL.send(ts_RSLDC_ChanRqd_anyFN(int2oct(ra,1))); |
| 1889 | |
| 1890 | f_L1CTL_PARAM(L1CTL, g_pars.l1_pars.ms_actual_ta, g_pars.l1_pars.ms_power_level); |
| 1891 | /* Send the actual RACH */ |
| 1892 | fn := f_L1CTL_RACH(L1CTL, ra); |
| 1893 | |
| 1894 | T.start; |
| 1895 | alt { |
| 1896 | [] RSL.receive(tr_RSL_CHAN_RQD(int2oct(ra,1), fn)) { setverdict(pass, "Received CHAN-RQD from RACH REQ") } |
| 1897 | [] T.timeout { |
| 1898 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Timeout waiting for CHAN-RQD from RACH REQ <", ra, ", ", fn, ">")); |
| 1899 | } |
| 1900 | } |
| 1901 | T.stop |
| 1902 | return fn; |
| 1903 | } |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 1904 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1905 | /* Establish dedicated channel: L1CTL + RSL side */ |
Harald Welte | c8d363c | 2019-05-19 20:36:48 +0200 | [diff] [blame] | 1906 | 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] | 1907 | var GsmFrameNumber fn; |
| 1908 | var ImmediateAssignment imm_ass; |
| 1909 | var integer ra := 23; |
| 1910 | |
Pau Espin Pedrol | 6451b04 | 2018-10-24 20:36:16 +0200 | [diff] [blame] | 1911 | /* Send RACH request and wait for ChanReq */ |
| 1912 | fn := f_rach_req_wait_chan_rqd(ra); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1913 | |
| 1914 | /* Activate channel on BTS side */ |
Harald Welte | c8d363c | 2019-05-19 20:36:48 +0200 | [diff] [blame] | 1915 | f_rsl_chan_act(g_pars.chan_mode, encr_enable, more_ies); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1916 | |
| 1917 | /* Send IMM.ASS via CCHAN */ |
| 1918 | var ChannelDescription ch_desc := { |
| 1919 | chan_nr := g_pars.chan_nr, |
| 1920 | tsc := 7, |
| 1921 | h := false, |
| 1922 | arfcn := mp_trx0_arfcn, |
| 1923 | maio_hsn := omit |
| 1924 | }; |
| 1925 | var MobileAllocation ma := { |
| 1926 | len := 0, |
| 1927 | ma := ''B |
| 1928 | }; |
| 1929 | var GsmRrMessage rr_msg := valueof(ts_IMM_ASS(ra, fn, 0, ch_desc, ma)); |
| 1930 | RSL.send(ts_RSL_IMM_ASSIGN(enc_GsmRrMessage(rr_msg))); |
| 1931 | |
| 1932 | /* receive IMM.ASS on MS side */ |
| 1933 | var ImmediateAssignment ia_um; |
| 1934 | ia_um := f_L1CTL_WAIT_IMM_ASS(L1CTL, ra, fn); |
| 1935 | /* enable dedicated mode */ |
| 1936 | f_L1CTL_DM_EST_REQ_IA(L1CTL, ia_um); |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 1937 | /* enable encryption, if requested */ |
| 1938 | if (encr_enable) { |
| 1939 | var uint8_t alg_id := f_alg_id_to_l1ctl(g_pars.encr.alg_id); |
| 1940 | f_L1CTL_CRYPTO_REQ(L1CTL, g_pars.chan_nr, alg_id, g_pars.encr.key); |
| 1941 | } |
Harald Welte | fa45e9e | 2018-03-10 18:59:03 +0100 | [diff] [blame] | 1942 | |
| 1943 | g_first_meas_res := true; |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1944 | } |
| 1945 | |
| 1946 | /* establish DChan, verify existance + contents of measurement reports */ |
| 1947 | function f_TC_meas_res_periodic(charstring id) runs on ConnHdlr { |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 1948 | f_l1_tune(L1CTL); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1949 | RSL.clear; |
| 1950 | |
Vadim Yanitskiy | 44ff214 | 2019-01-12 07:04:58 +0700 | [diff] [blame] | 1951 | if (mp_bts_trxc_port != -1) { |
Pau Espin Pedrol | e9571aa | 2018-10-22 17:13:07 +0200 | [diff] [blame] | 1952 | f_trxc_fake_rssi(rxlev2dbm(mp_ul_rxlev_exp)); |
Vadim Yanitskiy | dc8db92 | 2019-06-04 21:58:15 +0700 | [diff] [blame] | 1953 | f_trxc_fake_toffs256(g_pars.l1_pars.timing_offset_256syms); |
Pau Espin Pedrol | 121724c | 2018-09-28 15:58:12 +0200 | [diff] [blame] | 1954 | } |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1955 | |
| 1956 | f_est_dchan(); |
| 1957 | |
| 1958 | /* run for a number of seconds, send SACCH + FACCH from MS side and verify |
| 1959 | * RSL measurement reports on Abis side */ |
| 1960 | timer T := 8.0; |
| 1961 | T.start; |
| 1962 | alt { |
| 1963 | [] as_l1_sacch(); |
| 1964 | [] as_meas_res(); |
| 1965 | [] as_l1_dcch(); |
| 1966 | [] L1CTL.receive { repeat; } |
| 1967 | [g_Tmeas_exp.running] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1968 | /* 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] | 1969 | * of any earlier errors, so if we reach this timeout, we're good */ |
| 1970 | setverdict(pass); |
| 1971 | } |
| 1972 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 1973 | 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] | 1974 | } |
| 1975 | } |
| 1976 | f_rsl_chan_deact(); |
Harald Welte | 3dc2046 | 2018-03-10 23:03:38 +0100 | [diff] [blame] | 1977 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 1978 | } |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 1979 | |
Eric Wild | ae8f262 | 2019-06-18 17:05:11 +0200 | [diff] [blame] | 1980 | function f_check_meas_bs_power_level(integer level) runs on ConnHdlr { |
| 1981 | timer T := 8.0; |
| 1982 | T.start; |
| 1983 | var RSL_Message rsl; |
| 1984 | alt { |
| 1985 | [] as_l1_sacch(); |
| 1986 | [] L1CTL.receive { repeat; } |
| 1987 | [] RSL.receive(tr_RSL_MEAS_RES(g_chan_nr, ?, ?, ?)) -> value rsl { |
| 1988 | if (rsl.ies[3].body.bs_power.power_level == level) { |
| 1989 | setverdict(pass) |
| 1990 | } else { |
| 1991 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Received wrong BS power level in MEAS RES ", rsl)); |
| 1992 | } |
| 1993 | } |
| 1994 | [] T.timeout { |
| 1995 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "No MEAS RES received at all"); |
| 1996 | } |
| 1997 | } |
| 1998 | } |
| 1999 | |
| 2000 | /* see if the rsl meas res contains our expeced bs power level |
| 2001 | bs power set during assignment */ |
| 2002 | function f_TC_rsl_bs_pwr_static_ass(charstring id) runs on ConnHdlr { |
| 2003 | f_l1_tune(L1CTL); |
| 2004 | RSL.clear; |
| 2005 | |
| 2006 | if (mp_bts_trxc_port != -1) { |
| 2007 | f_trxc_fake_rssi(rxlev2dbm(mp_ul_rxlev_exp)); |
| 2008 | f_trxc_fake_toffs256(g_pars.l1_pars.timing_offset_256syms); |
| 2009 | } |
| 2010 | |
| 2011 | var uint5_t pwr_var := 1; |
| 2012 | var template (value) RSL_IE_BS_Power bs_power := ts_RSL_IE_BS_Power(pwr_var); |
| 2013 | var template (value) RSL_IE pwr := t_RSL_IE(RSL_IE_BS_POWER, RSL_IE_Body:{bs_power := bs_power}); |
| 2014 | |
| 2015 | f_est_dchan(more_ies :={valueof(pwr)}); |
| 2016 | |
| 2017 | f_check_meas_bs_power_level(pwr_var); |
| 2018 | |
| 2019 | f_rsl_chan_deact(); |
| 2020 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 2021 | } |
| 2022 | |
| 2023 | /* see if the rsl meas res contains our expeced bs power level |
| 2024 | bs power set after assignment */ |
| 2025 | function f_TC_rsl_bs_pwr_static_power_control(charstring id) runs on ConnHdlr { |
| 2026 | f_l1_tune(L1CTL); |
| 2027 | RSL.clear; |
| 2028 | |
| 2029 | if (mp_bts_trxc_port != -1) { |
| 2030 | f_trxc_fake_rssi(rxlev2dbm(mp_ul_rxlev_exp)); |
| 2031 | f_trxc_fake_toffs256(g_pars.l1_pars.timing_offset_256syms); |
| 2032 | } |
| 2033 | |
| 2034 | var uint5_t pwr_var := 1; |
| 2035 | var template (value) RSL_IE_BS_Power bs_power := ts_RSL_IE_BS_Power(pwr_var); |
| 2036 | |
| 2037 | f_est_dchan(); |
| 2038 | |
| 2039 | RSL.send(ts_RSL_BS_PWR_CTRL(g_chan_nr, bs_power)); |
| 2040 | |
| 2041 | f_check_meas_bs_power_level(pwr_var); |
| 2042 | |
| 2043 | f_rsl_chan_deact(); |
| 2044 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 2045 | } |
| 2046 | |
| 2047 | testcase TC_rsl_bs_pwr_static_ass() runs on test_CT { |
| 2048 | var ConnHdlr vc_conn; |
| 2049 | var ConnHdlrPars pars; |
| 2050 | f_init(); |
| 2051 | for (var integer tn := 1; tn <= 4; tn := tn+1) { |
| 2052 | pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN)); |
| 2053 | vc_conn := f_start_handler(refers(f_TC_rsl_bs_pwr_static_ass), pars, |
| 2054 | pcu_comp := false, trxc_comp := true); |
| 2055 | vc_conn.done; |
| 2056 | } |
| 2057 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 2058 | } |
| 2059 | |
| 2060 | testcase TC_rsl_bs_pwr_static_power_control() runs on test_CT { |
| 2061 | var ConnHdlr vc_conn; |
| 2062 | var ConnHdlrPars pars; |
| 2063 | f_init(); |
| 2064 | for (var integer tn := 1; tn <= 4; tn := tn+1) { |
| 2065 | pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN)); |
| 2066 | vc_conn := f_start_handler(refers(f_TC_rsl_bs_pwr_static_power_control), pars, |
| 2067 | pcu_comp := false, trxc_comp := true); |
| 2068 | vc_conn.done; |
| 2069 | } |
| 2070 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 2071 | } |
| 2072 | |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 2073 | /* target level -100, first rssi -90, ms power 7, expected increase to 7+6 within 6 seconds, |
| 2074 | second rssi -110, ms power 7+6, expected decrease to 7 within 6 seconds, |
| 2075 | These power levels are valid for all bands and require no special handling */ |
| 2076 | function f_TC_rsl_ms_pwr_dyn_ass_updown(charstring id) runs on ConnHdlr { |
| 2077 | var uint5_t pwr_var := 7; |
| 2078 | var L1ctlDlMessage l1_dl; |
| 2079 | |
| 2080 | f_trxc_fake_rssi(rxlev2dbm(10)); |
| 2081 | f_l1_tune(L1CTL); |
| 2082 | RSL.clear; |
| 2083 | |
| 2084 | var RSL_IE_List addl_ies; |
| 2085 | var template (value) RSL_IE_MS_Power_Parameters pp := (ts_RSL_IE_MS_Power_Parameters(''O)); |
| 2086 | |
| 2087 | addl_ies := { |
| 2088 | valueof(t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ts_RSL_IE_MS_Power(pwr_var)})), |
| 2089 | valueof(t_RSL_IE(RSL_IE_MS_POWER_PARAM, RSL_IE_Body:{ms_power_params := pp})) |
| 2090 | }; |
| 2091 | |
| 2092 | /* establish with power parameters */ |
| 2093 | f_est_dchan(more_ies := addl_ies); |
| 2094 | |
| 2095 | /* set a high value to ensure L1 power control level increases */ |
| 2096 | f_trxc_fake_rssi(rxlev2dbm(20)); |
| 2097 | |
| 2098 | timer T2 := 6.0; |
| 2099 | T2.start; |
| 2100 | alt { |
| 2101 | [] 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] | 2102 | /* Update sent MS power to follow what BTS requests */ |
| 2103 | f_L1CTL_PARAM(L1CTL, g_pars.l1_pars.ms_actual_ta, oct2int(l1_dl.payload.data_ind.payload[0])); |
| 2104 | if (oct2int(l1_dl.payload.data_ind.payload[0]) < (pwr_var + 6)) { |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 2105 | repeat; |
Pau Espin Pedrol | a1f7d24 | 2019-12-04 16:08:09 +0100 | [diff] [blame] | 2106 | } |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 2107 | T2.stop; |
| 2108 | } |
| 2109 | [] L1CTL.receive { repeat; } |
| 2110 | [] T2.timeout { |
| 2111 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2112 | "Power Level in L1 header has not increased sufficiently"); |
| 2113 | } |
| 2114 | } |
| 2115 | |
| 2116 | /* set a low value to ensure L1 power control level decreases */ |
| 2117 | f_trxc_fake_rssi(rxlev2dbm(0)); |
| 2118 | |
| 2119 | timer T4 := 6.0; |
| 2120 | T4.start; |
| 2121 | alt { |
| 2122 | [] 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] | 2123 | /* Update sent MS power to follow what BTS requests */ |
| 2124 | f_L1CTL_PARAM(L1CTL, g_pars.l1_pars.ms_actual_ta, oct2int(l1_dl.payload.data_ind.payload[0])); |
| 2125 | if (oct2int(l1_dl.payload.data_ind.payload[0]) > pwr_var) { |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 2126 | repeat; |
Pau Espin Pedrol | a1f7d24 | 2019-12-04 16:08:09 +0100 | [diff] [blame] | 2127 | } |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 2128 | T4.stop; |
| 2129 | setverdict(pass, "Power level in L1 decreased/increased as expected"); |
| 2130 | } |
| 2131 | [] L1CTL.receive { repeat; } |
| 2132 | [] T4.timeout { |
| 2133 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2134 | "Power Level in L1 header has not decreased sufficiently"); |
| 2135 | } |
| 2136 | } |
| 2137 | |
| 2138 | f_rsl_chan_deact(); |
| 2139 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 2140 | |
| 2141 | } |
| 2142 | |
| 2143 | /* check that we do not exceed the max power */ |
| 2144 | function f_TC_rsl_ms_pwr_dyn_max(charstring id) runs on ConnHdlr { |
| 2145 | var uint5_t pwr_var := 7; |
| 2146 | var L1ctlDlMessage l1_dl; |
| 2147 | |
| 2148 | /* set a low value to ensure power increases */ |
| 2149 | f_trxc_fake_rssi(rxlev2dbm(10)); |
| 2150 | f_l1_tune(L1CTL); |
| 2151 | RSL.clear; |
| 2152 | |
| 2153 | var RSL_IE_List addl_ies; |
| 2154 | var template (value) RSL_IE_MS_Power_Parameters pp := (ts_RSL_IE_MS_Power_Parameters(''O)); |
| 2155 | |
| 2156 | addl_ies := { |
| 2157 | valueof(t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ts_RSL_IE_MS_Power(pwr_var)})), |
| 2158 | valueof(t_RSL_IE(RSL_IE_MS_POWER_PARAM, RSL_IE_Body:{ms_power_params := pp})) |
| 2159 | }; |
| 2160 | |
| 2161 | /* establish with power parameters */ |
| 2162 | f_est_dchan(more_ies := addl_ies); |
| 2163 | |
| 2164 | timer T1 := 10.0; |
| 2165 | T1.start; |
| 2166 | alt { |
Pau Espin Pedrol | a1f7d24 | 2019-12-04 16:08:09 +0100 | [diff] [blame] | 2167 | [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl { |
| 2168 | /* Update sent MS power to follow what BTS requests */ |
| 2169 | f_L1CTL_PARAM(L1CTL, g_pars.l1_pars.ms_actual_ta, oct2int(l1_dl.payload.data_ind.payload[0])); |
| 2170 | repeat; |
| 2171 | } |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 2172 | [] L1CTL.receive { repeat; } |
| 2173 | [] T1.timeout { |
| 2174 | if( oct2int(l1_dl.payload.data_ind.payload[0]) != pwr_var){ |
| 2175 | setverdict(fail, "Power level in L1 header should not have changed"); |
| 2176 | } |
| 2177 | } |
| 2178 | } |
| 2179 | |
| 2180 | f_rsl_chan_deact(); |
| 2181 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 2182 | |
| 2183 | } |
| 2184 | |
| 2185 | /* see if we reach the band max power */ |
| 2186 | function f_TC_rsl_ms_pwr_dyn_up(charstring id) runs on ConnHdlr { |
| 2187 | var L1ctlDlMessage l1_dl; |
| 2188 | var uint5_t pwr_var := 15; |
| 2189 | var uint5_t pwr_max_var := f_get_max_power_from_band(); |
| 2190 | |
| 2191 | /* set a low value to ensure power increases */ |
| 2192 | f_trxc_fake_rssi(rxlev2dbm(10)); |
| 2193 | f_l1_tune(L1CTL); |
| 2194 | RSL.clear; |
| 2195 | |
| 2196 | var template (value) RSL_IE_MS_Power ms_power := ts_RSL_IE_MS_Power(pwr_var); |
| 2197 | var template (value) RSL_IE pwr := t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ms_power}); |
| 2198 | |
| 2199 | /* establish with fixed power level */ |
| 2200 | f_est_dchan(more_ies :={valueof(pwr)}); |
| 2201 | |
| 2202 | /* check our initial power level */ |
| 2203 | f_wait_for_l1_power_level(pwr_var); |
| 2204 | |
| 2205 | /* update power param to enable power loop |
| 2206 | 48.058 The maximum power to be used is indicated in the BS and MS Power elements respectively. */ |
| 2207 | RSL.send(ts_RSL_MS_PWR_CTRL_with_pp(g_chan_nr, pwr_max_var)); |
| 2208 | |
| 2209 | /* wait, then check that our power level was reduced */ |
| 2210 | timer T1 := 10.0; |
| 2211 | T1.start; |
| 2212 | alt { |
Pau Espin Pedrol | a1f7d24 | 2019-12-04 16:08:09 +0100 | [diff] [blame] | 2213 | [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl { |
| 2214 | /* Update sent MS power to follow what BTS requests */ |
| 2215 | f_L1CTL_PARAM(L1CTL, g_pars.l1_pars.ms_actual_ta, oct2int(l1_dl.payload.data_ind.payload[0])); |
| 2216 | repeat; |
| 2217 | } |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 2218 | [] L1CTL.receive { repeat; } |
| 2219 | [] T1.timeout { |
| 2220 | var int8_t rcv := oct2int(l1_dl.payload.data_ind.payload[0]); |
| 2221 | if( f_power_level_is_highest_dbm(rcv) ){ |
| 2222 | setverdict(pass, "Power level in L1 header reduced as expected"); |
| 2223 | } else { |
| 2224 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2225 | log2str("Power Level in L1 header did not reach the expected value, e:",pwr_max_var," r:",rcv)); |
| 2226 | } |
| 2227 | } |
| 2228 | } |
| 2229 | |
| 2230 | f_rsl_chan_deact(); |
| 2231 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 2232 | |
| 2233 | } |
| 2234 | |
| 2235 | /* see if we reach the band min power */ |
| 2236 | function f_TC_rsl_ms_pwr_dyn_down(charstring id) runs on ConnHdlr { |
| 2237 | var L1ctlDlMessage l1_dl; |
| 2238 | |
| 2239 | /* set a high value to ensure power decreases */ |
| 2240 | f_trxc_fake_rssi(rxlev2dbm(50)); |
| 2241 | f_l1_tune(L1CTL); |
| 2242 | RSL.clear; |
| 2243 | |
| 2244 | var uint5_t pwr_var := 5; |
| 2245 | var uint5_t pwr_target_val := 15; |
| 2246 | |
| 2247 | var template (value) RSL_IE_MS_Power ms_power := ts_RSL_IE_MS_Power(pwr_var); |
| 2248 | var template (value) RSL_IE pwr := t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ms_power}); |
| 2249 | |
| 2250 | /* establish with fixed power level */ |
| 2251 | f_est_dchan(more_ies :={valueof(pwr)}); |
| 2252 | |
| 2253 | /* check our initial power level */ |
| 2254 | f_wait_for_l1_power_level(pwr_var); |
| 2255 | |
| 2256 | /* update power param to enable power loop |
| 2257 | 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] | 2258 | 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] | 2259 | |
| 2260 | /* wait, then check that our power level was increased */ |
| 2261 | timer T1 := 10.0; |
| 2262 | T1.start; |
| 2263 | alt { |
Pau Espin Pedrol | a1f7d24 | 2019-12-04 16:08:09 +0100 | [diff] [blame] | 2264 | [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl { |
| 2265 | /* Update sent MS power to follow what BTS requests */ |
| 2266 | f_L1CTL_PARAM(L1CTL, g_pars.l1_pars.ms_actual_ta, oct2int(l1_dl.payload.data_ind.payload[0])); |
| 2267 | repeat; |
| 2268 | } |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 2269 | [] L1CTL.receive { repeat; } |
| 2270 | [] T1.timeout { |
| 2271 | if( f_power_level_is_lowest_dbm(oct2int(l1_dl.payload.data_ind.payload[0])) ){ |
| 2272 | setverdict(pass, "Power level in L1 header increased to lowest power value"); |
| 2273 | } else { |
| 2274 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2275 | "Power level in L1 header NOT increased to lowest power value"); |
| 2276 | } |
| 2277 | } |
| 2278 | } |
| 2279 | |
| 2280 | f_rsl_chan_deact(); |
| 2281 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 2282 | |
| 2283 | } |
| 2284 | |
Eric Wild | 095024b | 2019-06-17 15:08:57 +0200 | [diff] [blame] | 2285 | /* see if we change the power level without receiving power parameters, which should not happen |
| 2286 | rsl chan act WITHOUT power parameters */ |
Eric Wild | 280ccb8 | 2019-06-17 11:11:52 +0200 | [diff] [blame] | 2287 | function f_TC_rsl_ms_pwr_dyn_active(charstring id) runs on ConnHdlr { |
| 2288 | var L1ctlDlMessage l1_dl; |
| 2289 | |
| 2290 | /* set a high value to ensure power decreases */ |
| 2291 | f_trxc_fake_rssi(rxlev2dbm(50)); |
| 2292 | f_l1_tune(L1CTL); |
| 2293 | RSL.clear; |
| 2294 | |
| 2295 | var uint5_t pwr_var := 5; |
| 2296 | |
| 2297 | var template (value) RSL_IE_MS_Power ms_power := ts_RSL_IE_MS_Power(pwr_var); |
| 2298 | var template (value) RSL_IE pwr := t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ms_power}); |
| 2299 | |
| 2300 | /* establish with fixed power level */ |
| 2301 | f_est_dchan(more_ies :={valueof(pwr)}); |
| 2302 | |
| 2303 | /* check our initial power level */ |
| 2304 | f_wait_for_l1_power_level(pwr_var); |
| 2305 | |
| 2306 | /* wait, then check that our power level did not change */ |
| 2307 | timer T1 := 10.0; |
| 2308 | T1.start; |
| 2309 | alt { |
| 2310 | [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl { |
| 2311 | if ( oct2int(l1_dl.payload.data_ind.payload[0]) != pwr_var) { |
| 2312 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2313 | "BS power control should not be active unless we receive a power parameters IE!"); |
| 2314 | } |
| 2315 | repeat; |
| 2316 | } |
| 2317 | [] L1CTL.receive { repeat; } |
| 2318 | [] T1.timeout { setverdict(pass); } |
| 2319 | } |
| 2320 | |
| 2321 | f_rsl_chan_deact(); |
| 2322 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 2323 | |
| 2324 | } |
| 2325 | |
Eric Wild | 095024b | 2019-06-17 15:08:57 +0200 | [diff] [blame] | 2326 | /* see if we change the power level without receiving power parameters, which should not happen |
| 2327 | ms power control WITHOUT power parameters */ |
| 2328 | function f_TC_rsl_ms_pwr_dyn_active2(charstring id) runs on ConnHdlr { |
| 2329 | var L1ctlDlMessage l1_dl; |
| 2330 | |
| 2331 | /* set a high value to ensure power decreases */ |
| 2332 | f_trxc_fake_rssi(rxlev2dbm(50)); |
| 2333 | f_l1_tune(L1CTL); |
| 2334 | RSL.clear; |
| 2335 | |
| 2336 | var uint5_t pwr_var := 5; |
| 2337 | |
| 2338 | var template (value) RSL_IE_MS_Power ms_power := ts_RSL_IE_MS_Power(pwr_var); |
| 2339 | var template (value) RSL_IE pwr := t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ms_power}); |
| 2340 | |
| 2341 | /* establish with fixed power level */ |
| 2342 | f_est_dchan(more_ies :={valueof(pwr)}); |
| 2343 | |
| 2344 | /* check our initial power level */ |
| 2345 | f_wait_for_l1_power_level(pwr_var); |
| 2346 | |
| 2347 | /* pwr control without power params IE, should NOT activate MS power control*/ |
| 2348 | RSL.send(ts_RSL_MS_PWR_CTRL(g_chan_nr, ms_power)); |
| 2349 | |
| 2350 | /* wait, then check that our power level did not change */ |
| 2351 | timer T1 := 10.0; |
| 2352 | T1.start; |
| 2353 | alt { |
| 2354 | [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl { |
| 2355 | if ( oct2int(l1_dl.payload.data_ind.payload[0]) != pwr_var) { |
| 2356 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2357 | "BS power control should not be active unless we receive a power parameters IE!"); |
| 2358 | } |
| 2359 | repeat; |
| 2360 | } |
| 2361 | [] L1CTL.receive { repeat; } |
| 2362 | [] T1.timeout { setverdict(pass); } |
| 2363 | } |
| 2364 | |
| 2365 | f_rsl_chan_deact(); |
| 2366 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 2367 | |
| 2368 | } |
| 2369 | |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 2370 | function f_wait_for_l1_power_level(integer level) runs on ConnHdlr { |
| 2371 | var L1ctlDlMessage l1_dl; |
| 2372 | timer T0 := 10.0; |
| 2373 | T0.start; |
| 2374 | alt { |
| 2375 | [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl { |
| 2376 | if (not (l1_dl.payload.data_ind.payload[0] == int2oct(level, 1))) { |
| 2377 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2378 | "Power level in L1 header != signaled (RSL) power level."); |
| 2379 | } |
| 2380 | } |
| 2381 | [] L1CTL.receive { repeat; } |
| 2382 | [] T0.timeout { |
| 2383 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 2384 | "Timeout waiting for initial power level"); |
| 2385 | } |
| 2386 | } |
| 2387 | T0.stop; |
| 2388 | } |
| 2389 | |
| 2390 | private function f_power_level_is_lowest_dbm(integer level) runs on ConnHdlr return boolean { |
| 2391 | var IntegerRecord min_dbm_level; |
| 2392 | var IntegerRecord max_dbm_level; |
| 2393 | var IntegerRecord x := f_power_from_band(g_pars.bts0_band, min_dbm_level, max_dbm_level); |
| 2394 | |
| 2395 | for (var integer i := 0; i < sizeof(min_dbm_level); i := i+1) { |
| 2396 | if (min_dbm_level[i] == level) { |
| 2397 | return true; |
| 2398 | } |
| 2399 | } |
| 2400 | return false; |
| 2401 | } |
| 2402 | |
| 2403 | private function f_power_level_is_highest_dbm(integer level) runs on ConnHdlr return boolean { |
| 2404 | var IntegerRecord min_dbm_level; |
| 2405 | var IntegerRecord max_dbm_level; |
| 2406 | var IntegerRecord x := f_power_from_band(g_pars.bts0_band, min_dbm_level, max_dbm_level); |
| 2407 | |
| 2408 | for (var integer i := 0; i < sizeof(max_dbm_level); i := i+1) { |
| 2409 | if (max_dbm_level[i] == level) { |
| 2410 | return true; |
| 2411 | } |
| 2412 | } |
| 2413 | return false; |
| 2414 | } |
| 2415 | |
| 2416 | private function f_get_max_power_from_band() runs on ConnHdlr return integer { |
| 2417 | var IntegerRecord min_dbm_level; |
| 2418 | var IntegerRecord max_dbm_level; |
| 2419 | var IntegerRecord x := f_power_from_band(g_pars.bts0_band, min_dbm_level, max_dbm_level); |
| 2420 | return max_dbm_level[0]; |
| 2421 | } |
| 2422 | |
| 2423 | type charstring BtsBand ("GSM450","GSM480","GSM750","GSM810","GSM850","GSM900","DCS1800","PCS1900"); |
| 2424 | template charstring BtsBand_allGSM:= pattern "GSM???"; |
| 2425 | private function f_power_from_band(in BtsBand band, out IntegerRecord min_dbm_level, out IntegerRecord max_dbm_level) return IntegerRecord { |
| 2426 | // 45.005 4.1.1 |
| 2427 | var IntegerRecord gsm_power :={31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, |
| 2428 | 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, |
| 2429 | 2, 1, 0}; |
| 2430 | var IntegerRecord dcs_power :={28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, |
| 2431 | 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 31, 30, 29}; |
| 2432 | var IntegerRecord pcs_power :={15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 31, 30}; |
| 2433 | var IntegerRecord rv; |
| 2434 | |
| 2435 | select(band){ |
| 2436 | case (BtsBand_allGSM){ |
| 2437 | rv := gsm_power; |
| 2438 | min_dbm_level := {31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19} ; |
| 2439 | max_dbm_level := {2, 1, 0}; |
| 2440 | } |
| 2441 | case("DCS1800"){ |
| 2442 | rv := dcs_power; |
| 2443 | min_dbm_level := {28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15}; |
| 2444 | max_dbm_level := {0, 29}; // let's cheat here, assume MS_TXPWR_MAX_CCH might be being broadcast, so maybe no 29,30,31 |
| 2445 | } |
| 2446 | case("PCS1900"){ |
| 2447 | rv := pcs_power; |
| 2448 | min_dbm_level := {15}; |
| 2449 | max_dbm_level := {30}; |
| 2450 | } |
| 2451 | } |
| 2452 | |
| 2453 | return rv; |
| 2454 | } |
| 2455 | |
| 2456 | private function f_vty_get_bts0_band() runs on test_CT return BtsBand { |
| 2457 | return f_vty_transceive_match_regex(BTSVTY, "show bts 0", "BTS 0 is of \w+ type in band (\w+),*", 0); |
| 2458 | } |
| 2459 | |
| 2460 | testcase TC_rsl_ms_pwr_dyn_ass_updown() runs on test_CT { |
| 2461 | var ConnHdlr vc_conn; |
| 2462 | var ConnHdlrPars pars; |
| 2463 | f_init(); |
| 2464 | f_vty_config(BTSVTY, "phy 0", "osmotrx ms-power-loop -100"); |
| 2465 | for (var integer tn := 1; tn <= 1; tn := tn+1) { |
| 2466 | pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN)); |
| 2467 | pars.bts0_band := f_vty_get_bts0_band(); |
| 2468 | vc_conn := f_start_handler(refers(f_TC_rsl_ms_pwr_dyn_ass_updown), pars, trxc_comp := true); |
| 2469 | vc_conn.done; |
| 2470 | } |
| 2471 | f_vty_config(BTSVTY, "phy 0", "no osmotrx ms-power-loop"); |
| 2472 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 2473 | } |
| 2474 | |
| 2475 | testcase TC_rsl_ms_pwr_dyn_up() runs on test_CT { |
| 2476 | var ConnHdlr vc_conn; |
| 2477 | var ConnHdlrPars pars; |
| 2478 | f_init(); |
| 2479 | f_vty_config(BTSVTY, "phy 0", "osmotrx ms-power-loop -10"); |
| 2480 | for (var integer tn := 1; tn <= 1; tn := tn+1) { |
| 2481 | pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN)); |
| 2482 | pars.bts0_band := f_vty_get_bts0_band(); |
| 2483 | vc_conn := f_start_handler(refers(f_TC_rsl_ms_pwr_dyn_up), pars, trxc_comp := true); |
| 2484 | vc_conn.done; |
| 2485 | } |
| 2486 | f_vty_config(BTSVTY, "phy 0", "no osmotrx ms-power-loop"); |
| 2487 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 2488 | } |
| 2489 | |
| 2490 | testcase TC_rsl_ms_pwr_dyn_max() runs on test_CT { |
| 2491 | var ConnHdlr vc_conn; |
| 2492 | var ConnHdlrPars pars; |
| 2493 | f_init(); |
| 2494 | f_vty_config(BTSVTY, "phy 0", "osmotrx ms-power-loop -10"); |
| 2495 | for (var integer tn := 1; tn <= 1; tn := tn+1) { |
| 2496 | pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN)); |
| 2497 | pars.bts0_band := f_vty_get_bts0_band(); |
| 2498 | vc_conn := f_start_handler(refers(f_TC_rsl_ms_pwr_dyn_max), pars, trxc_comp := true); |
| 2499 | vc_conn.done; |
| 2500 | } |
| 2501 | f_vty_config(BTSVTY, "phy 0", "no osmotrx ms-power-loop"); |
| 2502 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 2503 | } |
| 2504 | |
| 2505 | testcase TC_rsl_ms_pwr_dyn_down() runs on test_CT { |
| 2506 | var ConnHdlr vc_conn; |
| 2507 | var ConnHdlrPars pars; |
| 2508 | f_init(); |
| 2509 | f_vty_config(BTSVTY, "phy 0", "osmotrx ms-power-loop -100"); |
| 2510 | for (var integer tn := 1; tn <= 1; tn := tn+1) { |
| 2511 | pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN)); |
| 2512 | pars.bts0_band := f_vty_get_bts0_band(); |
| 2513 | vc_conn := f_start_handler(refers(f_TC_rsl_ms_pwr_dyn_down), pars, trxc_comp := true); |
| 2514 | vc_conn.done; |
| 2515 | } |
| 2516 | f_vty_config(BTSVTY, "phy 0", "no osmotrx ms-power-loop"); |
| 2517 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 2518 | } |
| 2519 | |
Eric Wild | 280ccb8 | 2019-06-17 11:11:52 +0200 | [diff] [blame] | 2520 | testcase TC_rsl_ms_pwr_dyn_active() runs on test_CT { |
| 2521 | var ConnHdlr vc_conn; |
| 2522 | var ConnHdlrPars pars; |
| 2523 | f_init(); |
| 2524 | f_vty_config(BTSVTY, "phy 0", "osmotrx ms-power-loop -100"); |
| 2525 | for (var integer tn := 1; tn <= 1; tn := tn+1) { |
| 2526 | pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN)); |
| 2527 | pars.bts0_band := f_vty_get_bts0_band(); |
| 2528 | vc_conn := f_start_handler(refers(f_TC_rsl_ms_pwr_dyn_active), pars, trxc_comp := true); |
| 2529 | vc_conn.done; |
| 2530 | } |
| 2531 | f_vty_config(BTSVTY, "phy 0", "no osmotrx ms-power-loop"); |
| 2532 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 2533 | } |
| 2534 | |
Eric Wild | 095024b | 2019-06-17 15:08:57 +0200 | [diff] [blame] | 2535 | testcase TC_rsl_ms_pwr_dyn_active2() runs on test_CT { |
| 2536 | var ConnHdlr vc_conn; |
| 2537 | var ConnHdlrPars pars; |
| 2538 | f_init(); |
| 2539 | f_vty_config(BTSVTY, "phy 0", "osmotrx ms-power-loop -100"); |
| 2540 | for (var integer tn := 1; tn <= 1; tn := tn+1) { |
| 2541 | pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN)); |
| 2542 | pars.bts0_band := f_vty_get_bts0_band(); |
| 2543 | vc_conn := f_start_handler(refers(f_TC_rsl_ms_pwr_dyn_active2), pars, trxc_comp := true); |
| 2544 | vc_conn.done; |
| 2545 | } |
| 2546 | f_vty_config(BTSVTY, "phy 0", "no osmotrx ms-power-loop"); |
| 2547 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 2548 | } |
| 2549 | |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2550 | testcase TC_meas_res_sign_tchf() runs on test_CT { |
| 2551 | var ConnHdlr vc_conn; |
| 2552 | var ConnHdlrPars pars; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 2553 | f_init(); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2554 | for (var integer tn := 1; tn <= 4; tn := tn+1) { |
| 2555 | pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN)); |
Vadim Yanitskiy | f4e997c | 2019-06-04 21:40:33 +0700 | [diff] [blame] | 2556 | vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars, |
| 2557 | pcu_comp := false, trxc_comp := true); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2558 | vc_conn.done; |
| 2559 | } |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 2560 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2561 | } |
| 2562 | testcase TC_meas_res_sign_tchh() runs on test_CT { |
| 2563 | var ConnHdlr vc_conn; |
| 2564 | var ConnHdlrPars pars; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 2565 | f_init(); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2566 | for (var integer ss := 0; ss <= 1; ss := ss+1) { |
| 2567 | 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] | 2568 | vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars, |
| 2569 | pcu_comp := false, trxc_comp := true); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2570 | vc_conn.done; |
| 2571 | } |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 2572 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2573 | } |
| 2574 | testcase TC_meas_res_sign_sdcch4() runs on test_CT { |
| 2575 | var ConnHdlr vc_conn; |
| 2576 | var ConnHdlrPars pars; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 2577 | f_init(); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2578 | for (var integer ss := 0; ss <= 3; ss := ss+1) { |
| 2579 | 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] | 2580 | vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars, |
| 2581 | pcu_comp := false, trxc_comp := true); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2582 | vc_conn.done; |
| 2583 | } |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 2584 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2585 | } |
| 2586 | testcase TC_meas_res_sign_sdcch8() runs on test_CT { |
| 2587 | var ConnHdlr vc_conn; |
| 2588 | var ConnHdlrPars pars; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 2589 | f_init(); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2590 | for (var integer ss := 0; ss <= 7; ss := ss+1) { |
| 2591 | 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] | 2592 | vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars, |
| 2593 | pcu_comp := false, trxc_comp := true); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2594 | vc_conn.done; |
| 2595 | } |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 2596 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2597 | } |
Harald Welte | 685d598 | 2018-02-27 20:42:05 +0100 | [diff] [blame] | 2598 | testcase TC_meas_res_sign_tchh_toa256() runs on test_CT { |
| 2599 | var ConnHdlr vc_conn; |
| 2600 | var ConnHdlrPars pars; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 2601 | f_init(); |
Harald Welte | 685d598 | 2018-02-27 20:42:05 +0100 | [diff] [blame] | 2602 | f_vty_config(BTSVTY, "bts 0", "supp-meas-info toa256"); |
| 2603 | for (var integer ss := 0; ss <= 1; ss := ss+1) { |
| 2604 | pars := valueof(t_Pars(t_RslChanNr_Lm(5, ss), ts_RSL_ChanMode_SIGN)); |
| 2605 | pars.l1_pars.toa256_enabled := true; |
| 2606 | vc_conn := f_start_handler(refers(f_TC_meas_res_periodic), pars); |
| 2607 | vc_conn.done; |
| 2608 | } |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 2609 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 685d598 | 2018-02-27 20:42:05 +0100 | [diff] [blame] | 2610 | } |
| 2611 | |
Philipp Maier | 4d1e9c9 | 2018-12-20 11:11:56 +0100 | [diff] [blame] | 2612 | /* establish DChan, and send MS POWER CONTROL messages via RSL, verify that |
| 2613 | * the BTS is forwarding those values to the MS via the SACCH L1 header. */ |
| 2614 | function f_tc_rsl_ms_pwr_ctrl(charstring id) runs on ConnHdlr { |
| 2615 | var L1ctlDlMessage l1_dl; |
| 2616 | var RSL_IE_MS_Power ms_power; |
| 2617 | var RSL_Message rsl; |
| 2618 | var uint5_t power_level := 0; |
| 2619 | |
| 2620 | f_l1_tune(L1CTL); |
| 2621 | RSL.clear; |
| 2622 | |
| 2623 | f_est_dchan(); |
| 2624 | |
| 2625 | ms_power.reserved := 0; |
| 2626 | ms_power.fpc_epc := false; |
| 2627 | |
| 2628 | /* Send the first power control command. This will disable any BTS/TRX |
| 2629 | * internal power control and switch the MS (which is not in scope of |
| 2630 | * this test) to a constant power level. We start with a power level |
| 2631 | * of 0 */ |
| 2632 | ms_power.power_level := power_level; |
| 2633 | rsl := valueof(ts_RSL_MS_PWR_CTRL(g_chan_nr, ms_power)); |
| 2634 | RSL.send(rsl); |
| 2635 | |
| 2636 | alt { |
| 2637 | |
| 2638 | /* Pick all SACCH blocks for checking */ |
| 2639 | [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl { |
| 2640 | |
| 2641 | /* The first byte of the L1 header contains the power level. |
| 2642 | * The reserved bits and the fpc bit is set to 0, so we may |
| 2643 | * compare directly. */ |
| 2644 | if (not (l1_dl.payload.data_ind.payload[0] == int2oct(power_level, 1))) { |
| 2645 | setverdict(fail, "Power level in L1 header does not match the signaled (RSL) power level."); |
| 2646 | } |
| 2647 | |
| 2648 | /* Signal a new power level via RSL for the next turn. */ |
| 2649 | if (power_level < 31) { |
| 2650 | power_level := power_level + 1; |
| 2651 | ms_power.power_level := power_level; |
| 2652 | rsl := valueof(ts_RSL_MS_PWR_CTRL(g_chan_nr, ms_power)); |
| 2653 | RSL.send(rsl); |
| 2654 | repeat; |
| 2655 | } |
| 2656 | |
| 2657 | } |
| 2658 | |
| 2659 | /* Ignore all other blocks */ |
| 2660 | [] L1CTL.receive { repeat; } |
| 2661 | |
| 2662 | } |
| 2663 | |
| 2664 | f_rsl_chan_deact(); |
| 2665 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 2666 | |
| 2667 | setverdict(pass); |
| 2668 | } |
| 2669 | |
| 2670 | testcase TC_rsl_ms_pwr_ctrl() runs on test_CT { |
| 2671 | var ConnHdlr vc_conn; |
| 2672 | var ConnHdlrPars pars; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 2673 | f_init(); |
Philipp Maier | 4d1e9c9 | 2018-12-20 11:11:56 +0100 | [diff] [blame] | 2674 | |
| 2675 | for (var integer tn := 1; tn <= 4; tn := tn+1) { |
| 2676 | pars := valueof(t_Pars(t_RslChanNr_Bm(tn), ts_RSL_ChanMode_SIGN)); |
| 2677 | vc_conn := f_start_handler(refers(f_tc_rsl_ms_pwr_ctrl), pars); |
| 2678 | vc_conn.done; |
| 2679 | } |
| 2680 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 2681 | } |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2682 | |
Eric Wild | 6833cc9 | 2019-05-23 19:34:44 +0200 | [diff] [blame] | 2683 | /* establish DChan, verify that the BTS sets the TA in the first SACCH L1 header. |
| 2684 | TA for the IMM ASS messages is still controlled by g_pars.l1_pars.ms_actual_ta! */ |
| 2685 | function f_tc_rsl_chan_initial_ta(charstring id) runs on ConnHdlr { |
| 2686 | var L1ctlDlMessage l1_dl; |
| 2687 | var uint5_t ta_to_test := 16; |
| 2688 | |
| 2689 | |
| 2690 | f_l1_tune(L1CTL); |
| 2691 | RSL.clear; |
| 2692 | |
| 2693 | /* tell fake_trx to use a given timing offset for all bursts */ |
Vadim Yanitskiy | dc8db92 | 2019-06-04 21:58:15 +0700 | [diff] [blame] | 2694 | f_trxc_fake_toffs256(ta_to_test*256); |
Eric Wild | 6833cc9 | 2019-05-23 19:34:44 +0200 | [diff] [blame] | 2695 | |
| 2696 | f_est_dchan(more_ies :={valueof(t_RSL_IE(RSL_IE_TIMING_ADVANCE, RSL_IE_Body:{timing_adv := ta_to_test}))} ); |
| 2697 | |
| 2698 | |
| 2699 | alt { |
| 2700 | |
| 2701 | /* Pick all SACCH blocks for checking */ |
| 2702 | [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl { |
| 2703 | |
| 2704 | /* The second byte of the L1 header contains the TA. */ |
| 2705 | if (not (l1_dl.payload.data_ind.payload[1] == int2oct(ta_to_test, 1))) { |
| 2706 | setverdict(fail, "TA in L1 header does not match the signaled (RSL) TA."); |
| 2707 | } |
| 2708 | |
| 2709 | } |
| 2710 | |
| 2711 | /* Ignore all other blocks */ |
| 2712 | [] L1CTL.receive { repeat; } |
| 2713 | |
| 2714 | } |
| 2715 | |
| 2716 | f_rsl_chan_deact(); |
| 2717 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 2718 | |
| 2719 | setverdict(pass); |
| 2720 | } |
| 2721 | |
| 2722 | testcase TC_rsl_chan_initial_ta() runs on test_CT { |
| 2723 | var ConnHdlr vc_conn; |
| 2724 | var ConnHdlrPars pars; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 2725 | f_init(); |
Eric Wild | 6833cc9 | 2019-05-23 19:34:44 +0200 | [diff] [blame] | 2726 | pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
Vadim Yanitskiy | f4e997c | 2019-06-04 21:40:33 +0700 | [diff] [blame] | 2727 | vc_conn := f_start_handler(refers(f_tc_rsl_chan_initial_ta), pars, |
| 2728 | pcu_comp := false, trxc_comp := true); |
Eric Wild | 6833cc9 | 2019-05-23 19:34:44 +0200 | [diff] [blame] | 2729 | vc_conn.done; |
| 2730 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 2731 | } |
| 2732 | |
Eric Wild | e57e1a6 | 2019-05-28 13:30:55 +0200 | [diff] [blame] | 2733 | /* establish DChan, verify that the BTS sets MS power in the first SACCH L1 header. */ |
| 2734 | function f_tc_rsl_chan_initial_ms_pwr(charstring id) runs on ConnHdlr { |
| 2735 | var L1ctlDlMessage l1_dl; |
| 2736 | var uint5_t ms_power_level := 7; |
| 2737 | |
| 2738 | var RSL_IE_MS_Power ms_power; |
| 2739 | ms_power.reserved := 0; |
| 2740 | ms_power.fpc_epc := false; |
| 2741 | ms_power.power_level := ms_power_level; |
| 2742 | |
| 2743 | f_l1_tune(L1CTL); |
| 2744 | RSL.clear; |
| 2745 | |
| 2746 | f_est_dchan(more_ies :={valueof(t_RSL_IE(RSL_IE_MS_POWER, RSL_IE_Body:{ms_power := ms_power}))} ); |
| 2747 | |
| 2748 | timer T := 1.0; |
| 2749 | T.start; |
| 2750 | alt { |
| 2751 | /* Pick all SACCH blocks for checking */ |
| 2752 | [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl { |
| 2753 | /* The first byte of the L1 header contains the power level.. */ |
| 2754 | if (not (l1_dl.payload.data_ind.payload[0] == int2oct(ms_power_level, 1))) { |
| 2755 | setverdict(fail, "Power Level in L1 header does not match the signaled (RSL) MS Power Level."); |
| 2756 | } |
| 2757 | } |
| 2758 | /* Ignore all other blocks */ |
| 2759 | [] L1CTL.receive { repeat; } |
| 2760 | [] T.timeout { |
| 2761 | setverdict(fail, "Power Level in L1 header does not match the signaled (RSL) MS Power Level."); |
| 2762 | } |
| 2763 | } |
| 2764 | |
| 2765 | f_rsl_chan_deact(); |
| 2766 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 2767 | setverdict(pass); |
| 2768 | } |
| 2769 | |
| 2770 | testcase TC_rsl_chan_initial_ms_pwr() runs on test_CT { |
| 2771 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 2772 | f_testmatrix_each_chan(pars, refers(f_tc_rsl_chan_initial_ms_pwr)); |
| 2773 | } |
| 2774 | |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 2775 | /* 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] | 2776 | private function f_TC_conn_fail_crit(charstring id) runs on ConnHdlr { |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 2777 | f_l1_tune(L1CTL); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2778 | RSL.clear; |
| 2779 | |
| 2780 | f_est_dchan(); |
| 2781 | f_sleep(2.0); |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 2782 | L1CTL.send(ts_L1CTL_DM_REL_REQ(g_chan_nr)); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2783 | |
| 2784 | timer T := 40.0; |
| 2785 | T.start; |
| 2786 | alt { |
| 2787 | [] RSL.receive(tr_RSL_CONN_FAIL_IND(g_chan_nr, ?)) { |
| 2788 | setverdict(pass) |
| 2789 | } |
| 2790 | [] RSL.receive { repeat }; |
| 2791 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 2792 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "No CONN FAIL IND received"); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2793 | } |
| 2794 | } |
| 2795 | f_rsl_chan_deact(); |
| 2796 | } |
| 2797 | testcase TC_conn_fail_crit() runs on test_CT { |
| 2798 | var ConnHdlr vc_conn; |
| 2799 | var ConnHdlrPars pars; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 2800 | f_init(); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2801 | pars := valueof(t_Pars(t_RslChanNr_SDCCH8(6, 3), ts_RSL_ChanMode_SIGN)); |
| 2802 | pars.t_guard := 60.0; |
| 2803 | vc_conn := f_start_handler(refers(f_TC_conn_fail_crit), pars); |
| 2804 | vc_conn.done; |
| 2805 | } |
| 2806 | |
Harald Welte | 93640c6 | 2018-02-25 16:59:33 +0100 | [diff] [blame] | 2807 | /*********************************************************************** |
| 2808 | * Paging |
| 2809 | ***********************************************************************/ |
| 2810 | |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 2811 | function tmsi_is_dummy(TMSIP_TMSI_V tmsi) return boolean { |
| 2812 | if (tmsi == 'FFFFFFFF'O) { |
| 2813 | return true; |
| 2814 | } else { |
| 2815 | return false; |
| 2816 | } |
| 2817 | } |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 2818 | |
Philipp Maier | 82cb0b1 | 2018-08-31 14:41:39 +0200 | [diff] [blame] | 2819 | type record allowedFn { integer frame_nr } |
| 2820 | template allowedFn bs_ag_blks_res_0 := { frame_nr := (6, 12, 16, 22, 26, 32, 36, 42, 46) } |
| 2821 | template allowedFn bs_ag_blks_res_1 := { frame_nr := (12, 16, 22, 26, 32, 36, 42, 46) } |
| 2822 | template allowedFn bs_ag_blks_res_2 := { frame_nr := (16, 22, 26, 32, 36, 42, 46) } |
| 2823 | template allowedFn bs_ag_blks_res_3 := { frame_nr := (22, 26, 32, 36, 42, 46) } |
| 2824 | template allowedFn bs_ag_blks_res_4 := { frame_nr := (26, 32, 36, 42, 46) } |
| 2825 | template allowedFn bs_ag_blks_res_5 := { frame_nr := (32, 36, 42, 46) } |
| 2826 | template allowedFn bs_ag_blks_res_6 := { frame_nr := (36, 42, 46) } |
| 2827 | template allowedFn bs_ag_blks_res_7 := { frame_nr := (42, 46) } |
| 2828 | function check_pch_fn(integer frame_nr, integer bs_ag_blks_res) runs on test_CT |
| 2829 | { |
| 2830 | var integer frame_nr_51; |
| 2831 | frame_nr_51 := frame_nr mod 51 |
| 2832 | |
| 2833 | var allowedFn fn_check; |
| 2834 | fn_check.frame_nr := frame_nr_51; |
| 2835 | |
| 2836 | if (bs_ag_blks_res < 0 or bs_ag_blks_res > 7) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 2837 | 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] | 2838 | return; |
| 2839 | } |
| 2840 | |
| 2841 | if (bs_ag_blks_res == 0 and match(fn_check, bs_ag_blks_res_0)) { |
| 2842 | return; |
| 2843 | } |
| 2844 | if (bs_ag_blks_res == 1 and match(fn_check, bs_ag_blks_res_1)) { |
| 2845 | return; |
| 2846 | } |
| 2847 | if (bs_ag_blks_res == 2 and match(fn_check, bs_ag_blks_res_2)) { |
| 2848 | return; |
| 2849 | } |
| 2850 | if (bs_ag_blks_res == 3 and match(fn_check, bs_ag_blks_res_3)) { |
| 2851 | return; |
| 2852 | } |
| 2853 | if (bs_ag_blks_res == 4 and match(fn_check, bs_ag_blks_res_4)) { |
| 2854 | return; |
| 2855 | } |
| 2856 | if (bs_ag_blks_res == 5 and match(fn_check, bs_ag_blks_res_5)) { |
| 2857 | return; |
| 2858 | } |
| 2859 | if (bs_ag_blks_res == 6 and match(fn_check, bs_ag_blks_res_6)) { |
| 2860 | return; |
| 2861 | } |
| 2862 | if (bs_ag_blks_res == 7 and match(fn_check, bs_ag_blks_res_7)) { |
| 2863 | return; |
| 2864 | } |
| 2865 | |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 2866 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "received paging on AGCH"); |
Philipp Maier | 82cb0b1 | 2018-08-31 14:41:39 +0200 | [diff] [blame] | 2867 | return; |
| 2868 | } |
| 2869 | |
| 2870 | 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] | 2871 | runs on test_CT { |
| 2872 | var L1ctlDlMessage dl; |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 2873 | [] 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] | 2874 | repeat; |
| 2875 | } |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 2876 | [] 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] | 2877 | var octetstring without_plen := |
| 2878 | substr(dl.payload.data_ind.payload, 1, lengthof(dl.payload.data_ind.payload)-1); |
| 2879 | 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] | 2880 | |
| 2881 | check_pch_fn(dl.dl_info.frame_nr, cfg.bs_ag_blks_res); |
| 2882 | |
Vadim Yanitskiy | 36aa07c | 2020-03-31 14:33:43 +0700 | [diff] [blame] | 2883 | if (match(rr, tr_PAGING_REQ1(tr_MI_LV(t_MI_NoIdentity(?))))) { |
| 2884 | /* Ignore empty RR Paging Request (PCH filling) messages. |
| 2885 | * TODO: does it make sense to count them? */ |
| 2886 | } else if (match(rr, tr_PAGING_REQ1)) { |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 2887 | num_paging_rcv_msgs := num_paging_rcv_msgs + 1; |
| 2888 | num_paging_rcv_ids := num_paging_rcv_ids + 1; |
Vadim Yanitskiy | d665c23 | 2020-03-30 14:40:41 +0700 | [diff] [blame] | 2889 | if (ispresent(rr.msgs.rrm.pagingReq_Type1.mobileIdentity2)) { |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 2890 | num_paging_rcv_ids := num_paging_rcv_ids + 1; |
| 2891 | } |
| 2892 | } else if (match(rr, tr_PAGING_REQ2)) { |
| 2893 | num_paging_rcv_msgs := num_paging_rcv_msgs + 1; |
| 2894 | if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type2.mobileIdentity1)) { |
| 2895 | num_paging_rcv_ids := num_paging_rcv_ids + 1; |
| 2896 | } |
| 2897 | if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type2.mobileIdentity2)) { |
| 2898 | num_paging_rcv_ids := num_paging_rcv_ids + 1; |
| 2899 | } |
Vadim Yanitskiy | d665c23 | 2020-03-30 14:40:41 +0700 | [diff] [blame] | 2900 | if (ispresent(rr.msgs.rrm.pagingReq_Type2.mobileIdentity3)) { |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 2901 | num_paging_rcv_ids := num_paging_rcv_ids + 1; |
| 2902 | } |
| 2903 | } else if (match(rr, tr_PAGING_REQ3)) { |
| 2904 | num_paging_rcv_msgs := num_paging_rcv_msgs + 1; |
| 2905 | if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type3.mobileIdentity1)) { |
| 2906 | num_paging_rcv_ids := num_paging_rcv_ids + 1; |
| 2907 | } |
| 2908 | if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type3.mobileIdentity2)) { |
| 2909 | num_paging_rcv_ids := num_paging_rcv_ids + 1; |
| 2910 | } |
| 2911 | if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type3.mobileIdentity3)) { |
| 2912 | num_paging_rcv_ids := num_paging_rcv_ids + 1; |
| 2913 | } |
| 2914 | if (not tmsi_is_dummy(rr.msgs.rrm.pagingReq_Type3.mobileIdentity4)) { |
| 2915 | num_paging_rcv_ids := num_paging_rcv_ids + 1; |
| 2916 | } |
| 2917 | } |
| 2918 | repeat; |
| 2919 | } |
| 2920 | } |
| 2921 | |
| 2922 | type record PagingTestCfg { |
| 2923 | boolean combined_ccch, |
| 2924 | integer bs_ag_blks_res, |
| 2925 | float load_factor, |
| 2926 | boolean exp_load_ind, |
| 2927 | boolean exp_overload, |
| 2928 | boolean use_tmsi |
| 2929 | } |
| 2930 | |
| 2931 | type record PagingTestState { |
| 2932 | integer num_paging_sent, |
| 2933 | integer num_paging_rcv_msgs, |
| 2934 | integer num_paging_rcv_ids, |
| 2935 | integer num_overload |
| 2936 | } |
| 2937 | |
| 2938 | /* receive + ignore RSL RF RES IND */ |
| 2939 | altstep as_rsl_res_ind() runs on test_CT { |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 2940 | [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_RF_RES_IND)) { |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 2941 | repeat; |
| 2942 | } |
| 2943 | } |
| 2944 | |
| 2945 | /* Helper function for paging related testing */ |
| 2946 | 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] | 2947 | f_init(); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 2948 | f_init_l1ctl(); |
| 2949 | f_l1_tune(L1CTL); |
| 2950 | |
| 2951 | var PagingTestState st := { |
| 2952 | num_paging_sent := 0, |
| 2953 | num_paging_rcv_msgs := 0, |
| 2954 | num_paging_rcv_ids := 0, |
| 2955 | num_overload := 0 |
| 2956 | }; |
| 2957 | |
| 2958 | var float max_pch_blocks_per_sec := f_pch_block_rate_est(cfg.combined_ccch, cfg.bs_ag_blks_res); |
| 2959 | var float max_pch_imsi_per_sec; |
| 2960 | if (cfg.use_tmsi) { |
| 2961 | max_pch_imsi_per_sec := max_pch_blocks_per_sec * 4.0; /* Type 3 */ |
| 2962 | } else { |
| 2963 | max_pch_imsi_per_sec := max_pch_blocks_per_sec * 2.0; /* Type 1 */ |
| 2964 | } |
| 2965 | var float pch_blocks_per_sec := max_pch_imsi_per_sec * cfg.load_factor; |
| 2966 | var float interval := 1.0 / pch_blocks_per_sec; |
Pau Espin Pedrol | 9c3ff4e | 2018-09-26 18:30:16 +0200 | [diff] [blame] | 2967 | var float time_total := 20.0; |
| 2968 | var integer pkt_total := float2int(time_total * pch_blocks_per_sec); |
| 2969 | 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] | 2970 | |
Pau Espin Pedrol | 9c3ff4e | 2018-09-26 18:30:16 +0200 | [diff] [blame] | 2971 | timer T_total := 300.0; /* big value (far bigger than time_total), used to count elapsed time */ |
| 2972 | T_total.start; |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 2973 | |
Pau Espin Pedrol | 9c3ff4e | 2018-09-26 18:30:16 +0200 | [diff] [blame] | 2974 | timer T_itv := 0.0; |
| 2975 | T_itv.start; |
| 2976 | while (st.num_paging_sent < pkt_total) { |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 2977 | alt { |
| 2978 | /* check for presence of CCCH LOAD IND (paging load) */ |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 2979 | [cfg.exp_overload] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_PAGING_LOAD_IND(0))) { |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 2980 | st.num_overload := st.num_overload + 1; |
| 2981 | repeat; |
| 2982 | } |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 2983 | [not cfg.exp_overload] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_PAGING_LOAD_IND(0))) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 2984 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected PCH Overload"); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 2985 | } |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 2986 | [cfg.exp_load_ind] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_PAGING_LOAD_IND)) { |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 2987 | log("Rx LOAD_IND"); |
| 2988 | /* FIXME: analyze/verify interval + contents */ |
| 2989 | repeat; |
| 2990 | } |
| 2991 | /* check if paging requests arrive on Um side */ |
Philipp Maier | 82cb0b1 | 2018-08-31 14:41:39 +0200 | [diff] [blame] | 2992 | [] 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] | 2993 | [] L1CTL.receive { repeat; } |
Pau Espin Pedrol | 9c3ff4e | 2018-09-26 18:30:16 +0200 | [diff] [blame] | 2994 | [] T_itv.timeout { |
| 2995 | /* Send paging cmds based on elapsed time */ |
| 2996 | var integer new_sent := f_min(pkt_total, float2int(T_total.read * pch_blocks_per_sec) + 1); |
| 2997 | while (st.num_paging_sent < new_sent) { |
Vadim Yanitskiy | cc4623d | 2020-03-28 06:14:06 +0700 | [diff] [blame] | 2998 | var MobileIdentityV mi; |
| 2999 | |
Pau Espin Pedrol | 9c3ff4e | 2018-09-26 18:30:16 +0200 | [diff] [blame] | 3000 | /* build mobile Identity */ |
Pau Espin Pedrol | 9c3ff4e | 2018-09-26 18:30:16 +0200 | [diff] [blame] | 3001 | if (cfg.use_tmsi) { |
Vadim Yanitskiy | cc4623d | 2020-03-28 06:14:06 +0700 | [diff] [blame] | 3002 | mi := valueof(t_MI_TMSI(f_rnd_octstring(4))); |
Pau Espin Pedrol | 9c3ff4e | 2018-09-26 18:30:16 +0200 | [diff] [blame] | 3003 | } else { |
Vadim Yanitskiy | cc4623d | 2020-03-28 06:14:06 +0700 | [diff] [blame] | 3004 | 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] | 3005 | } |
Pau Espin Pedrol | 9c3ff4e | 2018-09-26 18:30:16 +0200 | [diff] [blame] | 3006 | |
| 3007 | /* Send RSL PAGING COMMAND */ |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 3008 | RSL_CCHAN.send(ts_ASP_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] | 3009 | |
| 3010 | st.num_paging_sent := st.num_paging_sent + 1; |
| 3011 | } |
| 3012 | if (st.num_paging_sent < pkt_total) { |
| 3013 | /* Wait for interval to next PAGING COMMAND */ |
| 3014 | var float time_now := T_total.read; |
| 3015 | var float next_sched := int2float(st.num_paging_sent)*interval; |
| 3016 | if (next_sched > time_now) { |
| 3017 | T_itv.start(next_sched - time_now); |
| 3018 | } else { |
| 3019 | T_itv.start(0.0); |
| 3020 | } |
| 3021 | } else { |
| 3022 | /* We are done, no need to keep counting */ |
| 3023 | T_total.stop; |
| 3024 | } |
| 3025 | } |
| 3026 | [] T_total.timeout { } |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3027 | [] as_rsl_res_ind(); |
| 3028 | } |
| 3029 | } |
| 3030 | |
| 3031 | /* wait for max 18s for paging queue to drain (size: 200, ~ 13 per s -> 15s) */ |
| 3032 | timer T_wait := 18.0; |
| 3033 | T_wait.start; |
| 3034 | alt { |
Philipp Maier | 82cb0b1 | 2018-08-31 14:41:39 +0200 | [diff] [blame] | 3035 | [] 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] | 3036 | [] L1CTL.receive { repeat; } |
| 3037 | /* 65535 == empty paging queue, we can terminate*/ |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 3038 | [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_PAGING_LOAD_IND(65535))) { } |
| 3039 | [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_PAGING_LOAD_IND)) { repeat; } |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3040 | [] T_wait.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3041 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Waiting for empty paging queue"); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3042 | } |
| 3043 | [] as_rsl_res_ind(); |
| 3044 | } |
| 3045 | |
| 3046 | log("num_paging_sent=", st.num_paging_sent, " rcvd_msgs=", st.num_paging_rcv_msgs, |
| 3047 | " rcvd_ids=", st.num_paging_rcv_ids); |
| 3048 | return st; |
| 3049 | } |
| 3050 | |
| 3051 | /* Create ~ 80% paging load (IMSI only) sustained for about 20s, verifying that |
| 3052 | * - the number of Mobile Identities on Um PCH match the number of pages on RSL |
| 3053 | * - that CCCH LOAD IND (PCH) are being generated |
| 3054 | * - that CCCH LOAD IND (PCH) [no load] is received after paging flood is over */ |
| 3055 | testcase TC_paging_imsi_80percent() runs on test_CT { |
Philipp Maier | d65d056 | 2018-08-30 16:25:47 +0200 | [diff] [blame] | 3056 | var SystemInformation si3 := valueof(ts_SI3_default); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3057 | var PagingTestCfg cfg := { |
| 3058 | combined_ccch := true, |
Philipp Maier | d65d056 | 2018-08-30 16:25:47 +0200 | [diff] [blame] | 3059 | 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] | 3060 | load_factor := 0.8, |
| 3061 | exp_load_ind := true, |
| 3062 | exp_overload := false, |
| 3063 | use_tmsi := false |
| 3064 | }; |
| 3065 | var PagingTestState st := f_TC_paging(cfg); |
| 3066 | if (st.num_paging_sent != st.num_paging_rcv_ids) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3067 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Expected ", st.num_paging_sent, " pagings but have ", |
| 3068 | st.num_paging_rcv_ids)); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3069 | } else { |
| 3070 | setverdict(pass); |
| 3071 | } |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3072 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3073 | } |
| 3074 | |
| 3075 | /* Create ~ 80% paging load (TMSI only) sustained for about 20s, verifying that |
| 3076 | * - the number of Mobile Identities on Um PCH match the number of pages on RSL |
| 3077 | * - that CCCH LOAD IND (PCH) are being generated |
| 3078 | * - that CCCH LOAD IND (PCH) [no load] is received after paging flood is over */ |
| 3079 | testcase TC_paging_tmsi_80percent() runs on test_CT { |
Philipp Maier | d65d056 | 2018-08-30 16:25:47 +0200 | [diff] [blame] | 3080 | var SystemInformation si3 := valueof(ts_SI3_default); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3081 | var PagingTestCfg cfg := { |
| 3082 | combined_ccch := true, |
Philipp Maier | d65d056 | 2018-08-30 16:25:47 +0200 | [diff] [blame] | 3083 | 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] | 3084 | load_factor := 0.8, |
| 3085 | exp_load_ind := true, |
| 3086 | exp_overload := false, |
| 3087 | use_tmsi := true |
| 3088 | }; |
| 3089 | var PagingTestState st := f_TC_paging(cfg); |
| 3090 | if (st.num_paging_sent != st.num_paging_rcv_ids) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3091 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, log2str("Expected ", st.num_paging_sent, " pagings but have ", |
| 3092 | st.num_paging_rcv_ids)); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3093 | } else { |
| 3094 | setverdict(pass); |
| 3095 | } |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3096 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3097 | } |
| 3098 | |
| 3099 | /* Create ~ 200% paging load (IMSI only) sustained for about 20s, verifying that |
| 3100 | * - the number of Mobile Identities on Um PCH are ~ 82% of the number of pages on RSL |
| 3101 | * - that CCCH LOAD IND (PCH) are being generated and reach 0 at some point |
| 3102 | * - that CCCH LOAD IND (PCH) [no load] is received after paging flood is over */ |
| 3103 | testcase TC_paging_imsi_200percent() runs on test_CT { |
Philipp Maier | d65d056 | 2018-08-30 16:25:47 +0200 | [diff] [blame] | 3104 | var SystemInformation si3 := valueof(ts_SI3_default); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3105 | var PagingTestCfg cfg := { |
| 3106 | combined_ccch := true, |
Philipp Maier | d65d056 | 2018-08-30 16:25:47 +0200 | [diff] [blame] | 3107 | 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] | 3108 | load_factor := 2.0, |
| 3109 | exp_load_ind := true, |
| 3110 | exp_overload := true, |
| 3111 | use_tmsi := false |
| 3112 | }; |
| 3113 | var PagingTestState st := f_TC_paging(cfg); |
| 3114 | /* We expect about 80-85% to pass, given that we can fill the paging buffer of 200 |
| 3115 | * slots and will fully drain that buffer before returning */ |
Pau Espin Pedrol | 9c3ff4e | 2018-09-26 18:30:16 +0200 | [diff] [blame] | 3116 | 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] | 3117 | if (not match(st.num_paging_rcv_ids, tpl)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3118 | 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] | 3119 | } else { |
| 3120 | setverdict(pass); |
| 3121 | } |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3122 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3123 | } |
| 3124 | |
| 3125 | /* Create ~ 200% paging load (TMSI only) sustained for about 20s, verifying that |
| 3126 | * - the number of Mobile Identities on Um PCH are ~ 82% of the number of pages on RSL |
| 3127 | * - that CCCH LOAD IND (PCH) are being generated and reach 0 at some point |
| 3128 | * - that CCCH LOAD IND (PCH) [no load] is received after paging flood is over */ |
| 3129 | testcase TC_paging_tmsi_200percent() runs on test_CT { |
Philipp Maier | d65d056 | 2018-08-30 16:25:47 +0200 | [diff] [blame] | 3130 | var SystemInformation si3 := valueof(ts_SI3_default); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3131 | var PagingTestCfg cfg := { |
| 3132 | combined_ccch := true, |
Philipp Maier | d65d056 | 2018-08-30 16:25:47 +0200 | [diff] [blame] | 3133 | 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] | 3134 | load_factor := 2.0, |
| 3135 | exp_load_ind := true, |
| 3136 | exp_overload := true, |
| 3137 | use_tmsi := true |
| 3138 | }; |
| 3139 | var PagingTestState st := f_TC_paging(cfg); |
| 3140 | /* We expect about 70% to pass, given that we can fill the paging buffer of 200 |
| 3141 | * slots and will fully drain that buffer before returning */ |
Pau Espin Pedrol | 9c3ff4e | 2018-09-26 18:30:16 +0200 | [diff] [blame] | 3142 | 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] | 3143 | if (not match(st.num_paging_rcv_ids, tpl)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3144 | 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] | 3145 | } else { |
| 3146 | setverdict(pass); |
| 3147 | } |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3148 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3149 | } |
| 3150 | |
| 3151 | |
Harald Welte | 93640c6 | 2018-02-25 16:59:33 +0100 | [diff] [blame] | 3152 | /*********************************************************************** |
| 3153 | * Immediate Assignment / AGCH |
| 3154 | ***********************************************************************/ |
Vadim Yanitskiy | a9eeb7b | 2020-05-27 01:42:49 +0700 | [diff] [blame] | 3155 | private const MobileAllocation c_MA_null := { |
Harald Welte | e8d750e | 2018-06-10 21:41:35 +0200 | [diff] [blame] | 3156 | len := 0, |
| 3157 | ma := ''B |
| 3158 | } |
Harald Welte | 93640c6 | 2018-02-25 16:59:33 +0100 | [diff] [blame] | 3159 | |
Vadim Yanitskiy | 9248456 | 2020-05-27 02:05:04 +0700 | [diff] [blame] | 3160 | template (value) ChannelDescription ts_ChanDescH0(template (value) RslChannelNr chan_nr, uint3_t tsc := 7, |
Vadim Yanitskiy | e9f68be | 2020-05-27 02:08:35 +0700 | [diff] [blame^] | 3161 | uint12_t arfcn := mp_trx0_arfcn) := { |
Harald Welte | e8d750e | 2018-06-10 21:41:35 +0200 | [diff] [blame] | 3162 | chan_nr := chan_nr, |
| 3163 | tsc := tsc, |
| 3164 | h := false, |
| 3165 | arfcn := arfcn, |
| 3166 | maio_hsn := omit |
| 3167 | } |
| 3168 | |
Vadim Yanitskiy | 9248456 | 2020-05-27 02:05:04 +0700 | [diff] [blame] | 3169 | template (value) ChannelDescription ts_ChanDescH1(template (value) RslChannelNr chan_nr, uint3_t tsc := 7, |
| 3170 | template (value) MaioHsn maio_hsn) := { |
| 3171 | chan_nr := chan_nr, |
| 3172 | tsc := tsc, |
| 3173 | h := true, |
| 3174 | arfcn := omit, |
| 3175 | maio_hsn := maio_hsn |
| 3176 | } |
| 3177 | |
Harald Welte | e8d750e | 2018-06-10 21:41:35 +0200 | [diff] [blame] | 3178 | private function f_fmt_ia_stats(integer num_tx, integer num_rx, integer num_del) return charstring { |
| 3179 | return int2str(num_tx) & " sent, " |
| 3180 | & int2str(num_rx) & " received, " |
| 3181 | & int2str(num_del) & " deleted"; |
| 3182 | } |
| 3183 | |
| 3184 | private function f_TC_imm_ass(integer num_total, float sleep_s, float exp_pass) runs on test_CT { |
| 3185 | var L1ctlDlMessage l1_dl; |
| 3186 | timer T := 10.0; |
| 3187 | var integer num_tx := 0; |
| 3188 | var integer num_rx := 0; |
| 3189 | var integer num_del := 0; |
| 3190 | var charstring res_str; |
| 3191 | var float rx_ratio; |
| 3192 | |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 3193 | f_init(); |
Harald Welte | e8d750e | 2018-06-10 21:41:35 +0200 | [diff] [blame] | 3194 | f_init_l1ctl(); |
| 3195 | f_l1_tune(L1CTL); |
| 3196 | |
| 3197 | for (var integer i := 0; i < num_total; i := i+1) { |
Vadim Yanitskiy | 9248456 | 2020-05-27 02:05:04 +0700 | [diff] [blame] | 3198 | var ChannelDescription ch_desc := valueof(ts_ChanDescH0(valueof(t_RslChanNr_SDCCH4(0, 0)))); |
Harald Welte | e8d750e | 2018-06-10 21:41:35 +0200 | [diff] [blame] | 3199 | var GsmRrMessage ia := valueof(ts_IMM_ASS(42, i, 5, ch_desc, c_MA_null)); |
| 3200 | var octetstring ia_enc := enc_GsmRrMessage(ia); |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 3201 | RSL_CCHAN.send(ts_ASP_RSL_UD(ts_RSL_IMM_ASSIGN(ia_enc, 0))); |
Harald Welte | e8d750e | 2018-06-10 21:41:35 +0200 | [diff] [blame] | 3202 | num_tx := num_tx+1; |
| 3203 | f_sleep(sleep_s); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3204 | } |
| 3205 | /* FIXME: check if imm.ass arrive on Um side */ |
Harald Welte | e8d750e | 2018-06-10 21:41:35 +0200 | [diff] [blame] | 3206 | T.start; |
| 3207 | alt { |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 3208 | [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_DELETE_IND(?, 0))) { |
Harald Welte | e8d750e | 2018-06-10 21:41:35 +0200 | [diff] [blame] | 3209 | num_del := num_del+1; |
| 3210 | repeat; |
| 3211 | } |
| 3212 | [] RSL_CCHAN.receive { |
| 3213 | repeat; |
| 3214 | } |
| 3215 | [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_PCH_AGCH(0), ?)) -> value l1_dl { |
| 3216 | /* somehow dec_SystemInformation will try to decode even non-RR as SI */ |
| 3217 | var GsmRrMessage rr := dec_GsmRrMessage(l1_dl.payload.data_ind.payload); |
| 3218 | if (not match(rr, tr_IMM_ASS(42, ?, 5, ?, ?))) { |
| 3219 | /* FIXME: Why are we seeing paging requests on PCH/AGCH? */ |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3220 | //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] | 3221 | } else { |
| 3222 | num_rx := num_rx+1; |
| 3223 | } |
| 3224 | repeat; |
| 3225 | } |
| 3226 | [] L1CTL.receive { repeat; } |
| 3227 | [] T.timeout { } |
| 3228 | } |
| 3229 | res_str := f_fmt_ia_stats(num_tx, num_rx, num_del); |
| 3230 | log("AGCH test: " & res_str); |
| 3231 | if (num_rx + num_del != num_tx) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3232 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "RX + DEL != TX ?!?: " & res_str); |
Harald Welte | e8d750e | 2018-06-10 21:41:35 +0200 | [diff] [blame] | 3233 | } |
| 3234 | rx_ratio := int2float(num_rx) / int2float(num_tx); |
| 3235 | 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] | 3236 | 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] | 3237 | } else { |
| 3238 | setverdict(pass); |
| 3239 | } |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3240 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3241 | } |
| 3242 | |
Harald Welte | e8d750e | 2018-06-10 21:41:35 +0200 | [diff] [blame] | 3243 | /* send a long burst of 1000 IMM.ASS with 20ms spacing (50 per s); expect 75% of them to be deleted */ |
| 3244 | testcase TC_imm_ass_1000_20ms() runs on test_CT { |
| 3245 | f_TC_imm_ass(1000, 0.02, 0.25); |
| 3246 | } |
| 3247 | |
| 3248 | /* send a short burst of 200 IMM.ASS without any spacing; expect 95% of them to be deleted */ |
| 3249 | testcase TC_imm_ass_200_0ms() runs on test_CT { |
| 3250 | f_TC_imm_ass(200, 0.0, 0.05); |
| 3251 | } |
| 3252 | |
| 3253 | /* send 150 IMM.ASS at rate of 13/s; expect none of them to be deleted */ |
| 3254 | testcase TC_imm_ass_200_76ms() runs on test_CT { |
| 3255 | f_TC_imm_ass(150, 0.076, 1.00); |
| 3256 | } |
| 3257 | |
| 3258 | |
| 3259 | |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 3260 | /*********************************************************************** |
| 3261 | * BCCH |
| 3262 | ***********************************************************************/ |
| 3263 | |
| 3264 | /* tuple of Frame Number + decoded SI */ |
| 3265 | type record SystemInformationFn { |
| 3266 | GsmFrameNumber frame_number, |
| 3267 | SystemInformation si |
| 3268 | } |
| 3269 | |
| 3270 | /* an arbitrary-length vector of decoded SI + gsmtap header */ |
| 3271 | type record of SystemInformationFn SystemInformationVector; |
| 3272 | |
| 3273 | /* an array of SI-vectors indexed by TC value */ |
| 3274 | type SystemInformationVector SystemInformationVectorPerTc[8]; |
| 3275 | |
| 3276 | /* determine if a given SI vector contains given SI type at least once */ |
| 3277 | function f_si_vecslot_contains(SystemInformationVector arr, RrMessageType key, boolean bcch_ext := false) return boolean { |
| 3278 | for (var integer i:= 0; i< sizeof(arr); i := i + 1) { |
| 3279 | var integer fn_mod51 := arr[i].frame_number mod 51; |
| 3280 | if (not bcch_ext and fn_mod51 == 2 or |
| 3281 | bcch_ext and fn_mod51 == 6) { |
| 3282 | if (arr[i].si.header.message_type == key) { |
| 3283 | return true; |
| 3284 | } |
| 3285 | } |
| 3286 | } |
| 3287 | return false; |
| 3288 | } |
| 3289 | |
| 3290 | /* ensure a given TC slot of the SI vector contains given SI type at least once at TC */ |
| 3291 | function f_ensure_si_vec_contains(SystemInformationVectorPerTc arr, integer tc, RrMessageType key, boolean ext_bcch := false) { |
| 3292 | if (not f_si_vecslot_contains(arr[tc], key, ext_bcch)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3293 | 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] | 3294 | } |
| 3295 | } |
| 3296 | |
| 3297 | /* check if a given SI vector contains given SI type at least once on any TC */ |
| 3298 | function f_si_vec_contains(SystemInformationVectorPerTc arr, RrMessageType key) return boolean { |
| 3299 | for (var integer tc:= 0; tc < sizeof(arr); tc := tc + 1) { |
| 3300 | if (f_si_vecslot_contains(arr[tc], key) or |
| 3301 | f_si_vecslot_contains(arr[tc], key, true)) { |
| 3302 | return true; |
| 3303 | } |
| 3304 | } |
| 3305 | return false; |
| 3306 | } |
| 3307 | |
| 3308 | /* determine if a given SI vector contains given SI type at least N of M times */ |
| 3309 | function f_si_vecslot_contains_n_of_m(SystemInformationVector arr, RrMessageType key, boolean bcch_ext := false, integer n := 1, integer m := 4) return boolean { |
| 3310 | var integer count := 0; |
| 3311 | if (sizeof(arr) < m) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3312 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Error: Insufficient SI in array"); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 3313 | } |
| 3314 | for (var integer i:= 0; i < m; i := i + 1) { |
| 3315 | var integer fn_mod51 := arr[i].frame_number mod 51; |
| 3316 | if (not bcch_ext and fn_mod51 == 2 or |
| 3317 | bcch_ext and fn_mod51 == 6) { |
| 3318 | if (arr[i].si.header.message_type == key) { |
| 3319 | count := count + 1; |
| 3320 | } |
| 3321 | } |
| 3322 | } |
| 3323 | if (count >= n) { |
| 3324 | return true; |
| 3325 | } else { |
| 3326 | return false; |
| 3327 | } |
| 3328 | } |
| 3329 | |
| 3330 | /* ensure a given TC slot of the SI vector contains given SI type at least N out of M times at TC */ |
| 3331 | function f_ensure_si_vec_contains_n_of_m(SystemInformationVectorPerTc arr, integer tc, RrMessageType key, boolean ext_bcch := false, integer n, integer m) { |
| 3332 | 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] | 3333 | 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] | 3334 | } |
| 3335 | } |
| 3336 | |
| 3337 | /* determine if a given SI vector contains given SI type at least once */ |
| 3338 | function f_si_vecslot_contains_only(SystemInformationVector arr, RrMessageType key, boolean bcch_ext := false) return boolean { |
| 3339 | for (var integer i:= 0; i< sizeof(arr); i := i + 1) { |
| 3340 | var integer fn_mod51 := arr[i].frame_number mod 51; |
| 3341 | if (not bcch_ext and fn_mod51 == 2 or |
| 3342 | bcch_ext and fn_mod51 == 6) { |
| 3343 | if (arr[i].si.header.message_type != key) { |
| 3344 | return false; |
| 3345 | } |
| 3346 | } |
| 3347 | } |
| 3348 | return true; |
| 3349 | } |
| 3350 | |
| 3351 | /* ensure a given TC slot of the SI vector contains only given SI type */ |
| 3352 | function f_ensure_si_vec_contains_only(SystemInformationVectorPerTc arr, integer tc, RrMessageType key, boolean ext_bcch := false) { |
| 3353 | if (not f_si_vecslot_contains_only(arr[tc], key, ext_bcch)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3354 | 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] | 3355 | } |
| 3356 | } |
| 3357 | |
| 3358 | /* SI configuration of cell, against which we validate actual SI messages */ |
| 3359 | type set SystemInformationConfig { |
| 3360 | boolean bcch_extended, |
| 3361 | boolean si1_present, |
| 3362 | boolean si2bis_present, |
| 3363 | boolean si2ter_present, |
| 3364 | boolean si2quater_present, |
| 3365 | boolean si7_present, |
| 3366 | boolean si8_present, |
| 3367 | boolean si9_present, |
| 3368 | boolean si13_present, |
| 3369 | boolean si13alt_present, |
| 3370 | boolean si15_present, |
| 3371 | boolean si16_present, |
| 3372 | boolean si17_present, |
| 3373 | boolean si2n_present, |
| 3374 | boolean si21_present, |
| 3375 | boolean si22_present |
| 3376 | } |
| 3377 | |
| 3378 | /* validate the SI scheduling according to TS 45.002 version 14.1.0 Release 14, Section 6.3.1.3 */ |
| 3379 | function f_validate_si_scheduling(SystemInformationConfig cfg, SystemInformationVectorPerTc si_per_tc) { |
| 3380 | var integer i; |
| 3381 | for (i := 0; i < sizeof(si_per_tc); i := i + 1) { |
| 3382 | if (sizeof(si_per_tc[i]) == 0) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3383 | 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] | 3384 | } |
| 3385 | } |
| 3386 | if (cfg.si1_present) { |
| 3387 | /* ii) System Information Type 1 needs to be sent if frequency hopping is in use or |
| 3388 | * when the NCH is present in a cell. If the MS finds another message on BCCH Norm |
| 3389 | * when TC = 0, it can assume that System Information Type 1 is not in use. */ |
| 3390 | f_ensure_si_vec_contains(si_per_tc, 0, SYSTEM_INFORMATION_TYPE_1); |
| 3391 | /* make sure *ALL* contain SI1 */ |
| 3392 | f_ensure_si_vec_contains_only(si_per_tc, 0, SYSTEM_INFORMATION_TYPE_1); |
| 3393 | } |
| 3394 | f_ensure_si_vec_contains(si_per_tc, 1, SYSTEM_INFORMATION_TYPE_2); |
| 3395 | /* iii) A SI 2 message will be sent at least every time TC = 1 */ |
| 3396 | f_ensure_si_vec_contains(si_per_tc, 2, SYSTEM_INFORMATION_TYPE_3); |
| 3397 | f_ensure_si_vec_contains(si_per_tc, 6, SYSTEM_INFORMATION_TYPE_3); |
| 3398 | f_ensure_si_vec_contains(si_per_tc, 3, SYSTEM_INFORMATION_TYPE_4); |
| 3399 | f_ensure_si_vec_contains(si_per_tc, 7, SYSTEM_INFORMATION_TYPE_4); |
| 3400 | |
| 3401 | /* iii) System information type 2 bis or 2 ter messages are sent if needed, as determined by the |
| 3402 | * system operator. If only one of them is needed, it is sent when TC = 5. If both are |
| 3403 | * needed, 2bis is sent when TC = 5 and 2ter is sent at least once within any of 4 |
| 3404 | * consecutive occurrences of TC = 4. */ |
| 3405 | if (cfg.si2bis_present and not cfg.si2ter_present) { |
| 3406 | f_ensure_si_vec_contains(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2bis); |
| 3407 | } else if (cfg.si2ter_present and not cfg.si2bis_present) { |
| 3408 | f_ensure_si_vec_contains(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2ter); |
| 3409 | } else if (cfg.si2ter_present and cfg.si2bis_present) { |
| 3410 | f_ensure_si_vec_contains(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2bis); |
| 3411 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_2ter, false, 1, 4); |
| 3412 | } |
| 3413 | |
| 3414 | if (cfg.si7_present or cfg.si8_present) { |
| 3415 | /* vi) Use of System Information type 7 and 8 is not always necessary. It is necessary |
| 3416 | * if System Information type 4 does not contain all information needed for cell |
| 3417 | * selection and reselection. */ |
| 3418 | if (not cfg.bcch_extended) { |
| 3419 | testcase.stop("Error: SI7/SI8 require BCCH Extd."); |
| 3420 | } |
| 3421 | if (cfg.si7_present) { |
| 3422 | f_ensure_si_vec_contains(si_per_tc, 7, SYSTEM_INFORMATION_TYPE_7, true); |
| 3423 | } |
| 3424 | if (cfg.si8_present) { |
| 3425 | f_ensure_si_vec_contains(si_per_tc, 3, SYSTEM_INFORMATION_TYPE_8, true); |
| 3426 | } |
| 3427 | } |
| 3428 | |
| 3429 | if (cfg.si2quater_present) { |
| 3430 | /* iii) System information type 2 quater is sent if needed, as determined by the system |
| 3431 | * operator. If sent on BCCH Norm, it shall be sent when TC = 5 if neither of 2bis |
| 3432 | * and 2ter are used, otherwise it shall be sent at least once within any of 4 |
| 3433 | * consecutive occurrences of TC = 4. If sent on BCCH Ext, it is sent at least once |
| 3434 | * within any of 4 consecutive occurrences of TC = 5. */ |
| 3435 | if (not (cfg.bcch_extended)) { |
| 3436 | if (not (cfg.si2bis_present or cfg.si2ter_present)) { |
| 3437 | f_ensure_si_vec_contains(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2quater); |
| 3438 | } else { |
| 3439 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_2quater, false, 1, 4); |
| 3440 | } |
| 3441 | } else { |
| 3442 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 5, SYSTEM_INFORMATION_TYPE_2quater, true, 1, 4); |
| 3443 | } |
| 3444 | } |
| 3445 | if (cfg.si9_present) { |
| 3446 | /* vi) System Information type 9 is sent in those blocks with TC = 4 which are specified |
| 3447 | * in system information type 3 as defined in 3GPP TS 44.018. */ |
| 3448 | f_ensure_si_vec_contains(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_9); // FIXME SI3 |
| 3449 | } |
| 3450 | if (cfg.si13_present) { |
| 3451 | /* vii) System Information type 13 is only related to the GPRS service. System Information |
| 3452 | * Type 13 need only be sent if GPRS support is indicated in one or more of System |
| 3453 | * Information Type 3 or 4 or 7 or 8 messages. These messages also indicate if the |
| 3454 | * message is sent on the BCCH Norm or if the message is transmitted on the BCCH Ext. |
| 3455 | * In the case that the message is sent on the BCCH Norm, it is sent at least once |
| 3456 | * within any of 4 consecutive occurrences of TC=4. */ |
| 3457 | if (not cfg.bcch_extended) { |
| 3458 | log("not-bccch-extended"); |
| 3459 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_13, false, 1, 4); |
| 3460 | } else { |
| 3461 | log("bccch-extended"); |
| 3462 | f_ensure_si_vec_contains(si_per_tc, 0, SYSTEM_INFORMATION_TYPE_13, true); |
| 3463 | } |
| 3464 | if (f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_13alt)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3465 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Cannot have SI13alt and SI13"); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 3466 | } |
| 3467 | } |
| 3468 | if (cfg.si16_present or cfg.si17_present) { |
| 3469 | /* viii) System Information type 16 and 17 are only related to the SoLSA service. They |
| 3470 | * should not be sent in a cell where network sharing is used (see rule xv). */ |
| 3471 | if (cfg.si22_present) { |
| 3472 | testcase.stop("Error: Cannot have SI16/SI17 and SI22!"); |
| 3473 | } |
| 3474 | if (f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_22)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3475 | 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] | 3476 | } |
| 3477 | if (not cfg.bcch_extended) { |
| 3478 | testcase.stop("Error: SI16/SI17 requires BCCH Extd!"); |
| 3479 | } |
| 3480 | if (cfg.si16_present) { |
| 3481 | f_ensure_si_vec_contains(si_per_tc, 6, SYSTEM_INFORMATION_TYPE_16, true); |
| 3482 | } |
| 3483 | if (cfg.si17_present) { |
| 3484 | f_ensure_si_vec_contains(si_per_tc, 2, SYSTEM_INFORMATION_TYPE_17, true); |
| 3485 | } |
| 3486 | } |
| 3487 | |
| 3488 | /* ix) System Information type 18 and 20 are sent in order to transmit non-GSM |
| 3489 | * broadcast information. The frequency with which they are sent is determined by the |
| 3490 | * system operator. System Information type 9 identifies the scheduling of System |
| 3491 | * Information type 18 and 20 messages. */ |
| 3492 | |
| 3493 | /* x) System Information Type 19 is sent if COMPACT neighbours exist. If System |
| 3494 | * Information Type 19 is present, then its scheduling shall be indicated in System |
| 3495 | * Information Type 9. */ |
| 3496 | |
| 3497 | if (cfg.si15_present) { |
| 3498 | /* xi) System Information Type 15 is broadcast if dynamic ARFCN mapping is used in the |
| 3499 | * PLMN. If sent on BCCH Norm, it is sent at least once within any of 4 consecutive |
| 3500 | * occurrences of TC = 4. If sent on BCCH Ext, it is sent at least once within any of |
| 3501 | * 4 consecutive occurrences of TC = 1. */ |
| 3502 | if (not cfg.bcch_extended) { |
| 3503 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_15, false, 1, 4); |
| 3504 | } else { |
| 3505 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 1, SYSTEM_INFORMATION_TYPE_15, true, 1, 4); |
| 3506 | } |
| 3507 | } |
| 3508 | if (cfg.si13alt_present) { |
| 3509 | /* xii) System Information type 13 alt is only related to the GERAN Iu mode. System |
| 3510 | * Information Type 13 alt need only be sent if GERAN Iu mode support is indicated in |
| 3511 | * one or more of System Information Type 3 or 4 or 7 or 8 messages and SI 13 is not |
| 3512 | * broadcast. These messages also indicate if the message is sent on the BCCH Norm or |
| 3513 | * if the message is transmitted on the BCCH Ext. In the case that the message is sent |
| 3514 | * on the BCCH Norm, it is sent at least once within any of 4 consecutive occurrences |
| 3515 | * of TC = 4. */ |
| 3516 | if (cfg.si13_present) { |
| 3517 | testcase.stop("Error: Cannot have SI13alt and SI13"); |
| 3518 | } |
| 3519 | if (f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_13)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3520 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Cannot have SI13alt and SI13"); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 3521 | } |
| 3522 | if (not cfg.bcch_extended) { |
| 3523 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_13alt, false, 1, 4); |
| 3524 | } else { |
| 3525 | f_ensure_si_vec_contains(si_per_tc, 0, SYSTEM_INFORMATION_TYPE_13alt, true); |
| 3526 | } |
| 3527 | } |
| 3528 | if (cfg.si2n_present) { |
| 3529 | /* xiii) System Information Type 2n is optionally sent on BCCH Norm or BCCH Ext if needed, |
| 3530 | * as determined by the system operator. In the case that the message is sent on the |
| 3531 | * BCCH Norm, it is sent at least once within any of 4 consecutive occurrences of TC = |
| 3532 | * 4. If the message is sent on BCCH Ext, it is sent at least once within any of 2 |
| 3533 | * consecutive occurrences of TC = 4. */ |
| 3534 | if (not cfg.bcch_extended) { |
| 3535 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_2n, false, 1, 4); |
| 3536 | } else { |
| 3537 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_2n, true, 2, 4); |
| 3538 | } |
| 3539 | } |
| 3540 | if (cfg.si21_present) { |
| 3541 | /* xiv) System Information Type 21 is optionally sent on BCCH Norm or BCCH Ext, as |
| 3542 | * determined by the system operator. If Extended Access Barring is in use in the cell |
| 3543 | * then this message is sent at least once within any of 4 consecutive occurrences of |
| 3544 | * TC = 4 regardless if it is sent on BCCH Norm or BCCH Ext. If BCCH Ext is used in a |
| 3545 | * cell then this message shall only be sent on BCCH Ext. */ |
| 3546 | if (not cfg.bcch_extended) { |
| 3547 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_21, false, 1, 4); |
| 3548 | } else { |
| 3549 | f_ensure_si_vec_contains_n_of_m(si_per_tc, 4, SYSTEM_INFORMATION_TYPE_21, true, 1, 4); |
| 3550 | 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] | 3551 | 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] | 3552 | } |
| 3553 | } |
| 3554 | } |
| 3555 | if (cfg.si22_present) { |
| 3556 | /* xv) System Information Type 22 is sent if network sharing is in use in the cell. It |
| 3557 | * should not be sent in a cell where SoLSA is used (see rule viii). System |
| 3558 | * Information Type 22 instances shall be sent on BCCH Ext within any occurrence of TC |
| 3559 | * =2 and TC=6. */ |
| 3560 | if (cfg.si16_present or cfg.si17_present) { |
| 3561 | testcase.stop("Error: Cannot have SI16/SI17 and SI22!"); |
| 3562 | } |
| 3563 | if (f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_16) or |
| 3564 | f_si_vec_contains(si_per_tc, SYSTEM_INFORMATION_TYPE_17)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3565 | 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] | 3566 | } |
| 3567 | if (not cfg.bcch_extended) { |
| 3568 | testcase.stop("Error: SI22 requires BCCH Extd!"); |
| 3569 | } else { |
| 3570 | f_ensure_si_vec_contains_only(si_per_tc, 2, SYSTEM_INFORMATION_TYPE_22, true); |
| 3571 | f_ensure_si_vec_contains_only(si_per_tc, 6, SYSTEM_INFORMATION_TYPE_22, true); |
| 3572 | } |
| 3573 | } |
| 3574 | } |
| 3575 | |
| 3576 | /* sample Systme Information for specified duration via L1CTL */ |
| 3577 | function f_l1_sample_si(L1CTL_PT pt, float duration := 8.0) return SystemInformationVectorPerTc { |
| 3578 | timer T := duration; |
| 3579 | var SystemInformationVectorPerTc si_per_tc; |
| 3580 | var L1ctlDlMessage l1_dl; |
| 3581 | |
| 3582 | /* initialize all per-TC vectors empty */ |
| 3583 | for (var integer i:= 0; i < sizeof(si_per_tc); i := i+1) { |
| 3584 | si_per_tc[i] := {}; |
| 3585 | } |
| 3586 | |
| 3587 | /* flush all previous L1 queued msgs */ |
| 3588 | pt.clear; |
| 3589 | |
| 3590 | T.start; |
| 3591 | alt { |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 3592 | [] 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] | 3593 | /* somehow dec_SystemInformation will try to decode even non-RR as SI */ |
| 3594 | if (not (l1_dl.payload.data_ind.payload[1] == '06'O)) { |
| 3595 | log("Ignoring non-RR SI ", l1_dl); |
| 3596 | repeat; |
| 3597 | } |
| 3598 | var SystemInformationFn sig := { |
| 3599 | frame_number := l1_dl.dl_info.frame_nr, |
| 3600 | si := dec_SystemInformation(l1_dl.payload.data_ind.payload) |
| 3601 | } |
| 3602 | var integer tc := f_gsm_compute_tc(sig.frame_number); |
| 3603 | log("SI received at TC=", tc, ": ", sig.si); |
| 3604 | /* append to the per-TC bucket */ |
| 3605 | si_per_tc[tc] := si_per_tc[tc] & { sig }; |
| 3606 | repeat; |
| 3607 | } |
| 3608 | [] pt.receive { repeat; } |
| 3609 | [] T.timeout { } |
| 3610 | } |
| 3611 | |
| 3612 | for (var integer i:= 0; i < sizeof(si_per_tc); i := i+1) { |
| 3613 | log(testcasename(), ": TC=", i, " has #of SI=", sizeof(si_per_tc[i])); |
| 3614 | } |
| 3615 | log("si_per_tc=", si_per_tc); |
| 3616 | return si_per_tc; |
| 3617 | } |
| 3618 | |
| 3619 | /* helper function: Set given SI via RSL + validate scheduling. |
| 3620 | * CALLER MUST MAKE SURE TO CHANGE GLOBAL si_cfg! */ |
| 3621 | function f_TC_si_sched() runs on test_CT { |
| 3622 | var SystemInformationVectorPerTc si_per_tc; |
| 3623 | f_init_l1ctl(); |
| 3624 | f_l1_tune(L1CTL); |
| 3625 | |
| 3626 | /* Sample + Validate Scheduling */ |
| 3627 | si_per_tc := f_l1_sample_si(L1CTL); |
| 3628 | f_validate_si_scheduling(si_cfg, si_per_tc); |
| 3629 | |
| 3630 | setverdict(pass); |
| 3631 | } |
| 3632 | |
| 3633 | testcase TC_si_sched_default() runs on test_CT { |
| 3634 | f_init(); |
Harald Welte | 0cae455 | 2018-03-09 22:20:26 +0100 | [diff] [blame] | 3635 | /* 2+3+4 are mandatory and set in f_init() */ |
| 3636 | f_TC_si_sched(); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3637 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 0cae455 | 2018-03-09 22:20:26 +0100 | [diff] [blame] | 3638 | } |
| 3639 | |
| 3640 | testcase TC_si_sched_1() runs on test_CT { |
| 3641 | f_init(); |
| 3642 | si_cfg.si1_present := true; |
| 3643 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_1, '5506198fb38000000000000000000000000000e504002b'O); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 3644 | f_TC_si_sched(); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3645 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 3646 | } |
| 3647 | |
| 3648 | testcase TC_si_sched_2bis() runs on test_CT { |
| 3649 | f_init(); |
| 3650 | si_cfg.si2bis_present := true; |
| 3651 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2bis, '550602bfe809b3ff00000000000000000000007900002b'O); |
| 3652 | f_TC_si_sched(); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3653 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 3654 | } |
| 3655 | |
| 3656 | testcase TC_si_sched_2ter() runs on test_CT { |
| 3657 | f_init(); |
| 3658 | si_cfg.si2ter_present := true; |
| 3659 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2ter, '010603bf66b0aa0a00000002000000000000002b2b2b2b'O); |
| 3660 | f_TC_si_sched(); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3661 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 3662 | } |
| 3663 | |
| 3664 | testcase TC_si_sched_2ter_2bis() runs on test_CT { |
| 3665 | f_init(); |
| 3666 | si_cfg.si2bis_present := true; |
| 3667 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2bis, '550602bfe809b3ff00000000000000000000007900002b'O); |
| 3668 | si_cfg.si2ter_present := true; |
| 3669 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2ter, '010603bf66b0aa0a00000002000000000000002b2b2b2b'O); |
| 3670 | f_TC_si_sched(); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3671 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 3672 | } |
| 3673 | |
| 3674 | testcase TC_si_sched_2quater() runs on test_CT { |
| 3675 | f_init(); |
| 3676 | si_cfg.si2quater_present := true; |
| 3677 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2quater, '050607a8a0364aa698d72ff424feee0506d5e7fff02043'O); |
| 3678 | f_TC_si_sched(); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3679 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 3680 | } |
| 3681 | |
| 3682 | testcase TC_si_sched_13() runs on test_CT { |
| 3683 | f_init(); |
| 3684 | si_cfg.si13_present := true; |
Harald Welte | 5618c2a | 2018-04-15 16:24:46 +0200 | [diff] [blame] | 3685 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_13, '0106009000185a6fc9e08410ab2b2b2b2b2b2b2b2b2b2b'O); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 3686 | f_TC_si_sched(); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3687 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 3688 | } |
| 3689 | |
| 3690 | testcase TC_si_sched_13_2bis_2ter_2quater() runs on test_CT { |
| 3691 | f_init(); |
| 3692 | si_cfg.si2bis_present := true; |
| 3693 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2bis, '550602bfe809b3ff00000000000000000000007900002b'O); |
| 3694 | si_cfg.si2ter_present := true; |
| 3695 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2ter, '010603bf66b0aa0a00000002000000000000002b2b2b2b'O); |
| 3696 | si_cfg.si2quater_present := true; |
| 3697 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_2quater, '050607a8a0364aa698d72ff424feee0506d5e7fff02043'O); |
| 3698 | si_cfg.si13_present := true; |
Harald Welte | 5618c2a | 2018-04-15 16:24:46 +0200 | [diff] [blame] | 3699 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_13, '0106009000185a6fc9e08410ab2b2b2b2b2b2b2b2b2b2b'O); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 3700 | f_TC_si_sched(); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3701 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 3702 | } |
| 3703 | |
| 3704 | |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3705 | testcase TC_bcch_info() runs on test_CT { |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 3706 | f_init(); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3707 | /* FIXME: enable / disable individual BCCH info */ |
| 3708 | //ts_RSL_BCCH_INFO(si_type, info); |
| 3709 | /* expect no ERROR REPORT after either of them * |
| 3710 | /* negative test: ensure ERROR REPORT on unsupported types */ |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3711 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3712 | } |
| 3713 | |
Harald Welte | 93640c6 | 2018-02-25 16:59:33 +0100 | [diff] [blame] | 3714 | /*********************************************************************** |
| 3715 | * Low-Level Protocol Errors / ERROR REPORT |
| 3716 | ***********************************************************************/ |
| 3717 | |
Harald Welte | 01d982c | 2018-02-25 01:31:40 +0100 | [diff] [blame] | 3718 | private function f_exp_err_rep(template RSL_Cause cause) runs on test_CT { |
| 3719 | timer T := 5.0; |
| 3720 | T.start; |
| 3721 | alt { |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 3722 | [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_ERROR_REPORT(cause))) { |
Harald Welte | 01d982c | 2018-02-25 01:31:40 +0100 | [diff] [blame] | 3723 | setverdict(pass); |
| 3724 | } |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 3725 | [] RSL_CCHAN.receive(tr_ASP_RSL_UD(tr_RSL_ERROR_REPORT(?))) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3726 | 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] | 3727 | } |
| 3728 | [] RSL_CCHAN.receive { |
| 3729 | repeat; |
| 3730 | } |
| 3731 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3732 | 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] | 3733 | } |
| 3734 | } |
| 3735 | } |
| 3736 | |
| 3737 | /* Provoke a protocol error (message too short) and match on ERROR REPORT */ |
| 3738 | testcase TC_rsl_protocol_error() runs on test_CT { |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 3739 | f_init(); |
Harald Welte | 01d982c | 2018-02-25 01:31:40 +0100 | [diff] [blame] | 3740 | var RSL_Message rsl := valueof(ts_RSL_BCCH_INFO(RSL_SYSTEM_INFO_1, ''O)); |
| 3741 | rsl.ies := omit; |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 3742 | RSL_CCHAN.send(ts_ASP_RSL_UD(rsl)); |
Harald Welte | 01d982c | 2018-02-25 01:31:40 +0100 | [diff] [blame] | 3743 | |
| 3744 | f_exp_err_rep(RSL_ERR_PROTO); |
| 3745 | } |
| 3746 | |
| 3747 | /* Provoke a mandatory IE error and match on ERROR REPORT */ |
| 3748 | testcase TC_rsl_mand_ie_error() runs on test_CT { |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 3749 | f_init(); |
Harald Welte | 01d982c | 2018-02-25 01:31:40 +0100 | [diff] [blame] | 3750 | |
| 3751 | var RSL_Message rsl := valueof(ts_RSL_BCCH_INFO(RSL_SYSTEM_INFO_1, ''O)); |
| 3752 | rsl.ies := { rsl.ies[0] }; |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 3753 | RSL_CCHAN.send(ts_ASP_RSL_UD(rsl)); |
Harald Welte | 01d982c | 2018-02-25 01:31:40 +0100 | [diff] [blame] | 3754 | |
| 3755 | f_exp_err_rep(RSL_ERR_MAND_IE_ERROR); |
| 3756 | } |
| 3757 | |
| 3758 | /* Provoke an IE content error and match on ERROR REPORT */ |
| 3759 | testcase TC_rsl_ie_content_error() runs on test_CT { |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 3760 | f_init(); |
Harald Welte | 01d982c | 2018-02-25 01:31:40 +0100 | [diff] [blame] | 3761 | var RSL_Message rsl := valueof(ts_RSL_BCCH_INFO(RSL_SYSTEM_INFO_1, ''O)); |
| 3762 | rsl.ies[1].body.sysinfo_type := RSL_SYSTEM_INFO_5; |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 3763 | RSL_CCHAN.send(ts_ASP_RSL_UD(rsl)); |
Harald Welte | 01d982c | 2018-02-25 01:31:40 +0100 | [diff] [blame] | 3764 | |
| 3765 | f_exp_err_rep(RSL_ERR_IE_CONTENT); |
| 3766 | } |
| 3767 | |
Harald Welte | ee25aae | 2019-05-19 14:32:37 +0200 | [diff] [blame] | 3768 | /* attempt to activate channel with wrong RSL Message Discriminator IE */ |
| 3769 | function f_TC_chan_act_wrong_mdisc(charstring id) runs on ConnHdlr { |
| 3770 | var template RSL_Message rsl := ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode); |
| 3771 | rsl.msg_disc := ts_RSL_MsgDisc(RSL_MDISC_RESERVED, false); |
| 3772 | RSL.send(rsl); |
| 3773 | f_rslem_unregister(0, g_chan_nr); |
| 3774 | } |
| 3775 | testcase TC_err_rep_wrong_mdisc() runs on test_CT { |
| 3776 | var ConnHdlr vc_conn; |
| 3777 | var ConnHdlrPars pars := valueof(t_Pars(ts_RslChanNr_SDCCH4(0,0), ts_RSL_ChanMode_SIGN)); |
| 3778 | |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 3779 | f_init(); |
Harald Welte | ee25aae | 2019-05-19 14:32:37 +0200 | [diff] [blame] | 3780 | |
| 3781 | vc_conn := f_start_handler(refers(f_TC_chan_act_wrong_mdisc), pars); |
| 3782 | vc_conn.done; |
| 3783 | f_exp_err_rep(RSL_ERR_MSG_DISCR); |
| 3784 | |
| 3785 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 3786 | } |
| 3787 | |
| 3788 | /* Send messages with wrong message type */ |
| 3789 | function f_TC_wrong_msg_type_dchan(charstring id) runs on ConnHdlr { |
| 3790 | var template (value) RSL_Message rsl_tx; |
| 3791 | rsl_tx := ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode); |
| 3792 | rsl_tx.msg_type := RSL_MT_NOT_CMD; |
| 3793 | RSL.send(rsl_tx); |
| 3794 | f_rslem_unregister(0, g_chan_nr); |
| 3795 | } |
| 3796 | function f_TC_wrong_msg_type_rll(charstring id) runs on ConnHdlr { |
| 3797 | var template (value) RSL_Message rsl_tx; |
| 3798 | /* we first have to activate the dedicated channel */ |
| 3799 | f_rsl_chan_act(g_pars.chan_mode); |
| 3800 | /* ... to then send an invalid RLL message */ |
| 3801 | rsl_tx := ts_RSL_UNITDATA_REQ(g_chan_nr, ts_RslLinkID_DCCH(0), '0102'O); |
| 3802 | rsl_tx.msg_type := RSL_MT_CBCH_LOAD_IND; |
| 3803 | RSL.send(rsl_tx); |
| 3804 | f_rslem_unregister(0, g_chan_nr); |
| 3805 | } |
| 3806 | testcase TC_err_rep_wrong_msg_type() runs on test_CT { |
| 3807 | var ConnHdlr vc_conn; |
| 3808 | var ConnHdlrPars pars := valueof(t_Pars(ts_RslChanNr_SDCCH4(0,0), ts_RSL_ChanMode_SIGN)); |
| 3809 | var template (value) RSL_Message rsl_tx; |
| 3810 | |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 3811 | f_init(); |
Harald Welte | ee25aae | 2019-05-19 14:32:37 +0200 | [diff] [blame] | 3812 | |
| 3813 | /* Common Channel with wrong message type */ |
| 3814 | RSL_CCHAN.clear; |
| 3815 | rsl_tx := valueof(ts_RSL_BCCH_INFO(RSL_SYSTEM_INFO_1, ''O)); |
| 3816 | rsl_tx.msg_type := RSL_MT_LOCATION_INFO; |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 3817 | RSL_CCHAN.send(ts_ASP_RSL_UD(rsl_tx)); |
Harald Welte | ee25aae | 2019-05-19 14:32:37 +0200 | [diff] [blame] | 3818 | f_exp_err_rep(RSL_ERR_MSG_TYPE); |
| 3819 | |
| 3820 | /* TRX Management */ |
| 3821 | RSL_CCHAN.clear; |
| 3822 | rsl_tx := ts_RSL_SACCH_FILL(RSL_SYSTEM_INFO_5, ''O); |
| 3823 | rsl_tx.msg_type := RSL_MT_UNIT_DATA_IND; |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 3824 | RSL_CCHAN.send(ts_ASP_RSL_UD(rsl_tx)); |
Harald Welte | ee25aae | 2019-05-19 14:32:37 +0200 | [diff] [blame] | 3825 | f_exp_err_rep(RSL_ERR_MSG_TYPE); |
| 3826 | |
| 3827 | /* Dedicated Channel */ |
| 3828 | RSL_CCHAN.clear; |
| 3829 | vc_conn := f_start_handler(refers(f_TC_wrong_msg_type_dchan), pars); |
| 3830 | vc_conn.done; |
| 3831 | f_exp_err_rep(RSL_ERR_MSG_TYPE); |
| 3832 | |
| 3833 | /* RLL */ |
| 3834 | RSL_CCHAN.clear; |
| 3835 | vc_conn := f_start_handler(refers(f_TC_wrong_msg_type_rll), pars); |
| 3836 | vc_conn.done; |
| 3837 | f_exp_err_rep(RSL_ERR_MSG_TYPE); |
| 3838 | } |
| 3839 | |
| 3840 | /* Send messages in wrong sequence (RLL to an inactive lchan) */ |
| 3841 | function f_TC_err_rep_wrong_sequence(charstring id) runs on ConnHdlr { |
| 3842 | RSL.send(ts_RSL_UNITDATA_REQ(g_chan_nr, ts_RslLinkID_DCCH(0), '0102'O)); |
| 3843 | f_rslem_unregister(0, g_chan_nr); |
| 3844 | } |
| 3845 | testcase TC_err_rep_wrong_sequence() runs on test_CT { |
| 3846 | var ConnHdlr vc_conn; |
| 3847 | var ConnHdlrPars pars := valueof(t_Pars(ts_RslChanNr_SDCCH4(0,0), ts_RSL_ChanMode_SIGN)); |
| 3848 | |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 3849 | f_init(); |
Harald Welte | ee25aae | 2019-05-19 14:32:37 +0200 | [diff] [blame] | 3850 | |
| 3851 | RSL_CCHAN.clear; |
| 3852 | vc_conn := f_start_handler(refers(f_TC_err_rep_wrong_sequence), pars); |
| 3853 | vc_conn.done; |
| 3854 | f_exp_err_rep(RSL_ERR_MSG_SEQ); |
| 3855 | } |
| 3856 | |
Harald Welte | 93640c6 | 2018-02-25 16:59:33 +0100 | [diff] [blame] | 3857 | /*********************************************************************** |
| 3858 | * IPA CRCX/MDCX/DLCS media stream handling |
| 3859 | ***********************************************************************/ |
| 3860 | |
Harald Welte | a871a38 | 2018-02-25 02:03:14 +0100 | [diff] [blame] | 3861 | /* Send IPA DLCX to inactive lchan */ |
| 3862 | function f_TC_ipa_dlcx_not_active(charstring id) runs on ConnHdlr { |
Harald Welte | 1eba374 | 2018-02-25 12:48:14 +0100 | [diff] [blame] | 3863 | f_rsl_transceive(ts_RSL_IPA_DLCX(g_chan_nr, 0), tr_RSL_IPA_DLCX_ACK(g_chan_nr, ?, ?), |
| 3864 | "IPA DLCX ACK"); |
Harald Welte | a871a38 | 2018-02-25 02:03:14 +0100 | [diff] [blame] | 3865 | } |
| 3866 | testcase TC_ipa_dlcx_not_active() runs on test_CT { |
| 3867 | 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] | 3868 | f_init(); |
Harald Welte | a871a38 | 2018-02-25 02:03:14 +0100 | [diff] [blame] | 3869 | var ConnHdlr vc_conn := f_start_handler(refers(f_TC_ipa_dlcx_not_active), pars); |
| 3870 | vc_conn.done; |
| 3871 | } |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 3872 | |
Harald Welte | a3f1df9 | 2018-02-25 12:49:55 +0100 | [diff] [blame] | 3873 | /* Send IPA CRCX twice to inactive lchan */ |
| 3874 | function f_TC_ipa_crcx_twice_not_active(charstring id) runs on ConnHdlr { |
| 3875 | f_rsl_transceive(ts_RSL_IPA_CRCX(g_chan_nr), tr_RSL_IPA_CRCX_ACK(g_chan_nr, ?, ?, ?), |
| 3876 | "IPA CRCX ACK"); |
| 3877 | f_rsl_transceive(ts_RSL_IPA_CRCX(g_chan_nr), tr_RSL_IPA_CRCX_NACK(g_chan_nr, RSL_ERR_RES_UNAVAIL), |
| 3878 | "IPA CRCX NACK"); |
| 3879 | } |
| 3880 | testcase TC_ipa_crcx_twice_not_active() runs on test_CT { |
| 3881 | 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] | 3882 | f_init(); |
Harald Welte | a3f1df9 | 2018-02-25 12:49:55 +0100 | [diff] [blame] | 3883 | var ConnHdlr vc_conn := f_start_handler(refers(f_TC_ipa_crcx_twice_not_active), pars); |
| 3884 | vc_conn.done; |
| 3885 | } |
| 3886 | |
| 3887 | /* Regular sequence of CRCX/MDCX/DLCX */ |
| 3888 | function f_TC_ipa_crcx_mdcx_dlcx_not_active(charstring id) runs on ConnHdlr { |
| 3889 | f_rsl_transceive(ts_RSL_IPA_CRCX(g_chan_nr), tr_RSL_IPA_CRCX_ACK(g_chan_nr, ?, ?, ?), |
| 3890 | "IPA CRCX ACK"); |
| 3891 | var uint32_t remote_ip := f_rnd_int(c_UINT32_MAX); |
| 3892 | var uint16_t remote_port := f_rnd_int(c_UINT16_MAX); |
| 3893 | var uint7_t rtp_pt2 := f_rnd_int(127); |
| 3894 | var uint16_t fake_conn_id := 23; /* we're too lazy to read it out from the CRCX ACK above */ |
| 3895 | f_rsl_transceive(ts_RSL_IPA_MDCX(g_chan_nr, fake_conn_id, remote_ip, remote_port, rtp_pt2), |
| 3896 | tr_RSL_IPA_MDCX_ACK(g_chan_nr, ?, ?, ?, rtp_pt2), |
| 3897 | "IPA MDCX ACK"); |
| 3898 | f_rsl_transceive(ts_RSL_IPA_DLCX(g_chan_nr, fake_conn_id), tr_RSL_IPA_DLCX_ACK(g_chan_nr, ?, ?), |
| 3899 | "IPA DLCX ACK"); |
| 3900 | } |
| 3901 | testcase TC_ipa_crcx_mdcx_dlcx_not_active() runs on test_CT { |
| 3902 | 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] | 3903 | f_init(); |
Harald Welte | a3f1df9 | 2018-02-25 12:49:55 +0100 | [diff] [blame] | 3904 | var ConnHdlr vc_conn := f_start_handler(refers(f_TC_ipa_crcx_mdcx_dlcx_not_active), pars); |
| 3905 | vc_conn.done; |
| 3906 | } |
| 3907 | |
Harald Welte | 3ae11da | 2018-02-25 13:36:06 +0100 | [diff] [blame] | 3908 | /* Sequence of CRCX, 2x MDCX, DLCX */ |
| 3909 | function f_TC_ipa_crcx_mdcx_mdcx_dlcx_not_active(charstring id) runs on ConnHdlr { |
| 3910 | f_rsl_transceive(ts_RSL_IPA_CRCX(g_chan_nr), tr_RSL_IPA_CRCX_ACK(g_chan_nr, ?, ?, ?), |
| 3911 | "IPA CRCX ACK"); |
| 3912 | var uint32_t remote_ip := f_rnd_int(c_UINT32_MAX); |
| 3913 | var uint16_t remote_port := f_rnd_int(c_UINT16_MAX); |
| 3914 | var uint7_t rtp_pt2 := f_rnd_int(127); |
| 3915 | var uint16_t fake_conn_id := 23; /* we're too lazy to read it out from the CRCX ACK above */ |
| 3916 | f_rsl_transceive(ts_RSL_IPA_MDCX(g_chan_nr, fake_conn_id, remote_ip, remote_port, rtp_pt2), |
| 3917 | tr_RSL_IPA_MDCX_ACK(g_chan_nr, ?, ?, ?, rtp_pt2), |
| 3918 | "IPA MDCX ACK"); |
| 3919 | /* Second MDCX */ |
| 3920 | remote_ip := f_rnd_int(c_UINT32_MAX); |
| 3921 | remote_port := f_rnd_int(c_UINT16_MAX); |
| 3922 | f_rsl_transceive(ts_RSL_IPA_MDCX(g_chan_nr, fake_conn_id, remote_ip, remote_port, rtp_pt2), |
| 3923 | tr_RSL_IPA_MDCX_ACK(g_chan_nr, ?, ?, ?, rtp_pt2), |
| 3924 | "IPA MDCX ACK"); |
| 3925 | f_rsl_transceive(ts_RSL_IPA_DLCX(g_chan_nr, fake_conn_id), tr_RSL_IPA_DLCX_ACK(g_chan_nr, ?, ?), |
| 3926 | "IPA DLCX ACK"); |
| 3927 | } |
| 3928 | testcase TC_ipa_crcx_mdcx_mdcx_dlcx_not_active() runs on test_CT { |
| 3929 | 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] | 3930 | f_init(); |
Harald Welte | 3ae11da | 2018-02-25 13:36:06 +0100 | [diff] [blame] | 3931 | var ConnHdlr vc_conn := f_start_handler(refers(f_TC_ipa_crcx_mdcx_mdcx_dlcx_not_active), pars); |
| 3932 | vc_conn.done; |
| 3933 | } |
| 3934 | |
Harald Welte | 9912eb5 | 2018-02-25 13:30:15 +0100 | [diff] [blame] | 3935 | /* IPA CRCX on SDCCH/4 and SDCCH/8 (doesn't make sense) */ |
| 3936 | function f_TC_ipa_crcx_sdcch_not_active(charstring id) runs on ConnHdlr { |
| 3937 | f_rsl_transceive(ts_RSL_IPA_CRCX(g_chan_nr), tr_RSL_IPA_CRCX_NACK(g_chan_nr, ?), |
| 3938 | "IPA CRCX NACK"); |
| 3939 | } |
| 3940 | testcase TC_ipa_crcx_sdcch_not_active() runs on test_CT { |
| 3941 | var ConnHdlrPars pars; |
| 3942 | var ConnHdlr vc_conn; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 3943 | f_init(); |
Harald Welte | 9912eb5 | 2018-02-25 13:30:15 +0100 | [diff] [blame] | 3944 | |
| 3945 | pars := valueof(t_Pars(t_RslChanNr_SDCCH4(0,1), ts_RSL_ChanMode_SIGN)); |
| 3946 | vc_conn := f_start_handler(refers(f_TC_ipa_crcx_sdcch_not_active), pars); |
| 3947 | vc_conn.done; |
| 3948 | |
| 3949 | pars := valueof(t_Pars(t_RslChanNr_SDCCH8(6,5), ts_RSL_ChanMode_SIGN)); |
| 3950 | vc_conn := f_start_handler(refers(f_TC_ipa_crcx_sdcch_not_active), pars); |
| 3951 | vc_conn.done; |
| 3952 | } |
| 3953 | |
Harald Welte | a3f1df9 | 2018-02-25 12:49:55 +0100 | [diff] [blame] | 3954 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 3955 | /*********************************************************************** |
| 3956 | * PCU Socket related tests |
| 3957 | ***********************************************************************/ |
| 3958 | |
Harald Welte | 07bd2d2 | 2019-05-25 11:03:30 +0200 | [diff] [blame] | 3959 | /* Verify no RTS before ACT_REQ; verify RTS after ACT_REQ */ |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 3960 | 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] | 3961 | runs on test_CT { |
| 3962 | timer T := 3.0; |
| 3963 | |
| 3964 | /* we don't expect any RTS.req before PDCH are active */ |
| 3965 | T.start; |
| 3966 | alt { |
| 3967 | [] 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] | 3968 | 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] | 3969 | } |
| 3970 | [] PCU.receive { repeat; } |
| 3971 | [] T.timeout { } |
| 3972 | } |
| 3973 | |
| 3974 | /* Send PDCH activate request for known PDCH timeslot */ |
| 3975 | PCU.send(t_SD_PCUIF(g_pcu_conn_id, ts_PCUIF_ACT_REQ(bts_nr, trx_nr, ts_nr))); |
| 3976 | |
| 3977 | /* we now expect RTS.req for this timeslot (only) */ |
| 3978 | T.start; |
| 3979 | alt { |
| 3980 | [exp_success] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RTS_REQ(bts_nr, trx_nr, ts_nr))) { |
| 3981 | setverdict(pass); |
| 3982 | } |
| 3983 | [not exp_success] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, |
| 3984 | tr_PCUIF_RTS_REQ(bts_nr, trx_nr, ts_nr))) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3985 | 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] | 3986 | } |
| 3987 | [] 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] | 3988 | 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] | 3989 | } |
| 3990 | [] PCU.receive { repeat; } |
| 3991 | [exp_success] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 3992 | 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] | 3993 | } |
| 3994 | [not exp_success] T.timeout { |
| 3995 | setverdict(pass); |
| 3996 | } |
| 3997 | } |
| 3998 | } |
| 3999 | |
Harald Welte | 07bd2d2 | 2019-05-25 11:03:30 +0200 | [diff] [blame] | 4000 | /* verify no more RTS after DEACT_REQ */ |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 4001 | 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] | 4002 | runs on test_CT { |
| 4003 | timer T := 3.0; |
| 4004 | |
| 4005 | /* Send PDCH activate request for known PDCH timeslot */ |
| 4006 | PCU.send(t_SD_PCUIF(g_pcu_conn_id, ts_PCUIF_DEACT_REQ(bts_nr, trx_nr, ts_nr))); |
| 4007 | |
| 4008 | PCU.clear; |
| 4009 | /* we now expect no RTS.req for this timeslot */ |
| 4010 | T.start; |
| 4011 | alt { |
| 4012 | [] 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] | 4013 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Received unexpected PCU RTS.req"); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4014 | } |
| 4015 | [] PCU.receive { repeat; } |
| 4016 | [] T.timeout { |
| 4017 | setverdict(pass); |
| 4018 | } |
| 4019 | } |
| 4020 | } |
| 4021 | |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 4022 | friend function f_init_pcu_test() runs on test_CT { |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 4023 | f_init(); |
| 4024 | PCU.send(t_SD_PCUIF(g_pcu_conn_id, ts_PCUIF_TXT_IND(0, PCU_VERSION, testcasename()))); |
| 4025 | } |
| 4026 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4027 | /* PDCH activation via PCU socket; check for presence of RTS.req */ |
| 4028 | testcase TC_pcu_act_req() runs on test_CT { |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 4029 | f_init_pcu_test(); |
| 4030 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4031 | f_TC_pcu_act_req(0, 0, 7, true); |
| 4032 | } |
| 4033 | |
| 4034 | /* PDCH activation via PCU socket on non-PDCU timeslot */ |
| 4035 | testcase TC_pcu_act_req_wrong_ts() runs on test_CT { |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 4036 | f_init_pcu_test(); |
| 4037 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4038 | f_TC_pcu_act_req(0, 0, 1, false); |
| 4039 | } |
| 4040 | |
| 4041 | /* PDCH activation via PCU socket on wrong BTS */ |
| 4042 | testcase TC_pcu_act_req_wrong_bts() runs on test_CT { |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 4043 | f_init_pcu_test(); |
| 4044 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4045 | f_TC_pcu_act_req(23, 0, 7, false); |
| 4046 | } |
| 4047 | |
| 4048 | /* PDCH activation via PCU socket on wrong TRX */ |
| 4049 | testcase TC_pcu_act_req_wrong_trx() runs on test_CT { |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 4050 | f_init_pcu_test(); |
| 4051 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4052 | f_TC_pcu_act_req(0, 23, 7, false); |
| 4053 | } |
| 4054 | |
| 4055 | /* PDCH deactivation via PCU socket; check for absence of RTS.req */ |
| 4056 | testcase TC_pcu_deact_req() runs on test_CT { |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 4057 | f_init_pcu_test(); |
| 4058 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4059 | /* Activate PDCH */ |
| 4060 | f_TC_pcu_act_req(0, 0, 7, true); |
| 4061 | f_sleep(1.0); |
| 4062 | /* and De-Activate again */ |
| 4063 | f_TC_pcu_deact_req(0, 0, 7); |
| 4064 | } |
| 4065 | |
| 4066 | /* Attempt to deactivate a PDCH on a non-PDCH timeslot */ |
| 4067 | testcase TC_pcu_deact_req_wrong_ts() runs on test_CT { |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 4068 | f_init_pcu_test(); |
| 4069 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4070 | f_TC_pcu_deact_req(0, 0, 1); |
| 4071 | } |
| 4072 | |
| 4073 | /* Test the PCU->BTS Version and BTS->PCU SI13 handshake */ |
| 4074 | testcase TC_pcu_ver_si13() runs on test_CT { |
| 4075 | const octetstring si13 := '00010203040506070909'O; |
| 4076 | var PCUIF_send_data sd; |
| 4077 | timer T:= 3.0; |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 4078 | f_init_pcu_test(); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4079 | |
| 4080 | /* Set SI13 via RSL */ |
| 4081 | f_rsl_bcch_fill_raw(RSL_SYSTEM_INFO_13, si13); |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 4082 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4083 | T.start; |
| 4084 | alt { |
| 4085 | [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_DATA_IND(0, 0, 0, ?, PCU_IF_SAPI_BCCH))) -> value sd { |
| 4086 | if (substr(sd.data.u.data_ind.data, 0, lengthof(si13)) == si13) { |
| 4087 | setverdict(pass); |
| 4088 | } else { |
| 4089 | repeat; |
| 4090 | } |
| 4091 | } |
| 4092 | [] PCU.receive { repeat; } |
| 4093 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4094 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for SI13"); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4095 | } |
| 4096 | } |
| 4097 | } |
| 4098 | |
| 4099 | private const octetstring c_PCU_DATA := '000102030405060708090a0b0c0d0e0f10111213141516'O; |
| 4100 | |
| 4101 | /* helper function to send a PCU DATA.req */ |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 4102 | 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] | 4103 | uint8_t block_nr, uint32_t fn, PCUIF_Sapi sapi, octetstring data) |
| 4104 | runs on test_CT |
| 4105 | { |
| 4106 | PCU.send(t_SD_PCUIF(g_pcu_conn_id, |
| 4107 | ts_PCUIF_DATA_REQ(bts_nr, trx_nr, ts_nr, block_nr, fn, sapi, data))); |
| 4108 | } |
| 4109 | |
| 4110 | /* 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] | 4111 | friend function f_pcu_wait_rts_and_data_req(uint8_t bts_nr, uint8_t trx_nr, uint8_t ts_nr, |
| 4112 | PCUIF_Sapi sapi, octetstring data) |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4113 | runs on test_CT |
| 4114 | { |
| 4115 | var PCUIF_send_data sd; |
| 4116 | |
| 4117 | timer T := 3.0; |
| 4118 | T.start; |
| 4119 | alt { |
| 4120 | [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, |
| 4121 | tr_PCUIF_RTS_REQ(bts_nr, trx_nr, ts_nr, sapi))) -> value sd { |
| 4122 | f_pcu_data_req(bts_nr, trx_nr, ts_nr, sd.data.u.rts_req.block_nr, |
| 4123 | sd.data.u.rts_req.fn, sapi, data); |
| 4124 | } |
| 4125 | [] PCU.receive { repeat; } |
| 4126 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4127 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for RTS.ind"); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4128 | } |
| 4129 | } |
| 4130 | } |
| 4131 | |
| 4132 | /* Send DATA.req on invalid BTS */ |
| 4133 | testcase TC_pcu_data_req_wrong_bts() runs on test_CT { |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 4134 | var TfiUsfArr tua := f_TfiUsfArrInit(); |
| 4135 | var octetstring data := '0000'O & f_rnd_octstring(21); |
| 4136 | |
| 4137 | f_virtphy_common(); |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 4138 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4139 | f_TC_pcu_act_req(0, 0, 7, true); |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 4140 | f_TfiUsfArrSet(tua, 7, 0); |
| 4141 | f_L1CTL_TBF_CFG(L1CTL, false, tua); |
| 4142 | f_sleep(1.0); |
| 4143 | |
| 4144 | 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] | 4145 | } |
| 4146 | |
| 4147 | /* Send DATA.req on invalid TRX */ |
| 4148 | testcase TC_pcu_data_req_wrong_trx() runs on test_CT { |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 4149 | var TfiUsfArr tua := f_TfiUsfArrInit(); |
| 4150 | var octetstring data := '0000'O & f_rnd_octstring(21); |
| 4151 | |
| 4152 | f_virtphy_common(); |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 4153 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4154 | f_TC_pcu_act_req(0, 0, 7, true); |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 4155 | f_TfiUsfArrSet(tua, 7, 0); |
| 4156 | f_L1CTL_TBF_CFG(L1CTL, false, tua); |
| 4157 | f_sleep(1.0); |
| 4158 | |
| 4159 | 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] | 4160 | } |
| 4161 | |
| 4162 | /* Send DATA.req on invalid timeslot */ |
| 4163 | testcase TC_pcu_data_req_wrong_ts() runs on test_CT { |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 4164 | var TfiUsfArr tua := f_TfiUsfArrInit(); |
| 4165 | var octetstring data := '0000'O & f_rnd_octstring(21); |
| 4166 | |
| 4167 | f_virtphy_common(); |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 4168 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4169 | f_TC_pcu_act_req(0, 0, 7, true); |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 4170 | f_TfiUsfArrSet(tua, 7, 0); |
| 4171 | f_L1CTL_TBF_CFG(L1CTL, false, tua); |
| 4172 | f_sleep(1.0); |
| 4173 | |
| 4174 | 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] | 4175 | } |
| 4176 | |
| 4177 | /* Send DATA.req on timeslot that hasn't been activated */ |
| 4178 | testcase TC_pcu_data_req_ts_inactive() runs on test_CT { |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 4179 | var TfiUsfArr tua := f_TfiUsfArrInit(); |
| 4180 | var octetstring data := '0000'O & f_rnd_octstring(21); |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 4181 | |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 4182 | f_virtphy_common(); |
| 4183 | |
| 4184 | f_TfiUsfArrSet(tua, 7, 0); |
| 4185 | f_L1CTL_TBF_CFG(L1CTL, false, tua); |
| 4186 | f_sleep(1.0); |
| 4187 | |
| 4188 | 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] | 4189 | } |
| 4190 | |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 4191 | 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] | 4192 | PCUIF_Sapi sapi, octetstring data, boolean expect_data := true, |
| 4193 | boolean wait_rts := true) |
| 4194 | runs on test_CT { |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 4195 | timer T := 5.0; |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 4196 | var L1ctlDlMessage rx_dl; |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 4197 | |
| 4198 | PCU.clear; |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 4199 | if (wait_rts) { |
| 4200 | f_pcu_wait_rts_and_data_req(bts_nr, trx_nr, ts_nr, sapi, data); |
| 4201 | } else { |
| 4202 | f_pcu_data_req(bts_nr, trx_nr, ts_nr, 0, 0, sapi, data); |
| 4203 | } |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 4204 | |
| 4205 | T.start; |
| 4206 | alt { |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 4207 | [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] | 4208 | /* FIXME: why is fn of DATA_IND different to fn of RTS / DATA_REQ above? */ |
| 4209 | setverdict(pass); |
| 4210 | } |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 4211 | [not expect_data] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_PDCH(ts_nr), ?, data)) -> value rx_dl { |
| 4212 | setverdict(fail, "Received unexpected ", rx_dl); |
| 4213 | } |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 4214 | [] L1CTL.receive { |
| 4215 | repeat; |
| 4216 | } |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 4217 | [expect_data] T.timeout { |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 4218 | setverdict(fail, "Timeout waiting for ", data); |
| 4219 | } |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 4220 | [not expect_data] T.timeout { |
| 4221 | setverdict(pass); |
| 4222 | } |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 4223 | } |
| 4224 | } |
| 4225 | |
| 4226 | private function f_disable_dynamic_ts() runs on test_CT |
| 4227 | { |
| 4228 | f_init_vty_bsc(); |
| 4229 | /* I'm not quite sure why we need this with osmo-bts-virtual. Somehow it deosn't seem to |
| 4230 | * support dynamic timeslots? But it uses the same scheduler as osmo-bts-trx ?!? */ |
| 4231 | f_vty_config2(BSCVTY, {"network", "bts 0", "trx 0", "timeslot 3"}, "phys_chan_config TCH/F"); |
| 4232 | 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] | 4233 | f_init_pcu_test(); |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 4234 | } |
| 4235 | |
| 4236 | private function f_virtphy_common() runs on test_CT { |
| 4237 | f_disable_dynamic_ts(); |
| 4238 | f_init_l1ctl(); |
| 4239 | f_l1_tune(L1CTL); |
| 4240 | } |
| 4241 | |
| 4242 | testcase TC_pcu_data_req_pdtch() runs on test_CT { |
| 4243 | var TfiUsfArr tua := f_TfiUsfArrInit(); |
| 4244 | var octetstring data := '0000'O & f_rnd_octstring(21); |
| 4245 | |
| 4246 | f_virtphy_common(); |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 4247 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4248 | f_TC_pcu_act_req(0, 0, 7, true); |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 4249 | f_TfiUsfArrSet(tua, 7, 0); |
| 4250 | f_L1CTL_TBF_CFG(L1CTL, false, tua); |
| 4251 | f_sleep(1.0); |
| 4252 | |
| 4253 | 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] | 4254 | } |
| 4255 | |
Vadim Yanitskiy | 8c242f0 | 2019-10-13 15:25:54 +0700 | [diff] [blame] | 4256 | /* FIXME: PTTCH has nothing to do with TBFs */ |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4257 | testcase TC_pcu_data_req_ptcch() runs on test_CT { |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 4258 | var TfiUsfArr tua := f_TfiUsfArrInit(); |
| 4259 | var octetstring data := '0000'O & f_rnd_octstring(21); |
| 4260 | |
| 4261 | f_virtphy_common(); |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 4262 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4263 | f_TC_pcu_act_req(0, 0, 7, true); |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 4264 | f_TfiUsfArrSet(tua, 7, 0); |
| 4265 | f_L1CTL_TBF_CFG(L1CTL, false, tua); |
| 4266 | f_sleep(1.0); |
| 4267 | |
| 4268 | f_pcu_to_l1(0, 0, 7, PCU_IF_SAPI_PTCCH, data); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4269 | } |
| 4270 | |
Vadim Yanitskiy | 8c242f0 | 2019-10-13 15:25:54 +0700 | [diff] [blame] | 4271 | private function f_TC_pcu_ptcch_ul(uint16_t ra) |
| 4272 | runs on test_CT { |
| 4273 | var template PCUIF_Message pcu_rach_ind; |
| 4274 | var PCUIF_send_data sd; |
| 4275 | var GsmFrameNumber fn; |
| 4276 | timer T; |
| 4277 | |
| 4278 | /* Send an Access Burst on PTCCH/U over the Um-interface */ |
| 4279 | fn := f_L1CTL_RACH(L1CTL, ra := ra, combined := 0, offset := 0, |
| 4280 | chan_nr := ts_RslChanNr_PDCH(7), |
| 4281 | link_id := ts_RslLinkID_OSMO_PTCCH(0)); |
| 4282 | |
Vadim Yanitskiy | 36558d9 | 2019-11-17 02:23:51 +0700 | [diff] [blame] | 4283 | pcu_rach_ind := tr_PCUIF_RACH_IND(bts_nr := 0, trx_nr := 0, ts_nr := 7, |
| 4284 | ra := ra, fn := fn, sapi := PCU_IF_SAPI_PTCCH); |
Vadim Yanitskiy | 8c242f0 | 2019-10-13 15:25:54 +0700 | [diff] [blame] | 4285 | |
| 4286 | /* Expect a RACH.ind on the PCU interface (timeout is one multi-frame) */ |
| 4287 | T.start(52.0 * 4.615 / 1000.0); |
| 4288 | alt { |
| 4289 | [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, pcu_rach_ind)) -> value sd { |
| 4290 | log("Rx an Access Burst on the PCU interface: ", sd.data); |
| 4291 | setverdict(pass); |
| 4292 | T.stop; |
| 4293 | } |
| 4294 | [] PCU.receive { repeat; } |
| 4295 | [] T.timeout { |
| 4296 | setverdict(fail, "Timeout waiting for RACH.ind on the PCU interface"); |
| 4297 | /* Keep going, that's not the end of the world */ |
| 4298 | } |
| 4299 | } |
| 4300 | } |
| 4301 | |
| 4302 | testcase TC_pcu_ptcch() runs on test_CT { |
| 4303 | var L1ctlDlMessage dl; |
| 4304 | var octetstring data; |
| 4305 | timer T; |
| 4306 | |
| 4307 | f_init_pcu_test(); |
| 4308 | f_init_l1ctl(); |
| 4309 | f_l1_tune(L1CTL); |
| 4310 | |
| 4311 | /* Activate PDCH channel on TS7 */ |
| 4312 | f_TC_pcu_act_req(0, 0, 7, true); |
| 4313 | |
| 4314 | /* Tune trxcon to that PDCH channel */ |
| 4315 | L1CTL.send(ts_L1CTL_DM_EST_REQ(arfcn := { false, mp_trx0_arfcn }, |
| 4316 | chan_nr := valueof(ts_RslChanNr_PDCH(7)), |
| 4317 | tsc := 7)); |
| 4318 | |
| 4319 | /* Verify PTCCH/U: send several access bursts, make sure they're received */ |
| 4320 | for (var integer i := 0; i < 16; i := i + 1) { |
| 4321 | log("Sending an Access Burst towards the L1CTL interface"); |
| 4322 | f_TC_pcu_ptcch_ul(oct2int(f_rnd_ra_ps())); |
| 4323 | } |
| 4324 | |
| 4325 | /* Generate a random payload for PTCCH/D (23 octets, CS-1) */ |
| 4326 | data := f_rnd_octstring(23); |
| 4327 | |
| 4328 | /* Verify PTCCH/D: send a random data block, make sure it's received */ |
| 4329 | log("Sending a PTCCH/D block towards the PCU interface: ", data); |
| 4330 | f_pcu_wait_rts_and_data_req(0, 0, 7, PCU_IF_SAPI_PTCCH, data); |
| 4331 | |
| 4332 | /* PTCCH/D period is 2 multi-frames (2 * 52 * 4.615 ms), but |
| 4333 | * let's give it more time in case if we miss the beginning. */ |
| 4334 | T.start(2.0 * 2.0 * 52.0 * 4.615 / 1000.0); |
| 4335 | alt { |
| 4336 | /* PDCH is considered as traffic in trxcon => expect TRAFFIC.ind */ |
| 4337 | [] L1CTL.receive(tr_L1CTL_TRAFFIC_IND(chan_nr := t_RslChanNr_PDCH(7), |
| 4338 | link_id := tr_RslLinkID_OSMO_PTCCH(?), |
| 4339 | frame := data)) -> value dl { |
| 4340 | log("Rx PTCCH/D data (traffic) block on L1CTL: ", dl); |
| 4341 | setverdict(pass); |
| 4342 | T.stop; |
| 4343 | } |
| 4344 | /* Other PHYs (e.g. virt_phy) may consider PDCH as data => expect DATA.ind */ |
| 4345 | [] L1CTL.receive(tr_L1CTL_DATA_IND(chan_nr := t_RslChanNr_PDCH(7), |
| 4346 | link_id := tr_RslLinkID_OSMO_PTCCH(?), |
| 4347 | l2_data := data)) -> value dl { |
| 4348 | log("Rx PTCCH/D data block on L1CTL: ", dl); |
| 4349 | setverdict(pass); |
| 4350 | T.stop; |
| 4351 | } |
| 4352 | [] L1CTL.receive { repeat; } |
| 4353 | [] T.timeout { |
| 4354 | setverdict(fail, "Timeout waiting for DATA.ind on L1CTL"); |
| 4355 | } |
| 4356 | } |
| 4357 | } |
| 4358 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4359 | /* Send AGCH from PCU; check it appears on Um side */ |
| 4360 | testcase TC_pcu_data_req_agch() runs on test_CT { |
| 4361 | timer T := 3.0; |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 4362 | f_init_pcu_test(); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4363 | f_init_l1ctl(); |
| 4364 | f_l1_tune(L1CTL); |
| 4365 | |
| 4366 | f_TC_pcu_act_req(0, 0, 7, true); |
| 4367 | f_pcu_data_req(0, 0, 7, 0, 0, PCU_IF_SAPI_AGCH, c_PCU_DATA); |
| 4368 | |
| 4369 | T.start; |
| 4370 | alt { |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 4371 | [] 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] | 4372 | setverdict(pass); |
| 4373 | } |
| 4374 | [] L1CTL.receive { repeat; } |
| 4375 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4376 | 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] | 4377 | } |
| 4378 | } |
| 4379 | } |
| 4380 | |
Harald Welte | 928622b | 2019-05-26 13:22:59 +0200 | [diff] [blame] | 4381 | /* Send AGCH from PCU; check it appears on Um side */ |
| 4382 | testcase TC_pcu_data_req_pch() runs on test_CT { |
| 4383 | timer T := 3.0; |
| 4384 | f_init_pcu_test(); |
| 4385 | f_init_l1ctl(); |
| 4386 | f_l1_tune(L1CTL); |
| 4387 | |
| 4388 | f_TC_pcu_act_req(0, 0, 7, true); |
| 4389 | /* three characters prefix: last 3 digits of IMSI as ASCII */ |
| 4390 | f_pcu_data_req(0, 0, 7, 0, 0, PCU_IF_SAPI_PCH, '313233'O & c_PCU_DATA); |
| 4391 | |
| 4392 | T.start; |
| 4393 | alt { |
| 4394 | [] L1CTL.receive(tr_L1CTL_DATA_IND(t_RslChanNr_PCH_AGCH(0), ?, c_PCU_DATA)) { |
| 4395 | setverdict(pass); |
| 4396 | } |
| 4397 | [] L1CTL.receive { repeat; } |
| 4398 | [] T.timeout { |
| 4399 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for PCU-originated PCH block on Um"); |
| 4400 | } |
| 4401 | } |
| 4402 | } |
| 4403 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4404 | /* Send IMM.ASS from PCU for PCH; check it appears on Um side */ |
| 4405 | testcase TC_pcu_data_req_imm_ass_pch() runs on test_CT { |
| 4406 | var octetstring imm_ass := f_rnd_octstring(23); |
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 | /* append 3 last imsi digits so BTS can compute pagng group */ |
| 4412 | var uint32_t fn := f_PCUIF_tx_imm_ass_pch(PCU, g_pcu_conn_id, imm_ass, '123459987'H); |
| 4413 | |
| 4414 | timer T := 0.5; |
| 4415 | T.start; |
| 4416 | alt { |
Harald Welte | f8df4cb | 2018-03-10 15:15:08 +0100 | [diff] [blame] | 4417 | [] 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] | 4418 | /* TODO: verify paging group */ |
| 4419 | setverdict(pass); |
| 4420 | } |
| 4421 | [] L1CTL.receive { repeat; } |
| 4422 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4423 | 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] | 4424 | } |
| 4425 | } |
| 4426 | } |
| 4427 | |
| 4428 | /* Send RACH from Um side, expect it to show up on PCU socket */ |
| 4429 | testcase TC_pcu_rach_content() runs on test_CT { |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 4430 | f_init_pcu_test(); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4431 | f_init_l1ctl(); |
| 4432 | f_l1_tune(L1CTL); |
| 4433 | |
| 4434 | var GsmFrameNumber fn_last := 0; |
| 4435 | for (var integer i := 0; i < 1000; i := i+1) { |
| 4436 | var OCT1 ra := f_rnd_ra_ps(); |
| 4437 | var GsmFrameNumber fn := f_L1CTL_RACH(L1CTL, oct2int(ra)); |
| 4438 | if (fn == fn_last) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4439 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Two RACH in same FN?!?"); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4440 | } |
| 4441 | fn_last := fn; |
| 4442 | |
| 4443 | timer T := 2.0; |
| 4444 | T.start; |
| 4445 | alt { |
Vadim Yanitskiy | 36558d9 | 2019-11-17 02:23:51 +0700 | [diff] [blame] | 4446 | [] 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] | 4447 | T.stop; |
| 4448 | } |
| 4449 | [] 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] | 4450 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected RACH IND"); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4451 | } |
| 4452 | [] PCU.receive { repeat; } |
| 4453 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4454 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for RACH IND"); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4455 | } |
| 4456 | } |
| 4457 | } |
| 4458 | setverdict(pass); |
| 4459 | } |
| 4460 | |
Vadim Yanitskiy | 51cbc10 | 2019-04-22 06:37:30 +0700 | [diff] [blame] | 4461 | /* Send extended (11-bit, TS1 & TS2) RACH bursts from the Um side, |
| 4462 | * expect them to show up on PCU socket (with proper BURST_TYPE_*). */ |
| 4463 | testcase TC_pcu_ext_rach_content() runs on test_CT { |
| 4464 | var template PCUIF_Message pcu_rach_ind; |
| 4465 | var GsmFrameNumber fn_last := 0; |
| 4466 | var L1ctlRachSynchSeq synch_seq; |
| 4467 | var PCUIF_BurstType pcu_bt; |
| 4468 | var GsmFrameNumber fn; |
| 4469 | var BIT11 ra11; |
| 4470 | |
| 4471 | f_init_pcu_test(); |
| 4472 | f_init_l1ctl(); |
| 4473 | f_l1_tune(L1CTL); |
| 4474 | |
| 4475 | for (var integer i := 0; i < 1000; i := i+1) { |
| 4476 | /* We need to test both TS1 & TS2 */ |
| 4477 | if (i rem 2 == 0) { |
| 4478 | synch_seq := RACH_SYNCH_SEQ_TS1; |
| 4479 | pcu_bt := BURST_TYPE_1; |
| 4480 | } else { |
| 4481 | synch_seq := RACH_SYNCH_SEQ_TS2; |
| 4482 | pcu_bt := BURST_TYPE_2; |
| 4483 | } |
| 4484 | |
| 4485 | ra11 := f_rnd_ra11_ps(); |
| 4486 | fn := f_L1CTL_EXT_RACH(L1CTL, bit2int(ra11), synch_seq); |
| 4487 | if (fn == fn_last) { |
| 4488 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 4489 | "Two RACH in same FN?!?"); |
| 4490 | } |
| 4491 | fn_last := fn; |
| 4492 | |
| 4493 | /* Compose the expected message */ |
| 4494 | pcu_rach_ind := tr_PCUIF_RACH_IND( |
Vadim Yanitskiy | 36558d9 | 2019-11-17 02:23:51 +0700 | [diff] [blame] | 4495 | bts_nr := 0, trx_nr := 0, ts_nr := 0, |
Vadim Yanitskiy | 51cbc10 | 2019-04-22 06:37:30 +0700 | [diff] [blame] | 4496 | ra := bit2int(ra11), |
| 4497 | is_11bit := 1, |
| 4498 | burst_type := pcu_bt, |
| 4499 | fn := fn); |
| 4500 | |
| 4501 | timer T := 2.0; |
| 4502 | T.start; |
| 4503 | alt { |
| 4504 | [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, pcu_rach_ind)) { |
| 4505 | T.stop; |
| 4506 | } |
| 4507 | [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RACH_IND)) { |
| 4508 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected RACH IND"); |
| 4509 | } |
| 4510 | [] PCU.receive { repeat; } |
| 4511 | [] T.timeout { |
| 4512 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for RACH IND"); |
| 4513 | } |
| 4514 | } |
| 4515 | } |
| 4516 | setverdict(pass); |
| 4517 | } |
| 4518 | |
Vadim Yanitskiy | a2c68e8 | 2019-07-03 13:07:20 +0700 | [diff] [blame] | 4519 | private function f_TC_pcu_data_ind_lqual_cb(int16_t lqual_cb_exp, int16_t thresh) |
| 4520 | runs on test_CT { |
| 4521 | var template PCUIF_send_data sdt; |
| 4522 | var PCUIF_send_data sd; |
| 4523 | var int16_t lqual_cb; |
| 4524 | timer T := 1.0; |
| 4525 | |
| 4526 | /* PCUIF_DATA.ind is encapsulated into a supplementary record */ |
| 4527 | sdt := t_SD_PCUIF_MSGT(g_pcu_conn_id, PCU_IF_MSG_DATA_IND); |
| 4528 | |
| 4529 | /* Send a random PDTCH frame over Um */ |
| 4530 | L1CTL.send(ts_L1CTL_TRAFFIC_REQ(ts_RslChanNr_PDCH(7), ts_RslLinkID_DCCH(0), |
| 4531 | '0000'O & f_rnd_octstring(21))); |
| 4532 | |
| 4533 | T.start; |
| 4534 | alt { |
| 4535 | /* If expected link quality is above the threshold */ |
| 4536 | [lqual_cb_exp >= thresh] PCU.receive(sdt) -> value sd { |
| 4537 | lqual_cb := sd.data.u.data_ind.lqual_cb; |
| 4538 | log("Rx PCUIF_DATA.ind (lqual_cb=", lqual_cb, ")"); |
| 4539 | |
| 4540 | /* Make sure the actual link quality matches the expected value */ |
| 4541 | if (not match(lqual_cb, lqual_cb_exp)) { |
| 4542 | setverdict(fail, log2str("Link quality ", lqual_cb, " does not match ", |
| 4543 | "expected value ", lqual_cb_exp)); |
| 4544 | } else { |
| 4545 | setverdict(pass); |
| 4546 | } |
| 4547 | } |
| 4548 | /* If expected link quality is below the threshold */ |
| 4549 | [lqual_cb_exp < thresh] PCU.receive(sdt) -> value sd { |
| 4550 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 4551 | log2str("Rx unexpected PCUIF_DATA.ind: ", sd.data)); |
| 4552 | } |
| 4553 | /* Ignore PCUIF_RTS.req and PCUIF_TIME.ind */ |
| 4554 | [] PCU.receive { repeat; } |
| 4555 | [lqual_cb_exp < thresh] T.timeout { |
| 4556 | log("Rx nothing, as expected"); |
| 4557 | setverdict(pass); |
| 4558 | } |
| 4559 | [lqual_cb_exp >= thresh] T.timeout { |
| 4560 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 4561 | "Timeout waiting for PCUIF_DATA.ind"); |
| 4562 | } |
| 4563 | } |
| 4564 | } |
| 4565 | |
| 4566 | /* Verify C/I (Carrier-to-Interference ratio) processing of PDTCH frames */ |
| 4567 | testcase TC_pcu_data_ind_lqual_cb() runs on test_CT { |
| 4568 | f_init_pcu_test(); |
| 4569 | PCU.clear; |
| 4570 | |
| 4571 | f_init_l1ctl(); |
| 4572 | f_l1_tune(L1CTL); |
| 4573 | |
| 4574 | /* Activate a PDCH channel on TS7 */ |
| 4575 | f_TC_pcu_act_req(0, 0, 7, true); |
| 4576 | |
| 4577 | /* Tune trxcon to that PDCH channel on TS7 */ |
| 4578 | f_L1CTL_DM_EST_REQ(L1CTL, { false, mp_trx0_arfcn }, |
| 4579 | valueof(ts_RslChanNr_PDCH(7)), 7); |
| 4580 | |
| 4581 | /* C/I in centiBels, test range: -256 .. +1280, step 128 */ |
| 4582 | for (var int16_t i := -256; i <= 1280; i := i + 128) { |
| 4583 | var TrxcMessage ret; |
| 4584 | |
| 4585 | ret := f_TRXC_transceive(BTS_TRXC, g_bts_trxc_conn_id, |
| 4586 | valueof(ts_TRXC_FAKE_CI(i))); |
| 4587 | |
| 4588 | /* FIXME: OsmoBTS may have different threshold (see MIN_QUAL_NORM) */ |
| 4589 | f_TC_pcu_data_ind_lqual_cb(i, thresh := 0); |
| 4590 | } |
| 4591 | } |
| 4592 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4593 | /* Send PAGING via RSL, expect it to shw up on PCU socket */ |
| 4594 | testcase TC_pcu_paging_from_rsl() runs on test_CT { |
Max | 2c6f563 | 2019-03-18 17:25:17 +0100 | [diff] [blame] | 4595 | f_init_pcu_test(); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4596 | |
| 4597 | for (var integer i := 0; i < 100; i := i+1) { |
Vadim Yanitskiy | cc4623d | 2020-03-28 06:14:06 +0700 | [diff] [blame] | 4598 | var MobileIdentityLV mi_lv; |
| 4599 | var octetstring mi_lv_enc; |
| 4600 | var MobileIdentityV mi; |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4601 | timer T := 3.0; |
Vadim Yanitskiy | cc4623d | 2020-03-28 06:14:06 +0700 | [diff] [blame] | 4602 | |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4603 | if (i < 50) { |
Vadim Yanitskiy | cc4623d | 2020-03-28 06:14:06 +0700 | [diff] [blame] | 4604 | mi := valueof(t_MI_TMSI(f_rnd_octstring(4))); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4605 | } else { |
Vadim Yanitskiy | cc4623d | 2020-03-28 06:14:06 +0700 | [diff] [blame] | 4606 | mi := valueof(ts_MI_IMSI(f_gen_imsi(i))); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4607 | } |
Vadim Yanitskiy | cc4623d | 2020-03-28 06:14:06 +0700 | [diff] [blame] | 4608 | |
| 4609 | /* Fancy encoding for PCUIF */ |
| 4610 | mi_lv := valueof(ts_MI_LV(mi)); |
| 4611 | mi_lv_enc := enc_MobileIdentityLV(mi_lv); |
| 4612 | mi_lv_enc := f_pad_oct(mi_lv_enc, 9, '00'O); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4613 | |
| 4614 | /* Send RSL PAGING COMMAND */ |
Vadim Yanitskiy | 493abe7 | 2020-05-25 22:03:48 +0700 | [diff] [blame] | 4615 | RSL_CCHAN.send(ts_ASP_RSL_UD(ts_RSL_PAGING_CMD(mi, i mod 4))); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4616 | T.start; |
| 4617 | alt { |
Vadim Yanitskiy | cc4623d | 2020-03-28 06:14:06 +0700 | [diff] [blame] | 4618 | [] 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] | 4619 | } |
| 4620 | [] 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] | 4621 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected PAGING REQ"); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4622 | } |
| 4623 | [] PCU.receive { repeat; } |
| 4624 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 4625 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for PAGING REQ"); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 4626 | } |
| 4627 | } |
| 4628 | } |
| 4629 | setverdict(pass); |
| 4630 | } |
| 4631 | |
Harald Welte | d66c9b8 | 2019-05-25 09:03:15 +0200 | [diff] [blame] | 4632 | /* test for periodic TIME_IND; check number of FN expired and number of TIME_IND within frames */ |
| 4633 | testcase TC_pcu_time_ind() runs on test_CT { |
| 4634 | var PCUIF_send_data pcu_sd; |
| 4635 | var integer num_time_ind := 0; |
| 4636 | var integer first_fn, last_fn; |
| 4637 | var float test_duration := 5.0; |
| 4638 | timer T; |
| 4639 | |
| 4640 | f_init_pcu_test(); |
| 4641 | f_TC_pcu_act_req(0, 0, 7, true); |
| 4642 | |
| 4643 | PCU.clear; |
| 4644 | T.start(test_duration); |
| 4645 | alt { |
| 4646 | [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_TIME_IND(0, ?))) -> value pcu_sd { |
| 4647 | num_time_ind := num_time_ind + 1; |
| 4648 | if (not isbound(first_fn)) { |
| 4649 | first_fn := pcu_sd.data.u.time_ind.fn; |
| 4650 | } |
| 4651 | last_fn := pcu_sd.data.u.time_ind.fn; |
| 4652 | repeat; |
| 4653 | } |
| 4654 | [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_TIME_IND(?, ?))) -> value pcu_sd { |
| 4655 | setverdict(fail, "Received unexpected PCUIF_TIME_IND: ", pcu_sd.data); |
| 4656 | repeat; |
| 4657 | } |
| 4658 | [] PCU.receive { |
| 4659 | repeat; |
| 4660 | } |
| 4661 | [] T.timeout {} |
| 4662 | } |
| 4663 | var integer fn_expired := last_fn - first_fn; |
| 4664 | log(fn_expired, " fn expired with ", num_time_ind, " PCU_TIME.ind"); |
| 4665 | |
| 4666 | /* verify the number of frames expired matches our expectation */ |
| 4667 | const float c_GSM_FN_DURATION_MS := 4.61538; |
| 4668 | 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] | 4669 | 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] | 4670 | if (not match(fn_expired, t_fn_expected)) { |
| 4671 | setverdict(fail, "Number of TDMA Frames (", fn_expired, ") not matching ", t_fn_expected); |
| 4672 | } |
| 4673 | |
| 4674 | /* There are three TIME.ind in every fn MOD 13 */ |
| 4675 | var float time_ind_expected := int2float(fn_expired) * 3.0 / 13.0; |
| 4676 | /* Add some tolerance */ |
| 4677 | var template integer t_time_ind_exp := f_tolerance(float2int(time_ind_expected), 1, 100000, 5); |
| 4678 | if (not match(num_time_ind, t_time_ind_exp)) { |
| 4679 | setverdict(fail, "Number of TIME.ind (", num_time_ind, ") not matching ", t_time_ind_exp); |
| 4680 | } |
| 4681 | |
| 4682 | setverdict(pass); |
| 4683 | } |
| 4684 | |
Harald Welte | 4832c86 | 2019-05-25 14:57:18 +0200 | [diff] [blame] | 4685 | /* test for periodic RTS_REQ; check number of FN expired and number of RTS_IND per SAPI */ |
| 4686 | testcase TC_pcu_rts_req() runs on test_CT { |
| 4687 | var PCUIF_send_data pcu_sd; |
| 4688 | var integer first_fn, last_fn; |
| 4689 | var integer num_rts_pdtch := 0; |
| 4690 | var integer num_rts_ptcch := 0; |
| 4691 | var float test_duration := 5.0; |
| 4692 | timer T; |
| 4693 | |
| 4694 | f_init_pcu_test(); |
| 4695 | f_TC_pcu_act_req(0, 0, 7, true); |
| 4696 | |
| 4697 | PCU.clear; |
| 4698 | T.start(test_duration); |
| 4699 | alt { |
| 4700 | [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RTS_REQ(0, 0, 7, PCU_IF_SAPI_PDTCH, ?, ?))) |
| 4701 | -> value pcu_sd { |
| 4702 | num_rts_pdtch := num_rts_pdtch + 1; |
| 4703 | if (not isbound(first_fn)) { |
| 4704 | first_fn := pcu_sd.data.u.rts_req.fn; |
| 4705 | } |
| 4706 | last_fn := pcu_sd.data.u.rts_req.fn; |
| 4707 | repeat; |
| 4708 | } |
| 4709 | [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RTS_REQ(0, 0, 7, PCU_IF_SAPI_PTCCH, ?, ?))) |
| 4710 | -> value pcu_sd { |
| 4711 | num_rts_ptcch := num_rts_ptcch + 1; |
| 4712 | if (not isbound(first_fn)) { |
| 4713 | first_fn := pcu_sd.data.u.rts_req.fn; |
| 4714 | } |
| 4715 | last_fn := pcu_sd.data.u.rts_req.fn; |
| 4716 | repeat; |
| 4717 | } |
| 4718 | [] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RTS_REQ)) -> value pcu_sd { |
| 4719 | setverdict(fail, "Received unexpected PCUIF_RTS_REQ: ", pcu_sd.data); |
| 4720 | repeat; |
| 4721 | } |
| 4722 | [] PCU.receive { |
| 4723 | repeat; |
| 4724 | } |
| 4725 | [] T.timeout {} |
| 4726 | } |
| 4727 | var integer fn_expired := last_fn - first_fn; |
| 4728 | log(fn_expired, " fn expired with num_rts_pdtch=", num_rts_pdtch, |
| 4729 | ", num_rts_ptcch=", num_rts_ptcch); |
| 4730 | |
| 4731 | /* verify the number of frames expired matches our expectation */ |
| 4732 | const float c_GSM_FN_DURATION_MS := 4.61538; |
| 4733 | 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] | 4734 | 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] | 4735 | if (not match(fn_expired, t_fn_expected)) { |
| 4736 | setverdict(fail, "Number of TDMA Frames (", fn_expired, ") not matching ", t_fn_expected); |
| 4737 | } |
| 4738 | |
| 4739 | /* PTCCH is in pos. 12 + 38 of 52-multiframe, but four slots/bursts required per block */ |
| 4740 | var float ptcch_expected := int2float(fn_expired) / 52.0 * 0.5; |
| 4741 | var template integer t_ptcch_exp := f_tolerance(float2int(ptcch_expected), 1, 100000, 1); |
| 4742 | if (not match(num_rts_ptcch, t_ptcch_exp)) { |
| 4743 | setverdict(fail, "Number of RTS.ind for PTCCH (", num_rts_ptcch, ") not matching ", |
| 4744 | t_ptcch_exp); |
| 4745 | } |
| 4746 | |
| 4747 | /* We have 12 PDTCH blocks every 52-multiframe */ |
| 4748 | var float pdtch_expected := int2float(fn_expired) / 52.0 * 12.0; |
| 4749 | var template integer t_pdtch_exp := f_tolerance(float2int(pdtch_expected), 1, 100000, 2); |
| 4750 | if (not match(num_rts_pdtch, t_pdtch_exp)) { |
| 4751 | setverdict(fail, "Number of RTS.ind for PDTCH (", num_rts_pdtch, ") not matching ", |
| 4752 | t_pdtch_exp); |
| 4753 | } |
| 4754 | |
| 4755 | setverdict(pass); |
| 4756 | } |
| 4757 | |
Harald Welte | 07bd2d2 | 2019-05-25 11:03:30 +0200 | [diff] [blame] | 4758 | /* test for generating Abis side OML ALERT from the PCU */ |
| 4759 | testcase TC_pcu_oml_alert() runs on test_CT { |
| 4760 | var PCUIF_send_data pcu_sd; |
| 4761 | var integer num_time_ind := 0; |
| 4762 | var integer first_fn, last_fn; |
| 4763 | var float test_duration := 5.0; |
| 4764 | timer T; |
| 4765 | |
| 4766 | f_init_pcu_test(); |
| 4767 | f_TC_pcu_act_req(0, 0, 7, true); |
| 4768 | |
| 4769 | /* re-connect CTRL port from BTS to BSC */ |
| 4770 | f_ipa_ctrl_stop(); |
| 4771 | f_ipa_ctrl_start(mp_bsc_ctrl_ip, mp_bsc_ctrl_port); |
| 4772 | |
| 4773 | /* Send that OML Alert */ |
| 4774 | PCU.send(t_SD_PCUIF(g_pcu_conn_id, ts_PCUIF_TXT_IND(0, PCU_OML_ALERT, testcasename()))); |
| 4775 | |
| 4776 | /* This requires https://gerrit.osmocom.org/#/c/osmo-bsc/+/14177 to be merged */ |
| 4777 | f_ctrl_exp_trap(IPA_CTRL, "bts.0.oml_failure_report", ?); |
| 4778 | setverdict(pass); |
| 4779 | } |
| 4780 | |
Harald Welte | eaa9a86 | 2019-05-26 23:01:08 +0200 | [diff] [blame] | 4781 | template (value) PDU_ML3_MS_NW ts_RRM_GprsSuspReq(template (value) OCT4 tlli, |
| 4782 | template (value) RoutingAreaIdentificationV rai, |
| 4783 | template (value) OCT1 cause) := { |
| 4784 | discriminator := '0000'B, /* overwritten */ |
| 4785 | tiOrSkip := { |
| 4786 | skipIndicator := '0000'B |
| 4787 | }, |
| 4788 | msgs := { |
| 4789 | rrm := { |
| 4790 | gPRS_suspensionRequest := { |
| 4791 | messageType := '00110100'B, |
| 4792 | tLLI := tlli, |
| 4793 | routingAreaIdentification := rai, |
| 4794 | suspensionCause := cause, |
| 4795 | service_Support := omit |
| 4796 | } |
| 4797 | } |
| 4798 | } |
| 4799 | } |
| 4800 | |
| 4801 | /* test for forwarding of RR SUSPEND from CS lchan to PCU via PCU socket */ |
| 4802 | private function f_TC_rr_suspend_req(charstring id) runs on ConnHdlr { |
| 4803 | var PCUIF_Message first_info; |
| 4804 | var integer pcu_conn_id := -1; |
| 4805 | var RslLinkId link_id := valueof(ts_RslLinkID_DCCH(0)); |
| 4806 | var RoutingAreaIdentificationV rai := f_RAI('262'H, '42F'H, '2342'O, '55'O); |
| 4807 | var OCT4 tlli := '01020304'O; |
| 4808 | var OCT1 cause := '23'O; |
| 4809 | timer T := 5.0; |
| 4810 | |
| 4811 | f_init_pcu(PCU, id, pcu_conn_id, first_info); |
| 4812 | |
| 4813 | f_l1_tune(L1CTL); |
| 4814 | RSL.clear; |
| 4815 | |
| 4816 | f_est_dchan(); |
| 4817 | L1CTL.clear; |
| 4818 | |
| 4819 | f_est_rll_mo(link_id.sapi, link_id, '23420815'O); |
| 4820 | |
| 4821 | var PDU_ML3_MS_NW susp_req := valueof(ts_RRM_GprsSuspReq(tlli, rai, cause)); |
| 4822 | var octetstring l3 := enc_PDU_ML3_MS_NW(susp_req); |
| 4823 | f_tx_lapdm(ts_LAPDm_I(link_id.sapi, cr_MO_CMD, true, 1, 0, l3), link_id); |
| 4824 | |
| 4825 | /* ConnHdlr has terminated after sending the RR SUSP REQ over a dedicaed channel */ |
| 4826 | T.start; |
| 4827 | alt { |
| 4828 | [] PCU.receive(t_SD_PCUIF(pcu_conn_id, tr_PCUIF_SUSP_REQ(0, tlli, ?, oct2int(cause)))) { |
| 4829 | setverdict(pass); |
| 4830 | } |
| 4831 | [] PCU.receive(t_SD_PCUIF(pcu_conn_id, tr_PCUIF_SUSP_REQ(?, ?, ?, ?))) { |
| 4832 | setverdict(fail, "Received unexpected PCUIF SUSPE REQ: "); |
| 4833 | } |
| 4834 | [] PCU.receive { |
| 4835 | repeat; |
| 4836 | } |
| 4837 | [] T.timeout { |
| 4838 | setverdict(fail, "Timeout waiting for SUSP REQ on PCUIF"); |
| 4839 | } |
| 4840 | } |
Alexander Couzens | a063483 | 2019-06-07 00:28:56 +0200 | [diff] [blame] | 4841 | |
| 4842 | /* release the channel */ |
| 4843 | f_rsl_chan_deact(); |
| 4844 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 4845 | f_rslem_unregister(0, g_chan_nr); |
Harald Welte | eaa9a86 | 2019-05-26 23:01:08 +0200 | [diff] [blame] | 4846 | } |
| 4847 | testcase TC_pcu_rr_suspend() runs on test_CT { |
| 4848 | var ConnHdlrPars pars; |
| 4849 | var ConnHdlr vc_conn; |
| 4850 | |
| 4851 | f_init(); |
| 4852 | |
| 4853 | pars := valueof(t_Pars(t_RslChanNr_SDCCH4(0,3), ts_RSL_ChanMode_SIGN)); |
| 4854 | vc_conn := f_start_handler(refers(f_TC_rr_suspend_req), pars, true); |
| 4855 | vc_conn.done; |
| 4856 | } |
Harald Welte | 07bd2d2 | 2019-05-25 11:03:30 +0200 | [diff] [blame] | 4857 | |
Harald Welte | a2e0e94 | 2019-05-27 18:12:53 +0200 | [diff] [blame] | 4858 | /* Ensure that PCUIF socket can accept only a single connection */ |
| 4859 | testcase TC_pcu_socket_connect_multi() runs on test_CT { |
| 4860 | timer T := 5.0; |
| 4861 | |
| 4862 | /* this (among other things) establishes the first connection to the PCUIF socket */ |
| 4863 | f_init(); |
| 4864 | |
| 4865 | /* try to establish a second connection, expect it to fail */ |
| 4866 | PCU.send(UD_connect:{mp_pcu_socket, -1}); |
| 4867 | T.start; |
| 4868 | alt { |
| 4869 | [] PCU.receive(UD_connect_result:{id := ?, result := { result_code := ERROR, err := ? }}) { |
| 4870 | setverdict(pass); |
| 4871 | } |
| 4872 | [] PCU.receive(UD_connect_result:?) { |
| 4873 | setverdict(fail, "Unexpected unix domain connect result"); |
| 4874 | } |
| 4875 | [] T.timeout { |
| 4876 | setverdict(pass); |
| 4877 | } |
| 4878 | } |
| 4879 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 4880 | } |
| 4881 | |
Harald Welte | c8effb7 | 2019-05-27 18:23:04 +0200 | [diff] [blame] | 4882 | /* Ensure that PCUIF socket can disconnect + reconnect */ |
| 4883 | testcase TC_pcu_socket_reconnect() runs on test_CT { |
| 4884 | /* this (among other things) establishes the first connection to the PCUIF socket */ |
| 4885 | f_init(); |
| 4886 | |
| 4887 | f_sleep(1.0); |
| 4888 | |
| 4889 | f_pcuif_close(PCU, g_pcu_conn_id); |
| 4890 | g_pcu_conn_id := -1; |
| 4891 | |
| 4892 | f_sleep(1.0); |
| 4893 | |
| 4894 | /* re-connect */ |
| 4895 | PCU.clear; |
| 4896 | f_init_pcu(PCU, testcasename(), g_pcu_conn_id, g_pcu_last_info); |
| 4897 | setverdict(pass); |
| 4898 | |
| 4899 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 4900 | } |
| 4901 | |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 4902 | /* Ensure that GPRS capability is not advertised before PCU socket conncet */ |
Vadim Yanitskiy | 3c18538 | 2020-05-04 14:55:02 +0700 | [diff] [blame] | 4903 | private function f_get_si(L1CTL_PT pt, RrMessageType si_type) |
| 4904 | runs on test_CT return SystemInformation { |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 4905 | var L1ctlDlMessage l1_dl; |
| 4906 | var SystemInformation si; |
| 4907 | timer T := 5.0; |
| 4908 | T.start; |
| 4909 | alt { |
| 4910 | [] pt.receive(tr_L1CTL_DATA_IND(t_RslChanNr_BCCH(0), ?)) -> value l1_dl { |
| 4911 | /* somehow dec_SystemInformation will try to decode even non-RR as SI */ |
| 4912 | if (not (l1_dl.payload.data_ind.payload[1] == '06'O)) { |
| 4913 | log("Ignoring non-RR SI ", l1_dl); |
| 4914 | repeat; |
| 4915 | } |
| 4916 | si := dec_SystemInformation(l1_dl.payload.data_ind.payload) |
Vadim Yanitskiy | 3c18538 | 2020-05-04 14:55:02 +0700 | [diff] [blame] | 4917 | if (si.header.message_type != si_type) { |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 4918 | repeat; |
| 4919 | } |
| 4920 | } |
| 4921 | [] pt.receive { |
| 4922 | repeat; |
| 4923 | } |
| 4924 | [] T.timeout { |
Vadim Yanitskiy | 3c18538 | 2020-05-04 14:55:02 +0700 | [diff] [blame] | 4925 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 4926 | log2str("Timeout waiting for ", si_type)); |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 4927 | } |
| 4928 | } |
Vadim Yanitskiy | 3c18538 | 2020-05-04 14:55:02 +0700 | [diff] [blame] | 4929 | return si; |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 4930 | } |
| 4931 | |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 4932 | /* Check if GPRS Indicator is present in RR System Information of a given type */ |
| 4933 | private function f_si_has_gprs_indicator(RrMessageType si_type) |
| 4934 | runs on test_CT return boolean { |
| 4935 | var SystemInformation si := f_get_si(L1CTL, si_type); |
| 4936 | |
| 4937 | if (si_type == SYSTEM_INFORMATION_TYPE_3) { |
| 4938 | var RestOctets ro := si.payload.si3.rest_octets; |
| 4939 | var SI3RestOctets rest := dec_SI3RestOctets(ro); |
| 4940 | return rest.gprs_ind.presence == '1'B; |
| 4941 | } else if (si_type == SYSTEM_INFORMATION_TYPE_4) { |
| 4942 | var RestOctets ro := si.payload.si4.rest_octets; |
| 4943 | var SI4RestOctets rest := dec_SI4RestOctets(ro); |
| 4944 | return rest.gprs_ind.presence == '1'B; |
| 4945 | } |
| 4946 | |
| 4947 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unhandled SI type"); |
| 4948 | return false; |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 4949 | } |
| 4950 | |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 4951 | /* Make sure that GPRS Indicator is absent when the PCU is not connected */ |
| 4952 | private function f_TC_pcu_socket_noconnect(RrMessageType si_type) |
| 4953 | runs on test_CT { |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 4954 | /* don't call f_init() as this would connect PCU socket */ |
| 4955 | f_init_rsl(testcasename()); |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 4956 | |
| 4957 | /* Send both System Information Type 3 and 4 (with GPRS Indicator) */ |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 4958 | f_rsl_bcch_fill(RSL_SYSTEM_INFO_3, ts_SI3_default); |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 4959 | f_rsl_bcch_fill(RSL_SYSTEM_INFO_4, ts_SI4_default); |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 4960 | |
| 4961 | f_init_l1ctl(); |
| 4962 | f_l1_tune(L1CTL); |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 4963 | f_sleep(2.0); |
| 4964 | L1CTL.clear; |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 4965 | |
| 4966 | if (f_si_has_gprs_indicator(si_type)) { |
| 4967 | setverdict(fail, si_type, " indicates GPRS even before PCU socket connected"); |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 4968 | } else { |
| 4969 | setverdict(pass); |
| 4970 | } |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 4971 | |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 4972 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 4973 | } |
| 4974 | |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 4975 | testcase TC_pcu_socket_noconnect_nosi3gprs() runs on test_CT { |
| 4976 | f_TC_pcu_socket_noconnect(SYSTEM_INFORMATION_TYPE_3); |
| 4977 | } |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 4978 | |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 4979 | testcase TC_pcu_socket_noconnect_nosi4gprs() runs on test_CT { |
| 4980 | f_TC_pcu_socket_noconnect(SYSTEM_INFORMATION_TYPE_4); |
| 4981 | } |
| 4982 | |
| 4983 | /* Ensure that GPRS capability is advertised after PCU socket connect */ |
| 4984 | private function f_TC_pcu_socket_connect(RrMessageType si_type) |
| 4985 | runs on test_CT { |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 4986 | /* this (among other things) establishes the first connection to the PCUIF socket */ |
| 4987 | f_init(); |
| 4988 | f_init_l1ctl(); |
| 4989 | f_l1_tune(L1CTL); |
| 4990 | |
| 4991 | f_sleep(2.0); |
| 4992 | L1CTL.clear; |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 4993 | |
| 4994 | if (not f_si_has_gprs_indicator(si_type)) { |
| 4995 | setverdict(fail, si_type, " indicates no GPRS despite PCU socket connected"); |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 4996 | } else { |
| 4997 | setverdict(pass); |
| 4998 | } |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 4999 | |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 5000 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 5001 | } |
| 5002 | |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 5003 | testcase TC_pcu_socket_connect_si3gprs() runs on test_CT { |
| 5004 | f_TC_pcu_socket_connect(SYSTEM_INFORMATION_TYPE_3); |
| 5005 | } |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 5006 | |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 5007 | testcase TC_pcu_socket_connect_si4gprs() runs on test_CT { |
| 5008 | f_TC_pcu_socket_connect(SYSTEM_INFORMATION_TYPE_4); |
| 5009 | } |
| 5010 | |
| 5011 | /* Ensure that GPRS capability is no longer advertised after PCU socket disconnect */ |
| 5012 | private function f_TC_pcu_socket_disconnect(RrMessageType si_type) |
| 5013 | runs on test_CT { |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 5014 | /* this (among other things) establishes the first connection to the PCUIF socket */ |
| 5015 | f_init(); |
| 5016 | f_init_l1ctl(); |
| 5017 | f_l1_tune(L1CTL); |
| 5018 | |
| 5019 | f_pcuif_close(PCU, g_pcu_conn_id); |
| 5020 | g_pcu_conn_id := -1; |
| 5021 | |
| 5022 | f_sleep(1.0); |
| 5023 | |
| 5024 | /* re-connect */ |
| 5025 | PCU.clear; |
| 5026 | f_init_pcu(PCU, testcasename(), g_pcu_conn_id, g_pcu_last_info); |
| 5027 | |
| 5028 | f_sleep(2.0); |
| 5029 | L1CTL.clear; |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 5030 | |
| 5031 | if (f_si_has_gprs_indicator(si_type)) { |
| 5032 | setverdict(fail, si_type, " indicates GPRS after PCU socket disconnected"); |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 5033 | } else { |
| 5034 | setverdict(pass); |
| 5035 | } |
| 5036 | |
| 5037 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
| 5038 | } |
| 5039 | |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 5040 | testcase TC_pcu_socket_disconnect_nosi3gprs() runs on test_CT { |
| 5041 | f_TC_pcu_socket_disconnect(SYSTEM_INFORMATION_TYPE_3); |
| 5042 | } |
| 5043 | |
| 5044 | testcase TC_pcu_socket_disconnect_nosi4gprs() runs on test_CT { |
| 5045 | f_TC_pcu_socket_disconnect(SYSTEM_INFORMATION_TYPE_4); |
| 5046 | } |
| 5047 | |
Oliver Smith | f5239c7 | 2019-08-28 10:01:25 +0200 | [diff] [blame] | 5048 | /* 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) */ |
| 5049 | testcase TC_pcu_socket_verify_info_ind() runs on test_CT { |
| 5050 | var SystemInformation si3 := valueof(ts_SI3_default); |
| 5051 | |
| 5052 | f_init(); |
| 5053 | |
| 5054 | /* Verify cell_id */ |
| 5055 | var uint16_t cell_id_si3 := si3.payload.si3.cell_id; |
| 5056 | var uint16_t cell_id_pcu := g_pcu_last_info.u.info_ind.cell_id; |
| 5057 | if (cell_id_si3 != cell_id_pcu) { |
Oliver Smith | e1c00f0 | 2019-09-04 11:35:56 +0200 | [diff] [blame] | 5058 | setverdict(fail, "Expected cell_id '", cell_id_si3, "' and got '", cell_id_pcu, "'. This either means,", |
| 5059 | " that the BTS is sending the wrong cell_id, or that the BTS sent it too early", |
| 5060 | " (OS#4179)"); |
Oliver Smith | f5239c7 | 2019-08-28 10:01:25 +0200 | [diff] [blame] | 5061 | } |
| 5062 | |
| 5063 | /* Verify LAC */ |
| 5064 | var uint16_t lac_si3 := si3.payload.si3.lai.lac; |
| 5065 | var uint16_t lac_pcu := g_pcu_last_info.u.info_ind.lac; |
| 5066 | if (lac_si3 != lac_pcu) { |
| 5067 | setverdict(fail, "Expected LAC ", lac_si3, " got: ", lac_pcu); |
| 5068 | } |
| 5069 | |
| 5070 | setverdict(pass); |
| 5071 | } |
Harald Welte | d66c9b8 | 2019-05-25 09:03:15 +0200 | [diff] [blame] | 5072 | |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 5073 | /*********************************************************************** |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 5074 | * Osmocom Style Dynamic Timeslot Support |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 5075 | ***********************************************************************/ |
| 5076 | |
| 5077 | private function f_dyn_osmo_pdch_act(integer pcu_conn_id, integer bts_nr, integer trx_nr) |
| 5078 | runs on ConnHdlr { |
| 5079 | var PCUIF_send_data sd; |
| 5080 | /* Expect BTS to immediately acknowledge activation as PDCH */ |
| 5081 | PCU.clear; |
| 5082 | f_rsl_chan_act(g_pars.chan_mode); |
| 5083 | /* expect INFO_IND on PCU interface listing TS as PDCH */ |
Pau Espin Pedrol | 202c2f7 | 2019-10-08 13:11:05 +0200 | [diff] [blame] | 5084 | timer T_wait := 2.0; |
| 5085 | T_wait.start; |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 5086 | alt { |
| 5087 | [] PCU.receive(t_SD_PCUIF(pcu_conn_id, tr_PCUIF_INFO_IND(bts_nr, ?))) -> value sd { |
| 5088 | if (substr(sd.data.u.info_ind.trx[trx_nr].pdch_mask, g_chan_nr.tn, 1) != '1'B) { |
Pau Espin Pedrol | 202c2f7 | 2019-10-08 13:11:05 +0200 | [diff] [blame] | 5089 | log("PCUIF_INFO_IND PDCH_MASK not yet '1' after PDCH ACT on TS", g_chan_nr.tn, |
| 5090 | " mask:", sd.data.u.info_ind.trx[trx_nr].pdch_mask); |
| 5091 | repeat; |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 5092 | } |
| 5093 | } |
| 5094 | [] PCU.receive { repeat; } |
Pau Espin Pedrol | 202c2f7 | 2019-10-08 13:11:05 +0200 | [diff] [blame] | 5095 | [] T_wait.timeout { |
| 5096 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 5097 | log2str("Timeout waiting for PCUIF_INFO_IND PDCH_MASK to be '1' on TS", g_chan_nr.tn)); |
| 5098 | } |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 5099 | } |
| 5100 | /* try to activate this PDCH from the PCU point of view */ |
| 5101 | PCU.send(t_SD_PCUIF(pcu_conn_id, ts_PCUIF_ACT_REQ(bts_nr, trx_nr, g_chan_nr.tn))); |
| 5102 | /* FIXME: is there a response? */ |
| 5103 | } |
| 5104 | |
| 5105 | private function f_dyn_osmo_pdch_deact(integer pcu_conn_id, integer bts_nr, integer trx_nr) |
| 5106 | runs on ConnHdlr { |
| 5107 | var PCUIF_send_data sd; |
| 5108 | /* Send RSL CHAN REL (deactivate) */ |
| 5109 | PCU.clear; |
| 5110 | RSL.send(ts_RSL_RF_CHAN_REL(g_chan_nr)); |
| 5111 | /* expect BTS to ask PCU to deactivate the channel */ |
Pau Espin Pedrol | 202c2f7 | 2019-10-08 13:11:05 +0200 | [diff] [blame] | 5112 | timer T_wait := 2.0; |
| 5113 | T_wait.start; |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 5114 | alt { |
| 5115 | [] PCU.receive(t_SD_PCUIF(pcu_conn_id, tr_PCUIF_INFO_IND(bts_nr, ?))) -> value sd { |
| 5116 | 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] | 5117 | log("PCUIF_INFO_IND PDCH_MASK not yet '0' after PDCH DEACT on TS", g_chan_nr.tn, |
| 5118 | " mask:", sd.data.u.info_ind.trx[trx_nr].pdch_mask); |
| 5119 | repeat; |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 5120 | } |
| 5121 | } |
| 5122 | [] PCU.receive { repeat; } |
Pau Espin Pedrol | 202c2f7 | 2019-10-08 13:11:05 +0200 | [diff] [blame] | 5123 | [] T_wait.timeout { |
| 5124 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 5125 | log2str("Timeout waiting for PCUIF_INFO_IND PDCH_MASK to be '0' on TS", g_chan_nr.tn)); |
| 5126 | } |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 5127 | } |
| 5128 | /* Emulate PCU asking BTS to deactivate PDCH */ |
| 5129 | PCU.send(t_SD_PCUIF(pcu_conn_id, ts_PCUIF_DEACT_REQ(bts_nr, trx_nr, g_chan_nr.tn))); |
| 5130 | alt { |
| 5131 | [] RSL.receive(tr_RSL_RF_CHAN_REL_ACK(g_chan_nr)) { |
| 5132 | setverdict(pass); |
| 5133 | } |
| 5134 | [] RSL.receive { repeat; } |
| 5135 | } |
| 5136 | } |
| 5137 | |
| 5138 | /* Activate Osmocom-style dynamic PDCH from BSC side */ |
| 5139 | function f_TC_dyn_osmo_pdch_act_deact(charstring id) runs on ConnHdlr { |
| 5140 | var PCUIF_Message first_info; |
| 5141 | var integer ts_nr := g_chan_nr.tn; |
| 5142 | var integer trx_nr := 0; |
| 5143 | var integer bts_nr := 0; |
| 5144 | var integer pcu_conn_id := -1; |
| 5145 | |
| 5146 | f_init_pcu(PCU, id, pcu_conn_id, first_info); |
| 5147 | |
| 5148 | f_dyn_osmo_pdch_act(pcu_conn_id, bts_nr, trx_nr); |
| 5149 | f_sleep(3.0); |
| 5150 | f_dyn_osmo_pdch_deact(pcu_conn_id, bts_nr, trx_nr); |
| 5151 | setverdict(pass); |
| 5152 | } |
| 5153 | testcase TC_dyn_osmo_pdch_act_deact() runs on test_CT { |
| 5154 | var ConnHdlrPars pars; |
| 5155 | var ConnHdlr vc_conn; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 5156 | f_init(); |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 5157 | |
| 5158 | pars := valueof(t_Pars(t_RslChanNr_PDCH(4), ts_RSL_ChanMode_SIGN)); |
| 5159 | vc_conn := f_start_handler(refers(f_TC_dyn_osmo_pdch_act_deact), pars, true); |
| 5160 | vc_conn.done; |
| 5161 | } |
| 5162 | |
| 5163 | /* send a RF CHAN REL for PDCH on an osmocom dynamci PDCH that's already inactive */ |
| 5164 | function f_TC_dyn_osmo_pdch_unsol_deact(charstring id) runs on ConnHdlr { |
| 5165 | var PCUIF_Message first_info; |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 5166 | var integer pcu_conn_id := -1; |
| 5167 | |
| 5168 | f_init_pcu(PCU, id, pcu_conn_id, first_info); |
| 5169 | |
Neels Hofmeyr | 9c50ca5 | 2018-05-08 20:37:54 +0200 | [diff] [blame] | 5170 | RSL.send(ts_RSL_RF_CHAN_REL(g_chan_nr)); |
| 5171 | /* since the lchan is already released, we don't expect any PCU changes, just a rel ack. */ |
| 5172 | RSL.receive(tr_RSL_RF_CHAN_REL_ACK(g_chan_nr)); |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 5173 | setverdict(pass); |
| 5174 | } |
| 5175 | testcase TC_dyn_osmo_pdch_unsol_deact() runs on test_CT { |
| 5176 | var ConnHdlrPars pars; |
| 5177 | var ConnHdlr vc_conn; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 5178 | f_init(); |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 5179 | |
| 5180 | pars := valueof(t_Pars(t_RslChanNr_PDCH(4), ts_RSL_ChanMode_SIGN)); |
| 5181 | vc_conn := f_start_handler(refers(f_TC_dyn_osmo_pdch_unsol_deact), pars, true); |
| 5182 | vc_conn.done; |
| 5183 | } |
| 5184 | |
| 5185 | /* try to RSL CHAN ACT a PDCH on an osmocom-style PDCH that's already active */ |
| 5186 | function f_TC_dyn_osmo_pdch_double_act(charstring id) runs on ConnHdlr { |
| 5187 | var PCUIF_Message first_info; |
| 5188 | var integer ts_nr := g_chan_nr.tn; |
| 5189 | var integer trx_nr := 0; |
| 5190 | var integer bts_nr := 0; |
| 5191 | var integer pcu_conn_id := -1; |
| 5192 | |
| 5193 | f_init_pcu(PCU, id, pcu_conn_id, first_info); |
| 5194 | |
| 5195 | f_dyn_osmo_pdch_act(pcu_conn_id, bts_nr, trx_nr); |
Neels Hofmeyr | df936a2 | 2018-05-08 22:07:57 +0200 | [diff] [blame] | 5196 | /* Send a second Chan Activ and expect it to be NACKed */ |
| 5197 | f_rsl_transceive(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode), tr_RSL_CHAN_ACT_NACK(g_chan_nr), |
| 5198 | "RSL CHAN ACT NACK"); |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 5199 | setverdict(pass); |
| 5200 | } |
| 5201 | testcase TC_dyn_osmo_pdch_double_act() runs on test_CT { |
| 5202 | var ConnHdlrPars pars; |
| 5203 | var ConnHdlr vc_conn; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 5204 | f_init(); |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 5205 | |
| 5206 | pars := valueof(t_Pars(t_RslChanNr_PDCH(4), ts_RSL_ChanMode_SIGN)); |
| 5207 | vc_conn := f_start_handler(refers(f_TC_dyn_osmo_pdch_double_act), pars, true); |
| 5208 | vc_conn.done; |
| 5209 | } |
| 5210 | |
| 5211 | /* try to RSL CHAN ACT a TCH/F on an osmocom-style PDCH */ |
| 5212 | function f_TC_dyn_osmo_pdch_tchf_act(charstring id) runs on ConnHdlr { |
| 5213 | var PCUIF_Message first_info; |
| 5214 | var integer ts_nr := g_chan_nr.tn; |
| 5215 | var integer trx_nr := 0; |
| 5216 | var integer bts_nr := 0; |
| 5217 | var integer pcu_conn_id := -1; |
| 5218 | var RslChannelNr chan_nr := valueof(t_RslChanNr_Bm(g_chan_nr.tn)); |
| 5219 | |
| 5220 | /* register for the TCH/F channel number */ |
| 5221 | f_rslem_register(0, chan_nr); |
| 5222 | |
| 5223 | f_init_pcu(PCU, id, pcu_conn_id, first_info); |
| 5224 | |
| 5225 | f_rsl_transceive(ts_RSL_CHAN_ACT(chan_nr, g_pars.chan_mode), tr_RSL_CHAN_ACT_ACK(chan_nr), |
| 5226 | "RSL CHAN ACT"); |
| 5227 | setverdict(pass); |
| 5228 | } |
| 5229 | testcase TC_dyn_osmo_pdch_tchf_act() runs on test_CT { |
| 5230 | var ConnHdlrPars pars; |
| 5231 | var ConnHdlr vc_conn; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 5232 | f_init(); |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 5233 | |
| 5234 | pars := valueof(t_Pars(t_RslChanNr_PDCH(4), ts_RSL_ChanMode_SIGN)); |
| 5235 | vc_conn := f_start_handler(refers(f_TC_dyn_osmo_pdch_tchf_act), pars, true); |
| 5236 | vc_conn.done; |
| 5237 | } |
| 5238 | |
| 5239 | /* try to RSL CHAN ACT the TCH/H on an osmocom-style PDCH */ |
| 5240 | function f_TC_dyn_osmo_pdch_tchh_act(charstring id) runs on ConnHdlr { |
| 5241 | var PCUIF_Message first_info; |
| 5242 | var integer ts_nr := g_chan_nr.tn; |
| 5243 | var integer trx_nr := 0; |
| 5244 | var integer bts_nr := 0; |
| 5245 | var integer pcu_conn_id := -1; |
| 5246 | var RslChannelNr chan_nr[2] := { valueof(t_RslChanNr_Lm(g_chan_nr.tn, 0)), |
| 5247 | valueof(t_RslChanNr_Lm(g_chan_nr.tn, 1)) }; |
| 5248 | |
| 5249 | /* register for the TCH/H channel numbers */ |
| 5250 | f_rslem_register(0, chan_nr[0]); |
| 5251 | f_rslem_register(0, chan_nr[1]); |
| 5252 | |
| 5253 | f_init_pcu(PCU, id, pcu_conn_id, first_info); |
| 5254 | |
| 5255 | f_rsl_transceive(ts_RSL_CHAN_ACT(chan_nr[1], g_pars.chan_mode), |
| 5256 | tr_RSL_CHAN_ACT_ACK(chan_nr[1]), "RSL CHAN ACT [1]"); |
| 5257 | f_rsl_transceive(ts_RSL_CHAN_ACT(chan_nr[0], g_pars.chan_mode), |
| 5258 | tr_RSL_CHAN_ACT_ACK(chan_nr[0]), "RSL CHAN ACT [0]"); |
| 5259 | setverdict(pass); |
| 5260 | } |
| 5261 | testcase TC_dyn_osmo_pdch_tchh_act() runs on test_CT { |
| 5262 | var ConnHdlrPars pars; |
| 5263 | var ConnHdlr vc_conn; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 5264 | f_init(); |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 5265 | |
| 5266 | pars := valueof(t_Pars(t_RslChanNr_PDCH(4), ts_RSL_ChanMode_SIGN)); |
| 5267 | vc_conn := f_start_handler(refers(f_TC_dyn_osmo_pdch_tchh_act), pars, true); |
| 5268 | vc_conn.done; |
| 5269 | } |
| 5270 | |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 5271 | /*********************************************************************** |
| 5272 | * IPA Style Dynamic Timeslot Support |
| 5273 | ***********************************************************************/ |
| 5274 | |
| 5275 | private function f_dyn_ipa_pdch_act(integer pcu_conn_id, integer bts_nr, integer trx_nr) |
| 5276 | runs on ConnHdlr { |
| 5277 | var PCUIF_send_data sd; |
| 5278 | /* Expect BTS to immediately acknowledge activation as PDCH */ |
| 5279 | PCU.clear; |
| 5280 | RSL.send(ts_RSL_IPA_PDCH_ACT(g_chan_nr)); |
| 5281 | /* expect INFO_IND on PCU interface listing TS as PDCH */ |
Pau Espin Pedrol | 446e07b | 2019-02-18 21:18:36 +0100 | [diff] [blame] | 5282 | timer T_wait := 2.0; |
| 5283 | T_wait.start; |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 5284 | alt { |
| 5285 | [] PCU.receive(t_SD_PCUIF(pcu_conn_id, tr_PCUIF_INFO_IND(bts_nr, ?))) -> value sd { |
| 5286 | 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] | 5287 | log("PCUIF_INFO_IND PDCH_MASK not yet '1' after PDCH ACT on TS", g_chan_nr.tn, |
| 5288 | " mask:", sd.data.u.info_ind.trx[trx_nr].pdch_mask); |
| 5289 | repeat; |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 5290 | } |
| 5291 | } |
| 5292 | [] PCU.receive { repeat; } |
Pau Espin Pedrol | 446e07b | 2019-02-18 21:18:36 +0100 | [diff] [blame] | 5293 | [] T_wait.timeout { |
| 5294 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 5295 | log2str("Timeout waiting for PCUIF_INFO_IND PDCH_MASK to be '1' on TS", g_chan_nr.tn)); |
| 5296 | } |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 5297 | } |
| 5298 | /* try to activate this PDCH from the PCU point of view */ |
| 5299 | PCU.send(t_SD_PCUIF(pcu_conn_id, ts_PCUIF_ACT_REQ(bts_nr, trx_nr, g_chan_nr.tn))); |
| 5300 | /* FIXME: is there a response? */ |
| 5301 | |
| 5302 | RSL.receive(tr_RSL_IPA_PDCH_ACT_ACK(g_chan_nr, ?)); |
| 5303 | } |
| 5304 | |
| 5305 | private function f_dyn_ipa_pdch_deact(integer pcu_conn_id, integer bts_nr, integer trx_nr) |
| 5306 | runs on ConnHdlr { |
| 5307 | var PCUIF_send_data sd; |
| 5308 | /* Send RSL CHAN REL (deactivate) */ |
| 5309 | RSL.send(ts_RSL_IPA_PDCH_DEACT(g_chan_nr)); |
| 5310 | PCU.clear; |
| 5311 | /* expect BTS to ask PCU to deactivate the channel */ |
Pau Espin Pedrol | 446e07b | 2019-02-18 21:18:36 +0100 | [diff] [blame] | 5312 | timer T_wait := 2.0; |
| 5313 | T_wait.start; |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 5314 | alt { |
| 5315 | [] PCU.receive(t_SD_PCUIF(pcu_conn_id, tr_PCUIF_INFO_IND(bts_nr, ?))) -> value sd { |
| 5316 | 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] | 5317 | log("PCUIF_INFO_IND PDCH_MASK not yet '0' after PDCH DEACT on TS", g_chan_nr.tn, |
| 5318 | " mask:", sd.data.u.info_ind.trx[trx_nr].pdch_mask); |
| 5319 | repeat; |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 5320 | } |
| 5321 | } |
| 5322 | [] PCU.receive { repeat; } |
Pau Espin Pedrol | 446e07b | 2019-02-18 21:18:36 +0100 | [diff] [blame] | 5323 | [] T_wait.timeout { |
| 5324 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, |
| 5325 | log2str("Timeout waiting for PCUIF_INFO_IND PDCH_MASK to be '0' on TS", g_chan_nr.tn)); |
| 5326 | } |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 5327 | } |
| 5328 | /* Emulate PCU asking BTS to deactivate PDCH */ |
| 5329 | PCU.send(t_SD_PCUIF(pcu_conn_id, ts_PCUIF_DEACT_REQ(bts_nr, trx_nr, g_chan_nr.tn))); |
| 5330 | alt { |
| 5331 | [] RSL.receive(tr_RSL_IPA_PDCH_DEACT_ACK(g_chan_nr)) { |
| 5332 | setverdict(pass); |
| 5333 | } |
| 5334 | [] RSL.receive { repeat; } |
| 5335 | } |
| 5336 | } |
| 5337 | |
| 5338 | /* Activate and de-activate an IPA-style dynamic TCH/F + PDCH */ |
| 5339 | function f_TC_dyn_ipa_pdch_act_deact(charstring id) runs on ConnHdlr { |
| 5340 | var PCUIF_Message first_info; |
| 5341 | var integer ts_nr := g_chan_nr.tn; |
| 5342 | var integer trx_nr := 0; |
| 5343 | var integer bts_nr := 0; |
| 5344 | var integer pcu_conn_id := -1; |
| 5345 | |
| 5346 | f_init_pcu(PCU, id, pcu_conn_id, first_info); |
| 5347 | |
| 5348 | f_dyn_ipa_pdch_act(pcu_conn_id, bts_nr, trx_nr); |
| 5349 | f_sleep(3.0); |
| 5350 | f_dyn_ipa_pdch_deact(pcu_conn_id, bts_nr, trx_nr); |
| 5351 | |
| 5352 | setverdict(pass); |
| 5353 | |
| 5354 | } |
| 5355 | testcase TC_dyn_ipa_pdch_act_deact() runs on test_CT { |
| 5356 | var ConnHdlrPars pars; |
| 5357 | var ConnHdlr vc_conn; |
| 5358 | f_init(); |
| 5359 | |
| 5360 | pars := valueof(t_Pars(t_RslChanNr_Bm(3), ts_RSL_ChanMode_SIGN)); |
| 5361 | vc_conn := f_start_handler(refers(f_TC_dyn_ipa_pdch_act_deact), pars, true); |
| 5362 | vc_conn.done; |
| 5363 | } |
| 5364 | |
| 5365 | /* try to RSL CHAN ACT a TCH/F on an IPA-style PDCH */ |
| 5366 | function f_TC_dyn_ipa_pdch_tchf_act(charstring id) runs on ConnHdlr { |
| 5367 | var PCUIF_Message first_info; |
| 5368 | var integer ts_nr := g_chan_nr.tn; |
| 5369 | var integer trx_nr := 0; |
| 5370 | var integer bts_nr := 0; |
| 5371 | var integer pcu_conn_id := -1; |
| 5372 | |
| 5373 | f_init_pcu(PCU, id, pcu_conn_id, first_info); |
| 5374 | |
| 5375 | f_rsl_transceive(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode), tr_RSL_CHAN_ACT_ACK(g_chan_nr), |
| 5376 | "RSL CHAN ACT"); |
| 5377 | f_rsl_transceive(ts_RSL_RF_CHAN_REL(g_chan_nr), tr_RSL_RF_CHAN_REL_ACK(g_chan_nr), |
| 5378 | "RF CHAN REL", true); |
| 5379 | setverdict(pass); |
| 5380 | } |
| 5381 | testcase TC_dyn_ipa_pdch_tchf_act() runs on test_CT { |
| 5382 | var ConnHdlrPars pars; |
| 5383 | var ConnHdlr vc_conn; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 5384 | f_init(); |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 5385 | |
| 5386 | pars := valueof(t_Pars(t_RslChanNr_Bm(3), ts_RSL_ChanMode_SIGN)); |
| 5387 | vc_conn := f_start_handler(refers(f_TC_dyn_ipa_pdch_tchf_act), pars, true); |
| 5388 | vc_conn.done; |
| 5389 | } |
| 5390 | |
| 5391 | /* Activate IPA style dyn PDCH as TCH/F and then illegally try to activate it as PDCH, too */ |
| 5392 | function f_TC_dyn_ipa_pdch_tchf_act_pdch_act_nack(charstring id) runs on ConnHdlr { |
| 5393 | var PCUIF_Message first_info; |
| 5394 | var integer ts_nr := g_chan_nr.tn; |
| 5395 | var integer trx_nr := 0; |
| 5396 | var integer bts_nr := 0; |
| 5397 | var integer pcu_conn_id := -1; |
| 5398 | |
| 5399 | f_init_pcu(PCU, id, pcu_conn_id, first_info); |
| 5400 | |
| 5401 | f_rsl_transceive(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode), tr_RSL_CHAN_ACT_ACK(g_chan_nr), |
| 5402 | "RSL CHAN ACT"); |
| 5403 | |
| 5404 | RSL.send(ts_RSL_IPA_PDCH_ACT(g_chan_nr)); |
| 5405 | alt { |
| 5406 | [] RSL.receive(tr_RSL_IPA_PDCH_ACT_NACK(g_chan_nr, ?)); |
| 5407 | [] RSL.receive(tr_RSL_IPA_PDCH_ACT_ACK(g_chan_nr, ?)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 5408 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected PDCH ACT ACK"); |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 5409 | } |
| 5410 | [] RSL.receive { repeat; } |
| 5411 | } |
| 5412 | |
| 5413 | f_rsl_transceive(ts_RSL_RF_CHAN_REL(g_chan_nr), tr_RSL_RF_CHAN_REL_ACK(g_chan_nr), |
| 5414 | "RF CHAN REL", true); |
| 5415 | setverdict(pass); |
| 5416 | } |
| 5417 | testcase TC_dyn_ipa_pdch_tchf_act_pdch_act_nack() runs on test_CT { |
| 5418 | var ConnHdlrPars pars; |
| 5419 | var ConnHdlr vc_conn; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 5420 | f_init(); |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 5421 | |
| 5422 | pars := valueof(t_Pars(t_RslChanNr_Bm(3), ts_RSL_ChanMode_SIGN)); |
| 5423 | vc_conn := f_start_handler(refers(f_TC_dyn_ipa_pdch_tchf_act_pdch_act_nack), pars, true); |
| 5424 | vc_conn.done; |
| 5425 | } |
| 5426 | |
| 5427 | /* try to RSL CHAN ACT a TCH/F on an IPA-style PDCH that's already in PDCH mode; expect NACK */ |
| 5428 | function f_TC_dyn_ipa_pdch_act_tchf_act_nack(charstring id) runs on ConnHdlr { |
| 5429 | var PCUIF_Message first_info; |
| 5430 | var integer ts_nr := g_chan_nr.tn; |
| 5431 | var integer trx_nr := 0; |
| 5432 | var integer bts_nr := 0; |
| 5433 | var integer pcu_conn_id := -1; |
| 5434 | |
| 5435 | /* register for the TCH/F channel number */ |
| 5436 | f_rslem_register(0, g_chan_nr); |
| 5437 | |
| 5438 | f_init_pcu(PCU, id, pcu_conn_id, first_info); |
| 5439 | |
| 5440 | f_dyn_ipa_pdch_act(pcu_conn_id, bts_nr, trx_nr); |
| 5441 | |
| 5442 | f_rsl_transceive(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode), tr_RSL_CHAN_ACT_NACK(g_chan_nr), |
| 5443 | "RSL CHAN ACT"); |
| 5444 | |
| 5445 | f_dyn_ipa_pdch_deact(pcu_conn_id, bts_nr, trx_nr); |
| 5446 | |
| 5447 | setverdict(pass); |
| 5448 | } |
| 5449 | testcase TC_dyn_ipa_pdch_act_tchf_act_nack() runs on test_CT { |
| 5450 | var ConnHdlrPars pars; |
| 5451 | var ConnHdlr vc_conn; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 5452 | f_init(); |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 5453 | |
| 5454 | pars := valueof(t_Pars(t_RslChanNr_Bm(3), ts_RSL_ChanMode_SIGN)); |
| 5455 | vc_conn := f_start_handler(refers(f_TC_dyn_ipa_pdch_act_tchf_act_nack), pars, true); |
| 5456 | vc_conn.done; |
| 5457 | } |
| 5458 | |
| 5459 | |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 5460 | /*********************************************************************** |
| 5461 | * LAPDm / RLL related |
| 5462 | ***********************************************************************/ |
| 5463 | |
| 5464 | private function f_tx_lapdm(template (value) LapdmFrame l, |
| 5465 | template (value) RslLinkId link_id) runs on ConnHdlr { |
| 5466 | var octetstring l2 := enc_LapdmFrame(valueof(l)); |
Vadim Yanitskiy | 0a8d6da | 2019-05-28 22:18:28 +0700 | [diff] [blame] | 5467 | var template (value) SacchL1Header l1h; |
| 5468 | |
| 5469 | /* 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] | 5470 | if (valueof(link_id.c) == SACCH) { |
Vadim Yanitskiy | 0a8d6da | 2019-05-28 22:18:28 +0700 | [diff] [blame] | 5471 | /* Compose dummy L1 header */ |
| 5472 | l1h := ts_SacchL1Header(g_pars.l1_pars.ms_power_level, false, g_pars.l1_pars.ms_actual_ta); |
| 5473 | 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] | 5474 | } else { |
| 5475 | /* If required, pad L2 frame with constant 0x2b filling */ |
Vadim Yanitskiy | 0a8d6da | 2019-05-28 22:18:28 +0700 | [diff] [blame] | 5476 | 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] | 5477 | } |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 5478 | } |
| 5479 | |
| 5480 | type record RllTestCase { |
| 5481 | uint3_t sapi, |
| 5482 | RslLinkId link_id, |
| 5483 | octetstring l3, |
| 5484 | boolean exp |
| 5485 | } |
| 5486 | type record of RllTestCase RllTestCases; |
| 5487 | template RllTestCase t_EITC(uint3_t sapi, RslLinkId id, octetstring l3, boolean exp) := { |
| 5488 | sapi := sapi, |
| 5489 | link_id := id, |
| 5490 | l3 := l3, |
| 5491 | exp := exp |
| 5492 | } |
| 5493 | |
| 5494 | /* execute the same callback function with a set of different parameters (tcs) on a |
| 5495 | * variety of logical channels */ |
| 5496 | private function f_rll_testmatrix(RllTestCases tcs, void_fn fn) runs on test_CT { |
| 5497 | var ConnHdlrPars pars; |
| 5498 | var ConnHdlr vc_conn; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 5499 | f_init(); |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 5500 | |
| 5501 | /* test on each of the channels we have */ |
| 5502 | for (var integer i := 0; i < sizeof(g_AllChanTypes); i := i+1) { |
| 5503 | pars := valueof(t_Pars(g_AllChanTypes[i], ts_RSL_ChanMode_SIGN)); |
| 5504 | |
| 5505 | /* test each of the test cases on the current channel */ |
| 5506 | for (var integer j := 0; j < sizeof(tcs); j := j+1) { |
| 5507 | pars.spec.rll := tcs[j]; |
| 5508 | log(testcasename(), ": XXX Starting ", tcs[j] , " on ", g_AllChanTypes[i]); |
| 5509 | vc_conn := f_start_handler(fn, pars); |
| 5510 | vc_conn.done; |
| 5511 | } |
| 5512 | } |
| 5513 | |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 5514 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__); |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 5515 | } |
| 5516 | |
| 5517 | /* test if SABM on Um triggers EST IND (TS 48.058 3.1) */ |
| 5518 | private function f_TC_rll_est_ind(charstring id) runs on ConnHdlr { |
| 5519 | var RllTestCase tc := g_pars.spec.rll; |
| 5520 | timer T := 3.0; |
| 5521 | |
| 5522 | f_l1_tune(L1CTL); |
| 5523 | RSL.clear; |
| 5524 | |
| 5525 | /* activate the logical channel */ |
| 5526 | f_est_dchan(); |
| 5527 | L1CTL.clear; |
| 5528 | |
| 5529 | f_tx_lapdm(ts_LAPDm_SABM(tc.sapi, cr_MO_CMD, true, tc.l3), tc.link_id); |
| 5530 | T.start; |
| 5531 | alt { |
| 5532 | [tc.l3 != ''O] RSL.receive(tr_RSL_EST_IND(g_chan_nr, tc.link_id, tc.l3)) { |
| 5533 | if (tc.exp) { |
| 5534 | setverdict(pass); |
| 5535 | } else { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 5536 | 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] | 5537 | } |
| 5538 | } |
| 5539 | [tc.l3 == ''O] RSL.receive(tr_RSL_EST_IND_NOL3(g_chan_nr, tc.link_id)) { |
| 5540 | if (tc.exp) { |
| 5541 | setverdict(pass); |
| 5542 | } else { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 5543 | 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] | 5544 | } |
| 5545 | } |
Vadim Yanitskiy | 3567787 | 2018-10-04 17:30:21 +0700 | [diff] [blame] | 5546 | /* We also expect to receive the measurements */ |
| 5547 | [] as_meas_res(verify_meas := false); |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 5548 | [tc.exp] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 5549 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for EST IND"); |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 5550 | } |
| 5551 | [not tc.exp] T.timeout { |
| 5552 | setverdict(pass); |
| 5553 | } |
| 5554 | } |
| 5555 | |
| 5556 | f_rsl_chan_deact(); |
| 5557 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 5558 | f_rslem_unregister(0, g_chan_nr); |
| 5559 | } |
| 5560 | testcase TC_rll_est_ind() runs on test_CT { |
| 5561 | var RllTestCases tcs := { |
Harald Welte | 7aacbbf | 2018-05-09 16:56:41 +0200 | [diff] [blame] | 5562 | /* SAPI0 establishment (contention resolution) */ |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 5563 | valueof(t_EITC(0, valueof(ts_RslLinkID_DCCH(0)), '01020304'O, true)), |
Harald Welte | 7aacbbf | 2018-05-09 16:56:41 +0200 | [diff] [blame] | 5564 | /* normal SAPI0 establishment */ |
| 5565 | valueof(t_EITC(0, valueof(ts_RslLinkID_DCCH(0)), ''O, true)), |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 5566 | /* SAPI 3 doesn't support contention resolution */ |
| 5567 | valueof(t_EITC(3, valueof(ts_RslLinkID_DCCH(3)), '01020304'O, false)), |
| 5568 | valueof(t_EITC(3, valueof(ts_RslLinkID_SACCH(3)), '01020304'O, false)), |
| 5569 | /* normal SAPI3 establishment on main DCCH */ |
| 5570 | valueof(t_EITC(3, valueof(ts_RslLinkID_DCCH(3)), ''O, true)), |
| 5571 | /* normal SAPI3 establishment on SACCH */ |
| 5572 | valueof(t_EITC(3, valueof(ts_RslLinkID_SACCH(3)), ''O, true)) |
| 5573 | }; |
| 5574 | f_rll_testmatrix(tcs, refers(f_TC_rll_est_ind)); |
| 5575 | } |
| 5576 | |
| 5577 | /* test if RLL EST REQ trigeres SABM on Um; UA on Um triggers EST CONF (TS 48.058 3.2) */ |
| 5578 | private function f_TC_rll_est_req(charstring id) runs on ConnHdlr { |
| 5579 | var RllTestCase tc := g_pars.spec.rll; |
| 5580 | var L1ctlDlMessage dl; |
| 5581 | timer T := 3.0; |
| 5582 | |
| 5583 | f_l1_tune(L1CTL); |
| 5584 | RSL.clear; |
| 5585 | |
| 5586 | /* activate the logical channel */ |
| 5587 | f_est_dchan(); |
| 5588 | L1CTL.clear; |
| 5589 | |
| 5590 | /* Send a RSL EST REQ for SAPI3 on main DCCH */ |
| 5591 | RSL.send(ts_RSL_EST_REQ(g_chan_nr, tc.link_id)); |
| 5592 | T.start; |
| 5593 | alt { |
| 5594 | [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, ?)) -> value dl { |
| 5595 | var LapdmFrame lapdm; |
| 5596 | var octetstring l2 := dl.payload.data_ind.payload; |
| 5597 | if (dl.dl_info.link_id.c == SACCH) { |
| 5598 | /* remove L1 header */ |
| 5599 | l2 := substr(l2, 2, lengthof(l2)-2); |
| 5600 | } |
| 5601 | lapdm.ab := dec_LapdmFrameAB(l2); |
| 5602 | if (match(lapdm, tr_LAPDm_SABM(tc.sapi, cr_MT_CMD, true, ''O))) { |
| 5603 | setverdict(pass); |
| 5604 | } else { |
| 5605 | repeat; |
| 5606 | } |
| 5607 | } |
| 5608 | [] L1CTL.receive { repeat; } |
| 5609 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 5610 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for SABM"); |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 5611 | } |
| 5612 | } |
| 5613 | |
| 5614 | f_rsl_chan_deact(); |
| 5615 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 5616 | f_rslem_unregister(0, g_chan_nr); |
| 5617 | } |
| 5618 | testcase TC_rll_est_req_DCCH_3() runs on test_CT { |
| 5619 | var RllTestCases tcs := { |
| 5620 | /* normal SAPI3 establishment on main DCCH */ |
| 5621 | valueof(t_EITC(3, valueof(ts_RslLinkID_DCCH(3)), ''O, true))//, |
| 5622 | }; |
| 5623 | f_rll_testmatrix(tcs, refers(f_TC_rll_est_req)); |
| 5624 | } |
| 5625 | testcase TC_rll_est_req_ACCH_3() runs on test_CT { |
| 5626 | var RllTestCases tcs := { |
| 5627 | /* normal SAPI3 establishment on SACCH */ |
| 5628 | valueof(t_EITC(3, valueof(ts_RslLinkID_SACCH(3)), ''O, true)) |
| 5629 | } |
| 5630 | f_rll_testmatrix(tcs, refers(f_TC_rll_est_req)); |
| 5631 | } |
| 5632 | |
| 5633 | /* altstep to receive a LAPDm frame matching the given template */ |
| 5634 | private altstep as_l1_exp_lapdm(template LapdmFrame exp) runs on ConnHdlr { |
| 5635 | var L1ctlDlMessage dl; |
| 5636 | [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, ?)) -> value dl { |
| 5637 | var LapdmFrame lapdm; |
| 5638 | var octetstring l2 := dl.payload.data_ind.payload; |
| 5639 | if (dl.dl_info.link_id.c == SACCH) { |
| 5640 | /* remove L1 header */ |
| 5641 | l2 := substr(l2, 2, lengthof(l2)-2); |
| 5642 | } |
| 5643 | if (ischosen(exp.ab)) { |
| 5644 | lapdm.ab := dec_LapdmFrameAB(l2); |
| 5645 | } else if (ischosen(exp.b4)) { |
| 5646 | lapdm.b4 := dec_LapdmFrameB4(l2); |
| 5647 | } else if (ischosen(exp.bbis)) { |
| 5648 | lapdm.bbis := dec_LapdmFrameBbis(l2); |
| 5649 | } |
| 5650 | log("Rx LAPDm ", lapdm); |
| 5651 | if (match(lapdm, exp)) { |
| 5652 | setverdict(pass); |
| 5653 | } else { |
| 5654 | repeat; |
| 5655 | } |
| 5656 | } |
| 5657 | [] L1CTL.receive { repeat; } |
| 5658 | } |
| 5659 | private function f_l1_exp_lapdm(template LapdmFrame exp, float t := 3.0) runs on ConnHdlr { |
| 5660 | timer T := t; |
| 5661 | T.start; |
| 5662 | alt { |
| 5663 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 5664 | 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] | 5665 | } |
| 5666 | [] as_l1_exp_lapdm(exp); |
| 5667 | } |
| 5668 | } |
| 5669 | |
| 5670 | /* establish one Radio Link Layer via SABM -> UA. Use l3 for contention resolution */ |
| 5671 | private function f_est_rll_mo(uint3_t sapi, RslLinkId link_id, octetstring l3) runs on ConnHdlr { |
| 5672 | /* send SABM from MS -> BTS */ |
| 5673 | f_tx_lapdm(ts_LAPDm_SABM(sapi, cr_MO_CMD, true, l3), link_id); |
| 5674 | /* expect RLL EST IND on Abis */ |
| 5675 | alt { |
| 5676 | [l3 != ''O] RSL.receive(tr_RSL_EST_IND(g_chan_nr, link_id, l3)); |
| 5677 | [l3 == ''O] RSL.receive(tr_RSL_EST_IND_NOL3(g_chan_nr, link_id)); |
| 5678 | [] RSL.receive(tr_RSL_ERROR_IND(g_chan_nr, link_id, ?)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 5679 | 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] | 5680 | } |
| 5681 | [] RSL.receive { repeat; } |
| 5682 | } |
| 5683 | /* expect UA from BTS -> MS */ |
| 5684 | f_l1_exp_lapdm(tr_LAPDm_UA(sapi, cr_MT_RSP, true, l3)); |
| 5685 | } |
| 5686 | |
| 5687 | /* test if DISC on Um triggers RLL REL IND (TS 48.058 3.3) */ |
| 5688 | private function f_TC_rll_rel_ind(charstring id) runs on ConnHdlr { |
| 5689 | var RllTestCase tc := g_pars.spec.rll; |
| 5690 | |
| 5691 | f_l1_tune(L1CTL); |
| 5692 | RSL.clear; |
| 5693 | |
| 5694 | /* activate the logical channel */ |
| 5695 | f_est_dchan(); |
| 5696 | L1CTL.clear; |
| 5697 | |
| 5698 | /* first establish the link-layer */ |
| 5699 | f_est_rll_mo(tc.sapi, tc.link_id, tc.l3); |
| 5700 | |
| 5701 | /* then send the DISC */ |
| 5702 | f_tx_lapdm(ts_LAPDm_DISC(tc.sapi, cr_MO_CMD, true), tc.link_id); |
| 5703 | /* ... and expect the REL IND on the RSL side */ |
| 5704 | alt { |
| 5705 | [] RSL.receive(tr_RSL_REL_IND(g_chan_nr, tc.link_id)) { |
| 5706 | setverdict(pass); |
| 5707 | } |
Vadim Yanitskiy | 3567787 | 2018-10-04 17:30:21 +0700 | [diff] [blame] | 5708 | /* We also expect to receive the measurements */ |
| 5709 | [] as_meas_res(verify_meas := false); |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 5710 | } |
| 5711 | |
| 5712 | /* release the channel */ |
| 5713 | f_rsl_chan_deact(); |
| 5714 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 5715 | f_rslem_unregister(0, g_chan_nr); |
| 5716 | } |
| 5717 | testcase TC_rll_rel_ind_DCCH_0() runs on test_CT { |
| 5718 | var RllTestCases tcs := { |
| 5719 | valueof(t_EITC(0, valueof(ts_RslLinkID_DCCH(0)), '01020304'O, true)) |
| 5720 | }; |
| 5721 | f_rll_testmatrix(tcs, refers(f_TC_rll_rel_ind)); |
| 5722 | } |
| 5723 | |
| 5724 | testcase TC_rll_rel_ind_ACCH_0() runs on test_CT { |
| 5725 | var RllTestCases tcs := { |
| 5726 | valueof(t_EITC(0, valueof(ts_RslLinkID_SACCH(0)), ''O, true)) |
| 5727 | }; |
| 5728 | f_rll_testmatrix(tcs, refers(f_TC_rll_rel_ind)); |
| 5729 | } |
| 5730 | testcase TC_rll_rel_ind_DCCH_3() runs on test_CT { |
| 5731 | var RllTestCases tcs := { |
| 5732 | valueof(t_EITC(3, valueof(ts_RslLinkID_DCCH(3)), ''O, true)) |
| 5733 | }; |
| 5734 | f_rll_testmatrix(tcs, refers(f_TC_rll_rel_ind)); |
| 5735 | } |
| 5736 | testcase TC_rll_rel_ind_ACCH_3() runs on test_CT { |
| 5737 | var RllTestCases tcs := { |
| 5738 | valueof(t_EITC(3, valueof(ts_RslLinkID_SACCH(3)), ''O, true)) |
| 5739 | }; |
| 5740 | f_rll_testmatrix(tcs, refers(f_TC_rll_rel_ind)); |
| 5741 | } |
| 5742 | |
| 5743 | /* test if RLL REL REQ triggers DISC on Um; UA/DM triggers RLL REL CONF (TS 48.058 3.4) */ |
| 5744 | private function f_TC_rll_rel_req(charstring id) runs on ConnHdlr { |
| 5745 | var RllTestCase tc := g_pars.spec.rll; |
| 5746 | f_l1_tune(L1CTL); |
| 5747 | RSL.clear; |
| 5748 | |
| 5749 | /* activate the logical channel */ |
| 5750 | f_est_dchan(); |
| 5751 | L1CTL.clear; |
| 5752 | |
| 5753 | /* first establish the link-layer */ |
| 5754 | f_est_rll_mo(tc.sapi, tc.link_id, tc.l3); |
| 5755 | |
| 5756 | /* then send the REL REQ via RSL */ |
| 5757 | RSL.send(ts_RSL_REL_REQ(g_chan_nr, tc.link_id, RSL_REL_MODE_NORMAL)); |
| 5758 | /* ... and expect the DISC on the Um side */ |
| 5759 | alt { |
Harald Welte | bc6199f | 2018-05-10 19:38:18 +0200 | [diff] [blame] | 5760 | [] 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] | 5761 | /* FIXME: send a UA in resposne to the DISC */ |
| 5762 | } |
| 5763 | } |
| 5764 | |
| 5765 | /* release the channel */ |
| 5766 | f_rsl_chan_deact(); |
| 5767 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 5768 | f_rslem_unregister(0, g_chan_nr); |
| 5769 | } |
| 5770 | testcase TC_rll_rel_req() runs on test_CT { |
| 5771 | var RllTestCases tcs := { |
| 5772 | valueof(t_EITC(0, valueof(ts_RslLinkID_DCCH(0)), '01020304'O, true)), |
| 5773 | valueof(t_EITC(0, valueof(ts_RslLinkID_SACCH(0)), ''O, true)), |
| 5774 | valueof(t_EITC(3, valueof(ts_RslLinkID_DCCH(3)), ''O, true)), |
| 5775 | valueof(t_EITC(3, valueof(ts_RslLinkID_SACCH(3)), ''O, true)) |
| 5776 | }; |
| 5777 | f_rll_testmatrix(tcs, refers(f_TC_rll_rel_req)); |
| 5778 | } |
| 5779 | |
| 5780 | /* test if RLL DATA REQ triggers I-frames on Um (TS 48.058 3.5) */ |
| 5781 | testcase TC_rll_data_req() runs on test_CT { |
| 5782 | } |
| 5783 | |
| 5784 | /* test if I-frames on Um trigger RLL DATA IND (TS 48.058 3.6) */ |
| 5785 | testcase TC_rll_data_ind() runs on test_CT { |
| 5786 | } |
| 5787 | |
| 5788 | /* test if RLL UNIT DATA REQ triggers UI-frame on Um (TS 48.058 3.7) */ |
| 5789 | private function f_TC_rll_ud_req(charstring id) runs on ConnHdlr { |
| 5790 | var RllTestCase tc := g_pars.spec.rll; |
| 5791 | |
| 5792 | f_l1_tune(L1CTL); |
| 5793 | RSL.clear; |
| 5794 | |
| 5795 | f_est_dchan(); |
| 5796 | L1CTL.clear; |
| 5797 | |
| 5798 | /* Send UNITDATA REQ on RSL side */ |
| 5799 | RSL.send(ts_RSL_UNITDATA_REQ(g_chan_nr, tc.link_id, tc.l3)); |
| 5800 | /* Expect it to arrive on the other side */ |
| 5801 | if (tc.link_id.c == SACCH) { |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 5802 | 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] | 5803 | } else { |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 5804 | 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] | 5805 | } |
| 5806 | |
| 5807 | /* release the channel */ |
| 5808 | f_rsl_chan_deact(); |
| 5809 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 5810 | f_rslem_unregister(0, g_chan_nr); |
| 5811 | } |
| 5812 | testcase TC_rll_unit_data_req_DCCH() runs on test_CT { |
| 5813 | var octetstring l3 := f_rnd_octstring(15); |
| 5814 | var RllTestCases tcs := { |
| 5815 | valueof(t_EITC(0, valueof(ts_RslLinkID_DCCH(0)), l3, true)), |
| 5816 | valueof(t_EITC(3, valueof(ts_RslLinkID_DCCH(3)), l3, true)) |
| 5817 | }; |
| 5818 | f_rll_testmatrix(tcs, refers(f_TC_rll_ud_req)); |
| 5819 | } |
| 5820 | testcase TC_rll_unit_data_req_ACCH() runs on test_CT { |
| 5821 | var octetstring l3 := f_rnd_octstring(19); |
| 5822 | var RllTestCases tcs := { |
| 5823 | valueof(t_EITC(0, valueof(ts_RslLinkID_SACCH(0)), l3, true)), |
| 5824 | valueof(t_EITC(3, valueof(ts_RslLinkID_SACCH(3)), l3, true)) |
| 5825 | }; |
| 5826 | f_rll_testmatrix(tcs, refers(f_TC_rll_ud_req)); |
| 5827 | } |
| 5828 | |
| 5829 | /* test if UI-frames on Um trigger RLL UNIT DATA IND (TS 48.058 3.8) */ |
| 5830 | private function f_TC_rll_ud_ind(charstring id) runs on ConnHdlr { |
| 5831 | var RllTestCase tc := g_pars.spec.rll; |
| 5832 | |
| 5833 | f_l1_tune(L1CTL); |
| 5834 | RSL.clear; |
| 5835 | |
| 5836 | f_est_dchan(); |
| 5837 | L1CTL.clear; |
| 5838 | |
| 5839 | /* Send LAPDm UI frame. There is no B4 format in uplink! */ |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 5840 | 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] | 5841 | /* Expdct RLL UNITDATA IND on RSL side */ |
| 5842 | alt { |
| 5843 | [] RSL.receive(tr_RSL_UNITDATA_IND(g_chan_nr, tc.link_id, tc.l3)) { |
| 5844 | setverdict(pass); |
| 5845 | } |
| 5846 | [] RSL.receive { repeat; } |
| 5847 | } |
| 5848 | |
| 5849 | /* release the channel */ |
| 5850 | f_rsl_chan_deact(); |
| 5851 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 5852 | f_rslem_unregister(0, g_chan_nr); |
| 5853 | } |
| 5854 | testcase TC_rll_unit_data_ind_DCCH() runs on test_CT { |
Stefan Sperling | c418191 | 2018-07-25 17:03:08 +0200 | [diff] [blame] | 5855 | var octetstring l3 := f_rnd_octstring(20); |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 5856 | var RllTestCases tcs := { |
| 5857 | valueof(t_EITC(0, valueof(ts_RslLinkID_DCCH(0)), l3, true)), |
| 5858 | valueof(t_EITC(3, valueof(ts_RslLinkID_DCCH(3)), l3, true)) |
| 5859 | }; |
| 5860 | f_rll_testmatrix(tcs, refers(f_TC_rll_ud_ind)); |
| 5861 | } |
| 5862 | testcase TC_rll_unit_data_ind_ACCH() runs on test_CT { |
| 5863 | var octetstring l3 := f_rnd_octstring(18); |
| 5864 | var RllTestCases tcs := { |
| 5865 | valueof(t_EITC(0, valueof(ts_RslLinkID_SACCH(0)), l3, true)), |
| 5866 | valueof(t_EITC(3, valueof(ts_RslLinkID_SACCH(3)), l3, true)) |
| 5867 | }; |
| 5868 | f_rll_testmatrix(tcs, refers(f_TC_rll_ud_ind)); |
| 5869 | } |
| 5870 | |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 5871 | /*********************************************************************** |
| 5872 | * Encryption Related |
| 5873 | ***********************************************************************/ |
| 5874 | |
| 5875 | /* send UNITDATA_REQ from BTS to MS and expect it to arrive */ |
| 5876 | function f_unitdata_mt(RslLinkId link_id, octetstring l3) runs on ConnHdlr { |
| 5877 | RSL.send(ts_RSL_UNITDATA_REQ(g_chan_nr, link_id, l3)); |
| 5878 | if (link_id.c == SACCH) { |
| 5879 | f_l1_exp_lapdm(tr_LAPDm_B4_UI(link_id.sapi, cr_MT_CMD, l3)); |
| 5880 | } else { |
| 5881 | f_l1_exp_lapdm(tr_LAPDm_UI(link_id.sapi, cr_MT_CMD, l3)); |
| 5882 | } |
| 5883 | } |
| 5884 | |
Vadim Yanitskiy | ad131c8 | 2018-10-04 06:18:59 +0700 | [diff] [blame] | 5885 | /* Expect (or not expect) other kinds of messages */ |
| 5886 | private altstep as_rsl_any_ind(boolean exp_any) runs on ConnHdlr { |
| 5887 | [exp_any] RSL.receive { repeat; } |
| 5888 | [not exp_any] RSL.receive { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 5889 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected RSL message!"); |
Vadim Yanitskiy | ad131c8 | 2018-10-04 06:18:59 +0700 | [diff] [blame] | 5890 | } |
| 5891 | } |
| 5892 | |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 5893 | /* 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] | 5894 | private function f_unitdata_mo( |
Vadim Yanitskiy | 98e0315 | 2018-10-03 18:06:06 +0700 | [diff] [blame] | 5895 | RslLinkId link_id, |
| 5896 | octetstring l3, |
| 5897 | boolean exp_sacch := true, /* Should tolerate SACCH messages? */ |
Vadim Yanitskiy | b992050 | 2018-10-03 18:29:51 +0700 | [diff] [blame] | 5898 | boolean exp_any := false /* Should tolerate any other RSL messages? */ |
Vadim Yanitskiy | 98e0315 | 2018-10-03 18:06:06 +0700 | [diff] [blame] | 5899 | ) runs on ConnHdlr { |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 5900 | timer T := 3.0; |
| 5901 | f_tx_lapdm(ts_LAPDm_UI(link_id.sapi, cr_MO_CMD, l3), link_id); |
| 5902 | T.start; |
| 5903 | /* Expect RLL UNITDATA IND on RSL side */ |
| 5904 | alt { |
| 5905 | [] RSL.receive(tr_RSL_UNITDATA_IND(g_chan_nr, link_id, l3)) { |
| 5906 | setverdict(pass); |
| 5907 | } |
Vadim Yanitskiy | e0b91a7 | 2018-10-04 15:44:40 +0700 | [diff] [blame] | 5908 | [exp_sacch] as_meas_res(verify_meas := false); |
Vadim Yanitskiy | ad131c8 | 2018-10-04 06:18:59 +0700 | [diff] [blame] | 5909 | [] as_rsl_any_ind(exp_any); |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 5910 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 5911 | 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] | 5912 | } |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 5913 | } |
| 5914 | } |
| 5915 | |
Vadim Yanitskiy | 4d78a70 | 2018-10-03 03:59:34 +0700 | [diff] [blame] | 5916 | /* Send I-frame from MS and expect it to arrive as RLL DATA IND on Abis */ |
| 5917 | private function f_data_mo( |
| 5918 | RslLinkId link_id, |
| 5919 | boolean p, uint3_t nr, uint3_t ns, |
| 5920 | octetstring l3, |
| 5921 | boolean exp_sacch := true, /* Should tolerate SACCH messages? */ |
Vadim Yanitskiy | b992050 | 2018-10-03 18:29:51 +0700 | [diff] [blame] | 5922 | boolean exp_any := false /* Should tolerate any other RSL messages? */ |
Vadim Yanitskiy | 4d78a70 | 2018-10-03 03:59:34 +0700 | [diff] [blame] | 5923 | ) runs on ConnHdlr { |
| 5924 | timer T := 3.0; |
| 5925 | f_tx_lapdm(ts_LAPDm_I(link_id.sapi, cr_MO_CMD, p, nr, ns, l3), link_id); |
| 5926 | T.start; |
| 5927 | /* Expect RLL DATA IND on RSL side */ |
| 5928 | alt { |
| 5929 | [] RSL.receive(tr_RSL_DATA_IND(g_chan_nr, link_id, l3)) { |
| 5930 | setverdict(pass); |
| 5931 | } |
Vadim Yanitskiy | e0b91a7 | 2018-10-04 15:44:40 +0700 | [diff] [blame] | 5932 | [exp_sacch] as_meas_res(verify_meas := false); |
Vadim Yanitskiy | 4d78a70 | 2018-10-03 03:59:34 +0700 | [diff] [blame] | 5933 | [] as_rsl_any_ind(exp_any); |
| 5934 | [] T.timeout { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 5935 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for DATA_IND"); |
Vadim Yanitskiy | 4d78a70 | 2018-10-03 03:59:34 +0700 | [diff] [blame] | 5936 | } |
| 5937 | } |
| 5938 | } |
| 5939 | |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 5940 | /* Test channel activation with A5/n right from the beginning (like in assignment + hand-over) */ |
| 5941 | function f_TC_chan_act_encr(charstring id) runs on ConnHdlr { |
| 5942 | f_l1_tune(L1CTL); |
| 5943 | f_est_dchan(true); |
| 5944 | |
| 5945 | /* now we actually need to transmit some data both ways to check if the encryption works */ |
| 5946 | var L1ctlDlMessage dl; |
| 5947 | |
Stefan Sperling | 603d98e | 2018-07-25 16:47:28 +0200 | [diff] [blame] | 5948 | var octetstring l3 := f_rnd_octstring(20); |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 5949 | var RslLinkId link_id := valueof(ts_RslLinkID_DCCH(0)); |
| 5950 | |
| 5951 | /* send UNITDATA_REQ from BTS to MS and expect it to arrive */ |
| 5952 | f_unitdata_mt(link_id, l3); |
| 5953 | |
| 5954 | /* Send UI frame from MS and expect it to arrive as RLL UNITDATA IND on Abis */ |
| 5955 | f_unitdata_mo(link_id, l3); |
| 5956 | |
| 5957 | /* release the channel */ |
| 5958 | f_rsl_chan_deact(); |
| 5959 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 5960 | f_rslem_unregister(0, g_chan_nr); |
| 5961 | } |
| 5962 | testcase TC_chan_act_a51() runs on test_CT { |
| 5963 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 5964 | pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_1, f_rnd_octstring(8))); |
| 5965 | f_testmatrix_each_chan(pars, refers(f_TC_chan_act_encr)); |
| 5966 | } |
| 5967 | testcase TC_chan_act_a52() runs on test_CT { |
| 5968 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 5969 | pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_2, f_rnd_octstring(8))); |
| 5970 | f_testmatrix_each_chan(pars, refers(f_TC_chan_act_encr)); |
| 5971 | } |
| 5972 | testcase TC_chan_act_a53() runs on test_CT { |
| 5973 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 5974 | pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_3, f_rnd_octstring(8))); |
| 5975 | f_testmatrix_each_chan(pars, refers(f_TC_chan_act_encr)); |
| 5976 | } |
| 5977 | |
Eric Wild | f1827a7 | 2019-05-28 17:37:35 +0200 | [diff] [blame] | 5978 | /* Test channel activation with A5/n right from the beginning and RSL MODE MODIFY |
| 5979 | which should break the en/decryption on purpose by supplying a new key that is unknown to the MS*/ |
| 5980 | function f_TC_rsl_modify_encr(charstring id) runs on ConnHdlr { |
| 5981 | f_l1_tune(L1CTL); |
| 5982 | f_est_dchan(true); |
| 5983 | |
| 5984 | /* now we actually need to transmit some data both ways to check if the encryption works */ |
| 5985 | var L1ctlDlMessage dl; |
| 5986 | |
| 5987 | var octetstring l3 := f_rnd_octstring(20); |
| 5988 | var RslLinkId link_id := valueof(ts_RslLinkID_DCCH(0)); |
| 5989 | |
| 5990 | /* send UNITDATA_REQ from BTS to MS and expect it to arrive */ |
| 5991 | f_unitdata_mt(link_id, l3); |
| 5992 | |
| 5993 | /* Send UI frame from MS and expect it to arrive as RLL UNITDATA IND on Abis */ |
| 5994 | f_unitdata_mo(link_id, l3); |
| 5995 | |
| 5996 | var RSL_Message rsl; |
| 5997 | rsl := valueof(ts_RSL_MODE_MODIFY_REQ(g_chan_nr, valueof(ts_RSL_ChanMode_SIGN(false)))); |
| 5998 | |
| 5999 | /* modify key to break proper encryption */ |
| 6000 | g_pars.encr.key := f_rnd_octstring(8); |
| 6001 | var RSL_IE ei := valueof(t_RSL_IE(RSL_IE_ENCR_INFO, RSL_IE_Body:{encr_info := g_pars.encr})); |
| 6002 | rsl.ies := rsl.ies & { ei }; |
| 6003 | RSL.send(rsl); |
| 6004 | |
| 6005 | timer T0 := 1.0; |
| 6006 | T0.start; |
| 6007 | /* Expect RSL MODIFY ACK */ |
| 6008 | alt { |
| 6009 | [] RSL.receive(tr_RSL_MODE_MODIFY_ACK(g_chan_nr)) {} |
| 6010 | [] RSL.receive(tr_RSL_MODE_MODIFY_NACK(g_chan_nr, ?)) { |
| 6011 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,"MODE MODIFY NACK"); |
| 6012 | } |
| 6013 | [] T0.timeout { |
| 6014 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for MODE MODIFY (N)ACK"); |
| 6015 | } |
| 6016 | } |
| 6017 | |
| 6018 | var octetstring l3msg := f_rnd_octstring(15); |
| 6019 | timer T1 := 3.0; |
| 6020 | /* Send UI frame from MS, do not expect it to arrive as RLL UNITDATA IND on Abis |
| 6021 | due to broken encryption */ |
| 6022 | f_tx_lapdm(ts_LAPDm_UI(link_id.sapi, cr_MO_CMD, l3msg), link_id); |
| 6023 | T1.start; |
| 6024 | alt { |
| 6025 | [] RSL.receive(tr_RSL_UNITDATA_IND(g_chan_nr, link_id, l3msg)) { |
| 6026 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "BTS shouldn't be able to decrypt after key change") |
| 6027 | } |
| 6028 | [] T1.timeout { |
| 6029 | setverdict(pass); |
| 6030 | } |
| 6031 | } |
| 6032 | |
| 6033 | /* release the channel */ |
| 6034 | f_rsl_chan_deact(); |
| 6035 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 6036 | f_rslem_unregister(0, g_chan_nr); |
| 6037 | } |
| 6038 | testcase TC_rsl_modify_encr() runs on test_CT { |
| 6039 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 6040 | pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_1, f_rnd_octstring(8))); |
| 6041 | f_testmatrix_each_chan(pars, refers(f_TC_rsl_modify_encr)); |
| 6042 | } |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 6043 | |
| 6044 | /* Test unencrypted channel activation followed by explicit ENCR CMD later */ |
| 6045 | function f_TC_encr_cmd(charstring id) runs on ConnHdlr { |
| 6046 | /* L3 payload doesn't matter, as it is passed transparently */ |
| 6047 | var BIT3 l3_alg_id := f_alg_id_to_l3(g_pars.encr.alg_id); |
| 6048 | var octetstring l3 := enc_PDU_ML3_NW_MS(valueof(ts_RRM_CiphModeCmd(l3_alg_id))); |
| 6049 | var RslLinkId link_id := valueof(ts_RslLinkID_DCCH(0)); |
| 6050 | |
| 6051 | f_l1_tune(L1CTL); |
| 6052 | |
| 6053 | /* first establish a dedicated channel in the clear */ |
| 6054 | f_est_dchan(false); |
| 6055 | |
| 6056 | /* Establish ABM */ |
| 6057 | f_est_rll_mo(link_id.sapi, link_id, '23420815'O); |
| 6058 | |
| 6059 | /* then send the RSL ENCR CMD with an actual RR CIPH MOD CMD inside */ |
| 6060 | RSL.send(ts_RSL_ENCR_CMD(g_chan_nr, link_id, g_pars.encr.alg_id, g_pars.encr.key, l3)); |
| 6061 | /* expect the L3 to arrive still unencrypted on the MS side */ |
| 6062 | f_l1_exp_lapdm(tr_LAPDm_I(link_id.sapi, cr_MT_CMD, ?, ?, ?, l3)); |
| 6063 | |
| 6064 | /* configure L1 to apply ciphering */ |
| 6065 | var uint8_t alg_id := f_alg_id_to_l1ctl(g_pars.encr.alg_id); |
| 6066 | f_L1CTL_CRYPTO_REQ(L1CTL, g_pars.chan_nr, alg_id, g_pars.encr.key); |
| 6067 | |
Vadim Yanitskiy | 4d78a70 | 2018-10-03 03:59:34 +0700 | [diff] [blame] | 6068 | /* send first ciphered I-frame in response and expect it on RSL */ |
| 6069 | 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] | 6070 | |
| 6071 | /* now the BTS code should have detected the first properly encrypted uplink I-frame, |
| 6072 | * and hence enable encryption also on the downlink */ |
| 6073 | |
| 6074 | /* expect bi-directional communication work in encrypted mode */ |
| 6075 | f_unitdata_mo(link_id, f_rnd_octstring(15)); |
| 6076 | f_unitdata_mt(link_id, f_rnd_octstring(15)); |
| 6077 | |
| 6078 | /* release the channel */ |
| 6079 | f_rsl_chan_deact(); |
| 6080 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
| 6081 | f_rslem_unregister(0, g_chan_nr); |
| 6082 | } |
| 6083 | testcase TC_encr_cmd_a51() runs on test_CT { |
| 6084 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 6085 | pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_1, f_rnd_octstring(8))); |
| 6086 | f_testmatrix_each_chan(pars, refers(f_TC_encr_cmd)); |
| 6087 | } |
| 6088 | testcase TC_encr_cmd_a52() runs on test_CT { |
| 6089 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 6090 | pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_2, f_rnd_octstring(8))); |
| 6091 | f_testmatrix_each_chan(pars, refers(f_TC_encr_cmd)); |
| 6092 | } |
| 6093 | testcase TC_encr_cmd_a53() runs on test_CT { |
| 6094 | var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN)); |
| 6095 | pars.encr := valueof(ts_RSL_IE_EncrInfo(RSL_ALG_ID_A5_3, f_rnd_octstring(8))); |
| 6096 | f_testmatrix_each_chan(pars, refers(f_TC_encr_cmd)); |
| 6097 | } |
| 6098 | |
| 6099 | private function f_assert_lapdm(octetstring enc, template LapdmFrame exp_match, charstring name := "") { |
| 6100 | var LapdmFrame lf; |
| 6101 | var octetstring reenc; |
| 6102 | |
| 6103 | /* decode the LAPDm frame */ |
| 6104 | if (ischosen(exp_match.ab)) { |
| 6105 | lf.ab := dec_LapdmFrameAB(enc); |
| 6106 | } else { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 6107 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "unsupported frame type"); |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 6108 | } |
| 6109 | |
| 6110 | /* check if decoder result matches expectation */ |
| 6111 | if (not match(lf, exp_match)) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 6112 | 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] | 6113 | } else { |
| 6114 | log(name, ": matched"); |
| 6115 | setverdict(pass); |
| 6116 | } |
| 6117 | |
| 6118 | /* test if re-encoded frame equals original input */ |
| 6119 | reenc := enc_LapdmFrame(lf); |
| 6120 | if (enc != reenc) { |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 6121 | 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] | 6122 | } else { |
| 6123 | setverdict(pass); |
| 6124 | } |
| 6125 | } |
| 6126 | |
| 6127 | testcase TC_lapdm_selftest() runs on test_CT { |
| 6128 | f_assert_lapdm('030301'O, tr_LAPDm_UI(0, true, ''O), "ui_s0_empty"); |
| 6129 | f_assert_lapdm('0F0301'O, tr_LAPDm_UI(3, true, ''O), "ui_s3_empty"); |
| 6130 | f_assert_lapdm('013F01'O, tr_LAPDm_SABM(0, false, true, ''O), "sabm_s0_empty"); |
| 6131 | f_assert_lapdm('013F1123420815'O, tr_LAPDm_SABM(0, false, true, '23420815'O), "sabm_s0_l3"); |
| 6132 | f_assert_lapdm('03E101'O, tr_LAPDm_RR(0, true, false, 7), "rr_s0_7"); |
| 6133 | f_assert_lapdm('03000d063505'O, tr_LAPDm_I(0, true, false, 0, 0, '063505'O), "I/0/0"); |
| 6134 | f_assert_lapdm('03e00d063505'O, tr_LAPDm_I(0, true, false, 7, 0, '063505'O), "I/7/0"); |
| 6135 | } |
| 6136 | |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 6137 | /*********************************************************************** |
| 6138 | * DTX Related (see GSM 05.08, section 8.3) |
| 6139 | ***********************************************************************/ |
| 6140 | |
| 6141 | /* XXX These functions must be kept in sync with g_AllChannels defined on test_CT. */ |
| 6142 | function f_g_chan_is_tchf() runs on ConnHdlr return boolean { |
| 6143 | return (g_chan_nr == valueof(ts_RslChanNr_Bm(1)) or |
| 6144 | g_chan_nr == valueof(ts_RslChanNr_Bm(2)) or |
| 6145 | g_chan_nr == valueof(ts_RslChanNr_Bm(3)) or |
| 6146 | g_chan_nr == valueof(ts_RslChanNr_Bm(4))); |
| 6147 | } |
| 6148 | function f_g_chan_is_tchh() runs on ConnHdlr return boolean { |
| 6149 | return (g_chan_nr == valueof(ts_RslChanNr_Lm(5,0)) or |
| 6150 | g_chan_nr == valueof(ts_RslChanNr_Lm(5,1))); |
| 6151 | } |
| 6152 | function f_g_chan_is_sdcch4() runs on ConnHdlr return boolean { |
| 6153 | return (g_chan_nr == valueof(ts_RslChanNr_SDCCH4(0,0)) or |
| 6154 | g_chan_nr == valueof(ts_RslChanNr_SDCCH4(0,1)) or |
| 6155 | g_chan_nr == valueof(ts_RslChanNr_SDCCH4(0,2)) or |
| 6156 | g_chan_nr == valueof(ts_RslChanNr_SDCCH4(0,3))); |
| 6157 | } |
| 6158 | function f_g_chan_is_sdcch8() runs on ConnHdlr return boolean { |
| 6159 | return (g_chan_nr == valueof(ts_RslChanNr_SDCCH8(6,0)) or |
| 6160 | g_chan_nr == valueof(ts_RslChanNr_SDCCH8(6,1)) or |
| 6161 | g_chan_nr == valueof(ts_RslChanNr_SDCCH8(6,2)) or |
| 6162 | g_chan_nr == valueof(ts_RslChanNr_SDCCH8(6,3)) or |
| 6163 | g_chan_nr == valueof(ts_RslChanNr_SDCCH8(6,4)) or |
| 6164 | g_chan_nr == valueof(ts_RslChanNr_SDCCH8(6,5)) or |
| 6165 | g_chan_nr == valueof(ts_RslChanNr_SDCCH8(6,6)) or |
| 6166 | g_chan_nr == valueof(ts_RslChanNr_SDCCH8(6,7))); |
| 6167 | } |
| 6168 | |
| 6169 | function f_test_l2_fill_frames(boolean dtxd) runs on ConnHdlr { |
| 6170 | var L1ctlDlMessage dl; |
| 6171 | var octetstring l2_fill_frame := '0303012B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B'O; |
| 6172 | var octetstring l2_fill_frame_sacch := substr(l2_fill_frame, 0, lengthof(l2_fill_frame) - 2); |
| 6173 | var GsmFrameNumber first_fn; |
| 6174 | var boolean is_first_frame := true; |
Stefan Sperling | 91d4c9d | 2018-08-09 20:03:08 +0200 | [diff] [blame] | 6175 | var integer nfill_frames_sacch := 0; |
| 6176 | var integer nfill_frames_nonsacch := 0; |
| 6177 | 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] | 6178 | /* Frames numbers (mod 104) for which a fill frame is expected on TCHF if DTX is enabled. */ |
| 6179 | 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] | 6180 | const integer frame_dtx_tchf_mod := 104; |
| 6181 | /* Frame numbers (mod 104) for which a fill frame is expected at the L1SAP level, |
| 6182 | * which operates in terms of blocks rather than frames. */ |
| 6183 | var Integers required_tdma_blocks_dtx_tchf := { 52, 56 }; |
| 6184 | const integer block_dtx_tchf_mod := 26; |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 6185 | timer T := 5.0; |
| 6186 | |
| 6187 | f_l1_tune(L1CTL); |
| 6188 | RSL.clear; |
| 6189 | L1CTL.clear; |
| 6190 | |
| 6191 | /* activate TCHF signalling channel */ |
| 6192 | f_est_dchan(false); |
| 6193 | |
| 6194 | T.start; |
| 6195 | alt { |
| 6196 | [] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, ?)) -> value dl { |
| 6197 | var GsmFrameNumber fn := dl.dl_info.frame_nr; |
| 6198 | var octetstring l2 := dl.payload.data_ind.payload; |
| 6199 | |
| 6200 | if (is_first_frame) { |
| 6201 | is_first_frame := false; |
| 6202 | first_fn := dl.dl_info.frame_nr; |
| 6203 | } |
| 6204 | |
| 6205 | if (dl.dl_info.link_id.c == SACCH) { |
| 6206 | l2 := substr(l2, 2, lengthof(l2) - 2); /* remove L1 header */ |
| 6207 | if (not match(l2_fill_frame_sacch, l2)) { |
| 6208 | repeat; |
| 6209 | } |
| 6210 | } else if (not match(l2_fill_frame, l2)) { |
| 6211 | repeat; |
| 6212 | } |
| 6213 | |
| 6214 | if (dtxd) { |
| 6215 | if (not f_g_chan_is_tchf()) { |
| 6216 | T.stop; |
| 6217 | f_rsl_chan_deact(); |
| 6218 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 6219 | 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] | 6220 | } |
Stefan Sperling | 91d4c9d | 2018-08-09 20:03:08 +0200 | [diff] [blame] | 6221 | if (fn > first_fn + frame_dtx_tchf_mod) { |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 6222 | T.stop; |
| 6223 | f_rsl_chan_deact(); |
| 6224 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
Stefan Sperling | 91d4c9d | 2018-08-09 20:03:08 +0200 | [diff] [blame] | 6225 | |
| 6226 | /* With DTX enabled we can expect at least 3 fill frames for every 104 frames. |
| 6227 | * 2 SACCH, 1 TCH/F */ |
| 6228 | expected_fill_frames := 3; |
| 6229 | |
| 6230 | if (nfill_frames_sacch + nfill_frames_nonsacch < expected_fill_frames) { |
| 6231 | log("received only ", nfill_frames_sacch, "+", nfill_frames_nonsacch, |
| 6232 | " (SACCH+other) out of ", expected_fill_frames, " expected fill frames"); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 6233 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Not enough fill frames received"); |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 6234 | } else { |
| 6235 | setverdict(pass); |
| 6236 | } |
Stefan Sperling | 91d4c9d | 2018-08-09 20:03:08 +0200 | [diff] [blame] | 6237 | } else { |
| 6238 | if (dl.dl_info.link_id.c == SACCH) { |
| 6239 | nfill_frames_sacch := nfill_frames_sacch + 1; |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 6240 | repeat; |
| 6241 | } |
Stefan Sperling | 91d4c9d | 2018-08-09 20:03:08 +0200 | [diff] [blame] | 6242 | /* On DTX TCH/F channels, fill frames occur only for specific frame numbers mod 104. |
| 6243 | * Furthermore, the L1SAP layer gives us frame numbers for the start of a block so |
| 6244 | * we should only see the subset of frames numbers which correspond to a block boundary. |
| 6245 | * TCH/F blocks are defined to start at 0,4,8,13,17,21 (modulo 26) */ |
| 6246 | for (var integer i := 0; i < lengthof(required_tdma_blocks_dtx_tchf); i := i + 1) { |
| 6247 | if (fn mod frame_dtx_tchf_mod == required_tdma_blocks_dtx_tchf[i]) { |
| 6248 | nfill_frames_nonsacch := nfill_frames_nonsacch + 1; |
| 6249 | repeat; |
| 6250 | } |
| 6251 | } |
| 6252 | log("Received DTX TCH fill frame with bad frame number: ", fn, |
| 6253 | " (mod ", frame_dtx_tchf_mod, ": ", fn mod frame_dtx_tchf_mod, ")", |
| 6254 | " (mod ", block_dtx_tchf_mod, ": ", fn mod block_dtx_tchf_mod, ")"); |
| 6255 | f_rsl_chan_deact(); |
| 6256 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 6257 | 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] | 6258 | } |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 6259 | } else { |
Stefan Sperling | 91d4c9d | 2018-08-09 20:03:08 +0200 | [diff] [blame] | 6260 | if (dl.dl_info.link_id.c == SACCH) { |
| 6261 | nfill_frames_sacch := nfill_frames_sacch + 1; |
| 6262 | } else { |
| 6263 | nfill_frames_nonsacch := nfill_frames_nonsacch + 1; |
| 6264 | } |
| 6265 | if (fn > first_fn + frame_dtx_tchf_mod) { |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 6266 | T.stop; |
| 6267 | if (f_g_chan_is_tchf()) { |
| 6268 | /* Without DTX we can expect 25 fill frames for every 104 frames. |
| 6269 | * (24 FACCH + 1 SACCH filling) */ |
| 6270 | expected_fill_frames := 25; |
| 6271 | } else if (f_g_chan_is_tchh()) { |
| 6272 | /* We can expect 2 fill frames for every 104 frames. */ |
| 6273 | expected_fill_frames := 2; |
| 6274 | } else if (f_g_chan_is_sdcch4() or f_g_chan_is_sdcch8()) { |
| 6275 | /* We can expect 5 fill frames for every 104 frames. */ |
| 6276 | expected_fill_frames := 5; |
| 6277 | } else { |
| 6278 | f_rsl_chan_deact(); |
| 6279 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 6280 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unknown channel type"); |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 6281 | } |
| 6282 | |
| 6283 | f_rsl_chan_deact(); |
| 6284 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
Stefan Sperling | 91d4c9d | 2018-08-09 20:03:08 +0200 | [diff] [blame] | 6285 | |
| 6286 | if (nfill_frames_sacch + nfill_frames_nonsacch >= expected_fill_frames) { |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 6287 | setverdict(pass); |
| 6288 | } else { |
Stefan Sperling | 91d4c9d | 2018-08-09 20:03:08 +0200 | [diff] [blame] | 6289 | log("received only ", nfill_frames_sacch, "+", nfill_frames_nonsacch, |
| 6290 | " (SACCH+other) out of ", expected_fill_frames, " expected fill frames"); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 6291 | Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Not enough fill frames received"); |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 6292 | } |
| 6293 | } else { |
| 6294 | repeat; |
| 6295 | } |
| 6296 | } |
| 6297 | } |
| 6298 | [] L1CTL.receive { repeat; } |
| 6299 | [] T.timeout { |
| 6300 | f_rsl_chan_deact(); |
| 6301 | f_L1CTL_DM_REL_REQ(L1CTL, g_chan_nr); |
Daniel Willmann | 0fcc4d3 | 2018-10-23 20:32:19 +0200 | [diff] [blame] | 6302 | 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] | 6303 | } |
| 6304 | } |
| 6305 | } |
| 6306 | |
| 6307 | function f_TC_tch_sign_l2_fill_frame(charstring id) runs on ConnHdlr { |
| 6308 | f_test_l2_fill_frames(false); |
| 6309 | } |
| 6310 | |
| 6311 | function f_TC_tch_sign_l2_fill_frame_dtxd(charstring id) runs on ConnHdlr { |
| 6312 | f_test_l2_fill_frames(true); |
| 6313 | } |
| 6314 | |
| 6315 | function f_tch_sign_l2_fill_frame(boolean dtxd) runs on test_CT { |
| 6316 | var ConnHdlr vc_conn; |
| 6317 | var ConnHdlrPars pars; |
| 6318 | pars.t_guard := 60.0; |
Harald Welte | 1047406 | 2019-05-30 16:48:17 +0200 | [diff] [blame] | 6319 | f_init(); |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 6320 | for (var integer i := 0; i < sizeof(g_AllChannels); i := i + 1) { |
| 6321 | pars := valueof(t_Pars(g_AllChannels[i], ts_RSL_ChanMode_SIGN(dtxd))); |
| 6322 | if (dtxd) { |
| 6323 | if (i >= 4) { /* DTX is only allowed on TCH/F */ |
| 6324 | break; |
| 6325 | } |
| 6326 | vc_conn := f_start_handler(refers(f_TC_tch_sign_l2_fill_frame_dtxd), pars); |
| 6327 | } else { |
| 6328 | vc_conn := f_start_handler(refers(f_TC_tch_sign_l2_fill_frame), pars); |
| 6329 | } |
| 6330 | vc_conn.done; |
| 6331 | } |
| 6332 | } |
| 6333 | |
| 6334 | /* Verify that L2 fill frames are sent on TCH in signaling mode if |
| 6335 | * there is nothing to transmit while DTX is disabled on downlink. */ |
| 6336 | testcase TC_tch_sign_l2_fill_frame() runs on test_CT { |
| 6337 | f_tch_sign_l2_fill_frame(false); |
| 6338 | } |
| 6339 | |
| 6340 | /* Verify that particular L2 fill frames are sent on TCH in signaling mode if |
| 6341 | * there is nothing to transmit while DTX is enabled on downlink. */ |
| 6342 | testcase TC_tch_sign_l2_fill_frame_dtxd() runs on test_CT { |
| 6343 | f_tch_sign_l2_fill_frame(true); |
| 6344 | } |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 6345 | |
Stefan Sperling | 0ec1c26 | 2018-10-15 15:12:52 +0200 | [diff] [blame] | 6346 | testcase TC_chopped_ipa_ping() runs on test_CT { |
| 6347 | IPA_Testing.f_run_TC_chopped_ipa_ping(mp_rsl_ip, mp_rsl_port, LISTEN_FOR_CLIENT); |
| 6348 | } |
| 6349 | |
Stefan Sperling | aa1e60f | 2018-10-15 16:34:07 +0200 | [diff] [blame] | 6350 | testcase TC_chopped_ipa_payload() runs on test_CT { |
| 6351 | IPA_Testing.f_run_TC_chopped_ipa_payload(mp_rsl_ip, mp_rsl_port, LISTEN_FOR_CLIENT); |
| 6352 | } |
| 6353 | |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 6354 | /* test generation of RLL ERR IND based on Um errors (TS 48.058 3.9) */ |
| 6355 | /* protocol error as per 44.006 */ |
| 6356 | /* link layer failure (repetition of I-frame N200 times without ACK */ |
| 6357 | /* repetition of SABM or DISC N200 times without ACK */ |
| 6358 | /* receptiom of SABM in multi-frame established state */ |
| 6359 | |
| 6360 | |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 6361 | /* TODO Areas: |
| 6362 | |
| 6363 | * channel activation |
| 6364 | ** with BS_Power / MS_Power, bypassing power control loop |
| 6365 | ** on primary vs. secondary TRX |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 6366 | ** with timing advance from initial activation on |
| 6367 | * mode modify |
| 6368 | ** encryption |
| 6369 | ** multirate |
| 6370 | * check DEACTIVATE SACCH |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 6371 | ** unsupported algorithm |
| 6372 | * handover detection |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 6373 | * BS Power Control |
| 6374 | * Physical Context |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 6375 | * RF resource ind |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 6376 | * error handling |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 6377 | ** IE duplicated? |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 6378 | * PCU interface |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 6379 | ** DATA_IND from BTS->PCU |
| 6380 | ** verification of PCU-originated DATA_REQ arrival on Um/MS side |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 6381 | |
| 6382 | */ |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 6383 | |
| 6384 | control { |
| 6385 | execute( TC_chan_act_stress() ); |
| 6386 | execute( TC_chan_act_react() ); |
| 6387 | execute( TC_chan_deact_not_active() ); |
| 6388 | execute( TC_chan_act_wrong_nr() ); |
Harald Welte | 629cc6b | 2018-03-11 17:19:05 +0100 | [diff] [blame] | 6389 | execute( TC_deact_sacch() ); |
Harald Welte | ea17b91 | 2018-03-11 22:29:31 +0100 | [diff] [blame] | 6390 | execute( TC_sacch_filling() ); |
| 6391 | execute( TC_sacch_info_mod() ); |
Harald Welte | 075d84c | 2018-03-12 13:07:24 +0100 | [diff] [blame] | 6392 | execute( TC_sacch_multi() ); |
Harald Welte | 5570066 | 2018-03-12 13:15:43 +0100 | [diff] [blame] | 6393 | execute( TC_sacch_multi_chg() ); |
Harald Welte | c8d363c | 2019-05-19 20:36:48 +0200 | [diff] [blame] | 6394 | execute( TC_sacch_chan_act() ); |
Harald Welte | 8b01c79 | 2019-05-19 22:51:25 +0200 | [diff] [blame] | 6395 | execute( TC_sacch_chan_act_ho_async() ); |
| 6396 | execute( TC_sacch_chan_act_ho_sync() ); |
Harald Welte | 8c24c2b | 2018-02-26 08:31:31 +0100 | [diff] [blame] | 6397 | execute( TC_rach_content() ); |
| 6398 | execute( TC_rach_count() ); |
Harald Welte | 54a2a2d | 2018-02-26 09:14:05 +0100 | [diff] [blame] | 6399 | execute( TC_rach_max_ta() ); |
Vadim Yanitskiy | 7c2c10c | 2019-05-31 20:42:01 +0700 | [diff] [blame] | 6400 | execute( TC_ho_rach() ); |
Harald Welte | 3453ab4 | 2019-05-24 21:19:58 +0200 | [diff] [blame] | 6401 | execute( TC_rach_load_idle_thresh0() ); |
| 6402 | execute( TC_rach_load_idle_below_thresh() ); |
| 6403 | execute( TC_rach_load_count() ); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 6404 | execute( TC_meas_res_sign_tchf() ); |
| 6405 | execute( TC_meas_res_sign_tchh() ); |
| 6406 | execute( TC_meas_res_sign_sdcch4() ); |
| 6407 | execute( TC_meas_res_sign_sdcch8() ); |
Harald Welte | 685d598 | 2018-02-27 20:42:05 +0100 | [diff] [blame] | 6408 | execute( TC_meas_res_sign_tchh_toa256() ); |
Eric Wild | ae8f262 | 2019-06-18 17:05:11 +0200 | [diff] [blame] | 6409 | execute( TC_rsl_bs_pwr_static_ass() ); |
| 6410 | execute( TC_rsl_bs_pwr_static_power_control() ); |
Philipp Maier | 4d1e9c9 | 2018-12-20 11:11:56 +0100 | [diff] [blame] | 6411 | execute( TC_rsl_ms_pwr_ctrl() ); |
Eric Wild | 280ccb8 | 2019-06-17 11:11:52 +0200 | [diff] [blame] | 6412 | execute( TC_rsl_ms_pwr_dyn_active() ); |
Eric Wild | 095024b | 2019-06-17 15:08:57 +0200 | [diff] [blame] | 6413 | execute( TC_rsl_ms_pwr_dyn_active2() ); |
Eric Wild | 61edb7e | 2019-06-03 12:38:31 +0200 | [diff] [blame] | 6414 | execute( TC_rsl_ms_pwr_dyn_up() ); |
| 6415 | execute( TC_rsl_ms_pwr_dyn_down() ); |
| 6416 | execute( TC_rsl_ms_pwr_dyn_ass_updown() ); |
| 6417 | execute( TC_rsl_ms_pwr_dyn_max() ); |
Eric Wild | e57e1a6 | 2019-05-28 13:30:55 +0200 | [diff] [blame] | 6418 | execute( TC_rsl_chan_initial_ms_pwr() ); |
Eric Wild | 6833cc9 | 2019-05-23 19:34:44 +0200 | [diff] [blame] | 6419 | execute( TC_rsl_chan_initial_ta() ); |
Eric Wild | f1827a7 | 2019-05-28 17:37:35 +0200 | [diff] [blame] | 6420 | execute( TC_rsl_modify_encr() ); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 6421 | execute( TC_conn_fail_crit() ); |
Harald Welte | 68e495b | 2018-02-25 00:05:57 +0100 | [diff] [blame] | 6422 | execute( TC_paging_imsi_80percent() ); |
| 6423 | execute( TC_paging_tmsi_80percent() ); |
| 6424 | execute( TC_paging_imsi_200percent() ); |
| 6425 | execute( TC_paging_tmsi_200percent() ); |
Harald Welte | 01d982c | 2018-02-25 01:31:40 +0100 | [diff] [blame] | 6426 | execute( TC_rsl_protocol_error() ); |
| 6427 | execute( TC_rsl_mand_ie_error() ); |
| 6428 | execute( TC_rsl_ie_content_error() ); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 6429 | execute( TC_si_sched_default() ); |
Harald Welte | 0cae455 | 2018-03-09 22:20:26 +0100 | [diff] [blame] | 6430 | execute( TC_si_sched_1() ); |
Harald Welte | 48494ca | 2018-02-25 16:59:50 +0100 | [diff] [blame] | 6431 | execute( TC_si_sched_2bis() ); |
| 6432 | execute( TC_si_sched_2ter() ); |
| 6433 | execute( TC_si_sched_2ter_2bis() ); |
| 6434 | execute( TC_si_sched_2quater() ); |
| 6435 | execute( TC_si_sched_13() ); |
| 6436 | execute( TC_si_sched_13_2bis_2ter_2quater() ); |
Harald Welte | a871a38 | 2018-02-25 02:03:14 +0100 | [diff] [blame] | 6437 | execute( TC_ipa_dlcx_not_active() ); |
Harald Welte | a3f1df9 | 2018-02-25 12:49:55 +0100 | [diff] [blame] | 6438 | execute( TC_ipa_crcx_twice_not_active() ); |
| 6439 | execute( TC_ipa_crcx_mdcx_dlcx_not_active() ); |
Harald Welte | 3ae11da | 2018-02-25 13:36:06 +0100 | [diff] [blame] | 6440 | execute( TC_ipa_crcx_mdcx_mdcx_dlcx_not_active() ); |
Harald Welte | 9912eb5 | 2018-02-25 13:30:15 +0100 | [diff] [blame] | 6441 | execute( TC_ipa_crcx_sdcch_not_active() ); |
Harald Welte | 883340c | 2018-02-28 18:59:29 +0100 | [diff] [blame] | 6442 | |
Pau Espin Pedrol | a14a8af | 2018-11-20 13:12:22 +0100 | [diff] [blame] | 6443 | if (mp_pcu_socket != "") { |
| 6444 | execute( TC_pcu_act_req() ); |
| 6445 | execute( TC_pcu_act_req_wrong_ts() ); |
| 6446 | execute( TC_pcu_act_req_wrong_bts() ); |
| 6447 | execute( TC_pcu_act_req_wrong_trx() ); |
| 6448 | execute( TC_pcu_deact_req() ); |
| 6449 | execute( TC_pcu_deact_req_wrong_ts() ); |
| 6450 | execute( TC_pcu_ver_si13() ); |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 6451 | if (mp_l1_supports_gprs) { |
| 6452 | execute( TC_pcu_data_req_pdtch() ); |
| 6453 | execute( TC_pcu_data_req_ptcch() ); |
Harald Welte | 7162a61 | 2019-05-26 12:56:09 +0200 | [diff] [blame] | 6454 | execute( TC_pcu_data_req_wrong_bts() ); |
| 6455 | execute( TC_pcu_data_req_wrong_trx() ); |
| 6456 | execute( TC_pcu_data_req_wrong_ts() ); |
| 6457 | execute( TC_pcu_data_req_ts_inactive() ); |
Harald Welte | ad033dc | 2019-05-25 17:28:16 +0200 | [diff] [blame] | 6458 | } |
Vadim Yanitskiy | 970b153 | 2019-10-24 15:22:19 +0700 | [diff] [blame] | 6459 | execute( TC_pcu_ptcch() ); |
Pau Espin Pedrol | a14a8af | 2018-11-20 13:12:22 +0100 | [diff] [blame] | 6460 | execute( TC_pcu_data_req_agch() ); |
Harald Welte | 928622b | 2019-05-26 13:22:59 +0200 | [diff] [blame] | 6461 | execute( TC_pcu_data_req_pch() ); |
Pau Espin Pedrol | a14a8af | 2018-11-20 13:12:22 +0100 | [diff] [blame] | 6462 | execute( TC_pcu_data_req_imm_ass_pch() ); |
| 6463 | execute( TC_pcu_rach_content() ); |
Vadim Yanitskiy | 51cbc10 | 2019-04-22 06:37:30 +0700 | [diff] [blame] | 6464 | execute( TC_pcu_ext_rach_content() ); |
Vadim Yanitskiy | a2c68e8 | 2019-07-03 13:07:20 +0700 | [diff] [blame] | 6465 | execute( TC_pcu_data_ind_lqual_cb() ); |
Pau Espin Pedrol | a14a8af | 2018-11-20 13:12:22 +0100 | [diff] [blame] | 6466 | execute( TC_pcu_paging_from_rsl() ); |
Harald Welte | d66c9b8 | 2019-05-25 09:03:15 +0200 | [diff] [blame] | 6467 | execute( TC_pcu_time_ind() ); |
Harald Welte | 4832c86 | 2019-05-25 14:57:18 +0200 | [diff] [blame] | 6468 | execute( TC_pcu_rts_req() ); |
Harald Welte | 07bd2d2 | 2019-05-25 11:03:30 +0200 | [diff] [blame] | 6469 | execute( TC_pcu_oml_alert() ); |
Harald Welte | eaa9a86 | 2019-05-26 23:01:08 +0200 | [diff] [blame] | 6470 | execute( TC_pcu_rr_suspend() ); |
Harald Welte | a2e0e94 | 2019-05-27 18:12:53 +0200 | [diff] [blame] | 6471 | execute( TC_pcu_socket_connect_multi() ); |
Harald Welte | c8effb7 | 2019-05-27 18:23:04 +0200 | [diff] [blame] | 6472 | execute( TC_pcu_socket_reconnect() ); |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 6473 | execute( TC_pcu_socket_noconnect_nosi3gprs() ); |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 6474 | execute( TC_pcu_socket_noconnect_nosi4gprs() ); |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 6475 | execute( TC_pcu_socket_connect_si3gprs() ); |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 6476 | execute( TC_pcu_socket_connect_si4gprs() ); |
Harald Welte | be03048 | 2019-05-27 22:29:35 +0200 | [diff] [blame] | 6477 | execute( TC_pcu_socket_disconnect_nosi3gprs() ); |
Vadim Yanitskiy | a8e83a8 | 2020-05-04 16:05:12 +0700 | [diff] [blame] | 6478 | execute( TC_pcu_socket_disconnect_nosi4gprs() ); |
Oliver Smith | f5239c7 | 2019-08-28 10:01:25 +0200 | [diff] [blame] | 6479 | execute( TC_pcu_socket_verify_info_ind() ); |
Philipp Maier | 15cd687 | 2020-01-08 13:41:41 +0100 | [diff] [blame] | 6480 | execute( TC_dyn_osmo_pdch_act_deact() ); |
| 6481 | execute( TC_dyn_osmo_pdch_double_act() ); |
| 6482 | execute( TC_dyn_ipa_pdch_act_deact() ); |
| 6483 | execute( TC_dyn_ipa_pdch_act_tchf_act_nack() ); |
| 6484 | |
Pau Espin Pedrol | a14a8af | 2018-11-20 13:12:22 +0100 | [diff] [blame] | 6485 | } else { |
| 6486 | log("PCU socket path not available, skipping PCU tests"); |
| 6487 | } |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 6488 | |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 6489 | execute( TC_dyn_osmo_pdch_unsol_deact() ); |
Harald Welte | 3d04ae6 | 2018-04-04 20:29:05 +0200 | [diff] [blame] | 6490 | execute( TC_dyn_osmo_pdch_tchf_act() ); |
| 6491 | execute( TC_dyn_osmo_pdch_tchh_act() ); |
Harald Welte | 9bbbfb5 | 2018-04-05 09:33:19 +0200 | [diff] [blame] | 6492 | execute( TC_dyn_ipa_pdch_tchf_act() ); |
| 6493 | execute( TC_dyn_ipa_pdch_tchf_act_pdch_act_nack() ); |
Harald Welte | 0472ab4 | 2018-03-12 15:02:26 +0100 | [diff] [blame] | 6494 | |
| 6495 | execute( TC_rll_est_ind() ); |
| 6496 | execute( TC_rll_est_req_DCCH_3() ); |
| 6497 | execute( TC_rll_est_req_ACCH_3() ); |
| 6498 | execute( TC_rll_rel_ind_DCCH_0() ); |
| 6499 | execute( TC_rll_rel_ind_DCCH_3() ); |
| 6500 | execute( TC_rll_rel_ind_ACCH_0() ); |
| 6501 | execute( TC_rll_rel_ind_ACCH_3() ); |
| 6502 | execute( TC_rll_rel_req() ); |
| 6503 | execute( TC_rll_unit_data_req_DCCH() ); |
| 6504 | execute( TC_rll_unit_data_req_ACCH() ); |
| 6505 | execute( TC_rll_unit_data_ind_DCCH() ); |
| 6506 | execute( TC_rll_unit_data_ind_ACCH() ); |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 6507 | |
| 6508 | execute( TC_chan_act_a51() ); |
| 6509 | execute( TC_chan_act_a52() ); |
| 6510 | execute( TC_chan_act_a53() ); |
| 6511 | execute( TC_encr_cmd_a51() ); |
| 6512 | execute( TC_encr_cmd_a52() ); |
| 6513 | execute( TC_encr_cmd_a53() ); |
| 6514 | |
Harald Welte | ee25aae | 2019-05-19 14:32:37 +0200 | [diff] [blame] | 6515 | execute( TC_err_rep_wrong_mdisc() ); |
| 6516 | execute( TC_err_rep_wrong_msg_type() ); |
| 6517 | execute( TC_err_rep_wrong_sequence() ); |
| 6518 | |
Harald Welte | e613f96 | 2018-04-18 22:38:16 +0200 | [diff] [blame] | 6519 | execute( TC_lapdm_selftest() ); |
Stefan Sperling | 4880be4 | 2018-08-07 18:12:59 +0200 | [diff] [blame] | 6520 | |
| 6521 | execute( TC_tch_sign_l2_fill_frame() ); |
| 6522 | execute( TC_tch_sign_l2_fill_frame_dtxd() ); |
Stefan Sperling | 0ec1c26 | 2018-10-15 15:12:52 +0200 | [diff] [blame] | 6523 | |
| 6524 | execute( TC_chopped_ipa_ping() ); |
Stefan Sperling | aa1e60f | 2018-10-15 16:34:07 +0200 | [diff] [blame] | 6525 | execute( TC_chopped_ipa_payload() ); |
Harald Welte | 7076738 | 2018-02-21 12:16:40 +0100 | [diff] [blame] | 6526 | } |
| 6527 | |
| 6528 | |
| 6529 | } |